claw-subagent-service 0.0.52 → 0.0.54
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
|
@@ -331,9 +331,7 @@ class OpenClawClient {
|
|
|
331
331
|
|
|
332
332
|
const quoteArg = (s) => `"${s}"`;
|
|
333
333
|
const cmdParts = ['openclaw', 'agent', '-m', quoteArg(escapedMessage), '--session-id', quoteArg(sessionId)];
|
|
334
|
-
|
|
335
|
-
cmdParts.push('--token', quoteArg(gatewayToken));
|
|
336
|
-
}
|
|
334
|
+
// 注意:openclaw agent CLI 不支持 --token 参数,token 通过环境变量传递
|
|
337
335
|
const command = cmdParts.join(' ');
|
|
338
336
|
|
|
339
337
|
this.log?.info(`[OpenClawClient] 执行: ${command}`);
|
|
@@ -345,10 +343,27 @@ class OpenClawClient {
|
|
|
345
343
|
|
|
346
344
|
// 关键:不设置 OPENCLAW_GATEWAY_URL,避免触发 "gateway url override requires explicit credentials"
|
|
347
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
|
+
|
|
356
|
+
const env = getOpenClawEnv();
|
|
357
|
+
// 将 gateway token 通过环境变量传递(openclaw agent 不支持 --token CLI 参数)
|
|
358
|
+
if (gatewayToken) {
|
|
359
|
+
env.OPENCLAW_API_KEY = gatewayToken;
|
|
360
|
+
env.OPENCLAW_TOKEN = gatewayToken;
|
|
361
|
+
}
|
|
348
362
|
const child = spawn(command, {
|
|
349
363
|
shell: true,
|
|
350
364
|
windowsHide: true,
|
|
351
|
-
env
|
|
365
|
+
env,
|
|
366
|
+
cwd: os.tmpdir(),
|
|
352
367
|
});
|
|
353
368
|
|
|
354
369
|
this.log?.info(`[OpenClawClient] CLI 子进程 PID=${child.pid}`);
|