@pushary/agent-hooks 0.8.3 → 0.9.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.js +17 -10
- package/dist/bin/pushary-doctor.js +35 -2
- package/dist/bin/pushary-hook.js +3 -2
- package/dist/bin/pushary-post-hook.js +2 -2
- package/dist/bin/pushary-setup.js +37 -31
- package/dist/bin/pushary-stop-hook.js +2 -2
- package/dist/chunk-5GFUI5N6.js +132 -0
- package/dist/chunk-AB4KX4XT.js +109 -0
- package/dist/chunk-IBWCHA5M.js +10 -0
- package/dist/chunk-M2N5DYWN.js +247 -0
- package/dist/chunk-OF5WIOYS.js +129 -0
- package/dist/chunk-W5KRWUNE.js +262 -0
- package/dist/src/index.d.ts +13 -17
- package/dist/src/index.js +6 -3
- package/package.json +5 -4
|
@@ -1,23 +1,29 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
reportEvent
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-AB4KX4XT.js";
|
|
5
5
|
import {
|
|
6
6
|
askUser,
|
|
7
|
+
getMachineId,
|
|
7
8
|
waitForAnswer
|
|
8
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-OF5WIOYS.js";
|
|
9
10
|
import "../chunk-3MIR7ODJ.js";
|
|
10
11
|
import {
|
|
11
12
|
getApiKey
|
|
12
13
|
} from "../chunk-VUNL35KE.js";
|
|
13
14
|
|
|
14
15
|
// bin/pushary-codex.ts
|
|
15
|
-
import { hostname } from "os";
|
|
16
16
|
import { basename } from "path";
|
|
17
|
+
var readStdin = async () => {
|
|
18
|
+
let raw = "";
|
|
19
|
+
for await (const chunk of process.stdin) raw += chunk;
|
|
20
|
+
return raw;
|
|
21
|
+
};
|
|
17
22
|
var main = async () => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
23
|
+
const argvPayload = process.argv.slice(2).find((a) => a.trim().startsWith("{"));
|
|
24
|
+
let rawInput = argvPayload ?? "";
|
|
25
|
+
if (!rawInput.trim()) {
|
|
26
|
+
rawInput = await readStdin();
|
|
21
27
|
}
|
|
22
28
|
if (!rawInput.trim()) {
|
|
23
29
|
process.exit(0);
|
|
@@ -37,7 +43,7 @@ var main = async () => {
|
|
|
37
43
|
agentType: "codex",
|
|
38
44
|
agentName,
|
|
39
45
|
action: event.message ?? "Turn complete",
|
|
40
|
-
machineId:
|
|
46
|
+
machineId: getMachineId()
|
|
41
47
|
});
|
|
42
48
|
process.stdout.write(JSON.stringify({ acknowledged: true }));
|
|
43
49
|
}
|
|
@@ -49,13 +55,14 @@ var main = async () => {
|
|
|
49
55
|
agentType: "codex",
|
|
50
56
|
agentName,
|
|
51
57
|
action: description,
|
|
52
|
-
machineId:
|
|
58
|
+
machineId: getMachineId()
|
|
53
59
|
});
|
|
54
60
|
const result = await askUser(apiKey, {
|
|
55
61
|
question: `Allow: ${description}?`,
|
|
56
62
|
type: "confirm",
|
|
57
63
|
context: `Codex wants to run this in ${projectName}`,
|
|
58
|
-
agentName
|
|
64
|
+
agentName,
|
|
65
|
+
machineId: getMachineId()
|
|
59
66
|
});
|
|
60
67
|
const deadline = Date.now() + 12e4;
|
|
61
68
|
while (Date.now() < deadline) {
|
|
@@ -69,7 +76,7 @@ var main = async () => {
|
|
|
69
76
|
agentType: "codex",
|
|
70
77
|
agentName,
|
|
71
78
|
action: approved ? `Approved: ${description}` : `Denied: ${description}`,
|
|
72
|
-
machineId:
|
|
79
|
+
machineId: getMachineId()
|
|
73
80
|
});
|
|
74
81
|
process.exit(0);
|
|
75
82
|
}
|
|
@@ -9,6 +9,7 @@ import "../chunk-VUNL35KE.js";
|
|
|
9
9
|
import { existsSync, readFileSync } from "fs";
|
|
10
10
|
import { join } from "path";
|
|
11
11
|
import { homedir } from "os";
|
|
12
|
+
import { execSync } from "child_process";
|
|
12
13
|
import { confirm } from "@inquirer/prompts";
|
|
13
14
|
var dim = (s) => `\x1B[2m${s}\x1B[0m`;
|
|
14
15
|
var bold = (s) => `\x1B[1m${s}\x1B[0m`;
|
|
@@ -29,6 +30,28 @@ var readJson = (path) => {
|
|
|
29
30
|
return null;
|
|
30
31
|
}
|
|
31
32
|
};
|
|
33
|
+
var commandResolves = (command) => {
|
|
34
|
+
if (command.includes("/") || command.includes("\\")) return existsSync(command);
|
|
35
|
+
try {
|
|
36
|
+
const whichCmd = process.platform === "win32" ? "where" : "which";
|
|
37
|
+
execSync(`${whichCmd} ${command}`, { stdio: "ignore", timeout: 5e3 });
|
|
38
|
+
return true;
|
|
39
|
+
} catch {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
var extractHookCommand = (entries, needle) => {
|
|
44
|
+
if (!Array.isArray(entries)) return null;
|
|
45
|
+
for (const entry of entries) {
|
|
46
|
+
const hookList = entry.hooks;
|
|
47
|
+
if (!Array.isArray(hookList)) continue;
|
|
48
|
+
for (const candidate of hookList) {
|
|
49
|
+
const command = candidate.command;
|
|
50
|
+
if (typeof command === "string" && command.includes(needle)) return command;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return null;
|
|
54
|
+
};
|
|
32
55
|
var results = [];
|
|
33
56
|
var check = (passed, label, detail) => {
|
|
34
57
|
results.push({ passed, label, detail });
|
|
@@ -80,6 +103,11 @@ var main = async () => {
|
|
|
80
103
|
check(hasPreHook, "Claude Code: PreToolUse hook");
|
|
81
104
|
check(hasPostHook, "Claude Code: PostToolUse hook");
|
|
82
105
|
check(hasStopHook, "Claude Code: Stop hook");
|
|
106
|
+
const preHookCommand = extractHookCommand(hooks?.PreToolUse, "pushary-hook");
|
|
107
|
+
if (preHookCommand) {
|
|
108
|
+
const resolves = commandResolves(preHookCommand);
|
|
109
|
+
check(resolves, "Claude Code: hook command resolves", resolves ? preHookCommand : `not on PATH \u2014 ${preHookCommand}`);
|
|
110
|
+
}
|
|
83
111
|
const permissions = settings.permissions;
|
|
84
112
|
const hasWildcard = permissions?.allow?.some((r) => r === "mcp__pushary__*" || r === "MCP(pushary:*)") ?? false;
|
|
85
113
|
check(hasWildcard, "Claude Code: Pushary tools auto-allowed", hasWildcard ? "mcp__pushary__*" : "missing");
|
|
@@ -103,16 +131,21 @@ var main = async () => {
|
|
|
103
131
|
console.log(` ${warn} Codex: per-tool approval overrides detected ${dim("(redundant with default_tools_approval_mode)")}`);
|
|
104
132
|
}
|
|
105
133
|
}
|
|
106
|
-
|
|
134
|
+
const codexNotifyPath = codexConfig.match(/["']([^"']*pushary-codex[^"']*)["']/)?.[1] ?? null;
|
|
135
|
+
check(!!codexNotifyPath, "Codex: notify handler configured");
|
|
136
|
+
if (codexNotifyPath) {
|
|
137
|
+
const resolves = commandResolves(codexNotifyPath);
|
|
138
|
+
check(resolves, "Codex: notify handler resolves", resolves ? codexNotifyPath : `not found \u2014 ${codexNotifyPath}`);
|
|
139
|
+
}
|
|
107
140
|
const codexSkillPath = join(homedir(), ".codex", "skills", "pushary", "SKILL.md");
|
|
108
141
|
check(existsSync(codexSkillPath), "Codex: skill installed");
|
|
109
142
|
}
|
|
110
143
|
check(existsSync(SKILL_PATH), "Skill installed", existsSync(SKILL_PATH) ? SKILL_PATH : "not found");
|
|
111
144
|
let globalVersion = "";
|
|
112
145
|
try {
|
|
113
|
-
const { execSync } = await import("child_process");
|
|
114
146
|
globalVersion = execSync("npm list -g @pushary/agent-hooks --depth=0 2>/dev/null", { encoding: "utf-8", timeout: 1e4 }).match(/@pushary\/agent-hooks@([\d.]+)/)?.[1] ?? "";
|
|
115
147
|
} catch {
|
|
148
|
+
globalVersion = "";
|
|
116
149
|
}
|
|
117
150
|
check(!!globalVersion, "Global package installed", globalVersion || "not found");
|
|
118
151
|
console.log();
|
package/dist/bin/pushary-hook.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
handlePreToolUse
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-W5KRWUNE.js";
|
|
5
|
+
import "../chunk-IBWCHA5M.js";
|
|
6
|
+
import "../chunk-OF5WIOYS.js";
|
|
6
7
|
import "../chunk-3MIR7ODJ.js";
|
|
7
8
|
import "../chunk-VUNL35KE.js";
|
|
8
9
|
|
|
@@ -3,7 +3,10 @@ import {
|
|
|
3
3
|
addClaudeMcpServer,
|
|
4
4
|
addPusharyHooks,
|
|
5
5
|
addPusharyToolPermissions
|
|
6
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-5GFUI5N6.js";
|
|
7
|
+
import {
|
|
8
|
+
isValidApiKey
|
|
9
|
+
} from "../chunk-IBWCHA5M.js";
|
|
7
10
|
|
|
8
11
|
// bin/pushary-setup.ts
|
|
9
12
|
import { existsSync, readFileSync, writeFileSync, appendFileSync, mkdirSync } from "fs";
|
|
@@ -34,6 +37,15 @@ var parseKeyFlag = () => {
|
|
|
34
37
|
}
|
|
35
38
|
return void 0;
|
|
36
39
|
};
|
|
40
|
+
var isInstalled = (command) => {
|
|
41
|
+
const whichCmd = process.platform === "win32" ? "where" : "which";
|
|
42
|
+
try {
|
|
43
|
+
execSync(`${whichCmd} ${command}`, { stdio: "ignore", timeout: 5e3 });
|
|
44
|
+
return true;
|
|
45
|
+
} catch {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
37
49
|
var readJson = (path) => {
|
|
38
50
|
try {
|
|
39
51
|
return JSON.parse(readFileSync(path, "utf-8"));
|
|
@@ -151,7 +163,13 @@ var setupClaudeCode = async (apiKey) => {
|
|
|
151
163
|
});
|
|
152
164
|
await installGlobally();
|
|
153
165
|
await spinner("Adding hooks (PreToolUse, PostToolUse, Stop)", async () => {
|
|
154
|
-
|
|
166
|
+
let binDir;
|
|
167
|
+
try {
|
|
168
|
+
binDir = join(execSync("npm prefix -g", { encoding: "utf-8", timeout: 5e3 }).trim(), "bin");
|
|
169
|
+
} catch {
|
|
170
|
+
binDir = void 0;
|
|
171
|
+
}
|
|
172
|
+
addPusharyHooks(settings, binDir);
|
|
155
173
|
});
|
|
156
174
|
await spinner(`Writing ${CLAUDE_SETTINGS}`, async () => {
|
|
157
175
|
writeJson(CLAUDE_SETTINGS, settings);
|
|
@@ -185,16 +203,7 @@ var setupHermes = async (_apiKey) => {
|
|
|
185
203
|
console.log(`
|
|
186
204
|
${bold("Setting up Hermes Agent")}
|
|
187
205
|
`);
|
|
188
|
-
|
|
189
|
-
const hasHermes = (() => {
|
|
190
|
-
try {
|
|
191
|
-
execSync(`${whichCmd} hermes`, { stdio: "ignore", timeout: 5e3 });
|
|
192
|
-
return true;
|
|
193
|
-
} catch {
|
|
194
|
-
return false;
|
|
195
|
-
}
|
|
196
|
-
})();
|
|
197
|
-
if (!hasHermes) {
|
|
206
|
+
if (!isInstalled("hermes")) {
|
|
198
207
|
console.log(` ${yellow("!")} Hermes CLI not found. Skipping.`);
|
|
199
208
|
console.log(` ${dim("Install Hermes and re-run setup to configure.")}`);
|
|
200
209
|
return;
|
|
@@ -256,16 +265,7 @@ var setupCodex = async (_apiKey) => {
|
|
|
256
265
|
console.log(`
|
|
257
266
|
${bold("Setting up Codex")}
|
|
258
267
|
`);
|
|
259
|
-
|
|
260
|
-
const hasCodex = (() => {
|
|
261
|
-
try {
|
|
262
|
-
execSync(`${whichCmd} codex`, { stdio: "ignore", timeout: 5e3 });
|
|
263
|
-
return true;
|
|
264
|
-
} catch {
|
|
265
|
-
return false;
|
|
266
|
-
}
|
|
267
|
-
})();
|
|
268
|
-
if (!hasCodex) {
|
|
268
|
+
if (!isInstalled("codex")) {
|
|
269
269
|
console.log(` ${yellow("!")} Codex CLI not found. Skipping.`);
|
|
270
270
|
console.log(` ${dim("Install Codex and re-run setup to configure.")}`);
|
|
271
271
|
return;
|
|
@@ -402,16 +402,15 @@ var main = async () => {
|
|
|
402
402
|
console.log(` ${dim("Push notifications for AI coding agents")}`);
|
|
403
403
|
console.log();
|
|
404
404
|
await checkForUpdates(version);
|
|
405
|
-
const keyPattern = /^pk_[a-f0-9]+\.[a-f0-9]+$/;
|
|
406
405
|
const flagKey = parseKeyFlag();
|
|
407
406
|
const envKey = process.env.PUSHARY_API_KEY?.trim();
|
|
408
407
|
let trimmedKey;
|
|
409
|
-
if (flagKey &&
|
|
408
|
+
if (flagKey && isValidApiKey(flagKey)) {
|
|
410
409
|
const masked = `${flagKey.slice(0, 8)}...${flagKey.slice(-4)}`;
|
|
411
410
|
console.log(` ${check} Using API key: ${dim(masked)}`);
|
|
412
411
|
console.log();
|
|
413
412
|
trimmedKey = flagKey;
|
|
414
|
-
} else if (envKey &&
|
|
413
|
+
} else if (envKey && isValidApiKey(envKey)) {
|
|
415
414
|
const masked = `${envKey.slice(0, 8)}...${envKey.slice(-4)}`;
|
|
416
415
|
console.log(` ${check} Found API key in environment: ${dim(masked)}`);
|
|
417
416
|
console.log();
|
|
@@ -429,7 +428,7 @@ var main = async () => {
|
|
|
429
428
|
const apiKey = await input({ message: "API key:" });
|
|
430
429
|
trimmedKey = apiKey.trim();
|
|
431
430
|
}
|
|
432
|
-
if (!trimmedKey || !
|
|
431
|
+
if (!trimmedKey || !isValidApiKey(trimmedKey)) {
|
|
433
432
|
console.log(`
|
|
434
433
|
${yellow("!")} Invalid key format. Expected: ${dim("pk_xxx.xxx")}`);
|
|
435
434
|
console.log(` ${dim("Copy your key from")} ${cyan("https://pushary.com/dashboard/agent/settings")}`);
|
|
@@ -437,13 +436,20 @@ var main = async () => {
|
|
|
437
436
|
`);
|
|
438
437
|
process.exit(1);
|
|
439
438
|
}
|
|
439
|
+
const detected = {
|
|
440
|
+
claude_code: isInstalled("claude"),
|
|
441
|
+
codex: isInstalled("codex"),
|
|
442
|
+
hermes: isInstalled("hermes"),
|
|
443
|
+
cursor: isInstalled("cursor")
|
|
444
|
+
};
|
|
445
|
+
const hint = Object.values(detected).some(Boolean) ? "(detected agents pre-selected)" : "(space = toggle, enter = confirm)";
|
|
440
446
|
const agents = await checkbox({
|
|
441
|
-
message: "Which agents do you use? " + dim(
|
|
447
|
+
message: "Which agents do you use? " + dim(hint),
|
|
442
448
|
choices: [
|
|
443
|
-
{ name: `Claude Code ${dim("MCP + hooks + auto-allowed tools")}`, value: "claude_code" },
|
|
444
|
-
{ name: `Codex ${dim("MCP + notify handler + auto-allowed tools")}`, value: "codex" },
|
|
445
|
-
{ name: `Hermes ${dim("native plugin + auto-error notifications")}`, value: "hermes" },
|
|
446
|
-
{ name: `Cursor ${dim("MCP server")}`, value: "cursor" }
|
|
449
|
+
{ name: `Claude Code ${dim("MCP + hooks + auto-allowed tools")}`, value: "claude_code", checked: detected.claude_code },
|
|
450
|
+
{ name: `Codex ${dim("MCP + notify handler + auto-allowed tools")}`, value: "codex", checked: detected.codex },
|
|
451
|
+
{ name: `Hermes ${dim("native plugin + auto-error notifications")}`, value: "hermes", checked: detected.hermes },
|
|
452
|
+
{ name: `Cursor ${dim("MCP server")}`, value: "cursor", checked: detected.cursor }
|
|
447
453
|
]
|
|
448
454
|
});
|
|
449
455
|
await saveApiKey(trimmedKey);
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// src/claude-config.ts
|
|
2
|
+
import { join } from "path";
|
|
3
|
+
var PUSHARY_MCP_URL = "https://pushary.com/api/mcp/mcp";
|
|
4
|
+
var PUSHARY_PERMISSION_RULE = "mcp__pushary__*";
|
|
5
|
+
var asRecord = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
6
|
+
var ensureRecord = (target, key) => {
|
|
7
|
+
const existing = asRecord(target[key]);
|
|
8
|
+
if (existing) return existing;
|
|
9
|
+
const created = {};
|
|
10
|
+
target[key] = created;
|
|
11
|
+
return created;
|
|
12
|
+
};
|
|
13
|
+
var isPusharyPermission = (rule) => typeof rule === "string" && (rule.includes("pushary") || rule.includes("MCP(pushary"));
|
|
14
|
+
var isPusharyHook = (entry) => {
|
|
15
|
+
const hooks = asRecord(entry)?.hooks;
|
|
16
|
+
if (!Array.isArray(hooks)) return false;
|
|
17
|
+
return hooks.some((hook) => {
|
|
18
|
+
const command = String(asRecord(hook)?.command ?? "");
|
|
19
|
+
return command.includes("pushary-hook") || command.includes("pushary-post-hook") || command.includes("pushary-stop-hook");
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var addClaudeMcpServer = (config, apiKey) => {
|
|
23
|
+
const mcpServers = ensureRecord(config, "mcpServers");
|
|
24
|
+
mcpServers.pushary = {
|
|
25
|
+
type: "http",
|
|
26
|
+
url: PUSHARY_MCP_URL,
|
|
27
|
+
headers: { Authorization: `Bearer ${apiKey}` }
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
var removeClaudeMcpServers = (config) => {
|
|
31
|
+
let changed = false;
|
|
32
|
+
const removeFrom = (target) => {
|
|
33
|
+
const mcpServers = asRecord(target.mcpServers);
|
|
34
|
+
if (!mcpServers?.pushary) return;
|
|
35
|
+
delete mcpServers.pushary;
|
|
36
|
+
if (Object.keys(mcpServers).length === 0) delete target.mcpServers;
|
|
37
|
+
changed = true;
|
|
38
|
+
};
|
|
39
|
+
removeFrom(config);
|
|
40
|
+
const projects = asRecord(config.projects);
|
|
41
|
+
if (projects) {
|
|
42
|
+
for (const project of Object.values(projects)) {
|
|
43
|
+
const projectConfig = asRecord(project);
|
|
44
|
+
if (projectConfig) removeFrom(projectConfig);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return changed;
|
|
48
|
+
};
|
|
49
|
+
var addPusharyToolPermissions = (settings) => {
|
|
50
|
+
const permissions = ensureRecord(settings, "permissions");
|
|
51
|
+
const allow = Array.isArray(permissions.allow) ? permissions.allow : [];
|
|
52
|
+
const filtered = allow.filter((rule) => !isPusharyPermission(rule));
|
|
53
|
+
if (!filtered.includes(PUSHARY_PERMISSION_RULE)) {
|
|
54
|
+
filtered.push(PUSHARY_PERMISSION_RULE);
|
|
55
|
+
}
|
|
56
|
+
permissions.allow = filtered;
|
|
57
|
+
};
|
|
58
|
+
var addPusharyHooks = (settings, binDir) => {
|
|
59
|
+
const resolve = (name) => binDir ? join(binDir, name) : name;
|
|
60
|
+
const hooks = ensureRecord(settings, "hooks");
|
|
61
|
+
const preToolUse = (Array.isArray(hooks.PreToolUse) ? hooks.PreToolUse : []).filter((entry) => !isPusharyHook(entry));
|
|
62
|
+
preToolUse.push({
|
|
63
|
+
matcher: "Bash|Write|Edit",
|
|
64
|
+
hooks: [{
|
|
65
|
+
type: "command",
|
|
66
|
+
command: resolve("pushary-hook"),
|
|
67
|
+
timeout: 120
|
|
68
|
+
}]
|
|
69
|
+
});
|
|
70
|
+
hooks.PreToolUse = preToolUse;
|
|
71
|
+
const postToolUse = (Array.isArray(hooks.PostToolUse) ? hooks.PostToolUse : []).filter((entry) => !isPusharyHook(entry));
|
|
72
|
+
postToolUse.push({
|
|
73
|
+
matcher: "Bash|Write|Edit",
|
|
74
|
+
hooks: [{
|
|
75
|
+
type: "command",
|
|
76
|
+
command: resolve("pushary-post-hook"),
|
|
77
|
+
timeout: 10
|
|
78
|
+
}]
|
|
79
|
+
});
|
|
80
|
+
hooks.PostToolUse = postToolUse;
|
|
81
|
+
const stop = (Array.isArray(hooks.Stop) ? hooks.Stop : []).filter((entry) => !isPusharyHook(entry));
|
|
82
|
+
stop.push({
|
|
83
|
+
hooks: [{
|
|
84
|
+
type: "command",
|
|
85
|
+
command: resolve("pushary-stop-hook"),
|
|
86
|
+
timeout: 10
|
|
87
|
+
}]
|
|
88
|
+
});
|
|
89
|
+
hooks.Stop = stop;
|
|
90
|
+
};
|
|
91
|
+
var removePusharySettings = (settings) => {
|
|
92
|
+
let changed = removeClaudeMcpServers(settings);
|
|
93
|
+
const permissions = asRecord(settings.permissions);
|
|
94
|
+
if (permissions && Array.isArray(permissions.allow)) {
|
|
95
|
+
const filtered = permissions.allow.filter((rule) => !isPusharyPermission(rule));
|
|
96
|
+
if (filtered.length !== permissions.allow.length) {
|
|
97
|
+
if (filtered.length === 0) {
|
|
98
|
+
delete permissions.allow;
|
|
99
|
+
} else {
|
|
100
|
+
permissions.allow = filtered;
|
|
101
|
+
}
|
|
102
|
+
if (Object.keys(permissions).length === 0) delete settings.permissions;
|
|
103
|
+
changed = true;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
const hooks = asRecord(settings.hooks);
|
|
107
|
+
if (hooks) {
|
|
108
|
+
for (const key of ["PreToolUse", "PostToolUse", "Stop"]) {
|
|
109
|
+
const entries = hooks[key];
|
|
110
|
+
if (!Array.isArray(entries)) continue;
|
|
111
|
+
const filtered = entries.filter((entry) => !isPusharyHook(entry));
|
|
112
|
+
if (filtered.length !== entries.length) {
|
|
113
|
+
if (filtered.length === 0) {
|
|
114
|
+
delete hooks[key];
|
|
115
|
+
} else {
|
|
116
|
+
hooks[key] = filtered;
|
|
117
|
+
}
|
|
118
|
+
changed = true;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (Object.keys(hooks).length === 0) delete settings.hooks;
|
|
122
|
+
}
|
|
123
|
+
return changed;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
export {
|
|
127
|
+
addClaudeMcpServer,
|
|
128
|
+
removeClaudeMcpServers,
|
|
129
|
+
addPusharyToolPermissions,
|
|
130
|
+
addPusharyHooks,
|
|
131
|
+
removePusharySettings
|
|
132
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_SESSION,
|
|
3
|
+
cancelQuestion,
|
|
4
|
+
describeToolCall,
|
|
5
|
+
getMachineId,
|
|
6
|
+
isDefaultSession,
|
|
7
|
+
listPendingQuestions,
|
|
8
|
+
removePendingQuestion,
|
|
9
|
+
removePendingSession
|
|
10
|
+
} from "./chunk-OF5WIOYS.js";
|
|
11
|
+
import {
|
|
12
|
+
withRetry
|
|
13
|
+
} from "./chunk-3MIR7ODJ.js";
|
|
14
|
+
import {
|
|
15
|
+
getApiKey,
|
|
16
|
+
getBaseUrl
|
|
17
|
+
} from "./chunk-VUNL35KE.js";
|
|
18
|
+
|
|
19
|
+
// src/events.ts
|
|
20
|
+
import { basename } from "path";
|
|
21
|
+
var cleanupPendingQuestions = async (sessionId) => {
|
|
22
|
+
try {
|
|
23
|
+
const files = listPendingQuestions(sessionId);
|
|
24
|
+
const apiKey = getApiKey();
|
|
25
|
+
for (const correlationId of files) {
|
|
26
|
+
try {
|
|
27
|
+
await cancelQuestion(apiKey, correlationId);
|
|
28
|
+
} catch {
|
|
29
|
+
}
|
|
30
|
+
removePendingQuestion(sessionId, correlationId);
|
|
31
|
+
}
|
|
32
|
+
if (!isDefaultSession(sessionId)) removePendingSession(sessionId);
|
|
33
|
+
} catch {
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
var reportEvent = async (event) => {
|
|
37
|
+
const apiKey = getApiKey();
|
|
38
|
+
const baseUrl = getBaseUrl();
|
|
39
|
+
await withRetry(async () => {
|
|
40
|
+
await fetch(`${baseUrl}/api/agent/event`, {
|
|
41
|
+
method: "POST",
|
|
42
|
+
headers: {
|
|
43
|
+
"Content-Type": "application/json",
|
|
44
|
+
"Authorization": `Bearer ${apiKey}`
|
|
45
|
+
},
|
|
46
|
+
body: JSON.stringify({
|
|
47
|
+
...event,
|
|
48
|
+
machineId: event.machineId ?? getMachineId()
|
|
49
|
+
}),
|
|
50
|
+
signal: AbortSignal.timeout(1e4)
|
|
51
|
+
});
|
|
52
|
+
}, { maxAttempts: 2, baseDelayMs: 300 });
|
|
53
|
+
};
|
|
54
|
+
var handlePostToolUse = async (input) => {
|
|
55
|
+
try {
|
|
56
|
+
const projectName = basename(input.cwd ?? process.cwd());
|
|
57
|
+
const action = describeToolCall(input.tool_name, input.tool_input, "event");
|
|
58
|
+
const isError = input.tool_result && ("error" in input.tool_result || "is_error" in input.tool_result);
|
|
59
|
+
await Promise.allSettled([
|
|
60
|
+
cleanupPendingQuestions(input.session_id || DEFAULT_SESSION),
|
|
61
|
+
reportEvent({
|
|
62
|
+
event: isError ? "tool_error" : "tool_complete",
|
|
63
|
+
agentType: "claude_code",
|
|
64
|
+
agentName: `Claude Code - ${projectName}`,
|
|
65
|
+
action,
|
|
66
|
+
sessionId: input.session_id,
|
|
67
|
+
error: isError ? String(input.tool_result?.error ?? input.tool_result?.stderr ?? "").slice(0, 500) : void 0
|
|
68
|
+
})
|
|
69
|
+
]);
|
|
70
|
+
} catch {
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
var handleStop = async (input) => {
|
|
74
|
+
try {
|
|
75
|
+
const projectName = basename(input.cwd ?? process.cwd());
|
|
76
|
+
await Promise.allSettled([
|
|
77
|
+
cleanupPendingQuestions(input.session_id || DEFAULT_SESSION),
|
|
78
|
+
reportEvent({
|
|
79
|
+
event: "session_end",
|
|
80
|
+
agentType: "claude_code",
|
|
81
|
+
agentName: `Claude Code - ${projectName}`,
|
|
82
|
+
action: "Session ended",
|
|
83
|
+
sessionId: input.session_id
|
|
84
|
+
})
|
|
85
|
+
]);
|
|
86
|
+
} catch {
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
var handleNotification = async (input) => {
|
|
90
|
+
try {
|
|
91
|
+
const projectName = basename(input.cwd ?? process.cwd());
|
|
92
|
+
await reportEvent({
|
|
93
|
+
event: input.type === "error" ? "error" : "notification",
|
|
94
|
+
agentType: "claude_code",
|
|
95
|
+
agentName: `Claude Code - ${projectName}`,
|
|
96
|
+
action: input.title ?? input.message ?? "Notification",
|
|
97
|
+
sessionId: input.session_id,
|
|
98
|
+
error: input.type === "error" ? input.message : void 0
|
|
99
|
+
});
|
|
100
|
+
} catch {
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export {
|
|
105
|
+
reportEvent,
|
|
106
|
+
handlePostToolUse,
|
|
107
|
+
handleStop,
|
|
108
|
+
handleNotification
|
|
109
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// ../contracts/src/index.ts
|
|
2
|
+
var APPROVAL_MODES = ["push_only", "terminal_only", "push_first", "notify_only"];
|
|
3
|
+
var isApprovalMode = (value) => typeof value === "string" && APPROVAL_MODES.includes(value);
|
|
4
|
+
var API_KEY_PATTERN = /^pk_[a-f0-9]+\.[a-f0-9]+$/;
|
|
5
|
+
var isValidApiKey = (value) => API_KEY_PATTERN.test(value);
|
|
6
|
+
|
|
7
|
+
export {
|
|
8
|
+
isApprovalMode,
|
|
9
|
+
isValidApiKey
|
|
10
|
+
};
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isApprovalMode
|
|
3
|
+
} from "./chunk-IBWCHA5M.js";
|
|
4
|
+
import {
|
|
5
|
+
askUser,
|
|
6
|
+
describeToolCall,
|
|
7
|
+
isPolicyConfig,
|
|
8
|
+
savePendingQuestion,
|
|
9
|
+
sendNotification,
|
|
10
|
+
waitForAnswer
|
|
11
|
+
} from "./chunk-7PTU7TGE.js";
|
|
12
|
+
import {
|
|
13
|
+
withRetry
|
|
14
|
+
} from "./chunk-3MIR7ODJ.js";
|
|
15
|
+
import {
|
|
16
|
+
getApiKey,
|
|
17
|
+
getBaseUrl
|
|
18
|
+
} from "./chunk-VUNL35KE.js";
|
|
19
|
+
|
|
20
|
+
// src/policy.ts
|
|
21
|
+
import { createHash } from "crypto";
|
|
22
|
+
import { existsSync, readFileSync, writeFileSync } from "fs";
|
|
23
|
+
import { join } from "path";
|
|
24
|
+
import { tmpdir } from "os";
|
|
25
|
+
var CACHE_TTL_MS = 5 * 60 * 1e3;
|
|
26
|
+
var cacheFile = (apiKey) => {
|
|
27
|
+
const hash = createHash("sha256").update(apiKey).digest("hex").slice(0, 12);
|
|
28
|
+
return join(tmpdir(), `pushary-policy-${hash}.json`);
|
|
29
|
+
};
|
|
30
|
+
var fetchPolicy = async (apiKey) => {
|
|
31
|
+
return withRetry(async () => {
|
|
32
|
+
const baseUrl = getBaseUrl();
|
|
33
|
+
const response = await fetch(`${baseUrl}/api/mcp/policy`, {
|
|
34
|
+
headers: { "Authorization": `Bearer ${apiKey}` },
|
|
35
|
+
signal: AbortSignal.timeout(1e4)
|
|
36
|
+
});
|
|
37
|
+
if (!response.ok) {
|
|
38
|
+
throw new Error(`Failed to fetch policy: ${response.status}`);
|
|
39
|
+
}
|
|
40
|
+
const raw = await response.json();
|
|
41
|
+
if (!isPolicyConfig(raw)) throw new Error("Invalid policy response");
|
|
42
|
+
return raw;
|
|
43
|
+
}, { maxAttempts: 2 });
|
|
44
|
+
};
|
|
45
|
+
var getPolicy = async (apiKey) => {
|
|
46
|
+
const path = cacheFile(apiKey);
|
|
47
|
+
let staleCache = null;
|
|
48
|
+
if (existsSync(path)) {
|
|
49
|
+
try {
|
|
50
|
+
const stat = readFileSync(path, "utf-8");
|
|
51
|
+
const cached = JSON.parse(stat);
|
|
52
|
+
if (!isPolicyConfig(cached)) throw new Error("Corrupted cache");
|
|
53
|
+
if (!cached._cachedAt || Date.now() - cached._cachedAt < CACHE_TTL_MS) {
|
|
54
|
+
return cached;
|
|
55
|
+
}
|
|
56
|
+
staleCache = cached;
|
|
57
|
+
} catch {
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
const policy = await fetchPolicy(apiKey);
|
|
62
|
+
try {
|
|
63
|
+
writeFileSync(path, JSON.stringify({ ...policy, _cachedAt: Date.now() }), "utf-8");
|
|
64
|
+
} catch {
|
|
65
|
+
}
|
|
66
|
+
return policy;
|
|
67
|
+
} catch {
|
|
68
|
+
if (staleCache) return staleCache;
|
|
69
|
+
throw new Error("Failed to fetch policy and no cached policy available");
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
var resolvePolicy = (config, toolName, modeOverride) => {
|
|
73
|
+
const base = config.policies.find((p) => p.tool === toolName) ?? config.policies.find((p) => p.tool === "*") ?? {
|
|
74
|
+
tool: toolName,
|
|
75
|
+
timeoutSeconds: config.defaultTimeoutSeconds,
|
|
76
|
+
timeoutAction: config.defaultTimeoutAction,
|
|
77
|
+
mode: config.defaultMode ?? "push_first",
|
|
78
|
+
pushFirstSeconds: config.defaultPushFirstSeconds ?? 20
|
|
79
|
+
};
|
|
80
|
+
const effectiveOverride = modeOverride ?? config.modeOverride;
|
|
81
|
+
if (effectiveOverride) {
|
|
82
|
+
return { ...base, mode: effectiveOverride };
|
|
83
|
+
}
|
|
84
|
+
return base;
|
|
85
|
+
};
|
|
86
|
+
var fetchModeOverride = async (apiKey) => {
|
|
87
|
+
try {
|
|
88
|
+
const baseUrl = getBaseUrl();
|
|
89
|
+
const response = await fetch(`${baseUrl}/api/mcp/mode`, {
|
|
90
|
+
headers: { "Authorization": `Bearer ${apiKey}` },
|
|
91
|
+
signal: AbortSignal.timeout(3e3)
|
|
92
|
+
});
|
|
93
|
+
if (!response.ok) return null;
|
|
94
|
+
const data = await response.json();
|
|
95
|
+
const mode = data.override?.mode;
|
|
96
|
+
if (isApprovalMode(mode)) {
|
|
97
|
+
return mode;
|
|
98
|
+
}
|
|
99
|
+
return null;
|
|
100
|
+
} catch {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
// src/hook.ts
|
|
106
|
+
import { basename } from "path";
|
|
107
|
+
var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
108
|
+
var allow = () => ({
|
|
109
|
+
hookSpecificOutput: {
|
|
110
|
+
hookEventName: "PreToolUse",
|
|
111
|
+
permissionDecision: "allow"
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
var deny = (reason) => ({
|
|
115
|
+
hookSpecificOutput: {
|
|
116
|
+
hookEventName: "PreToolUse",
|
|
117
|
+
permissionDecision: "deny",
|
|
118
|
+
permissionDecisionReason: reason
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
var ask = (reason) => ({
|
|
122
|
+
hookSpecificOutput: {
|
|
123
|
+
hookEventName: "PreToolUse",
|
|
124
|
+
permissionDecision: "ask",
|
|
125
|
+
...reason ? { permissionDecisionReason: reason } : {}
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
var pollForAnswer = async (apiKey, correlationId, deadlineMs, pollInterval = 2e3) => {
|
|
129
|
+
while (Date.now() < deadlineMs) {
|
|
130
|
+
const remaining = Math.min(Math.max(deadlineMs - Date.now(), 1e3), 3e4);
|
|
131
|
+
let answer;
|
|
132
|
+
try {
|
|
133
|
+
answer = await waitForAnswer(apiKey, correlationId, remaining);
|
|
134
|
+
} catch {
|
|
135
|
+
if (Date.now() + pollInterval >= deadlineMs) break;
|
|
136
|
+
await sleep(pollInterval);
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
if (answer.answered) return answer;
|
|
140
|
+
if (Date.now() + pollInterval >= deadlineMs) break;
|
|
141
|
+
await sleep(pollInterval);
|
|
142
|
+
}
|
|
143
|
+
return { answered: false };
|
|
144
|
+
};
|
|
145
|
+
var handlePushOnly = async (apiKey, description, projectName, timeoutSeconds, timeoutAction) => {
|
|
146
|
+
let result;
|
|
147
|
+
try {
|
|
148
|
+
result = await askUser(apiKey, {
|
|
149
|
+
question: `Allow ${description}?`,
|
|
150
|
+
type: "confirm",
|
|
151
|
+
context: `Agent wants to run this in ${projectName}`,
|
|
152
|
+
agentName: `Claude Code - ${projectName}`
|
|
153
|
+
});
|
|
154
|
+
} catch {
|
|
155
|
+
switch (timeoutAction) {
|
|
156
|
+
case "approve":
|
|
157
|
+
return allow();
|
|
158
|
+
case "deny":
|
|
159
|
+
return deny("Push notification failed, denying per policy");
|
|
160
|
+
default:
|
|
161
|
+
return ask("Push notification failed, asking in terminal");
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
const deadline = Date.now() + timeoutSeconds * 1e3;
|
|
165
|
+
const answer = await pollForAnswer(apiKey, result.correlationId, deadline);
|
|
166
|
+
if (answer.answered) {
|
|
167
|
+
return answer.value === "yes" ? allow() : deny("Denied via push notification");
|
|
168
|
+
}
|
|
169
|
+
switch (timeoutAction) {
|
|
170
|
+
case "approve":
|
|
171
|
+
return allow();
|
|
172
|
+
case "deny":
|
|
173
|
+
return deny("No response within timeout");
|
|
174
|
+
default:
|
|
175
|
+
return ask("No push response, asking in terminal");
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
var handleTerminalOnly = () => {
|
|
179
|
+
return ask();
|
|
180
|
+
};
|
|
181
|
+
var handlePushFirst = async (apiKey, description, projectName, pushFirstSeconds) => {
|
|
182
|
+
let result;
|
|
183
|
+
try {
|
|
184
|
+
result = await askUser(apiKey, {
|
|
185
|
+
question: `Allow ${description}?`,
|
|
186
|
+
type: "confirm",
|
|
187
|
+
context: `Agent wants to run this in ${projectName}`,
|
|
188
|
+
agentName: `Claude Code - ${projectName}`
|
|
189
|
+
});
|
|
190
|
+
} catch {
|
|
191
|
+
return ask("Push notification failed, asking in terminal");
|
|
192
|
+
}
|
|
193
|
+
const deadline = Date.now() + pushFirstSeconds * 1e3;
|
|
194
|
+
const answer = await pollForAnswer(apiKey, result.correlationId, deadline, 1500);
|
|
195
|
+
if (answer.answered) {
|
|
196
|
+
return answer.value === "yes" ? allow() : deny("Denied via push notification");
|
|
197
|
+
}
|
|
198
|
+
savePendingQuestion(result.correlationId);
|
|
199
|
+
return ask("Sent as push notification. You can also approve here.");
|
|
200
|
+
};
|
|
201
|
+
var handleNotifyOnly = async (apiKey, description, projectName) => {
|
|
202
|
+
try {
|
|
203
|
+
await sendNotification(apiKey, {
|
|
204
|
+
title: "Agent needs approval",
|
|
205
|
+
body: description,
|
|
206
|
+
agentName: `Claude Code - ${projectName}`
|
|
207
|
+
});
|
|
208
|
+
} catch {
|
|
209
|
+
}
|
|
210
|
+
return ask();
|
|
211
|
+
};
|
|
212
|
+
var handlePreToolUse = async (input) => {
|
|
213
|
+
try {
|
|
214
|
+
const apiKey = getApiKey();
|
|
215
|
+
const [policy, modeOverride] = await Promise.all([
|
|
216
|
+
getPolicy(apiKey),
|
|
217
|
+
fetchModeOverride(apiKey)
|
|
218
|
+
]);
|
|
219
|
+
const toolPolicy = resolvePolicy(policy, input.tool_name, modeOverride);
|
|
220
|
+
if (toolPolicy.timeoutSeconds === 0 && toolPolicy.timeoutAction === "approve") {
|
|
221
|
+
return allow();
|
|
222
|
+
}
|
|
223
|
+
const description = describeToolCall(input.tool_name, input.tool_input, "hook");
|
|
224
|
+
const projectName = basename(input.cwd ?? process.cwd());
|
|
225
|
+
switch (toolPolicy.mode) {
|
|
226
|
+
case "push_only":
|
|
227
|
+
return handlePushOnly(apiKey, description, projectName, toolPolicy.timeoutSeconds, toolPolicy.timeoutAction);
|
|
228
|
+
case "terminal_only":
|
|
229
|
+
return handleTerminalOnly();
|
|
230
|
+
case "push_first":
|
|
231
|
+
return handlePushFirst(apiKey, description, projectName, toolPolicy.pushFirstSeconds);
|
|
232
|
+
case "notify_only":
|
|
233
|
+
return handleNotifyOnly(apiKey, description, projectName);
|
|
234
|
+
default:
|
|
235
|
+
return handlePushFirst(apiKey, description, projectName, toolPolicy.pushFirstSeconds);
|
|
236
|
+
}
|
|
237
|
+
} catch {
|
|
238
|
+
return ask("Pushary unavailable, falling back to terminal approval");
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
export {
|
|
243
|
+
getPolicy,
|
|
244
|
+
resolvePolicy,
|
|
245
|
+
fetchModeOverride,
|
|
246
|
+
handlePreToolUse
|
|
247
|
+
};
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import {
|
|
2
|
+
callMcpTool
|
|
3
|
+
} from "./chunk-3MIR7ODJ.js";
|
|
4
|
+
|
|
5
|
+
// src/validate.ts
|
|
6
|
+
var isPolicyConfig = (data) => {
|
|
7
|
+
if (!data || typeof data !== "object") return false;
|
|
8
|
+
const d = data;
|
|
9
|
+
return Array.isArray(d.policies) && typeof d.defaultTimeoutSeconds === "number" && typeof d.defaultTimeoutAction === "string";
|
|
10
|
+
};
|
|
11
|
+
var isAskUserResponse = (data) => {
|
|
12
|
+
if (!data || typeof data !== "object") return false;
|
|
13
|
+
const d = data;
|
|
14
|
+
return typeof d.correlationId === "string" && typeof d.status === "string";
|
|
15
|
+
};
|
|
16
|
+
var isWaitForAnswerResponse = (data) => {
|
|
17
|
+
if (!data || typeof data !== "object") return false;
|
|
18
|
+
const d = data;
|
|
19
|
+
return typeof d.answered === "boolean";
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// src/api.ts
|
|
23
|
+
var askUser = async (apiKey, params) => {
|
|
24
|
+
const result = await callMcpTool(apiKey, "ask_user", { ...params, wait: false }, { maxRetries: 3 });
|
|
25
|
+
if (!isAskUserResponse(result)) throw new Error("Invalid ask_user response");
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
var waitForAnswer = async (apiKey, correlationId, timeoutMs = 3e4) => {
|
|
29
|
+
const result = await callMcpTool(apiKey, "wait_for_answer", {
|
|
30
|
+
correlationId,
|
|
31
|
+
timeoutMs
|
|
32
|
+
});
|
|
33
|
+
if (!isWaitForAnswerResponse(result)) throw new Error("Invalid wait_for_answer response");
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
var cancelQuestion = async (apiKey, correlationId) => {
|
|
37
|
+
await callMcpTool(apiKey, "cancel_question", { correlationId });
|
|
38
|
+
};
|
|
39
|
+
var sendNotification = async (apiKey, params) => {
|
|
40
|
+
await callMcpTool(apiKey, "send_notification", { ...params }, { maxRetries: 3 });
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// src/identity.ts
|
|
44
|
+
import { createHash } from "crypto";
|
|
45
|
+
import { hostname } from "os";
|
|
46
|
+
var deriveMachineId = (host) => createHash("sha256").update(host).digest("hex").slice(0, 8);
|
|
47
|
+
var getMachineId = () => deriveMachineId(hostname());
|
|
48
|
+
|
|
49
|
+
// src/describe.ts
|
|
50
|
+
var hookPrefixes = {
|
|
51
|
+
Bash: (input) => `bash: ${input.command ?? "(no command)"}`,
|
|
52
|
+
Write: (input) => `write file: ${input.file_path ?? "(unknown path)"}`,
|
|
53
|
+
Edit: (input) => `edit file: ${input.file_path ?? "(unknown path)"}`,
|
|
54
|
+
Read: (input) => `read file: ${input.file_path ?? "(unknown path)"}`
|
|
55
|
+
};
|
|
56
|
+
var eventPrefixes = {
|
|
57
|
+
Bash: (input) => `ran: ${String(input.command ?? "").slice(0, 120)}`,
|
|
58
|
+
Write: (input) => `wrote: ${input.file_path ?? "unknown"}`,
|
|
59
|
+
Edit: (input) => `edited: ${input.file_path ?? "unknown"}`,
|
|
60
|
+
Read: (input) => `read: ${input.file_path ?? "unknown"}`
|
|
61
|
+
};
|
|
62
|
+
var describeToolCall = (toolName, toolInput, format = "hook") => {
|
|
63
|
+
const prefixes = format === "hook" ? hookPrefixes : eventPrefixes;
|
|
64
|
+
const builder = prefixes[toolName];
|
|
65
|
+
if (builder) return builder(toolInput);
|
|
66
|
+
return format === "hook" ? `${toolName}: ${JSON.stringify(toolInput).slice(0, 200)}` : `${toolName}: done`;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
// src/pending.ts
|
|
70
|
+
import { join } from "path";
|
|
71
|
+
import { tmpdir } from "os";
|
|
72
|
+
import { existsSync, mkdirSync, writeFileSync, readdirSync, unlinkSync, rmSync, statSync } from "fs";
|
|
73
|
+
var PENDING_DIR = join(tmpdir(), "pushary-pending");
|
|
74
|
+
var DEFAULT_SESSION = "_no_session";
|
|
75
|
+
var GRACE_MS = 10 * 60 * 1e3;
|
|
76
|
+
var sanitize = (sessionId) => sessionId.replace(/[^A-Za-z0-9_-]/g, "_").slice(0, 128) || DEFAULT_SESSION;
|
|
77
|
+
var dirFor = (sessionId) => join(PENDING_DIR, sanitize(sessionId));
|
|
78
|
+
var isDefaultSession = (sessionId) => sanitize(sessionId) === DEFAULT_SESSION;
|
|
79
|
+
var savePendingQuestion = (sessionId, correlationId) => {
|
|
80
|
+
const dir = dirFor(sessionId);
|
|
81
|
+
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
|
82
|
+
writeFileSync(join(dir, correlationId), "", "utf-8");
|
|
83
|
+
};
|
|
84
|
+
var listPendingQuestions = (sessionId) => {
|
|
85
|
+
const dir = dirFor(sessionId);
|
|
86
|
+
let files;
|
|
87
|
+
try {
|
|
88
|
+
files = readdirSync(dir);
|
|
89
|
+
} catch {
|
|
90
|
+
return [];
|
|
91
|
+
}
|
|
92
|
+
if (!isDefaultSession(sessionId)) return files;
|
|
93
|
+
const cutoff = Date.now() - GRACE_MS;
|
|
94
|
+
return files.filter((name) => {
|
|
95
|
+
try {
|
|
96
|
+
return statSync(join(dir, name)).mtimeMs < cutoff;
|
|
97
|
+
} catch {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
var removePendingQuestion = (sessionId, correlationId) => {
|
|
103
|
+
try {
|
|
104
|
+
unlinkSync(join(dirFor(sessionId), correlationId));
|
|
105
|
+
} catch {
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
var removePendingSession = (sessionId) => {
|
|
109
|
+
try {
|
|
110
|
+
rmSync(dirFor(sessionId), { recursive: true, force: true });
|
|
111
|
+
} catch {
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export {
|
|
116
|
+
isPolicyConfig,
|
|
117
|
+
askUser,
|
|
118
|
+
waitForAnswer,
|
|
119
|
+
cancelQuestion,
|
|
120
|
+
sendNotification,
|
|
121
|
+
describeToolCall,
|
|
122
|
+
DEFAULT_SESSION,
|
|
123
|
+
isDefaultSession,
|
|
124
|
+
savePendingQuestion,
|
|
125
|
+
listPendingQuestions,
|
|
126
|
+
removePendingQuestion,
|
|
127
|
+
removePendingSession,
|
|
128
|
+
getMachineId
|
|
129
|
+
};
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isApprovalMode
|
|
3
|
+
} from "./chunk-IBWCHA5M.js";
|
|
4
|
+
import {
|
|
5
|
+
DEFAULT_SESSION,
|
|
6
|
+
askUser,
|
|
7
|
+
describeToolCall,
|
|
8
|
+
getMachineId,
|
|
9
|
+
isPolicyConfig,
|
|
10
|
+
savePendingQuestion,
|
|
11
|
+
sendNotification,
|
|
12
|
+
waitForAnswer
|
|
13
|
+
} from "./chunk-OF5WIOYS.js";
|
|
14
|
+
import {
|
|
15
|
+
withRetry
|
|
16
|
+
} from "./chunk-3MIR7ODJ.js";
|
|
17
|
+
import {
|
|
18
|
+
getApiKey,
|
|
19
|
+
getBaseUrl
|
|
20
|
+
} from "./chunk-VUNL35KE.js";
|
|
21
|
+
|
|
22
|
+
// src/policy.ts
|
|
23
|
+
import { createHash } from "crypto";
|
|
24
|
+
import { existsSync, readFileSync, writeFileSync } from "fs";
|
|
25
|
+
import { join } from "path";
|
|
26
|
+
import { tmpdir } from "os";
|
|
27
|
+
var CACHE_TTL_MS = 5 * 60 * 1e3;
|
|
28
|
+
var cacheFile = (apiKey) => {
|
|
29
|
+
const hash = createHash("sha256").update(apiKey).digest("hex").slice(0, 12);
|
|
30
|
+
return join(tmpdir(), `pushary-policy-${hash}.json`);
|
|
31
|
+
};
|
|
32
|
+
var fetchPolicy = async (apiKey) => {
|
|
33
|
+
return withRetry(async () => {
|
|
34
|
+
const baseUrl = getBaseUrl();
|
|
35
|
+
const response = await fetch(`${baseUrl}/api/mcp/policy`, {
|
|
36
|
+
headers: { "Authorization": `Bearer ${apiKey}` },
|
|
37
|
+
signal: AbortSignal.timeout(1e4)
|
|
38
|
+
});
|
|
39
|
+
if (!response.ok) {
|
|
40
|
+
throw new Error(`Failed to fetch policy: ${response.status}`);
|
|
41
|
+
}
|
|
42
|
+
const raw = await response.json();
|
|
43
|
+
if (!isPolicyConfig(raw)) throw new Error("Invalid policy response");
|
|
44
|
+
return raw;
|
|
45
|
+
}, { maxAttempts: 2 });
|
|
46
|
+
};
|
|
47
|
+
var getPolicy = async (apiKey) => {
|
|
48
|
+
const path = cacheFile(apiKey);
|
|
49
|
+
let staleCache = null;
|
|
50
|
+
if (existsSync(path)) {
|
|
51
|
+
try {
|
|
52
|
+
const stat = readFileSync(path, "utf-8");
|
|
53
|
+
const cached = JSON.parse(stat);
|
|
54
|
+
if (!isPolicyConfig(cached)) throw new Error("Corrupted cache");
|
|
55
|
+
if (!cached._cachedAt || Date.now() - cached._cachedAt < CACHE_TTL_MS) {
|
|
56
|
+
return cached;
|
|
57
|
+
}
|
|
58
|
+
staleCache = cached;
|
|
59
|
+
} catch {
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
try {
|
|
63
|
+
const policy = await fetchPolicy(apiKey);
|
|
64
|
+
try {
|
|
65
|
+
writeFileSync(path, JSON.stringify({ ...policy, _cachedAt: Date.now() }), "utf-8");
|
|
66
|
+
} catch {
|
|
67
|
+
}
|
|
68
|
+
return policy;
|
|
69
|
+
} catch {
|
|
70
|
+
if (staleCache) return staleCache;
|
|
71
|
+
throw new Error("Failed to fetch policy and no cached policy available");
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
var resolvePolicy = (config, toolName, modeOverride) => {
|
|
75
|
+
const base = config.policies.find((p) => p.tool === toolName) ?? config.policies.find((p) => p.tool === "*") ?? {
|
|
76
|
+
tool: toolName,
|
|
77
|
+
timeoutSeconds: config.defaultTimeoutSeconds,
|
|
78
|
+
timeoutAction: config.defaultTimeoutAction,
|
|
79
|
+
mode: config.defaultMode ?? "push_first",
|
|
80
|
+
pushFirstSeconds: config.defaultPushFirstSeconds ?? 20
|
|
81
|
+
};
|
|
82
|
+
const effectiveOverride = modeOverride ?? config.modeOverride;
|
|
83
|
+
if (effectiveOverride) {
|
|
84
|
+
return { ...base, mode: effectiveOverride };
|
|
85
|
+
}
|
|
86
|
+
return base;
|
|
87
|
+
};
|
|
88
|
+
var fetchModeState = async (apiKey, sessionId) => {
|
|
89
|
+
try {
|
|
90
|
+
const baseUrl = getBaseUrl();
|
|
91
|
+
const url = sessionId ? `${baseUrl}/api/mcp/mode?session=${encodeURIComponent(sessionId)}` : `${baseUrl}/api/mcp/mode`;
|
|
92
|
+
const response = await fetch(url, {
|
|
93
|
+
headers: { "Authorization": `Bearer ${apiKey}` },
|
|
94
|
+
signal: AbortSignal.timeout(3e3)
|
|
95
|
+
});
|
|
96
|
+
if (!response.ok) return { mode: null, kill: false };
|
|
97
|
+
const data = await response.json();
|
|
98
|
+
const mode = data.override?.mode;
|
|
99
|
+
return { mode: isApprovalMode(mode) ? mode : null, kill: data.kill === true };
|
|
100
|
+
} catch {
|
|
101
|
+
return { mode: null, kill: false };
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
var fetchModeOverride = async (apiKey) => (await fetchModeState(apiKey)).mode;
|
|
105
|
+
|
|
106
|
+
// src/hook.ts
|
|
107
|
+
import { basename } from "path";
|
|
108
|
+
var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
109
|
+
var allow = () => ({
|
|
110
|
+
hookSpecificOutput: {
|
|
111
|
+
hookEventName: "PreToolUse",
|
|
112
|
+
permissionDecision: "allow"
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
var deny = (reason) => ({
|
|
116
|
+
hookSpecificOutput: {
|
|
117
|
+
hookEventName: "PreToolUse",
|
|
118
|
+
permissionDecision: "deny",
|
|
119
|
+
permissionDecisionReason: reason
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
var ask = (reason) => ({
|
|
123
|
+
hookSpecificOutput: {
|
|
124
|
+
hookEventName: "PreToolUse",
|
|
125
|
+
permissionDecision: "ask",
|
|
126
|
+
...reason ? { permissionDecisionReason: reason } : {}
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
var pollForAnswer = async (apiKey, correlationId, deadlineMs, pollInterval = 2e3) => {
|
|
130
|
+
while (Date.now() < deadlineMs) {
|
|
131
|
+
const remaining = Math.min(Math.max(deadlineMs - Date.now(), 1e3), 3e4);
|
|
132
|
+
let answer;
|
|
133
|
+
try {
|
|
134
|
+
answer = await waitForAnswer(apiKey, correlationId, remaining);
|
|
135
|
+
} catch {
|
|
136
|
+
if (Date.now() + pollInterval >= deadlineMs) break;
|
|
137
|
+
await sleep(pollInterval);
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
if (answer.answered) return answer;
|
|
141
|
+
if (Date.now() + pollInterval >= deadlineMs) break;
|
|
142
|
+
await sleep(pollInterval);
|
|
143
|
+
}
|
|
144
|
+
return { answered: false };
|
|
145
|
+
};
|
|
146
|
+
var handlePushOnly = async (apiKey, description, projectName, timeoutSeconds, timeoutAction, sessionId, machineId, toolName) => {
|
|
147
|
+
let result;
|
|
148
|
+
try {
|
|
149
|
+
result = await askUser(apiKey, {
|
|
150
|
+
question: `Allow ${description}?`,
|
|
151
|
+
type: "confirm",
|
|
152
|
+
context: `Agent wants to run this in ${projectName}`,
|
|
153
|
+
agentName: `Claude Code - ${projectName}`,
|
|
154
|
+
sessionId,
|
|
155
|
+
machineId,
|
|
156
|
+
toolName
|
|
157
|
+
});
|
|
158
|
+
} catch {
|
|
159
|
+
switch (timeoutAction) {
|
|
160
|
+
case "approve":
|
|
161
|
+
return allow();
|
|
162
|
+
case "deny":
|
|
163
|
+
return deny("Push notification failed, denying per policy");
|
|
164
|
+
default:
|
|
165
|
+
return ask("Push notification failed, asking in terminal");
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
const deadline = Date.now() + timeoutSeconds * 1e3;
|
|
169
|
+
const answer = await pollForAnswer(apiKey, result.correlationId, deadline);
|
|
170
|
+
if (answer.answered) {
|
|
171
|
+
return answer.value === "yes" ? allow() : deny("Denied via push notification");
|
|
172
|
+
}
|
|
173
|
+
switch (timeoutAction) {
|
|
174
|
+
case "approve":
|
|
175
|
+
return allow();
|
|
176
|
+
case "deny":
|
|
177
|
+
return deny("No response within timeout");
|
|
178
|
+
default:
|
|
179
|
+
return ask("No push response, asking in terminal");
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
var handleTerminalOnly = () => {
|
|
183
|
+
return ask();
|
|
184
|
+
};
|
|
185
|
+
var handlePushFirst = async (apiKey, description, projectName, pushFirstSeconds, sessionId, machineId, toolName) => {
|
|
186
|
+
let result;
|
|
187
|
+
try {
|
|
188
|
+
result = await askUser(apiKey, {
|
|
189
|
+
question: `Allow ${description}?`,
|
|
190
|
+
type: "confirm",
|
|
191
|
+
context: `Agent wants to run this in ${projectName}`,
|
|
192
|
+
agentName: `Claude Code - ${projectName}`,
|
|
193
|
+
sessionId,
|
|
194
|
+
machineId,
|
|
195
|
+
toolName
|
|
196
|
+
});
|
|
197
|
+
} catch {
|
|
198
|
+
return ask("Push notification failed, asking in terminal");
|
|
199
|
+
}
|
|
200
|
+
const deadline = Date.now() + pushFirstSeconds * 1e3;
|
|
201
|
+
const answer = await pollForAnswer(apiKey, result.correlationId, deadline, 1500);
|
|
202
|
+
if (answer.answered) {
|
|
203
|
+
return answer.value === "yes" ? allow() : deny("Denied via push notification");
|
|
204
|
+
}
|
|
205
|
+
savePendingQuestion(sessionId || DEFAULT_SESSION, result.correlationId);
|
|
206
|
+
return ask("Sent as push notification. You can also approve here.");
|
|
207
|
+
};
|
|
208
|
+
var handleNotifyOnly = async (apiKey, description, projectName, sessionId, machineId) => {
|
|
209
|
+
try {
|
|
210
|
+
await sendNotification(apiKey, {
|
|
211
|
+
title: "Agent needs approval",
|
|
212
|
+
body: description,
|
|
213
|
+
agentName: `Claude Code - ${projectName}`,
|
|
214
|
+
sessionId,
|
|
215
|
+
machineId
|
|
216
|
+
});
|
|
217
|
+
} catch {
|
|
218
|
+
}
|
|
219
|
+
return ask();
|
|
220
|
+
};
|
|
221
|
+
var handlePreToolUse = async (input) => {
|
|
222
|
+
try {
|
|
223
|
+
const apiKey = getApiKey();
|
|
224
|
+
const [policy, modeState] = await Promise.all([
|
|
225
|
+
getPolicy(apiKey),
|
|
226
|
+
fetchModeState(apiKey, input.session_id)
|
|
227
|
+
]);
|
|
228
|
+
if (modeState.kill) {
|
|
229
|
+
return deny("Stopped by user \u2014 this agent was halted from Pushary");
|
|
230
|
+
}
|
|
231
|
+
const toolPolicy = resolvePolicy(policy, input.tool_name, modeState.mode);
|
|
232
|
+
if (toolPolicy.timeoutSeconds === 0 && toolPolicy.timeoutAction === "approve") {
|
|
233
|
+
return allow();
|
|
234
|
+
}
|
|
235
|
+
const description = describeToolCall(input.tool_name, input.tool_input, "hook");
|
|
236
|
+
const projectName = basename(input.cwd ?? process.cwd());
|
|
237
|
+
const sessionId = input.session_id;
|
|
238
|
+
const machineId = getMachineId();
|
|
239
|
+
switch (toolPolicy.mode) {
|
|
240
|
+
case "push_only":
|
|
241
|
+
return handlePushOnly(apiKey, description, projectName, toolPolicy.timeoutSeconds, toolPolicy.timeoutAction, sessionId, machineId, input.tool_name);
|
|
242
|
+
case "terminal_only":
|
|
243
|
+
return handleTerminalOnly();
|
|
244
|
+
case "push_first":
|
|
245
|
+
return handlePushFirst(apiKey, description, projectName, toolPolicy.pushFirstSeconds, sessionId, machineId, input.tool_name);
|
|
246
|
+
case "notify_only":
|
|
247
|
+
return handleNotifyOnly(apiKey, description, projectName, sessionId, machineId);
|
|
248
|
+
default:
|
|
249
|
+
return handlePushFirst(apiKey, description, projectName, toolPolicy.pushFirstSeconds, sessionId, machineId, input.tool_name);
|
|
250
|
+
}
|
|
251
|
+
} catch {
|
|
252
|
+
return ask("Pushary unavailable, falling back to terminal approval");
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
export {
|
|
257
|
+
getPolicy,
|
|
258
|
+
resolvePolicy,
|
|
259
|
+
fetchModeState,
|
|
260
|
+
fetchModeOverride,
|
|
261
|
+
handlePreToolUse
|
|
262
|
+
};
|
package/dist/src/index.d.ts
CHANGED
|
@@ -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
|
|
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-
|
|
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-
|
|
14
|
+
} from "../chunk-AB4KX4XT.js";
|
|
13
15
|
import {
|
|
14
16
|
askUser,
|
|
15
17
|
cancelQuestion,
|
|
16
18
|
waitForAnswer
|
|
17
|
-
} from "../chunk-
|
|
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.
|
|
3
|
+
"version": "0.9.0",
|
|
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
|
|
34
|
-
"dev": "tsup
|
|
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/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
|
}
|