@pushary/agent-hooks 1.7.2 → 1.8.0

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 (105) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +13 -1
  3. package/data/cursor-plugin/CHANGELOG.md +1 -0
  4. package/data/cursor-plugin/scripts/pushary-gate.mjs +2 -21
  5. package/data/cursor-plugin/scripts/pushary-gate.test.mjs +23 -1
  6. package/data/cursor-plugin/scripts/redaction.mjs +51 -0
  7. package/data/vscode-plugin/CHANGELOG.md +1 -0
  8. package/data/vscode-plugin/scripts/pushary-gate.mjs +1 -21
  9. package/data/vscode-plugin/scripts/redaction.mjs +51 -0
  10. package/dist/bin/pushary-bell-hook.js +23 -23
  11. package/dist/bin/pushary-bell.js +9 -9
  12. package/dist/bin/pushary-claude.js +28 -28
  13. package/dist/bin/pushary-clean.js +91 -107
  14. package/dist/bin/pushary-codex-bridge.js +18 -18
  15. package/dist/bin/pushary-codex-hook.js +42 -43
  16. package/dist/bin/pushary-codex.js +13 -13
  17. package/dist/bin/pushary-connect.js +13 -13
  18. package/dist/bin/pushary-cowork.js +5 -5
  19. package/dist/bin/pushary-daemon.js +27 -27
  20. package/dist/bin/pushary-disconnect.js +18 -18
  21. package/dist/bin/pushary-doctor.js +85 -79
  22. package/dist/bin/pushary-elicitation-hook.js +25 -25
  23. package/dist/bin/pushary-gemini-bridge.js +12 -12
  24. package/dist/bin/pushary-gemini-hook.js +29 -30
  25. package/dist/bin/pushary-hook.js +32 -32
  26. package/dist/bin/pushary-login.js +12 -12
  27. package/dist/bin/pushary-logout.js +7 -7
  28. package/dist/bin/pushary-mcp.js +85 -28
  29. package/dist/bin/pushary-mode.js +9 -9
  30. package/dist/bin/pushary-notification-hook.js +28 -28
  31. package/dist/bin/pushary-opencode-hook.js +28 -29
  32. package/dist/bin/pushary-permission-denied-hook.js +32 -32
  33. package/dist/bin/pushary-permission-hook.js +31 -31
  34. package/dist/bin/pushary-post-hook.js +28 -28
  35. package/dist/bin/pushary-prompt-hook.js +28 -28
  36. package/dist/bin/pushary-session-end-hook.js +28 -28
  37. package/dist/bin/pushary-session-start-hook.js +32 -32
  38. package/dist/bin/pushary-setup.js +60 -127
  39. package/dist/bin/pushary-stats.js +5 -5
  40. package/dist/bin/pushary-status.js +15 -15
  41. package/dist/bin/pushary-stop-hook.js +28 -28
  42. package/dist/bin/pushary-stopfailure-hook.js +28 -28
  43. package/dist/bin/pushary-suggestions.js +4 -4
  44. package/dist/bin/pushary-transcript-register.js +19 -19
  45. package/dist/bin/pushary-transcripts.js +7 -7
  46. package/dist/bin/pushary-upgrade.js +231 -105
  47. package/dist/bin/pushary-wait.js +9 -9
  48. package/dist/bin/pushary.js +6 -6
  49. package/dist/{chunk-VQDJ6KB3.js → chunk-2ABTSGFT.js} +3 -3
  50. package/dist/{chunk-UFNBKYWT.js → chunk-2OY3ZZ5N.js} +3 -3
  51. package/dist/{chunk-A6WQF7FQ.js → chunk-3EVPNIBE.js} +3 -3
  52. package/dist/{chunk-L6IF4JOF.js → chunk-6J2JC2RT.js} +3 -3
  53. package/dist/{chunk-3NSRL5E7.js → chunk-7Z7Q4GGS.js} +2 -2
  54. package/dist/{chunk-NYBZJ44G.js → chunk-A2A2YTMG.js} +108 -25
  55. package/dist/{chunk-SKEW3TQX.js → chunk-AHV4LNB5.js} +1 -1
  56. package/dist/{chunk-KAJT6HPI.js → chunk-AXPCESYO.js} +3 -3
  57. package/dist/{chunk-JMSB6CJT.js → chunk-C2WCPBF7.js} +1 -1
  58. package/dist/chunk-CJVVKOSR.js +73 -0
  59. package/dist/{chunk-2B4XCMH6.js → chunk-CULUZTWQ.js} +283 -41
  60. package/dist/{chunk-6QZK4O36.js → chunk-CVQYGMSR.js} +4 -4
  61. package/dist/{chunk-SEIZQZEE.js → chunk-D2FX3EPW.js} +1 -1
  62. package/dist/{chunk-LI3C2IQY.js → chunk-DB3ONZB4.js} +2 -2
  63. package/dist/{chunk-YU54LNC6.js → chunk-DE4Y6TCC.js} +6 -6
  64. package/dist/{chunk-65RN6ZCO.js → chunk-E4FJTUH4.js} +1 -1
  65. package/dist/{chunk-RLRDPZG4.js → chunk-EPCXUP3P.js} +3 -1
  66. package/dist/{chunk-OXEF6JHD.js → chunk-EX3GAPA4.js} +1 -1
  67. package/dist/{chunk-E3PLF7YB.js → chunk-EYK3GSRH.js} +4 -4
  68. package/dist/{chunk-SJN64NJX.js → chunk-GPEGOGRJ.js} +1 -1
  69. package/dist/chunk-GU3EJCVV.js +43 -0
  70. package/dist/{chunk-YNJ2H2FD.js → chunk-HQ6G3B5R.js} +2 -2
  71. package/dist/{chunk-6NHXKTQU.js → chunk-HZVVNGEW.js} +2 -2
  72. package/dist/{chunk-ZUKZJQGR.js → chunk-IPVKH2ST.js} +1 -1
  73. package/dist/{chunk-T3PRPFDY.js → chunk-J5TIV3J6.js} +5 -5
  74. package/dist/{chunk-F6BMJOSW.js → chunk-JU6W3XAU.js} +1 -1
  75. package/dist/{chunk-AWZNDM3B.js → chunk-JYG4B33G.js} +1 -1
  76. package/dist/{chunk-ZMWX5SDA.js → chunk-JZTHGAPA.js} +8 -8
  77. package/dist/{chunk-3RO2UWJQ.js → chunk-KGDWDSNL.js} +2 -2
  78. package/dist/{chunk-MY3UZO5U.js → chunk-KVQBWI5T.js} +3 -3
  79. package/dist/{chunk-HOIGXMI7.js → chunk-LXQ5FBBD.js} +1 -1
  80. package/dist/{chunk-D4OGEWLH.js → chunk-M5ICYGHT.js} +3 -3
  81. package/dist/{chunk-YLCSKVQQ.js → chunk-M5JDZ45W.js} +4 -4
  82. package/dist/{chunk-SKMWPXGV.js → chunk-MDEPU45E.js} +183 -28
  83. package/dist/{chunk-R7ZETVNR.js → chunk-MPWXGONV.js} +3 -3
  84. package/dist/{chunk-2XOHXZRC.js → chunk-NGDD6TXY.js} +20 -5
  85. package/dist/{chunk-WWTLAZQA.js → chunk-NQTHFF4W.js} +178 -39
  86. package/dist/{chunk-KLXYMPTM.js → chunk-OKXS7WDZ.js} +1 -1
  87. package/dist/{chunk-Q7CDBJXU.js → chunk-OLQRRFBX.js} +1 -1
  88. package/dist/{chunk-VSGKQ3HI.js → chunk-P7WQEVWA.js} +2 -2
  89. package/dist/{chunk-UUTWHVSV.js → chunk-Q7E4I6UA.js} +28 -16
  90. package/dist/{chunk-WXIVUIXA.js → chunk-R7437YI3.js} +2 -2
  91. package/dist/{chunk-5GIBNUBD.js → chunk-RHR6NARM.js} +2 -2
  92. package/dist/{chunk-QSZ37ROP.js → chunk-SAXBC4AZ.js} +1 -1
  93. package/dist/{chunk-U3MS6D5X.js → chunk-SIFVFP6T.js} +1 -1
  94. package/dist/{chunk-TVJYGZXB.js → chunk-SLFABHW3.js} +40 -10
  95. package/dist/{chunk-M2JGLFFS.js → chunk-TY4JT7W3.js} +1 -1
  96. package/dist/{chunk-YU4222G2.js → chunk-UI36QSBI.js} +28 -16
  97. package/dist/{chunk-OJRB5QKN.js → chunk-VQKRG3AC.js} +6 -6
  98. package/dist/{chunk-4S7CCOXB.js → chunk-WE2J62NC.js} +31 -17
  99. package/dist/{chunk-PWNQGITG.js → chunk-ZSZSSJCV.js} +1 -1
  100. package/dist/{chunk-I7B2DNVU.js → chunk-ZVSKMPBZ.js} +1 -1
  101. package/dist/{reapply-D6RSDYCK.js → reapply-CW3MA66V.js} +9 -9
  102. package/dist/src/index.js +20 -20
  103. package/package.json +1 -1
  104. package/dist/chunk-INR3RVQ3.js +0 -92
  105. package/dist/chunk-IZVAVXHQ.js +0 -255
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  SETUP_FLAGS
3
- } from "./chunk-I7B2DNVU.js";
3
+ } from "./chunk-ZVSKMPBZ.js";
4
4
  import {
5
5
  parseFlags
6
6
  } from "./chunk-GMXKITVA.js";
@@ -14,7 +14,7 @@ import {
14
14
  CLAUDE_CONNECTOR_URL,
15
15
  COWORK_CONNECTOR_LIMIT,
16
16
  COWORK_STANDING_INSTRUCTIONS
17
- } from "./chunk-WWTLAZQA.js";
17
+ } from "./chunk-NQTHFF4W.js";
18
18
 
19
19
  // src/cli/cowork.ts
20
20
  import { readFileSync } from "fs";
@@ -1,16 +1,25 @@
1
1
  import {
2
+ CLI_PACKAGE_NAMES,
2
3
  HOOK_BUDGETS,
3
4
  HOOK_LOCATOR_BINARY,
5
+ OWNERSHIP_PROBE_COMMAND,
6
+ classifyGlobalFolder,
7
+ classifyGlobalInstall,
8
+ cmdShimTarget,
9
+ decideCommandOwner,
10
+ globalInstallTarget,
11
+ globalPackageFolder,
12
+ globalRootFor,
4
13
  isReleaseVersion,
14
+ ownPackageName,
5
15
  withHookHoldBudget
6
- } from "./chunk-WWTLAZQA.js";
16
+ } from "./chunk-NQTHFF4W.js";
7
17
 
8
18
  // src/npm.ts
9
19
  import { execFileSync, execSync } from "child_process";
10
- import { existsSync, readFileSync, realpathSync } from "fs";
20
+ import { existsSync, readFileSync, readlinkSync, realpathSync } from "fs";
11
21
  import { dirname, isAbsolute, join, relative, resolve } from "path";
12
- var AGENT_HOOKS_PACKAGE = "@pushary/agent-hooks";
13
- var LATEST_RELEASE_URL = `https://registry.npmjs.org/${AGENT_HOOKS_PACKAGE}/latest`;
22
+ var latestReleaseUrl = (packageName) => `https://registry.npmjs.org/${packageName}/latest`;
14
23
  var REGISTRY_TIMEOUT_MS = 5e3;
15
24
  var LATEST_TAG = "latest";
16
25
  var cleanNpmEnv = () => {
@@ -36,15 +45,21 @@ var execNpm = (args, options = {}) => {
36
45
  env: { ...cleanNpmEnv(), ...options.env ?? {} }
37
46
  });
38
47
  };
39
- var resolveGlobalBinary = (name) => {
48
+ var GLOBAL_PREFIX_TIMEOUT_MS = 5e3;
49
+ var readGlobalPrefix = () => {
40
50
  try {
41
- const prefix = execNpm("prefix -g --no-workspaces", { timeout: 5e3 }).toString().trim();
42
- const candidates = process.platform === "win32" ? [join(prefix, `${name}.cmd`), join(prefix, name)] : [join(prefix, "bin", name)];
43
- return candidates.find(existsSync);
51
+ const prefix = execNpm("prefix -g --no-workspaces", { timeout: GLOBAL_PREFIX_TIMEOUT_MS }).toString().trim();
52
+ return prefix === "" ? void 0 : prefix;
44
53
  } catch {
45
54
  return void 0;
46
55
  }
47
56
  };
57
+ var resolveGlobalBinary = (name) => {
58
+ const prefix = readGlobalPrefix();
59
+ if (prefix === void 0) return void 0;
60
+ const candidates = process.platform === "win32" ? [join(prefix, `${name}.cmd`), join(prefix, name)] : [join(prefix, "bin", name)];
61
+ return candidates.find(existsSync);
62
+ };
48
63
  var resolvePathBinary = (name, platform = process.platform) => {
49
64
  try {
50
65
  return execFileSync(platform === "win32" ? "where" : "which", [name], {
@@ -155,29 +170,79 @@ var AGENT_HOOKS_RUNTIME_FILES = [
155
170
  "data/cursor-plugin/hooks/hooks.json",
156
171
  "data/cursor-plugin/mcp.json",
157
172
  "data/cursor-plugin/scripts/pushary-gate.mjs",
173
+ "data/cursor-plugin/scripts/redaction.mjs",
158
174
  "data/vscode-plugin/.claude-plugin/plugin.json",
159
175
  "data/vscode-plugin/hooks/hooks.json",
160
176
  "data/vscode-plugin/.mcp.json",
161
- "data/vscode-plugin/scripts/pushary-gate.mjs"
177
+ "data/vscode-plugin/scripts/pushary-gate.mjs",
178
+ "data/vscode-plugin/scripts/redaction.mjs"
162
179
  ];
163
- var globalPackageBinsPresent = (name) => {
180
+ var globalPackageBinsPresent = (name, prefix, platform) => packageBinsPresent(globalPackageFolder(globalRootFor(prefix, platform), name, platform), prefix, platform, AGENT_HOOKS_RUNTIME_FILES);
181
+ var errorCode = (error) => typeof error === "object" && error !== null && "code" in error ? error.code : void 0;
182
+ var realpathOrUndefined = (path) => {
164
183
  try {
165
- const root = execNpm("root -g --no-workspaces", { timeout: 5e3 }).toString().trim();
166
- const prefix = execNpm("prefix -g --no-workspaces", { timeout: 5e3 }).toString().trim();
167
- return packageBinsPresent(join(root, ...name.split("/")), prefix, process.platform, AGENT_HOOKS_RUNTIME_FILES);
184
+ return realpathSync(path);
168
185
  } catch {
169
- return false;
186
+ return void 0;
187
+ }
188
+ };
189
+ var definedPaths = (paths) => paths.filter((path) => path !== void 0);
190
+ var readPosixCommandLink = (prefix) => {
191
+ const command = join(prefix, "bin", OWNERSHIP_PROBE_COMMAND);
192
+ try {
193
+ const target = resolve(dirname(command), readlinkSync(command));
194
+ return { kind: "resolved", targets: definedPaths([target, realpathOrUndefined(command)]) };
195
+ } catch (error) {
196
+ if (errorCode(error) === "ENOENT") return { kind: "absent" };
197
+ const real = realpathOrUndefined(command);
198
+ return real === void 0 ? { kind: "unreadable" } : { kind: "resolved", targets: [real] };
199
+ }
200
+ };
201
+ var readWindowsCommandLink = (prefix) => {
202
+ const shim = join(prefix, `${OWNERSHIP_PROBE_COMMAND}.cmd`);
203
+ try {
204
+ const target = cmdShimTarget(prefix, readFileSync(shim, "utf8"));
205
+ return target === void 0 ? { kind: "unreadable" } : { kind: "resolved", targets: [target] };
206
+ } catch (error) {
207
+ return errorCode(error) === "ENOENT" ? { kind: "absent" } : { kind: "unreadable" };
170
208
  }
171
209
  };
210
+ var readCommandLink = (prefix, platform) => platform === "win32" ? readWindowsCommandLink(prefix) : readPosixCommandLink(prefix);
211
+ var readFolderManifest = (folder) => {
212
+ try {
213
+ return { kind: "read", manifest: JSON.parse(readFileSync(join(folder, "package.json"), "utf8")) };
214
+ } catch {
215
+ return { kind: "unreadable" };
216
+ }
217
+ };
218
+ var readGlobalFolder = (root, name, platform = process.platform) => classifyGlobalFolder(name, readFolderManifest(globalPackageFolder(root, name, platform)));
219
+ var installedIfOurs = (folder) => folder.kind === "ours" ? [folder.installed] : [];
220
+ var readInstalledCliPackages = (root, platform = process.platform) => CLI_PACKAGE_NAMES.flatMap((name) => installedIfOurs(readGlobalFolder(root, name, platform)));
221
+ var globalRootsFor = (prefix, platform) => {
222
+ const root = globalRootFor(prefix, platform);
223
+ return definedPaths([root, realpathOrUndefined(root)]);
224
+ };
225
+ var readCommandOwner = (prefix, platform = process.platform) => decideCommandOwner({
226
+ platform,
227
+ globalRoots: globalRootsFor(prefix, platform),
228
+ link: readCommandLink(prefix, platform),
229
+ installed: readInstalledCliPackages(globalRootFor(prefix, platform), platform).map((installed) => installed.name)
230
+ });
231
+ var NPM_UNAVAILABLE_OWNER = { kind: "unknown", reason: "npm_unavailable" };
232
+ var readGlobalCliInstallAt = (prefix, platform = process.platform) => classifyGlobalInstall(readInstalledCliPackages(globalRootFor(prefix, platform), platform), readCommandOwner(prefix, platform));
233
+ var readGlobalCliInstall = (platform = process.platform) => {
234
+ const prefix = readGlobalPrefix();
235
+ return prefix === void 0 ? { kind: "unavailable" } : readGlobalCliInstallAt(prefix, platform);
236
+ };
172
237
  var resolveGlobalBinDir = (probe) => {
173
238
  if (process.platform === "win32") return void 0;
174
239
  const resolved = resolveGlobalBinary(probe);
175
240
  return resolved ? resolved.slice(0, resolved.length - probe.length - 1) : void 0;
176
241
  };
177
242
  var quoteIfNeeded = (path) => /\s/.test(path) ? `"${path}"` : path;
178
- var fetchLatestPublishedVersion = async (request = {}) => {
243
+ var fetchLatestPublishedVersion = async (request) => {
179
244
  try {
180
- const response = await (request.fetchImpl ?? fetch)(LATEST_RELEASE_URL, {
245
+ const response = await (request.fetchImpl ?? fetch)(latestReleaseUrl(request.packageName), {
181
246
  signal: AbortSignal.timeout(request.timeoutMs ?? REGISTRY_TIMEOUT_MS)
182
247
  });
183
248
  if (!response.ok) return void 0;
@@ -190,29 +255,42 @@ var fetchLatestPublishedVersion = async (request = {}) => {
190
255
  };
191
256
  var POSIX_SHELL_WORD = /^[\w@%+=:,./-]+$/;
192
257
  var quoteForPosixShell = (value) => POSIX_SHELL_WORD.test(value) ? value : `'${value.replaceAll("'", `'\\''`)}'`;
193
- var installAgentHooksGlobally = (request, runNpm = execNpm) => {
258
+ var installPackageGlobally = (request, runNpm = execNpm) => {
194
259
  const prefixFlag = request.prefix === void 0 ? "" : ` --prefix ${quoteForPosixShell(request.prefix)}`;
195
- const spec = quoteForPosixShell(`${AGENT_HOOKS_PACKAGE}@${request.version}`);
260
+ const spec = quoteForPosixShell(`${request.packageName}@${request.version}`);
196
261
  runNpm(`install -g --no-workspaces${prefixFlag} ${spec}`, { timeout: request.timeoutMs });
197
262
  };
198
263
  var needsGlobalInstall = (requested, installed, binaryPresent) => requested !== installed || !binaryPresent;
264
+ var planGlobalInstall = (platform) => {
265
+ const prefix = readGlobalPrefix();
266
+ const owner = prefix === void 0 ? NPM_UNAVAILABLE_OWNER : readCommandOwner(prefix, platform);
267
+ return { prefix, packageName: globalInstallTarget(owner, ownPackageName()) };
268
+ };
269
+ var plannedGlobalPackage = () => planGlobalInstall(process.platform).packageName;
270
+ var installedVersionOf = (prefix, name, platform) => {
271
+ const folder = readGlobalFolder(globalRootFor(prefix, platform), name, platform);
272
+ return folder.kind === "ours" ? folder.installed.version : void 0;
273
+ };
274
+ var asCachedResult = (result) => result === "installed" ? "cached" : result;
199
275
  var installState;
200
276
  var installGlobally = (options) => {
201
277
  if (installState) {
202
- return installState.then((result) => result === "installed" ? "cached" : result);
278
+ return installState.then(asCachedResult);
203
279
  }
204
280
  const started = (async () => {
205
281
  if (!npmIsOnPath()) throw new NpmMissingError();
282
+ const platform = process.platform;
283
+ const { prefix, packageName } = planGlobalInstall(platform);
206
284
  const pinned = process.env.PUSHARY_PIN_GLOBAL_VERSION !== "0";
207
- if (pinned && !needsGlobalInstall(
285
+ if (pinned && prefix !== void 0 && !needsGlobalInstall(
208
286
  options.version,
209
- resolveGlobalPackageVersion(AGENT_HOOKS_PACKAGE),
210
- globalPackageBinsPresent(AGENT_HOOKS_PACKAGE)
287
+ installedVersionOf(prefix, packageName, platform),
288
+ globalPackageBinsPresent(packageName, prefix, platform)
211
289
  )) {
212
290
  return "skipped";
213
291
  }
214
292
  const version = pinned && options.version && options.version !== "0.0.0" ? options.version : LATEST_TAG;
215
- installAgentHooksGlobally({ version, timeoutMs: options.timeoutMs ?? 12e4 });
293
+ installPackageGlobally({ packageName, version, timeoutMs: options.timeoutMs ?? 12e4 });
216
294
  return "installed";
217
295
  })();
218
296
  installState = started;
@@ -670,10 +748,11 @@ export {
670
748
  registeredCommands,
671
749
  namesOurBinary,
672
750
  registrationHolderOf,
673
- AGENT_HOOKS_PACKAGE,
674
751
  LATEST_TAG,
752
+ cleanNpmEnv,
675
753
  npmErrorMessage,
676
754
  execNpm,
755
+ readGlobalPrefix,
677
756
  resolveGlobalBinary,
678
757
  resolvePathBinary,
679
758
  npmIsOnPath,
@@ -682,9 +761,13 @@ export {
682
761
  resolveBinary,
683
762
  resolvePackageVersionFromBinary,
684
763
  resolveGlobalPackageVersion,
764
+ readGlobalFolder,
765
+ readGlobalCliInstallAt,
766
+ readGlobalCliInstall,
685
767
  resolveGlobalBinDir,
686
768
  fetchLatestPublishedVersion,
687
- installAgentHooksGlobally,
769
+ installPackageGlobally,
770
+ plannedGlobalPackage,
688
771
  installGlobally,
689
772
  holdBudgetOf,
690
773
  guardBinary,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  HOOK_BUDGETS,
3
3
  OPENCODE_APPROVAL_EVENT
4
- } from "./chunk-WWTLAZQA.js";
4
+ } from "./chunk-NQTHFF4W.js";
5
5
 
6
6
  // src/opencode-plugin.ts
7
7
  var OPENCODE_PLUGIN_MARKER = "pushary-opencode-plugin w1";
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  CLAUDE_HOOK_EVENTS,
3
3
  supportedClaudeEvents
4
- } from "./chunk-A6WQF7FQ.js";
4
+ } from "./chunk-3EVPNIBE.js";
5
5
  import {
6
6
  guardBinary,
7
7
  holdBudgetOf,
8
8
  isProtectedByScope,
9
9
  registerHookEntry
10
- } from "./chunk-NYBZJ44G.js";
10
+ } from "./chunk-A2A2YTMG.js";
11
11
  import {
12
12
  HOOK_LOCATOR_BINARY,
13
13
  withHookHoldBudget
14
- } from "./chunk-WWTLAZQA.js";
14
+ } from "./chunk-NQTHFF4W.js";
15
15
 
16
16
  // src/claude-config.ts
17
17
  import { join } from "path";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  HOOK_LOCATOR_BINARY
3
- } from "./chunk-WWTLAZQA.js";
3
+ } from "./chunk-NQTHFF4W.js";
4
4
 
5
5
  // src/diagnostics/bridge.ts
6
6
  import { execFileSync } from "child_process";
@@ -0,0 +1,73 @@
1
+ import {
2
+ AUTO_DECISION_WINDOW_MS,
3
+ claimThrottle,
4
+ deriveToolTarget,
5
+ permissionDeniedAction,
6
+ releaseThrottle,
7
+ reportEvent
8
+ } from "./chunk-CULUZTWQ.js";
9
+ import {
10
+ DEFAULT_SESSION
11
+ } from "./chunk-N6IOSZOE.js";
12
+ import {
13
+ machineDecisionFor,
14
+ shouldDeferToNativeMode,
15
+ wireVerdictFor
16
+ } from "./chunk-NQTHFF4W.js";
17
+
18
+ // src/machine-decision-audit.ts
19
+ import { basename } from "path";
20
+ var reportMachineDenial = async (input, verdict, agent) => {
21
+ const decision = machineDecisionFor(wireVerdictFor(verdict, 0));
22
+ if (!decision) return;
23
+ const sessionKey = input.session_id || DEFAULT_SESSION;
24
+ const toolTarget = deriveToolTarget(input.tool_name, input.tool_input);
25
+ const throttleKey = `machinedecision:${agent.type}:${sessionKey}:${input.tool_name}:${decision.origin}:${toolTarget ?? ""}`;
26
+ const throttle = claimThrottle(throttleKey, AUTO_DECISION_WINDOW_MS);
27
+ if (throttle === "throttled") return;
28
+ if (throttle === "unavailable") {
29
+ console.error("[Pushary] Could not access the audit throttle; reporting this denial without deduplication.");
30
+ }
31
+ try {
32
+ const response = await reportEvent({
33
+ event: "permission_denied",
34
+ occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
35
+ toolUseId: input.tool_use_id,
36
+ agentType: agent.type,
37
+ agentName: `${agent.label} - ${basename(input.cwd ?? process.cwd())}`,
38
+ action: permissionDeniedAction(input.tool_name),
39
+ sessionId: input.session_id,
40
+ decisionSource: "policy_auto",
41
+ decisionOrigin: decision.origin,
42
+ decisionOutcome: decision.outcome,
43
+ toolName: input.tool_name,
44
+ toolTarget
45
+ }, { maxAttempts: 1, timeoutMs: 800, requireOk: true, skipDrain: true });
46
+ if (response?.ok !== true) throw new Error("Audit delivery was not acknowledged");
47
+ } catch {
48
+ console.error("[Pushary] Could not record the machine denial. The action remains blocked; its audit delivery will be retried on the next matching denial.");
49
+ if (throttle === "passed") {
50
+ try {
51
+ releaseThrottle(throttleKey);
52
+ } catch {
53
+ console.error("[Pushary] Could not reset the failed audit throttle.");
54
+ }
55
+ }
56
+ }
57
+ };
58
+
59
+ // src/native-defer.ts
60
+ var nativeDeferOptions = () => {
61
+ const respect = process.env.PUSHARY_RESPECT_PERMISSION_MODE;
62
+ const bypass = process.env.PUSHARY_DEFER_BYPASS;
63
+ return {
64
+ respectPermissionMode: !(respect === "0" || respect === "false"),
65
+ deferBypass: bypass === "1" || bypass === "true"
66
+ };
67
+ };
68
+ var defersToNativeMode = (permissionMode, toolName) => shouldDeferToNativeMode(permissionMode, toolName, nativeDeferOptions());
69
+
70
+ export {
71
+ reportMachineDenial,
72
+ defersToNativeMode
73
+ };