openclaw browser
CLI, और स्क्रिप्टिंग पैटर्न (स्नैपशॉट, refs, waits, debug flows) के लिए संदर्भ है।
नियंत्रण API (वैकल्पिक)
केवल स्थानीय इंटीग्रेशन के लिए, Gateway एक छोटा loopback HTTP API उपलब्ध कराता है। यह स्टैंडअलोन सर्वर opt-in है — HTTP endpoints उपलब्ध होने से पहले gateway सेवा environment में environment variableOPENCLAW_EAGER_BROWSER_CONTROL_SERVER=1 सेट करें
और gateway restart करें। इस variable के बिना browser control runtime फिर भी CLI और
agent tools के माध्यम से काम करता है, लेकिन loopback control port पर कुछ भी listen नहीं करता।
- स्थिति/start/stop:
GET /,POST /start,POST /stop - टैब:
GET /tabs,POST /tabs/open,POST /tabs/focus,DELETE /tabs/:targetId - स्नैपशॉट/screenshot:
GET /snapshot,POST /screenshot - क्रियाएँ:
POST /navigate,POST /act - Hooks:
POST /hooks/file-chooser,POST /hooks/dialog - डाउनलोड:
POST /download,POST /wait/download - अनुमतियाँ:
POST /permissions/grant - Debugging:
GET /console,POST /pdf - Debugging:
GET /errors,GET /requests,POST /trace/start,POST /trace/stop,POST /highlight - नेटवर्क:
POST /response/body - स्थिति:
GET /cookies,POST /cookies/set,POST /cookies/clear - स्थिति:
GET /storage/:kind,POST /storage/:kind/set,POST /storage/:kind/clear - सेटिंग्स:
POST /set/offline,POST /set/headers,POST /set/credentials,POST /set/geolocation,POST /set/media,POST /set/timezone,POST /set/locale,POST /set/device
?profile=<name> स्वीकार करते हैं। POST /start?headless=true persisted
browser config बदले बिना स्थानीय managed profiles के लिए one-shot headless launch का अनुरोध करता है; attach-only, remote CDP, और existing-session profiles
उस override को reject करते हैं क्योंकि OpenClaw उन browser processes को launch नहीं करता।
tab endpoints के लिए, targetId compatibility field name है। GET /tabs या POST /tabs/open से
suggestedTargetId पास करना बेहतर है; t1 जैसे labels और tabId
handles भी स्वीकार किए जाते हैं। Raw CDP target ids और unique raw
target-id prefixes अभी भी काम करते हैं, लेकिन वे volatile diagnostic handles हैं।
अगर shared-secret gateway auth configured है, तो browser HTTP routes को भी auth चाहिए:
Authorization: Bearer <gateway token>x-openclaw-password: <gateway password>या उस password के साथ HTTP Basic auth
- यह standalone loopback browser API trusted-proxy या Tailscale Serve identity headers consume नहीं करता।
- अगर
gateway.auth.modenoneयाtrusted-proxyहै, तो ये loopback browser routes उन identity-bearing modes को inherit नहीं करते; इन्हें केवल loopback-only रखें।
/act error contract
POST /act route-level validation और
policy failures के लिए structured error response का उपयोग करता है:
code values:
ACT_KIND_REQUIRED(HTTP 400):kindmissing या unrecognized है।ACT_INVALID_REQUEST(HTTP 400): action payload normalization या validation में fail हुआ।ACT_SELECTOR_UNSUPPORTED(HTTP 400):selectorकिसी unsupported action kind के साथ उपयोग किया गया।ACT_EVALUATE_DISABLED(HTTP 403):evaluate(याwait --fn) config द्वारा disabled है।ACT_TARGET_ID_MISMATCH(HTTP 403): top-level या batchedtargetIdrequest target से conflict करता है।ACT_EXISTING_SESSION_UNSUPPORTED(HTTP 501): action existing-session profiles के लिए supported नहीं है।
code field के बिना { "error": "<message>" } return कर सकते हैं।
Playwright requirement
कुछ features (navigate/act/AI snapshot/role snapshot, element screenshots, PDF) के लिए Playwright चाहिए। अगर Playwright installed नहीं है, तो वे endpoints स्पष्ट 501 error return करते हैं। Playwright के बिना भी क्या काम करता है:- ARIA snapshots
- Role-style accessibility snapshots (
--interactive,--compact,--depth,--efficient) जब per-tab CDP WebSocket उपलब्ध हो। यह inspection और ref discovery के लिए fallback है; Playwright मुख्य action engine रहता है। - managed
openclawbrowser के लिए page screenshots जब per-tab CDP WebSocket उपलब्ध हो existing-session/ Chrome MCP profiles के लिए page screenshots- snapshot output से
existing-sessionref-based screenshots (--ref)
navigateact- AI snapshots जो Playwright के native AI snapshot format पर निर्भर हैं
- CSS-selector element screenshots (
--element) - full browser PDF export
--full-page को भी reject करते हैं; route fullPage is not supported for element screenshots return करता है।
अगर आपको Playwright is not available in this gateway build दिखता है, तो packaged
Gateway में core browser runtime dependency missing है। OpenClaw reinstall या update करें,
फिर gateway restart करें। Docker के लिए, नीचे दिखाए अनुसार Chromium
browser binaries भी install करें।
Docker Playwright install
अगर आपका Gateway Docker में चलता है, तोnpx playwright से बचें (npm override conflicts)।
custom images के लिए, image में Chromium bake करें:
PLAYWRIGHT_BROWSERS_PATH सेट करें (उदाहरण के लिए,
/home/node/.cache/ms-playwright) और सुनिश्चित करें कि /home/node
OPENCLAW_HOME_VOLUME या bind mount के माध्यम से persisted है। OpenClaw Linux पर persisted
Chromium को auto-detect करता है। Docker देखें।
यह कैसे काम करता है (internal)
एक छोटा loopback control server HTTP requests स्वीकार करता है और CDP के माध्यम से Chromium-based browsers से connect करता है। Advanced actions (click/type/snapshot/PDF) CDP के ऊपर Playwright से होकर जाते हैं; जब Playwright missing होता है, तो केवल non-Playwright operations उपलब्ध होते हैं। agent को एक stable interface दिखता है जबकि local/remote browsers और profiles नीचे स्वतंत्र रूप से swap होते रहते हैं।CLI quick reference
सभी commands किसी specific profile को target करने के लिए--browser-profile <name>, और machine-readable output के लिए --json स्वीकार करते हैं।
Basics: status, tabs, open/focus/close
Basics: status, tabs, open/focus/close
Inspection: screenshot, snapshot, console, errors, requests
Inspection: screenshot, snapshot, console, errors, requests
Actions: navigate, click, type, drag, wait, evaluate
Actions: navigate, click, type, drag, wait, evaluate
State: cookies, storage, offline, headers, geo, device
State: cookies, storage, offline, headers, geo, device
uploadऔरdialogarming calls हैं; chooser/dialog trigger करने वाले click/press से पहले इन्हें run करें। अगर कोई action modal खोलता है, तो action response मेंblockedByDialogऔरbrowserState.dialogs.pendingशामिल होते हैं; सीधे respond करने के लिए वहdialogIdपास करें। OpenClaw के बाहर handled dialogsbrowserState.dialogs.recentके तहत दिखाई देते हैं।click/type/etc के लिएsnapshotसेrefचाहिए (numeric12, role refe12, या actionable ARIA refax12)। CSS selectors actions के लिए जानबूझकर supported नहीं हैं। जब visible viewport position ही एकमात्र reliable target हो, तोclick-coordsका उपयोग करें।- Download और trace paths OpenClaw temp roots तक constrained हैं:
/tmp/openclaw{,/downloads}(fallback:${os.tmpdir()}/openclaw/...)। uploadOpenClaw temp uploads root और OpenClaw-managed inbound media से files स्वीकार करता है। Managed inbound media कोmedia://inbound/<id>, sandbox-relativemedia/inbound/<id>, या managed inbound media directory के अंदर resolved path के रूप में referenced किया जा सकता है। Nested media refs, traversal, symlinks, hardlinks, और arbitrary local paths अभी भी rejected हैं।upload--input-refया--elementके माध्यम से file inputs directly set भी कर सकता है।
tabs से suggestedTargetId prefer करें।
Snapshot flags एक नजर में:
--format ai(Playwright के साथ डिफ़ॉल्ट): संख्यात्मक संदर्भों वाला AI स्नैपशॉट (aria-ref="<n>")।--format aria:axNसंदर्भों वाला accessibility tree। जब Playwright उपलब्ध होता है, OpenClaw संदर्भों को backend DOM ids के साथ live page से बांधता है ताकि आगे की कार्रवाइयां उनका उपयोग कर सकें; अन्यथा आउटपुट को केवल निरीक्षण के लिए मानें।--efficient(या--mode efficient): compact role snapshot preset। इसे डिफ़ॉल्ट बनाने के लिएbrowser.snapshotDefaults.mode: "efficient"सेट करें (Gateway configuration देखें)।--interactive,--compact,--depth,--selectorref=e12संदर्भों वाला role snapshot बाध्य करते हैं।--frame "<iframe>"role snapshots को iframe तक सीमित करता है।- Playwright के साथ,
--labelsoverlay किए गए ref labels वाला screenshot जोड़ता है (MEDIA:<path>प्रिंट करता है) और साथ में हर ref के bounding box वालाannotationsarray देता है।screenshotपर, Playwright-backed labels--full-page,--ref, और--elementके साथ काम करते हैं;snapshotपर, साथ वाला screenshot केवल viewport तक सीमित रहता है। Existing-session/chrome-mcp profiles page screenshots पर overlay labels render करते हैं लेकिनannotationsवापस नहीं करते या Playwright full-page/ref/element projection helper का उपयोग नहीं करते। Playwright या chrome-mcp के बिना, labeled screenshots उपलब्ध नहीं होते। --urlsखोजे गए link destinations को AI snapshots में जोड़ता है।
स्नैपशॉट और संदर्भ
OpenClaw दो “snapshot” शैलियों का समर्थन करता है:-
AI snapshot (numeric refs):
openclaw browser snapshot(डिफ़ॉल्ट;--format ai)- आउटपुट: एक text snapshot जिसमें numeric refs शामिल होते हैं।
- कार्रवाइयां:
openclaw browser click 12,openclaw browser type 23 "hello"। - आंतरिक रूप से, ref को Playwright के
aria-refके माध्यम से resolve किया जाता है।
-
Role snapshot (
e12जैसे role refs):openclaw browser snapshot --interactive(या--compact,--depth,--selector,--frame)- आउटपुट:
[ref=e12](और वैकल्पिक[nth=1]) वाली role-based list/tree। - कार्रवाइयां:
openclaw browser click e12,openclaw browser highlight e12। - आंतरिक रूप से, ref को
getByRole(...)(duplicates के लिएnth()सहित) के माध्यम से resolve किया जाता है। - overlay किए गए
e12labels वाला screenshot शामिल करने के लिए--labelsजोड़ें। Playwright-backed profiles पर यह प्रति-ref bounding-box metadata भी लौटाता है (annotations[])। - जब link text अस्पष्ट हो और agent को ठोस
navigation targets चाहिए हों, तब
--urlsजोड़ें।
- आउटपुट:
-
ARIA snapshot (
ax12जैसे ARIA refs):openclaw browser snapshot --format aria- आउटपुट: structured nodes के रूप में accessibility tree।
- कार्रवाइयां:
openclaw browser click ax12तब काम करता है जब snapshot path Playwright और Chrome backend DOM ids के जरिए ref को bind कर सकता है।
-
यदि Playwright उपलब्ध नहीं है, तो ARIA snapshots अभी भी
निरीक्षण के लिए उपयोगी हो सकते हैं, लेकिन refs actionable नहीं हो सकते। जब आपको action refs चाहिए हों,
--format aiया--interactiveके साथ फिर से snapshot लें। -
raw-CDP fallback path के लिए Docker proof:
pnpm test:docker:browser-cdp-snapshotCDP के साथ Chromium शुरू करता है,browser doctor --deepचलाता है, और सत्यापित करता है कि role snapshots में link URLs, cursor-promoted clickables, और iframe metadata शामिल हैं।
- Refs navigations के बीच स्थिर नहीं रहते; यदि कुछ विफल हो, तो
snapshotफिर से चलाएं और नया ref उपयोग करें। /actaction-triggered replacement के बाद मौजूदा rawtargetIdलौटाता है जब वह replacement tab को साबित कर सकता है। आगे के commands के लिए stable tab ids/labels का उपयोग जारी रखें।- यदि role snapshot
--frameके साथ लिया गया था, तो role refs अगले role snapshot तक उस iframe तक सीमित रहते हैं। - अज्ञात या stale
axNrefs Playwright केaria-refselector पर गिरने के बजाय तुरंत विफल होते हैं। ऐसा होने पर उसी tab पर fresh snapshot चलाएं।
Wait power-ups
आप केवल समय/text से अधिक चीज़ों पर wait कर सकते हैं:- URL के लिए wait करें (Playwright द्वारा समर्थित globs):
openclaw browser wait --url "**/dash"
- load state के लिए wait करें:
openclaw browser wait --load networkidle- managed
openclawऔर raw/remote CDP profiles पर समर्थित।userऔरexisting-sessionprofilesnetworkidleको reject करते हैं; वहां--url,--text, selector, या--fnwaits उपयोग करें।
- JS predicate के लिए wait करें:
openclaw browser wait --fn "window.ready===true"
- selector के visible होने तक wait करें:
openclaw browser wait "#main"
Debug workflows
जब कोई action विफल हो (जैसे “not visible”, “strict mode violation”, “covered”):openclaw browser snapshot --interactiveclick <ref>/type <ref>उपयोग करें (interactive mode में role refs को प्राथमिकता दें)- यदि यह फिर भी विफल हो: Playwright क्या target कर रहा है यह देखने के लिए
openclaw browser highlight <ref> - यदि page अजीब व्यवहार करे:
openclaw browser errors --clearopenclaw browser requests --filter api --clear
- गहरी debugging के लिए: trace record करें:
openclaw browser trace start- issue को reproduce करें
openclaw browser trace stop(TRACE:<path>प्रिंट करता है)
JSON output
--json scripting और structured tooling के लिए है।
उदाहरण:
refs और एक छोटा stats block (lines/chars/refs/interactive) शामिल होता है ताकि tools payload size और density के बारे में reason कर सकें।
State और environment knobs
ये “site को X की तरह व्यवहार कराएं” workflows के लिए उपयोगी हैं:- Cookies:
cookies,cookies set,cookies clear - Storage:
storage local|session get|set|clear - Offline:
set offline on|off - Headers:
set headers --headers-json '{"X-Debug":"1"}'(legacyset headers --json '{"X-Debug":"1"}'समर्थित रहता है) - HTTP basic auth:
set credentials user pass(या--clear) - Geolocation:
set geo <lat> <lon> --origin "https://example.com"(या--clear) - Media:
set media dark|light|no-preference|none - Timezone / locale:
set timezone ...,set locale ... - Device / viewport:
set device "iPhone 14"(Playwright device presets)set viewport 1280 720
Security और privacy
- openclaw browser profile में logged-in sessions हो सकते हैं; इसे संवेदनशील मानें।
browser act kind=evaluate/openclaw browser evaluateऔरwait --fnpage context में arbitrary JavaScript execute करते हैं। Prompt injection इसे steer कर सकता है। यदि आपको इसकी जरूरत नहीं है तोbrowser.evaluateEnabled=falseसे इसे disable करें।openclaw browser evaluate --fnfunction source, expression, या statement body स्वीकार करता है। Statement bodies को async functions के रूप में wrap किया जाता है, इसलिए जो value आप वापस चाहते हैं उसके लिएreturnउपयोग करें। जब page-side function को default evaluate timeout से अधिक समय चाहिए हो सकता है, तब--timeout-ms <ms>उपयोग करें।- logins और anti-bot notes (X/Twitter, आदि) के लिए, Browser login + X/Twitter posting देखें।
- Gateway/node host को private रखें (loopback या tailnet-only)।
- Remote CDP endpoints शक्तिशाली होते हैं; उन्हें tunnel और protect करें।
संबंधित
- Browser - overview, configuration, profiles, security
- Browser login - sites में sign in करना
- Browser Linux troubleshooting
- Browser WSL2 troubleshooting