Skip to content

System & Automation

Manage concurrent worker pools for batch processing. See Queue Workers for full details.

MethodSignatureAsyncDescription
start(options)NoLaunch worker pools
stop(queueName?)NoStop workers (all or by queue)
pause()NoPause all dequeue operations
resume()NoResume dequeue operations
status() → WorkerPoolStatus[]NoGet status of all pools

WorkerStartOptions:

{
clearTabs?: boolean
layout?: "horizontal" | "vertical" | "quad"
workers: WorkerPoolOptions[]
}

WorkerPoolOptions:

{
queue: string
script: string
concurrency?: number
throttle?: { requestsPerMinute?: number }
dequeue?: string
requiresWorkflowEnvelope?: boolean
}

Set requiresWorkflowEnvelope: true for workflow-owned queues that must only process items linked to a Workflow Ledger run/item envelope.


Available only inside worker scripts.

MethodSignatureAsyncDescription
getContext() → WorkerContextNoGet the current item, tab ID, and queue name

WorkerContext:

{
item: QueueItem
tabId: string
queueName: string
}


Access captured HTTP traffic. Capture must be enabled (it is by default).

MethodSignatureAsyncDescription
search(query?, options?) → TrafficEntryInfo[]NoSearch captured traffic
getById(id) → TrafficEntryInfo | nullNoGet a specific traffic entry
getResponseBody(id) → string | nullNoGet the response body
getRequestBody(id) → string | nullNoGet the request body
count() → numberNoCount captured entries
clear()NoClear all captured traffic
enable()NoEnable traffic capture
disable()NoDisable traffic capture
isEnabled() → booleanNoCheck if capture is enabled
waitForRequest(urlPattern, options?) → Promise<TrafficEntryInfo>YesWait for a matching request

NetworkSearchOptions:

{
method?: string // "GET", "POST", etc.
statusMin?: number
statusMax?: number
contentType?: string
tabId?: string
limit?: number // default: 100
offset?: number // default: 0
sort?: string // timestamp, url, status, size, duration, method
order?: string // "asc" or "desc" (default)
}

WaitForRequestOptions:

{
method?: string
timeout?: number // default: 30000ms
}
async function main() {
await g.nav.navigateToUrl("https://api.example.com/data");
// Wait for the API response
const entry = await g.network.waitForRequest("api.example.com/data");
const body = g.network.getResponseBody(entry.id);
const data = JSON.parse(body);
g.log("Got " + data.items.length + " items");
}


MethodSignatureAsyncDescription
search(query?, options?) → NavigationEntryInfo[]NoSearch navigation history
count() → numberNoCount history entries
clear()NoClear all history

HistorySearchOptions:

{
tabId?: string
limit?: number // default: 100
offset?: number // default: 0
sort?: string // "timestamp" (default), "url", "status"
order?: string // "asc" or "desc" (default)
}


Automatic robots.txt checking for scripted automation. Enabled by default.

MethodSignatureAsyncDescription
isAllowed(url) → Promise<boolean>YesCheck if a URL is allowed by robots.txt
getCrawlDelay(url) → Promise<number | null>YesGet the crawl-delay for a domain
disable()NoDisable robots.txt checking for this script
enable()NoRe-enable robots.txt checking


Inspect and switch between workflows within a workspace.

MethodSignatureAsyncDescription
getActive() → WorkflowInfo | nullNoGet the active workflow’s name and path
list() → WorkflowListItem[]NoList all workflows in the workspace
switch(name)NoSwitch to a workflow (fire-and-forget, happens on UI thread)

WorkflowInfo:

{
name: string // workflow name
path: string // absolute path to workflow folder
}

WorkflowListItem:

{
name: string
enabled: boolean
hasEvents: boolean // has events.json triggers
hasWorkers: boolean // has workers.json config
hasTools: boolean // has tools/ directory
hasViews: boolean // has views/ directory
scriptCount: number // number of script files
}


Available inside scripts executed by event triggers. Returns metadata about why the script was invoked.

MethodSignatureAsyncDescription
getContext() → TriggerContextNoGet event data for the current trigger execution

TriggerContext:

{
event: string // "url-match", "page-loaded", "tab-created", "tab-closed",
// "tab-activated", "external-queue", "dom-mutation"
tabId?: string // browser tab associated with the event
url?: string // page URL at the time of the event
timestamp: string // ISO 8601
pattern?: string // URL pattern that matched (url-match only)
// dom-mutation fields:
oldValue?: string // previous value
newValue?: string // new value
attribute?: string // changed attribute name (null for text changes)
mutationType?: string // "characterData", "attributes", or "childList"
selector?: string // CSS selector that matched
changes?: object[] // array of mutations (buffer strategy only)
}
async function main() {
const ctx = g.trigger.getContext();
if (ctx.event === "url-match") {
g.log("Matched " + ctx.pattern + " on " + ctx.url);
}
if (ctx.event === "dom-mutation") {
g.log(ctx.selector + " changed: " + ctx.oldValue + "" + ctx.newValue);
}
}