claw-subagent-service 0.0.54 → 0.0.55
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
CHANGED
package/service/daemon.js
CHANGED
|
@@ -176,6 +176,15 @@ function getRestartDelay() {
|
|
|
176
176
|
function startWorker(isAfterUpdate = false, backupDirForRollback = null) {
|
|
177
177
|
if (stopping || isRollingBack) return;
|
|
178
178
|
|
|
179
|
+
// 修复:如果 daemon 的 cwd 已失效(如目录被删除/替换),先切到临时目录,避免 worker 继承无效路径
|
|
180
|
+
try {
|
|
181
|
+
process.cwd();
|
|
182
|
+
} catch (e) {
|
|
183
|
+
if (e.code === 'ENOENT') {
|
|
184
|
+
try { process.chdir(os.tmpdir()); } catch {}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
179
188
|
log.info(`[DAEMON] 启动 Worker,daemon PID: ${process.pid},更新后重启: ${isAfterUpdate}`);
|
|
180
189
|
log.info(`[DAEMON] Daemon 目录: ${__dirname}`);
|
|
181
190
|
log.info(`[DAEMON] Worker 路径: ${WORKER_PATH}`);
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* 参考: nodejs_client/src/main/rongyun-client.ts startOpencodeService()
|
|
11
11
|
*/
|
|
12
12
|
const net = require('net');
|
|
13
|
+
const os = require('os');
|
|
13
14
|
const { spawn, exec } = require('child_process');
|
|
14
15
|
|
|
15
16
|
/**
|
|
@@ -57,7 +58,7 @@ function installOpencode(log) {
|
|
|
57
58
|
const installChild = spawn(
|
|
58
59
|
'npm',
|
|
59
60
|
['install', '-g', 'opencode-ai@latest'],
|
|
60
|
-
{ shell: true, windowsHide: true }
|
|
61
|
+
{ shell: true, windowsHide: true, cwd: os.tmpdir() }
|
|
61
62
|
);
|
|
62
63
|
|
|
63
64
|
let installOutput = '';
|
|
@@ -101,7 +102,7 @@ function startOpencodeProcess(log) {
|
|
|
101
102
|
const child = spawn(
|
|
102
103
|
'opencode',
|
|
103
104
|
['serve', '--port', '4096', '--hostname', '127.0.0.1'],
|
|
104
|
-
{ shell: true, windowsHide: true }
|
|
105
|
+
{ shell: true, windowsHide: true, cwd: os.tmpdir() }
|
|
105
106
|
);
|
|
106
107
|
|
|
107
108
|
// 保存进程引用,以便后续关闭
|
package/service/worker.js
CHANGED
|
@@ -130,6 +130,15 @@ const logTimestampValidation = (message) => {
|
|
|
130
130
|
|
|
131
131
|
log.info(`[WORKER] 业务进程启动,PID: ${process.pid}`);
|
|
132
132
|
|
|
133
|
+
// 修复:如果 worker 继承的 cwd 已失效(如 daemon 所在目录被删除),先切到临时目录
|
|
134
|
+
try {
|
|
135
|
+
process.cwd();
|
|
136
|
+
} catch (e) {
|
|
137
|
+
if (e.code === 'ENOENT') {
|
|
138
|
+
try { process.chdir(os.tmpdir()); } catch {}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
133
142
|
const localConfigPath = path.join(__dirname, '..', 'rongcloud-config.json');
|
|
134
143
|
let rongcloudConfig = null;
|
|
135
144
|
|