@pushary/agent-hooks 1.9.158 → 1.9.162

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 (146) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +1 -0
  3. package/dist/{api-MRFKFDVV.js → api-7NPCSUGY.js} +17 -13
  4. package/dist/bin/pushary-audit.js +7 -7
  5. package/dist/bin/pushary-bell-hook.js +31 -31
  6. package/dist/bin/pushary-bell.js +16 -16
  7. package/dist/bin/pushary-calls.d.ts +1 -0
  8. package/dist/bin/pushary-calls.js +287 -0
  9. package/dist/bin/pushary-claude.js +37 -37
  10. package/dist/bin/pushary-clean.js +47 -45
  11. package/dist/bin/pushary-codex-bridge.js +27 -27
  12. package/dist/bin/pushary-codex-hook.js +197 -60
  13. package/dist/bin/pushary-codex-session.js +8 -8
  14. package/dist/bin/pushary-codex.js +19 -19
  15. package/dist/bin/pushary-connect.js +41 -40
  16. package/dist/bin/pushary-cowork.js +6 -6
  17. package/dist/bin/pushary-daemon.js +52 -51
  18. package/dist/bin/pushary-disconnect.js +39 -37
  19. package/dist/bin/pushary-display-hook.js +20 -1
  20. package/dist/bin/pushary-doctor.js +61 -59
  21. package/dist/bin/pushary-elicitation-hook.js +32 -32
  22. package/dist/bin/pushary-gemini-bridge.js +19 -19
  23. package/dist/bin/pushary-gemini-hook.js +36 -36
  24. package/dist/bin/pushary-hook.js +39 -38
  25. package/dist/bin/pushary-login.js +28 -28
  26. package/dist/bin/pushary-logout.js +34 -33
  27. package/dist/bin/pushary-mcp.js +15 -15
  28. package/dist/bin/pushary-mode.js +21 -21
  29. package/dist/bin/pushary-notification-hook.js +30 -30
  30. package/dist/bin/pushary-opencode-hook.js +399 -45
  31. package/dist/bin/pushary-permission-denied-hook.js +39 -38
  32. package/dist/bin/pushary-permission-hook.js +39 -38
  33. package/dist/bin/pushary-post-hook.js +31 -31
  34. package/dist/bin/pushary-prompt-hook.js +30 -30
  35. package/dist/bin/pushary-session-end-hook.js +30 -30
  36. package/dist/bin/pushary-session-start-hook.js +41 -40
  37. package/dist/bin/pushary-setup.js +73 -72
  38. package/dist/bin/pushary-stats.js +6 -6
  39. package/dist/bin/pushary-status.js +40 -39
  40. package/dist/bin/pushary-stop-hook.js +30 -30
  41. package/dist/bin/pushary-stopfailure-hook.js +30 -30
  42. package/dist/bin/pushary-suggestions.js +21 -21
  43. package/dist/bin/pushary-transcript-register.js +21 -21
  44. package/dist/bin/pushary-transcripts.js +32 -32
  45. package/dist/bin/pushary-upgrade.js +50 -49
  46. package/dist/bin/pushary-wait.js +23 -23
  47. package/dist/bin/pushary.js +10 -9
  48. package/dist/{chunk-RRVFN432.js → chunk-2H7SDIM7.js} +1 -1
  49. package/dist/{chunk-DHI3X5WK.js → chunk-44DRCGP2.js} +2 -2
  50. package/dist/chunk-4IBUBMMP.js +885 -0
  51. package/dist/{chunk-RL5JLDRE.js → chunk-4U3GYVIW.js} +2 -2
  52. package/dist/{chunk-NW63PGKF.js → chunk-53IBMDX2.js} +12 -7
  53. package/dist/{chunk-XNJ2HOEL.js → chunk-5TU26542.js} +3 -3
  54. package/dist/{chunk-UVWKMFLQ.js → chunk-5ZS73ZLX.js} +2 -2
  55. package/dist/{chunk-4SN4FHFZ.js → chunk-644AKJMN.js} +2 -2
  56. package/dist/{chunk-TZJR5ESF.js → chunk-6QQUGYH6.js} +7 -7
  57. package/dist/{chunk-4B5K6YIP.js → chunk-72SYV43F.js} +1 -1
  58. package/dist/{chunk-JKRQL2BL.js → chunk-A5DXHJVS.js} +5 -5
  59. package/dist/{chunk-K3OCYJPK.js → chunk-AP26EU5H.js} +3 -3
  60. package/dist/{chunk-MLPPQ556.js → chunk-AQKMKVAD.js} +13 -13
  61. package/dist/{chunk-N5SSADNW.js → chunk-BHT76IIB.js} +4 -4
  62. package/dist/{chunk-TMWXWBFP.js → chunk-BMOGTNLK.js} +6 -6
  63. package/dist/{chunk-SNQOEDZ2.js → chunk-CSDB5VTI.js} +1 -1
  64. package/dist/{chunk-YPFOTFEG.js → chunk-CWH4LBUW.js} +1 -1
  65. package/dist/{chunk-FTTSQAF4.js → chunk-DAMTDSAE.js} +1 -1
  66. package/dist/{chunk-MHYX5Q3F.js → chunk-DSWUG4NV.js} +1 -1
  67. package/dist/{chunk-K3I2NMEF.js → chunk-EFKJCBWA.js} +8 -8
  68. package/dist/{chunk-CIAJ55EQ.js → chunk-EKELMI3A.js} +42 -34
  69. package/dist/{chunk-EGBI4GRS.js → chunk-EPQTCF6A.js} +2 -2
  70. package/dist/{chunk-4WL2MINE.js → chunk-FIR2MGSB.js} +1 -1
  71. package/dist/{chunk-N2LWKWNY.js → chunk-G5IL6C6S.js} +3 -3
  72. package/dist/{chunk-IKC33YKC.js → chunk-G6M6YJK4.js} +5 -2
  73. package/dist/{chunk-SZMDRBNK.js → chunk-GJOHGES6.js} +2 -2
  74. package/dist/{chunk-TPLTB256.js → chunk-H7OY4AAT.js} +4 -4
  75. package/dist/{chunk-IVOELLUK.js → chunk-HAOYL5JP.js} +39 -8
  76. package/dist/{chunk-Q7WCDUFV.js → chunk-I35XT5YY.js} +6 -6
  77. package/dist/{chunk-AOP55JR2.js → chunk-I5ANEYUK.js} +14 -3
  78. package/dist/{chunk-TKBCLK4B.js → chunk-I5HCOOAA.js} +5 -5
  79. package/dist/{chunk-IIK3CZXJ.js → chunk-IUXXEM4Q.js} +8 -7
  80. package/dist/{chunk-FGVBFDNV.js → chunk-J6KDUXJF.js} +1 -1
  81. package/dist/{chunk-XHCX6DOY.js → chunk-JCTS7COD.js} +5 -5
  82. package/dist/{chunk-AGYD6XNI.js → chunk-L3LFCZ5D.js} +3 -3
  83. package/dist/{chunk-3QU4WXAH.js → chunk-L44II2WD.js} +5 -5
  84. package/dist/{chunk-PBPQRJ2T.js → chunk-L6BMVCQQ.js} +5 -5
  85. package/dist/{chunk-LVZBLKAU.js → chunk-L6NG6EZS.js} +1 -1
  86. package/dist/{chunk-EHRWEXRN.js → chunk-LGR7WXI5.js} +2 -2
  87. package/dist/{chunk-2MPT7YQK.js → chunk-LQDIOUVU.js} +5 -3
  88. package/dist/{chunk-XSIZKQ2C.js → chunk-LVRFOGQY.js} +11 -11
  89. package/dist/{chunk-HA2SRYYP.js → chunk-M2ZGNZRS.js} +94 -0
  90. package/dist/{chunk-ZYDE6QRW.js → chunk-M74WT5NA.js} +3 -3
  91. package/dist/chunk-NX3Y36VY.js +242 -0
  92. package/dist/{chunk-ANQBLZAE.js → chunk-OH2WAG47.js} +1 -1
  93. package/dist/{chunk-GTYVNVBZ.js → chunk-P4KAYIMX.js} +4 -4
  94. package/dist/{chunk-4I2SHNEU.js → chunk-PIIKLAFY.js} +3 -3
  95. package/dist/{chunk-J7HSUQK2.js → chunk-QKNHNDOY.js} +3 -3
  96. package/dist/{chunk-ALQWZCUT.js → chunk-RKURAOFK.js} +4 -4
  97. package/dist/{chunk-TYBVQ33X.js → chunk-RUAGEPUJ.js} +6 -6
  98. package/dist/{chunk-IOKJJ2SY.js → chunk-SFYX32FX.js} +4 -4
  99. package/dist/{chunk-OCWXE4PR.js → chunk-SKA3U7QI.js} +11 -9
  100. package/dist/{chunk-X254TRBU.js → chunk-SQ4RPZ6O.js} +4 -4
  101. package/dist/chunk-SRSXZINE.js +18 -0
  102. package/dist/{chunk-CAMFNSJS.js → chunk-SVVZFXDX.js} +6 -6
  103. package/dist/{chunk-QVVBU2JU.js → chunk-SVWCMYR7.js} +24 -9
  104. package/dist/{chunk-MTITL2IG.js → chunk-TMDCIVZ2.js} +5 -5
  105. package/dist/{chunk-B3BOAYRO.js → chunk-TUXX7TKR.js} +3 -3
  106. package/dist/{chunk-CSZWWPNS.js → chunk-U4LHE5DH.js} +1 -1
  107. package/dist/{chunk-3UNZ7HRN.js → chunk-UBY7NJCU.js} +20 -18
  108. package/dist/{chunk-ORQ7THNZ.js → chunk-UPCIKGWA.js} +1 -1
  109. package/dist/{chunk-WIIMW5YO.js → chunk-UQTQ6HPO.js} +2 -0
  110. package/dist/{chunk-V36P4KS4.js → chunk-V3TWYF32.js} +1 -1
  111. package/dist/{chunk-N3CFEMLS.js → chunk-VGLIGBAJ.js} +6 -6
  112. package/dist/{chunk-PND5IGC7.js → chunk-VUGF2OC7.js} +6 -6
  113. package/dist/{chunk-APCJZFTJ.js → chunk-W3FE7GTH.js} +1 -1
  114. package/dist/{chunk-GHHVXARK.js → chunk-WCWWO5QL.js} +1 -1
  115. package/dist/{chunk-TSR3FPGL.js → chunk-WIFMTEQI.js} +1 -1
  116. package/dist/{chunk-AMIUB22C.js → chunk-WWSR5LMP.js} +1 -1
  117. package/dist/{chunk-CCKY3JDB.js → chunk-X5QSIMXA.js} +4 -4
  118. package/dist/{chunk-T3PZQNIK.js → chunk-XIICM4TX.js} +2 -2
  119. package/dist/{chunk-C6PAIHLP.js → chunk-XOSSXRIR.js} +10 -10
  120. package/dist/{chunk-QP3TCKRZ.js → chunk-Y3ELKLNH.js} +18 -16
  121. package/dist/{chunk-H6CL3T2S.js → chunk-Y6ILCLKE.js} +1 -1
  122. package/dist/{chunk-UDLWNOXX.js → chunk-YEVRMDG7.js} +2 -2
  123. package/dist/{chunk-CS4Z44F5.js → chunk-YH6EHCKQ.js} +87 -8
  124. package/dist/{chunk-2L52USKM.js → chunk-YPG3RXWO.js} +3 -3
  125. package/dist/{chunk-AZZNHW3R.js → chunk-YUF3AYAP.js} +9 -6
  126. package/dist/{chunk-4NHQAMSK.js → chunk-Z23SHFIC.js} +4 -4
  127. package/dist/{chunk-6GGK3T24.js → chunk-ZC42UG7B.js} +5 -5
  128. package/dist/{chunk-UPI3JDHZ.js → chunk-ZT55PJSW.js} +3 -3
  129. package/dist/{chunk-PI3BOI3A.js → chunk-ZWNFP4HZ.js} +1 -1
  130. package/dist/{codex-app-cards-switch-CXXDGH7R.js → codex-app-cards-switch-PJEY3EU5.js} +14 -14
  131. package/dist/{codex-card-routing-WP4IHJFN.js → codex-card-routing-MNAMCRPO.js} +2 -2
  132. package/dist/{codex-desktop-launch-EN7ACHC6.js → codex-desktop-launch-AUNDRYOL.js} +1 -1
  133. package/dist/{codex-session-launch-7BV4VTJW.js → codex-session-launch-IZNSTT7N.js} +23 -23
  134. package/dist/{config-SZMMBOJV.js → config-LG2RJO37.js} +4 -4
  135. package/dist/{global-upgrade-I5J6BDHA.js → global-upgrade-QE5Q3BYW.js} +11 -11
  136. package/dist/{identity-GLJNTNHW.js → identity-3BT6LWOP.js} +5 -5
  137. package/dist/{live-capabilities-AYO7FOHS.js → live-capabilities-IKTQBLVH.js} +5 -5
  138. package/dist/{paths-NRBEF3T2.js → paths-VEUTZJOY.js} +4 -4
  139. package/dist/reapply-BC2AF55M.js +69 -0
  140. package/dist/src/index.js +39 -38
  141. package/dist/{upgrade-lock-H6SU7MJR.js → upgrade-lock-NUGEPR75.js} +5 -5
  142. package/dist/usage-TEB5CX2Y.js +11 -0
  143. package/package.json +2 -1
  144. package/dist/chunk-GLDSXDRV.js +0 -593
  145. package/dist/reapply-J2QUV7J2.js +0 -68
  146. package/dist/usage-MY3DIFBG.js +0 -11
@@ -1,39 +1,41 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  takeHookHoldBudget
4
- } from "../chunk-LVZBLKAU.js";
5
- import {
6
- askAgentQuestions,
7
- defersToNativeMode
8
- } from "../chunk-CIAJ55EQ.js";
4
+ } from "../chunk-L6NG6EZS.js";
9
5
  import {
10
6
  parseCodexHookInput,
11
7
  pushQuestionAndWait,
12
8
  scopeQuestionOf
13
- } from "../chunk-AZZNHW3R.js";
9
+ } from "../chunk-YUF3AYAP.js";
10
+ import {
11
+ defersToNativeMode
12
+ } from "../chunk-SRSXZINE.js";
13
+ import {
14
+ askAgentQuestions
15
+ } from "../chunk-EKELMI3A.js";
14
16
  import {
15
17
  reportMachineDenial
16
- } from "../chunk-UPI3JDHZ.js";
18
+ } from "../chunk-ZT55PJSW.js";
17
19
  import {
18
20
  isGatingMoment,
19
21
  recordKeylessMoment
20
- } from "../chunk-AMIUB22C.js";
22
+ } from "../chunk-WWSR5LMP.js";
21
23
  import {
22
24
  triggerAutoUpdate
23
- } from "../chunk-J7HSUQK2.js";
25
+ } from "../chunk-QKNHNDOY.js";
24
26
  import {
25
27
  readHookInput
26
- } from "../chunk-3QU4WXAH.js";
27
- import "../chunk-GTYVNVBZ.js";
28
+ } from "../chunk-L44II2WD.js";
29
+ import "../chunk-P4KAYIMX.js";
28
30
  import {
29
31
  announceSubscriptionRequired,
30
32
  isDeferAnswer
31
- } from "../chunk-YPFOTFEG.js";
32
- import "../chunk-C6PAIHLP.js";
33
+ } from "../chunk-CWH4LBUW.js";
34
+ import "../chunk-XOSSXRIR.js";
33
35
  import "../chunk-WHB622LP.js";
34
- import "../chunk-MTITL2IG.js";
35
- import "../chunk-K3I2NMEF.js";
36
- import "../chunk-TPLTB256.js";
36
+ import "../chunk-TMDCIVZ2.js";
37
+ import "../chunk-EFKJCBWA.js";
38
+ import "../chunk-H7OY4AAT.js";
37
39
  import {
38
40
  CODEX_AGENT,
39
41
  DEFAULT_SESSION,
@@ -65,7 +67,7 @@ import {
65
67
  toPolicyLookup,
66
68
  toPolicyLookups,
67
69
  userScope
68
- } from "../chunk-QP3TCKRZ.js";
70
+ } from "../chunk-Y3ELKLNH.js";
69
71
  import {
70
72
  codexReviewerDenialsSince,
71
73
  deriveActionBody,
@@ -78,18 +80,20 @@ import {
78
80
  scanCodexGuardianReviews,
79
81
  scopePathFor,
80
82
  sessionIdentityOf
81
- } from "../chunk-IKC33YKC.js";
82
- import "../chunk-FGVBFDNV.js";
83
- import "../chunk-V36P4KS4.js";
83
+ } from "../chunk-G6M6YJK4.js";
84
+ import "../chunk-J6KDUXJF.js";
85
+ import "../chunk-V3TWYF32.js";
84
86
  import "../chunk-YPY4YCIZ.js";
85
- import "../chunk-4I2SHNEU.js";
87
+ import "../chunk-PIIKLAFY.js";
86
88
  import "../chunk-352FIVVH.js";
87
- import "../chunk-APCJZFTJ.js";
89
+ import "../chunk-W3FE7GTH.js";
90
+ import "../chunk-Y6ILCLKE.js";
88
91
  import {
89
92
  repoKeyFor,
90
93
  repositoryScopeFor
91
- } from "../chunk-4WL2MINE.js";
94
+ } from "../chunk-FIR2MGSB.js";
92
95
  import {
96
+ ABANDONED_WAIT,
93
97
  cancelQuestion,
94
98
  claimBlockedAction,
95
99
  exitAfterClientReports,
@@ -97,38 +101,39 @@ import {
97
101
  isQuestionLimitRefusal,
98
102
  pollForAnswer,
99
103
  requestGate,
100
- sendNotification
101
- } from "../chunk-CS4Z44F5.js";
104
+ sendNotification,
105
+ sleepUnlessAborted,
106
+ withdrawQuestion
107
+ } from "../chunk-YH6EHCKQ.js";
108
+ import "../chunk-OH2WAG47.js";
102
109
  import "../chunk-POFBE6ZY.js";
103
110
  import {
104
111
  SubscriptionRequiredError
105
- } from "../chunk-TZJR5ESF.js";
106
- import "../chunk-PBPQRJ2T.js";
107
- import "../chunk-PND5IGC7.js";
108
- import "../chunk-H6CL3T2S.js";
109
- import "../chunk-ANQBLZAE.js";
110
- import "../chunk-TSR3FPGL.js";
112
+ } from "../chunk-6QQUGYH6.js";
113
+ import "../chunk-WIFMTEQI.js";
114
+ import "../chunk-L6BMVCQQ.js";
115
+ import "../chunk-VUGF2OC7.js";
111
116
  import {
112
117
  getMachineId
113
- } from "../chunk-MHYX5Q3F.js";
114
- import "../chunk-YU2EUD7O.js";
115
- import "../chunk-ZYDE6QRW.js";
116
- import "../chunk-UDLWNOXX.js";
118
+ } from "../chunk-DSWUG4NV.js";
119
+ import "../chunk-M74WT5NA.js";
120
+ import "../chunk-YEVRMDG7.js";
117
121
  import {
118
122
  canonicalJson
119
- } from "../chunk-B3BOAYRO.js";
120
- import "../chunk-IVOELLUK.js";
123
+ } from "../chunk-TUXX7TKR.js";
124
+ import "../chunk-HAOYL5JP.js";
121
125
  import {
122
126
  getApiKey
123
- } from "../chunk-FTTSQAF4.js";
124
- import {
125
- EXIT
126
- } from "../chunk-BG4HHB7E.js";
127
+ } from "../chunk-DAMTDSAE.js";
128
+ import "../chunk-YU2EUD7O.js";
127
129
  import {
128
130
  writeFileAtomic
129
131
  } from "../chunk-TODDEIYG.js";
130
- import "../chunk-AOP55JR2.js";
131
- import "../chunk-WIIMW5YO.js";
132
+ import {
133
+ EXIT
134
+ } from "../chunk-BG4HHB7E.js";
135
+ import "../chunk-I5ANEYUK.js";
136
+ import "../chunk-UQTQ6HPO.js";
132
137
  import {
133
138
  CODEX_RESCUE_STOP_RESERVE_SECONDS,
134
139
  CODEX_RESCUE_TOOL_NAME,
@@ -149,20 +154,136 @@ import {
149
154
  editGoesToTheAgentsPrompt,
150
155
  effectiveWaitSeconds,
151
156
  hookHoldWindowMs,
157
+ hookMaxWaitSeconds,
152
158
  hookWaitDeadline,
153
159
  isCodexQuestionTool,
160
+ isGateRefusal,
154
161
  isPusharyOwnTool,
155
162
  parseCodexQuestions,
156
163
  questionHandedToTheTerminal,
157
164
  refusesWhenUnanswered,
158
165
  resolveGate,
159
166
  unapprovedScopeReason
160
- } from "../chunk-HA2SRYYP.js";
167
+ } from "../chunk-M2ZGNZRS.js";
161
168
  import "../chunk-MLKGABMK.js";
162
169
 
163
170
  // bin/pushary-codex-hook.ts
164
171
  import { basename } from "path";
165
172
 
173
+ // src/rule-watched-ask.ts
174
+ var SLOT_RETRY_MS = 5e3;
175
+ var MAX_SLOT_WAIT_SECONDS = 30;
176
+ var RULE_READ_BEFORE_RETRY_MS = 3e3;
177
+ var QUESTION_CREATE_ALLOWANCE_MS = 5e3;
178
+ var SLOT_ATTEMPT_MARGIN_MS = RULE_READ_BEFORE_RETRY_MS + QUESTION_CREATE_ALLOWANCE_MS;
179
+ var FIRST_RULE_RECHECK_MS = 4e3;
180
+ var LONGEST_RULE_RECHECK_MS = 15e3;
181
+ var RULE_RECHECK_GROWTH = 1.5;
182
+ var NO_RULE_CHANGE = { kind: "none" };
183
+ var RULE_ALLOWS = { kind: "allows" };
184
+ var COVERED_BY_RULE = { kind: "covered_by_rule" };
185
+ var NO_FREE_SLOT = { kind: "no_free_slot" };
186
+ var lastSlotAttemptAt = (startMs, waitSeconds, agent) => {
187
+ const budgetMs = hookMaxWaitSeconds(agent) * 1e3;
188
+ const windowMs = Math.min(Math.max(waitSeconds, 0) * 1e3, budgetMs);
189
+ const slotWaitMs = Math.min(windowMs, budgetMs - windowMs - SLOT_ATTEMPT_MARGIN_MS, MAX_SLOT_WAIT_SECONDS * 1e3);
190
+ return startMs + Math.max(slotWaitMs, 0);
191
+ };
192
+ var nextRuleRecheckMs = (previousMs) => Math.min(Math.round(previousMs * RULE_RECHECK_GROWTH), LONGEST_RULE_RECHECK_MS);
193
+ var ruleChangeOf = (verdict) => {
194
+ if (verdict.kind === "allow") return RULE_ALLOWS;
195
+ if (isGateRefusal(verdict)) return { kind: "refuses", verdict };
196
+ return NO_RULE_CHANGE;
197
+ };
198
+ var readRuleChange = async (deps, signal) => {
199
+ if (!deps.readsRules) return NO_RULE_CHANGE;
200
+ try {
201
+ return ruleChangeOf(await deps.readsRules(signal));
202
+ } catch {
203
+ return NO_RULE_CHANGE;
204
+ }
205
+ };
206
+ var readRuleChangeWithin = async (deps, limitMs) => {
207
+ const readOver = new AbortController();
208
+ const timeUp = deps.sleep(limitMs, readOver.signal).then(() => NO_RULE_CHANGE, () => NO_RULE_CHANGE);
209
+ try {
210
+ return await Promise.race([readRuleChange(deps, readOver.signal), timeUp]);
211
+ } finally {
212
+ readOver.abort();
213
+ }
214
+ };
215
+ var ruleSettlesAFailedAsk = (change, error) => change.kind === "refuses" || isQuestionLimitRefusal(error);
216
+ var outcomeOfRuleChange = (change) => {
217
+ if (change.kind === "allows") return COVERED_BY_RULE;
218
+ if (change.kind === "refuses") return { kind: "refused_by_rule", verdict: change.verdict };
219
+ return null;
220
+ };
221
+ var watchForARuleChange = async (deps, waitOver) => {
222
+ let intervalMs = FIRST_RULE_RECHECK_MS;
223
+ while (!waitOver.aborted) {
224
+ await deps.sleep(intervalMs, waitOver);
225
+ if (waitOver.aborted) return NO_RULE_CHANGE;
226
+ const change = await readRuleChange(deps, waitOver);
227
+ if (change.kind !== "none" && !waitOver.aborted) return change;
228
+ intervalMs = nextRuleRecheckMs(intervalMs);
229
+ }
230
+ return NO_RULE_CHANGE;
231
+ };
232
+ var isSettled = (answer) => answer.answered || isDecisionStopped(answer);
233
+ var wasAbandonedForARule = (answer) => answer.status === ABANDONED_WAIT.status;
234
+ var settleAfterARuleChange = async (deps, pushed, correlationId, change) => {
235
+ const late = correlationId.length > 0 ? await deps.withdraw(correlationId) : pushed.answer;
236
+ if (change.kind === "refuses") return { kind: "refused_by_rule", verdict: change.verdict };
237
+ return isSettled(late) ? { kind: "pushed", pushed: { ...pushed, answer: late } } : COVERED_BY_RULE;
238
+ };
239
+ var pushWatchingForARule = async (deps) => {
240
+ const ruleChanged = new AbortController();
241
+ const waitOver = new AbortController();
242
+ let correlationId = "";
243
+ let change = NO_RULE_CHANGE;
244
+ if (deps.readsRules) {
245
+ void watchForARuleChange(deps, waitOver.signal).catch(() => NO_RULE_CHANGE).then((seen) => {
246
+ if (seen.kind === "none") return;
247
+ change = seen;
248
+ ruleChanged.abort();
249
+ });
250
+ }
251
+ try {
252
+ let pushed;
253
+ try {
254
+ pushed = await deps.push({
255
+ signal: ruleChanged.signal,
256
+ onQuestionCreated: (created) => {
257
+ correlationId = created;
258
+ }
259
+ });
260
+ } catch (error) {
261
+ const ruled = ruleSettlesAFailedAsk(change, error) ? outcomeOfRuleChange(change) : null;
262
+ if (ruled) return ruled;
263
+ throw error;
264
+ }
265
+ if (change.kind === "none" || !wasAbandonedForARule(pushed.answer)) return { kind: "pushed", pushed };
266
+ return await settleAfterARuleChange(deps, pushed, correlationId, change);
267
+ } finally {
268
+ waitOver.abort();
269
+ }
270
+ };
271
+ var slotRetryStillFits = (deps) => deps.now() + SLOT_RETRY_MS <= deps.lastSlotAttemptAtMs;
272
+ var ruleOutcomeBeforeRetry = async (deps) => outcomeOfRuleChange(await readRuleChangeWithin(deps, RULE_READ_BEFORE_RETRY_MS));
273
+ var askWatchingForARule = async (deps) => {
274
+ for (; ; ) {
275
+ try {
276
+ return await pushWatchingForARule(deps);
277
+ } catch (error) {
278
+ if (!isQuestionLimitRefusal(error)) throw error;
279
+ }
280
+ if (!slotRetryStillFits(deps)) return NO_FREE_SLOT;
281
+ await deps.sleep(SLOT_RETRY_MS);
282
+ const ruled = await ruleOutcomeBeforeRetry(deps);
283
+ if (ruled) return ruled;
284
+ }
285
+ };
286
+
166
287
  // src/codex-call-decision.ts
167
288
  import { createHash } from "crypto";
168
289
  var CODEX_DECISION_TTL_MS = 60 * 1e3;
@@ -598,7 +719,7 @@ var callKeyFor = (input) => codexCallKey({
598
719
  var START_MS2 = Date.now();
599
720
  var agentNameFor = (input) => `Codex - ${basename(input.cwd ?? process.cwd())}`;
600
721
  var describeFor = (input, lookup) => input.tool_name === "apply_patch" ? describeApplyPatch(input.tool_input?.command) ?? describeToolCall(lookup.tool, lookup.input, "hook") : describeToolCall(lookup.tool, lookup.input, "hook");
601
- var pushQuestion = (apiKey, input, lookup, waitSeconds, mode, noLocalSurface, scope) => {
722
+ var pushQuestion = (apiKey, input, lookup, waitSeconds, mode, noLocalSurface, scope, watch) => {
602
723
  const description = describeFor(input, lookup);
603
724
  return pushQuestionAndWait(apiKey, {
604
725
  description,
@@ -622,7 +743,7 @@ var pushQuestion = (apiKey, input, lookup, waitSeconds, mode, noLocalSurface, sc
622
743
  // the same way, instead of putting the same approval on the phone twice.
623
744
  toolUseId: input.tool_use_id
624
745
  }
625
- }, { agent: "codex", startMs: START_MS2, waitSeconds, askFailure: "wait_as_unavailable" });
746
+ }, { agent: "codex", startMs: START_MS2, waitSeconds, askFailure: "wait_as_unavailable", signal: watch?.signal, onQuestionCreated: watch?.onQuestionCreated });
626
747
  };
627
748
  var codexStepsAside = (error, input) => {
628
749
  announceSubscriptionRequired(error.upgradeUrl, input.session_id);
@@ -641,12 +762,12 @@ var notifyApprovalNeeded = async (apiKey, input, lookup) => {
641
762
  } catch {
642
763
  }
643
764
  };
644
- var codexGate = async (apiKey, input) => {
645
- const modeState = await fetchModeState(apiKey, input.session_id);
765
+ var codexGate = async (apiKey, input, signal) => {
766
+ const modeState = await fetchModeState(apiKey, input.session_id, 0, signal);
646
767
  const policyRequest = policyRequestFor("codex");
647
768
  const lookup = toPolicyLookup(input.tool_name ?? "", input.tool_input ?? {}, input.cwd);
648
769
  const lookups = toPolicyLookups(input.tool_name ?? "", input.tool_input ?? {}, input.cwd);
649
- const config = await getPolicy(apiKey, modeState.policyVersion, policyRequest.agent, policyRequest.repoAware, input.session_id);
770
+ const config = await getPolicy(apiKey, modeState.policyVersion, policyRequest.agent, policyRequest.repoAware, input.session_id, signal);
650
771
  const gateInput = {
651
772
  modeState,
652
773
  config,
@@ -661,6 +782,15 @@ var codexGate = async (apiKey, input) => {
661
782
  };
662
783
  return { verdict: resolveGate(gateInput), lookup, gateInput };
663
784
  };
785
+ var SCOPE_BREACH_ASKS_ONCE = { lastSlotAttemptAtMs: START_MS2 };
786
+ var ruleWatchFor = (apiKey, input, scope, waitSeconds) => scope ? SCOPE_BREACH_ASKS_ONCE : {
787
+ readsRules: async (signal) => (await codexGate(apiKey, input, signal)).verdict,
788
+ lastSlotAttemptAtMs: lastSlotAttemptAt(START_MS2, waitSeconds, "codex")
789
+ };
790
+ var refusedByRule = async (input, lookup, verdict) => {
791
+ await reportMachineDenial({ ...input, tool_name: lookup.tool, tool_input: lookup.input }, verdict, CODEX_AGENT);
792
+ return codexDeny(verdict.kind === "kill" ? KILL_REASON : verdict.reason);
793
+ };
664
794
  var callsPusharysOwnTool = (input) => input.tool_name !== void 0 && isPusharyOwnTool(input.tool_name);
665
795
  var decidePermissionRequest = async (input) => {
666
796
  if (callsPusharysOwnTool(input)) return codexPass();
@@ -770,10 +900,7 @@ var decidePreToolUse = async (input) => {
770
900
  }
771
901
  try {
772
902
  const { verdict, lookup, gateInput } = await codexGate(apiKey, input);
773
- if (verdict.kind === "kill" || verdict.kind === "deny") {
774
- await reportMachineDenial({ ...input, tool_name: lookup.tool, tool_input: lookup.input }, verdict, CODEX_AGENT);
775
- return codexDeny(verdict.kind === "kill" ? KILL_REASON : verdict.reason);
776
- }
903
+ if (isGateRefusal(verdict)) return await refusedByRule(input, lookup, verdict);
777
904
  if (verdict.kind === "allow") return codexPass();
778
905
  if (isCodexQuestionTool(input.tool_name)) return await answerCodexQuestion(apiKey, input, verdict, gateInput.modeState);
779
906
  const scope = scopeQuestionOf(verdict);
@@ -791,17 +918,27 @@ var decidePreToolUse = async (input) => {
791
918
  if (scope && gateInput.toolInputs.length > 1) return recordPreToolUse(callKey, codexDeny(SCOPE_BATCH_REASON));
792
919
  const deliveryMode = delivery.policy.mode;
793
920
  if (deliveryMode === "push_only" || deliveryMode === "push_first") {
794
- let pushed;
921
+ const waitSeconds = effectiveWaitSeconds(toolPolicy.timeoutAction, toolPolicy.timeoutSeconds, "codex");
922
+ const noLocalSurface = codexHasNoPromptOfItsOwn(scope?.reason, input.permission_mode);
923
+ let asked;
795
924
  try {
796
- pushed = await pushQuestion(apiKey, input, lookup, effectiveWaitSeconds(toolPolicy.timeoutAction, toolPolicy.timeoutSeconds, "codex"), deliveryMode, codexHasNoPromptOfItsOwn(scope?.reason, input.permission_mode), scope);
925
+ asked = await askWatchingForARule({
926
+ push: (watch) => pushQuestion(apiKey, input, lookup, waitSeconds, deliveryMode, noLocalSurface, scope, watch),
927
+ withdraw: (correlationId) => withdrawQuestion(apiKey, correlationId),
928
+ sleep: sleepUnlessAborted,
929
+ now: Date.now,
930
+ ...ruleWatchFor(apiKey, input, scope, waitSeconds)
931
+ });
797
932
  } catch (error) {
798
933
  if (error instanceof SubscriptionRequiredError) return recordPreToolUse(callKey, codexStepsAside(error, input));
799
- if (isQuestionLimitRefusal(error)) {
800
- return recordPreToolUse(callKey, unansweredOutcome(scope, codexQuestionLimitDecision({ refusesUnanswered: refusesWhenUnanswered(delivery.policy), agentPromptFollows: false })));
801
- }
802
934
  return recordPreToolUse(callKey, codexDeny(UNVERIFIABLE_APPROVAL_REASON));
803
935
  }
804
- const { answer, localHandoff, clampCut, paused } = pushed;
936
+ if (asked.kind === "covered_by_rule") return codexPass();
937
+ if (asked.kind === "refused_by_rule") return await refusedByRule(input, lookup, asked.verdict);
938
+ if (asked.kind === "no_free_slot") {
939
+ return recordPreToolUse(callKey, unansweredOutcome(scope, codexQuestionLimitDecision({ refusesUnanswered: refusesWhenUnanswered(delivery.policy), agentPromptFollows: false })));
940
+ }
941
+ const { answer, localHandoff, clampCut, paused } = asked.pushed;
805
942
  if (isDecisionStopped(answer)) return codexDeny(DECISION_STOP_REASON);
806
943
  if (localHandoff) return recordPreToolUse(callKey, keyboardOutcome(deliveryMode, scope, toolPolicy));
807
944
  if (answer.answered) {
@@ -823,7 +960,7 @@ var decidePreToolUse = async (input) => {
823
960
  };
824
961
  var repairCodexHoldsQuietly = async () => {
825
962
  try {
826
- const { repairCodexHolds } = await import("../reapply-J2QUV7J2.js");
963
+ const { repairCodexHolds } = await import("../reapply-BC2AF55M.js");
827
964
  repairCodexHolds();
828
965
  } catch {
829
966
  return;
@@ -8,8 +8,8 @@ import "../chunk-MLKGABMK.js";
8
8
  var args = process.argv.slice(2);
9
9
  if (args[0] === "codex") args.shift();
10
10
  var appBehindTheProxy = args[0] === "--desktop-proxy" && args[2] === "--" ? args[1] : void 0;
11
- if (args[0] !== "--desktop-proxy") (await import("../usage-MY3DIFBG.js")).exitOnHelpFlag("codex");
12
- var loadWhatReadsTheAccount = () => Promise.all([import("../config-SZMMBOJV.js"), import("../identity-GLJNTNHW.js")]);
11
+ if (args[0] !== "--desktop-proxy") (await import("../usage-TEB5CX2Y.js")).exitOnHelpFlag("codex");
12
+ var loadWhatReadsTheAccount = () => Promise.all([import("../config-LG2RJO37.js"), import("../identity-3BT6LWOP.js")]);
13
13
  var loadedWhenThePassThroughStarted = appBehindTheProxy === void 0 ? null : loadWhatReadsTheAccount().catch(() => null);
14
14
  var desktopAccount = async () => {
15
15
  try {
@@ -19,7 +19,7 @@ var desktopAccount = async () => {
19
19
  return null;
20
20
  }
21
21
  };
22
- var desktopLaunch = await import("../codex-desktop-launch-EN7ACHC6.js").catch(() => null);
22
+ var desktopLaunch = await import("../codex-desktop-launch-AUNDRYOL.js").catch(() => null);
23
23
  if (desktopLaunch === null && appBehindTheProxy !== void 0) {
24
24
  process.exitCode = await letCodexRunWithoutPushary(appBehindTheProxy, args.slice(3));
25
25
  } else {
@@ -27,15 +27,15 @@ if (desktopLaunch === null && appBehindTheProxy !== void 0) {
27
27
  const stop = () => abort.abort();
28
28
  if (!args[0]?.startsWith("--desktop")) for (const signal of ["SIGINT", "SIGTERM", "SIGHUP"]) process.on(signal, stop);
29
29
  try {
30
- const { codexDesktopCommand } = desktopLaunch ?? await import("../codex-desktop-launch-EN7ACHC6.js");
30
+ const { codexDesktopCommand } = desktopLaunch ?? await import("../codex-desktop-launch-AUNDRYOL.js");
31
31
  const desktop = await codexDesktopCommand(args, [process.execPath, ...process.execArgv, process.argv[1], "codex"], desktopAccount);
32
32
  if (desktop !== null) process.exitCode = desktop;
33
33
  else {
34
34
  const [{ getApiKey, getBaseUrl }, { getMachineId }, { resolveProviderBinary }, { codexSessionDirectory, launchCodexSession }] = await Promise.all([
35
- import("../config-SZMMBOJV.js"),
36
- import("../identity-GLJNTNHW.js"),
37
- import("../live-capabilities-AYO7FOHS.js"),
38
- import("../codex-session-launch-7BV4VTJW.js")
35
+ import("../config-LG2RJO37.js"),
36
+ import("../identity-3BT6LWOP.js"),
37
+ import("../live-capabilities-IKTQBLVH.js"),
38
+ import("../codex-session-launch-IZNSTT7N.js")
39
39
  ]);
40
40
  const binary = resolveProviderBinary("codex");
41
41
  if (!binary) throw new Error("Install Codex first, then run pushary codex");
@@ -1,37 +1,37 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  reportEvent
4
- } from "../chunk-QP3TCKRZ.js";
5
- import "../chunk-IKC33YKC.js";
6
- import "../chunk-4WL2MINE.js";
4
+ } from "../chunk-Y3ELKLNH.js";
5
+ import "../chunk-G6M6YJK4.js";
6
+ import "../chunk-FIR2MGSB.js";
7
7
  import {
8
8
  askUser,
9
9
  isDecisionStopped,
10
10
  waitForAnswer
11
- } from "../chunk-CS4Z44F5.js";
11
+ } from "../chunk-YH6EHCKQ.js";
12
+ import "../chunk-OH2WAG47.js";
12
13
  import "../chunk-POFBE6ZY.js";
13
- import "../chunk-TZJR5ESF.js";
14
- import "../chunk-PBPQRJ2T.js";
15
- import "../chunk-PND5IGC7.js";
16
- import "../chunk-ANQBLZAE.js";
17
- import "../chunk-TSR3FPGL.js";
14
+ import "../chunk-6QQUGYH6.js";
15
+ import "../chunk-WIFMTEQI.js";
16
+ import "../chunk-L6BMVCQQ.js";
17
+ import "../chunk-VUGF2OC7.js";
18
18
  import {
19
19
  getMachineId
20
- } from "../chunk-MHYX5Q3F.js";
21
- import "../chunk-YU2EUD7O.js";
22
- import "../chunk-UDLWNOXX.js";
23
- import "../chunk-B3BOAYRO.js";
24
- import "../chunk-IVOELLUK.js";
20
+ } from "../chunk-DSWUG4NV.js";
21
+ import "../chunk-YEVRMDG7.js";
22
+ import "../chunk-TUXX7TKR.js";
23
+ import "../chunk-HAOYL5JP.js";
25
24
  import {
26
25
  getApiKey
27
- } from "../chunk-FTTSQAF4.js";
28
- import "../chunk-BG4HHB7E.js";
26
+ } from "../chunk-DAMTDSAE.js";
27
+ import "../chunk-YU2EUD7O.js";
29
28
  import "../chunk-TODDEIYG.js";
29
+ import "../chunk-BG4HHB7E.js";
30
30
  import {
31
31
  NPX_LATEST_COMMAND
32
- } from "../chunk-AOP55JR2.js";
33
- import "../chunk-WIIMW5YO.js";
34
- import "../chunk-HA2SRYYP.js";
32
+ } from "../chunk-I5ANEYUK.js";
33
+ import "../chunk-UQTQ6HPO.js";
34
+ import "../chunk-M2ZGNZRS.js";
35
35
  import "../chunk-MLKGABMK.js";
36
36
 
37
37
  // bin/pushary-codex.ts
@@ -2,10 +2,7 @@
2
2
  import {
3
3
  pairingComputerOf,
4
4
  planPairCommand
5
- } from "../chunk-4B5K6YIP.js";
6
- import {
7
- printKeyCheck
8
- } from "../chunk-IIK3CZXJ.js";
5
+ } from "../chunk-72SYV43F.js";
9
6
  import {
10
7
  canShowPairingQr,
11
8
  checkPhoneWithoutPairing,
@@ -15,72 +12,76 @@ import {
15
12
  pairAppWithThisComputer,
16
13
  pairingAgainHelps,
17
14
  printConnectInstructions
18
- } from "../chunk-CAMFNSJS.js";
15
+ } from "../chunk-SVVZFXDX.js";
19
16
  import "../chunk-3EGEA4KH.js";
20
- import "../chunk-TMWXWBFP.js";
21
- import "../chunk-DHI3X5WK.js";
17
+ import "../chunk-BMOGTNLK.js";
18
+ import {
19
+ printKeyCheck
20
+ } from "../chunk-IUXXEM4Q.js";
21
+ import "../chunk-44DRCGP2.js";
22
22
  import {
23
23
  detectedAgentChoices
24
- } from "../chunk-6GGK3T24.js";
24
+ } from "../chunk-ZC42UG7B.js";
25
25
  import "../chunk-OYIN77HO.js";
26
26
  import {
27
27
  CONNECTED_THROUGH_MAC_APP,
28
28
  PAIR_FROM_MAC_APP,
29
29
  readMacAppConnection
30
- } from "../chunk-X254TRBU.js";
31
- import "../chunk-SZMDRBNK.js";
30
+ } from "../chunk-SQ4RPZ6O.js";
32
31
  import "../chunk-QCGNGEGE.js";
33
- import "../chunk-CCKY3JDB.js";
34
- import "../chunk-GLDSXDRV.js";
32
+ import "../chunk-X5QSIMXA.js";
33
+ import "../chunk-NX3Y36VY.js";
34
+ import "../chunk-4IBUBMMP.js";
35
+ import "../chunk-GJOHGES6.js";
35
36
  import {
36
37
  ciMarker,
37
38
  createIo,
38
39
  describeCiReason
39
- } from "../chunk-GHHVXARK.js";
40
+ } from "../chunk-WCWWO5QL.js";
40
41
  import {
41
42
  exitOnHelpFlag
42
- } from "../chunk-T3PZQNIK.js";
43
+ } from "../chunk-XIICM4TX.js";
43
44
  import "../chunk-CYTPQDQY.js";
44
- import "../chunk-MTITL2IG.js";
45
- import "../chunk-TPLTB256.js";
46
- import "../chunk-QP3TCKRZ.js";
47
- import "../chunk-IKC33YKC.js";
48
- import "../chunk-FGVBFDNV.js";
49
- import "../chunk-V36P4KS4.js";
45
+ import "../chunk-TMDCIVZ2.js";
46
+ import "../chunk-H7OY4AAT.js";
47
+ import "../chunk-Y3ELKLNH.js";
48
+ import "../chunk-G6M6YJK4.js";
49
+ import "../chunk-J6KDUXJF.js";
50
+ import "../chunk-V3TWYF32.js";
50
51
  import {
51
52
  parseFlags
52
53
  } from "../chunk-YPY4YCIZ.js";
53
- import "../chunk-4WL2MINE.js";
54
- import "../chunk-CS4Z44F5.js";
54
+ import "../chunk-Y6ILCLKE.js";
55
+ import "../chunk-FIR2MGSB.js";
56
+ import "../chunk-YH6EHCKQ.js";
57
+ import "../chunk-OH2WAG47.js";
55
58
  import "../chunk-POFBE6ZY.js";
56
- import "../chunk-TZJR5ESF.js";
59
+ import "../chunk-6QQUGYH6.js";
60
+ import "../chunk-WIFMTEQI.js";
57
61
  import {
58
62
  checkApiKey
59
- } from "../chunk-PBPQRJ2T.js";
60
- import "../chunk-PND5IGC7.js";
61
- import "../chunk-H6CL3T2S.js";
62
- import "../chunk-ANQBLZAE.js";
63
- import "../chunk-TSR3FPGL.js";
64
- import "../chunk-MHYX5Q3F.js";
63
+ } from "../chunk-L6BMVCQQ.js";
64
+ import "../chunk-VUGF2OC7.js";
65
+ import "../chunk-DSWUG4NV.js";
66
+ import {
67
+ readKeySource
68
+ } from "../chunk-M74WT5NA.js";
69
+ import "../chunk-YEVRMDG7.js";
70
+ import "../chunk-TUXX7TKR.js";
71
+ import "../chunk-HAOYL5JP.js";
72
+ import "../chunk-DAMTDSAE.js";
65
73
  import {
66
74
  UsageError
67
75
  } from "../chunk-YU2EUD7O.js";
68
- import {
69
- readKeySource
70
- } from "../chunk-ZYDE6QRW.js";
71
- import "../chunk-UDLWNOXX.js";
72
- import "../chunk-B3BOAYRO.js";
73
- import "../chunk-IVOELLUK.js";
74
- import "../chunk-FTTSQAF4.js";
76
+ import "../chunk-TODDEIYG.js";
75
77
  import {
76
78
  EXIT
77
79
  } from "../chunk-BG4HHB7E.js";
78
- import "../chunk-TODDEIYG.js";
79
80
  import {
80
81
  isInvocationOf
81
- } from "../chunk-AOP55JR2.js";
82
- import "../chunk-WIIMW5YO.js";
83
- import "../chunk-HA2SRYYP.js";
82
+ } from "../chunk-I5ANEYUK.js";
83
+ import "../chunk-UQTQ6HPO.js";
84
+ import "../chunk-M2ZGNZRS.js";
84
85
  import "../chunk-MLKGABMK.js";
85
86
 
86
87
  // bin/pushary-connect.ts
@@ -2,15 +2,15 @@
2
2
  import {
3
3
  coworkOutput,
4
4
  parseCoworkOptions
5
- } from "../chunk-XNJ2HOEL.js";
5
+ } from "../chunk-5TU26542.js";
6
6
  import {
7
7
  canOpenBrowser,
8
8
  openInBrowser
9
9
  } from "../chunk-PUZZELE6.js";
10
10
  import {
11
11
  exitOnHelpFlag
12
- } from "../chunk-T3PZQNIK.js";
13
- import "../chunk-FGVBFDNV.js";
12
+ } from "../chunk-XIICM4TX.js";
13
+ import "../chunk-J6KDUXJF.js";
14
14
  import "../chunk-YPY4YCIZ.js";
15
15
  import {
16
16
  UsageError
@@ -18,11 +18,11 @@ import {
18
18
  import {
19
19
  EXIT
20
20
  } from "../chunk-BG4HHB7E.js";
21
- import "../chunk-AOP55JR2.js";
22
- import "../chunk-WIIMW5YO.js";
21
+ import "../chunk-I5ANEYUK.js";
22
+ import "../chunk-UQTQ6HPO.js";
23
23
  import {
24
24
  CLAUDE_CONNECTOR_GUIDE
25
- } from "../chunk-HA2SRYYP.js";
25
+ } from "../chunk-M2ZGNZRS.js";
26
26
  import "../chunk-MLKGABMK.js";
27
27
 
28
28
  // bin/pushary-cowork.ts