0agent 1.0.33 → 1.0.34
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/bin/chat.js +16 -1
- package/dist/daemon.mjs +5 -1
- package/package.json +1 -1
package/bin/chat.js
CHANGED
|
@@ -354,8 +354,23 @@ async function runTask(input) {
|
|
|
354
354
|
// Catches completion when WS is disconnected (e.g. daemon just restarted).
|
|
355
355
|
let lastPolledStep = 0;
|
|
356
356
|
const sid = sessionId;
|
|
357
|
+
const sessionStart = Date.now();
|
|
357
358
|
const pollTimer = setInterval(async () => {
|
|
358
359
|
if (!pendingResolve || sessionId !== sid) { clearInterval(pollTimer); return; }
|
|
360
|
+
|
|
361
|
+
// Hard cap: if session runs for > 2 minutes, force-unblock the chat.
|
|
362
|
+
// The daemon session may still run in background, but the user gets their prompt back.
|
|
363
|
+
if (Date.now() - sessionStart > 120_000) {
|
|
364
|
+
clearInterval(pollTimer);
|
|
365
|
+
spinner.stop();
|
|
366
|
+
console.log(`\n \x1b[33m⚠\x1b[0m Session still running in background (> 2min). Chat unblocked.\n`);
|
|
367
|
+
const res = pendingResolve;
|
|
368
|
+
pendingResolve = null;
|
|
369
|
+
sessionId = null;
|
|
370
|
+
res();
|
|
371
|
+
rl.prompt();
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
359
374
|
try {
|
|
360
375
|
const r = await fetch(`${BASE_URL}/api/sessions/${sid}`, { signal: AbortSignal.timeout(2000) });
|
|
361
376
|
const session = await r.json();
|
|
@@ -391,7 +406,7 @@ async function runTask(input) {
|
|
|
391
406
|
rl.prompt();
|
|
392
407
|
}
|
|
393
408
|
} catch {}
|
|
394
|
-
},
|
|
409
|
+
}, 800);
|
|
395
410
|
|
|
396
411
|
return new Promise(resolve => { pendingResolve = resolve; });
|
|
397
412
|
} catch (e) {
|
package/dist/daemon.mjs
CHANGED
|
@@ -2339,9 +2339,13 @@ var init_ShellCapability = __esm({
|
|
|
2339
2339
|
}
|
|
2340
2340
|
};
|
|
2341
2341
|
async execute(input, cwd) {
|
|
2342
|
-
|
|
2342
|
+
let command = String(input.command ?? "");
|
|
2343
2343
|
const timeout = Number(input.timeout_ms ?? 3e4);
|
|
2344
2344
|
const start = Date.now();
|
|
2345
|
+
if (/&\s*$/.test(command) && !/[>|].*&\s*$/.test(command)) {
|
|
2346
|
+
const logFile = `/tmp/0agent-bg-${Date.now()}.log`;
|
|
2347
|
+
command = command.replace(/\s*&\s*$/, ` > ${logFile} 2>&1 &`);
|
|
2348
|
+
}
|
|
2345
2349
|
return new Promise((resolve_) => {
|
|
2346
2350
|
const chunks = [];
|
|
2347
2351
|
let settled = false;
|