pushary 1.8.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 (186) hide show
  1. package/CHANGELOG.md +1943 -0
  2. package/LICENSE +21 -0
  3. package/README.md +330 -0
  4. package/data/SKILL.md +591 -0
  5. package/data/cowork/SKILL.md +77 -0
  6. package/data/cursor-plugin/.cursor-plugin/plugin.json +25 -0
  7. package/data/cursor-plugin/CHANGELOG.md +70 -0
  8. package/data/cursor-plugin/CONTRIBUTING.md +40 -0
  9. package/data/cursor-plugin/LICENSE +21 -0
  10. package/data/cursor-plugin/README.md +113 -0
  11. package/data/cursor-plugin/SECURITY.md +33 -0
  12. package/data/cursor-plugin/assets/logo.png +0 -0
  13. package/data/cursor-plugin/commands/notify-when-done.md +14 -0
  14. package/data/cursor-plugin/commands/pushary-test.md +13 -0
  15. package/data/cursor-plugin/hooks/hooks.json +75 -0
  16. package/data/cursor-plugin/mcp.json +11 -0
  17. package/data/cursor-plugin/rules/pushary.mdc +40 -0
  18. package/data/cursor-plugin/scripts/pushary-gate.mjs +724 -0
  19. package/data/cursor-plugin/scripts/pushary-gate.test.mjs +137 -0
  20. package/data/cursor-plugin/scripts/redaction.mjs +51 -0
  21. package/data/cursor-plugin/skills/pushary/SKILL.md +584 -0
  22. package/data/vscode-plugin/.claude-plugin/plugin.json +28 -0
  23. package/data/vscode-plugin/.mcp.json +11 -0
  24. package/data/vscode-plugin/CHANGELOG.md +49 -0
  25. package/data/vscode-plugin/CONTRIBUTING.md +40 -0
  26. package/data/vscode-plugin/LICENSE +21 -0
  27. package/data/vscode-plugin/README.md +128 -0
  28. package/data/vscode-plugin/SECURITY.md +56 -0
  29. package/data/vscode-plugin/assets/logo.png +0 -0
  30. package/data/vscode-plugin/commands/notify-when-done.md +14 -0
  31. package/data/vscode-plugin/commands/pushary-test.md +13 -0
  32. package/data/vscode-plugin/hooks/hooks.json +60 -0
  33. package/data/vscode-plugin/scripts/pushary-gate.mjs +762 -0
  34. package/data/vscode-plugin/scripts/redaction.mjs +51 -0
  35. package/data/vscode-plugin/skills/pushary/SKILL.md +584 -0
  36. package/dist/bin/pushary-bell-hook.d.ts +1 -0
  37. package/dist/bin/pushary-bell-hook.js +46 -0
  38. package/dist/bin/pushary-bell.d.ts +1 -0
  39. package/dist/bin/pushary-bell.js +146 -0
  40. package/dist/bin/pushary-claude.d.ts +1 -0
  41. package/dist/bin/pushary-claude.js +1916 -0
  42. package/dist/bin/pushary-clean.d.ts +1 -0
  43. package/dist/bin/pushary-clean.js +1300 -0
  44. package/dist/bin/pushary-codex-bridge.d.ts +1 -0
  45. package/dist/bin/pushary-codex-bridge.js +599 -0
  46. package/dist/bin/pushary-codex-hook.d.ts +1 -0
  47. package/dist/bin/pushary-codex-hook.js +886 -0
  48. package/dist/bin/pushary-codex.d.ts +1 -0
  49. package/dist/bin/pushary-codex.js +125 -0
  50. package/dist/bin/pushary-connect.d.ts +1 -0
  51. package/dist/bin/pushary-connect.js +100 -0
  52. package/dist/bin/pushary-cowork.d.ts +1 -0
  53. package/dist/bin/pushary-cowork.js +36 -0
  54. package/dist/bin/pushary-daemon-supervisor.d.ts +1 -0
  55. package/dist/bin/pushary-daemon-supervisor.js +27 -0
  56. package/dist/bin/pushary-daemon.d.ts +1 -0
  57. package/dist/bin/pushary-daemon.js +878 -0
  58. package/dist/bin/pushary-disconnect.d.ts +1 -0
  59. package/dist/bin/pushary-disconnect.js +264 -0
  60. package/dist/bin/pushary-doctor.d.ts +1 -0
  61. package/dist/bin/pushary-doctor.js +1433 -0
  62. package/dist/bin/pushary-elicitation-hook.d.ts +1 -0
  63. package/dist/bin/pushary-elicitation-hook.js +149 -0
  64. package/dist/bin/pushary-gemini-bridge.d.ts +1 -0
  65. package/dist/bin/pushary-gemini-bridge.js +339 -0
  66. package/dist/bin/pushary-gemini-hook.d.ts +1 -0
  67. package/dist/bin/pushary-gemini-hook.js +381 -0
  68. package/dist/bin/pushary-hook.d.ts +1 -0
  69. package/dist/bin/pushary-hook.js +95 -0
  70. package/dist/bin/pushary-login.d.ts +1 -0
  71. package/dist/bin/pushary-login.js +198 -0
  72. package/dist/bin/pushary-logout.d.ts +1 -0
  73. package/dist/bin/pushary-logout.js +147 -0
  74. package/dist/bin/pushary-mcp.d.ts +1 -0
  75. package/dist/bin/pushary-mcp.js +114 -0
  76. package/dist/bin/pushary-mode.d.ts +1 -0
  77. package/dist/bin/pushary-mode.js +130 -0
  78. package/dist/bin/pushary-notification-hook.d.ts +1 -0
  79. package/dist/bin/pushary-notification-hook.js +56 -0
  80. package/dist/bin/pushary-opencode-hook.d.ts +1 -0
  81. package/dist/bin/pushary-opencode-hook.js +338 -0
  82. package/dist/bin/pushary-permission-denied-hook.d.ts +1 -0
  83. package/dist/bin/pushary-permission-denied-hook.js +60 -0
  84. package/dist/bin/pushary-permission-hook.d.ts +1 -0
  85. package/dist/bin/pushary-permission-hook.js +65 -0
  86. package/dist/bin/pushary-post-hook.d.ts +1 -0
  87. package/dist/bin/pushary-post-hook.js +70 -0
  88. package/dist/bin/pushary-prompt-hook.d.ts +1 -0
  89. package/dist/bin/pushary-prompt-hook.js +61 -0
  90. package/dist/bin/pushary-session-end-hook.d.ts +1 -0
  91. package/dist/bin/pushary-session-end-hook.js +59 -0
  92. package/dist/bin/pushary-session-start-hook.d.ts +1 -0
  93. package/dist/bin/pushary-session-start-hook.js +72 -0
  94. package/dist/bin/pushary-setup.d.ts +1 -0
  95. package/dist/bin/pushary-setup.js +2660 -0
  96. package/dist/bin/pushary-stats.d.ts +1 -0
  97. package/dist/bin/pushary-stats.js +44 -0
  98. package/dist/bin/pushary-status.d.ts +1 -0
  99. package/dist/bin/pushary-status.js +262 -0
  100. package/dist/bin/pushary-stop-hook.d.ts +1 -0
  101. package/dist/bin/pushary-stop-hook.js +63 -0
  102. package/dist/bin/pushary-stopfailure-hook.d.ts +1 -0
  103. package/dist/bin/pushary-stopfailure-hook.js +56 -0
  104. package/dist/bin/pushary-suggestions.d.ts +1 -0
  105. package/dist/bin/pushary-suggestions.js +100 -0
  106. package/dist/bin/pushary-transcript-register.d.ts +1 -0
  107. package/dist/bin/pushary-transcript-register.js +40 -0
  108. package/dist/bin/pushary-transcripts.d.ts +1 -0
  109. package/dist/bin/pushary-transcripts.js +77 -0
  110. package/dist/bin/pushary-upgrade.d.ts +1 -0
  111. package/dist/bin/pushary-upgrade.js +599 -0
  112. package/dist/bin/pushary-wait.d.ts +1 -0
  113. package/dist/bin/pushary-wait.js +122 -0
  114. package/dist/bin/pushary.d.ts +1 -0
  115. package/dist/bin/pushary.js +74 -0
  116. package/dist/chunk-2ABTSGFT.js +173 -0
  117. package/dist/chunk-2OY3ZZ5N.js +124 -0
  118. package/dist/chunk-3EGEA4KH.js +44 -0
  119. package/dist/chunk-3EVPNIBE.js +185 -0
  120. package/dist/chunk-5OP5MQI7.js +45 -0
  121. package/dist/chunk-6J2JC2RT.js +149 -0
  122. package/dist/chunk-7QLSKOSU.js +19 -0
  123. package/dist/chunk-7Z7Q4GGS.js +88 -0
  124. package/dist/chunk-A2A2YTMG.js +835 -0
  125. package/dist/chunk-AHV4LNB5.js +377 -0
  126. package/dist/chunk-AXPCESYO.js +197 -0
  127. package/dist/chunk-C2WCPBF7.js +86 -0
  128. package/dist/chunk-CJVVKOSR.js +73 -0
  129. package/dist/chunk-CULUZTWQ.js +2117 -0
  130. package/dist/chunk-CVQYGMSR.js +142 -0
  131. package/dist/chunk-CVWG2N3Y.js +16 -0
  132. package/dist/chunk-D2FX3EPW.js +15 -0
  133. package/dist/chunk-DB3ONZB4.js +44 -0
  134. package/dist/chunk-DE4Y6TCC.js +160 -0
  135. package/dist/chunk-E4FJTUH4.js +249 -0
  136. package/dist/chunk-EPCXUP3P.js +41 -0
  137. package/dist/chunk-EX3GAPA4.js +44 -0
  138. package/dist/chunk-EYK3GSRH.js +143 -0
  139. package/dist/chunk-GMXKITVA.js +70 -0
  140. package/dist/chunk-GPEGOGRJ.js +49 -0
  141. package/dist/chunk-GU3EJCVV.js +43 -0
  142. package/dist/chunk-HQ6G3B5R.js +59 -0
  143. package/dist/chunk-HZVVNGEW.js +22 -0
  144. package/dist/chunk-IPVKH2ST.js +231 -0
  145. package/dist/chunk-J5TIV3J6.js +238 -0
  146. package/dist/chunk-JU6W3XAU.js +64 -0
  147. package/dist/chunk-JYG4B33G.js +227 -0
  148. package/dist/chunk-JZTHGAPA.js +503 -0
  149. package/dist/chunk-KGDWDSNL.js +102 -0
  150. package/dist/chunk-KVQBWI5T.js +99 -0
  151. package/dist/chunk-KZERVKTD.js +16 -0
  152. package/dist/chunk-LXQ5FBBD.js +47 -0
  153. package/dist/chunk-M5ICYGHT.js +138 -0
  154. package/dist/chunk-M5JDZ45W.js +943 -0
  155. package/dist/chunk-MDEPU45E.js +1226 -0
  156. package/dist/chunk-MPWXGONV.js +157 -0
  157. package/dist/chunk-N6IOSZOE.js +185 -0
  158. package/dist/chunk-NGDD6TXY.js +192 -0
  159. package/dist/chunk-NQTHFF4W.js +2830 -0
  160. package/dist/chunk-OKXS7WDZ.js +68 -0
  161. package/dist/chunk-OLQRRFBX.js +21 -0
  162. package/dist/chunk-P7WQEVWA.js +307 -0
  163. package/dist/chunk-POFBE6ZY.js +12 -0
  164. package/dist/chunk-PQ4K74WL.js +30 -0
  165. package/dist/chunk-PUZZELE6.js +37 -0
  166. package/dist/chunk-Q7E4I6UA.js +767 -0
  167. package/dist/chunk-QCGNGEGE.js +15 -0
  168. package/dist/chunk-R7437YI3.js +151 -0
  169. package/dist/chunk-RHR6NARM.js +305 -0
  170. package/dist/chunk-SAXBC4AZ.js +60 -0
  171. package/dist/chunk-SGZJ5LYH.js +76 -0
  172. package/dist/chunk-SIFVFP6T.js +70 -0
  173. package/dist/chunk-SLFABHW3.js +150 -0
  174. package/dist/chunk-T7E75EKA.js +67 -0
  175. package/dist/chunk-TY4JT7W3.js +38 -0
  176. package/dist/chunk-U4TMAANR.js +111 -0
  177. package/dist/chunk-UI36QSBI.js +177 -0
  178. package/dist/chunk-VQKRG3AC.js +339 -0
  179. package/dist/chunk-WE2J62NC.js +1131 -0
  180. package/dist/chunk-XHKBHWLX.js +14 -0
  181. package/dist/chunk-ZSZSSJCV.js +275 -0
  182. package/dist/chunk-ZVSKMPBZ.js +135 -0
  183. package/dist/reapply-CW3MA66V.js +34 -0
  184. package/dist/src/index.d.ts +204 -0
  185. package/dist/src/index.js +64 -0
  186. package/package.json +108 -0
@@ -0,0 +1,99 @@
1
+ import {
2
+ pusharyHookExecutable
3
+ } from "./chunk-6J2JC2RT.js";
4
+ import {
5
+ isProtectedByScope,
6
+ registerHookEntry
7
+ } from "./chunk-A2A2YTMG.js";
8
+
9
+ // src/skills-cli.ts
10
+ import { execSync } from "child_process";
11
+ var PUSHARY_SKILL_SOURCE = "Pushary/pushary-skill";
12
+ var PUSHARY_SKILL_NAME = "pushary";
13
+ var installSkillViaSkillsCli = (agent) => {
14
+ try {
15
+ execSync(`npx -y skills@latest add ${PUSHARY_SKILL_SOURCE}@${PUSHARY_SKILL_NAME} -y -g --agent ${agent}`, {
16
+ stdio: "pipe",
17
+ timeout: 9e4
18
+ });
19
+ return true;
20
+ } catch {
21
+ return false;
22
+ }
23
+ };
24
+ var installAgentSkill = async (request, effects) => {
25
+ if (request.skillsCliInUse) {
26
+ const startedAt = effects.now();
27
+ if (effects.runSkillsCli(request.agent)) {
28
+ const modifiedAt = effects.skillModifiedAt(request.agentSkillDir);
29
+ if (modifiedAt !== null && modifiedAt >= startedAt) return "skills-cli";
30
+ }
31
+ }
32
+ await effects.writePackagedSkill(request.agentSkillDir);
33
+ return "packaged-copy";
34
+ };
35
+
36
+ // src/cursor-config.ts
37
+ var hookCommandOf = (entry) => {
38
+ const command = entry && typeof entry === "object" && !Array.isArray(entry) ? entry.command : void 0;
39
+ return typeof command === "string" ? command : "";
40
+ };
41
+ var isPusharyCursorEntry = (entry) => pusharyHookExecutable(hookCommandOf(entry)) !== null;
42
+ var registerCursorGate = (existing, entry) => registerHookEntry(existing, isPusharyCursorEntry, entry);
43
+ var withoutPusharyCursorHooks = (hooks, scope) => {
44
+ let removed = 0;
45
+ const kept = {};
46
+ for (const [event, entries] of Object.entries(hooks)) {
47
+ if (!Array.isArray(entries)) {
48
+ kept[event] = entries;
49
+ continue;
50
+ }
51
+ const others = entries.filter((entry) => !isPusharyCursorEntry(entry) || isProtectedByScope(hookCommandOf(entry), scope));
52
+ removed += entries.length - others.length;
53
+ if (others.length > 0 || entries.length === 0) kept[event] = others;
54
+ }
55
+ return { hooks: kept, removed };
56
+ };
57
+
58
+ // src/cli/dry-run.ts
59
+ import { execFileSync } from "child_process";
60
+ import { rmSync, writeFileSync } from "fs";
61
+ var createGuards = (isDryRun, note) => ({
62
+ write: (path, contents) => {
63
+ if (isDryRun()) return note("rewrite", path);
64
+ writeFileSync(path, contents, "utf-8");
65
+ },
66
+ remove: (path, options = {}) => {
67
+ if (isDryRun()) return note("remove ", path);
68
+ rmSync(path, { recursive: true, force: options.force ?? false });
69
+ },
70
+ execFile: (file, args, options, describe) => {
71
+ if (isDryRun()) return note("run ", describe);
72
+ execFileSync(file, args, options);
73
+ }
74
+ });
75
+ var describeService = (effects) => {
76
+ if (effects.controlMode === "off") return "skip the phone-start background service (--control off)";
77
+ const where = effects.serviceDefinitionPath ?? "the phone-start service definition";
78
+ const condition = effects.controlMode === "on" ? "" : ", when a supported agent and a service manager are present";
79
+ return `write ${where} and register it with the OS${condition}`;
80
+ };
81
+ var describeSetupSideEffects = (effects) => [
82
+ `run npm install -g ${effects.globalPackage}@${effects.version} (the hooks run from the global copy; up to two minutes)`,
83
+ `write ${effects.configFile} (the API key, mode 600)`,
84
+ effects.rcPath ? `edit ${effects.rcPath} (export PUSHARY_API_KEY)` : "print the export line for your shell, since no rc file was found",
85
+ describeService(effects),
86
+ "ask Add Pushary instructions to this project's CLAUDE.md/AGENTS.md? (default no)",
87
+ "ask Alias claude to pushary claude? (default no)"
88
+ ];
89
+
90
+ export {
91
+ PUSHARY_SKILL_SOURCE,
92
+ PUSHARY_SKILL_NAME,
93
+ installSkillViaSkillsCli,
94
+ installAgentSkill,
95
+ registerCursorGate,
96
+ withoutPusharyCursorHooks,
97
+ createGuards,
98
+ describeSetupSideEffects
99
+ };
@@ -0,0 +1,16 @@
1
+ // src/exit.ts
2
+ var EXIT = {
3
+ OK: 0,
4
+ FAILED: 1,
5
+ USAGE: 2,
6
+ NOT_CONFIGURED: 3,
7
+ UNAUTHENTICATED: 4,
8
+ PROBLEMS_FOUND: 5,
9
+ NO_DEVICE: 6,
10
+ INPUT_REQUIRED: 7,
11
+ UNREACHABLE: 8
12
+ };
13
+
14
+ export {
15
+ EXIT
16
+ };
@@ -0,0 +1,47 @@
1
+ import {
2
+ pusharyDir
3
+ } from "./chunk-A2A2YTMG.js";
4
+ import {
5
+ writeFileAtomic
6
+ } from "./chunk-T7E75EKA.js";
7
+
8
+ // src/identity.ts
9
+ import { randomUUID } from "crypto";
10
+ import { mkdirSync, readFileSync, writeFileSync } from "fs";
11
+ import { dirname, join } from "path";
12
+ var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
13
+ var readMachineId = (filePath) => {
14
+ try {
15
+ const value = readFileSync(filePath, "utf8").trim();
16
+ return UUID.test(value) ? value : null;
17
+ } catch {
18
+ return null;
19
+ }
20
+ };
21
+ var readExistingMachineId = (options = {}) => readMachineId(options.filePath ?? join(pusharyDir(), "machine-id"));
22
+ var getOrCreateMachineId = (options = {}) => {
23
+ const filePath = options.filePath ?? join(pusharyDir(), "machine-id");
24
+ const existing = readMachineId(filePath);
25
+ if (existing) return existing;
26
+ const id = (options.randomId ?? randomUUID)();
27
+ if (!UUID.test(id)) throw new Error("machine id generator returned an invalid UUID");
28
+ mkdirSync(dirname(filePath), { recursive: true });
29
+ try {
30
+ writeFileSync(filePath, `${id}
31
+ `, { flag: "wx", mode: 384 });
32
+ return id;
33
+ } catch (err) {
34
+ if (err.code !== "EEXIST") throw err;
35
+ }
36
+ const winner = readMachineId(filePath);
37
+ if (winner) return winner;
38
+ writeFileAtomic(filePath, `${id}
39
+ `, 384);
40
+ return id;
41
+ };
42
+ var getMachineId = (options = {}) => getOrCreateMachineId(options);
43
+
44
+ export {
45
+ readExistingMachineId,
46
+ getMachineId
47
+ };
@@ -0,0 +1,138 @@
1
+ import {
2
+ keyCheckFromResponse
3
+ } from "./chunk-2ABTSGFT.js";
4
+ import {
5
+ installNetworkDefaults
6
+ } from "./chunk-2OY3ZZ5N.js";
7
+ import {
8
+ getBaseUrl
9
+ } from "./chunk-GPEGOGRJ.js";
10
+
11
+ // src/retry.ts
12
+ var isRetryable = (err) => {
13
+ if (!(err instanceof Error)) return false;
14
+ const msg = err.message;
15
+ return /\b(502|503|429)\b/.test(msg) || /ECONNRESET|ECONNREFUSED|ETIMEDOUT|UND_ERR_CONNECT_TIMEOUT|fetch failed/i.test(msg) || msg.includes("AbortError");
16
+ };
17
+ var withRetry = async (fn, options = {}) => {
18
+ const {
19
+ maxAttempts = 3,
20
+ baseDelayMs = 500,
21
+ maxDelayMs = 5e3,
22
+ shouldRetry = isRetryable
23
+ } = options;
24
+ let lastError;
25
+ for (let attempt = 0; attempt < maxAttempts; attempt++) {
26
+ try {
27
+ return await fn();
28
+ } catch (err) {
29
+ lastError = err;
30
+ if (attempt + 1 >= maxAttempts || !shouldRetry(err)) throw err;
31
+ const jitter = Math.random() * 0.3 + 0.85;
32
+ const delay = Math.min(baseDelayMs * 2 ** attempt * jitter, maxDelayMs);
33
+ await new Promise((r) => setTimeout(r, delay));
34
+ }
35
+ }
36
+ throw lastError;
37
+ };
38
+
39
+ // src/mcp-http.ts
40
+ installNetworkDefaults();
41
+ var SUBSCRIPTION_REQUIRED_MESSAGE = "Pushary MCP error: 403 Subscription required";
42
+ var SubscriptionRequiredError = class extends Error {
43
+ plan;
44
+ upgradeUrl;
45
+ constructor(plan, upgradeUrl) {
46
+ super(SUBSCRIPTION_REQUIRED_MESSAGE);
47
+ this.name = "SubscriptionRequiredError";
48
+ this.plan = plan;
49
+ this.upgradeUrl = upgradeUrl;
50
+ }
51
+ };
52
+ var parseSseMessages = (body) => {
53
+ const messages = [];
54
+ for (const event of body.split(/\r?\n\r?\n/)) {
55
+ const data = event.split(/\r?\n/).filter((line) => line.startsWith("data:")).map((line) => line.slice(5).trimStart()).join("\n").trim();
56
+ if (!data) continue;
57
+ try {
58
+ messages.push(JSON.parse(data));
59
+ } catch {
60
+ }
61
+ }
62
+ return messages;
63
+ };
64
+ var parseSseJson = (body) => {
65
+ const message = parseSseMessages(body).at(-1);
66
+ if (!message) throw new Error("Empty response from Pushary");
67
+ return message;
68
+ };
69
+ var parseMcpResponse = (body, contentType) => {
70
+ if (contentType?.includes("text/event-stream")) {
71
+ return parseSseJson(body);
72
+ }
73
+ return JSON.parse(body);
74
+ };
75
+ var sendMcpRequest = async (apiKey, message, options = {}) => {
76
+ return withRetry(async () => {
77
+ options.signal?.throwIfAborted();
78
+ const baseUrl = options.baseUrl ?? getBaseUrl();
79
+ const fetchFn = options.fetchFn ?? fetch;
80
+ const headers = {
81
+ "Content-Type": "application/json",
82
+ "Accept": "application/json, text/event-stream",
83
+ "Authorization": `Bearer ${apiKey}`
84
+ };
85
+ if (options.sessionId) {
86
+ headers["Mcp-Session-Id"] = options.sessionId;
87
+ }
88
+ const response = await fetchFn(`${baseUrl}/api/mcp/mcp`, {
89
+ method: "POST",
90
+ headers,
91
+ body: JSON.stringify(message),
92
+ signal: options.timeoutMs ? AbortSignal.any([AbortSignal.timeout(options.timeoutMs), ...options.signal ? [options.signal] : []]) : options.signal
93
+ });
94
+ const lock = response.ok ? null : await keyCheckFromResponse(response, baseUrl);
95
+ if (lock?.kind === "locked") throw new SubscriptionRequiredError(lock.plan, lock.upgradeUrl);
96
+ const body = await response.text();
97
+ const contentType = response.headers.get("content-type");
98
+ let data = null;
99
+ if (body.trim()) {
100
+ try {
101
+ data = parseMcpResponse(body, contentType);
102
+ } catch (err) {
103
+ if (response.ok) throw err;
104
+ }
105
+ }
106
+ if (!response.ok) {
107
+ const msg = data?.error?.message ?? (body.trim() || response.statusText);
108
+ throw new Error(`Pushary MCP error: ${response.status} ${msg}`);
109
+ }
110
+ if (!data) throw new Error("Empty response from Pushary");
111
+ if (data.error) throw new Error(data.error.message ?? "Pushary MCP error");
112
+ return {
113
+ data,
114
+ sessionId: response.headers.get("mcp-session-id") ?? "",
115
+ status: response.status,
116
+ statusText: response.statusText
117
+ };
118
+ }, { maxAttempts: options.maxRetries ?? 1 });
119
+ };
120
+ var callMcpTool = async (apiKey, toolName, params, options = {}) => {
121
+ const { data } = await sendMcpRequest(apiKey, {
122
+ jsonrpc: "2.0",
123
+ id: options.id ?? Date.now(),
124
+ method: "tools/call",
125
+ params: { name: toolName, arguments: params }
126
+ }, options);
127
+ const text = data.result?.content?.[0]?.text;
128
+ if (!text) throw new Error("Empty response from Pushary");
129
+ return JSON.parse(text);
130
+ };
131
+
132
+ export {
133
+ withRetry,
134
+ SubscriptionRequiredError,
135
+ parseSseMessages,
136
+ sendMcpRequest,
137
+ callMcpTool
138
+ };