@agentek/tools
Version:
Blockchain tools for AI agents
85 lines • 3.07 kB
TypeScript
import { type WalletClient, type Transport, type Chain, type Account, Address, Hex, SignableMessage, TypedDataParameter, TypedDataDomain } from "viem";
import { z } from "zod";
export interface BaseTool {
name: string;
description: string;
parameters: z.ZodObject<any, any, any, any>;
execute: (client: AgentekClient, args: any) => Promise<any>;
supportedChains?: Chain[];
}
export interface Op {
target: Address;
value: string;
data: Hex;
}
export interface PersonalSign {
type: 'personal_sign';
message: SignableMessage;
}
export interface TypedDataSign {
type: "typed_data_sign";
domain: TypedDataDomain;
types: Record<string, readonly TypedDataParameter[]>;
primaryType: string;
message: Record<string, unknown>;
}
export type Sign = PersonalSign | TypedDataSign;
export type Operation = Op | Sign;
interface RequestIntent {
intent: string;
ops: Operation[];
chain: number;
}
interface CompletedIntent {
intent: string;
ops: Operation[];
chain: number;
hash?: string;
signatures?: string[];
}
export type Intent = RequestIntent | CompletedIntent;
export interface AgentekClientConfig {
transports: Transport[];
chains: Chain[];
accountOrAddress: Account | Address;
tools: BaseTool[];
}
export declare const isTransactionOp: (op: Operation) => op is Op;
export declare const isPersonalSign: (op: Operation) => op is PersonalSign;
export declare const isTypedDataSign: (op: Operation) => op is TypedDataSign;
export declare const isSignOperation: (op: Operation) => op is Sign;
export declare class AgentekClient {
private publicClients;
private walletClients;
private tools;
private chains;
private accountOrAddress;
constructor(config: AgentekClientConfig);
getAddress(): Promise<Address>;
getPublicClient(chainId?: number): any;
getPublicClients(): Map<number, any>;
getWalletClient(chainId?: number): WalletClient | undefined;
getWalletClients(): Map<number, WalletClient>;
getChains(): Chain[];
getTools(): Map<string, BaseTool>;
filterSupportedChains(supportedChains: Chain[], chainId?: number): Chain[];
addTools(tools: BaseTool[]): void;
executeOps(ops: Op[], chainId: number): Promise<string>;
executeSign(signs: Sign[], chainId: number): Promise<string[]>;
executeOperations(operations: Operation[], chainId: number): Promise<{
hash?: string;
signatures?: string[];
}>;
execute(method: string, args: any): Promise<any>;
}
export declare function createAgentekClient(config: AgentekClientConfig): AgentekClient;
export declare function createTool<T extends z.ZodObject<any, any, any, any>>({ name, description, parameters, execute, supportedChains, }: {
name: string;
description: string;
parameters: T;
execute: (client: AgentekClient, args: z.infer<T>) => Promise<any>;
supportedChains?: Chain[];
}): BaseTool;
export declare function createToolCollection(tools: BaseTool[]): BaseTool[];
export {};
//# sourceMappingURL=client.d.ts.map