eoka-protocol 0.2.5

Protocol and tool catalog definitions for eoka browser automation
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct OpenArgs {
    pub url: String,
    pub headers: Option<serde_json::Value>,
    pub user_agent: Option<String>,
    #[serde(default)]
    pub bypass_csp: bool,
    pub inject_js: Option<String>,
    pub load_state: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct SnapshotArgs {
    #[serde(default)]
    pub interactive: bool,
    #[serde(default)]
    pub all: bool,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct ObserveArgs {
    #[schemars(
        description = "Filter: 'inputs' for form elements, 'buttons' for buttons and links, or 'all' for all observed elements."
    )]
    pub filter: Option<String>,
    #[schemars(description = "Maximum elements to return.")]
    pub max: Option<usize>,
    #[serde(default)]
    pub structured: bool,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct ScreenshotArgs {
    pub output: Option<String>,
    #[serde(default)]
    pub annotate: bool,
}

#[derive(Debug, Clone, Serialize, Deserialize, schemars::JsonSchema)]
pub struct EmulateArgs {
    #[serde(default = "default_viewport_width")]
    pub width: u32,
    #[serde(default = "default_viewport_height")]
    pub height: u32,
    #[serde(default = "default_device_pixel_ratio")]
    pub dpr: f64,
    #[serde(default)]
    pub desktop: bool,
    #[serde(default)]
    pub reset: bool,
}

impl Default for EmulateArgs {
    fn default() -> Self {
        Self {
            width: default_viewport_width(),
            height: default_viewport_height(),
            dpr: default_device_pixel_ratio(),
            desktop: false,
            reset: false,
        }
    }
}

#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct TextArgs {
    #[schemars(description = "Text substring to search for, matched case-insensitively.")]
    pub text: String,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct TargetArgs {
    #[schemars(
        description = "Target element. Supports index, snapshot refs like @e1, text:Submit, placeholder:Email, role:button, css:form button, id:my-btn, or plain text search."
    )]
    pub target: String,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct FillArgs {
    #[schemars(
        description = "Target input. Supports index, text:Email, placeholder:Enter code, css:input.search, id:email-field, or plain text search."
    )]
    pub target: String,
    #[schemars(description = "Text to type into the element.")]
    pub text: String,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct SelectArgs {
    #[schemars(description = "Target select element by index, text, CSS selector, id, or role.")]
    pub target: String,
    #[schemars(description = "Option value or visible text to select.")]
    pub value: String,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct KeyArgs {
    #[schemars(
        description = "Key to press, for example Enter, Tab, Escape, ArrowDown, or Backspace."
    )]
    pub key: String,
}

#[derive(Debug, Clone, Copy, Serialize, Deserialize, schemars::JsonSchema)]
#[serde(rename_all = "lowercase")]
pub enum MouseButton {
    Left,
    Middle,
    Right,
    Back,
    Forward,
}

#[derive(Debug, Clone, Serialize, Deserialize, schemars::JsonSchema)]
pub struct MouseButtonArgs {
    #[schemars(description = "Viewport horizontal coordinate in CSS pixels.")]
    pub x: f64,
    #[schemars(description = "Viewport vertical coordinate in CSS pixels.")]
    pub y: f64,
    #[schemars(description = "Mouse button to hold or release.")]
    pub button: MouseButton,
}

#[derive(Debug, Clone, Serialize, Deserialize, schemars::JsonSchema)]
pub struct MouseMoveArgs {
    #[schemars(description = "Viewport horizontal coordinate in CSS pixels.")]
    pub x: f64,
    #[schemars(description = "Viewport vertical coordinate in CSS pixels.")]
    pub y: f64,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct ScriptArgs {
    pub code: Option<String>,
    pub file: Option<String>,
    pub max_size: Option<usize>,
    #[serde(default)]
    pub no_await: bool,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct FrameEvalArgs {
    #[schemars(
        description = "CSS selector matching exactly one iframe/frame in the top document, or id:<frame-id> from frames for explicit/nested selection. Bare URLs and indices are not supported. Evaluation uses an isolated world, not page-owned JavaScript globals."
    )]
    pub frame: String,
    pub code: Option<String>,
    pub file: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct FetchArgs {
    pub url: String,
    pub method: Option<String>,
    pub headers: Option<serde_json::Value>,
    pub body: Option<String>,
    pub redirect: Option<String>,
    #[serde(default)]
    pub body_only: bool,
    #[schemars(
        description = "Raw text byte limit: default 8192, maximum 16777216; zero inspects headers only.",
        range(max = 16777216)
    )]
    pub max_body: Option<usize>,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct SetCookieArgs {
    pub name: String,
    pub value: String,
    pub domain: Option<String>,
    pub path: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct DeleteCookieArgs {
    pub name: String,
    pub domain: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct StorageArgs {
    pub key: Option<String>,
    #[serde(default)]
    pub session_storage: bool,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct SetStorageArgs {
    pub key: String,
    pub value: String,
    #[serde(default)]
    pub session_storage: bool,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct PathArgs {
    #[schemars(description = "File path.")]
    pub path: String,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct LoadStateArgs {
    pub path: String,
    #[serde(default)]
    pub no_navigate: bool,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct HeadersArgs {
    pub headers_json: String,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct ConsoleArgs {
    #[serde(default)]
    pub clear: bool,
    pub level: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct ClearFlagArgs {
    #[serde(default)]
    pub clear: bool,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct TabNewArgs {
    #[schemars(description = "Optional URL to navigate to. If omitted, opens a blank tab.")]
    pub url: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct TabIdArgs {
    #[schemars(description = "Tab ID from list_tabs.")]
    pub tab_id: String,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct CloneFromArgs {
    pub source: String,
    pub to: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct WaitArgs {
    pub ms: Option<u64>,
    pub text: Option<String>,
    pub url: Option<String>,
    pub load: Option<String>,
    pub timeout: Option<u64>,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct PathStringArgs {
    #[schemars(description = "Target path, for example /docs or /about.")]
    pub path: String,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct FakeCameraArgs {
    pub file: String,
    #[serde(default)]
    pub loop_video: bool,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct WasmReadArgs {
    pub addr: String,
    pub len: usize,
    pub memory: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct WasmWriteArgs {
    pub addr: String,
    pub hex: String,
    pub memory: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize, schemars::JsonSchema)]
pub struct WasmFindArgs {
    pub pattern: String,
    pub start: Option<String>,
    pub end: Option<String>,
    #[serde(default = "default_wasm_find_max")]
    pub max: usize,
    pub memory: Option<String>,
}

impl Default for WasmFindArgs {
    fn default() -> Self {
        Self {
            pattern: String::new(),
            start: None,
            end: None,
            max: default_wasm_find_max(),
            memory: None,
        }
    }
}

#[derive(Debug, Clone, Serialize, Deserialize, schemars::JsonSchema)]
pub struct InterceptAddArgs {
    pub url_pattern: String,
    pub capture: Option<String>,
    pub respond: Option<String>,
    #[serde(default = "default_intercept_status")]
    pub status: u16,
}

impl Default for InterceptAddArgs {
    fn default() -> Self {
        Self {
            url_pattern: String::new(),
            capture: None,
            respond: None,
            status: default_intercept_status(),
        }
    }
}

#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct IdArgs {
    pub id: String,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct ModeArgs {
    pub mode: String,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct DomainArgs {
    pub domain: String,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct CaptchaInjectArgs {
    pub token: String,
    #[serde(default = "default_captcha_type")]
    pub captcha_type: String,
    pub callback: Option<String>,
    pub click_after: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct NetworkRecordStartArgs {
    #[serde(default)]
    pub patterns: Vec<String>,
    #[serde(default)]
    pub no_bodies: bool,
    #[serde(default = "default_max_body_bytes")]
    pub max_body_bytes: usize,
    #[serde(default)]
    pub clear: bool,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct NetworkLogArgs {
    pub limit: Option<usize>,
    pub pattern: Option<String>,
    pub method: Option<String>,
    pub status: Option<u16>,
    pub since: Option<u64>,
    #[serde(default)]
    pub compact: bool,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct NetworkShowArgs {
    pub id: u64,
    #[serde(default)]
    pub body: bool,
    pub max_body: Option<usize>,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct NetworkWaitArgs {
    pub pattern: Option<String>,
    pub method: Option<String>,
    pub status: Option<u16>,
    pub timeout: Option<u64>,
    pub since: Option<u64>,
    #[serde(default)]
    pub include_existing: bool,
}

#[derive(Debug, Clone, Serialize, Deserialize, schemars::JsonSchema)]
pub struct NetworkExportArgs {
    pub path: String,
    #[serde(default = "default_network_export_format")]
    pub format: String,
    pub settle_ms: Option<u64>,
}

impl Default for NetworkExportArgs {
    fn default() -> Self {
        Self {
            path: String::new(),
            format: default_network_export_format(),
            settle_ms: None,
        }
    }
}

fn default_max_body_bytes() -> usize {
    10 * 1024 * 1024
}

fn default_network_export_format() -> String {
    "har".to_string()
}

fn default_viewport_width() -> u32 {
    390
}

fn default_viewport_height() -> u32 {
    844
}

fn default_device_pixel_ratio() -> f64 {
    2.0
}

fn default_wasm_find_max() -> usize {
    20
}

fn default_intercept_status() -> u16 {
    200
}

fn default_captcha_type() -> String {
    "auto".to_string()
}