@prompteryx/sdk 0.4.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 +21 -0
- package/README.md +336 -0
- package/dist/chunk-ODLNHNQT.mjs +272 -0
- package/dist/chunk-ODLNHNQT.mjs.map +1 -0
- package/dist/index.d.mts +541 -0
- package/dist/index.d.ts +541 -0
- package/dist/index.js +1258 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +975 -0
- package/dist/index.mjs.map +1 -0
- package/dist/page-8LsjwpEo.d.mts +879 -0
- package/dist/page-8LsjwpEo.d.ts +879 -0
- package/dist/page.d.mts +1 -0
- package/dist/page.d.ts +1 -0
- package/dist/page.js +230 -0
- package/dist/page.js.map +1 -0
- package/dist/page.mjs +7 -0
- package/dist/page.mjs.map +1 -0
- package/package.json +86 -0
- package/src/client.ts +286 -0
- package/src/errors.ts +113 -0
- package/src/index.ts +140 -0
- package/src/models.ts +63 -0
- package/src/page.ts +264 -0
- package/src/resources/apiKeys.ts +53 -0
- package/src/resources/autopilot.ts +385 -0
- package/src/resources/cloudBrowser.ts +197 -0
- package/src/resources/connectHub.ts +93 -0
- package/src/resources/customNodes.ts +62 -0
- package/src/resources/executions.ts +84 -0
- package/src/resources/profiles.ts +48 -0
- package/src/resources/recordings.ts +32 -0
- package/src/resources/schedules.ts +49 -0
- package/src/resources/subscription.ts +27 -0
- package/src/resources/templates.ts +46 -0
- package/src/resources/workflows.ts +84 -0
- package/src/types.ts +680 -0
|
@@ -0,0 +1,879 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser-agent model catalog — the ids `px.autopilot.run({ model })` accepts.
|
|
3
|
+
*
|
|
4
|
+
* ⚠️ MUST MIRROR `components/unified-chat-v2/browser-models.ts`
|
|
5
|
+
* `V2_BROWSER_MODELS` in the platform repo — that file is the canonical
|
|
6
|
+
* catalog the server validates against (an unknown id hard-400s with
|
|
7
|
+
* `UNSUPPORTED_MODEL` under strict validation). When that list changes,
|
|
8
|
+
* regenerate this one. Last synced: 2026-09-03 — 32 ids.
|
|
9
|
+
*
|
|
10
|
+
* The type stays open (`| (string & {})`) so a model the server adds
|
|
11
|
+
* tomorrow works without an SDK release, while editors still autocomplete
|
|
12
|
+
* the known catalog.
|
|
13
|
+
*/
|
|
14
|
+
declare const AUTOPILOT_MODELS: readonly ["gemini-3.5-flash", "gemini-3.7-flash", "gemini-3.6-flash", "gemini-default", "gemini-3-flash-preview", "gemini-3.5-flash-lite", "model-a", "model-a1", "model-b", "model-j", "model-k", "model-k37", "claude-sonnet-4-6", "claude-opus-4-8", "gpt-5.6-terra", "gpt-5.6-sol", "gpt-5.5", "claude-fable-5-vision", "claude-opus-5-vision", "claude-sonnet-5-vision", "claude-sonnet-4-6-vision", "gpt-5.6-luna-vision", "gpt-5.4-vision", "gpt-4o-vision", "kimi-k3-vision", "modelc", "model-d", "model-d1", "model-e", "model-f", "model-h", "model-i"];
|
|
15
|
+
/** A model id from the known catalog. */
|
|
16
|
+
type AutopilotModelId = (typeof AUTOPILOT_MODELS)[number];
|
|
17
|
+
/** Open union: known ids autocomplete, forward-compatible strings still pass. */
|
|
18
|
+
type AutopilotModel = AutopilotModelId | (string & {});
|
|
19
|
+
/** The platform default when `model` is omitted. */
|
|
20
|
+
declare const DEFAULT_AUTOPILOT_MODEL = "gemini-3.5-flash";
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Shared types for the Prompteryx SDK.
|
|
24
|
+
*
|
|
25
|
+
* Two important framing decisions reflected here:
|
|
26
|
+
*
|
|
27
|
+
* 1. NAMING: We use Prompteryx-native names throughout — `copilot`,
|
|
28
|
+
* `autopilot`, `read`, `scan`, `do`, `run`. We deliberately don't
|
|
29
|
+
* use the Stagehand vocabulary (act/extract/observe/agent).
|
|
30
|
+
* 2. EXTENSIBILITY: Many fields accept `string` rather than enums so
|
|
31
|
+
* new Visual Studio nodes / new Gemini models / new providers
|
|
32
|
+
* work the moment they're available server-side, without the SDK
|
|
33
|
+
* needing a release. Where we DO enum, the type adds `| string`
|
|
34
|
+
* so callers can still pass forward-compatible values.
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
type ExecutionStatus = 'queued' | 'running' | 'completed' | 'failed' | 'cancelled' | 'timed_out';
|
|
38
|
+
type Region = 'us-east-1' | 'us-west-2' | 'eu-west-1' | 'eu-central-1' | 'ap-southeast-1' | (string & {});
|
|
39
|
+
type ProxyLocation = 'auto' | 'us' | 'gb' | 'ca' | 'de' | 'fr' | 'au' | 'in' | 'br' | 'jp' | (string & {});
|
|
40
|
+
/** Where a workflow runs. Cloud = our infrastructure (always works).
|
|
41
|
+
* Local = the user's own Chrome via the Prompteryx plugin (more
|
|
42
|
+
* capable for tasks needing the user's real logins). */
|
|
43
|
+
type ExecutionTarget = 'cloud' | 'local';
|
|
44
|
+
interface WorkflowSummary {
|
|
45
|
+
/** `wf_…` */
|
|
46
|
+
id: string;
|
|
47
|
+
name: string;
|
|
48
|
+
description?: string;
|
|
49
|
+
createdAt: string;
|
|
50
|
+
updatedAt: string;
|
|
51
|
+
nodeCount?: number;
|
|
52
|
+
/** True if the workflow has an active schedule attached. */
|
|
53
|
+
scheduled?: boolean;
|
|
54
|
+
/** Tags / categories the user has assigned. */
|
|
55
|
+
tags?: string[];
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Every option the Visual Studio UI exposes when you run a workflow.
|
|
59
|
+
* Adding a new option in the UI? Add it here too. Anything passed in
|
|
60
|
+
* an `executionOptions` field unrecognised by the SDK still rides
|
|
61
|
+
* through (passthrough = future-proof).
|
|
62
|
+
*/
|
|
63
|
+
interface WorkflowExecutionOptions {
|
|
64
|
+
/** Run on cloud browser (default) or via the user's local Chrome
|
|
65
|
+
* through the Prompteryx plugin. */
|
|
66
|
+
target?: ExecutionTarget;
|
|
67
|
+
/** Chrome profile id (cloud or local). Override the workflow's
|
|
68
|
+
* saved profile for this one run. */
|
|
69
|
+
chromeProfile?: string;
|
|
70
|
+
/** 'visible' = headed; 'headless' = no UI. */
|
|
71
|
+
runMode?: 'visible' | 'headless';
|
|
72
|
+
/** Capture a video recording. */
|
|
73
|
+
videoRecording?: boolean;
|
|
74
|
+
/** "Turbo" mode skips visual polish + delay tweaks for speed. */
|
|
75
|
+
turboBoost?: boolean;
|
|
76
|
+
/** Max execution time in ms. */
|
|
77
|
+
timeout?: number;
|
|
78
|
+
/** Return every node's output in the execution record (heavy). */
|
|
79
|
+
includeNodeOutputs?: boolean;
|
|
80
|
+
/** Override viewport size. */
|
|
81
|
+
viewport?: {
|
|
82
|
+
width: number;
|
|
83
|
+
height: number;
|
|
84
|
+
};
|
|
85
|
+
/** Run in a specific region (cloud only). */
|
|
86
|
+
region?: Region;
|
|
87
|
+
/** Use residential proxy. */
|
|
88
|
+
useProxy?: boolean;
|
|
89
|
+
/** Proxy exit country. */
|
|
90
|
+
proxyLocation?: ProxyLocation;
|
|
91
|
+
/** Auto-solve CAPTCHAs during the run. */
|
|
92
|
+
useCaptcha?: boolean;
|
|
93
|
+
/** Free-form passthrough — anything unrecognised by the SDK is
|
|
94
|
+
* forwarded to the server intact. Use for new server-side
|
|
95
|
+
* options before the SDK gets a release for them. */
|
|
96
|
+
passthrough?: Record<string, unknown>;
|
|
97
|
+
}
|
|
98
|
+
interface RunWorkflowOptions {
|
|
99
|
+
/** Workflow variables / input the workflow expects. */
|
|
100
|
+
input?: Record<string, unknown>;
|
|
101
|
+
/** Execution options — overrides the workflow's saved settings. */
|
|
102
|
+
execution?: WorkflowExecutionOptions;
|
|
103
|
+
}
|
|
104
|
+
interface RunWorkflowResult {
|
|
105
|
+
executionId: string;
|
|
106
|
+
status: ExecutionStatus;
|
|
107
|
+
workflowId: string;
|
|
108
|
+
startedAt?: string;
|
|
109
|
+
}
|
|
110
|
+
interface ExecutionRecord {
|
|
111
|
+
id: string;
|
|
112
|
+
workflowId: string;
|
|
113
|
+
status: ExecutionStatus;
|
|
114
|
+
startedAt: string;
|
|
115
|
+
finishedAt?: string;
|
|
116
|
+
durationMs?: number;
|
|
117
|
+
outputs?: Record<string, unknown>;
|
|
118
|
+
/** Detailed final state of every node (only when
|
|
119
|
+
* `execution.includeNodeOutputs` was set to true). */
|
|
120
|
+
nodeOutputs?: Record<string, unknown>;
|
|
121
|
+
error?: {
|
|
122
|
+
message: string;
|
|
123
|
+
nodeId?: string;
|
|
124
|
+
nodeLabel?: string;
|
|
125
|
+
};
|
|
126
|
+
nodeErrors?: Array<{
|
|
127
|
+
nodeId: string;
|
|
128
|
+
nodeLabel?: string;
|
|
129
|
+
message: string;
|
|
130
|
+
}>;
|
|
131
|
+
/** AI Credit + cloud-minute + proxy-MB + CAPTCHA consumption. */
|
|
132
|
+
usage?: {
|
|
133
|
+
aiCredits?: number;
|
|
134
|
+
cloudBrowserMinutes?: number;
|
|
135
|
+
proxyDataMB?: number;
|
|
136
|
+
captchaSolves?: number;
|
|
137
|
+
connectHubCalls?: number;
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
interface ExecutionLogEvent {
|
|
141
|
+
type: 'log' | 'progress' | 'node-start' | 'node-end' | 'error' | 'done';
|
|
142
|
+
message?: string;
|
|
143
|
+
nodeId?: string;
|
|
144
|
+
nodeLabel?: string;
|
|
145
|
+
timestamp: string;
|
|
146
|
+
level?: 'info' | 'warn' | 'error' | 'debug';
|
|
147
|
+
data?: unknown;
|
|
148
|
+
}
|
|
149
|
+
interface CreateSessionOptions {
|
|
150
|
+
/**
|
|
151
|
+
* Where the browser should actually run.
|
|
152
|
+
* • 'cloud' (default) — Prompteryx Cloud / AWS fleet, billed in
|
|
153
|
+
* cloud-browser minutes.
|
|
154
|
+
* • 'local' — your own Chrome via the Prompteryx plugin + Electron
|
|
155
|
+
* runner. ZERO cloud minutes, but requires the plugin to be
|
|
156
|
+
* running on the SAME machine as the SDK consumer (your script
|
|
157
|
+
* talks to localhost). Best for personal dev work where you want
|
|
158
|
+
* a real browser but don't want to spend cloud minutes.
|
|
159
|
+
* See README "Local mode" for the prereqs.
|
|
160
|
+
*/
|
|
161
|
+
target?: 'cloud' | 'local';
|
|
162
|
+
recordSession?: boolean;
|
|
163
|
+
captureDownloads?: boolean;
|
|
164
|
+
/** Storage keys for bring-your-own Chrome extensions
|
|
165
|
+
* (.tar.gz bundles uploaded via the platform). */
|
|
166
|
+
extensions?: string[];
|
|
167
|
+
/** Route the session through a residential proxy (sent as the wire
|
|
168
|
+
* field `proxy`). */
|
|
169
|
+
useProxy?: boolean;
|
|
170
|
+
/** Proxy exit country (sent as the wire field `country`, e.g. 'us'). */
|
|
171
|
+
proxyLocation?: ProxyLocation;
|
|
172
|
+
/** Auto-close the session after this many minutes. */
|
|
173
|
+
sessionTimeoutMinutes?: number;
|
|
174
|
+
/**
|
|
175
|
+
* Reuse a named cloud profile (preserves cookies + storage state
|
|
176
|
+
* across sessions). OPTIONAL — when omitted the session is
|
|
177
|
+
* ephemeral: nothing is loaded at start, nothing is saved at close,
|
|
178
|
+
* which is usually what you want for one-off automations. Naming a
|
|
179
|
+
* profile implicitly opts in to persistence — you don't need to set
|
|
180
|
+
* `persistContext` as well.
|
|
181
|
+
*/
|
|
182
|
+
profileId?: string;
|
|
183
|
+
/**
|
|
184
|
+
* Explicit persistence opt-in WITHOUT naming a profile. Uses the
|
|
185
|
+
* account's Default profile. Most users should leave this alone and
|
|
186
|
+
* either pass `profileId` (named profile) or nothing (ephemeral).
|
|
187
|
+
*/
|
|
188
|
+
persistContext?: boolean;
|
|
189
|
+
/** Custom viewport. */
|
|
190
|
+
viewport?: {
|
|
191
|
+
width: number;
|
|
192
|
+
height: number;
|
|
193
|
+
};
|
|
194
|
+
/** Anything unrecognised by the SDK is forwarded as-is. */
|
|
195
|
+
passthrough?: Record<string, unknown>;
|
|
196
|
+
}
|
|
197
|
+
/** Response of `sessions.create` — matches POST /api/v1/cloud-browser/sessions. */
|
|
198
|
+
interface CloudSession {
|
|
199
|
+
id: string;
|
|
200
|
+
/** CDP endpoint — pass to `chromium.connectOverCDP(connectUrl)`. */
|
|
201
|
+
connectUrl: string;
|
|
202
|
+
/** Watch-it-live URL (when the provider supports it). */
|
|
203
|
+
liveURL?: string | null;
|
|
204
|
+
status: 'launching' | 'active' | 'closed' | 'failed' | (string & {});
|
|
205
|
+
startedAt: string;
|
|
206
|
+
recordSession?: boolean;
|
|
207
|
+
}
|
|
208
|
+
/** Row returned by `sessions.list` / `sessions.get` — durable session
|
|
209
|
+
* history, NOT a live handle (no connectUrl). */
|
|
210
|
+
interface CloudSessionSummary {
|
|
211
|
+
id: string;
|
|
212
|
+
status: string;
|
|
213
|
+
provider?: string;
|
|
214
|
+
startedAt?: string;
|
|
215
|
+
endedAt?: string | null;
|
|
216
|
+
durationMs?: number | null;
|
|
217
|
+
region?: string;
|
|
218
|
+
hasRecording?: boolean;
|
|
219
|
+
}
|
|
220
|
+
/** Options for the one-shot `cloudBrowser.fetch` — matches
|
|
221
|
+
* POST /api/v1/cloud-browser/fetch. */
|
|
222
|
+
interface CloudFetchOptions {
|
|
223
|
+
url: string;
|
|
224
|
+
/** What to return in `content`. Default 'text' (readable text —
|
|
225
|
+
* token-efficient for LLMs). 'links' fills `links` instead. */
|
|
226
|
+
format?: 'text' | 'markdown' | 'html' | 'links';
|
|
227
|
+
/** Navigation wait state. Default 'domcontentloaded'. */
|
|
228
|
+
waitUntil?: 'load' | 'domcontentloaded' | 'networkidle' | 'commit';
|
|
229
|
+
/** Page-load budget in ms (5000–60000, default 30000). */
|
|
230
|
+
timeoutMs?: number;
|
|
231
|
+
/** Route through a residential proxy. */
|
|
232
|
+
proxy?: boolean;
|
|
233
|
+
/** Proxy exit country (with `proxy: true`), e.g. 'us'. */
|
|
234
|
+
country?: string;
|
|
235
|
+
/** After load, wait until this CSS selector exists (JS-rendered content). */
|
|
236
|
+
waitForSelector?: string;
|
|
237
|
+
/** Extra settle time after load/selector, ms (capped at 10000). */
|
|
238
|
+
waitMs?: number;
|
|
239
|
+
/** Up to 10 CSS selectors extracted deterministically — per selector the
|
|
240
|
+
* match count and the first 50 elements' text + outerHTML (capped). */
|
|
241
|
+
selectors?: string[];
|
|
242
|
+
/** Include a base64 JPEG of the viewport in the response. */
|
|
243
|
+
screenshot?: boolean;
|
|
244
|
+
}
|
|
245
|
+
/** Response of `cloudBrowser.fetch`. */
|
|
246
|
+
interface CloudFetchResult {
|
|
247
|
+
url: string;
|
|
248
|
+
finalUrl: string;
|
|
249
|
+
title: string;
|
|
250
|
+
status: string;
|
|
251
|
+
/** Page content in the requested `format` (absent for format 'links'). */
|
|
252
|
+
content?: string;
|
|
253
|
+
/** Present for format 'links'. */
|
|
254
|
+
links?: Array<{
|
|
255
|
+
text: string;
|
|
256
|
+
href: string;
|
|
257
|
+
}>;
|
|
258
|
+
/** Present when `waitForSelector` was given — whether it appeared in time. */
|
|
259
|
+
waitedSelector?: boolean;
|
|
260
|
+
/** Present when `selectors` were given. */
|
|
261
|
+
extracted?: Array<{
|
|
262
|
+
selector: string;
|
|
263
|
+
count?: number;
|
|
264
|
+
elements?: Array<{
|
|
265
|
+
text: string;
|
|
266
|
+
html: string;
|
|
267
|
+
}>;
|
|
268
|
+
error?: string;
|
|
269
|
+
}>;
|
|
270
|
+
/** Present when `screenshot: true`. */
|
|
271
|
+
screenshotBase64?: string;
|
|
272
|
+
}
|
|
273
|
+
interface CloudSearchResult {
|
|
274
|
+
title: string;
|
|
275
|
+
url: string;
|
|
276
|
+
snippet: string;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Every option exposed by the in-app AI Browser Agent surface, plus
|
|
280
|
+
* SDK-only hooks. Naming is `autopilot` not `agent` — autopilot
|
|
281
|
+
* implies "runs the whole task end-to-end without you", which is
|
|
282
|
+
* what this actually does.
|
|
283
|
+
*/
|
|
284
|
+
interface AutopilotRunOptions {
|
|
285
|
+
/** What the autopilot should accomplish, in plain English. */
|
|
286
|
+
goal: string;
|
|
287
|
+
/** Where to start. The autopilot navigates here before reasoning. */
|
|
288
|
+
startUrl?: string;
|
|
289
|
+
/** Max reasoning steps before giving up. Default 30. */
|
|
290
|
+
maxSteps?: number;
|
|
291
|
+
/** Hard cap on AI Credits this run may spend — the run stops once reached.
|
|
292
|
+
* A cost guardrail for unattended/automated runs (pairs with maxSteps). */
|
|
293
|
+
maxCredits?: number;
|
|
294
|
+
/** Cost-saving action batching — let the model chain several safe actions per
|
|
295
|
+
* screenshot before taking the next one (cheaper on simple same-page tasks).
|
|
296
|
+
* Default false. */
|
|
297
|
+
costSaving?: boolean;
|
|
298
|
+
/** When `costSaving` is on: max actions the model may chain per screenshot
|
|
299
|
+
* (2–20, default 5). Higher = cheaper on simple pages; lower = safer. */
|
|
300
|
+
costSavingMaxBatch?: number;
|
|
301
|
+
/** When `costSaving` is on: "careful batching" — take a fresh screenshot after
|
|
302
|
+
* each submit/commit action in a batch, so the agent never types the next
|
|
303
|
+
* record blind. Fewer skipped/duplicated rows on form loops. Default false. */
|
|
304
|
+
carefulBatching?: boolean;
|
|
305
|
+
/** AI Vision quality preset. Lower presets are cheaper and faster per step;
|
|
306
|
+
* higher presets read small text and dense pages more accurately.
|
|
307
|
+
* One of: 'ultra-saver' | 'low' | 'saver' | 'efficient' | 'balanced' |
|
|
308
|
+
* 'detailed' | 'enhanced' | 'precision' | 'max-precision'. */
|
|
309
|
+
aiVision?: 'ultra-saver' | 'low' | 'saver' | 'efficient' | 'balanced' | 'detailed' | 'enhanced' | 'precision' | 'max-precision' | (string & {});
|
|
310
|
+
/** Final-step quality boost: one extra look at the finished page at this
|
|
311
|
+
* preset right before the answer is written — sharper reads of prices,
|
|
312
|
+
* dates and small text for one screenshot's extra cost.
|
|
313
|
+
* 'same' (default) = off. */
|
|
314
|
+
finalStepVision?: 'same' | 'ultra-saver' | 'low' | 'saver' | 'efficient' | 'balanced' | 'detailed' | 'enhanced' | 'precision' | 'max-precision' | (string & {});
|
|
315
|
+
/** Structured output: a JSON Schema object for the final answer. When set,
|
|
316
|
+
* `finalAnswer` is JSON conforming to this schema (the server also accepts
|
|
317
|
+
* the snake_case `output_schema` spelling via passthrough). */
|
|
318
|
+
outputSchema?: Record<string, unknown>;
|
|
319
|
+
/**
|
|
320
|
+
* Safety checkpoints. 'auto' (default) auto-consents past the model's safety
|
|
321
|
+
* decisions (e.g. submitting a form) — best for unattended runs. 'ask' pauses
|
|
322
|
+
* the job (status becomes terminal `awaiting_input`, with the checkpoint in
|
|
323
|
+
* `finalAnswer`) so you can review and resume it. Mirrors the settings dialog's
|
|
324
|
+
* "Auto-consent to safety checkpoints" toggle.
|
|
325
|
+
*/
|
|
326
|
+
safetyConsent?: 'auto' | 'ask';
|
|
327
|
+
/**
|
|
328
|
+
* "Check unclear or risky tasks" (default ON). When on, a too-vague goal makes
|
|
329
|
+
* the agent ask a clarifying question first, and it confirms before an
|
|
330
|
+
* irreversible/costly action instead of guessing — surfacing as a terminal
|
|
331
|
+
* `awaiting_input` with the question in `finalAnswer`. Pass false to always
|
|
332
|
+
* proceed with a best guess.
|
|
333
|
+
*/
|
|
334
|
+
confirmUnclear?: boolean;
|
|
335
|
+
/**
|
|
336
|
+
* Smart Context Compression (default OFF). Summarises long sessions to cut token
|
|
337
|
+
* cost (~70% on long tasks). `compressionThreshold` = compress after this many
|
|
338
|
+
* steps (default 8).
|
|
339
|
+
*/
|
|
340
|
+
enableContextCompression?: boolean;
|
|
341
|
+
compressionThreshold?: number;
|
|
342
|
+
/**
|
|
343
|
+
* Fresh-session reset (default OFF) — an alternative long-task cost saver. Every
|
|
344
|
+
* N turns it starts a clean session from a verified progress summary so per-step
|
|
345
|
+
* cost stops climbing. `sessionResetThreshold` = reset every N turns (default 12).
|
|
346
|
+
*/
|
|
347
|
+
enableSessionReset?: boolean;
|
|
348
|
+
sessionResetThreshold?: number;
|
|
349
|
+
/**
|
|
350
|
+
* Where the autopilot should drive the browser.
|
|
351
|
+
* • 'cloud' (default) — cloud browser, bills cloud-browser minutes.
|
|
352
|
+
* • 'local' (v0.3+) — YOUR local Chrome via the Prompteryx desktop app.
|
|
353
|
+
* ZERO cloud-browser minutes; AI Credits still apply. Requirements:
|
|
354
|
+
* the desktop app must be RUNNING and SIGNED IN on this machine, and
|
|
355
|
+
* your code must run on the same machine (the SDK talks to the app
|
|
356
|
+
* directly at http://localhost:61337 — override with `runnerUrl`).
|
|
357
|
+
* The browser tab stays open after the run for inspection/follow-ups.
|
|
358
|
+
*/
|
|
359
|
+
target?: 'cloud' | 'local';
|
|
360
|
+
/** Local target only: the desktop app's local address.
|
|
361
|
+
* Default 'http://localhost:61337'. */
|
|
362
|
+
runnerUrl?: string;
|
|
363
|
+
/** Which browser-agent model to use. Default: 'gemini-3.5-flash'.
|
|
364
|
+
* The known catalog is `AUTOPILOT_MODELS` (see models.ts — mirrored from
|
|
365
|
+
* the platform's canonical V2_BROWSER_MODELS list); any other string is
|
|
366
|
+
* forwarded as-is for forward compatibility, but an id the server doesn't
|
|
367
|
+
* know hard-400s with UNSUPPORTED_MODEL. */
|
|
368
|
+
model?: AutopilotModel;
|
|
369
|
+
/**
|
|
370
|
+
* Capture the discovered action sequence as a permanent workflow
|
|
371
|
+
* the user can replay forever at zero AI cost — the action-caching
|
|
372
|
+
* pattern, materialised as a first-class Visual Studio workflow
|
|
373
|
+
* (schedulable, shareable, editable, multi-option-selector
|
|
374
|
+
* resilient). The response includes `savedWorkflowId`.
|
|
375
|
+
*/
|
|
376
|
+
saveAsWorkflow?: boolean;
|
|
377
|
+
/** Display name for the saved workflow. Defaults to a slug of `goal`. */
|
|
378
|
+
savedWorkflowName?: string;
|
|
379
|
+
/** Hard timeout for the whole run in ms. Default 5 minutes. */
|
|
380
|
+
timeoutMs?: number;
|
|
381
|
+
/** Run on a pre-existing cloud session. If omitted the autopilot
|
|
382
|
+
* spins up a fresh one + closes it on completion. */
|
|
383
|
+
sessionId?: string;
|
|
384
|
+
/** Override the autopilot's system prompt. Advanced — most users
|
|
385
|
+
* shouldn't set this. Used for niche bespoke tasks where the
|
|
386
|
+
* default prompt loses subtlety (e.g. "always confirm before
|
|
387
|
+
* submitting any form"). */
|
|
388
|
+
systemPromptOverride?: string;
|
|
389
|
+
/** Restrict the tools the autopilot can use. By default all of
|
|
390
|
+
* click / type / scroll / navigate / press_key / hover / extract
|
|
391
|
+
* are available; pass a subset to constrain behaviour (e.g.
|
|
392
|
+
* `['click', 'extract']` for a read-only task). */
|
|
393
|
+
allowedTools?: string[];
|
|
394
|
+
/** Viewport for the cloud browser session the autopilot uses. */
|
|
395
|
+
viewport?: {
|
|
396
|
+
width: number;
|
|
397
|
+
height: number;
|
|
398
|
+
};
|
|
399
|
+
/** Per-session controls forwarded to the underlying cloud-browser
|
|
400
|
+
* session creation. Ignored when `sessionId` is set. */
|
|
401
|
+
session?: Omit<CreateSessionOptions, 'viewport'>;
|
|
402
|
+
/**
|
|
403
|
+
* MULTI-AGENT SWARM. Run the goal across N parallel cloud agents instead of
|
|
404
|
+
* one. Default 1 (a normal single-agent run). When > 1 the response gains a
|
|
405
|
+
* `swarm` block with per-agent answers/usage, and `finalAnswer` is the merged
|
|
406
|
+
* result across all agents. Each agent still respects `maxCredits`; use
|
|
407
|
+
* `maxRunCredits` to bound the whole run.
|
|
408
|
+
*/
|
|
409
|
+
agents?: number;
|
|
410
|
+
/**
|
|
411
|
+
* Swarm coordination style (only meaningful when `agents` > 1):
|
|
412
|
+
* • false (default) — N INDEPENDENT agents, each runs the FULL `goal` in its
|
|
413
|
+
* own browser (fastest for "do the same thing N ways / N places").
|
|
414
|
+
* • true — COLLABORATE via a shared work-queue: the goal (or the attached
|
|
415
|
+
* spreadsheet, one item per row) is split into work items that agents claim
|
|
416
|
+
* atomically — none done twice, none missed, idle agents work-steal.
|
|
417
|
+
*/
|
|
418
|
+
collaborate?: boolean;
|
|
419
|
+
/** Collaborate mode: a spreadsheet's TEXT (CSV / TSV / pipe table). When it looks
|
|
420
|
+
* like a row table the shared queue is seeded ONE work item per ROW. */
|
|
421
|
+
attachmentContext?: string;
|
|
422
|
+
/** Swarm whole-run credit budget (admission control). Once the run's total AI
|
|
423
|
+
* Credits reach this, agents stop claiming new work items and wrap up what's in
|
|
424
|
+
* flight. 0/undefined = no cap. Distinct from per-agent `maxCredits`. */
|
|
425
|
+
maxRunCredits?: number;
|
|
426
|
+
/** Passthrough for future server-side options. */
|
|
427
|
+
passthrough?: Record<string, unknown>;
|
|
428
|
+
}
|
|
429
|
+
interface AutopilotStep {
|
|
430
|
+
step: number;
|
|
431
|
+
action: string;
|
|
432
|
+
reasoning?: string;
|
|
433
|
+
/** Base64 JPEG screenshot taken before the step (debugging aid). */
|
|
434
|
+
screenshot?: string;
|
|
435
|
+
result?: unknown;
|
|
436
|
+
}
|
|
437
|
+
interface AutopilotRunResult {
|
|
438
|
+
success: boolean;
|
|
439
|
+
/** The autopilot's final summary / answer. */
|
|
440
|
+
finalAnswer?: string;
|
|
441
|
+
steps: AutopilotStep[];
|
|
442
|
+
/** `wf_…` if `saveAsWorkflow` was true. Run it later with
|
|
443
|
+
* `px.workflows.run(savedWorkflowId)` for zero-AI-cost replay. */
|
|
444
|
+
savedWorkflowId?: string;
|
|
445
|
+
/** AI Credit + token usage telemetry. Sums ALL agents on a swarm run. */
|
|
446
|
+
usage?: {
|
|
447
|
+
aiCredits: number;
|
|
448
|
+
tokensIn?: number;
|
|
449
|
+
tokensOut?: number;
|
|
450
|
+
/** USD cost the platform charged the user (1 credit = $0.01). */
|
|
451
|
+
costUSD?: number;
|
|
452
|
+
/** Model turns (think-and-act cycles) the run took. */
|
|
453
|
+
turns?: number;
|
|
454
|
+
};
|
|
455
|
+
/** Present only when `agents` > 1 — the multi-agent swarm detail. `finalAnswer`
|
|
456
|
+
* above is the merged answer across every agent; this exposes each agent's own
|
|
457
|
+
* answer/usage/session and (collaborate mode) the shared work-queue coverage. */
|
|
458
|
+
swarm?: {
|
|
459
|
+
mode: 'collaborate' | 'independent';
|
|
460
|
+
status: 'completed' | 'partial' | 'error';
|
|
461
|
+
agents: Array<{
|
|
462
|
+
idx: number;
|
|
463
|
+
title: string;
|
|
464
|
+
status: 'completed' | 'error' | 'stopped';
|
|
465
|
+
finalAnswer: string;
|
|
466
|
+
costUSD: number;
|
|
467
|
+
inTokens: number;
|
|
468
|
+
outTokens: number;
|
|
469
|
+
turns: number;
|
|
470
|
+
sessionId: string;
|
|
471
|
+
recordingUrl?: string;
|
|
472
|
+
error?: string;
|
|
473
|
+
}>;
|
|
474
|
+
/** Shared-queue coverage (collaborate mode): items total / done / failed / etc. */
|
|
475
|
+
coverage?: {
|
|
476
|
+
total: number;
|
|
477
|
+
done: number;
|
|
478
|
+
failed: number;
|
|
479
|
+
claimed: number;
|
|
480
|
+
unclaimed: number;
|
|
481
|
+
};
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
interface CopilotDoResult {
|
|
485
|
+
success: boolean;
|
|
486
|
+
action: string;
|
|
487
|
+
selector?: string;
|
|
488
|
+
/** True when every ranked selector failed and the AI-vision coordinate
|
|
489
|
+
* fallback was used instead. Lets you spot pages where stable selectors
|
|
490
|
+
* aren't resolving so you can tighten them. */
|
|
491
|
+
usedVisionFallback?: boolean;
|
|
492
|
+
durationMs: number;
|
|
493
|
+
error?: string;
|
|
494
|
+
}
|
|
495
|
+
interface DiscoveredAction {
|
|
496
|
+
/** Semantic intent: 'click', 'fill', 'select', 'hover'. */
|
|
497
|
+
type: string;
|
|
498
|
+
selector: string;
|
|
499
|
+
alternativeSelectors?: string[];
|
|
500
|
+
description: string;
|
|
501
|
+
/** Natural-language instruction the user would describe this with
|
|
502
|
+
* ("click the Sign up button"). Useful for `px.copilot.do(page, a.example)`. */
|
|
503
|
+
example?: string;
|
|
504
|
+
}
|
|
505
|
+
interface ConnectHubAppSummary {
|
|
506
|
+
/** Pipedream slug ('gmail', 'google-sheets', ...). */
|
|
507
|
+
slug: string;
|
|
508
|
+
name: string;
|
|
509
|
+
iconUrl?: string;
|
|
510
|
+
/** Categories the app belongs to. */
|
|
511
|
+
categories?: string[];
|
|
512
|
+
}
|
|
513
|
+
interface ConnectHubActionSummary {
|
|
514
|
+
app: string;
|
|
515
|
+
/** Action key ('send_message', 'create_row', etc.). */
|
|
516
|
+
action: string;
|
|
517
|
+
name: string;
|
|
518
|
+
description?: string;
|
|
519
|
+
/** Parameter spec — the schema the user must satisfy in `params`. */
|
|
520
|
+
parameters?: Record<string, unknown>;
|
|
521
|
+
}
|
|
522
|
+
interface RunConnectHubActionOptions {
|
|
523
|
+
app: string;
|
|
524
|
+
action: string;
|
|
525
|
+
/** Action parameters. Shape depends on the action — call
|
|
526
|
+
* `px.connectHub.getAction(app, action)` to fetch the schema. */
|
|
527
|
+
params: Record<string, unknown>;
|
|
528
|
+
/** Optional credential id if the user has multiple accounts of the
|
|
529
|
+
* same app connected. Defaults to the most recently used. */
|
|
530
|
+
credentialId?: string;
|
|
531
|
+
}
|
|
532
|
+
interface CustomNodeSummary {
|
|
533
|
+
id: string;
|
|
534
|
+
name: string;
|
|
535
|
+
description?: string;
|
|
536
|
+
/** 'http' (one external call) or 'expression' (data transform) or
|
|
537
|
+
* 'composition' (sub-workflow). */
|
|
538
|
+
kind: 'http' | 'expression' | 'composition';
|
|
539
|
+
/** Input schema the node accepts. */
|
|
540
|
+
inputSchema?: Record<string, unknown>;
|
|
541
|
+
/** Output schema the node returns. */
|
|
542
|
+
outputSchema?: Record<string, unknown>;
|
|
543
|
+
}
|
|
544
|
+
interface ScheduleSummary {
|
|
545
|
+
id: string;
|
|
546
|
+
workflowId: string;
|
|
547
|
+
workflowName?: string;
|
|
548
|
+
/** Cron expression in the schedule's timezone. */
|
|
549
|
+
cronExpression: string;
|
|
550
|
+
timezone: string;
|
|
551
|
+
active: boolean;
|
|
552
|
+
nextRun?: string;
|
|
553
|
+
lastRun?: string;
|
|
554
|
+
createdAt: string;
|
|
555
|
+
}
|
|
556
|
+
interface CreateScheduleOptions {
|
|
557
|
+
workflowId: string;
|
|
558
|
+
cronExpression: string;
|
|
559
|
+
/** IANA timezone ('America/New_York'). */
|
|
560
|
+
timezone?: string;
|
|
561
|
+
/** Initial state. Default true. */
|
|
562
|
+
active?: boolean;
|
|
563
|
+
/** Override the workflow's saved execution options for scheduled
|
|
564
|
+
* runs. */
|
|
565
|
+
execution?: WorkflowExecutionOptions;
|
|
566
|
+
/** Input variables passed every scheduled run. */
|
|
567
|
+
input?: Record<string, unknown>;
|
|
568
|
+
}
|
|
569
|
+
interface TemplateSummary {
|
|
570
|
+
id: string;
|
|
571
|
+
name: string;
|
|
572
|
+
description?: string;
|
|
573
|
+
categories?: string[];
|
|
574
|
+
/** Author of the template (the platform team or another user). */
|
|
575
|
+
author?: string;
|
|
576
|
+
/** Indicative complexity. */
|
|
577
|
+
nodeCount?: number;
|
|
578
|
+
}
|
|
579
|
+
interface ProfileSummary {
|
|
580
|
+
id: string;
|
|
581
|
+
name: string;
|
|
582
|
+
/** 'cloud' = persistent cloud profile; 'local' = Chrome profile
|
|
583
|
+
* on the user's machine (requires the Prompteryx plugin). */
|
|
584
|
+
kind: 'cloud' | 'local';
|
|
585
|
+
/** Cookies / storage size. */
|
|
586
|
+
sizeBytes?: number;
|
|
587
|
+
lastUsedAt?: string;
|
|
588
|
+
}
|
|
589
|
+
interface SubscriptionStatus {
|
|
590
|
+
tier: 'free' | 'starter' | 'developer' | 'pro' | 'enterprise' | (string & {});
|
|
591
|
+
renewedAt?: string;
|
|
592
|
+
/** Plan-included balances. */
|
|
593
|
+
balances: {
|
|
594
|
+
aiCredits: {
|
|
595
|
+
remaining: number;
|
|
596
|
+
included: number;
|
|
597
|
+
};
|
|
598
|
+
cloudBrowserMinutes: {
|
|
599
|
+
remaining: number;
|
|
600
|
+
included: number;
|
|
601
|
+
};
|
|
602
|
+
proxyDataMB: {
|
|
603
|
+
remaining: number;
|
|
604
|
+
included: number;
|
|
605
|
+
};
|
|
606
|
+
captchaSolves: {
|
|
607
|
+
remaining: number;
|
|
608
|
+
included: number;
|
|
609
|
+
};
|
|
610
|
+
connectHubCalls: {
|
|
611
|
+
remaining: number;
|
|
612
|
+
included: number;
|
|
613
|
+
};
|
|
614
|
+
monthlyExecutions: {
|
|
615
|
+
remaining: number;
|
|
616
|
+
included: number;
|
|
617
|
+
};
|
|
618
|
+
};
|
|
619
|
+
/** Top-up balances (don't reset monthly). */
|
|
620
|
+
topUpBalances: {
|
|
621
|
+
aiCredits: number;
|
|
622
|
+
cloudBrowserMinutes: number;
|
|
623
|
+
proxyDataMB: number;
|
|
624
|
+
captchaSolves: number;
|
|
625
|
+
connectHubCalls: number;
|
|
626
|
+
};
|
|
627
|
+
}
|
|
628
|
+
interface SessionRecording {
|
|
629
|
+
sessionId: string;
|
|
630
|
+
startedAt: string;
|
|
631
|
+
endedAt?: string;
|
|
632
|
+
url: string;
|
|
633
|
+
durationMs?: number;
|
|
634
|
+
sizeBytes?: number;
|
|
635
|
+
}
|
|
636
|
+
interface ApiKeySummary {
|
|
637
|
+
id: string;
|
|
638
|
+
name: string;
|
|
639
|
+
keyPrefix: string;
|
|
640
|
+
createdAt: string;
|
|
641
|
+
lastUsedAt?: string;
|
|
642
|
+
expiresAt?: string;
|
|
643
|
+
status: 'active' | 'expired' | 'revoked';
|
|
644
|
+
usageCount: number;
|
|
645
|
+
}
|
|
646
|
+
interface PrompteryxClientOptions {
|
|
647
|
+
/** Platform API key (`px_live_…`) — sent as `Authorization: Bearer`.
|
|
648
|
+
* Rate limits: 60 requests/minute, 10,000/day. */
|
|
649
|
+
apiKey: string;
|
|
650
|
+
/**
|
|
651
|
+
* Cloud Browser API key (`pcb_live_…`) — a SEPARATE key family, created
|
|
652
|
+
* under Cloud Platform → API Keys. Required for `px.cloudBrowser.*`
|
|
653
|
+
* (sessions / fetch / search), which authenticates with `x-api-key`
|
|
654
|
+
* rather than the platform Bearer key. Calls to `px.cloudBrowser.*`
|
|
655
|
+
* throw an AuthError explaining this when it's absent.
|
|
656
|
+
*/
|
|
657
|
+
cloudBrowserKey?: string;
|
|
658
|
+
baseUrl?: string;
|
|
659
|
+
timeoutMs?: number;
|
|
660
|
+
maxRetries?: number;
|
|
661
|
+
defaultHeaders?: Record<string, string>;
|
|
662
|
+
fetch?: typeof fetch;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
/**
|
|
666
|
+
* HTTP client for the Prompteryx SDK.
|
|
667
|
+
*
|
|
668
|
+
* Thin layer over `fetch` that adds:
|
|
669
|
+
* - Bearer auth from the configured API key
|
|
670
|
+
* - JSON serialisation + content-type
|
|
671
|
+
* - Status-to-typed-error mapping (see errors.ts)
|
|
672
|
+
* - Configurable timeout via AbortController
|
|
673
|
+
* - Bounded retry for idempotent ops on 5xx / network errors
|
|
674
|
+
* - Optional SSE streaming for execution logs / agent traces
|
|
675
|
+
*
|
|
676
|
+
* Anything that needs raw `Response` (e.g. downloading a recording
|
|
677
|
+
* binary) can use `rawRequest()`. Everything else should use
|
|
678
|
+
* `request<T>()` which returns the parsed JSON body typed as T.
|
|
679
|
+
*/
|
|
680
|
+
|
|
681
|
+
interface RequestOptions {
|
|
682
|
+
method?: 'GET' | 'POST' | 'PATCH' | 'DELETE';
|
|
683
|
+
/** Object that will be JSON.stringified into the body. Skip for GET/DELETE. */
|
|
684
|
+
body?: unknown;
|
|
685
|
+
/** Extra headers merged into the defaults. */
|
|
686
|
+
headers?: Record<string, string>;
|
|
687
|
+
/** Override the client default timeout for this single call. */
|
|
688
|
+
timeoutMs?: number;
|
|
689
|
+
/** Whether this op is safe to retry on transient failure. Defaults
|
|
690
|
+
* based on method: GET = yes, others = no. The caller can force
|
|
691
|
+
* retry for idempotent POSTs (e.g. a poll loop). */
|
|
692
|
+
retry?: boolean;
|
|
693
|
+
/** Query string params (URI-encoded automatically). */
|
|
694
|
+
query?: Record<string, string | number | boolean | undefined | null>;
|
|
695
|
+
/** Optional AbortSignal for caller-side cancellation. */
|
|
696
|
+
signal?: AbortSignal;
|
|
697
|
+
}
|
|
698
|
+
declare class HttpClient {
|
|
699
|
+
private readonly apiKey;
|
|
700
|
+
/** Optional Cloud Browser key (`pcb_live_…`) — a separate key family used
|
|
701
|
+
* only by the /api/v1/cloud-browser/* endpoints (sent as `x-api-key`). */
|
|
702
|
+
readonly cloudBrowserKey?: string;
|
|
703
|
+
private readonly baseUrl;
|
|
704
|
+
private readonly timeoutMs;
|
|
705
|
+
private readonly maxRetries;
|
|
706
|
+
private readonly defaultHeaders;
|
|
707
|
+
private readonly fetchImpl;
|
|
708
|
+
constructor(opts: PrompteryxClientOptions);
|
|
709
|
+
/** Returns the JSON-parsed body typed as T. Throws typed errors on non-2xx. */
|
|
710
|
+
request<T = unknown>(path: string, opts?: RequestOptions): Promise<T>;
|
|
711
|
+
/** Returns the raw Response. Throws typed errors on non-2xx, but does
|
|
712
|
+
* not attempt to read the body. Useful for downloading binaries. */
|
|
713
|
+
rawRequest(path: string, opts?: RequestOptions): Promise<Response>;
|
|
714
|
+
/**
|
|
715
|
+
* Stream a Server-Sent Events response line-by-line as JSON-parsed
|
|
716
|
+
* payloads. Yields each event's `data:` payload parsed as JSON. The
|
|
717
|
+
* caller is responsible for breaking the loop / cancelling the
|
|
718
|
+
* AbortSignal when done.
|
|
719
|
+
*/
|
|
720
|
+
streamSse<T = unknown>(path: string, opts?: RequestOptions): AsyncGenerator<T, void, void>;
|
|
721
|
+
private sendOnce;
|
|
722
|
+
private buildUrl;
|
|
723
|
+
private errorFromResponse;
|
|
724
|
+
private wrapTransport;
|
|
725
|
+
private isRetryable;
|
|
726
|
+
private backoff;
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
/**
|
|
730
|
+
* Copilot primitives — `do`, `read`, `scan` — operating on a Playwright
|
|
731
|
+
* page.
|
|
732
|
+
*
|
|
733
|
+
* Two namespaces in the Prompteryx SDK:
|
|
734
|
+
* • Copilot → SDK helps with ONE step you describe in plain English.
|
|
735
|
+
* Your code drives Playwright; copilot just figures out
|
|
736
|
+
* which selector to click / what data to pull / what's
|
|
737
|
+
* discoverable on the current page.
|
|
738
|
+
* • Autopilot → SDK runs an autonomous multi-step task with no per-
|
|
739
|
+
* action involvement from you. See ./resources/autopilot.ts.
|
|
740
|
+
*
|
|
741
|
+
* The copilot primitives:
|
|
742
|
+
* • `do(page, instruction)` — execute a single natural-language
|
|
743
|
+
* action ("click the Sign up button", "fill the email field with
|
|
744
|
+
* hello@example.com"). Returns a structured result describing
|
|
745
|
+
* what was done.
|
|
746
|
+
* • `read(page, schema)` — pull typed data from the page. Pass a
|
|
747
|
+
* Zod schema or a raw JSON Schema; the SDK returns the populated
|
|
748
|
+
* object validated against your schema.
|
|
749
|
+
* • `scan(page, hint?)` — list discoverable actions on the page.
|
|
750
|
+
* Useful as a pre-step to `do()` for resilient automations:
|
|
751
|
+
* scan → pick the action whose description matches your intent →
|
|
752
|
+
* do() against it.
|
|
753
|
+
*
|
|
754
|
+
* Architecturally the SDK never drives the browser server-side. The
|
|
755
|
+
* server returns a structured plan and the SDK executes it locally
|
|
756
|
+
* against your Playwright page, so your trace, debugger, and any
|
|
757
|
+
* custom event handlers continue to work normally.
|
|
758
|
+
*/
|
|
759
|
+
|
|
760
|
+
/** Minimal Page surface — anything satisfying this works (Playwright's
|
|
761
|
+
* Page does, by structural typing, without an explicit import). */
|
|
762
|
+
interface PageLike {
|
|
763
|
+
url(): string;
|
|
764
|
+
title(): Promise<string>;
|
|
765
|
+
screenshot(opts?: {
|
|
766
|
+
type?: 'png' | 'jpeg';
|
|
767
|
+
quality?: number;
|
|
768
|
+
fullPage?: boolean;
|
|
769
|
+
}): Promise<Buffer | Uint8Array>;
|
|
770
|
+
evaluate<T>(fn: (...args: unknown[]) => T): Promise<T>;
|
|
771
|
+
click(selector: string, opts?: {
|
|
772
|
+
timeout?: number;
|
|
773
|
+
}): Promise<void>;
|
|
774
|
+
fill(selector: string, value: string, opts?: {
|
|
775
|
+
timeout?: number;
|
|
776
|
+
}): Promise<void>;
|
|
777
|
+
selectOption(selector: string, value: string | string[], opts?: {
|
|
778
|
+
timeout?: number;
|
|
779
|
+
}): Promise<unknown>;
|
|
780
|
+
goto(url: string, opts?: {
|
|
781
|
+
timeout?: number;
|
|
782
|
+
}): Promise<unknown>;
|
|
783
|
+
hover(selector: string, opts?: {
|
|
784
|
+
timeout?: number;
|
|
785
|
+
}): Promise<void>;
|
|
786
|
+
keyboard: {
|
|
787
|
+
press(key: string): Promise<void>;
|
|
788
|
+
type(text: string, opts?: {
|
|
789
|
+
delay?: number;
|
|
790
|
+
}): Promise<void>;
|
|
791
|
+
};
|
|
792
|
+
mouse?: {
|
|
793
|
+
click(x: number, y: number): Promise<void>;
|
|
794
|
+
move?(x: number, y: number): Promise<void>;
|
|
795
|
+
};
|
|
796
|
+
viewportSize?(): {
|
|
797
|
+
width: number;
|
|
798
|
+
height: number;
|
|
799
|
+
} | null;
|
|
800
|
+
locator(selector: string): {
|
|
801
|
+
first(): {
|
|
802
|
+
isVisible(opts?: {
|
|
803
|
+
timeout?: number;
|
|
804
|
+
}): Promise<boolean>;
|
|
805
|
+
textContent(opts?: {
|
|
806
|
+
timeout?: number;
|
|
807
|
+
}): Promise<string | null>;
|
|
808
|
+
};
|
|
809
|
+
};
|
|
810
|
+
}
|
|
811
|
+
interface ZodLikeSchema<T> {
|
|
812
|
+
parse(input: unknown): T;
|
|
813
|
+
_def?: unknown;
|
|
814
|
+
}
|
|
815
|
+
declare class CopilotHelpers {
|
|
816
|
+
private readonly http;
|
|
817
|
+
constructor(http: HttpClient);
|
|
818
|
+
/**
|
|
819
|
+
* Execute a single natural-language action against the page.
|
|
820
|
+
*
|
|
821
|
+
* ```ts
|
|
822
|
+
* await px.copilot.do(page, 'click the Sign up button')
|
|
823
|
+
* await px.copilot.do(page, 'fill the email field with hello@example.com')
|
|
824
|
+
* ```
|
|
825
|
+
*
|
|
826
|
+
* Internally: snapshot the page → POST `/api/v1/copilot/do` → server
|
|
827
|
+
* returns a structured action plan (ranked selector + alternatives +
|
|
828
|
+
* value + a normalised vision point) → SDK executes locally, trying the
|
|
829
|
+
* ranked selectors in order, and ONLY if every selector fails, falling
|
|
830
|
+
* back to an AI-vision coordinate click. Costs 1 AI Credit per call.
|
|
831
|
+
*
|
|
832
|
+
* This is the key resilience advantage over a pure-LLM `act()`: the cheap,
|
|
833
|
+
* deterministic ranked selectors are tried first (no flakiness, no re-asking
|
|
834
|
+
* the model); the vision fallback is a safety net, not the default path. Pass
|
|
835
|
+
* `{ visionFallback: false }` to disable the fallback (selectors-only).
|
|
836
|
+
*/
|
|
837
|
+
do(page: PageLike, instruction: string, opts?: {
|
|
838
|
+
timeout?: number;
|
|
839
|
+
visionFallback?: boolean;
|
|
840
|
+
}): Promise<CopilotDoResult>;
|
|
841
|
+
/**
|
|
842
|
+
* Pull typed structured data from the page conforming to a schema.
|
|
843
|
+
*
|
|
844
|
+
* ```ts
|
|
845
|
+
* import { z } from 'zod'
|
|
846
|
+
* const product = await px.copilot.read(page, z.object({
|
|
847
|
+
* name: z.string(),
|
|
848
|
+
* pricePerMonth: z.number(),
|
|
849
|
+
* features: z.array(z.string()),
|
|
850
|
+
* }))
|
|
851
|
+
* // product is fully typed; ValidationError is thrown if the model
|
|
852
|
+
* // returns data that doesn't match the schema.
|
|
853
|
+
* ```
|
|
854
|
+
*
|
|
855
|
+
* Accepts a Zod schema (preferred — gives you compile-time types)
|
|
856
|
+
* OR a raw JSON Schema via `{ jsonSchema: ... }` if you don't want
|
|
857
|
+
* a `zod` peer dep.
|
|
858
|
+
*/
|
|
859
|
+
read<T>(page: PageLike, schema: ZodLikeSchema<T> | {
|
|
860
|
+
jsonSchema: unknown;
|
|
861
|
+
}): Promise<T>;
|
|
862
|
+
/**
|
|
863
|
+
* Scan the page for available actions. Returns a ranked list of
|
|
864
|
+
* actions a user / agent could take next, with selectors + multi-
|
|
865
|
+
* option fallbacks + human-readable descriptions.
|
|
866
|
+
*
|
|
867
|
+
* Useful as a pre-step to `do()` for resilient automations:
|
|
868
|
+
* const actions = await px.copilot.scan(page, 'sign up flow')
|
|
869
|
+
* const target = actions.find(a => a.description.includes('Sign up'))
|
|
870
|
+
* if (target) await px.copilot.do(page, target.example ?? `click ${target.description}`)
|
|
871
|
+
*/
|
|
872
|
+
scan(page: PageLike, hint?: string): Promise<DiscoveredAction[]>;
|
|
873
|
+
private snapshotPage;
|
|
874
|
+
/** Execute the plan. Returns true if the AI-vision fallback was used. */
|
|
875
|
+
private runAction;
|
|
876
|
+
private zodToJsonSchema;
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
export { type AutopilotRunOptions as A, type Region as B, type CreateSessionOptions as C, type DiscoveredAction as D, type ExecutionRecord as E, type RunConnectHubActionOptions as F, type SessionRecording as G, HttpClient as H, type WorkflowExecutionOptions as I, type ProfileSummary as P, type RunWorkflowOptions as R, type ScheduleSummary as S, type TemplateSummary as T, type WorkflowSummary as W, type AutopilotRunResult as a, type AutopilotStep as b, type CloudSession as c, type CloudSessionSummary as d, type CloudFetchOptions as e, type CloudFetchResult as f, type CloudSearchResult as g, type ExecutionLogEvent as h, type CreateScheduleOptions as i, type SubscriptionStatus as j, type RunWorkflowResult as k, CopilotHelpers as l, type PageLike as m, type CopilotDoResult as n, type PrompteryxClientOptions as o, AUTOPILOT_MODELS as p, type ApiKeySummary as q, type AutopilotModel as r, type AutopilotModelId as s, type ConnectHubActionSummary as t, type ConnectHubAppSummary as u, type CustomNodeSummary as v, DEFAULT_AUTOPILOT_MODEL as w, type ExecutionStatus as x, type ExecutionTarget as y, type ProxyLocation as z };
|