@fv-ui/ai-chat 1.2.0 → 1.4.1

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/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,12 +1528,28 @@ 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;
1499
1535
  role: 'user' | 'assistant' | 'tool';
1500
1536
  content: string | null;
1537
+ /**
1538
+ * V1.1+ 消息附件(仅 user 行非 null;旧数据/无附件恒 null,判空容错)。
1539
+ * 元素与上传端点出参同构(AiChatAttachmentDTO:id/originalName/type/suffix/
1540
+ * sizeBytes/downloadUrl),但**不含 createdTime**(快照 JSON 无该键,勿依赖)。
1541
+ * 消费方映射为 MessageNode.files 渲染 chips(downloadUrl 需鉴权取流时配
1542
+ * AiChat 的 resolveFileUrl 钩子)
1543
+ */
1544
+ attachments?: Array<{
1545
+ id: string;
1546
+ originalName: string;
1547
+ type: 'IMAGE' | 'DOCUMENT' | string;
1548
+ suffix?: string;
1549
+ sizeBytes?: number;
1550
+ downloadUrl?: string;
1551
+ [k: string]: unknown;
1552
+ }> | null;
1501
1553
  /**
1502
1554
  * V57 思考留底(仅 assistant 最终行;null=GENERATING 未回写/user/tool 行恒 null,
1503
1555
  * 空串=该轮无思考)——判空须用 !!r && r.length > 0,勿用 != null
@@ -1506,6 +1558,13 @@ interface FvCommonMessage {
1506
1558
  toolCalls?: string | null;
1507
1559
  toolCallId?: string | null;
1508
1560
  toolName?: string | null;
1561
+ /**
1562
+ * V58+ 追问建议(仅 assistant 行且 status=SUCCESS 的最终回答非 null;user/tool 行、
1563
+ * GENERATING/INTERRUPTED/FAILED 行、开关关闭期间旧行恒 null)。JSON 数组原文透传
1564
+ * (如 '["问题1","问题2","问题3"]'),与 toolCalls 同款约定:消费方 JSON.parse 并
1565
+ * try-catch 包裹,解析失败按 null 处理不渲染(见 parseSuggestions)
1566
+ */
1567
+ suggestions?: string | null;
1509
1568
  status?: 'GENERATING' | 'SUCCESS' | 'FAILED' | 'INTERRUPTED' | null;
1510
1569
  failReason?: string | null;
1511
1570
  promptTokens?: number | null;
@@ -1539,6 +1598,13 @@ declare class FvCommonError extends Error {
1539
1598
  code?: number | string;
1540
1599
  constructor(message: string, code?: number | string);
1541
1600
  }
1601
+ /**
1602
+ * 安全解析历史消息行的追问建议(FvCommonMessage.suggestions,JSON 数组原文透传)。
1603
+ * 与 toolCalls 同款约定:try-catch 包裹,脏数据(非 JSON/非字符串数组/全空)按无建议
1604
+ * 处理返回 undefined。仅 assistant 行且 status=SUCCESS 的最终回答字段非 null,
1605
+ * 但本函数不校验角色/状态(调用方已按行筛选),只做形状容错。
1606
+ */
1607
+ declare function parseSuggestions(raw: string | null | undefined): string[] | undefined;
1542
1608
  /**
1543
1609
  * Fv 系通用聊天适配器:消费六事件 SSE。
1544
1610
  * 同步段失败(会话不存在/单飞行闸/未启用/参数校验)发生在 SSE 建立前,
@@ -1611,13 +1677,17 @@ interface MessageUsage {
1611
1677
  }
1612
1678
  /** 消息附件文件描述(序列化安全:只含可 JSON 化字段,不含 File 原始对象) */
1613
1679
  interface ChatFile {
1614
- /** 附件唯一标识 */
1680
+ /** 附件唯一标识(先传后发架构下为服务端附件 id) */
1615
1681
  id: string;
1616
1682
  /** 文件名 */
1617
1683
  name: string;
1618
1684
  /** 体积(字节) */
1619
1685
  size?: number;
1620
- /** 预览/下载地址(data URL 或远程地址) */
1686
+ /**
1687
+ * 预览/下载地址(data URL、本地 objectURL 或远程地址)。
1688
+ * 远程地址需鉴权取流时经 AiChat 的 resolveFileUrl 换可渲染地址,
1689
+ * 此时本字段存原始远程地址(供解析函数取用)
1690
+ */
1621
1691
  url?: string;
1622
1692
  /** 附件类别,缺省按 'file' 处理 */
1623
1693
  type?: 'image' | 'file';
@@ -1667,6 +1737,12 @@ interface MessageNode {
1667
1737
  model?: string;
1668
1738
  /** 后端消息行 id(Fv 系带会话管理后端):流式 message_end 时回填,UI 落库/对账锚定用 */
1669
1739
  backendId?: string;
1740
+ /**
1741
+ * 追问建议(Fv 系 V58+:回答末尾生成的可点击追问 chips,点击即作为新用户消息发送)。
1742
+ * 流式经 adapter onSuggestions 回写;历史恢复由消费方从 FvCommonMessage.suggestions
1743
+ * (JSON 数组原文)解析灌入。空/缺省不渲染;展示端仅链尾消息渲染 chips
1744
+ */
1745
+ suggestions?: string[];
1670
1746
  /** 中间轮工具调用列表(JSON 字符串或已展开数组;Fv 系 assistant 行 toolCalls 非空即中间轮) */
1671
1747
  toolCalls?: string | ToolCallItem[];
1672
1748
  /** 父节点 id,根消息为 null */
@@ -1785,6 +1861,11 @@ type __VLS_Props$3 = {
1785
1861
  showTime?: boolean;
1786
1862
  /** 消息时间自定义格式化(透传 AiMessage) */
1787
1863
  timeFormat?: (message: MessageNode, timestamp: number) => string;
1864
+ /**
1865
+ * 附件地址解析钩子(鉴权取流;透传 AiMessage):消息附件 url 渲染前调用,
1866
+ * 返回可直渲地址;缺省原样使用 url
1867
+ */
1868
+ resolveFileUrl?: (file: ChatFile) => Promise<string> | string;
1788
1869
  /** 语言包:'zh-CN'/'en-US' 整包或部分文案对象(优先于祖先注入与全局设置) */
1789
1870
  locale?: LocaleInput;
1790
1871
  };
@@ -1805,28 +1886,28 @@ declare var __VLS_10: {};
1805
1886
  declare var __VLS_13: {};
1806
1887
  declare var __VLS_16$1: {};
1807
1888
  declare var __VLS_19: {};
1808
- declare var __VLS_40: {
1889
+ declare var __VLS_42: {
1809
1890
  message: MessageNode;
1810
1891
  };
1811
- declare var __VLS_43: {
1892
+ declare var __VLS_45: {
1812
1893
  message: MessageNode;
1813
1894
  };
1814
- declare var __VLS_46: {};
1815
- declare var __VLS_49: {
1895
+ declare var __VLS_48: {};
1896
+ declare var __VLS_51: {
1816
1897
  status: "thinking" | "error" | "done";
1817
1898
  message: MessageNode;
1818
1899
  };
1819
- declare var __VLS_52: {
1900
+ declare var __VLS_54: {
1820
1901
  message: MessageNode;
1821
1902
  };
1822
- declare var __VLS_55: {
1903
+ declare var __VLS_57: {
1823
1904
  message: MessageNode;
1824
1905
  };
1825
- declare var __VLS_63$1: {
1906
+ declare var __VLS_65$1: {
1826
1907
  scrollToBottom: typeof scrollToBottom;
1827
1908
  awayFromBottom: boolean;
1828
1909
  };
1829
- declare var __VLS_79: {};
1910
+ declare var __VLS_81: {};
1830
1911
  type __VLS_Slots$2 = {} & {
1831
1912
  empty?: (props: typeof __VLS_1$1) => any;
1832
1913
  } & {
@@ -1838,21 +1919,21 @@ type __VLS_Slots$2 = {} & {
1838
1919
  } & {
1839
1920
  'welcome-suggestions'?: (props: typeof __VLS_19) => any;
1840
1921
  } & {
1841
- 'message-avatar'?: (props: typeof __VLS_40) => any;
1922
+ 'message-avatar'?: (props: typeof __VLS_42) => any;
1842
1923
  } & {
1843
- 'message-actions'?: (props: typeof __VLS_43) => any;
1924
+ 'message-actions'?: (props: typeof __VLS_45) => any;
1844
1925
  } & {
1845
- 'user-avatar'?: (props: typeof __VLS_46) => any;
1926
+ 'user-avatar'?: (props: typeof __VLS_48) => any;
1846
1927
  } & {
1847
- 'assistant-avatar'?: (props: typeof __VLS_49) => any;
1928
+ 'assistant-avatar'?: (props: typeof __VLS_51) => any;
1848
1929
  } & {
1849
- 'user-name'?: (props: typeof __VLS_52) => any;
1930
+ 'user-name'?: (props: typeof __VLS_54) => any;
1850
1931
  } & {
1851
- 'assistant-name'?: (props: typeof __VLS_55) => any;
1932
+ 'assistant-name'?: (props: typeof __VLS_57) => any;
1852
1933
  } & {
1853
- 'scroll-button'?: (props: typeof __VLS_63$1) => any;
1934
+ 'scroll-button'?: (props: typeof __VLS_65$1) => any;
1854
1935
  } & {
1855
- 'scroll-button-icon'?: (props: typeof __VLS_79) => any;
1936
+ 'scroll-button-icon'?: (props: typeof __VLS_81) => any;
1856
1937
  };
1857
1938
  declare const __VLS_base$2: vue.DefineComponent<__VLS_Props$3, {
1858
1939
  scrollTo: typeof scrollTo$1;
@@ -1866,12 +1947,16 @@ declare const __VLS_base$2: vue.DefineComponent<__VLS_Props$3, {
1866
1947
  regenerate: (message: MessageNode) => any;
1867
1948
  select: (item: AiMessagesSuggestion) => any;
1868
1949
  "branch-change": (dir: BranchDirection, message: MessageNode) => any;
1950
+ "followup-select": (item: string, message: MessageNode) => any;
1951
+ "message-file-click": (file: ChatFile, message: MessageNode) => any;
1869
1952
  }, string, vue.PublicProps, Readonly<__VLS_Props$3> & Readonly<{
1870
1953
  onScroll?: ((event: Event) => any) | undefined;
1871
1954
  onCopy?: ((message: MessageNode) => any) | undefined;
1872
1955
  onRegenerate?: ((message: MessageNode) => any) | undefined;
1873
1956
  onSelect?: ((item: AiMessagesSuggestion) => any) | undefined;
1874
1957
  "onBranch-change"?: ((dir: BranchDirection, message: MessageNode) => any) | undefined;
1958
+ "onFollowup-select"?: ((item: string, message: MessageNode) => any) | undefined;
1959
+ "onMessage-file-click"?: ((file: ChatFile, message: MessageNode) => any) | undefined;
1875
1960
  }>, {
1876
1961
  description: string;
1877
1962
  name: string;
@@ -1899,6 +1984,7 @@ declare const __VLS_base$2: vue.DefineComponent<__VLS_Props$3, {
1899
1984
  assistantName: string;
1900
1985
  showTime: boolean;
1901
1986
  timeFormat: (message: MessageNode, timestamp: number) => string;
1987
+ resolveFileUrl: (file: ChatFile) => Promise<string> | string;
1902
1988
  suggestionsTitle: string;
1903
1989
  suggestionsWrap: boolean;
1904
1990
  scrollThreshold: number;
@@ -2027,6 +2113,18 @@ type __VLS_Props$2 = {
2027
2113
  accept?: string;
2028
2114
  /** 附件数量上限(透传 Attachments,0 不限) */
2029
2115
  attachmentLimit?: number;
2116
+ /**
2117
+ * 附件上传钩子(先传后发):选文件即调,成功返回附件描述(id/name/type 等回填列表项,
2118
+ * id 随发送进入 adapter 的 user 消息 files);返回错误文案串/抛错置 error 可重传。
2119
+ * 缺省不调(附件仅本地待发展示,不落服务端)
2120
+ */
2121
+ uploadAttachment?: (file: File, item: AttachmentItem) => Promise<Partial<AttachmentItem> | string | undefined | void> | Partial<AttachmentItem> | string | undefined | void;
2122
+ /**
2123
+ * 附件地址解析钩子(鉴权取流):消息气泡渲染附件 url 前调用,返回可直渲地址
2124
+ * (如 JWT fetch 换 blob objectURL)。缺省原样使用 url(blob/dataURL/公开地址)。
2125
+ * 消费方宜在钩子内按 url 缓存,避免同一附件重复取流
2126
+ */
2127
+ resolveFileUrl?: (file: ChatFile) => Promise<string> | string;
2030
2128
  /** 主题:light/dark/auto(注入 html dark class) */
2031
2129
  theme?: 'light' | 'dark' | 'auto';
2032
2130
  /** 语言包:'zh-CN'/'en-US' 整包或部分文案对象;解析后向整框后代注入(后代仍可用自身 locale prop 覆盖) */
@@ -2051,62 +2149,62 @@ declare function expandThoughtChains(): void;
2051
2149
  declare function collapseThoughtChains(): void;
2052
2150
  /** 消息区滚动到指定位置(透传 AiMessages scrollTo;options 同原生 ScrollToOptions) */
2053
2151
  declare function scrollTo(options: ScrollToOptions | number): void;
2054
- declare var __VLS_27: {
2152
+ declare var __VLS_29: {
2055
2153
  message: MessageNode;
2056
2154
  };
2057
- declare var __VLS_30: {
2155
+ declare var __VLS_32: {
2058
2156
  message: MessageNode;
2059
2157
  };
2060
- declare var __VLS_33: {};
2061
- declare var __VLS_36: {
2158
+ declare var __VLS_35: {};
2159
+ declare var __VLS_38: {
2062
2160
  status: "thinking" | "error" | "done";
2063
2161
  message: MessageNode;
2064
2162
  };
2065
- declare var __VLS_39: {
2163
+ declare var __VLS_41: {
2066
2164
  message: MessageNode;
2067
2165
  };
2068
- declare var __VLS_42: {
2166
+ declare var __VLS_44: {
2069
2167
  message: MessageNode;
2070
2168
  };
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: {
2169
+ declare var __VLS_47: {};
2170
+ declare var __VLS_50: {};
2171
+ declare var __VLS_53: {};
2172
+ declare var __VLS_56: {};
2173
+ declare var __VLS_59: {};
2174
+ declare var __VLS_62: {
2077
2175
  scrollToBottom: (smooth?: boolean) => void;
2078
2176
  awayFromBottom: boolean;
2079
2177
  };
2080
- declare var __VLS_63: {};
2081
- declare var __VLS_99: {};
2178
+ declare var __VLS_65: {};
2179
+ declare var __VLS_103: {};
2082
2180
  type __VLS_Slots$1 = {} & {
2083
- 'message-avatar'?: (props: typeof __VLS_27) => any;
2181
+ 'message-avatar'?: (props: typeof __VLS_29) => any;
2084
2182
  } & {
2085
- 'message-actions'?: (props: typeof __VLS_30) => any;
2183
+ 'message-actions'?: (props: typeof __VLS_32) => any;
2086
2184
  } & {
2087
- 'user-avatar'?: (props: typeof __VLS_33) => any;
2185
+ 'user-avatar'?: (props: typeof __VLS_35) => any;
2088
2186
  } & {
2089
- 'assistant-avatar'?: (props: typeof __VLS_36) => any;
2187
+ 'assistant-avatar'?: (props: typeof __VLS_38) => any;
2090
2188
  } & {
2091
- 'user-name'?: (props: typeof __VLS_39) => any;
2189
+ 'user-name'?: (props: typeof __VLS_41) => any;
2092
2190
  } & {
2093
- 'assistant-name'?: (props: typeof __VLS_42) => any;
2191
+ 'assistant-name'?: (props: typeof __VLS_44) => any;
2094
2192
  } & {
2095
- empty?: (props: typeof __VLS_45) => any;
2193
+ empty?: (props: typeof __VLS_47) => any;
2096
2194
  } & {
2097
- 'welcome-name'?: (props: typeof __VLS_48) => any;
2195
+ 'welcome-name'?: (props: typeof __VLS_50) => any;
2098
2196
  } & {
2099
- 'welcome-description'?: (props: typeof __VLS_51) => any;
2197
+ 'welcome-description'?: (props: typeof __VLS_53) => any;
2100
2198
  } & {
2101
- 'welcome-icon'?: (props: typeof __VLS_54) => any;
2199
+ 'welcome-icon'?: (props: typeof __VLS_56) => any;
2102
2200
  } & {
2103
- 'welcome-suggestions'?: (props: typeof __VLS_57) => any;
2201
+ 'welcome-suggestions'?: (props: typeof __VLS_59) => any;
2104
2202
  } & {
2105
- 'scroll-button'?: (props: typeof __VLS_60) => any;
2203
+ 'scroll-button'?: (props: typeof __VLS_62) => any;
2106
2204
  } & {
2107
- 'scroll-button-icon'?: (props: typeof __VLS_63) => any;
2205
+ 'scroll-button-icon'?: (props: typeof __VLS_65) => any;
2108
2206
  } & {
2109
- 'sender-prefix'?: (props: typeof __VLS_99) => any;
2207
+ 'sender-prefix'?: (props: typeof __VLS_103) => any;
2110
2208
  };
2111
2209
  declare const __VLS_base$1: vue.DefineComponent<__VLS_Props$2, {
2112
2210
  sendMessage: typeof sendMessage;
@@ -2124,10 +2222,16 @@ declare const __VLS_base$1: vue.DefineComponent<__VLS_Props$2, {
2124
2222
  send: (text: string, files?: ChatFile[] | undefined) => any;
2125
2223
  error: (err: Error, message?: MessageNode | undefined) => any;
2126
2224
  "branch-change": (dir: BranchDirection, message: MessageNode) => any;
2225
+ "followup-select": (item: string, message: MessageNode) => any;
2226
+ "message-file-click": (file: ChatFile, message: MessageNode) => any;
2127
2227
  "update:messages": (value: MessageNode[]) => any;
2128
2228
  "suggestion-select": (item: AiChatSuggestion) => any;
2129
2229
  "message-complete": (message: MessageNode) => any;
2130
2230
  "attachment-exceed": (file: File) => any;
2231
+ "attachment-uploaded": (item: AttachmentItem, result: {
2232
+ ok: boolean;
2233
+ message?: string;
2234
+ }) => any;
2131
2235
  "tool-event": (ev: {
2132
2236
  toolName: string;
2133
2237
  status: "start" | "done";
@@ -2137,10 +2241,16 @@ declare const __VLS_base$1: vue.DefineComponent<__VLS_Props$2, {
2137
2241
  onSend?: ((text: string, files?: ChatFile[] | undefined) => any) | undefined;
2138
2242
  onError?: ((err: Error, message?: MessageNode | undefined) => any) | undefined;
2139
2243
  "onBranch-change"?: ((dir: BranchDirection, message: MessageNode) => any) | undefined;
2244
+ "onFollowup-select"?: ((item: string, message: MessageNode) => any) | undefined;
2245
+ "onMessage-file-click"?: ((file: ChatFile, message: MessageNode) => any) | undefined;
2140
2246
  "onUpdate:messages"?: ((value: MessageNode[]) => any) | undefined;
2141
2247
  "onSuggestion-select"?: ((item: AiChatSuggestion) => any) | undefined;
2142
2248
  "onMessage-complete"?: ((message: MessageNode) => any) | undefined;
2143
2249
  "onAttachment-exceed"?: ((file: File) => any) | undefined;
2250
+ "onAttachment-uploaded"?: ((item: AttachmentItem, result: {
2251
+ ok: boolean;
2252
+ message?: string;
2253
+ }) => any) | undefined;
2144
2254
  "onTool-event"?: ((ev: {
2145
2255
  toolName: string;
2146
2256
  status: "start" | "done";
@@ -2173,6 +2283,7 @@ declare const __VLS_base$1: vue.DefineComponent<__VLS_Props$2, {
2173
2283
  assistantName: string;
2174
2284
  showTime: boolean;
2175
2285
  timeFormat: (message: MessageNode, timestamp: number) => string;
2286
+ resolveFileUrl: (file: ChatFile) => Promise<string> | string;
2176
2287
  suggestionsWrap: boolean;
2177
2288
  scrollThreshold: number;
2178
2289
  showScrollButton: boolean;
@@ -2190,6 +2301,7 @@ declare const __VLS_base$1: vue.DefineComponent<__VLS_Props$2, {
2190
2301
  features: AiChatFeatures;
2191
2302
  allowAttachments: boolean;
2192
2303
  attachmentLimit: number;
2304
+ uploadAttachment: (file: File, item: AttachmentItem) => Promise<Partial<AttachmentItem> | string | undefined | void> | Partial<AttachmentItem> | string | undefined | void;
2193
2305
  theme: "light" | "dark" | "auto";
2194
2306
  }, {}, {}, {}, string, vue.ComponentProvideOptions, false, {}, any>;
2195
2307
  declare const __VLS_export$2: __VLS_WithSlots$1<typeof __VLS_base$1, __VLS_Slots$1>;
@@ -2213,6 +2325,11 @@ type __VLS_Props$1 = {
2213
2325
  message: MessageNode;
2214
2326
  /** 同层分支元数据;缺省视为单分支(不渲染切换器) */
2215
2327
  branch?: AiMessageBranchInfo;
2328
+ /**
2329
+ * 是否当前链最后一条消息(由 AiMessages 按链位置判定注入)。
2330
+ * 追问建议 chips 仅链尾消息渲染——此前消息即使留有 suggestions 也不显示
2331
+ */
2332
+ isLast?: boolean;
2216
2333
  /** 显示操作按钮(复制/重生成;仅 assistant) */
2217
2334
  showActions?: boolean;
2218
2335
  /** 显示分支切换器(branch.count > 1 时) */
@@ -2261,6 +2378,11 @@ type __VLS_Props$1 = {
2261
2378
  /** 消息时间自定义格式化(透传 message 与已归一为 ms 的时间戳;
2262
2379
  * 缺省自动识别 + 格式化为 'YYYY-MM-DD HH:mm',本机时区) */
2263
2380
  timeFormat?: (message: MessageNode, timestamp: number) => string;
2381
+ /**
2382
+ * 附件地址解析钩子(鉴权取流):附件 url 渲染前调用,返回可直渲地址
2383
+ * (如 JWT fetch 换 blob objectURL);缺省原样使用 url。消费方宜按 url 缓存
2384
+ */
2385
+ resolveFileUrl?: (file: ChatFile) => Promise<string> | string;
2264
2386
  /** 语言包:'zh-CN'/'en-US' 整包或部分文案对象(优先于祖先注入与全局设置) */
2265
2387
  locale?: LocaleInput;
2266
2388
  };
@@ -2285,7 +2407,7 @@ declare var __VLS_22: {
2285
2407
  message: MessageNode;
2286
2408
  files: ChatFile[];
2287
2409
  };
2288
- declare var __VLS_66: {
2410
+ declare var __VLS_73: {
2289
2411
  message: MessageNode;
2290
2412
  };
2291
2413
  type __VLS_Slots = {} & {
@@ -2301,7 +2423,7 @@ type __VLS_Slots = {} & {
2301
2423
  } & {
2302
2424
  'message-files'?: (props: typeof __VLS_22) => any;
2303
2425
  } & {
2304
- 'message-actions'?: (props: typeof __VLS_66) => any;
2426
+ 'message-actions'?: (props: typeof __VLS_73) => any;
2305
2427
  };
2306
2428
  declare const __VLS_base: vue.DefineComponent<__VLS_Props$1, {
2307
2429
  message: vue.ComputedRef<MessageNode>;
@@ -2312,11 +2434,15 @@ declare const __VLS_base: vue.DefineComponent<__VLS_Props$1, {
2312
2434
  regenerate: (message: MessageNode) => any;
2313
2435
  typing: () => any;
2314
2436
  "branch-change": (dir: BranchDirection, message: MessageNode) => any;
2437
+ "followup-select": (item: string, message: MessageNode) => any;
2438
+ "file-click": (file: ChatFile, message: MessageNode) => any;
2315
2439
  }, string, vue.PublicProps, Readonly<__VLS_Props$1> & Readonly<{
2316
2440
  onCopy?: ((message: MessageNode) => any) | undefined;
2317
2441
  onRegenerate?: ((message: MessageNode) => any) | undefined;
2318
2442
  onTyping?: (() => any) | undefined;
2319
2443
  "onBranch-change"?: ((dir: BranchDirection, message: MessageNode) => any) | undefined;
2444
+ "onFollowup-select"?: ((item: string, message: MessageNode) => any) | undefined;
2445
+ "onFile-click"?: ((file: ChatFile, message: MessageNode) => any) | undefined;
2320
2446
  }>, {
2321
2447
  typing: boolean | {
2322
2448
  step?: number;
@@ -2326,6 +2452,7 @@ declare const __VLS_base: vue.DefineComponent<__VLS_Props$1, {
2326
2452
  collapsible: boolean;
2327
2453
  showDuration: boolean;
2328
2454
  branch: AiMessageBranchInfo;
2455
+ isLast: boolean;
2329
2456
  showActions: boolean;
2330
2457
  showBranchSwitch: boolean;
2331
2458
  showUserAvatar: boolean;
@@ -2340,6 +2467,7 @@ declare const __VLS_base: vue.DefineComponent<__VLS_Props$1, {
2340
2467
  assistantName: string;
2341
2468
  showTime: boolean;
2342
2469
  timeFormat: (message: MessageNode, timestamp: number) => string;
2470
+ resolveFileUrl: (file: ChatFile) => Promise<string> | string;
2343
2471
  }, {}, {}, {}, string, vue.ComponentProvideOptions, false, {}, any>;
2344
2472
  declare const __VLS_export$1: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
2345
2473
  declare const _default$1: typeof __VLS_export$1;
@@ -2568,5 +2696,5 @@ declare function createMessageTree(initial?: {
2568
2696
 
2569
2697
  declare const version = "0.1.0";
2570
2698
 
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 };
2699
+ 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 };
2700
+ 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 };