@solarisdk/browserbase-compat 0.0.0-stage → 0.2.0

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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,12 @@
1
+ # Changelog
2
+
3
+ ## 0.2.0
4
+ - `timeout`, `keepAlive` and `userMetadata` are sent to Solari (they were warned about and ignored in 0.1.0). `userMetadata` comes back on `create`, `retrieve` and `list`, and `sessions.list({ q })` filters on it.
5
+ - **A base URL that does not point at Solari is now refused.** `baseURL` and `SOLARI_BASE_URL` must be `https` on `getsolari.com` (or a subdomain) or a loopback address; anything else throws `BrowserbaseError` ("Refusing to send a Solari API key to …"). In 0.1.0 such a URL was used as given, which could send your `slr_` key to another host.
6
+ - Errors use Browserbase's class names: `NotFoundError`, `RateLimitError`, `BadRequestError`, `AuthenticationError`, `PermissionDeniedError`, `ConflictError`, `UnprocessableEntityError`, `InternalServerError` (all `APIError` subclasses), `APIConnectionError` and `APIConnectionTimeoutError`. Network failures used to surface as the raw `fetch` error.
7
+ - A saved context's cookies are also present in the browser's default context (`browser.contexts()[0]`).
8
+ - `viewport` at create remains a documented gap (warns; `strict` throws).
9
+ - Added `NOTICE`; README links to docs.getsolari.com.
10
+
11
+ ## 0.1.0
12
+ - First release.
package/COMPAT.md ADDED
@@ -0,0 +1,65 @@
1
+ # Browserbase compatibility — what works, what differs, what raises
2
+
3
+ `@solarisdk/browserbase-compat` gives Solari Browser the shape of the Browserbase SDK, so code written against
4
+ `new Browserbase({ apiKey })` runs against Solari with the import and the key changed. This page is the full list.
5
+
6
+ ```ts
7
+ import Browserbase from "@solarisdk/browserbase-compat";
8
+ import { chromium } from "playwright-core";
9
+
10
+ const bb = new Browserbase({ apiKey: process.env.SOLARI_API_KEY }); // slr_… key
11
+ const session = await bb.sessions.create({ browserSettings: { recordSession: true } });
12
+ const browser = await chromium.connectOverCDP(session.connectUrl); // Puppeteer: puppeteer.connect({ browserWSEndpoint: session.connectUrl })
13
+ // … drive the page …
14
+ await browser.close();
15
+ await bb.sessions.update(session.id, { status: "REQUEST_RELEASE" });
16
+ ```
17
+
18
+ `connectUrl` is a raw CDP websocket URL, so any CDP client works and **nothing needs a pinned Playwright version**.
19
+ Keep it private: the session id inside it is the credential.
20
+
21
+ ## Keys and endpoint
22
+ | | |
23
+ |---|---|
24
+ | Key | `apiKey` option, else `SOLARI_API_KEY`, else `BROWSERBASE_API_KEY`. **A key that does not start with `slr_` is never used or sent** (it is probably a Browserbase secret): it is skipped with a warning that does not print it, and if no `slr_` key remains the constructor throws. |
25
+ | Endpoint | `baseURL` option or `SOLARI_BASE_URL`; default `https://api.getsolari.com`. Must be `https` on `getsolari.com` (or a subdomain) or loopback, otherwise the constructor throws `BrowserbaseError` ("Refusing to send a Solari API key to …"): the key is never sent to another host. |
26
+ | `projectId` | Accepted and ignored: Solari keys belong to an organisation, there are no projects. |
27
+
28
+ ## Works
29
+ | Browserbase | Here |
30
+ |---|---|
31
+ | `sessions.create` | `POST /sessions`; returns `connectUrl` (CDP), `id`, `status: "RUNNING"`, `expiresAt`, `region`, `keepAlive`, `contextId`. A create is retried safely (idempotency key). |
32
+ | `sessions.retrieve`, `sessions.list({ status })` | Solari `active/released/expired/unknown` map to `RUNNING/COMPLETED/TIMED_OUT/ERROR`. `proxyBytes` is `0`, `startedAt` is the create time. |
33
+ | `sessions.update(id, { status: "REQUEST_RELEASE" })` | Releases the session. |
34
+ | `proxies: true`, `proxies: [{ type: "browserbase", geolocation }]` | A managed proxy; `geolocation.country/state/city` map across (a proxy needs the stealth browser, so `stealth` is switched on for you). `{ type: "none" }` means no proxy. |
35
+ | `browserSettings.verified`, `advancedStealth` | Solari's stealth browser. |
36
+ | `browserSettings.solveCaptchas: true` | Solari captcha solving (stealth browser, plan-gated). **Off unless you pass `true`**: Browserbase turns it on by default. |
37
+ | `browserSettings.recordSession: true` | Session recording. **Off unless you pass `true`**: Browserbase records by default. Read it back with `sessions.recording.retrieve(id)` (rrweb events). |
38
+ | `browserSettings.allowedDomains` | Egress allowlist (enterprise plan, stealth browser); a plan error comes back as an `APIError` with `code: "FeatureRequiresPlan"`. |
39
+ | `browserSettings.context: { id, persist }`, `contexts.create/retrieve/delete` | A Context is a Solari **profile**. See [Contexts](#contexts). |
40
+ | `sessions.debug(id, { expiresIn })` | A view-only live-view link (`debuggerUrl` and `debuggerFullscreenUrl` are the same link; `pages` is empty; `wsUrl` is the CDP URL). |
41
+
42
+ ## Differs (documented, not errors)
43
+ - **Recording is a DOM-event log, not video.** `sessions.recording.retrieve(id)` returns rrweb events once the replay has been uploaded (a few seconds after release; until then it throws `APIError` with `code: "ReplayPending"`). There is no HLS playlist and no MP4.
44
+ - **Contexts store cookies and localStorage only** (Playwright `storageState`), not IndexedDB, service workers or autofill data.
45
+ - **No choice of operating system or viewport at create time (known gap).** A `viewport` setting is accepted with a one-line warning and has no effect; set the viewport from your automation client (`page.setViewportSize`). `strict: true` makes it throw instead.
46
+ - **`timeout`, `keepAlive` and `userMetadata` work as in Browserbase.** `timeout` (seconds, at least 60) ends the session at that time, capped at your plan's maximum session length. `keepAlive: true` keeps the session after your client disconnects, until its `timeout` (default 1 hour), the plan maximum, or `sessions.update(..., REQUEST_RELEASE)`. `userMetadata` (up to 50 keys, 8 KB) is stored, returned by `retrieve`/`list`, and filterable with `sessions.list({ q: "user_metadata['key']:'value'" })` (conditions joined with `AND`).
47
+ - **`viewport`, `blockAds: true`, `logSession: true`, `os`** are accepted with a one-line warning and have no effect. Pass `strict: true` to make them throw instead.
48
+
49
+ ## Contexts
50
+ ```ts
51
+ const ctx = await bb.contexts.create({ name: "shop-login" });
52
+ const s = await bb.sessions.create({ browserSettings: { context: { id: ctx.id, persist: true } } });
53
+ const browser = await chromium.connectOverCDP(s.connectUrl);
54
+ // First run: log in, then release; the context is saved when you release through this client.
55
+ await bb.sessions.update(s.id, { status: "REQUEST_RELEASE" });
56
+
57
+ // Later: the saved login comes back as `storageState`. Create your browser context with it:
58
+ const s2 = await bb.sessions.create({ browserSettings: { context: { id: ctx.id } } });
59
+ const b2 = await chromium.connectOverCDP(s2.connectUrl);
60
+ const page = await (await b2.newContext({ storageState: s2.storageState })).newPage();
61
+ ```
62
+ Two differences from Browserbase: a saved context's **cookies** are also present in the default browser context (`browser.contexts()[0]`), but localStorage is applied only to a browser context created *with* the state (use `newContext({ storageState })` to get both), and `persist: true` saves when you release **through the same client object** (it is remembered in memory).
63
+
64
+ ## Raises `SolariCompatUnsupported`
65
+ Extensions (`extensionId`), the Selenium endpoint (`seleniumRemoteUrl` is always empty), downloads (`sessions.downloads`) and uploads (`sessions.uploads`) APIs, video replays (`sessions.replays`), session logs (`sessions.logs`), external/bring-your-own proxies, per-domain proxy rules (`domainPattern`), custom CA certificates, `ignoreCertificateErrors: true`, custom captcha selectors, `os: "mobile" | "tablet"`, a `region` other than `us-west-2` (or `us-west`), `contexts.update`, and the separate `projects`, `extensions`, `agents`, `fetchAPI` and `search` resources.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Solari
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/NOTICE ADDED
@@ -0,0 +1,10 @@
1
+ Solari Browserbase compatibility SDK
2
+ Copyright (c) 2026 Solari. Licensed under the MIT License (see LICENSE).
3
+
4
+ This package implements a client whose method names and parameters follow the
5
+ publicly documented Browserbase SDK, so that code written for that SDK can run
6
+ against Solari Browser. It contains no Browserbase source code.
7
+
8
+ It is not affiliated with, endorsed by, or sponsored by Browserbase, Inc.
9
+ "Browserbase" is a trademark of its owner and is used only to describe API
10
+ compatibility.
package/README.md CHANGED
@@ -1,3 +1,28 @@
1
- # Temporary Holding Version
1
+ # @solarisdk/browserbase-compat
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A Browserbase-shaped SDK for [Solari Browser](https://getsolari.com): change the import and the key, keep your code.
4
+
5
+ ```bash
6
+ npm install @solarisdk/browserbase-compat
7
+ ```
8
+
9
+ ```ts
10
+ import Browserbase from "@solarisdk/browserbase-compat";
11
+ import { chromium } from "playwright-core";
12
+
13
+ const bb = new Browserbase({ apiKey: process.env.SOLARI_API_KEY }); // slr_… key
14
+ const session = await bb.sessions.create();
15
+ const browser = await chromium.connectOverCDP(session.connectUrl);
16
+ const page = browser.contexts()[0].pages()[0] ?? (await browser.contexts()[0].newPage());
17
+ await page.goto("https://example.com");
18
+ await browser.close();
19
+ await bb.sessions.update(session.id, { status: "REQUEST_RELEASE" });
20
+ ```
21
+
22
+ Sessions, contexts, live view and recording are supported; extensions, downloads/uploads APIs, video replays,
23
+ bring-your-own proxies and Selenium raise `SolariCompatUnsupported`. See [docs.getsolari.com/browserbase](https://docs.getsolari.com/browserbase) (and `COMPAT.md` in this package) for the full list
24
+ and every difference. Requires Node 20+. No Playwright version pin is needed: `connectUrl` is a plain CDP endpoint.
25
+
26
+ Licence: MIT. See `NOTICE`.
27
+
28
+ This is an independent project. It is not affiliated with, endorsed by, or sponsored by Browserbase, Inc. "Browserbase" is a trademark of its owner and is used here only to describe API compatibility.
@@ -0,0 +1,95 @@
1
+ import type { Context, ContextCreateResponse, Session, SessionCreateParams, SessionCreateResponse, SessionLiveURLs, SessionRetrieveResponse, SessionStatus } from "./types.js";
2
+ export declare const DEFAULT_BASE_URL = "https://api.getsolari.com";
3
+ export interface BrowserbaseOptions {
4
+ /** Solari API key (`slr_...`). Falls back to SOLARI_API_KEY, then BROWSERBASE_API_KEY. A key that does not start with `slr_` is never used or sent. */
5
+ apiKey?: string;
6
+ /** Gateway base URL. Default https://api.getsolari.com (env SOLARI_BASE_URL). */
7
+ baseURL?: string;
8
+ /** Throw SolariCompatUnsupported instead of warning when an ignorable setting (timeout, keepAlive, ...) is passed. */
9
+ strict?: boolean;
10
+ /** Called for each soft difference; default console.warn. */
11
+ onWarning?: (message: string) => void;
12
+ maxRetries?: number;
13
+ /** Per-request timeout in ms. */
14
+ timeout?: number;
15
+ /** Test hook. */
16
+ fetch?: typeof fetch;
17
+ }
18
+ /** Whether a base URL may receive a Solari key: https on getsolari.com or a subdomain, or loopback. */
19
+ export declare function isSolariBaseUrl(raw: string): boolean;
20
+ export declare class Browserbase {
21
+ readonly sessions: Sessions;
22
+ readonly contexts: Contexts;
23
+ readonly extensions: UnsupportedResource;
24
+ readonly projects: UnsupportedResource;
25
+ readonly agents: UnsupportedResource;
26
+ readonly fetchAPI: UnsupportedResource;
27
+ readonly search: UnsupportedResource;
28
+ readonly apiKey: string;
29
+ readonly baseURL: string;
30
+ /** @internal */ readonly strict: boolean;
31
+ /** @internal */ readonly warn: (m: string) => void;
32
+ private readonly fetchImpl;
33
+ private readonly maxRetries;
34
+ private readonly timeoutMs;
35
+ /** session id -> profile to save on release (browserSettings.context.persist). In-process only. */
36
+ /** @internal */ readonly persist: Map<string, string>;
37
+ constructor(opts?: BrowserbaseOptions);
38
+ /** @internal GET a presigned URL (no Solari auth header). */
39
+ fetchPublic(url: string): Promise<Response>;
40
+ /** @internal */
41
+ request(method: string, path: string, body?: unknown, opts?: {
42
+ idempotencyKey?: string;
43
+ }): Promise<Response>;
44
+ /** @internal */
45
+ json<T>(method: string, path: string, body?: unknown, opts?: {
46
+ idempotencyKey?: string;
47
+ }): Promise<T>;
48
+ }
49
+ /** A resource whose every method throws SolariCompatUnsupported. */
50
+ export type UnsupportedResource = {
51
+ [method: string]: (...args: unknown[]) => never;
52
+ };
53
+ declare class Sessions {
54
+ private readonly c;
55
+ readonly recording: Recording;
56
+ readonly replays: UnsupportedResource;
57
+ readonly logs: UnsupportedResource;
58
+ readonly downloads: UnsupportedResource;
59
+ readonly uploads: UnsupportedResource;
60
+ constructor(c: Browserbase);
61
+ create(params?: SessionCreateParams): Promise<SessionCreateResponse>;
62
+ retrieve(id: string): Promise<SessionRetrieveResponse>;
63
+ list(query?: {
64
+ status?: SessionStatus;
65
+ q?: string;
66
+ }): Promise<Session[]>;
67
+ /** `{ status: "REQUEST_RELEASE" }` releases the session (saving the context first when it was created with persist: true). */
68
+ update(id: string, params: {
69
+ status: "REQUEST_RELEASE";
70
+ projectId?: string;
71
+ }): Promise<Session>;
72
+ /** Live-view links. Both URLs are the same view-only share link; `pages` is empty. */
73
+ debug(id: string, query?: {
74
+ expiresIn?: number;
75
+ }): Promise<SessionLiveURLs>;
76
+ }
77
+ declare class Recording {
78
+ private readonly c;
79
+ constructor(c: Browserbase);
80
+ /** The session's DOM recording as an array of rrweb events. Needs `browserSettings: { recordSession: true }`; available a few seconds after release. */
81
+ retrieve(id: string): Promise<unknown[]>;
82
+ }
83
+ declare class Contexts {
84
+ private readonly c;
85
+ constructor(c: Browserbase);
86
+ /** A Context is a Solari profile (cookies + localStorage). */
87
+ create(params?: {
88
+ projectId?: string;
89
+ name?: string;
90
+ }): Promise<ContextCreateResponse>;
91
+ retrieve(id: string): Promise<Context>;
92
+ update(): never;
93
+ delete(id: string): Promise<void>;
94
+ }
95
+ export {};
package/dist/client.js ADDED
@@ -0,0 +1,323 @@
1
+ import { gunzipSync } from "node:zlib";
2
+ import { APIError, BrowserbaseError, SolariCompatUnsupported, apiErrorFor, connectionErrorFor } from "./errors.js";
3
+ import { mapCreateParams, mapStatus } from "./mapping.js";
4
+ export const DEFAULT_BASE_URL = "https://api.getsolari.com";
5
+ const REGION = "us-west-2"; // reported for Browserbase-shaped objects; Solari's single region (us-west)
6
+ function resolveApiKey(explicit, warn) {
7
+ const sources = [
8
+ ["apiKey", explicit],
9
+ ["SOLARI_API_KEY", process.env.SOLARI_API_KEY],
10
+ ["BROWSERBASE_API_KEY", process.env.BROWSERBASE_API_KEY],
11
+ ];
12
+ for (const [name, v] of sources) {
13
+ if (!v)
14
+ continue;
15
+ if (v.startsWith("slr_"))
16
+ return v;
17
+ // Never echo any part of the value: it is probably a Browserbase secret.
18
+ warn(`${name} does not look like a Solari key (expected the slr_ prefix); ignoring it. It was not sent anywhere.`);
19
+ }
20
+ throw new BrowserbaseError("No Solari API key: pass apiKey or set SOLARI_API_KEY (keys start with slr_)");
21
+ }
22
+ /** Whether a base URL may receive a Solari key: https on getsolari.com or a subdomain, or loopback. */
23
+ export function isSolariBaseUrl(raw) {
24
+ let u;
25
+ try {
26
+ u = new URL(raw);
27
+ }
28
+ catch {
29
+ return false;
30
+ }
31
+ if (u.username || u.password)
32
+ return false; // never a URL with credentials in it
33
+ const host = u.hostname.toLowerCase().replace(/\.$/, "");
34
+ if (u.protocol === "https:" && (host === "getsolari.com" || host.endsWith(".getsolari.com")))
35
+ return true;
36
+ const loopback = host === "localhost" || host === "[::1]" || /^127(\.\d{1,3}){3}$/.test(host);
37
+ return loopback && (u.protocol === "http:" || u.protocol === "https:");
38
+ }
39
+ function describeHost(raw) {
40
+ try {
41
+ return new URL(raw).hostname || "unparsable URL";
42
+ }
43
+ catch {
44
+ return "unparsable URL";
45
+ }
46
+ }
47
+ function resolveBaseUrl(explicit) {
48
+ const given = explicit || process.env.SOLARI_BASE_URL;
49
+ if (!given)
50
+ return DEFAULT_BASE_URL;
51
+ if (!isSolariBaseUrl(given)) {
52
+ throw new BrowserbaseError(`Refusing to send a Solari API key to ${describeHost(given)}: it does not point at Solari (getsolari.com or loopback).`);
53
+ }
54
+ return given.replace(/\/+$/, "");
55
+ }
56
+ function sleep(ms) {
57
+ return new Promise((r) => setTimeout(r, ms));
58
+ }
59
+ export class Browserbase {
60
+ sessions;
61
+ contexts;
62
+ extensions;
63
+ projects;
64
+ agents;
65
+ fetchAPI;
66
+ search;
67
+ apiKey;
68
+ baseURL;
69
+ /** @internal */ strict;
70
+ /** @internal */ warn;
71
+ fetchImpl;
72
+ maxRetries;
73
+ timeoutMs;
74
+ /** session id -> profile to save on release (browserSettings.context.persist). In-process only. */
75
+ /** @internal */ persist = new Map();
76
+ constructor(opts = {}) {
77
+ this.warn = opts.onWarning ?? ((m) => console.warn(`[solari-browserbase-compat] ${m}`));
78
+ // Non-enumerable so console.log(client) / JSON.stringify(client) never print the key.
79
+ Object.defineProperty(this, "apiKey", { value: resolveApiKey(opts.apiKey, this.warn), enumerable: false });
80
+ this.baseURL = resolveBaseUrl(opts.baseURL);
81
+ this.strict = opts.strict === true;
82
+ this.fetchImpl = opts.fetch ?? fetch;
83
+ this.maxRetries = opts.maxRetries ?? 2;
84
+ this.timeoutMs = opts.timeout ?? 60_000;
85
+ this.sessions = new Sessions(this);
86
+ this.contexts = new Contexts(this);
87
+ this.extensions = unsupported("extensions", "browser extensions cannot be loaded");
88
+ this.projects = unsupported("projects", "Solari keys are organisation-scoped; there are no projects");
89
+ this.agents = unsupported("agents", "Browserbase Agents is a separate product");
90
+ this.fetchAPI = unsupported("fetchAPI", "Browserbase Fetch is a separate product");
91
+ this.search = unsupported("search", "Browserbase Search is a separate product");
92
+ }
93
+ /** @internal GET a presigned URL (no Solari auth header). */
94
+ async fetchPublic(url) {
95
+ const ac = new AbortController();
96
+ const timer = setTimeout(() => ac.abort(), 15_000);
97
+ try {
98
+ return await this.fetchImpl(url, { signal: ac.signal });
99
+ }
100
+ finally {
101
+ clearTimeout(timer);
102
+ }
103
+ }
104
+ /** @internal */
105
+ async request(method, path, body, opts) {
106
+ const headers = { Authorization: `Bearer ${this.apiKey}`, "Content-Type": "application/json" };
107
+ if (opts?.idempotencyKey)
108
+ headers["Idempotency-Key"] = opts.idempotencyKey;
109
+ const replaySafe = method === "GET" || method === "DELETE" || opts?.idempotencyKey !== undefined;
110
+ let lastErr;
111
+ for (let attempt = 0; attempt <= this.maxRetries; attempt++) {
112
+ const ac = new AbortController();
113
+ const timer = setTimeout(() => ac.abort(), this.timeoutMs);
114
+ try {
115
+ const res = await this.fetchImpl(`${this.baseURL}${path}`, {
116
+ method,
117
+ headers,
118
+ body: body === undefined ? undefined : JSON.stringify(body),
119
+ signal: ac.signal,
120
+ });
121
+ clearTimeout(timer);
122
+ if (res.ok || !replaySafe || ![502, 503, 504].includes(res.status) || attempt === this.maxRetries)
123
+ return res;
124
+ await res.text().catch(() => { });
125
+ }
126
+ catch (e) {
127
+ clearTimeout(timer);
128
+ if (!replaySafe || attempt === this.maxRetries)
129
+ throw connectionErrorFor(e);
130
+ lastErr = e;
131
+ }
132
+ await sleep(300 * (attempt + 1));
133
+ }
134
+ throw connectionErrorFor(lastErr ?? new Error("request failed"));
135
+ }
136
+ /** @internal */
137
+ async json(method, path, body, opts) {
138
+ const res = await this.request(method, path, body, opts);
139
+ if (res.status === 204)
140
+ return undefined;
141
+ const text = await res.text();
142
+ let parsed;
143
+ try {
144
+ parsed = text ? JSON.parse(text) : undefined;
145
+ }
146
+ catch {
147
+ parsed = undefined;
148
+ }
149
+ if (!res.ok) {
150
+ const o = (parsed ?? {});
151
+ throw apiErrorFor(res.status, `Solari ${method} ${path}: ${res.status} ${o.error ?? text.slice(0, 200)}`, o.code, parsed);
152
+ }
153
+ return parsed;
154
+ }
155
+ }
156
+ class UnsupportedImpl {
157
+ feature;
158
+ hint;
159
+ constructor(feature, hint) {
160
+ this.feature = feature;
161
+ this.hint = hint;
162
+ // Every method on this object throws; a Proxy keeps the surface open-ended (create/list/retrieve/...).
163
+ return new Proxy(this, {
164
+ get: (target, prop) => {
165
+ if (typeof prop === "symbol" || prop === "then" || prop in target)
166
+ return Reflect.get(target, prop);
167
+ return () => {
168
+ throw new SolariCompatUnsupported(`${target.feature}.${prop}`, target.hint);
169
+ };
170
+ },
171
+ });
172
+ }
173
+ }
174
+ function unsupported(feature, hint) {
175
+ return new UnsupportedImpl(feature, hint);
176
+ }
177
+ function newKey() {
178
+ return globalThis.crypto?.randomUUID?.() ?? `bbc-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 12)}`;
179
+ }
180
+ function toSession(row, extra = {}) {
181
+ const created = row.createdAt ?? new Date().toISOString();
182
+ const status = extra.status ?? mapStatus(row.status);
183
+ return {
184
+ id: row.id,
185
+ createdAt: created,
186
+ updatedAt: created,
187
+ projectId: "",
188
+ startedAt: created,
189
+ ...(status === "COMPLETED" || status === "TIMED_OUT" ? { endedAt: new Date().toISOString() } : {}),
190
+ expiresAt: row.expiresAt ?? created,
191
+ status,
192
+ proxyBytes: 0,
193
+ keepAlive: extra.keepAlive ?? false,
194
+ ...(row.userMetadata ? { userMetadata: row.userMetadata } : {}),
195
+ ...(extra.contextId ? { contextId: extra.contextId } : {}),
196
+ region: REGION,
197
+ };
198
+ }
199
+ function withConnect(s, cdp) {
200
+ return { ...s, connectUrl: cdp, seleniumRemoteUrl: "", signingKey: "" };
201
+ }
202
+ class Sessions {
203
+ c;
204
+ recording;
205
+ replays;
206
+ logs;
207
+ downloads;
208
+ uploads;
209
+ constructor(c) {
210
+ this.c = c;
211
+ this.recording = new Recording(c);
212
+ this.replays = unsupported("sessions.replays", "Solari records DOM events, not video; use sessions.recording.retrieve");
213
+ this.logs = unsupported("sessions.logs", "session command logs are not available");
214
+ this.downloads = unsupported("sessions.downloads", "file downloads cannot be retrieved through the API");
215
+ this.uploads = unsupported("sessions.uploads", "use your automation client's setInputFiles");
216
+ }
217
+ async create(params) {
218
+ const mapped = mapCreateParams(params, this.c.strict);
219
+ for (const w of mapped.warnings)
220
+ this.c.warn(w);
221
+ const data = await this.c.json("POST", "/sessions", Object.keys(mapped.body).length ? mapped.body : undefined, { idempotencyKey: newKey() });
222
+ if (!data?.sessionId || !data.cdpEndpoint) {
223
+ throw new BrowserbaseError(`Solari returned an unexpected session response: ${JSON.stringify(data)}`);
224
+ }
225
+ if (mapped.persistProfileId)
226
+ this.c.persist.set(data.sessionId, mapped.persistProfileId);
227
+ const ctx = params?.browserSettings?.context?.id;
228
+ const s = toSession({
229
+ id: data.sessionId,
230
+ status: "active",
231
+ createdAt: new Date().toISOString(),
232
+ ...(data.expiresAt ? { expiresAt: data.expiresAt } : {}),
233
+ ...(data.userMetadata ? { userMetadata: data.userMetadata } : {}),
234
+ }, { keepAlive: params?.keepAlive === true, ...(ctx ? { contextId: ctx } : {}), status: "RUNNING" });
235
+ const out = withConnect(s, data.cdpEndpoint);
236
+ if (ctx) {
237
+ let state = data.storageState ?? null;
238
+ if (!state && data.storageStateUrl?.url) {
239
+ const r = await this.c.fetchPublic(data.storageStateUrl.url).catch(() => undefined);
240
+ if (r?.ok)
241
+ state = (await r.json().catch(() => null));
242
+ else
243
+ this.c.warn("could not download the saved context; the session starts without it");
244
+ }
245
+ out.storageState = state;
246
+ }
247
+ return out;
248
+ }
249
+ async retrieve(id) {
250
+ const row = await this.c.json("GET", `/sessions/${encodeURIComponent(id)}`);
251
+ return withConnect(toSession({ ...row, id: row.id ?? id }), row.cdpEndpoint ?? "");
252
+ }
253
+ async list(query) {
254
+ const data = await this.c.json("GET", query?.q ? `/sessions?q=${encodeURIComponent(query.q)}` : "/sessions");
255
+ const all = (data?.sessions ?? []).map((r) => toSession(r));
256
+ return query?.status ? all.filter((s) => s.status === query.status) : all;
257
+ }
258
+ /** `{ status: "REQUEST_RELEASE" }` releases the session (saving the context first when it was created with persist: true). */
259
+ async update(id, params) {
260
+ if (params?.status !== "REQUEST_RELEASE")
261
+ throw new SolariCompatUnsupported(`sessions.update status ${String(params?.status)}`, "only REQUEST_RELEASE exists");
262
+ const profileId = this.c.persist.get(id);
263
+ if (profileId) {
264
+ await this.c.json("POST", `/sessions/${encodeURIComponent(id)}/save-profile`, { profileId });
265
+ this.c.persist.delete(id);
266
+ }
267
+ await this.c.json("DELETE", `/sessions/${encodeURIComponent(id)}`);
268
+ return toSession({ id, status: "released" }, { status: "COMPLETED" });
269
+ }
270
+ /** Live-view links. Both URLs are the same view-only share link; `pages` is empty. */
271
+ async debug(id, query) {
272
+ const share = await this.c.json("POST", `/sessions/${encodeURIComponent(id)}/shares`, query?.expiresIn !== undefined ? { ttlSeconds: query.expiresIn } : {});
273
+ const row = await this.c.json("GET", `/sessions/${encodeURIComponent(id)}`);
274
+ return { debuggerFullscreenUrl: share.url, debuggerUrl: share.url, wsUrl: row.cdpEndpoint ?? "", pages: [] };
275
+ }
276
+ }
277
+ class Recording {
278
+ c;
279
+ constructor(c) {
280
+ this.c = c;
281
+ }
282
+ /** The session's DOM recording as an array of rrweb events. Needs `browserSettings: { recordSession: true }`; available a few seconds after release. */
283
+ async retrieve(id) {
284
+ const meta = await this.c.json("GET", `/sessions/${encodeURIComponent(id)}/replay-url`);
285
+ if (!meta?.url)
286
+ throw new BrowserbaseError("Solari returned no replay URL");
287
+ const r = await fetch(meta.url);
288
+ if (!r.ok)
289
+ throw new APIError(r.status, `replay download failed: ${r.status}`);
290
+ let buf = Buffer.from(await r.arrayBuffer());
291
+ if (buf.length > 2 && buf[0] === 0x1f && buf[1] === 0x8b)
292
+ buf = gunzipSync(buf);
293
+ return buf
294
+ .toString("utf8")
295
+ .split("\n")
296
+ .filter((l) => l.trim() !== "")
297
+ .map((l) => JSON.parse(l));
298
+ }
299
+ }
300
+ class Contexts {
301
+ c;
302
+ constructor(c) {
303
+ this.c = c;
304
+ }
305
+ /** A Context is a Solari profile (cookies + localStorage). */
306
+ async create(params) {
307
+ const p = await this.c.json("POST", "/profiles", { name: params?.name ?? `context-${newKey().slice(0, 8)}` });
308
+ return { id: p.id, publicKey: "", cipherAlgorithm: "", initializationVectorSize: 0 };
309
+ }
310
+ async retrieve(id) {
311
+ const list = await this.c.json("GET", "/profiles");
312
+ const p = (list ?? []).find((x) => x.id === id);
313
+ if (!p)
314
+ throw new APIError(404, `context ${id} not found`, "NotFound");
315
+ return { id: p.id, ...(p.name ? { name: p.name } : {}), ...(p.createdAt ? { createdAt: p.createdAt } : {}) };
316
+ }
317
+ update() {
318
+ throw new SolariCompatUnsupported("contexts.update", "contexts are saved when a persist:true session is released");
319
+ }
320
+ async delete(id) {
321
+ await this.c.json("DELETE", `/profiles/${encodeURIComponent(id)}`);
322
+ }
323
+ }
@@ -0,0 +1,54 @@
1
+ /** Base class for everything this package throws. */
2
+ export declare class BrowserbaseError extends Error {
3
+ constructor(message: string);
4
+ }
5
+ /** The gateway answered with a non-2xx status. `code` is Solari's machine-readable error code when present. */
6
+ export declare class APIError extends BrowserbaseError {
7
+ readonly status: number;
8
+ readonly code: string | undefined;
9
+ readonly body: unknown;
10
+ constructor(status: number, message: string, code?: string, body?: unknown);
11
+ }
12
+ /** 400 */
13
+ export declare class BadRequestError extends APIError {
14
+ }
15
+ /** 401 */
16
+ export declare class AuthenticationError extends APIError {
17
+ }
18
+ /** 403 */
19
+ export declare class PermissionDeniedError extends APIError {
20
+ }
21
+ /** 404 */
22
+ export declare class NotFoundError extends APIError {
23
+ }
24
+ /** 409 */
25
+ export declare class ConflictError extends APIError {
26
+ }
27
+ /** 422 */
28
+ export declare class UnprocessableEntityError extends APIError {
29
+ }
30
+ /** 429 */
31
+ export declare class RateLimitError extends APIError {
32
+ }
33
+ /** 5xx */
34
+ export declare class InternalServerError extends APIError {
35
+ }
36
+ /** The request never produced an HTTP response (DNS, refused, reset, ...). Same name as Browserbase's SDK. */
37
+ export declare class APIConnectionError extends BrowserbaseError {
38
+ readonly cause: unknown;
39
+ constructor(message: string, cause?: unknown);
40
+ }
41
+ /** The request timed out. */
42
+ export declare class APIConnectionTimeoutError extends APIConnectionError {
43
+ constructor(message?: string, cause?: unknown);
44
+ }
45
+ /** The APIError subclass for an HTTP status, as Browserbase's SDK raises them. */
46
+ export declare function apiErrorFor(status: number, message: string, code?: string, body?: unknown): APIError;
47
+ /** A fetch failure as a Browserbase-style connection error (abort/timeout vs. everything else). */
48
+ export declare function connectionErrorFor(e: unknown): BrowserbaseError;
49
+ /** A Browserbase feature Solari Browser does not offer (see COMPAT.md). Never silently ignored when it would change results. */
50
+ export declare class SolariCompatUnsupported extends BrowserbaseError {
51
+ readonly feature: string;
52
+ readonly hint: string | undefined;
53
+ constructor(feature: string, hint?: string);
54
+ }
package/dist/errors.js ADDED
@@ -0,0 +1,89 @@
1
+ /** Base class for everything this package throws. */
2
+ export class BrowserbaseError extends Error {
3
+ constructor(message) {
4
+ super(message);
5
+ this.name = new.target.name;
6
+ }
7
+ }
8
+ /** The gateway answered with a non-2xx status. `code` is Solari's machine-readable error code when present. */
9
+ export class APIError extends BrowserbaseError {
10
+ status;
11
+ code;
12
+ body;
13
+ constructor(status, message, code, body) {
14
+ super(message);
15
+ this.status = status;
16
+ this.code = code;
17
+ this.body = body;
18
+ }
19
+ }
20
+ /** 400 */
21
+ export class BadRequestError extends APIError {
22
+ }
23
+ /** 401 */
24
+ export class AuthenticationError extends APIError {
25
+ }
26
+ /** 403 */
27
+ export class PermissionDeniedError extends APIError {
28
+ }
29
+ /** 404 */
30
+ export class NotFoundError extends APIError {
31
+ }
32
+ /** 409 */
33
+ export class ConflictError extends APIError {
34
+ }
35
+ /** 422 */
36
+ export class UnprocessableEntityError extends APIError {
37
+ }
38
+ /** 429 */
39
+ export class RateLimitError extends APIError {
40
+ }
41
+ /** 5xx */
42
+ export class InternalServerError extends APIError {
43
+ }
44
+ /** The request never produced an HTTP response (DNS, refused, reset, ...). Same name as Browserbase's SDK. */
45
+ export class APIConnectionError extends BrowserbaseError {
46
+ cause;
47
+ constructor(message, cause) {
48
+ super(message);
49
+ this.cause = cause;
50
+ }
51
+ }
52
+ /** The request timed out. */
53
+ export class APIConnectionTimeoutError extends APIConnectionError {
54
+ constructor(message = "Request timed out.", cause) {
55
+ super(message, cause);
56
+ }
57
+ }
58
+ /** The APIError subclass for an HTTP status, as Browserbase's SDK raises them. */
59
+ export function apiErrorFor(status, message, code, body) {
60
+ const C = status === 400 ? BadRequestError
61
+ : status === 401 ? AuthenticationError
62
+ : status === 403 ? PermissionDeniedError
63
+ : status === 404 ? NotFoundError
64
+ : status === 409 ? ConflictError
65
+ : status === 422 ? UnprocessableEntityError
66
+ : status === 429 ? RateLimitError
67
+ : status >= 500 ? InternalServerError
68
+ : APIError;
69
+ return new C(status, message, code, body);
70
+ }
71
+ /** A fetch failure as a Browserbase-style connection error (abort/timeout vs. everything else). */
72
+ export function connectionErrorFor(e) {
73
+ if (e instanceof BrowserbaseError)
74
+ return e;
75
+ const name = e?.name;
76
+ if (name === "AbortError" || name === "TimeoutError")
77
+ return new APIConnectionTimeoutError("Request timed out.", e);
78
+ return new APIConnectionError(`Connection error: ${e?.message ?? "request failed"}`, e);
79
+ }
80
+ /** A Browserbase feature Solari Browser does not offer (see COMPAT.md). Never silently ignored when it would change results. */
81
+ export class SolariCompatUnsupported extends BrowserbaseError {
82
+ feature;
83
+ hint;
84
+ constructor(feature, hint) {
85
+ super(`Not supported by Solari Browser: ${feature}${hint ? ` — ${hint}` : ""}`);
86
+ this.feature = feature;
87
+ this.hint = hint;
88
+ }
89
+ }
@@ -0,0 +1,7 @@
1
+ import { Browserbase } from "./client.js";
2
+ export { Browserbase, DEFAULT_BASE_URL } from "./client.js";
3
+ export type { BrowserbaseOptions, UnsupportedResource } from "./client.js";
4
+ export { APIConnectionError, APIConnectionTimeoutError, APIError, AuthenticationError, BadRequestError, BrowserbaseError, ConflictError, InternalServerError, NotFoundError, PermissionDeniedError, RateLimitError, SolariCompatUnsupported, UnprocessableEntityError, } from "./errors.js";
5
+ export { mapCreateParams, mapStatus } from "./mapping.js";
6
+ export type * from "./types.js";
7
+ export default Browserbase;
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ import { Browserbase } from "./client.js";
2
+ export { Browserbase, DEFAULT_BASE_URL } from "./client.js";
3
+ export { APIConnectionError, APIConnectionTimeoutError, APIError, AuthenticationError, BadRequestError, BrowserbaseError, ConflictError, InternalServerError, NotFoundError, PermissionDeniedError, RateLimitError, SolariCompatUnsupported, UnprocessableEntityError, } from "./errors.js";
4
+ export { mapCreateParams, mapStatus } from "./mapping.js";
5
+ export default Browserbase;
@@ -0,0 +1,17 @@
1
+ import type { SessionCreateParams, SessionStatus } from "./types.js";
2
+ export interface MappedCreate {
3
+ /** Body for POST /sessions on the Solari gateway. */
4
+ body: Record<string, unknown>;
5
+ /** Context to save back to when the session is released (browserSettings.context.persist). */
6
+ persistProfileId?: string;
7
+ /** Soft differences the caller should know about (also emitted via the warn callback). */
8
+ warnings: string[];
9
+ }
10
+ /**
11
+ * Translate Browserbase `sessions.create` params into a Solari `POST /sessions` body.
12
+ * Hard gaps throw SolariCompatUnsupported. Soft gaps (a setting we cannot honour but whose absence does not change
13
+ * what the page sees) are returned as warnings, or thrown when `strict` is set.
14
+ */
15
+ export declare function mapCreateParams(params: SessionCreateParams | undefined, strict: boolean): MappedCreate;
16
+ /** Solari session state -> Browserbase status. */
17
+ export declare function mapStatus(s: string | undefined): SessionStatus;
@@ -0,0 +1,115 @@
1
+ import { SolariCompatUnsupported } from "./errors.js";
2
+ const SOLARI_REGION_ALIASES = new Set(["us-west-2"]);
3
+ function proxyBody(proxies, caCerts) {
4
+ if (caCerts && caCerts.length > 0) {
5
+ throw new SolariCompatUnsupported("proxySettings.caCertificates", "custom CA certificates are not supported");
6
+ }
7
+ if (proxies === undefined || proxies === false)
8
+ return undefined;
9
+ if (proxies === true)
10
+ return { country: "us" };
11
+ if (!Array.isArray(proxies) || proxies.length === 0)
12
+ return undefined;
13
+ if (proxies.length > 1) {
14
+ throw new SolariCompatUnsupported("multiple proxies / domain routing rules", "pass at most one managed proxy; per-domain routing is not supported");
15
+ }
16
+ const p = proxies[0];
17
+ if (p.domainPattern !== undefined && p.domainPattern !== "") {
18
+ throw new SolariCompatUnsupported("proxies[].domainPattern", "per-domain proxy routing is not supported");
19
+ }
20
+ if (p.type === "external") {
21
+ throw new SolariCompatUnsupported("external proxy", "bring-your-own proxy servers are not supported; use a managed proxy");
22
+ }
23
+ if (p.type === "none")
24
+ return undefined; // no proxy, same as not asking for one
25
+ if (p.type !== "browserbase") {
26
+ throw new SolariCompatUnsupported(`proxy type ${JSON.stringify(p.type)}`);
27
+ }
28
+ const g = p.geolocation;
29
+ if (!g)
30
+ return { country: "us" };
31
+ const out = { country: g.country.toLowerCase() };
32
+ if (g.state)
33
+ out.state = g.state.toLowerCase();
34
+ if (g.city)
35
+ out.city = g.city;
36
+ return out;
37
+ }
38
+ /**
39
+ * Translate Browserbase `sessions.create` params into a Solari `POST /sessions` body.
40
+ * Hard gaps throw SolariCompatUnsupported. Soft gaps (a setting we cannot honour but whose absence does not change
41
+ * what the page sees) are returned as warnings, or thrown when `strict` is set.
42
+ */
43
+ export function mapCreateParams(params, strict) {
44
+ const p = params ?? {};
45
+ const bs = p.browserSettings ?? {};
46
+ const warnings = [];
47
+ const soft = (feature, why) => {
48
+ if (strict)
49
+ throw new SolariCompatUnsupported(feature, why);
50
+ warnings.push(`${feature}: ${why}`);
51
+ };
52
+ // ── hard gaps ────────────────────────────────────────────────────────────────
53
+ if (p.extensionId || bs.extensionId)
54
+ throw new SolariCompatUnsupported("extensions", "browser extensions cannot be loaded");
55
+ if (bs.ignoreCertificateErrors === true)
56
+ throw new SolariCompatUnsupported("browserSettings.ignoreCertificateErrors");
57
+ if (bs.captchaImageSelector || bs.captchaInputSelector)
58
+ throw new SolariCompatUnsupported("custom CAPTCHA selectors");
59
+ if (bs.os === "mobile" || bs.os === "tablet")
60
+ throw new SolariCompatUnsupported(`browserSettings.os=${bs.os}`, "only desktop browsers");
61
+ if (p.region !== undefined && !SOLARI_REGION_ALIASES.has(p.region) && p.region !== "us-west") {
62
+ throw new SolariCompatUnsupported(`region ${p.region}`, "Solari Browser runs in one region (us-west)");
63
+ }
64
+ // ── soft gaps ────────────────────────────────────────────────────────────────
65
+ if (bs.viewport !== undefined)
66
+ soft("browserSettings.viewport", "known gap: the viewport cannot be set at create; call page.setViewportSize() from your automation client");
67
+ if (bs.blockAds === true)
68
+ soft("browserSettings.blockAds", "ad blocking is not available");
69
+ if (bs.logSession === true)
70
+ soft("browserSettings.logSession", "session command logs are not available");
71
+ if (bs.os === "windows" || bs.os === "mac" || bs.os === "linux")
72
+ soft("browserSettings.os", "the operating system profile cannot be chosen");
73
+ // ── mapping ──────────────────────────────────────────────────────────────────
74
+ const proxy = proxyBody(p.proxies, p.proxySettings?.caCertificates);
75
+ const allowedDomains = bs.allowedDomains && bs.allowedDomains.length > 0 ? bs.allowedDomains : undefined;
76
+ const captcha = bs.solveCaptchas === true;
77
+ const stealth = bs.verified === true || bs.advancedStealth === true || captcha || proxy !== undefined || allowedDomains !== undefined;
78
+ const body = {};
79
+ if (stealth)
80
+ body.stealth = true;
81
+ if (captcha)
82
+ body.captcha = true;
83
+ if (bs.recordSession === true)
84
+ body.recording = true;
85
+ if (proxy !== undefined)
86
+ body.proxy = proxy;
87
+ if (allowedDomains)
88
+ body.allowedDomains = allowedDomains;
89
+ if (bs.context?.id)
90
+ body.profileId = bs.context.id;
91
+ if (p.timeout !== undefined)
92
+ body.timeoutSeconds = p.timeout; // the gateway validates (>= 60) and clamps to the plan maximum
93
+ if (p.keepAlive === true)
94
+ body.keepAlive = true;
95
+ if (p.userMetadata !== undefined)
96
+ body.userMetadata = p.userMetadata;
97
+ return {
98
+ body,
99
+ ...(bs.context?.id && bs.context.persist === true ? { persistProfileId: bs.context.id } : {}),
100
+ warnings,
101
+ };
102
+ }
103
+ /** Solari session state -> Browserbase status. */
104
+ export function mapStatus(s) {
105
+ switch (s) {
106
+ case "active":
107
+ return "RUNNING";
108
+ case "released":
109
+ return "COMPLETED";
110
+ case "expired":
111
+ return "TIMED_OUT";
112
+ default:
113
+ return "ERROR";
114
+ }
115
+ }
@@ -0,0 +1,118 @@
1
+ /** Browserbase-shaped types (the subset this package supports). */
2
+ export type SessionStatus = "PENDING" | "RUNNING" | "ERROR" | "TIMED_OUT" | "COMPLETED";
3
+ export interface ProxyGeolocation {
4
+ country: string;
5
+ state?: string;
6
+ city?: string;
7
+ }
8
+ export interface BrowserbaseProxyConfig {
9
+ type: "browserbase";
10
+ geolocation?: ProxyGeolocation;
11
+ domainPattern?: string;
12
+ }
13
+ export interface ExternalProxyConfig {
14
+ type: "external";
15
+ server: string;
16
+ username?: string;
17
+ password?: string;
18
+ domainPattern?: string;
19
+ }
20
+ export interface NoneProxyConfig {
21
+ type: "none";
22
+ domainPattern?: string;
23
+ }
24
+ export type ProxyConfig = BrowserbaseProxyConfig | ExternalProxyConfig | NoneProxyConfig;
25
+ export interface BrowserSettings {
26
+ context?: {
27
+ id: string;
28
+ persist?: boolean;
29
+ };
30
+ extensionId?: string;
31
+ viewport?: {
32
+ width?: number;
33
+ height?: number;
34
+ };
35
+ blockAds?: boolean;
36
+ solveCaptchas?: boolean;
37
+ recordSession?: boolean;
38
+ logSession?: boolean;
39
+ advancedStealth?: boolean;
40
+ verified?: boolean;
41
+ captchaImageSelector?: string;
42
+ captchaInputSelector?: string;
43
+ os?: "windows" | "mac" | "linux" | "mobile" | "tablet";
44
+ allowedDomains?: string[];
45
+ ignoreCertificateErrors?: boolean;
46
+ }
47
+ export interface SessionCreateParams {
48
+ projectId?: string;
49
+ extensionId?: string;
50
+ browserSettings?: BrowserSettings;
51
+ timeout?: number;
52
+ keepAlive?: boolean;
53
+ proxies?: boolean | ProxyConfig[];
54
+ proxySettings?: {
55
+ caCertificates?: string[];
56
+ };
57
+ region?: string;
58
+ userMetadata?: Record<string, unknown>;
59
+ }
60
+ export interface Session {
61
+ id: string;
62
+ createdAt: string;
63
+ updatedAt: string;
64
+ projectId: string;
65
+ startedAt: string;
66
+ endedAt?: string;
67
+ expiresAt: string;
68
+ status: SessionStatus;
69
+ proxyBytes: number;
70
+ keepAlive: boolean;
71
+ contextId?: string;
72
+ region: string;
73
+ userMetadata?: Record<string, unknown>;
74
+ }
75
+ export interface SessionCreateResponse extends Session {
76
+ /** CDP websocket URL: `chromium.connectOverCDP(connectUrl)` / `puppeteer.connect({browserWSEndpoint})`. */
77
+ connectUrl: string;
78
+ /** Always empty: Solari Browser has no WebDriver endpoint. */
79
+ seleniumRemoteUrl: string;
80
+ /** Always empty: nothing to sign, the session id in the URL is the credential. */
81
+ signingKey: string;
82
+ /**
83
+ * Solari extension. For a session created with `browserSettings.context`, the saved cookies and localStorage.
84
+ * Solari applies a saved context only to a browser context created with it, so create yours with
85
+ * `browser.newContext({ storageState: session.storageState })`. Absent when no context was requested.
86
+ */
87
+ storageState?: StorageState | null;
88
+ }
89
+ export interface StorageState {
90
+ cookies?: Array<Record<string, unknown>>;
91
+ origins?: Array<Record<string, unknown>>;
92
+ }
93
+ export type SessionRetrieveResponse = SessionCreateResponse;
94
+ export interface SessionLiveURLs {
95
+ debuggerFullscreenUrl: string;
96
+ debuggerUrl: string;
97
+ wsUrl: string;
98
+ pages: Array<{
99
+ id: string;
100
+ url: string;
101
+ title: string;
102
+ faviconUrl: string;
103
+ debuggerUrl: string;
104
+ debuggerFullscreenUrl: string;
105
+ }>;
106
+ }
107
+ export interface Context {
108
+ id: string;
109
+ name?: string;
110
+ createdAt?: string;
111
+ }
112
+ export interface ContextCreateResponse {
113
+ id: string;
114
+ /** Empty: Solari profiles are stored server-side, no client-side encryption material. */
115
+ publicKey: string;
116
+ cipherAlgorithm: string;
117
+ initializationVectorSize: number;
118
+ }
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,28 @@
1
1
  {
2
2
  "name": "@solarisdk/browserbase-compat",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "Drop-in Browserbase-style SDK surface for Solari Browser: sessions, connectUrl (CDP), contexts, live view, replay events.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": ["dist", "README.md", "COMPAT.md", "CHANGELOG.md", "LICENSE", "NOTICE"],
16
+ "keywords": ["browserbase", "solari", "browser", "playwright", "puppeteer", "cdp", "compat"],
17
+ "engines": { "node": ">=20" },
18
+ "publishConfig": { "access": "public" },
19
+ "scripts": {
20
+ "build": "tsc",
21
+ "typecheck": "node ../../scripts/typecheck-guard.mjs 2 -- tsc --noEmit",
22
+ "test": "tsc && node --test test/*.test.mjs"
23
+ },
24
+ "devDependencies": {
25
+ "@types/node": "^20.0.0",
26
+ "typescript": "^5.4.0"
27
+ }
28
+ }