feat(browser-tools): cut low-value tools
This commit is contained in:
@@ -73,28 +73,12 @@ const commandParseCases = [
|
||||
{
|
||||
name: "screenshot",
|
||||
command: { command: "screenshot", args: { browserId: BROWSER_ID } },
|
||||
expected: { command: "screenshot", args: { browserId: BROWSER_ID } },
|
||||
expected: { command: "screenshot", args: { browserId: BROWSER_ID, fullPage: false } },
|
||||
},
|
||||
{
|
||||
name: "full page screenshot",
|
||||
command: { command: "full_page_screenshot", args: { browserId: BROWSER_ID } },
|
||||
expected: { command: "full_page_screenshot", args: { browserId: BROWSER_ID } },
|
||||
},
|
||||
{
|
||||
name: "pdf",
|
||||
command: { command: "pdf", args: { browserId: BROWSER_ID } },
|
||||
expected: { command: "pdf", args: { browserId: BROWSER_ID, printBackground: true } },
|
||||
},
|
||||
{
|
||||
name: "download",
|
||||
command: {
|
||||
command: "download",
|
||||
args: { browserId: BROWSER_ID, url: "https://example.com/file.txt" },
|
||||
},
|
||||
expected: {
|
||||
command: "download",
|
||||
args: { browserId: BROWSER_ID, url: "https://example.com/file.txt" },
|
||||
},
|
||||
command: { command: "screenshot", args: { browserId: BROWSER_ID, fullPage: true } },
|
||||
expected: { command: "screenshot", args: { browserId: BROWSER_ID, fullPage: true } },
|
||||
},
|
||||
{
|
||||
name: "upload",
|
||||
@@ -107,21 +91,6 @@ const commandParseCases = [
|
||||
args: { browserId: BROWSER_ID, ref: "@e1", filePaths: ["/tmp/file.txt"] },
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "focus",
|
||||
command: { command: "focus", args: { browserId: BROWSER_ID, ref: "@e1" } },
|
||||
expected: { command: "focus", args: { browserId: BROWSER_ID, ref: "@e1" } },
|
||||
},
|
||||
{
|
||||
name: "clear",
|
||||
command: { command: "clear", args: { browserId: BROWSER_ID, ref: "@e1" } },
|
||||
expected: { command: "clear", args: { browserId: BROWSER_ID, ref: "@e1" } },
|
||||
},
|
||||
{
|
||||
name: "check",
|
||||
command: { command: "check", args: { browserId: BROWSER_ID, ref: "@e2" } },
|
||||
expected: { command: "check", args: { browserId: BROWSER_ID, ref: "@e2", checked: true } },
|
||||
},
|
||||
{
|
||||
name: "select",
|
||||
command: {
|
||||
@@ -154,61 +123,9 @@ const commandParseCases = [
|
||||
command: { command: "logs", args: { browserId: BROWSER_ID } },
|
||||
expected: { command: "logs", args: { browserId: BROWSER_ID, maxEntries: 50 } },
|
||||
},
|
||||
{
|
||||
name: "storage",
|
||||
command: { command: "storage", args: { browserId: BROWSER_ID } },
|
||||
expected: { command: "storage", args: { browserId: BROWSER_ID } },
|
||||
},
|
||||
{
|
||||
name: "environment",
|
||||
command: {
|
||||
command: "environment",
|
||||
args: {
|
||||
browserId: BROWSER_ID,
|
||||
viewport: { width: 390, height: 844, deviceScaleFactor: 3 },
|
||||
geolocation: { latitude: 37.7749, longitude: -122.4194, accuracy: 5 },
|
||||
},
|
||||
},
|
||||
expected: {
|
||||
command: "environment",
|
||||
args: {
|
||||
browserId: BROWSER_ID,
|
||||
viewport: { width: 390, height: 844, deviceScaleFactor: 3 },
|
||||
geolocation: { latitude: 37.7749, longitude: -122.4194, accuracy: 5 },
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "set background",
|
||||
command: { command: "set_background", args: { browserId: BROWSER_ID, color: "red" } },
|
||||
expected: { command: "set_background", args: { browserId: BROWSER_ID, color: "red" } },
|
||||
},
|
||||
] as const;
|
||||
|
||||
const resultParseCases = [
|
||||
{
|
||||
name: "page info",
|
||||
result: {
|
||||
command: "page_info",
|
||||
tab: {
|
||||
browserId: BROWSER_ID,
|
||||
workspaceId: "workspace-1",
|
||||
url: "https://example.com",
|
||||
title: "Example",
|
||||
},
|
||||
},
|
||||
expected: {
|
||||
command: "page_info",
|
||||
tab: {
|
||||
browserId: BROWSER_ID,
|
||||
workspaceId: "workspace-1",
|
||||
url: "https://example.com",
|
||||
title: "Example",
|
||||
isActive: false,
|
||||
isLoading: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "snapshot",
|
||||
result: {
|
||||
@@ -313,7 +230,7 @@ const resultParseCases = [
|
||||
{
|
||||
name: "full page screenshot",
|
||||
result: {
|
||||
command: "full_page_screenshot",
|
||||
command: "screenshot",
|
||||
browserId: BROWSER_ID,
|
||||
mimeType: "image/png",
|
||||
dataBase64: "iVBORw0KGgo=",
|
||||
@@ -321,7 +238,7 @@ const resultParseCases = [
|
||||
height: 1200,
|
||||
},
|
||||
expected: {
|
||||
command: "full_page_screenshot",
|
||||
command: "screenshot",
|
||||
browserId: BROWSER_ID,
|
||||
mimeType: "image/png",
|
||||
dataBase64: "iVBORw0KGgo=",
|
||||
@@ -329,40 +246,6 @@ const resultParseCases = [
|
||||
height: 1200,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "pdf",
|
||||
result: {
|
||||
command: "pdf",
|
||||
browserId: BROWSER_ID,
|
||||
mimeType: "application/pdf",
|
||||
dataBase64: "JVBERg==",
|
||||
},
|
||||
expected: {
|
||||
command: "pdf",
|
||||
browserId: BROWSER_ID,
|
||||
mimeType: "application/pdf",
|
||||
dataBase64: "JVBERg==",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "download",
|
||||
result: {
|
||||
command: "download",
|
||||
browserId: BROWSER_ID,
|
||||
url: "https://example.com/file.txt",
|
||||
filePath: "/tmp/file.txt",
|
||||
totalBytes: 5,
|
||||
state: "completed",
|
||||
},
|
||||
expected: {
|
||||
command: "download",
|
||||
browserId: BROWSER_ID,
|
||||
url: "https://example.com/file.txt",
|
||||
filePath: "/tmp/file.txt",
|
||||
totalBytes: 5,
|
||||
state: "completed",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "upload",
|
||||
result: {
|
||||
@@ -378,21 +261,6 @@ const resultParseCases = [
|
||||
filePaths: ["/tmp/file.txt"],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "focus",
|
||||
result: { command: "focus", browserId: BROWSER_ID, ref: "@e1" },
|
||||
expected: { command: "focus", browserId: BROWSER_ID, ref: "@e1" },
|
||||
},
|
||||
{
|
||||
name: "clear",
|
||||
result: { command: "clear", browserId: BROWSER_ID, ref: "@e1" },
|
||||
expected: { command: "clear", browserId: BROWSER_ID, ref: "@e1" },
|
||||
},
|
||||
{
|
||||
name: "check",
|
||||
result: { command: "check", browserId: BROWSER_ID, ref: "@e2", checked: false },
|
||||
expected: { command: "check", browserId: BROWSER_ID, ref: "@e2", checked: false },
|
||||
},
|
||||
{
|
||||
name: "select",
|
||||
result: { command: "select", browserId: BROWSER_ID, ref: "@e3", value: "us" },
|
||||
@@ -437,45 +305,6 @@ const resultParseCases = [
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "storage",
|
||||
result: {
|
||||
command: "storage",
|
||||
browserId: BROWSER_ID,
|
||||
url: "https://example.com",
|
||||
cookies: [{ name: "theme", value: "dark", domain: "example.com", httpOnly: true }],
|
||||
localStorage: [{ key: "token", value: "abc" }],
|
||||
sessionStorage: [{ key: "tab", value: "1" }],
|
||||
},
|
||||
expected: {
|
||||
command: "storage",
|
||||
browserId: BROWSER_ID,
|
||||
url: "https://example.com",
|
||||
cookies: [{ name: "theme", value: "dark", domain: "example.com", httpOnly: true }],
|
||||
localStorage: [{ key: "token", value: "abc" }],
|
||||
sessionStorage: [{ key: "tab", value: "1" }],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "environment",
|
||||
result: {
|
||||
command: "environment",
|
||||
browserId: BROWSER_ID,
|
||||
viewport: { width: 390, height: 844, deviceScaleFactor: 3 },
|
||||
geolocation: { latitude: 37.7749, longitude: -122.4194, accuracy: 5 },
|
||||
},
|
||||
expected: {
|
||||
command: "environment",
|
||||
browserId: BROWSER_ID,
|
||||
viewport: { width: 390, height: 844, deviceScaleFactor: 3 },
|
||||
geolocation: { latitude: 37.7749, longitude: -122.4194, accuracy: 5 },
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "set background",
|
||||
result: { command: "set_background", browserId: BROWSER_ID, color: "red" },
|
||||
expected: { command: "set_background", browserId: BROWSER_ID, color: "red" },
|
||||
},
|
||||
] as const;
|
||||
|
||||
describe("browser automation execute RPC schemas", () => {
|
||||
@@ -526,9 +355,9 @@ describe("browser automation execute RPC schemas", () => {
|
||||
test("tab commands reject hallucinated browser ids", () => {
|
||||
const parsed = BrowserAutomationExecuteRequestSchema.safeParse({
|
||||
type: "browser.automation.execute.request",
|
||||
requestId: "req-page-info",
|
||||
requestId: "req-snapshot",
|
||||
workspaceId: "workspace-1",
|
||||
command: { command: "page_info", args: { browserId: "default" } },
|
||||
command: { command: "snapshot", args: { browserId: "default" } },
|
||||
});
|
||||
|
||||
expect(parsed).toMatchObject({
|
||||
@@ -540,13 +369,13 @@ describe("browser automation execute RPC schemas", () => {
|
||||
test("tab commands parse browser ids produced by the fallback generator", () => {
|
||||
const parsed = BrowserAutomationExecuteRequestSchema.parse({
|
||||
type: "browser.automation.execute.request",
|
||||
requestId: "req-page-info",
|
||||
requestId: "req-snapshot",
|
||||
workspaceId: "workspace-1",
|
||||
command: { command: "page_info", args: { browserId: FALLBACK_BROWSER_ID } },
|
||||
command: { command: "snapshot", args: { browserId: FALLBACK_BROWSER_ID } },
|
||||
});
|
||||
|
||||
expect(parsed.command).toEqual({
|
||||
command: "page_info",
|
||||
command: "snapshot",
|
||||
args: { browserId: FALLBACK_BROWSER_ID },
|
||||
});
|
||||
});
|
||||
@@ -658,22 +487,6 @@ describe("browser automation execute RPC schemas", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("download rejects non-http URLs at the protocol boundary", () => {
|
||||
const parsed = BrowserAutomationExecuteRequestSchema.safeParse({
|
||||
type: "browser.automation.execute.request",
|
||||
requestId: "req-download",
|
||||
command: {
|
||||
command: "download",
|
||||
args: { browserId: BROWSER_ID, url: "file:///tmp/secret.txt" },
|
||||
},
|
||||
});
|
||||
|
||||
expect(parsed).toMatchObject({
|
||||
success: false,
|
||||
error: { issues: [expect.objectContaining({ message: "URL must use http or https" })] },
|
||||
});
|
||||
});
|
||||
|
||||
test("new tab responses declare the generated browser id shape", () => {
|
||||
const parsed = BrowserAutomationExecuteResponseSchema.parse({
|
||||
type: "browser.automation.execute.response",
|
||||
@@ -705,16 +518,15 @@ describe("browser automation execute RPC schemas", () => {
|
||||
const parsed = BrowserAutomationExecuteResponseSchema.safeParse({
|
||||
type: "browser.automation.execute.response",
|
||||
payload: {
|
||||
requestId: "req-page-info",
|
||||
requestId: "req-snapshot",
|
||||
ok: true,
|
||||
result: {
|
||||
command: "page_info",
|
||||
tab: {
|
||||
browserId: "default",
|
||||
workspaceId: "workspace-1",
|
||||
url: "https://example.com",
|
||||
title: "Example",
|
||||
},
|
||||
command: "snapshot",
|
||||
browserId: "default",
|
||||
workspaceId: "workspace-1",
|
||||
url: "https://example.com",
|
||||
title: "Example",
|
||||
elements: [],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -55,11 +55,6 @@ export const BrowserAutomationNewTabCommandSchema = z.object({
|
||||
.default({}),
|
||||
});
|
||||
|
||||
export const BrowserAutomationPageInfoCommandSchema = z.object({
|
||||
command: z.literal("page_info"),
|
||||
args: BrowserAutomationTabTargetSchema,
|
||||
});
|
||||
|
||||
export const BrowserAutomationSnapshotCommandSchema = z.object({
|
||||
command: z.literal("snapshot"),
|
||||
args: BrowserAutomationTabTargetSchema,
|
||||
@@ -131,27 +126,8 @@ export const BrowserAutomationReloadCommandSchema = z.object({
|
||||
|
||||
export const BrowserAutomationScreenshotCommandSchema = z.object({
|
||||
command: z.literal("screenshot"),
|
||||
args: BrowserAutomationTabTargetSchema,
|
||||
});
|
||||
|
||||
export const BrowserAutomationFullPageScreenshotCommandSchema = z.object({
|
||||
command: z.literal("full_page_screenshot"),
|
||||
args: BrowserAutomationTabTargetSchema,
|
||||
});
|
||||
|
||||
export const BrowserAutomationPdfCommandSchema = z.object({
|
||||
command: z.literal("pdf"),
|
||||
args: BrowserAutomationTabTargetSchema.extend({
|
||||
landscape: z.boolean().optional(),
|
||||
printBackground: z.boolean().default(true),
|
||||
}),
|
||||
});
|
||||
|
||||
export const BrowserAutomationDownloadCommandSchema = z.object({
|
||||
command: z.literal("download"),
|
||||
args: BrowserAutomationTabTargetSchema.extend({
|
||||
url: BrowserAutomationHttpUrlSchema,
|
||||
fileName: z.string().min(1).optional(),
|
||||
fullPage: z.boolean().default(false),
|
||||
}),
|
||||
});
|
||||
|
||||
@@ -163,28 +139,6 @@ export const BrowserAutomationUploadCommandSchema = z.object({
|
||||
}),
|
||||
});
|
||||
|
||||
export const BrowserAutomationFocusCommandSchema = z.object({
|
||||
command: z.literal("focus"),
|
||||
args: BrowserAutomationTabTargetSchema.extend({
|
||||
ref: BrowserAutomationRefSchema,
|
||||
}),
|
||||
});
|
||||
|
||||
export const BrowserAutomationClearCommandSchema = z.object({
|
||||
command: z.literal("clear"),
|
||||
args: BrowserAutomationTabTargetSchema.extend({
|
||||
ref: BrowserAutomationRefSchema,
|
||||
}),
|
||||
});
|
||||
|
||||
export const BrowserAutomationCheckCommandSchema = z.object({
|
||||
command: z.literal("check"),
|
||||
args: BrowserAutomationTabTargetSchema.extend({
|
||||
ref: BrowserAutomationRefSchema,
|
||||
checked: z.boolean().default(true),
|
||||
}),
|
||||
});
|
||||
|
||||
export const BrowserAutomationSelectCommandSchema = z.object({
|
||||
command: z.literal("select"),
|
||||
args: BrowserAutomationTabTargetSchema.extend({
|
||||
@@ -215,42 +169,9 @@ export const BrowserAutomationLogsCommandSchema = z.object({
|
||||
}),
|
||||
});
|
||||
|
||||
export const BrowserAutomationStorageCommandSchema = z.object({
|
||||
command: z.literal("storage"),
|
||||
args: BrowserAutomationTabTargetSchema,
|
||||
});
|
||||
|
||||
const BrowserAutomationViewportInputSchema = z.object({
|
||||
width: z.number().int().positive(),
|
||||
height: z.number().int().positive(),
|
||||
deviceScaleFactor: z.number().positive().optional(),
|
||||
});
|
||||
|
||||
const BrowserAutomationGeolocationInputSchema = z.object({
|
||||
latitude: z.number().min(-90).max(90),
|
||||
longitude: z.number().min(-180).max(180),
|
||||
accuracy: z.number().positive().optional(),
|
||||
});
|
||||
|
||||
export const BrowserAutomationEnvironmentCommandSchema = z.object({
|
||||
command: z.literal("environment"),
|
||||
args: BrowserAutomationTabTargetSchema.extend({
|
||||
viewport: BrowserAutomationViewportInputSchema.optional(),
|
||||
geolocation: BrowserAutomationGeolocationInputSchema.optional(),
|
||||
}),
|
||||
});
|
||||
|
||||
export const BrowserAutomationSetBackgroundCommandSchema = z.object({
|
||||
command: z.literal("set_background"),
|
||||
args: BrowserAutomationTabTargetSchema.extend({
|
||||
color: z.string().min(1),
|
||||
}),
|
||||
});
|
||||
|
||||
export const BrowserAutomationCommandSchema = z.discriminatedUnion("command", [
|
||||
BrowserAutomationListTabsCommandSchema,
|
||||
BrowserAutomationNewTabCommandSchema,
|
||||
BrowserAutomationPageInfoCommandSchema,
|
||||
BrowserAutomationSnapshotCommandSchema,
|
||||
BrowserAutomationClickCommandSchema,
|
||||
BrowserAutomationFillCommandSchema,
|
||||
@@ -262,20 +183,11 @@ export const BrowserAutomationCommandSchema = z.discriminatedUnion("command", [
|
||||
BrowserAutomationForwardCommandSchema,
|
||||
BrowserAutomationReloadCommandSchema,
|
||||
BrowserAutomationScreenshotCommandSchema,
|
||||
BrowserAutomationFullPageScreenshotCommandSchema,
|
||||
BrowserAutomationPdfCommandSchema,
|
||||
BrowserAutomationDownloadCommandSchema,
|
||||
BrowserAutomationUploadCommandSchema,
|
||||
BrowserAutomationFocusCommandSchema,
|
||||
BrowserAutomationClearCommandSchema,
|
||||
BrowserAutomationCheckCommandSchema,
|
||||
BrowserAutomationSelectCommandSchema,
|
||||
BrowserAutomationHoverCommandSchema,
|
||||
BrowserAutomationDragCommandSchema,
|
||||
BrowserAutomationLogsCommandSchema,
|
||||
BrowserAutomationStorageCommandSchema,
|
||||
BrowserAutomationEnvironmentCommandSchema,
|
||||
BrowserAutomationSetBackgroundCommandSchema,
|
||||
]);
|
||||
|
||||
export const BrowserAutomationTabInfoSchema = z.object({
|
||||
@@ -301,11 +213,6 @@ export const BrowserAutomationNewTabResultSchema = z.object({
|
||||
url: z.string().min(1),
|
||||
});
|
||||
|
||||
export const BrowserAutomationPageInfoResultSchema = z.object({
|
||||
command: z.literal("page_info"),
|
||||
tab: BrowserAutomationTabInfoSchema,
|
||||
});
|
||||
|
||||
export const BrowserAutomationSnapshotElementSchema = z.object({
|
||||
ref: z.string().regex(/^@e\d+$/),
|
||||
role: z.string(),
|
||||
@@ -385,31 +292,6 @@ export const BrowserAutomationScreenshotResultSchema = z.object({
|
||||
height: z.number().int().nonnegative(),
|
||||
});
|
||||
|
||||
export const BrowserAutomationFullPageScreenshotResultSchema = z.object({
|
||||
command: z.literal("full_page_screenshot"),
|
||||
browserId: BrowserAutomationBrowserIdSchema,
|
||||
mimeType: z.literal("image/png"),
|
||||
dataBase64: z.string().min(1),
|
||||
width: z.number().int().nonnegative(),
|
||||
height: z.number().int().nonnegative(),
|
||||
});
|
||||
|
||||
export const BrowserAutomationPdfResultSchema = z.object({
|
||||
command: z.literal("pdf"),
|
||||
browserId: BrowserAutomationBrowserIdSchema,
|
||||
mimeType: z.literal("application/pdf"),
|
||||
dataBase64: z.string().min(1),
|
||||
});
|
||||
|
||||
export const BrowserAutomationDownloadResultSchema = z.object({
|
||||
command: z.literal("download"),
|
||||
browserId: BrowserAutomationBrowserIdSchema,
|
||||
url: z.string().min(1),
|
||||
filePath: z.string().min(1),
|
||||
totalBytes: z.number().int().nonnegative().optional(),
|
||||
state: z.string().min(1),
|
||||
});
|
||||
|
||||
export const BrowserAutomationUploadResultSchema = z.object({
|
||||
command: z.literal("upload"),
|
||||
browserId: BrowserAutomationBrowserIdSchema,
|
||||
@@ -417,25 +299,6 @@ export const BrowserAutomationUploadResultSchema = z.object({
|
||||
filePaths: z.array(z.string().min(1)).min(1),
|
||||
});
|
||||
|
||||
export const BrowserAutomationFocusResultSchema = z.object({
|
||||
command: z.literal("focus"),
|
||||
browserId: BrowserAutomationBrowserIdSchema,
|
||||
ref: BrowserAutomationRefSchema,
|
||||
});
|
||||
|
||||
export const BrowserAutomationClearResultSchema = z.object({
|
||||
command: z.literal("clear"),
|
||||
browserId: BrowserAutomationBrowserIdSchema,
|
||||
ref: BrowserAutomationRefSchema,
|
||||
});
|
||||
|
||||
export const BrowserAutomationCheckResultSchema = z.object({
|
||||
command: z.literal("check"),
|
||||
browserId: BrowserAutomationBrowserIdSchema,
|
||||
ref: BrowserAutomationRefSchema,
|
||||
checked: z.boolean(),
|
||||
});
|
||||
|
||||
export const BrowserAutomationSelectResultSchema = z.object({
|
||||
command: z.literal("select"),
|
||||
browserId: BrowserAutomationBrowserIdSchema,
|
||||
@@ -481,59 +344,9 @@ export const BrowserAutomationLogsResultSchema = z.object({
|
||||
network: z.array(BrowserAutomationNetworkLogEntrySchema),
|
||||
});
|
||||
|
||||
export const BrowserAutomationCookieEntrySchema = z.object({
|
||||
name: z.string(),
|
||||
value: z.string(),
|
||||
domain: z.string().optional(),
|
||||
path: z.string().optional(),
|
||||
secure: z.boolean().optional(),
|
||||
httpOnly: z.boolean().optional(),
|
||||
expirationDate: z.number().optional(),
|
||||
});
|
||||
|
||||
export const BrowserAutomationStorageEntrySchema = z.object({
|
||||
key: z.string(),
|
||||
value: z.string(),
|
||||
});
|
||||
|
||||
export const BrowserAutomationStorageResultSchema = z.object({
|
||||
command: z.literal("storage"),
|
||||
browserId: BrowserAutomationBrowserIdSchema,
|
||||
url: z.string(),
|
||||
cookies: z.array(BrowserAutomationCookieEntrySchema),
|
||||
localStorage: z.array(BrowserAutomationStorageEntrySchema),
|
||||
sessionStorage: z.array(BrowserAutomationStorageEntrySchema),
|
||||
});
|
||||
|
||||
export const BrowserAutomationViewportResultSchema = z.object({
|
||||
width: z.number().int().nonnegative(),
|
||||
height: z.number().int().nonnegative(),
|
||||
deviceScaleFactor: z.number().positive(),
|
||||
});
|
||||
|
||||
export const BrowserAutomationGeolocationResultSchema = z.object({
|
||||
latitude: z.number(),
|
||||
longitude: z.number(),
|
||||
accuracy: z.number(),
|
||||
});
|
||||
|
||||
export const BrowserAutomationEnvironmentResultSchema = z.object({
|
||||
command: z.literal("environment"),
|
||||
browserId: BrowserAutomationBrowserIdSchema,
|
||||
viewport: BrowserAutomationViewportResultSchema,
|
||||
geolocation: BrowserAutomationGeolocationResultSchema.optional(),
|
||||
});
|
||||
|
||||
export const BrowserAutomationSetBackgroundResultSchema = z.object({
|
||||
command: z.literal("set_background"),
|
||||
browserId: BrowserAutomationBrowserIdSchema,
|
||||
color: z.string().min(1),
|
||||
});
|
||||
|
||||
export const BrowserAutomationResultSchema = z.discriminatedUnion("command", [
|
||||
BrowserAutomationListTabsResultSchema,
|
||||
BrowserAutomationNewTabResultSchema,
|
||||
BrowserAutomationPageInfoResultSchema,
|
||||
BrowserAutomationSnapshotResultSchema,
|
||||
BrowserAutomationClickResultSchema,
|
||||
BrowserAutomationFillResultSchema,
|
||||
@@ -545,20 +358,11 @@ export const BrowserAutomationResultSchema = z.discriminatedUnion("command", [
|
||||
BrowserAutomationForwardResultSchema,
|
||||
BrowserAutomationReloadResultSchema,
|
||||
BrowserAutomationScreenshotResultSchema,
|
||||
BrowserAutomationFullPageScreenshotResultSchema,
|
||||
BrowserAutomationPdfResultSchema,
|
||||
BrowserAutomationDownloadResultSchema,
|
||||
BrowserAutomationUploadResultSchema,
|
||||
BrowserAutomationFocusResultSchema,
|
||||
BrowserAutomationClearResultSchema,
|
||||
BrowserAutomationCheckResultSchema,
|
||||
BrowserAutomationSelectResultSchema,
|
||||
BrowserAutomationHoverResultSchema,
|
||||
BrowserAutomationDragResultSchema,
|
||||
BrowserAutomationLogsResultSchema,
|
||||
BrowserAutomationStorageResultSchema,
|
||||
BrowserAutomationEnvironmentResultSchema,
|
||||
BrowserAutomationSetBackgroundResultSchema,
|
||||
]);
|
||||
|
||||
export const BrowserAutomationErrorSchema = z.object({
|
||||
@@ -603,8 +407,6 @@ export type BrowserAutomationConsoleLogEntry = z.infer<
|
||||
export type BrowserAutomationNetworkLogEntry = z.infer<
|
||||
typeof BrowserAutomationNetworkLogEntrySchema
|
||||
>;
|
||||
export type BrowserAutomationCookieEntry = z.infer<typeof BrowserAutomationCookieEntrySchema>;
|
||||
export type BrowserAutomationStorageEntry = z.infer<typeof BrowserAutomationStorageEntrySchema>;
|
||||
export type BrowserAutomationExecuteRequest = z.infer<typeof BrowserAutomationExecuteRequestSchema>;
|
||||
export type BrowserAutomationExecuteResponse = z.infer<
|
||||
typeof BrowserAutomationExecuteResponseSchema
|
||||
|
||||
@@ -41,7 +41,7 @@ describe("browser automation protocol integration", () => {
|
||||
const parsed = SessionOutboundMessageSchema.parse({
|
||||
type: "browser.automation.execute.request",
|
||||
requestId: "req-1",
|
||||
command: { command: "page_info", args: { browserId } },
|
||||
command: { command: "snapshot", args: { browserId } },
|
||||
});
|
||||
|
||||
expect(parsed.type).toBe("browser.automation.execute.request");
|
||||
|
||||
Reference in New Issue
Block a user