@flrande/browserctl 0.1.0-dev.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README-CN.md +66 -0
- package/README.md +66 -0
- package/apps/browserctl/src/commands/a11y-snapshot.ts +20 -0
- package/apps/browserctl/src/commands/act.ts +20 -0
- package/apps/browserctl/src/commands/common.test.ts +87 -0
- package/apps/browserctl/src/commands/common.ts +191 -0
- package/apps/browserctl/src/commands/console-list.ts +20 -0
- package/apps/browserctl/src/commands/cookie-clear.ts +18 -0
- package/apps/browserctl/src/commands/cookie-get.ts +18 -0
- package/apps/browserctl/src/commands/cookie-set.ts +22 -0
- package/apps/browserctl/src/commands/dialog-arm.ts +20 -0
- package/apps/browserctl/src/commands/dom-query-all.ts +18 -0
- package/apps/browserctl/src/commands/dom-query.ts +18 -0
- package/apps/browserctl/src/commands/download-trigger.ts +22 -0
- package/apps/browserctl/src/commands/download-wait.test.ts +67 -0
- package/apps/browserctl/src/commands/download-wait.ts +27 -0
- package/apps/browserctl/src/commands/element-screenshot.ts +20 -0
- package/apps/browserctl/src/commands/frame-list.ts +16 -0
- package/apps/browserctl/src/commands/frame-snapshot.ts +18 -0
- package/apps/browserctl/src/commands/network-wait-for.ts +100 -0
- package/apps/browserctl/src/commands/profile-list.ts +16 -0
- package/apps/browserctl/src/commands/profile-use.ts +18 -0
- package/apps/browserctl/src/commands/response-body.ts +24 -0
- package/apps/browserctl/src/commands/screenshot.ts +16 -0
- package/apps/browserctl/src/commands/snapshot.ts +16 -0
- package/apps/browserctl/src/commands/status.ts +10 -0
- package/apps/browserctl/src/commands/storage-get.ts +20 -0
- package/apps/browserctl/src/commands/storage-set.ts +22 -0
- package/apps/browserctl/src/commands/tab-close.ts +20 -0
- package/apps/browserctl/src/commands/tab-focus.ts +20 -0
- package/apps/browserctl/src/commands/tab-open.ts +19 -0
- package/apps/browserctl/src/commands/tabs.ts +13 -0
- package/apps/browserctl/src/commands/upload-arm.ts +26 -0
- package/apps/browserctl/src/daemon-client.test.ts +253 -0
- package/apps/browserctl/src/daemon-client.ts +632 -0
- package/apps/browserctl/src/e2e.test.ts +99 -0
- package/apps/browserctl/src/main.test.ts +215 -0
- package/apps/browserctl/src/main.ts +372 -0
- package/apps/browserctl/src/smoke.test.ts +16 -0
- package/apps/browserctl/src/smoke.ts +5 -0
- package/apps/browserd/src/bootstrap.ts +432 -0
- package/apps/browserd/src/chrome-relay-extension-bridge.test.ts +275 -0
- package/apps/browserd/src/chrome-relay-extension-bridge.ts +506 -0
- package/apps/browserd/src/container.ts +1531 -0
- package/apps/browserd/src/main.test.ts +864 -0
- package/apps/browserd/src/main.ts +7 -0
- package/bin/browserctl.cjs +21 -0
- package/bin/browserd.cjs +21 -0
- package/extensions/chrome-relay/README-CN.md +38 -0
- package/extensions/chrome-relay/README.md +38 -0
- package/extensions/chrome-relay/background.js +1687 -0
- package/extensions/chrome-relay/manifest.json +15 -0
- package/extensions/chrome-relay/popup.html +369 -0
- package/extensions/chrome-relay/popup.js +972 -0
- package/package.json +51 -0
- package/packages/core/src/bootstrap.test.ts +10 -0
- package/packages/core/src/driver-registry.test.ts +45 -0
- package/packages/core/src/driver-registry.ts +22 -0
- package/packages/core/src/driver.ts +47 -0
- package/packages/core/src/index.ts +5 -0
- package/packages/core/src/ref-cache.test.ts +61 -0
- package/packages/core/src/ref-cache.ts +28 -0
- package/packages/core/src/session-store.test.ts +49 -0
- package/packages/core/src/session-store.ts +33 -0
- package/packages/core/src/types.ts +9 -0
- package/packages/driver-chrome-relay/src/chrome-relay-driver.test.ts +634 -0
- package/packages/driver-chrome-relay/src/chrome-relay-driver.ts +2206 -0
- package/packages/driver-chrome-relay/src/chrome-relay-extension-runtime.test.ts +264 -0
- package/packages/driver-chrome-relay/src/chrome-relay-extension-runtime.ts +521 -0
- package/packages/driver-chrome-relay/src/index.ts +26 -0
- package/packages/driver-managed/src/index.ts +22 -0
- package/packages/driver-managed/src/managed-driver.test.ts +59 -0
- package/packages/driver-managed/src/managed-driver.ts +125 -0
- package/packages/driver-managed/src/managed-local-driver.test.ts +506 -0
- package/packages/driver-managed/src/managed-local-driver.ts +2021 -0
- package/packages/driver-remote-cdp/src/index.ts +19 -0
- package/packages/driver-remote-cdp/src/remote-cdp-driver.test.ts +617 -0
- package/packages/driver-remote-cdp/src/remote-cdp-driver.ts +2042 -0
- package/packages/protocol/src/envelope.test.ts +25 -0
- package/packages/protocol/src/envelope.ts +31 -0
- package/packages/protocol/src/errors.test.ts +17 -0
- package/packages/protocol/src/errors.ts +11 -0
- package/packages/protocol/src/index.ts +3 -0
- package/packages/protocol/src/tools.ts +3 -0
- package/packages/transport-mcp-stdio/src/index.ts +3 -0
- package/packages/transport-mcp-stdio/src/sdk-server.ts +139 -0
- package/packages/transport-mcp-stdio/src/server.test.ts +281 -0
- package/packages/transport-mcp-stdio/src/server.ts +183 -0
- package/packages/transport-mcp-stdio/src/tool-map.ts +67 -0
- package/scripts/smoke.ps1 +127 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
|
|
3
|
+
const { callDaemonToolMock } = vi.hoisted(() => ({
|
|
4
|
+
callDaemonToolMock: vi.fn()
|
|
5
|
+
}));
|
|
6
|
+
|
|
7
|
+
vi.mock("../daemon-client", () => ({
|
|
8
|
+
callDaemonTool: callDaemonToolMock
|
|
9
|
+
}));
|
|
10
|
+
|
|
11
|
+
import { runDownloadWaitCommand } from "./download-wait";
|
|
12
|
+
|
|
13
|
+
const ORIGINAL_AUTH_TOKEN = process.env.BROWSERCTL_AUTH_TOKEN;
|
|
14
|
+
|
|
15
|
+
afterEach(() => {
|
|
16
|
+
callDaemonToolMock.mockReset();
|
|
17
|
+
|
|
18
|
+
if (ORIGINAL_AUTH_TOKEN === undefined) {
|
|
19
|
+
delete process.env.BROWSERCTL_AUTH_TOKEN;
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
process.env.BROWSERCTL_AUTH_TOKEN = ORIGINAL_AUTH_TOKEN;
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
describe("runDownloadWaitCommand", () => {
|
|
27
|
+
it("forwards optional download path when provided", async () => {
|
|
28
|
+
callDaemonToolMock.mockResolvedValue({
|
|
29
|
+
driver: "managed",
|
|
30
|
+
targetId: "target:1",
|
|
31
|
+
download: {}
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
await runDownloadWaitCommand(["target:1", "downloads/file.bin"]);
|
|
35
|
+
|
|
36
|
+
expect(callDaemonToolMock).toHaveBeenCalledTimes(1);
|
|
37
|
+
expect(callDaemonToolMock).toHaveBeenCalledWith(
|
|
38
|
+
"browser.download.wait",
|
|
39
|
+
expect.objectContaining({
|
|
40
|
+
sessionId: "cli:local",
|
|
41
|
+
targetId: "target:1",
|
|
42
|
+
path: "downloads/file.bin"
|
|
43
|
+
})
|
|
44
|
+
);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("uses --token over environment token", async () => {
|
|
48
|
+
process.env.BROWSERCTL_AUTH_TOKEN = "env-token";
|
|
49
|
+
callDaemonToolMock.mockResolvedValue({
|
|
50
|
+
driver: "managed",
|
|
51
|
+
targetId: "target:1",
|
|
52
|
+
download: {}
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
await runDownloadWaitCommand(["--token", "cli-token", "target:1"]);
|
|
56
|
+
|
|
57
|
+
expect(callDaemonToolMock).toHaveBeenCalledTimes(1);
|
|
58
|
+
expect(callDaemonToolMock).toHaveBeenCalledWith(
|
|
59
|
+
"browser.download.wait",
|
|
60
|
+
expect.objectContaining({
|
|
61
|
+
sessionId: "cli:local",
|
|
62
|
+
targetId: "target:1",
|
|
63
|
+
authToken: "cli-token"
|
|
64
|
+
})
|
|
65
|
+
);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { callDaemonTool } from "../daemon-client";
|
|
2
|
+
import { buildToolArguments, parseCommandContext, requirePositionalArg } from "./common";
|
|
3
|
+
|
|
4
|
+
export type DownloadWaitCommandResult = {
|
|
5
|
+
driver: string;
|
|
6
|
+
targetId: string;
|
|
7
|
+
download: Record<string, unknown>;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export async function runDownloadWaitCommand(args: string[]): Promise<DownloadWaitCommandResult> {
|
|
11
|
+
const context = parseCommandContext(args);
|
|
12
|
+
const targetId = requirePositionalArg(context, 0, "targetId");
|
|
13
|
+
const path = context.positional[1];
|
|
14
|
+
|
|
15
|
+
return await callDaemonTool<DownloadWaitCommandResult>(
|
|
16
|
+
"browser.download.wait",
|
|
17
|
+
buildToolArguments(
|
|
18
|
+
context,
|
|
19
|
+
path === undefined
|
|
20
|
+
? { targetId }
|
|
21
|
+
: {
|
|
22
|
+
targetId,
|
|
23
|
+
path
|
|
24
|
+
}
|
|
25
|
+
)
|
|
26
|
+
);
|
|
27
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { callDaemonTool } from "../daemon-client";
|
|
2
|
+
import { buildToolArguments, parseCommandContext, requirePositionalArg } from "./common";
|
|
3
|
+
|
|
4
|
+
export type ElementScreenshotCommandResult = Record<string, unknown>;
|
|
5
|
+
|
|
6
|
+
export async function runElementScreenshotCommand(
|
|
7
|
+
args: string[]
|
|
8
|
+
): Promise<ElementScreenshotCommandResult> {
|
|
9
|
+
const context = parseCommandContext(args);
|
|
10
|
+
const targetId = requirePositionalArg(context, 0, "targetId");
|
|
11
|
+
const selector = requirePositionalArg(context, 1, "selector");
|
|
12
|
+
|
|
13
|
+
return await callDaemonTool<ElementScreenshotCommandResult>(
|
|
14
|
+
"browser.element.screenshot",
|
|
15
|
+
buildToolArguments(context, {
|
|
16
|
+
targetId,
|
|
17
|
+
selector
|
|
18
|
+
})
|
|
19
|
+
);
|
|
20
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { callDaemonTool } from "../daemon-client";
|
|
2
|
+
import { buildToolArguments, parseCommandContext, requirePositionalArg } from "./common";
|
|
3
|
+
|
|
4
|
+
export type FrameListCommandResult = Record<string, unknown>;
|
|
5
|
+
|
|
6
|
+
export async function runFrameListCommand(args: string[]): Promise<FrameListCommandResult> {
|
|
7
|
+
const context = parseCommandContext(args);
|
|
8
|
+
const targetId = requirePositionalArg(context, 0, "targetId");
|
|
9
|
+
|
|
10
|
+
return await callDaemonTool<FrameListCommandResult>(
|
|
11
|
+
"browser.frame.list",
|
|
12
|
+
buildToolArguments(context, {
|
|
13
|
+
targetId
|
|
14
|
+
})
|
|
15
|
+
);
|
|
16
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { callDaemonTool } from "../daemon-client";
|
|
2
|
+
import { buildToolArguments, parseCommandContext, requirePositionalArg } from "./common";
|
|
3
|
+
|
|
4
|
+
export type FrameSnapshotCommandResult = Record<string, unknown>;
|
|
5
|
+
|
|
6
|
+
export async function runFrameSnapshotCommand(args: string[]): Promise<FrameSnapshotCommandResult> {
|
|
7
|
+
const context = parseCommandContext(args);
|
|
8
|
+
const targetId = requirePositionalArg(context, 0, "targetId");
|
|
9
|
+
const frameId = requirePositionalArg(context, 1, "frameId");
|
|
10
|
+
|
|
11
|
+
return await callDaemonTool<FrameSnapshotCommandResult>(
|
|
12
|
+
"browser.frame.snapshot",
|
|
13
|
+
buildToolArguments(context, {
|
|
14
|
+
targetId,
|
|
15
|
+
frameId
|
|
16
|
+
})
|
|
17
|
+
);
|
|
18
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { callDaemonTool } from "../daemon-client";
|
|
2
|
+
import { buildToolArguments, parseCommandContext, requirePositionalArg } from "./common";
|
|
3
|
+
|
|
4
|
+
export type NetworkWaitForCommandResult = Record<string, unknown>;
|
|
5
|
+
|
|
6
|
+
function parsePositiveInteger(value: string, optionName: string): number {
|
|
7
|
+
const parsed = Number.parseInt(value, 10);
|
|
8
|
+
if (!Number.isFinite(parsed) || parsed <= 0) {
|
|
9
|
+
throw new Error(`${optionName} must be a positive integer.`);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return parsed;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function parseNetworkWaitOptions(tokens: string[]): {
|
|
16
|
+
method?: string;
|
|
17
|
+
status?: number;
|
|
18
|
+
timeoutMs?: number;
|
|
19
|
+
pollMs?: number;
|
|
20
|
+
} {
|
|
21
|
+
let method: string | undefined;
|
|
22
|
+
let status: number | undefined;
|
|
23
|
+
let timeoutMs: number | undefined;
|
|
24
|
+
let pollMs: number | undefined;
|
|
25
|
+
|
|
26
|
+
for (let index = 0; index < tokens.length; index += 1) {
|
|
27
|
+
const token = tokens[index];
|
|
28
|
+
if (token === "--method") {
|
|
29
|
+
const value = tokens[index + 1];
|
|
30
|
+
if (value === undefined) {
|
|
31
|
+
throw new Error("Missing value for --method.");
|
|
32
|
+
}
|
|
33
|
+
method = value.trim().toUpperCase();
|
|
34
|
+
index += 1;
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (token === "--status") {
|
|
39
|
+
const value = tokens[index + 1];
|
|
40
|
+
if (value === undefined) {
|
|
41
|
+
throw new Error("Missing value for --status.");
|
|
42
|
+
}
|
|
43
|
+
status = parsePositiveInteger(value, "--status");
|
|
44
|
+
index += 1;
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (token === "--timeout-ms") {
|
|
49
|
+
const value = tokens[index + 1];
|
|
50
|
+
if (value === undefined) {
|
|
51
|
+
throw new Error("Missing value for --timeout-ms.");
|
|
52
|
+
}
|
|
53
|
+
timeoutMs = parsePositiveInteger(value, "--timeout-ms");
|
|
54
|
+
index += 1;
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (token === "--poll-ms") {
|
|
59
|
+
const value = tokens[index + 1];
|
|
60
|
+
if (value === undefined) {
|
|
61
|
+
throw new Error("Missing value for --poll-ms.");
|
|
62
|
+
}
|
|
63
|
+
pollMs = parsePositiveInteger(value, "--poll-ms");
|
|
64
|
+
index += 1;
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (timeoutMs === undefined) {
|
|
69
|
+
timeoutMs = parsePositiveInteger(token, "timeoutMs");
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
throw new Error(`Unknown network-wait-for option: ${token}`);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return {
|
|
77
|
+
...(method !== undefined ? { method } : {}),
|
|
78
|
+
...(status !== undefined ? { status } : {}),
|
|
79
|
+
...(timeoutMs !== undefined ? { timeoutMs } : {}),
|
|
80
|
+
...(pollMs !== undefined ? { pollMs } : {})
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export async function runNetworkWaitForCommand(
|
|
85
|
+
args: string[]
|
|
86
|
+
): Promise<NetworkWaitForCommandResult> {
|
|
87
|
+
const context = parseCommandContext(args);
|
|
88
|
+
const targetId = requirePositionalArg(context, 0, "targetId");
|
|
89
|
+
const urlPattern = requirePositionalArg(context, 1, "urlPattern");
|
|
90
|
+
const options = parseNetworkWaitOptions(context.positional.slice(2));
|
|
91
|
+
|
|
92
|
+
return await callDaemonTool<NetworkWaitForCommandResult>(
|
|
93
|
+
"browser.network.waitFor",
|
|
94
|
+
buildToolArguments(context, {
|
|
95
|
+
targetId,
|
|
96
|
+
urlPattern,
|
|
97
|
+
...options
|
|
98
|
+
})
|
|
99
|
+
);
|
|
100
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { callDaemonTool } from "../daemon-client";
|
|
2
|
+
import { buildToolArguments, parseCommandContext } from "./common";
|
|
3
|
+
|
|
4
|
+
export type ProfileListCommandResult = {
|
|
5
|
+
driver: string;
|
|
6
|
+
profiles: string[];
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export async function runProfileListCommand(args: string[] = []): Promise<ProfileListCommandResult> {
|
|
10
|
+
const context = parseCommandContext(args);
|
|
11
|
+
|
|
12
|
+
return await callDaemonTool<ProfileListCommandResult>(
|
|
13
|
+
"browser.profile.list",
|
|
14
|
+
buildToolArguments(context)
|
|
15
|
+
);
|
|
16
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { callDaemonTool } from "../daemon-client";
|
|
2
|
+
import { buildToolArguments, parseCommandContext, requirePositionalArg } from "./common";
|
|
3
|
+
|
|
4
|
+
export type ProfileUseCommandResult = {
|
|
5
|
+
profile: string;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export async function runProfileUseCommand(args: string[]): Promise<ProfileUseCommandResult> {
|
|
9
|
+
const context = parseCommandContext(args);
|
|
10
|
+
const profile = requirePositionalArg(context, 0, "profile");
|
|
11
|
+
|
|
12
|
+
return await callDaemonTool<ProfileUseCommandResult>(
|
|
13
|
+
"browser.profile.use",
|
|
14
|
+
buildToolArguments(context, {
|
|
15
|
+
profile
|
|
16
|
+
})
|
|
17
|
+
);
|
|
18
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { callDaemonTool } from "../daemon-client";
|
|
2
|
+
import { buildToolArguments, parseCommandContext, requirePositionalArg } from "./common";
|
|
3
|
+
|
|
4
|
+
export type ResponseBodyCommandResult = {
|
|
5
|
+
driver: string;
|
|
6
|
+
targetId: string;
|
|
7
|
+
requestId: string;
|
|
8
|
+
body: string;
|
|
9
|
+
encoding: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export async function runResponseBodyCommand(args: string[]): Promise<ResponseBodyCommandResult> {
|
|
13
|
+
const context = parseCommandContext(args);
|
|
14
|
+
const targetId = requirePositionalArg(context, 0, "targetId");
|
|
15
|
+
const requestId = requirePositionalArg(context, 1, "requestId");
|
|
16
|
+
|
|
17
|
+
return await callDaemonTool<ResponseBodyCommandResult>(
|
|
18
|
+
"browser.network.responseBody",
|
|
19
|
+
buildToolArguments(context, {
|
|
20
|
+
targetId,
|
|
21
|
+
requestId
|
|
22
|
+
})
|
|
23
|
+
);
|
|
24
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { callDaemonTool } from "../daemon-client";
|
|
2
|
+
import { buildToolArguments, parseCommandContext, requirePositionalArg } from "./common";
|
|
3
|
+
|
|
4
|
+
export type ScreenshotCommandResult = Record<string, unknown>;
|
|
5
|
+
|
|
6
|
+
export async function runScreenshotCommand(args: string[]): Promise<ScreenshotCommandResult> {
|
|
7
|
+
const context = parseCommandContext(args);
|
|
8
|
+
const targetId = requirePositionalArg(context, 0, "targetId");
|
|
9
|
+
|
|
10
|
+
return await callDaemonTool<ScreenshotCommandResult>(
|
|
11
|
+
"browser.screenshot",
|
|
12
|
+
buildToolArguments(context, {
|
|
13
|
+
targetId
|
|
14
|
+
})
|
|
15
|
+
);
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { callDaemonTool } from "../daemon-client";
|
|
2
|
+
import { buildToolArguments, parseCommandContext, requirePositionalArg } from "./common";
|
|
3
|
+
|
|
4
|
+
export type SnapshotCommandResult = Record<string, unknown>;
|
|
5
|
+
|
|
6
|
+
export async function runSnapshotCommand(args: string[]): Promise<SnapshotCommandResult> {
|
|
7
|
+
const context = parseCommandContext(args);
|
|
8
|
+
const targetId = requirePositionalArg(context, 0, "targetId");
|
|
9
|
+
|
|
10
|
+
return await callDaemonTool<SnapshotCommandResult>(
|
|
11
|
+
"browser.snapshot",
|
|
12
|
+
buildToolArguments(context, {
|
|
13
|
+
targetId
|
|
14
|
+
})
|
|
15
|
+
);
|
|
16
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { callDaemonTool } from "../daemon-client";
|
|
2
|
+
import { buildToolArguments, parseCommandContext } from "./common";
|
|
3
|
+
|
|
4
|
+
export type StatusCommandResult = Record<string, unknown>;
|
|
5
|
+
|
|
6
|
+
export async function runStatusCommand(args: string[] = []): Promise<StatusCommandResult> {
|
|
7
|
+
const context = parseCommandContext(args);
|
|
8
|
+
|
|
9
|
+
return await callDaemonTool<StatusCommandResult>("browser.status", buildToolArguments(context));
|
|
10
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { callDaemonTool } from "../daemon-client";
|
|
2
|
+
import { buildToolArguments, parseCommandContext, requirePositionalArg } from "./common";
|
|
3
|
+
|
|
4
|
+
export type StorageGetCommandResult = Record<string, unknown>;
|
|
5
|
+
|
|
6
|
+
export async function runStorageGetCommand(args: string[]): Promise<StorageGetCommandResult> {
|
|
7
|
+
const context = parseCommandContext(args);
|
|
8
|
+
const targetId = requirePositionalArg(context, 0, "targetId");
|
|
9
|
+
const scope = requirePositionalArg(context, 1, "scope");
|
|
10
|
+
const key = requirePositionalArg(context, 2, "key");
|
|
11
|
+
|
|
12
|
+
return await callDaemonTool<StorageGetCommandResult>(
|
|
13
|
+
"browser.storage.get",
|
|
14
|
+
buildToolArguments(context, {
|
|
15
|
+
targetId,
|
|
16
|
+
scope,
|
|
17
|
+
key
|
|
18
|
+
})
|
|
19
|
+
);
|
|
20
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { callDaemonTool } from "../daemon-client";
|
|
2
|
+
import { buildToolArguments, parseCommandContext, requirePositionalArg } from "./common";
|
|
3
|
+
|
|
4
|
+
export type StorageSetCommandResult = Record<string, unknown>;
|
|
5
|
+
|
|
6
|
+
export async function runStorageSetCommand(args: string[]): Promise<StorageSetCommandResult> {
|
|
7
|
+
const context = parseCommandContext(args);
|
|
8
|
+
const targetId = requirePositionalArg(context, 0, "targetId");
|
|
9
|
+
const scope = requirePositionalArg(context, 1, "scope");
|
|
10
|
+
const key = requirePositionalArg(context, 2, "key");
|
|
11
|
+
const value = requirePositionalArg(context, 3, "value");
|
|
12
|
+
|
|
13
|
+
return await callDaemonTool<StorageSetCommandResult>(
|
|
14
|
+
"browser.storage.set",
|
|
15
|
+
buildToolArguments(context, {
|
|
16
|
+
targetId,
|
|
17
|
+
scope,
|
|
18
|
+
key,
|
|
19
|
+
value
|
|
20
|
+
})
|
|
21
|
+
);
|
|
22
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { callDaemonTool } from "../daemon-client";
|
|
2
|
+
import { buildToolArguments, parseCommandContext, requirePositionalArg } from "./common";
|
|
3
|
+
|
|
4
|
+
export type TabCloseCommandResult = {
|
|
5
|
+
driver: string;
|
|
6
|
+
targetId: string;
|
|
7
|
+
closed: boolean;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export async function runTabCloseCommand(args: string[]): Promise<TabCloseCommandResult> {
|
|
11
|
+
const context = parseCommandContext(args);
|
|
12
|
+
const targetId = requirePositionalArg(context, 0, "targetId");
|
|
13
|
+
|
|
14
|
+
return await callDaemonTool<TabCloseCommandResult>(
|
|
15
|
+
"browser.tab.close",
|
|
16
|
+
buildToolArguments(context, {
|
|
17
|
+
targetId
|
|
18
|
+
})
|
|
19
|
+
);
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { callDaemonTool } from "../daemon-client";
|
|
2
|
+
import { buildToolArguments, parseCommandContext, requirePositionalArg } from "./common";
|
|
3
|
+
|
|
4
|
+
export type TabFocusCommandResult = {
|
|
5
|
+
driver: string;
|
|
6
|
+
targetId: string;
|
|
7
|
+
focused: boolean;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export async function runTabFocusCommand(args: string[]): Promise<TabFocusCommandResult> {
|
|
11
|
+
const context = parseCommandContext(args);
|
|
12
|
+
const targetId = requirePositionalArg(context, 0, "targetId");
|
|
13
|
+
|
|
14
|
+
return await callDaemonTool<TabFocusCommandResult>(
|
|
15
|
+
"browser.tab.focus",
|
|
16
|
+
buildToolArguments(context, {
|
|
17
|
+
targetId
|
|
18
|
+
})
|
|
19
|
+
);
|
|
20
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { callDaemonTool } from "../daemon-client";
|
|
2
|
+
import { buildToolArguments, parseCommandContext, requirePositionalArg } from "./common";
|
|
3
|
+
|
|
4
|
+
export type TabOpenCommandResult = {
|
|
5
|
+
driver: string;
|
|
6
|
+
targetId: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export async function runTabOpenCommand(args: string[]): Promise<TabOpenCommandResult> {
|
|
10
|
+
const context = parseCommandContext(args);
|
|
11
|
+
const url = requirePositionalArg(context, 0, "url");
|
|
12
|
+
|
|
13
|
+
return await callDaemonTool<TabOpenCommandResult>(
|
|
14
|
+
"browser.tab.open",
|
|
15
|
+
buildToolArguments(context, {
|
|
16
|
+
url
|
|
17
|
+
})
|
|
18
|
+
);
|
|
19
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { callDaemonTool } from "../daemon-client";
|
|
2
|
+
import { buildToolArguments, parseCommandContext } from "./common";
|
|
3
|
+
|
|
4
|
+
export type TabsCommandResult = {
|
|
5
|
+
driver: string;
|
|
6
|
+
tabs: string[];
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export async function runTabsCommand(args: string[] = []): Promise<TabsCommandResult> {
|
|
10
|
+
const context = parseCommandContext(args);
|
|
11
|
+
|
|
12
|
+
return await callDaemonTool<TabsCommandResult>("browser.tab.list", buildToolArguments(context));
|
|
13
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { callDaemonTool } from "../daemon-client";
|
|
2
|
+
import { buildToolArguments, parseCommandContext, requirePositionalArg } from "./common";
|
|
3
|
+
|
|
4
|
+
export type UploadArmCommandResult = {
|
|
5
|
+
driver: string;
|
|
6
|
+
targetId: string;
|
|
7
|
+
armed: boolean;
|
|
8
|
+
files: string[];
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export async function runUploadArmCommand(args: string[]): Promise<UploadArmCommandResult> {
|
|
12
|
+
const context = parseCommandContext(args);
|
|
13
|
+
const targetId = requirePositionalArg(context, 0, "targetId");
|
|
14
|
+
const files = context.positional.slice(1);
|
|
15
|
+
if (files.length === 0) {
|
|
16
|
+
throw new Error("Missing required argument: files.");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return await callDaemonTool<UploadArmCommandResult>(
|
|
20
|
+
"browser.upload.arm",
|
|
21
|
+
buildToolArguments(context, {
|
|
22
|
+
targetId,
|
|
23
|
+
files
|
|
24
|
+
})
|
|
25
|
+
);
|
|
26
|
+
}
|