@pushary/agent-hooks 1.9.145 → 1.9.147

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 (167) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +5 -4
  3. package/data/SKILL.md +3 -3
  4. package/data/cursor-plugin/scripts/redaction.mjs +2 -1
  5. package/data/cursor-plugin/skills/pushary/SKILL.md +2 -2
  6. package/data/openclaw-plugin/LICENSE +21 -0
  7. package/data/openclaw-plugin/README.md +113 -0
  8. package/data/openclaw-plugin/dist/api-key-shape.js +5 -0
  9. package/data/openclaw-plugin/dist/approval-hook.js +88 -0
  10. package/data/openclaw-plugin/dist/approval-question.js +66 -0
  11. package/data/openclaw-plugin/dist/connection.js +101 -0
  12. package/data/openclaw-plugin/dist/decision-reply.js +6 -0
  13. package/data/openclaw-plugin/dist/gate-result.js +58 -0
  14. package/data/openclaw-plugin/dist/gate.js +173 -0
  15. package/data/openclaw-plugin/dist/hook-budget.js +19 -0
  16. package/data/openclaw-plugin/dist/host-api.js +1 -0
  17. package/data/openclaw-plugin/dist/host-version.js +25 -0
  18. package/data/openclaw-plugin/dist/index.js +32 -0
  19. package/data/openclaw-plugin/dist/openclaw-paths.js +43 -0
  20. package/data/openclaw-plugin/dist/openclaw-write-guard.js +93 -0
  21. package/data/openclaw-plugin/dist/protected-writes.js +217 -0
  22. package/data/openclaw-plugin/dist/pushary-client.js +103 -0
  23. package/data/openclaw-plugin/dist/pushary-hosts.js +3 -0
  24. package/data/openclaw-plugin/dist/redaction.js +53 -0
  25. package/data/openclaw-plugin/dist/replies.js +65 -0
  26. package/data/openclaw-plugin/dist/settings.js +103 -0
  27. package/data/openclaw-plugin/openclaw.plugin.json +32 -0
  28. package/data/openclaw-plugin/package.json +70 -0
  29. package/data/vscode-plugin/scripts/redaction.mjs +2 -1
  30. package/data/vscode-plugin/skills/pushary/SKILL.md +2 -2
  31. package/dist/{api-KWJQMO6G.js → api-2KDVLXHT.js} +11 -11
  32. package/dist/bin/pushary-audit.js +3 -3
  33. package/dist/bin/pushary-bell-hook.js +28 -28
  34. package/dist/bin/pushary-bell.js +11 -11
  35. package/dist/bin/pushary-claude.js +27 -27
  36. package/dist/bin/pushary-clean.js +76 -39
  37. package/dist/bin/pushary-codex-bridge.js +23 -23
  38. package/dist/bin/pushary-codex-hook.js +35 -35
  39. package/dist/bin/pushary-codex-session.js +8 -8
  40. package/dist/bin/pushary-codex.js +16 -16
  41. package/dist/bin/pushary-connect.js +78 -36
  42. package/dist/bin/pushary-cowork.js +5 -5
  43. package/dist/bin/pushary-daemon.js +44 -43
  44. package/dist/bin/pushary-disconnect.js +28 -28
  45. package/dist/bin/pushary-display-hook.js +96 -44
  46. package/dist/bin/pushary-doctor.js +124 -55
  47. package/dist/bin/pushary-elicitation-hook.js +28 -28
  48. package/dist/bin/pushary-gemini-bridge.js +17 -17
  49. package/dist/bin/pushary-gemini-hook.js +32 -32
  50. package/dist/bin/pushary-hook.js +35 -35
  51. package/dist/bin/pushary-login.js +22 -22
  52. package/dist/bin/pushary-logout.js +33 -31
  53. package/dist/bin/pushary-mcp.js +12 -12
  54. package/dist/bin/pushary-mode.js +16 -16
  55. package/dist/bin/pushary-notification-hook.js +27 -27
  56. package/dist/bin/pushary-opencode-hook.js +31 -31
  57. package/dist/bin/pushary-permission-denied-hook.js +35 -35
  58. package/dist/bin/pushary-permission-hook.js +35 -35
  59. package/dist/bin/pushary-post-hook.js +28 -28
  60. package/dist/bin/pushary-prompt-hook.js +27 -27
  61. package/dist/bin/pushary-session-end-hook.js +27 -27
  62. package/dist/bin/pushary-session-start-hook.js +37 -36
  63. package/dist/bin/pushary-setup.js +140 -87
  64. package/dist/bin/pushary-stats.js +5 -5
  65. package/dist/bin/pushary-status.js +38 -36
  66. package/dist/bin/pushary-stop-hook.js +27 -27
  67. package/dist/bin/pushary-stopfailure-hook.js +27 -27
  68. package/dist/bin/pushary-suggestions.js +16 -16
  69. package/dist/bin/pushary-transcript-register.js +17 -17
  70. package/dist/bin/pushary-transcripts.js +25 -25
  71. package/dist/bin/pushary-upgrade.js +42 -41
  72. package/dist/bin/pushary-wait.js +16 -16
  73. package/dist/bin/pushary.js +7 -7
  74. package/dist/{chunk-4KDRT3OA.js → chunk-2EETRVCZ.js} +1 -1
  75. package/dist/{chunk-LJRPWUST.js → chunk-2G54YLN3.js} +3 -3
  76. package/dist/{chunk-R34RWVN2.js → chunk-2I6A34GJ.js} +14 -5
  77. package/dist/{chunk-WPBWJMBZ.js → chunk-2QY2BD4T.js} +5 -5
  78. package/dist/{chunk-RO6EVL5C.js → chunk-2RAIG6NF.js} +2 -2
  79. package/dist/{chunk-LD4R2P6N.js → chunk-2YNAQ5TX.js} +1 -1
  80. package/dist/{chunk-TRV3ETGY.js → chunk-37ZBJB2Q.js} +5 -5
  81. package/dist/{chunk-BWREST4F.js → chunk-3NMX4725.js} +1 -1
  82. package/dist/{chunk-YRJZF5RG.js → chunk-3TTXOU6G.js} +3 -3
  83. package/dist/{chunk-FCSPMSDC.js → chunk-4P3ML7HP.js} +200 -59
  84. package/dist/{chunk-IRPIMQ7U.js → chunk-526XSNMS.js} +3 -3
  85. package/dist/{chunk-4L5WPDTB.js → chunk-57GVGSOQ.js} +1 -1
  86. package/dist/{chunk-ZORBUQFG.js → chunk-5II3USXS.js} +2 -2
  87. package/dist/{chunk-USFZJAB4.js → chunk-5K65H6OO.js} +1 -1
  88. package/dist/{chunk-5TWW7ZUL.js → chunk-6C5QRJIH.js} +5 -5
  89. package/dist/{chunk-KFALRZIN.js → chunk-6EPTMB7L.js} +4 -4
  90. package/dist/{chunk-LQXUWXQP.js → chunk-6JBX55K4.js} +31 -8
  91. package/dist/{chunk-B4JQIH5M.js → chunk-6YVGY2ZX.js} +7 -7
  92. package/dist/{chunk-7LTP2GHO.js → chunk-72S6PF2I.js} +2 -2
  93. package/dist/{chunk-WMBWKPKJ.js → chunk-7P32YU2M.js} +10 -74
  94. package/dist/{chunk-TJXJGMSP.js → chunk-7TVSWGAV.js} +8 -6
  95. package/dist/{chunk-L4OGTRVW.js → chunk-7WDEJTNX.js} +4 -4
  96. package/dist/{chunk-KGFB2LEB.js → chunk-7XIJD7NL.js} +3 -3
  97. package/dist/{chunk-S3A4PCRR.js → chunk-A5MSVNFS.js} +10 -10
  98. package/dist/{chunk-OONMKLUF.js → chunk-ANLR5G2W.js} +4 -4
  99. package/dist/{chunk-HOQH5CLZ.js → chunk-BEDAQAEN.js} +1 -1
  100. package/dist/{chunk-JKWUF776.js → chunk-BHGSNYG5.js} +3 -3
  101. package/dist/{chunk-VTJ4WZOC.js → chunk-BU2J4P7P.js} +3 -3
  102. package/dist/{chunk-6UK4K5RS.js → chunk-BYVLAPCF.js} +1 -1
  103. package/dist/{chunk-KS3PNTRT.js → chunk-CSNG5NQR.js} +1 -1
  104. package/dist/{chunk-JZT2LPRM.js → chunk-D7ZWJYXB.js} +1 -1
  105. package/dist/{chunk-Y7INHH5G.js → chunk-ELRZO6A7.js} +3 -3
  106. package/dist/{chunk-6IWOMXUF.js → chunk-EV54ZQ5J.js} +4 -4
  107. package/dist/{chunk-33BYPZ52.js → chunk-FHBJJOMF.js} +1 -1
  108. package/dist/{chunk-YU5XE6VC.js → chunk-FKGWP4MF.js} +8 -7
  109. package/dist/{chunk-2ELNRGNX.js → chunk-FMAIUTVU.js} +3 -3
  110. package/dist/{chunk-EPWOARGR.js → chunk-FWCECQTY.js} +2 -2
  111. package/dist/{chunk-BYKRAYGD.js → chunk-GGCUXNZN.js} +1 -1
  112. package/dist/{chunk-WH4ODOCE.js → chunk-GIWI5IHB.js} +6 -6
  113. package/dist/{chunk-72LP4RPC.js → chunk-GJV5RVUU.js} +98 -47
  114. package/dist/chunk-GPAMD5JG.js +157 -0
  115. package/dist/{chunk-FNAH3YJC.js → chunk-I72UU75H.js} +16 -16
  116. package/dist/{chunk-ZSOCJHL7.js → chunk-ISM6XF3V.js} +309 -5
  117. package/dist/{chunk-Q6P7G4NY.js → chunk-ISOP4ENY.js} +17 -5
  118. package/dist/{chunk-6LZ7MXHD.js → chunk-JDIKCM2N.js} +5 -5
  119. package/dist/{chunk-52UXNCZG.js → chunk-KDJIDRJS.js} +3 -3
  120. package/dist/{chunk-LMU6NG2G.js → chunk-KFL7OWLI.js} +1 -1
  121. package/dist/{chunk-PXZTCR4M.js → chunk-KH27X5CW.js} +2 -2
  122. package/dist/{chunk-MOC2DN42.js → chunk-KXMIDDUN.js} +2 -2
  123. package/dist/{chunk-QKTF7WS6.js → chunk-L2M6D2N4.js} +4 -4
  124. package/dist/{chunk-CUR2DCZN.js → chunk-L6BTSIKF.js} +4 -4
  125. package/dist/{chunk-YZA3YBHX.js → chunk-LO52V6WG.js} +2 -2
  126. package/dist/{chunk-GK5X2ZTN.js → chunk-MI7GHNTO.js} +5 -5
  127. package/dist/{chunk-MKHVLDMN.js → chunk-MYJJNLT2.js} +2 -2
  128. package/dist/{chunk-WUT3PO33.js → chunk-NAGF5ZJ2.js} +8 -8
  129. package/dist/{chunk-ZBMVOMFG.js → chunk-NMUEUDTT.js} +1 -1
  130. package/dist/{chunk-MNU5N3CQ.js → chunk-OSYULPJO.js} +23 -12
  131. package/dist/{chunk-SQL5YXUH.js → chunk-OXDKZYBO.js} +1 -1
  132. package/dist/chunk-OYIN77HO.js +72 -0
  133. package/dist/{chunk-KKPT7ROP.js → chunk-P6W2V2AP.js} +2 -2
  134. package/dist/{chunk-G3VSMI7K.js → chunk-Q3JW44JV.js} +2 -2
  135. package/dist/{chunk-K2SKUBYY.js → chunk-Q6POCQOV.js} +12 -12
  136. package/dist/{chunk-IIN26HL7.js → chunk-Q767Y4LY.js} +1 -1
  137. package/dist/{chunk-GURIOZE7.js → chunk-QGKFDSEO.js} +8 -8
  138. package/dist/{chunk-YNCVSKUW.js → chunk-RZGR4G5G.js} +5 -5
  139. package/dist/{chunk-2LGDEPVL.js → chunk-RZJHCHEA.js} +6 -6
  140. package/dist/{chunk-ZJZNT2G5.js → chunk-T274HRSR.js} +4 -4
  141. package/dist/chunk-T2CR5REM.js +176 -0
  142. package/dist/{chunk-A2H256WR.js → chunk-T3TVMMXJ.js} +1 -1
  143. package/dist/{chunk-NTMKJRQ3.js → chunk-TZ7CBPCD.js} +2 -2
  144. package/dist/{chunk-S7HGPKCL.js → chunk-UGPNLU4O.js} +1 -1
  145. package/dist/{chunk-DZIZ3XFL.js → chunk-UR55VBLY.js} +2 -2
  146. package/dist/{chunk-PY6CM4NK.js → chunk-WLKW2TF7.js} +19 -12
  147. package/dist/{chunk-63WX5KZN.js → chunk-WNV3X2VU.js} +3 -3
  148. package/dist/{chunk-WOSO4YFQ.js → chunk-XQOBM3E6.js} +3 -3
  149. package/dist/{chunk-RWLNTZK5.js → chunk-YICO6HEW.js} +5 -5
  150. package/dist/{chunk-FO3MDD26.js → chunk-YM2T76UM.js} +27 -0
  151. package/dist/chunk-YOVJOHM5.js +36 -0
  152. package/dist/{chunk-IDLOJIIS.js → chunk-ZKAQWXGO.js} +1 -1
  153. package/dist/{codex-app-cards-switch-F7WQ7Y3I.js → codex-app-cards-switch-GN65VEKM.js} +11 -11
  154. package/dist/{codex-card-routing-EVL5L36G.js → codex-card-routing-JTS75442.js} +2 -2
  155. package/dist/{codex-desktop-launch-PL6Z2ELZ.js → codex-desktop-launch-AQ2HSOQJ.js} +1 -1
  156. package/dist/{codex-session-launch-7NQEAUDU.js → codex-session-launch-QYZZGVSQ.js} +20 -20
  157. package/dist/{config-KFFD4VWH.js → config-5ATI6KPI.js} +3 -3
  158. package/dist/{global-upgrade-L3CY6EFF.js → global-upgrade-K4HWVUMI.js} +9 -9
  159. package/dist/{identity-DPYYIMHL.js → identity-V2GZCPJV.js} +4 -4
  160. package/dist/{live-capabilities-QJEXK6GH.js → live-capabilities-PD62FO4K.js} +4 -4
  161. package/dist/{paths-PEF6C64P.js → paths-WPJEIHUE.js} +7 -3
  162. package/dist/{reapply-7APCQRRK.js → reapply-ZEWMGDXT.js} +30 -29
  163. package/dist/src/index.js +34 -34
  164. package/dist/{upgrade-lock-A7OKXMRW.js → upgrade-lock-7OR6V323.js} +4 -4
  165. package/dist/{usage-HSS33762.js → usage-GWZ3UGZG.js} +3 -3
  166. package/package.json +1 -1
  167. package/dist/chunk-D3UFDCTQ.js +0 -87
@@ -4,6 +4,8 @@ import {
4
4
  publicKeyFingerprint
5
5
  } from "./chunk-3EGEA4KH.js";
6
6
  import {
7
+ PUSHARY_APP_DOWNLOAD_URL,
8
+ SIGN_IN_ON_THE_APP_STEP,
7
9
  describeAppRepair,
8
10
  describeJustPairedRepair,
9
11
  describeReach,
@@ -12,26 +14,35 @@ import {
12
14
  reachVerdict,
13
15
  reachesYou,
14
16
  verifyDelivery
15
- } from "./chunk-PY6CM4NK.js";
17
+ } from "./chunk-WLKW2TF7.js";
18
+ import {
19
+ describeRevokeAttempt,
20
+ keyNoLongerAccepted,
21
+ revokeOwnKey
22
+ } from "./chunk-OYIN77HO.js";
16
23
  import {
17
24
  humanIsTty,
18
25
  writeHuman
19
26
  } from "./chunk-QCGNGEGE.js";
20
27
  import {
21
28
  clipToRow,
29
+ isCI,
22
30
  terminalColumns,
23
31
  useColor
24
- } from "./chunk-FO3MDD26.js";
32
+ } from "./chunk-YM2T76UM.js";
33
+ import {
34
+ checkApiKey
35
+ } from "./chunk-3TTXOU6G.js";
25
36
  import {
26
37
  reportedInstallSource
27
- } from "./chunk-MOC2DN42.js";
38
+ } from "./chunk-KXMIDDUN.js";
28
39
  import {
29
40
  NPX_LATEST_COMMAND
30
- } from "./chunk-6LZ7MXHD.js";
41
+ } from "./chunk-JDIKCM2N.js";
31
42
  import {
32
43
  NO_PAIRING_COMPUTER,
33
44
  PAIR_TTL_SECONDS
34
- } from "./chunk-LQXUWXQP.js";
45
+ } from "./chunk-6JBX55K4.js";
35
46
 
36
47
  // src/onboarding.ts
37
48
  import qrcodeTerminal from "qrcode-terminal";
@@ -190,6 +201,7 @@ var printQr = (url) => new Promise((resolve, reject) => {
190
201
  reject(err);
191
202
  }
192
203
  });
204
+ var canShowPairingQr = () => !isCI();
193
205
  var phoneFailure = (detail, repair) => ({
194
206
  reachesYou: false,
195
207
  outcome: null,
@@ -252,7 +264,7 @@ var sendAndConfirm = async (apiKey, channels) => {
252
264
  var printCapabilityDelta = () => {
253
265
  console.log(` ${dim("Two ways to get approvals on your phone:")}`);
254
266
  console.log();
255
- console.log(` ${bold("Pushary app")} ${dim("(iOS / Android)")} ${cyan("pushary setup --connect app")}`);
267
+ console.log(` ${bold("Pushary app")} ${dim("(iOS / Android)")} ${cyan("pushary pair")}`);
256
268
  console.log(` ${dim("\u2022 Answers from the lock screen, and while the app is closed")}`);
257
269
  console.log(` ${dim("\u2022 Can start and steer agents remotely")}`);
258
270
  console.log();
@@ -370,6 +382,7 @@ var waitForAppRegistration = async (apiKey) => {
370
382
  stop(yellow("!"), "This phone has not registered for notifications yet");
371
383
  return { kind: "timeout" };
372
384
  };
385
+ var APP_NOT_REGISTERED = "app_not_registered";
373
386
  var confirmAppConnection = async (apiKey) => {
374
387
  const probe = await fetchChannels(apiKey);
375
388
  if (probe.kind !== "ok") return describeProbeFailure(probe);
@@ -384,26 +397,47 @@ var confirmAppConnection = async (apiKey) => {
384
397
  const repair = describeJustPairedRepair(reachVerdict(channels));
385
398
  console.log(` ${yellow("!")} Paired, but this phone has not registered for notifications yet.`);
386
399
  for (const line of repair) console.log(` ${dim(line)}`);
387
- console.log(` ${dim("Then run")} ${cyan("pushary doctor")}${dim(".")}`);
388
- return phoneFailure("app_not_registered", repair);
400
+ console.log(` ${dim("Then run")} ${cyan("pushary doctor --roundtrip")} ${dim("to test delivery. No new pairing is needed.")}`);
401
+ return phoneFailure(APP_NOT_REGISTERED, repair);
389
402
  }
390
403
  return sendAndConfirm(apiKey, channels);
391
404
  };
405
+ var phoneAwaitsNotificationPermission = (result) => result.detail === APP_NOT_REGISTERED;
406
+ var pairingAgainHelps = (result) => !phoneAwaitsNotificationPermission(result);
392
407
  var planAppConnect = (channels) => channels.precise && ownedApp(channels) === 0 ? { kind: "unpaired", repair: describeAppRepair(reachVerdict(channels)) ?? [] } : { kind: "send" };
393
- var connectExistingApp = async (apiKey) => {
408
+ var checkPhoneWithoutPairing = async (apiKey) => {
394
409
  const probe = await fetchChannels(apiKey);
395
410
  if (probe.kind !== "ok") return describeProbeFailure(probe);
396
411
  const plan = planAppConnect(probe.status);
397
- if (plan.kind === "send") {
412
+ if (plan.kind === "send" || reachesYou(probe.status)) {
398
413
  console.log(` ${check} ${describeExistingConnection(probe.status)}`);
399
414
  return sendAndConfirm(apiKey, probe.status);
400
415
  }
401
416
  console.log(` ${yellow("!")} No Pushary app of yours is connected to this site, and nothing was paired just now.`);
402
417
  for (const line of plan.repair) console.log(` ${dim(line)}`);
403
- console.log(` ${dim("No app yet? Get it at")} ${cyan("https://pushary.com/download")}`);
418
+ console.log(` ${dim("No app yet? Get it at")} ${cyan(PUSHARY_APP_DOWNLOAD_URL)}`);
404
419
  return phoneFailure("app_not_paired", plan.repair);
405
420
  };
406
- var printConnectInstructions = async (apiKey) => {
421
+ var GET_THE_APP_HEADING = "Connect your phone with the Pushary app";
422
+ var GET_THE_APP_SCAN_LINE = "Scan this with your phone's camera to get the app:";
423
+ var appDownloadLinkLabel = (qrShown) => qrShown ? "or open" : "Get it at";
424
+ var printGetTheApp = async (options) => {
425
+ console.log();
426
+ console.log(` ${bold(GET_THE_APP_HEADING)}`);
427
+ if (options.showQr) {
428
+ console.log(` ${dim(GET_THE_APP_SCAN_LINE)}`);
429
+ await printQr(PUSHARY_APP_DOWNLOAD_URL);
430
+ }
431
+ console.log(` ${dim(appDownloadLinkLabel(options.showQr))} ${cyan(PUSHARY_APP_DOWNLOAD_URL)}`);
432
+ console.log(` ${dim(SIGN_IN_ON_THE_APP_STEP)}`);
433
+ };
434
+ var printSubscribePage = async (apiKey) => {
435
+ const site = await fetchSite(apiKey);
436
+ console.log(` ${dim("Pair your phone for push notifications at")} ${cyan(site?.subscribeUrl ?? PUSHARY_APP_DOWNLOAD_URL)}`);
437
+ console.log(` ${dim("or get the Pushary app at")} ${cyan(PUSHARY_APP_DOWNLOAD_URL)}`);
438
+ };
439
+ var printPhoneInstructions = (apiKey, options) => options.channel === "browser" ? printSubscribePage(apiKey) : printGetTheApp(options);
440
+ var printConnectInstructions = async (apiKey, options) => {
407
441
  const probe = await fetchChannels(apiKey);
408
442
  if (probe.kind !== "ok") return describeProbeFailure(probe);
409
443
  const channels = probe.status;
@@ -414,10 +448,7 @@ var printConnectInstructions = async (apiKey) => {
414
448
  if (channels.site !== null && channels.site.otherMembers > 0 && channels.phoneReachable) {
415
449
  printSiteOnlyWarning(channels);
416
450
  }
417
- const site = await fetchSite(apiKey);
418
- const target = site?.subscribeUrl ?? "https://pushary.com/download";
419
- console.log(` ${dim("Pair your phone for push notifications at")} ${cyan(target)}`);
420
- console.log(` ${dim("or get the Pushary app at")} ${cyan("https://pushary.com/download")}`);
451
+ await printPhoneInstructions(apiKey, options);
421
452
  return phoneFailure("no_device");
422
453
  };
423
454
  var PAIR_POLL_INTERVAL_MS = 2e3;
@@ -440,17 +471,28 @@ var pairWaitingLabel = (elapsedMs, minutesLeft) => {
440
471
  const labels = [...due.map((advice) => dim(advice.text)).reverse(), pairCountdownLabel(elapsedMs, minutesLeft)];
441
472
  return labels[Math.floor((elapsedMs - newest.afterMs) / PAIR_ADVICE_ROTATION_MS) % labels.length] ?? PAIR_WAITING_LABEL;
442
473
  };
443
- var PAIR_GET_APP_LINE = "No app yet? Get it at pushary.com/download. Setup keeps waiting.";
444
- var PAIRING_ESCAPE_APP_URL = "https://pushary.com/download";
474
+ var PAIR_GET_APP_LINE = "No app yet? Get it at pushary.com/download. Pairing keeps waiting.";
445
475
  var PAIRING_ESCAPE_KEY_COMMAND = `${NPX_LATEST_COMMAND} setup --key pk_...`;
446
476
  var PAIRING_ESCAPE_KEY_PAGE = "pushary.com/dashboard/agent/settings";
447
477
  var describePairingEscape = () => [
448
- `${yellow("!")} No app yet? Get it at ${cyan(PAIRING_ESCAPE_APP_URL)}, then run setup again.`,
478
+ `${yellow("!")} No app yet? Get it at ${cyan(PUSHARY_APP_DOWNLOAD_URL)}, then run setup again.`,
449
479
  "",
450
480
  ` ${dim("Already have a key? Use it instead:")}`,
451
481
  ` ${cyan(PAIRING_ESCAPE_KEY_COMMAND)}`,
452
482
  ` ${dim("Find it at")} ${cyan(PAIRING_ESCAPE_KEY_PAGE)}`
453
483
  ];
484
+ var PAIRING_CANCELLED_LABEL = "Cancelled";
485
+ var PAIRING_STOPPED_LABEL = "Stopped before your phone approved. The pairing code was cancelled.";
486
+ var PAIRING_KEEP_RUNNING_LINES = [
487
+ "This command has to keep running until your phone approves.",
488
+ "Run the same command again in the background, keep it running, and wait for it to finish."
489
+ ];
490
+ var describePairCommandEscape = () => [
491
+ `${yellow("!")} No app yet? Get it at ${cyan(PUSHARY_APP_DOWNLOAD_URL)}, then run ${cyan("pushary pair")} again.`
492
+ ];
493
+ var stoppedByTermination = (exitCode) => exitCode === EXIT_TERMINATED;
494
+ var describeCancelledPairingLabel = (exitCode) => stoppedByTermination(exitCode) ? PAIRING_STOPPED_LABEL : PAIRING_CANCELLED_LABEL;
495
+ var describeCancelledPairing = (exitCode, personEscape) => stoppedByTermination(exitCode) ? PAIRING_KEEP_RUNNING_LINES.map((line) => dim(line)) : personEscape;
454
496
  var describePairingScreen = (screen) => [
455
497
  bold("Connect your phone"),
456
498
  "Scan this with your phone's camera or the Pushary app.",
@@ -481,20 +523,22 @@ var startPairing = async (cliPublicKey, computer) => {
481
523
  return null;
482
524
  }
483
525
  };
484
- var describePairFailure = (reason) => {
526
+ var RERUN_NAME = { setup: "setup", pair: "pushary pair" };
527
+ var describePairFailure = (reason, command) => {
528
+ const rerun = RERUN_NAME[command];
485
529
  switch (reason) {
486
530
  case "no_site":
487
531
  return "Couldn't set up your workspace. Try again, or finish setup at pushary.com/dashboard";
488
532
  case "blocked":
489
- return "Finish setting up in the Pushary app, then run setup again";
533
+ return `Finish setting up in the Pushary app, then run ${rerun} again`;
490
534
  case "authorize_failed":
491
- return "The app could not authorize this terminal. Re-run setup to try again";
535
+ return `The app could not authorize this terminal. Re-run ${rerun} to try again`;
492
536
  case "payment_required":
493
- return "Your Pushary workspace has no active subscription. Subscribe in the Pushary app or at pushary.com, then run setup again";
537
+ return `Your Pushary workspace has no active subscription. Subscribe in the Pushary app or at pushary.com, then run ${rerun} again`;
494
538
  case "denied":
495
- return "You denied this computer on your phone. Run setup again if that was a mistake";
539
+ return `You denied this computer on your phone. Run ${rerun} again if that was a mistake`;
496
540
  default:
497
- return "Pairing failed. Re-run setup to try again";
541
+ return `Pairing failed. Re-run ${rerun} to try again`;
498
542
  }
499
543
  };
500
544
  var cancelPairing = async (pairId) => {
@@ -532,7 +576,7 @@ var ackPairing = async (pairId) => {
532
576
  }
533
577
  };
534
578
  var pairFailed = (reason) => ({ kind: "failed", reason });
535
- var pairingEscapeApplies = (outcome) => outcome.reason === "timeout" || outcome.reason === "expired" || outcome.reason === "cancelled";
579
+ var pairingEscapeApplies = (outcome) => outcome.reason === "timeout" || outcome.reason === "expired";
536
580
  var buildPairLinks = (pairId, publicKeyB64, baseUrl = apiBase(), code = null) => {
537
581
  const id = encodeURIComponent(pairId);
538
582
  const pk = encodeURIComponent(publicKeyB64);
@@ -551,7 +595,11 @@ var buildPairLinks = (pairId, publicKeyB64, baseUrl = apiBase(), code = null) =>
551
595
  deepLink: `pushary://pair?pk=${pk}&id=${id}`
552
596
  };
553
597
  };
554
- var connectViaAppPairing = async (options = {}) => {
598
+ var PAIR_TIMEOUT_MINUTES = Math.ceil(PAIR_TIMEOUT_MS / 6e4);
599
+ var PAIRING_KEEPS_RUNNING_NOTICE = `This keeps running until your phone approves, for up to ${PAIR_TIMEOUT_MINUTES} minutes. Run it in the background and keep it running.`;
600
+ var heldUntilTheSignalExits = () => new Promise(() => {
601
+ });
602
+ var connectViaAppPairing = async (options) => {
555
603
  const clock = options.clock ?? SYSTEM_PAIR_CLOCK;
556
604
  const keypair = generateKeypair();
557
605
  const requestedAt = clock.now();
@@ -561,48 +609,59 @@ var connectViaAppPairing = async (options = {}) => {
561
609
  return pairFailed("unreachable");
562
610
  }
563
611
  const { pairId, code } = started;
564
- const { qrLink, universalLink, deepLink } = buildPairLinks(pairId, keypair.publicKeyB64, apiBase(), code);
565
- for (const line of describePairingScreen({ universalLink, deepLink })) {
566
- console.log(` ${line}`);
567
- }
568
- await printQr(qrLink);
569
- console.log(` ${describePairingFingerprint(publicKeyFingerprint(keypair.publicKeyB64))}`);
570
- const startedAt = clock.now();
571
- const deadline = requestedAt + PAIR_TIMEOUT_MS;
572
- const elapsed = () => clock.now() - startedAt;
573
- const minutesLeft = () => Math.max(0, Math.ceil((deadline - clock.now()) / 6e4));
574
- const advisesInTheLabel = humanIsTty();
575
- let adviceWritten = 0;
576
- const writeAdviceThatFellDue = () => {
577
- const due = pairAdviceDue(elapsed());
578
- for (const advice of due.slice(adviceWritten)) writeStatusLine(dim(advice));
579
- adviceWritten = due.length;
580
- };
581
- const stop = startSpinner(() => advisesInTheLabel ? pairWaitingLabel(elapsed(), minutesLeft()) : pairCountdownLabel(elapsed(), minutesLeft()));
612
+ const rerun = RERUN_NAME[options.command];
582
613
  let cancelled = false;
614
+ let stopSpinner = null;
615
+ const finishWaitLine = (glyph, label) => {
616
+ if (stopSpinner === null) writeStatusLine(`${glyph} ${label}`);
617
+ else stopSpinner(glyph, label);
618
+ };
583
619
  const cancelOnSignal = (exitCode) => () => {
584
620
  if (cancelled) return;
585
621
  cancelled = true;
586
- stop(yellow("!"), "Cancelled");
622
+ finishWaitLine(yellow("!"), describeCancelledPairingLabel(exitCode));
587
623
  const flushed = options.onCancelled?.(exitCode);
588
624
  void Promise.allSettled([Promise.resolve(flushed), cancelPairing(pairId)]).finally(() => process.exit(exitCode));
589
625
  };
626
+ const unlessSignalled = (outcome) => cancelled ? heldUntilTheSignalExits() : outcome;
590
627
  const onInterrupt = cancelOnSignal(EXIT_ABORTED);
591
628
  const onTerminate = cancelOnSignal(EXIT_TERMINATED);
592
629
  process.once("SIGINT", onInterrupt);
593
630
  process.once("SIGTERM", onTerminate);
594
- let consecutiveFailures = 0;
595
631
  try {
632
+ const { qrLink, universalLink, deepLink } = buildPairLinks(pairId, keypair.publicKeyB64, apiBase(), code);
633
+ if (!humanIsTty()) console.log(` ${PAIRING_KEEPS_RUNNING_NOTICE}`);
634
+ for (const line of describePairingScreen({ universalLink, deepLink })) {
635
+ console.log(` ${line}`);
636
+ }
637
+ await printQr(qrLink);
638
+ if (cancelled) return heldUntilTheSignalExits();
639
+ console.log(` ${describePairingFingerprint(publicKeyFingerprint(keypair.publicKeyB64))}`);
640
+ const startedAt = clock.now();
641
+ const deadline = requestedAt + PAIR_TIMEOUT_MS;
642
+ const elapsed = () => clock.now() - startedAt;
643
+ const minutesLeft = () => Math.max(0, Math.ceil((deadline - clock.now()) / 6e4));
644
+ const advisesInTheLabel = humanIsTty();
645
+ let adviceWritten = 0;
646
+ const writeAdviceThatFellDue = () => {
647
+ const due = pairAdviceDue(elapsed());
648
+ for (const advice of due.slice(adviceWritten)) writeStatusLine(dim(advice));
649
+ adviceWritten = due.length;
650
+ };
651
+ const stop = startSpinner(() => advisesInTheLabel ? pairWaitingLabel(elapsed(), minutesLeft()) : pairCountdownLabel(elapsed(), minutesLeft()));
652
+ stopSpinner = stop;
653
+ let consecutiveFailures = 0;
596
654
  while (clock.now() < deadline) {
597
- if (cancelled) return pairFailed("cancelled");
655
+ if (cancelled) return heldUntilTheSignalExits();
598
656
  if (!advisesInTheLabel) writeAdviceThatFellDue();
599
657
  const claim = await claimPairing(pairId);
658
+ if (cancelled) return heldUntilTheSignalExits();
600
659
  if (claim === null) {
601
660
  consecutiveFailures += 1;
602
661
  if (consecutiveFailures >= PAIR_MAX_CONSECUTIVE_FAILURES) {
603
- stop(yellow("!"), "Can't reach pushary.com to finish pairing. Check your connection, then re-run setup.");
662
+ stop(yellow("!"), `Can't reach pushary.com to finish pairing. Check your connection, then run ${rerun} again.`);
604
663
  await cancelPairing(pairId);
605
- return pairFailed("unreachable");
664
+ return unlessSignalled(pairFailed("unreachable"));
606
665
  }
607
666
  await clock.sleep(PAIR_POLL_INTERVAL_MS);
608
667
  continue;
@@ -613,31 +672,32 @@ var connectViaAppPairing = async (options = {}) => {
613
672
  try {
614
673
  apiKey = openSealedKey(claim.sealed, keypair);
615
674
  } catch {
616
- stop(yellow("!"), "Pairing failed to decrypt. Re-run setup to try again.");
675
+ stop(yellow("!"), `Pairing failed to decrypt. Re-run ${rerun} to try again.`);
617
676
  await cancelPairing(pairId);
618
- return pairFailed("decrypt");
677
+ return unlessSignalled(pairFailed("decrypt"));
619
678
  }
620
679
  await ackPairing(pairId);
680
+ if (cancelled) return heldUntilTheSignalExits();
621
681
  stop(check, "App connected");
622
682
  return { kind: "paired", apiKey, handle: claim.siteSlug };
623
683
  }
624
684
  if (claim?.status === "expired") {
625
- stop(yellow("!"), "Pairing expired. Re-run setup to try again.");
685
+ stop(yellow("!"), `Pairing expired. Re-run ${rerun} to try again.`);
626
686
  return pairFailed("expired");
627
687
  }
628
688
  if (claim?.status === "failed") {
629
- stop(yellow("!"), describePairFailure(claim.reason));
689
+ stop(yellow("!"), describePairFailure(claim.reason, options.command));
630
690
  return pairFailed("rejected");
631
691
  }
632
692
  await clock.sleep(PAIR_POLL_INTERVAL_MS);
633
693
  }
634
694
  stop(yellow("!"), "Timed out waiting for the app");
635
695
  await cancelPairing(pairId);
636
- return pairFailed("timeout");
696
+ return unlessSignalled(pairFailed("timeout"));
637
697
  } catch (err) {
638
- stop(yellow("!"), `Pairing error ${dim(`(${err instanceof Error ? err.message : "network"})`)}`);
698
+ finishWaitLine(yellow("!"), `Pairing error ${dim(`(${err instanceof Error ? err.message : "network"})`)}`);
639
699
  await cancelPairing(pairId);
640
- return pairFailed("unreachable");
700
+ return unlessSignalled(pairFailed("unreachable"));
641
701
  } finally {
642
702
  process.off("SIGINT", onInterrupt);
643
703
  process.off("SIGTERM", onTerminate);
@@ -717,15 +777,96 @@ var waitForYourPhone = async (apiKey, options = {}) => {
717
777
  for (const line of repair) console.log(` ${dim(line)}`);
718
778
  return phoneFailure("no_device", repair);
719
779
  };
780
+ var differentPeople = (pairedUserId, accountUserId) => pairedUserId !== null && accountUserId !== null && pairedUserId !== accountUserId;
781
+ var otherSiteKindOf = (pairedUserId, accountUserId) => {
782
+ if (pairedUserId === null || accountUserId === null) return "unknown";
783
+ return differentPeople(pairedUserId, accountUserId) ? "account" : "workspace";
784
+ };
785
+ var pairedAccountMismatch = (paired, account) => {
786
+ if (paired.siteSlug === null || account.siteSlug === null) return null;
787
+ const slugs = { pairedSiteSlug: paired.siteSlug, accountSiteSlug: account.siteSlug };
788
+ if (paired.siteSlug !== account.siteSlug) return { kind: otherSiteKindOf(paired.userId, account.userId), ...slugs };
789
+ return differentPeople(paired.userId, account.userId) ? { kind: "teammate", ...slugs } : null;
790
+ };
791
+ var describePairedAccountMismatch = (mismatch) => {
792
+ const move = `Or move this computer to @${mismatch.pairedSiteSlug}: ${NPX_LATEST_COMMAND} setup --connect app (this replaces its key)`;
793
+ switch (mismatch.kind) {
794
+ case "workspace":
795
+ return {
796
+ headline: `Your phone approved in your @${mismatch.pairedSiteSlug} workspace, but this computer is connected to your @${mismatch.accountSiteSlug} workspace.`,
797
+ repair: [`In the Pushary app, switch to the @${mismatch.accountSiteSlug} workspace.`, move]
798
+ };
799
+ case "account":
800
+ return {
801
+ headline: `Your phone is signed in to a different account (@${mismatch.pairedSiteSlug}). This computer is connected to @${mismatch.accountSiteSlug}.`,
802
+ repair: ["Sign in on the Pushary app with the account this computer uses.", move]
803
+ };
804
+ case "teammate":
805
+ return {
806
+ headline: `Your phone is signed in as another member of @${mismatch.accountSiteSlug}, not as the person this computer belongs to.`,
807
+ repair: ["Sign in on the Pushary app with your own account."]
808
+ };
809
+ case "unknown":
810
+ return {
811
+ headline: `Your phone approved for @${mismatch.pairedSiteSlug}, but this computer is connected to @${mismatch.accountSiteSlug}.`,
812
+ repair: [`In the Pushary app, switch to @${mismatch.accountSiteSlug}, or sign in with the account that has it.`, move]
813
+ };
814
+ }
815
+ };
816
+ var PAIR_COMMAND_RETRY_REPAIR = [`No app yet? Get it at ${PUSHARY_APP_DOWNLOAD_URL}.`];
817
+ var printRepair = (repair) => {
818
+ for (const line of repair) console.log(` ${dim(line)}`);
819
+ };
820
+ var pairingKeyAccount = async (pairingKey, claimed) => {
821
+ const verdict = await checkApiKey(pairingKey);
822
+ return verdict.kind === "ok" ? { siteSlug: verdict.identity.siteSlug, userId: verdict.identity.authorizedUserId } : claimed;
823
+ };
824
+ var discardPairingKey = async (pairingKey) => {
825
+ const attempt = await revokeOwnKey(pairingKey, apiBase());
826
+ if (keyNoLongerAccepted(attempt)) return;
827
+ console.log(` ${yellow("!")} ${describeRevokeAttempt(attempt)}`);
828
+ console.log(` ${dim('This computer keeps its own key. Revoke the extra "Paired agent (mobile)" key at')} ${cyan("pushary.com/dashboard/agent/settings")}${dim(".")}`);
829
+ };
830
+ var pairAppWithThisComputer = async (apiKey, options) => {
831
+ const probe = await fetchChannels(apiKey);
832
+ if (probe.kind !== "ok") return describeProbeFailure(probe);
833
+ if (planAppConnect(probe.status).kind === "send") {
834
+ console.log(` ${check} ${describeExistingConnection(probe.status)}`);
835
+ return sendAndConfirm(apiKey, probe.status);
836
+ }
837
+ const paired = await connectViaAppPairing({ computer: options.computer, command: "pair", onCancelled: options.onCancelled });
838
+ if (paired.kind === "failed") {
839
+ const repair = pairingEscapeApplies(paired) ? PAIR_COMMAND_RETRY_REPAIR : [];
840
+ printRepair(repair);
841
+ return phoneFailure(paired.reason, repair);
842
+ }
843
+ const claimed = { siteSlug: paired.handle ?? null, userId: null };
844
+ const pairedAccount = options.account.siteSlug === null ? claimed : await pairingKeyAccount(paired.apiKey, claimed);
845
+ await discardPairingKey(paired.apiKey);
846
+ const mismatch = pairedAccountMismatch(pairedAccount, options.account);
847
+ if (mismatch !== null) {
848
+ const report = describePairedAccountMismatch(mismatch);
849
+ console.log(` ${yellow("!")} ${report.headline}`);
850
+ printRepair(report.repair);
851
+ return phoneFailure("other_account", report.repair);
852
+ }
853
+ return confirmAppConnection(apiKey);
854
+ };
720
855
 
721
856
  export {
722
857
  fetchChannels,
858
+ canShowPairingQr,
723
859
  connectDevice,
724
860
  confirmAppConnection,
725
- connectExistingApp,
861
+ phoneAwaitsNotificationPermission,
862
+ pairingAgainHelps,
863
+ checkPhoneWithoutPairing,
726
864
  printConnectInstructions,
727
865
  describePairingEscape,
866
+ describePairCommandEscape,
867
+ describeCancelledPairing,
728
868
  pairingEscapeApplies,
729
869
  connectViaAppPairing,
730
- waitForYourPhone
870
+ waitForYourPhone,
871
+ pairAppWithThisComputer
731
872
  };
@@ -3,15 +3,15 @@ import {
3
3
  } from "./chunk-XMSDA5WA.js";
4
4
  import {
5
5
  fetchAsCredential
6
- } from "./chunk-S7HGPKCL.js";
6
+ } from "./chunk-UGPNLU4O.js";
7
7
  import {
8
8
  getBaseUrl
9
- } from "./chunk-BWREST4F.js";
9
+ } from "./chunk-3NMX4725.js";
10
10
  import {
11
11
  compressTranscriptRecord,
12
12
  redactSecretsFromContent,
13
13
  transcriptRecordPlaintext
14
- } from "./chunk-LQXUWXQP.js";
14
+ } from "./chunk-6JBX55K4.js";
15
15
 
16
16
  // src/transcript-api.ts
17
17
  var providerRecipientSchema = external_exports.object({
@@ -7,7 +7,7 @@ import {
7
7
  recordSealerFor,
8
8
  uploadTranscriptRecords,
9
9
  wrapSessionKey
10
- } from "./chunk-IRPIMQ7U.js";
10
+ } from "./chunk-526XSNMS.js";
11
11
 
12
12
  // src/live-session.ts
13
13
  var LIVE_TRANSCRIPT_LIMITS = { queuedRecords: 100, recordCharacters: 32 * 1024 };
@@ -7,10 +7,10 @@ import {
7
7
  codexHome,
8
8
  codexHooksJsonIn,
9
9
  isPusharyCodexCommand
10
- } from "./chunk-72LP4RPC.js";
10
+ } from "./chunk-GJV5RVUU.js";
11
11
  import {
12
12
  resolvePathBinary
13
- } from "./chunk-VTJ4WZOC.js";
13
+ } from "./chunk-BU2J4P7P.js";
14
14
  import {
15
15
  getPackageVersion
16
16
  } from "./chunk-WIIMW5YO.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  DEFAULT_SESSION
3
- } from "./chunk-K2SKUBYY.js";
3
+ } from "./chunk-Q6POCQOV.js";
4
4
 
5
5
  // src/answer.ts
6
6
  var isDeferAnswer = (value) => value === "defer";
@@ -1,22 +1,22 @@
1
1
  import {
2
2
  cursorGateOwnsClaudeCall,
3
3
  readCursorGateRegistration
4
- } from "./chunk-L4OGTRVW.js";
4
+ } from "./chunk-7WDEJTNX.js";
5
5
  import {
6
6
  registerTranscript
7
- } from "./chunk-S3A4PCRR.js";
7
+ } from "./chunk-A5MSVNFS.js";
8
8
  import {
9
9
  namedEvent
10
- } from "./chunk-R34RWVN2.js";
10
+ } from "./chunk-2I6A34GJ.js";
11
11
  import {
12
12
  writeDegraded
13
- } from "./chunk-YU5XE6VC.js";
13
+ } from "./chunk-FKGWP4MF.js";
14
14
  import {
15
15
  claudeShapedHookInput,
16
16
  hookCompatibleProfileBySource,
17
17
  isGrokHookPayload,
18
18
  isGrokSessionEndStop
19
- } from "./chunk-LQXUWXQP.js";
19
+ } from "./chunk-6JBX55K4.js";
20
20
 
21
21
  // src/tool-hook-input.ts
22
22
  var OPTIONAL_TEXT_FIELDS = ["hook_event_name", "session_id", "cwd", "transcript_path", "tool_use_id", "permission_mode", "cursor_version"];
@@ -1,19 +1,19 @@
1
1
  import {
2
2
  macAppBridgeAvailable
3
- } from "./chunk-GK5X2ZTN.js";
3
+ } from "./chunk-MI7GHNTO.js";
4
4
  import {
5
5
  keyPrefix
6
- } from "./chunk-WOSO4YFQ.js";
6
+ } from "./chunk-XQOBM3E6.js";
7
7
  import {
8
8
  bridgeAgentKey
9
- } from "./chunk-72LP4RPC.js";
9
+ } from "./chunk-GJV5RVUU.js";
10
10
  import {
11
11
  readJsonSafe
12
12
  } from "./chunk-TODDEIYG.js";
13
13
  import {
14
14
  isRecord,
15
15
  isValidApiKey
16
- } from "./chunk-LQXUWXQP.js";
16
+ } from "./chunk-6JBX55K4.js";
17
17
 
18
18
  // src/shared-mcp-key.ts
19
19
  var asRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;