@pushary/agent-hooks 1.9.6 → 1.9.8

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 (111) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +3 -3
  3. package/data/cursor-plugin/README.md +3 -7
  4. package/data/vscode-plugin/README.md +1 -1
  5. package/dist/bin/pushary-bell-hook.js +22 -23
  6. package/dist/bin/pushary-bell.js +9 -9
  7. package/dist/bin/pushary-claude.js +27 -28
  8. package/dist/bin/pushary-clean.js +98 -76
  9. package/dist/bin/pushary-codex-bridge.js +18 -18
  10. package/dist/bin/pushary-codex-hook.js +32 -33
  11. package/dist/bin/pushary-codex.js +13 -13
  12. package/dist/bin/pushary-connect.js +24 -21
  13. package/dist/bin/pushary-cowork.js +5 -5
  14. package/dist/bin/pushary-daemon.js +51 -38
  15. package/dist/bin/pushary-disconnect.js +187 -52
  16. package/dist/bin/pushary-doctor.js +68 -56
  17. package/dist/bin/pushary-elicitation-hook.js +24 -25
  18. package/dist/bin/pushary-gemini-bridge.js +13 -13
  19. package/dist/bin/pushary-gemini-hook.js +29 -30
  20. package/dist/bin/pushary-hook.js +30 -32
  21. package/dist/bin/pushary-login.js +12 -12
  22. package/dist/bin/pushary-logout.js +105 -42
  23. package/dist/bin/pushary-mcp.js +9 -9
  24. package/dist/bin/pushary-mode.js +28 -31
  25. package/dist/bin/pushary-notification-hook.js +26 -28
  26. package/dist/bin/pushary-opencode-hook.js +28 -29
  27. package/dist/bin/pushary-permission-denied-hook.js +30 -32
  28. package/dist/bin/pushary-permission-hook.js +29 -31
  29. package/dist/bin/pushary-post-hook.js +26 -28
  30. package/dist/bin/pushary-prompt-hook.js +26 -28
  31. package/dist/bin/pushary-session-end-hook.js +26 -28
  32. package/dist/bin/pushary-session-start-hook.js +31 -31
  33. package/dist/bin/pushary-setup.js +98 -106
  34. package/dist/bin/pushary-stats.js +5 -5
  35. package/dist/bin/pushary-status.js +34 -18
  36. package/dist/bin/pushary-stop-hook.js +26 -28
  37. package/dist/bin/pushary-stopfailure-hook.js +26 -28
  38. package/dist/bin/pushary-suggestions.js +19 -21
  39. package/dist/bin/pushary-transcript-register.js +18 -19
  40. package/dist/bin/pushary-transcripts.js +7 -7
  41. package/dist/bin/pushary-upgrade.js +67 -31
  42. package/dist/bin/pushary-wait.js +23 -19
  43. package/dist/bin/pushary.js +15 -14
  44. package/dist/{chunk-BSZ7VBVT.js → chunk-2A53H4S6.js} +17 -15
  45. package/dist/{chunk-D7SOOVHX.js → chunk-2QGYMY7A.js} +83 -3
  46. package/dist/{chunk-SVTHEMM3.js → chunk-2QTO5YIT.js} +6 -6
  47. package/dist/{chunk-WN6WYUCV.js → chunk-2VZAALEJ.js} +5 -9
  48. package/dist/chunk-2WXF3QJR.js +49 -0
  49. package/dist/{chunk-UKNKYTTY.js → chunk-3I6IVOZV.js} +3 -3
  50. package/dist/chunk-3Z3A37WD.js +77 -0
  51. package/dist/{chunk-2QRE6QH2.js → chunk-5QUPKDI5.js} +1 -1
  52. package/dist/chunk-6TE27XZR.js +69 -0
  53. package/dist/{chunk-L6USMDTW.js → chunk-7DVNSQWF.js} +59 -15
  54. package/dist/{chunk-SNJ3BOCP.js → chunk-7PT35RY2.js} +27 -8
  55. package/dist/{chunk-CBVDW2N6.js → chunk-B64KHETR.js} +3 -3
  56. package/dist/chunk-BEJRK4DF.js +94 -0
  57. package/dist/chunk-BXET3ALR.js +46 -0
  58. package/dist/{chunk-DJ4BB264.js → chunk-CD47ZFFZ.js} +1 -1
  59. package/dist/{chunk-FBD3QGVJ.js → chunk-CKV3UPMU.js} +2 -2
  60. package/dist/{chunk-7JTVYR5B.js → chunk-CLOSJ4ES.js} +1 -1
  61. package/dist/{chunk-DA4FTGTK.js → chunk-DKMD6AWR.js} +4 -4
  62. package/dist/{chunk-SPXBXN23.js → chunk-DL7XWKYV.js} +7 -5
  63. package/dist/{chunk-VRT3EEZN.js → chunk-DPGSLWOS.js} +8 -8
  64. package/dist/{chunk-3BUAEQCY.js → chunk-DUZVXBBU.js} +1 -1
  65. package/dist/{chunk-6GERGJHF.js → chunk-EUW7JL2K.js} +0 -32
  66. package/dist/{chunk-75CA37FZ.js → chunk-FQ2GORVG.js} +2 -2
  67. package/dist/{chunk-WUKUXICK.js → chunk-HRULIYDU.js} +2 -2
  68. package/dist/{chunk-Q4E56K4X.js → chunk-I5IJRMNV.js} +78 -8
  69. package/dist/{chunk-MKJ3RTUS.js → chunk-I6MJXLMY.js} +2 -2
  70. package/dist/{chunk-YPXUD6DW.js → chunk-IAD2RT4L.js} +14 -14
  71. package/dist/{chunk-LBLCFD5K.js → chunk-IHFDPV7C.js} +2 -2
  72. package/dist/{chunk-BVCHY4OY.js → chunk-IHO3YQAN.js} +2 -2
  73. package/dist/{chunk-RDK7FX5F.js → chunk-KF3UZLYI.js} +1 -1
  74. package/dist/chunk-KFF7G225.js +599 -0
  75. package/dist/{chunk-TE5M6GGK.js → chunk-KHNFLYJO.js} +204 -28
  76. package/dist/{chunk-CCDVL63C.js → chunk-KRCR2CRQ.js} +9 -9
  77. package/dist/{chunk-ZC3TF4LR.js → chunk-LKLVTG3V.js} +18 -9
  78. package/dist/{chunk-4QKM44N6.js → chunk-LWOO567I.js} +4 -3
  79. package/dist/{chunk-KK54WQ74.js → chunk-M6BZZFVQ.js} +1 -1
  80. package/dist/{chunk-RIC6OOJX.js → chunk-MFF3ONG5.js} +21 -1
  81. package/dist/{chunk-IMGJYFCX.js → chunk-MGRFDGWU.js} +3 -2
  82. package/dist/{chunk-ZPW4MJOV.js → chunk-MKTJEXZ3.js} +3 -3
  83. package/dist/{chunk-2I23NFVT.js → chunk-MXHTGVFZ.js} +52 -9
  84. package/dist/{chunk-5BHROGRB.js → chunk-N4QSPI3B.js} +54 -5
  85. package/dist/{chunk-DGQTJDSJ.js → chunk-NWDG3MSW.js} +1 -1
  86. package/dist/chunk-OP7IHC2I.js +24 -0
  87. package/dist/{chunk-EVFY3VE6.js → chunk-QOLITCIP.js} +1 -1
  88. package/dist/{chunk-W4Q7NFXU.js → chunk-TCQ43LSG.js} +3 -3
  89. package/dist/chunk-TCWKTUAE.js +50 -0
  90. package/dist/{chunk-EZAFBC2C.js → chunk-V5HPPF3E.js} +8 -4
  91. package/dist/{chunk-Q23MMVTD.js → chunk-WG3K4TCH.js} +1 -1
  92. package/dist/{chunk-F56SB65Y.js → chunk-WS4H76EP.js} +2 -2
  93. package/dist/{chunk-HWQNQVY6.js → chunk-WWOHTTVP.js} +2 -2
  94. package/dist/{chunk-NVGDMTX3.js → chunk-YIG2R3BJ.js} +9 -7
  95. package/dist/{chunk-HJXZJF6O.js → chunk-ZBHUHJG6.js} +4 -4
  96. package/dist/{chunk-5AXCOTIT.js → chunk-ZBK6E2OR.js} +1 -1
  97. package/dist/{chunk-5PMTC2CB.js → chunk-ZN3C6GBG.js} +84 -673
  98. package/dist/{chunk-GQHZIBAZ.js → chunk-ZSTSEBG7.js} +1 -1
  99. package/dist/{chunk-PYZC54KA.js → chunk-ZW3XZLJC.js} +61 -17
  100. package/dist/{global-upgrade-7F5RP45B.js → global-upgrade-I56HNM23.js} +6 -6
  101. package/dist/{paths-MELXIVBO.js → paths-AGY43CXS.js} +2 -2
  102. package/dist/reapply-IA5XUKWW.js +57 -0
  103. package/dist/src/index.d.ts +1 -0
  104. package/dist/src/index.js +19 -20
  105. package/dist/{upgrade-lock-AHRBA66K.js → upgrade-lock-B34TAUKV.js} +5 -3
  106. package/package.json +1 -1
  107. package/dist/chunk-HT3WMM6Q.js +0 -44
  108. package/dist/chunk-IR5FRUPQ.js +0 -197
  109. package/dist/chunk-JUFKJCZG.js +0 -38
  110. package/dist/chunk-SJN22ADZ.js +0 -86
  111. package/dist/reapply-NOB2Q6C4.js +0 -35
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  isSafeReadOnlyCommand
3
- } from "./chunk-Q4E56K4X.js";
3
+ } from "./chunk-I5IJRMNV.js";
4
4
 
5
5
  // src/ledger.ts
6
6
  import { appendFileSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, statSync } from "fs";
@@ -1,17 +1,20 @@
1
1
  import {
2
2
  claimUpgradeLock,
3
3
  finishWithUpgradeLock,
4
+ forkFinishWithUpgradeLock,
4
5
  installWithUpgradeLock,
5
6
  releaseAutoUpdateLock
6
- } from "./chunk-EZAFBC2C.js";
7
+ } from "./chunk-V5HPPF3E.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-SNJ3BOCP.js";
17
+ } from "./chunk-7PT35RY2.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-HJXZJF6O.js";
30
+ } from "./chunk-ZBHUHJG6.js";
28
31
  import {
29
32
  NPX_LATEST_COMMAND
30
- } from "./chunk-L6USMDTW.js";
33
+ } from "./chunk-7DVNSQWF.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-Q4E56K4X.js";
42
+ } from "./chunk-I5IJRMNV.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,
@@ -5,15 +5,15 @@ import {
5
5
  readGlobalUpgradeSubject,
6
6
  upgradeInstalledPackage,
7
7
  withUpgradeLock
8
- } from "./chunk-PYZC54KA.js";
9
- import "./chunk-EZAFBC2C.js";
10
- import "./chunk-SNJ3BOCP.js";
8
+ } from "./chunk-ZW3XZLJC.js";
9
+ import "./chunk-V5HPPF3E.js";
10
+ import "./chunk-7PT35RY2.js";
11
11
  import "./chunk-POFBE6ZY.js";
12
12
  import "./chunk-KZERVKTD.js";
13
- import "./chunk-HJXZJF6O.js";
13
+ import "./chunk-ZBHUHJG6.js";
14
14
  import "./chunk-T7E75EKA.js";
15
- import "./chunk-L6USMDTW.js";
16
- import "./chunk-Q4E56K4X.js";
15
+ import "./chunk-7DVNSQWF.js";
16
+ import "./chunk-I5IJRMNV.js";
17
17
  export {
18
18
  finishGlobalUpgrade,
19
19
  finishUpgradeWithLock,
@@ -32,8 +32,8 @@ import {
32
32
  pusharyDir,
33
33
  vscodePluginDir,
34
34
  vscodePluginMcp
35
- } from "./chunk-HJXZJF6O.js";
36
- import "./chunk-Q4E56K4X.js";
35
+ } from "./chunk-ZBHUHJG6.js";
36
+ import "./chunk-I5IJRMNV.js";
37
37
  export {
38
38
  autoUpdateLock,
39
39
  autoUpdateLog,
@@ -0,0 +1,57 @@
1
+ import {
2
+ ensureCodexTrustAfterReapply,
3
+ inspectConfiguredManagedProviders,
4
+ reapplyAllAgents,
5
+ reapplyClaudeForVersion,
6
+ reapplyClaudeSettings,
7
+ reapplyCodexSettings,
8
+ reapplyCursorPlugin,
9
+ reapplyGeminiSettings,
10
+ reapplyOpenCodePlugin,
11
+ reapplyVsCodePlugin,
12
+ repairCodexHolds
13
+ } from "./chunk-MXHTGVFZ.js";
14
+ import "./chunk-3Z3A37WD.js";
15
+ import "./chunk-MGRFDGWU.js";
16
+ import "./chunk-MFF3ONG5.js";
17
+ import "./chunk-KHNFLYJO.js";
18
+ import "./chunk-RIVNNBEK.js";
19
+ import "./chunk-YIG2R3BJ.js";
20
+ import "./chunk-DL7XWKYV.js";
21
+ import "./chunk-2QGYMY7A.js";
22
+ import "./chunk-3I6IVOZV.js";
23
+ import "./chunk-WG3K4TCH.js";
24
+ import "./chunk-XHKBHWLX.js";
25
+ import "./chunk-6ICPEJY5.js";
26
+ import "./chunk-KRCR2CRQ.js";
27
+ import "./chunk-N6IOSZOE.js";
28
+ import "./chunk-CD47ZFFZ.js";
29
+ import "./chunk-2VZAALEJ.js";
30
+ import "./chunk-DKMD6AWR.js";
31
+ import "./chunk-POFBE6ZY.js";
32
+ import "./chunk-GMXKITVA.js";
33
+ import "./chunk-MKTJEXZ3.js";
34
+ import "./chunk-LWOO567I.js";
35
+ import "./chunk-TCQ43LSG.js";
36
+ import "./chunk-DUZVXBBU.js";
37
+ import "./chunk-7QLSKOSU.js";
38
+ import "./chunk-KZERVKTD.js";
39
+ import "./chunk-FQ2GORVG.js";
40
+ import "./chunk-ZBHUHJG6.js";
41
+ import "./chunk-T7E75EKA.js";
42
+ import "./chunk-5QUPKDI5.js";
43
+ import "./chunk-7DVNSQWF.js";
44
+ import "./chunk-I5IJRMNV.js";
45
+ export {
46
+ ensureCodexTrustAfterReapply,
47
+ inspectConfiguredManagedProviders,
48
+ reapplyAllAgents,
49
+ reapplyClaudeForVersion,
50
+ reapplyClaudeSettings,
51
+ reapplyCodexSettings,
52
+ reapplyCursorPlugin,
53
+ reapplyGeminiSettings,
54
+ reapplyOpenCodePlugin,
55
+ reapplyVsCodePlugin,
56
+ repairCodexHolds
57
+ };
@@ -183,6 +183,7 @@ interface AnswerResult {
183
183
  value?: string;
184
184
  note?: string;
185
185
  }
186
+
186
187
  declare const askUser: (apiKey: string, params: AskUserParams, timeoutMs?: number) => Promise<AskUserResponse>;
187
188
  declare const waitForAnswer: (apiKey: string, correlationId: string, timeoutMs?: number, signal?: AbortSignal) => Promise<AnswerResult>;
188
189
  declare const cancelQuestion: (apiKey: string, correlationId: string, signal?: AbortSignal) => Promise<{
package/dist/src/index.js CHANGED
@@ -1,15 +1,14 @@
1
1
  import {
2
2
  handlePreToolUse
3
- } from "../chunk-BSZ7VBVT.js";
4
- import "../chunk-TE5M6GGK.js";
5
- import "../chunk-IR5FRUPQ.js";
6
- import "../chunk-BVCHY4OY.js";
7
- import "../chunk-GQHZIBAZ.js";
3
+ } from "../chunk-2A53H4S6.js";
4
+ import "../chunk-KHNFLYJO.js";
5
+ import "../chunk-IHO3YQAN.js";
6
+ import "../chunk-ZSTSEBG7.js";
8
7
  import "../chunk-5OP5MQI7.js";
9
- import "../chunk-UKNKYTTY.js";
8
+ import "../chunk-3I6IVOZV.js";
10
9
  import {
11
10
  fetchAccountPublicKey
12
- } from "../chunk-7JTVYR5B.js";
11
+ } from "../chunk-CLOSJ4ES.js";
13
12
  import "../chunk-6ICPEJY5.js";
14
13
  import {
15
14
  fetchModeOverride,
@@ -19,33 +18,33 @@ import {
19
18
  handlePostToolUse,
20
19
  handleStop,
21
20
  reportEvent
22
- } from "../chunk-CCDVL63C.js";
21
+ } from "../chunk-KRCR2CRQ.js";
23
22
  import "../chunk-N6IOSZOE.js";
24
- import "../chunk-DJ4BB264.js";
23
+ import "../chunk-CD47ZFFZ.js";
25
24
  import {
26
25
  askUser,
27
26
  cancelQuestion,
28
27
  waitForAnswer
29
- } from "../chunk-WN6WYUCV.js";
30
- import "../chunk-DA4FTGTK.js";
28
+ } from "../chunk-2VZAALEJ.js";
29
+ import "../chunk-DKMD6AWR.js";
31
30
  import "../chunk-POFBE6ZY.js";
32
- import "../chunk-ZPW4MJOV.js";
33
- import "../chunk-4QKM44N6.js";
34
- import "../chunk-W4Q7NFXU.js";
35
- import "../chunk-3BUAEQCY.js";
31
+ import "../chunk-MKTJEXZ3.js";
32
+ import "../chunk-LWOO567I.js";
33
+ import "../chunk-TCQ43LSG.js";
34
+ import "../chunk-DUZVXBBU.js";
36
35
  import "../chunk-7QLSKOSU.js";
37
36
  import "../chunk-KZERVKTD.js";
38
- import "../chunk-75CA37FZ.js";
39
- import "../chunk-HJXZJF6O.js";
37
+ import "../chunk-FQ2GORVG.js";
38
+ import "../chunk-ZBHUHJG6.js";
40
39
  import "../chunk-T7E75EKA.js";
41
40
  import {
42
41
  getApiKey,
43
42
  getBaseUrl
44
- } from "../chunk-2QRE6QH2.js";
45
- import "../chunk-L6USMDTW.js";
43
+ } from "../chunk-5QUPKDI5.js";
44
+ import "../chunk-7DVNSQWF.js";
46
45
  import {
47
46
  resolvePolicy
48
- } from "../chunk-Q4E56K4X.js";
47
+ } from "../chunk-I5IJRMNV.js";
49
48
  export {
50
49
  askUser,
51
50
  cancelQuestion,
@@ -1,16 +1,18 @@
1
1
  import {
2
2
  claimUpgradeLock,
3
3
  finishWithUpgradeLock,
4
+ forkFinishWithUpgradeLock,
4
5
  installWithUpgradeLock,
5
6
  ownsUpgradeLock,
6
7
  releaseAutoUpdateLock
7
- } from "./chunk-EZAFBC2C.js";
8
- import "./chunk-HJXZJF6O.js";
8
+ } from "./chunk-V5HPPF3E.js";
9
+ import "./chunk-ZBHUHJG6.js";
9
10
  import "./chunk-T7E75EKA.js";
10
- import "./chunk-Q4E56K4X.js";
11
+ import "./chunk-I5IJRMNV.js";
11
12
  export {
12
13
  claimUpgradeLock,
13
14
  finishWithUpgradeLock,
15
+ forkFinishWithUpgradeLock,
14
16
  installWithUpgradeLock,
15
17
  ownsUpgradeLock,
16
18
  releaseAutoUpdateLock
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushary/agent-hooks",
3
- "version": "1.9.6",
3
+ "version": "1.9.8",
4
4
  "description": "Permission hooks for AI coding agents: route tool approvals through Pushary push notifications",
5
5
  "keywords": [
6
6
  "pushary",
@@ -1,44 +0,0 @@
1
- import {
2
- createIo
3
- } from "./chunk-U4TMAANR.js";
4
- import {
5
- describeKeyCheck,
6
- keyCheckFromResponse
7
- } from "./chunk-4QKM44N6.js";
8
- import {
9
- EXIT
10
- } from "./chunk-KZERVKTD.js";
11
-
12
- // src/cli/report-key.ts
13
- var { dim, yellow } = createIo();
14
- var printKeyCheck = (check, baseUrl) => {
15
- const report = describeKeyCheck(check, baseUrl);
16
- console.log(` ${yellow("!")} ${report.message}`);
17
- for (const line of report.next) console.log(` ${dim(line)}`);
18
- return report;
19
- };
20
- var exitIfKeyFailure = async (response, baseUrl) => {
21
- const check = await keyCheckFromResponse(response, baseUrl);
22
- if (!check) return;
23
- const report = printKeyCheck(check, baseUrl);
24
- process.exit(report.exitCode);
25
- };
26
- var responseDetail = async (response) => {
27
- try {
28
- const body = await response.json();
29
- const text = [body.error, body.message].find((part) => typeof part === "string" && part);
30
- if (typeof text === "string") return text;
31
- } catch {
32
- }
33
- return response.statusText || `HTTP ${response.status}`;
34
- };
35
- var exitOnFailedResponse = async (response, baseUrl) => {
36
- await exitIfKeyFailure(response, baseUrl);
37
- console.log(` ${yellow("!")} Failed: ${await responseDetail(response)}`);
38
- process.exit(EXIT.FAILED);
39
- };
40
-
41
- export {
42
- printKeyCheck,
43
- exitOnFailedResponse
44
- };
@@ -1,197 +0,0 @@
1
- import {
2
- CLAUDE_HOOK_EVENTS,
3
- supportedClaudeEvents
4
- } from "./chunk-UKNKYTTY.js";
5
- import {
6
- guardBinary,
7
- holdBudgetOf,
8
- isProtectedByScope,
9
- registerHookEntry
10
- } from "./chunk-HJXZJF6O.js";
11
- import {
12
- HOOK_LOCATOR_BINARY,
13
- withHookHoldBudget
14
- } from "./chunk-Q4E56K4X.js";
15
-
16
- // src/claude-config.ts
17
- import { join } from "path";
18
- import { isDeepStrictEqual } from "util";
19
- var PUSHARY_MCP_URL = "https://pushary.com/api/mcp/mcp";
20
- var PUSHARY_PERMISSION_RULE = "mcp__pushary__*";
21
- var asRecord = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
22
- var ensureRecord = (target, key) => {
23
- const existing = asRecord(target[key]);
24
- if (existing) return existing;
25
- const created = {};
26
- target[key] = created;
27
- return created;
28
- };
29
- var isPusharyPermission = (rule) => typeof rule === "string" && (rule.includes("pushary") || rule.includes("MCP(pushary"));
30
- var HOOK_BINARIES = /* @__PURE__ */ new Set([
31
- ...CLAUDE_HOOK_EVENTS.map((hook) => hook.binary),
32
- HOOK_LOCATOR_BINARY
33
- ]);
34
- var namesPusharyBinary = (command) => command.split(/[\s/\\"']+/).some((segment) => HOOK_BINARIES.has(segment.replace(/\.(cmd|exe)$/i, "")));
35
- var isPusharyHook = (entry2, scope) => {
36
- const hooks = asRecord(entry2)?.hooks;
37
- if (!Array.isArray(hooks)) return false;
38
- return hooks.some((hook) => {
39
- const command = String(asRecord(hook)?.command ?? "");
40
- if (isProtectedByScope(command, scope)) return false;
41
- return namesPusharyBinary(command);
42
- });
43
- };
44
- var pusharyMcpServer = (apiKey) => ({
45
- type: "http",
46
- url: PUSHARY_MCP_URL,
47
- headers: { Authorization: `Bearer ${apiKey}` }
48
- });
49
- var addClaudeMcpServer = (config, apiKey) => {
50
- const mcpServers = ensureRecord(config, "mcpServers");
51
- mcpServers.pushary = pusharyMcpServer(apiKey);
52
- };
53
- var isClaudeMcpSnapshot = (value) => {
54
- if (!value || typeof value !== "object" || Array.isArray(value)) return false;
55
- const snapshot = value;
56
- return typeof snapshot.hadMcpServers === "boolean" && typeof snapshot.mcpServersWasRecord === "boolean" && (!snapshot.hadMcpServers || snapshot.mcpServersWasRecord || Object.hasOwn(snapshot, "mcpServers")) && typeof snapshot.hadPushary === "boolean" && (!snapshot.hadPushary || Object.hasOwn(snapshot, "pushary")) && (!Object.hasOwn(snapshot, "installedPushary") || asRecord(snapshot.installedPushary)?.type === "http" && asRecord(snapshot.installedPushary)?.url === PUSHARY_MCP_URL);
57
- };
58
- var captureClaudeMcpServer = (config, apiKey) => {
59
- const mcpServers = asRecord(config.mcpServers);
60
- const hadMcpServers = Object.hasOwn(config, "mcpServers");
61
- return {
62
- hadMcpServers,
63
- mcpServersWasRecord: Boolean(mcpServers),
64
- ...hadMcpServers && !mcpServers ? { mcpServers: structuredClone(config.mcpServers) } : {},
65
- hadPushary: Boolean(mcpServers && Object.hasOwn(mcpServers, "pushary")),
66
- ...mcpServers && Object.hasOwn(mcpServers, "pushary") ? { pushary: structuredClone(mcpServers.pushary) } : {},
67
- ...apiKey ? { installedPushary: pusharyMcpServer(apiKey) } : {}
68
- };
69
- };
70
- var updateClaudeMcpSnapshot = (snapshot, apiKey) => ({
71
- ...snapshot,
72
- installedPushary: pusharyMcpServer(apiKey)
73
- });
74
- var restoreClaudeMcpServer = (config, snapshot) => {
75
- const mcpServers = asRecord(config.mcpServers);
76
- const current = asRecord(mcpServers?.pushary);
77
- if (Object.hasOwn(snapshot, "installedPushary")) {
78
- if (!isDeepStrictEqual(mcpServers?.pushary, snapshot.installedPushary)) return false;
79
- } else if (current?.type !== "http" || current.url !== PUSHARY_MCP_URL) {
80
- return false;
81
- }
82
- if (!snapshot.mcpServersWasRecord) {
83
- if (Object.keys(mcpServers).length === 1) {
84
- if (snapshot.hadMcpServers) config.mcpServers = structuredClone(snapshot.mcpServers);
85
- else delete config.mcpServers;
86
- } else {
87
- delete mcpServers.pushary;
88
- }
89
- } else if (snapshot.hadPushary) {
90
- mcpServers.pushary = structuredClone(snapshot.pushary);
91
- } else {
92
- delete mcpServers.pushary;
93
- if (!snapshot.hadMcpServers && Object.keys(mcpServers).length === 0) delete config.mcpServers;
94
- }
95
- return true;
96
- };
97
- var removeClaudeMcpServers = (config) => {
98
- let changed = false;
99
- const removeFrom = (target) => {
100
- const mcpServers = asRecord(target.mcpServers);
101
- if (!mcpServers?.pushary) return;
102
- delete mcpServers.pushary;
103
- if (Object.keys(mcpServers).length === 0) delete target.mcpServers;
104
- changed = true;
105
- };
106
- removeFrom(config);
107
- const projects = asRecord(config.projects);
108
- if (projects) {
109
- for (const project of Object.values(projects)) {
110
- const projectConfig = asRecord(project);
111
- if (projectConfig) removeFrom(projectConfig);
112
- }
113
- }
114
- return changed;
115
- };
116
- var removePusharyToolPermissions = (settings) => {
117
- const permissions = asRecord(settings.permissions);
118
- if (!permissions || !Array.isArray(permissions.allow)) return false;
119
- const filtered = permissions.allow.filter((rule) => !isPusharyPermission(rule));
120
- if (filtered.length === permissions.allow.length) return false;
121
- if (filtered.length === 0) delete permissions.allow;
122
- else permissions.allow = filtered;
123
- if (Object.keys(permissions).length === 0) delete settings.permissions;
124
- return true;
125
- };
126
- var addPusharyToolPermissions = (settings) => {
127
- const permissions = ensureRecord(settings, "permissions");
128
- const allow = Array.isArray(permissions.allow) ? permissions.allow : [];
129
- const filtered = allow.filter((rule) => !isPusharyPermission(rule));
130
- if (!filtered.includes(PUSHARY_PERMISSION_RULE)) {
131
- filtered.push(PUSHARY_PERMISSION_RULE);
132
- }
133
- permissions.allow = filtered;
134
- };
135
- var addPusharyHooks = (settings, binDir, version = null) => {
136
- const resolve = (name) => guardBinary(binDir ? join(binDir, name) : name);
137
- const hooks = ensureRecord(settings, "hooks");
138
- const supported = new Map(supportedClaudeEvents(version).map((hook) => [hook.event, hook]));
139
- for (const known of CLAUDE_HOOK_EVENTS) {
140
- const current = Array.isArray(hooks[known.event]) ? hooks[known.event] : [];
141
- const definition = supported.get(known.event);
142
- if (definition) {
143
- hooks[known.event] = registerHookEntry(current, isPusharyHook, entry(definition, resolve));
144
- continue;
145
- }
146
- const others = current.filter((item) => !isPusharyHook(item));
147
- if (others.length > 0) {
148
- hooks[known.event] = others;
149
- } else {
150
- delete hooks[known.event];
151
- }
152
- }
153
- };
154
- var entry = (definition, resolve) => ({
155
- ...definition.matcher ? { matcher: definition.matcher } : {},
156
- hooks: [{
157
- type: "command",
158
- command: withHookHoldBudget(resolve(definition.binary), holdBudgetOf(definition)),
159
- timeout: definition.timeout
160
- }]
161
- });
162
- var removePusharySettings = (settings, scope) => {
163
- let changed = scope?.keepMcpServer === true ? false : removeClaudeMcpServers(settings);
164
- if (scope?.keepMcpServer !== true && removePusharyToolPermissions(settings)) changed = true;
165
- const hooks = asRecord(settings.hooks);
166
- if (hooks) {
167
- for (const { event: key } of CLAUDE_HOOK_EVENTS) {
168
- const entries = hooks[key];
169
- if (!Array.isArray(entries)) continue;
170
- const filtered = entries.filter((entry2) => !isPusharyHook(entry2, scope));
171
- if (filtered.length !== entries.length) {
172
- if (filtered.length === 0) {
173
- delete hooks[key];
174
- } else {
175
- hooks[key] = filtered;
176
- }
177
- changed = true;
178
- }
179
- }
180
- if (Object.keys(hooks).length === 0) delete settings.hooks;
181
- }
182
- return changed;
183
- };
184
-
185
- export {
186
- isPusharyHook,
187
- addClaudeMcpServer,
188
- isClaudeMcpSnapshot,
189
- captureClaudeMcpServer,
190
- updateClaudeMcpSnapshot,
191
- restoreClaudeMcpServer,
192
- removeClaudeMcpServers,
193
- removePusharyToolPermissions,
194
- addPusharyToolPermissions,
195
- addPusharyHooks,
196
- removePusharySettings
197
- };
@@ -1,38 +0,0 @@
1
- import {
2
- NPX_LATEST_COMMAND
3
- } from "./chunk-L6USMDTW.js";
4
-
5
- // src/setup/codex-trust.ts
6
- var CODEX_TRUST_TELEMETRY = {
7
- verified: "verified",
8
- refused: "manual",
9
- unlisted: "manual",
10
- skipped: "unverified",
11
- unavailable: "unverified"
12
- };
13
- var isUnanswered = (confirmation) => confirmation.kind === "skipped" || confirmation.kind === "unavailable";
14
- var codexTrustOutcome = (confirmation, portedTrustWritten) => isUnanswered(confirmation) && !portedTrustWritten ? "manual" : CODEX_TRUST_TELEMETRY[confirmation.kind];
15
- var CODEX_TRUST_REFUSED = "Codex did not accept the trust Pushary asked for, so its hooks are not trusted yet. Open Codex, run /hooks, and choose Trust for the Pushary hooks.";
16
- var describeUnlistedCodexHooks = (warnings) => {
17
- const said = warnings[0] ? ` Codex said: ${warnings[0]}` : "";
18
- return `Codex does not list the Pushary hooks, so it will not run them.${said} Run ${NPX_LATEST_COMMAND} doctor for details.`;
19
- };
20
- var describeCodexTrustConfirmation = (confirmation) => {
21
- switch (confirmation.kind) {
22
- case "verified":
23
- return confirmation.wrote ? "Codex trusted the Pushary hooks when asked, and confirmed it." : "Codex confirms the Pushary hooks are trusted.";
24
- case "refused":
25
- return confirmation.writeError ? `${CODEX_TRUST_REFUSED} Codex said: ${confirmation.writeError}` : CODEX_TRUST_REFUSED;
26
- case "unlisted":
27
- return describeUnlistedCodexHooks(confirmation.warnings);
28
- case "skipped":
29
- return `Pushary did not ask Codex to confirm the trust: ${confirmation.reason}.`;
30
- case "unavailable":
31
- return `Codex could not be asked to confirm the Pushary hooks are trusted (${confirmation.reason}).`;
32
- }
33
- };
34
-
35
- export {
36
- codexTrustOutcome,
37
- describeCodexTrustConfirmation
38
- };