UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

77 lines (76 loc) • 3.53 kB
import { g as readStringValue, l as normalizeOptionalString } from "./string-coerce-CCIiB4H7.mjs"; import { p as shortenHomePath } from "./utils-C8YECn2Q.mjs"; import "./string-coerce-runtime-BwAZZDf5.mjs"; import "./text-utility-runtime-Ds8jsG0J.mjs"; import { l as runBrowserCliRequest, o as printBrowserList, t as BROWSER_TAB_REFERENCE_HELP } from "./browser-cli-shared-BEDAHNiM.mjs"; //#region extensions/browser/src/cli/browser-cli-debug.ts function registerBrowserDebugCommands(e, t) { e.command("highlight").description("Highlight an element by ref").argument("<ref>", "Ref id from snapshot").option("--target-id <id>", BROWSER_TAB_REFERENCE_HELP).action(async (e, n, r) => { await runBrowserCliRequest({ parent: t(r), path: "/highlight", body: { ref: e.trim(), targetId: normalizeOptionalString(n.targetId) }, successMessage: `highlighted ${e.trim()}` }); }); e.command("errors").description("Get recent page errors").option("--clear", "Clear stored errors after reading", false).option("--target-id <id>", BROWSER_TAB_REFERENCE_HELP).action(async (e, n) => { await runBrowserCliRequest({ parent: t(n), method: "GET", path: "/errors", query: { targetId: normalizeOptionalString(e.targetId), clear: Boolean(e.clear) }, print: (e) => printBrowserList(e.errors, "No page errors.", (e) => `${e.timestamp} ${e.name ? `${e.name}: ` : ""}${e.message}`) }); }); e.command("requests").description("Get recent network requests (best-effort)").option("--filter <text>", "Only show URLs that contain this substring").option("--clear", "Clear stored requests after reading", false).option("--target-id <id>", BROWSER_TAB_REFERENCE_HELP).action(async (e, n) => { await runBrowserCliRequest({ parent: t(n), method: "GET", path: "/requests", query: { targetId: normalizeOptionalString(e.targetId), filter: normalizeOptionalString(e.filter), clear: Boolean(e.clear) }, print: (e) => printBrowserList(e.requests, "No requests recorded.", (e) => { const t = typeof e.status === "number" ? ` ${e.status}` : ""; const n = e.ok === true ? " ok" : e.ok === false ? " fail" : ""; const r = e.failureText ? ` (${e.failureText})` : ""; return `${e.timestamp} ${e.method}${t}${n} ${e.url}${r}`; }) }); }); const n = e.command("trace").description("Record a Playwright trace"); n.command("start").description("Start trace recording").option("--target-id <id>", BROWSER_TAB_REFERENCE_HELP).option("--no-screenshots", "Disable screenshots").option("--no-snapshots", "Disable snapshots").option("--sources", "Include sources (bigger traces)", false).action(async (e, n) => { await runBrowserCliRequest({ parent: t(n), path: "/trace/start", body: { targetId: normalizeOptionalString(e.targetId), screenshots: Boolean(e.screenshots), snapshots: Boolean(e.snapshots), sources: Boolean(e.sources) }, successMessage: "trace started" }); }); n.command("stop").description("Stop trace recording and write a .zip").option("--out <path>", "Output path within openclaw temp dir (e.g. trace.zip or /tmp/openclaw/trace.zip)").option("--target-id <id>", BROWSER_TAB_REFERENCE_HELP).action(async (e, n) => { await runBrowserCliRequest({ parent: t(n), path: "/trace/stop", body: { targetId: normalizeOptionalString(e.targetId), path: readStringValue(e.out) }, successMessage: (e) => `TRACE:${shortenHomePath(e.path)}` }); }); } //#endregion export { registerBrowserDebugCommands };