import type React from "react"; import type { ParseAgentMessageOptions, ParsedPart } from "../utils"; import type { IMessage, FunctionCall, FunctionResponse, MarkdownExtension } from "./XAdkChatbot"; import type { ToolRenderKind } from "./FunctionCallRender"; import type { UploadRequestFn } from "./XAdkSender"; export interface ToolKindResolveContext { name?: string; msg?: IMessage; } export interface ChatStrategies { /** * 工具名/消息 -> 渲染类型解析策略。 */ resolveToolKind?: (ctx: ToolKindResolveContext) => ToolRenderKind; /** * 函数调用确认场景中,基于工具调用和用户选择生成 functionResponse。 */ createFunctionResponse?: (fnCall: FunctionCall, confirmed: boolean) => FunctionResponse; /** * 将模型文本拆分为过程节点和最终答案。 */ parseProcessMessage?: (text: string, options?: ParseAgentMessageOptions) => ParsedPart[]; /** * Markdown 资源链接协议白名单,如 skill://、plugin://。 * 业务预设可在这里追加私有协议,例如 xgroup-adk 的 kb://。 */ markdownResourceLinkSchemes?: readonly string[]; /** * 自定义 approval 场景渲染,返回 null 则使用默认渲染。 */ renderApproval?: (msg: IMessage, onConfirm?: (fnCall: FunctionCall, confirmed: boolean) => void) => React.ReactNode | null; /** * 自定义 handoff 场景渲染,返回 null 则使用默认渲染。 */ renderHandoff?: (msg: IMessage) => React.ReactNode | null; } export interface ChatPreset { name: string; strategies?: ChatStrategies; /** 当前协议预设提供的默认 Markdown/XML 标签扩展。 */ markdownExtensions?: readonly MarkdownExtension[]; /** * 基于当前协议预设创建默认文件上传函数。 * 用户显式传入 config.uploadRequest 时优先使用用户配置。 */ createUploadRequest?: (context: { url: string; token?: string; appNo?: string; }) => UploadRequestFn | undefined; } /** SDK 为兼容现有接入提供的内建预设名称。自定义预设建议直接传 ChatPreset 对象。 */ export type BuiltinChatPresetName = "base" | "xgroup-adk"; export type ChatPresetInput = BuiltinChatPresetName | ChatPreset;