@huyooo/ai-chat-bridge-electron 0.1.8 → 0.2.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/main/index.cjs +2 -3
- package/dist/main/index.d.cts +3 -9
- package/dist/main/index.d.ts +3 -9
- package/dist/main/index.js +3 -5
- package/package.json +4 -4
- package/src/main/index.ts +7 -17
package/dist/main/index.cjs
CHANGED
|
@@ -44,11 +44,10 @@ async function createElectronBridge(options) {
|
|
|
44
44
|
const {
|
|
45
45
|
channelPrefix = "ai-chat",
|
|
46
46
|
dataDir,
|
|
47
|
-
storagePath,
|
|
48
47
|
defaultContext = {},
|
|
49
48
|
...agentConfig
|
|
50
49
|
} = options;
|
|
51
|
-
const resolvedStoragePath =
|
|
50
|
+
const resolvedStoragePath = path.join(dataDir, "db.sqlite");
|
|
52
51
|
(0, import_electron2.createSearchElectronBridge)({
|
|
53
52
|
ipcMain: import_electron.ipcMain,
|
|
54
53
|
channelPrefix
|
|
@@ -77,7 +76,7 @@ async function createElectronBridge(options) {
|
|
|
77
76
|
};
|
|
78
77
|
const storage = await (0, import_ai_chat_storage.createStorage)({
|
|
79
78
|
type: "sqlite",
|
|
80
|
-
sqlitePath: resolvedStoragePath
|
|
79
|
+
sqlitePath: resolvedStoragePath
|
|
81
80
|
});
|
|
82
81
|
const getContext = () => defaultContext;
|
|
83
82
|
const getAutoRunConfig = async () => {
|
package/dist/main/index.d.cts
CHANGED
|
@@ -24,18 +24,12 @@ interface ElectronBridgeOptions extends Omit<AgentConfig, 'tools'> {
|
|
|
24
24
|
/** IPC channel 前缀 */
|
|
25
25
|
channelPrefix?: string;
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
27
|
+
* 统一数据目录(必填)
|
|
28
28
|
* 所有数据都存储在此目录下:
|
|
29
29
|
* - db.sqlite: 对话历史
|
|
30
|
-
* - search-data/:
|
|
31
|
-
* 默认: ~/.ai-chat/
|
|
30
|
+
* - search-data/: 搜索索引(由宿主 tools 注入 searchPlugin 时使用)
|
|
32
31
|
*/
|
|
33
|
-
dataDir
|
|
34
|
-
/**
|
|
35
|
-
* SQLite 数据库路径(可选,覆盖 dataDir 设置)
|
|
36
|
-
* @deprecated 推荐使用 dataDir
|
|
37
|
-
*/
|
|
38
|
-
storagePath?: string;
|
|
32
|
+
dataDir: string;
|
|
39
33
|
/** 默认租户上下文 */
|
|
40
34
|
defaultContext?: StorageContext;
|
|
41
35
|
/**
|
package/dist/main/index.d.ts
CHANGED
|
@@ -24,18 +24,12 @@ interface ElectronBridgeOptions extends Omit<AgentConfig, 'tools'> {
|
|
|
24
24
|
/** IPC channel 前缀 */
|
|
25
25
|
channelPrefix?: string;
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
27
|
+
* 统一数据目录(必填)
|
|
28
28
|
* 所有数据都存储在此目录下:
|
|
29
29
|
* - db.sqlite: 对话历史
|
|
30
|
-
* - search-data/:
|
|
31
|
-
* 默认: ~/.ai-chat/
|
|
30
|
+
* - search-data/: 搜索索引(由宿主 tools 注入 searchPlugin 时使用)
|
|
32
31
|
*/
|
|
33
|
-
dataDir
|
|
34
|
-
/**
|
|
35
|
-
* SQLite 数据库路径(可选,覆盖 dataDir 设置)
|
|
36
|
-
* @deprecated 推荐使用 dataDir
|
|
37
|
-
*/
|
|
38
|
-
storagePath?: string;
|
|
32
|
+
dataDir: string;
|
|
39
33
|
/** 默认租户上下文 */
|
|
40
34
|
defaultContext?: StorageContext;
|
|
41
35
|
/**
|
package/dist/main/index.js
CHANGED
|
@@ -9,18 +9,16 @@ import {
|
|
|
9
9
|
} from "@huyooo/ai-chat-core";
|
|
10
10
|
import { createSearchElectronBridge } from "@huyooo/ai-search/bridge/electron";
|
|
11
11
|
import {
|
|
12
|
-
createStorage
|
|
13
|
-
getDefaultStoragePath
|
|
12
|
+
createStorage
|
|
14
13
|
} from "@huyooo/ai-chat-storage";
|
|
15
14
|
async function createElectronBridge(options) {
|
|
16
15
|
const {
|
|
17
16
|
channelPrefix = "ai-chat",
|
|
18
17
|
dataDir,
|
|
19
|
-
storagePath,
|
|
20
18
|
defaultContext = {},
|
|
21
19
|
...agentConfig
|
|
22
20
|
} = options;
|
|
23
|
-
const resolvedStoragePath =
|
|
21
|
+
const resolvedStoragePath = path.join(dataDir, "db.sqlite");
|
|
24
22
|
createSearchElectronBridge({
|
|
25
23
|
ipcMain,
|
|
26
24
|
channelPrefix
|
|
@@ -49,7 +47,7 @@ async function createElectronBridge(options) {
|
|
|
49
47
|
};
|
|
50
48
|
const storage = await createStorage({
|
|
51
49
|
type: "sqlite",
|
|
52
|
-
sqlitePath: resolvedStoragePath
|
|
50
|
+
sqlitePath: resolvedStoragePath
|
|
53
51
|
});
|
|
54
52
|
const getContext = () => defaultContext;
|
|
55
53
|
const getAutoRunConfig = async () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@huyooo/ai-chat-bridge-electron",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "AI Chat Electron Bridge - IPC integration for Electron apps",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/main/index.cjs",
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
"clean": "rm -rf dist"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@huyooo/ai-chat-core": "^0.1
|
|
41
|
-
"@huyooo/ai-chat-storage": "^0.1
|
|
42
|
-
"@huyooo/ai-search": "
|
|
40
|
+
"@huyooo/ai-chat-core": "^0.2.1",
|
|
41
|
+
"@huyooo/ai-chat-storage": "^0.2.1",
|
|
42
|
+
"@huyooo/ai-search": "^0.2.1"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"electron": ">=20.0.0"
|
package/src/main/index.ts
CHANGED
|
@@ -35,7 +35,6 @@ export interface FileInfo {
|
|
|
35
35
|
}
|
|
36
36
|
import {
|
|
37
37
|
createStorage,
|
|
38
|
-
getDefaultStoragePath,
|
|
39
38
|
type StorageAdapter,
|
|
40
39
|
type StorageContext,
|
|
41
40
|
type SessionRecord,
|
|
@@ -47,19 +46,13 @@ import {
|
|
|
47
46
|
export interface ElectronBridgeOptions extends Omit<AgentConfig, 'tools'> {
|
|
48
47
|
/** IPC channel 前缀 */
|
|
49
48
|
channelPrefix?: string;
|
|
50
|
-
/**
|
|
51
|
-
*
|
|
49
|
+
/**
|
|
50
|
+
* 统一数据目录(必填)
|
|
52
51
|
* 所有数据都存储在此目录下:
|
|
53
52
|
* - db.sqlite: 对话历史
|
|
54
|
-
* - search-data/:
|
|
55
|
-
* 默认: ~/.ai-chat/
|
|
56
|
-
*/
|
|
57
|
-
dataDir?: string;
|
|
58
|
-
/**
|
|
59
|
-
* SQLite 数据库路径(可选,覆盖 dataDir 设置)
|
|
60
|
-
* @deprecated 推荐使用 dataDir
|
|
53
|
+
* - search-data/: 搜索索引(由宿主 tools 注入 searchPlugin 时使用)
|
|
61
54
|
*/
|
|
62
|
-
|
|
55
|
+
dataDir: string;
|
|
63
56
|
/** 默认租户上下文 */
|
|
64
57
|
defaultContext?: StorageContext;
|
|
65
58
|
/**
|
|
@@ -134,15 +127,12 @@ export async function createElectronBridge(options: ElectronBridgeOptions) {
|
|
|
134
127
|
const {
|
|
135
128
|
channelPrefix = 'ai-chat',
|
|
136
129
|
dataDir,
|
|
137
|
-
storagePath,
|
|
138
130
|
defaultContext = {},
|
|
139
131
|
...agentConfig
|
|
140
132
|
} = options;
|
|
141
133
|
|
|
142
|
-
//
|
|
143
|
-
|
|
144
|
-
const resolvedStoragePath = storagePath
|
|
145
|
-
|| (dataDir ? `${dataDir}/db.sqlite` : undefined);
|
|
134
|
+
// 对话历史 SQLite 路径(统一规则:dataDir/db.sqlite)
|
|
135
|
+
const resolvedStoragePath = path.join(dataDir, 'db.sqlite');
|
|
146
136
|
|
|
147
137
|
// 🔴 重要:在处理任何 tools 之前,先初始化搜索 Electron 桥接
|
|
148
138
|
// 这样当 searchPlugin 开始后台索引时,全局进度监听器已经注册好了
|
|
@@ -198,7 +188,7 @@ export async function createElectronBridge(options: ElectronBridgeOptions) {
|
|
|
198
188
|
// 初始化存储(在 agent 之前,因为 getAutoRunConfig 需要访问 storage)
|
|
199
189
|
const storage = await createStorage({
|
|
200
190
|
type: 'sqlite',
|
|
201
|
-
sqlitePath: resolvedStoragePath
|
|
191
|
+
sqlitePath: resolvedStoragePath,
|
|
202
192
|
});
|
|
203
193
|
|
|
204
194
|
// 获取上下文
|