@pushary/agent-hooks 1.9.158 → 1.9.162

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 (146) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +1 -0
  3. package/dist/{api-MRFKFDVV.js → api-7NPCSUGY.js} +17 -13
  4. package/dist/bin/pushary-audit.js +7 -7
  5. package/dist/bin/pushary-bell-hook.js +31 -31
  6. package/dist/bin/pushary-bell.js +16 -16
  7. package/dist/bin/pushary-calls.d.ts +1 -0
  8. package/dist/bin/pushary-calls.js +287 -0
  9. package/dist/bin/pushary-claude.js +37 -37
  10. package/dist/bin/pushary-clean.js +47 -45
  11. package/dist/bin/pushary-codex-bridge.js +27 -27
  12. package/dist/bin/pushary-codex-hook.js +197 -60
  13. package/dist/bin/pushary-codex-session.js +8 -8
  14. package/dist/bin/pushary-codex.js +19 -19
  15. package/dist/bin/pushary-connect.js +41 -40
  16. package/dist/bin/pushary-cowork.js +6 -6
  17. package/dist/bin/pushary-daemon.js +52 -51
  18. package/dist/bin/pushary-disconnect.js +39 -37
  19. package/dist/bin/pushary-display-hook.js +20 -1
  20. package/dist/bin/pushary-doctor.js +61 -59
  21. package/dist/bin/pushary-elicitation-hook.js +32 -32
  22. package/dist/bin/pushary-gemini-bridge.js +19 -19
  23. package/dist/bin/pushary-gemini-hook.js +36 -36
  24. package/dist/bin/pushary-hook.js +39 -38
  25. package/dist/bin/pushary-login.js +28 -28
  26. package/dist/bin/pushary-logout.js +34 -33
  27. package/dist/bin/pushary-mcp.js +15 -15
  28. package/dist/bin/pushary-mode.js +21 -21
  29. package/dist/bin/pushary-notification-hook.js +30 -30
  30. package/dist/bin/pushary-opencode-hook.js +399 -45
  31. package/dist/bin/pushary-permission-denied-hook.js +39 -38
  32. package/dist/bin/pushary-permission-hook.js +39 -38
  33. package/dist/bin/pushary-post-hook.js +31 -31
  34. package/dist/bin/pushary-prompt-hook.js +30 -30
  35. package/dist/bin/pushary-session-end-hook.js +30 -30
  36. package/dist/bin/pushary-session-start-hook.js +41 -40
  37. package/dist/bin/pushary-setup.js +73 -72
  38. package/dist/bin/pushary-stats.js +6 -6
  39. package/dist/bin/pushary-status.js +40 -39
  40. package/dist/bin/pushary-stop-hook.js +30 -30
  41. package/dist/bin/pushary-stopfailure-hook.js +30 -30
  42. package/dist/bin/pushary-suggestions.js +21 -21
  43. package/dist/bin/pushary-transcript-register.js +21 -21
  44. package/dist/bin/pushary-transcripts.js +32 -32
  45. package/dist/bin/pushary-upgrade.js +50 -49
  46. package/dist/bin/pushary-wait.js +23 -23
  47. package/dist/bin/pushary.js +10 -9
  48. package/dist/{chunk-RRVFN432.js → chunk-2H7SDIM7.js} +1 -1
  49. package/dist/{chunk-DHI3X5WK.js → chunk-44DRCGP2.js} +2 -2
  50. package/dist/chunk-4IBUBMMP.js +885 -0
  51. package/dist/{chunk-RL5JLDRE.js → chunk-4U3GYVIW.js} +2 -2
  52. package/dist/{chunk-NW63PGKF.js → chunk-53IBMDX2.js} +12 -7
  53. package/dist/{chunk-XNJ2HOEL.js → chunk-5TU26542.js} +3 -3
  54. package/dist/{chunk-UVWKMFLQ.js → chunk-5ZS73ZLX.js} +2 -2
  55. package/dist/{chunk-4SN4FHFZ.js → chunk-644AKJMN.js} +2 -2
  56. package/dist/{chunk-TZJR5ESF.js → chunk-6QQUGYH6.js} +7 -7
  57. package/dist/{chunk-4B5K6YIP.js → chunk-72SYV43F.js} +1 -1
  58. package/dist/{chunk-JKRQL2BL.js → chunk-A5DXHJVS.js} +5 -5
  59. package/dist/{chunk-K3OCYJPK.js → chunk-AP26EU5H.js} +3 -3
  60. package/dist/{chunk-MLPPQ556.js → chunk-AQKMKVAD.js} +13 -13
  61. package/dist/{chunk-N5SSADNW.js → chunk-BHT76IIB.js} +4 -4
  62. package/dist/{chunk-TMWXWBFP.js → chunk-BMOGTNLK.js} +6 -6
  63. package/dist/{chunk-SNQOEDZ2.js → chunk-CSDB5VTI.js} +1 -1
  64. package/dist/{chunk-YPFOTFEG.js → chunk-CWH4LBUW.js} +1 -1
  65. package/dist/{chunk-FTTSQAF4.js → chunk-DAMTDSAE.js} +1 -1
  66. package/dist/{chunk-MHYX5Q3F.js → chunk-DSWUG4NV.js} +1 -1
  67. package/dist/{chunk-K3I2NMEF.js → chunk-EFKJCBWA.js} +8 -8
  68. package/dist/{chunk-CIAJ55EQ.js → chunk-EKELMI3A.js} +42 -34
  69. package/dist/{chunk-EGBI4GRS.js → chunk-EPQTCF6A.js} +2 -2
  70. package/dist/{chunk-4WL2MINE.js → chunk-FIR2MGSB.js} +1 -1
  71. package/dist/{chunk-N2LWKWNY.js → chunk-G5IL6C6S.js} +3 -3
  72. package/dist/{chunk-IKC33YKC.js → chunk-G6M6YJK4.js} +5 -2
  73. package/dist/{chunk-SZMDRBNK.js → chunk-GJOHGES6.js} +2 -2
  74. package/dist/{chunk-TPLTB256.js → chunk-H7OY4AAT.js} +4 -4
  75. package/dist/{chunk-IVOELLUK.js → chunk-HAOYL5JP.js} +39 -8
  76. package/dist/{chunk-Q7WCDUFV.js → chunk-I35XT5YY.js} +6 -6
  77. package/dist/{chunk-AOP55JR2.js → chunk-I5ANEYUK.js} +14 -3
  78. package/dist/{chunk-TKBCLK4B.js → chunk-I5HCOOAA.js} +5 -5
  79. package/dist/{chunk-IIK3CZXJ.js → chunk-IUXXEM4Q.js} +8 -7
  80. package/dist/{chunk-FGVBFDNV.js → chunk-J6KDUXJF.js} +1 -1
  81. package/dist/{chunk-XHCX6DOY.js → chunk-JCTS7COD.js} +5 -5
  82. package/dist/{chunk-AGYD6XNI.js → chunk-L3LFCZ5D.js} +3 -3
  83. package/dist/{chunk-3QU4WXAH.js → chunk-L44II2WD.js} +5 -5
  84. package/dist/{chunk-PBPQRJ2T.js → chunk-L6BMVCQQ.js} +5 -5
  85. package/dist/{chunk-LVZBLKAU.js → chunk-L6NG6EZS.js} +1 -1
  86. package/dist/{chunk-EHRWEXRN.js → chunk-LGR7WXI5.js} +2 -2
  87. package/dist/{chunk-2MPT7YQK.js → chunk-LQDIOUVU.js} +5 -3
  88. package/dist/{chunk-XSIZKQ2C.js → chunk-LVRFOGQY.js} +11 -11
  89. package/dist/{chunk-HA2SRYYP.js → chunk-M2ZGNZRS.js} +94 -0
  90. package/dist/{chunk-ZYDE6QRW.js → chunk-M74WT5NA.js} +3 -3
  91. package/dist/chunk-NX3Y36VY.js +242 -0
  92. package/dist/{chunk-ANQBLZAE.js → chunk-OH2WAG47.js} +1 -1
  93. package/dist/{chunk-GTYVNVBZ.js → chunk-P4KAYIMX.js} +4 -4
  94. package/dist/{chunk-4I2SHNEU.js → chunk-PIIKLAFY.js} +3 -3
  95. package/dist/{chunk-J7HSUQK2.js → chunk-QKNHNDOY.js} +3 -3
  96. package/dist/{chunk-ALQWZCUT.js → chunk-RKURAOFK.js} +4 -4
  97. package/dist/{chunk-TYBVQ33X.js → chunk-RUAGEPUJ.js} +6 -6
  98. package/dist/{chunk-IOKJJ2SY.js → chunk-SFYX32FX.js} +4 -4
  99. package/dist/{chunk-OCWXE4PR.js → chunk-SKA3U7QI.js} +11 -9
  100. package/dist/{chunk-X254TRBU.js → chunk-SQ4RPZ6O.js} +4 -4
  101. package/dist/chunk-SRSXZINE.js +18 -0
  102. package/dist/{chunk-CAMFNSJS.js → chunk-SVVZFXDX.js} +6 -6
  103. package/dist/{chunk-QVVBU2JU.js → chunk-SVWCMYR7.js} +24 -9
  104. package/dist/{chunk-MTITL2IG.js → chunk-TMDCIVZ2.js} +5 -5
  105. package/dist/{chunk-B3BOAYRO.js → chunk-TUXX7TKR.js} +3 -3
  106. package/dist/{chunk-CSZWWPNS.js → chunk-U4LHE5DH.js} +1 -1
  107. package/dist/{chunk-3UNZ7HRN.js → chunk-UBY7NJCU.js} +20 -18
  108. package/dist/{chunk-ORQ7THNZ.js → chunk-UPCIKGWA.js} +1 -1
  109. package/dist/{chunk-WIIMW5YO.js → chunk-UQTQ6HPO.js} +2 -0
  110. package/dist/{chunk-V36P4KS4.js → chunk-V3TWYF32.js} +1 -1
  111. package/dist/{chunk-N3CFEMLS.js → chunk-VGLIGBAJ.js} +6 -6
  112. package/dist/{chunk-PND5IGC7.js → chunk-VUGF2OC7.js} +6 -6
  113. package/dist/{chunk-APCJZFTJ.js → chunk-W3FE7GTH.js} +1 -1
  114. package/dist/{chunk-GHHVXARK.js → chunk-WCWWO5QL.js} +1 -1
  115. package/dist/{chunk-TSR3FPGL.js → chunk-WIFMTEQI.js} +1 -1
  116. package/dist/{chunk-AMIUB22C.js → chunk-WWSR5LMP.js} +1 -1
  117. package/dist/{chunk-CCKY3JDB.js → chunk-X5QSIMXA.js} +4 -4
  118. package/dist/{chunk-T3PZQNIK.js → chunk-XIICM4TX.js} +2 -2
  119. package/dist/{chunk-C6PAIHLP.js → chunk-XOSSXRIR.js} +10 -10
  120. package/dist/{chunk-QP3TCKRZ.js → chunk-Y3ELKLNH.js} +18 -16
  121. package/dist/{chunk-H6CL3T2S.js → chunk-Y6ILCLKE.js} +1 -1
  122. package/dist/{chunk-UDLWNOXX.js → chunk-YEVRMDG7.js} +2 -2
  123. package/dist/{chunk-CS4Z44F5.js → chunk-YH6EHCKQ.js} +87 -8
  124. package/dist/{chunk-2L52USKM.js → chunk-YPG3RXWO.js} +3 -3
  125. package/dist/{chunk-AZZNHW3R.js → chunk-YUF3AYAP.js} +9 -6
  126. package/dist/{chunk-4NHQAMSK.js → chunk-Z23SHFIC.js} +4 -4
  127. package/dist/{chunk-6GGK3T24.js → chunk-ZC42UG7B.js} +5 -5
  128. package/dist/{chunk-UPI3JDHZ.js → chunk-ZT55PJSW.js} +3 -3
  129. package/dist/{chunk-PI3BOI3A.js → chunk-ZWNFP4HZ.js} +1 -1
  130. package/dist/{codex-app-cards-switch-CXXDGH7R.js → codex-app-cards-switch-PJEY3EU5.js} +14 -14
  131. package/dist/{codex-card-routing-WP4IHJFN.js → codex-card-routing-MNAMCRPO.js} +2 -2
  132. package/dist/{codex-desktop-launch-EN7ACHC6.js → codex-desktop-launch-AUNDRYOL.js} +1 -1
  133. package/dist/{codex-session-launch-7BV4VTJW.js → codex-session-launch-IZNSTT7N.js} +23 -23
  134. package/dist/{config-SZMMBOJV.js → config-LG2RJO37.js} +4 -4
  135. package/dist/{global-upgrade-I5J6BDHA.js → global-upgrade-QE5Q3BYW.js} +11 -11
  136. package/dist/{identity-GLJNTNHW.js → identity-3BT6LWOP.js} +5 -5
  137. package/dist/{live-capabilities-AYO7FOHS.js → live-capabilities-IKTQBLVH.js} +5 -5
  138. package/dist/{paths-NRBEF3T2.js → paths-VEUTZJOY.js} +4 -4
  139. package/dist/reapply-BC2AF55M.js +69 -0
  140. package/dist/src/index.js +39 -38
  141. package/dist/{upgrade-lock-H6SU7MJR.js → upgrade-lock-NUGEPR75.js} +5 -5
  142. package/dist/usage-TEB5CX2Y.js +11 -0
  143. package/package.json +2 -1
  144. package/dist/chunk-GLDSXDRV.js +0 -593
  145. package/dist/reapply-J2QUV7J2.js +0 -68
  146. package/dist/usage-MY3DIFBG.js +0 -11
@@ -0,0 +1,242 @@
1
+ import {
2
+ OPENCODE_FAILED_EVENT,
3
+ OPENCODE_IDLE_EVENT,
4
+ OPENCODE_PLUGIN_DIR,
5
+ OPENCODE_PLUGIN_FILE,
6
+ OPENCODE_PLUGIN_SIBLING,
7
+ OPENCODE_PLUGIN_SIBLING_CONTENTS,
8
+ OPENCODE_SUBAGENT_IDLE_EVENT,
9
+ isOpenCodePluginOurs,
10
+ openCodePluginArgv,
11
+ openCodePluginModule,
12
+ renderOpenCodePlugin
13
+ } from "./chunk-4IBUBMMP.js";
14
+ import {
15
+ compatibleConfigFile
16
+ } from "./chunk-TMDCIVZ2.js";
17
+ import {
18
+ hookOwnerOf,
19
+ hookOwnerOfCommands
20
+ } from "./chunk-H7OY4AAT.js";
21
+ import {
22
+ AGENT_CHOICES
23
+ } from "./chunk-J6KDUXJF.js";
24
+ import {
25
+ OPENCODE_INSTRUCTIONS_LABEL,
26
+ bridgeStub,
27
+ claudeSettings,
28
+ codexHooksJson,
29
+ cursorUserHooks,
30
+ geminiSettings,
31
+ guardedArgv,
32
+ liveBridgeProbe,
33
+ renderAgentInstructions,
34
+ resolveBridgeStub,
35
+ vscodePluginDir,
36
+ windowsNodeLauncherFor
37
+ } from "./chunk-TUXX7TKR.js";
38
+ import {
39
+ readJsonSafe
40
+ } from "./chunk-TODDEIYG.js";
41
+ import {
42
+ HOOK_BUDGETS,
43
+ HOOK_COMPATIBLE_PROFILES,
44
+ OPENCODE_APPROVAL_EVENT,
45
+ hookCompatibleProfile,
46
+ isRecord
47
+ } from "./chunk-M2ZGNZRS.js";
48
+
49
+ // src/opencode-config.ts
50
+ import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from "fs";
51
+ import { homedir } from "os";
52
+ import { join } from "path";
53
+ var OPENCODE_HOOK_BINARY = "pushary-opencode-hook";
54
+ var OPENCODE_HOOK_ARGS = ["--source", "opencode"];
55
+ var openCodeHookArgv = (resolvedBinary, platform = process.platform) => guardedArgv({ kind: "binary", path: resolvedBinary ?? OPENCODE_HOOK_BINARY, runtime: "node" }, OPENCODE_HOOK_ARGS, platform, windowsNodeLauncherFor(platform));
56
+ var openCodeConfigDirFrom = (home, env = process.env) => env.OPENCODE_CONFIG_DIR?.trim() || join(env.XDG_CONFIG_HOME?.trim() || join(home, ".config"), "opencode");
57
+ var openCodeConfigDir = () => openCodeConfigDirFrom(homedir());
58
+ var OPENCODE_PLUGIN_PATH = `${OPENCODE_PLUGIN_DIR}/${OPENCODE_PLUGIN_FILE}`;
59
+ var openCodePluginDir = () => join(openCodeConfigDir(), OPENCODE_PLUGIN_DIR);
60
+ var openCodePluginFile = () => join(openCodePluginDir(), OPENCODE_PLUGIN_FILE);
61
+ var OPENCODE_HOOK_EVENTS = [
62
+ { event: OPENCODE_APPROVAL_EVENT, delivery: "approval", timeout: HOOK_BUDGETS.opencode.budgetSeconds },
63
+ { event: "tool.execute.after", delivery: "telemetry", timeout: 10 },
64
+ { event: "chat.message", delivery: "telemetry", timeout: 10 },
65
+ { event: OPENCODE_IDLE_EVENT, delivery: "telemetry", timeout: 10 },
66
+ { event: OPENCODE_FAILED_EVENT, delivery: "telemetry", timeout: 10 },
67
+ { event: OPENCODE_SUBAGENT_IDLE_EVENT, delivery: "telemetry", timeout: 10 }
68
+ ];
69
+ var hasForeignPlugins = (entries) => entries.some((entry) => entry !== OPENCODE_PLUGIN_FILE && /\.(ts|js)$/.test(entry));
70
+ var installOpenCodePlugin = (argv, dir = openCodePluginDir()) => {
71
+ mkdirSync(dir, { recursive: true });
72
+ const plugin = join(dir, OPENCODE_PLUGIN_FILE);
73
+ writeFileSync(plugin, renderOpenCodePlugin(openCodePluginModule(), argv), "utf-8");
74
+ const sibling = join(dir, OPENCODE_PLUGIN_SIBLING);
75
+ if (existsSync(sibling)) return { plugin, wroteSibling: false };
76
+ writeFileSync(sibling, OPENCODE_PLUGIN_SIBLING_CONTENTS, "utf-8");
77
+ return { plugin, wroteSibling: true };
78
+ };
79
+ var openCodeWired = (dir = openCodePluginDir()) => {
80
+ try {
81
+ return isOpenCodePluginOurs(readFileSync(join(dir, OPENCODE_PLUGIN_FILE), "utf-8"));
82
+ } catch {
83
+ return false;
84
+ }
85
+ };
86
+ var OPENCODE_MCP_URL = "https://pushary.com/api/mcp/mcp";
87
+ var OPENCODE_CONFIG_FILE = "opencode.json";
88
+ var openCodeConfigFile = () => join(openCodeConfigDir(), OPENCODE_CONFIG_FILE);
89
+ var OPENCODE_INSTRUCTIONS_FILE = "AGENTS.md";
90
+ var openCodeInstructionsFile = () => join(openCodeConfigDir(), OPENCODE_INSTRUCTIONS_FILE);
91
+ var OPENCODE_QUESTION_TOOL = "question";
92
+ var OPENCODE_QUESTION_NOTE = `In OpenCode, this replaces the guidance above to prefer \`ask_user\`: ask with OpenCode's own \`${OPENCODE_QUESTION_TOOL}\` tool, one question per call. Pushary shows that question on the phone and the Mac notch as well, and the first answer, in the terminal or on the phone, is the one you receive. Do not ask the same question through \`ask_user\` too. Use the Pushary \`ask_user\` tool only when OpenCode has no \`${OPENCODE_QUESTION_TOOL}\` tool. When Pushary's tools are listed under Code Mode, as in OpenCode 2, call them inside \`execute\`, for example \`await tools.pushary.ask_user({ ... })\` and \`await tools.pushary.wait_for_answer({ ... })\`. Otherwise, as in OpenCode 1, they are direct tools such as \`pushary_ask_user\`.`;
93
+ var openCodeInstructionsBody = () => `${renderAgentInstructions(OPENCODE_INSTRUCTIONS_LABEL)}
94
+
95
+ ${OPENCODE_QUESTION_NOTE}`;
96
+ var OPENCODE_MAC_APP_QUESTION_NOTE = `In OpenCode, this replaces the guidance above to ask in the terminal while the user is there: ask every question through the Pushary \`ask_user\` tool, even while the user is at this terminal, and not through OpenCode's own \`${OPENCODE_QUESTION_TOOL}\` tool. When Pushary's tools are listed under Code Mode, call them inside \`execute\`, for example \`await tools.pushary.ask_user({ ... })\` and \`await tools.pushary.wait_for_answer({ ... })\`. Otherwise OpenCode lists them as direct tools such as \`pushary_ask_user\`. That includes a question the user asks you to put to them, such as "ask me a multiple choice question": use \`ask_user\` with type "select". Ask one question at a time and wait for its answer before asking the next. OpenCode's question prompt cannot reach the phone or the Mac notch, so a question asked there waits unseen once the user steps away. Ask in your reply or with the \`${OPENCODE_QUESTION_TOOL}\` tool instead only when a Pushary handoffAction tells you to ask here, or when Pushary's tools are listed under neither name or \`ask_user\` fails without a handoffAction.`;
97
+ var asRecord = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
98
+ var addOpenCodeMcpServer = (config, apiKey) => {
99
+ const servers = asRecord(config.mcp) ?? {};
100
+ servers.pushary = {
101
+ type: "remote",
102
+ url: OPENCODE_MCP_URL,
103
+ enabled: true,
104
+ headers: { Authorization: `Bearer ${apiKey}` }
105
+ };
106
+ config.mcp = servers;
107
+ };
108
+ var OPENCODE_ASKED_PERMISSIONS = ["bash", "edit", "webfetch"];
109
+ var PERMISSION_KEY = "permission";
110
+ var PERMISSIONS_KEY = "permissions";
111
+ var TOOLS_KEY = "tools";
112
+ var ASK_ACTION = "ask";
113
+ var ALLOW_ACTION = "allow";
114
+ var DENY_ACTION = "deny";
115
+ var ALL_PATTERNS = "*";
116
+ var RULE_EFFECTS = [ASK_ACTION, ALLOW_ACTION, DENY_ACTION];
117
+ var OPENCODE_ACTION_NAMES = {
118
+ bash: ["bash", "shell"],
119
+ edit: ["edit", "write", "patch"],
120
+ webfetch: ["webfetch"]
121
+ };
122
+ var escapedForPattern = (text) => text.replace(/[.+^${}()|[\]\\]/g, "\\$&").replaceAll("?", ".");
123
+ var keyMatches = (key, name) => new RegExp(`^${key.split(ALL_PATTERNS).map(escapedForPattern).join(".*")}$`).test(name);
124
+ var ruleNamesPermission = (permission) => ([key]) => OPENCODE_ACTION_NAMES[permission].some((name) => keyMatches(key, name));
125
+ var toolRules = (config) => Object.entries(asRecord(config[TOOLS_KEY]) ?? {}).filter(([, enabled]) => typeof enabled === "boolean").map(([key, enabled]) => [key, enabled ? ALLOW_ACTION : DENY_ACTION]);
126
+ var permissionRules = (config) => {
127
+ const permission = config[PERMISSION_KEY];
128
+ if (permission === void 0) return [];
129
+ const rules = asRecord(permission);
130
+ return rules ? Object.entries(rules) : [[ALL_PATTERNS, permission]];
131
+ };
132
+ var rulesInOrder = (config) => [...toolRules(config), ...permissionRules(config)];
133
+ var isNativeRule = (value) => {
134
+ const rule = asRecord(value);
135
+ return rule !== void 0 && typeof rule.action === "string" && typeof rule.resource === "string" && RULE_EFFECTS.includes(rule.effect);
136
+ };
137
+ var nativePermissionRules = (config) => {
138
+ const entries = config[PERMISSIONS_KEY];
139
+ if (!Array.isArray(entries)) return [];
140
+ return entries.filter(isNativeRule).map(({ action, resource, effect }) => [action, { [resource]: effect }]);
141
+ };
142
+ var effectiveRulesInOrder = (config) => [...rulesInOrder(config), ...nativePermissionRules(config)];
143
+ var actionOfRule = (value) => {
144
+ const patterns = asRecord(value);
145
+ return patterns ? patterns[ALL_PATTERNS] : value;
146
+ };
147
+ var holdsTheCall = (action) => action === ASK_ACTION || action === DENY_ACTION;
148
+ var withOpenCodeAskRules = (config) => {
149
+ const permission = config[PERMISSION_KEY];
150
+ const rules = asRecord(permission);
151
+ if (permission !== void 0 && !rules) return { config, change: { kind: "person-setting-kept" } };
152
+ const personRules = rulesInOrder(config);
153
+ const added = OPENCODE_ASKED_PERMISSIONS.filter((name) => !personRules.some(ruleNamesPermission(name)));
154
+ if (added.length === 0) return { config, change: { kind: "present" } };
155
+ const asks = Object.fromEntries(added.map((name) => [name, ASK_ACTION]));
156
+ return { config: { ...config, [PERMISSION_KEY]: { ...asks, ...rules } }, change: { kind: "added", added } };
157
+ };
158
+ var openCodePermissionsLeftOpen = (config) => {
159
+ const rules = effectiveRulesInOrder(asRecord(config) ?? {});
160
+ return OPENCODE_ASKED_PERMISSIONS.filter((name) => !holdsTheCall(
161
+ rules.filter(ruleNamesPermission(name)).map(([, value]) => actionOfRule(value)).filter((action) => action !== void 0).at(-1)
162
+ ));
163
+ };
164
+ var openCodeAskCheck = (config) => {
165
+ if (config.kind === "unreadable" || config.kind === "unparseable") return { kind: "unreadable" };
166
+ const value = config.kind === "ok" ? asRecord(config.value) ?? {} : {};
167
+ const open = openCodePermissionsLeftOpen(value);
168
+ if (open.length === 0) return { kind: "asks" };
169
+ const personRules = effectiveRulesInOrder(value);
170
+ const namedByPerson = (name) => personRules.some(ruleNamesPermission(name));
171
+ return { kind: "open", unset: open.filter((name) => !namedByPerson(name)), allowedByPerson: open.filter(namedByPerson) };
172
+ };
173
+ var removeOpenCodeMcpServer = (config) => {
174
+ const servers = asRecord(config.mcp);
175
+ if (!servers || !("pushary" in servers)) return false;
176
+ delete servers.pushary;
177
+ if (Object.keys(servers).length === 0) delete config.mcp;
178
+ return true;
179
+ };
180
+
181
+ // src/setup/agent-hook-owner.ts
182
+ import { readFileSync as readFileSync2 } from "fs";
183
+ import { join as join2 } from "path";
184
+ var COMPATIBLE_HOOK_FILES = Object.fromEntries(
185
+ HOOK_COMPATIBLE_PROFILES.map((profile) => [profile.agentType, () => compatibleConfigFile(profile)])
186
+ );
187
+ var HOOK_FILES = {
188
+ claude_code: claudeSettings,
189
+ codex: codexHooksJson,
190
+ gemini_cli: geminiSettings,
191
+ cursor: cursorUserHooks,
192
+ vscode: () => join2(vscodePluginDir(), "hooks", "hooks.json"),
193
+ ...COMPATIBLE_HOOK_FILES
194
+ };
195
+ var agentHookFile = (agent) => HOOK_FILES[agent]?.() ?? null;
196
+ var agentHooksKeyPath = (agent) => hookCompatibleProfile(agent)?.hooksKeyPath;
197
+ var readTextOrNull = (path) => {
198
+ try {
199
+ return readFileSync2(path, "utf-8");
200
+ } catch {
201
+ return null;
202
+ }
203
+ };
204
+ var openCodePluginOwner = (appAvailable) => {
205
+ const contents = readTextOrNull(openCodePluginFile());
206
+ return hookOwnerOfCommands(contents === null ? [] : openCodePluginArgv(contents) ?? [], appAvailable);
207
+ };
208
+ var agentHookOwner = (agent, appAvailable) => {
209
+ if (agent === "opencode") return openCodePluginOwner(appAvailable);
210
+ const file = agentHookFile(agent);
211
+ if (!file) return "none";
212
+ const document = readJsonSafe(file);
213
+ return hookOwnerOf(document.kind === "ok" && isRecord(document.value) ? document.value : null, appAvailable, agentHooksKeyPath(agent));
214
+ };
215
+ var cliOwnsAnyAgentHooks = (appAvailable) => AGENT_CHOICES.some((agent) => agentHookOwner(agent, appAvailable) === "cli");
216
+ var macAppBridgeAvailable = () => resolveBridgeStub(bridgeStub(), liveBridgeProbe()).kind === "bundle";
217
+
218
+ export {
219
+ OPENCODE_HOOK_BINARY,
220
+ openCodeHookArgv,
221
+ openCodeConfigDirFrom,
222
+ openCodeConfigDir,
223
+ openCodePluginDir,
224
+ openCodePluginFile,
225
+ hasForeignPlugins,
226
+ installOpenCodePlugin,
227
+ openCodeWired,
228
+ openCodeConfigFile,
229
+ openCodeInstructionsFile,
230
+ openCodeInstructionsBody,
231
+ addOpenCodeMcpServer,
232
+ OPENCODE_ASKED_PERMISSIONS,
233
+ withOpenCodeAskRules,
234
+ openCodePermissionsLeftOpen,
235
+ openCodeAskCheck,
236
+ removeOpenCodeMcpServer,
237
+ agentHookFile,
238
+ agentHooksKeyPath,
239
+ agentHookOwner,
240
+ cliOwnsAnyAgentHooks,
241
+ macAppBridgeAvailable
242
+ };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  isFinalCommandAckRefusal
3
- } from "./chunk-HA2SRYYP.js";
3
+ } from "./chunk-M2ZGNZRS.js";
4
4
 
5
5
  // src/command-ack-outcome.ts
6
6
  var SETTLED_ACK = { outcome: "settled" };
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  pusharyHookExecutable
3
- } from "./chunk-TPLTB256.js";
3
+ } from "./chunk-H7OY4AAT.js";
4
4
  import {
5
5
  bridgeResolvesToApp,
6
6
  cursorUserHooks,
7
7
  executableFileName,
8
8
  isBridgeLocator,
9
9
  liveBridgeProbe
10
- } from "./chunk-B3BOAYRO.js";
10
+ } from "./chunk-TUXX7TKR.js";
11
11
  import {
12
12
  atLeast,
13
13
  parseVersion
14
- } from "./chunk-IVOELLUK.js";
14
+ } from "./chunk-HAOYL5JP.js";
15
15
  import {
16
16
  CURSOR_GATE_COVERAGE,
17
17
  CURSOR_GATE_SCRIPT,
@@ -21,7 +21,7 @@ import {
21
21
  isCursorHookPayload,
22
22
  isRecord,
23
23
  toolsCoveredByGateEntry
24
- } from "./chunk-HA2SRYYP.js";
24
+ } from "./chunk-M2ZGNZRS.js";
25
25
 
26
26
  // src/cursor-gate-registration.ts
27
27
  import { dirname, isAbsolute, join, resolve } from "path";
@@ -4,10 +4,10 @@ import {
4
4
  } from "./chunk-352FIVVH.js";
5
5
  import {
6
6
  fetchAsCredential
7
- } from "./chunk-TSR3FPGL.js";
7
+ } from "./chunk-WIFMTEQI.js";
8
8
  import {
9
9
  getBaseUrl
10
- } from "./chunk-FTTSQAF4.js";
10
+ } from "./chunk-DAMTDSAE.js";
11
11
  import {
12
12
  writeJsonAtomicDurable
13
13
  } from "./chunk-TODDEIYG.js";
@@ -15,7 +15,7 @@ import {
15
15
  compressTranscriptRecord,
16
16
  redactSecretsFromContent,
17
17
  transcriptRecordPlaintext
18
- } from "./chunk-HA2SRYYP.js";
18
+ } from "./chunk-M2ZGNZRS.js";
19
19
 
20
20
  // src/transcript-recipient-pin.ts
21
21
  import { createHash } from "crypto";
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-POFBE6ZY.js";
4
4
  import {
5
5
  autoUpdateState
6
- } from "./chunk-B3BOAYRO.js";
6
+ } from "./chunk-TUXX7TKR.js";
7
7
  import {
8
8
  readJsonSafe,
9
9
  writeJsonAtomic
@@ -14,10 +14,10 @@ import {
14
14
  cliPackagePathSegments,
15
15
  globalUpgradeEntry,
16
16
  ownPackageRoot
17
- } from "./chunk-WIIMW5YO.js";
17
+ } from "./chunk-UQTQ6HPO.js";
18
18
  import {
19
19
  isAutoUpdateResult
20
- } from "./chunk-HA2SRYYP.js";
20
+ } from "./chunk-M2ZGNZRS.js";
21
21
 
22
22
  // src/auto-update.ts
23
23
  import { spawn } from "child_process";
@@ -1,18 +1,18 @@
1
1
  import {
2
2
  CODEX_HOOK_STATUS
3
- } from "./chunk-4NHQAMSK.js";
3
+ } from "./chunk-Z23SHFIC.js";
4
4
  import {
5
5
  HERMES_ALWAYS_ALLOWED_SHELL_RULE,
6
6
  HERMES_COMMAND_ALLOWLIST_KEY,
7
7
  HERMES_GATE_TOOLS_KEY,
8
8
  HERMES_SHELL_TOOL
9
- } from "./chunk-Q7WCDUFV.js";
9
+ } from "./chunk-I35XT5YY.js";
10
10
  import {
11
11
  retryAgentCommand
12
- } from "./chunk-2L52USKM.js";
12
+ } from "./chunk-YPG3RXWO.js";
13
13
  import {
14
14
  NPX_LATEST_COMMAND
15
- } from "./chunk-AOP55JR2.js";
15
+ } from "./chunk-I5ANEYUK.js";
16
16
 
17
17
  // src/setup/codex-trust.ts
18
18
  var CODEX_TRUST_TELEMETRY = {
@@ -3,27 +3,27 @@ import {
3
3
  expectedLaunchCapabilities,
4
4
  hasSpawnProvider,
5
5
  resolveControlPolicy
6
- } from "./chunk-AGYD6XNI.js";
6
+ } from "./chunk-L3LFCZ5D.js";
7
7
  import {
8
8
  daemonHasRemoteProof,
9
9
  daemonServiceManagerAvailable,
10
10
  hasDaemonServiceDefinition,
11
11
  readDaemonNeedsLogin,
12
12
  readDaemonStatus
13
- } from "./chunk-K3I2NMEF.js";
13
+ } from "./chunk-EFKJCBWA.js";
14
14
  import {
15
15
  getMachineId
16
- } from "./chunk-MHYX5Q3F.js";
16
+ } from "./chunk-DSWUG4NV.js";
17
17
  import {
18
18
  readControlMode,
19
19
  readKeySource
20
- } from "./chunk-ZYDE6QRW.js";
20
+ } from "./chunk-M74WT5NA.js";
21
21
  import {
22
22
  getBaseUrl
23
- } from "./chunk-FTTSQAF4.js";
23
+ } from "./chunk-DAMTDSAE.js";
24
24
  import {
25
25
  getPackageVersion
26
- } from "./chunk-WIIMW5YO.js";
26
+ } from "./chunk-UQTQ6HPO.js";
27
27
 
28
28
  // src/machines.ts
29
29
  import { hostname } from "os";
@@ -13,16 +13,16 @@ import {
13
13
  } from "./chunk-WHB622LP.js";
14
14
  import {
15
15
  keyPrefix
16
- } from "./chunk-ZYDE6QRW.js";
16
+ } from "./chunk-M74WT5NA.js";
17
17
  import {
18
18
  getBaseUrl
19
- } from "./chunk-FTTSQAF4.js";
19
+ } from "./chunk-DAMTDSAE.js";
20
20
  import {
21
21
  NPX_LATEST_COMMAND
22
- } from "./chunk-AOP55JR2.js";
22
+ } from "./chunk-I5ANEYUK.js";
23
23
  import {
24
24
  isValidApiKey
25
- } from "./chunk-HA2SRYYP.js";
25
+ } from "./chunk-M2ZGNZRS.js";
26
26
 
27
27
  // src/cli/login-ui.ts
28
28
  import { hostname } from "os";
@@ -1,31 +1,33 @@
1
1
  import {
2
2
  MANAGED_CLAUDE_SETTINGS_BY_PLATFORM
3
- } from "./chunk-RL5JLDRE.js";
3
+ } from "./chunk-4U3GYVIW.js";
4
4
  import {
5
5
  declinedAgentsFile,
6
6
  readDeclinedAgents
7
- } from "./chunk-UVWKMFLQ.js";
7
+ } from "./chunk-5ZS73ZLX.js";
8
8
  import {
9
9
  OPENCODE_HOOK_BINARY,
10
10
  openCodeConfigDir,
11
- openCodePluginArgv,
12
11
  openCodePluginFile
13
- } from "./chunk-GLDSXDRV.js";
12
+ } from "./chunk-NX3Y36VY.js";
13
+ import {
14
+ openCodePluginArgv
15
+ } from "./chunk-4IBUBMMP.js";
14
16
  import {
15
17
  liveCursorGateCoverage
16
- } from "./chunk-GTYVNVBZ.js";
18
+ } from "./chunk-P4KAYIMX.js";
17
19
  import {
18
20
  compatibleConfigFile,
19
21
  compatibleHookEvents,
20
22
  grokHome,
21
23
  parseConfigDocument
22
- } from "./chunk-MTITL2IG.js";
24
+ } from "./chunk-TMDCIVZ2.js";
23
25
  import {
24
26
  DEFAULT_HOOKS_KEY_PATH,
25
27
  GEMINI_HOOK_BINARY,
26
28
  GEMINI_HOOK_EVENTS,
27
29
  hooksAt
28
- } from "./chunk-TPLTB256.js";
30
+ } from "./chunk-H7OY4AAT.js";
29
31
  import {
30
32
  CODEX_EARLIER_APPROVAL_MATCHERS,
31
33
  CODEX_HOOK_BINARY,
@@ -53,7 +55,7 @@ import {
53
55
  parseHookArgv,
54
56
  parseHookCommand,
55
57
  supportedClaudeEvents
56
- } from "./chunk-B3BOAYRO.js";
58
+ } from "./chunk-TUXX7TKR.js";
57
59
  import {
58
60
  readRegularJsonFile,
59
61
  readRegularTextFile
@@ -67,7 +69,7 @@ import {
67
69
  OPENCODE_APPROVAL_EVENT,
68
70
  isRecord,
69
71
  matcherMatchesEveryCall
70
- } from "./chunk-HA2SRYYP.js";
72
+ } from "./chunk-M2ZGNZRS.js";
71
73
 
72
74
  // src/hook-wiring.ts
73
75
  import { createHash } from "crypto";
@@ -1,19 +1,19 @@
1
1
  import {
2
2
  macAppBridgeAvailable
3
- } from "./chunk-GLDSXDRV.js";
3
+ } from "./chunk-NX3Y36VY.js";
4
4
  import {
5
5
  keyPrefix
6
- } from "./chunk-ZYDE6QRW.js";
6
+ } from "./chunk-M74WT5NA.js";
7
7
  import {
8
8
  bridgeAgentKey
9
- } from "./chunk-B3BOAYRO.js";
9
+ } from "./chunk-TUXX7TKR.js";
10
10
  import {
11
11
  readJsonSafe
12
12
  } from "./chunk-TODDEIYG.js";
13
13
  import {
14
14
  isRecord,
15
15
  isValidApiKey
16
- } from "./chunk-HA2SRYYP.js";
16
+ } from "./chunk-M2ZGNZRS.js";
17
17
 
18
18
  // src/shared-mcp-key.ts
19
19
  var asRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
@@ -0,0 +1,18 @@
1
+ import {
2
+ shouldDeferToNativeMode
3
+ } from "./chunk-M2ZGNZRS.js";
4
+
5
+ // src/native-defer.ts
6
+ var nativeDeferOptions = () => {
7
+ const respect = process.env.PUSHARY_RESPECT_PERMISSION_MODE;
8
+ const bypass = process.env.PUSHARY_DEFER_BYPASS;
9
+ return {
10
+ respectPermissionMode: !(respect === "0" || respect === "false"),
11
+ deferBypass: bypass === "1" || bypass === "true"
12
+ };
13
+ };
14
+ var defersToNativeMode = (permissionMode, toolName) => shouldDeferToNativeMode(permissionMode, toolName, nativeDeferOptions());
15
+
16
+ export {
17
+ defersToNativeMode
18
+ };
@@ -14,7 +14,7 @@ import {
14
14
  reachVerdict,
15
15
  reachesYou,
16
16
  verifyDelivery
17
- } from "./chunk-TMWXWBFP.js";
17
+ } from "./chunk-BMOGTNLK.js";
18
18
  import {
19
19
  describeRevokeAttempt,
20
20
  keyNoLongerAccepted,
@@ -29,20 +29,20 @@ import {
29
29
  isCI,
30
30
  terminalColumns,
31
31
  useColor
32
- } from "./chunk-GHHVXARK.js";
32
+ } from "./chunk-WCWWO5QL.js";
33
33
  import {
34
34
  checkApiKey
35
- } from "./chunk-PBPQRJ2T.js";
35
+ } from "./chunk-L6BMVCQQ.js";
36
36
  import {
37
37
  reportedInstallSource
38
- } from "./chunk-UDLWNOXX.js";
38
+ } from "./chunk-YEVRMDG7.js";
39
39
  import {
40
40
  NPX_LATEST_COMMAND
41
- } from "./chunk-AOP55JR2.js";
41
+ } from "./chunk-I5ANEYUK.js";
42
42
  import {
43
43
  NO_PAIRING_COMPUTER,
44
44
  PAIR_TTL_SECONDS
45
- } from "./chunk-HA2SRYYP.js";
45
+ } from "./chunk-M2ZGNZRS.js";
46
46
 
47
47
  // src/onboarding.ts
48
48
  import qrcodeTerminal from "qrcode-terminal";
@@ -3,10 +3,10 @@ import {
3
3
  forkFinishWithUpgradeLock,
4
4
  installWithUpgradeLock,
5
5
  releaseAutoUpdateLock
6
- } from "./chunk-2MPT7YQK.js";
6
+ } from "./chunk-LQDIOUVU.js";
7
7
  import {
8
8
  phoneStartIsRequired
9
- } from "./chunk-AGYD6XNI.js";
9
+ } from "./chunk-L3LFCZ5D.js";
10
10
  import {
11
11
  describeAutoUpdateCheck,
12
12
  globalInstallLocation,
@@ -18,26 +18,28 @@ import {
18
18
  readAutoUpdateState,
19
19
  updateAutoUpdateState,
20
20
  upgradeEntryFor
21
- } from "./chunk-J7HSUQK2.js";
21
+ } from "./chunk-QKNHNDOY.js";
22
22
  import {
23
23
  autoUpdateLock,
24
24
  autoUpdateLog,
25
25
  autoUpdateState
26
- } from "./chunk-B3BOAYRO.js";
26
+ } from "./chunk-TUXX7TKR.js";
27
27
  import {
28
28
  execNpm,
29
29
  fetchLatestPublishedVersion,
30
30
  npmErrorMessage,
31
+ previewGlobalInstall,
31
32
  readGlobalCliInstallAt,
32
33
  readGlobalPrefix
33
- } from "./chunk-IVOELLUK.js";
34
+ } from "./chunk-HAOYL5JP.js";
34
35
  import {
35
36
  EXIT
36
37
  } from "./chunk-BG4HHB7E.js";
37
38
  import {
38
39
  NPX_LATEST_COMMAND
39
- } from "./chunk-AOP55JR2.js";
40
+ } from "./chunk-I5ANEYUK.js";
40
41
  import {
42
+ LATEST_DIST_TAG,
41
43
  commandsPackage,
42
44
  globalUpgradeEntry,
43
45
  isNewerVersion,
@@ -45,7 +47,7 @@ import {
45
47
  isSameMajorVersion,
46
48
  ownPackageRoot,
47
49
  packageVersionAt
48
- } from "./chunk-WIIMW5YO.js";
50
+ } from "./chunk-UQTQ6HPO.js";
49
51
 
50
52
  // src/global-upgrade.ts
51
53
  import { existsSync } from "fs";
@@ -185,6 +187,18 @@ var finishInstalledUpgrade = async (context, from, to, finishAttempts) => {
185
187
  };
186
188
  var settledFinishCheck = (state) => ({ result: "finish_blocked", from: state.from, to: state.to, detail: state.detail });
187
189
  var isInstallableRelease = (latest, installed) => latest !== void 0 && isNewerVersion(latest, installed) && isSameMajorVersion(latest, installed);
190
+ var releaseNpmAllows = (context, installed, published) => {
191
+ if (!isInstallableRelease(published, installed)) return published;
192
+ const preview = previewGlobalInstall({
193
+ packageName: context.location.packageName,
194
+ version: LATEST_DIST_TAG,
195
+ prefix: context.location.prefix,
196
+ timeoutMs: INSTALL_TIMEOUT_MS
197
+ }, context.runNpm);
198
+ if (preview.kind === "resolved") return preview.version;
199
+ return preview.kind === "refused_for_release_age" ? installed : published;
200
+ };
201
+ var npmPolicyHoldDetail = (published, allowed) => published !== void 0 && published !== allowed && isNewerVersion(published, allowed) ? `${published} is not yet allowed by this machine's npm settings, such as min-release-age` : void 0;
188
202
  var checkAndInstall = async (context) => {
189
203
  const installed = packageVersionAt(context.packageRoot);
190
204
  if (installed === void 0 || !isReleaseVersion(installed)) {
@@ -192,11 +206,12 @@ var checkAndInstall = async (context) => {
192
206
  }
193
207
  const previous = readAutoUpdateState(context.statePath);
194
208
  const pendingFinish = hasRetryableUpgradeFinish(previous, installed);
195
- const latest = await fetchLatestPublishedVersion({ packageName: context.location.packageName, fetchImpl: context.fetchImpl });
209
+ const published = await fetchLatestPublishedVersion({ packageName: context.location.packageName, fetchImpl: context.fetchImpl });
210
+ const latest = releaseNpmAllows(context, installed, published);
196
211
  if (pendingFinish && !isInstallableRelease(latest, installed)) return finishInstalledUpgrade(context, previous.from, installed, nextFinishAttempt(previous, installed));
197
212
  if (hasSettledUpgradeFinish(previous, installed) && !isInstallableRelease(latest, installed)) return settledFinishCheck(previous);
198
213
  if (latest === void 0) return { result: "failed", from: installed, detail: UNREACHABLE_REGISTRY };
199
- if (!isNewerVersion(latest, installed)) return { result: "current", from: installed };
214
+ if (!isNewerVersion(latest, installed)) return { result: "current", from: installed, detail: npmPolicyHoldDetail(published, installed) };
200
215
  if (!isSameMajorVersion(latest, installed)) {
201
216
  return { result: "needs_manual", from: installed, to: latest, detail: newMajorDetail(latest) };
202
217
  }
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  addGeminiMcpServer,
3
3
  removeGeminiMcpServer
4
- } from "./chunk-TPLTB256.js";
4
+ } from "./chunk-H7OY4AAT.js";
5
5
  import {
6
6
  CLAUDE_CODE_AGENT
7
- } from "./chunk-QP3TCKRZ.js";
7
+ } from "./chunk-Y3ELKLNH.js";
8
8
  import {
9
9
  compatibleToolLookup
10
- } from "./chunk-IKC33YKC.js";
10
+ } from "./chunk-G6M6YJK4.js";
11
11
  import {
12
12
  CLAUDE_HOOK_EVENTS,
13
13
  PUSHARY_MCP_URL,
@@ -19,7 +19,7 @@ import {
19
19
  isPusharyHook,
20
20
  registerHookEntry,
21
21
  removeClaudeMcpServers
22
- } from "./chunk-B3BOAYRO.js";
22
+ } from "./chunk-TUXX7TKR.js";
23
23
  import {
24
24
  HOOK_COMPATIBLE_PROFILES,
25
25
  PHONE_ANSWERED_TOOLS,
@@ -30,7 +30,7 @@ import {
30
30
  pusharyMissingReason,
31
31
  refusalOutput,
32
32
  withHookHoldBudget
33
- } from "./chunk-HA2SRYYP.js";
33
+ } from "./chunk-M2ZGNZRS.js";
34
34
 
35
35
  // src/config-document.ts
36
36
  import { parse, stringify } from "smol-toml";