feat: Enhance Solana tools with action-based architecture

- Introduced action system for Solana tools, allowing for better modularity and maintainability.
- Updated SolanaBalanceTool, SolanaTransferTool, SolanaDeployTokenTool, SolanaDeployCollectionTool, SolanaMintNFTTool, SolanaTradeTool, and SolanaRequestFundsTool to utilize action handlers.
- Added new action exports in index.ts for better organization and accessibility.
This commit is contained in:
Fahri Bilici
2024-12-26 21:54:55 +01:00
parent 8d299244fc
commit 79cada2cbd
13 changed files with 825 additions and 165 deletions

53
src/types/action.ts Normal file
View File

@@ -0,0 +1,53 @@
import { SolanaAgentKit } from "../agent";
import { z } from "zod";
/**
* Example of an action with input and output
*/
export interface ActionExample {
input: Record<string, any>;
output: Record<string, any>;
explanation: string;
}
/**
* Handler function type for executing the action
*/
export type Handler = (agent: SolanaAgentKit, input: Record<string, any>) => Promise<Record<string, any>>;
/**
* Main Action interface inspired by ELIZA
* This interface makes it easier to implement actions across different frameworks
*/
export interface Action {
/**
* Unique name of the action
*/
name: string;
/**
* Alternative names/phrases that can trigger this action
*/
similes: string[];
/**
* Detailed description of what the action does
*/
description: string;
/**
* Array of example inputs and outputs for the action
* Each inner array represents a group of related examples
*/
examples: ActionExample[][];
/**
* Zod schema for input validation
*/
schema: z.ZodType<any>;
/**
* Function that executes the action
*/
handler: Handler;
}