@mxmweb/rtext 1.3.10 → 1.4.3

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.
@@ -0,0 +1,64 @@
1
+ /**
2
+ * 思维链相关的业务类型与节点状态枚举定义
3
+ * 2025-12-19 新增: 抽取统一的思维链类型,供历史会话与实时 SSE 复用。
4
+ */
5
+ /**
6
+ * 思维链节点业务类型
7
+ * - plan: 理解与规划
8
+ * - retrieve: 召回 / 检索
9
+ * - think: 深度思考
10
+ * - reason: 推理
11
+ */
12
+ export type ThoughtBusinessType = 'plan' | 'retrieve' | 'think' | 'reason';
13
+ /**
14
+ * 思维链节点状态枚举
15
+ * 1. 运行中 2. 完成 3. 失败 4. 异常
16
+ */
17
+ export type ThoughtNodeStatus = 1 | 2 | 3 | 4;
18
+ /**
19
+ * 思维链节点统一结构
20
+ * 用于在 UI 组件中展示 plan / retrieve / think 的进度与内容。
21
+ */
22
+ export interface ThoughtNode {
23
+ /** 节点唯一标识,可以由业务类型与顺序组合生成 */
24
+ id: string;
25
+ /** 业务类型:plan / retrieve / think */
26
+ businessType: ThoughtBusinessType;
27
+ /** 当前状态:待执行 / 运行中 / 完成 / 失败 / 异常 */
28
+ nodeStatus: ThoughtNodeStatus;
29
+ /** UI 中展示的标题,例如“理解规划完成”、“召回成功”等 */
30
+ title: string;
31
+ /** 主体内容文案,通常为模型生成的自然语言描述 */
32
+ content: string;
33
+ /** 原始业务数据,便于后续在弹窗中展示完整 JSON 或调试 */
34
+ rawContent?: any;
35
+ }
36
+ /**
37
+ * 思维链渲染模式
38
+ * - live: 实时流式 SSE 场景
39
+ * - history: 历史会话详情场景
40
+ */
41
+ export type ThoughtChainRenderMode = 'live' | 'history';
42
+ /**
43
+ * 思维链版本控制模式
44
+ * - auto: 默认按数据自动识别新老版本
45
+ * - v1: 强制使用旧版 <think> 解析逻辑
46
+ * - v2: 强制使用新版 chain + businessType/nodeStatus 逻辑
47
+ */
48
+ export type ThoughtChainVersionMode = 'auto' | 'v1' | 'v2';
49
+ /**
50
+ * 当前思维链解析版本开关
51
+ * 后续如果需要从外部注入(例如环境变量或运行时配置),可以调整为由上层传入。
52
+ */
53
+ export declare const DEFAULT_THOUGHT_CHAIN_VERSION: ThoughtChainVersionMode;
54
+ /**
55
+ * SSE 消息体的思维链相关字段
56
+ * 说明: 为了避免直接修改示例中的原始 SSEMessage 定义,将这一部分单独抽象,
57
+ * 由具体使用方通过交叉类型扩展。
58
+ */
59
+ export interface ThoughtSSEMeta {
60
+ /** 节点业务类型:plan / retrieve / think */
61
+ businessType?: ThoughtBusinessType;
62
+ /** 节点状态:1.待执行 2.运行中 3.执行完成 4.执行失败 5.异常 */
63
+ nodeStatus?: ThoughtNodeStatus;
64
+ }
@@ -0,0 +1,39 @@
1
+ import { ThoughtNode, ThoughtBusinessType, ThoughtNodeStatus } from '../thought_chain_types';
2
+ /**
3
+ * 历史 chain 原始节点类型(与后端对齐)
4
+ */
5
+ export interface RawChainNode {
6
+ businessType: ThoughtBusinessType;
7
+ nodeStatus: ThoughtNodeStatus;
8
+ content: string;
9
+ type?: string;
10
+ [key: string]: any;
11
+ }
12
+ /**
13
+ * 统一的标题映射
14
+ */
15
+ export declare function getThoughtTitleByBusinessType(type: ThoughtBusinessType): string;
16
+ /**
17
+ * 将历史回复中的 chain 数组映射为 UI 使用的 ThoughtNode 列表
18
+ * 2025-12-19 新增: 支持 rtext 思维链 UI 升级。
19
+ * 2025-01-28 更新: 支持历史数据中的 reply.content 结构。
20
+ */
21
+ export declare function mapReplyChainToNodes(chain: RawChainNode[] | undefined | null): ThoughtNode[];
22
+ /**
23
+ * SSE 消息在当前文件中只需要关心与思维链相关的字段。
24
+ * 这里使用 Pick 代替直接引入完整类型,避免与示例组件产生循环依赖。
25
+ */
26
+ export interface ThoughtSSEChunkMeta {
27
+ businessType?: ThoughtBusinessType;
28
+ nodeStatus?: ThoughtNodeStatus;
29
+ reply?: {
30
+ content?: string;
31
+ type?: string;
32
+ };
33
+ }
34
+ /**
35
+ * 将实时 SSE chunk 合并到现有 ThoughtNode 列表中
36
+ * - 若尚未存在对应业务类型,则创建一个新的节点
37
+ * - 若已存在,则根据 nodeStatus 更新状态与内容(追加文本)
38
+ */
39
+ export declare function mergeLiveChunkToNodes(nodes: ThoughtNode[], chunk: ThoughtSSEChunkMeta): ThoughtNode[];
@@ -1 +0,0 @@
1
- export default function SSEDemo(): import("react/jsx-runtime").JSX.Element;