@pushary/agent-hooks 1.9.157 → 1.9.161

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 (147) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.md +1 -0
  3. package/dist/{api-3C62HQDC.js → api-WHTSBK74.js} +15 -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 +61 -51
  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-2SHPCEH6.js → chunk-26GVUJMR.js} +5 -2
  49. package/dist/{chunk-UAYNQ2IG.js → chunk-2ABUBECK.js} +6 -6
  50. package/dist/{chunk-6NRFAP45.js → chunk-2PY5DJTC.js} +1 -1
  51. package/dist/{chunk-RF7HGOBC.js → chunk-3F6HE5AK.js} +3 -3
  52. package/dist/{chunk-5MWNWCCI.js → chunk-4ZNZS6FM.js} +8 -5
  53. package/dist/{chunk-KB7YWU7A.js → chunk-55AHQF63.js} +110 -0
  54. package/dist/{chunk-3XTH6EKH.js → chunk-5S66DHJS.js} +3 -3
  55. package/dist/{chunk-CHI57HS3.js → chunk-5UBV26GO.js} +3 -3
  56. package/dist/{chunk-V4OIPLSC.js → chunk-6NWESDKK.js} +4 -4
  57. package/dist/{chunk-RF35YTIF.js → chunk-6OSE2IRG.js} +2 -2
  58. package/dist/{chunk-G6SQOGSD.js → chunk-7AQTKVA6.js} +12 -7
  59. package/dist/{chunk-ANL74IBU.js → chunk-7IHVTLHK.js} +1 -1
  60. package/dist/{chunk-3EF7G5EV.js → chunk-7VXHWU7A.js} +4 -4
  61. package/dist/{chunk-MH4O453X.js → chunk-7WLKE7QN.js} +4 -3
  62. package/dist/{chunk-3UYTCDDY.js → chunk-ANYLSZN3.js} +24 -9
  63. package/dist/{chunk-GA5T3WEB.js → chunk-AT5ZLKMQ.js} +5 -5
  64. package/dist/{chunk-HXX4EFK3.js → chunk-ATI5XO3E.js} +4 -4
  65. package/dist/{chunk-TIOQ55VZ.js → chunk-AVGYUZVK.js} +6 -6
  66. package/dist/{chunk-6UGVZTRA.js → chunk-AVRRD6AY.js} +1 -1
  67. package/dist/{chunk-WCVANKUD.js → chunk-BGU56XCS.js} +1 -1
  68. package/dist/{chunk-DDSMTD4W.js → chunk-BTYHDCAP.js} +3 -3
  69. package/dist/{chunk-IQWMRFKD.js → chunk-DHUWAUVL.js} +1 -1
  70. package/dist/{chunk-W2GOSAFI.js → chunk-DHX5JZSH.js} +4 -4
  71. package/dist/{chunk-KOBIBSE6.js → chunk-DLZ6RK2P.js} +3 -3
  72. package/dist/{chunk-TWOSBIAW.js → chunk-DWMQZM52.js} +1 -1
  73. package/dist/{chunk-WDU4LEEW.js → chunk-E7K6YCWY.js} +6 -6
  74. package/dist/{chunk-7JAEIKBV.js → chunk-EGEZKJHX.js} +5 -5
  75. package/dist/{chunk-VRLYEBDN.js → chunk-F5NJUDGA.js} +78 -50
  76. package/dist/{chunk-ELF4NIIM.js → chunk-FZCEPG6J.js} +2 -2
  77. package/dist/{chunk-KURQ4KMV.js → chunk-G44FOBHN.js} +4 -4
  78. package/dist/{chunk-S6DJAYQW.js → chunk-GJA3KQ3T.js} +5 -5
  79. package/dist/{chunk-WIOLCW7W.js → chunk-GNHXDRO6.js} +1 -1
  80. package/dist/{chunk-C3HYWUZE.js → chunk-HHNC6FWO.js} +1 -1
  81. package/dist/{chunk-E2KAAKWU.js → chunk-HKCJZGAJ.js} +6 -6
  82. package/dist/{chunk-7HDQUTRK.js → chunk-HKI4RMZF.js} +8 -7
  83. package/dist/{chunk-C4K4KYOY.js → chunk-I5HXAELM.js} +5 -5
  84. package/dist/{chunk-MGT2V2AB.js → chunk-IGSSDODQ.js} +2 -2
  85. package/dist/{chunk-ICHKAH5Q.js → chunk-IHYKSPWH.js} +85 -8
  86. package/dist/chunk-J36DDPJV.js +18 -0
  87. package/dist/{chunk-QONYKXWP.js → chunk-KDHLOPSO.js} +1 -1
  88. package/dist/{chunk-O3NAHPCR.js → chunk-KKDKPWGM.js} +1 -1
  89. package/dist/{chunk-REUFDG7O.js → chunk-L2ADRR62.js} +5 -5
  90. package/dist/{chunk-F6ZBXV4G.js → chunk-LRTRIDOC.js} +1 -1
  91. package/dist/{chunk-4I4HAPT5.js → chunk-LVGRSC44.js} +5 -5
  92. package/dist/{chunk-UH5NAPWL.js → chunk-MGOBIHXH.js} +10 -10
  93. package/dist/{chunk-CV6G4IDZ.js → chunk-MPYQW4IV.js} +2 -2
  94. package/dist/{chunk-QBDCKECQ.js → chunk-N4OKAE65.js} +120 -32
  95. package/dist/{chunk-EQF6SSQL.js → chunk-ONMAG5BF.js} +2 -2
  96. package/dist/{chunk-CAZ5FMWP.js → chunk-OOODAKCC.js} +6 -6
  97. package/dist/chunk-OQAIMSHQ.js +885 -0
  98. package/dist/{chunk-MOX7IOGL.js → chunk-OSCZ4MNE.js} +7 -7
  99. package/dist/{chunk-6W6MZ53D.js → chunk-OXZ75E2Y.js} +4 -4
  100. package/dist/{chunk-O2DJWDVK.js → chunk-OZK75SFS.js} +11 -9
  101. package/dist/{chunk-WSPDIT2B.js → chunk-PXLWR4TG.js} +2 -2
  102. package/dist/{chunk-UJJ2OXFA.js → chunk-QLEFFGCN.js} +1 -1
  103. package/dist/{chunk-T3LSBTWU.js → chunk-R7NAG65X.js} +4 -4
  104. package/dist/{chunk-WDCS3RGI.js → chunk-R7RN3Z2T.js} +2 -2
  105. package/dist/{chunk-P5JV6YZW.js → chunk-RZBCXPOV.js} +14 -3
  106. package/dist/{chunk-JBF6A2X5.js → chunk-S6ARXVVZ.js} +1 -1
  107. package/dist/{chunk-R4DMHIOK.js → chunk-TYB2QGJD.js} +6 -6
  108. package/dist/{chunk-C74JHUD3.js → chunk-U36COV3Z.js} +11 -11
  109. package/dist/{chunk-PKU3WFT5.js → chunk-U3FVVMB3.js} +1 -1
  110. package/dist/{chunk-3FQJYA76.js → chunk-UH7GJHOO.js} +3 -3
  111. package/dist/chunk-UJT32RSQ.js +242 -0
  112. package/dist/{chunk-WIIMW5YO.js → chunk-UQTQ6HPO.js} +2 -0
  113. package/dist/{chunk-WWDWEVGT.js → chunk-UZTGEACF.js} +5 -5
  114. package/dist/{chunk-4RSJZOKB.js → chunk-VIS3EVRH.js} +1 -1
  115. package/dist/{chunk-5HMVXNFU.js → chunk-VYNC7EYV.js} +2 -2
  116. package/dist/{chunk-MEUAK5BK.js → chunk-W6FCSBTM.js} +2 -2
  117. package/dist/{chunk-PMEDJ4WM.js → chunk-WAFJGQSE.js} +39 -8
  118. package/dist/{chunk-25PVMWSM.js → chunk-WCXVPYSD.js} +1 -1
  119. package/dist/{chunk-5TCLBCUO.js → chunk-WNIDBPT2.js} +8 -8
  120. package/dist/{chunk-2NSPZZBJ.js → chunk-WTWBHE2Y.js} +42 -34
  121. package/dist/{chunk-UOVTXOSS.js → chunk-XWCLKWKP.js} +1 -1
  122. package/dist/{chunk-2LTRA6NA.js → chunk-Y23YO46U.js} +3 -3
  123. package/dist/{chunk-2N23JFER.js → chunk-Y553AEQU.js} +3 -3
  124. package/dist/{chunk-H6CL3T2S.js → chunk-Y6ILCLKE.js} +1 -1
  125. package/dist/{chunk-AKUYCHJU.js → chunk-YD45WNVQ.js} +1 -1
  126. package/dist/{chunk-44FDCO7M.js → chunk-YEB7YWW7.js} +13 -13
  127. package/dist/{chunk-BMR66K6T.js → chunk-YGHHDDIM.js} +4 -4
  128. package/dist/{chunk-KRI7BOND.js → chunk-Z5DOTAFI.js} +3 -3
  129. package/dist/{chunk-XHPTW6WL.js → chunk-ZIKSHD5M.js} +5 -3
  130. package/dist/{codex-app-cards-switch-MQIEZLSU.js → codex-app-cards-switch-DPCGWQSX.js} +14 -14
  131. package/dist/{codex-card-routing-UTWTJ6YQ.js → codex-card-routing-NFIEH66Q.js} +2 -2
  132. package/dist/{codex-desktop-launch-A6GX6F54.js → codex-desktop-launch-MARNBY23.js} +1 -1
  133. package/dist/{codex-session-launch-AVEFGOT7.js → codex-session-launch-LSNU7CUV.js} +23 -23
  134. package/dist/{config-YGUXX5GB.js → config-5D34OAYM.js} +4 -4
  135. package/dist/{global-upgrade-HLXPTFDU.js → global-upgrade-5XBO6FYU.js} +11 -11
  136. package/dist/{identity-CAC763RQ.js → identity-6QEFK7PW.js} +5 -5
  137. package/dist/{live-capabilities-WRI22INV.js → live-capabilities-6KOGY6KM.js} +5 -5
  138. package/dist/{paths-DNXBDJJH.js → paths-7M6V62NO.js} +4 -4
  139. package/dist/reapply-ZECM5JRX.js +69 -0
  140. package/dist/src/index.d.ts +6 -1
  141. package/dist/src/index.js +39 -38
  142. package/dist/{upgrade-lock-CRW26OIW.js → upgrade-lock-DI4JY2CU.js} +5 -5
  143. package/dist/usage-X4BIHYR5.js +11 -0
  144. package/package.json +2 -1
  145. package/dist/chunk-BO4HRAY7.js +0 -593
  146. package/dist/reapply-5ZNMLEKV.js +0 -68
  147. package/dist/usage-AWWCZ7H7.js +0 -11
@@ -1,22 +1,22 @@
1
1
  import {
2
2
  cursorGateOwnsClaudeCall,
3
3
  readCursorGateRegistration
4
- } from "./chunk-3EF7G5EV.js";
4
+ } from "./chunk-7VXHWU7A.js";
5
5
  import {
6
6
  registerTranscript
7
- } from "./chunk-UH5NAPWL.js";
7
+ } from "./chunk-MGOBIHXH.js";
8
8
  import {
9
9
  namedEvent
10
- } from "./chunk-4I4HAPT5.js";
10
+ } from "./chunk-LVGRSC44.js";
11
11
  import {
12
12
  writeDegraded
13
- } from "./chunk-ICHKAH5Q.js";
13
+ } from "./chunk-IHYKSPWH.js";
14
14
  import {
15
15
  claudeShapedHookInput,
16
16
  hookCompatibleProfileBySource,
17
17
  isGrokHookPayload,
18
18
  isGrokSessionEndStop
19
- } from "./chunk-KB7YWU7A.js";
19
+ } from "./chunk-55AHQF63.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"];
@@ -2,37 +2,39 @@ import {
2
2
  forgetPhoneApproval,
3
3
  rememberPhoneApproval,
4
4
  takePhoneApproval
5
- } from "./chunk-5HMVXNFU.js";
5
+ } from "./chunk-VYNC7EYV.js";
6
6
  import {
7
7
  claudeSettingsLocationFor,
8
8
  readClaudePermissionRules
9
- } from "./chunk-WSPDIT2B.js";
9
+ } from "./chunk-PXLWR4TG.js";
10
+ import {
11
+ defersToNativeMode
12
+ } from "./chunk-J36DDPJV.js";
10
13
  import {
11
14
  askAgentQuestions,
12
- defersToNativeMode,
13
15
  outcomeOfFailedAsk,
14
16
  storedWaitDeadline
15
- } from "./chunk-2NSPZZBJ.js";
17
+ } from "./chunk-WTWBHE2Y.js";
16
18
  import {
17
19
  reportMachineDenial
18
- } from "./chunk-3XTH6EKH.js";
20
+ } from "./chunk-5S66DHJS.js";
19
21
  import {
20
22
  isGatingMoment,
21
23
  recordKeylessMoment
22
- } from "./chunk-C3HYWUZE.js";
24
+ } from "./chunk-HHNC6FWO.js";
23
25
  import {
24
26
  isAdmitted,
25
27
  readAdmissionRules
26
- } from "./chunk-7JAEIKBV.js";
28
+ } from "./chunk-EGEZKJHX.js";
27
29
  import {
28
30
  isDeferAnswer,
29
31
  oncePerSession
30
- } from "./chunk-IQWMRFKD.js";
32
+ } from "./chunk-DHUWAUVL.js";
31
33
  import {
32
34
  activeHookSource,
33
35
  activeIdentity,
34
36
  namedSource
35
- } from "./chunk-4I4HAPT5.js";
37
+ } from "./chunk-LVGRSC44.js";
36
38
  import {
37
39
  DEFAULT_SESSION,
38
40
  approvalAwaitingRetry,
@@ -45,15 +47,17 @@ import {
45
47
  getPolicyForStandingDenies,
46
48
  hasBlockedActionHint,
47
49
  markApprovalReminded,
50
+ permissionModeOf,
48
51
  readCachedPolicy,
49
52
  readLastPrompt,
50
53
  readLastUserPrompt,
51
54
  recordBlockedActionHint,
55
+ recordGateOutcome,
52
56
  reportEvent,
53
57
  settleQuestionsForToolUse,
54
58
  sweepFilesOlderThan,
55
59
  userScope
56
- } from "./chunk-QBDCKECQ.js";
60
+ } from "./chunk-N4OKAE65.js";
57
61
  import {
58
62
  UNNAMED_ACTION,
59
63
  deriveAction,
@@ -64,12 +68,12 @@ import {
64
68
  patchDeletesFiles,
65
69
  permissionDeniedAction,
66
70
  scopePathFor
67
- } from "./chunk-2SHPCEH6.js";
71
+ } from "./chunk-26GVUJMR.js";
68
72
  import {
69
73
  branchFor,
70
74
  repoKeyFor,
71
75
  repositoryScopeFor
72
- } from "./chunk-UJJ2OXFA.js";
76
+ } from "./chunk-QLEFFGCN.js";
73
77
  import {
74
78
  askUser,
75
79
  cancelQuestion,
@@ -86,20 +90,23 @@ import {
86
90
  waitForQuestion,
87
91
  waitsForThePhone,
88
92
  withdrawQuestion
89
- } from "./chunk-ICHKAH5Q.js";
93
+ } from "./chunk-IHYKSPWH.js";
90
94
  import {
91
95
  getMachineId
92
- } from "./chunk-4RSJZOKB.js";
96
+ } from "./chunk-VIS3EVRH.js";
97
+ import {
98
+ POSTTOOLUSE_MIRRORED_TOOLS
99
+ } from "./chunk-7WLKE7QN.js";
93
100
  import {
94
101
  getApiKey,
95
102
  getBaseUrl
96
- } from "./chunk-ANL74IBU.js";
103
+ } from "./chunk-7IHVTLHK.js";
97
104
  import {
98
105
  writeFileAtomic
99
106
  } from "./chunk-TODDEIYG.js";
100
107
  import {
101
108
  NPX_LATEST_COMMAND
102
- } from "./chunk-P5JV6YZW.js";
109
+ } from "./chunk-RZBCXPOV.js";
103
110
  import {
104
111
  AGENT_QUESTION_STRATEGY,
105
112
  AGENT_QUESTION_TOOL,
@@ -169,7 +176,7 @@ import {
169
176
  timeoutActionWithoutLocalPrompt,
170
177
  unansweredRefusalReason,
171
178
  unapprovedScopeReason
172
- } from "./chunk-KB7YWU7A.js";
179
+ } from "./chunk-55AHQF63.js";
173
180
 
174
181
  // src/terminal-answer-watch.ts
175
182
  import { closeSync, openSync, readSync, statSync } from "fs";
@@ -335,6 +342,7 @@ var handlePushOnly = async (apiKey, call, timeoutSeconds, timeoutAction, signals
335
342
  ...decision
336
343
  });
337
344
  } catch (error) {
345
+ signals.askFailed = true;
338
346
  return outcomeOfFailedPermissionAsk(error, sessionId, {
339
347
  refusesUnanswered: refusesWhenUnanswered({ mode: "push_only", timeoutAction }),
340
348
  agentPromptFollows
@@ -394,6 +402,7 @@ var handlePushFirst = async (apiKey, call, pushFirstSeconds, signals) => {
394
402
  ...decision
395
403
  });
396
404
  } catch (error) {
405
+ signals.askFailed = true;
397
406
  return outcomeOfFailedPermissionAsk(error, sessionId, { refusesUnanswered: false, agentPromptFollows }, subscriptionRequiredOutput);
398
407
  }
399
408
  if (isDecisionStopped(result)) return halted(DECISION_STOP_REASON);
@@ -449,6 +458,12 @@ var claimMcpHoldHandback = (fingerprint) => {
449
458
  };
450
459
 
451
460
  // src/hook.ts
461
+ var settledAs = (outcome, output) => ({ output, outcome });
462
+ var settledWithoutAKey = (output) => ({ output, outcome: null });
463
+ var POSTTOOLUSE_REPORTED_TOOLS = new Set(POSTTOOLUSE_MIRRORED_TOOLS);
464
+ var rememberGateOutcome = (input, outcome) => {
465
+ if (outcome !== null && POSTTOOLUSE_REPORTED_TOOLS.has(input.tool_name)) recordGateOutcome(input.tool_use_id, outcome);
466
+ };
452
467
  var START_MS = Date.now();
453
468
  var ACTIVE_AGENT = activeIdentity(process.argv);
454
469
  var ACTIVE_SOURCE = activeHookSource(process.argv);
@@ -463,7 +478,7 @@ var undecidedCall = (reason) => PUSHARY_IS_SOLE_GATE ? deny(reason) : void 0;
463
478
  var handleTerminalOnly = () => {
464
479
  return ask();
465
480
  };
466
- var handleNotifyOnly = async (apiKey, description, projectName, sessionId, machineId) => {
481
+ var handleNotifyOnly = async (apiKey, description, projectName, sessionId, machineId, signals) => {
467
482
  try {
468
483
  await sendNotification(apiKey, {
469
484
  title: "Agent needs approval",
@@ -473,6 +488,7 @@ var handleNotifyOnly = async (apiKey, description, projectName, sessionId, machi
473
488
  machineId
474
489
  });
475
490
  } catch {
491
+ signals.askFailed = true;
476
492
  }
477
493
  return ask();
478
494
  };
@@ -562,6 +578,10 @@ var emitDecisionEpisode = (apiKey, input, toolPolicy, machineId, toolTarget, dec
562
578
  machineId
563
579
  });
564
580
  };
581
+ var outcomeOfDispatch = (decided) => {
582
+ if (decided.mode === "terminal_only") return "terminal_only";
583
+ return decided.askFailed ? "ask_failed" : "asked";
584
+ };
565
585
  var dispatchModeDecision = async (apiKey, input, toolPolicy, machineId, trainingConsent = false, scopeReason, scopePath, terminalLive, askReason, matchedRoute) => {
566
586
  const description = describeToolCall(input.tool_name, input.tool_input, "hook");
567
587
  const projectName = basename(input.cwd ?? process.cwd());
@@ -607,8 +627,8 @@ var dispatchModeDecision = async (apiKey, input, toolPolicy, machineId, training
607
627
  subscriptionRequiredOutput: undecidedCall(SOLE_GATE_SUBSCRIPTION_REASON),
608
628
  announceWait
609
629
  };
630
+ const mode = deliveredWithoutAPrompt ? approvalModeWithoutLocalPrompt(toolPolicy.mode) : toolPolicy.mode;
610
631
  const runHandler = () => {
611
- const mode = deliveredWithoutAPrompt ? approvalModeWithoutLocalPrompt(toolPolicy.mode) : toolPolicy.mode;
612
632
  if (terminalLive && pushesToThePhone(mode)) {
613
633
  return handleTerminalLive(apiKey, input, description, projectName, { ...toolPolicy, mode }, terminalLive.holdBudgetSeconds, machineId, toolTarget, decision, signals);
614
634
  }
@@ -620,7 +640,7 @@ var dispatchModeDecision = async (apiKey, input, toolPolicy, machineId, training
620
640
  case "push_first":
621
641
  return handlePushFirst(apiKey, permissionAsk, toolPolicy.pushFirstSeconds, signals);
622
642
  case "notify_only":
623
- return scopeQuestionHasNoPrompt ? Promise.resolve(deny(unapprovedScopeReason(scopeReason))) : handleNotifyOnly(apiKey, description, projectName, sessionId, machineId);
643
+ return scopeQuestionHasNoPrompt ? Promise.resolve(deny(unapprovedScopeReason(scopeReason))) : handleNotifyOnly(apiKey, description, projectName, sessionId, machineId, signals);
624
644
  default:
625
645
  return handlePushFirst(apiKey, permissionAsk, toolPolicy.pushFirstSeconds, signals);
626
646
  }
@@ -630,7 +650,7 @@ var dispatchModeDecision = async (apiKey, input, toolPolicy, machineId, training
630
650
  if (trainingConsent && signals.humanDecision) {
631
651
  emitDecisionEpisode(apiKey, input, toolPolicy, machineId, toolTarget, decision, result);
632
652
  }
633
- return { result, humanDecision: signals.humanDecision === true };
653
+ return { result, humanDecision: signals.humanDecision === true, mode, askFailed: signals.askFailed === true };
634
654
  };
635
655
  var dispatchModeHandler = async (...args) => (await dispatchModeDecision(...args)).result;
636
656
  var isPhoneApproval = (decided) => decided.humanDecision && decided.result?.hookSpecificOutput.permissionDecision === "allow";
@@ -847,45 +867,47 @@ var rememberHandbackToThePrompt = (input, heldForMcpRoute, result) => {
847
867
  };
848
868
  var isRefusalsOnlyCallInClaudeCode = (input) => ACTIVE_SOURCE === "claude" && isClaudeRefusalsOnlyTool(input.tool_name);
849
869
  var STANDING_REFUSAL_NETWORK_BUDGET_MS = 800;
870
+ var refusalsOnlyOutcomeOf = (toolName) => toolName.startsWith(MCP_TOOL_PREFIX) ? "mcp_tool" : "refusals_only";
850
871
  var standingRefusalOf = async (input) => {
872
+ const noStandingRefusal = refusalsOnlyOutcomeOf(input.tool_name);
851
873
  let apiKey;
852
874
  try {
853
875
  apiKey = getApiKey();
854
876
  } catch {
855
- return void 0;
877
+ return settledWithoutAKey(void 0);
856
878
  }
857
879
  try {
858
880
  const networkBudget = AbortSignal.timeout(STANDING_REFUSAL_NETWORK_BUDGET_MS);
859
881
  const { state: modeState, answeredLive } = await fetchLiveModeState(apiKey, input.session_id, networkBudget);
860
882
  if (modeState.kill) {
861
883
  await reportMachineDenial(input, { kind: "kill", reason: KILL_REASON }, ACTIVE_AGENT);
862
- return halted(KILL_REASON);
884
+ return settledAs("killed", halted(KILL_REASON));
863
885
  }
864
886
  const policy = answeredLive ? await getPolicyForStandingDenies(apiKey, modeState.policyVersion, ACTIVE_AGENT.type, true, input.session_id, networkBudget) : readCachedPolicy(apiKey, ACTIVE_AGENT.type, true);
865
- if (policy === null) return void 0;
887
+ if (policy === null) return settledAs("undecided", void 0);
866
888
  const gateInputFor = (toolName) => claudeGateInput(modeState, policy, { ...input, tool_name: toolName });
867
889
  const asCalled = resolveGate(gateInputFor(input.tool_name));
868
890
  const denied = asCalled.kind === "deny" ? asCalled : standingDenyOfSubagentAlias(input.tool_name, (toolName) => resolveGate(gateInputFor(toolName)));
869
- if (denied === void 0) return void 0;
891
+ if (denied === void 0) return settledAs(noStandingRefusal, void 0);
870
892
  await reportMachineDenial(input, denied, ACTIVE_AGENT);
871
- return deny(denied.reason);
893
+ return settledAs("denied", deny(denied.reason));
872
894
  } catch (error) {
873
895
  await reportHookFailure("pre_tool_use_failed", error);
874
- return void 0;
896
+ return settledAs("undecided", void 0);
875
897
  }
876
898
  };
877
- var handlePreToolUse = async (input, canonical) => {
899
+ var decidePreToolUse = async (input, canonical) => {
878
900
  if (PHONE_APPROVAL_SOURCE) forgetPhoneApproval(PHONE_APPROVAL_SOURCE, input);
879
- if (isPusharyOwnTool(input.tool_name)) return void 0;
901
+ if (isPusharyOwnTool(input.tool_name)) return settledAs("mcp_tool", void 0);
880
902
  if (isRefusalsOnlyCallInClaudeCode(input) && !mcpCallWaitsForSomeoneElse(input)) {
881
- return isPusharyConnectorTool(input.tool_name) ? void 0 : standingRefusalOf(input);
903
+ return isPusharyConnectorTool(input.tool_name) ? settledAs("mcp_tool", void 0) : standingRefusalOf(input);
882
904
  }
883
905
  let apiKey;
884
906
  try {
885
907
  apiKey = getApiKey();
886
908
  } catch {
887
909
  handleKeyless(input);
888
- return undecidedCall(SOLE_GATE_SIGNED_OUT_REASON);
910
+ return settledWithoutAKey(undecidedCall(SOLE_GATE_SIGNED_OUT_REASON));
889
911
  }
890
912
  try {
891
913
  const modeState = await fetchModeState(apiKey, input.session_id);
@@ -894,52 +916,57 @@ var handlePreToolUse = async (input, canonical) => {
894
916
  const verdict = resolveGate(gateInput);
895
917
  if (verdict.kind === "kill") {
896
918
  await reportMachineDenial(input, verdict, ACTIVE_AGENT);
897
- return halted(verdict.reason);
919
+ return settledAs("killed", halted(verdict.reason));
898
920
  }
899
921
  if (verdict.kind === "deny") {
900
922
  await reportMachineDenial(input, verdict, ACTIVE_AGENT);
901
- return deny(verdict.reason);
923
+ return settledAs("denied", deny(verdict.reason));
902
924
  }
903
- if (canonical === null) return deny(UNREADABLE_CALL_REASON);
904
- if (verdict.kind === "gate" && verdict.scopeReason && (canonical?.toolInputs.length ?? 0) > 1) return deny(SCOPE_BATCH_REASON);
905
- if (agentQuestionStrategy(ACTIVE_SOURCE, "PreToolUse", input.tool_name) === AGENT_QUESTION_STRATEGY.native) return void 0;
925
+ if (canonical === null) return settledAs("denied", deny(UNREADABLE_CALL_REASON));
926
+ if (verdict.kind === "gate" && verdict.scopeReason && (canonical?.toolInputs.length ?? 0) > 1) return settledAs("denied", deny(SCOPE_BATCH_REASON));
927
+ if (agentQuestionStrategy(ACTIVE_SOURCE, "PreToolUse", input.tool_name) === AGENT_QUESTION_STRATEGY.native) return settledAs("terminal_only", void 0);
906
928
  if (input.tool_name === "AskUserQuestion") {
907
- return await handleAskUserQuestion(apiKey, input, modeState);
929
+ return settledAs("asked", await handleAskUserQuestion(apiKey, input, modeState));
908
930
  }
909
931
  if (input.tool_name === "ExitPlanMode") {
910
- return await handleExitPlanMode(apiKey, input);
932
+ return settledAs("asked", await handleExitPlanMode(apiKey, input));
911
933
  }
912
934
  const heldForMcpRoute = approvalRouteHoldsMcpCall(gateInput, verdict, input.permission_mode);
913
- if (isMcpCallInClaudeCode(input) && !heldForMcpRoute) return void 0;
914
- if (await claimedBlockedActionRetry(apiKey, input)) return allow(BLOCKED_ACTION_ALLOW_REASON);
915
- if (remindedOfApprovedRetry(input)) return deny(BLOCKED_ACTION_CHANGED_RETRY_REASON);
935
+ if (isMcpCallInClaudeCode(input) && !heldForMcpRoute) return settledAs("mcp_tool", void 0);
936
+ if (await claimedBlockedActionRetry(apiKey, input)) return settledAs("asked", allow(BLOCKED_ACTION_ALLOW_REASON));
937
+ if (remindedOfApprovedRetry(input)) return settledAs("denied", deny(BLOCKED_ACTION_CHANGED_RETRY_REASON));
916
938
  if (!(verdict.kind === "gate" && verdict.scopeReason) && !approvalRouteOutranksAutoMode(gateInput, verdict, input.permission_mode) && !heldForMcpRoute && shouldDeferToNativeMode(input.permission_mode, input.tool_name)) {
917
- return void 0;
939
+ return settledAs("native_mode", void 0);
918
940
  }
919
- if (claudeAllowlistOwnsCall(gateInput, verdict, input.permission_mode, claudePermissionRulesFor(input))) return void 0;
920
- if (editGoesToTheAgentsPrompt({ source: ACTIVE_SOURCE, event: "PreToolUse", permissionMode: input.permission_mode }, gateInput, verdict)) return handleTerminalOnly();
941
+ if (claudeAllowlistOwnsCall(gateInput, verdict, input.permission_mode, claudePermissionRulesFor(input))) return settledAs("claude_allowlist", void 0);
942
+ if (editGoesToTheAgentsPrompt({ source: ACTIVE_SOURCE, event: "PreToolUse", permissionMode: input.permission_mode }, gateInput, verdict)) return settledAs("terminal_only", handleTerminalOnly());
921
943
  switch (verdict.kind) {
922
944
  case "allow":
923
- return allow();
945
+ return settledAs("policy_allow", allow());
924
946
  // No `deny` case: it is handled above the defer, and the compiler enforces
925
947
  // that it stays there. Restoring one here would type-error as unreachable.
926
948
  //
927
949
  // State we could not establish, with an auto-approve on the table. No
928
950
  // opinion, so Claude Code's own flow runs as if the hook were absent.
929
951
  case "defer":
930
- return undecidedCall(SOLE_GATE_UNDECIDED_REASON);
952
+ return settledAs("undecided", undecidedCall(SOLE_GATE_UNDECIDED_REASON));
931
953
  default: {
932
- if (preToolUseHandsOff(input, gateInput, verdict)) return ask(TERMINAL_AND_PHONE_REASON);
954
+ if (preToolUseHandsOff(input, gateInput, verdict)) return settledAs("terminal_only", ask(TERMINAL_AND_PHONE_REASON));
933
955
  const decided = await dispatchModeDecision(apiKey, input, verdict.policy, getMachineId(), modeState.trainingConsent, verdict.scopeReason, verdict.scopePath, void 0, permissionsOffAskReason(gateInput, verdict), matchedRouteOf(gateInput));
934
956
  if (PHONE_APPROVAL_SOURCE && isPhoneApproval(decided)) rememberPhoneApproval(PHONE_APPROVAL_SOURCE, input);
935
- return rememberHandbackToThePrompt(input, heldForMcpRoute, decided.result);
957
+ return settledAs(outcomeOfDispatch(decided), rememberHandbackToThePrompt(input, heldForMcpRoute, decided.result));
936
958
  }
937
959
  }
938
960
  } catch (error) {
939
961
  await reportHookFailure("pre_tool_use_failed", error);
940
- return undecidedCall(SOLE_GATE_UNDECIDED_REASON);
962
+ return settledAs("undecided", undecidedCall(SOLE_GATE_UNDECIDED_REASON));
941
963
  }
942
964
  };
965
+ var handlePreToolUse = async (input, canonical) => {
966
+ const decision = await decidePreToolUse(input, canonical);
967
+ rememberGateOutcome(input, decision.outcome);
968
+ return decision.output;
969
+ };
943
970
  var permReqAllow = (updatedInput) => claudePermissionRequestOutput("allow", void 0, updatedInput);
944
971
  var permReqDeny = (message) => claudePermissionRequestOutput("deny", message);
945
972
  var permReqHalted = (reason) => claudeStoppedPermissionRequestOutput(reason);
@@ -1016,7 +1043,8 @@ var reportPermissionDenied = (input) => reportEvent({
1016
1043
  agentType: ACTIVE_AGENT.type,
1017
1044
  agentName: agentNameIn(basename(input.cwd ?? process.cwd())),
1018
1045
  action: permissionDeniedAction(input.tool_name),
1019
- sessionId: input.session_id
1046
+ sessionId: input.session_id,
1047
+ ...permissionModeOf(input)
1020
1048
  // Side report, not a command carrier. Without timeoutMs this takes the phone's
1021
1049
  // queued instruction and acknowledges it delivered, and this hook can print
1022
1050
  // only {retry}. 4s rather than the Notification path's 2.5s because
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  configFilePath
3
- } from "./chunk-ANL74IBU.js";
3
+ } from "./chunk-7IHVTLHK.js";
4
4
  import {
5
5
  normalizeInstallSource
6
- } from "./chunk-KB7YWU7A.js";
6
+ } from "./chunk-55AHQF63.js";
7
7
 
8
8
  // src/install-source.ts
9
9
  import { readFileSync } from "fs";
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  compatibleConfigFile,
3
3
  hasCompatibleHooks
4
- } from "./chunk-4I4HAPT5.js";
4
+ } from "./chunk-LVGRSC44.js";
5
5
  import {
6
6
  pusharyHookExecutable
7
- } from "./chunk-BMR66K6T.js";
7
+ } from "./chunk-YGHHDDIM.js";
8
8
  import {
9
9
  isProtectedByScope,
10
10
  registerHookEntry
11
- } from "./chunk-MH4O453X.js";
11
+ } from "./chunk-7WLKE7QN.js";
12
12
  import {
13
13
  isRecord
14
- } from "./chunk-KB7YWU7A.js";
14
+ } from "./chunk-55AHQF63.js";
15
15
 
16
16
  // src/cursor-config.ts
17
17
  var hookCommandOf = (entry) => {
@@ -4,13 +4,13 @@ import {
4
4
  configFailureKind,
5
5
  retryAgentCommand,
6
6
  writeSetupConfigFile
7
- } from "./chunk-2N23JFER.js";
7
+ } from "./chunk-Y553AEQU.js";
8
8
  import {
9
9
  MCP_BRIDGE_BINARY
10
- } from "./chunk-DDSMTD4W.js";
10
+ } from "./chunk-BTYHDCAP.js";
11
11
  import {
12
12
  KEY_FILE_MODE
13
- } from "./chunk-2LTRA6NA.js";
13
+ } from "./chunk-Y23YO46U.js";
14
14
  import {
15
15
  CLINE_SERVER_NAME_TAKEN,
16
16
  CLINE_SETTINGS_REFUSALS,
@@ -32,10 +32,10 @@ import {
32
32
  withClinePusharyServer,
33
33
  withRefreshedClineKey,
34
34
  withoutClinePusharyServer
35
- } from "./chunk-MH4O453X.js";
35
+ } from "./chunk-7WLKE7QN.js";
36
36
  import {
37
37
  resolveGlobalBinary
38
- } from "./chunk-PMEDJ4WM.js";
38
+ } from "./chunk-WAFJGQSE.js";
39
39
  import {
40
40
  readJsonSafe,
41
41
  writeFileAtomic,
@@ -7,7 +7,7 @@ import {
7
7
  } from "./chunk-BG4HHB7E.js";
8
8
  import {
9
9
  redactSecretsFromContent
10
- } from "./chunk-KB7YWU7A.js";
10
+ } from "./chunk-55AHQF63.js";
11
11
 
12
12
  // src/cli/json.ts
13
13
  var writeStdoutFully = (text) => new Promise((resolve, reject) => {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  isSafeReadOnlyCommand
3
- } from "./chunk-KB7YWU7A.js";
3
+ } from "./chunk-55AHQF63.js";
4
4
 
5
5
  // src/ledger.ts
6
6
  import { appendFileSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, statSync } from "fs";
@@ -1,19 +1,19 @@
1
1
  import {
2
2
  readExistingMachineId
3
- } from "./chunk-4RSJZOKB.js";
3
+ } from "./chunk-VIS3EVRH.js";
4
+ import {
5
+ getBaseUrl
6
+ } from "./chunk-7IHVTLHK.js";
4
7
  import {
5
8
  NetworkError
6
9
  } from "./chunk-YU2EUD7O.js";
7
- import {
8
- getBaseUrl
9
- } from "./chunk-ANL74IBU.js";
10
10
  import {
11
11
  getPackageVersion
12
- } from "./chunk-WIIMW5YO.js";
12
+ } from "./chunk-UQTQ6HPO.js";
13
13
  import {
14
14
  clientContextHeaders,
15
15
  redactSecretsFromContent
16
- } from "./chunk-KB7YWU7A.js";
16
+ } from "./chunk-55AHQF63.js";
17
17
 
18
18
  // src/cli/net.ts
19
19
  import { createRequire } from "module";
@@ -2,31 +2,31 @@ import {
2
2
  SIGNED_OUT_ON_MAC_MESSAGE,
3
3
  describeSignedOutKey,
4
4
  readSignedOutDiagnosis
5
- } from "./chunk-RF35YTIF.js";
5
+ } from "./chunk-6OSE2IRG.js";
6
6
  import {
7
7
  APPROVAL_RULES_PATH
8
- } from "./chunk-EQF6SSQL.js";
8
+ } from "./chunk-ONMAG5BF.js";
9
9
  import {
10
10
  createIo
11
- } from "./chunk-UOVTXOSS.js";
11
+ } from "./chunk-XWCLKWKP.js";
12
12
  import {
13
13
  absoluteUrl,
14
14
  checkApiKey,
15
15
  describeKeyCheck,
16
16
  keyCheckFromResponse
17
- } from "./chunk-C4K4KYOY.js";
17
+ } from "./chunk-I5HXAELM.js";
18
18
  import {
19
19
  readKeySource
20
- } from "./chunk-2LTRA6NA.js";
20
+ } from "./chunk-Y23YO46U.js";
21
21
  import {
22
22
  getBaseUrl
23
- } from "./chunk-ANL74IBU.js";
23
+ } from "./chunk-7IHVTLHK.js";
24
24
  import {
25
25
  EXIT
26
26
  } from "./chunk-BG4HHB7E.js";
27
27
  import {
28
28
  KEY_SCOPE
29
- } from "./chunk-KB7YWU7A.js";
29
+ } from "./chunk-55AHQF63.js";
30
30
 
31
31
  // src/cli/report-key.ts
32
32
  var { dim, yellow } = createIo();
@@ -108,5 +108,6 @@ var exitOnFailedSettingsRequest = async (response, settings) => {
108
108
 
109
109
  export {
110
110
  printKeyCheck,
111
+ exitOnFailedResponse,
111
112
  exitOnFailedSettingsRequest
112
113
  };
@@ -1,19 +1,19 @@
1
1
  import {
2
2
  pusharyFetch
3
- } from "./chunk-E2KAAKWU.js";
3
+ } from "./chunk-HKCJZGAJ.js";
4
+ import {
5
+ getBaseUrl
6
+ } from "./chunk-7IHVTLHK.js";
4
7
  import {
5
8
  NetworkError
6
9
  } from "./chunk-YU2EUD7O.js";
7
- import {
8
- getBaseUrl
9
- } from "./chunk-ANL74IBU.js";
10
10
  import {
11
11
  EXIT
12
12
  } from "./chunk-BG4HHB7E.js";
13
13
  import {
14
14
  isValidApiKey,
15
15
  normalizeKeyScope
16
- } from "./chunk-KB7YWU7A.js";
16
+ } from "./chunk-55AHQF63.js";
17
17
 
18
18
  // src/session.ts
19
19
  var samePusharyAccount = (left, right) => left.kind === "ok" && right.kind === "ok" && left.identity.workspaceId !== "" && left.identity.workspaceId === right.identity.workspaceId && left.identity.siteId === right.identity.siteId;
@@ -3,10 +3,10 @@ import {
3
3
  } from "./chunk-BG4HHB7E.js";
4
4
  import {
5
5
  renderCommandHelp
6
- } from "./chunk-P5JV6YZW.js";
6
+ } from "./chunk-RZBCXPOV.js";
7
7
  import {
8
8
  getPackageVersion
9
- } from "./chunk-WIIMW5YO.js";
9
+ } from "./chunk-UQTQ6HPO.js";
10
10
 
11
11
  // src/cli/usage.ts
12
12
  var exitOnHelpFlag = (command) => {