tinyagent-ts
Version:
Modern TypeScript framework for building AI agents with pluggable tools and ReAct reasoning
38 lines (37 loc) • 1.21 kB
TypeScript
import { z } from 'zod';
export interface Tool<I = unknown, O = unknown> {
/** A human-readable name used when the agent calls this tool. */
readonly name: string;
/** A short description surfaced to the LLM. */
readonly description: string;
/** Strongly-typed runtime validation of the input payload (if you need it). */
validate?(input: I): void;
/** Core execution logic. */
forward(input: I): O | Promise<O>;
}
export type FinalAnswerArgs = {
answer: string;
};
export type FinalAnswerOutput = FinalAnswerArgs;
export declare const FinalAnswerSchema: z.ZodObject<{
answer: z.ZodString;
}, "strip", z.ZodTypeAny, {
answer: string;
}, {
answer: string;
}>;
/**
* Always provide the agent’s final answer verbatim.
*/
export declare class FinalAnswerTool implements Tool<FinalAnswerArgs, FinalAnswerOutput> {
readonly name = "final_answer";
readonly description = "Provides the definitive answer to the user\u2019s question.";
readonly schema: z.ZodObject<{
answer: z.ZodString;
}, "strip", z.ZodTypeAny, {
answer: string;
}, {
answer: string;
}>;
forward(answer: FinalAnswerArgs): FinalAnswerOutput;
}