fix: naming

This commit is contained in:
aryan
2025-01-01 03:37:56 +05:30
parent 18b719012b
commit e2f1536774
37 changed files with 121 additions and 67 deletions

View File

@@ -5,7 +5,7 @@ import { z } from "zod";
import { get_balance } from "../tools";
const balanceAction: Action = {
name: "solana_balance",
name: "BALANCE_ACTION",
similes: [
"check balance",
"get wallet balance",

View File

@@ -4,7 +4,7 @@ import { z } from "zod";
import { sendCompressedAirdrop } from "../tools";
const compressedAirdropAction: Action = {
name: "solana_compressed_airdrop",
name: "COMPRESSED_AIRDROP",
similes: [
"ZK Compressed airdrop",
"Airdrop tokens with compression",

View File

@@ -5,7 +5,7 @@ import { PublicKey } from "@solana/web3.js";
import { create_gibwork_task } from "../tools";
const createGibworkTaskAction: Action = {
name: "solana_create_gibwork_task",
name: "CREATE_GIBWORK_TASK",
similes: [
"create task",
"post job",

View File

@@ -4,7 +4,7 @@ import { z } from "zod";
import { create_image } from "../tools/create_image";
const createImageAction: Action = {
name: "solana_create_image",
name: "CREATE_IMAGE",
similes: [
"generate image",
"create artwork",

View File

@@ -5,7 +5,7 @@ import { PublicKey } from "@solana/web3.js";
import { openbookCreateMarket } from "../tools";
const createOpenbookMarketAction: Action = {
name: "solana_create_openbook_market",
name: "CREATE_OPENBOOK_MARKET",
similes: [
"create openbook market",
"setup trading market",

View File

@@ -20,7 +20,7 @@ const FEE_TIERS = {
} as const;
const createOrcaSingleSidedWhirlpoolAction: Action = {
name: "solana_create_orca_single_sided_whirlpool",
name: "CREATE_ORCA_SINGLE_SIDED_WHIRLPOOL",
similes: [
"create orca whirlpool",
"setup orca single sided pool",

View File

@@ -10,7 +10,7 @@ interface CollectionOptions {
}
const deployCollectionAction: Action = {
name: "solana_deploy_collection",
name: "DEPLOY_COLLECTION",
similes: [
"create collection",
"launch collection",

View File

@@ -4,7 +4,7 @@ import { z } from "zod";
import { deploy_token } from "../tools";
const deployTokenAction: Action = {
name: "deploy_token",
name: "DEPLOY_TOKEN",
similes: [
"create token",
"launch token",

View File

@@ -5,7 +5,7 @@ import { PublicKey } from "@solana/web3.js";
import { fetchPrice } from "../tools";
const fetchPriceAction: Action = {
name: "solana_fetch_price",
name: "FETCH_PRICE",
similes: [
"get token price",
"check price",

View File

@@ -4,7 +4,7 @@ import { z } from "zod";
import { getAllDomainsTLDs } from "../tools";
const getAllDomainsTLDsAction: Action = {
name: "solana_get_all_tlds",
name: "GET_ALL_TLDS",
similes: [
"list domain tlds",
"get domain extensions",

View File

@@ -4,7 +4,7 @@ import { z } from "zod";
import { getAllRegisteredAllDomains } from "../tools";
const getAllRegisteredAllDomainsAction: Action = {
name: "solana_get_all_registered_all_domains",
name: "GET_ALL_REGISTERED_ALL_DOMAINS",
similes: [
"list registered domains",
"get all domains",

View File

@@ -5,7 +5,7 @@ import { PublicKey } from "@solana/web3.js";
import { getMainAllDomainsDomain } from "../tools";
const getMainAllDomainsDomainAction: Action = {
name: "solana_get_main_domain",
name: "GET_MAIN_ALL_DOMAINS_DOMAIN",
similes: [
"get main domain",
"fetch primary domain",

View File

@@ -5,7 +5,7 @@ import { PublicKey } from "@solana/web3.js";
import { getOwnedAllDomains } from "../tools";
const getOwnedAllDomainsAction: Action = {
name: "solana_get_owned_all_domains",
name: "GET_OWNED_ALL_DOMAINS",
similes: [
"list owned domains",
"get my domains",

View File

@@ -4,7 +4,7 @@ import { z } from "zod";
import { getOwnedDomainsForTLD } from "../tools";
const getOwnedDomainsForTLDAction: Action = {
name: "solana_get_owned_tld_domains",
name: "GET_OWNED_DOMAINS_FOR_TLD",
similes: [
"list owned domains for tld",
"get my domains for extension",

View File

@@ -5,7 +5,7 @@ import { PublicKey } from "@solana/web3.js";
import { getPrimaryDomain } from "../tools";
const getPrimaryDomainAction: Action = {
name: "solana_get_domain",
name: "GET_PRIMARY_DOMAIN",
similes: [
"get primary domain",
"lookup primary domain",

View File

@@ -4,7 +4,7 @@ import { z } from "zod";
import { getTPS } from "../tools";
const getTPSAction: Action = {
name: "solana_get_tps",
name: "GET_TPS",
similes: [
"get transactions per second",
"check network speed",

View File

@@ -6,7 +6,7 @@ import { JupiterTokenData } from "../types";
import { getTokenAddressFromTicker, getTokenDataByAddress } from "../tools";
const getTokenDataAction: Action = {
name: "solana_token_data",
name: "GET_TOKEN_DATA",
similes: [
"get token info",
"token details",

View File

@@ -27,35 +27,35 @@ import raydiumCreateAmmV4Action from "./raydiumCreateAmmV4";
import createOrcaSingleSidedWhirlpoolAction from "./createOrcaSingleSidedWhirlpool";
import launchPumpfunTokenAction from "./launchPumpfunToken";
export const actions = [
deployTokenAction,
balanceAction,
transferAction,
deployCollectionAction,
mintNFTAction,
tradeAction,
requestFundsAction,
resolveDomainAction,
getTokenDataAction,
getTPSAction,
fetchPriceAction,
stakeWithJupAction,
registerDomainAction,
lendAssetAction,
createGibworkTaskAction,
resolveSolDomainAction,
pythFetchPriceAction,
getOwnedDomainsForTLDAction,
getPrimaryDomainAction,
getAllDomainsTLDsAction,
getOwnedAllDomainsAction,
createImageAction,
getMainAllDomainsDomainAction,
getAllRegisteredAllDomainsAction,
raydiumCreateCpmmAction,
raydiumCreateAmmV4Action,
createOrcaSingleSidedWhirlpoolAction,
launchPumpfunTokenAction,
];
export const ACTIONS = {
"DEPLOY_TOKEN_ACTION" : deployTokenAction,
"BALANCE_ACTION" : balanceAction,
"TRANSFER_ACTION" : transferAction,
"DEPLOY_COLLECTION_ACTION" : deployCollectionAction,
"MINT_NFT_ACTION" : mintNFTAction,
"TRADE_ACTION" : tradeAction,
"REQUEST_FUNDS_ACTION" : requestFundsAction,
"RESOLVE_DOMAIN_ACTION" : resolveDomainAction,
"GET_TOKEN_DATA_ACTION" : getTokenDataAction,
"GET_TPS_ACTION" : getTPSAction,
"FETCH_PRICE_ACTION" : fetchPriceAction,
"STAKE_WITH_JUP_ACTION" : stakeWithJupAction,
"REGISTER_DOMAIN_ACTION" : registerDomainAction,
"LEND_ASSET_ACTION" : lendAssetAction,
"CREATE_GIBWORK_TASK_ACTION" : createGibworkTaskAction,
"RESOLVE_SOL_DOMAIN_ACTION" : resolveSolDomainAction,
"PYTH_FETCH_PRICE_ACTION" : pythFetchPriceAction,
"GET_OWNED_DOMAINS_FOR_TLD_ACTION" : getOwnedDomainsForTLDAction,
"GET_PRIMARY_DOMAIN_ACTION" : getPrimaryDomainAction,
"GET_ALL_DOMAINS_TLDS_ACTION" : getAllDomainsTLDsAction,
"GET_OWNED_ALL_DOMAINS_ACTION" : getOwnedAllDomainsAction,
"CREATE_IMAGE_ACTION" : createImageAction,
"GET_MAIN_ALL_DOMAINS_DOMAIN_ACTION" : getMainAllDomainsDomainAction,
"GET_ALL_REGISTERED_ALL_DOMAINS_ACTION" : getAllRegisteredAllDomainsAction,
"RAYDIUM_CREATE_CPMM_ACTION" : raydiumCreateCpmmAction,
"RAYDIUM_CREATE_AMM_V4_ACTION" : raydiumCreateAmmV4Action,
"CREATE_ORCA_SINGLE_SIDED_WHIRLPOOL_ACTION" : createOrcaSingleSidedWhirlpoolAction,
"LAUNCH_PUMPFUN_TOKEN_ACTION" : launchPumpfunTokenAction,
};
export type { Action, ActionExample, Handler } from "../types/action";

View File

@@ -4,7 +4,7 @@ import { z } from "zod";
import { launchPumpFunToken } from "../tools";
const launchPumpfunTokenAction: Action = {
name: "solana_launch_pumpfun_token",
name: "LAUNCH_PUMPFUN_TOKEN",
similes: [
"create pumpfun token",
"launch token on pumpfun",

View File

@@ -4,7 +4,7 @@ import { z } from "zod";
import { lendAsset } from "../tools";
const lendAssetAction: Action = {
name: "solana_lend_asset",
name: "LEND_ASSET",
similes: [
"lend usdc",
"deposit for yield",

View File

@@ -5,7 +5,7 @@ import { z } from "zod";
import { mintCollectionNFT } from "../tools";
const mintNFTAction: Action = {
name: "solana_mint_nft",
name: "MINT_NFT",
similes: [
"mint nft",
"create nft",

View File

@@ -4,7 +4,7 @@ import { z } from "zod";
import { pythFetchPrice } from "../tools";
const pythFetchPriceAction: Action = {
name: "solana_pyth_fetch_price",
name: "PYTH_FETCH_PRICE",
similes: [
"get pyth price",
"check pyth price",

View File

@@ -6,7 +6,7 @@ import BN from "bn.js";
import { raydiumCreateAmmV4 } from "../tools";
const raydiumCreateAmmV4Action: Action = {
name: "raydium_create_ammV4",
name: "RAYDIUM_CREATE_AMM_V4",
similes: [
"create raydium v4 pool",
"setup raydium v4 liquidity pool",

View File

@@ -7,7 +7,7 @@ import Decimal from "decimal.js";
import { raydiumCreateClmm } from "../tools";
const raydiumCreateClmmAction: Action = {
name: "raydium_create_clmm",
name: "RAYDIUM_CREATE_CLMM",
similes: [
"create clmm pool",
"create concentrated liquidity pool",

View File

@@ -6,7 +6,7 @@ import BN from "bn.js";
import { raydiumCreateCpmm } from "../tools";
const raydiumCreateCpmmAction: Action = {
name: "solana_raydium_create_cpmm",
name: "RAYDIUM_CREATE_CPMM",
similes: [
"create raydium pool",
"setup raydium liquidity pool",

View File

@@ -4,7 +4,7 @@ import { z } from "zod";
import { registerDomain } from "../tools";
const registerDomainAction: Action = {
name: "solana_register_domain",
name: "REGISTER_DOMAIN",
similes: [
"register domain",
"buy domain",

View File

@@ -4,7 +4,7 @@ import { z } from "zod";
import { request_faucet_funds } from "../tools";
const requestFundsAction: Action = {
name: "solana_request_funds",
name: "REQUEST_FUNDS",
similes: [
"request sol",
"get test sol",

View File

@@ -4,7 +4,7 @@ import { z } from "zod";
import { resolveAllDomains } from "../tools";
const resolveDomainAction: Action = {
name: "solana_resolve_all_domains",
name: "RESOLVE_ALL_DOMAINS",
similes: [
"resolve domain",
"lookup domain",

View File

@@ -4,7 +4,7 @@ import { z } from "zod";
import { resolveSolDomain } from "../tools";
const resolveSolDomainAction: Action = {
name: "solana_resolve_sol_domain",
name: "RESOLVE_SOL_DOMAIN",
similes: [
"resolve sol domain",
"lookup sol domain",

View File

@@ -4,7 +4,7 @@ import { z } from "zod";
import { stakeWithJup } from "../tools";
const stakeWithJupAction: Action = {
name: "solana_stake_with_jup",
name: "STAKE_WITH_JUPITER",
similes: [
"stake sol",
"stake with jupiter",

View File

@@ -4,7 +4,7 @@ import { z } from "zod";
import { getTokenDataByTicker } from "../tools";
const tokenDataByTickerAction: Action = {
name: "solana_token_data_by_ticker",
name: "GET_TOKEN_DATA_BY_TICKER",
similes: [
"token data by ticker",
"fetch token info by ticker",

View File

@@ -5,7 +5,7 @@ import { z } from "zod";
import { trade } from "../tools";
const tradeAction: Action = {
name: "solana_trade",
name: "TRADE",
similes: [
"swap tokens",
"exchange tokens",

View File

@@ -5,7 +5,7 @@ import { z } from "zod";
import { transfer } from "../tools";
const transferAction: Action = {
name: "solana_transfer",
name: "TRANSFER",
similes: [
"send tokens",
"transfer funds",

View File

@@ -7,6 +7,5 @@ export { SolanaAgentKit, createSolanaTools };
export * from "./types";
// Export action system
export * from "./actions";
export * from "./types/action";
export { ACTIONS } from "./actions";
export * from "./utils/actionExecutor";

View File

@@ -1,4 +1,6 @@
import { PublicKey } from "@solana/web3.js";
import { SolanaAgentKit } from "../agent";
import { z } from "zod";
export interface Config {
OPENAI_API_KEY?: string;
@@ -98,3 +100,56 @@ export interface GibworkCreateTaskReponse {
signature?: string | undefined;
}
/**
* 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;
}

View File

@@ -1,13 +1,13 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { actions } from "../actions";
import { ACTIONS } from "../actions";
/**
* Find an action by its name or one of its similes
*/
export function findAction(query: string): Action | undefined {
const normalizedQuery = query.toLowerCase().trim();
return actions.find(
return Object.values(ACTIONS).find(
(action) =>
action.name.toLowerCase() === normalizedQuery ||
action.similes.some((simile) => simile.toLowerCase() === normalizedQuery),

View File

@@ -1,4 +1,4 @@
import { SolanaAgentKit } from "../src";
import { SolanaAgentKit , actions} from "../src";
import { createSolanaTools } from "../src/langchain";
import { HumanMessage } from "@langchain/core/messages";
import { MemorySaver } from "@langchain/langgraph";