/** * @zhin.js/ai - Multi-modal Output Pipeline * * 统一输出类型系统:AI 回复 → OutputElement[] → Adapter 渲染 * * 支持的输出类型: * - text: 纯文本 / markdown * - image: 图片 URL 或 base64 * - audio: 音频 URL 或 base64 * - video: 视频 URL * - card: 结构化卡片 (标题 + 正文 + 字段 + 按钮) * - file: 文件附件 */ export interface TextElement { type: 'text'; content: string; /** markdown / plain */ format?: 'markdown' | 'plain'; } export interface ImageElement { type: 'image'; url: string; /** base64 数据 (url 不可用时的后备) */ base64?: string; alt?: string; width?: number; height?: number; } export interface AudioElement { type: 'audio'; url: string; base64?: string; duration?: number; /** 语音转文字的后备文本 */ fallbackText?: string; } export interface VideoElement { type: 'video'; url: string; /** base64 载荷(出站优先;url 可为空或 data URI) */ base64?: string; mimeType?: string; coverUrl?: string; duration?: number; fallbackText?: string; } export interface CardField { label: string; value: string; inline?: boolean; } export interface CardButton { text: string; /** 点击后发送的命令 */ command?: string; /** 点击后打开的 URL */ url?: string; } export interface CardElement { type: 'card'; title: string; description?: string; fields?: CardField[]; imageUrl?: string; buttons?: CardButton[]; color?: string; } export interface FileElement { type: 'file'; url: string; name: string; size?: number; mimeType?: string; } export type OutputElement = TextElement | ImageElement | AudioElement | VideoElement | CardElement | FileElement; /** * 从 AI 回复文本中解析出结构化的 OutputElement[] * * 识别规则: * - ![alt](url) → ImageElement * - [audio](url) → AudioElement * - [video](url) → VideoElement * - ```card ... ``` → CardElement (JSON) * - [file:name](url) → FileElement * - 其余文本 → TextElement */ export declare function parseOutput(raw: string): OutputElement[]; /** * 将 OutputElement[] 降级为纯文本(用于不支持富媒体的平台) */ export declare function renderToPlainText(elements: OutputElement[]): string; /** * 将 OutputElement[] 渲染为 Satori 兼容的 HTML 片段 */ export declare function renderToSatori(elements: OutputElement[]): string; //# sourceMappingURL=output.d.ts.map