@edlsh/browse-core 0.6.1 → 0.6.3

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.
@@ -233,8 +233,8 @@ export class RealBrowserSession {
233
233
  if (signal.aborted || !(error instanceof BrowseToolError))
234
234
  throw error;
235
235
  progress.failedIndex = results.length;
236
- // A script that failed did not act; a server that went away may have.
237
- progress.outcomeUnknown = error.code === "real_browser_unreachable";
236
+ // A script can act before throwing or losing its reply. Only local preflight failures are safe to retry.
237
+ progress.outcomeUnknown = error.code === "real_browser_error" || error.code === "real_browser_unreachable";
238
238
  progress.error = { code: error.code, message: error.message.slice(0, 4000) };
239
239
  break;
240
240
  }
package/dist/schema.js CHANGED
@@ -54,11 +54,11 @@ const browserFields = {
54
54
  return false;
55
55
  const url = new URL(value);
56
56
  return !url.username && !url.password && !url.hash;
57
- }, "cdpUrl must be an http(s) or ws(s) endpoint without credentials or a fragment; send credentials in headers").optional().describe("Only for start with backend local. Attach to this explicitly supplied DevTools endpoint, on this machine or another; close disconnects without terminating the browser. Omit to launch an isolated browser."),
57
+ }, "cdpUrl must be an http(s) or ws(s) endpoint without credentials or a fragment; send credentials in headers").optional().describe("Only for start with backend local. Attach to this explicitly supplied DevTools endpoint, on this machine or another; close disconnects without terminating the browser. Omit for the profile's local browser."),
58
58
  headers: z.record(z.string().regex(/^[A-Za-z0-9-]{1,64}$/), z.string().min(1).max(4096)).optional().describe("Only with cdpUrl: HTTP headers an authenticated DevTools gateway needs, e.g. {\"Authorization\":\"Bearer <token>\"}. Sent only to cdpUrl's host; values never appear in results."),
59
59
  extensionCdpUrl: z.url({ protocol: /^wss?$/ }).optional().describe("Only with cdpUrl for a browser on another machine or behind a gateway: the browser-level DevTools WebSocket URL the browser itself reaches without headers, e.g. ws://127.0.0.1:9222/devtools/browser/<id>. Default: the URL the browser reports."),
60
60
  endpoint: z.string().regex(/^[A-Za-z0-9_-]{1,64}$/).optional().describe("Only for start with backend local: attach to the remote browser this profile configures under that name, which supplies its cdpUrl, headers, and extensionCdpUrl."),
61
- headless: z.boolean().optional().describe("Only for a local launch with start. Default false (visible window); cannot be used with cdpUrl."),
61
+ headless: z.boolean().optional().describe("Only for start with backend local: launch a browser of this tool's own, false for a visible window or true for none; cannot be used with cdpUrl or endpoint. Where the profile's local browser is the user's own, omit it to open tabs there: any value launches the separate browser instead, and its tabs never appear in the user's browser."),
62
62
  tabId: z.string().min(1).optional().describe("Target tab ID; defaults to the selected tab. Required for tab_select/tab_close."),
63
63
  // Other schemes are unsafe or unsupported: javascript: hangs navigation and file: reads the remote machine.
64
64
  url: z.url({ protocol: /^https?$/, error: "url must be an http or https URL" }).optional().describe("An http or https URL. Required for open; optional for start/tab_new."),
package/dist/session.js CHANGED
@@ -13,7 +13,7 @@ import { BrokerConnection } from "./broker-client.js";
13
13
  import { RealBrowserSession } from "./real-browser-session.js";
14
14
  import { extractPage, observePage } from "./real-browser-ai.js";
15
15
  import { extensionCacheKey, extensionCachePath, provisionExtension } from "./extension-cache.js";
16
- import { randomUUID } from "node:crypto";
16
+ import { createHash, randomUUID } from "node:crypto";
17
17
  import { cancelPageBatch, pageOperation, readOperation, tabsOperation, viewOperation } from "./page-operations.js";
18
18
  import { CookieSourceError, localCookieProvider, normalizeCookieDomains } from "./browser-cookies.js";
19
19
  import { fitsAction, JEV_MIN_CONFIDENCE, jevChooser, outlineCandidates, pickTarget, treeCandidates } from "./jev.js";
@@ -650,7 +650,8 @@ export class BrowseSession {
650
650
  if (policy?.blockedDomains?.length) {
651
651
  throw new BrowseToolError("unsupported_backend", "Blocked domains cannot be enforced in the user's real browser. Start with headless true or backend \"browserbase\" to keep them.");
652
652
  }
653
- return RealBrowserSession.open(config.realBrowser.command, { name: this.identity.integration, version: "1" }, this.owner(context), `${this.identity.name} ${context.sessionId.slice(0, 6)}`, policy?.allowedDomains?.flatMap(domain => [domain, `*.${domain}`]));
653
+ const groupId = createHash("sha256").update(JSON.stringify([this.identity.integration, context.profile, context.sessionId])).digest("hex").slice(0, 24);
654
+ return RealBrowserSession.open(config.realBrowser.command, { name: this.identity.integration, version: "1" }, this.owner(context), `${this.identity.name} ${groupId}`, policy?.allowedDomains?.flatMap(domain => [domain, `*.${domain}`]));
654
655
  }
655
656
  async inRealBrowser(real, params, context, ai) {
656
657
  // SAFETY: `ai` marks a browse_ai call, whose arguments are AIParams; every other call's are BrowserParams.
@@ -663,6 +664,10 @@ export class BrowseSession {
663
664
  // Listing the cookie sources needs no browser.
664
665
  if (p.action === "cookie_profiles")
665
666
  return this.browse(p, context);
667
+ // The person's logins are already here; an import is for a browser this tool launches.
668
+ if (p.action === "cookie_import") {
669
+ throw new BrowseToolError("unsupported_backend", "cookie_import is not needed in the user's real browser: their logins are already there. Open the page, and call handoff if it asks to sign in. To import into a browser of this tool's own instead, close this one, then start with headless set or backend \"browserbase\".");
670
+ }
666
671
  if (p.action === "ask" || p.target !== undefined)
667
672
  return this.classifyInRealBrowser(real, p, context);
668
673
  if (p.action === "har_stop") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edlsh/browse-core",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
4
4
  "description": "Host-neutral browser core (Browserbase, local Chrome, remote CDP, Stagehand) shared by omp-browse, pi-browse, and hermes-browse",
5
5
  "keywords": [
6
6
  "browser",