UNPKG

flux-agent

Version:

FluxAgent - 一个可灵活插拔的AI Agent系统框架,基于TypeScript开发,支持流式执行、事件系统、插件系统、知识库管理等功能 (Protected Release) (Protected Release) (Protected Release) (Protected Release) (Protected Release) (Protected Release) (Protected Release) (Protected Release) (Protected Release) (

50 lines (49 loc) 1.87 kB
import { Tool } from '../LLM'; import { PhaseType } from '../Phases'; import { Context } from '../Context'; import { EventHub } from '../EventHub'; import { Agent } from '../Agent'; export interface ToolExecutionContext { toolcallId: string; phase: PhaseType; context: Context; eventHub?: EventHub; logger?: (message: string, data?: any) => void; } export interface ToolExecutionResult { type: 'success' | 'error' | 'skip' | 'reject' | 'pause' | 'stop'; data?: any; error?: Error; } export interface BaseTool { isSystemTool?: boolean; phase: PhaseType | PhaseType[]; getDefinition(): Tool; execute(args: Record<string, any>, context: ToolExecutionContext): Promise<ToolExecutionResult>; cancel(): void; getName(): string; getDescription(): string; validateArgs?(args: Record<string, any>): boolean; applyAgent(agent: Agent): void; getContextRecordText(data?: any): string; } export declare abstract class AbstractTool implements BaseTool { protected agent: Agent; protected name: string; protected description: string; abstract phase: PhaseType | PhaseType[]; constructor(name: string, description: string); getName(): string; getDescription(): string; abstract getDefinition(): Tool; abstract execute(args: Record<string, any>, context: ToolExecutionContext): Promise<ToolExecutionResult>; abstract cancel(): void; validateArgs(): boolean; protected createSuccessResult(data?: any): ToolExecutionResult; protected createSkipResult(): ToolExecutionResult; protected createRejectResult(): ToolExecutionResult; protected createErrorResult(error: Error): ToolExecutionResult; protected createPauseResult(data?: any): ToolExecutionResult; applyAgent(agent: Agent): void; getContextRecordText(_data: ToolExecutionResult): string; }