pushary 1.9.110 → 1.9.112

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 (128) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/{api-4MS4CPKY.js → api-3AWH6PR6.js} +11 -11
  3. package/dist/bin/pushary-audit.js +3 -3
  4. package/dist/bin/pushary-bell-hook.js +27 -27
  5. package/dist/bin/pushary-bell.js +10 -10
  6. package/dist/bin/pushary-claude.js +25 -25
  7. package/dist/bin/pushary-clean.js +34 -34
  8. package/dist/bin/pushary-codex-bridge.js +21 -21
  9. package/dist/bin/pushary-codex-hook.js +32 -32
  10. package/dist/bin/pushary-codex-session.js +8 -8
  11. package/dist/bin/pushary-codex.js +15 -15
  12. package/dist/bin/pushary-connect.js +28 -28
  13. package/dist/bin/pushary-cowork.js +5 -5
  14. package/dist/bin/pushary-daemon.js +66 -484
  15. package/dist/bin/pushary-disconnect.js +27 -27
  16. package/dist/bin/pushary-display-hook.js +17 -17
  17. package/dist/bin/pushary-doctor.js +42 -42
  18. package/dist/bin/pushary-elicitation-hook.js +27 -27
  19. package/dist/bin/pushary-gemini-bridge.js +15 -15
  20. package/dist/bin/pushary-gemini-hook.js +29 -29
  21. package/dist/bin/pushary-hook.js +32 -32
  22. package/dist/bin/pushary-login.js +21 -21
  23. package/dist/bin/pushary-logout.js +26 -26
  24. package/dist/bin/pushary-mcp.js +12 -12
  25. package/dist/bin/pushary-mode.js +15 -15
  26. package/dist/bin/pushary-notification-hook.js +26 -26
  27. package/dist/bin/pushary-opencode-hook.js +28 -28
  28. package/dist/bin/pushary-permission-denied-hook.js +32 -32
  29. package/dist/bin/pushary-permission-hook.js +32 -32
  30. package/dist/bin/pushary-post-hook.js +26 -26
  31. package/dist/bin/pushary-prompt-hook.js +26 -26
  32. package/dist/bin/pushary-session-end-hook.js +26 -26
  33. package/dist/bin/pushary-session-start-hook.js +35 -35
  34. package/dist/bin/pushary-setup.js +61 -47
  35. package/dist/bin/pushary-stats.js +5 -5
  36. package/dist/bin/pushary-status.js +32 -32
  37. package/dist/bin/pushary-stop-hook.js +26 -26
  38. package/dist/bin/pushary-stopfailure-hook.js +26 -26
  39. package/dist/bin/pushary-suggestions.js +15 -15
  40. package/dist/bin/pushary-transcript-register.js +17 -17
  41. package/dist/bin/pushary-transcripts.js +25 -25
  42. package/dist/bin/pushary-upgrade.js +40 -40
  43. package/dist/bin/pushary-wait.js +15 -15
  44. package/dist/bin/pushary.js +7 -7
  45. package/dist/{chunk-WEWTT7FE.js → chunk-2SCXLYWI.js} +1 -1
  46. package/dist/{chunk-NMSRA7QO.js → chunk-2Y2HEOT6.js} +459 -28
  47. package/dist/{chunk-I2LPRMDP.js → chunk-3JCT4ABX.js} +34 -13
  48. package/dist/{chunk-ZCFPKN72.js → chunk-4D53JUQC.js} +4 -4
  49. package/dist/{chunk-HENHPRJN.js → chunk-5CHFR4SM.js} +6 -6
  50. package/dist/{chunk-AZBKSMYC.js → chunk-5HEKYLZD.js} +1 -1
  51. package/dist/{chunk-LJH2QDF3.js → chunk-5TWYZGZY.js} +10 -10
  52. package/dist/{chunk-T72BV3CU.js → chunk-66FYIYTH.js} +4 -4
  53. package/dist/{chunk-2U54YY4M.js → chunk-6DWWTT2K.js} +3 -3
  54. package/dist/{chunk-JPR4S254.js → chunk-7M5QJE24.js} +3 -3
  55. package/dist/{chunk-QYBQCMRP.js → chunk-BATGR3LA.js} +1 -1
  56. package/dist/{chunk-S7ZX7V5S.js → chunk-BI7NKEEZ.js} +1 -1
  57. package/dist/{chunk-NGZB5BVO.js → chunk-BJ6INBM6.js} +6 -6
  58. package/dist/{chunk-2MJL3ZVW.js → chunk-BNZOA7RL.js} +1 -1
  59. package/dist/{chunk-FBDUY6RN.js → chunk-BS3IFLU4.js} +1 -1
  60. package/dist/{chunk-JDIWIRUN.js → chunk-BSZNW4BV.js} +6 -6
  61. package/dist/{chunk-MZDFTXXO.js → chunk-D37U7BKX.js} +1 -1
  62. package/dist/{chunk-NBNWMQH4.js → chunk-D6KWDBL5.js} +3 -3
  63. package/dist/{chunk-5RWBSMCI.js → chunk-DO63NPJX.js} +18 -13
  64. package/dist/{chunk-M6EYOBLJ.js → chunk-DRXRTLL4.js} +5 -5
  65. package/dist/{chunk-UWQKGWBF.js → chunk-EKIA5CSV.js} +1 -1
  66. package/dist/{chunk-KAG2BWDB.js → chunk-F7F5PTQE.js} +6 -6
  67. package/dist/{chunk-TTDJHOYY.js → chunk-FF3UYU76.js} +3 -3
  68. package/dist/{chunk-YLLQZ6MR.js → chunk-FUFJKR53.js} +2 -2
  69. package/dist/{chunk-DLS43QDO.js → chunk-FWFOABQJ.js} +1 -1
  70. package/dist/{chunk-G2TL4OEY.js → chunk-GJWBVRPF.js} +1 -1
  71. package/dist/{chunk-PKN4XIBP.js → chunk-HNR23BLB.js} +2 -2
  72. package/dist/{chunk-3OLVEVGW.js → chunk-IAI6ZRVA.js} +6 -6
  73. package/dist/{chunk-TR6AJV4Z.js → chunk-IFJ3XS2R.js} +2 -2
  74. package/dist/{chunk-WKXSLMKC.js → chunk-J3THYTYM.js} +4 -4
  75. package/dist/{chunk-JMQORTFD.js → chunk-JG75WTA6.js} +2 -2
  76. package/dist/{chunk-GOUUFBBP.js → chunk-JY2QQNS4.js} +3 -3
  77. package/dist/{chunk-KS3OJ4C2.js → chunk-KBPUTWVR.js} +2 -2
  78. package/dist/{chunk-MOBSQM4B.js → chunk-KJFCQ5I5.js} +15 -3
  79. package/dist/{chunk-DZMKNP3I.js → chunk-KSPVTLCC.js} +1 -1
  80. package/dist/{chunk-FE4CSARF.js → chunk-KZ56PDQ2.js} +3 -3
  81. package/dist/{chunk-6ZPGNVXS.js → chunk-LWVOQZ24.js} +3 -3
  82. package/dist/{chunk-3FQTC27T.js → chunk-M52Q62SO.js} +7 -7
  83. package/dist/{chunk-WGQIJJIS.js → chunk-M6U4CXYS.js} +1 -1
  84. package/dist/chunk-MMHO6RWH.js +454 -0
  85. package/dist/{chunk-DP62DH2Q.js → chunk-MQTXIY32.js} +6 -6
  86. package/dist/{chunk-XNMSVXB4.js → chunk-MZOJR4TO.js} +3 -3
  87. package/dist/{chunk-FLH5MJOS.js → chunk-O465JWZH.js} +3 -3
  88. package/dist/{chunk-3QZSG2L4.js → chunk-OL5DDV6T.js} +1 -1
  89. package/dist/{chunk-CTBH3E3Z.js → chunk-OW3WQWBA.js} +2 -2
  90. package/dist/{chunk-CUOFHW7F.js → chunk-OXME4ZAD.js} +4 -4
  91. package/dist/{chunk-TKXM3QYK.js → chunk-P27ZXTQ6.js} +2 -2
  92. package/dist/{chunk-DSA5E7IB.js → chunk-PDB5DALK.js} +5 -5
  93. package/dist/{chunk-E4ZZMAWF.js → chunk-PFZGAUTM.js} +1 -1
  94. package/dist/{chunk-TBJ4OMO4.js → chunk-PKVNCWKH.js} +5 -5
  95. package/dist/{chunk-2Q4V4ZP4.js → chunk-QGZ4BPFE.js} +4 -4
  96. package/dist/{chunk-OKZR3LFO.js → chunk-QVGVFLKO.js} +4 -4
  97. package/dist/{chunk-DOHQKE4Y.js → chunk-QXRW4G7Q.js} +2 -2
  98. package/dist/{chunk-4LRFQMTQ.js → chunk-RDUOOCAQ.js} +10 -10
  99. package/dist/{chunk-DQKTKMR3.js → chunk-RXIZTNVQ.js} +3 -3
  100. package/dist/{chunk-XF3K42EV.js → chunk-SLMDTNKA.js} +3 -3
  101. package/dist/{chunk-UNHXJLHP.js → chunk-SOVLQH6W.js} +5 -5
  102. package/dist/{chunk-S2FLLNQI.js → chunk-SZQKXQIX.js} +2 -2
  103. package/dist/{chunk-TJUDVI2Y.js → chunk-TC6TGMST.js} +2 -2
  104. package/dist/{chunk-X3ROGIHG.js → chunk-TCRITVSK.js} +1 -1
  105. package/dist/{chunk-AXOY7CKN.js → chunk-TFZUWGXG.js} +14 -14
  106. package/dist/{chunk-OJZ3CVGK.js → chunk-TTIMLMWS.js} +5 -5
  107. package/dist/{chunk-SQR7GGOH.js → chunk-UEXWOQWA.js} +5 -5
  108. package/dist/{chunk-ALA2OMOM.js → chunk-UORHVH4P.js} +1 -1
  109. package/dist/{chunk-5IRJERK2.js → chunk-VQ4C6Y2C.js} +2 -2
  110. package/dist/{chunk-NQAY6G3S.js → chunk-VTK353JE.js} +4 -4
  111. package/dist/{chunk-FYSQQW6Q.js → chunk-WOI2LYGL.js} +2 -2
  112. package/dist/{chunk-WKBXLLDY.js → chunk-WQ5FG3ED.js} +5 -5
  113. package/dist/{chunk-FRY3LB5N.js → chunk-YAULUCRG.js} +2 -2
  114. package/dist/{chunk-BCZSRQ3L.js → chunk-ZF2GMORS.js} +1 -1
  115. package/dist/{codex-app-cards-switch-MPIXI3DK.js → codex-app-cards-switch-XJAPXIM4.js} +11 -11
  116. package/dist/{codex-card-routing-YQIWKPSG.js → codex-card-routing-MT2V4TZW.js} +2 -2
  117. package/dist/{codex-desktop-launch-GTKUXNPD.js → codex-desktop-launch-T236LJJF.js} +1 -1
  118. package/dist/{codex-session-launch-AHYAAGRT.js → codex-session-launch-AHN34OHP.js} +18 -18
  119. package/dist/{config-XMZVS6DQ.js → config-DVOF7LRQ.js} +3 -3
  120. package/dist/{global-upgrade-CBBBQIWS.js → global-upgrade-RMJEXXYL.js} +9 -9
  121. package/dist/{identity-OQXQU2WN.js → identity-3GG54AII.js} +4 -4
  122. package/dist/{live-capabilities-3UHWJHLY.js → live-capabilities-AF5VHAIS.js} +4 -4
  123. package/dist/{paths-GMKZGF5F.js → paths-IAK4623I.js} +3 -3
  124. package/dist/{reapply-C3WFUQZA.js → reapply-HTAXDM76.js} +28 -28
  125. package/dist/src/index.js +31 -31
  126. package/dist/{upgrade-lock-J6MD575X.js → upgrade-lock-CNS3ST2M.js} +4 -4
  127. package/dist/{usage-KYQUBGEW.js → usage-GPRH7WHQ.js} +3 -3
  128. package/package.json +1 -1
@@ -0,0 +1,454 @@
1
+ import {
2
+ MANAGED_CLAUDE_SETTINGS_BY_PLATFORM
3
+ } from "./chunk-P27ZXTQ6.js";
4
+ import {
5
+ declinedAgentsFile,
6
+ readDeclinedAgents
7
+ } from "./chunk-YAULUCRG.js";
8
+ import {
9
+ OPENCODE_HOOK_BINARY,
10
+ openCodeConfigDir,
11
+ openCodePluginArgv,
12
+ openCodePluginFile
13
+ } from "./chunk-DRXRTLL4.js";
14
+ import {
15
+ liveCursorGateCoverage
16
+ } from "./chunk-QVGVFLKO.js";
17
+ import {
18
+ compatibleConfigFile,
19
+ compatibleHookEvents,
20
+ grokHome,
21
+ parseConfigDocument
22
+ } from "./chunk-WQ5FG3ED.js";
23
+ import {
24
+ DEFAULT_HOOKS_KEY_PATH,
25
+ GEMINI_HOOK_BINARY,
26
+ GEMINI_HOOK_EVENTS,
27
+ hooksAt
28
+ } from "./chunk-66FYIYTH.js";
29
+ import {
30
+ CODEX_EARLIER_APPROVAL_MATCHERS,
31
+ CODEX_HOOK_BINARY,
32
+ CODEX_HOOK_EVENTS,
33
+ NO_SPOTLIGHT,
34
+ bridgeCache,
35
+ bridgeStub,
36
+ claudeConfigDir,
37
+ claudeSettings,
38
+ claudeSettingsLocal,
39
+ codexConfigToml,
40
+ codexHome,
41
+ codexHookPositions,
42
+ codexHooksFeatureDisabled,
43
+ codexHooksJson,
44
+ codexTrustGaps,
45
+ cursorUserHooks,
46
+ geminiSettings,
47
+ hookBinaryNameOf,
48
+ hookExecutableName,
49
+ installedBridgeBundleRoots,
50
+ isBridgeLocator,
51
+ liveBridgeProbe,
52
+ macAppBridgeIsInstalled,
53
+ parseHookArgv,
54
+ parseHookCommand,
55
+ supportedClaudeEvents
56
+ } from "./chunk-WOI2LYGL.js";
57
+ import {
58
+ readRegularJsonFile,
59
+ readRegularTextFile
60
+ } from "./chunk-T5I4PKOQ.js";
61
+ import {
62
+ CURSOR_GATE_EVENTS,
63
+ CURSOR_GATE_SCRIPT,
64
+ HOOK_COMPATIBLE_PROFILES,
65
+ HOOK_WIRING_PROFILE_LENGTH,
66
+ HOOK_WIRING_REPORT_VERSION,
67
+ OPENCODE_APPROVAL_EVENT,
68
+ isRecord,
69
+ matcherMatchesEveryCall
70
+ } from "./chunk-2Y2HEOT6.js";
71
+
72
+ // src/hook-wiring.ts
73
+ import { createHash } from "crypto";
74
+ import { realpathSync, statSync } from "fs";
75
+ import { homedir } from "os";
76
+ import { dirname, isAbsolute, resolve } from "path";
77
+ var HOOK_WIRING_MAX_FILE_BYTES = 16 * 1024 * 1024;
78
+ var COMMAND_HOOK_TYPE = "command";
79
+ var CODEX_TRUST_GAPS_THAT_SWITCH_OFF = /* @__PURE__ */ new Set(["disabled", "asynchronous"]);
80
+ var CODEX_TRUST_GAP_UNTRUSTED = "untrusted";
81
+ var MATCHER_ALTERNATIVE_SEPARATOR = "|";
82
+ var SIMPLE_CLAUDE_CODE_MATCHER = /^[a-zA-Z0-9_|]+$/;
83
+ var TABLE_PATTERN_WILDCARD = ".*";
84
+ var TABLE_PATTERN_SAMPLE = "probe";
85
+ var UNRESTRICTED_MATCHER_PROBES = ["Bash", "Write", "Edit", "Read", "apply_patch", "run_shell_command", "mcp__probe__tool", "probe"];
86
+ var EXECUTE_BITS = 73;
87
+ var WINDOWS_PLATFORM = "win32";
88
+ var NO_EVENTS = /* @__PURE__ */ new Set();
89
+ var NO_HANDLERS = /* @__PURE__ */ new Map();
90
+ var NO_EARLIER_MATCHERS = {};
91
+ var approvalEventsOf = (definitions, binaryOf, earlierMatchers = NO_EARLIER_MATCHERS) => definitions.filter((definition) => definition.delivery === "approval").map((definition) => ({
92
+ event: definition.event,
93
+ binary: binaryOf(definition),
94
+ matcher: definition.matcher ?? null,
95
+ earlierMatchers: earlierMatchers[definition.event] ?? [],
96
+ cliOnly: definition.cliOnly === true
97
+ }));
98
+ var eventsWithBinary = (events, binary) => events.map((event) => ({ event, binary, matcher: null, earlierMatchers: [], cliOnly: false }));
99
+ var CODEX_APPROVAL_EVENTS = approvalEventsOf(CODEX_HOOK_EVENTS, () => CODEX_HOOK_BINARY, CODEX_EARLIER_APPROVAL_MATCHERS);
100
+ var hookWiringAgentOf = (target) => {
101
+ switch (target.kind) {
102
+ case "claude":
103
+ return "claude";
104
+ case "codex":
105
+ return "codex";
106
+ case "gemini":
107
+ return "gemini";
108
+ case "cursor":
109
+ return "cursor";
110
+ case "opencode":
111
+ return "opencode";
112
+ case "compatible":
113
+ return target.profile.source;
114
+ }
115
+ };
116
+ var hookWiringApprovalEvents = (target) => {
117
+ switch (target.kind) {
118
+ case "claude":
119
+ return approvalEventsOf(supportedClaudeEvents(null), (hook) => hook.binary);
120
+ case "codex":
121
+ return CODEX_APPROVAL_EVENTS;
122
+ case "gemini":
123
+ return approvalEventsOf(GEMINI_HOOK_EVENTS, () => GEMINI_HOOK_BINARY);
124
+ case "cursor":
125
+ return eventsWithBinary(CURSOR_GATE_EVENTS, hookBinaryNameOf(CURSOR_GATE_SCRIPT));
126
+ case "opencode":
127
+ return eventsWithBinary([OPENCODE_APPROVAL_EVENT], OPENCODE_HOOK_BINARY);
128
+ case "compatible":
129
+ return approvalEventsOf(compatibleHookEvents(target.profile), (hook) => hook.binary);
130
+ }
131
+ };
132
+ var configFileOf = (target) => {
133
+ switch (target.kind) {
134
+ case "claude":
135
+ case "gemini":
136
+ return target.settingsFile;
137
+ case "opencode":
138
+ return target.pluginFile;
139
+ case "codex":
140
+ case "cursor":
141
+ case "compatible":
142
+ return target.hooksFile;
143
+ }
144
+ };
145
+ var hooksKeyPathOf = (target) => target.kind === "compatible" ? target.profile.hooksKeyPath : DEFAULT_HOOKS_KEY_PATH;
146
+ var handlerTypeOf = (target) => target.kind === "cursor" ? "optional" : "required";
147
+ var hookWiringProfileOf = (machineId, configFile) => createHash("sha256").update(`${machineId}\0${resolve(configFile)}`, "utf8").digest("hex").slice(0, HOOK_WIRING_PROFILE_LENGTH);
148
+ var requiredApprovalEvents = (events, owner) => events.filter((event) => !(event.cliOnly && owner === "app")).map((event) => event.event);
149
+ var isSwitchedOff = (reading, required) => reading.switchedOff || reading.trustGaps.some((gap) => CODEX_TRUST_GAPS_THAT_SWITCH_OFF.has(gap.kind) && required.has(gap.event));
150
+ var isUntrusted = (reading, required) => reading.trustGaps.some((gap) => gap.kind === CODEX_TRUST_GAP_UNTRUSTED && required.has(gap.event));
151
+ var weakeningOf = (switchedOff, wiring) => {
152
+ if (switchedOff) return "switched_off";
153
+ if (wiring.missing.length > 0) return "events_missing";
154
+ return wiring.narrowed.length > 0 ? "matcher_narrowed" : null;
155
+ };
156
+ var guardedStateOf = (reading, required) => isUntrusted(reading, required) ? "untrusted" : "wired";
157
+ var requiredEventWiringOf = (required, wiredEvents, narrowedEvents) => ({
158
+ missing: required.filter((event) => !wiredEvents.has(event) && !narrowedEvents.has(event)),
159
+ narrowed: required.filter((event) => !wiredEvents.has(event) && narrowedEvents.has(event))
160
+ });
161
+ var hookWiringOf = (reading) => {
162
+ if (!reading.configDirExists) return null;
163
+ const base = { agent: reading.agent, profile: reading.profile };
164
+ if (reading.hooks.kind === "unreadable") {
165
+ return { ...base, state: reading.declined ? "disconnected" : "unreadable", owner: null };
166
+ }
167
+ const owner = reading.hooks.kind === "read" ? reading.hooks.owner : null;
168
+ if (reading.declined) return { ...base, state: "disconnected", owner };
169
+ const required = requiredApprovalEvents(reading.approvalEvents, owner);
170
+ const wiring = reading.hooks.kind === "read" ? requiredEventWiringOf(required, reading.hooks.wiredEvents, reading.hooks.narrowedEvents) : requiredEventWiringOf(required, NO_EVENTS, NO_EVENTS);
171
+ if (wiring.missing.length === required.length) return { ...base, state: "missing", owner };
172
+ const requiredSet = new Set(required);
173
+ const weakenedBy = weakeningOf(isSwitchedOff(reading, requiredSet), wiring);
174
+ if (weakenedBy) {
175
+ return { ...base, state: "weakened", owner, weakenedBy, ...wiring.missing.length > 0 ? { missing: wiring.missing } : {} };
176
+ }
177
+ return { ...base, state: guardedStateOf(reading, requiredSet), owner };
178
+ };
179
+ var isCommandHandler = (handler, handlerType) => handler.type === COMMAND_HOOK_TYPE || handlerType === "optional" && handler.type === void 0;
180
+ var handlerOf = (handler, matcher, handlerType) => {
181
+ if (!isCommandHandler(handler, handlerType) || typeof handler.command !== "string") return [];
182
+ const command = parseHookCommand(handler.command);
183
+ return command ? [{ raw: handler.command, command, matcher }] : [];
184
+ };
185
+ var handlersInEntry = (entry, handlerType) => {
186
+ if (!isRecord(entry)) return [];
187
+ if (!Array.isArray(entry.hooks)) return handlerOf(entry, entry.matcher, handlerType);
188
+ return entry.hooks.filter(isRecord).flatMap((handler) => handlerOf(handler, entry.matcher, handlerType));
189
+ };
190
+ var handlersOnEvent = (entries, handlerType) => Array.isArray(entries) ? entries.flatMap((entry) => handlersInEntry(entry, handlerType)) : [];
191
+ var handlersByEventIn = (hooks, handlerType) => new Map(isRecord(hooks) ? Object.entries(hooks).map(([event, entries]) => [event, handlersOnEvent(entries, handlerType)]) : []);
192
+ var matcherAlternatives = (matcher) => matcher.split(MATCHER_ALTERNATIVE_SEPARATOR);
193
+ var compiledMatcher = (matcher) => {
194
+ try {
195
+ return new RegExp(matcher);
196
+ } catch {
197
+ return null;
198
+ }
199
+ };
200
+ var regexToolMatch = (matcher) => {
201
+ const pattern = compiledMatcher(matcher);
202
+ return (tool) => pattern !== null && pattern.test(tool);
203
+ };
204
+ var toolMatchOf = (semantics, matcher) => {
205
+ if (semantics === "regex" || !SIMPLE_CLAUDE_CODE_MATCHER.test(matcher)) return regexToolMatch(matcher);
206
+ const names = new Set(matcherAlternatives(matcher));
207
+ return (tool) => names.has(tool);
208
+ };
209
+ var tableToolSamples = (tableMatcher) => matcherAlternatives(tableMatcher).map((alternative) => alternative.replaceAll(TABLE_PATTERN_WILDCARD, TABLE_PATTERN_SAMPLE));
210
+ var coverageOfSamples = (samples, matches) => {
211
+ const matched = samples.filter(matches).length;
212
+ if (matched === samples.length) return "covers";
213
+ return matched > 0 ? "narrows" : "misses";
214
+ };
215
+ var unrestrictedEventCoverage = (matcher, matches, event) => {
216
+ if (UNRESTRICTED_MATCHER_PROBES.every(matches)) return "covers";
217
+ return event.earlierMatchers.includes(matcher) ? "narrows" : "misses";
218
+ };
219
+ var tableMatcherCoverage = (semantics) => (matcher, event) => {
220
+ if (matcherMatchesEveryCall(matcher)) return "covers";
221
+ if (typeof matcher !== "string") return "misses";
222
+ const matches = toolMatchOf(semantics, matcher);
223
+ if (event.matcher === null) return unrestrictedEventCoverage(matcher, matches, event);
224
+ return coverageOfSamples(tableToolSamples(event.matcher), matches);
225
+ };
226
+ var matcherSemanticsOf = (target) => target.kind === "codex" || target.kind === "gemini" ? "regex" : "claude_code";
227
+ var coverageDecidedElsewhere = () => "covers";
228
+ var runsBinary = (command, binary, context) => {
229
+ if (!command.runsExecutable) return false;
230
+ if (isBridgeLocator(command.executable)) return context.isLiveBridge(command.executable);
231
+ return hookExecutableName(command.executable) === binary && context.isRunnableBinary(command);
232
+ };
233
+ var coveredHandlerOf = (handler, event, coverageOf) => {
234
+ const coverage = coverageOf(handler.matcher, event);
235
+ return coverage === "misses" ? [] : [{ handler, coverage }];
236
+ };
237
+ var approvalHandlersOn = (handlersByEvent, event, context, coverageOf) => ({
238
+ event,
239
+ handlers: (handlersByEvent.get(event.event) ?? []).filter((handler) => runsBinary(handler.command, event.binary, context)).flatMap((handler) => coveredHandlerOf(handler, event, coverageOf))
240
+ });
241
+ var coversTableMatcher = (approval) => approval.handlers.some((covered) => covered.coverage === "covers");
242
+ var isBridgeHandler = (handler) => isBridgeLocator(handler.command.executable);
243
+ var hasLiveBridgeAnywhere = (handlersByEvent, isLiveBridge) => [...handlersByEvent.values()].flat().some((handler) => handler.command.runsExecutable && isBridgeHandler(handler) && isLiveBridge(handler.command.executable));
244
+ var approvalOwnerOf = (running, liveBridgeAnywhere) => {
245
+ const covering = running.flatMap((approval) => approval.handlers.filter((covered) => covered.coverage === "covers").map((covered) => covered.handler));
246
+ if (covering.length > 0) return covering.some(isBridgeHandler) ? "app" : "cli";
247
+ if (running.some((approval) => approval.handlers.some((covered) => !isBridgeHandler(covered.handler)))) return "cli";
248
+ return liveBridgeAnywhere ? "app" : null;
249
+ };
250
+ var eventNamesOf = (approvals) => new Set(approvals.map((approval) => approval.event.event));
251
+ var approvalWiringOf = (handlersByEvent, events, context, coverageOf) => {
252
+ const running = events.map((event) => approvalHandlersOn(handlersByEvent, event, context, coverageOf)).filter((approval) => approval.handlers.length > 0);
253
+ return {
254
+ owner: approvalOwnerOf(running, hasLiveBridgeAnywhere(handlersByEvent, context.isLiveBridge)),
255
+ wiredEvents: eventNamesOf(running.filter(coversTableMatcher)),
256
+ narrowedEvents: eventNamesOf(running.filter((approval) => !coversTableMatcher(approval)))
257
+ };
258
+ };
259
+ var readJsonDocument = (path) => {
260
+ const result = readRegularJsonFile(path, HOOK_WIRING_MAX_FILE_BYTES);
261
+ if (result.kind === "missing") return { kind: "missing" };
262
+ if (result.kind === "ok" && isRecord(result.value)) return { kind: "read", document: result.value };
263
+ return { kind: "unreadable" };
264
+ };
265
+ var jsonDocumentOrEmpty = (path) => {
266
+ if (path === null) return {};
267
+ const reading = readJsonDocument(path);
268
+ return reading.kind === "read" ? reading.document : {};
269
+ };
270
+ var textOrNull = (path) => {
271
+ const result = readRegularTextFile(path, HOOK_WIRING_MAX_FILE_BYTES);
272
+ return result.kind === "ok" ? result.value : null;
273
+ };
274
+ var tomlDocumentOrEmpty = (path) => {
275
+ const document = parseConfigDocument(textOrNull(path), "toml");
276
+ return document.kind === "parsed" ? document.value : {};
277
+ };
278
+ var handlersIn = (document, target) => handlersByEventIn(hooksAt(document, hooksKeyPathOf(target)), handlerTypeOf(target));
279
+ var tableFileReading = (reading, target, context) => reading.kind === "read" ? { kind: "read", ...approvalWiringOf(handlersIn(reading.document, target), hookWiringApprovalEvents(target), context, tableMatcherCoverage(matcherSemanticsOf(target))) } : reading;
280
+ var cursorFileReading = (target, context) => {
281
+ const reading = readJsonDocument(target.hooksFile);
282
+ if (reading.kind !== "read") return reading;
283
+ const wiring = approvalWiringOf(handlersIn(reading.document, target), hookWiringApprovalEvents(target), context, coverageDecidedElsewhere);
284
+ const coverage = liveCursorGateCoverage(reading.document, { hooksFile: target.hooksFile, probe: context.probe });
285
+ const runsPushary = (event) => wiring.wiredEvents.has(event);
286
+ return {
287
+ kind: "read",
288
+ owner: wiring.owner,
289
+ wiredEvents: new Set(coverage.full.filter(runsPushary)),
290
+ narrowedEvents: new Set(coverage.partial.filter(runsPushary))
291
+ };
292
+ };
293
+ var openCodeHandlers = (argv) => {
294
+ const command = parseHookArgv(argv);
295
+ return command ? /* @__PURE__ */ new Map([[OPENCODE_APPROVAL_EVENT, [{ raw: argv.join(" "), command, matcher: void 0 }]]]) : NO_HANDLERS;
296
+ };
297
+ var openCodeFileReading = (target, context) => {
298
+ const result = readRegularTextFile(target.pluginFile, HOOK_WIRING_MAX_FILE_BYTES);
299
+ if (result.kind === "missing") return { kind: "missing" };
300
+ if (result.kind !== "ok") return { kind: "unreadable" };
301
+ const handlersByEvent = openCodeHandlers(openCodePluginArgv(result.value) ?? []);
302
+ return { kind: "read", ...approvalWiringOf(handlersByEvent, hookWiringApprovalEvents(target), context, tableMatcherCoverage(matcherSemanticsOf(target))) };
303
+ };
304
+ var isDirectory = (path) => {
305
+ try {
306
+ return statSync(path).isDirectory();
307
+ } catch {
308
+ return false;
309
+ }
310
+ };
311
+ var claudeHooksSwitchedOff = (user, local, managed) => [user, local, managed].some((settings) => settings.disableAllHooks === true) || managed.allowManagedHooksOnly === true;
312
+ var codexTrustCommandIn = (document) => {
313
+ const handlersByEvent = handlersByEventIn(hooksAt(document, DEFAULT_HOOKS_KEY_PATH), "required");
314
+ const handlers = CODEX_APPROVAL_EVENTS.flatMap((event) => handlersByEvent.get(event.event) ?? []);
315
+ return handlers.find((handler) => hookExecutableName(handler.command.executable) === CODEX_HOOK_BINARY)?.raw ?? "";
316
+ };
317
+ var codexHookTrustGapsIn = (config, document, hooksFile) => codexTrustGaps(config, document, hooksFile, codexTrustCommandIn(document), codexHookPositions(document));
318
+ var CODEX_HOOKS_UNREADABLE = { kind: "unreadable" };
319
+ var readCodexHooksOnDisk = (configFile, hooksFile) => {
320
+ const config = parseConfigDocument(textOrNull(configFile), "toml");
321
+ const hooks = readJsonDocument(hooksFile);
322
+ if (config.kind !== "parsed" || hooks.kind !== "read") return CODEX_HOOKS_UNREADABLE;
323
+ return {
324
+ kind: "read",
325
+ hooksFeatureOff: codexHooksFeatureDisabled(config.value),
326
+ gaps: codexHookTrustGapsIn(config.value, hooks.document, hooksFile)
327
+ };
328
+ };
329
+ var UNSWITCHED = { switchedOff: false, trustGaps: [] };
330
+ var readClaudeTarget = (target, context) => {
331
+ const settings = readJsonDocument(target.settingsFile);
332
+ return {
333
+ hooks: tableFileReading(settings, target, context),
334
+ switchedOff: claudeHooksSwitchedOff(
335
+ settings.kind === "read" ? settings.document : {},
336
+ jsonDocumentOrEmpty(target.localSettingsFile),
337
+ jsonDocumentOrEmpty(target.managedSettingsFile)
338
+ ),
339
+ trustGaps: []
340
+ };
341
+ };
342
+ var readCodexTarget = (target, context) => {
343
+ const hooksDocument = readJsonDocument(target.hooksFile);
344
+ const hooks = tableFileReading(hooksDocument, target, context);
345
+ if (hooksDocument.kind !== "read") return { hooks, ...UNSWITCHED };
346
+ const config = tomlDocumentOrEmpty(target.configFile);
347
+ return {
348
+ hooks,
349
+ switchedOff: codexHooksFeatureDisabled(config),
350
+ trustGaps: codexHookTrustGapsIn(config, hooksDocument.document, target.hooksFile)
351
+ };
352
+ };
353
+ var readAgentSpecific = (target, context) => {
354
+ switch (target.kind) {
355
+ case "claude":
356
+ return readClaudeTarget(target, context);
357
+ case "codex":
358
+ return readCodexTarget(target, context);
359
+ case "opencode":
360
+ return { hooks: openCodeFileReading(target, context), ...UNSWITCHED };
361
+ case "cursor":
362
+ return { hooks: cursorFileReading(target, context), ...UNSWITCHED };
363
+ case "gemini":
364
+ case "compatible":
365
+ return { hooks: tableFileReading(readJsonDocument(configFileOf(target)), target, context), ...UNSWITCHED };
366
+ }
367
+ };
368
+ var readHookWiringTarget = (target, machineId, declined, context) => {
369
+ const agent = hookWiringAgentOf(target);
370
+ return {
371
+ agent,
372
+ profile: hookWiringProfileOf(machineId, configFileOf(target)),
373
+ configDirExists: isDirectory(target.configDir),
374
+ declined: declined.has(agent),
375
+ approvalEvents: hookWiringApprovalEvents(target),
376
+ ...readAgentSpecific(target, context)
377
+ };
378
+ };
379
+ var realpathOrNull = (path) => {
380
+ try {
381
+ return realpathSync(path);
382
+ } catch {
383
+ return null;
384
+ }
385
+ };
386
+ var canonicalLiveBridge = (location, probe) => {
387
+ const stub = realpathOrNull(location.stub);
388
+ if (stub === null || !macAppBridgeIsInstalled(location, probe)) return () => false;
389
+ return (executable) => isAbsolute(executable) && isBridgeLocator(executable) && realpathOrNull(executable) === stub;
390
+ };
391
+ var regularFileMode = (path) => {
392
+ try {
393
+ const stats = statSync(path);
394
+ return stats.isFile() ? stats.mode : null;
395
+ } catch {
396
+ return null;
397
+ }
398
+ };
399
+ var runnableBinaryCheck = (platform) => (command) => {
400
+ if (!isAbsolute(command.executable)) return false;
401
+ const mode = regularFileMode(command.executable);
402
+ if (mode === null) return false;
403
+ return command.runsThroughNode || platform === WINDOWS_PLATFORM || (mode & EXECUTE_BITS) !== 0;
404
+ };
405
+ var hookWiringReadContext = (bridge, platform) => {
406
+ const probe = { ...liveBridgeProbe(), readFile: textOrNull, mdfind: NO_SPOTLIGHT };
407
+ return { probe, isLiveBridge: canonicalLiveBridge(bridge, probe), isRunnableBinary: runnableBinaryCheck(platform) };
408
+ };
409
+ var compatibleConfigDirOf = (profile, hooksFile) => profile.configFile.root === "grok_home" ? grokHome() : dirname(hooksFile);
410
+ var compatibleTarget = (profile) => {
411
+ const hooksFile = compatibleConfigFile(profile);
412
+ return { kind: "compatible", profile, configDir: compatibleConfigDirOf(profile, hooksFile), hooksFile };
413
+ };
414
+ var hookWiringLocations = (platform = process.platform) => ({
415
+ declinedAgentsFile: declinedAgentsFile(),
416
+ bridge: { stub: bridgeStub(), cache: bridgeCache(), bundleRoots: installedBridgeBundleRoots(homedir()) },
417
+ targets: [
418
+ {
419
+ kind: "claude",
420
+ configDir: claudeConfigDir(),
421
+ settingsFile: claudeSettings(),
422
+ localSettingsFile: claudeSettingsLocal(),
423
+ managedSettingsFile: MANAGED_CLAUDE_SETTINGS_BY_PLATFORM[platform] ?? null
424
+ },
425
+ { kind: "codex", configDir: codexHome(), hooksFile: codexHooksJson(), configFile: codexConfigToml() },
426
+ { kind: "gemini", configDir: dirname(geminiSettings()), settingsFile: geminiSettings() },
427
+ { kind: "cursor", configDir: dirname(cursorUserHooks()), hooksFile: cursorUserHooks() },
428
+ { kind: "opencode", configDir: openCodeConfigDir(), pluginFile: openCodePluginFile() },
429
+ ...HOOK_COMPATIBLE_PROFILES.map(compatibleTarget)
430
+ ]
431
+ });
432
+ var readHookWiring = (machineId, locations = hookWiringLocations()) => {
433
+ const declined = new Set(readDeclinedAgents(locations.declinedAgentsFile));
434
+ const context = hookWiringReadContext(locations.bridge, process.platform);
435
+ const agents = locations.targets.flatMap((target) => {
436
+ const entry = hookWiringOf(readHookWiringTarget(target, machineId, declined, context));
437
+ return entry ? [entry] : [];
438
+ });
439
+ return { version: HOOK_WIRING_REPORT_VERSION, agents };
440
+ };
441
+ var readHookWiringSafely = (read, reportFailure) => {
442
+ try {
443
+ return read();
444
+ } catch (error) {
445
+ reportFailure(error);
446
+ return null;
447
+ }
448
+ };
449
+
450
+ export {
451
+ readCodexHooksOnDisk,
452
+ readHookWiring,
453
+ readHookWiringSafely
454
+ };
@@ -6,21 +6,21 @@ import {
6
6
  McpToolError,
7
7
  SubscriptionRequiredError,
8
8
  callMcpTool
9
- } from "./chunk-OJZ3CVGK.js";
9
+ } from "./chunk-TTIMLMWS.js";
10
10
  import {
11
11
  installNetworkDefaults,
12
12
  isNetworkFailure
13
- } from "./chunk-XNMSVXB4.js";
13
+ } from "./chunk-MZOJR4TO.js";
14
14
  import {
15
15
  fetchAsCredential
16
- } from "./chunk-DZMKNP3I.js";
16
+ } from "./chunk-KSPVTLCC.js";
17
17
  import {
18
18
  clientReportClaims
19
- } from "./chunk-FYSQQW6Q.js";
19
+ } from "./chunk-WOI2LYGL.js";
20
20
  import {
21
21
  getApiKey,
22
22
  getBaseUrl
23
- } from "./chunk-QYBQCMRP.js";
23
+ } from "./chunk-BATGR3LA.js";
24
24
  import {
25
25
  ASK_AGENT_NAME_MAX,
26
26
  CLIENT_REPORT_PATH,
@@ -29,7 +29,7 @@ import {
29
29
  TOOL_FAILURE_CODES,
30
30
  degradedLine,
31
31
  truncateLine
32
- } from "./chunk-NMSRA7QO.js";
32
+ } from "./chunk-2Y2HEOT6.js";
33
33
 
34
34
  // src/api.ts
35
35
  import { randomUUID } from "crypto";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  readExistingMachineId
3
- } from "./chunk-G2TL4OEY.js";
3
+ } from "./chunk-GJWBVRPF.js";
4
4
  import {
5
5
  getBaseUrl
6
- } from "./chunk-QYBQCMRP.js";
6
+ } from "./chunk-BATGR3LA.js";
7
7
  import {
8
8
  NetworkError
9
9
  } from "./chunk-YU2EUD7O.js";
@@ -13,7 +13,7 @@ import {
13
13
  import {
14
14
  clientContextHeaders,
15
15
  redactSecretsFromContent
16
- } from "./chunk-NMSRA7QO.js";
16
+ } from "./chunk-2Y2HEOT6.js";
17
17
 
18
18
  // src/cli/net.ts
19
19
  import { createRequire } from "module";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  SETUP_FLAGS
3
- } from "./chunk-MZDFTXXO.js";
3
+ } from "./chunk-D37U7BKX.js";
4
4
  import {
5
5
  parseFlags
6
6
  } from "./chunk-YPY4YCIZ.js";
@@ -9,7 +9,7 @@ import {
9
9
  } from "./chunk-YU2EUD7O.js";
10
10
  import {
11
11
  NPX_LATEST_COMMAND
12
- } from "./chunk-DLS43QDO.js";
12
+ } from "./chunk-FWFOABQJ.js";
13
13
  import {
14
14
  CLAUDE_CONNECTOR_GUIDE,
15
15
  CLAUDE_CONNECTOR_STEPS,
@@ -17,7 +17,7 @@ import {
17
17
  CLAUDE_CONNECTOR_URL,
18
18
  COWORK_CONNECTOR_LIMIT,
19
19
  COWORK_STANDING_INSTRUCTIONS
20
- } from "./chunk-NMSRA7QO.js";
20
+ } from "./chunk-2Y2HEOT6.js";
21
21
 
22
22
  // src/cli/cowork.ts
23
23
  import { readFileSync } from "fs";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  guardBinary
3
- } from "./chunk-FYSQQW6Q.js";
3
+ } from "./chunk-WOI2LYGL.js";
4
4
 
5
5
  // src/bell/install.ts
6
6
  import { join } from "path";
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-POFBE6ZY.js";
4
4
  import {
5
5
  autoUpdateState
6
- } from "./chunk-FYSQQW6Q.js";
6
+ } from "./chunk-WOI2LYGL.js";
7
7
  import {
8
8
  readJsonSafe,
9
9
  writeJsonAtomic
@@ -17,7 +17,7 @@ import {
17
17
  } from "./chunk-ZVU6WMMU.js";
18
18
  import {
19
19
  isAutoUpdateResult
20
- } from "./chunk-NMSRA7QO.js";
20
+ } from "./chunk-2Y2HEOT6.js";
21
21
 
22
22
  // src/auto-update.ts
23
23
  import { spawn } from "child_process";
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  compatibleConfigFile,
3
3
  hasCompatibleHooks
4
- } from "./chunk-WKBXLLDY.js";
4
+ } from "./chunk-WQ5FG3ED.js";
5
5
  import {
6
6
  pusharyHookExecutable
7
- } from "./chunk-T72BV3CU.js";
7
+ } from "./chunk-66FYIYTH.js";
8
8
  import {
9
9
  isProtectedByScope,
10
10
  registerHookEntry
11
- } from "./chunk-FYSQQW6Q.js";
11
+ } from "./chunk-WOI2LYGL.js";
12
12
  import {
13
13
  isRecord
14
- } from "./chunk-NMSRA7QO.js";
14
+ } from "./chunk-2Y2HEOT6.js";
15
15
 
16
16
  // src/cursor-config.ts
17
17
  var hookCommandOf = (entry) => {
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  claudeConfigDir
3
- } from "./chunk-FYSQQW6Q.js";
3
+ } from "./chunk-WOI2LYGL.js";
4
4
  import {
5
5
  claudePermissionRulesFromSettings
6
- } from "./chunk-NMSRA7QO.js";
6
+ } from "./chunk-2Y2HEOT6.js";
7
7
 
8
8
  // src/claude-permission-rules.ts
9
9
  import { readFileSync, statSync } from "fs";
@@ -4,13 +4,13 @@ import {
4
4
  configFailureKind,
5
5
  retryAgentCommand,
6
6
  writeSetupConfigFile
7
- } from "./chunk-TTDJHOYY.js";
7
+ } from "./chunk-FF3UYU76.js";
8
8
  import {
9
9
  MCP_BRIDGE_BINARY
10
- } from "./chunk-NBNWMQH4.js";
10
+ } from "./chunk-D6KWDBL5.js";
11
11
  import {
12
12
  KEY_FILE_MODE
13
- } from "./chunk-XF3K42EV.js";
13
+ } from "./chunk-SLMDTNKA.js";
14
14
  import {
15
15
  CLINE_SERVER_NAME_TAKEN,
16
16
  CLINE_SETTINGS_REFUSALS,
@@ -32,10 +32,10 @@ import {
32
32
  withClinePusharyServer,
33
33
  withRefreshedClineKey,
34
34
  withoutClinePusharyServer
35
- } from "./chunk-FYSQQW6Q.js";
35
+ } from "./chunk-WOI2LYGL.js";
36
36
  import {
37
37
  resolveGlobalBinary
38
- } from "./chunk-DQKTKMR3.js";
38
+ } from "./chunk-RXIZTNVQ.js";
39
39
  import {
40
40
  readJsonSafe,
41
41
  writeFileAtomic,
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-BG4HHB7E.js";
4
4
  import {
5
5
  renderCommandHelp
6
- } from "./chunk-DLS43QDO.js";
6
+ } from "./chunk-FWFOABQJ.js";
7
7
  import {
8
8
  getPackageVersion
9
9
  } from "./chunk-ZVU6WMMU.js";
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  readMacAppAgentKey
3
- } from "./chunk-NQAY6G3S.js";
3
+ } from "./chunk-VTK353JE.js";
4
4
  import {
5
5
  API_KEYS_PATH
6
- } from "./chunk-5IRJERK2.js";
6
+ } from "./chunk-VQ4C6Y2C.js";
7
7
  import {
8
8
  absoluteUrl
9
- } from "./chunk-GOUUFBBP.js";
9
+ } from "./chunk-JY2QQNS4.js";
10
10
  import {
11
11
  findExportedKeyLines,
12
12
  isAdoptedMacAppKey,
@@ -16,10 +16,10 @@ import {
16
16
  readConfigFileKey,
17
17
  readKeySource,
18
18
  readMacAppKeyPrefix
19
- } from "./chunk-XF3K42EV.js";
19
+ } from "./chunk-SLMDTNKA.js";
20
20
  import {
21
21
  isValidApiKey
22
- } from "./chunk-NMSRA7QO.js";
22
+ } from "./chunk-2Y2HEOT6.js";
23
23
 
24
24
  // src/key-revocation.ts
25
25
  var SELF_REVOKE_PATH = "/api/v1/server/keys/self/revoke";