@poncho-ai/browser 0.6.0 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
 
2
- > @poncho-ai/browser@0.6.0 build /Users/cesar/Dev/latitude/poncho-ai/packages/browser
2
+ > @poncho-ai/browser@0.6.2 build /home/runner/work/poncho-ai/poncho-ai/packages/browser
3
3
  > tsup src/index.ts --format esm --dts
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -7,8 +7,8 @@
7
7
  CLI tsup v8.5.1
8
8
  CLI Target: es2022
9
9
  ESM Build start
10
- ESM dist/index.js 40.85 KB
11
- ESM ⚡️ Build success in 76ms
10
+ ESM dist/index.js 41.37 KB
11
+ ESM ⚡️ Build success in 75ms
12
12
  DTS Build start
13
- DTS ⚡️ Build success in 1346ms
14
- DTS dist/index.d.ts 13.55 KB
13
+ DTS ⚡️ Build success in 4983ms
14
+ DTS dist/index.d.ts 13.59 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @poncho-ai/browser
2
2
 
3
+ ## 0.6.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`6f0abfd`](https://github.com/cesr/poncho-ai/commit/6f0abfd9f729b545cf293741ee813f705910aaf3)]:
8
+ - @poncho-ai/sdk@1.5.0
9
+
10
+ ## 0.6.1
11
+
12
+ ### Patch Changes
13
+
14
+ - Pass `@sparticuz/chromium` recommended args (--no-sandbox, --disable-gpu, etc.) when launching on serverless platforms. Fixes Chromium sandbox crash on Vercel/Lambda.
15
+
3
16
  ## 0.6.0
4
17
 
5
18
  ### Minor Changes
package/dist/index.d.ts CHANGED
@@ -111,10 +111,11 @@ declare class BrowserSession {
111
111
  private get isRemote();
112
112
  private get isServerless();
113
113
  /**
114
- * Resolve executablePath for local launches. When no explicit path is set
115
- * and we're on a serverless platform, try `@sparticuz/chromium` automatically.
114
+ * Resolve executablePath and launch args for serverless platforms.
115
+ * When `@sparticuz/chromium` is installed, uses its executable and
116
+ * recommended args (--no-sandbox, --disable-gpu, etc.).
116
117
  */
117
- private resolveExecutablePath;
118
+ private resolveServerlessChromium;
118
119
  private launchFreshManager;
119
120
  private ensureManager;
120
121
  private evictOldestTab;
package/dist/index.js CHANGED
@@ -345,12 +345,13 @@ var BrowserSession = class {
345
345
  return !!(process.env.VERCEL || process.env.AWS_LAMBDA_FUNCTION_NAME || process.env.AWS_EXECUTION_ENV || process.env.SERVERLESS);
346
346
  }
347
347
  /**
348
- * Resolve executablePath for local launches. When no explicit path is set
349
- * and we're on a serverless platform, try `@sparticuz/chromium` automatically.
348
+ * Resolve executablePath and launch args for serverless platforms.
349
+ * When `@sparticuz/chromium` is installed, uses its executable and
350
+ * recommended args (--no-sandbox, --disable-gpu, etc.).
350
351
  */
351
- async resolveExecutablePath() {
352
- if (this.config.executablePath) return this.config.executablePath;
353
- if (!this.isServerless) return void 0;
352
+ async resolveServerlessChromium() {
353
+ if (this.config.executablePath) return { executablePath: this.config.executablePath };
354
+ if (!this.isServerless) return {};
354
355
  try {
355
356
  const spec = ["@sparticuz", "chromium"].join("/");
356
357
  const mod = await import(
@@ -358,23 +359,24 @@ var BrowserSession = class {
358
359
  spec
359
360
  );
360
361
  const chromium = mod.default ?? mod;
361
- const path = await chromium.executablePath();
362
- console.log(`[poncho][browser] Auto-detected @sparticuz/chromium: ${path}`);
363
- return path;
362
+ const executablePath = await chromium.executablePath();
363
+ const args = Array.isArray(chromium.args) ? chromium.args : [];
364
+ console.log(`[poncho][browser] Auto-detected @sparticuz/chromium: ${executablePath} (${args.length} args)`);
365
+ return { executablePath, args };
364
366
  } catch {
365
- return void 0;
367
+ return {};
366
368
  }
367
369
  }
368
370
  async launchFreshManager() {
369
371
  const Ctor = await getBrowserManagerCtor();
370
372
  const mgr = new Ctor();
371
373
  const viewport = this.config.viewport ?? { width: 1280, height: 720 };
372
- const executablePath = await this.resolveExecutablePath();
374
+ const serverless = await this.resolveServerlessChromium();
373
375
  const launchOpts = {
374
376
  action: "launch",
375
377
  headless: this.config.headless ?? true,
376
378
  viewport: { width: viewport.width ?? 1280, height: viewport.height ?? 720 },
377
- executablePath
379
+ executablePath: serverless.executablePath
378
380
  };
379
381
  if (this.config.cdpUrl) {
380
382
  launchOpts.cdpUrl = this.config.cdpUrl;
@@ -387,16 +389,25 @@ var BrowserSession = class {
387
389
  await mkdir(profileDir, { recursive: true });
388
390
  launchOpts.profile = profileDir;
389
391
  }
392
+ const baseArgs = serverless.args ?? [];
390
393
  if (this.stealthEnabled) {
391
394
  const ua = this.stealthUserAgent;
392
395
  launchOpts.userAgent = ua;
393
396
  if (!this.isRemote) {
394
- launchOpts.args = buildStealthArgs(ua);
397
+ const stealthArgs = buildStealthArgs(ua);
398
+ const merged = [...baseArgs];
399
+ for (const arg of stealthArgs) {
400
+ if (!merged.includes(arg)) merged.push(arg);
401
+ }
402
+ launchOpts.args = merged;
395
403
  }
396
404
  console.log("[poncho][browser] Launching with stealth mode enabled (UA: " + ua + ")");
397
405
  } else if (this.config.userAgent) {
398
406
  launchOpts.userAgent = this.config.userAgent;
399
407
  }
408
+ if (!launchOpts.args && baseArgs.length > 0) {
409
+ launchOpts.args = baseArgs;
410
+ }
400
411
  await mgr.launch(launchOpts);
401
412
  this._contextStealthInstalled = false;
402
413
  this._uaOverrideApplied.clear();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@poncho-ai/browser",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "description": "Browser automation for Poncho agents, powered by agent-browser",
5
5
  "repository": {
6
6
  "type": "git",
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "agent-browser": "^0.15.1",
24
- "@poncho-ai/sdk": "1.4.1"
24
+ "@poncho-ai/sdk": "1.5.0"
25
25
  },
26
26
  "devDependencies": {
27
27
  "tsup": "^8.0.0",
package/src/session.ts CHANGED
@@ -258,23 +258,26 @@ export class BrowserSession {
258
258
  }
259
259
 
260
260
  /**
261
- * Resolve executablePath for local launches. When no explicit path is set
262
- * and we're on a serverless platform, try `@sparticuz/chromium` automatically.
261
+ * Resolve executablePath and launch args for serverless platforms.
262
+ * When `@sparticuz/chromium` is installed, uses its executable and
263
+ * recommended args (--no-sandbox, --disable-gpu, etc.).
263
264
  */
264
- private async resolveExecutablePath(): Promise<string | undefined> {
265
- if (this.config.executablePath) return this.config.executablePath;
266
- if (!this.isServerless) return undefined;
265
+ private async resolveServerlessChromium(): Promise<{
266
+ executablePath?: string;
267
+ args?: string[];
268
+ }> {
269
+ if (this.config.executablePath) return { executablePath: this.config.executablePath };
270
+ if (!this.isServerless) return {};
267
271
  try {
268
- // Dynamic require — @sparticuz/chromium is an optional peer dependency
269
- // that the user installs in their agent project for serverless runtimes.
270
272
  const spec = ["@sparticuz", "chromium"].join("/");
271
273
  const mod = await import(/* webpackIgnore: true */ spec);
272
274
  const chromium = mod.default ?? mod;
273
- const path = await chromium.executablePath();
274
- console.log(`[poncho][browser] Auto-detected @sparticuz/chromium: ${path}`);
275
- return path;
275
+ const executablePath = await chromium.executablePath();
276
+ const args: string[] = Array.isArray(chromium.args) ? chromium.args : [];
277
+ console.log(`[poncho][browser] Auto-detected @sparticuz/chromium: ${executablePath} (${args.length} args)`);
278
+ return { executablePath, args };
276
279
  } catch {
277
- return undefined;
280
+ return {};
278
281
  }
279
282
  }
280
283
 
@@ -283,13 +286,13 @@ export class BrowserSession {
283
286
  const mgr = new Ctor();
284
287
 
285
288
  const viewport = this.config.viewport ?? { width: 1280, height: 720 };
286
- const executablePath = await this.resolveExecutablePath();
289
+ const serverless = await this.resolveServerlessChromium();
287
290
 
288
291
  const launchOpts: Record<string, unknown> = {
289
292
  action: "launch",
290
293
  headless: this.config.headless ?? true,
291
294
  viewport: { width: viewport.width ?? 1280, height: viewport.height ?? 720 },
292
- executablePath,
295
+ executablePath: serverless.executablePath,
293
296
  };
294
297
 
295
298
  if (this.config.cdpUrl) {
@@ -306,17 +309,29 @@ export class BrowserSession {
306
309
  launchOpts.profile = profileDir;
307
310
  }
308
311
 
312
+ // Merge args: serverless chromium args (--no-sandbox etc.) + stealth args
313
+ const baseArgs: string[] = serverless.args ?? [];
314
+
309
315
  if (this.stealthEnabled) {
310
316
  const ua = this.stealthUserAgent!;
311
317
  launchOpts.userAgent = ua;
312
318
  if (!this.isRemote) {
313
- launchOpts.args = buildStealthArgs(ua);
319
+ const stealthArgs = buildStealthArgs(ua);
320
+ const merged = [...baseArgs];
321
+ for (const arg of stealthArgs) {
322
+ if (!merged.includes(arg)) merged.push(arg);
323
+ }
324
+ launchOpts.args = merged;
314
325
  }
315
326
  console.log("[poncho][browser] Launching with stealth mode enabled (UA: " + ua + ")");
316
327
  } else if (this.config.userAgent) {
317
328
  launchOpts.userAgent = this.config.userAgent;
318
329
  }
319
330
 
331
+ if (!launchOpts.args && baseArgs.length > 0) {
332
+ launchOpts.args = baseArgs;
333
+ }
334
+
320
335
  await mgr.launch(launchOpts as Parameters<BrowserManagerInstance["launch"]>[0]);
321
336
 
322
337
  // Reset stealth tracking for fresh browser
@@ -1,12 +0,0 @@
1
-
2
- > @poncho-ai/browser@0.3.0 test /Users/cesar/Dev/latitude/poncho-ai/packages/browser
3
- > vitest --passWithNoTests
4
-
5
-
6
-  RUN  v1.6.1 /Users/cesar/Dev/latitude/poncho-ai/packages/browser
7
-
8
- include: **/*.{test,spec}.?(c|m)[jt]s?(x)
9
- exclude: **/node_modules/**, **/dist/**, **/cypress/**, **/.{idea,git,cache,output,temp}/**, **/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*
10
- watch exclude: **/node_modules/**, **/dist/**
11
- No test files found, exiting with code 0
12
-