Class: Browser

Represents a browser session using Puppeteer. Manages the creation of new browser pages and handles the browser instance.

Constructors

new Browser()

new Browser(browser: Browser, agent: Agent, logger?: Logger, opts?: {apiKey: string;disableMemory: boolean;endpoint: string;inventory: Inventory;mode: BrowserMode; }): Browser

Initializes a new instance of the Browser class.

Parameters

ParameterTypeDescription
browserBrowserThe Puppeteer browser instance.
agentAgentThe agent instance that interacts with the browser.
logger?LoggerOptional logger for logging browser activities.
opts?objectOptional configuration options for the browser.
opts.apiKey?stringThe API key for the browser.
opts.disableMemory?booleanSpecifies if the browser should disable memory.
opts.endpoint?stringThe HDR collective memory endpoint.
opts.inventory?InventoryThe inventory to use for the browser.
opts.mode?BrowserModeThe mode of the browser (e.g., text).

Returns

Browser

Defined in

src/browser/browser.ts:48

Properties

agent

agent: Agent

The agent instance that interacts with the browser.

Defined in

src/browser/browser.ts:31


browser

browser: Browser

The Puppeteer browser instance.

Defined in

src/browser/browser.ts:29


logger?

optional logger: Logger

Optional logger for logging browser activities.

Defined in

src/browser/browser.ts:32


mode

mode: BrowserMode

The mode of the browser which could be headless or non-headless.

Defined in

src/browser/browser.ts:30


pages

pages: Map<string, Page>

Defined in

src/browser/browser.ts:25

Methods

close()

close(): Promise<void>

Closes all pages and the browser instance.

Returns

Promise<void>

A promise that resolves when all pages and the browser have been closed.

Defined in

src/browser/browser.ts:165


newPage()

newPage(opts?: {agent: Agent;device: Device;disableMemory: boolean;inventory: Inventory;pageId: string; }): Promise<Page>

Asynchronously creates and returns a new Page instance, potentially emulating a specific device.

Parameters

ParameterType
opts?object
opts.agent?Agent
opts.device?Device
opts.disableMemory?boolean
opts.inventory?Inventory
opts.pageId?string

Returns

Promise<Page>

A promise that resolves to the newly created Page instance.

Defined in

src/browser/browser.ts:124


launch()

static launch(headless: boolean, agent: Agent, logger?: Logger, opts?: {apiKey: string;browserLaunchArgs: string[];browserWSEndpoint: string;disableMemory: boolean;endpoint: string;inventory: Inventory;mode: BrowserMode; }): Promise<Browser>

Asynchronously launch a new Browser instance with given configuration.

Parameters

ParameterTypeDescription
headlessbooleanSpecifies if the browser should be launched in headless mode.
agentAgentThe agent that will interact with the browser.
logger?LoggerOptional logger to pass for browser operation logs.
opts?objectOptional configuration options for launching the browser.
opts.apiKey?stringThe API key for the browser.
opts.browserLaunchArgs?string[]Additional arguments for launching the browser.
opts.browserWSEndpoint?stringThe WebSocket endpoint to connect to a browser instance.
opts.disableMemory?booleanSpecifies if the browser should disable memory.
opts.endpoint?stringThe HDR collective memory endpoint.
opts.inventory?InventoryThe inventory to use for the browser.
opts.mode?BrowserModeThe mode of the browser, defaults to text.

Returns

Promise<Browser>

A promise that resolves to an instance of Browser.

Defined in

src/browser/browser.ts:89