@pushary/agent-hooks 1.4.0 → 1.4.2

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 (78) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/bin/pushary-bell-hook.js +18 -18
  3. package/dist/bin/pushary-bell.js +6 -6
  4. package/dist/bin/pushary-claude.js +18 -18
  5. package/dist/bin/pushary-clean.js +159 -138
  6. package/dist/bin/pushary-codex-bridge.js +10 -10
  7. package/dist/bin/pushary-codex-hook.js +31 -26
  8. package/dist/bin/pushary-codex.js +6 -6
  9. package/dist/bin/pushary-connect.js +6 -6
  10. package/dist/bin/pushary-cowork.js +3 -3
  11. package/dist/bin/pushary-daemon.js +22 -22
  12. package/dist/bin/pushary-disconnect.js +10 -10
  13. package/dist/bin/pushary-doctor.js +20 -20
  14. package/dist/bin/pushary-elicitation-hook.js +17 -17
  15. package/dist/bin/pushary-gemini-bridge.js +9 -9
  16. package/dist/bin/pushary-gemini-hook.js +19 -19
  17. package/dist/bin/pushary-hook.js +23 -23
  18. package/dist/bin/pushary-login.js +7 -7
  19. package/dist/bin/pushary-logout.js +4 -4
  20. package/dist/bin/pushary-mode.js +3 -3
  21. package/dist/bin/pushary-notification-hook.js +20 -20
  22. package/dist/bin/pushary-opencode-hook.js +19 -19
  23. package/dist/bin/pushary-permission-denied-hook.js +24 -24
  24. package/dist/bin/pushary-permission-hook.js +23 -23
  25. package/dist/bin/pushary-post-hook.js +20 -20
  26. package/dist/bin/pushary-prompt-hook.js +20 -20
  27. package/dist/bin/pushary-session-end-hook.js +20 -20
  28. package/dist/bin/pushary-session-start-hook.js +22 -22
  29. package/dist/bin/pushary-setup.js +53 -32
  30. package/dist/bin/pushary-stats.js +2 -2
  31. package/dist/bin/pushary-status.js +10 -10
  32. package/dist/bin/pushary-stop-hook.js +20 -20
  33. package/dist/bin/pushary-stopfailure-hook.js +20 -20
  34. package/dist/bin/pushary-transcript-register.js +16 -16
  35. package/dist/bin/pushary-transcripts.js +4 -4
  36. package/dist/bin/pushary-upgrade.js +14 -14
  37. package/dist/bin/pushary-wait.js +3 -3
  38. package/dist/{chunk-VENQSVKA.js → chunk-25RTLTQD.js} +1 -1
  39. package/dist/{chunk-H25UB3CG.js → chunk-2V2IKOGJ.js} +1 -1
  40. package/dist/{chunk-BYAXXBNO.js → chunk-4BROEAKH.js} +1 -1
  41. package/dist/{chunk-UTYTPDWN.js → chunk-4ZDKSDVW.js} +4 -4
  42. package/dist/{chunk-2TOTCUJC.js → chunk-55KW4FLG.js} +2 -2
  43. package/dist/{chunk-S3CLZSV3.js → chunk-ACYIZ3KH.js} +5 -5
  44. package/dist/{chunk-RGZY77CD.js → chunk-BZ4GDOJX.js} +3 -3
  45. package/dist/{chunk-5MSBI6NP.js → chunk-DY4ILT6L.js} +1 -1
  46. package/dist/{chunk-Q4UAMWXK.js → chunk-F4UWL4NY.js} +1 -1
  47. package/dist/{chunk-NYHNLMQO.js → chunk-FU2DFEAZ.js} +1 -1
  48. package/dist/{chunk-IF46POXX.js → chunk-G653QPTR.js} +17 -13
  49. package/dist/{chunk-S3EUZZJB.js → chunk-GZ7E6VOB.js} +1 -1
  50. package/dist/{chunk-5IBVIMWT.js → chunk-II7PUMPB.js} +3 -3
  51. package/dist/{chunk-ZIGGEKZW.js → chunk-JVTOML54.js} +2 -2
  52. package/dist/{chunk-5F5QQMCA.js → chunk-LEAAERSQ.js} +1 -1
  53. package/dist/{chunk-A7XIL2WD.js → chunk-LPYCPFBZ.js} +3 -3
  54. package/dist/{chunk-XJWMPQ6X.js → chunk-M5CTUFF3.js} +1 -1
  55. package/dist/{chunk-O5L2OJBB.js → chunk-MUVTZNJW.js} +3 -3
  56. package/dist/{chunk-7PQZYCEP.js → chunk-MW6ZPC6R.js} +1 -1
  57. package/dist/{chunk-RQM5SMMR.js → chunk-NHTAHAIS.js} +1 -1
  58. package/dist/{chunk-GS5EI2YL.js → chunk-NOWZUGZW.js} +1 -1
  59. package/dist/{chunk-D4TNSUDY.js → chunk-NY6XQ6CA.js} +1 -1
  60. package/dist/{chunk-SGZ3IAWF.js → chunk-PC6DU5C4.js} +1 -1
  61. package/dist/{chunk-7IEB2GV4.js → chunk-SOUZBGYJ.js} +5 -0
  62. package/dist/{chunk-JCWCTBYH.js → chunk-SUWRZYQG.js} +56 -5
  63. package/dist/{chunk-U4FB623J.js → chunk-T5SZ4PML.js} +24 -10
  64. package/dist/{chunk-UCGQEAKZ.js → chunk-TRLFZKVG.js} +1 -1
  65. package/dist/{chunk-GLPWCQ6V.js → chunk-TYEO6T5J.js} +2 -2
  66. package/dist/{chunk-ESLLVHDY.js → chunk-UJBZIKSY.js} +6 -6
  67. package/dist/{chunk-P4JVVJ2D.js → chunk-UM5J3J4V.js} +1 -1
  68. package/dist/{chunk-HGN6VZTY.js → chunk-VIOL2DJS.js} +5 -5
  69. package/dist/{chunk-GIXLZFEY.js → chunk-VOMOZ4D5.js} +1 -1
  70. package/dist/{chunk-UIN3RD2U.js → chunk-VW66JEGU.js} +4 -4
  71. package/dist/{chunk-O6RN46OS.js → chunk-WPVHRUDT.js} +3 -3
  72. package/dist/{chunk-43Z3RLS5.js → chunk-XDP3UYH5.js} +16 -43
  73. package/dist/{chunk-NBCTKC4Z.js → chunk-Y3MM6PYN.js} +4 -4
  74. package/dist/{chunk-KZIXHLPQ.js → chunk-YXP3WPAI.js} +1 -1
  75. package/dist/{chunk-YYRZPEMA.js → chunk-ZVY25BMK.js} +1 -1
  76. package/dist/{reapply-B3S2LRMT.js → reapply-J527BCJG.js} +8 -8
  77. package/dist/src/index.js +12 -12
  78. package/package.json +1 -1
@@ -1,17 +1,67 @@
1
1
  import {
2
- canonicalGateInputs
3
- } from "./chunk-IF46POXX.js";
2
+ AUTO_DECISION_WINDOW_MS,
3
+ DEFAULT_SESSION,
4
+ canonicalGateInputs,
5
+ claimThrottle,
6
+ deriveToolTarget,
7
+ permissionDeniedAction,
8
+ releaseThrottle,
9
+ reportEvent
10
+ } from "./chunk-G653QPTR.js";
4
11
  import {
5
12
  canonicalJson
6
- } from "./chunk-UCGQEAKZ.js";
13
+ } from "./chunk-TRLFZKVG.js";
7
14
  import {
8
15
  writeFileAtomic
9
16
  } from "./chunk-T7E75EKA.js";
10
17
  import {
11
18
  BLOCKED_ACTION_GRANT_TTL_SECONDS,
12
19
  blockedActionIdentity,
13
- shouldDeferToNativeMode
14
- } from "./chunk-7IEB2GV4.js";
20
+ machineDecisionFor,
21
+ shouldDeferToNativeMode,
22
+ wireVerdictFor
23
+ } from "./chunk-SOUZBGYJ.js";
24
+
25
+ // src/machine-decision-audit.ts
26
+ import { basename } from "path";
27
+ var reportMachineDenial = async (input, verdict, agent) => {
28
+ const decision = machineDecisionFor(wireVerdictFor(verdict, 0));
29
+ if (!decision) return;
30
+ const sessionKey = input.session_id || DEFAULT_SESSION;
31
+ const toolTarget = deriveToolTarget(input.tool_name, input.tool_input);
32
+ const throttleKey = `machinedecision:${agent.type}:${sessionKey}:${input.tool_name}:${decision.origin}:${toolTarget ?? ""}`;
33
+ const throttle = claimThrottle(throttleKey, AUTO_DECISION_WINDOW_MS);
34
+ if (throttle === "throttled") return;
35
+ if (throttle === "unavailable") {
36
+ console.error("[Pushary] Could not access the audit throttle; reporting this denial without deduplication.");
37
+ }
38
+ try {
39
+ const response = await reportEvent({
40
+ event: "permission_denied",
41
+ occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
42
+ toolUseId: input.tool_use_id,
43
+ agentType: agent.type,
44
+ agentName: `${agent.label} - ${basename(input.cwd ?? process.cwd())}`,
45
+ action: permissionDeniedAction(input.tool_name),
46
+ sessionId: input.session_id,
47
+ decisionSource: "policy_auto",
48
+ decisionOrigin: decision.origin,
49
+ decisionOutcome: decision.outcome,
50
+ toolName: input.tool_name,
51
+ toolTarget
52
+ }, { maxAttempts: 1, timeoutMs: 800, requireOk: true, skipDrain: true });
53
+ if (response?.ok !== true) throw new Error("Audit delivery was not acknowledged");
54
+ } catch {
55
+ console.error("[Pushary] Could not record the machine denial. The action remains blocked; its audit delivery will be retried on the next matching denial.");
56
+ if (throttle === "passed") {
57
+ try {
58
+ releaseThrottle(throttleKey);
59
+ } catch {
60
+ console.error("[Pushary] Could not reset the failed audit throttle.");
61
+ }
62
+ }
63
+ }
64
+ };
15
65
 
16
66
  // src/native-defer.ts
17
67
  var nativeDeferOptions = () => {
@@ -190,6 +240,7 @@ var forgetBlockedActionHint = (fingerprint) => {
190
240
  };
191
241
 
192
242
  export {
243
+ reportMachineDenial,
193
244
  defersToNativeMode,
194
245
  userScope,
195
246
  codexCallKey,
@@ -15,10 +15,11 @@ import {
15
15
  } from "./chunk-EYRGBYZG.js";
16
16
  import {
17
17
  reportedInstallSource
18
- } from "./chunk-P4JVVJ2D.js";
18
+ } from "./chunk-UM5J3J4V.js";
19
19
  import {
20
+ PAIR_TTL_SECONDS,
20
21
  isAnswerSource
21
- } from "./chunk-7IEB2GV4.js";
22
+ } from "./chunk-SOUZBGYJ.js";
22
23
 
23
24
  // src/reach.ts
24
25
  var reachVerdict = (channels) => {
@@ -747,8 +748,13 @@ var printConnectInstructions = async (apiKey) => {
747
748
  return phoneFailure("no_device");
748
749
  };
749
750
  var PAIR_POLL_INTERVAL_MS = 2e3;
750
- var PAIR_TIMEOUT_MS = 9e5;
751
+ var PAIR_STOP_BEFORE_EXPIRY_MS = 1e4;
752
+ var PAIR_TIMEOUT_MS = PAIR_TTL_SECONDS * 1e3 - PAIR_STOP_BEFORE_EXPIRY_MS;
751
753
  var PAIR_HINT_AFTER_MS = 45e3;
754
+ var PAIR_BROWSER_FALLBACK_AFTER_MS = 6e4;
755
+ var BROWSER_CONNECT_COMMAND = "npx @pushary/agent-hooks setup --connect browser";
756
+ var PAIR_BROWSER_FALLBACK_LINE = `Still waiting? Sign in with a browser instead: Ctrl-C, then ${BROWSER_CONNECT_COMMAND}`;
757
+ var SYSTEM_PAIR_CLOCK = { now: () => Date.now(), sleep };
752
758
  var startPairing = async (cliPublicKey) => {
753
759
  try {
754
760
  const res = await fetch(`${apiBase()}/api/mobile/pair/start`, {
@@ -837,7 +843,9 @@ var buildPairLinks = (pairId, publicKeyB64, baseUrl = apiBase(), code = null) =>
837
843
  };
838
844
  };
839
845
  var connectViaAppPairing = async (options = {}) => {
846
+ const clock = options.clock ?? SYSTEM_PAIR_CLOCK;
840
847
  const keypair = generateKeypair();
848
+ const requestedAt = clock.now();
841
849
  const started = await startPairing(keypair.publicKeyB64);
842
850
  if (!started) {
843
851
  console.log(` ${yellow("!")} Couldn't start pairing. Check your connection and try again.`);
@@ -854,12 +862,13 @@ var connectViaAppPairing = async (options = {}) => {
854
862
  console.log(` ${dim("Confirm the app shows fingerprint")} ${cyan(publicKeyFingerprint(keypair.publicKeyB64))}`);
855
863
  console.log(` ${dim("Already have the app and it opened a browser? Use")} ${cyan(deepLink)}`);
856
864
  console.log();
857
- const startedAt = Date.now();
858
- const deadline = startedAt + PAIR_TIMEOUT_MS;
865
+ const startedAt = clock.now();
866
+ const deadline = requestedAt + PAIR_TIMEOUT_MS;
859
867
  let hintShown = false;
868
+ let browserFallbackShown = false;
860
869
  const stop = startSpinner(() => {
861
- const left = Math.max(0, Math.ceil((deadline - Date.now()) / 6e4));
862
- if (Date.now() - startedAt < PAIR_HINT_AFTER_MS) {
870
+ const left = Math.max(0, Math.ceil((deadline - clock.now()) / 6e4));
871
+ if (clock.now() - startedAt < PAIR_HINT_AFTER_MS) {
863
872
  return "Waiting for the app to authorize";
864
873
  }
865
874
  if (!hintShown) {
@@ -880,8 +889,12 @@ var connectViaAppPairing = async (options = {}) => {
880
889
  process.once("SIGINT", onInterrupt);
881
890
  let consecutiveFailures = 0;
882
891
  try {
883
- while (Date.now() < deadline) {
892
+ while (clock.now() < deadline) {
884
893
  if (cancelled) return pairFailed("cancelled");
894
+ if (!browserFallbackShown && clock.now() - startedAt >= PAIR_BROWSER_FALLBACK_AFTER_MS) {
895
+ browserFallbackShown = true;
896
+ writeStatusLine(dim(PAIR_BROWSER_FALLBACK_LINE));
897
+ }
885
898
  const claim = await claimPairing(pairId);
886
899
  if (claim === null) {
887
900
  consecutiveFailures += 1;
@@ -890,7 +903,7 @@ var connectViaAppPairing = async (options = {}) => {
890
903
  await cancelPairing(pairId);
891
904
  return pairFailed("unreachable");
892
905
  }
893
- await sleep(PAIR_POLL_INTERVAL_MS);
906
+ await clock.sleep(PAIR_POLL_INTERVAL_MS);
894
907
  continue;
895
908
  }
896
909
  consecutiveFailures = 0;
@@ -915,7 +928,7 @@ var connectViaAppPairing = async (options = {}) => {
915
928
  stop(yellow("!"), describePairFailure(claim.reason));
916
929
  return pairFailed("rejected");
917
930
  }
918
- await sleep(PAIR_POLL_INTERVAL_MS);
931
+ await clock.sleep(PAIR_POLL_INTERVAL_MS);
919
932
  }
920
933
  stop(yellow("!"), "Timed out waiting for the app");
921
934
  await cancelPairing(pairId);
@@ -940,6 +953,7 @@ export {
940
953
  confirmAppConnection,
941
954
  connectExistingApp,
942
955
  printConnectInstructions,
956
+ BROWSER_CONNECT_COMMAND,
943
957
  pairingEscapeApplies,
944
958
  connectViaAppPairing
945
959
  };
@@ -2,7 +2,7 @@ import {
2
2
  HOOK_BUDGETS,
3
3
  HOOK_LOCATOR_BINARY,
4
4
  withHookHoldBudget
5
- } from "./chunk-7IEB2GV4.js";
5
+ } from "./chunk-SOUZBGYJ.js";
6
6
 
7
7
  // src/npm.ts
8
8
  import { execFileSync, execSync } from "child_process";
@@ -2,10 +2,10 @@ import {
2
2
  resolveBinary,
3
3
  resolveGlobalPackageVersion,
4
4
  resolvePackageVersionFromBinary
5
- } from "./chunk-UCGQEAKZ.js";
5
+ } from "./chunk-TRLFZKVG.js";
6
6
  import {
7
7
  MANAGED_PROVIDERS
8
- } from "./chunk-7IEB2GV4.js";
8
+ } from "./chunk-SOUZBGYJ.js";
9
9
 
10
10
  // src/live-capabilities.ts
11
11
  var CLAUDE_BRIDGE_CAPABILITY = "claude-bridge";
@@ -6,16 +6,16 @@ import {
6
6
  } from "./chunk-SGZJ5LYH.js";
7
7
  import {
8
8
  hookOwnerOf
9
- } from "./chunk-UTYTPDWN.js";
9
+ } from "./chunk-4ZDKSDVW.js";
10
10
  import {
11
11
  ensureDaemonRunning
12
- } from "./chunk-RGZY77CD.js";
12
+ } from "./chunk-BZ4GDOJX.js";
13
13
  import {
14
14
  buildTranscriptRecords,
15
15
  decodePublicKey,
16
16
  generateSessionKey,
17
17
  wrapSessionKey
18
- } from "./chunk-S3EUZZJB.js";
18
+ } from "./chunk-GZ7E6VOB.js";
19
19
  import {
20
20
  fetchTranscriptRecipients,
21
21
  uploadTranscriptRecords
@@ -23,14 +23,14 @@ import {
23
23
  import {
24
24
  transcriptEnvironmentPreference,
25
25
  transcriptsEnabled
26
- } from "./chunk-BYAXXBNO.js";
26
+ } from "./chunk-4BROEAKH.js";
27
27
  import {
28
28
  codexHome,
29
29
  pusharyDir
30
- } from "./chunk-UCGQEAKZ.js";
30
+ } from "./chunk-TRLFZKVG.js";
31
31
  import {
32
32
  readTranscriptPreference
33
- } from "./chunk-NYHNLMQO.js";
33
+ } from "./chunk-FU2DFEAZ.js";
34
34
  import {
35
35
  writeJsonAtomic
36
36
  } from "./chunk-T7E75EKA.js";
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-2UMNXADU.js";
4
4
  import {
5
5
  normalizeInstallSource
6
- } from "./chunk-7IEB2GV4.js";
6
+ } from "./chunk-SOUZBGYJ.js";
7
7
 
8
8
  // src/install-source.ts
9
9
  import { readFileSync } from "fs";
@@ -3,28 +3,28 @@ import {
3
3
  addPusharyToolPermissions,
4
4
  isPusharyHook,
5
5
  removeClaudeMcpServers
6
- } from "./chunk-5IBVIMWT.js";
6
+ } from "./chunk-II7PUMPB.js";
7
7
  import {
8
8
  CLAUDE_HOOK_EVENTS,
9
9
  addGeminiMcpServer,
10
10
  removeGeminiMcpServer
11
- } from "./chunk-A7XIL2WD.js";
11
+ } from "./chunk-LPYCPFBZ.js";
12
12
  import {
13
13
  CLAUDE_CODE_AGENT,
14
14
  parseApplyPatchFiles
15
- } from "./chunk-IF46POXX.js";
15
+ } from "./chunk-G653QPTR.js";
16
16
  import {
17
17
  guardBinary,
18
18
  holdBudgetOf,
19
19
  registerHookEntry
20
- } from "./chunk-UCGQEAKZ.js";
20
+ } from "./chunk-TRLFZKVG.js";
21
21
  import {
22
22
  PHONE_ANSWERED_TOOLS,
23
23
  hookCompatibleProfile,
24
24
  hookCompatibleProfileBySource,
25
25
  toToolLookup,
26
26
  withHookHoldBudget
27
- } from "./chunk-7IEB2GV4.js";
27
+ } from "./chunk-SOUZBGYJ.js";
28
28
 
29
29
  // src/compatible-config.ts
30
30
  import { homedir } from "os";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  pusharyDir
3
- } from "./chunk-UCGQEAKZ.js";
3
+ } from "./chunk-TRLFZKVG.js";
4
4
  import {
5
5
  readJsonSafe
6
6
  } from "./chunk-T7E75EKA.js";
@@ -2,24 +2,24 @@ import {
2
2
  detectProviderLiveCapabilities,
3
3
  hasSpawnProvider,
4
4
  resolveControlPolicy
5
- } from "./chunk-GLPWCQ6V.js";
5
+ } from "./chunk-TYEO6T5J.js";
6
6
  import {
7
7
  daemonHasRemoteProof,
8
8
  daemonServiceManagerAvailable,
9
9
  hasDaemonServiceDefinition,
10
10
  readDaemonNeedsLogin,
11
11
  readDaemonStatus
12
- } from "./chunk-RGZY77CD.js";
12
+ } from "./chunk-BZ4GDOJX.js";
13
13
  import {
14
14
  getMachineId
15
- } from "./chunk-RQM5SMMR.js";
15
+ } from "./chunk-NHTAHAIS.js";
16
16
  import {
17
17
  getPackageVersion
18
18
  } from "./chunk-DINDL2CF.js";
19
19
  import {
20
20
  readControlMode,
21
21
  readKeySource
22
- } from "./chunk-NYHNLMQO.js";
22
+ } from "./chunk-FU2DFEAZ.js";
23
23
  import {
24
24
  getBaseUrl
25
25
  } from "./chunk-2UMNXADU.js";
@@ -2,17 +2,17 @@ import {
2
2
  CLAUDE_HOOK_EVENTS,
3
3
  GEMINI_HOOK_EVENTS,
4
4
  hasGeminiHooks
5
- } from "./chunk-A7XIL2WD.js";
5
+ } from "./chunk-LPYCPFBZ.js";
6
6
  import {
7
7
  CODEX_HOOK_EVENTS,
8
8
  hasCodexHooks,
9
9
  holdBudgetOf
10
- } from "./chunk-UCGQEAKZ.js";
10
+ } from "./chunk-TRLFZKVG.js";
11
11
  import {
12
12
  CURSOR_GATE_EVENTS,
13
13
  HOOK_LOCATOR_BINARY,
14
14
  hookCommandHoldBudget
15
- } from "./chunk-7IEB2GV4.js";
15
+ } from "./chunk-SOUZBGYJ.js";
16
16
 
17
17
  // src/diagnostics/wiring.ts
18
18
  var record = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : null;
@@ -1,26 +1,27 @@
1
1
  import {
2
2
  activeHookSource,
3
3
  activeIdentity
4
- } from "./chunk-HGN6VZTY.js";
4
+ } from "./chunk-VIOL2DJS.js";
5
5
  import {
6
6
  blockedActionFingerprint,
7
7
  defersToNativeMode,
8
8
  forgetBlockedActionHint,
9
9
  hasBlockedActionHint,
10
- recordBlockedActionHint
11
- } from "./chunk-JCWCTBYH.js";
10
+ recordBlockedActionHint,
11
+ reportMachineDenial
12
+ } from "./chunk-SUWRZYQG.js";
12
13
  import {
13
14
  isGatingMoment,
14
15
  recordKeylessMoment
15
- } from "./chunk-5F5QQMCA.js";
16
+ } from "./chunk-LEAAERSQ.js";
16
17
  import {
17
18
  denyReasonFrom,
18
19
  isDeferAnswer
19
20
  } from "./chunk-YHG74UFF.js";
20
21
  import {
21
- AUTO_DECISION_WINDOW_MS,
22
22
  DEFAULT_SESSION,
23
23
  UNNAMED_ACTION,
24
+ claimThrottle,
24
25
  deriveAction,
25
26
  deriveActionBody,
26
27
  deriveBlocker,
@@ -34,9 +35,8 @@ import {
34
35
  repoKeyFor,
35
36
  reportEvent,
36
37
  scopePathFor,
37
- settleQuestionsForToolUse,
38
- throttlePass
39
- } from "./chunk-IF46POXX.js";
38
+ settleQuestionsForToolUse
39
+ } from "./chunk-G653QPTR.js";
40
40
  import {
41
41
  DECISION_STOP_REASON,
42
42
  askUser,
@@ -51,7 +51,7 @@ import {
51
51
  } from "./chunk-LGXUGYUH.js";
52
52
  import {
53
53
  getMachineId
54
- } from "./chunk-RQM5SMMR.js";
54
+ } from "./chunk-NHTAHAIS.js";
55
55
  import {
56
56
  getApiKey,
57
57
  getBaseUrl
@@ -75,13 +75,11 @@ import {
75
75
  isBlockedActionRequest,
76
76
  isPermissionRequestOwnedByPreToolUse,
77
77
  isPusharyOwnTool,
78
- machineDecisionFor,
79
78
  parseAgentQuestionAnswers,
80
79
  parseAgentQuestions,
81
80
  resolveGate,
82
- stoppedOutput,
83
- wireVerdictFor
84
- } from "./chunk-7IEB2GV4.js";
81
+ stoppedOutput
82
+ } from "./chunk-SOUZBGYJ.js";
85
83
 
86
84
  // src/decision-episode.ts
87
85
  var EPISODE_PATH = "/api/agent/decision-episode";
@@ -118,31 +116,6 @@ var deny = (reason) => claudePreToolUseOutput("deny", reason);
118
116
  var allowWithInput = (updatedInput) => claudePreToolUseOutput("allow", void 0, updatedInput);
119
117
  var ask = (reason) => claudePreToolUseOutput("ask", reason);
120
118
  var halted = (reason) => stoppedOutput(deny(reason), reason);
121
- var reportMachineDecision = async (input, verdict) => {
122
- const decision = machineDecisionFor(wireVerdictFor(verdict, 0));
123
- if (!decision) return;
124
- const sessionKey = input.session_id || DEFAULT_SESSION;
125
- const toolTarget = deriveToolTarget(input.tool_name, input.tool_input);
126
- const throttleKey = `machinedecision:${sessionKey}:${input.tool_name}:${decision.origin}:${toolTarget ?? ""}`;
127
- if (!throttlePass(throttleKey, AUTO_DECISION_WINDOW_MS)) return;
128
- await reportEvent(
129
- {
130
- event: "permission_denied",
131
- occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
132
- toolUseId: input.tool_use_id,
133
- agentType: ACTIVE_AGENT.type,
134
- agentName: agentNameIn(basename(input.cwd ?? process.cwd())),
135
- action: permissionDeniedAction(input.tool_name),
136
- sessionId: input.session_id,
137
- decisionSource: "policy_auto",
138
- decisionOrigin: decision.origin,
139
- decisionOutcome: decision.outcome,
140
- toolName: input.tool_name,
141
- toolTarget
142
- },
143
- { maxAttempts: 1, timeoutMs: 800 }
144
- ).catch(() => void 0);
145
- };
146
119
  var storedWaitDeadline = (result, requestedDeadline) => {
147
120
  const stored = result.waitEndsAt ? Date.parse(result.waitEndsAt) : Number.NaN;
148
121
  return Number.isFinite(stored) ? Math.min(stored, requestedDeadline) : requestedDeadline;
@@ -556,11 +529,11 @@ var handlePreToolUse = async (input, canonical) => {
556
529
  const gateInput = claudeGateInput(modeState, policy, input, canonical);
557
530
  const verdict = resolveGate(gateInput);
558
531
  if (verdict.kind === "kill") {
559
- await reportMachineDecision(input, verdict);
532
+ await reportMachineDenial(input, verdict, ACTIVE_AGENT);
560
533
  return halted(verdict.reason);
561
534
  }
562
535
  if (verdict.kind === "deny") {
563
- await reportMachineDecision(input, verdict);
536
+ await reportMachineDenial(input, verdict, ACTIVE_AGENT);
564
537
  return deny(verdict.reason);
565
538
  }
566
539
  if (canonical === null) return deny(unreadableReason);
@@ -618,11 +591,11 @@ var handlePermissionRequest = async (input, canonical) => {
618
591
  const policy = await getPolicy(apiKey, modeState.policyVersion, ACTIVE_AGENT.type, true, input.session_id);
619
592
  const verdict = resolveGate(claudeGateInput(modeState, policy, input, canonical));
620
593
  if (verdict.kind === "kill") {
621
- await reportMachineDecision(input, verdict);
594
+ await reportMachineDenial(input, verdict, ACTIVE_AGENT);
622
595
  return permReqHalted(verdict.reason);
623
596
  }
624
597
  if (verdict.kind === "deny") {
625
- await reportMachineDecision(input, verdict);
598
+ await reportMachineDenial(input, verdict, ACTIVE_AGENT);
626
599
  return permReqDeny(verdict.reason);
627
600
  }
628
601
  if (canonical === null) return permReqDeny(unreadableReason);
@@ -662,7 +635,7 @@ var PERMISSION_DENIED_NOTICE_WINDOW_MS = 5 * 60 * 1e3;
662
635
  var blockedActionHoldEndsAt = (holdBudgetSeconds) => START_MS + hookHoldWindowMs("claude", holdBudgetSeconds);
663
636
  var notifyPermissionDenied = async (apiKey, input) => {
664
637
  const sessionKey = input.session_id || DEFAULT_SESSION;
665
- if (!throttlePass(`permdenied:${sessionKey}:${input.tool_name}`, PERMISSION_DENIED_NOTICE_WINDOW_MS)) return;
638
+ if (claimThrottle(`permdenied:${sessionKey}:${input.tool_name}`, PERMISSION_DENIED_NOTICE_WINDOW_MS) !== "passed") return;
666
639
  const mode = await fetchModeState(apiKey, input.session_id).catch(() => null);
667
640
  if (mode?.kill || mode?.mode === "terminal_only") return;
668
641
  const projectName = basename(input.cwd ?? process.cwd());
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  resolvePathBinary
3
- } from "./chunk-UCGQEAKZ.js";
3
+ } from "./chunk-TRLFZKVG.js";
4
4
 
5
5
  // src/hermes-config.ts
6
6
  import { execFileSync } from "child_process";
@@ -261,7 +261,7 @@ var installAgentSkill = async (request, effects) => {
261
261
  };
262
262
 
263
263
  // src/cli/dry-run.ts
264
- import { execSync as execSync2 } from "child_process";
264
+ import { execFileSync as execFileSync2 } from "child_process";
265
265
  import { rmSync as rmSync2, writeFileSync as writeFileSync2 } from "fs";
266
266
  var createGuards = (isDryRun, note) => ({
267
267
  write: (path, contents) => {
@@ -272,9 +272,9 @@ var createGuards = (isDryRun, note) => ({
272
272
  if (isDryRun()) return note("remove ", path);
273
273
  rmSync2(path, { recursive: true, force: options.force ?? false });
274
274
  },
275
- exec: (command, options, describe) => {
275
+ execFile: (file, args, options, describe) => {
276
276
  if (isDryRun()) return note("run ", describe);
277
- execSync2(command, options);
277
+ execFileSync2(file, args, options);
278
278
  }
279
279
  });
280
280
  var describeService = (effects) => {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  PRETOOLUSE_GATED_TOOLS
3
- } from "./chunk-7IEB2GV4.js";
3
+ } from "./chunk-SOUZBGYJ.js";
4
4
 
5
5
  // src/claude-tools.ts
6
6
  var POSTTOOLUSE_MIRROR_ONLY_TOOLS = ["TodoWrite", "Task", "WebFetch", "WebSearch"];
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  HOOK_LOCATOR_BINARY
3
- } from "./chunk-7IEB2GV4.js";
3
+ } from "./chunk-SOUZBGYJ.js";
4
4
 
5
5
  // src/diagnostics/bridge.ts
6
6
  import { execFileSync } from "child_process";
@@ -8,15 +8,15 @@ import {
8
8
  reapplyGeminiSettings,
9
9
  reapplyVsCodePlugin,
10
10
  repairCodexHolds
11
- } from "./chunk-S3CLZSV3.js";
12
- import "./chunk-SGZ3IAWF.js";
13
- import "./chunk-5IBVIMWT.js";
14
- import "./chunk-O6RN46OS.js";
15
- import "./chunk-A7XIL2WD.js";
16
- import "./chunk-KZIXHLPQ.js";
17
- import "./chunk-UCGQEAKZ.js";
11
+ } from "./chunk-ACYIZ3KH.js";
12
+ import "./chunk-PC6DU5C4.js";
13
+ import "./chunk-II7PUMPB.js";
14
+ import "./chunk-WPVHRUDT.js";
15
+ import "./chunk-LPYCPFBZ.js";
16
+ import "./chunk-YXP3WPAI.js";
17
+ import "./chunk-TRLFZKVG.js";
18
18
  import "./chunk-T7E75EKA.js";
19
- import "./chunk-7IEB2GV4.js";
19
+ import "./chunk-SOUZBGYJ.js";
20
20
  export {
21
21
  inspectConfiguredManagedProviders,
22
22
  reapplyAllAgents,
package/dist/src/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  handlePreToolUse
3
- } from "../chunk-43Z3RLS5.js";
4
- import "../chunk-HGN6VZTY.js";
5
- import "../chunk-5IBVIMWT.js";
6
- import "../chunk-JCWCTBYH.js";
7
- import "../chunk-5F5QQMCA.js";
3
+ } from "../chunk-XDP3UYH5.js";
4
+ import "../chunk-VIOL2DJS.js";
5
+ import "../chunk-II7PUMPB.js";
6
+ import "../chunk-SUWRZYQG.js";
7
+ import "../chunk-LEAAERSQ.js";
8
8
  import "../chunk-YHG74UFF.js";
9
- import "../chunk-A7XIL2WD.js";
9
+ import "../chunk-LPYCPFBZ.js";
10
10
  import {
11
11
  fetchAccountPublicKey
12
12
  } from "../chunk-EQRS3SGM.js";
@@ -18,20 +18,20 @@ import {
18
18
  handlePostToolUse,
19
19
  handleStop,
20
20
  reportEvent
21
- } from "../chunk-IF46POXX.js";
22
- import "../chunk-KZIXHLPQ.js";
21
+ } from "../chunk-G653QPTR.js";
22
+ import "../chunk-YXP3WPAI.js";
23
23
  import {
24
24
  askUser,
25
25
  cancelQuestion,
26
26
  waitForAnswer
27
27
  } from "../chunk-LGXUGYUH.js";
28
- import "../chunk-RQM5SMMR.js";
29
- import "../chunk-UCGQEAKZ.js";
28
+ import "../chunk-NHTAHAIS.js";
29
+ import "../chunk-TRLFZKVG.js";
30
30
  import "../chunk-EYRGBYZG.js";
31
31
  import "../chunk-SAF6HGAA.js";
32
32
  import "../chunk-7QLSKOSU.js";
33
33
  import "../chunk-KZERVKTD.js";
34
- import "../chunk-P4JVVJ2D.js";
34
+ import "../chunk-UM5J3J4V.js";
35
35
  import "../chunk-T7E75EKA.js";
36
36
  import {
37
37
  getApiKey,
@@ -39,7 +39,7 @@ import {
39
39
  } from "../chunk-2UMNXADU.js";
40
40
  import {
41
41
  resolvePolicy
42
- } from "../chunk-7IEB2GV4.js";
42
+ } from "../chunk-SOUZBGYJ.js";
43
43
  export {
44
44
  askUser,
45
45
  cancelQuestion,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushary/agent-hooks",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
4
4
  "description": "Permission hooks for AI coding agents: route tool approvals through Pushary push notifications",
5
5
  "keywords": [
6
6
  "pushary",