@pushary/agent-hooks 0.8.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26,6 +26,14 @@ var green = (s) => `\x1B[32m${s}\x1B[0m`;
26
26
  var cyan = (s) => `\x1B[36m${s}\x1B[0m`;
27
27
  var yellow = (s) => `\x1B[33m${s}\x1B[0m`;
28
28
  var check = green("\u2713");
29
+ var parseKeyFlag = () => {
30
+ const args = process.argv.slice(2);
31
+ for (let i = 0; i < args.length; i++) {
32
+ if (args[i] === "--key" && args[i + 1]) return args[i + 1].trim();
33
+ if (args[i].startsWith("--key=")) return args[i].slice(6).trim();
34
+ }
35
+ return void 0;
36
+ };
29
37
  var readJson = (path) => {
30
38
  try {
31
39
  return JSON.parse(readFileSync(path, "utf-8"));
@@ -394,9 +402,16 @@ var main = async () => {
394
402
  console.log(` ${dim("Push notifications for AI coding agents")}`);
395
403
  console.log();
396
404
  await checkForUpdates(version);
405
+ const keyPattern = /^pk_[a-f0-9]+\.[a-f0-9]+$/;
406
+ const flagKey = parseKeyFlag();
397
407
  const envKey = process.env.PUSHARY_API_KEY?.trim();
398
408
  let trimmedKey;
399
- if (envKey && /^pk_[a-f0-9]+\.[a-f0-9]+$/.test(envKey)) {
409
+ if (flagKey && keyPattern.test(flagKey)) {
410
+ const masked = `${flagKey.slice(0, 8)}...${flagKey.slice(-4)}`;
411
+ console.log(` ${check} Using API key: ${dim(masked)}`);
412
+ console.log();
413
+ trimmedKey = flagKey;
414
+ } else if (envKey && keyPattern.test(envKey)) {
400
415
  const masked = `${envKey.slice(0, 8)}...${envKey.slice(-4)}`;
401
416
  console.log(` ${check} Found API key in environment: ${dim(masked)}`);
402
417
  console.log();
@@ -414,7 +429,7 @@ var main = async () => {
414
429
  const apiKey = await input({ message: "API key:" });
415
430
  trimmedKey = apiKey.trim();
416
431
  }
417
- if (!trimmedKey || !/^pk_[a-f0-9]+\.[a-f0-9]+$/.test(trimmedKey)) {
432
+ if (!trimmedKey || !keyPattern.test(trimmedKey)) {
418
433
  console.log(`
419
434
  ${yellow("!")} Invalid key format. Expected: ${dim("pk_xxx.xxx")}`);
420
435
  console.log(` ${dim("Copy your key from")} ${cyan("https://pushary.com/dashboard/agent/settings")}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushary/agent-hooks",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "Permission hooks for AI coding agents: route tool approvals through Pushary push notifications",
5
5
  "author": "Pushary <business@pushary.com>",
6
6
  "homepage": "https://pushary.com",