@pushary/agent-hooks 1.9.5 → 1.9.7

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 (100) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/data/cowork/SKILL.md +11 -10
  3. package/dist/bin/pushary-bell-hook.js +23 -23
  4. package/dist/bin/pushary-bell.js +9 -9
  5. package/dist/bin/pushary-claude.js +26 -26
  6. package/dist/bin/pushary-clean.js +35 -35
  7. package/dist/bin/pushary-codex-bridge.js +18 -18
  8. package/dist/bin/pushary-codex-hook.js +31 -31
  9. package/dist/bin/pushary-codex.js +13 -13
  10. package/dist/bin/pushary-connect.js +13 -13
  11. package/dist/bin/pushary-cowork.js +5 -5
  12. package/dist/bin/pushary-daemon.js +27 -26
  13. package/dist/bin/pushary-disconnect.js +24 -24
  14. package/dist/bin/pushary-doctor.js +42 -39
  15. package/dist/bin/pushary-elicitation-hook.js +25 -25
  16. package/dist/bin/pushary-gemini-bridge.js +13 -13
  17. package/dist/bin/pushary-gemini-hook.js +28 -28
  18. package/dist/bin/pushary-hook.js +32 -32
  19. package/dist/bin/pushary-login.js +12 -12
  20. package/dist/bin/pushary-logout.js +7 -7
  21. package/dist/bin/pushary-mcp.js +9 -9
  22. package/dist/bin/pushary-mode.js +9 -9
  23. package/dist/bin/pushary-notification-hook.js +28 -28
  24. package/dist/bin/pushary-opencode-hook.js +27 -27
  25. package/dist/bin/pushary-permission-denied-hook.js +32 -32
  26. package/dist/bin/pushary-permission-hook.js +31 -31
  27. package/dist/bin/pushary-post-hook.js +28 -28
  28. package/dist/bin/pushary-prompt-hook.js +28 -28
  29. package/dist/bin/pushary-session-end-hook.js +28 -28
  30. package/dist/bin/pushary-session-start-hook.js +32 -31
  31. package/dist/bin/pushary-setup.js +57 -55
  32. package/dist/bin/pushary-stats.js +5 -5
  33. package/dist/bin/pushary-status.js +15 -15
  34. package/dist/bin/pushary-stop-hook.js +28 -28
  35. package/dist/bin/pushary-stopfailure-hook.js +28 -28
  36. package/dist/bin/pushary-suggestions.js +4 -4
  37. package/dist/bin/pushary-transcript-register.js +19 -19
  38. package/dist/bin/pushary-transcripts.js +7 -7
  39. package/dist/bin/pushary-upgrade.js +34 -28
  40. package/dist/bin/pushary-wait.js +9 -9
  41. package/dist/bin/pushary.js +6 -6
  42. package/dist/{chunk-VZGCXECP.js → chunk-3GNUXXDZ.js} +2 -2
  43. package/dist/{chunk-LBTOB7Z7.js → chunk-3PVDOCFI.js} +61 -17
  44. package/dist/{chunk-FQKFONAS.js → chunk-4D2AYNSE.js} +2 -2
  45. package/dist/{chunk-7AV2KBZC.js → chunk-4FK6RZVJ.js} +1 -1
  46. package/dist/{chunk-RKEVFUBN.js → chunk-4YO4T5FV.js} +3 -3
  47. package/dist/{chunk-KSJCYP4I.js → chunk-6DJTDHBI.js} +1 -1
  48. package/dist/{chunk-23R4BMUP.js → chunk-7264S5HZ.js} +1 -1
  49. package/dist/{chunk-UQBJTGLX.js → chunk-7OIWWZAD.js} +3 -3
  50. package/dist/{chunk-5DU7LJ7L.js → chunk-ADSQDYYG.js} +2 -2
  51. package/dist/{chunk-V3TD72QA.js → chunk-ANEAA37E.js} +3 -3
  52. package/dist/{chunk-FYEQSB6N.js → chunk-AQ55ZSSS.js} +1 -1
  53. package/dist/{chunk-IX5EFNCI.js → chunk-AUUXS44H.js} +1 -1
  54. package/dist/{chunk-CPMVKL6H.js → chunk-AVNKVF7N.js} +4 -4
  55. package/dist/{chunk-V3ASMZLF.js → chunk-BTQGAXZ3.js} +8 -8
  56. package/dist/{chunk-M7MMZURA.js → chunk-CBQACHKY.js} +1 -1
  57. package/dist/{chunk-UM7DXK6V.js → chunk-D6S5EKXA.js} +5 -5
  58. package/dist/{chunk-2JOP4D2G.js → chunk-EB4XGVBG.js} +2 -2
  59. package/dist/{chunk-4LVFBQJ3.js → chunk-GKI6LFAV.js} +2 -2
  60. package/dist/{chunk-NUYECJ57.js → chunk-H37L7TT3.js} +1 -1
  61. package/dist/{chunk-FNOY2K4N.js → chunk-H7MMU64M.js} +3 -2
  62. package/dist/{chunk-XXBOA4ZL.js → chunk-HPRZJKRO.js} +1 -1
  63. package/dist/{chunk-NI2BRIHL.js → chunk-JCWZ23MJ.js} +3 -3
  64. package/dist/chunk-JWKBDSPF.js +69 -0
  65. package/dist/{chunk-XEZWDDR5.js → chunk-JWQZSYCK.js} +1 -1
  66. package/dist/{chunk-ELQAQZNO.js → chunk-JXISQ7DT.js} +3 -3
  67. package/dist/{chunk-L5XJZKF2.js → chunk-KFKL3FHS.js} +3 -3
  68. package/dist/{chunk-QEY4SCXT.js → chunk-KT5E2RLS.js} +1 -1
  69. package/dist/{chunk-K2J6OGGN.js → chunk-KYO45G5L.js} +1 -1
  70. package/dist/{chunk-CV2IAVD5.js → chunk-L76HTPU6.js} +3 -3
  71. package/dist/{chunk-GBKM4ULB.js → chunk-MBK7N46B.js} +6 -6
  72. package/dist/{chunk-5T65DZBH.js → chunk-MNWRUGMH.js} +1 -1
  73. package/dist/{chunk-NH63BTRO.js → chunk-MZPXVH4A.js} +5 -5
  74. package/dist/{chunk-EYKHHCLA.js → chunk-N4EUSDKX.js} +4 -4
  75. package/dist/{chunk-G3W5GP6O.js → chunk-NIBFSARF.js} +25 -6
  76. package/dist/{chunk-JSVBVV2Q.js → chunk-QFEM7R6T.js} +9 -9
  77. package/dist/{chunk-TNCINDSF.js → chunk-QQ4HBXZC.js} +6 -6
  78. package/dist/{chunk-SBR2UKUO.js → chunk-QR6VE5ME.js} +35 -3
  79. package/dist/{chunk-Q6KNNFGG.js → chunk-QTO6HEZD.js} +27 -8
  80. package/dist/{chunk-ZJSII7OP.js → chunk-R3YW55MY.js} +10 -10
  81. package/dist/{chunk-LSYSKKWW.js → chunk-RQGODFQN.js} +8 -4
  82. package/dist/{chunk-ORBTANP2.js → chunk-RQSOEB4S.js} +1 -1
  83. package/dist/{chunk-ZW7KE2GP.js → chunk-SBLPHUEB.js} +1 -1
  84. package/dist/{chunk-3Z7NUGXO.js → chunk-SD3272LS.js} +4 -4
  85. package/dist/{chunk-HOTK2D2S.js → chunk-STQRUH3S.js} +1 -1
  86. package/dist/{chunk-6OUATBSK.js → chunk-T7Y5EADL.js} +2 -2
  87. package/dist/{chunk-6WKOOF2H.js → chunk-UFVGSEWH.js} +2 -2
  88. package/dist/{chunk-KTIY7ZIA.js → chunk-VXRXFU6Q.js} +9 -7
  89. package/dist/{chunk-2KH5NTKR.js → chunk-W2KI5KPD.js} +2 -2
  90. package/dist/{chunk-GRFV6GPY.js → chunk-X5NXPCIC.js} +7 -1
  91. package/dist/{chunk-2PFD44YK.js → chunk-XWAYAO3V.js} +2 -2
  92. package/dist/{chunk-2DSUVY6R.js → chunk-Z6HPS67T.js} +1 -1
  93. package/dist/{chunk-ZBF5WAP7.js → chunk-ZUTU43FT.js} +4 -4
  94. package/dist/{global-upgrade-GWD4OADP.js → global-upgrade-E2HUEB4B.js} +6 -6
  95. package/dist/{paths-MJGE4UFY.js → paths-QVTEGNZV.js} +2 -2
  96. package/dist/{reapply-U6BMGCAB.js → reapply-5QVKM6LA.js} +11 -8
  97. package/dist/src/index.js +20 -20
  98. package/dist/{upgrade-lock-HQP6XCER.js → upgrade-lock-JCIDZMHF.js} +5 -3
  99. package/package.json +1 -1
  100. package/dist/chunk-G7CZUI4G.js +0 -38
@@ -5,42 +5,47 @@ import {
5
5
  finishUpgradeWithLock,
6
6
  readGlobalUpgradeSubject,
7
7
  runAutoUpdate,
8
+ upgradeFinishExitCode,
9
+ upgradeFinishOutcome,
8
10
  upgradeInstalledPackage,
9
11
  withUpgradeLock
10
- } from "../chunk-LBTOB7Z7.js";
12
+ } from "../chunk-3PVDOCFI.js";
11
13
  import {
12
14
  installWithUpgradeLock
13
- } from "../chunk-LSYSKKWW.js";
14
- import {
15
- describeCodexTrustConfirmation
16
- } from "../chunk-G7CZUI4G.js";
15
+ } from "../chunk-RQGODFQN.js";
17
16
  import {
18
17
  ensureCodexTrustAfterReapply,
19
18
  reapplyAllAgents
20
- } from "../chunk-G3W5GP6O.js";
21
- import "../chunk-FNOY2K4N.js";
19
+ } from "../chunk-NIBFSARF.js";
20
+ import {
21
+ describeCodexTrustConfirmation
22
+ } from "../chunk-JWKBDSPF.js";
23
+ import "../chunk-H7MMU64M.js";
22
24
  import {
23
25
  waitForMachineReadiness
24
- } from "../chunk-GBKM4ULB.js";
25
- import "../chunk-V3TD72QA.js";
26
+ } from "../chunk-MBK7N46B.js";
27
+ import "../chunk-X5NXPCIC.js";
28
+ import "../chunk-ANEAA37E.js";
26
29
  import {
27
30
  detectProviderLiveCapabilities,
28
31
  expectedLaunchCapabilities,
29
32
  hasSpawnProvider,
30
33
  resolveControlPolicy
31
- } from "../chunk-6OUATBSK.js";
34
+ } from "../chunk-T7Y5EADL.js";
32
35
  import "../chunk-RIVNNBEK.js";
33
36
  import {
34
37
  AUTO_UPDATE_DISABLE_ENV,
35
38
  describeAutoUpdateCheck,
36
39
  hasPendingUpgradeFinish,
37
40
  isAutoUpdateDisabledByEnv,
41
+ isUnfinishedAutoUpdate,
38
42
  parseAutoUpdateFlag,
39
43
  readAutoUpdateState,
40
44
  updateAutoUpdateState
41
- } from "../chunk-Q6KNNFGG.js";
42
- import "../chunk-RKEVFUBN.js";
45
+ } from "../chunk-QTO6HEZD.js";
46
+ import "../chunk-4YO4T5FV.js";
43
47
  import {
48
+ DAEMON_COLD_START_TIMEOUT_MS,
44
49
  daemonHasRemoteProof,
45
50
  daemonServiceManagerAvailable,
46
51
  disableDaemonService,
@@ -50,23 +55,23 @@ import {
50
55
  replaceDaemonService,
51
56
  stopDaemonService,
52
57
  waitForDaemonRemoteProof
53
- } from "../chunk-KTIY7ZIA.js";
54
- import "../chunk-NI2BRIHL.js";
58
+ } from "../chunk-VXRXFU6Q.js";
59
+ import "../chunk-JCWZ23MJ.js";
55
60
  import "../chunk-XHKBHWLX.js";
56
61
  import "../chunk-6ICPEJY5.js";
57
- import "../chunk-KSJCYP4I.js";
62
+ import "../chunk-6DJTDHBI.js";
58
63
  import "../chunk-POFBE6ZY.js";
59
64
  import {
60
65
  exitOnHelpFlag
61
- } from "../chunk-6WKOOF2H.js";
66
+ } from "../chunk-UFVGSEWH.js";
62
67
  import {
63
68
  readControlMode
64
- } from "../chunk-5DU7LJ7L.js";
65
- import "../chunk-K2J6OGGN.js";
69
+ } from "../chunk-ADSQDYYG.js";
70
+ import "../chunk-KYO45G5L.js";
66
71
  import {
67
72
  EXIT
68
73
  } from "../chunk-KZERVKTD.js";
69
- import "../chunk-FQKFONAS.js";
74
+ import "../chunk-4D2AYNSE.js";
70
75
  import {
71
76
  LATEST_TAG,
72
77
  autoUpdateState,
@@ -76,19 +81,19 @@ import {
76
81
  fetchLatestPublishedVersion,
77
82
  geminiSettings,
78
83
  vscodePluginDir
79
- } from "../chunk-ZBF5WAP7.js";
84
+ } from "../chunk-ZUTU43FT.js";
80
85
  import "../chunk-T7E75EKA.js";
81
86
  import {
82
87
  getApiKey
83
- } from "../chunk-2DSUVY6R.js";
88
+ } from "../chunk-Z6HPS67T.js";
84
89
  import {
85
90
  NPX_LATEST_COMMAND
86
- } from "../chunk-HOTK2D2S.js";
91
+ } from "../chunk-STQRUH3S.js";
87
92
  import {
88
93
  CANONICAL_PACKAGE,
89
94
  LEGACY_PACKAGE,
90
95
  getPackageVersion
91
- } from "../chunk-SBR2UKUO.js";
96
+ } from "../chunk-QR6VE5ME.js";
92
97
 
93
98
  // bin/pushary-upgrade.ts
94
99
  import { existsSync } from "fs";
@@ -166,7 +171,7 @@ var finishUpgrade = async () => {
166
171
  } else {
167
172
  const service = await replaceDaemonService();
168
173
  const daemon = service.kind === "ok" ? await ensureDaemonRunning({ spawnDaemon: () => {
169
- } }) : null;
174
+ }, waitTimeoutMs: DAEMON_COLD_START_TIMEOUT_MS }) : null;
170
175
  const localProof = daemon?.kind === "running" || daemon?.kind === "started" ? await waitForDaemonRemoteProof() : null;
171
176
  const serverProof = localProof && daemonHasRemoteProof(localProof) ? await waitForMachineReadiness(apiKey, expectedLaunchCapabilities(configuredControlProviders)) : null;
172
177
  daemonReady = service.kind === "ok" && localProof !== null && daemonHasRemoteProof(localProof) && (serverProof?.kind === "ready" || serverProof?.kind === "unsupported");
@@ -174,6 +179,7 @@ var finishUpgrade = async () => {
174
179
  } else if (controlMode === "on" && controlPolicy === "unsupported") {
175
180
  daemonReady = false;
176
181
  }
182
+ const finishOutcome = upgradeFinishOutcome({ controlMode, controlPolicy, daemonReady, failedRefreshCount: failedRefreshes.length });
177
183
  console.log();
178
184
  if (refreshed.length > 0) {
179
185
  console.log("Refreshed so the new hook set is active now:");
@@ -195,12 +201,12 @@ var finishUpgrade = async () => {
195
201
  console.log();
196
202
  if (!daemonReady) {
197
203
  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");
198
- process.exitCode = 1;
204
+ process.exitCode = upgradeFinishExitCode(finishOutcome);
199
205
  return;
200
206
  }
201
207
  if (failedRefreshes.length > 0) {
202
208
  console.error(`Upgrade installed, but refreshing agent configuration failed for: ${failedRefreshes.map((agent) => agent.label).join(", ")}. Check the config files and run pushary upgrade again.`);
203
- process.exitCode = 1;
209
+ process.exitCode = upgradeFinishExitCode(finishOutcome);
204
210
  return;
205
211
  }
206
212
  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.");
@@ -227,7 +233,7 @@ var runAutomaticUpdate = async () => {
227
233
  return;
228
234
  }
229
235
  console.log(`Automatic update: ${describeAutoUpdateCheck(outcome.state)}`);
230
- if (outcome.state.lastResult === "failed" || outcome.state.lastResult === "finish_pending") process.exitCode = 1;
236
+ if (isUnfinishedAutoUpdate(outcome.state)) process.exitCode = 1;
231
237
  };
232
238
  var FINISH_FAILED_MESSAGE = "Upgrade installed, but refreshing the agent configs did not finish. Fix the problem printed above, then run pushary upgrade again.";
233
239
  var describeFinishFailure = (finish) => finish.kind === "entry_missing" ? `Upgrade installed, but the new pushary-upgrade entry was not found at ${finish.entry}.` : FINISH_FAILED_MESSAGE;
@@ -272,7 +278,7 @@ var upgradeSubject = async (subject) => {
272
278
  fetchLatest: (packageName) => fetchLatestPublishedVersion({ packageName }),
273
279
  hasPendingFinish: (installed) => hasPendingUpgradeFinish(readAutoUpdateState(autoUpdateState()), installed),
274
280
  recordFinished: () => {
275
- updateAutoUpdateState(autoUpdateState(), { lastResult: "updated", detail: void 0, announced: false });
281
+ updateAutoUpdateState(autoUpdateState(), { lastResult: "updated", detail: void 0, announced: false, finishAttempts: void 0 });
276
282
  },
277
283
  announce: (line) => console.log(line),
278
284
  install: (packageName) => installWithUpgradeLock({ packageName, version: LATEST_TAG, timeoutMs: 12e4 }),
@@ -4,33 +4,33 @@ import {
4
4
  } from "../chunk-CVWG2N3Y.js";
5
5
  import {
6
6
  exitOnFailedResponse
7
- } from "../chunk-ORBTANP2.js";
7
+ } from "../chunk-RQSOEB4S.js";
8
8
  import {
9
9
  createIo
10
10
  } from "../chunk-U4TMAANR.js";
11
11
  import {
12
12
  exitOnHelpFlag
13
- } from "../chunk-6WKOOF2H.js";
13
+ } from "../chunk-UFVGSEWH.js";
14
14
  import {
15
15
  rejectUnknownFlags
16
16
  } from "../chunk-GMXKITVA.js";
17
- import "../chunk-L5XJZKF2.js";
18
- import "../chunk-ELQAQZNO.js";
19
- import "../chunk-K2J6OGGN.js";
17
+ import "../chunk-KFKL3FHS.js";
18
+ import "../chunk-JXISQ7DT.js";
19
+ import "../chunk-KYO45G5L.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-ZBF5WAP7.js";
26
+ import "../chunk-ZUTU43FT.js";
27
27
  import "../chunk-T7E75EKA.js";
28
28
  import {
29
29
  getApiKey,
30
30
  getBaseUrl
31
- } from "../chunk-2DSUVY6R.js";
32
- import "../chunk-HOTK2D2S.js";
33
- import "../chunk-SBR2UKUO.js";
31
+ } from "../chunk-Z6HPS67T.js";
32
+ import "../chunk-STQRUH3S.js";
33
+ import "../chunk-QR6VE5ME.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-ELQAQZNO.js";
5
- import "../chunk-K2J6OGGN.js";
4
+ } from "../chunk-JXISQ7DT.js";
5
+ import "../chunk-KYO45G5L.js";
6
6
  import "../chunk-7QLSKOSU.js";
7
7
  import {
8
8
  EXIT
9
9
  } from "../chunk-KZERVKTD.js";
10
- import "../chunk-ZBF5WAP7.js";
10
+ import "../chunk-ZUTU43FT.js";
11
11
  import "../chunk-T7E75EKA.js";
12
- import "../chunk-2DSUVY6R.js";
12
+ import "../chunk-Z6HPS67T.js";
13
13
  import {
14
14
  COMMANDS,
15
15
  isCommandName,
16
16
  renderHelp
17
- } from "../chunk-HOTK2D2S.js";
17
+ } from "../chunk-STQRUH3S.js";
18
18
  import {
19
19
  getPackageVersion
20
- } from "../chunk-SBR2UKUO.js";
20
+ } from "../chunk-QR6VE5ME.js";
21
21
 
22
22
  // src/cli/runtime.ts
23
23
  var supportsRuntime = (version) => {
@@ -5,7 +5,7 @@ import {
5
5
  permissionDeniedAction,
6
6
  releaseThrottle,
7
7
  reportEvent
8
- } from "./chunk-JSVBVV2Q.js";
8
+ } from "./chunk-QFEM7R6T.js";
9
9
  import {
10
10
  DEFAULT_SESSION
11
11
  } from "./chunk-N6IOSZOE.js";
@@ -13,7 +13,7 @@ import {
13
13
  machineDecisionFor,
14
14
  shouldDeferToNativeMode,
15
15
  wireVerdictFor
16
- } from "./chunk-SBR2UKUO.js";
16
+ } from "./chunk-QR6VE5ME.js";
17
17
 
18
18
  // src/machine-decision-audit.ts
19
19
  import { basename } from "path";
@@ -1,17 +1,20 @@
1
1
  import {
2
2
  claimUpgradeLock,
3
3
  finishWithUpgradeLock,
4
+ forkFinishWithUpgradeLock,
4
5
  installWithUpgradeLock,
5
6
  releaseAutoUpdateLock
6
- } from "./chunk-LSYSKKWW.js";
7
+ } from "./chunk-RQGODFQN.js";
7
8
  import {
8
9
  describeAutoUpdateCheck,
9
10
  globalInstallLocation,
10
- hasPendingUpgradeFinish,
11
+ hasRetryableUpgradeFinish,
12
+ hasSettledUpgradeFinish,
13
+ nextFinishAttempt,
11
14
  readAutoUpdateState,
12
15
  updateAutoUpdateState,
13
16
  upgradeEntryFor
14
- } from "./chunk-Q6KNNFGG.js";
17
+ } from "./chunk-QTO6HEZD.js";
15
18
  import {
16
19
  EXIT
17
20
  } from "./chunk-KZERVKTD.js";
@@ -24,10 +27,10 @@ import {
24
27
  npmErrorMessage,
25
28
  readGlobalCliInstallAt,
26
29
  readGlobalPrefix
27
- } from "./chunk-ZBF5WAP7.js";
30
+ } from "./chunk-ZUTU43FT.js";
28
31
  import {
29
32
  NPX_LATEST_COMMAND
30
- } from "./chunk-HOTK2D2S.js";
33
+ } from "./chunk-STQRUH3S.js";
31
34
  import {
32
35
  commandsPackage,
33
36
  globalUpgradeEntry,
@@ -36,7 +39,7 @@ import {
36
39
  isSameMajorVersion,
37
40
  ownPackageRoot,
38
41
  packageVersionAt
39
- } from "./chunk-SBR2UKUO.js";
42
+ } from "./chunk-QR6VE5ME.js";
40
43
 
41
44
  // src/global-upgrade.ts
42
45
  import { existsSync } from "fs";
@@ -44,6 +47,28 @@ import { existsSync } from "fs";
44
47
  // src/auto-update-run.ts
45
48
  import { closeSync, mkdirSync, openSync, statSync, writeSync } from "fs";
46
49
  import { dirname } from "path";
50
+
51
+ // src/upgrade-finish.ts
52
+ var FINISHED_UPGRADE = { kind: "finished" };
53
+ var RETRYABLE_UPGRADE_FINISH = { kind: "retryable" };
54
+ var SETTLED_UPGRADE_FINISH = { kind: "settled" };
55
+ var controlWaitsOnThePerson = (readings) => readings.controlPolicy === "legacy" || readings.controlMode === "on" && readings.controlPolicy === "unsupported";
56
+ var upgradeFinishOutcome = (readings) => {
57
+ if (!readings.daemonReady) return controlWaitsOnThePerson(readings) ? SETTLED_UPGRADE_FINISH : RETRYABLE_UPGRADE_FINISH;
58
+ return readings.failedRefreshCount > 0 ? SETTLED_UPGRADE_FINISH : FINISHED_UPGRADE;
59
+ };
60
+ var UPGRADE_FINISH_EXIT_CODES = {
61
+ finished: EXIT.OK,
62
+ retryable: EXIT.FAILED,
63
+ settled: EXIT.PROBLEMS_FOUND
64
+ };
65
+ var upgradeFinishExitCode = (outcome) => UPGRADE_FINISH_EXIT_CODES[outcome.kind];
66
+ var upgradeFinishOutcomeOfExit = (code) => {
67
+ if (code === UPGRADE_FINISH_EXIT_CODES.finished) return FINISHED_UPGRADE;
68
+ return code === UPGRADE_FINISH_EXIT_CODES.settled ? SETTLED_UPGRADE_FINISH : RETRYABLE_UPGRADE_FINISH;
69
+ };
70
+
71
+ // src/auto-update-run.ts
47
72
  var FINISH_UPGRADE_FLAG = "--finish-upgrade";
48
73
  var INSTALL_TIMEOUT_MS = 12e4;
49
74
  var LOG_LIMIT_BYTES = 256 * 1024;
@@ -71,29 +96,44 @@ var appendAutoUpdateLog = (logPath, line) => {
71
96
  var finishInNewInstall = async (request) => {
72
97
  const handle = openAutoUpdateLog(request.logPath);
73
98
  try {
74
- await finishWithUpgradeLock({
99
+ const exit = await forkFinishWithUpgradeLock({
75
100
  entry: request.entry,
76
101
  args: [FINISH_UPGRADE_FLAG],
77
102
  lockPath: request.lockPath,
78
103
  stdio: ["ignore", handle, handle, "ipc"],
79
104
  env: { npm_config_prefix: request.prefix }
80
105
  });
106
+ return upgradeFinishOutcomeOfExit(exit.code);
81
107
  } finally {
82
108
  closeSync(handle);
83
109
  }
84
110
  };
85
111
  var incompleteFinishDetail = (logPath) => `installed, but refreshing the agent configs did not finish cleanly; see ${logPath}`;
112
+ var blockedFinishDetail = (logPath) => `installed, but refreshing the agent configs needs a change only you can make; see ${logPath}, then run pushary upgrade`;
86
113
  var newMajorDetail = (latest) => `${latest} is a new major version; run ${MANUAL_UPGRADE_COMMAND}`;
87
- var finishInstalledUpgrade = async (context, from, to) => {
88
- const pending = { result: "finish_pending", from, to, detail: incompleteFinishDetail(context.logPath) };
89
- recordAutoUpdateCheck(context.statePath, pending, new Date(context.now()).toISOString());
114
+ var attemptFinish = async (context) => {
90
115
  try {
91
- await context.finish({ lockPath: context.lockPath, entry: upgradeEntryFor(context.location), prefix: context.location.prefix, logPath: context.logPath });
92
- return { result: "updated", from, to };
116
+ return await context.finish({ lockPath: context.lockPath, entry: upgradeEntryFor(context.location), prefix: context.location.prefix, logPath: context.logPath });
93
117
  } catch {
94
- return pending;
118
+ return RETRYABLE_UPGRADE_FINISH;
119
+ }
120
+ };
121
+ var checkAfterFinish = (outcome, pending, logPath) => {
122
+ switch (outcome.kind) {
123
+ case "finished":
124
+ return { result: "updated", from: pending.from, to: pending.to };
125
+ case "retryable":
126
+ return pending;
127
+ case "settled":
128
+ return { result: "finish_blocked", from: pending.from, to: pending.to, detail: blockedFinishDetail(logPath) };
95
129
  }
96
130
  };
131
+ var finishInstalledUpgrade = async (context, from, to, finishAttempts) => {
132
+ const pending = { result: "finish_pending", from, to, detail: incompleteFinishDetail(context.logPath), finishAttempts };
133
+ recordAutoUpdateCheck(context.statePath, pending, new Date(context.now()).toISOString());
134
+ return checkAfterFinish(await attemptFinish(context), pending, context.logPath);
135
+ };
136
+ var settledFinishCheck = (state) => ({ result: "finish_blocked", from: state.from, to: state.to, detail: state.detail });
97
137
  var isInstallableRelease = (latest, installed) => latest !== void 0 && isNewerVersion(latest, installed) && isSameMajorVersion(latest, installed);
98
138
  var checkAndInstall = async (context) => {
99
139
  const installed = packageVersionAt(context.packageRoot);
@@ -101,9 +141,10 @@ var checkAndInstall = async (context) => {
101
141
  return { result: "failed", from: installed, detail: UNREADABLE_INSTALLED_VERSION };
102
142
  }
103
143
  const previous = readAutoUpdateState(context.statePath);
104
- const pendingFinish = hasPendingUpgradeFinish(previous, installed);
144
+ const pendingFinish = hasRetryableUpgradeFinish(previous, installed);
105
145
  const latest = await fetchLatestPublishedVersion({ packageName: context.location.packageName, fetchImpl: context.fetchImpl });
106
- if (pendingFinish && !isInstallableRelease(latest, installed)) return finishInstalledUpgrade(context, previous.from, installed);
146
+ if (pendingFinish && !isInstallableRelease(latest, installed)) return finishInstalledUpgrade(context, previous.from, installed, nextFinishAttempt(previous, installed));
147
+ if (hasSettledUpgradeFinish(previous, installed) && !isInstallableRelease(latest, installed)) return settledFinishCheck(previous);
107
148
  if (latest === void 0) return { result: "failed", from: installed, detail: UNREACHABLE_REGISTRY };
108
149
  if (!isNewerVersion(latest, installed)) return { result: "current", from: installed };
109
150
  if (!isSameMajorVersion(latest, installed)) {
@@ -120,7 +161,7 @@ var checkAndInstall = async (context) => {
120
161
  } catch (error) {
121
162
  return { result: "failed", from: installed, to: latest, detail: npmErrorMessage(error) };
122
163
  }
123
- return finishInstalledUpgrade(context, installed, latest);
164
+ return finishInstalledUpgrade(context, installed, latest, nextFinishAttempt(previous, latest));
124
165
  };
125
166
  var recordAutoUpdateCheck = (statePath, check, at) => updateAutoUpdateState(statePath, {
126
167
  lastCheckAt: at,
@@ -129,7 +170,8 @@ var recordAutoUpdateCheck = (statePath, check, at) => updateAutoUpdateState(stat
129
170
  to: check.to,
130
171
  at,
131
172
  detail: check.detail,
132
- announced: check.result === "updated" ? false : void 0
173
+ announced: check.result === "updated" ? false : void 0,
174
+ finishAttempts: check.finishAttempts
133
175
  });
134
176
  var runAutoUpdate = async (run = {}) => {
135
177
  if ((run.platform ?? process.platform) === "linux") return { kind: "linux" };
@@ -231,6 +273,8 @@ var upgradeInstalledPackage = async (subject, effects) => {
231
273
  };
232
274
 
233
275
  export {
276
+ upgradeFinishOutcome,
277
+ upgradeFinishExitCode,
234
278
  FINISH_UPGRADE_FLAG,
235
279
  runAutoUpdate,
236
280
  globalUpgradeSubject,
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  configFilePath
3
- } from "./chunk-2DSUVY6R.js";
3
+ } from "./chunk-Z6HPS67T.js";
4
4
  import {
5
5
  normalizeInstallSource
6
- } from "./chunk-SBR2UKUO.js";
6
+ } from "./chunk-QR6VE5ME.js";
7
7
 
8
8
  // src/install-source.ts
9
9
  import { readFileSync } from "fs";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getBaseUrl
3
- } from "./chunk-2DSUVY6R.js";
3
+ } from "./chunk-Z6HPS67T.js";
4
4
 
5
5
  // src/transcript-api.ts
6
6
  var fetchTranscriptRecipients = async (apiKey, baseUrl = getBaseUrl()) => {
@@ -2,17 +2,17 @@ import {
2
2
  CLAUDE_HOOK_EVENTS,
3
3
  GEMINI_HOOK_EVENTS,
4
4
  hasGeminiHooks
5
- } from "./chunk-NI2BRIHL.js";
5
+ } from "./chunk-JCWZ23MJ.js";
6
6
  import {
7
7
  CODEX_HOOK_EVENTS,
8
8
  hasCodexHooks,
9
9
  holdBudgetOf
10
- } from "./chunk-ZBF5WAP7.js";
10
+ } from "./chunk-ZUTU43FT.js";
11
11
  import {
12
12
  CURSOR_GATE_EVENTS,
13
13
  HOOK_LOCATOR_BINARY,
14
14
  hookCommandHoldBudget
15
- } from "./chunk-SBR2UKUO.js";
15
+ } from "./chunk-QR6VE5ME.js";
16
16
 
17
17
  // src/diagnostics/wiring.ts
18
18
  var record = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : null;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  PRETOOLUSE_GATED_TOOLS
3
- } from "./chunk-SBR2UKUO.js";
3
+ } from "./chunk-QR6VE5ME.js";
4
4
 
5
5
  // src/claude-tools.ts
6
6
  var POSTTOOLUSE_MIRROR_ONLY_TOOLS = ["TodoWrite", "Task", "WebFetch", "WebSearch"];
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  guardBinary
3
- } from "./chunk-ZBF5WAP7.js";
3
+ } from "./chunk-ZUTU43FT.js";
4
4
 
5
5
  // src/bell/install.ts
6
6
  import { join } from "path";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  SETUP_FLAGS
3
- } from "./chunk-ZW7KE2GP.js";
3
+ } from "./chunk-SBLPHUEB.js";
4
4
  import {
5
5
  parseFlags
6
6
  } from "./chunk-GMXKITVA.js";
@@ -9,7 +9,7 @@ import {
9
9
  } from "./chunk-7QLSKOSU.js";
10
10
  import {
11
11
  NPX_LATEST_COMMAND
12
- } from "./chunk-HOTK2D2S.js";
12
+ } from "./chunk-STQRUH3S.js";
13
13
  import {
14
14
  CLAUDE_CONNECTOR_GUIDE,
15
15
  CLAUDE_CONNECTOR_STEPS,
@@ -17,7 +17,7 @@ import {
17
17
  CLAUDE_CONNECTOR_URL,
18
18
  COWORK_CONNECTOR_LIMIT,
19
19
  COWORK_STANDING_INSTRUCTIONS
20
- } from "./chunk-SBR2UKUO.js";
20
+ } from "./chunk-QR6VE5ME.js";
21
21
 
22
22
  // src/cli/cowork.ts
23
23
  import { readFileSync } from "fs";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  resolveInstallSourceFor
3
- } from "./chunk-FQKFONAS.js";
3
+ } from "./chunk-4D2AYNSE.js";
4
4
  import {
5
5
  backupFile,
6
6
  readJsonSafe,
@@ -9,7 +9,7 @@ import {
9
9
  } from "./chunk-T7E75EKA.js";
10
10
  import {
11
11
  configFilePath
12
- } from "./chunk-2DSUVY6R.js";
12
+ } from "./chunk-Z6HPS67T.js";
13
13
 
14
14
  // src/shell-alias.ts
15
15
  import { homedir } from "os";
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  CLAUDE_HOOK_EVENTS,
3
3
  supportedClaudeEvents
4
- } from "./chunk-NI2BRIHL.js";
4
+ } from "./chunk-JCWZ23MJ.js";
5
5
  import {
6
6
  guardBinary,
7
7
  holdBudgetOf,
8
8
  isProtectedByScope,
9
9
  registerHookEntry
10
- } from "./chunk-ZBF5WAP7.js";
10
+ } from "./chunk-ZUTU43FT.js";
11
11
  import {
12
12
  HOOK_LOCATOR_BINARY,
13
13
  withHookHoldBudget
14
- } from "./chunk-SBR2UKUO.js";
14
+ } from "./chunk-QR6VE5ME.js";
15
15
 
16
16
  // src/claude-config.ts
17
17
  import { join } from "path";
@@ -9,7 +9,7 @@ import {
9
9
  } from "./chunk-3EGEA4KH.js";
10
10
  import {
11
11
  getBaseUrl
12
- } from "./chunk-2DSUVY6R.js";
12
+ } from "./chunk-Z6HPS67T.js";
13
13
 
14
14
  // src/cli/login-ui.ts
15
15
  import { hostname } from "os";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  redactSecretsFromContent
3
- } from "./chunk-SBR2UKUO.js";
3
+ } from "./chunk-QR6VE5ME.js";
4
4
 
5
5
  // src/crypto.ts
6
6
  import nacl from "tweetnacl";
@@ -4,18 +4,18 @@ import {
4
4
  } from "./chunk-POFBE6ZY.js";
5
5
  import {
6
6
  isNetworkFailure
7
- } from "./chunk-ELQAQZNO.js";
7
+ } from "./chunk-JXISQ7DT.js";
8
8
  import {
9
9
  clientReportClaims
10
- } from "./chunk-ZBF5WAP7.js";
10
+ } from "./chunk-ZUTU43FT.js";
11
11
  import {
12
12
  getApiKey,
13
13
  getBaseUrl
14
- } from "./chunk-2DSUVY6R.js";
14
+ } from "./chunk-Z6HPS67T.js";
15
15
  import {
16
16
  CLIENT_REPORT_PATH,
17
17
  degradedLine
18
- } from "./chunk-SBR2UKUO.js";
18
+ } from "./chunk-QR6VE5ME.js";
19
19
 
20
20
  // src/client-report-claim.ts
21
21
  import { createHash } from "crypto";
@@ -6,38 +6,38 @@ import {
6
6
  } from "./chunk-SGZJ5LYH.js";
7
7
  import {
8
8
  hookOwnerOf
9
- } from "./chunk-3Z7NUGXO.js";
9
+ } from "./chunk-SD3272LS.js";
10
10
  import {
11
11
  ensureDaemonRunning
12
- } from "./chunk-KTIY7ZIA.js";
12
+ } from "./chunk-VXRXFU6Q.js";
13
13
  import {
14
14
  buildTranscriptRecords,
15
15
  decodePublicKey,
16
16
  generateSessionKey,
17
17
  wrapSessionKey
18
- } from "./chunk-IX5EFNCI.js";
18
+ } from "./chunk-AUUXS44H.js";
19
19
  import {
20
20
  fetchTranscriptRecipients,
21
21
  uploadTranscriptRecords
22
- } from "./chunk-7AV2KBZC.js";
22
+ } from "./chunk-4FK6RZVJ.js";
23
23
  import {
24
24
  transcriptEnvironmentPreference,
25
25
  transcriptsEnabled
26
- } from "./chunk-XXBOA4ZL.js";
26
+ } from "./chunk-HPRZJKRO.js";
27
27
  import {
28
28
  readTranscriptPreference
29
- } from "./chunk-5DU7LJ7L.js";
29
+ } from "./chunk-ADSQDYYG.js";
30
30
  import {
31
31
  codexHome,
32
32
  pusharyDir
33
- } from "./chunk-ZBF5WAP7.js";
33
+ } from "./chunk-ZUTU43FT.js";
34
34
  import {
35
35
  writeJsonAtomic
36
36
  } from "./chunk-T7E75EKA.js";
37
37
  import {
38
38
  getApiKey,
39
39
  getBaseUrl
40
- } from "./chunk-2DSUVY6R.js";
40
+ } from "./chunk-Z6HPS67T.js";
41
41
 
42
42
  // src/transcript-registration.ts
43
43
  import { createHash } from "crypto";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  isSafeReadOnlyCommand
3
- } from "./chunk-SBR2UKUO.js";
3
+ } from "./chunk-QR6VE5ME.js";
4
4
 
5
5
  // src/ledger.ts
6
6
  import { appendFileSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, statSync } from "fs";