@pushary/agent-hooks 1.9.157 → 1.9.158

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 (136) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/{api-3C62HQDC.js → api-MRFKFDVV.js} +11 -11
  3. package/dist/bin/pushary-audit.js +3 -3
  4. package/dist/bin/pushary-bell-hook.js +28 -28
  5. package/dist/bin/pushary-bell.js +11 -11
  6. package/dist/bin/pushary-claude.js +27 -27
  7. package/dist/bin/pushary-clean.js +37 -37
  8. package/dist/bin/pushary-codex-bridge.js +23 -23
  9. package/dist/bin/pushary-codex-hook.js +50 -42
  10. package/dist/bin/pushary-codex-session.js +8 -8
  11. package/dist/bin/pushary-codex.js +16 -16
  12. package/dist/bin/pushary-connect.js +33 -33
  13. package/dist/bin/pushary-cowork.js +5 -5
  14. package/dist/bin/pushary-daemon.js +44 -44
  15. package/dist/bin/pushary-disconnect.js +28 -28
  16. package/dist/bin/pushary-doctor.js +45 -45
  17. package/dist/bin/pushary-elicitation-hook.js +28 -28
  18. package/dist/bin/pushary-gemini-bridge.js +17 -17
  19. package/dist/bin/pushary-gemini-hook.js +32 -32
  20. package/dist/bin/pushary-hook.js +35 -35
  21. package/dist/bin/pushary-login.js +22 -22
  22. package/dist/bin/pushary-logout.js +28 -28
  23. package/dist/bin/pushary-mcp.js +12 -12
  24. package/dist/bin/pushary-mode.js +16 -16
  25. package/dist/bin/pushary-notification-hook.js +27 -27
  26. package/dist/bin/pushary-opencode-hook.js +31 -31
  27. package/dist/bin/pushary-permission-denied-hook.js +35 -35
  28. package/dist/bin/pushary-permission-hook.js +35 -35
  29. package/dist/bin/pushary-post-hook.js +28 -28
  30. package/dist/bin/pushary-prompt-hook.js +27 -27
  31. package/dist/bin/pushary-session-end-hook.js +27 -27
  32. package/dist/bin/pushary-session-start-hook.js +37 -37
  33. package/dist/bin/pushary-setup.js +53 -53
  34. package/dist/bin/pushary-stats.js +5 -5
  35. package/dist/bin/pushary-status.js +34 -34
  36. package/dist/bin/pushary-stop-hook.js +27 -27
  37. package/dist/bin/pushary-stopfailure-hook.js +27 -27
  38. package/dist/bin/pushary-suggestions.js +16 -16
  39. package/dist/bin/pushary-transcript-register.js +17 -17
  40. package/dist/bin/pushary-transcripts.js +25 -25
  41. package/dist/bin/pushary-upgrade.js +42 -42
  42. package/dist/bin/pushary-wait.js +16 -16
  43. package/dist/bin/pushary.js +7 -7
  44. package/dist/{chunk-2N23JFER.js → chunk-2L52USKM.js} +3 -3
  45. package/dist/{chunk-XHPTW6WL.js → chunk-2MPT7YQK.js} +2 -2
  46. package/dist/{chunk-7JAEIKBV.js → chunk-3QU4WXAH.js} +5 -5
  47. package/dist/{chunk-VRLYEBDN.js → chunk-3UNZ7HRN.js} +75 -49
  48. package/dist/{chunk-O3NAHPCR.js → chunk-4B5K6YIP.js} +1 -1
  49. package/dist/{chunk-CHI57HS3.js → chunk-4I2SHNEU.js} +3 -3
  50. package/dist/{chunk-T3LSBTWU.js → chunk-4NHQAMSK.js} +2 -2
  51. package/dist/{chunk-5HMVXNFU.js → chunk-4SN4FHFZ.js} +2 -2
  52. package/dist/{chunk-UJJ2OXFA.js → chunk-4WL2MINE.js} +1 -1
  53. package/dist/{chunk-GA5T3WEB.js → chunk-6GGK3T24.js} +5 -5
  54. package/dist/{chunk-3FQJYA76.js → chunk-AGYD6XNI.js} +3 -3
  55. package/dist/{chunk-V4OIPLSC.js → chunk-ALQWZCUT.js} +4 -4
  56. package/dist/{chunk-C3HYWUZE.js → chunk-AMIUB22C.js} +1 -1
  57. package/dist/{chunk-QONYKXWP.js → chunk-ANQBLZAE.js} +1 -1
  58. package/dist/{chunk-P5JV6YZW.js → chunk-AOP55JR2.js} +1 -1
  59. package/dist/{chunk-AKUYCHJU.js → chunk-APCJZFTJ.js} +1 -1
  60. package/dist/{chunk-5MWNWCCI.js → chunk-AZZNHW3R.js} +4 -4
  61. package/dist/{chunk-MH4O453X.js → chunk-B3BOAYRO.js} +3 -2
  62. package/dist/{chunk-UH5NAPWL.js → chunk-C6PAIHLP.js} +10 -10
  63. package/dist/{chunk-TIOQ55VZ.js → chunk-CAMFNSJS.js} +6 -6
  64. package/dist/{chunk-HXX4EFK3.js → chunk-CCKY3JDB.js} +3 -3
  65. package/dist/{chunk-2NSPZZBJ.js → chunk-CIAJ55EQ.js} +5 -5
  66. package/dist/{chunk-ICHKAH5Q.js → chunk-CS4Z44F5.js} +6 -6
  67. package/dist/{chunk-WIOLCW7W.js → chunk-CSZWWPNS.js} +1 -1
  68. package/dist/{chunk-RF35YTIF.js → chunk-DHI3X5WK.js} +2 -2
  69. package/dist/{chunk-MEUAK5BK.js → chunk-EGBI4GRS.js} +2 -2
  70. package/dist/{chunk-CV6G4IDZ.js → chunk-EHRWEXRN.js} +2 -2
  71. package/dist/{chunk-6UGVZTRA.js → chunk-FGVBFDNV.js} +1 -1
  72. package/dist/{chunk-ANL74IBU.js → chunk-FTTSQAF4.js} +1 -1
  73. package/dist/{chunk-UOVTXOSS.js → chunk-GHHVXARK.js} +1 -1
  74. package/dist/{chunk-BO4HRAY7.js → chunk-GLDSXDRV.js} +5 -5
  75. package/dist/{chunk-3EF7G5EV.js → chunk-GTYVNVBZ.js} +4 -4
  76. package/dist/{chunk-KB7YWU7A.js → chunk-HA2SRYYP.js} +18 -0
  77. package/dist/{chunk-7HDQUTRK.js → chunk-IIK3CZXJ.js} +7 -7
  78. package/dist/{chunk-2SHPCEH6.js → chunk-IKC33YKC.js} +1 -1
  79. package/dist/{chunk-W2GOSAFI.js → chunk-IOKJJ2SY.js} +4 -4
  80. package/dist/{chunk-PMEDJ4WM.js → chunk-IVOELLUK.js} +4 -4
  81. package/dist/{chunk-RF7HGOBC.js → chunk-J7HSUQK2.js} +2 -2
  82. package/dist/{chunk-WWDWEVGT.js → chunk-JKRQL2BL.js} +5 -5
  83. package/dist/{chunk-5TCLBCUO.js → chunk-K3I2NMEF.js} +6 -6
  84. package/dist/{chunk-DDSMTD4W.js → chunk-K3OCYJPK.js} +3 -3
  85. package/dist/{chunk-25PVMWSM.js → chunk-LVZBLKAU.js} +1 -1
  86. package/dist/{chunk-4RSJZOKB.js → chunk-MHYX5Q3F.js} +1 -1
  87. package/dist/{chunk-44FDCO7M.js → chunk-MLPPQ556.js} +8 -8
  88. package/dist/{chunk-4I4HAPT5.js → chunk-MTITL2IG.js} +5 -5
  89. package/dist/{chunk-KRI7BOND.js → chunk-N2LWKWNY.js} +3 -3
  90. package/dist/{chunk-WDU4LEEW.js → chunk-N3CFEMLS.js} +2 -2
  91. package/dist/{chunk-KURQ4KMV.js → chunk-N5SSADNW.js} +4 -4
  92. package/dist/{chunk-G6SQOGSD.js → chunk-NW63PGKF.js} +4 -4
  93. package/dist/{chunk-O2DJWDVK.js → chunk-OCWXE4PR.js} +8 -8
  94. package/dist/{chunk-WCVANKUD.js → chunk-ORQ7THNZ.js} +1 -1
  95. package/dist/{chunk-C4K4KYOY.js → chunk-PBPQRJ2T.js} +3 -3
  96. package/dist/{chunk-PKU3WFT5.js → chunk-PI3BOI3A.js} +1 -1
  97. package/dist/{chunk-E2KAAKWU.js → chunk-PND5IGC7.js} +3 -3
  98. package/dist/{chunk-UAYNQ2IG.js → chunk-Q7WCDUFV.js} +4 -4
  99. package/dist/{chunk-QBDCKECQ.js → chunk-QP3TCKRZ.js} +117 -29
  100. package/dist/{chunk-3UYTCDDY.js → chunk-QVVBU2JU.js} +6 -6
  101. package/dist/{chunk-WSPDIT2B.js → chunk-RL5JLDRE.js} +2 -2
  102. package/dist/{chunk-F6ZBXV4G.js → chunk-RRVFN432.js} +1 -1
  103. package/dist/{chunk-JBF6A2X5.js → chunk-SNQOEDZ2.js} +1 -1
  104. package/dist/{chunk-EQF6SSQL.js → chunk-SZMDRBNK.js} +2 -2
  105. package/dist/{chunk-MGT2V2AB.js → chunk-T3PZQNIK.js} +1 -1
  106. package/dist/{chunk-S6DJAYQW.js → chunk-TKBCLK4B.js} +5 -5
  107. package/dist/{chunk-CAZ5FMWP.js → chunk-TMWXWBFP.js} +6 -6
  108. package/dist/{chunk-BMR66K6T.js → chunk-TPLTB256.js} +4 -4
  109. package/dist/{chunk-TWOSBIAW.js → chunk-TSR3FPGL.js} +1 -1
  110. package/dist/{chunk-R4DMHIOK.js → chunk-TYBVQ33X.js} +5 -5
  111. package/dist/{chunk-MOX7IOGL.js → chunk-TZJR5ESF.js} +5 -5
  112. package/dist/{chunk-ELF4NIIM.js → chunk-UDLWNOXX.js} +2 -2
  113. package/dist/{chunk-3XTH6EKH.js → chunk-UPI3JDHZ.js} +3 -3
  114. package/dist/{chunk-WDCS3RGI.js → chunk-UVWKMFLQ.js} +2 -2
  115. package/dist/{chunk-6NRFAP45.js → chunk-V36P4KS4.js} +1 -1
  116. package/dist/{chunk-6W6MZ53D.js → chunk-X254TRBU.js} +4 -4
  117. package/dist/{chunk-REUFDG7O.js → chunk-XHCX6DOY.js} +5 -5
  118. package/dist/{chunk-KOBIBSE6.js → chunk-XNJ2HOEL.js} +3 -3
  119. package/dist/{chunk-C74JHUD3.js → chunk-XSIZKQ2C.js} +11 -11
  120. package/dist/{chunk-IQWMRFKD.js → chunk-YPFOTFEG.js} +1 -1
  121. package/dist/{chunk-2LTRA6NA.js → chunk-ZYDE6QRW.js} +3 -3
  122. package/dist/{codex-app-cards-switch-MQIEZLSU.js → codex-app-cards-switch-CXXDGH7R.js} +11 -11
  123. package/dist/{codex-card-routing-UTWTJ6YQ.js → codex-card-routing-WP4IHJFN.js} +2 -2
  124. package/dist/{codex-desktop-launch-A6GX6F54.js → codex-desktop-launch-EN7ACHC6.js} +1 -1
  125. package/dist/{codex-session-launch-AVEFGOT7.js → codex-session-launch-7BV4VTJW.js} +20 -20
  126. package/dist/{config-YGUXX5GB.js → config-SZMMBOJV.js} +3 -3
  127. package/dist/{global-upgrade-HLXPTFDU.js → global-upgrade-I5J6BDHA.js} +9 -9
  128. package/dist/{identity-CAC763RQ.js → identity-GLJNTNHW.js} +4 -4
  129. package/dist/{live-capabilities-WRI22INV.js → live-capabilities-AYO7FOHS.js} +4 -4
  130. package/dist/{paths-DNXBDJJH.js → paths-NRBEF3T2.js} +3 -3
  131. package/dist/{reapply-5ZNMLEKV.js → reapply-J2QUV7J2.js} +30 -30
  132. package/dist/src/index.d.ts +6 -1
  133. package/dist/src/index.js +34 -34
  134. package/dist/{upgrade-lock-CRW26OIW.js → upgrade-lock-H6SU7MJR.js} +4 -4
  135. package/dist/{usage-AWWCZ7H7.js → usage-MY3DIFBG.js} +3 -3
  136. package/package.json +1 -1
@@ -2,37 +2,37 @@ import {
2
2
  forgetPhoneApproval,
3
3
  rememberPhoneApproval,
4
4
  takePhoneApproval
5
- } from "./chunk-5HMVXNFU.js";
5
+ } from "./chunk-4SN4FHFZ.js";
6
6
  import {
7
7
  claudeSettingsLocationFor,
8
8
  readClaudePermissionRules
9
- } from "./chunk-WSPDIT2B.js";
9
+ } from "./chunk-RL5JLDRE.js";
10
10
  import {
11
11
  askAgentQuestions,
12
12
  defersToNativeMode,
13
13
  outcomeOfFailedAsk,
14
14
  storedWaitDeadline
15
- } from "./chunk-2NSPZZBJ.js";
15
+ } from "./chunk-CIAJ55EQ.js";
16
16
  import {
17
17
  reportMachineDenial
18
- } from "./chunk-3XTH6EKH.js";
18
+ } from "./chunk-UPI3JDHZ.js";
19
19
  import {
20
20
  isGatingMoment,
21
21
  recordKeylessMoment
22
- } from "./chunk-C3HYWUZE.js";
22
+ } from "./chunk-AMIUB22C.js";
23
23
  import {
24
24
  isAdmitted,
25
25
  readAdmissionRules
26
- } from "./chunk-7JAEIKBV.js";
26
+ } from "./chunk-3QU4WXAH.js";
27
27
  import {
28
28
  isDeferAnswer,
29
29
  oncePerSession
30
- } from "./chunk-IQWMRFKD.js";
30
+ } from "./chunk-YPFOTFEG.js";
31
31
  import {
32
32
  activeHookSource,
33
33
  activeIdentity,
34
34
  namedSource
35
- } from "./chunk-4I4HAPT5.js";
35
+ } from "./chunk-MTITL2IG.js";
36
36
  import {
37
37
  DEFAULT_SESSION,
38
38
  approvalAwaitingRetry,
@@ -45,15 +45,17 @@ import {
45
45
  getPolicyForStandingDenies,
46
46
  hasBlockedActionHint,
47
47
  markApprovalReminded,
48
+ permissionModeOf,
48
49
  readCachedPolicy,
49
50
  readLastPrompt,
50
51
  readLastUserPrompt,
51
52
  recordBlockedActionHint,
53
+ recordGateOutcome,
52
54
  reportEvent,
53
55
  settleQuestionsForToolUse,
54
56
  sweepFilesOlderThan,
55
57
  userScope
56
- } from "./chunk-QBDCKECQ.js";
58
+ } from "./chunk-QP3TCKRZ.js";
57
59
  import {
58
60
  UNNAMED_ACTION,
59
61
  deriveAction,
@@ -64,12 +66,12 @@ import {
64
66
  patchDeletesFiles,
65
67
  permissionDeniedAction,
66
68
  scopePathFor
67
- } from "./chunk-2SHPCEH6.js";
69
+ } from "./chunk-IKC33YKC.js";
68
70
  import {
69
71
  branchFor,
70
72
  repoKeyFor,
71
73
  repositoryScopeFor
72
- } from "./chunk-UJJ2OXFA.js";
74
+ } from "./chunk-4WL2MINE.js";
73
75
  import {
74
76
  askUser,
75
77
  cancelQuestion,
@@ -86,20 +88,23 @@ import {
86
88
  waitForQuestion,
87
89
  waitsForThePhone,
88
90
  withdrawQuestion
89
- } from "./chunk-ICHKAH5Q.js";
91
+ } from "./chunk-CS4Z44F5.js";
90
92
  import {
91
93
  getMachineId
92
- } from "./chunk-4RSJZOKB.js";
94
+ } from "./chunk-MHYX5Q3F.js";
95
+ import {
96
+ POSTTOOLUSE_MIRRORED_TOOLS
97
+ } from "./chunk-B3BOAYRO.js";
93
98
  import {
94
99
  getApiKey,
95
100
  getBaseUrl
96
- } from "./chunk-ANL74IBU.js";
101
+ } from "./chunk-FTTSQAF4.js";
97
102
  import {
98
103
  writeFileAtomic
99
104
  } from "./chunk-TODDEIYG.js";
100
105
  import {
101
106
  NPX_LATEST_COMMAND
102
- } from "./chunk-P5JV6YZW.js";
107
+ } from "./chunk-AOP55JR2.js";
103
108
  import {
104
109
  AGENT_QUESTION_STRATEGY,
105
110
  AGENT_QUESTION_TOOL,
@@ -169,7 +174,7 @@ import {
169
174
  timeoutActionWithoutLocalPrompt,
170
175
  unansweredRefusalReason,
171
176
  unapprovedScopeReason
172
- } from "./chunk-KB7YWU7A.js";
177
+ } from "./chunk-HA2SRYYP.js";
173
178
 
174
179
  // src/terminal-answer-watch.ts
175
180
  import { closeSync, openSync, readSync, statSync } from "fs";
@@ -335,6 +340,7 @@ var handlePushOnly = async (apiKey, call, timeoutSeconds, timeoutAction, signals
335
340
  ...decision
336
341
  });
337
342
  } catch (error) {
343
+ signals.askFailed = true;
338
344
  return outcomeOfFailedPermissionAsk(error, sessionId, {
339
345
  refusesUnanswered: refusesWhenUnanswered({ mode: "push_only", timeoutAction }),
340
346
  agentPromptFollows
@@ -394,6 +400,7 @@ var handlePushFirst = async (apiKey, call, pushFirstSeconds, signals) => {
394
400
  ...decision
395
401
  });
396
402
  } catch (error) {
403
+ signals.askFailed = true;
397
404
  return outcomeOfFailedPermissionAsk(error, sessionId, { refusesUnanswered: false, agentPromptFollows }, subscriptionRequiredOutput);
398
405
  }
399
406
  if (isDecisionStopped(result)) return halted(DECISION_STOP_REASON);
@@ -449,6 +456,12 @@ var claimMcpHoldHandback = (fingerprint) => {
449
456
  };
450
457
 
451
458
  // src/hook.ts
459
+ var settledAs = (outcome, output) => ({ output, outcome });
460
+ var settledWithoutAKey = (output) => ({ output, outcome: null });
461
+ var POSTTOOLUSE_REPORTED_TOOLS = new Set(POSTTOOLUSE_MIRRORED_TOOLS);
462
+ var rememberGateOutcome = (input, outcome) => {
463
+ if (outcome !== null && POSTTOOLUSE_REPORTED_TOOLS.has(input.tool_name)) recordGateOutcome(input.tool_use_id, outcome);
464
+ };
452
465
  var START_MS = Date.now();
453
466
  var ACTIVE_AGENT = activeIdentity(process.argv);
454
467
  var ACTIVE_SOURCE = activeHookSource(process.argv);
@@ -463,7 +476,7 @@ var undecidedCall = (reason) => PUSHARY_IS_SOLE_GATE ? deny(reason) : void 0;
463
476
  var handleTerminalOnly = () => {
464
477
  return ask();
465
478
  };
466
- var handleNotifyOnly = async (apiKey, description, projectName, sessionId, machineId) => {
479
+ var handleNotifyOnly = async (apiKey, description, projectName, sessionId, machineId, signals) => {
467
480
  try {
468
481
  await sendNotification(apiKey, {
469
482
  title: "Agent needs approval",
@@ -473,6 +486,7 @@ var handleNotifyOnly = async (apiKey, description, projectName, sessionId, machi
473
486
  machineId
474
487
  });
475
488
  } catch {
489
+ signals.askFailed = true;
476
490
  }
477
491
  return ask();
478
492
  };
@@ -562,6 +576,10 @@ var emitDecisionEpisode = (apiKey, input, toolPolicy, machineId, toolTarget, dec
562
576
  machineId
563
577
  });
564
578
  };
579
+ var outcomeOfDispatch = (decided) => {
580
+ if (decided.mode === "terminal_only") return "terminal_only";
581
+ return decided.askFailed ? "ask_failed" : "asked";
582
+ };
565
583
  var dispatchModeDecision = async (apiKey, input, toolPolicy, machineId, trainingConsent = false, scopeReason, scopePath, terminalLive, askReason, matchedRoute) => {
566
584
  const description = describeToolCall(input.tool_name, input.tool_input, "hook");
567
585
  const projectName = basename(input.cwd ?? process.cwd());
@@ -607,8 +625,8 @@ var dispatchModeDecision = async (apiKey, input, toolPolicy, machineId, training
607
625
  subscriptionRequiredOutput: undecidedCall(SOLE_GATE_SUBSCRIPTION_REASON),
608
626
  announceWait
609
627
  };
628
+ const mode = deliveredWithoutAPrompt ? approvalModeWithoutLocalPrompt(toolPolicy.mode) : toolPolicy.mode;
610
629
  const runHandler = () => {
611
- const mode = deliveredWithoutAPrompt ? approvalModeWithoutLocalPrompt(toolPolicy.mode) : toolPolicy.mode;
612
630
  if (terminalLive && pushesToThePhone(mode)) {
613
631
  return handleTerminalLive(apiKey, input, description, projectName, { ...toolPolicy, mode }, terminalLive.holdBudgetSeconds, machineId, toolTarget, decision, signals);
614
632
  }
@@ -620,7 +638,7 @@ var dispatchModeDecision = async (apiKey, input, toolPolicy, machineId, training
620
638
  case "push_first":
621
639
  return handlePushFirst(apiKey, permissionAsk, toolPolicy.pushFirstSeconds, signals);
622
640
  case "notify_only":
623
- return scopeQuestionHasNoPrompt ? Promise.resolve(deny(unapprovedScopeReason(scopeReason))) : handleNotifyOnly(apiKey, description, projectName, sessionId, machineId);
641
+ return scopeQuestionHasNoPrompt ? Promise.resolve(deny(unapprovedScopeReason(scopeReason))) : handleNotifyOnly(apiKey, description, projectName, sessionId, machineId, signals);
624
642
  default:
625
643
  return handlePushFirst(apiKey, permissionAsk, toolPolicy.pushFirstSeconds, signals);
626
644
  }
@@ -630,7 +648,7 @@ var dispatchModeDecision = async (apiKey, input, toolPolicy, machineId, training
630
648
  if (trainingConsent && signals.humanDecision) {
631
649
  emitDecisionEpisode(apiKey, input, toolPolicy, machineId, toolTarget, decision, result);
632
650
  }
633
- return { result, humanDecision: signals.humanDecision === true };
651
+ return { result, humanDecision: signals.humanDecision === true, mode, askFailed: signals.askFailed === true };
634
652
  };
635
653
  var dispatchModeHandler = async (...args) => (await dispatchModeDecision(...args)).result;
636
654
  var isPhoneApproval = (decided) => decided.humanDecision && decided.result?.hookSpecificOutput.permissionDecision === "allow";
@@ -847,45 +865,47 @@ var rememberHandbackToThePrompt = (input, heldForMcpRoute, result) => {
847
865
  };
848
866
  var isRefusalsOnlyCallInClaudeCode = (input) => ACTIVE_SOURCE === "claude" && isClaudeRefusalsOnlyTool(input.tool_name);
849
867
  var STANDING_REFUSAL_NETWORK_BUDGET_MS = 800;
868
+ var refusalsOnlyOutcomeOf = (toolName) => toolName.startsWith(MCP_TOOL_PREFIX) ? "mcp_tool" : "refusals_only";
850
869
  var standingRefusalOf = async (input) => {
870
+ const noStandingRefusal = refusalsOnlyOutcomeOf(input.tool_name);
851
871
  let apiKey;
852
872
  try {
853
873
  apiKey = getApiKey();
854
874
  } catch {
855
- return void 0;
875
+ return settledWithoutAKey(void 0);
856
876
  }
857
877
  try {
858
878
  const networkBudget = AbortSignal.timeout(STANDING_REFUSAL_NETWORK_BUDGET_MS);
859
879
  const { state: modeState, answeredLive } = await fetchLiveModeState(apiKey, input.session_id, networkBudget);
860
880
  if (modeState.kill) {
861
881
  await reportMachineDenial(input, { kind: "kill", reason: KILL_REASON }, ACTIVE_AGENT);
862
- return halted(KILL_REASON);
882
+ return settledAs("killed", halted(KILL_REASON));
863
883
  }
864
884
  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;
885
+ if (policy === null) return settledAs("undecided", void 0);
866
886
  const gateInputFor = (toolName) => claudeGateInput(modeState, policy, { ...input, tool_name: toolName });
867
887
  const asCalled = resolveGate(gateInputFor(input.tool_name));
868
888
  const denied = asCalled.kind === "deny" ? asCalled : standingDenyOfSubagentAlias(input.tool_name, (toolName) => resolveGate(gateInputFor(toolName)));
869
- if (denied === void 0) return void 0;
889
+ if (denied === void 0) return settledAs(noStandingRefusal, void 0);
870
890
  await reportMachineDenial(input, denied, ACTIVE_AGENT);
871
- return deny(denied.reason);
891
+ return settledAs("denied", deny(denied.reason));
872
892
  } catch (error) {
873
893
  await reportHookFailure("pre_tool_use_failed", error);
874
- return void 0;
894
+ return settledAs("undecided", void 0);
875
895
  }
876
896
  };
877
- var handlePreToolUse = async (input, canonical) => {
897
+ var decidePreToolUse = async (input, canonical) => {
878
898
  if (PHONE_APPROVAL_SOURCE) forgetPhoneApproval(PHONE_APPROVAL_SOURCE, input);
879
- if (isPusharyOwnTool(input.tool_name)) return void 0;
899
+ if (isPusharyOwnTool(input.tool_name)) return settledAs("mcp_tool", void 0);
880
900
  if (isRefusalsOnlyCallInClaudeCode(input) && !mcpCallWaitsForSomeoneElse(input)) {
881
- return isPusharyConnectorTool(input.tool_name) ? void 0 : standingRefusalOf(input);
901
+ return isPusharyConnectorTool(input.tool_name) ? settledAs("mcp_tool", void 0) : standingRefusalOf(input);
882
902
  }
883
903
  let apiKey;
884
904
  try {
885
905
  apiKey = getApiKey();
886
906
  } catch {
887
907
  handleKeyless(input);
888
- return undecidedCall(SOLE_GATE_SIGNED_OUT_REASON);
908
+ return settledWithoutAKey(undecidedCall(SOLE_GATE_SIGNED_OUT_REASON));
889
909
  }
890
910
  try {
891
911
  const modeState = await fetchModeState(apiKey, input.session_id);
@@ -894,52 +914,57 @@ var handlePreToolUse = async (input, canonical) => {
894
914
  const verdict = resolveGate(gateInput);
895
915
  if (verdict.kind === "kill") {
896
916
  await reportMachineDenial(input, verdict, ACTIVE_AGENT);
897
- return halted(verdict.reason);
917
+ return settledAs("killed", halted(verdict.reason));
898
918
  }
899
919
  if (verdict.kind === "deny") {
900
920
  await reportMachineDenial(input, verdict, ACTIVE_AGENT);
901
- return deny(verdict.reason);
921
+ return settledAs("denied", deny(verdict.reason));
902
922
  }
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;
923
+ if (canonical === null) return settledAs("denied", deny(UNREADABLE_CALL_REASON));
924
+ if (verdict.kind === "gate" && verdict.scopeReason && (canonical?.toolInputs.length ?? 0) > 1) return settledAs("denied", deny(SCOPE_BATCH_REASON));
925
+ if (agentQuestionStrategy(ACTIVE_SOURCE, "PreToolUse", input.tool_name) === AGENT_QUESTION_STRATEGY.native) return settledAs("terminal_only", void 0);
906
926
  if (input.tool_name === "AskUserQuestion") {
907
- return await handleAskUserQuestion(apiKey, input, modeState);
927
+ return settledAs("asked", await handleAskUserQuestion(apiKey, input, modeState));
908
928
  }
909
929
  if (input.tool_name === "ExitPlanMode") {
910
- return await handleExitPlanMode(apiKey, input);
930
+ return settledAs("asked", await handleExitPlanMode(apiKey, input));
911
931
  }
912
932
  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);
933
+ if (isMcpCallInClaudeCode(input) && !heldForMcpRoute) return settledAs("mcp_tool", void 0);
934
+ if (await claimedBlockedActionRetry(apiKey, input)) return settledAs("asked", allow(BLOCKED_ACTION_ALLOW_REASON));
935
+ if (remindedOfApprovedRetry(input)) return settledAs("denied", deny(BLOCKED_ACTION_CHANGED_RETRY_REASON));
916
936
  if (!(verdict.kind === "gate" && verdict.scopeReason) && !approvalRouteOutranksAutoMode(gateInput, verdict, input.permission_mode) && !heldForMcpRoute && shouldDeferToNativeMode(input.permission_mode, input.tool_name)) {
917
- return void 0;
937
+ return settledAs("native_mode", void 0);
918
938
  }
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();
939
+ if (claudeAllowlistOwnsCall(gateInput, verdict, input.permission_mode, claudePermissionRulesFor(input))) return settledAs("claude_allowlist", void 0);
940
+ if (editGoesToTheAgentsPrompt({ source: ACTIVE_SOURCE, event: "PreToolUse", permissionMode: input.permission_mode }, gateInput, verdict)) return settledAs("terminal_only", handleTerminalOnly());
921
941
  switch (verdict.kind) {
922
942
  case "allow":
923
- return allow();
943
+ return settledAs("policy_allow", allow());
924
944
  // No `deny` case: it is handled above the defer, and the compiler enforces
925
945
  // that it stays there. Restoring one here would type-error as unreachable.
926
946
  //
927
947
  // State we could not establish, with an auto-approve on the table. No
928
948
  // opinion, so Claude Code's own flow runs as if the hook were absent.
929
949
  case "defer":
930
- return undecidedCall(SOLE_GATE_UNDECIDED_REASON);
950
+ return settledAs("undecided", undecidedCall(SOLE_GATE_UNDECIDED_REASON));
931
951
  default: {
932
- if (preToolUseHandsOff(input, gateInput, verdict)) return ask(TERMINAL_AND_PHONE_REASON);
952
+ if (preToolUseHandsOff(input, gateInput, verdict)) return settledAs("terminal_only", ask(TERMINAL_AND_PHONE_REASON));
933
953
  const decided = await dispatchModeDecision(apiKey, input, verdict.policy, getMachineId(), modeState.trainingConsent, verdict.scopeReason, verdict.scopePath, void 0, permissionsOffAskReason(gateInput, verdict), matchedRouteOf(gateInput));
934
954
  if (PHONE_APPROVAL_SOURCE && isPhoneApproval(decided)) rememberPhoneApproval(PHONE_APPROVAL_SOURCE, input);
935
- return rememberHandbackToThePrompt(input, heldForMcpRoute, decided.result);
955
+ return settledAs(outcomeOfDispatch(decided), rememberHandbackToThePrompt(input, heldForMcpRoute, decided.result));
936
956
  }
937
957
  }
938
958
  } catch (error) {
939
959
  await reportHookFailure("pre_tool_use_failed", error);
940
- return undecidedCall(SOLE_GATE_UNDECIDED_REASON);
960
+ return settledAs("undecided", undecidedCall(SOLE_GATE_UNDECIDED_REASON));
941
961
  }
942
962
  };
963
+ var handlePreToolUse = async (input, canonical) => {
964
+ const decision = await decidePreToolUse(input, canonical);
965
+ rememberGateOutcome(input, decision.outcome);
966
+ return decision.output;
967
+ };
943
968
  var permReqAllow = (updatedInput) => claudePermissionRequestOutput("allow", void 0, updatedInput);
944
969
  var permReqDeny = (message) => claudePermissionRequestOutput("deny", message);
945
970
  var permReqHalted = (reason) => claudeStoppedPermissionRequestOutput(reason);
@@ -1016,7 +1041,8 @@ var reportPermissionDenied = (input) => reportEvent({
1016
1041
  agentType: ACTIVE_AGENT.type,
1017
1042
  agentName: agentNameIn(basename(input.cwd ?? process.cwd())),
1018
1043
  action: permissionDeniedAction(input.tool_name),
1019
- sessionId: input.session_id
1044
+ sessionId: input.session_id,
1045
+ ...permissionModeOf(input)
1020
1046
  // Side report, not a command carrier. Without timeoutMs this takes the phone's
1021
1047
  // queued instruction and acknowledges it delivered, and this hook can print
1022
1048
  // only {retry}. 4s rather than the Notification path's 2.5s because
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  computerOsOfPlatform,
3
3
  isComputerAgent
4
- } from "./chunk-KB7YWU7A.js";
4
+ } from "./chunk-HA2SRYYP.js";
5
5
 
6
6
  // src/setup/phone-check.ts
7
7
  var planPhoneCheck = (context) => {
@@ -4,10 +4,10 @@ import {
4
4
  } from "./chunk-352FIVVH.js";
5
5
  import {
6
6
  fetchAsCredential
7
- } from "./chunk-TWOSBIAW.js";
7
+ } from "./chunk-TSR3FPGL.js";
8
8
  import {
9
9
  getBaseUrl
10
- } from "./chunk-ANL74IBU.js";
10
+ } from "./chunk-FTTSQAF4.js";
11
11
  import {
12
12
  writeJsonAtomicDurable
13
13
  } from "./chunk-TODDEIYG.js";
@@ -15,7 +15,7 @@ import {
15
15
  compressTranscriptRecord,
16
16
  redactSecretsFromContent,
17
17
  transcriptRecordPlaintext
18
- } from "./chunk-KB7YWU7A.js";
18
+ } from "./chunk-HA2SRYYP.js";
19
19
 
20
20
  // src/transcript-recipient-pin.ts
21
21
  import { createHash } from "crypto";
@@ -7,10 +7,10 @@ import {
7
7
  codexHome,
8
8
  codexHooksJsonIn,
9
9
  isPusharyCodexCommand
10
- } from "./chunk-MH4O453X.js";
10
+ } from "./chunk-B3BOAYRO.js";
11
11
  import {
12
12
  resolvePathBinary
13
- } from "./chunk-PMEDJ4WM.js";
13
+ } from "./chunk-IVOELLUK.js";
14
14
  import {
15
15
  getPackageVersion
16
16
  } from "./chunk-WIIMW5YO.js";
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  callDecisionStore,
3
3
  identifyingToolInput
4
- } from "./chunk-QBDCKECQ.js";
4
+ } from "./chunk-QP3TCKRZ.js";
5
5
  import {
6
6
  canonicalJson
7
- } from "./chunk-MH4O453X.js";
7
+ } from "./chunk-B3BOAYRO.js";
8
8
 
9
9
  // src/phone-approval.ts
10
10
  import { createHash } from "crypto";
@@ -2,7 +2,7 @@ import {
2
2
  localRepoKey,
3
3
  normalizeRepoRemote,
4
4
  parseGitBranch
5
- } from "./chunk-KB7YWU7A.js";
5
+ } from "./chunk-HA2SRYYP.js";
6
6
 
7
7
  // src/repo.ts
8
8
  import { existsSync, readFileSync, statSync } from "fs";
@@ -1,25 +1,25 @@
1
1
  import {
2
2
  openClawLauncherCandidates
3
- } from "./chunk-HXX4EFK3.js";
3
+ } from "./chunk-CCKY3JDB.js";
4
4
  import {
5
5
  openCodeConfigDirFrom
6
- } from "./chunk-BO4HRAY7.js";
6
+ } from "./chunk-GLDSXDRV.js";
7
7
  import {
8
8
  nativeClaudeInstallPath
9
9
  } from "./chunk-CYTPQDQY.js";
10
10
  import {
11
11
  grokHome
12
- } from "./chunk-4I4HAPT5.js";
12
+ } from "./chunk-MTITL2IG.js";
13
13
  import {
14
14
  claudeConfigDir,
15
15
  clineDataDirectory,
16
16
  codexHomeFrom,
17
17
  openClawEnvironmentOf,
18
18
  openClawPathsFrom
19
- } from "./chunk-MH4O453X.js";
19
+ } from "./chunk-B3BOAYRO.js";
20
20
  import {
21
21
  HOOK_COMPATIBLE_PROFILES
22
- } from "./chunk-KB7YWU7A.js";
22
+ } from "./chunk-HA2SRYYP.js";
23
23
 
24
24
  // src/vscode-config.ts
25
25
  import { homedir } from "os";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  realpath
3
- } from "./chunk-MEUAK5BK.js";
3
+ } from "./chunk-EGBI4GRS.js";
4
4
  import {
5
5
  findNativeClaudeInstall
6
6
  } from "./chunk-CYTPQDQY.js";
@@ -12,7 +12,7 @@ import {
12
12
  resolvePackageVersionFromBinary,
13
13
  resolvePathBinary,
14
14
  resolvePathBinaryAsync
15
- } from "./chunk-PMEDJ4WM.js";
15
+ } from "./chunk-IVOELLUK.js";
16
16
  import {
17
17
  CLAUDE_BRIDGE_CAPABILITY,
18
18
  CLAUDE_RESUME_CAPABILITY,
@@ -23,7 +23,7 @@ import {
23
23
  MANAGED_PROVIDERS,
24
24
  SPAWN_CAPABILITY,
25
25
  sessionProvidersAdvertisedBy
26
- } from "./chunk-KB7YWU7A.js";
26
+ } from "./chunk-HA2SRYYP.js";
27
27
 
28
28
  // src/live-capabilities.ts
29
29
  import { accessSync, constants, statSync as statSync2 } from "fs";
@@ -1,18 +1,18 @@
1
1
  import {
2
2
  CODEX_HOOK_STATUS
3
- } from "./chunk-T3LSBTWU.js";
3
+ } from "./chunk-4NHQAMSK.js";
4
4
  import {
5
5
  HERMES_ALWAYS_ALLOWED_SHELL_RULE,
6
6
  HERMES_COMMAND_ALLOWLIST_KEY,
7
7
  HERMES_GATE_TOOLS_KEY,
8
8
  HERMES_SHELL_TOOL
9
- } from "./chunk-UAYNQ2IG.js";
9
+ } from "./chunk-Q7WCDUFV.js";
10
10
  import {
11
11
  retryAgentCommand
12
- } from "./chunk-2N23JFER.js";
12
+ } from "./chunk-2L52USKM.js";
13
13
  import {
14
14
  NPX_LATEST_COMMAND
15
- } from "./chunk-P5JV6YZW.js";
15
+ } from "./chunk-AOP55JR2.js";
16
16
 
17
17
  // src/setup/codex-trust.ts
18
18
  var CODEX_TRUST_TELEMETRY = {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  isSafeReadOnlyCommand
3
- } from "./chunk-KB7YWU7A.js";
3
+ } from "./chunk-HA2SRYYP.js";
4
4
 
5
5
  // src/ledger.ts
6
6
  import { appendFileSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, statSync } from "fs";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  isFinalCommandAckRefusal
3
- } from "./chunk-KB7YWU7A.js";
3
+ } from "./chunk-HA2SRYYP.js";
4
4
 
5
5
  // src/command-ack-outcome.ts
6
6
  var SETTLED_ACK = { outcome: "settled" };
@@ -5,7 +5,7 @@ import {
5
5
  DISCONNECT_AGENT_IDS,
6
6
  SETUP_AGENT_CHOICES,
7
7
  isApprovalMode
8
- } from "./chunk-KB7YWU7A.js";
8
+ } from "./chunk-HA2SRYYP.js";
9
9
 
10
10
  // src/cli/mode-request.ts
11
11
  var parseDuration = (value) => {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  readTranscriptPreference
3
- } from "./chunk-2LTRA6NA.js";
3
+ } from "./chunk-ZYDE6QRW.js";
4
4
 
5
5
  // src/transcript-setting.ts
6
6
  var transcriptEnvironmentPreference = () => {
@@ -1,21 +1,21 @@
1
1
  import {
2
2
  UNNAMED_ACTION
3
- } from "./chunk-2SHPCEH6.js";
3
+ } from "./chunk-IKC33YKC.js";
4
4
  import {
5
5
  askUser,
6
6
  isAwayPaused,
7
7
  isLocalQuestionHandoff,
8
8
  unavailableQuestionUnlessRefused,
9
9
  waitForQuestion
10
- } from "./chunk-ICHKAH5Q.js";
10
+ } from "./chunk-CS4Z44F5.js";
11
11
  import {
12
12
  getMachineId
13
- } from "./chunk-4RSJZOKB.js";
13
+ } from "./chunk-MHYX5Q3F.js";
14
14
  import {
15
15
  hookWaitClamped,
16
16
  hookWaitDeadline,
17
17
  scopeBreachReasonOf
18
- } from "./chunk-KB7YWU7A.js";
18
+ } from "./chunk-HA2SRYYP.js";
19
19
 
20
20
  // src/pushed-question.ts
21
21
  var scopeQuestionOf = (verdict) => {
@@ -3,7 +3,7 @@ import {
3
3
  formatVersion,
4
4
  quoteIfNeeded,
5
5
  shellDoubleQuoted
6
- } from "./chunk-PMEDJ4WM.js";
6
+ } from "./chunk-IVOELLUK.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-KB7YWU7A.js";
25
+ } from "./chunk-HA2SRYYP.js";
26
26
 
27
27
  // src/setup/paths.ts
28
28
  import { createHash as createHash2 } from "crypto";
@@ -1388,6 +1388,7 @@ export {
1388
1388
  isBridgeLocator,
1389
1389
  liveBridgeProbe,
1390
1390
  POSTTOOLUSE_MIRROR_ONLY_TOOLS,
1391
+ POSTTOOLUSE_MIRRORED_TOOLS,
1391
1392
  IDLE_PROMPT_NOTIFICATION,
1392
1393
  NOTIFICATION_PUSH_TYPES,
1393
1394
  CLAUDE_HOOK_BINARY,
@@ -3,13 +3,13 @@ import {
3
3
  } from "./chunk-WHB622LP.js";
4
4
  import {
5
5
  ensureDaemonRunning
6
- } from "./chunk-5TCLBCUO.js";
6
+ } from "./chunk-K3I2NMEF.js";
7
7
  import {
8
8
  hookOwnerOf
9
- } from "./chunk-BMR66K6T.js";
9
+ } from "./chunk-TPLTB256.js";
10
10
  import {
11
11
  hookMeaning
12
- } from "./chunk-2SHPCEH6.js";
12
+ } from "./chunk-IKC33YKC.js";
13
13
  import {
14
14
  buildTranscriptRecords,
15
15
  changedRecipientsMessage,
@@ -24,7 +24,7 @@ import {
24
24
  uploadTranscriptRecords,
25
25
  verifyAnchoredRecipients,
26
26
  wrapSessionKey
27
- } from "./chunk-CHI57HS3.js";
27
+ } from "./chunk-4I2SHNEU.js";
28
28
  import {
29
29
  external_exports,
30
30
  ownedOnlyByThisUser,
@@ -33,22 +33,22 @@ import {
33
33
  import {
34
34
  transcriptEnvironmentPreference,
35
35
  transcriptsEnabled
36
- } from "./chunk-AKUYCHJU.js";
36
+ } from "./chunk-APCJZFTJ.js";
37
37
  import {
38
38
  fetchAsCredential
39
- } from "./chunk-TWOSBIAW.js";
39
+ } from "./chunk-TSR3FPGL.js";
40
40
  import {
41
41
  readTranscriptPreference
42
- } from "./chunk-2LTRA6NA.js";
42
+ } from "./chunk-ZYDE6QRW.js";
43
43
  import {
44
44
  claudeConfigDir,
45
45
  codexHome,
46
46
  pusharyDir
47
- } from "./chunk-MH4O453X.js";
47
+ } from "./chunk-B3BOAYRO.js";
48
48
  import {
49
49
  getApiKey,
50
50
  getBaseUrl
51
- } from "./chunk-ANL74IBU.js";
51
+ } from "./chunk-FTTSQAF4.js";
52
52
  import {
53
53
  writeJsonAtomic,
54
54
  writeJsonAtomicDurable
@@ -60,7 +60,7 @@ import {
60
60
  isHookSource,
61
61
  isRecord,
62
62
  redactSecretsFromContent
63
- } from "./chunk-KB7YWU7A.js";
63
+ } from "./chunk-HA2SRYYP.js";
64
64
 
65
65
  // src/transcript-registration.ts
66
66
  import { createHash as createHash4 } from "crypto";