@cqfe/sxin-chat-core 1.0.2 → 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.
- package/dist/{ChatCore-cSM1HmXp.d.cts → ChatCore-CCeoxjP9.d.cts} +228 -203
- package/dist/{ChatCore-cSM1HmXp.d.ts → ChatCore-CCeoxjP9.d.ts} +228 -203
- package/dist/{chunk-Z65C2UII.mjs → chunk-2AXUXZVK.mjs} +762 -931
- package/dist/index.cjs +763 -1598
- package/dist/index.d.cts +133 -523
- package/dist/index.d.ts +133 -523
- package/dist/index.mjs +48 -689
- package/dist/vue/index.cjs +785 -1024
- 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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Ref,
|
|
1
|
+
import { Ref, ComputedRef, ShallowRef } 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> {
|
|
@@ -565,14 +565,18 @@ interface FetchMessagesPageOptions {
|
|
|
565
565
|
interface ChatStreamHandle {
|
|
566
566
|
isLoading: Ref<boolean>;
|
|
567
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>;
|
|
568
574
|
/** 发起一次流式运行(发送用户消息) */
|
|
569
575
|
submit(input: StreamSubmitInput, options?: StreamSubmitOptions): void;
|
|
570
576
|
/** 加入既有 run 的 SSE 流(断线重连)。
|
|
571
|
-
*
|
|
572
|
-
*
|
|
573
|
-
* lastEventId
|
|
574
|
-
* web streamBridge 旁路打开 join SSE,复用旧泵回调直驱 store(不经 SDK 控制器);
|
|
575
|
-
* 旧管道为 client.runs.joinStream 原生实现。 */
|
|
577
|
+
* SDK client 经典模式语义:web 端委托 SDK 原生 client.runs.joinStream
|
|
578
|
+
* (服务端重放该 run 剩余缓冲事件;刷新重连另由 SDK reconnectOnMount 接管)。
|
|
579
|
+
* lastEventId 为本端最后事件游标(' -1' 表示从头;本后端实测不消费游标,仅签名兼容)。 */
|
|
576
580
|
joinStream(runId: string, lastEventId?: string): Promise<void>;
|
|
577
581
|
/** 停止当前流 */
|
|
578
582
|
stop(): void;
|
|
@@ -595,7 +599,8 @@ interface CreateStreamOptions {
|
|
|
595
599
|
/** messages/messages-tuple chunk 事件解构后转发(store 消费:accumulator 累积产 upsert/remove/clear) */
|
|
596
600
|
onMessageTupleEvent?(serialized: Record<string, any>, metadata: Record<string, any>): void;
|
|
597
601
|
/**
|
|
598
|
-
*
|
|
602
|
+
* SDK messages 投影的整段快照(web 端 watch stream.messages 后转发;
|
|
603
|
+
* 经典 client 模式由 SDK MessageTupleManager 组装,remove 消息原生处理)。
|
|
599
604
|
* runtime 以快照 mini diff(protocol/snapshot-diff)转为增量指令——
|
|
600
605
|
* 与 onMessageTupleEvent 二选一(tuple 泵模式不调用本回调)。
|
|
601
606
|
*/
|
|
@@ -649,48 +654,6 @@ interface ChatTransport {
|
|
|
649
654
|
createStream(options: CreateStreamOptions): ChatStreamHandle;
|
|
650
655
|
}
|
|
651
656
|
|
|
652
|
-
/** LangGraph run 在前端的投影 */
|
|
653
|
-
interface RunInfo {
|
|
654
|
-
/** run 唯一 id */
|
|
655
|
-
runId: string;
|
|
656
|
-
/** 所属 thread id */
|
|
657
|
-
threadId: string;
|
|
658
|
-
/** token 消耗(来自 /threads/{id}/runs 接口字段) */
|
|
659
|
-
usage?: MessageTokenUsage;
|
|
660
|
-
/** 模型耗时,毫秒(优先接口 latency_ms,缺失时 created_at/updated_at 兜底;历史 run 以 turn_duration enrichment 为准) */
|
|
661
|
-
latencyMs?: number;
|
|
662
|
-
/** 模型结束原因 */
|
|
663
|
-
finishReason?: string;
|
|
664
|
-
/** 模型名(优先来自 run,流结束时缺失可从 AI message response_metadata 回填首条非空值) */
|
|
665
|
-
modelName?: string;
|
|
666
|
-
/** 用户反馈(一定从 /runs/{runId}/messages 返回的 message.feedback 解析) */
|
|
667
|
-
feedback?: unknown;
|
|
668
|
-
/** run 状态 */
|
|
669
|
-
status?: 'running' | 'completed' | 'error';
|
|
670
|
-
/** run 创建时间戳 */
|
|
671
|
-
createdAt?: number;
|
|
672
|
-
}
|
|
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)。 */
|
|
680
|
-
declare function buildRunInfo(run: any, threadId: string): RunInfo;
|
|
681
|
-
/**
|
|
682
|
-
* 解析 run 接口直报的耗时字段 latency_ms(缺失/0/非法时为 undefined)。
|
|
683
|
-
* 与 buildRunLatencyMs 的区别:不做 created_at/updated_at 时间戳兜底——
|
|
684
|
-
* refreshRuns 合并时需要区分「接口直报」与「时间戳差值」两种来源,以便让
|
|
685
|
-
* messagesPage 的 turn_duration enrichment(精确耗时)优先于时间戳兜底。
|
|
686
|
-
*/
|
|
687
|
-
declare function buildRunDirectLatencyMs(run: any): number | undefined;
|
|
688
|
-
/** 从 AI messages 中提取首个非空 modelName / finishReason(轻量提取,不做 token/latency 累加) */
|
|
689
|
-
declare function pickRunMessageMetadata(messages: Message$1[]): {
|
|
690
|
-
modelName?: string;
|
|
691
|
-
finishReason?: string;
|
|
692
|
-
};
|
|
693
|
-
|
|
694
657
|
/** 元素属性:key/value 均字符串(parseAttrs 已格式化) */
|
|
695
658
|
interface XmlAttrs {
|
|
696
659
|
[name: string]: string;
|
|
@@ -727,93 +690,92 @@ interface ItemSegment {
|
|
|
727
690
|
declare function sliceBodySegments(body: string): BodySegment[];
|
|
728
691
|
|
|
729
692
|
/**
|
|
730
|
-
*
|
|
731
|
-
*
|
|
693
|
+
* assembler/types.ts — Run 中心装配的数据模型与输入契约。
|
|
694
|
+
*
|
|
695
|
+
* 装配是纯函数:输入(page 行 + SDK 流窗口 + runs.list 元数据 + 语义层)→ 输出 RunItem[]。
|
|
696
|
+
* 页面渲染单元 = run(后端持久化实体),SSE 只是往活跃 run 里填内容;
|
|
697
|
+
* core 不再维护消息基线 / diff / COW / 乐观合成(原 turn-machine 状态机职责全删)。
|
|
732
698
|
*/
|
|
733
699
|
|
|
734
|
-
/**
|
|
735
|
-
interface
|
|
736
|
-
/** 有序;一轮 = 用户可见提问 + AI 应答 */
|
|
737
|
-
turns: Turn[];
|
|
738
|
-
}
|
|
739
|
-
/** 一轮对话 */
|
|
740
|
-
interface Turn {
|
|
741
|
-
/** = human 消息 id */
|
|
742
|
-
id: string;
|
|
743
|
-
/** 首个 ai 段的 runId */
|
|
700
|
+
/** runs.list 条目映射(web adapter 负责 snake_case → 本结构;缺字段容忍) */
|
|
701
|
+
interface RunMeta {
|
|
744
702
|
runId: string;
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
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;
|
|
751
724
|
};
|
|
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[];
|
|
761
725
|
}
|
|
762
|
-
/**
|
|
763
|
-
interface
|
|
764
|
-
/**
|
|
726
|
+
/** 装配输入行:page 行与 SDK live 消息归一化后的统一形状 */
|
|
727
|
+
interface AsmRow {
|
|
728
|
+
/** 消息 id(LangChain Message.id;live 快照的 __user 回放镜像在归一化阶段已剔除,page 的 __user 触发输入本体保留) */
|
|
765
729
|
id: string;
|
|
730
|
+
/** 窗口归属 run(page 行自带;live 行注入 activeRunId) */
|
|
766
731
|
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';
|
|
782
732
|
/**
|
|
783
|
-
*
|
|
784
|
-
*
|
|
785
|
-
* 若 finalize 全量重建只登记段首 id,流收尾 /state 回填的 update 会因索引 miss
|
|
786
|
-
* 被静默丢弃(citation 丢失断点,2026-11 实测)。渲染不消费。
|
|
733
|
+
* 全局序号:page 行为真实 seq(升序权威);live 行恒为 MAX_SAFE_INTEGER——
|
|
734
|
+
* 稳定排序下 live 行保持插入序且排在已落库行之后(与「活跃 run 是最新 run」一致)
|
|
787
735
|
*/
|
|
788
|
-
|
|
736
|
+
seq: number;
|
|
737
|
+
/** 行级时间戳(毫秒,可选) */
|
|
738
|
+
createdAt?: number;
|
|
739
|
+
/** 行级反馈(page 行专属) */
|
|
740
|
+
feedback?: unknown;
|
|
741
|
+
/** LangGraph Message 字典(语义补丁已应用) */
|
|
742
|
+
msg: Message$1;
|
|
789
743
|
}
|
|
790
|
-
/**
|
|
744
|
+
/** 工具运行记录(与原 materializer ToolRun 同形,渲染层零迁移) */
|
|
791
745
|
interface ToolRun {
|
|
792
746
|
callId: string;
|
|
793
747
|
name: string;
|
|
794
748
|
input?: unknown;
|
|
795
749
|
status: 'running' | 'finished' | 'error';
|
|
796
750
|
result?: string;
|
|
797
|
-
/** write_file 类工具的 artifact_meta
|
|
751
|
+
/** write_file 类工具的 artifact_meta(与 args 平级;报告产物判定用) */
|
|
798
752
|
artifactMeta?: unknown;
|
|
799
|
-
/** tool
|
|
753
|
+
/** tool result 业务载荷(extractFromToolResult 产物) */
|
|
800
754
|
extracted?: ExtractedPayload;
|
|
801
755
|
}
|
|
802
|
-
/**
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
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 路径两种来源) */
|
|
807
773
|
interface ReportAttachment {
|
|
808
774
|
kind: 'report';
|
|
809
775
|
reportKind: 'report_outline' | 'report_body';
|
|
810
|
-
/** 内嵌正文(JSON result 路径) */
|
|
811
776
|
body?: string;
|
|
812
|
-
/** 内嵌大纲 markdown(JSON result 路径) */
|
|
813
777
|
outline?: string;
|
|
814
|
-
/** artifact 文件路径(artifact_meta 路径;点击卡片后经 loadArtifactContent 拉取) */
|
|
815
778
|
sourcePath?: string;
|
|
816
|
-
/** 卡片展示标题(缺省由内容/路径提取) */
|
|
817
779
|
title?: string;
|
|
818
780
|
}
|
|
819
781
|
/** 附件载荷(report/artifact/twin) */
|
|
@@ -824,84 +786,134 @@ type Attachment = ReportAttachment | {
|
|
|
824
786
|
kind: 'twin';
|
|
825
787
|
payload: unknown;
|
|
826
788
|
};
|
|
827
|
-
/**
|
|
789
|
+
/** 澄清记录(与原 materializer 同形;回答由跨 run join 或乐观覆盖层回填) */
|
|
828
790
|
interface ClarificationRecord {
|
|
829
791
|
callId: string;
|
|
830
792
|
question: string;
|
|
831
793
|
options?: unknown;
|
|
832
|
-
/**
|
|
794
|
+
/** ask_clarification args.fields 的结构化字段(多题澄清) */
|
|
833
795
|
fields?: FormFieldItem[];
|
|
834
|
-
/**
|
|
796
|
+
/** 回答文本(human_input_response 提取 / 乐观覆盖层) */
|
|
835
797
|
answer?: string;
|
|
836
|
-
|
|
798
|
+
/** 回答所在 run 的 runId(跨 run join 的溯源) */
|
|
799
|
+
answerRunId?: string;
|
|
837
800
|
}
|
|
838
|
-
/**
|
|
839
|
-
type
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
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;
|
|
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>;
|
|
858
812
|
};
|
|
859
|
-
/**
|
|
860
|
-
|
|
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;
|
|
813
|
+
/** pending(submit→onCreated 窗口)/ running(流中)/ 后端权威值(历史) */
|
|
814
|
+
status: RunStatus;
|
|
815
|
+
/** run 内 ai 正文聚合(保留 sxin 协议标签) */
|
|
878
816
|
body: string;
|
|
879
|
-
|
|
880
|
-
} | {
|
|
881
|
-
type: 'ai-sealed';
|
|
882
|
-
turnId: string;
|
|
883
|
-
aiId: string;
|
|
817
|
+
/** 正文切片(sxin-list/item 协议段;密封/历史 run 才切片,流中为单 text 段) */
|
|
884
818
|
segments: BodySegment[];
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
}
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
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;
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
/** LangGraph run 在前端的投影 */
|
|
870
|
+
interface RunInfo {
|
|
871
|
+
/** run 唯一 id */
|
|
872
|
+
runId: string;
|
|
873
|
+
/** 所属 thread id */
|
|
874
|
+
threadId: string;
|
|
875
|
+
/** token 消耗(来自 /threads/{id}/runs 接口字段) */
|
|
876
|
+
usage?: MessageTokenUsage;
|
|
877
|
+
/** 模型耗时,毫秒(优先接口 latency_ms,缺失时 created_at/updated_at 兜底;历史 run 以 turn_duration enrichment 为准) */
|
|
878
|
+
latencyMs?: number;
|
|
879
|
+
/** 模型结束原因 */
|
|
880
|
+
finishReason?: string;
|
|
881
|
+
/** 模型名(优先来自 run,流结束时缺失可从 AI message response_metadata 回填首条非空值) */
|
|
882
|
+
modelName?: string;
|
|
883
|
+
/** 用户反馈(一定从 /runs/{runId}/messages 返回的 message.feedback 解析) */
|
|
884
|
+
feedback?: unknown;
|
|
885
|
+
/** run 状态 */
|
|
886
|
+
status?: 'running' | 'completed' | 'error';
|
|
887
|
+
/** run 创建时间戳 */
|
|
888
|
+
createdAt?: number;
|
|
889
|
+
}
|
|
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)。 */
|
|
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;
|
|
906
|
+
/**
|
|
907
|
+
* 解析 run 接口直报的耗时字段 latency_ms(缺失/0/非法时为 undefined)。
|
|
908
|
+
* 与 buildRunLatencyMs 的区别:不做 created_at/updated_at 时间戳兜底——
|
|
909
|
+
* refreshRuns 合并时需要区分「接口直报」与「时间戳差值」两种来源,以便让
|
|
910
|
+
* messagesPage 的 turn_duration enrichment(精确耗时)优先于时间戳兜底。
|
|
911
|
+
*/
|
|
912
|
+
declare function buildRunDirectLatencyMs(run: any): number | undefined;
|
|
913
|
+
/** 从 AI messages 中提取首个非空 modelName / finishReason(轻量提取,不做 token/latency 累加) */
|
|
914
|
+
declare function pickRunMessageMetadata(messages: Message$1[]): {
|
|
915
|
+
modelName?: string;
|
|
916
|
+
finishReason?: string;
|
|
905
917
|
};
|
|
906
918
|
|
|
907
919
|
interface ThreadRuntimeOptions {
|
|
@@ -922,13 +934,14 @@ interface ThreadRuntime {
|
|
|
922
934
|
lastViewedAt: number;
|
|
923
935
|
/** 更新最近查看时间 */
|
|
924
936
|
touch(): void;
|
|
925
|
-
|
|
926
|
-
readonly
|
|
927
|
-
/**
|
|
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(含乐观答案覆盖) */
|
|
928
942
|
readonly activeClarification: ComputedRef<ClarificationRecord | undefined>;
|
|
929
943
|
readonly isGenerating: ComputedRef<boolean>;
|
|
930
944
|
readonly isInitializing: Ref<boolean>;
|
|
931
|
-
readonly runs: ComputedRef<Map<string, RunInfo>>;
|
|
932
945
|
readonly interrupt: ComputedRef<Interrupt | undefined>;
|
|
933
946
|
readonly hasPendingInterrupt: ComputedRef<boolean>;
|
|
934
947
|
readonly streamError: ComputedRef<Error | null>;
|
|
@@ -941,20 +954,25 @@ interface ThreadRuntime {
|
|
|
941
954
|
submit(text: string, options?: SendMessageOptions): void;
|
|
942
955
|
/** 加入既有 run 的 SSE(断线重连) */
|
|
943
956
|
joinStream(runId: string, lastEventId?: string): Promise<void>;
|
|
944
|
-
/** 停止当前流(本地 abort
|
|
957
|
+
/** 停止当前流(本地 abort + 服务端取消) */
|
|
945
958
|
stop(): void;
|
|
946
959
|
/** 响应 pending interrupt(乐观标记 + 失败回滚) */
|
|
947
960
|
resumeInterrupt(decisions: HitlResponse): Promise<void>;
|
|
948
961
|
/** 加载更早历史页;返回是否还有更多 */
|
|
949
962
|
loadOlderMessages(): Promise<boolean>;
|
|
950
963
|
applyFeedback(messageId: string, feedback: unknown): void;
|
|
951
|
-
/** R5:API 路径乐观
|
|
964
|
+
/** R5:API 路径乐观 run(useReportGenerate) */
|
|
952
965
|
addOptimisticTurn(body: string): void;
|
|
953
|
-
/** R5:更新指定
|
|
966
|
+
/** R5:更新指定 run 正文(API 路径流式写 body;改 rows store 内对应行) */
|
|
954
967
|
updateAiBody(aiId: string, body: string): void;
|
|
955
|
-
/** W5:定点装饰(attachments
|
|
956
|
-
decorate(messageId: string, patch:
|
|
957
|
-
|
|
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 占位) */
|
|
958
976
|
finalizeTurns(): void;
|
|
959
977
|
setClarificationAnswer(toolCallId: string, answer: string): void;
|
|
960
978
|
clearClarificationAnswers(): void;
|
|
@@ -1054,20 +1072,23 @@ interface ChatCoreOptions {
|
|
|
1054
1072
|
}
|
|
1055
1073
|
/** ChatCore 门面(成员与 web 原 chat store 同名同语义) */
|
|
1056
1074
|
interface ChatCore {
|
|
1057
|
-
/**
|
|
1058
|
-
|
|
1059
|
-
turns
|
|
1075
|
+
/** RunItem 投影(UI 渲染单元 = run;原 turns 改名) */
|
|
1076
|
+
runs: Ref<RunItem[]>;
|
|
1077
|
+
/** 历史别名(原 turns;指向同一投影,迁移期兼容,删除条件:UI 全部切换 runs) */
|
|
1078
|
+
turns: Ref<RunItem[]>;
|
|
1060
1079
|
isGenerating: Ref<boolean>;
|
|
1061
1080
|
isLoadingThread: Ref<boolean>;
|
|
1062
1081
|
currentThreadId: Ref<string | null>;
|
|
1063
1082
|
threads: Ref<Thread<AgentThreadState>[]>;
|
|
1064
1083
|
threadsPagination: Ref<ThreadsPagination>;
|
|
1065
|
-
|
|
1084
|
+
runsInfo: Ref<Map<string, RunInfo>>;
|
|
1085
|
+
/** 兼容投影:从 runs 的 tools 聚合,形状适配旧 GroupMessageTool(ReportPane 零改契约) */
|
|
1066
1086
|
toolCalls: Ref<any[]>;
|
|
1087
|
+
/** 兼容别名(原 runs;RunInfo map——点赞/latency/modelName 视图数据源) */
|
|
1067
1088
|
getRunById: (runId?: string | null) => RunInfo | undefined;
|
|
1068
1089
|
getRunsByThreadId: (threadId?: string | null) => RunInfo[];
|
|
1069
|
-
clarificationAnswers: Ref<
|
|
1070
|
-
/** R11
|
|
1090
|
+
clarificationAnswers: Ref<ReadonlyMap<string, string>>;
|
|
1091
|
+
/** R11 投影:最近一个未答澄清(含乐观答案覆盖;ClarificationCard/ChatBox 数据源) */
|
|
1071
1092
|
activeClarification: Ref<ClarificationRecord | undefined>;
|
|
1072
1093
|
setClarificationAnswer: (toolCallId: string, answer: string) => void;
|
|
1073
1094
|
clearClarificationAnswers: () => void;
|
|
@@ -1076,15 +1097,19 @@ interface ChatCore {
|
|
|
1076
1097
|
stopGeneration: () => void;
|
|
1077
1098
|
clearMessages: () => void;
|
|
1078
1099
|
applyFeedback: (messageId: string, feedback: unknown) => void;
|
|
1079
|
-
/** 按
|
|
1080
|
-
regenerateTurn: (
|
|
1081
|
-
/** R5:API 路径乐观
|
|
1100
|
+
/** 按 runId 重新生成(从 RunItem.input.text 取原文重发) */
|
|
1101
|
+
regenerateTurn: (runId: string) => Promise<void>;
|
|
1102
|
+
/** R5:API 路径乐观 run(useReportGenerate) */
|
|
1082
1103
|
addOptimisticTurn: (body: string) => void;
|
|
1083
1104
|
/** R5:更新指定 ai 段正文 */
|
|
1084
1105
|
updateAiBody: (aiId: string, body: string) => void;
|
|
1085
|
-
/** W5:定点装饰(
|
|
1086
|
-
decorate: (messageId: string, patch:
|
|
1087
|
-
|
|
1106
|
+
/** W5:定点装饰(feedback 盖章) */
|
|
1107
|
+
decorate: (messageId: string, patch: {
|
|
1108
|
+
feedback?: {
|
|
1109
|
+
rating: number;
|
|
1110
|
+
};
|
|
1111
|
+
}) => void;
|
|
1112
|
+
/** W5:API 路径乐观收尾(清 pending 占位) */
|
|
1088
1113
|
finalizeTurns: () => void;
|
|
1089
1114
|
fetchThreads: (reset?: boolean, keyword?: string) => Promise<void>;
|
|
1090
1115
|
deleteThread: (threadId: string) => Promise<boolean>;
|
|
@@ -1094,7 +1119,7 @@ interface ChatCore {
|
|
|
1094
1119
|
runningNotConnectedThreadIds: Ref<Set<string>>;
|
|
1095
1120
|
recoverRunningThreads: () => Promise<void>;
|
|
1096
1121
|
activeInterrupt: Ref<Interrupt | undefined>;
|
|
1097
|
-
/** 当前待响应 interrupt 本体(InterruptBar
|
|
1122
|
+
/** 当前待响应 interrupt 本体(InterruptBar 审核卡数据源) */
|
|
1098
1123
|
interrupt: Ref<Interrupt | undefined>;
|
|
1099
1124
|
hasPendingInterrupt: Ref<boolean>;
|
|
1100
1125
|
inputDisabled: Ref<boolean>;
|
|
@@ -1110,4 +1135,4 @@ interface ChatCore {
|
|
|
1110
1135
|
}
|
|
1111
1136
|
declare function createChatCore(options: ChatCoreOptions): ChatCore;
|
|
1112
1137
|
|
|
1113
|
-
export { type InterruptReviewBlock as $, type
|
|
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 };
|