@pushary/agent-hooks 1.9.0 → 1.9.1

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.
Files changed (98) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/bin/pushary-bell-hook.js +23 -23
  3. package/dist/bin/pushary-bell.js +9 -9
  4. package/dist/bin/pushary-claude.js +26 -26
  5. package/dist/bin/pushary-clean.js +28 -28
  6. package/dist/bin/pushary-codex-bridge.js +18 -18
  7. package/dist/bin/pushary-codex-hook.js +31 -31
  8. package/dist/bin/pushary-codex.js +13 -13
  9. package/dist/bin/pushary-connect.js +13 -13
  10. package/dist/bin/pushary-cowork.js +5 -5
  11. package/dist/bin/pushary-daemon.js +26 -26
  12. package/dist/bin/pushary-disconnect.js +18 -18
  13. package/dist/bin/pushary-doctor.js +30 -30
  14. package/dist/bin/pushary-elicitation-hook.js +25 -25
  15. package/dist/bin/pushary-gemini-bridge.js +13 -13
  16. package/dist/bin/pushary-gemini-hook.js +28 -28
  17. package/dist/bin/pushary-hook.js +32 -32
  18. package/dist/bin/pushary-login.js +12 -12
  19. package/dist/bin/pushary-logout.js +7 -7
  20. package/dist/bin/pushary-mcp.js +9 -9
  21. package/dist/bin/pushary-mode.js +9 -9
  22. package/dist/bin/pushary-notification-hook.js +28 -28
  23. package/dist/bin/pushary-opencode-hook.js +27 -27
  24. package/dist/bin/pushary-permission-denied-hook.js +32 -32
  25. package/dist/bin/pushary-permission-hook.js +31 -31
  26. package/dist/bin/pushary-post-hook.js +28 -28
  27. package/dist/bin/pushary-prompt-hook.js +28 -28
  28. package/dist/bin/pushary-session-end-hook.js +28 -28
  29. package/dist/bin/pushary-session-start-hook.js +31 -31
  30. package/dist/bin/pushary-setup.js +36 -36
  31. package/dist/bin/pushary-stats.js +5 -5
  32. package/dist/bin/pushary-status.js +15 -15
  33. package/dist/bin/pushary-stop-hook.js +28 -28
  34. package/dist/bin/pushary-stopfailure-hook.js +28 -28
  35. package/dist/bin/pushary-suggestions.js +4 -4
  36. package/dist/bin/pushary-transcript-register.js +19 -19
  37. package/dist/bin/pushary-transcripts.js +7 -7
  38. package/dist/bin/pushary-upgrade.js +42 -394
  39. package/dist/bin/pushary-wait.js +9 -9
  40. package/dist/bin/pushary.js +6 -6
  41. package/dist/{chunk-EG46RJRF.js → chunk-4SB46XLF.js} +1 -1
  42. package/dist/{chunk-KETBIX7I.js → chunk-4XT4JXMG.js} +1 -1
  43. package/dist/{chunk-NAJ3UV4E.js → chunk-5K43TBK4.js} +3 -3
  44. package/dist/{chunk-OLG6FJV2.js → chunk-65TOHCXT.js} +4 -4
  45. package/dist/{chunk-P6VDRQF3.js → chunk-6JTTJIKJ.js} +3 -3
  46. package/dist/{chunk-3OFHFVPX.js → chunk-6L7TNZ43.js} +1 -1
  47. package/dist/{chunk-MQJWO3AA.js → chunk-6Q4NM2LW.js} +3 -3
  48. package/dist/{chunk-US3RDXK7.js → chunk-6QSDNXGM.js} +2 -2
  49. package/dist/{chunk-MBVV3RX3.js → chunk-7ER66HZH.js} +1 -1
  50. package/dist/{chunk-7TQQSQZ7.js → chunk-AKCJ5SNO.js} +6 -6
  51. package/dist/{chunk-HQWPMVR4.js → chunk-C6PPDKVI.js} +3 -3
  52. package/dist/{chunk-P25O4K3J.js → chunk-CE4UH4AP.js} +2 -2
  53. package/dist/{chunk-HHNFGWR5.js → chunk-CGRPHFOV.js} +1 -1
  54. package/dist/{chunk-RZXQFAWR.js → chunk-COSADFEH.js} +1 -1
  55. package/dist/{chunk-YFS4HYCI.js → chunk-D3RS57MN.js} +3 -3
  56. package/dist/{chunk-75CEJ4WP.js → chunk-DMA3QUOB.js} +3 -3
  57. package/dist/{chunk-MGXXQHCM.js → chunk-FJPC35OW.js} +1 -1
  58. package/dist/{chunk-SDSKTRIV.js → chunk-FVOCQSBG.js} +1 -1
  59. package/dist/{chunk-YJZDIFON.js → chunk-GHKNUQYU.js} +2 -2
  60. package/dist/{chunk-ET6QSY3H.js → chunk-HU2LWGEE.js} +1 -1
  61. package/dist/{chunk-CFAD2LTH.js → chunk-IITCMJ4G.js} +2 -2
  62. package/dist/{chunk-HNMMKFYN.js → chunk-IJXJW2VH.js} +10 -10
  63. package/dist/{chunk-VV4SBPCQ.js → chunk-J7JXA2LX.js} +1 -1
  64. package/dist/{chunk-42E4DE6C.js → chunk-JCER3Q6P.js} +9 -9
  65. package/dist/{chunk-K75TP4JY.js → chunk-JGQ2ANHQ.js} +2 -2
  66. package/dist/{chunk-ZMVLKPT7.js → chunk-JHZAZAI3.js} +5 -5
  67. package/dist/{chunk-JW7DKTT6.js → chunk-KR5JASA4.js} +2 -2
  68. package/dist/{chunk-MBNMO5IR.js → chunk-LJI7U6PM.js} +2 -2
  69. package/dist/{chunk-4ZXYWEEH.js → chunk-LKKYRNJT.js} +1 -1
  70. package/dist/{chunk-TUZ7WKOF.js → chunk-LXWUYG7D.js} +1 -1
  71. package/dist/{chunk-2V64X5RE.js → chunk-LZMH4EGE.js} +1 -1
  72. package/dist/{chunk-CKPDSFY3.js → chunk-NVLXK2I6.js} +5 -5
  73. package/dist/{chunk-IJJ3HHFT.js → chunk-P7YDVWLL.js} +1 -1
  74. package/dist/{chunk-LQESQPIT.js → chunk-PEGKBNGN.js} +5 -5
  75. package/dist/{chunk-HSM5FIA3.js → chunk-PMS3EBD2.js} +1 -1
  76. package/dist/chunk-QQJCDRD3.js +242 -0
  77. package/dist/chunk-QXL27RY6.js +175 -0
  78. package/dist/{chunk-ZRHA4PGN.js → chunk-RJ7ECJSZ.js} +2 -2
  79. package/dist/{chunk-VYNTRHB6.js → chunk-RNDFGHSQ.js} +1 -1
  80. package/dist/{chunk-4GMZOGH4.js → chunk-RS4ZOFSF.js} +4 -4
  81. package/dist/{chunk-JOQEPWDH.js → chunk-SKEP3M6M.js} +2 -2
  82. package/dist/{chunk-BG4QCOHQ.js → chunk-SPB3QRE7.js} +4 -4
  83. package/dist/{chunk-XXVMUMKT.js → chunk-SWGY5WNX.js} +5 -5
  84. package/dist/{chunk-OXQKXZJ3.js → chunk-UPTEPARD.js} +2 -2
  85. package/dist/{chunk-IQUBCAEK.js → chunk-UYHLMBPQ.js} +1 -1
  86. package/dist/{chunk-K7DY2DQN.js → chunk-V4H33GBM.js} +6 -6
  87. package/dist/{chunk-CPBRXBLG.js → chunk-VH6763OR.js} +3 -3
  88. package/dist/{chunk-7LLNRCOK.js → chunk-VQLWYKX7.js} +1 -1
  89. package/dist/{chunk-WFVNXGZ6.js → chunk-WWDPULS3.js} +8 -8
  90. package/dist/{chunk-4PCF34AB.js → chunk-XEIV5QOT.js} +75 -23
  91. package/dist/{chunk-XGS2DHGF.js → chunk-XW2B4QV2.js} +2 -2
  92. package/dist/{chunk-R76C43H7.js → chunk-ZMKEKWNR.js} +70 -49
  93. package/dist/global-upgrade-ML2RHV4W.js +24 -0
  94. package/dist/paths-LG3IEDDM.js +71 -0
  95. package/dist/{reapply-FYCVOWCW.js → reapply-7PFOITE4.js} +8 -8
  96. package/dist/src/index.js +20 -20
  97. package/dist/upgrade-lock-2A2YUUEU.js +17 -0
  98. package/package.json +1 -1
@@ -1,35 +1,45 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ FINISH_UPGRADE_FLAG,
4
+ finishGlobalUpgrade,
5
+ finishUpgradeWithLock,
6
+ readGlobalUpgradeSubject,
7
+ runAutoUpdate,
8
+ upgradeInstalledPackage,
9
+ withUpgradeLock
10
+ } from "../chunk-QQJCDRD3.js";
11
+ import {
12
+ installWithUpgradeLock
13
+ } from "../chunk-QXL27RY6.js";
2
14
  import {
3
15
  describeCodexTrustConfirmation
4
- } from "../chunk-7LLNRCOK.js";
16
+ } from "../chunk-VQLWYKX7.js";
5
17
  import {
6
18
  ensureCodexTrustAfterReapply,
7
19
  reapplyAllAgents
8
- } from "../chunk-XXVMUMKT.js";
9
- import "../chunk-JW7DKTT6.js";
20
+ } from "../chunk-SWGY5WNX.js";
21
+ import "../chunk-KR5JASA4.js";
10
22
  import {
11
23
  waitForMachineReadiness
12
- } from "../chunk-7TQQSQZ7.js";
13
- import "../chunk-MQJWO3AA.js";
24
+ } from "../chunk-AKCJ5SNO.js";
25
+ import "../chunk-6Q4NM2LW.js";
14
26
  import {
15
27
  detectProviderLiveCapabilities,
16
28
  expectedLaunchCapabilities,
17
29
  hasSpawnProvider,
18
30
  resolveControlPolicy
19
- } from "../chunk-CFAD2LTH.js";
31
+ } from "../chunk-IITCMJ4G.js";
20
32
  import "../chunk-RIVNNBEK.js";
21
33
  import {
22
34
  AUTO_UPDATE_DISABLE_ENV,
23
35
  describeAutoUpdateCheck,
24
- globalInstallLocation,
25
36
  hasPendingUpgradeFinish,
26
37
  isAutoUpdateDisabledByEnv,
27
38
  parseAutoUpdateFlag,
28
39
  readAutoUpdateState,
29
- updateAutoUpdateState,
30
- upgradeEntryFor
31
- } from "../chunk-P25O4K3J.js";
32
- import "../chunk-NAJ3UV4E.js";
40
+ updateAutoUpdateState
41
+ } from "../chunk-CE4UH4AP.js";
42
+ import "../chunk-5K43TBK4.js";
33
43
  import {
34
44
  daemonHasRemoteProof,
35
45
  daemonServiceManagerAvailable,
@@ -40,444 +50,82 @@ import {
40
50
  replaceDaemonService,
41
51
  stopDaemonService,
42
52
  waitForDaemonRemoteProof
43
- } from "../chunk-LQESQPIT.js";
44
- import "../chunk-YFS4HYCI.js";
53
+ } from "../chunk-PEGKBNGN.js";
54
+ import "../chunk-D3RS57MN.js";
45
55
  import "../chunk-XHKBHWLX.js";
46
56
  import "../chunk-6ICPEJY5.js";
47
- import "../chunk-VYNTRHB6.js";
57
+ import "../chunk-RNDFGHSQ.js";
48
58
  import "../chunk-POFBE6ZY.js";
49
59
  import {
50
60
  exitOnHelpFlag
51
- } from "../chunk-K75TP4JY.js";
61
+ } from "../chunk-JGQ2ANHQ.js";
52
62
  import {
53
63
  readControlMode
54
- } from "../chunk-ZRHA4PGN.js";
55
- import "../chunk-VV4SBPCQ.js";
64
+ } from "../chunk-RJ7ECJSZ.js";
65
+ import "../chunk-J7JXA2LX.js";
56
66
  import {
57
67
  EXIT
58
68
  } from "../chunk-KZERVKTD.js";
59
- import "../chunk-US3RDXK7.js";
69
+ import "../chunk-6QSDNXGM.js";
60
70
  import {
61
71
  LATEST_TAG,
62
- autoUpdateLock,
63
- autoUpdateLog,
64
72
  autoUpdateState,
65
73
  claudeJson,
66
74
  codexConfigToml,
67
75
  cursorPluginDir,
68
- execNpm,
69
76
  fetchLatestPublishedVersion,
70
77
  geminiSettings,
71
- installPackageGlobally,
72
- npmErrorMessage,
73
- readGlobalCliInstallAt,
74
- readGlobalPrefix,
75
78
  vscodePluginDir
76
- } from "../chunk-R76C43H7.js";
77
- import {
78
- writeJsonAtomic
79
- } from "../chunk-T7E75EKA.js";
79
+ } from "../chunk-ZMKEKWNR.js";
80
+ import "../chunk-T7E75EKA.js";
80
81
  import {
81
82
  getApiKey
82
- } from "../chunk-EG46RJRF.js";
83
+ } from "../chunk-4SB46XLF.js";
83
84
  import {
84
85
  NPX_LATEST_COMMAND
85
- } from "../chunk-SDSKTRIV.js";
86
+ } from "../chunk-FVOCQSBG.js";
86
87
  import {
87
88
  CANONICAL_PACKAGE,
88
89
  LEGACY_PACKAGE,
89
- commandsPackage,
90
- getPackageVersion,
91
- globalUpgradeEntry,
92
- isNewerVersion,
93
- isReleaseVersion,
94
- isSameMajorVersion,
95
- ownPackageRoot,
96
- packageVersionAt
97
- } from "../chunk-4PCF34AB.js";
98
-
99
- // src/upgrade-lock.ts
100
- import { fork } from "child_process";
101
- import { createHash } from "crypto";
102
- import { existsSync, mkdirSync, readFileSync, realpathSync, unlinkSync } from "fs";
103
- import { createServer, Server } from "net";
104
- import { basename, dirname, join } from "path";
105
- var LOCK_HOST = "127.0.0.1";
106
- var LOCK_PORT_START = 49152;
107
- var LOCK_PORT_COUNT = 16384;
108
- var INHERITED_LOCK_ENV = "PUSHARY_UPGRADE_LOCK";
109
- var LOCK_READY = "pushary-upgrade-lock-ready";
110
- var LOCK_HANDLE = "pushary-upgrade-lock-handle";
111
- var HANDOFF_TIMEOUT_MS = 1e4;
112
- var FINISH_TIMEOUT_MS = 5 * 60 * 1e3;
113
- var KERNEL_LOCK_FORMAT = "kernel-v1";
114
- var heldLocks = /* @__PURE__ */ new Map();
115
- var canonicalLockPath = (path) => {
116
- mkdirSync(dirname(path), { recursive: true });
117
- return join(realpathSync(dirname(path)), basename(path));
118
- };
119
- var lockPort = (path) => LOCK_PORT_START + createHash("sha256").update(path).digest().readUInt32BE(0) % LOCK_PORT_COUNT;
120
- var readLockRecord = (path) => {
121
- try {
122
- const value = JSON.parse(readFileSync(path, "utf8"));
123
- const pid = value && typeof value === "object" && "pid" in value ? value.pid : void 0;
124
- return {
125
- pid: typeof pid === "number" && Number.isInteger(pid) && pid > 0 ? pid : void 0,
126
- installationPending: value !== null && typeof value === "object" && "installationPending" in value && value.installationPending === true,
127
- usesKernelLock: value !== null && typeof value === "object" && "format" in value && value.format === KERNEL_LOCK_FORMAT
128
- };
129
- } catch {
130
- return { pid: void 0, usesKernelLock: false, installationPending: false };
131
- }
132
- };
133
- var isProcessAlive = (pid) => {
134
- try {
135
- process.kill(pid, 0);
136
- return true;
137
- } catch (error) {
138
- return !(error instanceof Error && "code" in error && error.code === "ESRCH");
139
- }
140
- };
141
- var rejectConnection = (socket) => {
142
- socket.destroy();
143
- };
144
- var inheritLock = (path) => new Promise((resolve) => {
145
- const done = (claim) => {
146
- clearTimeout(timer);
147
- process.off("message", receive);
148
- process.off("disconnect", disconnected);
149
- resolve(claim);
150
- };
151
- const disconnected = () => done({ kind: "unavailable", reason: "Upgrade parent disconnected before transferring its lock" });
152
- const receive = (message, handle) => {
153
- if (message !== LOCK_HANDLE || !(handle instanceof Server)) return;
154
- const address = handle.address();
155
- if (address === null || typeof address === "string" || address.port !== lockPort(path) || address.address !== LOCK_HOST) {
156
- handle.close();
157
- done({ kind: "unavailable", reason: "Invalid inherited upgrade lock" });
158
- return;
159
- }
160
- handle.on("connection", rejectConnection);
161
- heldLocks.set(path, handle);
162
- done({ kind: "inherited" });
163
- process.disconnect?.();
164
- };
165
- const timer = setTimeout(() => done({ kind: "unavailable", reason: "Upgrade lock handoff timed out" }), HANDOFF_TIMEOUT_MS);
166
- process.on("message", receive);
167
- process.once("disconnect", disconnected);
168
- if (!process.send || !process.connected) return disconnected();
169
- process.send(LOCK_READY, (error) => {
170
- if (error) disconnected();
171
- });
172
- });
173
- var claimUpgradeLock = async (request = {}) => {
174
- let server;
175
- try {
176
- const path = canonicalLockPath(request.lockPath ?? autoUpdateLock());
177
- const inheritedPath = process.env[INHERITED_LOCK_ENV];
178
- delete process.env[INHERITED_LOCK_ENV];
179
- if (inheritedPath === path && !heldLocks.has(path)) return await inheritLock(path);
180
- server = createServer(rejectConnection);
181
- const listener = server;
182
- await new Promise((resolve, reject) => {
183
- listener.once("error", reject);
184
- listener.listen({ host: LOCK_HOST, port: lockPort(path), exclusive: true }, resolve);
185
- });
186
- const record = readLockRecord(path);
187
- if (record.installationPending) {
188
- server.close();
189
- return { kind: "unavailable", reason: `An earlier installation did not finish safely. Stop its npm processes (or restart the computer), then remove ${path} and retry the upgrade.` };
190
- }
191
- if (existsSync(path) && !record.usesKernelLock && (record.pid === void 0 || (request.isAlive ?? isProcessAlive)(record.pid))) {
192
- server.close();
193
- return { kind: "held", holderPid: record.pid };
194
- }
195
- writeJsonAtomic(path, { pid: process.pid, format: KERNEL_LOCK_FORMAT }, 384);
196
- heldLocks.set(path, server);
197
- return { kind: "acquired" };
198
- } catch (error) {
199
- server?.close();
200
- if (error instanceof Error && "code" in error && error.code === "EADDRINUSE") {
201
- return { kind: "held", holderPid: readLockRecord(request.lockPath ?? autoUpdateLock()).pid };
202
- }
203
- return { kind: "unavailable", reason: npmErrorMessage(error) };
204
- }
205
- };
206
- var releaseAutoUpdateLock = (lockPath) => {
207
- const path = canonicalLockPath(lockPath);
208
- const server = heldLocks.get(path);
209
- if (!server) return;
210
- heldLocks.delete(path);
211
- try {
212
- const record = readLockRecord(path);
213
- if (record.pid === process.pid && !record.installationPending) unlinkSync(path);
214
- } finally {
215
- server.close();
216
- }
217
- };
218
- var finishWithUpgradeLock = (request) => new Promise((resolve, reject) => {
219
- const path = canonicalLockPath(request.lockPath ?? autoUpdateLock());
220
- const server = heldLocks.get(path);
221
- if (!server) return reject(new Error("Cannot finish an upgrade without its lock"));
222
- const child = fork(request.entry, [...request.args], {
223
- execArgv: [],
224
- stdio: request.stdio ?? ["inherit", "inherit", "inherit", "ipc"],
225
- env: { ...process.env, ...request.env, [INHERITED_LOCK_ENV]: path }
226
- });
227
- const timer = setTimeout(() => child.kill("SIGKILL"), FINISH_TIMEOUT_MS);
228
- child.on("message", (message) => {
229
- if (message === LOCK_READY) child.send(LOCK_HANDLE, server, (error) => {
230
- if (error) child.kill();
231
- });
232
- });
233
- child.once("error", (error) => {
234
- clearTimeout(timer);
235
- reject(error);
236
- });
237
- child.once("exit", (code, signal) => {
238
- clearTimeout(timer);
239
- if (code === 0) resolve();
240
- else reject(new Error(`Upgrade finish exited with ${signal ?? code}`));
241
- });
242
- });
243
- var installWithUpgradeLock = (request, lockPath = autoUpdateLock(), runNpm) => {
244
- const path = canonicalLockPath(lockPath);
245
- if (!heldLocks.has(path)) throw new Error("Cannot install an upgrade without its lock");
246
- writeJsonAtomic(path, { pid: process.pid, format: KERNEL_LOCK_FORMAT, installationPending: true }, 384);
247
- installPackageGlobally(request, runNpm);
248
- writeJsonAtomic(path, { pid: process.pid, format: KERNEL_LOCK_FORMAT }, 384);
249
- };
90
+ getPackageVersion
91
+ } from "../chunk-XEIV5QOT.js";
250
92
 
251
93
  // bin/pushary-upgrade.ts
252
- import { existsSync as existsSync3 } from "fs";
94
+ import { existsSync } from "fs";
253
95
  import { homedir } from "os";
254
- import { join as join2 } from "path";
255
-
256
- // src/global-upgrade.ts
257
- import { existsSync as existsSync2 } from "fs";
258
-
259
- // src/auto-update-run.ts
260
- import { closeSync, mkdirSync as mkdirSync2, openSync, statSync, writeSync } from "fs";
261
- import { dirname as dirname2 } from "path";
262
- var FINISH_UPGRADE_FLAG = "--finish-upgrade";
263
- var INSTALL_TIMEOUT_MS = 12e4;
264
- var LOG_LIMIT_BYTES = 256 * 1024;
265
- var UNREADABLE_INSTALLED_VERSION = "could not read the installed version";
266
- var UNREACHABLE_REGISTRY = "could not read the latest version from the npm registry";
267
- var MANUAL_UPGRADE_COMMAND = `${NPX_LATEST_COMMAND} upgrade`;
268
- var openAutoUpdateLog = (logPath) => {
269
- mkdirSync2(dirname2(logPath), { recursive: true });
270
- const size = statSync(logPath, { throwIfNoEntry: false })?.size ?? 0;
271
- return openSync(logPath, size > LOG_LIMIT_BYTES ? "w" : "a");
272
- };
273
- var appendAutoUpdateLog = (logPath, line) => {
274
- try {
275
- const handle = openAutoUpdateLog(logPath);
276
- try {
277
- writeSync(handle, `${line}
278
- `);
279
- } finally {
280
- closeSync(handle);
281
- }
282
- } catch {
283
- return;
284
- }
285
- };
286
- var finishInNewInstall = async (request) => {
287
- const handle = openAutoUpdateLog(request.logPath);
288
- try {
289
- await finishWithUpgradeLock({
290
- entry: request.entry,
291
- args: [FINISH_UPGRADE_FLAG],
292
- lockPath: request.lockPath,
293
- stdio: ["ignore", handle, handle, "ipc"],
294
- env: { npm_config_prefix: request.prefix }
295
- });
296
- } finally {
297
- closeSync(handle);
298
- }
299
- };
300
- var incompleteFinishDetail = (logPath) => `installed, but refreshing the agent configs did not finish cleanly; see ${logPath}`;
301
- var newMajorDetail = (latest) => `${latest} is a new major version; run ${MANUAL_UPGRADE_COMMAND}`;
302
- var finishInstalledUpgrade = async (context, from, to) => {
303
- const pending = { result: "finish_pending", from, to, detail: incompleteFinishDetail(context.logPath) };
304
- recordAutoUpdateCheck(context.statePath, pending, new Date(context.now()).toISOString());
305
- try {
306
- await context.finish({ lockPath: context.lockPath, entry: upgradeEntryFor(context.location), prefix: context.location.prefix, logPath: context.logPath });
307
- return { result: "updated", from, to };
308
- } catch {
309
- return pending;
310
- }
311
- };
312
- var isInstallableRelease = (latest, installed) => latest !== void 0 && isNewerVersion(latest, installed) && isSameMajorVersion(latest, installed);
313
- var checkAndInstall = async (context) => {
314
- const installed = packageVersionAt(context.packageRoot);
315
- if (installed === void 0 || !isReleaseVersion(installed)) {
316
- return { result: "failed", from: installed, detail: UNREADABLE_INSTALLED_VERSION };
317
- }
318
- const previous = readAutoUpdateState(context.statePath);
319
- const pendingFinish = hasPendingUpgradeFinish(previous, installed);
320
- const latest = await fetchLatestPublishedVersion({ packageName: context.location.packageName, fetchImpl: context.fetchImpl });
321
- if (pendingFinish && !isInstallableRelease(latest, installed)) return finishInstalledUpgrade(context, previous.from, installed);
322
- if (latest === void 0) return { result: "failed", from: installed, detail: UNREACHABLE_REGISTRY };
323
- if (!isNewerVersion(latest, installed)) return { result: "current", from: installed };
324
- if (!isSameMajorVersion(latest, installed)) {
325
- return { result: "needs_manual", from: installed, to: latest, detail: newMajorDetail(latest) };
326
- }
327
- appendAutoUpdateLog(context.logPath, `${new Date(context.now()).toISOString()} installing ${context.location.packageName}@${latest} into ${context.location.prefix}`);
328
- try {
329
- installWithUpgradeLock({
330
- packageName: context.location.packageName,
331
- version: latest,
332
- prefix: context.location.prefix,
333
- timeoutMs: INSTALL_TIMEOUT_MS
334
- }, context.lockPath, context.runNpm);
335
- } catch (error) {
336
- return { result: "failed", from: installed, to: latest, detail: npmErrorMessage(error) };
337
- }
338
- return finishInstalledUpgrade(context, installed, latest);
339
- };
340
- var recordAutoUpdateCheck = (statePath, check, at) => updateAutoUpdateState(statePath, {
341
- lastCheckAt: at,
342
- lastResult: check.result,
343
- from: check.from,
344
- to: check.to,
345
- at,
346
- detail: check.detail,
347
- announced: check.result === "updated" ? false : void 0
348
- });
349
- var runAutoUpdate = async (run = {}) => {
350
- if ((run.platform ?? process.platform) === "linux") return { kind: "linux" };
351
- const packageRoot = run.packageRoot ?? ownPackageRoot();
352
- const location = packageRoot === void 0 ? null : globalInstallLocation(packageRoot);
353
- if (packageRoot === void 0 || location === null) return { kind: "not_global_install" };
354
- const now = run.now ?? Date.now;
355
- const lockPath = run.lockPath ?? autoUpdateLock();
356
- const logPath = run.logPath ?? autoUpdateLog();
357
- const claim = await claimUpgradeLock({ lockPath });
358
- if (claim.kind === "unavailable") {
359
- const at = new Date(now()).toISOString();
360
- const state = recordAutoUpdateCheck(run.statePath ?? autoUpdateState(), { result: "failed", detail: claim.reason }, at);
361
- appendAutoUpdateLog(logPath, `${at} ${describeAutoUpdateCheck(state)}`);
362
- return { kind: "recorded", state };
363
- }
364
- if (claim.kind !== "acquired") return { kind: "locked" };
365
- try {
366
- const check = await checkAndInstall({
367
- lockPath,
368
- packageRoot,
369
- statePath: run.statePath ?? autoUpdateState(),
370
- location,
371
- logPath,
372
- now,
373
- fetchImpl: run.fetchImpl ?? fetch,
374
- runNpm: run.runNpm ?? execNpm,
375
- finish: run.finish ?? finishInNewInstall
376
- });
377
- const at = new Date(now()).toISOString();
378
- const state = recordAutoUpdateCheck(run.statePath ?? autoUpdateState(), check, at);
379
- appendAutoUpdateLog(logPath, `${at} ${describeAutoUpdateCheck(state)}`);
380
- return { kind: "recorded", state };
381
- } finally {
382
- releaseAutoUpdateLock(lockPath);
383
- }
384
- };
385
-
386
- // src/global-upgrade.ts
387
- var NOT_INSTALLED = { kind: "not_installed" };
388
- var globalUpgradeSubject = (prefix, install) => {
389
- if (prefix === void 0) return NOT_INSTALLED;
390
- const commands = commandsPackage(install);
391
- if (commands?.version !== void 0) return { kind: "installed", prefix, name: commands.name, version: commands.version };
392
- return install.kind === "both" ? { kind: "both_installed" } : NOT_INSTALLED;
393
- };
394
- var readGlobalUpgradeSubject = (platform = process.platform) => {
395
- const prefix = readGlobalPrefix();
396
- return globalUpgradeSubject(prefix, prefix === void 0 ? { kind: "unavailable" } : readGlobalCliInstallAt(prefix, platform));
397
- };
398
- var finishWithThisNode = (entry) => finishWithUpgradeLock({ entry, args: [FINISH_UPGRADE_FLAG] });
399
- var finishGlobalUpgrade = async (subject, platform = process.platform, runFinish = finishWithThisNode) => {
400
- const entry = globalUpgradeEntry(subject.prefix, subject.name, platform);
401
- if (!existsSync2(entry)) return { kind: "entry_missing", entry };
402
- try {
403
- await runFinish(entry);
404
- return { kind: "finished" };
405
- } catch {
406
- return { kind: "failed" };
407
- }
408
- };
409
- var describeHeldUpgradeLock = (holderPid) => `Another Pushary upgrade is already running${holderPid === void 0 ? "" : ` (pid ${holderPid})`}. Try again when it has finished.`;
410
- var withUpgradeLock = async (run, request = {}) => {
411
- const claim = await claimUpgradeLock(request);
412
- if (claim.kind === "unavailable") return { kind: "refused", exitCode: EXIT.FAILED, message: `Could not lock the Pushary upgrade: ${claim.reason}` };
413
- if (claim.kind === "held") return { kind: "refused", exitCode: EXIT.FAILED, message: describeHeldUpgradeLock(claim.holderPid) };
414
- try {
415
- await run();
416
- } finally {
417
- releaseAutoUpdateLock(request.lockPath ?? autoUpdateLock());
418
- }
419
- return { kind: "ran" };
420
- };
421
- var finishUpgradeWithLock = async (run, request) => {
422
- const outcome = await withUpgradeLock(run, request);
423
- if (outcome.kind === "refused") {
424
- updateAutoUpdateState(request.statePath, { lastResult: "finish_pending", to: request.installedVersion, detail: outcome.message });
425
- }
426
- return outcome;
427
- };
428
- var describeUpgradeStart = (subject, latest) => `Upgrading ${subject.name} ${subject.version} -> ${latest ?? "latest"}`;
429
- var upgradeInstalledPackage = async (subject, effects) => {
430
- const pendingFinish = effects.hasPendingFinish(subject.version);
431
- const latest = await effects.fetchLatest(subject.name);
432
- const newerPublished = latest !== void 0 && isNewerVersion(latest, subject.version);
433
- if (pendingFinish && !newerPublished) {
434
- const finish = await effects.finish(subject);
435
- if (finish.kind !== "finished") return { kind: "pending_finish_failed", finish };
436
- effects.recordFinished();
437
- }
438
- if (latest !== void 0 && !newerPublished) return { kind: "current", version: subject.version };
439
- effects.announce(describeUpgradeStart(subject, latest));
440
- try {
441
- effects.install(subject.name);
442
- } catch (error) {
443
- return { kind: "install_failed", detail: npmErrorMessage(error) };
444
- }
445
- return { kind: "installed", finish: await effects.finish(subject) };
446
- };
447
-
448
- // bin/pushary-upgrade.ts
96
+ import { join } from "path";
449
97
  exitOnHelpFlag("upgrade");
450
98
  var detectInstallModes = () => {
451
99
  const candidates = [
452
100
  {
453
101
  label: "Cursor plugin",
454
102
  upgrade: "updates itself through Cursor",
455
- present: existsSync3(cursorPluginDir())
103
+ present: existsSync(cursorPluginDir())
456
104
  },
457
105
  {
458
106
  label: "VS Code plugin",
459
107
  upgrade: `${NPX_LATEST_COMMAND} setup --agents vscode`,
460
- present: existsSync3(vscodePluginDir())
108
+ present: existsSync(vscodePluginDir())
461
109
  },
462
110
  {
463
111
  label: "Codex config",
464
112
  upgrade: `${NPX_LATEST_COMMAND} setup --agents codex`,
465
- present: existsSync3(codexConfigToml())
113
+ present: existsSync(codexConfigToml())
466
114
  },
467
115
  {
468
116
  label: "Claude Code config",
469
117
  upgrade: `${NPX_LATEST_COMMAND} setup --agents claude_code`,
470
- present: existsSync3(claudeJson())
118
+ present: existsSync(claudeJson())
471
119
  },
472
120
  {
473
121
  label: "Gemini config",
474
122
  upgrade: `${NPX_LATEST_COMMAND} setup --agents gemini_cli`,
475
- present: existsSync3(geminiSettings())
123
+ present: existsSync(geminiSettings())
476
124
  },
477
125
  {
478
126
  label: "Hermes plugin (pip)",
479
127
  upgrade: `${NPX_LATEST_COMMAND} setup --agents hermes`,
480
- present: existsSync3(join2(homedir(), ".hermes"))
128
+ present: existsSync(join(homedir(), ".hermes"))
481
129
  }
482
130
  ];
483
131
  return candidates.filter((candidate) => candidate.present).map(({ label, upgrade }) => ({ label, upgrade }));
@@ -4,33 +4,33 @@ import {
4
4
  } from "../chunk-CVWG2N3Y.js";
5
5
  import {
6
6
  exitOnFailedResponse
7
- } from "../chunk-2V64X5RE.js";
7
+ } from "../chunk-LZMH4EGE.js";
8
8
  import {
9
9
  createIo
10
10
  } from "../chunk-U4TMAANR.js";
11
11
  import {
12
12
  exitOnHelpFlag
13
- } from "../chunk-K75TP4JY.js";
13
+ } from "../chunk-JGQ2ANHQ.js";
14
14
  import {
15
15
  rejectUnknownFlags
16
16
  } from "../chunk-GMXKITVA.js";
17
- import "../chunk-75CEJ4WP.js";
18
- import "../chunk-P6VDRQF3.js";
19
- import "../chunk-VV4SBPCQ.js";
17
+ import "../chunk-DMA3QUOB.js";
18
+ import "../chunk-6JTTJIKJ.js";
19
+ import "../chunk-J7JXA2LX.js";
20
20
  import {
21
21
  UsageError
22
22
  } from "../chunk-7QLSKOSU.js";
23
23
  import {
24
24
  EXIT
25
25
  } from "../chunk-KZERVKTD.js";
26
- import "../chunk-R76C43H7.js";
26
+ import "../chunk-ZMKEKWNR.js";
27
27
  import "../chunk-T7E75EKA.js";
28
28
  import {
29
29
  getApiKey,
30
30
  getBaseUrl
31
- } from "../chunk-EG46RJRF.js";
32
- import "../chunk-SDSKTRIV.js";
33
- import "../chunk-4PCF34AB.js";
31
+ } from "../chunk-4SB46XLF.js";
32
+ import "../chunk-FVOCQSBG.js";
33
+ import "../chunk-XEIV5QOT.js";
34
34
 
35
35
  // bin/pushary-wait.ts
36
36
  exitOnHelpFlag("wait");
@@ -1,23 +1,23 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  installNetworkDefaults
4
- } from "../chunk-P6VDRQF3.js";
5
- import "../chunk-VV4SBPCQ.js";
4
+ } from "../chunk-6JTTJIKJ.js";
5
+ import "../chunk-J7JXA2LX.js";
6
6
  import "../chunk-7QLSKOSU.js";
7
7
  import {
8
8
  EXIT
9
9
  } from "../chunk-KZERVKTD.js";
10
- import "../chunk-R76C43H7.js";
10
+ import "../chunk-ZMKEKWNR.js";
11
11
  import "../chunk-T7E75EKA.js";
12
- import "../chunk-EG46RJRF.js";
12
+ import "../chunk-4SB46XLF.js";
13
13
  import {
14
14
  COMMANDS,
15
15
  isCommandName,
16
16
  renderHelp
17
- } from "../chunk-SDSKTRIV.js";
17
+ } from "../chunk-FVOCQSBG.js";
18
18
  import {
19
19
  getPackageVersion
20
- } from "../chunk-4PCF34AB.js";
20
+ } from "../chunk-XEIV5QOT.js";
21
21
 
22
22
  // src/cli/runtime.ts
23
23
  var supportsRuntime = (version) => {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  NPX_LATEST_COMMAND
3
- } from "./chunk-SDSKTRIV.js";
3
+ } from "./chunk-FVOCQSBG.js";
4
4
 
5
5
  // src/config.ts
6
6
  import { readFileSync } from "fs";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  readConfigFileKey
3
- } from "./chunk-ZRHA4PGN.js";
3
+ } from "./chunk-RJ7ECJSZ.js";
4
4
 
5
5
  // src/bell/fleet.ts
6
6
  import { closeSync, constants, futimesSync, lstatSync, mkdirSync, openSync, readdirSync, unlinkSync } from "fs";
@@ -2,17 +2,17 @@ import {
2
2
  CLAUDE_HOOK_EVENTS,
3
3
  GEMINI_HOOK_EVENTS,
4
4
  hasGeminiHooks
5
- } from "./chunk-YFS4HYCI.js";
5
+ } from "./chunk-D3RS57MN.js";
6
6
  import {
7
7
  CODEX_HOOK_EVENTS,
8
8
  hasCodexHooks,
9
9
  holdBudgetOf
10
- } from "./chunk-R76C43H7.js";
10
+ } from "./chunk-ZMKEKWNR.js";
11
11
  import {
12
12
  CURSOR_GATE_EVENTS,
13
13
  HOOK_LOCATOR_BINARY,
14
14
  hookCommandHoldBudget
15
- } from "./chunk-4PCF34AB.js";
15
+ } from "./chunk-XEIV5QOT.js";
16
16
 
17
17
  // src/diagnostics/wiring.ts
18
18
  var record = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : null;
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  AGENT_CHOICES
3
- } from "./chunk-ET6QSY3H.js";
3
+ } from "./chunk-HU2LWGEE.js";
4
4
  import {
5
5
  isBridgeLocator
6
- } from "./chunk-TUZ7WKOF.js";
6
+ } from "./chunk-LXWUYG7D.js";
7
7
  import {
8
8
  pusharyHookExecutable
9
- } from "./chunk-NAJ3UV4E.js";
9
+ } from "./chunk-5K43TBK4.js";
10
10
  import {
11
11
  BELL_HOOK_BINARY
12
- } from "./chunk-RZXQFAWR.js";
12
+ } from "./chunk-COSADFEH.js";
13
13
 
14
14
  // src/setup/hook-ownership.ts
15
15
  var commandsIn = (value) => {
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  readExistingMachineId
3
- } from "./chunk-VV4SBPCQ.js";
3
+ } from "./chunk-J7JXA2LX.js";
4
4
  import {
5
5
  NetworkError
6
6
  } from "./chunk-7QLSKOSU.js";
7
7
  import {
8
8
  getBaseUrl
9
- } from "./chunk-EG46RJRF.js";
9
+ } from "./chunk-4SB46XLF.js";
10
10
  import {
11
11
  clientContextHeaders,
12
12
  getPackageVersion
13
- } from "./chunk-4PCF34AB.js";
13
+ } from "./chunk-XEIV5QOT.js";
14
14
 
15
15
  // src/cli/net.ts
16
16
  import { createRequire } from "module";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  pusharyDir
3
- } from "./chunk-R76C43H7.js";
3
+ } from "./chunk-ZMKEKWNR.js";
4
4
  import {
5
5
  readJsonSafe
6
6
  } from "./chunk-T7E75EKA.js";