diff --git a/examples/agent-kit-nextjs-langchain/app/api/chat/route.ts b/examples/agent-kit-nextjs-langchain/app/api/chat/route.ts
index 06e6911..badd6b3 100644
--- a/examples/agent-kit-nextjs-langchain/app/api/chat/route.ts
+++ b/examples/agent-kit-nextjs-langchain/app/api/chat/route.ts
@@ -5,24 +5,24 @@ import { createReactAgent } from "@langchain/langgraph/prebuilt";
import { SolanaAgentKit, createSolanaTools } from "solana-agent-kit";
const llm = new ChatOpenAI({
- temperature: 0.7,
- model: "gpt-4o-mini",
+ temperature: 0.7,
+ model: "gpt-4o-mini",
});
const solanaAgent = new SolanaAgentKit(
- process.env.SOLANA_PRIVATE_KEY!,
- process.env.RPC_URL,
- process.env.OPENAI_API_KEY!,
+ process.env.SOLANA_PRIVATE_KEY!,
+ process.env.RPC_URL,
+ process.env.OPENAI_API_KEY!,
);
const tools = createSolanaTools(solanaAgent);
const memory = new MemorySaver();
const agent = createReactAgent({
- llm,
- tools,
- checkpointSaver: memory,
- messageModifier: `
+ llm,
+ tools,
+ checkpointSaver: memory,
+ messageModifier: `
You are a helpful agent that can interact onchain using the Solana Agent Kit. You are
empowered to interact onchain using your tools. If you ever need funds, you can request them from the
faucet. If not, you can provide your wallet details and request funds from the user. If there is a 5XX
@@ -34,38 +34,38 @@ const agent = createReactAgent({
});
export async function POST(req: NextRequest) {
- try {
- const body = await req.json();
- const messages = body.messages ?? [];
+ try {
+ const body = await req.json();
+ const messages = body.messages ?? [];
- const eventStream = agent.streamEvents(
- {
- messages,
- },
- {
- version: "v2",
- configurable: {
- thread_id: "Solana Agent Kit!",
- },
- },
- );
+ const eventStream = agent.streamEvents(
+ {
+ messages,
+ },
+ {
+ version: "v2",
+ configurable: {
+ thread_id: "Solana Agent Kit!",
+ },
+ },
+ );
- const textEncoder = new TextEncoder();
- const transformStream = new ReadableStream({
- async start(controller) {
- for await (const { event, data } of eventStream) {
- if (event === "on_chat_model_stream") {
- if (!!data.chunk.content) {
- controller.enqueue(textEncoder.encode(data.chunk.content));
- }
- }
- }
- controller.close();
- },
- });
+ const textEncoder = new TextEncoder();
+ const transformStream = new ReadableStream({
+ async start(controller) {
+ for await (const { event, data } of eventStream) {
+ if (event === "on_chat_model_stream") {
+ if (data.chunk.content) {
+ controller.enqueue(textEncoder.encode(data.chunk.content));
+ }
+ }
+ }
+ controller.close();
+ },
+ });
- return new Response(transformStream);
- } catch (e: any) {
- return NextResponse.json({ error: e.message }, { status: e.status ?? 500 });
- }
+ return new Response(transformStream);
+ } catch (e: any) {
+ return NextResponse.json({ error: e.message }, { status: e.status ?? 500 });
+ }
}
diff --git a/examples/agent-kit-nextjs-langchain/data/DefaultRetrievalText.ts b/examples/agent-kit-nextjs-langchain/data/DefaultRetrievalText.ts
index 898acba..6973d98 100644
--- a/examples/agent-kit-nextjs-langchain/data/DefaultRetrievalText.ts
+++ b/examples/agent-kit-nextjs-langchain/data/DefaultRetrievalText.ts
@@ -537,4 +537,4 @@ const executor = await initializeAgentExecutorWithOptions(tools, llm, {
},
});
\`\`\`
-`;
\ No newline at end of file
+`;
diff --git a/examples/agent-kit-nextjs-langchain/utils/markdownToHTML.ts b/examples/agent-kit-nextjs-langchain/utils/markdownToHTML.ts
index dc265b1..135fdd9 100644
--- a/examples/agent-kit-nextjs-langchain/utils/markdownToHTML.ts
+++ b/examples/agent-kit-nextjs-langchain/utils/markdownToHTML.ts
@@ -2,29 +2,29 @@ import { marked } from "marked";
import DOMPurify from "isomorphic-dompurify";
interface MarkedOptions {
- gfm: boolean;
- breaks: boolean;
- headerIds: boolean;
- mangle: false;
- highlight?: (code: string, lang: string) => string;
+ gfm: boolean;
+ breaks: boolean;
+ headerIds: boolean;
+ mangle: false;
+ highlight?: (code: string, lang: string) => string;
}
// Configure marked options
const markedOptions: MarkedOptions = {
- gfm: true, // GitHub Flavored Markdown
- breaks: true, // Convert \n to
- headerIds: true, // Add ids to headers
- mangle: false, // Don't escape HTML
- highlight: function (code: string, lang: string): string {
- // You can add syntax highlighting here if needed
- return code;
- },
+ gfm: true, // GitHub Flavored Markdown
+ breaks: true, // Convert \n to
+ headerIds: true, // Add ids to headers
+ mangle: false, // Don't escape HTML
+ highlight: function (code: string, lang: string): string {
+ // You can add syntax highlighting here if needed
+ return code;
+ },
};
marked.setOptions(markedOptions);
// Basic markdown to HTML conversion with sanitization
export default function markdownToHtml(markdown: string) {
- const rawHtml = marked.parse(markdown);
- return DOMPurify.sanitize(rawHtml as string);
+ const rawHtml = marked.parse(markdown);
+ return DOMPurify.sanitize(rawHtml as string);
}
diff --git a/package.json b/package.json
index a84f7b5..5b2c3e4 100644
--- a/package.json
+++ b/package.json
@@ -10,8 +10,8 @@
"test": "ts-node test/index.ts",
"test:vercel-ai": "ts-node test/agent_sdks/vercel_ai.ts",
"generate": "ts-node src/utils/keypair.ts",
- "lint": "eslint . --ext .ts,.json",
- "lint:fix": "eslint . --ext .ts,.json --fix",
+ "lint": "eslint . --ext .ts",
+ "lint:fix": "eslint . --ext .ts --fix",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\""
},
"engines": {
diff --git a/src/actions/createOrcaSingleSidedWhirlpool.ts b/src/actions/createOrcaSingleSidedWhirlpool.ts
index affc445..3a1fb52 100644
--- a/src/actions/createOrcaSingleSidedWhirlpool.ts
+++ b/src/actions/createOrcaSingleSidedWhirlpool.ts
@@ -87,7 +87,7 @@ const createOrcaSingleSidedWhirlpoolAction: Action = {
const otherTokenMint = new PublicKey(input.otherTokenMint);
const initialPrice = new Decimal(input.initialPrice);
const maxPrice = new Decimal(input.maxPrice);
- const feeTier = input.feeTier
+ const feeTier = input.feeTier;
// Create the whirlpool
const signature = await orcaCreateSingleSidedLiquidityPool(
diff --git a/src/actions/getWalletAddress.ts b/src/actions/getWalletAddress.ts
index 114d642..7cd87c6 100644
--- a/src/actions/getWalletAddress.ts
+++ b/src/actions/getWalletAddress.ts
@@ -4,26 +4,26 @@ import { get_wallet_address } from "../tools";
import { Action } from "../types/action";
const getWalletAddressAction: Action = {
- name: "GET_WALLET_ADDRESS",
- similes: ["wallet address", "address", "wallet"],
- description: "Get wallet address of the agent",
- examples: [
- [
- {
- input: {},
- output: {
- status: "success",
- address: "0x1234567890abcdef",
- },
- explanation: "The agent's wallet address is 0x1234567890abcdef",
- },
- ],
- ],
- schema: z.object({}),
- handler: async (agent: SolanaAgentKit) => ({
- status: "success",
- address: get_wallet_address(agent),
- }),
+ name: "GET_WALLET_ADDRESS",
+ similes: ["wallet address", "address", "wallet"],
+ description: "Get wallet address of the agent",
+ examples: [
+ [
+ {
+ input: {},
+ output: {
+ status: "success",
+ address: "0x1234567890abcdef",
+ },
+ explanation: "The agent's wallet address is 0x1234567890abcdef",
+ },
+ ],
+ ],
+ schema: z.object({}),
+ handler: async (agent: SolanaAgentKit) => ({
+ status: "success",
+ address: get_wallet_address(agent),
+ }),
};
export default getWalletAddressAction;
diff --git a/src/actions/index.ts b/src/actions/index.ts
index b99698a..1a2b75d 100644
--- a/src/actions/index.ts
+++ b/src/actions/index.ts
@@ -29,36 +29,36 @@ import launchPumpfunTokenAction from "./launchPumpfunToken";
import getWalletAddressAction from "./getWalletAddress";
export const ACTIONS = {
- WALLET_ADDRESS_ACTION: getWalletAddressAction,
- 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,
+ WALLET_ADDRESS_ACTION: getWalletAddressAction,
+ 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";
diff --git a/src/agent/index.ts b/src/agent/index.ts
index d0b017a..e982aa1 100644
--- a/src/agent/index.ts
+++ b/src/agent/index.ts
@@ -85,24 +85,30 @@ export class SolanaAgentKit {
* @deprecated Using openai_api_key directly in constructor is deprecated.
* Please use the new constructor with Config object instead:
* @example
- * const agent = new SolanaAgentKit(privateKey, rpcUrl, {
+ * const agent = new SolanaAgentKit(privateKey, rpcUrl, {
* OPENAI_API_KEY: 'your-key'
* });
*/
- constructor(private_key: string, rpc_url: string, openai_api_key: string | null);
+ constructor(
+ private_key: string,
+ rpc_url: string,
+ openai_api_key: string | null,
+ );
constructor(private_key: string, rpc_url: string, config: Config);
constructor(
private_key: string,
rpc_url: string,
configOrKey: Config | string | null,
) {
- this.connection = new Connection(rpc_url || "https://api.mainnet-beta.solana.com");
+ this.connection = new Connection(
+ rpc_url || "https://api.mainnet-beta.solana.com",
+ );
this.wallet = Keypair.fromSecretKey(bs58.decode(private_key));
this.wallet_address = this.wallet.publicKey;
// Handle both old and new patterns
- if (typeof configOrKey === 'string' || configOrKey === null) {
- this.config = { OPENAI_API_KEY: configOrKey || '' };
+ if (typeof configOrKey === "string" || configOrKey === null) {
+ this.config = { OPENAI_API_KEY: configOrKey || "" };
} else {
this.config = configOrKey;
}
diff --git a/src/langchain/index.ts b/src/langchain/index.ts
index 49db2f8..b7c836e 100644
--- a/src/langchain/index.ts
+++ b/src/langchain/index.ts
@@ -2,17 +2,17 @@ import { PublicKey } from "@solana/web3.js";
import Decimal from "decimal.js";
import { Tool } from "langchain/tools";
import {
- GibworkCreateTaskReponse,
- PythFetchPriceResponse,
- SolanaAgentKit,
+ GibworkCreateTaskReponse,
+ PythFetchPriceResponse,
+ SolanaAgentKit,
} from "../index";
import { create_image } from "../tools/create_image";
import { BN } from "@coral-xyz/anchor";
import { FEE_TIERS } from "../tools";
export class SolanaBalanceTool extends Tool {
- name = "solana_balance";
- description = `Get the balance of a Solana wallet or token account.
+ name = "solana_balance";
+ description = `Get the balance of a Solana wallet or token account.
If you want to get the balance of your wallet, you don't need to provide the tokenAddress.
If no tokenAddress is provided, the balance will be in SOL.
@@ -20,33 +20,33 @@ export class SolanaBalanceTool extends Tool {
Inputs ( input is a JSON string ):
tokenAddress: string, eg "So11111111111111111111111111111111111111112" (optional)`;
- constructor(private solanaKit: SolanaAgentKit) {
- super();
- }
+ constructor(private solanaKit: SolanaAgentKit) {
+ super();
+ }
- protected async _call(input: string): Promise {
- try {
- const tokenAddress = input ? new PublicKey(input) : undefined;
- const balance = await this.solanaKit.getBalance(tokenAddress);
+ protected async _call(input: string): Promise {
+ try {
+ const tokenAddress = input ? new PublicKey(input) : undefined;
+ const balance = await this.solanaKit.getBalance(tokenAddress);
- return JSON.stringify({
- status: "success",
- balance,
- token: input || "SOL",
- });
- } catch (error: any) {
- return JSON.stringify({
- status: "error",
- message: error.message,
- code: error.code || "UNKNOWN_ERROR",
- });
- }
- }
+ return JSON.stringify({
+ status: "success",
+ balance,
+ token: input || "SOL",
+ });
+ } catch (error: any) {
+ return JSON.stringify({
+ status: "error",
+ message: error.message,
+ code: error.code || "UNKNOWN_ERROR",
+ });
+ }
+ }
}
export class SolanaBalanceOtherTool extends Tool {
- name = "solana_balance_other";
- description = `Get the balance of a Solana wallet or token account which is different from the agent's wallet.
+ name = "solana_balance_other";
+ description = `Get the balance of a Solana wallet or token account which is different from the agent's wallet.
If no tokenAddress is provided, the SOL balance of the wallet will be returned.
@@ -54,88 +54,88 @@ export class SolanaBalanceOtherTool extends Tool {
walletAddress: string, eg "GDEkQF7UMr7RLv1KQKMtm8E2w3iafxJLtyXu3HVQZnME" (required)
tokenAddress: string, eg "SENDdRQtYMWaQrBroBrJ2Q53fgVuq95CV9UPGEvpCxa" (optional)`;
- constructor(private solanaKit: SolanaAgentKit) {
- super();
- }
+ constructor(private solanaKit: SolanaAgentKit) {
+ super();
+ }
- protected async _call(input: string): Promise {
- try {
- const { walletAddress, tokenAddress } = JSON.parse(input);
+ protected async _call(input: string): Promise {
+ try {
+ const { walletAddress, tokenAddress } = JSON.parse(input);
- const tokenPubKey = tokenAddress
- ? new PublicKey(tokenAddress)
- : undefined;
+ const tokenPubKey = tokenAddress
+ ? new PublicKey(tokenAddress)
+ : undefined;
- const balance = await this.solanaKit.getBalanceOther(
- new PublicKey(walletAddress),
- tokenPubKey,
- );
+ const balance = await this.solanaKit.getBalanceOther(
+ new PublicKey(walletAddress),
+ tokenPubKey,
+ );
- return JSON.stringify({
- status: "success",
- balance,
- wallet: walletAddress,
- token: tokenAddress || "SOL",
- });
- } catch (error: any) {
- return JSON.stringify({
- status: "error",
- message: error.message,
- code: error.code || "UNKNOWN_ERROR",
- });
- }
- }
+ return JSON.stringify({
+ status: "success",
+ balance,
+ wallet: walletAddress,
+ token: tokenAddress || "SOL",
+ });
+ } catch (error: any) {
+ return JSON.stringify({
+ status: "error",
+ message: error.message,
+ code: error.code || "UNKNOWN_ERROR",
+ });
+ }
+ }
}
export class SolanaTransferTool extends Tool {
- name = "solana_transfer";
- description = `Transfer tokens or SOL to another address ( also called as wallet address ).
+ name = "solana_transfer";
+ description = `Transfer tokens or SOL to another address ( also called as wallet address ).
Inputs ( input is a JSON string ):
to: string, eg "8x2dR8Mpzuz2YqyZyZjUbYWKSWesBo5jMx2Q9Y86udVk" (required)
amount: number, eg 1 (required)
mint?: string, eg "So11111111111111111111111111111111111111112" or "SENDdRQtYMWaQrBroBrJ2Q53fgVuq95CV9UPGEvpCxa" (optional)`;
- constructor(private solanaKit: SolanaAgentKit) {
- super();
- }
+ constructor(private solanaKit: SolanaAgentKit) {
+ super();
+ }
- protected async _call(input: string): Promise {
- try {
- const parsedInput = JSON.parse(input);
+ protected async _call(input: string): Promise {
+ try {
+ const parsedInput = JSON.parse(input);
- const recipient = new PublicKey(parsedInput.to);
- const mintAddress = parsedInput.mint
- ? new PublicKey(parsedInput.mint)
- : undefined;
+ const recipient = new PublicKey(parsedInput.to);
+ const mintAddress = parsedInput.mint
+ ? new PublicKey(parsedInput.mint)
+ : undefined;
- const tx = await this.solanaKit.transfer(
- recipient,
- parsedInput.amount,
- mintAddress,
- );
+ const tx = await this.solanaKit.transfer(
+ recipient,
+ parsedInput.amount,
+ mintAddress,
+ );
- return JSON.stringify({
- status: "success",
- message: "Transfer completed successfully",
- amount: parsedInput.amount,
- recipient: parsedInput.to,
- token: parsedInput.mint || "SOL",
- transaction: tx,
- });
- } catch (error: any) {
- return JSON.stringify({
- status: "error",
- message: error.message,
- code: error.code || "UNKNOWN_ERROR",
- });
- }
- }
+ return JSON.stringify({
+ status: "success",
+ message: "Transfer completed successfully",
+ amount: parsedInput.amount,
+ recipient: parsedInput.to,
+ token: parsedInput.mint || "SOL",
+ transaction: tx,
+ });
+ } catch (error: any) {
+ return JSON.stringify({
+ status: "error",
+ message: error.message,
+ code: error.code || "UNKNOWN_ERROR",
+ });
+ }
+ }
}
export class SolanaDeployTokenTool extends Tool {
- name = "solana_deploy_token";
- description = `Deploy a new token on Solana blockchain.
+ name = "solana_deploy_token";
+ description = `Deploy a new token on Solana blockchain.
Inputs (input is a JSON string):
name: string, eg "My Token" (required)
@@ -144,76 +144,76 @@ export class SolanaDeployTokenTool extends Tool {
decimals?: number, eg 9 (optional, defaults to 9)
initialSupply?: number, eg 1000000 (optional)`;
- constructor(private solanaKit: SolanaAgentKit) {
- super();
- }
+ constructor(private solanaKit: SolanaAgentKit) {
+ super();
+ }
- protected async _call(input: string): Promise {
- try {
- const parsedInput = JSON.parse(input);
+ protected async _call(input: string): Promise {
+ try {
+ const parsedInput = JSON.parse(input);
- const result = await this.solanaKit.deployToken(
- parsedInput.name,
- parsedInput.uri,
- parsedInput.symbol,
- parsedInput.decimals,
- parsedInput.initialSupply,
- );
+ const result = await this.solanaKit.deployToken(
+ parsedInput.name,
+ parsedInput.uri,
+ parsedInput.symbol,
+ parsedInput.decimals,
+ parsedInput.initialSupply,
+ );
- return JSON.stringify({
- status: "success",
- message: "Token deployed successfully",
- mintAddress: result.mint.toString(),
- decimals: parsedInput.decimals || 9,
- });
- } catch (error: any) {
- return JSON.stringify({
- status: "error",
- message: error.message,
- code: error.code || "UNKNOWN_ERROR",
- });
- }
- }
+ return JSON.stringify({
+ status: "success",
+ message: "Token deployed successfully",
+ mintAddress: result.mint.toString(),
+ decimals: parsedInput.decimals || 9,
+ });
+ } catch (error: any) {
+ return JSON.stringify({
+ status: "error",
+ message: error.message,
+ code: error.code || "UNKNOWN_ERROR",
+ });
+ }
+ }
}
export class SolanaDeployCollectionTool extends Tool {
- name = "solana_deploy_collection";
- description = `Deploy a new NFT collection on Solana blockchain.
+ name = "solana_deploy_collection";
+ description = `Deploy a new NFT collection on Solana blockchain.
Inputs (input is a JSON string):
name: string, eg "My Collection" (required)
uri: string, eg "https://example.com/collection.json" (required)
royaltyBasisPoints?: number, eg 500 for 5% (optional)`;
- constructor(private solanaKit: SolanaAgentKit) {
- super();
- }
+ constructor(private solanaKit: SolanaAgentKit) {
+ super();
+ }
- protected async _call(input: string): Promise {
- try {
- const parsedInput = JSON.parse(input);
+ protected async _call(input: string): Promise {
+ try {
+ const parsedInput = JSON.parse(input);
- const result = await this.solanaKit.deployCollection(parsedInput);
+ const result = await this.solanaKit.deployCollection(parsedInput);
- return JSON.stringify({
- status: "success",
- message: "Collection deployed successfully",
- collectionAddress: result.collectionAddress.toString(),
- name: parsedInput.name,
- });
- } catch (error: any) {
- return JSON.stringify({
- status: "error",
- message: error.message,
- code: error.code || "UNKNOWN_ERROR",
- });
- }
- }
+ return JSON.stringify({
+ status: "success",
+ message: "Collection deployed successfully",
+ collectionAddress: result.collectionAddress.toString(),
+ name: parsedInput.name,
+ });
+ } catch (error: any) {
+ return JSON.stringify({
+ status: "error",
+ message: error.message,
+ code: error.code || "UNKNOWN_ERROR",
+ });
+ }
+ }
}
export class SolanaMintNFTTool extends Tool {
- name = "solana_mint_nft";
- description = `Mint a new NFT in a collection on Solana blockchain.
+ name = "solana_mint_nft";
+ description = `Mint a new NFT in a collection on Solana blockchain.
Inputs (input is a JSON string):
collectionMint: string, eg "J1S9H3QjnRtBbbuD4HjPV6RpRhwuk4zKbxsnCHuTgh9w" (required) - The address of the collection to mint into
@@ -221,49 +221,49 @@ export class SolanaMintNFTTool extends Tool {
uri: string, eg "https://example.com/nft.json" (required)
recipient?: string, eg "9aUn5swQzUTRanaaTwmszxiv89cvFwUCjEBv1vZCoT1u" (optional) - The wallet to receive the NFT, defaults to agent's wallet which is ${this.solanaKit.wallet_address.toString()}`;
- constructor(private solanaKit: SolanaAgentKit) {
- super();
- }
+ constructor(private solanaKit: SolanaAgentKit) {
+ super();
+ }
- protected async _call(input: string): Promise {
- try {
- const parsedInput = JSON.parse(input);
+ protected async _call(input: string): Promise {
+ try {
+ const parsedInput = JSON.parse(input);
- const result = await this.solanaKit.mintNFT(
- new PublicKey(parsedInput.collectionMint),
- {
- name: parsedInput.name,
- uri: parsedInput.uri,
- },
- parsedInput.recipient
- ? new PublicKey(parsedInput.recipient)
- : this.solanaKit.wallet_address,
- );
+ const result = await this.solanaKit.mintNFT(
+ new PublicKey(parsedInput.collectionMint),
+ {
+ name: parsedInput.name,
+ uri: parsedInput.uri,
+ },
+ parsedInput.recipient
+ ? new PublicKey(parsedInput.recipient)
+ : this.solanaKit.wallet_address,
+ );
- return JSON.stringify({
- status: "success",
- message: "NFT minted successfully",
- mintAddress: result.mint.toString(),
- metadata: {
- name: parsedInput.name,
- symbol: parsedInput.symbol,
- uri: parsedInput.uri,
- },
- recipient: parsedInput.recipient || result.mint.toString(),
- });
- } catch (error: any) {
- return JSON.stringify({
- status: "error",
- message: error.message,
- code: error.code || "UNKNOWN_ERROR",
- });
- }
- }
+ return JSON.stringify({
+ status: "success",
+ message: "NFT minted successfully",
+ mintAddress: result.mint.toString(),
+ metadata: {
+ name: parsedInput.name,
+ symbol: parsedInput.symbol,
+ uri: parsedInput.uri,
+ },
+ recipient: parsedInput.recipient || result.mint.toString(),
+ });
+ } catch (error: any) {
+ return JSON.stringify({
+ status: "error",
+ message: error.message,
+ code: error.code || "UNKNOWN_ERROR",
+ });
+ }
+ }
}
export class SolanaTradeTool extends Tool {
- name = "solana_trade";
- description = `This tool can be used to swap tokens to another token ( It uses Jupiter Exchange ).
+ name = "solana_trade";
+ description = `This tool can be used to swap tokens to another token ( It uses Jupiter Exchange ).
Inputs ( input is a JSON string ):
outputMint: string, eg "So11111111111111111111111111111111111111112" or "SENDdRQtYMWaQrBroBrJ2Q53fgVuq95CV9UPGEvpCxa" (required)
@@ -271,44 +271,44 @@ export class SolanaTradeTool extends Tool {
inputMint?: string, eg "So11111111111111111111111111111111111111112" (optional)
slippageBps?: number, eg 100 (optional)`;
- constructor(private solanaKit: SolanaAgentKit) {
- super();
- }
+ constructor(private solanaKit: SolanaAgentKit) {
+ super();
+ }
- protected async _call(input: string): Promise {
- try {
- const parsedInput = JSON.parse(input);
+ protected async _call(input: string): Promise {
+ try {
+ const parsedInput = JSON.parse(input);
- const tx = await this.solanaKit.trade(
- new PublicKey(parsedInput.outputMint),
- parsedInput.inputAmount,
- parsedInput.inputMint
- ? new PublicKey(parsedInput.inputMint)
- : new PublicKey("So11111111111111111111111111111111111111112"),
- parsedInput.slippageBps,
- );
+ const tx = await this.solanaKit.trade(
+ new PublicKey(parsedInput.outputMint),
+ parsedInput.inputAmount,
+ parsedInput.inputMint
+ ? new PublicKey(parsedInput.inputMint)
+ : new PublicKey("So11111111111111111111111111111111111111112"),
+ parsedInput.slippageBps,
+ );
- return JSON.stringify({
- status: "success",
- message: "Trade executed successfully",
- transaction: tx,
- inputAmount: parsedInput.inputAmount,
- inputToken: parsedInput.inputMint || "SOL",
- outputToken: parsedInput.outputMint,
- });
- } catch (error: any) {
- return JSON.stringify({
- status: "error",
- message: error.message,
- code: error.code || "UNKNOWN_ERROR",
- });
- }
- }
+ return JSON.stringify({
+ status: "success",
+ message: "Trade executed successfully",
+ transaction: tx,
+ inputAmount: parsedInput.inputAmount,
+ inputToken: parsedInput.inputMint || "SOL",
+ outputToken: parsedInput.outputMint,
+ });
+ } catch (error: any) {
+ return JSON.stringify({
+ status: "error",
+ message: error.message,
+ code: error.code || "UNKNOWN_ERROR",
+ });
+ }
+ }
}
export class SolanaLimitOrderTool extends Tool {
- name = "solana_limit_order";
- description = `This tool can be used to place limit orders using Manifest.
+ name = "solana_limit_order";
+ description = `This tool can be used to place limit orders using Manifest.
Inputs ( input is a JSON string ):
marketId: PublicKey, eg "ENhU8LsaR7vDD2G1CsWcsuSGNrih9Cv5WZEk7q9kPapQ" for SOL/USDC (required)
@@ -316,186 +316,186 @@ export class SolanaLimitOrderTool extends Tool {
side: string, eg "Buy" or "Sell" (required)
price: number, in tokens eg 200 for SOL/USDC (required)`;
- constructor(private solanaKit: SolanaAgentKit) {
- super();
- }
+ constructor(private solanaKit: SolanaAgentKit) {
+ super();
+ }
- protected async _call(input: string): Promise {
- try {
- const parsedInput = JSON.parse(input);
+ protected async _call(input: string): Promise {
+ try {
+ const parsedInput = JSON.parse(input);
- const tx = await this.solanaKit.limitOrder(
- new PublicKey(parsedInput.marketId),
- parsedInput.quantity,
- parsedInput.side,
- parsedInput.price,
- );
+ const tx = await this.solanaKit.limitOrder(
+ new PublicKey(parsedInput.marketId),
+ parsedInput.quantity,
+ parsedInput.side,
+ parsedInput.price,
+ );
- return JSON.stringify({
- status: "success",
- message: "Trade executed successfully",
- transaction: tx,
- marketId: parsedInput.marketId,
- quantity: parsedInput.quantity,
- side: parsedInput.side,
- price: parsedInput.price,
- });
- } catch (error: any) {
- return JSON.stringify({
- status: "error",
- message: error.message,
- code: error.code || "UNKNOWN_ERROR",
- });
- }
- }
+ return JSON.stringify({
+ status: "success",
+ message: "Trade executed successfully",
+ transaction: tx,
+ marketId: parsedInput.marketId,
+ quantity: parsedInput.quantity,
+ side: parsedInput.side,
+ price: parsedInput.price,
+ });
+ } catch (error: any) {
+ return JSON.stringify({
+ status: "error",
+ message: error.message,
+ code: error.code || "UNKNOWN_ERROR",
+ });
+ }
+ }
}
export class SolanaCancelAllOrdersTool extends Tool {
- name = "solana_cancel_all_orders";
- description = `This tool can be used to cancel all orders from a Manifest market.
+ name = "solana_cancel_all_orders";
+ description = `This tool can be used to cancel all orders from a Manifest market.
Input ( input is a JSON string ):
marketId: string, eg "ENhU8LsaR7vDD2G1CsWcsuSGNrih9Cv5WZEk7q9kPapQ" for SOL/USDC (required)`;
- constructor(private solanaKit: SolanaAgentKit) {
- super();
- }
+ constructor(private solanaKit: SolanaAgentKit) {
+ super();
+ }
- protected async _call(input: string): Promise {
- try {
- const marketId = new PublicKey(input.trim());
- const tx = await this.solanaKit.cancelAllOrders(marketId);
+ protected async _call(input: string): Promise {
+ try {
+ const marketId = new PublicKey(input.trim());
+ const tx = await this.solanaKit.cancelAllOrders(marketId);
- return JSON.stringify({
- status: "success",
- message: "Cancel orders successfully",
- transaction: tx,
- marketId,
- });
- } catch (error: any) {
- return JSON.stringify({
- status: "error",
- message: error.message,
- code: error.code || "UNKNOWN_ERROR",
- });
- }
- }
+ return JSON.stringify({
+ status: "success",
+ message: "Cancel orders successfully",
+ transaction: tx,
+ marketId,
+ });
+ } catch (error: any) {
+ return JSON.stringify({
+ status: "error",
+ message: error.message,
+ code: error.code || "UNKNOWN_ERROR",
+ });
+ }
+ }
}
export class SolanaWithdrawAllTool extends Tool {
- name = "solana_withdraw_all";
- description = `This tool can be used to withdraw all funds from a Manifest market.
+ name = "solana_withdraw_all";
+ description = `This tool can be used to withdraw all funds from a Manifest market.
Input ( input is a JSON string ):
marketId: string, eg "ENhU8LsaR7vDD2G1CsWcsuSGNrih9Cv5WZEk7q9kPapQ" for SOL/USDC (required)`;
- constructor(private solanaKit: SolanaAgentKit) {
- super();
- }
+ constructor(private solanaKit: SolanaAgentKit) {
+ super();
+ }
- protected async _call(input: string): Promise {
- try {
- const marketId = new PublicKey(input.trim());
- const tx = await this.solanaKit.withdrawAll(marketId);
+ protected async _call(input: string): Promise {
+ try {
+ const marketId = new PublicKey(input.trim());
+ const tx = await this.solanaKit.withdrawAll(marketId);
- return JSON.stringify({
- status: "success",
- message: "Withdrew successfully",
- transaction: tx,
- marketId,
- });
- } catch (error: any) {
- return JSON.stringify({
- status: "error",
- message: error.message,
- code: error.code || "UNKNOWN_ERROR",
- });
- }
- }
+ return JSON.stringify({
+ status: "success",
+ message: "Withdrew successfully",
+ transaction: tx,
+ marketId,
+ });
+ } catch (error: any) {
+ return JSON.stringify({
+ status: "error",
+ message: error.message,
+ code: error.code || "UNKNOWN_ERROR",
+ });
+ }
+ }
}
export class SolanaRequestFundsTool extends Tool {
- name = "solana_request_funds";
- description = "Request SOL from Solana faucet (devnet/testnet only)";
+ name = "solana_request_funds";
+ description = "Request SOL from Solana faucet (devnet/testnet only)";
- constructor(private solanaKit: SolanaAgentKit) {
- super();
- }
+ constructor(private solanaKit: SolanaAgentKit) {
+ super();
+ }
- protected async _call(_input: string): Promise {
- try {
- await this.solanaKit.requestFaucetFunds();
+ protected async _call(_input: string): Promise {
+ try {
+ await this.solanaKit.requestFaucetFunds();
- return JSON.stringify({
- status: "success",
- message: "Successfully requested faucet funds",
- network: this.solanaKit.connection.rpcEndpoint.split("/")[2],
- });
- } catch (error: any) {
- return JSON.stringify({
- status: "error",
- message: error.message,
- code: error.code || "UNKNOWN_ERROR",
- });
- }
- }
+ return JSON.stringify({
+ status: "success",
+ message: "Successfully requested faucet funds",
+ network: this.solanaKit.connection.rpcEndpoint.split("/")[2],
+ });
+ } catch (error: any) {
+ return JSON.stringify({
+ status: "error",
+ message: error.message,
+ code: error.code || "UNKNOWN_ERROR",
+ });
+ }
+ }
}
export class SolanaRegisterDomainTool extends Tool {
- name = "solana_register_domain";
- description = `Register a .sol domain name for your wallet.
+ name = "solana_register_domain";
+ description = `Register a .sol domain name for your wallet.
Inputs:
name: string, eg "pumpfun.sol" (required)
spaceKB: number, eg 1 (optional, default is 1)
`;
- constructor(private solanaKit: SolanaAgentKit) {
- super();
- }
+ constructor(private solanaKit: SolanaAgentKit) {
+ super();
+ }
- private validateInput(input: any): void {
- if (!input.name || typeof input.name !== "string") {
- throw new Error("name is required and must be a string");
- }
- if (
- input.spaceKB !== undefined &&
- (typeof input.spaceKB !== "number" || input.spaceKB <= 0)
- ) {
- throw new Error("spaceKB must be a positive number when provided");
- }
- }
+ private validateInput(input: any): void {
+ if (!input.name || typeof input.name !== "string") {
+ throw new Error("name is required and must be a string");
+ }
+ if (
+ input.spaceKB !== undefined &&
+ (typeof input.spaceKB !== "number" || input.spaceKB <= 0)
+ ) {
+ throw new Error("spaceKB must be a positive number when provided");
+ }
+ }
- protected async _call(input: string): Promise {
- try {
- const parsedInput = JSON.parse(input);
- this.validateInput(parsedInput);
+ protected async _call(input: string): Promise {
+ try {
+ const parsedInput = JSON.parse(input);
+ this.validateInput(parsedInput);
- const tx = await this.solanaKit.registerDomain(
- parsedInput.name,
- parsedInput.spaceKB || 1,
- );
+ const tx = await this.solanaKit.registerDomain(
+ parsedInput.name,
+ parsedInput.spaceKB || 1,
+ );
- return JSON.stringify({
- status: "success",
- message: "Domain registered successfully",
- transaction: tx,
- domain: `${parsedInput.name}.sol`,
- spaceKB: parsedInput.spaceKB || 1,
- });
- } catch (error: any) {
- return JSON.stringify({
- status: "error",
- message: error.message,
- code: error.code || "UNKNOWN_ERROR",
- });
- }
- }
+ return JSON.stringify({
+ status: "success",
+ message: "Domain registered successfully",
+ transaction: tx,
+ domain: `${parsedInput.name}.sol`,
+ spaceKB: parsedInput.spaceKB || 1,
+ });
+ } catch (error: any) {
+ return JSON.stringify({
+ status: "error",
+ message: error.message,
+ code: error.code || "UNKNOWN_ERROR",
+ });
+ }
+ }
}
export class SolanaResolveDomainTool extends Tool {
- name = "solana_resolve_domain";
- description = `Resolve ONLY .sol domain names to a Solana PublicKey.
+ name = "solana_resolve_domain";
+ description = `Resolve ONLY .sol domain names to a Solana PublicKey.
This tool is exclusively for .sol domains.
DO NOT use this for other domain types like .blink, .bonk, etc.
@@ -503,79 +503,79 @@ export class SolanaResolveDomainTool extends Tool {
domain: string, eg "pumpfun.sol" (required)
`;
- constructor(private solanaKit: SolanaAgentKit) {
- super();
- }
+ constructor(private solanaKit: SolanaAgentKit) {
+ super();
+ }
- protected async _call(input: string): Promise {
- try {
- const domain = input.trim();
- const publicKey = await this.solanaKit.resolveSolDomain(domain);
+ protected async _call(input: string): Promise {
+ try {
+ const domain = input.trim();
+ const publicKey = await this.solanaKit.resolveSolDomain(domain);
- return JSON.stringify({
- status: "success",
- message: "Domain resolved successfully",
- publicKey: publicKey.toBase58(),
- });
- } catch (error: any) {
- return JSON.stringify({
- status: "error",
- message: error.message,
- code: error.code || "UNKNOWN_ERROR",
- });
- }
- }
+ return JSON.stringify({
+ status: "success",
+ message: "Domain resolved successfully",
+ publicKey: publicKey.toBase58(),
+ });
+ } catch (error: any) {
+ return JSON.stringify({
+ status: "error",
+ message: error.message,
+ code: error.code || "UNKNOWN_ERROR",
+ });
+ }
+ }
}
export class SolanaGetDomainTool extends Tool {
- name = "solana_get_domain";
- description = `Retrieve the .sol domain associated for a given account address.
+ name = "solana_get_domain";
+ description = `Retrieve the .sol domain associated for a given account address.
Inputs:
account: string, eg "4Be9CvxqHW6BYiRAxW9Q3xu1ycTMWaL5z8NX4HR3ha7t" (required)
`;
- constructor(private solanaKit: SolanaAgentKit) {
- super();
- }
+ constructor(private solanaKit: SolanaAgentKit) {
+ super();
+ }
- protected async _call(input: string): Promise {
- try {
- const account = new PublicKey(input.trim());
- const domain = await this.solanaKit.getPrimaryDomain(account);
+ protected async _call(input: string): Promise {
+ try {
+ const account = new PublicKey(input.trim());
+ const domain = await this.solanaKit.getPrimaryDomain(account);
- return JSON.stringify({
- status: "success",
- message: "Primary domain retrieved successfully",
- domain,
- });
- } catch (error: any) {
- return JSON.stringify({
- status: "error",
- message: error.message,
- code: error.code || "UNKNOWN_ERROR",
- });
- }
- }
+ return JSON.stringify({
+ status: "success",
+ message: "Primary domain retrieved successfully",
+ domain,
+ });
+ } catch (error: any) {
+ return JSON.stringify({
+ status: "error",
+ message: error.message,
+ code: error.code || "UNKNOWN_ERROR",
+ });
+ }
+ }
}
export class SolanaGetWalletAddressTool extends Tool {
- name = "solana_get_wallet_address";
- description = `Get the wallet address of the agent`;
+ name = "solana_get_wallet_address";
+ description = `Get the wallet address of the agent`;
- constructor(private solanaKit: SolanaAgentKit) {
- super();
- }
+ constructor(private solanaKit: SolanaAgentKit) {
+ super();
+ }
- async _call(_input: string): Promise {
- return this.solanaKit.wallet_address.toString();
- }
+ async _call(_input: string): Promise {
+ return this.solanaKit.wallet_address.toString();
+ }
}
export class SolanaPumpfunTokenLaunchTool extends Tool {
- name = "solana_launch_pumpfun_token";
+ name = "solana_launch_pumpfun_token";
- description = `This tool can be used to launch a token on Pump.fun,
+ description = `This tool can be used to launch a token on Pump.fun,
do not use this tool for any other purpose, or for creating SPL tokens.
If the user asks you to chose the parameters, you should generate valid values.
For generating the image, you can use the solana_create_image tool.
@@ -586,283 +586,283 @@ export class SolanaPumpfunTokenLaunchTool extends Tool {
description: string, eg "PumpFun Token is a token on the Solana blockchain",
imageUrl: string, eg "https://i.imgur.com/UFm07Np_d.png`;
- constructor(private solanaKit: SolanaAgentKit) {
- super();
- }
+ constructor(private solanaKit: SolanaAgentKit) {
+ super();
+ }
- private validateInput(input: any): void {
- if (!input.tokenName || typeof input.tokenName !== "string") {
- throw new Error("tokenName is required and must be a string");
- }
- if (!input.tokenTicker || typeof input.tokenTicker !== "string") {
- throw new Error("tokenTicker is required and must be a string");
- }
- if (!input.description || typeof input.description !== "string") {
- throw new Error("description is required and must be a string");
- }
- if (!input.imageUrl || typeof input.imageUrl !== "string") {
- throw new Error("imageUrl is required and must be a string");
- }
- if (
- input.initialLiquiditySOL !== undefined &&
- typeof input.initialLiquiditySOL !== "number"
- ) {
- throw new Error("initialLiquiditySOL must be a number when provided");
- }
- }
+ private validateInput(input: any): void {
+ if (!input.tokenName || typeof input.tokenName !== "string") {
+ throw new Error("tokenName is required and must be a string");
+ }
+ if (!input.tokenTicker || typeof input.tokenTicker !== "string") {
+ throw new Error("tokenTicker is required and must be a string");
+ }
+ if (!input.description || typeof input.description !== "string") {
+ throw new Error("description is required and must be a string");
+ }
+ if (!input.imageUrl || typeof input.imageUrl !== "string") {
+ throw new Error("imageUrl is required and must be a string");
+ }
+ if (
+ input.initialLiquiditySOL !== undefined &&
+ typeof input.initialLiquiditySOL !== "number"
+ ) {
+ throw new Error("initialLiquiditySOL must be a number when provided");
+ }
+ }
- protected async _call(input: string): Promise {
- try {
- // Parse and normalize input
- input = input.trim();
- const parsedInput = JSON.parse(input);
+ protected async _call(input: string): Promise {
+ try {
+ // Parse and normalize input
+ input = input.trim();
+ const parsedInput = JSON.parse(input);
- this.validateInput(parsedInput);
+ this.validateInput(parsedInput);
- // Launch token with validated input
- await this.solanaKit.launchPumpFunToken(
- parsedInput.tokenName,
- parsedInput.tokenTicker,
- parsedInput.description,
- parsedInput.imageUrl,
- {
- twitter: parsedInput.twitter,
- telegram: parsedInput.telegram,
- website: parsedInput.website,
- initialLiquiditySOL: parsedInput.initialLiquiditySOL,
- },
- );
+ // Launch token with validated input
+ await this.solanaKit.launchPumpFunToken(
+ parsedInput.tokenName,
+ parsedInput.tokenTicker,
+ parsedInput.description,
+ parsedInput.imageUrl,
+ {
+ twitter: parsedInput.twitter,
+ telegram: parsedInput.telegram,
+ website: parsedInput.website,
+ initialLiquiditySOL: parsedInput.initialLiquiditySOL,
+ },
+ );
- return JSON.stringify({
- status: "success",
- message: "Token launched successfully on Pump.fun",
- tokenName: parsedInput.tokenName,
- tokenTicker: parsedInput.tokenTicker,
- });
- } catch (error: any) {
- return JSON.stringify({
- status: "error",
- message: error.message,
- code: error.code || "UNKNOWN_ERROR",
- });
- }
- }
+ return JSON.stringify({
+ status: "success",
+ message: "Token launched successfully on Pump.fun",
+ tokenName: parsedInput.tokenName,
+ tokenTicker: parsedInput.tokenTicker,
+ });
+ } catch (error: any) {
+ return JSON.stringify({
+ status: "error",
+ message: error.message,
+ code: error.code || "UNKNOWN_ERROR",
+ });
+ }
+ }
}
export class SolanaCreateImageTool extends Tool {
- name = "solana_create_image";
- description =
- "Create an image using OpenAI's DALL-E. Input should be a string prompt for the image.";
+ name = "solana_create_image";
+ description =
+ "Create an image using OpenAI's DALL-E. Input should be a string prompt for the image.";
- constructor(private solanaKit: SolanaAgentKit) {
- super();
- }
+ constructor(private solanaKit: SolanaAgentKit) {
+ super();
+ }
- private validateInput(input: string): void {
- if (typeof input !== "string" || input.trim().length === 0) {
- throw new Error("Input must be a non-empty string prompt");
- }
- }
+ private validateInput(input: string): void {
+ if (typeof input !== "string" || input.trim().length === 0) {
+ throw new Error("Input must be a non-empty string prompt");
+ }
+ }
- protected async _call(input: string): Promise {
- try {
- this.validateInput(input);
- const result = await create_image(this.solanaKit, input.trim());
+ protected async _call(input: string): Promise {
+ try {
+ this.validateInput(input);
+ const result = await create_image(this.solanaKit, input.trim());
- return JSON.stringify({
- status: "success",
- message: "Image created successfully",
- ...result,
- });
- } catch (error: any) {
- return JSON.stringify({
- status: "error",
- message: error.message,
- code: error.code || "UNKNOWN_ERROR",
- });
- }
- }
+ return JSON.stringify({
+ status: "success",
+ message: "Image created successfully",
+ ...result,
+ });
+ } catch (error: any) {
+ return JSON.stringify({
+ status: "error",
+ message: error.message,
+ code: error.code || "UNKNOWN_ERROR",
+ });
+ }
+ }
}
export class SolanaLendAssetTool extends Tool {
- name = "solana_lend_asset";
- description = `Lend idle USDC for yield using Lulo. ( only USDC is supported )
+ name = "solana_lend_asset";
+ description = `Lend idle USDC for yield using Lulo. ( only USDC is supported )
Inputs (input is a json string):
amount: number, eg 1, 0.01 (required)`;
- constructor(private solanaKit: SolanaAgentKit) {
- super();
- }
+ constructor(private solanaKit: SolanaAgentKit) {
+ super();
+ }
- async _call(input: string): Promise {
- try {
- const amount = JSON.parse(input).amount || input;
+ async _call(input: string): Promise {
+ try {
+ const amount = JSON.parse(input).amount || input;
- const tx = await this.solanaKit.lendAssets(amount);
+ const tx = await this.solanaKit.lendAssets(amount);
- return JSON.stringify({
- status: "success",
- message: "Asset lent successfully",
- transaction: tx,
- amount,
- });
- } catch (error: any) {
- return JSON.stringify({
- status: "error",
- message: error.message,
- code: error.code || "UNKNOWN_ERROR",
- });
- }
- }
+ return JSON.stringify({
+ status: "success",
+ message: "Asset lent successfully",
+ transaction: tx,
+ amount,
+ });
+ } catch (error: any) {
+ return JSON.stringify({
+ status: "error",
+ message: error.message,
+ code: error.code || "UNKNOWN_ERROR",
+ });
+ }
+ }
}
export class SolanaTPSCalculatorTool extends Tool {
- name = "solana_get_tps";
- description = "Get the current TPS of the Solana network";
+ name = "solana_get_tps";
+ description = "Get the current TPS of the Solana network";
- constructor(private solanaKit: SolanaAgentKit) {
- super();
- }
+ constructor(private solanaKit: SolanaAgentKit) {
+ super();
+ }
- async _call(_input: string): Promise {
- try {
- const tps = await this.solanaKit.getTPS();
- return `Solana (mainnet-beta) current transactions per second: ${tps}`;
- } catch (error: any) {
- return `Error fetching TPS: ${error.message}`;
- }
- }
+ async _call(_input: string): Promise {
+ try {
+ const tps = await this.solanaKit.getTPS();
+ return `Solana (mainnet-beta) current transactions per second: ${tps}`;
+ } catch (error: any) {
+ return `Error fetching TPS: ${error.message}`;
+ }
+ }
}
export class SolanaStakeTool extends Tool {
- name = "solana_stake";
- description = `This tool can be used to stake your SOL (Solana), also called as SOL staking or liquid staking.
+ name = "solana_stake";
+ description = `This tool can be used to stake your SOL (Solana), also called as SOL staking or liquid staking.
Inputs ( input is a JSON string ):
amount: number, eg 1 or 0.01 (required)`;
- constructor(private solanaKit: SolanaAgentKit) {
- super();
- }
+ constructor(private solanaKit: SolanaAgentKit) {
+ super();
+ }
- protected async _call(input: string): Promise {
- try {
- const parsedInput = JSON.parse(input) || Number(input);
+ protected async _call(input: string): Promise {
+ try {
+ const parsedInput = JSON.parse(input) || Number(input);
- const tx = await this.solanaKit.stake(parsedInput.amount);
+ const tx = await this.solanaKit.stake(parsedInput.amount);
- return JSON.stringify({
- status: "success",
- message: "Staked successfully",
- transaction: tx,
- amount: parsedInput.amount,
- });
- } catch (error: any) {
- return JSON.stringify({
- status: "error",
- message: error.message,
- code: error.code || "UNKNOWN_ERROR",
- });
- }
- }
+ return JSON.stringify({
+ status: "success",
+ message: "Staked successfully",
+ transaction: tx,
+ amount: parsedInput.amount,
+ });
+ } catch (error: any) {
+ return JSON.stringify({
+ status: "error",
+ message: error.message,
+ code: error.code || "UNKNOWN_ERROR",
+ });
+ }
+ }
}
/**
* Tool to fetch the price of a token in USDC
*/
export class SolanaFetchPriceTool extends Tool {
- name = "solana_fetch_price";
- description = `Fetch the price of a given token in USDC.
+ name = "solana_fetch_price";
+ description = `Fetch the price of a given token in USDC.
Inputs:
- tokenId: string, the mint address of the token, e.g., "JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN"`;
- constructor(private solanaKit: SolanaAgentKit) {
- super();
- }
+ constructor(private solanaKit: SolanaAgentKit) {
+ super();
+ }
- async _call(input: string): Promise {
- try {
- const price = await this.solanaKit.fetchTokenPrice(input.trim());
- return JSON.stringify({
- status: "success",
- tokenId: input.trim(),
- priceInUSDC: price,
- });
- } catch (error: any) {
- return JSON.stringify({
- status: "error",
- message: error.message,
- code: error.code || "UNKNOWN_ERROR",
- });
- }
- }
+ async _call(input: string): Promise {
+ try {
+ const price = await this.solanaKit.fetchTokenPrice(input.trim());
+ return JSON.stringify({
+ status: "success",
+ tokenId: input.trim(),
+ priceInUSDC: price,
+ });
+ } catch (error: any) {
+ return JSON.stringify({
+ status: "error",
+ message: error.message,
+ code: error.code || "UNKNOWN_ERROR",
+ });
+ }
+ }
}
export class SolanaTokenDataTool extends Tool {
- name = "solana_token_data";
- description = `Get the token data for a given token mint address
+ name = "solana_token_data";
+ description = `Get the token data for a given token mint address
Inputs: mintAddress is required.
mintAddress: string, eg "So11111111111111111111111111111111111111112" (required)`;
- constructor(private solanaKit: SolanaAgentKit) {
- super();
- }
+ constructor(private solanaKit: SolanaAgentKit) {
+ super();
+ }
- protected async _call(input: string): Promise {
- try {
- const parsedInput = input.trim();
+ protected async _call(input: string): Promise {
+ try {
+ const parsedInput = input.trim();
- const tokenData = await this.solanaKit.getTokenDataByAddress(parsedInput);
+ const tokenData = await this.solanaKit.getTokenDataByAddress(parsedInput);
- return JSON.stringify({
- status: "success",
- tokenData,
- });
- } catch (error: any) {
- return JSON.stringify({
- status: "error",
- message: error.message,
- code: error.code || "UNKNOWN_ERROR",
- });
- }
- }
+ return JSON.stringify({
+ status: "success",
+ tokenData,
+ });
+ } catch (error: any) {
+ return JSON.stringify({
+ status: "error",
+ message: error.message,
+ code: error.code || "UNKNOWN_ERROR",
+ });
+ }
+ }
}
export class SolanaTokenDataByTickerTool extends Tool {
- name = "solana_token_data_by_ticker";
- description = `Get the token data for a given token ticker
+ name = "solana_token_data_by_ticker";
+ description = `Get the token data for a given token ticker
Inputs: ticker is required.
ticker: string, eg "USDC" (required)`;
- constructor(private solanaKit: SolanaAgentKit) {
- super();
- }
+ constructor(private solanaKit: SolanaAgentKit) {
+ super();
+ }
- protected async _call(input: string): Promise {
- try {
- const ticker = input.trim();
- const tokenData = await this.solanaKit.getTokenDataByTicker(ticker);
- return JSON.stringify({
- status: "success",
- tokenData,
- });
- } catch (error: any) {
- return JSON.stringify({
- status: "error",
- message: error.message,
- code: error.code || "UNKNOWN_ERROR",
- });
- }
- }
+ protected async _call(input: string): Promise {
+ try {
+ const ticker = input.trim();
+ const tokenData = await this.solanaKit.getTokenDataByTicker(ticker);
+ return JSON.stringify({
+ status: "success",
+ tokenData,
+ });
+ } catch (error: any) {
+ return JSON.stringify({
+ status: "error",
+ message: error.message,
+ code: error.code || "UNKNOWN_ERROR",
+ });
+ }
+ }
}
export class SolanaCompressedAirdropTool extends Tool {
- name = "solana_compressed_airdrop";
- description = `Airdrop SPL tokens with ZK Compression (also called as airdropping tokens)
+ name = "solana_compressed_airdrop";
+ description = `Airdrop SPL tokens with ZK Compression (also called as airdropping tokens)
Inputs (input is a JSON string):
mintAddress: string, the mint address of the token, e.g., "JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN" (required)
@@ -872,77 +872,77 @@ export class SolanaCompressedAirdropTool extends Tool {
priorityFeeInLamports: number, the priority fee in lamports. Default is 30_000. (optional)
shouldLog: boolean, whether to log progress to stdout. Default is false. (optional)`;
- constructor(private solanaKit: SolanaAgentKit) {
- super();
- }
+ constructor(private solanaKit: SolanaAgentKit) {
+ super();
+ }
- protected async _call(input: string): Promise {
- try {
- const parsedInput = JSON.parse(input);
+ protected async _call(input: string): Promise {
+ try {
+ const parsedInput = JSON.parse(input);
- const txs = await this.solanaKit.sendCompressedAirdrop(
- parsedInput.mintAddress,
- parsedInput.amount,
- parsedInput.decimals,
- parsedInput.recipients,
- parsedInput.priorityFeeInLamports || 30_000,
- parsedInput.shouldLog || false,
- );
+ const txs = await this.solanaKit.sendCompressedAirdrop(
+ parsedInput.mintAddress,
+ parsedInput.amount,
+ parsedInput.decimals,
+ parsedInput.recipients,
+ parsedInput.priorityFeeInLamports || 30_000,
+ parsedInput.shouldLog || false,
+ );
- return JSON.stringify({
- status: "success",
- message: `Airdropped ${parsedInput.amount} tokens to ${parsedInput.recipients.length} recipients.`,
- transactionHashes: txs,
- });
- } catch (error: any) {
- return JSON.stringify({
- status: "error",
- message: error.message,
- code: error.code || "UNKNOWN_ERROR",
- });
- }
- }
+ return JSON.stringify({
+ status: "success",
+ message: `Airdropped ${parsedInput.amount} tokens to ${parsedInput.recipients.length} recipients.`,
+ transactionHashes: txs,
+ });
+ } catch (error: any) {
+ return JSON.stringify({
+ status: "error",
+ message: error.message,
+ code: error.code || "UNKNOWN_ERROR",
+ });
+ }
+ }
}
export class SolanaClosePosition extends Tool {
- name = "orca_close_position";
- description = `Closes an existing liquidity position in an Orca Whirlpool. This function fetches the position
+ name = "orca_close_position";
+ description = `Closes an existing liquidity position in an Orca Whirlpool. This function fetches the position
details using the provided mint address and closes the position with a 1% slippage.
Inputs (JSON string):
- positionMintAddress: string, the address of the position mint that represents the liquidity position.`;
- constructor(private solanaKit: SolanaAgentKit) {
- super();
- }
+ constructor(private solanaKit: SolanaAgentKit) {
+ super();
+ }
- async _call(input: string): Promise {
- try {
- const inputFormat = JSON.parse(input);
- const positionMintAddress = new PublicKey(
- inputFormat.positionMintAddress,
- );
+ async _call(input: string): Promise {
+ try {
+ const inputFormat = JSON.parse(input);
+ const positionMintAddress = new PublicKey(
+ inputFormat.positionMintAddress,
+ );
- const txId = await this.solanaKit.orcaClosePosition(positionMintAddress);
+ const txId = await this.solanaKit.orcaClosePosition(positionMintAddress);
- return JSON.stringify({
- status: "success",
- message: "Liquidity position closed successfully.",
- transaction: txId,
- });
- } catch (error: any) {
- return JSON.stringify({
- status: "error",
- message: error.message,
- code: error.code || "UNKNOWN_ERROR",
- });
- }
- }
+ return JSON.stringify({
+ status: "success",
+ message: "Liquidity position closed successfully.",
+ transaction: txId,
+ });
+ } catch (error: any) {
+ return JSON.stringify({
+ status: "error",
+ message: error.message,
+ code: error.code || "UNKNOWN_ERROR",
+ });
+ }
+ }
}
export class SolanaOrcaCreateCLMM extends Tool {
- name = "orca_create_clmm";
- description = `Create a Concentrated Liquidity Market Maker (CLMM) pool on Orca, the most efficient and capital-optimized CLMM on Solana. This function initializes a CLMM pool but does not add liquidity. You can add liquidity later using a centered position or a single-sided position.
+ name = "orca_create_clmm";
+ description = `Create a Concentrated Liquidity Market Maker (CLMM) pool on Orca, the most efficient and capital-optimized CLMM on Solana. This function initializes a CLMM pool but does not add liquidity. You can add liquidity later using a centered position or a single-sided position.
Inputs (JSON string):
- mintDeploy: string, the mint of the token you want to deploy (required).
@@ -950,52 +950,52 @@ export class SolanaOrcaCreateCLMM extends Tool {
- initialPrice: number, initial price of mintA in terms of mintB, e.g., 0.001 (required).
- feeTier: number, fee tier in bps. Options: 1, 2, 4, 5, 16, 30, 65, 100, 200 (required).`;
- constructor(private solanaKit: SolanaAgentKit) {
- super();
- }
+ constructor(private solanaKit: SolanaAgentKit) {
+ super();
+ }
- async _call(input: string): Promise {
- try {
- const inputFormat = JSON.parse(input);
- const mintA = new PublicKey(inputFormat.mintDeploy);
- const mintB = new PublicKey(inputFormat.mintPair);
- const initialPrice = new Decimal(inputFormat.initialPrice);
- const feeTier = inputFormat.feeTier;
+ async _call(input: string): Promise {
+ try {
+ const inputFormat = JSON.parse(input);
+ const mintA = new PublicKey(inputFormat.mintDeploy);
+ const mintB = new PublicKey(inputFormat.mintPair);
+ const initialPrice = new Decimal(inputFormat.initialPrice);
+ const feeTier = inputFormat.feeTier;
- if (!feeTier || !(feeTier in FEE_TIERS)) {
- throw new Error(
- `Invalid feeTier. Available options: ${Object.keys(FEE_TIERS).join(
- ", ",
- )}`,
- );
- }
+ if (!feeTier || !(feeTier in FEE_TIERS)) {
+ throw new Error(
+ `Invalid feeTier. Available options: ${Object.keys(FEE_TIERS).join(
+ ", ",
+ )}`,
+ );
+ }
- const txId = await this.solanaKit.orcaCreateCLMM(
- mintA,
- mintB,
- initialPrice,
- feeTier,
- );
+ const txId = await this.solanaKit.orcaCreateCLMM(
+ mintA,
+ mintB,
+ initialPrice,
+ feeTier,
+ );
- return JSON.stringify({
- status: "success",
- message:
- "CLMM pool created successfully. Note: No liquidity was added.",
- transaction: txId,
- });
- } catch (error: any) {
- return JSON.stringify({
- status: "error",
- message: error.message,
- code: error.code || "UNKNOWN_ERROR",
- });
- }
- }
+ return JSON.stringify({
+ status: "success",
+ message:
+ "CLMM pool created successfully. Note: No liquidity was added.",
+ transaction: txId,
+ });
+ } catch (error: any) {
+ return JSON.stringify({
+ status: "error",
+ message: error.message,
+ code: error.code || "UNKNOWN_ERROR",
+ });
+ }
+ }
}
export class SolanaOrcaCreateSingleSideLiquidityPool extends Tool {
- name = "orca_create_single_sided_liquidity_pool";
- description = `Create a single-sided liquidity pool on Orca, the most efficient and capital-optimized CLMM platform on Solana.
+ name = "orca_create_single_sided_liquidity_pool";
+ description = `Create a single-sided liquidity pool on Orca, the most efficient and capital-optimized CLMM platform on Solana.
This function initializes a single-sided liquidity pool, ideal for community driven project, fair launches, and fundraising. Minimize price impact by setting a narrow price range.
@@ -1007,82 +1007,82 @@ export class SolanaOrcaCreateSingleSideLiquidityPool extends Tool {
- maxPrice: number, maximum price at which liquidity is added, e.g., 5.0 (required).
- feeTier: number, fee tier for the pool in bps. Options: 1, 2, 4, 5, 16, 30, 65, 100, 200 (required).`;
- constructor(private solanaKit: SolanaAgentKit) {
- super();
- }
+ constructor(private solanaKit: SolanaAgentKit) {
+ super();
+ }
- async _call(input: string): Promise {
- try {
- const inputFormat = JSON.parse(input);
- const depositTokenAmount = inputFormat.depositTokenAmount;
- const depositTokenMint = new PublicKey(inputFormat.depositTokenMint);
- const otherTokenMint = new PublicKey(inputFormat.otherTokenMint);
- const initialPrice = new Decimal(inputFormat.initialPrice);
- const maxPrice = new Decimal(inputFormat.maxPrice);
- const feeTier = inputFormat.feeTier;
+ async _call(input: string): Promise {
+ try {
+ const inputFormat = JSON.parse(input);
+ const depositTokenAmount = inputFormat.depositTokenAmount;
+ const depositTokenMint = new PublicKey(inputFormat.depositTokenMint);
+ const otherTokenMint = new PublicKey(inputFormat.otherTokenMint);
+ const initialPrice = new Decimal(inputFormat.initialPrice);
+ const maxPrice = new Decimal(inputFormat.maxPrice);
+ const feeTier = inputFormat.feeTier;
- if (!feeTier || !(feeTier in FEE_TIERS)) {
- throw new Error(
- `Invalid feeTier. Available options: ${Object.keys(FEE_TIERS).join(
- ", ",
- )}`,
- );
- }
+ if (!feeTier || !(feeTier in FEE_TIERS)) {
+ throw new Error(
+ `Invalid feeTier. Available options: ${Object.keys(FEE_TIERS).join(
+ ", ",
+ )}`,
+ );
+ }
- const txId = await this.solanaKit.orcaCreateSingleSidedLiquidityPool(
- depositTokenAmount,
- depositTokenMint,
- otherTokenMint,
- initialPrice,
- maxPrice,
- feeTier,
- );
+ const txId = await this.solanaKit.orcaCreateSingleSidedLiquidityPool(
+ depositTokenAmount,
+ depositTokenMint,
+ otherTokenMint,
+ initialPrice,
+ maxPrice,
+ feeTier,
+ );
- return JSON.stringify({
- status: "success",
- message: "Single-sided Whirlpool created successfully",
- transaction: txId,
- });
- } catch (error: any) {
- return JSON.stringify({
- status: "error",
- message: error.message,
- code: error.code || "UNKNOWN_ERROR",
- });
- }
- }
+ return JSON.stringify({
+ status: "success",
+ message: "Single-sided Whirlpool created successfully",
+ transaction: txId,
+ });
+ } catch (error: any) {
+ return JSON.stringify({
+ status: "error",
+ message: error.message,
+ code: error.code || "UNKNOWN_ERROR",
+ });
+ }
+ }
}
export class SolanaOrcaFetchPositions extends Tool {
- name = "orca_fetch_positions";
- description = `Fetch all the liquidity positions in an Orca Whirlpool by owner. Returns an object with positiont mint addresses as keys and position status details as values.`;
+ name = "orca_fetch_positions";
+ description = `Fetch all the liquidity positions in an Orca Whirlpool by owner. Returns an object with positiont mint addresses as keys and position status details as values.`;
- constructor(private solanaKit: SolanaAgentKit) {
- super();
- }
+ constructor(private solanaKit: SolanaAgentKit) {
+ super();
+ }
- async _call(): Promise {
- try {
- const txId = await this.solanaKit.orcaFetchPositions();
+ async _call(): Promise {
+ try {
+ const txId = await this.solanaKit.orcaFetchPositions();
- return JSON.stringify({
- status: "success",
- message: "Liquidity positions fetched.",
- transaction: txId,
- });
- } catch (error: any) {
- return JSON.stringify({
- status: "error",
- message: error.message,
- code: error.code || "UNKNOWN_ERROR",
- });
- }
- }
+ return JSON.stringify({
+ status: "success",
+ message: "Liquidity positions fetched.",
+ transaction: txId,
+ });
+ } catch (error: any) {
+ return JSON.stringify({
+ status: "error",
+ message: error.message,
+ code: error.code || "UNKNOWN_ERROR",
+ });
+ }
+ }
}
export class SolanaOrcaOpenCenteredPosition extends Tool {
- name = "orca_open_centered_position_with_liquidity";
- description = `Add liquidity to a CLMM by opening a centered position in an Orca Whirlpool, the most efficient liquidity pool on Solana.
+ name = "orca_open_centered_position_with_liquidity";
+ description = `Add liquidity to a CLMM by opening a centered position in an Orca Whirlpool, the most efficient liquidity pool on Solana.
Inputs (JSON string):
- whirlpoolAddress: string, address of the Orca Whirlpool (required).
@@ -1090,49 +1090,49 @@ export class SolanaOrcaOpenCenteredPosition extends Tool {
- inputTokenMint: string, mint address of the deposit token (required).
- inputAmount: number, amount of the deposit token, e.g., 100.0 (required).`;
- constructor(private solanaKit: SolanaAgentKit) {
- super();
- }
+ constructor(private solanaKit: SolanaAgentKit) {
+ super();
+ }
- async _call(input: string): Promise {
- try {
- const inputFormat = JSON.parse(input);
- const whirlpoolAddress = new PublicKey(inputFormat.whirlpoolAddress);
- const priceOffsetBps = parseInt(inputFormat.priceOffsetBps, 10);
- const inputTokenMint = new PublicKey(inputFormat.inputTokenMint);
- const inputAmount = new Decimal(inputFormat.inputAmount);
+ async _call(input: string): Promise {
+ try {
+ const inputFormat = JSON.parse(input);
+ const whirlpoolAddress = new PublicKey(inputFormat.whirlpoolAddress);
+ const priceOffsetBps = parseInt(inputFormat.priceOffsetBps, 10);
+ const inputTokenMint = new PublicKey(inputFormat.inputTokenMint);
+ const inputAmount = new Decimal(inputFormat.inputAmount);
- if (priceOffsetBps < 0) {
- throw new Error(
- "Invalid distanceFromCurrentPriceBps. It must be equal or greater than 0.",
- );
- }
+ if (priceOffsetBps < 0) {
+ throw new Error(
+ "Invalid distanceFromCurrentPriceBps. It must be equal or greater than 0.",
+ );
+ }
- const txId = await this.solanaKit.orcaOpenCenteredPositionWithLiquidity(
- whirlpoolAddress,
- priceOffsetBps,
- inputTokenMint,
- inputAmount,
- );
+ const txId = await this.solanaKit.orcaOpenCenteredPositionWithLiquidity(
+ whirlpoolAddress,
+ priceOffsetBps,
+ inputTokenMint,
+ inputAmount,
+ );
- return JSON.stringify({
- status: "success",
- message: "Centered liquidity position opened successfully.",
- transaction: txId,
- });
- } catch (error: any) {
- return JSON.stringify({
- status: "error",
- message: error.message,
- code: error.code || "UNKNOWN_ERROR",
- });
- }
- }
+ return JSON.stringify({
+ status: "success",
+ message: "Centered liquidity position opened successfully.",
+ transaction: txId,
+ });
+ } catch (error: any) {
+ return JSON.stringify({
+ status: "error",
+ message: error.message,
+ code: error.code || "UNKNOWN_ERROR",
+ });
+ }
+ }
}
export class SolanaOrcaOpenSingleSidedPosition extends Tool {
- name = "orca_open_single_sided_position";
- description = `Add liquidity to a CLMM by opening a single-sided position in an Orca Whirlpool, the most efficient liquidity pool on Solana.
+ name = "orca_open_single_sided_position";
+ description = `Add liquidity to a CLMM by opening a single-sided position in an Orca Whirlpool, the most efficient liquidity pool on Solana.
Inputs (JSON string):
- whirlpoolAddress: string, address of the Orca Whirlpool (required).
@@ -1141,52 +1141,52 @@ export class SolanaOrcaOpenSingleSidedPosition extends Tool {
- inputTokenMint: string, mint address of the deposit token (required).
- inputAmount: number, amount of the deposit token, e.g., 100.0 (required).`;
- constructor(private solanaKit: SolanaAgentKit) {
- super();
- }
+ constructor(private solanaKit: SolanaAgentKit) {
+ super();
+ }
- async _call(input: string): Promise {
- try {
- const inputFormat = JSON.parse(input);
- const whirlpoolAddress = new PublicKey(inputFormat.whirlpoolAddress);
- const distanceFromCurrentPriceBps =
- inputFormat.distanceFromCurrentPriceBps;
- const widthBps = inputFormat.widthBps;
- const inputTokenMint = new PublicKey(inputFormat.inputTokenMint);
- const inputAmount = new Decimal(inputFormat.inputAmount);
+ async _call(input: string): Promise {
+ try {
+ const inputFormat = JSON.parse(input);
+ const whirlpoolAddress = new PublicKey(inputFormat.whirlpoolAddress);
+ const distanceFromCurrentPriceBps =
+ inputFormat.distanceFromCurrentPriceBps;
+ const widthBps = inputFormat.widthBps;
+ const inputTokenMint = new PublicKey(inputFormat.inputTokenMint);
+ const inputAmount = new Decimal(inputFormat.inputAmount);
- if (distanceFromCurrentPriceBps < 0 || widthBps < 0) {
- throw new Error(
- "Invalid distanceFromCurrentPriceBps or width. It must be equal or greater than 0.",
- );
- }
+ if (distanceFromCurrentPriceBps < 0 || widthBps < 0) {
+ throw new Error(
+ "Invalid distanceFromCurrentPriceBps or width. It must be equal or greater than 0.",
+ );
+ }
- const txId = await this.solanaKit.orcaOpenSingleSidedPosition(
- whirlpoolAddress,
- distanceFromCurrentPriceBps,
- widthBps,
- inputTokenMint,
- inputAmount,
- );
+ const txId = await this.solanaKit.orcaOpenSingleSidedPosition(
+ whirlpoolAddress,
+ distanceFromCurrentPriceBps,
+ widthBps,
+ inputTokenMint,
+ inputAmount,
+ );
- return JSON.stringify({
- status: "success",
- message: "Single-sided liquidity position opened successfully.",
- transaction: txId,
- });
- } catch (error: any) {
- return JSON.stringify({
- status: "error",
- message: error.message,
- code: error.code || "UNKNOWN_ERROR",
- });
- }
- }
+ return JSON.stringify({
+ status: "success",
+ message: "Single-sided liquidity position opened successfully.",
+ transaction: txId,
+ });
+ } catch (error: any) {
+ return JSON.stringify({
+ status: "error",
+ message: error.message,
+ code: error.code || "UNKNOWN_ERROR",
+ });
+ }
+ }
}
export class SolanaRaydiumCreateAmmV4 extends Tool {
- name = "raydium_create_ammV4";
- description = `Raydium's Legacy AMM that requires an OpenBook marketID
+ name = "raydium_create_ammV4";
+ description = `Raydium's Legacy AMM that requires an OpenBook marketID
Inputs (input is a json string):
marketId: string (required)
@@ -1195,39 +1195,39 @@ export class SolanaRaydiumCreateAmmV4 extends Tool {
startTime: number(seconds), eg: now number or zero (required)
`;
- constructor(private solanaKit: SolanaAgentKit) {
- super();
- }
+ constructor(private solanaKit: SolanaAgentKit) {
+ super();
+ }
- async _call(input: string): Promise {
- try {
- const inputFormat = JSON.parse(input);
+ async _call(input: string): Promise {
+ try {
+ const inputFormat = JSON.parse(input);
- const tx = await this.solanaKit.raydiumCreateAmmV4(
- new PublicKey(inputFormat.marketId),
- new BN(inputFormat.baseAmount),
- new BN(inputFormat.quoteAmount),
- new BN(inputFormat.startTime),
- );
+ const tx = await this.solanaKit.raydiumCreateAmmV4(
+ new PublicKey(inputFormat.marketId),
+ new BN(inputFormat.baseAmount),
+ new BN(inputFormat.quoteAmount),
+ new BN(inputFormat.startTime),
+ );
- return JSON.stringify({
- status: "success",
- message: "Raydium amm v4 pool created successfully",
- transaction: tx,
- });
- } catch (error: any) {
- return JSON.stringify({
- status: "error",
- message: error.message,
- code: error.code || "UNKNOWN_ERROR",
- });
- }
- }
+ return JSON.stringify({
+ status: "success",
+ message: "Raydium amm v4 pool created successfully",
+ transaction: tx,
+ });
+ } catch (error: any) {
+ return JSON.stringify({
+ status: "error",
+ message: error.message,
+ code: error.code || "UNKNOWN_ERROR",
+ });
+ }
+ }
}
export class SolanaRaydiumCreateClmm extends Tool {
- name = "raydium_create_clmm";
- description = `Concentrated liquidity market maker, custom liquidity ranges, increased capital efficiency
+ name = "raydium_create_clmm";
+ description = `Concentrated liquidity market maker, custom liquidity ranges, increased capital efficiency
Inputs (input is a json string):
mint1: string (required)
@@ -1237,42 +1237,42 @@ export class SolanaRaydiumCreateClmm extends Tool {
startTime: number(seconds), eg: now number or zero (required)
`;
- constructor(private solanaKit: SolanaAgentKit) {
- super();
- }
+ constructor(private solanaKit: SolanaAgentKit) {
+ super();
+ }
- async _call(input: string): Promise {
- try {
- const inputFormat = JSON.parse(input);
+ async _call(input: string): Promise {
+ try {
+ const inputFormat = JSON.parse(input);
- const tx = await this.solanaKit.raydiumCreateClmm(
- new PublicKey(inputFormat.mint1),
- new PublicKey(inputFormat.mint2),
+ const tx = await this.solanaKit.raydiumCreateClmm(
+ new PublicKey(inputFormat.mint1),
+ new PublicKey(inputFormat.mint2),
- new PublicKey(inputFormat.configId),
+ new PublicKey(inputFormat.configId),
- new Decimal(inputFormat.initialPrice),
- new BN(inputFormat.startTime),
- );
+ new Decimal(inputFormat.initialPrice),
+ new BN(inputFormat.startTime),
+ );
- return JSON.stringify({
- status: "success",
- message: "Raydium clmm pool created successfully",
- transaction: tx,
- });
- } catch (error: any) {
- return JSON.stringify({
- status: "error",
- message: error.message,
- code: error.code || "UNKNOWN_ERROR",
- });
- }
- }
+ return JSON.stringify({
+ status: "success",
+ message: "Raydium clmm pool created successfully",
+ transaction: tx,
+ });
+ } catch (error: any) {
+ return JSON.stringify({
+ status: "error",
+ message: error.message,
+ code: error.code || "UNKNOWN_ERROR",
+ });
+ }
+ }
}
export class SolanaRaydiumCreateCpmm extends Tool {
- name = "raydium_create_cpmm";
- description = `Raydium's newest CPMM, does not require marketID, supports Token 2022 standard
+ name = "raydium_create_cpmm";
+ description = `Raydium's newest CPMM, does not require marketID, supports Token 2022 standard
Inputs (input is a json string):
mint1: string (required)
@@ -1283,44 +1283,44 @@ export class SolanaRaydiumCreateCpmm extends Tool {
startTime: number(seconds), eg: now number or zero (required)
`;
- constructor(private solanaKit: SolanaAgentKit) {
- super();
- }
+ constructor(private solanaKit: SolanaAgentKit) {
+ super();
+ }
- async _call(input: string): Promise {
- try {
- const inputFormat = JSON.parse(input);
+ async _call(input: string): Promise {
+ try {
+ const inputFormat = JSON.parse(input);
- const tx = await this.solanaKit.raydiumCreateCpmm(
- new PublicKey(inputFormat.mint1),
- new PublicKey(inputFormat.mint2),
+ const tx = await this.solanaKit.raydiumCreateCpmm(
+ new PublicKey(inputFormat.mint1),
+ new PublicKey(inputFormat.mint2),
- new PublicKey(inputFormat.configId),
+ new PublicKey(inputFormat.configId),
- new BN(inputFormat.mintAAmount),
- new BN(inputFormat.mintBAmount),
+ new BN(inputFormat.mintAAmount),
+ new BN(inputFormat.mintBAmount),
- new BN(inputFormat.startTime),
- );
+ new BN(inputFormat.startTime),
+ );
- return JSON.stringify({
- status: "success",
- message: "Raydium cpmm pool created successfully",
- transaction: tx,
- });
- } catch (error: any) {
- return JSON.stringify({
- status: "error",
- message: error.message,
- code: error.code || "UNKNOWN_ERROR",
- });
- }
- }
+ return JSON.stringify({
+ status: "success",
+ message: "Raydium cpmm pool created successfully",
+ transaction: tx,
+ });
+ } catch (error: any) {
+ return JSON.stringify({
+ status: "error",
+ message: error.message,
+ code: error.code || "UNKNOWN_ERROR",
+ });
+ }
+ }
}
export class SolanaOpenbookCreateMarket extends Tool {
- name = "solana_openbook_create_market";
- description = `Openbook marketId, required for ammv4
+ name = "solana_openbook_create_market";
+ description = `Openbook marketId, required for ammv4
Inputs (input is a json string):
baseMint: string (required)
@@ -1329,270 +1329,270 @@ export class SolanaOpenbookCreateMarket extends Tool {
tickSize: number (required)
`;
- constructor(private solanaKit: SolanaAgentKit) {
- super();
- }
+ constructor(private solanaKit: SolanaAgentKit) {
+ super();
+ }
- async _call(input: string): Promise {
- try {
- const inputFormat = JSON.parse(input);
+ async _call(input: string): Promise {
+ try {
+ const inputFormat = JSON.parse(input);
- const tx = await this.solanaKit.openbookCreateMarket(
- new PublicKey(inputFormat.baseMint),
- new PublicKey(inputFormat.quoteMint),
+ const tx = await this.solanaKit.openbookCreateMarket(
+ new PublicKey(inputFormat.baseMint),
+ new PublicKey(inputFormat.quoteMint),
- inputFormat.lotSize,
- inputFormat.tickSize,
- );
+ inputFormat.lotSize,
+ inputFormat.tickSize,
+ );
- return JSON.stringify({
- status: "success",
- message: "Openbook market created successfully",
- transaction: tx,
- });
- } catch (error: any) {
- return JSON.stringify({
- status: "error",
- message: error.message,
- code: error.code || "UNKNOWN_ERROR",
- });
- }
- }
+ return JSON.stringify({
+ status: "success",
+ message: "Openbook market created successfully",
+ transaction: tx,
+ });
+ } catch (error: any) {
+ return JSON.stringify({
+ status: "error",
+ message: error.message,
+ code: error.code || "UNKNOWN_ERROR",
+ });
+ }
+ }
}
export class SolanaManifestCreateMarket extends Tool {
- name = "solana_manifest_create_market";
- description = `Manifest market
+ name = "solana_manifest_create_market";
+ description = `Manifest market
Inputs (input is a json string):
baseMint: string (required)
quoteMint: string (required)
`;
- constructor(private solanaKit: SolanaAgentKit) {
- super();
- }
+ constructor(private solanaKit: SolanaAgentKit) {
+ super();
+ }
- async _call(input: string): Promise {
- try {
- const inputFormat = JSON.parse(input);
+ async _call(input: string): Promise {
+ try {
+ const inputFormat = JSON.parse(input);
- const tx = await this.solanaKit.manifestCreateMarket(
- new PublicKey(inputFormat.baseMint),
- new PublicKey(inputFormat.quoteMint),
- );
+ const tx = await this.solanaKit.manifestCreateMarket(
+ new PublicKey(inputFormat.baseMint),
+ new PublicKey(inputFormat.quoteMint),
+ );
- return JSON.stringify({
- status: "success",
- message: "Create manifest market successfully",
- transaction: tx[0],
- marketId: tx[1],
- });
- } catch (error: any) {
- return JSON.stringify({
- status: "error",
- message: error.message,
- code: error.code || "UNKNOWN_ERROR",
- });
- }
- }
+ return JSON.stringify({
+ status: "success",
+ message: "Create manifest market successfully",
+ transaction: tx[0],
+ marketId: tx[1],
+ });
+ } catch (error: any) {
+ return JSON.stringify({
+ status: "error",
+ message: error.message,
+ code: error.code || "UNKNOWN_ERROR",
+ });
+ }
+ }
}
export class SolanaPythFetchPrice extends Tool {
- name = "solana_pyth_fetch_price";
- description = `Fetch the price of a given price feed from Pyth's Hermes service
+ name = "solana_pyth_fetch_price";
+ description = `Fetch the price of a given price feed from Pyth's Hermes service
Inputs:
priceFeedID: string, the price feed ID, e.g., "0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43" for BTC/USD`;
- constructor(private solanaKit: SolanaAgentKit) {
- super();
- }
+ constructor(private solanaKit: SolanaAgentKit) {
+ super();
+ }
- async _call(input: string): Promise {
- try {
- const price = await this.solanaKit.pythFetchPrice(input);
- const response: PythFetchPriceResponse = {
- status: "success",
- priceFeedID: input,
- price,
- };
- return JSON.stringify(response);
- } catch (error: any) {
- const response: PythFetchPriceResponse = {
- status: "error",
- priceFeedID: input,
- message: error.message,
- code: error.code || "UNKNOWN_ERROR",
- };
- return JSON.stringify(response);
- }
- }
+ async _call(input: string): Promise {
+ try {
+ const price = await this.solanaKit.pythFetchPrice(input);
+ const response: PythFetchPriceResponse = {
+ status: "success",
+ priceFeedID: input,
+ price,
+ };
+ return JSON.stringify(response);
+ } catch (error: any) {
+ const response: PythFetchPriceResponse = {
+ status: "error",
+ priceFeedID: input,
+ message: error.message,
+ code: error.code || "UNKNOWN_ERROR",
+ };
+ return JSON.stringify(response);
+ }
+ }
}
export class SolanaResolveAllDomainsTool extends Tool {
- name = "solana_resolve_all_domains";
- description = `Resolve domain names to a public key for ALL domain types EXCEPT .sol domains.
+ name = "solana_resolve_all_domains";
+ description = `Resolve domain names to a public key for ALL domain types EXCEPT .sol domains.
Use this for domains like .blink, .bonk, etc.
DO NOT use this for .sol domains (use solana_resolve_domain instead).
Input:
domain: string, eg "mydomain.blink" or "mydomain.bonk" (required)`;
- constructor(private solanaKit: SolanaAgentKit) {
- super();
- }
+ constructor(private solanaKit: SolanaAgentKit) {
+ super();
+ }
- async _call(input: string): Promise {
- try {
- const owner = await this.solanaKit.resolveAllDomains(input);
+ async _call(input: string): Promise {
+ try {
+ const owner = await this.solanaKit.resolveAllDomains(input);
- if (!owner) {
- return JSON.stringify({
- status: "error",
- message: "Domain not found",
- code: "DOMAIN_NOT_FOUND",
- });
- }
+ if (!owner) {
+ return JSON.stringify({
+ status: "error",
+ message: "Domain not found",
+ code: "DOMAIN_NOT_FOUND",
+ });
+ }
- return JSON.stringify({
- status: "success",
- message: "Domain resolved successfully",
- owner: owner?.toString(),
- });
- } catch (error: any) {
- return JSON.stringify({
- status: "error",
- message: error.message,
- code: error.code || "DOMAIN_RESOLUTION_ERROR",
- });
- }
- }
+ return JSON.stringify({
+ status: "success",
+ message: "Domain resolved successfully",
+ owner: owner?.toString(),
+ });
+ } catch (error: any) {
+ return JSON.stringify({
+ status: "error",
+ message: error.message,
+ code: error.code || "DOMAIN_RESOLUTION_ERROR",
+ });
+ }
+ }
}
export class SolanaGetOwnedDomains extends Tool {
- name = "solana_get_owned_domains";
- description = `Get all domains owned by a specific wallet address.
+ name = "solana_get_owned_domains";
+ description = `Get all domains owned by a specific wallet address.
Inputs:
owner: string, eg "4Be9CvxqHW6BYiRAxW9Q3xu1ycTMWaL5z8NX4HR3ha7t" (required)`;
- constructor(private solanaKit: SolanaAgentKit) {
- super();
- }
+ constructor(private solanaKit: SolanaAgentKit) {
+ super();
+ }
- async _call(input: string): Promise {
- try {
- const ownerPubkey = new PublicKey(input.trim());
- const domains = await this.solanaKit.getOwnedAllDomains(ownerPubkey);
+ async _call(input: string): Promise {
+ try {
+ const ownerPubkey = new PublicKey(input.trim());
+ const domains = await this.solanaKit.getOwnedAllDomains(ownerPubkey);
- return JSON.stringify({
- status: "success",
- message: "Owned domains fetched successfully",
- domains,
- });
- } catch (error: any) {
- return JSON.stringify({
- status: "error",
- message: error.message,
- code: error.code || "FETCH_OWNED_DOMAINS_ERROR",
- });
- }
- }
+ return JSON.stringify({
+ status: "success",
+ message: "Owned domains fetched successfully",
+ domains,
+ });
+ } catch (error: any) {
+ return JSON.stringify({
+ status: "error",
+ message: error.message,
+ code: error.code || "FETCH_OWNED_DOMAINS_ERROR",
+ });
+ }
+ }
}
export class SolanaGetOwnedTldDomains extends Tool {
- name = "solana_get_owned_tld_domains";
- description = `Get all domains owned by the agent's wallet for a specific TLD.
+ name = "solana_get_owned_tld_domains";
+ description = `Get all domains owned by the agent's wallet for a specific TLD.
Inputs:
tld: string, eg "bonk" (required)`;
- constructor(private solanaKit: SolanaAgentKit) {
- super();
- }
+ constructor(private solanaKit: SolanaAgentKit) {
+ super();
+ }
- async _call(input: string): Promise {
- try {
- const domains = await this.solanaKit.getOwnedDomainsForTLD(input);
+ async _call(input: string): Promise {
+ try {
+ const domains = await this.solanaKit.getOwnedDomainsForTLD(input);
- return JSON.stringify({
- status: "success",
- message: "TLD domains fetched successfully",
- domains,
- });
- } catch (error: any) {
- return JSON.stringify({
- status: "error",
- message: error.message,
- code: error.code || "FETCH_TLD_DOMAINS_ERROR",
- });
- }
- }
+ return JSON.stringify({
+ status: "success",
+ message: "TLD domains fetched successfully",
+ domains,
+ });
+ } catch (error: any) {
+ return JSON.stringify({
+ status: "error",
+ message: error.message,
+ code: error.code || "FETCH_TLD_DOMAINS_ERROR",
+ });
+ }
+ }
}
export class SolanaGetAllTlds extends Tool {
- name = "solana_get_all_tlds";
- description = `Get all active top-level domains (TLDs) in the AllDomains Name Service`;
+ name = "solana_get_all_tlds";
+ description = `Get all active top-level domains (TLDs) in the AllDomains Name Service`;
- constructor(private solanaKit: SolanaAgentKit) {
- super();
- }
+ constructor(private solanaKit: SolanaAgentKit) {
+ super();
+ }
- async _call(): Promise {
- try {
- const tlds = await this.solanaKit.getAllDomainsTLDs();
+ async _call(): Promise {
+ try {
+ const tlds = await this.solanaKit.getAllDomainsTLDs();
- return JSON.stringify({
- status: "success",
- message: "TLDs fetched successfully",
- tlds,
- });
- } catch (error: any) {
- return JSON.stringify({
- status: "error",
- message: error.message,
- code: error.code || "FETCH_TLDS_ERROR",
- });
- }
- }
+ return JSON.stringify({
+ status: "success",
+ message: "TLDs fetched successfully",
+ tlds,
+ });
+ } catch (error: any) {
+ return JSON.stringify({
+ status: "error",
+ message: error.message,
+ code: error.code || "FETCH_TLDS_ERROR",
+ });
+ }
+ }
}
export class SolanaGetMainDomain extends Tool {
- name = "solana_get_main_domain";
- description = `Get the main/favorite domain for a given wallet address.
+ name = "solana_get_main_domain";
+ description = `Get the main/favorite domain for a given wallet address.
Inputs:
owner: string, eg "4Be9CvxqHW6BYiRAxW9Q3xu1ycTMWaL5z8NX4HR3ha7t" (required)`;
- constructor(private solanaKit: SolanaAgentKit) {
- super();
- }
+ constructor(private solanaKit: SolanaAgentKit) {
+ super();
+ }
- async _call(input: string): Promise {
- try {
- const ownerPubkey = new PublicKey(input.trim());
- const mainDomain =
- await this.solanaKit.getMainAllDomainsDomain(ownerPubkey);
+ async _call(input: string): Promise {
+ try {
+ const ownerPubkey = new PublicKey(input.trim());
+ const mainDomain =
+ await this.solanaKit.getMainAllDomainsDomain(ownerPubkey);
- return JSON.stringify({
- status: "success",
- message: "Main domain fetched successfully",
- domain: mainDomain,
- });
- } catch (error: any) {
- return JSON.stringify({
- status: "error",
- message: error.message,
- code: error.code || "FETCH_MAIN_DOMAIN_ERROR",
- });
- }
- }
+ return JSON.stringify({
+ status: "success",
+ message: "Main domain fetched successfully",
+ domain: mainDomain,
+ });
+ } catch (error: any) {
+ return JSON.stringify({
+ status: "error",
+ message: error.message,
+ code: error.code || "FETCH_MAIN_DOMAIN_ERROR",
+ });
+ }
+ }
}
export class SolanaCreateGibworkTask extends Tool {
- name = "create_gibwork_task";
- description = `Create a task on Gibwork.
+ name = "create_gibwork_task";
+ description = `Create a task on Gibwork.
Inputs (input is a JSON string):
title: string, title of the task (required)
@@ -1604,274 +1604,274 @@ export class SolanaCreateGibworkTask extends Tool {
amount: number, payment amount (required)
`;
- constructor(private solanaSdk: SolanaAgentKit) {
- super();
- }
+ constructor(private solanaSdk: SolanaAgentKit) {
+ super();
+ }
- protected async _call(input: string): Promise {
- try {
- const parsedInput = JSON.parse(input);
+ protected async _call(input: string): Promise {
+ try {
+ const parsedInput = JSON.parse(input);
- const taskData = await this.solanaSdk.createGibworkTask(
- parsedInput.title,
- parsedInput.content,
- parsedInput.requirements,
- parsedInput.tags,
- parsedInput.tokenMintAddress,
- parsedInput.amount,
- parsedInput.payer,
- );
+ const taskData = await this.solanaSdk.createGibworkTask(
+ parsedInput.title,
+ parsedInput.content,
+ parsedInput.requirements,
+ parsedInput.tags,
+ parsedInput.tokenMintAddress,
+ parsedInput.amount,
+ parsedInput.payer,
+ );
- const response: GibworkCreateTaskReponse = {
- status: "success",
- taskId: taskData.taskId,
- signature: taskData.signature,
- };
+ const response: GibworkCreateTaskReponse = {
+ status: "success",
+ taskId: taskData.taskId,
+ signature: taskData.signature,
+ };
- return JSON.stringify(response);
- } catch (err: any) {
- return JSON.stringify({
- status: "error",
- message: err.message,
- code: err.code || "CREATE_TASK_ERROR",
- });
- }
- }
+ return JSON.stringify(response);
+ } catch (err: any) {
+ return JSON.stringify({
+ status: "error",
+ message: err.message,
+ code: err.code || "CREATE_TASK_ERROR",
+ });
+ }
+ }
}
export class SolanaRockPaperScissorsTool extends Tool {
- name = "rock_paper_scissors";
- description = `Play rock paper scissors to win SEND coins.
+ name = "rock_paper_scissors";
+ description = `Play rock paper scissors to win SEND coins.
Inputs (input is a JSON string):
choice: string, either "rock", "paper", or "scissors" (required)
amount: number, amount of SOL to play with - must be 0.1, 0.01, or 0.005 SOL (required)`;
- constructor(private solanaKit: SolanaAgentKit) {
- super();
- }
+ constructor(private solanaKit: SolanaAgentKit) {
+ super();
+ }
- private validateInput(input: any): void {
- if (input.choice !== undefined) {
- throw new Error("choice is required.");
- }
- if (
- input.amount !== undefined &&
- (typeof input.spaceKB !== "number" || input.spaceKB <= 0)
- ) {
- throw new Error("amount must be a positive number when provided");
- }
- }
+ private validateInput(input: any): void {
+ if (input.choice !== undefined) {
+ throw new Error("choice is required.");
+ }
+ if (
+ input.amount !== undefined &&
+ (typeof input.spaceKB !== "number" || input.spaceKB <= 0)
+ ) {
+ throw new Error("amount must be a positive number when provided");
+ }
+ }
- protected async _call(input: string): Promise {
- try {
- const parsedInput = JSON.parse(input);
- this.validateInput(parsedInput);
- const result = await this.solanaKit.rockPaperScissors(
- Number(parsedInput['"amount"']),
- parsedInput['"choice"'].replace(/^"|"$/g, "") as
- | "rock"
- | "paper"
- | "scissors",
- );
+ protected async _call(input: string): Promise {
+ try {
+ const parsedInput = JSON.parse(input);
+ this.validateInput(parsedInput);
+ const result = await this.solanaKit.rockPaperScissors(
+ Number(parsedInput['"amount"']),
+ parsedInput['"choice"'].replace(/^"|"$/g, "") as
+ | "rock"
+ | "paper"
+ | "scissors",
+ );
- return JSON.stringify({
- status: "success",
- message: result,
- });
- } catch (error: any) {
- return JSON.stringify({
- status: "error",
- message: error.message,
- code: error.code || "UNKNOWN_ERROR",
- });
- }
- }
+ return JSON.stringify({
+ status: "success",
+ message: result,
+ });
+ } catch (error: any) {
+ return JSON.stringify({
+ status: "error",
+ message: error.message,
+ code: error.code || "UNKNOWN_ERROR",
+ });
+ }
+ }
}
export class SolanaTipLinkTool extends Tool {
- name = "solana_tiplink";
- description = `Create a TipLink for transferring SOL or SPL tokens.
+ name = "solana_tiplink";
+ description = `Create a TipLink for transferring SOL or SPL tokens.
Input is a JSON string with:
- amount: number (required) - Amount to transfer
- splmintAddress: string (optional) - SPL token mint address`;
- constructor(private solanaKit: SolanaAgentKit) {
- super();
- }
+ constructor(private solanaKit: SolanaAgentKit) {
+ super();
+ }
- protected async _call(input: string): Promise {
- try {
- const parsedInput = JSON.parse(input);
+ protected async _call(input: string): Promise {
+ try {
+ const parsedInput = JSON.parse(input);
- if (!parsedInput.amount) {
- throw new Error("Amount is required");
- }
+ if (!parsedInput.amount) {
+ throw new Error("Amount is required");
+ }
- const amount = parseFloat(parsedInput.amount);
- const splmintAddress = parsedInput.splmintAddress
- ? new PublicKey(parsedInput.splmintAddress)
- : undefined;
+ const amount = parseFloat(parsedInput.amount);
+ const splmintAddress = parsedInput.splmintAddress
+ ? new PublicKey(parsedInput.splmintAddress)
+ : undefined;
- const { url, signature } = await this.solanaKit.createTiplink(
- amount,
- splmintAddress,
- );
+ const { url, signature } = await this.solanaKit.createTiplink(
+ amount,
+ splmintAddress,
+ );
- return JSON.stringify({
- status: "success",
- url,
- signature,
- amount,
- tokenType: splmintAddress ? "SPL" : "SOL",
- message: `TipLink created successfully`,
- });
- } catch (error: any) {
- return JSON.stringify({
- status: "error",
- message: error.message,
- code: error.code || "UNKNOWN_ERROR",
- });
- }
- }
+ return JSON.stringify({
+ status: "success",
+ url,
+ signature,
+ amount,
+ tokenType: splmintAddress ? "SPL" : "SOL",
+ message: `TipLink created successfully`,
+ });
+ } catch (error: any) {
+ return JSON.stringify({
+ status: "error",
+ message: error.message,
+ code: error.code || "UNKNOWN_ERROR",
+ });
+ }
+ }
}
export class SolanaListNFTForSaleTool extends Tool {
- name = "solana_list_nft_for_sale";
- description = `List an NFT for sale on Tensor Trade.
+ name = "solana_list_nft_for_sale";
+ description = `List an NFT for sale on Tensor Trade.
Inputs (input is a JSON string):
nftMint: string, the mint address of the NFT (required)
price: number, price in SOL (required)`;
- constructor(private solanaKit: SolanaAgentKit) {
- super();
- }
+ constructor(private solanaKit: SolanaAgentKit) {
+ super();
+ }
- protected async _call(input: string): Promise {
- try {
- const parsedInput = JSON.parse(input);
+ protected async _call(input: string): Promise {
+ try {
+ const parsedInput = JSON.parse(input);
- // Validate NFT ownership first
- const nftAccount =
- await this.solanaKit.connection.getTokenAccountsByOwner(
- this.solanaKit.wallet_address,
- { mint: new PublicKey(parsedInput.nftMint) },
- );
+ // Validate NFT ownership first
+ const nftAccount =
+ await this.solanaKit.connection.getTokenAccountsByOwner(
+ this.solanaKit.wallet_address,
+ { mint: new PublicKey(parsedInput.nftMint) },
+ );
- if (nftAccount.value.length === 0) {
- return JSON.stringify({
- status: "error",
- message:
- "NFT not found in wallet. Please make sure you own this NFT.",
- code: "NFT_NOT_FOUND",
- });
- }
+ if (nftAccount.value.length === 0) {
+ return JSON.stringify({
+ status: "error",
+ message:
+ "NFT not found in wallet. Please make sure you own this NFT.",
+ code: "NFT_NOT_FOUND",
+ });
+ }
- const tx = await this.solanaKit.tensorListNFT(
- new PublicKey(parsedInput.nftMint),
- parsedInput.price,
- );
+ const tx = await this.solanaKit.tensorListNFT(
+ new PublicKey(parsedInput.nftMint),
+ parsedInput.price,
+ );
- return JSON.stringify({
- status: "success",
- message: "NFT listed for sale successfully",
- transaction: tx,
- price: parsedInput.price,
- nftMint: parsedInput.nftMint,
- });
- } catch (error: any) {
- return JSON.stringify({
- status: "error",
- message: error.message,
- code: error.code || "UNKNOWN_ERROR",
- });
- }
- }
+ return JSON.stringify({
+ status: "success",
+ message: "NFT listed for sale successfully",
+ transaction: tx,
+ price: parsedInput.price,
+ nftMint: parsedInput.nftMint,
+ });
+ } catch (error: any) {
+ return JSON.stringify({
+ status: "error",
+ message: error.message,
+ code: error.code || "UNKNOWN_ERROR",
+ });
+ }
+ }
}
export class SolanaCancelNFTListingTool extends Tool {
- name = "solana_cancel_nft_listing";
- description = `Cancel an NFT listing on Tensor Trade.
+ name = "solana_cancel_nft_listing";
+ description = `Cancel an NFT listing on Tensor Trade.
Inputs (input is a JSON string):
nftMint: string, the mint address of the NFT (required)`;
- constructor(private solanaKit: SolanaAgentKit) {
- super();
- }
+ constructor(private solanaKit: SolanaAgentKit) {
+ super();
+ }
- protected async _call(input: string): Promise {
- try {
- const parsedInput = JSON.parse(input);
+ protected async _call(input: string): Promise {
+ try {
+ const parsedInput = JSON.parse(input);
- const tx = await this.solanaKit.tensorCancelListing(
- new PublicKey(parsedInput.nftMint),
- );
+ const tx = await this.solanaKit.tensorCancelListing(
+ new PublicKey(parsedInput.nftMint),
+ );
- return JSON.stringify({
- status: "success",
- message: "NFT listing cancelled successfully",
- transaction: tx,
- nftMint: parsedInput.nftMint,
- });
- } catch (error: any) {
- return JSON.stringify({
- status: "error",
- message: error.message,
- code: error.code || "UNKNOWN_ERROR",
- });
- }
- }
+ return JSON.stringify({
+ status: "success",
+ message: "NFT listing cancelled successfully",
+ transaction: tx,
+ nftMint: parsedInput.nftMint,
+ });
+ } catch (error: any) {
+ return JSON.stringify({
+ status: "error",
+ message: error.message,
+ code: error.code || "UNKNOWN_ERROR",
+ });
+ }
+ }
}
export function createSolanaTools(solanaKit: SolanaAgentKit) {
- return [
- new SolanaBalanceTool(solanaKit),
- new SolanaBalanceOtherTool(solanaKit),
- new SolanaTransferTool(solanaKit),
- new SolanaDeployTokenTool(solanaKit),
- new SolanaDeployCollectionTool(solanaKit),
- new SolanaMintNFTTool(solanaKit),
- new SolanaTradeTool(solanaKit),
- new SolanaRequestFundsTool(solanaKit),
- new SolanaRegisterDomainTool(solanaKit),
- new SolanaGetWalletAddressTool(solanaKit),
- new SolanaPumpfunTokenLaunchTool(solanaKit),
- new SolanaCreateImageTool(solanaKit),
- new SolanaLendAssetTool(solanaKit),
- new SolanaTPSCalculatorTool(solanaKit),
- new SolanaStakeTool(solanaKit),
- new SolanaFetchPriceTool(solanaKit),
- new SolanaGetDomainTool(solanaKit),
- new SolanaTokenDataTool(solanaKit),
- new SolanaTokenDataByTickerTool(solanaKit),
- new SolanaCompressedAirdropTool(solanaKit),
- new SolanaRaydiumCreateAmmV4(solanaKit),
- new SolanaRaydiumCreateClmm(solanaKit),
- new SolanaRaydiumCreateCpmm(solanaKit),
- new SolanaOpenbookCreateMarket(solanaKit),
- new SolanaManifestCreateMarket(solanaKit),
- new SolanaLimitOrderTool(solanaKit),
- new SolanaCancelAllOrdersTool(solanaKit),
- new SolanaWithdrawAllTool(solanaKit),
- new SolanaClosePosition(solanaKit),
- new SolanaOrcaCreateCLMM(solanaKit),
- new SolanaOrcaCreateSingleSideLiquidityPool(solanaKit),
- new SolanaOrcaFetchPositions(solanaKit),
- new SolanaOrcaOpenCenteredPosition(solanaKit),
- new SolanaOrcaOpenSingleSidedPosition(solanaKit),
- new SolanaPythFetchPrice(solanaKit),
- new SolanaResolveDomainTool(solanaKit),
- new SolanaGetOwnedDomains(solanaKit),
- new SolanaGetOwnedTldDomains(solanaKit),
- new SolanaGetAllTlds(solanaKit),
- new SolanaGetMainDomain(solanaKit),
- new SolanaResolveAllDomainsTool(solanaKit),
- new SolanaCreateGibworkTask(solanaKit),
- new SolanaRockPaperScissorsTool(solanaKit),
- new SolanaTipLinkTool(solanaKit),
- new SolanaListNFTForSaleTool(solanaKit),
- new SolanaCancelNFTListingTool(solanaKit),
- ];
+ return [
+ new SolanaBalanceTool(solanaKit),
+ new SolanaBalanceOtherTool(solanaKit),
+ new SolanaTransferTool(solanaKit),
+ new SolanaDeployTokenTool(solanaKit),
+ new SolanaDeployCollectionTool(solanaKit),
+ new SolanaMintNFTTool(solanaKit),
+ new SolanaTradeTool(solanaKit),
+ new SolanaRequestFundsTool(solanaKit),
+ new SolanaRegisterDomainTool(solanaKit),
+ new SolanaGetWalletAddressTool(solanaKit),
+ new SolanaPumpfunTokenLaunchTool(solanaKit),
+ new SolanaCreateImageTool(solanaKit),
+ new SolanaLendAssetTool(solanaKit),
+ new SolanaTPSCalculatorTool(solanaKit),
+ new SolanaStakeTool(solanaKit),
+ new SolanaFetchPriceTool(solanaKit),
+ new SolanaGetDomainTool(solanaKit),
+ new SolanaTokenDataTool(solanaKit),
+ new SolanaTokenDataByTickerTool(solanaKit),
+ new SolanaCompressedAirdropTool(solanaKit),
+ new SolanaRaydiumCreateAmmV4(solanaKit),
+ new SolanaRaydiumCreateClmm(solanaKit),
+ new SolanaRaydiumCreateCpmm(solanaKit),
+ new SolanaOpenbookCreateMarket(solanaKit),
+ new SolanaManifestCreateMarket(solanaKit),
+ new SolanaLimitOrderTool(solanaKit),
+ new SolanaCancelAllOrdersTool(solanaKit),
+ new SolanaWithdrawAllTool(solanaKit),
+ new SolanaClosePosition(solanaKit),
+ new SolanaOrcaCreateCLMM(solanaKit),
+ new SolanaOrcaCreateSingleSideLiquidityPool(solanaKit),
+ new SolanaOrcaFetchPositions(solanaKit),
+ new SolanaOrcaOpenCenteredPosition(solanaKit),
+ new SolanaOrcaOpenSingleSidedPosition(solanaKit),
+ new SolanaPythFetchPrice(solanaKit),
+ new SolanaResolveDomainTool(solanaKit),
+ new SolanaGetOwnedDomains(solanaKit),
+ new SolanaGetOwnedTldDomains(solanaKit),
+ new SolanaGetAllTlds(solanaKit),
+ new SolanaGetMainDomain(solanaKit),
+ new SolanaResolveAllDomainsTool(solanaKit),
+ new SolanaCreateGibworkTask(solanaKit),
+ new SolanaRockPaperScissorsTool(solanaKit),
+ new SolanaTipLinkTool(solanaKit),
+ new SolanaListNFTForSaleTool(solanaKit),
+ new SolanaCancelNFTListingTool(solanaKit),
+ ];
}
diff --git a/src/tools/get_wallet_address.ts b/src/tools/get_wallet_address.ts
index d0b0ad4..55b19cd 100644
--- a/src/tools/get_wallet_address.ts
+++ b/src/tools/get_wallet_address.ts
@@ -6,5 +6,5 @@ import { SolanaAgentKit } from "..";
* @returns string
*/
export function get_wallet_address(agent: SolanaAgentKit) {
- return agent.wallet_address.toBase58();
+ return agent.wallet_address.toBase58();
}
diff --git a/src/vercel-ai/index.ts b/src/vercel-ai/index.ts
index a9a47d4..ba35643 100644
--- a/src/vercel-ai/index.ts
+++ b/src/vercel-ai/index.ts
@@ -4,22 +4,22 @@ import { executeAction } from "../utils/actionExecutor";
import { ACTIONS } from "../actions";
export function createSolanaTools(
- solanaAgentKit: SolanaAgentKit,
+ solanaAgentKit: SolanaAgentKit,
): Record {
- const tools: Record = {};
- const actionKeys = Object.keys(ACTIONS);
+ const tools: Record = {};
+ const actionKeys = Object.keys(ACTIONS);
- for (const key of actionKeys) {
- const action = ACTIONS[key as keyof typeof ACTIONS];
- tools[key] = tool({
- // @ts-expect-error Value matches type however TS still shows error
- id: action.name,
- description: action.description,
- parameters: action.schema,
- execute: async (params) =>
- await executeAction(action, solanaAgentKit, params),
- });
- }
+ for (const key of actionKeys) {
+ const action = ACTIONS[key as keyof typeof ACTIONS];
+ tools[key] = tool({
+ // @ts-expect-error Value matches type however TS still shows error
+ id: action.name,
+ description: action.description,
+ parameters: action.schema,
+ execute: async (params) =>
+ await executeAction(action, solanaAgentKit, params),
+ });
+ }
- return tools;
+ return tools;
}
diff --git a/test/agent_sdks/vercel_ai.ts b/test/agent_sdks/vercel_ai.ts
index 8fd19c1..77fda22 100644
--- a/test/agent_sdks/vercel_ai.ts
+++ b/test/agent_sdks/vercel_ai.ts
@@ -8,191 +8,191 @@ import { createOpenAI } from "@ai-sdk/openai";
dotenv.config();
function validateEnvironment(): void {
- const missingVars: string[] = [];
- const requiredVars = ["OPENAI_API_KEY", "RPC_URL", "SOLANA_PRIVATE_KEY"];
+ const missingVars: string[] = [];
+ const requiredVars = ["OPENAI_API_KEY", "RPC_URL", "SOLANA_PRIVATE_KEY"];
- requiredVars.forEach((varName) => {
- if (!process.env[varName]) {
- missingVars.push(varName);
- }
- });
+ requiredVars.forEach((varName) => {
+ if (!process.env[varName]) {
+ missingVars.push(varName);
+ }
+ });
- if (missingVars.length > 0) {
- console.error("Error: Required environment variables are not set");
- missingVars.forEach((varName) => {
- console.error(`${varName}=your_${varName.toLowerCase()}_here`);
- });
- process.exit(1);
- }
+ if (missingVars.length > 0) {
+ console.error("Error: Required environment variables are not set");
+ missingVars.forEach((varName) => {
+ console.error(`${varName}=your_${varName.toLowerCase()}_here`);
+ });
+ process.exit(1);
+ }
}
validateEnvironment();
async function runAutonomousMode(interval = 10) {
- console.log("Starting autonomous mode...");
- const openai = createOpenAI({
- apiKey: process.env.OPENAI_API_KEY as string,
- });
+ console.log("Starting autonomous mode...");
+ const openai = createOpenAI({
+ apiKey: process.env.OPENAI_API_KEY as string,
+ });
- const solanaAgent = new SolanaAgentKit(
- process.env.SOLANA_PRIVATE_KEY!,
- process.env.RPC_URL!,
- {
- OPENAI_API_KEY: process.env.OPENAI_API_KEY!,
- },
- );
+ const solanaAgent = new SolanaAgentKit(
+ process.env.SOLANA_PRIVATE_KEY!,
+ process.env.RPC_URL!,
+ {
+ OPENAI_API_KEY: process.env.OPENAI_API_KEY!,
+ },
+ );
- const tools = createVercelAITools(solanaAgent);
+ const tools = createVercelAITools(solanaAgent);
- while (true) {
- try {
- const thought =
- "Be creative and do something interesting on the blockchain. " +
- "Choose an action or set of actions and execute it that highlights your abilities.";
+ while (true) {
+ try {
+ const thought =
+ "Be creative and do something interesting on the blockchain. " +
+ "Choose an action or set of actions and execute it that highlights your abilities.";
- const response = streamText({
- prompt: thought,
- tools,
- model: openai("gpt-4o-mini"),
- temperature: 0.7,
- system: `You are a helpful agent that can interact onchain using the Solana Agent Kit. You are
+ const response = streamText({
+ prompt: thought,
+ tools,
+ model: openai("gpt-4o-mini"),
+ temperature: 0.7,
+ system: `You are a helpful agent that can interact onchain using the Solana Agent Kit. You are
empowered to interact onchain using your tools. If you ever need funds, you can request them from the
faucet. If not, you can provide your wallet details and request funds from the user. If there is a 5XX
(internal) HTTP error code, ask the user to try again later. If someone asks you to do something you
can't do with your currently available tools, you must say so, and encourage them to implement it
themselves using the Solana Agent Kit, recommend they go to https://www.solanaagentkit.xyz for more information. Be
concise and helpful with your responses. Refrain from restating your tools' descriptions unless it is explicitly requested.`,
- maxSteps: 10,
- });
+ maxSteps: 10,
+ });
- for await (const textPart of response.textStream) {
- process.stdout.write(textPart);
- }
- console.log();
+ for await (const textPart of response.textStream) {
+ process.stdout.write(textPart);
+ }
+ console.log();
- await new Promise((resolve) => setTimeout(resolve, interval * 1000));
- } catch (error) {
- if (error instanceof Error) {
- console.error("Error:", error.message);
- }
- process.exit(1);
- }
- }
+ await new Promise((resolve) => setTimeout(resolve, interval * 1000));
+ } catch (error) {
+ if (error instanceof Error) {
+ console.error("Error:", error.message);
+ }
+ process.exit(1);
+ }
+ }
}
async function runChatMode() {
- console.log("Starting chat mode... Type 'exit' to end.");
- const openai = createOpenAI({
- apiKey: process.env.OPENAI_API_KEY as string,
- });
+ console.log("Starting chat mode... Type 'exit' to end.");
+ const openai = createOpenAI({
+ apiKey: process.env.OPENAI_API_KEY as string,
+ });
- const solanaAgent = new SolanaAgentKit(
- process.env.SOLANA_PRIVATE_KEY!,
- process.env.RPC_URL!,
- {
- OPENAI_API_KEY: process.env.OPENAI_API_KEY!,
- },
- );
+ const solanaAgent = new SolanaAgentKit(
+ process.env.SOLANA_PRIVATE_KEY!,
+ process.env.RPC_URL!,
+ {
+ OPENAI_API_KEY: process.env.OPENAI_API_KEY!,
+ },
+ );
- const tools = createVercelAITools(solanaAgent);
- console.log(tools);
+ const tools = createVercelAITools(solanaAgent);
+ console.log(tools);
- const rl = readline.createInterface({
- input: process.stdin,
- output: process.stdout,
- });
+ const rl = readline.createInterface({
+ input: process.stdin,
+ output: process.stdout,
+ });
- const question = (prompt: string): Promise =>
- new Promise((resolve) => rl.question(prompt, resolve));
+ const question = (prompt: string): Promise =>
+ new Promise((resolve) => rl.question(prompt, resolve));
- try {
- while (true) {
- const userInput = await question("\nPrompt: ");
+ try {
+ while (true) {
+ const userInput = await question("\nPrompt: ");
- if (userInput.toLowerCase() === "exit") {
- break;
- }
+ if (userInput.toLowerCase() === "exit") {
+ break;
+ }
- const response = streamText({
- prompt: userInput,
- tools,
- model: openai("gpt-4o-mini"),
- temperature: 0.7,
- system: `You are a helpful agent that can interact onchain using the Solana Agent Kit. You are
+ const response = streamText({
+ prompt: userInput,
+ tools,
+ model: openai("gpt-4o-mini"),
+ temperature: 0.7,
+ system: `You are a helpful agent that can interact onchain using the Solana Agent Kit. You are
empowered to interact onchain using your tools. If you ever need funds, you can request them from the
faucet. If not, you can provide your wallet details and request funds from the user. If there is a 5XX
(internal) HTTP error code, ask the user to try again later. If someone asks you to do something you
can't do with your currently available tools, you must say so, and encourage them to implement it
themselves using the Solana Agent Kit, recommend they go to https://www.solanaagentkit.xyz for more information. Be
concise and helpful with your responses. Refrain from restating your tools' descriptions unless it is explicitly requested.`,
- maxSteps: 10,
- });
+ maxSteps: 10,
+ });
- for await (const textPart of response.textStream) {
- process.stdout.write(textPart);
- }
- console.log();
- }
- } catch (error) {
- if (error instanceof Error) {
- console.error("Error:", error.message);
- }
- process.exit(1);
- } finally {
- rl.close();
- }
+ for await (const textPart of response.textStream) {
+ process.stdout.write(textPart);
+ }
+ console.log();
+ }
+ } catch (error) {
+ if (error instanceof Error) {
+ console.error("Error:", error.message);
+ }
+ process.exit(1);
+ } finally {
+ rl.close();
+ }
}
async function chooseMode(): Promise<"chat" | "auto"> {
- const rl = readline.createInterface({
- input: process.stdin,
- output: process.stdout,
- });
+ const rl = readline.createInterface({
+ input: process.stdin,
+ output: process.stdout,
+ });
- const question = (prompt: string): Promise =>
- new Promise((resolve) => rl.question(prompt, resolve));
+ const question = (prompt: string): Promise =>
+ new Promise((resolve) => rl.question(prompt, resolve));
- while (true) {
- console.log("\nAvailable modes:");
- console.log("1. chat - Interactive chat mode");
- console.log("2. auto - Autonomous action mode");
+ while (true) {
+ console.log("\nAvailable modes:");
+ console.log("1. chat - Interactive chat mode");
+ console.log("2. auto - Autonomous action mode");
- const choice = (await question("\nChoose a mode (enter number or name): "))
- .toLowerCase()
- .trim();
+ const choice = (await question("\nChoose a mode (enter number or name): "))
+ .toLowerCase()
+ .trim();
- rl.close();
+ rl.close();
- if (choice === "1" || choice === "chat") {
- return "chat";
- } else if (choice === "2" || choice === "auto") {
- return "auto";
- }
- console.log("Invalid choice. Please try again.");
- }
+ if (choice === "1" || choice === "chat") {
+ return "chat";
+ } else if (choice === "2" || choice === "auto") {
+ return "auto";
+ }
+ console.log("Invalid choice. Please try again.");
+ }
}
async function main() {
- try {
- console.log("Starting Agent...");
- const mode = await chooseMode();
+ try {
+ console.log("Starting Agent...");
+ const mode = await chooseMode();
- if (mode === "chat") {
- await runChatMode();
- } else {
- await runAutonomousMode();
- }
- } catch (error) {
- if (error instanceof Error) {
- console.error("Error:", error.message);
- }
- process.exit(1);
- }
+ if (mode === "chat") {
+ await runChatMode();
+ } else {
+ await runAutonomousMode();
+ }
+ } catch (error) {
+ if (error instanceof Error) {
+ console.error("Error:", error.message);
+ }
+ process.exit(1);
+ }
}
if (require.main === module) {
- main().catch((error) => {
- console.error("Fatal error:", error);
- process.exit(1);
- });
+ main().catch((error) => {
+ console.error("Fatal error:", error);
+ process.exit(1);
+ });
}
diff --git a/test/index.ts b/test/index.ts
index 2a3312b..00f9976 100644
--- a/test/index.ts
+++ b/test/index.ts
@@ -1,4 +1,4 @@
-import { SolanaAgentKit , ACTIONS} from "../src";
+import { SolanaAgentKit, ACTIONS } from "../src";
import { createSolanaTools } from "../src/langchain";
import { HumanMessage } from "@langchain/core/messages";
import { MemorySaver } from "@langchain/langgraph";