diff --git a/.env.example b/.env.example index b7cd764f588..2c118655286 100644 --- a/.env.example +++ b/.env.example @@ -368,9 +368,9 @@ COINBASE_GENERATED_WALLET_HEX_SEED= # Not your address but the wallet hex seed f COINBASE_NOTIFICATION_URI= # For webhook plugin the uri you want to send the webhook to for dummy ones use https://webhook.site # Coinbase AgentKit -COINBASE_AGENT_KIT_NETWORK= # defaults to 'base-sepolia' CDP_API_KEY_NAME= CDP_API_KEY_PRIVATE_KEY= +CDP_AGENT_KIT_NETWORK=base-sepolia # Optional: Defaults to base-sepolia # Coinbase Charity Configuration IS_CHARITABLE=false # Set to true to enable charity donations diff --git a/agent/src/index.ts b/agent/src/index.ts index d5813f0a67d..d839bae518d 100644 --- a/agent/src/index.ts +++ b/agent/src/index.ts @@ -12,6 +12,7 @@ import { TelegramClientInterface } from "@elizaos/client-telegram"; import { TwitterClientInterface } from "@elizaos/client-twitter"; import { FarcasterClientInterface } from "@elizaos/client-farcaster"; import { DirectClient } from "@elizaos/client-direct"; +import { agentKitPlugin } from "@elizaos/plugin-agentkit"; // import { ReclaimAdapter } from "@elizaos/plugin-reclaim"; import { PrimusAdapter } from "@elizaos/plugin-primus"; import { elizaCodeinPlugin, onchainJson } from "@elizaos/plugin-iq6900"; @@ -250,7 +251,6 @@ export async function loadCharacterFromOnchain(): Promise { } } - async function loadCharactersFromUrl(url: string): Promise { try { const response = await fetch(url); @@ -869,6 +869,10 @@ export async function createAgent( ? elizaCodeinPlugin : null, bootstrapPlugin, + getSecret(character, "CDP_API_KEY_NAME") && + getSecret(character, "CDP_API_KEY_PRIVATE_KEY") + ? agentKitPlugin + : null, getSecret(character, "DEXSCREENER_API_KEY") ? dexScreenerPlugin : null, diff --git a/packages/plugin-agentkit/README.md b/packages/plugin-agentkit/README.md index dfd2499a9dc..f5a2580832c 100644 --- a/packages/plugin-agentkit/README.md +++ b/packages/plugin-agentkit/README.md @@ -15,18 +15,18 @@ pnpm install ```env CDP_API_KEY_NAME=your_key_name CDP_API_KEY_PRIVATE_KEY=your_private_key +CDP_AGENT_KIT_NETWORK=base-sepolia # Optional: Defaults to base-sepolia ``` 3. Add the plugin to your character configuration: ```json { - "plugins": ["@ai16z/plugin-agentkit"], + "plugins": ["@elizaos/plugin-agentkit"], "settings": { "secrets": { "CDP_API_KEY_NAME": "your_key_name", - "CDP_API_KEY_PRIVATE_KEY": "your_private_key", - "networkId": "base-sepolia" + "CDP_API_KEY_PRIVATE_KEY": "your_private_key" } } } @@ -36,18 +36,18 @@ CDP_API_KEY_PRIVATE_KEY=your_private_key The plugin provides access to the following CDP AgentKit tools: -- `GET_WALLET_DETAILS`: Get wallet information -- `DEPLOY_NFT`: Deploy a new NFT collection -- `DEPLOY_TOKEN`: Deploy a new token -- `GET_BALANCE`: Check token or NFT balance -- `MINT_NFT`: Mint NFTs from a collection -- `REGISTER_BASENAME`: Register a basename for NFTs -- `REQUEST_FAUCET_FUNDS`: Request testnet funds -- `TRADE`: Execute trades -- `TRANSFER`: Transfer tokens or NFTs -- `WOW_BUY_TOKEN`: Buy WOW tokens -- `WOW_SELL_TOKEN`: Sell WOW tokens -- `WOW_CREATE_TOKEN`: Create new WOW tokens +- `GET_WALLET_DETAILS`: Get wallet information +- `DEPLOY_NFT`: Deploy a new NFT collection +- `DEPLOY_TOKEN`: Deploy a new token +- `GET_BALANCE`: Check token or NFT balance +- `MINT_NFT`: Mint NFTs from a collection +- `REGISTER_BASENAME`: Register a basename for NFTs +- `REQUEST_FAUCET_FUNDS`: Request testnet funds +- `TRADE`: Execute trades +- `TRANSFER`: Transfer tokens or NFTs +- `WOW_BUY_TOKEN`: Buy WOW tokens +- `WOW_SELL_TOKEN`: Sell WOW tokens +- `WOW_CREATE_TOKEN`: Create new WOW tokens ## Usage Examples @@ -91,19 +91,19 @@ pnpm dev ## Dependencies -- @elizaos/core -- @coinbase/cdp-agentkit-core -- @coinbase/cdp-langchain -- @langchain/core +- @elizaos/core +- @coinbase/cdp-agentkit-core +- @coinbase/cdp-langchain +- @langchain/core ## Network Support -The plugin currently supports the following networks: +The plugin supports the following networks: -- Base Sepolia (default) -- Base Mainnet +- Base Sepolia (default) +- Base Mainnet -Configure the network using the `networkId` setting in your character configuration. +Configure the network using the `CDP_AGENT_KIT_NETWORK` environment variable. ## Troubleshooting diff --git a/packages/plugin-agentkit/src/actions.ts b/packages/plugin-agentkit/src/actions.ts index 5c36b26c0bc..7bf3827c51c 100644 --- a/packages/plugin-agentkit/src/actions.ts +++ b/packages/plugin-agentkit/src/actions.ts @@ -44,8 +44,9 @@ export async function getAgentKitActions({ const client = await getClient(); let currentState = state ?? (await runtime.composeState(message)); - currentState = - await runtime.updateRecentMessageState(currentState); + currentState = await runtime.updateRecentMessageState( + currentState + ); const parameterContext = composeParameterContext( tool, diff --git a/packages/plugin-agentkit/src/index.ts b/packages/plugin-agentkit/src/index.ts index 3901617b32b..878a28cd130 100644 --- a/packages/plugin-agentkit/src/index.ts +++ b/packages/plugin-agentkit/src/index.ts @@ -2,6 +2,14 @@ import type { Plugin } from "@elizaos/core"; import { walletProvider, getClient } from "./provider"; import { getAgentKitActions } from "./actions"; +// Initial banner +console.log("\n┌════════════════════════════════════════┐"); +console.log("│ AGENTKIT PLUGIN │"); +console.log("├────────────────────────────────────────┤"); +console.log("│ Initializing AgentKit Plugin... │"); +console.log("│ Version: 0.0.1 │"); +console.log("└════════════════════════════════════════┘"); + export const agentKitPlugin: Plugin = { name: "[AgentKit] Integration", description: "AgentKit integration plugin", diff --git a/packages/plugin-agentkit/src/provider.ts b/packages/plugin-agentkit/src/provider.ts index b8f03cd677a..fd2c708bba1 100644 --- a/packages/plugin-agentkit/src/provider.ts +++ b/packages/plugin-agentkit/src/provider.ts @@ -4,9 +4,7 @@ import * as fs from "fs"; const WALLET_DATA_FILE = "wallet_data.txt"; -export async function getClient( - networkId = "base-sepolia" -): Promise { +export async function getClient(): Promise { let walletDataStr: string | null = null; // Read existing wallet data if available @@ -22,7 +20,7 @@ export async function getClient( // Configure CDP AgentKit const config = { cdpWalletData: walletDataStr || undefined, - networkId, + networkId: process.env.CDP_AGENT_KIT_NETWORK || "base-sepolia", }; const agentkit = await CdpAgentkit.configureWithWallet(config); @@ -36,9 +34,7 @@ export async function getClient( export const walletProvider: Provider = { async get(runtime: IAgentRuntime): Promise { try { - const client = await getClient( - runtime.getSetting("COINBASE_AGENT_KIT_NETWORK") - ); + const client = await getClient(); const address = (await (client as any).wallet.addresses)[0].id; return `AgentKit Wallet Address: ${address}`; } catch (error) {