Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sentienceapi",
"version": "0.92.0",
"version": "0.92.1",
"description": "TypeScript SDK for Sentience AI Agent Browser Automation",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
28 changes: 27 additions & 1 deletion src/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,24 @@ export class SentienceBrowser implements IBrowser {
private _recordVideoDir?: string;
private _recordVideoSize?: { width: number; height: number };
private _viewport?: { width: number; height: number };
private _deviceScaleFactor?: number;

/**
* Create a new SentienceBrowser instance
*
* @param apiKey - Optional API key for server-side processing (Pro/Enterprise tiers)
* @param apiUrl - Optional API URL (defaults to https://api.sentienceapi.com if apiKey provided)
* @param headless - Whether to run in headless mode (defaults to true in CI, false locally)
* @param proxy - Optional proxy server URL (e.g., 'http://user:pass@proxy.example.com:8080')
* @param userDataDir - Optional path to user data directory for persistent sessions
* @param storageState - Optional storage state to inject (cookies + localStorage)
* @param recordVideoDir - Optional directory path to save video recordings
* @param recordVideoSize - Optional video resolution as object with 'width' and 'height' keys
* @param viewport - Optional viewport size as object with 'width' and 'height' keys
* @param deviceScaleFactor - Optional device scale factor to emulate high-DPI (Retina) screens.
* Examples: 1.0 (default, standard DPI), 2.0 (Retina/high-DPI, like MacBook Pro), 3.0 (very high DPI)
* If undefined, defaults to 1.0 (standard DPI).
*/
constructor(
apiKey?: string,
apiUrl?: string,
Expand All @@ -37,7 +54,8 @@ export class SentienceBrowser implements IBrowser {
storageState?: string | StorageState | object,
recordVideoDir?: string,
recordVideoSize?: { width: number; height: number },
viewport?: { width: number; height: number }
viewport?: { width: number; height: number },
deviceScaleFactor?: number
) {
this._apiKey = apiKey;

Expand Down Expand Up @@ -72,6 +90,9 @@ export class SentienceBrowser implements IBrowser {

// Viewport configuration
this._viewport = viewport || { width: 1280, height: 800 };

// Device scale factor for high-DPI emulation
this._deviceScaleFactor = deviceScaleFactor;
}

async start(): Promise<void> {
Expand Down Expand Up @@ -171,6 +192,11 @@ export class SentienceBrowser implements IBrowser {
ignoreHTTPSErrors: proxyConfig !== undefined,
};

// Add device scale factor if configured
if (this._deviceScaleFactor !== undefined) {
launchOptions.deviceScaleFactor = this._deviceScaleFactor;
}

// Add video recording if configured
if (this._recordVideoDir) {
launchOptions.recordVideo = {
Expand Down
Loading