@pushary/agent-hooks 1.4.2 → 1.5.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 (94) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +28 -0
  3. package/data/vscode-plugin/README.md +1 -1
  4. package/data/vscode-plugin/scripts/pushary-gate.mjs +2 -2
  5. package/dist/bin/pushary-bell-hook.js +22 -21
  6. package/dist/bin/pushary-bell.js +10 -10
  7. package/dist/bin/pushary-claude.js +28 -24
  8. package/dist/bin/pushary-clean.js +25 -25
  9. package/dist/bin/pushary-codex-bridge.js +16 -14
  10. package/dist/bin/pushary-codex-hook.js +32 -27
  11. package/dist/bin/pushary-codex.js +15 -10
  12. package/dist/bin/pushary-connect.js +11 -11
  13. package/dist/bin/pushary-cowork.js +6 -6
  14. package/dist/bin/pushary-daemon.js +32 -28
  15. package/dist/bin/pushary-disconnect.js +16 -16
  16. package/dist/bin/pushary-doctor.js +111 -40
  17. package/dist/bin/pushary-elicitation-hook.js +23 -22
  18. package/dist/bin/pushary-gemini-bridge.js +13 -11
  19. package/dist/bin/pushary-gemini-hook.js +29 -24
  20. package/dist/bin/pushary-hook.js +30 -30
  21. package/dist/bin/pushary-login.js +14 -14
  22. package/dist/bin/pushary-logout.js +8 -8
  23. package/dist/bin/pushary-mode.js +7 -7
  24. package/dist/bin/pushary-notification-hook.js +26 -25
  25. package/dist/bin/pushary-opencode-hook.js +25 -24
  26. package/dist/bin/pushary-permission-denied-hook.js +30 -29
  27. package/dist/bin/pushary-permission-hook.js +29 -28
  28. package/dist/bin/pushary-post-hook.js +26 -25
  29. package/dist/bin/pushary-prompt-hook.js +26 -25
  30. package/dist/bin/pushary-session-end-hook.js +26 -25
  31. package/dist/bin/pushary-session-start-hook.js +33 -27
  32. package/dist/bin/pushary-setup.js +94 -88
  33. package/dist/bin/pushary-stats.js +6 -6
  34. package/dist/bin/pushary-status.js +15 -15
  35. package/dist/bin/pushary-stop-hook.js +26 -25
  36. package/dist/bin/pushary-stopfailure-hook.js +26 -25
  37. package/dist/bin/pushary-suggestions.js +4 -4
  38. package/dist/bin/pushary-transcript-register.js +20 -19
  39. package/dist/bin/pushary-transcripts.js +8 -8
  40. package/dist/bin/pushary-upgrade.js +269 -45
  41. package/dist/bin/pushary-wait.js +7 -7
  42. package/dist/bin/pushary.js +8 -8
  43. package/dist/{chunk-LPYCPFBZ.js → chunk-2AUIEZYS.js} +3 -3
  44. package/dist/{chunk-4BROEAKH.js → chunk-2QT3GCU4.js} +1 -1
  45. package/dist/{chunk-55KW4FLG.js → chunk-3ZSGKLSO.js} +2 -2
  46. package/dist/{chunk-NY6XQ6CA.js → chunk-43LJSM4F.js} +2 -2
  47. package/dist/{chunk-LEAAERSQ.js → chunk-43ZDACBO.js} +1 -1
  48. package/dist/{chunk-II7PUMPB.js → chunk-4ERLRNOK.js} +3 -3
  49. package/dist/{chunk-M5CTUFF3.js → chunk-5HYNICS7.js} +1 -1
  50. package/dist/{chunk-MW6ZPC6R.js → chunk-5UQ5ATIE.js} +1 -1
  51. package/dist/{chunk-TYEO6T5J.js → chunk-5ZZG76S2.js} +2 -2
  52. package/dist/{chunk-EQRS3SGM.js → chunk-66H2QQAK.js} +1 -1
  53. package/dist/chunk-6EEANS74.js +300 -0
  54. package/dist/{chunk-TRLFZKVG.js → chunk-6IU45EHE.js} +49 -26
  55. package/dist/{chunk-JVTOML54.js → chunk-6QFEQIPM.js} +2 -2
  56. package/dist/chunk-BY2CRWBO.js +38 -0
  57. package/dist/{chunk-G653QPTR.js → chunk-D573TLP6.js} +7 -7
  58. package/dist/{chunk-25RTLTQD.js → chunk-DTQNDR7C.js} +1 -1
  59. package/dist/{chunk-FAH3D74E.js → chunk-EA3IELHP.js} +6 -0
  60. package/dist/{chunk-EYRGBYZG.js → chunk-HETOKNIL.js} +1 -1
  61. package/dist/{chunk-UM5J3J4V.js → chunk-HU5LSYL2.js} +2 -2
  62. package/dist/{chunk-PC6DU5C4.js → chunk-HUAOMX4U.js} +1 -1
  63. package/dist/{chunk-2V2IKOGJ.js → chunk-HVBF35GT.js} +2 -2
  64. package/dist/{chunk-DINDL2CF.js → chunk-HWJW3CPO.js} +25 -5
  65. package/dist/{chunk-VW66JEGU.js → chunk-IV3RHICU.js} +8 -8
  66. package/dist/{chunk-ACYIZ3KH.js → chunk-JKBDGZFL.js} +12 -6
  67. package/dist/{chunk-ZVY25BMK.js → chunk-K3QVDAZW.js} +1 -1
  68. package/dist/{chunk-MUVTZNJW.js → chunk-KHXVTWYS.js} +3 -3
  69. package/dist/{chunk-T5SZ4PML.js → chunk-KJRALILH.js} +7 -4
  70. package/dist/{chunk-VOMOZ4D5.js → chunk-M2LMXPJZ.js} +1 -1
  71. package/dist/{chunk-SUWRZYQG.js → chunk-MDJJW3LP.js} +3 -3
  72. package/dist/chunk-MU3WU2FO.js +166 -0
  73. package/dist/{chunk-2UMNXADU.js → chunk-OSJEMXSR.js} +5 -1
  74. package/dist/{chunk-TWWLVOPB.js → chunk-P4BNYJ5Q.js} +5 -5
  75. package/dist/{chunk-XDP3UYH5.js → chunk-PJ27EHCD.js} +8 -8
  76. package/dist/{chunk-LGXUGYUH.js → chunk-PYCQXCI5.js} +2 -2
  77. package/dist/{chunk-VIOL2DJS.js → chunk-R5KY3PBN.js} +5 -5
  78. package/dist/{chunk-SOUZBGYJ.js → chunk-T4QY64OR.js} +15 -14
  79. package/dist/{chunk-DY4ILT6L.js → chunk-TFKBFQCE.js} +1 -1
  80. package/dist/{chunk-GZ7E6VOB.js → chunk-TIWURSLS.js} +1 -1
  81. package/dist/{chunk-F4UWL4NY.js → chunk-TUXFIVOH.js} +1 -1
  82. package/dist/{chunk-UJBZIKSY.js → chunk-TZGCUNOX.js} +8 -8
  83. package/dist/{chunk-FU2DFEAZ.js → chunk-USQDVBEV.js} +2 -2
  84. package/dist/{chunk-YXP3WPAI.js → chunk-UYDTFCHW.js} +1 -1
  85. package/dist/{chunk-4ZDKSDVW.js → chunk-WNJSGZY7.js} +4 -4
  86. package/dist/{chunk-NHTAHAIS.js → chunk-WOLPADR6.js} +1 -1
  87. package/dist/{chunk-BZ4GDOJX.js → chunk-X7FESZTD.js} +7 -7
  88. package/dist/{chunk-NOWZUGZW.js → chunk-XWEONSLV.js} +1 -1
  89. package/dist/{chunk-Y3MM6PYN.js → chunk-YAWXKL2X.js} +1 -1
  90. package/dist/{chunk-GKIUEIDX.js → chunk-YQMFGWBD.js} +1 -1
  91. package/dist/{chunk-WPVHRUDT.js → chunk-Z4VGIBJ7.js} +3 -3
  92. package/dist/{reapply-J527BCJG.js → reapply-5CZSTJZI.js} +13 -8
  93. package/dist/src/index.js +18 -16
  94. package/package.json +1 -1
@@ -1,31 +1,32 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  registerTranscript
4
- } from "../chunk-UJBZIKSY.js";
4
+ } from "../chunk-TZGCUNOX.js";
5
5
  import "../chunk-SGZJ5LYH.js";
6
- import "../chunk-4ZDKSDVW.js";
7
- import "../chunk-DY4ILT6L.js";
8
- import "../chunk-ZVY25BMK.js";
9
- import "../chunk-WPVHRUDT.js";
10
- import "../chunk-BZ4GDOJX.js";
11
- import "../chunk-LPYCPFBZ.js";
12
- import "../chunk-MW6ZPC6R.js";
13
- import "../chunk-GZ7E6VOB.js";
14
- import "../chunk-EQRS3SGM.js";
15
- import "../chunk-4BROEAKH.js";
6
+ import "../chunk-WNJSGZY7.js";
7
+ import "../chunk-TFKBFQCE.js";
8
+ import "../chunk-K3QVDAZW.js";
9
+ import "../chunk-Z4VGIBJ7.js";
10
+ import "../chunk-X7FESZTD.js";
11
+ import "../chunk-2AUIEZYS.js";
12
+ import "../chunk-5UQ5ATIE.js";
13
+ import "../chunk-TIWURSLS.js";
14
+ import "../chunk-66H2QQAK.js";
15
+ import "../chunk-2QT3GCU4.js";
16
16
  import "../chunk-XHKBHWLX.js";
17
- import "../chunk-YXP3WPAI.js";
18
- import "../chunk-NHTAHAIS.js";
19
- import "../chunk-TRLFZKVG.js";
17
+ import "../chunk-UYDTFCHW.js";
18
+ import "../chunk-WOLPADR6.js";
19
+ import "../chunk-6IU45EHE.js";
20
20
  import "../chunk-GMXKITVA.js";
21
- import "../chunk-DINDL2CF.js";
22
- import "../chunk-FU2DFEAZ.js";
21
+ import "../chunk-USQDVBEV.js";
23
22
  import "../chunk-7QLSKOSU.js";
24
23
  import "../chunk-KZERVKTD.js";
25
- import "../chunk-UM5J3J4V.js";
24
+ import "../chunk-HU5LSYL2.js";
26
25
  import "../chunk-T7E75EKA.js";
27
- import "../chunk-2UMNXADU.js";
28
- import "../chunk-SOUZBGYJ.js";
26
+ import "../chunk-OSJEMXSR.js";
27
+ import "../chunk-T4QY64OR.js";
28
+ import "../chunk-EA3IELHP.js";
29
+ import "../chunk-HWJW3CPO.js";
29
30
 
30
31
  // bin/pushary-transcript-register.ts
31
32
  var raw = "";
@@ -6,18 +6,18 @@ import {
6
6
  } from "../chunk-SGZJ5LYH.js";
7
7
  import {
8
8
  transcriptsEnabled
9
- } from "../chunk-4BROEAKH.js";
9
+ } from "../chunk-2QT3GCU4.js";
10
10
  import {
11
11
  exitOnHelpFlag
12
- } from "../chunk-TWWLVOPB.js";
13
- import "../chunk-FAH3D74E.js";
14
- import "../chunk-DINDL2CF.js";
15
- import "../chunk-FU2DFEAZ.js";
12
+ } from "../chunk-P4BNYJ5Q.js";
13
+ import "../chunk-USQDVBEV.js";
16
14
  import "../chunk-KZERVKTD.js";
17
- import "../chunk-UM5J3J4V.js";
15
+ import "../chunk-HU5LSYL2.js";
18
16
  import "../chunk-T7E75EKA.js";
19
- import "../chunk-2UMNXADU.js";
20
- import "../chunk-SOUZBGYJ.js";
17
+ import "../chunk-OSJEMXSR.js";
18
+ import "../chunk-T4QY64OR.js";
19
+ import "../chunk-EA3IELHP.js";
20
+ import "../chunk-HWJW3CPO.js";
21
21
 
22
22
  // bin/pushary-transcripts.ts
23
23
  exitOnHelpFlag("transcripts");
@@ -1,18 +1,34 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
+ describeCodexTrustConfirmation
4
+ } from "../chunk-BY2CRWBO.js";
5
+ import {
6
+ ensureCodexTrustAfterReapply,
3
7
  reapplyAllAgents
4
- } from "../chunk-ACYIZ3KH.js";
5
- import "../chunk-PC6DU5C4.js";
8
+ } from "../chunk-JKBDGZFL.js";
9
+ import "../chunk-HUAOMX4U.js";
10
+ import "../chunk-6EEANS74.js";
6
11
  import {
7
12
  waitForMachineReadiness
8
- } from "../chunk-VW66JEGU.js";
9
- import "../chunk-II7PUMPB.js";
13
+ } from "../chunk-IV3RHICU.js";
14
+ import "../chunk-4ERLRNOK.js";
10
15
  import {
11
16
  detectProviderLiveCapabilities,
12
17
  hasSpawnProvider,
13
18
  resolveControlPolicy
14
- } from "../chunk-TYEO6T5J.js";
15
- import "../chunk-WPVHRUDT.js";
19
+ } from "../chunk-5ZZG76S2.js";
20
+ import {
21
+ AUTO_UPDATE_DISABLE_ENV,
22
+ describeAutoUpdateCheck,
23
+ globalInstallPrefix,
24
+ hasPendingUpgradeFinish,
25
+ isAutoUpdateDisabledByEnv,
26
+ parseAutoUpdateFlag,
27
+ readAutoUpdateState,
28
+ updateAutoUpdateState,
29
+ upgradeEntryFor
30
+ } from "../chunk-MU3WU2FO.js";
31
+ import "../chunk-Z4VGIBJ7.js";
16
32
  import {
17
33
  daemonHasRemoteProof,
18
34
  daemonServiceManagerAvailable,
@@ -23,46 +39,216 @@ import {
23
39
  replaceDaemonService,
24
40
  stopDaemonService,
25
41
  waitForDaemonRemoteProof
26
- } from "../chunk-BZ4GDOJX.js";
27
- import "../chunk-LPYCPFBZ.js";
42
+ } from "../chunk-X7FESZTD.js";
43
+ import "../chunk-2AUIEZYS.js";
28
44
  import {
29
45
  needsShell
30
46
  } from "../chunk-XHKBHWLX.js";
31
- import "../chunk-YXP3WPAI.js";
32
- import "../chunk-NHTAHAIS.js";
47
+ import "../chunk-UYDTFCHW.js";
48
+ import "../chunk-WOLPADR6.js";
33
49
  import {
50
+ LATEST_TAG,
51
+ autoUpdateLock,
52
+ autoUpdateLog,
53
+ autoUpdateState,
34
54
  claudeJson,
35
55
  codexConfigToml,
36
56
  cursorPluginDir,
37
57
  execNpm,
58
+ fetchLatestPublishedVersion,
38
59
  geminiSettings,
60
+ installAgentHooksGlobally,
39
61
  npmErrorMessage,
40
62
  resolveGlobalBinary,
41
63
  vscodePluginDir
42
- } from "../chunk-TRLFZKVG.js";
64
+ } from "../chunk-6IU45EHE.js";
43
65
  import {
44
66
  exitOnHelpFlag
45
- } from "../chunk-TWWLVOPB.js";
46
- import "../chunk-FAH3D74E.js";
47
- import {
48
- isNewerVersion
49
- } from "../chunk-DINDL2CF.js";
67
+ } from "../chunk-P4BNYJ5Q.js";
50
68
  import {
51
69
  readControlMode
52
- } from "../chunk-FU2DFEAZ.js";
53
- import "../chunk-KZERVKTD.js";
54
- import "../chunk-UM5J3J4V.js";
70
+ } from "../chunk-USQDVBEV.js";
71
+ import {
72
+ EXIT
73
+ } from "../chunk-KZERVKTD.js";
74
+ import "../chunk-HU5LSYL2.js";
55
75
  import "../chunk-T7E75EKA.js";
56
76
  import {
57
77
  getApiKey
58
- } from "../chunk-2UMNXADU.js";
59
- import "../chunk-SOUZBGYJ.js";
78
+ } from "../chunk-OSJEMXSR.js";
79
+ import "../chunk-T4QY64OR.js";
80
+ import {
81
+ NPX_LATEST_COMMAND
82
+ } from "../chunk-EA3IELHP.js";
83
+ import {
84
+ isNewerVersion,
85
+ isReleaseVersion,
86
+ isSameMajorVersion,
87
+ ownPackageRoot,
88
+ packageVersionAt
89
+ } from "../chunk-HWJW3CPO.js";
60
90
 
61
91
  // bin/pushary-upgrade.ts
62
92
  import { existsSync } from "fs";
63
93
  import { homedir } from "os";
64
94
  import { join } from "path";
95
+ import { execFileSync as execFileSync2 } from "child_process";
96
+
97
+ // src/auto-update-run.ts
65
98
  import { execFileSync } from "child_process";
99
+ import { closeSync, mkdirSync, openSync, statSync, unlinkSync, writeSync } from "fs";
100
+ import { dirname } from "path";
101
+ var FINISH_UPGRADE_FLAG = "--finish-upgrade";
102
+ var LOCK_STALE_MS = 10 * 60 * 1e3;
103
+ var INSTALL_TIMEOUT_MS = 12e4;
104
+ var FINISH_TIMEOUT_MS = 5 * 60 * 1e3;
105
+ var LOG_LIMIT_BYTES = 256 * 1024;
106
+ var UNREADABLE_INSTALLED_VERSION = "could not read the installed version";
107
+ var UNREACHABLE_REGISTRY = "could not read the latest version from the npm registry";
108
+ var MANUAL_UPGRADE_COMMAND = `${NPX_LATEST_COMMAND} upgrade`;
109
+ var isAlreadyExists = (error) => error instanceof Error && "code" in error && error.code === "EEXIST";
110
+ var createLock = (lockPath, now) => {
111
+ const handle = openSync(lockPath, "wx");
112
+ try {
113
+ writeSync(handle, `${JSON.stringify({ pid: process.pid, at: new Date(now).toISOString() })}
114
+ `);
115
+ } finally {
116
+ closeSync(handle);
117
+ }
118
+ };
119
+ var tryCreateLock = (lockPath, now) => {
120
+ try {
121
+ createLock(lockPath, now);
122
+ return "acquired";
123
+ } catch (error) {
124
+ if (isAlreadyExists(error)) return "held";
125
+ throw error;
126
+ }
127
+ };
128
+ var isStaleLock = (lockPath, now) => {
129
+ const modifiedAt = statSync(lockPath, { throwIfNoEntry: false })?.mtimeMs;
130
+ return modifiedAt !== void 0 && now - modifiedAt > LOCK_STALE_MS;
131
+ };
132
+ var acquireAutoUpdateLock = (lockPath, now) => {
133
+ mkdirSync(dirname(lockPath), { recursive: true });
134
+ if (tryCreateLock(lockPath, now) === "acquired") return "acquired";
135
+ if (!isStaleLock(lockPath, now)) return "held";
136
+ try {
137
+ unlinkSync(lockPath);
138
+ } catch {
139
+ return "held";
140
+ }
141
+ return tryCreateLock(lockPath, now);
142
+ };
143
+ var releaseAutoUpdateLock = (lockPath) => {
144
+ try {
145
+ unlinkSync(lockPath);
146
+ } catch {
147
+ return;
148
+ }
149
+ };
150
+ var openAutoUpdateLog = (logPath) => {
151
+ mkdirSync(dirname(logPath), { recursive: true });
152
+ const size = statSync(logPath, { throwIfNoEntry: false })?.size ?? 0;
153
+ return openSync(logPath, size > LOG_LIMIT_BYTES ? "w" : "a");
154
+ };
155
+ var appendAutoUpdateLog = (logPath, line) => {
156
+ try {
157
+ const handle = openAutoUpdateLog(logPath);
158
+ try {
159
+ writeSync(handle, `${line}
160
+ `);
161
+ } finally {
162
+ closeSync(handle);
163
+ }
164
+ } catch {
165
+ return;
166
+ }
167
+ };
168
+ var finishInNewInstall = (request) => {
169
+ const handle = openAutoUpdateLog(request.logPath);
170
+ try {
171
+ execFileSync(process.execPath, [request.entry, FINISH_UPGRADE_FLAG], {
172
+ stdio: ["ignore", handle, handle],
173
+ env: { ...process.env, npm_config_prefix: request.prefix },
174
+ timeout: FINISH_TIMEOUT_MS
175
+ });
176
+ } finally {
177
+ closeSync(handle);
178
+ }
179
+ };
180
+ var incompleteFinishDetail = (logPath) => `installed, but refreshing the agent configs did not finish cleanly; see ${logPath}`;
181
+ var newMajorDetail = (latest) => `${latest} is a new major version; run ${MANUAL_UPGRADE_COMMAND}`;
182
+ var finishInstalledUpgrade = (context, from, to) => {
183
+ const pending = { result: "finish_pending", from, to, detail: incompleteFinishDetail(context.logPath) };
184
+ recordAutoUpdateCheck(context.statePath, pending, new Date(context.now()).toISOString());
185
+ try {
186
+ context.finish({ entry: upgradeEntryFor(context.prefix), prefix: context.prefix, logPath: context.logPath });
187
+ return { result: "updated", from, to };
188
+ } catch {
189
+ return pending;
190
+ }
191
+ };
192
+ var checkAndInstall = async (context) => {
193
+ const installed = packageVersionAt(context.packageRoot);
194
+ if (installed === void 0 || !isReleaseVersion(installed)) {
195
+ return { result: "failed", from: installed, detail: UNREADABLE_INSTALLED_VERSION };
196
+ }
197
+ const previous = readAutoUpdateState(context.statePath);
198
+ if (hasPendingUpgradeFinish(previous, installed)) return finishInstalledUpgrade(context, previous.from, installed);
199
+ const latest = await fetchLatestPublishedVersion({ fetchImpl: context.fetchImpl });
200
+ if (latest === void 0) return { result: "failed", from: installed, detail: UNREACHABLE_REGISTRY };
201
+ if (!isNewerVersion(latest, installed)) return { result: "current", from: installed };
202
+ if (!isSameMajorVersion(latest, installed)) {
203
+ return { result: "needs_manual", from: installed, to: latest, detail: newMajorDetail(latest) };
204
+ }
205
+ appendAutoUpdateLog(context.logPath, `${new Date(context.now()).toISOString()} installing ${latest} into ${context.prefix}`);
206
+ try {
207
+ installAgentHooksGlobally({ version: latest, prefix: context.prefix, timeoutMs: INSTALL_TIMEOUT_MS }, context.runNpm);
208
+ } catch (error) {
209
+ return { result: "failed", from: installed, to: latest, detail: npmErrorMessage(error) };
210
+ }
211
+ return finishInstalledUpgrade(context, installed, latest);
212
+ };
213
+ var recordAutoUpdateCheck = (statePath, check, at) => updateAutoUpdateState(statePath, {
214
+ lastCheckAt: at,
215
+ lastResult: check.result,
216
+ from: check.from,
217
+ to: check.to,
218
+ at,
219
+ detail: check.detail,
220
+ announced: check.result === "updated" ? false : void 0
221
+ });
222
+ var runAutoUpdate = async (run = {}) => {
223
+ if ((run.platform ?? process.platform) === "linux") return { kind: "linux" };
224
+ const packageRoot = run.packageRoot ?? ownPackageRoot();
225
+ const prefix = packageRoot === void 0 ? null : globalInstallPrefix(packageRoot);
226
+ if (packageRoot === void 0 || prefix === null) return { kind: "not_global_install" };
227
+ const now = run.now ?? Date.now;
228
+ const lockPath = run.lockPath ?? autoUpdateLock();
229
+ const logPath = run.logPath ?? autoUpdateLog();
230
+ if (acquireAutoUpdateLock(lockPath, now()) === "held") return { kind: "locked" };
231
+ try {
232
+ const check = await checkAndInstall({
233
+ packageRoot,
234
+ statePath: run.statePath ?? autoUpdateState(),
235
+ prefix,
236
+ logPath,
237
+ now,
238
+ fetchImpl: run.fetchImpl ?? fetch,
239
+ runNpm: run.runNpm ?? execNpm,
240
+ finish: run.finish ?? finishInNewInstall
241
+ });
242
+ const at = new Date(now()).toISOString();
243
+ const state = recordAutoUpdateCheck(run.statePath ?? autoUpdateState(), check, at);
244
+ appendAutoUpdateLog(logPath, `${at} ${describeAutoUpdateCheck(state)}`);
245
+ return { kind: "recorded", state };
246
+ } finally {
247
+ releaseAutoUpdateLock(lockPath);
248
+ }
249
+ };
250
+
251
+ // bin/pushary-upgrade.ts
66
252
  exitOnHelpFlag("upgrade");
67
253
  var detectInstallModes = () => {
68
254
  const candidates = [
@@ -106,18 +292,6 @@ var getInstalledVersion = () => {
106
292
  return "";
107
293
  }
108
294
  };
109
- var fetchLatestVersion = async () => {
110
- try {
111
- const res = await fetch("https://registry.npmjs.org/@pushary/agent-hooks/latest", {
112
- signal: AbortSignal.timeout(5e3)
113
- });
114
- if (!res.ok) return void 0;
115
- const data = await res.json();
116
- return data.version;
117
- } catch {
118
- return void 0;
119
- }
120
- };
121
295
  var finishUpgrade = async () => {
122
296
  let apiKey;
123
297
  try {
@@ -126,6 +300,7 @@ var finishUpgrade = async () => {
126
300
  apiKey = void 0;
127
301
  }
128
302
  const inspectedAgents = reapplyAllAgents(apiKey);
303
+ const codexTrust = await ensureCodexTrustAfterReapply(inspectedAgents);
129
304
  const refreshed = inspectedAgents.filter((agent) => agent.result.reapplied);
130
305
  const configuredControlProviders = inspectedAgents.filter((agent) => agent.result.configured && (agent.id === "claude" || agent.id === "codex" || agent.id === "gemini")).map((agent) => agent.id);
131
306
  const controlMode = readControlMode();
@@ -174,6 +349,10 @@ var finishUpgrade = async () => {
174
349
  } else {
175
350
  console.log("No agent config on this machine needed refreshing.");
176
351
  }
352
+ if (codexTrust) {
353
+ console.log();
354
+ console.log(describeCodexTrustConfirmation(codexTrust));
355
+ }
177
356
  console.log();
178
357
  if (!daemonReady) {
179
358
  console.error(controlPolicy === "disabled" ? "Upgrade installed, but the disabled background service could not be fully removed. Re-run setup with --control off." : controlPolicy === "legacy" ? legacyStopFailure ? `Upgrade installed, but the legacy background service could not be stopped: ${legacyStopFailure}. Run setup with --control off.` : "Upgrade installed and the legacy background service was stopped, but it cannot be safely adopted. Run setup with --control off, or restore its provider and native service manager." : controlPolicy === "enabled" && !apiKey ? "Upgrade installed, but phone-start could not be reconciled because no API key was readable. Re-run setup." : "Upgrade installed, but the background service did not start. Run: pushary daemon install");
@@ -183,11 +362,59 @@ var finishUpgrade = async () => {
183
362
  console.log(controlPolicy === "disabled" ? "Done. Your hooks use the new global install; phone-start remains disabled." : controlPolicy === "unsupported" || controlPolicy === "preserve-absent" ? "Done. Your hooks use the new global install; no background service was added." : "Done. Your hooks and background service use the new global install.");
184
363
  console.log("Verify with: pushary doctor");
185
364
  };
365
+ var AUTO_UPDATE_ON_MESSAGE = "Automatic updates are on. Pushary checks for a new version once a day, when an agent session starts.";
366
+ var AUTO_UPDATE_OFF_MESSAGE = "Automatic updates are off. Turn them back on with: pushary upgrade --auto=on";
367
+ var AUTO_UPDATE_RUN_MESSAGES = {
368
+ linux: `Automatic updates are paused on Linux to protect running sessions. When your sessions have finished, run: ${NPX_LATEST_COMMAND} upgrade`,
369
+ not_global_install: `This copy of Pushary is not a global npm install, so it does not update itself. Run: ${NPX_LATEST_COMMAND} upgrade`,
370
+ locked: "Another automatic update is already running."
371
+ };
372
+ var setAutomaticUpdates = (enabled) => {
373
+ updateAutoUpdateState(autoUpdateState(), { disabled: !enabled });
374
+ console.log(enabled ? AUTO_UPDATE_ON_MESSAGE : AUTO_UPDATE_OFF_MESSAGE);
375
+ if (enabled && isAutoUpdateDisabledByEnv(process.env)) {
376
+ console.log(`${AUTO_UPDATE_DISABLE_ENV} is set in this shell, and it keeps them off wherever it is set.`);
377
+ }
378
+ };
379
+ var runAutomaticUpdate = async () => {
380
+ const outcome = await runAutoUpdate();
381
+ if (outcome.kind !== "recorded") {
382
+ console.log(AUTO_UPDATE_RUN_MESSAGES[outcome.kind]);
383
+ return;
384
+ }
385
+ console.log(`Automatic update: ${describeAutoUpdateCheck(outcome.state)}`);
386
+ if (outcome.state.lastResult === "failed" || outcome.state.lastResult === "finish_pending") process.exitCode = 1;
387
+ };
388
+ var finishGlobalUpgrade = () => {
389
+ const upgradedBinary = resolveGlobalBinary("pushary-upgrade");
390
+ if (!upgradedBinary) {
391
+ console.error("Upgrade installed, but the new pushary-upgrade binary could not be found on PATH.");
392
+ process.exit(1);
393
+ }
394
+ execFileSync2(upgradedBinary, [FINISH_UPGRADE_FLAG], {
395
+ stdio: "inherit",
396
+ shell: needsShell(upgradedBinary)
397
+ });
398
+ };
186
399
  var main = async () => {
187
- if (process.argv.includes("--finish-upgrade")) {
400
+ if (process.argv.includes(FINISH_UPGRADE_FLAG)) {
188
401
  await finishUpgrade();
189
402
  return;
190
403
  }
404
+ const autoFlag = parseAutoUpdateFlag(process.argv.slice(2));
405
+ if (autoFlag.kind === "invalid") {
406
+ console.error(`--auto takes on or off (got ${autoFlag.value || "nothing"}).`);
407
+ process.exitCode = EXIT.USAGE;
408
+ return;
409
+ }
410
+ if (autoFlag.kind === "set") {
411
+ setAutomaticUpdates(autoFlag.enabled);
412
+ return;
413
+ }
414
+ if (autoFlag.kind === "run") {
415
+ await runAutomaticUpdate();
416
+ return;
417
+ }
191
418
  const installed = getInstalledVersion();
192
419
  if (!installed) {
193
420
  const found = detectInstallModes();
@@ -206,26 +433,23 @@ var main = async () => {
206
433
  console.log("Check the result with: pushary doctor");
207
434
  return;
208
435
  }
209
- const latest = await fetchLatestVersion();
436
+ const pending = readAutoUpdateState(autoUpdateState());
437
+ if (hasPendingUpgradeFinish(pending, installed)) {
438
+ finishGlobalUpgrade();
439
+ updateAutoUpdateState(autoUpdateState(), { lastResult: "updated", detail: void 0, announced: false });
440
+ }
441
+ const latest = await fetchLatestPublishedVersion();
210
442
  if (latest && !isNewerVersion(latest, installed)) {
211
443
  console.log(`Already on the latest version (${installed}).`);
212
444
  return;
213
445
  }
214
446
  console.log(`Upgrading @pushary/agent-hooks ${installed} -> ${latest ?? "latest"}`);
215
447
  try {
216
- execNpm("install -g --no-workspaces @pushary/agent-hooks@latest", { timeout: 12e4 });
448
+ installAgentHooksGlobally({ version: LATEST_TAG, timeoutMs: 12e4 });
217
449
  } catch (err) {
218
450
  console.error(`Upgrade failed: ${npmErrorMessage(err)}`);
219
451
  process.exit(1);
220
452
  }
221
- const upgradedBinary = resolveGlobalBinary("pushary-upgrade");
222
- if (!upgradedBinary) {
223
- console.error("Upgrade installed, but the new pushary-upgrade binary could not be found on PATH.");
224
- process.exit(1);
225
- }
226
- execFileSync(upgradedBinary, ["--finish-upgrade"], {
227
- stdio: "inherit",
228
- shell: needsShell(upgradedBinary)
229
- });
453
+ finishGlobalUpgrade();
230
454
  };
231
455
  main();
@@ -4,19 +4,17 @@ import {
4
4
  } from "../chunk-CVWG2N3Y.js";
5
5
  import {
6
6
  exitOnFailedResponse
7
- } from "../chunk-NOWZUGZW.js";
8
- import "../chunk-NY6XQ6CA.js";
7
+ } from "../chunk-XWEONSLV.js";
8
+ import "../chunk-43LJSM4F.js";
9
9
  import {
10
10
  createIo
11
11
  } from "../chunk-5RUIFDTP.js";
12
12
  import {
13
13
  exitOnHelpFlag
14
- } from "../chunk-TWWLVOPB.js";
15
- import "../chunk-FAH3D74E.js";
14
+ } from "../chunk-P4BNYJ5Q.js";
16
15
  import {
17
16
  rejectUnknownFlags
18
17
  } from "../chunk-GMXKITVA.js";
19
- import "../chunk-DINDL2CF.js";
20
18
  import "../chunk-SAF6HGAA.js";
21
19
  import {
22
20
  UsageError
@@ -27,8 +25,10 @@ import {
27
25
  import {
28
26
  getApiKey,
29
27
  getBaseUrl
30
- } from "../chunk-2UMNXADU.js";
31
- import "../chunk-SOUZBGYJ.js";
28
+ } from "../chunk-OSJEMXSR.js";
29
+ import "../chunk-T4QY64OR.js";
30
+ import "../chunk-EA3IELHP.js";
31
+ import "../chunk-HWJW3CPO.js";
32
32
 
33
33
  // bin/pushary-wait.ts
34
34
  exitOnHelpFlag("wait");
@@ -1,12 +1,4 @@
1
1
  #!/usr/bin/env node
2
- import {
3
- COMMANDS,
4
- isCommandName,
5
- renderHelp
6
- } from "../chunk-FAH3D74E.js";
7
- import {
8
- getPackageVersion
9
- } from "../chunk-DINDL2CF.js";
10
2
  import {
11
3
  installProxyDispatcher
12
4
  } from "../chunk-SAF6HGAA.js";
@@ -14,6 +6,14 @@ import "../chunk-7QLSKOSU.js";
14
6
  import {
15
7
  EXIT
16
8
  } from "../chunk-KZERVKTD.js";
9
+ import {
10
+ COMMANDS,
11
+ isCommandName,
12
+ renderHelp
13
+ } from "../chunk-EA3IELHP.js";
14
+ import {
15
+ getPackageVersion
16
+ } from "../chunk-HWJW3CPO.js";
17
17
 
18
18
  // src/cli/runtime.ts
19
19
  var supportsRuntime = (version) => {
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  NOTIFICATION_MATCHED_TYPES,
3
3
  POSTTOOLUSE_MIRRORED_TOOLS
4
- } from "./chunk-YXP3WPAI.js";
4
+ } from "./chunk-UYDTFCHW.js";
5
5
  import {
6
6
  isProtectedByScope,
7
7
  registerHookEntry
8
- } from "./chunk-TRLFZKVG.js";
8
+ } from "./chunk-6IU45EHE.js";
9
9
  import {
10
10
  CLAUDE_PRETOOLUSE_MATCHER,
11
11
  HOOK_BUDGETS,
12
12
  HOOK_LOCATOR_BINARY
13
- } from "./chunk-SOUZBGYJ.js";
13
+ } from "./chunk-T4QY64OR.js";
14
14
 
15
15
  // src/gemini-config.ts
16
16
  var GEMINI_HOOK_BINARY = "pushary-gemini-hook";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  readTranscriptPreference
3
- } from "./chunk-FU2DFEAZ.js";
3
+ } from "./chunk-USQDVBEV.js";
4
4
 
5
5
  // src/transcript-setting.ts
6
6
  var transcriptEnvironmentPreference = () => {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  SETUP_FLAGS
3
- } from "./chunk-DY4ILT6L.js";
3
+ } from "./chunk-TFKBFQCE.js";
4
4
  import {
5
5
  parseFlags
6
6
  } from "./chunk-GMXKITVA.js";
@@ -14,7 +14,7 @@ import {
14
14
  CLAUDE_CONNECTOR_URL,
15
15
  COWORK_CONNECTOR_LIMIT,
16
16
  COWORK_STANDING_INSTRUCTIONS
17
- } from "./chunk-SOUZBGYJ.js";
17
+ } from "./chunk-T4QY64OR.js";
18
18
 
19
19
  // src/cli/cowork.ts
20
20
  import { readFileSync } from "fs";
@@ -9,11 +9,11 @@ import {
9
9
  } from "./chunk-KZERVKTD.js";
10
10
  import {
11
11
  getBaseUrl
12
- } from "./chunk-2UMNXADU.js";
12
+ } from "./chunk-OSJEMXSR.js";
13
13
  import {
14
14
  isValidApiKey,
15
15
  normalizeKeyScope
16
- } from "./chunk-SOUZBGYJ.js";
16
+ } from "./chunk-T4QY64OR.js";
17
17
 
18
18
  // src/session.ts
19
19
  var samePusharyAccount = (left, right) => left.kind === "ok" && right.kind === "ok" && left.identity.workspaceId !== "" && left.identity.workspaceId === right.identity.workspaceId && left.identity.siteId === right.identity.siteId;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  isSafeReadOnlyCommand
3
- } from "./chunk-SOUZBGYJ.js";
3
+ } from "./chunk-T4QY64OR.js";
4
4
 
5
5
  // src/ledger.ts
6
6
  import { appendFileSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, statSync } from "fs";
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  CLAUDE_HOOK_EVENTS,
3
3
  supportedClaudeEvents
4
- } from "./chunk-LPYCPFBZ.js";
4
+ } from "./chunk-2AUIEZYS.js";
5
5
  import {
6
6
  guardBinary,
7
7
  holdBudgetOf,
8
8
  isProtectedByScope,
9
9
  registerHookEntry
10
- } from "./chunk-TRLFZKVG.js";
10
+ } from "./chunk-6IU45EHE.js";
11
11
  import {
12
12
  HOOK_LOCATOR_BINARY,
13
13
  withHookHoldBudget
14
- } from "./chunk-SOUZBGYJ.js";
14
+ } from "./chunk-T4QY64OR.js";
15
15
 
16
16
  // src/claude-config.ts
17
17
  import { join } from "path";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  HOOK_HOLD_BUDGET_ENV,
3
3
  hookHoldBudgetProof
4
- } from "./chunk-SOUZBGYJ.js";
4
+ } from "./chunk-T4QY64OR.js";
5
5
 
6
6
  // src/hold-budget.ts
7
7
  var takeHookHoldBudget = (args = process.argv.slice(2), env = process.env) => {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  guardBinary
3
- } from "./chunk-TRLFZKVG.js";
3
+ } from "./chunk-6IU45EHE.js";
4
4
 
5
5
  // src/bell/install.ts
6
6
  import { join } from "path";
@@ -2,10 +2,10 @@ import {
2
2
  resolveBinary,
3
3
  resolveGlobalPackageVersion,
4
4
  resolvePackageVersionFromBinary
5
- } from "./chunk-TRLFZKVG.js";
5
+ } from "./chunk-6IU45EHE.js";
6
6
  import {
7
7
  MANAGED_PROVIDERS
8
- } from "./chunk-SOUZBGYJ.js";
8
+ } from "./chunk-T4QY64OR.js";
9
9
 
10
10
  // src/live-capabilities.ts
11
11
  var CLAUDE_BRIDGE_CAPABILITY = "claude-bridge";