@somecat/ai-assist-sdk 1.2.6 → 1.3.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.
@@ -55670,7 +55670,26 @@ const MC = /* @__PURE__ */ Qs(xC), LC = new lt({
55670
55670
  return t;
55671
55671
  const o = a.index;
55672
55672
  return t.slice(0, o) + '<span class="streaming-cursor"></span>' + t.slice(o);
55673
- }, yh = () => {
55673
+ }, yh = (t) => {
55674
+ const e = t ?? [];
55675
+ if (e.length <= 1) return [...e];
55676
+ const n = (a) => {
55677
+ if (typeof a == "number") return Number.isFinite(a) && a > 0 ? a : void 0;
55678
+ if (typeof a == "string" && a) {
55679
+ const i = Number(a);
55680
+ if (Number.isFinite(i) && i > 0) return i;
55681
+ const o = Date.parse(a);
55682
+ if (!Number.isNaN(o)) return o;
55683
+ }
55684
+ }, r = e.map((a) => {
55685
+ var i, o;
55686
+ return {
55687
+ item: a,
55688
+ time: n((i = a.answerInfo) == null ? void 0 : i.createdTime) ?? n((o = a.answerInfo) == null ? void 0 : o.createTime) ?? n(a.createdTime) ?? n(a.createTime)
55689
+ };
55690
+ });
55691
+ return r.every((a) => a.time != null) ? r.sort((a, i) => a.time - i.time).map((a) => a.item) : [...e].reverse();
55692
+ }, vh = () => {
55674
55693
  if (typeof document > "u") return;
55675
55694
  let t = document.querySelector('meta[name="viewport"]');
55676
55695
  if (!t) {
@@ -55686,7 +55705,7 @@ const MC = /* @__PURE__ */ Qs(xC), LC = new lt({
55686
55705
  if (!isNaN(e)) return e;
55687
55706
  }
55688
55707
  return 0;
55689
- }, vh = (t) => {
55708
+ }, Dh = (t) => {
55690
55709
  const e = /* @__PURE__ */ new Date(), n = new Date(e.getFullYear(), e.getMonth(), e.getDate()).getTime(), r = n - 7 * xd, a = n - 30 * xd, i = [], o = [], s = [], c = /* @__PURE__ */ new Map(), l = [...t].sort((m, p) => Cs(p) - Cs(m));
55691
55710
  for (const m of l) {
55692
55711
  const p = Cs(m);
@@ -55708,10 +55727,10 @@ const MC = /* @__PURE__ */ Qs(xC), LC = new lt({
55708
55727
  for (const m of _)
55709
55728
  u.push({ label: m, items: c.get(m) });
55710
55729
  return u;
55711
- }, PC = "#ai-assist-root", kC = (t = "light") => t === "auto" ? typeof window < "u" && window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : t, Dh = (t = "light") => {
55730
+ }, PC = "#ai-assist-root", kC = (t = "light") => t === "auto" ? typeof window < "u" && window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : t, xh = (t = "light") => {
55712
55731
  const e = kC(t), n = document.querySelector(PC);
55713
55732
  return n && n.setAttribute("data-theme", e), e;
55714
- }, xh = (t) => {
55733
+ }, Mh = (t) => {
55715
55734
  if (typeof window > "u" || !window.matchMedia) return () => {
55716
55735
  };
55717
55736
  const e = window.matchMedia("(prefers-color-scheme: dark)"), n = (r) => {
@@ -55844,12 +55863,13 @@ class Lp {
55844
55863
  }
55845
55864
  }
55846
55865
  export {
55847
- yt as A,
55848
- Ah as B,
55849
- Oh as C,
55850
- Zn as D,
55851
- Ch as E,
55852
- Nh as F,
55866
+ mh as A,
55867
+ yt as B,
55868
+ Ah as C,
55869
+ Oh as D,
55870
+ Zn as E,
55871
+ Ch as F,
55872
+ Nh as G,
55853
55873
  Lp as V,
55854
55874
  Ih as a,
55855
55875
  tp as b,
@@ -55859,22 +55879,22 @@ export {
55859
55879
  Vn as f,
55860
55880
  _h as g,
55861
55881
  hh as h,
55862
- vh as i,
55882
+ Dh as i,
55863
55883
  ch as j,
55864
55884
  lh as k,
55865
55885
  Sh as l,
55866
- Dh as m,
55886
+ xh as m,
55867
55887
  kC as n,
55868
55888
  yh as o,
55869
55889
  bh as p,
55870
- ih as q,
55890
+ vh as q,
55871
55891
  fh as r,
55872
55892
  ph as s,
55873
- dh as t,
55893
+ ih as t,
55874
55894
  Th as u,
55875
- Rh as v,
55876
- xh as w,
55877
- gh as x,
55878
- Eh as y,
55879
- mh as z
55895
+ dh as v,
55896
+ Mh as w,
55897
+ Rh as x,
55898
+ gh as y,
55899
+ Eh as z
55880
55900
  };
@@ -20,6 +20,16 @@ export interface AiAssistConfig {
20
20
  panelDraggable?: boolean;
21
21
  /** 面板停靠(嵌入宿主布局)配置 */
22
22
  dock?: AiAssistDockConfig;
23
+ /** 面板活跃心跳间隔(毫秒),默认 30000;用于「不丢尾段」地上报活跃时长增量 */
24
+ activityInterval?: number;
25
+ /**
26
+ * 面板活跃回调:展开 / 收起 / 心跳 / 标签隐藏补报。
27
+ *
28
+ * 各相位 durationMs 互不重叠,累加即「面板累计活跃时长」(毫秒);仅统计面板展开且标签可见的时间。
29
+ */
30
+ onPanelActive?: (info: AiAssistPanelActiveInfo) => void;
31
+ /** 用户发送消息回调(点发送 / 回车 / 语音;「重新生成」不计) */
32
+ onMessageSend?: (info: AiAssistMessageSendInfo) => void;
23
33
  apis: {
24
34
  chatQueryApi: string;
25
35
  chatQueryStreamApi?: string;
@@ -56,12 +66,80 @@ export interface AiAssistDockConfig {
56
66
  */
57
67
  onDockWidthChange?: (width: number) => void;
58
68
  }
69
+ /** 面板活跃回调相位 */
70
+ export type AiAssistPanelPhase = 'open' | 'close' | 'heartbeat' | 'hidden';
71
+ /** 面板活跃回调信息(各相位 durationMs 互不重叠,累加即累计活跃时长) */
72
+ export interface AiAssistPanelActiveInfo {
73
+ /**
74
+ * - open:面板展开(悬浮球展开 / 停靠态展开),durationMs 恒为 0;
75
+ * - heartbeat:保持展开且标签可见时按 activityInterval 触发一次;
76
+ * - hidden:标签页隐藏(visibilitychange)时立即补报,隐藏期间不计时;
77
+ * - close:面板收起,durationMs 为剩余未上报的活跃增量。
78
+ */
79
+ phase: AiAssistPanelPhase;
80
+ /** 当前是否处于停靠(嵌入)态 */
81
+ docked: boolean;
82
+ /** 本次需上报的活跃增量(毫秒),phase='open' 时恒为 0 */
83
+ durationMs: number;
84
+ /** 本次展开累计活跃时长(含本次,毫秒) */
85
+ totalMs: number;
86
+ }
87
+ /** 消息发送回调信息 */
88
+ export interface AiAssistMessageSendInfo {
89
+ /** 用户输入原文(隐私敏感:仅供宿主本地判断,请勿直接上报正文) */
90
+ text: string;
91
+ /** 是否为当前会话首条消息 */
92
+ isFirstMessage: boolean;
93
+ /** 会话 ID(懒创建后必有值) */
94
+ conversationId: string;
95
+ }
59
96
  export type ViewStatus = 'answer' | 'info';
60
97
  export type MessageStatus = 'thinking' | 'rethinking' | 'answering' | 'paused' | 'completed' | 'stop' | 'error';
61
98
  export interface MessageSegment {
62
- type: 'thinking' | 'agent_thought' | 'answer';
99
+ type: 'thinking' | 'agent_thought' | 'answer' | 'step';
63
100
  content: string;
64
101
  duration?: number;
102
+ /** 流程步骤标题(对话流型智能体 tool_message 的 message_title,如「執行準備」) */
103
+ title?: string;
104
+ /** 后端消息 id(对话流型下同一 id 的 tool_message 会分帧下发,需按 id 累积) */
105
+ id?: string;
106
+ /** 是否为推理内容(对话流型 message_config.reasoning === true) */
107
+ reasoning?: boolean;
108
+ }
109
+ /** 流程步骤展示状态 */
110
+ export type StepState = 'pending' | 'active' | 'done';
111
+ /** 流程步骤展示项:由 MessageItem 按揭示进度构建,供 StepBlock 渲染 */
112
+ export interface StepItem {
113
+ /** 步骤标题(tool_message 的 message_title) */
114
+ title?: string;
115
+ /** 该步骤已揭示的正文 */
116
+ content: string;
117
+ /** 该步骤耗时(秒),未结束为 undefined */
118
+ duration?: number;
119
+ /** 展示状态:pending 未开始揭示 / active 揭示中 / done 已完成 */
120
+ state: StepState;
121
+ }
122
+ /**
123
+ * 过程内容块 — 严格按 SSE 事件顺序排列,保证与后端返回的从上到下顺序一致。
124
+ *
125
+ * 采用扁平结构(各字段恒存在,按 kind 取用)以便 React / Vue 模板统一访问、无需类型收窄。
126
+ */
127
+ export interface MetaBlock {
128
+ kind: 'steps' | 'thinking' | 'tools';
129
+ /** 揭示坐标系中的起始偏移(前序可揭示内容长度) */
130
+ offset: number;
131
+ /** kind==='steps':连续多个步骤项 */
132
+ items: StepItem[];
133
+ /** kind==='thinking':已揭示的思考内容 */
134
+ content: string;
135
+ /** kind==='thinking':该段是否仍在揭示中 */
136
+ streaming: boolean;
137
+ /** kind==='tools':已完成的工具调用次数 */
138
+ count: number;
139
+ /** kind==='tools':工具调用总耗时(秒) */
140
+ duration: number;
141
+ /** kind==='tools':是否仍在调用中 */
142
+ calling: boolean;
65
143
  }
66
144
  /** SSE message_cost 事件携带的消费信息 */
67
145
  export interface MessageCost {
@@ -82,6 +160,12 @@ export interface ChatMessage {
82
160
  cost?: MessageCost;
83
161
  /** agent_error 的错误信息 */
84
162
  errorMessage?: string;
163
+ /**
164
+ * 是否由本次会话的实时流产生(需要前端按序逐字揭示)。
165
+ * 后端为批量转发(多事件同一帧到达),终态可能早于渲染,
166
+ * 故不能仅凭 status 判断是否需要动画;历史/降级消息不带此标记,直接全量渲染。
167
+ */
168
+ streamed?: boolean;
85
169
  }
86
170
  /** API 返回的会话列表项(已转 camelCase) */
87
171
  export interface ConversationItem {
@@ -104,7 +188,14 @@ export interface ConversationMessageItem {
104
188
  query?: string;
105
189
  answerInfo: {
106
190
  answer: string;
191
+ /** 该轮回答创建时间(Unix 秒,接口为 AnswerInfo.CreatedTime) */
192
+ createdTime?: number;
193
+ /** 兼容字段 */
194
+ createTime?: number;
107
195
  };
196
+ /** 提问创建时间(部分网关返回,兼容用) */
197
+ createdTime?: number;
198
+ createTime?: number;
108
199
  }
109
200
  export interface PersonalInfo {
110
201
  name: string;
@@ -19,7 +19,23 @@ export declare const parseSSEData: (sseData: string) => string;
19
19
  * 仅当内容以段落/列表/代码块等非表格标签结尾时才正常插入光标。
20
20
  */
21
21
  export declare const appendStreamingCursor: (html: string, streaming?: boolean) => string;
22
+ /**
23
+ * 将 GetConversationMessages 返回的消息项按时间**升序**重排(旧 → 新)。
24
+ *
25
+ * 该接口不保证数组顺序(实测为「最新在前」),直接渲染会把最新一轮顶到最上面。
26
+ * 优先按 `answerInfo.createdTime`(Unix 秒)等时间字段升序排序;
27
+ * 若所有条目都拿不到可用时间,则回退为整体反转(同样消除「最新在最上」)。
28
+ */
29
+ export declare const orderConversationMessages: <T extends {
30
+ answerInfo?: {
31
+ createdTime?: number | string;
32
+ createTime?: number | string;
33
+ };
34
+ createdTime?: number | string;
35
+ createTime?: number | string;
36
+ }>(items: T[] | undefined | null) => T[];
22
37
  export { renderMarkdown, preprocessStreamingMarkdown } from './markdown';
38
+ export { isRevealableSegment, totalRevealLength, revealSegmentContents, findRevealFrontier, isSegmentRevealed, segmentRevealRange, buildMetaBlocks, advanceReveal, stepRevealCap, REVEAL_BASE_CPS, REVEAL_TARGET_SEC, REVEAL_MAX_CPS, REVEAL_STEP_MIN_SEC, } from './streamPlayback';
23
39
  export { showToast, type ToastType } from './toast';
24
40
  export declare const ensureViewportFit: () => void;
25
41
  export interface HistoryGroup {
@@ -0,0 +1,56 @@
1
+ import { MessageSegment, MetaBlock } from '../types';
2
+ /** 基准速率(字/秒):积压很小时的自然打字节奏(深度思考 / 回答的默认输出速度) */
3
+ export declare const REVEAL_BASE_CPS = 45;
4
+ /**
5
+ * 排空时间常数(秒):cps = 剩余 / TARGET_SEC(下限 BASE、上限 MAX)。
6
+ * 即一阶衰减,时间常数越大整体越慢;同时保证「积压有界」——
7
+ * 若后端持续以 R 字/秒产出,稳态积压 ≈ R × TARGET_SEC,不会无限落后。
8
+ */
9
+ export declare const REVEAL_TARGET_SEC = 1.4;
10
+ /** 速率上限(字/秒):防止超大批量一帧铺满 */
11
+ export declare const REVEAL_MAX_CPS = 1600;
12
+ /**
13
+ * 单个「流程步骤」的最短展示时长(秒)。
14
+ * 大包内往往含多个步骤,若按全局排空速率会被一起冲掉,故对步骤单独限速:
15
+ * 揭示该步骤全部内容至少耗时 STEP_MIN_SEC,使步骤与步骤之间保持可见节奏。
16
+ */
17
+ export declare const REVEAL_STEP_MIN_SEC = 2;
18
+ /** 该分段是否参与逐字揭示 */
19
+ export declare function isRevealableSegment(seg: MessageSegment): boolean;
20
+ /** 按 segments 顺序统计需要揭示的总字符数 */
21
+ export declare function totalRevealLength(segments?: MessageSegment[]): number;
22
+ /**
23
+ * 计算每个分段当前应展示的已揭示内容(与 segments 等长)。
24
+ * 不可揭示的分段(agent_thought)原样返回,便于调用方统一按索引取值。
25
+ */
26
+ export declare function revealSegmentContents(segments: MessageSegment[] | undefined, reveal: number): string[];
27
+ /** 揭示游标当前所处(尚未揭示完)的分段下标;全部揭示完返回 -1 */
28
+ export declare function findRevealFrontier(segments: MessageSegment[] | undefined, reveal: number): number;
29
+ /** 分段是否已完全揭示 */
30
+ export declare function isSegmentRevealed(segments: MessageSegment[] | undefined, segIdx: number, reveal: number): boolean;
31
+ /** 分段在揭示坐标系中的区间 [start, end)(不可揭示分段返回 [0,0]) */
32
+ export declare function segmentRevealRange(segments: MessageSegment[] | undefined, segIdx: number): {
33
+ start: number;
34
+ end: number;
35
+ };
36
+ /**
37
+ * 构建「过程内容块」列表。
38
+ *
39
+ * 严格按 segments 的原始顺序(= SSE 事件到达顺序)分组:连续 step 合成一个步骤块、
40
+ * 连续 thinking 合成一个思考块、连续 agent_thought 合成一个工具调用块。
41
+ * 只有揭示游标走到某块的内容后该块才会出现(thinking/steps 由内容是否为空自然判定,
42
+ * tools 无正文,按揭示偏移 gate),从而保证「从上到下逐个出现」。
43
+ */
44
+ export declare function buildMetaBlocks(segments: MessageSegment[] | undefined, reveal: number): MetaBlock[];
45
+ /**
46
+ * 揭示游标当前所在分段为「流程步骤」时的速率上限(字/秒)。
47
+ * 保证单个步骤的揭示耗时 ≥ REVEAL_STEP_MIN_SEC;非步骤分段返回 Infinity(不额外限速)。
48
+ */
49
+ export declare function stepRevealCap(segments: MessageSegment[] | undefined, reveal: number): number;
50
+ /** 推进一帧揭示进度(返回新的 reveal 与小数累加器,跨帧保留以保证低速率均匀) */
51
+ export declare function advanceReveal(reveal: number, total: number, frac: number, dtMs: number,
52
+ /** 速率上限(字/秒),用于对步骤等分段单独限速;默认不限 */
53
+ cpsCap?: number): {
54
+ reveal: number;
55
+ frac: number;
56
+ };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { V as a, m as t, t as o, b as n, c as r, k as i, e as g, v as p, h as u, x as C, f as c, j as f, g as h, y as l, l as v, z as d, A as m, B as x, C as S, r as T, D as E, n as y, q as A, E as M, s as w, F as D, d as Q, u as b, w as k } from "./chunks/index-DElfgKrt.mjs";
1
+ import { V as a, m as t, v as o, b as n, c as r, k as i, e as g, x as p, h as u, y as C, f as c, j as f, g as h, z as l, l as v, A as d, B as m, C as x, D as S, r as T, E, n as y, t as A, F as M, s as w, G as D, d as Q, u as b, w as k } from "./chunks/index-Da2hiup1.mjs";
2
2
  export {
3
3
  a as VoiceEngine,
4
4
  t as applyTheme,
@@ -0,0 +1,12 @@
1
+ import { StepItem } from '../../../../core/types';
2
+ /**
3
+ * 流程步骤块 — 对话流型智能体的执行步骤列表。
4
+ *
5
+ * 由 buildMetaBlocks 按 SSE 事件顺序切分(连续 step 合成一块),使用户看到的顺序
6
+ * 与后端返回的从上到下顺序一致:步骤块可与深度思考块交替出现。
7
+ * 标题只在多步时展示,单步块直接作为一行,避免与思考块交错时标题重复。
8
+ */
9
+ declare const StepBlock: React.FC<{
10
+ steps: StepItem[];
11
+ }>;
12
+ export default StepBlock;
@@ -1,20 +1,12 @@
1
- import { MessageStatus } from '../../../../core/types';
2
1
  /**
3
- * 流式 Markdown 渲染器 — 逐字打字机效果
2
+ * Markdown 渲染器(流式光标装饰)。
4
3
  *
5
- * 采用「字符/秒」时间驱动模型 + 小数累加器,根据积压量平滑分配显示时间:
6
- * - 基准速率 CPS_BASE:正常逐字节奏,即使单字符也缓慢呈现
7
- * - 积压越多速率越快,但封顶 CPS_MAX,避免一个时刻涌来的多段内容瞬间铺满
8
- * - 跨帧累积小数进度,保证低速率下也能均匀推进
9
- *
10
- * 思考/回答穿插大包以思考结尾时 status 可能停在 THINKING/RETHINKING,
11
- * 此时消息内容仍在流式,不能全量显示(否则消息区闪现)。
12
- * - isTyping(ANSWERING/THINKING/RETHINKING):打字机推进
13
- * - showCursor(仅 ANSWERING):光标展示,避免与深度思考区光标同时出现
4
+ * 逐字揭示已统一上移到 useMessagePlayback:本组件接收的 content 即为「已揭示」的内容,
5
+ * 只做 markdown 渲染,并在揭示未完成时补充光标,不再自行打字。
14
6
  */
15
7
  declare const StreamingMarkdown: React.FC<{
16
8
  content: string;
17
- status: MessageStatus;
18
- onContentGrow?: () => void;
9
+ /** 是否处于揭示中(显示光标) */
10
+ showCursor?: boolean;
19
11
  }>;
20
12
  export default StreamingMarkdown;
@@ -1,19 +1,17 @@
1
1
  /**
2
- * 深度思考区块 — 可折叠展示深度思考内容
2
+ * 深度思考区块 — 可折叠展示深度思考内容。
3
3
  *
4
- * 打字机输出规则(RAF 驱动,恒定速率 CPS):
5
- * - 恒定速率逐字输出,不随积压量加速。后端 SSE 中转会把大量 think_message 合并成
6
- * 一帧批量写入,组件挂载时 content 往往已是全量 —— 因此流式中挂载必须从第 0 个
7
- * 字符开始重放,否则会整段闪现。
8
- * - 只有整条消息结束(messageDone=true,即 COMPLETED/STOP)才 flush 全量补齐。
9
- * 单个思考段结束(isStreaming=false)不 flush,仅自动收起;若该段后续仍被追加
10
- * 内容,继续按固定节奏慢慢输出。
11
- * - 流式中 content 被替换且变短(重新生成等)→ 从头重放。
4
+ * 内容由父级按统一揭示进度(useMessagePlayback)逐字提供,本组件只负责折叠/展开与
5
+ * 流式跟随滚动,不再自行打字,避免与回答各自为政导致「回答已闪现、思考还在慢慢输出」。
6
+ *
7
+ * - isStreaming:思考仍在揭示中 → 自动展开、显示光标;
8
+ * - messageDone:整条消息与揭示均已结束 → 保持展开(折叠条展开态);
9
+ * - 段结束但消息未结束 → 延迟收起,转场更丝滑。
12
10
  */
13
11
  declare const ThinkingBlock: React.FC<{
14
12
  content: string;
15
13
  isStreaming?: boolean;
16
- /** 整条消息是否已结束(COMPLETED/STOP),结束才允许全量补齐 */
14
+ /** 整条消息是否已完全结束(终态 + 揭示完毕) */
17
15
  messageDone?: boolean;
18
16
  }>;
19
17
  export default ThinkingBlock;
@@ -0,0 +1,25 @@
1
+ import { ChatMessage } from '../../../../core/types';
2
+ interface MessagePlayback {
3
+ /** 已揭示字符数(揭示坐标系中的游标) */
4
+ reveal: number;
5
+ /** 每个分段当前已揭示的内容(与 msg.segments 等长) */
6
+ segmentContents: string[];
7
+ /** 揭示游标所在分段下标(-1 表示已全部揭示) */
8
+ frontier: number;
9
+ /** 是否已全部揭示 */
10
+ revealDone: boolean;
11
+ /** 指定分段是否已完全揭示 */
12
+ isSegRevealed: (segIdx: number) => boolean;
13
+ }
14
+ /**
15
+ * 单条 AI 消息的流式揭示播放。
16
+ *
17
+ * 后端为批量转发(多事件同一帧到达,甚至终态与内容同帧),不能依赖 status 触发动画,
18
+ * 而是以 msg.streamed 标记该消息需要按序逐字揭示;揭示进度只增不减,按 segments
19
+ * 原始顺序推进,从而保证 深度思考 → 流程步骤 → 回答 严格依次流出。
20
+ *
21
+ * 终止态(stop/error)直接补齐,避免用户点了停止还慢慢打字。
22
+ * 历史 / 降级消息不带 streamed 标记 → 立即全量展示。
23
+ */
24
+ export declare function useMessagePlayback(msg: ChatMessage, onGrow?: () => void): MessagePlayback;
25
+ export {};
@@ -11,10 +11,19 @@ interface UseSSEStreamParams {
11
11
  /**
12
12
  * SSE 流式请求:处理 think_message / agent_thought / message 等事件的分段拼接与状态流转。
13
13
  *
14
+ * 同时兼容两套智能体协议:
15
+ * - 对话型:think_message_output_start / think_message / think_message_output_end(深度思考)、
16
+ * agent_thought / agent_thought_end(工具调用)、message_output_start / message / message_end(回答)
17
+ * - 对话流型:flow_start / flow_end 包裹,思考与流程步骤统一走
18
+ * tool_message_output_start / tool_message / tool_message_output_end(带 message_title、
19
+ * message_config.reasoning,同一 id 分帧下发需累积)→ reasoning 归入深度思考,其余归入流程步骤(step)
20
+ *
14
21
  * 内部管理:
15
- * - segmentsRef: 每条 AI 消息的分段数组(支持 thinking/agent_thought/answer 穿插)
22
+ * - segmentsRef: 每条 AI 消息的分段数组(支持 thinking/agent_thought/step/answer 穿插)
16
23
  * - currentSegTypeRef: 当前正在写入的 segment 类型
17
24
  * - thinkingStartTimeRef / agentThoughtStartTimeRef: 用于计算耗时
25
+ * - flowModeRef: 是否已进入对话流型协议(未进入则完全走旧协议,零回归)
26
+ * - toolSegIndexRef / toolStartTimeRef: 对话流型下按 message id 定位分段与开始时间
18
27
  * - issTopRef: 是否已手动停止
19
28
  *
20
29
  * 对外暴露 doStreamRequest 与 issTopRef(toggleStop 需读写)。