@pushary/agent-hooks 1.6.3 → 1.7.0

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 (100) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +3 -2
  3. package/dist/bin/pushary-bell-hook.js +24 -22
  4. package/dist/bin/pushary-bell.js +11 -12
  5. package/dist/bin/pushary-claude.js +29 -28
  6. package/dist/bin/pushary-clean.js +99 -40
  7. package/dist/bin/pushary-codex-bridge.js +25 -25
  8. package/dist/bin/pushary-codex-hook.js +39 -34
  9. package/dist/bin/pushary-codex.js +13 -12
  10. package/dist/bin/pushary-connect.js +13 -12
  11. package/dist/bin/pushary-cowork.js +5 -6
  12. package/dist/bin/pushary-daemon.js +31 -32
  13. package/dist/bin/pushary-disconnect.js +22 -21
  14. package/dist/bin/pushary-doctor.js +98 -61
  15. package/dist/bin/pushary-elicitation-hook.js +26 -25
  16. package/dist/bin/pushary-gemini-bridge.js +12 -13
  17. package/dist/bin/pushary-gemini-hook.js +35 -30
  18. package/dist/bin/pushary-hook.js +38 -33
  19. package/dist/bin/pushary-login.js +13 -15
  20. package/dist/bin/pushary-logout.js +12 -13
  21. package/dist/bin/pushary-mcp.d.ts +1 -0
  22. package/dist/bin/pushary-mcp.js +56 -0
  23. package/dist/bin/pushary-mode.js +10 -8
  24. package/dist/bin/pushary-notification-hook.js +28 -27
  25. package/dist/bin/pushary-opencode-hook.js +34 -29
  26. package/dist/bin/pushary-permission-denied-hook.js +32 -31
  27. package/dist/bin/pushary-permission-hook.js +31 -30
  28. package/dist/bin/pushary-post-hook.js +28 -27
  29. package/dist/bin/pushary-prompt-hook.js +28 -27
  30. package/dist/bin/pushary-session-end-hook.js +28 -27
  31. package/dist/bin/pushary-session-start-hook.js +32 -31
  32. package/dist/bin/pushary-setup.js +222 -110
  33. package/dist/bin/pushary-stats.js +5 -6
  34. package/dist/bin/pushary-status.js +15 -16
  35. package/dist/bin/pushary-stop-hook.js +28 -27
  36. package/dist/bin/pushary-stopfailure-hook.js +28 -27
  37. package/dist/bin/pushary-suggestions.js +4 -4
  38. package/dist/bin/pushary-transcript-register.js +19 -20
  39. package/dist/bin/pushary-transcripts.js +7 -8
  40. package/dist/bin/pushary-upgrade.js +28 -28
  41. package/dist/bin/pushary-wait.js +10 -8
  42. package/dist/bin/pushary.js +9 -5
  43. package/dist/{chunk-4KSTLHWY.js → chunk-2C7CCWVX.js} +1 -1
  44. package/dist/{chunk-P4BNYJ5Q.js → chunk-2PS6QWDW.js} +2 -2
  45. package/dist/{chunk-ILGL4L3J.js → chunk-4F46VIEE.js} +8 -8
  46. package/dist/{chunk-UAV5MNKY.js → chunk-52NVBNJT.js} +3 -3
  47. package/dist/{chunk-GQPCPEG2.js → chunk-5HLTWFJ6.js} +1 -1
  48. package/dist/{chunk-EJ7ADMNM.js → chunk-6ADZQFVW.js} +1 -1
  49. package/dist/{chunk-QKOVVL7I.js → chunk-73T6MSU5.js} +7 -7
  50. package/dist/{chunk-YOCXPNQ5.js → chunk-7OS4IHGI.js} +2 -2
  51. package/dist/{chunk-BY2CRWBO.js → chunk-B234346F.js} +1 -1
  52. package/dist/{chunk-EA3IELHP.js → chunk-B3UXMSMW.js} +6 -2
  53. package/dist/{chunk-STOMNX4S.js → chunk-B3YQANFN.js} +1 -1
  54. package/dist/{chunk-JBU7XKY2.js → chunk-B76WVEDX.js} +1 -1
  55. package/dist/{chunk-WA7SQX6S.js → chunk-BBKNJJVX.js} +6 -6
  56. package/dist/{chunk-KNIIFNNQ.js → chunk-BH2SKSSK.js} +1 -1
  57. package/dist/{chunk-CTOK3AYA.js → chunk-BWYJ6AAF.js} +6 -7
  58. package/dist/{chunk-HCVAMXHT.js → chunk-CVALVGA7.js} +1 -1
  59. package/dist/{chunk-DX5FOQSO.js → chunk-D6BULEJW.js} +2 -2
  60. package/dist/{chunk-RJUHSFYE.js → chunk-DANOZVZK.js} +1 -1
  61. package/dist/{chunk-3BJQYXTL.js → chunk-DNJUSFBL.js} +13 -5
  62. package/dist/{chunk-57YDFAPP.js → chunk-DVQDPI3T.js} +8 -8
  63. package/dist/{chunk-BEHGVU4W.js → chunk-DZURML2D.js} +1 -1
  64. package/dist/{chunk-LDS4ERW4.js → chunk-EAQMWJPG.js} +10 -10
  65. package/dist/{chunk-LVHGSD5E.js → chunk-EGKXSQCY.js} +13 -7
  66. package/dist/{chunk-HHYVBHHC.js → chunk-HDRNWNVP.js} +6 -6
  67. package/dist/{chunk-JBXUKGZS.js → chunk-IJ6ECPA6.js} +15 -9
  68. package/dist/{chunk-NMRH3VX4.js → chunk-J2355HR7.js} +1 -1
  69. package/dist/{chunk-HETOKNIL.js → chunk-JNXVOU6Y.js} +10 -6
  70. package/dist/{chunk-COGHCL6K.js → chunk-JXUAXO74.js} +2 -2
  71. package/dist/chunk-KW2RRR7D.js +124 -0
  72. package/dist/{chunk-66H2QQAK.js → chunk-KXMZMZD3.js} +1 -1
  73. package/dist/{chunk-H3FEVIQD.js → chunk-KYQXUGH7.js} +3 -3
  74. package/dist/{chunk-P35IUFFR.js → chunk-L4H2Q2S4.js} +276 -19
  75. package/dist/{chunk-NKR4YDRP.js → chunk-LEZFOTMI.js} +1 -1
  76. package/dist/{chunk-WD6W7QDI.js → chunk-O2LEPIU6.js} +1 -1
  77. package/dist/chunk-POFBE6ZY.js +12 -0
  78. package/dist/{chunk-SND3C2AV.js → chunk-PQ4F64M2.js} +3 -3
  79. package/dist/{chunk-3UOC3GRO.js → chunk-PUDBG3GM.js} +1 -1
  80. package/dist/{chunk-YQMFGWBD.js → chunk-QXAK5RFU.js} +1 -1
  81. package/dist/{chunk-REYWOCQJ.js → chunk-R2XCLT6I.js} +4 -4
  82. package/dist/{chunk-NPGOQQCV.js → chunk-ROQK7IN3.js} +2 -2
  83. package/dist/{chunk-GU3EJCVV.js → chunk-S3UD4V6W.js} +39 -0
  84. package/dist/{chunk-ICGAIM2R.js → chunk-SQRWHALT.js} +2 -2
  85. package/dist/{chunk-JX67DVMY.js → chunk-UC65FJJT.js} +5 -6
  86. package/dist/{chunk-CWIARY6F.js → chunk-UOAQ6QMP.js} +2 -2
  87. package/dist/{chunk-OSJEMXSR.js → chunk-V4AQBAVG.js} +1 -1
  88. package/dist/chunk-V6QRSU2G.js +142 -0
  89. package/dist/{chunk-VDMX5EMU.js → chunk-VKVIAZQO.js} +1 -1
  90. package/dist/{chunk-BG6OCZ4N.js → chunk-WUNZAE7I.js} +5 -5
  91. package/dist/{chunk-TZ4KUNZG.js → chunk-X6KDKOV5.js} +3 -3
  92. package/dist/{chunk-LM2IOEDK.js → chunk-XNCMT7YY.js} +3 -1
  93. package/dist/{chunk-GHOB245Q.js → chunk-YROGUPOZ.js} +132 -30
  94. package/dist/chunk-YYINL576.js +120 -0
  95. package/dist/{chunk-57DDP4TB.js → chunk-ZQ7IDOKY.js} +3 -3
  96. package/dist/{reapply-IB7YE7BU.js → reapply-6PH3FMPX.js} +9 -10
  97. package/dist/src/index.js +20 -19
  98. package/package.json +2 -1
  99. package/dist/chunk-HWJW3CPO.js +0 -65
  100. package/dist/chunk-SAF6HGAA.js +0 -57
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  SETUP_FLAGS
3
- } from "./chunk-HCVAMXHT.js";
3
+ } from "./chunk-CVALVGA7.js";
4
4
  import {
5
5
  parseFlags
6
6
  } from "./chunk-GMXKITVA.js";
@@ -14,7 +14,7 @@ import {
14
14
  CLAUDE_CONNECTOR_URL,
15
15
  COWORK_CONNECTOR_LIMIT,
16
16
  COWORK_STANDING_INSTRUCTIONS
17
- } from "./chunk-GHOB245Q.js";
17
+ } from "./chunk-YROGUPOZ.js";
18
18
 
19
19
  // src/cli/cowork.ts
20
20
  import { readFileSync } from "fs";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  resolvePathBinary
3
- } from "./chunk-3BJQYXTL.js";
3
+ } from "./chunk-DNJUSFBL.js";
4
4
 
5
5
  // src/hermes-config.ts
6
6
  import { execFileSync } from "child_process";
@@ -1,11 +1,9 @@
1
1
  import {
2
2
  HOOK_BUDGETS,
3
3
  HOOK_LOCATOR_BINARY,
4
+ isReleaseVersion,
4
5
  withHookHoldBudget
5
- } from "./chunk-GHOB245Q.js";
6
- import {
7
- isReleaseVersion
8
- } from "./chunk-HWJW3CPO.js";
6
+ } from "./chunk-YROGUPOZ.js";
9
7
 
10
8
  // src/npm.ts
11
9
  import { execFileSync, execSync } from "child_process";
@@ -625,6 +623,7 @@ var bridgeAgentKey = () => join3(pusharyDir(), "bridge-auth", "agent-key.json");
625
623
  var autoUpdateState = () => join3(pusharyDir(), "auto-update.json");
626
624
  var autoUpdateLock = () => join3(pusharyDir(), "auto-update.lock");
627
625
  var autoUpdateLog = () => join3(pusharyDir(), "logs", "auto-update.log");
626
+ var clientReportClaims = () => join3(pusharyDir(), "client-reports");
628
627
  var claudeRegistrationReceipt = () => join3(pusharyDir(), "setup", "claude-registration.json");
629
628
  var hermesConfigReceipt = () => join3(pusharyDir(), "setup", "hermes-config.json");
630
629
  var hookTakeoverReceipt = (agent) => join3(pusharyDir(), "setup", `hook-takeover-${agent}.json`);
@@ -633,6 +632,10 @@ var codexAgentsMd2 = () => join3(codexHome(), "AGENTS.md");
633
632
  var geminiSettings = () => join3(homedir2(), ".gemini", "settings.json");
634
633
  var geminiMd = () => join3(homedir2(), ".gemini", "GEMINI.md");
635
634
  var pusharyConfigFile = () => join3(homedir2(), ".pushary", "config.json");
635
+ var fxConfigDir = () => join3(homedir2(), ".fx");
636
+ var fxMcpProfile = () => join3(fxConfigDir(), "mcp.json");
637
+ var fxSettings = () => join3(fxConfigDir(), "settings.json");
638
+ var fxAgentsMd = () => join3(fxConfigDir(), "AGENTS.md");
636
639
 
637
640
  export {
638
641
  registeredCommands,
@@ -698,6 +701,7 @@ export {
698
701
  autoUpdateState,
699
702
  autoUpdateLock,
700
703
  autoUpdateLog,
704
+ clientReportClaims,
701
705
  claudeRegistrationReceipt,
702
706
  hermesConfigReceipt,
703
707
  hookTakeoverReceipt,
@@ -705,5 +709,9 @@ export {
705
709
  codexAgentsMd2,
706
710
  geminiSettings,
707
711
  geminiMd,
708
- pusharyConfigFile
712
+ pusharyConfigFile,
713
+ fxConfigDir,
714
+ fxMcpProfile,
715
+ fxSettings,
716
+ fxAgentsMd
709
717
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  activeHookSource,
3
3
  activeIdentity
4
- } from "./chunk-BG6OCZ4N.js";
4
+ } from "./chunk-WUNZAE7I.js";
5
5
  import {
6
6
  blockedActionFingerprint,
7
7
  defersToNativeMode,
@@ -9,11 +9,11 @@ import {
9
9
  hasBlockedActionHint,
10
10
  recordBlockedActionHint,
11
11
  reportMachineDenial
12
- } from "./chunk-UAV5MNKY.js";
12
+ } from "./chunk-52NVBNJT.js";
13
13
  import {
14
14
  isGatingMoment,
15
15
  recordKeylessMoment
16
- } from "./chunk-4KSTLHWY.js";
16
+ } from "./chunk-2C7CCWVX.js";
17
17
  import {
18
18
  denyReasonFrom,
19
19
  isDeferAnswer
@@ -36,7 +36,7 @@ import {
36
36
  reportEvent,
37
37
  scopePathFor,
38
38
  settleQuestionsForToolUse
39
- } from "./chunk-JBXUKGZS.js";
39
+ } from "./chunk-IJ6ECPA6.js";
40
40
  import {
41
41
  DECISION_STOP_REASON,
42
42
  askUser,
@@ -48,14 +48,14 @@ import {
48
48
  requestGate,
49
49
  sendNotification,
50
50
  waitForQuestion
51
- } from "./chunk-LVHGSD5E.js";
51
+ } from "./chunk-EGKXSQCY.js";
52
52
  import {
53
53
  getMachineId
54
- } from "./chunk-LM2IOEDK.js";
54
+ } from "./chunk-XNCMT7YY.js";
55
55
  import {
56
56
  getApiKey,
57
57
  getBaseUrl
58
- } from "./chunk-OSJEMXSR.js";
58
+ } from "./chunk-V4AQBAVG.js";
59
59
  import {
60
60
  AGENT_QUESTION_STRATEGY,
61
61
  GATE_BLOCK_REASON_MAX_LENGTH,
@@ -83,7 +83,7 @@ import {
83
83
  parseAgentQuestions,
84
84
  resolveGate,
85
85
  stoppedOutput
86
- } from "./chunk-GHOB245Q.js";
86
+ } from "./chunk-YROGUPOZ.js";
87
87
 
88
88
  // src/claude-permission-rules.ts
89
89
  import { readFileSync, statSync } from "fs";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  PRETOOLUSE_GATED_TOOLS
3
- } from "./chunk-GHOB245Q.js";
3
+ } from "./chunk-YROGUPOZ.js";
4
4
 
5
5
  // src/claude-tools.ts
6
6
  var POSTTOOLUSE_MIRROR_ONLY_TOOLS = ["TodoWrite", "Task", "WebFetch", "WebSearch"];
@@ -6,38 +6,38 @@ import {
6
6
  } from "./chunk-SGZJ5LYH.js";
7
7
  import {
8
8
  hookOwnerOf
9
- } from "./chunk-REYWOCQJ.js";
9
+ } from "./chunk-R2XCLT6I.js";
10
10
  import {
11
11
  ensureDaemonRunning
12
- } from "./chunk-QKOVVL7I.js";
12
+ } from "./chunk-73T6MSU5.js";
13
13
  import {
14
14
  buildTranscriptRecords,
15
15
  decodePublicKey,
16
16
  generateSessionKey,
17
17
  wrapSessionKey
18
- } from "./chunk-KNIIFNNQ.js";
18
+ } from "./chunk-BH2SKSSK.js";
19
19
  import {
20
20
  fetchTranscriptRecipients,
21
21
  uploadTranscriptRecords
22
- } from "./chunk-66H2QQAK.js";
22
+ } from "./chunk-KXMZMZD3.js";
23
23
  import {
24
24
  transcriptEnvironmentPreference,
25
25
  transcriptsEnabled
26
- } from "./chunk-JBU7XKY2.js";
26
+ } from "./chunk-B76WVEDX.js";
27
+ import {
28
+ readTranscriptPreference
29
+ } from "./chunk-UOAQ6QMP.js";
27
30
  import {
28
31
  codexHome,
29
32
  pusharyDir
30
- } from "./chunk-3BJQYXTL.js";
31
- import {
32
- readTranscriptPreference
33
- } from "./chunk-CWIARY6F.js";
33
+ } from "./chunk-DNJUSFBL.js";
34
34
  import {
35
35
  writeJsonAtomic
36
36
  } from "./chunk-T7E75EKA.js";
37
37
  import {
38
38
  getApiKey,
39
39
  getBaseUrl
40
- } from "./chunk-OSJEMXSR.js";
40
+ } from "./chunk-V4AQBAVG.js";
41
41
 
42
42
  // src/transcript-registration.ts
43
43
  import { createHash } from "crypto";
@@ -1,12 +1,16 @@
1
+ import {
2
+ clientErrorKindOf,
3
+ reportClientError
4
+ } from "./chunk-V6QRSU2G.js";
1
5
  import {
2
6
  callMcpTool
3
- } from "./chunk-HETOKNIL.js";
7
+ } from "./chunk-JNXVOU6Y.js";
4
8
  import {
5
- installProxyDispatcher
6
- } from "./chunk-SAF6HGAA.js";
9
+ installNetworkDefaults
10
+ } from "./chunk-KW2RRR7D.js";
7
11
  import {
8
12
  getBaseUrl
9
- } from "./chunk-OSJEMXSR.js";
13
+ } from "./chunk-V4AQBAVG.js";
10
14
 
11
15
  // src/api.ts
12
16
  import { randomUUID } from "crypto";
@@ -44,7 +48,7 @@ var isBlockedActionClaim = (data) => {
44
48
  };
45
49
 
46
50
  // src/api.ts
47
- installProxyDispatcher();
51
+ installNetworkDefaults();
48
52
  var DECISION_STOP_REASON = "Approval was cancelled or became unavailable. Retry only after resolving it.";
49
53
  var isDecisionStopped = (result) => result.handoffAction === "stop" || ["cancelled", "unavailable", "stopped", "missing"].includes(result.status ?? "");
50
54
  var isLocalQuestionHandoff = (result) => result.suppressed === true || result.noDevices === true || result.status === "terminal" || result.status === "notified";
@@ -130,7 +134,8 @@ var requestGate = async (apiKey, request, timeoutMs = 15e3) => {
130
134
  try {
131
135
  const reply = await postAgentRequest(apiKey, GATE_PATH, request, timeoutMs);
132
136
  return isGateReply(reply) ? reply : null;
133
- } catch {
137
+ } catch (error) {
138
+ void reportClientError({ kind: clientErrorKindOf(error), code: "gate_request_failed" });
134
139
  return null;
135
140
  }
136
141
  };
@@ -138,7 +143,8 @@ var claimBlockedAction = async (apiKey, request, timeoutMs) => {
138
143
  try {
139
144
  const reply = await postAgentRequest(apiKey, BLOCKED_ACTION_CLAIM_PATH, request, timeoutMs);
140
145
  return isBlockedActionClaim(reply) ? reply.granted : null;
141
- } catch {
146
+ } catch (error) {
147
+ void reportClientError({ kind: clientErrorKindOf(error), code: "blocked_action_claim_failed" });
142
148
  return null;
143
149
  }
144
150
  };
@@ -12,17 +12,17 @@ import {
12
12
  } from "./chunk-5RUIFDTP.js";
13
13
  import {
14
14
  callMcpTool
15
- } from "./chunk-HETOKNIL.js";
15
+ } from "./chunk-JNXVOU6Y.js";
16
16
  import {
17
17
  reportedInstallSource
18
- } from "./chunk-NPGOQQCV.js";
18
+ } from "./chunk-ROQK7IN3.js";
19
+ import {
20
+ NPX_LATEST_COMMAND
21
+ } from "./chunk-B3UXMSMW.js";
19
22
  import {
20
23
  PAIR_TTL_SECONDS,
21
24
  isAnswerSource
22
- } from "./chunk-GHOB245Q.js";
23
- import {
24
- NPX_LATEST_COMMAND
25
- } from "./chunk-EA3IELHP.js";
25
+ } from "./chunk-YROGUPOZ.js";
26
26
 
27
27
  // src/reach.ts
28
28
  var reachVerdict = (channels) => {
@@ -1,26 +1,30 @@
1
1
  import {
2
2
  NOTIFICATION_PUSH_TYPES,
3
3
  POSTTOOLUSE_MIRROR_ONLY_TOOLS
4
- } from "./chunk-BEHGVU4W.js";
4
+ } from "./chunk-DZURML2D.js";
5
5
  import {
6
6
  cancelQuestion,
7
7
  isPolicyConfig,
8
8
  sendNotification,
9
9
  waitForAnswer
10
- } from "./chunk-LVHGSD5E.js";
10
+ } from "./chunk-EGKXSQCY.js";
11
11
  import {
12
- getMachineId
13
- } from "./chunk-LM2IOEDK.js";
12
+ clientErrorKindOf,
13
+ reportClientError
14
+ } from "./chunk-V6QRSU2G.js";
14
15
  import {
15
16
  withRetry
16
- } from "./chunk-HETOKNIL.js";
17
+ } from "./chunk-JNXVOU6Y.js";
18
+ import {
19
+ getMachineId
20
+ } from "./chunk-XNCMT7YY.js";
17
21
  import {
18
22
  reportedInstallSource
19
- } from "./chunk-NPGOQQCV.js";
23
+ } from "./chunk-ROQK7IN3.js";
20
24
  import {
21
25
  getApiKey,
22
26
  getBaseUrl
23
- } from "./chunk-OSJEMXSR.js";
27
+ } from "./chunk-V4AQBAVG.js";
24
28
  import {
25
29
  ACTION_BODY_MAX,
26
30
  AGENT_LABELS_BY_TYPE,
@@ -44,7 +48,7 @@ import {
44
48
  resolveAutoResolveOrigin,
45
49
  resolvePolicy,
46
50
  toToolLookup
47
- } from "./chunk-GHOB245Q.js";
51
+ } from "./chunk-YROGUPOZ.js";
48
52
 
49
53
  // src/policy.ts
50
54
  import { createHash } from "crypto";
@@ -176,12 +180,14 @@ var fetchModeState = async (apiKey, sessionId, reuseWithinMs = 0, signal) => {
176
180
  signal: AbortSignal.any([AbortSignal.timeout(3e3), ...signal ? [signal] : []])
177
181
  });
178
182
  if (!response.ok) {
183
+ void reportClientError({ kind: "http_status", code: `mode_http_${response.status}` });
179
184
  return degradedFallback(apiKey, response.status === 401 || response.status === 403);
180
185
  }
181
186
  const state = modeStateFromResponse(await response.json());
182
187
  writeLastGoodMode(apiKey, state, sessionId);
183
188
  return state;
184
- } catch {
189
+ } catch (error) {
190
+ void reportClientError({ kind: clientErrorKindOf(error), code: "mode_fetch_failed" });
185
191
  return degradedFallback(apiKey);
186
192
  }
187
193
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  HOOK_HOLD_BUDGET_ENV,
3
3
  hookHoldBudgetProof
4
- } from "./chunk-GHOB245Q.js";
4
+ } from "./chunk-YROGUPOZ.js";
5
5
 
6
6
  // src/hold-budget.ts
7
7
  var takeHookHoldBudget = (args = process.argv.slice(2), env = process.env) => {
@@ -1,9 +1,9 @@
1
1
  import {
2
- installProxyDispatcher
3
- } from "./chunk-SAF6HGAA.js";
2
+ installNetworkDefaults
3
+ } from "./chunk-KW2RRR7D.js";
4
4
  import {
5
5
  getBaseUrl
6
- } from "./chunk-OSJEMXSR.js";
6
+ } from "./chunk-V4AQBAVG.js";
7
7
 
8
8
  // src/retry.ts
9
9
  var isRetryable = (err) => {
@@ -34,8 +34,8 @@ var withRetry = async (fn, options = {}) => {
34
34
  };
35
35
 
36
36
  // src/mcp-http.ts
37
- installProxyDispatcher();
38
- var parseSseJson = (body) => {
37
+ installNetworkDefaults();
38
+ var parseSseMessages = (body) => {
39
39
  const messages = [];
40
40
  for (const event of body.split(/\r?\n\r?\n/)) {
41
41
  const data = event.split(/\r?\n/).filter((line) => line.startsWith("data:")).map((line) => line.slice(5).trimStart()).join("\n").trim();
@@ -45,7 +45,10 @@ var parseSseJson = (body) => {
45
45
  } catch {
46
46
  }
47
47
  }
48
- const message = messages.at(-1);
48
+ return messages;
49
+ };
50
+ var parseSseJson = (body) => {
51
+ const message = parseSseMessages(body).at(-1);
49
52
  if (!message) throw new Error("Empty response from Pushary");
50
53
  return message;
51
54
  };
@@ -112,6 +115,7 @@ var callMcpTool = async (apiKey, toolName, params, options = {}) => {
112
115
 
113
116
  export {
114
117
  withRetry,
118
+ parseSseMessages,
115
119
  sendMcpRequest,
116
120
  callMcpTool
117
121
  };
@@ -2,10 +2,10 @@ import {
2
2
  resolveBinary,
3
3
  resolveGlobalPackageVersion,
4
4
  resolvePackageVersionFromBinary
5
- } from "./chunk-3BJQYXTL.js";
5
+ } from "./chunk-DNJUSFBL.js";
6
6
  import {
7
7
  MANAGED_PROVIDERS
8
- } from "./chunk-GHOB245Q.js";
8
+ } from "./chunk-YROGUPOZ.js";
9
9
 
10
10
  // src/live-capabilities.ts
11
11
  var CLAUDE_BRIDGE_CAPABILITY = "claude-bridge";
@@ -0,0 +1,124 @@
1
+ import {
2
+ readExistingMachineId
3
+ } from "./chunk-XNCMT7YY.js";
4
+ import {
5
+ NetworkError
6
+ } from "./chunk-7QLSKOSU.js";
7
+ import {
8
+ getBaseUrl
9
+ } from "./chunk-V4AQBAVG.js";
10
+ import {
11
+ clientContextHeaders,
12
+ getPackageVersion
13
+ } from "./chunk-YROGUPOZ.js";
14
+
15
+ // src/cli/net.ts
16
+ import { createRequire } from "module";
17
+
18
+ // src/cli/client-context.ts
19
+ import { randomUUID } from "crypto";
20
+ var CLI_RUN_ID = randomUUID();
21
+ var cliPlatform = () => `${process.platform}-${process.arch}`;
22
+ var memoizedContext = null;
23
+ var safeMachineId = () => {
24
+ try {
25
+ return readExistingMachineId();
26
+ } catch {
27
+ return null;
28
+ }
29
+ };
30
+ var readCliClientContext = () => ({
31
+ surface: "cli",
32
+ clientVersion: getPackageVersion(),
33
+ machineId: safeMachineId(),
34
+ runId: CLI_RUN_ID,
35
+ platform: cliPlatform()
36
+ });
37
+ var cliClientContext = () => {
38
+ if (memoizedContext) return memoizedContext;
39
+ const context = readCliClientContext();
40
+ if (context.machineId !== null) memoizedContext = context;
41
+ return context;
42
+ };
43
+ var originOf = (url) => {
44
+ try {
45
+ return new URL(url).origin;
46
+ } catch {
47
+ return null;
48
+ }
49
+ };
50
+ var requestUrlOf = (input) => typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
51
+ var isPusharyRequest = (input, baseUrl) => {
52
+ const target = originOf(requestUrlOf(input));
53
+ return target !== null && target === originOf(baseUrl);
54
+ };
55
+ var mergeClientContextHeaders = (input, init, context) => {
56
+ const headers = new Headers(input instanceof Request ? input.headers : void 0);
57
+ new Headers(init?.headers).forEach((value, name) => headers.set(name, value));
58
+ for (const [name, value] of Object.entries(clientContextHeaders(context))) {
59
+ if (!headers.has(name)) headers.set(name, value);
60
+ }
61
+ return headers;
62
+ };
63
+ var withClientContext = (fetchImpl, options) => (input, init) => isPusharyRequest(input, options.baseUrl()) ? fetchImpl(input, { ...init, headers: mergeClientContextHeaders(input, init, options.context()) }) : fetchImpl(input, init);
64
+ var installed = false;
65
+ var installClientContextHeaders = () => {
66
+ if (installed) return;
67
+ installed = true;
68
+ globalThis.fetch = withClientContext(globalThis.fetch.bind(globalThis), { baseUrl: getBaseUrl, context: cliClientContext });
69
+ };
70
+
71
+ // src/cli/net.ts
72
+ var requireCjs = createRequire(import.meta.url);
73
+ var PROXY_VARS = ["HTTPS_PROXY", "https_proxy", "HTTP_PROXY", "http_proxy"];
74
+ var proxyFromEnv = () => {
75
+ for (const name of PROXY_VARS) {
76
+ const value = process.env[name]?.trim();
77
+ if (value) return value;
78
+ }
79
+ return void 0;
80
+ };
81
+ var installed2 = false;
82
+ var installNetworkDefaults = () => {
83
+ if (installed2) return;
84
+ installed2 = true;
85
+ installClientContextHeaders();
86
+ if (!proxyFromEnv()) return;
87
+ try {
88
+ const { EnvHttpProxyAgent, setGlobalDispatcher } = requireCjs("undici");
89
+ setGlobalDispatcher(new EnvHttpProxyAgent());
90
+ } catch {
91
+ }
92
+ };
93
+ var isNetworkFailure = (err) => {
94
+ if (!(err instanceof Error)) return false;
95
+ const code = err.code;
96
+ if (code && ["ENOTFOUND", "ECONNREFUSED", "ECONNRESET", "ETIMEDOUT", "EAI_AGAIN", "EPROTO", "CERT_HAS_EXPIRED", "UNABLE_TO_VERIFY_LEAF_SIGNATURE"].includes(code)) {
97
+ return true;
98
+ }
99
+ return err.name === "AbortError" || err.name === "TimeoutError" || /fetch failed/i.test(err.message);
100
+ };
101
+ var DEFAULT_TIMEOUT_MS = 15e3;
102
+ var pusharyFetch = async (url, init = {}) => {
103
+ installNetworkDefaults();
104
+ const { timeoutMs = DEFAULT_TIMEOUT_MS, signal, ...rest } = init;
105
+ try {
106
+ return await fetch(url, {
107
+ ...rest,
108
+ signal: signal ?? AbortSignal.timeout(timeoutMs)
109
+ });
110
+ } catch (err) {
111
+ if (isNetworkFailure(err)) {
112
+ const proxy = proxyFromEnv();
113
+ const via = proxy ? ` (via proxy ${proxy})` : "";
114
+ throw new NetworkError(`Could not reach ${new URL(url).host}${via}: ${err instanceof Error ? err.message : String(err)}`);
115
+ }
116
+ throw err;
117
+ }
118
+ };
119
+
120
+ export {
121
+ installNetworkDefaults,
122
+ isNetworkFailure,
123
+ pusharyFetch
124
+ };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getBaseUrl
3
- } from "./chunk-OSJEMXSR.js";
3
+ } from "./chunk-V4AQBAVG.js";
4
4
 
5
5
  // src/transcript-api.ts
6
6
  var fetchTranscriptRecipients = async (apiKey, baseUrl = getBaseUrl()) => {
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  CLAUDE_HOOK_EVENTS,
3
3
  supportedClaudeEvents
4
- } from "./chunk-57DDP4TB.js";
4
+ } from "./chunk-ZQ7IDOKY.js";
5
5
  import {
6
6
  guardBinary,
7
7
  holdBudgetOf,
8
8
  isProtectedByScope,
9
9
  registerHookEntry
10
- } from "./chunk-3BJQYXTL.js";
10
+ } from "./chunk-DNJUSFBL.js";
11
11
  import {
12
12
  HOOK_LOCATOR_BINARY,
13
13
  withHookHoldBudget
14
- } from "./chunk-GHOB245Q.js";
14
+ } from "./chunk-YROGUPOZ.js";
15
15
 
16
16
  // src/claude-config.ts
17
17
  import { join } from "path";