browserTools(The browser tools:options):ToolSet
browser_open, browser_click, browser_fill,
browser_select, browser_press, browser_scroll and
browser_screenshot, over Telnyx Agent Browser. Pass them to
createHarness({ tools }), alone or beside your own.
Each durable run holds one browser session, opened on the site of the
first URL the model opens (that host and its subdomains), replaced when
the model opens another site, and closed when the run ends: the operation
that ended the run waits for the close for at most
HARNESS_RUN_END_TIMEOUT_MS (ten seconds). If the API answers neither
the create nor the DELETE within that, the session may still be live when
that operation returns, and the API ends it by its idle timeout (idleTimeoutS)
or lifetime. Under a plain turn() (no run) the tools share one session
that only the API’s idle timeout closes. The model acts
on the page by the element refs in the page tree it gets back; a stale
observation is refreshed once, a ref that is gone is answered with the
page read again, and the tree is cut at BROWSER_TREE_MAX_CHARS
characters and BROWSER_MAX_REFS refs. A failure comes back to the
model as text it can act on, not as a failed run.
Parameters
Returns
ToolSet
Over Agent Browser
browserTools() is exported from @telnyx/agent-harness/tools, from 0.1.0-beta.3. The tools call Agent Browser through transport, the Telnyx API client; in a deployed function that is the TELNYX binding.
A page is a
BrowserPage: the URL, the title, the element refs (e13: link "Learn more") and the text tree, cut at 20,000 characters and 300 refs. A stale observation is refreshed once. A ref that is gone is answered with the page read again. A failure, such as a link to another site or a site that refuses to load, comes back to the model as text, not as a failed run.
Sessions
- Per run. Each durable run holds at most one session, keyed by the run’s id. The tools learn the run from the harness; the host wires nothing. A run paused for approval keeps its session until it ends.
- Per site. The session’s domain policy is the host of the first URL the model opens and its subdomains, plus the bare host when the URL starts with
www.(seesiteDomains()). Opening another site closes the session and opens one for that site.browser_openwaits up to 45 seconds for a new session to be ready. - Cleanup. The session is closed when the run ends: completed, failed or canceled. The harness operation that ended the run waits for the close for at most 10 seconds, the harness’s run-end timeout. If the API does not answer within it, the operation returns with the session possibly live, and the session’s idle timeout (
idleTimeoutS) or lifetime (lifetimeS) ends it. - Reopen. A session the platform ended is reopened once per run.
- Without a run. Under a plain
turn()the tools share one session, which only its idle timeout closes. - Budget. A run takes at most
actionsbrowser actions, 40 by default.
BrowserToolsOptions
Properties actions?How many actions a run may take. Default DEFAULT_BROWSER_ACTIONS. idleTimeoutS?optionalactions?:number
How long a session lives without an action, in seconds. Default BROWSER_IDLE_TIMEOUT_DEFAULT_S. lifetimeS?optionalidleTimeoutS?:number
How long a session may live, in seconds. Default BROWSER_LIFETIME_DEFAULT_S. log?optionallifetimeS?:number
Where the tools’ log lines go: one per call with the tool, its URL or ref and the time it took, and one per session opened or closed. Default: each line as JSON on standard output. Never the value of a fill. Parametersoptionallog?: (line) =>void
Returns
void
now?
The clock, for tests. Returnsoptionalnow?: () =>number
number
sleep?
The pause between readiness polls, for tests. Parametersoptionalsleep?: (ms) =>Promise<void>
Returns
Promise<void>
transport
transport:The Telnyx API client the tools call, or a function returning it. The function form is called on every call, so a host can resolve the client lazily and throw its own message when there is none; the message reaches the model as the tool’s answer.BrowserTransport| (() =>BrowserTransport)
BrowserTransport
The slice of a Telnyx API client the browser tools call. Paths are relative to the API’s/v2; the Telnyx client bound to a deployed function has all
three methods, and a test’s fake declares them.
Methods
delete()
delete<Type ParametersT>(path):PromiseLike<T>
Parameters
Returns
PromiseLike<T>
get()
get<Type ParametersT>(path,opts?):PromiseLike<T>
Parameters
Returns
PromiseLike<T>
post()
post<Type ParametersT>(path,opts?):PromiseLike<T>
Parameters
Returns
PromiseLike<T>
BrowserPage
The page as the model sees it after an action. Properties refsrefs:The element refs the model may act on:Record<string,string>
e13: link "Learn more".
title
title: string
tree
tree: string
truncated
truncated: boolean
url
url: string
BrowserObservation
A page as the API observes it. Properties observation_id?refs?optionalobservation_id?:string
title?optionalrefs?:Record<string, {name?:string;role?:string; }>
tree?optionaltitle?:string
truncated?optionaltree?:string
url?optionaltruncated?:boolean
optionalurl?:string
browserToolNames()
browserToolNames(): string[]
Returns
string[]
BROWSER_TOOL_NAMES
The names browserTools returns, so a host can list them or name them in an approval policy.constBROWSER_TOOL_NAMES: readonly ["browser_open","browser_click","browser_fill","browser_select","browser_press","browser_scroll","browser_screenshot"]
BrowserToolName
BrowserToolName = typeofBROWSER_TOOL_NAMES[number]
BROWSER_KEYS
The keysconstBROWSER_KEYS: readonly ["Enter","Tab","Escape","Backspace","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End"]
browser_press takes.
siteDomains()
siteDomains(The session policy for a site: the host and its subdomains, and the bare host with its subdomains when the model openedhostname):string[]
www., since a site’s
links go between the two. No guessed apex: without the public suffix list
a guess is either too wide (*.github.io for one site) or wrong
(co.uk), so a link to a sibling host is a browser_open away.
Parameters
Returns
string[]
trimPage()
trimPage(The observation within the model’s budget: the tree cut at BROWSER_TREE_MAX_CHARS, refs as one line each, at most BROWSER_MAX_REFS. Parametersobs):BrowserPage
Returns
BrowserPage
DEFAULT_BROWSER_ACTIONS
How many actions a run may take by default.constDEFAULT_BROWSER_ACTIONS:40=40
BROWSER_LIFETIME_DEFAULT_S
The API’s defaults for a session’s lifetime and idle timeout, in seconds.constBROWSER_LIFETIME_DEFAULT_S:900=900
BROWSER_IDLE_TIMEOUT_DEFAULT_S
constBROWSER_IDLE_TIMEOUT_DEFAULT_S:300=300
BROWSER_TREE_MAX_CHARS
How much of a page’s tree one observation hands the model, and how many refs.constBROWSER_TREE_MAX_CHARS:20000=20_000
BROWSER_MAX_REFS
constBROWSER_MAX_REFS:300=300