@pushary/agent-hooks 1.9.10 → 1.9.11

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 (102) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +1 -1
  3. package/dist/bin/pushary-bell-hook.js +25 -21
  4. package/dist/bin/pushary-bell.js +9 -9
  5. package/dist/bin/pushary-claude.js +31 -34
  6. package/dist/bin/pushary-clean.js +35 -37
  7. package/dist/bin/pushary-codex-bridge.js +20 -22
  8. package/dist/bin/pushary-codex-hook.js +33 -36
  9. package/dist/bin/pushary-codex.js +12 -14
  10. package/dist/bin/pushary-connect.js +25 -27
  11. package/dist/bin/pushary-cowork.js +5 -5
  12. package/dist/bin/pushary-daemon.js +31 -33
  13. package/dist/bin/pushary-disconnect.js +29 -29
  14. package/dist/bin/pushary-doctor.js +39 -41
  15. package/dist/bin/pushary-elicitation-hook.js +26 -26
  16. package/dist/bin/pushary-gemini-bridge.js +13 -13
  17. package/dist/bin/pushary-gemini-hook.js +30 -33
  18. package/dist/bin/pushary-hook.js +31 -33
  19. package/dist/bin/pushary-login.js +12 -12
  20. package/dist/bin/pushary-logout.js +10 -10
  21. package/dist/bin/pushary-mcp.js +9 -9
  22. package/dist/bin/pushary-mode.js +12 -12
  23. package/dist/bin/pushary-notification-hook.js +24 -26
  24. package/dist/bin/pushary-opencode-hook.js +29 -32
  25. package/dist/bin/pushary-permission-denied-hook.js +29 -31
  26. package/dist/bin/pushary-permission-hook.js +28 -30
  27. package/dist/bin/pushary-post-hook.js +24 -26
  28. package/dist/bin/pushary-prompt-hook.js +24 -26
  29. package/dist/bin/pushary-session-end-hook.js +24 -26
  30. package/dist/bin/pushary-session-start-hook.js +28 -30
  31. package/dist/bin/pushary-setup.js +47 -44
  32. package/dist/bin/pushary-stats.js +5 -5
  33. package/dist/bin/pushary-status.js +27 -29
  34. package/dist/bin/pushary-stop-hook.js +24 -26
  35. package/dist/bin/pushary-stopfailure-hook.js +24 -26
  36. package/dist/bin/pushary-suggestions.js +12 -12
  37. package/dist/bin/pushary-transcript-register.js +17 -17
  38. package/dist/bin/pushary-transcripts.js +7 -7
  39. package/dist/bin/pushary-upgrade.js +30 -32
  40. package/dist/bin/pushary-wait.js +12 -12
  41. package/dist/bin/pushary.js +6 -6
  42. package/dist/{chunk-IIVZZMSO.js → chunk-2AQ4VZSA.js} +1 -1
  43. package/dist/{chunk-APP43AW7.js → chunk-2GG77ADC.js} +1 -1
  44. package/dist/{chunk-H4F5O3RE.js → chunk-2NAQRPZQ.js} +1 -1
  45. package/dist/{chunk-UJZ7AGSC.js → chunk-4FWWHCYM.js} +4 -4
  46. package/dist/{chunk-ZGADIZDS.js → chunk-4HR2ICME.js} +1 -1
  47. package/dist/{chunk-BOSXFI7L.js → chunk-4RENRBSB.js} +4 -4
  48. package/dist/{chunk-BTFUSQFB.js → chunk-5WAYSUWV.js} +2 -2
  49. package/dist/{chunk-SIHYBIEN.js → chunk-7RWQZQV2.js} +5 -5
  50. package/dist/{chunk-LDQGURCF.js → chunk-A6J5Z2HO.js} +514 -313
  51. package/dist/{chunk-C6QTMWJZ.js → chunk-AIWZRRSK.js} +2 -2
  52. package/dist/{chunk-OL2Z7WI4.js → chunk-BDRXDO25.js} +2 -2
  53. package/dist/{chunk-S2DAKKQQ.js → chunk-BMP2BLIR.js} +3 -3
  54. package/dist/{chunk-QGRENWJL.js → chunk-BZI7EBTB.js} +1 -1
  55. package/dist/{chunk-2HFSKYLN.js → chunk-C6QM5SJR.js} +2 -2
  56. package/dist/{chunk-Q3UMWSE4.js → chunk-CBDJ2X5P.js} +2 -2
  57. package/dist/{chunk-DWO4RLYK.js → chunk-CHDAH4HP.js} +8 -8
  58. package/dist/{chunk-PR2VDVCP.js → chunk-CZYMYM7X.js} +3 -3
  59. package/dist/{chunk-MD4SVNT6.js → chunk-E6YQW43K.js} +1 -1
  60. package/dist/{chunk-UM5WXBKN.js → chunk-EJVYEOKC.js} +3 -3
  61. package/dist/{chunk-5MQYA3YL.js → chunk-ERXY2SIW.js} +19 -16
  62. package/dist/{chunk-2M52CFVO.js → chunk-FJCOOFT7.js} +1 -1
  63. package/dist/{chunk-Y7JM47CI.js → chunk-GA4J6YFN.js} +2 -2
  64. package/dist/{chunk-ZSGJYSF2.js → chunk-GUNZHSTL.js} +136 -8
  65. package/dist/{chunk-T6ZN4TEF.js → chunk-HX5TI6DP.js} +1 -1
  66. package/dist/{chunk-XXLCYKVS.js → chunk-I4I4UH62.js} +3 -3
  67. package/dist/{chunk-I3W7GJ5R.js → chunk-KBN3UP2R.js} +3 -3
  68. package/dist/{chunk-7HGR5GNY.js → chunk-KEV2MOJH.js} +46 -21
  69. package/dist/{chunk-QAGWWDXQ.js → chunk-KIVFWGG6.js} +5 -5
  70. package/dist/{chunk-AKPHYSEL.js → chunk-LBAMPNDM.js} +4 -4
  71. package/dist/{chunk-BVSIM4EF.js → chunk-LUHNNZSH.js} +2 -2
  72. package/dist/{chunk-Z2Q2VH43.js → chunk-LX6EWNRK.js} +15 -3
  73. package/dist/{chunk-TCXL5FQQ.js → chunk-M54ATCOZ.js} +1 -1
  74. package/dist/{chunk-2HXG2QDI.js → chunk-MHHXR7DT.js} +4 -4
  75. package/dist/{chunk-2S34OPHS.js → chunk-MITMDERZ.js} +1 -1
  76. package/dist/{chunk-BVPPYR7B.js → chunk-MJLTABWF.js} +3 -3
  77. package/dist/{chunk-XKMGHVXW.js → chunk-MX3LPP3K.js} +6 -6
  78. package/dist/{chunk-EVC765EO.js → chunk-N6GEI3PK.js} +2 -2
  79. package/dist/{chunk-MISUKJGW.js → chunk-N7HXP4PZ.js} +1 -1
  80. package/dist/{chunk-LXA236ZQ.js → chunk-OKSU74QH.js} +2 -2
  81. package/dist/{chunk-DL6QHS7V.js → chunk-P2EJN7UB.js} +1 -1
  82. package/dist/{chunk-YUQHUGTH.js → chunk-P7N7FJ7W.js} +1 -1
  83. package/dist/{chunk-DAOQT4WK.js → chunk-PRJNUNCV.js} +2 -2
  84. package/dist/{chunk-RPQLZLKC.js → chunk-PTGUJZSD.js} +5 -5
  85. package/dist/{chunk-6KNC6KLL.js → chunk-STUJXZC2.js} +4 -4
  86. package/dist/{chunk-GQYX24UC.js → chunk-TVVUJTUW.js} +1 -1
  87. package/dist/{chunk-5OP5MQI7.js → chunk-V6IW5WMK.js} +1 -1
  88. package/dist/{chunk-5RGA636G.js → chunk-VOP5U2VX.js} +145 -9
  89. package/dist/{chunk-U5FP5JIS.js → chunk-WCELLK4P.js} +2 -2
  90. package/dist/{chunk-SJDMULE7.js → chunk-WHRYW4P2.js} +5 -5
  91. package/dist/{chunk-SMVMLWCD.js → chunk-XYCTS3WP.js} +1 -1
  92. package/dist/{chunk-PNC5ZQFS.js → chunk-YETKAI5Q.js} +6 -6
  93. package/dist/{chunk-GTZ4HIHU.js → chunk-Z4AOR6RZ.js} +2 -2
  94. package/dist/{chunk-CJYM4ZHV.js → chunk-ZTSMQYST.js} +3 -5
  95. package/dist/{global-upgrade-PUM44JUH.js → global-upgrade-VT2JS7DR.js} +6 -6
  96. package/dist/{paths-U2MJGNBT.js → paths-WRBEUNEY.js} +2 -2
  97. package/dist/{reapply-PRKV4EO7.js → reapply-BCR6U7HO.js} +20 -22
  98. package/dist/src/index.js +19 -21
  99. package/dist/{upgrade-lock-QZSVLEM7.js → upgrade-lock-VRYMTPZQ.js} +3 -3
  100. package/package.json +1 -1
  101. package/dist/chunk-N6IOSZOE.js +0 -185
  102. package/dist/chunk-NQ67AF3V.js +0 -142
@@ -1,185 +0,0 @@
1
- // src/pending.ts
2
- import { join } from "path";
3
- import { homedir, tmpdir } from "os";
4
- import { createHash } from "crypto";
5
- import { existsSync, mkdirSync, writeFileSync, readFileSync, readdirSync, renameSync, unlinkSync, rmSync, statSync } from "fs";
6
- var PENDING_DIR = join(tmpdir(), "pushary-pending");
7
- var commandRoot = () => process.env.PUSHARY_COMMAND_DIR?.trim() || join(homedir(), ".pushary", "run", "commands");
8
- var DEFAULT_SESSION = "_no_session";
9
- var GRACE_MS = 10 * 60 * 1e3;
10
- var sanitize = (sessionId) => sessionId.replace(/[^A-Za-z0-9_-]/g, "_").slice(0, 128) || DEFAULT_SESSION;
11
- var dirFor = (sessionId) => join(PENDING_DIR, sanitize(sessionId));
12
- var commandDirFor = (sessionId, namespace = "") => join(
13
- commandRoot(),
14
- createHash("sha256").update(namespace).digest("hex").slice(0, 16),
15
- sanitize(sessionId)
16
- );
17
- var legacyCommandFile = (sessionId, namespace = "") => join(commandDirFor(sessionId, namespace), "command.json");
18
- var commandFile = (sessionId, id, namespace = "") => join(commandDirFor(sessionId, namespace), `${createHash("sha256").update(id).digest("hex")}.json`);
19
- var readCommandFile = (file) => {
20
- try {
21
- const value = JSON.parse(readFileSync(file, "utf-8"));
22
- if (typeof value.id !== "string" || typeof value.text !== "string" || typeof value.expiresAtMs !== "number") return null;
23
- if (value.expiresAtMs <= Date.now()) {
24
- unlinkSync(file);
25
- return null;
26
- }
27
- return {
28
- ...value,
29
- delivered: value.delivered === true,
30
- ...value.failed === true ? { failed: true } : {}
31
- };
32
- } catch {
33
- return null;
34
- }
35
- };
36
- var readPendingCommandById = (sessionId, id, namespace = "") => {
37
- const current = readCommandFile(commandFile(sessionId, id, namespace));
38
- if (current?.id === id) return current;
39
- const legacy = readCommandFile(legacyCommandFile(sessionId, namespace));
40
- return legacy?.id === id ? legacy : null;
41
- };
42
- var pruneExpiredCommands = (dir) => {
43
- let files;
44
- try {
45
- files = readdirSync(dir).filter((file) => file.endsWith(".json"));
46
- } catch {
47
- return [];
48
- }
49
- return files.flatMap((file) => {
50
- const command = readCommandFile(join(dir, file));
51
- return command ? [command] : [];
52
- });
53
- };
54
- var pruneExpiredCommandStore = () => {
55
- let namespaces;
56
- try {
57
- namespaces = readdirSync(commandRoot(), { withFileTypes: true });
58
- } catch {
59
- return;
60
- }
61
- for (const namespace of namespaces.filter((entry) => entry.isDirectory())) {
62
- const namespaceDir = join(commandRoot(), namespace.name);
63
- let sessions;
64
- try {
65
- sessions = readdirSync(namespaceDir, { withFileTypes: true });
66
- } catch {
67
- continue;
68
- }
69
- for (const session of sessions.filter((entry) => entry.isDirectory())) {
70
- pruneExpiredCommands(join(namespaceDir, session.name));
71
- }
72
- }
73
- };
74
- var readPendingCommand = (sessionId, namespace = "") => {
75
- const commands = pruneExpiredCommands(commandDirFor(sessionId, namespace));
76
- return commands.find((command) => !command.delivered && !command.failed) ?? commands[0] ?? null;
77
- };
78
- var savePendingCommand = (sessionId, command, namespace = "") => {
79
- const dir = commandDirFor(sessionId, namespace);
80
- try {
81
- mkdirSync(dir, { recursive: true, mode: 448 });
82
- pruneExpiredCommandStore();
83
- if (readPendingCommandById(sessionId, command.id, namespace)) return false;
84
- writeFileSync(commandFile(sessionId, command.id, namespace), JSON.stringify(command), { encoding: "utf-8", mode: 384, flag: "wx" });
85
- return true;
86
- } catch {
87
- return false;
88
- }
89
- };
90
- var updatePendingCommand = (sessionId, id, update, namespace = "") => {
91
- const command = readPendingCommandById(sessionId, id, namespace);
92
- if (!command) return false;
93
- const currentFile = commandFile(sessionId, id, namespace);
94
- const file = existsSync(currentFile) ? currentFile : legacyCommandFile(sessionId, namespace);
95
- const temporary = `${file}.${process.pid}.tmp`;
96
- try {
97
- writeFileSync(temporary, JSON.stringify({ ...command, ...update, text: "" }), { encoding: "utf-8", mode: 384 });
98
- renameSync(temporary, file);
99
- return true;
100
- } catch {
101
- try {
102
- unlinkSync(temporary);
103
- } catch {
104
- }
105
- return false;
106
- }
107
- };
108
- var markPendingCommandDelivered = (sessionId, id, namespace = "") => updatePendingCommand(sessionId, id, { delivered: true, failed: void 0 }, namespace);
109
- var markPendingCommandFailed = (sessionId, id, namespace = "") => updatePendingCommand(sessionId, id, { delivered: false, failed: true }, namespace);
110
- var removePendingCommand = (sessionId, id, namespace = "") => {
111
- if (!readPendingCommandById(sessionId, id, namespace)) return;
112
- try {
113
- unlinkSync(commandFile(sessionId, id, namespace));
114
- } catch {
115
- }
116
- try {
117
- if (readCommandFile(legacyCommandFile(sessionId, namespace))?.id === id) {
118
- unlinkSync(legacyCommandFile(sessionId, namespace));
119
- }
120
- } catch {
121
- }
122
- };
123
- var isDefaultSession = (sessionId) => sanitize(sessionId) === DEFAULT_SESSION;
124
- var listPendingQuestionsForToolUse = (sessionId, toolUseId) => {
125
- if (!toolUseId) return [];
126
- const dir = dirFor(sessionId);
127
- let files;
128
- try {
129
- files = readdirSync(dir);
130
- } catch {
131
- return [];
132
- }
133
- return files.filter((name) => {
134
- try {
135
- return readFileSync(join(dir, name), "utf-8") === toolUseId;
136
- } catch {
137
- return false;
138
- }
139
- });
140
- };
141
- var listPendingQuestions = (sessionId) => {
142
- const dir = dirFor(sessionId);
143
- let files;
144
- try {
145
- files = readdirSync(dir);
146
- } catch {
147
- return [];
148
- }
149
- if (!isDefaultSession(sessionId)) return files;
150
- const cutoff = Date.now() - GRACE_MS;
151
- return files.filter((name) => {
152
- try {
153
- return statSync(join(dir, name)).mtimeMs < cutoff;
154
- } catch {
155
- return false;
156
- }
157
- });
158
- };
159
- var removePendingQuestion = (sessionId, correlationId) => {
160
- try {
161
- unlinkSync(join(dirFor(sessionId), correlationId));
162
- } catch {
163
- }
164
- };
165
- var removePendingSession = (sessionId) => {
166
- try {
167
- rmSync(dirFor(sessionId), { recursive: true, force: true });
168
- } catch {
169
- }
170
- };
171
-
172
- export {
173
- DEFAULT_SESSION,
174
- readPendingCommandById,
175
- readPendingCommand,
176
- savePendingCommand,
177
- markPendingCommandDelivered,
178
- markPendingCommandFailed,
179
- removePendingCommand,
180
- isDefaultSession,
181
- listPendingQuestionsForToolUse,
182
- listPendingQuestions,
183
- removePendingQuestion,
184
- removePendingSession
185
- };
@@ -1,142 +0,0 @@
1
- import {
2
- CLIENT_REPORT_DISABLE_ENV,
3
- isDisabledByEnv
4
- } from "./chunk-POFBE6ZY.js";
5
- import {
6
- isNetworkFailure
7
- } from "./chunk-UM5WXBKN.js";
8
- import {
9
- clientReportClaims
10
- } from "./chunk-UJZ7AGSC.js";
11
- import {
12
- getApiKey,
13
- getBaseUrl
14
- } from "./chunk-2M52CFVO.js";
15
- import {
16
- CLIENT_REPORT_PATH,
17
- degradedLine
18
- } from "./chunk-5RGA636G.js";
19
-
20
- // src/client-report-claim.ts
21
- import { createHash } from "crypto";
22
- import { closeSync, mkdirSync, openSync, readdirSync, unlinkSync } from "fs";
23
- import { join } from "path";
24
- var CLIENT_REPORT_WINDOW_MS = 6e4;
25
- var CLAIM_DIRECTORY_MODE = 448;
26
- var CLAIM_FILE_MODE = 384;
27
- var CLAIM_KEY_HASH_LENGTH = 16;
28
- var CLAIM_FILE_PATTERN = /^[0-9a-f]{16}-(\d+)$/;
29
- var EXCLUSIVE_CREATE = "wx";
30
- var ALREADY_EXISTS = "EEXIST";
31
- var WINDOWS_KEPT_BEHIND = 1;
32
- var reportWindowOf = (now) => Math.floor(now / CLIENT_REPORT_WINDOW_MS);
33
- var claimFileName = (key, window) => `${createHash("sha256").update(key).digest("hex").slice(0, CLAIM_KEY_HASH_LENGTH)}-${window}`;
34
- var errorCodeOf = (error) => typeof error === "object" && error !== null && "code" in error && typeof error.code === "string" ? error.code : null;
35
- var claimWindowOf = (fileName) => {
36
- const match = CLAIM_FILE_PATTERN.exec(fileName);
37
- return match ? Number(match[1]) : null;
38
- };
39
- var isStaleClaim = (fileName, window) => {
40
- const claimedWindow = claimWindowOf(fileName);
41
- return claimedWindow !== null && claimedWindow < window - WINDOWS_KEPT_BEHIND;
42
- };
43
- var removeQuietly = (filePath) => {
44
- try {
45
- unlinkSync(filePath);
46
- } catch {
47
- return;
48
- }
49
- };
50
- var removeStaleClaims = (claimsDir, window) => {
51
- try {
52
- for (const fileName of readdirSync(claimsDir)) {
53
- if (isStaleClaim(fileName, window)) removeQuietly(join(claimsDir, fileName));
54
- }
55
- } catch {
56
- return;
57
- }
58
- };
59
- var claimReportWindow = (claimsDir, key, now) => {
60
- const window = reportWindowOf(now);
61
- try {
62
- mkdirSync(claimsDir, { recursive: true, mode: CLAIM_DIRECTORY_MODE });
63
- closeSync(openSync(join(claimsDir, claimFileName(key, window)), EXCLUSIVE_CREATE, CLAIM_FILE_MODE));
64
- } catch (error) {
65
- return errorCodeOf(error) === ALREADY_EXISTS ? "already_claimed" : "unavailable";
66
- }
67
- removeStaleClaims(claimsDir, window);
68
- return "claimed";
69
- };
70
-
71
- // src/client-report.ts
72
- var CLIENT_REPORT_TIMEOUT_MS = 1e3;
73
- var readApiKey = () => {
74
- try {
75
- return getApiKey();
76
- } catch {
77
- return null;
78
- }
79
- };
80
- var defaultDeps = () => ({
81
- disabled: () => isDisabledByEnv(process.env, CLIENT_REPORT_DISABLE_ENV),
82
- fetchImpl: fetch,
83
- apiKey: readApiKey,
84
- baseUrl: getBaseUrl,
85
- now: Date.now,
86
- claimsDir: clientReportClaims()
87
- });
88
- var reportKey = (event) => `${event.kind}:${event.code}`;
89
- var createClientErrorReporter = (deps) => {
90
- const windowClaimedInProcess = /* @__PURE__ */ new Map();
91
- const claimInProcess = (key, now) => {
92
- if (windowClaimedInProcess.get(key) === reportWindowOf(now)) return false;
93
- windowClaimedInProcess.set(key, reportWindowOf(now));
94
- return true;
95
- };
96
- const claimReport = (key, now) => {
97
- const claim = claimReportWindow(deps.claimsDir, key, now);
98
- return claim === "unavailable" ? claimInProcess(key, now) : claim === "claimed";
99
- };
100
- return async (event) => {
101
- try {
102
- if (deps.disabled()) return;
103
- const apiKey = deps.apiKey();
104
- const now = deps.now();
105
- if (!apiKey || !claimReport(reportKey(event), now)) return;
106
- await deps.fetchImpl(`${deps.baseUrl()}${CLIENT_REPORT_PATH}`, {
107
- method: "POST",
108
- headers: { "Authorization": `Bearer ${apiKey}`, "Content-Type": "application/json" },
109
- body: JSON.stringify({ ...event, occurredAt: new Date(now).toISOString() }),
110
- signal: AbortSignal.timeout(CLIENT_REPORT_TIMEOUT_MS)
111
- });
112
- } catch {
113
- return;
114
- }
115
- };
116
- };
117
- var processReporter = null;
118
- var inFlightReports = /* @__PURE__ */ new Set();
119
- var reportClientError = (event) => {
120
- processReporter ??= createClientErrorReporter(defaultDeps());
121
- const report = processReporter(event);
122
- inFlightReports.add(report);
123
- void report.finally(() => inFlightReports.delete(report));
124
- return report;
125
- };
126
- var exitAfterClientReports = async (code) => {
127
- await Promise.all(inFlightReports);
128
- return process.exit(code);
129
- };
130
- var clientErrorKindOf = (error) => isNetworkFailure(error) ? "network" : "unexpected";
131
- var writeDegraded = (subsystem, report) => {
132
- process.stderr.write(`${degradedLine(subsystem, report)}
133
- `);
134
- void reportClientError({ kind: "degraded", code: `${subsystem}:${report.reason}` });
135
- };
136
-
137
- export {
138
- reportClientError,
139
- exitAfterClientReports,
140
- clientErrorKindOf,
141
- writeDegraded
142
- };