@cqfe/sxin-chat-core 1.0.1 → 1.0.2
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/{ChatCore-C-G9isDM.d.cts → ChatCore-cSM1HmXp.d.cts} +407 -337
- package/dist/{ChatCore-C-G9isDM.d.ts → ChatCore-cSM1HmXp.d.ts} +407 -337
- package/dist/chunk-Z65C2UII.mjs +2830 -0
- package/dist/index.cjs +1815 -1488
- package/dist/index.d.cts +606 -208
- package/dist/index.d.ts +606 -208
- package/dist/index.mjs +999 -143
- package/dist/vue/index.cjs +1429 -2177
- package/dist/vue/index.d.cts +2 -2
- package/dist/vue/index.d.ts +2 -2
- package/dist/vue/index.mjs +1 -1
- package/package.json +3 -3
- package/dist/chunk-K2ZOZPBB.mjs +0 -3391
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Ref,
|
|
1
|
+
import { Ref, ShallowRef, ComputedRef } from 'vue';
|
|
2
2
|
import { Message as Message$1, DefaultToolCall, Interrupt, Thread, Run } from '@langchain/langgraph-sdk';
|
|
3
3
|
|
|
4
4
|
interface AgentThreadState extends Record<string, unknown> {
|
|
@@ -23,102 +23,6 @@ interface IQuote {
|
|
|
23
23
|
actions?: string[];
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
/** 子章节(可嵌套,相对章节最多再嵌套 2 层,共 3 个层级) */
|
|
27
|
-
interface OutlineSubChapter {
|
|
28
|
-
id: string;
|
|
29
|
-
title: string;
|
|
30
|
-
/** 子章节摘要 */
|
|
31
|
-
summary?: string;
|
|
32
|
-
/** 子章节内容主题 */
|
|
33
|
-
contentTheme?: string;
|
|
34
|
-
children: OutlineSubChapter[];
|
|
35
|
-
}
|
|
36
|
-
interface OutlineChapter {
|
|
37
|
-
id: string;
|
|
38
|
-
chapterTitle: string;
|
|
39
|
-
/** 章节摘要/概述 */
|
|
40
|
-
chapterSummary?: string;
|
|
41
|
-
/** 子章节列表(第 2 层级) */
|
|
42
|
-
children: OutlineSubChapter[];
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
interface ReportOutlinePayload {
|
|
46
|
-
templateId: string;
|
|
47
|
-
templateName: string;
|
|
48
|
-
outline: OutlineChapter[];
|
|
49
|
-
/** 大纲创建时间(ISO):取触发 write_file 的消息事件时间,缺失时不展示 */
|
|
50
|
-
createdAt?: string;
|
|
51
|
-
sourcePath?: string;
|
|
52
|
-
outlineMarkdown?: string;
|
|
53
|
-
/**
|
|
54
|
-
* 内容引用:state(历史)通道不内嵌正文,仅带路径元信息;
|
|
55
|
-
* 消费方经 ChatCore.loadArtifactContent(contentRef.path) 拉取后自行解析(parseMarkdownToOutline)。
|
|
56
|
-
* threadId 不冗余在 block 上,由 ChatCore 调用时从 activeSession 补。
|
|
57
|
-
*/
|
|
58
|
-
contentRef?: {
|
|
59
|
-
path: string;
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
interface ReportBodyPayload {
|
|
63
|
-
templateId: string;
|
|
64
|
-
templateName: string;
|
|
65
|
-
reportTitle: string;
|
|
66
|
-
createdAt: string;
|
|
67
|
-
sourcePath?: string;
|
|
68
|
-
bodyMarkdown?: string;
|
|
69
|
-
/** 内容引用:同 ReportOutlinePayload.contentRef */
|
|
70
|
-
contentRef?: {
|
|
71
|
-
path: string;
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
interface IAttachment {
|
|
75
|
-
name: string;
|
|
76
|
-
url: string;
|
|
77
|
-
type: string;
|
|
78
|
-
size: number;
|
|
79
|
-
uid: string;
|
|
80
|
-
id?: string;
|
|
81
|
-
}
|
|
82
|
-
interface IKwargs {
|
|
83
|
-
hide_from_ui?: boolean;
|
|
84
|
-
human_input_response?: Record<string, unknown>;
|
|
85
|
-
attachments?: IAttachment[];
|
|
86
|
-
selection?: Record<string, unknown>;
|
|
87
|
-
context?: Record<string, unknown>;
|
|
88
|
-
capability?: string[];
|
|
89
|
-
workflow?: Record<string, any>;
|
|
90
|
-
}
|
|
91
|
-
interface GenerateBodyRequest {
|
|
92
|
-
templateId: string;
|
|
93
|
-
outline: OutlineChapter[];
|
|
94
|
-
}
|
|
95
|
-
interface GenerateBodyResult {
|
|
96
|
-
bodyMarkdown: string;
|
|
97
|
-
}
|
|
98
|
-
interface ReportSelectedArtifact {
|
|
99
|
-
path: string;
|
|
100
|
-
kind: 'report_outline';
|
|
101
|
-
}
|
|
102
|
-
interface ReportGenerateBodyHumanKwargs {
|
|
103
|
-
selected_artifact: ReportSelectedArtifact;
|
|
104
|
-
report_action: 'generate_body';
|
|
105
|
-
}
|
|
106
|
-
interface ReportSelectedTemplate {
|
|
107
|
-
kind: 'report_template';
|
|
108
|
-
source: 'template_library';
|
|
109
|
-
template_id: string;
|
|
110
|
-
template_name: string;
|
|
111
|
-
/** 范文 OSS 地址(列表接口无此字段时可为空) */
|
|
112
|
-
oss_url: string;
|
|
113
|
-
/** 报告大纲 Markdown(来自 /biz/report/template/list 的 outline 字段) */
|
|
114
|
-
outline?: string;
|
|
115
|
-
reportStyle?: string;
|
|
116
|
-
datasourceId?: string;
|
|
117
|
-
datasourceName?: string;
|
|
118
|
-
jdbcUrl?: string;
|
|
119
|
-
name?: string;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
26
|
/**
|
|
123
27
|
* HITL(Human-in-the-loop)类型定义。
|
|
124
28
|
* 从 parser/hitl 下沉至此,使 types/blockBuilder 无需反向依赖 parser 层(打破循环依赖);
|
|
@@ -151,10 +55,6 @@ interface HitlInterruptPayload {
|
|
|
151
55
|
reviewConfigs: HitlReviewConfig[];
|
|
152
56
|
}
|
|
153
57
|
|
|
154
|
-
/**
|
|
155
|
-
* Block 类型系统(blockBuilder.ts re-export 保持 import 路径不变)。
|
|
156
|
-
*/
|
|
157
|
-
|
|
158
58
|
/** Block 状态:流式中 / 已完成 / 等待中 / 错误 */
|
|
159
59
|
type BlockStatus = 'streaming' | 'completed' | 'pending' | 'error';
|
|
160
60
|
/** Block 基础字段 */
|
|
@@ -193,11 +93,6 @@ interface ArtifactFile {
|
|
|
193
93
|
/** 文件类型后缀 */
|
|
194
94
|
fileType?: string;
|
|
195
95
|
}
|
|
196
|
-
/** 产物 Block */
|
|
197
|
-
interface ArtifactBlock extends BlockBase {
|
|
198
|
-
type: 'artifact';
|
|
199
|
-
files: ArtifactFile[];
|
|
200
|
-
}
|
|
201
96
|
/** 自定义渲染 Block:对应 <sxin-xxx> 标签 */
|
|
202
97
|
interface CustomBlock extends BlockBase {
|
|
203
98
|
type: 'custom';
|
|
@@ -206,16 +101,6 @@ interface CustomBlock extends BlockBase {
|
|
|
206
101
|
/** 解析后的属性对象 */
|
|
207
102
|
spec: Record<string, any>;
|
|
208
103
|
}
|
|
209
|
-
/** 报告大纲卡片 Block */
|
|
210
|
-
interface ReportOutlineBlock extends BlockBase {
|
|
211
|
-
type: 'report-outline';
|
|
212
|
-
payload: ReportOutlinePayload;
|
|
213
|
-
}
|
|
214
|
-
/** 报告正文卡片 Block */
|
|
215
|
-
interface ReportBodyBlock extends BlockBase {
|
|
216
|
-
type: 'report-body';
|
|
217
|
-
payload: ReportBodyPayload;
|
|
218
|
-
}
|
|
219
104
|
/** 通用表单字段类型 */
|
|
220
105
|
type FormFieldType = 'text' | 'textarea' | 'number' | 'select' | 'multi_select' | 'radio' | 'checkbox' | 'switch' | 'date' | 'date-picker' | 'dateRange' | 'date-range' | 'time' | 'timeRange' | 'tree-select' | 'cascader' | 'upload' | 'table' | 'list' | 'hidden';
|
|
221
106
|
interface FormFieldItem {
|
|
@@ -251,10 +136,10 @@ interface FormFieldItem {
|
|
|
251
136
|
/** list 类型候选数据 */
|
|
252
137
|
items?: any[];
|
|
253
138
|
}
|
|
254
|
-
/** 通用表单 Block
|
|
139
|
+
/** 通用表单 Block:澄清/确认/删除确认统一走此块(ask_clarification 与其他 form 来源共用) */
|
|
255
140
|
interface FormBlock extends BlockBase {
|
|
256
141
|
type: 'form';
|
|
257
|
-
/**
|
|
142
|
+
/** 表单模式:仅决定提交按钮样式(delete_confirm → danger),不再分支交互逻辑 */
|
|
258
143
|
variant: 'input' | 'confirm' | 'delete_confirm';
|
|
259
144
|
/** 表单标题 */
|
|
260
145
|
title?: string;
|
|
@@ -264,23 +149,9 @@ interface FormBlock extends BlockBase {
|
|
|
264
149
|
context?: string;
|
|
265
150
|
/** 表单字段 */
|
|
266
151
|
fields: FormFieldItem[];
|
|
267
|
-
/**
|
|
152
|
+
/** 已收集的字段值,用于预填 */
|
|
268
153
|
values?: Record<string, any>;
|
|
269
|
-
/**
|
|
270
|
-
stepInfo?: {
|
|
271
|
-
title?: string;
|
|
272
|
-
current: number;
|
|
273
|
-
total: number;
|
|
274
|
-
canSkip?: boolean;
|
|
275
|
-
};
|
|
276
|
-
/** 业务专属动作按钮 */
|
|
277
|
-
customActions?: Array<{
|
|
278
|
-
key: string;
|
|
279
|
-
label: string;
|
|
280
|
-
primary?: boolean;
|
|
281
|
-
danger?: boolean;
|
|
282
|
-
}>;
|
|
283
|
-
/** 当前状态 */
|
|
154
|
+
/** 当前状态:澄清类块恒 pending(跨 run 回答态由 isAnswered / 回答缓存判定) */
|
|
284
155
|
status: BlockStatus;
|
|
285
156
|
/** 关联的 tool_call_id,用于去重 */
|
|
286
157
|
toolCallId?: string;
|
|
@@ -288,6 +159,8 @@ interface FormBlock extends BlockBase {
|
|
|
288
159
|
source?: string;
|
|
289
160
|
/** thread 级回答状态(跨 run 不回写 block,渲染层据此自行判断是否已回答) */
|
|
290
161
|
isAnswered?: boolean;
|
|
162
|
+
/** 用户回答内容(由装饰层根据 thread 级回答状态注入,仅已回答时有值) */
|
|
163
|
+
answer?: string;
|
|
291
164
|
}
|
|
292
165
|
/** 列表选择项 */
|
|
293
166
|
interface ListItem {
|
|
@@ -331,28 +204,6 @@ interface ListBlock extends BlockBase {
|
|
|
331
204
|
/** 关联的 tool_call_id,用于去重 */
|
|
332
205
|
toolCallId?: string;
|
|
333
206
|
}
|
|
334
|
-
/** 澄清反问 Block(兼容旧版简单澄清) */
|
|
335
|
-
interface AskClarificationBlock extends BlockBase {
|
|
336
|
-
type: 'ask-clarification';
|
|
337
|
-
/** 问题正文(markdown) */
|
|
338
|
-
question: string;
|
|
339
|
-
/** 问题背景 */
|
|
340
|
-
context?: string;
|
|
341
|
-
/** 澄清类型 */
|
|
342
|
-
clarification_type?: 'mission_info' | 'confirmation' | 'select_option';
|
|
343
|
-
/** 可选选项列表;为空时用户自由输入 */
|
|
344
|
-
options?: string[];
|
|
345
|
-
/** 动态表单字段 */
|
|
346
|
-
fields?: Array<FormFieldItem>;
|
|
347
|
-
/** 复用 BlockStatus:pending 可交互 / completed 已回答(options 禁用) */
|
|
348
|
-
status: BlockStatus;
|
|
349
|
-
/** 关联的 tool_call_id,用于去重 */
|
|
350
|
-
toolCallId?: string;
|
|
351
|
-
/** 用户回答内容(由渲染层根据 thread 级回答状态注入,仅已回答时有值) */
|
|
352
|
-
answer?: string;
|
|
353
|
-
/** thread 级回答状态(跨 run 不回写 block,渲染层据此自行判断是否已回答) */
|
|
354
|
-
isAnswered?: boolean;
|
|
355
|
-
}
|
|
356
207
|
/** 引用文件项(GroupMessage.citations 元素类型:refId 锚点 + 详情字段,详情由渲染层拉取后写回) */
|
|
357
208
|
interface CitationItem {
|
|
358
209
|
/** 引用唯一标识 */
|
|
@@ -378,11 +229,6 @@ interface CitationItem {
|
|
|
378
229
|
}
|
|
379
230
|
/** 引用 Block 已下线:citation 走 sxin-item contract="support.kbCitation" 自定义渲染链,
|
|
380
231
|
* 解析层仅产出锚点挂到 GroupMessage.citations(见 types/groupMessage.ts)。 */
|
|
381
|
-
interface TwinBlock extends BlockBase {
|
|
382
|
-
type: 'twin';
|
|
383
|
-
toolName: string;
|
|
384
|
-
args: Record<string, unknown>;
|
|
385
|
-
}
|
|
386
232
|
/** HITL 审核 Block:对应 pending interrupt 的人工审核卡片 */
|
|
387
233
|
interface InterruptReviewBlock extends BlockBase {
|
|
388
234
|
type: 'interrupt-review';
|
|
@@ -396,7 +242,125 @@ interface InterruptReviewBlock extends BlockBase {
|
|
|
396
242
|
isResponded?: boolean;
|
|
397
243
|
}
|
|
398
244
|
/** Block 联合类型 */
|
|
399
|
-
type Block = TextBlock |
|
|
245
|
+
type Block = TextBlock | CustomBlock | FormBlock | ListBlock | InterruptReviewBlock;
|
|
246
|
+
/** 工具调用快照(ReasoningChainBlock 渲染契约;原 types/groupMessage 迁入——组模型退役后内核仍消费此形状) */
|
|
247
|
+
interface GroupMessageTool {
|
|
248
|
+
/** tool_call_id */
|
|
249
|
+
id: string;
|
|
250
|
+
/** 工具调用定义 */
|
|
251
|
+
call: DefaultToolCall;
|
|
252
|
+
/** 工具调用结果(可能逐步补全) */
|
|
253
|
+
result?: any;
|
|
254
|
+
/** 触发该 tool call 的 ai 消息 */
|
|
255
|
+
aiMessage?: Message$1;
|
|
256
|
+
/** 当前状态 */
|
|
257
|
+
state: 'pending' | 'active' | 'completed' | 'error';
|
|
258
|
+
/** 在工具序列中的顺序 */
|
|
259
|
+
index: number;
|
|
260
|
+
}
|
|
261
|
+
/** Block 构建来源(blockBuilder.ts 退役迁入;渲染层按 source 决定流式/完成态语义) */
|
|
262
|
+
type BlockSource = 'optimistic' | 'sse' | 'history';
|
|
263
|
+
/** Block 构建配置(blockBuilder.ts 退役迁入) */
|
|
264
|
+
interface BlockBuilderOptions {
|
|
265
|
+
/** 数据来源 */
|
|
266
|
+
source: BlockSource;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/** 子章节(可嵌套,相对章节最多再嵌套 2 层,共 3 个层级) */
|
|
270
|
+
interface OutlineSubChapter {
|
|
271
|
+
id: string;
|
|
272
|
+
title: string;
|
|
273
|
+
/** 子章节摘要 */
|
|
274
|
+
summary?: string;
|
|
275
|
+
/** 子章节内容主题 */
|
|
276
|
+
contentTheme?: string;
|
|
277
|
+
children: OutlineSubChapter[];
|
|
278
|
+
}
|
|
279
|
+
interface OutlineChapter {
|
|
280
|
+
id: string;
|
|
281
|
+
chapterTitle: string;
|
|
282
|
+
/** 章节摘要/概述 */
|
|
283
|
+
chapterSummary?: string;
|
|
284
|
+
/** 子章节列表(第 2 层级) */
|
|
285
|
+
children: OutlineSubChapter[];
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
interface ReportOutlinePayload {
|
|
289
|
+
templateId: string;
|
|
290
|
+
templateName: string;
|
|
291
|
+
outline: OutlineChapter[];
|
|
292
|
+
/** 大纲创建时间(ISO):取触发 write_file 的消息事件时间,缺失时不展示 */
|
|
293
|
+
createdAt?: string;
|
|
294
|
+
sourcePath?: string;
|
|
295
|
+
outlineMarkdown?: string;
|
|
296
|
+
/**
|
|
297
|
+
* 内容引用:state(历史)通道不内嵌正文,仅带路径元信息;
|
|
298
|
+
* 消费方经 ChatCore.loadArtifactContent(contentRef.path) 拉取后自行解析(parseMarkdownToOutline)。
|
|
299
|
+
* threadId 不冗余在 block 上,由 ChatCore 调用时从 activeSession 补。
|
|
300
|
+
*/
|
|
301
|
+
contentRef?: {
|
|
302
|
+
path: string;
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
interface ReportBodyPayload {
|
|
306
|
+
templateId: string;
|
|
307
|
+
templateName: string;
|
|
308
|
+
reportTitle: string;
|
|
309
|
+
createdAt: string;
|
|
310
|
+
sourcePath?: string;
|
|
311
|
+
bodyMarkdown?: string;
|
|
312
|
+
/** 内容引用:同 ReportOutlinePayload.contentRef */
|
|
313
|
+
contentRef?: {
|
|
314
|
+
path: string;
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
interface IAttachment {
|
|
318
|
+
name: string;
|
|
319
|
+
url: string;
|
|
320
|
+
type: string;
|
|
321
|
+
size: number;
|
|
322
|
+
uid: string;
|
|
323
|
+
id?: string;
|
|
324
|
+
}
|
|
325
|
+
interface IKwargs {
|
|
326
|
+
hide_from_ui?: boolean;
|
|
327
|
+
human_input_response?: Record<string, unknown>;
|
|
328
|
+
attachments?: IAttachment[];
|
|
329
|
+
selection?: Record<string, unknown>;
|
|
330
|
+
context?: Record<string, unknown>;
|
|
331
|
+
capability?: string[];
|
|
332
|
+
workflow?: Record<string, any>;
|
|
333
|
+
}
|
|
334
|
+
interface GenerateBodyRequest {
|
|
335
|
+
templateId: string;
|
|
336
|
+
outline: OutlineChapter[];
|
|
337
|
+
}
|
|
338
|
+
interface GenerateBodyResult {
|
|
339
|
+
bodyMarkdown: string;
|
|
340
|
+
}
|
|
341
|
+
interface ReportSelectedArtifact {
|
|
342
|
+
path: string;
|
|
343
|
+
kind: 'report_outline';
|
|
344
|
+
}
|
|
345
|
+
interface ReportGenerateBodyHumanKwargs {
|
|
346
|
+
selected_artifact: ReportSelectedArtifact;
|
|
347
|
+
report_action: 'generate_body';
|
|
348
|
+
}
|
|
349
|
+
interface ReportSelectedTemplate {
|
|
350
|
+
kind: 'report_template';
|
|
351
|
+
source: 'template_library';
|
|
352
|
+
template_id: string;
|
|
353
|
+
template_name: string;
|
|
354
|
+
/** 范文 OSS 地址(列表接口无此字段时可为空) */
|
|
355
|
+
oss_url: string;
|
|
356
|
+
/** 报告大纲 Markdown(来自 /biz/report/template/list 的 outline 字段) */
|
|
357
|
+
outline?: string;
|
|
358
|
+
reportStyle?: string;
|
|
359
|
+
datasourceId?: string;
|
|
360
|
+
datasourceName?: string;
|
|
361
|
+
jdbcUrl?: string;
|
|
362
|
+
name?: string;
|
|
363
|
+
}
|
|
400
364
|
|
|
401
365
|
/**
|
|
402
366
|
* 前端 Message 结构类型(blockBuilder.ts re-export 保持 import 路径不变)。
|
|
@@ -461,88 +425,10 @@ interface Message {
|
|
|
461
425
|
feedback?: unknown;
|
|
462
426
|
}
|
|
463
427
|
|
|
464
|
-
/**
|
|
465
|
-
* chat 类型定义入口(单一事实来源,所有 Block/Message/Channel 类型均从此处导出)。
|
|
466
|
-
* 实现按职责拆分:Block 类型系统见 ./block,Message 结构见 ./message-schema;
|
|
467
|
-
* 本文件保留 useChatManager 发送选项与 BlockBuilder 配置,并 re-export 两者保持既有 import 路径不变。
|
|
468
|
-
*/
|
|
469
|
-
|
|
470
|
-
/** sendMessage 可选参数,与旧 chat store 对齐 */
|
|
428
|
+
/** 发送消息选项(blockBuilder.ts 退役迁入) */
|
|
471
429
|
interface SendMessageOptions {
|
|
472
430
|
kwargs?: IKwargs;
|
|
473
431
|
}
|
|
474
|
-
/** BlockBuilder 数据来源 */
|
|
475
|
-
type BlockSource = MessageSource;
|
|
476
|
-
/** BlockBuilder 配置选项 */
|
|
477
|
-
interface BlockBuilderOptions {
|
|
478
|
-
/** 数据来源 */
|
|
479
|
-
source: BlockSource;
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
/** GroupMessage 数据来源 / 会话来源 */
|
|
483
|
-
type GroupMessageSource = 'history' | 'sse' | 'state';
|
|
484
|
-
/** GroupMessage 角色 */
|
|
485
|
-
type GroupMessageType = 'human' | 'ai';
|
|
486
|
-
/** GroupMessage 状态 */
|
|
487
|
-
type GroupMessageStatus = 'streaming' | 'completed' | 'pending' | 'error';
|
|
488
|
-
/** tool block 状态快照(deriveToolsFromMessages 从消息 tool_calls/tool_call_id 配对派生) */
|
|
489
|
-
interface GroupMessageTool {
|
|
490
|
-
/** tool_call_id */
|
|
491
|
-
id: string;
|
|
492
|
-
/** 工具调用定义 */
|
|
493
|
-
call: DefaultToolCall;
|
|
494
|
-
/** 工具调用结果(可能逐步补全) */
|
|
495
|
-
result?: any;
|
|
496
|
-
/** 触发该 tool call 的 ai 消息 */
|
|
497
|
-
aiMessage?: Message$1;
|
|
498
|
-
/** 当前状态 */
|
|
499
|
-
state: 'pending' | 'active' | 'completed' | 'error';
|
|
500
|
-
/** 在 GroupMessage.tools 中的顺序 */
|
|
501
|
-
index: number;
|
|
502
|
-
}
|
|
503
|
-
/** 前端渲染消息:一个 Bubble */
|
|
504
|
-
interface GroupMessage {
|
|
505
|
-
/** 消息唯一 id,取组内最后一条原始消息的 id,或本地生成 */
|
|
506
|
-
id: string;
|
|
507
|
-
/** 消息类型:human / ai */
|
|
508
|
-
type: GroupMessageType;
|
|
509
|
-
/** 渲染状态 */
|
|
510
|
-
status: GroupMessageStatus;
|
|
511
|
-
/** 数据来源 / 会话来源 */
|
|
512
|
-
source?: GroupMessageSource;
|
|
513
|
-
/** 组成这条 GroupMessage 的所有原始消息 id */
|
|
514
|
-
originMessageIds: string[];
|
|
515
|
-
/** 该组关联的 run id(run 级信息通过 runId 查询 RunInfo) */
|
|
516
|
-
runId?: string;
|
|
517
|
-
/** 该组所在的 checkpoint id(可选) */
|
|
518
|
-
checkpointId?: string;
|
|
519
|
-
/** 渲染 block 列表 */
|
|
520
|
-
blocks: Block[];
|
|
521
|
-
/**
|
|
522
|
-
* 消息级引用锚点:由 sxin-item contract="support.kbCitation" 块提取(refId + searchText),
|
|
523
|
-
* 顺序即正文 [n] 角标序号;docUrl/docId 等详情由渲染层按 refId 拉 artifact 后写回。
|
|
524
|
-
* 仅 AI 组可能有值;无引用块时为 undefined。
|
|
525
|
-
*/
|
|
526
|
-
citations?: CitationItem[];
|
|
527
|
-
/** 该组内提取到的 tool_call_id 列表(按出现顺序去重) */
|
|
528
|
-
toolIds: string[];
|
|
529
|
-
/** 与 toolIds 对应的完整 tool 对象 */
|
|
530
|
-
tools: GroupMessageTool[];
|
|
531
|
-
/** 原始 LangGraph 消息快照 */
|
|
532
|
-
rawMessages: Message$1[];
|
|
533
|
-
/** human 消息的可见文本:buildHumanGroup 时一次性预计算,消费端(MessageHuman / MessageFooterCopy 等)直接读取,避免对同一 rawMessages 重复解析 */
|
|
534
|
-
texts?: string[];
|
|
535
|
-
/** human 消息的 additional_kwargs(附件、澄清回答标记等) */
|
|
536
|
-
additionalKwargs?: IKwargs;
|
|
537
|
-
/** 创建时间戳 */
|
|
538
|
-
createdAt: number;
|
|
539
|
-
}
|
|
540
|
-
/** buildHumanGroup/buildAiGroup 的入参(从 message/group-builder.ts 下沉到 types 层,打破与 group-assembler 的模块环) */
|
|
541
|
-
interface BuildAllOptions {
|
|
542
|
-
source: GroupMessageSource;
|
|
543
|
-
isStreaming: boolean;
|
|
544
|
-
runId?: string;
|
|
545
|
-
}
|
|
546
432
|
|
|
547
433
|
/** run 内单条消息:run messages 分页拉取的数据结构(区别于流式快照的 LangGraph Message) */
|
|
548
434
|
interface RunMessage {
|
|
@@ -632,8 +518,6 @@ declare function buildHitlDecisions(requests: HitlActionRequest[], currentArgsLi
|
|
|
632
518
|
declare function buildRejectDecisions(requests: HitlActionRequest[]): HitlDecision[];
|
|
633
519
|
/** 由 interrupt 合成审核 Block;负载非法时返回 null(调用方不渲染) */
|
|
634
520
|
declare function buildInterruptReviewBlock(interrupt: Interrupt, responded: boolean): InterruptReviewBlock | null;
|
|
635
|
-
/** 由 interrupt 合成末尾审核 GroupMessage(无 AI 消息可合并时的独立追加回退);负载非法时返回 null */
|
|
636
|
-
declare function buildInterruptReviewGroup(interrupt: Interrupt, responded: boolean): GroupMessage | null;
|
|
637
521
|
|
|
638
522
|
/** 分页搜索 thread 的参数 */
|
|
639
523
|
interface SearchThreadsOptions {
|
|
@@ -683,10 +567,20 @@ interface ChatStreamHandle {
|
|
|
683
567
|
error: Ref<Error | null>;
|
|
684
568
|
/** 发起一次流式运行(发送用户消息) */
|
|
685
569
|
submit(input: StreamSubmitInput, options?: StreamSubmitOptions): void;
|
|
686
|
-
/** 加入既有 run 的 SSE
|
|
570
|
+
/** 加入既有 run 的 SSE 流(断线重连)。
|
|
571
|
+
* D9 桥接语义(chat-core-bridge 重构):deer-flow join 端点(GET
|
|
572
|
+
* /threads/{tid}/runs/{rid}/join)v1 协议兼容,全量重放剩余缓冲事件、不消费
|
|
573
|
+
* lastEventId(OpenAPI 实测无游标参数)。桥接模式已于 2026-11-13 提前转正:
|
|
574
|
+
* web streamBridge 旁路打开 join SSE,复用旧泵回调直驱 store(不经 SDK 控制器);
|
|
575
|
+
* 旧管道为 client.runs.joinStream 原生实现。 */
|
|
687
576
|
joinStream(runId: string, lastEventId?: string): Promise<void>;
|
|
688
577
|
/** 停止当前流 */
|
|
689
578
|
stop(): void;
|
|
579
|
+
/**
|
|
580
|
+
* 释放句柄资源(桥接模式的 effectScope / 适配器连接等)。
|
|
581
|
+
* 可选:旧泵句柄无资源可释,不实现;ThreadRuntime.dispose 时会后随 stop() 调用。
|
|
582
|
+
*/
|
|
583
|
+
dispose?(): void;
|
|
690
584
|
/** 向 pending interrupt 发送 HITL 决策以恢复图执行(区别于 joinStream 的 SSE 重连) */
|
|
691
585
|
resumeInterrupt(decisions: HitlResponse): Promise<void>;
|
|
692
586
|
}
|
|
@@ -700,6 +594,12 @@ interface CreateStreamOptions {
|
|
|
700
594
|
onValuesEvent?(data: Record<string, unknown>): void;
|
|
701
595
|
/** messages/messages-tuple chunk 事件解构后转发(store 消费:accumulator 累积产 upsert/remove/clear) */
|
|
702
596
|
onMessageTupleEvent?(serialized: Record<string, any>, metadata: Record<string, any>): void;
|
|
597
|
+
/**
|
|
598
|
+
* 桥接模式专用:SDK messages 投影的整段快照(transport 侧 watch 投影后转发)。
|
|
599
|
+
* runtime 以快照 mini diff(protocol/snapshot-diff)转为增量指令——
|
|
600
|
+
* 与 onMessageTupleEvent 二选一(tuple 泵模式不调用本回调)。
|
|
601
|
+
*/
|
|
602
|
+
onSnapshotMessages?(messages: Message$1[]): void;
|
|
703
603
|
/**
|
|
704
604
|
* 本轮流实际开始时调用(isLoading 置 true 后、首个 SSE 事件前)。
|
|
705
605
|
* 经泵的串行队列调用,时序保证「旧流收尾(onStreamEnd)先于新流本回调」——
|
|
@@ -749,49 +649,6 @@ interface ChatTransport {
|
|
|
749
649
|
createStream(options: CreateStreamOptions): ChatStreamHandle;
|
|
750
650
|
}
|
|
751
651
|
|
|
752
|
-
/**
|
|
753
|
-
* sxin AST 节点类型定义
|
|
754
|
-
*
|
|
755
|
-
* 独立成文件以打破 sxin-ast ↔ sxin-ast-collect 的模块环:
|
|
756
|
-
* tokenizer 与文本提取均只依赖本文件的类型,互不引用。
|
|
757
|
-
*/
|
|
758
|
-
/** 文本节点:原文切片 */
|
|
759
|
-
interface TextNode {
|
|
760
|
-
type: 'text';
|
|
761
|
-
/** 原文内容 */
|
|
762
|
-
value: string;
|
|
763
|
-
/** 在原文中的起始偏移(含) */
|
|
764
|
-
start: number;
|
|
765
|
-
/** 在原文中的结束偏移(不含) */
|
|
766
|
-
end: number;
|
|
767
|
-
}
|
|
768
|
-
/** 注释节点:<!-- ... --> */
|
|
769
|
-
interface CommentNode {
|
|
770
|
-
type: 'comment';
|
|
771
|
-
/** 注释内部内容(不含 <!-- 与 -->) */
|
|
772
|
-
content: string;
|
|
773
|
-
start: number;
|
|
774
|
-
end: number;
|
|
775
|
-
}
|
|
776
|
-
/** 元素节点:<tag attrs>children</tag> 或 <tag attrs/> */
|
|
777
|
-
interface ElementNode {
|
|
778
|
-
type: 'element';
|
|
779
|
-
/** 标签名(统一小写,大小写不敏感) */
|
|
780
|
-
tagName: string;
|
|
781
|
-
/** 解析后的属性对象(key/value 均经 formatStr 格式化) */
|
|
782
|
-
attrs: Record<string, string>;
|
|
783
|
-
/** 子节点(已闭合或自闭合标签才有内容;未闭合标签延伸到 EOF) */
|
|
784
|
-
children: SxinNode[];
|
|
785
|
-
/** 是否自闭合(<tag/>) */
|
|
786
|
-
selfClosing: boolean;
|
|
787
|
-
/** 是否有配对闭合标签;false 表示流式截断或 LLM 少输出闭合标签 */
|
|
788
|
-
closed: boolean;
|
|
789
|
-
start: number;
|
|
790
|
-
/** closed=false 时等于原文长度 */
|
|
791
|
-
end: number;
|
|
792
|
-
}
|
|
793
|
-
type SxinNode = TextNode | CommentNode | ElementNode;
|
|
794
|
-
|
|
795
652
|
/** LangGraph run 在前端的投影 */
|
|
796
653
|
interface RunInfo {
|
|
797
654
|
/** run 唯一 id */
|
|
@@ -813,7 +670,13 @@ interface RunInfo {
|
|
|
813
670
|
/** run 创建时间戳 */
|
|
814
671
|
createdAt?: number;
|
|
815
672
|
}
|
|
816
|
-
/** 从 /threads/{id}/runs 返回的单个 run 对象解析基础 RunInfo
|
|
673
|
+
/** 从 /threads/{id}/runs 返回的单个 run 对象解析基础 RunInfo。
|
|
674
|
+
* G7 定案字段(2026-11-13 直连 deer-flow 实测):token 三件套(total_input_tokens/
|
|
675
|
+
* total_output_tokens/total_tokens)+ llm_call_count/message_count 等扩展 +
|
|
676
|
+
* stop_reason(实测结束原因字段名,非 finish_reason);
|
|
677
|
+
* 无 latency_ms → latencyMs 走 created_at/updated_at 差值兜底;
|
|
678
|
+
* 无 model_name → modelName 依赖流结束 pickRunMessageMetadata 从 AI 消息回填;
|
|
679
|
+
* 无 feedback → 维持本地盖章语义(§9.1 #5)。 */
|
|
817
680
|
declare function buildRunInfo(run: any, threadId: string): RunInfo;
|
|
818
681
|
/**
|
|
819
682
|
* 解析 run 接口直报的耗时字段 latency_ms(缺失/0/非法时为 undefined)。
|
|
@@ -828,50 +691,228 @@ declare function pickRunMessageMetadata(messages: Message$1[]): {
|
|
|
828
691
|
finishReason?: string;
|
|
829
692
|
};
|
|
830
693
|
|
|
694
|
+
/** 元素属性:key/value 均字符串(parseAttrs 已格式化) */
|
|
695
|
+
interface XmlAttrs {
|
|
696
|
+
[name: string]: string;
|
|
697
|
+
}
|
|
698
|
+
/** 正文段(§4.3):有序序列元素 */
|
|
699
|
+
type BodySegment = {
|
|
700
|
+
type: 'text';
|
|
701
|
+
content: string;
|
|
702
|
+
} | {
|
|
703
|
+
type: 'list';
|
|
704
|
+
tag: 'sxin-list';
|
|
705
|
+
attrs: XmlAttrs;
|
|
706
|
+
children: ItemSegment[];
|
|
707
|
+
raw: string;
|
|
708
|
+
} | {
|
|
709
|
+
type: 'item';
|
|
710
|
+
tag: 'sxin-item';
|
|
711
|
+
attrs: XmlAttrs;
|
|
712
|
+
content?: string;
|
|
713
|
+
raw: string;
|
|
714
|
+
};
|
|
715
|
+
/** sxin-item 段(list children 元素类型) */
|
|
716
|
+
interface ItemSegment {
|
|
717
|
+
type: 'item';
|
|
718
|
+
tag: 'sxin-item';
|
|
719
|
+
attrs: XmlAttrs;
|
|
720
|
+
content?: string;
|
|
721
|
+
raw: string;
|
|
722
|
+
}
|
|
831
723
|
/**
|
|
832
|
-
*
|
|
833
|
-
*
|
|
724
|
+
* 正文切片为有序段序列。
|
|
725
|
+
* 恒返回非空数组(空 body → 单空 text 段),消费方无需判空。
|
|
834
726
|
*/
|
|
727
|
+
declare function sliceBodySegments(body: string): BodySegment[];
|
|
835
728
|
|
|
836
|
-
/**
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
/**
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
729
|
+
/**
|
|
730
|
+
* materializer/types.ts — §4.1 数据模型 + §6.2 TurnEffect 全量类型。
|
|
731
|
+
* 纯类型文件(零运行时),物化器各模块共享。
|
|
732
|
+
*/
|
|
733
|
+
|
|
734
|
+
/** 线程视图:物化器输出的唯一结构(turn 有序数组) */
|
|
735
|
+
interface ThreadView {
|
|
736
|
+
/** 有序;一轮 = 用户可见提问 + AI 应答 */
|
|
737
|
+
turns: Turn[];
|
|
738
|
+
}
|
|
739
|
+
/** 一轮对话 */
|
|
740
|
+
interface Turn {
|
|
741
|
+
/** = human 消息 id */
|
|
742
|
+
id: string;
|
|
743
|
+
/** 首个 ai 段的 runId */
|
|
744
|
+
runId: string;
|
|
745
|
+
createdAt: number;
|
|
746
|
+
/** 用户可见提问(乐观占位时 text 可能为空串,吸收后回填) */
|
|
747
|
+
human: {
|
|
748
|
+
id: string;
|
|
749
|
+
text: string;
|
|
750
|
+
kwargs?: Record<string, unknown>;
|
|
850
751
|
};
|
|
752
|
+
/** 数组:一轮可能多段(resume 续写为新段,D5 规则 3) */
|
|
753
|
+
ai: AiTurn[];
|
|
754
|
+
/** 澄清记录(ask_clarification 工具调用 + 回答回填) */
|
|
755
|
+
clarifications: ClarificationRecord[];
|
|
756
|
+
status: 'streaming' | 'sealed';
|
|
757
|
+
/** 乐观占位标记(规则 4;吸收/丢弃后复位 false) */
|
|
758
|
+
optimistic?: boolean;
|
|
759
|
+
/** 归属本 turn 的原始消息引用(按到达序追加;update 按 id 替换)——仅排查问题用,渲染不消费 */
|
|
760
|
+
rawMessages?: Message$1[];
|
|
851
761
|
}
|
|
852
|
-
/**
|
|
853
|
-
interface
|
|
854
|
-
/**
|
|
855
|
-
|
|
762
|
+
/** AI 应答段(同 turn 多段 = interrupt resume 续写) */
|
|
763
|
+
interface AiTurn {
|
|
764
|
+
/** = 段首 ai 消息 id */
|
|
765
|
+
id: string;
|
|
766
|
+
runId: string;
|
|
767
|
+
/** 单一正文(含 sxin 标签);引用 SDK 消息内容,不复制 */
|
|
768
|
+
body: string;
|
|
769
|
+
/** 仅开放尾段:增量部分(渲染打字机) */
|
|
770
|
+
streamingText?: string;
|
|
771
|
+
/** 定点装饰(feedback 盖章,R9):仅人工写入,流数据不携带 */
|
|
772
|
+
feedback?: {
|
|
773
|
+
rating: number;
|
|
774
|
+
};
|
|
775
|
+
/** 追加序 = 执行序(运行日志,非正文结构) */
|
|
776
|
+
tools: ToolRun[];
|
|
777
|
+
/** report/artifact/twin;固定尾部区,与正文顺序无关 */
|
|
778
|
+
attachments: Attachment[];
|
|
779
|
+
/** 密封时由切片器切分(§4.3);流式期 = 单 text 段 */
|
|
780
|
+
segments: BodySegment[];
|
|
781
|
+
status: 'streaming' | 'sealed';
|
|
856
782
|
/**
|
|
857
|
-
*
|
|
858
|
-
*
|
|
783
|
+
* 并入本段的消息 id 列表(段首 + 同 runId 并入的非段首消息;增量登记)。
|
|
784
|
+
* rebuildIndexes 依赖它重建 byMessageId——多步 agent 场景(多条 ai 消息并入一段)
|
|
785
|
+
* 若 finalize 全量重建只登记段首 id,流收尾 /state 回填的 update 会因索引 miss
|
|
786
|
+
* 被静默丢弃(citation 丢失断点,2026-11 实测)。渲染不消费。
|
|
859
787
|
*/
|
|
860
|
-
|
|
788
|
+
messageIds?: string[];
|
|
861
789
|
}
|
|
862
|
-
/**
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
790
|
+
/** 工具运行记录 */
|
|
791
|
+
interface ToolRun {
|
|
792
|
+
callId: string;
|
|
793
|
+
name: string;
|
|
794
|
+
input?: unknown;
|
|
795
|
+
status: 'running' | 'finished' | 'error';
|
|
796
|
+
result?: string;
|
|
797
|
+
/** write_file 类工具的 artifact_meta(tool_call 顶层,与 args 平级;报告产物判定用) */
|
|
798
|
+
artifactMeta?: unknown;
|
|
799
|
+
/** tool-finished 时由 extractor 写入(§6.4) */
|
|
800
|
+
extracted?: ExtractedPayload;
|
|
801
|
+
}
|
|
802
|
+
/** 报告附件载荷(write_file 产物;两类来源):
|
|
803
|
+
* - JSON result 路径:body(+可选 outline)内嵌正文,reportKind 固定 report_body;
|
|
804
|
+
* - artifact_meta 路径(result 非 JSON,如 "OK"):仅 sourcePath(内容经 artifact 端点
|
|
805
|
+
* 按需拉取)+ title(路径提取),reportKind 由 resolveReportArtifactKind 判定。 */
|
|
806
|
+
/** 模块内私有:仅 Attachment 联合类型使用,不对外导出 */
|
|
807
|
+
interface ReportAttachment {
|
|
808
|
+
kind: 'report';
|
|
809
|
+
reportKind: 'report_outline' | 'report_body';
|
|
810
|
+
/** 内嵌正文(JSON result 路径) */
|
|
811
|
+
body?: string;
|
|
812
|
+
/** 内嵌大纲 markdown(JSON result 路径) */
|
|
813
|
+
outline?: string;
|
|
814
|
+
/** artifact 文件路径(artifact_meta 路径;点击卡片后经 loadArtifactContent 拉取) */
|
|
815
|
+
sourcePath?: string;
|
|
816
|
+
/** 卡片展示标题(缺省由内容/路径提取) */
|
|
817
|
+
title?: string;
|
|
818
|
+
}
|
|
819
|
+
/** 附件载荷(report/artifact/twin) */
|
|
820
|
+
type Attachment = ReportAttachment | {
|
|
821
|
+
kind: 'artifact';
|
|
822
|
+
files: unknown[];
|
|
823
|
+
} | {
|
|
824
|
+
kind: 'twin';
|
|
825
|
+
payload: unknown;
|
|
826
|
+
};
|
|
827
|
+
/** 澄清记录 */
|
|
828
|
+
interface ClarificationRecord {
|
|
829
|
+
callId: string;
|
|
830
|
+
question: string;
|
|
831
|
+
options?: unknown;
|
|
832
|
+
/** 来自 tool call args.fields 的结构化字段(多题澄清;缺省走单题 textarea/select 兜底) */
|
|
833
|
+
fields?: FormFieldItem[];
|
|
834
|
+
/** 来自 human_input_response 提取(D6) */
|
|
835
|
+
answer?: string;
|
|
836
|
+
answerMessageId?: string;
|
|
837
|
+
}
|
|
838
|
+
/** tool result 提取载荷(§6.4;物化器不感知业务语义) */
|
|
839
|
+
type ExtractedPayload = {
|
|
840
|
+
kind: 'clarification';
|
|
841
|
+
question: string;
|
|
842
|
+
options?: unknown;
|
|
843
|
+
} | {
|
|
844
|
+
kind: 'report';
|
|
845
|
+
reportKind: 'report_outline' | 'report_body';
|
|
846
|
+
body?: string;
|
|
847
|
+
outline?: string;
|
|
848
|
+
sourcePath?: string;
|
|
849
|
+
title?: string;
|
|
850
|
+
} | {
|
|
851
|
+
kind: 'artifact';
|
|
852
|
+
files: unknown[];
|
|
853
|
+
};
|
|
854
|
+
/** 定点装饰 patch(R9/W5;按 byMessageId 定位 ai 段写入,流数据不携带这些字段) */
|
|
855
|
+
interface DecoratePatch {
|
|
856
|
+
feedback?: {
|
|
857
|
+
rating: number;
|
|
858
|
+
};
|
|
859
|
+
/** W5:整组替换附件(API 路径报告卡注入;undefined 不动) */
|
|
860
|
+
attachments?: Attachment[];
|
|
861
|
+
}
|
|
862
|
+
/** TurnEffect:状态机输出,驱动响应式更新(已密封 turn 引用稳定) */
|
|
863
|
+
type TurnEffect = {
|
|
864
|
+
type: 'turn-opened';
|
|
865
|
+
turn: Turn;
|
|
866
|
+
optimistic: boolean;
|
|
867
|
+
} | {
|
|
868
|
+
type: 'turn-sealed';
|
|
869
|
+
turnId: string;
|
|
870
|
+
} | {
|
|
871
|
+
type: 'ai-opened';
|
|
872
|
+
turnId: string;
|
|
873
|
+
ai: AiTurn;
|
|
874
|
+
} | {
|
|
875
|
+
type: 'ai-delta';
|
|
876
|
+
turnId: string;
|
|
877
|
+
aiId: string;
|
|
878
|
+
body: string;
|
|
879
|
+
streamingText: string;
|
|
880
|
+
} | {
|
|
881
|
+
type: 'ai-sealed';
|
|
882
|
+
turnId: string;
|
|
883
|
+
aiId: string;
|
|
884
|
+
segments: BodySegment[];
|
|
885
|
+
} | {
|
|
886
|
+
type: 'tool-updated';
|
|
887
|
+
turnId: string;
|
|
888
|
+
aiId: string;
|
|
889
|
+
tool: ToolRun;
|
|
890
|
+
} | {
|
|
891
|
+
type: 'clarification-answered';
|
|
892
|
+
turnId: string;
|
|
893
|
+
callId: string;
|
|
894
|
+
answer: string;
|
|
895
|
+
} | {
|
|
896
|
+
type: 'message-updated';
|
|
897
|
+
turnId: string;
|
|
898
|
+
aiId: string | null;
|
|
899
|
+
} | {
|
|
900
|
+
type: 'placeholder-absorbed';
|
|
901
|
+
turnId: string;
|
|
902
|
+
} | {
|
|
903
|
+
type: 'placeholder-dropped';
|
|
904
|
+
turnId: string;
|
|
905
|
+
};
|
|
868
906
|
|
|
869
907
|
interface ThreadRuntimeOptions {
|
|
870
908
|
threadId: string;
|
|
871
909
|
transport: ChatTransport;
|
|
872
910
|
assistantId: string;
|
|
873
911
|
/** 数字孪生 block 配置(缺省关闭) */
|
|
874
|
-
twin?:
|
|
912
|
+
twin?: {
|
|
913
|
+
enabled?: boolean;
|
|
914
|
+
toolPrefix?: string;
|
|
915
|
+
};
|
|
875
916
|
/** SSE 期间同步 thread 标题到侧边栏(ThreadDirectory 转发) */
|
|
876
917
|
onTitle?(threadId: string, title: string): void;
|
|
877
918
|
}
|
|
@@ -881,13 +922,15 @@ interface ThreadRuntime {
|
|
|
881
922
|
lastViewedAt: number;
|
|
882
923
|
/** 更新最近查看时间 */
|
|
883
924
|
touch(): void;
|
|
884
|
-
readonly
|
|
925
|
+
readonly view: ShallowRef<ThreadView>;
|
|
926
|
+
readonly turns: ComputedRef<Turn[]>;
|
|
927
|
+
/** R11 投影:尾 turn 最后一个未答澄清(含乐观答案覆盖) */
|
|
928
|
+
readonly activeClarification: ComputedRef<ClarificationRecord | undefined>;
|
|
885
929
|
readonly isGenerating: ComputedRef<boolean>;
|
|
886
930
|
readonly isInitializing: Ref<boolean>;
|
|
887
931
|
readonly runs: ComputedRef<Map<string, RunInfo>>;
|
|
888
932
|
readonly interrupt: ComputedRef<Interrupt | undefined>;
|
|
889
933
|
readonly hasPendingInterrupt: ComputedRef<boolean>;
|
|
890
|
-
readonly hasPendingClarification: ComputedRef<boolean>;
|
|
891
934
|
readonly streamError: ComputedRef<Error | null>;
|
|
892
935
|
readonly tokenUsage: ShallowRef<ThreadTokenUsage | null>;
|
|
893
936
|
readonly hasMoreHistory: ComputedRef<boolean>;
|
|
@@ -904,13 +947,18 @@ interface ThreadRuntime {
|
|
|
904
947
|
resumeInterrupt(decisions: HitlResponse): Promise<void>;
|
|
905
948
|
/** 加载更早历史页;返回是否还有更多 */
|
|
906
949
|
loadOlderMessages(): Promise<boolean>;
|
|
907
|
-
appendOptimisticGroups(groups: GroupMessage[]): void;
|
|
908
|
-
createOptimisticHuman(text: string, options?: SendMessageOptions): GroupMessage;
|
|
909
|
-
patchGroup(messageId: string, patch: Partial<GroupMessage> | ((g: GroupMessage) => GroupMessage)): void;
|
|
910
950
|
applyFeedback(messageId: string, feedback: unknown): void;
|
|
951
|
+
/** R5:API 路径乐观 turn(useReportGenerate) */
|
|
952
|
+
addOptimisticTurn(body: string): void;
|
|
953
|
+
/** R5:更新指定 ai 段正文(API 路径流式写 body) */
|
|
954
|
+
updateAiBody(aiId: string, body: string): void;
|
|
955
|
+
/** W5:定点装饰(attachments 注入等;C2 decorate) */
|
|
956
|
+
decorate(messageId: string, patch: DecoratePatch): void;
|
|
957
|
+
/** W5:密封开放段/turn(API 路径乐观 turn 收尾;流中勿调用) */
|
|
958
|
+
finalizeTurns(): void;
|
|
911
959
|
setClarificationAnswer(toolCallId: string, answer: string): void;
|
|
912
960
|
clearClarificationAnswers(): void;
|
|
913
|
-
readonly clarificationAnswers: ComputedRef<
|
|
961
|
+
readonly clarificationAnswers: ComputedRef<ReadonlyMap<string, string>>;
|
|
914
962
|
dispose(): void;
|
|
915
963
|
}
|
|
916
964
|
declare function createThreadRuntime(options: ThreadRuntimeOptions): ThreadRuntime;
|
|
@@ -927,7 +975,10 @@ interface ThreadDirectoryOptions {
|
|
|
927
975
|
maxCachedRuntimes?: number;
|
|
928
976
|
maxConcurrentStreams?: number;
|
|
929
977
|
/** 数字孪生 block 配置(透传各 runtime 的 viewmodel) */
|
|
930
|
-
twin?:
|
|
978
|
+
twin?: {
|
|
979
|
+
enabled?: boolean;
|
|
980
|
+
toolPrefix?: string;
|
|
981
|
+
};
|
|
931
982
|
/** 通知回调(ChatNotify 形态上移,core 门面注入) */
|
|
932
983
|
notify?(type: 'warning' | 'error', text: string): void;
|
|
933
984
|
/** 新 thread 默认标题(UI 文案由平台层注入,core 不内嵌多语言) */
|
|
@@ -939,7 +990,10 @@ declare class ThreadDirectory {
|
|
|
939
990
|
assistantId: string;
|
|
940
991
|
maxCachedRuntimes: number;
|
|
941
992
|
maxConcurrentStreams: number;
|
|
942
|
-
twin?:
|
|
993
|
+
twin?: {
|
|
994
|
+
enabled?: boolean;
|
|
995
|
+
toolPrefix?: string;
|
|
996
|
+
};
|
|
943
997
|
notify: (type: 'warning' | 'error', text: string) => void;
|
|
944
998
|
threads: Ref<Thread<AgentThreadState>[]>;
|
|
945
999
|
threadsPagination: Ref<ThreadsPagination>;
|
|
@@ -972,8 +1026,14 @@ declare class ThreadDirectory {
|
|
|
972
1026
|
get activeCount(): number;
|
|
973
1027
|
get generatingCount(): number;
|
|
974
1028
|
/**
|
|
975
|
-
*
|
|
976
|
-
*
|
|
1029
|
+
* 恢复未完成 run 的 SSE:按 thread.status(含 interrupted)筛出候选线程并行 listRuns
|
|
1030
|
+
* 取最新 run → init + joinStream。
|
|
1031
|
+
* ⚠️ DeerFlow 语义:thread.status 与 run.status 的 'interrupted' 都表示「run 未完成」
|
|
1032
|
+
*(_derive_thread_status:tasks 非空 → interrupted;涵盖在跑、停在半路、HITL 挂起),
|
|
1033
|
+
* 不等于 LangGraph 官方的「HITL 挂起」——因此 run.status 不作硬判定,最新 run 一律
|
|
1034
|
+
* join:在跑则继续收流;已断则 join 返回 end 帧走 onFinish 对账(runs/state/citation
|
|
1035
|
+
* 刷新),页面收敛到最终状态。join 为只读幂等端点,误 join 无副作用。
|
|
1036
|
+
* 并行确认,串行连接(并发上限内)。
|
|
977
1037
|
*/
|
|
978
1038
|
recoverRunningThreads(): Promise<void>;
|
|
979
1039
|
dispose(): void;
|
|
@@ -988,14 +1048,15 @@ interface ChatCoreOptions {
|
|
|
988
1048
|
maxCachedSessions?: number;
|
|
989
1049
|
maxConcurrentStreams?: number;
|
|
990
1050
|
/** 数字孪生 block 配置(web 端按客户端类型注入;缺省关闭) */
|
|
991
|
-
twin?:
|
|
1051
|
+
twin?: ThreadRuntimeOptions['twin'];
|
|
992
1052
|
/** 新 thread 默认标题(UI 文案注入) */
|
|
993
1053
|
defaultThreadTitle?: string;
|
|
994
1054
|
}
|
|
995
1055
|
/** ChatCore 门面(成员与 web 原 chat store 同名同语义) */
|
|
996
1056
|
interface ChatCore {
|
|
997
|
-
|
|
998
|
-
|
|
1057
|
+
/** materializer 视图(turns 上游原始结构) */
|
|
1058
|
+
view: Ref<ThreadView>;
|
|
1059
|
+
turns: Ref<Turn[]>;
|
|
999
1060
|
isGenerating: Ref<boolean>;
|
|
1000
1061
|
isLoadingThread: Ref<boolean>;
|
|
1001
1062
|
currentThreadId: Ref<string | null>;
|
|
@@ -1006,17 +1067,25 @@ interface ChatCore {
|
|
|
1006
1067
|
getRunById: (runId?: string | null) => RunInfo | undefined;
|
|
1007
1068
|
getRunsByThreadId: (threadId?: string | null) => RunInfo[];
|
|
1008
1069
|
clarificationAnswers: Ref<Map<string, string>>;
|
|
1070
|
+
/** R11 投影:尾 turn 最后一个未答澄清(含乐观答案覆盖;ClarificationCard/ChatBox 数据源) */
|
|
1071
|
+
activeClarification: Ref<ClarificationRecord | undefined>;
|
|
1009
1072
|
setClarificationAnswer: (toolCallId: string, answer: string) => void;
|
|
1010
1073
|
clearClarificationAnswers: () => void;
|
|
1011
1074
|
sendMessage: (text: string, options?: SendMessageOptions) => Promise<void>;
|
|
1012
1075
|
loadThread: (threadId: string) => Promise<void>;
|
|
1013
1076
|
stopGeneration: () => void;
|
|
1014
1077
|
clearMessages: () => void;
|
|
1015
|
-
updateGroupMessage: (messageId: string, patch: Partial<GroupMessage> | ((msg: GroupMessage) => GroupMessage)) => void;
|
|
1016
|
-
addOptimisticGroupMessages: (messages: GroupMessage[]) => void;
|
|
1017
|
-
updateGroupMessageBlocks: (messageId: string, blocks: Block[]) => void;
|
|
1018
1078
|
applyFeedback: (messageId: string, feedback: unknown) => void;
|
|
1019
|
-
|
|
1079
|
+
/** 按 ai 段 id 重新生成(从 turns 定位 human 文本与 kwargs 重发) */
|
|
1080
|
+
regenerateTurn: (aiSegmentId: string) => Promise<void>;
|
|
1081
|
+
/** R5:API 路径乐观 turn(useReportGenerate) */
|
|
1082
|
+
addOptimisticTurn: (body: string) => void;
|
|
1083
|
+
/** R5:更新指定 ai 段正文 */
|
|
1084
|
+
updateAiBody: (aiId: string, body: string) => void;
|
|
1085
|
+
/** W5:定点装饰(API 路径报告卡 attachments 注入;C2 decorate 门面) */
|
|
1086
|
+
decorate: (messageId: string, patch: DecoratePatch) => void;
|
|
1087
|
+
/** W5:密封开放段/turn(API 路径乐观 turn 收尾;流中勿调用) */
|
|
1088
|
+
finalizeTurns: () => void;
|
|
1020
1089
|
fetchThreads: (reset?: boolean, keyword?: string) => Promise<void>;
|
|
1021
1090
|
deleteThread: (threadId: string) => Promise<boolean>;
|
|
1022
1091
|
updateThreadTitle: (threadId: string, title: string) => void;
|
|
@@ -1025,8 +1094,9 @@ interface ChatCore {
|
|
|
1025
1094
|
runningNotConnectedThreadIds: Ref<Set<string>>;
|
|
1026
1095
|
recoverRunningThreads: () => Promise<void>;
|
|
1027
1096
|
activeInterrupt: Ref<Interrupt | undefined>;
|
|
1097
|
+
/** 当前待响应 interrupt 本体(InterruptBar 审核卡数据源;responded 态由 hasPendingInterrupt 派生) */
|
|
1098
|
+
interrupt: Ref<Interrupt | undefined>;
|
|
1028
1099
|
hasPendingInterrupt: Ref<boolean>;
|
|
1029
|
-
hasPendingClarification: Ref<boolean>;
|
|
1030
1100
|
inputDisabled: Ref<boolean>;
|
|
1031
1101
|
/** 当前会话流错误(UI 提示位消费;无活跃会话或无错误时为 null) */
|
|
1032
1102
|
streamError: Ref<Error | null>;
|
|
@@ -1040,4 +1110,4 @@ interface ChatCore {
|
|
|
1040
1110
|
}
|
|
1041
1111
|
declare function createChatCore(options: ChatCoreOptions): ChatCore;
|
|
1042
1112
|
|
|
1043
|
-
export { type
|
|
1113
|
+
export { type InterruptReviewBlock as $, type AcquireResult as A, type Block as B, type CitationItem as C, type DecoratePatch as D, type ExtractedPayload as E, type FetchMessagesPageOptions as F, type GroupMessageTool as G, type HitlResponse as H, type IKwargs as I, type FormBlock as J, type FormFieldItem as K, type FormFieldType as L, type MessageTokenUsage as M, type GenerateBodyRequest as N, type OutlineSubChapter as O, type GenerateBodyResult as P, type HitlActionRequest as Q, type RunInfo as R, type StreamSubmitInput as S, type ThreadView as T, type HitlDecision as U, type HitlDecisionType as V, type HitlInterruptPayload as W, type HitlReviewConfig as X, type IAttachment as Y, type IQuote as Z, type InlineCitation as _, type RunMessage as a, type ItemSegment as a0, type ListBlock as a1, type ListItem as a2, type Message as a3, type MessageMetadata as a4, type MessageRole as a5, type MessageSource as a6, type MessageStatus as a7, type ReportGenerateBodyHumanKwargs as a8, type ReportSelectedArtifact as a9, type ReportSelectedTemplate as aa, type SearchThreadsOptions as ab, type SendMessageOptions as ac, type TextBlock as ad, ThreadDirectory as ae, type ThreadDirectoryOptions as af, type ThreadRuntime as ag, type ThreadRuntimeOptions as ah, type ThreadsPagination as ai, type ToolRun as aj, type TurnEffect as ak, type XmlAttrs as al, buildHitlDecisions as am, buildInterruptReviewBlock as an, buildRejectDecisions as ao, buildRunDirectLatencyMs as ap, buildRunInfo as aq, createChatCore as ar, createThreadRuntime as as, getAllowedDecisions as at, isSameArgs as au, normalizeForCompare as av, parseHitlPayload as aw, pickRunMessageMetadata as ax, sliceBodySegments as ay, type ReportBodyPayload as b, type ReportOutlinePayload as c, type BlockBuilderOptions as d, type OutlineChapter as e, type Turn as f, type ClarificationRecord as g, type ChatTransport as h, type ThreadInitialValues as i, type MessagesPage as j, type ThreadTokenUsage as k, type StreamSubmitOptions as l, type CreateStreamOptions as m, type AgentThreadState as n, type AiTurn as o, type ArtifactFile as p, type Attachment as q, type BlockBase as r, type BlockSource as s, type BlockStatus as t, type BodySegment as u, type ChatCore as v, type ChatCoreOptions as w, type ChatNotify as x, type ChatStreamHandle as y, type CustomBlock as z };
|