/** * Agent Executor 抽象基类 * * 所有 AI Agent 执行器的基类,提供公共逻辑。 */ import type { IAgentExecutor, ExecutorType, AuthType, AuthInfo, ExecutorConfig, ExecuteResult, ExecuteMessage, ChatMessage, BaseExecutorOptions, AiCredential, AIConnectionInvocationConfig } from './types'; /** * Agent 执行器抽象基类 * * 提供公共实现: * - executeAndWait: 基于 execute 的便捷方法 * - 日志记录 * - 错误处理包装 * * 子类需要实现: * - executorType: 执行器类型 * - getAuthType(): 认证类型 * - checkAuthentication(): 认证检查 * - execute(): 流式执行 * - chat(): 多轮对话 */ export declare abstract class BaseAgentExecutor implements IAgentExecutor { abstract readonly executorType: ExecutorType; readonly providerId: string; protected readonly logger: import("global-logger-factory").Logger; protected readonly credential: AiCredential; protected readonly baseUrl?: string; protected readonly aiConnection?: AIConnectionInvocationConfig; /** * 构造函数 * @param options 可选,如果不传则使用默认值(CLI 模式) */ constructor(options?: BaseExecutorOptions); /** * 获取认证类型 */ abstract getAuthType(): AuthType; /** * 检查认证状态 */ abstract checkAuthentication(): Promise; /** * 执行任务(流式) */ abstract execute(config: ExecutorConfig, message: string): AsyncGenerator; /** * 多轮对话 */ abstract chat(config: ExecutorConfig, messages: ChatMessage[]): Promise; /** * 执行任务并等待完成 * * 基于 execute() 的便捷方法,消费整个流并返回最终结果。 */ executeAndWait(config: ExecutorConfig, message: string): Promise; /** * 包装执行错误 */ protected wrapError(error: unknown, startTime: number): ExecuteResult; /** * 创建成功结果 */ protected createSuccessResult(result: string, promptTokens: number, completionTokens: number, startTime: number): ExecuteResult; /** * 创建错误消息 */ protected yieldError(error: unknown, startTime: number): Generator; }