@pushary/agent-hooks 0.62.0 → 0.62.2

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.
Files changed (45) hide show
  1. package/CHANGELOG.md +62 -0
  2. package/dist/bin/pushary-claude.js +5 -2
  3. package/dist/bin/pushary-clean.js +24 -6
  4. package/dist/bin/pushary-codex-hook.js +5 -2
  5. package/dist/bin/pushary-codex.js +5 -2
  6. package/dist/bin/pushary-connect.js +16 -13
  7. package/dist/bin/pushary-daemon.js +5 -4
  8. package/dist/bin/pushary-doctor.js +20 -14
  9. package/dist/bin/pushary-gemini-hook.js +5 -2
  10. package/dist/bin/pushary-hook.js +8 -5
  11. package/dist/bin/pushary-login.js +15 -11
  12. package/dist/bin/pushary-logout.js +11 -9
  13. package/dist/bin/pushary-mode.js +29 -6
  14. package/dist/bin/pushary-notification-hook.js +5 -2
  15. package/dist/bin/pushary-permission-denied-hook.js +6 -3
  16. package/dist/bin/pushary-permission-hook.js +6 -3
  17. package/dist/bin/pushary-post-hook.js +5 -2
  18. package/dist/bin/pushary-prompt-hook.js +5 -2
  19. package/dist/bin/pushary-session-end-hook.js +5 -2
  20. package/dist/bin/pushary-session-start-hook.js +5 -2
  21. package/dist/bin/pushary-setup.js +21 -16
  22. package/dist/bin/pushary-stats.js +3 -2
  23. package/dist/bin/pushary-status.js +22 -8
  24. package/dist/bin/pushary-stop-hook.js +5 -2
  25. package/dist/bin/pushary-stopfailure-hook.js +5 -2
  26. package/dist/bin/pushary-suggestions.js +27 -2
  27. package/dist/bin/pushary-upgrade.js +16 -9
  28. package/dist/bin/pushary-wait.js +29 -6
  29. package/dist/bin/pushary.js +9 -2
  30. package/dist/{chunk-HIIBSYFJ.js → chunk-5ZDYDU2Q.js} +5 -1
  31. package/dist/chunk-6MTNS63X.js +55 -0
  32. package/dist/{chunk-SP7OZXCQ.js → chunk-7OXIC7E3.js} +1 -15
  33. package/dist/{chunk-HNTKTK5B.js → chunk-BSZYIAZL.js} +4 -0
  34. package/dist/{chunk-247C4RE5.js → chunk-COC6NPWG.js} +12 -59
  35. package/dist/{chunk-YJ7YZRVV.js → chunk-G4TARJAY.js} +8 -54
  36. package/dist/{chunk-N4DA4CJB.js → chunk-GMXKITVA.js} +13 -0
  37. package/dist/chunk-KZERVKTD.js +16 -0
  38. package/dist/{chunk-3O27ZSRE.js → chunk-NGZMVCXN.js} +1 -1
  39. package/dist/chunk-SAF6HGAA.js +57 -0
  40. package/dist/{chunk-5SO3CEGJ.js → chunk-SDXF5I46.js} +1 -1
  41. package/dist/{chunk-ONVEYEVR.js → chunk-SR52774M.js} +2 -2
  42. package/dist/{chunk-IIZZYUWK.js → chunk-WXFEK7KD.js} +4 -2
  43. package/dist/{chunk-QHOVJXOT.js → chunk-Z3Z4VK5F.js} +2 -1
  44. package/dist/src/index.js +6 -3
  45. package/package.json +1 -1
@@ -1,3 +1,9 @@
1
+ import {
2
+ backupFile,
3
+ readJsonSafe,
4
+ writeFileAtomic,
5
+ writeJsonAtomic
6
+ } from "./chunk-6MTNS63X.js";
1
7
  import {
2
8
  resolveShellRc
3
9
  } from "./chunk-BC3VCZ3E.js";
@@ -5,59 +11,10 @@ import {
5
11
  configFilePath
6
12
  } from "./chunk-2UMNXADU.js";
7
13
 
8
- // src/cli/fsx.ts
9
- import { copyFileSync, existsSync, fsyncSync, mkdirSync, openSync, closeSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "fs";
10
- import { dirname, join } from "path";
11
- var readJsonSafe = (filePath) => {
12
- let raw;
13
- try {
14
- raw = readFileSync(filePath, "utf-8");
15
- } catch (err) {
16
- const error = err;
17
- if (error.code === "ENOENT") return { kind: "missing" };
18
- return { kind: "unreadable", error };
19
- }
20
- if (raw.trim() === "") return { kind: "ok", value: {} };
21
- try {
22
- return { kind: "ok", value: JSON.parse(raw) };
23
- } catch (err) {
24
- return { kind: "unparseable", error: err, raw };
25
- }
26
- };
27
- var stamp = () => (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
28
- var backupFile = (filePath) => {
29
- const target = `${filePath}.pushary-backup-${stamp()}`;
30
- copyFileSync(filePath, target);
31
- return target;
32
- };
33
- var writeFileAtomic = (filePath, contents, mode) => {
34
- const dir = dirname(filePath);
35
- if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
36
- const temp = join(dir, `.${process.pid}-${stamp()}.pushary-tmp`);
37
- try {
38
- writeFileSync(temp, contents, mode === void 0 ? "utf-8" : { encoding: "utf-8", mode });
39
- const handle = openSync(temp, "r+");
40
- try {
41
- fsyncSync(handle);
42
- } finally {
43
- closeSync(handle);
44
- }
45
- renameSync(temp, filePath);
46
- } catch (err) {
47
- try {
48
- if (existsSync(temp)) unlinkSync(temp);
49
- } catch {
50
- }
51
- throw err;
52
- }
53
- };
54
- var writeJsonAtomic = (filePath, data, mode) => writeFileAtomic(filePath, `${JSON.stringify(data, null, 2)}
55
- `, mode);
56
-
57
14
  // src/keystore.ts
58
- import { chmodSync, existsSync as existsSync2, readFileSync as readFileSync2, realpathSync, writeFileSync as writeFileSync2 } from "fs";
15
+ import { chmodSync, existsSync, readFileSync, realpathSync, writeFileSync } from "fs";
59
16
  import { homedir } from "os";
60
- import { join as join2 } from "path";
17
+ import { join } from "path";
61
18
  var KEY_FILE_MODE = 384;
62
19
  var FALLBACK_RCS = [".zshrc", ".zprofile", ".bashrc", ".bash_profile"];
63
20
  var OUR_EXPORT = /^[ \t]*export[ \t]+PUSHARY_API_KEY=(['"]?)(pk_[a-f0-9]+\.[a-f0-9]+)\1[ \t]*$/;
@@ -86,7 +43,7 @@ var rewriteRcExport = (rcPath, apiKey, shell = null) => {
86
43
  const target = realPathOf(rcPath);
87
44
  let content = "";
88
45
  try {
89
- content = readFileSync2(target, "utf-8");
46
+ content = readFileSync(target, "utf-8");
90
47
  } catch (err) {
91
48
  const error = err;
92
49
  if (error.code !== "ENOENT") {
@@ -141,7 +98,7 @@ var rewriteRcExport = (rcPath, apiKey, shell = null) => {
141
98
  var resolveRcTarget = () => {
142
99
  const resolved = resolveShellRc();
143
100
  if (resolved) return { path: resolved.path, shell: resolved.shell };
144
- const fallback = FALLBACK_RCS.map((name) => join2(homedir(), name)).find(existsSync2);
101
+ const fallback = FALLBACK_RCS.map((name) => join(homedir(), name)).find(existsSync);
145
102
  return fallback ? { path: fallback, shell: null } : null;
146
103
  };
147
104
  var writeKey = (apiKey, options = {}) => {
@@ -181,13 +138,13 @@ var clearKey = (options = {}) => {
181
138
  if (target) {
182
139
  try {
183
140
  const real = realpathSync(target.path);
184
- const lines = readFileSync2(real, "utf8").split("\n");
141
+ const lines = readFileSync(real, "utf8").split("\n");
185
142
  const next = lines.map((line) => {
186
143
  if (!OUR_EXPORT.test(line)) return line;
187
144
  rcLinesDisabled += 1;
188
145
  return `# ${line.trim()} # removed by pushary logout`;
189
146
  });
190
- if (rcLinesDisabled > 0) writeFileSync2(real, next.join("\n"));
147
+ if (rcLinesDisabled > 0) writeFileSync(real, next.join("\n"));
191
148
  } catch {
192
149
  rcLinesDisabled = 0;
193
150
  }
@@ -223,10 +180,6 @@ var readKeySource = () => {
223
180
  };
224
181
 
225
182
  export {
226
- readJsonSafe,
227
- backupFile,
228
- writeFileAtomic,
229
- writeJsonAtomic,
230
183
  KEY_FILE_MODE,
231
184
  exportLine,
232
185
  keyPrefix,
@@ -1,68 +1,22 @@
1
+ import {
2
+ pusharyFetch
3
+ } from "./chunk-SAF6HGAA.js";
1
4
  import {
2
5
  NetworkError
3
6
  } from "./chunk-7QLSKOSU.js";
4
- import {
5
- EXIT
6
- } from "./chunk-SP7OZXCQ.js";
7
7
  import {
8
8
  isValidApiKey
9
9
  } from "./chunk-DQAN3JQP.js";
10
10
  import {
11
11
  getBaseUrl
12
12
  } from "./chunk-2UMNXADU.js";
13
-
14
- // src/cli/net.ts
15
- import { createRequire } from "module";
16
- var requireCjs = createRequire(import.meta.url);
17
- var PROXY_VARS = ["HTTPS_PROXY", "https_proxy", "HTTP_PROXY", "http_proxy"];
18
- var proxyFromEnv = () => {
19
- for (const name of PROXY_VARS) {
20
- const value = process.env[name]?.trim();
21
- if (value) return value;
22
- }
23
- return void 0;
24
- };
25
- var installed = false;
26
- var installProxyDispatcher = () => {
27
- if (installed) return;
28
- installed = true;
29
- if (!proxyFromEnv()) return;
30
- try {
31
- const { EnvHttpProxyAgent, setGlobalDispatcher } = requireCjs("undici");
32
- setGlobalDispatcher(new EnvHttpProxyAgent());
33
- } catch {
34
- }
35
- };
36
- var isNetworkFailure = (err) => {
37
- if (!(err instanceof Error)) return false;
38
- const code = err.code;
39
- if (code && ["ENOTFOUND", "ECONNREFUSED", "ECONNRESET", "ETIMEDOUT", "EAI_AGAIN", "EPROTO", "CERT_HAS_EXPIRED", "UNABLE_TO_VERIFY_LEAF_SIGNATURE"].includes(code)) {
40
- return true;
41
- }
42
- return err.name === "AbortError" || err.name === "TimeoutError" || /fetch failed/i.test(err.message);
43
- };
44
- var DEFAULT_TIMEOUT_MS = 15e3;
45
- var pusharyFetch = async (url, init = {}) => {
46
- installProxyDispatcher();
47
- const { timeoutMs = DEFAULT_TIMEOUT_MS, signal, ...rest } = init;
48
- try {
49
- return await fetch(url, {
50
- ...rest,
51
- signal: signal ?? AbortSignal.timeout(timeoutMs)
52
- });
53
- } catch (err) {
54
- if (isNetworkFailure(err)) {
55
- const proxy = proxyFromEnv();
56
- const via = proxy ? ` (via proxy ${proxy})` : "";
57
- throw new NetworkError(`Could not reach ${new URL(url).host}${via}: ${err instanceof Error ? err.message : String(err)}`);
58
- }
59
- throw err;
60
- }
61
- };
13
+ import {
14
+ EXIT
15
+ } from "./chunk-KZERVKTD.js";
62
16
 
63
17
  // src/session.ts
64
18
  var IDENTITY_PATH = "/api/v1/server/identity";
65
- var DEFAULT_TIMEOUT_MS2 = 1e4;
19
+ var DEFAULT_TIMEOUT_MS = 1e4;
66
20
  var SUBSCRIPTION_REQUIRED_CODE = "subscription_required";
67
21
  var DEFAULT_UPGRADE_PATH = "/dashboard/settings?tab=billing";
68
22
  var KEY_SCOPES = ["full_access", "connector", "bound"];
@@ -120,7 +74,7 @@ var checkApiKey = async (apiKey, options = {}) => {
120
74
  if (!isValidApiKey(apiKey)) return { kind: "malformed" };
121
75
  const baseUrl = options.baseUrl ?? getBaseUrl();
122
76
  const fetchImpl = options.fetchImpl ?? pusharyFetch;
123
- const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS2;
77
+ const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
124
78
  let response;
125
79
  try {
126
80
  response = await fetchImpl(`${baseUrl.replace(/\/+$/, "")}${IDENTITY_PATH}`, {
@@ -9,6 +9,18 @@ var known = (spec, name) => {
9
9
  if (spec.values.includes(name)) return "value";
10
10
  return void 0;
11
11
  };
12
+ var rejectUnknownFlags = (args, allowed) => {
13
+ for (const token of args) {
14
+ if (token === "--") break;
15
+ if (!token.startsWith("-")) continue;
16
+ const name = token.includes("=") ? token.slice(0, token.indexOf("=")) : token;
17
+ if (!allowed.includes(name)) {
18
+ throw new UsageError(
19
+ `Unknown flag: ${name}${allowed.length > 0 ? `. This command accepts ${allowed.join(", ")}` : ". This command takes no flags"}`
20
+ );
21
+ }
22
+ }
23
+ };
12
24
  var parseFlags = (argv, spec) => {
13
25
  const bools = /* @__PURE__ */ new Set();
14
26
  const values = /* @__PURE__ */ new Map();
@@ -53,5 +65,6 @@ var parseFlags = (argv, spec) => {
53
65
  };
54
66
 
55
67
  export {
68
+ rejectUnknownFlags,
56
69
  parseFlags
57
70
  };
@@ -0,0 +1,16 @@
1
+ // src/exit.ts
2
+ var EXIT = {
3
+ OK: 0,
4
+ FAILED: 1,
5
+ USAGE: 2,
6
+ NOT_CONFIGURED: 3,
7
+ UNAUTHENTICATED: 4,
8
+ PROBLEMS_FOUND: 5,
9
+ NO_DEVICE: 6,
10
+ INPUT_REQUIRED: 7,
11
+ UNREACHABLE: 8
12
+ };
13
+
14
+ export {
15
+ EXIT
16
+ };
@@ -5,7 +5,7 @@ import {
5
5
  } from "./chunk-3EGEA4KH.js";
6
6
  import {
7
7
  callMcpTool
8
- } from "./chunk-HNTKTK5B.js";
8
+ } from "./chunk-BSZYIAZL.js";
9
9
 
10
10
  // src/reach.ts
11
11
  var reachVerdict = (channels) => {
@@ -0,0 +1,57 @@
1
+ import {
2
+ NetworkError
3
+ } from "./chunk-7QLSKOSU.js";
4
+
5
+ // src/cli/net.ts
6
+ import { createRequire } from "module";
7
+ var requireCjs = createRequire(import.meta.url);
8
+ var PROXY_VARS = ["HTTPS_PROXY", "https_proxy", "HTTP_PROXY", "http_proxy"];
9
+ var proxyFromEnv = () => {
10
+ for (const name of PROXY_VARS) {
11
+ const value = process.env[name]?.trim();
12
+ if (value) return value;
13
+ }
14
+ return void 0;
15
+ };
16
+ var installed = false;
17
+ var installProxyDispatcher = () => {
18
+ if (installed) return;
19
+ installed = true;
20
+ if (!proxyFromEnv()) return;
21
+ try {
22
+ const { EnvHttpProxyAgent, setGlobalDispatcher } = requireCjs("undici");
23
+ setGlobalDispatcher(new EnvHttpProxyAgent());
24
+ } catch {
25
+ }
26
+ };
27
+ var isNetworkFailure = (err) => {
28
+ if (!(err instanceof Error)) return false;
29
+ const code = err.code;
30
+ if (code && ["ENOTFOUND", "ECONNREFUSED", "ECONNRESET", "ETIMEDOUT", "EAI_AGAIN", "EPROTO", "CERT_HAS_EXPIRED", "UNABLE_TO_VERIFY_LEAF_SIGNATURE"].includes(code)) {
31
+ return true;
32
+ }
33
+ return err.name === "AbortError" || err.name === "TimeoutError" || /fetch failed/i.test(err.message);
34
+ };
35
+ var DEFAULT_TIMEOUT_MS = 15e3;
36
+ var pusharyFetch = async (url, init = {}) => {
37
+ installProxyDispatcher();
38
+ const { timeoutMs = DEFAULT_TIMEOUT_MS, signal, ...rest } = init;
39
+ try {
40
+ return await fetch(url, {
41
+ ...rest,
42
+ signal: signal ?? AbortSignal.timeout(timeoutMs)
43
+ });
44
+ } catch (err) {
45
+ if (isNetworkFailure(err)) {
46
+ const proxy = proxyFromEnv();
47
+ const via = proxy ? ` (via proxy ${proxy})` : "";
48
+ throw new NetworkError(`Could not reach ${new URL(url).host}${via}: ${err instanceof Error ? err.message : String(err)}`);
49
+ }
50
+ throw err;
51
+ }
52
+ };
53
+
54
+ export {
55
+ installProxyDispatcher,
56
+ pusharyFetch
57
+ };
@@ -25,7 +25,7 @@ import {
25
25
  sendNotification,
26
26
  throttlePass,
27
27
  waitForAnswer
28
- } from "./chunk-HIIBSYFJ.js";
28
+ } from "./chunk-5ZDYDU2Q.js";
29
29
  import {
30
30
  isGatingMoment,
31
31
  recordKeylessMoment
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  describeKeyCheck,
3
3
  keyCheckFromResponse
4
- } from "./chunk-YJ7YZRVV.js";
4
+ } from "./chunk-G4TARJAY.js";
5
5
  import {
6
6
  createIo
7
7
  } from "./chunk-TX7KBKT7.js";
8
8
  import {
9
9
  EXIT
10
- } from "./chunk-SP7OZXCQ.js";
10
+ } from "./chunk-KZERVKTD.js";
11
11
 
12
12
  // src/cli/report-key.ts
13
13
  var { dim, yellow } = createIo();
@@ -1,8 +1,10 @@
1
1
  import {
2
- EXIT,
3
2
  getPackageVersion,
4
3
  renderCommandHelp
5
- } from "./chunk-SP7OZXCQ.js";
4
+ } from "./chunk-7OXIC7E3.js";
5
+ import {
6
+ EXIT
7
+ } from "./chunk-KZERVKTD.js";
6
8
 
7
9
  // src/cli/usage.ts
8
10
  var exitOnHelpFlag = (command) => {
@@ -227,7 +227,8 @@ var runBrowserLogin = async (ui, options, deps = {}) => {
227
227
  } else if (state2.kind === "payment-required") {
228
228
  ui.say(` ${ui.yellow("!")} A plan is needed before a key can be issued. Nothing was created yet.`);
229
229
  ui.say(` ${ui.dim("Choose one at")} ${ui.cyan(state2.checkoutUrl)}`);
230
- ui.say(` ${ui.dim("This terminal keeps the same code and finishes on its own once the plan is active.")}`);
230
+ ui.say(` ${ui.dim("Keep the browser tab open and this finishes on its own once the plan is active.")}`);
231
+ ui.say(` ${ui.dim("If you closed it, reopen the page and enter the same code again.")}`);
231
232
  if (!options.noBrowser && canOpenBrowser()) openInBrowser(state2.checkoutUrl);
232
233
  } else if (state2.kind === "unreachable") {
233
234
  ui.say(` ${ui.yellow("!")} Still trying. pushary.com is not answering ${ui.dim(`(${state2.detail})`)}`);
package/dist/src/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  handlePreToolUse
3
- } from "../chunk-5SO3CEGJ.js";
3
+ } from "../chunk-SDXF5I46.js";
4
4
  import "../chunk-CAJZAFVS.js";
5
5
  import "../chunk-YHG74UFF.js";
6
6
  import {
@@ -15,15 +15,18 @@ import {
15
15
  reportEvent,
16
16
  resolvePolicy,
17
17
  waitForAnswer
18
- } from "../chunk-HIIBSYFJ.js";
18
+ } from "../chunk-5ZDYDU2Q.js";
19
19
  import "../chunk-WLGEY4UX.js";
20
- import "../chunk-HNTKTK5B.js";
20
+ import "../chunk-BSZYIAZL.js";
21
+ import "../chunk-SAF6HGAA.js";
22
+ import "../chunk-7QLSKOSU.js";
21
23
  import "../chunk-DQAN3JQP.js";
22
24
  import "../chunk-RN3NOEJF.js";
23
25
  import {
24
26
  getApiKey,
25
27
  getBaseUrl
26
28
  } from "../chunk-2UMNXADU.js";
29
+ import "../chunk-KZERVKTD.js";
27
30
  export {
28
31
  askUser,
29
32
  cancelQuestion,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushary/agent-hooks",
3
- "version": "0.62.0",
3
+ "version": "0.62.2",
4
4
  "description": "Permission hooks for AI coding agents: route tool approvals through Pushary push notifications",
5
5
  "keywords": [
6
6
  "pushary",