@getpaseo/protocol 0.1.103 → 0.1.104-beta.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.
@@ -0,0 +1,347 @@
1
+ import { z } from "zod";
2
+ export const BrowserAutomationErrorCodeSchema = z.enum([
3
+ "browser_disabled",
4
+ "browser_no_desktop",
5
+ "browser_tab_not_found",
6
+ "browser_tab_closed",
7
+ "browser_timeout",
8
+ "screenshot_no_frame",
9
+ "browser_denied",
10
+ "browser_unsupported",
11
+ "browser_stale_ref",
12
+ "browser_unknown_error",
13
+ ]);
14
+ const BROWSER_AUTOMATION_BROWSER_ID_PATTERN = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|\d{13,}-[0-9a-f]+)$/i;
15
+ const BROWSER_AUTOMATION_BROWSER_ID_MESSAGE = "browserId must be a real id returned by browser_new_tab or browser_list_tabs";
16
+ const BROWSER_AUTOMATION_WAIT_CONDITION_MESSAGE = "browser_wait requires exactly one of text or url";
17
+ export const BrowserAutomationBrowserIdSchema = z
18
+ .string({ error: () => BROWSER_AUTOMATION_BROWSER_ID_MESSAGE })
19
+ .min(1, BROWSER_AUTOMATION_BROWSER_ID_MESSAGE)
20
+ .regex(BROWSER_AUTOMATION_BROWSER_ID_PATTERN, BROWSER_AUTOMATION_BROWSER_ID_MESSAGE);
21
+ const BrowserAutomationTabTargetSchema = z
22
+ .object({
23
+ browserId: BrowserAutomationBrowserIdSchema,
24
+ })
25
+ .strict();
26
+ const BrowserAutomationRefSchema = z.string().regex(/^@e\d+$/);
27
+ const BrowserAutomationHttpUrlSchema = z
28
+ .string()
29
+ .url()
30
+ .refine((value) => {
31
+ const protocol = new URL(value).protocol;
32
+ return protocol === "http:" || protocol === "https:";
33
+ }, "URL must use http or https");
34
+ export const BrowserAutomationListTabsCommandSchema = z.object({
35
+ command: z.literal("list_tabs"),
36
+ args: z.object({}).strict().default({}),
37
+ });
38
+ export const BrowserAutomationNewTabCommandSchema = z.object({
39
+ command: z.literal("new_tab"),
40
+ args: z
41
+ .object({
42
+ url: BrowserAutomationHttpUrlSchema.optional(),
43
+ })
44
+ .strict()
45
+ .default({}),
46
+ });
47
+ export const BrowserAutomationSnapshotCommandSchema = z.object({
48
+ command: z.literal("snapshot"),
49
+ args: BrowserAutomationTabTargetSchema,
50
+ });
51
+ export const BrowserAutomationClickCommandSchema = z.object({
52
+ command: z.literal("click"),
53
+ args: BrowserAutomationTabTargetSchema.extend({
54
+ ref: BrowserAutomationRefSchema,
55
+ }),
56
+ });
57
+ export const BrowserAutomationFillCommandSchema = z.object({
58
+ command: z.literal("fill"),
59
+ args: BrowserAutomationTabTargetSchema.extend({
60
+ ref: BrowserAutomationRefSchema,
61
+ value: z.string(),
62
+ }),
63
+ });
64
+ export const BrowserAutomationWaitCommandSchema = z.object({
65
+ command: z.literal("wait"),
66
+ args: BrowserAutomationTabTargetSchema.extend({
67
+ text: z.string().min(1).optional(),
68
+ url: z.string().min(1).optional(),
69
+ timeoutMs: z.number().int().positive().max(30000).optional(),
70
+ }).refine((args) => Number(Boolean(args.text)) + Number(Boolean(args.url)) === 1, {
71
+ message: BROWSER_AUTOMATION_WAIT_CONDITION_MESSAGE,
72
+ }),
73
+ });
74
+ export const BrowserAutomationTypeCommandSchema = z.object({
75
+ command: z.literal("type"),
76
+ args: BrowserAutomationTabTargetSchema.extend({
77
+ ref: BrowserAutomationRefSchema.optional(),
78
+ text: z.string(),
79
+ }),
80
+ });
81
+ export const BrowserAutomationKeypressCommandSchema = z.object({
82
+ command: z.literal("keypress"),
83
+ args: BrowserAutomationTabTargetSchema.extend({
84
+ ref: BrowserAutomationRefSchema.optional(),
85
+ key: z.string().min(1),
86
+ }),
87
+ });
88
+ export const BrowserAutomationNavigateCommandSchema = z.object({
89
+ command: z.literal("navigate"),
90
+ args: BrowserAutomationTabTargetSchema.extend({
91
+ url: BrowserAutomationHttpUrlSchema,
92
+ }),
93
+ });
94
+ export const BrowserAutomationBackCommandSchema = z.object({
95
+ command: z.literal("back"),
96
+ args: BrowserAutomationTabTargetSchema,
97
+ });
98
+ export const BrowserAutomationForwardCommandSchema = z.object({
99
+ command: z.literal("forward"),
100
+ args: BrowserAutomationTabTargetSchema,
101
+ });
102
+ export const BrowserAutomationReloadCommandSchema = z.object({
103
+ command: z.literal("reload"),
104
+ args: BrowserAutomationTabTargetSchema,
105
+ });
106
+ export const BrowserAutomationScreenshotCommandSchema = z.object({
107
+ command: z.literal("screenshot"),
108
+ args: BrowserAutomationTabTargetSchema.extend({
109
+ fullPage: z.boolean().default(false),
110
+ }),
111
+ });
112
+ export const BrowserAutomationUploadCommandSchema = z.object({
113
+ command: z.literal("upload"),
114
+ args: BrowserAutomationTabTargetSchema.extend({
115
+ ref: BrowserAutomationRefSchema,
116
+ filePaths: z.array(z.string().min(1)).min(1),
117
+ }),
118
+ });
119
+ export const BrowserAutomationSelectCommandSchema = z.object({
120
+ command: z.literal("select"),
121
+ args: BrowserAutomationTabTargetSchema.extend({
122
+ ref: BrowserAutomationRefSchema,
123
+ value: z.string(),
124
+ }),
125
+ });
126
+ export const BrowserAutomationHoverCommandSchema = z.object({
127
+ command: z.literal("hover"),
128
+ args: BrowserAutomationTabTargetSchema.extend({
129
+ ref: BrowserAutomationRefSchema,
130
+ }),
131
+ });
132
+ export const BrowserAutomationDragCommandSchema = z.object({
133
+ command: z.literal("drag"),
134
+ args: BrowserAutomationTabTargetSchema.extend({
135
+ sourceRef: BrowserAutomationRefSchema,
136
+ targetRef: BrowserAutomationRefSchema,
137
+ }),
138
+ });
139
+ export const BrowserAutomationLogsCommandSchema = z.object({
140
+ command: z.literal("logs"),
141
+ args: BrowserAutomationTabTargetSchema.extend({
142
+ maxEntries: z.number().int().positive().max(200).default(50),
143
+ }),
144
+ });
145
+ export const BrowserAutomationCommandSchema = z.discriminatedUnion("command", [
146
+ BrowserAutomationListTabsCommandSchema,
147
+ BrowserAutomationNewTabCommandSchema,
148
+ BrowserAutomationSnapshotCommandSchema,
149
+ BrowserAutomationClickCommandSchema,
150
+ BrowserAutomationFillCommandSchema,
151
+ BrowserAutomationWaitCommandSchema,
152
+ BrowserAutomationTypeCommandSchema,
153
+ BrowserAutomationKeypressCommandSchema,
154
+ BrowserAutomationNavigateCommandSchema,
155
+ BrowserAutomationBackCommandSchema,
156
+ BrowserAutomationForwardCommandSchema,
157
+ BrowserAutomationReloadCommandSchema,
158
+ BrowserAutomationScreenshotCommandSchema,
159
+ BrowserAutomationUploadCommandSchema,
160
+ BrowserAutomationSelectCommandSchema,
161
+ BrowserAutomationHoverCommandSchema,
162
+ BrowserAutomationDragCommandSchema,
163
+ BrowserAutomationLogsCommandSchema,
164
+ ]);
165
+ export const BrowserAutomationTabInfoSchema = z.object({
166
+ browserId: BrowserAutomationBrowserIdSchema,
167
+ workspaceId: z.string().min(1).optional(),
168
+ url: z.string(),
169
+ title: z.string(),
170
+ isActive: z.boolean().default(false),
171
+ isLoading: z.boolean().default(false),
172
+ canGoBack: z.boolean().optional(),
173
+ canGoForward: z.boolean().optional(),
174
+ });
175
+ export const BrowserAutomationListTabsResultSchema = z.object({
176
+ command: z.literal("list_tabs"),
177
+ tabs: z.array(BrowserAutomationTabInfoSchema),
178
+ });
179
+ export const BrowserAutomationNewTabResultSchema = z.object({
180
+ command: z.literal("new_tab"),
181
+ browserId: BrowserAutomationBrowserIdSchema,
182
+ workspaceId: z.string().min(1),
183
+ url: z.string().min(1),
184
+ });
185
+ export const BrowserAutomationSnapshotElementSchema = z.object({
186
+ ref: z.string().regex(/^@e\d+$/),
187
+ role: z.string(),
188
+ tagName: z.string(),
189
+ text: z.string(),
190
+ selector: z.string(),
191
+ attributes: z.record(z.string(), z.string()).default({}),
192
+ });
193
+ export const BrowserAutomationSnapshotResultSchema = z.object({
194
+ command: z.literal("snapshot"),
195
+ browserId: BrowserAutomationBrowserIdSchema,
196
+ workspaceId: z.string().min(1).optional(),
197
+ url: z.string(),
198
+ title: z.string(),
199
+ elements: z.array(BrowserAutomationSnapshotElementSchema),
200
+ });
201
+ export const BrowserAutomationClickResultSchema = z.object({
202
+ command: z.literal("click"),
203
+ browserId: BrowserAutomationBrowserIdSchema,
204
+ ref: BrowserAutomationRefSchema,
205
+ });
206
+ export const BrowserAutomationFillResultSchema = z.object({
207
+ command: z.literal("fill"),
208
+ browserId: BrowserAutomationBrowserIdSchema,
209
+ ref: BrowserAutomationRefSchema,
210
+ });
211
+ export const BrowserAutomationWaitResultSchema = z.object({
212
+ command: z.literal("wait"),
213
+ browserId: BrowserAutomationBrowserIdSchema,
214
+ matched: z.enum(["text", "url"]),
215
+ });
216
+ export const BrowserAutomationTypeResultSchema = z.object({
217
+ command: z.literal("type"),
218
+ browserId: BrowserAutomationBrowserIdSchema,
219
+ ref: BrowserAutomationRefSchema.optional(),
220
+ });
221
+ export const BrowserAutomationKeypressResultSchema = z.object({
222
+ command: z.literal("keypress"),
223
+ browserId: BrowserAutomationBrowserIdSchema,
224
+ key: z.string().min(1),
225
+ ref: BrowserAutomationRefSchema.optional(),
226
+ });
227
+ export const BrowserAutomationNavigateResultSchema = z.object({
228
+ command: z.literal("navigate"),
229
+ browserId: BrowserAutomationBrowserIdSchema,
230
+ url: z.string().min(1),
231
+ });
232
+ export const BrowserAutomationBackResultSchema = z.object({
233
+ command: z.literal("back"),
234
+ browserId: BrowserAutomationBrowserIdSchema,
235
+ });
236
+ export const BrowserAutomationForwardResultSchema = z.object({
237
+ command: z.literal("forward"),
238
+ browserId: BrowserAutomationBrowserIdSchema,
239
+ });
240
+ export const BrowserAutomationReloadResultSchema = z.object({
241
+ command: z.literal("reload"),
242
+ browserId: BrowserAutomationBrowserIdSchema,
243
+ });
244
+ export const BrowserAutomationScreenshotResultSchema = z.object({
245
+ command: z.literal("screenshot"),
246
+ browserId: BrowserAutomationBrowserIdSchema,
247
+ mimeType: z.literal("image/png"),
248
+ dataBase64: z.string().min(1),
249
+ width: z.number().int().nonnegative(),
250
+ height: z.number().int().nonnegative(),
251
+ });
252
+ export const BrowserAutomationUploadResultSchema = z.object({
253
+ command: z.literal("upload"),
254
+ browserId: BrowserAutomationBrowserIdSchema,
255
+ ref: BrowserAutomationRefSchema,
256
+ filePaths: z.array(z.string().min(1)).min(1),
257
+ });
258
+ export const BrowserAutomationSelectResultSchema = z.object({
259
+ command: z.literal("select"),
260
+ browserId: BrowserAutomationBrowserIdSchema,
261
+ ref: BrowserAutomationRefSchema,
262
+ value: z.string(),
263
+ });
264
+ export const BrowserAutomationHoverResultSchema = z.object({
265
+ command: z.literal("hover"),
266
+ browserId: BrowserAutomationBrowserIdSchema,
267
+ ref: BrowserAutomationRefSchema,
268
+ });
269
+ export const BrowserAutomationDragResultSchema = z.object({
270
+ command: z.literal("drag"),
271
+ browserId: BrowserAutomationBrowserIdSchema,
272
+ sourceRef: BrowserAutomationRefSchema,
273
+ targetRef: BrowserAutomationRefSchema,
274
+ });
275
+ export const BrowserAutomationConsoleLogEntrySchema = z.object({
276
+ level: z.string(),
277
+ message: z.string(),
278
+ source: z.string().optional(),
279
+ line: z.number().int().optional(),
280
+ timestamp: z.number(),
281
+ });
282
+ export const BrowserAutomationNetworkLogEntrySchema = z.object({
283
+ url: z.string(),
284
+ method: z.string().optional(),
285
+ status: z.number().int().optional(),
286
+ type: z.string().optional(),
287
+ startTime: z.number(),
288
+ duration: z.number(),
289
+ transferSize: z.number().optional(),
290
+ });
291
+ export const BrowserAutomationLogsResultSchema = z.object({
292
+ command: z.literal("logs"),
293
+ browserId: BrowserAutomationBrowserIdSchema,
294
+ console: z.array(BrowserAutomationConsoleLogEntrySchema),
295
+ network: z.array(BrowserAutomationNetworkLogEntrySchema),
296
+ });
297
+ export const BrowserAutomationResultSchema = z.discriminatedUnion("command", [
298
+ BrowserAutomationListTabsResultSchema,
299
+ BrowserAutomationNewTabResultSchema,
300
+ BrowserAutomationSnapshotResultSchema,
301
+ BrowserAutomationClickResultSchema,
302
+ BrowserAutomationFillResultSchema,
303
+ BrowserAutomationWaitResultSchema,
304
+ BrowserAutomationTypeResultSchema,
305
+ BrowserAutomationKeypressResultSchema,
306
+ BrowserAutomationNavigateResultSchema,
307
+ BrowserAutomationBackResultSchema,
308
+ BrowserAutomationForwardResultSchema,
309
+ BrowserAutomationReloadResultSchema,
310
+ BrowserAutomationScreenshotResultSchema,
311
+ BrowserAutomationUploadResultSchema,
312
+ BrowserAutomationSelectResultSchema,
313
+ BrowserAutomationHoverResultSchema,
314
+ BrowserAutomationDragResultSchema,
315
+ BrowserAutomationLogsResultSchema,
316
+ ]);
317
+ export const BrowserAutomationErrorSchema = z.object({
318
+ code: BrowserAutomationErrorCodeSchema,
319
+ message: z.string().min(1),
320
+ retryable: z.boolean().default(false),
321
+ });
322
+ export const BrowserAutomationExecuteRequestSchema = z
323
+ .object({
324
+ type: z.literal("browser.automation.execute.request"),
325
+ requestId: z.string().min(1),
326
+ agentId: z.string().min(1).optional(),
327
+ cwd: z.string().min(1).optional(),
328
+ workspaceId: z.string().min(1).optional(),
329
+ command: BrowserAutomationCommandSchema,
330
+ })
331
+ .strict();
332
+ export const BrowserAutomationExecuteResponseSchema = z.object({
333
+ type: z.literal("browser.automation.execute.response"),
334
+ payload: z.discriminatedUnion("ok", [
335
+ z.object({
336
+ requestId: z.string().min(1),
337
+ ok: z.literal(true),
338
+ result: BrowserAutomationResultSchema,
339
+ }),
340
+ z.object({
341
+ requestId: z.string().min(1),
342
+ ok: z.literal(false),
343
+ error: BrowserAutomationErrorSchema,
344
+ }),
345
+ ]),
346
+ });
347
+ //# sourceMappingURL=rpc-schemas.js.map
@@ -2,6 +2,7 @@ export declare const CLIENT_CAPS: {
2
2
  readonly reasoningMergeEnum: "reasoning_merge_enum";
3
3
  readonly customModeIcons: "custom_mode_icons";
4
4
  readonly terminalReflowableSnapshot: "terminal_reflowable_snapshot";
5
+ readonly desktopBrowserAutomation: "desktop_browser_automation";
5
6
  };
6
7
  export type ClientCapability = (typeof CLIENT_CAPS)[keyof typeof CLIENT_CAPS];
7
8
  //# sourceMappingURL=client-capabilities.d.ts.map
@@ -11,5 +11,6 @@ export const CLIENT_CAPS = {
11
11
  // Old clients use a strict TerminalState schema and would reject the extra fields.
12
12
  // Drop the gate (always send the flags) when floor >= v0.1.88.
13
13
  terminalReflowableSnapshot: "terminal_reflowable_snapshot",
14
+ desktopBrowserAutomation: "desktop_browser_automation",
14
15
  };
15
16
  //# sourceMappingURL=client-capabilities.js.map