import type { RegisteredTool, ToolContext } from './types.js'; import type { StructuredAgentOutput, WorkflowRole } from '../agent/workflow.js'; /** * 子 Agent 执行器接口 * 由上层(agent.service.ts)实现,Core 层只定义接口 */ export interface SubAgentRunOptions { role?: WorkflowRole | string; structured?: boolean; /** * 流式输出回调:每次子 Agent 产生新内容时调用,传入累积内容。 * 用于超时场景下保留部分结果。若设置了超时,executor 会自动传入此回调。 */ onPartial?: (content: string) => void; } export interface SubAgentRunResult { content: string; structured?: StructuredAgentOutput; /** * 执行过程中产生的部分结果(流式输出累积)。 * 即使子 Agent 最终出错,partialContent 中已获取的内容也会被保留并返回给主 Agent。 */ partialContent?: string; /** * 执行过程中遇到的错误列表(非致命错误,子 Agent 可能已产出部分结果)。 */ errors?: string[]; } export type SubAgentRunResponse = string | SubAgentRunResult; export interface SubAgentRunner { /** 子 Agent 的标识名(用于 LLM 选择) */ name: string; /** 子 Agent 的领域描述(用于 LLM 理解其能力) */ description: string; /** 优先级(数值越高越优先,默认为 0)。当多个 Agent 都能匹配用户意图时,优先选择高优先级的 */ priority?: number; /** 适用范围/领域标签(用于 LLM 判断是否匹配用户意图) */ scope?: string[]; /** 触发关键词(当用户消息包含这些关键词时,此 Agent 更可能被选中) */ keywords?: string[]; /** 排他性范围:当用户意图落在此范围内时,此 Agent 可独立完成任务,无需调用其他 Agent */ exclusiveScope?: string[]; /** * 该子 Agent 的委派超时时间(毫秒)。 * 若设置,则覆盖 createDelegateTool 传入的全局 timeoutMs;不设置时回退到全局超时。 */ timeoutMs?: number; /** 动态输入字段元数据,供 delegate_task 生成 LLM 引导文案(仅多字段场景填充) */ inputFields?: SubAgentInputField[]; /** 执行子任务,返回结果文本或结构化结果 */ run(task: string, context: ToolContext, options?: SubAgentRunOptions): Promise; } /** 子 Agent 动态输入字段描述 */ export interface SubAgentInputField { name: string; required: boolean; description: string; type: string; } export declare function createDelegateTool(runners: SubAgentRunner[], options?: { timeoutMs?: number; }): RegisteredTool | null; //# sourceMappingURL=delegate.d.ts.map