@bolloon/bolloon-agent 0.1.10 → 0.1.12
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/cli-entry.js +1 -1
- package/dist/utils/auto-update.js +65 -8
- package/package.json +4 -2
- package/scripts/postinstall.js +1 -1
- package/src/cli-entry.ts +1 -1
- package/src/utils/auto-update.ts +66 -6
package/dist/cli-entry.js
CHANGED
|
@@ -36,19 +36,71 @@ function httpGet(url) {
|
|
|
36
36
|
});
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* 获取 bolloon 全局安装目录
|
|
41
|
+
*/
|
|
42
|
+
function getGlobalBolloonDir() {
|
|
43
|
+
const possiblePaths = [
|
|
44
|
+
path.join(process.env.HOME || '', '.npm-global/lib/node_modules/@bolloon/bolloon-agent'),
|
|
45
|
+
path.join(process.env.PREFIX || '/usr/local', 'lib/node_modules/@bolloon/bolloon-agent'),
|
|
46
|
+
];
|
|
47
|
+
for (const p of possiblePaths) {
|
|
48
|
+
if (fs.existsSync(path.join(p, 'package.json'))) {
|
|
49
|
+
return p;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
39
54
|
/**
|
|
40
55
|
* 获取当前安装的包版本
|
|
56
|
+
* 优先使用全局安装的版本(更准确反映实际运行的版本)
|
|
41
57
|
*/
|
|
42
58
|
function getInstalledVersion(packageName) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
59
|
+
// 调试:打印 cwd
|
|
60
|
+
console.error(`[DEBUG] getInstalledVersion called, cwd=${process.cwd()}, package=${packageName}`);
|
|
61
|
+
// 对于 @bolloon/bolloon-agent,始终优先从全局安装位置读取版本
|
|
62
|
+
// 这样可以准确检测实际安装的版本,而不受 cwd 影响
|
|
63
|
+
if (packageName === '@bolloon/bolloon-agent') {
|
|
64
|
+
const globalDir = getGlobalBolloonDir();
|
|
65
|
+
console.error(`[DEBUG] globalDir=${globalDir}`);
|
|
66
|
+
if (globalDir) {
|
|
67
|
+
const pkgPath = path.join(globalDir, 'package.json');
|
|
68
|
+
console.error(`[DEBUG] pkgPath=${pkgPath}, exists=${fs.existsSync(pkgPath)}`);
|
|
69
|
+
try {
|
|
70
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
|
|
71
|
+
console.error(`[DEBUG] pkg.version=${pkg.version}`);
|
|
72
|
+
return pkg.version || null;
|
|
73
|
+
}
|
|
74
|
+
catch (e) {
|
|
75
|
+
// 忽略
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// 回退到本地 package.json
|
|
79
|
+
const localPkgPath = path.join(process.cwd(), 'package.json');
|
|
80
|
+
console.error(`[DEBUG] localPkgPath=${localPkgPath}, exists=${fs.existsSync(localPkgPath)}`);
|
|
81
|
+
if (fs.existsSync(localPkgPath)) {
|
|
82
|
+
try {
|
|
83
|
+
const pkg = JSON.parse(fs.readFileSync(localPkgPath, 'utf-8'));
|
|
84
|
+
console.error(`[DEBUG] local pkg.version=${pkg.version}`);
|
|
85
|
+
return pkg.version || null;
|
|
86
|
+
}
|
|
87
|
+
catch (e) {
|
|
88
|
+
// 忽略
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
// 检查本地 node_modules
|
|
93
|
+
const packageJsonPath = findPackageJson(packageName);
|
|
94
|
+
console.error(`[DEBUG] findPackageJson=${packageJsonPath}`);
|
|
95
|
+
if (packageJsonPath) {
|
|
96
|
+
try {
|
|
46
97
|
const pkg = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
98
|
+
console.error(`[DEBUG] node_modules pkg.version=${pkg.version}`);
|
|
47
99
|
return pkg.version || null;
|
|
48
100
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
101
|
+
catch (e) {
|
|
102
|
+
// 忽略错误
|
|
103
|
+
}
|
|
52
104
|
}
|
|
53
105
|
return null;
|
|
54
106
|
}
|
|
@@ -112,10 +164,15 @@ async function checkBolloonUpdates() {
|
|
|
112
164
|
let latestVersion = '';
|
|
113
165
|
for (const pkg of packagesToCheck) {
|
|
114
166
|
const installed = getInstalledVersion(pkg);
|
|
167
|
+
console.error(`[DEBUG] getInstalledVersion(${pkg}) = ${installed}`);
|
|
115
168
|
if (!installed)
|
|
116
169
|
continue;
|
|
117
|
-
|
|
170
|
+
// 只记录 @bolloon/bolloon-agent 的版本作为当前版本
|
|
171
|
+
if (pkg === '@bolloon/bolloon-agent') {
|
|
172
|
+
currentVersion = installed;
|
|
173
|
+
}
|
|
118
174
|
const latest = await getLatestVersion(pkg);
|
|
175
|
+
console.error(`[DEBUG] getLatestVersion(${pkg}) = ${latest}`);
|
|
119
176
|
if (latest && compareVersions(installed, latest) < 0) {
|
|
120
177
|
hasUpdate = true;
|
|
121
178
|
latestVersion = latest;
|
|
@@ -289,7 +346,7 @@ export async function performUpdate(packages) {
|
|
|
289
346
|
return await updatePackages(packages);
|
|
290
347
|
}
|
|
291
348
|
// CLI 入口
|
|
292
|
-
if (
|
|
349
|
+
if (process.argv[1]?.includes('auto-update')) {
|
|
293
350
|
(async () => {
|
|
294
351
|
const command = process.argv[2];
|
|
295
352
|
switch (command) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bolloon/bolloon-agent",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "P2P AI Document Agent - 全局安装后执行 `bolloon` 启动产品",
|
|
6
6
|
"main": "dist/cli.js",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"src/constraint-runtime"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@bolloon/bolloon-agent": "^0.1.
|
|
35
|
+
"@bolloon/bolloon-agent": "^0.1.11",
|
|
36
36
|
"@bolloon/constraint-runtime": "0.1.0",
|
|
37
37
|
"@chainsafe/libp2p-noise": "^17.0.0",
|
|
38
38
|
"@chainsafe/libp2p-yamux": "^8.0.1",
|
|
@@ -47,12 +47,14 @@
|
|
|
47
47
|
"@multiformats/multiaddr": "^13.0.3",
|
|
48
48
|
"@noble/hashes": "^1.3.0",
|
|
49
49
|
"@rayhanadev/iroh": "^0.1.1",
|
|
50
|
+
"b4a": "^1.8.1",
|
|
50
51
|
"dotenv": "^17.4.2",
|
|
51
52
|
"esbuild": "^0.24.0",
|
|
52
53
|
"express": "^5.2.1",
|
|
53
54
|
"libp2p": "^3.3.0",
|
|
54
55
|
"mammoth": "^1.6.0",
|
|
55
56
|
"pdf-parse": "^1.1.4",
|
|
57
|
+
"platform": "^1.3.6",
|
|
56
58
|
"react": "^18.3.0",
|
|
57
59
|
"react-dom": "^18.3.0"
|
|
58
60
|
},
|
package/scripts/postinstall.js
CHANGED
|
@@ -47,7 +47,7 @@ function initUserDirs() {
|
|
|
47
47
|
const configPath = path.join(bolloonDir, 'config.json');
|
|
48
48
|
if (!fs.existsSync(configPath)) {
|
|
49
49
|
const defaultConfig = {
|
|
50
|
-
version: '0.1.
|
|
50
|
+
version: '0.1.12',
|
|
51
51
|
initializedAt: new Date().toISOString(),
|
|
52
52
|
defaults: {
|
|
53
53
|
port: 54188,
|
package/src/cli-entry.ts
CHANGED
package/src/utils/auto-update.ts
CHANGED
|
@@ -65,18 +65,72 @@ function httpGet(url: string): Promise<string> {
|
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
/**
|
|
69
|
+
* 获取 bolloon 全局安装目录
|
|
70
|
+
*/
|
|
71
|
+
function getGlobalBolloonDir(): string | null {
|
|
72
|
+
const possiblePaths = [
|
|
73
|
+
path.join(process.env.HOME || '', '.npm-global/lib/node_modules/@bolloon/bolloon-agent'),
|
|
74
|
+
path.join(process.env.PREFIX || '/usr/local', 'lib/node_modules/@bolloon/bolloon-agent'),
|
|
75
|
+
];
|
|
76
|
+
for (const p of possiblePaths) {
|
|
77
|
+
if (fs.existsSync(path.join(p, 'package.json'))) {
|
|
78
|
+
return p;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
|
|
68
84
|
/**
|
|
69
85
|
* 获取当前安装的包版本
|
|
86
|
+
* 优先使用全局安装的版本(更准确反映实际运行的版本)
|
|
70
87
|
*/
|
|
71
88
|
function getInstalledVersion(packageName: string): string | null {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
89
|
+
// 调试:打印 cwd
|
|
90
|
+
console.error(`[DEBUG] getInstalledVersion called, cwd=${process.cwd()}, package=${packageName}`);
|
|
91
|
+
|
|
92
|
+
// 对于 @bolloon/bolloon-agent,始终优先从全局安装位置读取版本
|
|
93
|
+
// 这样可以准确检测实际安装的版本,而不受 cwd 影响
|
|
94
|
+
if (packageName === '@bolloon/bolloon-agent') {
|
|
95
|
+
const globalDir = getGlobalBolloonDir();
|
|
96
|
+
console.error(`[DEBUG] globalDir=${globalDir}`);
|
|
97
|
+
if (globalDir) {
|
|
98
|
+
const pkgPath = path.join(globalDir, 'package.json');
|
|
99
|
+
console.error(`[DEBUG] pkgPath=${pkgPath}, exists=${fs.existsSync(pkgPath)}`);
|
|
100
|
+
try {
|
|
101
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
|
|
102
|
+
console.error(`[DEBUG] pkg.version=${pkg.version}`);
|
|
103
|
+
return pkg.version || null;
|
|
104
|
+
} catch (e) {
|
|
105
|
+
// 忽略
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// 回退到本地 package.json
|
|
110
|
+
const localPkgPath = path.join(process.cwd(), 'package.json');
|
|
111
|
+
console.error(`[DEBUG] localPkgPath=${localPkgPath}, exists=${fs.existsSync(localPkgPath)}`);
|
|
112
|
+
if (fs.existsSync(localPkgPath)) {
|
|
113
|
+
try {
|
|
114
|
+
const pkg = JSON.parse(fs.readFileSync(localPkgPath, 'utf-8'));
|
|
115
|
+
console.error(`[DEBUG] local pkg.version=${pkg.version}`);
|
|
116
|
+
return pkg.version || null;
|
|
117
|
+
} catch (e) {
|
|
118
|
+
// 忽略
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// 检查本地 node_modules
|
|
124
|
+
const packageJsonPath = findPackageJson(packageName);
|
|
125
|
+
console.error(`[DEBUG] findPackageJson=${packageJsonPath}`);
|
|
126
|
+
if (packageJsonPath) {
|
|
127
|
+
try {
|
|
75
128
|
const pkg = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
129
|
+
console.error(`[DEBUG] node_modules pkg.version=${pkg.version}`);
|
|
76
130
|
return pkg.version || null;
|
|
131
|
+
} catch (e) {
|
|
132
|
+
// 忽略错误
|
|
77
133
|
}
|
|
78
|
-
} catch (e) {
|
|
79
|
-
// 忽略错误
|
|
80
134
|
}
|
|
81
135
|
return null;
|
|
82
136
|
}
|
|
@@ -144,10 +198,16 @@ async function checkBolloonUpdates(): Promise<PackageInfo | null> {
|
|
|
144
198
|
|
|
145
199
|
for (const pkg of packagesToCheck) {
|
|
146
200
|
const installed = getInstalledVersion(pkg);
|
|
201
|
+
console.error(`[DEBUG] getInstalledVersion(${pkg}) = ${installed}`);
|
|
147
202
|
if (!installed) continue;
|
|
148
203
|
|
|
149
|
-
|
|
204
|
+
// 只记录 @bolloon/bolloon-agent 的版本作为当前版本
|
|
205
|
+
if (pkg === '@bolloon/bolloon-agent') {
|
|
206
|
+
currentVersion = installed;
|
|
207
|
+
}
|
|
208
|
+
|
|
150
209
|
const latest = await getLatestVersion(pkg);
|
|
210
|
+
console.error(`[DEBUG] getLatestVersion(${pkg}) = ${latest}`);
|
|
151
211
|
|
|
152
212
|
if (latest && compareVersions(installed, latest) < 0) {
|
|
153
213
|
hasUpdate = true;
|