@ibiz-template-plugin/ai-chat 0.0.108 → 0.0.109

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.
@@ -4,6 +4,10 @@ import { AiChatController, AiTopicController } from '../../controller';
4
4
  import { IChatToolbarItem, IExtensionOptions } from '../../interface';
5
5
 
6
6
  export interface FlatChatContainerProps {
7
+ /**
8
+ * 组件外层容器id
9
+ */
10
+ compWrapperId: string;
7
11
  /**
8
12
  * 呈现模式
9
13
  */
@@ -68,8 +72,29 @@ export declare class FlatChatContainer extends Component<FlatChatContainerProps>
68
72
  messagesRef: RefObject<HTMLDivElement>;
69
73
  toolbarsRef: RefObject<HTMLDivElement>;
70
74
  topicRef: RefObject<HTMLDivElement>;
75
+ /**
76
+ * 容器根节点(用于测量整体宽度)
77
+ */
78
+ containerRef: RefObject<HTMLDivElement>;
79
+ /**
80
+ * 输入区容器(用于高度分隔条)
81
+ */
82
+ footerRef: RefObject<HTMLDivElement>;
83
+ /**
84
+ * 侧栏宽度拖动起始值(px)
85
+ */
86
+ sidebarDragStartWidth: number;
87
+ /**
88
+ * 输入区高度拖动起始值(px)
89
+ */
90
+ inputDragStartHeight: number;
91
+ /**
92
+ * 输入区高度拖动时其父容器高度(px)
93
+ */
94
+ inputDragContainerHeight: number;
71
95
  state: {
72
96
  mountedSlots: Record<string, boolean>;
97
+ inputHeight: number | null;
73
98
  };
74
99
  /**
75
100
  * @description 添加扩展插槽
@@ -109,12 +134,51 @@ export declare class FlatChatContainer extends Component<FlatChatContainerProps>
109
134
  */
110
135
  renderLoading(): JSX.Element;
111
136
  /**
112
- * 计算底部工具栏的定位样式
113
- * 默认 162px;存在待发送素材时 +60px;追问引导开启时再 +32px
114
- *
137
+ * 绘制侧栏宽度分隔条(仅展开态)
138
+ */
139
+ renderSidebarSplitter(): JSX.Element | null;
140
+ /**
141
+ * 右侧聊天区宽度
142
+ */
143
+ getRightWidth(): string;
144
+ /**
145
+ * 侧栏宽度拖动开始
146
+ */
147
+ handleSidebarResizeStart: () => void;
148
+ /**
149
+ * 侧栏宽度拖动中
150
+ */
151
+ handleSidebarResizeMove: (delta: number) => void;
152
+ /**
153
+ * 侧栏宽度拖动结束
154
+ */
155
+ handleSidebarResizeEnd: () => void;
156
+ /**
157
+ * @description 获取输入区高度缓存key
158
+ * @returns {string}
115
159
  * @memberof FlatChatContainer
116
160
  */
117
- getFooterToolbarStyle(): JSX.CSSProperties;
161
+ getInputHeightCacheKey(): string;
162
+ /**
163
+ * 读取输入区高度缓存
164
+ */
165
+ readInputHeight(): number | null;
166
+ /**
167
+ * 输入区样式(固定高度模式下生效)
168
+ */
169
+ getFooterStyle(): JSX.CSSProperties;
170
+ /**
171
+ * 输入区高度拖动开始
172
+ */
173
+ handleInputHeightDragStart: () => void;
174
+ /**
175
+ * 输入区高度拖动中
176
+ */
177
+ handleInputHeightDragMove: (delta: number) => void;
178
+ /**
179
+ * 输入区高度拖动结束
180
+ */
181
+ handleInputHeightDragEnd: () => void;
118
182
  /**
119
183
  * @description 绘制内容
120
184
  * @memberof FlatChatContainer
@@ -7,6 +7,14 @@ export declare enum AIChatConst {
7
7
  * 最小化样式缓存
8
8
  */
9
9
  MINIMIZE_STYLY_CHCHE = "ai-chat-minimize-style-cache",
10
+ /**
11
+ * 话题侧边栏宽度缓存(展开态)
12
+ */
13
+ TOPIC_SIDEBAR_WIDTH = "ai-chat-topic-sidebar-width",
14
+ /**
15
+ * 聊天输入区高度缓存
16
+ */
17
+ INPUT_HEIGHT = "ai-chat-input-height",
10
18
  /**
11
19
  * 数据库名称
12
20
  */
@@ -367,13 +367,12 @@ export declare class AiChatController {
367
367
  */
368
368
  attachMessageAgentID(data: IChatMessage): void;
369
369
  /**
370
- * 新增聊天记录
371
- *
372
- * @author chitanda
373
- * @date 2023-10-09 15:10:15
374
- * @param {IMessage} data
370
+ * @description 新增聊天记录
371
+ * @param {IChatMessage} data
372
+ * @param {boolean} [ignoreChange=false] 是否忽略变更
373
+ * @memberof AiChatController
375
374
  */
376
- addMessage(data: IChatMessage): void;
375
+ addMessage(data: IChatMessage, ignoreChange?: boolean): ChatMessage;
377
376
  /**
378
377
  * 更新消息完成状态
379
378
  *
@@ -661,7 +660,7 @@ export declare class AiChatController {
661
660
  * @param {ChatMessage} msg
662
661
  * @memberof AiChatController
663
662
  */
664
- onMessageChange(msg: ChatMessage): void;
663
+ onMessageChange(actionName: 'createmsg' | 'deletemsg' | 'updatemsg' | 'historymsg', msg: ChatMessage | ChatMessage[]): void;
665
664
  /**
666
665
  * 销毁
667
666
  *
@@ -84,6 +84,12 @@ export declare class AiTopicController {
84
84
  * AI话题存储模式,DEFAULT:默认值,会话数据基于config和远程session配合存储; REMOTESESSION:远程,会话仅远程session存储
85
85
  */
86
86
  storageMode: 'DEFAULT' | 'REMOTESESSION';
87
+ /**
88
+ * @description 组件外层容器id
89
+ * @type {string}
90
+ * @memberof AiTopicController
91
+ */
92
+ compWrapperId: string;
87
93
  /**
88
94
  * Creates an instance of AiTopicController.
89
95
  * @author tony001
@@ -96,6 +102,11 @@ export declare class AiTopicController {
96
102
  * @param topic 话题数据
97
103
  */
98
104
  setActivedTopic(topic: ChatTopic | undefined): void;
105
+ /**
106
+ * 注入组件外层容器id
107
+ * @param compWrapperId
108
+ */
109
+ injectCompWrapperId(compWrapperId: string): void;
99
110
  /**
100
111
  * 注入资源选项
101
112
  * @param resourceOptions
@@ -214,6 +225,21 @@ export declare class AiTopicController {
214
225
  * 计算话题侧边栏宽度
215
226
  */
216
227
  computeTopicSidebarWidth(): void;
228
+ /**
229
+ * @description 获取侧边栏宽度缓存key
230
+ * @private
231
+ * @returns {*} {string}
232
+ * @memberof AiTopicController
233
+ */
234
+ getTopicSidebarWidthCacheKey(): string;
235
+ /**
236
+ * 读取展开态侧边栏宽度缓存
237
+ */
238
+ getTopicSidebarWidthCache(): number | undefined;
239
+ /**
240
+ * 更新展开态侧边栏宽度并持久化
241
+ */
242
+ updateTopicSidebarWidth(): void;
217
243
  /**
218
244
  * 切换话题侧边栏折叠状态
219
245
  */
@@ -233,4 +259,12 @@ export declare class AiTopicController {
233
259
  * @returns
234
260
  */
235
261
  exitTempChat(): void;
262
+ /**
263
+ * @description 处理行为
264
+ * @private
265
+ * @param {string} action
266
+ * @param {ChatTopic} topic
267
+ * @memberof AiTopicController
268
+ */
269
+ private handleAction;
236
270
  }
@@ -48,6 +48,8 @@ export declare class ChatMessage implements IChatMessage {
48
48
  get realmessageid(): IChatMessage['realmessageid'];
49
49
  get metadata(): IChatMessage['metadata'];
50
50
  get agent_tag(): IChatMessage['agent_tag'];
51
+ get create_time(): IChatMessage['create_time'];
52
+ set create_time(value: string);
51
53
  constructor(msg: IChatMessage);
52
54
  /**
53
55
  * 更新消息
@@ -60,6 +60,12 @@ export interface IMinimizeOptions {
60
60
  * @interface IChatContainerOptions
61
61
  */
62
62
  export interface IChatContainerOptions {
63
+ /**
64
+ * @description 组件外层容器id,用于隔离不同位置的组件界面状态
65
+ * @type {string}
66
+ * @memberof IChatContainerOptions
67
+ */
68
+ compWrapperId?: string;
63
69
  /**
64
70
  * 平铺模式挂载容器,传入时使用平铺模式
65
71
  *
@@ -189,4 +189,10 @@ export interface IChatMessage {
189
189
  * @memberof IChatMessage
190
190
  */
191
191
  usage?: IChatMessageUsage;
192
+ /**
193
+ * @description 创建时间
194
+ * @type {string}
195
+ * @memberof IChatMessage
196
+ */
197
+ create_time?: string;
192
198
  }
@@ -337,11 +337,11 @@ export interface IChatOptions extends IChat {
337
337
  *
338
338
  * @author chitanda
339
339
  * @date 2023-10-13 18:10:56
340
- * @param {string} action 操作的行为标识 backfill:回填 question:提问 deletemsg:删除消息 refreshmsg:刷新消息 send: 发送消息 message: 聊天消息
340
+ * @param {string} action 操作的行为标识 backfill:回填 question:提问 deletemsg:删除消息 refreshmsg:刷新消息 send: 发送消息 createmsg: 新建消息,updatemsg:更新消息,historymsg: 历史消息
341
341
  * @param {T} [params] 传递的参数
342
342
  * @return {*} {Promise<boolean>} 等待操作,用于显示 loading 并获取最终成功与否
343
343
  */
344
- action?<T = unknown>(action: 'backfill' | 'question' | 'deletemsg' | 'refreshmsg' | 'copymsg' | 'send' | 'message', params?: T): Promise<boolean>;
344
+ action?<T = unknown>(action: 'backfill' | 'question' | 'deletemsg' | 'refreshmsg' | 'copymsg' | 'send' | 'createmsg' | 'updatemsg' | 'historymsg', params?: T): Promise<boolean>;
345
345
  /**
346
346
  * 全屏操作
347
347
  *
@@ -77,4 +77,8 @@ export interface IRemoteMessage {
77
77
  * 当前智能体标记
78
78
  */
79
79
  agent_tag: string | undefined;
80
+ /**
81
+ * 创建时间
82
+ */
83
+ create_time: string | undefined;
80
84
  }
@@ -141,18 +141,13 @@ export interface ITopicOptions extends ITopic {
141
141
  */
142
142
  beforeDelete?(context: object, params: object, data: ITopic, event?: MouseEvent, isBatch?: boolean): Promise<boolean>;
143
143
  /**
144
- * 话题行为
145
- *
146
- * @author tony001
147
- * @date 2025-02-24 16:02:04
148
- * @param { string} action
149
- * @param {object} context
144
+ * @description 话题行为
145
+ * @param {string} action
150
146
  * @param {object} params
151
- * @param {ITopic} data
152
- * @param {MouseEvent} event
153
- * @return {*} {Promise<boolean>}
147
+ * @returns {*} {Promise<boolean>}
148
+ * @memberof ITopicOptions
154
149
  */
155
- action?(action: string, context: object, params: object, data: ITopic, event: MouseEvent): Promise<boolean>;
150
+ action?(action: string, params?: object): Promise<boolean>;
156
151
  /**
157
152
  * 存储服务构造器
158
153
  *
@@ -10,4 +10,5 @@ export { generateHashWithText } from './util/text-hash-util';
10
10
  export { ChatToolCallParser } from './util/chat-tool-call-parser';
11
11
  export { ChatStepParser } from './util/chat-step-parser';
12
12
  export { ChatUIActionParser } from './util/chat-ui-action-parser';
13
+ export { ContentProtector } from './util/content-protector';
13
14
  export { TextUtil } from './util/util';
@@ -0,0 +1,24 @@
1
+ /**
2
+ * 内容保护器
3
+ *
4
+ * 在把内容交给 Cherry 等渲染器绘制前,对特定代码片段做「仅 UI 展示用」的保护处理,
5
+ * 不修改原始数据。新增保护规则时,向 rules 数组追加即可。
6
+ */
7
+ export declare class ContentProtector {
8
+ /**
9
+ * 保护规则列表,按顺序依次应用
10
+ */
11
+ private static readonly rules;
12
+ /**
13
+ * 对外统一入口:对内容应用所有保护规则
14
+ */
15
+ static protect(content: string): string;
16
+ /**
17
+ * mermaid 节点标签保护
18
+ *
19
+ * 匹配 ```mermaid ... ``` 代码块,把未用双引号包裹的节点标签([ ] 与 { } 形状)
20
+ * 补上双引号,避免含 <br/>、/、? 等特殊字符时 Cherry 绘制失败。
21
+ * 边界标签(-->|否| 中的 |否|)不受影响。
22
+ */
23
+ private static protectMermaid;
24
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ibiz-template-plugin/ai-chat",
3
- "version": "0.0.108",
3
+ "version": "0.0.109",
4
4
  "description": "iBiz AI交互框插件",
5
5
  "type": "module",
6
6
  "main": "dist/index.es.js",