import type { SubAgentRunner } from '../tool/delegate.js'; import type { RestA2AClient } from './rest-client.js'; /** 远程 Capability 的 input_schema 片段(供 runner 拆解 JSON 打包的 task) */ export interface RestInputSchema { type?: string; /** input_schema.required 字段名列表 */ required?: string[]; /** input_schema.properties,值为各字段的 schema 定义(含 type/description/enum 等) */ properties?: Record; } /** createRestA2ARemoteRunner 配置项 */ export interface RestA2ARemoteRunnerConfig { /** 远程 Agent 的 base URL(如 http://localhost:8000) */ baseUrl: string; /** Capability ID(如 'competitive_review') */ capabilityId: string; /** Runner 标识名(展示用) */ name: string; /** Runner 能力描述(供 LLM 理解) */ description: string; /** REST A2A 客户端实例 */ client: RestA2AClient; /** 静态输入字段(如 { caller_agent_id: 'agent-alpha', business_line: '固定收益' }) */ staticFields?: Record; /** 任务字符串映射到的字段名(默认 'analysis_focus') */ taskField?: string; /** * 允许 LLM 动态填写的字段名列表(来自 input_schema 的 properties 键)。 * - 缺省时仅 taskField 为动态,其余走 staticFields(与旧行为一致)。 * - 配置后,当 LLM 把 task 打包成 JSON 对象时,这些键会被合并进最终 input。 */ dynamicFields?: string[]; /** 远程 Capability 的 input_schema 片段,用于校验/白名单动态字段及生成 LLM 引导文案 */ inputSchema?: RestInputSchema; /** 是否启用流式(默认 true) */ streaming?: boolean; /** 流式失败时是否自动回退到同步模式,默认 true */ fallbackToSync?: boolean; /** 远程 Agent 输出模式:merge=合并到主正文,panel=保留子面板 */ outputMode?: 'panel' | 'merge'; /** 流式调用的 action 后缀(默认 'stream'),如 URL 为 .../cap_id:stream 则填 'stream' */ streamAction?: string; /** 同步调用的 action 后缀(默认 'invoke'),如 URL 为 .../cap_id:run 则填 'run' */ invokeAction?: string; /** * 静态运行时变量默认值(如 { userId, userMail })。 * 构造时固定;运行时还会与 `ToolContext.custom.vars` 合并(调用方每次 run 携带的系统变量优先)。 * 最终用于解析 headers / auth 中的 ${vars.x} 占位符,决定"带哪些变量去请求"远端。 */ vars?: Record; } /** * 创建 REST 风格远程 A2A Agent 的 SubAgentRunner * * 核心逻辑: * - streaming=true && ctx.emitSubEvent 存在 → invokeStreaming + 事件转发 * - 否则 → invoke 同步阻塞 * * 事件映射: * - status(running) → start * - stage → progress * - tool_call → tool_call * - tool_result → tool_result * - message_chunk → content * - result → done(由 runStreaming 提取最终文本) * - error → error */ export declare function createRestA2ARemoteRunner(config: RestA2ARemoteRunnerConfig): SubAgentRunner; //# sourceMappingURL=rest-runner.d.ts.map