pushary 1.9.275 → 1.9.277

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 (148) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +1 -0
  3. package/dist/{api-UYF7LSAY.js → api-JDJKIBJ2.js} +12 -12
  4. package/dist/bin/pushary-ask.d.ts +1 -0
  5. package/dist/bin/pushary-ask.js +303 -0
  6. package/dist/bin/pushary-audit.js +3 -3
  7. package/dist/bin/pushary-bell-hook.js +31 -30
  8. package/dist/bin/pushary-bell.js +11 -11
  9. package/dist/bin/pushary-calls.js +14 -14
  10. package/dist/bin/pushary-claude.js +42 -40
  11. package/dist/bin/pushary-clean.js +47 -46
  12. package/dist/bin/pushary-codex-bridge.js +23 -23
  13. package/dist/bin/pushary-codex-hook.js +37 -35
  14. package/dist/bin/pushary-codex-session.js +8 -8
  15. package/dist/bin/pushary-codex.js +17 -16
  16. package/dist/bin/pushary-connect.js +37 -36
  17. package/dist/bin/pushary-cowork.js +5 -5
  18. package/dist/bin/pushary-daemon.js +69 -68
  19. package/dist/bin/pushary-disconnect.js +33 -32
  20. package/dist/bin/pushary-display-hook.js +89 -52
  21. package/dist/bin/pushary-doctor.js +76 -75
  22. package/dist/bin/pushary-elicitation-hook.js +30 -28
  23. package/dist/bin/pushary-gemini-bridge.js +18 -18
  24. package/dist/bin/pushary-gemini-hook.js +34 -32
  25. package/dist/bin/pushary-hook.js +38 -37
  26. package/dist/bin/pushary-login.js +45 -44
  27. package/dist/bin/pushary-logout.js +33 -32
  28. package/dist/bin/pushary-mcp.js +14 -14
  29. package/dist/bin/pushary-mode.js +15 -15
  30. package/dist/bin/pushary-notification-hook.js +28 -27
  31. package/dist/bin/pushary-opencode-bridge.js +25 -25
  32. package/dist/bin/pushary-opencode-hook.js +48 -46
  33. package/dist/bin/pushary-permission-denied-hook.js +35 -34
  34. package/dist/bin/pushary-permission-hook.js +36 -35
  35. package/dist/bin/pushary-post-hook.js +29 -28
  36. package/dist/bin/pushary-prompt-hook.js +28 -27
  37. package/dist/bin/pushary-session-end-hook.js +31 -30
  38. package/dist/bin/pushary-session-start-hook.js +41 -40
  39. package/dist/bin/pushary-sessions.js +12 -12
  40. package/dist/bin/pushary-setup.js +94 -93
  41. package/dist/bin/pushary-stats.js +7 -7
  42. package/dist/bin/pushary-status.js +38 -37
  43. package/dist/bin/pushary-stop-hook.js +28 -27
  44. package/dist/bin/pushary-stopfailure-hook.js +28 -27
  45. package/dist/bin/pushary-suggestions.js +15 -15
  46. package/dist/bin/pushary-transcript-register.js +16 -16
  47. package/dist/bin/pushary-transcripts.js +27 -27
  48. package/dist/bin/pushary-upgrade.js +65 -64
  49. package/dist/bin/pushary-wait.js +16 -16
  50. package/dist/bin/pushary.js +8 -7
  51. package/dist/{chunk-SSTYK7PS.js → chunk-22OYSTAN.js} +1 -1
  52. package/dist/{chunk-3SYN4CZY.js → chunk-2BW7GNNB.js} +2 -2
  53. package/dist/{chunk-MBCFK4M6.js → chunk-2XAZO2Q3.js} +2 -2
  54. package/dist/{chunk-2ECFTUS4.js → chunk-33IU43ZR.js} +7 -7
  55. package/dist/{chunk-F5DE3MC4.js → chunk-3CNXRECH.js} +4 -4
  56. package/dist/{chunk-K3PCCRPC.js → chunk-3HKTW7AH.js} +2 -2
  57. package/dist/{chunk-MA7OYH7C.js → chunk-4IX2PONM.js} +1 -1
  58. package/dist/{chunk-IUMOULO7.js → chunk-5VAI3RDO.js} +4 -4
  59. package/dist/{chunk-VK4535XM.js → chunk-5XVPGNE5.js} +6 -6
  60. package/dist/{chunk-G4WDZ3HX.js → chunk-5ZX57DNR.js} +2 -2
  61. package/dist/{chunk-JLCFHXBI.js → chunk-63J4TOMV.js} +4 -4
  62. package/dist/{chunk-JPSTWHPO.js → chunk-6RSP2BY4.js} +3 -3
  63. package/dist/{chunk-B7NY7IOT.js → chunk-6X7GXEBI.js} +15 -4
  64. package/dist/{chunk-SQNXMDZY.js → chunk-72CPOGDP.js} +3 -3
  65. package/dist/{chunk-OIC7O6TI.js → chunk-76XC2ICT.js} +18 -19
  66. package/dist/{chunk-JQNX7T7E.js → chunk-7AMWTZTL.js} +5 -5
  67. package/dist/{chunk-JTHR2DFZ.js → chunk-7RLMFVUZ.js} +2 -2
  68. package/dist/{chunk-PBPRRUMU.js → chunk-A7PIULSY.js} +1 -1
  69. package/dist/{chunk-DW457FN4.js → chunk-AECDNNRM.js} +1 -1
  70. package/dist/{chunk-ZWI4DDDU.js → chunk-B5565Y33.js} +1 -1
  71. package/dist/{chunk-2H224XIR.js → chunk-B6RL3XXW.js} +3 -3
  72. package/dist/{chunk-7DOHIVGA.js → chunk-BAYA2H6O.js} +7 -7
  73. package/dist/{chunk-TZJKQHUA.js → chunk-C3E5KDBH.js} +10 -10
  74. package/dist/{chunk-EDUIGTJS.js → chunk-CB2NT2J5.js} +1 -1
  75. package/dist/{chunk-TZE2UIDX.js → chunk-CUXMOQDW.js} +3 -3
  76. package/dist/{chunk-NCXLS6FG.js → chunk-DFNJBEFV.js} +10 -10
  77. package/dist/{chunk-AIJ3FW2A.js → chunk-DIQKY76N.js} +1 -1
  78. package/dist/{chunk-R45GN73L.js → chunk-DISRB3NE.js} +1 -1
  79. package/dist/{chunk-JUA3T6LW.js → chunk-DMMIXJKD.js} +12 -12
  80. package/dist/{chunk-GQAYH7ZE.js → chunk-DWM7BYVK.js} +1 -1
  81. package/dist/{chunk-T3NUY5YT.js → chunk-EEC52E5K.js} +1 -1
  82. package/dist/{chunk-46AKZ7HL.js → chunk-ETZUDUCB.js} +1 -1
  83. package/dist/{chunk-EBKQFPAF.js → chunk-FGIJ46DR.js} +5 -5
  84. package/dist/{chunk-RVNIA7WP.js → chunk-FSJVDHQ5.js} +14 -14
  85. package/dist/{chunk-VNLNZRQI.js → chunk-GJQJHWQ4.js} +2 -2
  86. package/dist/{chunk-7VSN3RAO.js → chunk-GP7Q2DCX.js} +4 -4
  87. package/dist/{chunk-H5G3E46X.js → chunk-GQDJPX3J.js} +1 -1
  88. package/dist/{chunk-KEEOJGWM.js → chunk-GUL5YSME.js} +5 -5
  89. package/dist/{chunk-WI3MLHNC.js → chunk-HMUSFFEH.js} +3 -3
  90. package/dist/{chunk-XIWSDHAN.js → chunk-HQSTVSDO.js} +169 -74
  91. package/dist/{chunk-GG5NSV3O.js → chunk-I4A6CL5Q.js} +6 -6
  92. package/dist/{chunk-G74VXDI3.js → chunk-I5I5PXQL.js} +10 -10
  93. package/dist/{chunk-YKM4OBUT.js → chunk-ISPN73NA.js} +5 -5
  94. package/dist/{chunk-PRAELNHG.js → chunk-J2N3BNNE.js} +1 -1
  95. package/dist/{chunk-GH3EJZBB.js → chunk-JHJPAG6R.js} +6 -6
  96. package/dist/{chunk-HKQ6XCNT.js → chunk-JNPWASVJ.js} +11 -1
  97. package/dist/{chunk-B6JUK74V.js → chunk-K5JEB3I4.js} +8 -8
  98. package/dist/{chunk-IWHNP4G6.js → chunk-K5LHDTYS.js} +1 -1
  99. package/dist/{chunk-CHN6AZXY.js → chunk-KKEX5FAB.js} +8 -8
  100. package/dist/{chunk-GJVGG2NX.js → chunk-KO2QJNTA.js} +1 -1
  101. package/dist/{chunk-6NXYMMKP.js → chunk-LO2LCXNB.js} +5 -5
  102. package/dist/{chunk-DOEEYXPK.js → chunk-MGV6KJJF.js} +1 -1
  103. package/dist/{chunk-QOPP2CM2.js → chunk-MOMA4DD4.js} +1 -1
  104. package/dist/{chunk-SI4LICC4.js → chunk-MZJIL5CA.js} +5 -5
  105. package/dist/{chunk-YWVWYZ5X.js → chunk-NDDIA2YJ.js} +7 -7
  106. package/dist/{chunk-RI3VO4MZ.js → chunk-NLJUHVZJ.js} +3 -3
  107. package/dist/{chunk-7Z4QAO67.js → chunk-OIRKU5GW.js} +4 -4
  108. package/dist/{chunk-NLXZG4RI.js → chunk-OMHFKENS.js} +6 -6
  109. package/dist/{chunk-F64Z7PD3.js → chunk-QHSJVHNC.js} +4 -4
  110. package/dist/{chunk-F3R6NNUT.js → chunk-QNMJJMZF.js} +4 -4
  111. package/dist/{chunk-KYTIMYSH.js → chunk-QUU74XFH.js} +3 -3
  112. package/dist/{chunk-PQEGVH55.js → chunk-R5FAM3I6.js} +1 -1
  113. package/dist/{chunk-IAJZ6VB2.js → chunk-R7VMXE6A.js} +1 -1
  114. package/dist/{chunk-O2UTXGB3.js → chunk-SMI5X7BO.js} +1 -1
  115. package/dist/{chunk-FKPDU6TF.js → chunk-TSKDJNC5.js} +1 -1
  116. package/dist/{chunk-Z4X4YQIN.js → chunk-UCX7X333.js} +1 -1
  117. package/dist/{chunk-K4JNAPYA.js → chunk-UXB54PYF.js} +29 -22
  118. package/dist/{chunk-GB2T6QG4.js → chunk-WCTHF35Z.js} +3 -3
  119. package/dist/{chunk-AU23W5SP.js → chunk-WFDFDUHU.js} +2 -2
  120. package/dist/{chunk-NHWKYVGF.js → chunk-WG4Y6DJD.js} +24 -11
  121. package/dist/{chunk-HM3ZQM43.js → chunk-WJALXH6I.js} +1 -1
  122. package/dist/{chunk-XHWLP32J.js → chunk-WTPNWUEQ.js} +3 -3
  123. package/dist/{chunk-HNR2GHEZ.js → chunk-WXXAFKZE.js} +2 -2
  124. package/dist/{chunk-3YNP26P3.js → chunk-WY6VFXYH.js} +22 -20
  125. package/dist/{chunk-NB72LXU3.js → chunk-XHEF2MQZ.js} +2 -2
  126. package/dist/{chunk-52JEQJYX.js → chunk-XOALU2TA.js} +4 -4
  127. package/dist/{chunk-LMGJSABO.js → chunk-XUIQOGUN.js} +3 -3
  128. package/dist/{chunk-HIMWOMEM.js → chunk-YAV677T2.js} +4 -4
  129. package/dist/{chunk-JAZIUZOL.js → chunk-YBTS5ZR3.js} +43 -14
  130. package/dist/{chunk-ALIXGN7U.js → chunk-YPTRRRD3.js} +1 -1
  131. package/dist/{chunk-O2GXSLCL.js → chunk-YSDITWDH.js} +4 -4
  132. package/dist/chunk-Z25VDYAL.js +6 -0
  133. package/dist/{chunk-DC7AK2SR.js → chunk-Z5H2XKMF.js} +2 -2
  134. package/dist/{codex-app-cards-switch-ZVDNZ2UC.js → codex-app-cards-switch-YN66WO7X.js} +12 -12
  135. package/dist/{codex-card-routing-JSZRQKBM.js → codex-card-routing-QXVDJGWF.js} +2 -2
  136. package/dist/{codex-desktop-launch-HOD53MVT.js → codex-desktop-launch-XFRDRYXQ.js} +3 -3
  137. package/dist/{codex-session-launch-EZG3K35D.js → codex-session-launch-W3SUQJMA.js} +22 -22
  138. package/dist/{config-GCBSQG55.js → config-EGAARNM4.js} +9 -3
  139. package/dist/{global-upgrade-EIHPC527.js → global-upgrade-KKCSLSUA.js} +9 -9
  140. package/dist/{identity-TM22H43G.js → identity-P35TDUOJ.js} +4 -4
  141. package/dist/{live-capabilities-OAUT7MJS.js → live-capabilities-6NS5JAL4.js} +4 -4
  142. package/dist/{paths-BF2E3BRF.js → paths-FCBX57O2.js} +3 -3
  143. package/dist/{reapply-CS3B7JDA.js → reapply-KASKVOYN.js} +36 -35
  144. package/dist/src/index.d.ts +14 -3
  145. package/dist/src/index.js +34 -33
  146. package/dist/{upgrade-lock-UGHULXB5.js → upgrade-lock-HOMFI7KP.js} +4 -4
  147. package/dist/{usage-V46QHLZC.js → usage-MAE6ZECN.js} +3 -3
  148. package/package.json +2 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.9.277
4
+
5
+ - `pushary ask "Ship this layout?" --image checkout.png` asks a question from the terminal, with up to two screenshots (PNG, JPEG or WebP, 2 MiB each), and prints the reply as JSON. `--type confirm|select|input` and `--option` set how it is answered. A picture can be read for 48 hours, and the question stays open after that.
6
+ - Exit 0 is a yes, or an answered selection or text. Exit 1 is only a declined confirmation. Everything else, such as handing the question back to the computer, is 9 or a more exact code.
7
+ - With no API key on this machine, or one Pushary rejects, the question goes through the Mac app's sign-in when the app is installed.
8
+ - The question is withdrawn when nobody can be reached, when the process that asked is gone, and on Ctrl-C. Started by process 0 or 1, as in some containers, it waits 10 minutes and is then withdrawn.
9
+
10
+ ## 1.9.276
11
+
12
+ - A command with thousands of blanks, line breaks or digits in a row is judged in well under a second. One with 8,000 blanks took more than 8 seconds and could outlast the hook's time limit. No verdict changes.
13
+
3
14
  ## 1.9.275
4
15
 
5
16
  - A standing deny for all of `Bash`, or for `*`, no longer refuses a chained command that an ask rule of yours governs. Beside a `Bash(git:*)` rule that asks and an argument rule such as a `Bash(*secret*)` deny, `cd /repo && git status` was refused by the bare deny since 1.9.272; it is asked about again. A standing deny that names an argument still refuses the whole command, and a call only the bare deny governs is still refused. A command of more than 64 steps under a rule that approves on timeout can still be refused by the bare deny.
package/README.md CHANGED
@@ -234,6 +234,7 @@ setup Configure Claude Code, Codex, Gemini CLI, Hermes, OpenClaw, Cursor,
234
234
  claude Run Claude Code through Pushary, reachable from your phone even when idle
235
235
  daemon Keep this machine reachable so your phone can START a new session
236
236
  status One screen: which key is in force, whether the server accepts it, what can receive an approval
237
+ ask Ask a question with optional screenshots and print the response as JSON
237
238
  sessions List agent sessions, their locations, and pending decisions as JSON
238
239
  login Sign in from this terminal, no key to copy (--with-token to pipe one in)
239
240
  sign-out Sign out: remove the key this machine stores, and say what it does not remove (also: logout)
@@ -28,21 +28,21 @@ import {
28
28
  waitForQuestion,
29
29
  waitRetryPauseMs,
30
30
  withdrawQuestion
31
- } from "./chunk-K4JNAPYA.js";
31
+ } from "./chunk-UXB54PYF.js";
32
32
  import "./chunk-POFBE6ZY.js";
33
- import "./chunk-NHWKYVGF.js";
34
- import "./chunk-HM3ZQM43.js";
35
- import "./chunk-KYTIMYSH.js";
36
- import "./chunk-2H224XIR.js";
37
- import "./chunk-O2UTXGB3.js";
38
- import "./chunk-G4WDZ3HX.js";
39
- import "./chunk-XIWSDHAN.js";
33
+ import "./chunk-WG4Y6DJD.js";
34
+ import "./chunk-WJALXH6I.js";
35
+ import "./chunk-QUU74XFH.js";
36
+ import "./chunk-B6RL3XXW.js";
37
+ import "./chunk-SMI5X7BO.js";
38
+ import "./chunk-5ZX57DNR.js";
39
+ import "./chunk-HQSTVSDO.js";
40
40
  import "./chunk-6ICPEJY5.js";
41
- import "./chunk-F3R6NNUT.js";
42
- import "./chunk-B7NY7IOT.js";
41
+ import "./chunk-QNMJJMZF.js";
42
+ import "./chunk-6X7GXEBI.js";
43
43
  import "./chunk-CINBAX5G.js";
44
44
  import "./chunk-PM2NRK6Y.js";
45
- import "./chunk-HKQ6XCNT.js";
45
+ import "./chunk-JNPWASVJ.js";
46
46
  import "./chunk-BG4HHB7E.js";
47
47
  import "./chunk-CXQWDQCJ.js";
48
48
  import {
@@ -51,7 +51,7 @@ import {
51
51
  isAwayPaused,
52
52
  isLocalQuestionHandoff,
53
53
  waitsForThePhone
54
- } from "./chunk-JAZIUZOL.js";
54
+ } from "./chunk-YBTS5ZR3.js";
55
55
  import "./chunk-MLKGABMK.js";
56
56
  export {
57
57
  ABANDONED_WAIT,
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
@@ -0,0 +1,303 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ launcherIsGone
4
+ } from "../chunk-U4P4NDVB.js";
5
+ import {
6
+ exitOnHelpFlag
7
+ } from "../chunk-ETZUDUCB.js";
8
+ import {
9
+ isDeferAnswer
10
+ } from "../chunk-Z25VDYAL.js";
11
+ import {
12
+ askUser,
13
+ askingProcessWaitsFrom,
14
+ cancelQuestion,
15
+ exitAfterClientReports,
16
+ isDecisionStopped,
17
+ isTransientWaitFailure,
18
+ reportFailedQuestionWithdrawal,
19
+ sleepUnlessAborted,
20
+ waitForAnswer,
21
+ waitWhileTheQuestionIsOpen,
22
+ withdrawQuestion
23
+ } from "../chunk-UXB54PYF.js";
24
+ import "../chunk-POFBE6ZY.js";
25
+ import {
26
+ McpHttpError,
27
+ callMcpTool,
28
+ isRetryable,
29
+ withRetry
30
+ } from "../chunk-WG4Y6DJD.js";
31
+ import "../chunk-WJALXH6I.js";
32
+ import {
33
+ projectNameFor
34
+ } from "../chunk-DWM7BYVK.js";
35
+ import "../chunk-QUU74XFH.js";
36
+ import {
37
+ isNetworkFailure
38
+ } from "../chunk-B6RL3XXW.js";
39
+ import "../chunk-SMI5X7BO.js";
40
+ import "../chunk-5ZX57DNR.js";
41
+ import {
42
+ MacAppRefusedError,
43
+ MacAppUnreachableError,
44
+ macAppSignIn
45
+ } from "../chunk-HQSTVSDO.js";
46
+ import "../chunk-6ICPEJY5.js";
47
+ import "../chunk-QNMJJMZF.js";
48
+ import {
49
+ PUSHARY_PRODUCTION_URL,
50
+ getApiKey,
51
+ getBaseUrl,
52
+ isMalformedApiKeyError,
53
+ isMissingApiKeyError,
54
+ readApiKey
55
+ } from "../chunk-6X7GXEBI.js";
56
+ import {
57
+ UsageError,
58
+ exitCodeFor,
59
+ messageFor
60
+ } from "../chunk-CINBAX5G.js";
61
+ import "../chunk-PM2NRK6Y.js";
62
+ import "../chunk-JNPWASVJ.js";
63
+ import {
64
+ EXIT
65
+ } from "../chunk-BG4HHB7E.js";
66
+ import "../chunk-CXQWDQCJ.js";
67
+ import {
68
+ ASK_QUESTION_MAX,
69
+ MAX_ASK_SELECT_OPTIONS,
70
+ MIN_ASK_SELECT_OPTIONS,
71
+ isApprovingAnswer,
72
+ isAwayPaused,
73
+ isLocalQuestionHandoff,
74
+ isRecord
75
+ } from "../chunk-YBTS5ZR3.js";
76
+ import "../chunk-MLKGABMK.js";
77
+
78
+ // bin/pushary-ask.ts
79
+ import { randomUUID } from "crypto";
80
+
81
+ // src/cli/ask-sign-in.ts
82
+ var UNAUTHENTICATED_STATUS = 401;
83
+ var KEY_REJECTED_ASKS_THROUGH_MAC_APP = "Pushary rejected this machine's API key. Asking through the Mac app's sign-in instead.";
84
+ var macAppForThisServer = () => getBaseUrl() === PUSHARY_PRODUCTION_URL ? macAppSignIn() : null;
85
+ var startingSignIn = () => (readApiKey().kind === "missing" ? macAppForThisServer() : null) ?? getApiKey();
86
+ var isRejectedKey = (signIn, error) => typeof signIn === "string" && error instanceof McpHttpError && error.status === UNAUTHENTICATED_STATUS;
87
+ var callWithWorkingSignIn = async (signIn, call) => {
88
+ try {
89
+ return { signIn, result: await call(signIn) };
90
+ } catch (error) {
91
+ const macApp = isRejectedKey(signIn, error) ? macAppForThisServer() : null;
92
+ if (!macApp) throw error;
93
+ console.error(KEY_REJECTED_ASKS_THROUGH_MAC_APP);
94
+ return { signIn: macApp, result: await call(macApp) };
95
+ }
96
+ };
97
+
98
+ // src/cli/ask.ts
99
+ import { constants } from "fs";
100
+ import { open } from "fs/promises";
101
+ import { basename, extname } from "path";
102
+ import { parseArgs } from "util";
103
+ function parseAsk(argv) {
104
+ let parsed;
105
+ try {
106
+ parsed = parseArgs({ args: argv, allowPositionals: true, options: {
107
+ type: { type: "string", default: "confirm" },
108
+ option: { type: "string", multiple: true },
109
+ image: { type: "string", multiple: true }
110
+ } });
111
+ } catch (error) {
112
+ throw new UsageError(error instanceof Error ? error.message : "Invalid ask arguments");
113
+ }
114
+ const question = parsed.positionals[0]?.trim();
115
+ const { type, image: paths = [], option: options = [] } = parsed.values;
116
+ if (parsed.positionals.length !== 1 || !question || question.length > ASK_QUESTION_MAX) throw new UsageError("Supply one quoted question within the question length limit.");
117
+ if (type !== "confirm" && type !== "select" && type !== "input") throw new UsageError("Choose --type confirm, select, or input.");
118
+ if (type === "select" ? options.length < MIN_ASK_SELECT_OPTIONS || options.length > MAX_ASK_SELECT_OPTIONS || options.some((option) => !option.trim()) : options.length > 0) {
119
+ throw new UsageError("Use 2 to 6 nonempty --option values with --type select.");
120
+ }
121
+ if (paths.length > 2) throw new UsageError("Attach up to two screenshots.");
122
+ return { question, type, options, paths };
123
+ }
124
+ async function localScreenshot(path) {
125
+ const mimeTypes = { ".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".webp": "image/webp" };
126
+ const type = mimeTypes[extname(path).toLowerCase()];
127
+ const label = basename(path).trim();
128
+ if (!type || label.length > 80) throw new UsageError("Choose a PNG, JPEG or WebP file with a filename of up to 80 characters.");
129
+ const file = await open(path, constants.O_RDONLY | constants.O_NONBLOCK);
130
+ try {
131
+ const stat = await file.stat();
132
+ if (!stat.isFile() || stat.size < 16 || stat.size > 2 * 1024 * 1024) throw new UsageError("Choose a regular screenshot file of 16 bytes to 2 MiB.");
133
+ const bytes = new Uint8Array(stat.size);
134
+ let offset = 0;
135
+ while (offset < bytes.length) {
136
+ const { bytesRead } = await file.read(bytes, offset, bytes.length - offset, offset);
137
+ if (!bytesRead) throw new UsageError("Screenshot changed while reading.");
138
+ offset += bytesRead;
139
+ }
140
+ return { blob: new Blob([bytes], { type }), label };
141
+ } finally {
142
+ await file.close();
143
+ }
144
+ }
145
+ function askExitCode(type, reply) {
146
+ if (!reply || typeof reply !== "object" || !("answered" in reply) || reply.answered !== true || !("value" in reply) || typeof reply.value !== "string" || !reply.value.trim() || "status" in reply && reply.status !== "answered" || "handoffAction" in reply && reply.handoffAction) return EXIT.INCONCLUSIVE;
147
+ const typed = "typedAnswer" in reply && reply.typedAnswer === true;
148
+ if (!typed && isDeferAnswer(reply.value)) return EXIT.INCONCLUSIVE;
149
+ return type === "confirm" && !isApprovingAnswer(reply.value) ? EXIT.FAILED : EXIT.OK;
150
+ }
151
+ function askFailureExitCode(error) {
152
+ if ((error instanceof McpHttpError || error instanceof MacAppRefusedError) && error.status === 401) return EXIT.UNAUTHENTICATED;
153
+ if (isMalformedApiKeyError(error) || isMissingApiKeyError(error)) return EXIT.NOT_CONFIGURED;
154
+ if (error instanceof MacAppUnreachableError || isNetworkFailure(error)) return EXIT.UNREACHABLE;
155
+ const code = exitCodeFor(error);
156
+ return code === EXIT.FAILED ? EXIT.INCONCLUSIVE : code;
157
+ }
158
+ var printedReply = (asked, reply) => {
159
+ if (reply.answered) return { ...reply, correlationId: asked.correlationId };
160
+ const { nextAction: _staleAction, hint: _staleHint, ...reach } = asked;
161
+ return { ...reach, ...reply, correlationId: asked.correlationId };
162
+ };
163
+
164
+ // src/cli/upload-screenshot.ts
165
+ var PREPARE_SCREENSHOT_TOOL = "prepare_screenshot";
166
+ var PREPARE_TIMEOUT_MS = 15e3;
167
+ var UPLOAD_TIMEOUT_MS = 3e4;
168
+ var UPLOAD_ATTEMPTS = 3;
169
+ var ALREADY_UPLOADED_STATUS = 412;
170
+ var FIRST_SERVER_ERROR = 500;
171
+ var PASSING_CLIENT_ERRORS = /* @__PURE__ */ new Set([408, 429]);
172
+ var STORAGE_HOST_SUFFIX = ".r2.cloudflarestorage.com";
173
+ var ScreenshotUploadError = class extends Error {
174
+ status;
175
+ constructor(status) {
176
+ super(`The screenshot upload failed (HTTP ${status}).`);
177
+ this.name = "ScreenshotUploadError";
178
+ this.status = status;
179
+ }
180
+ };
181
+ var isStorageUrl = (url) => url.protocol === "https:" && url.hostname.endsWith(STORAGE_HOST_SUFFIX);
182
+ var isTextRecord = (value) => isRecord(value) && Object.values(value).every((entry) => typeof entry === "string");
183
+ var preparedScreenshotOf = (reply) => {
184
+ if (!isRecord(reply) || typeof reply.id !== "string" || typeof reply.url !== "string" || !isTextRecord(reply.headers) || !URL.canParse(reply.url)) {
185
+ throw new Error("Invalid prepare_screenshot response");
186
+ }
187
+ const url = new URL(reply.url);
188
+ if (!isStorageUrl(url)) throw new Error("Invalid screenshot upload destination");
189
+ return { id: reply.id, url, headers: reply.headers };
190
+ };
191
+ var isPassingUploadFailure = (error) => error instanceof ScreenshotUploadError ? error.status >= FIRST_SERVER_ERROR || PASSING_CLIENT_ERRORS.has(error.status) : isRetryable(error);
192
+ var putOnce = async ({ url, headers }, blob, fetchImpl) => {
193
+ const response = await fetchImpl(url, { method: "PUT", headers, body: blob, redirect: "error", signal: AbortSignal.timeout(UPLOAD_TIMEOUT_MS) });
194
+ if (!response.ok && response.status !== ALREADY_UPLOADED_STATUS) throw new ScreenshotUploadError(response.status);
195
+ };
196
+ var putScreenshot = (prepared, blob, fetchImpl = fetch) => withRetry(() => putOnce(prepared, blob, fetchImpl), { maxAttempts: UPLOAD_ATTEMPTS, shouldRetry: isPassingUploadFailure });
197
+ var uploadScreenshot = async (signIn, { blob, label }, baseUrl) => {
198
+ const reply = await callMcpTool(signIn, PREPARE_SCREENSHOT_TOOL, { contentType: blob.type, bytes: blob.size }, { timeoutMs: PREPARE_TIMEOUT_MS, baseUrl });
199
+ const prepared = preparedScreenshotOf(reply);
200
+ await putScreenshot(prepared, blob);
201
+ return { id: prepared.id, label };
202
+ };
203
+
204
+ // src/cli/withdraw-asked-question.ts
205
+ var WITHDRAWN = "withdrawn";
206
+ var UNAVAILABLE = { answered: false, status: "unavailable", handoffAction: "stop" };
207
+ var withdrawAskedQuestion = async (signIn, correlationId) => {
208
+ let cancelled;
209
+ const result = await withdrawQuestion(signIn, correlationId, {
210
+ waitForAnswer,
211
+ cancelQuestion: async (...request) => {
212
+ cancelled = await cancelQuestion(...request);
213
+ return cancelled;
214
+ }
215
+ });
216
+ if (result.answered || result.status === WITHDRAWN) return result;
217
+ if (cancelled?.cancelled === true) return { ...result, status: WITHDRAWN };
218
+ if (cancelled && isDecisionStopped(cancelled)) return result;
219
+ reportFailedQuestionWithdrawal();
220
+ return UNAVAILABLE;
221
+ };
222
+ var questionMayStillBeOpen = (withdrawal) => withdrawal.status === UNAVAILABLE.status;
223
+ var waitForAskedQuestion = async (signIn, { correlationId }, askerStillWaits2) => {
224
+ const ending = await waitWhileTheQuestionIsOpen({
225
+ now: Date.now,
226
+ sleep: (ms) => sleepUnlessAborted(ms),
227
+ poll: (holdMs) => waitForAnswer(signIn, correlationId, holdMs),
228
+ askerStillWaits: askerStillWaits2,
229
+ isTransientFailure: isTransientWaitFailure
230
+ });
231
+ return ending.kind === "abandoned" ? withdrawAskedQuestion(signIn, correlationId) : ending.reply;
232
+ };
233
+
234
+ // bin/pushary-ask.ts
235
+ exitOnHelpFlag("ask");
236
+ process.exitCode = EXIT.INCONCLUSIVE;
237
+ var ASKING_PROCESS = process.ppid;
238
+ var STARTED_AT = Date.now();
239
+ var INTERRUPTIONS = ["SIGINT", "SIGTERM", "SIGHUP"];
240
+ var REPEATED_INTERRUPTION_MS = 1e3;
241
+ var INTERRUPTED_ASK_MS = 5e3;
242
+ var STILL_OPEN = "Interrupted before the question could be withdrawn. It may still be open.";
243
+ var interruptedAt = null;
244
+ var askerStillWaits = () => askingProcessWaitsFrom({ asker: ASKING_PROCESS, currentParent: process.ppid, waitedMs: Date.now() - STARTED_AT, isGone: launcherIsGone });
245
+ var withdrawInterrupted = async (asked) => {
246
+ const question = await Promise.race([asked.catch(() => null), sleepUnlessAborted(INTERRUPTED_ASK_MS).then(() => null)]);
247
+ if (!question) return console.error(STILL_OPEN);
248
+ const withdrawal = await withdrawAskedQuestion(question.signIn, question.result.correlationId);
249
+ if (questionMayStillBeOpen(withdrawal)) console.error(STILL_OPEN);
250
+ if (withdrawal.answered) console.error(`Answered before it could be withdrawn: ${withdrawal.value ?? ""}`);
251
+ };
252
+ var withdrawWhenInterrupted = (asked) => {
253
+ const onInterruption = () => {
254
+ if (interruptedAt !== null) {
255
+ if (Date.now() - interruptedAt <= REPEATED_INTERRUPTION_MS) return;
256
+ console.error(STILL_OPEN);
257
+ process.exit(EXIT.INCONCLUSIVE);
258
+ }
259
+ interruptedAt = Date.now();
260
+ void withdrawInterrupted(asked).finally(() => exitAfterClientReports(EXIT.INCONCLUSIVE));
261
+ };
262
+ for (const interruption of INTERRUPTIONS) process.on(interruption, onInterruption);
263
+ };
264
+ var replyTo = ({ signIn, result: question }) => {
265
+ if (question.answered || isDecisionStopped(question)) return { ...question, answered: question.answered === true };
266
+ if (isAwayPaused(question) || isLocalQuestionHandoff(question)) return withdrawAskedQuestion(signIn, question.correlationId);
267
+ console.error(`Waiting for question ${question.correlationId}`);
268
+ return waitForAskedQuestion(signIn, question, askerStillWaits);
269
+ };
270
+ async function main() {
271
+ const args = process.argv.slice(2);
272
+ const { question, type, options, paths } = parseAsk(args[0] === "ask" ? args.slice(1) : args);
273
+ const files = await Promise.all(paths.map(localScreenshot));
274
+ const baseUrl = getBaseUrl();
275
+ let signIn = startingSignIn();
276
+ const images = [];
277
+ for (const file of files) {
278
+ const uploaded = await callWithWorkingSignIn(signIn, (working) => uploadScreenshot(working, file, baseUrl));
279
+ signIn = uploaded.signIn;
280
+ images.push(uploaded.result);
281
+ }
282
+ const requestId = randomUUID();
283
+ const asked = callWithWorkingSignIn(signIn, (working) => askUser(working, {
284
+ question,
285
+ type,
286
+ requestId,
287
+ agentName: `Terminal - ${projectNameFor()}`,
288
+ ...options.length && { options: [...options] },
289
+ ...images.length && { images }
290
+ }, void 0, baseUrl));
291
+ withdrawWhenInterrupted(asked);
292
+ const initial = await asked;
293
+ if (interruptedAt !== null) return;
294
+ const reply = await replyTo(initial);
295
+ if (interruptedAt !== null) return;
296
+ console.log(JSON.stringify(printedReply(initial.result, reply)));
297
+ process.exitCode = askExitCode(type, reply);
298
+ }
299
+ main().catch((error) => {
300
+ if (interruptedAt !== null) return;
301
+ console.error(messageFor(error));
302
+ process.exitCode = askFailureExitCode(error);
303
+ });
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  exitOnHelpFlag
4
- } from "../chunk-46AKZ7HL.js";
4
+ } from "../chunk-ETZUDUCB.js";
5
5
  import {
6
6
  readJsonSafe,
7
7
  writeJsonAtomic
8
8
  } from "../chunk-PM2NRK6Y.js";
9
- import "../chunk-HKQ6XCNT.js";
9
+ import "../chunk-JNPWASVJ.js";
10
10
  import {
11
11
  EXIT
12
12
  } from "../chunk-BG4HHB7E.js";
@@ -22,7 +22,7 @@ import {
22
22
  parseAuditChainExport,
23
23
  parseAuditKnownHead,
24
24
  verifyAuditChainSite
25
- } from "../chunk-JAZIUZOL.js";
25
+ } from "../chunk-YBTS5ZR3.js";
26
26
  import "../chunk-MLKGABMK.js";
27
27
 
28
28
  // src/audit-verify.ts
@@ -1,46 +1,47 @@
1
1
  #!/usr/bin/env node
2
- import {
3
- handleBell
4
- } from "../chunk-JTHR2DFZ.js";
5
2
  import {
6
3
  readHookInput
7
- } from "../chunk-KEEOJGWM.js";
8
- import "../chunk-TZE2UIDX.js";
9
- import "../chunk-NCXLS6FG.js";
4
+ } from "../chunk-GUL5YSME.js";
5
+ import "../chunk-CUXMOQDW.js";
6
+ import {
7
+ handleBell
8
+ } from "../chunk-7RLMFVUZ.js";
9
+ import "../chunk-DFNJBEFV.js";
10
10
  import "../chunk-WHB622LP.js";
11
- import "../chunk-NLXZG4RI.js";
12
- import "../chunk-DW457FN4.js";
13
- import "../chunk-GH3EJZBB.js";
14
- import "../chunk-52JEQJYX.js";
15
- import "../chunk-OIC7O6TI.js";
16
- import "../chunk-AIJ3FW2A.js";
17
- import "../chunk-DOEEYXPK.js";
18
- import "../chunk-Z4X4YQIN.js";
11
+ import "../chunk-OMHFKENS.js";
12
+ import "../chunk-AECDNNRM.js";
13
+ import "../chunk-JHJPAG6R.js";
14
+ import "../chunk-XOALU2TA.js";
15
+ import "../chunk-76XC2ICT.js";
16
+ import "../chunk-DIQKY76N.js";
17
+ import "../chunk-MGV6KJJF.js";
18
+ import "../chunk-Z25VDYAL.js";
19
+ import "../chunk-UCX7X333.js";
19
20
  import "../chunk-BZIBNSQE.js";
20
- import "../chunk-JPSTWHPO.js";
21
- import "../chunk-H5G3E46X.js";
21
+ import "../chunk-6RSP2BY4.js";
22
+ import "../chunk-GQDJPX3J.js";
22
23
  import "../chunk-P6DUWKAO.js";
23
24
  import "../chunk-3PSNUHC5.js";
24
- import "../chunk-K4JNAPYA.js";
25
- import "../chunk-FKPDU6TF.js";
25
+ import "../chunk-TSKDJNC5.js";
26
+ import "../chunk-UXB54PYF.js";
26
27
  import "../chunk-POFBE6ZY.js";
27
- import "../chunk-NHWKYVGF.js";
28
- import "../chunk-HM3ZQM43.js";
29
- import "../chunk-GQAYH7ZE.js";
30
- import "../chunk-KYTIMYSH.js";
31
- import "../chunk-2H224XIR.js";
32
- import "../chunk-O2UTXGB3.js";
33
- import "../chunk-G4WDZ3HX.js";
34
- import "../chunk-XIWSDHAN.js";
28
+ import "../chunk-WG4Y6DJD.js";
29
+ import "../chunk-WJALXH6I.js";
30
+ import "../chunk-DWM7BYVK.js";
31
+ import "../chunk-QUU74XFH.js";
32
+ import "../chunk-B6RL3XXW.js";
33
+ import "../chunk-SMI5X7BO.js";
34
+ import "../chunk-5ZX57DNR.js";
35
+ import "../chunk-HQSTVSDO.js";
35
36
  import "../chunk-6ICPEJY5.js";
36
- import "../chunk-F3R6NNUT.js";
37
- import "../chunk-B7NY7IOT.js";
37
+ import "../chunk-QNMJJMZF.js";
38
+ import "../chunk-6X7GXEBI.js";
38
39
  import "../chunk-CINBAX5G.js";
39
40
  import "../chunk-PM2NRK6Y.js";
40
- import "../chunk-HKQ6XCNT.js";
41
+ import "../chunk-JNPWASVJ.js";
41
42
  import "../chunk-BG4HHB7E.js";
42
43
  import "../chunk-CXQWDQCJ.js";
43
- import "../chunk-JAZIUZOL.js";
44
+ import "../chunk-YBTS5ZR3.js";
44
45
  import "../chunk-MLKGABMK.js";
45
46
 
46
47
  // bin/pushary-bell-hook.ts
@@ -5,42 +5,42 @@ import {
5
5
  liveAgentCount,
6
6
  ring,
7
7
  upgradeThreshold
8
- } from "../chunk-JTHR2DFZ.js";
8
+ } from "../chunk-7RLMFVUZ.js";
9
9
  import {
10
10
  createIo
11
- } from "../chunk-IWHNP4G6.js";
11
+ } from "../chunk-K5LHDTYS.js";
12
12
  import {
13
13
  exitOnHelpFlag
14
- } from "../chunk-46AKZ7HL.js";
14
+ } from "../chunk-ETZUDUCB.js";
15
15
  import {
16
16
  addBellHooks,
17
17
  bellInstalled,
18
18
  removeBellHooks
19
- } from "../chunk-Z4X4YQIN.js";
19
+ } from "../chunk-UCX7X333.js";
20
20
  import {
21
21
  parseFlags
22
22
  } from "../chunk-BZIBNSQE.js";
23
- import "../chunk-GQAYH7ZE.js";
24
- import "../chunk-G4WDZ3HX.js";
23
+ import "../chunk-DWM7BYVK.js";
24
+ import "../chunk-5ZX57DNR.js";
25
25
  import {
26
26
  claudeSettings
27
- } from "../chunk-XIWSDHAN.js";
27
+ } from "../chunk-HQSTVSDO.js";
28
28
  import "../chunk-6ICPEJY5.js";
29
- import "../chunk-F3R6NNUT.js";
30
- import "../chunk-B7NY7IOT.js";
29
+ import "../chunk-QNMJJMZF.js";
30
+ import "../chunk-6X7GXEBI.js";
31
31
  import "../chunk-CINBAX5G.js";
32
32
  import {
33
33
  readJsonSafe,
34
34
  writeJsonAtomic
35
35
  } from "../chunk-PM2NRK6Y.js";
36
- import "../chunk-HKQ6XCNT.js";
36
+ import "../chunk-JNPWASVJ.js";
37
37
  import {
38
38
  EXIT
39
39
  } from "../chunk-BG4HHB7E.js";
40
40
  import "../chunk-CXQWDQCJ.js";
41
41
  import {
42
42
  isRecord
43
- } from "../chunk-JAZIUZOL.js";
43
+ } from "../chunk-YBTS5ZR3.js";
44
44
  import "../chunk-MLKGABMK.js";
45
45
 
46
46
  // bin/pushary-bell.ts
@@ -1,31 +1,31 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  exitOnFailedResponse
4
- } from "../chunk-2ECFTUS4.js";
5
- import "../chunk-3SYN4CZY.js";
6
- import "../chunk-NB72LXU3.js";
4
+ } from "../chunk-33IU43ZR.js";
5
+ import "../chunk-2BW7GNNB.js";
6
+ import "../chunk-XHEF2MQZ.js";
7
7
  import {
8
8
  createIo
9
- } from "../chunk-IWHNP4G6.js";
9
+ } from "../chunk-K5LHDTYS.js";
10
10
  import {
11
11
  exitOnHelpFlag
12
- } from "../chunk-46AKZ7HL.js";
12
+ } from "../chunk-ETZUDUCB.js";
13
13
  import {
14
14
  parseFlags
15
15
  } from "../chunk-BZIBNSQE.js";
16
- import "../chunk-KYTIMYSH.js";
16
+ import "../chunk-QUU74XFH.js";
17
17
  import {
18
18
  pusharyFetch
19
- } from "../chunk-2H224XIR.js";
20
- import "../chunk-O2UTXGB3.js";
21
- import "../chunk-G4WDZ3HX.js";
22
- import "../chunk-XIWSDHAN.js";
19
+ } from "../chunk-B6RL3XXW.js";
20
+ import "../chunk-SMI5X7BO.js";
21
+ import "../chunk-5ZX57DNR.js";
22
+ import "../chunk-HQSTVSDO.js";
23
23
  import "../chunk-6ICPEJY5.js";
24
- import "../chunk-F3R6NNUT.js";
24
+ import "../chunk-QNMJJMZF.js";
25
25
  import {
26
26
  getApiKey,
27
27
  getBaseUrl
28
- } from "../chunk-B7NY7IOT.js";
28
+ } from "../chunk-6X7GXEBI.js";
29
29
  import {
30
30
  UsageError,
31
31
  exitCodeFor
@@ -34,7 +34,7 @@ import "../chunk-PM2NRK6Y.js";
34
34
  import {
35
35
  NPX_LATEST_COMMAND,
36
36
  isInvocationOf
37
- } from "../chunk-HKQ6XCNT.js";
37
+ } from "../chunk-JNPWASVJ.js";
38
38
  import {
39
39
  EXIT
40
40
  } from "../chunk-BG4HHB7E.js";
@@ -44,7 +44,7 @@ import {
44
44
  PHONE_CALL_SETUP_TEST_CALL_PARAM,
45
45
  parsePhoneCallSetupReply,
46
46
  parseTestCallReply
47
- } from "../chunk-JAZIUZOL.js";
47
+ } from "../chunk-YBTS5ZR3.js";
48
48
  import "../chunk-MLKGABMK.js";
49
49
 
50
50
  // bin/pushary-calls.ts