openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 3.09 kB
JavaScript
import{g as readStringValue,l as normalizeOptionalString}from"./string-coerce-CpTFcSwY.mjs";import{f as shortenHomePath}from"./utils-Dlk0IYAa.mjs";import"./string-coerce-runtime-BYDH9Quw.mjs";import"./text-utility-runtime-CDtGqkrl.mjs";import{l as runBrowserCliRequest,o as printBrowserList,t as BROWSER_TAB_REFERENCE_HELP}from"./browser-cli-shared-5N8-HcJT.mjs";
//!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)}`})})}export{registerBrowserDebugCommands};