Skip to content

New Components - browserbase #16714

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 20, 2025
Merged

New Components - browserbase #16714

merged 6 commits into from
May 20, 2025

Conversation

luancazarine
Copy link
Collaborator

@luancazarine luancazarine commented May 19, 2025

Resolves #15425.

Summary by CodeRabbit

  • New Features
    • Introduced actions to create contexts and sessions, and to list projects within Browserbase.
    • Added a source to emit events when new sessions are created, with filtering options for status and metadata.
    • Provided selectable options for regions and session statuses.
  • Improvements
    • Enhanced project selection with dynamic project listing.
    • Centralized API request handling and added utility for parsing JSON inputs.
  • Chores
    • Updated package version and dependencies.
    • Added sample event data for testing and demonstration purposes.

Copy link

vercel bot commented May 19, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs-v2 ⬜️ Ignored (Inspect) Visit Preview May 19, 2025 9:33pm
pipedream-docs ⬜️ Ignored (Inspect) May 19, 2025 9:33pm
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) May 19, 2025 9:33pm

@luancazarine luancazarine added the ai-assisted Content generated by AI, with human refinement and modification label May 19, 2025
Copy link
Contributor

coderabbitai bot commented May 19, 2025

Walkthrough

This update introduces a new integration for Browserbase, adding actions to create sessions, create contexts, and list projects, as well as polling sources for new sessions. Supporting modules for constants, utilities, and base polling logic are included. The Browserbase app module is expanded to provide API interaction methods and dynamic prop options.

Changes

File(s) Change Summary
components/browserbase/actions/create-context/create-context.mjs New action: Create Context. Exports an action object to create a context via Browserbase API.
components/browserbase/actions/create-session/create-session.mjs New action: Create Session. Exports an action object to create a session with various options.
components/browserbase/actions/list-projects/list-projects.mjs New action: List Projects. Exports an action object to list all projects.
components/browserbase/browserbase.app.mjs Adds axios import, propDefinitions (dynamic projectId), and API methods: listProjects, listSessions, createSession, createContext. Removes placeholder method.
components/browserbase/common/constants.mjs New module: Exports REGION_OPTIONS and STATUS_OPTIONS arrays for use in UI and logic.
components/browserbase/common/utils.mjs New utility: Exports parseObject function for parsing JSON input flexibly.
components/browserbase/package.json Updates version to 0.1.0 and adds @pipedream/platform dependency.
components/browserbase/sources/common/base.mjs New base module: Provides polling and event emission logic for sources.
components/browserbase/sources/new-session/new-session.mjs New source: Emits events for new sessions, with status and query filtering. Uses base polling logic.
components/browserbase/sources/new-session/test-event.mjs New test event fixture: Exports a sample session event object.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Action
    participant BrowserbaseApp
    participant BrowserbaseAPI

    User->>Action: Trigger (e.g., Create Session)
    Action->>BrowserbaseApp: Call createSession()
    BrowserbaseApp->>BrowserbaseAPI: POST /sessions with params
    BrowserbaseAPI-->>BrowserbaseApp: Response (session data)
    BrowserbaseApp-->>Action: Return session data
    Action-->>User: Output summary and session data
Loading
sequenceDiagram
    participant Source (New Session)
    participant Base Poller
    participant BrowserbaseApp
    participant BrowserbaseAPI

    loop Polling Interval
        Source->>Base Poller: run()
        Base Poller->>BrowserbaseApp: listSessions(params)
        BrowserbaseApp->>BrowserbaseAPI: GET /sessions
        BrowserbaseAPI-->>BrowserbaseApp: List of sessions
        BrowserbaseApp-->>Base Poller: Return sessions
        Base Poller->>Source: Emit new session events
    end
Loading

Assessment against linked issues

Objective Addressed Explanation
Implement action: create-session (required: projectId; optional: extensionId, browserSettings, timeout, keepAlive, proxies, region, userMetadata) [#15425]
Implement action: create-context (required: projectId) [#15425]
Implement action: list-projects (no props required) [#15425]
Implement polling source: new-session (emit event on new session) [#15425]
Implement supporting modules/utilities/constants for Browserbase integration [#15425]

Poem

(\(\
( -.-)
o_(")(")

A browser hops, a session starts,
New contexts bloom in code’s fine arts.
Projects listed, regions set,
Polling sources never fret.
With every hop, new features grow—
Browserbase, onward we go!

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

components/browserbase/actions/create-session/create-session.mjs

Oops! Something went wrong! :(

ESLint: 8.57.1

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
at Object.getPackageJSONURL (node:internal/modules/package_json_reader:255:9)
at packageResolve (node:internal/modules/esm/resolve:767:81)
at moduleResolve (node:internal/modules/esm/resolve:853:18)
at defaultResolve (node:internal/modules/esm/resolve:983:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:799:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:723:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:706:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:307:38)
at #link (node:internal/modules/esm/module_job:163:49)

components/browserbase/actions/list-projects/list-projects.mjs

Oops! Something went wrong! :(

ESLint: 8.57.1

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
at Object.getPackageJSONURL (node:internal/modules/package_json_reader:255:9)
at packageResolve (node:internal/modules/esm/resolve:767:81)
at moduleResolve (node:internal/modules/esm/resolve:853:18)
at defaultResolve (node:internal/modules/esm/resolve:983:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:799:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:723:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:706:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:307:38)
at #link (node:internal/modules/esm/module_job:163:49)

components/browserbase/browserbase.app.mjs

Oops! Something went wrong! :(

ESLint: 8.57.1

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
at Object.getPackageJSONURL (node:internal/modules/package_json_reader:255:9)
at packageResolve (node:internal/modules/esm/resolve:767:81)
at moduleResolve (node:internal/modules/esm/resolve:853:18)
at defaultResolve (node:internal/modules/esm/resolve:983:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:799:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:723:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:706:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:307:38)
at #link (node:internal/modules/esm/module_job:163:49)

  • 6 others

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@luancazarine luancazarine marked this pull request as ready for review May 19, 2025 21:36
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (8)
components/browserbase/common/utils.mjs (1)

1-24: Flexible object parsing utility.

The parseObject function provides a useful way to handle various input formats, particularly for converting JSON strings to objects or arrays. It gracefully handles edge cases and different input types.

Consider adding a JSDoc comment above the function to document its purpose and parameters:

+/**
+ * Attempts to parse JSON strings within the input
+ * @param {any} obj - The object to parse
+ * @returns {any} The parsed object or the original input if parsing fails
+ */
export const parseObject = (obj) => {
components/browserbase/actions/create-session/create-session.mjs (2)

5-64: Well-structured action definition with comprehensive props.

The action is well-defined with clear props that include descriptive labels and documentation links. The constraints on the timeout property (min: 60, max: 21600) are appropriate for limiting session duration.

Consider adding validation for complex objects like browserSettings and proxies to ensure they meet the API requirements before submission.


65-82: Effective implementation of the run method.

The run method correctly uses the app's createSession method and applies the parseObject utility for complex input properties. The summary export provides good feedback to the user.

Consider adding error handling to provide more specific feedback when the API call fails:

async run({ $ }) {
  try {
    const response = await this.browserbase.createSession({
      $,
      data: {
        projectId: this.projectId,
        extensionId: this.extensionId,
        browserSettings: parseObject(this.browserSettings),
        timeout: this.timeout,
        keepAlive: this.keepAlive,
        proxies: parseObject(this.proxies),
        region: this.region,
        userMetadata: parseObject(this.userMetadata),
      },
    });

    $.export("$summary", `Session created successfully with ID: ${response.id}`);
    return response;
+  } catch (error) {
+    $.export("$summary", `Failed to create session: ${error.message}`);
+    throw error;
+  }
},
components/browserbase/browserbase.app.mjs (2)

21-38: Consider improving URL path handling in the request method

The URL construction in _makeRequest uses string concatenation which could lead to path issues if the path doesn't start with a forward slash.

Consider using a more robust approach to URL joining:

    _makeRequest({
      $ = this, path, ...opts
    }) {
      return axios($, {
-        url: this._baseUrl() + path,
+        url: `${this._baseUrl()}${path.startsWith('/') ? path : `/${path}`}`,
        headers: this._headers(),
        ...opts,
      });
    },

39-64: Consider adding error handling to API methods

The API methods are well-structured and consistent, but they lack specific error handling which could improve the developer experience when troubleshooting issues.

Consider adding try-catch blocks to provide more specific error messages:

    listProjects(opts = {}) {
+     try {
        return this._makeRequest({
          path: "/projects",
          ...opts,
        });
+     } catch (error) {
+       throw new Error(`Failed to list projects: ${error.message}`);
+     }
    },

This pattern could be applied to all API methods to provide more context when errors occur.

components/browserbase/sources/new-session/test-event.mjs (1)

1-17: Consider using more realistic test data for IDs

The test event provides a good structure for session events, but some fields use placeholder values that might not accurately represent real data.

Consider replacing placeholder values with more realistic test data:

export default {
-    "id": "<string>",
+    "id": "sess_1a2b3c4d5e6f7g8h9i0j",
    "createdAt": "2023-11-07T05:31:56Z",
    "updatedAt": "2023-11-07T05:31:56Z",
-    "projectId": "<string>",
+    "projectId": "proj_9i8h7g6f5e4d3c2b1a0",
    "startedAt": "2023-11-07T05:31:56Z",
    "endedAt": "2023-11-07T05:31:56Z",
    "expiresAt": "2023-11-07T05:31:56Z",
    "status": "RUNNING",
    "proxyBytes": 123,
    "avgCpuUsage": 123,
    "memoryUsage": 123,
    "keepAlive": true,
-    "contextId": "<string>",
+    "contextId": "ctx_5e4d3c2b1a0z9y8x7w6v",
    "region": "us-west-2",
-    "userMetadata": {}
+    "userMetadata": { "purpose": "test", "environment": "development" }
  }
components/browserbase/sources/common/base.mjs (1)

16-24: Consider adding JSDoc comments for better developer experience.

The state management methods are correctly implemented, but adding JSDoc comments would help clarify their purpose and usage for other developers.

components/browserbase/sources/new-session/new-session.mjs (1)

29-43: Improve parameter handling and error resilience in methods.

The implementation could be more robust with better empty value handling and validation.

  methods: {
    ...common.methods,
    getFunction() {
      return this.browserbase.listSessions;
    },
    getParams() {
      return {
        status: this.status,
-       q: this.q || null,
+       q: this.q || undefined, // Using undefined allows API to ignore the parameter completely
      };
    },
    getSummary(item) {
-     return `New session: ${item.id}`;
+     return `New session: ${item.id || "Unknown"}`;
    },
  },
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 6144407 and 26065e9.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (10)
  • components/browserbase/actions/create-context/create-context.mjs (1 hunks)
  • components/browserbase/actions/create-session/create-session.mjs (1 hunks)
  • components/browserbase/actions/list-projects/list-projects.mjs (1 hunks)
  • components/browserbase/browserbase.app.mjs (1 hunks)
  • components/browserbase/common/constants.mjs (1 hunks)
  • components/browserbase/common/utils.mjs (1 hunks)
  • components/browserbase/package.json (2 hunks)
  • components/browserbase/sources/common/base.mjs (1 hunks)
  • components/browserbase/sources/new-session/new-session.mjs (1 hunks)
  • components/browserbase/sources/new-session/test-event.mjs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Verify TypeScript components
  • GitHub Check: pnpm publish
  • GitHub Check: Publish TypeScript components
🔇 Additional comments (12)
components/browserbase/common/constants.mjs (2)

1-18: Clean implementation of region constants.

The REGION_OPTIONS array is well-structured with clear label-value pairs for cloud regions. This organization will enable consistent region selection across the Browserbase integration components.


20-25: Well-defined status options.

The STATUS_OPTIONS array provides a comprehensive list of session statuses that will be useful for filtering and displaying session state information throughout the integration.

components/browserbase/package.json (2)

3-3: Version bump follows semantic versioning.

Increasing the version from 0.0.1 to 0.1.0 is appropriate for this feature addition.


14-17: Appropriate dependency addition.

Adding the @pipedream/platform dependency is necessary for API communication features in the new components.

components/browserbase/actions/create-session/create-session.mjs (1)

1-4: Good import organization.

The imports are well-structured, bringing in the necessary dependencies from the app module and common utilities.

components/browserbase/actions/list-projects/list-projects.mjs (1)

3-19: Well-structured action with clean implementation

The code follows the typical Pipedream action pattern with clear naming, proper documentation references, and effective result handling. The action imports the Browserbase app module, uses it to list projects, and exports a useful summary for the user.

components/browserbase/actions/create-context/create-context.mjs (1)

3-30: Well-implemented action with proper prop definitions

The action is well structured with clear naming, documentation references, and appropriate use of the project ID prop definition from the Browserbase app. The run method correctly passes the project ID to the API call and provides a helpful success summary.

components/browserbase/browserbase.app.mjs (1)

6-19: Well-designed prop definition with dynamic options

The projectId prop definition is well implemented with appropriate type, label, and description. The async options method provides a good user experience by dynamically fetching available projects and formatting them for display.

components/browserbase/sources/common/base.mjs (2)

1-14: LGTM! Good implementation of the base polling structure.

The props structure follows Pipedream conventions with appropriate use of the timer interface and DB service.


53-60: LGTM! Appropriate lifecycle hooks implementation.

The deploy and run methods effectively utilize the emitEvent method with appropriate parameters.

components/browserbase/sources/new-session/new-session.mjs (2)

1-28: LGTM! Clear component definition with good documentation.

The component is properly structured with appropriate metadata, version, and property definitions. The documentation links are helpful.


44-45: LGTM! Good inclusion of sample data for testing.

Including a sample emit helps with testing and documentation.

Copy link
Collaborator

@michelle0927 michelle0927 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@luancazarine luancazarine merged commit 375489e into master May 20, 2025
11 checks passed
@luancazarine luancazarine deleted the issue-15425 branch May 20, 2025 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ai-assisted Content generated by AI, with human refinement and modification
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Components] browserbase
2 participants