style: fix lint
This commit is contained in:
@@ -8,7 +8,10 @@ import { ensurePortAvailable } from "../infra/ports.js";
|
||||
import { createSubsystemLogger } from "../logging.js";
|
||||
import { CONFIG_DIR } from "../utils.js";
|
||||
import { normalizeCdpWsUrl } from "./cdp.js";
|
||||
import type { ResolvedBrowserConfig, ResolvedBrowserProfile } from "./config.js";
|
||||
import type {
|
||||
ResolvedBrowserConfig,
|
||||
ResolvedBrowserProfile,
|
||||
} from "./config.js";
|
||||
import {
|
||||
DEFAULT_CLAWD_BROWSER_COLOR,
|
||||
DEFAULT_CLAWD_BROWSER_PROFILE_NAME,
|
||||
@@ -119,12 +122,7 @@ function resolveBrowserExecutable(
|
||||
export function resolveClawdUserDataDir(
|
||||
profileName = DEFAULT_CLAWD_BROWSER_PROFILE_NAME,
|
||||
) {
|
||||
return path.join(
|
||||
CONFIG_DIR,
|
||||
"browser",
|
||||
profileName,
|
||||
"user-data",
|
||||
);
|
||||
return path.join(CONFIG_DIR, "browser", profileName, "user-data");
|
||||
}
|
||||
|
||||
function decoratedMarkerPath(userDataDir: string) {
|
||||
|
||||
@@ -27,13 +27,10 @@ export async function browserPdfSave(
|
||||
opts: { targetId?: string; profile?: string } = {},
|
||||
): Promise<BrowserActionPathResult> {
|
||||
const q = buildProfileQuery(opts.profile);
|
||||
return await fetchBrowserJson<BrowserActionPathResult>(
|
||||
`${baseUrl}/pdf${q}`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ targetId: opts.targetId }),
|
||||
timeoutMs: 20000,
|
||||
},
|
||||
);
|
||||
return await fetchBrowserJson<BrowserActionPathResult>(`${baseUrl}/pdf${q}`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ targetId: opts.targetId }),
|
||||
timeoutMs: 20000,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -98,12 +98,16 @@ export function registerBrowserActionInputCommands(
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const result = await browserAct(baseUrl, {
|
||||
kind: "resize",
|
||||
width,
|
||||
height,
|
||||
targetId: opts.targetId?.trim() || undefined,
|
||||
}, { profile });
|
||||
const result = await browserAct(
|
||||
baseUrl,
|
||||
{
|
||||
kind: "resize",
|
||||
width,
|
||||
height,
|
||||
targetId: opts.targetId?.trim() || undefined,
|
||||
},
|
||||
{ profile },
|
||||
);
|
||||
if (parent?.json) {
|
||||
defaultRuntime.log(JSON.stringify(result, null, 2));
|
||||
return;
|
||||
@@ -140,14 +144,18 @@ export function registerBrowserActionInputCommands(
|
||||
.filter(Boolean)
|
||||
: undefined;
|
||||
try {
|
||||
const result = await browserAct(baseUrl, {
|
||||
kind: "click",
|
||||
ref: refValue,
|
||||
targetId: opts.targetId?.trim() || undefined,
|
||||
doubleClick: Boolean(opts.double),
|
||||
button: opts.button?.trim() || undefined,
|
||||
modifiers,
|
||||
}, { profile });
|
||||
const result = await browserAct(
|
||||
baseUrl,
|
||||
{
|
||||
kind: "click",
|
||||
ref: refValue,
|
||||
targetId: opts.targetId?.trim() || undefined,
|
||||
doubleClick: Boolean(opts.double),
|
||||
button: opts.button?.trim() || undefined,
|
||||
modifiers,
|
||||
},
|
||||
{ profile },
|
||||
);
|
||||
if (parent?.json) {
|
||||
defaultRuntime.log(JSON.stringify(result, null, 2));
|
||||
return;
|
||||
@@ -179,14 +187,18 @@ export function registerBrowserActionInputCommands(
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const result = await browserAct(baseUrl, {
|
||||
kind: "type",
|
||||
ref: refValue,
|
||||
text,
|
||||
submit: Boolean(opts.submit),
|
||||
slowly: Boolean(opts.slowly),
|
||||
targetId: opts.targetId?.trim() || undefined,
|
||||
}, { profile });
|
||||
const result = await browserAct(
|
||||
baseUrl,
|
||||
{
|
||||
kind: "type",
|
||||
ref: refValue,
|
||||
text,
|
||||
submit: Boolean(opts.submit),
|
||||
slowly: Boolean(opts.slowly),
|
||||
targetId: opts.targetId?.trim() || undefined,
|
||||
},
|
||||
{ profile },
|
||||
);
|
||||
if (parent?.json) {
|
||||
defaultRuntime.log(JSON.stringify(result, null, 2));
|
||||
return;
|
||||
@@ -208,11 +220,15 @@ export function registerBrowserActionInputCommands(
|
||||
const baseUrl = resolveBrowserControlUrl(parent?.url);
|
||||
const profile = parent?.profile;
|
||||
try {
|
||||
const result = await browserAct(baseUrl, {
|
||||
kind: "press",
|
||||
key,
|
||||
targetId: opts.targetId?.trim() || undefined,
|
||||
}, { profile });
|
||||
const result = await browserAct(
|
||||
baseUrl,
|
||||
{
|
||||
kind: "press",
|
||||
key,
|
||||
targetId: opts.targetId?.trim() || undefined,
|
||||
},
|
||||
{ profile },
|
||||
);
|
||||
if (parent?.json) {
|
||||
defaultRuntime.log(JSON.stringify(result, null, 2));
|
||||
return;
|
||||
@@ -234,11 +250,15 @@ export function registerBrowserActionInputCommands(
|
||||
const baseUrl = resolveBrowserControlUrl(parent?.url);
|
||||
const profile = parent?.profile;
|
||||
try {
|
||||
const result = await browserAct(baseUrl, {
|
||||
kind: "hover",
|
||||
ref,
|
||||
targetId: opts.targetId?.trim() || undefined,
|
||||
}, { profile });
|
||||
const result = await browserAct(
|
||||
baseUrl,
|
||||
{
|
||||
kind: "hover",
|
||||
ref,
|
||||
targetId: opts.targetId?.trim() || undefined,
|
||||
},
|
||||
{ profile },
|
||||
);
|
||||
if (parent?.json) {
|
||||
defaultRuntime.log(JSON.stringify(result, null, 2));
|
||||
return;
|
||||
@@ -261,12 +281,16 @@ export function registerBrowserActionInputCommands(
|
||||
const baseUrl = resolveBrowserControlUrl(parent?.url);
|
||||
const profile = parent?.profile;
|
||||
try {
|
||||
const result = await browserAct(baseUrl, {
|
||||
kind: "drag",
|
||||
startRef,
|
||||
endRef,
|
||||
targetId: opts.targetId?.trim() || undefined,
|
||||
}, { profile });
|
||||
const result = await browserAct(
|
||||
baseUrl,
|
||||
{
|
||||
kind: "drag",
|
||||
startRef,
|
||||
endRef,
|
||||
targetId: opts.targetId?.trim() || undefined,
|
||||
},
|
||||
{ profile },
|
||||
);
|
||||
if (parent?.json) {
|
||||
defaultRuntime.log(JSON.stringify(result, null, 2));
|
||||
return;
|
||||
@@ -289,12 +313,16 @@ export function registerBrowserActionInputCommands(
|
||||
const baseUrl = resolveBrowserControlUrl(parent?.url);
|
||||
const profile = parent?.profile;
|
||||
try {
|
||||
const result = await browserAct(baseUrl, {
|
||||
kind: "select",
|
||||
ref,
|
||||
values,
|
||||
targetId: opts.targetId?.trim() || undefined,
|
||||
}, { profile });
|
||||
const result = await browserAct(
|
||||
baseUrl,
|
||||
{
|
||||
kind: "select",
|
||||
ref,
|
||||
values,
|
||||
targetId: opts.targetId?.trim() || undefined,
|
||||
},
|
||||
{ profile },
|
||||
);
|
||||
if (parent?.json) {
|
||||
defaultRuntime.log(JSON.stringify(result, null, 2));
|
||||
return;
|
||||
@@ -361,11 +389,15 @@ export function registerBrowserActionInputCommands(
|
||||
fields: opts.fields,
|
||||
fieldsFile: opts.fieldsFile,
|
||||
});
|
||||
const result = await browserAct(baseUrl, {
|
||||
kind: "fill",
|
||||
fields,
|
||||
targetId: opts.targetId?.trim() || undefined,
|
||||
}, { profile });
|
||||
const result = await browserAct(
|
||||
baseUrl,
|
||||
{
|
||||
kind: "fill",
|
||||
fields,
|
||||
targetId: opts.targetId?.trim() || undefined,
|
||||
},
|
||||
{ profile },
|
||||
);
|
||||
if (parent?.json) {
|
||||
defaultRuntime.log(JSON.stringify(result, null, 2));
|
||||
return;
|
||||
@@ -432,13 +464,17 @@ export function registerBrowserActionInputCommands(
|
||||
const baseUrl = resolveBrowserControlUrl(parent?.url);
|
||||
const profile = parent?.profile;
|
||||
try {
|
||||
const result = await browserAct(baseUrl, {
|
||||
kind: "wait",
|
||||
timeMs: Number.isFinite(opts.time) ? opts.time : undefined,
|
||||
text: opts.text?.trim() || undefined,
|
||||
textGone: opts.textGone?.trim() || undefined,
|
||||
targetId: opts.targetId?.trim() || undefined,
|
||||
}, { profile });
|
||||
const result = await browserAct(
|
||||
baseUrl,
|
||||
{
|
||||
kind: "wait",
|
||||
timeMs: Number.isFinite(opts.time) ? opts.time : undefined,
|
||||
text: opts.text?.trim() || undefined,
|
||||
textGone: opts.textGone?.trim() || undefined,
|
||||
targetId: opts.targetId?.trim() || undefined,
|
||||
},
|
||||
{ profile },
|
||||
);
|
||||
if (parent?.json) {
|
||||
defaultRuntime.log(JSON.stringify(result, null, 2));
|
||||
return;
|
||||
@@ -466,12 +502,16 @@ export function registerBrowserActionInputCommands(
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const result = await browserAct(baseUrl, {
|
||||
kind: "evaluate",
|
||||
fn: opts.fn,
|
||||
ref: opts.ref?.trim() || undefined,
|
||||
targetId: opts.targetId?.trim() || undefined,
|
||||
}, { profile });
|
||||
const result = await browserAct(
|
||||
baseUrl,
|
||||
{
|
||||
kind: "evaluate",
|
||||
fn: opts.fn,
|
||||
ref: opts.ref?.trim() || undefined,
|
||||
targetId: opts.targetId?.trim() || undefined,
|
||||
},
|
||||
{ profile },
|
||||
);
|
||||
if (parent?.json) {
|
||||
defaultRuntime.log(JSON.stringify(result, null, 2));
|
||||
return;
|
||||
|
||||
@@ -1 +1,5 @@
|
||||
export type BrowserParentOpts = { url?: string; json?: boolean; profile?: string };
|
||||
export type BrowserParentOpts = {
|
||||
url?: string;
|
||||
json?: boolean;
|
||||
profile?: string;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user