@openagents-org/agent-launcher 0.2.28 → 0.2.29
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 +1 -1
- package/src/adapters/openclaw.js +70 -65
package/package.json
CHANGED
package/src/adapters/openclaw.js
CHANGED
|
@@ -180,6 +180,7 @@ class OpenClawAdapter extends BaseAdapter {
|
|
|
180
180
|
const sessionKey = `openagents-${this.workspaceId.slice(0, 8)}-${channel.slice(-8)}`;
|
|
181
181
|
|
|
182
182
|
const args = [
|
|
183
|
+
'--log-level', 'trace',
|
|
183
184
|
'agent', '--local',
|
|
184
185
|
'--agent', this.openclawAgentId,
|
|
185
186
|
'--session-id', sessionKey,
|
|
@@ -230,73 +231,77 @@ class OpenClawAdapter extends BaseAdapter {
|
|
|
230
231
|
}
|
|
231
232
|
};
|
|
232
233
|
|
|
233
|
-
//
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
if (exitCode !== 0) {
|
|
269
|
-
reject(new Error(`CLI exited ${exitCode}: ${output.slice(-300)}`));
|
|
270
|
-
return;
|
|
234
|
+
// Redirect stderr to temp file for real-time tool status polling.
|
|
235
|
+
// --log-level trace makes OpenClaw write diagnostic events to stderr
|
|
236
|
+
// even in non-TTY mode. We poll the temp file for new lines every 500ms.
|
|
237
|
+
const stderrFile = path.join(os.tmpdir(), `openclaw-stderr-${Date.now()}.log`);
|
|
238
|
+
const stderrFd = fs.openSync(stderrFile, 'w');
|
|
239
|
+
this._log('Spawn: stderr → ' + stderrFile);
|
|
240
|
+
|
|
241
|
+
let spawnBin = binary;
|
|
242
|
+
let spawnArgs = args;
|
|
243
|
+
if (IS_WINDOWS) {
|
|
244
|
+
spawnBin = process.env.COMSPEC || 'cmd.exe';
|
|
245
|
+
spawnArgs = ['/C', binary, ...args.map(a => a.includes(' ') ? `"${a}"` : a)];
|
|
246
|
+
}
|
|
247
|
+
const proc = spawn(spawnBin, spawnArgs, {
|
|
248
|
+
stdio: ['ignore', 'pipe', stderrFd],
|
|
249
|
+
env: spawnEnv,
|
|
250
|
+
timeout: 600000,
|
|
251
|
+
windowsHide: true,
|
|
252
|
+
});
|
|
253
|
+
if (proc.stdout) proc.stdout.on('data', (d) => { output += d; });
|
|
254
|
+
|
|
255
|
+
// Poll stderr file every 500ms for tool events
|
|
256
|
+
let stderrOffset = 0;
|
|
257
|
+
const pollInterval = setInterval(() => {
|
|
258
|
+
try {
|
|
259
|
+
const stat = fs.statSync(stderrFile);
|
|
260
|
+
if (stat.size > stderrOffset) {
|
|
261
|
+
const fd = fs.openSync(stderrFile, 'r');
|
|
262
|
+
const buf = Buffer.alloc(stat.size - stderrOffset);
|
|
263
|
+
fs.readSync(fd, buf, 0, buf.length, stderrOffset);
|
|
264
|
+
fs.closeSync(fd);
|
|
265
|
+
stderrOffset = stat.size;
|
|
266
|
+
const chunk = buf.toString('utf-8');
|
|
267
|
+
const lines = chunk.split('\n');
|
|
268
|
+
for (const line of lines) processLine(line);
|
|
271
269
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
270
|
+
} catch {}
|
|
271
|
+
}, 500);
|
|
272
|
+
|
|
273
|
+
const killTimeout = setTimeout(() => {
|
|
274
|
+
proc.kill();
|
|
275
|
+
reject(new Error('CLI timed out after 600 seconds'));
|
|
276
|
+
}, 600000);
|
|
277
|
+
|
|
278
|
+
proc.on('error', (err) => {
|
|
279
|
+
clearInterval(pollInterval);
|
|
280
|
+
clearTimeout(killTimeout);
|
|
281
|
+
fs.closeSync(stderrFd);
|
|
282
|
+
try { fs.unlinkSync(stderrFile); } catch {}
|
|
283
|
+
reject(err);
|
|
284
|
+
});
|
|
285
|
+
proc.on('exit', (code) => {
|
|
286
|
+
clearInterval(pollInterval);
|
|
287
|
+
clearTimeout(killTimeout);
|
|
288
|
+
fs.closeSync(stderrFd);
|
|
289
|
+
// Read any remaining stderr
|
|
290
|
+
try {
|
|
291
|
+
const remaining = fs.readFileSync(stderrFile, 'utf-8').slice(stderrOffset);
|
|
292
|
+
if (remaining) {
|
|
293
|
+
output += remaining;
|
|
294
|
+
for (const line of remaining.split('\n')) processLine(line);
|
|
296
295
|
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
296
|
+
} catch {}
|
|
297
|
+
try { fs.unlinkSync(stderrFile); } catch {}
|
|
298
|
+
|
|
299
|
+
if (code !== 0) {
|
|
300
|
+
reject(new Error(`CLI exited ${code}: ${output.slice(-300)}`));
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
this._parseCliOutput(output, resolve);
|
|
304
|
+
});
|
|
300
305
|
});
|
|
301
306
|
}
|
|
302
307
|
|