@fv-ui/ai-chat 1.2.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -528,6 +528,7 @@ Markdown 渲染(Sanitized by DOMPurify),内置 Prism 代码高亮与 KaTeX。
528
528
  | update:messages | (MessageNode[]) 全量消息链(去抖后) |
529
529
  | send | (text, files?) 用户发送(allowAttachments 开启时 files 为降维后的 ChatFile[]) |
530
530
  | suggestion-select | (item) 点击空态建议项(先于 send 触发;label 为空的项不发) |
531
+ | followup-select | (item, message) 点击回答尾部追问建议 chip(先于 send 触发;组件内部已接住转 send 开启新一轮,事件仅供消费方可观测/埋点;仅链尾 assistant 消息渲染 chips,流式 message_end 前禁用防误点) |
531
532
  | message-complete | (message) 链尾 assistant 生成完成 |
532
533
  | error | (err, message?) 生成出错 |
533
534
  | branch-change | (dir, message) 分支切换 |
@@ -632,6 +633,7 @@ Markdown 渲染(Sanitized by DOMPurify),内置 Prism 代码高亮与 KaTeX。
632
633
  | --- | --- | --- | --- |
633
634
  | message | MessageNode | —(必填) | 消息节点 |
634
635
  | branch | AiMessageBranchInfo | undefined | 分支元数据 { count, index };缺省视为单分支 |
636
+ | isLast | boolean | false | 是否当前链最后一条消息(由 AiMessages 注入);追问建议 chips 仅链尾消息渲染——此前消息即使留有 suggestions 也不显示 |
635
637
  | showActions | boolean | true | 显示复制/重生成(仅 assistant) |
636
638
  | showBranchSwitch | boolean | true | 显示分支切换器(branch.count > 1 时) |
637
639
  | showUserAvatar | boolean | false | 显示用户头像(默认隐藏;false 时用户消息不渲染头像块) |
@@ -658,6 +660,7 @@ Markdown 渲染(Sanitized by DOMPurify),内置 Prism 代码高亮与 KaTeX。
658
660
  | Event | 说明 |
659
661
  | --- | --- |
660
662
  | copy / regenerate / branch-change | (message) / (message) / (dir, message) |
663
+ | followup-select | (item, message) 点击追问建议 chip(item 为建议文本;仅链尾 assistant 消息渲染 chips,status 落 done 后可点;AiChat 内部已接住转 send,直接用 AiMessage 时的消费方需自行接管发送) |
661
664
 
662
665
  | Slot | 说明 |
663
666
  | --- | --- |
@@ -740,6 +743,7 @@ const adapter = FvCommonAdapter({
740
743
  - 同步段失败(Content-Type 非 `text/event-stream`)按 JSON 错误 `{code,message}` 走 `onError`;命中 `errorMessages` 时用映射文案(带 `code` 的 `FvCommonError`)
741
744
  - `message_end` 的 `messageId`(最终文本行 id)经 `onBackendMessageId` 回填到 `MessageNode.backendId`——多轮工具循环下与 `message_start` 的首轮 id 不同,UI 落库/对账以它为准
742
745
  - `tool` 事件经 `onTool` → `useChat.onToolEvent` → `AiChat @tool-event` 上抛,消费方展示「正在查询库存…」等中间态
746
+ - 追问建议(V58+):`suggestions` 事件(流式收尾 0..1 次,最后一个 delta 后、message_end 前,载荷 `{items: string[]}`)经可选 `onSuggestions` 上抛,`useChat` 回写 `MessageNode.suggestions`,AiMessage 在链尾消息渲染追问 chips;开关关闭/模型未产出/中断/失败无此事件;历史恢复用导出的 `parseSuggestions(raw)` 安全解析 `FvCommonMessage.suggestions`(JSON 数组原文透传,脏数据按无建议)
743
747
  - 配套 DTO 类型:`FvCommonSessionItem` / `FvCommonMessage` / `FvCommonSessionDetail` / `FvCommonMessagePage`(消费方直接调会话管理端点时用)
744
748
 
745
749
  ### useMessages(initial?)
package/dist/index.d.ts CHANGED
@@ -83,6 +83,8 @@ declare const zhCN: {
83
83
  attachments: {
84
84
  add: string;
85
85
  retry: string;
86
+ /** 上传中状态角标文案(loading 态 files 卡片辅助提示) */
87
+ uploading: string;
86
88
  };
87
89
  filesCard: {
88
90
  remove: string;
@@ -117,6 +119,8 @@ declare const zhCN: {
117
119
  querying: string;
118
120
  queried: string;
119
121
  generateFailed: string;
122
+ /** 追问建议 chips 区 aria 标签 */
123
+ followups: string;
120
124
  loadingPhrases: string[];
121
125
  };
122
126
  aiArtifacts: {
@@ -295,7 +299,7 @@ declare var __VLS_1$9: {};
295
299
  declare var __VLS_10$2: {};
296
300
  declare var __VLS_12$1: {};
297
301
  declare var __VLS_14: {};
298
- declare var __VLS_32: {};
302
+ declare var __VLS_32$1: {};
299
303
  type __VLS_Slots$e = {} & {
300
304
  avatar?: (props: typeof __VLS_1$9) => any;
301
305
  } & {
@@ -305,7 +309,7 @@ type __VLS_Slots$e = {} & {
305
309
  } & {
306
310
  content?: (props: typeof __VLS_14) => any;
307
311
  } & {
308
- footer?: (props: typeof __VLS_32) => any;
312
+ footer?: (props: typeof __VLS_32$1) => any;
309
313
  };
310
314
  declare const __VLS_base$e: vue.DefineComponent<__VLS_Props$f, {
311
315
  interrupt: typeof interrupt;
@@ -537,11 +541,11 @@ declare function closeHeader$2(): void;
537
541
  declare var __VLS_1$8: {};
538
542
  declare var __VLS_3$3: {};
539
543
  declare var __VLS_5: {};
540
- declare var __VLS_52$1: {
544
+ declare var __VLS_52: {
541
545
  keyword: string;
542
546
  };
543
547
  declare var __VLS_54$1: {};
544
- declare var __VLS_56: {};
548
+ declare var __VLS_56$1: {};
545
549
  declare var __VLS_134: {};
546
550
  type __VLS_Slots$c = {} & {
547
551
  header?: (props: typeof __VLS_1$8) => any;
@@ -550,11 +554,11 @@ type __VLS_Slots$c = {} & {
550
554
  } & {
551
555
  prefix?: (props: typeof __VLS_5) => any;
552
556
  } & {
553
- trigger?: (props: typeof __VLS_52$1) => any;
557
+ trigger?: (props: typeof __VLS_52) => any;
554
558
  } & {
555
559
  'action-list'?: (props: typeof __VLS_54$1) => any;
556
560
  } & {
557
- 'action-left'?: (props: typeof __VLS_56) => any;
561
+ 'action-left'?: (props: typeof __VLS_56$1) => any;
558
562
  } & {
559
563
  footer?: (props: typeof __VLS_134) => any;
560
564
  };
@@ -997,20 +1001,20 @@ type __VLS_Props$a = {
997
1001
  /** 切换门控:start 起始态不可切换;thinking 中可展开查看思考流,end/error 后可自由收起展开 */
998
1002
  declare function toggle(): void;
999
1003
  declare var __VLS_1$6: {};
1000
- declare var __VLS_36$1: {};
1001
- declare var __VLS_38: {};
1004
+ declare var __VLS_36: {};
1005
+ declare var __VLS_38$1: {};
1002
1006
  declare var __VLS_51$1: {};
1003
- declare var __VLS_53: {};
1007
+ declare var __VLS_53$1: {};
1004
1008
  type __VLS_Slots$9 = {} & {
1005
1009
  'status-icon'?: (props: typeof __VLS_1$6) => any;
1006
1010
  } & {
1007
- label?: (props: typeof __VLS_36$1) => any;
1011
+ label?: (props: typeof __VLS_36) => any;
1008
1012
  } & {
1009
- arrow?: (props: typeof __VLS_38) => any;
1013
+ arrow?: (props: typeof __VLS_38$1) => any;
1010
1014
  } & {
1011
1015
  error?: (props: typeof __VLS_51$1) => any;
1012
1016
  } & {
1013
- content?: (props: typeof __VLS_53) => any;
1017
+ content?: (props: typeof __VLS_53$1) => any;
1014
1018
  };
1015
1019
  declare const __VLS_base$9: vue.DefineComponent<__VLS_Props$a, {
1016
1020
  modelValue: vue.Ref<boolean, boolean>;
@@ -1192,6 +1196,8 @@ type __VLS_Props$6 = {
1192
1196
  status?: 'loading' | 'success' | 'error';
1193
1197
  /** 图片缩略图尺寸(image 模式) */
1194
1198
  imageSize?: string;
1199
+ /** 错误提示文案(status=error 时替代大小行展示,如上传失败原因) */
1200
+ errorText?: string;
1195
1201
  /** 删除回调:右上删除按钮点击时调用 */
1196
1202
  onDelete?: () => void;
1197
1203
  /** 语言配置:内置语言名(如 'en-US')或部分文案对象(深合并覆盖) */
@@ -1209,6 +1215,7 @@ declare const __VLS_base$5: vue.DefineComponent<__VLS_Props$6, {}, {}, {}, {}, v
1209
1215
  status: "loading" | "success" | "error";
1210
1216
  fileType: "image" | "file";
1211
1217
  imageSize: string;
1218
+ errorText: string;
1212
1219
  onDelete: () => void;
1213
1220
  }, {}, {}, {}, string, vue.ComponentProvideOptions, false, {}, any>;
1214
1221
  declare const __VLS_export$6: __VLS_WithSlots$5<typeof __VLS_base$5, __VLS_Slots$5>;
@@ -1231,6 +1238,12 @@ interface AttachmentItem {
1231
1238
  raw?: File;
1232
1239
  [key: string]: unknown;
1233
1240
  }
1241
+ /**
1242
+ * 上传钩子:选文件即调(先传后发架构),成功返回附件描述回填 item
1243
+ * (远程信息合并进列表项,发送时随 @send 上抛);抛错/resolve 错误文案置 error
1244
+ * 可重传。缺省不调(纯本地待发列表,向后兼容)
1245
+ */
1246
+ type AttachmentUpload = (file: File, item: AttachmentItem) => Promise<Partial<AttachmentItem> | undefined | void> | Partial<AttachmentItem> | undefined | void;
1234
1247
  type __VLS_Props$5 = {
1235
1248
  /** 附件列表(v-model) */
1236
1249
  modelValue?: object[];
@@ -1242,12 +1255,14 @@ type __VLS_Props$5 = {
1242
1255
  count?: number;
1243
1256
  /** 上传前校验,返回 false(或 resolve false)拦截 */
1244
1257
  beforeUpload?: (file: File) => boolean | Promise<boolean>;
1258
+ /** 选文件即上传钩子(先传后发):成功回填附件描述,失败置 error 可重传;缺省不调 */
1259
+ upload?: AttachmentUpload;
1245
1260
  /** 布局:inline(默认)按钮+列表+提示一行;triggerOnly 只渲染回形针按钮;listOnly 只渲染文件列表 */
1246
1261
  layout?: 'inline' | 'triggerOnly' | 'listOnly';
1247
1262
  /** 语言配置:内置语言名(如 'en-US')或部分文案对象(深合并覆盖) */
1248
1263
  locale?: LocaleInput;
1249
1264
  };
1250
- /** 重传:error 项重新置为 loading(具体上传由外部接线,这里只驱动状态流转) */
1265
+ /** 重传:error 项重新走 upload(无钩子时仅置回 loading 等外部接线) */
1251
1266
  declare function retry(item: AttachmentItem): void;
1252
1267
  declare function openSelect(): void;
1253
1268
  declare var __VLS_12: {
@@ -1271,11 +1286,13 @@ declare const __VLS_base$4: vue.DefineComponent<__VLS_Props$5, {
1271
1286
  "update:modelValue": (list: object[]) => any;
1272
1287
  change: (list: object[]) => any;
1273
1288
  exceed: (file: File) => any;
1289
+ uploaded: (item: AttachmentItem, result?: Partial<AttachmentItem> | undefined) => any;
1274
1290
  }, string, vue.PublicProps, Readonly<__VLS_Props$5> & Readonly<{
1275
1291
  onDelete?: ((item: object) => any) | undefined;
1276
1292
  "onUpdate:modelValue"?: ((list: object[]) => any) | undefined;
1277
1293
  onChange?: ((list: object[]) => any) | undefined;
1278
1294
  onExceed?: ((file: File) => any) | undefined;
1295
+ onUploaded?: ((item: AttachmentItem, result?: Partial<AttachmentItem> | undefined) => any) | undefined;
1279
1296
  }>, {
1280
1297
  locale: LocaleInput;
1281
1298
  modelValue: object[];
@@ -1284,6 +1301,7 @@ declare const __VLS_base$4: vue.DefineComponent<__VLS_Props$5, {
1284
1301
  tip: string;
1285
1302
  count: number;
1286
1303
  beforeUpload: (file: File) => boolean | Promise<boolean>;
1304
+ upload: AttachmentUpload;
1287
1305
  }, {}, {}, {}, string, vue.ComponentProvideOptions, false, {}, any>;
1288
1306
  declare const __VLS_export$5: __VLS_WithSlots$4<typeof __VLS_base$4, __VLS_Slots$4>;
1289
1307
  declare const _default$5: typeof __VLS_export$5;
@@ -1389,18 +1407,29 @@ type __VLS_WithSlots$3<T, S> = T & {
1389
1407
  };
1390
1408
  };
1391
1409
 
1410
+ /**
1411
+ * adapter 层透传的附件描述(结构兼容 types.ChatFile:消费方 ChatFile[] 可直传)。
1412
+ * 先传后发架构下 id 即消费方上传端点返回的附件标识,由 adapter 拼进 send 入参
1413
+ */
1414
+ interface AdapterChatFile {
1415
+ /** 附件标识(先传后发场景为服务端附件 id) */
1416
+ id: string;
1417
+ name?: string;
1418
+ url?: string;
1419
+ type?: 'image' | 'file';
1420
+ size?: number;
1421
+ }
1392
1422
  /** adapter 层透传的 OpenAI 风格消息 */
1393
1423
  interface AdapterChatMessage {
1394
1424
  role: 'user' | 'assistant' | 'system' | string;
1395
1425
  content: string;
1426
+ /** 本条消息携带的附件(user 行;缺省无附件) */
1427
+ files?: AdapterChatFile[];
1396
1428
  }
1397
1429
  /** 发送请求体 */
1398
1430
  interface ChatAdapterRequest {
1399
1431
  /** 对话消息(时间正序) */
1400
- messages: Array<{
1401
- role: string;
1402
- content: string;
1403
- }>;
1432
+ messages: Array<AdapterChatMessage>;
1404
1433
  /** 覆盖配置中的模型 */
1405
1434
  model?: string;
1406
1435
  /** 是否流式,默认 true */
@@ -1432,6 +1461,12 @@ interface ChatAdapterHandlers {
1432
1461
  toolName: string;
1433
1462
  status: 'start' | 'done';
1434
1463
  }): void;
1464
+ /**
1465
+ * 追问建议(可选):Fv 系 V58+ suggestions 事件(流式收尾 0..1 次,必在 message_end
1466
+ * 之前);开关关闭/模型未产出/中断/失败无此事件。开关开启时回答末尾生成可点击
1467
+ * 追问 chips,点击即作为新用户消息发送
1468
+ */
1469
+ onSuggestions?(items: string[]): void;
1435
1470
  /** 正常结束(含非流式) */
1436
1471
  onDone(): void;
1437
1472
  /** 出错(HTTP 非 2xx / 网络 / 中断) */
@@ -1465,7 +1500,8 @@ declare function OpenAIAdapter(config: OpenAIAdapterConfig): ChatAdapter;
1465
1500
  * Fv 系后端通用聊天适配器(`/api/ai-chat/*`):六事件 SSE 协议
1466
1501
  * (message_start / tool / delta / reasoning / message_end / error),POST `/message/send`。
1467
1502
  * 适用于 Fv 各项目组返回此结构的后端;V57 起新增 reasoning 思考事件
1468
- * (载荷 {text} 与 delta 同构,多轮每轮都推,无思考轮不推)。
1503
+ * (载荷 {text} 与 delta 同构,多轮每轮都推,无思考轮不推);
1504
+ * V58 起新增 suggestions 追问建议事件(流式收尾时 0..1 次,必在 message_end 之前)。
1469
1505
  * 本适配器负责协议解析与事件分发,
1470
1506
  * 会话管理(列表/归档/删除等)由消费方直接调后端,不经此适配器。
1471
1507
  */
@@ -1492,7 +1528,7 @@ interface FvCommonSessionItem {
1492
1528
  createdTime?: string;
1493
1529
  updatedTime?: string;
1494
1530
  }
1495
- /** 历史/详情消息行(assistant 行 toolCalls 为 JSON 字符串,消费方自行 JSON.parse) */
1531
+ /** 历史/详情消息行(assistant 行 toolCalls/suggestions 为 JSON 字符串,消费方自行 JSON.parse) */
1496
1532
  interface FvCommonMessage {
1497
1533
  id: string;
1498
1534
  seq: number;
@@ -1506,6 +1542,13 @@ interface FvCommonMessage {
1506
1542
  toolCalls?: string | null;
1507
1543
  toolCallId?: string | null;
1508
1544
  toolName?: string | null;
1545
+ /**
1546
+ * V58+ 追问建议(仅 assistant 行且 status=SUCCESS 的最终回答非 null;user/tool 行、
1547
+ * GENERATING/INTERRUPTED/FAILED 行、开关关闭期间旧行恒 null)。JSON 数组原文透传
1548
+ * (如 '["问题1","问题2","问题3"]'),与 toolCalls 同款约定:消费方 JSON.parse 并
1549
+ * try-catch 包裹,解析失败按 null 处理不渲染(见 parseSuggestions)
1550
+ */
1551
+ suggestions?: string | null;
1509
1552
  status?: 'GENERATING' | 'SUCCESS' | 'FAILED' | 'INTERRUPTED' | null;
1510
1553
  failReason?: string | null;
1511
1554
  promptTokens?: number | null;
@@ -1539,6 +1582,13 @@ declare class FvCommonError extends Error {
1539
1582
  code?: number | string;
1540
1583
  constructor(message: string, code?: number | string);
1541
1584
  }
1585
+ /**
1586
+ * 安全解析历史消息行的追问建议(FvCommonMessage.suggestions,JSON 数组原文透传)。
1587
+ * 与 toolCalls 同款约定:try-catch 包裹,脏数据(非 JSON/非字符串数组/全空)按无建议
1588
+ * 处理返回 undefined。仅 assistant 行且 status=SUCCESS 的最终回答字段非 null,
1589
+ * 但本函数不校验角色/状态(调用方已按行筛选),只做形状容错。
1590
+ */
1591
+ declare function parseSuggestions(raw: string | null | undefined): string[] | undefined;
1542
1592
  /**
1543
1593
  * Fv 系通用聊天适配器:消费六事件 SSE。
1544
1594
  * 同步段失败(会话不存在/单飞行闸/未启用/参数校验)发生在 SSE 建立前,
@@ -1611,13 +1661,17 @@ interface MessageUsage {
1611
1661
  }
1612
1662
  /** 消息附件文件描述(序列化安全:只含可 JSON 化字段,不含 File 原始对象) */
1613
1663
  interface ChatFile {
1614
- /** 附件唯一标识 */
1664
+ /** 附件唯一标识(先传后发架构下为服务端附件 id) */
1615
1665
  id: string;
1616
1666
  /** 文件名 */
1617
1667
  name: string;
1618
1668
  /** 体积(字节) */
1619
1669
  size?: number;
1620
- /** 预览/下载地址(data URL 或远程地址) */
1670
+ /**
1671
+ * 预览/下载地址(data URL、本地 objectURL 或远程地址)。
1672
+ * 远程地址需鉴权取流时经 AiChat 的 resolveFileUrl 换可渲染地址,
1673
+ * 此时本字段存原始远程地址(供解析函数取用)
1674
+ */
1621
1675
  url?: string;
1622
1676
  /** 附件类别,缺省按 'file' 处理 */
1623
1677
  type?: 'image' | 'file';
@@ -1667,6 +1721,12 @@ interface MessageNode {
1667
1721
  model?: string;
1668
1722
  /** 后端消息行 id(Fv 系带会话管理后端):流式 message_end 时回填,UI 落库/对账锚定用 */
1669
1723
  backendId?: string;
1724
+ /**
1725
+ * 追问建议(Fv 系 V58+:回答末尾生成的可点击追问 chips,点击即作为新用户消息发送)。
1726
+ * 流式经 adapter onSuggestions 回写;历史恢复由消费方从 FvCommonMessage.suggestions
1727
+ * (JSON 数组原文)解析灌入。空/缺省不渲染;展示端仅链尾消息渲染 chips
1728
+ */
1729
+ suggestions?: string[];
1670
1730
  /** 中间轮工具调用列表(JSON 字符串或已展开数组;Fv 系 assistant 行 toolCalls 非空即中间轮) */
1671
1731
  toolCalls?: string | ToolCallItem[];
1672
1732
  /** 父节点 id,根消息为 null */
@@ -1785,6 +1845,11 @@ type __VLS_Props$3 = {
1785
1845
  showTime?: boolean;
1786
1846
  /** 消息时间自定义格式化(透传 AiMessage) */
1787
1847
  timeFormat?: (message: MessageNode, timestamp: number) => string;
1848
+ /**
1849
+ * 附件地址解析钩子(鉴权取流;透传 AiMessage):消息附件 url 渲染前调用,
1850
+ * 返回可直渲地址;缺省原样使用 url
1851
+ */
1852
+ resolveFileUrl?: (file: ChatFile) => Promise<string> | string;
1788
1853
  /** 语言包:'zh-CN'/'en-US' 整包或部分文案对象(优先于祖先注入与全局设置) */
1789
1854
  locale?: LocaleInput;
1790
1855
  };
@@ -1805,28 +1870,28 @@ declare var __VLS_10: {};
1805
1870
  declare var __VLS_13: {};
1806
1871
  declare var __VLS_16$1: {};
1807
1872
  declare var __VLS_19: {};
1808
- declare var __VLS_40: {
1873
+ declare var __VLS_42: {
1809
1874
  message: MessageNode;
1810
1875
  };
1811
- declare var __VLS_43: {
1876
+ declare var __VLS_45: {
1812
1877
  message: MessageNode;
1813
1878
  };
1814
- declare var __VLS_46: {};
1815
- declare var __VLS_49: {
1879
+ declare var __VLS_48: {};
1880
+ declare var __VLS_51: {
1816
1881
  status: "thinking" | "error" | "done";
1817
1882
  message: MessageNode;
1818
1883
  };
1819
- declare var __VLS_52: {
1884
+ declare var __VLS_54: {
1820
1885
  message: MessageNode;
1821
1886
  };
1822
- declare var __VLS_55: {
1887
+ declare var __VLS_57: {
1823
1888
  message: MessageNode;
1824
1889
  };
1825
- declare var __VLS_63$1: {
1890
+ declare var __VLS_65$1: {
1826
1891
  scrollToBottom: typeof scrollToBottom;
1827
1892
  awayFromBottom: boolean;
1828
1893
  };
1829
- declare var __VLS_79: {};
1894
+ declare var __VLS_81: {};
1830
1895
  type __VLS_Slots$2 = {} & {
1831
1896
  empty?: (props: typeof __VLS_1$1) => any;
1832
1897
  } & {
@@ -1838,21 +1903,21 @@ type __VLS_Slots$2 = {} & {
1838
1903
  } & {
1839
1904
  'welcome-suggestions'?: (props: typeof __VLS_19) => any;
1840
1905
  } & {
1841
- 'message-avatar'?: (props: typeof __VLS_40) => any;
1906
+ 'message-avatar'?: (props: typeof __VLS_42) => any;
1842
1907
  } & {
1843
- 'message-actions'?: (props: typeof __VLS_43) => any;
1908
+ 'message-actions'?: (props: typeof __VLS_45) => any;
1844
1909
  } & {
1845
- 'user-avatar'?: (props: typeof __VLS_46) => any;
1910
+ 'user-avatar'?: (props: typeof __VLS_48) => any;
1846
1911
  } & {
1847
- 'assistant-avatar'?: (props: typeof __VLS_49) => any;
1912
+ 'assistant-avatar'?: (props: typeof __VLS_51) => any;
1848
1913
  } & {
1849
- 'user-name'?: (props: typeof __VLS_52) => any;
1914
+ 'user-name'?: (props: typeof __VLS_54) => any;
1850
1915
  } & {
1851
- 'assistant-name'?: (props: typeof __VLS_55) => any;
1916
+ 'assistant-name'?: (props: typeof __VLS_57) => any;
1852
1917
  } & {
1853
- 'scroll-button'?: (props: typeof __VLS_63$1) => any;
1918
+ 'scroll-button'?: (props: typeof __VLS_65$1) => any;
1854
1919
  } & {
1855
- 'scroll-button-icon'?: (props: typeof __VLS_79) => any;
1920
+ 'scroll-button-icon'?: (props: typeof __VLS_81) => any;
1856
1921
  };
1857
1922
  declare const __VLS_base$2: vue.DefineComponent<__VLS_Props$3, {
1858
1923
  scrollTo: typeof scrollTo$1;
@@ -1866,12 +1931,16 @@ declare const __VLS_base$2: vue.DefineComponent<__VLS_Props$3, {
1866
1931
  regenerate: (message: MessageNode) => any;
1867
1932
  select: (item: AiMessagesSuggestion) => any;
1868
1933
  "branch-change": (dir: BranchDirection, message: MessageNode) => any;
1934
+ "followup-select": (item: string, message: MessageNode) => any;
1935
+ "message-file-click": (file: ChatFile, message: MessageNode) => any;
1869
1936
  }, string, vue.PublicProps, Readonly<__VLS_Props$3> & Readonly<{
1870
1937
  onScroll?: ((event: Event) => any) | undefined;
1871
1938
  onCopy?: ((message: MessageNode) => any) | undefined;
1872
1939
  onRegenerate?: ((message: MessageNode) => any) | undefined;
1873
1940
  onSelect?: ((item: AiMessagesSuggestion) => any) | undefined;
1874
1941
  "onBranch-change"?: ((dir: BranchDirection, message: MessageNode) => any) | undefined;
1942
+ "onFollowup-select"?: ((item: string, message: MessageNode) => any) | undefined;
1943
+ "onMessage-file-click"?: ((file: ChatFile, message: MessageNode) => any) | undefined;
1875
1944
  }>, {
1876
1945
  description: string;
1877
1946
  name: string;
@@ -1899,6 +1968,7 @@ declare const __VLS_base$2: vue.DefineComponent<__VLS_Props$3, {
1899
1968
  assistantName: string;
1900
1969
  showTime: boolean;
1901
1970
  timeFormat: (message: MessageNode, timestamp: number) => string;
1971
+ resolveFileUrl: (file: ChatFile) => Promise<string> | string;
1902
1972
  suggestionsTitle: string;
1903
1973
  suggestionsWrap: boolean;
1904
1974
  scrollThreshold: number;
@@ -2027,6 +2097,18 @@ type __VLS_Props$2 = {
2027
2097
  accept?: string;
2028
2098
  /** 附件数量上限(透传 Attachments,0 不限) */
2029
2099
  attachmentLimit?: number;
2100
+ /**
2101
+ * 附件上传钩子(先传后发):选文件即调,成功返回附件描述(id/name/type 等回填列表项,
2102
+ * id 随发送进入 adapter 的 user 消息 files);返回错误文案串/抛错置 error 可重传。
2103
+ * 缺省不调(附件仅本地待发展示,不落服务端)
2104
+ */
2105
+ uploadAttachment?: (file: File, item: AttachmentItem) => Promise<Partial<AttachmentItem> | string | undefined | void> | Partial<AttachmentItem> | string | undefined | void;
2106
+ /**
2107
+ * 附件地址解析钩子(鉴权取流):消息气泡渲染附件 url 前调用,返回可直渲地址
2108
+ * (如 JWT fetch 换 blob objectURL)。缺省原样使用 url(blob/dataURL/公开地址)。
2109
+ * 消费方宜在钩子内按 url 缓存,避免同一附件重复取流
2110
+ */
2111
+ resolveFileUrl?: (file: ChatFile) => Promise<string> | string;
2030
2112
  /** 主题:light/dark/auto(注入 html dark class) */
2031
2113
  theme?: 'light' | 'dark' | 'auto';
2032
2114
  /** 语言包:'zh-CN'/'en-US' 整包或部分文案对象;解析后向整框后代注入(后代仍可用自身 locale prop 覆盖) */
@@ -2051,62 +2133,62 @@ declare function expandThoughtChains(): void;
2051
2133
  declare function collapseThoughtChains(): void;
2052
2134
  /** 消息区滚动到指定位置(透传 AiMessages scrollTo;options 同原生 ScrollToOptions) */
2053
2135
  declare function scrollTo(options: ScrollToOptions | number): void;
2054
- declare var __VLS_27: {
2136
+ declare var __VLS_29: {
2055
2137
  message: MessageNode;
2056
2138
  };
2057
- declare var __VLS_30: {
2139
+ declare var __VLS_32: {
2058
2140
  message: MessageNode;
2059
2141
  };
2060
- declare var __VLS_33: {};
2061
- declare var __VLS_36: {
2142
+ declare var __VLS_35: {};
2143
+ declare var __VLS_38: {
2062
2144
  status: "thinking" | "error" | "done";
2063
2145
  message: MessageNode;
2064
2146
  };
2065
- declare var __VLS_39: {
2147
+ declare var __VLS_41: {
2066
2148
  message: MessageNode;
2067
2149
  };
2068
- declare var __VLS_42: {
2150
+ declare var __VLS_44: {
2069
2151
  message: MessageNode;
2070
2152
  };
2071
- declare var __VLS_45: {};
2072
- declare var __VLS_48: {};
2073
- declare var __VLS_51: {};
2074
- declare var __VLS_54: {};
2075
- declare var __VLS_57: {};
2076
- declare var __VLS_60: {
2153
+ declare var __VLS_47: {};
2154
+ declare var __VLS_50: {};
2155
+ declare var __VLS_53: {};
2156
+ declare var __VLS_56: {};
2157
+ declare var __VLS_59: {};
2158
+ declare var __VLS_62: {
2077
2159
  scrollToBottom: (smooth?: boolean) => void;
2078
2160
  awayFromBottom: boolean;
2079
2161
  };
2080
- declare var __VLS_63: {};
2081
- declare var __VLS_99: {};
2162
+ declare var __VLS_65: {};
2163
+ declare var __VLS_103: {};
2082
2164
  type __VLS_Slots$1 = {} & {
2083
- 'message-avatar'?: (props: typeof __VLS_27) => any;
2165
+ 'message-avatar'?: (props: typeof __VLS_29) => any;
2084
2166
  } & {
2085
- 'message-actions'?: (props: typeof __VLS_30) => any;
2167
+ 'message-actions'?: (props: typeof __VLS_32) => any;
2086
2168
  } & {
2087
- 'user-avatar'?: (props: typeof __VLS_33) => any;
2169
+ 'user-avatar'?: (props: typeof __VLS_35) => any;
2088
2170
  } & {
2089
- 'assistant-avatar'?: (props: typeof __VLS_36) => any;
2171
+ 'assistant-avatar'?: (props: typeof __VLS_38) => any;
2090
2172
  } & {
2091
- 'user-name'?: (props: typeof __VLS_39) => any;
2173
+ 'user-name'?: (props: typeof __VLS_41) => any;
2092
2174
  } & {
2093
- 'assistant-name'?: (props: typeof __VLS_42) => any;
2175
+ 'assistant-name'?: (props: typeof __VLS_44) => any;
2094
2176
  } & {
2095
- empty?: (props: typeof __VLS_45) => any;
2177
+ empty?: (props: typeof __VLS_47) => any;
2096
2178
  } & {
2097
- 'welcome-name'?: (props: typeof __VLS_48) => any;
2179
+ 'welcome-name'?: (props: typeof __VLS_50) => any;
2098
2180
  } & {
2099
- 'welcome-description'?: (props: typeof __VLS_51) => any;
2181
+ 'welcome-description'?: (props: typeof __VLS_53) => any;
2100
2182
  } & {
2101
- 'welcome-icon'?: (props: typeof __VLS_54) => any;
2183
+ 'welcome-icon'?: (props: typeof __VLS_56) => any;
2102
2184
  } & {
2103
- 'welcome-suggestions'?: (props: typeof __VLS_57) => any;
2185
+ 'welcome-suggestions'?: (props: typeof __VLS_59) => any;
2104
2186
  } & {
2105
- 'scroll-button'?: (props: typeof __VLS_60) => any;
2187
+ 'scroll-button'?: (props: typeof __VLS_62) => any;
2106
2188
  } & {
2107
- 'scroll-button-icon'?: (props: typeof __VLS_63) => any;
2189
+ 'scroll-button-icon'?: (props: typeof __VLS_65) => any;
2108
2190
  } & {
2109
- 'sender-prefix'?: (props: typeof __VLS_99) => any;
2191
+ 'sender-prefix'?: (props: typeof __VLS_103) => any;
2110
2192
  };
2111
2193
  declare const __VLS_base$1: vue.DefineComponent<__VLS_Props$2, {
2112
2194
  sendMessage: typeof sendMessage;
@@ -2124,10 +2206,16 @@ declare const __VLS_base$1: vue.DefineComponent<__VLS_Props$2, {
2124
2206
  send: (text: string, files?: ChatFile[] | undefined) => any;
2125
2207
  error: (err: Error, message?: MessageNode | undefined) => any;
2126
2208
  "branch-change": (dir: BranchDirection, message: MessageNode) => any;
2209
+ "followup-select": (item: string, message: MessageNode) => any;
2210
+ "message-file-click": (file: ChatFile, message: MessageNode) => any;
2127
2211
  "update:messages": (value: MessageNode[]) => any;
2128
2212
  "suggestion-select": (item: AiChatSuggestion) => any;
2129
2213
  "message-complete": (message: MessageNode) => any;
2130
2214
  "attachment-exceed": (file: File) => any;
2215
+ "attachment-uploaded": (item: AttachmentItem, result: {
2216
+ ok: boolean;
2217
+ message?: string;
2218
+ }) => any;
2131
2219
  "tool-event": (ev: {
2132
2220
  toolName: string;
2133
2221
  status: "start" | "done";
@@ -2137,10 +2225,16 @@ declare const __VLS_base$1: vue.DefineComponent<__VLS_Props$2, {
2137
2225
  onSend?: ((text: string, files?: ChatFile[] | undefined) => any) | undefined;
2138
2226
  onError?: ((err: Error, message?: MessageNode | undefined) => any) | undefined;
2139
2227
  "onBranch-change"?: ((dir: BranchDirection, message: MessageNode) => any) | undefined;
2228
+ "onFollowup-select"?: ((item: string, message: MessageNode) => any) | undefined;
2229
+ "onMessage-file-click"?: ((file: ChatFile, message: MessageNode) => any) | undefined;
2140
2230
  "onUpdate:messages"?: ((value: MessageNode[]) => any) | undefined;
2141
2231
  "onSuggestion-select"?: ((item: AiChatSuggestion) => any) | undefined;
2142
2232
  "onMessage-complete"?: ((message: MessageNode) => any) | undefined;
2143
2233
  "onAttachment-exceed"?: ((file: File) => any) | undefined;
2234
+ "onAttachment-uploaded"?: ((item: AttachmentItem, result: {
2235
+ ok: boolean;
2236
+ message?: string;
2237
+ }) => any) | undefined;
2144
2238
  "onTool-event"?: ((ev: {
2145
2239
  toolName: string;
2146
2240
  status: "start" | "done";
@@ -2173,6 +2267,7 @@ declare const __VLS_base$1: vue.DefineComponent<__VLS_Props$2, {
2173
2267
  assistantName: string;
2174
2268
  showTime: boolean;
2175
2269
  timeFormat: (message: MessageNode, timestamp: number) => string;
2270
+ resolveFileUrl: (file: ChatFile) => Promise<string> | string;
2176
2271
  suggestionsWrap: boolean;
2177
2272
  scrollThreshold: number;
2178
2273
  showScrollButton: boolean;
@@ -2190,6 +2285,7 @@ declare const __VLS_base$1: vue.DefineComponent<__VLS_Props$2, {
2190
2285
  features: AiChatFeatures;
2191
2286
  allowAttachments: boolean;
2192
2287
  attachmentLimit: number;
2288
+ uploadAttachment: (file: File, item: AttachmentItem) => Promise<Partial<AttachmentItem> | string | undefined | void> | Partial<AttachmentItem> | string | undefined | void;
2193
2289
  theme: "light" | "dark" | "auto";
2194
2290
  }, {}, {}, {}, string, vue.ComponentProvideOptions, false, {}, any>;
2195
2291
  declare const __VLS_export$2: __VLS_WithSlots$1<typeof __VLS_base$1, __VLS_Slots$1>;
@@ -2213,6 +2309,11 @@ type __VLS_Props$1 = {
2213
2309
  message: MessageNode;
2214
2310
  /** 同层分支元数据;缺省视为单分支(不渲染切换器) */
2215
2311
  branch?: AiMessageBranchInfo;
2312
+ /**
2313
+ * 是否当前链最后一条消息(由 AiMessages 按链位置判定注入)。
2314
+ * 追问建议 chips 仅链尾消息渲染——此前消息即使留有 suggestions 也不显示
2315
+ */
2316
+ isLast?: boolean;
2216
2317
  /** 显示操作按钮(复制/重生成;仅 assistant) */
2217
2318
  showActions?: boolean;
2218
2319
  /** 显示分支切换器(branch.count > 1 时) */
@@ -2261,6 +2362,11 @@ type __VLS_Props$1 = {
2261
2362
  /** 消息时间自定义格式化(透传 message 与已归一为 ms 的时间戳;
2262
2363
  * 缺省自动识别 + 格式化为 'YYYY-MM-DD HH:mm',本机时区) */
2263
2364
  timeFormat?: (message: MessageNode, timestamp: number) => string;
2365
+ /**
2366
+ * 附件地址解析钩子(鉴权取流):附件 url 渲染前调用,返回可直渲地址
2367
+ * (如 JWT fetch 换 blob objectURL);缺省原样使用 url。消费方宜按 url 缓存
2368
+ */
2369
+ resolveFileUrl?: (file: ChatFile) => Promise<string> | string;
2264
2370
  /** 语言包:'zh-CN'/'en-US' 整包或部分文案对象(优先于祖先注入与全局设置) */
2265
2371
  locale?: LocaleInput;
2266
2372
  };
@@ -2285,7 +2391,7 @@ declare var __VLS_22: {
2285
2391
  message: MessageNode;
2286
2392
  files: ChatFile[];
2287
2393
  };
2288
- declare var __VLS_66: {
2394
+ declare var __VLS_73: {
2289
2395
  message: MessageNode;
2290
2396
  };
2291
2397
  type __VLS_Slots = {} & {
@@ -2301,7 +2407,7 @@ type __VLS_Slots = {} & {
2301
2407
  } & {
2302
2408
  'message-files'?: (props: typeof __VLS_22) => any;
2303
2409
  } & {
2304
- 'message-actions'?: (props: typeof __VLS_66) => any;
2410
+ 'message-actions'?: (props: typeof __VLS_73) => any;
2305
2411
  };
2306
2412
  declare const __VLS_base: vue.DefineComponent<__VLS_Props$1, {
2307
2413
  message: vue.ComputedRef<MessageNode>;
@@ -2312,11 +2418,15 @@ declare const __VLS_base: vue.DefineComponent<__VLS_Props$1, {
2312
2418
  regenerate: (message: MessageNode) => any;
2313
2419
  typing: () => any;
2314
2420
  "branch-change": (dir: BranchDirection, message: MessageNode) => any;
2421
+ "followup-select": (item: string, message: MessageNode) => any;
2422
+ "file-click": (file: ChatFile, message: MessageNode) => any;
2315
2423
  }, string, vue.PublicProps, Readonly<__VLS_Props$1> & Readonly<{
2316
2424
  onCopy?: ((message: MessageNode) => any) | undefined;
2317
2425
  onRegenerate?: ((message: MessageNode) => any) | undefined;
2318
2426
  onTyping?: (() => any) | undefined;
2319
2427
  "onBranch-change"?: ((dir: BranchDirection, message: MessageNode) => any) | undefined;
2428
+ "onFollowup-select"?: ((item: string, message: MessageNode) => any) | undefined;
2429
+ "onFile-click"?: ((file: ChatFile, message: MessageNode) => any) | undefined;
2320
2430
  }>, {
2321
2431
  typing: boolean | {
2322
2432
  step?: number;
@@ -2326,6 +2436,7 @@ declare const __VLS_base: vue.DefineComponent<__VLS_Props$1, {
2326
2436
  collapsible: boolean;
2327
2437
  showDuration: boolean;
2328
2438
  branch: AiMessageBranchInfo;
2439
+ isLast: boolean;
2329
2440
  showActions: boolean;
2330
2441
  showBranchSwitch: boolean;
2331
2442
  showUserAvatar: boolean;
@@ -2340,6 +2451,7 @@ declare const __VLS_base: vue.DefineComponent<__VLS_Props$1, {
2340
2451
  assistantName: string;
2341
2452
  showTime: boolean;
2342
2453
  timeFormat: (message: MessageNode, timestamp: number) => string;
2454
+ resolveFileUrl: (file: ChatFile) => Promise<string> | string;
2343
2455
  }, {}, {}, {}, string, vue.ComponentProvideOptions, false, {}, any>;
2344
2456
  declare const __VLS_export$1: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
2345
2457
  declare const _default$1: typeof __VLS_export$1;
@@ -2568,5 +2680,5 @@ declare function createMessageTree(initial?: {
2568
2680
 
2569
2681
  declare const version = "0.1.0";
2570
2682
 
2571
- export { _default as FvAiArtifacts, _default$2 as FvAiChat, _default$1 as FvAiMessage, _default$3 as FvAiMessages, _default$5 as FvAttachments, _default$f as FvBubble, _default$e as FvBubbleList, FvCommonAdapter, FvCommonError, _default$4 as FvConversations, _default$b as FvEditorSender, _default$6 as FvFilesCard, _default$h as FvMarkdown, _default$c as FvMentionSender, _default$7 as FvPrompts, _default$d as FvSender, _default$a as FvThinking, _default$9 as FvThoughtChain, _default$g as FvTypewriter, _default$8 as FvWelcome, OpenAIAdapter, XRequest, configureLocale, createLocalStorageAdapter, createMemoryAdapter, createMessageTree, createSSEParser, enUS, useChat, useMessages, useRecord, useSend, useXStream, version, zhCN };
2572
- export type { AdapterChatMessage, AiArtifactItem, AiChatArtifactsOptions, AiChatFeatures, AiChatSuggestion, AiMessageBranchInfo, AiMessagesSuggestion, BranchDirection, ChatAdapter, ChatAdapterHandlers, ChatAdapterRequest, ChatFile, DeepPartialLocale, FvCommonAdapterConfig, FvCommonMessage, FvCommonMessagePage, FvCommonSendBody, FvCommonSessionDetail, FvCommonSessionItem, FvCommonToolEvent, LocaleInput, LocaleMessages, MessageNode, MessageNodeInput, MessageRole, MessageStatus, MessageTree, MessageUsage, OpenAIAdapterConfig, QueueItem, RawUsage, SSEEvent, SSEParser, SendOptions, StorageAdapter, ToolCallItem, ToolStepItem, UseChatOptions, UseChatReturn, UseMessagesReturn, UseRecordReturn, UseSendReturn, UseXStreamReturn };
2683
+ export { _default as FvAiArtifacts, _default$2 as FvAiChat, _default$1 as FvAiMessage, _default$3 as FvAiMessages, _default$5 as FvAttachments, _default$f as FvBubble, _default$e as FvBubbleList, FvCommonAdapter, FvCommonError, _default$4 as FvConversations, _default$b as FvEditorSender, _default$6 as FvFilesCard, _default$h as FvMarkdown, _default$c as FvMentionSender, _default$7 as FvPrompts, _default$d as FvSender, _default$a as FvThinking, _default$9 as FvThoughtChain, _default$g as FvTypewriter, _default$8 as FvWelcome, OpenAIAdapter, XRequest, configureLocale, createLocalStorageAdapter, createMemoryAdapter, createMessageTree, createSSEParser, enUS, parseSuggestions, useChat, useMessages, useRecord, useSend, useXStream, version, zhCN };
2684
+ export type { AdapterChatFile, AdapterChatMessage, AiArtifactItem, AiChatArtifactsOptions, AiChatFeatures, AiChatSuggestion, AiMessageBranchInfo, AiMessagesSuggestion, AttachmentItem, AttachmentUpload, BranchDirection, ChatAdapter, ChatAdapterHandlers, ChatAdapterRequest, ChatFile, DeepPartialLocale, FvCommonAdapterConfig, FvCommonMessage, FvCommonMessagePage, FvCommonSendBody, FvCommonSessionDetail, FvCommonSessionItem, FvCommonToolEvent, LocaleInput, LocaleMessages, MessageNode, MessageNodeInput, MessageRole, MessageStatus, MessageTree, MessageUsage, OpenAIAdapterConfig, QueueItem, RawUsage, SSEEvent, SSEParser, SendOptions, StorageAdapter, ToolCallItem, ToolStepItem, UseChatOptions, UseChatReturn, UseMessagesReturn, UseRecordReturn, UseSendReturn, UseXStreamReturn };