@customize-agent/knowledge 4.0.31 → 4.0.32
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/package.json +4 -2
- package/scripts/install-hnsw.cjs +16 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@customize-agent/knowledge",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.32",
|
|
4
4
|
"description": "Local knowledge base infrastructure for customize-agent",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -36,6 +36,9 @@
|
|
|
36
36
|
"customize-agent",
|
|
37
37
|
"knowledge-base"
|
|
38
38
|
],
|
|
39
|
+
"optionalDependencies": {
|
|
40
|
+
"hnswlib-node": "^3.0.0"
|
|
41
|
+
},
|
|
39
42
|
"dependencies": {
|
|
40
43
|
"@huggingface/transformers": "^3.8.0",
|
|
41
44
|
"@napi-rs/canvas": "^0.1.82",
|
|
@@ -44,7 +47,6 @@
|
|
|
44
47
|
"dwgdxf": "^2.0.1",
|
|
45
48
|
"dxf-parser": "^1.1.2",
|
|
46
49
|
"fast-glob": "^3.3.3",
|
|
47
|
-
"hnswlib-node": "^3.0.0",
|
|
48
50
|
"jszip": "^3.10.1",
|
|
49
51
|
"mammoth": "^1.12.0",
|
|
50
52
|
"node-gyp": "^12.1.0",
|
package/scripts/install-hnsw.cjs
CHANGED
|
@@ -10,7 +10,7 @@ function packageDir(name) {
|
|
|
10
10
|
|
|
11
11
|
function run(command, args, cwd) {
|
|
12
12
|
const result = spawnSync(command, args, { cwd, stdio: 'inherit', shell: false });
|
|
13
|
-
if (result.status !== 0)
|
|
13
|
+
if (result.status !== 0) throw new Error(`${command} ${args.join(' ')} exited with ${result.status || 1}`);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
function markerPath(hnswDir) {
|
|
@@ -61,7 +61,14 @@ function verify(hnswDir) {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
try {
|
|
64
|
-
|
|
64
|
+
let hnswDir;
|
|
65
|
+
try {
|
|
66
|
+
hnswDir = packageDir('hnswlib-node');
|
|
67
|
+
} catch {
|
|
68
|
+
console.log('[hnsw] 未安装可选依赖 hnswlib-node,跳过 native 初始化。');
|
|
69
|
+
process.exit(0);
|
|
70
|
+
}
|
|
71
|
+
|
|
65
72
|
if (isMarkerFresh(hnswDir)) {
|
|
66
73
|
try {
|
|
67
74
|
verify(hnswDir);
|
|
@@ -78,7 +85,11 @@ try {
|
|
|
78
85
|
writeMarker(hnswDir);
|
|
79
86
|
console.log('[hnsw] hnswlib-node 安装和运行验证通过');
|
|
80
87
|
} catch (error) {
|
|
81
|
-
console.
|
|
82
|
-
console.
|
|
83
|
-
process.
|
|
88
|
+
console.warn('[hnsw] hnswlib-node 当前不可用,已跳过可选向量索引 native 初始化,不影响主包安装。');
|
|
89
|
+
console.warn('[hnsw] 如需启用本地向量索引,请安装 native 编译工具链后运行 npm rebuild hnswlib-node 或在源码仓库执行 pnpm doctor:hnsw。');
|
|
90
|
+
if (process.env.CUSTOMIZE_AGENT_HNSW_STRICT === '1') {
|
|
91
|
+
console.warn(error && error.stack ? error.stack : error);
|
|
92
|
+
process.exit(1);
|
|
93
|
+
}
|
|
94
|
+
process.exit(0);
|
|
84
95
|
}
|