@steerpane/sdk 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +109 -2
- package/dist/client.d.ts +409 -0
- package/dist/client.js +506 -0
- package/dist/errors.d.ts +28 -0
- package/dist/errors.js +49 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +5 -0
- package/dist/playwright.d.ts +16 -0
- package/dist/playwright.js +20 -0
- package/dist/types.d.ts +454 -0
- package/dist/types.js +1 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +1 -0
- package/dist/webhooks.d.ts +17 -0
- package/dist/webhooks.js +64 -0
- package/package.json +29 -4
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
import { APIError } from "./errors.js";
|
|
2
|
+
import type { ActionGuard, ActionGuardRule, ActionGuardUnlock, AgentRun, CaptchaSolveResult, Capture, Credential, CrawlJob, Device, DevicePairingCode, EmbedLink, EndUser, FetchResult, HelpRequest, HumanResult, Json, Page, Profile, SearchResponse, SecretFillResult, Session, StoredFile, UploadUrl, WaitForCodeOptions, WaitForCodeResult, Webhook, WebhookDelivery } from "./types.js";
|
|
3
|
+
export declare const DEFAULT_BASE_URL = "https://api.steerpane.app";
|
|
4
|
+
export interface SteerpaneOptions {
|
|
5
|
+
/** Falls back to `STEERPANE_API_TOKEN`. */
|
|
6
|
+
token?: string;
|
|
7
|
+
/** Falls back to `STEERPANE_API_URL`, then `DEFAULT_BASE_URL`. */
|
|
8
|
+
baseUrl?: string;
|
|
9
|
+
timeoutMs?: number;
|
|
10
|
+
maxRetries?: number;
|
|
11
|
+
/** Allow sending the token over plain http to a host that isn't local. */
|
|
12
|
+
allowInsecureHttp?: boolean;
|
|
13
|
+
/** Replace `fetch`, for tests. */
|
|
14
|
+
fetch?: typeof fetch;
|
|
15
|
+
/** Who your program is, e.g. "Acme support bot" (falls back to `STEERPANE_AGENT_NAME`). The dashboard shows it on the sessions it
|
|
16
|
+
* drives, their activity and the agent cursor (sent as `X-Steerpane-Agent`). Without it the token's name is shown. */
|
|
17
|
+
agentName?: string;
|
|
18
|
+
}
|
|
19
|
+
interface RequestOptions {
|
|
20
|
+
json?: unknown;
|
|
21
|
+
params?: Record<string, unknown>;
|
|
22
|
+
headers?: Record<string, string>;
|
|
23
|
+
body?: FormData;
|
|
24
|
+
timeoutMs?: number;
|
|
25
|
+
}
|
|
26
|
+
/** Browser actions, `POST /v1/sessions/{id}/actions`. While a human holds control, acting calls throw `HumanInControlError` and queue. */
|
|
27
|
+
declare class Actions {
|
|
28
|
+
private readonly c;
|
|
29
|
+
constructor(c: Steerpane);
|
|
30
|
+
/** Run any action type. `waitS` holds the call until a takeover ends instead of throwing, up to 600 seconds. */
|
|
31
|
+
run<T = Json>(sessionId: string, type: string, args?: Json, options?: {
|
|
32
|
+
waitS?: number;
|
|
33
|
+
}): Promise<T>;
|
|
34
|
+
navigate(sessionId: string, url: string, args?: Json): Promise<Json>;
|
|
35
|
+
click(sessionId: string, selector: string, args?: Json): Promise<Json>;
|
|
36
|
+
type(sessionId: string, selector: string, text: string, args?: Json): Promise<Json>;
|
|
37
|
+
pressKey(sessionId: string, key: string, args?: Json): Promise<Json>;
|
|
38
|
+
selectOption(sessionId: string, selector: string, option: string, args?: Json): Promise<Json>;
|
|
39
|
+
scroll(sessionId: string, args?: Json): Promise<Json>;
|
|
40
|
+
/** Exactly one of `selector` (+ `state`), `text`, `url`, `load_state` or `ms`. `timeout_ms` defaults to 10000. */
|
|
41
|
+
waitFor(sessionId: string, args: Json): Promise<Json>;
|
|
42
|
+
snapshot(sessionId: string, args?: Json): Promise<Json>;
|
|
43
|
+
getPageText(sessionId: string, args?: Json): Promise<{
|
|
44
|
+
text: string;
|
|
45
|
+
} & Json>;
|
|
46
|
+
elementState(sessionId: string, selector: string, args?: Json): Promise<Json>;
|
|
47
|
+
formFields(sessionId: string, args?: Json): Promise<{
|
|
48
|
+
fields: Json[];
|
|
49
|
+
} & Json>;
|
|
50
|
+
screenshot(sessionId: string, args?: Json): Promise<Json>;
|
|
51
|
+
/** Run JavaScript in the page. `code` is a function body, so use `return` to get a value back as `result`. */
|
|
52
|
+
execute<R = unknown>(sessionId: string, code: string, args?: Json): Promise<{
|
|
53
|
+
result: R;
|
|
54
|
+
} & Json>;
|
|
55
|
+
/** Needs a model key on the organization. */
|
|
56
|
+
extract(sessionId: string, instruction: string, args?: Json): Promise<Json>;
|
|
57
|
+
download(sessionId: string, args?: Json): Promise<Json>;
|
|
58
|
+
uploadFile(sessionId: string, args?: Json): Promise<Json>;
|
|
59
|
+
/** Type a value you hold (a password, an access code) into ONE field of the page, on the site you name. `POST /v1/sessions/{id}/secret-fill`; needs the `vault:use` scope.
|
|
60
|
+
* The runtime checks the origin of the frame holding the field against `site` in the same step that types (`exact: true`: the host must match exactly, no subdomains).
|
|
61
|
+
* `kind` is `password` (default; the field must be a password input) or `code`. `submit` and `exact` must be real booleans.
|
|
62
|
+
*
|
|
63
|
+
* The value is never logged, recorded, queued or returned (the result shows `value: "••••••"`). The SDK doesn't echo it either, and this call is NEVER retried: no
|
|
64
|
+
* automatic retry, no Idempotency-Key (the API refuses one). Treat every failure that isn't a definitive refusal before typing (`origin_mismatch`, `insecure_origin`,
|
|
65
|
+
* `field_type_mismatch`, `element_not_found`, ...) as "maybe typed": look at the page before you send it again.
|
|
66
|
+
* **`typed: true` in the result, or a 409 with `details.typed`, means the value is already in the page: do not send it again.** A human in control or a paused agent
|
|
67
|
+
* answers 409 `human_in_control` with nothing typed; a secret is never queued. */
|
|
68
|
+
secretFill(sessionId: string, input: {
|
|
69
|
+
site: string;
|
|
70
|
+
selector: string;
|
|
71
|
+
value: string;
|
|
72
|
+
kind?: "password" | "code";
|
|
73
|
+
submit?: boolean;
|
|
74
|
+
exact?: boolean;
|
|
75
|
+
frame?: string;
|
|
76
|
+
}): Promise<SecretFillResult>;
|
|
77
|
+
/** Type a stored credential into the page. The secret never comes back. Refused off the credential's site. */
|
|
78
|
+
vaultFill(sessionId: string, credentialId: string, args?: Json): Promise<Json>;
|
|
79
|
+
}
|
|
80
|
+
declare class Sessions {
|
|
81
|
+
private readonly c;
|
|
82
|
+
constructor(c: Steerpane);
|
|
83
|
+
list(params?: {
|
|
84
|
+
status?: string;
|
|
85
|
+
profile_id?: string;
|
|
86
|
+
q?: string;
|
|
87
|
+
project_id?: string;
|
|
88
|
+
end_user_id?: string;
|
|
89
|
+
limit?: number;
|
|
90
|
+
cursor?: string | null;
|
|
91
|
+
}): Promise<Page<Session>>;
|
|
92
|
+
/** Start a browser. `config` takes the session fields in the API docs, such as `initial_url`, `profile_id`, `end_user_id`, `auto_close`, `timeout_min`.
|
|
93
|
+
* `profile_wait: { timeout_s: 300 }` queues behind the profile's current writer instead of failing with 409 `profile_locked`: the session comes back with
|
|
94
|
+
* `status: "queued"` and `queue_position`; stop it to cancel. Without `profile_id` you get a throwaway browser that saves nothing. */
|
|
95
|
+
create(config?: Json, options?: {
|
|
96
|
+
idempotencyKey?: string;
|
|
97
|
+
}): Promise<Session>;
|
|
98
|
+
get(sessionId: string): Promise<Session>;
|
|
99
|
+
/** Wait for the browser to leave `starting` (and `queued`, for a session created with `profile_wait`: raise `timeoutS` to cover the wait). Throws if it ends instead, or doesn't start in time. */
|
|
100
|
+
waitUntilReady(sessionId: string, options?: {
|
|
101
|
+
timeoutS?: number;
|
|
102
|
+
pollS?: number;
|
|
103
|
+
}): Promise<Session>;
|
|
104
|
+
stop(sessionId: string): Promise<Session>;
|
|
105
|
+
delete(sessionId: string): Promise<void>;
|
|
106
|
+
keepalive(sessionId: string): Promise<Session>;
|
|
107
|
+
takeover(sessionId: string): Promise<Session>;
|
|
108
|
+
/** Give control back. The waiting agent receives `outcome` and `note`. */
|
|
109
|
+
handback(sessionId: string, input?: {
|
|
110
|
+
outcome?: "done" | "not_done";
|
|
111
|
+
note?: string;
|
|
112
|
+
}): Promise<Session>;
|
|
113
|
+
/** Name what the agent may not click or submit without approval. `rules` replaces the current ones; `[]` removes the guard. A blocked action fails with the
|
|
114
|
+
* `action_guard_blocked` error code until `unlockAction` is called. The service ships no rules of its own. */
|
|
115
|
+
setActionGuard(sessionId: string, rules: ActionGuardRule[]): Promise<ActionGuard>;
|
|
116
|
+
getActionGuard(sessionId: string): Promise<ActionGuard>;
|
|
117
|
+
removeActionGuard(sessionId: string): Promise<void>;
|
|
118
|
+
/** Approve ONE blocked gesture (the next matching click, Enter-submit or form submit, optionally only for `ruleId`) within `ttlS` seconds (1 to 120, default 30). Needs the `takeover` scope.
|
|
119
|
+
* The result's `late_targets` counts frames where a page script may have registered a listener ahead of the guard; if you need certainty, decline to rely on the guard when it is above 0.
|
|
120
|
+
* An action that spends the unlock returns `unlock_spent: true`, and an error it ends with carries `details.unlock_spent: true` (read it from `APIError.details`/`ToolError.details`): the act may have happened, so never click again, whatever the error.
|
|
121
|
+
* A session whose guard can't be installed refuses guarded actions with `action_guard_unavailable`. */
|
|
122
|
+
unlockAction(sessionId: string, options?: {
|
|
123
|
+
ruleId?: string;
|
|
124
|
+
ttlS?: number;
|
|
125
|
+
}): Promise<ActionGuardUnlock>;
|
|
126
|
+
/** Run the CAPTCHA solver on the session's page. One call waits about 45 s: while `status` is `in_progress`, call again (the worker keeps running, it never restarts).
|
|
127
|
+
* `onFailure` is `wait_for_human` (default), `request_help` or `return`. Needs a CAPTCHA model on the organization. */
|
|
128
|
+
solveCaptcha(sessionId: string, options?: {
|
|
129
|
+
onFailure?: "wait_for_human" | "request_help" | "return";
|
|
130
|
+
maxReloads?: number;
|
|
131
|
+
model?: string;
|
|
132
|
+
captchaImageSelector?: string;
|
|
133
|
+
captchaInputSelector?: string;
|
|
134
|
+
}): Promise<CaptchaSolveResult>;
|
|
135
|
+
/** Ask a person for help. The agent goes on hold, and `agent.human_help_requested` fires. */
|
|
136
|
+
requestHelp(sessionId: string, input: {
|
|
137
|
+
reason: string;
|
|
138
|
+
message?: string;
|
|
139
|
+
}): Promise<HelpRequest>;
|
|
140
|
+
/** Long-poll until the human hands back. `status` is `handed_back`, `timeout` (call again) or `stopped`. */
|
|
141
|
+
waitForHuman(sessionId: string, options?: {
|
|
142
|
+
requestId?: string;
|
|
143
|
+
timeoutS?: number;
|
|
144
|
+
}): Promise<HumanResult>;
|
|
145
|
+
events(sessionId: string, params?: {
|
|
146
|
+
limit?: number;
|
|
147
|
+
cursor?: string | null;
|
|
148
|
+
}): Promise<Page<Json>>;
|
|
149
|
+
files(sessionId: string): Promise<Json>;
|
|
150
|
+
/** Pack what the session downloaded into one ZIP in the file store. */
|
|
151
|
+
zipFiles(sessionId: string): Promise<Json>;
|
|
152
|
+
}
|
|
153
|
+
declare class Profiles {
|
|
154
|
+
private readonly c;
|
|
155
|
+
constructor(c: Steerpane);
|
|
156
|
+
list(params?: {
|
|
157
|
+
tag?: string;
|
|
158
|
+
q?: string;
|
|
159
|
+
end_user_id?: string;
|
|
160
|
+
limit?: number;
|
|
161
|
+
cursor?: string | null;
|
|
162
|
+
}): Promise<Page<Profile>>;
|
|
163
|
+
get(profileId: string): Promise<Profile>;
|
|
164
|
+
/** `fields` include `end_user_id` to give the profile to one of your end users. */
|
|
165
|
+
create(name: string, fields?: Json): Promise<Profile>;
|
|
166
|
+
update(profileId: string, fields: Json): Promise<Profile>;
|
|
167
|
+
delete(profileId: string): Promise<void>;
|
|
168
|
+
clone(profileId: string): Promise<Profile>;
|
|
169
|
+
/** Really load each signed-in site with the profile's state, and report whether it is still signed in. */
|
|
170
|
+
verify(profileId: string, input?: {
|
|
171
|
+
domains?: string[];
|
|
172
|
+
}): Promise<Json>;
|
|
173
|
+
lock(profileId: string): Promise<Json>;
|
|
174
|
+
importCookies(profileId: string, cookies: Json[]): Promise<{
|
|
175
|
+
imported: number;
|
|
176
|
+
}>;
|
|
177
|
+
}
|
|
178
|
+
/** Your own customers. Profiles and sessions can belong to one; a session only uses profiles of its own end user. */
|
|
179
|
+
declare class EndUsers {
|
|
180
|
+
private readonly c;
|
|
181
|
+
constructor(c: Steerpane);
|
|
182
|
+
/** Idempotent on `external_id`: calling it again returns the existing end user unchanged. */
|
|
183
|
+
create(externalId: string, fields?: {
|
|
184
|
+
name?: string;
|
|
185
|
+
metadata?: Record<string, string>;
|
|
186
|
+
}): Promise<EndUser>;
|
|
187
|
+
list(params?: {
|
|
188
|
+
external_id?: string;
|
|
189
|
+
limit?: number;
|
|
190
|
+
cursor?: string | null;
|
|
191
|
+
}): Promise<Page<EndUser>>;
|
|
192
|
+
get(endUserId: string): Promise<EndUser>;
|
|
193
|
+
update(endUserId: string, fields: {
|
|
194
|
+
name?: string;
|
|
195
|
+
metadata?: Record<string, string>;
|
|
196
|
+
disabled?: boolean;
|
|
197
|
+
}): Promise<EndUser>;
|
|
198
|
+
/** 409 while it owns profiles or live sessions; `cascade: true` deletes its profiles too (never while a session is live). */
|
|
199
|
+
delete(endUserId: string, options?: {
|
|
200
|
+
cascade?: boolean;
|
|
201
|
+
}): Promise<void>;
|
|
202
|
+
/** A single-use code (valid a few minutes) to hand to this end user so they can pair their own computer. Answers 404 while devices are off for the service. */
|
|
203
|
+
createDevicePairingCode(endUserId: string): Promise<DevicePairingCode>;
|
|
204
|
+
}
|
|
205
|
+
/** Computers that run sessions: yours, shared ones, and your end users'. Answers 404 while devices are off for the service. */
|
|
206
|
+
declare class Devices {
|
|
207
|
+
private readonly c;
|
|
208
|
+
constructor(c: Steerpane);
|
|
209
|
+
/** `scope` is `user`, `org` or `end_user`; `end_user_id` narrows to one end user's devices. Capped at 200, no cursor. */
|
|
210
|
+
list(params?: {
|
|
211
|
+
scope?: "user" | "org" | "end_user";
|
|
212
|
+
end_user_id?: string;
|
|
213
|
+
}): Promise<{
|
|
214
|
+
data: Device[];
|
|
215
|
+
}>;
|
|
216
|
+
get(deviceId: string): Promise<Device>;
|
|
217
|
+
}
|
|
218
|
+
/** Hosted agent runs. These use your organization's own model key. */
|
|
219
|
+
declare class Runs {
|
|
220
|
+
private readonly c;
|
|
221
|
+
constructor(c: Steerpane);
|
|
222
|
+
/** `fields`: `profile_id`, `agent_id`, `model`, `max_steps`, `max_cost_usd`, `max_duration_s`, `result_schema`, `variables`, `project_id`. */
|
|
223
|
+
create(task: string, fields?: Json, options?: {
|
|
224
|
+
idempotencyKey?: string;
|
|
225
|
+
}): Promise<AgentRun>;
|
|
226
|
+
get(runId: string): Promise<AgentRun>;
|
|
227
|
+
list(params?: {
|
|
228
|
+
status?: string;
|
|
229
|
+
agent_id?: string;
|
|
230
|
+
project_id?: string;
|
|
231
|
+
limit?: number;
|
|
232
|
+
cursor?: string | null;
|
|
233
|
+
}): Promise<Page<AgentRun>>;
|
|
234
|
+
messages(runId: string): Promise<Page<Json>>;
|
|
235
|
+
cancel(runId: string): Promise<AgentRun>;
|
|
236
|
+
/** Poll until the run finishes. Returns the run whatever its outcome, so check `status`. */
|
|
237
|
+
wait(runId: string, options?: {
|
|
238
|
+
timeoutS?: number;
|
|
239
|
+
pollS?: number;
|
|
240
|
+
}): Promise<AgentRun>;
|
|
241
|
+
}
|
|
242
|
+
declare class Files {
|
|
243
|
+
private readonly c;
|
|
244
|
+
constructor(c: Steerpane);
|
|
245
|
+
/** Store a file: a path, or bytes with `name`. The result's `id` goes straight into `actions.uploadFile(sessionId, { file_id })`. */
|
|
246
|
+
upload(file: string | Uint8Array, options?: {
|
|
247
|
+
name?: string;
|
|
248
|
+
mime?: string;
|
|
249
|
+
ttlHours?: number;
|
|
250
|
+
}): Promise<StoredFile>;
|
|
251
|
+
createUploadUrl(name: string, fields?: {
|
|
252
|
+
mime?: string;
|
|
253
|
+
size_bytes?: number;
|
|
254
|
+
ttl_hours?: number;
|
|
255
|
+
}): Promise<UploadUrl>;
|
|
256
|
+
list(params?: {
|
|
257
|
+
source?: string;
|
|
258
|
+
session_id?: string;
|
|
259
|
+
q?: string;
|
|
260
|
+
limit?: number;
|
|
261
|
+
cursor?: string | null;
|
|
262
|
+
}): Promise<Page<StoredFile>>;
|
|
263
|
+
get(fileId: string): Promise<StoredFile>;
|
|
264
|
+
/** The file's bytes. On S3 storage the API redirects to a presigned URL, which `fetch` follows without your token. */
|
|
265
|
+
download(fileId: string): Promise<Uint8Array>;
|
|
266
|
+
delete(fileId: string): Promise<void>;
|
|
267
|
+
}
|
|
268
|
+
/** Links that show a session inside your own product. Scale and Enterprise plans. The URL is a credential: keep it out of logs. */
|
|
269
|
+
declare class Embeds {
|
|
270
|
+
private readonly c;
|
|
271
|
+
constructor(c: Steerpane);
|
|
272
|
+
create(sessionId: string, config?: {
|
|
273
|
+
allow_takeover?: boolean;
|
|
274
|
+
allowed_origins?: string[];
|
|
275
|
+
expires_in_min?: number;
|
|
276
|
+
hide_toolbar?: boolean;
|
|
277
|
+
show_control?: boolean;
|
|
278
|
+
theme?: string;
|
|
279
|
+
end_user?: {
|
|
280
|
+
id: string;
|
|
281
|
+
name?: string;
|
|
282
|
+
};
|
|
283
|
+
mode?: string;
|
|
284
|
+
}): Promise<EmbedLink>;
|
|
285
|
+
list(params?: {
|
|
286
|
+
session_id?: string;
|
|
287
|
+
limit?: number;
|
|
288
|
+
cursor?: string | null;
|
|
289
|
+
}): Promise<Page<EmbedLink>>;
|
|
290
|
+
/** Closes open iframes at once, and returns control to the agent if this link held it. */
|
|
291
|
+
revoke(linkId: string): Promise<EmbedLink>;
|
|
292
|
+
}
|
|
293
|
+
/** Endpoint management. To check a delivery's signature use `verifySignature`, which needs no client. */
|
|
294
|
+
declare class Webhooks {
|
|
295
|
+
private readonly c;
|
|
296
|
+
constructor(c: Steerpane);
|
|
297
|
+
list(): Promise<Page<Webhook>>;
|
|
298
|
+
create(url: string, events: string[], fields?: Json): Promise<Webhook>;
|
|
299
|
+
get(webhookId: string): Promise<Webhook>;
|
|
300
|
+
delete(webhookId: string): Promise<void>;
|
|
301
|
+
sendTest(webhookId: string, input?: {
|
|
302
|
+
event?: string;
|
|
303
|
+
}): Promise<WebhookDelivery>;
|
|
304
|
+
}
|
|
305
|
+
/** Stored logins. Passwords and TOTP secrets go in and never come back to an API token. */
|
|
306
|
+
declare class Vault {
|
|
307
|
+
private readonly c;
|
|
308
|
+
constructor(c: Steerpane);
|
|
309
|
+
list(): Promise<Page<Credential>>;
|
|
310
|
+
create(input: {
|
|
311
|
+
domain: string;
|
|
312
|
+
username: string;
|
|
313
|
+
password: string;
|
|
314
|
+
name?: string;
|
|
315
|
+
totp_secret?: string;
|
|
316
|
+
profile_ids?: string[];
|
|
317
|
+
token_ids?: string[];
|
|
318
|
+
}): Promise<Credential>;
|
|
319
|
+
delete(credentialId: string): Promise<void>;
|
|
320
|
+
}
|
|
321
|
+
declare class Crawls {
|
|
322
|
+
private readonly c;
|
|
323
|
+
constructor(c: Steerpane);
|
|
324
|
+
/** `options`: `limit`, `max_depth`, `mode`, `formats`, `include_paths`, `exclude_paths`, `check_links`, `same_site`, ... */
|
|
325
|
+
start(url: string, options?: Json): Promise<CrawlJob>;
|
|
326
|
+
get(jobId: string, params?: {
|
|
327
|
+
cursor?: string | number | null;
|
|
328
|
+
limit?: number;
|
|
329
|
+
include_content?: boolean;
|
|
330
|
+
}): Promise<CrawlJob>;
|
|
331
|
+
cancel(jobId: string): Promise<CrawlJob>;
|
|
332
|
+
wait(jobId: string, options?: {
|
|
333
|
+
timeoutS?: number;
|
|
334
|
+
pollS?: number;
|
|
335
|
+
}): Promise<CrawlJob>;
|
|
336
|
+
}
|
|
337
|
+
/** Call MCP tools over the API's Streamable HTTP endpoint. A few tools are MCP only, such as `act`, `observe` and `wait_for_code`. */
|
|
338
|
+
declare class Mcp {
|
|
339
|
+
private readonly c;
|
|
340
|
+
private sessionId;
|
|
341
|
+
private nextId;
|
|
342
|
+
constructor(c: Steerpane);
|
|
343
|
+
private post;
|
|
344
|
+
private ensureSession;
|
|
345
|
+
/** The default list: core tools plus `search_tools` and `call_tool`. Any tool still runs by name with `call`. */
|
|
346
|
+
listTools(): Promise<Json[]>;
|
|
347
|
+
/** Run a tool and return its JSON result. A tool failure throws `ToolError` with the API's error code. */
|
|
348
|
+
call<T = Json>(tool: string, args?: Json, options?: {
|
|
349
|
+
timeoutS?: number;
|
|
350
|
+
}): Promise<T>;
|
|
351
|
+
/** Wait for an email or SMS verification code (the MCP tool `wait_for_code`). With `sessionId` the code is typed into the page and never reaches you
|
|
352
|
+
* (`status: "entered"`); with `returnCode: true` you get it back (`status: "received"`). The server answers in rounds of about 45 s with `status: "waiting"`:
|
|
353
|
+
* this keeps calling, with the `started_at` it was given, until the code arrives or `timeoutS` runs out (`status: "timeout"`), so the result is always final.
|
|
354
|
+
* Needs the `vault:use` scope and a code source set up on the organization. */
|
|
355
|
+
waitForCode(options?: WaitForCodeOptions): Promise<WaitForCodeResult>;
|
|
356
|
+
}
|
|
357
|
+
/** Client for the Steerpane API. */
|
|
358
|
+
export declare class Steerpane {
|
|
359
|
+
readonly baseUrl: string;
|
|
360
|
+
readonly timeoutMs: number;
|
|
361
|
+
readonly maxRetries: number;
|
|
362
|
+
/** Sent as X-Steerpane-Agent: the name the dashboard shows for this program. */
|
|
363
|
+
readonly agentName: string | undefined;
|
|
364
|
+
/** The token, for helpers that need it. Not enumerable, so logging the client doesn't print it. */
|
|
365
|
+
readonly token: string;
|
|
366
|
+
private readonly fetchImpl;
|
|
367
|
+
readonly sessions: Sessions;
|
|
368
|
+
readonly actions: Actions;
|
|
369
|
+
readonly profiles: Profiles;
|
|
370
|
+
readonly endUsers: EndUsers;
|
|
371
|
+
readonly devices: Devices;
|
|
372
|
+
readonly runs: Runs;
|
|
373
|
+
readonly files: Files;
|
|
374
|
+
readonly embeds: Embeds;
|
|
375
|
+
readonly webhooks: Webhooks;
|
|
376
|
+
readonly vault: Vault;
|
|
377
|
+
readonly crawls: Crawls;
|
|
378
|
+
readonly mcp: Mcp;
|
|
379
|
+
constructor(options?: SteerpaneOptions);
|
|
380
|
+
/** One HTTP call with your token and the retry rules. Doesn't throw on an error status. */
|
|
381
|
+
rawRequest(method: string, path: string, options?: RequestOptions): Promise<Response>;
|
|
382
|
+
/** Call any endpoint, for what this client has no method for. Returns the parsed body, or throws `APIError`. */
|
|
383
|
+
request<T = unknown>(method: string, path: string, options?: RequestOptions): Promise<T>;
|
|
384
|
+
/** Every item across pages: `for await (const s of client.paginate((p) => client.sessions.list({ ...p, status: "live" })))`. */
|
|
385
|
+
paginate<T>(listCall: (page: {
|
|
386
|
+
cursor: string | null;
|
|
387
|
+
}) => Promise<Page<T>>): AsyncGenerator<T>;
|
|
388
|
+
/** Fetch a page without a browser session. `mode` is `fast`, `deep` or `auto`. The site's own status is in the result's `status`. */
|
|
389
|
+
fetch(url: string, options?: {
|
|
390
|
+
format?: string;
|
|
391
|
+
mode?: string;
|
|
392
|
+
formats?: string[];
|
|
393
|
+
} & Json): Promise<FetchResult>;
|
|
394
|
+
fetchBatch(urls: string[], options?: Json): Promise<Json>;
|
|
395
|
+
search(query: string, options?: {
|
|
396
|
+
limit?: number;
|
|
397
|
+
}): Promise<SearchResponse>;
|
|
398
|
+
screenshot(url: string, options?: Json): Promise<Capture>;
|
|
399
|
+
pdf(url: string, options?: Json): Promise<Capture>;
|
|
400
|
+
map(url: string, options?: Json): Promise<Json>;
|
|
401
|
+
/** Structured data from up to 10 URLs. Needs a model key on the organization. */
|
|
402
|
+
extract(input: {
|
|
403
|
+
instruction: string;
|
|
404
|
+
url?: string;
|
|
405
|
+
urls?: string[];
|
|
406
|
+
schema?: Json;
|
|
407
|
+
} & Json): Promise<Json>;
|
|
408
|
+
}
|
|
409
|
+
export { APIError };
|