@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/types.d.ts
ADDED
|
@@ -0,0 +1,2147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The API's objects, as in docs/openapi.yaml (and docs/CONTRACT.md). Dates are ISO 8601 strings.
|
|
3
|
+
*/
|
|
4
|
+
export type SessionStatus = "RUNNING" | "PAUSED" | "COMPLETED" | "ERROR";
|
|
5
|
+
/** What happens when a CAPTCHA waits for a person: "ask" (default) pauses and hands over, "ignore" carries on, "solve" tries to solve it first. */
|
|
6
|
+
export type CaptchaMode = "ask" | "ignore" | "solve";
|
|
7
|
+
/** A CAPTCHA provider the platform recognises. */
|
|
8
|
+
export type CaptchaKind = "recaptcha" | "hcaptcha" | "turnstile" | "cloudflare" | "datadome" | "arkose" | "human";
|
|
9
|
+
export type WaitUntil = "load" | "domcontentloaded" | "networkidle" | "commit";
|
|
10
|
+
/** Model providers: Anthropic Claude, OpenAI, Grok (xAI) and Google Gemini. Grok and Gemini have no computer use (mode "computer"). */
|
|
11
|
+
export type AgentProvider = "anthropic" | "openai" | "xai" | "google";
|
|
12
|
+
/** Whose key a model call uses: the project's own ("project": no model charge from Boxline) or the platform's. */
|
|
13
|
+
export type ModelKeySource = "project" | "platform";
|
|
14
|
+
export interface Viewport {
|
|
15
|
+
width: number;
|
|
16
|
+
height: number;
|
|
17
|
+
}
|
|
18
|
+
export interface User {
|
|
19
|
+
id: string;
|
|
20
|
+
email: string;
|
|
21
|
+
/** The user's name (signup, login and `me`), or null. */
|
|
22
|
+
name?: string | null;
|
|
23
|
+
}
|
|
24
|
+
export interface Suspension {
|
|
25
|
+
at: string;
|
|
26
|
+
reason: string | null;
|
|
27
|
+
}
|
|
28
|
+
export interface Project {
|
|
29
|
+
id: string;
|
|
30
|
+
name: string;
|
|
31
|
+
plan: string;
|
|
32
|
+
suspended?: Suspension | null;
|
|
33
|
+
}
|
|
34
|
+
export interface SignupResponse {
|
|
35
|
+
user: User;
|
|
36
|
+
project: Project;
|
|
37
|
+
/** The first API key, shown only here. */
|
|
38
|
+
apiKey: string;
|
|
39
|
+
}
|
|
40
|
+
export interface LoginResponse {
|
|
41
|
+
user: User;
|
|
42
|
+
project: Project;
|
|
43
|
+
}
|
|
44
|
+
/** What a plan may use; set per plan in the admin panel. Calls that need a missing one fail with 402 `feature_not_in_plan`. */
|
|
45
|
+
export type PlanFeature = "shell" | "pauseResume" | "contexts" | "recording" | "realisticBrowser" | "residentialProxy" | "datacenterProxy" | "customProxy" | "captchaSolving" | "agentRuns" | "steps" | "extract" | "quickApis" | "crawl" | "extensions" | "webSearch" | "loginDetails"
|
|
46
|
+
/** Model calls on Boxline's keys; without it (Free) a project runs models on its own keys only. */
|
|
47
|
+
| "platformModels";
|
|
48
|
+
/** A plan's limits (null = no limit) and features. */
|
|
49
|
+
export interface Plan {
|
|
50
|
+
id?: string;
|
|
51
|
+
name: string;
|
|
52
|
+
priceUsd: number | null;
|
|
53
|
+
includedUsd: number;
|
|
54
|
+
concurrency: number;
|
|
55
|
+
maxTimeoutSeconds: number;
|
|
56
|
+
modelSpendCapUsd: number | null;
|
|
57
|
+
proxyGbPerMonth: number | null;
|
|
58
|
+
/** 0 = not on this plan, null = no cap. */
|
|
59
|
+
captchaSolvesPerMonth: number | null;
|
|
60
|
+
/** Web searches included per calendar month (UTC); null = no limit. */
|
|
61
|
+
searchesPerMonth: number | null;
|
|
62
|
+
/** Price per 1,000 searches beyond searchesPerMonth; null = no searches beyond it (402 plan_limit). */
|
|
63
|
+
extraSearchesPer1000Usd: number | null;
|
|
64
|
+
/** Webhook endpoints a project may have; null = no limit. */
|
|
65
|
+
webhookEndpoints: number | null;
|
|
66
|
+
/** Days an ended session's recording, logs and agent-run steps are kept (then deleted; the session stays). */
|
|
67
|
+
retentionDays: number;
|
|
68
|
+
/** Tasks a project may have; null = no plan limit (1,000 per project at most). */
|
|
69
|
+
tasks?: number | null;
|
|
70
|
+
/** Tasks with a schedule switched on; 0 = no schedules, null = no limit. */
|
|
71
|
+
schedules?: number | null;
|
|
72
|
+
/** Project secrets a project may keep. */
|
|
73
|
+
maxSecrets?: number;
|
|
74
|
+
/** Saved logins (contexts) a project may keep; null = no limit. */
|
|
75
|
+
maxContexts?: number | null;
|
|
76
|
+
/** Bytes a project's saved logins may hold together; null = no limit. */
|
|
77
|
+
maxContextBytes?: number | null;
|
|
78
|
+
features: Record<PlanFeature, boolean>;
|
|
79
|
+
public?: boolean;
|
|
80
|
+
}
|
|
81
|
+
/** @deprecated Use Plan. */
|
|
82
|
+
export type PlanLimits = Plan;
|
|
83
|
+
/** The project's settings (GET/PUT /v1/project/settings). */
|
|
84
|
+
export interface ProjectSettings {
|
|
85
|
+
/** What new sessions and agent runs without a `captcha` option get (default "ask"). */
|
|
86
|
+
captchaDefault: CaptchaMode;
|
|
87
|
+
/** What they get now: "ask" when the setting is "solve" but the plan no longer includes solving. */
|
|
88
|
+
captchaDefaultEffective: CaptchaMode;
|
|
89
|
+
/** The model used when a request names no provider or model (explicit request, then this, then the server default); null: none. */
|
|
90
|
+
defaultModel: {
|
|
91
|
+
provider: AgentProvider;
|
|
92
|
+
model: string;
|
|
93
|
+
} | null;
|
|
94
|
+
updatedAt: string | null;
|
|
95
|
+
/** The project's own user who changed it last in the console (null for an API key or support). */
|
|
96
|
+
updatedBy: string | null;
|
|
97
|
+
/** How it was changed last; null if never. */
|
|
98
|
+
updatedVia: "console" | "api_key" | "support" | null;
|
|
99
|
+
}
|
|
100
|
+
/** One provider's own-key state (GET/PUT /v1/project/model-keys). The key itself is never returned. */
|
|
101
|
+
export interface ModelKey {
|
|
102
|
+
provider: AgentProvider;
|
|
103
|
+
/** The stored choice: calls use the project's own key or the platform's. */
|
|
104
|
+
use: ModelKeySource;
|
|
105
|
+
/** What calls use now: the plan can override the choice (Free: always "project"). */
|
|
106
|
+
useEffective: ModelKeySource;
|
|
107
|
+
hasKey: boolean;
|
|
108
|
+
/** The last 4 characters of the key, or null. */
|
|
109
|
+
preview: string | null;
|
|
110
|
+
/** The provider accepted the key when it was saved (false: the provider could not be reached; the key was saved). */
|
|
111
|
+
verified: boolean | null;
|
|
112
|
+
createdAt: string | null;
|
|
113
|
+
updatedAt: string | null;
|
|
114
|
+
updatedVia: "console" | "api_key" | "support" | null;
|
|
115
|
+
lastUsedAt: string | null;
|
|
116
|
+
/** The platform can make calls for this provider for this project (a server key exists and the plan includes it). */
|
|
117
|
+
platformAvailable: boolean;
|
|
118
|
+
}
|
|
119
|
+
export interface ModelKeyParams {
|
|
120
|
+
/** The provider key (20 to 400 characters). Saving one without `use` sets `use: "project"`. */
|
|
121
|
+
key?: string;
|
|
122
|
+
/** "project" needs a saved key; "platform" needs a plan with `platformModels` (402 otherwise). */
|
|
123
|
+
use?: ModelKeySource;
|
|
124
|
+
}
|
|
125
|
+
/** A project's Trajectories program setting (see the Terms of Service and Privacy Policy). */
|
|
126
|
+
export interface TrajectoriesSetting {
|
|
127
|
+
enabled: boolean;
|
|
128
|
+
/** When the project was shown the notice; until then no session is eligible. */
|
|
129
|
+
noticeSeenAt: string | null;
|
|
130
|
+
/** The user who made the last choice (null for an API key). */
|
|
131
|
+
decidedBy: string | null;
|
|
132
|
+
}
|
|
133
|
+
export interface Me {
|
|
134
|
+
/** The logged-in user; null when calling with an API key. */
|
|
135
|
+
user: (User & {
|
|
136
|
+
isAdmin: boolean;
|
|
137
|
+
name: string | null;
|
|
138
|
+
/** The latest terms of service version the user accepted (a date), or null. */
|
|
139
|
+
termsVersion: string | null;
|
|
140
|
+
/** Newer terms exist: the console asks the user to accept them. */
|
|
141
|
+
termsUpdate: boolean;
|
|
142
|
+
/** The current terms version (what accepting the terms records). */
|
|
143
|
+
termsCurrentVersion?: string;
|
|
144
|
+
/** The user confirmed the email (a completed password reset). */
|
|
145
|
+
emailVerified?: boolean;
|
|
146
|
+
}) | null;
|
|
147
|
+
/** Set when an admin is acting as this user from the admin panel. */
|
|
148
|
+
impersonatedBy: User | null;
|
|
149
|
+
project: Project & {
|
|
150
|
+
suspended: Suspension | null;
|
|
151
|
+
limits: Plan;
|
|
152
|
+
trajectories: TrajectoriesSetting;
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
export interface ApiKeyInfo {
|
|
156
|
+
id: string;
|
|
157
|
+
name: string;
|
|
158
|
+
/** Identifies the key; the key itself is never shown again. */
|
|
159
|
+
prefix: string;
|
|
160
|
+
createdAt: string;
|
|
161
|
+
lastUsedAt: string | null;
|
|
162
|
+
}
|
|
163
|
+
export interface NewApiKey {
|
|
164
|
+
id: string;
|
|
165
|
+
name: string;
|
|
166
|
+
prefix: string;
|
|
167
|
+
/** The key itself: shown only in this response. */
|
|
168
|
+
key: string;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* One proxy.
|
|
172
|
+
* - residential / datacenter: the platform's proxies; `country` (two letters), and for residential
|
|
173
|
+
* `state` ("us_california") and `city` ("los_angeles").
|
|
174
|
+
* - custom: your own proxy, `server` like "http://host:port" with optional `username` / `password`.
|
|
175
|
+
* `ip`: "sticky" keeps one IP (sessions and crawls default) or "rotating" (quick APIs default).
|
|
176
|
+
* `scope`: "all" also routes the session's shell (curl, pip, git…) through the proxy.
|
|
177
|
+
*/
|
|
178
|
+
export type ProxyConfig = {
|
|
179
|
+
type: "residential";
|
|
180
|
+
country?: string;
|
|
181
|
+
state?: string;
|
|
182
|
+
city?: string;
|
|
183
|
+
ip?: "sticky" | "rotating";
|
|
184
|
+
scope?: "browser" | "all";
|
|
185
|
+
} | {
|
|
186
|
+
type: "datacenter";
|
|
187
|
+
country?: string;
|
|
188
|
+
ip?: "sticky" | "rotating";
|
|
189
|
+
scope?: "browser" | "all";
|
|
190
|
+
} | {
|
|
191
|
+
type: "custom";
|
|
192
|
+
server: string;
|
|
193
|
+
username?: string;
|
|
194
|
+
password?: string;
|
|
195
|
+
ip?: "sticky" | "rotating";
|
|
196
|
+
scope?: "browser" | "all";
|
|
197
|
+
};
|
|
198
|
+
/**
|
|
199
|
+
* One rule of a proxy list. For every connection the rules are tried in order and the first whose
|
|
200
|
+
* `domainPattern` (a regular expression tested against the site's host name) matches is used; a rule without a
|
|
201
|
+
* pattern matches everything. `type: "none"` goes straight out. No match: straight out.
|
|
202
|
+
*/
|
|
203
|
+
export type ProxyRule = (ProxyConfig & {
|
|
204
|
+
domainPattern?: string;
|
|
205
|
+
}) | {
|
|
206
|
+
type: "none";
|
|
207
|
+
domainPattern?: string;
|
|
208
|
+
};
|
|
209
|
+
/**
|
|
210
|
+
* A proxy for a session or a quick-API request: `true` (a residential US proxy), one proxy, or a list of rules by
|
|
211
|
+
* site (at most 10). `false` means none.
|
|
212
|
+
*/
|
|
213
|
+
export type ProxyOption = boolean | ProxyConfig | ProxyRule[];
|
|
214
|
+
/** A proxy as the API returns it: never with a password. */
|
|
215
|
+
export type PublicProxy<T = ProxyConfig | ProxyRule> = T extends {
|
|
216
|
+
password?: string;
|
|
217
|
+
} ? Omit<T, "password"> : T;
|
|
218
|
+
/**
|
|
219
|
+
* How the session's browser runs.
|
|
220
|
+
* - `mode: "realistic"` puts its clock and language on the proxy's country, so a session leaving from Berlin
|
|
221
|
+
* also says it is in Berlin. `"standard"` (the default) leaves the browser as it is (UTC, en-US).
|
|
222
|
+
* - `locale` ("de-DE") and `timezone` ("Europe/Berlin") set them yourself, and win over the mode.
|
|
223
|
+
* Nothing here changes what the browser reports about itself.
|
|
224
|
+
*/
|
|
225
|
+
export interface BrowserOptions {
|
|
226
|
+
mode?: "standard" | "realistic";
|
|
227
|
+
locale?: string;
|
|
228
|
+
timezone?: string;
|
|
229
|
+
}
|
|
230
|
+
/** What is in force (locale and timezone null = the browser's own default). */
|
|
231
|
+
export interface BrowserSettings {
|
|
232
|
+
mode: "standard" | "realistic";
|
|
233
|
+
locale: string | null;
|
|
234
|
+
timezone: string | null;
|
|
235
|
+
}
|
|
236
|
+
/** Set on a session while a CAPTCHA waits for a person (or is being solved). */
|
|
237
|
+
export interface CaptchaAttention {
|
|
238
|
+
type: "captcha";
|
|
239
|
+
kind: CaptchaKind;
|
|
240
|
+
url: string;
|
|
241
|
+
tabId?: string;
|
|
242
|
+
since: string;
|
|
243
|
+
/** "solving": captcha "solve" is trying it automatically, nobody needs to act. "waiting": a person's turn. */
|
|
244
|
+
state?: "solving" | "waiting";
|
|
245
|
+
/** Why it waits for a person when automatic solving was not allowed or failed. */
|
|
246
|
+
reason?: string;
|
|
247
|
+
}
|
|
248
|
+
export interface SessionData {
|
|
249
|
+
id: string;
|
|
250
|
+
status: SessionStatus;
|
|
251
|
+
projectId: string;
|
|
252
|
+
region: string;
|
|
253
|
+
browser: boolean;
|
|
254
|
+
shell: boolean;
|
|
255
|
+
keepAlive: boolean;
|
|
256
|
+
/** Seconds. */
|
|
257
|
+
timeout: number;
|
|
258
|
+
/** Seconds without activity after which the session ends (endReason "idle"); null: off. */
|
|
259
|
+
idleTimeout?: number | null;
|
|
260
|
+
createdAt: string;
|
|
261
|
+
startedAt: string | null;
|
|
262
|
+
endedAt: string | null;
|
|
263
|
+
expiresAt: string;
|
|
264
|
+
endReason: SessionEndReason | null;
|
|
265
|
+
/** CDP WebSocket for Playwright/Puppeteer (null without a browser or once ended). Treat it like a password. */
|
|
266
|
+
connectUrl: string | null;
|
|
267
|
+
/** The live view page. Treat it like a password. */
|
|
268
|
+
liveUrl: string | null;
|
|
269
|
+
/** The terminal WebSocket (null without a shell). Treat it like a password. */
|
|
270
|
+
terminalUrl: string | null;
|
|
271
|
+
/** The session's proxy or proxy rules (never passwords), or null. */
|
|
272
|
+
proxy: PublicProxy<ProxyConfig> | PublicProxy<ProxyRule>[] | null;
|
|
273
|
+
/** The browser mode, and the clock and language actually in force. */
|
|
274
|
+
browserSettings: BrowserSettings;
|
|
275
|
+
/** The page size (fixed at start, kept across moves and resumes); null without a browser. */
|
|
276
|
+
viewport: Viewport | null;
|
|
277
|
+
/** Whether this session may be used for trajectory datasets (fixed when it started). */
|
|
278
|
+
trajectoriesEligible: boolean;
|
|
279
|
+
captcha: CaptchaMode;
|
|
280
|
+
/** A CAPTCHA waiting for a person, or null. */
|
|
281
|
+
attention: CaptchaAttention | null;
|
|
282
|
+
workspacePath: string;
|
|
283
|
+
contextId: string | null;
|
|
284
|
+
/** Whether the session saves its sign-ins back to `contextId` when it ends. */
|
|
285
|
+
contextPersist?: boolean;
|
|
286
|
+
userMetadata: Record<string, unknown>;
|
|
287
|
+
moves: number;
|
|
288
|
+
/** When the last automatic checkpoint was taken (null before the first one). */
|
|
289
|
+
checkpointAt: string | null;
|
|
290
|
+
/** How many times the session was brought back on a new machine after its machine stopped. */
|
|
291
|
+
recoveries: number;
|
|
292
|
+
error: string | null;
|
|
293
|
+
recordSession: boolean;
|
|
294
|
+
hasRecording: boolean;
|
|
295
|
+
/** When the recording, logs and agent-run steps were deleted under the plan's `retentionDays` (null until then). */
|
|
296
|
+
dataDeletedAt?: string | null;
|
|
297
|
+
setup: string[];
|
|
298
|
+
setupStatus: "none" | "running" | "done" | "failed";
|
|
299
|
+
setupError: string | null;
|
|
300
|
+
/** Requests to ad and tracker sites are refused inside the machine. */
|
|
301
|
+
blockAds: boolean;
|
|
302
|
+
/** Requests refused so far (collected about every 30 s). */
|
|
303
|
+
blockedRequests: number;
|
|
304
|
+
/** "reject": consent banners are answered "Reject all" / "Necessary only", else hidden. */
|
|
305
|
+
cookieBanners: CookieBanners;
|
|
306
|
+
/** The extension ids the session started with. */
|
|
307
|
+
extensions: string[];
|
|
308
|
+
/** The names of the session's env variables (values are never returned). */
|
|
309
|
+
env?: string[];
|
|
310
|
+
/** The names of the project secrets its shell exports. */
|
|
311
|
+
secrets?: string[];
|
|
312
|
+
usage: {
|
|
313
|
+
seconds: number;
|
|
314
|
+
costUsd: number;
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Why a session ended. "idle": its idleTimeout passed without activity; "disconnected": a browser-only session without
|
|
319
|
+
* keepAlive whose last client left, with no agent run, script or step working in it; "agent_finished": its agent run's
|
|
320
|
+
* own session, released when the run ended (or when a run's continue window passed unused).
|
|
321
|
+
*/
|
|
322
|
+
export type SessionEndReason = "released" | "timeout" | "idle" | "disconnected" | "agent_finished" | "api_restart" | "paused_expired" | "machine_lost" | "account_recovered" | (string & {});
|
|
323
|
+
/** "reject" (the default for new sessions): answer consent banners with "Reject all" or "Necessary only" (never accept), else hide them. */
|
|
324
|
+
export type CookieBanners = "reject" | "off";
|
|
325
|
+
export interface CreateSessionParams {
|
|
326
|
+
/** `false` for a session without a browser, or options for the one it gets (see BrowserOptions). */
|
|
327
|
+
browser?: boolean | BrowserOptions;
|
|
328
|
+
/** A bash shell with Python, Node, ffmpeg and sudo, sharing /workspace with the browser. */
|
|
329
|
+
shell?: boolean;
|
|
330
|
+
/** Seconds (default 300), up to the plan's maxTimeoutSeconds. */
|
|
331
|
+
timeout?: number;
|
|
332
|
+
/**
|
|
333
|
+
* Opt-in: the session ends (endReason "idle") after this many seconds without activity, 30 to `timeout`. Activity:
|
|
334
|
+
* CDP commands, live-view input, terminal keys, exec, files, actions and steps, scripts, agent steps and messages;
|
|
335
|
+
* an agent run working in it (or one that can still be continued) counts the whole time. Protects keepAlive and
|
|
336
|
+
* shell sessions whose client crashed.
|
|
337
|
+
*/
|
|
338
|
+
idleTimeout?: number | null;
|
|
339
|
+
/** Keep a browser-only session after its last client disconnects. */
|
|
340
|
+
keepAlive?: boolean;
|
|
341
|
+
viewport?: Viewport;
|
|
342
|
+
userMetadata?: Record<string, unknown>;
|
|
343
|
+
/** Start from a saved login; `persist: true` saves the browser's logins back into it at the end. */
|
|
344
|
+
context?: {
|
|
345
|
+
id: string;
|
|
346
|
+
persist?: boolean;
|
|
347
|
+
};
|
|
348
|
+
/** Keep replay frames of this session (default true). */
|
|
349
|
+
recordSession?: boolean;
|
|
350
|
+
/**
|
|
351
|
+
* Shell commands run when the session starts and again after a move or resume, e.g.
|
|
352
|
+
* ["sudo apt-get install -y ffmpeg", "pip install yt-dlp"]. Needs shell: true.
|
|
353
|
+
*/
|
|
354
|
+
setup?: string[];
|
|
355
|
+
/** Send the session's traffic through a proxy (see ProxyOption). */
|
|
356
|
+
proxy?: ProxyOption;
|
|
357
|
+
/**
|
|
358
|
+
* When a CAPTCHA waits for a person: "ask" (default) pauses agent runs and plain-English steps until someone
|
|
359
|
+
* solves it in the live view; "ignore" lets them carry on; "solve" has the platform try to solve it
|
|
360
|
+
* automatically and falls back to "ask" if that fails. Either way `attention` and `captcha` events report it.
|
|
361
|
+
* Only enable "solve" for sites you are authorised to automate.
|
|
362
|
+
*/
|
|
363
|
+
captcha?: CaptchaMode;
|
|
364
|
+
/** Refuse requests to ad and tracker sites inside the machine (every plan; default false). */
|
|
365
|
+
blockAds?: boolean;
|
|
366
|
+
/** "reject" (default) answers cookie banners with "Reject all" / "Necessary only"; "off" leaves them. */
|
|
367
|
+
cookieBanners?: CookieBanners;
|
|
368
|
+
/**
|
|
369
|
+
* Uploaded extensions (extensions.upload) to load into the browser, at most 10; set at start only. An extension sees
|
|
370
|
+
* every page and every typed value in the session: use only ones you trust.
|
|
371
|
+
*/
|
|
372
|
+
extensions?: string[];
|
|
373
|
+
/**
|
|
374
|
+
* Variables for the session's shell (needs shell: true): new terminals, exec, scripts and `setup` commands get them,
|
|
375
|
+
* and they are set again on every new machine (move, resume, recovery). Names like the shell's
|
|
376
|
+
* ([A-Za-z_][A-Za-z0-9_]*, not PATH, HOME or BOXLINE_*), at most 100, 64 KB together. Kept sealed; the session
|
|
377
|
+
* shows the names only.
|
|
378
|
+
*/
|
|
379
|
+
env?: Record<string, string | number | boolean>;
|
|
380
|
+
/**
|
|
381
|
+
* Project secrets exported into the shell as `$NAME` (needs shell: true; the secret needs scope "shell" or "all", or
|
|
382
|
+
* shell: true, else SecretNotAllowedError). Kept in the machine's memory only and hidden in exec, script and terminal
|
|
383
|
+
* output. Anything that runs in the shell can read them: export only what you accept that for.
|
|
384
|
+
*/
|
|
385
|
+
secrets?: string[];
|
|
386
|
+
}
|
|
387
|
+
export interface UpdateSessionParams {
|
|
388
|
+
keepAlive?: boolean;
|
|
389
|
+
/** Seconds without activity before it ends (counted from now), 30 to its timeout; null switches it off. */
|
|
390
|
+
idleTimeout?: number | null;
|
|
391
|
+
userMetadata?: Record<string, unknown>;
|
|
392
|
+
/** A new proxy applies at once (open connections are closed); null removes it. */
|
|
393
|
+
proxy?: ProxyOption | null;
|
|
394
|
+
captcha?: CaptchaMode;
|
|
395
|
+
browser?: BrowserOptions;
|
|
396
|
+
/** Applies at once; turning it on also closes open connections to listed sites. */
|
|
397
|
+
blockAds?: boolean;
|
|
398
|
+
/** Applies at once: "reject" also answers banners already open. */
|
|
399
|
+
cookieBanners?: CookieBanners;
|
|
400
|
+
}
|
|
401
|
+
export interface SessionListParams {
|
|
402
|
+
/** One status or several, e.g. ["RUNNING", "PAUSED"]. */
|
|
403
|
+
status?: SessionStatus | SessionStatus[];
|
|
404
|
+
/** "browser" (no shell), "combined" (browser and shell) or "shell" (no browser). */
|
|
405
|
+
kind?: "browser" | "combined" | "shell";
|
|
406
|
+
/** A session id prefix, or text inside userMetadata. */
|
|
407
|
+
q?: string;
|
|
408
|
+
/** Created at or after (ISO date). */
|
|
409
|
+
from?: string;
|
|
410
|
+
/** Created at or before (ISO date). */
|
|
411
|
+
to?: string;
|
|
412
|
+
sort?: "created_desc" | "created_asc" | "duration_desc";
|
|
413
|
+
/** Per page: 1–500, default 50. */
|
|
414
|
+
limit?: number;
|
|
415
|
+
/** The `next` of the previous page. */
|
|
416
|
+
after?: string;
|
|
417
|
+
/** @deprecated Use `after` (cursor pages). */
|
|
418
|
+
offset?: number;
|
|
419
|
+
}
|
|
420
|
+
/** @deprecated Use SessionListParams. */
|
|
421
|
+
export type SessionListFilters = SessionListParams;
|
|
422
|
+
export interface ListParams {
|
|
423
|
+
limit?: number;
|
|
424
|
+
/** The `next` of the previous page. */
|
|
425
|
+
after?: string;
|
|
426
|
+
}
|
|
427
|
+
export interface SessionUrls {
|
|
428
|
+
liveUrl: string | null;
|
|
429
|
+
terminalUrl: string | null;
|
|
430
|
+
connectUrl: string | null;
|
|
431
|
+
}
|
|
432
|
+
export interface MoveTimings {
|
|
433
|
+
captureMs: number;
|
|
434
|
+
acquireMs: number;
|
|
435
|
+
restoreMs: number;
|
|
436
|
+
totalMs: number;
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Sessions with a shell, after a move: where the shell continues and which exported variables came along (the
|
|
440
|
+
* session's env and secrets are set again as well). Running processes do not move; the ones that were stopped are listed.
|
|
441
|
+
*/
|
|
442
|
+
export interface MoveShell {
|
|
443
|
+
cwd: string;
|
|
444
|
+
/** Names of the variables the commands exported. */
|
|
445
|
+
exported: string[];
|
|
446
|
+
/** `command` with secret values hidden, at most 200 characters; `seconds`: how long it had run. */
|
|
447
|
+
stoppedProcesses: {
|
|
448
|
+
pid: number;
|
|
449
|
+
command: string;
|
|
450
|
+
seconds: number;
|
|
451
|
+
}[];
|
|
452
|
+
}
|
|
453
|
+
export interface BulkResult {
|
|
454
|
+
results: {
|
|
455
|
+
id: string;
|
|
456
|
+
ok: boolean;
|
|
457
|
+
error?: string;
|
|
458
|
+
}[];
|
|
459
|
+
}
|
|
460
|
+
/** Viewport coordinates in CSS pixels, from the top-left corner (the session's viewport, 1280×720 by default). */
|
|
461
|
+
export interface Point {
|
|
462
|
+
x: number;
|
|
463
|
+
y: number;
|
|
464
|
+
}
|
|
465
|
+
export type MouseButton = "left" | "right" | "middle";
|
|
466
|
+
/** Where a drag starts or ends: a point, or a selector (the element's centre, scrolled into view). */
|
|
467
|
+
export type DragTarget = Point | string;
|
|
468
|
+
export type Action = {
|
|
469
|
+
action: "goto";
|
|
470
|
+
url: string;
|
|
471
|
+
waitUntil?: WaitUntil;
|
|
472
|
+
}
|
|
473
|
+
/** A selector or x/y; `count` 2 is a double click, 3 a triple click; `modifiers` are keys held, e.g. ["Shift"]. */
|
|
474
|
+
| {
|
|
475
|
+
action: "click";
|
|
476
|
+
selector?: string;
|
|
477
|
+
x?: number;
|
|
478
|
+
y?: number;
|
|
479
|
+
button?: MouseButton;
|
|
480
|
+
count?: 1 | 2 | 3;
|
|
481
|
+
modifiers?: string[];
|
|
482
|
+
} | {
|
|
483
|
+
action: "fill";
|
|
484
|
+
selector: string;
|
|
485
|
+
value: string;
|
|
486
|
+
} | {
|
|
487
|
+
action: "type";
|
|
488
|
+
text: string;
|
|
489
|
+
selector?: string;
|
|
490
|
+
delayMs?: number;
|
|
491
|
+
} | {
|
|
492
|
+
action: "press";
|
|
493
|
+
key: string;
|
|
494
|
+
}
|
|
495
|
+
/** A combination held together ("Control+A" or ["Control", "A"]); a string may hold several, separated by spaces. */
|
|
496
|
+
| {
|
|
497
|
+
action: "key";
|
|
498
|
+
keys: string | string[];
|
|
499
|
+
holdMs?: number;
|
|
500
|
+
}
|
|
501
|
+
/** Moves the pointer to x/y first when given, then turns the wheel (pixels). */
|
|
502
|
+
| {
|
|
503
|
+
action: "scroll";
|
|
504
|
+
deltaY?: number;
|
|
505
|
+
deltaX?: number;
|
|
506
|
+
x?: number;
|
|
507
|
+
y?: number;
|
|
508
|
+
modifiers?: string[];
|
|
509
|
+
}
|
|
510
|
+
/** To x/y, or by dx/dy from where the pointer is, in a straight line through `steps` points. Value: {x, y}. */
|
|
511
|
+
| {
|
|
512
|
+
action: "move";
|
|
513
|
+
x?: number;
|
|
514
|
+
y?: number;
|
|
515
|
+
dx?: number;
|
|
516
|
+
dy?: number;
|
|
517
|
+
steps?: number;
|
|
518
|
+
modifiers?: string[];
|
|
519
|
+
} | {
|
|
520
|
+
action: "hover";
|
|
521
|
+
selector?: string;
|
|
522
|
+
x?: number;
|
|
523
|
+
y?: number;
|
|
524
|
+
} | {
|
|
525
|
+
action: "mouse_down";
|
|
526
|
+
button?: MouseButton;
|
|
527
|
+
} | {
|
|
528
|
+
action: "mouse_up";
|
|
529
|
+
button?: MouseButton;
|
|
530
|
+
}
|
|
531
|
+
/** From `from` to `to` in `steps` points (default 10), or along `path` (2–200 points). Value: {from, to}. */
|
|
532
|
+
| {
|
|
533
|
+
action: "drag";
|
|
534
|
+
from?: DragTarget;
|
|
535
|
+
to?: DragTarget;
|
|
536
|
+
path?: Point[];
|
|
537
|
+
steps?: number;
|
|
538
|
+
button?: MouseButton;
|
|
539
|
+
modifiers?: string[];
|
|
540
|
+
}
|
|
541
|
+
/** Value: {x, y}, where the API last moved the pointer on this tab. */
|
|
542
|
+
| {
|
|
543
|
+
action: "cursor";
|
|
544
|
+
} | {
|
|
545
|
+
action: "wait";
|
|
546
|
+
selector?: string;
|
|
547
|
+
ms?: number;
|
|
548
|
+
}
|
|
549
|
+
/** `maxWidth` scales it down (viewport screenshots only); `cursor` draws the pointer. */
|
|
550
|
+
| {
|
|
551
|
+
action: "screenshot";
|
|
552
|
+
fullPage?: boolean;
|
|
553
|
+
format?: "png" | "jpeg";
|
|
554
|
+
quality?: number;
|
|
555
|
+
maxWidth?: number;
|
|
556
|
+
cursor?: boolean;
|
|
557
|
+
} | {
|
|
558
|
+
action: "content";
|
|
559
|
+
format?: "markdown" | "html" | "text";
|
|
560
|
+
} | {
|
|
561
|
+
action: "evaluate";
|
|
562
|
+
expression: string;
|
|
563
|
+
}
|
|
564
|
+
/** Sets a file input to a file in the session's workspace. */
|
|
565
|
+
| {
|
|
566
|
+
action: "upload";
|
|
567
|
+
selector: string;
|
|
568
|
+
path: string;
|
|
569
|
+
}
|
|
570
|
+
/** Picks an option of a select element by label or value. */
|
|
571
|
+
| {
|
|
572
|
+
action: "select";
|
|
573
|
+
selector: string;
|
|
574
|
+
option: string;
|
|
575
|
+
}
|
|
576
|
+
/** The page as a model sees it: title, URL, visible text and numbered interactive elements. */
|
|
577
|
+
| {
|
|
578
|
+
action: "elements";
|
|
579
|
+
} | {
|
|
580
|
+
action: "tabs";
|
|
581
|
+
} | {
|
|
582
|
+
action: "newTab";
|
|
583
|
+
url?: string;
|
|
584
|
+
} | {
|
|
585
|
+
action: "switchTab";
|
|
586
|
+
index: number;
|
|
587
|
+
} | {
|
|
588
|
+
action: "closeTab";
|
|
589
|
+
index?: number;
|
|
590
|
+
} | {
|
|
591
|
+
action: "back";
|
|
592
|
+
} | {
|
|
593
|
+
action: "forward";
|
|
594
|
+
} | {
|
|
595
|
+
action: "reload";
|
|
596
|
+
}
|
|
597
|
+
/** A plain-English step; a model picks one action. Use %name% for `variables` (their values never reach the model). */
|
|
598
|
+
| {
|
|
599
|
+
action: "step";
|
|
600
|
+
instruction: string;
|
|
601
|
+
variables?: Record<string, string>;
|
|
602
|
+
/** Project secrets usable as %NAME% (scope "agent" or "all"), each on its own sites; never shown in the result. */
|
|
603
|
+
secrets?: string[];
|
|
604
|
+
/** Allow `secrets` and saved login details in a session with Chrome extensions (VariablesWithExtensionsError otherwise). */
|
|
605
|
+
allowWithExtensions?: boolean;
|
|
606
|
+
provider?: AgentProvider;
|
|
607
|
+
model?: string;
|
|
608
|
+
targetId?: string;
|
|
609
|
+
}
|
|
610
|
+
/** Structured data from the current page (instruction and/or JSON Schema). */
|
|
611
|
+
| {
|
|
612
|
+
action: "extract";
|
|
613
|
+
instruction?: string;
|
|
614
|
+
schema?: Record<string, unknown>;
|
|
615
|
+
provider?: AgentProvider;
|
|
616
|
+
model?: string;
|
|
617
|
+
targetId?: string;
|
|
618
|
+
};
|
|
619
|
+
/** An action, or a plain-English step written as a bare string ("click Sign in"). */
|
|
620
|
+
export type ActionItem = Action | string;
|
|
621
|
+
export interface ActionResult {
|
|
622
|
+
ok: boolean;
|
|
623
|
+
action: string;
|
|
624
|
+
/** The action's result (see each action); StepResult for step. */
|
|
625
|
+
value?: any;
|
|
626
|
+
/** One line saying what happened ("Dragged from (180, 200) to (400, 200) in 10 steps"); never typed text. */
|
|
627
|
+
text?: string;
|
|
628
|
+
error?: string;
|
|
629
|
+
/** A stable error code when there is one (e.g. "captcha_timeout", "out_of_viewport"). */
|
|
630
|
+
code?: string;
|
|
631
|
+
ms: number;
|
|
632
|
+
}
|
|
633
|
+
export interface GotoResult {
|
|
634
|
+
url: string;
|
|
635
|
+
title: string;
|
|
636
|
+
status: number | null;
|
|
637
|
+
}
|
|
638
|
+
export interface PageContent {
|
|
639
|
+
url: string;
|
|
640
|
+
title: string;
|
|
641
|
+
content: string;
|
|
642
|
+
}
|
|
643
|
+
export interface ScreenshotValue {
|
|
644
|
+
/** Base64. */
|
|
645
|
+
data: string;
|
|
646
|
+
mimeType: string;
|
|
647
|
+
/** With maxWidth or cursor: the image's size, and image pixels per CSS pixel. */
|
|
648
|
+
width?: number;
|
|
649
|
+
height?: number;
|
|
650
|
+
scale?: number;
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* The input of a tool_use block of Claude's `computer` tool (computer_20250124, computer_20251124), as the model
|
|
654
|
+
* gives it. Coordinates are screenshot pixels.
|
|
655
|
+
*/
|
|
656
|
+
export interface AnthropicComputerAction {
|
|
657
|
+
action: "screenshot" | "cursor_position" | "mouse_move" | "left_click" | "right_click" | "middle_click" | "double_click" | "triple_click" | "left_mouse_down" | "left_mouse_up" | "left_click_drag" | "scroll" | "key" | "hold_key" | "type" | "wait" | "zoom";
|
|
658
|
+
coordinate?: [number, number];
|
|
659
|
+
start_coordinate?: [number, number];
|
|
660
|
+
/** type: the text; key / hold_key: keys (xdotool style, "ctrl+s"); clicks and scroll: keys held. */
|
|
661
|
+
text?: string;
|
|
662
|
+
key?: string;
|
|
663
|
+
scroll_direction?: "up" | "down" | "left" | "right";
|
|
664
|
+
scroll_amount?: number;
|
|
665
|
+
duration?: number;
|
|
666
|
+
region?: [number, number, number, number];
|
|
667
|
+
}
|
|
668
|
+
/** One item of an OpenAI computer_call's `actions` (GA `computer` tool). Coordinates are screenshot pixels. */
|
|
669
|
+
export interface OpenAIComputerAction {
|
|
670
|
+
type: "click" | "double_click" | "drag" | "keypress" | "move" | "screenshot" | "scroll" | "type" | "wait";
|
|
671
|
+
x?: number;
|
|
672
|
+
y?: number;
|
|
673
|
+
button?: "left" | "right" | "wheel" | "back" | "forward";
|
|
674
|
+
keys?: string[];
|
|
675
|
+
path?: Point[];
|
|
676
|
+
scroll_x?: number;
|
|
677
|
+
scroll_y?: number;
|
|
678
|
+
text?: string;
|
|
679
|
+
}
|
|
680
|
+
export type ComputerAction = AnthropicComputerAction | OpenAIComputerAction;
|
|
681
|
+
export interface ComputerOptions {
|
|
682
|
+
/**
|
|
683
|
+
* Scale the screenshot down to at most this width (100–3840); the action's coordinates are then read in that
|
|
684
|
+
* screenshot's pixels. Send the same value on every call of a conversation.
|
|
685
|
+
*/
|
|
686
|
+
maxWidth?: number;
|
|
687
|
+
/** Default true; false skips the screenshot (e.g. for all but the last action of an OpenAI batch). */
|
|
688
|
+
screenshot?: boolean;
|
|
689
|
+
format?: "png" | "jpeg";
|
|
690
|
+
quality?: number;
|
|
691
|
+
/** Draw the pointer on the screenshot. */
|
|
692
|
+
cursor?: boolean;
|
|
693
|
+
}
|
|
694
|
+
/** What POST /v1/sessions/:id/computer answers: what happened, and the screen after it. */
|
|
695
|
+
export interface ComputerResult {
|
|
696
|
+
ok: boolean;
|
|
697
|
+
/** The provider's action name. */
|
|
698
|
+
action: string;
|
|
699
|
+
shape: "anthropic" | "openai";
|
|
700
|
+
/** One line saying what happened. */
|
|
701
|
+
text: string;
|
|
702
|
+
error?: string;
|
|
703
|
+
code?: string;
|
|
704
|
+
/** Base64 image, or null with screenshot: false. */
|
|
705
|
+
screenshot: string | null;
|
|
706
|
+
mimeType: string | null;
|
|
707
|
+
width: number | null;
|
|
708
|
+
height: number | null;
|
|
709
|
+
/** Screenshot pixels per CSS pixel. */
|
|
710
|
+
scale: number;
|
|
711
|
+
/** The pointer, in screenshot pixels. */
|
|
712
|
+
cursor: Point;
|
|
713
|
+
url: string;
|
|
714
|
+
title: string;
|
|
715
|
+
}
|
|
716
|
+
/** The page as a model sees it; `elements` is one line per numbered interactive element. */
|
|
717
|
+
export interface PageElements {
|
|
718
|
+
url: string;
|
|
719
|
+
title: string;
|
|
720
|
+
text: string;
|
|
721
|
+
elements: string;
|
|
722
|
+
count: number;
|
|
723
|
+
}
|
|
724
|
+
export interface TabList {
|
|
725
|
+
current: number;
|
|
726
|
+
tabs: {
|
|
727
|
+
index: number;
|
|
728
|
+
url: string;
|
|
729
|
+
title: string;
|
|
730
|
+
}[];
|
|
731
|
+
}
|
|
732
|
+
export interface ModelUsage {
|
|
733
|
+
inputTokens: number;
|
|
734
|
+
outputTokens: number;
|
|
735
|
+
costUsd: number;
|
|
736
|
+
}
|
|
737
|
+
/** What a plain-English step did. `code` is the equivalent Playwright line for an exported script. */
|
|
738
|
+
export interface StepResult {
|
|
739
|
+
/** goto, click, fill, type, press, select, check, uncheck, hover, scroll, wait, extract, shell or none. */
|
|
740
|
+
method: string;
|
|
741
|
+
description: string;
|
|
742
|
+
element?: {
|
|
743
|
+
id: number;
|
|
744
|
+
role: string;
|
|
745
|
+
name: string;
|
|
746
|
+
};
|
|
747
|
+
code: string;
|
|
748
|
+
data?: unknown;
|
|
749
|
+
url: string;
|
|
750
|
+
title: string;
|
|
751
|
+
model: string;
|
|
752
|
+
usage: ModelUsage;
|
|
753
|
+
}
|
|
754
|
+
export interface ExtractValue<T = unknown> {
|
|
755
|
+
data: T;
|
|
756
|
+
model: string;
|
|
757
|
+
usage: ModelUsage;
|
|
758
|
+
}
|
|
759
|
+
/** Options of a plain-English step (session.step). */
|
|
760
|
+
export interface StepOptions {
|
|
761
|
+
/** Text values for %name% placeholders. */
|
|
762
|
+
variables?: Record<string, string>;
|
|
763
|
+
/**
|
|
764
|
+
* Project secrets usable as %NAME% (scope "agent" or "all"), each only on its own sites and in the shell only with
|
|
765
|
+
* shell: true. The step's result never shows their values. In a session with a saved login's details,
|
|
766
|
+
* %login.username%, %login.password% and %login.otp% work too, on that login's site only.
|
|
767
|
+
*/
|
|
768
|
+
secrets?: string[];
|
|
769
|
+
/**
|
|
770
|
+
* Allow `secrets` and saved login details in a session with Chrome extensions, which can read every typed value
|
|
771
|
+
* (secrets: VariablesWithExtensionsError otherwise; login details are not offered). Logs a warning in the session's events.
|
|
772
|
+
*/
|
|
773
|
+
allowWithExtensions?: boolean;
|
|
774
|
+
provider?: AgentProvider;
|
|
775
|
+
model?: string;
|
|
776
|
+
}
|
|
777
|
+
export interface ExecOptions {
|
|
778
|
+
timeoutMs?: number;
|
|
779
|
+
/** The directory for this command only (inside the workspace); the shell stays where it was. */
|
|
780
|
+
cwd?: string;
|
|
781
|
+
/** Variables for this command only (it may set PATH, HOME and the like for itself). */
|
|
782
|
+
env?: Record<string, string>;
|
|
783
|
+
/** Project secrets as environment variables for this command only (scope "shell" or "all", or shell: true); hidden in the output. */
|
|
784
|
+
secrets?: string[];
|
|
785
|
+
/** Named persistent shell (default "default"); false runs in a fresh process with no kept state. */
|
|
786
|
+
shell?: string | false;
|
|
787
|
+
}
|
|
788
|
+
export interface ExecResult {
|
|
789
|
+
stdout: string;
|
|
790
|
+
stderr: string;
|
|
791
|
+
exitCode: number | null;
|
|
792
|
+
timedOut: boolean;
|
|
793
|
+
/** The output was cut (it was too long). */
|
|
794
|
+
truncated: boolean;
|
|
795
|
+
durationMs: number;
|
|
796
|
+
}
|
|
797
|
+
export interface ExecExit {
|
|
798
|
+
exitCode: number | null;
|
|
799
|
+
timedOut: boolean;
|
|
800
|
+
durationMs: number;
|
|
801
|
+
truncated: boolean;
|
|
802
|
+
}
|
|
803
|
+
export interface ScriptResult {
|
|
804
|
+
stdout: string;
|
|
805
|
+
stderr: string;
|
|
806
|
+
exitCode: number | null;
|
|
807
|
+
timedOut: boolean;
|
|
808
|
+
durationMs: number;
|
|
809
|
+
}
|
|
810
|
+
export interface RunScriptOptions {
|
|
811
|
+
env?: Record<string, string>;
|
|
812
|
+
timeoutMs?: number;
|
|
813
|
+
/** The model step() and extract() use unless a call (or useModel()) picks its own. */
|
|
814
|
+
ai?: {
|
|
815
|
+
provider?: AgentProvider;
|
|
816
|
+
model?: string;
|
|
817
|
+
};
|
|
818
|
+
/**
|
|
819
|
+
* Project secrets the script's step() calls may use as %NAME% (scope "agent" or "all"). The values never enter the
|
|
820
|
+
* machine: the platform fills them in when the step runs. The grant is for this run only.
|
|
821
|
+
*/
|
|
822
|
+
secrets?: string[];
|
|
823
|
+
/** Let step() use the session's saved login details (%login.username%, %login.password%, %login.otp%). */
|
|
824
|
+
login?: boolean;
|
|
825
|
+
/**
|
|
826
|
+
* Allow `secrets` and `login` in a session with Chrome extensions, which can read every typed value
|
|
827
|
+
* (VariablesWithExtensionsError otherwise); a warning goes into the session's events.
|
|
828
|
+
*/
|
|
829
|
+
allowWithExtensions?: boolean;
|
|
830
|
+
/** Aborting it stops the script. */
|
|
831
|
+
signal?: AbortSignal;
|
|
832
|
+
onData?: (stream: "stdout" | "stderr", data: string) => void;
|
|
833
|
+
}
|
|
834
|
+
export interface FileEntry {
|
|
835
|
+
name: string;
|
|
836
|
+
type: "file" | "dir" | "other";
|
|
837
|
+
size: number;
|
|
838
|
+
/** ISO date. */
|
|
839
|
+
mtime: string;
|
|
840
|
+
}
|
|
841
|
+
export interface FileList {
|
|
842
|
+
path: string;
|
|
843
|
+
entries: FileEntry[];
|
|
844
|
+
}
|
|
845
|
+
export interface FileRef {
|
|
846
|
+
path: string;
|
|
847
|
+
size: number;
|
|
848
|
+
}
|
|
849
|
+
export interface SessionEvent {
|
|
850
|
+
seq: number;
|
|
851
|
+
at: string;
|
|
852
|
+
type: "console" | "network" | "navigation" | "error" | "lifecycle" | "action" | "exec" | "captcha";
|
|
853
|
+
level?: string;
|
|
854
|
+
text?: string;
|
|
855
|
+
url?: string;
|
|
856
|
+
method?: string;
|
|
857
|
+
status?: number;
|
|
858
|
+
resourceType?: string;
|
|
859
|
+
durationMs?: number;
|
|
860
|
+
tabId?: string;
|
|
861
|
+
data?: Record<string, unknown>;
|
|
862
|
+
}
|
|
863
|
+
export interface SessionEventsParams {
|
|
864
|
+
types?: SessionEvent["type"][];
|
|
865
|
+
/** An event seq, or the previous page's `next`. */
|
|
866
|
+
after?: number | string;
|
|
867
|
+
/** Per page: 1–2000, default 500. */
|
|
868
|
+
limit?: number;
|
|
869
|
+
}
|
|
870
|
+
export interface VisitedPage {
|
|
871
|
+
tabId: string;
|
|
872
|
+
url: string;
|
|
873
|
+
title: string;
|
|
874
|
+
visits: number;
|
|
875
|
+
firstSeen: string;
|
|
876
|
+
lastSeen: string;
|
|
877
|
+
}
|
|
878
|
+
export interface Recording {
|
|
879
|
+
frames: {
|
|
880
|
+
index: number;
|
|
881
|
+
at: string;
|
|
882
|
+
url: string | null;
|
|
883
|
+
}[];
|
|
884
|
+
durationMs: number;
|
|
885
|
+
}
|
|
886
|
+
export interface ContextInfo {
|
|
887
|
+
id: string;
|
|
888
|
+
name: string;
|
|
889
|
+
sizeBytes: number;
|
|
890
|
+
createdAt: string;
|
|
891
|
+
updatedAt: string;
|
|
892
|
+
/** The running session using it. */
|
|
893
|
+
inUseBy: string | null;
|
|
894
|
+
/** Its login details (contexts.setLogin), never the password or the 2FA secret; null without any. */
|
|
895
|
+
login?: ContextLogin | null;
|
|
896
|
+
}
|
|
897
|
+
/** What a saved login shows of its login details. */
|
|
898
|
+
export interface ContextLogin {
|
|
899
|
+
origin: string;
|
|
900
|
+
username: string;
|
|
901
|
+
hasPassword: boolean;
|
|
902
|
+
hasTotp: boolean;
|
|
903
|
+
updatedAt?: string;
|
|
904
|
+
}
|
|
905
|
+
/**
|
|
906
|
+
* A saved login's sign-in details (plan feature `loginDetails`). Agent runs, plain-English steps and scripts' step() in
|
|
907
|
+
* a session started with that context get %login.username%, %login.password% and %login.otp% (a TOTP code made when it
|
|
908
|
+
* is typed), filled in only into fields whose frame is on `origin`, never into shell commands, never shown to the model.
|
|
909
|
+
*/
|
|
910
|
+
export interface LoginDetails {
|
|
911
|
+
/** The one site they may be typed on: "https://example.com" or "https://*.example.com" (any subdomain). */
|
|
912
|
+
origin: string;
|
|
913
|
+
/** At most 320 characters. */
|
|
914
|
+
username: string;
|
|
915
|
+
/** 1 to 1024 characters. */
|
|
916
|
+
password: string;
|
|
917
|
+
/**
|
|
918
|
+
* The site's 2FA setup key (base32, any case, spaces allowed) or an otpauth://totp/ link from its QR code (SHA1,
|
|
919
|
+
* SHA256 or SHA512, 6 to 8 digits, a 15 to 120 s period; defaults SHA-1, 6 digits, 30 s).
|
|
920
|
+
*/
|
|
921
|
+
totpSecret?: string;
|
|
922
|
+
}
|
|
923
|
+
/** contexts.updateLogin: any of the login details; what is not sent is kept. */
|
|
924
|
+
export interface LoginDetailsUpdate {
|
|
925
|
+
/** A new site: needs `password` too (and `totpSecret` when the login has 2FA), or the call fails with 400. */
|
|
926
|
+
origin?: string;
|
|
927
|
+
username?: string;
|
|
928
|
+
password?: string;
|
|
929
|
+
/** A new 2FA setup key or otpauth://totp/ link; null removes 2FA. */
|
|
930
|
+
totpSecret?: string | null;
|
|
931
|
+
}
|
|
932
|
+
/** Options shared by fetch, screenshot and pdf. */
|
|
933
|
+
export interface RenderOptions {
|
|
934
|
+
/** Open the page through a proxy (the IP rotates per request unless ip: "sticky"). */
|
|
935
|
+
proxy?: ProxyOption;
|
|
936
|
+
/** The page's clock and language (see BrowserOptions). */
|
|
937
|
+
browser?: boolean | BrowserOptions;
|
|
938
|
+
timeoutMs?: number;
|
|
939
|
+
waitUntil?: WaitUntil;
|
|
940
|
+
viewport?: Viewport;
|
|
941
|
+
/** Extra wait after the page loads (ms, up to 10 000). */
|
|
942
|
+
delayMs?: number;
|
|
943
|
+
/** Refuse requests to ad and tracker sites for this page. */
|
|
944
|
+
blockAds?: boolean;
|
|
945
|
+
}
|
|
946
|
+
export interface FetchParams extends RenderOptions {
|
|
947
|
+
format?: "markdown" | "html" | "text";
|
|
948
|
+
/** Also return the page's absolute http(s) links (at most 2000). */
|
|
949
|
+
links?: boolean;
|
|
950
|
+
}
|
|
951
|
+
export interface FetchResult {
|
|
952
|
+
url: string;
|
|
953
|
+
finalUrl: string;
|
|
954
|
+
status: number | null;
|
|
955
|
+
title: string;
|
|
956
|
+
content: string;
|
|
957
|
+
/** A CAPTCHA waiting for a person on the page, or null. */
|
|
958
|
+
captcha: CaptchaKind | null;
|
|
959
|
+
ms: number;
|
|
960
|
+
/** With `links: true`. */
|
|
961
|
+
links?: string[];
|
|
962
|
+
}
|
|
963
|
+
export interface ScreenshotParams extends RenderOptions {
|
|
964
|
+
fullPage?: boolean;
|
|
965
|
+
format?: "png" | "jpeg";
|
|
966
|
+
/** JPEG only, 1–100. */
|
|
967
|
+
quality?: number;
|
|
968
|
+
/** Only this element. */
|
|
969
|
+
selector?: string;
|
|
970
|
+
}
|
|
971
|
+
export interface PdfParams extends RenderOptions {
|
|
972
|
+
paper?: "A4" | "A3" | "A5" | "Letter" | "Legal" | "Tabloid";
|
|
973
|
+
landscape?: boolean;
|
|
974
|
+
printBackground?: boolean;
|
|
975
|
+
scale?: number;
|
|
976
|
+
}
|
|
977
|
+
export interface ExtractParams {
|
|
978
|
+
url?: string;
|
|
979
|
+
/** Up to 10 pages. */
|
|
980
|
+
urls?: string[];
|
|
981
|
+
prompt?: string;
|
|
982
|
+
/** A JSON Schema for the result. */
|
|
983
|
+
schema?: Record<string, unknown>;
|
|
984
|
+
provider?: AgentProvider;
|
|
985
|
+
model?: string;
|
|
986
|
+
proxy?: ProxyOption;
|
|
987
|
+
browser?: boolean | BrowserOptions;
|
|
988
|
+
waitUntil?: WaitUntil;
|
|
989
|
+
delayMs?: number;
|
|
990
|
+
timeoutMs?: number;
|
|
991
|
+
/** Refuse requests to ad and tracker sites for these pages. */
|
|
992
|
+
blockAds?: boolean;
|
|
993
|
+
}
|
|
994
|
+
export interface ExtractResult<T = unknown> {
|
|
995
|
+
data: T;
|
|
996
|
+
provider: AgentProvider;
|
|
997
|
+
model: string;
|
|
998
|
+
keySource: ModelKeySource;
|
|
999
|
+
usage: ModelUsage;
|
|
1000
|
+
/**
|
|
1001
|
+
* Every page asked for, in order. With several `urls`, a page that did not load (`page_unreachable`,
|
|
1002
|
+
* `page_timeout`) is left out of the model's input and has `status: null`, `finalUrl: null` and an `error`; the call
|
|
1003
|
+
* fails only when none load.
|
|
1004
|
+
*/
|
|
1005
|
+
pages: {
|
|
1006
|
+
url: string;
|
|
1007
|
+
finalUrl: string | null;
|
|
1008
|
+
status: number | null;
|
|
1009
|
+
title: string;
|
|
1010
|
+
error?: {
|
|
1011
|
+
code: string;
|
|
1012
|
+
message: string;
|
|
1013
|
+
};
|
|
1014
|
+
}[];
|
|
1015
|
+
ms: number;
|
|
1016
|
+
}
|
|
1017
|
+
export interface SearchParams {
|
|
1018
|
+
/** 1–400 characters (at most 75 words). Operators work: "exact words", -word, site:example.com, filetype:pdf. */
|
|
1019
|
+
query: string;
|
|
1020
|
+
/** 1–20 results (default 10). */
|
|
1021
|
+
limit?: number;
|
|
1022
|
+
/** Where the results come from, e.g. "DE", or "ALL" (default US). */
|
|
1023
|
+
country?: string;
|
|
1024
|
+
/** The results' language, e.g. "de" (default en). */
|
|
1025
|
+
language?: string;
|
|
1026
|
+
recency?: "day" | "week" | "month" | "year";
|
|
1027
|
+
safeSearch?: "off" | "moderate" | "strict";
|
|
1028
|
+
/** Also open the top pages in a sandboxed browser and return them as Markdown: true = the top 3, or 0–5. */
|
|
1029
|
+
fetch?: boolean | number;
|
|
1030
|
+
/** For the pages `fetch` opens only (the search itself never goes through it). */
|
|
1031
|
+
proxy?: ProxyOption;
|
|
1032
|
+
}
|
|
1033
|
+
export interface SearchResult {
|
|
1034
|
+
title: string;
|
|
1035
|
+
url: string;
|
|
1036
|
+
snippet: string;
|
|
1037
|
+
publishedAt?: string;
|
|
1038
|
+
siteName?: string;
|
|
1039
|
+
/** Fetched results only: the page as Markdown, or null when it could not be loaded. */
|
|
1040
|
+
content?: string | null;
|
|
1041
|
+
page?: {
|
|
1042
|
+
finalUrl: string;
|
|
1043
|
+
status: number | null;
|
|
1044
|
+
title: string;
|
|
1045
|
+
captcha: CaptchaKind | null;
|
|
1046
|
+
ms: number;
|
|
1047
|
+
} | null;
|
|
1048
|
+
error?: {
|
|
1049
|
+
code: string;
|
|
1050
|
+
message: string;
|
|
1051
|
+
} | null;
|
|
1052
|
+
}
|
|
1053
|
+
export interface SearchResponse {
|
|
1054
|
+
/** The query as searched (white space collapsed). */
|
|
1055
|
+
query: string;
|
|
1056
|
+
results: SearchResult[];
|
|
1057
|
+
/** The whole request, fetched pages included. */
|
|
1058
|
+
ms: number;
|
|
1059
|
+
/** Answered from this project's cache (the same search in the last hour): not counted. */
|
|
1060
|
+
cached: boolean;
|
|
1061
|
+
}
|
|
1062
|
+
export interface CrawlParams {
|
|
1063
|
+
url: string;
|
|
1064
|
+
/** Sticky by default: one IP per crawl. */
|
|
1065
|
+
proxy?: ProxyOption;
|
|
1066
|
+
browser?: boolean | BrowserOptions;
|
|
1067
|
+
/** 1–200, default 20. */
|
|
1068
|
+
maxPages?: number;
|
|
1069
|
+
/** 0–10, default 3. */
|
|
1070
|
+
maxDepth?: number;
|
|
1071
|
+
sameHost?: boolean;
|
|
1072
|
+
/** Regular expressions a URL must match. */
|
|
1073
|
+
include?: string[];
|
|
1074
|
+
/** Regular expressions that skip a URL. */
|
|
1075
|
+
exclude?: string[];
|
|
1076
|
+
format?: "markdown" | "text" | "html";
|
|
1077
|
+
waitUntil?: WaitUntil;
|
|
1078
|
+
delayMs?: number;
|
|
1079
|
+
timeoutMs?: number;
|
|
1080
|
+
/** Refuse requests to ad and tracker sites on every page of the crawl. */
|
|
1081
|
+
blockAds?: boolean;
|
|
1082
|
+
}
|
|
1083
|
+
export interface CrawlPage {
|
|
1084
|
+
index: number;
|
|
1085
|
+
url: string;
|
|
1086
|
+
finalUrl: string | null;
|
|
1087
|
+
status: number | null;
|
|
1088
|
+
title: string | null;
|
|
1089
|
+
depth: number;
|
|
1090
|
+
content: string | null;
|
|
1091
|
+
captcha: CaptchaKind | null;
|
|
1092
|
+
error: string | null;
|
|
1093
|
+
}
|
|
1094
|
+
export interface CrawlJob {
|
|
1095
|
+
id: string;
|
|
1096
|
+
status: "running" | "completed" | "failed" | "canceled";
|
|
1097
|
+
url: string;
|
|
1098
|
+
/** The crawl's settings (proxy without passwords). */
|
|
1099
|
+
params: Record<string, unknown>;
|
|
1100
|
+
pagesDone: number;
|
|
1101
|
+
pagesFailed: number;
|
|
1102
|
+
skippedByRobots: number;
|
|
1103
|
+
error: string | null;
|
|
1104
|
+
createdAt: string;
|
|
1105
|
+
finishedAt: string | null;
|
|
1106
|
+
/** A page of the crawl's pages (empty in lists). */
|
|
1107
|
+
data: CrawlPage[];
|
|
1108
|
+
/** The cursor of the next page of pages (pass it as `after`), or null. */
|
|
1109
|
+
next: string | null;
|
|
1110
|
+
}
|
|
1111
|
+
export interface CrawlGetParams {
|
|
1112
|
+
/** Pages per call: 0–100, default 50 (0 = the job only). */
|
|
1113
|
+
limit?: number;
|
|
1114
|
+
after?: string;
|
|
1115
|
+
}
|
|
1116
|
+
export interface AgentModelCatalog {
|
|
1117
|
+
default: {
|
|
1118
|
+
provider: AgentProvider;
|
|
1119
|
+
model: string;
|
|
1120
|
+
};
|
|
1121
|
+
providers: {
|
|
1122
|
+
id: AgentProvider;
|
|
1123
|
+
name: string;
|
|
1124
|
+
/** A call could be made now for this project (a key exists for the source its settings choose). */
|
|
1125
|
+
available: boolean;
|
|
1126
|
+
/** Whose key a call would use now; null when there is none. */
|
|
1127
|
+
keySource: ModelKeySource | null;
|
|
1128
|
+
reason: string | null;
|
|
1129
|
+
models: {
|
|
1130
|
+
id: string;
|
|
1131
|
+
name: string;
|
|
1132
|
+
note: string;
|
|
1133
|
+
pricePerMTok: {
|
|
1134
|
+
input: number;
|
|
1135
|
+
output: number;
|
|
1136
|
+
};
|
|
1137
|
+
supportsEffort: boolean;
|
|
1138
|
+
/** Agent runs with mode "computer" work with this model. */
|
|
1139
|
+
supportsComputerUse: boolean;
|
|
1140
|
+
/** The computer-use tool the model gets in mode "computer" (Anthropic tool version, or OpenAI's "computer"). */
|
|
1141
|
+
computerTool: "computer_20251124" | "computer_20250124" | "computer" | null;
|
|
1142
|
+
default: boolean;
|
|
1143
|
+
}[];
|
|
1144
|
+
}[];
|
|
1145
|
+
}
|
|
1146
|
+
/**
|
|
1147
|
+
* An agent-run variable: the value, or the value with limits. `origins`: sites whose fields may receive it, e.g.
|
|
1148
|
+
* ["https://example.com", "https://*.example.com"] (scheme, host and port must match; "*." = any subdomain).
|
|
1149
|
+
* `shell`: bash commands may use it too. The plain string form has no site limit and no shell use.
|
|
1150
|
+
*/
|
|
1151
|
+
export type AgentVariable = string | {
|
|
1152
|
+
value: string;
|
|
1153
|
+
origins?: string[];
|
|
1154
|
+
shell?: boolean;
|
|
1155
|
+
};
|
|
1156
|
+
/** "tools" (default): the page view and browser tools. "computer": the provider's computer-use tool on screenshots. */
|
|
1157
|
+
export type AgentMode = "tools" | "computer";
|
|
1158
|
+
/**
|
|
1159
|
+
* Structured output: a JSON Schema the answer must match, e.g.
|
|
1160
|
+
* `{type: "object", properties: {title: {type: "string"}, price: {type: "number"}}, required: ["title", "price"]}`.
|
|
1161
|
+
* At most 32 KB (as JSON), 2,000 parts and 32 levels deep, with `$ref` only inside the schema ("#/$defs/…"); checked
|
|
1162
|
+
* when the run or task is created (400 invalid_request names the place). Enforced: type (nullable too), enum, const,
|
|
1163
|
+
* properties, required, additionalProperties, items, prefixItems, min/maxItems, uniqueItems, min/maxLength, minimum,
|
|
1164
|
+
* maximum, exclusiveMinimum/Maximum, multipleOf, min/maxProperties, allOf, anyOf, oneOf, not, $ref. Given to the model
|
|
1165
|
+
* but not enforced: pattern, patternProperties, format. An answer that does not match gets one repair try, then the
|
|
1166
|
+
* run fails with errorCode "output_invalid".
|
|
1167
|
+
*/
|
|
1168
|
+
export type OutputSchema = Record<string, unknown>;
|
|
1169
|
+
export interface AgentRunParams {
|
|
1170
|
+
task: string;
|
|
1171
|
+
/** Work in this session (its own settings apply) instead of a new one. */
|
|
1172
|
+
sessionId?: string;
|
|
1173
|
+
/** `false` for a run without a browser, or options for the run's own session (see BrowserOptions). */
|
|
1174
|
+
browser?: boolean | BrowserOptions;
|
|
1175
|
+
shell?: boolean;
|
|
1176
|
+
/**
|
|
1177
|
+
* Seconds for the run's own session (default 1800, or the plan's maximum when shorter; PlanLimitError above it). Not
|
|
1178
|
+
* with sessionId: that session keeps its own time (extend it with sessions.extend).
|
|
1179
|
+
*/
|
|
1180
|
+
timeout?: number;
|
|
1181
|
+
/** The run's own session's idleTimeout (see CreateSessionParams.idleTimeout). Not with sessionId. */
|
|
1182
|
+
idleTimeout?: number;
|
|
1183
|
+
/**
|
|
1184
|
+
* The run's work budget in model turns: 1–1000, default 30. `null`: no step limit, the run goes until it is done or
|
|
1185
|
+
* its session's time ends it (set a maxCostUsd or a sensible timeout then). At the limit it stops with errorCode
|
|
1186
|
+
* "max_steps" and can be continued (agent.continueRun).
|
|
1187
|
+
*/
|
|
1188
|
+
maxSteps?: number | null;
|
|
1189
|
+
/**
|
|
1190
|
+
* A money budget next to maxSteps (0.01–100 USD of model cost, as usage.costUsd counts it), checked before each model
|
|
1191
|
+
* call: the run stops with errorCode "max_cost" (continuable) once it is reached; one call can go past it. Default none.
|
|
1192
|
+
*/
|
|
1193
|
+
maxCostUsd?: number | null;
|
|
1194
|
+
/** Tool errors in a row after which the run stops with errorCode "too_many_errors" (continuable): 1–20, default 5. */
|
|
1195
|
+
maxConsecutiveErrors?: number;
|
|
1196
|
+
effort?: "low" | "medium" | "high" | "xhigh" | "max";
|
|
1197
|
+
/** Keep the run's own session after it finishes (until its expiresAt, with keepAlive on). */
|
|
1198
|
+
keepSession?: boolean;
|
|
1199
|
+
/**
|
|
1200
|
+
* Project secrets as %NAME% placeholders, exactly like `variables`, each with the secret's own `origins` and `shell`
|
|
1201
|
+
* rule (scope "agent" or "all"; SecretNotAllowedError for scope "shell"). An explicit variable with the same name wins.
|
|
1202
|
+
*/
|
|
1203
|
+
secrets?: string[];
|
|
1204
|
+
/**
|
|
1205
|
+
* For the run's own session: a saved login to start with. With login details the run also gets %login.username%,
|
|
1206
|
+
* %login.password% and %login.otp% on the login's site.
|
|
1207
|
+
*/
|
|
1208
|
+
context?: {
|
|
1209
|
+
id: string;
|
|
1210
|
+
persist?: boolean;
|
|
1211
|
+
};
|
|
1212
|
+
/** "anthropic" or "openai"; defaults to the first configured provider. */
|
|
1213
|
+
provider?: AgentProvider;
|
|
1214
|
+
/** e.g. "claude-opus-5", "claude-sonnet-5", "gpt-6-sol"; defaults to the provider's default model. */
|
|
1215
|
+
model?: string;
|
|
1216
|
+
/** A proxy for the run's own session (ignored with sessionId: that session's proxy applies). */
|
|
1217
|
+
proxy?: ProxyOption;
|
|
1218
|
+
/** CAPTCHAs on the run's own session: "ask" (default) pauses until a person solves one; "ignore" carries on; "solve" tries first. */
|
|
1219
|
+
captcha?: CaptchaMode;
|
|
1220
|
+
/**
|
|
1221
|
+
* "computer": the model drives the page with its provider's own computer-use tool on screenshots (models with
|
|
1222
|
+
* supportsComputerUse in agent.models(); 400 otherwise, or without a browser). Default "tools".
|
|
1223
|
+
*/
|
|
1224
|
+
mode?: AgentMode;
|
|
1225
|
+
/** For the run's own session (with sessionId that session's settings apply). */
|
|
1226
|
+
blockAds?: boolean;
|
|
1227
|
+
cookieBanners?: CookieBanners;
|
|
1228
|
+
extensions?: string[];
|
|
1229
|
+
/**
|
|
1230
|
+
* Allow `variables` in a session with extensions, which can read every typed value (400
|
|
1231
|
+
* `variables_with_extensions` otherwise); a warning goes into the session's events.
|
|
1232
|
+
*/
|
|
1233
|
+
allowWithExtensions?: boolean;
|
|
1234
|
+
/**
|
|
1235
|
+
* Secrets and other values the agent may type as %name% placeholders (e.g. a task "sign in with %email% and
|
|
1236
|
+
* %password%"). The model is told the names only. A value is filled in only where the model types text
|
|
1237
|
+
* (browser_type) or picks an option (browser_select), never into URLs, selectors or keys; shell commands only
|
|
1238
|
+
* with `shell: true`. `origins` limits typing it to fields on those sites (recommended for passwords). Values are
|
|
1239
|
+
* replaced by their placeholder in everything the model sees and the run stores, and kept in memory for the run
|
|
1240
|
+
* only. Up to 50; names are letters, digits and _ (not starting with a digit, 64 characters at most); values up
|
|
1241
|
+
* to 8000 characters, 64 KB together. Values shorter than 3 characters are filled in but cannot be hidden.
|
|
1242
|
+
*/
|
|
1243
|
+
variables?: Record<string, AgentVariable>;
|
|
1244
|
+
/**
|
|
1245
|
+
* Structured output (see OutputSchema): the run's `result` is then the JSON answer matching this schema, and
|
|
1246
|
+
* `resultText` a one-sentence summary. Type the answer when you read the run: `bx.agent.wait<Books>(id)`.
|
|
1247
|
+
*/
|
|
1248
|
+
output?: OutputSchema;
|
|
1249
|
+
}
|
|
1250
|
+
export interface AgentRunStarted {
|
|
1251
|
+
id: string;
|
|
1252
|
+
status: "running";
|
|
1253
|
+
sessionId: string;
|
|
1254
|
+
/** When the run's session ends by its time limit (the run stops then, errorCode "session_timeout"). */
|
|
1255
|
+
sessionExpiresAt?: string | null;
|
|
1256
|
+
provider: AgentProvider;
|
|
1257
|
+
model: string;
|
|
1258
|
+
/** Whose key pays for the run's model calls ("project": the project's own key, no model charge from Boxline). */
|
|
1259
|
+
keySource: ModelKeySource;
|
|
1260
|
+
mode: AgentMode;
|
|
1261
|
+
}
|
|
1262
|
+
/**
|
|
1263
|
+
* A run's `errorCode`. The first four are limits: the run stopped without finishing and can be continued
|
|
1264
|
+
* (agent.continueRun) while `continuable` is set; so can "server_restarted" (the API server running it stopped while its
|
|
1265
|
+
* session went on). "session_timeout": its session reached its time limit; "session_ended":
|
|
1266
|
+
* its session ended another way (`error` names how); "output_invalid": the answer did not match the output schema;
|
|
1267
|
+
* "internal": an error on the platform's side. Other codes are those of the platform error that stopped it.
|
|
1268
|
+
*/
|
|
1269
|
+
export type AgentRunErrorCode = "spend_limit" | "max_steps" | "max_cost" | "too_many_errors" | "no_progress" | "server_restarted" | "session_timeout" | "session_ended" | "output_invalid" | "internal" | "spend_limit" | "captcha_timeout" | "handover_timeout" | (string & {});
|
|
1270
|
+
/** The body of agent.continueRun. */
|
|
1271
|
+
export interface ContinueRunParams {
|
|
1272
|
+
/** 1–1000, or null for no step limit (default: the run's own). */
|
|
1273
|
+
maxSteps?: number | null;
|
|
1274
|
+
/** The new run's own money budget, 0.01–100 USD, or null for none (default: the run's own). */
|
|
1275
|
+
maxCostUsd?: number | null;
|
|
1276
|
+
/** An extra note for the model, at most 2000 characters (the new run's first `message` step). */
|
|
1277
|
+
instruction?: string;
|
|
1278
|
+
/**
|
|
1279
|
+
* The original run's variables again (their values are never stored): every name, as text or `{value}`. They keep the
|
|
1280
|
+
* sites and shell rule they had (MissingVariablesError when one is missing).
|
|
1281
|
+
*/
|
|
1282
|
+
variables?: Record<string, string | {
|
|
1283
|
+
value: string;
|
|
1284
|
+
}>;
|
|
1285
|
+
}
|
|
1286
|
+
/** agent.sendMessage's answer: queued for the agent's next step. */
|
|
1287
|
+
export interface AgentMessageSent {
|
|
1288
|
+
id: string;
|
|
1289
|
+
at: string;
|
|
1290
|
+
delivered: false;
|
|
1291
|
+
}
|
|
1292
|
+
export interface AgentStep {
|
|
1293
|
+
/** message: a message you sent (agent.sendMessage), recorded when the model received it. */
|
|
1294
|
+
type: "text" | "tool" | "handover" | "handback" | "captcha" | "message";
|
|
1295
|
+
at: string;
|
|
1296
|
+
/** message steps: who wrote it, its id, when it was sent (`at` is when the model got it). */
|
|
1297
|
+
from?: "user";
|
|
1298
|
+
id?: string;
|
|
1299
|
+
sentAt?: string;
|
|
1300
|
+
delivered?: boolean;
|
|
1301
|
+
/** handover: who paused the run; captcha "solved": who solved it. */
|
|
1302
|
+
by?: "user" | "agent" | "captcha" | "auto" | "person";
|
|
1303
|
+
text?: string;
|
|
1304
|
+
/** tool and handover steps: the model's own words with the call (what it is doing and will do next), redacted. */
|
|
1305
|
+
thought?: string;
|
|
1306
|
+
name?: string;
|
|
1307
|
+
/** A tool's input as the model wrote it: variables appear as %name%, never as their values. */
|
|
1308
|
+
input?: unknown;
|
|
1309
|
+
output?: string;
|
|
1310
|
+
isError?: boolean;
|
|
1311
|
+
ms?: number;
|
|
1312
|
+
/** captcha steps: "solving" (automatic solving), "waiting" (a person's turn), "solved" (the run goes on). */
|
|
1313
|
+
state?: "solving" | "waiting" | "solved";
|
|
1314
|
+
/** captcha steps: the CAPTCHA kind and the host of its page. */
|
|
1315
|
+
kind?: string;
|
|
1316
|
+
host?: string;
|
|
1317
|
+
/** captcha "waiting": why a person is asked. */
|
|
1318
|
+
reason?: string;
|
|
1319
|
+
}
|
|
1320
|
+
/**
|
|
1321
|
+
* An agent run. `T` is the type of `result`: the final text (string, the default) for a plain run, or the JSON answer
|
|
1322
|
+
* for a run with an `output` schema: read it as `bx.agent.get<Books>(id)` / `bx.agent.wait<Books>(id)`, or with
|
|
1323
|
+
* `unknown` and check it yourself.
|
|
1324
|
+
*/
|
|
1325
|
+
export interface AgentRun<T = string> {
|
|
1326
|
+
id: string;
|
|
1327
|
+
/** paused: the user has the browser (took it over, or the agent asked for help). */
|
|
1328
|
+
status: "running" | "paused" | "completed" | "failed" | "canceled";
|
|
1329
|
+
task: string;
|
|
1330
|
+
sessionId: string;
|
|
1331
|
+
/** The session's expiresAt: the run stops then (session_timeout). */
|
|
1332
|
+
sessionExpiresAt?: string | null;
|
|
1333
|
+
provider: AgentProvider;
|
|
1334
|
+
model: string;
|
|
1335
|
+
/** Whose key paid for the run's model calls: "project" is the project's own key (no model charge from Boxline). */
|
|
1336
|
+
keySource: ModelKeySource;
|
|
1337
|
+
mode: AgentMode;
|
|
1338
|
+
/** Its limits: steps (null: none), model cost in USD (null: none), tool errors in a row. */
|
|
1339
|
+
maxSteps?: number | null;
|
|
1340
|
+
maxCostUsd?: number | null;
|
|
1341
|
+
maxConsecutiveErrors?: number;
|
|
1342
|
+
/**
|
|
1343
|
+
* handover / handback steps mark when the user had the browser. `captcha` steps say what happened to a CAPTCHA the
|
|
1344
|
+
* run paused for: `state` "solving" (automatic solving), "waiting" (a person's turn, with `reason`), then "solved"
|
|
1345
|
+
* with `by` ("auto" or "person") and `ms` (how long the run waited).
|
|
1346
|
+
*/
|
|
1347
|
+
steps: AgentStep[];
|
|
1348
|
+
/** The final text of a completed run; with an `output` schema, the JSON answer (null unless the run completed). */
|
|
1349
|
+
result: T | null;
|
|
1350
|
+
/**
|
|
1351
|
+
* The final text; with an `output` schema, the model's one-sentence summary of the answer; for a run that stopped at a
|
|
1352
|
+
* limit, the model's short account of what is done and what is left.
|
|
1353
|
+
*/
|
|
1354
|
+
resultText?: string | null;
|
|
1355
|
+
/** The run's output schema, or null. */
|
|
1356
|
+
output?: OutputSchema | null;
|
|
1357
|
+
error: string | null;
|
|
1358
|
+
errorCode?: AgentRunErrorCode | null;
|
|
1359
|
+
/** Set while the run can be continued (agent.continueRun): it stopped at a limit, and its session is kept until then. */
|
|
1360
|
+
continuable?: {
|
|
1361
|
+
until: string;
|
|
1362
|
+
} | null;
|
|
1363
|
+
/** The run this one continues, and the run that continued this one. */
|
|
1364
|
+
continuedFrom?: string | null;
|
|
1365
|
+
continuedBy?: string | null;
|
|
1366
|
+
/** The names of the run's own variables (never values): continueRun needs their values again. */
|
|
1367
|
+
variableNames?: string[];
|
|
1368
|
+
usage: {
|
|
1369
|
+
inputTokens: number;
|
|
1370
|
+
outputTokens: number;
|
|
1371
|
+
costUsd: number | null;
|
|
1372
|
+
};
|
|
1373
|
+
/** Set while paused: who asked for the handover and why ("captcha": the run continues by itself once it is solved). */
|
|
1374
|
+
handover: {
|
|
1375
|
+
by: "user" | "agent" | "captcha";
|
|
1376
|
+
reason: string | null;
|
|
1377
|
+
} | null;
|
|
1378
|
+
/** Set when a task started the run (tasks.run, or its schedule). */
|
|
1379
|
+
taskId?: string | null;
|
|
1380
|
+
taskRunId?: string | null;
|
|
1381
|
+
createdAt: string;
|
|
1382
|
+
finishedAt: string | null;
|
|
1383
|
+
}
|
|
1384
|
+
/** One event of an agent run's live stream (agent.stream); `T` as on AgentRun (the type of the final `result`). */
|
|
1385
|
+
export type AgentRunEvent<T = string> = AgentStep
|
|
1386
|
+
/** The model's words, as soon as its reply arrives (before its tool runs; then that step's `thought`). */
|
|
1387
|
+
| {
|
|
1388
|
+
type: "thought";
|
|
1389
|
+
text: string;
|
|
1390
|
+
at: string;
|
|
1391
|
+
} | {
|
|
1392
|
+
type: "status";
|
|
1393
|
+
status: AgentRun["status"];
|
|
1394
|
+
by?: string;
|
|
1395
|
+
reason?: string | null;
|
|
1396
|
+
} | {
|
|
1397
|
+
type: "exec";
|
|
1398
|
+
command: string;
|
|
1399
|
+
at: string;
|
|
1400
|
+
} | {
|
|
1401
|
+
type: "output";
|
|
1402
|
+
stream: "stdout" | "stderr";
|
|
1403
|
+
data: string;
|
|
1404
|
+
} | {
|
|
1405
|
+
type: "done";
|
|
1406
|
+
status: AgentRun["status"];
|
|
1407
|
+
result: T | null;
|
|
1408
|
+
resultText?: string | null;
|
|
1409
|
+
error: string | null;
|
|
1410
|
+
errorCode?: AgentRunErrorCode | null;
|
|
1411
|
+
continuable?: {
|
|
1412
|
+
until: string;
|
|
1413
|
+
} | null;
|
|
1414
|
+
};
|
|
1415
|
+
/**
|
|
1416
|
+
* A variable of a task, written in its instruction as %name%.
|
|
1417
|
+
* - Plain (the default): the value (from the run, else the schedule, else `default`) is written into the instruction,
|
|
1418
|
+
* so the model reads it, and is kept with the run.
|
|
1419
|
+
* - `secret: true`: the value is never stored anywhere (so no `default`), must come with every run, and is typed by the
|
|
1420
|
+
* agent without the model seeing it (as agent-run variables: `origins`, `shell`). A task with one cannot have a
|
|
1421
|
+
* schedule.
|
|
1422
|
+
*/
|
|
1423
|
+
export interface TaskVariable {
|
|
1424
|
+
/** Letters, digits and _ (not starting with a digit), 64 characters at most. */
|
|
1425
|
+
name: string;
|
|
1426
|
+
secret?: boolean;
|
|
1427
|
+
/** Plain variables only: the value when a run (or the schedule) gives none. */
|
|
1428
|
+
default?: string | null;
|
|
1429
|
+
/** For people (the console's run form), up to 500 characters. */
|
|
1430
|
+
description?: string | null;
|
|
1431
|
+
/** Secret variables only: the sites whose fields may receive the value, e.g. ["https://example.com"]. */
|
|
1432
|
+
origins?: string[] | null;
|
|
1433
|
+
/** Secret variables only: bash commands may use it. */
|
|
1434
|
+
shell?: boolean;
|
|
1435
|
+
}
|
|
1436
|
+
/**
|
|
1437
|
+
* The settings of each run's own session, as on sessions.create, checked when saved and again at each run. A custom
|
|
1438
|
+
* proxy's password is stored encrypted and never returned. `allowWithExtensions` is needed for a task with secret
|
|
1439
|
+
* variables and extensions (VariablesWithExtensionsError otherwise).
|
|
1440
|
+
*/
|
|
1441
|
+
export interface TaskBrowser extends BrowserOptions {
|
|
1442
|
+
shell?: boolean;
|
|
1443
|
+
proxy?: ProxyOption | null;
|
|
1444
|
+
captcha?: CaptchaMode;
|
|
1445
|
+
viewport?: Viewport;
|
|
1446
|
+
/** Seconds for each run's own session (as timeout on agent.run), and its idleTimeout. */
|
|
1447
|
+
timeout?: number;
|
|
1448
|
+
idleTimeout?: number;
|
|
1449
|
+
blockAds?: boolean;
|
|
1450
|
+
cookieBanners?: CookieBanners;
|
|
1451
|
+
/** This project's uploaded extensions (the plan's `extensions`), at most 10. */
|
|
1452
|
+
extensions?: string[];
|
|
1453
|
+
allowWithExtensions?: boolean;
|
|
1454
|
+
}
|
|
1455
|
+
/** A task's schedule as you set it; on update its fields are merged into the current schedule. */
|
|
1456
|
+
export interface TaskScheduleInput {
|
|
1457
|
+
/**
|
|
1458
|
+
* Five fields (minute hour day-of-month month day-of-week) with `*`, numbers, ranges, steps and lists, names JAN–DEC and
|
|
1459
|
+
* SUN–SAT, or @hourly, @daily, @weekly, @monthly, @yearly. At most every 5 minutes. E.g. "0 9 * * MON-FRI".
|
|
1460
|
+
*/
|
|
1461
|
+
cron?: string;
|
|
1462
|
+
/** An IANA time zone the cron is read in (default "UTC"). */
|
|
1463
|
+
timezone?: string;
|
|
1464
|
+
/** Values for the task's plain variables (their defaults fill the rest). */
|
|
1465
|
+
variables?: Record<string, string>;
|
|
1466
|
+
/** Default true. Switching it on, or changing cron or timezone, counts the next run from now. */
|
|
1467
|
+
enabled?: boolean;
|
|
1468
|
+
}
|
|
1469
|
+
export interface TaskSchedule {
|
|
1470
|
+
cron: string;
|
|
1471
|
+
timezone: string;
|
|
1472
|
+
variables: Record<string, string>;
|
|
1473
|
+
enabled: boolean;
|
|
1474
|
+
/** When it runs next; null while switched off. */
|
|
1475
|
+
nextRunAt: string | null;
|
|
1476
|
+
/** The next 3 times it fires, ISO in UTC (the first is nextRunAt), on the schedule's time zone and DST; [] while switched off. */
|
|
1477
|
+
nextRuns: string[];
|
|
1478
|
+
}
|
|
1479
|
+
/** A task's newest run (by hand or scheduled, queued included; skipped and missed times are not runs). */
|
|
1480
|
+
export interface TaskLastRun {
|
|
1481
|
+
id: string;
|
|
1482
|
+
/** As in the run history: it follows the agent run while that works. */
|
|
1483
|
+
status: Exclude<TaskRunStatus, "skipped" | "missed">;
|
|
1484
|
+
/** Why it stopped (`max_steps`, `session_timeout`, …), as on its agent run; null while working or when completed. */
|
|
1485
|
+
errorCode: string | null;
|
|
1486
|
+
createdAt: string;
|
|
1487
|
+
finishedAt: string | null;
|
|
1488
|
+
}
|
|
1489
|
+
/** A saved login (context) each run's session starts with: its id, or `{id, persist}` (persist: keep what the run changes). */
|
|
1490
|
+
export type TaskSavedLogin = string | {
|
|
1491
|
+
id: string;
|
|
1492
|
+
persist?: boolean;
|
|
1493
|
+
};
|
|
1494
|
+
export interface TaskCreateParams {
|
|
1495
|
+
/** 1–100 characters. */
|
|
1496
|
+
name: string;
|
|
1497
|
+
/** What the agent does, with %name% where a variable goes (up to 20,000 characters). */
|
|
1498
|
+
instruction: string;
|
|
1499
|
+
/** Up to 50. */
|
|
1500
|
+
variables?: TaskVariable[];
|
|
1501
|
+
/**
|
|
1502
|
+
* Project secrets (by name, up to 50) each run gets as %NAME%, as `secrets` on agent runs. They must exist with scope
|
|
1503
|
+
* "agent" or "all"; a scheduled task may use them (secret variables cannot be scheduled).
|
|
1504
|
+
*/
|
|
1505
|
+
secrets?: string[];
|
|
1506
|
+
/** Structured output for every run (see OutputSchema). */
|
|
1507
|
+
output?: OutputSchema;
|
|
1508
|
+
browser?: TaskBrowser;
|
|
1509
|
+
savedLogin?: TaskSavedLogin;
|
|
1510
|
+
/** From agent.models() (default: the server's default model). */
|
|
1511
|
+
model?: {
|
|
1512
|
+
provider?: AgentProvider;
|
|
1513
|
+
model?: string;
|
|
1514
|
+
};
|
|
1515
|
+
/** 1–1000 (default 30), or null for no step limit. */
|
|
1516
|
+
maxSteps?: number | null;
|
|
1517
|
+
/** Each run's money budget, 0.01–100 USD (as maxCostUsd on agent.run); default none. */
|
|
1518
|
+
maxCostUsd?: number | null;
|
|
1519
|
+
/** Stored only: no email is sent yet. */
|
|
1520
|
+
notifyOnFailure?: "email" | null;
|
|
1521
|
+
/** Run it on a schedule (the plan's `schedules`; PlanLimitError beyond). */
|
|
1522
|
+
schedule?: TaskScheduleInput;
|
|
1523
|
+
}
|
|
1524
|
+
/** Any TaskCreateParams fields; `null` removes the optional ones. `schedule` fields are merged into the current schedule. */
|
|
1525
|
+
export interface TaskUpdateParams {
|
|
1526
|
+
name?: string;
|
|
1527
|
+
instruction?: string;
|
|
1528
|
+
variables?: TaskVariable[];
|
|
1529
|
+
/** The whole new list; null or [] removes them. */
|
|
1530
|
+
secrets?: string[] | null;
|
|
1531
|
+
output?: OutputSchema | null;
|
|
1532
|
+
browser?: TaskBrowser | null;
|
|
1533
|
+
savedLogin?: TaskSavedLogin | null;
|
|
1534
|
+
model?: {
|
|
1535
|
+
provider?: AgentProvider;
|
|
1536
|
+
model?: string;
|
|
1537
|
+
} | null;
|
|
1538
|
+
/** null: no step limit. */
|
|
1539
|
+
maxSteps?: number | null;
|
|
1540
|
+
/** null removes it. */
|
|
1541
|
+
maxCostUsd?: number | null;
|
|
1542
|
+
notifyOnFailure?: "email" | null;
|
|
1543
|
+
/** e.g. `{enabled: false}` pauses it; null removes it. */
|
|
1544
|
+
schedule?: TaskScheduleInput | null;
|
|
1545
|
+
}
|
|
1546
|
+
/** A task as stored: secret variables without values, `browser.proxy` without its password. */
|
|
1547
|
+
export interface Task {
|
|
1548
|
+
id: string;
|
|
1549
|
+
name: string;
|
|
1550
|
+
instruction: string;
|
|
1551
|
+
variables: TaskVariable[];
|
|
1552
|
+
/** Names of the project secrets its runs get (never values). */
|
|
1553
|
+
secrets: string[];
|
|
1554
|
+
output: OutputSchema | null;
|
|
1555
|
+
browser: TaskBrowser | null;
|
|
1556
|
+
savedLogin: {
|
|
1557
|
+
id: string;
|
|
1558
|
+
persist: boolean;
|
|
1559
|
+
} | null;
|
|
1560
|
+
model: {
|
|
1561
|
+
provider?: AgentProvider;
|
|
1562
|
+
model?: string;
|
|
1563
|
+
} | null;
|
|
1564
|
+
/** null: no step limit (a task saved without one shows 30). */
|
|
1565
|
+
maxSteps: number | null;
|
|
1566
|
+
maxCostUsd?: number | null;
|
|
1567
|
+
notifyOnFailure: "email" | null;
|
|
1568
|
+
schedule: TaskSchedule | null;
|
|
1569
|
+
lastRunAt: string | null;
|
|
1570
|
+
/** The newest run, or null before the first. */
|
|
1571
|
+
lastRun: TaskLastRun | null;
|
|
1572
|
+
createdAt: string;
|
|
1573
|
+
updatedAt: string;
|
|
1574
|
+
}
|
|
1575
|
+
/**
|
|
1576
|
+
* - queued: a scheduled run waiting for its turn to start (it fails with `not_started` after 10 minutes);
|
|
1577
|
+
* - running, paused (a person has the browser), then completed, failed or canceled, as its agent run;
|
|
1578
|
+
* - skipped, missed: a scheduled time that did not run (`reason`, `missedCount`).
|
|
1579
|
+
*/
|
|
1580
|
+
export type TaskRunStatus = "queued" | "running" | "paused" | "completed" | "failed" | "canceled" | "skipped" | "missed";
|
|
1581
|
+
/**
|
|
1582
|
+
* One run of a task (by hand or on its schedule), or a scheduled time that did not run. `T` is the type of `result`:
|
|
1583
|
+
* the JSON answer when the task has an output schema (`structured`), else the final text.
|
|
1584
|
+
*/
|
|
1585
|
+
export interface TaskRun<T = unknown> {
|
|
1586
|
+
id: string;
|
|
1587
|
+
taskId: string;
|
|
1588
|
+
/** The agent run (agent.get(runId) has its steps); null while queued, for skipped and missed times, and for a scheduled run that could not start. */
|
|
1589
|
+
runId: string | null;
|
|
1590
|
+
sessionId: string | null;
|
|
1591
|
+
status: TaskRunStatus;
|
|
1592
|
+
scheduled: boolean;
|
|
1593
|
+
scheduledFor: string | null;
|
|
1594
|
+
/** skipped and missed: why the time did not run. */
|
|
1595
|
+
reason: "previous_run_running" | "plan_limit" | "not_running" | null;
|
|
1596
|
+
/** missed: how many scheduled times it stands for (counted up to 1,000). */
|
|
1597
|
+
missedCount: number | null;
|
|
1598
|
+
/** The plain values it ran with. */
|
|
1599
|
+
variables: Record<string, string>;
|
|
1600
|
+
/** The names of its secret variables, never their values. */
|
|
1601
|
+
secretVariables: string[];
|
|
1602
|
+
/** The result is JSON (the task has an output schema). */
|
|
1603
|
+
structured: boolean;
|
|
1604
|
+
/** The JSON answer (structured) or the final text; null until it completes. */
|
|
1605
|
+
result: T | null;
|
|
1606
|
+
resultText: string | null;
|
|
1607
|
+
error: string | null;
|
|
1608
|
+
/** e.g. "output_invalid", or why a scheduled run could not start ("no_capacity", "missing_variables", "not_started", …). */
|
|
1609
|
+
errorCode: string | null;
|
|
1610
|
+
usage: {
|
|
1611
|
+
inputTokens: number;
|
|
1612
|
+
outputTokens: number;
|
|
1613
|
+
costUsd: number | null;
|
|
1614
|
+
};
|
|
1615
|
+
durationMs: number | null;
|
|
1616
|
+
createdAt: string;
|
|
1617
|
+
finishedAt: string | null;
|
|
1618
|
+
}
|
|
1619
|
+
export interface TaskRunParams {
|
|
1620
|
+
/** Values by name. Secret variables must be given on every run; plain ones fall back to their defaults. */
|
|
1621
|
+
variables?: Record<string, string | number | boolean>;
|
|
1622
|
+
/** Work in this session (its own settings apply; the task's `browser` and `savedLogin` do not). */
|
|
1623
|
+
sessionId?: string;
|
|
1624
|
+
}
|
|
1625
|
+
export interface TaskRunListParams extends ListParams {
|
|
1626
|
+
/** Only runs with these statuses. */
|
|
1627
|
+
status?: TaskRunStatus | TaskRunStatus[];
|
|
1628
|
+
}
|
|
1629
|
+
export interface Usage {
|
|
1630
|
+
from: string;
|
|
1631
|
+
to: string;
|
|
1632
|
+
sessions: number;
|
|
1633
|
+
running: number;
|
|
1634
|
+
browserSeconds: number;
|
|
1635
|
+
sandboxVcpuSeconds: number;
|
|
1636
|
+
sandboxGibSeconds: number;
|
|
1637
|
+
proxy: {
|
|
1638
|
+
residentialGb: number;
|
|
1639
|
+
datacenterGb: number;
|
|
1640
|
+
customGb: number;
|
|
1641
|
+
costUsd: number;
|
|
1642
|
+
};
|
|
1643
|
+
/** Automatic CAPTCHA solving (captcha "solve"): attempts are billed whether solved or failed. */
|
|
1644
|
+
captchaSolves: {
|
|
1645
|
+
solved: number;
|
|
1646
|
+
failed: number;
|
|
1647
|
+
refused: number;
|
|
1648
|
+
costUsd: number;
|
|
1649
|
+
};
|
|
1650
|
+
/** Web searches that reached the provider (cached answers are not counted); cost of those beyond the allowance. */
|
|
1651
|
+
searches: {
|
|
1652
|
+
count: number;
|
|
1653
|
+
costUsd: number;
|
|
1654
|
+
};
|
|
1655
|
+
/** Includes proxy data, CAPTCHA solving and searches beyond the allowance. */
|
|
1656
|
+
costUsd: number;
|
|
1657
|
+
byDay: {
|
|
1658
|
+
date: string;
|
|
1659
|
+
seconds: number;
|
|
1660
|
+
costUsd: number;
|
|
1661
|
+
}[];
|
|
1662
|
+
}
|
|
1663
|
+
export interface StatsDay {
|
|
1664
|
+
sessions: number;
|
|
1665
|
+
browserSeconds: number;
|
|
1666
|
+
costUsd: number;
|
|
1667
|
+
agentRuns: number;
|
|
1668
|
+
/** Model cost on the platform's keys (runs on the project's own keys are in `ownKeyModelCostUsd`). */
|
|
1669
|
+
modelCostUsd: number;
|
|
1670
|
+
ownKeyModelCostUsd: number;
|
|
1671
|
+
}
|
|
1672
|
+
export interface Stats {
|
|
1673
|
+
days: number;
|
|
1674
|
+
running: number;
|
|
1675
|
+
concurrencyLimit: number;
|
|
1676
|
+
totals: StatsDay;
|
|
1677
|
+
byDay: (StatsDay & {
|
|
1678
|
+
date: string;
|
|
1679
|
+
})[];
|
|
1680
|
+
}
|
|
1681
|
+
export interface Pricing {
|
|
1682
|
+
currency: "USD";
|
|
1683
|
+
billing: string;
|
|
1684
|
+
browserSessionPerHour: number;
|
|
1685
|
+
sandboxPerVcpuHour: number;
|
|
1686
|
+
sandboxPerGibHour: number;
|
|
1687
|
+
defaultShellMachine: {
|
|
1688
|
+
vcpu: number;
|
|
1689
|
+
gib: number;
|
|
1690
|
+
perHour: number;
|
|
1691
|
+
};
|
|
1692
|
+
pausedSessions: {
|
|
1693
|
+
freeHours: number;
|
|
1694
|
+
perGbMonthAfter: number;
|
|
1695
|
+
};
|
|
1696
|
+
proxies: {
|
|
1697
|
+
residentialPerGb: number;
|
|
1698
|
+
datacenterPerGb: number;
|
|
1699
|
+
customPerGb: number;
|
|
1700
|
+
};
|
|
1701
|
+
captchaSolving: {
|
|
1702
|
+
per1000Attempts: number;
|
|
1703
|
+
};
|
|
1704
|
+
/** Searches included per month, and the price per 1,000 beyond them (null: none beyond), per public plan. */
|
|
1705
|
+
webSearch: {
|
|
1706
|
+
byPlan: Record<string, {
|
|
1707
|
+
includedPerMonth: number | null;
|
|
1708
|
+
extraPer1000Usd: number | null;
|
|
1709
|
+
}>;
|
|
1710
|
+
};
|
|
1711
|
+
plans: Plan[];
|
|
1712
|
+
/** A label for people per plan feature. */
|
|
1713
|
+
features: Record<PlanFeature, string>;
|
|
1714
|
+
}
|
|
1715
|
+
/**
|
|
1716
|
+
* The events an endpoint can subscribe to (`webhook.test` needs no subscription). New types may be added: an endpoint
|
|
1717
|
+
* subscribed to "*" gets them too, so a receiver should ignore types it does not know.
|
|
1718
|
+
*/
|
|
1719
|
+
export type WebhookEventType = "session.started" | "session.expiring" | "session.ended" | "agent_run.started" | "agent_run.waiting" | "agent_run.resumed" | "agent_run.finished" | "captcha.waiting" | "captcha.solved" | "captcha.failed" | "crawl.finished" | "task_run.started" | "task_run.finished" | "task.schedule_paused" | "usage.limit_reached" | "api_key.created" | "api_key.revoked" | "secret.changed" | "webhook.changed" | "webhook.disabled" | "extension.uploaded" | "extension.deleted";
|
|
1720
|
+
/** What an endpoint subscribes to: event types, or "*" for all of them (those added later too). */
|
|
1721
|
+
export type WebhookSubscription = WebhookEventType | "*";
|
|
1722
|
+
/** One entry of bx.webhooks.eventTypes(): a type, its group (for pickers) and what it says. */
|
|
1723
|
+
export interface WebhookEventTypeInfo {
|
|
1724
|
+
type: WebhookEventType;
|
|
1725
|
+
group: string;
|
|
1726
|
+
description: string;
|
|
1727
|
+
}
|
|
1728
|
+
export interface WebhookEventTypeList {
|
|
1729
|
+
data: WebhookEventTypeInfo[];
|
|
1730
|
+
/** "*": subscribe to it for every type. */
|
|
1731
|
+
all: "*";
|
|
1732
|
+
}
|
|
1733
|
+
export interface WebhookEndpoint {
|
|
1734
|
+
id: string;
|
|
1735
|
+
url: string;
|
|
1736
|
+
/** The types it gets, or ["*"] for all of them. */
|
|
1737
|
+
events: WebhookSubscription[];
|
|
1738
|
+
description: string | null;
|
|
1739
|
+
enabled: boolean;
|
|
1740
|
+
/** "user": switched off with update; "gone": it answered 410; "failing": 3 days of failed deliveries. */
|
|
1741
|
+
/** `account_recovered`: a password reset recovered an account whose email had not been confirmed. */
|
|
1742
|
+
disabledReason: "user" | "gone" | "failing" | "account_recovered" | null;
|
|
1743
|
+
disabledAt: string | null;
|
|
1744
|
+
/** The first failed delivery since the last success. */
|
|
1745
|
+
failingSince: string | null;
|
|
1746
|
+
lastSuccessAt: string | null;
|
|
1747
|
+
lastFailureAt: string | null;
|
|
1748
|
+
secretRotatedAt: string | null;
|
|
1749
|
+
/** Until then deliveries are also signed with the secret before the last rotation. */
|
|
1750
|
+
previousSecretExpiresAt: string | null;
|
|
1751
|
+
/** Deliveries wait until then because the endpoint timed out 3 times in a row (test events still go). */
|
|
1752
|
+
pausedUntil: string | null;
|
|
1753
|
+
createdAt: string;
|
|
1754
|
+
updatedAt: string;
|
|
1755
|
+
}
|
|
1756
|
+
/** An endpoint just created or with a rotated secret: `secret` ("whsec_…") is shown only in this response. */
|
|
1757
|
+
export interface NewWebhookEndpoint extends WebhookEndpoint {
|
|
1758
|
+
secret: string;
|
|
1759
|
+
}
|
|
1760
|
+
export interface WebhookCreateParams {
|
|
1761
|
+
/** Public HTTPS (400 webhook_url_not_allowed otherwise). */
|
|
1762
|
+
url: string;
|
|
1763
|
+
/** Event types, or ["*"] for all of them (those added later too). */
|
|
1764
|
+
events: WebhookSubscription[];
|
|
1765
|
+
description?: string;
|
|
1766
|
+
}
|
|
1767
|
+
export interface WebhookUpdateParams {
|
|
1768
|
+
url?: string;
|
|
1769
|
+
events?: WebhookSubscription[];
|
|
1770
|
+
/** true also after the platform switched it off (and forgets its failures); false: deliveries not yet made fail. */
|
|
1771
|
+
enabled?: boolean;
|
|
1772
|
+
description?: string | null;
|
|
1773
|
+
}
|
|
1774
|
+
/** Why a delivery or an attempt failed (null when delivered); the last five are deliveries that were never sent. */
|
|
1775
|
+
export type WebhookErrorCode = "bad_status" | "gone" | "timeout" | "connection_failed" | "tls_failed" | "address_not_allowed" | "gateway_unavailable" | "endpoint_disabled" | "project_suspended" | "payload_expired" | "queue_full" | "signing_failed";
|
|
1776
|
+
export interface WebhookAttempt {
|
|
1777
|
+
at: string;
|
|
1778
|
+
/** The HTTP status of the answer, null when there was none. */
|
|
1779
|
+
status: number | null;
|
|
1780
|
+
durationMs: number;
|
|
1781
|
+
error: string | null;
|
|
1782
|
+
errorCode: WebhookErrorCode | null;
|
|
1783
|
+
}
|
|
1784
|
+
export interface WebhookDelivery {
|
|
1785
|
+
id: string;
|
|
1786
|
+
endpointId: string;
|
|
1787
|
+
/** The event's id: the same on every endpoint and every attempt (dedupe by it). */
|
|
1788
|
+
eventId: string;
|
|
1789
|
+
eventType: string;
|
|
1790
|
+
test: boolean;
|
|
1791
|
+
/** "pending": waiting for its next attempt; "failed": no more attempts. */
|
|
1792
|
+
status: "pending" | "delivered" | "failed";
|
|
1793
|
+
attempts: number;
|
|
1794
|
+
nextAttemptAt: string | null;
|
|
1795
|
+
lastAttemptAt: string | null;
|
|
1796
|
+
deliveredAt: string | null;
|
|
1797
|
+
responseStatus: number | null;
|
|
1798
|
+
/** The first 1 KB of the last answer (kept 7 days). */
|
|
1799
|
+
responseBody: string | null;
|
|
1800
|
+
durationMs: number | null;
|
|
1801
|
+
error: string | null;
|
|
1802
|
+
errorCode: WebhookErrorCode | null;
|
|
1803
|
+
/** The last 20 attempts. */
|
|
1804
|
+
history: WebhookAttempt[];
|
|
1805
|
+
/** The body that was sent (the event); null after 7 days. */
|
|
1806
|
+
payload: WebhookEvent | null;
|
|
1807
|
+
createdAt: string;
|
|
1808
|
+
}
|
|
1809
|
+
export interface WebhookDeliveryListParams extends ListParams {
|
|
1810
|
+
status?: "pending" | "delivered" | "failed";
|
|
1811
|
+
}
|
|
1812
|
+
/**
|
|
1813
|
+
* The body of every delivery. Verify it with verifyWebhook() before trusting it, and drop an `id` already handled.
|
|
1814
|
+
* `verifyWebhook(body, header, secret) as WebhookEventPayload` gives the typed union below: switch on `type`
|
|
1815
|
+
* (verifyWebhook's own type parameter describes `data`, not the union).
|
|
1816
|
+
*/
|
|
1817
|
+
export interface WebhookEvent<T = Record<string, unknown>> {
|
|
1818
|
+
id: string;
|
|
1819
|
+
type: WebhookEventType | "webhook.test";
|
|
1820
|
+
createdAt: string;
|
|
1821
|
+
projectId: string;
|
|
1822
|
+
/** Set on "send test" deliveries (webhook.test, and samples of other types): made-up data. */
|
|
1823
|
+
test?: boolean;
|
|
1824
|
+
data: T;
|
|
1825
|
+
}
|
|
1826
|
+
/** Who made a change: "user:<email>" (a console login), "key:<api key id>", "support" (support acting as you) or "platform". */
|
|
1827
|
+
export type WebhookActor = string;
|
|
1828
|
+
/** session.started and session.ended: the session as sessions.get returns it, with every URL (and attention) null. */
|
|
1829
|
+
export type WebhookSessionData = Omit<SessionData, "setup" | "setupError"> & {
|
|
1830
|
+
userMetadataTruncated?: true;
|
|
1831
|
+
};
|
|
1832
|
+
export interface WebhookSessionExpiringData {
|
|
1833
|
+
sessionId: string;
|
|
1834
|
+
expiresAt: string;
|
|
1835
|
+
secondsLeft: number;
|
|
1836
|
+
userMetadata: Record<string, unknown> | null;
|
|
1837
|
+
userMetadataTruncated?: true;
|
|
1838
|
+
}
|
|
1839
|
+
export interface WebhookAgentRunStartedData {
|
|
1840
|
+
id: string;
|
|
1841
|
+
status: "running";
|
|
1842
|
+
/** At most 4000 characters; variables are their %name%. */
|
|
1843
|
+
task: string;
|
|
1844
|
+
sessionId: string;
|
|
1845
|
+
provider: AgentProvider;
|
|
1846
|
+
model: string;
|
|
1847
|
+
mode: AgentMode;
|
|
1848
|
+
continuedFrom: string | null;
|
|
1849
|
+
taskId: string | null;
|
|
1850
|
+
taskRunId: string | null;
|
|
1851
|
+
createdAt: string;
|
|
1852
|
+
truncated?: true;
|
|
1853
|
+
}
|
|
1854
|
+
export interface WebhookAgentRunWaitingData {
|
|
1855
|
+
id: string;
|
|
1856
|
+
sessionId: string | null;
|
|
1857
|
+
state: "waiting";
|
|
1858
|
+
/** "agent": it asked for help; "user": someone took over; "captcha": a CAPTCHA needs a person. */
|
|
1859
|
+
by: "agent" | "user" | "captcha";
|
|
1860
|
+
/** At most 500 characters, with variables as their %name%. */
|
|
1861
|
+
reason: string | null;
|
|
1862
|
+
/** The run in the console (a login is needed). The signed live view is never sent: get it with sessions.live(). */
|
|
1863
|
+
consoleUrl: string;
|
|
1864
|
+
since: string;
|
|
1865
|
+
}
|
|
1866
|
+
export interface WebhookAgentRunResumedData {
|
|
1867
|
+
id: string;
|
|
1868
|
+
sessionId: string | null;
|
|
1869
|
+
state: "resumed";
|
|
1870
|
+
/** What it waited for, as in agent_run.waiting. */
|
|
1871
|
+
by: "agent" | "user" | "captcha";
|
|
1872
|
+
/** "handback": a person handed back; "message": a message answered its request for help; "solved": the CAPTCHA was solved. */
|
|
1873
|
+
via: "handback" | "message" | "solved";
|
|
1874
|
+
at: string;
|
|
1875
|
+
}
|
|
1876
|
+
export interface WebhookAgentRunFinishedData {
|
|
1877
|
+
id: string;
|
|
1878
|
+
status: "completed" | "failed" | "canceled";
|
|
1879
|
+
task: string;
|
|
1880
|
+
sessionId: string | null;
|
|
1881
|
+
provider: AgentProvider;
|
|
1882
|
+
model: string | null;
|
|
1883
|
+
result: unknown;
|
|
1884
|
+
resultText: string | null;
|
|
1885
|
+
structured: boolean;
|
|
1886
|
+
error: string | null;
|
|
1887
|
+
errorCode: string | null;
|
|
1888
|
+
continuable: {
|
|
1889
|
+
until: string;
|
|
1890
|
+
} | null;
|
|
1891
|
+
continuedFrom: string | null;
|
|
1892
|
+
/** The names of the run's own variables (never values): continuing it needs their values again. */
|
|
1893
|
+
variableNames: string[];
|
|
1894
|
+
messages: number;
|
|
1895
|
+
usage: {
|
|
1896
|
+
inputTokens: number;
|
|
1897
|
+
outputTokens: number;
|
|
1898
|
+
costUsd: number | null;
|
|
1899
|
+
};
|
|
1900
|
+
taskId: string | null;
|
|
1901
|
+
taskRunId: string | null;
|
|
1902
|
+
createdAt: string;
|
|
1903
|
+
finishedAt: string | null;
|
|
1904
|
+
truncated?: true;
|
|
1905
|
+
}
|
|
1906
|
+
export interface WebhookCaptchaWaitingData {
|
|
1907
|
+
sessionId: string;
|
|
1908
|
+
kind: CaptchaKind;
|
|
1909
|
+
host: string;
|
|
1910
|
+
reason: string | null;
|
|
1911
|
+
since: string;
|
|
1912
|
+
captcha: CaptchaMode;
|
|
1913
|
+
}
|
|
1914
|
+
export interface WebhookCaptchaOutcomeData {
|
|
1915
|
+
sessionId: string;
|
|
1916
|
+
/** The agent run working in the session, if any. */
|
|
1917
|
+
runId: string | null;
|
|
1918
|
+
kind: CaptchaKind;
|
|
1919
|
+
host: string;
|
|
1920
|
+
/** "auto": automatic solving; "person": it cleared while it waited for a person. */
|
|
1921
|
+
by: "auto" | "person";
|
|
1922
|
+
ms: number;
|
|
1923
|
+
/** captcha.failed: why automatic solving failed. */
|
|
1924
|
+
reason?: string;
|
|
1925
|
+
}
|
|
1926
|
+
export interface WebhookCrawlFinishedData {
|
|
1927
|
+
id: string;
|
|
1928
|
+
status: "completed" | "failed" | "canceled";
|
|
1929
|
+
url: string;
|
|
1930
|
+
pagesDone: number;
|
|
1931
|
+
pagesFailed: number;
|
|
1932
|
+
skippedByRobots: number;
|
|
1933
|
+
error: string | null;
|
|
1934
|
+
createdAt: string;
|
|
1935
|
+
finishedAt: string | null;
|
|
1936
|
+
}
|
|
1937
|
+
export interface WebhookTaskRunStartedData {
|
|
1938
|
+
taskId: string;
|
|
1939
|
+
taskName: string | null;
|
|
1940
|
+
taskRunId: string;
|
|
1941
|
+
runId: string;
|
|
1942
|
+
sessionId: string | null;
|
|
1943
|
+
status: "running";
|
|
1944
|
+
scheduled: boolean;
|
|
1945
|
+
scheduledFor: string | null;
|
|
1946
|
+
/** Names only, never values. */
|
|
1947
|
+
variables: string[];
|
|
1948
|
+
startedAt: string;
|
|
1949
|
+
}
|
|
1950
|
+
export interface WebhookTaskRunFinishedData {
|
|
1951
|
+
taskId: string;
|
|
1952
|
+
taskName: string | null;
|
|
1953
|
+
taskRunId: string;
|
|
1954
|
+
runId: string | null;
|
|
1955
|
+
status: "completed" | "failed" | "canceled";
|
|
1956
|
+
scheduled: boolean;
|
|
1957
|
+
scheduledFor: string | null;
|
|
1958
|
+
result: unknown;
|
|
1959
|
+
resultText: string | null;
|
|
1960
|
+
structured: boolean;
|
|
1961
|
+
error: string | null;
|
|
1962
|
+
errorCode: string | null;
|
|
1963
|
+
usage: {
|
|
1964
|
+
inputTokens: number;
|
|
1965
|
+
outputTokens: number;
|
|
1966
|
+
costUsd: number | null;
|
|
1967
|
+
};
|
|
1968
|
+
variables: string[];
|
|
1969
|
+
createdAt: string | null;
|
|
1970
|
+
finishedAt: string | null;
|
|
1971
|
+
truncated?: true;
|
|
1972
|
+
}
|
|
1973
|
+
export interface WebhookSchedulePausedData {
|
|
1974
|
+
taskId: string;
|
|
1975
|
+
taskName: string | null;
|
|
1976
|
+
/** "schedule_invalid": it could not be read; "schedule_ended": it has no more times. */
|
|
1977
|
+
reason: "schedule_invalid" | "schedule_ended";
|
|
1978
|
+
message: string;
|
|
1979
|
+
pausedAt: string;
|
|
1980
|
+
}
|
|
1981
|
+
export interface WebhookUsageLimitData {
|
|
1982
|
+
kind: "model_spend" | "proxy_gb" | "captcha_solves" | "searches" | "concurrency";
|
|
1983
|
+
/** The plan's limit: USD, GB, a count, or sessions at once. */
|
|
1984
|
+
limit: number;
|
|
1985
|
+
used: number;
|
|
1986
|
+
/** "2026-09" (a UTC month), or "2026-09-30T14" (a UTC hour) for concurrency. */
|
|
1987
|
+
period: string;
|
|
1988
|
+
/** When a monthly limit starts over; null for concurrency. */
|
|
1989
|
+
resetsAt: string | null;
|
|
1990
|
+
}
|
|
1991
|
+
export interface WebhookApiKeyData {
|
|
1992
|
+
id: string;
|
|
1993
|
+
/** The key's first 12 characters, as apiKeys.list shows. */
|
|
1994
|
+
prefix: string;
|
|
1995
|
+
name: string;
|
|
1996
|
+
by: WebhookActor;
|
|
1997
|
+
}
|
|
1998
|
+
export interface WebhookSecretChangedData {
|
|
1999
|
+
/** The secret's name, or for a login the context's id. */
|
|
2000
|
+
name: string;
|
|
2001
|
+
action: "created" | "updated" | "deleted";
|
|
2002
|
+
kind: "secret" | "login";
|
|
2003
|
+
by: WebhookActor;
|
|
2004
|
+
/** Field names an update changed ("value", "origins", …). */
|
|
2005
|
+
changed?: string[];
|
|
2006
|
+
}
|
|
2007
|
+
export interface WebhookChangedData {
|
|
2008
|
+
endpointId: string;
|
|
2009
|
+
host: string;
|
|
2010
|
+
action: "created" | "updated" | "deleted" | "secret_rotated";
|
|
2011
|
+
events: WebhookSubscription[];
|
|
2012
|
+
enabled: boolean;
|
|
2013
|
+
by: WebhookActor;
|
|
2014
|
+
changed?: ("url" | "events" | "enabled" | "description")[];
|
|
2015
|
+
}
|
|
2016
|
+
export interface WebhookDisabledData {
|
|
2017
|
+
endpointId: string;
|
|
2018
|
+
host: string;
|
|
2019
|
+
reason: "gone" | "failing";
|
|
2020
|
+
failingSince: string | null;
|
|
2021
|
+
disabledAt: string;
|
|
2022
|
+
}
|
|
2023
|
+
export interface WebhookExtensionData {
|
|
2024
|
+
id: string;
|
|
2025
|
+
name: string;
|
|
2026
|
+
version: string | null;
|
|
2027
|
+
sha256: string | null;
|
|
2028
|
+
by: WebhookActor;
|
|
2029
|
+
}
|
|
2030
|
+
/** Each event type's `data`. */
|
|
2031
|
+
export interface WebhookEventDataMap {
|
|
2032
|
+
"session.started": WebhookSessionData;
|
|
2033
|
+
"session.expiring": WebhookSessionExpiringData;
|
|
2034
|
+
"session.ended": WebhookSessionData;
|
|
2035
|
+
"agent_run.started": WebhookAgentRunStartedData;
|
|
2036
|
+
"agent_run.waiting": WebhookAgentRunWaitingData;
|
|
2037
|
+
"agent_run.resumed": WebhookAgentRunResumedData;
|
|
2038
|
+
"agent_run.finished": WebhookAgentRunFinishedData;
|
|
2039
|
+
"captcha.waiting": WebhookCaptchaWaitingData;
|
|
2040
|
+
"captcha.solved": WebhookCaptchaOutcomeData;
|
|
2041
|
+
"captcha.failed": WebhookCaptchaOutcomeData & {
|
|
2042
|
+
reason: string;
|
|
2043
|
+
};
|
|
2044
|
+
"crawl.finished": WebhookCrawlFinishedData;
|
|
2045
|
+
"task_run.started": WebhookTaskRunStartedData;
|
|
2046
|
+
"task_run.finished": WebhookTaskRunFinishedData;
|
|
2047
|
+
"task.schedule_paused": WebhookSchedulePausedData;
|
|
2048
|
+
"usage.limit_reached": WebhookUsageLimitData;
|
|
2049
|
+
"api_key.created": WebhookApiKeyData;
|
|
2050
|
+
"api_key.revoked": WebhookApiKeyData;
|
|
2051
|
+
"secret.changed": WebhookSecretChangedData;
|
|
2052
|
+
"webhook.changed": WebhookChangedData;
|
|
2053
|
+
"webhook.disabled": WebhookDisabledData;
|
|
2054
|
+
"extension.uploaded": WebhookExtensionData;
|
|
2055
|
+
"extension.deleted": WebhookExtensionData;
|
|
2056
|
+
"webhook.test": {
|
|
2057
|
+
endpointId: string;
|
|
2058
|
+
message: string;
|
|
2059
|
+
};
|
|
2060
|
+
}
|
|
2061
|
+
/** A verified delivery as a union keyed by `type`: `verifyWebhook(…) as WebhookEventPayload`, then switch on `event.type`. */
|
|
2062
|
+
export type WebhookEventPayload = {
|
|
2063
|
+
[K in keyof WebhookEventDataMap]: Omit<WebhookEvent<WebhookEventDataMap[K]>, "type"> & {
|
|
2064
|
+
type: K;
|
|
2065
|
+
};
|
|
2066
|
+
}[keyof WebhookEventDataMap];
|
|
2067
|
+
/**
|
|
2068
|
+
* Where a project secret may be used: "agent" (default): only the AI, as %NAME% in agent runs, plain-English steps and
|
|
2069
|
+
* scripts' step(); "shell": only as an environment variable in session shells and commands; "all": both.
|
|
2070
|
+
*/
|
|
2071
|
+
export type SecretScope = "agent" | "shell" | "all";
|
|
2072
|
+
/** A project secret. Its value is never returned. */
|
|
2073
|
+
export interface Secret {
|
|
2074
|
+
name: string;
|
|
2075
|
+
description: string | null;
|
|
2076
|
+
/** Sites where the AI may type it (null = any site). */
|
|
2077
|
+
origins: string[] | null;
|
|
2078
|
+
/** The AI may use it in bash commands; this also allows exporting it into shells. */
|
|
2079
|
+
shell: boolean;
|
|
2080
|
+
scope: SecretScope;
|
|
2081
|
+
/** "••••1a2b": the last 4 characters of values of 24 characters or more; null for shorter values and secrets with origins. */
|
|
2082
|
+
preview: string | null;
|
|
2083
|
+
createdAt: string;
|
|
2084
|
+
updatedAt: string;
|
|
2085
|
+
lastUsedAt: string | null;
|
|
2086
|
+
}
|
|
2087
|
+
export interface SecretCreateParams {
|
|
2088
|
+
/**
|
|
2089
|
+
* An environment variable name in capitals, [A-Z_][A-Z0-9_]*, at most 64 characters; not one the platform or bash
|
|
2090
|
+
* sets (PATH, HOME, PWD, IFS, …, or starting with BOXLINE_, SANDBOXD_ or BASH_). One per project.
|
|
2091
|
+
*/
|
|
2092
|
+
name: string;
|
|
2093
|
+
/** 1 to 8000 characters, no NUL. Sealed when stored and never returned. */
|
|
2094
|
+
value: string;
|
|
2095
|
+
/** Up to 500 characters. */
|
|
2096
|
+
description?: string;
|
|
2097
|
+
/** Sites where the AI may type it, e.g. ["https://example.com"] (recommended for passwords); 1 to 20. */
|
|
2098
|
+
origins?: string[];
|
|
2099
|
+
/** Let the AI use it in bash commands (and so export it into shells). Default false. */
|
|
2100
|
+
shell?: boolean;
|
|
2101
|
+
/** Default "agent". */
|
|
2102
|
+
scope?: SecretScope;
|
|
2103
|
+
}
|
|
2104
|
+
/** Any of these; `description: null` clears it, `origins: null` allows any site. Changes apply to new uses. */
|
|
2105
|
+
export interface SecretUpdateParams {
|
|
2106
|
+
value?: string;
|
|
2107
|
+
description?: string | null;
|
|
2108
|
+
origins?: string[] | null;
|
|
2109
|
+
shell?: boolean;
|
|
2110
|
+
scope?: SecretScope;
|
|
2111
|
+
}
|
|
2112
|
+
/** One entry of the secrets audit log: a change, or a use (once per session, command, agent run, step session or script). Never values. */
|
|
2113
|
+
export interface SecretAuditEntry {
|
|
2114
|
+
at: string;
|
|
2115
|
+
action: "create" | "update" | "delete" | "use";
|
|
2116
|
+
/** "login": a saved login's details (`name` is the context id). */
|
|
2117
|
+
kind: "secret" | "login";
|
|
2118
|
+
name: string;
|
|
2119
|
+
/** Who changed it: "user:<email>", "key:<api key id>", or "support" (Boxline support acting as a user). */
|
|
2120
|
+
actor: string | null;
|
|
2121
|
+
/** What used it. */
|
|
2122
|
+
usedBy: {
|
|
2123
|
+
type: "session" | "exec" | "agent_run" | "step" | "script" | "task_run";
|
|
2124
|
+
id: string;
|
|
2125
|
+
} | null;
|
|
2126
|
+
details: Record<string, unknown>;
|
|
2127
|
+
}
|
|
2128
|
+
export interface SecretAuditParams extends ListParams {
|
|
2129
|
+
/** One secret (or a context id, for login details). */
|
|
2130
|
+
name?: string;
|
|
2131
|
+
}
|
|
2132
|
+
/** An uploaded Chrome extension (Manifest V3). */
|
|
2133
|
+
export interface ExtensionInfo {
|
|
2134
|
+
id: string;
|
|
2135
|
+
/** From the manifest (resolved from _locales when it uses __MSG_…__). */
|
|
2136
|
+
name: string;
|
|
2137
|
+
version: string;
|
|
2138
|
+
description: string;
|
|
2139
|
+
permissions: string[];
|
|
2140
|
+
hostPermissions: string[];
|
|
2141
|
+
/** Size of the zip. */
|
|
2142
|
+
sizeBytes: number;
|
|
2143
|
+
files: number;
|
|
2144
|
+
/** Of the zip. */
|
|
2145
|
+
sha256: string;
|
|
2146
|
+
createdAt: string;
|
|
2147
|
+
}
|