@somecat/ai-assist-sdk 1.2.6 → 1.3.0

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.
@@ -20,6 +20,16 @@ export interface AiAssistConfig {
20
20
  panelDraggable?: boolean;
21
21
  /** 面板停靠(嵌入宿主布局)配置 */
22
22
  dock?: AiAssistDockConfig;
23
+ /** 面板活跃心跳间隔(毫秒),默认 30000;用于「不丢尾段」地上报活跃时长增量 */
24
+ activityInterval?: number;
25
+ /**
26
+ * 面板活跃回调:展开 / 收起 / 心跳 / 标签隐藏补报。
27
+ *
28
+ * 各相位 durationMs 互不重叠,累加即「面板累计活跃时长」(毫秒);仅统计面板展开且标签可见的时间。
29
+ */
30
+ onPanelActive?: (info: AiAssistPanelActiveInfo) => void;
31
+ /** 用户发送消息回调(点发送 / 回车 / 语音;「重新生成」不计) */
32
+ onMessageSend?: (info: AiAssistMessageSendInfo) => void;
23
33
  apis: {
24
34
  chatQueryApi: string;
25
35
  chatQueryStreamApi?: string;
@@ -56,6 +66,33 @@ export interface AiAssistDockConfig {
56
66
  */
57
67
  onDockWidthChange?: (width: number) => void;
58
68
  }
69
+ /** 面板活跃回调相位 */
70
+ export type AiAssistPanelPhase = 'open' | 'close' | 'heartbeat' | 'hidden';
71
+ /** 面板活跃回调信息(各相位 durationMs 互不重叠,累加即累计活跃时长) */
72
+ export interface AiAssistPanelActiveInfo {
73
+ /**
74
+ * - open:面板展开(悬浮球展开 / 停靠态展开),durationMs 恒为 0;
75
+ * - heartbeat:保持展开且标签可见时按 activityInterval 触发一次;
76
+ * - hidden:标签页隐藏(visibilitychange)时立即补报,隐藏期间不计时;
77
+ * - close:面板收起,durationMs 为剩余未上报的活跃增量。
78
+ */
79
+ phase: AiAssistPanelPhase;
80
+ /** 当前是否处于停靠(嵌入)态 */
81
+ docked: boolean;
82
+ /** 本次需上报的活跃增量(毫秒),phase='open' 时恒为 0 */
83
+ durationMs: number;
84
+ /** 本次展开累计活跃时长(含本次,毫秒) */
85
+ totalMs: number;
86
+ }
87
+ /** 消息发送回调信息 */
88
+ export interface AiAssistMessageSendInfo {
89
+ /** 用户输入原文(隐私敏感:仅供宿主本地判断,请勿直接上报正文) */
90
+ text: string;
91
+ /** 是否为当前会话首条消息 */
92
+ isFirstMessage: boolean;
93
+ /** 会话 ID(懒创建后必有值) */
94
+ conversationId: string;
95
+ }
59
96
  export type ViewStatus = 'answer' | 'info';
60
97
  export type MessageStatus = 'thinking' | 'rethinking' | 'answering' | 'paused' | 'completed' | 'stop' | 'error';
61
98
  export interface MessageSegment {