@pushary/agent-hooks 0.35.0 → 0.36.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.
- package/dist/bin/pushary-clean.js +1 -1
- package/dist/bin/pushary-codex-hook.js +1 -1
- package/dist/bin/pushary-codex.js +1 -1
- package/dist/bin/pushary-gemini-hook.js +1 -1
- package/dist/bin/pushary-hook.js +2 -2
- package/dist/bin/pushary-notification-hook.js +1 -1
- package/dist/bin/pushary-post-hook.js +1 -1
- package/dist/bin/pushary-prompt-hook.js +1 -1
- package/dist/bin/pushary-session-end-hook.d.ts +1 -0
- package/dist/bin/pushary-session-end-hook.js +21 -0
- package/dist/bin/pushary-session-start-hook.js +1 -1
- package/dist/bin/pushary-setup.js +2 -2
- package/dist/bin/pushary-stop-hook.js +1 -1
- package/dist/{chunk-JE3WQW63.js → chunk-JR4H3FND.js} +1 -1
- package/dist/{chunk-ZJICOAAN.js → chunk-SO6ZG5ML.js} +11 -2
- package/dist/{chunk-FIBI2QZC.js → chunk-WH5ASAZK.js} +25 -0
- package/dist/src/index.js +2 -2
- package/package.json +2 -1
package/dist/bin/pushary-hook.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
handlePreToolUse
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-JR4H3FND.js";
|
|
5
5
|
import "../chunk-KQYIHZ5E.js";
|
|
6
|
-
import "../chunk-
|
|
6
|
+
import "../chunk-WH5ASAZK.js";
|
|
7
7
|
import "../chunk-R5AJNXZS.js";
|
|
8
8
|
import "../chunk-DWED7BS3.js";
|
|
9
9
|
import "../chunk-Z5PL3K7C.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
handleSessionEnd
|
|
4
|
+
} from "../chunk-WH5ASAZK.js";
|
|
5
|
+
import "../chunk-DWED7BS3.js";
|
|
6
|
+
import "../chunk-Z5PL3K7C.js";
|
|
7
|
+
import "../chunk-NKXSILEW.js";
|
|
8
|
+
|
|
9
|
+
// bin/pushary-session-end-hook.ts
|
|
10
|
+
var main = async () => {
|
|
11
|
+
let rawInput = "";
|
|
12
|
+
for await (const chunk of process.stdin) {
|
|
13
|
+
rawInput += chunk;
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
const input = rawInput.trim() ? JSON.parse(rawInput) : {};
|
|
17
|
+
await handleSessionEnd(input);
|
|
18
|
+
} catch {
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
main();
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
addClaudeMcpServer,
|
|
4
4
|
addPusharyHooks,
|
|
5
5
|
addPusharyToolPermissions
|
|
6
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-SO6ZG5ML.js";
|
|
7
7
|
import {
|
|
8
8
|
GEMINI_HOOK_BINARY,
|
|
9
9
|
addCodexHookTrust,
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
} from "../chunk-J7JWI3KU.js";
|
|
25
25
|
import {
|
|
26
26
|
reportEvent
|
|
27
|
-
} from "../chunk-
|
|
27
|
+
} from "../chunk-WH5ASAZK.js";
|
|
28
28
|
import "../chunk-DWED7BS3.js";
|
|
29
29
|
import {
|
|
30
30
|
isValidApiKey
|
|
@@ -20,7 +20,7 @@ var isPusharyHook = (entry) => {
|
|
|
20
20
|
if (!Array.isArray(hooks)) return false;
|
|
21
21
|
return hooks.some((hook) => {
|
|
22
22
|
const command = String(asRecord(hook)?.command ?? "");
|
|
23
|
-
return command.includes("pushary-hook") || command.includes("pushary-post-hook") || command.includes("pushary-stop-hook") || command.includes("pushary-prompt-hook") || command.includes("pushary-notification-hook") || command.includes("pushary-session-start-hook");
|
|
23
|
+
return command.includes("pushary-hook") || command.includes("pushary-post-hook") || command.includes("pushary-stop-hook") || command.includes("pushary-prompt-hook") || command.includes("pushary-notification-hook") || command.includes("pushary-session-start-hook") || command.includes("pushary-session-end-hook");
|
|
24
24
|
});
|
|
25
25
|
};
|
|
26
26
|
var addClaudeMcpServer = (config, apiKey) => {
|
|
@@ -124,6 +124,15 @@ var addPusharyHooks = (settings, binDir) => {
|
|
|
124
124
|
}]
|
|
125
125
|
});
|
|
126
126
|
hooks.SessionStart = sessionStart;
|
|
127
|
+
const sessionEnd = (Array.isArray(hooks.SessionEnd) ? hooks.SessionEnd : []).filter((entry) => !isPusharyHook(entry));
|
|
128
|
+
sessionEnd.push({
|
|
129
|
+
hooks: [{
|
|
130
|
+
type: "command",
|
|
131
|
+
command: resolve("pushary-session-end-hook"),
|
|
132
|
+
timeout: 10
|
|
133
|
+
}]
|
|
134
|
+
});
|
|
135
|
+
hooks.SessionEnd = sessionEnd;
|
|
127
136
|
};
|
|
128
137
|
var removePusharySettings = (settings) => {
|
|
129
138
|
let changed = removeClaudeMcpServers(settings);
|
|
@@ -142,7 +151,7 @@ var removePusharySettings = (settings) => {
|
|
|
142
151
|
}
|
|
143
152
|
const hooks = asRecord(settings.hooks);
|
|
144
153
|
if (hooks) {
|
|
145
|
-
for (const key of ["PreToolUse", "PostToolUse", "Stop", "UserPromptSubmit", "Notification", "SessionStart"]) {
|
|
154
|
+
for (const key of ["PreToolUse", "PostToolUse", "Stop", "UserPromptSubmit", "Notification", "SessionStart", "SessionEnd"]) {
|
|
146
155
|
const entries = hooks[key];
|
|
147
156
|
if (!Array.isArray(entries)) continue;
|
|
148
157
|
const filtered = entries.filter((entry) => !isPusharyHook(entry));
|
|
@@ -952,6 +952,30 @@ var handleSessionStart = async (input, agent = CLAUDE_CODE_AGENT) => {
|
|
|
952
952
|
} catch {
|
|
953
953
|
}
|
|
954
954
|
};
|
|
955
|
+
var SESSION_END_ACTIONS = {
|
|
956
|
+
clear: "Session cleared",
|
|
957
|
+
logout: "Logged out",
|
|
958
|
+
resume: "Session suspended",
|
|
959
|
+
prompt_input_exit: "Session ended",
|
|
960
|
+
bypass_permissions_disabled: "Session ended",
|
|
961
|
+
other: "Session ended"
|
|
962
|
+
};
|
|
963
|
+
var handleSessionEnd = async (input, agent = CLAUDE_CODE_AGENT) => {
|
|
964
|
+
try {
|
|
965
|
+
const projectName = basename(input.cwd ?? process.cwd());
|
|
966
|
+
const action = typeof input.reason === "string" && SESSION_END_ACTIONS[input.reason] || "Session ended";
|
|
967
|
+
const sessionKey = input.session_id || DEFAULT_SESSION;
|
|
968
|
+
if (!isDefaultSession(sessionKey)) removePendingSession(sessionKey);
|
|
969
|
+
await reportEvent({
|
|
970
|
+
event: "session_closed",
|
|
971
|
+
agentType: agent.type,
|
|
972
|
+
agentName: `${agent.label} - ${projectName}`,
|
|
973
|
+
action,
|
|
974
|
+
sessionId: input.session_id
|
|
975
|
+
}, { maxAttempts: 1, timeoutMs: 800 });
|
|
976
|
+
} catch {
|
|
977
|
+
}
|
|
978
|
+
};
|
|
955
979
|
var NOTIFICATION_PUSH_TYPES = /* @__PURE__ */ new Set(["idle_prompt", "agent_needs_input"]);
|
|
956
980
|
var NOTIFICATION_THROTTLE_MS = 60 * 1e3;
|
|
957
981
|
var handleNotification = async (input, agent = CLAUDE_CODE_AGENT) => {
|
|
@@ -1024,5 +1048,6 @@ export {
|
|
|
1024
1048
|
handleUserPrompt,
|
|
1025
1049
|
handleStop,
|
|
1026
1050
|
handleSessionStart,
|
|
1051
|
+
handleSessionEnd,
|
|
1027
1052
|
handleNotification
|
|
1028
1053
|
};
|
package/dist/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
handlePreToolUse
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-JR4H3FND.js";
|
|
4
4
|
import "../chunk-KQYIHZ5E.js";
|
|
5
5
|
import {
|
|
6
6
|
askUser,
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
reportEvent,
|
|
15
15
|
resolvePolicy,
|
|
16
16
|
waitForAnswer
|
|
17
|
-
} from "../chunk-
|
|
17
|
+
} from "../chunk-WH5ASAZK.js";
|
|
18
18
|
import "../chunk-R5AJNXZS.js";
|
|
19
19
|
import "../chunk-DWED7BS3.js";
|
|
20
20
|
import "../chunk-Z5PL3K7C.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pushary/agent-hooks",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.36.0",
|
|
4
4
|
"description": "Permission hooks for AI coding agents: route tool approvals through Pushary push notifications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pushary",
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
"pushary-prompt-hook": "./dist/bin/pushary-prompt-hook.js",
|
|
50
50
|
"pushary-notification-hook": "./dist/bin/pushary-notification-hook.js",
|
|
51
51
|
"pushary-session-start-hook": "./dist/bin/pushary-session-start-hook.js",
|
|
52
|
+
"pushary-session-end-hook": "./dist/bin/pushary-session-end-hook.js",
|
|
52
53
|
"pushary-claude": "./dist/bin/pushary-claude.js",
|
|
53
54
|
"pushary-codex": "./dist/bin/pushary-codex.js",
|
|
54
55
|
"pushary-codex-hook": "./dist/bin/pushary-codex-hook.js",
|