@pushary/agent-hooks 1.9.167 → 1.9.169

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 (142) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/data/openclaw-plugin/README.md +2 -2
  3. package/data/openclaw-plugin/dist/openclaw-write-guard.js +4 -0
  4. package/data/openclaw-plugin/dist/protected-writes.js +12 -3
  5. package/data/openclaw-plugin/package.json +1 -1
  6. package/dist/{api-7DCJGW6H.js → api-2NP643KP.js} +15 -11
  7. package/dist/bin/pushary-audit.js +3 -3
  8. package/dist/bin/pushary-bell-hook.js +28 -28
  9. package/dist/bin/pushary-bell.js +11 -11
  10. package/dist/bin/pushary-calls.js +15 -15
  11. package/dist/bin/pushary-claude.js +27 -27
  12. package/dist/bin/pushary-clean.js +38 -38
  13. package/dist/bin/pushary-codex-bridge.js +23 -23
  14. package/dist/bin/pushary-codex-hook.js +36 -36
  15. package/dist/bin/pushary-codex-session.js +8 -8
  16. package/dist/bin/pushary-codex.js +16 -16
  17. package/dist/bin/pushary-connect.js +34 -34
  18. package/dist/bin/pushary-cowork.js +5 -5
  19. package/dist/bin/pushary-daemon.js +45 -45
  20. package/dist/bin/pushary-disconnect.js +29 -29
  21. package/dist/bin/pushary-doctor.js +46 -46
  22. package/dist/bin/pushary-elicitation-hook.js +28 -28
  23. package/dist/bin/pushary-gemini-bridge.js +17 -17
  24. package/dist/bin/pushary-gemini-hook.js +32 -32
  25. package/dist/bin/pushary-hook.js +36 -36
  26. package/dist/bin/pushary-login.js +22 -22
  27. package/dist/bin/pushary-logout.js +29 -29
  28. package/dist/bin/pushary-mcp.js +12 -12
  29. package/dist/bin/pushary-mode.js +16 -16
  30. package/dist/bin/pushary-notification-hook.js +27 -27
  31. package/dist/bin/pushary-opencode-hook.js +135 -40
  32. package/dist/bin/pushary-permission-denied-hook.js +36 -36
  33. package/dist/bin/pushary-permission-hook.js +36 -36
  34. package/dist/bin/pushary-post-hook.js +28 -28
  35. package/dist/bin/pushary-prompt-hook.js +27 -27
  36. package/dist/bin/pushary-session-end-hook.js +27 -27
  37. package/dist/bin/pushary-session-start-hook.js +38 -38
  38. package/dist/bin/pushary-setup.js +54 -54
  39. package/dist/bin/pushary-stats.js +5 -5
  40. package/dist/bin/pushary-status.js +35 -35
  41. package/dist/bin/pushary-stop-hook.js +27 -27
  42. package/dist/bin/pushary-stopfailure-hook.js +27 -27
  43. package/dist/bin/pushary-suggestions.js +16 -16
  44. package/dist/bin/pushary-transcript-register.js +17 -17
  45. package/dist/bin/pushary-transcripts.js +25 -25
  46. package/dist/bin/pushary-upgrade.js +43 -43
  47. package/dist/bin/pushary-wait.js +16 -16
  48. package/dist/bin/pushary.js +7 -7
  49. package/dist/{chunk-JIJVIP6B.js → chunk-2SMEEXDR.js} +1 -1
  50. package/dist/{chunk-OHB4XCZT.js → chunk-2TRYSF64.js} +1 -1
  51. package/dist/{chunk-XSHGKPWN.js → chunk-3M4ZOSR3.js} +1 -1
  52. package/dist/{chunk-J2SH6BMP.js → chunk-4HLSCBES.js} +1 -1
  53. package/dist/{chunk-7JPXLFTJ.js → chunk-5N7MRVM3.js} +4 -4
  54. package/dist/{chunk-SG45DOSW.js → chunk-5Q2UDUR6.js} +2 -2
  55. package/dist/{chunk-P4KKTV6I.js → chunk-66VZIS6R.js} +1 -1
  56. package/dist/{chunk-O7QQO22I.js → chunk-6B2YKVX3.js} +2 -2
  57. package/dist/{chunk-3AK7A275.js → chunk-6IZVL42W.js} +1 -1
  58. package/dist/{chunk-HR67NNCI.js → chunk-6PDBRLIH.js} +5 -5
  59. package/dist/{chunk-EQUF4YXM.js → chunk-752NWYBD.js} +5 -5
  60. package/dist/{chunk-FXKXPDQH.js → chunk-7AENNOGX.js} +1 -1
  61. package/dist/{chunk-4Q2BXJKI.js → chunk-7DEAVAAS.js} +3 -3
  62. package/dist/{chunk-GWVT4TQN.js → chunk-7GMTA5NR.js} +10 -10
  63. package/dist/{chunk-5WH6NFNY.js → chunk-AIUFZQAA.js} +1 -1
  64. package/dist/{chunk-B6MT6HZQ.js → chunk-AO4CKFQA.js} +2 -2
  65. package/dist/{chunk-EEIYR2PU.js → chunk-AVIQZSCU.js} +1 -1
  66. package/dist/{chunk-AG2WP3R5.js → chunk-BIEJHRZG.js} +6 -5
  67. package/dist/{chunk-65A5VPDE.js → chunk-CCQZGWSR.js} +6 -6
  68. package/dist/{chunk-DRZLGR3F.js → chunk-CFZUESTS.js} +1 -1
  69. package/dist/{chunk-YTWNOHNK.js → chunk-CRTNHB6F.js} +3 -3
  70. package/dist/{chunk-CGNNCVSC.js → chunk-DXUPOVJP.js} +1 -1
  71. package/dist/{chunk-ZOEMN4PT.js → chunk-DYZ26IPH.js} +3 -3
  72. package/dist/{chunk-U2LU6NXY.js → chunk-EDCDODWA.js} +5 -5
  73. package/dist/{chunk-2MJDREYL.js → chunk-EGPOBJZG.js} +1 -1
  74. package/dist/{chunk-Q7S6ITE4.js → chunk-F7N6LYGG.js} +5 -5
  75. package/dist/{chunk-OTEHOBCC.js → chunk-FAORXDJ4.js} +4 -4
  76. package/dist/{chunk-6FTP2IGU.js → chunk-FUK2DC53.js} +4 -4
  77. package/dist/{chunk-DHMTIS7B.js → chunk-GV3ZGKMK.js} +3 -3
  78. package/dist/{chunk-QS5A5WBR.js → chunk-GVIKF73A.js} +1 -1
  79. package/dist/{chunk-PZH43ICC.js → chunk-HFI6SU27.js} +3 -3
  80. package/dist/{chunk-Y6QXHWZZ.js → chunk-HV7KTGWF.js} +7 -7
  81. package/dist/{chunk-GRBUY5ZC.js → chunk-IWWKO4MP.js} +4 -4
  82. package/dist/{chunk-7FBLMKLW.js → chunk-K24RAOIO.js} +2 -2
  83. package/dist/{chunk-YMO2IWHO.js → chunk-KEC67NZF.js} +5 -5
  84. package/dist/{chunk-SMT3YD6D.js → chunk-KX4Q4CKZ.js} +2 -2
  85. package/dist/{chunk-U6XGBWHB.js → chunk-L77OIGRB.js} +4 -2
  86. package/dist/{chunk-AB265IBW.js → chunk-LDUK7D2I.js} +6 -6
  87. package/dist/{chunk-JD4PIFZA.js → chunk-LEDGOYZV.js} +3 -3
  88. package/dist/{chunk-L35WZXWE.js → chunk-LGQUJFVZ.js} +2 -2
  89. package/dist/{chunk-HP74S2AZ.js → chunk-LL4TMEDG.js} +4 -4
  90. package/dist/{chunk-3AICHW2O.js → chunk-LOUSA3NO.js} +6 -6
  91. package/dist/{chunk-UCQJA73V.js → chunk-LVF5IBS6.js} +1 -1
  92. package/dist/{chunk-SSPDI2AU.js → chunk-LZU7ZDY7.js} +2 -2
  93. package/dist/{chunk-NJTMQOLV.js → chunk-MK7T7MNB.js} +1 -1
  94. package/dist/{chunk-SCJZGEYG.js → chunk-MOQUKAVU.js} +1 -1
  95. package/dist/{chunk-U5SZI6GP.js → chunk-MRTJ54MC.js} +3 -3
  96. package/dist/{chunk-NA2P74E6.js → chunk-NOHOCNY6.js} +4 -4
  97. package/dist/{chunk-ZUDFZNBQ.js → chunk-NRXFFCNG.js} +2 -2
  98. package/dist/{chunk-SZYXBY2H.js → chunk-OBUKF3WP.js} +4 -4
  99. package/dist/{chunk-BILK2RDJ.js → chunk-OI5OOFUY.js} +5 -5
  100. package/dist/{chunk-T4LDWOIG.js → chunk-ORTEANZH.js} +3 -3
  101. package/dist/{chunk-G5NBQSB5.js → chunk-OU7PO32D.js} +3 -3
  102. package/dist/{chunk-4AYUAZEK.js → chunk-PG5N3FL5.js} +12 -12
  103. package/dist/{chunk-5HYHDR2D.js → chunk-QCQADUHN.js} +4 -4
  104. package/dist/{chunk-VFFJSYJQ.js → chunk-QMVUDNQR.js} +4 -4
  105. package/dist/{chunk-XJ23WHWH.js → chunk-RY5EPLCY.js} +5 -5
  106. package/dist/{chunk-63TOLXOC.js → chunk-SD5K34T2.js} +1 -1
  107. package/dist/{chunk-C2AXJZNA.js → chunk-SSKNRWWS.js} +1 -1
  108. package/dist/{chunk-GLPVQBG6.js → chunk-TGIWLQOV.js} +5 -5
  109. package/dist/{chunk-57JWFFEI.js → chunk-TTTMOX73.js} +1 -1
  110. package/dist/{chunk-G5TR3F6L.js → chunk-UCND4JHN.js} +101 -23
  111. package/dist/{chunk-3FQGK5XX.js → chunk-UCW24KPU.js} +2 -2
  112. package/dist/{chunk-A23GU72F.js → chunk-UN36O6U6.js} +3 -3
  113. package/dist/{chunk-PI3L74XD.js → chunk-VWVYDYCV.js} +25 -9
  114. package/dist/{chunk-N7IF5QJ5.js → chunk-VY22KT5X.js} +3 -3
  115. package/dist/{chunk-XANRM6TE.js → chunk-W4NCWOVL.js} +1 -1
  116. package/dist/{chunk-5FYS2WJI.js → chunk-WDLBF3PM.js} +1 -1
  117. package/dist/{chunk-GJRRTSKA.js → chunk-WI2WYKSE.js} +1 -1
  118. package/dist/{chunk-PNZ5DTOG.js → chunk-WIOC6L6Y.js} +2 -2
  119. package/dist/{chunk-FZLALNEW.js → chunk-WK6TE6U7.js} +2 -2
  120. package/dist/{chunk-5H7HNGXQ.js → chunk-WTUURSCO.js} +5 -5
  121. package/dist/{chunk-XG7VMTTL.js → chunk-X7RPRBZE.js} +2 -2
  122. package/dist/{chunk-Z4RNXOJM.js → chunk-X7RR2ZQH.js} +6 -6
  123. package/dist/{chunk-4QFWQ337.js → chunk-XGNOM3XC.js} +2 -2
  124. package/dist/{chunk-H44MW5CL.js → chunk-XWLSZNXW.js} +9 -9
  125. package/dist/{chunk-L7B5RMS3.js → chunk-ZKMXHG5G.js} +8 -8
  126. package/dist/{chunk-GYQER2XO.js → chunk-ZXRBGLTI.js} +6 -6
  127. package/dist/{chunk-SFMMWJLD.js → chunk-ZXZEETHT.js} +18 -18
  128. package/dist/{chunk-7RTMQPNV.js → chunk-ZYH4KTY5.js} +15 -13
  129. package/dist/{codex-app-cards-switch-MO6URXIW.js → codex-app-cards-switch-C6OKN3RA.js} +11 -11
  130. package/dist/{codex-card-routing-7C4NT6VL.js → codex-card-routing-QGOX4RNI.js} +2 -2
  131. package/dist/{codex-desktop-launch-B57GFBK6.js → codex-desktop-launch-5ISZYYGG.js} +1 -1
  132. package/dist/{codex-session-launch-GOUPFBK5.js → codex-session-launch-JWT76ONU.js} +20 -20
  133. package/dist/{config-KCJBXXFC.js → config-PWEPWMNF.js} +3 -3
  134. package/dist/{global-upgrade-CX5FWDDN.js → global-upgrade-ZAPGSH66.js} +9 -9
  135. package/dist/{identity-JMYE6VRO.js → identity-O57FDCPL.js} +4 -4
  136. package/dist/{live-capabilities-YZFB7SNI.js → live-capabilities-FVRWXQAC.js} +4 -4
  137. package/dist/{paths-26C7U354.js → paths-LCARWI3S.js} +3 -3
  138. package/dist/{reapply-7QZ5CZEH.js → reapply-T5JXYBH2.js} +31 -31
  139. package/dist/src/index.js +35 -35
  140. package/dist/{upgrade-lock-24S6DVKT.js → upgrade-lock-3P3VK6KQ.js} +4 -4
  141. package/dist/{usage-23YN2SGZ.js → usage-BKT5P2P3.js} +3 -3
  142. package/package.json +1 -1
@@ -1,19 +1,19 @@
1
1
  import {
2
2
  macAppBridgeAvailable
3
- } from "./chunk-Z4RNXOJM.js";
3
+ } from "./chunk-X7RR2ZQH.js";
4
4
  import {
5
5
  keyPrefix
6
- } from "./chunk-ZOEMN4PT.js";
6
+ } from "./chunk-DYZ26IPH.js";
7
7
  import {
8
8
  bridgeAgentKey
9
- } from "./chunk-XG7VMTTL.js";
9
+ } from "./chunk-X7RPRBZE.js";
10
10
  import {
11
11
  readJsonSafe
12
12
  } from "./chunk-TODDEIYG.js";
13
13
  import {
14
14
  isRecord,
15
15
  isValidApiKey
16
- } from "./chunk-U6XGBWHB.js";
16
+ } from "./chunk-L77OIGRB.js";
17
17
 
18
18
  // src/shared-mcp-key.ts
19
19
  var asRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
@@ -3,24 +3,24 @@ import {
3
3
  expectedLaunchCapabilities,
4
4
  hasSpawnProvider,
5
5
  resolveControlPolicy
6
- } from "./chunk-JD4PIFZA.js";
6
+ } from "./chunk-LEDGOYZV.js";
7
7
  import {
8
8
  daemonHasRemoteProof,
9
9
  daemonServiceManagerAvailable,
10
10
  hasDaemonServiceDefinition,
11
11
  readDaemonNeedsLogin,
12
12
  readDaemonStatus
13
- } from "./chunk-AB265IBW.js";
13
+ } from "./chunk-LDUK7D2I.js";
14
14
  import {
15
15
  getMachineId
16
- } from "./chunk-SCJZGEYG.js";
16
+ } from "./chunk-MOQUKAVU.js";
17
17
  import {
18
18
  readControlMode,
19
19
  readKeySource
20
- } from "./chunk-ZOEMN4PT.js";
20
+ } from "./chunk-DYZ26IPH.js";
21
21
  import {
22
22
  getBaseUrl
23
- } from "./chunk-UCQJA73V.js";
23
+ } from "./chunk-LVF5IBS6.js";
24
24
  import {
25
25
  getPackageVersion
26
26
  } from "./chunk-UQTQ6HPO.js";
@@ -10,7 +10,7 @@ import {
10
10
  uploadTranscriptRecords,
11
11
  verifyAnchoredRecipients,
12
12
  wrapSessionKey
13
- } from "./chunk-4Q2BXJKI.js";
13
+ } from "./chunk-7DEAVAAS.js";
14
14
 
15
15
  // src/live-session.ts
16
16
  var LIVE_TRANSCRIPT_LIMITS = { queuedRecords: 100, recordCharacters: 32 * 1024 };
@@ -5,7 +5,7 @@ import {
5
5
  MCP_CREDENTIAL_REJECTION_BODY,
6
6
  isRecord,
7
7
  responseRejectsCredential
8
- } from "./chunk-U6XGBWHB.js";
8
+ } from "./chunk-L77OIGRB.js";
9
9
 
10
10
  // src/credential-rejection.ts
11
11
  import { createHash, randomUUID } from "crypto";
@@ -1,22 +1,22 @@
1
1
  import {
2
2
  cursorGateOwnsClaudeCall,
3
3
  readCursorGateRegistration
4
- } from "./chunk-GRBUY5ZC.js";
4
+ } from "./chunk-IWWKO4MP.js";
5
5
  import {
6
6
  registerTranscript
7
- } from "./chunk-GWVT4TQN.js";
7
+ } from "./chunk-7GMTA5NR.js";
8
8
  import {
9
9
  namedEvent
10
- } from "./chunk-5H7HNGXQ.js";
10
+ } from "./chunk-WTUURSCO.js";
11
11
  import {
12
12
  writeDegraded
13
- } from "./chunk-PI3L74XD.js";
13
+ } from "./chunk-VWVYDYCV.js";
14
14
  import {
15
15
  claudeShapedHookInput,
16
16
  hookCompatibleProfileBySource,
17
17
  isGrokHookPayload,
18
18
  isGrokSessionEndStop
19
- } from "./chunk-U6XGBWHB.js";
19
+ } from "./chunk-L77OIGRB.js";
20
20
 
21
21
  // src/tool-hook-input.ts
22
22
  var OPTIONAL_TEXT_FIELDS = ["hook_event_name", "session_id", "cwd", "transcript_path", "tool_use_id", "permission_mode", "cursor_version"];
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  RETRY_ACK,
6
6
  refusedReceiptMessage
7
- } from "./chunk-QS5A5WBR.js";
7
+ } from "./chunk-GVIKF73A.js";
8
8
 
9
9
  // src/command-receipts.ts
10
10
  import { randomUUID } from "crypto";
@@ -3,7 +3,7 @@ import {
3
3
  HOOK_BUDGETS,
4
4
  KILL_REASON,
5
5
  OPENCODE_APPROVAL_EVENT
6
- } from "./chunk-U6XGBWHB.js";
6
+ } from "./chunk-L77OIGRB.js";
7
7
 
8
8
  // src/opencode-plugin.ts
9
9
  var OPENCODE_PLUGIN_MARKER = "pushary-opencode-plugin w1";
@@ -39,6 +39,14 @@ var OPENCODE_SERVICE_REVERIFY_MS = 2e3;
39
39
  var OPENCODE_SETTLED_ELSEWHERE_STATUSES = [404, 409];
40
40
  var OPENCODE_CLI_BRIDGES_QUESTIONS = true;
41
41
  var OPENCODE_SERVICE_REQUEST_TIMEOUT_MS = 5e3;
42
+ var OPENCODE_WITHDRAW_ON_STDIN_END = "withdraw_on_stdin_end";
43
+ var OPENCODE_CAPABILITIES_EVENT = "pushary.capabilities";
44
+ var OPENCODE_HOOK_CAPABILITIES = { capabilities: [OPENCODE_WITHDRAW_ON_STDIN_END] };
45
+ var OPENCODE_CAPABILITY_PROBE_TIMEOUT_MS = 5e3;
46
+ var OPENCODE_QUESTION_WITHDRAW_TIMEOUT_MS = 5e3;
47
+ var OPENCODE_QUESTION_ASK_IN_FLIGHT_GRACE_MS = 6e4;
48
+ var OPENCODE_HOOK_EXIT_MARGIN_MS = 2e3;
49
+ var OPENCODE_QUESTION_WITHDRAW_GRACE_MS = OPENCODE_QUESTION_ASK_IN_FLIGHT_GRACE_MS + OPENCODE_QUESTION_WITHDRAW_TIMEOUT_MS + 2 * OPENCODE_HOOK_EXIT_MARGIN_MS;
42
50
  var approvalTimeoutMs = () => (HOOK_BUDGETS.opencode.budgetSeconds - HOOK_BUDGETS.opencode.guardSeconds) * 1e3;
43
51
  var openCodePluginSource = (bridgesQuestions) => `// Pushary for OpenCode. Generated by @pushary/agent-hooks \u2014 do not edit.
44
52
  // ${OPENCODE_PLUGIN_MARKER}
@@ -60,7 +68,7 @@ var openCodePluginSource = (bridgesQuestions) => `// Pushary for OpenCode. Gener
60
68
  // worst this file may do to somebody is nothing at all.
61
69
 
62
70
  import { spawn } from "node:child_process"
63
- import { readdir, readFile } from "node:fs/promises"
71
+ import { readdir, readFile, stat } from "node:fs/promises"
64
72
  import { homedir } from "node:os"
65
73
  import { isAbsolute, join, relative, resolve, sep } from "node:path"
66
74
 
@@ -76,6 +84,10 @@ const GLOBAL_FORM_OWNER = ${JSON.stringify(OPENCODE_GLOBAL_FORM_OWNER)}
76
84
  const QUESTION_ANSWERED = ${JSON.stringify(OPENCODE_QUESTION_ANSWERED)}
77
85
  const QUESTION_CANCELLED = ${JSON.stringify(OPENCODE_QUESTION_CANCELLED)}
78
86
  const SERVICE_REQUEST_TIMEOUT_MS = ${OPENCODE_SERVICE_REQUEST_TIMEOUT_MS}
87
+ const WITHDRAW_ON_STDIN_END = ${JSON.stringify(OPENCODE_WITHDRAW_ON_STDIN_END)}
88
+ const CAPABILITIES_EVENT = ${JSON.stringify(OPENCODE_CAPABILITIES_EVENT)}
89
+ const CAPABILITY_PROBE_TIMEOUT_MS = ${OPENCODE_CAPABILITY_PROBE_TIMEOUT_MS}
90
+ const QUESTION_WITHDRAW_GRACE_MS = ${OPENCODE_QUESTION_WITHDRAW_GRACE_MS}
79
91
  const SERVICE_REGISTRATION = /^service.*\\.json$/
80
92
  const SERVICE_USER = "opencode"
81
93
  const SERVICE_PROTOCOL = "http:"
@@ -116,22 +128,36 @@ const remember = (map, key, value) => {
116
128
  map.set(key, value)
117
129
  }
118
130
 
119
- const run = (payload, timeoutMs, onSpawn) =>
131
+ const withdrawsOverStdin = (payload) => payload[WITHDRAW_ON_STDIN_END] === true
132
+
133
+ const replyIn = (out) => {
134
+ const body = out.trim()
135
+ if (!body) return null
136
+ try {
137
+ return JSON.parse(body)
138
+ } catch {
139
+ return null
140
+ }
141
+ }
142
+
143
+ const exitedCleanly = (code, signal) => code === 0 && !signal
144
+
145
+ const runHook = (payload, timeoutMs, onSpawn) =>
120
146
  new Promise((resolve) => {
121
147
  let settled = false
122
148
  let timer
123
- const finish = (value) => {
149
+ const finish = (reply, cleanExit) => {
124
150
  if (settled) return
125
151
  settled = true
126
152
  clearTimeout(timer)
127
- resolve(value)
153
+ resolve({ reply, cleanExit })
128
154
  }
129
155
 
130
156
  let child
131
157
  try {
132
158
  child = spawn(COMMAND[0], COMMAND.slice(1), { stdio: ["pipe", "pipe", "ignore"] })
133
159
  } catch {
134
- return finish(null)
160
+ return finish(null, false)
135
161
  }
136
162
  if (onSpawn) onSpawn(child)
137
163
 
@@ -140,7 +166,7 @@ const run = (payload, timeoutMs, onSpawn) =>
140
166
  try {
141
167
  child.kill("SIGKILL")
142
168
  } catch {}
143
- finish(null)
169
+ finish(null, false)
144
170
  }, timeoutMs)
145
171
  if (typeof timer.unref === "function") timer.unref()
146
172
  }
@@ -149,25 +175,55 @@ const run = (payload, timeoutMs, onSpawn) =>
149
175
  child.stdout.on("data", (chunk) => {
150
176
  if (out.length < MAX_REPLY_BYTES) out += chunk
151
177
  })
152
- child.on("error", () => finish(null))
153
- child.on("close", () => {
154
- const body = out.trim()
155
- if (!body) return finish(null)
156
- try {
157
- finish(JSON.parse(body))
158
- } catch {
159
- finish(null)
160
- }
161
- })
178
+ child.on("error", () => finish(null, false))
179
+ child.on("close", (code, signal) => finish(replyIn(out), exitedCleanly(code, signal)))
162
180
 
163
181
  try {
164
182
  child.stdin.on("error", () => {})
165
- child.stdin.end(JSON.stringify(payload))
183
+ if (withdrawsOverStdin(payload)) child.stdin.write(JSON.stringify(payload) + "\\n")
184
+ else child.stdin.end(JSON.stringify(payload))
166
185
  } catch {
167
- finish(null)
186
+ finish(null, false)
168
187
  }
169
188
  })
170
189
 
190
+ const run = (payload, timeoutMs, onSpawn) => runHook(payload, timeoutMs, onSpawn).then((ended) => ended.reply)
191
+
192
+ const commandSignature = async () => {
193
+ const parts = []
194
+ for (const entry of COMMAND.filter((part) => isAbsolute(part))) {
195
+ try {
196
+ const info = await stat(entry)
197
+ parts.push([entry, info.ino, info.size, info.mtimeMs, info.ctimeMs].join(":"))
198
+ } catch {}
199
+ }
200
+ return parts.join("|")
201
+ }
202
+
203
+ const reportsHeldStdin = (reply) =>
204
+ Boolean(reply) && typeof reply === "object" && Array.isArray(reply.capabilities) && reply.capabilities.includes(WITHDRAW_ON_STDIN_END)
205
+
206
+ const probeCapabilities = async () => {
207
+ const ended = await runHook({ hook_event_name: CAPABILITIES_EVENT }, CAPABILITY_PROBE_TIMEOUT_MS)
208
+ return { holds: ended.cleanExit && reportsHeldStdin(ended.reply), conclusive: ended.cleanExit }
209
+ }
210
+
211
+ let knownCapabilities
212
+ let capabilityCheck
213
+
214
+ const checkHookCapabilities = async () => {
215
+ const signature = await commandSignature()
216
+ if (signature && knownCapabilities && knownCapabilities.signature === signature) return knownCapabilities.holds
217
+ const answer = await probeCapabilities()
218
+ knownCapabilities = signature && answer.conclusive ? { signature, holds: answer.holds } : undefined
219
+ return answer.holds
220
+ }
221
+
222
+ const hookWithdrawsOverStdin = () => {
223
+ if (!capabilityCheck) capabilityCheck = checkHookCapabilities().finally(() => { capabilityCheck = undefined })
224
+ return capabilityCheck
225
+ }
226
+
171
227
  // Telemetry is fire and forget: the agent has already acted and is only being
172
228
  // observed, so nothing here may hold up the next turn.
173
229
  const tell = (payload) => {
@@ -646,7 +702,10 @@ const PusharyPlugin = async ({ client, directory, worktree, replyPermission, ses
646
702
  }
647
703
  pending.channel = channel
648
704
  keepRechecking()
649
- const reply = await run({ ...formPayload(form), hook_event_name: QUESTION_EVENT }, undefined, (child) => {
705
+ pending.holdsStdin = await hookWithdrawsOverStdin()
706
+ if (questions.get(form.id) !== pending) return
707
+ const asked = { ...formPayload(form), hook_event_name: QUESTION_EVENT, ...(pending.holdsStdin ? { [WITHDRAW_ON_STDIN_END]: true } : {}) }
708
+ const reply = await run(asked, undefined, (child) => {
650
709
  pending.child = child
651
710
  })
652
711
  if (questions.get(form.id) !== pending) return
@@ -656,14 +715,28 @@ const PusharyPlugin = async ({ client, directory, worktree, replyPermission, ses
656
715
  forgetQuestion(form.id, pending)
657
716
  }
658
717
 
718
+ const signalQuestionHook = (child) => {
719
+ try {
720
+ child.kill("SIGTERM")
721
+ } catch {}
722
+ }
723
+
724
+ const endQuestionHook = (child) => {
725
+ try {
726
+ child.stdin.end()
727
+ } catch {}
728
+ const fallback = setTimeout(() => signalQuestionHook(child), QUESTION_WITHDRAW_GRACE_MS)
729
+ if (typeof fallback.unref === "function") fallback.unref()
730
+ child.once("close", () => clearTimeout(fallback))
731
+ }
732
+
659
733
  const withdrawQuestion = (id) => {
660
734
  const pending = id ? questions.get(id) : undefined
661
735
  if (!pending) return
662
736
  forgetQuestion(id, pending)
663
737
  if (!pending.child) return
664
- try {
665
- pending.child.kill("SIGTERM")
666
- } catch {}
738
+ if (pending.holdsStdin) endQuestionHook(pending.child)
739
+ else signalQuestionHook(pending.child)
667
740
  }
668
741
 
669
742
  const withdrawSessionQuestions = (sessionID) => {
@@ -878,6 +951,11 @@ export {
878
951
  OPENCODE_QUESTION_CANCELLED,
879
952
  OPENCODE_QUESTION_UNDELIVERED_EVENT,
880
953
  OPENCODE_QUESTION_UNREACHABLE_EVENT,
954
+ OPENCODE_CAPABILITIES_EVENT,
955
+ OPENCODE_HOOK_CAPABILITIES,
956
+ OPENCODE_QUESTION_WITHDRAW_TIMEOUT_MS,
957
+ OPENCODE_QUESTION_ASK_IN_FLIGHT_GRACE_MS,
958
+ OPENCODE_HOOK_EXIT_MARGIN_MS,
881
959
  openCodePluginModule,
882
960
  renderOpenCodePlugin,
883
961
  openCodePluginArgv,
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  pusharyDir
3
- } from "./chunk-XG7VMTTL.js";
3
+ } from "./chunk-X7RPRBZE.js";
4
4
  import {
5
5
  readJsonSafe
6
6
  } from "./chunk-TODDEIYG.js";
7
7
  import {
8
8
  isRecord
9
- } from "./chunk-U6XGBWHB.js";
9
+ } from "./chunk-L77OIGRB.js";
10
10
 
11
11
  // src/process-ownership.ts
12
12
  import { createHash, randomUUID } from "crypto";
@@ -536,8 +536,8 @@ var loadedOnce = (load) => {
536
536
  };
537
537
 
538
538
  // src/codex-desktop-proxy.ts
539
- var loadThePhone = () => import("./api-7DCJGW6H.js");
540
- var loadTheCardRouting = () => import("./codex-card-routing-7C4NT6VL.js");
539
+ var loadThePhone = () => import("./api-2NP643KP.js");
540
+ var loadTheCardRouting = () => import("./codex-card-routing-QGOX4RNI.js");
541
541
  var theFirstCardLoadsAgain = () => {
542
542
  };
543
543
  var ASKS_WITHOUT_ROUTING = {};
@@ -1097,7 +1097,7 @@ var codexDesktopCommand = async (args, entry, readAccount) => {
1097
1097
  return runCodexDesktopProxy(engine2, args.slice(3), readAccount, { watchesForCards: layoutIsKnown });
1098
1098
  }
1099
1099
  if (args[0] === APP_CARDS_FLAG) {
1100
- const { codexAppCardsCommandOnThisMac } = await import("./codex-app-cards-switch-MO6URXIW.js");
1100
+ const { codexAppCardsCommandOnThisMac } = await import("./codex-app-cards-switch-C6OKN3RA.js");
1101
1101
  return codexAppCardsCommandOnThisMac(args.slice(1), entry, readAccount);
1102
1102
  }
1103
1103
  if (args.length > 2) throw new Error("Usage: pushary codex --desktop [path/to/Codex.app]");
@@ -8,21 +8,21 @@ import {
8
8
  SubscriptionRequiredError,
9
9
  callMcpTool,
10
10
  isRetryable
11
- } from "./chunk-HR67NNCI.js";
11
+ } from "./chunk-6PDBRLIH.js";
12
12
  import {
13
13
  fetchAsCredential
14
- } from "./chunk-C2AXJZNA.js";
14
+ } from "./chunk-SSKNRWWS.js";
15
15
  import {
16
16
  installNetworkDefaults,
17
17
  isNetworkFailure
18
- } from "./chunk-N7IF5QJ5.js";
18
+ } from "./chunk-VY22KT5X.js";
19
19
  import {
20
20
  clientReportClaims
21
- } from "./chunk-XG7VMTTL.js";
21
+ } from "./chunk-X7RPRBZE.js";
22
22
  import {
23
23
  getApiKey,
24
24
  getBaseUrl
25
- } from "./chunk-UCQJA73V.js";
25
+ } from "./chunk-LVF5IBS6.js";
26
26
  import {
27
27
  ASK_AGENT_NAME_MAX,
28
28
  CLIENT_REPORT_PATH,
@@ -32,7 +32,7 @@ import {
32
32
  degradedLine,
33
33
  isDecisionStoppedReply,
34
34
  truncateLine
35
- } from "./chunk-U6XGBWHB.js";
35
+ } from "./chunk-L77OIGRB.js";
36
36
 
37
37
  // src/api.ts
38
38
  import { randomUUID } from "crypto";
@@ -348,8 +348,9 @@ var pollForAnswer = async (apiKey, correlationId, deadlineMs, pollInterval = 2e3
348
348
  if (signal?.aborted) return ABANDONED_WAIT;
349
349
  return waitedThroughAnOutage ? withdrawAfterAFailedPoll(apiKey, correlationId) : withdrawQuestion(apiKey, correlationId);
350
350
  };
351
+ var CANCEL_QUESTION_TIMEOUT_MS = 4e3;
351
352
  var cancelQuestion = async (apiKey, correlationId, signal, baseUrl) => {
352
- return callMcpTool(apiKey, "cancel_question", { correlationId }, { signal, timeoutMs: 4e3, maxRetries: 1, baseUrl });
353
+ return callMcpTool(apiKey, "cancel_question", { correlationId }, { signal, timeoutMs: CANCEL_QUESTION_TIMEOUT_MS, maxRetries: 1, baseUrl });
353
354
  };
354
355
  var withdrawQuestion = async (apiKey, correlationId, transport = { cancelQuestion, waitForAnswer }) => {
355
356
  try {
@@ -374,10 +375,23 @@ var answerThatWonTheCancel = async (apiKey, correlationId) => {
374
375
  const late = await waitForAnswer(apiKey, correlationId, OPEN_QUESTION_LATE_ANSWER_HOLD_MS, AbortSignal.timeout(2e3));
375
376
  return late.answered ? late : OPEN_QUESTION_CLOSED;
376
377
  };
378
+ var OPEN_QUESTION_WITHDRAWAL_FAILED = "open_question_withdrawal_failed";
379
+ var reportFailedQuestionWithdrawal = (event) => writeDegraded("questions", {
380
+ reason: OPEN_QUESTION_WITHDRAWAL_FAILED,
381
+ fallback: "the question stays on the phone until it is answered, cancelled or expires",
382
+ ...event ? { event } : {}
383
+ });
377
384
  var withdrawOpenQuestion = async (apiKey, correlationId) => {
385
+ let cancelled;
386
+ try {
387
+ cancelled = await cancelQuestion(apiKey, correlationId, AbortSignal.timeout(4e3));
388
+ } catch {
389
+ reportFailedQuestionWithdrawal();
390
+ return OPEN_QUESTION_CLOSED;
391
+ }
392
+ if (cancelled.cancelled === true) return OPEN_QUESTION_CLOSED;
378
393
  try {
379
- const cancelled = await cancelQuestion(apiKey, correlationId, AbortSignal.timeout(4e3));
380
- return cancelled.cancelled === true ? OPEN_QUESTION_CLOSED : await answerThatWonTheCancel(apiKey, correlationId);
394
+ return await answerThatWonTheCancel(apiKey, correlationId);
381
395
  } catch {
382
396
  return OPEN_QUESTION_CLOSED;
383
397
  }
@@ -460,9 +474,11 @@ export {
460
474
  waitRetryPauseMs,
461
475
  sleepUnlessAborted,
462
476
  pollForAnswer,
477
+ CANCEL_QUESTION_TIMEOUT_MS,
463
478
  cancelQuestion,
464
479
  withdrawQuestion,
465
480
  waitForQuestion,
481
+ reportFailedQuestionWithdrawal,
466
482
  waitForOpenQuestion,
467
483
  sendNotification,
468
484
  requestGate,
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  readExistingMachineId
3
- } from "./chunk-SCJZGEYG.js";
3
+ } from "./chunk-MOQUKAVU.js";
4
4
  import {
5
5
  getBaseUrl
6
- } from "./chunk-UCQJA73V.js";
6
+ } from "./chunk-LVF5IBS6.js";
7
7
  import {
8
8
  NetworkError
9
9
  } from "./chunk-YU2EUD7O.js";
@@ -13,7 +13,7 @@ import {
13
13
  import {
14
14
  clientContextHeaders,
15
15
  redactSecretsFromContent
16
- } from "./chunk-U6XGBWHB.js";
16
+ } from "./chunk-L77OIGRB.js";
17
17
 
18
18
  // src/cli/net.ts
19
19
  import { createRequire } from "module";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  shouldDeferToNativeMode
3
- } from "./chunk-U6XGBWHB.js";
3
+ } from "./chunk-L77OIGRB.js";
4
4
 
5
5
  // src/native-defer.ts
6
6
  var nativeDeferOptions = () => {
@@ -6,7 +6,7 @@ import {
6
6
  DISCONNECT_AGENT_IDS,
7
7
  SETUP_AGENT_CHOICES,
8
8
  isApprovalMode
9
- } from "./chunk-U6XGBWHB.js";
9
+ } from "./chunk-L77OIGRB.js";
10
10
 
11
11
  // src/cli/mode-request.ts
12
12
  var parseDuration = (value) => {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  HOOK_HOLD_BUDGET_ENV,
3
3
  hookHoldBudgetProof
4
- } from "./chunk-U6XGBWHB.js";
4
+ } from "./chunk-L77OIGRB.js";
5
5
 
6
6
  // src/hold-budget.ts
7
7
  var takeHookHoldBudget = (args = process.argv.slice(2), env = process.env) => {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  pusharyDir
3
- } from "./chunk-XG7VMTTL.js";
3
+ } from "./chunk-X7RPRBZE.js";
4
4
  import {
5
5
  readRegularJsonFile,
6
6
  writeFileAtomic
@@ -13,7 +13,7 @@ import {
13
13
  serializeDeclinedAgents,
14
14
  withDeclinedAgent,
15
15
  withoutDeclinedAgent
16
- } from "./chunk-U6XGBWHB.js";
16
+ } from "./chunk-L77OIGRB.js";
17
17
 
18
18
  // src/declined-agents-file.ts
19
19
  import { join } from "path";
@@ -4,10 +4,10 @@ import {
4
4
  keyPrefix,
5
5
  readConfigFileKey,
6
6
  readMacAppKeyPrefix
7
- } from "./chunk-ZOEMN4PT.js";
7
+ } from "./chunk-DYZ26IPH.js";
8
8
  import {
9
9
  NPX_LATEST_COMMAND
10
- } from "./chunk-5FYS2WJI.js";
10
+ } from "./chunk-WDLBF3PM.js";
11
11
 
12
12
  // src/key-signed-out.ts
13
13
  var VERDICT_BY_CHECK = {
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  addGeminiMcpServer,
3
3
  removeGeminiMcpServer
4
- } from "./chunk-SZYXBY2H.js";
4
+ } from "./chunk-OBUKF3WP.js";
5
5
  import {
6
6
  CLAUDE_CODE_AGENT
7
- } from "./chunk-4AYUAZEK.js";
7
+ } from "./chunk-PG5N3FL5.js";
8
8
  import {
9
9
  compatibleToolLookup
10
- } from "./chunk-DRZLGR3F.js";
10
+ } from "./chunk-CFZUESTS.js";
11
11
  import {
12
12
  CLAUDE_HOOK_EVENTS,
13
13
  PUSHARY_MCP_URL,
@@ -19,7 +19,7 @@ import {
19
19
  isPusharyHook,
20
20
  registerHookEntry,
21
21
  removeClaudeMcpServers
22
- } from "./chunk-XG7VMTTL.js";
22
+ } from "./chunk-X7RPRBZE.js";
23
23
  import {
24
24
  HOOK_COMPATIBLE_PROFILES,
25
25
  PHONE_ANSWERED_TOOLS,
@@ -30,7 +30,7 @@ import {
30
30
  pusharyMissingReason,
31
31
  refusalOutput,
32
32
  withHookHoldBudget
33
- } from "./chunk-U6XGBWHB.js";
33
+ } from "./chunk-L77OIGRB.js";
34
34
 
35
35
  // src/config-document.ts
36
36
  import { parse, stringify } from "smol-toml";
@@ -3,7 +3,7 @@ import {
3
3
  formatVersion,
4
4
  quoteIfNeeded,
5
5
  shellDoubleQuoted
6
- } from "./chunk-NA2P74E6.js";
6
+ } from "./chunk-NOHOCNY6.js";
7
7
  import {
8
8
  writeFileAtomic
9
9
  } from "./chunk-TODDEIYG.js";
@@ -22,7 +22,7 @@ import {
22
22
  PUSHARY_HOSTS,
23
23
  PUSHARY_TOOL_PREFIX,
24
24
  withHookHoldBudget
25
- } from "./chunk-U6XGBWHB.js";
25
+ } from "./chunk-L77OIGRB.js";
26
26
 
27
27
  // src/setup/paths.ts
28
28
  import { createHash as createHash2 } from "crypto";
@@ -10,17 +10,17 @@ import {
10
10
  openCodePluginArgv,
11
11
  openCodePluginModule,
12
12
  renderOpenCodePlugin
13
- } from "./chunk-G5TR3F6L.js";
13
+ } from "./chunk-UCND4JHN.js";
14
14
  import {
15
15
  compatibleConfigFile
16
- } from "./chunk-5H7HNGXQ.js";
16
+ } from "./chunk-WTUURSCO.js";
17
17
  import {
18
18
  hookOwnerOf,
19
19
  hookOwnerOfCommands
20
- } from "./chunk-SZYXBY2H.js";
20
+ } from "./chunk-OBUKF3WP.js";
21
21
  import {
22
22
  AGENT_CHOICES
23
- } from "./chunk-5WH6NFNY.js";
23
+ } from "./chunk-AIUFZQAA.js";
24
24
  import {
25
25
  OPENCODE_INSTRUCTIONS_LABEL,
26
26
  bridgeStub,
@@ -34,7 +34,7 @@ import {
34
34
  resolveBridgeStub,
35
35
  vscodePluginDir,
36
36
  windowsNodeLauncherFor
37
- } from "./chunk-XG7VMTTL.js";
37
+ } from "./chunk-X7RPRBZE.js";
38
38
  import {
39
39
  readJsonSafe
40
40
  } from "./chunk-TODDEIYG.js";
@@ -44,7 +44,7 @@ import {
44
44
  OPENCODE_APPROVAL_EVENT,
45
45
  hookCompatibleProfile,
46
46
  isRecord
47
- } from "./chunk-U6XGBWHB.js";
47
+ } from "./chunk-L77OIGRB.js";
48
48
 
49
49
  // src/opencode-config.ts
50
50
  import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from "fs";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  claudeConfigDir
3
- } from "./chunk-XG7VMTTL.js";
3
+ } from "./chunk-X7RPRBZE.js";
4
4
  import {
5
5
  claudePermissionRulesFromSettings
6
- } from "./chunk-U6XGBWHB.js";
6
+ } from "./chunk-L77OIGRB.js";
7
7
 
8
8
  // src/claude-permission-rules.ts
9
9
  import { readFileSync, statSync } from "fs";