@pushary/agent-hooks 1.9.8 → 1.9.10

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 (104) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/bin/pushary-bell-hook.js +22 -23
  3. package/dist/bin/pushary-bell.js +13 -13
  4. package/dist/bin/pushary-claude.js +26 -27
  5. package/dist/bin/pushary-clean.js +124 -51
  6. package/dist/bin/pushary-codex-bridge.js +20 -20
  7. package/dist/bin/pushary-codex-hook.js +34 -35
  8. package/dist/bin/pushary-codex.js +13 -13
  9. package/dist/bin/pushary-connect.js +41 -18
  10. package/dist/bin/pushary-cowork.js +5 -5
  11. package/dist/bin/pushary-daemon.js +35 -37
  12. package/dist/bin/pushary-disconnect.js +29 -32
  13. package/dist/bin/pushary-doctor.js +101 -78
  14. package/dist/bin/pushary-elicitation-hook.js +25 -26
  15. package/dist/bin/pushary-gemini-bridge.js +13 -13
  16. package/dist/bin/pushary-gemini-hook.js +29 -30
  17. package/dist/bin/pushary-hook.js +36 -37
  18. package/dist/bin/pushary-login.js +12 -12
  19. package/dist/bin/pushary-logout.js +18 -78
  20. package/dist/bin/pushary-mcp.js +9 -9
  21. package/dist/bin/pushary-mode.js +12 -12
  22. package/dist/bin/pushary-notification-hook.js +29 -30
  23. package/dist/bin/pushary-opencode-hook.js +28 -29
  24. package/dist/bin/pushary-permission-denied-hook.js +30 -31
  25. package/dist/bin/pushary-permission-hook.js +33 -34
  26. package/dist/bin/pushary-post-hook.js +30 -31
  27. package/dist/bin/pushary-prompt-hook.js +29 -30
  28. package/dist/bin/pushary-session-end-hook.js +29 -30
  29. package/dist/bin/pushary-session-start-hook.js +33 -35
  30. package/dist/bin/pushary-setup.js +147 -116
  31. package/dist/bin/pushary-stats.js +5 -5
  32. package/dist/bin/pushary-status.js +48 -18
  33. package/dist/bin/pushary-stop-hook.js +29 -30
  34. package/dist/bin/pushary-stopfailure-hook.js +29 -30
  35. package/dist/bin/pushary-suggestions.js +12 -12
  36. package/dist/bin/pushary-transcript-register.js +18 -19
  37. package/dist/bin/pushary-transcripts.js +7 -7
  38. package/dist/bin/pushary-upgrade.js +38 -44
  39. package/dist/bin/pushary-wait.js +12 -12
  40. package/dist/bin/pushary.js +6 -6
  41. package/dist/{chunk-CKV3UPMU.js → chunk-2HFSKYLN.js} +2 -2
  42. package/dist/{chunk-ZN3C6GBG.js → chunk-2HXG2QDI.js} +4 -4
  43. package/dist/{chunk-5QUPKDI5.js → chunk-2M52CFVO.js} +1 -1
  44. package/dist/{chunk-KF3UZLYI.js → chunk-2S34OPHS.js} +1 -1
  45. package/dist/{chunk-2A53H4S6.js → chunk-5MQYA3YL.js} +22 -21
  46. package/dist/{chunk-I5IJRMNV.js → chunk-5RGA636G.js} +21 -9
  47. package/dist/{chunk-IAD2RT4L.js → chunk-6KNC6KLL.js} +4 -4
  48. package/dist/{chunk-KHNFLYJO.js → chunk-7HGR5GNY.js} +4 -4
  49. package/dist/{chunk-BEJRK4DF.js → chunk-AKPHYSEL.js} +5 -4
  50. package/dist/{chunk-ZBK6E2OR.js → chunk-APP43AW7.js} +1 -1
  51. package/dist/chunk-BOSXFI7L.js +52 -0
  52. package/dist/{chunk-WS4H76EP.js → chunk-BTFUSQFB.js} +2 -2
  53. package/dist/{chunk-B64KHETR.js → chunk-BVPPYR7B.js} +3 -3
  54. package/dist/{chunk-TCWKTUAE.js → chunk-BVSIM4EF.js} +2 -2
  55. package/dist/{chunk-BXET3ALR.js → chunk-C6QTMWJZ.js} +2 -2
  56. package/dist/{chunk-IHO3YQAN.js → chunk-CJYM4ZHV.js} +2 -2
  57. package/dist/{chunk-6TE27XZR.js → chunk-DAOQT4WK.js} +2 -2
  58. package/dist/{chunk-V5HPPF3E.js → chunk-DL6QHS7V.js} +1 -1
  59. package/dist/{chunk-DPGSLWOS.js → chunk-DWO4RLYK.js} +10 -10
  60. package/dist/{chunk-GU3EJCVV.js → chunk-EA5NWDK7.js} +4 -0
  61. package/dist/{chunk-I6MJXLMY.js → chunk-EVC765EO.js} +2 -2
  62. package/dist/{chunk-WG3K4TCH.js → chunk-GQYX24UC.js} +1 -1
  63. package/dist/{chunk-N4QSPI3B.js → chunk-GTZ4HIHU.js} +15 -13
  64. package/dist/{chunk-DUZVXBBU.js → chunk-H4F5O3RE.js} +1 -1
  65. package/dist/{chunk-MKTJEXZ3.js → chunk-I3W7GJ5R.js} +3 -3
  66. package/dist/{chunk-ZSTSEBG7.js → chunk-IIVZZMSO.js} +1 -1
  67. package/dist/{chunk-KRCR2CRQ.js → chunk-LDQGURCF.js} +11 -11
  68. package/dist/{chunk-2WXF3QJR.js → chunk-LXA236ZQ.js} +2 -2
  69. package/dist/{chunk-CD47ZFFZ.js → chunk-MD4SVNT6.js} +1 -1
  70. package/dist/{chunk-CLOSJ4ES.js → chunk-MISUKJGW.js} +1 -1
  71. package/dist/{chunk-DKMD6AWR.js → chunk-NQ67AF3V.js} +4 -4
  72. package/dist/{chunk-HRULIYDU.js → chunk-OL2Z7WI4.js} +2 -2
  73. package/dist/{chunk-MXHTGVFZ.js → chunk-PNC5ZQFS.js} +16 -20
  74. package/dist/{chunk-3I6IVOZV.js → chunk-PR2VDVCP.js} +3 -3
  75. package/dist/{chunk-FQ2GORVG.js → chunk-Q3UMWSE4.js} +2 -2
  76. package/dist/{chunk-MFF3ONG5.js → chunk-QAGWWDXQ.js} +78 -8
  77. package/dist/{chunk-M6BZZFVQ.js → chunk-QGRENWJL.js} +1 -1
  78. package/dist/{chunk-LKLVTG3V.js → chunk-RPQLZLKC.js} +5 -5
  79. package/dist/{chunk-KFF7G225.js → chunk-S2DAKKQQ.js} +3 -3
  80. package/dist/chunk-SB2GN6OP.js +71 -0
  81. package/dist/{chunk-2QGYMY7A.js → chunk-SIHYBIEN.js} +142 -4
  82. package/dist/{chunk-ZW3XZLJC.js → chunk-SJDMULE7.js} +5 -5
  83. package/dist/{chunk-IHFDPV7C.js → chunk-SMVMLWCD.js} +1 -1
  84. package/dist/{chunk-QOLITCIP.js → chunk-T6ZN4TEF.js} +1 -1
  85. package/dist/{chunk-7DVNSQWF.js → chunk-TCXL5FQQ.js} +2 -2
  86. package/dist/{chunk-7PT35RY2.js → chunk-U5FP5JIS.js} +2 -2
  87. package/dist/{chunk-ZBHUHJG6.js → chunk-UJZ7AGSC.js} +6 -4
  88. package/dist/{chunk-TCQ43LSG.js → chunk-UM5WXBKN.js} +3 -3
  89. package/dist/{chunk-2QTO5YIT.js → chunk-XKMGHVXW.js} +6 -6
  90. package/dist/{chunk-LWOO567I.js → chunk-XXLCYKVS.js} +3 -3
  91. package/dist/{chunk-MGRFDGWU.js → chunk-Y7JM47CI.js} +2 -2
  92. package/dist/{chunk-NWDG3MSW.js → chunk-YUQHUGTH.js} +1 -1
  93. package/dist/{chunk-WWOHTTVP.js → chunk-Z2Q2VH43.js} +2 -2
  94. package/dist/{chunk-DL7XWKYV.js → chunk-ZGADIZDS.js} +2 -2
  95. package/dist/{chunk-2VZAALEJ.js → chunk-ZSGJYSF2.js} +8 -8
  96. package/dist/{global-upgrade-I56HNM23.js → global-upgrade-PUM44JUH.js} +6 -6
  97. package/dist/{paths-AGY43CXS.js → paths-U2MJGNBT.js} +2 -2
  98. package/dist/{reapply-IA5XUKWW.js → reapply-PRKV4EO7.js} +22 -24
  99. package/dist/src/index.js +19 -19
  100. package/dist/{upgrade-lock-B34TAUKV.js → upgrade-lock-QZSVLEM7.js} +3 -3
  101. package/package.json +1 -1
  102. package/dist/chunk-3Z3A37WD.js +0 -77
  103. package/dist/chunk-OP7IHC2I.js +0 -24
  104. package/dist/chunk-YIG2R3BJ.js +0 -145
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  keyCheckFromResponse
3
- } from "./chunk-LWOO567I.js";
3
+ } from "./chunk-XXLCYKVS.js";
4
4
  import {
5
5
  installNetworkDefaults
6
- } from "./chunk-TCQ43LSG.js";
6
+ } from "./chunk-UM5WXBKN.js";
7
7
  import {
8
8
  getBaseUrl
9
- } from "./chunk-5QUPKDI5.js";
9
+ } from "./chunk-2M52CFVO.js";
10
10
 
11
11
  // src/retry.ts
12
12
  var isRetryable = (err) => {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  isSafeReadOnlyCommand
3
- } from "./chunk-I5IJRMNV.js";
3
+ } from "./chunk-5RGA636G.js";
4
4
 
5
5
  // src/ledger.ts
6
6
  import { appendFileSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, statSync } from "fs";
@@ -14,36 +14,36 @@ import {
14
14
  IDLE_PROMPT_NOTIFICATION,
15
15
  NOTIFICATION_PUSH_TYPES,
16
16
  POSTTOOLUSE_MIRROR_ONLY_TOOLS
17
- } from "./chunk-CD47ZFFZ.js";
17
+ } from "./chunk-MD4SVNT6.js";
18
18
  import {
19
19
  cancelQuestion,
20
20
  isPolicyConfig,
21
21
  sendNotification,
22
22
  waitForAnswer
23
- } from "./chunk-2VZAALEJ.js";
23
+ } from "./chunk-ZSGJYSF2.js";
24
+ import {
25
+ withRetry
26
+ } from "./chunk-I3W7GJ5R.js";
24
27
  import {
25
28
  clientErrorKindOf,
26
29
  reportClientError
27
- } from "./chunk-DKMD6AWR.js";
28
- import {
29
- withRetry
30
- } from "./chunk-MKTJEXZ3.js";
30
+ } from "./chunk-NQ67AF3V.js";
31
31
  import {
32
32
  getMachineId
33
- } from "./chunk-DUZVXBBU.js";
33
+ } from "./chunk-H4F5O3RE.js";
34
34
  import {
35
35
  reportedInstallSource
36
- } from "./chunk-FQ2GORVG.js";
36
+ } from "./chunk-Q3UMWSE4.js";
37
37
  import {
38
38
  canonicalJson
39
- } from "./chunk-ZBHUHJG6.js";
39
+ } from "./chunk-UJZ7AGSC.js";
40
40
  import {
41
41
  writeFileAtomic
42
42
  } from "./chunk-T7E75EKA.js";
43
43
  import {
44
44
  getApiKey,
45
45
  getBaseUrl
46
- } from "./chunk-5QUPKDI5.js";
46
+ } from "./chunk-2M52CFVO.js";
47
47
  import {
48
48
  ACTION_BODY_MAX,
49
49
  AGENT_LABELS_BY_TYPE,
@@ -70,7 +70,7 @@ import {
70
70
  resolvePolicy,
71
71
  toToolLookup,
72
72
  truncateLine
73
- } from "./chunk-I5IJRMNV.js";
73
+ } from "./chunk-5RGA636G.js";
74
74
 
75
75
  // src/policy.ts
76
76
  import { createHash } from "crypto";
@@ -3,10 +3,10 @@ import {
3
3
  keyPrefix,
4
4
  readConfigFileKey,
5
5
  readMacAppKeyPrefix
6
- } from "./chunk-N4QSPI3B.js";
6
+ } from "./chunk-GTZ4HIHU.js";
7
7
  import {
8
8
  NPX_LATEST_COMMAND
9
- } from "./chunk-7DVNSQWF.js";
9
+ } from "./chunk-TCXL5FQQ.js";
10
10
 
11
11
  // src/key-signed-out.ts
12
12
  var VERDICT_BY_CHECK = {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  PRETOOLUSE_GATED_TOOLS
3
- } from "./chunk-I5IJRMNV.js";
3
+ } from "./chunk-5RGA636G.js";
4
4
 
5
5
  // src/claude-tools.ts
6
6
  var POSTTOOLUSE_MIRROR_ONLY_TOOLS = ["TodoWrite", "Task", "WebFetch", "WebSearch"];
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getBaseUrl
3
- } from "./chunk-5QUPKDI5.js";
3
+ } from "./chunk-2M52CFVO.js";
4
4
 
5
5
  // src/transcript-api.ts
6
6
  var fetchTranscriptRecipients = async (apiKey, baseUrl = getBaseUrl()) => {
@@ -4,18 +4,18 @@ import {
4
4
  } from "./chunk-POFBE6ZY.js";
5
5
  import {
6
6
  isNetworkFailure
7
- } from "./chunk-TCQ43LSG.js";
7
+ } from "./chunk-UM5WXBKN.js";
8
8
  import {
9
9
  clientReportClaims
10
- } from "./chunk-ZBHUHJG6.js";
10
+ } from "./chunk-UJZ7AGSC.js";
11
11
  import {
12
12
  getApiKey,
13
13
  getBaseUrl
14
- } from "./chunk-5QUPKDI5.js";
14
+ } from "./chunk-2M52CFVO.js";
15
15
  import {
16
16
  CLIENT_REPORT_PATH,
17
17
  degradedLine
18
- } from "./chunk-I5IJRMNV.js";
18
+ } from "./chunk-5RGA636G.js";
19
19
 
20
20
  // src/client-report-claim.ts
21
21
  import { createHash } from "crypto";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  parseSseMessages
3
- } from "./chunk-MKTJEXZ3.js";
3
+ } from "./chunk-I3W7GJ5R.js";
4
4
  import {
5
5
  NPX_LATEST_COMMAND
6
- } from "./chunk-7DVNSQWF.js";
6
+ } from "./chunk-TCXL5FQQ.js";
7
7
 
8
8
  // src/mcp-stdio-bridge.ts
9
9
  var MCP_BRIDGE_BINARY = "pushary-mcp";
@@ -1,36 +1,31 @@
1
- import {
2
- agentHookOwner,
3
- macAppBridgeAvailable,
4
- openCodePluginOwner
5
- } from "./chunk-3Z3A37WD.js";
6
1
  import {
7
2
  ensureCodexTrustsPusharyHooks
8
- } from "./chunk-MGRFDGWU.js";
3
+ } from "./chunk-Y7JM47CI.js";
4
+ import {
5
+ detectClaudeVersion
6
+ } from "./chunk-RIVNNBEK.js";
9
7
  import {
10
8
  OPENCODE_HOOK_BINARY,
9
+ agentHookOwner,
11
10
  installOpenCodePlugin,
11
+ macAppBridgeAvailable,
12
12
  openCodeHookArgv,
13
13
  openCodePluginDir,
14
14
  openCodeWired
15
- } from "./chunk-MFF3ONG5.js";
15
+ } from "./chunk-QAGWWDXQ.js";
16
16
  import {
17
17
  addClaudeMcpServer,
18
18
  addPusharyHooks,
19
19
  addPusharyToolPermissions
20
- } from "./chunk-KHNFLYJO.js";
21
- import {
22
- detectClaudeVersion
23
- } from "./chunk-RIVNNBEK.js";
24
- import {
25
- planHooks
26
- } from "./chunk-YIG2R3BJ.js";
20
+ } from "./chunk-7HGR5GNY.js";
27
21
  import {
28
22
  claudeUnprovenHolds,
29
23
  claudeWired,
30
24
  codexUnprovenHolds,
31
25
  codexWired,
32
- geminiWired
33
- } from "./chunk-2QGYMY7A.js";
26
+ geminiWired,
27
+ planHooks
28
+ } from "./chunk-SIHYBIEN.js";
34
29
  import {
35
30
  CLAUDE_HOOK_BINARY,
36
31
  CLAUDE_HOOK_EVENTS,
@@ -41,7 +36,7 @@ import {
41
36
  needsReregistration,
42
37
  registrationSignatures,
43
38
  supportedClaudeEvents
44
- } from "./chunk-3I6IVOZV.js";
39
+ } from "./chunk-PR2VDVCP.js";
45
40
  import {
46
41
  formatVersion
47
42
  } from "./chunk-6ICPEJY5.js";
@@ -64,7 +59,7 @@ import {
64
59
  registrationHolderOf,
65
60
  resolveGlobalBinary,
66
61
  vscodePluginMcp
67
- } from "./chunk-ZBHUHJG6.js";
62
+ } from "./chunk-UJZ7AGSC.js";
68
63
  import {
69
64
  readJsonSafe,
70
65
  writeFileAtomic,
@@ -335,9 +330,10 @@ var SETUP_CHOICE_BY_REAPPLY_ID = {
335
330
  codex: "codex",
336
331
  gemini: "gemini_cli",
337
332
  cursor: "cursor",
338
- vscode: "vscode"
333
+ vscode: "vscode",
334
+ opencode: "opencode"
339
335
  };
340
- var reapplyHookOwner = (id, appAvailable) => id === "opencode" ? openCodePluginOwner(appAvailable) : agentHookOwner(SETUP_CHOICE_BY_REAPPLY_ID[id], appAvailable);
336
+ var reapplyHookOwner = (id, appAvailable) => agentHookOwner(SETUP_CHOICE_BY_REAPPLY_ID[id], appAvailable);
341
337
  var reapplyHolder = (id, appAvailable) => planHooks({ owner: reapplyHookOwner(id, appAvailable), takeOverHooks: false, nonInteractive: true }) === "keep" ? "app" : "cli";
342
338
  var KEPT_FOR_APP = { configured: true, reapplied: false, hooks: false, mcp: false };
343
339
  var FAILED_REAPPLY = { configured: false, reapplied: false, hooks: false, mcp: false, failed: true };
@@ -5,16 +5,16 @@ import {
5
5
  import {
6
6
  NOTIFICATION_MATCHED_TYPES,
7
7
  POSTTOOLUSE_MIRRORED_TOOLS
8
- } from "./chunk-CD47ZFFZ.js";
8
+ } from "./chunk-MD4SVNT6.js";
9
9
  import {
10
10
  isProtectedByScope,
11
11
  registerHookEntry
12
- } from "./chunk-ZBHUHJG6.js";
12
+ } from "./chunk-UJZ7AGSC.js";
13
13
  import {
14
14
  CLAUDE_PRETOOLUSE_MATCHER,
15
15
  HOOK_BUDGETS,
16
16
  HOOK_LOCATOR_BINARY
17
- } from "./chunk-I5IJRMNV.js";
17
+ } from "./chunk-5RGA636G.js";
18
18
 
19
19
  // src/gemini-config.ts
20
20
  var GEMINI_HOOK_BINARY = "pushary-gemini-hook";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  configFilePath
3
- } from "./chunk-5QUPKDI5.js";
3
+ } from "./chunk-2M52CFVO.js";
4
4
  import {
5
5
  normalizeInstallSource
6
- } from "./chunk-I5IJRMNV.js";
6
+ } from "./chunk-5RGA636G.js";
7
7
 
8
8
  // src/install-source.ts
9
9
  import { readFileSync } from "fs";
@@ -1,14 +1,39 @@
1
1
  import {
2
- guardedArgv
3
- } from "./chunk-ZBHUHJG6.js";
2
+ compatibleConfigFile
3
+ } from "./chunk-7HGR5GNY.js";
4
+ import {
5
+ hookOwnerOf,
6
+ hookOwnerOfCommands,
7
+ liveBridgeProbe,
8
+ resolveBridgeStub
9
+ } from "./chunk-SIHYBIEN.js";
10
+ import {
11
+ AGENT_CHOICES
12
+ } from "./chunk-ZGADIZDS.js";
13
+ import {
14
+ claudeSettings,
15
+ codexHooksJson,
16
+ cursorUserHooks,
17
+ geminiSettings,
18
+ guardedArgv,
19
+ pusharyDir,
20
+ vscodePluginDir
21
+ } from "./chunk-UJZ7AGSC.js";
22
+ import {
23
+ readJsonSafe
24
+ } from "./chunk-T7E75EKA.js";
4
25
  import {
5
26
  HOOK_BUDGETS,
6
- OPENCODE_APPROVAL_EVENT
7
- } from "./chunk-I5IJRMNV.js";
27
+ HOOK_COMPATIBLE_PROFILES,
28
+ HOOK_LOCATOR_BINARY,
29
+ OPENCODE_APPROVAL_EVENT,
30
+ hookCompatibleProfile
31
+ } from "./chunk-5RGA636G.js";
8
32
 
9
33
  // src/opencode-plugin.ts
10
34
  var OPENCODE_PLUGIN_MARKER = "pushary-opencode-plugin w1";
11
35
  var OPENCODE_PLUGIN_PLACEHOLDER = "__PUSHARY_COMMAND__";
36
+ var OPENCODE_APPROVAL_EVENTS_PLACEHOLDER = "__PUSHARY_APPROVAL_EVENTS__";
12
37
  var OPENCODE_PLUGIN_FILE = "pushary.js";
13
38
  var OPENCODE_PLUGIN_DIR = "plugins";
14
39
  var OPENCODE_PLUGIN_SIBLING = "package.json";
@@ -262,7 +287,7 @@ export const PusharyPlugin = async ({ client, directory, worktree }) => {
262
287
  try {
263
288
  const type = event && event.type
264
289
  const properties = event && event.properties
265
- if (${JSON.stringify(OPENCODE_ASKED_EVENTS)}.includes(type)) {
290
+ if (${OPENCODE_APPROVAL_EVENTS_PLACEHOLDER}.includes(type)) {
266
291
  const asked = askedFrom(properties)
267
292
  if (asked) void gate(asked)
268
293
  return
@@ -295,12 +320,16 @@ var openCodePluginModule = () => ({
295
320
  marker: OPENCODE_PLUGIN_MARKER,
296
321
  source: openCodePluginSource(),
297
322
  placeholder: OPENCODE_PLUGIN_PLACEHOLDER,
323
+ approvalEvents: {
324
+ placeholder: OPENCODE_APPROVAL_EVENTS_PLACEHOLDER,
325
+ events: OPENCODE_ASKED_EVENTS
326
+ },
298
327
  sibling: {
299
328
  path: OPENCODE_PLUGIN_SIBLING,
300
329
  contents: OPENCODE_PLUGIN_SIBLING_CONTENTS
301
330
  }
302
331
  });
303
- var renderOpenCodePlugin = (module, argv) => module.source.replace(module.placeholder, JSON.stringify(argv));
332
+ var renderOpenCodePlugin = (module, argv, holdsApprovals = true) => module.source.replace(module.placeholder, JSON.stringify(argv)).replace(module.approvalEvents.placeholder, JSON.stringify(holdsApprovals ? module.approvalEvents.events : []));
304
333
  var COMMAND_LINE = /^const COMMAND = (.*)$/m;
305
334
  var isArgv = (value) => Array.isArray(value) && value.every((item) => typeof item === "string");
306
335
  var openCodePluginArgv = (contents) => {
@@ -375,11 +404,47 @@ var removeOpenCodeMcpServer = (config) => {
375
404
  return true;
376
405
  };
377
406
 
407
+ // src/setup/agent-hook-owner.ts
408
+ import { readFileSync as readFileSync2 } from "fs";
409
+ import { join as join2 } from "path";
410
+ var COMPATIBLE_HOOK_FILES = Object.fromEntries(
411
+ HOOK_COMPATIBLE_PROFILES.map((profile) => [profile.agentType, () => compatibleConfigFile(profile)])
412
+ );
413
+ var HOOK_FILES = {
414
+ claude_code: claudeSettings,
415
+ codex: codexHooksJson,
416
+ gemini_cli: geminiSettings,
417
+ cursor: cursorUserHooks,
418
+ vscode: () => join2(vscodePluginDir(), "hooks", "hooks.json"),
419
+ ...COMPATIBLE_HOOK_FILES
420
+ };
421
+ var agentHookFile = (agent) => HOOK_FILES[agent]?.() ?? null;
422
+ var agentHooksKeyPath = (agent) => hookCompatibleProfile(agent)?.hooksKeyPath;
423
+ var readTextOrNull = (path) => {
424
+ try {
425
+ return readFileSync2(path, "utf-8");
426
+ } catch {
427
+ return null;
428
+ }
429
+ };
430
+ var openCodePluginOwner = (appAvailable) => {
431
+ const contents = readTextOrNull(openCodePluginFile());
432
+ return hookOwnerOfCommands(contents === null ? [] : openCodePluginArgv(contents) ?? [], appAvailable);
433
+ };
434
+ var agentHookOwner = (agent, appAvailable) => {
435
+ if (agent === "opencode") return openCodePluginOwner(appAvailable);
436
+ const file = agentHookFile(agent);
437
+ if (!file) return "none";
438
+ const document = readJsonSafe(file);
439
+ return hookOwnerOf(document.kind === "ok" ? document.value : null, appAvailable, agentHooksKeyPath(agent));
440
+ };
441
+ var cliOwnsAnyAgentHooks = (appAvailable) => AGENT_CHOICES.some((agent) => agentHookOwner(agent, appAvailable) === "cli");
442
+ var macAppBridgeAvailable = () => resolveBridgeStub(join2(pusharyDir(), "bin", HOOK_LOCATOR_BINARY), liveBridgeProbe()).kind === "bundle";
443
+
378
444
  export {
379
445
  OPENCODE_PLUGIN_PLACEHOLDER,
380
446
  OPENCODE_PLUGIN_SIBLING,
381
447
  OPENCODE_PLUGIN_SIBLING_CONTENTS,
382
- openCodePluginArgv,
383
448
  isOpenCodePluginOurs,
384
449
  OPENCODE_HOOK_BINARY,
385
450
  openCodeHookArgv,
@@ -393,5 +458,10 @@ export {
393
458
  openCodeConfigFile,
394
459
  openCodeInstructionsFile,
395
460
  addOpenCodeMcpServer,
396
- removeOpenCodeMcpServer
461
+ removeOpenCodeMcpServer,
462
+ agentHookFile,
463
+ agentHooksKeyPath,
464
+ agentHookOwner,
465
+ cliOwnsAnyAgentHooks,
466
+ macAppBridgeAvailable
397
467
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  readTranscriptPreference
3
- } from "./chunk-N4QSPI3B.js";
3
+ } from "./chunk-GTZ4HIHU.js";
4
4
 
5
5
  // src/transcript-setting.ts
6
6
  var transcriptEnvironmentPreference = () => {
@@ -4,14 +4,14 @@ import {
4
4
  } from "./chunk-XHKBHWLX.js";
5
5
  import {
6
6
  readControlMode
7
- } from "./chunk-N4QSPI3B.js";
7
+ } from "./chunk-GTZ4HIHU.js";
8
8
  import {
9
9
  getMachineId
10
- } from "./chunk-DUZVXBBU.js";
10
+ } from "./chunk-H4F5O3RE.js";
11
11
  import {
12
12
  pusharyDir,
13
13
  resolveGlobalBinary
14
- } from "./chunk-ZBHUHJG6.js";
14
+ } from "./chunk-UJZ7AGSC.js";
15
15
  import {
16
16
  readJsonSafe,
17
17
  writeFileAtomic,
@@ -20,14 +20,14 @@ import {
20
20
  } from "./chunk-T7E75EKA.js";
21
21
  import {
22
22
  getApiKey
23
- } from "./chunk-5QUPKDI5.js";
23
+ } from "./chunk-2M52CFVO.js";
24
24
  import {
25
25
  CLI_PACKAGE_NAMES,
26
26
  cmdShimTarget,
27
27
  getPackageVersion,
28
28
  globalPackageFolder,
29
29
  globalRootFor
30
- } from "./chunk-I5IJRMNV.js";
30
+ } from "./chunk-5RGA636G.js";
31
31
 
32
32
  // src/daemon-lifecycle.ts
33
33
  import { dirname, join, win32 as win32Path } from "path";
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  openCodeConfigDirFrom
3
- } from "./chunk-MFF3ONG5.js";
3
+ } from "./chunk-QAGWWDXQ.js";
4
4
  import {
5
5
  codexHomeFrom,
6
6
  resolvePathBinary
7
- } from "./chunk-ZBHUHJG6.js";
7
+ } from "./chunk-UJZ7AGSC.js";
8
8
  import {
9
9
  HOOK_COMPATIBLE_PROFILES
10
- } from "./chunk-I5IJRMNV.js";
10
+ } from "./chunk-5RGA636G.js";
11
11
 
12
12
  // src/hermes-config.ts
13
13
  import { execFileSync } from "child_process";
@@ -0,0 +1,71 @@
1
+ // src/key-revocation.ts
2
+ var SELF_REVOKE_PATH = "/api/v1/server/keys/self/revoke";
3
+ var DEVICE_KEY_PATH = "/api/agent/device-key";
4
+ var FULL_ACCESS_ONLY_STATUS = 403;
5
+ var REVOKE_TIMEOUT_MS = 1e4;
6
+ var readRevokedCount = async (response) => {
7
+ try {
8
+ const body = await response.json();
9
+ const revoked = typeof body === "object" && body !== null && "revoked" in body ? body.revoked : void 0;
10
+ return typeof revoked === "number" && Number.isInteger(revoked) && revoked >= 0 ? revoked : null;
11
+ } catch {
12
+ return null;
13
+ }
14
+ };
15
+ var revokeAgentKey = async (apiKey, baseUrl, fetchImpl) => {
16
+ const response = await fetchImpl(`${baseUrl}${DEVICE_KEY_PATH}`, {
17
+ method: "DELETE",
18
+ headers: { Authorization: `Bearer ${apiKey}` },
19
+ signal: AbortSignal.timeout(REVOKE_TIMEOUT_MS)
20
+ });
21
+ if (!response.ok) return { kind: "refused", status: response.status };
22
+ const revoked = await readRevokedCount(response);
23
+ if (revoked === null) return { kind: "refused", status: response.status };
24
+ return revoked > 0 ? { kind: "revoked" } : { kind: "not_accepted" };
25
+ };
26
+ var revokeOwnKey = async (apiKey, baseUrl, fetchImpl = fetch) => {
27
+ try {
28
+ const response = await fetchImpl(`${baseUrl}${SELF_REVOKE_PATH}`, {
29
+ method: "POST",
30
+ headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" },
31
+ signal: AbortSignal.timeout(REVOKE_TIMEOUT_MS)
32
+ });
33
+ if (response.status === 401) return { kind: "not_accepted" };
34
+ if (response.status === FULL_ACCESS_ONLY_STATUS) return await revokeAgentKey(apiKey, baseUrl, fetchImpl);
35
+ if (!response.ok) return { kind: "refused", status: response.status };
36
+ return { kind: "revoked" };
37
+ } catch (err) {
38
+ return { kind: "unreachable", detail: err instanceof Error ? err.message : "network error" };
39
+ }
40
+ };
41
+ var REVOKE_DETAIL = {
42
+ revoked: "Revoked the key on pushary.com.",
43
+ not_accepted: "pushary.com had already stopped accepting the key.",
44
+ refused: "pushary.com refused to revoke the key",
45
+ unreachable: "Could not reach pushary.com to revoke the key"
46
+ };
47
+ var describeRevokeAttempt = (attempt) => {
48
+ if (attempt.kind === "refused") return `${REVOKE_DETAIL.refused} (HTTP ${attempt.status}).`;
49
+ if (attempt.kind === "unreachable") return `${REVOKE_DETAIL.unreachable}: ${attempt.detail}`;
50
+ return REVOKE_DETAIL[attempt.kind];
51
+ };
52
+ var keyNoLongerAccepted = (attempt) => attempt.kind === "revoked" || attempt.kind === "not_accepted";
53
+ var keyValidityOf = (check) => {
54
+ switch (check.kind) {
55
+ case "ok":
56
+ case "locked":
57
+ return "valid";
58
+ case "rejected":
59
+ case "malformed":
60
+ return "invalid";
61
+ case "unreachable":
62
+ return "unknown";
63
+ }
64
+ };
65
+
66
+ export {
67
+ revokeOwnKey,
68
+ describeRevokeAttempt,
69
+ keyNoLongerAccepted,
70
+ keyValidityOf
71
+ };