reevesagents 1.7.3 → 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.
@@ -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-GSWMKYSU.js";
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-EXUYSBTC.js.map
266
+ //# sourceMappingURL=chunk-4ARHWX5G.js.map
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- // src/web/tui-launch.ts
3
+ // src/surfaces/webui/tui-launch.ts
4
4
  var handle = null;
5
5
  var pending = null;
6
6
  var launchToken = 0;
7
7
  async function startWebFromTui() {
8
8
  if (handle) {
9
- const { openBrowser } = await import("./open-browser-DRSIJQ37.js");
9
+ const { openBrowser } = await import("./open-browser-IQ5MTCWZ.js");
10
10
  openBrowser(handle.url);
11
11
  return handle.url;
12
12
  }
@@ -25,10 +25,10 @@ async function startWebFromTui() {
25
25
  }
26
26
  }
27
27
  async function startTuiWebServer() {
28
- const { checkWebExtras, webExtrasMessage } = await import("./extras-25AF6TAR.js");
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-WLXS227K.js");
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-7K3XRI7L.js.map
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-GSWMKYSU.js";
4
+ } from "./chunk-HHNMES47.js";
5
5
 
6
6
  // src/i18n/locales/en.ts
7
7
  var en = {
@@ -850,7 +850,7 @@ var de = {
850
850
  "peek interval (ms)": "Vorschau-Intervall (ms)",
851
851
  "peek lines": "Vorschau-Zeilen",
852
852
  "pending": "ausstehend",
853
- "planned public install channels": "Geplante \xF6ffentliche Installationskan\xE4le",
853
+ "public install channels": "\xD6ffentliche Installationskan\xE4le",
854
854
  "presets": "Vorlagen",
855
855
  "press Esc to go back": "Esc dr\xFCcken, um zur\xFCckzugehen",
856
856
  "provider": "Provider",
@@ -1432,7 +1432,7 @@ var fr = {
1432
1432
  "peek interval (ms)": "Intervalle d'aper\xE7u (ms)",
1433
1433
  "peek lines": "Lignes d'aper\xE7u",
1434
1434
  "pending": "en attente",
1435
- "planned public install channels": "canaux d'installation publics pr\xE9vus",
1435
+ "public install channels": "canaux d'installation publics",
1436
1436
  "presets": "pr\xE9r\xE9glages",
1437
1437
  "press Esc to go back": "appuyez sur Esc pour revenir",
1438
1438
  "provider": "fournisseur",
@@ -2026,7 +2026,7 @@ var es = {
2026
2026
  "peek interval (ms)": "Intervalo de ojeada (ms)",
2027
2027
  "peek lines": "L\xEDneas de ojeada",
2028
2028
  "pending": "pendiente",
2029
- "planned public install channels": "canales de instalaci\xF3n p\xFAblica previstos",
2029
+ "public install channels": "canales de instalaci\xF3n p\xFAblica",
2030
2030
  "presets": "preajustes",
2031
2031
  "press Esc to go back": "pulsa Esc para volver",
2032
2032
  "provider": "proveedor",
@@ -2624,7 +2624,7 @@ var pt = {
2624
2624
  "peek interval (ms)": "Intervalo de espreitadela (ms)",
2625
2625
  "peek lines": "Linhas de espreitadela",
2626
2626
  "pending": "pendente",
2627
- "planned public install channels": "canais de instala\xE7\xE3o p\xFAblica previstos",
2627
+ "public install channels": "canais de instala\xE7\xE3o p\xFAblica",
2628
2628
  "presets": "predefini\xE7\xF5es",
2629
2629
  "press Esc to go back": "prima esc para voltar",
2630
2630
  "provider": "fornecedor",
@@ -3213,7 +3213,7 @@ var it = {
3213
3213
  "peek interval (ms)": "Intervallo anteprima (ms)",
3214
3214
  "peek lines": "Righe anteprima",
3215
3215
  "pending": "in sospeso",
3216
- "planned public install channels": "canali di installazione pubblici previsti",
3216
+ "public install channels": "canali di installazione pubblici",
3217
3217
  "presets": "preset",
3218
3218
  "press Esc to go back": "premi Esc per tornare indietro",
3219
3219
  "provider agent inside the run session": "agente del provider nella sessione del run",
@@ -3805,7 +3805,7 @@ var tr = {
3805
3805
  "peek interval (ms)": "Bak\u0131\u015F aral\u0131\u011F\u0131 (ms)",
3806
3806
  "peek lines": "Bak\u0131\u015F sat\u0131rlar\u0131",
3807
3807
  "pending": "bekliyor",
3808
- "planned public install channels": "planlanan herkese a\xE7\u0131k kurulum kanallar\u0131",
3808
+ "public install channels": "herkese a\xE7\u0131k kurulum kanallar\u0131",
3809
3809
  "presets": "haz\u0131r ayarlar",
3810
3810
  "press Esc to go back": "geri d\xF6nmek i\xE7in Esc'e bas\u0131n",
3811
3811
  "provider": "sa\u011Flay\u0131c\u0131",
@@ -4059,7 +4059,7 @@ var ru = {
4059
4059
  "web.doctor": "\u0414\u0438\u0430\u0433\u043D\u043E\u0441\u0442\u0438\u043A\u0430",
4060
4060
  "web.doctorSubtitle": "\u041F\u0440\u043E\u0432\u0435\u0440\u043A\u0438 \u0441\u043E\u0441\u0442\u043E\u044F\u043D\u0438\u044F \u043E\u043A\u0440\u0443\u0436\u0435\u043D\u0438\u044F \u0434\u043B\u044F \u044D\u0442\u043E\u0439 \u043C\u0430\u0448\u0438\u043D\u044B.",
4061
4061
  "web.effort": "\u0423\u0441\u0438\u043B\u0438\u0435 \u0440\u0430\u0441\u0441\u0443\u0436\u0434\u0435\u043D\u0438\u0439",
4062
- "web.effortHelp": "\u0411\u043E\u043B\u044C\u0448\u0435 \u0443\u0441\u0438\u043B\u0438\u0439 \u2014 \u0431\u043E\u043B\u044C\u0448\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u043E\u0432 \u043D\u0430 \u0440\u0430\u0441\u0441\u0443\u0436\u0434\u0435\u043D\u0438\u044F. \u0417\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u043F\u0440\u043E\u0432\u0430\u0439\u0434\u0435\u0440\u0430 \u043F\u043E \u0443\u043C\u043E\u043B\u0447\u0430\u043D\u0438\u044E \u0431\u0435\u0437\u043E\u043F\u0430\u0441\u043D\u0435\u0435 \u0432\u0441\u0435\u0433\u043E.",
4062
+ "web.effortHelp": "\u0411\u043E\u043B\u044C\u0448\u0435 \u0443\u0441\u0438\u043B\u0438\u0439, \u0431\u043E\u043B\u044C\u0448\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u043E\u0432 \u043D\u0430 \u0440\u0430\u0441\u0441\u0443\u0436\u0434\u0435\u043D\u0438\u044F. \u0417\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u043F\u0440\u043E\u0432\u0430\u0439\u0434\u0435\u0440\u0430 \u043F\u043E \u0443\u043C\u043E\u043B\u0447\u0430\u043D\u0438\u044E \u0431\u0435\u0437\u043E\u043F\u0430\u0441\u043D\u0435\u0435 \u0432\u0441\u0435\u0433\u043E.",
4063
4063
  "web.effortHigh": "\u0412\u044B\u0441\u043E\u043A\u043E\u0435",
4064
4064
  "web.effortLow": "\u041D\u0438\u0437\u043A\u043E\u0435",
4065
4065
  "web.effortMax": "\u041C\u0430\u043A\u0441\u0438\u043C\u0430\u043B\u044C\u043D\u043E\u0435",
@@ -4352,8 +4352,8 @@ var ru = {
4352
4352
  "count": "\u043A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E",
4353
4353
  "create a run with one or more agents": "\u0441\u043E\u0437\u0434\u0430\u0442\u044C run \u0441 \u043E\u0434\u043D\u0438\u043C \u0438\u043B\u0438 \u043D\u0435\u0441\u043A\u043E\u043B\u044C\u043A\u0438\u043C\u0438 \u0430\u0433\u0435\u043D\u0442\u0430\u043C\u0438",
4354
4354
  "dashboard, lifecycle, agents, output": "\u043F\u0430\u043D\u0435\u043B\u044C, \u0436\u0438\u0437\u043D\u0435\u043D\u043D\u044B\u0439 \u0446\u0438\u043A\u043B, \u0430\u0433\u0435\u043D\u0442\u044B, \u0432\u044B\u0432\u043E\u0434",
4355
- "defaults to the run working dir": "\u043F\u043E \u0443\u043C\u043E\u043B\u0447\u0430\u043D\u0438\u044E \u2014 \u0440\u0430\u0431\u043E\u0447\u0430\u044F \u043F\u0430\u043F\u043A\u0430 run",
4356
- "defaults to where you ran reevesagents": "\u043F\u043E \u0443\u043C\u043E\u043B\u0447\u0430\u043D\u0438\u044E \u2014 \u043F\u0430\u043F\u043A\u0430, \u043E\u0442\u043A\u0443\u0434\u0430 \u0437\u0430\u043F\u0443\u0449\u0435\u043D reevesagents",
4355
+ "defaults to the run working dir": "\u043F\u043E \u0443\u043C\u043E\u043B\u0447\u0430\u043D\u0438\u044E: \u0440\u0430\u0431\u043E\u0447\u0430\u044F \u043F\u0430\u043F\u043A\u0430 run",
4356
+ "defaults to where you ran reevesagents": "\u043F\u043E \u0443\u043C\u043E\u043B\u0447\u0430\u043D\u0438\u044E: \u043F\u0430\u043F\u043A\u0430, \u043E\u0442\u043A\u0443\u0434\u0430 \u0437\u0430\u043F\u0443\u0449\u0435\u043D reevesagents",
4357
4357
  "default permissions": "\u0420\u0430\u0437\u0440\u0435\u0448\u0435\u043D\u0438\u044F \u043F\u043E \u0443\u043C\u043E\u043B\u0447\u0430\u043D\u0438\u044E",
4358
4358
  "delete and return": "\u0443\u0434\u0430\u043B\u0438\u0442\u044C \u0438 \u0432\u0435\u0440\u043D\u0443\u0442\u044C\u0441\u044F",
4359
4359
  "delete archived run": "\u0443\u0434\u0430\u043B\u0438\u0442\u044C \u0430\u0440\u0445\u0438\u0432\u043D\u044B\u0439 run",
@@ -4398,14 +4398,14 @@ var ru = {
4398
4398
  "ok": "\u043E\u043A",
4399
4399
  "open the visible-menu TUI": "\u043E\u0442\u043A\u0440\u044B\u0442\u044C TUI \u0441 \u043C\u0435\u043D\u044E",
4400
4400
  "optional initial prompt \xB7 enter newline \xB7 esc done": "\u043D\u0435\u043E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u044B\u0439 \u043D\u0430\u0447\u0430\u043B\u044C\u043D\u044B\u0439 \u043F\u0440\u043E\u043C\u043F\u0442 \xB7 enter \u043D\u043E\u0432\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430 \xB7 esc \u0433\u043E\u0442\u043E\u0432\u043E",
4401
- "optional \xB7 blank uses provider default": "\u043D\u0435\u043E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E \xB7 \u043F\u0443\u0441\u0442\u043E \u2014 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u043F\u0440\u043E\u0432\u0430\u0439\u0434\u0435\u0440\u0430 \u043F\u043E \u0443\u043C\u043E\u043B\u0447\u0430\u043D\u0438\u044E",
4402
- "optional, defaults to the run working dir": "\u043D\u0435\u043E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E, \u043F\u043E \u0443\u043C\u043E\u043B\u0447\u0430\u043D\u0438\u044E \u2014 \u0440\u0430\u0431\u043E\u0447\u0430\u044F \u043F\u0430\u043F\u043A\u0430 run",
4401
+ "optional \xB7 blank uses provider default": "\u043D\u0435\u043E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E \xB7 \u043F\u0443\u0441\u0442\u043E: \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u043F\u0440\u043E\u0432\u0430\u0439\u0434\u0435\u0440\u0430 \u043F\u043E \u0443\u043C\u043E\u043B\u0447\u0430\u043D\u0438\u044E",
4402
+ "optional, defaults to the run working dir": "\u043D\u0435\u043E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E, \u043F\u043E \u0443\u043C\u043E\u043B\u0447\u0430\u043D\u0438\u044E: \u0440\u0430\u0431\u043E\u0447\u0430\u044F \u043F\u0430\u043F\u043A\u0430 run",
4403
4403
  "peek across agents": "\u043F\u0440\u043E\u0441\u043C\u043E\u0442\u0440\u0435\u0442\u044C \u0432\u044B\u0432\u043E\u0434 \u0430\u0433\u0435\u043D\u0442\u043E\u0432",
4404
4404
  "peek across all agents": "\u043F\u0440\u043E\u0441\u043C\u043E\u0442\u0440\u0435\u0442\u044C \u0432\u044B\u0432\u043E\u0434 \u0432\u0441\u0435\u0445 \u0430\u0433\u0435\u043D\u0442\u043E\u0432",
4405
4405
  "peek interval (ms)": "\u0418\u043D\u0442\u0435\u0440\u0432\u0430\u043B \u043F\u0440\u043E\u0441\u043C\u043E\u0442\u0440\u0430 (\u043C\u0441)",
4406
4406
  "peek lines": "\u0421\u0442\u0440\u043E\u043A \u043F\u0440\u043E\u0441\u043C\u043E\u0442\u0440\u0430",
4407
4407
  "pending": "\u043E\u0436\u0438\u0434\u0430\u0435\u0442",
4408
- "planned public install channels": "\u0437\u0430\u043F\u043B\u0430\u043D\u0438\u0440\u043E\u0432\u0430\u043D\u043D\u044B\u0435 \u043A\u0430\u043D\u0430\u043B\u044B \u043F\u0443\u0431\u043B\u0438\u0447\u043D\u043E\u0439 \u0443\u0441\u0442\u0430\u043D\u043E\u0432\u043A\u0438",
4408
+ "public install channels": "\u043A\u0430\u043D\u0430\u043B\u044B \u043F\u0443\u0431\u043B\u0438\u0447\u043D\u043E\u0439 \u0443\u0441\u0442\u0430\u043D\u043E\u0432\u043A\u0438",
4409
4409
  "presets": "\u043F\u0440\u0435\u0441\u0435\u0442\u044B",
4410
4410
  "press Esc to go back": "\u043D\u0430\u0436\u043C\u0438\u0442\u0435 Esc, \u0447\u0442\u043E\u0431\u044B \u0432\u0435\u0440\u043D\u0443\u0442\u044C\u0441\u044F",
4411
4411
  "provider": "\u043F\u0440\u043E\u0432\u0430\u0439\u0434\u0435\u0440",
@@ -5008,7 +5008,7 @@ var zhHans = {
5008
5008
  "peek interval (ms)": "\u67E5\u770B\u95F4\u9694 (ms)",
5009
5009
  "peek lines": "\u67E5\u770B\u884C\u6570",
5010
5010
  "pending": "\u5F85\u5904\u7406",
5011
- "planned public install channels": "\u8BA1\u5212\u4E2D\u7684\u516C\u5F00\u5B89\u88C5\u6E20\u9053",
5011
+ "public install channels": "\u516C\u5F00\u5B89\u88C5\u6E20\u9053",
5012
5012
  "presets": "\u9884\u8BBE",
5013
5013
  "press Esc to go back": "\u6309 esc \u8FD4\u56DE",
5014
5014
  "provider": "\u670D\u52A1\u5546",
@@ -5612,7 +5612,7 @@ var ar = {
5612
5612
  "peek interval (ms)": "\u0641\u062A\u0631\u0629 \u0627\u0644\u0627\u0637\u0651\u0644\u0627\u0639 (ms)",
5613
5613
  "peek lines": "\u0623\u0633\u0637\u0631 \u0627\u0644\u0627\u0637\u0651\u0644\u0627\u0639",
5614
5614
  "pending": "\u0645\u0639\u0644\u0651\u0642",
5615
- "planned public install channels": "\u0642\u0646\u0648\u0627\u062A \u0627\u0644\u062A\u062B\u0628\u064A\u062A \u0627\u0644\u0639\u0627\u0645\u0629 \u0627\u0644\u0645\u062E\u0637\u0651\u0637\u0629",
5615
+ "public install channels": "\u0642\u0646\u0648\u0627\u062A \u0627\u0644\u062A\u062B\u0628\u064A\u062A \u0627\u0644\u0639\u0627\u0645\u0629",
5616
5616
  "presets": "\u0625\u0639\u062F\u0627\u062F\u0627\u062A \u062C\u0627\u0647\u0632\u0629",
5617
5617
  "press Esc to go back": "\u0627\u0636\u063A\u0637 Esc \u0644\u0644\u0631\u062C\u0648\u0639",
5618
5618
  "provider": "\u0627\u0644\u0645\u0632\u0648\u0651\u062F",
@@ -5712,4 +5712,4 @@ export {
5712
5712
  localeCatalog,
5713
5713
  translatePhrase
5714
5714
  };
5715
- //# sourceMappingURL=chunk-OVNVE2TJ.js.map
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-GSWMKYSU.js";
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-GNS5ULTD.js.map
30
+ //# sourceMappingURL=chunk-EZJQYBYP.js.map
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  WEB_EXTRA_MODULES
4
- } from "./chunk-D24DQQ6V.js";
4
+ } from "./chunk-Q3WWQP2R.js";
5
5
 
6
6
  // src/core/model-data.ts
7
7
  var CC_MODEL_SOURCE = "curated Claude Code aliases";
@@ -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 sleepSync(ms) {
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
- sleepSync(25);
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
- const isStale = !isEnded && haveTmux && !runHasLiveTmuxTarget(run, { sessionExists: sessionExists2, targetExists: targetExists2 });
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 sleepSync2(ms) {
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) sleepSync2(POST_PASTE_ENTER_DELAY_MS);
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
- return { windowId, paneId };
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) sleepSync2(remaining);
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
- if (windowInSession(driver, agent.tmux_session, agent.tmux_window_id)) {
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 };
@@ -1843,7 +1982,7 @@ function openTmuxTarget(id, options = {}) {
1843
1982
  return { session, window, label };
1844
1983
  }
1845
1984
 
1846
- // src/mcp/installer.ts
1985
+ // src/surfaces/mcp/installer.ts
1847
1986
  import { execFileSync as execFileSync3 } from "child_process";
1848
1987
  import { realpathSync, readFileSync as readFileSync4, writeFileSync as writeFileSync4, existsSync as existsSync4, mkdirSync as mkdirSync4 } from "fs";
1849
1988
  import { homedir as homedir4 } from "os";
@@ -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-GSWMKYSU.js.map
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-JX6SHZKB.js";
4
+ } from "./chunk-YAR57K3U.js";
5
5
  import {
6
6
  attachAll,
7
7
  checkTmux,
@@ -11,9 +11,9 @@ import {
11
11
  resolveLaunchCmd,
12
12
  stateRoot,
13
13
  verifyServerLaunch
14
- } from "./chunk-GSWMKYSU.js";
14
+ } from "./chunk-HHNMES47.js";
15
15
 
16
- // src/tui/open-token.ts
16
+ // src/surfaces/tui/open-token.ts
17
17
  import { mkdirSync, readFileSync, writeFileSync } from "fs";
18
18
  import { join } from "path";
19
19
  function tokenPath() {
@@ -67,4 +67,4 @@ export {
67
67
  runOnboarding,
68
68
  suggestedAgentPrompt
69
69
  };
70
- //# sourceMappingURL=chunk-MKNSEZTG.js.map
70
+ //# sourceMappingURL=chunk-MEIFYC3B.js.map
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- // src/web/extras.ts
3
+ // src/surfaces/webui/extras.ts
4
4
  var WEB_EXTRA_MODULES = ["ws", "@lydell/node-pty"];
5
5
  async function checkWebExtras() {
6
6
  const missing = [];
@@ -33,4 +33,4 @@ export {
33
33
  checkWebExtras,
34
34
  webExtrasMessage
35
35
  };
36
- //# sourceMappingURL=chunk-D24DQQ6V.js.map
36
+ //# sourceMappingURL=chunk-Q3WWQP2R.js.map