agent-yes 1.177.1 → 1.177.3

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.
@@ -0,0 +1,8 @@
1
+ import "./ts-CMv9I9mN.js";
2
+ import "./logger-CDIsZ-Pp.js";
3
+ import "./versionChecker-JwWyeRyM.js";
4
+ import "./pidStore-BIvsBQ8X.js";
5
+ import "./globalPidIndex-CoNr7tS8.js";
6
+ import { t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-HqRiNZTN.js";
7
+
8
+ export { SUPPORTED_CLIS };
@@ -1,8 +1,8 @@
1
- import { t as CLIS_CONFIG } from "./ts-DsSOwxe2.js";
1
+ import { t as CLIS_CONFIG } from "./ts-CMv9I9mN.js";
2
2
 
3
3
  //#region ts/SUPPORTED_CLIS.ts
4
4
  const SUPPORTED_CLIS = Object.keys(CLIS_CONFIG);
5
5
 
6
6
  //#endregion
7
7
  export { SUPPORTED_CLIS as t };
8
- //# sourceMappingURL=SUPPORTED_CLIS-rXoXMD10.js.map
8
+ //# sourceMappingURL=SUPPORTED_CLIS-HqRiNZTN.js.map
@@ -1,7 +1,7 @@
1
1
  import "./logger-CDIsZ-Pp.js";
2
2
  import "./globalPidIndex-CoNr7tS8.js";
3
3
  import "./configShared-0MnIQ652.js";
4
- import { j as resolveOne } from "./subcommands-4yuXYKaw.js";
4
+ import { j as resolveOne } from "./subcommands-BwjcLKP-.js";
5
5
  import "./e2e-BeKjLhmO.js";
6
6
  import "./webrtcLink-BG0Xc4-W.js";
7
7
  import "./remotes-DsTnQhyx.js";
@@ -228,4 +228,4 @@ function transformEvent(rawEvent, agentId, forwarded) {
228
228
 
229
229
  //#endregion
230
230
  export { createScopedShare, listShares, revokeAllShares, revokeShare };
231
- //# sourceMappingURL=agentShare-BmqMHyq4.js.map
231
+ //# sourceMappingURL=agentShare-aGYbqc3C.js.map
package/dist/cli.js CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env bun
2
2
  import { t as invokedCliName } from "./invokedCli-uqM2YYA7.js";
3
3
  import { n as logger } from "./logger-CDIsZ-Pp.js";
4
- import { i as versionString, n as displayVersion, t as checkAndAutoUpdate } from "./versionChecker-DOi2Sthf.js";
5
- import { n as getRustBinary } from "./rustBinary-lxyUv4Rq.js";
4
+ import { i as versionString, n as displayVersion, t as checkAndAutoUpdate } from "./versionChecker-JwWyeRyM.js";
5
+ import { n as getRustBinary } from "./rustBinary-Debn0Aks.js";
6
6
  import { argv } from "process";
7
7
  import { spawn } from "child_process";
8
8
  import ms from "ms";
@@ -285,7 +285,7 @@ function buildRustArgs(argv, cliFromScript, supportedClis) {
285
285
  const rawArg = process.argv[2];
286
286
  const managerCommands = !invokedCliName(process.argv);
287
287
  const isHelpFlag = rawArg === "-h" || rawArg === "--help";
288
- const { isSubcommand, runSubcommand, cmdHelp } = await import("./subcommands-C8ZzwPvy.js");
288
+ const { isSubcommand, runSubcommand, cmdHelp } = await import("./subcommands-BpeOn_YE.js");
289
289
  if (isHelpFlag && process.argv.length === 3) {
290
290
  await cmdHelp(managerCommands);
291
291
  process.exit(0);
@@ -327,7 +327,7 @@ if (config.useRust) {
327
327
  }
328
328
  }
329
329
  if (rustBinary) {
330
- const { SUPPORTED_CLIS } = await import("./SUPPORTED_CLIS-C8qCd1ge.js");
330
+ const { SUPPORTED_CLIS } = await import("./SUPPORTED_CLIS-CQQOIxMn.js");
331
331
  const rustArgs = buildRustArgs(process.argv, config.cli, SUPPORTED_CLIS);
332
332
  if (config.verbose) {
333
333
  console.log(`[rust] Using binary: ${rustBinary}`);
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { a as removeControlCharacters, i as AgentContext, n as agentYes, r as config, t as CLIS_CONFIG } from "./ts-DsSOwxe2.js";
1
+ import { a as removeControlCharacters, i as AgentContext, n as agentYes, r as config, t as CLIS_CONFIG } from "./ts-CMv9I9mN.js";
2
2
  import "./logger-CDIsZ-Pp.js";
3
- import "./versionChecker-DOi2Sthf.js";
3
+ import "./versionChecker-JwWyeRyM.js";
4
4
  import "./pidStore-BIvsBQ8X.js";
5
5
  import "./globalPidIndex-CoNr7tS8.js";
6
6
 
@@ -1,7 +1,7 @@
1
1
  import { n as logger } from "./logger-CDIsZ-Pp.js";
2
2
  import "./globalPidIndex-CoNr7tS8.js";
3
3
  import "./configShared-0MnIQ652.js";
4
- import { G as hostId, J as readInbox, K as listInboxParents, O as renderLogTailLines, Q as notifyDir, S as listRecords, U as appendEvent, W as gcInboxes, X as daemonLockDir, Y as shouldStealLock, Z as daemonLockOwnerPath, _ as isPidAlive, c as deriveLiveState, q as liveWatchers } from "./subcommands-4yuXYKaw.js";
4
+ import { G as hostId, J as readInbox, K as listInboxParents, O as renderLogTailLines, Q as notifyDir, S as listRecords, U as appendEvent, W as gcInboxes, X as daemonLockDir, Y as shouldStealLock, Z as daemonLockOwnerPath, _ as isPidAlive, c as deriveLiveState, q as liveWatchers } from "./subcommands-BwjcLKP-.js";
5
5
  import "./e2e-BeKjLhmO.js";
6
6
  import "./webrtcLink-BG0Xc4-W.js";
7
7
  import "./remotes-DsTnQhyx.js";
@@ -588,4 +588,4 @@ async function ensureDaemon() {
588
588
 
589
589
  //#endregion
590
590
  export { daemonStatus, ensureDaemon, requestDaemonStop, runDaemon };
591
- //# sourceMappingURL=notifyDaemon-D5BEsoJs.js.map
591
+ //# sourceMappingURL=notifyDaemon-CgvMP8jE.js.map
@@ -1,4 +1,4 @@
1
- import { r as getInstalledPackage } from "./versionChecker-DOi2Sthf.js";
1
+ import { r as getInstalledPackage } from "./versionChecker-JwWyeRyM.js";
2
2
  import { execFileSync } from "child_process";
3
3
  import { existsSync, mkdirSync, unlinkSync } from "fs";
4
4
  import { chmod, copyFile } from "fs/promises";
@@ -225,4 +225,4 @@ async function getRustBinary(options = {}) {
225
225
 
226
226
  //#endregion
227
227
  export { getRustBinary as n, findSpawnHiddenLauncher as t };
228
- //# sourceMappingURL=rustBinary-lxyUv4Rq.js.map
228
+ //# sourceMappingURL=rustBinary-Debn0Aks.js.map
@@ -1,9 +1,9 @@
1
- import "./ts-DsSOwxe2.js";
1
+ import "./ts-CMv9I9mN.js";
2
2
  import "./logger-CDIsZ-Pp.js";
3
- import "./versionChecker-DOi2Sthf.js";
3
+ import "./versionChecker-JwWyeRyM.js";
4
4
  import "./pidStore-BIvsBQ8X.js";
5
5
  import "./globalPidIndex-CoNr7tS8.js";
6
- import { t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-rXoXMD10.js";
6
+ import { t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-HqRiNZTN.js";
7
7
  import { d as resolveSpawnCwd } from "./workspaceConfig-DKd6UvVm.js";
8
8
  import { createHash } from "node:crypto";
9
9
 
@@ -141,4 +141,4 @@ async function cmdSchedule(rest) {
141
141
 
142
142
  //#endregion
143
143
  export { cmdSchedule };
144
- //# sourceMappingURL=schedule-DpGs0P37.js.map
144
+ //# sourceMappingURL=schedule-gkLUdn9f.js.map
@@ -1,13 +1,13 @@
1
- import "./ts-DsSOwxe2.js";
1
+ import "./ts-CMv9I9mN.js";
2
2
  import "./logger-CDIsZ-Pp.js";
3
- import { r as getInstalledPackage } from "./versionChecker-DOi2Sthf.js";
4
- import { t as findSpawnHiddenLauncher } from "./rustBinary-lxyUv4Rq.js";
3
+ import { r as getInstalledPackage } from "./versionChecker-JwWyeRyM.js";
4
+ import { t as findSpawnHiddenLauncher } from "./rustBinary-Debn0Aks.js";
5
5
  import "./pidStore-BIvsBQ8X.js";
6
6
  import { a as updateGlobalPidStatus } from "./globalPidIndex-CoNr7tS8.js";
7
7
  import { t as pgidForWrapper } from "./reaper-CWF2_ATd.js";
8
8
  import "./configShared-0MnIQ652.js";
9
- import { t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-rXoXMD10.js";
10
- import { $ as TYPING_BADGE, D as recentReadEdges, E as readPtysize, H as writeToIpc, I as snapshotStatus, S as listRecords, T as readNotes, b as isUserTyping, f as extractNeedsInput, j as resolveOne, k as renderRawLog, l as deriveLiveStatus, o as controlCodeFromName, p as extractTaskCounts, u as extractBadges } from "./subcommands-4yuXYKaw.js";
9
+ import { t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-HqRiNZTN.js";
10
+ import { $ as TYPING_BADGE, D as recentReadEdges, E as readPtysize, H as writeToIpc, I as snapshotStatus, S as listRecords, T as readNotes, b as isUserTyping, f as extractNeedsInput, j as resolveOne, k as renderRawLog, l as deriveLiveStatus, o as controlCodeFromName, p as extractTaskCounts, u as extractBadges } from "./subcommands-BwjcLKP-.js";
11
11
  import "./e2e-BeKjLhmO.js";
12
12
  import "./webrtcLink-BG0Xc4-W.js";
13
13
  import "./remotes-DsTnQhyx.js";
@@ -1179,13 +1179,27 @@ Options:
1179
1179
  const ctrlRe = /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g;
1180
1180
  const fh = await open(logPath, "r").catch(() => null);
1181
1181
  let reading = false;
1182
- const flush = async () => {
1182
+ const flush = async (viaPoll = false) => {
1183
1183
  if (closed || reading || !fh) return;
1184
1184
  reading = true;
1185
1185
  try {
1186
1186
  const { size } = await fh.stat();
1187
1187
  if (size < offset) offset = size;
1188
1188
  if (size > offset) {
1189
+ if (viaPoll && watcher && !demoteCheck && Date.now() - lastWatcherFireAt > POLL_WATCHED - 50) {
1190
+ const suspectAt = Date.now();
1191
+ demoteCheck = setTimeout(() => {
1192
+ demoteCheck = null;
1193
+ if (closed || !watcher) return;
1194
+ if (lastWatcherFireAt >= suspectAt) return;
1195
+ try {
1196
+ watcher.close();
1197
+ } catch {}
1198
+ watcher = null;
1199
+ clearInterval(poller);
1200
+ poller = setInterval(() => void flush(true), POLL_UNWATCHED);
1201
+ }, 100);
1202
+ }
1189
1203
  const len = size - offset;
1190
1204
  const buf = Buffer.allocUnsafe(len);
1191
1205
  const { bytesRead } = await fh.read(buf, 0, len, offset);
@@ -1201,16 +1215,24 @@ Options:
1201
1215
  reading = false;
1202
1216
  }
1203
1217
  };
1218
+ let lastWatcherFireAt = Date.now();
1219
+ let demoteCheck = null;
1204
1220
  let watcher = null;
1205
1221
  try {
1206
- watcher = watch(logPath, () => void flush());
1222
+ watcher = watch(logPath, () => {
1223
+ lastWatcherFireAt = Date.now();
1224
+ flush();
1225
+ });
1207
1226
  } catch {}
1208
- const poller = setInterval(() => void flush(), watcher ? 500 : 60);
1227
+ const POLL_WATCHED = 500;
1228
+ const POLL_UNWATCHED = 60;
1229
+ let poller = setInterval(() => void flush(true), watcher ? POLL_WATCHED : POLL_UNWATCHED);
1209
1230
  cleanup = () => {
1210
1231
  if (closed) return;
1211
1232
  closed = true;
1212
1233
  clearInterval(heartbeat);
1213
1234
  clearInterval(poller);
1235
+ if (demoteCheck) clearTimeout(demoteCheck);
1214
1236
  try {
1215
1237
  watcher?.close();
1216
1238
  } catch {}
@@ -1583,7 +1605,7 @@ Options:
1583
1605
  const perm = body.perm ?? "r";
1584
1606
  if (perm !== "r" && perm !== "rw") return new Response(`invalid perm ${perm} (want r or rw)`, { status: 400 });
1585
1607
  try {
1586
- const { createScopedShare } = await import("./agentShare-BmqMHyq4.js");
1608
+ const { createScopedShare } = await import("./agentShare-aGYbqc3C.js");
1587
1609
  const share = await createScopedShare({
1588
1610
  agent: body.agent,
1589
1611
  perm,
@@ -1598,12 +1620,12 @@ Options:
1598
1620
  }
1599
1621
  }
1600
1622
  if (req.method === "GET" && p === "/api/shares") {
1601
- const { listShares } = await import("./agentShare-BmqMHyq4.js");
1623
+ const { listShares } = await import("./agentShare-aGYbqc3C.js");
1602
1624
  return Response.json(listShares());
1603
1625
  }
1604
1626
  const revokeM = /^\/api\/share\/([^/]+)$/.exec(p);
1605
1627
  if (req.method === "DELETE" && revokeM) {
1606
- const { revokeShare } = await import("./agentShare-BmqMHyq4.js");
1628
+ const { revokeShare } = await import("./agentShare-aGYbqc3C.js");
1607
1629
  const ok = revokeShare(decodeURIComponent(revokeM[1]));
1608
1630
  return new Response(ok ? "revoked" : "no such share", { status: ok ? 200 : 404 });
1609
1631
  }
@@ -1743,7 +1765,7 @@ Options:
1743
1765
  const shutdown = (resolve) => {
1744
1766
  if (heartbeat) clearInterval(heartbeat);
1745
1767
  closeShare?.();
1746
- import("./agentShare-BmqMHyq4.js").then((m) => m.revokeAllShares()).catch(() => {});
1768
+ import("./agentShare-aGYbqc3C.js").then((m) => m.revokeAllShares()).catch(() => {});
1747
1769
  server?.stop();
1748
1770
  resolve();
1749
1771
  };
@@ -1756,4 +1778,4 @@ Options:
1756
1778
 
1757
1779
  //#endregion
1758
1780
  export { cmdServe };
1759
- //# sourceMappingURL=serve-DfVcrSoz.js.map
1781
+ //# sourceMappingURL=serve-DSxebHP8.js.map
@@ -32,7 +32,7 @@ async function cmdSetup(rest) {
32
32
  if (!existsSync(abs)) process.stderr.write(` note: that directory doesn't exist yet — create it, or agents spawned there will fail\n`);
33
33
  if (noShare) return 0;
34
34
  process.stdout.write(`\nsharing this machine to agent-yes.com…\n`);
35
- const { cmdServe } = await import("./serve-DfVcrSoz.js");
35
+ const { cmdServe } = await import("./serve-DSxebHP8.js");
36
36
  return cmdServe([
37
37
  "install",
38
38
  "--share",
@@ -42,4 +42,4 @@ async function cmdSetup(rest) {
42
42
 
43
43
  //#endregion
44
44
  export { cmdSetup };
45
- //# sourceMappingURL=setup-BmKEO1VC.js.map
45
+ //# sourceMappingURL=setup-6hzNooaJ.js.map
@@ -1,7 +1,7 @@
1
1
  import "./logger-CDIsZ-Pp.js";
2
2
  import "./globalPidIndex-CoNr7tS8.js";
3
3
  import "./configShared-0MnIQ652.js";
4
- import { A as renderRawLogLines, B as waitForLogQuiet, C as matchKeyword, D as recentReadEdges, E as readPtysize, F as runSubcommand, H as writeToIpc, I as snapshotStatus, L as stdinActivityPath, M as resolveReadWindow, N as resolveResumeArgs, O as renderLogTailLines, P as restartHintLines, R as stopTipForCli, S as listRecords, T as readNotes, V as writeKeysPaced, _ as isPidAlive, a as cmdHelp, b as isUserTyping, c as deriveLiveState, d as extractMenu, f as extractNeedsInput, g as isExitRequest, h as isAgentStuck, i as backoffWhileTyping, j as resolveOne, k as renderRawLog, l as deriveLiveStatus, m as finalizedLines, n as READ_PAGE_DEFAULT, o as controlCodeFromName, p as extractTaskCounts, r as TYPING_WINDOW_MS, s as cursorAbs, t as GRACEFUL_EXIT_COMMANDS, u as extractBadges, v as isSlashCommand, w as menuSelectKeys, x as lastStdinAt, y as isSubcommand, z as submitAndConfirm } from "./subcommands-4yuXYKaw.js";
4
+ import { A as renderRawLogLines, B as waitForLogQuiet, C as matchKeyword, D as recentReadEdges, E as readPtysize, F as runSubcommand, H as writeToIpc, I as snapshotStatus, L as stdinActivityPath, M as resolveReadWindow, N as resolveResumeArgs, O as renderLogTailLines, P as restartHintLines, R as stopTipForCli, S as listRecords, T as readNotes, V as writeKeysPaced, _ as isPidAlive, a as cmdHelp, b as isUserTyping, c as deriveLiveState, d as extractMenu, f as extractNeedsInput, g as isExitRequest, h as isAgentStuck, i as backoffWhileTyping, j as resolveOne, k as renderRawLog, l as deriveLiveStatus, m as finalizedLines, n as READ_PAGE_DEFAULT, o as controlCodeFromName, p as extractTaskCounts, r as TYPING_WINDOW_MS, s as cursorAbs, t as GRACEFUL_EXIT_COMMANDS, u as extractBadges, v as isSlashCommand, w as menuSelectKeys, x as lastStdinAt, y as isSubcommand, z as submitAndConfirm } from "./subcommands-BwjcLKP-.js";
5
5
  import "./e2e-BeKjLhmO.js";
6
6
  import "./webrtcLink-BG0Xc4-W.js";
7
7
  import "./remotes-DsTnQhyx.js";
@@ -1145,15 +1145,15 @@ async function runSubcommand(argv) {
1145
1145
  case "restart": return await cmdRestart(rest);
1146
1146
  case "note": return await cmdNote(rest);
1147
1147
  case "serve": {
1148
- const { cmdServe } = await import("./serve-DfVcrSoz.js");
1148
+ const { cmdServe } = await import("./serve-DSxebHP8.js");
1149
1149
  return cmdServe(rest);
1150
1150
  }
1151
1151
  case "setup": {
1152
- const { cmdSetup } = await import("./setup-BmKEO1VC.js");
1152
+ const { cmdSetup } = await import("./setup-6hzNooaJ.js");
1153
1153
  return cmdSetup(rest);
1154
1154
  }
1155
1155
  case "schedule": {
1156
- const { cmdSchedule } = await import("./schedule-DpGs0P37.js");
1156
+ const { cmdSchedule } = await import("./schedule-gkLUdn9f.js");
1157
1157
  return cmdSchedule(rest);
1158
1158
  }
1159
1159
  case "remote": {
@@ -3991,7 +3991,7 @@ async function cmdNotify(rest) {
3991
3991
  }
3992
3992
  const ensure = async () => {
3993
3993
  if (!argv["ensure-daemon"]) return;
3994
- const { ensureDaemon } = await import("./notifyDaemon-D5BEsoJs.js");
3994
+ const { ensureDaemon } = await import("./notifyDaemon-CgvMP8jE.js");
3995
3995
  await ensureDaemon().catch(() => null);
3996
3996
  };
3997
3997
  await heartbeatWatcher(parent, selfStartedAt);
@@ -4065,7 +4065,7 @@ async function cmdNotifyCursor(args) {
4065
4065
  }
4066
4066
  async function cmdNotifyd(rest) {
4067
4067
  const sub = rest[0] ?? "status";
4068
- const daemon = await import("./notifyDaemon-D5BEsoJs.js");
4068
+ const daemon = await import("./notifyDaemon-CgvMP8jE.js");
4069
4069
  switch (sub) {
4070
4070
  case "run": return daemon.runDaemon();
4071
4071
  case "once": return daemon.runDaemon({ once: true });
@@ -4092,4 +4092,4 @@ async function cmdNotifyd(rest) {
4092
4092
 
4093
4093
  //#endregion
4094
4094
  export { TYPING_BADGE as $, renderRawLogLines as A, waitForLogQuiet as B, matchKeyword as C, recentReadEdges as D, readPtysize as E, runSubcommand as F, hostId as G, writeToIpc as H, snapshotStatus as I, readInbox as J, listInboxParents as K, stdinActivityPath as L, resolveReadWindow as M, resolveResumeArgs as N, renderLogTailLines as O, restartHintLines as P, notifyDir as Q, stopTipForCli as R, listRecords as S, readNotes as T, appendEvent as U, writeKeysPaced as V, gcInboxes as W, daemonLockDir as X, shouldStealLock as Y, daemonLockOwnerPath as Z, isPidAlive as _, cmdHelp as a, isUserTyping as b, deriveLiveState as c, extractMenu as d, extractNeedsInput as f, isExitRequest as g, isAgentStuck as h, backoffWhileTyping as i, resolveOne as j, renderRawLog as k, deriveLiveStatus as l, finalizedLines as m, READ_PAGE_DEFAULT as n, controlCodeFromName as o, extractTaskCounts as p, liveWatchers as q, TYPING_WINDOW_MS as r, cursorAbs as s, GRACEFUL_EXIT_COMMANDS as t, extractBadges as u, isSlashCommand as v, menuSelectKeys as w, lastStdinAt as x, isSubcommand as y, submitAndConfirm as z };
4095
- //# sourceMappingURL=subcommands-4yuXYKaw.js.map
4095
+ //# sourceMappingURL=subcommands-BwjcLKP-.js.map
@@ -1,5 +1,5 @@
1
1
  import { n as logger, t as addTransport } from "./logger-CDIsZ-Pp.js";
2
- import { r as getInstalledPackage } from "./versionChecker-DOi2Sthf.js";
2
+ import { r as getInstalledPackage } from "./versionChecker-JwWyeRyM.js";
3
3
  import { t as agentYesHome } from "./agentYesHome-CtHb5b71.js";
4
4
  import { i as shouldUseLock, r as releaseLock, t as acquireLock } from "./runningLock-CNMl13dC.js";
5
5
  import { t as PidStore } from "./pidStore-BIvsBQ8X.js";
@@ -1824,4 +1824,4 @@ function sleep(ms) {
1824
1824
 
1825
1825
  //#endregion
1826
1826
  export { removeControlCharacters as a, AgentContext as i, agentYes as n, config as r, CLIS_CONFIG as t };
1827
- //# sourceMappingURL=ts-DsSOwxe2.js.map
1827
+ //# sourceMappingURL=ts-CMv9I9mN.js.map
@@ -7,7 +7,7 @@ import { fileURLToPath } from "url";
7
7
 
8
8
  //#region package.json
9
9
  var name = "agent-yes";
10
- var version = "1.177.1";
10
+ var version = "1.177.3";
11
11
 
12
12
  //#endregion
13
13
  //#region ts/versionChecker.ts
@@ -215,4 +215,4 @@ async function displayVersion() {
215
215
 
216
216
  //#endregion
217
217
  export { versionString as i, displayVersion as n, getInstalledPackage as r, checkAndAutoUpdate as t };
218
- //# sourceMappingURL=versionChecker-DOi2Sthf.js.map
218
+ //# sourceMappingURL=versionChecker-JwWyeRyM.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-yes",
3
- "version": "1.177.1",
3
+ "version": "1.177.3",
4
4
  "description": "A wrapper tool that automates interactions with various AI CLI tools by automatically handling common prompts and responses.",
5
5
  "keywords": [
6
6
  "ai",
package/ts/serve.ts CHANGED
@@ -1759,13 +1759,41 @@ export async function cmdServe(rest: string[]): Promise<number> {
1759
1759
  // 300 ms full-file poll was the dominant typing-echo latency.
1760
1760
  const fh = await open(logPath, "r").catch(() => null);
1761
1761
  let reading = false;
1762
- const flush = async () => {
1762
+ const flush = async (viaPoll = false) => {
1763
1763
  if (closed || reading || !fh) return;
1764
1764
  reading = true;
1765
1765
  try {
1766
1766
  const { size } = await fh.stat();
1767
1767
  if (size < offset) offset = size; // truncated/rotated
1768
1768
  if (size > offset) {
1769
+ // The safety-net poll found appended bytes the watcher never
1770
+ // announced — suspicious: the watcher may be dead (a
1771
+ // long-lived daemon can reach a state where fs.watch
1772
+ // callbacks stop firing process-wide; observed alongside the
1773
+ // node-datachannel native-stack pathologies), leaving every
1774
+ // keystroke echo riding the slow poll (~500ms felt lag). But
1775
+ // a HEALTHY watcher's callback may merely be queued behind
1776
+ // this very tick (sparse append landing just before the poll,
1777
+ // with lastWatcherFireAt stale from an idle stretch) — so
1778
+ // verify before demoting: give it 100ms to fire, and only
1779
+ // then demote this stream to the fast poll it would have used
1780
+ // had watch() failed outright.
1781
+ if (viaPoll && watcher && !demoteCheck && Date.now() - lastWatcherFireAt > POLL_WATCHED - 50) {
1782
+ const suspectAt = Date.now();
1783
+ demoteCheck = setTimeout(() => {
1784
+ demoteCheck = null;
1785
+ if (closed || !watcher) return;
1786
+ if (lastWatcherFireAt >= suspectAt) return; // fired since — healthy
1787
+ try {
1788
+ watcher.close();
1789
+ } catch {
1790
+ /* already dead */
1791
+ }
1792
+ watcher = null;
1793
+ clearInterval(poller);
1794
+ poller = setInterval(() => void flush(true), POLL_UNWATCHED);
1795
+ }, 100);
1796
+ }
1769
1797
  const len = size - offset;
1770
1798
  const buf = Buffer.allocUnsafe(len);
1771
1799
  const { bytesRead } = await fh.read(buf, 0, len, offset);
@@ -1788,9 +1816,14 @@ export async function cmdServe(rest: string[]): Promise<number> {
1788
1816
  }
1789
1817
  };
1790
1818
 
1819
+ let lastWatcherFireAt = Date.now(); // grace at open — see demotion above
1820
+ let demoteCheck: ReturnType<typeof setTimeout> | null = null;
1791
1821
  let watcher: ReturnType<typeof watch> | null = null;
1792
1822
  try {
1793
- watcher = watch(logPath, () => void flush());
1823
+ watcher = watch(logPath, () => {
1824
+ lastWatcherFireAt = Date.now();
1825
+ void flush();
1826
+ });
1794
1827
  } catch {
1795
1828
  /* fs.watch unsupported — the fallback poll below still works */
1796
1829
  }
@@ -1799,7 +1832,13 @@ export async function cmdServe(rest: string[]): Promise<number> {
1799
1832
  // → keep it at 60ms for low typing-echo latency. This matters when many
1800
1833
  // /api/tail streams are open at once (the /rgui viewer opens one per
1801
1834
  // node): N × a 60ms poll each was needless load on the event loop.
1802
- const poller = setInterval(() => void flush(), watcher ? 500 : 60);
1835
+ // (If the watcher turns out to be dead, flush() demotes to 60ms.)
1836
+ const POLL_WATCHED = 500;
1837
+ const POLL_UNWATCHED = 60;
1838
+ let poller = setInterval(
1839
+ () => void flush(true),
1840
+ watcher ? POLL_WATCHED : POLL_UNWATCHED,
1841
+ );
1803
1842
 
1804
1843
  // Tear down on client disconnect via BOTH the req.signal 'abort'
1805
1844
  // listener and the stream's cancel() — whichever the runtime fires
@@ -1812,6 +1851,7 @@ export async function cmdServe(rest: string[]): Promise<number> {
1812
1851
  closed = true;
1813
1852
  clearInterval(heartbeat);
1814
1853
  clearInterval(poller);
1854
+ if (demoteCheck) clearTimeout(demoteCheck);
1815
1855
  try {
1816
1856
  watcher?.close();
1817
1857
  } catch {
@@ -1,8 +0,0 @@
1
- import "./ts-DsSOwxe2.js";
2
- import "./logger-CDIsZ-Pp.js";
3
- import "./versionChecker-DOi2Sthf.js";
4
- import "./pidStore-BIvsBQ8X.js";
5
- import "./globalPidIndex-CoNr7tS8.js";
6
- import { t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-rXoXMD10.js";
7
-
8
- export { SUPPORTED_CLIS };