agent-browser 0.3.0 → 0.3.2
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/bin/agent-browser +0 -0
- package/bin/agent-browser-darwin-arm64 +0 -0
- package/bin/agent-browser-darwin-x64 +0 -0
- package/bin/agent-browser-linux-arm64 +0 -0
- package/bin/agent-browser-linux-x64 +0 -0
- package/bin/agent-browser.cmd +35 -0
- package/dist/cli-light.d.ts +1 -1
- package/dist/cli-light.js +1 -1
- package/package.json +10 -4
- package/scripts/build-all-platforms.sh +68 -0
- package/scripts/copy-native.js +35 -0
- package/scripts/postinstall.js +113 -15
- package/.prettierrc +0 -7
- package/AGENTS.md +0 -26
- package/benchmark/benchmark.ts +0 -521
- package/benchmark/run.ts +0 -322
- package/cli/Cargo.lock +0 -114
- package/cli/Cargo.toml +0 -17
- package/cli/src/main.rs +0 -332
- package/cli/target/.rustc_info.json +0 -1
- package/cli/target/CACHEDIR.TAG +0 -3
- package/cli/target/release/.cargo-lock +0 -0
- package/cli/target/release/.fingerprint/agent-browser-5894536b887e2ce7/bin-agent-browser +0 -1
- package/cli/target/release/.fingerprint/agent-browser-5894536b887e2ce7/bin-agent-browser.json +0 -1
- package/cli/target/release/.fingerprint/agent-browser-5894536b887e2ce7/dep-bin-agent-browser +0 -0
- package/cli/target/release/.fingerprint/agent-browser-5894536b887e2ce7/invoked.timestamp +0 -1
- package/cli/target/release/.fingerprint/agent-browser-5894536b887e2ce7/output-bin-agent-browser +0 -2
- package/cli/target/release/.fingerprint/itoa-653b9192107a1caa/dep-lib-itoa +0 -0
- package/cli/target/release/.fingerprint/itoa-653b9192107a1caa/invoked.timestamp +0 -1
- package/cli/target/release/.fingerprint/itoa-653b9192107a1caa/lib-itoa +0 -1
- package/cli/target/release/.fingerprint/itoa-653b9192107a1caa/lib-itoa.json +0 -1
- package/cli/target/release/.fingerprint/libc-0303d277881093f4/build-script-build-script-build +0 -1
- package/cli/target/release/.fingerprint/libc-0303d277881093f4/build-script-build-script-build.json +0 -1
- package/cli/target/release/.fingerprint/libc-0303d277881093f4/dep-build-script-build-script-build +0 -0
- package/cli/target/release/.fingerprint/libc-0303d277881093f4/invoked.timestamp +0 -1
- package/cli/target/release/.fingerprint/libc-b8c0d8e35a1980d3/run-build-script-build-script-build +0 -1
- package/cli/target/release/.fingerprint/libc-b8c0d8e35a1980d3/run-build-script-build-script-build.json +0 -1
- package/cli/target/release/.fingerprint/libc-d843359d3dd4757b/dep-lib-libc +0 -0
- package/cli/target/release/.fingerprint/libc-d843359d3dd4757b/invoked.timestamp +0 -1
- package/cli/target/release/.fingerprint/libc-d843359d3dd4757b/lib-libc +0 -1
- package/cli/target/release/.fingerprint/libc-d843359d3dd4757b/lib-libc.json +0 -1
- package/cli/target/release/.fingerprint/memchr-dcaf8011940d18dd/dep-lib-memchr +0 -0
- package/cli/target/release/.fingerprint/memchr-dcaf8011940d18dd/invoked.timestamp +0 -1
- package/cli/target/release/.fingerprint/memchr-dcaf8011940d18dd/lib-memchr +0 -1
- package/cli/target/release/.fingerprint/memchr-dcaf8011940d18dd/lib-memchr.json +0 -1
- package/cli/target/release/.fingerprint/proc-macro2-291b57751730d5b3/build-script-build-script-build +0 -1
- package/cli/target/release/.fingerprint/proc-macro2-291b57751730d5b3/build-script-build-script-build.json +0 -1
- package/cli/target/release/.fingerprint/proc-macro2-291b57751730d5b3/dep-build-script-build-script-build +0 -0
- package/cli/target/release/.fingerprint/proc-macro2-291b57751730d5b3/invoked.timestamp +0 -1
- package/cli/target/release/.fingerprint/proc-macro2-a753b344a6b4aa98/dep-lib-proc_macro2 +0 -0
- package/cli/target/release/.fingerprint/proc-macro2-a753b344a6b4aa98/invoked.timestamp +0 -1
- package/cli/target/release/.fingerprint/proc-macro2-a753b344a6b4aa98/lib-proc_macro2 +0 -1
- package/cli/target/release/.fingerprint/proc-macro2-a753b344a6b4aa98/lib-proc_macro2.json +0 -1
- package/cli/target/release/.fingerprint/proc-macro2-fc2999f6676f03db/run-build-script-build-script-build +0 -1
- package/cli/target/release/.fingerprint/proc-macro2-fc2999f6676f03db/run-build-script-build-script-build.json +0 -1
- package/cli/target/release/.fingerprint/quote-352ae41707d371c9/run-build-script-build-script-build +0 -1
- package/cli/target/release/.fingerprint/quote-352ae41707d371c9/run-build-script-build-script-build.json +0 -1
- package/cli/target/release/.fingerprint/quote-7d13be3cbe4f9de4/build-script-build-script-build +0 -1
- package/cli/target/release/.fingerprint/quote-7d13be3cbe4f9de4/build-script-build-script-build.json +0 -1
- package/cli/target/release/.fingerprint/quote-7d13be3cbe4f9de4/dep-build-script-build-script-build +0 -0
- package/cli/target/release/.fingerprint/quote-7d13be3cbe4f9de4/invoked.timestamp +0 -1
- package/cli/target/release/.fingerprint/quote-833e6725e0f7d298/dep-lib-quote +0 -0
- package/cli/target/release/.fingerprint/quote-833e6725e0f7d298/invoked.timestamp +0 -1
- package/cli/target/release/.fingerprint/quote-833e6725e0f7d298/lib-quote +0 -1
- package/cli/target/release/.fingerprint/quote-833e6725e0f7d298/lib-quote.json +0 -1
- package/cli/target/release/.fingerprint/serde-b8c046c16de48f41/run-build-script-build-script-build +0 -1
- package/cli/target/release/.fingerprint/serde-b8c046c16de48f41/run-build-script-build-script-build.json +0 -1
- package/cli/target/release/.fingerprint/serde-d35d32ab52b82a81/build-script-build-script-build +0 -1
- package/cli/target/release/.fingerprint/serde-d35d32ab52b82a81/build-script-build-script-build.json +0 -1
- package/cli/target/release/.fingerprint/serde-d35d32ab52b82a81/dep-build-script-build-script-build +0 -0
- package/cli/target/release/.fingerprint/serde-d35d32ab52b82a81/invoked.timestamp +0 -1
- package/cli/target/release/.fingerprint/serde-d6fb44202dad3efd/dep-lib-serde +0 -0
- package/cli/target/release/.fingerprint/serde-d6fb44202dad3efd/invoked.timestamp +0 -1
- package/cli/target/release/.fingerprint/serde-d6fb44202dad3efd/lib-serde +0 -1
- package/cli/target/release/.fingerprint/serde-d6fb44202dad3efd/lib-serde.json +0 -1
- package/cli/target/release/.fingerprint/serde_core-0f7ba2581c8c0423/dep-lib-serde_core +0 -0
- package/cli/target/release/.fingerprint/serde_core-0f7ba2581c8c0423/invoked.timestamp +0 -1
- package/cli/target/release/.fingerprint/serde_core-0f7ba2581c8c0423/lib-serde_core +0 -1
- package/cli/target/release/.fingerprint/serde_core-0f7ba2581c8c0423/lib-serde_core.json +0 -1
- package/cli/target/release/.fingerprint/serde_core-74db491143173930/run-build-script-build-script-build +0 -1
- package/cli/target/release/.fingerprint/serde_core-74db491143173930/run-build-script-build-script-build.json +0 -1
- package/cli/target/release/.fingerprint/serde_core-f043ae3f4b601577/build-script-build-script-build +0 -1
- package/cli/target/release/.fingerprint/serde_core-f043ae3f4b601577/build-script-build-script-build.json +0 -1
- package/cli/target/release/.fingerprint/serde_core-f043ae3f4b601577/dep-build-script-build-script-build +0 -0
- package/cli/target/release/.fingerprint/serde_core-f043ae3f4b601577/invoked.timestamp +0 -1
- package/cli/target/release/.fingerprint/serde_derive-a5d13e0e658ceae3/dep-lib-serde_derive +0 -0
- package/cli/target/release/.fingerprint/serde_derive-a5d13e0e658ceae3/invoked.timestamp +0 -1
- package/cli/target/release/.fingerprint/serde_derive-a5d13e0e658ceae3/lib-serde_derive +0 -1
- package/cli/target/release/.fingerprint/serde_derive-a5d13e0e658ceae3/lib-serde_derive.json +0 -1
- package/cli/target/release/.fingerprint/serde_json-a8467019a959068f/run-build-script-build-script-build +0 -1
- package/cli/target/release/.fingerprint/serde_json-a8467019a959068f/run-build-script-build-script-build.json +0 -1
- package/cli/target/release/.fingerprint/serde_json-bfa3f43b57842d41/build-script-build-script-build +0 -1
- package/cli/target/release/.fingerprint/serde_json-bfa3f43b57842d41/build-script-build-script-build.json +0 -1
- package/cli/target/release/.fingerprint/serde_json-bfa3f43b57842d41/dep-build-script-build-script-build +0 -0
- package/cli/target/release/.fingerprint/serde_json-bfa3f43b57842d41/invoked.timestamp +0 -1
- package/cli/target/release/.fingerprint/serde_json-f61651a65bf0eb31/dep-lib-serde_json +0 -0
- package/cli/target/release/.fingerprint/serde_json-f61651a65bf0eb31/invoked.timestamp +0 -1
- package/cli/target/release/.fingerprint/serde_json-f61651a65bf0eb31/lib-serde_json +0 -1
- package/cli/target/release/.fingerprint/serde_json-f61651a65bf0eb31/lib-serde_json.json +0 -1
- package/cli/target/release/.fingerprint/syn-6f9a22f8c7f909b0/dep-lib-syn +0 -0
- package/cli/target/release/.fingerprint/syn-6f9a22f8c7f909b0/invoked.timestamp +0 -1
- package/cli/target/release/.fingerprint/syn-6f9a22f8c7f909b0/lib-syn +0 -1
- package/cli/target/release/.fingerprint/syn-6f9a22f8c7f909b0/lib-syn.json +0 -1
- package/cli/target/release/.fingerprint/unicode-ident-60c57228d30a23d0/dep-lib-unicode_ident +0 -0
- package/cli/target/release/.fingerprint/unicode-ident-60c57228d30a23d0/invoked.timestamp +0 -1
- package/cli/target/release/.fingerprint/unicode-ident-60c57228d30a23d0/lib-unicode_ident +0 -1
- package/cli/target/release/.fingerprint/unicode-ident-60c57228d30a23d0/lib-unicode_ident.json +0 -1
- package/cli/target/release/.fingerprint/zmij-60b0e0e9d7c08f71/run-build-script-build-script-build +0 -1
- package/cli/target/release/.fingerprint/zmij-60b0e0e9d7c08f71/run-build-script-build-script-build.json +0 -1
- package/cli/target/release/.fingerprint/zmij-9501bcbd6d8b933c/dep-lib-zmij +0 -0
- package/cli/target/release/.fingerprint/zmij-9501bcbd6d8b933c/invoked.timestamp +0 -1
- package/cli/target/release/.fingerprint/zmij-9501bcbd6d8b933c/lib-zmij +0 -1
- package/cli/target/release/.fingerprint/zmij-9501bcbd6d8b933c/lib-zmij.json +0 -1
- package/cli/target/release/.fingerprint/zmij-aa602f885104061e/build-script-build-script-build +0 -1
- package/cli/target/release/.fingerprint/zmij-aa602f885104061e/build-script-build-script-build.json +0 -1
- package/cli/target/release/.fingerprint/zmij-aa602f885104061e/dep-build-script-build-script-build +0 -0
- package/cli/target/release/.fingerprint/zmij-aa602f885104061e/invoked.timestamp +0 -1
- package/cli/target/release/agent-browser +0 -0
- package/cli/target/release/agent-browser.d +0 -1
- package/cli/target/release/build/libc-0303d277881093f4/build-script-build +0 -0
- package/cli/target/release/build/libc-0303d277881093f4/build_script_build-0303d277881093f4 +0 -0
- package/cli/target/release/build/libc-0303d277881093f4/build_script_build-0303d277881093f4.d +0 -5
- package/cli/target/release/build/libc-b8c0d8e35a1980d3/invoked.timestamp +0 -1
- package/cli/target/release/build/libc-b8c0d8e35a1980d3/output +0 -25
- package/cli/target/release/build/libc-b8c0d8e35a1980d3/root-output +0 -1
- package/cli/target/release/build/libc-b8c0d8e35a1980d3/stderr +0 -0
- package/cli/target/release/build/proc-macro2-291b57751730d5b3/build-script-build +0 -0
- package/cli/target/release/build/proc-macro2-291b57751730d5b3/build_script_build-291b57751730d5b3 +0 -0
- package/cli/target/release/build/proc-macro2-291b57751730d5b3/build_script_build-291b57751730d5b3.d +0 -5
- package/cli/target/release/build/proc-macro2-fc2999f6676f03db/invoked.timestamp +0 -1
- package/cli/target/release/build/proc-macro2-fc2999f6676f03db/output +0 -23
- package/cli/target/release/build/proc-macro2-fc2999f6676f03db/root-output +0 -1
- package/cli/target/release/build/proc-macro2-fc2999f6676f03db/stderr +0 -0
- package/cli/target/release/build/quote-352ae41707d371c9/invoked.timestamp +0 -1
- package/cli/target/release/build/quote-352ae41707d371c9/output +0 -2
- package/cli/target/release/build/quote-352ae41707d371c9/root-output +0 -1
- package/cli/target/release/build/quote-352ae41707d371c9/stderr +0 -0
- package/cli/target/release/build/quote-7d13be3cbe4f9de4/build-script-build +0 -0
- package/cli/target/release/build/quote-7d13be3cbe4f9de4/build_script_build-7d13be3cbe4f9de4 +0 -0
- package/cli/target/release/build/quote-7d13be3cbe4f9de4/build_script_build-7d13be3cbe4f9de4.d +0 -5
- package/cli/target/release/build/serde-b8c046c16de48f41/invoked.timestamp +0 -1
- package/cli/target/release/build/serde-b8c046c16de48f41/out/private.rs +0 -6
- package/cli/target/release/build/serde-b8c046c16de48f41/output +0 -13
- package/cli/target/release/build/serde-b8c046c16de48f41/root-output +0 -1
- package/cli/target/release/build/serde-b8c046c16de48f41/stderr +0 -0
- package/cli/target/release/build/serde-d35d32ab52b82a81/build-script-build +0 -0
- package/cli/target/release/build/serde-d35d32ab52b82a81/build_script_build-d35d32ab52b82a81 +0 -0
- package/cli/target/release/build/serde-d35d32ab52b82a81/build_script_build-d35d32ab52b82a81.d +0 -5
- package/cli/target/release/build/serde_core-74db491143173930/invoked.timestamp +0 -1
- package/cli/target/release/build/serde_core-74db491143173930/out/private.rs +0 -5
- package/cli/target/release/build/serde_core-74db491143173930/output +0 -11
- package/cli/target/release/build/serde_core-74db491143173930/root-output +0 -1
- package/cli/target/release/build/serde_core-74db491143173930/stderr +0 -0
- package/cli/target/release/build/serde_core-f043ae3f4b601577/build-script-build +0 -0
- package/cli/target/release/build/serde_core-f043ae3f4b601577/build_script_build-f043ae3f4b601577 +0 -0
- package/cli/target/release/build/serde_core-f043ae3f4b601577/build_script_build-f043ae3f4b601577.d +0 -5
- package/cli/target/release/build/serde_json-a8467019a959068f/invoked.timestamp +0 -1
- package/cli/target/release/build/serde_json-a8467019a959068f/output +0 -3
- package/cli/target/release/build/serde_json-a8467019a959068f/root-output +0 -1
- package/cli/target/release/build/serde_json-a8467019a959068f/stderr +0 -0
- package/cli/target/release/build/serde_json-bfa3f43b57842d41/build-script-build +0 -0
- package/cli/target/release/build/serde_json-bfa3f43b57842d41/build_script_build-bfa3f43b57842d41 +0 -0
- package/cli/target/release/build/serde_json-bfa3f43b57842d41/build_script_build-bfa3f43b57842d41.d +0 -5
- package/cli/target/release/build/zmij-60b0e0e9d7c08f71/invoked.timestamp +0 -1
- package/cli/target/release/build/zmij-60b0e0e9d7c08f71/output +0 -3
- package/cli/target/release/build/zmij-60b0e0e9d7c08f71/root-output +0 -1
- package/cli/target/release/build/zmij-60b0e0e9d7c08f71/stderr +0 -0
- package/cli/target/release/build/zmij-aa602f885104061e/build-script-build +0 -0
- package/cli/target/release/build/zmij-aa602f885104061e/build_script_build-aa602f885104061e +0 -0
- package/cli/target/release/build/zmij-aa602f885104061e/build_script_build-aa602f885104061e.d +0 -5
- package/cli/target/release/deps/agent_browser-5894536b887e2ce7 +0 -0
- package/cli/target/release/deps/agent_browser-5894536b887e2ce7.d +0 -5
- package/cli/target/release/deps/itoa-653b9192107a1caa.d +0 -8
- package/cli/target/release/deps/libc-d843359d3dd4757b.d +0 -45
- package/cli/target/release/deps/libitoa-653b9192107a1caa.rlib +0 -0
- package/cli/target/release/deps/libitoa-653b9192107a1caa.rmeta +0 -0
- package/cli/target/release/deps/liblibc-d843359d3dd4757b.rlib +0 -0
- package/cli/target/release/deps/liblibc-d843359d3dd4757b.rmeta +0 -0
- package/cli/target/release/deps/libmemchr-dcaf8011940d18dd.rlib +0 -0
- package/cli/target/release/deps/libmemchr-dcaf8011940d18dd.rmeta +0 -0
- package/cli/target/release/deps/libproc_macro2-a753b344a6b4aa98.rlib +0 -0
- package/cli/target/release/deps/libproc_macro2-a753b344a6b4aa98.rmeta +0 -0
- package/cli/target/release/deps/libquote-833e6725e0f7d298.rlib +0 -0
- package/cli/target/release/deps/libquote-833e6725e0f7d298.rmeta +0 -0
- package/cli/target/release/deps/libserde-d6fb44202dad3efd.rlib +0 -0
- package/cli/target/release/deps/libserde-d6fb44202dad3efd.rmeta +0 -0
- package/cli/target/release/deps/libserde_core-0f7ba2581c8c0423.rlib +0 -0
- package/cli/target/release/deps/libserde_core-0f7ba2581c8c0423.rmeta +0 -0
- package/cli/target/release/deps/libserde_derive-a5d13e0e658ceae3.dylib +0 -0
- package/cli/target/release/deps/libserde_json-f61651a65bf0eb31.rlib +0 -0
- package/cli/target/release/deps/libserde_json-f61651a65bf0eb31.rmeta +0 -0
- package/cli/target/release/deps/libsyn-6f9a22f8c7f909b0.rlib +0 -0
- package/cli/target/release/deps/libsyn-6f9a22f8c7f909b0.rmeta +0 -0
- package/cli/target/release/deps/libunicode_ident-60c57228d30a23d0.rlib +0 -0
- package/cli/target/release/deps/libunicode_ident-60c57228d30a23d0.rmeta +0 -0
- package/cli/target/release/deps/libzmij-9501bcbd6d8b933c.rlib +0 -0
- package/cli/target/release/deps/libzmij-9501bcbd6d8b933c.rmeta +0 -0
- package/cli/target/release/deps/memchr-dcaf8011940d18dd.d +0 -30
- package/cli/target/release/deps/proc_macro2-a753b344a6b4aa98.d +0 -17
- package/cli/target/release/deps/quote-833e6725e0f7d298.d +0 -13
- package/cli/target/release/deps/serde-d6fb44202dad3efd.d +0 -14
- package/cli/target/release/deps/serde_core-0f7ba2581c8c0423.d +0 -27
- package/cli/target/release/deps/serde_derive-a5d13e0e658ceae3.d +0 -34
- package/cli/target/release/deps/serde_json-f61651a65bf0eb31.d +0 -22
- package/cli/target/release/deps/syn-6f9a22f8c7f909b0.d +0 -49
- package/cli/target/release/deps/unicode_ident-60c57228d30a23d0.d +0 -8
- package/cli/target/release/deps/zmij-9501bcbd6d8b933c.d +0 -8
- package/src/actions.ts +0 -1670
- package/src/browser.test.ts +0 -157
- package/src/browser.ts +0 -686
- package/src/cli-light.ts +0 -457
- package/src/client.ts +0 -150
- package/src/daemon.ts +0 -187
- package/src/index.ts +0 -1185
- package/src/protocol.test.ts +0 -216
- package/src/protocol.ts +0 -852
- package/src/snapshot.ts +0 -380
- package/src/types.ts +0 -913
- package/tsconfig.json +0 -28
- package/vitest.config.ts +0 -9
package/src/protocol.ts
DELETED
|
@@ -1,852 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import type { Command, Response } from './types.js';
|
|
3
|
-
|
|
4
|
-
// Base schema for all commands
|
|
5
|
-
const baseCommandSchema = z.object({
|
|
6
|
-
id: z.string(),
|
|
7
|
-
action: z.string(),
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
// Individual action schemas
|
|
11
|
-
const launchSchema = baseCommandSchema.extend({
|
|
12
|
-
action: z.literal('launch'),
|
|
13
|
-
headless: z.boolean().optional(),
|
|
14
|
-
viewport: z
|
|
15
|
-
.object({
|
|
16
|
-
width: z.number().positive(),
|
|
17
|
-
height: z.number().positive(),
|
|
18
|
-
})
|
|
19
|
-
.optional(),
|
|
20
|
-
browser: z.enum(['chromium', 'firefox', 'webkit']).optional(),
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
const navigateSchema = baseCommandSchema.extend({
|
|
24
|
-
action: z.literal('navigate'),
|
|
25
|
-
url: z.string().min(1),
|
|
26
|
-
waitUntil: z.enum(['load', 'domcontentloaded', 'networkidle']).optional(),
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
const clickSchema = baseCommandSchema.extend({
|
|
30
|
-
action: z.literal('click'),
|
|
31
|
-
selector: z.string().min(1),
|
|
32
|
-
button: z.enum(['left', 'right', 'middle']).optional(),
|
|
33
|
-
clickCount: z.number().positive().optional(),
|
|
34
|
-
delay: z.number().nonnegative().optional(),
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
const typeSchema = baseCommandSchema.extend({
|
|
38
|
-
action: z.literal('type'),
|
|
39
|
-
selector: z.string().min(1),
|
|
40
|
-
text: z.string(),
|
|
41
|
-
delay: z.number().nonnegative().optional(),
|
|
42
|
-
clear: z.boolean().optional(),
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
const fillSchema = baseCommandSchema.extend({
|
|
46
|
-
action: z.literal('fill'),
|
|
47
|
-
selector: z.string().min(1),
|
|
48
|
-
value: z.string(),
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
const checkSchema = baseCommandSchema.extend({
|
|
52
|
-
action: z.literal('check'),
|
|
53
|
-
selector: z.string().min(1),
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
const uncheckSchema = baseCommandSchema.extend({
|
|
57
|
-
action: z.literal('uncheck'),
|
|
58
|
-
selector: z.string().min(1),
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
const uploadSchema = baseCommandSchema.extend({
|
|
62
|
-
action: z.literal('upload'),
|
|
63
|
-
selector: z.string().min(1),
|
|
64
|
-
files: z.union([z.string(), z.array(z.string())]),
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
const dblclickSchema = baseCommandSchema.extend({
|
|
68
|
-
action: z.literal('dblclick'),
|
|
69
|
-
selector: z.string().min(1),
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
const focusSchema = baseCommandSchema.extend({
|
|
73
|
-
action: z.literal('focus'),
|
|
74
|
-
selector: z.string().min(1),
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
const dragSchema = baseCommandSchema.extend({
|
|
78
|
-
action: z.literal('drag'),
|
|
79
|
-
source: z.string().min(1),
|
|
80
|
-
target: z.string().min(1),
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
const frameSchema = baseCommandSchema.extend({
|
|
84
|
-
action: z.literal('frame'),
|
|
85
|
-
selector: z.string().min(1).optional(),
|
|
86
|
-
name: z.string().optional(),
|
|
87
|
-
url: z.string().optional(),
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
const mainframeSchema = baseCommandSchema.extend({
|
|
91
|
-
action: z.literal('mainframe'),
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
const getByRoleSchema = baseCommandSchema.extend({
|
|
95
|
-
action: z.literal('getbyrole'),
|
|
96
|
-
role: z.string().min(1),
|
|
97
|
-
name: z.string().optional(),
|
|
98
|
-
subaction: z.enum(['click', 'fill', 'check', 'hover']),
|
|
99
|
-
value: z.string().optional(),
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
const getByTextSchema = baseCommandSchema.extend({
|
|
103
|
-
action: z.literal('getbytext'),
|
|
104
|
-
text: z.string().min(1),
|
|
105
|
-
exact: z.boolean().optional(),
|
|
106
|
-
subaction: z.enum(['click', 'hover']),
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
const getByLabelSchema = baseCommandSchema.extend({
|
|
110
|
-
action: z.literal('getbylabel'),
|
|
111
|
-
label: z.string().min(1),
|
|
112
|
-
subaction: z.enum(['click', 'fill', 'check']),
|
|
113
|
-
value: z.string().optional(),
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
const getByPlaceholderSchema = baseCommandSchema.extend({
|
|
117
|
-
action: z.literal('getbyplaceholder'),
|
|
118
|
-
placeholder: z.string().min(1),
|
|
119
|
-
subaction: z.enum(['click', 'fill']),
|
|
120
|
-
value: z.string().optional(),
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
const cookiesGetSchema = baseCommandSchema.extend({
|
|
124
|
-
action: z.literal('cookies_get'),
|
|
125
|
-
urls: z.array(z.string()).optional(),
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
const cookiesSetSchema = baseCommandSchema.extend({
|
|
129
|
-
action: z.literal('cookies_set'),
|
|
130
|
-
cookies: z.array(
|
|
131
|
-
z.object({
|
|
132
|
-
name: z.string(),
|
|
133
|
-
value: z.string(),
|
|
134
|
-
url: z.string().optional(),
|
|
135
|
-
domain: z.string().optional(),
|
|
136
|
-
path: z.string().optional(),
|
|
137
|
-
expires: z.number().optional(),
|
|
138
|
-
httpOnly: z.boolean().optional(),
|
|
139
|
-
secure: z.boolean().optional(),
|
|
140
|
-
sameSite: z.enum(['Strict', 'Lax', 'None']).optional(),
|
|
141
|
-
})
|
|
142
|
-
),
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
const cookiesClearSchema = baseCommandSchema.extend({
|
|
146
|
-
action: z.literal('cookies_clear'),
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
const storageGetSchema = baseCommandSchema.extend({
|
|
150
|
-
action: z.literal('storage_get'),
|
|
151
|
-
key: z.string().optional(),
|
|
152
|
-
type: z.enum(['local', 'session']),
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
const storageSetSchema = baseCommandSchema.extend({
|
|
156
|
-
action: z.literal('storage_set'),
|
|
157
|
-
key: z.string().min(1),
|
|
158
|
-
value: z.string(),
|
|
159
|
-
type: z.enum(['local', 'session']),
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
const storageClearSchema = baseCommandSchema.extend({
|
|
163
|
-
action: z.literal('storage_clear'),
|
|
164
|
-
type: z.enum(['local', 'session']),
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
const dialogSchema = baseCommandSchema.extend({
|
|
168
|
-
action: z.literal('dialog'),
|
|
169
|
-
response: z.enum(['accept', 'dismiss']),
|
|
170
|
-
promptText: z.string().optional(),
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
const pdfSchema = baseCommandSchema.extend({
|
|
174
|
-
action: z.literal('pdf'),
|
|
175
|
-
path: z.string().min(1),
|
|
176
|
-
format: z
|
|
177
|
-
.enum(['Letter', 'Legal', 'Tabloid', 'Ledger', 'A0', 'A1', 'A2', 'A3', 'A4', 'A5', 'A6'])
|
|
178
|
-
.optional(),
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
const routeSchema = baseCommandSchema.extend({
|
|
182
|
-
action: z.literal('route'),
|
|
183
|
-
url: z.string().min(1),
|
|
184
|
-
response: z
|
|
185
|
-
.object({
|
|
186
|
-
status: z.number().optional(),
|
|
187
|
-
body: z.string().optional(),
|
|
188
|
-
contentType: z.string().optional(),
|
|
189
|
-
headers: z.record(z.string()).optional(),
|
|
190
|
-
})
|
|
191
|
-
.optional(),
|
|
192
|
-
abort: z.boolean().optional(),
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
const unrouteSchema = baseCommandSchema.extend({
|
|
196
|
-
action: z.literal('unroute'),
|
|
197
|
-
url: z.string().optional(),
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
const requestsSchema = baseCommandSchema.extend({
|
|
201
|
-
action: z.literal('requests'),
|
|
202
|
-
filter: z.string().optional(),
|
|
203
|
-
clear: z.boolean().optional(),
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
const downloadSchema = baseCommandSchema.extend({
|
|
207
|
-
action: z.literal('download'),
|
|
208
|
-
selector: z.string().min(1),
|
|
209
|
-
path: z.string().min(1),
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
const geolocationSchema = baseCommandSchema.extend({
|
|
213
|
-
action: z.literal('geolocation'),
|
|
214
|
-
latitude: z.number(),
|
|
215
|
-
longitude: z.number(),
|
|
216
|
-
accuracy: z.number().optional(),
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
const permissionsSchema = baseCommandSchema.extend({
|
|
220
|
-
action: z.literal('permissions'),
|
|
221
|
-
permissions: z.array(z.string()),
|
|
222
|
-
grant: z.boolean(),
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
const viewportSchema = baseCommandSchema.extend({
|
|
226
|
-
action: z.literal('viewport'),
|
|
227
|
-
width: z.number().positive(),
|
|
228
|
-
height: z.number().positive(),
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
const userAgentSchema = baseCommandSchema.extend({
|
|
232
|
-
action: z.literal('useragent'),
|
|
233
|
-
userAgent: z.string().min(1),
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
const deviceSchema = baseCommandSchema.extend({
|
|
237
|
-
action: z.literal('device'),
|
|
238
|
-
device: z.string().min(1),
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
const backSchema = baseCommandSchema.extend({
|
|
242
|
-
action: z.literal('back'),
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
const forwardSchema = baseCommandSchema.extend({
|
|
246
|
-
action: z.literal('forward'),
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
const reloadSchema = baseCommandSchema.extend({
|
|
250
|
-
action: z.literal('reload'),
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
const urlSchema = baseCommandSchema.extend({
|
|
254
|
-
action: z.literal('url'),
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
const titleSchema = baseCommandSchema.extend({
|
|
258
|
-
action: z.literal('title'),
|
|
259
|
-
});
|
|
260
|
-
|
|
261
|
-
const getAttributeSchema = baseCommandSchema.extend({
|
|
262
|
-
action: z.literal('getattribute'),
|
|
263
|
-
selector: z.string().min(1),
|
|
264
|
-
attribute: z.string().min(1),
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
const getTextSchema = baseCommandSchema.extend({
|
|
268
|
-
action: z.literal('gettext'),
|
|
269
|
-
selector: z.string().min(1),
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
const isVisibleSchema = baseCommandSchema.extend({
|
|
273
|
-
action: z.literal('isvisible'),
|
|
274
|
-
selector: z.string().min(1),
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
const isEnabledSchema = baseCommandSchema.extend({
|
|
278
|
-
action: z.literal('isenabled'),
|
|
279
|
-
selector: z.string().min(1),
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
const isCheckedSchema = baseCommandSchema.extend({
|
|
283
|
-
action: z.literal('ischecked'),
|
|
284
|
-
selector: z.string().min(1),
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
const countSchema = baseCommandSchema.extend({
|
|
288
|
-
action: z.literal('count'),
|
|
289
|
-
selector: z.string().min(1),
|
|
290
|
-
});
|
|
291
|
-
|
|
292
|
-
const boundingBoxSchema = baseCommandSchema.extend({
|
|
293
|
-
action: z.literal('boundingbox'),
|
|
294
|
-
selector: z.string().min(1),
|
|
295
|
-
});
|
|
296
|
-
|
|
297
|
-
const videoStartSchema = baseCommandSchema.extend({
|
|
298
|
-
action: z.literal('video_start'),
|
|
299
|
-
path: z.string().min(1),
|
|
300
|
-
});
|
|
301
|
-
|
|
302
|
-
const videoStopSchema = baseCommandSchema.extend({
|
|
303
|
-
action: z.literal('video_stop'),
|
|
304
|
-
});
|
|
305
|
-
|
|
306
|
-
const traceStartSchema = baseCommandSchema.extend({
|
|
307
|
-
action: z.literal('trace_start'),
|
|
308
|
-
screenshots: z.boolean().optional(),
|
|
309
|
-
snapshots: z.boolean().optional(),
|
|
310
|
-
});
|
|
311
|
-
|
|
312
|
-
const traceStopSchema = baseCommandSchema.extend({
|
|
313
|
-
action: z.literal('trace_stop'),
|
|
314
|
-
path: z.string().min(1),
|
|
315
|
-
});
|
|
316
|
-
|
|
317
|
-
const harStartSchema = baseCommandSchema.extend({
|
|
318
|
-
action: z.literal('har_start'),
|
|
319
|
-
});
|
|
320
|
-
|
|
321
|
-
const harStopSchema = baseCommandSchema.extend({
|
|
322
|
-
action: z.literal('har_stop'),
|
|
323
|
-
path: z.string().min(1),
|
|
324
|
-
});
|
|
325
|
-
|
|
326
|
-
const stateSaveSchema = baseCommandSchema.extend({
|
|
327
|
-
action: z.literal('state_save'),
|
|
328
|
-
path: z.string().min(1),
|
|
329
|
-
});
|
|
330
|
-
|
|
331
|
-
const stateLoadSchema = baseCommandSchema.extend({
|
|
332
|
-
action: z.literal('state_load'),
|
|
333
|
-
path: z.string().min(1),
|
|
334
|
-
});
|
|
335
|
-
|
|
336
|
-
const consoleSchema = baseCommandSchema.extend({
|
|
337
|
-
action: z.literal('console'),
|
|
338
|
-
clear: z.boolean().optional(),
|
|
339
|
-
});
|
|
340
|
-
|
|
341
|
-
const errorsSchema = baseCommandSchema.extend({
|
|
342
|
-
action: z.literal('errors'),
|
|
343
|
-
clear: z.boolean().optional(),
|
|
344
|
-
});
|
|
345
|
-
|
|
346
|
-
const keyboardSchema = baseCommandSchema.extend({
|
|
347
|
-
action: z.literal('keyboard'),
|
|
348
|
-
keys: z.string().min(1),
|
|
349
|
-
});
|
|
350
|
-
|
|
351
|
-
const wheelSchema = baseCommandSchema.extend({
|
|
352
|
-
action: z.literal('wheel'),
|
|
353
|
-
deltaX: z.number().optional(),
|
|
354
|
-
deltaY: z.number().optional(),
|
|
355
|
-
selector: z.string().optional(),
|
|
356
|
-
});
|
|
357
|
-
|
|
358
|
-
const tapSchema = baseCommandSchema.extend({
|
|
359
|
-
action: z.literal('tap'),
|
|
360
|
-
selector: z.string().min(1),
|
|
361
|
-
});
|
|
362
|
-
|
|
363
|
-
const clipboardSchema = baseCommandSchema.extend({
|
|
364
|
-
action: z.literal('clipboard'),
|
|
365
|
-
operation: z.enum(['copy', 'paste', 'read']),
|
|
366
|
-
text: z.string().optional(),
|
|
367
|
-
});
|
|
368
|
-
|
|
369
|
-
const highlightSchema = baseCommandSchema.extend({
|
|
370
|
-
action: z.literal('highlight'),
|
|
371
|
-
selector: z.string().min(1),
|
|
372
|
-
});
|
|
373
|
-
|
|
374
|
-
const clearSchema = baseCommandSchema.extend({
|
|
375
|
-
action: z.literal('clear'),
|
|
376
|
-
selector: z.string().min(1),
|
|
377
|
-
});
|
|
378
|
-
|
|
379
|
-
const selectAllSchema = baseCommandSchema.extend({
|
|
380
|
-
action: z.literal('selectall'),
|
|
381
|
-
selector: z.string().min(1),
|
|
382
|
-
});
|
|
383
|
-
|
|
384
|
-
const innerTextSchema = baseCommandSchema.extend({
|
|
385
|
-
action: z.literal('innertext'),
|
|
386
|
-
selector: z.string().min(1),
|
|
387
|
-
});
|
|
388
|
-
|
|
389
|
-
const innerHtmlSchema = baseCommandSchema.extend({
|
|
390
|
-
action: z.literal('innerhtml'),
|
|
391
|
-
selector: z.string().min(1),
|
|
392
|
-
});
|
|
393
|
-
|
|
394
|
-
const inputValueSchema = baseCommandSchema.extend({
|
|
395
|
-
action: z.literal('inputvalue'),
|
|
396
|
-
selector: z.string().min(1),
|
|
397
|
-
});
|
|
398
|
-
|
|
399
|
-
const setValueSchema = baseCommandSchema.extend({
|
|
400
|
-
action: z.literal('setvalue'),
|
|
401
|
-
selector: z.string().min(1),
|
|
402
|
-
value: z.string(),
|
|
403
|
-
});
|
|
404
|
-
|
|
405
|
-
const dispatchSchema = baseCommandSchema.extend({
|
|
406
|
-
action: z.literal('dispatch'),
|
|
407
|
-
selector: z.string().min(1),
|
|
408
|
-
event: z.string().min(1),
|
|
409
|
-
eventInit: z.record(z.unknown()).optional(),
|
|
410
|
-
});
|
|
411
|
-
|
|
412
|
-
const evalHandleSchema = baseCommandSchema.extend({
|
|
413
|
-
action: z.literal('evalhandle'),
|
|
414
|
-
script: z.string().min(1),
|
|
415
|
-
});
|
|
416
|
-
|
|
417
|
-
const exposeSchema = baseCommandSchema.extend({
|
|
418
|
-
action: z.literal('expose'),
|
|
419
|
-
name: z.string().min(1),
|
|
420
|
-
});
|
|
421
|
-
|
|
422
|
-
const addScriptSchema = baseCommandSchema.extend({
|
|
423
|
-
action: z.literal('addscript'),
|
|
424
|
-
content: z.string().optional(),
|
|
425
|
-
url: z.string().optional(),
|
|
426
|
-
});
|
|
427
|
-
|
|
428
|
-
const addStyleSchema = baseCommandSchema.extend({
|
|
429
|
-
action: z.literal('addstyle'),
|
|
430
|
-
content: z.string().optional(),
|
|
431
|
-
url: z.string().optional(),
|
|
432
|
-
});
|
|
433
|
-
|
|
434
|
-
const emulateMediaSchema = baseCommandSchema.extend({
|
|
435
|
-
action: z.literal('emulatemedia'),
|
|
436
|
-
media: z.enum(['screen', 'print']).nullable().optional(),
|
|
437
|
-
colorScheme: z.enum(['light', 'dark', 'no-preference']).nullable().optional(),
|
|
438
|
-
reducedMotion: z.enum(['reduce', 'no-preference']).nullable().optional(),
|
|
439
|
-
forcedColors: z.enum(['active', 'none']).nullable().optional(),
|
|
440
|
-
});
|
|
441
|
-
|
|
442
|
-
const offlineSchema = baseCommandSchema.extend({
|
|
443
|
-
action: z.literal('offline'),
|
|
444
|
-
offline: z.boolean(),
|
|
445
|
-
});
|
|
446
|
-
|
|
447
|
-
const headersSchema = baseCommandSchema.extend({
|
|
448
|
-
action: z.literal('headers'),
|
|
449
|
-
headers: z.record(z.string()),
|
|
450
|
-
});
|
|
451
|
-
|
|
452
|
-
const pauseSchema = baseCommandSchema.extend({
|
|
453
|
-
action: z.literal('pause'),
|
|
454
|
-
});
|
|
455
|
-
|
|
456
|
-
const getByAltTextSchema = baseCommandSchema.extend({
|
|
457
|
-
action: z.literal('getbyalttext'),
|
|
458
|
-
text: z.string().min(1),
|
|
459
|
-
exact: z.boolean().optional(),
|
|
460
|
-
subaction: z.enum(['click', 'hover']),
|
|
461
|
-
});
|
|
462
|
-
|
|
463
|
-
const getByTitleSchema = baseCommandSchema.extend({
|
|
464
|
-
action: z.literal('getbytitle'),
|
|
465
|
-
text: z.string().min(1),
|
|
466
|
-
exact: z.boolean().optional(),
|
|
467
|
-
subaction: z.enum(['click', 'hover']),
|
|
468
|
-
});
|
|
469
|
-
|
|
470
|
-
const getByTestIdSchema = baseCommandSchema.extend({
|
|
471
|
-
action: z.literal('getbytestid'),
|
|
472
|
-
testId: z.string().min(1),
|
|
473
|
-
subaction: z.enum(['click', 'fill', 'check', 'hover']),
|
|
474
|
-
value: z.string().optional(),
|
|
475
|
-
});
|
|
476
|
-
|
|
477
|
-
const nthSchema = baseCommandSchema.extend({
|
|
478
|
-
action: z.literal('nth'),
|
|
479
|
-
selector: z.string().min(1),
|
|
480
|
-
index: z.number(),
|
|
481
|
-
subaction: z.enum(['click', 'fill', 'check', 'hover', 'text']),
|
|
482
|
-
value: z.string().optional(),
|
|
483
|
-
});
|
|
484
|
-
|
|
485
|
-
const waitForUrlSchema = baseCommandSchema.extend({
|
|
486
|
-
action: z.literal('waitforurl'),
|
|
487
|
-
url: z.string().min(1),
|
|
488
|
-
timeout: z.number().positive().optional(),
|
|
489
|
-
});
|
|
490
|
-
|
|
491
|
-
const waitForLoadStateSchema = baseCommandSchema.extend({
|
|
492
|
-
action: z.literal('waitforloadstate'),
|
|
493
|
-
state: z.enum(['load', 'domcontentloaded', 'networkidle']),
|
|
494
|
-
timeout: z.number().positive().optional(),
|
|
495
|
-
});
|
|
496
|
-
|
|
497
|
-
const setContentSchema = baseCommandSchema.extend({
|
|
498
|
-
action: z.literal('setcontent'),
|
|
499
|
-
html: z.string(),
|
|
500
|
-
});
|
|
501
|
-
|
|
502
|
-
const timezoneSchema = baseCommandSchema.extend({
|
|
503
|
-
action: z.literal('timezone'),
|
|
504
|
-
timezone: z.string().min(1),
|
|
505
|
-
});
|
|
506
|
-
|
|
507
|
-
const localeSchema = baseCommandSchema.extend({
|
|
508
|
-
action: z.literal('locale'),
|
|
509
|
-
locale: z.string().min(1),
|
|
510
|
-
});
|
|
511
|
-
|
|
512
|
-
const credentialsSchema = baseCommandSchema.extend({
|
|
513
|
-
action: z.literal('credentials'),
|
|
514
|
-
username: z.string(),
|
|
515
|
-
password: z.string(),
|
|
516
|
-
});
|
|
517
|
-
|
|
518
|
-
const mouseMoveSchema = baseCommandSchema.extend({
|
|
519
|
-
action: z.literal('mousemove'),
|
|
520
|
-
x: z.number(),
|
|
521
|
-
y: z.number(),
|
|
522
|
-
});
|
|
523
|
-
|
|
524
|
-
const mouseDownSchema = baseCommandSchema.extend({
|
|
525
|
-
action: z.literal('mousedown'),
|
|
526
|
-
button: z.enum(['left', 'right', 'middle']).optional(),
|
|
527
|
-
});
|
|
528
|
-
|
|
529
|
-
const mouseUpSchema = baseCommandSchema.extend({
|
|
530
|
-
action: z.literal('mouseup'),
|
|
531
|
-
button: z.enum(['left', 'right', 'middle']).optional(),
|
|
532
|
-
});
|
|
533
|
-
|
|
534
|
-
const bringToFrontSchema = baseCommandSchema.extend({
|
|
535
|
-
action: z.literal('bringtofront'),
|
|
536
|
-
});
|
|
537
|
-
|
|
538
|
-
const waitForFunctionSchema = baseCommandSchema.extend({
|
|
539
|
-
action: z.literal('waitforfunction'),
|
|
540
|
-
expression: z.string().min(1),
|
|
541
|
-
timeout: z.number().positive().optional(),
|
|
542
|
-
});
|
|
543
|
-
|
|
544
|
-
const scrollIntoViewSchema = baseCommandSchema.extend({
|
|
545
|
-
action: z.literal('scrollintoview'),
|
|
546
|
-
selector: z.string().min(1),
|
|
547
|
-
});
|
|
548
|
-
|
|
549
|
-
const addInitScriptSchema = baseCommandSchema.extend({
|
|
550
|
-
action: z.literal('addinitscript'),
|
|
551
|
-
script: z.string().min(1),
|
|
552
|
-
});
|
|
553
|
-
|
|
554
|
-
const keyDownSchema = baseCommandSchema.extend({
|
|
555
|
-
action: z.literal('keydown'),
|
|
556
|
-
key: z.string().min(1),
|
|
557
|
-
});
|
|
558
|
-
|
|
559
|
-
const keyUpSchema = baseCommandSchema.extend({
|
|
560
|
-
action: z.literal('keyup'),
|
|
561
|
-
key: z.string().min(1),
|
|
562
|
-
});
|
|
563
|
-
|
|
564
|
-
const insertTextSchema = baseCommandSchema.extend({
|
|
565
|
-
action: z.literal('inserttext'),
|
|
566
|
-
text: z.string(),
|
|
567
|
-
});
|
|
568
|
-
|
|
569
|
-
const multiSelectSchema = baseCommandSchema.extend({
|
|
570
|
-
action: z.literal('multiselect'),
|
|
571
|
-
selector: z.string().min(1),
|
|
572
|
-
values: z.array(z.string()),
|
|
573
|
-
});
|
|
574
|
-
|
|
575
|
-
const waitForDownloadSchema = baseCommandSchema.extend({
|
|
576
|
-
action: z.literal('waitfordownload'),
|
|
577
|
-
path: z.string().optional(),
|
|
578
|
-
timeout: z.number().positive().optional(),
|
|
579
|
-
});
|
|
580
|
-
|
|
581
|
-
const responseBodySchema = baseCommandSchema.extend({
|
|
582
|
-
action: z.literal('responsebody'),
|
|
583
|
-
url: z.string().min(1),
|
|
584
|
-
timeout: z.number().positive().optional(),
|
|
585
|
-
});
|
|
586
|
-
|
|
587
|
-
const pressSchema = baseCommandSchema.extend({
|
|
588
|
-
action: z.literal('press'),
|
|
589
|
-
key: z.string().min(1),
|
|
590
|
-
selector: z.string().min(1).optional(),
|
|
591
|
-
});
|
|
592
|
-
|
|
593
|
-
const screenshotSchema = baseCommandSchema.extend({
|
|
594
|
-
action: z.literal('screenshot'),
|
|
595
|
-
path: z.string().optional(),
|
|
596
|
-
fullPage: z.boolean().optional(),
|
|
597
|
-
selector: z.string().min(1).optional(),
|
|
598
|
-
format: z.enum(['png', 'jpeg']).optional(),
|
|
599
|
-
quality: z.number().min(0).max(100).optional(),
|
|
600
|
-
});
|
|
601
|
-
|
|
602
|
-
const snapshotSchema = baseCommandSchema.extend({
|
|
603
|
-
action: z.literal('snapshot'),
|
|
604
|
-
interactive: z.boolean().optional(),
|
|
605
|
-
maxDepth: z.number().nonnegative().optional(),
|
|
606
|
-
compact: z.boolean().optional(),
|
|
607
|
-
selector: z.string().optional(),
|
|
608
|
-
});
|
|
609
|
-
|
|
610
|
-
const evaluateSchema = baseCommandSchema.extend({
|
|
611
|
-
action: z.literal('evaluate'),
|
|
612
|
-
script: z.string().min(1),
|
|
613
|
-
args: z.array(z.unknown()).optional(),
|
|
614
|
-
});
|
|
615
|
-
|
|
616
|
-
const waitSchema = baseCommandSchema.extend({
|
|
617
|
-
action: z.literal('wait'),
|
|
618
|
-
selector: z.string().min(1).optional(),
|
|
619
|
-
timeout: z.number().positive().optional(),
|
|
620
|
-
state: z.enum(['attached', 'detached', 'visible', 'hidden']).optional(),
|
|
621
|
-
});
|
|
622
|
-
|
|
623
|
-
const scrollSchema = baseCommandSchema.extend({
|
|
624
|
-
action: z.literal('scroll'),
|
|
625
|
-
selector: z.string().min(1).optional(),
|
|
626
|
-
x: z.number().optional(),
|
|
627
|
-
y: z.number().optional(),
|
|
628
|
-
direction: z.enum(['up', 'down', 'left', 'right']).optional(),
|
|
629
|
-
amount: z.number().positive().optional(),
|
|
630
|
-
});
|
|
631
|
-
|
|
632
|
-
const selectSchema = baseCommandSchema.extend({
|
|
633
|
-
action: z.literal('select'),
|
|
634
|
-
selector: z.string().min(1),
|
|
635
|
-
values: z.union([z.string(), z.array(z.string())]),
|
|
636
|
-
});
|
|
637
|
-
|
|
638
|
-
const hoverSchema = baseCommandSchema.extend({
|
|
639
|
-
action: z.literal('hover'),
|
|
640
|
-
selector: z.string().min(1),
|
|
641
|
-
});
|
|
642
|
-
|
|
643
|
-
const contentSchema = baseCommandSchema.extend({
|
|
644
|
-
action: z.literal('content'),
|
|
645
|
-
selector: z.string().min(1).optional(),
|
|
646
|
-
});
|
|
647
|
-
|
|
648
|
-
const closeSchema = baseCommandSchema.extend({
|
|
649
|
-
action: z.literal('close'),
|
|
650
|
-
});
|
|
651
|
-
|
|
652
|
-
// Tab/Window schemas
|
|
653
|
-
const tabNewSchema = baseCommandSchema.extend({
|
|
654
|
-
action: z.literal('tab_new'),
|
|
655
|
-
});
|
|
656
|
-
|
|
657
|
-
const tabListSchema = baseCommandSchema.extend({
|
|
658
|
-
action: z.literal('tab_list'),
|
|
659
|
-
});
|
|
660
|
-
|
|
661
|
-
const tabSwitchSchema = baseCommandSchema.extend({
|
|
662
|
-
action: z.literal('tab_switch'),
|
|
663
|
-
index: z.number().nonnegative(),
|
|
664
|
-
});
|
|
665
|
-
|
|
666
|
-
const tabCloseSchema = baseCommandSchema.extend({
|
|
667
|
-
action: z.literal('tab_close'),
|
|
668
|
-
index: z.number().nonnegative().optional(),
|
|
669
|
-
});
|
|
670
|
-
|
|
671
|
-
const windowNewSchema = baseCommandSchema.extend({
|
|
672
|
-
action: z.literal('window_new'),
|
|
673
|
-
viewport: z
|
|
674
|
-
.object({
|
|
675
|
-
width: z.number().positive(),
|
|
676
|
-
height: z.number().positive(),
|
|
677
|
-
})
|
|
678
|
-
.optional(),
|
|
679
|
-
});
|
|
680
|
-
|
|
681
|
-
// Union schema for all commands
|
|
682
|
-
const commandSchema = z.discriminatedUnion('action', [
|
|
683
|
-
launchSchema,
|
|
684
|
-
navigateSchema,
|
|
685
|
-
clickSchema,
|
|
686
|
-
typeSchema,
|
|
687
|
-
fillSchema,
|
|
688
|
-
checkSchema,
|
|
689
|
-
uncheckSchema,
|
|
690
|
-
uploadSchema,
|
|
691
|
-
dblclickSchema,
|
|
692
|
-
focusSchema,
|
|
693
|
-
dragSchema,
|
|
694
|
-
frameSchema,
|
|
695
|
-
mainframeSchema,
|
|
696
|
-
getByRoleSchema,
|
|
697
|
-
getByTextSchema,
|
|
698
|
-
getByLabelSchema,
|
|
699
|
-
getByPlaceholderSchema,
|
|
700
|
-
pressSchema,
|
|
701
|
-
screenshotSchema,
|
|
702
|
-
snapshotSchema,
|
|
703
|
-
evaluateSchema,
|
|
704
|
-
waitSchema,
|
|
705
|
-
scrollSchema,
|
|
706
|
-
selectSchema,
|
|
707
|
-
hoverSchema,
|
|
708
|
-
contentSchema,
|
|
709
|
-
closeSchema,
|
|
710
|
-
tabNewSchema,
|
|
711
|
-
tabListSchema,
|
|
712
|
-
tabSwitchSchema,
|
|
713
|
-
tabCloseSchema,
|
|
714
|
-
windowNewSchema,
|
|
715
|
-
cookiesGetSchema,
|
|
716
|
-
cookiesSetSchema,
|
|
717
|
-
cookiesClearSchema,
|
|
718
|
-
storageGetSchema,
|
|
719
|
-
storageSetSchema,
|
|
720
|
-
storageClearSchema,
|
|
721
|
-
dialogSchema,
|
|
722
|
-
pdfSchema,
|
|
723
|
-
routeSchema,
|
|
724
|
-
unrouteSchema,
|
|
725
|
-
requestsSchema,
|
|
726
|
-
downloadSchema,
|
|
727
|
-
geolocationSchema,
|
|
728
|
-
permissionsSchema,
|
|
729
|
-
viewportSchema,
|
|
730
|
-
userAgentSchema,
|
|
731
|
-
deviceSchema,
|
|
732
|
-
backSchema,
|
|
733
|
-
forwardSchema,
|
|
734
|
-
reloadSchema,
|
|
735
|
-
urlSchema,
|
|
736
|
-
titleSchema,
|
|
737
|
-
getAttributeSchema,
|
|
738
|
-
getTextSchema,
|
|
739
|
-
isVisibleSchema,
|
|
740
|
-
isEnabledSchema,
|
|
741
|
-
isCheckedSchema,
|
|
742
|
-
countSchema,
|
|
743
|
-
boundingBoxSchema,
|
|
744
|
-
videoStartSchema,
|
|
745
|
-
videoStopSchema,
|
|
746
|
-
traceStartSchema,
|
|
747
|
-
traceStopSchema,
|
|
748
|
-
harStartSchema,
|
|
749
|
-
harStopSchema,
|
|
750
|
-
stateSaveSchema,
|
|
751
|
-
stateLoadSchema,
|
|
752
|
-
consoleSchema,
|
|
753
|
-
errorsSchema,
|
|
754
|
-
keyboardSchema,
|
|
755
|
-
wheelSchema,
|
|
756
|
-
tapSchema,
|
|
757
|
-
clipboardSchema,
|
|
758
|
-
highlightSchema,
|
|
759
|
-
clearSchema,
|
|
760
|
-
selectAllSchema,
|
|
761
|
-
innerTextSchema,
|
|
762
|
-
innerHtmlSchema,
|
|
763
|
-
inputValueSchema,
|
|
764
|
-
setValueSchema,
|
|
765
|
-
dispatchSchema,
|
|
766
|
-
evalHandleSchema,
|
|
767
|
-
exposeSchema,
|
|
768
|
-
addScriptSchema,
|
|
769
|
-
addStyleSchema,
|
|
770
|
-
emulateMediaSchema,
|
|
771
|
-
offlineSchema,
|
|
772
|
-
headersSchema,
|
|
773
|
-
pauseSchema,
|
|
774
|
-
getByAltTextSchema,
|
|
775
|
-
getByTitleSchema,
|
|
776
|
-
getByTestIdSchema,
|
|
777
|
-
nthSchema,
|
|
778
|
-
waitForUrlSchema,
|
|
779
|
-
waitForLoadStateSchema,
|
|
780
|
-
setContentSchema,
|
|
781
|
-
timezoneSchema,
|
|
782
|
-
localeSchema,
|
|
783
|
-
credentialsSchema,
|
|
784
|
-
mouseMoveSchema,
|
|
785
|
-
mouseDownSchema,
|
|
786
|
-
mouseUpSchema,
|
|
787
|
-
bringToFrontSchema,
|
|
788
|
-
waitForFunctionSchema,
|
|
789
|
-
scrollIntoViewSchema,
|
|
790
|
-
addInitScriptSchema,
|
|
791
|
-
keyDownSchema,
|
|
792
|
-
keyUpSchema,
|
|
793
|
-
insertTextSchema,
|
|
794
|
-
multiSelectSchema,
|
|
795
|
-
waitForDownloadSchema,
|
|
796
|
-
responseBodySchema,
|
|
797
|
-
]);
|
|
798
|
-
|
|
799
|
-
// Parse result type
|
|
800
|
-
export type ParseResult =
|
|
801
|
-
| { success: true; command: Command }
|
|
802
|
-
| { success: false; error: string; id?: string };
|
|
803
|
-
|
|
804
|
-
/**
|
|
805
|
-
* Parse a JSON string into a validated command
|
|
806
|
-
*/
|
|
807
|
-
export function parseCommand(input: string): ParseResult {
|
|
808
|
-
// First, try to parse JSON
|
|
809
|
-
let json: unknown;
|
|
810
|
-
try {
|
|
811
|
-
json = JSON.parse(input);
|
|
812
|
-
} catch {
|
|
813
|
-
return { success: false, error: 'Invalid JSON' };
|
|
814
|
-
}
|
|
815
|
-
|
|
816
|
-
// Extract id for error responses if possible
|
|
817
|
-
const id =
|
|
818
|
-
typeof json === 'object' && json !== null && 'id' in json
|
|
819
|
-
? String((json as { id: unknown }).id)
|
|
820
|
-
: undefined;
|
|
821
|
-
|
|
822
|
-
// Validate against schema
|
|
823
|
-
const result = commandSchema.safeParse(json);
|
|
824
|
-
|
|
825
|
-
if (!result.success) {
|
|
826
|
-
const errors = result.error.errors.map((e) => `${e.path.join('.')}: ${e.message}`).join(', ');
|
|
827
|
-
return { success: false, error: `Validation error: ${errors}`, id };
|
|
828
|
-
}
|
|
829
|
-
|
|
830
|
-
return { success: true, command: result.data as Command };
|
|
831
|
-
}
|
|
832
|
-
|
|
833
|
-
/**
|
|
834
|
-
* Create a success response
|
|
835
|
-
*/
|
|
836
|
-
export function successResponse<T>(id: string, data: T): Response<T> {
|
|
837
|
-
return { id, success: true, data };
|
|
838
|
-
}
|
|
839
|
-
|
|
840
|
-
/**
|
|
841
|
-
* Create an error response
|
|
842
|
-
*/
|
|
843
|
-
export function errorResponse(id: string, error: string): Response {
|
|
844
|
-
return { id, success: false, error };
|
|
845
|
-
}
|
|
846
|
-
|
|
847
|
-
/**
|
|
848
|
-
* Serialize a response to JSON string
|
|
849
|
-
*/
|
|
850
|
-
export function serializeResponse(response: Response): string {
|
|
851
|
-
return JSON.stringify(response);
|
|
852
|
-
}
|