UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 7.26 kB
import{r as defaultRuntime}from"./runtime-DIcLIHcp.mjs";import{t as formatCliCommand}from"./command-format-D7KhNLP0.mjs";import{r as theme}from"./theme-DS2CtI9X.mjs";import{t as danger}from"./globals-l9I53ZKA.mjs";import{t as formatDocsLink}from"./links-C_FK9uVv.mjs";import{t as addGatewayClientOptions}from"./gateway-rpc-17pTfL8i.mjs";import"./runtime-env-Qb8DG6sI.mjs";import{n as shouldEagerRegisterSubcommands}from"./command-registration-policy-WY6o6uol.mjs";import"./setup-tools-CPykgh4_.mjs";import"./gateway-runtime-CCd3DVdi.mjs";import{n as formatHelpExamples}from"./help-format-DLfgiheF.mjs";import{i as registerCommandGroups}from"./register-command-groups-Dm-xJnvg.mjs";import"./cli-runtime-BLVbyFtb.mjs";import{n as resolveBrowserLazySubcommand}from"./cli-output-mode-Bvnv8NIb.mjs"; //!extensions/browser/src/cli/browser-cli.ts const browserExamples=[`openclaw browser status`,`openclaw browser start`,`openclaw browser start --headless`,`openclaw browser stop`,`openclaw browser tabs`,`openclaw browser open https://example.com`,`openclaw browser focus abcd1234`,`openclaw browser close abcd1234`,`openclaw browser screenshot`,`openclaw browser screenshot --full-page`,`openclaw browser screenshot --ref 12`,`openclaw browser snapshot`,`openclaw browser snapshot --format aria --limit 200`,`openclaw browser snapshot --efficient`,`openclaw browser snapshot --labels`,`openclaw browser navigate https://example.com`,`openclaw browser resize 1280 720`,`openclaw browser click 12 --double`,`openclaw browser click-coords 120 340`,`openclaw browser type 23 "hello" --submit`,`openclaw browser press Enter`,`openclaw browser hover 44`,`openclaw browser drag 10 11`,`openclaw browser select 9 OptionA OptionB`,`openclaw browser upload /tmp/openclaw/uploads/file.pdf`,`openclaw browser upload media://inbound/file.pdf`,`openclaw browser fill --fields '[{"ref":"1","value":"Ada"}]'`,`openclaw browser dialog --accept`,`openclaw browser wait --text "Done"`,`openclaw browser evaluate --fn '(el) => el.textContent' --ref 7`,`openclaw browser evaluate --fn 'const title = document.title; return title;'`,`openclaw browser console --level error`,`openclaw browser pdf`,`openclaw browser batch --actions-file plan.json`,`openclaw browser batch --actions '[{"kind":"wait","timeMs":500},{"kind":"click","ref":"12"},{"kind":"type","ref":"23","text":"hello"}]'`,`openclaw browser batch --actions-file plan.json --continue`];const command=(e,t,n)=>({name:e,description:t,...n?{options:n}:{}});function browserCommandGroups(e,t,n){return[{placeholders:[command(`status`,`Show browser status`),command(`start`,`Start the browser (no-op if already running)`),command(`stop`,`Stop the browser (best-effort)`),command(`reset-profile`,`Reset browser profile (moves it to Trash)`),command(`tabs`,`List open tabs`),command(`tab`,`Tab shortcuts (index-based)`),command(`open`,`Open a URL in a new tab`),command(`focus`,`Focus a tab by tab reference`),command(`close`,`Close a tab (tab reference optional)`),command(`profiles`,`List all browser profiles`),command(`system-profiles`,`List Chrome-family profiles available for cookie import`),command(`import-profile`,`Import cookies from a macOS Chrome-family profile`),command(`create-profile`,`Create a new browser profile`),command(`delete-profile`,`Delete a browser profile`),command(`doctor`,`Check browser plugin readiness`,[{flags:`--deep`,description:`Run a live snapshot check`}])],register:async()=>{(await import(`./browser-cli-manage-C6CKv11c.mjs`)).registerBrowserManageCommands(e,t)}},{placeholders:[command(`cookie-sync`,`Sync allowlisted macOS browser cookies to a managed profile`)],register:async()=>{(await import(`./browser-cli-cookie-sync-DCnH1u6h.mjs`)).registerBrowserCookieSyncCommand(e,t)}},{placeholders:[command(`screenshot`,`Capture a screenshot (prints the saved path)`),command(`snapshot`,`Capture a snapshot (default: ai; aria is the accessibility tree)`)],register:async()=>{(await import(`./browser-cli-inspect-B2t34Jvy.mjs`)).registerBrowserInspectCommands(e,t)}},{placeholders:[command(`navigate`,`Navigate the current tab to a URL`),command(`resize`,`Resize the viewport`),command(`click`,`Click an element by ref from snapshot`),command(`click-coords`,`Click viewport coordinates`),command(`type`,`Type into an element by ref from snapshot`),command(`press`,`Press a key`),command(`hover`,`Hover an element by ai ref`),command(`scrollintoview`,`Scroll an element into view by ref from snapshot`),command(`drag`,`Drag from one ref to another`),command(`select`,`Select option(s) in a select element`),command(`upload`,`Arm file upload for the next file chooser`),command(`waitfordownload`,`Wait for the next download (and save it)`),command(`download`,`Click a ref and save the resulting download`),command(`dialog`,`Arm the next modal dialog (alert/confirm/prompt)`),command(`fill`,`Fill a form with JSON field descriptors`),command(`wait`,`Wait for time, selector, URL, load state, or JS conditions`),command(`evaluate`,`Evaluate a function against the page or a ref`),command(`batch`,`Run a batch of browser actions in one call`)],register:async()=>{(await import(`./register-DJzqwuXM.mjs`)).registerBrowserActionInputCommands(e,t)}},{placeholders:[command(`console`,`Get recent console messages`),command(`pdf`,`Save page as PDF`),command(`responsebody`,`Wait for a network response and return its body`)],register:async()=>{(await import(`./browser-cli-actions-observe-D226gTxW.mjs`)).registerBrowserActionObserveCommands(e,t)}},{placeholders:[command(`highlight`,`Highlight an element by ref`),command(`errors`,`Get recent page errors`),command(`requests`,`Get recent network requests (best-effort)`),command(`trace`,`Record a Playwright trace`)],register:async()=>{(await import(`./browser-cli-debug-CjGnlssI.mjs`)).registerBrowserDebugCommands(e,t)}},{placeholders:[command(`cookies`,`Read/write cookies`),command(`storage`,`Read/write localStorage/sessionStorage`),command(`set`,`Browser environment settings`)],register:async()=>{(await import(`./browser-cli-state-BdZkEyGZ.mjs`)).registerBrowserStateCommands(e,t)}},{placeholders:[command(`extension`,`Chrome extension install, status, and pairing`)],register:async()=>{(await import(`./browser-cli-extension-Bc_Y2b0G.mjs`)).registerBrowserExtensionCommands(e,t,n)}}]}function registerBrowserCli(e,t=process.argv,n){const r=e.command(`browser`).description(`Manage OpenClaw's dedicated browser (Chrome/Chromium)`).option(`--browser-profile <name>`,`Browser profile name (default from config)`).option(`--json`,`Output machine-readable JSON`,false).addHelpText(`after`,()=>`\n${theme.heading(`Examples:`)}\n${formatHelpExamples(browserExamples.map(e=>[e,``]),true)}\n\n${theme.muted(`Docs:`)} ${formatDocsLink(`/cli/browser`,`docs.openclaw.ai/cli/browser`)}\n`).action(()=>{const e=`Missing subcommand. Try: "${formatCliCommand(`openclaw browser status`)}"`;if(r.opts().json)throw new Error(e);r.outputHelp();defaultRuntime.error(danger(e));defaultRuntime.exit(1)});addGatewayClientOptions(r);const parentOpts=()=>r.opts();const i=resolveBrowserLazySubcommand(t);registerCommandGroups(r,browserCommandGroups(r,parentOpts,n),{eager:shouldEagerRegisterSubcommands(),primary:i,registerPrimaryOnly:i!==null})}export{registerBrowserCli};