@nuanu-ai/agentbrowse 0.2.25 → 0.2.27

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.
@@ -3,25 +3,25 @@
3
3
  */
4
4
  import { loadSession, deleteSession } from '../session.js';
5
5
  import { info } from '../output.js';
6
- import { terminateOwnedPid } from '../owned-process.js';
6
+ import { closeOwnedBrowser } from '../owned-browser.js';
7
7
  function isOwnedSessionRecord(session) {
8
8
  return session?.identity?.ownership === 'agentbrowse';
9
9
  }
10
10
  export async function close() {
11
11
  const session = loadSession();
12
12
  if (isOwnedSessionRecord(session)) {
13
- const termination = await terminateOwnedPid(session.pid);
14
- if (termination === 'still_alive') {
15
- info(`Owned browser pid ${session.pid} did not exit; keeping session record`);
13
+ const closeResult = await closeOwnedBrowser(session);
14
+ if (!closeResult.success) {
15
+ info(`Owned browser close failed; keeping session record: ${closeResult.reason}`);
16
16
  return {
17
17
  success: false,
18
18
  error: 'browser_close_failed',
19
19
  outcomeType: 'blocked',
20
20
  message: 'Browser close failed.',
21
- reason: `Owned browser pid ${session.pid} did not exit after SIGTERM/SIGKILL.`,
21
+ reason: closeResult.reason,
22
22
  };
23
23
  }
24
- info(`Killed owned browser pid ${session.pid}`);
24
+ info(`Closed owned browser via ${closeResult.method}`);
25
25
  }
26
26
  if (session) {
27
27
  deleteSession();
@@ -1 +1 @@
1
- {"version":3,"file":"launch.d.ts","sourceRoot":"","sources":["../../src/commands/launch.ts"],"names":[],"mappings":"AAAA;;GAEG;AAWH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAWvE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,IAAI,CAAC;IACd,OAAO,EAAE,SAAS,CAAC;IACnB,mBAAmB,EAAE,IAAI,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,oBAAoB,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,KAAK,CAAC;IACf,KAAK,EAAE,uBAAuB,CAAC;IAC/B,WAAW,EAAE,SAAS,CAAC;IACvB,OAAO,EAAE,wBAAwB,CAAC;IAClC,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,mBAAmB,GAAG,mBAAmB,CAAC;AAErE,wBAAsB,MAAM,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,YAAY,CAAC,CAazF"}
1
+ {"version":3,"file":"launch.d.ts","sourceRoot":"","sources":["../../src/commands/launch.ts"],"names":[],"mappings":"AAAA;;GAEG;AAUH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAYvE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,IAAI,CAAC;IACd,OAAO,EAAE,SAAS,CAAC;IACnB,mBAAmB,EAAE,IAAI,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,oBAAoB,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,KAAK,CAAC;IACf,KAAK,EAAE,uBAAuB,CAAC;IAC/B,WAAW,EAAE,SAAS,CAAC;IACvB,OAAO,EAAE,wBAAwB,CAAC;IAClC,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,mBAAmB,GAAG,mBAAmB,CAAC;AAErE,wBAAsB,MAAM,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,YAAY,CAAC,CAazF"}
@@ -5,11 +5,11 @@ import { readConfig } from '../solver/config.js';
5
5
  import { ensureProfile } from '../solver/profile-manager.js';
6
6
  import { launchSolver } from '../solver/browser-launcher.js';
7
7
  import { buildOwnedSession, isOwnedSession, loadSession, saveSession } from '../session.js';
8
- import { findChromePid } from '../stagehand.js';
9
8
  import { applyAgentpayGatewayEnv, tryResolveAgentpayGatewayConfig } from '../agentpay-gateway.js';
10
9
  import { connectPlaywright, disconnectPlaywright, syncLaunchPage } from '../playwright-runtime.js';
11
10
  import { summarizeSecretCatalog, syncSecretCatalogForUrl } from '../secrets/catalog-sync.js';
12
- import { cleanupManagedBrowserPids, terminateOwnedPid } from '../owned-process.js';
11
+ import { closeOwnedBrowser } from '../owned-browser.js';
12
+ import { cleanupManagedBrowserPids } from '../owned-process.js';
13
13
  import { info } from '../output.js';
14
14
  const DEFAULT_PROFILE = 'default';
15
15
  const COMPACT_WINDOW = {
@@ -33,9 +33,9 @@ async function cleanupOwnedSession() {
33
33
  const excludePids = new Set();
34
34
  if (isOwnedSession(existingSession)) {
35
35
  excludePids.add(existingSession.pid);
36
- const termination = await terminateOwnedPid(existingSession.pid);
37
- if (termination === 'still_alive') {
38
- return buildLaunchFailure(new Error(`Existing owned browser pid ${existingSession.pid} did not exit after SIGTERM/SIGKILL.`));
36
+ const closeResult = await closeOwnedBrowser(existingSession);
37
+ if (!closeResult.success) {
38
+ return buildLaunchFailure(new Error(closeResult.reason));
39
39
  }
40
40
  }
41
41
  // Phase-1 ownership removed port-global prekill, so launch needs a second guardrail
@@ -58,19 +58,6 @@ function buildLaunchFailure(err) {
58
58
  reason: formatUnknownError(err),
59
59
  };
60
60
  }
61
- function getPortFromCdpUrl(cdpUrl) {
62
- try {
63
- const url = new URL(cdpUrl);
64
- if (!url.port) {
65
- return undefined;
66
- }
67
- const port = Number(url.port);
68
- return Number.isFinite(port) && port > 0 ? port : undefined;
69
- }
70
- catch {
71
- return undefined;
72
- }
73
- }
74
61
  async function launchManaged(url, profileName, headless, compact, proxyOverride, noProxy = false) {
75
62
  let session;
76
63
  let browser = null;
@@ -102,15 +89,9 @@ async function launchManaged(url, profileName, headless, compact, proxyOverride,
102
89
  catch (err) {
103
90
  return buildLaunchFailure(err);
104
91
  }
105
- const cdpPort = getPortFromCdpUrl(session.cdpUrl);
106
- const chromePid = findChromePid(cdpPort);
107
- if (!chromePid) {
108
- await session.close().catch(() => undefined);
109
- return buildLaunchFailure(new Error('Launched browser PID could not be resolved.'));
110
- }
111
92
  const persistedSession = buildOwnedSession({
112
93
  cdpUrl: session.cdpUrl,
113
- pid: chromePid,
94
+ pid: session.pid,
114
95
  profile: profileName,
115
96
  launchedAt: new Date().toISOString(),
116
97
  capabilities: {
@@ -1 +1 @@
1
- {"version":3,"file":"screenshot.d.ts","sourceRoot":"","sources":["../../src/commands/screenshot.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAWnD,wBAAsB,UAAU,CAAC,OAAO,EAAE,aAAa,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAmEzF"}
1
+ {"version":3,"file":"screenshot.d.ts","sourceRoot":"","sources":["../../src/commands/screenshot.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAWnD,wBAAsB,UAAU,CAAC,OAAO,EAAE,aAAa,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAsEzF"}
@@ -8,11 +8,9 @@ import { connectPlaywright, disconnectPlaywright, resolveCurrentPageContext, syn
8
8
  import { buildProtectedScreenshotBlockedResult } from '../secrets/protected-artifact-guard.js';
9
9
  export async function screenshot(session, filePath) {
10
10
  const outputPath = filePath ?? `/tmp/browse-screenshot-${Date.now()}.png`;
11
- let pageRef = session.runtime?.currentPageRef ?? 'p0';
12
- const initialProtectedExposure = getProtectedExposure(session, pageRef);
13
- if (initialProtectedExposure) {
14
- return outputFailure(buildProtectedScreenshotBlockedResult(initialProtectedExposure));
15
- }
11
+ const initialPageRef = session.runtime?.currentPageRef ?? 'p0';
12
+ let pageRef = initialPageRef;
13
+ const initialProtectedExposure = getProtectedExposure(session, initialPageRef);
16
14
  let browser = null;
17
15
  let failureMessage = null;
18
16
  let page = null;
@@ -35,8 +33,12 @@ export async function screenshot(session, filePath) {
35
33
  catch (err) {
36
34
  failureMessage = `Screenshot failed: ${err instanceof Error ? err.message : String(err)}`;
37
35
  }
38
- const recoveredProtectedExposure = getProtectedExposure(session, pageRef);
36
+ const recoveredProtectedExposure = getProtectedExposure(session, pageRef) ?? (!page ? initialProtectedExposure : null);
39
37
  if (recoveredProtectedExposure) {
38
+ if (page && pageRef !== initialPageRef) {
39
+ setCurrentPage(session, pageRef);
40
+ saveSession(session);
41
+ }
40
42
  if (browser) {
41
43
  disconnectPlaywright(browser);
42
44
  browser = null;
@@ -0,0 +1,10 @@
1
+ import { type BrowseSession } from './session.js';
2
+ export type CloseOwnedBrowserResult = {
3
+ success: true;
4
+ method: 'already_closed' | 'cdp' | 'signal';
5
+ } | {
6
+ success: false;
7
+ reason: string;
8
+ };
9
+ export declare function closeOwnedBrowser(session: BrowseSession): Promise<CloseOwnedBrowserResult>;
10
+ //# sourceMappingURL=owned-browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"owned-browser.d.ts","sourceRoot":"","sources":["../src/owned-browser.ts"],"names":[],"mappings":"AAEA,OAAO,EAAkB,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAKlE,MAAM,MAAM,uBAAuB,GAC/B;IACE,OAAO,EAAE,IAAI,CAAC;IACd,MAAM,EAAE,gBAAgB,GAAG,KAAK,GAAG,QAAQ,CAAC;CAC7C,GACD;IACE,OAAO,EAAE,KAAK,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEN,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,uBAAuB,CAAC,CA2BlC"}
@@ -0,0 +1,58 @@
1
+ import { connectPlaywright } from './playwright-runtime.js';
2
+ import { terminateOwnedPid } from './owned-process.js';
3
+ import { getSessionPort } from './session.js';
4
+ const ENDPOINT_WAIT_ATTEMPTS = 10;
5
+ const ENDPOINT_WAIT_MS = 100;
6
+ export async function closeOwnedBrowser(session) {
7
+ const port = getSessionPort(session);
8
+ const endpointAliveBeforeClose = await isBrowserEndpointAlive(port);
9
+ if (endpointAliveBeforeClose) {
10
+ await tryCloseBrowserViaCdp(session.cdpUrl);
11
+ if (await waitForBrowserEndpointToClose(port)) {
12
+ return { success: true, method: 'cdp' };
13
+ }
14
+ }
15
+ const termination = await terminateOwnedPid(session.pid);
16
+ if (await waitForBrowserEndpointToClose(port)) {
17
+ return {
18
+ success: true,
19
+ method: endpointAliveBeforeClose ? 'signal' : 'already_closed',
20
+ };
21
+ }
22
+ if (!endpointAliveBeforeClose && termination === 'not_found') {
23
+ return { success: true, method: 'already_closed' };
24
+ }
25
+ return {
26
+ success: false,
27
+ reason: `Owned browser endpoint on port ${port} remained reachable after close attempts (termination=${termination}).`,
28
+ };
29
+ }
30
+ async function tryCloseBrowserViaCdp(cdpUrl) {
31
+ try {
32
+ const browser = await connectPlaywright(cdpUrl);
33
+ await browser.close();
34
+ }
35
+ catch {
36
+ }
37
+ }
38
+ async function isBrowserEndpointAlive(port) {
39
+ try {
40
+ const response = await fetch(`http://127.0.0.1:${port}/json/version`);
41
+ return response.ok;
42
+ }
43
+ catch {
44
+ return false;
45
+ }
46
+ }
47
+ async function waitForBrowserEndpointToClose(port) {
48
+ for (let attempt = 0; attempt < ENDPOINT_WAIT_ATTEMPTS; attempt++) {
49
+ if (!(await isBrowserEndpointAlive(port))) {
50
+ return true;
51
+ }
52
+ await sleep(ENDPOINT_WAIT_MS);
53
+ }
54
+ return !(await isBrowserEndpointAlive(port));
55
+ }
56
+ function sleep(ms) {
57
+ return new Promise((resolve) => setTimeout(resolve, ms));
58
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"owned-process.d.ts","sourceRoot":"","sources":["../src/owned-process.ts"],"names":[],"mappings":"AAaA,MAAM,MAAM,yBAAyB,GAAG,WAAW,GAAG,YAAY,GAAG,WAAW,GAAG,aAAa,CAAC;AACjG,MAAM,MAAM,2BAA2B,GAAG;IACxC,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAEF,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAW/C;AAED,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAsBvF;AAED,wBAAsB,yBAAyB,CAC7C,OAAO,GAAE;IAAE,WAAW,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;CAAO,GAC/C,OAAO,CAAC,2BAA2B,CAAC,CAqBtC;AAED,wBAAgB,sBAAsB,CACpC,OAAO,GAAE;IACP,YAAY,CAAC,EAAE,MAAM,CAAC;CAClB,GACL,MAAM,EAAE,CAuBV"}
1
+ {"version":3,"file":"owned-process.d.ts","sourceRoot":"","sources":["../src/owned-process.ts"],"names":[],"mappings":"AAaA,MAAM,MAAM,yBAAyB,GAAG,WAAW,GAAG,YAAY,GAAG,WAAW,GAAG,aAAa,CAAC;AACjG,MAAM,MAAM,2BAA2B,GAAG;IACxC,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAEF,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAW/C;AAED,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAOvF;AAiCD,wBAAsB,yBAAyB,CAC7C,OAAO,GAAE;IAAE,WAAW,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;CAAO,GAC/C,OAAO,CAAC,2BAA2B,CAAC,CAqBtC;AAED,wBAAgB,sBAAsB,CACpC,OAAO,GAAE;IACP,YAAY,CAAC,EAAE,MAAM,CAAC;CAClB,GACL,MAAM,EAAE,CAuBV"}
@@ -23,17 +23,28 @@ export function isPidAlive(pid) {
23
23
  }
24
24
  }
25
25
  export async function terminateOwnedPid(pid) {
26
+ const processGroupTermination = await terminateSignalTarget(-pid, pid);
27
+ if (processGroupTermination !== 'not_found') {
28
+ return processGroupTermination;
29
+ }
30
+ return terminateSignalTarget(pid, pid);
31
+ }
32
+ async function terminateSignalTarget(target, pid) {
26
33
  try {
27
- process.kill(pid, 'SIGTERM');
34
+ process.kill(target, 'SIGTERM');
28
35
  }
29
36
  catch (error) {
37
+ const code = getErrorCode(error);
38
+ if (target < 0 && code === 'ESRCH' && isPidAlive(pid)) {
39
+ return 'not_found';
40
+ }
30
41
  return isPidAlive(pid) ? 'still_alive' : 'not_found';
31
42
  }
32
43
  if (await waitForPidExit(pid, TERM_WAIT_ATTEMPTS, TERM_WAIT_MS)) {
33
44
  return 'terminated';
34
45
  }
35
46
  try {
36
- process.kill(pid, 'SIGKILL');
47
+ process.kill(target, 'SIGKILL');
37
48
  }
38
49
  catch {
39
50
  return isPidAlive(pid) ? 'still_alive' : 'sigkilled';
@@ -4,6 +4,7 @@ export type SolverSession = {
4
4
  browser: Browser;
5
5
  page: Page;
6
6
  cdpUrl: string;
7
+ pid: number;
7
8
  profile: ProfileInfo;
8
9
  close: () => Promise<void>;
9
10
  disconnect: () => Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"browser-launcher.d.ts","sourceRoot":"","sources":["../../src/solver/browser-launcher.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAsB,aAAa,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAajF,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,IAAI,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,WAAW,CAAC;IACrB,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACjC,CAAC;AAiBF,wBAAsB,YAAY,CAChC,OAAO,EAAE,WAAW,EACpB,IAAI,CAAC,EAAE,aAAa,GACnB,OAAO,CAAC,aAAa,CAAC,CAiExB"}
1
+ {"version":3,"file":"browser-launcher.d.ts","sourceRoot":"","sources":["../../src/solver/browser-launcher.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAsB,aAAa,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAajF,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,IAAI,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,WAAW,CAAC;IACrB,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACjC,CAAC;AAiBF,wBAAsB,YAAY,CAChC,OAAO,EAAE,WAAW,EACpB,IAAI,CAAC,EAAE,aAAa,GACnB,OAAO,CAAC,aAAa,CAAC,CAkExB"}
@@ -59,6 +59,7 @@ export async function launchSolver(profile, opts) {
59
59
  browser,
60
60
  page,
61
61
  cdpUrl,
62
+ pid: chromeProcess.pid,
62
63
  profile,
63
64
  close: async () => {
64
65
  try {
@@ -10,6 +10,4 @@ export interface StagehandSession {
10
10
  }
11
11
  /** Connect to an existing browser via CDP URL. */
12
12
  export declare function connectStagehand(cdpUrl: string): Promise<Stagehand>;
13
- /** Find the PID of the Chrome process listening on CDP_PORT. */
14
- export declare function findChromePid(port?: number): number | null;
15
13
  //# sourceMappingURL=stagehand.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"stagehand.d.ts","sourceRoot":"","sources":["../src/stagehand.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAMrD,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,SAAS,CAAC;CACtB;AAED,kDAAkD;AAClD,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAezE;AAED,gEAAgE;AAChE,wBAAgB,aAAa,CAAC,IAAI,SAAmB,GAAG,MAAM,GAAG,IAAI,CAQpE"}
1
+ {"version":3,"file":"stagehand.d.ts","sourceRoot":"","sources":["../src/stagehand.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAIrD,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,SAAS,CAAC;CACtB;AAED,kDAAkD;AAClD,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAezE"}
package/dist/stagehand.js CHANGED
@@ -4,11 +4,9 @@
4
4
  * For `launch`: Stagehand launches Chrome itself (port 9222).
5
5
  * For all other commands: Stagehand connects to existing Chrome via cdpUrl.
6
6
  */
7
- import { execSync } from 'node:child_process';
8
7
  import { Stagehand } from '@browserbasehq/stagehand';
9
8
  import { createAgentpayStagehandLlmClient } from './agentpay-stagehand-llm.js';
10
9
  import { resolveAgentpayGatewayConfig } from './agentpay-gateway.js';
11
- const DEFAULT_CDP_PORT = 9222;
12
10
  /** Connect to an existing browser via CDP URL. */
13
11
  export async function connectStagehand(cdpUrl) {
14
12
  const gateway = resolveAgentpayGatewayConfig();
@@ -25,14 +23,3 @@ export async function connectStagehand(cdpUrl) {
25
23
  await stagehand.init();
26
24
  return stagehand;
27
25
  }
28
- /** Find the PID of the Chrome process listening on CDP_PORT. */
29
- export function findChromePid(port = DEFAULT_CDP_PORT) {
30
- try {
31
- const out = execSync(`lsof -ti :${port}`, { encoding: 'utf-8' }).trim();
32
- const first = out.split('\n')[0];
33
- return first ? Number(first) : null;
34
- }
35
- catch {
36
- return null;
37
- }
38
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuanu-ai/agentbrowse",
3
- "version": "0.2.25",
3
+ "version": "0.2.27",
4
4
  "type": "module",
5
5
  "description": "Browser automation CLI for AI agents: control a CDP browser, observe UI surfaces, act on refs, extract data, capture screenshots, complete protected fills, and solve captchas",
6
6
  "keywords": [