@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.
- package/CHANGELOG.md +187 -0
- package/LICENSE +21 -0
- package/README.md +495 -0
- package/dist/client.d.ts +529 -0
- package/dist/client.js +874 -0
- package/dist/client.js.map +1 -0
- package/dist/core.d.ts +77 -0
- package/dist/core.js +223 -0
- package/dist/core.js.map +1 -0
- package/dist/errors.d.ts +300 -0
- package/dist/errors.js +403 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/pagination.d.ts +34 -0
- package/dist/pagination.js +67 -0
- package/dist/pagination.js.map +1 -0
- package/dist/session.d.ts +252 -0
- package/dist/session.js +345 -0
- package/dist/session.js.map +1 -0
- package/dist/streaming.d.ts +7 -0
- package/dist/streaming.js +71 -0
- package/dist/streaming.js.map +1 -0
- package/dist/types.d.ts +2147 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +3 -0
- package/dist/version.js.map +1 -0
- package/dist/webhooks.d.ts +27 -0
- package/dist/webhooks.js +184 -0
- package/dist/webhooks.js.map +1 -0
- package/package.json +59 -0
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,529 @@
|
|
|
1
|
+
import { type CoreConfig, type Query, type RequestOptions, type SendInit } from "./core.js";
|
|
2
|
+
import { Page, PagePromise } from "./pagination.js";
|
|
3
|
+
import { Session } from "./session.js";
|
|
4
|
+
import type { ActionItem, ActionResult, AgentMessageSent, AgentModelCatalog, AgentRun, AgentRunEvent, AgentRunParams, AgentRunStarted, ContinueRunParams, ApiKeyInfo, BulkResult, ComputerAction, ComputerOptions, ComputerResult, ContextInfo, LoginDetails, LoginDetailsUpdate, MoveShell, Secret, SecretAuditEntry, SecretAuditParams, SecretCreateParams, SecretUpdateParams, CrawlGetParams, CrawlJob, CrawlPage, CrawlParams, CreateSessionParams, ExecExit, ExecOptions, ExecResult, ExtensionInfo, ExtractParams, ExtractResult, FetchParams, FetchResult, FileList, FileRef, ListParams, LoginResponse, Me, MoveTimings, NewApiKey, NewWebhookEndpoint, ProjectSettings as ProjectSettingsData, AgentProvider, ModelKey, ModelKeyParams, CaptchaMode, WebhookCreateParams, WebhookDelivery, WebhookDeliveryListParams, WebhookEndpoint, WebhookEventType, WebhookEventTypeList, WebhookUpdateParams, PdfParams, PlanFeature, Pricing, Recording, RunScriptOptions, ScreenshotParams, ScriptResult, SearchParams, SearchResponse, SessionEvent, SessionEventsParams, SessionListParams, SessionUrls, SignupResponse, Stats, Task, TaskCreateParams, TaskRun, TaskRunListParams, TaskRunParams, TaskUpdateParams, TrajectoriesSetting, UpdateSessionParams, Usage, VisitedPage } from "./types.js";
|
|
5
|
+
export interface BoxlineOptions {
|
|
6
|
+
/** Defaults to the BOXLINE_API_KEY environment variable. */
|
|
7
|
+
apiKey?: string;
|
|
8
|
+
/** Defaults to BOXLINE_API_URL, then https://api.boxline.dev (a local API: http://localhost:8080). */
|
|
9
|
+
baseUrl?: string;
|
|
10
|
+
/** Send the dashboard cookie instead of an API key (browser apps on the same site). */
|
|
11
|
+
credentials?: RequestCredentials;
|
|
12
|
+
/** A fetch implementation (default: the global fetch). */
|
|
13
|
+
fetch?: typeof fetch;
|
|
14
|
+
/** Retries after network errors, 429 and 5xx, for GETs and for POSTs with an Idempotency-Key (default 2). */
|
|
15
|
+
maxRetries?: number;
|
|
16
|
+
/** Time limit per request in ms (default 120 000; streams: until the response starts). */
|
|
17
|
+
timeoutMs?: number;
|
|
18
|
+
/** Headers sent with every request. */
|
|
19
|
+
headers?: Record<string, string>;
|
|
20
|
+
}
|
|
21
|
+
/** Where the SDK goes without baseUrl or BOXLINE_API_URL (the same default as the CLI). */
|
|
22
|
+
export declare const DEFAULT_BASE_URL = "https://api.boxline.dev";
|
|
23
|
+
/**
|
|
24
|
+
* Client for the Boxline API: isolated cloud sessions with a Chrome browser, a bash shell and a shared disk, plus
|
|
25
|
+
* the web APIs and the AI agent. Works in Node 18+ and modern browsers (it uses the global fetch).
|
|
26
|
+
*
|
|
27
|
+
* const bx = new Boxline(); // BOXLINE_API_KEY; BOXLINE_API_URL (default https://api.boxline.dev)
|
|
28
|
+
* const s = await bx.sessions.create();
|
|
29
|
+
* const browser = await chromium.connectOverCDP(s.connectUrl!);
|
|
30
|
+
*/
|
|
31
|
+
export declare class Boxline {
|
|
32
|
+
readonly baseUrl: string;
|
|
33
|
+
readonly auth: Auth;
|
|
34
|
+
readonly project: ProjectSettings;
|
|
35
|
+
readonly apiKeys: ApiKeys;
|
|
36
|
+
readonly sessions: Sessions;
|
|
37
|
+
readonly contexts: Contexts;
|
|
38
|
+
readonly crawl: Crawl;
|
|
39
|
+
readonly agent: Agent;
|
|
40
|
+
readonly tasks: Tasks;
|
|
41
|
+
readonly secrets: Secrets;
|
|
42
|
+
readonly webhooks: Webhooks;
|
|
43
|
+
readonly extensions: Extensions;
|
|
44
|
+
/** @internal */
|
|
45
|
+
readonly cfg: CoreConfig;
|
|
46
|
+
private readonly options;
|
|
47
|
+
constructor(opts?: BoxlineOptions);
|
|
48
|
+
/** What JSON.stringify shows: where the client points, never its key. */
|
|
49
|
+
toJSON(): {
|
|
50
|
+
baseUrl: string;
|
|
51
|
+
maxRetries: number;
|
|
52
|
+
timeoutMs: number;
|
|
53
|
+
};
|
|
54
|
+
/** A client like this one with some options changed, e.g. `bx.withOptions({ maxRetries: 5 })`. */
|
|
55
|
+
withOptions(opts: BoxlineOptions): Boxline;
|
|
56
|
+
/** The calling user/project, its plan's limits and features, and whether it is suspended. */
|
|
57
|
+
me(options?: RequestOptions): Promise<Me>;
|
|
58
|
+
/** True when the project's plan includes `feature` (calls using a missing feature fail with 402 feature_not_in_plan). */
|
|
59
|
+
hasFeature(feature: PlanFeature, options?: RequestOptions): Promise<boolean>;
|
|
60
|
+
/** Fetch API: open a URL in a real browser (inside a sandbox) and get Markdown, HTML or text back. */
|
|
61
|
+
fetch(url: string, params?: FetchParams, options?: RequestOptions): Promise<FetchResult>;
|
|
62
|
+
/** A screenshot of any URL (fresh browser context each time). Returns the image bytes. */
|
|
63
|
+
screenshot(url: string, params?: ScreenshotParams, options?: RequestOptions): Promise<Uint8Array>;
|
|
64
|
+
/** A PDF of any URL, printed like Chrome's "Save as PDF". Returns the PDF bytes. */
|
|
65
|
+
pdf(url: string, params?: PdfParams, options?: RequestOptions): Promise<Uint8Array>;
|
|
66
|
+
/**
|
|
67
|
+
* Structured data from one or more pages: they are rendered in a real browser, then a model fills `schema`
|
|
68
|
+
* (JSON Schema) and/or follows `prompt`. Defaults to a fast, low-cost model.
|
|
69
|
+
*/
|
|
70
|
+
extract<T = unknown>(params: ExtractParams, options?: RequestOptions): Promise<ExtractResult<T>>;
|
|
71
|
+
/**
|
|
72
|
+
* Web search (the platform's provider, Brave): titles, URLs, snippets and dates. With `fetch`, the top pages are
|
|
73
|
+
* also opened in a sandboxed browser and returned as Markdown (`content`). The same search within an hour is
|
|
74
|
+
* answered from the cache (`cached: true`, not counted). The query text goes to the provider: keep secrets and
|
|
75
|
+
* personal data out of it. 503 `search_unavailable` (SearchUnavailableError) when search is not set up.
|
|
76
|
+
*/
|
|
77
|
+
search(params: SearchParams, options?: RequestOptions): Promise<SearchResponse>;
|
|
78
|
+
/** Usage and cost of the sessions created in a period (default: this month so far). */
|
|
79
|
+
usage(params?: {
|
|
80
|
+
from?: string;
|
|
81
|
+
to?: string;
|
|
82
|
+
}, options?: RequestOptions): Promise<Usage>;
|
|
83
|
+
/** Totals and per-day numbers for the last `days` days (UTC, including today). */
|
|
84
|
+
stats(days?: number, options?: RequestOptions): Promise<Stats>;
|
|
85
|
+
/** The public price table and plans (no API key needed). */
|
|
86
|
+
pricing(options?: RequestOptions): Promise<Pricing>;
|
|
87
|
+
/** The OpenAPI 3.1 description of the API. */
|
|
88
|
+
openapi(options?: RequestOptions): Promise<Record<string, unknown>>;
|
|
89
|
+
/** `{ok: true}` when the API is up. */
|
|
90
|
+
health(options?: RequestOptions): Promise<{
|
|
91
|
+
ok: true;
|
|
92
|
+
}>;
|
|
93
|
+
/** Low-level request: parsed JSON (undefined for 204). The SDK's retry and error rules apply. */
|
|
94
|
+
request<T>(method: string, path: string, body?: unknown, options?: RequestOptions & Omit<SendInit, "as" | "body">): Promise<T>;
|
|
95
|
+
/** Low-level request returning the Response with its body unread (after checking for errors). */
|
|
96
|
+
send(method: string, path: string, body?: unknown, options?: RequestOptions & Omit<SendInit, "as" | "body">): Promise<Response>;
|
|
97
|
+
/** @internal */
|
|
98
|
+
bytes(method: string, path: string, body?: unknown, options?: RequestOptions): Promise<Uint8Array>;
|
|
99
|
+
/** @internal A list whose pages follow `next`; `map` turns each raw item into what the list yields. */
|
|
100
|
+
list<T, E extends object = object>(path: string, query: Query, map: (raw: any) => T, options?: RequestOptions): PagePromise<T, Page<T> & E>;
|
|
101
|
+
}
|
|
102
|
+
/** Sign-up and console logins. Server-side code uses an API key instead of logging in. */
|
|
103
|
+
export declare class Auth {
|
|
104
|
+
private readonly client;
|
|
105
|
+
constructor(client: Boxline);
|
|
106
|
+
/**
|
|
107
|
+
* Creates a user, a project on the Free plan and a first API key (in the response only). No API key needed.
|
|
108
|
+
* `acceptTerms: true` says the user accepts the terms of service and acceptable use policy (400
|
|
109
|
+
* `terms_not_accepted` without it); `name` is optional.
|
|
110
|
+
*/
|
|
111
|
+
signup(params: {
|
|
112
|
+
email: string;
|
|
113
|
+
password: string;
|
|
114
|
+
acceptTerms: true;
|
|
115
|
+
name?: string;
|
|
116
|
+
}, options?: RequestOptions): Promise<SignupResponse>;
|
|
117
|
+
/** Starts a console login (cookie `bx_session`): for browser apps with `credentials: "include"`. */
|
|
118
|
+
login(params: {
|
|
119
|
+
email: string;
|
|
120
|
+
password: string;
|
|
121
|
+
}, options?: RequestOptions): Promise<LoginResponse>;
|
|
122
|
+
/** Ends the console login. */
|
|
123
|
+
logout(options?: RequestOptions): Promise<void>;
|
|
124
|
+
}
|
|
125
|
+
/** Project settings. */
|
|
126
|
+
export declare class ProjectSettings {
|
|
127
|
+
private readonly client;
|
|
128
|
+
constructor(client: Boxline);
|
|
129
|
+
/** The Trajectories program setting: on by default; see the Terms of Service and Privacy Policy. */
|
|
130
|
+
trajectories(options?: RequestOptions): Promise<TrajectoriesSetting>;
|
|
131
|
+
/** Turns the Trajectories program on or off for this project (logged). */
|
|
132
|
+
setTrajectories(enabled: boolean, opts?: {
|
|
133
|
+
source?: "notice" | "settings";
|
|
134
|
+
}, options?: RequestOptions): Promise<TrajectoriesSetting>;
|
|
135
|
+
/**
|
|
136
|
+
* The project's settings: `captchaDefault` is what new sessions and agent runs without a `captcha` option get;
|
|
137
|
+
* `captchaDefaultEffective` what they get now (the plan may no longer include solving).
|
|
138
|
+
*/
|
|
139
|
+
settings(options?: RequestOptions): Promise<ProjectSettingsData>;
|
|
140
|
+
/**
|
|
141
|
+
* Changes the fields you send (`captchaDefault: "solve"` needs a plan with CAPTCHA solving: 402 otherwise).
|
|
142
|
+
* `defaultModel` is the model used when a request names none; `null` clears it.
|
|
143
|
+
*/
|
|
144
|
+
setSettings(params: {
|
|
145
|
+
captchaDefault?: CaptchaMode;
|
|
146
|
+
defaultModel?: {
|
|
147
|
+
provider: AgentProvider;
|
|
148
|
+
model?: string;
|
|
149
|
+
} | null;
|
|
150
|
+
}, options?: RequestOptions): Promise<ProjectSettingsData>;
|
|
151
|
+
/** The four providers with the project's own-key state (never a key: `preview` is its last 4 characters). */
|
|
152
|
+
modelKeys(options?: RequestOptions): Promise<{
|
|
153
|
+
keys: ModelKey[];
|
|
154
|
+
}>;
|
|
155
|
+
/**
|
|
156
|
+
* Saves a provider key and/or the choice of whose key calls use. The provider checks the key first (400
|
|
157
|
+
* `invalid_model_key` when it refuses it). Runs on your own key have no model charge from Boxline.
|
|
158
|
+
*/
|
|
159
|
+
setModelKey(provider: AgentProvider, params: ModelKeyParams, options?: RequestOptions): Promise<ModelKey>;
|
|
160
|
+
/** Deletes the provider's key; calls go back to the platform's key where the plan includes it. */
|
|
161
|
+
deleteModelKey(provider: AgentProvider, options?: RequestOptions): Promise<void>;
|
|
162
|
+
}
|
|
163
|
+
/** The project's API keys. */
|
|
164
|
+
export declare class ApiKeys {
|
|
165
|
+
private readonly client;
|
|
166
|
+
constructor(client: Boxline);
|
|
167
|
+
/** Active keys, oldest first (the keys themselves are never shown again; `prefix` identifies them). */
|
|
168
|
+
list(params?: ListParams, options?: RequestOptions): PagePromise<ApiKeyInfo>;
|
|
169
|
+
/** A new key; `key` is in this response only. */
|
|
170
|
+
create(params?: {
|
|
171
|
+
name?: string;
|
|
172
|
+
}, options?: RequestOptions): Promise<NewApiKey>;
|
|
173
|
+
revoke(id: string, options?: RequestOptions): Promise<void>;
|
|
174
|
+
}
|
|
175
|
+
export type SessionPage = Page<Session> & {
|
|
176
|
+
total: number;
|
|
177
|
+
limit: number;
|
|
178
|
+
offset: number;
|
|
179
|
+
};
|
|
180
|
+
export declare class Sessions {
|
|
181
|
+
private readonly client;
|
|
182
|
+
readonly files: SessionFiles;
|
|
183
|
+
constructor(client: Boxline);
|
|
184
|
+
private wrap;
|
|
185
|
+
private one;
|
|
186
|
+
/** Starts a session (an Idempotency-Key is sent, so a retry never starts a second one). */
|
|
187
|
+
create(params?: CreateSessionParams, options?: RequestOptions): Promise<Session>;
|
|
188
|
+
get(id: string, options?: RequestOptions): Promise<Session>;
|
|
189
|
+
/**
|
|
190
|
+
* Sessions, newest first unless `sort` says otherwise. Await it for one page (`total` counts every match), or
|
|
191
|
+
* `for await (const s of bx.sessions.list())` for all of them.
|
|
192
|
+
*/
|
|
193
|
+
list(params?: SessionListParams, options?: RequestOptions): PagePromise<Session, SessionPage>;
|
|
194
|
+
/** @deprecated Use list(): its first page has `total` too. */
|
|
195
|
+
page(params?: SessionListParams, options?: RequestOptions): Promise<SessionPage>;
|
|
196
|
+
/** Pause, resume or release 1 to 100 sessions at once (session ids; 30 calls per minute per project). */
|
|
197
|
+
bulk(action: "release" | "pause" | "resume", ids: string[], options?: RequestOptions): Promise<BulkResult>;
|
|
198
|
+
/** Changes keepAlive, userMetadata, the proxy, the captcha option or the browser settings. */
|
|
199
|
+
update(id: string, patch: UpdateSessionParams, options?: RequestOptions): Promise<Session>;
|
|
200
|
+
/** Ends the session and deletes its machine. */
|
|
201
|
+
release(id: string, options?: RequestOptions): Promise<Session>;
|
|
202
|
+
/** Saves browser state and files, frees the machine and stops billing. Touching the session resumes it. */
|
|
203
|
+
pause(id: string, options?: RequestOptions): Promise<Session>;
|
|
204
|
+
resume(id: string, options?: RequestOptions): Promise<Session>;
|
|
205
|
+
/** Moves the live session to a fresh machine; clients reconnect to the same connectUrl. */
|
|
206
|
+
move(id: string, options?: RequestOptions): Promise<{
|
|
207
|
+
session: Session;
|
|
208
|
+
timings: MoveTimings;
|
|
209
|
+
shell: MoveShell | null;
|
|
210
|
+
}>;
|
|
211
|
+
/** Adds time (60–3600 s), up to the plan's maximum session length. */
|
|
212
|
+
extend(id: string, seconds: number, options?: RequestOptions): Promise<Session>;
|
|
213
|
+
/** A new IP for the session's proxy. */
|
|
214
|
+
rotateProxy(id: string, options?: RequestOptions): Promise<Session>;
|
|
215
|
+
/** Revokes the session's connect, live and terminal URLs and returns the session with fresh ones. */
|
|
216
|
+
rotateUrls(id: string, options?: RequestOptions): Promise<Session>;
|
|
217
|
+
/** Fresh signed URLs (treat them like passwords). */
|
|
218
|
+
live(id: string, options?: RequestOptions): Promise<SessionUrls>;
|
|
219
|
+
/**
|
|
220
|
+
* Runs browser actions in order, next to the browser; stops at the first failure. A bare string is a plain-English
|
|
221
|
+
* step: `["click Sign in", {action: "fill", selector: "#q", value: "x"}]`. Each result's `text` says what happened.
|
|
222
|
+
*/
|
|
223
|
+
actions(id: string, actions: ActionItem[] | ActionItem, opts?: {
|
|
224
|
+
timeoutMs?: number;
|
|
225
|
+
}, options?: RequestOptions): Promise<ActionResult[]>;
|
|
226
|
+
/**
|
|
227
|
+
* Runs ONE computer-use action exactly as the model's tool gave it (Anthropic `computer` tool input, or one OpenAI
|
|
228
|
+
* `computer_call` action) on the session's page, and returns the screen after it. With `maxWidth` the screenshot is
|
|
229
|
+
* scaled down and the action's coordinates are read in its pixels. A failure in the page is `ok: false`; input that
|
|
230
|
+
* cannot be mapped, or a point off the screen, throws (400 `invalid_request` / `out_of_viewport`).
|
|
231
|
+
*/
|
|
232
|
+
computer(id: string, action: ComputerAction, opts?: ComputerOptions, options?: RequestOptions): Promise<ComputerResult>;
|
|
233
|
+
/** Runs a shell command (persistent bash by default: cd/export survive between calls). */
|
|
234
|
+
/**
|
|
235
|
+
* Runs a command and returns its output. It is read as a stream (headers at once, the API keeps the connection
|
|
236
|
+
* alive), so neither a long command nor a wait for the session's setup runs into an HTTP client's own limits
|
|
237
|
+
* (Node's fetch gives up after 300 s without headers or data). Output past 64 KB is cut in the middle, as
|
|
238
|
+
* `truncated` says.
|
|
239
|
+
*/
|
|
240
|
+
exec(id: string, command: string, opts?: ExecOptions, options?: RequestOptions): Promise<ExecResult>;
|
|
241
|
+
/** Runs a command and streams its output as it happens; resolves with the exit information. */
|
|
242
|
+
execStream(id: string, command: string, onData: (stream: "stdout" | "stderr", data: string) => void, opts?: ExecOptions & {
|
|
243
|
+
signal?: AbortSignal;
|
|
244
|
+
}, options?: RequestOptions): Promise<ExecExit>;
|
|
245
|
+
/**
|
|
246
|
+
* Runs Playwright code inside the session's own sandbox (needs a shell), streaming its output to `onData`. In
|
|
247
|
+
* scope: `page`, `context`, `browser`, `env`, and `step()`, `extract()`, `useModel(model)` / `useModel(provider,
|
|
248
|
+
* model)`. A step or extract uses the call's own `{provider, model}`, else the last `useModel()`, else `ai`.
|
|
249
|
+
*/
|
|
250
|
+
runScript(id: string, code: string, opts?: RunScriptOptions, options?: RequestOptions): Promise<ScriptResult>;
|
|
251
|
+
/** Restarts the persistent shell (or the named one). */
|
|
252
|
+
restartShell(id: string, name?: string, options?: RequestOptions): Promise<void>;
|
|
253
|
+
/** Writes the browser's cookies as a Netscape cookie file in the workspace (for curl -b / wget). */
|
|
254
|
+
exportCookies(id: string, path?: string, options?: RequestOptions): Promise<{
|
|
255
|
+
path: string;
|
|
256
|
+
count: number;
|
|
257
|
+
}>;
|
|
258
|
+
/** Console, network, navigation, error, lifecycle, action, exec and captcha events, oldest first. */
|
|
259
|
+
events(id: string, params?: SessionEventsParams, options?: RequestOptions): PagePromise<SessionEvent, Page<SessionEvent> & {
|
|
260
|
+
nextAfter: number;
|
|
261
|
+
}>;
|
|
262
|
+
/** Events as they happen: first the backlog after `after`, then live. Stop with `break` or `options.signal`. */
|
|
263
|
+
streamEvents(id: string, params?: {
|
|
264
|
+
after?: number;
|
|
265
|
+
}, options?: RequestOptions): AsyncGenerator<SessionEvent>;
|
|
266
|
+
/** Pages visited, grouped by tab and URL, in the order they were first visited. */
|
|
267
|
+
pages(id: string, params?: ListParams, options?: RequestOptions): PagePromise<VisitedPage>;
|
|
268
|
+
/** Replay frames kept while the session ran. */
|
|
269
|
+
recording(id: string, options?: RequestOptions): Promise<Recording>;
|
|
270
|
+
/** One replay frame as JPEG bytes. */
|
|
271
|
+
recordingFrame(id: string, index: number, options?: RequestOptions): Promise<Uint8Array>;
|
|
272
|
+
}
|
|
273
|
+
export declare class SessionFiles {
|
|
274
|
+
private readonly client;
|
|
275
|
+
constructor(client: Boxline);
|
|
276
|
+
private url;
|
|
277
|
+
list(id: string, path?: string, options?: RequestOptions): Promise<FileList>;
|
|
278
|
+
/** A file's bytes. */
|
|
279
|
+
read(id: string, path: string, options?: RequestOptions): Promise<Uint8Array>;
|
|
280
|
+
readText(id: string, path: string, options?: RequestOptions): Promise<string>;
|
|
281
|
+
/** Writes a file (folders are made as needed). */
|
|
282
|
+
write(id: string, path: string, data: string | Uint8Array | Blob, options?: RequestOptions): Promise<FileRef>;
|
|
283
|
+
delete(id: string, path: string, options?: RequestOptions): Promise<void>;
|
|
284
|
+
/** Waits for a file matching a glob (e.g. `downloads/*.csv`) that has finished writing. */
|
|
285
|
+
waitFor(id: string, pattern: string, timeoutMs?: number, options?: RequestOptions): Promise<FileRef>;
|
|
286
|
+
}
|
|
287
|
+
/** Saved logins: cookies and local storage to start sessions with (`context: {id, persist: true}` fills one). */
|
|
288
|
+
export declare class Contexts {
|
|
289
|
+
private readonly client;
|
|
290
|
+
constructor(client: Boxline);
|
|
291
|
+
/**
|
|
292
|
+
* A new saved login: empty, or with `fromSession` holding that working session's current cookies and site storage
|
|
293
|
+
* (sign in there first, e.g. in its live view). `attach: true` also makes the session save to it from now on (at its
|
|
294
|
+
* checkpoints and when it ends); a session that already has a saved login refuses that (409 `conflict`). 413
|
|
295
|
+
* `context_too_large` over 16 MB; PlanLimitError (402) past the plan's `maxContexts` or `maxContextBytes`.
|
|
296
|
+
*/
|
|
297
|
+
create(params?: {
|
|
298
|
+
name?: string;
|
|
299
|
+
fromSession?: string;
|
|
300
|
+
attach?: boolean;
|
|
301
|
+
}, options?: RequestOptions): Promise<ContextInfo>;
|
|
302
|
+
get(id: string, options?: RequestOptions): Promise<ContextInfo>;
|
|
303
|
+
/** Newest first; the first page's `total` counts them all. */
|
|
304
|
+
list(params?: ListParams, options?: RequestOptions): PagePromise<ContextInfo, Page<ContextInfo> & {
|
|
305
|
+
total: number;
|
|
306
|
+
}>;
|
|
307
|
+
rename(id: string, name: string, options?: RequestOptions): Promise<ContextInfo>;
|
|
308
|
+
delete(id: string, options?: RequestOptions): Promise<void>;
|
|
309
|
+
/**
|
|
310
|
+
* Keeps sign-in details on the saved login (plan feature `loginDetails`), replacing earlier ones: the site, user name,
|
|
311
|
+
* password and optionally the 2FA setup key, sealed like secrets. Returns the context, whose `login` shows
|
|
312
|
+
* `{origin, username, hasPassword, hasTotp}`, never the password or the 2FA secret.
|
|
313
|
+
*/
|
|
314
|
+
setLogin(id: string, details: LoginDetails, options?: RequestOptions): Promise<ContextInfo>;
|
|
315
|
+
/**
|
|
316
|
+
* Changes some of the login details and keeps the rest (setLogin replaces them all); `totpSecret: null` removes 2FA.
|
|
317
|
+
* A password never moves to another site on its own: a new `origin` needs `password` in the same call, and
|
|
318
|
+
* `totpSecret` (a new one or null) when the login has 2FA (400 otherwise). A BoxlineError with code `conflict` (409)
|
|
319
|
+
* when the login changed meanwhile: send it again.
|
|
320
|
+
*/
|
|
321
|
+
updateLogin(id: string, changes: LoginDetailsUpdate, options?: RequestOptions): Promise<ContextInfo>;
|
|
322
|
+
/** Removes the login details (the saved cookies and storage stay). */
|
|
323
|
+
deleteLogin(id: string, options?: RequestOptions): Promise<void>;
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Project secrets: write-only values the AI uses as %NAME% placeholders (`secrets` on agent runs, steps and scripts) and
|
|
327
|
+
* shells get as environment variables (`secrets` on sessions.create and exec), depending on each secret's `scope`. The
|
|
328
|
+
* value is never returned, logged or shown; every change and use is audited.
|
|
329
|
+
*/
|
|
330
|
+
export declare class Secrets {
|
|
331
|
+
private readonly client;
|
|
332
|
+
constructor(client: Boxline);
|
|
333
|
+
/** The project's secrets, in name order, without their values. */
|
|
334
|
+
list(params?: ListParams, options?: RequestOptions): PagePromise<Secret>;
|
|
335
|
+
/**
|
|
336
|
+
* Stores a secret, sealed; the answer never has the value. SecretExistsError for a name the project has (change it
|
|
337
|
+
* with update), PlanLimitError beyond the plan's `maxSecrets`. Not retried by the SDK (the API takes no
|
|
338
|
+
* Idempotency-Key here): a retry after a lost answer may meet SecretExistsError.
|
|
339
|
+
*/
|
|
340
|
+
create(params: SecretCreateParams, options?: RequestOptions): Promise<Secret>;
|
|
341
|
+
get(name: string, options?: RequestOptions): Promise<Secret>;
|
|
342
|
+
/**
|
|
343
|
+
* Changes the fields you send. A running agent run keeps the value it started with; a session that exports the secret
|
|
344
|
+
* gets the new value on its next machine (move, resume, recovery).
|
|
345
|
+
*/
|
|
346
|
+
update(name: string, patch: SecretUpdateParams, options?: RequestOptions): Promise<Secret>;
|
|
347
|
+
/** Deletes it; sessions that exported it no longer get it on their next machine. */
|
|
348
|
+
delete(name: string, options?: RequestOptions): Promise<void>;
|
|
349
|
+
/** Changes to secrets and saved login details, and each use (once per session, command, run or script), newest first. */
|
|
350
|
+
audit(params?: SecretAuditParams, options?: RequestOptions): PagePromise<SecretAuditEntry>;
|
|
351
|
+
}
|
|
352
|
+
/** Crawls: follow links from a start URL in the background (robots.txt respected); poll with get() or wait(). */
|
|
353
|
+
export declare class Crawl {
|
|
354
|
+
private readonly client;
|
|
355
|
+
constructor(client: Boxline);
|
|
356
|
+
start(params: CrawlParams, options?: RequestOptions): Promise<CrawlJob>;
|
|
357
|
+
/** The job and one page of its pages (`limit: 0` for the job only); `next` is the cursor of the following pages. */
|
|
358
|
+
get(id: string, params?: CrawlGetParams, options?: RequestOptions): Promise<CrawlJob>;
|
|
359
|
+
/** Jobs, newest first (without their pages). */
|
|
360
|
+
list(params?: ListParams, options?: RequestOptions): PagePromise<CrawlJob>;
|
|
361
|
+
cancel(id: string, options?: RequestOptions): Promise<CrawlJob>;
|
|
362
|
+
/** Every page crawled so far, in index order: `for await (const p of bx.crawl.pages(id))`. */
|
|
363
|
+
pages(id: string, params?: {
|
|
364
|
+
limit?: number;
|
|
365
|
+
}, options?: RequestOptions): AsyncGenerator<CrawlPage>;
|
|
366
|
+
/** Waits for the crawl to finish, then returns the job with every page in `data`. */
|
|
367
|
+
wait(id: string, opts?: {
|
|
368
|
+
pollMs?: number;
|
|
369
|
+
timeoutMs?: number;
|
|
370
|
+
}, options?: RequestOptions): Promise<CrawlJob>;
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Webhook endpoints: signed HTTPS callbacks when something finishes or needs a person. Verify each delivery with
|
|
374
|
+
* verifyWebhook(rawBody, header, secret) and drop event ids you have handled already.
|
|
375
|
+
*/
|
|
376
|
+
export declare class Webhooks {
|
|
377
|
+
private readonly client;
|
|
378
|
+
constructor(client: Boxline);
|
|
379
|
+
/** A new endpoint (public HTTPS only); `secret` ("whsec_…") is in this response only. */
|
|
380
|
+
create(params: WebhookCreateParams, options?: RequestOptions): Promise<NewWebhookEndpoint>;
|
|
381
|
+
/** The project's endpoints, oldest first (never their secrets). */
|
|
382
|
+
list(params?: ListParams, options?: RequestOptions): PagePromise<WebhookEndpoint>;
|
|
383
|
+
get(id: string, options?: RequestOptions): Promise<WebhookEndpoint>;
|
|
384
|
+
/** Changes the URL, events, description, or switches it on or off (`enabled: true` also forgets its failures). */
|
|
385
|
+
update(id: string, patch: WebhookUpdateParams, options?: RequestOptions): Promise<WebhookEndpoint>;
|
|
386
|
+
/** Deletes the endpoint with its queue and delivery log. */
|
|
387
|
+
delete(id: string, options?: RequestOptions): Promise<void>;
|
|
388
|
+
/** A new secret (in this response only); the old one keeps signing too for 24 hours (a second v1). */
|
|
389
|
+
rotateSecret(id: string, options?: RequestOptions): Promise<NewWebhookEndpoint>;
|
|
390
|
+
/**
|
|
391
|
+
* Sends a `webhook.test` event to this endpoint now, or with `type` a made-up sample of that event type (marked
|
|
392
|
+
* `test: true`); one attempt, waits up to 12 s for the answer.
|
|
393
|
+
*/
|
|
394
|
+
test(id: string, params?: {
|
|
395
|
+
type?: WebhookEventType | "webhook.test";
|
|
396
|
+
}, options?: RequestOptions): Promise<WebhookDelivery>;
|
|
397
|
+
/** Every event type an endpoint can subscribe to, with its group and description (subscribe to "*" for all). */
|
|
398
|
+
eventTypes(options?: RequestOptions): Promise<WebhookEventTypeList>;
|
|
399
|
+
/** The endpoint's deliveries, newest first, each with its attempt history; `status` filters them. */
|
|
400
|
+
deliveries(id: string, params?: WebhookDeliveryListParams, options?: RequestOptions): PagePromise<WebhookDelivery>;
|
|
401
|
+
/**
|
|
402
|
+
* Sends a finished delivery again now, with the same event id and body (409 invalid_state while it is still queued,
|
|
403
|
+
* PayloadExpiredError after 7 days, WebhookDisabledError while the endpoint is switched off).
|
|
404
|
+
*/
|
|
405
|
+
retryDelivery(id: string, deliveryId: string, options?: RequestOptions): Promise<WebhookDelivery>;
|
|
406
|
+
}
|
|
407
|
+
export interface WaitOptions {
|
|
408
|
+
/** How often to look, in ms (default 1000). */
|
|
409
|
+
pollMs?: number;
|
|
410
|
+
/** Give up after this long, in ms (default 30 minutes): BoxlineTimeoutError. */
|
|
411
|
+
timeoutMs?: number;
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* Tasks: saved agent runs (an instruction with %name% variables, an optional output schema, browser settings, a saved
|
|
415
|
+
* login and a model), run by hand or on a schedule. Every run is an agent run tagged with the task. Needs the plan's
|
|
416
|
+
* `agentRuns`; the plan limits tasks and schedules switched on (PlanLimitError).
|
|
417
|
+
*/
|
|
418
|
+
export declare class Tasks {
|
|
419
|
+
private readonly client;
|
|
420
|
+
constructor(client: Boxline);
|
|
421
|
+
/** Saves a task (an Idempotency-Key is sent, so a retry never saves it twice). */
|
|
422
|
+
create(params: TaskCreateParams, options?: RequestOptions): Promise<Task>;
|
|
423
|
+
/** The project's tasks, newest first. */
|
|
424
|
+
list(params?: ListParams, options?: RequestOptions): PagePromise<Task>;
|
|
425
|
+
get(id: string, options?: RequestOptions): Promise<Task>;
|
|
426
|
+
/**
|
|
427
|
+
* Changes the fields you send; `null` removes an optional one. `schedule` fields are merged into the current schedule
|
|
428
|
+
* (`{schedule: {enabled: false}}` pauses it); switching it on, or changing cron or timezone, counts from now.
|
|
429
|
+
*/
|
|
430
|
+
update(id: string, patch: TaskUpdateParams, options?: RequestOptions): Promise<Task>;
|
|
431
|
+
/** Deletes the task with its run history (its agent runs stay, and runs in progress go on). */
|
|
432
|
+
delete(id: string, options?: RequestOptions): Promise<void>;
|
|
433
|
+
/**
|
|
434
|
+
* Runs the task now and returns its task run (status running) right away; waitForRun() waits for the result. Plain
|
|
435
|
+
* values are written into the instruction; secret ones must come with every run and go in as agent variables (the
|
|
436
|
+
* model sees only %name%). MissingVariablesError when a variable without a default has no value. Counts as an agent
|
|
437
|
+
* run (rate, plan, spend cap). An Idempotency-Key is sent, so a retry never starts a second run. `T`: the type of the
|
|
438
|
+
* result (the JSON answer when the task has an output schema).
|
|
439
|
+
*/
|
|
440
|
+
run<T = unknown>(id: string, params?: TaskRunParams, options?: RequestOptions): Promise<TaskRun<T>>;
|
|
441
|
+
/** The task's runs, newest first: by hand, on the schedule, and skipped or missed times (kept 30 days); `status` filters. */
|
|
442
|
+
runs<T = unknown>(id: string, params?: TaskRunListParams, options?: RequestOptions): PagePromise<TaskRun<T>>;
|
|
443
|
+
/**
|
|
444
|
+
* Polls until the task run has finished (completed, failed or canceled; a paused run keeps waiting for a person, a
|
|
445
|
+
* queued one for its turn) and returns it with its result. Pass the run that run() returned, or the task's and the
|
|
446
|
+
* run's ids. NotFoundError when the run is not in the task's history.
|
|
447
|
+
*
|
|
448
|
+
* const run = await bx.tasks.run<{ books: Book[] }>(task.id, { variables: { category: "Poetry" } });
|
|
449
|
+
* const done = await bx.tasks.waitForRun(run); // done.result: { books: Book[] } | null
|
|
450
|
+
*/
|
|
451
|
+
waitForRun<T = unknown>(run: TaskRun<T> | {
|
|
452
|
+
taskId: string;
|
|
453
|
+
id: string;
|
|
454
|
+
}, opts?: WaitOptions, options?: RequestOptions): Promise<TaskRun<T>>;
|
|
455
|
+
waitForRun<T = unknown>(taskId: string, taskRunId: string, opts?: WaitOptions, options?: RequestOptions): Promise<TaskRun<T>>;
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* Chrome extensions (Manifest V3) to start sessions with (`extensions: [id]`; plan feature `extensions`). An extension
|
|
459
|
+
* sees every page and every typed value in the sessions that use it: upload only extensions you trust.
|
|
460
|
+
*/
|
|
461
|
+
export declare class Extensions {
|
|
462
|
+
private readonly client;
|
|
463
|
+
constructor(client: Boxline);
|
|
464
|
+
/**
|
|
465
|
+
* Uploads an unpacked extension as a zip, at most 10 MB: its bytes, a Blob, or a file path (Node). It is checked
|
|
466
|
+
* before it is stored (InvalidExtensionError says why; PayloadTooLargeError over 10 MB; LimitReachedError beyond 100
|
|
467
|
+
* extensions). An Idempotency-Key is sent, so a retry never stores it twice.
|
|
468
|
+
*/
|
|
469
|
+
upload(zip: Uint8Array | ArrayBuffer | Blob | string, options?: RequestOptions): Promise<ExtensionInfo>;
|
|
470
|
+
/** The project's extensions, newest first. */
|
|
471
|
+
list(params?: ListParams, options?: RequestOptions): PagePromise<ExtensionInfo>;
|
|
472
|
+
get(id: string, options?: RequestOptions): Promise<ExtensionInfo>;
|
|
473
|
+
/** Deletes it; sessions already running with it keep it until they move or resume. */
|
|
474
|
+
delete(id: string, options?: RequestOptions): Promise<void>;
|
|
475
|
+
}
|
|
476
|
+
/** Agent runs: a model (Claude or GPT) drives the session's browser and shell to finish a task. */
|
|
477
|
+
export declare class Agent {
|
|
478
|
+
private readonly client;
|
|
479
|
+
constructor(client: Boxline);
|
|
480
|
+
/** Providers and models customers can choose, with prices and whether each is configured on the server. */
|
|
481
|
+
models(options?: RequestOptions): Promise<AgentModelCatalog>;
|
|
482
|
+
/**
|
|
483
|
+
* Starts a run and returns right away (an Idempotency-Key is sent, so a retry never starts a second run). With
|
|
484
|
+
* `output` (a JSON Schema) the answer is JSON matching it: read it with `wait<T>(id)` or `get<T>(id)`.
|
|
485
|
+
*/
|
|
486
|
+
run(params: AgentRunParams, options?: RequestOptions): Promise<AgentRunStarted>;
|
|
487
|
+
/** The run with its steps. `T`: the type of `result` (text by default; the JSON answer's type with an output schema). */
|
|
488
|
+
get<T = string>(id: string, options?: RequestOptions): Promise<AgentRun<T>>;
|
|
489
|
+
/** Runs, newest first. */
|
|
490
|
+
list(params?: ListParams, options?: RequestOptions): PagePromise<AgentRun>;
|
|
491
|
+
/** Take the browser from the agent (it finishes its current action, then waits). RunNotLiveError when its server stopped. */
|
|
492
|
+
takeover(id: string, reason?: string, options?: RequestOptions): Promise<AgentRun>;
|
|
493
|
+
/** Give the browser back; the agent reads `note` before it continues. RunNotLiveError when its server stopped: continueRun. */
|
|
494
|
+
handBack(id: string, note?: string, options?: RequestOptions): Promise<AgentRun>;
|
|
495
|
+
/** Stops the run for good. */
|
|
496
|
+
cancel(id: string, options?: RequestOptions): Promise<AgentRun>;
|
|
497
|
+
/**
|
|
498
|
+
* Continues a run that stopped at one of its limits (errorCode max_steps, max_cost, too_many_errors or no_progress)
|
|
499
|
+
* while its `continuable` is set: a new run in the same session, with the same model, mode, output schema, secrets
|
|
500
|
+
* and saved login, and a compact record of what the previous run did. Returns the new run (`continuedFrom` links
|
|
501
|
+
* back); wait for it with `wait(run.id)` or `stream(run.id)` like any run. A run that had `variables` needs them again
|
|
502
|
+
* (MissingVariablesError otherwise). NotContinuableError: it did not stop at a limit, was continued already, or its
|
|
503
|
+
* window passed. An Idempotency-Key is sent, so a retry never starts a second run.
|
|
504
|
+
*
|
|
505
|
+
* `const next = await bx.agent.continueRun(run.id, { maxSteps: 30, instruction: "The CSV is downloaded already" })`
|
|
506
|
+
*/
|
|
507
|
+
continueRun<T = string>(id: string, params?: ContinueRunParams, options?: RequestOptions): Promise<AgentRun<T>>;
|
|
508
|
+
/**
|
|
509
|
+
* Tells a working run something (1–2000 characters) without taking the browser: the agent reads it at its next step
|
|
510
|
+
* (a model call or tool under way is not interrupted), and it shows as a `message` step. A run waiting for your help
|
|
511
|
+
* (ask_user_for_help) takes it as the answer and goes on. At most 50 per run; InvalidStateError-like 409
|
|
512
|
+
* (a BoxlineError with code `invalid_state`) once the run has finished, TooManyMessagesError after 50.
|
|
513
|
+
*/
|
|
514
|
+
sendMessage(id: string, text: string, options?: RequestOptions): Promise<AgentMessageSent>;
|
|
515
|
+
/**
|
|
516
|
+
* The run as it happens: its steps so far, then new steps, `status` changes, live shell `exec`/`output`, and a
|
|
517
|
+
* final `done` event, after which the iteration ends.
|
|
518
|
+
*/
|
|
519
|
+
stream<T = string>(id: string, options?: RequestOptions): AsyncGenerator<AgentRunEvent<T>>;
|
|
520
|
+
/**
|
|
521
|
+
* Polls until the run finishes (a paused run keeps waiting for the user). `T` as on get():
|
|
522
|
+
* `const run = await bx.agent.wait<{ books: Book[] }>(id)`.
|
|
523
|
+
*/
|
|
524
|
+
wait<T = string>(id: string, opts?: {
|
|
525
|
+
pollMs?: number;
|
|
526
|
+
timeoutMs?: number;
|
|
527
|
+
}, options?: RequestOptions): Promise<AgentRun<T>>;
|
|
528
|
+
}
|
|
529
|
+
export default Boxline;
|