Skip to content
Open
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
8 changes: 6 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,18 @@ jobs:
run: ./scripts/build

- name: Get GitHub OIDC Token
if: github.repository == 'stainless-sdks/browserbase-node'
if: |-
github.repository == 'stainless-sdks/browserbase-node' &&
!startsWith(github.ref, 'refs/heads/stl/')
id: github-oidc
uses: actions/github-script@v8
with:
script: core.setOutput('github_token', await core.getIDToken());

- name: Upload tarball
if: github.repository == 'stainless-sdks/browserbase-node'
if: |-
github.repository == 'stainless-sdks/browserbase-node' &&
!startsWith(github.ref, 'refs/heads/stl/')
env:
URL: https://pkg.stainless.com/s
AUTH: ${{ steps.github-oidc.outputs.github_token }}
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "2.7.0"
".": "2.8.0"
}
40 changes: 40 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,45 @@
# Changelog

## 2.8.0 (2026-03-07)

Full Changelog: [v2.7.0...v2.8.0](https://github.com/browserbase/sdk-node/compare/v2.7.0...v2.8.0)

### Features

* **api:** api update ([#19](https://github.com/browserbase/sdk-node/issues/19)) ([8df9cc8](https://github.com/browserbase/sdk-node/commit/8df9cc8c76e4a615ba63d4568086bd60e88a0dfb))
* **api:** update via SDK Studio ([#10](https://github.com/browserbase/sdk-node/issues/10)) ([2c6c15d](https://github.com/browserbase/sdk-node/commit/2c6c15d148d1a5e74a48f92087580d8c590288af))
* **api:** update via SDK Studio ([#11](https://github.com/browserbase/sdk-node/issues/11)) ([9191ed6](https://github.com/browserbase/sdk-node/commit/9191ed631256b52a39de1aafcf1d7deb2788efdb))
* **api:** update via SDK Studio ([#12](https://github.com/browserbase/sdk-node/issues/12)) ([ebeaf82](https://github.com/browserbase/sdk-node/commit/ebeaf82736747398450d739e27d6874603c4f942))
* **api:** update via SDK Studio ([#13](https://github.com/browserbase/sdk-node/issues/13)) ([c0ffdce](https://github.com/browserbase/sdk-node/commit/c0ffdce615059b9523817d22ef18e01e778f3454))
* **api:** update via SDK Studio ([#16](https://github.com/browserbase/sdk-node/issues/16)) ([a96a86c](https://github.com/browserbase/sdk-node/commit/a96a86c2e7c5025cacd7edd89f88b914de3596e3))
* **api:** update via SDK Studio ([#17](https://github.com/browserbase/sdk-node/issues/17)) ([52cf741](https://github.com/browserbase/sdk-node/commit/52cf741bc4c5712f2fe15ee6eaa48e4c3643ec58))
* **api:** update via SDK Studio ([#3](https://github.com/browserbase/sdk-node/issues/3)) ([8a06f81](https://github.com/browserbase/sdk-node/commit/8a06f81c1cd5dc8a64b9fd10ed26f8547469fdeb))
* **api:** update via SDK Studio ([#4](https://github.com/browserbase/sdk-node/issues/4)) ([cf6309b](https://github.com/browserbase/sdk-node/commit/cf6309bb5de1376139fb0ba6b8e45b5d0801bee5))
* **api:** update via SDK Studio ([#5](https://github.com/browserbase/sdk-node/issues/5)) ([4275810](https://github.com/browserbase/sdk-node/commit/427581035437844d44333c0e3471db675dff89c7))
* **api:** update via SDK Studio ([#6](https://github.com/browserbase/sdk-node/issues/6)) ([299d77e](https://github.com/browserbase/sdk-node/commit/299d77ebc0994b0ab39a9c908157d42d605e9765))
* **api:** update via SDK Studio ([#7](https://github.com/browserbase/sdk-node/issues/7)) ([e1e4738](https://github.com/browserbase/sdk-node/commit/e1e47381dc142f94bd61e7f5819eafbf5b4797a7))
* **api:** update via SDK Studio ([#8](https://github.com/browserbase/sdk-node/issues/8)) ([2d845ff](https://github.com/browserbase/sdk-node/commit/2d845ffc683ea988980e42ea2c03699034af6980))
* **api:** update via SDK Studio ([#9](https://github.com/browserbase/sdk-node/issues/9)) ([a17fadc](https://github.com/browserbase/sdk-node/commit/a17fadcac323079f3e36e0c965f6d6c1be26f1d8))


### Bug Fixes

* **client:** preserve URL params already embedded in path ([81f76ab](https://github.com/browserbase/sdk-node/commit/81f76aba8e0ac48fe758e9c567ba9e3fb174cfc5))
* use npm publish instead of yarn publish ([#173](https://github.com/browserbase/sdk-node/issues/173)) ([05b3225](https://github.com/browserbase/sdk-node/commit/05b3225efe94473f2b49988dab63a9e67beb9802))


### Chores

* **ci:** skip uploading artifacts on stainless-internal branches ([0c1949d](https://github.com/browserbase/sdk-node/commit/0c1949d9237aa69c6ca9adda699376672f398f24))
* go live ([#1](https://github.com/browserbase/sdk-node/issues/1)) ([bc9e36e](https://github.com/browserbase/sdk-node/commit/bc9e36ec17be8df65bc4bd43bad6ad6617e4973c))
* **internal:** codegen related update ([d8b846c](https://github.com/browserbase/sdk-node/commit/d8b846cae415cec3a826e26b1a8cae47cca9e943))
* **internal:** move stringifyQuery implementation to internal function ([fb87469](https://github.com/browserbase/sdk-node/commit/fb8746921c5bad61c77f44b6e3fe8bf164c1e5b5))
* **release:** prepare alpha ([#36](https://github.com/browserbase/sdk-node/issues/36)) ([c5e0f61](https://github.com/browserbase/sdk-node/commit/c5e0f61f324c607421449db10cf861a0a5100b4a))
* **release:** v2.0.0 ([#39](https://github.com/browserbase/sdk-node/issues/39)) ([2ecb572](https://github.com/browserbase/sdk-node/commit/2ecb5720bc6102a3487ecd71f06fd3c548b5f760))
* **test:** do not count install time for mock server timeout ([1fd6556](https://github.com/browserbase/sdk-node/commit/1fd655639e75cf32f66d361c5c287960f6fc3982))
* update placeholder string ([fb97b1c](https://github.com/browserbase/sdk-node/commit/fb97b1c30905958b6a427a13e6922a4da30c2c15))
* update SDK settings ([#21](https://github.com/browserbase/sdk-node/issues/21)) ([dd2956f](https://github.com/browserbase/sdk-node/commit/dd2956f0b22aac232b6ae3cdd572a4d6b688099d))

## 2.7.0-alpha.3 (2026-02-26)

Full Changelog: [v2.7.0-alpha.2...v2.7.0-alpha.3](https://github.com/browserbase/sdk-node/compare/v2.7.0-alpha.2...v2.7.0-alpha.3)
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@browserbasehq/sdk",
"version": "2.7.0",
"version": "2.8.0",
"description": "The official Node.js library for the Browserbase API",
"author": "Browserbase <support@browserbase.com>",
"types": "dist/index.d.ts",
Expand Down
13 changes: 12 additions & 1 deletion scripts/mock
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,22 @@ echo "==> Starting mock server with URL ${URL}"

# Run prism mock on the given spec
if [ "$1" == "--daemon" ]; then
# Pre-install the package so the download doesn't eat into the startup timeout
npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism --version

npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" &> .prism.log &

# Wait for server to come online
# Wait for server to come online (max 30s)
echo -n "Waiting for server"
attempts=0
while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do
attempts=$((attempts + 1))
if [ "$attempts" -ge 300 ]; then
echo
echo "Timed out waiting for Prism server to start"
cat .prism.log
exit 1
fi
echo -n "."
sleep 0.1
done
Expand Down
31 changes: 10 additions & 21 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
APIConnectionTimeoutError,
APIUserAbortError,
} from './error';
import { stringifyQuery } from './internal/utils/query';
import {
kind as shimsKind,
type Readable,
Expand Down Expand Up @@ -523,32 +524,20 @@ export abstract class APIClient {
: new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));

const defaultQuery = this.defaultQuery();
if (!isEmptyObj(defaultQuery)) {
query = { ...defaultQuery, ...query } as Req;
const pathQuery = Object.fromEntries(url.searchParams);
if (!isEmptyObj(defaultQuery) || !isEmptyObj(pathQuery)) {
query = { ...pathQuery, ...defaultQuery, ...query } as Req;
}

if (typeof query === 'object' && query && !Array.isArray(query)) {
url.search = this.stringifyQuery(query as Record<string, unknown>);
url.search = this.stringifyQuery(query);
}

return url.toString();
}

protected stringifyQuery(query: Record<string, unknown>): string {
return Object.entries(query)
.filter(([_, value]) => typeof value !== 'undefined')
.map(([key, value]) => {
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
}
if (value === null) {
return `${encodeURIComponent(key)}=`;
}
throw new BrowserbaseError(
`Cannot stringify type ${typeof value}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`,
);
})
.join('&');
protected stringifyQuery(query: object | Record<string, unknown>): string {
return stringifyQuery(query);
}

async fetchWithTimeout(
Expand Down Expand Up @@ -630,9 +619,9 @@ export abstract class APIClient {
}
}

// If the API asks us to wait a certain amount of time (and it's a reasonable amount),
// just do what it says, but otherwise calculate a default
if (!(timeoutMillis && 0 <= timeoutMillis && timeoutMillis < 60 * 1000)) {
// If the API asks us to wait a certain amount of time, do what it says.
// Otherwise calculate a default.
if (timeoutMillis === undefined) {
const maxRetries = options.maxRetries ?? this.maxRetries;
timeoutMillis = this.calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries);
}
Expand Down
23 changes: 23 additions & 0 deletions src/internal/utils/query.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import { BrowserbaseError } from '../../error';

/**
* Basic re-implementation of `qs.stringify` for primitive types.
*/
export function stringifyQuery(query: object | Record<string, unknown>) {
return Object.entries(query)
.filter(([_, value]) => typeof value !== 'undefined')
.map(([key, value]) => {
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
}
if (value === null) {
return `${encodeURIComponent(key)}=`;
}
throw new BrowserbaseError(
`Cannot stringify type ${typeof value}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`,
);
})
.join('&');
}
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = '2.7.0'; // x-release-please-version
export const VERSION = '2.8.0'; // x-release-please-version
4 changes: 2 additions & 2 deletions tests/api-resources/extensions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const client = new Browserbase({
describe('resource extensions', () => {
test('create: only required params', async () => {
const responsePromise = client.extensions.create({
file: await toFile(Buffer.from('# my file contents'), 'README.md'),
file: await toFile(Buffer.from('Example data'), 'README.md'),
});
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
Expand All @@ -24,7 +24,7 @@ describe('resource extensions', () => {

test('create: required and optional params', async () => {
const response = await client.extensions.create({
file: await toFile(Buffer.from('# my file contents'), 'README.md'),
file: await toFile(Buffer.from('Example data'), 'README.md'),
});
});

Expand Down
4 changes: 2 additions & 2 deletions tests/api-resources/sessions/uploads.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const client = new Browserbase({
describe('resource uploads', () => {
test('create: only required params', async () => {
const responsePromise = client.sessions.uploads.create('id', {
file: await toFile(Buffer.from('# my file contents'), 'README.md'),
file: await toFile(Buffer.from('Example data'), 'README.md'),
});
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
Expand All @@ -24,7 +24,7 @@ describe('resource uploads', () => {

test('create: required and optional params', async () => {
const response = await client.sessions.uploads.create('id', {
file: await toFile(Buffer.from('# my file contents'), 'README.md'),
file: await toFile(Buffer.from('Example data'), 'README.md'),
});
});
});
6 changes: 2 additions & 4 deletions tests/stringifyQuery.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import { Browserbase } from '@browserbasehq/sdk';

const { stringifyQuery } = Browserbase.prototype as any;
import { stringifyQuery } from '@browserbasehq/sdk/internal/utils/query';

describe(stringifyQuery, () => {
for (const [input, expected] of [
Expand All @@ -15,7 +13,7 @@ describe(stringifyQuery, () => {
'e=f',
)}=${encodeURIComponent('g&h')}`,
],
]) {
] as const) {
it(`${JSON.stringify(input)} -> ${expected}`, () => {
expect(stringifyQuery(input)).toEqual(expected);
});
Expand Down