@pushary/agent-hooks 1.3.0 → 1.4.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 (90) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +1 -1
  3. package/data/SKILL.md +3 -3
  4. package/data/cursor-plugin/skills/pushary/SKILL.md +2 -2
  5. package/data/vscode-plugin/skills/pushary/SKILL.md +2 -2
  6. package/dist/bin/pushary-bell-hook.js +20 -20
  7. package/dist/bin/pushary-bell.js +9 -9
  8. package/dist/bin/pushary-claude.js +20 -20
  9. package/dist/bin/pushary-clean.js +472 -94
  10. package/dist/bin/pushary-codex-bridge.js +11 -11
  11. package/dist/bin/pushary-codex-hook.js +30 -28
  12. package/dist/bin/pushary-codex.js +7 -7
  13. package/dist/bin/pushary-connect.js +9 -9
  14. package/dist/bin/pushary-cowork.js +5 -5
  15. package/dist/bin/pushary-daemon.js +26 -26
  16. package/dist/bin/pushary-disconnect.js +13 -13
  17. package/dist/bin/pushary-doctor.js +86 -24
  18. package/dist/bin/pushary-elicitation-hook.js +19 -19
  19. package/dist/bin/pushary-gemini-bridge.js +10 -10
  20. package/dist/bin/pushary-gemini-hook.js +21 -21
  21. package/dist/bin/pushary-hook.js +34 -44
  22. package/dist/bin/pushary-login.js +10 -10
  23. package/dist/bin/pushary-logout.js +7 -7
  24. package/dist/bin/pushary-mode.js +5 -5
  25. package/dist/bin/pushary-notification-hook.js +22 -22
  26. package/dist/bin/pushary-opencode-hook.js +21 -21
  27. package/dist/bin/pushary-permission-denied-hook.js +26 -26
  28. package/dist/bin/pushary-permission-hook.js +32 -31
  29. package/dist/bin/pushary-post-hook.js +22 -22
  30. package/dist/bin/pushary-prompt-hook.js +22 -22
  31. package/dist/bin/pushary-session-end-hook.js +22 -22
  32. package/dist/bin/pushary-session-start-hook.js +24 -24
  33. package/dist/bin/pushary-setup.js +39 -60
  34. package/dist/bin/pushary-stats.js +4 -4
  35. package/dist/bin/pushary-status.js +13 -13
  36. package/dist/bin/pushary-stop-hook.js +22 -22
  37. package/dist/bin/pushary-stopfailure-hook.js +22 -22
  38. package/dist/bin/pushary-suggestions.js +2 -2
  39. package/dist/bin/pushary-transcript-register.js +18 -18
  40. package/dist/bin/pushary-transcripts.js +8 -8
  41. package/dist/bin/pushary-upgrade.js +17 -17
  42. package/dist/bin/pushary-wait.js +5 -5
  43. package/dist/bin/pushary.js +1 -1
  44. package/dist/{chunk-3AIFWTVB.js → chunk-2TOTCUJC.js} +2 -2
  45. package/dist/{chunk-X3KIGNIP.js → chunk-43Z3RLS5.js} +83 -24
  46. package/dist/{chunk-YF4JDCU4.js → chunk-5F5QQMCA.js} +1 -1
  47. package/dist/{chunk-ZHL62DRA.js → chunk-5IBVIMWT.js} +3 -3
  48. package/dist/{chunk-BYGEZI7B.js → chunk-5MSBI6NP.js} +1 -1
  49. package/dist/{chunk-WPJS3OZH.js → chunk-7IEB2GV4.js} +100 -9
  50. package/dist/{chunk-2PLEJ7SY.js → chunk-7PQZYCEP.js} +1 -1
  51. package/dist/{chunk-OE6U2AXM.js → chunk-A7XIL2WD.js} +3 -3
  52. package/dist/{chunk-A2URMNFM.js → chunk-BYAXXBNO.js} +1 -1
  53. package/dist/{chunk-DON24PNT.js → chunk-D4TNSUDY.js} +1 -1
  54. package/dist/{chunk-EU6JH7KU.js → chunk-ESLLVHDY.js} +8 -8
  55. package/dist/{chunk-LZQVAEWP.js → chunk-FAH3D74E.js} +2 -1
  56. package/dist/{chunk-MU275U5A.js → chunk-GIXLZFEY.js} +2 -2
  57. package/dist/{chunk-4V24U44H.js → chunk-GLPWCQ6V.js} +2 -2
  58. package/dist/{chunk-BL4SQNO6.js → chunk-GS5EI2YL.js} +1 -1
  59. package/dist/{chunk-EKQAKSGI.js → chunk-H25UB3CG.js} +1 -1
  60. package/dist/{chunk-BNDHXPTQ.js → chunk-HGN6VZTY.js} +20 -13
  61. package/dist/{chunk-WXXDHGTZ.js → chunk-IF46POXX.js} +5 -4
  62. package/dist/{chunk-A5ZWYQFV.js → chunk-JCWCTBYH.js} +4 -4
  63. package/dist/{chunk-IAEVVUXO.js → chunk-KZIXHLPQ.js} +1 -1
  64. package/dist/{chunk-FGVNU7XD.js → chunk-NBCTKC4Z.js} +34 -3
  65. package/dist/{chunk-XBO42HKH.js → chunk-NYHNLMQO.js} +12 -3
  66. package/dist/{chunk-K4TAUYUJ.js → chunk-O5L2OJBB.js} +3 -3
  67. package/dist/{chunk-DVO4SZMJ.js → chunk-O6RN46OS.js} +3 -3
  68. package/dist/{chunk-POAFXBNH.js → chunk-P4JVVJ2D.js} +1 -1
  69. package/dist/{chunk-E7WBNGJS.js → chunk-Q4UAMWXK.js} +1 -1
  70. package/dist/{chunk-KS4P6F3R.js → chunk-RGZY77CD.js} +4 -4
  71. package/dist/{chunk-K7UIAE7I.js → chunk-RQM5SMMR.js} +2 -2
  72. package/dist/{chunk-UVXNYYHG.js → chunk-S3CLZSV3.js} +6 -6
  73. package/dist/{chunk-B3S4SF3D.js → chunk-S3EUZZJB.js} +1 -1
  74. package/dist/{chunk-XBJW4MV5.js → chunk-SGZ3IAWF.js} +1 -1
  75. package/dist/{chunk-YKLCWWEI.js → chunk-SGZJ5LYH.js} +1 -1
  76. package/dist/{chunk-4LL6LG5X.js → chunk-T7E75EKA.js} +4 -3
  77. package/dist/{chunk-GOQHN2UH.js → chunk-TWWLVOPB.js} +1 -1
  78. package/dist/{chunk-RVDHN2TJ.js → chunk-U4FB623J.js} +2 -2
  79. package/dist/{chunk-RHLUJE4H.js → chunk-UCGQEAKZ.js} +1 -1
  80. package/dist/{chunk-KPNGPRYU.js → chunk-UIN3RD2U.js} +4 -4
  81. package/dist/{chunk-XEXOHUJ6.js → chunk-UTYTPDWN.js} +4 -4
  82. package/dist/{chunk-EJZCV5G4.js → chunk-VENQSVKA.js} +1 -1
  83. package/dist/{chunk-EYMMU5HC.js → chunk-XJWMPQ6X.js} +1 -1
  84. package/dist/{chunk-JYEGOYQC.js → chunk-YYRZPEMA.js} +1 -1
  85. package/dist/{chunk-N43EQPJK.js → chunk-ZIGGEKZW.js} +41 -7
  86. package/dist/{reapply-FUCAKR6Z.js → reapply-B3S2LRMT.js} +9 -9
  87. package/dist/src/index.d.ts +20 -17
  88. package/dist/src/index.js +13 -13
  89. package/package.json +1 -1
  90. /package/dist/{chunk-KBITFQST.js → chunk-P32LPT2L.js} +0 -0
@@ -2,7 +2,7 @@ import {
2
2
  HOOK_BUDGETS,
3
3
  HOOK_LOCATOR_BINARY,
4
4
  withHookHoldBudget
5
- } from "./chunk-WPJS3OZH.js";
5
+ } from "./chunk-7IEB2GV4.js";
6
6
 
7
7
  // src/npm.ts
8
8
  import { execFileSync, execSync } from "child_process";
@@ -2,24 +2,24 @@ import {
2
2
  detectProviderLiveCapabilities,
3
3
  hasSpawnProvider,
4
4
  resolveControlPolicy
5
- } from "./chunk-4V24U44H.js";
5
+ } from "./chunk-GLPWCQ6V.js";
6
6
  import {
7
7
  daemonHasRemoteProof,
8
8
  daemonServiceManagerAvailable,
9
9
  hasDaemonServiceDefinition,
10
10
  readDaemonNeedsLogin,
11
11
  readDaemonStatus
12
- } from "./chunk-KS4P6F3R.js";
12
+ } from "./chunk-RGZY77CD.js";
13
13
  import {
14
14
  getMachineId
15
- } from "./chunk-K7UIAE7I.js";
15
+ } from "./chunk-RQM5SMMR.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-XBO42HKH.js";
22
+ } from "./chunk-NYHNLMQO.js";
23
23
  import {
24
24
  getBaseUrl
25
25
  } from "./chunk-2UMNXADU.js";
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  AGENT_CHOICES
3
- } from "./chunk-BYGEZI7B.js";
3
+ } from "./chunk-5MSBI6NP.js";
4
4
  import {
5
5
  isBridgeLocator
6
- } from "./chunk-JYEGOYQC.js";
6
+ } from "./chunk-YYRZPEMA.js";
7
7
  import {
8
8
  pusharyHookExecutable
9
- } from "./chunk-DVO4SZMJ.js";
9
+ } from "./chunk-O6RN46OS.js";
10
10
  import {
11
11
  BELL_HOOK_BINARY
12
- } from "./chunk-2PLEJ7SY.js";
12
+ } from "./chunk-7PQZYCEP.js";
13
13
 
14
14
  // src/setup/hook-ownership.ts
15
15
  var commandsIn = (value) => {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  readConfigFileKey
3
- } from "./chunk-XBO42HKH.js";
3
+ } from "./chunk-NYHNLMQO.js";
4
4
 
5
5
  // src/bell/fleet.ts
6
6
  import { closeSync, constants, futimesSync, lstatSync, mkdirSync, openSync, readdirSync, unlinkSync } from "fs";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  HOOK_HOLD_BUDGET_ENV,
3
3
  hookHoldBudgetProof
4
- } from "./chunk-WPJS3OZH.js";
4
+ } from "./chunk-7IEB2GV4.js";
5
5
 
6
6
  // src/hold-budget.ts
7
7
  var takeHookHoldBudget = (args = process.argv.slice(2), env = process.env) => {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  HOOK_LOCATOR_BINARY
3
- } from "./chunk-WPJS3OZH.js";
3
+ } from "./chunk-7IEB2GV4.js";
4
4
 
5
5
  // src/diagnostics/bridge.ts
6
6
  import { execFileSync } from "child_process";
@@ -1,6 +1,29 @@
1
1
  import {
2
2
  registerTranscript
3
- } from "./chunk-EU6JH7KU.js";
3
+ } from "./chunk-ESLLVHDY.js";
4
+ import {
5
+ degradedLine
6
+ } from "./chunk-7IEB2GV4.js";
7
+
8
+ // src/tool-hook-input.ts
9
+ var OPTIONAL_TEXT_FIELDS = ["hook_event_name", "session_id", "cwd", "transcript_path", "tool_use_id", "permission_mode"];
10
+ function isInputRecord(value) {
11
+ return value !== null && typeof value === "object" && !Array.isArray(value);
12
+ }
13
+ function isToolHookInput(value) {
14
+ if (!isInputRecord(value)) return false;
15
+ if (typeof value.tool_name !== "string" || value.tool_name.length === 0) return false;
16
+ if (!isInputRecord(value.tool_input)) return false;
17
+ for (const field of OPTIONAL_TEXT_FIELDS) {
18
+ if (value[field] !== void 0 && typeof value[field] !== "string") return false;
19
+ }
20
+ return true;
21
+ }
22
+ function parseToolHookInput(value) {
23
+ if (!isInputRecord(value)) return null;
24
+ const input = { ...value, tool_input: value.tool_input === void 0 ? {} : value.tool_input };
25
+ return isToolHookInput(input) ? input : null;
26
+ }
4
27
 
5
28
  // src/admission.ts
6
29
  import { readFileSync } from "fs";
@@ -38,9 +61,14 @@ var matches = (rule, source, event) => {
38
61
  return (ruleSource === "*" || ruleSource === source) && (ruleEvent === "*" || ruleEvent === event);
39
62
  };
40
63
  var isAdmitted = (rules, source, event) => !rules.disabled.some((rule) => matches(rule, source, event));
41
- var readHookInput = async (source, fallbackEvent = "", stdin = process.stdin) => {
64
+ var readHookInput = async (source, fallbackEvent = "", stdin = process.stdin, parseInput) => {
42
65
  if (source === null) {
43
- process.stderr.write("[pushary] unrecognised --agent, standing aside rather than acting as another agent\n");
66
+ process.stderr.write(`${degradedLine("hook", {
67
+ reason: "unknown_agent",
68
+ fallback: "stood aside, so nothing is gated or reported for this call",
69
+ event: fallbackEvent
70
+ })}
71
+ `);
44
72
  return null;
45
73
  }
46
74
  let raw = "";
@@ -53,17 +81,23 @@ var readHookInput = async (source, fallbackEvent = "", stdin = process.stdin) =>
53
81
  return null;
54
82
  }
55
83
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
56
- const event = eventNameOf(parsed) ?? fallbackEvent;
84
+ const input = parseInput ? parseInput(parsed) : parsed;
85
+ if (input === null) return null;
86
+ const event = eventNameOf(input) ?? fallbackEvent;
57
87
  if (!isAdmitted(readAdmissionRules(), source, event)) return null;
58
- if (stdin === process.stdin) registerTranscript(source, parsed);
59
- return parsed;
88
+ if (stdin === process.stdin) registerTranscript(source, input);
89
+ return input;
60
90
  };
61
91
  var eventNameOf = (input) => {
62
92
  if (!("hook_event_name" in input)) return void 0;
63
93
  const name = input.hook_event_name;
64
94
  return typeof name === "string" && name.length > 0 ? name : void 0;
65
95
  };
96
+ function readToolHookInput(source, event, stdin = process.stdin) {
97
+ return readHookInput(source, event, stdin, parseToolHookInput);
98
+ }
66
99
 
67
100
  export {
68
- readHookInput
101
+ readHookInput,
102
+ readToolHookInput
69
103
  };
@@ -8,15 +8,15 @@ import {
8
8
  reapplyGeminiSettings,
9
9
  reapplyVsCodePlugin,
10
10
  repairCodexHolds
11
- } from "./chunk-UVXNYYHG.js";
12
- import "./chunk-XBJW4MV5.js";
13
- import "./chunk-ZHL62DRA.js";
14
- import "./chunk-DVO4SZMJ.js";
15
- import "./chunk-OE6U2AXM.js";
16
- import "./chunk-IAEVVUXO.js";
17
- import "./chunk-RHLUJE4H.js";
18
- import "./chunk-4LL6LG5X.js";
19
- import "./chunk-WPJS3OZH.js";
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";
18
+ import "./chunk-T7E75EKA.js";
19
+ import "./chunk-7IEB2GV4.js";
20
20
  export {
21
21
  inspectConfiguredManagedProviders,
22
22
  reapplyAllAgents,
@@ -1,23 +1,20 @@
1
- import { ClaudePreToolUseOutput, PolicyConfig, ApprovalMode, ModeState, AutoResolveOrigin, AgentQuestion } from '@pushary/contracts';
1
+ import { CanonicalGateInputs, ReceiptMeta } from '@pushary/hook-mapping';
2
+ import { ClaudePreToolUseOutput, MachineDecisionOrigin, SettledOutcome, AgentQuestion, PolicyConfig, ApprovalMode, ModeState } from '@pushary/contracts';
2
3
  export { ApprovalMode, ModeState, PolicyConfig, ToolPolicy, resolvePolicy } from '@pushary/contracts';
3
- import { ReceiptMeta } from '@pushary/hook-mapping';
4
4
 
5
- interface ToolInput {
6
- tool_name: string;
7
- tool_input: Record<string, unknown>;
8
- session_id?: string;
9
- cwd?: string;
10
- transcript_path?: string;
11
- tool_use_id?: string;
12
- permission_mode?: string;
5
+ interface ToolHookInput {
6
+ readonly hook_event_name?: string;
7
+ readonly tool_name: string;
8
+ readonly tool_input: Record<string, unknown>;
9
+ readonly session_id?: string;
10
+ readonly cwd?: string;
11
+ readonly transcript_path?: string;
12
+ readonly tool_use_id?: string;
13
+ readonly permission_mode?: string;
13
14
  }
14
- type HookOutput = ClaudePreToolUseOutput;
15
- declare const handlePreToolUse: (input: ToolInput) => Promise<HookOutput | undefined>;
16
-
17
- declare const getPolicy: (apiKey: string, expectedVersion?: string | null, agent?: string, repoAware?: boolean, sessionId?: string) => Promise<PolicyConfig>;
18
15
 
19
- declare const fetchModeState: (apiKey: string, sessionId?: string, reuseWithinMs?: number, signal?: AbortSignal) => Promise<ModeState>;
20
- declare const fetchModeOverride: (apiKey: string) => Promise<ApprovalMode | null>;
16
+ type HookOutput = ClaudePreToolUseOutput;
17
+ declare const handlePreToolUse: (input: ToolHookInput, canonical?: CanonicalGateInputs | null) => Promise<HookOutput | undefined>;
21
18
 
22
19
  interface UsageReport {
23
20
  readonly eventId: string;
@@ -47,7 +44,8 @@ interface AgentEvent {
47
44
  error?: string;
48
45
  taskTitle?: string;
49
46
  decisionSource?: DecisionSource;
50
- decisionOrigin?: AutoResolveOrigin;
47
+ decisionOrigin?: MachineDecisionOrigin;
48
+ decisionOutcome?: SettledOutcome;
51
49
  toolName?: string;
52
50
  toolTarget?: string;
53
51
  agents?: readonly string[];
@@ -191,6 +189,11 @@ declare const cancelQuestion: (apiKey: string, correlationId: string, signal?: A
191
189
  handoffAction?: string;
192
190
  }>;
193
191
 
192
+ declare const getPolicy: (apiKey: string, expectedVersion?: string | null, agent?: string, repoAware?: boolean, sessionId?: string) => Promise<PolicyConfig>;
193
+
194
+ declare const fetchModeState: (apiKey: string, sessionId?: string, reuseWithinMs?: number, signal?: AbortSignal) => Promise<ModeState>;
195
+ declare const fetchModeOverride: (apiKey: string) => Promise<ApprovalMode | null>;
196
+
194
197
  declare const getApiKey: () => string;
195
198
  declare const getBaseUrl: () => string;
196
199
 
package/dist/src/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  handlePreToolUse
3
- } from "../chunk-X3KIGNIP.js";
4
- import "../chunk-BNDHXPTQ.js";
5
- import "../chunk-ZHL62DRA.js";
6
- import "../chunk-A5ZWYQFV.js";
7
- import "../chunk-YF4JDCU4.js";
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";
8
8
  import "../chunk-YHG74UFF.js";
9
- import "../chunk-OE6U2AXM.js";
9
+ import "../chunk-A7XIL2WD.js";
10
10
  import {
11
11
  fetchAccountPublicKey
12
12
  } from "../chunk-EQRS3SGM.js";
@@ -18,28 +18,28 @@ import {
18
18
  handlePostToolUse,
19
19
  handleStop,
20
20
  reportEvent
21
- } from "../chunk-WXXDHGTZ.js";
22
- import "../chunk-IAEVVUXO.js";
21
+ } from "../chunk-IF46POXX.js";
22
+ import "../chunk-KZIXHLPQ.js";
23
23
  import {
24
24
  askUser,
25
25
  cancelQuestion,
26
26
  waitForAnswer
27
27
  } from "../chunk-LGXUGYUH.js";
28
- import "../chunk-K7UIAE7I.js";
29
- import "../chunk-RHLUJE4H.js";
28
+ import "../chunk-RQM5SMMR.js";
29
+ import "../chunk-UCGQEAKZ.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-POAFXBNH.js";
35
- import "../chunk-4LL6LG5X.js";
34
+ import "../chunk-P4JVVJ2D.js";
35
+ import "../chunk-T7E75EKA.js";
36
36
  import {
37
37
  getApiKey,
38
38
  getBaseUrl
39
39
  } from "../chunk-2UMNXADU.js";
40
40
  import {
41
41
  resolvePolicy
42
- } from "../chunk-WPJS3OZH.js";
42
+ } from "../chunk-7IEB2GV4.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.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "Permission hooks for AI coding agents: route tool approvals through Pushary push notifications",
5
5
  "keywords": [
6
6
  "pushary",
File without changes