@otto-code/protocol 0.5.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/README.md +12 -0
- package/dist/agent-attention-notification.d.ts +41 -0
- package/dist/agent-attention-notification.js +140 -0
- package/dist/agent-labels.d.ts +7 -0
- package/dist/agent-labels.js +11 -0
- package/dist/agent-lifecycle.d.ts +3 -0
- package/dist/agent-lifecycle.js +8 -0
- package/dist/agent-personalities.d.ts +32 -0
- package/dist/agent-personalities.js +69 -0
- package/dist/agent-state-bucket.d.ts +14 -0
- package/dist/agent-state-bucket.js +41 -0
- package/dist/agent-title-limits.d.ts +2 -0
- package/dist/agent-title-limits.js +2 -0
- package/dist/agent-types.d.ts +479 -0
- package/dist/agent-types.js +22 -0
- package/dist/artifacts/rpc-schemas.d.ts +396 -0
- package/dist/artifacts/rpc-schemas.js +175 -0
- package/dist/artifacts/types.d.ts +166 -0
- package/dist/artifacts/types.js +73 -0
- package/dist/binary-frames/demux.d.ts +11 -0
- package/dist/binary-frames/demux.js +23 -0
- package/dist/binary-frames/file-transfer.d.ts +50 -0
- package/dist/binary-frames/file-transfer.js +107 -0
- package/dist/binary-frames/index.d.ts +4 -0
- package/dist/binary-frames/index.js +4 -0
- package/dist/binary-frames/terminal.d.ts +31 -0
- package/dist/binary-frames/terminal.js +99 -0
- package/dist/branch-slug.d.ts +14 -0
- package/dist/branch-slug.js +49 -0
- package/dist/browser-automation/capabilities.d.ts +7 -0
- package/dist/browser-automation/capabilities.js +31 -0
- package/dist/browser-automation/rpc-schemas.d.ts +1329 -0
- package/dist/browser-automation/rpc-schemas.js +555 -0
- package/dist/chat/rpc-schemas.d.ts +158 -0
- package/dist/chat/rpc-schemas.js +103 -0
- package/dist/chat/types.d.ts +30 -0
- package/dist/chat/types.js +22 -0
- package/dist/client-capabilities.d.ts +8 -0
- package/dist/client-capabilities.js +16 -0
- package/dist/connection-offer.d.ts +36 -0
- package/dist/connection-offer.js +53 -0
- package/dist/daemon-endpoints.d.ts +47 -0
- package/dist/daemon-endpoints.js +201 -0
- package/dist/default-personalities.d.ts +3 -0
- package/dist/default-personalities.js +127 -0
- package/dist/effort.d.ts +32 -0
- package/dist/effort.js +99 -0
- package/dist/error-utils.d.ts +11 -0
- package/dist/error-utils.js +27 -0
- package/dist/generated/validation/ws-outbound.aot.d.ts +2 -0
- package/dist/generated/validation/ws-outbound.aot.js +48755 -0
- package/dist/git-hosting.d.ts +21 -0
- package/dist/git-hosting.js +36 -0
- package/dist/git-remote.d.ts +18 -0
- package/dist/git-remote.js +84 -0
- package/dist/host-connection-schema.d.ts +11 -0
- package/dist/host-connection-schema.js +9 -0
- package/dist/literal-union.d.ts +2 -0
- package/dist/literal-union.js +2 -0
- package/dist/loop/rpc-schemas.d.ts +636 -0
- package/dist/loop/rpc-schemas.js +163 -0
- package/dist/messages.d.ts +38505 -0
- package/dist/messages.js +4719 -0
- package/dist/otto-config-schema.d.ts +136 -0
- package/dist/otto-config-schema.js +96 -0
- package/dist/path-utils.d.ts +2 -0
- package/dist/path-utils.js +16 -0
- package/dist/provider-config.d.ts +266 -0
- package/dist/provider-config.js +238 -0
- package/dist/provider-icon-names.d.ts +5 -0
- package/dist/provider-icon-names.js +52 -0
- package/dist/provider-manifest.d.ts +34 -0
- package/dist/provider-manifest.js +227 -0
- package/dist/schedule/cron-expression.d.ts +13 -0
- package/dist/schedule/cron-expression.js +97 -0
- package/dist/schedule/rpc-schemas.d.ts +667 -0
- package/dist/schedule/rpc-schemas.js +155 -0
- package/dist/schedule/types.d.ts +236 -0
- package/dist/schedule/types.js +84 -0
- package/dist/terminal-activity.d.ts +21 -0
- package/dist/terminal-activity.js +25 -0
- package/dist/terminal-input-mode.d.ts +26 -0
- package/dist/terminal-input-mode.js +151 -0
- package/dist/terminal-key-input.d.ts +13 -0
- package/dist/terminal-key-input.js +201 -0
- package/dist/terminal-profiles.d.ts +6 -0
- package/dist/terminal-profiles.js +28 -0
- package/dist/terminal-snapshot.d.ts +3 -0
- package/dist/terminal-snapshot.js +178 -0
- package/dist/terminal-stream-protocol.d.ts +2 -0
- package/dist/terminal-stream-protocol.js +2 -0
- package/dist/terminal-subscription-key.d.ts +2 -0
- package/dist/terminal-subscription-key.js +9 -0
- package/dist/tool-call-display.d.ts +11 -0
- package/dist/tool-call-display.js +135 -0
- package/dist/tool-name-normalization.d.ts +9 -0
- package/dist/tool-name-normalization.js +82 -0
- package/dist/validation/ws-outbound-schema-metadata.d.ts +7256 -0
- package/dist/validation/ws-outbound-schema-metadata.js +3 -0
- package/dist/validation/ws-outbound.d.ts +12 -0
- package/dist/validation/ws-outbound.js +8 -0
- package/package.json +42 -0
|
@@ -0,0 +1,555 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const BrowserAutomationErrorCodeSchema = z.enum([
|
|
3
|
+
"browser_disabled",
|
|
4
|
+
"browser_no_host",
|
|
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_element_not_found",
|
|
13
|
+
"browser_unknown_error",
|
|
14
|
+
]);
|
|
15
|
+
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;
|
|
16
|
+
const BROWSER_AUTOMATION_BROWSER_ID_MESSAGE = "browserId must be a real id returned by browser_new_tab or browser_list_tabs";
|
|
17
|
+
const BROWSER_AUTOMATION_WAIT_CONDITION_MESSAGE = "browser_wait requires exactly one of text or url";
|
|
18
|
+
const BROWSER_AUTOMATION_INSPECT_TARGET_MESSAGE = "browser_inspect requires exactly one of selector or ref";
|
|
19
|
+
export const BROWSER_AUTOMATION_COMMAND_NAMES = [
|
|
20
|
+
"list_tabs",
|
|
21
|
+
"new_tab",
|
|
22
|
+
"snapshot",
|
|
23
|
+
"click",
|
|
24
|
+
"fill",
|
|
25
|
+
"wait",
|
|
26
|
+
"type",
|
|
27
|
+
"keypress",
|
|
28
|
+
"navigate",
|
|
29
|
+
"back",
|
|
30
|
+
"forward",
|
|
31
|
+
"reload",
|
|
32
|
+
"screenshot",
|
|
33
|
+
"upload",
|
|
34
|
+
"select",
|
|
35
|
+
"hover",
|
|
36
|
+
"drag",
|
|
37
|
+
"logs",
|
|
38
|
+
"evaluate",
|
|
39
|
+
"inspect",
|
|
40
|
+
"network",
|
|
41
|
+
"scroll",
|
|
42
|
+
"resize",
|
|
43
|
+
"close_tab",
|
|
44
|
+
];
|
|
45
|
+
export const BrowserAutomationCommandNameSchema = z.enum(BROWSER_AUTOMATION_COMMAND_NAMES);
|
|
46
|
+
export const BrowserAutomationBrowserIdSchema = z
|
|
47
|
+
.string({ error: () => BROWSER_AUTOMATION_BROWSER_ID_MESSAGE })
|
|
48
|
+
.min(1, BROWSER_AUTOMATION_BROWSER_ID_MESSAGE)
|
|
49
|
+
.regex(BROWSER_AUTOMATION_BROWSER_ID_PATTERN, BROWSER_AUTOMATION_BROWSER_ID_MESSAGE);
|
|
50
|
+
const BrowserAutomationTabTargetSchema = z
|
|
51
|
+
.object({
|
|
52
|
+
browserId: BrowserAutomationBrowserIdSchema,
|
|
53
|
+
})
|
|
54
|
+
.strict();
|
|
55
|
+
const BrowserAutomationRefSchema = z.string().regex(/^@e\d+$/);
|
|
56
|
+
const BrowserAutomationMouseButtonSchema = z.enum(["left", "right", "middle"]);
|
|
57
|
+
const BrowserAutomationInputModifierSchema = z.enum(["Alt", "Control", "Meta", "Shift"]);
|
|
58
|
+
const BrowserAutomationHttpUrlSchema = z
|
|
59
|
+
.string()
|
|
60
|
+
.url()
|
|
61
|
+
.refine((value) => {
|
|
62
|
+
const protocol = new URL(value).protocol;
|
|
63
|
+
return protocol === "http:" || protocol === "https:";
|
|
64
|
+
}, "URL must use http or https");
|
|
65
|
+
export const BrowserAutomationListTabsCommandSchema = z.object({
|
|
66
|
+
command: z.literal("list_tabs"),
|
|
67
|
+
args: z.object({}).strict().default({}),
|
|
68
|
+
});
|
|
69
|
+
export const BrowserAutomationNewTabCommandSchema = z.object({
|
|
70
|
+
command: z.literal("new_tab"),
|
|
71
|
+
args: z
|
|
72
|
+
.object({
|
|
73
|
+
url: BrowserAutomationHttpUrlSchema.optional(),
|
|
74
|
+
/**
|
|
75
|
+
* "split-right" opens the tab in its own pane to the right of whatever
|
|
76
|
+
* pane currently has focus, instead of joining that pane's tab strip.
|
|
77
|
+
* Used by preview_start so the preview tab is always visible alongside
|
|
78
|
+
* the pane the user was already looking at.
|
|
79
|
+
*/
|
|
80
|
+
layout: z.enum(["default", "split-right"]).optional(),
|
|
81
|
+
/**
|
|
82
|
+
* Sent by preview_start when the tab is the designated preview tab for
|
|
83
|
+
* a dev server, so the app creates it with preview-tab identity (icon,
|
|
84
|
+
* lifecycle status) instead of a generic browser tab. Absent for plain
|
|
85
|
+
* browser_new_tab calls and from daemons older than this field.
|
|
86
|
+
*/
|
|
87
|
+
preview: z
|
|
88
|
+
.object({
|
|
89
|
+
serverId: z.string().min(1),
|
|
90
|
+
serverName: z.string().min(1),
|
|
91
|
+
cwd: z.string().min(1),
|
|
92
|
+
})
|
|
93
|
+
.optional(),
|
|
94
|
+
})
|
|
95
|
+
.strict()
|
|
96
|
+
.default({}),
|
|
97
|
+
});
|
|
98
|
+
export const BrowserAutomationSnapshotCommandSchema = z.object({
|
|
99
|
+
command: z.literal("snapshot"),
|
|
100
|
+
args: BrowserAutomationTabTargetSchema,
|
|
101
|
+
});
|
|
102
|
+
export const BrowserAutomationClickCommandSchema = z.object({
|
|
103
|
+
command: z.literal("click"),
|
|
104
|
+
args: BrowserAutomationTabTargetSchema.extend({
|
|
105
|
+
ref: BrowserAutomationRefSchema,
|
|
106
|
+
button: BrowserAutomationMouseButtonSchema.default("left"),
|
|
107
|
+
doubleClick: z.boolean().default(false),
|
|
108
|
+
modifiers: z.array(BrowserAutomationInputModifierSchema).default([]),
|
|
109
|
+
}),
|
|
110
|
+
});
|
|
111
|
+
export const BrowserAutomationFillCommandSchema = z.object({
|
|
112
|
+
command: z.literal("fill"),
|
|
113
|
+
args: BrowserAutomationTabTargetSchema.extend({
|
|
114
|
+
ref: BrowserAutomationRefSchema,
|
|
115
|
+
value: z.string(),
|
|
116
|
+
}),
|
|
117
|
+
});
|
|
118
|
+
export const BrowserAutomationWaitCommandSchema = z.object({
|
|
119
|
+
command: z.literal("wait"),
|
|
120
|
+
args: BrowserAutomationTabTargetSchema.extend({
|
|
121
|
+
text: z.string().min(1).optional(),
|
|
122
|
+
url: z.string().min(1).optional(),
|
|
123
|
+
timeoutMs: z.number().int().positive().max(30000).optional(),
|
|
124
|
+
}).refine((args) => Number(Boolean(args.text)) + Number(Boolean(args.url)) === 1, {
|
|
125
|
+
message: BROWSER_AUTOMATION_WAIT_CONDITION_MESSAGE,
|
|
126
|
+
}),
|
|
127
|
+
});
|
|
128
|
+
export const BrowserAutomationTypeCommandSchema = z.object({
|
|
129
|
+
command: z.literal("type"),
|
|
130
|
+
args: BrowserAutomationTabTargetSchema.extend({
|
|
131
|
+
ref: BrowserAutomationRefSchema.optional(),
|
|
132
|
+
text: z.string(),
|
|
133
|
+
}),
|
|
134
|
+
});
|
|
135
|
+
export const BrowserAutomationKeypressCommandSchema = z.object({
|
|
136
|
+
command: z.literal("keypress"),
|
|
137
|
+
args: BrowserAutomationTabTargetSchema.extend({
|
|
138
|
+
ref: BrowserAutomationRefSchema.optional(),
|
|
139
|
+
key: z.string().min(1),
|
|
140
|
+
}),
|
|
141
|
+
});
|
|
142
|
+
export const BrowserAutomationNavigateCommandSchema = z.object({
|
|
143
|
+
command: z.literal("navigate"),
|
|
144
|
+
args: BrowserAutomationTabTargetSchema.extend({
|
|
145
|
+
url: BrowserAutomationHttpUrlSchema,
|
|
146
|
+
}),
|
|
147
|
+
});
|
|
148
|
+
export const BrowserAutomationBackCommandSchema = z.object({
|
|
149
|
+
command: z.literal("back"),
|
|
150
|
+
args: BrowserAutomationTabTargetSchema,
|
|
151
|
+
});
|
|
152
|
+
export const BrowserAutomationForwardCommandSchema = z.object({
|
|
153
|
+
command: z.literal("forward"),
|
|
154
|
+
args: BrowserAutomationTabTargetSchema,
|
|
155
|
+
});
|
|
156
|
+
export const BrowserAutomationReloadCommandSchema = z.object({
|
|
157
|
+
command: z.literal("reload"),
|
|
158
|
+
args: BrowserAutomationTabTargetSchema,
|
|
159
|
+
});
|
|
160
|
+
export const BrowserAutomationScreenshotCommandSchema = z.object({
|
|
161
|
+
command: z.literal("screenshot"),
|
|
162
|
+
args: BrowserAutomationTabTargetSchema.extend({
|
|
163
|
+
fullPage: z.boolean().default(false),
|
|
164
|
+
}),
|
|
165
|
+
});
|
|
166
|
+
export const BrowserAutomationUploadCommandSchema = z.object({
|
|
167
|
+
command: z.literal("upload"),
|
|
168
|
+
args: BrowserAutomationTabTargetSchema.extend({
|
|
169
|
+
ref: BrowserAutomationRefSchema,
|
|
170
|
+
filePaths: z.array(z.string().min(1)).min(1),
|
|
171
|
+
}),
|
|
172
|
+
});
|
|
173
|
+
export const BrowserAutomationSelectCommandSchema = z.object({
|
|
174
|
+
command: z.literal("select"),
|
|
175
|
+
args: BrowserAutomationTabTargetSchema.extend({
|
|
176
|
+
ref: BrowserAutomationRefSchema,
|
|
177
|
+
value: z.string(),
|
|
178
|
+
}),
|
|
179
|
+
});
|
|
180
|
+
export const BrowserAutomationHoverCommandSchema = z.object({
|
|
181
|
+
command: z.literal("hover"),
|
|
182
|
+
args: BrowserAutomationTabTargetSchema.extend({
|
|
183
|
+
ref: BrowserAutomationRefSchema,
|
|
184
|
+
}),
|
|
185
|
+
});
|
|
186
|
+
export const BrowserAutomationDragCommandSchema = z.object({
|
|
187
|
+
command: z.literal("drag"),
|
|
188
|
+
args: BrowserAutomationTabTargetSchema.extend({
|
|
189
|
+
sourceRef: BrowserAutomationRefSchema,
|
|
190
|
+
targetRef: BrowserAutomationRefSchema,
|
|
191
|
+
}),
|
|
192
|
+
});
|
|
193
|
+
export const BrowserAutomationLogsCommandSchema = z.object({
|
|
194
|
+
command: z.literal("logs"),
|
|
195
|
+
args: BrowserAutomationTabTargetSchema.extend({
|
|
196
|
+
maxEntries: z.number().int().positive().max(200).default(50),
|
|
197
|
+
}),
|
|
198
|
+
});
|
|
199
|
+
export const BrowserAutomationEvaluateCommandSchema = z.object({
|
|
200
|
+
command: z.literal("evaluate"),
|
|
201
|
+
args: BrowserAutomationTabTargetSchema.extend({
|
|
202
|
+
function: z.string().min(1),
|
|
203
|
+
ref: BrowserAutomationRefSchema.optional(),
|
|
204
|
+
}),
|
|
205
|
+
});
|
|
206
|
+
export const BrowserAutomationInspectCommandSchema = z.object({
|
|
207
|
+
command: z.literal("inspect"),
|
|
208
|
+
args: BrowserAutomationTabTargetSchema.extend({
|
|
209
|
+
selector: z.string().min(1).optional(),
|
|
210
|
+
ref: BrowserAutomationRefSchema.optional(),
|
|
211
|
+
styles: z.array(z.string().min(1)).max(50).optional(),
|
|
212
|
+
}).refine((args) => Number(Boolean(args.selector)) + Number(Boolean(args.ref)) === 1, {
|
|
213
|
+
message: BROWSER_AUTOMATION_INSPECT_TARGET_MESSAGE,
|
|
214
|
+
}),
|
|
215
|
+
});
|
|
216
|
+
export const BrowserAutomationNetworkCommandSchema = z.object({
|
|
217
|
+
command: z.literal("network"),
|
|
218
|
+
args: BrowserAutomationTabTargetSchema.extend({
|
|
219
|
+
filter: z.enum(["all", "failed"]).default("all"),
|
|
220
|
+
/** When set, fetch the response body for this captured request instead of listing. */
|
|
221
|
+
requestId: z.string().min(1).optional(),
|
|
222
|
+
}),
|
|
223
|
+
});
|
|
224
|
+
export const BrowserAutomationScrollCommandSchema = z.object({
|
|
225
|
+
command: z.literal("scroll"),
|
|
226
|
+
args: BrowserAutomationTabTargetSchema.extend({
|
|
227
|
+
ref: BrowserAutomationRefSchema.optional(),
|
|
228
|
+
deltaX: z.number(),
|
|
229
|
+
deltaY: z.number(),
|
|
230
|
+
}),
|
|
231
|
+
});
|
|
232
|
+
export const BrowserAutomationResizeCommandSchema = z.object({
|
|
233
|
+
command: z.literal("resize"),
|
|
234
|
+
args: BrowserAutomationTabTargetSchema.extend({
|
|
235
|
+
width: z.number().int().positive(),
|
|
236
|
+
height: z.number().int().positive(),
|
|
237
|
+
}),
|
|
238
|
+
});
|
|
239
|
+
export const BrowserAutomationCloseTabCommandSchema = z.object({
|
|
240
|
+
command: z.literal("close_tab"),
|
|
241
|
+
args: BrowserAutomationTabTargetSchema,
|
|
242
|
+
});
|
|
243
|
+
export const BrowserAutomationCommandSchema = z.discriminatedUnion("command", [
|
|
244
|
+
BrowserAutomationListTabsCommandSchema,
|
|
245
|
+
BrowserAutomationNewTabCommandSchema,
|
|
246
|
+
BrowserAutomationSnapshotCommandSchema,
|
|
247
|
+
BrowserAutomationClickCommandSchema,
|
|
248
|
+
BrowserAutomationFillCommandSchema,
|
|
249
|
+
BrowserAutomationWaitCommandSchema,
|
|
250
|
+
BrowserAutomationTypeCommandSchema,
|
|
251
|
+
BrowserAutomationKeypressCommandSchema,
|
|
252
|
+
BrowserAutomationNavigateCommandSchema,
|
|
253
|
+
BrowserAutomationBackCommandSchema,
|
|
254
|
+
BrowserAutomationForwardCommandSchema,
|
|
255
|
+
BrowserAutomationReloadCommandSchema,
|
|
256
|
+
BrowserAutomationScreenshotCommandSchema,
|
|
257
|
+
BrowserAutomationUploadCommandSchema,
|
|
258
|
+
BrowserAutomationSelectCommandSchema,
|
|
259
|
+
BrowserAutomationHoverCommandSchema,
|
|
260
|
+
BrowserAutomationDragCommandSchema,
|
|
261
|
+
BrowserAutomationLogsCommandSchema,
|
|
262
|
+
BrowserAutomationEvaluateCommandSchema,
|
|
263
|
+
BrowserAutomationInspectCommandSchema,
|
|
264
|
+
BrowserAutomationNetworkCommandSchema,
|
|
265
|
+
BrowserAutomationScrollCommandSchema,
|
|
266
|
+
BrowserAutomationResizeCommandSchema,
|
|
267
|
+
BrowserAutomationCloseTabCommandSchema,
|
|
268
|
+
]);
|
|
269
|
+
export const BrowserAutomationTabInfoSchema = z.object({
|
|
270
|
+
browserId: BrowserAutomationBrowserIdSchema,
|
|
271
|
+
workspaceId: z.string().min(1).optional(),
|
|
272
|
+
url: z.string(),
|
|
273
|
+
title: z.string(),
|
|
274
|
+
isActive: z.boolean().default(false),
|
|
275
|
+
isLoading: z.boolean().default(false),
|
|
276
|
+
canGoBack: z.boolean().optional(),
|
|
277
|
+
canGoForward: z.boolean().optional(),
|
|
278
|
+
});
|
|
279
|
+
export const BrowserAutomationListTabsResultSchema = z.object({
|
|
280
|
+
command: z.literal("list_tabs"),
|
|
281
|
+
tabs: z.array(BrowserAutomationTabInfoSchema),
|
|
282
|
+
});
|
|
283
|
+
export const BrowserAutomationNewTabResultSchema = z.object({
|
|
284
|
+
command: z.literal("new_tab"),
|
|
285
|
+
browserId: BrowserAutomationBrowserIdSchema,
|
|
286
|
+
workspaceId: z.string().min(1),
|
|
287
|
+
url: z.string().min(1),
|
|
288
|
+
});
|
|
289
|
+
export const BrowserAutomationSnapshotStatsSchema = z
|
|
290
|
+
.object({
|
|
291
|
+
nodeCount: z.number().int().nonnegative(),
|
|
292
|
+
refCount: z.number().int().nonnegative(),
|
|
293
|
+
textLength: z.number().int().nonnegative(),
|
|
294
|
+
iframeCount: z.number().int().nonnegative().optional(),
|
|
295
|
+
maxDepth: z.number().int().nonnegative().optional(),
|
|
296
|
+
})
|
|
297
|
+
.strict();
|
|
298
|
+
export const BrowserAutomationSnapshotResultSchema = z.object({
|
|
299
|
+
command: z.literal("snapshot"),
|
|
300
|
+
browserId: BrowserAutomationBrowserIdSchema,
|
|
301
|
+
workspaceId: z.string().min(1).optional(),
|
|
302
|
+
url: z.string(),
|
|
303
|
+
title: z.string(),
|
|
304
|
+
format: z.literal("aria-yaml"),
|
|
305
|
+
snapshot: z.string(),
|
|
306
|
+
truncated: z.boolean(),
|
|
307
|
+
stats: BrowserAutomationSnapshotStatsSchema,
|
|
308
|
+
});
|
|
309
|
+
export const BrowserAutomationClickResultSchema = z.object({
|
|
310
|
+
command: z.literal("click"),
|
|
311
|
+
browserId: BrowserAutomationBrowserIdSchema,
|
|
312
|
+
ref: BrowserAutomationRefSchema,
|
|
313
|
+
x: z.number().optional(),
|
|
314
|
+
y: z.number().optional(),
|
|
315
|
+
});
|
|
316
|
+
export const BrowserAutomationFillResultSchema = z.object({
|
|
317
|
+
command: z.literal("fill"),
|
|
318
|
+
browserId: BrowserAutomationBrowserIdSchema,
|
|
319
|
+
ref: BrowserAutomationRefSchema,
|
|
320
|
+
});
|
|
321
|
+
export const BrowserAutomationWaitResultSchema = z.object({
|
|
322
|
+
command: z.literal("wait"),
|
|
323
|
+
browserId: BrowserAutomationBrowserIdSchema,
|
|
324
|
+
matched: z.enum(["text", "url"]),
|
|
325
|
+
});
|
|
326
|
+
export const BrowserAutomationTypeResultSchema = z.object({
|
|
327
|
+
command: z.literal("type"),
|
|
328
|
+
browserId: BrowserAutomationBrowserIdSchema,
|
|
329
|
+
ref: BrowserAutomationRefSchema.optional(),
|
|
330
|
+
x: z.number().optional(),
|
|
331
|
+
y: z.number().optional(),
|
|
332
|
+
});
|
|
333
|
+
export const BrowserAutomationKeypressResultSchema = z.object({
|
|
334
|
+
command: z.literal("keypress"),
|
|
335
|
+
browserId: BrowserAutomationBrowserIdSchema,
|
|
336
|
+
key: z.string().min(1),
|
|
337
|
+
ref: BrowserAutomationRefSchema.optional(),
|
|
338
|
+
x: z.number().optional(),
|
|
339
|
+
y: z.number().optional(),
|
|
340
|
+
});
|
|
341
|
+
export const BrowserAutomationNavigateResultSchema = z.object({
|
|
342
|
+
command: z.literal("navigate"),
|
|
343
|
+
browserId: BrowserAutomationBrowserIdSchema,
|
|
344
|
+
url: z.string().min(1),
|
|
345
|
+
});
|
|
346
|
+
export const BrowserAutomationBackResultSchema = z.object({
|
|
347
|
+
command: z.literal("back"),
|
|
348
|
+
browserId: BrowserAutomationBrowserIdSchema,
|
|
349
|
+
});
|
|
350
|
+
export const BrowserAutomationForwardResultSchema = z.object({
|
|
351
|
+
command: z.literal("forward"),
|
|
352
|
+
browserId: BrowserAutomationBrowserIdSchema,
|
|
353
|
+
});
|
|
354
|
+
export const BrowserAutomationReloadResultSchema = z.object({
|
|
355
|
+
command: z.literal("reload"),
|
|
356
|
+
browserId: BrowserAutomationBrowserIdSchema,
|
|
357
|
+
});
|
|
358
|
+
export const BrowserAutomationScreenshotResultSchema = z.object({
|
|
359
|
+
command: z.literal("screenshot"),
|
|
360
|
+
browserId: BrowserAutomationBrowserIdSchema,
|
|
361
|
+
mimeType: z.literal("image/png"),
|
|
362
|
+
dataBase64: z.string().min(1),
|
|
363
|
+
width: z.number().int().nonnegative(),
|
|
364
|
+
height: z.number().int().nonnegative(),
|
|
365
|
+
});
|
|
366
|
+
export const BrowserAutomationUploadResultSchema = z.object({
|
|
367
|
+
command: z.literal("upload"),
|
|
368
|
+
browserId: BrowserAutomationBrowserIdSchema,
|
|
369
|
+
ref: BrowserAutomationRefSchema,
|
|
370
|
+
filePaths: z.array(z.string().min(1)).min(1),
|
|
371
|
+
});
|
|
372
|
+
export const BrowserAutomationSelectResultSchema = z.object({
|
|
373
|
+
command: z.literal("select"),
|
|
374
|
+
browserId: BrowserAutomationBrowserIdSchema,
|
|
375
|
+
ref: BrowserAutomationRefSchema,
|
|
376
|
+
value: z.string(),
|
|
377
|
+
});
|
|
378
|
+
export const BrowserAutomationHoverResultSchema = z.object({
|
|
379
|
+
command: z.literal("hover"),
|
|
380
|
+
browserId: BrowserAutomationBrowserIdSchema,
|
|
381
|
+
ref: BrowserAutomationRefSchema,
|
|
382
|
+
x: z.number().optional(),
|
|
383
|
+
y: z.number().optional(),
|
|
384
|
+
});
|
|
385
|
+
export const BrowserAutomationDragResultSchema = z.object({
|
|
386
|
+
command: z.literal("drag"),
|
|
387
|
+
browserId: BrowserAutomationBrowserIdSchema,
|
|
388
|
+
sourceRef: BrowserAutomationRefSchema,
|
|
389
|
+
targetRef: BrowserAutomationRefSchema,
|
|
390
|
+
sourceX: z.number().optional(),
|
|
391
|
+
sourceY: z.number().optional(),
|
|
392
|
+
targetX: z.number().optional(),
|
|
393
|
+
targetY: z.number().optional(),
|
|
394
|
+
});
|
|
395
|
+
export const BrowserAutomationConsoleLogEntrySchema = z.object({
|
|
396
|
+
level: z.string(),
|
|
397
|
+
message: z.string(),
|
|
398
|
+
source: z.string().optional(),
|
|
399
|
+
line: z.number().int().optional(),
|
|
400
|
+
timestamp: z.number(),
|
|
401
|
+
});
|
|
402
|
+
export const BrowserAutomationNetworkLogEntrySchema = z.object({
|
|
403
|
+
url: z.string(),
|
|
404
|
+
method: z.string().optional(),
|
|
405
|
+
status: z.number().int().optional(),
|
|
406
|
+
type: z.string().optional(),
|
|
407
|
+
startTime: z.number(),
|
|
408
|
+
duration: z.number(),
|
|
409
|
+
transferSize: z.number().optional(),
|
|
410
|
+
});
|
|
411
|
+
export const BrowserAutomationLogsResultSchema = z.object({
|
|
412
|
+
command: z.literal("logs"),
|
|
413
|
+
browserId: BrowserAutomationBrowserIdSchema,
|
|
414
|
+
console: z.array(BrowserAutomationConsoleLogEntrySchema),
|
|
415
|
+
network: z.array(BrowserAutomationNetworkLogEntrySchema),
|
|
416
|
+
});
|
|
417
|
+
export const BrowserAutomationEvaluateResultSchema = z.object({
|
|
418
|
+
command: z.literal("evaluate"),
|
|
419
|
+
browserId: BrowserAutomationBrowserIdSchema,
|
|
420
|
+
resultJson: z.string(),
|
|
421
|
+
truncated: z.boolean(),
|
|
422
|
+
});
|
|
423
|
+
export const BrowserAutomationInspectResultSchema = z.object({
|
|
424
|
+
command: z.literal("inspect"),
|
|
425
|
+
browserId: BrowserAutomationBrowserIdSchema,
|
|
426
|
+
selector: z.string().optional(),
|
|
427
|
+
ref: BrowserAutomationRefSchema.optional(),
|
|
428
|
+
/** How many elements matched the selector; the first match is inspected. */
|
|
429
|
+
matchCount: z.number().int().nonnegative(),
|
|
430
|
+
tagName: z.string(),
|
|
431
|
+
id: z.string(),
|
|
432
|
+
className: z.string(),
|
|
433
|
+
text: z.string(),
|
|
434
|
+
box: z.object({
|
|
435
|
+
x: z.number(),
|
|
436
|
+
y: z.number(),
|
|
437
|
+
width: z.number(),
|
|
438
|
+
height: z.number(),
|
|
439
|
+
}),
|
|
440
|
+
styles: z.record(z.string(), z.string()),
|
|
441
|
+
});
|
|
442
|
+
export const BrowserAutomationNetworkRequestEntrySchema = z.object({
|
|
443
|
+
requestId: z.string().min(1),
|
|
444
|
+
url: z.string(),
|
|
445
|
+
method: z.string(),
|
|
446
|
+
resourceType: z.string().optional(),
|
|
447
|
+
status: z.number().int().optional(),
|
|
448
|
+
statusText: z.string().optional(),
|
|
449
|
+
mimeType: z.string().optional(),
|
|
450
|
+
encodedDataLength: z.number().optional(),
|
|
451
|
+
/** CDP error text when the request failed at the network layer. */
|
|
452
|
+
failed: z.string().optional(),
|
|
453
|
+
finished: z.boolean().default(false),
|
|
454
|
+
});
|
|
455
|
+
export const BrowserAutomationNetworkResultSchema = z.object({
|
|
456
|
+
command: z.literal("network"),
|
|
457
|
+
browserId: BrowserAutomationBrowserIdSchema,
|
|
458
|
+
/** Present when listing captured requests (no requestId in args). */
|
|
459
|
+
requests: z.array(BrowserAutomationNetworkRequestEntrySchema).optional(),
|
|
460
|
+
/** Present when a specific requestId's body was fetched. */
|
|
461
|
+
body: z
|
|
462
|
+
.object({
|
|
463
|
+
requestId: z.string().min(1),
|
|
464
|
+
body: z.string(),
|
|
465
|
+
base64Encoded: z.boolean().default(false),
|
|
466
|
+
truncated: z.boolean().default(false),
|
|
467
|
+
})
|
|
468
|
+
.optional(),
|
|
469
|
+
});
|
|
470
|
+
export const BrowserAutomationScrollResultSchema = z.object({
|
|
471
|
+
command: z.literal("scroll"),
|
|
472
|
+
browserId: BrowserAutomationBrowserIdSchema,
|
|
473
|
+
ref: BrowserAutomationRefSchema.optional(),
|
|
474
|
+
deltaX: z.number(),
|
|
475
|
+
deltaY: z.number(),
|
|
476
|
+
x: z.number().optional(),
|
|
477
|
+
y: z.number().optional(),
|
|
478
|
+
});
|
|
479
|
+
export const BrowserAutomationResizeResultSchema = z.object({
|
|
480
|
+
command: z.literal("resize"),
|
|
481
|
+
browserId: BrowserAutomationBrowserIdSchema,
|
|
482
|
+
width: z.number().int().positive(),
|
|
483
|
+
height: z.number().int().positive(),
|
|
484
|
+
});
|
|
485
|
+
export const BrowserAutomationCloseTabResultSchema = z.object({
|
|
486
|
+
command: z.literal("close_tab"),
|
|
487
|
+
browserId: BrowserAutomationBrowserIdSchema,
|
|
488
|
+
});
|
|
489
|
+
export const BrowserAutomationResultSchema = z.discriminatedUnion("command", [
|
|
490
|
+
BrowserAutomationListTabsResultSchema,
|
|
491
|
+
BrowserAutomationNewTabResultSchema,
|
|
492
|
+
BrowserAutomationSnapshotResultSchema,
|
|
493
|
+
BrowserAutomationClickResultSchema,
|
|
494
|
+
BrowserAutomationFillResultSchema,
|
|
495
|
+
BrowserAutomationWaitResultSchema,
|
|
496
|
+
BrowserAutomationTypeResultSchema,
|
|
497
|
+
BrowserAutomationKeypressResultSchema,
|
|
498
|
+
BrowserAutomationNavigateResultSchema,
|
|
499
|
+
BrowserAutomationBackResultSchema,
|
|
500
|
+
BrowserAutomationForwardResultSchema,
|
|
501
|
+
BrowserAutomationReloadResultSchema,
|
|
502
|
+
BrowserAutomationScreenshotResultSchema,
|
|
503
|
+
BrowserAutomationUploadResultSchema,
|
|
504
|
+
BrowserAutomationSelectResultSchema,
|
|
505
|
+
BrowserAutomationHoverResultSchema,
|
|
506
|
+
BrowserAutomationDragResultSchema,
|
|
507
|
+
BrowserAutomationLogsResultSchema,
|
|
508
|
+
BrowserAutomationEvaluateResultSchema,
|
|
509
|
+
BrowserAutomationInspectResultSchema,
|
|
510
|
+
BrowserAutomationNetworkResultSchema,
|
|
511
|
+
BrowserAutomationScrollResultSchema,
|
|
512
|
+
BrowserAutomationResizeResultSchema,
|
|
513
|
+
BrowserAutomationCloseTabResultSchema,
|
|
514
|
+
]);
|
|
515
|
+
export const BrowserAutomationErrorSchema = z.object({
|
|
516
|
+
code: BrowserAutomationErrorCodeSchema,
|
|
517
|
+
message: z.string().min(1),
|
|
518
|
+
retryable: z.boolean().default(false),
|
|
519
|
+
});
|
|
520
|
+
export const BrowserAutomationDialogEventSchema = z.object({
|
|
521
|
+
type: z.enum(["alert", "confirm", "prompt", "beforeunload"]),
|
|
522
|
+
message: z.string(),
|
|
523
|
+
defaultValue: z.string().optional(),
|
|
524
|
+
action: z.enum(["accepted", "dismissed"]),
|
|
525
|
+
promptText: z.string().optional(),
|
|
526
|
+
timestamp: z.number(),
|
|
527
|
+
});
|
|
528
|
+
export const BrowserAutomationExecuteRequestSchema = z
|
|
529
|
+
.object({
|
|
530
|
+
type: z.literal("browser.automation.execute.request"),
|
|
531
|
+
requestId: z.string().min(1),
|
|
532
|
+
agentId: z.string().min(1).optional(),
|
|
533
|
+
cwd: z.string().min(1).optional(),
|
|
534
|
+
workspaceId: z.string().min(1).optional(),
|
|
535
|
+
command: BrowserAutomationCommandSchema,
|
|
536
|
+
})
|
|
537
|
+
.strict();
|
|
538
|
+
export const BrowserAutomationExecuteResponseSchema = z.object({
|
|
539
|
+
type: z.literal("browser.automation.execute.response"),
|
|
540
|
+
payload: z.discriminatedUnion("ok", [
|
|
541
|
+
z.object({
|
|
542
|
+
requestId: z.string().min(1),
|
|
543
|
+
ok: z.literal(true),
|
|
544
|
+
result: BrowserAutomationResultSchema,
|
|
545
|
+
dialogs: z.array(BrowserAutomationDialogEventSchema).optional(),
|
|
546
|
+
}),
|
|
547
|
+
z.object({
|
|
548
|
+
requestId: z.string().min(1),
|
|
549
|
+
ok: z.literal(false),
|
|
550
|
+
error: BrowserAutomationErrorSchema,
|
|
551
|
+
dialogs: z.array(BrowserAutomationDialogEventSchema).optional(),
|
|
552
|
+
}),
|
|
553
|
+
]),
|
|
554
|
+
});
|
|
555
|
+
//# sourceMappingURL=rpc-schemas.js.map
|