@cqfe/sxin-chat-core 1.0.1 → 1.0.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.
@@ -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
- /** 已收集的字段值,confirm 模式下用于预填 */
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 | ArtifactBlock | CustomBlock | ReportOutlineBlock | ReportBodyBlock | FormBlock | ListBlock | AskClarificationBlock | TwinBlock | InterruptReviewBlock;
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 {
@@ -681,12 +565,26 @@ interface FetchMessagesPageOptions {
681
565
  interface ChatStreamHandle {
682
566
  isLoading: Ref<boolean>;
683
567
  error: Ref<Error | null>;
568
+ /**
569
+ * 当前 pending interrupt(SDK extractInterrupts:values.__interrupt__ 优先,
570
+ * threadState.tasks fallback 兜底——刷新后审批卡可见性依赖此通道)。
571
+ * 响应与否(respondedIds 乐观标记)由 runtime 门控,句柄只透出原始值。
572
+ */
573
+ interrupt: Ref<Interrupt | undefined>;
684
574
  /** 发起一次流式运行(发送用户消息) */
685
575
  submit(input: StreamSubmitInput, options?: StreamSubmitOptions): void;
686
- /** 加入既有 run 的 SSE 流(断线重连) */
576
+ /** 加入既有 run 的 SSE 流(断线重连)。
577
+ * SDK client 经典模式语义:web 端委托 SDK 原生 client.runs.joinStream
578
+ * (服务端重放该 run 剩余缓冲事件;刷新重连另由 SDK reconnectOnMount 接管)。
579
+ * lastEventId 为本端最后事件游标(' -1' 表示从头;本后端实测不消费游标,仅签名兼容)。 */
687
580
  joinStream(runId: string, lastEventId?: string): Promise<void>;
688
581
  /** 停止当前流 */
689
582
  stop(): void;
583
+ /**
584
+ * 释放句柄资源(桥接模式的 effectScope / 适配器连接等)。
585
+ * 可选:旧泵句柄无资源可释,不实现;ThreadRuntime.dispose 时会后随 stop() 调用。
586
+ */
587
+ dispose?(): void;
690
588
  /** 向 pending interrupt 发送 HITL 决策以恢复图执行(区别于 joinStream 的 SSE 重连) */
691
589
  resumeInterrupt(decisions: HitlResponse): Promise<void>;
692
590
  }
@@ -700,6 +598,13 @@ interface CreateStreamOptions {
700
598
  onValuesEvent?(data: Record<string, unknown>): void;
701
599
  /** messages/messages-tuple chunk 事件解构后转发(store 消费:accumulator 累积产 upsert/remove/clear) */
702
600
  onMessageTupleEvent?(serialized: Record<string, any>, metadata: Record<string, any>): void;
601
+ /**
602
+ * SDK messages 投影的整段快照(web 端 watch stream.messages 后转发;
603
+ * 经典 client 模式由 SDK MessageTupleManager 组装,remove 消息原生处理)。
604
+ * runtime 以快照 mini diff(protocol/snapshot-diff)转为增量指令——
605
+ * 与 onMessageTupleEvent 二选一(tuple 泵模式不调用本回调)。
606
+ */
607
+ onSnapshotMessages?(messages: Message$1[]): void;
703
608
  /**
704
609
  * 本轮流实际开始时调用(isLoading 置 true 后、首个 SSE 事件前)。
705
610
  * 经泵的串行队列调用,时序保证「旧流收尾(onStreamEnd)先于新流本回调」——
@@ -749,48 +654,217 @@ interface ChatTransport {
749
654
  createStream(options: CreateStreamOptions): ChatStreamHandle;
750
655
  }
751
656
 
657
+ /** 元素属性:key/value 均字符串(parseAttrs 已格式化) */
658
+ interface XmlAttrs {
659
+ [name: string]: string;
660
+ }
661
+ /** 正文段(§4.3):有序序列元素 */
662
+ type BodySegment = {
663
+ type: 'text';
664
+ content: string;
665
+ } | {
666
+ type: 'list';
667
+ tag: 'sxin-list';
668
+ attrs: XmlAttrs;
669
+ children: ItemSegment[];
670
+ raw: string;
671
+ } | {
672
+ type: 'item';
673
+ tag: 'sxin-item';
674
+ attrs: XmlAttrs;
675
+ content?: string;
676
+ raw: string;
677
+ };
678
+ /** sxin-item 段(list children 元素类型) */
679
+ interface ItemSegment {
680
+ type: 'item';
681
+ tag: 'sxin-item';
682
+ attrs: XmlAttrs;
683
+ content?: string;
684
+ raw: string;
685
+ }
686
+ /**
687
+ * 正文切片为有序段序列。
688
+ * 恒返回非空数组(空 body → 单空 text 段),消费方无需判空。
689
+ */
690
+ declare function sliceBodySegments(body: string): BodySegment[];
691
+
752
692
  /**
753
- * sxin AST 节点类型定义
693
+ * assembler/types.ts — Run 中心装配的数据模型与输入契约。
754
694
  *
755
- * 独立成文件以打破 sxin-ast ↔ sxin-ast-collect 的模块环:
756
- * tokenizer 与文本提取均只依赖本文件的类型,互不引用。
695
+ * 装配是纯函数:输入(page 行 + SDK 流窗口 + runs.list 元数据 + 语义层)→ 输出 RunItem[]。
696
+ * 页面渲染单元 = run(后端持久化实体),SSE 只是往活跃 run 里填内容;
697
+ * core 不再维护消息基线 / diff / COW / 乐观合成(原 turn-machine 状态机职责全删)。
757
698
  */
758
- /** 文本节点:原文切片 */
759
- interface TextNode {
760
- type: 'text';
761
- /** 原文内容 */
762
- value: string;
763
- /** 在原文中的起始偏移(含) */
764
- start: number;
765
- /** 在原文中的结束偏移(不含) */
766
- end: number;
699
+
700
+ /** runs.list 条目映射(web adapter 负责 snake_case → 本结构;缺字段容忍) */
701
+ interface RunMeta {
702
+ runId: string;
703
+ /** 后端 run 状态原值(success / error / pending / running ...) */
704
+ status: string;
705
+ /** ISO 或毫秒时间戳(runs.list created_at) */
706
+ createdAt?: number;
707
+ /** 触发输入的消息(kwargs.input.messages;澄清 resume = 合成回答消息,带 human_input_response) */
708
+ inputMessages?: Message$1[];
709
+ /** token 统计(runs.list 内联) */
710
+ tokens?: RunTokens;
711
+ /** 停止原因(stop_reason 透传,排查用) */
712
+ stopReason?: string;
713
+ }
714
+ /** run 级 token 统计(runs.list 权威) */
715
+ interface RunTokens {
716
+ total: number;
717
+ input: number;
718
+ output: number;
719
+ llmCallCount?: number;
720
+ byCaller?: {
721
+ leadAgent?: number;
722
+ subagent?: number;
723
+ middleware?: number;
724
+ };
767
725
  }
768
- /** 注释节点:<!-- ... --> */
769
- interface CommentNode {
770
- type: 'comment';
771
- /** 注释内部内容(不含 <!-- 与 -->) */
772
- content: string;
773
- start: number;
774
- end: number;
726
+ /** 装配输入行:page 行与 SDK live 消息归一化后的统一形状 */
727
+ interface AsmRow {
728
+ /** 消息 id(LangChain Message.id;live 快照的 __user 回放镜像在归一化阶段已剔除,page 的 __user 触发输入本体保留) */
729
+ id: string;
730
+ /** 窗口归属 run(page 行自带;live 行注入 activeRunId) */
731
+ runId: string;
732
+ /**
733
+ * 全局序号:page 行为真实 seq(升序权威);live 行恒为 MAX_SAFE_INTEGER——
734
+ * 稳定排序下 live 行保持插入序且排在已落库行之后(与「活跃 run 是最新 run」一致)
735
+ */
736
+ seq: number;
737
+ /** 行级时间戳(毫秒,可选) */
738
+ createdAt?: number;
739
+ /** 行级反馈(page 行专属) */
740
+ feedback?: unknown;
741
+ /** LangGraph Message 字典(语义补丁已应用) */
742
+ msg: Message$1;
775
743
  }
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;
744
+ /** 工具运行记录(与原 materializer ToolRun 同形,渲染层零迁移) */
745
+ interface ToolRun {
746
+ callId: string;
747
+ name: string;
748
+ input?: unknown;
749
+ status: 'running' | 'finished' | 'error';
750
+ result?: string;
751
+ /** write_file 类工具的 artifact_meta(与 args 平级;报告产物判定用) */
752
+ artifactMeta?: unknown;
753
+ /** tool result 业务载荷(extractFromToolResult 产物) */
754
+ extracted?: ExtractedPayload;
755
+ }
756
+ /** tool result 提取载荷(语义见 extractors.ts,类型从原 materializer/types 平移) */
757
+ type ExtractedPayload = {
758
+ kind: 'clarification';
759
+ question: string;
760
+ options?: unknown;
761
+ } | {
762
+ kind: 'report';
763
+ reportKind: 'report_outline' | 'report_body';
764
+ body?: string;
765
+ outline?: string;
766
+ sourcePath?: string;
767
+ title?: string;
768
+ } | {
769
+ kind: 'artifact';
770
+ files: unknown[];
771
+ };
772
+ /** 报告附件载荷(write_file 产物;内嵌正文或 artifact 路径两种来源) */
773
+ interface ReportAttachment {
774
+ kind: 'report';
775
+ reportKind: 'report_outline' | 'report_body';
776
+ body?: string;
777
+ outline?: string;
778
+ sourcePath?: string;
779
+ title?: string;
780
+ }
781
+ /** 附件载荷(report/artifact/twin) */
782
+ type Attachment = ReportAttachment | {
783
+ kind: 'artifact';
784
+ files: unknown[];
785
+ } | {
786
+ kind: 'twin';
787
+ payload: unknown;
788
+ };
789
+ /** 澄清记录(与原 materializer 同形;回答由跨 run join 或乐观覆盖层回填) */
790
+ interface ClarificationRecord {
791
+ callId: string;
792
+ question: string;
793
+ options?: unknown;
794
+ /** ask_clarification args.fields 的结构化字段(多题澄清) */
795
+ fields?: FormFieldItem[];
796
+ /** 回答文本(human_input_response 提取 / 乐观覆盖层) */
797
+ answer?: string;
798
+ /** 回答所在 run 的 runId(跨 run join 的溯源) */
799
+ answerRunId?: string;
800
+ }
801
+ /** 触发输入类型:普通消息轮 / 澄清回答轮 / HITL 审批轮 */
802
+ type RunInputKind = 'message' | 'clarification' | 'hitl';
803
+ /** 一次执行 = 页面渲染单元(后端 run 实体的前端投影) */
804
+ interface RunItem {
805
+ /** 真锚:runId;pending 占位窗口为本地临时 id(onCreated 转正) */
806
+ runId: string;
807
+ /** 触发输入(历史=runs.list kwargs.input;流中=submit 本地参数) */
808
+ input: {
809
+ kind: RunInputKind;
810
+ text: string;
811
+ kwargs?: Record<string, unknown>;
812
+ };
813
+ /** pending(submit→onCreated 窗口)/ running(流中)/ 后端权威值(历史) */
814
+ status: RunStatus;
815
+ /** run 内 ai 正文聚合(保留 sxin 协议标签) */
816
+ body: string;
817
+ /** 正文切片(sxin-list/item 协议段;密封/历史 run 才切片,流中为单 text 段) */
818
+ segments: BodySegment[];
819
+ /** 执行序工具记录(tool_calls ↔ tool 行按 tool_call_id 关联) */
820
+ tools: ToolRun[];
821
+ /** report/artifact/twin 附件卡(同 kind 只留最后一个) */
822
+ attachments: Attachment[];
823
+ /** 行级反馈回填(feedback 权威在 page 行) */
824
+ feedback?: unknown;
825
+ /** 本 run 内的澄清提问(回答在下一 run 的 input,跨 run join 回填) */
826
+ clarifications: ClarificationRecord[];
827
+ /** token 统计(runs.list 内联;翻页外的老 run 无) */
828
+ tokens?: RunTokens;
829
+ /** run 开始时间(runs.list created_at 优先,行级兜底) */
830
+ createdAt?: number;
831
+ /** 归属本 run 的原始装配行(排查用;渲染不消费) */
832
+ rawMessages: AsmRow[];
833
+ }
834
+ /** run 状态值域(后端权威值 ∪ 前端临时态) */
835
+ type RunStatus = 'pending' | 'running' | 'success' | 'error' | 'interrupted' | 'cancelled';
836
+ /** pending 占位(submit/resume → onCreated 窗口;转正后 runId 换真值) */
837
+ interface PendingRun {
838
+ /** 本地临时 id(local-<ts>-<seq>) */
839
+ runId: string;
840
+ /** 用户输入文本(resume 时为回答摘要) */
841
+ text: string;
842
+ kind: RunInputKind;
843
+ /** 提交时的 kwargs(透传用) */
844
+ kwargs?: Record<string, unknown>;
845
+ }
846
+ /** projectRuns 装配输入(全部由 runtime 提供,纯函数不感知数据源时序) */
847
+ interface ProjectRunsInput {
848
+ /** page 行集合(消息层权威;seq 升序由 store 保证) */
849
+ rows: RunMessage[];
850
+ /** SDK 流窗口消息(useStream stream.messages;活跃 run 的未落库行) */
851
+ liveMessages: Message$1[];
852
+ /** 当前活跃 run(metadata 首帧权威值;null = 流已开但 runId 未到) */
853
+ activeRunId: string | null;
854
+ /** runs.list 元数据(input/tokens/status 语义层) */
855
+ runsList: RunMeta[];
856
+ /** pending 占位(submit→onCreated 窗口;null = 无占位) */
857
+ pendingRun: PendingRun | null;
858
+ /** 澄清乐观答案覆盖(callId → answer;UI 输入后立即回显) */
859
+ answers?: ReadonlyMap<string, string>;
860
+ /** 数字孪生附件识别(web 按客户端类型注入;缺省关闭) */
861
+ twin?: {
862
+ enabled?: boolean;
863
+ toolPrefix?: string;
864
+ };
865
+ /** 流式进行中标记(活跃 run status=running + segments 不切片) */
866
+ streaming: boolean;
792
867
  }
793
- type SxinNode = TextNode | CommentNode | ElementNode;
794
868
 
795
869
  /** LangGraph run 在前端的投影 */
796
870
  interface RunInfo {
@@ -813,8 +887,22 @@ interface RunInfo {
813
887
  /** run 创建时间戳 */
814
888
  createdAt?: number;
815
889
  }
816
- /** 从 /threads/{id}/runs 返回的单个 run 对象解析基础 RunInfo */
890
+ /** 从 /threads/{id}/runs 返回的单个 run 对象解析基础 RunInfo。
891
+ * G7 定案字段(2026-11-13 直连 deer-flow 实测):token 三件套(total_input_tokens/
892
+ * total_output_tokens/total_tokens)+ llm_call_count/message_count 等扩展 +
893
+ * stop_reason(实测结束原因字段名,非 finish_reason);
894
+ * 无 latency_ms → latencyMs 走 created_at/updated_at 差值兜底;
895
+ * 无 model_name → modelName 依赖流结束 pickRunMessageMetadata 从 AI 消息回填;
896
+ * 无 feedback → 维持本地盖章语义(§9.1 #5)。 */
817
897
  declare function buildRunInfo(run: any, threadId: string): RunInfo;
898
+ /**
899
+ * run 接口对象 → RunMeta(assembler 装配的 runs.list 语义层输入)。
900
+ * 与 buildRunInfo 的分工:RunInfo 面向 footer/token-usage 视图(feedback/latency/modelName),
901
+ * RunMeta 面向 run 窗口装配(input 触发消息/tokens 聚合/status)。
902
+ * kwargs.input.messages 是澄清 resume 轮的合成回答消息(human_input_response 协议载体),
903
+ * projectRuns 据此回填前轮 clarification answer 与 input.kind。
904
+ */
905
+ declare function buildRunMeta(run: any): RunMeta | null;
818
906
  /**
819
907
  * 解析 run 接口直报的耗时字段 latency_ms(缺失/0/非法时为 undefined)。
820
908
  * 与 buildRunLatencyMs 的区别:不做 created_at/updated_at 时间戳兜底——
@@ -828,50 +916,15 @@ declare function pickRunMessageMetadata(messages: Message$1[]): {
828
916
  finishReason?: string;
829
917
  };
830
918
 
831
- /**
832
- * block-builder:content AST + tools → Block[]。
833
- * 闭包工厂:每次调用产生一份独立去重作用域与 parser 注册表。
834
- */
835
-
836
- /** 数字孪生工具名前缀(与 web constants/chat.ts 的 TWIN_TOOL_PREFIX 一致) */
837
- declare const DEFAULT_TWIN_TOOL_PREFIX = "city-digital-twin-display_";
838
- interface BlockBuilderLiteOptions {
839
- source: 'history' | 'sse' | 'state';
840
- isStreaming?: boolean;
841
- /** 本轮组级真实时间(毫秒);工具自身缺少 created_at 时作为兜底,避免卡片显示渲染时刻 */
842
- createdAt?: number;
843
- /**
844
- * 数字孪生 block 开关与工具名前缀(平台/租户差异,构造注入)。
845
- * web 端传 `{ enabled: getBsClient() === BS_CLIENT_TYPE.TWIN }`;缺省关闭。
846
- */
847
- twin?: {
848
- enabled: boolean;
849
- toolPrefix?: string;
850
- };
851
- }
852
- /** 闭包工厂产物(原 BlockBuilderLite 类的公开面) */
853
- interface BlockBuilderLite {
854
- /** 便捷入口:content 自行 tokenize 后走 buildFromNodes(未提前解析的调用方使用) */
855
- build(content: string, tools: GroupMessageTool[]): Block[];
856
- /**
857
- * 核心构建入口:直接消费已 tokenize 的节点树,不再重复解析。
858
- * group-builder 等已持有 AST 的调用方应走此入口(一次 tokenize 直通渲染)。
859
- */
860
- buildFromNodes(nodes: SxinNode[], rawText: string, tools: GroupMessageTool[]): Block[];
861
- }
862
- /**
863
- * 创建一个 BlockBuilderLite 实例(原 class 构造器的等价物)。
864
- * 文件去重 Set 的生命周期 = 单次工厂调用(buildAiGroup 每 group 调一次工厂),
865
- * 即去重作用域为【单轮次】:本轮 write_file 的产物不再被 present_files 重复展示;跨轮次不去重。
866
- */
867
- declare function createBlockBuilderLite(options: BlockBuilderLiteOptions): BlockBuilderLite;
868
-
869
919
  interface ThreadRuntimeOptions {
870
920
  threadId: string;
871
921
  transport: ChatTransport;
872
922
  assistantId: string;
873
923
  /** 数字孪生 block 配置(缺省关闭) */
874
- twin?: BlockBuilderLiteOptions['twin'];
924
+ twin?: {
925
+ enabled?: boolean;
926
+ toolPrefix?: string;
927
+ };
875
928
  /** SSE 期间同步 thread 标题到侧边栏(ThreadDirectory 转发) */
876
929
  onTitle?(threadId: string, title: string): void;
877
930
  }
@@ -881,13 +934,16 @@ interface ThreadRuntime {
881
934
  lastViewedAt: number;
882
935
  /** 更新最近查看时间 */
883
936
  touch(): void;
884
- readonly groups: ComputedRef<GroupMessage[]>;
937
+ /** RunItem 投影(UI v-for 直接消费;装配纯函数输出) */
938
+ readonly runs: ComputedRef<RunItem[]>;
939
+ /** RunInfo map(footer/token 视图数据源:feedback/latency/modelName) */
940
+ readonly runsInfo: ComputedRef<Map<string, RunInfo>>;
941
+ /** R11 投影:从尾向前扫最近一个含未答澄清的 run(含乐观答案覆盖) */
942
+ readonly activeClarification: ComputedRef<ClarificationRecord | undefined>;
885
943
  readonly isGenerating: ComputedRef<boolean>;
886
944
  readonly isInitializing: Ref<boolean>;
887
- readonly runs: ComputedRef<Map<string, RunInfo>>;
888
945
  readonly interrupt: ComputedRef<Interrupt | undefined>;
889
946
  readonly hasPendingInterrupt: ComputedRef<boolean>;
890
- readonly hasPendingClarification: ComputedRef<boolean>;
891
947
  readonly streamError: ComputedRef<Error | null>;
892
948
  readonly tokenUsage: ShallowRef<ThreadTokenUsage | null>;
893
949
  readonly hasMoreHistory: ComputedRef<boolean>;
@@ -898,19 +954,29 @@ interface ThreadRuntime {
898
954
  submit(text: string, options?: SendMessageOptions): void;
899
955
  /** 加入既有 run 的 SSE(断线重连) */
900
956
  joinStream(runId: string, lastEventId?: string): Promise<void>;
901
- /** 停止当前流(本地 abort) */
957
+ /** 停止当前流(本地 abort + 服务端取消) */
902
958
  stop(): void;
903
959
  /** 响应 pending interrupt(乐观标记 + 失败回滚) */
904
960
  resumeInterrupt(decisions: HitlResponse): Promise<void>;
905
961
  /** 加载更早历史页;返回是否还有更多 */
906
962
  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
963
  applyFeedback(messageId: string, feedback: unknown): void;
964
+ /** R5:API 路径乐观 run(useReportGenerate) */
965
+ addOptimisticTurn(body: string): void;
966
+ /** R5:更新指定 run 正文(API 路径流式写 body;改 rows store 内对应行) */
967
+ updateAiBody(aiId: string, body: string): void;
968
+ /** W5:定点装饰(attachments 注入等;透传 patchRun/行级覆盖) */
969
+ decorate(messageId: string, patch: {
970
+ feedback?: {
971
+ rating: number;
972
+ };
973
+ attachments?: RunItem['attachments'];
974
+ }): void;
975
+ /** W5:密封开放段(API 路径乐观收尾;Run 模型下 = 清 pending 占位) */
976
+ finalizeTurns(): void;
911
977
  setClarificationAnswer(toolCallId: string, answer: string): void;
912
978
  clearClarificationAnswers(): void;
913
- readonly clarificationAnswers: ComputedRef<Map<string, string>>;
979
+ readonly clarificationAnswers: ComputedRef<ReadonlyMap<string, string>>;
914
980
  dispose(): void;
915
981
  }
916
982
  declare function createThreadRuntime(options: ThreadRuntimeOptions): ThreadRuntime;
@@ -927,7 +993,10 @@ interface ThreadDirectoryOptions {
927
993
  maxCachedRuntimes?: number;
928
994
  maxConcurrentStreams?: number;
929
995
  /** 数字孪生 block 配置(透传各 runtime 的 viewmodel) */
930
- twin?: BlockBuilderLiteOptions['twin'];
996
+ twin?: {
997
+ enabled?: boolean;
998
+ toolPrefix?: string;
999
+ };
931
1000
  /** 通知回调(ChatNotify 形态上移,core 门面注入) */
932
1001
  notify?(type: 'warning' | 'error', text: string): void;
933
1002
  /** 新 thread 默认标题(UI 文案由平台层注入,core 不内嵌多语言) */
@@ -939,7 +1008,10 @@ declare class ThreadDirectory {
939
1008
  assistantId: string;
940
1009
  maxCachedRuntimes: number;
941
1010
  maxConcurrentStreams: number;
942
- twin?: BlockBuilderLiteOptions['twin'];
1011
+ twin?: {
1012
+ enabled?: boolean;
1013
+ toolPrefix?: string;
1014
+ };
943
1015
  notify: (type: 'warning' | 'error', text: string) => void;
944
1016
  threads: Ref<Thread<AgentThreadState>[]>;
945
1017
  threadsPagination: Ref<ThreadsPagination>;
@@ -972,8 +1044,14 @@ declare class ThreadDirectory {
972
1044
  get activeCount(): number;
973
1045
  get generatingCount(): number;
974
1046
  /**
975
- * 恢复 running run 的 SSE:在已加载列表里过滤活跃线程 → listRuns 确认 → init + joinStream。
976
- * interrupted 线程不恢复(打开时经 init 恢复 interrupt 卡片)。并行确认,串行连接(并发上限内)。
1047
+ * 恢复未完成 run 的 SSE:按 thread.status(含 interrupted)筛出候选线程并行 listRuns
1048
+ * 取最新 run → init + joinStream。
1049
+ * ⚠️ DeerFlow 语义:thread.status 与 run.status 的 'interrupted' 都表示「run 未完成」
1050
+ *(_derive_thread_status:tasks 非空 → interrupted;涵盖在跑、停在半路、HITL 挂起),
1051
+ * 不等于 LangGraph 官方的「HITL 挂起」——因此 run.status 不作硬判定,最新 run 一律
1052
+ * join:在跑则继续收流;已断则 join 返回 end 帧走 onFinish 对账(runs/state/citation
1053
+ * 刷新),页面收敛到最终状态。join 为只读幂等端点,误 join 无副作用。
1054
+ * 并行确认,串行连接(并发上限内)。
977
1055
  */
978
1056
  recoverRunningThreads(): Promise<void>;
979
1057
  dispose(): void;
@@ -988,35 +1066,51 @@ interface ChatCoreOptions {
988
1066
  maxCachedSessions?: number;
989
1067
  maxConcurrentStreams?: number;
990
1068
  /** 数字孪生 block 配置(web 端按客户端类型注入;缺省关闭) */
991
- twin?: BlockBuilderLiteOptions['twin'];
1069
+ twin?: ThreadRuntimeOptions['twin'];
992
1070
  /** 新 thread 默认标题(UI 文案注入) */
993
1071
  defaultThreadTitle?: string;
994
1072
  }
995
1073
  /** ChatCore 门面(成员与 web 原 chat store 同名同语义) */
996
1074
  interface ChatCore {
997
- messages: Ref<GroupMessage[]>;
998
- groupMessages: Ref<GroupMessage[]>;
1075
+ /** RunItem 投影(UI 渲染单元 = run;原 turns 改名) */
1076
+ runs: Ref<RunItem[]>;
1077
+ /** 历史别名(原 turns;指向同一投影,迁移期兼容,删除条件:UI 全部切换 runs) */
1078
+ turns: Ref<RunItem[]>;
999
1079
  isGenerating: Ref<boolean>;
1000
1080
  isLoadingThread: Ref<boolean>;
1001
1081
  currentThreadId: Ref<string | null>;
1002
1082
  threads: Ref<Thread<AgentThreadState>[]>;
1003
1083
  threadsPagination: Ref<ThreadsPagination>;
1004
- runs: Ref<Map<string, RunInfo>>;
1084
+ runsInfo: Ref<Map<string, RunInfo>>;
1085
+ /** 兼容投影:从 runs 的 tools 聚合,形状适配旧 GroupMessageTool(ReportPane 零改契约) */
1005
1086
  toolCalls: Ref<any[]>;
1087
+ /** 兼容别名(原 runs;RunInfo map——点赞/latency/modelName 视图数据源) */
1006
1088
  getRunById: (runId?: string | null) => RunInfo | undefined;
1007
1089
  getRunsByThreadId: (threadId?: string | null) => RunInfo[];
1008
- clarificationAnswers: Ref<Map<string, string>>;
1090
+ clarificationAnswers: Ref<ReadonlyMap<string, string>>;
1091
+ /** R11 投影:最近一个未答澄清(含乐观答案覆盖;ClarificationCard/ChatBox 数据源) */
1092
+ activeClarification: Ref<ClarificationRecord | undefined>;
1009
1093
  setClarificationAnswer: (toolCallId: string, answer: string) => void;
1010
1094
  clearClarificationAnswers: () => void;
1011
1095
  sendMessage: (text: string, options?: SendMessageOptions) => Promise<void>;
1012
1096
  loadThread: (threadId: string) => Promise<void>;
1013
1097
  stopGeneration: () => void;
1014
1098
  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
1099
  applyFeedback: (messageId: string, feedback: unknown) => void;
1019
- regenerate: (assistantMessageId: string) => Promise<void>;
1100
+ /** 按 runId 重新生成(从 RunItem.input.text 取原文重发) */
1101
+ regenerateTurn: (runId: string) => Promise<void>;
1102
+ /** R5:API 路径乐观 run(useReportGenerate) */
1103
+ addOptimisticTurn: (body: string) => void;
1104
+ /** R5:更新指定 ai 段正文 */
1105
+ updateAiBody: (aiId: string, body: string) => void;
1106
+ /** W5:定点装饰(feedback 盖章) */
1107
+ decorate: (messageId: string, patch: {
1108
+ feedback?: {
1109
+ rating: number;
1110
+ };
1111
+ }) => void;
1112
+ /** W5:API 路径乐观收尾(清 pending 占位) */
1113
+ finalizeTurns: () => void;
1020
1114
  fetchThreads: (reset?: boolean, keyword?: string) => Promise<void>;
1021
1115
  deleteThread: (threadId: string) => Promise<boolean>;
1022
1116
  updateThreadTitle: (threadId: string, title: string) => void;
@@ -1025,8 +1119,9 @@ interface ChatCore {
1025
1119
  runningNotConnectedThreadIds: Ref<Set<string>>;
1026
1120
  recoverRunningThreads: () => Promise<void>;
1027
1121
  activeInterrupt: Ref<Interrupt | undefined>;
1122
+ /** 当前待响应 interrupt 本体(InterruptBar 审核卡数据源) */
1123
+ interrupt: Ref<Interrupt | undefined>;
1028
1124
  hasPendingInterrupt: Ref<boolean>;
1029
- hasPendingClarification: Ref<boolean>;
1030
1125
  inputDisabled: Ref<boolean>;
1031
1126
  /** 当前会话流错误(UI 提示位消费;无活跃会话或无错误时为 null) */
1032
1127
  streamError: Ref<Error | null>;
@@ -1040,4 +1135,4 @@ interface ChatCore {
1040
1135
  }
1041
1136
  declare function createChatCore(options: ChatCoreOptions): ChatCore;
1042
1137
 
1043
- export { type HitlDecisionType as $, type AcquireResult as A, type Block as B, type CreateStreamOptions as C, type ChatCoreOptions as D, type ElementNode as E, type ChatNotify as F, type GroupMessageTool as G, type HitlResponse as H, type IKwargs as I, type CommentNode as J, type CustomBlock as K, DEFAULT_TWIN_TOOL_PREFIX as L, type MessageTokenUsage as M, type FetchMessagesPageOptions as N, type OutlineSubChapter as O, type FormBlock as P, type FormFieldItem as Q, type RunInfo as R, type SxinNode as S, type ThreadInitialValues as T, type FormFieldType as U, type GenerateBodyRequest as V, type GenerateBodyResult as W, type GroupMessageSource as X, type GroupMessageStatus as Y, type HitlActionRequest as Z, type HitlDecision as _, type ChatStreamHandle as a, type HitlInterruptPayload as a0, type HitlReviewConfig as a1, type IAttachment as a2, type IQuote as a3, type InlineCitation as a4, type InterruptReviewBlock as a5, type ListBlock as a6, type ListItem as a7, type Message as a8, type MessageMetadata as a9, getAllowedDecisions as aA, isSameArgs as aB, normalizeForCompare as aC, parseHitlPayload as aD, pickRunMessageMetadata as aE, type MessageRole as aa, type MessageSource as ab, type MessageStatus as ac, type ReportBodyBlock as ad, type ReportGenerateBodyHumanKwargs as ae, type ReportOutlineBlock as af, type ReportSelectedArtifact as ag, type ReportSelectedTemplate as ah, type SearchThreadsOptions as ai, type TextBlock as aj, type TextNode as ak, ThreadDirectory as al, type ThreadDirectoryOptions as am, type ThreadRuntime as an, type ThreadRuntimeOptions as ao, type ThreadsPagination as ap, type TwinBlock as aq, buildHitlDecisions as ar, buildInterruptReviewBlock as as, buildInterruptReviewGroup as at, buildRejectDecisions as au, buildRunDirectLatencyMs as av, buildRunInfo as aw, createBlockBuilderLite as ax, createChatCore as ay, createThreadRuntime as az, type CitationItem as b, type RunMessage as c, type ReportBodyPayload as d, type ReportOutlinePayload as e, type BlockBuilderOptions as f, type OutlineChapter as g, type GroupMessageType as h, type BlockBuilderLiteOptions as i, type GroupMessage as j, type SendMessageOptions as k, type ChatTransport as l, type MessagesPage as m, type ThreadTokenUsage as n, type StreamSubmitInput as o, type StreamSubmitOptions as p, type AgentThreadState as q, type ArtifactBlock as r, type ArtifactFile as s, type AskClarificationBlock as t, type BlockBase as u, type BlockBuilderLite as v, type BlockSource as w, type BlockStatus as x, type BuildAllOptions as y, type ChatCore as z };
1138
+ export { type InterruptReviewBlock as $, type AsmRow as A, type Block as B, type CitationItem as C, type FormBlock as D, type ExtractedPayload as E, type FetchMessagesPageOptions as F, type GroupMessageTool as G, type HitlResponse as H, type IKwargs as I, type FormFieldItem as J, type FormFieldType as K, type GenerateBodyRequest as L, type MessageTokenUsage as M, type GenerateBodyResult as N, type OutlineSubChapter as O, type ProjectRunsInput as P, type HitlActionRequest as Q, type RunInfo as R, type StreamSubmitInput as S, type ThreadInitialValues 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 PendingRun as a8, type ReportAttachment as a9, normalizeForCompare as aA, parseHitlPayload as aB, pickRunMessageMetadata as aC, sliceBodySegments as aD, type ReportGenerateBodyHumanKwargs as aa, type ReportSelectedArtifact as ab, type ReportSelectedTemplate as ac, type RunInputKind as ad, type RunMeta as ae, type RunTokens as af, type SearchThreadsOptions as ag, type SendMessageOptions as ah, type TextBlock as ai, ThreadDirectory as aj, type ThreadDirectoryOptions as ak, type ThreadRuntime as al, type ThreadRuntimeOptions as am, type ThreadsPagination as an, type ToolRun as ao, type XmlAttrs as ap, buildHitlDecisions as aq, buildInterruptReviewBlock as ar, buildRejectDecisions as as, buildRunDirectLatencyMs as at, buildRunInfo as au, buildRunMeta as av, createChatCore as aw, createThreadRuntime as ax, getAllowedDecisions as ay, isSameArgs as az, type ReportBodyPayload as b, type ReportOutlinePayload as c, type BlockBuilderOptions as d, type OutlineChapter as e, type RunItem as f, type RunStatus as g, type ChatTransport as h, type MessagesPage as i, type ThreadTokenUsage as j, type StreamSubmitOptions as k, type CreateStreamOptions as l, type AcquireResult as m, type AgentThreadState as n, type ArtifactFile as o, type Attachment as p, type BlockBase as q, type BlockSource as r, type BlockStatus as s, type BodySegment as t, type ChatCore as u, type ChatCoreOptions as v, type ChatNotify as w, type ChatStreamHandle as x, type ClarificationRecord as y, type CustomBlock as z };