@prompteryx/mcp-server 1.0.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.
Files changed (66) hide show
  1. package/README.md +271 -0
  2. package/dist/auth/api-key-auth.d.ts +51 -0
  3. package/dist/auth/api-key-auth.d.ts.map +1 -0
  4. package/dist/auth/api-key-auth.js +50 -0
  5. package/dist/auth/api-key-auth.js.map +1 -0
  6. package/dist/auth/usage-enforcer.d.ts +40 -0
  7. package/dist/auth/usage-enforcer.d.ts.map +1 -0
  8. package/dist/auth/usage-enforcer.js +134 -0
  9. package/dist/auth/usage-enforcer.js.map +1 -0
  10. package/dist/execution/cloud-executor.d.ts +16 -0
  11. package/dist/execution/cloud-executor.d.ts.map +1 -0
  12. package/dist/execution/cloud-executor.js +225 -0
  13. package/dist/execution/cloud-executor.js.map +1 -0
  14. package/dist/execution/integration-executor.d.ts +18 -0
  15. package/dist/execution/integration-executor.d.ts.map +1 -0
  16. package/dist/execution/integration-executor.js +101 -0
  17. package/dist/execution/integration-executor.js.map +1 -0
  18. package/dist/index.d.ts +19 -0
  19. package/dist/index.d.ts.map +1 -0
  20. package/dist/index.js +54 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/resources/workflow-resources.d.ts +16 -0
  23. package/dist/resources/workflow-resources.d.ts.map +1 -0
  24. package/dist/resources/workflow-resources.js +79 -0
  25. package/dist/resources/workflow-resources.js.map +1 -0
  26. package/dist/server.d.ts +28 -0
  27. package/dist/server.d.ts.map +1 -0
  28. package/dist/server.js +104 -0
  29. package/dist/server.js.map +1 -0
  30. package/dist/tools/ai-browser-tools.d.ts +21 -0
  31. package/dist/tools/ai-browser-tools.d.ts.map +1 -0
  32. package/dist/tools/ai-browser-tools.js +88 -0
  33. package/dist/tools/ai-browser-tools.js.map +1 -0
  34. package/dist/tools/browser-session-manager.d.ts +75 -0
  35. package/dist/tools/browser-session-manager.d.ts.map +1 -0
  36. package/dist/tools/browser-session-manager.js +206 -0
  37. package/dist/tools/browser-session-manager.js.map +1 -0
  38. package/dist/tools/browser-tools.d.ts +20 -0
  39. package/dist/tools/browser-tools.d.ts.map +1 -0
  40. package/dist/tools/browser-tools.js +270 -0
  41. package/dist/tools/browser-tools.js.map +1 -0
  42. package/dist/tools/data-tools.d.ts +9 -0
  43. package/dist/tools/data-tools.d.ts.map +1 -0
  44. package/dist/tools/data-tools.js +110 -0
  45. package/dist/tools/data-tools.js.map +1 -0
  46. package/dist/tools/integration-tools.d.ts +29 -0
  47. package/dist/tools/integration-tools.d.ts.map +1 -0
  48. package/dist/tools/integration-tools.js +214 -0
  49. package/dist/tools/integration-tools.js.map +1 -0
  50. package/dist/tools/workflow-builder-tools.d.ts +20 -0
  51. package/dist/tools/workflow-builder-tools.d.ts.map +1 -0
  52. package/dist/tools/workflow-builder-tools.js +95 -0
  53. package/dist/tools/workflow-builder-tools.js.map +1 -0
  54. package/dist/tools/workflow-tools.d.ts +16 -0
  55. package/dist/tools/workflow-tools.d.ts.map +1 -0
  56. package/dist/tools/workflow-tools.js +128 -0
  57. package/dist/tools/workflow-tools.js.map +1 -0
  58. package/dist/utils/node-config-loader.d.ts +54 -0
  59. package/dist/utils/node-config-loader.d.ts.map +1 -0
  60. package/dist/utils/node-config-loader.js +105 -0
  61. package/dist/utils/node-config-loader.js.map +1 -0
  62. package/dist/utils/output-formatter.d.ts +37 -0
  63. package/dist/utils/output-formatter.d.ts.map +1 -0
  64. package/dist/utils/output-formatter.js +62 -0
  65. package/dist/utils/output-formatter.js.map +1 -0
  66. package/package.json +51 -0
package/README.md ADDED
@@ -0,0 +1,271 @@
1
+ # @prompteryx/mcp-server
2
+
3
+ **The most feature-rich browser automation MCP server.** Control web browsers, run workflows, send emails, manage spreadsheets, and more — all from your favourite AI assistant.
4
+
5
+ Works with **Claude Desktop, ChatGPT, Cursor, VS Code, Gemini CLI**, and 400+ other MCP clients.
6
+
7
+ ---
8
+
9
+ ## Quick Start (5 minutes)
10
+
11
+ ### 1. Get your API key
12
+
13
+ 1. Log in at [prompteryx.ai](https://www.prompteryx.ai)
14
+ 2. Go to **Settings → API Keys**
15
+ 3. Click **Create API Key** and copy it (starts with `px_key_`)
16
+
17
+ ### 2. Add to your AI tool
18
+
19
+ **Claude Desktop** — edit `~/.claude/claude_desktop_config.json`:
20
+
21
+ ```json
22
+ {
23
+ "mcpServers": {
24
+ "prompteryx": {
25
+ "command": "npx",
26
+ "args": ["@prompteryx/mcp-server@latest"],
27
+ "env": { "PROMPTERYX_API_KEY": "px_key_YOUR_KEY_HERE" }
28
+ }
29
+ }
30
+ }
31
+ ```
32
+
33
+ **Cursor** — create `.cursor/mcp.json` in your project:
34
+
35
+ ```json
36
+ {
37
+ "mcpServers": {
38
+ "prompteryx": {
39
+ "command": "npx",
40
+ "args": ["@prompteryx/mcp-server@latest"],
41
+ "env": { "PROMPTERYX_API_KEY": "px_key_YOUR_KEY_HERE" }
42
+ }
43
+ }
44
+ }
45
+ ```
46
+
47
+ **VS Code** — add to `.vscode/settings.json`:
48
+
49
+ ```json
50
+ {
51
+ "mcp": {
52
+ "servers": {
53
+ "prompteryx": {
54
+ "command": "npx",
55
+ "args": ["@prompteryx/mcp-server@latest"],
56
+ "env": { "PROMPTERYX_API_KEY": "px_key_YOUR_KEY_HERE" }
57
+ }
58
+ }
59
+ }
60
+ }
61
+ ```
62
+
63
+ **ChatGPT** — via MCP connectors:
64
+
65
+ ```
66
+ Server URL: https://www.prompteryx.ai/api/mcp
67
+ API Key: px_key_YOUR_KEY_HERE
68
+ ```
69
+
70
+ **Gemini CLI**:
71
+
72
+ ```bash
73
+ gemini --mcp-server="npx @prompteryx/mcp-server" \
74
+ --mcp-env="PROMPTERYX_API_KEY=px_key_YOUR_KEY_HERE"
75
+ ```
76
+
77
+ ### 3. Start using it
78
+
79
+ Just ask your AI assistant:
80
+
81
+ - *"Go to amazon.com and find wireless headphones under £50"*
82
+ - *"Take a screenshot of the current page"*
83
+ - *"Send an email via Gmail to john@example.com with subject 'Meeting tomorrow'"*
84
+ - *"Read the data from my Google Sheet"*
85
+ - *"Create a Prompteryx workflow that monitors Gmail and posts to Slack"*
86
+ - *"Run my 'Daily Report' workflow"*
87
+
88
+ ---
89
+
90
+ ## What You Can Do
91
+
92
+ ### Browser Automation (21 tools)
93
+
94
+ Navigate websites, click buttons, fill forms, extract data, take screenshots, generate PDFs, manage cookies, upload files, execute JavaScript, and more.
95
+
96
+ All browser actions run in a **cloud browser** by default — nothing to install locally.
97
+
98
+ | Tool | Description |
99
+ |------|-------------|
100
+ | `browser_navigate` | Go to a URL |
101
+ | `browser_click` | Click an element |
102
+ | `browser_fill` | Fill an input field |
103
+ | `browser_type` | Type text character by character |
104
+ | `browser_press_key` | Press keyboard keys (Enter, Tab, etc.) |
105
+ | `browser_select` | Select a dropdown option |
106
+ | `browser_check` | Check/uncheck a checkbox |
107
+ | `browser_hover` | Hover over an element |
108
+ | `browser_scroll` | Scroll the page or to an element |
109
+ | `browser_extract_text` | Get text content from an element |
110
+ | `browser_extract_attribute` | Get an HTML attribute (href, src, etc.) |
111
+ | `browser_screenshot` | Take a screenshot (returns image) |
112
+ | `browser_evaluate` | Run JavaScript in the page |
113
+ | `browser_wait` | Wait for elements, timeouts, or navigation |
114
+ | `browser_get_page_info` | Get current URL and title |
115
+ | `browser_drag_drop` | Drag and drop elements |
116
+ | `browser_set_files` | Upload files |
117
+ | `browser_get_cookies` | Read cookies |
118
+ | `browser_set_cookies` | Set cookies |
119
+ | `browser_pdf` | Generate a PDF of the page |
120
+ | `browser_close` | Close the browser session |
121
+
122
+ ### AI Browser Agent
123
+
124
+ Give natural language instructions and let the AI see the screen and act:
125
+
126
+ | Tool | Description |
127
+ |------|-------------|
128
+ | `browser_ai_action` | "Log in and download the monthly report" — the AI figures out the clicks, scrolls, and typing |
129
+
130
+ Uses Google Gemini Computer Use. Actions are recorded so you can replay them without AI costs.
131
+
132
+ ### Workflows (unique — no other MCP server has this)
133
+
134
+ | Tool | Description |
135
+ |------|-------------|
136
+ | `workflow_list` | List your saved workflows |
137
+ | `workflow_get` | Get workflow details |
138
+ | `workflow_execute` | Run a saved workflow |
139
+ | `workflow_create` | Create a workflow (from nodes or natural language) |
140
+ | `workflow_delete` | Delete a workflow |
141
+ | `workflow_add_node` | Add a node to an existing workflow |
142
+ | `workflow_record_actions` | Record browser actions → save as reusable workflow |
143
+
144
+ ### Integrations
145
+
146
+ Automatically available for services you've connected on [prompteryx.ai/connections](https://www.prompteryx.ai/connections):
147
+
148
+ - **Gmail** — send, read, search emails
149
+ - **Google Sheets** — read, append, update data
150
+ - **Google Calendar** — create, list events
151
+ - **Google Drive** — upload, download, list files
152
+ - **Google Docs** — create, read documents
153
+ - **Slack** — send messages, manage channels
154
+ - **Notion** — create pages, manage databases
155
+ - **Airtable** — CRUD operations on bases
156
+ - **Microsoft Outlook, Excel, Word, SharePoint, Teams**
157
+ - **Telegram, WhatsApp, Facebook, Instagram, YouTube**
158
+ - **WordPress** — create posts, manage content
159
+ - **Stripe** — customers, charges, invoices
160
+ - **OpenAI, Anthropic, Gemini, ElevenLabs** — AI model calls
161
+ - More added regularly — new integrations appear automatically
162
+
163
+ ### Data Tools (zero cost, run locally)
164
+
165
+ | Tool | Description |
166
+ |------|-------------|
167
+ | `transform_json` | Parse, query, transform JSON data |
168
+ | `generate_uuid` | Generate a UUID |
169
+ | `base64_encode` | Encode text to Base64 |
170
+ | `base64_decode` | Decode Base64 to text |
171
+ | `format_date` | Format dates and timestamps |
172
+ | `math_operation` | Evaluate math expressions |
173
+
174
+ ### Resources
175
+
176
+ | Resource | URI | Description |
177
+ |----------|-----|-------------|
178
+ | Workflows | `prompteryx://workflows` | Your saved workflows |
179
+ | Connections | `prompteryx://connections` | Connected OAuth services |
180
+ | Usage | `prompteryx://usage` | Current usage stats and limits |
181
+
182
+ ---
183
+
184
+ ## Environment Variables
185
+
186
+ | Variable | Required | Default | Description |
187
+ |----------|----------|---------|-------------|
188
+ | `PROMPTERYX_API_KEY` | Yes | — | Your API key (from Settings → API Keys) |
189
+ | `PROMPTERYX_API_URL` | No | `https://www.prompteryx.ai` | API base URL |
190
+ | `PROMPTERYX_EXECUTION_MODE` | No | `cloud` | `cloud` or `local` |
191
+ | `PROMPTERYX_CHROME_PROFILE` | No | — | Chrome profile ID (local mode only) |
192
+ | `PROMPTERYX_SESSION_TIMEOUT` | No | `300000` | Session idle timeout in ms |
193
+ | `PROMPTERYX_STEALTH_MODE` | No | `true` | Bypass bot detection (Patchright) |
194
+ | `PROMPTERYX_VIDEO_RECORDING` | No | `false` | Record browser sessions |
195
+
196
+ ---
197
+
198
+ ## Local Browser Mode (optional)
199
+
200
+ For using your own Chrome profiles with saved logins:
201
+
202
+ 1. Download the **Prompteryx Desktop App** from [prompteryx.ai/download](https://www.prompteryx.ai/download)
203
+ 2. Install and launch it (runs in the system tray)
204
+ 3. Add to your config:
205
+
206
+ ```json
207
+ "env": {
208
+ "PROMPTERYX_API_KEY": "px_key_...",
209
+ "PROMPTERYX_EXECUTION_MODE": "local",
210
+ "PROMPTERYX_CHROME_PROFILE": "your-profile-id"
211
+ }
212
+ ```
213
+
214
+ ---
215
+
216
+ ## Pricing
217
+
218
+ MCP usage is included in your Prompteryx subscription:
219
+
220
+ | | Free | Starter (£20/mo) | Pro (£45/mo) | Enterprise |
221
+ |---|---|---|---|---|
222
+ | Browser tools | 1,500/mo | 3,000/mo | 12,000/mo | Custom |
223
+ | Cloud browser | — | 60 min | 300 min | 1,200 min |
224
+ | AI credits | 50 | 500 | 1,500 | Custom |
225
+ | Integrations | 3 services | All | All | All |
226
+ | Workflow execution | Limited | Unlimited | Unlimited | Unlimited |
227
+ | Workflow creation | — | Yes | Yes | Yes |
228
+ | Record to workflow | — | Yes | Yes | Yes |
229
+ | Stealth mode | — | Yes | Yes | Yes |
230
+ | Video recording | — | — | Yes | Yes |
231
+
232
+ ---
233
+
234
+ ## How It Compares
235
+
236
+ | Feature | Prompteryx | Playwright MCP | Zapier MCP | Puppeteer MCP |
237
+ |---------|-----------|---------------|-----------|--------------|
238
+ | Browser automation | 21 tools | 13 tools | None | 8 tools |
239
+ | Cloud browser | Yes | No | No | No |
240
+ | Chrome profiles | Yes | No | No | No |
241
+ | AI browser agent | Yes | No | No | No |
242
+ | Stealth mode | Yes | No | No | No |
243
+ | Integrations | 20+ | None | 8,000+ | None |
244
+ | Workflow builder | Yes | No | No | No |
245
+ | Action recording | Yes | No | No | No |
246
+ | Screenshots | Visual | Text-only | N/A | Yes |
247
+
248
+ ---
249
+
250
+ ## Troubleshooting
251
+
252
+ | Problem | Solution |
253
+ |---------|----------|
254
+ | "API key invalid" | Verify key starts with `px_key_` and is active in Settings |
255
+ | "Cloud browser minutes exceeded" | Upgrade your plan or use `PROMPTERYX_EXECUTION_MODE=local` |
256
+ | "Integration not available" | Connect the service at [prompteryx.ai/connections](https://www.prompteryx.ai/connections) |
257
+ | "Session disconnected" | The server auto-recovers — just retry your request |
258
+ | "AI credits exhausted" | Purchase more at Settings → AI Credits |
259
+ | Server not starting | Ensure Node.js 18+ is installed: `node --version` |
260
+
261
+ ---
262
+
263
+ ## Support
264
+
265
+ - Website: [prompteryx.ai](https://www.prompteryx.ai)
266
+ - Documentation: [docs.prompteryx.ai](https://docs.prompteryx.ai)
267
+ - Email: support@prompteryx.ai
268
+
269
+ ## License
270
+
271
+ MIT
@@ -0,0 +1,51 @@
1
+ /**
2
+ * API Key Authentication
3
+ *
4
+ * Validates the Prompteryx API key against the platform API
5
+ * and returns a full auth context with user info, subscription tier,
6
+ * usage stats, credentials, and workflows.
7
+ */
8
+ export interface CredentialSummary {
9
+ id: string;
10
+ connectorId: string;
11
+ name: string;
12
+ isValid: boolean;
13
+ }
14
+ export interface WorkflowSummary {
15
+ id: string;
16
+ name: string;
17
+ description?: string;
18
+ nodeCount: number;
19
+ lastRun?: string;
20
+ }
21
+ export interface MonthlyUsage {
22
+ executions: number;
23
+ cloudBrowserMinutes: number;
24
+ aiCreditsUsed: number;
25
+ }
26
+ export interface AuthContext {
27
+ userId: string;
28
+ email: string;
29
+ apiKeyId: string;
30
+ scopes: string[];
31
+ subscriptionTier: 'free' | 'starter' | 'pro' | 'enterprise';
32
+ aiCreditsIncluded: number;
33
+ aiCreditsUsedThisMonth: number;
34
+ cloudBrowserMinutesAllowed: number;
35
+ monthlyExecutionsAllowed: number;
36
+ monthlyUsage: MonthlyUsage;
37
+ credentials: CredentialSummary[];
38
+ workflows: WorkflowSummary[];
39
+ browserbaseContextId?: string;
40
+ }
41
+ export declare class AuthError extends Error {
42
+ statusCode: number;
43
+ constructor(message: string, statusCode?: number);
44
+ }
45
+ export declare function authenticate(apiKey: string, apiUrl: string): Promise<AuthContext>;
46
+ /**
47
+ * Refreshes usage data from the platform.
48
+ * Called periodically to keep limits in sync.
49
+ */
50
+ export declare function refreshAuthContext(apiKey: string, apiUrl: string): Promise<AuthContext>;
51
+ //# sourceMappingURL=api-key-auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-key-auth.d.ts","sourceRoot":"","sources":["../../src/auth/api-key-auth.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,gBAAgB,EAAE,MAAM,GAAG,SAAS,GAAG,KAAK,GAAG,YAAY,CAAC;IAC5D,iBAAiB,EAAE,MAAM,CAAC;IAC1B,sBAAsB,EAAE,MAAM,CAAC;IAC/B,0BAA0B,EAAE,MAAM,CAAC;IACnC,wBAAwB,EAAE,MAAM,CAAC;IACjC,YAAY,EAAE,YAAY,CAAC;IAC3B,WAAW,EAAE,iBAAiB,EAAE,CAAC;IACjC,SAAS,EAAE,eAAe,EAAE,CAAC;IAC7B,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,qBAAa,SAAU,SAAQ,KAAK;IACE,UAAU,EAAE,MAAM;gBAA1C,OAAO,EAAE,MAAM,EAAS,UAAU,GAAE,MAAY;CAI7D;AAED,wBAAsB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CA8BvF;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAE7F"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * API Key Authentication
3
+ *
4
+ * Validates the Prompteryx API key against the platform API
5
+ * and returns a full auth context with user info, subscription tier,
6
+ * usage stats, credentials, and workflows.
7
+ */
8
+ export class AuthError extends Error {
9
+ statusCode;
10
+ constructor(message, statusCode = 401) {
11
+ super(message);
12
+ this.statusCode = statusCode;
13
+ this.name = 'AuthError';
14
+ }
15
+ }
16
+ export async function authenticate(apiKey, apiUrl) {
17
+ if (!apiKey) {
18
+ throw new AuthError('PROMPTERYX_API_KEY environment variable is required');
19
+ }
20
+ const response = await fetch(`${apiUrl}/api/v1/auth/validate`, {
21
+ method: 'GET',
22
+ headers: {
23
+ 'X-API-Key': apiKey,
24
+ 'Content-Type': 'application/json',
25
+ },
26
+ });
27
+ if (!response.ok) {
28
+ const body = await response.text().catch(() => '');
29
+ if (response.status === 401) {
30
+ throw new AuthError('Invalid API key. Generate one at prompteryx.ai → Settings → API Keys.');
31
+ }
32
+ if (response.status === 403) {
33
+ throw new AuthError('API key does not have required scopes. Ensure workflows.execute and executions.create are enabled.');
34
+ }
35
+ throw new AuthError(`Authentication failed (${response.status}): ${body}`, response.status);
36
+ }
37
+ const data = await response.json();
38
+ if (!data.success || !data.data) {
39
+ throw new AuthError('Unexpected response from auth endpoint');
40
+ }
41
+ return data.data;
42
+ }
43
+ /**
44
+ * Refreshes usage data from the platform.
45
+ * Called periodically to keep limits in sync.
46
+ */
47
+ export async function refreshAuthContext(apiKey, apiUrl) {
48
+ return authenticate(apiKey, apiUrl);
49
+ }
50
+ //# sourceMappingURL=api-key-auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-key-auth.js","sourceRoot":"","sources":["../../src/auth/api-key-auth.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAuCH,MAAM,OAAO,SAAU,SAAQ,KAAK;IACE;IAApC,YAAY,OAAe,EAAS,aAAqB,GAAG;QAC1D,KAAK,CAAC,OAAO,CAAC,CAAC;QADmB,eAAU,GAAV,UAAU,CAAc;QAE1D,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;IAC1B,CAAC;CACF;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,MAAc,EAAE,MAAc;IAC/D,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,SAAS,CAAC,qDAAqD,CAAC,CAAC;IAC7E,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,MAAM,uBAAuB,EAAE;QAC7D,MAAM,EAAE,KAAK;QACb,OAAO,EAAE;YACP,WAAW,EAAE,MAAM;YACnB,cAAc,EAAE,kBAAkB;SACnC;KACF,CAAC,CAAC;IAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;QACnD,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YAC5B,MAAM,IAAI,SAAS,CAAC,uEAAuE,CAAC,CAAC;QAC/F,CAAC;QACD,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YAC5B,MAAM,IAAI,SAAS,CAAC,oGAAoG,CAAC,CAAC;QAC5H,CAAC;QACD,MAAM,IAAI,SAAS,CAAC,0BAA0B,QAAQ,CAAC,MAAM,MAAM,IAAI,EAAE,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC9F,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IACnC,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QAChC,MAAM,IAAI,SAAS,CAAC,wCAAwC,CAAC,CAAC;IAChE,CAAC;IAED,OAAO,IAAI,CAAC,IAAmB,CAAC;AAClC,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,MAAc,EAAE,MAAc;IACrE,OAAO,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AACtC,CAAC"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Usage Enforcement
3
+ *
4
+ * Pre-checks subscription limits before every tool call and
5
+ * records usage after successful execution.
6
+ * Mirrors the checks in lib/subscription-config.ts and
7
+ * app/api/cloud-execute/route.ts from the main platform.
8
+ */
9
+ import type { AuthContext } from './api-key-auth.js';
10
+ export type ToolCategory = 'browser' | 'ai-agent' | 'integration' | 'workflow' | 'data';
11
+ export interface UsageCheckResult {
12
+ allowed: boolean;
13
+ reason?: string;
14
+ }
15
+ export declare function getTierFeatures(tier: string): {
16
+ cloudBrowser: boolean;
17
+ aiAgent: boolean;
18
+ stealth: boolean;
19
+ videoRecording: boolean;
20
+ debugUrl: boolean;
21
+ workflowCreate: boolean;
22
+ recordToWorkflow: boolean;
23
+ maxIntegrationServices: number;
24
+ };
25
+ export declare function enforceUsageLimits(auth: AuthContext, category: ToolCategory, executionMode?: 'cloud' | 'local'): UsageCheckResult;
26
+ /**
27
+ * Records usage by calling the platform API.
28
+ * This increments the user's Firestore counters server-side.
29
+ */
30
+ export declare function recordUsage(apiKey: string, apiUrl: string, usage: {
31
+ cloudBrowserMinutes?: number;
32
+ aiCreditsUsed?: number;
33
+ executionCount?: number;
34
+ }): Promise<void>;
35
+ export declare function formatUsageRemaining(auth: AuthContext): {
36
+ cloudBrowserMinutes: number;
37
+ aiCredits: number;
38
+ executions: number;
39
+ };
40
+ //# sourceMappingURL=usage-enforcer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usage-enforcer.d.ts","sourceRoot":"","sources":["../../src/auth/usage-enforcer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,UAAU,GAAG,aAAa,GAAG,UAAU,GAAG,MAAM,CAAC;AAExF,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAsDD,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM;kBAnD5B,OAAO;aACZ,OAAO;aACP,OAAO;oBACA,OAAO;cACb,OAAO;oBACD,OAAO;sBACL,OAAO;4BACD,MAAM;EA8C/B;AAED,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,WAAW,EACjB,QAAQ,EAAE,YAAY,EACtB,aAAa,GAAE,OAAO,GAAG,OAAiB,GACzC,gBAAgB,CA2DlB;AAED;;;GAGG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,KAAK,EAAE;IACL,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,GACA,OAAO,CAAC,IAAI,CAAC,CAaf;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,WAAW;;;;EAMrD"}
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Usage Enforcement
3
+ *
4
+ * Pre-checks subscription limits before every tool call and
5
+ * records usage after successful execution.
6
+ * Mirrors the checks in lib/subscription-config.ts and
7
+ * app/api/cloud-execute/route.ts from the main platform.
8
+ */
9
+ const TIER_FEATURES = {
10
+ free: {
11
+ cloudBrowser: false,
12
+ aiAgent: true,
13
+ stealth: false,
14
+ videoRecording: false,
15
+ debugUrl: false,
16
+ workflowCreate: false,
17
+ recordToWorkflow: false,
18
+ maxIntegrationServices: 3,
19
+ },
20
+ starter: {
21
+ cloudBrowser: true,
22
+ aiAgent: true,
23
+ stealth: true,
24
+ videoRecording: false,
25
+ debugUrl: true,
26
+ workflowCreate: true,
27
+ recordToWorkflow: true,
28
+ maxIntegrationServices: Infinity,
29
+ },
30
+ pro: {
31
+ cloudBrowser: true,
32
+ aiAgent: true,
33
+ stealth: true,
34
+ videoRecording: true,
35
+ debugUrl: true,
36
+ workflowCreate: true,
37
+ recordToWorkflow: true,
38
+ maxIntegrationServices: Infinity,
39
+ },
40
+ enterprise: {
41
+ cloudBrowser: true,
42
+ aiAgent: true,
43
+ stealth: true,
44
+ videoRecording: true,
45
+ debugUrl: true,
46
+ workflowCreate: true,
47
+ recordToWorkflow: true,
48
+ maxIntegrationServices: Infinity,
49
+ },
50
+ };
51
+ export function getTierFeatures(tier) {
52
+ return TIER_FEATURES[tier] ?? TIER_FEATURES.free;
53
+ }
54
+ export function enforceUsageLimits(auth, category, executionMode = 'cloud') {
55
+ const features = getTierFeatures(auth.subscriptionTier);
56
+ // Browser tools using cloud need cloud minutes
57
+ if (category === 'browser' && executionMode === 'cloud') {
58
+ if (!features.cloudBrowser) {
59
+ return {
60
+ allowed: false,
61
+ reason: 'Cloud browser is not available on the Free plan. Upgrade to Starter (£20/mo) or use local mode with the Prompteryx Desktop App.',
62
+ };
63
+ }
64
+ if (auth.monthlyUsage.cloudBrowserMinutes >= auth.cloudBrowserMinutesAllowed) {
65
+ return {
66
+ allowed: false,
67
+ reason: `Cloud browser minutes exceeded (${auth.monthlyUsage.cloudBrowserMinutes}/${auth.cloudBrowserMinutesAllowed}). Upgrade your plan or switch to local execution mode.`,
68
+ };
69
+ }
70
+ }
71
+ // AI agent needs credits
72
+ if (category === 'ai-agent') {
73
+ const remaining = auth.aiCreditsIncluded - auth.aiCreditsUsedThisMonth;
74
+ if (remaining <= 0) {
75
+ return {
76
+ allowed: false,
77
+ reason: 'AI credits exhausted. Purchase more at prompteryx.ai → Settings → AI Credits, or upgrade your plan.',
78
+ };
79
+ }
80
+ if (executionMode === 'cloud' && !features.cloudBrowser) {
81
+ return {
82
+ allowed: false,
83
+ reason: 'AI Browser Agent requires cloud browser access. Upgrade to Starter or higher.',
84
+ };
85
+ }
86
+ }
87
+ // Workflow execution counts
88
+ if (category === 'workflow') {
89
+ if (auth.monthlyUsage.executions >= auth.monthlyExecutionsAllowed) {
90
+ return {
91
+ allowed: false,
92
+ reason: `Monthly execution limit reached (${auth.monthlyUsage.executions}/${auth.monthlyExecutionsAllowed}). Upgrade your plan for more executions.`,
93
+ };
94
+ }
95
+ }
96
+ // Integration calls count as executions
97
+ if (category === 'integration') {
98
+ if (auth.monthlyUsage.executions >= auth.monthlyExecutionsAllowed) {
99
+ return {
100
+ allowed: false,
101
+ reason: `Monthly execution limit reached (${auth.monthlyUsage.executions}/${auth.monthlyExecutionsAllowed}).`,
102
+ };
103
+ }
104
+ }
105
+ // Data tools are always allowed (run locally, zero cost)
106
+ return { allowed: true };
107
+ }
108
+ /**
109
+ * Records usage by calling the platform API.
110
+ * This increments the user's Firestore counters server-side.
111
+ */
112
+ export async function recordUsage(apiKey, apiUrl, usage) {
113
+ try {
114
+ await fetch(`${apiUrl}/api/v1/usage/record`, {
115
+ method: 'POST',
116
+ headers: {
117
+ 'X-API-Key': apiKey,
118
+ 'Content-Type': 'application/json',
119
+ },
120
+ body: JSON.stringify(usage),
121
+ });
122
+ }
123
+ catch {
124
+ // Best-effort — don't block the tool call on usage recording failure
125
+ }
126
+ }
127
+ export function formatUsageRemaining(auth) {
128
+ return {
129
+ cloudBrowserMinutes: auth.cloudBrowserMinutesAllowed - auth.monthlyUsage.cloudBrowserMinutes,
130
+ aiCredits: auth.aiCreditsIncluded - auth.aiCreditsUsedThisMonth,
131
+ executions: auth.monthlyExecutionsAllowed - auth.monthlyUsage.executions,
132
+ };
133
+ }
134
+ //# sourceMappingURL=usage-enforcer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usage-enforcer.js","sourceRoot":"","sources":["../../src/auth/usage-enforcer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAWH,MAAM,aAAa,GASd;IACH,IAAI,EAAE;QACJ,YAAY,EAAE,KAAK;QACnB,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,KAAK;QACd,cAAc,EAAE,KAAK;QACrB,QAAQ,EAAE,KAAK;QACf,cAAc,EAAE,KAAK;QACrB,gBAAgB,EAAE,KAAK;QACvB,sBAAsB,EAAE,CAAC;KAC1B;IACD,OAAO,EAAE;QACP,YAAY,EAAE,IAAI;QAClB,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,IAAI;QACb,cAAc,EAAE,KAAK;QACrB,QAAQ,EAAE,IAAI;QACd,cAAc,EAAE,IAAI;QACpB,gBAAgB,EAAE,IAAI;QACtB,sBAAsB,EAAE,QAAQ;KACjC;IACD,GAAG,EAAE;QACH,YAAY,EAAE,IAAI;QAClB,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,IAAI;QACb,cAAc,EAAE,IAAI;QACpB,QAAQ,EAAE,IAAI;QACd,cAAc,EAAE,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AC;IAAC,MAAM,CAAC;QACP,qEAAqE;IACvE,CAAC;AACH,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,IAAiB;IACpD,OAAO;QACL,mBAAmB,EAAE,IAAI,CAAC,0BAA0B,GAAG,IAAI,CAAC,YAAY,CAAC,mBAAmB;QAC5F,SAAS,EAAE,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,sBAAsB;QAC/D,UAAU,EAAE,IAAI,CAAC,wBAAwB,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU;KACzE,CAAC;AACJ,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Cloud Executor
3
+ *
4
+ * Executes browser node operations on a cloud Browserbase session
5
+ * by calling individual node actions against the active Playwright page.
6
+ * Mirrors the logic from lib/node-executor.ts executeNode().
7
+ */
8
+ import type { Page } from 'playwright-core';
9
+ import { type McpToolResult } from '../utils/output-formatter.js';
10
+ /**
11
+ * Core browser action executor.
12
+ * Takes a Playwright Page and a command with params,
13
+ * then executes the corresponding browser action.
14
+ */
15
+ export declare function executeBrowserAction(page: Page, action: string, params: Record<string, any>): Promise<McpToolResult>;
16
+ //# sourceMappingURL=cloud-executor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cloud-executor.d.ts","sourceRoot":"","sources":["../../src/execution/cloud-executor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAIL,KAAK,aAAa,EACnB,MAAM,8BAA8B,CAAC;AAItC;;;;GAIG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC1B,OAAO,CAAC,aAAa,CAAC,CAsNxB"}