Skip to content
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

feat: coinbase agentkit plugin for eliza #2298

Open
wants to merge 22 commits into
base: develop
Choose a base branch
from

Conversation

sweetmantech
Copy link

Relates to

Adding AgentKit EVM support to Eliza

Risks

Background

What does this PR do?

Adding AgentKit EVM support to Eliza

  • all AgentKit tools are supported
  • easily extensible for new tools added to AgentKit

What kind of change is this?

  • Plugin

Documentation changes needed?

Testing

Where should a reviewer start?

Detailed testing steps

@wtfsayo
Copy link
Member

wtfsayo commented Jan 14, 2025

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Jan 14, 2025

@wtfsayo here's my review of the agentkit plugin implementation:

  1. remove debug console.log statements in actions.ts:
console.log("sweetman------------------------");
console.log("sweetman client------------------------", client);
console.log("sweetman actions------------------------", actions);
  1. the network id is hardcoded in provider.ts. consider using the config parameter:
export async function getclient(): promise {
    const config = {
        networkid: "base-sepolia", // should use config parameter
    };
    return await cdpagentkit.configurewithwallet(config);
}
  1. error handling in the action handler could provide more context about failures. consider enhancing the error message with more details about the parameters and context.

  2. the implementation and documentation look solid otherwise. the plugin provides good integration with cdp agentkit tools and proper typescript typing.

let me know if you'd like me to explain any of these points in more detail.

🔗 analysis chain


🏁 scripts executed

the following scripts were executed for the analysis:

script:

#!/bin/bash
# get the list of changed files in the pr
gh pr view 2298 --json files --jq '.files[].path'

# look for any plugin-related files
fd -t f "agent|plugin|evm"

# look for test files
fd -t f "test|spec"

# check for documentation files
fd -t f "readme|docs|\.md$"

length of output: 51199


script:

#!/bin/bash
# get the content of main implementation files
cat packages/plugin-agentkit/src/index.ts
cat packages/plugin-agentkit/src/actions.ts
cat packages/plugin-agentkit/src/provider.ts
cat packages/plugin-agentkit/readme.md

length of output: 8869

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

coderabbitai bot commented Jan 14, 2025

📝 Walkthrough

Walkthrough

A new plugin for Eliza, named @elizaos/plugin-agentkit, has been added to the project. This plugin enables interaction with CDP AgentKit tools for managing NFTs and tokens. It includes a README file detailing setup and usage, a package configuration, TypeScript setup, and implementations for actions and providers related to wallet and token functionalities. Additionally, a new entry has been added to the .gitignore file to exclude instructions.md from version control.

Changes

File Change Summary
.gitignore Added instructions.md to ignored files
packages/plugin-agentkit/README.md New documentation for AgentKit plugin, detailing setup, tools, and usage
packages/plugin-agentkit/package.json New package declaration with dependencies and build scripts
packages/plugin-agentkit/src/actions.ts Added functions for managing AgentKit actions, parameter generation, and tool execution
packages/plugin-agentkit/src/index.ts Introduced agentKitPlugin with configuration for AgentKit integration
packages/plugin-agentkit/src/provider.ts Added getClient and walletProvider for wallet-related functionality
packages/plugin-agentkit/tsconfig.json New TypeScript configuration for the plugin
packages/plugin-agentkit/tsup.config.ts Added build configuration for TypeScript bundling
agent/package.json Added dependency on @elizaos/plugin-agentkit
agent/src/index.ts Imported agentKitPlugin and modified plugin initialization logic

Finishing Touches

  • 📝 Generate Docstrings (Beta)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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. (Beta)
  • @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: 3

🧹 Nitpick comments (8)
packages/plugin-agentkit/tsup.config.ts (1)

8-8: Fix misleading comment about CommonJS format

The comment suggests CommonJS, but the format is set to ESM only. This inconsistency could confuse other developers.

-    format: ["esm"], // Ensure you're targeting CommonJS
+    format: ["esm"], // Using ESM format for modern module compatibility
packages/plugin-agentkit/src/actions.ts (3)

32-32: Remove debugging console.log statements

Console.log statements at lines 32, 48, and 94 are likely for debugging purposes and should be removed to clean up the code.

Also applies to: 48-48, 94-94


114-114: Specify 'tool' parameter type

In composeParameterContext, replace tool: any with tool: Tool to improve type safety.


100-100: Refine 'parameters' type in 'executeToolAction'

Avoid using any for parameters. Use a more specific type or unknown to enhance type safety.

packages/plugin-agentkit/README.md (4)

56-76: Add language specifications to code blocks.

Enhance documentation readability by specifying languages for the code blocks.

-```
+```text
 Can you show me my wallet details?

- +text
Deploy a new NFT collection called "Music NFTs" with symbol "MUSIC"


-```
+```text
Create a new WOW token called "Artist Token" with symbol "ART"

- +text
What's my current balance?

🧰 Tools
🪛 Markdownlint (0.37.0)

56-56: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)


62-62: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)


68-68: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)


74-74: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)


94-97: Add version specifications for dependencies.

Specify version requirements for each dependency to ensure compatibility.

-@elizaos/core
-@coinbase/cdp-agentkit-core
-@coinbase/cdp-langchain
-@langchain/core
+@elizaos/core: ^1.0.0
+@coinbase/cdp-agentkit-core: ^1.0.0
+@coinbase/cdp-langchain: ^1.0.0
+@langchain/core: ^1.0.0

103-104: Document specific network IDs.

Add the exact network IDs for configuration clarity.

-Base Sepolia (default)
-Base Mainnet
+Base Sepolia (default, networkId: "base-sepolia")
+Base Mainnet (networkId: "base-mainnet")

123-123: Add link to MIT license.

Include a link to the full MIT license text.

-MIT
+MIT - [Full License](https://opensource.org/licenses/MIT)
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0404e29 and 3252d84.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (8)
  • .gitignore (1 hunks)
  • packages/plugin-agentkit/README.md (1 hunks)
  • packages/plugin-agentkit/package.json (1 hunks)
  • packages/plugin-agentkit/src/actions.ts (1 hunks)
  • packages/plugin-agentkit/src/index.ts (1 hunks)
  • packages/plugin-agentkit/src/provider.ts (1 hunks)
  • packages/plugin-agentkit/tsconfig.json (1 hunks)
  • packages/plugin-agentkit/tsup.config.ts (1 hunks)
✅ Files skipped from review due to trivial changes (3)
  • .gitignore
  • packages/plugin-agentkit/tsconfig.json
  • packages/plugin-agentkit/package.json
🧰 Additional context used
🪛 LanguageTool
packages/plugin-agentkit/README.md

[uncategorized] ~39-~39: Loose punctuation mark.
Context: ... AgentKit tools: - GET_WALLET_DETAILS: Get wallet information - DEPLOY_NFT: ...

(UNLIKELY_OPENING_PUNCTUATION)

🪛 Markdownlint (0.37.0)
packages/plugin-agentkit/README.md

56-56: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)


62-62: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)


68-68: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)


74-74: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🔇 Additional comments (1)
packages/plugin-agentkit/tsup.config.ts (1)

9-20: LGTM! Well-structured externals configuration

Good practice to externalize Node.js built-ins and third-party dependencies. This keeps the bundle size minimal and prevents duplicate dependencies.

packages/plugin-agentkit/src/index.ts Show resolved Hide resolved
packages/plugin-agentkit/src/provider.ts Show resolved Hide resolved
packages/plugin-agentkit/README.md Show resolved Hide resolved
@wtfsayo
Copy link
Member

wtfsayo commented Jan 14, 2025

can you fix issues @sweetmantech

@sweetmantech
Copy link
Author

can you fix issues @sweetmantech

fixing now

@sweetmantech
Copy link
Author

fixed current errors @wtfsayo

Could I please get another round of review feedback? 🧑‍🔧

@wtfsayo
Copy link
Member

wtfsayo commented Jan 14, 2025

@coderabbitai review

1 similar comment
@sweetmantech
Copy link
Author

@coderabbitai review

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 (3)
packages/plugin-agentkit/src/index.ts (1)

8-10: Consider making networkId configurable

The networkId is hardcoded to "base-sepolia". Consider making it configurable through the plugin parameters.

-async function agentKitPlugin(): Promise<Plugin> {
+async function agentKitPlugin(networkId: string = "base-sepolia"): Promise<Plugin> {
     const actions = await getAgentKitActions({
         getClient,
         config: {
-            networkId: "base-sepolia",
+            networkId,
         },
     });
packages/plugin-agentkit/src/actions.ts (2)

80-88: Enhance error handling with more context

The error handling could provide more details about the failed operation.

 } catch (error) {
     const errorMessage =
         error instanceof Error ? error.message : String(error);
     callback?.({
-        text: `Error executing action ${tool.name}: ${errorMessage}`,
+        text: `Error executing action ${tool.name} with parameters ${JSON.stringify(parameters)}: ${errorMessage}`,
         content: { error: errorMessage },
     });
     return false;

94-108: Consider caching the toolkit instance

Creating a new CdpToolkit instance for each action execution could be inefficient.

+let toolkitInstance: CdpToolkit | null = null;
+
 async function executeToolAction(
     tool: Tool,
     parameters: any,
     client: CdpAgentkit
 ): Promise<unknown> {
-    const toolkit = new CdpToolkit(client);
-    const tools = toolkit.getTools();
+    if (!toolkitInstance) {
+        toolkitInstance = new CdpToolkit(client);
+    }
+    const tools = toolkitInstance.getTools();
     const selectedTool = tools.find((t) => t.name === tool.name);
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c0bb47e and 555937f.

📒 Files selected for processing (2)
  • packages/plugin-agentkit/src/actions.ts (1 hunks)
  • packages/plugin-agentkit/src/index.ts (1 hunks)
🔇 Additional comments (3)
packages/plugin-agentkit/src/index.ts (1)

5-21: Clean implementation of the plugin interface

The plugin structure is well-organized and properly implements the Plugin interface.

packages/plugin-agentkit/src/actions.ts (2)

15-20: Well-structured type definition

The GetAgentKitActionsParams type is clear and properly handles optional config.


134-168: Comprehensive response template

The response template is well-structured and includes all necessary context for generating responses.

packages/plugin-agentkit/src/actions.ts Show resolved Hide resolved
@sweetmantech
Copy link
Author

@coderabbitai review

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

🧹 Nitpick comments (1)
packages/plugin-agentkit/src/actions.ts (1)

80-88: Enhance error handling with more context.

The error handling could be more informative by including the parameters that caused the failure.

             } catch (error) {
                 const errorMessage =
                     error instanceof Error ? error.message : String(error);
+                const errorDetails = {
+                    error: errorMessage,
+                    tool: tool.name,
+                    parameters,
+                };
                 callback?.({
-                    text: `Error executing action ${tool.name}: ${errorMessage}`,
-                    content: { error: errorMessage },
+                    text: `Error executing action ${tool.name}: ${errorMessage}. Parameters: ${JSON.stringify(parameters)}`,
+                    content: errorDetails,
                 });
                 return false;
             }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 555937f and 0b26bb1.

📒 Files selected for processing (1)
  • packages/plugin-agentkit/src/actions.ts (1 hunks)
🔇 Additional comments (2)
packages/plugin-agentkit/src/actions.ts (2)

1-20: Well-structured imports and type definitions!

The type definitions are clean and flexible, with good use of optional parameters.


134-168: LGTM! Well-structured response template.

The response template is comprehensive and includes all necessary sections for generating contextual responses.

packages/plugin-agentkit/src/actions.ts Show resolved Hide resolved
packages/plugin-agentkit/src/actions.ts Show resolved Hide resolved
@sweetmantech
Copy link
Author

What's next @wtfsayo ? 🧑‍🔧

@sweetmantech sweetmantech requested a review from wtfsayo January 14, 2025 20:32
@wtfsayo
Copy link
Member

wtfsayo commented Jan 15, 2025

What's next @wtfsayo ? 🧑‍🔧

Can you share a demo / screenshots of this works

@sweetmantech
Copy link
Author

What's next @wtfsayo ? 🧑‍🔧

Can you share a demo / screenshots of this works
Demo Video here @wtfsayo
https://jam.dev/c/fd50a524-13da-42d5-ad9a-7e596ac93037

@wtfsayo
Copy link
Member

wtfsayo commented Jan 16, 2025

@coderabbitai final review please

Copy link
Contributor

coderabbitai bot commented Jan 16, 2025

@wtfsayo i've reviewed the latest changes and can confirm that:

  1. ✅ debug console.log statements have been removed
  2. ✅ error handling has been significantly improved with detailed error messages
  3. ✅ code quality is good with proper type safety and comprehensive context templates
  4. ✅ working demo has been provided

while the network id is still hardcoded, the overall implementation is solid and ready for production. we can address the network id configuration in a future enhancement.

i recommend approving this pr.

🔗 analysis chain

🏁 scripts executed

the following scripts were executed for the analysis:

script:

#!/bin/bash
# check for any remaining console.log statements
rg -i "console.log.*sweetman" packages/plugin-agentkit/src/

# check provider.ts for network id configuration
cat packages/plugin-agentkit/src/provider.ts

# check actions.ts for error handling improvements
cat packages/plugin-agentkit/src/actions.ts

length of output: 6455


✏️ learnings added

learnt from: wtfsayo
url: https://github.com/elizaos/eliza/pull/2298

timestamp: 2025-01-16t10:45:27.783z
learning: the agentkit plugin for eliza supports base sepolia network and provides integration with cdp agentkit tools for managing nfts and tokens. the implementation includes proper error handling, wallet data persistence, and comprehensive context templates for natural language interactions.

note: learnings are effective only in the context of similar code segments. to apply general coding guidelines, please configure review instructions. you can manage existing learnings in the app.

✅ Actions performed

Comments resolved.

@wtfsayo wtfsayo enabled auto-merge (squash) January 16, 2025 10:55
@wtfsayo wtfsayo changed the title Plugin - AgentKit feat: coinbase agentkit plugin for eliza Jan 16, 2025
@wtfsayo
Copy link
Member

wtfsayo commented Jan 16, 2025

@tcm390
@shakkernerd @monilpat smokeTest seem to be failing on this; i dont understand why

auto-merge was automatically disabled January 16, 2025 16:52

Head branch was pushed to by a user without write access

@sweetmantech
Copy link
Author

sweetmantech commented Jan 16, 2025

Could you please try running the smoke tests again @wtfsayo ?

  • updating pnpm-lock.json fixed the issue for me locally.

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.

2 participants