claw-subagent-service 0.0.53 → 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
|
// 保存进程引用,以便后续关闭
|
|
@@ -343,6 +343,16 @@ class OpenClawClient {
|
|
|
343
343
|
|
|
344
344
|
// 关键:不设置 OPENCLAW_GATEWAY_URL,避免触发 "gateway url override requires explicit credentials"
|
|
345
345
|
// 让 openclaw agent 通过默认方式自动发现本地 gateway
|
|
346
|
+
|
|
347
|
+
// 修复:如果父进程 cwd 已失效(如目录被删除/替换),先修复自身 cwd,避免子进程继承无效路径
|
|
348
|
+
try {
|
|
349
|
+
process.cwd();
|
|
350
|
+
} catch (e) {
|
|
351
|
+
if (e.code === 'ENOENT') {
|
|
352
|
+
try { process.chdir(os.tmpdir()); } catch {}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
346
356
|
const env = getOpenClawEnv();
|
|
347
357
|
// 将 gateway token 通过环境变量传递(openclaw agent 不支持 --token CLI 参数)
|
|
348
358
|
if (gatewayToken) {
|
|
@@ -353,6 +363,7 @@ class OpenClawClient {
|
|
|
353
363
|
shell: true,
|
|
354
364
|
windowsHide: true,
|
|
355
365
|
env,
|
|
366
|
+
cwd: os.tmpdir(),
|
|
356
367
|
});
|
|
357
368
|
|
|
358
369
|
this.log?.info(`[OpenClawClient] CLI 子进程 PID=${child.pid}`);
|
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
|
|