Files
solana-agent-kit/src/vercel-ai/index.ts
michaelessiet c2bf6191ff fix: lint
2025-01-03 18:22:32 +01:00

26 lines
779 B
TypeScript

import { tool, type CoreTool } from "ai";
import { SolanaAgentKit } from "../agent";
import { executeAction } from "../utils/actionExecutor";
import { ACTIONS } from "../actions";
export function createSolanaTools(
solanaAgentKit: SolanaAgentKit,
): Record<string, CoreTool> {
const tools: Record<string, CoreTool> = {};
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),
});
}
return tools;
}