donobu
Version:
Create browser automations with an LLM agent and replay them as Playwright scripts.
140 lines • 5.61 kB
JavaScript
"use strict";
// src/models/BrowserConfig.ts
Object.defineProperty(exports, "__esModule", { value: true });
exports.BrowserConfigSchema = exports.BrowserBaseSessionArgsSchema = void 0;
const v4_1 = require("zod/v4");
const BrowserStateFlowReference_1 = require("./BrowserStateFlowReference");
/**
* Broadly follows the HTTP body fields described in...
* https://docs.browserbase.com/reference/api/create-a-session
*/
exports.BrowserBaseSessionArgsSchema = v4_1.z.object({
projectId: v4_1.z.string().describe('The project ID for the BrowserBase session'),
extensionId: v4_1.z.string().optional().describe('Optional extension ID'),
browserSettings: v4_1.z
.object({
context: v4_1.z
.object({
id: v4_1.z.string().describe('Context ID'),
})
.optional()
.describe('Browser context settings'),
extensionId: v4_1.z
.string()
.optional()
.describe('Extension ID in browser settings'),
viewport: v4_1.z
.object({
width: v4_1.z.number().describe('Viewport width in pixels'),
height: v4_1.z.number().describe('Viewport height in pixels'),
})
.optional()
.describe('Viewport dimensions'),
blockAds: v4_1.z
.boolean()
.optional()
.describe('Whether to block advertisements'),
solveCaptchas: v4_1.z
.boolean()
.optional()
.describe('Whether to automatically solve captchas'),
advancedStealth: v4_1.z
.boolean()
.optional()
.describe('Whether to enable advanced stealth mode'),
})
.optional()
.describe('Browser-specific settings'),
timeout: v4_1.z
.number()
.optional()
.describe('Duration in seconds after which the session will automatically end'),
keepAlive: v4_1.z
.boolean()
.optional()
.describe('Set to true to keep the session alive even after disconnections. Available on the Hobby Plan and above.'),
proxies: v4_1.z
.boolean()
.optional()
.describe("Set to true to use BrowserBase's built-in proxies, with no particular configuration.")
.or(v4_1.z.array(v4_1.z.discriminatedUnion('type', [
v4_1.z.object({
type: v4_1.z.literal('browserbase'),
geolocation: v4_1.z
.object({
country: v4_1.z.string().length(2),
state: v4_1.z.string().length(2).optional(),
city: v4_1.z.string().optional(),
})
.optional(),
domainPattern: v4_1.z.string().optional(),
}),
v4_1.z.object({
type: v4_1.z.literal('external'),
server: v4_1.z.string(),
username: v4_1.z.string().optional(),
password: v4_1.z.string().optional(),
domainPattern: v4_1.z.string().optional(),
}),
]))),
region: v4_1.z
.string()
.optional()
.describe('Geographic region for the browser session'),
userMetadata: v4_1.z
.record(v4_1.z.string(), v4_1.z.string())
.optional()
.describe('Custom user metadata as key-value pairs'),
});
exports.BrowserConfigSchema = v4_1.z.object({
initialState: BrowserStateFlowReference_1.BrowserStateReferenceSchema.optional().describe('When starting the flow, initialize the browser state from here'),
persistState: v4_1.z
.boolean()
.optional()
.describe('If set to true, saves the browser state at the end of the flow'),
using: v4_1.z
.discriminatedUnion('type', [
v4_1.z.object({
type: v4_1.z.literal('device').describe('Use a local device browser'),
deviceName: v4_1.z
.string()
.optional()
.describe("The name of the device to run the flow with. See devices.json for details. If not specified, defaults to 'Desktop Chromium'"),
headless: v4_1.z
.boolean()
.optional()
.describe('If true, will not open a real browser window to perform the flow'),
proxy: v4_1.z
.object({
server: v4_1.z.string(),
bypass: v4_1.z.string().optional(),
username: v4_1.z
.string()
.optional()
.describe('Will default to process.env.PROXY_USERNAME'),
password: v4_1.z
.string()
.optional()
.describe('Will default to process.env.PROXY_PASSWORD'),
})
.optional()
.describe('Optional network proxy configuration'),
}),
v4_1.z.object({
type: v4_1.z
.literal('remoteInstance')
.describe('Connect to a remote browser instance'),
url: v4_1.z
.string()
.describe('The URL of a remote browser instance to connect to using the Chrome DevTools Protocol (CDP)'),
}),
v4_1.z.object({
type: v4_1.z
.literal('browserBase')
.describe('Use BrowserBase cloud browser service'),
sessionArgs: exports.BrowserBaseSessionArgsSchema.describe('Configuration arguments for the BrowserBase session'),
}),
])
.describe('Browser configuration type and settings'),
});
//# sourceMappingURL=BrowserConfig.js.map