@pushary/agent-hooks 0.8.3 → 0.9.1

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.
@@ -1,3 +1,6 @@
1
+ import { PolicyConfig, ApprovalMode, ToolPolicy } from '@pushary/contracts';
2
+ export { ApprovalMode, PolicyConfig, ToolPolicy } from '@pushary/contracts';
3
+
1
4
  interface ToolInput {
2
5
  tool_name: string;
3
6
  tool_input: Record<string, unknown>;
@@ -19,6 +22,7 @@ interface AgentEvent {
19
22
  agentName?: string;
20
23
  action?: string;
21
24
  machineId?: string;
25
+ sessionId?: string;
22
26
  error?: string;
23
27
  }
24
28
  declare const reportEvent: (event: AgentEvent) => Promise<void>;
@@ -48,6 +52,9 @@ interface AskUserParams {
48
52
  options?: string[];
49
53
  context?: string;
50
54
  agentName?: string;
55
+ sessionId?: string;
56
+ machineId?: string;
57
+ toolName?: string;
51
58
  }
52
59
  interface AskUserResponse {
53
60
  correlationId: string;
@@ -61,27 +68,16 @@ declare const askUser: (apiKey: string, params: AskUserParams) => Promise<AskUse
61
68
  declare const waitForAnswer: (apiKey: string, correlationId: string, timeoutMs?: number) => Promise<WaitForAnswerResponse>;
62
69
  declare const cancelQuestion: (apiKey: string, correlationId: string) => Promise<void>;
63
70
 
64
- type ApprovalMode = 'push_only' | 'terminal_only' | 'push_first' | 'notify_only';
65
- interface ToolPolicy {
66
- tool: string;
67
- timeoutSeconds: number;
68
- timeoutAction: 'approve' | 'deny' | 'escalate';
69
- mode: ApprovalMode;
70
- pushFirstSeconds: number;
71
- }
72
- interface PolicyConfig {
73
- policies: ToolPolicy[];
74
- defaultTimeoutSeconds: number;
75
- defaultTimeoutAction: 'approve' | 'deny' | 'escalate';
76
- defaultMode: ApprovalMode;
77
- defaultPushFirstSeconds: number;
78
- modeOverride?: ApprovalMode | null;
79
- }
80
71
  declare const getPolicy: (apiKey: string) => Promise<PolicyConfig>;
81
72
  declare const resolvePolicy: (config: PolicyConfig, toolName: string, modeOverride?: ApprovalMode | null) => ToolPolicy;
73
+ interface ModeState {
74
+ readonly mode: ApprovalMode | null;
75
+ readonly kill: boolean;
76
+ }
77
+ declare const fetchModeState: (apiKey: string, sessionId?: string) => Promise<ModeState>;
82
78
  declare const fetchModeOverride: (apiKey: string) => Promise<ApprovalMode | null>;
83
79
 
84
80
  declare const getApiKey: () => string;
85
81
  declare const getBaseUrl: () => string;
86
82
 
87
- export { type ApprovalMode, type PolicyConfig, type ToolPolicy, askUser, cancelQuestion, fetchModeOverride, getApiKey, getBaseUrl, getPolicy, handleNotification, handlePostToolUse, handlePreToolUse, handleStop, reportEvent, resolvePolicy, waitForAnswer };
83
+ export { type ModeState, askUser, cancelQuestion, fetchModeOverride, fetchModeState, getApiKey, getBaseUrl, getPolicy, handleNotification, handlePostToolUse, handlePreToolUse, handleStop, reportEvent, resolvePolicy, waitForAnswer };
package/dist/src/index.js CHANGED
@@ -1,20 +1,22 @@
1
1
  import {
2
2
  fetchModeOverride,
3
+ fetchModeState,
3
4
  getPolicy,
4
5
  handlePreToolUse,
5
6
  resolvePolicy
6
- } from "../chunk-M6S3M6E3.js";
7
+ } from "../chunk-W5KRWUNE.js";
8
+ import "../chunk-IBWCHA5M.js";
7
9
  import {
8
10
  handleNotification,
9
11
  handlePostToolUse,
10
12
  handleStop,
11
13
  reportEvent
12
- } from "../chunk-6SRXMZAN.js";
14
+ } from "../chunk-AB4KX4XT.js";
13
15
  import {
14
16
  askUser,
15
17
  cancelQuestion,
16
18
  waitForAnswer
17
- } from "../chunk-7PTU7TGE.js";
19
+ } from "../chunk-OF5WIOYS.js";
18
20
  import "../chunk-3MIR7ODJ.js";
19
21
  import {
20
22
  getApiKey,
@@ -24,6 +26,7 @@ export {
24
26
  askUser,
25
27
  cancelQuestion,
26
28
  fetchModeOverride,
29
+ fetchModeState,
27
30
  getApiKey,
28
31
  getBaseUrl,
29
32
  getPolicy,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushary/agent-hooks",
3
- "version": "0.8.3",
3
+ "version": "0.9.1",
4
4
  "description": "Permission hooks for AI coding agents: route tool approvals through Pushary push notifications",
5
5
  "author": "Pushary <business@pushary.com>",
6
6
  "homepage": "https://pushary.com",
@@ -30,15 +30,16 @@
30
30
  "data"
31
31
  ],
32
32
  "scripts": {
33
- "build": "tsup src/index.ts bin/pushary.ts bin/pushary-hook.ts bin/pushary-post-hook.ts bin/pushary-stop-hook.ts bin/pushary-codex.ts bin/pushary-setup.ts bin/pushary-clean.ts bin/pushary-doctor.ts bin/pushary-mode.ts --format esm --dts --outDir dist",
34
- "dev": "tsup src/index.ts bin/pushary.ts bin/pushary-hook.ts bin/pushary-post-hook.ts bin/pushary-stop-hook.ts bin/pushary-codex.ts bin/pushary-setup.ts bin/pushary-clean.ts bin/pushary-doctor.ts bin/pushary-mode.ts --format esm --watch",
35
- "test": "bun test src/api.test.ts && bun test src/claude-config.test.ts && bun test src/mcp-http.test.ts && bun test src/retry.test.ts && bun test src/validate.test.ts && bun test src/policy.test.ts && bun test src/events.test.ts && bun test src/hook.test.ts"
33
+ "build": "tsup",
34
+ "dev": "tsup --watch",
35
+ "test": "bun test src/api.test.ts && bun test src/claude-config.test.ts && bun test src/mcp-http.test.ts && bun test src/retry.test.ts && bun test src/validate.test.ts && bun test src/policy.test.ts && bun test src/npm.test.ts && bun test src/identity.test.ts && bun test src/pending.test.ts && bun test src/events.test.ts && bun test src/hook.test.ts"
36
36
  },
37
37
  "dependencies": {
38
38
  "@inquirer/prompts": "^8.4.2",
39
39
  "smol-toml": "^1.6.1"
40
40
  },
41
41
  "devDependencies": {
42
+ "@pushary/contracts": "workspace:*",
42
43
  "tsup": "^8.0.0",
43
44
  "typescript": "^5.0.0"
44
45
  }