@pushary/agent-hooks 1.9.57 → 1.9.59

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 (119) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/{api-RQAY3A5V.js → api-UVJGNZIF.js} +10 -10
  3. package/dist/bin/pushary-bell-hook.js +27 -27
  4. package/dist/bin/pushary-bell.js +10 -10
  5. package/dist/bin/pushary-claude.js +26 -26
  6. package/dist/bin/pushary-clean.js +49 -46
  7. package/dist/bin/pushary-codex-bridge.js +21 -21
  8. package/dist/bin/pushary-codex-hook.js +32 -32
  9. package/dist/bin/pushary-codex-session.js +10 -8
  10. package/dist/bin/pushary-codex.js +14 -14
  11. package/dist/bin/pushary-connect.js +27 -26
  12. package/dist/bin/pushary-cowork.js +5 -5
  13. package/dist/bin/pushary-daemon.js +37 -37
  14. package/dist/bin/pushary-disconnect.js +26 -26
  15. package/dist/bin/pushary-doctor.js +41 -39
  16. package/dist/bin/pushary-elicitation-hook.js +27 -27
  17. package/dist/bin/pushary-gemini-bridge.js +15 -15
  18. package/dist/bin/pushary-gemini-hook.js +29 -29
  19. package/dist/bin/pushary-hook.js +31 -31
  20. package/dist/bin/pushary-login.js +13 -13
  21. package/dist/bin/pushary-logout.js +26 -26
  22. package/dist/bin/pushary-mcp.js +11 -11
  23. package/dist/bin/pushary-mode.js +13 -13
  24. package/dist/bin/pushary-notification-hook.js +26 -26
  25. package/dist/bin/pushary-opencode-hook.js +28 -28
  26. package/dist/bin/pushary-permission-denied-hook.js +31 -31
  27. package/dist/bin/pushary-permission-hook.js +30 -30
  28. package/dist/bin/pushary-post-hook.js +26 -26
  29. package/dist/bin/pushary-prompt-hook.js +26 -26
  30. package/dist/bin/pushary-session-end-hook.js +26 -26
  31. package/dist/bin/pushary-session-start-hook.js +33 -33
  32. package/dist/bin/pushary-setup.js +65 -268
  33. package/dist/bin/pushary-stats.js +5 -5
  34. package/dist/bin/pushary-status.js +32 -30
  35. package/dist/bin/pushary-stop-hook.js +26 -26
  36. package/dist/bin/pushary-stopfailure-hook.js +26 -26
  37. package/dist/bin/pushary-suggestions.js +13 -13
  38. package/dist/bin/pushary-transcript-register.js +18 -18
  39. package/dist/bin/pushary-transcripts.js +7 -7
  40. package/dist/bin/pushary-upgrade.js +107 -58
  41. package/dist/bin/pushary-wait.js +13 -13
  42. package/dist/bin/pushary.js +7 -7
  43. package/dist/chunk-2FVP7WRP.js +378 -0
  44. package/dist/{chunk-W6363YYZ.js → chunk-2WMZDKPM.js} +8 -8
  45. package/dist/{chunk-N3NSWWNU.js → chunk-3N2ZTHZZ.js} +1 -1
  46. package/dist/{chunk-JCMSISCC.js → chunk-3NROUNIS.js} +2 -2
  47. package/dist/{chunk-7RZO6VWD.js → chunk-3RKIJM26.js} +2 -2
  48. package/dist/{chunk-Z7Q36I4K.js → chunk-4QF2YLYK.js} +11 -7
  49. package/dist/{chunk-LVDC3RUE.js → chunk-4XXZUFWN.js} +1 -1
  50. package/dist/{chunk-BAJ3A3BU.js → chunk-5BNXJTOZ.js} +5 -2
  51. package/dist/{chunk-A54W5A74.js → chunk-5EFNBL6V.js} +3 -3
  52. package/dist/{chunk-4YTFYILS.js → chunk-5JWCWALO.js} +9 -9
  53. package/dist/{chunk-3IBUZQKM.js → chunk-5O6D4J2K.js} +2 -2
  54. package/dist/{chunk-DDQRYX2L.js → chunk-5PP4455M.js} +3 -3
  55. package/dist/{chunk-NQDEMRAS.js → chunk-6ONSTCDJ.js} +5 -5
  56. package/dist/{chunk-ECJJKDP7.js → chunk-75UYYIFJ.js} +1 -1
  57. package/dist/{chunk-GZL3KEPC.js → chunk-762CDAJJ.js} +140 -136
  58. package/dist/{chunk-YKYVDHIY.js → chunk-AS4Z6KS4.js} +1 -1
  59. package/dist/{chunk-4YNNAF53.js → chunk-AY32RSUC.js} +2 -2
  60. package/dist/{chunk-I43PY5G3.js → chunk-BKVX53QR.js} +1 -1
  61. package/dist/{chunk-5SFM6XB4.js → chunk-BMPZ5HVJ.js} +2 -2
  62. package/dist/{chunk-7OQ4AJC7.js → chunk-BRUHVTFB.js} +2 -7
  63. package/dist/{chunk-OZSP4RIQ.js → chunk-CPRA7IEK.js} +174 -41
  64. package/dist/{chunk-C3IWX6KU.js → chunk-D6CXQIXO.js} +1 -1
  65. package/dist/{chunk-T45PAPOG.js → chunk-DK35M4TH.js} +5 -5
  66. package/dist/{chunk-K45CFSYV.js → chunk-DS7X36Z3.js} +4 -4
  67. package/dist/{chunk-IBSRULIY.js → chunk-EBQTWH5O.js} +10 -10
  68. package/dist/{chunk-OLNBYAPI.js → chunk-EHCIQA5D.js} +4 -4
  69. package/dist/{chunk-2NIRYGTK.js → chunk-IBXHVYN2.js} +2 -2
  70. package/dist/{chunk-HCIB4YNB.js → chunk-JAKBCKEB.js} +3 -3
  71. package/dist/{chunk-PZDMZ7LM.js → chunk-JBCMXSBO.js} +5 -5
  72. package/dist/{chunk-IRZ5FVWG.js → chunk-KAJDKYUM.js} +3 -3
  73. package/dist/{chunk-AN6TVB2H.js → chunk-KHDD74MK.js} +5 -5
  74. package/dist/{chunk-ZZB4J6CX.js → chunk-KQHY6L3X.js} +4 -4
  75. package/dist/{chunk-UPFFO4F6.js → chunk-KQWN7C5C.js} +4 -4
  76. package/dist/{chunk-D2EETYAL.js → chunk-KW3DED2A.js} +14 -369
  77. package/dist/{chunk-TWLWDIFB.js → chunk-KZCYHWDF.js} +4 -2
  78. package/dist/{chunk-RFAF3TOX.js → chunk-L3NVHPBU.js} +94 -15
  79. package/dist/{chunk-LVZYIUSR.js → chunk-LAEW5QQD.js} +1 -1
  80. package/dist/{chunk-SQ5G6A6K.js → chunk-M46WDK64.js} +1 -1
  81. package/dist/{chunk-LVWXRXT7.js → chunk-M6MOQBR5.js} +1 -1
  82. package/dist/{chunk-FBKVCODG.js → chunk-MA37WNVS.js} +3 -3
  83. package/dist/{chunk-XTZHUIGJ.js → chunk-MMLIQDTG.js} +1 -1
  84. package/dist/{chunk-CB565EVO.js → chunk-MSU3VKGJ.js} +2 -2
  85. package/dist/{chunk-ZU6L34DQ.js → chunk-MYU5D5VH.js} +4 -4
  86. package/dist/{chunk-WXZN5CS3.js → chunk-OZIXBN3O.js} +2 -2
  87. package/dist/{chunk-JSQOHMNJ.js → chunk-PVANKDWM.js} +1 -1
  88. package/dist/{chunk-JYXIARGW.js → chunk-RAMQBSVZ.js} +1 -1
  89. package/dist/{chunk-S5LX25XE.js → chunk-RQDP2SJY.js} +1 -1
  90. package/dist/{chunk-DS6OR5OS.js → chunk-SIU6OWA6.js} +6 -6
  91. package/dist/{chunk-QLDTBZBP.js → chunk-T65RIQK2.js} +6 -6
  92. package/dist/{chunk-2PJENKRJ.js → chunk-TCH5UCPR.js} +77 -30
  93. package/dist/{chunk-QQYUWTYS.js → chunk-TDOKDCFH.js} +3 -3
  94. package/dist/chunk-UFJS4RR7.js +266 -0
  95. package/dist/{chunk-AEXACKDR.js → chunk-US3IT6ZC.js} +3 -3
  96. package/dist/{chunk-4QD7VE4E.js → chunk-UTJ5465F.js} +2 -2
  97. package/dist/{chunk-M7NX25ZA.js → chunk-UVZK5LIK.js} +1 -1
  98. package/dist/{chunk-IUOUNRLH.js → chunk-V3PDUDPB.js} +2 -2
  99. package/dist/{chunk-K5SDLOFS.js → chunk-VAJHDTJX.js} +11 -11
  100. package/dist/{chunk-QTCFEKLJ.js → chunk-W47WL6JY.js} +1 -1
  101. package/dist/{chunk-6QM54CSJ.js → chunk-WW24SG27.js} +5 -5
  102. package/dist/{chunk-3TJLPABQ.js → chunk-WWAVHLGS.js} +3 -3
  103. package/dist/{chunk-CUEUANIU.js → chunk-X4ES7QBT.js} +5 -5
  104. package/dist/{chunk-XXNT4FGA.js → chunk-XGP5VSQG.js} +1 -1
  105. package/dist/{chunk-LW7IWGSV.js → chunk-YQVKG5MC.js} +5 -5
  106. package/dist/{codex-app-cards-switch-SVGTZ2UN.js → codex-app-cards-switch-N77RWKCO.js} +21 -19
  107. package/dist/{codex-desktop-launch-SH7OUEEC.js → codex-desktop-launch-KIX7OMTL.js} +3 -1
  108. package/dist/{codex-session-launch-IQ57OL3N.js → codex-session-launch-XV7SIIWP.js} +18 -18
  109. package/dist/{config-SYLUYZQE.js → config-HH4DYYNX.js} +3 -3
  110. package/dist/global-upgrade-YWIVJIUR.js +34 -0
  111. package/dist/{identity-6KRUO2YO.js → identity-4J7Y2MW3.js} +4 -4
  112. package/dist/{live-capabilities-RKUHAWT6.js → live-capabilities-LHZBCI5U.js} +4 -4
  113. package/dist/{paths-MUPQZNLG.js → paths-ES3V7BWQ.js} +5 -3
  114. package/dist/{reapply-YZXZCWCI.js → reapply-KA5SIYWX.js} +26 -26
  115. package/dist/src/index.js +21 -21
  116. package/dist/{upgrade-lock-JXP27UKI.js → upgrade-lock-TJPKU5HL.js} +4 -6
  117. package/dist/{usage-OUV76AIY.js → usage-7ALXBJVJ.js} +3 -3
  118. package/package.json +1 -1
  119. package/dist/global-upgrade-SRCWQE7N.js +0 -26
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-6ICPEJY5.js";
7
7
  import {
8
8
  isRecord
9
- } from "./chunk-GZL3KEPC.js";
9
+ } from "./chunk-762CDAJJ.js";
10
10
 
11
11
  // src/setup/agent-probe.ts
12
12
  import { execSync } from "child_process";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  pusharyFetch
3
- } from "./chunk-HCIB4YNB.js";
3
+ } from "./chunk-JAKBCKEB.js";
4
4
  import {
5
5
  NetworkError
6
6
  } from "./chunk-7QLSKOSU.js";
@@ -9,11 +9,11 @@ import {
9
9
  } from "./chunk-KZERVKTD.js";
10
10
  import {
11
11
  getBaseUrl
12
- } from "./chunk-LVDC3RUE.js";
12
+ } from "./chunk-4XXZUFWN.js";
13
13
  import {
14
14
  isValidApiKey,
15
15
  normalizeKeyScope
16
- } from "./chunk-GZL3KEPC.js";
16
+ } from "./chunk-762CDAJJ.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
  readConfigFileKey
3
- } from "./chunk-IRZ5FVWG.js";
3
+ } from "./chunk-KAJDKYUM.js";
4
4
 
5
5
  // src/bell/fleet.ts
6
6
  import { closeSync, constants, futimesSync, lstatSync, mkdirSync, openSync, readdirSync, unlinkSync } from "fs";
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  pusharyDir
3
- } from "./chunk-TWLWDIFB.js";
3
+ } from "./chunk-KZCYHWDF.js";
4
4
  import {
5
5
  readJsonSafe
6
6
  } from "./chunk-QENTGE75.js";
7
7
  import {
8
8
  isRecord
9
- } from "./chunk-GZL3KEPC.js";
9
+ } from "./chunk-762CDAJJ.js";
10
10
 
11
11
  // src/process-ownership.ts
12
12
  import { createHash, randomUUID } from "crypto";
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  compatibleConfigFile,
3
3
  hasCompatibleHooks
4
- } from "./chunk-UPFFO4F6.js";
4
+ } from "./chunk-KQWN7C5C.js";
5
5
  import {
6
6
  pusharyHookExecutable
7
- } from "./chunk-CUEUANIU.js";
7
+ } from "./chunk-X4ES7QBT.js";
8
8
  import {
9
9
  isProtectedByScope,
10
10
  registerHookEntry
11
- } from "./chunk-TWLWDIFB.js";
11
+ } from "./chunk-KZCYHWDF.js";
12
12
  import {
13
13
  isRecord
14
- } from "./chunk-GZL3KEPC.js";
14
+ } from "./chunk-762CDAJJ.js";
15
15
 
16
16
  // src/cursor-config.ts
17
17
  var hookCommandOf = (entry) => {
@@ -4,10 +4,10 @@ import {
4
4
  } from "./chunk-QENTGE75.js";
5
5
  import {
6
6
  configFilePath
7
- } from "./chunk-LVDC3RUE.js";
7
+ } from "./chunk-4XXZUFWN.js";
8
8
  import {
9
9
  readSetupOutcomeProperties
10
- } from "./chunk-GZL3KEPC.js";
10
+ } from "./chunk-762CDAJJ.js";
11
11
 
12
12
  // src/hooks-spec.ts
13
13
  var CURSOR_GATE_SCRIPT = "pushary-gate.mjs";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  redactSecretsFromContent
3
- } from "./chunk-GZL3KEPC.js";
3
+ } from "./chunk-762CDAJJ.js";
4
4
 
5
5
  // src/crypto.ts
6
6
  import nacl from "tweetnacl";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  isSafeReadOnlyCommand
3
- } from "./chunk-GZL3KEPC.js";
3
+ } from "./chunk-762CDAJJ.js";
4
4
 
5
5
  // src/ledger.ts
6
6
  import { appendFileSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, statSync } from "fs";
@@ -9,7 +9,7 @@ import {
9
9
  } from "./chunk-3EGEA4KH.js";
10
10
  import {
11
11
  getBaseUrl
12
- } from "./chunk-LVDC3RUE.js";
12
+ } from "./chunk-4XXZUFWN.js";
13
13
 
14
14
  // src/cli/login-ui.ts
15
15
  import { hostname } from "os";
@@ -4,30 +4,30 @@ import {
4
4
  postLiveSession,
5
5
  postLiveSessionUntilAccepted,
6
6
  startLiveSessionHeartbeat
7
- } from "./chunk-IUOUNRLH.js";
7
+ } from "./chunk-V3PDUDPB.js";
8
8
  import {
9
9
  SESSION_IDLE_TIMEOUT_MS,
10
10
  describeIdleWindow,
11
11
  idleDeadlinePassed,
12
12
  startProcessOwnership
13
- } from "./chunk-CB565EVO.js";
13
+ } from "./chunk-MSU3VKGJ.js";
14
14
  import {
15
15
  spawnClaude
16
16
  } from "./chunk-XHKBHWLX.js";
17
17
  import {
18
18
  repoKeyFor
19
- } from "./chunk-XXNT4FGA.js";
19
+ } from "./chunk-XGP5VSQG.js";
20
20
  import {
21
21
  isAskUserResponse,
22
22
  isDecisionStopped,
23
23
  isWaitForAnswerResponse,
24
24
  withdrawQuestion,
25
25
  writeDegraded
26
- } from "./chunk-6QM54CSJ.js";
26
+ } from "./chunk-WW24SG27.js";
27
27
  import {
28
28
  callMcpTool,
29
29
  isRetryable
30
- } from "./chunk-A54W5A74.js";
30
+ } from "./chunk-5EFNBL6V.js";
31
31
  import {
32
32
  AGENT_QUESTION_DESCRIPTION_MAX,
33
33
  AGENT_QUESTION_HEADER_MAX,
@@ -48,7 +48,7 @@ import {
48
48
  parseCodexQuestions,
49
49
  planElicitationAsk,
50
50
  readElicitationFields
51
- } from "./chunk-GZL3KEPC.js";
51
+ } from "./chunk-762CDAJJ.js";
52
52
 
53
53
  // src/codex-question-owner.ts
54
54
  import { createHash } from "crypto";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  announceSubscriptionRequired,
3
3
  isDeferAnswer
4
- } from "./chunk-LVZYIUSR.js";
4
+ } from "./chunk-LAEW5QQD.js";
5
5
  import {
6
6
  AUTO_DECISION_WINDOW_MS,
7
7
  DEFAULT_SESSION,
@@ -10,18 +10,18 @@ import {
10
10
  permissionDeniedAction,
11
11
  releaseThrottle,
12
12
  reportEvent
13
- } from "./chunk-4YTFYILS.js";
13
+ } from "./chunk-5JWCWALO.js";
14
14
  import {
15
15
  askUser,
16
16
  isDecisionStopped,
17
17
  waitForQuestion
18
- } from "./chunk-6QM54CSJ.js";
18
+ } from "./chunk-WW24SG27.js";
19
19
  import {
20
20
  SubscriptionRequiredError
21
- } from "./chunk-A54W5A74.js";
21
+ } from "./chunk-5EFNBL6V.js";
22
22
  import {
23
23
  getMachineId
24
- } from "./chunk-SQ5G6A6K.js";
24
+ } from "./chunk-M46WDK64.js";
25
25
  import {
26
26
  ASK_CONTEXT_MAX,
27
27
  agentQuestionContext,
@@ -33,7 +33,7 @@ import {
33
33
  questionsShownAsASet,
34
34
  shouldDeferToNativeMode,
35
35
  wireVerdictFor
36
- } from "./chunk-GZL3KEPC.js";
36
+ } from "./chunk-762CDAJJ.js";
37
37
 
38
38
  // src/machine-decision-audit.ts
39
39
  import { basename } from "path";
@@ -1,4 +1,5 @@
1
1
  import {
2
+ LAUNCHCTL,
2
3
  codexAppOnThisMac,
3
4
  codexEngineBehindLauncher,
4
5
  codexPassThroughScript,
@@ -7,13 +8,13 @@ import {
7
8
  everyProgramFileIsThere,
8
9
  installedCodexApp,
9
10
  shellQuoted
10
- } from "./chunk-OZSP4RIQ.js";
11
+ } from "./chunk-CPRA7IEK.js";
11
12
  import {
12
13
  writeHuman
13
14
  } from "./chunk-QCGNGEGE.js";
14
15
  import {
15
16
  xml
16
- } from "./chunk-Z7Q36I4K.js";
17
+ } from "./chunk-4QF2YLYK.js";
17
18
  import {
18
19
  CODEX_APP_LAUNCH_AT_LOGIN_VERB,
19
20
  CODEX_APP_LAUNCH_VARIABLE
@@ -211,7 +212,6 @@ var waitForMacAppExit = (attempts = 20, everyMs = 250) => {
211
212
  // src/codex-app-cards-switch.ts
212
213
  var CODEX_APP_CARDS_LOGIN_ITEM = "com.pushary.codex-app-cards";
213
214
  var CODEX_APP_CARDS_DIRECTORY = "codex-app";
214
- var LAUNCHCTL = "/bin/launchctl";
215
215
  var LAUNCHER_NAME = "codex";
216
216
  var RECEIPT_NAME = "turned-on.json";
217
217
  var TURNED_OFF_NAME = "turned-off";
@@ -276,14 +276,14 @@ var codexAppCardsReceiptFrom = (contents) => {
276
276
  const { entry, app, engine } = parsed;
277
277
  return Array.isArray(entry) && entry.length > 0 && entry.every(isAString) && isAString(app) && isAString(engine) && isAbsolute2(engine) ? { entry, app, engine } : null;
278
278
  };
279
+ var filesThisVersionWrites = (paths, receipt) => ({
280
+ launcherScript: desktopProxyScript(receipt.entry, receipt.app, receipt.engine, { turnsItselfOffWithoutTheEngine: true }),
281
+ loginItem: codexAppCardsLoginItem(paths.launcherPath, receipt.engine, receipt.entry)
282
+ });
279
283
  var codexAppCardsInstallation = (input) => {
280
284
  const paths = codexAppCardsPaths(input.homeDir, input.uid);
281
- return {
282
- paths,
283
- launcherScript: desktopProxyScript(input.entry, input.app, input.engine, { turnsItselfOffWithoutTheEngine: true }),
284
- loginItem: codexAppCardsLoginItem(paths.launcherPath, input.engine, input.entry),
285
- receipt: { entry: input.entry, app: input.app, engine: input.engine }
286
- };
285
+ const receipt = { entry: input.entry, app: input.app, engine: input.engine };
286
+ return { paths, ...filesThisVersionWrites(paths, receipt), receipt };
287
287
  };
288
288
  var isAbsolutePath = (value) => value.startsWith("/");
289
289
  var whatTheLauncherCannotRun = (receipt, machine) => {
@@ -292,8 +292,10 @@ var whatTheLauncherCannotRun = (receipt, machine) => {
292
292
  const missing = receipt.entry.filter(isAbsolutePath).find((path) => !machine.exists(path));
293
293
  return missing === void 0 ? null : { kind: "on_but_pushary_is_missing", missing };
294
294
  };
295
+ var LAUNCH_SETTING_NOT_READ = "The setting that starts the Codex app could not be read, so nothing was changed";
296
+ var launchVariableOrNoneWhenNotRead = (machine) => machine.launchVariable() ?? "";
295
297
  var codexAppCardsStatus = (paths, machine) => {
296
- const value = machine.launchVariable();
298
+ const value = launchVariableOrNoneWhenNotRead(machine);
297
299
  if (value.length > 0 && value !== paths.launcherPath) return { kind: "another_program_owns_the_launch", value };
298
300
  const launcherIsThere = machine.exists(paths.launcherPath);
299
301
  const setForThisLogin = value === paths.launcherPath && launcherIsThere;
@@ -306,7 +308,7 @@ var codexAppCardsStatus = (paths, machine) => {
306
308
  };
307
309
  var turnCodexAppCardsOn = (installation, machine) => {
308
310
  const { paths } = installation;
309
- const value = machine.launchVariable();
311
+ const value = launchVariableOrNoneWhenNotRead(machine);
310
312
  if (value.length > 0 && value !== paths.launcherPath) return { kind: "another_program_owns_the_launch", value };
311
313
  machine.makeDirectory(paths.launcherDirectory, PRIVATE_DIRECTORY_MODE);
312
314
  machine.writeFile(paths.launcherPath, installation.launcherScript, PRIVATE_PROGRAM_MODE);
@@ -321,7 +323,7 @@ var turnCodexAppCardsOn = (installation, machine) => {
321
323
  var setCodexAppLaunchAtLogin = (paths, machine) => {
322
324
  const isTurnedOn = machine.exists(paths.launcherPath) && machine.exists(paths.loginItemPath);
323
325
  const cannotRun = whatTheLauncherCannotRun(codexAppCardsReceiptFrom(machine.readFile(paths.receiptPath)), machine);
324
- if (!isTurnedOn || cannotRun !== null || machine.launchVariable().length > 0) return "left_as_it_is";
326
+ if (!isTurnedOn || cannotRun !== null || launchVariableOrNoneWhenNotRead(machine).length > 0) return "left_as_it_is";
325
327
  machine.setLaunchVariable(paths.launcherPath);
326
328
  return "set";
327
329
  };
@@ -336,6 +338,7 @@ var leaveOnlyThePathToTheEngine = (paths, machine) => {
336
338
  };
337
339
  var turnCodexAppCardsOff = (paths, machine) => {
338
340
  const value = machine.launchVariable();
341
+ if (value === null) throw new Error(LAUNCH_SETTING_NOT_READ);
339
342
  const ours = value === paths.launcherPath;
340
343
  const loginItemIsThere = machine.exists(paths.loginItemPath);
341
344
  leaveOnlyThePathToTheEngine(paths, machine);
@@ -352,18 +355,28 @@ var rememberCodexAppCardsWereTurnedOff = (paths, machine) => {
352
355
  machine.writeFile(paths.turnedOffPath, "", PRIVATE_FILE_MODE);
353
356
  };
354
357
  var turnedOnByTheMacApp = (receipt) => receipt !== null && isTheMacAppsHelper(receipt.entry);
355
- var codexAppCardsReport = (paths, machine) => ({
356
- status: codexAppCardsStatus(paths, machine),
357
- codexApp: machine.codexApp(),
358
- turnedOnByTheMacApp: turnedOnByTheMacApp(codexAppCardsReceiptFrom(machine.readFile(paths.receiptPath))),
359
- turnedOffOnPurpose: machine.exists(paths.turnedOffPath)
360
- });
358
+ var isWhatThisVersionWrites = (receipt, paths, machine) => {
359
+ if (receipt === null) return false;
360
+ const written = filesThisVersionWrites(paths, receipt);
361
+ return machine.readFile(paths.launcherPath) === written.launcherScript && machine.readFile(paths.loginItemPath) === written.loginItem;
362
+ };
363
+ var launchesOrStartsAtLogin = (paths, machine) => machine.launchVariable() === paths.launcherPath || machine.exists(paths.loginItemPath);
364
+ var offButStillLaunchedOrStartedAtLogin = (status, paths, machine) => status.kind === "off" && launchesOrStartsAtLogin(paths, machine);
365
+ var codexAppCardsReport = (paths, machine) => {
366
+ const status = codexAppCardsStatus(paths, machine);
367
+ const receipt = codexAppCardsReceiptFrom(machine.readFile(paths.receiptPath));
368
+ return {
369
+ status,
370
+ codexApp: machine.codexApp(),
371
+ turnedOnByTheMacApp: turnedOnByTheMacApp(receipt),
372
+ turnedOffOnPurpose: machine.exists(paths.turnedOffPath),
373
+ launcher: paths.launcherPath,
374
+ launcherIsCurrent: isWhatThisVersionWrites(receipt, paths, machine),
375
+ leavesALaunchBehind: offButStillLaunchedOrStartedAtLogin(status, paths, machine)
376
+ };
377
+ };
361
378
  var isKeptOnForTheMacApp = (request, paths, machine) => request.keepWhatTheMacAppTurnedOn && turnedOnByTheMacApp(codexAppCardsReceiptFrom(machine.readFile(paths.receiptPath))) && codexAppCardsStatus(paths, machine).kind !== "off";
362
379
  var isKeptOffForTheMacApp = (request, paths, machine) => request.keepWhatTheMacAppTurnedOn && machine.exists(paths.turnedOffPath);
363
- var codexAppCardsFolderStays = (request, machine) => {
364
- const paths = codexAppCardsPaths(request.homeDir, request.uid);
365
- return isKeptOnForTheMacApp(request, paths, machine) || isKeptOffForTheMacApp(request, paths, machine);
366
- };
367
380
  var nothingIsTurnedOn = (paths, machine) => !machine.exists(paths.launcherPath) && !machine.exists(paths.loginItemPath) && machine.launchVariable() !== paths.launcherPath;
368
381
  var removeCodexAppCards = (request, machine) => {
369
382
  const paths = codexAppCardsPaths(request.homeDir, request.uid);
@@ -373,13 +386,40 @@ var removeCodexAppCards = (request, machine) => {
373
386
  return "absent";
374
387
  }
375
388
  if (isKeptOnForTheMacApp(request, paths, machine)) return "kept_for_the_mac_app";
389
+ if (machine.launchVariable() === null) throw new Error(LAUNCH_SETTING_NOT_READ);
376
390
  if (request.dryRun) return "removed";
377
391
  turnCodexAppCardsOff(paths, machine);
378
392
  machine.remove(paths.launcherDirectory);
379
393
  if (keepsTheOff) rememberCodexAppCardsWereTurnedOff(paths, machine);
380
394
  return "removed";
381
395
  };
382
- var launchctl = (args) => execFileSync2(LAUNCHCTL, [...args], { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] });
396
+ var firstLineOf = (error) => (error instanceof Error ? error.message : String(error)).split("\n", 1)[0] ?? "";
397
+ var whatTheCleanUpLeft = (paths, machine) => machine.launchVariable() === null || launchesOrStartsAtLogin(paths, machine) ? "could_not_turn_off" : "off_but_not_tidied";
398
+ var cleanUpCodexAppCards = (request, machine) => {
399
+ const paths = codexAppCardsPaths(request.homeDir, request.uid);
400
+ try {
401
+ const outcome = removeCodexAppCards(request, machine);
402
+ return { outcome, keepsTheFolder: outcome === "kept_for_the_mac_app" || isKeptOffForTheMacApp(request, paths, machine) };
403
+ } catch (error) {
404
+ return { outcome: whatTheCleanUpLeft(paths, machine), keepsTheFolder: true, reason: firstLineOf(error) };
405
+ }
406
+ };
407
+ var codexAppCardsFolderInTheLastSweep = (cleanedUpOnThisMac) => {
408
+ if (cleanedUpOnThisMac === null) return "swept_with_the_rest";
409
+ return cleanedUpOnThisMac.keepsTheFolder ? "kept" : "left_to_the_switch";
410
+ };
411
+ var hasWhatTheCommandSaid = (error) => typeof error === "object" && error !== null && "stderr" in error;
412
+ var whyLaunchctlFailed = (error, verb) => {
413
+ const said = hasWhatTheCommandSaid(error) && typeof error.stderr === "string" ? error.stderr.split("\n").map((line) => line.trim()).find((line) => line.length > 0) : void 0;
414
+ return said ?? `launchctl ${verb} failed`;
415
+ };
416
+ var launchctl = (args) => {
417
+ try {
418
+ return execFileSync2(LAUNCHCTL, [...args], { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] });
419
+ } catch (error) {
420
+ throw new Error(whyLaunchctlFailed(error, args[0] ?? ""));
421
+ }
422
+ };
383
423
  var launchctlIgnoringFailure = (args) => {
384
424
  try {
385
425
  return launchctl(args);
@@ -387,6 +427,13 @@ var launchctlIgnoringFailure = (args) => {
387
427
  return "";
388
428
  }
389
429
  };
430
+ var launchVariableOnThisMac = () => {
431
+ try {
432
+ return launchctl(["getenv", CODEX_APP_LAUNCH_VARIABLE]).trim();
433
+ } catch {
434
+ return null;
435
+ }
436
+ };
390
437
  var fileContents = (path) => {
391
438
  try {
392
439
  return readFileSync(path, "utf8");
@@ -396,7 +443,7 @@ var fileContents = (path) => {
396
443
  };
397
444
  var thisMacsCodexAppCardsMachine = () => ({
398
445
  codexApp: codexAppOnThisMac,
399
- launchVariable: () => launchctlIgnoringFailure(["getenv", CODEX_APP_LAUNCH_VARIABLE]).trim(),
446
+ launchVariable: launchVariableOnThisMac,
400
447
  setLaunchVariable: (value) => {
401
448
  launchctl(["setenv", CODEX_APP_LAUNCH_VARIABLE, value]);
402
449
  },
@@ -418,8 +465,7 @@ var thisMacsCodexAppCardsMachine = () => ({
418
465
  rmSync(path, { recursive: true, force: true });
419
466
  }
420
467
  });
421
- var removeCodexAppCardsFromThisMac = (request) => removeCodexAppCards(request, thisMacsCodexAppCardsMachine());
422
- var codexAppCardsFolderStaysOnThisMac = (request) => codexAppCardsFolderStays(request, thisMacsCodexAppCardsMachine());
468
+ var cleanUpCodexAppCardsOnThisMac = (request) => cleanUpCodexAppCards(request, thisMacsCodexAppCardsMachine());
423
469
  var setCodexAppLaunchAtLoginOnThisMac = () => {
424
470
  const uid = process.getuid?.();
425
471
  if (uid === void 0) return;
@@ -479,7 +525,7 @@ var codexAppCardsCommand = async (args, entry, readAccount, machine, say) => {
479
525
  return 1;
480
526
  }
481
527
  say(`Codex app cards are on. ${TAKES_EFFECT_AFTER_REOPENING}`);
482
- say("From then on, when Codex asks to use an app on this Mac, the question also reaches Pushary. Everything else in Codex stays as it is.");
528
+ say("From then on, when Codex asks to use an app on this Mac, or its browser asks to open a site, download or upload, the question also reaches Pushary. Everything else in Codex stays as it is.");
483
529
  say("Turn them off by running the same command with off.");
484
530
  if (runsFromATemporaryFolder(entry)) say("This copy of Pushary runs from a temporary npx folder. If that folder is cleared, the cards stop reaching Pushary and Codex keeps working. Install Pushary with npm install -g pushary and turn them on again to make it last.");
485
531
  return 0;
@@ -516,10 +562,11 @@ export {
516
562
  turnCodexAppCardsOff,
517
563
  rememberCodexAppCardsWereTurnedOff,
518
564
  codexAppCardsReport,
519
- codexAppCardsFolderStays,
520
565
  removeCodexAppCards,
521
- removeCodexAppCardsFromThisMac,
522
- codexAppCardsFolderStaysOnThisMac,
566
+ cleanUpCodexAppCards,
567
+ codexAppCardsFolderInTheLastSweep,
568
+ whyLaunchctlFailed,
569
+ cleanUpCodexAppCardsOnThisMac,
523
570
  setCodexAppLaunchAtLoginOnThisMac,
524
571
  runsFromATemporaryFolder,
525
572
  codexAppCardsStatusLine,
@@ -5,16 +5,16 @@ import {
5
5
  import {
6
6
  NOTIFICATION_MATCHED_TYPES,
7
7
  POSTTOOLUSE_MIRRORED_TOOLS
8
- } from "./chunk-QTCFEKLJ.js";
8
+ } from "./chunk-W47WL6JY.js";
9
9
  import {
10
10
  isProtectedByScope,
11
11
  registerHookEntry
12
- } from "./chunk-TWLWDIFB.js";
12
+ } from "./chunk-KZCYHWDF.js";
13
13
  import {
14
14
  CLAUDE_PRETOOLUSE_MATCHER,
15
15
  HOOK_BUDGETS,
16
16
  HOOK_LOCATOR_BINARY
17
- } from "./chunk-GZL3KEPC.js";
17
+ } from "./chunk-762CDAJJ.js";
18
18
 
19
19
  // src/gemini-config.ts
20
20
  var GEMINI_HOOK_BINARY = "pushary-gemini-hook";