@huyooo/ai-chat-bridge-electron 0.1.4 → 0.1.8

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.
@@ -18,13 +18,15 @@ interface SendMessageParams {
18
18
  };
19
19
  }
20
20
  /** 模型配置 */
21
- interface ModelConfig$1 {
22
- provider: string;
23
- model: string;
21
+ interface ModelOption$1 {
22
+ modelId: string;
24
23
  displayName: string;
25
- supportsTools: boolean;
26
- supportsWebSearch: boolean;
27
- supportedThinkingModes: string[];
24
+ /** 分组名称(由后端决定,前端只负责渲染,必填) */
25
+ group: string;
26
+ /** 是否来自 OpenRouter(保留用于兼容,后续可能移除) */
27
+ isOpenRouter?: boolean;
28
+ /** 提供商名称(保留用于兼容,后续可能移除) */
29
+ provider?: string;
28
30
  }
29
31
  /** 会话记录 */
30
32
  interface SessionRecord$1 {
@@ -34,6 +36,10 @@ interface SessionRecord$1 {
34
36
  title: string;
35
37
  model: string;
36
38
  mode: 'agent' | 'plan' | 'ask';
39
+ webSearchEnabled: boolean;
40
+ thinkingEnabled: boolean;
41
+ /** 是否在 tab 栏隐藏(关闭但不删除) */
42
+ hidden: boolean;
37
43
  createdAt: Date;
38
44
  updatedAt: Date;
39
45
  }
@@ -43,9 +49,16 @@ interface MessageRecord$1 {
43
49
  sessionId: string;
44
50
  role: 'user' | 'assistant';
45
51
  content: string;
46
- thinking?: string | null;
47
- toolCalls?: string | null;
48
- searchResults?: string | null;
52
+ /** 生成此消息时使用的模型 */
53
+ model?: string | null;
54
+ /** 生成此消息时使用的模式 (ask/agent) */
55
+ mode?: string | null;
56
+ /** 生成此消息时是否启用 web 搜索 */
57
+ webSearchEnabled?: boolean | null;
58
+ /** 生成此消息时是否启用深度思考 */
59
+ thinkingEnabled?: boolean | null;
60
+ /** 执行步骤列表 JSON */
61
+ steps?: string | null;
49
62
  operationIds?: string | null;
50
63
  timestamp: Date;
51
64
  }
@@ -69,19 +82,24 @@ interface TrashRecord$1 {
69
82
  deletedAt: Date;
70
83
  autoDeleteAt: Date;
71
84
  }
85
+ /** 文件信息 */
86
+ interface FileInfo$1 {
87
+ name: string;
88
+ path: string;
89
+ isDirectory: boolean;
90
+ size: number;
91
+ modifiedAt: Date;
92
+ extension: string;
93
+ }
72
94
  interface AiChatBridge {
73
95
  /** 获取可用模型 */
74
- getModels(): Promise<ModelConfig$1[]>;
96
+ getModels(): Promise<ModelOption$1[]>;
75
97
  /** 发送消息 */
76
98
  send(params: SendMessageParams): Promise<void>;
77
99
  /** 取消当前请求 */
78
100
  cancel(): Promise<void>;
79
- /** 清空 Agent 内存历史 */
80
- clearAgentHistory(): Promise<void>;
81
- /** 获取 Agent 内存历史 */
82
- getAgentHistory(): Promise<unknown[]>;
83
- /** 设置工作目录 */
84
- setWorkingDir(dir: string): Promise<void>;
101
+ /** 设置当前工作目录 */
102
+ setCwd(dir: string): Promise<void>;
85
103
  /** 获取配置 */
86
104
  getConfig(): Promise<unknown>;
87
105
  /** 监听进度事件 */
@@ -95,12 +113,18 @@ interface AiChatBridge {
95
113
  title?: string;
96
114
  model?: string;
97
115
  mode?: string;
116
+ webSearchEnabled?: boolean;
117
+ thinkingEnabled?: boolean;
118
+ hidden?: boolean;
98
119
  }): Promise<SessionRecord$1>;
99
120
  /** 更新会话 */
100
121
  updateSession(id: string, data: {
101
122
  title?: string;
102
123
  model?: string;
103
124
  mode?: string;
125
+ webSearchEnabled?: boolean;
126
+ thinkingEnabled?: boolean;
127
+ hidden?: boolean;
104
128
  }): Promise<SessionRecord$1 | null>;
105
129
  /** 删除会话 */
106
130
  deleteSession(id: string): Promise<{
@@ -110,14 +134,31 @@ interface AiChatBridge {
110
134
  getMessages(sessionId: string): Promise<MessageRecord$1[]>;
111
135
  /** 保存消息 */
112
136
  saveMessage(params: {
137
+ /** 消息 ID(可选,如果不传则自动生成) */
138
+ id?: string;
113
139
  sessionId: string;
114
140
  role: 'user' | 'assistant';
115
141
  content: string;
116
- thinking?: string;
117
- toolCalls?: string;
118
- searchResults?: string;
142
+ /** 生成此消息时使用的模型 */
143
+ model?: string;
144
+ /** 生成此消息时使用的模式 (ask/agent) */
145
+ mode?: string;
146
+ /** 生成此消息时是否启用 web 搜索 */
147
+ webSearchEnabled?: boolean;
148
+ /** 生成此消息时是否启用深度思考 */
149
+ thinkingEnabled?: boolean;
150
+ /** 执行步骤列表 JSON */
151
+ steps?: string;
119
152
  operationIds?: string;
120
153
  }): Promise<MessageRecord$1>;
154
+ /** 更新消息(增量保存) */
155
+ updateMessage(params: {
156
+ id: string;
157
+ content?: string;
158
+ steps?: string;
159
+ }): Promise<{
160
+ success: boolean;
161
+ }>;
121
162
  /** 删除指定时间之后的消息(用于分叉) */
122
163
  deleteMessagesAfter(sessionId: string, timestamp: number): Promise<{
123
164
  success: boolean;
@@ -128,6 +169,98 @@ interface AiChatBridge {
128
169
  getTrashItems(): Promise<TrashRecord$1[]>;
129
170
  /** 恢复回收站项目 */
130
171
  restoreFromTrash(id: string): Promise<TrashRecord$1 | undefined>;
172
+ /** 在系统默认浏览器中打开链接 */
173
+ openExternal(url: string): Promise<void>;
174
+ /** 列出目录内容 */
175
+ listDir(dirPath: string): Promise<FileInfo$1[]>;
176
+ /** 检查路径是否存在 */
177
+ exists(filePath: string): Promise<boolean>;
178
+ /** 获取文件信息 */
179
+ stat(filePath: string): Promise<FileInfo$1 | null>;
180
+ /** 读取文件内容(文本) */
181
+ readFile(filePath: string): Promise<string | null>;
182
+ /** 读取文件为 base64 */
183
+ readFileBase64(filePath: string): Promise<string | null>;
184
+ /** 获取用户主目录 */
185
+ homeDir(): Promise<string>;
186
+ /** 解析路径(处理 ~) */
187
+ resolvePath(inputPath: string): Promise<string>;
188
+ /** 获取父目录 */
189
+ parentDir(dirPath: string): Promise<string>;
190
+ /** 监听目录变化 */
191
+ watchDir(dirPath: string): Promise<boolean>;
192
+ /** 停止监听目录 */
193
+ unwatchDir(dirPath: string): Promise<void>;
194
+ /** 监听目录变化事件 */
195
+ onDirChange(callback: (data: {
196
+ dirPath: string;
197
+ eventType: string;
198
+ filename: string | null;
199
+ }) => void): () => void;
200
+ /** 获取用户设置 */
201
+ getSetting(key: string): Promise<string | null>;
202
+ /** 设置用户设置 */
203
+ setSetting(key: string, value: string): Promise<{
204
+ success: boolean;
205
+ }>;
206
+ /** 获取所有用户设置 */
207
+ getAllSettings(): Promise<Record<string, string>>;
208
+ /** 删除用户设置 */
209
+ deleteSetting(key: string): Promise<{
210
+ success: boolean;
211
+ }>;
212
+ /** 获取索引统计信息 */
213
+ getIndexStats(): Promise<{
214
+ totalDocuments: number;
215
+ indexSize: number;
216
+ lastUpdated: string | null;
217
+ }>;
218
+ /** 检查索引状态 */
219
+ getIndexStatus(): Promise<{
220
+ isIndexing: boolean;
221
+ lastProgress: {
222
+ indexed: number;
223
+ total: number;
224
+ currentFile?: string;
225
+ stage: string;
226
+ } | null;
227
+ }>;
228
+ /** 同步索引(重新索引工作空间) */
229
+ syncIndex(): Promise<{
230
+ success: boolean;
231
+ }>;
232
+ /** 取消索引 */
233
+ cancelIndex(): Promise<{
234
+ success: boolean;
235
+ }>;
236
+ /** 删除索引 */
237
+ deleteIndex(): Promise<{
238
+ success: boolean;
239
+ }>;
240
+ /** 注册索引进度监听器 */
241
+ registerIndexListener(): Promise<{
242
+ success: boolean;
243
+ }>;
244
+ /** 注销索引进度监听器 */
245
+ unregisterIndexListener(): Promise<{
246
+ success: boolean;
247
+ }>;
248
+ /** 监听索引进度 */
249
+ onIndexProgress(callback: (progress: {
250
+ indexed: number;
251
+ total: number;
252
+ currentFile?: string;
253
+ stage: string;
254
+ error?: string;
255
+ }) => void): () => void;
256
+ /** 监听工具批准请求(manual 模式) */
257
+ onToolApprovalRequest(callback: (request: {
258
+ id: string;
259
+ name: string;
260
+ args: Record<string, unknown>;
261
+ }) => void): () => void;
262
+ /** 响应工具批准请求 */
263
+ respondToolApproval(id: string, approved: boolean): Promise<void>;
131
264
  }
132
265
 
133
266
  /**
@@ -136,29 +269,54 @@ interface AiChatBridge {
136
269
  * 在渲染进程中使用,创建 ChatAdapter
137
270
  */
138
271
 
139
- type ChatProgressType = 'thinking' | 'search_start' | 'search_result' | 'tool_call' | 'tool_result' | 'text' | 'text_delta' | 'image' | 'video' | 'done' | 'error';
140
- interface ChatProgress {
141
- type: ChatProgressType;
272
+ type ChatEventType = 'thinking_start' | 'thinking_delta' | 'thinking_end' | 'search_start' | 'search_result' | 'search_end' | 'tool_approval_request' | 'tool_call_start' | 'tool_call_result' | 'text_delta' | 'image' | 'video' | 'stream_start' | 'done' | 'error' | 'abort' | 'step_start' | 'step_end';
273
+ interface ChatEvent {
274
+ type: ChatEventType;
142
275
  data: unknown;
143
276
  }
144
277
  type ChatMode = 'agent' | 'plan' | 'ask';
145
- type ModelProvider = 'doubao' | 'deepseek' | 'openrouter' | 'qwen' | 'gemini' | 'ark' | 'anthropic' | 'openai';
278
+ type ProviderType = 'ark' | 'qwen' | 'gemini' | 'openrouter';
146
279
  type ThinkingMode = 'enabled' | 'disabled';
280
+ type AutoRunMode = 'run-everything' | 'manual';
281
+ interface AutoRunConfig {
282
+ /**
283
+ * 自动运行模式
284
+ * - 'run-everything': 运行所有内容(自动执行)
285
+ * - 'manual': 手动批准(每次执行前询问)
286
+ */
287
+ mode?: AutoRunMode;
288
+ }
289
+ /** 聊天历史消息(无状态架构) */
290
+ interface ChatHistoryMessage {
291
+ role: 'user' | 'assistant' | 'system' | 'tool';
292
+ content: string;
293
+ }
147
294
  interface ChatOptions {
148
295
  mode?: ChatMode;
149
296
  model?: string;
150
- provider?: ModelProvider;
297
+ provider?: ProviderType;
151
298
  enableWebSearch?: boolean;
299
+ /** 深度思考开关(每个 provider 内部使用最优参数) */
152
300
  thinkingMode?: ThinkingMode;
153
- thinkingBudget?: number;
301
+ /** 自动运行配置 */
302
+ autoRunConfig?: AutoRunConfig;
303
+ /** 对话历史(无状态架构,历史从前端传入) */
304
+ history?: ChatHistoryMessage[];
154
305
  }
155
- interface ModelConfig {
156
- provider: ModelProvider;
157
- model: string;
306
+ /**
307
+ * 简化的模型配置
308
+ */
309
+ interface ModelOption {
310
+ /** 模型 ID(发送给 API) */
311
+ modelId: string;
312
+ /** 显示名称 */
158
313
  displayName: string;
159
- supportsTools: boolean;
160
- supportsWebSearch: boolean;
161
- supportedThinkingModes: ThinkingMode[];
314
+ /** 分组名称(由后端决定,前端只负责渲染,必填) */
315
+ group: string;
316
+ /** 是否来自 OpenRouter(保留用于兼容,后续可能移除) */
317
+ isOpenRouter?: boolean;
318
+ /** 提供商名称(保留用于兼容,后续可能移除) */
319
+ provider?: string;
162
320
  }
163
321
  interface SessionRecord {
164
322
  id: string;
@@ -167,6 +325,10 @@ interface SessionRecord {
167
325
  title: string;
168
326
  model: string;
169
327
  mode: ChatMode;
328
+ webSearchEnabled: boolean;
329
+ thinkingEnabled: boolean;
330
+ /** 是否在 tab 栏隐藏(关闭但不删除) */
331
+ hidden: boolean;
170
332
  createdAt: Date;
171
333
  updatedAt: Date;
172
334
  }
@@ -175,9 +337,16 @@ interface MessageRecord {
175
337
  sessionId: string;
176
338
  role: 'user' | 'assistant';
177
339
  content: string;
178
- thinking?: string | null;
179
- toolCalls?: string | null;
180
- searchResults?: string | null;
340
+ /** 生成此消息时使用的模型 */
341
+ model?: string | null;
342
+ /** 生成此消息时使用的模式 (ask/agent) */
343
+ mode?: string | null;
344
+ /** 生成此消息时是否启用 web 搜索 */
345
+ webSearchEnabled?: boolean | null;
346
+ /** 生成此消息时是否启用深度思考 */
347
+ thinkingEnabled?: boolean | null;
348
+ /** 执行步骤列表 JSON */
349
+ steps?: string | null;
181
350
  operationIds?: string | null;
182
351
  timestamp: Date;
183
352
  }
@@ -199,19 +368,23 @@ interface TrashRecord {
199
368
  deletedAt: Date;
200
369
  autoDeleteAt: Date;
201
370
  }
371
+ interface FileInfo {
372
+ name: string;
373
+ path: string;
374
+ isDirectory: boolean;
375
+ size: number;
376
+ modifiedAt: Date;
377
+ extension: string;
378
+ }
202
379
  interface ChatAdapter {
203
380
  /** 获取可用模型 */
204
- getModels(): Promise<ModelConfig[]>;
381
+ getModels(): Promise<ModelOption[]>;
205
382
  /** 发送消息,返回异步迭代器 */
206
- sendMessage(message: string, options?: ChatOptions, images?: string[]): AsyncIterable<ChatProgress>;
383
+ sendMessage(message: string, options?: ChatOptions, images?: string[], sessionId?: string): AsyncIterable<ChatEvent>;
207
384
  /** 取消当前请求 */
208
385
  cancel(): void;
209
- /** 清空 Agent 内存历史 */
210
- clearAgentHistory?(): void;
211
- /** 获取 Agent 内存历史 */
212
- getAgentHistory?(): Promise<unknown[]>;
213
- /** 设置工作目录 */
214
- setWorkingDir?(dir: string): void;
386
+ /** 设置当前工作目录 */
387
+ setCwd?(dir: string): void;
215
388
  /** 获取会话列表 */
216
389
  getSessions(): Promise<SessionRecord[]>;
217
390
  /** 获取单个会话 */
@@ -221,12 +394,18 @@ interface ChatAdapter {
221
394
  title?: string;
222
395
  model?: string;
223
396
  mode?: string;
397
+ webSearchEnabled?: boolean;
398
+ thinkingEnabled?: boolean;
399
+ hidden?: boolean;
224
400
  }): Promise<SessionRecord>;
225
401
  /** 更新会话 */
226
402
  updateSession(id: string, data: {
227
403
  title?: string;
228
404
  model?: string;
229
405
  mode?: string;
406
+ webSearchEnabled?: boolean;
407
+ thinkingEnabled?: boolean;
408
+ hidden?: boolean;
230
409
  }): Promise<SessionRecord | null>;
231
410
  /** 删除会话 */
232
411
  deleteSession(id: string): Promise<void>;
@@ -234,14 +413,29 @@ interface ChatAdapter {
234
413
  getMessages(sessionId: string): Promise<MessageRecord[]>;
235
414
  /** 保存消息 */
236
415
  saveMessage(params: {
416
+ /** 消息 ID(可选,如果不传则自动生成) */
417
+ id?: string;
237
418
  sessionId: string;
238
419
  role: 'user' | 'assistant';
239
420
  content: string;
240
- thinking?: string;
241
- toolCalls?: string;
242
- searchResults?: string;
421
+ /** 生成此消息时使用的模型 */
422
+ model?: string;
423
+ /** 生成此消息时使用的模式 (ask/agent) */
424
+ mode?: string;
425
+ /** 生成此消息时是否启用 web 搜索 */
426
+ webSearchEnabled?: boolean;
427
+ /** 生成此消息时是否启用深度思考 */
428
+ thinkingEnabled?: boolean;
429
+ /** 执行步骤列表 JSON */
430
+ steps?: string;
243
431
  operationIds?: string;
244
432
  }): Promise<MessageRecord>;
433
+ /** 更新消息(增量保存) */
434
+ updateMessage(params: {
435
+ id: string;
436
+ content?: string;
437
+ steps?: string;
438
+ }): Promise<void>;
245
439
  /** 删除指定时间之后的消息(用于分叉) */
246
440
  deleteMessagesAfter(sessionId: string, timestamp: number): Promise<void>;
247
441
  /** 获取操作日志 */
@@ -250,6 +444,48 @@ interface ChatAdapter {
250
444
  getTrashItems(): Promise<TrashRecord[]>;
251
445
  /** 恢复回收站项目 */
252
446
  restoreFromTrash(id: string): Promise<TrashRecord | undefined>;
447
+ /** 列出目录内容 */
448
+ listDir?(dirPath: string): Promise<FileInfo[]>;
449
+ /** 检查路径是否存在 */
450
+ exists?(filePath: string): Promise<boolean>;
451
+ /** 获取文件信息 */
452
+ stat?(filePath: string): Promise<FileInfo | null>;
453
+ /** 读取文件内容(文本) */
454
+ readFile?(filePath: string): Promise<string | null>;
455
+ /** 读取文件为 base64 */
456
+ readFileBase64?(filePath: string): Promise<string | null>;
457
+ /** 获取用户主目录 */
458
+ homeDir?(): Promise<string>;
459
+ /** 解析路径(处理 ~) */
460
+ resolvePath?(inputPath: string): Promise<string>;
461
+ /** 获取父目录 */
462
+ parentDir?(dirPath: string): Promise<string>;
463
+ /** 监听目录变化 */
464
+ watchDir?(dirPath: string): Promise<boolean>;
465
+ /** 停止监听目录 */
466
+ unwatchDir?(dirPath: string): Promise<void>;
467
+ /** 监听目录变化事件 */
468
+ onDirChange?(callback: (data: {
469
+ dirPath: string;
470
+ eventType: string;
471
+ filename: string | null;
472
+ }) => void): () => void;
473
+ /** 获取用户设置 */
474
+ getSetting?(key: string): Promise<string | null>;
475
+ /** 设置用户设置 */
476
+ setSetting?(key: string, value: string): Promise<void>;
477
+ /** 获取所有用户设置 */
478
+ getAllSettings?(): Promise<Record<string, string>>;
479
+ /** 删除用户设置 */
480
+ deleteSetting?(key: string): Promise<void>;
481
+ /** 监听工具批准请求(manual 模式) */
482
+ onToolApprovalRequest?(callback: (request: {
483
+ id: string;
484
+ name: string;
485
+ args: Record<string, unknown>;
486
+ }) => void): () => void;
487
+ /** 响应工具批准请求 */
488
+ respondToolApproval?(id: string, approved: boolean): Promise<void>;
253
489
  }
254
490
  declare global {
255
491
  interface Window {
@@ -265,4 +501,4 @@ interface CreateAdapterOptions {
265
501
  */
266
502
  declare function createElectronAdapter(options?: CreateAdapterOptions): ChatAdapter;
267
503
 
268
- export { type ChatAdapter, type ChatMode, type ChatOptions, type ChatProgress, type ChatProgressType, type CreateAdapterOptions, type MessageRecord, type ModelConfig, type ModelProvider, type OperationRecord, type SessionRecord, type ThinkingMode, type TrashRecord, createElectronAdapter };
504
+ export { type AutoRunConfig, type AutoRunMode, type ChatAdapter, type ChatEvent, type ChatEventType, type ChatHistoryMessage, type ChatMode, type ChatOptions, type CreateAdapterOptions, type FileInfo, type MessageRecord, type ModelOption, type OperationRecord, type ProviderType, type SessionRecord, type ThinkingMode, type TrashRecord, createElectronAdapter };
@@ -12,26 +12,25 @@ function createElectronAdapter(options = {}) {
12
12
  // ============ Chat API ============
13
13
  async getModels() {
14
14
  const bridge = getBridge();
15
- const models = await bridge.getModels();
16
- return models.map((m) => ({
17
- ...m,
18
- provider: m.provider,
19
- supportedThinkingModes: m.supportedThinkingModes
20
- }));
21
- },
22
- async *sendMessage(message, options2, images) {
15
+ return bridge.getModels();
16
+ },
17
+ async *sendMessage(message, options2, images, sessionId) {
23
18
  const bridge = getBridge();
24
19
  const queue = [];
25
20
  let resolveNext = null;
26
21
  let done = false;
27
22
  const cleanup = bridge.onProgress((progress) => {
23
+ const eventWithSession = progress;
24
+ if (sessionId && eventWithSession.sessionId && eventWithSession.sessionId !== sessionId) {
25
+ return;
26
+ }
28
27
  queue.push(progress);
29
28
  resolveNext?.();
30
29
  if (progress.type === "done" || progress.type === "error") {
31
30
  done = true;
32
31
  }
33
32
  });
34
- bridge.send({ message, images, options: options2 });
33
+ bridge.send({ message, images, options: options2, sessionId });
35
34
  try {
36
35
  while (!done || queue.length > 0) {
37
36
  while (queue.length === 0 && !done) {
@@ -52,14 +51,9 @@ function createElectronAdapter(options = {}) {
52
51
  cancel() {
53
52
  getBridge().cancel();
54
53
  },
55
- clearAgentHistory() {
56
- getBridge().clearAgentHistory();
57
- },
58
- async getAgentHistory() {
59
- return getBridge().getAgentHistory();
60
- },
61
- setWorkingDir(dir) {
62
- getBridge().setWorkingDir(dir);
54
+ // 无状态架构:历史通过 ChatOptions.history 传入
55
+ setCwd(dir) {
56
+ getBridge().setCwd(dir);
63
57
  },
64
58
  // ============ Sessions API ============
65
59
  async getSessions() {
@@ -84,6 +78,9 @@ function createElectronAdapter(options = {}) {
84
78
  async saveMessage(params) {
85
79
  return getBridge().saveMessage(params);
86
80
  },
81
+ async updateMessage(params) {
82
+ await getBridge().updateMessage(params);
83
+ },
87
84
  async deleteMessagesAfter(sessionId, timestamp) {
88
85
  await getBridge().deleteMessagesAfter(sessionId, timestamp);
89
86
  },
@@ -97,6 +94,82 @@ function createElectronAdapter(options = {}) {
97
94
  },
98
95
  async restoreFromTrash(id) {
99
96
  return getBridge().restoreFromTrash(id);
97
+ },
98
+ // ============ File System API ============
99
+ async listDir(dirPath) {
100
+ return getBridge().listDir(dirPath);
101
+ },
102
+ async exists(filePath) {
103
+ return getBridge().exists(filePath);
104
+ },
105
+ async stat(filePath) {
106
+ return getBridge().stat(filePath);
107
+ },
108
+ async readFile(filePath) {
109
+ return getBridge().readFile(filePath);
110
+ },
111
+ async readFileBase64(filePath) {
112
+ return getBridge().readFileBase64(filePath);
113
+ },
114
+ async homeDir() {
115
+ return getBridge().homeDir();
116
+ },
117
+ async resolvePath(inputPath) {
118
+ return getBridge().resolvePath(inputPath);
119
+ },
120
+ async parentDir(dirPath) {
121
+ return getBridge().parentDir(dirPath);
122
+ },
123
+ async watchDir(dirPath) {
124
+ return getBridge().watchDir(dirPath);
125
+ },
126
+ async unwatchDir(dirPath) {
127
+ return getBridge().unwatchDir(dirPath);
128
+ },
129
+ onDirChange(callback) {
130
+ return getBridge().onDirChange(callback);
131
+ },
132
+ // ============ Settings API ============
133
+ async getSetting(key) {
134
+ const bridge = getBridge();
135
+ if (bridge.getSetting) {
136
+ return bridge.getSetting(key);
137
+ }
138
+ return null;
139
+ },
140
+ async setSetting(key, value) {
141
+ const bridge = getBridge();
142
+ if (bridge.setSetting) {
143
+ await bridge.setSetting(key, value);
144
+ }
145
+ },
146
+ async getAllSettings() {
147
+ const bridge = getBridge();
148
+ if (bridge.getAllSettings) {
149
+ return bridge.getAllSettings();
150
+ }
151
+ return {};
152
+ },
153
+ async deleteSetting(key) {
154
+ const bridge = getBridge();
155
+ if (bridge.deleteSetting) {
156
+ await bridge.deleteSetting(key);
157
+ }
158
+ },
159
+ // ============ Tool Approval API ============
160
+ onToolApprovalRequest(callback) {
161
+ const bridge = getBridge();
162
+ if (bridge.onToolApprovalRequest) {
163
+ return bridge.onToolApprovalRequest(callback);
164
+ }
165
+ return () => {
166
+ };
167
+ },
168
+ async respondToolApproval(id, approved) {
169
+ const bridge = getBridge();
170
+ if (bridge.respondToolApproval) {
171
+ return bridge.respondToolApproval(id, approved);
172
+ }
100
173
  }
101
174
  };
102
175
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@huyooo/ai-chat-bridge-electron",
3
- "version": "0.1.4",
3
+ "version": "0.1.8",
4
4
  "description": "AI Chat Electron Bridge - IPC integration for Electron apps",
5
5
  "type": "module",
6
6
  "main": "./dist/main/index.cjs",
@@ -9,22 +9,26 @@
9
9
  "exports": {
10
10
  "./main": {
11
11
  "types": "./dist/main/index.d.ts",
12
+ "development": "./src/main/index.ts",
12
13
  "import": "./dist/main/index.js",
13
14
  "require": "./dist/main/index.cjs"
14
15
  },
15
16
  "./preload": {
16
17
  "types": "./dist/preload/index.d.ts",
18
+ "development": "./src/preload/index.ts",
17
19
  "import": "./dist/preload/index.js",
18
20
  "require": "./dist/preload/index.cjs"
19
21
  },
20
22
  "./renderer": {
21
23
  "types": "./dist/renderer/index.d.ts",
24
+ "development": "./src/renderer/index.ts",
22
25
  "import": "./dist/renderer/index.js",
23
26
  "require": "./dist/renderer/index.cjs"
24
27
  }
25
28
  },
26
29
  "files": [
27
- "dist"
30
+ "dist",
31
+ "src"
28
32
  ],
29
33
  "scripts": {
30
34
  "build": "tsup",
@@ -33,8 +37,9 @@
33
37
  "clean": "rm -rf dist"
34
38
  },
35
39
  "dependencies": {
36
- "@huyooo/ai-chat-core": "^0.1.4",
37
- "@huyooo/ai-chat-storage": "^0.1.4"
40
+ "@huyooo/ai-chat-core": "^0.1.8",
41
+ "@huyooo/ai-chat-storage": "^0.1.8",
42
+ "@huyooo/ai-search": "*"
38
43
  },
39
44
  "peerDependencies": {
40
45
  "electron": ">=20.0.0"