diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dc091c19..4425e63c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,18 +1,18 @@ name: CI on: push: - branches: - - main - pull_request: - branches: - - main - - next + branches-ignore: + - 'generated' + - 'codegen/**' + - 'integrated/**' + - 'stl-preview-head/**' + - 'stl-preview-base/**' jobs: lint: + timeout-minutes: 10 name: lint - runs-on: ubuntu-latest - + runs-on: ${{ github.repository == 'stainless-sdks/browserbase-node' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} steps: - uses: actions/checkout@v4 @@ -28,9 +28,12 @@ jobs: run: ./scripts/lint build: + timeout-minutes: 5 name: build - runs-on: ubuntu-latest - + runs-on: ${{ github.repository == 'stainless-sdks/browserbase-node' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + permissions: + contents: read + id-token: write steps: - uses: actions/checkout@v4 @@ -44,10 +47,25 @@ jobs: - name: Check build run: ./scripts/build + + - name: Get GitHub OIDC Token + if: github.repository == 'stainless-sdks/browserbase-node' + id: github-oidc + uses: actions/github-script@v6 + with: + script: core.setOutput('github_token', await core.getIDToken()); + + - name: Upload tarball + if: github.repository == 'stainless-sdks/browserbase-node' + env: + URL: https://pkg.stainless.com/s + AUTH: ${{ steps.github-oidc.outputs.github_token }} + SHA: ${{ github.sha }} + run: ./scripts/utils/upload-artifact.sh test: + timeout-minutes: 10 name: test - runs-on: ubuntu-latest - + runs-on: ${{ github.repository == 'stainless-sdks/browserbase-node' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} steps: - uses: actions/checkout@v4 diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 78baf5bf..69e82f12 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "2.5.0" + ".": "2.6.0" } diff --git a/.stats.yml b/.stats.yml index 072ee700..38c95a82 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 18 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fbrowserbase-ad8e080c2347b3f28d64f49cf02c2ab4a69b7bf289fd7eb018c955d8915bb990.yml -openapi_spec_hash: b3aea10135a89597634d62f1ef418839 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fbrowserbase-e2ed1b5267eeff92982918505349017b9155da2c7ab948787ab11cf9068af1b8.yml +openapi_spec_hash: 6639c21dccb52ca610cae833227a9791 config_hash: 74882e23a455dece33e43a27e67f0fbb diff --git a/CHANGELOG.md b/CHANGELOG.md index 26e67930..e085bb8f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,37 @@ # Changelog +## 2.6.0 (2025-05-16) + +Full Changelog: [v2.5.0...v2.6.0](https://github.com/browserbase/sdk-node/compare/v2.5.0...v2.6.0) + +### Features + +* **api:** api update ([0b43bac](https://github.com/browserbase/sdk-node/commit/0b43baccf8dbb13ed4b9bb8feed15849007cc531)) +* **api:** api update ([#158](https://github.com/browserbase/sdk-node/issues/158)) ([1287216](https://github.com/browserbase/sdk-node/commit/12872160a6e7be94d82cb4189cf53dc9eecbfbba)) + + +### Bug Fixes + +* **api:** improve type resolution when importing as a package ([#163](https://github.com/browserbase/sdk-node/issues/163)) ([758c8e0](https://github.com/browserbase/sdk-node/commit/758c8e048537bdc6d0070a11010ed307b5d4de03)) +* **client:** send `X-Stainless-Timeout` in seconds ([#161](https://github.com/browserbase/sdk-node/issues/161)) ([8aea1ee](https://github.com/browserbase/sdk-node/commit/8aea1ee6f66052fa976087c6dbb57f98385c6eee)) +* **mcp:** remove unused tools.ts ([#164](https://github.com/browserbase/sdk-node/issues/164)) ([b09bd54](https://github.com/browserbase/sdk-node/commit/b09bd54af116847e852f67bf6c7f0e32dfa92509)) + + +### Chores + +* **ci:** add timeout thresholds for CI jobs ([c813b38](https://github.com/browserbase/sdk-node/commit/c813b38b3be8470e2c5b95b58c621ccd7b7ccfe5)) +* **ci:** only use depot for staging repos ([475fe50](https://github.com/browserbase/sdk-node/commit/475fe5018be88d96971697bdc3e1b33ae9669310)) +* **client:** minor internal fixes ([ee36919](https://github.com/browserbase/sdk-node/commit/ee369190b385d25726cac1e3bc0e23559539d8d9)) +* **internal:** add aliases for Record and Array ([#162](https://github.com/browserbase/sdk-node/issues/162)) ([e658ed9](https://github.com/browserbase/sdk-node/commit/e658ed9e739c0479ffd542ffe4b616fc5884d77d)) +* **internal:** codegen related update ([99b8089](https://github.com/browserbase/sdk-node/commit/99b8089de31eb102cb82a9b85b2d13fd57570f5c)) +* **internal:** reduce CI branch coverage ([37d8e14](https://github.com/browserbase/sdk-node/commit/37d8e1406cc38d5e2003f40b43a7632c7f528544)) +* **internal:** upload builds and expand CI branch coverage ([d30a38a](https://github.com/browserbase/sdk-node/commit/d30a38a6331169eb4ef7672ae6fbd561cd5c5b0c)) + + +### Documentation + +* **readme:** fix typo ([7bc4b9b](https://github.com/browserbase/sdk-node/commit/7bc4b9ba006fef118f7883ed2fab7cc140906f97)) + ## 2.5.0 (2025-03-28) Full Changelog: [v2.4.0...v2.5.0](https://github.com/browserbase/sdk-node/compare/v2.4.0...v2.5.0) diff --git a/README.md b/README.md index 498687bf..5066f7fd 100644 --- a/README.md +++ b/README.md @@ -110,7 +110,7 @@ async function main() { main(); ``` -Error codes are as followed: +Error codes are as follows: | Status Code | Error Type | | ----------- | -------------------------- | diff --git a/package-lock.json b/package-lock.json index bc040c78..4edad490 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@browserbasehq/sdk", - "version": "2.5.0", + "version": "2.6.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@browserbasehq/sdk", - "version": "2.5.0", + "version": "2.6.0", "dependencies": { "@types/node": "^18.11.18", "@types/node-fetch": "^2.6.4", diff --git a/package.json b/package.json index 83453d5c..39c08ec4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@browserbasehq/sdk", - "version": "2.5.0", + "version": "2.6.0", "description": "The official Node.js library for the Browserbase API", "author": "Browserbase ", "types": "dist/index.d.ts", diff --git a/scripts/utils/upload-artifact.sh b/scripts/utils/upload-artifact.sh new file mode 100755 index 00000000..e8b835ad --- /dev/null +++ b/scripts/utils/upload-artifact.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +set -exuo pipefail + +RESPONSE=$(curl -X POST "$URL" \ + -H "Authorization: Bearer $AUTH" \ + -H "Content-Type: application/json") + +SIGNED_URL=$(echo "$RESPONSE" | jq -r '.url') + +if [[ "$SIGNED_URL" == "null" ]]; then + echo -e "\033[31mFailed to get signed URL.\033[0m" + exit 1 +fi + +UPLOAD_RESPONSE=$(tar -cz dist | curl -v -X PUT \ + -H "Content-Type: application/gzip" \ + --data-binary @- "$SIGNED_URL" 2>&1) + +if echo "$UPLOAD_RESPONSE" | grep -q "HTTP/[0-9.]* 200"; then + echo -e "\033[32mUploaded build to Stainless storage.\033[0m" + echo -e "\033[32mInstallation: npm install 'https://pkg.stainless.com/s/browserbase-node/$SHA'\033[0m" +else + echo -e "\033[31mFailed to upload artifact.\033[0m" + exit 1 +fi diff --git a/src/core.ts b/src/core.ts index df4306a6..180db7da 100644 --- a/src/core.ts +++ b/src/core.ts @@ -33,6 +33,20 @@ export { export type Fetch = (url: RequestInfo, init?: RequestInit) => Promise; +/** + * An alias to the builtin `Array` type so we can + * easily alias it in import statements if there are name clashes. + */ +type _Array = Array; + +/** + * An alias to the builtin `Record` type so we can + * easily alias it in import statements if there are name clashes. + */ +type _Record = Record; + +export type { _Array as Array, _Record as Record }; + type PromiseOrValue = T | Promise; type APIResponseProps = { @@ -282,10 +296,10 @@ export abstract class APIClient { } buildRequest( - options: FinalRequestOptions, + inputOptions: FinalRequestOptions, { retryCount = 0 }: { retryCount?: number } = {}, ): { req: RequestInit; url: string; timeout: number } { - options = { ...options }; + const options = { ...inputOptions }; const { method, path, query, headers: headers = {} } = options; const body = @@ -313,8 +327,8 @@ export abstract class APIClient { } if (this.idempotencyHeader && method !== 'get') { - if (!options.idempotencyKey) options.idempotencyKey = this.defaultIdempotencyKey(); - headers[this.idempotencyHeader] = options.idempotencyKey; + if (!inputOptions.idempotencyKey) inputOptions.idempotencyKey = this.defaultIdempotencyKey(); + headers[this.idempotencyHeader] = inputOptions.idempotencyKey; } const reqHeaders = this.buildHeaders({ options, headers, contentLength, retryCount }); @@ -371,7 +385,7 @@ export abstract class APIClient { getHeader(headers, 'x-stainless-timeout') === undefined && options.timeout ) { - reqHeaders['x-stainless-timeout'] = String(options.timeout); + reqHeaders['x-stainless-timeout'] = String(Math.trunc(options.timeout / 1000)); } this.validateHeaders(reqHeaders, headers); diff --git a/src/resources/sessions/sessions.ts b/src/resources/sessions/sessions.ts index 9952372c..8e9c6d06 100644 --- a/src/resources/sessions/sessions.ts +++ b/src/resources/sessions/sessions.ts @@ -307,8 +307,8 @@ export interface SessionCreateParams { extensionId?: string; /** - * Set to true to keep the session alive even after disconnections. This is - * available on the Startup plan only. + * Set to true to keep the session alive even after disconnections. Available on + * the Hobby Plan and above. */ keepAlive?: boolean; @@ -350,6 +350,18 @@ export namespace SessionCreateParams { */ blockAds?: boolean; + /** + * Custom selector for captcha image. See + * [Custom Captcha Solving](/features/stealth-mode#custom-captcha-solving) + */ + captchaImageSelector?: string; + + /** + * Custom selector for captcha input. See + * [Custom Captcha Solving](/features/stealth-mode#custom-captcha-solving) + */ + captchaInputSelector?: string; + context?: BrowserSettings.Context; /** diff --git a/src/version.ts b/src/version.ts index 38ceab27..cc6e4a84 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '2.5.0'; // x-release-please-version +export const VERSION = '2.6.0'; // x-release-please-version diff --git a/tests/api-resources/sessions/sessions.test.ts b/tests/api-resources/sessions/sessions.test.ts index c039294a..63ffc713 100644 --- a/tests/api-resources/sessions/sessions.test.ts +++ b/tests/api-resources/sessions/sessions.test.ts @@ -26,6 +26,8 @@ describe('resource sessions', () => { browserSettings: { advancedStealth: true, blockAds: true, + captchaImageSelector: 'captchaImageSelector', + captchaInputSelector: 'captchaInputSelector', context: { id: 'id', persist: true }, extensionId: 'extensionId', fingerprint: {