@prompteryx/sdk 0.4.0 → 0.4.1
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/README.md +336 -336
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +15 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -2
- package/dist/index.mjs.map +1 -1
- package/dist/{page-8LsjwpEo.d.mts → page-CjBjLBLN.d.mts} +2 -2
- package/dist/{page-8LsjwpEo.d.ts → page-CjBjLBLN.d.ts} +2 -2
- package/dist/page.d.mts +1 -1
- package/dist/page.d.ts +1 -1
- package/package.json +86 -86
- package/src/client.ts +24 -2
- package/src/index.ts +140 -140
- package/src/models.ts +66 -63
- package/src/resources/cloudBrowser.ts +197 -197
- package/src/resources/connectHub.ts +1 -1
- package/src/types.ts +1 -1
package/package.json
CHANGED
|
@@ -1,86 +1,86 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@prompteryx/sdk",
|
|
3
|
-
"version": "0.4.
|
|
4
|
-
"description": "Official TypeScript SDK for Prompteryx
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"author": "Prompteryx <support@prompteryx.
|
|
7
|
-
"homepage": "https://prompteryx.
|
|
8
|
-
"repository": {
|
|
9
|
-
"type": "git",
|
|
10
|
-
"url": "git+https://github.com/prompteryx/sdk-js.git"
|
|
11
|
-
},
|
|
12
|
-
"type": "commonjs",
|
|
13
|
-
"keywords": [
|
|
14
|
-
"prompteryx",
|
|
15
|
-
"browser-automation",
|
|
16
|
-
"playwright",
|
|
17
|
-
"ai-agent",
|
|
18
|
-
"cloud-browser",
|
|
19
|
-
"autopilot",
|
|
20
|
-
"copilot",
|
|
21
|
-
"web-automation"
|
|
22
|
-
],
|
|
23
|
-
"main": "dist/index.js",
|
|
24
|
-
"module": "dist/index.mjs",
|
|
25
|
-
"types": "dist/index.d.ts",
|
|
26
|
-
"exports": {
|
|
27
|
-
".": {
|
|
28
|
-
"import": {
|
|
29
|
-
"types": "./dist/index.d.mts",
|
|
30
|
-
"default": "./dist/index.mjs"
|
|
31
|
-
},
|
|
32
|
-
"require": {
|
|
33
|
-
"types": "./dist/index.d.ts",
|
|
34
|
-
"default": "./dist/index.js"
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
"./page": {
|
|
38
|
-
"import": {
|
|
39
|
-
"types": "./dist/page.d.mts",
|
|
40
|
-
"default": "./dist/page.mjs"
|
|
41
|
-
},
|
|
42
|
-
"require": {
|
|
43
|
-
"types": "./dist/page.d.ts",
|
|
44
|
-
"default": "./dist/page.js"
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
"sideEffects": false,
|
|
49
|
-
"files": [
|
|
50
|
-
"dist",
|
|
51
|
-
"src",
|
|
52
|
-
"README.md",
|
|
53
|
-
"LICENSE"
|
|
54
|
-
],
|
|
55
|
-
"scripts": {
|
|
56
|
-
"build": "tsup",
|
|
57
|
-
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
58
|
-
"prepublishOnly": "npm run typecheck && npm run build",
|
|
59
|
-
"clean": "rimraf dist"
|
|
60
|
-
},
|
|
61
|
-
"publishConfig": {
|
|
62
|
-
"access": "public"
|
|
63
|
-
},
|
|
64
|
-
"peerDependencies": {
|
|
65
|
-
"playwright-core": ">=1.40.0",
|
|
66
|
-
"zod": ">=3.20.0"
|
|
67
|
-
},
|
|
68
|
-
"peerDependenciesMeta": {
|
|
69
|
-
"playwright-core": {
|
|
70
|
-
"optional": true
|
|
71
|
-
},
|
|
72
|
-
"zod": {
|
|
73
|
-
"optional": true
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
"devDependencies": {
|
|
77
|
-
"@types/node": ">=18.0.0",
|
|
78
|
-
"playwright-core": "^1.56.1",
|
|
79
|
-
"tsup": "^8.5.0",
|
|
80
|
-
"typescript": "^5.0.0",
|
|
81
|
-
"zod": "^3.24.1"
|
|
82
|
-
},
|
|
83
|
-
"engines": {
|
|
84
|
-
"node": ">=18.0.0"
|
|
85
|
-
}
|
|
86
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@prompteryx/sdk",
|
|
3
|
+
"version": "0.4.1",
|
|
4
|
+
"description": "Official TypeScript SDK for Prompteryx \u2014 cloud browser, the AI Browser Agent (autopilot), workflows, and the copilot do/read/scan primitives.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Prompteryx <support@prompteryx.ai>",
|
|
7
|
+
"homepage": "https://www.prompteryx.ai",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/prompteryx/sdk-js.git"
|
|
11
|
+
},
|
|
12
|
+
"type": "commonjs",
|
|
13
|
+
"keywords": [
|
|
14
|
+
"prompteryx",
|
|
15
|
+
"browser-automation",
|
|
16
|
+
"playwright",
|
|
17
|
+
"ai-agent",
|
|
18
|
+
"cloud-browser",
|
|
19
|
+
"autopilot",
|
|
20
|
+
"copilot",
|
|
21
|
+
"web-automation"
|
|
22
|
+
],
|
|
23
|
+
"main": "dist/index.js",
|
|
24
|
+
"module": "dist/index.mjs",
|
|
25
|
+
"types": "dist/index.d.ts",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"import": {
|
|
29
|
+
"types": "./dist/index.d.mts",
|
|
30
|
+
"default": "./dist/index.mjs"
|
|
31
|
+
},
|
|
32
|
+
"require": {
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"default": "./dist/index.js"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"./page": {
|
|
38
|
+
"import": {
|
|
39
|
+
"types": "./dist/page.d.mts",
|
|
40
|
+
"default": "./dist/page.mjs"
|
|
41
|
+
},
|
|
42
|
+
"require": {
|
|
43
|
+
"types": "./dist/page.d.ts",
|
|
44
|
+
"default": "./dist/page.js"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"sideEffects": false,
|
|
49
|
+
"files": [
|
|
50
|
+
"dist",
|
|
51
|
+
"src",
|
|
52
|
+
"README.md",
|
|
53
|
+
"LICENSE"
|
|
54
|
+
],
|
|
55
|
+
"scripts": {
|
|
56
|
+
"build": "tsup",
|
|
57
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
58
|
+
"prepublishOnly": "npm run typecheck && npm run build",
|
|
59
|
+
"clean": "rimraf dist"
|
|
60
|
+
},
|
|
61
|
+
"publishConfig": {
|
|
62
|
+
"access": "public"
|
|
63
|
+
},
|
|
64
|
+
"peerDependencies": {
|
|
65
|
+
"playwright-core": ">=1.40.0",
|
|
66
|
+
"zod": ">=3.20.0"
|
|
67
|
+
},
|
|
68
|
+
"peerDependenciesMeta": {
|
|
69
|
+
"playwright-core": {
|
|
70
|
+
"optional": true
|
|
71
|
+
},
|
|
72
|
+
"zod": {
|
|
73
|
+
"optional": true
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
"devDependencies": {
|
|
77
|
+
"@types/node": ">=18.0.0",
|
|
78
|
+
"playwright-core": "^1.56.1",
|
|
79
|
+
"tsup": "^8.5.0",
|
|
80
|
+
"typescript": "^5.0.0",
|
|
81
|
+
"zod": "^3.24.1"
|
|
82
|
+
},
|
|
83
|
+
"engines": {
|
|
84
|
+
"node": ">=18.0.0"
|
|
85
|
+
}
|
|
86
|
+
}
|
package/src/client.ts
CHANGED
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
} from './errors'
|
|
29
29
|
import type { PrompteryxClientOptions } from './types'
|
|
30
30
|
|
|
31
|
-
const DEFAULT_BASE_URL = 'https://prompteryx.
|
|
31
|
+
const DEFAULT_BASE_URL = 'https://www.prompteryx.ai'
|
|
32
32
|
const DEFAULT_TIMEOUT_MS = 60_000
|
|
33
33
|
const DEFAULT_MAX_RETRIES = 2
|
|
34
34
|
|
|
@@ -50,6 +50,26 @@ export interface RequestOptions {
|
|
|
50
50
|
signal?: AbortSignal
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
/**
|
|
54
|
+
* Every /api/v1 route answers `{ success, data, meta }`. Resources read the
|
|
55
|
+
* payload directly (`res.workflows`, `res.apps`, …), so unwrap the envelope
|
|
56
|
+
* here. Before 0.4.1 the raw envelope was returned and every list() came
|
|
57
|
+
* back empty. Non-envelope bodies (webhooks, raw payloads) pass through.
|
|
58
|
+
*/
|
|
59
|
+
function unwrapEnvelope(parsed: unknown): unknown {
|
|
60
|
+
if (
|
|
61
|
+
parsed &&
|
|
62
|
+
typeof parsed === 'object' &&
|
|
63
|
+
!Array.isArray(parsed) &&
|
|
64
|
+
'success' in parsed &&
|
|
65
|
+
'data' in parsed &&
|
|
66
|
+
typeof (parsed as { success: unknown }).success === 'boolean'
|
|
67
|
+
) {
|
|
68
|
+
return (parsed as { data: unknown }).data
|
|
69
|
+
}
|
|
70
|
+
return parsed
|
|
71
|
+
}
|
|
72
|
+
|
|
53
73
|
export class HttpClient {
|
|
54
74
|
private readonly apiKey: string
|
|
55
75
|
/** Optional Cloud Browser key (`pcb_live_…`) — a separate key family used
|
|
@@ -86,14 +106,16 @@ export class HttpClient {
|
|
|
86
106
|
const res = await this.rawRequest(path, opts)
|
|
87
107
|
const text = await res.text()
|
|
88
108
|
if (!text) return undefined as T
|
|
109
|
+
let parsed: unknown
|
|
89
110
|
try {
|
|
90
|
-
|
|
111
|
+
parsed = JSON.parse(text)
|
|
91
112
|
} catch {
|
|
92
113
|
throw new ParseError(`Failed to parse JSON response from ${path}`, {
|
|
93
114
|
status: res.status,
|
|
94
115
|
raw: text.slice(0, 500),
|
|
95
116
|
})
|
|
96
117
|
}
|
|
118
|
+
return unwrapEnvelope(parsed) as T
|
|
97
119
|
}
|
|
98
120
|
|
|
99
121
|
/** Returns the raw Response. Throws typed errors on non-2xx, but does
|
package/src/index.ts
CHANGED
|
@@ -1,140 +1,140 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @prompteryx/sdk
|
|
3
|
-
*
|
|
4
|
-
* Official TypeScript SDK for the Prompteryx platform.
|
|
5
|
-
*
|
|
6
|
-
* Two AI surfaces:
|
|
7
|
-
*
|
|
8
|
-
* • **Copilot** — helps with ONE step you describe in plain English.
|
|
9
|
-
* Your code drives Playwright; copilot just figures out the
|
|
10
|
-
* selector to click / the data to pull / what's on the page.
|
|
11
|
-
*
|
|
12
|
-
* ```ts
|
|
13
|
-
* await px.copilot.do(page, 'click the Sign up button')
|
|
14
|
-
* const product = await px.copilot.read(page, productSchema)
|
|
15
|
-
* const actions = await px.copilot.scan(page, 'checkout buttons')
|
|
16
|
-
* ```
|
|
17
|
-
*
|
|
18
|
-
* • **Autopilot** — runs an autonomous multi-step task end-to-end
|
|
19
|
-
* with no per-action involvement from you.
|
|
20
|
-
*
|
|
21
|
-
* ```ts
|
|
22
|
-
* const result = await px.autopilot.run({
|
|
23
|
-
* goal: 'Apply for the Senior Engineer role at OpenAI',
|
|
24
|
-
* saveAsWorkflow: true, // permanent zero-AI-cost replay
|
|
25
|
-
* })
|
|
26
|
-
* ```
|
|
27
|
-
*
|
|
28
|
-
* Plus workflows, executions, cloud browser sessions / fetch / search,
|
|
29
|
-
* schedules, profiles, and subscription telemetry.
|
|
30
|
-
*
|
|
31
|
-
* TWO KEY FAMILIES:
|
|
32
|
-
* • `apiKey` (`px_live_…`) — the platform API key; sent as
|
|
33
|
-
* `Authorization: Bearer`. 60 requests/minute, 10,000/day.
|
|
34
|
-
* • `cloudBrowserKey` (`pcb_live_…`) — the Cloud Browser key; required
|
|
35
|
-
* only for `px.cloudBrowser.*`, sent as `x-api-key`.
|
|
36
|
-
*
|
|
37
|
-
* Quick start:
|
|
38
|
-
*
|
|
39
|
-
* ```ts
|
|
40
|
-
* import { Prompteryx } from '@prompteryx/sdk'
|
|
41
|
-
* import { chromium } from 'playwright-core'
|
|
42
|
-
*
|
|
43
|
-
* const px = new Prompteryx({
|
|
44
|
-
* apiKey: process.env.PROMPTERYX_API_KEY!, // px_live_…
|
|
45
|
-
* cloudBrowserKey: process.env.PROMPTERYX_CLOUD_BROWSER_KEY, // pcb_live_…
|
|
46
|
-
* })
|
|
47
|
-
*
|
|
48
|
-
* // 1. Cloud browser session
|
|
49
|
-
* const session = await px.cloudBrowser.sessions.create({
|
|
50
|
-
* useProxy: true, proxyLocation: 'us',
|
|
51
|
-
* })
|
|
52
|
-
* const browser = await chromium.connectOverCDP(session.connectUrl)
|
|
53
|
-
* const page = browser.contexts()[0].pages()[0]
|
|
54
|
-
*
|
|
55
|
-
* // 2. Copilot on top of Playwright
|
|
56
|
-
* await page.goto('https://news.ycombinator.com')
|
|
57
|
-
* const top = await px.copilot.read(page, z.object({
|
|
58
|
-
* stories: z.array(z.object({ title: z.string(), url: z.string() })),
|
|
59
|
-
* }))
|
|
60
|
-
* ```
|
|
61
|
-
*
|
|
62
|
-
* See PROMPTERYX_SDK.md in docs/ for the full design + reference.
|
|
63
|
-
*/
|
|
64
|
-
|
|
65
|
-
import { HttpClient } from './client'
|
|
66
|
-
import { AutopilotResource } from './resources/autopilot'
|
|
67
|
-
import { CloudBrowserResource } from './resources/cloudBrowser'
|
|
68
|
-
import { ExecutionsResource } from './resources/executions'
|
|
69
|
-
import { ProfilesResource } from './resources/profiles'
|
|
70
|
-
import { SchedulesResource } from './resources/schedules'
|
|
71
|
-
import { SubscriptionResource } from './resources/subscription'
|
|
72
|
-
import { WorkflowsResource } from './resources/workflows'
|
|
73
|
-
import { CopilotHelpers, type PageLike } from './page'
|
|
74
|
-
import type {
|
|
75
|
-
CopilotDoResult,
|
|
76
|
-
DiscoveredAction,
|
|
77
|
-
PrompteryxClientOptions,
|
|
78
|
-
} from './types'
|
|
79
|
-
|
|
80
|
-
// Public re-exports
|
|
81
|
-
export * from './errors'
|
|
82
|
-
export * from './types'
|
|
83
|
-
export * from './models'
|
|
84
|
-
export type { PageLike }
|
|
85
|
-
|
|
86
|
-
// v0.4.0 (2026-09-03): the connectHub, customNodes, templates, apiKeys and
|
|
87
|
-
// recordings namespaces plus subscription.usage() were REMOVED from the
|
|
88
|
-
// public surface — the routes they target don't exist on the live API (or,
|
|
89
|
-
// for api-keys, can never accept API-key auth). The source files remain in
|
|
90
|
-
// src/resources/ with dated NOT-SHIPPED headers for a future release.
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Copilot surface — bundles the three on-page primitives behind a
|
|
94
|
-
* single namespace so calling code reads as
|
|
95
|
-
* `px.copilot.do(...)` / `px.copilot.read(...)` / `px.copilot.scan(...)`.
|
|
96
|
-
* Used internally by the Prompteryx class.
|
|
97
|
-
*/
|
|
98
|
-
class Copilot {
|
|
99
|
-
constructor(private readonly helpers: CopilotHelpers) {}
|
|
100
|
-
/** Execute a natural-language action on a connected Playwright page. */
|
|
101
|
-
do(page: PageLike, instruction: string, opts?: { timeout?: number }): Promise<CopilotDoResult> {
|
|
102
|
-
return this.helpers.do(page, instruction, opts)
|
|
103
|
-
}
|
|
104
|
-
/** Pull typed data from the page (Zod schema or raw JSON Schema). */
|
|
105
|
-
read<T>(page: PageLike, schema: { parse(input: unknown): T } | { jsonSchema: unknown }): Promise<T> {
|
|
106
|
-
return this.helpers.read<T>(page, schema as any)
|
|
107
|
-
}
|
|
108
|
-
/** Discover available actions on the page; useful pre-`do` step. */
|
|
109
|
-
scan(page: PageLike, hint?: string): Promise<DiscoveredAction[]> {
|
|
110
|
-
return this.helpers.scan(page, hint)
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export class Prompteryx {
|
|
115
|
-
private readonly http: HttpClient
|
|
116
|
-
|
|
117
|
-
// Core resources — the verified live surface.
|
|
118
|
-
public readonly workflows: WorkflowsResource
|
|
119
|
-
public readonly executions: ExecutionsResource
|
|
120
|
-
public readonly cloudBrowser: CloudBrowserResource
|
|
121
|
-
public readonly autopilot: AutopilotResource
|
|
122
|
-
public readonly copilot: Copilot
|
|
123
|
-
public readonly schedules: SchedulesResource
|
|
124
|
-
public readonly profiles: ProfilesResource
|
|
125
|
-
public readonly subscription: SubscriptionResource
|
|
126
|
-
|
|
127
|
-
constructor(opts: PrompteryxClientOptions) {
|
|
128
|
-
this.http = new HttpClient(opts)
|
|
129
|
-
this.workflows = new WorkflowsResource(this.http)
|
|
130
|
-
this.executions = new ExecutionsResource(this.http)
|
|
131
|
-
this.cloudBrowser = new CloudBrowserResource(this.http)
|
|
132
|
-
this.autopilot = new AutopilotResource(this.http)
|
|
133
|
-
this.copilot = new Copilot(new CopilotHelpers(this.http))
|
|
134
|
-
this.schedules = new SchedulesResource(this.http)
|
|
135
|
-
this.profiles = new ProfilesResource(this.http)
|
|
136
|
-
this.subscription = new SubscriptionResource(this.http)
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
export default Prompteryx
|
|
1
|
+
/**
|
|
2
|
+
* @prompteryx/sdk
|
|
3
|
+
*
|
|
4
|
+
* Official TypeScript SDK for the Prompteryx platform.
|
|
5
|
+
*
|
|
6
|
+
* Two AI surfaces:
|
|
7
|
+
*
|
|
8
|
+
* • **Copilot** — helps with ONE step you describe in plain English.
|
|
9
|
+
* Your code drives Playwright; copilot just figures out the
|
|
10
|
+
* selector to click / the data to pull / what's on the page.
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* await px.copilot.do(page, 'click the Sign up button')
|
|
14
|
+
* const product = await px.copilot.read(page, productSchema)
|
|
15
|
+
* const actions = await px.copilot.scan(page, 'checkout buttons')
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* • **Autopilot** — runs an autonomous multi-step task end-to-end
|
|
19
|
+
* with no per-action involvement from you.
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* const result = await px.autopilot.run({
|
|
23
|
+
* goal: 'Apply for the Senior Engineer role at OpenAI',
|
|
24
|
+
* saveAsWorkflow: true, // permanent zero-AI-cost replay
|
|
25
|
+
* })
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* Plus workflows, executions, cloud browser sessions / fetch / search,
|
|
29
|
+
* schedules, profiles, and subscription telemetry.
|
|
30
|
+
*
|
|
31
|
+
* TWO KEY FAMILIES:
|
|
32
|
+
* • `apiKey` (`px_live_…`) — the platform API key; sent as
|
|
33
|
+
* `Authorization: Bearer`. 60 requests/minute, 10,000/day.
|
|
34
|
+
* • `cloudBrowserKey` (`pcb_live_…`) — the Cloud Browser key; required
|
|
35
|
+
* only for `px.cloudBrowser.*`, sent as `x-api-key`.
|
|
36
|
+
*
|
|
37
|
+
* Quick start:
|
|
38
|
+
*
|
|
39
|
+
* ```ts
|
|
40
|
+
* import { Prompteryx } from '@prompteryx/sdk'
|
|
41
|
+
* import { chromium } from 'playwright-core'
|
|
42
|
+
*
|
|
43
|
+
* const px = new Prompteryx({
|
|
44
|
+
* apiKey: process.env.PROMPTERYX_API_KEY!, // px_live_…
|
|
45
|
+
* cloudBrowserKey: process.env.PROMPTERYX_CLOUD_BROWSER_KEY, // pcb_live_…
|
|
46
|
+
* })
|
|
47
|
+
*
|
|
48
|
+
* // 1. Cloud browser session
|
|
49
|
+
* const session = await px.cloudBrowser.sessions.create({
|
|
50
|
+
* useProxy: true, proxyLocation: 'us',
|
|
51
|
+
* })
|
|
52
|
+
* const browser = await chromium.connectOverCDP(session.connectUrl)
|
|
53
|
+
* const page = browser.contexts()[0].pages()[0]
|
|
54
|
+
*
|
|
55
|
+
* // 2. Copilot on top of Playwright
|
|
56
|
+
* await page.goto('https://news.ycombinator.com')
|
|
57
|
+
* const top = await px.copilot.read(page, z.object({
|
|
58
|
+
* stories: z.array(z.object({ title: z.string(), url: z.string() })),
|
|
59
|
+
* }))
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* See PROMPTERYX_SDK.md in docs/ for the full design + reference.
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
import { HttpClient } from './client'
|
|
66
|
+
import { AutopilotResource } from './resources/autopilot'
|
|
67
|
+
import { CloudBrowserResource } from './resources/cloudBrowser'
|
|
68
|
+
import { ExecutionsResource } from './resources/executions'
|
|
69
|
+
import { ProfilesResource } from './resources/profiles'
|
|
70
|
+
import { SchedulesResource } from './resources/schedules'
|
|
71
|
+
import { SubscriptionResource } from './resources/subscription'
|
|
72
|
+
import { WorkflowsResource } from './resources/workflows'
|
|
73
|
+
import { CopilotHelpers, type PageLike } from './page'
|
|
74
|
+
import type {
|
|
75
|
+
CopilotDoResult,
|
|
76
|
+
DiscoveredAction,
|
|
77
|
+
PrompteryxClientOptions,
|
|
78
|
+
} from './types'
|
|
79
|
+
|
|
80
|
+
// Public re-exports
|
|
81
|
+
export * from './errors'
|
|
82
|
+
export * from './types'
|
|
83
|
+
export * from './models'
|
|
84
|
+
export type { PageLike }
|
|
85
|
+
|
|
86
|
+
// v0.4.0 (2026-09-03): the connectHub, customNodes, templates, apiKeys and
|
|
87
|
+
// recordings namespaces plus subscription.usage() were REMOVED from the
|
|
88
|
+
// public surface — the routes they target don't exist on the live API (or,
|
|
89
|
+
// for api-keys, can never accept API-key auth). The source files remain in
|
|
90
|
+
// src/resources/ with dated NOT-SHIPPED headers for a future release.
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Copilot surface — bundles the three on-page primitives behind a
|
|
94
|
+
* single namespace so calling code reads as
|
|
95
|
+
* `px.copilot.do(...)` / `px.copilot.read(...)` / `px.copilot.scan(...)`.
|
|
96
|
+
* Used internally by the Prompteryx class.
|
|
97
|
+
*/
|
|
98
|
+
class Copilot {
|
|
99
|
+
constructor(private readonly helpers: CopilotHelpers) {}
|
|
100
|
+
/** Execute a natural-language action on a connected Playwright page. */
|
|
101
|
+
do(page: PageLike, instruction: string, opts?: { timeout?: number }): Promise<CopilotDoResult> {
|
|
102
|
+
return this.helpers.do(page, instruction, opts)
|
|
103
|
+
}
|
|
104
|
+
/** Pull typed data from the page (Zod schema or raw JSON Schema). */
|
|
105
|
+
read<T>(page: PageLike, schema: { parse(input: unknown): T } | { jsonSchema: unknown }): Promise<T> {
|
|
106
|
+
return this.helpers.read<T>(page, schema as any)
|
|
107
|
+
}
|
|
108
|
+
/** Discover available actions on the page; useful pre-`do` step. */
|
|
109
|
+
scan(page: PageLike, hint?: string): Promise<DiscoveredAction[]> {
|
|
110
|
+
return this.helpers.scan(page, hint)
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export class Prompteryx {
|
|
115
|
+
private readonly http: HttpClient
|
|
116
|
+
|
|
117
|
+
// Core resources — the verified live surface.
|
|
118
|
+
public readonly workflows: WorkflowsResource
|
|
119
|
+
public readonly executions: ExecutionsResource
|
|
120
|
+
public readonly cloudBrowser: CloudBrowserResource
|
|
121
|
+
public readonly autopilot: AutopilotResource
|
|
122
|
+
public readonly copilot: Copilot
|
|
123
|
+
public readonly schedules: SchedulesResource
|
|
124
|
+
public readonly profiles: ProfilesResource
|
|
125
|
+
public readonly subscription: SubscriptionResource
|
|
126
|
+
|
|
127
|
+
constructor(opts: PrompteryxClientOptions) {
|
|
128
|
+
this.http = new HttpClient(opts)
|
|
129
|
+
this.workflows = new WorkflowsResource(this.http)
|
|
130
|
+
this.executions = new ExecutionsResource(this.http)
|
|
131
|
+
this.cloudBrowser = new CloudBrowserResource(this.http)
|
|
132
|
+
this.autopilot = new AutopilotResource(this.http)
|
|
133
|
+
this.copilot = new Copilot(new CopilotHelpers(this.http))
|
|
134
|
+
this.schedules = new SchedulesResource(this.http)
|
|
135
|
+
this.profiles = new ProfilesResource(this.http)
|
|
136
|
+
this.subscription = new SubscriptionResource(this.http)
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export default Prompteryx
|
package/src/models.ts
CHANGED
|
@@ -1,63 +1,66 @@
|
|
|
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-
|
|
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
|
-
|
|
15
|
-
export const AUTOPILOT_MODELS = [
|
|
16
|
-
// ── Standard (Gemini native Computer Use) ────────────────────────────────
|
|
17
|
-
'gemini-3.5-flash', // Recommended — fast and cheap. THE DEFAULT.
|
|
18
|
-
'gemini-3.7-flash', // Newest GA Flash — Google-recommended for computer use
|
|
19
|
-
'gemini-3.6-flash', // Newest Flash (Computer Use preview)
|
|
20
|
-
'gemini-default', // Gemini 2.5 Computer Use (legacy)
|
|
21
|
-
// ── Experimental (Gemini) ────────────────────────────────────────────────
|
|
22
|
-
'gemini-3-flash-preview',
|
|
23
|
-
'gemini-3.5-flash-lite',
|
|
24
|
-
// Harness aliases — resolved server-side to an underlying brain + prompt.
|
|
25
|
-
'model-a',
|
|
26
|
-
'model-a1',
|
|
27
|
-
'model-b',
|
|
28
|
-
'model-j',
|
|
29
|
-
'model-k',
|
|
30
|
-
'model-k37',
|
|
31
|
-
// ── Anthropic / OpenAI native Computer Use ───────────────────────────────
|
|
32
|
-
'claude-sonnet-4-6',
|
|
33
|
-
'claude-opus-4-8',
|
|
34
|
-
'gpt-5.6-terra',
|
|
35
|
-
'gpt-5.6-sol',
|
|
36
|
-
'gpt-5.5',
|
|
37
|
-
//
|
|
38
|
-
|
|
39
|
-
'claude-
|
|
40
|
-
'claude-
|
|
41
|
-
'claude-
|
|
42
|
-
'
|
|
43
|
-
'
|
|
44
|
-
'gpt-
|
|
45
|
-
'
|
|
46
|
-
|
|
47
|
-
'
|
|
48
|
-
'
|
|
49
|
-
|
|
50
|
-
'
|
|
51
|
-
'model-
|
|
52
|
-
'model-
|
|
53
|
-
'model-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
export type
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
export
|
|
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-07 — 35 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
|
+
|
|
15
|
+
export const AUTOPILOT_MODELS = [
|
|
16
|
+
// ── Standard (Gemini native Computer Use) ────────────────────────────────
|
|
17
|
+
'gemini-3.5-flash', // Recommended — fast and cheap. THE DEFAULT.
|
|
18
|
+
'gemini-3.7-flash', // Newest GA Flash — Google-recommended for computer use
|
|
19
|
+
'gemini-3.6-flash', // Newest Flash (Computer Use preview)
|
|
20
|
+
'gemini-default', // Gemini 2.5 Computer Use (legacy)
|
|
21
|
+
// ── Experimental (Gemini) ────────────────────────────────────────────────
|
|
22
|
+
'gemini-3-flash-preview',
|
|
23
|
+
'gemini-3.5-flash-lite',
|
|
24
|
+
// Harness aliases — resolved server-side to an underlying brain + prompt.
|
|
25
|
+
'model-a',
|
|
26
|
+
'model-a1',
|
|
27
|
+
'model-b',
|
|
28
|
+
'model-j',
|
|
29
|
+
'model-k',
|
|
30
|
+
'model-k37',
|
|
31
|
+
// ── Anthropic / OpenAI native Computer Use ───────────────────────────────
|
|
32
|
+
'claude-sonnet-4-6',
|
|
33
|
+
'claude-opus-4-8',
|
|
34
|
+
'gpt-5.6-terra',
|
|
35
|
+
'gpt-5.6-sol',
|
|
36
|
+
'gpt-5.5',
|
|
37
|
+
'gpt-6-astra', // OpenAI flagship (Sep 2026) — admin-gated in the UI for now
|
|
38
|
+
// ── Generic Vision Loop (standard chat models on screenshots) ────────────
|
|
39
|
+
'claude-fable-5-1-vision',
|
|
40
|
+
'claude-fable-5-vision',
|
|
41
|
+
'claude-opus-5-vision',
|
|
42
|
+
'claude-sonnet-5-vision',
|
|
43
|
+
'claude-sonnet-4-6-vision',
|
|
44
|
+
'gpt-6-astra-vision', // admin-gated in the UI for now
|
|
45
|
+
'gpt-5.6-luna-vision',
|
|
46
|
+
'gpt-5.4-vision',
|
|
47
|
+
'gpt-4o-vision',
|
|
48
|
+
'kimi-k3-vision',
|
|
49
|
+
// ── Experimental server-side harness engines ─────────────────────────────
|
|
50
|
+
'modelc',
|
|
51
|
+
'model-d',
|
|
52
|
+
'model-d1',
|
|
53
|
+
'model-e',
|
|
54
|
+
'model-f',
|
|
55
|
+
'model-h',
|
|
56
|
+
'model-i',
|
|
57
|
+
] as const
|
|
58
|
+
|
|
59
|
+
/** A model id from the known catalog. */
|
|
60
|
+
export type AutopilotModelId = (typeof AUTOPILOT_MODELS)[number]
|
|
61
|
+
|
|
62
|
+
/** Open union: known ids autocomplete, forward-compatible strings still pass. */
|
|
63
|
+
export type AutopilotModel = AutopilotModelId | (string & {})
|
|
64
|
+
|
|
65
|
+
/** The platform default when `model` is omitted. */
|
|
66
|
+
export const DEFAULT_AUTOPILOT_MODEL = 'gemini-3.5-flash'
|