reevesagents 1.7.4 → 1.7.5
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/CHANGELOG.md +14 -0
- package/dist/{chunk-UH6K25MG.js → chunk-4ARHWX5G.js} +97 -2
- package/dist/{chunk-LXZNX6EJ.js → chunk-5K4BBZMS.js} +2 -2
- package/dist/{chunk-TIDTHK3L.js → chunk-BITRLLG5.js} +2 -2
- package/dist/{chunk-HIJYVPYH.js → chunk-EZJQYBYP.js} +2 -2
- package/dist/{chunk-PDJ2CPVO.js → chunk-HHNMES47.js} +157 -11
- package/dist/{chunk-X6EBVSC7.js → chunk-MEIFYC3B.js} +3 -3
- package/dist/{chunk-CFDTC6GY.js → chunk-YAR57K3U.js} +1 -51
- package/dist/cli.js +24 -19
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -2
- package/dist/{router-KMZQ52T2.js → router-2LPA3MHU.js} +12 -11
- package/dist/{server-Y2IEANCZ.js → server-GJTDNSX7.js} +16 -10
- package/dist/{server-NREXCROR.js → server-KHCFIUJH.js} +17 -10
- package/dist/{tui-launch-ESUQ7SYU.js → tui-launch-XYYH3XEY.js} +2 -2
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.7.5](https://github.com/mertkayacs/reevesagents/compare/v1.7.4...v1.7.5) (2026-08-06)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **core:** kill tmux sessions and pane processes before their records disappear ([6ec0460](https://github.com/mertkayacs/reevesagents/commit/6ec046004abc7dcb4730c3308f0d31a143e10a8a)), closes [#48](https://github.com/mertkayacs/reevesagents/issues/48) [#49](https://github.com/mertkayacs/reevesagents/issues/49) [#50](https://github.com/mertkayacs/reevesagents/issues/50) [#51](https://github.com/mertkayacs/reevesagents/issues/51) [#52](https://github.com/mertkayacs/reevesagents/issues/52)
|
|
9
|
+
* **core:** stop leaking tmux sessions and agent processes across the run lifecycle ([cf185d8](https://github.com/mertkayacs/reevesagents/commit/cf185d884ea41f763536b49ecbac4f7c82e44bc1))
|
|
10
|
+
* **win:** sync shared types with the unix catalog (pane_pid) ([1913273](https://github.com/mertkayacs/reevesagents/commit/19132738b93b5dc64e65b1ff5c732e3bc22dd318))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Performance Improvements
|
|
14
|
+
|
|
15
|
+
* **core:** batch sweep probes into one server-wide tmux enumeration ([7d3f26a](https://github.com/mertkayacs/reevesagents/commit/7d3f26a0fa7bdb85ffcfa6680d47ec311e080eeb)), closes [#53](https://github.com/mertkayacs/reevesagents/issues/53)
|
|
16
|
+
|
|
3
17
|
## [1.7.4](https://github.com/mertkayacs/reevesagents/compare/v1.7.3...v1.7.4) (2026-07-31)
|
|
4
18
|
|
|
5
19
|
|
|
@@ -1,12 +1,25 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
+
RUN_SESSION_PATTERN,
|
|
4
|
+
VIEWER_SESSION_PATTERN,
|
|
5
|
+
allWindowIds,
|
|
3
6
|
findAgent,
|
|
7
|
+
killAgent,
|
|
8
|
+
killSession,
|
|
9
|
+
listAgents,
|
|
4
10
|
listRuns,
|
|
11
|
+
listSessions,
|
|
12
|
+
loadConfig,
|
|
5
13
|
nowIso,
|
|
14
|
+
nowMs,
|
|
6
15
|
redactSecrets,
|
|
7
16
|
runDir,
|
|
17
|
+
sessionAttached,
|
|
18
|
+
sessionInGroup,
|
|
19
|
+
targetExists,
|
|
20
|
+
tmuxAvailable,
|
|
8
21
|
withRunsLock
|
|
9
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-HHNMES47.js";
|
|
10
23
|
|
|
11
24
|
// src/version.ts
|
|
12
25
|
import { readFileSync } from "fs";
|
|
@@ -18,6 +31,84 @@ function readVersion() {
|
|
|
18
31
|
}
|
|
19
32
|
var REEVESAGENTS_VERSION = readVersion();
|
|
20
33
|
|
|
34
|
+
// src/core/reaper.ts
|
|
35
|
+
function sweepAgents(options = {}) {
|
|
36
|
+
const haveTmux = options.targetExists ? true : (options.tmuxAvailable ?? tmuxAvailable)();
|
|
37
|
+
if (!haveTmux) return { reaped: [] };
|
|
38
|
+
const targetExists2 = options.targetExists ?? targetExists;
|
|
39
|
+
const now = options.now ?? nowMs;
|
|
40
|
+
const maxLifetimeMs = options.maxLifetimeMs ?? loadConfig().global.max_lifetime_ms;
|
|
41
|
+
const candidates = listAgents().filter((agent) => !agent.ended_at && !agent.headless);
|
|
42
|
+
const batchWindows = !options.targetExists && candidates.some((agent) => agent.tmux_window_id) ? allWindowIds() : null;
|
|
43
|
+
const probe = batchWindows ? (id, session) => batchWindows.has(`${session}\0${id}`) || targetExists2(id, session) : targetExists2;
|
|
44
|
+
const reaped = [];
|
|
45
|
+
for (const agent of candidates) {
|
|
46
|
+
const ageMs = now() - new Date(agent.started_at).getTime();
|
|
47
|
+
let reason = null;
|
|
48
|
+
if (agent.tmux_window_id && !probe(agent.tmux_window_id, agent.tmux_session)) {
|
|
49
|
+
reason = "window-gone";
|
|
50
|
+
} else if (maxLifetimeMs > 0 && ageMs > maxLifetimeMs) {
|
|
51
|
+
reason = "lifetime-exceeded";
|
|
52
|
+
}
|
|
53
|
+
if (!reason) continue;
|
|
54
|
+
try {
|
|
55
|
+
killAgent(agent.id, options.driver ? { driver: options.driver } : {});
|
|
56
|
+
reaped.push({
|
|
57
|
+
agent_id: agent.id,
|
|
58
|
+
run_id: agent.run_id,
|
|
59
|
+
nickname: agent.nickname,
|
|
60
|
+
reason,
|
|
61
|
+
age_ms: Math.max(0, Math.round(ageMs))
|
|
62
|
+
});
|
|
63
|
+
} catch {
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return { reaped };
|
|
67
|
+
}
|
|
68
|
+
var ORPHAN_MIN_AGE_SEC = 60;
|
|
69
|
+
function sweepOrphanSessions(options = {}) {
|
|
70
|
+
const haveTmux = options.listSessions ? true : (options.tmuxAvailable ?? tmuxAvailable)();
|
|
71
|
+
if (!haveTmux) return { killed: [] };
|
|
72
|
+
const sessions = (options.listSessions ?? listSessions)();
|
|
73
|
+
const killSession2 = options.killSession ?? killSession;
|
|
74
|
+
const sessionAttached2 = options.sessionAttached ?? sessionAttached;
|
|
75
|
+
const nowSec = (options.now ?? nowMs)() / 1e3;
|
|
76
|
+
const liveRunSessions = new Set(listRuns().map((run) => run.tmux_session));
|
|
77
|
+
const killed = [];
|
|
78
|
+
for (const info of sessions) {
|
|
79
|
+
if (info.attached) continue;
|
|
80
|
+
if (!options.ignoreGrace && info.createdSec > 0 && nowSec - info.createdSec < ORPHAN_MIN_AGE_SEC) continue;
|
|
81
|
+
let orphan = false;
|
|
82
|
+
if (RUN_SESSION_PATTERN.test(info.name)) {
|
|
83
|
+
orphan = !liveRunSessions.has(info.name);
|
|
84
|
+
} else if (VIEWER_SESSION_PATTERN.test(info.name)) {
|
|
85
|
+
orphan = ![...liveRunSessions].some((s) => sessionInGroup(info, s));
|
|
86
|
+
}
|
|
87
|
+
if (!orphan) continue;
|
|
88
|
+
if (sessionAttached2(info.name)) continue;
|
|
89
|
+
try {
|
|
90
|
+
killSession2(info.name);
|
|
91
|
+
killed.push(info.name);
|
|
92
|
+
} catch {
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return { killed };
|
|
96
|
+
}
|
|
97
|
+
var lastOrphanSweepAt = 0;
|
|
98
|
+
function sweepOrphanSessionsThrottled(minIntervalMs = 15e3, options = {}) {
|
|
99
|
+
const now = nowMs();
|
|
100
|
+
if (lastOrphanSweepAt !== 0 && now - lastOrphanSweepAt < minIntervalMs) return { killed: [], swept: false };
|
|
101
|
+
lastOrphanSweepAt = now;
|
|
102
|
+
return { ...sweepOrphanSessions(options), swept: true };
|
|
103
|
+
}
|
|
104
|
+
var lastSweepAt = 0;
|
|
105
|
+
function sweepAgentsThrottled(minIntervalMs = 15e3, options = {}) {
|
|
106
|
+
const now = (options.now ?? nowMs)();
|
|
107
|
+
if (lastSweepAt !== 0 && now - lastSweepAt < minIntervalMs) return { reaped: [], swept: false };
|
|
108
|
+
lastSweepAt = now;
|
|
109
|
+
return { ...sweepAgents(options), swept: true };
|
|
110
|
+
}
|
|
111
|
+
|
|
21
112
|
// src/core/approvals.ts
|
|
22
113
|
import {
|
|
23
114
|
chmodSync,
|
|
@@ -163,9 +254,13 @@ function resolveRunApproval(approvalId, decision, note = "") {
|
|
|
163
254
|
|
|
164
255
|
export {
|
|
165
256
|
REEVESAGENTS_VERSION,
|
|
257
|
+
sweepAgents,
|
|
258
|
+
sweepOrphanSessions,
|
|
259
|
+
sweepOrphanSessionsThrottled,
|
|
260
|
+
sweepAgentsThrottled,
|
|
166
261
|
createRunApproval,
|
|
167
262
|
readRunApproval,
|
|
168
263
|
listRunApprovals,
|
|
169
264
|
resolveRunApproval
|
|
170
265
|
};
|
|
171
|
-
//# sourceMappingURL=chunk-
|
|
266
|
+
//# sourceMappingURL=chunk-4ARHWX5G.js.map
|
|
@@ -28,7 +28,7 @@ async function startTuiWebServer() {
|
|
|
28
28
|
const { checkWebExtras, webExtrasMessage } = await import("./extras-MWGWGEPB.js");
|
|
29
29
|
const extras = await checkWebExtras();
|
|
30
30
|
if (!extras.ok) throw new Error(webExtrasMessage(extras.missing));
|
|
31
|
-
const { startWebServer } = await import("./server-
|
|
31
|
+
const { startWebServer } = await import("./server-GJTDNSX7.js");
|
|
32
32
|
return startWebServer({ open: true });
|
|
33
33
|
}
|
|
34
34
|
async function closeTuiWebServer() {
|
|
@@ -48,4 +48,4 @@ export {
|
|
|
48
48
|
startWebFromTui,
|
|
49
49
|
closeTuiWebServer
|
|
50
50
|
};
|
|
51
|
-
//# sourceMappingURL=chunk-
|
|
51
|
+
//# sourceMappingURL=chunk-5K4BBZMS.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
DEFAULT_LANGUAGE
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-HHNMES47.js";
|
|
5
5
|
|
|
6
6
|
// src/i18n/locales/en.ts
|
|
7
7
|
var en = {
|
|
@@ -5712,4 +5712,4 @@ export {
|
|
|
5712
5712
|
localeCatalog,
|
|
5713
5713
|
translatePhrase
|
|
5714
5714
|
};
|
|
5715
|
-
//# sourceMappingURL=chunk-
|
|
5715
|
+
//# sourceMappingURL=chunk-BITRLLG5.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
PROVIDER_DEFS
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-HHNMES47.js";
|
|
5
5
|
|
|
6
6
|
// src/core/model-catalog.ts
|
|
7
7
|
var PROVIDER_DEFAULT_MODEL = "";
|
|
@@ -27,4 +27,4 @@ export {
|
|
|
27
27
|
modelDisplayName,
|
|
28
28
|
modelSourceForProvider
|
|
29
29
|
};
|
|
30
|
-
//# sourceMappingURL=chunk-
|
|
30
|
+
//# sourceMappingURL=chunk-EZJQYBYP.js.map
|
|
@@ -455,6 +455,40 @@ function redactSecrets(text) {
|
|
|
455
455
|
return result;
|
|
456
456
|
}
|
|
457
457
|
|
|
458
|
+
// src/core/process.ts
|
|
459
|
+
function sleepSync(ms) {
|
|
460
|
+
const buffer = new SharedArrayBuffer(4);
|
|
461
|
+
const view = new Int32Array(buffer);
|
|
462
|
+
Atomics.wait(view, 0, 0, ms);
|
|
463
|
+
}
|
|
464
|
+
function processAlive(pid) {
|
|
465
|
+
try {
|
|
466
|
+
process.kill(pid, 0);
|
|
467
|
+
return true;
|
|
468
|
+
} catch (err) {
|
|
469
|
+
return err.code === "EPERM";
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
function signalProcessGroup(pid, signal) {
|
|
473
|
+
try {
|
|
474
|
+
process.kill(-pid, signal);
|
|
475
|
+
} catch {
|
|
476
|
+
try {
|
|
477
|
+
process.kill(pid, signal);
|
|
478
|
+
} catch {
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
var KILL_GRACE_MS = 400;
|
|
483
|
+
function reapPaneProcess(pid) {
|
|
484
|
+
if (!pid || pid <= 0 || !processAlive(pid)) return;
|
|
485
|
+
sleepSync(KILL_GRACE_MS);
|
|
486
|
+
if (!processAlive(pid)) return;
|
|
487
|
+
signalProcessGroup(pid, "SIGTERM");
|
|
488
|
+
sleepSync(KILL_GRACE_MS);
|
|
489
|
+
if (processAlive(pid)) signalProcessGroup(pid, "SIGKILL");
|
|
490
|
+
}
|
|
491
|
+
|
|
458
492
|
// src/core/tmux.ts
|
|
459
493
|
import { execFileSync as execFileSync2, spawnSync as spawnSync2 } from "child_process";
|
|
460
494
|
var realDriver = {
|
|
@@ -507,6 +541,60 @@ function targetExists(target, session) {
|
|
|
507
541
|
return false;
|
|
508
542
|
}
|
|
509
543
|
}
|
|
544
|
+
function listSessions() {
|
|
545
|
+
try {
|
|
546
|
+
return execFileSync2("tmux", ["list-sessions", "-F", "#{session_name} #{session_attached} #{session_group} #{session_group_list} #{session_created}"], { encoding: "utf8" }).split("\n").map((line) => line.trim()).filter(Boolean).map((row) => {
|
|
547
|
+
const [name = "", attached = "0", group = "", groupList = "", created = "0"] = row.split(" ");
|
|
548
|
+
return {
|
|
549
|
+
name,
|
|
550
|
+
attached: attached !== "0",
|
|
551
|
+
group,
|
|
552
|
+
groupList: groupList.split(",").filter(Boolean),
|
|
553
|
+
createdSec: Number.parseInt(created, 10) || 0
|
|
554
|
+
};
|
|
555
|
+
});
|
|
556
|
+
} catch {
|
|
557
|
+
return [];
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
function sessionAttached(session) {
|
|
561
|
+
try {
|
|
562
|
+
const out = execFileSync2("tmux", ["display-message", "-p", "-t", exactSession(session), "#{session_attached}"], { encoding: "utf8" }).trim();
|
|
563
|
+
return out !== "0" && out !== "";
|
|
564
|
+
} catch {
|
|
565
|
+
return true;
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
function killSession(session) {
|
|
569
|
+
try {
|
|
570
|
+
spawnSync2("tmux", ["kill-session", "-t", exactSession(session)], { stdio: "ignore" });
|
|
571
|
+
} catch {
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
function allWindowIds() {
|
|
575
|
+
try {
|
|
576
|
+
return new Set(
|
|
577
|
+
execFileSync2("tmux", ["list-windows", "-a", "-F", "#{session_name} #{window_id}"], { encoding: "utf8" }).split("\n").map((line) => line.trim()).filter(Boolean).map((row) => {
|
|
578
|
+
const [session = "", id = ""] = row.split(" ");
|
|
579
|
+
return `${session}\0${id}`;
|
|
580
|
+
})
|
|
581
|
+
);
|
|
582
|
+
} catch {
|
|
583
|
+
return /* @__PURE__ */ new Set();
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
var RUN_SESSION_PATTERN = /^reeves-.+-[0-9a-f]{8}$/;
|
|
587
|
+
var VIEWER_SESSION_PATTERN = /^reevesweb_[0-9a-f]{8}$/;
|
|
588
|
+
function sessionInGroup(info, runSession) {
|
|
589
|
+
return info.group === runSession || info.groupList.includes(runSession);
|
|
590
|
+
}
|
|
591
|
+
function killGroupedViewers(runSession) {
|
|
592
|
+
for (const info of listSessions()) {
|
|
593
|
+
if (VIEWER_SESSION_PATTERN.test(info.name) && sessionInGroup(info, runSession)) {
|
|
594
|
+
killSession(info.name);
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
}
|
|
510
598
|
function windowIds(session) {
|
|
511
599
|
try {
|
|
512
600
|
return execFileSync2("tmux", ["list-windows", "-t", exactSession(session), "-F", "#{window_id}"], { encoding: "utf8" }).split("\n").map((line) => line.trim()).filter(Boolean);
|
|
@@ -573,7 +661,7 @@ function nowIso() {
|
|
|
573
661
|
function nowMs() {
|
|
574
662
|
return Date.now();
|
|
575
663
|
}
|
|
576
|
-
function
|
|
664
|
+
function sleepSync2(ms) {
|
|
577
665
|
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
|
578
666
|
}
|
|
579
667
|
function withRunsLock(fn) {
|
|
@@ -597,7 +685,7 @@ function withRunsLock(fn) {
|
|
|
597
685
|
} catch {
|
|
598
686
|
}
|
|
599
687
|
if (Date.now() > deadline) throw new Error(`Timed out waiting for runs lock: ${lockPath}`);
|
|
600
|
-
|
|
688
|
+
sleepSync2(25);
|
|
601
689
|
}
|
|
602
690
|
}
|
|
603
691
|
try {
|
|
@@ -690,6 +778,7 @@ function normalizeAgent(raw) {
|
|
|
690
778
|
tmux_session: asString(raw.tmux_session),
|
|
691
779
|
tmux_window_id: asString(raw.tmux_window_id),
|
|
692
780
|
tmux_pane_id: asString(raw.tmux_pane_id),
|
|
781
|
+
pane_pid: typeof raw.pane_pid === "number" && raw.pane_pid > 0 ? raw.pane_pid : null,
|
|
693
782
|
rc_enabled: typeof raw.rc_enabled === "boolean" ? raw.rc_enabled : false,
|
|
694
783
|
permissions: normalizePermissions(raw.permissions),
|
|
695
784
|
headless: raw.headless === true,
|
|
@@ -920,16 +1009,36 @@ function runHasLiveTmuxTarget(run, options = {}) {
|
|
|
920
1009
|
function autoCleanupRuns(options = {}) {
|
|
921
1010
|
const sessionExists2 = options.sessionExists ?? sessionExists;
|
|
922
1011
|
const targetExists2 = options.targetExists ?? targetExists;
|
|
1012
|
+
const killSession2 = options.killSession ?? killSession;
|
|
1013
|
+
const killViewers = options.killViewers ?? killGroupedViewers;
|
|
923
1014
|
const tmuxAvailable2 = options.sessionExists || options.targetExists ? () => true : options.tmuxAvailable ?? tmuxAvailable;
|
|
924
1015
|
const haveTmux = options.cleanStale === false ? false : tmuxAvailable2();
|
|
925
1016
|
const removed = [];
|
|
926
1017
|
const archived = [];
|
|
927
1018
|
const runs = listRunsUnlocked(true);
|
|
1019
|
+
const useBatch = haveTmux && !options.sessionExists && !options.targetExists && runs.length > 0;
|
|
1020
|
+
const batchWindows = useBatch ? allWindowIds() : null;
|
|
1021
|
+
const batchSessions = useBatch ? new Set(listSessions().map((info) => info.name)) : null;
|
|
1022
|
+
const batchTargetExists = batchWindows ? (target, session) => batchWindows.has(`${session}\0${target}`) : void 0;
|
|
1023
|
+
const batchSessionExists = batchSessions ? (session) => batchSessions.has(session) : void 0;
|
|
928
1024
|
for (const run of runs) {
|
|
929
1025
|
const isEnded = isRunEnded(run);
|
|
930
|
-
|
|
1026
|
+
let isStale = false;
|
|
1027
|
+
if (!isEnded && haveTmux) {
|
|
1028
|
+
const looksDead = batchTargetExists && batchSessionExists ? !runHasLiveTmuxTarget(run, { sessionExists: batchSessionExists, targetExists: batchTargetExists }) : !runHasLiveTmuxTarget(run, { sessionExists: sessionExists2, targetExists: targetExists2 });
|
|
1029
|
+
isStale = looksDead && !runHasLiveTmuxTarget(run, batchTargetExists ? {} : { sessionExists: sessionExists2, targetExists: targetExists2 });
|
|
1030
|
+
}
|
|
931
1031
|
if (!isEnded && !isStale) continue;
|
|
932
1032
|
try {
|
|
1033
|
+
if (isStale) {
|
|
1034
|
+
killViewers(run.tmux_session);
|
|
1035
|
+
if (sessionExists2(run.tmux_session)) {
|
|
1036
|
+
killSession2(run.tmux_session);
|
|
1037
|
+
for (const agent of listAgents(run.id)) {
|
|
1038
|
+
if (!agent.ended_at && agent.pane_pid) reapPaneProcess(agent.pane_pid);
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
933
1042
|
const record = archiveAndRemoveRun(run.id, isStale ? "stale" : "ended");
|
|
934
1043
|
removed.push(run.id);
|
|
935
1044
|
archived.push(record.id);
|
|
@@ -1305,13 +1414,30 @@ var POST_PASTE_ENTER_DELAY_MS = 1e3;
|
|
|
1305
1414
|
var STARTUP_READY_POLL_MS = 1e3;
|
|
1306
1415
|
var STARTUP_READY_TIMEOUT_MS = 2e4;
|
|
1307
1416
|
var lastPasteAtByPane = /* @__PURE__ */ new Map();
|
|
1308
|
-
function
|
|
1417
|
+
function sleepSync3(ms) {
|
|
1309
1418
|
const buffer = new SharedArrayBuffer(4);
|
|
1310
1419
|
const view = new Int32Array(buffer);
|
|
1311
1420
|
Atomics.wait(view, 0, 0, ms);
|
|
1312
1421
|
}
|
|
1422
|
+
function killViewerSessions(driver, runSession) {
|
|
1423
|
+
let rows;
|
|
1424
|
+
try {
|
|
1425
|
+
rows = driver.tmux(["list-sessions", "-F", "#{session_name} #{session_group} #{session_group_list}"]);
|
|
1426
|
+
} catch {
|
|
1427
|
+
return;
|
|
1428
|
+
}
|
|
1429
|
+
for (const row of rows.split("\n")) {
|
|
1430
|
+
const [name = "", group = "", groupList = ""] = row.trim().split(" ");
|
|
1431
|
+
if (!VIEWER_SESSION_PATTERN.test(name)) continue;
|
|
1432
|
+
if (!sessionInGroup({ group, groupList: groupList.split(",").filter(Boolean) }, runSession)) continue;
|
|
1433
|
+
try {
|
|
1434
|
+
driver.tmux(["kill-session", "-t", `=${name}`]);
|
|
1435
|
+
} catch {
|
|
1436
|
+
}
|
|
1437
|
+
}
|
|
1438
|
+
}
|
|
1313
1439
|
function waitAfterPaste(driver) {
|
|
1314
|
-
if (driver === realDriver)
|
|
1440
|
+
if (driver === realDriver) sleepSync3(POST_PASTE_ENTER_DELAY_MS);
|
|
1315
1441
|
else driver.delay(() => {
|
|
1316
1442
|
}, POST_PASTE_ENTER_DELAY_MS);
|
|
1317
1443
|
}
|
|
@@ -1357,11 +1483,12 @@ function childProcessOutput(err) {
|
|
|
1357
1483
|
return stdout;
|
|
1358
1484
|
}
|
|
1359
1485
|
function parseTmuxIds(output) {
|
|
1360
|
-
const [windowId, paneId] = output.trim().split(/\s+/);
|
|
1486
|
+
const [windowId, paneId, panePidRaw] = output.trim().split(/\s+/);
|
|
1361
1487
|
if (!windowId?.startsWith("@") || !paneId?.startsWith("%")) {
|
|
1362
1488
|
throw new Error(`Could not parse tmux ids from: ${output}`);
|
|
1363
1489
|
}
|
|
1364
|
-
|
|
1490
|
+
const panePid = panePidRaw === void 0 ? void 0 : Number.parseInt(panePidRaw, 10);
|
|
1491
|
+
return { windowId, paneId, panePid: Number.isFinite(panePid) && panePid > 0 ? panePid : void 0 };
|
|
1365
1492
|
}
|
|
1366
1493
|
function readDisplayIds(driver, target) {
|
|
1367
1494
|
try {
|
|
@@ -1465,6 +1592,7 @@ function newAgentRecord(id, runId, tmuxSession, role, config, workingDir, ids, p
|
|
|
1465
1592
|
tmux_session: tmuxSession,
|
|
1466
1593
|
tmux_window_id: ids.windowId,
|
|
1467
1594
|
tmux_pane_id: ids.paneId,
|
|
1595
|
+
pane_pid: ids.panePid ?? null,
|
|
1468
1596
|
rc_enabled: false,
|
|
1469
1597
|
permissions,
|
|
1470
1598
|
inbox: [],
|
|
@@ -1485,7 +1613,7 @@ function createAgentWindow(runId, tmuxSession, role, config, inheritedWorkingDir
|
|
|
1485
1613
|
"-d",
|
|
1486
1614
|
"-P",
|
|
1487
1615
|
"-F",
|
|
1488
|
-
"#{window_id} #{pane_id}",
|
|
1616
|
+
"#{window_id} #{pane_id} #{pane_pid}",
|
|
1489
1617
|
"-t",
|
|
1490
1618
|
`${tmuxSession}:`,
|
|
1491
1619
|
"-n",
|
|
@@ -1747,7 +1875,7 @@ function sendKey(agentId, key, options = {}) {
|
|
|
1747
1875
|
const lastPasteAt = lastPasteAtByPane.get(agent.tmux_pane_id) ?? 0;
|
|
1748
1876
|
const remaining = POST_PASTE_ENTER_DELAY_MS - (Date.now() - lastPasteAt);
|
|
1749
1877
|
if (remaining > 0) {
|
|
1750
|
-
if (driver === realDriver)
|
|
1878
|
+
if (driver === realDriver) sleepSync3(remaining);
|
|
1751
1879
|
else driver.delay(() => {
|
|
1752
1880
|
}, remaining);
|
|
1753
1881
|
}
|
|
@@ -1762,12 +1890,15 @@ function killAgent(agentId, options = {}) {
|
|
|
1762
1890
|
const driver = options.driver ?? realDriver;
|
|
1763
1891
|
const agent = findAgent(agentId);
|
|
1764
1892
|
const run = readRun(agent.run_id);
|
|
1765
|
-
|
|
1893
|
+
const hadWindow = windowInSession(driver, agent.tmux_session, agent.tmux_window_id);
|
|
1894
|
+
if (hadWindow) {
|
|
1766
1895
|
try {
|
|
1767
1896
|
driver.tmux(["kill-window", "-t", agent.tmux_window_id]);
|
|
1768
1897
|
} catch {
|
|
1769
1898
|
}
|
|
1899
|
+
reapPaneProcess(agent.pane_pid);
|
|
1770
1900
|
}
|
|
1901
|
+
lastPasteAtByPane.delete(agent.tmux_pane_id);
|
|
1771
1902
|
const endedAt = nowIso();
|
|
1772
1903
|
updateAgent(agent.run_id, agent.id, { ended_at: endedAt, task_status: "done" });
|
|
1773
1904
|
const updatedAgent = readAgent(agent.run_id, agent.id);
|
|
@@ -1775,6 +1906,7 @@ function killAgent(agentId, options = {}) {
|
|
|
1775
1906
|
if (endedRun.status === "ended" || endedRun.ended_at !== null) {
|
|
1776
1907
|
const runOwnsSession = !!run.reeves_session && run.reeves_session !== run.tmux_session;
|
|
1777
1908
|
if (runOwnsSession) {
|
|
1909
|
+
killViewerSessions(driver, run.tmux_session);
|
|
1778
1910
|
try {
|
|
1779
1911
|
driver.tmux(["kill-session", "-t", `=${run.tmux_session}`]);
|
|
1780
1912
|
} catch {
|
|
@@ -1789,9 +1921,12 @@ function stopRun(runId, options = {}) {
|
|
|
1789
1921
|
const run = readRun(runId);
|
|
1790
1922
|
const endedAt = nowIso();
|
|
1791
1923
|
const runOwnsSession = !!run.reeves_session && run.reeves_session !== run.tmux_session;
|
|
1924
|
+
let sessionKilled = false;
|
|
1792
1925
|
if (runOwnsSession) {
|
|
1926
|
+
killViewerSessions(driver, run.tmux_session);
|
|
1793
1927
|
try {
|
|
1794
1928
|
driver.tmux(["kill-session", "-t", `=${run.tmux_session}`]);
|
|
1929
|
+
sessionKilled = true;
|
|
1795
1930
|
} catch {
|
|
1796
1931
|
}
|
|
1797
1932
|
}
|
|
@@ -1802,7 +1937,11 @@ function stopRun(runId, options = {}) {
|
|
|
1802
1937
|
driver.tmux(["kill-window", "-t", agent.tmux_window_id]);
|
|
1803
1938
|
} catch {
|
|
1804
1939
|
}
|
|
1940
|
+
reapPaneProcess(agent.pane_pid);
|
|
1941
|
+
} else if (sessionKilled) {
|
|
1942
|
+
reapPaneProcess(agent.pane_pid);
|
|
1805
1943
|
}
|
|
1944
|
+
lastPasteAtByPane.delete(agent.tmux_pane_id);
|
|
1806
1945
|
updateAgent(run.id, agent.id, { ended_at: endedAt });
|
|
1807
1946
|
}
|
|
1808
1947
|
const endedRun = { ...run, status: "ended", ended_at: endedAt };
|
|
@@ -2371,6 +2510,13 @@ export {
|
|
|
2371
2510
|
tmuxAvailable,
|
|
2372
2511
|
sessionExists,
|
|
2373
2512
|
targetExists,
|
|
2513
|
+
listSessions,
|
|
2514
|
+
sessionAttached,
|
|
2515
|
+
killSession,
|
|
2516
|
+
allWindowIds,
|
|
2517
|
+
RUN_SESSION_PATTERN,
|
|
2518
|
+
VIEWER_SESSION_PATTERN,
|
|
2519
|
+
sessionInGroup,
|
|
2374
2520
|
windowIds,
|
|
2375
2521
|
windowByName,
|
|
2376
2522
|
stateRoot,
|
|
@@ -2439,4 +2585,4 @@ export {
|
|
|
2439
2585
|
checkTmux,
|
|
2440
2586
|
runDoctor
|
|
2441
2587
|
};
|
|
2442
|
-
//# sourceMappingURL=chunk-
|
|
2588
|
+
//# sourceMappingURL=chunk-HHNMES47.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
installSkills
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-YAR57K3U.js";
|
|
5
5
|
import {
|
|
6
6
|
attachAll,
|
|
7
7
|
checkTmux,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
resolveLaunchCmd,
|
|
12
12
|
stateRoot,
|
|
13
13
|
verifyServerLaunch
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-HHNMES47.js";
|
|
15
15
|
|
|
16
16
|
// src/surfaces/tui/open-token.ts
|
|
17
17
|
import { mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
@@ -67,4 +67,4 @@ export {
|
|
|
67
67
|
runOnboarding,
|
|
68
68
|
suggestedAgentPrompt
|
|
69
69
|
};
|
|
70
|
-
//# sourceMappingURL=chunk-
|
|
70
|
+
//# sourceMappingURL=chunk-MEIFYC3B.js.map
|
|
@@ -1,52 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
killAgent,
|
|
4
|
-
listAgents,
|
|
5
|
-
loadConfig,
|
|
6
|
-
nowMs,
|
|
7
|
-
targetExists,
|
|
8
|
-
tmuxAvailable
|
|
9
|
-
} from "./chunk-PDJ2CPVO.js";
|
|
10
|
-
|
|
11
|
-
// src/core/reaper.ts
|
|
12
|
-
function sweepAgents(options = {}) {
|
|
13
|
-
const haveTmux = options.targetExists ? true : (options.tmuxAvailable ?? tmuxAvailable)();
|
|
14
|
-
if (!haveTmux) return { reaped: [] };
|
|
15
|
-
const targetExists2 = options.targetExists ?? targetExists;
|
|
16
|
-
const now = options.now ?? nowMs;
|
|
17
|
-
const maxLifetimeMs = options.maxLifetimeMs ?? loadConfig().global.max_lifetime_ms;
|
|
18
|
-
const reaped = [];
|
|
19
|
-
for (const agent of listAgents()) {
|
|
20
|
-
if (agent.ended_at || agent.headless) continue;
|
|
21
|
-
const ageMs = now() - new Date(agent.started_at).getTime();
|
|
22
|
-
let reason = null;
|
|
23
|
-
if (agent.tmux_window_id && !targetExists2(agent.tmux_window_id, agent.tmux_session)) {
|
|
24
|
-
reason = "window-gone";
|
|
25
|
-
} else if (maxLifetimeMs > 0 && ageMs > maxLifetimeMs) {
|
|
26
|
-
reason = "lifetime-exceeded";
|
|
27
|
-
}
|
|
28
|
-
if (!reason) continue;
|
|
29
|
-
try {
|
|
30
|
-
killAgent(agent.id, options.driver ? { driver: options.driver } : {});
|
|
31
|
-
reaped.push({
|
|
32
|
-
agent_id: agent.id,
|
|
33
|
-
run_id: agent.run_id,
|
|
34
|
-
nickname: agent.nickname,
|
|
35
|
-
reason,
|
|
36
|
-
age_ms: Math.max(0, Math.round(ageMs))
|
|
37
|
-
});
|
|
38
|
-
} catch {
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return { reaped };
|
|
42
|
-
}
|
|
43
|
-
var lastSweepAt = 0;
|
|
44
|
-
function sweepAgentsThrottled(minIntervalMs = 15e3, options = {}) {
|
|
45
|
-
const now = (options.now ?? nowMs)();
|
|
46
|
-
if (lastSweepAt !== 0 && now - lastSweepAt < minIntervalMs) return { reaped: [], swept: false };
|
|
47
|
-
lastSweepAt = now;
|
|
48
|
-
return { ...sweepAgents(options), swept: true };
|
|
49
|
-
}
|
|
50
2
|
|
|
51
3
|
// src/core/skills.ts
|
|
52
4
|
import { mkdirSync, writeFileSync, readFileSync, rmSync, existsSync } from "fs";
|
|
@@ -177,10 +129,8 @@ function removeSkills() {
|
|
|
177
129
|
}
|
|
178
130
|
|
|
179
131
|
export {
|
|
180
|
-
sweepAgents,
|
|
181
|
-
sweepAgentsThrottled,
|
|
182
132
|
installSkills,
|
|
183
133
|
skillsStatus,
|
|
184
134
|
removeSkills
|
|
185
135
|
};
|
|
186
|
-
//# sourceMappingURL=chunk-
|
|
136
|
+
//# sourceMappingURL=chunk-YAR57K3U.js.map
|
package/dist/cli.js
CHANGED
|
@@ -4,21 +4,22 @@ import {
|
|
|
4
4
|
runOnboarding,
|
|
5
5
|
suggestedAgentPrompt,
|
|
6
6
|
writeTuiOpenToken
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-MEIFYC3B.js";
|
|
8
8
|
import {
|
|
9
9
|
installSkills,
|
|
10
10
|
removeSkills,
|
|
11
|
-
skillsStatus
|
|
12
|
-
|
|
13
|
-
} from "./chunk-CFDTC6GY.js";
|
|
11
|
+
skillsStatus
|
|
12
|
+
} from "./chunk-YAR57K3U.js";
|
|
14
13
|
import {
|
|
15
14
|
MODEL_CATALOG
|
|
16
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-EZJQYBYP.js";
|
|
17
16
|
import {
|
|
18
17
|
REEVESAGENTS_VERSION,
|
|
19
18
|
listRunApprovals,
|
|
20
|
-
resolveRunApproval
|
|
21
|
-
|
|
19
|
+
resolveRunApproval,
|
|
20
|
+
sweepAgents,
|
|
21
|
+
sweepOrphanSessions
|
|
22
|
+
} from "./chunk-4ARHWX5G.js";
|
|
22
23
|
import {
|
|
23
24
|
ALLOWED_KEYS,
|
|
24
25
|
CONFIG_FIELDS,
|
|
@@ -64,7 +65,7 @@ import {
|
|
|
64
65
|
verifyServerLaunch,
|
|
65
66
|
windowByName,
|
|
66
67
|
windowIds
|
|
67
|
-
} from "./chunk-
|
|
68
|
+
} from "./chunk-HHNMES47.js";
|
|
68
69
|
import "./chunk-Q3WWQP2R.js";
|
|
69
70
|
|
|
70
71
|
// src/surfaces/cli/index.ts
|
|
@@ -399,20 +400,24 @@ function registerRuns(program2) {
|
|
|
399
400
|
});
|
|
400
401
|
}
|
|
401
402
|
function registerReap(program2) {
|
|
402
|
-
program2.command("reap").description("reap zombie agents
|
|
403
|
+
program2.command("reap").description("reap zombie agents and orphan tmux sessions no live record owns").option("--json", "output JSON object: { reaped, killed_sessions }").action((opts) => {
|
|
403
404
|
const { reaped } = sweepAgents();
|
|
405
|
+
const { killed } = sweepOrphanSessions({ ignoreGrace: true });
|
|
404
406
|
if (opts.json) {
|
|
405
|
-
console.log(JSON.stringify(reaped, null, 2));
|
|
406
|
-
return;
|
|
407
|
-
}
|
|
408
|
-
if (reaped.length === 0) {
|
|
409
|
-
console.log("no zombie agents");
|
|
407
|
+
console.log(JSON.stringify({ reaped, killed_sessions: killed }, null, 2));
|
|
410
408
|
return;
|
|
411
409
|
}
|
|
412
410
|
for (const r of reaped) {
|
|
413
411
|
console.log(`${r.agent_id.slice(0, 8)} ${r.run_id.slice(0, 8)} ${r.reason.padEnd(17)} ${String(Math.round(r.age_ms / 1e3)).padStart(5)}s ${r.nickname}`);
|
|
414
412
|
}
|
|
415
|
-
|
|
413
|
+
for (const name of killed) {
|
|
414
|
+
console.log(`killed orphan session ${name}`);
|
|
415
|
+
}
|
|
416
|
+
if (reaped.length === 0 && killed.length === 0) {
|
|
417
|
+
console.log("no zombie agents or orphan sessions");
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
console.log(`reaped ${reaped.length} ${reaped.length === 1 ? "agent" : "agents"}, killed ${killed.length} orphan ${killed.length === 1 ? "session" : "sessions"}`);
|
|
416
421
|
});
|
|
417
422
|
}
|
|
418
423
|
function registerOpen(program2) {
|
|
@@ -812,7 +817,7 @@ function registerDetach(program2) {
|
|
|
812
817
|
function registerMcp(program2) {
|
|
813
818
|
program2.command("mcp").description("start the agent control MCP server over stdio (for CLIs that have it attached)").action(async () => {
|
|
814
819
|
try {
|
|
815
|
-
const { startAgentMcpServer } = await import("./server-
|
|
820
|
+
const { startAgentMcpServer } = await import("./server-KHCFIUJH.js");
|
|
816
821
|
await startAgentMcpServer();
|
|
817
822
|
} catch (err) {
|
|
818
823
|
console.error(err instanceof Error ? err.message : String(err));
|
|
@@ -910,7 +915,7 @@ async function runWeb(opts) {
|
|
|
910
915
|
console.error(webExtrasMessage(extras.missing));
|
|
911
916
|
process.exit(1);
|
|
912
917
|
}
|
|
913
|
-
const { startWebServer } = await import("./server-
|
|
918
|
+
const { startWebServer } = await import("./server-GJTDNSX7.js");
|
|
914
919
|
const parsed = opts.port ? Number.parseInt(opts.port, 10) : void 0;
|
|
915
920
|
const handle = await startWebServer({
|
|
916
921
|
port: parsed !== void 0 && Number.isFinite(parsed) ? parsed : void 0,
|
|
@@ -981,12 +986,12 @@ async function renderTui() {
|
|
|
981
986
|
const [{ default: React }, { render }, { Router }] = await Promise.all([
|
|
982
987
|
import("react"),
|
|
983
988
|
import("ink"),
|
|
984
|
-
import("./router-
|
|
989
|
+
import("./router-2LPA3MHU.js")
|
|
985
990
|
]);
|
|
986
991
|
try {
|
|
987
992
|
await render(React.createElement(Router), { alternateScreen: false }).waitUntilExit();
|
|
988
993
|
} finally {
|
|
989
|
-
const { closeTuiWebServer } = await import("./tui-launch-
|
|
994
|
+
const { closeTuiWebServer } = await import("./tui-launch-XYYH3XEY.js");
|
|
990
995
|
await closeTuiWebServer();
|
|
991
996
|
}
|
|
992
997
|
process.exit(0);
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
modelDisplayName,
|
|
7
7
|
modelSourceForProvider,
|
|
8
8
|
modelValuesForProvider
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-EZJQYBYP.js";
|
|
10
10
|
import {
|
|
11
11
|
BIN,
|
|
12
12
|
PROVIDERS,
|
|
@@ -39,7 +39,7 @@ import {
|
|
|
39
39
|
startRun,
|
|
40
40
|
stateRoot,
|
|
41
41
|
stopRun
|
|
42
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-HHNMES47.js";
|
|
43
43
|
import "./chunk-Q3WWQP2R.js";
|
|
44
44
|
export {
|
|
45
45
|
BIN,
|
|
@@ -2,23 +2,23 @@
|
|
|
2
2
|
import {
|
|
3
3
|
buildOnboardingState,
|
|
4
4
|
readTuiOpenToken
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import
|
|
7
|
-
sweepAgentsThrottled
|
|
8
|
-
} from "./chunk-CFDTC6GY.js";
|
|
5
|
+
} from "./chunk-MEIFYC3B.js";
|
|
6
|
+
import "./chunk-YAR57K3U.js";
|
|
9
7
|
import {
|
|
10
8
|
translate,
|
|
11
9
|
translatePhrase
|
|
12
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-BITRLLG5.js";
|
|
13
11
|
import {
|
|
14
12
|
modelDisplayName,
|
|
15
13
|
modelValuesForProvider
|
|
16
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-EZJQYBYP.js";
|
|
17
15
|
import {
|
|
18
16
|
REEVESAGENTS_VERSION,
|
|
19
17
|
listRunApprovals,
|
|
20
|
-
resolveRunApproval
|
|
21
|
-
|
|
18
|
+
resolveRunApproval,
|
|
19
|
+
sweepAgentsThrottled,
|
|
20
|
+
sweepOrphanSessionsThrottled
|
|
21
|
+
} from "./chunk-4ARHWX5G.js";
|
|
22
22
|
import {
|
|
23
23
|
CONFIG_FIELDS,
|
|
24
24
|
DEFAULT_LANGUAGE,
|
|
@@ -70,11 +70,11 @@ import {
|
|
|
70
70
|
startRunFromPreset,
|
|
71
71
|
stateRoot,
|
|
72
72
|
stopRun
|
|
73
|
-
} from "./chunk-
|
|
73
|
+
} from "./chunk-HHNMES47.js";
|
|
74
74
|
import "./chunk-Q3WWQP2R.js";
|
|
75
75
|
import {
|
|
76
76
|
startWebFromTui
|
|
77
|
-
} from "./chunk-
|
|
77
|
+
} from "./chunk-5K4BBZMS.js";
|
|
78
78
|
|
|
79
79
|
// src/surfaces/tui/router.tsx
|
|
80
80
|
import { createContext as createContext6, useContext as useContext6, useState as useState37, useCallback as useCallback5, useEffect as useEffect17, useRef as useRef4 } from "react";
|
|
@@ -1210,6 +1210,7 @@ function Runs() {
|
|
|
1210
1210
|
const [runScroll, setRunScroll] = useState8(0);
|
|
1211
1211
|
function refresh() {
|
|
1212
1212
|
sweepAgentsThrottled();
|
|
1213
|
+
sweepOrphanSessionsThrottled();
|
|
1213
1214
|
autoCleanupRuns();
|
|
1214
1215
|
const next = listRuns();
|
|
1215
1216
|
setRuns((prev) => {
|
|
@@ -6639,4 +6640,4 @@ export {
|
|
|
6639
6640
|
nextHistoryOnReset,
|
|
6640
6641
|
useRouter
|
|
6641
6642
|
};
|
|
6642
|
-
//# sourceMappingURL=router-
|
|
6643
|
+
//# sourceMappingURL=router-2LPA3MHU.js.map
|
|
@@ -2,15 +2,17 @@
|
|
|
2
2
|
import {
|
|
3
3
|
localeCatalog,
|
|
4
4
|
translatePhrase
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-BITRLLG5.js";
|
|
6
6
|
import {
|
|
7
7
|
modelValuesForProvider
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-EZJQYBYP.js";
|
|
9
9
|
import {
|
|
10
10
|
REEVESAGENTS_VERSION,
|
|
11
11
|
listRunApprovals,
|
|
12
|
-
resolveRunApproval
|
|
13
|
-
|
|
12
|
+
resolveRunApproval,
|
|
13
|
+
sweepAgentsThrottled,
|
|
14
|
+
sweepOrphanSessionsThrottled
|
|
15
|
+
} from "./chunk-4ARHWX5G.js";
|
|
14
16
|
import {
|
|
15
17
|
CONFIG_FIELDS,
|
|
16
18
|
LANGUAGE_OPTIONS,
|
|
@@ -52,7 +54,7 @@ import {
|
|
|
52
54
|
targetExists,
|
|
53
55
|
tmuxAvailable,
|
|
54
56
|
verifyServerLaunch
|
|
55
|
-
} from "./chunk-
|
|
57
|
+
} from "./chunk-HHNMES47.js";
|
|
56
58
|
import "./chunk-Q3WWQP2R.js";
|
|
57
59
|
|
|
58
60
|
// src/surfaces/webui/server.ts
|
|
@@ -332,7 +334,7 @@ function disposeBridge(bridge) {
|
|
|
332
334
|
} catch {
|
|
333
335
|
}
|
|
334
336
|
try {
|
|
335
|
-
execFileSync("tmux", ["kill-session", "-t", bridge.viewer], { stdio: "ignore" });
|
|
337
|
+
execFileSync("tmux", ["kill-session", "-t", `=${bridge.viewer}`], { stdio: "ignore" });
|
|
336
338
|
} catch {
|
|
337
339
|
}
|
|
338
340
|
try {
|
|
@@ -365,7 +367,7 @@ function openBridge(ws, id, bridges) {
|
|
|
365
367
|
execFileSync("tmux", ["select-window", "-t", `${viewer}:${target.windowId}`], { stdio: "ignore" });
|
|
366
368
|
} catch {
|
|
367
369
|
try {
|
|
368
|
-
execFileSync("tmux", ["kill-session", "-t", viewer], { stdio: "ignore" });
|
|
370
|
+
execFileSync("tmux", ["kill-session", "-t", `=${viewer}`], { stdio: "ignore" });
|
|
369
371
|
} catch {
|
|
370
372
|
}
|
|
371
373
|
send(ws, { t: "e", m: "could not open a tmux view for this agent" });
|
|
@@ -509,7 +511,9 @@ function createSseHub() {
|
|
|
509
511
|
let timer = null;
|
|
510
512
|
let last = "";
|
|
511
513
|
const snapshot = () => {
|
|
512
|
-
|
|
514
|
+
sweepAgentsThrottled();
|
|
515
|
+
sweepOrphanSessionsThrottled();
|
|
516
|
+
autoCleanupRuns();
|
|
513
517
|
return JSON.stringify(buildWebState());
|
|
514
518
|
};
|
|
515
519
|
const write = (res, payload) => {
|
|
@@ -742,7 +746,9 @@ async function handleRequest(req, res, ctx) {
|
|
|
742
746
|
return;
|
|
743
747
|
}
|
|
744
748
|
if (method === "GET" && path === "/api/state") {
|
|
745
|
-
|
|
749
|
+
sweepAgentsThrottled();
|
|
750
|
+
sweepOrphanSessionsThrottled();
|
|
751
|
+
autoCleanupRuns();
|
|
746
752
|
sendJson(res, 200, {
|
|
747
753
|
...buildWebState(),
|
|
748
754
|
providers: listWebProviders(),
|
|
@@ -1016,4 +1022,4 @@ async function startWebServer(options = {}) {
|
|
|
1016
1022
|
export {
|
|
1017
1023
|
startWebServer
|
|
1018
1024
|
};
|
|
1019
|
-
//# sourceMappingURL=server-
|
|
1025
|
+
//# sourceMappingURL=server-GJTDNSX7.js.map
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
installSkills,
|
|
4
|
-
skillsStatus
|
|
5
|
-
|
|
6
|
-
sweepAgentsThrottled
|
|
7
|
-
} from "./chunk-CFDTC6GY.js";
|
|
4
|
+
skillsStatus
|
|
5
|
+
} from "./chunk-YAR57K3U.js";
|
|
8
6
|
import {
|
|
9
7
|
REEVESAGENTS_VERSION,
|
|
10
8
|
createRunApproval,
|
|
11
9
|
listRunApprovals,
|
|
12
10
|
readRunApproval,
|
|
13
|
-
resolveRunApproval
|
|
14
|
-
|
|
11
|
+
resolveRunApproval,
|
|
12
|
+
sweepAgents,
|
|
13
|
+
sweepAgentsThrottled,
|
|
14
|
+
sweepOrphanSessions,
|
|
15
|
+
sweepOrphanSessionsThrottled
|
|
16
|
+
} from "./chunk-4ARHWX5G.js";
|
|
15
17
|
import {
|
|
16
18
|
ALLOWED_KEYS,
|
|
17
19
|
BIN,
|
|
@@ -49,7 +51,7 @@ import {
|
|
|
49
51
|
startRunFromPreset,
|
|
50
52
|
startRunWithHead,
|
|
51
53
|
stopRun
|
|
52
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-HHNMES47.js";
|
|
53
55
|
import "./chunk-Q3WWQP2R.js";
|
|
54
56
|
|
|
55
57
|
// src/surfaces/mcp/server.ts
|
|
@@ -319,6 +321,7 @@ var TOOLS = [
|
|
|
319
321
|
inputSchema: { type: "object", properties: {} },
|
|
320
322
|
handler: () => {
|
|
321
323
|
sweepAgentsThrottled();
|
|
324
|
+
sweepOrphanSessionsThrottled();
|
|
322
325
|
return ok(listRuns().map((run) => ({ ...run, agents: listAgents(run.id) })));
|
|
323
326
|
}
|
|
324
327
|
},
|
|
@@ -469,9 +472,9 @@ var TOOLS = [
|
|
|
469
472
|
},
|
|
470
473
|
{
|
|
471
474
|
name: "reap",
|
|
472
|
-
description: "Sweep for zombie agents and
|
|
475
|
+
description: "Sweep for zombie agents and orphan tmux sessions: ends any agent whose tmux window has died or that is older than max_lifetime_ms when that is set above 0 (see get_config), and kills reeves-*/reevesweb_* sessions no live record owns. Returns each reaped agent with the reason (window-gone or lifetime-exceeded) and its age, plus the killed orphan session names. This runs on its own in the background; call it to force an immediate sweep, e.g. after a crash or before relying on list.",
|
|
473
476
|
inputSchema: { type: "object", properties: {} },
|
|
474
|
-
handler: () => ok(sweepAgents())
|
|
477
|
+
handler: () => ok({ ...sweepAgents(), killed_sessions: sweepOrphanSessions({ ignoreGrace: true }).killed })
|
|
475
478
|
},
|
|
476
479
|
{
|
|
477
480
|
name: "get_config",
|
|
@@ -686,6 +689,10 @@ async function startAgentMcpServer() {
|
|
|
686
689
|
sweepAgents();
|
|
687
690
|
} catch {
|
|
688
691
|
}
|
|
692
|
+
try {
|
|
693
|
+
sweepOrphanSessions();
|
|
694
|
+
} catch {
|
|
695
|
+
}
|
|
689
696
|
}, BACKGROUND_REAP_INTERVAL_MS);
|
|
690
697
|
reapTimer.unref();
|
|
691
698
|
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: MCP_TOOLS }));
|
|
@@ -710,4 +717,4 @@ export {
|
|
|
710
717
|
sessionRunIsLive,
|
|
711
718
|
startAgentMcpServer
|
|
712
719
|
};
|
|
713
|
-
//# sourceMappingURL=server-
|
|
720
|
+
//# sourceMappingURL=server-KHCFIUJH.js.map
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import {
|
|
3
3
|
closeTuiWebServer,
|
|
4
4
|
startWebFromTui
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-5K4BBZMS.js";
|
|
6
6
|
export {
|
|
7
7
|
closeTuiWebServer,
|
|
8
8
|
startWebFromTui
|
|
9
9
|
};
|
|
10
|
-
//# sourceMappingURL=tui-launch-
|
|
10
|
+
//# sourceMappingURL=tui-launch-XYYH3XEY.js.map
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reevesagents",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.5",
|
|
4
4
|
"description": "Local tmux-first workspace manager for AI CLI agents",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"packageManager": "pnpm@10.34.
|
|
6
|
+
"packageManager": "pnpm@10.34.5",
|
|
7
7
|
"bin": {
|
|
8
8
|
"reevesagents": "dist/cli.js"
|
|
9
9
|
},
|
|
@@ -52,14 +52,14 @@
|
|
|
52
52
|
"body-parser": "2.3.0",
|
|
53
53
|
"brace-expansion": "5.0.9",
|
|
54
54
|
"esbuild": "0.28.1",
|
|
55
|
-
"fast-uri": "3.1.
|
|
56
|
-
"hono": "4.12.
|
|
55
|
+
"fast-uri": "3.1.5",
|
|
56
|
+
"hono": "4.12.34"
|
|
57
57
|
}
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@eslint/js": "^10.0.1",
|
|
61
61
|
"@types/node": "^25.7.0",
|
|
62
|
-
"@types/react": "19.2.
|
|
62
|
+
"@types/react": "19.2.18",
|
|
63
63
|
"@types/ws": "^8.18.1",
|
|
64
64
|
"@typescript-eslint/parser": "^8.65.0",
|
|
65
65
|
"@xterm/addon-fit": "^0.11.0",
|