Skip to content

Utopian Labs new components #16812

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

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

Utopian Labs new components #16812

wants to merge 11 commits into from

Conversation

GTFalcao
Copy link
Collaborator

@GTFalcao GTFalcao commented May 23, 2025

Closes #16726

Summary by CodeRabbit

  • New Features
    • Added actions to initiate and track various types of agent runs (Research, Qualification, Classification, Copywriting, Timing) in the Utopian Labs integration.
    • Introduced the ability to retrieve the status of previously initiated runs.
    • Provided support for specifying agent type, lead data, research step limits, context, language options, and additional customizable options.
    • Expanded language selection with a comprehensive list of language codes.
  • Chores
    • Updated package version and dependencies for improved compatibility and stability.

Copy link

vercel bot commented May 23, 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 23, 2025 0:52am
pipedream-docs ⬜️ Ignored (Inspect) May 23, 2025 0:52am
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) May 23, 2025 0:52am

Copy link
Contributor

coderabbitai bot commented May 23, 2025

"""

Walkthrough

A new Utopian Labs integration is introduced, including utility modules, constants, and multiple action modules for initiating and monitoring various agent runs (research, classification, copywriting, qualification, and timing). The app module is refactored to provide structured properties and encapsulated API client methods. Package metadata and dependencies are updated.

Changes

Files/Paths Change Summary
components/utopian_labs/actions/initiate-research-run/initiate-research-run.mjs
components/utopian_labs/actions/initiate-classification-run/initiate-classification-run.mjs
components/utopian_labs/actions/initiate-copywriting-run/initiate-copywriting-run.mjs
components/utopian_labs/actions/initiate-qualification-run/initiate-qualification-run.mjs
components/utopian_labs/actions/initiate-timing-run/initiate-timing-run.mjs
Added new action modules for initiating various Utopian Labs agent runs (research, classification, copywriting, qualification, timing), each defining input properties, parsing logic, and invoking the app's initiateRun method.
components/utopian_labs/actions/get-run-status/get-run-status.mjs Added a new action module for retrieving the status of an existing Utopian Labs run by run ID.
components/utopian_labs/common/constants.mjs Added a new constants module exporting a list of language code options.
components/utopian_labs/common/utils.mjs Added a new utilities module with JSON parsing helper functions and error handling.
components/utopian_labs/utopian_labs.app.mjs Refactored app module: added property definitions for agent run parameters, encapsulated UtopianLabs client instantiation, and added methods to initiate runs and get run status.
components/utopian_labs/package.json Updated package version and added dependencies for "utopianlabs" and "@pipedream/platform".

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ActionModule
    participant UtopianLabsApp
    participant UtopianLabsAPI

    User->>ActionModule: Provide input parameters
    ActionModule->>UtopianLabsApp: initiateRun(args)
    UtopianLabsApp->>UtopianLabsAPI: Create agent run (POST /agents/runs)
    UtopianLabsAPI-->>UtopianLabsApp: Return run details
    UtopianLabsApp-->>ActionModule: Return run details
    ActionModule-->>User: Return summary and run details

    User->>ActionModule: Provide run ID for status
    ActionModule->>UtopianLabsApp: getRunStatus(runId)
    UtopianLabsApp->>UtopianLabsAPI: Get run status (GET /agents/runs/{id})
    UtopianLabsAPI-->>UtopianLabsApp: Return status
    UtopianLabsApp-->>ActionModule: Return status
    ActionModule-->>User: Return summary and status
Loading

Assessment against linked issues

Objective Addressed Explanation
Add webhook sources: new-idea-submission-instant, new-comment-instant, new-project-follow-instant (#16726) No webhook sources are implemented in this PR.
Add actions: create-idea, post-comment, update-idea-status (#16726) These specific actions are not present in the current changes.

Suggested labels

action

Poem

A hop, a jump, a leap so grand,
New Utopian Labs actions now at hand!
With agents that run and statuses to track,
Utilities and constants have joined the pack.
The code now blooms, dependencies align—
A rabbit’s proud of this new design! 🐇✨
"""

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/utopian_labs/actions/initiate-classification-run/initiate-classification-run.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/utopian_labs/actions/initiate-qualification-run/initiate-qualification-run.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/utopian_labs/actions/initiate-copywriting-run/initiate-copywriting-run.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)

  • 2 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.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6579708 and 8465db4.

📒 Files selected for processing (5)
  • components/utopian_labs/actions/initiate-classification-run/initiate-classification-run.mjs (1 hunks)
  • components/utopian_labs/actions/initiate-copywriting-run/initiate-copywriting-run.mjs (1 hunks)
  • components/utopian_labs/actions/initiate-qualification-run/initiate-qualification-run.mjs (1 hunks)
  • components/utopian_labs/actions/initiate-research-run/initiate-research-run.mjs (1 hunks)
  • components/utopian_labs/actions/initiate-timing-run/initiate-timing-run.mjs (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • components/utopian_labs/actions/initiate-qualification-run/initiate-qualification-run.mjs
🚧 Files skipped from review as they are similar to previous changes (4)
  • components/utopian_labs/actions/initiate-copywriting-run/initiate-copywriting-run.mjs
  • components/utopian_labs/actions/initiate-research-run/initiate-research-run.mjs
  • components/utopian_labs/actions/initiate-timing-run/initiate-timing-run.mjs
  • components/utopian_labs/actions/initiate-classification-run/initiate-classification-run.mjs
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Publish TypeScript components
  • GitHub Check: Lint Code Base
  • GitHub Check: Verify TypeScript components
✨ 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.

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: 12

🧹 Nitpick comments (9)
components/utopian_labs/actions/get-run-status/get-run-status.mjs (1)

17-21: Consider adding explicit error handling

The implementation is clean and follows Pipedream's component model. However, consider adding explicit error handling for cases where the API call might fail, providing a more user-friendly error message.

  async run({ $ }) {
-    const response = await this.utopianLabs.getRunStatus(this.runId);
-    $.export("$summary", `Successfully retrieved status for run ${this.runId}`);
-    return response;
+    try {
+      const response = await this.utopianLabs.getRunStatus(this.runId);
+      $.export("$summary", `Successfully retrieved status for run ${this.runId}`);
+      return response;
+    } catch (error) {
+      $.export("$summary", `Failed to retrieve status for run ${this.runId}`);
+      throw error;
+    }
  },
components/utopian_labs/common/utils.mjs (2)

3-9: Add JSDoc comments to clarify function behavior

Consider adding JSDoc comments to explain what this function does, especially for edge cases. This will make the code more maintainable.

+/**
+ * Attempts to parse a value as JSON, returning the original value if parsing fails.
+ * 
+ * @param {any} value - The value to parse
+ * @returns {any} The parsed JSON object or the original value if parsing fails
+ */
function optionalParseAsJSON(value) {
  try {
    return JSON.parse(value);
  } catch (e) {
    return value;
  }
}

26-34: Improve type handling in parseStringAsJSON

parseStringAsJSON could be enhanced to handle non-string values more explicitly. Currently, if a non-string, non-object value is passed, it will simply return that value without validation.

export function parseStringAsJSON(value) {
  try {
-    return typeof value === "string"
-      ? JSON.parse(value)
-      : value;
+    if (typeof value === "string") {
+      return JSON.parse(value);
+    }
+    if (typeof value === "object" && value !== null) {
+      return value;
+    }
+    throw new ConfigurationError(`Expected a JSON string or object, got ${typeof value}`);
  } catch (err) {
    throw new ConfigurationError(`Error parsing JSON string: ${err}`);
  }
}
components/utopian_labs/actions/initiate-copywriting-run/initiate-copywriting-run.mjs (1)

41-41: Fix typo in language description

There's a typo in the language property description.

-  description: "The langauge to write the copy in (defaults to `en-US`)",
+  description: "The language to write the copy in (defaults to `en-US`)",
components/utopian_labs/utopian_labs.app.mjs (3)

43-47: Implement client caching for better performance

Creating a new client instance on every method call can be inefficient. Consider caching the client instance.

+ _clientInstance = null;
  _client() {
+   if (this._clientInstance) {
+     return this._clientInstance;
+   }
-   return new UtopianLabs({
+   this._clientInstance = new UtopianLabs({
      apiKey: this.$auth.api_key,
    });
+   return this._clientInstance;
  },

48-50: Add error handling to initiateRun method

The initiateRun method currently doesn't handle potential API errors. Consider adding error handling for a more robust implementation.

  initiateRun(args) {
-   return this._client().agents.runs.create(args);
+   try {
+     return this._client().agents.runs.create(args);
+   } catch (error) {
+     console.error("Error initiating run:", error);
+     throw new Error(`Failed to initiate run: ${error.message}`);
+   }
  },

51-55: Add error handling and input validation to getRunStatus method

The getRunStatus method could benefit from input validation and error handling.

  getRunStatus(run) {
+   if (!run) {
+     throw new Error("Run ID is required");
+   }
+   try {
      return this._client().agents.runs.get({
        run,
      });
+   } catch (error) {
+     console.error("Error getting run status:", error);
+     throw new Error(`Failed to get run status: ${error.message}`);
+   }
  },
components/utopian_labs/actions/initiate-classification-run/initiate-classification-run.mjs (2)

38-42: Consider adding validation for options array length

The description mentions that the options should have a minimum of 2 and maximum of 10 elements, but there's no validation in the code to enforce this constraint.

Consider adding validation in the run method to ensure the options array meets these requirements:

async run({ $ }) {
+  const parsedOptions = parseArrayAsJSON(this.options);
+  if (parsedOptions.length < 2 || parsedOptions.length > 10) {
+    throw new Error("Options must contain between 2 and 10 elements");
+  }
  
  const response = await this.utopianLabs.initiateRun({
    agent: this.agent,
    lead: parseStringAsJSON(this.lead),
-   options: parseArrayAsJSON(this.options),
+   options: parsedOptions,
    min_research_steps: this.minResearchSteps,
    max_research_steps: this.maxResearchSteps,
    context: this.context,
    ...parseObjectEntries(this.additionalOptions),
  });

69-78: Add error handling for the API call

The run method doesn't include error handling for the API call, which could lead to unhandled exceptions if the call fails.

Consider adding try-catch block to handle potential errors:

async run({ $ }) {
+  try {
    const response = await this.utopianLabs.initiateRun({
      agent: this.agent,
      lead: parseStringAsJSON(this.lead),
      options: parseArrayAsJSON(this.options),
      min_research_steps: this.minResearchSteps,
      max_research_steps: this.maxResearchSteps,
      context: this.context,
      ...parseObjectEntries(this.additionalOptions),
    });
    $.export("$summary", `Successfully initiated run (ID: ${response.id}`);
    return response;
+  } catch (error) {
+    $.export("$summary", `Failed to initiate run: ${error.message}`);
+    throw error;
+  }
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d91decd and 0cbf137.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (10)
  • components/utopian_labs/actions/get-run-status/get-run-status.mjs (1 hunks)
  • components/utopian_labs/actions/initiate-classification-run/initiate-classification-run.mjs (1 hunks)
  • components/utopian_labs/actions/initiate-copywriting-run/initiate-copywriting-run.mjs (1 hunks)
  • components/utopian_labs/actions/initiate-qualification-run/initiate-qualification-run.mjs (1 hunks)
  • components/utopian_labs/actions/initiate-research-run/initiate-research-run.mjs (1 hunks)
  • components/utopian_labs/actions/initiate-timing-run/initiate-timing-run.mjs (1 hunks)
  • components/utopian_labs/common/constants.mjs (1 hunks)
  • components/utopian_labs/common/utils.mjs (1 hunks)
  • components/utopian_labs/package.json (2 hunks)
  • components/utopian_labs/utopian_labs.app.mjs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: pnpm publish
  • GitHub Check: Verify TypeScript components
  • GitHub Check: Publish TypeScript components
  • GitHub Check: Lint Code Base
🔇 Additional comments (6)
components/utopian_labs/package.json (1)

3-18: LGTM! Dependencies and version update

The package version update and added dependencies look appropriate for the new Utopian Labs integration. The JSON structure is properly formatted with the dependencies section.

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

1-56:

✅ Verification successful

Verify API version compatibility

Ensure that the imported UtopianLabs client version is compatible with the methods being called. Consider adding version checking or documentation about compatible versions.


🏁 Script executed:

#!/bin/bash
# Check package.json for utopianlabs dependency version
grep -r "utopianlabs" --include="package.json" .

Length of output: 115


🏁 Script executed:

#!/bin/bash
set -e
# Download utopianlabs v0.1.11 and inspect for the methods used
npm pack [email protected]
tar -xzf utopianlabs-0.1.11.tgz
# Search for the agents.runs.create and agents.runs.get implementations
grep -R "agents\.runs\.create" -n package
grep -R "agents\.runs\.get"    -n package

Length of output: 2216


No Action Needed: API Version Compatibility Confirmed

The utopianlabs client at version ^0.1.11 provides both agents.runs.create and agents.runs.get methods (confirmed in the package’s README). No changes to your code are required.

components/utopian_labs/actions/initiate-classification-run/initiate-classification-run.mjs (4)

1-5: Imports look good

The imports are well-structured, separating utility functions for JSON parsing and the main app module.


7-12: Component metadata is well-defined

The component key, name, description, version, and type are properly defined with good documentation links.


13-68: Props structure is well-organized

The props are well-defined with appropriate references to propDefinitions from the app module. The descriptions provide clear guidance and include documentation links where needed.


80-82: Return statement looks good

The return statement properly returns the full response object from the API call.

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!

Just an FYI, sometimes I like to use a waitForCompletion prop for actions that start a job. Example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Components] utopian_labs
2 participants