pushary 1.9.235 → 1.9.237

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 (149) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/data/cursor-plugin/.cursor-plugin/plugin.json +1 -1
  3. package/data/cursor-plugin/CHANGELOG.md +4 -0
  4. package/data/cursor-plugin/scripts/redaction.mjs +2 -0
  5. package/data/openclaw-plugin/dist/redaction.js +2 -0
  6. package/data/vscode-plugin/.claude-plugin/plugin.json +1 -1
  7. package/data/vscode-plugin/CHANGELOG.md +4 -0
  8. package/data/vscode-plugin/scripts/redaction.mjs +2 -0
  9. package/dist/{api-UVFEVNJD.js → api-HJSGVYQY.js} +11 -11
  10. package/dist/bin/pushary-audit.js +3 -3
  11. package/dist/bin/pushary-bell-hook.js +28 -28
  12. package/dist/bin/pushary-bell.js +12 -12
  13. package/dist/bin/pushary-calls.js +15 -15
  14. package/dist/bin/pushary-claude.js +26 -26
  15. package/dist/bin/pushary-clean.js +39 -39
  16. package/dist/bin/pushary-codex-bridge.js +23 -23
  17. package/dist/bin/pushary-codex-hook.js +34 -34
  18. package/dist/bin/pushary-codex-session.js +8 -8
  19. package/dist/bin/pushary-codex.js +16 -16
  20. package/dist/bin/pushary-connect.js +35 -35
  21. package/dist/bin/pushary-cowork.js +5 -5
  22. package/dist/bin/pushary-daemon.js +46 -46
  23. package/dist/bin/pushary-disconnect.js +30 -30
  24. package/dist/bin/pushary-display-hook.js +16 -0
  25. package/dist/bin/pushary-doctor.js +47 -47
  26. package/dist/bin/pushary-elicitation-hook.js +27 -27
  27. package/dist/bin/pushary-gemini-bridge.js +18 -18
  28. package/dist/bin/pushary-gemini-hook.js +31 -31
  29. package/dist/bin/pushary-hook.js +35 -35
  30. package/dist/bin/pushary-login.js +23 -23
  31. package/dist/bin/pushary-logout.js +31 -31
  32. package/dist/bin/pushary-mcp.js +12 -12
  33. package/dist/bin/pushary-mode.js +16 -16
  34. package/dist/bin/pushary-notification-hook.js +27 -27
  35. package/dist/bin/pushary-opencode-bridge.js +22 -22
  36. package/dist/bin/pushary-opencode-hook.js +32 -32
  37. package/dist/bin/pushary-permission-denied-hook.js +34 -34
  38. package/dist/bin/pushary-permission-hook.js +35 -35
  39. package/dist/bin/pushary-post-hook.js +28 -28
  40. package/dist/bin/pushary-prompt-hook.js +27 -27
  41. package/dist/bin/pushary-session-end-hook.js +27 -27
  42. package/dist/bin/pushary-session-start-hook.js +39 -39
  43. package/dist/bin/pushary-sessions.js +12 -12
  44. package/dist/bin/pushary-setup.js +555 -70
  45. package/dist/bin/pushary-stats.js +5 -5
  46. package/dist/bin/pushary-status.js +36 -36
  47. package/dist/bin/pushary-stop-hook.js +27 -27
  48. package/dist/bin/pushary-stopfailure-hook.js +27 -27
  49. package/dist/bin/pushary-suggestions.js +16 -16
  50. package/dist/bin/pushary-transcript-register.js +17 -17
  51. package/dist/bin/pushary-transcripts.js +26 -26
  52. package/dist/bin/pushary-upgrade.js +47 -47
  53. package/dist/bin/pushary-wait.js +16 -16
  54. package/dist/bin/pushary.js +7 -7
  55. package/dist/{chunk-7MRK2WXT.js → chunk-3BNYU7LA.js} +2 -2
  56. package/dist/{chunk-4UIVOCDT.js → chunk-3XEOKKCT.js} +1 -1
  57. package/dist/{chunk-WY2UKKLD.js → chunk-47UJLOWC.js} +1 -1
  58. package/dist/{chunk-DW7ZQX7L.js → chunk-4QFQH4DE.js} +1 -1
  59. package/dist/{chunk-NDXTGRZG.js → chunk-56ZVNO4C.js} +1 -1
  60. package/dist/{chunk-HPFGXE6Y.js → chunk-5V2X63OJ.js} +6 -6
  61. package/dist/{chunk-XGW4PJPO.js → chunk-5Y5FFPNI.js} +2 -2
  62. package/dist/{chunk-3C2XMGXE.js → chunk-66KEOAAB.js} +3 -3
  63. package/dist/{chunk-BBZ3BBZC.js → chunk-6SSWRXJ3.js} +4 -4
  64. package/dist/{chunk-XYRXKL3V.js → chunk-74Z7L2LQ.js} +1 -1
  65. package/dist/{chunk-MHZSIN5K.js → chunk-77FFXRKW.js} +3 -3
  66. package/dist/{chunk-JF4VX754.js → chunk-7BRTSKYT.js} +1 -1
  67. package/dist/{chunk-FKX7SWNT.js → chunk-7RMOKXHS.js} +7 -7
  68. package/dist/{chunk-7B2DHU32.js → chunk-A636SGRV.js} +16 -16
  69. package/dist/{chunk-LDX3KQMJ.js → chunk-BQS4RV3T.js} +2 -2
  70. package/dist/{chunk-3B5FQ542.js → chunk-BUFXSMY6.js} +2 -2
  71. package/dist/{chunk-X4G5G2ZN.js → chunk-BWYM4X2Z.js} +2 -2
  72. package/dist/{chunk-HI3LOBT5.js → chunk-BZ2LBE2K.js} +116 -49
  73. package/dist/{chunk-A2GO3G2I.js → chunk-CKBAQUE3.js} +6 -6
  74. package/dist/{chunk-E6IFBGZF.js → chunk-CLDEQACG.js} +2 -2
  75. package/dist/{chunk-MQSO2S3H.js → chunk-CWZCWIQT.js} +1 -1
  76. package/dist/{chunk-H5TBR4BB.js → chunk-DF6TLBHZ.js} +5 -5
  77. package/dist/{chunk-2QUYUFYQ.js → chunk-DFHMD7G7.js} +4 -4
  78. package/dist/{chunk-V7ULGI7U.js → chunk-DHU22BBS.js} +4 -4
  79. package/dist/{chunk-TAXOI6AK.js → chunk-DJ67SBPF.js} +4 -4
  80. package/dist/{chunk-DN6HPGCI.js → chunk-DK4BKL43.js} +5 -5
  81. package/dist/{chunk-Z7LAWFZ7.js → chunk-DZJ4WO7T.js} +1 -1
  82. package/dist/{chunk-52PIW2SN.js → chunk-E7RUE3HG.js} +3 -3
  83. package/dist/{chunk-OSDIFFSP.js → chunk-EFYTCLOR.js} +3 -3
  84. package/dist/{chunk-ZPQPTIIY.js → chunk-FMU5CMVS.js} +2 -2
  85. package/dist/{chunk-JPKOYDQJ.js → chunk-GEEQ5JLH.js} +6 -6
  86. package/dist/{chunk-WMCF6PR5.js → chunk-GM4YH5PP.js} +3 -3
  87. package/dist/{chunk-5QLIXOVT.js → chunk-HBB2B6YX.js} +1 -1
  88. package/dist/{chunk-KTJHZVCD.js → chunk-HMIFIDPC.js} +3 -3
  89. package/dist/{chunk-JYFMVOML.js → chunk-HSLZ2ZJI.js} +1 -1
  90. package/dist/{chunk-3QQY5USW.js → chunk-HYE5ARRS.js} +4 -4
  91. package/dist/{chunk-FMWG4X3D.js → chunk-I3OCBCNT.js} +5 -5
  92. package/dist/{chunk-7XCL66ON.js → chunk-I4RKTMEX.js} +2 -2
  93. package/dist/{chunk-TWACA7ER.js → chunk-IBIKEGDF.js} +9 -9
  94. package/dist/{chunk-WVJFHP75.js → chunk-ITDN4EH5.js} +1 -1
  95. package/dist/{chunk-JM6EAV42.js → chunk-JN23XJFF.js} +5 -5
  96. package/dist/{chunk-5DRTR5FC.js → chunk-JOQ4H6NH.js} +5 -5
  97. package/dist/{chunk-EINN22XV.js → chunk-JVAMUEHS.js} +2 -2
  98. package/dist/{chunk-TGM2WHUG.js → chunk-JWRCNFPM.js} +2 -2
  99. package/dist/{chunk-FZN7TKSM.js → chunk-JX5R7WCL.js} +1 -1
  100. package/dist/{chunk-G5OTSL26.js → chunk-KJ2WZOHD.js} +3 -3
  101. package/dist/{chunk-ICLT2KA5.js → chunk-KJJTE4HC.js} +1 -1
  102. package/dist/{chunk-GPD4BB76.js → chunk-LVSQJNUN.js} +1 -1
  103. package/dist/{chunk-UIBQDALO.js → chunk-M6CLKAF6.js} +3 -3
  104. package/dist/{chunk-GSB62GNT.js → chunk-MODLPJPU.js} +4 -4
  105. package/dist/{chunk-4CEGJAEB.js → chunk-MSTQIKS4.js} +176 -23
  106. package/dist/{chunk-HJSW3MH2.js → chunk-N3IM3JEH.js} +2 -2
  107. package/dist/{chunk-6H3RBEHP.js → chunk-NBTUSWX2.js} +1 -1
  108. package/dist/{chunk-OV2XD2UY.js → chunk-OOPL7BL2.js} +1 -1
  109. package/dist/{chunk-VPG6QENY.js → chunk-ORCSR77N.js} +10 -10
  110. package/dist/{chunk-URDT623B.js → chunk-OTRVJVKS.js} +1 -1
  111. package/dist/{chunk-4QQ3HXGR.js → chunk-PJHG34QL.js} +3 -3
  112. package/dist/{chunk-FEVQDABQ.js → chunk-PMJKR7WR.js} +2 -2
  113. package/dist/{chunk-CSXA4HMV.js → chunk-PNLG2FXX.js} +2 -2
  114. package/dist/{chunk-JFXYGMV5.js → chunk-Q43WP2LP.js} +4 -4
  115. package/dist/{chunk-ELP65DFC.js → chunk-Q6F3FM5A.js} +1 -1
  116. package/dist/{chunk-K6PBTBLO.js → chunk-Q6KONQHQ.js} +4 -4
  117. package/dist/{chunk-FCQ52N4E.js → chunk-QIWVSIK2.js} +8 -8
  118. package/dist/{chunk-ULDUDSTW.js → chunk-QXIDU6YJ.js} +33 -0
  119. package/dist/{chunk-JF3ONE4H.js → chunk-RZANH42A.js} +2 -2
  120. package/dist/{chunk-3K2S4OW7.js → chunk-T5WMBVKG.js} +7 -6
  121. package/dist/{chunk-LIYQSMYK.js → chunk-TOAPYOT6.js} +4 -4
  122. package/dist/{chunk-HDD23XYP.js → chunk-U7HEUEZQ.js} +11 -11
  123. package/dist/{chunk-RV5LIW3K.js → chunk-UEZLE5S5.js} +12 -12
  124. package/dist/{chunk-BJRPBKE7.js → chunk-UN7PMXBY.js} +4 -4
  125. package/dist/{chunk-TMN7LKDC.js → chunk-US4WGPDI.js} +7 -7
  126. package/dist/{chunk-V4ZQBKI6.js → chunk-USOOH77B.js} +1 -1
  127. package/dist/{chunk-MN6DXDJR.js → chunk-UX62CHEU.js} +6 -6
  128. package/dist/{chunk-G5EKU4RB.js → chunk-V2P2NUCI.js} +3 -3
  129. package/dist/{chunk-AA54OZM2.js → chunk-VC4EBXGF.js} +5 -5
  130. package/dist/{chunk-H4364HR3.js → chunk-VJTMLOV4.js} +5 -5
  131. package/dist/{chunk-M64A2Z2F.js → chunk-VO4VXPCH.js} +1 -1
  132. package/dist/{chunk-Q5SVRCFU.js → chunk-XIMXQ4OB.js} +1 -1
  133. package/dist/{chunk-SFIYMKWT.js → chunk-XKWYE3ZY.js} +5 -5
  134. package/dist/{chunk-Z5EWWGD2.js → chunk-XWL2QPIG.js} +5 -5
  135. package/dist/{chunk-FUJZW3R5.js → chunk-Z5SJDN5J.js} +1 -1
  136. package/dist/{codex-app-cards-switch-DBFQJU3Y.js → codex-app-cards-switch-FY5HJYZR.js} +11 -11
  137. package/dist/{codex-card-routing-TKG7LOP4.js → codex-card-routing-3TVI3V2W.js} +2 -2
  138. package/dist/{codex-desktop-launch-UXMYKS5C.js → codex-desktop-launch-OOSA2UHI.js} +3 -3
  139. package/dist/{codex-session-launch-5NOJKDWN.js → codex-session-launch-6BNQDMCH.js} +20 -20
  140. package/dist/{config-HHUSXJZE.js → config-WOG7M4P2.js} +3 -3
  141. package/dist/{global-upgrade-J2NB62DV.js → global-upgrade-QGWLB3XX.js} +9 -9
  142. package/dist/{identity-7O3ZBVUY.js → identity-DSZ5C7LA.js} +4 -4
  143. package/dist/{live-capabilities-773SVQWH.js → live-capabilities-ARZLZCZC.js} +4 -4
  144. package/dist/{paths-VZXMX35O.js → paths-6QS77FBA.js} +3 -3
  145. package/dist/{reapply-7MIBK2WB.js → reapply-TXPOSMJF.js} +34 -34
  146. package/dist/src/index.js +33 -33
  147. package/dist/{upgrade-lock-WWTTPOIZ.js → upgrade-lock-6777RDS5.js} +4 -4
  148. package/dist/{usage-PHTLHFL2.js → usage-4EOFN3X4.js} +3 -3
  149. package/package.json +1 -1
@@ -1,11 +1,20 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  withUpgradeLock
4
- } from "../chunk-HPFGXE6Y.js";
5
- import "../chunk-E6IFBGZF.js";
4
+ } from "../chunk-5V2X63OJ.js";
5
+ import "../chunk-CLDEQACG.js";
6
6
  import {
7
- runBrowserLogin
8
- } from "../chunk-4CEGJAEB.js";
7
+ browserEntryUrl,
8
+ cancelLogin,
9
+ listenForThisTerminal,
10
+ localConfirmStateHash,
11
+ newLocalConfirmState,
12
+ pollOnce,
13
+ printLoginNotice,
14
+ runBrowserLogin,
15
+ startLogin,
16
+ waitForLogin
17
+ } from "../chunk-MSTQIKS4.js";
9
18
  import {
10
19
  INSTALL_NODE_STEP,
11
20
  NPM_FILE_IN_USE_STEP,
@@ -19,7 +28,7 @@ import {
19
28
  renderCommandSurface,
20
29
  teamOfferLines,
21
30
  unverifiedKeyClosingReason
22
- } from "../chunk-3K2S4OW7.js";
31
+ } from "../chunk-T5WMBVKG.js";
23
32
  import {
24
33
  WRONG_ACCOUNT_HINT,
25
34
  canAskAtTheTerminal,
@@ -42,29 +51,32 @@ import {
42
51
  someoneIsAtTheTerminal,
43
52
  switchBackToTheShellKeyLine,
44
53
  wrongAccountHintPlacement
45
- } from "../chunk-TAXOI6AK.js";
54
+ } from "../chunk-DJ67SBPF.js";
46
55
  import {
47
56
  instructionsChannelFor,
48
57
  pairingComputerOf,
49
58
  planPhoneCheck
50
- } from "../chunk-WY2UKKLD.js";
59
+ } from "../chunk-47UJLOWC.js";
51
60
  import {
52
61
  coworkOutput,
53
62
  coworkSelection
54
- } from "../chunk-3C2XMGXE.js";
55
- import "../chunk-PUZZELE6.js";
63
+ } from "../chunk-66KEOAAB.js";
64
+ import {
65
+ canOpenBrowser,
66
+ openInBrowser
67
+ } from "../chunk-PUZZELE6.js";
56
68
  import {
57
69
  readCodexHooksOnDisk
58
- } from "../chunk-TWACA7ER.js";
70
+ } from "../chunk-IBIKEGDF.js";
59
71
  import {
60
72
  macAppHistoryDecision,
61
73
  nativeBridgeAccount
62
74
  } from "../chunk-TWWOQKXK.js";
63
- import "../chunk-LDX3KQMJ.js";
75
+ import "../chunk-BQS4RV3T.js";
64
76
  import {
65
77
  clearDeclinedAgent,
66
78
  declinedAgentForSetupChoice
67
- } from "../chunk-EINN22XV.js";
79
+ } from "../chunk-JVAMUEHS.js";
68
80
  import {
69
81
  OPENCLAW_RESTART_NOTE,
70
82
  describeOpenClawInstallFailure,
@@ -72,7 +84,7 @@ import {
72
84
  gateHermesShell,
73
85
  readHermesShellGate,
74
86
  saveSetupFailure
75
- } from "../chunk-Z5EWWGD2.js";
87
+ } from "../chunk-XWL2QPIG.js";
76
88
  import {
77
89
  CODEX_NEEDS_A_NEWER_VERSION,
78
90
  CODEX_SETTINGS_STOP_A_HOOK,
@@ -88,28 +100,48 @@ import {
88
100
  describeHermesState,
89
101
  hermesGateShellCommand,
90
102
  needsCodexTrustStep
91
- } from "../chunk-3QQY5USW.js";
103
+ } from "../chunk-HYE5ARRS.js";
92
104
  import {
93
105
  describeWaitLadder
94
106
  } from "../chunk-CVWG2N3Y.js";
95
107
  import {
96
108
  writeJsonError,
97
109
  writeStdoutFully
98
- } from "../chunk-MQSO2S3H.js";
110
+ } from "../chunk-CWZCWIQT.js";
99
111
  import {
112
+ EXIT_ABORTED,
113
+ EXIT_TERMINATED,
114
+ PAIR_TIMEOUT_MS,
100
115
  PHONE_WAIT_SKIP_KEY,
116
+ PHONE_WAIT_SKIP_LINE,
117
+ SYSTEM_PAIR_CLOCK,
118
+ buildPairLinks,
101
119
  canShowPairingQr,
120
+ cancelPairing,
102
121
  confirmAppConnection,
103
122
  connectDevice,
104
123
  connectViaAppPairing,
105
124
  describeCancelledPairing,
125
+ describeCancelledSignIn,
126
+ describePairFailure,
106
127
  describePairingEscape,
128
+ describeSignInEscape,
129
+ heldUntilTheSignalExits,
130
+ keyLeftInPairing,
107
131
  pairingEscapeApplies,
108
132
  phoneAwaitsNotificationPermission,
133
+ phoneWaitWasSkipped,
134
+ pollAppPairing,
109
135
  printConnectInstructions,
110
- waitForYourPhone
111
- } from "../chunk-HI3LOBT5.js";
112
- import "../chunk-3EGEA4KH.js";
136
+ printQr,
137
+ startPairing,
138
+ waitForYourPhone,
139
+ writeStatusLine
140
+ } from "../chunk-BZ2LBE2K.js";
141
+ import {
142
+ generateKeypair,
143
+ publicKeyFingerprint
144
+ } from "../chunk-3EGEA4KH.js";
113
145
  import {
114
146
  SETUP_AGENT_NAME,
115
147
  describeAnswerTestPrompt,
@@ -117,7 +149,7 @@ import {
117
149
  roundTripEvidence,
118
150
  roundTripWasAnswered,
119
151
  verifyRoundTrip
120
- } from "../chunk-MN6DXDJR.js";
152
+ } from "../chunk-UX62CHEU.js";
121
153
  import {
122
154
  keepLinuxDaemonAfterLogout,
123
155
  lingerReportOf
@@ -125,13 +157,13 @@ import {
125
157
  import {
126
158
  readManagedControlEvidence,
127
159
  waitForMachineReadiness
128
- } from "../chunk-5DRTR5FC.js";
160
+ } from "../chunk-JOQ4H6NH.js";
129
161
  import {
130
162
  ensureCodexTrustsPusharyHooks,
131
163
  hermesHistoryHelperRecordPath,
132
164
  hermesHistoryNeedsTheCliHelper,
133
165
  recordInstalledHermesHistoryHelper
134
- } from "../chunk-KTJHZVCD.js";
166
+ } from "../chunk-HMIFIDPC.js";
135
167
  import {
136
168
  scheduleWithTimer
137
169
  } from "../chunk-AVFPHV4N.js";
@@ -142,7 +174,7 @@ import {
142
174
  } from "../chunk-UOPOVQ2P.js";
143
175
  import {
144
176
  codexEngineBehindLauncher
145
- } from "../chunk-LIYQSMYK.js";
177
+ } from "../chunk-TOAPYOT6.js";
146
178
  import "../chunk-XCEN33UP.js";
147
179
  import {
148
180
  CODEX_ENGINE_DIRECTORY,
@@ -159,7 +191,7 @@ import {
159
191
  soleGateLeftAloneFor,
160
192
  soleGateReceipt,
161
193
  soleGateReceiptFile
162
- } from "../chunk-BJRPBKE7.js";
194
+ } from "../chunk-UN7PMXBY.js";
163
195
  import {
164
196
  describeDetection,
165
197
  detectAllAgents,
@@ -169,12 +201,14 @@ import {
169
201
  registerPluginLocation,
170
202
  shortenHome,
171
203
  vscodeSettingsTargets
172
- } from "../chunk-JM6EAV42.js";
173
- import "../chunk-OYIN77HO.js";
204
+ } from "../chunk-JN23XJFF.js";
205
+ import {
206
+ revokeOwnKey
207
+ } from "../chunk-OYIN77HO.js";
174
208
  import {
175
209
  mcpServerBearer,
176
210
  readMacAppAgentKey
177
- } from "../chunk-BBZ3BBZC.js";
211
+ } from "../chunk-6SSWRXJ3.js";
178
212
  import {
179
213
  HERMES_CONFIG_FILE,
180
214
  HERMES_GATE_TOOLS_KEY,
@@ -193,7 +227,7 @@ import {
193
227
  routesHermesQuestions,
194
228
  runsAnOlderPlugin,
195
229
  shippedHermesPlugin
196
- } from "../chunk-2QUYUFYQ.js";
230
+ } from "../chunk-DFHMD7G7.js";
197
231
  import {
198
232
  setHumanStream
199
233
  } from "../chunk-QCGNGEGE.js";
@@ -201,7 +235,7 @@ import {
201
235
  findOpenClawLauncher,
202
236
  isOpenClawWired,
203
237
  openClawPathsNow
204
- } from "../chunk-4QQ3HXGR.js";
238
+ } from "../chunk-PJHG34QL.js";
205
239
  import {
206
240
  FX_PICKS_UP_CONFIGURATION,
207
241
  FX_PUSHARY_TOOLS_RULE,
@@ -218,7 +252,7 @@ import {
218
252
  readFxProfileForSetup,
219
253
  withFxPusharyServer,
220
254
  writeFxProfile
221
- } from "../chunk-SFIYMKWT.js";
255
+ } from "../chunk-XKWYE3ZY.js";
222
256
  import {
223
257
  AgentConfigError,
224
258
  afterAgentFailureNote,
@@ -231,10 +265,10 @@ import {
231
265
  retryAgentCommand,
232
266
  writeSetupConfigFile,
233
267
  writeSetupConfigJson
234
- } from "../chunk-MHZSIN5K.js";
268
+ } from "../chunk-77FFXRKW.js";
235
269
  import {
236
270
  MCP_BRIDGE_BINARY
237
- } from "../chunk-GSB62GNT.js";
271
+ } from "../chunk-MODLPJPU.js";
238
272
  import {
239
273
  OPENCODE_HOOK_BINARY,
240
274
  addOpenCodeMcpServer,
@@ -253,12 +287,12 @@ import {
253
287
  openCodePluginFile,
254
288
  openCodeWired,
255
289
  withOpenCodeAskRules
256
- } from "../chunk-FKX7SWNT.js";
257
- import "../chunk-GPD4BB76.js";
258
- import "../chunk-JYFMVOML.js";
290
+ } from "../chunk-7RMOKXHS.js";
291
+ import "../chunk-LVSQJNUN.js";
292
+ import "../chunk-HSLZ2ZJI.js";
259
293
  import {
260
294
  keyScopeOf
261
- } from "../chunk-ZPQPTIIY.js";
295
+ } from "../chunk-FMU5CMVS.js";
262
296
  import {
263
297
  ansiPainter,
264
298
  ciMarker,
@@ -267,7 +301,7 @@ import {
267
301
  describeError,
268
302
  isCI,
269
303
  useColor
270
- } from "../chunk-FZN7TKSM.js";
304
+ } from "../chunk-JX5R7WCL.js";
271
305
  import {
272
306
  checkCodexInstall,
273
307
  describeMissingControlPrerequisite,
@@ -280,16 +314,16 @@ import {
280
314
  nodeCodexInstallProbe,
281
315
  phoneStartIsRequired,
282
316
  resolveControlPolicy
283
- } from "../chunk-G5EKU4RB.js";
317
+ } from "../chunk-V2P2NUCI.js";
284
318
  import {
285
319
  detectClaudeVersion
286
- } from "../chunk-Q5SVRCFU.js";
320
+ } from "../chunk-XIMXQ4OB.js";
287
321
  import "../chunk-TCE3J44Z.js";
288
322
  import {
289
323
  describeAutoUpdateAnnouncement,
290
324
  takeAutoUpdateAnnouncement
291
- } from "../chunk-JF3ONE4H.js";
292
- import "../chunk-UIBQDALO.js";
325
+ } from "../chunk-RZANH42A.js";
326
+ import "../chunk-M6CLKAF6.js";
293
327
  import "../chunk-WHB622LP.js";
294
328
  import {
295
329
  addCompatibleHooks,
@@ -304,7 +338,7 @@ import {
304
338
  compatibleRecord,
305
339
  compatibleTargetPaths,
306
340
  hasCompatibleHooks
307
- } from "../chunk-FMWG4X3D.js";
341
+ } from "../chunk-I3OCBCNT.js";
308
342
  import {
309
343
  DAEMON_COLD_START_TIMEOUT_MS,
310
344
  clearDaemonNeedsLogin,
@@ -323,7 +357,7 @@ import {
323
357
  stopDaemonService,
324
358
  versionManagerOf,
325
359
  waitForDaemonRemoteProof
326
- } from "../chunk-JPKOYDQJ.js";
360
+ } from "../chunk-GEEQ5JLH.js";
327
361
  import {
328
362
  GEMINI_HOOK_BINARY,
329
363
  GEMINI_HOOK_EVENTS,
@@ -339,38 +373,38 @@ import {
339
373
  geminiWired,
340
374
  planHooks,
341
375
  pusharyHookExecutable
342
- } from "../chunk-K6PBTBLO.js";
376
+ } from "../chunk-Q6KONQHQ.js";
343
377
  import {
344
378
  reportEvent
345
- } from "../chunk-HDD23XYP.js";
346
- import "../chunk-WVJFHP75.js";
379
+ } from "../chunk-U7HEUEZQ.js";
380
+ import "../chunk-ITDN4EH5.js";
347
381
  import {
348
382
  AGENT_CHOICES,
349
383
  effectiveAgentSelection,
350
384
  effectiveControlMode,
351
385
  effectiveVerify,
352
386
  parseSetupOptions
353
- } from "../chunk-Z7LAWFZ7.js";
354
- import "../chunk-5QLIXOVT.js";
387
+ } from "../chunk-DZJ4WO7T.js";
388
+ import "../chunk-HBB2B6YX.js";
355
389
  import "../chunk-BZIBNSQE.js";
356
390
  import {
357
391
  transcriptPreferenceForSetup
358
- } from "../chunk-XYRXKL3V.js";
392
+ } from "../chunk-74Z7L2LQ.js";
359
393
  import "../chunk-P6DUWKAO.js";
360
394
  import "../chunk-3PSNUHC5.js";
361
- import "../chunk-A2GO3G2I.js";
362
- import "../chunk-M64A2Z2F.js";
395
+ import "../chunk-CKBAQUE3.js";
396
+ import "../chunk-VO4VXPCH.js";
363
397
  import "../chunk-POFBE6ZY.js";
364
- import "../chunk-H4364HR3.js";
365
- import "../chunk-NDXTGRZG.js";
366
- import "../chunk-4UIVOCDT.js";
398
+ import "../chunk-VJTMLOV4.js";
399
+ import "../chunk-56ZVNO4C.js";
400
+ import "../chunk-3XEOKKCT.js";
367
401
  import {
368
402
  checkApiKey,
369
403
  describeKeyCheck,
370
404
  samePusharyAccount
371
- } from "../chunk-G5OTSL26.js";
372
- import "../chunk-OSDIFFSP.js";
373
- import "../chunk-OV2XD2UY.js";
405
+ } from "../chunk-KJ2WZOHD.js";
406
+ import "../chunk-EFYTCLOR.js";
407
+ import "../chunk-OOPL7BL2.js";
374
408
  import {
375
409
  KEY_FILE_MODE,
376
410
  installClaudeAlias,
@@ -385,8 +419,10 @@ import {
385
419
  resolveShellRc,
386
420
  shellKeyWasReplaced,
387
421
  writeKey
388
- } from "../chunk-WMCF6PR5.js";
389
- import "../chunk-X4G5G2ZN.js";
422
+ } from "../chunk-GM4YH5PP.js";
423
+ import {
424
+ reportedInstallSource
425
+ } from "../chunk-BWYM4X2Z.js";
390
426
  import {
391
427
  CLAUDE_CODE_PUSHARY_PERMISSION_RULES,
392
428
  CLINE_AUTO_APPROVE_STEP,
@@ -448,7 +484,7 @@ import {
448
484
  vscodePluginDir,
449
485
  vscodePluginMcp,
450
486
  writeInstructionBlock
451
- } from "../chunk-FEVQDABQ.js";
487
+ } from "../chunk-PMJKR7WR.js";
452
488
  import {
453
489
  compareVersion,
454
490
  parseVersion
@@ -470,11 +506,11 @@ import {
470
506
  runNpmInTerminal,
471
507
  setupNeedsGlobalInstall,
472
508
  setupWouldDowngrade
473
- } from "../chunk-JFXYGMV5.js";
509
+ } from "../chunk-Q43WP2LP.js";
474
510
  import {
475
511
  getBaseUrl,
476
512
  readApiKey
477
- } from "../chunk-XGW4PJPO.js";
513
+ } from "../chunk-5Y5FFPNI.js";
478
514
  import {
479
515
  UsageError
480
516
  } from "../chunk-CINBAX5G.js";
@@ -486,7 +522,7 @@ import {
486
522
  NPX_LATEST_COMMAND,
487
523
  isInvocationOf,
488
524
  renderCommandHelp
489
- } from "../chunk-7MRK2WXT.js";
525
+ } from "../chunk-3BNYU7LA.js";
490
526
  import {
491
527
  EXIT
492
528
  } from "../chunk-BG4HHB7E.js";
@@ -500,22 +536,24 @@ import {
500
536
  import {
501
537
  CURSOR_GATE_SCRIPT,
502
538
  HOOK_COMPATIBLE_PROFILES,
539
+ PHONE_SIGN_IN_CLIENT_HEADER,
503
540
  PRETOOLUSE_GATED_TOOLS,
504
541
  SETUP_STOPPED_PATH,
505
542
  SUPPORT_EMAIL,
543
+ TERMINAL_PHONE_SIGN_IN_CLIENT,
506
544
  computerOsOfPlatform,
507
545
  hookCompatibleProfile,
508
546
  isApprovalMode,
509
547
  isRecord,
510
548
  isTimeoutAction,
511
549
  isValidApiKey
512
- } from "../chunk-ULDUDSTW.js";
550
+ } from "../chunk-QXIDU6YJ.js";
513
551
  import "../chunk-MLKGABMK.js";
514
552
 
515
553
  // bin/pushary-setup.ts
516
554
  import { existsSync as existsSync2, readFileSync, writeFileSync, mkdirSync, cpSync, rmSync, renameSync, realpathSync, statSync, openSync, readSync, closeSync } from "fs";
517
555
  import { join as join5, dirname as dirname3, basename } from "path";
518
- import { homedir, hostname } from "os";
556
+ import { homedir, hostname as hostname2 } from "os";
519
557
  import { execSync } from "child_process";
520
558
  import { input, confirm } from "@inquirer/prompts";
521
559
  import { fileURLToPath } from "url";
@@ -697,6 +735,49 @@ var singleKeyListener = (key, input2 = process.stdin, interrupt = interruptThisP
697
735
  };
698
736
  };
699
737
  };
738
+ var ENTER = "\r";
739
+ var ENTER_VARIANTS = /* @__PURE__ */ new Set(["\n", "\r\n"]);
740
+ var keyPressedAlone = (typed) => ENTER_VARIANTS.has(typed) ? ENTER : typed;
741
+ var keyRouter = (input2 = process.stdin, interrupt = interruptThisProcess) => {
742
+ if (input2.isTTY !== true) return null;
743
+ const handlers = /* @__PURE__ */ new Map();
744
+ const wasRaw = input2.isRaw === true;
745
+ let listening = false;
746
+ const onData = (chunk) => {
747
+ const typed = chunk.toString().toLowerCase();
748
+ if (typed.includes(CONTROL_C)) return interrupt();
749
+ handlers.get(keyPressedAlone(typed))?.();
750
+ };
751
+ const startListening = () => {
752
+ if (listening) return;
753
+ listening = true;
754
+ input2.setRawMode(true);
755
+ input2.on("data", onData);
756
+ input2.resume();
757
+ };
758
+ const stopListening = () => {
759
+ if (!listening) return;
760
+ listening = false;
761
+ input2.off("data", onData);
762
+ input2.setRawMode(wasRaw);
763
+ input2.pause();
764
+ };
765
+ return {
766
+ listenerFor: (key) => (onKey) => {
767
+ const wanted = key.toLowerCase();
768
+ handlers.set(wanted, onKey);
769
+ startListening();
770
+ return () => {
771
+ if (handlers.get(wanted) === onKey) handlers.delete(wanted);
772
+ if (handlers.size === 0) stopListening();
773
+ };
774
+ },
775
+ close: () => {
776
+ handlers.clear();
777
+ stopListening();
778
+ }
779
+ };
780
+ };
700
781
 
701
782
  // src/setup/restart-steps.ts
702
783
  var AND_LIST = new Intl.ListFormat("en", { style: "long", type: "conjunction" });
@@ -895,6 +976,355 @@ var parseCodexEngineManifestVersion = (contents) => {
895
976
  };
896
977
  var parseEmbeddedCodexVersion = (haystack) => haystack.match(/cli_version(\d+\.\d+\.\d+)/)?.[1] ?? null;
897
978
 
979
+ // src/setup/sign-in.ts
980
+ import { hostname } from "os";
981
+ var SIGN_IN_ENTER_KEY = "\r";
982
+ var SIGN_IN_TIMEOUT_MINUTES = Math.ceil(PAIR_TIMEOUT_MS / 6e4);
983
+ var SIGN_IN_CANCELLED_LINE = "Cancelled. Nothing was written.";
984
+ var SIGN_IN_STOPPED_LINE = "Stopped before you signed in. The sign-in code was cancelled.";
985
+ var SIGN_IN_KEEPS_RUNNING_LINE = `This keeps running until you sign in, for up to ${SIGN_IN_TIMEOUT_MINUTES} minutes. Keep it running.`;
986
+ var PHONE_DENIED_REASON = "denied";
987
+ var appWaitGaveUp = (poll) => poll.kind === "timeout" || poll.kind === "unreachable" || poll.kind === "decrypt";
988
+ var describeStartFailure = (started) => {
989
+ if (started.kind === "rate-limited") return `too many attempts, retry in ${started.retryAfterSeconds}s`;
990
+ if (started.kind === "unavailable") return started.detail;
991
+ return "pairing could not start";
992
+ };
993
+ var fingerprintLine = (ui, fingerprint, browser, app) => {
994
+ const where = browser && app ? "The page and the app show" : browser ? "The page shows" : "The app shows";
995
+ return ` ${ui.dim(`${where} ${fingerprint}. Check it matches.`)}`;
996
+ };
997
+ var revokeKeyThatArrivedLate = async (apiKey) => {
998
+ await revokeOwnKey(apiKey, getBaseUrl()).catch(() => {
999
+ });
1000
+ };
1001
+ var lateKeyOf = (finished) => {
1002
+ if (finished === null) return null;
1003
+ if (finished.via === "browser") return finished.report.state.kind === "authorized" ? finished.report.state.apiKey : null;
1004
+ return finished.poll.kind === "paired" ? finished.poll.apiKey : null;
1005
+ };
1006
+ var signedIn = (outcome) => outcome.kind === "browser" || outcome.kind === "app";
1007
+ var settledLoser = (loser) => loser ?? Promise.resolve(null);
1008
+ var releaseLoginLeftOver = async (login, loser, deps) => {
1009
+ const lateKey = lateKeyOf(await settledLoser(loser));
1010
+ if (lateKey !== null) return revokeKeyThatArrivedLate(lateKey);
1011
+ await cancelLogin(login, deps);
1012
+ const left = await pollOnce(login, deps);
1013
+ if (left.kind === "authorized") await revokeKeyThatArrivedLate(left.apiKey);
1014
+ };
1015
+ var releasePairingLeftOver = async (pairing, keypair, loser) => {
1016
+ const lateKey = lateKeyOf(await settledLoser(loser)) ?? await keyLeftInPairing(pairing.pairId, keypair);
1017
+ if (lateKey !== null) await revokeKeyThatArrivedLate(lateKey);
1018
+ await cancelPairing(pairing.pairId);
1019
+ };
1020
+ var printSignInScreen = async (screen) => {
1021
+ const { ui, login, pairing } = screen;
1022
+ ui.say("");
1023
+ ui.say(` ${ui.bold("Sign in to Pushary")}`);
1024
+ ui.say("");
1025
+ if (login !== null) {
1026
+ if (screen.offersEnter) ui.say(" Press Enter to sign in with your browser.");
1027
+ ui.say(` ${screen.offersEnter ? "Or go to" : "Go to"} ${ui.cyan(login.verificationUrl)} on any device and enter ${ui.bold(login.userCode)}`);
1028
+ }
1029
+ if (pairing !== null) {
1030
+ const links = buildPairLinks(pairing.pairId, screen.keypair.publicKeyB64, void 0, pairing.code);
1031
+ ui.say("");
1032
+ ui.say(login === null ? " Scan this with your phone's camera or the Pushary app." : " Have the Pushary app? Scan this with your phone instead.");
1033
+ await printQr(links.qrLink);
1034
+ ui.say(` ${ui.dim("Or open on your phone:")} ${ui.cyan(links.universalLink)}`);
1035
+ }
1036
+ ui.say(fingerprintLine(ui, publicKeyFingerprint(screen.keypair.publicKeyB64), login !== null, pairing !== null));
1037
+ ui.say("");
1038
+ ui.say(` ${ui.dim(screen.offersEnter ? "Waiting for you to sign in. Ctrl-C to stop." : SIGN_IN_KEEPS_RUNNING_LINE)}`);
1039
+ };
1040
+ var signInForSetup = async (ui, options, deps = {}) => {
1041
+ const keypair = generateKeypair();
1042
+ const clock = deps.clock ?? SYSTEM_PAIR_CLOCK;
1043
+ const requestedAt = clock.now();
1044
+ const showQr = deps.showQr ?? canShowPairingQr();
1045
+ const loginDeps = deps.login ?? {};
1046
+ const browserCanOpen = deps.browserAvailable ?? canOpenBrowser();
1047
+ const enterKey = browserCanOpen ? deps.enter === void 0 ? singleKeyListener(SIGN_IN_ENTER_KEY) : deps.enter : null;
1048
+ const localState = newLocalConfirmState();
1049
+ const [started, pairing] = await Promise.all([
1050
+ startLogin(hostname(), options.cliVersion, loginDeps, {
1051
+ command: "setup",
1052
+ keypair,
1053
+ ...enterKey === null ? {} : { localConfirmStateHash: localConfirmStateHash(localState) }
1054
+ }),
1055
+ showQr ? startPairing(keypair.publicKeyB64, options.computer) : Promise.resolve(null)
1056
+ ]);
1057
+ const login = started.kind === "ok" ? started.start : null;
1058
+ if (login === null && pairing === null) return { kind: "unavailable", detail: describeStartFailure(started) };
1059
+ const browserAvailable = login !== null && browserCanOpen;
1060
+ const enter = login === null ? null : enterKey;
1061
+ const listener = login !== null && enter !== null ? await listenForThisTerminal(login, localState, loginDeps) : null;
1062
+ const openBrowser = deps.openBrowser ?? openInBrowser;
1063
+ const controller = new AbortController();
1064
+ const bothWaysStopped = new Promise((resolve) => controller.signal.addEventListener("abort", () => resolve(), { once: true }));
1065
+ const appClock = { now: clock.now, sleep: (ms) => Promise.race([clock.sleep(ms), bothWaysStopped]) };
1066
+ let appStopped = false;
1067
+ let interruptedWith = null;
1068
+ let releaseEnter = () => {
1069
+ };
1070
+ let enterReleased = false;
1071
+ const stopEnter = () => {
1072
+ if (enterReleased) return;
1073
+ enterReleased = true;
1074
+ releaseEnter();
1075
+ };
1076
+ const stopBothWays = () => {
1077
+ controller.abort();
1078
+ appStopped = true;
1079
+ stopEnter();
1080
+ listener?.close();
1081
+ };
1082
+ const cancelBothWays = () => Promise.allSettled([
1083
+ login === null ? null : cancelLogin(login, loginDeps),
1084
+ pairing === null ? null : cancelPairing(pairing.pairId)
1085
+ ]);
1086
+ const cancelOnSignal = (exitCode) => () => {
1087
+ if (interruptedWith !== null) return;
1088
+ interruptedWith = exitCode;
1089
+ stopBothWays();
1090
+ ui.say("");
1091
+ ui.say(` ${ui.yellow("!")} ${exitCode === EXIT_TERMINATED ? SIGN_IN_STOPPED_LINE : SIGN_IN_CANCELLED_LINE}`);
1092
+ const flushed = options.onCancelled(exitCode);
1093
+ void Promise.allSettled([Promise.resolve(flushed), cancelBothWays()]).finally(() => process.exit(exitCode));
1094
+ };
1095
+ const onInterrupt = cancelOnSignal(EXIT_ABORTED);
1096
+ const onTerminate = cancelOnSignal(EXIT_TERMINATED);
1097
+ process.once("SIGINT", onInterrupt);
1098
+ process.once("SIGTERM", onTerminate);
1099
+ try {
1100
+ await printSignInScreen({ ui, login, pairing, keypair, offersEnter: enter !== null });
1101
+ if (interruptedWith !== null) return heldUntilTheSignalExits();
1102
+ const openTheBrowser = () => {
1103
+ if (login === null) return;
1104
+ if (openBrowser(browserEntryUrl(login, listener))) ui.say(` ${ui.dim("Opened your browser.")}`);
1105
+ else ui.say(` ${ui.yellow("!")} Couldn't open a browser. Go to ${ui.cyan(login.verificationUrl)} and enter ${ui.bold(login.userCode)}`);
1106
+ };
1107
+ if (enter !== null && !enterReleased) releaseEnter = enter(openTheBrowser);
1108
+ const pending = /* @__PURE__ */ new Map();
1109
+ if (login !== null) {
1110
+ const notice = (state) => printLoginNotice(ui, state, browserAvailable);
1111
+ pending.set("browser", waitForLogin(login, { signal: controller.signal, onNotice: notice }, loginDeps).then((report) => ({ via: "browser", report })));
1112
+ }
1113
+ if (pairing !== null) {
1114
+ const deadline = requestedAt + PAIR_TIMEOUT_MS;
1115
+ pending.set("app", pollAppPairing({ pairId: pairing.pairId, keypair, deadline, clock: appClock, stopped: () => appStopped }).then((poll) => ({ via: "app", poll })));
1116
+ }
1117
+ const finishWith = async (outcome) => {
1118
+ stopBothWays();
1119
+ const released = Promise.allSettled([
1120
+ login !== null && outcome.kind !== "browser" ? releaseLoginLeftOver(login, pending.get("browser"), loginDeps) : null,
1121
+ pairing !== null && outcome.kind !== "app" ? releasePairingLeftOver(pairing, keypair, pending.get("app")) : null
1122
+ ]);
1123
+ if (!signedIn(outcome)) await released;
1124
+ if (interruptedWith !== null) return heldUntilTheSignalExits();
1125
+ return outcome;
1126
+ };
1127
+ while (pending.size > 0) {
1128
+ const finished = await Promise.race(pending.values());
1129
+ if (interruptedWith !== null) return heldUntilTheSignalExits();
1130
+ pending.delete(finished.via);
1131
+ if (finished.via === "browser") {
1132
+ const state = finished.report.state;
1133
+ if (state.kind === "authorized") return await finishWith({ kind: "browser", apiKey: state.apiKey, siteSlug: state.siteSlug, phonePass: state.phonePass });
1134
+ if (state.kind === "rejected") return await finishWith({ kind: "rejected" });
1135
+ continue;
1136
+ }
1137
+ const poll = finished.poll;
1138
+ if (poll.kind === "paired") return await finishWith({ kind: "app", apiKey: poll.apiKey, handle: poll.handle ?? null });
1139
+ if (poll.kind === "failed" && (poll.reason === PHONE_DENIED_REASON || !pending.has("browser"))) {
1140
+ return await finishWith({ kind: "app_stopped", detail: describePairFailure(poll.reason, "setup") });
1141
+ }
1142
+ if (poll.kind === "failed" && pending.has("browser")) {
1143
+ ui.say(` ${ui.yellow("!")} ${describePairFailure(poll.reason, "setup")}`);
1144
+ ui.say(` ${ui.dim("You can still sign in with your browser.")}`);
1145
+ }
1146
+ if (pairing !== null && appWaitGaveUp(poll)) void cancelPairing(pairing.pairId);
1147
+ }
1148
+ return await finishWith({ kind: "expired" });
1149
+ } finally {
1150
+ stopEnter();
1151
+ listener?.close();
1152
+ process.off("SIGINT", onInterrupt);
1153
+ process.off("SIGTERM", onTerminate);
1154
+ }
1155
+ };
1156
+
1157
+ // src/setup/phone-sign-in.ts
1158
+ var START_PATH = "/api/phone-sign-in/start";
1159
+ var REQUEST_PATH = "/api/phone-sign-in/request";
1160
+ var DECIDE_PATH = "/api/phone-sign-in/decide";
1161
+ var CANCEL_PATH = "/api/phone-sign-in/cancel";
1162
+ var PHONE_SIGN_IN_LINK_PATH = "/app/phone-sign-in";
1163
+ var REQUEST_TIMEOUT_MS = 1e4;
1164
+ var PHONE_SIGN_IN_POLL_MS = 2e3;
1165
+ var PHONE_SIGN_IN_ID = /^[0-9a-f]{32}$/;
1166
+ var PHONE_CODE = /^\d{6}$/;
1167
+ var PHONE_ALLOW_KEY = "\r";
1168
+ var PHONE_DENY_KEY = "n";
1169
+ var PHONE_SIGN_IN_SCAN_LINE = "Scan this with your phone's camera to sign the Pushary app in to this account.";
1170
+ var PHONE_SIGN_IN_ENDED_LINE = "The QR stopped working. Sign in to the Pushary app with the same account instead.";
1171
+ var ALLOWED_STATES = /* @__PURE__ */ new Set(["approved", "issuing", "issued", "completed"]);
1172
+ var STILL_WAITING_STATES = /* @__PURE__ */ new Set(["waiting", "claimed", "unavailable"]);
1173
+ var isRecord2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
1174
+ var terminalHeaders = (pass) => ({
1175
+ "Content-Type": "application/json",
1176
+ [PHONE_SIGN_IN_CLIENT_HEADER]: TERMINAL_PHONE_SIGN_IN_CLIENT,
1177
+ Authorization: `Bearer ${pass}`
1178
+ });
1179
+ var spacedCode = (code) => `${code.slice(0, 3)} ${code.slice(3)}`;
1180
+ var startTerminalPhoneSignIn = async (pass, computer, installSource, deps = {}) => {
1181
+ const fetchImpl = deps.fetchImpl ?? fetch;
1182
+ const baseUrl = deps.baseUrl ?? getBaseUrl();
1183
+ try {
1184
+ const response = await fetchImpl(`${baseUrl}${START_PATH}`, {
1185
+ method: "POST",
1186
+ headers: terminalHeaders(pass),
1187
+ body: JSON.stringify({
1188
+ cliPublicKey: generateKeypair().publicKeyB64,
1189
+ ...computer.computerName === null ? {} : { computerName: computer.computerName },
1190
+ ...computer.os === null ? {} : { os: computer.os },
1191
+ ...computer.agents === null ? {} : { agents: computer.agents },
1192
+ installSource
1193
+ }),
1194
+ signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
1195
+ });
1196
+ if (!response.ok) return null;
1197
+ const body = await response.json();
1198
+ const id = isRecord2(body) ? body.phoneSignInId : null;
1199
+ if (typeof id !== "string" || !PHONE_SIGN_IN_ID.test(id)) return null;
1200
+ return { id, pass, baseUrl, link: `${baseUrl}${PHONE_SIGN_IN_LINK_PATH}?id=${id}` };
1201
+ } catch {
1202
+ return null;
1203
+ }
1204
+ };
1205
+ var phoneSignInStateOf = (body) => {
1206
+ if (!isRecord2(body) || typeof body.status !== "string") return { kind: "waiting" };
1207
+ if (body.status === "claimed" && typeof body.code === "string" && PHONE_CODE.test(body.code)) return { kind: "asking", code: body.code };
1208
+ if (ALLOWED_STATES.has(body.status)) return { kind: "allowed" };
1209
+ if (STILL_WAITING_STATES.has(body.status)) return { kind: "waiting" };
1210
+ return { kind: "ended" };
1211
+ };
1212
+ var readTerminalPhoneSignIn = async (signIn, deps = {}) => {
1213
+ const fetchImpl = deps.fetchImpl ?? fetch;
1214
+ try {
1215
+ const response = await fetchImpl(`${signIn.baseUrl}${REQUEST_PATH}?id=${signIn.id}`, {
1216
+ headers: terminalHeaders(signIn.pass),
1217
+ signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
1218
+ });
1219
+ if (response.status === 401) return { kind: "ended" };
1220
+ return response.ok ? phoneSignInStateOf(await response.json()) : { kind: "waiting" };
1221
+ } catch {
1222
+ return { kind: "waiting" };
1223
+ }
1224
+ };
1225
+ var postAsTheTerminal = async (signIn, path, body, deps) => {
1226
+ const fetchImpl = deps.fetchImpl ?? fetch;
1227
+ try {
1228
+ const response = await fetchImpl(`${signIn.baseUrl}${path}`, {
1229
+ method: "POST",
1230
+ headers: terminalHeaders(signIn.pass),
1231
+ body: JSON.stringify(body),
1232
+ signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
1233
+ });
1234
+ return response.ok;
1235
+ } catch {
1236
+ return false;
1237
+ }
1238
+ };
1239
+ var cancelTerminalPhoneSignIn = (signIn, deps = {}) => postAsTheTerminal(signIn, CANCEL_PATH, { id: signIn.id }, deps);
1240
+ var allowOrDeny = (allow, deny, stopped) => new Promise((resolve) => {
1241
+ const releases = [];
1242
+ const settle = (choice) => {
1243
+ for (const release of releases) release();
1244
+ resolve(choice);
1245
+ };
1246
+ releases.push(allow(() => settle("allow")), deny(() => settle("deny")));
1247
+ void stopped.then(() => settle("stopped"));
1248
+ });
1249
+ var approveThePhoneWhenItAsks = async (signIn, ui, options, deps = {}) => {
1250
+ const clock = deps.clock ?? SYSTEM_PAIR_CLOCK;
1251
+ while (!options.stopped()) {
1252
+ const state = await readTerminalPhoneSignIn(signIn, deps);
1253
+ if (options.stopped()) return "stopped";
1254
+ if (state.kind === "allowed") return "allowed";
1255
+ if (state.kind === "ended") {
1256
+ writeStatusLine(ui.dim(PHONE_SIGN_IN_ENDED_LINE));
1257
+ return "ended";
1258
+ }
1259
+ if (state.kind === "asking") {
1260
+ writeStatusLine(`${ui.yellow("!")} A phone wants to sign in to this account. Code ${ui.bold(spacedCode(state.code))}`);
1261
+ writeStatusLine(ui.dim("If your phone shows the same code, press Enter to allow it. Press N to deny."));
1262
+ const choice = await allowOrDeny(options.allow, options.deny, options.woken);
1263
+ if (choice === "stopped") return "stopped";
1264
+ const approve = choice === "allow";
1265
+ const decided = await postAsTheTerminal(signIn, DECIDE_PATH, { id: signIn.id, code: state.code, approve }, deps);
1266
+ if (approve && decided) {
1267
+ writeStatusLine(`${ui.done} Allowed. Finish on your phone.`);
1268
+ return "allowed";
1269
+ }
1270
+ writeStatusLine(approve ? ui.dim(PHONE_SIGN_IN_ENDED_LINE) : `${ui.yellow("!")} Denied. That phone was not signed in.`);
1271
+ return approve ? "ended" : "denied";
1272
+ }
1273
+ await Promise.race([clock.sleep(PHONE_SIGN_IN_POLL_MS), options.woken]);
1274
+ }
1275
+ return "stopped";
1276
+ };
1277
+ var showTerminalPhoneSignIn = async (signIn, ui) => {
1278
+ ui.say(` ${ui.bold("Connect your phone")}`);
1279
+ ui.say(` ${PHONE_SIGN_IN_SCAN_LINE}`);
1280
+ await printQr(signIn.link);
1281
+ ui.say(` ${ui.dim("Or open on your phone:")} ${ui.cyan(signIn.link)}`);
1282
+ ui.say(` ${ui.dim(PHONE_WAIT_SKIP_LINE)}`);
1283
+ };
1284
+ var waitForYourPhoneToSignIn = async (apiKey, signIn, keys, ui, deps = {}) => {
1285
+ const exit = deps.exit ?? ((code) => process.exit(code));
1286
+ let stopped = false;
1287
+ let wake = () => {
1288
+ };
1289
+ const woken = new Promise((resolve) => {
1290
+ wake = resolve;
1291
+ });
1292
+ let approval = Promise.resolve("stopped");
1293
+ const stopWaiting = () => {
1294
+ stopped = true;
1295
+ wake();
1296
+ };
1297
+ const cancelOnSignal = (exitCode) => () => {
1298
+ stopWaiting();
1299
+ keys.close();
1300
+ void cancelTerminalPhoneSignIn(signIn, deps).finally(() => exit(exitCode));
1301
+ };
1302
+ const onInterrupt = cancelOnSignal(EXIT_ABORTED);
1303
+ const onTerminate = cancelOnSignal(EXIT_TERMINATED);
1304
+ process.once("SIGINT", onInterrupt);
1305
+ process.once("SIGTERM", onTerminate);
1306
+ try {
1307
+ return await waitForYourPhone(apiKey, {
1308
+ skip: keys.listenerFor(PHONE_WAIT_SKIP_KEY),
1309
+ ...deps.clock ? { clock: deps.clock } : {},
1310
+ intro: async () => {
1311
+ await showTerminalPhoneSignIn(signIn, ui);
1312
+ approval = approveThePhoneWhenItAsks(signIn, ui, {
1313
+ allow: keys.listenerFor(PHONE_ALLOW_KEY),
1314
+ deny: keys.listenerFor(PHONE_DENY_KEY),
1315
+ stopped: () => stopped,
1316
+ woken
1317
+ }, deps);
1318
+ }
1319
+ });
1320
+ } finally {
1321
+ process.off("SIGINT", onInterrupt);
1322
+ process.off("SIGTERM", onTerminate);
1323
+ stopWaiting();
1324
+ if (await approval !== "allowed") await cancelTerminalPhoneSignIn(signIn, deps);
1325
+ }
1326
+ };
1327
+
898
1328
  // src/setup/telemetry.ts
899
1329
  import { randomUUID } from "crypto";
900
1330
  var roundTripOutcome = (outcome) => {
@@ -2666,6 +3096,11 @@ var verifyKeyOrExit = async (apiKey, options, precomputed) => {
2666
3096
  }
2667
3097
  return result;
2668
3098
  };
3099
+ var describeSignInStop = (stop) => {
3100
+ if (stop.kind === "app_stopped") return stop.detail;
3101
+ if (stop.kind === "expired") return "The sign-in code expired before it was used. Nothing was written.";
3102
+ return `Couldn't start sign-in ${dim(`(${stop.detail})`)}. Check your connection. Nothing was written.`;
3103
+ };
2669
3104
  var printPairingEscape = (lines) => {
2670
3105
  console.log();
2671
3106
  for (const line of lines) console.log(line === "" ? "" : ` ${line}`);
@@ -2992,6 +3427,7 @@ var main = async () => {
2992
3427
  let trimmedKey;
2993
3428
  let keyOrigin = "supplied";
2994
3429
  let keyFromPairing = false;
3430
+ let phonePass = null;
2995
3431
  const storedKey = readConfigFileKey();
2996
3432
  const pairingRequested = connectMode === "app" && options.connectExplicit && !options.skipPhone;
2997
3433
  const ambientEligible = flagKey === void 0 && !pairingRequested;
@@ -3052,11 +3488,52 @@ var main = async () => {
3052
3488
  reportDryRun(null, plannedAgents, null, controlMode);
3053
3489
  await emitJson(options, { ok: true, dryRun: true, agents: plannedAgents, control: controlMode, keyCheck: "skipped", key: "none" });
3054
3490
  return;
3491
+ } else if (connectMode === "app" && canPairWithApp && !options.connectExplicit) {
3492
+ if (reuseDeclined) console.log();
3493
+ markStep("sign-in");
3494
+ const previous = readKeyInForce();
3495
+ const signedIn2 = await signInForSetup(
3496
+ { say: (line) => console.log(line), bold, dim, cyan, yellow },
3497
+ {
3498
+ cliVersion: version,
3499
+ computer: pairingComputerOf(hostname2(), process.platform, detectedAgentChoices()),
3500
+ onCancelled: async (exitCode2) => {
3501
+ printPairingEscape(describeCancelledSignIn(exitCode2));
3502
+ await reportSetupAbort("pairing-cancelled", exitCode2);
3503
+ }
3504
+ }
3505
+ );
3506
+ if (signedIn2.kind === "rejected") {
3507
+ console.log();
3508
+ console.log(` ${yellow("!")} That request was rejected in the browser. Nothing was written.`);
3509
+ console.log();
3510
+ process.exit(await abortWith("login-rejected", EXIT.NOT_CONFIGURED));
3511
+ }
3512
+ if (signedIn2.kind === "app_stopped" || signedIn2.kind === "expired" || signedIn2.kind === "unavailable") {
3513
+ console.log();
3514
+ console.log(` ${yellow("!")} ${describeSignInStop(signedIn2)}`);
3515
+ printPairingEscape(describeSignInEscape());
3516
+ process.exit(await abortWith("pairing-failed", EXIT.NOT_CONFIGURED));
3517
+ }
3518
+ trimmedKey = signedIn2.apiKey;
3519
+ phonePass = signedIn2.kind === "browser" ? signedIn2.phonePass : null;
3520
+ keyOrigin = "created_by_this_cli";
3521
+ keyFromPairing = signedIn2.kind === "app";
3522
+ pairedHandle = signedIn2.kind === "app" && signedIn2.handle ? `@${signedIn2.handle}` : null;
3523
+ console.log();
3524
+ if (signedIn2.kind === "browser") console.log(` ${check} Signed in${signedIn2.siteSlug ? ` ${dim(`(${signedIn2.siteSlug})`)}` : ""}`);
3525
+ if (signedIn2.kind === "app") console.log(` ${check} Your phone approved this computer`);
3526
+ if (pairedHandle) console.log(` ${check} Connected to ${cyan(pairedHandle)}`);
3527
+ const previousKeyLeftActive = describePreviousKeyLeftActive(previous.key, trimmedKey);
3528
+ if (previousKeyLeftActive !== null) {
3529
+ console.log(` ${yellow("!")} ${previousKeyLeftActive}`);
3530
+ console.log(` ${dim("Revoke it at")} ${cyan("pushary.com/dashboard/agent/settings")} ${dim("if nothing else uses it.")}`);
3531
+ }
3055
3532
  } else if (connectMode === "app" && canPairWithApp) {
3056
3533
  if (reuseDeclined) console.log();
3057
3534
  markStep("pair");
3058
3535
  const previous = readKeyInForce();
3059
- const computer = pairingComputerOf(hostname(), process.platform, detectedAgentChoices());
3536
+ const computer = pairingComputerOf(hostname2(), process.platform, detectedAgentChoices());
3060
3537
  const paired = await connectViaAppPairing({
3061
3538
  computer,
3062
3539
  command: "setup",
@@ -3101,10 +3578,11 @@ var main = async () => {
3101
3578
  markStep("browser-login");
3102
3579
  const outcome = await runBrowserLogin(
3103
3580
  { say: (line) => console.log(line), bold, dim, cyan, yellow },
3104
- { cliVersion: version }
3581
+ { cliVersion: version, command: "setup" }
3105
3582
  );
3106
3583
  if (outcome.kind === "ok") {
3107
3584
  trimmedKey = outcome.apiKey;
3585
+ phonePass = outcome.phonePass;
3108
3586
  keyOrigin = "created_by_this_cli";
3109
3587
  console.log();
3110
3588
  console.log(` ${check} Signed in${outcome.siteSlug ? ` ${dim(`(${outcome.siteSlug})`)}` : ""}`);
@@ -3353,14 +3831,20 @@ var main = async () => {
3353
3831
  phone = await printConnectInstructions(trimmedKey, connectInstructions);
3354
3832
  break;
3355
3833
  case "wait-for-app": {
3356
- const skip = singleKeyListener(PHONE_WAIT_SKIP_KEY);
3357
- phone = skip === null ? await printConnectInstructions(trimmedKey, connectInstructions) : await waitForYourPhone(trimmedKey, { skip });
3834
+ const keys = keyRouter();
3835
+ const phoneSignIn = keys !== null && phonePass !== null && connectInstructions.showQr ? await startTerminalPhoneSignIn(phonePass, pairingComputerOf(hostname2(), process.platform, detectedAgentChoices()), reportedInstallSource()) : null;
3836
+ if (keys === null) phone = await printConnectInstructions(trimmedKey, connectInstructions);
3837
+ else if (phoneSignIn === null) phone = await waitForYourPhone(trimmedKey, { skip: keys.listenerFor(PHONE_WAIT_SKIP_KEY) });
3838
+ else phone = await waitForYourPhoneToSignIn(trimmedKey, phoneSignIn, keys, { say: (line) => console.log(line), bold, dim, cyan, yellow, done: check });
3839
+ keys?.close();
3358
3840
  break;
3359
3841
  }
3360
3842
  case "connect":
3361
3843
  phone = await connectDevice(trimmedKey, { showCapabilities: !options.connectExplicit });
3362
3844
  break;
3363
3845
  }
3846
+ const phoneSkippedAtTheTerminal = phoneWaitWasSkipped(phone);
3847
+ if (phoneSkippedAtTheTerminal) phone = null;
3364
3848
  let roundTrip = null;
3365
3849
  if (verifyMode === "roundtrip" && keyCheck.kind === "ok" && !skipPhone && // Reaching nobody is already reported by the delivery check above, in copy
3366
3850
  // that names the fix. Asking a question nobody can receive would repeat it
@@ -3390,7 +3874,7 @@ var main = async () => {
3390
3874
  const report = describeRoundTripOutcome(roundTrip, { appPlatforms, keyScope });
3391
3875
  if (!report.ok) console.log(` ${yellow("!")} ${report.message}`);
3392
3876
  for (const line of report.next) console.log(` ${dim(line)}`);
3393
- } else if (verifyMode === "roundtrip" && keyCheck.kind === "ok") {
3877
+ } else if (verifyMode === "roundtrip" && keyCheck.kind === "ok" && !phoneSkippedAtTheTerminal) {
3394
3878
  console.log();
3395
3879
  console.log(` ${dim("Skipped the round trip: nothing is connected that could answer it.")}`);
3396
3880
  }
@@ -3570,7 +4054,8 @@ var main = async () => {
3570
4054
  roundTripAnswer: roundTripAnswerOf(roundTrip),
3571
4055
  appPlatforms: phone?.appPlatforms,
3572
4056
  codexApprovals,
3573
- phoneAwaitsNotifications: phone !== null && phoneAwaitsNotificationPermission(phone)
4057
+ phoneAwaitsNotifications: phone !== null && phoneAwaitsNotificationPermission(phone),
4058
+ phoneSkippedAtTheTerminal
3574
4059
  });
3575
4060
  console.log(` ${closing.ok ? green(bold(closing.headline)) : yellow(bold(closing.headline))}`);
3576
4061
  if (failures.length > 0) {