@pushary/agent-hooks 0.14.1 → 0.14.3
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-codex-hook.js +2 -2
- package/dist/bin/pushary-codex.js +2 -2
- package/dist/bin/pushary-hook.js +2 -2
- package/dist/bin/pushary-post-hook.js +2 -2
- package/dist/bin/pushary-prompt-hook.js +2 -2
- package/dist/bin/pushary-setup.js +20 -3
- package/dist/bin/pushary-stop-hook.js +2 -2
- package/dist/chunk-5QHQVXWN.js +174 -0
- package/dist/chunk-QEPRH7JB.js +315 -0
- package/dist/chunk-YCL4GUFR.js +222 -0
- package/dist/src/index.js +3 -3
- package/package.json +2 -2
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
reportEvent,
|
|
13
13
|
toCodexWire,
|
|
14
14
|
toPolicyLookup
|
|
15
|
-
} from "../chunk-
|
|
15
|
+
} from "../chunk-YCL4GUFR.js";
|
|
16
16
|
import {
|
|
17
17
|
DEFAULT_SESSION,
|
|
18
18
|
askUser,
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
savePendingQuestion,
|
|
26
26
|
sendNotification,
|
|
27
27
|
waitForAnswer
|
|
28
|
-
} from "../chunk-
|
|
28
|
+
} from "../chunk-QEPRH7JB.js";
|
|
29
29
|
import "../chunk-22CV7V7A.js";
|
|
30
30
|
import "../chunk-3MIR7ODJ.js";
|
|
31
31
|
import {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
reportEvent
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-YCL4GUFR.js";
|
|
5
5
|
import {
|
|
6
6
|
askUser,
|
|
7
7
|
getMachineId,
|
|
8
8
|
waitForAnswer
|
|
9
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-QEPRH7JB.js";
|
|
10
10
|
import "../chunk-22CV7V7A.js";
|
|
11
11
|
import "../chunk-3MIR7ODJ.js";
|
|
12
12
|
import {
|
package/dist/bin/pushary-hook.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
handlePreToolUse
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-5QHQVXWN.js";
|
|
5
|
+
import "../chunk-QEPRH7JB.js";
|
|
6
6
|
import "../chunk-22CV7V7A.js";
|
|
7
7
|
import "../chunk-3MIR7ODJ.js";
|
|
8
8
|
import "../chunk-VUNL35KE.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
handlePostToolUse
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-YCL4GUFR.js";
|
|
5
|
+
import "../chunk-QEPRH7JB.js";
|
|
6
6
|
import "../chunk-22CV7V7A.js";
|
|
7
7
|
import "../chunk-3MIR7ODJ.js";
|
|
8
8
|
import "../chunk-VUNL35KE.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
handleUserPrompt
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-YCL4GUFR.js";
|
|
5
|
+
import "../chunk-QEPRH7JB.js";
|
|
6
6
|
import "../chunk-22CV7V7A.js";
|
|
7
7
|
import "../chunk-3MIR7ODJ.js";
|
|
8
8
|
import "../chunk-VUNL35KE.js";
|
|
@@ -587,11 +587,26 @@ export PUSHARY_API_KEY='${apiKey}'
|
|
|
587
587
|
process.env.PUSHARY_API_KEY = apiKey;
|
|
588
588
|
});
|
|
589
589
|
};
|
|
590
|
+
var setupCustom = async (_apiKey) => {
|
|
591
|
+
console.log(`
|
|
592
|
+
${bold2("Connect any other agent (MCP or HTTP)")}
|
|
593
|
+
`);
|
|
594
|
+
console.log(` ${dim2("Your key is saved as")} ${cyan2("$PUSHARY_API_KEY")} ${dim2("in your shell profile.")}`);
|
|
595
|
+
console.log();
|
|
596
|
+
console.log(` ${dim2("MCP clients (Windsurf, LangChain, custom) \u2014 add this server:")}`);
|
|
597
|
+
console.log(` ${cyan2("https://pushary.com/api/mcp/mcp")} ${dim2("with header")} ${cyan2("Authorization: Bearer $PUSHARY_API_KEY")}`);
|
|
598
|
+
console.log();
|
|
599
|
+
console.log(` ${dim2("No-code / HTTP (n8n, Zapier, scripts) \u2014 ask a human and wait:")}`);
|
|
600
|
+
console.log(` ${dim2("POST")} ${cyan2("https://pushary.com/api/v1/server/ask")} ${dim2("body")} ${cyan2('{"question":"Approve?","type":"confirm","wait":true}')}`);
|
|
601
|
+
console.log();
|
|
602
|
+
console.log(` ${dim2("Full guide:")} ${cyan2("https://pushary.com/docs/agents/connect-any-agent")}`);
|
|
603
|
+
};
|
|
590
604
|
var AGENT_SETUP = {
|
|
591
605
|
claude_code: setupClaudeCode,
|
|
592
606
|
codex: setupCodex,
|
|
593
607
|
hermes: setupHermes,
|
|
594
|
-
cursor: setupCursor
|
|
608
|
+
cursor: setupCursor,
|
|
609
|
+
custom: setupCustom
|
|
595
610
|
};
|
|
596
611
|
var main = async () => {
|
|
597
612
|
const version = getPackageVersion();
|
|
@@ -638,7 +653,8 @@ var main = async () => {
|
|
|
638
653
|
claude_code: isInstalled("claude"),
|
|
639
654
|
codex: isInstalled("codex"),
|
|
640
655
|
hermes: isInstalled("hermes"),
|
|
641
|
-
cursor: isInstalled("cursor")
|
|
656
|
+
cursor: isInstalled("cursor"),
|
|
657
|
+
custom: false
|
|
642
658
|
};
|
|
643
659
|
const hint = Object.values(detected).some(Boolean) ? "(detected agents pre-selected)" : "(space = toggle, enter = confirm)";
|
|
644
660
|
const agents = await checkbox({
|
|
@@ -647,7 +663,8 @@ var main = async () => {
|
|
|
647
663
|
{ name: `Claude Code ${dim2("MCP + hooks + auto-allowed tools")}`, value: "claude_code", checked: detected.claude_code },
|
|
648
664
|
{ name: `Codex ${dim2("MCP + native hooks + auto-allowed tools")}`, value: "codex", checked: detected.codex },
|
|
649
665
|
{ name: `Hermes ${dim2("native plugin + auto-error notifications")}`, value: "hermes", checked: detected.hermes },
|
|
650
|
-
{ name: `Cursor ${dim2("MCP server")}`, value: "cursor", checked: detected.cursor }
|
|
666
|
+
{ name: `Cursor ${dim2("MCP server")}`, value: "cursor", checked: detected.cursor },
|
|
667
|
+
{ name: `Other ${dim2("any MCP or HTTP agent (Windsurf, n8n, custom)")}`, value: "custom", checked: false }
|
|
651
668
|
]
|
|
652
669
|
});
|
|
653
670
|
await saveApiKey(trimmedKey);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
handleStop
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-YCL4GUFR.js";
|
|
5
|
+
import "../chunk-QEPRH7JB.js";
|
|
6
6
|
import "../chunk-22CV7V7A.js";
|
|
7
7
|
import "../chunk-3MIR7ODJ.js";
|
|
8
8
|
import "../chunk-VUNL35KE.js";
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_SESSION,
|
|
3
|
+
askUser,
|
|
4
|
+
deriveToolTarget,
|
|
5
|
+
describeToolCall,
|
|
6
|
+
fetchModeState,
|
|
7
|
+
getMachineId,
|
|
8
|
+
getPolicy,
|
|
9
|
+
resolvePolicy,
|
|
10
|
+
savePendingQuestion,
|
|
11
|
+
sendNotification,
|
|
12
|
+
waitForAnswer
|
|
13
|
+
} from "./chunk-QEPRH7JB.js";
|
|
14
|
+
import {
|
|
15
|
+
getApiKey
|
|
16
|
+
} from "./chunk-VUNL35KE.js";
|
|
17
|
+
|
|
18
|
+
// src/hook.ts
|
|
19
|
+
import { basename } from "path";
|
|
20
|
+
var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
21
|
+
var allow = () => ({
|
|
22
|
+
hookSpecificOutput: {
|
|
23
|
+
hookEventName: "PreToolUse",
|
|
24
|
+
permissionDecision: "allow"
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
var deny = (reason) => ({
|
|
28
|
+
hookSpecificOutput: {
|
|
29
|
+
hookEventName: "PreToolUse",
|
|
30
|
+
permissionDecision: "deny",
|
|
31
|
+
permissionDecisionReason: reason
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
var ask = (reason) => ({
|
|
35
|
+
hookSpecificOutput: {
|
|
36
|
+
hookEventName: "PreToolUse",
|
|
37
|
+
permissionDecision: "ask",
|
|
38
|
+
...reason ? { permissionDecisionReason: reason } : {}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
var pollForAnswer = async (apiKey, correlationId, deadlineMs, pollInterval = 2e3) => {
|
|
42
|
+
while (Date.now() < deadlineMs) {
|
|
43
|
+
const remaining = Math.min(Math.max(deadlineMs - Date.now(), 1e3), 3e4);
|
|
44
|
+
let answer;
|
|
45
|
+
try {
|
|
46
|
+
answer = await waitForAnswer(apiKey, correlationId, remaining);
|
|
47
|
+
} catch {
|
|
48
|
+
if (Date.now() + pollInterval >= deadlineMs) break;
|
|
49
|
+
await sleep(pollInterval);
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (answer.answered) return answer;
|
|
53
|
+
if (Date.now() + pollInterval >= deadlineMs) break;
|
|
54
|
+
await sleep(pollInterval);
|
|
55
|
+
}
|
|
56
|
+
return { answered: false };
|
|
57
|
+
};
|
|
58
|
+
var handlePushOnly = async (apiKey, description, projectName, timeoutSeconds, timeoutAction, sessionId, machineId, toolName, toolTarget) => {
|
|
59
|
+
let result;
|
|
60
|
+
try {
|
|
61
|
+
result = await askUser(apiKey, {
|
|
62
|
+
question: `Allow ${description}?`,
|
|
63
|
+
type: "confirm",
|
|
64
|
+
context: `Agent wants to run this in ${projectName}`,
|
|
65
|
+
agentName: `Claude Code - ${projectName}`,
|
|
66
|
+
sessionId,
|
|
67
|
+
machineId,
|
|
68
|
+
toolName,
|
|
69
|
+
toolTarget
|
|
70
|
+
});
|
|
71
|
+
} catch {
|
|
72
|
+
switch (timeoutAction) {
|
|
73
|
+
case "approve":
|
|
74
|
+
return allow();
|
|
75
|
+
case "deny":
|
|
76
|
+
return deny("Push notification failed, denying per policy");
|
|
77
|
+
default:
|
|
78
|
+
return ask("Push notification failed, asking in terminal");
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const deadline = Date.now() + timeoutSeconds * 1e3;
|
|
82
|
+
const answer = await pollForAnswer(apiKey, result.correlationId, deadline);
|
|
83
|
+
if (answer.answered) {
|
|
84
|
+
return answer.value === "yes" ? allow() : deny("Denied via push notification");
|
|
85
|
+
}
|
|
86
|
+
switch (timeoutAction) {
|
|
87
|
+
case "approve":
|
|
88
|
+
return allow();
|
|
89
|
+
case "deny":
|
|
90
|
+
return deny("No response within timeout");
|
|
91
|
+
default:
|
|
92
|
+
return ask("No push response, asking in terminal");
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
var handleTerminalOnly = () => {
|
|
96
|
+
return ask();
|
|
97
|
+
};
|
|
98
|
+
var handlePushFirst = async (apiKey, description, projectName, pushFirstSeconds, sessionId, machineId, toolName, toolTarget) => {
|
|
99
|
+
let result;
|
|
100
|
+
try {
|
|
101
|
+
result = await askUser(apiKey, {
|
|
102
|
+
question: `Allow ${description}?`,
|
|
103
|
+
type: "confirm",
|
|
104
|
+
context: `Agent wants to run this in ${projectName}`,
|
|
105
|
+
agentName: `Claude Code - ${projectName}`,
|
|
106
|
+
sessionId,
|
|
107
|
+
machineId,
|
|
108
|
+
toolName,
|
|
109
|
+
toolTarget
|
|
110
|
+
});
|
|
111
|
+
} catch {
|
|
112
|
+
return ask("Push notification failed, asking in terminal");
|
|
113
|
+
}
|
|
114
|
+
const deadline = Date.now() + pushFirstSeconds * 1e3;
|
|
115
|
+
const answer = await pollForAnswer(apiKey, result.correlationId, deadline, 1500);
|
|
116
|
+
if (answer.answered) {
|
|
117
|
+
return answer.value === "yes" ? allow() : deny("Denied via push notification");
|
|
118
|
+
}
|
|
119
|
+
savePendingQuestion(sessionId || DEFAULT_SESSION, result.correlationId);
|
|
120
|
+
return ask("Sent as push notification. You can also approve here.");
|
|
121
|
+
};
|
|
122
|
+
var handleNotifyOnly = async (apiKey, description, projectName, sessionId, machineId) => {
|
|
123
|
+
try {
|
|
124
|
+
await sendNotification(apiKey, {
|
|
125
|
+
title: "Agent needs approval",
|
|
126
|
+
body: description,
|
|
127
|
+
agentName: `Claude Code - ${projectName}`,
|
|
128
|
+
sessionId,
|
|
129
|
+
machineId
|
|
130
|
+
});
|
|
131
|
+
} catch {
|
|
132
|
+
}
|
|
133
|
+
return ask();
|
|
134
|
+
};
|
|
135
|
+
var handlePreToolUse = async (input) => {
|
|
136
|
+
try {
|
|
137
|
+
const apiKey = getApiKey();
|
|
138
|
+
const modeState = await fetchModeState(apiKey, input.session_id);
|
|
139
|
+
const policy = await getPolicy(apiKey, modeState.policyVersion);
|
|
140
|
+
if (modeState.kill) {
|
|
141
|
+
return deny("Stopped by user \u2014 this agent was halted from Pushary");
|
|
142
|
+
}
|
|
143
|
+
const toolPolicy = resolvePolicy(policy, input.tool_name, modeState.mode, input.tool_input);
|
|
144
|
+
if (toolPolicy.timeoutSeconds === 0 && toolPolicy.timeoutAction === "approve") {
|
|
145
|
+
return allow();
|
|
146
|
+
}
|
|
147
|
+
if (toolPolicy.timeoutSeconds === 0 && toolPolicy.timeoutAction === "deny") {
|
|
148
|
+
return deny(`Denied by policy for ${toolPolicy.tool}`);
|
|
149
|
+
}
|
|
150
|
+
const description = describeToolCall(input.tool_name, input.tool_input, "hook");
|
|
151
|
+
const projectName = basename(input.cwd ?? process.cwd());
|
|
152
|
+
const sessionId = input.session_id;
|
|
153
|
+
const machineId = getMachineId();
|
|
154
|
+
const toolTarget = deriveToolTarget(input.tool_name, input.tool_input);
|
|
155
|
+
switch (toolPolicy.mode) {
|
|
156
|
+
case "push_only":
|
|
157
|
+
return handlePushOnly(apiKey, description, projectName, toolPolicy.timeoutSeconds, toolPolicy.timeoutAction, sessionId, machineId, input.tool_name, toolTarget);
|
|
158
|
+
case "terminal_only":
|
|
159
|
+
return handleTerminalOnly();
|
|
160
|
+
case "push_first":
|
|
161
|
+
return handlePushFirst(apiKey, description, projectName, toolPolicy.pushFirstSeconds, sessionId, machineId, input.tool_name, toolTarget);
|
|
162
|
+
case "notify_only":
|
|
163
|
+
return handleNotifyOnly(apiKey, description, projectName, sessionId, machineId);
|
|
164
|
+
default:
|
|
165
|
+
return handlePushFirst(apiKey, description, projectName, toolPolicy.pushFirstSeconds, sessionId, machineId, input.tool_name, toolTarget);
|
|
166
|
+
}
|
|
167
|
+
} catch {
|
|
168
|
+
return ask("Pushary unavailable, falling back to terminal approval");
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
export {
|
|
173
|
+
handlePreToolUse
|
|
174
|
+
};
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import {
|
|
2
|
+
extractPolicyArg,
|
|
3
|
+
isApprovalMode,
|
|
4
|
+
matchRankWeight,
|
|
5
|
+
matchToolPattern
|
|
6
|
+
} from "./chunk-22CV7V7A.js";
|
|
7
|
+
import {
|
|
8
|
+
callMcpTool,
|
|
9
|
+
withRetry
|
|
10
|
+
} from "./chunk-3MIR7ODJ.js";
|
|
11
|
+
import {
|
|
12
|
+
getBaseUrl
|
|
13
|
+
} from "./chunk-VUNL35KE.js";
|
|
14
|
+
|
|
15
|
+
// src/validate.ts
|
|
16
|
+
var isPolicyConfig = (data) => {
|
|
17
|
+
if (!data || typeof data !== "object") return false;
|
|
18
|
+
const d = data;
|
|
19
|
+
return Array.isArray(d.policies) && typeof d.defaultTimeoutSeconds === "number" && typeof d.defaultTimeoutAction === "string";
|
|
20
|
+
};
|
|
21
|
+
var isAskUserResponse = (data) => {
|
|
22
|
+
if (!data || typeof data !== "object") return false;
|
|
23
|
+
const d = data;
|
|
24
|
+
return typeof d.correlationId === "string" && typeof d.status === "string";
|
|
25
|
+
};
|
|
26
|
+
var isWaitForAnswerResponse = (data) => {
|
|
27
|
+
if (!data || typeof data !== "object") return false;
|
|
28
|
+
const d = data;
|
|
29
|
+
return typeof d.answered === "boolean";
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// src/api.ts
|
|
33
|
+
var askUser = async (apiKey, params) => {
|
|
34
|
+
const result = await callMcpTool(apiKey, "ask_user", { ...params, wait: false }, { maxRetries: 3 });
|
|
35
|
+
if (!isAskUserResponse(result)) throw new Error("Invalid ask_user response");
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
var waitForAnswer = async (apiKey, correlationId, timeoutMs = 3e4) => {
|
|
39
|
+
const result = await callMcpTool(apiKey, "wait_for_answer", {
|
|
40
|
+
correlationId,
|
|
41
|
+
timeoutMs
|
|
42
|
+
});
|
|
43
|
+
if (!isWaitForAnswerResponse(result)) throw new Error("Invalid wait_for_answer response");
|
|
44
|
+
return result;
|
|
45
|
+
};
|
|
46
|
+
var cancelQuestion = async (apiKey, correlationId) => {
|
|
47
|
+
await callMcpTool(apiKey, "cancel_question", { correlationId });
|
|
48
|
+
};
|
|
49
|
+
var sendNotification = async (apiKey, params) => {
|
|
50
|
+
await callMcpTool(apiKey, "send_notification", { ...params }, { maxRetries: 3 });
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// src/policy.ts
|
|
54
|
+
import { createHash } from "crypto";
|
|
55
|
+
import { existsSync, readFileSync, writeFileSync } from "fs";
|
|
56
|
+
import { join } from "path";
|
|
57
|
+
import { tmpdir } from "os";
|
|
58
|
+
var CACHE_TTL_MS = 60 * 1e3;
|
|
59
|
+
var cacheFile = (apiKey) => {
|
|
60
|
+
const hash = createHash("sha256").update(apiKey).digest("hex").slice(0, 12);
|
|
61
|
+
return join(tmpdir(), `pushary-policy-${hash}.json`);
|
|
62
|
+
};
|
|
63
|
+
var fetchPolicy = async (apiKey) => {
|
|
64
|
+
return withRetry(async () => {
|
|
65
|
+
const baseUrl = getBaseUrl();
|
|
66
|
+
const response = await fetch(`${baseUrl}/api/mcp/policy`, {
|
|
67
|
+
headers: { "Authorization": `Bearer ${apiKey}` },
|
|
68
|
+
signal: AbortSignal.timeout(1e4)
|
|
69
|
+
});
|
|
70
|
+
if (!response.ok) {
|
|
71
|
+
throw new Error(`Failed to fetch policy: ${response.status}`);
|
|
72
|
+
}
|
|
73
|
+
const raw = await response.json();
|
|
74
|
+
if (!isPolicyConfig(raw)) throw new Error("Invalid policy response");
|
|
75
|
+
return raw;
|
|
76
|
+
}, { maxAttempts: 2 });
|
|
77
|
+
};
|
|
78
|
+
var getPolicy = async (apiKey, expectedVersion) => {
|
|
79
|
+
const path = cacheFile(apiKey);
|
|
80
|
+
let staleCache = null;
|
|
81
|
+
if (existsSync(path)) {
|
|
82
|
+
try {
|
|
83
|
+
const stat = readFileSync(path, "utf-8");
|
|
84
|
+
const cached = JSON.parse(stat);
|
|
85
|
+
if (!isPolicyConfig(cached)) throw new Error("Corrupted cache");
|
|
86
|
+
const versionStale = expectedVersion != null && (cached._policyVersion ?? null) !== expectedVersion;
|
|
87
|
+
const ttlFresh = !cached._cachedAt || Date.now() - cached._cachedAt < CACHE_TTL_MS;
|
|
88
|
+
if (ttlFresh && !versionStale) {
|
|
89
|
+
return cached;
|
|
90
|
+
}
|
|
91
|
+
staleCache = cached;
|
|
92
|
+
} catch {
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
try {
|
|
96
|
+
const policy = await fetchPolicy(apiKey);
|
|
97
|
+
try {
|
|
98
|
+
writeFileSync(path, JSON.stringify({ ...policy, _cachedAt: Date.now(), _policyVersion: expectedVersion ?? null }), "utf-8");
|
|
99
|
+
} catch {
|
|
100
|
+
}
|
|
101
|
+
return policy;
|
|
102
|
+
} catch {
|
|
103
|
+
if (staleCache) return staleCache;
|
|
104
|
+
throw new Error("Failed to fetch policy and no cached policy available");
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
var findBestMatch = (policies, toolName, arg) => {
|
|
108
|
+
let best;
|
|
109
|
+
let bestWeight = 0;
|
|
110
|
+
let bestLength = -1;
|
|
111
|
+
for (const candidate of policies) {
|
|
112
|
+
const rank = matchToolPattern(candidate.tool, toolName, arg);
|
|
113
|
+
if (rank === "none") continue;
|
|
114
|
+
const weight = matchRankWeight(rank);
|
|
115
|
+
const length = rank === "prefix" ? candidate.tool.length : -1;
|
|
116
|
+
if (weight > bestWeight || weight === bestWeight && length > bestLength) {
|
|
117
|
+
best = candidate;
|
|
118
|
+
bestWeight = weight;
|
|
119
|
+
bestLength = length;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return best;
|
|
123
|
+
};
|
|
124
|
+
var resolvePolicy = (config, toolName, modeOverride, toolInput) => {
|
|
125
|
+
const arg = toolInput ? extractPolicyArg(toolName, toolInput) : void 0;
|
|
126
|
+
const base = findBestMatch(config.policies, toolName, arg) ?? config.policies.find((p) => p.tool === "*") ?? {
|
|
127
|
+
tool: toolName,
|
|
128
|
+
timeoutSeconds: config.defaultTimeoutSeconds,
|
|
129
|
+
timeoutAction: config.defaultTimeoutAction,
|
|
130
|
+
mode: config.defaultMode ?? "push_first",
|
|
131
|
+
pushFirstSeconds: config.defaultPushFirstSeconds ?? 20
|
|
132
|
+
};
|
|
133
|
+
const effectiveOverride = modeOverride ?? config.modeOverride;
|
|
134
|
+
if (effectiveOverride) {
|
|
135
|
+
return { ...base, mode: effectiveOverride };
|
|
136
|
+
}
|
|
137
|
+
return base;
|
|
138
|
+
};
|
|
139
|
+
var toPolicyVersion = (value) => typeof value === "string" || typeof value === "number" ? String(value) : null;
|
|
140
|
+
var fetchModeState = async (apiKey, sessionId) => {
|
|
141
|
+
try {
|
|
142
|
+
const baseUrl = getBaseUrl();
|
|
143
|
+
const url = sessionId ? `${baseUrl}/api/mcp/mode?session=${encodeURIComponent(sessionId)}` : `${baseUrl}/api/mcp/mode`;
|
|
144
|
+
const response = await fetch(url, {
|
|
145
|
+
headers: { "Authorization": `Bearer ${apiKey}` },
|
|
146
|
+
signal: AbortSignal.timeout(3e3)
|
|
147
|
+
});
|
|
148
|
+
if (!response.ok) return { mode: null, kill: false, policyVersion: null };
|
|
149
|
+
const data = await response.json();
|
|
150
|
+
const mode = data.override?.mode;
|
|
151
|
+
return {
|
|
152
|
+
mode: isApprovalMode(mode) ? mode : null,
|
|
153
|
+
kill: data.kill === true,
|
|
154
|
+
policyVersion: toPolicyVersion(data.policyVersion)
|
|
155
|
+
};
|
|
156
|
+
} catch {
|
|
157
|
+
return { mode: null, kill: false, policyVersion: null };
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
var fetchModeOverride = async (apiKey) => (await fetchModeState(apiKey)).mode;
|
|
161
|
+
|
|
162
|
+
// src/describe.ts
|
|
163
|
+
import { isAbsolute, relative } from "path";
|
|
164
|
+
var hookPrefixes = {
|
|
165
|
+
Bash: (input) => `bash: ${input.command ?? "(no command)"}`,
|
|
166
|
+
Write: (input) => `write file: ${input.file_path ?? "(unknown path)"}`,
|
|
167
|
+
Edit: (input) => `edit file: ${input.file_path ?? "(unknown path)"}`,
|
|
168
|
+
Read: (input) => `read file: ${input.file_path ?? "(unknown path)"}`
|
|
169
|
+
};
|
|
170
|
+
var eventPrefixes = {
|
|
171
|
+
Bash: (input) => `ran: ${String(input.command ?? "").slice(0, 120)}`,
|
|
172
|
+
Write: (input) => `wrote: ${input.file_path ?? "unknown"}`,
|
|
173
|
+
Edit: (input) => `edited: ${input.file_path ?? "unknown"}`,
|
|
174
|
+
Read: (input) => `read: ${input.file_path ?? "unknown"}`
|
|
175
|
+
};
|
|
176
|
+
var describeToolCall = (toolName, toolInput, format = "hook") => {
|
|
177
|
+
const prefixes = format === "hook" ? hookPrefixes : eventPrefixes;
|
|
178
|
+
const builder = prefixes[toolName];
|
|
179
|
+
if (builder) return builder(toolInput);
|
|
180
|
+
return format === "hook" ? `${toolName}: ${JSON.stringify(toolInput).slice(0, 200)}` : `${toolName}: done`;
|
|
181
|
+
};
|
|
182
|
+
var TOOL_TARGET_MAX_LENGTH = 80;
|
|
183
|
+
var deriveCommandHead = (command) => {
|
|
184
|
+
if (typeof command !== "string") return void 0;
|
|
185
|
+
const head = command.trim().split(/\s+/).slice(0, 2).join(" ");
|
|
186
|
+
return head ? head.slice(0, TOOL_TARGET_MAX_LENGTH) : void 0;
|
|
187
|
+
};
|
|
188
|
+
var deriveToolTarget = (toolName, toolInput) => {
|
|
189
|
+
if (toolName === "Bash") {
|
|
190
|
+
return deriveCommandHead(toolInput.command);
|
|
191
|
+
}
|
|
192
|
+
if (toolName === "Edit" || toolName === "Write") {
|
|
193
|
+
const filePath = toolInput.file_path;
|
|
194
|
+
if (typeof filePath !== "string") return void 0;
|
|
195
|
+
const separator = Math.max(filePath.lastIndexOf("/"), filePath.lastIndexOf("\\"));
|
|
196
|
+
const base = filePath.slice(separator + 1);
|
|
197
|
+
const dot = base.lastIndexOf(".");
|
|
198
|
+
if (dot <= 0) return void 0;
|
|
199
|
+
return base.slice(dot).slice(0, TOOL_TARGET_MAX_LENGTH);
|
|
200
|
+
}
|
|
201
|
+
return void 0;
|
|
202
|
+
};
|
|
203
|
+
var RECEIPT_TARGET_MAX_LENGTH = 256;
|
|
204
|
+
var isToolResultError = (toolResult) => {
|
|
205
|
+
try {
|
|
206
|
+
return Boolean(toolResult && ("error" in toolResult || "is_error" in toolResult));
|
|
207
|
+
} catch {
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
var relativizeReceiptPath = (filePath, cwd) => {
|
|
212
|
+
if (!cwd || !isAbsolute(filePath)) return filePath;
|
|
213
|
+
return relative(cwd, filePath);
|
|
214
|
+
};
|
|
215
|
+
var deriveReceiptMeta = (toolName, toolInput, toolResult, cwd) => {
|
|
216
|
+
try {
|
|
217
|
+
const ok = !isToolResultError(toolResult);
|
|
218
|
+
if (toolName === "Edit" || toolName === "Write") {
|
|
219
|
+
const filePath = toolInput.file_path;
|
|
220
|
+
if (typeof filePath !== "string" || !filePath) return void 0;
|
|
221
|
+
return {
|
|
222
|
+
kind: toolName === "Edit" ? "edit" : "write",
|
|
223
|
+
target: relativizeReceiptPath(filePath, cwd).slice(0, RECEIPT_TARGET_MAX_LENGTH),
|
|
224
|
+
ok
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
if (toolName === "Bash") {
|
|
228
|
+
const head = deriveCommandHead(toolInput.command);
|
|
229
|
+
if (!head) return void 0;
|
|
230
|
+
return {
|
|
231
|
+
kind: head === "git commit" ? "commit" : "bash",
|
|
232
|
+
target: head,
|
|
233
|
+
ok
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
return void 0;
|
|
237
|
+
} catch {
|
|
238
|
+
return void 0;
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
// src/identity.ts
|
|
243
|
+
import { createHash as createHash2 } from "crypto";
|
|
244
|
+
import { hostname } from "os";
|
|
245
|
+
var deriveMachineId = (host) => createHash2("sha256").update(host).digest("hex").slice(0, 8);
|
|
246
|
+
var getMachineId = () => deriveMachineId(hostname());
|
|
247
|
+
|
|
248
|
+
// src/pending.ts
|
|
249
|
+
import { join as join2 } from "path";
|
|
250
|
+
import { tmpdir as tmpdir2 } from "os";
|
|
251
|
+
import { existsSync as existsSync2, mkdirSync, writeFileSync as writeFileSync2, readdirSync, unlinkSync, rmSync, statSync } from "fs";
|
|
252
|
+
var PENDING_DIR = join2(tmpdir2(), "pushary-pending");
|
|
253
|
+
var DEFAULT_SESSION = "_no_session";
|
|
254
|
+
var GRACE_MS = 10 * 60 * 1e3;
|
|
255
|
+
var sanitize = (sessionId) => sessionId.replace(/[^A-Za-z0-9_-]/g, "_").slice(0, 128) || DEFAULT_SESSION;
|
|
256
|
+
var dirFor = (sessionId) => join2(PENDING_DIR, sanitize(sessionId));
|
|
257
|
+
var isDefaultSession = (sessionId) => sanitize(sessionId) === DEFAULT_SESSION;
|
|
258
|
+
var savePendingQuestion = (sessionId, correlationId) => {
|
|
259
|
+
const dir = dirFor(sessionId);
|
|
260
|
+
if (!existsSync2(dir)) mkdirSync(dir, { recursive: true });
|
|
261
|
+
writeFileSync2(join2(dir, correlationId), "", "utf-8");
|
|
262
|
+
};
|
|
263
|
+
var listPendingQuestions = (sessionId) => {
|
|
264
|
+
const dir = dirFor(sessionId);
|
|
265
|
+
let files;
|
|
266
|
+
try {
|
|
267
|
+
files = readdirSync(dir);
|
|
268
|
+
} catch {
|
|
269
|
+
return [];
|
|
270
|
+
}
|
|
271
|
+
if (!isDefaultSession(sessionId)) return files;
|
|
272
|
+
const cutoff = Date.now() - GRACE_MS;
|
|
273
|
+
return files.filter((name) => {
|
|
274
|
+
try {
|
|
275
|
+
return statSync(join2(dir, name)).mtimeMs < cutoff;
|
|
276
|
+
} catch {
|
|
277
|
+
return false;
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
};
|
|
281
|
+
var removePendingQuestion = (sessionId, correlationId) => {
|
|
282
|
+
try {
|
|
283
|
+
unlinkSync(join2(dirFor(sessionId), correlationId));
|
|
284
|
+
} catch {
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
var removePendingSession = (sessionId) => {
|
|
288
|
+
try {
|
|
289
|
+
rmSync(dirFor(sessionId), { recursive: true, force: true });
|
|
290
|
+
} catch {
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
export {
|
|
295
|
+
isPolicyConfig,
|
|
296
|
+
askUser,
|
|
297
|
+
waitForAnswer,
|
|
298
|
+
cancelQuestion,
|
|
299
|
+
sendNotification,
|
|
300
|
+
getPolicy,
|
|
301
|
+
resolvePolicy,
|
|
302
|
+
fetchModeState,
|
|
303
|
+
fetchModeOverride,
|
|
304
|
+
describeToolCall,
|
|
305
|
+
deriveToolTarget,
|
|
306
|
+
isToolResultError,
|
|
307
|
+
deriveReceiptMeta,
|
|
308
|
+
getMachineId,
|
|
309
|
+
DEFAULT_SESSION,
|
|
310
|
+
isDefaultSession,
|
|
311
|
+
savePendingQuestion,
|
|
312
|
+
listPendingQuestions,
|
|
313
|
+
removePendingQuestion,
|
|
314
|
+
removePendingSession
|
|
315
|
+
};
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_SESSION,
|
|
3
|
+
cancelQuestion,
|
|
4
|
+
deriveReceiptMeta,
|
|
5
|
+
describeToolCall,
|
|
6
|
+
fetchModeState,
|
|
7
|
+
getMachineId,
|
|
8
|
+
isDefaultSession,
|
|
9
|
+
isPolicyConfig,
|
|
10
|
+
isToolResultError,
|
|
11
|
+
listPendingQuestions,
|
|
12
|
+
removePendingQuestion,
|
|
13
|
+
removePendingSession,
|
|
14
|
+
resolvePolicy
|
|
15
|
+
} from "./chunk-QEPRH7JB.js";
|
|
16
|
+
import {
|
|
17
|
+
withRetry
|
|
18
|
+
} from "./chunk-3MIR7ODJ.js";
|
|
19
|
+
import {
|
|
20
|
+
getApiKey,
|
|
21
|
+
getBaseUrl
|
|
22
|
+
} from "./chunk-VUNL35KE.js";
|
|
23
|
+
|
|
24
|
+
// src/codex-adapter.ts
|
|
25
|
+
var CODEX_AGENT = { type: "codex", label: "Codex" };
|
|
26
|
+
var codexAllow = () => ({ kind: "allow" });
|
|
27
|
+
var codexDeny = (reason) => ({ kind: "deny", reason });
|
|
28
|
+
var codexPass = () => ({ kind: "pass" });
|
|
29
|
+
var toCodexWire = (event, decision) => {
|
|
30
|
+
if (event === "PermissionRequest") {
|
|
31
|
+
if (decision.kind === "allow") {
|
|
32
|
+
return {
|
|
33
|
+
hookSpecificOutput: {
|
|
34
|
+
hookEventName: "PermissionRequest",
|
|
35
|
+
decision: { behavior: "allow" }
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
if (decision.kind === "deny") {
|
|
40
|
+
return {
|
|
41
|
+
hookSpecificOutput: {
|
|
42
|
+
hookEventName: "PermissionRequest",
|
|
43
|
+
decision: { behavior: "deny", message: decision.reason }
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
if (event === "PreToolUse" && decision.kind === "deny") {
|
|
50
|
+
return {
|
|
51
|
+
hookSpecificOutput: {
|
|
52
|
+
hookEventName: "PreToolUse",
|
|
53
|
+
permissionDecision: "deny",
|
|
54
|
+
permissionDecisionReason: decision.reason
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
59
|
+
};
|
|
60
|
+
var toPolicyLookup = (toolName, toolInput) => {
|
|
61
|
+
if (toolName !== "apply_patch") return { tool: toolName, input: toolInput };
|
|
62
|
+
const command = toolInput.command;
|
|
63
|
+
return {
|
|
64
|
+
tool: "Edit",
|
|
65
|
+
input: typeof command === "string" ? { file_path: command } : {}
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
var permissionTimeoutDecision = (timeoutAction) => {
|
|
69
|
+
if (timeoutAction === "approve") return codexAllow();
|
|
70
|
+
if (timeoutAction === "deny") return codexDeny("No response within timeout");
|
|
71
|
+
return codexPass();
|
|
72
|
+
};
|
|
73
|
+
var preToolUseTimeoutDecision = (timeoutAction, denyReason = "No response within timeout") => timeoutAction === "deny" ? codexDeny(denyReason) : codexPass();
|
|
74
|
+
|
|
75
|
+
// src/events.ts
|
|
76
|
+
import { basename, join } from "path";
|
|
77
|
+
import { createHash } from "crypto";
|
|
78
|
+
import { existsSync, readFileSync } from "fs";
|
|
79
|
+
import { tmpdir } from "os";
|
|
80
|
+
var cleanupPendingQuestions = async (sessionId) => {
|
|
81
|
+
try {
|
|
82
|
+
const files = listPendingQuestions(sessionId);
|
|
83
|
+
const apiKey = getApiKey();
|
|
84
|
+
for (const correlationId of files) {
|
|
85
|
+
try {
|
|
86
|
+
await cancelQuestion(apiKey, correlationId);
|
|
87
|
+
} catch {
|
|
88
|
+
}
|
|
89
|
+
removePendingQuestion(sessionId, correlationId);
|
|
90
|
+
}
|
|
91
|
+
if (!isDefaultSession(sessionId)) removePendingSession(sessionId);
|
|
92
|
+
} catch {
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
var CLAUDE_CODE_AGENT = { type: "claude_code", label: "Claude Code" };
|
|
96
|
+
var POLICY_CACHE_TTL_MS = 5 * 60 * 1e3;
|
|
97
|
+
var readFreshCachedPolicy = (apiKey) => {
|
|
98
|
+
const hash = createHash("sha256").update(apiKey).digest("hex").slice(0, 12);
|
|
99
|
+
const path = join(tmpdir(), `pushary-policy-${hash}.json`);
|
|
100
|
+
if (!existsSync(path)) return null;
|
|
101
|
+
const cached = JSON.parse(readFileSync(path, "utf-8"));
|
|
102
|
+
if (!isPolicyConfig(cached)) return null;
|
|
103
|
+
if (!cached._cachedAt || Date.now() - cached._cachedAt >= POLICY_CACHE_TTL_MS) return null;
|
|
104
|
+
return cached;
|
|
105
|
+
};
|
|
106
|
+
var deriveDecisionSource = (toolName, toolInput, liveMode) => {
|
|
107
|
+
try {
|
|
108
|
+
if (liveMode.kill) return "terminal";
|
|
109
|
+
const policy = readFreshCachedPolicy(getApiKey());
|
|
110
|
+
if (!policy) return void 0;
|
|
111
|
+
const resolved = resolvePolicy(policy, toolName, liveMode.mode, toolInput);
|
|
112
|
+
if (resolved.timeoutSeconds === 0 && resolved.timeoutAction === "approve") return "policy_auto";
|
|
113
|
+
if (resolved.mode === "push_only" || resolved.mode === "push_first") return "human";
|
|
114
|
+
return "terminal";
|
|
115
|
+
} catch {
|
|
116
|
+
return void 0;
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
var reportEvent = async (event, options = {}) => {
|
|
120
|
+
const apiKey = getApiKey();
|
|
121
|
+
const baseUrl = getBaseUrl();
|
|
122
|
+
await withRetry(async () => {
|
|
123
|
+
await fetch(`${baseUrl}/api/agent/event`, {
|
|
124
|
+
method: "POST",
|
|
125
|
+
headers: {
|
|
126
|
+
"Content-Type": "application/json",
|
|
127
|
+
"Authorization": `Bearer ${apiKey}`
|
|
128
|
+
},
|
|
129
|
+
body: JSON.stringify({
|
|
130
|
+
...event,
|
|
131
|
+
machineId: event.machineId ?? getMachineId()
|
|
132
|
+
}),
|
|
133
|
+
signal: AbortSignal.timeout(options.timeoutMs ?? 1e4)
|
|
134
|
+
});
|
|
135
|
+
}, { maxAttempts: options.maxAttempts ?? 2, baseDelayMs: 300 });
|
|
136
|
+
};
|
|
137
|
+
var handlePostToolUse = async (input, agent = CLAUDE_CODE_AGENT) => {
|
|
138
|
+
try {
|
|
139
|
+
const projectName = basename(input.cwd ?? process.cwd());
|
|
140
|
+
const action = describeToolCall(input.tool_name, input.tool_input, "event");
|
|
141
|
+
const lookup = toPolicyLookup(input.tool_name, input.tool_input);
|
|
142
|
+
const isError = isToolResultError(input.tool_result);
|
|
143
|
+
const receiptsEnabled = process.env.PUSHARY_RECEIPTS !== "off";
|
|
144
|
+
const liveMode = await fetchModeState(getApiKey(), input.session_id);
|
|
145
|
+
await Promise.allSettled([
|
|
146
|
+
cleanupPendingQuestions(input.session_id || DEFAULT_SESSION),
|
|
147
|
+
reportEvent({
|
|
148
|
+
event: isError ? "tool_error" : "tool_complete",
|
|
149
|
+
agentType: agent.type,
|
|
150
|
+
agentName: `${agent.label} - ${projectName}`,
|
|
151
|
+
action,
|
|
152
|
+
sessionId: input.session_id,
|
|
153
|
+
error: isError ? String(input.tool_result?.error ?? input.tool_result?.stderr ?? "").slice(0, 500) : void 0,
|
|
154
|
+
decisionSource: deriveDecisionSource(lookup.tool, lookup.input, liveMode),
|
|
155
|
+
meta: receiptsEnabled ? deriveReceiptMeta(lookup.tool, lookup.input, input.tool_result, input.cwd ?? process.cwd()) : void 0
|
|
156
|
+
})
|
|
157
|
+
]);
|
|
158
|
+
} catch {
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
var TASK_TITLE_MAX_LENGTH = 120;
|
|
162
|
+
var handleUserPrompt = async (input, agent = CLAUDE_CODE_AGENT) => {
|
|
163
|
+
try {
|
|
164
|
+
const projectName = basename(input.cwd ?? process.cwd());
|
|
165
|
+
const titlesEnabled = process.env.PUSHARY_TASK_TITLES !== "off";
|
|
166
|
+
const taskTitle = titlesEnabled ? input.prompt?.replace(/\s+/g, " ").trim().slice(0, TASK_TITLE_MAX_LENGTH) || void 0 : void 0;
|
|
167
|
+
await reportEvent({
|
|
168
|
+
event: "user_prompt",
|
|
169
|
+
agentType: agent.type,
|
|
170
|
+
agentName: `${agent.label} - ${projectName}`,
|
|
171
|
+
sessionId: input.session_id,
|
|
172
|
+
taskTitle
|
|
173
|
+
}, { maxAttempts: 1, timeoutMs: 800 });
|
|
174
|
+
} catch {
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
var handleStop = async (input, agent = CLAUDE_CODE_AGENT) => {
|
|
178
|
+
try {
|
|
179
|
+
const projectName = basename(input.cwd ?? process.cwd());
|
|
180
|
+
await Promise.allSettled([
|
|
181
|
+
cleanupPendingQuestions(input.session_id || DEFAULT_SESSION),
|
|
182
|
+
reportEvent({
|
|
183
|
+
event: "session_end",
|
|
184
|
+
agentType: agent.type,
|
|
185
|
+
agentName: `${agent.label} - ${projectName}`,
|
|
186
|
+
action: "Session ended",
|
|
187
|
+
sessionId: input.session_id
|
|
188
|
+
})
|
|
189
|
+
]);
|
|
190
|
+
} catch {
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
var handleNotification = async (input) => {
|
|
194
|
+
try {
|
|
195
|
+
const projectName = basename(input.cwd ?? process.cwd());
|
|
196
|
+
await reportEvent({
|
|
197
|
+
event: input.type === "error" ? "error" : "notification",
|
|
198
|
+
agentType: "claude_code",
|
|
199
|
+
agentName: `Claude Code - ${projectName}`,
|
|
200
|
+
action: input.title ?? input.message ?? "Notification",
|
|
201
|
+
sessionId: input.session_id,
|
|
202
|
+
error: input.type === "error" ? input.message : void 0
|
|
203
|
+
});
|
|
204
|
+
} catch {
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
export {
|
|
209
|
+
CODEX_AGENT,
|
|
210
|
+
codexAllow,
|
|
211
|
+
codexDeny,
|
|
212
|
+
codexPass,
|
|
213
|
+
toCodexWire,
|
|
214
|
+
toPolicyLookup,
|
|
215
|
+
permissionTimeoutDecision,
|
|
216
|
+
preToolUseTimeoutDecision,
|
|
217
|
+
reportEvent,
|
|
218
|
+
handlePostToolUse,
|
|
219
|
+
handleUserPrompt,
|
|
220
|
+
handleStop,
|
|
221
|
+
handleNotification
|
|
222
|
+
};
|
package/dist/src/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
handlePreToolUse
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-5QHQVXWN.js";
|
|
4
4
|
import {
|
|
5
5
|
handleNotification,
|
|
6
6
|
handlePostToolUse,
|
|
7
7
|
handleStop,
|
|
8
8
|
reportEvent
|
|
9
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-YCL4GUFR.js";
|
|
10
10
|
import {
|
|
11
11
|
askUser,
|
|
12
12
|
cancelQuestion,
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
getPolicy,
|
|
16
16
|
resolvePolicy,
|
|
17
17
|
waitForAnswer
|
|
18
|
-
} from "../chunk-
|
|
18
|
+
} from "../chunk-QEPRH7JB.js";
|
|
19
19
|
import "../chunk-22CV7V7A.js";
|
|
20
20
|
import "../chunk-3MIR7ODJ.js";
|
|
21
21
|
import {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pushary/agent-hooks",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.3",
|
|
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",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"smol-toml": "^1.6.1"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@pushary/contracts": "
|
|
45
|
+
"@pushary/contracts": "0.1.0",
|
|
46
46
|
"tsup": "^8.0.0",
|
|
47
47
|
"typescript": "^5.0.0"
|
|
48
48
|
}
|