mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-10 12:42:52 +00:00
45 lines
1.2 KiB
TypeScript
45 lines
1.2 KiB
TypeScript
import { ACT_MAX_VIEWPORT_DIMENSION } from "../browser/act-policy.js";
|
|
import { callBrowserResize, type BrowserParentOpts } from "./browser-cli-shared.js";
|
|
import { danger, defaultRuntime } from "./core-api.js";
|
|
|
|
export async function runBrowserResizeWithOutput(params: {
|
|
parent: BrowserParentOpts;
|
|
profile?: string;
|
|
width: number;
|
|
height: number;
|
|
targetId?: string;
|
|
timeoutMs?: number;
|
|
successMessage: string;
|
|
}): Promise<void> {
|
|
const { width, height } = params;
|
|
if (!Number.isFinite(width) || !Number.isFinite(height)) {
|
|
defaultRuntime.error(danger("width and height must be numbers"));
|
|
defaultRuntime.exit(1);
|
|
return;
|
|
}
|
|
if (width > ACT_MAX_VIEWPORT_DIMENSION || height > ACT_MAX_VIEWPORT_DIMENSION) {
|
|
defaultRuntime.error(
|
|
danger(`width and height must not exceed ${ACT_MAX_VIEWPORT_DIMENSION}`),
|
|
);
|
|
defaultRuntime.exit(1);
|
|
return;
|
|
}
|
|
|
|
const result = await callBrowserResize(
|
|
params.parent,
|
|
{
|
|
profile: params.profile,
|
|
width,
|
|
height,
|
|
targetId: params.targetId,
|
|
},
|
|
{ timeoutMs: params.timeoutMs ?? 20000 },
|
|
);
|
|
|
|
if (params.parent?.json) {
|
|
defaultRuntime.writeJson(result);
|
|
return;
|
|
}
|
|
defaultRuntime.log(params.successMessage);
|
|
}
|