@pushary/agent-hooks 0.24.0 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/pushary-clean.js +1 -1
- package/dist/bin/pushary-codex-hook.js +1 -1
- package/dist/bin/pushary-codex.js +1 -1
- package/dist/bin/pushary-doctor.js +21 -9
- package/dist/bin/pushary-gemini-hook.js +1 -1
- package/dist/bin/pushary-hook.js +2 -2
- package/dist/bin/pushary-post-hook.js +1 -1
- package/dist/bin/pushary-prompt-hook.js +1 -1
- package/dist/bin/pushary-setup.js +7 -19
- package/dist/bin/pushary-stop-hook.js +1 -1
- package/dist/{chunk-OQZH5PVA.js → chunk-A7DQCA2N.js} +33 -19
- package/dist/{chunk-FGZZRCOG.js → chunk-SA4BDS7T.js} +1 -1
- package/dist/{chunk-JPRRYC5X.js → chunk-SLX4AONG.js} +25 -0
- package/dist/src/index.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-M4GDBGXF.js +0 -824
- package/dist/chunk-U4SSWRVM.js +0 -194
- package/dist/chunk-WPVL6VIT.js +0 -160
|
@@ -7,8 +7,9 @@ import {
|
|
|
7
7
|
hasInstructionBlock,
|
|
8
8
|
missingCodexHookEvents,
|
|
9
9
|
missingGeminiHookEvents,
|
|
10
|
+
readCodexMcpAuth,
|
|
10
11
|
untrustedCodexHookEvents
|
|
11
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-SLX4AONG.js";
|
|
12
13
|
import {
|
|
13
14
|
callMcpTool,
|
|
14
15
|
sendMcpRequest
|
|
@@ -171,22 +172,33 @@ var main = async () => {
|
|
|
171
172
|
}
|
|
172
173
|
const codexMcp = codexParsed.mcp_servers?.pushary;
|
|
173
174
|
const codexTransport = !!codexMcp && (typeof codexMcp.url === "string" || typeof codexMcp.command === "string");
|
|
174
|
-
const
|
|
175
|
-
const
|
|
176
|
-
|
|
177
|
-
check(codexMcpOk, "Codex: MCP server configured", codexMcpOk ? void 0 : !codexMcp ? "no [mcp_servers.pushary] \u2014 re-run setup" : !codexTransport ? "entry has no url \u2014 `codex mcp add` likely failed, re-run setup" : "entry has no bearer_token/_env_var \u2014 re-run setup");
|
|
175
|
+
const codexAuth = readCodexMcpAuth(codexParsed);
|
|
176
|
+
const codexMcpOk = !!codexMcp && codexTransport && !!codexAuth;
|
|
177
|
+
check(codexMcpOk, "Codex: MCP server configured", codexMcpOk ? void 0 : !codexMcp ? "no [mcp_servers.pushary] \u2014 re-run setup" : !codexTransport ? "entry has no url \u2014 re-run setup" : "entry has no Authorization header or bearer token \u2014 re-run setup");
|
|
178
178
|
if (codexMcp) {
|
|
179
179
|
const hasAutoApprove = codexMcp.default_tools_approval_mode === "approve";
|
|
180
180
|
check(hasAutoApprove, "Codex: tools auto-allowed", hasAutoApprove ? "default_tools_approval_mode = approve" : "missing \u2014 MCP calls will prompt for approval");
|
|
181
181
|
if (codexMcp.tools && typeof codexMcp.tools === "object") {
|
|
182
182
|
console.log(` ${warn} Codex: per-tool approval overrides detected ${dim("(redundant with default_tools_approval_mode)")}`);
|
|
183
183
|
}
|
|
184
|
-
if (
|
|
185
|
-
const
|
|
186
|
-
check(
|
|
184
|
+
if (codexAuth?.method === "embedded") {
|
|
185
|
+
const keyMatches = !apiKey || codexAuth.key === apiKey;
|
|
186
|
+
check(keyMatches, "Codex: MCP key embedded (config.toml)", keyMatches ? "no shell export needed" : "differs from your active key \u2014 re-run setup");
|
|
187
|
+
} else if (codexAuth?.method === "env") {
|
|
188
|
+
const envValue = process.env[codexAuth.envVar]?.trim();
|
|
189
|
+
const exportedInProfile = SHELL_FILES.some((f) => {
|
|
190
|
+
try {
|
|
191
|
+
return readFileSync(f, "utf-8").includes(`export ${codexAuth.envVar}=`);
|
|
192
|
+
} catch {
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
check(!!envValue, `Codex: MCP key available in shell ($${codexAuth.envVar})`, envValue ? "set \u2014 re-run setup to embed the key and drop the shell dependency" : exportedInProfile ? "exported in your profile but not in this shell \u2014 restart the terminal, or re-run setup to embed the key in config.toml" : "not set \u2014 Codex reads its key from your shell; re-run setup to embed the key in config.toml");
|
|
187
197
|
if (envValue && apiKey && envValue !== apiKey) {
|
|
188
|
-
console.log(` ${warn} Codex: $${
|
|
198
|
+
console.log(` ${warn} Codex: $${codexAuth.envVar} differs from your active key ${dim("(rotate or re-run setup so hooks and MCP match)")}`);
|
|
189
199
|
}
|
|
200
|
+
} else if (codexAuth?.method === "legacy-bearer") {
|
|
201
|
+
console.log(` ${warn} Codex: legacy bearer_token entry ${dim("(re-run setup to embed the key as an Authorization header)")}`);
|
|
190
202
|
}
|
|
191
203
|
}
|
|
192
204
|
const codexNotifyPath = codexConfig.match(/["']([^"']*pushary-codex[^"']*)["']/)?.[1] ?? null;
|
package/dist/bin/pushary-hook.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
handlePreToolUse
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-SA4BDS7T.js";
|
|
5
5
|
import "../chunk-KQYIHZ5E.js";
|
|
6
|
-
import "../chunk-
|
|
6
|
+
import "../chunk-A7DQCA2N.js";
|
|
7
7
|
import "../chunk-DWED7BS3.js";
|
|
8
8
|
import "../chunk-NKXSILEW.js";
|
|
9
9
|
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
GEMINI_HOOK_BINARY,
|
|
9
9
|
addCodexHookTrust,
|
|
10
10
|
addCodexHooks,
|
|
11
|
+
addCodexMcpServer,
|
|
11
12
|
addGeminiHooks,
|
|
12
13
|
addGeminiMcpServer,
|
|
13
14
|
execNpm,
|
|
@@ -15,11 +16,11 @@ import {
|
|
|
15
16
|
renderAgentInstructions,
|
|
16
17
|
renderProjectAgentInstructions,
|
|
17
18
|
writeInstructionBlock
|
|
18
|
-
} from "../chunk-
|
|
19
|
+
} from "../chunk-SLX4AONG.js";
|
|
19
20
|
import {
|
|
20
21
|
isValidApiKey,
|
|
21
22
|
reportEvent
|
|
22
|
-
} from "../chunk-
|
|
23
|
+
} from "../chunk-A7DQCA2N.js";
|
|
23
24
|
import "../chunk-DWED7BS3.js";
|
|
24
25
|
import "../chunk-NKXSILEW.js";
|
|
25
26
|
|
|
@@ -602,7 +603,7 @@ var addCodexNotifyEntry = (codexConfig) => {
|
|
|
602
603
|
writeFileSync(codexConfig, stringifyTOML(config), "utf-8");
|
|
603
604
|
}
|
|
604
605
|
};
|
|
605
|
-
var setupCodex = async (
|
|
606
|
+
var setupCodex = async (apiKey) => {
|
|
606
607
|
console.log(`
|
|
607
608
|
${bold2("Setting up Codex")}
|
|
608
609
|
`);
|
|
@@ -613,28 +614,14 @@ var setupCodex = async (_apiKey) => {
|
|
|
613
614
|
}
|
|
614
615
|
await installGlobally();
|
|
615
616
|
const codexConfig = join(homedir(), ".codex", "config.toml");
|
|
616
|
-
await spinner("Adding Pushary MCP server
|
|
617
|
-
try {
|
|
618
|
-
execSync(
|
|
619
|
-
"codex mcp add pushary --url https://pushary.com/api/mcp/mcp --bearer-token-env-var PUSHARY_API_KEY",
|
|
620
|
-
{ stdio: "ignore", timeout: 15e3 }
|
|
621
|
-
);
|
|
622
|
-
} catch {
|
|
623
|
-
}
|
|
624
|
-
});
|
|
625
|
-
await spinner("Auto-allowing all Pushary tools", async () => {
|
|
617
|
+
await spinner("Adding Pushary MCP server (key embedded, auto-allowed)", async () => {
|
|
626
618
|
let raw = "";
|
|
627
619
|
try {
|
|
628
620
|
raw = readFileSync(codexConfig, "utf-8");
|
|
629
621
|
} catch {
|
|
630
622
|
}
|
|
631
623
|
const config = raw ? parseTOML(raw) : {};
|
|
632
|
-
|
|
633
|
-
const pushary = mcpServers.pushary ?? {};
|
|
634
|
-
pushary.default_tools_approval_mode = "approve";
|
|
635
|
-
delete pushary.tools;
|
|
636
|
-
mcpServers.pushary = pushary;
|
|
637
|
-
config.mcp_servers = mcpServers;
|
|
624
|
+
addCodexMcpServer(config, apiKey);
|
|
638
625
|
writeFileSync(codexConfig, stringifyTOML(config), "utf-8");
|
|
639
626
|
});
|
|
640
627
|
const codexVersion = readCodexVersion();
|
|
@@ -681,6 +668,7 @@ var setupCodex = async (_apiKey) => {
|
|
|
681
668
|
console.log();
|
|
682
669
|
console.log(` ${dim2("What this configured:")}`);
|
|
683
670
|
console.log(` ${dim2("\u2022")} MCP server: Codex can send notifications and ask questions`);
|
|
671
|
+
console.log(` ${dim2("\u2022")} API key embedded in config.toml: works without a shell reload or export`);
|
|
684
672
|
console.log(` ${dim2("\u2022")} Proactive instructions: ~/.codex/AGENTS.md tells Codex to ask via push, not the terminal`);
|
|
685
673
|
console.log(` ${dim2("\u2022")} Auto-allowed tools: no permission prompts for Pushary MCP calls`);
|
|
686
674
|
if (hooksSupported) {
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
getBaseUrl
|
|
8
8
|
} from "./chunk-NKXSILEW.js";
|
|
9
9
|
|
|
10
|
-
//
|
|
10
|
+
// ../../../../../packages/contracts/src/index.ts
|
|
11
11
|
var APPROVAL_MODES = ["push_only", "terminal_only", "push_first", "notify_only"];
|
|
12
12
|
var isApprovalMode = (value) => typeof value === "string" && APPROVAL_MODES.includes(value);
|
|
13
13
|
var MATCH_RANKS = ["none", "tool", "prefix", "exact"];
|
|
@@ -156,6 +156,30 @@ var API_KEY_PATTERN = /^pk_[a-f0-9]+\.[a-f0-9]+$/;
|
|
|
156
156
|
var isValidApiKey = (value) => API_KEY_PATTERN.test(value);
|
|
157
157
|
var ACTION_BODY_MAX = 4e3;
|
|
158
158
|
var DECISION_LINE_MAX = 500;
|
|
159
|
+
var SECRET_REDACTION_RULES = [
|
|
160
|
+
{ pattern: /-----BEGIN[A-Z0-9 ]*PRIVATE KEY-----[\s\S]*?-----END[A-Z0-9 ]*PRIVATE KEY-----/g, replacement: "[redacted key]" },
|
|
161
|
+
{ pattern: /\bsk-[A-Za-z0-9_-]{16,}\b/g, replacement: "[redacted]" },
|
|
162
|
+
{ pattern: /\b[spr]k_(?:live|test)_[A-Za-z0-9]{8,}\b/g, replacement: "[redacted]" },
|
|
163
|
+
{ pattern: /\bwhsec_[A-Za-z0-9]{16,}\b/g, replacement: "[redacted]" },
|
|
164
|
+
{ pattern: /\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9]{36,}\b/g, replacement: "[redacted]" },
|
|
165
|
+
{ pattern: /\bgithub_pat_[A-Za-z0-9_]{22,}\b/g, replacement: "[redacted]" },
|
|
166
|
+
{ pattern: /\bglpat-[A-Za-z0-9_-]{20,}\b/g, replacement: "[redacted]" },
|
|
167
|
+
{ pattern: /\bxox[baprs]-[A-Za-z0-9-]{10,}\b/g, replacement: "[redacted]" },
|
|
168
|
+
{ pattern: /\bAIza[A-Za-z0-9_-]{35}\b/g, replacement: "[redacted]" },
|
|
169
|
+
{ pattern: /\bAKIA[0-9A-Z]{16}\b/g, replacement: "[redacted]" },
|
|
170
|
+
{ pattern: /\bnpm_[A-Za-z0-9]{36}\b/g, replacement: "[redacted]" },
|
|
171
|
+
{ pattern: /\bxai-[A-Za-z0-9]{16,}\b/g, replacement: "[redacted]" },
|
|
172
|
+
{ pattern: /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, replacement: "[redacted]" },
|
|
173
|
+
{ pattern: /\bbearer\s+[A-Za-z0-9._~+/=-]+/gi, replacement: "bearer [redacted]" },
|
|
174
|
+
{ pattern: /\bauthorization:\s*\S+/gi, replacement: "authorization: [redacted]" },
|
|
175
|
+
{
|
|
176
|
+
pattern: /((?:secret|token|password|passwd|api[_-]?key|access[_-]?key|client[_-]?secret|private[_-]?key)\s*[=:]\s*)("[^"]*"|'[^']*'|\S+)/gi,
|
|
177
|
+
replacement: "$1[redacted]"
|
|
178
|
+
}
|
|
179
|
+
];
|
|
180
|
+
var HIGH_ENTROPY_RULE = { pattern: /[A-Za-z0-9+/]{40,}={0,2}/g, replacement: "[redacted]" };
|
|
181
|
+
var redactSecrets = (text) => SECRET_REDACTION_RULES.reduce((acc, rule) => acc.replace(rule.pattern, rule.replacement), text);
|
|
182
|
+
var redactSecretsDeep = (text) => redactSecrets(text).replace(HIGH_ENTROPY_RULE.pattern, HIGH_ENTROPY_RULE.replacement);
|
|
159
183
|
|
|
160
184
|
// src/validate.ts
|
|
161
185
|
var isPolicyConfig = (data) => {
|
|
@@ -334,16 +358,20 @@ var hookPrefixes = {
|
|
|
334
358
|
Read: (input) => `read file: ${input.file_path ?? "(unknown path)"}`
|
|
335
359
|
};
|
|
336
360
|
var eventPrefixes = {
|
|
337
|
-
Bash: (input) => `ran: ${String(input.command ?? "")
|
|
361
|
+
Bash: (input) => `ran: ${String(input.command ?? "")}`,
|
|
338
362
|
Write: (input) => `wrote: ${input.file_path ?? "unknown"}`,
|
|
339
363
|
Edit: (input) => `edited: ${input.file_path ?? "unknown"}`,
|
|
340
364
|
Read: (input) => `read: ${input.file_path ?? "unknown"}`
|
|
341
365
|
};
|
|
366
|
+
var EVENT_ACTION_MAX = 120;
|
|
367
|
+
var HOOK_FALLBACK_MAX = 200;
|
|
342
368
|
var describeToolCall = (toolName, toolInput, format = "hook") => {
|
|
343
369
|
const prefixes = format === "hook" ? hookPrefixes : eventPrefixes;
|
|
344
370
|
const builder = prefixes[toolName];
|
|
345
|
-
|
|
346
|
-
|
|
371
|
+
const raw = builder ? builder(toolInput) : format === "hook" ? `${toolName}: ${JSON.stringify(toolInput)}` : `${toolName}: done`;
|
|
372
|
+
const redacted = redactSecrets(raw);
|
|
373
|
+
if (format === "event") return redacted.slice(0, EVENT_ACTION_MAX);
|
|
374
|
+
return builder ? redacted : redacted.slice(0, HOOK_FALLBACK_MAX);
|
|
347
375
|
};
|
|
348
376
|
var TOOL_TARGET_MAX_LENGTH = 80;
|
|
349
377
|
var deriveCommandHead = (command) => {
|
|
@@ -405,20 +433,6 @@ var deriveReceiptMeta = (toolName, toolInput, toolResult, cwd) => {
|
|
|
405
433
|
}
|
|
406
434
|
};
|
|
407
435
|
var firstString = (...values) => values.find((v) => typeof v === "string" && v.length > 0);
|
|
408
|
-
var REDACTION_RULES = [
|
|
409
|
-
{ pattern: /\bsk-[A-Za-z0-9]{20,}\b/g, replacement: "[redacted]" },
|
|
410
|
-
{ pattern: /\bpk_(?:live|test)_[A-Za-z0-9]+\b/g, replacement: "[redacted]" },
|
|
411
|
-
{ pattern: /\brk_[A-Za-z0-9]+\b/g, replacement: "[redacted]" },
|
|
412
|
-
{ pattern: /\bAKIA[0-9A-Z]{16}\b/g, replacement: "[redacted]" },
|
|
413
|
-
{ pattern: /\bbearer\s+[A-Za-z0-9._-]+/gi, replacement: "bearer [redacted]" },
|
|
414
|
-
{ pattern: /\bauthorization:\s*\S+/gi, replacement: "authorization: [redacted]" },
|
|
415
|
-
{
|
|
416
|
-
pattern: /((?:secret|token|password|passwd|api[_-]?key|private[_-]?key)\s*[=:]\s*)(\S+)/gi,
|
|
417
|
-
replacement: "$1[redacted]"
|
|
418
|
-
},
|
|
419
|
-
{ pattern: /[A-Za-z0-9+/]{40,}={0,2}/g, replacement: "[redacted]" }
|
|
420
|
-
];
|
|
421
|
-
var redactSecrets = (text) => REDACTION_RULES.reduce((acc, rule) => acc.replace(rule.pattern, rule.replacement), text);
|
|
422
436
|
var ACTION_BODY_TRUNCATION_MARKER = "\n\u2026 [truncated]";
|
|
423
437
|
var capActionBody = (text) => text.length <= ACTION_BODY_MAX ? text : `${text.slice(0, ACTION_BODY_MAX - ACTION_BODY_TRUNCATION_MARKER.length)}${ACTION_BODY_TRUNCATION_MARKER}`;
|
|
424
438
|
var rawActionBody = (toolName, toolInput) => {
|
|
@@ -439,7 +453,7 @@ var deriveActionBody = (toolName, toolInput) => {
|
|
|
439
453
|
try {
|
|
440
454
|
const raw = rawActionBody(toolName, toolInput);
|
|
441
455
|
if (!raw) return void 0;
|
|
442
|
-
return capActionBody(
|
|
456
|
+
return capActionBody(redactSecretsDeep(raw));
|
|
443
457
|
} catch {
|
|
444
458
|
return void 0;
|
|
445
459
|
}
|
|
@@ -25,6 +25,29 @@ var ensureRecord = (target, key) => {
|
|
|
25
25
|
target[key] = created;
|
|
26
26
|
return created;
|
|
27
27
|
};
|
|
28
|
+
var CODEX_MCP_URL = "https://pushary.com/api/mcp/mcp";
|
|
29
|
+
var addCodexMcpServer = (config, apiKey) => {
|
|
30
|
+
const servers = ensureRecord(config, "mcp_servers");
|
|
31
|
+
const pushary = ensureRecord(servers, "pushary");
|
|
32
|
+
pushary.url = CODEX_MCP_URL;
|
|
33
|
+
ensureRecord(pushary, "http_headers").Authorization = `Bearer ${apiKey}`;
|
|
34
|
+
pushary.default_tools_approval_mode = "approve";
|
|
35
|
+
delete pushary.bearer_token_env_var;
|
|
36
|
+
delete pushary.tools;
|
|
37
|
+
};
|
|
38
|
+
var readCodexMcpAuth = (config) => {
|
|
39
|
+
const pushary = asRecord(asRecord(config.mcp_servers)?.pushary);
|
|
40
|
+
if (!pushary) return void 0;
|
|
41
|
+
const authorization = asRecord(pushary.http_headers)?.Authorization;
|
|
42
|
+
if (typeof authorization === "string" && authorization.startsWith("Bearer ")) {
|
|
43
|
+
return { method: "embedded", key: authorization.slice("Bearer ".length).trim() };
|
|
44
|
+
}
|
|
45
|
+
if (typeof pushary.bearer_token_env_var === "string") {
|
|
46
|
+
return { method: "env", envVar: pushary.bearer_token_env_var };
|
|
47
|
+
}
|
|
48
|
+
if (typeof pushary.bearer_token === "string") return { method: "legacy-bearer" };
|
|
49
|
+
return void 0;
|
|
50
|
+
};
|
|
28
51
|
var isPusharyCodexHook = (entry) => {
|
|
29
52
|
const hooks = asRecord(entry)?.hooks;
|
|
30
53
|
if (!Array.isArray(hooks)) return false;
|
|
@@ -306,6 +329,8 @@ var execNpm = (args, options = {}) => {
|
|
|
306
329
|
};
|
|
307
330
|
|
|
308
331
|
export {
|
|
332
|
+
addCodexMcpServer,
|
|
333
|
+
readCodexMcpAuth,
|
|
309
334
|
addCodexHooks,
|
|
310
335
|
removeCodexHooks,
|
|
311
336
|
hasCodexHooks,
|
package/dist/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
handlePreToolUse
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-SA4BDS7T.js";
|
|
4
4
|
import "../chunk-KQYIHZ5E.js";
|
|
5
5
|
import {
|
|
6
6
|
askUser,
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
reportEvent,
|
|
15
15
|
resolvePolicy,
|
|
16
16
|
waitForAnswer
|
|
17
|
-
} from "../chunk-
|
|
17
|
+
} from "../chunk-A7DQCA2N.js";
|
|
18
18
|
import "../chunk-DWED7BS3.js";
|
|
19
19
|
import {
|
|
20
20
|
getApiKey,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pushary/agent-hooks",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.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",
|