@beeper/desktop-mcp 4.2.3 → 4.6.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 (384) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +18 -199
  3. package/auth.d.mts +6 -0
  4. package/auth.d.mts.map +1 -0
  5. package/auth.d.ts +6 -0
  6. package/auth.d.ts.map +1 -0
  7. package/auth.js +37 -0
  8. package/auth.js.map +1 -0
  9. package/auth.mjs +32 -0
  10. package/auth.mjs.map +1 -0
  11. package/code-tool-types.d.mts +7 -7
  12. package/code-tool-types.d.mts.map +1 -1
  13. package/code-tool-types.d.ts +7 -7
  14. package/code-tool-types.d.ts.map +1 -1
  15. package/code-tool-worker.d.mts.map +1 -1
  16. package/code-tool-worker.d.ts.map +1 -1
  17. package/code-tool-worker.js +103 -19
  18. package/code-tool-worker.js.map +1 -1
  19. package/code-tool-worker.mjs +103 -19
  20. package/code-tool-worker.mjs.map +1 -1
  21. package/code-tool.d.mts +12 -3
  22. package/code-tool.d.mts.map +1 -1
  23. package/code-tool.d.ts +12 -3
  24. package/code-tool.d.ts.map +1 -1
  25. package/code-tool.js +276 -95
  26. package/code-tool.js.map +1 -1
  27. package/code-tool.mjs +273 -95
  28. package/code-tool.mjs.map +1 -1
  29. package/http.d.mts +6 -9
  30. package/http.d.mts.map +1 -1
  31. package/http.d.ts +6 -9
  32. package/http.d.ts.map +1 -1
  33. package/http.js +81 -47
  34. package/http.js.map +1 -1
  35. package/http.mjs +80 -43
  36. package/http.mjs.map +1 -1
  37. package/index.js +19 -50
  38. package/index.js.map +1 -1
  39. package/index.mjs +19 -50
  40. package/index.mjs.map +1 -1
  41. package/instructions.d.mts +2 -0
  42. package/instructions.d.mts.map +1 -0
  43. package/instructions.d.ts +2 -0
  44. package/instructions.d.ts.map +1 -0
  45. package/instructions.js +48 -0
  46. package/instructions.js.map +1 -0
  47. package/instructions.mjs +45 -0
  48. package/instructions.mjs.map +1 -0
  49. package/logger.d.mts +7 -0
  50. package/logger.d.mts.map +1 -0
  51. package/logger.d.ts +7 -0
  52. package/logger.d.ts.map +1 -0
  53. package/logger.js +29 -0
  54. package/logger.js.map +1 -0
  55. package/logger.mjs +22 -0
  56. package/logger.mjs.map +1 -0
  57. package/methods.d.mts +10 -0
  58. package/methods.d.mts.map +1 -0
  59. package/methods.d.ts +10 -0
  60. package/methods.d.ts.map +1 -0
  61. package/methods.js +203 -0
  62. package/methods.js.map +1 -0
  63. package/methods.mjs +199 -0
  64. package/methods.mjs.map +1 -0
  65. package/options.d.mts +9 -10
  66. package/options.d.mts.map +1 -1
  67. package/options.d.ts +9 -10
  68. package/options.d.ts.map +1 -1
  69. package/options.js +52 -363
  70. package/options.js.map +1 -1
  71. package/options.mjs +52 -363
  72. package/options.mjs.map +1 -1
  73. package/package.json +68 -82
  74. package/server.d.mts +10 -16
  75. package/server.d.mts.map +1 -1
  76. package/server.d.ts +10 -16
  77. package/server.d.ts.map +1 -1
  78. package/server.js +82 -105
  79. package/server.js.map +1 -1
  80. package/server.mjs +81 -100
  81. package/server.mjs.map +1 -1
  82. package/src/auth.ts +42 -0
  83. package/src/code-tool-types.ts +8 -5
  84. package/src/code-tool-worker.ts +118 -34
  85. package/src/code-tool.ts +359 -118
  86. package/src/http.ts +99 -50
  87. package/src/index.ts +22 -63
  88. package/src/instructions.ts +67 -0
  89. package/src/logger.ts +28 -0
  90. package/src/methods.ts +224 -0
  91. package/src/options.ts +69 -390
  92. package/src/server.ts +95 -121
  93. package/src/stdio.ts +6 -5
  94. package/src/{tools/types.ts → types.ts} +25 -5
  95. package/src/util.ts +25 -0
  96. package/stdio.d.mts +1 -1
  97. package/stdio.d.mts.map +1 -1
  98. package/stdio.d.ts +1 -1
  99. package/stdio.d.ts.map +1 -1
  100. package/stdio.js +5 -4
  101. package/stdio.js.map +1 -1
  102. package/stdio.mjs +5 -4
  103. package/stdio.mjs.map +1 -1
  104. package/{tools/types.d.mts → types.d.mts} +10 -2
  105. package/types.d.mts.map +1 -0
  106. package/{tools/types.d.ts → types.d.ts} +10 -2
  107. package/types.d.ts.map +1 -0
  108. package/{tools/types.js → types.js} +12 -0
  109. package/types.js.map +1 -0
  110. package/{tools/types.mjs → types.mjs} +11 -0
  111. package/types.mjs.map +1 -0
  112. package/util.d.mts +4 -0
  113. package/util.d.mts.map +1 -0
  114. package/util.d.ts +4 -0
  115. package/util.d.ts.map +1 -0
  116. package/util.js +30 -0
  117. package/util.js.map +1 -0
  118. package/util.mjs +24 -0
  119. package/util.mjs.map +1 -0
  120. package/compat.d.mts +0 -58
  121. package/compat.d.mts.map +0 -1
  122. package/compat.d.ts +0 -58
  123. package/compat.d.ts.map +0 -1
  124. package/compat.js +0 -387
  125. package/compat.js.map +0 -1
  126. package/compat.mjs +0 -378
  127. package/compat.mjs.map +0 -1
  128. package/docs-search-tool.d.mts +0 -44
  129. package/docs-search-tool.d.mts.map +0 -1
  130. package/docs-search-tool.d.ts +0 -44
  131. package/docs-search-tool.d.ts.map +0 -1
  132. package/docs-search-tool.js +0 -43
  133. package/docs-search-tool.js.map +0 -1
  134. package/docs-search-tool.mjs +0 -39
  135. package/docs-search-tool.mjs.map +0 -1
  136. package/dynamic-tools.d.mts +0 -12
  137. package/dynamic-tools.d.mts.map +0 -1
  138. package/dynamic-tools.d.ts +0 -12
  139. package/dynamic-tools.d.ts.map +0 -1
  140. package/dynamic-tools.js +0 -135
  141. package/dynamic-tools.js.map +0 -1
  142. package/dynamic-tools.mjs +0 -132
  143. package/dynamic-tools.mjs.map +0 -1
  144. package/filtering.d.mts +0 -2
  145. package/filtering.d.mts.map +0 -1
  146. package/filtering.d.ts +0 -2
  147. package/filtering.d.ts.map +0 -1
  148. package/filtering.js +0 -20
  149. package/filtering.js.map +0 -1
  150. package/filtering.mjs +0 -13
  151. package/filtering.mjs.map +0 -1
  152. package/handlers/get-accounts.d.mts +0 -3
  153. package/handlers/get-accounts.d.mts.map +0 -1
  154. package/handlers/get-accounts.d.ts +0 -3
  155. package/handlers/get-accounts.d.ts.map +0 -1
  156. package/handlers/get-accounts.js +0 -32
  157. package/handlers/get-accounts.js.map +0 -1
  158. package/handlers/get-accounts.mjs +0 -28
  159. package/handlers/get-accounts.mjs.map +0 -1
  160. package/handlers/get-chat.d.mts +0 -3
  161. package/handlers/get-chat.d.mts.map +0 -1
  162. package/handlers/get-chat.d.ts +0 -3
  163. package/handlers/get-chat.d.ts.map +0 -1
  164. package/handlers/get-chat.js +0 -20
  165. package/handlers/get-chat.js.map +0 -1
  166. package/handlers/get-chat.mjs +0 -16
  167. package/handlers/get-chat.mjs.map +0 -1
  168. package/handlers/index.d.mts +0 -3
  169. package/handlers/index.d.mts.map +0 -1
  170. package/handlers/index.d.ts +0 -3
  171. package/handlers/index.d.ts.map +0 -1
  172. package/handlers/index.js +0 -30
  173. package/handlers/index.js.map +0 -1
  174. package/handlers/index.mjs +0 -27
  175. package/handlers/index.mjs.map +0 -1
  176. package/handlers/list-chats.d.mts +0 -3
  177. package/handlers/list-chats.d.mts.map +0 -1
  178. package/handlers/list-chats.d.ts +0 -3
  179. package/handlers/list-chats.d.ts.map +0 -1
  180. package/handlers/list-chats.js +0 -46
  181. package/handlers/list-chats.js.map +0 -1
  182. package/handlers/list-chats.mjs +0 -42
  183. package/handlers/list-chats.mjs.map +0 -1
  184. package/handlers/list-messages.d.mts +0 -3
  185. package/handlers/list-messages.d.mts.map +0 -1
  186. package/handlers/list-messages.d.ts +0 -3
  187. package/handlers/list-messages.d.ts.map +0 -1
  188. package/handlers/list-messages.js +0 -34
  189. package/handlers/list-messages.js.map +0 -1
  190. package/handlers/list-messages.mjs +0 -30
  191. package/handlers/list-messages.mjs.map +0 -1
  192. package/handlers/open-app.d.mts +0 -3
  193. package/handlers/open-app.d.mts.map +0 -1
  194. package/handlers/open-app.d.ts +0 -3
  195. package/handlers/open-app.d.ts.map +0 -1
  196. package/handlers/open-app.js +0 -26
  197. package/handlers/open-app.js.map +0 -1
  198. package/handlers/open-app.mjs +0 -22
  199. package/handlers/open-app.mjs.map +0 -1
  200. package/handlers/search-chats.d.mts +0 -3
  201. package/handlers/search-chats.d.mts.map +0 -1
  202. package/handlers/search-chats.d.ts +0 -3
  203. package/handlers/search-chats.d.ts.map +0 -1
  204. package/handlers/search-chats.js +0 -38
  205. package/handlers/search-chats.js.map +0 -1
  206. package/handlers/search-chats.mjs +0 -34
  207. package/handlers/search-chats.mjs.map +0 -1
  208. package/handlers/search-messages.d.mts +0 -3
  209. package/handlers/search-messages.d.mts.map +0 -1
  210. package/handlers/search-messages.d.ts +0 -3
  211. package/handlers/search-messages.d.ts.map +0 -1
  212. package/handlers/search-messages.js +0 -11
  213. package/handlers/search-messages.js.map +0 -1
  214. package/handlers/search-messages.mjs +0 -7
  215. package/handlers/search-messages.mjs.map +0 -1
  216. package/handlers/search.d.mts +0 -3
  217. package/handlers/search.d.mts.map +0 -1
  218. package/handlers/search.d.ts +0 -3
  219. package/handlers/search.d.ts.map +0 -1
  220. package/handlers/search.js +0 -29
  221. package/handlers/search.js.map +0 -1
  222. package/handlers/search.mjs +0 -25
  223. package/handlers/search.mjs.map +0 -1
  224. package/handlers/send-message.d.mts +0 -3
  225. package/handlers/send-message.d.mts.map +0 -1
  226. package/handlers/send-message.d.ts +0 -3
  227. package/handlers/send-message.d.ts.map +0 -1
  228. package/handlers/send-message.js +0 -20
  229. package/handlers/send-message.js.map +0 -1
  230. package/handlers/send-message.mjs +0 -16
  231. package/handlers/send-message.mjs.map +0 -1
  232. package/handlers/utils.d.mts +0 -29
  233. package/handlers/utils.d.mts.map +0 -1
  234. package/handlers/utils.d.ts +0 -29
  235. package/handlers/utils.d.ts.map +0 -1
  236. package/handlers/utils.js +0 -296
  237. package/handlers/utils.js.map +0 -1
  238. package/handlers/utils.mjs +0 -282
  239. package/handlers/utils.mjs.map +0 -1
  240. package/headers.d.mts +0 -4
  241. package/headers.d.mts.map +0 -1
  242. package/headers.d.ts +0 -4
  243. package/headers.d.ts.map +0 -1
  244. package/headers.js +0 -22
  245. package/headers.js.map +0 -1
  246. package/headers.mjs +0 -18
  247. package/headers.mjs.map +0 -1
  248. package/src/compat.ts +0 -483
  249. package/src/docs-search-tool.ts +0 -48
  250. package/src/dynamic-tools.ts +0 -159
  251. package/src/filtering.ts +0 -14
  252. package/src/handlers/get-accounts.ts +0 -28
  253. package/src/handlers/get-chat.ts +0 -18
  254. package/src/handlers/index.ts +0 -29
  255. package/src/handlers/list-chats.ts +0 -47
  256. package/src/handlers/list-messages.ts +0 -33
  257. package/src/handlers/open-app.ts +0 -20
  258. package/src/handlers/search-chats.ts +0 -39
  259. package/src/handlers/search-messages.ts +0 -8
  260. package/src/handlers/search.ts +0 -24
  261. package/src/handlers/send-message.ts +0 -17
  262. package/src/handlers/utils.ts +0 -381
  263. package/src/headers.ts +0 -23
  264. package/src/tools/accounts/get-accounts.ts +0 -34
  265. package/src/tools/chats/archive-chat.ts +0 -43
  266. package/src/tools/chats/get-chat.ts +0 -45
  267. package/src/tools/chats/reminders/clear-chat-reminder.ts +0 -41
  268. package/src/tools/chats/reminders/set-chat-reminder.ts +0 -54
  269. package/src/tools/chats/search-chats.ts +0 -104
  270. package/src/tools/index.ts +0 -92
  271. package/src/tools/messages/list-messages.ts +0 -51
  272. package/src/tools/messages/search-messages.ts +0 -123
  273. package/src/tools/messages/send-message.ts +0 -47
  274. package/src/tools/top-level/focus-app.ts +0 -52
  275. package/src/tools/top-level/search.ts +0 -41
  276. package/src/tools.ts +0 -1
  277. package/tools/accounts/get-accounts.d.mts +0 -45
  278. package/tools/accounts/get-accounts.d.mts.map +0 -1
  279. package/tools/accounts/get-accounts.d.ts +0 -45
  280. package/tools/accounts/get-accounts.d.ts.map +0 -1
  281. package/tools/accounts/get-accounts.js +0 -31
  282. package/tools/accounts/get-accounts.js.map +0 -1
  283. package/tools/accounts/get-accounts.mjs +0 -27
  284. package/tools/accounts/get-accounts.mjs.map +0 -1
  285. package/tools/chats/archive-chat.d.mts +0 -45
  286. package/tools/chats/archive-chat.d.mts.map +0 -1
  287. package/tools/chats/archive-chat.d.ts +0 -45
  288. package/tools/chats/archive-chat.d.ts.map +0 -1
  289. package/tools/chats/archive-chat.js +0 -40
  290. package/tools/chats/archive-chat.js.map +0 -1
  291. package/tools/chats/archive-chat.mjs +0 -36
  292. package/tools/chats/archive-chat.mjs.map +0 -1
  293. package/tools/chats/get-chat.d.mts +0 -45
  294. package/tools/chats/get-chat.d.mts.map +0 -1
  295. package/tools/chats/get-chat.d.ts +0 -45
  296. package/tools/chats/get-chat.d.ts.map +0 -1
  297. package/tools/chats/get-chat.js +0 -41
  298. package/tools/chats/get-chat.js.map +0 -1
  299. package/tools/chats/get-chat.mjs +0 -37
  300. package/tools/chats/get-chat.mjs.map +0 -1
  301. package/tools/chats/reminders/clear-chat-reminder.d.mts +0 -45
  302. package/tools/chats/reminders/clear-chat-reminder.d.mts.map +0 -1
  303. package/tools/chats/reminders/clear-chat-reminder.d.ts +0 -45
  304. package/tools/chats/reminders/clear-chat-reminder.d.ts.map +0 -1
  305. package/tools/chats/reminders/clear-chat-reminder.js +0 -38
  306. package/tools/chats/reminders/clear-chat-reminder.js.map +0 -1
  307. package/tools/chats/reminders/clear-chat-reminder.mjs +0 -34
  308. package/tools/chats/reminders/clear-chat-reminder.mjs.map +0 -1
  309. package/tools/chats/reminders/set-chat-reminder.d.mts +0 -45
  310. package/tools/chats/reminders/set-chat-reminder.d.mts.map +0 -1
  311. package/tools/chats/reminders/set-chat-reminder.d.ts +0 -45
  312. package/tools/chats/reminders/set-chat-reminder.d.ts.map +0 -1
  313. package/tools/chats/reminders/set-chat-reminder.js +0 -51
  314. package/tools/chats/reminders/set-chat-reminder.js.map +0 -1
  315. package/tools/chats/reminders/set-chat-reminder.mjs +0 -47
  316. package/tools/chats/reminders/set-chat-reminder.mjs.map +0 -1
  317. package/tools/chats/search-chats.d.mts +0 -45
  318. package/tools/chats/search-chats.d.mts.map +0 -1
  319. package/tools/chats/search-chats.d.ts +0 -45
  320. package/tools/chats/search-chats.d.ts.map +0 -1
  321. package/tools/chats/search-chats.js +0 -92
  322. package/tools/chats/search-chats.js.map +0 -1
  323. package/tools/chats/search-chats.mjs +0 -88
  324. package/tools/chats/search-chats.mjs.map +0 -1
  325. package/tools/index.d.mts +0 -10
  326. package/tools/index.d.mts.map +0 -1
  327. package/tools/index.d.ts +0 -10
  328. package/tools/index.d.ts.map +0 -1
  329. package/tools/index.js +0 -76
  330. package/tools/index.js.map +0 -1
  331. package/tools/index.mjs +0 -69
  332. package/tools/index.mjs.map +0 -1
  333. package/tools/messages/list-messages.d.mts +0 -45
  334. package/tools/messages/list-messages.d.mts.map +0 -1
  335. package/tools/messages/list-messages.d.ts +0 -45
  336. package/tools/messages/list-messages.d.ts.map +0 -1
  337. package/tools/messages/list-messages.js +0 -47
  338. package/tools/messages/list-messages.js.map +0 -1
  339. package/tools/messages/list-messages.mjs +0 -43
  340. package/tools/messages/list-messages.mjs.map +0 -1
  341. package/tools/messages/search-messages.d.mts +0 -45
  342. package/tools/messages/search-messages.d.mts.map +0 -1
  343. package/tools/messages/search-messages.d.ts +0 -45
  344. package/tools/messages/search-messages.d.ts.map +0 -1
  345. package/tools/messages/search-messages.js +0 -110
  346. package/tools/messages/search-messages.js.map +0 -1
  347. package/tools/messages/search-messages.mjs +0 -106
  348. package/tools/messages/search-messages.mjs.map +0 -1
  349. package/tools/messages/send-message.d.mts +0 -45
  350. package/tools/messages/send-message.d.mts.map +0 -1
  351. package/tools/messages/send-message.d.ts +0 -45
  352. package/tools/messages/send-message.d.ts.map +0 -1
  353. package/tools/messages/send-message.js +0 -43
  354. package/tools/messages/send-message.js.map +0 -1
  355. package/tools/messages/send-message.mjs +0 -39
  356. package/tools/messages/send-message.mjs.map +0 -1
  357. package/tools/top-level/focus-app.d.mts +0 -45
  358. package/tools/top-level/focus-app.d.mts.map +0 -1
  359. package/tools/top-level/focus-app.d.ts +0 -45
  360. package/tools/top-level/focus-app.d.ts.map +0 -1
  361. package/tools/top-level/focus-app.js +0 -47
  362. package/tools/top-level/focus-app.js.map +0 -1
  363. package/tools/top-level/focus-app.mjs +0 -43
  364. package/tools/top-level/focus-app.mjs.map +0 -1
  365. package/tools/top-level/search.d.mts +0 -45
  366. package/tools/top-level/search.d.mts.map +0 -1
  367. package/tools/top-level/search.d.ts +0 -45
  368. package/tools/top-level/search.d.ts.map +0 -1
  369. package/tools/top-level/search.js +0 -37
  370. package/tools/top-level/search.js.map +0 -1
  371. package/tools/top-level/search.mjs +0 -33
  372. package/tools/top-level/search.mjs.map +0 -1
  373. package/tools/types.d.mts.map +0 -1
  374. package/tools/types.d.ts.map +0 -1
  375. package/tools/types.js.map +0 -1
  376. package/tools/types.mjs.map +0 -1
  377. package/tools.d.mts +0 -2
  378. package/tools.d.mts.map +0 -1
  379. package/tools.d.ts +0 -2
  380. package/tools.d.ts.map +0 -1
  381. package/tools.js +0 -18
  382. package/tools.js.map +0 -1
  383. package/tools.mjs +0 -2
  384. package/tools.mjs.map +0 -1
package/code-tool.mjs CHANGED
@@ -1,6 +1,38 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
- import { dirname } from 'node:path';
3
- import { pathToFileURL } from 'node:url';
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+ import url from 'node:url';
5
+ import { newDenoHTTPWorker } from '@valtown/deno-http-worker';
6
+ import { workerPath } from './code-tool-paths.cjs';
7
+ import { asErrorResult, asTextContentResult, } from "./types.mjs";
8
+ import { readEnv, requireValue } from "./util.mjs";
9
+ import { getLogger } from "./logger.mjs";
10
+ const prompt = `Runs JavaScript code to interact with the Beeper Desktop API.
11
+
12
+ You are a skilled TypeScript programmer writing code to interface with the service.
13
+ Define an async function named "run" that takes a single parameter of an initialized SDK client and it will be run.
14
+ For example:
15
+
16
+ \`\`\`
17
+ async function run(client) {
18
+ const page = await client.chats.search({
19
+ includeMuted: true,
20
+ limit: 3,
21
+ type: 'single',
22
+ });
23
+ const chat = page.items[0]
24
+
25
+ console.log(chat.id);
26
+ }
27
+ \`\`\`
28
+
29
+ You will be returned anything that your function returns, plus the results of any console.log statements.
30
+ Do not add try-catch blocks for single API calls. The tool will handle errors for you.
31
+ Do not add comments unless necessary for generating better code.
32
+ Code will run in a container, and cannot interact with the network outside of the given SDK client.
33
+ Variables will not persist between calls, so make sure to return or log any data you might need later.
34
+ Remember that you are writing TypeScript code, so you need to be careful with your types.
35
+ Always type dynamic key-value stores explicitly as Record<string, YourValueType> instead of {}.`;
4
36
  /**
5
37
  * A tool that runs code against a copy of the SDK.
6
38
  *
@@ -8,112 +40,258 @@ import { pathToFileURL } from 'node:url';
8
40
  * we expose a single tool that can be used to search for endpoints by name, resource, operation, or tag, and then
9
41
  * a generic endpoint that can be used to invoke any endpoint with the provided arguments.
10
42
  *
11
- * @param endpoints - The endpoints to include in the list.
43
+ * @param blockedMethods - The methods to block for code execution. Blocking is done by simple string
44
+ * matching, so it is not secure against obfuscation. For stronger security, block in the downstream API
45
+ * with limited API keys.
46
+ * @param codeExecutionMode - Whether to execute code in a local Deno environment or in a remote
47
+ * sandbox environment hosted by Stainless.
12
48
  */
13
- export async function codeTool() {
49
+ export function codeTool({ blockedMethods, codeExecutionMode, }) {
14
50
  const metadata = { resource: 'all', operation: 'write', tags: [] };
15
51
  const tool = {
16
52
  name: 'execute',
17
- description: 'Runs JavaScript code to interact with the API.\n\nYou are a skilled programmer writing code to interface with the service.\nDefine an async function named "run" that takes a single parameter of an initialized client named "client", and it will be run.\nWrite code within this template:\n\n```\nasync function run(client) {\n // Fill this out\n}\n```\n\nYou will be returned anything that your function returns, plus the results of any console.log statements.\nIf any code triggers an error, the tool will return an error response, so you do not need to add error handling unless you want to output something more helpful than the raw error.\nIt is not necessary to add comments to code, unless by adding those comments you believe that you can generate better code.\nThis code will run in a container, and you will not be able to use fetch or otherwise interact with the network calls other than through the client you are given.\nAny variables you define won\'t live between successive uses of this call, so make sure to return or log any data you might need later.',
18
- inputSchema: { type: 'object', properties: { code: { type: 'string' } } },
19
- };
20
- // Import dynamically to avoid failing at import time in cases where the environment is not well-supported.
21
- const { newDenoHTTPWorker } = await import('@valtown/deno-http-worker');
22
- const { workerPath } = await import('./code-tool-paths.cjs');
23
- const handler = async (client, args) => {
24
- const baseURLHostname = new URL(client.baseURL).hostname;
25
- const { code } = args;
26
- const worker = await newDenoHTTPWorker(pathToFileURL(workerPath), {
27
- runFlags: [
28
- `--node-modules-dir=manual`,
29
- `--allow-read=code-tool-worker.mjs,${workerPath.replace(/([\/\\]node_modules)[\/\\].+$/, '$1')}/`,
30
- `--allow-net=${baseURLHostname}`,
31
- // Allow environment variables because instantiating the client will try to read from them,
32
- // even though they are not set.
33
- '--allow-env',
34
- ],
35
- printOutput: true,
36
- spawnOptions: {
37
- cwd: dirname(workerPath),
53
+ description: prompt,
54
+ inputSchema: {
55
+ type: 'object',
56
+ properties: {
57
+ code: {
58
+ type: 'string',
59
+ description: 'Code to execute.',
60
+ },
61
+ intent: {
62
+ type: 'string',
63
+ description: 'Task you are trying to perform. Used for improving the service.',
64
+ },
38
65
  },
39
- });
66
+ required: ['code'],
67
+ },
68
+ };
69
+ const logger = getLogger();
70
+ const handler = async ({ reqContext, args, }) => {
71
+ const code = args.code;
72
+ // Do very basic blocking of code that includes forbidden method names.
73
+ //
74
+ // WARNING: This is not secure against obfuscation and other evasion methods. If
75
+ // stronger security blocks are required, then these should be enforced in the downstream
76
+ // API (e.g., by having users call the MCP server with API keys with limited permissions).
77
+ if (blockedMethods) {
78
+ const blockedMatches = blockedMethods.filter((method) => code.includes(method.fullyQualifiedName));
79
+ if (blockedMatches.length > 0) {
80
+ return asErrorResult(`The following methods have been blocked by the MCP server and cannot be used in code execution: ${blockedMatches
81
+ .map((m) => m.fullyQualifiedName)
82
+ .join(', ')}`);
83
+ }
84
+ }
85
+ let result;
86
+ const startTime = Date.now();
87
+ if (codeExecutionMode === 'local') {
88
+ logger.debug('Executing code in local Deno environment');
89
+ result = await localDenoHandler({ reqContext, args });
90
+ }
91
+ else {
92
+ logger.debug('Executing code in remote Stainless environment');
93
+ result = await remoteStainlessHandler({ reqContext, args });
94
+ }
95
+ logger.info({
96
+ codeExecutionMode,
97
+ durationMs: Date.now() - startTime,
98
+ isError: result.isError,
99
+ contentRows: result.content?.length ?? 0,
100
+ }, 'Got code tool execution result');
101
+ return result;
102
+ };
103
+ return { metadata, tool, handler };
104
+ }
105
+ const remoteStainlessHandler = async ({ reqContext, args, }) => {
106
+ const code = args.code;
107
+ const intent = args.intent;
108
+ const client = reqContext.client;
109
+ const codeModeEndpoint = readEnv('CODE_MODE_ENDPOINT_URL') ?? 'https://api.stainless.com/api/ai/code-tool';
110
+ // Setting a Stainless API key authenticates requests to the code tool endpoint.
111
+ const res = await fetch(codeModeEndpoint, {
112
+ method: 'POST',
113
+ headers: {
114
+ ...(reqContext.stainlessApiKey && { Authorization: reqContext.stainlessApiKey }),
115
+ 'Content-Type': 'application/json',
116
+ 'x-stainless-mcp-client-envs': JSON.stringify({
117
+ BEEPER_ACCESS_TOKEN: requireValue(readEnv('BEEPER_ACCESS_TOKEN') ?? client.accessToken, 'set BEEPER_ACCESS_TOKEN environment variable or provide accessToken client option'),
118
+ BEEPER_DESKTOP_BASE_URL: readEnv('BEEPER_DESKTOP_BASE_URL') ?? client.baseURL ?? undefined,
119
+ }),
120
+ },
121
+ body: JSON.stringify({
122
+ project_name: 'beeper-desktop-api',
123
+ code,
124
+ intent,
125
+ client_opts: {},
126
+ }),
127
+ });
128
+ if (!res.ok) {
129
+ if (res.status === 404 && !reqContext.stainlessApiKey) {
130
+ throw new Error('Could not access code tool for this project. You may need to provide a Stainless API key via the STAINLESS_API_KEY environment variable, the --stainless-api-key flag, or the x-stainless-api-key HTTP header.');
131
+ }
132
+ throw new Error(`${res.status}: ${res.statusText} error when trying to contact Code Tool server. Details: ${await res.text()}`);
133
+ }
134
+ const { is_error, result, log_lines, err_lines } = (await res.json());
135
+ const hasLogs = log_lines.length > 0 || err_lines.length > 0;
136
+ const output = {
137
+ result,
138
+ ...(log_lines.length > 0 && { log_lines }),
139
+ ...(err_lines.length > 0 && { err_lines }),
140
+ };
141
+ if (is_error) {
142
+ return asErrorResult(typeof result === 'string' && !hasLogs ? result : JSON.stringify(output, null, 2));
143
+ }
144
+ return asTextContentResult(output);
145
+ };
146
+ const localDenoHandler = async ({ reqContext, args, }) => {
147
+ const client = reqContext.client;
148
+ const baseURLHostname = new URL(client.baseURL).hostname;
149
+ const { code } = args;
150
+ let denoPath;
151
+ const packageRoot = path.resolve(path.dirname(workerPath), '..');
152
+ const packageNodeModulesPath = path.resolve(packageRoot, 'node_modules');
153
+ // Check if deno is in PATH
154
+ const { execSync } = await import('node:child_process');
155
+ try {
156
+ execSync('command -v deno', { stdio: 'ignore' });
157
+ denoPath = 'deno';
158
+ }
159
+ catch {
40
160
  try {
41
- const resp = await new Promise((resolve, reject) => {
42
- worker.addEventListener('exit', (exitCode) => {
43
- reject(new Error(`Worker exited with code ${exitCode}`));
44
- });
45
- const opts = {
46
- baseURL: client.baseURL,
47
- accessToken: client.accessToken,
48
- defaultHeaders: {
49
- 'X-Stainless-MCP': 'true',
50
- },
51
- };
52
- const req = worker.request('http://localhost', {
53
- headers: {
54
- 'content-type': 'application/json',
55
- },
56
- method: 'POST',
57
- }, (resp) => {
58
- const body = [];
59
- resp.on('error', (err) => {
60
- reject(err);
61
- });
62
- resp.on('data', (chunk) => {
63
- body.push(chunk);
64
- });
65
- resp.on('end', () => {
66
- resolve(new Response(Buffer.concat(body).toString(), {
67
- status: resp.statusCode ?? 200,
68
- headers: resp.headers,
69
- }));
70
- });
161
+ // Use deno binary in node_modules if it's found
162
+ const denoNodeModulesPath = path.resolve(packageNodeModulesPath, 'deno', 'bin.cjs');
163
+ await fs.promises.access(denoNodeModulesPath, fs.constants.X_OK);
164
+ denoPath = denoNodeModulesPath;
165
+ }
166
+ catch {
167
+ return asErrorResult('Deno is required for code execution but was not found. ' +
168
+ 'Install it from https://deno.land or run: npm install deno');
169
+ }
170
+ }
171
+ const allowReadPaths = [
172
+ 'code-tool-worker.mjs',
173
+ `${workerPath.replace(/([\/\\]node_modules)[\/\\].+$/, '$1')}/`,
174
+ packageRoot,
175
+ ];
176
+ // Follow symlinks in node_modules to allow read access to workspace-linked packages
177
+ try {
178
+ const sdkPkgName = '@beeper/desktop-api';
179
+ const sdkDir = path.resolve(packageNodeModulesPath, sdkPkgName);
180
+ const realSdkDir = fs.realpathSync(sdkDir);
181
+ if (realSdkDir !== sdkDir) {
182
+ allowReadPaths.push(realSdkDir);
183
+ }
184
+ }
185
+ catch {
186
+ // Ignore if symlink resolution fails
187
+ }
188
+ const allowRead = allowReadPaths.join(',');
189
+ const worker = await newDenoHTTPWorker(url.pathToFileURL(workerPath), {
190
+ denoExecutable: denoPath,
191
+ runFlags: [
192
+ `--node-modules-dir=manual`,
193
+ `--allow-read=${allowRead}`,
194
+ `--allow-net=${baseURLHostname}`,
195
+ // Allow environment variables because instantiating the client will try to read from them,
196
+ // even though they are not set.
197
+ '--allow-env',
198
+ ],
199
+ printOutput: true,
200
+ spawnOptions: {
201
+ cwd: path.dirname(workerPath),
202
+ },
203
+ });
204
+ try {
205
+ const resp = await new Promise((resolve, reject) => {
206
+ worker.addEventListener('exit', (exitCode) => {
207
+ reject(new Error(`Worker exited with code ${exitCode}`));
208
+ });
209
+ const opts = {
210
+ baseURL: client.baseURL,
211
+ accessToken: client.accessToken,
212
+ defaultHeaders: {
213
+ 'X-Stainless-MCP': 'true',
214
+ },
215
+ };
216
+ const req = worker.request('http://localhost', {
217
+ headers: {
218
+ 'content-type': 'application/json',
219
+ },
220
+ method: 'POST',
221
+ }, (resp) => {
222
+ const body = [];
223
+ resp.on('error', (err) => {
224
+ reject(err);
71
225
  });
72
- const body = JSON.stringify({
73
- opts,
74
- code,
226
+ resp.on('data', (chunk) => {
227
+ body.push(chunk);
75
228
  });
76
- req.write(body, (err) => {
77
- if (err != null) {
78
- reject(err);
79
- }
229
+ resp.on('end', () => {
230
+ resolve(new Response(Buffer.concat(body).toString(), {
231
+ status: resp.statusCode ?? 200,
232
+ headers: resp.headers,
233
+ }));
80
234
  });
81
- req.end();
82
235
  });
83
- if (resp.status === 200) {
84
- const { result, logLines, errLines } = (await resp.json());
85
- const returnOutput = result == null ? null : ({
236
+ const body = JSON.stringify({
237
+ opts,
238
+ code,
239
+ });
240
+ req.write(body, (err) => {
241
+ if (err != null) {
242
+ reject(err);
243
+ }
244
+ });
245
+ req.end();
246
+ });
247
+ if (resp.status === 200) {
248
+ const { result, log_lines, err_lines } = (await resp.json());
249
+ const returnOutput = result == null ? null : ({
250
+ type: 'text',
251
+ text: typeof result === 'string' ? result : JSON.stringify(result),
252
+ });
253
+ const logOutput = log_lines.length === 0 ?
254
+ null
255
+ : {
86
256
  type: 'text',
87
- text: typeof result === 'string' ? result : JSON.stringify(result),
88
- });
89
- const logOutput = logLines.length === 0 ?
90
- null
91
- : {
92
- type: 'text',
93
- text: logLines.join('\n'),
94
- };
95
- const errOutput = errLines.length === 0 ?
96
- null
97
- : {
98
- type: 'text',
99
- text: 'Error output:\n' + errLines.join('\n'),
100
- };
101
- return {
102
- content: [returnOutput, logOutput, errOutput].filter((block) => block !== null),
257
+ text: log_lines.join('\n'),
103
258
  };
104
- }
105
- else {
106
- const { message } = (await resp.json());
107
- return {
108
- content: message == null ? [] : [{ type: 'text', text: message }],
109
- isError: true,
259
+ const errOutput = err_lines.length === 0 ?
260
+ null
261
+ : {
262
+ type: 'text',
263
+ text: 'Error output:\n' + err_lines.join('\n'),
110
264
  };
111
- }
265
+ return {
266
+ content: [returnOutput, logOutput, errOutput].filter((block) => block !== null),
267
+ };
112
268
  }
113
- finally {
114
- worker.terminate();
269
+ else {
270
+ const { result, log_lines, err_lines } = (await resp.json());
271
+ const messageOutput = result == null ? null : ({
272
+ type: 'text',
273
+ text: typeof result === 'string' ? result : JSON.stringify(result),
274
+ });
275
+ const logOutput = log_lines.length === 0 ?
276
+ null
277
+ : {
278
+ type: 'text',
279
+ text: log_lines.join('\n'),
280
+ };
281
+ const errOutput = err_lines.length === 0 ?
282
+ null
283
+ : {
284
+ type: 'text',
285
+ text: 'Error output:\n' + err_lines.join('\n'),
286
+ };
287
+ return {
288
+ content: [messageOutput, logOutput, errOutput].filter((block) => block !== null),
289
+ isError: true,
290
+ };
115
291
  }
116
- };
117
- return { metadata, tool, handler };
118
- }
292
+ }
293
+ finally {
294
+ worker.terminate();
295
+ }
296
+ };
119
297
  //# sourceMappingURL=code-tool.mjs.map
package/code-tool.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"code-tool.mjs","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,OAAO,EAAE,MAAM,WAAW;OAC5B,EAAE,aAAa,EAAE,MAAM,UAAU;AAQxC;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ;IAC5B,MAAM,QAAQ,GAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;IAC7E,MAAM,IAAI,GAAS;QACjB,IAAI,EAAE,SAAS;QACf,WAAW,EACT,6iCAA6iC;QAC/iC,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE;KAC1E,CAAC;IAEF,2GAA2G;IAC3G,MAAM,EAAE,iBAAiB,EAAE,GAAG,MAAM,MAAM,CAAC,2BAA2B,CAAC,CAAC;IACxE,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,MAAM,CAAC,uBAAuB,CAAC,CAAC;IAE7D,MAAM,OAAO,GAAG,KAAK,EAAE,MAAqB,EAAE,IAAa,EAA2B,EAAE;QACtF,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC;QACzD,MAAM,EAAE,IAAI,EAAE,GAAG,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,KAAK,IAAI,CAAC;aAChF,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,CAAiB,CAAC;YAC7E,MAAM,aAAa,GACjB,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CACtB;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;aACnE,CACF,CAAC;YACJ,MAAM,SAAS,GACb,SAAS,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC;gBACtB,IAAI;gBACN,CAAC,CAAC;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;iBAC3B,CAAC;YACN,MAAM,SAAS,GACb,SAAS,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC;gBACtB,IAAI;gBACN,CAAC,CAAC;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,iBAAiB,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;iBAC/C,CAAC;YACN,OAAO;gBACL,OAAO,EAAE,CAAC,aAAa,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,IAAI,CAAC;gBAChF,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC;YAAS,CAAC;QACT,MAAM,CAAC,SAAS,EAAE,CAAC;IACrB,CAAC;AACH,CAAC,CAAC"}
package/http.d.mts CHANGED
@@ -1,15 +1,12 @@
1
+ import { ClientOptions } from '@beeper/desktop-api';
1
2
  import express from 'express';
2
3
  import { McpOptions } from "./options.mjs";
3
- import { ClientOptions } from "./server.mjs";
4
- export declare const post: (options: {
5
- clientOptions: ClientOptions;
6
- mcpOptions: McpOptions;
7
- }) => (req: express.Request, res: express.Response) => Promise<void>;
8
- export declare const get: (req: express.Request, res: express.Response) => Promise<void>;
9
- export declare const del: (req: express.Request, res: express.Response) => Promise<void>;
10
4
  export declare const streamableHTTPApp: ({ clientOptions, mcpOptions, }: {
11
5
  clientOptions?: ClientOptions;
12
- mcpOptions?: McpOptions;
6
+ mcpOptions: McpOptions;
13
7
  }) => express.Express;
14
- export declare const launchStreamableHTTPServer: (options: McpOptions, port: number | string | undefined) => Promise<void>;
8
+ export declare const launchStreamableHTTPServer: ({ mcpOptions, port, }: {
9
+ mcpOptions: McpOptions;
10
+ port: number | string | undefined;
11
+ }) => Promise<void>;
15
12
  //# sourceMappingURL=http.d.mts.map
package/http.d.mts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"http.d.mts","sourceRoot":"","sources":["src/http.ts"],"names":[],"mappings":"OAMO,OAAO,MAAM,SAAS;OAEtB,EAAE,UAAU,EAAqB;OACjC,EAAE,aAAa,EAA+B;AAgErD,eAAO,MAAM,IAAI,GACd,SAAS;IAAE,aAAa,EAAE,aAAa,CAAC;IAAC,UAAU,EAAE,UAAU,CAAA;CAAE,MAC3D,KAAK,OAAO,CAAC,OAAO,EAAE,KAAK,OAAO,CAAC,QAAQ,kBAUjD,CAAC;AAEJ,eAAO,MAAM,GAAG,GAAU,KAAK,OAAO,CAAC,OAAO,EAAE,KAAK,OAAO,CAAC,QAAQ,kBAQpE,CAAC;AAEF,eAAO,MAAM,GAAG,GAAU,KAAK,OAAO,CAAC,OAAO,EAAE,KAAK,OAAO,CAAC,QAAQ,kBAQpE,CAAC;AAYF,eAAO,MAAM,iBAAiB,GAAI,gCAG/B;IACD,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB,KAAG,OAAO,CAAC,OAWX,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAU,SAAS,UAAU,EAAE,MAAM,MAAM,GAAG,MAAM,GAAG,SAAS,kBAYtG,CAAC"}
1
+ {"version":3,"file":"http.d.mts","sourceRoot":"","sources":["src/http.ts"],"names":[],"mappings":"OAIO,EAAE,aAAa,EAAE,MAAM,qBAAqB;OAE5C,OAAO,MAAM,SAAS;OAKtB,EAAE,UAAU,EAAE;AA8GrB,eAAO,MAAM,iBAAiB,GAAI,gCAG/B;IACD,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,UAAU,EAAE,UAAU,CAAC;CACxB,KAAG,OAAO,CAAC,OAgDX,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAU,uBAG9C;IACD,UAAU,EAAE,UAAU,CAAC;IACvB,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CACnC,kBAcA,CAAC"}
package/http.d.ts CHANGED
@@ -1,15 +1,12 @@
1
+ import { ClientOptions } from '@beeper/desktop-api';
1
2
  import express from 'express';
2
3
  import { McpOptions } from "./options.js";
3
- import { ClientOptions } from "./server.js";
4
- export declare const post: (options: {
5
- clientOptions: ClientOptions;
6
- mcpOptions: McpOptions;
7
- }) => (req: express.Request, res: express.Response) => Promise<void>;
8
- export declare const get: (req: express.Request, res: express.Response) => Promise<void>;
9
- export declare const del: (req: express.Request, res: express.Response) => Promise<void>;
10
4
  export declare const streamableHTTPApp: ({ clientOptions, mcpOptions, }: {
11
5
  clientOptions?: ClientOptions;
12
- mcpOptions?: McpOptions;
6
+ mcpOptions: McpOptions;
13
7
  }) => express.Express;
14
- export declare const launchStreamableHTTPServer: (options: McpOptions, port: number | string | undefined) => Promise<void>;
8
+ export declare const launchStreamableHTTPServer: ({ mcpOptions, port, }: {
9
+ mcpOptions: McpOptions;
10
+ port: number | string | undefined;
11
+ }) => Promise<void>;
15
12
  //# sourceMappingURL=http.d.ts.map
package/http.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["src/http.ts"],"names":[],"mappings":"OAMO,OAAO,MAAM,SAAS;OAEtB,EAAE,UAAU,EAAqB;OACjC,EAAE,aAAa,EAA+B;AAgErD,eAAO,MAAM,IAAI,GACd,SAAS;IAAE,aAAa,EAAE,aAAa,CAAC;IAAC,UAAU,EAAE,UAAU,CAAA;CAAE,MAC3D,KAAK,OAAO,CAAC,OAAO,EAAE,KAAK,OAAO,CAAC,QAAQ,kBAUjD,CAAC;AAEJ,eAAO,MAAM,GAAG,GAAU,KAAK,OAAO,CAAC,OAAO,EAAE,KAAK,OAAO,CAAC,QAAQ,kBAQpE,CAAC;AAEF,eAAO,MAAM,GAAG,GAAU,KAAK,OAAO,CAAC,OAAO,EAAE,KAAK,OAAO,CAAC,QAAQ,kBAQpE,CAAC;AAYF,eAAO,MAAM,iBAAiB,GAAI,gCAG/B;IACD,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB,KAAG,OAAO,CAAC,OAWX,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAU,SAAS,UAAU,EAAE,MAAM,MAAM,GAAG,MAAM,GAAG,SAAS,kBAYtG,CAAC"}
1
+ {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["src/http.ts"],"names":[],"mappings":"OAIO,EAAE,aAAa,EAAE,MAAM,qBAAqB;OAE5C,OAAO,MAAM,SAAS;OAKtB,EAAE,UAAU,EAAE;AA8GrB,eAAO,MAAM,iBAAiB,GAAI,gCAG/B;IACD,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,UAAU,EAAE,UAAU,CAAC;CACxB,KAAG,OAAO,CAAC,OAgDX,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAU,uBAG9C;IACD,UAAU,EAAE,UAAU,CAAC;IACvB,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CACnC,kBAcA,CAAC"}