@somecat/ai-assist-sdk 1.2.6 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai-assist-sdk.css +1 -1
- package/dist/chunks/index-BZPlXfol.mjs +351 -0
- package/dist/chunks/{index-DElfgKrt.mjs → index-Da2hiup1.mjs} +39 -19
- package/dist/core/types/index.d.ts +92 -1
- package/dist/core/utils/index.d.ts +16 -0
- package/dist/core/utils/streamPlayback.d.ts +56 -0
- package/dist/index.mjs +1 -1
- package/dist/react/components/answer/components/StepBlock.d.ts +12 -0
- package/dist/react/components/answer/components/StreamingMarkdown.d.ts +5 -13
- package/dist/react/components/answer/components/ThinkingBlock.d.ts +8 -10
- package/dist/react/components/answer/hooks/useMessagePlayback.d.ts +25 -0
- package/dist/react/components/answer/hooks/useSSEStream.d.ts +10 -1
- package/dist/react/index.mjs +12567 -12393
- package/dist/vue/components/answer/composables/useMessagePlayback.d.ts +18 -0
- package/dist/vue/components/answer/composables/useSSEStream.d.ts +10 -1
- package/dist/vue/index.d.ts +1 -1
- package/dist/vue/index.mjs +1606 -1435
- package/package.json +113 -112
- package/dist/chunks/index-BtUB4IU0.mjs +0 -196
- package/dist/vue/components/answer/composables/useTypewriter.d.ts +0 -23
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ChatMessage } from '../../../../core/types';
|
|
2
|
+
/**
|
|
3
|
+
* 单条 AI 消息的流式揭示播放(Vue 版,与 React useMessagePlayback 对等)。
|
|
4
|
+
*
|
|
5
|
+
* 后端为批量转发(多事件同一帧到达,甚至终态与内容同帧),不能依赖 status 触发动画,
|
|
6
|
+
* 而是以 msg.streamed 标记该消息需要按序逐字揭示;揭示进度只增不减,按 segments
|
|
7
|
+
* 原始顺序推进,从而保证 深度思考 → 流程步骤 → 回答 严格依次流出。
|
|
8
|
+
*
|
|
9
|
+
* 终止态(stop/error)直接补齐;历史 / 降级消息不带 streamed 标记 → 立即全量展示。
|
|
10
|
+
*/
|
|
11
|
+
export declare function useMessagePlayback(getMsg: () => ChatMessage, onGrow?: () => void): {
|
|
12
|
+
reveal: import('../../../../../vue/dist/vue.esm-bundler.js').Ref<number, number>;
|
|
13
|
+
segmentContents: import('../../../../../vue/dist/vue.esm-bundler.js').ComputedRef<string[]>;
|
|
14
|
+
frontier: import('../../../../../vue/dist/vue.esm-bundler.js').ComputedRef<number>;
|
|
15
|
+
revealDone: import('../../../../../vue/dist/vue.esm-bundler.js').ComputedRef<boolean>;
|
|
16
|
+
isSegRevealed: (segIdx: number) => boolean;
|
|
17
|
+
stopLoop: () => void;
|
|
18
|
+
};
|
|
@@ -12,10 +12,19 @@ interface UseSSEStreamParams {
|
|
|
12
12
|
/**
|
|
13
13
|
* SSE 流式请求:处理 think_message / agent_thought / message 等事件的分段拼接与状态流转。
|
|
14
14
|
*
|
|
15
|
+
* 同时兼容两套智能体协议:
|
|
16
|
+
* - 对话型:think_message_output_start / think_message / think_message_output_end(深度思考)、
|
|
17
|
+
* agent_thought / agent_thought_end(工具调用)、message_output_start / message / message_end(回答)
|
|
18
|
+
* - 对话流型:flow_start / flow_end 包裹,思考与流程步骤统一走
|
|
19
|
+
* tool_message_output_start / tool_message / tool_message_output_end(带 message_title、
|
|
20
|
+
* message_config.reasoning,同一 id 分帧下发需累积)→ reasoning 归入深度思考,其余归入流程步骤(step)
|
|
21
|
+
*
|
|
15
22
|
* 内部管理:
|
|
16
|
-
* - segmentsMap: 每条 AI 消息的分段数组(支持 thinking/agent_thought/answer 穿插)
|
|
23
|
+
* - segmentsMap: 每条 AI 消息的分段数组(支持 thinking/agent_thought/step/answer 穿插)
|
|
17
24
|
* - currentSegType: 当前正在写入的 segment 类型
|
|
18
25
|
* - thinkingStartTimes / agentThoughtStartTimes: 用于计算耗时
|
|
26
|
+
* - flowMode: 是否已进入对话流型协议(未进入则完全走旧协议,零回归)
|
|
27
|
+
* - toolSegIndexes / toolStartTimes: 对话流型下按 message id 定位分段与开始时间
|
|
19
28
|
* - issTop: 是否已手动停止
|
|
20
29
|
*
|
|
21
30
|
* 对外暴露 doStreamRequest 与 issTop(toggleStop 需读写)。
|
package/dist/vue/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { App as VueApp } from '../../vue/dist/vue.esm-bundler.js';
|
|
|
2
2
|
import { default as AiAssist } from './components/AiAssist.vue';
|
|
3
3
|
import { default as VoiceInput } from './components/VoiceInput.vue';
|
|
4
4
|
import { AiAssistConfig } from '../core/types';
|
|
5
|
-
export type { AiAssistConfig, AiAssistTheme } from '../core/types';
|
|
5
|
+
export type { AiAssistConfig, AiAssistTheme, AiAssistPanelPhase, AiAssistPanelActiveInfo, AiAssistMessageSendInfo, } from '../core/types';
|
|
6
6
|
export declare const initAiAssist: (config: AiAssistConfig) => void;
|
|
7
7
|
export declare const mountAiAssist: (container?: HTMLElement) => void;
|
|
8
8
|
export declare const unmountAiAssist: () => void;
|