@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/errors.d.ts
ADDED
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Errors. Every failed call throws a BoxlineError (or a subclass) with the HTTP status, the API's stable
|
|
3
|
+
* snake_case `code`, a message for people, the API's `requestId` to quote when asking for support, and your own
|
|
4
|
+
* `clientRequestId` if you sent one.
|
|
5
|
+
*/
|
|
6
|
+
/** Stable error codes the SDK gives its own class to (docs/CONTRACT.md "Errors"). */
|
|
7
|
+
export declare const ErrorCode: {
|
|
8
|
+
readonly rateLimited: "rate_limited";
|
|
9
|
+
readonly concurrencyLimit: "concurrency_limit";
|
|
10
|
+
readonly featureNotInPlan: "feature_not_in_plan";
|
|
11
|
+
readonly projectSuspended: "project_suspended";
|
|
12
|
+
readonly idempotencyMismatch: "idempotency_mismatch";
|
|
13
|
+
readonly idempotencyInProgress: "idempotency_in_progress";
|
|
14
|
+
readonly invalidCursor: "invalid_cursor";
|
|
15
|
+
readonly captchaTimeout: "captcha_timeout";
|
|
16
|
+
readonly pageUnreachable: "page_unreachable";
|
|
17
|
+
readonly pageTimeout: "page_timeout";
|
|
18
|
+
readonly notAWebPage: "not_a_web_page";
|
|
19
|
+
readonly modelRefused: "model_refused";
|
|
20
|
+
readonly searchUnavailable: "search_unavailable";
|
|
21
|
+
readonly outOfViewport: "out_of_viewport";
|
|
22
|
+
readonly webhookUrlNotAllowed: "webhook_url_not_allowed";
|
|
23
|
+
readonly webhooksUnavailable: "webhooks_unavailable";
|
|
24
|
+
readonly webhookDisabled: "webhook_disabled";
|
|
25
|
+
readonly payloadExpired: "payload_expired";
|
|
26
|
+
/** A delivery's errorCode (never an HTTP error): the project already had 10,000 deliveries waiting. */
|
|
27
|
+
readonly queueFull: "queue_full";
|
|
28
|
+
readonly invalidSignature: "invalid_signature";
|
|
29
|
+
readonly variablesWithExtensions: "variables_with_extensions";
|
|
30
|
+
readonly extensionDenied: "extension_denied";
|
|
31
|
+
readonly crossSiteRequest: "cross_site_request";
|
|
32
|
+
readonly invalidExtension: "invalid_extension";
|
|
33
|
+
readonly payloadTooLarge: "payload_too_large";
|
|
34
|
+
readonly limitReached: "limit_reached";
|
|
35
|
+
readonly missingVariables: "missing_variables";
|
|
36
|
+
readonly planLimit: "plan_limit";
|
|
37
|
+
readonly tooManySecretValues: "too_many_secret_values";
|
|
38
|
+
readonly secretExists: "secret_exists";
|
|
39
|
+
readonly secretNotForAi: "secret_not_for_ai";
|
|
40
|
+
readonly secretNotForShell: "secret_not_for_shell";
|
|
41
|
+
readonly machineTooOld: "machine_too_old";
|
|
42
|
+
/**
|
|
43
|
+
* An agent or task run's errorCode (never an HTTP error): the answer did not match the run's output schema after the
|
|
44
|
+
* repair try (the run's `error` lists the problems).
|
|
45
|
+
*/
|
|
46
|
+
readonly outputInvalid: "output_invalid";
|
|
47
|
+
/**
|
|
48
|
+
* Agent-run errorCodes (never HTTP errors) for a run that stopped at one of its limits and can be continued
|
|
49
|
+
* (agent.continueRun) while its `continuable` is set: its maxSteps, its maxCostUsd, maxConsecutiveErrors tool errors in
|
|
50
|
+
* a row, or the same call with the same result 5 times in a row.
|
|
51
|
+
*/
|
|
52
|
+
readonly maxSteps: "max_steps";
|
|
53
|
+
readonly maxCost: "max_cost";
|
|
54
|
+
readonly tooManyErrors: "too_many_errors";
|
|
55
|
+
readonly noProgress: "no_progress";
|
|
56
|
+
/**
|
|
57
|
+
* Agent-run errorCode (continuable like the limits): the API server running the loop stopped (a restart, a deploy)
|
|
58
|
+
* while its session went on; agent.continueRun picks it up in the same browser.
|
|
59
|
+
*/
|
|
60
|
+
readonly serverRestarted: "server_restarted";
|
|
61
|
+
/** Agent-run errorCodes: its session reached its time limit, or ended another way, while it worked (not continuable). */
|
|
62
|
+
readonly sessionTimeout: "session_timeout";
|
|
63
|
+
readonly sessionEnded: "session_ended";
|
|
64
|
+
/** 409: agent.continueRun on a run that did not stop at a limit, was continued already, or whose window passed. */
|
|
65
|
+
readonly notContinuable: "not_continuable";
|
|
66
|
+
/** 409: agent.sendMessage after 50 messages to one run. */
|
|
67
|
+
readonly tooManyMessages: "too_many_messages";
|
|
68
|
+
/** 409: takeover, handBack or sendMessage on a run whose server stopped (continue it instead). */
|
|
69
|
+
readonly runNotLive: "run_not_live";
|
|
70
|
+
/** 400: project.setModelKey when the provider does not accept the key (nothing is saved). */
|
|
71
|
+
readonly invalidModelKey: "invalid_model_key";
|
|
72
|
+
/** 400: a call on the project's own model key was refused by the provider (a run ends with this errorCode); never falls back to Boxline's key. */
|
|
73
|
+
readonly modelKeyRejected: "model_key_rejected";
|
|
74
|
+
/** 502: another failure of a call on the project's own model key (the provider's text, key scrubbed). */
|
|
75
|
+
readonly modelError: "model_error";
|
|
76
|
+
/** 413: contexts.create({fromSession}) when the session's cookies and site storage exceed 16 MB. */
|
|
77
|
+
readonly contextTooLarge: "context_too_large";
|
|
78
|
+
/** 409: the session has ended (e.g. an agent run or continueRun in it). */
|
|
79
|
+
readonly sessionNotRunning: "session_not_running";
|
|
80
|
+
readonly unauthorized: "unauthorized";
|
|
81
|
+
readonly notFound: "not_found";
|
|
82
|
+
readonly connectionError: "connection_error";
|
|
83
|
+
readonly timeout: "timeout";
|
|
84
|
+
};
|
|
85
|
+
export interface ErrorDetails {
|
|
86
|
+
/** The API's request id (error body, else the X-Request-Id header); null when no response came back. */
|
|
87
|
+
requestId?: string | null;
|
|
88
|
+
/** Your own id for the request (RequestOptions.clientRequestId), as the API echoed it in X-Client-Request-Id. */
|
|
89
|
+
clientRequestId?: string | null;
|
|
90
|
+
headers?: Headers;
|
|
91
|
+
/** The parsed error body, when there was one. */
|
|
92
|
+
body?: unknown;
|
|
93
|
+
cause?: unknown;
|
|
94
|
+
}
|
|
95
|
+
export declare class BoxlineError extends Error {
|
|
96
|
+
readonly status: number;
|
|
97
|
+
readonly code: string;
|
|
98
|
+
/** The API's id for the request: quote it when asking for support. */
|
|
99
|
+
readonly requestId: string | null;
|
|
100
|
+
/** Your own id for the request, if you sent one (RequestOptions.clientRequestId). */
|
|
101
|
+
readonly clientRequestId: string | null;
|
|
102
|
+
/** Response headers (RateLimit-*, Retry-After, …); undefined when no response came back. */
|
|
103
|
+
readonly headers?: Headers;
|
|
104
|
+
readonly body?: unknown;
|
|
105
|
+
constructor(status: number, code: string, message: string, details?: ErrorDetails);
|
|
106
|
+
/** Whether trying the same call again later can succeed (rate limits, server errors, network trouble). */
|
|
107
|
+
get retryable(): boolean;
|
|
108
|
+
}
|
|
109
|
+
/** 429: too many requests (`rate_limited`) or all of the plan's concurrent sessions in use (`concurrency_limit`). */
|
|
110
|
+
export declare class RateLimitError extends BoxlineError {
|
|
111
|
+
/** Seconds the server asked to wait (Retry-After), when it said. */
|
|
112
|
+
readonly retryAfter: number | null;
|
|
113
|
+
constructor(status: number, code: string, message: string, details?: ErrorDetails);
|
|
114
|
+
}
|
|
115
|
+
/** 402 `feature_not_in_plan`: the project's plan does not include this. */
|
|
116
|
+
export declare class FeatureNotInPlanError extends BoxlineError {
|
|
117
|
+
name: string;
|
|
118
|
+
}
|
|
119
|
+
/** 403 `project_suspended`: an admin suspended the project; the message says why. */
|
|
120
|
+
export declare class ProjectSuspendedError extends BoxlineError {
|
|
121
|
+
name: string;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* 422 `idempotency_mismatch`: this Idempotency-Key was already used for a different request (another body or route),
|
|
125
|
+
* or, for a new API key, by another caller (another API key or console login).
|
|
126
|
+
*/
|
|
127
|
+
export declare class IdempotencyMismatchError extends BoxlineError {
|
|
128
|
+
name: string;
|
|
129
|
+
}
|
|
130
|
+
/** 409 `idempotency_in_progress`: the first request with this key is still being answered (retried automatically). */
|
|
131
|
+
export declare class IdempotencyInProgressError extends BoxlineError {
|
|
132
|
+
name: string;
|
|
133
|
+
}
|
|
134
|
+
/** 400 `invalid_cursor`: `after` is not a `next` value of that list. */
|
|
135
|
+
export declare class InvalidCursorError extends BoxlineError {
|
|
136
|
+
name: string;
|
|
137
|
+
}
|
|
138
|
+
/** `captcha_timeout`: a CAPTCHA kept waiting for a person (a plain-English step, or waitForHuman). */
|
|
139
|
+
export declare class CaptchaTimeoutError extends BoxlineError {
|
|
140
|
+
name: string;
|
|
141
|
+
}
|
|
142
|
+
/** 502 `page_unreachable` (fetch, screenshot, pdf, extract): the page could not be loaded; the message says why. */
|
|
143
|
+
export declare class PageUnreachableError extends BoxlineError {
|
|
144
|
+
name: string;
|
|
145
|
+
}
|
|
146
|
+
/** 504 `page_timeout` (fetch, screenshot, pdf, extract): the page did not finish loading within `timeoutMs`. */
|
|
147
|
+
export declare class PageTimeoutError extends BoxlineError {
|
|
148
|
+
name: string;
|
|
149
|
+
}
|
|
150
|
+
/** 422 `not_a_web_page` (fetch, extract, search, crawl): the address is a file Chrome only displays (a PDF), with no page text. */
|
|
151
|
+
export declare class NotAWebPageError extends BoxlineError {
|
|
152
|
+
name: string;
|
|
153
|
+
}
|
|
154
|
+
/** 422 `model_refused` (extract): the model declined to extract from these pages. */
|
|
155
|
+
export declare class ModelRefusedError extends BoxlineError {
|
|
156
|
+
name: string;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* 503 `search_unavailable`: web search is not set up on this server, or its provider did not answer or is limiting
|
|
160
|
+
* the platform (then `retryable`, with Retry-After).
|
|
161
|
+
*/
|
|
162
|
+
export declare class SearchUnavailableError extends BoxlineError {
|
|
163
|
+
name: string;
|
|
164
|
+
}
|
|
165
|
+
/** 400 `out_of_viewport`: a mouse action's point is outside the page (or the computer-use screenshot). */
|
|
166
|
+
export declare class OutOfViewportError extends BoxlineError {
|
|
167
|
+
name: string;
|
|
168
|
+
}
|
|
169
|
+
/** 400 `webhook_url_not_allowed`: webhook endpoints must be public HTTPS addresses (the message says what is wrong). */
|
|
170
|
+
export declare class WebhookUrlNotAllowedError extends BoxlineError {
|
|
171
|
+
name: string;
|
|
172
|
+
}
|
|
173
|
+
/** 503 `webhooks_unavailable`: webhook delivery is not set up on this server. */
|
|
174
|
+
export declare class WebhooksUnavailableError extends BoxlineError {
|
|
175
|
+
name: string;
|
|
176
|
+
}
|
|
177
|
+
/** 409 `webhook_disabled`: the endpoint is switched off; turn it on (update enabled: true) first. */
|
|
178
|
+
export declare class WebhookDisabledError extends BoxlineError {
|
|
179
|
+
name: string;
|
|
180
|
+
}
|
|
181
|
+
/** 409 `payload_expired`: the event's body is kept 7 days; that delivery can no longer be sent again. */
|
|
182
|
+
export declare class PayloadExpiredError extends BoxlineError {
|
|
183
|
+
name: string;
|
|
184
|
+
}
|
|
185
|
+
/** 400 `variables_with_extensions`: an agent run with variables in a session with extensions (see allowWithExtensions). */
|
|
186
|
+
export declare class VariablesWithExtensionsError extends BoxlineError {
|
|
187
|
+
name: string;
|
|
188
|
+
}
|
|
189
|
+
/** 403 `extension_denied`: the operator does not allow this extension. */
|
|
190
|
+
export declare class ExtensionDeniedError extends BoxlineError {
|
|
191
|
+
name: string;
|
|
192
|
+
}
|
|
193
|
+
/** 403 `cross_site_request`: a console-login upload that did not come from the platform's own sites. */
|
|
194
|
+
export declare class CrossSiteRequestError extends BoxlineError {
|
|
195
|
+
name: string;
|
|
196
|
+
}
|
|
197
|
+
/** 400 `invalid_extension`: the zip is not an acceptable Manifest V3 extension (the message says why). */
|
|
198
|
+
export declare class InvalidExtensionError extends BoxlineError {
|
|
199
|
+
name: string;
|
|
200
|
+
}
|
|
201
|
+
/** 413 `payload_too_large`: the body is larger than the route allows (an extension zip: 10 MB). */
|
|
202
|
+
export declare class PayloadTooLargeError extends BoxlineError {
|
|
203
|
+
name: string;
|
|
204
|
+
}
|
|
205
|
+
/** 409 `limit_reached`: the project has as many as it may (e.g. 100 extensions). */
|
|
206
|
+
export declare class LimitReachedError extends BoxlineError {
|
|
207
|
+
name: string;
|
|
208
|
+
}
|
|
209
|
+
/** 400 `missing_variables`: a task run (or its schedule) has no value for a variable without a default; the message names them. */
|
|
210
|
+
export declare class MissingVariablesError extends BoxlineError {
|
|
211
|
+
name: string;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* `plan_limit`: the plan allows no more of this (402: tasks, schedules switched on, searches on Free, project
|
|
215
|
+
* secrets beyond `maxSecrets`, a session longer than the plan allows); the message says the limit.
|
|
216
|
+
*/
|
|
217
|
+
export declare class PlanLimitError extends BoxlineError {
|
|
218
|
+
name: string;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* 409 `too_many_secret_values`: the session already hides as many earlier secret values in its output as it can (256
|
|
222
|
+
* values or 256 KB); a session create, exec, agent run or step adding more is refused. Start a new session.
|
|
223
|
+
*/
|
|
224
|
+
export declare class TooManySecretValuesError extends BoxlineError {
|
|
225
|
+
name: string;
|
|
226
|
+
}
|
|
227
|
+
/** 409 `secret_exists`: the project has a secret with that name; change it with secrets.update. */
|
|
228
|
+
export declare class SecretExistsError extends BoxlineError {
|
|
229
|
+
name: string;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* 400 `secret_not_for_ai` / `secret_not_for_shell`: the secret's scope does not allow this use (scope "shell" is not for
|
|
233
|
+
* the AI; a secret goes into a shell only with scope "shell" or "all", or shell: true).
|
|
234
|
+
*/
|
|
235
|
+
export declare class SecretNotAllowedError extends BoxlineError {
|
|
236
|
+
name: string;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* 409 `machine_too_old`: the session's machine comes from an image older than the API (during a deploy) and cannot take
|
|
240
|
+
* `env` or `secrets`; start a new session.
|
|
241
|
+
*/
|
|
242
|
+
export declare class MachineTooOldError extends BoxlineError {
|
|
243
|
+
name: string;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* 409 `not_continuable`: agent.continueRun on a run that did not stop at one of its limits, was already continued (the
|
|
247
|
+
* message names the run that did), or whose continue window has passed.
|
|
248
|
+
*/
|
|
249
|
+
export declare class NotContinuableError extends BoxlineError {
|
|
250
|
+
name: string;
|
|
251
|
+
}
|
|
252
|
+
/** 409 `too_many_messages`: a run takes at most 50 messages (agent.sendMessage). */
|
|
253
|
+
export declare class TooManyMessagesError extends BoxlineError {
|
|
254
|
+
name: string;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* 409 `run_not_live`: agent.takeover, handBack or sendMessage on a run whose API server stopped (a restart, a deploy):
|
|
258
|
+
* no loop is left to act on it. Continue it (agent.continueRun) once it shows as failed with `server_restarted`.
|
|
259
|
+
*/
|
|
260
|
+
export declare class RunNotLiveError extends BoxlineError {
|
|
261
|
+
name: string;
|
|
262
|
+
}
|
|
263
|
+
/** 409 `session_not_running`: the session has ended (an agent run started or continued in it, a command, …). */
|
|
264
|
+
export declare class SessionNotRunningError extends BoxlineError {
|
|
265
|
+
name: string;
|
|
266
|
+
}
|
|
267
|
+
/** Why verifyWebhook refused a delivery. */
|
|
268
|
+
export type WebhookSignatureFailure = "malformed" | "timestamp_out_of_range" | "no_matching_signature";
|
|
269
|
+
/**
|
|
270
|
+
* verifyWebhook refused a delivery (not an API error: answer the sender 400). `reason`: the Boxline-Signature header
|
|
271
|
+
* is missing or malformed, its timestamp is too far from now (a replay), or no signature matches the secret(s).
|
|
272
|
+
*/
|
|
273
|
+
export declare class WebhookSignatureError extends BoxlineError {
|
|
274
|
+
readonly reason: WebhookSignatureFailure;
|
|
275
|
+
constructor(reason: WebhookSignatureFailure, message: string);
|
|
276
|
+
get retryable(): boolean;
|
|
277
|
+
}
|
|
278
|
+
/** 401: missing or invalid API key. */
|
|
279
|
+
export declare class AuthenticationError extends BoxlineError {
|
|
280
|
+
name: string;
|
|
281
|
+
}
|
|
282
|
+
/** 404: no such thing in this project. */
|
|
283
|
+
export declare class NotFoundError extends BoxlineError {
|
|
284
|
+
name: string;
|
|
285
|
+
}
|
|
286
|
+
/** No response: the network failed or the server went away (retried automatically where safe). */
|
|
287
|
+
export declare class BoxlineConnectionError extends BoxlineError {
|
|
288
|
+
constructor(message: string, details?: ErrorDetails);
|
|
289
|
+
get retryable(): boolean;
|
|
290
|
+
}
|
|
291
|
+
/** The request took longer than its time limit (`timeoutMs`). */
|
|
292
|
+
export declare class BoxlineTimeoutError extends BoxlineConnectionError {
|
|
293
|
+
constructor(message: string, details?: ErrorDetails);
|
|
294
|
+
}
|
|
295
|
+
/** The error class for an API error: by its code first, then by its status. */
|
|
296
|
+
export declare function makeError(status: number, code: string, message: string, details?: ErrorDetails): BoxlineError;
|
|
297
|
+
/** Retry-After in seconds (a number of seconds or an HTTP date); null when absent or unreadable. */
|
|
298
|
+
export declare function retryAfterSeconds(headers?: Headers): number | null;
|
|
299
|
+
/** Turns an error response into a typed error. The body is read here (it is small JSON); this never throws. */
|
|
300
|
+
export declare function errorFromResponse(res: Response, method: string, path: string, sentClientId?: string): Promise<BoxlineError>;
|