@somecat/ai-assist-sdk 2.0.3 → 2.0.4
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/ai-assist-sdk.css +1 -1
- package/dist/chunks/{engine-D2uBPK10.mjs → engine-CObUibqY.mjs} +927 -917
- package/dist/chunks/{index-BIUOuQxJ.mjs → index-CoDHrvxN.mjs} +171 -252
- package/dist/core/types/index.d.ts +8 -12
- package/dist/core/utils/index.d.ts +2 -11
- package/dist/core/utils/markdown.d.ts +15 -0
- package/dist/core/utils/streamPlayback.d.ts +9 -58
- package/dist/core/utils/structured.d.ts +0 -8
- package/dist/index.mjs +109 -58
- package/dist/react/components/answer/chatStore.d.ts +2 -2
- package/dist/react/components/answer/components/MessageItem.d.ts +0 -5
- package/dist/react/components/answer/components/StepBlock.d.ts +1 -5
- package/dist/react/components/answer/components/StreamingMarkdown.d.ts +1 -8
- package/dist/react/components/answer/components/ThinkingBlock.d.ts +2 -0
- package/dist/react/components/answer/hooks/useScrollManager.d.ts +2 -0
- package/dist/react/components/page/AiChartCard.d.ts +6 -0
- package/dist/react/index.mjs +10375 -10407
- package/dist/vue/components/answer/composables/useChatSessions.d.ts +0 -2
- package/dist/vue/components/answer/composables/useMessagesBatch.d.ts +3 -1
- package/dist/vue/components/answer/composables/useSSEStream.d.ts +2 -2
- package/dist/vue/components/answer/composables/useScrollManager.d.ts +2 -0
- package/dist/vue/index.mjs +2286 -2316
- package/package.json +1 -1
- package/dist/chunks/index-Hn7EdCb5.mjs +0 -98
- package/dist/react/components/answer/hooks/useMessagePlayback.d.ts +0 -34
- package/dist/react/components/answer/hooks/useStallHint.d.ts +0 -15
- package/dist/vue/components/answer/composables/useMessagePlayback.d.ts +0 -27
- package/dist/vue/components/answer/composables/useStallHint.d.ts +0 -16
|
@@ -299,6 +299,8 @@ export interface MessageSegment {
|
|
|
299
299
|
id?: string;
|
|
300
300
|
/** 是否为推理内容(对话流型 message_config.reasoning === true) */
|
|
301
301
|
reasoning?: boolean;
|
|
302
|
+
/** 该分段开始时刻(毫秒),用于按段结算耗时;内部字段,不展示 */
|
|
303
|
+
startedAt?: number;
|
|
302
304
|
}
|
|
303
305
|
/** 流程步骤展示状态 */
|
|
304
306
|
export type StepState = 'pending' | 'active' | 'done';
|
|
@@ -354,18 +356,6 @@ export interface ChatMessage {
|
|
|
354
356
|
cost?: MessageCost;
|
|
355
357
|
/** agent_error 的错误信息 */
|
|
356
358
|
errorMessage?: string;
|
|
357
|
-
/**
|
|
358
|
-
* 是否由本次会话的实时流产生(需要前端按序逐字揭示)。
|
|
359
|
-
* 后端为批量转发(多事件同一帧到达),终态可能早于渲染,
|
|
360
|
-
* 故不能仅凭 status 判断是否需要动画;历史/降级消息不带此标记,直接全量渲染。
|
|
361
|
-
*/
|
|
362
|
-
streamed?: boolean;
|
|
363
|
-
/**
|
|
364
|
-
* 最近一次收到后端 SSE 数据包的时间戳(毫秒)。
|
|
365
|
-
* 用于识别「伪流式」卡顿:前端已追平已有内容但后端长时间不再发包时,
|
|
366
|
-
* 由渲染层补一条「工具调用中」状态,避免界面呆滞。
|
|
367
|
-
*/
|
|
368
|
-
lastChunkAt?: number;
|
|
369
359
|
/** page 模式:智能体返回的结构化动作 */
|
|
370
360
|
actions?: AiPageAction[];
|
|
371
361
|
/** page 模式:动作执行状态(按动作 key 存储) */
|
|
@@ -433,6 +423,12 @@ export interface ConversationMessageItem {
|
|
|
433
423
|
charts?: AiChartItem[];
|
|
434
424
|
/** 新平台:本轮产物文件 */
|
|
435
425
|
files?: AiPageFile[];
|
|
426
|
+
/** 新平台:平台轮次 ID(内部字段,按轮回填用) */
|
|
427
|
+
runTurnId?: string;
|
|
428
|
+
/** 新平台:平台轮次状态(completed / failed / stopped / running / unknown) */
|
|
429
|
+
turnStatus?: string;
|
|
430
|
+
/** 新平台:失败原因(内部字段) */
|
|
431
|
+
errorMessage?: string;
|
|
436
432
|
};
|
|
437
433
|
/** 提问创建时间(部分网关返回,兼容用) */
|
|
438
434
|
createdTime?: number;
|
|
@@ -35,15 +35,6 @@ export declare const looksLikeRawPayload: (text?: string) => boolean;
|
|
|
35
35
|
* 返回空串表示该标题不可用,调用方应跳过更新(保留服务端默认会话名)。
|
|
36
36
|
*/
|
|
37
37
|
export declare const sanitizeConversationTitle: (raw?: string) => string;
|
|
38
|
-
/**
|
|
39
|
-
* 将流式光标拼接到 HTML 最后一个块级元素内部末尾,保证光标跟在文字后而非换行独占一行。
|
|
40
|
-
*
|
|
41
|
-
* 表格处理:markdown-it 对表格几乎总是输出「完整闭合」的 <table>(流式行也会补空 td),
|
|
42
|
-
* 因此光标插入点常落在最后一个闭合标签 </table> 之前 —— 即表格结构内部(表头下方/表格内),
|
|
43
|
-
* 视觉上表现为光标出现在表格上方。故当最后一个块级闭合标签属于表格标签时隐藏光标;
|
|
44
|
-
* 仅当内容以段落/列表/代码块等非表格标签结尾时才正常插入光标。
|
|
45
|
-
*/
|
|
46
|
-
export declare const appendStreamingCursor: (html: string, streaming?: boolean) => string;
|
|
47
38
|
/**
|
|
48
39
|
* 将 GetConversationMessages 返回的消息项按时间**升序**重排(旧 → 新)。
|
|
49
40
|
*
|
|
@@ -59,8 +50,8 @@ export declare const orderConversationMessages: <T extends {
|
|
|
59
50
|
createdTime?: number | string;
|
|
60
51
|
createTime?: number | string;
|
|
61
52
|
}>(items: T[] | undefined | null) => T[];
|
|
62
|
-
export { renderMarkdown, preprocessStreamingMarkdown, stripChartBlocks } from './markdown';
|
|
63
|
-
export {
|
|
53
|
+
export { renderMarkdown, preprocessStreamingMarkdown, stripChartBlocks, parseAnswerBlocks, type AnswerBlock, } from './markdown';
|
|
54
|
+
export { buildMetaBlocks, segmentDuration, sumThinkingDuration } from './streamPlayback';
|
|
64
55
|
export { showToast, type ToastType } from './toast';
|
|
65
56
|
export declare const ensureViewportFit: () => void;
|
|
66
57
|
export interface HistoryGroup {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AiChartItem } from '../types';
|
|
1
2
|
export declare const renderMarkdown: (content: string) => string;
|
|
2
3
|
/**
|
|
3
4
|
* 移除平台图表工具的「正文引用」,避免把 chart_id JSON 当代码块展示。
|
|
@@ -10,6 +11,20 @@ export declare const renderMarkdown: (content: string) => string;
|
|
|
10
11
|
* - 无匹配时原样返回。
|
|
11
12
|
*/
|
|
12
13
|
export declare const stripChartBlocks: (content: string) => string;
|
|
14
|
+
/** 回答正文的有序块:文本或图表引用(按原文顺序渲染) */
|
|
15
|
+
export type AnswerBlock = {
|
|
16
|
+
kind: 'text';
|
|
17
|
+
content: string;
|
|
18
|
+
} | {
|
|
19
|
+
kind: 'chart';
|
|
20
|
+
chartId: string;
|
|
21
|
+
chart?: AiChartItem;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* 把正文里的 echarts 引用解析为有序的文本/图卡块。
|
|
25
|
+
* 图表数据可能晚于引用到达:先出占位,数据到达后按同一 chartId 升级为卡片。
|
|
26
|
+
*/
|
|
27
|
+
export declare function parseAnswerBlocks(content: string, charts?: AiChartItem[], fallbackCharts?: boolean): AnswerBlock[];
|
|
13
28
|
/**
|
|
14
29
|
* 预处理流式传输中的不完整 Markdown,避免渲染错乱
|
|
15
30
|
* - 闭合未关闭的代码块 (```)
|
|
@@ -1,62 +1,13 @@
|
|
|
1
1
|
import { MessageSegment, MetaBlock } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
export declare
|
|
2
|
+
/** 按分段自身开始时间结算耗时(秒,保留 1 位小数) */
|
|
3
|
+
export declare function segmentDuration(seg: MessageSegment, now?: number): number;
|
|
4
|
+
/** 思考总耗时由各 thinking 分段派生,避免多处累加重复计时 */
|
|
5
|
+
export declare function sumThinkingDuration(segments: MessageSegment[] | undefined): number;
|
|
4
6
|
/**
|
|
5
|
-
*
|
|
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
|
-
* 伪流式卡顿判定阈值(毫秒)。
|
|
20
|
-
* 前端已把已收到的内容揭示完毕,若这段时间内后端仍未下发新包,
|
|
21
|
-
* 且不处于深度思考 / 工具调用 / 步骤进行中,则补一条「工具调用中」状态占位。
|
|
22
|
-
*/
|
|
23
|
-
export declare const STALL_HINT_DELAY_MS = 2000;
|
|
24
|
-
/** 该分段是否参与逐字揭示 */
|
|
25
|
-
export declare function isRevealableSegment(seg: MessageSegment): boolean;
|
|
26
|
-
/** 按 segments 顺序统计需要揭示的总字符数 */
|
|
27
|
-
export declare function totalRevealLength(segments?: MessageSegment[]): number;
|
|
28
|
-
/**
|
|
29
|
-
* 计算每个分段当前应展示的已揭示内容(与 segments 等长)。
|
|
30
|
-
* 不可揭示的分段(agent_thought)原样返回,便于调用方统一按索引取值。
|
|
31
|
-
*/
|
|
32
|
-
export declare function revealSegmentContents(segments: MessageSegment[] | undefined, reveal: number): string[];
|
|
33
|
-
/** 揭示游标当前所处(尚未揭示完)的分段下标;全部揭示完返回 -1 */
|
|
34
|
-
export declare function findRevealFrontier(segments: MessageSegment[] | undefined, reveal: number): number;
|
|
35
|
-
/** 分段是否已完全揭示 */
|
|
36
|
-
export declare function isSegmentRevealed(segments: MessageSegment[] | undefined, segIdx: number, reveal: number): boolean;
|
|
37
|
-
/** 分段在揭示坐标系中的区间 [start, end)(不可揭示分段返回 [0,0]) */
|
|
38
|
-
export declare function segmentRevealRange(segments: MessageSegment[] | undefined, segIdx: number): {
|
|
39
|
-
start: number;
|
|
40
|
-
end: number;
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* 构建「过程内容块」列表。
|
|
7
|
+
* 过程内容块分组(框架无关)。
|
|
44
8
|
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
* tools 无正文,按揭示偏移 gate),从而保证「从上到下逐个出现」。
|
|
49
|
-
*/
|
|
50
|
-
export declare function buildMetaBlocks(segments: MessageSegment[] | undefined, reveal: number): MetaBlock[];
|
|
51
|
-
/**
|
|
52
|
-
* 揭示游标当前所在分段为「流程步骤」时的速率上限(字/秒)。
|
|
53
|
-
* 保证单个步骤的揭示耗时 ≥ REVEAL_STEP_MIN_SEC;非步骤分段返回 Infinity(不额外限速)。
|
|
9
|
+
* 新平台是真实 SSE:正文、思考、工具事件按到达顺序增量写入,
|
|
10
|
+
* 这里只负责把连续的 step / thinking / agent_thought 分段组织成块供 UI 渲染,
|
|
11
|
+
* 不再做任何「逐字揭示 / 二次限速 / 卡顿伪装」。
|
|
54
12
|
*/
|
|
55
|
-
export declare function
|
|
56
|
-
/** 推进一帧揭示进度(返回新的 reveal 与小数累加器,跨帧保留以保证低速率均匀) */
|
|
57
|
-
export declare function advanceReveal(reveal: number, total: number, frac: number, dtMs: number,
|
|
58
|
-
/** 速率上限(字/秒),用于对步骤等分段单独限速;默认不限 */
|
|
59
|
-
cpsCap?: number): {
|
|
60
|
-
reveal: number;
|
|
61
|
-
frac: number;
|
|
62
|
-
};
|
|
13
|
+
export declare function buildMetaBlocks(segments: MessageSegment[] | undefined): MetaBlock[];
|
|
@@ -13,13 +13,5 @@ export interface AiStructuredAnswer {
|
|
|
13
13
|
* 兼容代码围栏与前后噪声;解析失败时整段按纯文本返回,由渲染层走 Markdown,不白屏。
|
|
14
14
|
*/
|
|
15
15
|
export declare const parseStructuredAnswer: (raw: string) => AiStructuredAnswer;
|
|
16
|
-
/**
|
|
17
|
-
* 流式场景下从「尚未闭合的 JSON」里提取 `answer` 字段已到达的部分。
|
|
18
|
-
*
|
|
19
|
-
* - 还没出现 `"answer"`(或是纯文本回答)→ 直接返回原文;
|
|
20
|
-
* - 已出现但内容未到达 → 返回空串,避免把 JSON 骨架显示给用户;
|
|
21
|
-
* - 遇到未完成的转义序列时先不追加,等下一段数据。
|
|
22
|
-
*/
|
|
23
|
-
export declare const extractStreamingAnswer: (raw: string) => string;
|
|
24
16
|
/** 拼装 page 模式的提问内容(上下文块 + 用户原话) */
|
|
25
17
|
export declare const composePageQuery: (question: string, pageContext?: Record<string, any>) => string;
|
package/dist/index.mjs
CHANGED
|
@@ -1,60 +1,111 @@
|
|
|
1
|
-
import { V as
|
|
2
|
-
|
|
1
|
+
import { V as d, I as y, a0 as h, f as S, T, U as C, m as b, h as w, D as P, w as m, n as x, a1 as v, A as M, q as E, W as O, a2 as j, g as I, z, j as N, a3 as k, H as Q, k as U, c as D, E as J, a4 as V, a5 as $, a6 as G, i as X, M as Z, X as _, a7 as F, a8 as H, v as L, F as R, r as K, a9 as W, R as Y, Y as q, O as B, x as ss, N as es, Z as ts, K as as, S as rs, _ as ns, t as is, aa as os, l as cs, G as gs, ab as ls, $ as As, y as fs, u as us, J as ps } from "./chunks/engine-CObUibqY.mjs";
|
|
2
|
+
const o = (e) => {
|
|
3
|
+
const s = e.trim(), a = /^```[a-zA-Z]*\s*\n([\s\S]*?)\n?```$/m.exec(s);
|
|
4
|
+
if (a) return a[1].trim();
|
|
5
|
+
const t = /```[a-zA-Z]*\s*\n([\s\S]*?)\n?```/.exec(s);
|
|
6
|
+
return t ? t[1].trim() : s;
|
|
7
|
+
}, c = (e) => {
|
|
8
|
+
const s = e.indexOf("{");
|
|
9
|
+
if (s < 0) return null;
|
|
10
|
+
let a = 0, t = !1, i = !1;
|
|
11
|
+
for (let r = s; r < e.length; r++) {
|
|
12
|
+
const n = e[r];
|
|
13
|
+
if (t) {
|
|
14
|
+
i ? i = !1 : n === "\\" ? i = !0 : n === '"' && (t = !1);
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
if (n === '"') t = !0;
|
|
18
|
+
else if (n === "{") a++;
|
|
19
|
+
else if (n === "}" && (a--, a === 0))
|
|
20
|
+
return e.slice(s, r + 1);
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
}, g = (e) => Array.isArray(e) ? e.filter((s) => s && typeof s == "object" && typeof s.type == "string" && s.type.trim()).map((s) => ({
|
|
24
|
+
type: String(s.type).trim(),
|
|
25
|
+
label: typeof s.label == "string" ? s.label : void 0,
|
|
26
|
+
payload: s.payload && typeof s.payload == "object" && !Array.isArray(s.payload) ? s.payload : void 0
|
|
27
|
+
})) : [], l = (e) => Array.isArray(e) ? e.filter((s) => typeof s == "string" && s.trim()).map((s) => s.trim()) : [], A = (e) => {
|
|
28
|
+
const s = (e || "").trim();
|
|
29
|
+
if (!s) return { answer: "", actions: [], suggestions: [] };
|
|
30
|
+
const a = c(o(s));
|
|
31
|
+
if (!a) return { answer: s, actions: [], suggestions: [] };
|
|
32
|
+
try {
|
|
33
|
+
const t = JSON.parse(a);
|
|
34
|
+
if (!t || typeof t != "object") return { answer: s, actions: [], suggestions: [] };
|
|
35
|
+
const i = typeof t.answer == "string" ? t.answer : typeof t.content == "string" ? t.content : "", r = g(t.actions), n = l(t.suggestions);
|
|
36
|
+
return !i && !r.length ? { answer: s, actions: r, suggestions: n } : { answer: i || s, actions: r, suggestions: n };
|
|
37
|
+
} catch {
|
|
38
|
+
return { answer: s, actions: [], suggestions: [] };
|
|
39
|
+
}
|
|
40
|
+
}, f = (e, s) => {
|
|
41
|
+
if (!s || !Object.keys(s).length) return e;
|
|
42
|
+
let a = "";
|
|
43
|
+
try {
|
|
44
|
+
a = JSON.stringify(s);
|
|
45
|
+
} catch {
|
|
46
|
+
return e;
|
|
47
|
+
}
|
|
48
|
+
return `[PAGE_CONTEXT]
|
|
49
|
+
${a}
|
|
50
|
+
[/PAGE_CONTEXT]
|
|
51
|
+
[QUESTION]
|
|
52
|
+
${e}`;
|
|
53
|
+
};
|
|
3
54
|
export {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
d as VoiceEngine,
|
|
56
|
+
y as applyTheme,
|
|
57
|
+
h as chatQuery,
|
|
58
|
+
S as clearPageThreadId,
|
|
59
|
+
T as closeAiAssist,
|
|
60
|
+
C as collapsePageAssist,
|
|
61
|
+
f as composePageQuery,
|
|
62
|
+
b as createAuthAxios,
|
|
63
|
+
w as createConversation,
|
|
64
|
+
P as deleteConversation,
|
|
65
|
+
m as ensureTitleConversation,
|
|
66
|
+
x as extractAnswerText,
|
|
67
|
+
v as extractPlainText,
|
|
68
|
+
M as formatQuestions,
|
|
69
|
+
E as getAiAssistMode,
|
|
70
|
+
O as getAiAssistUserCode,
|
|
71
|
+
j as getAppConfig,
|
|
72
|
+
I as getConfig,
|
|
73
|
+
z as getConversationList,
|
|
74
|
+
N as getConversationMessages,
|
|
75
|
+
k as getMessageInfo,
|
|
76
|
+
Q as getPageContextSnapshot,
|
|
77
|
+
U as getPageModule,
|
|
78
|
+
D as getPageThreadId,
|
|
79
|
+
J as getPersonalInfo,
|
|
80
|
+
V as getSuggestedQuestions,
|
|
81
|
+
$ as http,
|
|
82
|
+
G as isAiAssistModeLocked,
|
|
83
|
+
X as isAiAssistPageMode,
|
|
84
|
+
Z as isAiAssistVisible,
|
|
85
|
+
_ as openAiAssist,
|
|
86
|
+
F as parseSSEData,
|
|
87
|
+
A as parseStructuredAnswer,
|
|
88
|
+
H as processSSEData,
|
|
89
|
+
L as refreshAiPanelContext,
|
|
90
|
+
R as registerAiAssistResetHook,
|
|
91
|
+
K as renderMarkdown,
|
|
92
|
+
W as request,
|
|
93
|
+
Y as resetAiAssistState,
|
|
94
|
+
q as resetAiAssistUserData,
|
|
95
|
+
B as resolveTheme,
|
|
96
|
+
ss as sanitizeConversationTitle,
|
|
97
|
+
es as setAiAssistMode,
|
|
98
|
+
ts as setAiAssistUserCode,
|
|
99
|
+
as as setAiAssistVisible,
|
|
100
|
+
rs as setConfig,
|
|
101
|
+
ns as setPageModule,
|
|
102
|
+
is as setPageThreadId,
|
|
103
|
+
os as statusText,
|
|
104
|
+
cs as stopMessage,
|
|
105
|
+
gs as subscribeAiAssistState,
|
|
106
|
+
ls as textError,
|
|
107
|
+
As as toggleAiAssist,
|
|
108
|
+
fs as updateConversation,
|
|
109
|
+
us as useClipboard,
|
|
110
|
+
ps as watchSystemTheme
|
|
60
111
|
};
|
|
@@ -49,8 +49,6 @@ export declare class ChatSession {
|
|
|
49
49
|
updatedAt: number;
|
|
50
50
|
/** 是否已手动停止当前生成 */
|
|
51
51
|
stopped: boolean;
|
|
52
|
-
/** 逐字揭示进度:消息下标 → 已揭示字符数(切回会话时恢复,避免重放整段动画) */
|
|
53
|
-
readonly reveal: Map<number, number>;
|
|
54
52
|
sendMessage: () => Promise<void>;
|
|
55
53
|
regenerateResponse: () => Promise<void>;
|
|
56
54
|
toggleStop: () => Promise<void>;
|
|
@@ -88,6 +86,8 @@ export declare class ChatStore {
|
|
|
88
86
|
subscribe: (listener: () => void) => () => void;
|
|
89
87
|
getSnapshot: () => ChatStoreSnapshot;
|
|
90
88
|
get activeSession(): ChatSession | undefined;
|
|
89
|
+
/** 会话消息批量写入完成后调用:只有当前展示会话才按门闩滚底 */
|
|
90
|
+
onSessionBatchApplied(uid: string): void;
|
|
91
91
|
/** 切换展示会话 */
|
|
92
92
|
activate(uid: string): void;
|
|
93
93
|
/** 新建对话:复用一个空草稿会话,避免堆积无用会话 */
|
|
@@ -2,12 +2,7 @@ import { ChatMessage } from '../../../../core/types';
|
|
|
2
2
|
interface MessageItemProps {
|
|
3
3
|
msg: ChatMessage;
|
|
4
4
|
index: number;
|
|
5
|
-
scrollToBottom: () => void;
|
|
6
5
|
onRegenerate: () => void;
|
|
7
|
-
/** 挂载时恢复的揭示进度(会话切回时避免重放动画) */
|
|
8
|
-
initialReveal?: number;
|
|
9
|
-
/** 揭示进度变化(宿主持久化,切回会话时用 initialReveal 恢复) */
|
|
10
|
-
onRevealProgress?: (reveal: number) => void;
|
|
11
6
|
}
|
|
12
7
|
declare const MessageItem: React.FC<MessageItemProps>;
|
|
13
8
|
export default MessageItem;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { StepItem } from '../../../../core/types';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* 由 buildMetaBlocks 按 SSE 事件顺序切分(连续 step 合成一块),使用户看到的顺序
|
|
6
|
-
* 与后端返回的从上到下顺序一致:步骤块可与深度思考块交替出现。
|
|
7
|
-
* 标题只在多步时展示,单步块直接作为一行,避免与思考块交错时标题重复。
|
|
3
|
+
* 流程步骤块:流式展开、结束后收起;单步可展开原文。
|
|
8
4
|
*/
|
|
9
5
|
declare const StepBlock: React.FC<{
|
|
10
6
|
steps: StepItem[];
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Markdown 渲染器(流式光标装饰)。
|
|
3
|
-
*
|
|
4
|
-
* 逐字揭示已统一上移到 useMessagePlayback:本组件接收的 content 即为「已揭示」的内容,
|
|
5
|
-
* 只做 markdown 渲染,并在揭示未完成时补充光标,不再自行打字。
|
|
6
|
-
*/
|
|
1
|
+
/** 纯 Markdown 渲染:直接展示平台真实 SSE 已到达的增量,不自行打字、不追加光标 */
|
|
7
2
|
declare const StreamingMarkdown: React.FC<{
|
|
8
3
|
content: string;
|
|
9
|
-
/** 是否处于揭示中(显示光标) */
|
|
10
|
-
showCursor?: boolean;
|
|
11
4
|
}>;
|
|
12
5
|
export default StreamingMarkdown;
|