Browser drives a real Chrome browser from your code. Use it for pages that only show their content after JavaScript runs, such as single-page apps, price widgets, and dashboards, where a plain fetch returns an empty shell. There are three ways in:
Browser.readopens one page, waits for it, and returns its title and content in one call.Browser.executegives the browser a task in plain words and lets it work through the pages step by step.- The step-by-step methods (
navigate,click,fill,get, and the rest) drive a page one command at a time.
Browser is off until you turn it on with browser on the agent, or attach a named browser. It works in tools, jobs, webhooks, triggers, device triggers, processors, web routes, and workflow code steps. It is not available in tool conditions, model resolvers, or MCP server resolvers.
New to the browser? Use the browser walks through which method to reach for and the settings worth having from the start.
Quick example
src/agent.ts
lua browser read.
Where pages open
Every command runs on one of two browsers:- The user’s desktop browser, when the Lua desktop app is running with its browser connected. Pages open with the user’s own logins.
- The Lua cloud browser, a fresh Chrome that Lua runs for you. Each session starts empty, with no cookies or logins, and is deleted when it closes.
engine setting decides which one runs:
The retry on Browser-Use applies to the commands that open or look at a page:
session_open, navigate, and snapshot, including the ones Browser.execute runs. The session then stays on Browser-Use, and a fallback row is written to the logs. Browser.read does not move to Browser-Use; it returns the page it got.
Jobs, webhooks, triggers, web routes, and workflow steps run with no user at a desktop, so they always use the Lua cloud browser. When the desktop browser doesn’t answer as a session opens, Browser.read and the commands that open a page (session_open, navigate) continue on the Lua cloud browser and a fallback row is written to the logs. If the desktop stops answering later, in the middle of a read or for any other command, the call fails with session_lost.
Configuration
Set these on the agent’sbrowser option. browser: true uses the defaults. A named browser takes the same settings.
Which browser runs the commands; see Where pages open. Default
'auto'.What happens when the Lua cloud browser can’t get past a page.
'browser-use' (default) retries the command once on Browser-Use. 'none' keeps every page on the Lua cloud browser, and the command returns the page it got. Browser-Use is never used when engine is 'agent-browser' or allowedDomains is set.A two-letter country code, such as
'gb' or 'de', for the country Browser-Use browses from. It applies only to work that runs on Browser-Use.Hosts the browser may open. List each host the pages need, or use a wildcard such as
*.ikea.com for a domain and its subdomains. The list is checked before every command that opens a URL, Browser.read and Browser.execute included; a blocked URL fails with BROWSER_DOMAIN_NOT_ALLOWED. On the Lua cloud browser it also applies to redirects and everything a page loads (scripts, images, requests), so include the hosts a page loads its content from. On the desktop browser, Browser.read also checks the page it ended on after redirects and fails with BROWSER_DOMAIN_NOT_ALLOWED when that host is not allowed. Empty or unset allows all public sites. Setting it turns off the Browser-Use retry, because the list can’t be enforced on a remote browser.Actions that must be approved before they run.
Browser.execute checks these categories: navigate, click, fill, type, select, press, scroll, and submit. submit covers clicking a button such as Buy, Pay, Place order, Sign in, or Send, and pressing Enter. The step-by-step commands add four of their own: download, upload, pdf and eval, so a browser that moves files or runs scripts can hold each one for the person. When a run reaches one of them it stops with stopReason: 'confirmation_required', holds that action, and returns a pendingAction with a confirmationId; see execute. For the step-by-step commands, a matching command is held the same way until you call Browser.confirm({ id }) or Browser.deny({ id }). A held action can only be approved from the person’s next message, never in the turn that held it, and it is dropped after 60 seconds. A run with no person, such as a job or webhook, can hold an action but never approve it. On engine 'browser-use', a non-empty list makes Browser.execute fail with BROWSER_USE_CONFIRM_UNSUPPORTED, because Browser-Use runs can’t pause for approval.How much page content the browser log rows keep:
'summary' (default) keeps titles and sizes, 'full' also keeps page text (shortened), 'none' keeps neither.When a log row carries a screenshot reference. Default
'onError'. On the Lua cloud browser a screenshot comes back in the command result and is not stored, so its log rows carry no reference.How long a Lua cloud browser session may stay open, in whole minutes. Default 10, maximum 60. On
browser, a larger value is cut to 60 when the session opens. On a named browser, a value over 60 fails lua compile.How long a Lua cloud browser session may go without a command before it closes, in whole seconds. Default 120, maximum 900. On
browser, a larger value is cut to 900 when the session opens. On a named browser, a value over 900 fails lua compile.How many Lua cloud browser sessions this agent may have open at once for one person. Default 3. A command that would open one more fails with
BROWSER_SESSION_LIMIT. The platform allows at most 10, and your plan may allow fewer, so the lowest of the three applies. On a named browser, lua compile accepts 1 to 100.Turns on
download, pdf and upload for this browser, and caps each file, in whole megabytes from 1 to 500. The cap is lowered to your plan’s per-file limit. Unset, those three methods fail with files_disabled.The types a download may have, such as
['application/pdf', 'image/*'], up to 50 entries. Each entry is type/subtype or type/*. The type is read from the file’s own bytes, not from what the site says it is; another type is refused with mime. Empty or unset allows any type.Lets your own code run page scripts with
Browser.eval. Off by default. It needs an allowedDomains list naming at least one real domain. The chat model never runs scripts, and neither does Browser.execute.persist and credentials are accepted and stored but not enforced yet. To sign a browser in, use a saved login.
Named browsers
A named browser is aLuaBrowser with its own settings. Attach one or more to the agent with browsers, then pick one per call with browser: '<name>'. Use them when different jobs need different rules, such as one browser locked to a supplier site and another that can open anything.
src/browsers/supplier.ts
src/agent.ts
- Attaching a browser turns the browser on.
browser: trueis not needed whenbrowsershas at least one entry. - Every method takes
browser.Browser.readtakes it in its options;Browser.executeand the step-by-step methods take it in their input object. - Calls without
browseruse thebrowseroption’s settings when the agent setsbrowser, and the first browser inbrowserswhen it doesn’t. - An unknown name fails with
BROWSER_PROFILE_NOT_FOUND:Browser.readthrows it, and the other methods return it incode. - Names start with a letter or digit and use only letters, digits,
_, and-, up to 64 characters. The constructor throws on any other name.defineBrowser({...})is the same asnew LuaBrowser({...}). lua compilechecks every setting. An unknownengineorfallback, aproxyCountrythat isn’t two letters, a limit that isn’t a whole number in range, anallowScripts: truewith no real domain inallowedDomains, two browsers with the same name, or an entry inbrowsersthat isn’t aLuaBrowserfails the compile.
lua push browser --name supplier-portal, then lua push agent so the agent picks up its browsers list. lua push all pushes browsers with everything else. lua browsers lists and deletes them.
The full settings table, the compile-time messages and worked examples are on the LuaBrowser page.
Methods
read(url, options?)
Reads one page in a new browser session and closes that session when it is done, whether the read succeeded or not. Steps: open the URL, wait forwaitFor if given, then read the page title, the final URL, and the content of selector.
What to wait for after the page opens.
'load' waits for the load event, 'networkidle' waits until the page stops making requests, and any other string is a CSS selector to wait for, such as '.price'. Unset reads as soon as the page has opened.CSS selector of the element to read. Default
'body', the whole page. On the Lua cloud browser with format: 'text', every match is read, in page order, up to 200 matches, joined by a blank line, with empty matches skipped. With format: 'html' the cloud browser reads the first match. The desktop browser reads the first match in both formats.Time budget for the whole read, from opening the browser session to the last read. Default 60000. A value under 1000 is raised to 1000 and a value over 100000 is cut to 100000. When the budget runs out, the read fails with
timeout.The named browser to read with.
The name of a saved login to sign in with before the page is read, so a page behind a sign-in can be read as that person. The read then happens in the signed-in session. When the sign-in does not finish,
read throws with the login’s code instead of returning a page.read throws an error with name: 'BrowserError', a code, and for http_error the page’s status; see Errors. Closing the session after the read takes up to 10 more seconds.
In a tool
src/tools/ReadPageTool.ts
In a scheduled job
src/jobs/PriceCheckJob.ts
In a webhook
src/webhooks/PageChangedWebhook.ts
execute(input)
Gives the browser a task in plain words. A model looks at the page, picks the next action (navigate, click, fill, read), and repeats until the task is done or a limit is reached. Use it when you can describe what you want but not the exact clicks.execute input
What the browser should do, in plain words. An empty task rejects with
name: 'BrowserExecuteError' and code BROWSER_EXECUTE_INVALID_INPUT.The page the run starts on. Unless you set
allowedDomains or allowAnyDomain, and the agent has no allowedDomains of its own, the run stays on this page’s domain.A JSON Schema the
output must match. The model gets a chance to fix output that doesn’t match; if it still doesn’t, the run fails with BROWSER_OUTPUT_SCHEMA_MISMATCH. A schema that is not an object rejects with BROWSER_EXECUTE_INVALID_INPUT.The most the run may spend on the model, in US dollars. Default 1, at most 10. Zero or less fails with
invalid_argument.A model code to drive the run. Unset uses the platform’s default. A model the agent can’t use fails with
MODEL_NOT_AVAILABLE.Run in the session with this key, for example one you opened and signed in to with the step-by-step methods. That session stays open after the run. Without it, the run opens its own session and closes it at the end.
Hosts this run may visit. When the agent has its own
allowedDomains, only hosts on both lists are allowed.The named browser to run with.
Names of saved logins to sign the browser in with before the task starts, at most 5. The run then works as that person on those sites, on the Lua cloud browser. A name the person has not saved, or more than 5 names, rejects with
BROWSER_EXECUTE_INVALID_INPUT. The run never types a password or a code itself: when a site asks for one, the run stops with stopReason: 'needs_verification' and the person gets a private link. With a read login the run may only navigate, scroll, read and wait.maxSteps outside 1 to 60 or not a whole number, a maxCostUsd above 10, a timeoutMs outside 1000 to 900000, and a task over 20,000 characters fail with invalid_argument before anything runs.
The run never spends more than maxCostUsd: before each model call it checks that the call still fits, and stops with stopReason: 'cost_cap' when it would not. The same action three times in a row on a page that did not change stops the run with repeated_action. When the model gives up on the last allowed step, the run ends as max_steps, and detail has the model’s reason.
execute result
execute returns a result instead of throwing when the run fails. Check status.
An agent runs at most 3 execute runs at a time for each user. Another run fails with BROWSER_EXECUTE_CONCURRENCY. On engine 'browser-use', execute runs as a Browser-Use task: steps is 0, there is no history, and confirmActions must be empty.
Step-by-step commands
For pages you need to interact with,Browser also has one method per browser command. Each takes one object, with an optional sessionKey and browser, and returns { engine, data?, error?, code? }. These methods do not throw when a command fails; check error and code.
The input type of every method is exported as
BrowserCommandInputs['<method>']. From lua-cli 3.50.0 the types accept only what the browser engine runs: find takes the actions click, fill, hover, check and text; wait takes state: 'visible' only; keyboard takes the actions type and inserttext. Use press for single keys and key chords. Commands with the same sessionKey share one session for the length of one conversation or run. A command that needs a page before one is open fails with no_page; open one with navigate or session_open first.
download, pdf and upload need maxDownloadMb on the browser, and eval needs allowScripts; without those they are refused with files_disabled and scripts_disabled. On the Lua cloud browser, these are not available and fail with unsupported: extract, auth, state, act with a natural-language instruction and no ref, wait with fn, screenshot with path, network with action: 'har', and download by URL (click the link or button instead). download, pdf and upload pick their own file location there, so passing a path fails with invalid_argument. On engine 'browser-use', every command except close returns an error that starts with BROWSER_STEPWISE_UNSUPPORTED.
Saved logins
A saved login is one person’s account on one site, kept by the platform for them. The agent can ask the browser to sign in with it, but never sees the username, the password or a verification code: the person types those on a Lua page, and the browser fills them in. Your code only ever names the login, and the link the person opens is masked in what the conversation remembers.Ask the person for a login
An agent asks for a login from a live chat turn withSecrets.request. Lua sends a one-time link straight to that person in the conversation; they open it, type their username and password on a Lua page, and pick the access they are happy with.
src/tools/AddSupplierLoginTool.ts
The name your code uses for this login, such as
'supplier'. It starts with a lowercase letter and then uses only lowercase letters, digits, - and _, up to 40 characters. One name per site per person: asking again with the same name replaces that person’s login rather than adding a second one.The hosts this login belongs to, 1 to 10 of them, written as bare hostnames such as
'supplier.example.com'. An IP address, a port, or a host with credentials in it is refused. origins[0] is the sign-in host, the only one where the password may be typed. The others can allow hosts a page needs to render, and never receive the password. A signed-in session stays on these hosts; navigating off them is refused with browser_login_site_not_allowed.The page the sign-in starts on. It must be an absolute
https:// URL whose host is one of origins, with no port and no credentials in it. Anything else rejects the request with browser_login_invalid.The most the agent may do on the site with this login; see Access levels. The person can pick the level you asked for or a lower one, never a higher one.
How often the browser may try to sign in; see The sign-in policy. Defaults to one attempt per 30 minutes with a 30-minute cooldown.
One short line telling the person why the agent needs it, shown on the page. Kept to 200 characters.
{ kind, requestId, name, state: 'pending', expiresAt, reused?, delivery? }. The receipt never carries the link or its token, so it is safe to return from a tool. delivery says whether the link reached the person: { delivered: true, channel }, or { delivered: false, reason } with channel_unsupported, conversation_held, window_closed, send_failed or no_email. When the chat itself cannot carry a link, Lua emails it instead and channel is 'email'. The link works once and stops working after 15 minutes; asking again while an unused link still has more than about four minutes left re-sends that same link, and the receipt says reused: true.
The request is refused when:
Sign in
The session to sign in. Later commands with the same
sessionKey run in that signed-in session. One login per session: signing a second login into the same key fails, so give each login its own key.The named browser to sign in.
restored: true. A saved session lasts about 30 days by default. When the site signs the session out, the next command fails and Browser.login signs in again.
Codes, checks and take-over
The browser never types a verification code and never solves a bot check. When a site asks for one:- A code: the sign-in pauses, the person gets a private link to type the code on, and
statusisneeds_verification. They have 10 minutes. Submitting it resumes the sign-in on its own; the nextBrowser.loginwith the samesessionKeyreturns the outcome. Never ask for the code in the chat. - A check or an approval on their phone: the session is kept open and the person gets a private link that opens this same browser, so they can finish the step themselves and the run carries on.
failureiscaptchaorneeds_approval.
Access levels
The level the person chose decides what the browser may do in that session, on top of the browser’s ownallowedDomains and confirmActions.
Page scripts never run in a signed-in session, whatever the level and whatever the browser’s
allowScripts says.
The sign-in policy
A saved login is tried sparingly, because sites lock accounts out. By default the browser makes one sign-in attempt per 30 minutes. A wrong password, a verification code, a bot check or an approval the person has to give on another device also starts a 30-minute cooldown; a sign-in that works clears it. Ask for different numbers withsignInPolicy:
With the attempts used up, or inside a cooldown,
Browser.login comes back with failure: 'too_many_attempts'. Tell the person and stop; a retry loop only burns the attempts they have left. The person can clear the cooldown themselves from their saved logins.
Jobs
A job has nobody to ask, so it cannot use a login unless the person said so first. From a live chat turn, grant it, naming the job by its id:The id of the job this grant is for, as
Jobs.getAll reports it. One grant per job.What the job may do. A
read login stays read-only however high the grant is, so the lower of the two applies.{ credential, jobId, access?, granted? | revoked?, error?, code? }. Both work only on a live turn of the person who owns the login; anywhere else they return browser_login_needs_user. A job that calls Browser.login without a grant is refused with browser_login_grant_required.
The person stays in charge: they can see their saved logins, remove one, clear its sign-in cooldown, or stop one job from using it. Removing a login deletes its saved session and withdraws every job grant for it, so the next run asks them to add it again.
Login error codes
Files
A browser can save a file from a page, save the page itself as a PDF, and put a file the person gave the agent into a file input. All three are off until the browser setsmaxDownloadMb, which also caps each file.
src/browsers/invoices.ts
downloadclicks the link or button atref(a snapshot ref such as'@e7') orselectorand keeps the file it starts. Passreforselector, not both. There is no download by URL: find the link and click it.pdfsaves the page as it stands.namenames the file.uploadputs one of the person’s own files into the file input atreforselector.fileis that file as you see it: its URL, itsfileId(with or without the extension), or the person’s artefact URL.
download and pdf return { fileId, url, name, bytes, mime, scanStatus } in data; upload returns { uploaded: true, name, bytes }, with the file’s fileId on the Lua cloud browser. Like the other step-by-step commands, these do not throw: check error and code.
Scanning
A saved file is private to the person it was saved for, and arrives withscanStatus: 'scanning'. It stays that way until the malware scan clears it as clean. Until then nobody can open it and it cannot be uploaded anywhere, so hand the person the file’s name and url and let it open once the scan clears, rather than fetching it in the same breath. A file the scan marks infected or failed can never be downloaded or re-uploaded.
Uploads work the other way round: only a file belonging to the same person in the same organization is accepted, and only once its scan has passed. Anything else is refused.
Each of the three has its own confirmActions category, download, upload and pdf, so a person can approve each file before it moves.
In a signed-in session the login’s access level decides as well: pdf counts as reading, while download and upload count as writes that cannot be held one at a time, so they are refused on a read or act login and need act-auto.
Caps
maxDownloadMb caps each file, and your plan caps both the file and the total a single run may move:
A
maxDownloadMb above your plan’s limit is lowered to it rather than refused. A file over the cap, or a run that has used up its total, is refused with file_cap.
What the chat model may do
When the chat model drives the browser itself, the same settings apply and these rules too:- It may upload a file the person attached in their current message or the one before it. An older file is refused, and the message asks them to send it again so it can be uploaded in that turn.
- It may save downloads and PDFs for the person like your code can, and it never runs page scripts.
- On the person’s own desktop browser the model cannot upload a file from the chat at all, since that browser can only reach files on their computer. It asks them to attach the file to the page themselves.
File error codes
Page scripts
Browser.eval runs one script in the page and returns its result. It is for the cases a command cannot reach: a value computed by the page, a count across a table, a bit of state only the page knows.
allowScripts: true and an allowedDomains list naming at least one real domain, such as 'reports.example.com' or '*.reports.example.com'. A single word with no dot, or an IP address, does not count, and lua compile refuses allowScripts: true without a real domain. Without both, eval is refused with scripts_disabled.
Scripts are for your code only:
- The chat model never runs scripts, on any browser.
Browser.executenever runs scripts either: it reportsinvalid_argumentand says to callBrowser.evalfrom your own code.- Scripts never run in a signed-in session, whatever the login’s access level.
- Scripts are not available on the Browser-Use browser (
remote_session).
script log row carrying the script’s hash, its size, the size of the result and whether it worked, never the script’s text.
Limits
The session limits are defaults. Raise them withmaxSessionMinutes and idleTimeoutSeconds on browser or on a named browser, up to the maximum. The Browser.read and Browser.execute limits are set per call. The file limits come from your plan.
When a Lua cloud browser session reaches its length or idle limit it closes, and the next command fails with
session_lost; open the page again. A command that would open one session too many fails with BROWSER_SESSION_LIMIT. The Lua cloud browser never opens private or internal network addresses.
Logs
Every browser command writes rows to the agent’s logs under thebrowser source:
Arguments that look like secrets are redacted. Page text appears only with
logContent: 'full'. Rows written by lua browser carry the dev channel.
Errors
Browser.read throws an error with name: 'BrowserError' and one of these codes. Browser.execute and the step-by-step methods return the code in code instead. Every method rejects with BROWSER_DISABLED and BROWSER_UNAVAILABLE.
The file and login codes are listed with their own sections.
On engine
'browser-use', the step-by-step commands return no code; their error starts with BROWSER_STEPWISE_UNSUPPORTED.
Browser.execute adds these codes:
Testing
lua test does not open a browser: every Browser method, execute, login, download and eval included, rejects with BrowserError with code BROWSER_UNAVAILABLE. Secrets.request({ kind: 'browser-login' }) refuses there too, with secrets_unavailable, because a login belongs to a person in a live chat. Try a page or a task from the terminal with lua browser read and lua browser run, or push the agent and run the tool, job, or webhook on the platform, then read lua logs --type browser.
Types
These types are exported fromlua-cli:
BrowserApi,BrowserStepwiseApi,BrowserStepwiseCommandName,BrowserSessionInput,BrowserCommandInputs,BrowserCommandResultBrowserApiReadOptions,BrowserReadOptions,BrowserReadResult,BrowserReadFormat,BrowserReadLoadStateBrowserExecuteInput,BrowserExecuteResult,BrowserExecuteStatus,BrowserExecuteStopReason,BrowserExecuteStep,BrowserExecutePendingActionBrowserElementInput,BrowserFileResultBrowserLoginInput,BrowserLoginResult,BrowserLoginStatus,BrowserLoginAccess,BrowserLoginLinkDelivery,BrowserLoginRequestInput,BrowserLoginRequestReceipt,BrowserJobLoginGrantInput,BrowserJobLoginGrantResultBrowserErrorCode,BrowserErrorFieldsBrowserSwitchConfig,LuaBrowserConfig,LuaBrowserSettings,BrowserProfileOption
See also
LuaBrowser— named browsers and every setting one takes- Use the browser — which method to reach for, and the settings worth having from the start
LuaAgent— thebrowserandbrowsersoptionslua browser— read a page or run a task from the terminal, and list or delete named browsers- Logs and debugging — reading agent logs

