pushary 1.9.97 → 1.9.99

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 (127) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/{api-WH3DLHJB.js → api-UGCOLWF4.js} +10 -10
  3. package/dist/bin/pushary-bell-hook.js +27 -26
  4. package/dist/bin/pushary-bell.js +10 -10
  5. package/dist/bin/pushary-claude.js +48 -33
  6. package/dist/bin/pushary-clean.js +34 -34
  7. package/dist/bin/pushary-codex-bridge.js +21 -21
  8. package/dist/bin/pushary-codex-hook.js +32 -31
  9. package/dist/bin/pushary-codex-session.js +8 -8
  10. package/dist/bin/pushary-codex.js +14 -14
  11. package/dist/bin/pushary-connect.js +27 -27
  12. package/dist/bin/pushary-cowork.js +5 -5
  13. package/dist/bin/pushary-daemon.js +40 -39
  14. package/dist/bin/pushary-disconnect.js +26 -26
  15. package/dist/bin/pushary-display-hook.js +18 -17
  16. package/dist/bin/pushary-doctor.js +42 -42
  17. package/dist/bin/pushary-elicitation-hook.js +27 -26
  18. package/dist/bin/pushary-gemini-bridge.js +15 -15
  19. package/dist/bin/pushary-gemini-hook.js +29 -28
  20. package/dist/bin/pushary-hook.js +31 -30
  21. package/dist/bin/pushary-login.js +38 -20
  22. package/dist/bin/pushary-logout.js +25 -25
  23. package/dist/bin/pushary-mcp.js +11 -11
  24. package/dist/bin/pushary-mode.js +15 -15
  25. package/dist/bin/pushary-notification-hook.js +26 -25
  26. package/dist/bin/pushary-opencode-hook.js +28 -27
  27. package/dist/bin/pushary-permission-denied-hook.js +31 -30
  28. package/dist/bin/pushary-permission-hook.js +31 -30
  29. package/dist/bin/pushary-post-hook.js +26 -25
  30. package/dist/bin/pushary-prompt-hook.js +26 -25
  31. package/dist/bin/pushary-session-end-hook.js +28 -27
  32. package/dist/bin/pushary-session-start-hook.js +36 -35
  33. package/dist/bin/pushary-setup.js +103 -109
  34. package/dist/bin/pushary-stats.js +5 -5
  35. package/dist/bin/pushary-status.js +32 -32
  36. package/dist/bin/pushary-stop-hook.js +26 -25
  37. package/dist/bin/pushary-stopfailure-hook.js +26 -25
  38. package/dist/bin/pushary-suggestions.js +15 -15
  39. package/dist/bin/pushary-transcript-register.js +19 -18
  40. package/dist/bin/pushary-transcripts.js +27 -26
  41. package/dist/bin/pushary-upgrade.js +40 -40
  42. package/dist/bin/pushary-wait.js +15 -15
  43. package/dist/bin/pushary.js +7 -7
  44. package/dist/{chunk-UAUADSJX.js → chunk-2CO34UJK.js} +2 -2
  45. package/dist/{chunk-R7D3PH2M.js → chunk-2DKM45TQ.js} +6 -6
  46. package/dist/{chunk-IFQKSIID.js → chunk-35Q2Z7HD.js} +3 -3
  47. package/dist/{chunk-32577NGL.js → chunk-3NS3YK5S.js} +1 -1
  48. package/dist/{chunk-CMDIKFVL.js → chunk-3QTUISNT.js} +1 -1
  49. package/dist/{chunk-Z6O6CDTP.js → chunk-3VWS2EAB.js} +5 -5
  50. package/dist/{chunk-JA6GCOW2.js → chunk-4CD75FOI.js} +7 -7
  51. package/dist/{chunk-5OLBO5EB.js → chunk-4OG7AYQN.js} +1 -1
  52. package/dist/{chunk-KYX7VBEE.js → chunk-54476CMC.js} +2 -2
  53. package/dist/chunk-56MGFZDM.js +45 -0
  54. package/dist/{chunk-RILJLDKG.js → chunk-5UKWIMMW.js} +5 -5
  55. package/dist/{chunk-TSSV3NBD.js → chunk-73WH2KOH.js} +2 -2
  56. package/dist/{chunk-2ZAFA3XI.js → chunk-7C5M5NY3.js} +3 -3
  57. package/dist/{chunk-6CDA4R5L.js → chunk-7DJWJWRS.js} +3 -3
  58. package/dist/{chunk-5U63KUP3.js → chunk-AP2VXDQB.js} +1 -1
  59. package/dist/{chunk-RSITUL2U.js → chunk-AWO5VRPH.js} +2 -2
  60. package/dist/{chunk-APFQBVQW.js → chunk-BFA36PR4.js} +6 -6
  61. package/dist/{chunk-W5IW7NZE.js → chunk-BSG7IIMK.js} +104 -2
  62. package/dist/{chunk-HD7AURL6.js → chunk-BYGU5IV4.js} +52 -7
  63. package/dist/{chunk-CP72YEEA.js → chunk-E7WAVZNC.js} +1 -1
  64. package/dist/{chunk-WOFHN2IZ.js → chunk-EBGUGOS3.js} +200 -12
  65. package/dist/{chunk-MGYGWHG5.js → chunk-EIREGHP2.js} +1 -1
  66. package/dist/{chunk-OBB6VTSG.js → chunk-EJ7DI2HX.js} +5 -5
  67. package/dist/{chunk-ZFUSWR2P.js → chunk-EXDEE4KB.js} +2 -2
  68. package/dist/{chunk-EAJT6RYP.js → chunk-EXUGDNCF.js} +7 -7
  69. package/dist/{chunk-RRA6POT5.js → chunk-FRAXLEC2.js} +1 -1
  70. package/dist/{chunk-5WYXFKZV.js → chunk-FSQXIJYX.js} +1 -1
  71. package/dist/{chunk-T35RHO3X.js → chunk-G24MYZIR.js} +5 -5
  72. package/dist/{chunk-VPT3RDTO.js → chunk-G66WIAST.js} +0 -43
  73. package/dist/{chunk-LKDAMWTZ.js → chunk-GJ7CPXXB.js} +4 -4
  74. package/dist/{chunk-GNFUPHPZ.js → chunk-GKRGH3SF.js} +10 -10
  75. package/dist/{chunk-TZE2S3XP.js → chunk-GNW6AHGY.js} +3 -3
  76. package/dist/{chunk-ORVMA5KJ.js → chunk-GOHFQONY.js} +3 -3
  77. package/dist/{chunk-R7TVELKF.js → chunk-HF24RY6N.js} +1 -1
  78. package/dist/{chunk-KZTN6OXM.js → chunk-HVQSHNVK.js} +6 -6
  79. package/dist/{chunk-QCEY7TSX.js → chunk-IBHSZUXM.js} +3 -3
  80. package/dist/{chunk-OW4WEO56.js → chunk-IOMU3A6E.js} +3 -3
  81. package/dist/{chunk-HXUE6IIP.js → chunk-JATIKUQ5.js} +5 -5
  82. package/dist/{chunk-W3OTAHLV.js → chunk-JE6UEOMG.js} +4 -4
  83. package/dist/{chunk-VVHNHETX.js → chunk-KLLX5ZTC.js} +2 -2
  84. package/dist/{chunk-KNVTKFDP.js → chunk-KRQKPVHG.js} +2 -2
  85. package/dist/{chunk-RZD7ULBJ.js → chunk-L6Q5FZ54.js} +1 -1
  86. package/dist/{chunk-QP3OSLKU.js → chunk-LM2YX5SO.js} +5 -5
  87. package/dist/{chunk-NTCVGJFC.js → chunk-LN53RAXQ.js} +4 -4
  88. package/dist/{chunk-5RNZP53C.js → chunk-MCZF73KL.js} +6 -6
  89. package/dist/{chunk-HWEEBVS7.js → chunk-MLFZ4F2L.js} +4 -4
  90. package/dist/{chunk-CG3C2WL7.js → chunk-N4SM5GMN.js} +14 -12
  91. package/dist/{chunk-VHOGSWUF.js → chunk-NDOQN5VC.js} +3 -3
  92. package/dist/{chunk-IED5CTYP.js → chunk-NTAVA4LB.js} +3 -3
  93. package/dist/{chunk-TKOL7DJH.js → chunk-OBIXCQPF.js} +2 -2
  94. package/dist/{chunk-VVP4CP4O.js → chunk-OLA7MWVD.js} +11 -10
  95. package/dist/{chunk-CB2RYMAO.js → chunk-P7SBX7QQ.js} +1 -1
  96. package/dist/{chunk-X22LLKBY.js → chunk-PDC4UQUC.js} +3 -3
  97. package/dist/{chunk-NI3NSURQ.js → chunk-PED2VA34.js} +1 -1
  98. package/dist/{chunk-FZQSUS3R.js → chunk-PT43DN4J.js} +14 -14
  99. package/dist/{chunk-GN2L5CYF.js → chunk-PVERXZOS.js} +1 -1
  100. package/dist/{chunk-E5WUBHVH.js → chunk-QTFN3ND3.js} +4 -4
  101. package/dist/{chunk-4D4USO5K.js → chunk-RB4E2YHR.js} +6 -6
  102. package/dist/{chunk-5YRDZE5F.js → chunk-SYMYZNSB.js} +1 -1
  103. package/dist/{chunk-SXX47FHL.js → chunk-T3HCMKX4.js} +2 -2
  104. package/dist/{chunk-RPY5XCGA.js → chunk-T7YK7FNA.js} +2 -2
  105. package/dist/{chunk-GEA6ZV2P.js → chunk-TBE76OH7.js} +2 -2
  106. package/dist/{chunk-ZDIQPYM2.js → chunk-TMRJOWWU.js} +1 -1
  107. package/dist/{chunk-JR6FCHAQ.js → chunk-U4MEORPA.js} +3 -3
  108. package/dist/{chunk-MYKZPTAL.js → chunk-UKX7IMD2.js} +1 -1
  109. package/dist/{chunk-6RGQIKAC.js → chunk-UMRO47H3.js} +3 -3
  110. package/dist/{chunk-AUZITE2H.js → chunk-VSKHU5XR.js} +6 -6
  111. package/dist/{chunk-MFJFN4DA.js → chunk-VWGZZSJG.js} +3 -3
  112. package/dist/{chunk-NDJ7H2WF.js → chunk-YIPSSNTL.js} +1 -1
  113. package/dist/{chunk-5WOO44TA.js → chunk-YLBUBQEL.js} +5 -5
  114. package/dist/{chunk-VAY5AJ6N.js → chunk-ZP7R762D.js} +4 -4
  115. package/dist/{codex-app-cards-switch-DFZK6GPW.js → codex-app-cards-switch-XMHI5UNS.js} +11 -11
  116. package/dist/{codex-desktop-launch-7QGN7SL7.js → codex-desktop-launch-QSD3X65K.js} +1 -1
  117. package/dist/{codex-session-launch-OWMNCYAH.js → codex-session-launch-TKDH5MHT.js} +18 -18
  118. package/dist/{config-ITPE5M6M.js → config-R3P7U2TH.js} +3 -3
  119. package/dist/{global-upgrade-PYEFLMJA.js → global-upgrade-SYF6JI7C.js} +10 -10
  120. package/dist/{identity-WTYTOLG3.js → identity-VH233LC3.js} +4 -4
  121. package/dist/{live-capabilities-HZ42KLZS.js → live-capabilities-THIEYKPD.js} +5 -5
  122. package/dist/{paths-6JUJIM74.js → paths-UA5EZQAH.js} +3 -3
  123. package/dist/{reapply-5WV6IS5V.js → reapply-QDTONXI3.js} +28 -28
  124. package/dist/src/index.js +30 -29
  125. package/dist/{upgrade-lock-ENAQL63D.js → upgrade-lock-GHMTQ3JP.js} +4 -4
  126. package/dist/{usage-BO7LGOA3.js → usage-E3M5YPYW.js} +3 -3
  127. package/package.json +1 -1
@@ -1,30 +1,30 @@
1
1
  import {
2
2
  announceSubscriptionRequired,
3
3
  isDeferAnswer
4
- } from "./chunk-GN2L5CYF.js";
4
+ } from "./chunk-PVERXZOS.js";
5
5
  import {
6
6
  AUTO_DECISION_WINDOW_MS,
7
7
  DEFAULT_SESSION,
8
8
  claimThrottle,
9
9
  releaseThrottle,
10
10
  reportEvent
11
- } from "./chunk-VVP4CP4O.js";
11
+ } from "./chunk-OLA7MWVD.js";
12
12
  import {
13
13
  deriveToolTarget,
14
14
  permissionDeniedAction
15
- } from "./chunk-ZDIQPYM2.js";
15
+ } from "./chunk-TMRJOWWU.js";
16
16
  import {
17
17
  askUser,
18
18
  isDecisionStopped,
19
19
  isQuestionLimitRefusal,
20
20
  waitForQuestion
21
- } from "./chunk-Z6O6CDTP.js";
21
+ } from "./chunk-3VWS2EAB.js";
22
22
  import {
23
23
  SubscriptionRequiredError
24
- } from "./chunk-E5WUBHVH.js";
24
+ } from "./chunk-QTFN3ND3.js";
25
25
  import {
26
26
  getMachineId
27
- } from "./chunk-ZFUSWR2P.js";
27
+ } from "./chunk-EXDEE4KB.js";
28
28
  import {
29
29
  ASK_CONTEXT_MAX,
30
30
  agentQuestionContext,
@@ -36,7 +36,7 @@ import {
36
36
  questionsShownAsASet,
37
37
  shouldDeferToNativeMode,
38
38
  wireVerdictFor
39
- } from "./chunk-WOFHN2IZ.js";
39
+ } from "./chunk-EBGUGOS3.js";
40
40
 
41
41
  // src/machine-decision-audit.ts
42
42
  import { basename } from "path";
@@ -7,7 +7,7 @@ import {
7
7
  recordSealerFor,
8
8
  uploadTranscriptRecords,
9
9
  wrapSessionKey
10
- } from "./chunk-UAUADSJX.js";
10
+ } from "./chunk-2CO34UJK.js";
11
11
 
12
12
  // src/live-session.ts
13
13
  var MAX_TRANSCRIPT_QUEUE = 100;
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  findNativeClaudeInstall
3
- } from "./chunk-NI3NSURQ.js";
3
+ } from "./chunk-PED2VA34.js";
4
4
  import {
5
5
  isFile
6
- } from "./chunk-6CDA4R5L.js";
6
+ } from "./chunk-7DJWJWRS.js";
7
7
 
8
8
  // src/wrapper/claudeBinary.ts
9
9
  import { homedir } from "os";
@@ -0,0 +1,45 @@
1
+ import {
2
+ external_exports
3
+ } from "./chunk-XMSDA5WA.js";
4
+ import {
5
+ writeJsonAtomic
6
+ } from "./chunk-7DJWJWRS.js";
7
+
8
+ // src/transcript-read-positions.ts
9
+ import { lstatSync, readFileSync } from "fs";
10
+ var OWNER_ONLY_FILE_MODE = 384;
11
+ var MAXIMUM_READ_POSITIONS_BYTES = 4 * 1024 * 1024;
12
+ var transcriptReadPositionSchema = external_exports.object({
13
+ identity: external_exports.string().nullable(),
14
+ offset: external_exports.number().int().nonnegative(),
15
+ startedBeforeEpoch: external_exports.boolean()
16
+ });
17
+ var savedReadPositionsSchema = external_exports.object({ positions: external_exports.record(external_exports.string(), transcriptReadPositionSchema) });
18
+ var ownedOnlyByThisUser = (info) => !process.getuid || info.uid === process.getuid() && (info.mode & 511) === OWNER_ONLY_FILE_MODE;
19
+ var readOwnerOnlyJson = (path, maximumBytes) => {
20
+ const info = lstatSync(path);
21
+ if (!info.isFile() || info.nlink !== 1 || !ownedOnlyByThisUser(info) || info.size > maximumBytes) return null;
22
+ return JSON.parse(readFileSync(path, "utf8"));
23
+ };
24
+ var savedTranscriptReadPositions = (file) => ({
25
+ load: () => {
26
+ try {
27
+ return new Map(Object.entries(savedReadPositionsSchema.parse(readOwnerOnlyJson(file, MAXIMUM_READ_POSITIONS_BYTES)).positions));
28
+ } catch {
29
+ return /* @__PURE__ */ new Map();
30
+ }
31
+ },
32
+ save: (positions) => {
33
+ try {
34
+ writeJsonAtomic(file, { positions: Object.fromEntries(positions) }, OWNER_ONLY_FILE_MODE);
35
+ } catch {
36
+ return;
37
+ }
38
+ }
39
+ });
40
+
41
+ export {
42
+ transcriptReadPositionSchema,
43
+ readOwnerOnlyJson,
44
+ savedTranscriptReadPositions
45
+ };
@@ -3,24 +3,24 @@ import {
3
3
  expectedLaunchCapabilities,
4
4
  hasSpawnProvider,
5
5
  resolveControlPolicy
6
- } from "./chunk-LKDAMWTZ.js";
6
+ } from "./chunk-GJ7CPXXB.js";
7
7
  import {
8
8
  daemonHasRemoteProof,
9
9
  daemonServiceManagerAvailable,
10
10
  hasDaemonServiceDefinition,
11
11
  readDaemonNeedsLogin,
12
12
  readDaemonStatus
13
- } from "./chunk-APFQBVQW.js";
13
+ } from "./chunk-BFA36PR4.js";
14
14
  import {
15
15
  readControlMode,
16
16
  readKeySource
17
- } from "./chunk-HD7AURL6.js";
17
+ } from "./chunk-BYGU5IV4.js";
18
18
  import {
19
19
  getMachineId
20
- } from "./chunk-ZFUSWR2P.js";
20
+ } from "./chunk-EXDEE4KB.js";
21
21
  import {
22
22
  getBaseUrl
23
- } from "./chunk-RZD7ULBJ.js";
23
+ } from "./chunk-L6Q5FZ54.js";
24
24
  import {
25
25
  getPackageVersion
26
26
  } from "./chunk-ZVU6WMMU.js";
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  autoUpdateLock
3
- } from "./chunk-KNVTKFDP.js";
3
+ } from "./chunk-KRQKPVHG.js";
4
4
  import {
5
5
  installPackageGlobally,
6
6
  npmErrorMessage,
7
7
  writeJsonAtomic
8
- } from "./chunk-6CDA4R5L.js";
8
+ } from "./chunk-7DJWJWRS.js";
9
9
 
10
10
  // src/upgrade-lock.ts
11
11
  import { fork } from "child_process";
@@ -9,20 +9,20 @@ import {
9
9
  installedCodexApp,
10
10
  readCodexAppRuntime,
11
11
  shellQuoted
12
- } from "./chunk-TKOL7DJH.js";
12
+ } from "./chunk-OBIXCQPF.js";
13
13
  import {
14
14
  writeHuman
15
15
  } from "./chunk-QCGNGEGE.js";
16
16
  import {
17
17
  xml
18
- } from "./chunk-APFQBVQW.js";
18
+ } from "./chunk-BFA36PR4.js";
19
19
  import {
20
20
  CODEX_APP_LAUNCH_AT_LOGIN_VERB,
21
21
  CODEX_APP_LAUNCH_VARIABLE
22
22
  } from "./chunk-E46NE7FB.js";
23
23
  import {
24
24
  writeFileAtomic
25
- } from "./chunk-6CDA4R5L.js";
25
+ } from "./chunk-7DJWJWRS.js";
26
26
 
27
27
  // src/codex-app-cards-switch.ts
28
28
  import { execFileSync as execFileSync2 } from "child_process";
@@ -471,9 +471,9 @@ var installGlobally = (options) => {
471
471
  }
472
472
  const started = (async () => {
473
473
  if (!npmIsOnPath()) throw new NpmMissingError();
474
- const { withUpgradeLock } = await import("./global-upgrade-PYEFLMJA.js");
475
- const { installWithUpgradeLock, ownsUpgradeLock } = await import("./upgrade-lock-ENAQL63D.js");
476
- const { autoUpdateLock } = await import("./paths-6JUJIM74.js");
474
+ const { withUpgradeLock } = await import("./global-upgrade-SYF6JI7C.js");
475
+ const { installWithUpgradeLock, ownsUpgradeLock } = await import("./upgrade-lock-GHMTQ3JP.js");
476
+ const { autoUpdateLock } = await import("./paths-UA5EZQAH.js");
477
477
  let result = "skipped";
478
478
  const install = async () => {
479
479
  const platform = process.platform;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  guardBinary
3
- } from "./chunk-KNVTKFDP.js";
3
+ } from "./chunk-KRQKPVHG.js";
4
4
 
5
5
  // src/bell/install.ts
6
6
  import { join } from "path";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  parseSseMessages
3
- } from "./chunk-E5WUBHVH.js";
3
+ } from "./chunk-QTFN3ND3.js";
4
4
  import {
5
5
  NPX_LATEST_COMMAND
6
- } from "./chunk-CMDIKFVL.js";
6
+ } from "./chunk-3QTUISNT.js";
7
7
 
8
8
  // src/mcp-stdio-bridge.ts
9
9
  var MCP_BRIDGE_BINARY = "pushary-mcp";
@@ -4,23 +4,23 @@ import {
4
4
  } from "./chunk-XHKBHWLX.js";
5
5
  import {
6
6
  readControlMode
7
- } from "./chunk-HD7AURL6.js";
7
+ } from "./chunk-BYGU5IV4.js";
8
8
  import {
9
9
  getMachineId
10
- } from "./chunk-ZFUSWR2P.js";
10
+ } from "./chunk-EXDEE4KB.js";
11
11
  import {
12
12
  pusharyDir
13
- } from "./chunk-KNVTKFDP.js";
13
+ } from "./chunk-KRQKPVHG.js";
14
14
  import {
15
15
  readJsonSafe,
16
16
  resolveGlobalBinary,
17
17
  writeFileAtomic,
18
18
  writeJsonAtomic,
19
19
  writeJsonAtomicDurable
20
- } from "./chunk-6CDA4R5L.js";
20
+ } from "./chunk-7DJWJWRS.js";
21
21
  import {
22
22
  getApiKey
23
- } from "./chunk-RZD7ULBJ.js";
23
+ } from "./chunk-L6Q5FZ54.js";
24
24
  import {
25
25
  CLI_PACKAGE_NAMES,
26
26
  cmdShimScriptOf,
@@ -30,7 +30,7 @@ import {
30
30
  } from "./chunk-ZVU6WMMU.js";
31
31
  import {
32
32
  isRecord
33
- } from "./chunk-WOFHN2IZ.js";
33
+ } from "./chunk-EBGUGOS3.js";
34
34
 
35
35
  // src/daemon-lifecycle.ts
36
36
  import { dirname, join, win32 as win32Path } from "path";
@@ -7,9 +7,22 @@ import {
7
7
  openSealedKey,
8
8
  publicKeyFingerprint
9
9
  } from "./chunk-3EGEA4KH.js";
10
+ import {
11
+ PLAN_CONFIGS,
12
+ PLAN_TYPES
13
+ } from "./chunk-G66WIAST.js";
14
+ import {
15
+ keyPrefix
16
+ } from "./chunk-BYGU5IV4.js";
10
17
  import {
11
18
  getBaseUrl
12
- } from "./chunk-RZD7ULBJ.js";
19
+ } from "./chunk-L6Q5FZ54.js";
20
+ import {
21
+ NPX_LATEST_COMMAND
22
+ } from "./chunk-3QTUISNT.js";
23
+ import {
24
+ isValidApiKey
25
+ } from "./chunk-EBGUGOS3.js";
13
26
 
14
27
  // src/cli/login-ui.ts
15
28
  import { hostname } from "os";
@@ -222,6 +235,95 @@ var runBrowserLogin = async (ui, options, deps = {}) => {
222
235
  }
223
236
  };
224
237
 
238
+ // src/setup/key-account.ts
239
+ var isKeyHeldByMacApp = (key, holder) => holder.macAppInstalled && holder.macAppKey === key;
240
+ var agentConfigKeySource = (agentConfigKey, holder) => isKeyHeldByMacApp(agentConfigKey, holder) ? "mac-app" : "agent-settings";
241
+ var replacedShellKeyChoice = (facts) => {
242
+ if (!facts.shellKeyWasReplaced || !facts.shellKeyUsable || !facts.savedKeyFound) return "shell_key_not_replaced";
243
+ if (!facts.recordHonoured) return "keep_saved_key";
244
+ return facts.canAsk ? "ask_to_keep_saved_key" : "keep_saved_key_and_say_how_to_switch";
245
+ };
246
+ var keepsTheSavedKeyOverTheReplacedShellKey = (choice, reused, reuseAccepted) => choice !== "shell_key_not_replaced" && reuseAccepted && reused?.source === "stored";
247
+ var pickReusableKey = (candidates) => {
248
+ if (candidates.storedKey !== null && candidates.storedCheck !== null) {
249
+ return { source: "stored", key: candidates.storedKey, check: candidates.storedCheck };
250
+ }
251
+ if (candidates.envKey && candidates.envCheck !== null) {
252
+ return { source: "environment", key: candidates.envKey, check: candidates.envCheck };
253
+ }
254
+ if (candidates.agentConfigKey !== null && candidates.agentConfigCheck !== null) {
255
+ return { source: agentConfigKeySource(candidates.agentConfigKey, candidates), key: candidates.agentConfigKey, check: candidates.agentConfigCheck };
256
+ }
257
+ return null;
258
+ };
259
+ var REUSED_KEY_SOURCE_LABELS = {
260
+ stored: "the key saved on this machine",
261
+ environment: "the key in PUSHARY_API_KEY",
262
+ "mac-app": "the key Pushary for Mac is signed in with",
263
+ "agent-settings": "a key found in your agent settings"
264
+ };
265
+ var maskKey = (key) => `${key.slice(0, 8)}...${key.slice(-4)}`;
266
+ var describeFoundKey = (reusable) => `Found ${REUSED_KEY_SOURCE_LABELS[reusable.source]}: ${maskKey(reusable.key)}`;
267
+ var describeUsedKey = (reusable) => `Using ${REUSED_KEY_SOURCE_LABELS[reusable.source]}: ${maskKey(reusable.key)}`;
268
+ var canAskAtTheTerminal = (context) => context.stdoutIsTty && !context.nonInteractive && !context.dryRun;
269
+ var keyReuseConfirmation = (context) => canAskAtTheTerminal(context) && context.canPairWithApp ? "ask" : "announce";
270
+ var accountHandleOf = (identity) => identity.siteSlug ? `@${identity.siteSlug}` : identity.siteName || null;
271
+ var keyAccountHandle = (check) => check.kind === "ok" ? accountHandleOf(check.identity) : null;
272
+ var continueAsQuestion = (account) => account ? `Continue as ${account}?` : "Continue with this key?";
273
+ var keepSavedKeyQuestion = (savedAccount, shellAccount) => `${savedAccount ? `Continue as ${savedAccount}?` : "Continue with the saved key?"} This terminal still exports the key for ${shellAccount ?? "the workspace this computer left"}.`;
274
+ var switchBackToTheShellKeyLine = (shellAccount) => `Kept the saved key. To move this computer to ${shellAccount ?? "the key this terminal exports"} on purpose, run ${NPX_LATEST_COMMAND} login --force and choose it.`;
275
+ var WRONG_ACCOUNT_HINT = `Wrong account? Run ${NPX_LATEST_COMMAND} setup --connect app`;
276
+ var wrongAccountHintPlacement = (context) => {
277
+ if (!context.canPairWithApp) return "none";
278
+ if (context.planInactive && !context.dryRun) return "with-inactive-plan";
279
+ return context.reusedWithoutAsking ? "after-key-check" : "none";
280
+ };
281
+ var planNameOf = (plan) => {
282
+ const known = PLAN_TYPES.find((type) => type === plan);
283
+ return known ? PLAN_CONFIGS[known].name : null;
284
+ };
285
+ var withPlanName = (account, plan) => {
286
+ const planName = planNameOf(plan);
287
+ return planName ? `${account} (${planName} plan)` : account;
288
+ };
289
+ var describeSignedIn = (identity) => `Signed in to ${withPlanName(accountHandleOf(identity) ?? "your account", identity.plan)}`;
290
+ var describeKeyAccount = (check) => {
291
+ if (check.kind !== "ok") return null;
292
+ const account = accountHandleOf(check.identity);
293
+ return account ? withPlanName(account, check.identity.plan) : null;
294
+ };
295
+ var shownKeyPrefix = (key) => isValidApiKey(key) ? ` (${keyPrefix(key)})` : "";
296
+ var shellKeyLine = (shadow) => {
297
+ const held = `This terminal still has the old key in PUSHARY_API_KEY${shownKeyPrefix(shadow.shellKey)}`;
298
+ return shadow.shellAccount ? `${held}, for ${shadow.shellAccount}.` : `${held}.`;
299
+ };
300
+ var savedKeyLine = (shadow) => {
301
+ if (shadow.savedAccount === null) return shadow.newTerminalsUseSavedKey ? "New terminals use the saved key." : null;
302
+ const saved = `The saved key is for ${shadow.savedAccount}.`;
303
+ return shadow.newTerminalsUseSavedKey ? `${saved} New terminals use it.` : saved;
304
+ };
305
+ var leaveShellKeyLine = (shadow) => shadow.newTerminalsUseSavedKey ? "Open a new terminal, or run unset PUSHARY_API_KEY, before you start an agent here." : "If new terminals still get the old key, change PUSHARY_API_KEY where it is set, then open a new terminal before you start an agent.";
306
+ var describeShellKeyShadow = (shadow) => [shellKeyLine(shadow), savedKeyLine(shadow), leaveShellKeyLine(shadow)].filter((line) => line !== null);
307
+ var describeLockedKeyAccount = (key, account) => account ? `${account} has no active plan.` : `The key ${maskKey(key)} is on an account with no active plan.`;
308
+
225
309
  export {
226
- runBrowserLogin
310
+ runBrowserLogin,
311
+ isKeyHeldByMacApp,
312
+ replacedShellKeyChoice,
313
+ keepsTheSavedKeyOverTheReplacedShellKey,
314
+ pickReusableKey,
315
+ describeFoundKey,
316
+ describeUsedKey,
317
+ canAskAtTheTerminal,
318
+ keyReuseConfirmation,
319
+ keyAccountHandle,
320
+ continueAsQuestion,
321
+ keepSavedKeyQuestion,
322
+ switchBackToTheShellKeyLine,
323
+ WRONG_ACCOUNT_HINT,
324
+ wrongAccountHintPlacement,
325
+ describeSignedIn,
326
+ describeKeyAccount,
327
+ describeShellKeyShadow,
328
+ describeLockedKeyAccount
227
329
  };
@@ -1,19 +1,20 @@
1
1
  import {
2
2
  resolveInstallSourceFor
3
- } from "./chunk-GEA6ZV2P.js";
3
+ } from "./chunk-TBE76OH7.js";
4
4
  import {
5
5
  backupFile,
6
6
  readJsonSafe,
7
7
  writeFileAtomic,
8
8
  writeJsonAtomic
9
- } from "./chunk-6CDA4R5L.js";
9
+ } from "./chunk-7DJWJWRS.js";
10
10
  import {
11
11
  configFilePath
12
- } from "./chunk-RZD7ULBJ.js";
12
+ } from "./chunk-L6Q5FZ54.js";
13
13
  import {
14
14
  API_KEY_PREFIX_PATTERN,
15
- isRecord
16
- } from "./chunk-WOFHN2IZ.js";
15
+ isRecord,
16
+ isValidApiKey
17
+ } from "./chunk-EBGUGOS3.js";
17
18
 
18
19
  // src/shell-alias.ts
19
20
  import { homedir } from "os";
@@ -116,6 +117,8 @@ var isDisabledExport = (line) => {
116
117
  var keyPrefix = (key) => key.split(".")[0] ?? key;
117
118
  var MAC_APP_KEY_PREFIX_FIELD = "macAppKeyPrefix";
118
119
  var CLI_CREATED_KEY_PREFIX_FIELD = "cliCreatedKeyPrefix";
120
+ var REPLACED_KEY_PREFIX_FIELD = "replacedKeyPrefix";
121
+ var REPLACED_KEY_HONOURED_FIELD = "replacedKeyHonouredPrefix";
119
122
  var isCliCreatedKey = (key, createdPrefix) => keyPrefix(key) === createdPrefix;
120
123
  var findKeyExport = (contents) => {
121
124
  const lines = contents.split("\n");
@@ -138,6 +141,35 @@ var withKeyRecords = (current, apiKey, origin) => {
138
141
  const { [CLI_CREATED_KEY_PREFIX_FIELD]: _previous, ...rest } = keepMacAppKeyPrefix(current, apiKey);
139
142
  return savedKeyIsCliCreated(current, apiKey, origin) ? { ...rest, [CLI_CREATED_KEY_PREFIX_FIELD]: keyPrefix(apiKey) } : rest;
140
143
  };
144
+ var replacedKeyToRecord = (keyInForce, apiKey, rc, platform) => keyInForce !== null && keyInForce !== apiKey && isValidApiKey(keyInForce) && newTerminalsUseSavedKey(rc, platform) ? keyInForce : null;
145
+ var withoutStaleReplacedKeyRecord = (current, apiKey) => {
146
+ const { [REPLACED_KEY_PREFIX_FIELD]: recorded, [REPLACED_KEY_HONOURED_FIELD]: honoured, ...rest } = current;
147
+ if (recorded === void 0 || current.apiKey !== apiKey) return rest;
148
+ return honoured === void 0 ? { ...rest, [REPLACED_KEY_PREFIX_FIELD]: recorded } : { ...rest, [REPLACED_KEY_PREFIX_FIELD]: recorded, [REPLACED_KEY_HONOURED_FIELD]: honoured };
149
+ };
150
+ var withReplacedKeyRecordHonoured = (kept) => {
151
+ const recorded = kept[REPLACED_KEY_PREFIX_FIELD];
152
+ return typeof recorded === "string" ? { ...kept, [REPLACED_KEY_HONOURED_FIELD]: recorded } : { ...kept };
153
+ };
154
+ var replacedKeyRecordAfterSave = (current, apiKey, honoured) => {
155
+ const kept = withoutStaleReplacedKeyRecord(current, apiKey);
156
+ return honoured ? withReplacedKeyRecordHonoured(kept) : kept;
157
+ };
158
+ var recordReplacedKey = (configPath, replacedKey) => {
159
+ const current = readConfigRecord(configPath);
160
+ if (current === null) return;
161
+ try {
162
+ writeJsonAtomic(configPath, { ...current, [REPLACED_KEY_PREFIX_FIELD]: keyPrefix(replacedKey) }, KEY_FILE_MODE);
163
+ } catch {
164
+ return;
165
+ }
166
+ };
167
+ var shellKeyWasReplaced = ({ shellKey, savedKey, replacedKeyPrefix }) => {
168
+ if (!shellKey || savedKey === null || replacedKeyPrefix === null) return false;
169
+ return shellKey !== savedKey && keyPrefix(shellKey) === replacedKeyPrefix;
170
+ };
171
+ var RC_KINDS_NEW_TERMINALS_FOLLOW = /* @__PURE__ */ new Set(["written", "updated", "unchanged"]);
172
+ var newTerminalsUseSavedKey = (rc, platform) => platform !== "win32" && rc.shell !== null && RC_KINDS_NEW_TERMINALS_FOLLOW.has(rc.kind);
141
173
  var manualKeyStepFor = (kind, platform) => kind === "no-rc" || platform === "win32" ? "config-only" : "paste-export";
142
174
  var rcResult = (kind, over = {}) => ({
143
175
  kind,
@@ -220,7 +252,9 @@ var resolveRcTarget = () => {
220
252
  };
221
253
  var writeKey = (apiKey, origin, options = {}) => {
222
254
  const configPath = configFilePath();
255
+ const keyInForce = readKeySource().key;
223
256
  const existing = readJsonSafe(configPath);
257
+ const replacedKeyRecordWasHonoured = options.replacedKeyRecordWasHonoured === true;
224
258
  let current = {};
225
259
  let configBackupPath = null;
226
260
  if (existing.kind === "unreadable") {
@@ -236,7 +270,7 @@ var writeKey = (apiKey, origin, options = {}) => {
236
270
  writeJsonAtomic(
237
271
  configPath,
238
272
  {
239
- ...withKeyRecords(current, apiKey, origin),
273
+ ...withKeyRecords(replacedKeyRecordAfterSave(current, apiKey, replacedKeyRecordWasHonoured), apiKey, origin),
240
274
  apiKey,
241
275
  installSource: resolveInstallSourceFor(current),
242
276
  ...options.controlMode ? { controlMode: options.controlMode } : {},
@@ -247,6 +281,8 @@ var writeKey = (apiKey, origin, options = {}) => {
247
281
  restrictFile(configPath);
248
282
  const target = (options.resolveRc ?? resolveRcTarget)();
249
283
  const rc = target ? rewriteRcExport(target.path, apiKey, target.shell) : rcResult("no-rc");
284
+ const replacedKey = replacedKeyRecordWasHonoured ? null : replacedKeyToRecord(keyInForce, apiKey, rc, process.platform);
285
+ if (replacedKey !== null) recordReplacedKey(configPath, replacedKey);
250
286
  process.env.PUSHARY_API_KEY = apiKey;
251
287
  return { configPath, rc, configBackupPath };
252
288
  };
@@ -255,7 +291,7 @@ var clearKey = (options = {}) => {
255
291
  const existing = readConfigRecord(configPath);
256
292
  let removedFromConfig = false;
257
293
  if (existing !== null && typeof existing.apiKey === "string") {
258
- const { apiKey: _dropped, [MAC_APP_KEY_PREFIX_FIELD]: _adopted, [CLI_CREATED_KEY_PREFIX_FIELD]: _created, ...rest } = existing;
294
+ const { apiKey: _dropped, [MAC_APP_KEY_PREFIX_FIELD]: _adopted, [CLI_CREATED_KEY_PREFIX_FIELD]: _created, [REPLACED_KEY_PREFIX_FIELD]: _replaced, [REPLACED_KEY_HONOURED_FIELD]: _honoured, ...rest } = existing;
259
295
  writeJsonAtomic(configPath, rest, KEY_FILE_MODE);
260
296
  restrictFile(configPath);
261
297
  removedFromConfig = true;
@@ -333,6 +369,11 @@ var readRecordedKeyPrefix = (configPath, field) => {
333
369
  var readMacAppKeyPrefix = (configPath = configFilePath()) => readRecordedKeyPrefix(configPath, MAC_APP_KEY_PREFIX_FIELD);
334
370
  var isAdoptedMacAppKey = (key, adoptedPrefix) => keyPrefix(key) === adoptedPrefix;
335
371
  var readCliCreatedKeyPrefix = (configPath = configFilePath()) => readRecordedKeyPrefix(configPath, CLI_CREATED_KEY_PREFIX_FIELD);
372
+ var readReplacedKeyPrefix = (configPath = configFilePath()) => readRecordedKeyPrefix(configPath, REPLACED_KEY_PREFIX_FIELD);
373
+ var replacedKeyRecordIsHonoured = (configPath = configFilePath()) => {
374
+ const recorded = readReplacedKeyPrefix(configPath);
375
+ return recorded !== null && readRecordedKeyPrefix(configPath, REPLACED_KEY_HONOURED_FIELD) === recorded;
376
+ };
336
377
  var recordMacAppKeyPrefix = (apiKey, configPath = configFilePath()) => {
337
378
  const config = readConfigRecord(configPath);
338
379
  if (config === null || config.apiKey !== apiKey) return false;
@@ -371,6 +412,8 @@ export {
371
412
  isDisabledExport,
372
413
  keyPrefix,
373
414
  isCliCreatedKey,
415
+ shellKeyWasReplaced,
416
+ newTerminalsUseSavedKey,
374
417
  manualKeyStepFor,
375
418
  resolveRcTarget,
376
419
  writeKey,
@@ -383,6 +426,8 @@ export {
383
426
  readMacAppKeyPrefix,
384
427
  isAdoptedMacAppKey,
385
428
  readCliCreatedKeyPrefix,
429
+ readReplacedKeyPrefix,
430
+ replacedKeyRecordIsHonoured,
386
431
  recordMacAppKeyPrefix,
387
432
  shellProfileCandidates,
388
433
  findExportedKeyLines,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  readTranscriptPreference
3
- } from "./chunk-HD7AURL6.js";
3
+ } from "./chunk-BYGU5IV4.js";
4
4
 
5
5
  // src/transcript-setting.ts
6
6
  var transcriptEnvironmentPreference = () => {