Skip to content

Commit

Permalink
Merge pull request #3172 from AIFlowML/fix-plugin-agentkit
Browse files Browse the repository at this point in the history
fix: plugin-agentkit
  • Loading branch information
shakkernerd authored Feb 2, 2025
2 parents e16eea6 + a41081b commit 4a2cf37
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 7 deletions.
41 changes: 41 additions & 0 deletions packages/plugin-agentkit/biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"$schema": "https://biomejs.dev/schemas/1.5.3/schema.json",
"organizeImports": {
"enabled": false
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"correctness": {
"noUnusedVariables": "error"
},
"suspicious": {
"noExplicitAny": "error"
},
"style": {
"useConst": "error",
"useImportType": "off"
}
}
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 4,
"lineWidth": 100
},
"javascript": {
"formatter": {
"quoteStyle": "single",
"trailingCommas": "es5"
}
},
"files": {
"ignore": [
"dist/**/*",
"extra/**/*",
"node_modules/**/*"
]
}
}
7 changes: 6 additions & 1 deletion packages/plugin-agentkit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,18 @@
"tsup": "8.3.5"
},
"devDependencies": {
"@biomejs/biome": "1.9.4",
"vitest": "^1.0.0"
},
"scripts": {
"build": "tsup --format esm --dts",
"dev": "tsup --format esm --dts --watch",
"test": "vitest run",
"test:watch": "vitest watch",
"test:coverage": "vitest run --coverage"
"test:coverage": "vitest run --coverage",
"lint": "biome lint .",
"lint:fix": "biome check --apply .",
"format": "biome format .",
"format:fix": "biome format --write ."
}
}
6 changes: 3 additions & 3 deletions packages/plugin-agentkit/src/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export async function getAgentKitActions({
runtime: IAgentRuntime,
message: Memory,
state: State | undefined,
options?: Record<string, unknown>,
_options?: Record<string, unknown>,
callback?: HandlerCallback
): Promise<boolean> => {
try {
Expand Down Expand Up @@ -93,7 +93,7 @@ export async function getAgentKitActions({

async function executeToolAction(
tool: Tool,
parameters: any,
parameters: unknown,
client: CdpAgentkit
): Promise<unknown> {
const toolkit = new CdpToolkit(client);
Expand All @@ -107,7 +107,7 @@ async function executeToolAction(
return await selectedTool.call(parameters);
}

function composeParameterContext(tool: any, state: State): string {
function composeParameterContext(tool: Tool, state: State): string {
const contextTemplate = `{{recentMessages}}
Given the recent messages, extract the following information for the action "${tool.name}":
Expand Down
7 changes: 4 additions & 3 deletions packages/plugin-agentkit/src/provider.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Provider, IAgentRuntime } from "@elizaos/core";
import { CdpAgentkit } from "@coinbase/cdp-agentkit-core";
import * as fs from "fs";
import * as fs from "node:fs";

const WALLET_DATA_FILE = "wallet_data.txt";

Expand Down Expand Up @@ -46,10 +46,11 @@ export async function getClient(): Promise<CdpAgentkit> {
}

export const walletProvider: Provider = {
async get(runtime: IAgentRuntime): Promise<string | null> {
async get(_runtime: IAgentRuntime): Promise<string | null> {
try {
const client = await getClient();
const address = (await (client as any).wallet.addresses)[0].id;
// Access wallet addresses using type assertion based on the known structure
const address = (client as unknown as { wallet: { addresses: Array<{ id: string }> } }).wallet.addresses[0].id;
return `AgentKit Wallet Address: ${address}`;
} catch (error) {
console.error("Error in AgentKit provider:", error);
Expand Down

0 comments on commit 4a2cf37

Please # to comment.