diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 63e6b75..f9f879f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -200,5 +200,4 @@ jobs: - name: Run e2e tests env: BROWSERBASE_API_KEY: ${{ secrets.BB_INTEGRATION_TEST_API_KEY }} - BROWSERBASE_PROJECT_ID: ${{ secrets.BB_INTEGRATION_TEST_PROJECT_ID }} run: pnpm run test:e2e diff --git a/README.md b/README.md index f3ff111..d268398 100644 --- a/README.md +++ b/README.md @@ -27,11 +27,10 @@ pnpm dlx @browserbasehq/sdk-functions init my-project cd my-project ``` -Add your Browserbase credentials to `.env`: +Add your Browserbase API key to `.env`: ```sh BROWSERBASE_API_KEY=your_api_key_here -BROWSERBASE_PROJECT_ID=your_project_id_here ``` Start the local development server: @@ -188,14 +187,13 @@ Options: ## Configuration -Set your Browserbase credentials as environment variables or in a `.env` file: +Set your Browserbase API key as an environment variable or in a `.env` file: -| Variable | Required | Description | -| ------------------------ | -------- | --------------------------- | -| `BROWSERBASE_API_KEY` | Yes | Your Browserbase API key | -| `BROWSERBASE_PROJECT_ID` | Yes | Your Browserbase project ID | +| Variable | Required | Description | +| --------------------- | -------- | ------------------------ | +| `BROWSERBASE_API_KEY` | Yes | Your Browserbase API key | -Get your API key and project ID from [browserbase.com](https://browserbase.com). +Get your API key from [browserbase.com](https://browserbase.com). ## Requirements diff --git a/package.json b/package.json index 4bb5458..ff4c0de 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@browserbasehq/sdk-functions", - "version": "1.0.1", + "version": "1.0.2", "description": "", "type": "module", "exports": { @@ -60,7 +60,7 @@ "typescript-eslint": "^8.42.0" }, "dependencies": { - "@browserbasehq/sdk": "^2.6.0", + "@browserbasehq/sdk": "^2.10.0", "archiver": "^7.0.1", "chalk": "^5.6.2", "commander": "^14.0.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4529f1e..c998087 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,8 +8,8 @@ importers: .: dependencies: "@browserbasehq/sdk": - specifier: ^2.6.0 - version: 2.6.0 + specifier: ^2.10.0 + version: 2.10.0 archiver: specifier: ^7.0.1 version: 7.0.1 @@ -67,10 +67,10 @@ importers: version: 8.42.0(eslint@9.35.0(jiti@2.5.1))(typescript@5.9.2) packages: - "@browserbasehq/sdk@2.6.0": + "@browserbasehq/sdk@2.10.0": resolution: { - integrity: sha512-83iXP5D7xMm8Wyn66TUaUrgoByCmAJuoMoZQI3sGg3JAiMlTfnCIMqyVBoNSaItaPIkaCnrsj6LiusmXV2X9YA==, + integrity: sha512-pOL4yW8P8AI2+N5y6zEP6XXKqIXtYyKunr1JXppqQDOyKLxxvZEDqQCHJXWUzqgx3R1tGWpn7m9AjXN7MeYInA==, } "@cspotcode/source-map-support@0.8.1": @@ -2534,7 +2534,7 @@ packages: } snapshots: - "@browserbasehq/sdk@2.6.0": + "@browserbasehq/sdk@2.10.0": dependencies: "@types/node": 18.19.124 "@types/node-fetch": 2.6.13 diff --git a/src/cli/dev/browser-manager.ts b/src/cli/dev/browser-manager.ts index d997dcf..619e787 100644 --- a/src/cli/dev/browser-manager.ts +++ b/src/cli/dev/browser-manager.ts @@ -29,11 +29,6 @@ export interface IRemoteBrowserManager { */ closeSession(sessionId: string): Promise; - /** - * Get the project ID - */ - getProjectId(): string; - /** * Check if the manager is initialized */ @@ -45,20 +40,16 @@ export interface IRemoteBrowserManager { */ export class RemoteBrowserManager implements IRemoteBrowserManager { private browserbaseClient: Browserbase | null = null; - private projectId: string; private apiKey: string; private initialized: boolean = false; constructor() { - const foundProjectId = process.env["BROWSERBASE_PROJECT_ID"]; const foundApiKey = process.env["BROWSERBASE_API_KEY"]; - if (!foundProjectId || !foundApiKey) { + if (!foundApiKey) { console.error( chalk.red("✗ Browserbase credentials not found.\n") + - chalk.red( - " Please set BROWSERBASE_PROJECT_ID and BROWSERBASE_API_KEY in your .env file.\n", - ) + + chalk.red(" Please set BROWSERBASE_API_KEY in your .env file.\n") + chalk.gray( " Copy .env.example to .env and fill in your credentials.", ), @@ -66,7 +57,6 @@ export class RemoteBrowserManager implements IRemoteBrowserManager { throw new Error("Missing Browserbase credentials"); } - this.projectId = foundProjectId; this.apiKey = foundApiKey; } @@ -98,7 +88,6 @@ export class RemoteBrowserManager implements IRemoteBrowserManager { console.log(chalk.cyan(`Creating browser session...`)); const createdSession = await this.browserbaseClient.sessions.create({ - projectId: this.projectId, ...sessionConfig, }); @@ -122,7 +111,6 @@ export class RemoteBrowserManager implements IRemoteBrowserManager { try { console.log(chalk.cyan(`Closing browser session: ${sessionId}...`)); await this.browserbaseClient.sessions.update(sessionId, { - projectId: this.projectId, status: "REQUEST_RELEASE", }); console.log(chalk.green(`✓ Browser session closed: ${sessionId}`)); @@ -135,13 +123,6 @@ export class RemoteBrowserManager implements IRemoteBrowserManager { } } - /** - * Get the project ID - */ - public getProjectId(): string { - return this.projectId; - } - /** * Check if the manager is initialized */ diff --git a/src/cli/dev/server.test.ts b/src/cli/dev/server.test.ts index ea20bcc..787fd80 100644 --- a/src/cli/dev/server.test.ts +++ b/src/cli/dev/server.test.ts @@ -233,10 +233,6 @@ class MockBrowserManager implements IRemoteBrowserManager { this.closeSessionCalls.push([sessionId]); } - getProjectId(): string { - return "test-project-id"; - } - isInitialized(): boolean { return true; } diff --git a/src/cli/init/templates/.env.template b/src/cli/init/templates/.env.template index a2a9f9e..e7e6194 100644 --- a/src/cli/init/templates/.env.template +++ b/src/cli/init/templates/.env.template @@ -1,8 +1,5 @@ # Browserbase Configuration -# Get your API key and project ID from https://browserbase.com +# Get your API key from https://browserbase.com # Your Browserbase API key BROWSERBASE_API_KEY=your_api_key_here - -# Your Browserbase project ID -BROWSERBASE_PROJECT_ID=your_project_id_here diff --git a/src/cli/invoke/index.ts b/src/cli/invoke/index.ts index 79123c7..35e68d8 100644 --- a/src/cli/invoke/index.ts +++ b/src/cli/invoke/index.ts @@ -12,7 +12,6 @@ import { export interface InvocationResponse { id: string; functionId: string; - projectId: string; status: InvocationStatus; params?: Record; results?: Record; diff --git a/src/cli/publish/api-client.ts b/src/cli/publish/api-client.ts index 8d2aced..a4320f5 100644 --- a/src/cli/publish/api-client.ts +++ b/src/cli/publish/api-client.ts @@ -10,7 +10,6 @@ import { export interface BuildMetadata { entrypoint: string; - projectId?: string; } export interface UploadResult { @@ -21,7 +20,6 @@ export interface UploadResult { export interface FunctionCreatedVersion { id: string; - projectId: string; functionId: string; functionBuildId: string; sessionCreateParams?: Record; @@ -31,7 +29,6 @@ export interface FunctionCreatedVersion { export interface BuiltFunction { id: string; - projectId: string; name: string; createdVersion: FunctionCreatedVersion; createdAt: string; @@ -40,7 +37,6 @@ export interface BuiltFunction { export interface BuildStatusResponse { id: string; - projectId: string; status: BuildStatus; request: { entrypoint: string; @@ -63,7 +59,6 @@ export async function uploadBuild( if (options?.dryRun) { console.log(chalk.cyan("\n[Dry run] Would upload to:")); console.log(chalk.gray(` URL: ${config.apiUrl}/v1/functions/builds`)); - console.log(chalk.gray(` Project ID: ${config.projectId}`)); console.log(chalk.gray(` Entrypoint: ${config.entrypoint}`)); console.log( chalk.gray( @@ -85,7 +80,6 @@ export async function uploadBuild( // Add metadata const metadata: BuildMetadata = { entrypoint: config.entrypoint, - projectId: config.projectId, }; formData.append("metadata", JSON.stringify(metadata)); diff --git a/src/cli/publish/config.ts b/src/cli/publish/config.ts index 3eae772..1837095 100644 --- a/src/cli/publish/config.ts +++ b/src/cli/publish/config.ts @@ -5,7 +5,6 @@ import * as path from "node:path"; import { type BaseConfig, requireApiKey, - requireProjectId, getApiUrl, validateApiKeyFormat, } from "../shared/index.js"; @@ -14,7 +13,6 @@ import { * Extended configuration for publish command. */ export interface PublishConfig extends BaseConfig { - projectId: string; entrypoint: string; workingDirectory: string; } @@ -24,7 +22,6 @@ export function loadConfig(options: { apiUrl?: string; }): PublishConfig { const apiKey = requireApiKey(); - const projectId = requireProjectId(); const apiUrl = getApiUrl(options.apiUrl); // Use provided entrypoint or default to main.ts @@ -52,7 +49,6 @@ export function loadConfig(options: { return { apiKey, - projectId, apiUrl, entrypoint, workingDirectory: process.cwd(), diff --git a/src/cli/publish/index.ts b/src/cli/publish/index.ts index c1c4264..98e71a2 100644 --- a/src/cli/publish/index.ts +++ b/src/cli/publish/index.ts @@ -20,7 +20,6 @@ function displayBuildDetails(build: BuildStatusResponse): void { // Display basic build information console.log(chalk.white(`Build ID: ${chalk.cyan(build.id)}`)); - console.log(chalk.white(`Project ID: ${chalk.cyan(build.projectId)}`)); console.log(chalk.white(`Status: ${chalk.green(build.status)}`)); if (build.request?.entrypoint) { @@ -101,7 +100,7 @@ function displayBuildDetails(build: BuildStatusResponse): void { console.log(chalk.gray("\n curl --request POST \\")); console.log( chalk.gray( - ` --url ${func.projectId ? "https" : "http"}://api.browserbase.com/v1/functions/${func.id}/invoke \\`, + ` --url https://api.browserbase.com/v1/functions/${func.id}/invoke \\`, ), ); console.log( @@ -138,7 +137,6 @@ export async function publishFunction(options: PublishOptions): Promise { console.log(chalk.gray(`Working directory: ${config.workingDirectory}`)); console.log(chalk.gray(`Entrypoint: ${config.entrypoint}`)); console.log(chalk.gray(`API URL: ${config.apiUrl}`)); - console.log(chalk.gray(`Project ID: ${config.projectId}`)); if (options.dryRun) { console.log( diff --git a/src/cli/shared/config.ts b/src/cli/shared/config.ts index 8bbc052..d2afda2 100644 --- a/src/cli/shared/config.ts +++ b/src/cli/shared/config.ts @@ -33,28 +33,6 @@ export function requireApiKey(): string { return apiKey; } -/** - * Get the Browserbase project ID from environment. - * Exits the process with an error message if not found. - */ -export function requireProjectId(): string { - const projectId = process.env["BROWSERBASE_PROJECT_ID"]; - if (!projectId) { - console.error( - chalk.red( - "Error: BROWSERBASE_PROJECT_ID not found in environment variables.", - ), - ); - console.log( - chalk.gray( - "Please set BROWSERBASE_PROJECT_ID in your .env file or environment.", - ), - ); - process.exit(1); - } - return projectId; -} - /** * Get the API URL from options, environment, or use the default. */ diff --git a/src/cli/shared/index.ts b/src/cli/shared/index.ts index 2e943ef..5ad1e4b 100644 --- a/src/cli/shared/index.ts +++ b/src/cli/shared/index.ts @@ -1,7 +1,6 @@ export { type BaseConfig, requireApiKey, - requireProjectId, getApiUrl, validateApiKeyFormat, loadBaseConfig, diff --git a/src/define/helpers.test.ts b/src/define/helpers.test.ts index 9bb0aa9..66d8658 100644 --- a/src/define/helpers.test.ts +++ b/src/define/helpers.test.ts @@ -69,7 +69,7 @@ describe("buildPersistedFunctionManifest", () => { parametersSchema: schema, sessionConfig: { browserSettings: { - fingerprint: { devices: ["desktop"] }, + blockAds: true, }, }, }, @@ -81,7 +81,7 @@ describe("buildPersistedFunctionManifest", () => { assert(result.config.parametersSchema); assert.deepStrictEqual(result.config.sessionConfig, { browserSettings: { - fingerprint: { devices: ["desktop"] }, + blockAds: true, }, }); }); diff --git a/tests/e2e/e2e.test.ts b/tests/e2e/e2e.test.ts index cb97073..b268dbf 100644 --- a/tests/e2e/e2e.test.ts +++ b/tests/e2e/e2e.test.ts @@ -8,7 +8,6 @@ import { requireCredentials, pollBuildStatus, API_KEY, - PROJECT_ID, discoverTemplates, getTarballPath, setupTemplateProject, @@ -63,7 +62,6 @@ describe("E2E: Publish, Build, and Invoke", { concurrency: true }, () => { env: { ...process.env, BROWSERBASE_API_KEY: API_KEY, - BROWSERBASE_PROJECT_ID: PROJECT_ID, }, stdio: ["pipe", "pipe", "pipe"], }, @@ -114,7 +112,6 @@ describe("E2E: Publish, Build, and Invoke", { concurrency: true }, () => { env: { ...process.env, BROWSERBASE_API_KEY: API_KEY, - BROWSERBASE_PROJECT_ID: PROJECT_ID, }, stdio: ["pipe", "pipe", "pipe"], timeout: 120_000, diff --git a/tests/e2e/helpers.ts b/tests/e2e/helpers.ts index 746d292..54d2e0c 100644 --- a/tests/e2e/helpers.ts +++ b/tests/e2e/helpers.ts @@ -11,15 +11,12 @@ dotenv.config({ path: join(PROJECT_ROOT_LOCAL, ".env.e2e") }); // ── Credentials ────────────────────────────────────────────────── export const API_KEY = process.env["BROWSERBASE_API_KEY"]; -export const PROJECT_ID = process.env["BROWSERBASE_PROJECT_ID"]; export const API_URL = process.env["BROWSERBASE_API_URL"] ?? "https://api.browserbase.com"; export function requireCredentials(): void { - if (!API_KEY || !PROJECT_ID) { - throw new Error( - "BROWSERBASE_API_KEY and BROWSERBASE_PROJECT_ID must be set for e2e tests", - ); + if (!API_KEY) { + throw new Error("BROWSERBASE_API_KEY must be set for e2e tests"); } } diff --git a/tests/integration/cli/dev-server.test.ts b/tests/integration/cli/dev-server.test.ts index d31313a..0c567fb 100644 --- a/tests/integration/cli/dev-server.test.ts +++ b/tests/integration/cli/dev-server.test.ts @@ -15,7 +15,6 @@ import { const templates = discoverTemplates(); const API_KEY = "test_key"; -const PROJECT_ID = "test_project"; function getFunctionName(templateName: string): string { return `sdk-e2e-${templateName}`; @@ -36,7 +35,6 @@ function startDevServer( env: { ...process.env, BROWSERBASE_API_KEY: API_KEY, - BROWSERBASE_PROJECT_ID: PROJECT_ID, }, }, ); diff --git a/tests/integration/cli/publish.test.ts b/tests/integration/cli/publish.test.ts index 427827e..2f96cc7 100644 --- a/tests/integration/cli/publish.test.ts +++ b/tests/integration/cli/publish.test.ts @@ -39,8 +39,6 @@ describe("Publish CLI", () => { env: { BROWSERBASE_API_KEY: process.env["BROWSERBASE_API_KEY"] ?? "test_key", - BROWSERBASE_PROJECT_ID: - process.env["BROWSERBASE_PROJECT_ID"] ?? "test_project", }, }); @@ -84,25 +82,12 @@ describe("Publish CLI", () => { cwd: projectDir, env: { BROWSERBASE_API_KEY: "", - BROWSERBASE_PROJECT_ID: "test_project", }, }); assert.notEqual(result.exitCode, 0, "Should fail without API key"); }); - it("missing project ID fails", () => { - const result = runBb(`publish ${template.entrypoint}`, { - cwd: projectDir, - env: { - BROWSERBASE_API_KEY: "test_key", - BROWSERBASE_PROJECT_ID: "", - }, - }); - - assert.notEqual(result.exitCode, 0, "Should fail without project ID"); - }); - it("gitignore patterns are respected", () => { // Create test artifacts that should be ignored const gitignorePath = join(projectDir, ".gitignore"); @@ -137,8 +122,6 @@ describe("Publish CLI", () => { env: { BROWSERBASE_API_KEY: process.env["BROWSERBASE_API_KEY"] ?? "test_key", - BROWSERBASE_PROJECT_ID: - process.env["BROWSERBASE_PROJECT_ID"] ?? "test_project", }, });