@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/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2025 beeperdesktop
1
+ Copyright 2026 beeperdesktop
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
4
 
package/README.md CHANGED
@@ -1,8 +1,6 @@
1
- # Beeper Desktop API MCP Server
1
+ # TypeScript SDK for Beeper Desktop MCP Server
2
2
 
3
- > Beeper Desktop already comes with this MCP server, use this package directly for custom integrations.
4
- >
5
- > [Learn more about the built-in Beeper Desktop MCP server here.](https://developers.beeper.com/desktop-api/mcp/)
3
+ It is generated with [Stainless](https://www.stainless.com/).
6
4
 
7
5
  ## Installation
8
6
 
@@ -27,7 +25,7 @@ For clients with a configuration JSON, it might look something like this:
27
25
  "mcpServers": {
28
26
  "beeper_desktop_api_api": {
29
27
  "command": "npx",
30
- "args": ["-y", "@beeper/desktop-mcp", "--client=claude", "--tools=all"],
28
+ "args": ["-y", "@beeper/desktop-mcp"],
31
29
  "env": {
32
30
  "BEEPER_ACCESS_TOKEN": "My Access Token"
33
31
  }
@@ -41,14 +39,14 @@ For clients with a configuration JSON, it might look something like this:
41
39
  If you use Cursor, you can install the MCP server by using the button below. You will need to set your environment variables
42
40
  in Cursor's `mcp.json`, which can be found in Cursor Settings > Tools & MCP > New MCP Server.
43
41
 
44
- [![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=@beeper/desktop-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBiZWVwZXIvZGVza3RvcC1tY3AiXSwiZW52Ijp7IkJFRVBFUl9BQ0NFU1NfVE9LRU4iOiJTZXQgeW91ciBCRUVQRVJfQUNDRVNTX1RPS0VOIGhlcmUuIn19)
42
+ [![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40beeper%2Fdesktop-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBiZWVwZXIvZGVza3RvcC1tY3AiXSwiZW52Ijp7IkJFRVBFUl9BQ0NFU1NfVE9LRU4iOiJNeSBBY2Nlc3MgVG9rZW4ifX0)
45
43
 
46
44
  ### VS Code
47
45
 
48
46
  If you use MCP, you can install the MCP server by clicking the link below. You will need to set your environment variables
49
47
  in VS Code's `mcp.json`, which can be found via Command Palette > MCP: Open User Configuration.
50
48
 
51
- [Open VS Code](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40beeper%2Fdesktop-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40beeper%2Fdesktop-mcp%22%5D%2C%22env%22%3A%7B%22BEEPER_ACCESS_TOKEN%22%3A%22Set%20your%20BEEPER_ACCESS_TOKEN%20here.%22%7D%7D)
49
+ [Open VS Code](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40beeper%2Fdesktop-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40beeper%2Fdesktop-mcp%22%5D%2C%22env%22%3A%7B%22BEEPER_ACCESS_TOKEN%22%3A%22My%20Access%20Token%22%7D%7D)
52
50
 
53
51
  ### Claude Code
54
52
 
@@ -56,114 +54,25 @@ If you use Claude Code, you can install the MCP server by running the command be
56
54
  environment variables in Claude Code's `.claude.json`, which can be found in your home directory.
57
55
 
58
56
  ```
59
- claude mcp add --transport stdio beeper_desktop_api_api --env BEEPER_ACCESS_TOKEN="Your BEEPER_ACCESS_TOKEN here." -- npx -y @beeper/desktop-mcp
57
+ claude mcp add beeper_desktop_mcp_api --env BEEPER_ACCESS_TOKEN="My Access Token" -- npx -y @beeper/desktop-mcp
60
58
  ```
61
59
 
62
- ## Exposing endpoints to your MCP Client
60
+ ## Code Mode
63
61
 
64
- There are three ways to expose endpoints as tools in the MCP server:
62
+ This MCP server is built on the "Code Mode" tool scheme. In this MCP Server,
63
+ your agent will write code against the TypeScript SDK, which will then be executed in an
64
+ isolated sandbox. To accomplish this, the server will expose two tools to your agent:
65
65
 
66
- 1. Exposing one tool per endpoint, and filtering as necessary
67
- 2. Exposing a set of tools to dynamically discover and invoke endpoints from the API
68
- 3. Exposing a docs search tool and a code execution tool, allowing the client to write code to be executed against the TypeScript client
66
+ - The first tool is a docs search tool, which can be used to generically query for
67
+ documentation about your API/SDK.
69
68
 
70
- ### Filtering endpoints and tools
69
+ - The second tool is a code tool, where the agent can write code against the TypeScript SDK.
70
+ The code will be executed in a sandbox environment without web or filesystem access. Then,
71
+ anything the code returns or prints will be returned to the agent as the result of the
72
+ tool call.
71
73
 
72
- You can run the package on the command line to discover and filter the set of tools that are exposed by the
73
- MCP Server. This can be helpful for large APIs where including all endpoints at once is too much for your AI's
74
- context window.
75
-
76
- You can filter by multiple aspects:
77
-
78
- - `--tool` includes a specific tool by name
79
- - `--resource` includes all tools under a specific resource, and can have wildcards, e.g. `my.resource*`
80
- - `--operation` includes just read (get/list) or just write operations
81
- - `--tag` includes a set of endpoints with custom tags provided
82
-
83
- ### Dynamic tools
84
-
85
- If you specify `--tools=dynamic` to the MCP server, instead of exposing one tool per endpoint in the API, it will
86
- expose the following tools:
87
-
88
- 1. `list_api_endpoints` - Discovers available endpoints, with optional filtering by search query
89
- 2. `get_api_endpoint_schema` - Gets detailed schema information for a specific endpoint
90
- 3. `invoke_api_endpoint` - Executes any endpoint with the appropriate parameters
91
-
92
- This allows you to have the full set of API endpoints available to your MCP Client, while not requiring that all
93
- of their schemas be loaded into context at once. Instead, the LLM will automatically use these tools together to
94
- search for, look up, and invoke endpoints dynamically. However, due to the indirect nature of the schemas, it
95
- can struggle to provide the correct properties a bit more than when tools are imported explicitly. Therefore,
96
- you can opt-in to explicit tools, the dynamic tools, or both.
97
-
98
- See more information with `--help`.
99
-
100
- All of these command-line options can be repeated, combined together, and have corresponding exclusion versions (e.g. `--no-tool`).
101
-
102
- Use `--list` to see the list of available tools, or see below.
103
-
104
- ### Code execution
105
-
106
- If you specify `--tools=code` to the MCP server, it will expose just two tools:
107
-
108
- - `search_docs` - Searches the API documentation and returns a list of markdown results
109
- - `execute` - Runs code against the TypeScript client
110
-
111
- This allows the LLM to implement more complex logic by chaining together many API calls without loading
112
- intermediary results into its context window.
113
-
114
- The code execution itself happens in a Deno sandbox that has network access only to the base URL for the API.
115
-
116
- ### Specifying the MCP Client
117
-
118
- Different clients have varying abilities to handle arbitrary tools and schemas.
119
-
120
- You can specify the client you are using with the `--client` argument, and the MCP server will automatically
121
- serve tools and schemas that are more compatible with that client.
122
-
123
- - `--client=<type>`: Set all capabilities based on a known MCP client
124
-
125
- - Valid values: `openai-agents`, `claude`, `claude-code`, `cursor`
126
- - Example: `--client=cursor`
127
-
128
- Additionally, if you have a client not on the above list, or the client has gotten better
129
- over time, you can manually enable or disable certain capabilities:
130
-
131
- - `--capability=<name>`: Specify individual client capabilities
132
- - Available capabilities:
133
- - `top-level-unions`: Enable support for top-level unions in tool schemas
134
- - `valid-json`: Enable JSON string parsing for arguments
135
- - `refs`: Enable support for $ref pointers in schemas
136
- - `unions`: Enable support for union types (anyOf) in schemas
137
- - `formats`: Enable support for format validations in schemas (e.g. date-time, email)
138
- - `tool-name-length=N`: Set maximum tool name length to N characters
139
- - Example: `--capability=top-level-unions --capability=tool-name-length=40`
140
- - Example: `--capability=top-level-unions,tool-name-length=40`
141
-
142
- ### Examples
143
-
144
- 1. Filter for read operations on cards:
145
-
146
- ```bash
147
- --resource=cards --operation=read
148
- ```
149
-
150
- 2. Exclude specific tools while including others:
151
-
152
- ```bash
153
- --resource=cards --no-tool=create_cards
154
- ```
155
-
156
- 3. Configure for Cursor client with custom max tool name length:
157
-
158
- ```bash
159
- --client=cursor --capability=tool-name-length=40
160
- ```
161
-
162
- 4. Complex filtering with multiple criteria:
163
-
164
- ```bash
165
- --resource=cards,accounts --operation=read --tag=kyc --no-tool=create_cards
166
- ```
74
+ Using this scheme, agents are capable of performing very complex tasks deterministically
75
+ and repeatably.
167
76
 
168
77
  ## Running remotely
169
78
 
@@ -190,93 +99,3 @@ A configuration JSON for this server might look like this, assuming the server i
190
99
  }
191
100
  }
192
101
  ```
193
-
194
- The command-line arguments for filtering tools and specifying clients can also be used as query parameters in the URL.
195
- For example, to exclude specific tools while including others, use the URL:
196
-
197
- ```
198
- http://localhost:3000?resource=cards&resource=accounts&no_tool=create_cards
199
- ```
200
-
201
- Or, to configure for the Cursor client, with a custom max tool name length, use the URL:
202
-
203
- ```
204
- http://localhost:3000?client=cursor&capability=tool-name-length%3D40
205
- ```
206
-
207
- ## Importing the tools and server individually
208
-
209
- ```js
210
- // Import the server, generated endpoints, or the init function
211
- import { server, endpoints, init } from "@beeper/desktop-mcp/server";
212
-
213
- // import a specific tool
214
- import focusApp from "@beeper/desktop-mcp/tools/top-level/focus-app";
215
-
216
- // initialize the server and all endpoints
217
- init({ server, endpoints });
218
-
219
- // manually start server
220
- const transport = new StdioServerTransport();
221
- await server.connect(transport);
222
-
223
- // or initialize your own server with specific tools
224
- const myServer = new McpServer(...);
225
-
226
- // define your own endpoint
227
- const myCustomEndpoint = {
228
- tool: {
229
- name: 'my_custom_tool',
230
- description: 'My custom tool',
231
- inputSchema: zodToJsonSchema(z.object({ a_property: z.string() })),
232
- },
233
- handler: async (client: client, args: any) => {
234
- return { myResponse: 'Hello world!' };
235
- })
236
- };
237
-
238
- // initialize the server with your custom endpoints
239
- init({ server: myServer, endpoints: [focusApp, myCustomEndpoint] });
240
- ```
241
-
242
- ## Available Tools
243
-
244
- The following tools are available in this MCP server.
245
-
246
- ### Resource `$client`:
247
-
248
- - `focus_app` (`write`) tags: [app]: Focus Beeper Desktop and optionally navigate to a specific chat, message, or pre-fill draft text and attachment.
249
- - `search` (`read`) tags: [app]: Search for chats, participant name matches in groups, and the first page of messages in one call. Use this when the user asks for a specific chat, group, or person.
250
-
251
- ### Resource `accounts`:
252
-
253
- - `get_accounts` (`read`) tags: [accounts]: List connected accounts on this device.
254
-
255
- ### Resource `chats`:
256
-
257
- - `get_chat` (`read`) tags: [chats]: Get chat details: metadata, participants (limited), last activity.
258
- - `archive_chat` (`write`) tags: [chats]: Archive or unarchive a chat.
259
- - `search_chats` (`read`) tags: [chats]: Search chats by title/network or participants using Beeper Desktop's renderer algorithm. Optional 'scope'.
260
-
261
- ### Resource `chats.reminders`:
262
-
263
- - `set_chat_reminder` (`write`) tags: [chats]: Set a reminder for a chat at a specific time.
264
- - `clear_chat_reminder` (`write`) tags: [chats]: Clear a chat reminder.
265
-
266
- ### Resource `messages`:
267
-
268
- - `list_messages` (`read`) tags: [messages]: List messages from a specific chat with pagination support.
269
- - `search_messages` (`read`) tags: [messages]: Search messages across chats using Beeper's message index.
270
- - When to use: find messages by text and/or filters (chatIDs, accountIDs, chatType, media type filters, sender, date ranges).
271
- - CRITICAL: Query is LITERAL WORD MATCHING, NOT semantic search! Only finds messages containing these EXACT words.
272
- • ✅ RIGHT: query="dinner" or query="sick" or query="error" (single words users type)
273
- • ❌ WRONG: query="dinner plans tonight" or query="health issues" (phrases/concepts)
274
- • The query matches ALL words provided (in any order). Example: query="flight booking" finds messages with both "flight" AND "booking".
275
- - Performance: provide chatIDs/accountIDs when known. Omitted 'query' returns results based on filters only. Partial matches enabled; 'excludeLowPriority' defaults to true.
276
- - Workflow tip: To search messages in specific conversations: 1) Use find-chats to get chatIDs, 2) Use search-messages with those chatIDs.
277
- - IMPORTANT: Chat names vary widely. ASK the user for clarification:
278
- • "Which chat do you mean by family?" (could be "The Smiths", "Mom Dad Kids", etc.)
279
- • "What's the name of your work chat?" (could be "Team", company name, project name)
280
- • "Who are the participants?" (use scope="participants" in search-chats)
281
- Returns: matching messages and referenced chats.
282
- - `send_message` (`write`) tags: [messages]: Send a text message to a specific chat. Supports replying to existing messages. Returns the sent message ID and a deeplink to the chat
package/auth.d.mts ADDED
@@ -0,0 +1,6 @@
1
+ import { IncomingMessage } from 'node:http';
2
+ import { ClientOptions } from '@beeper/desktop-api';
3
+ import { McpOptions } from "./options.mjs";
4
+ export declare const parseClientAuthHeaders: (req: IncomingMessage, required?: boolean) => Partial<ClientOptions>;
5
+ export declare const getStainlessApiKey: (req: IncomingMessage, mcpOptions: McpOptions) => string | undefined;
6
+ //# sourceMappingURL=auth.d.mts.map
package/auth.d.mts.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.mts","sourceRoot":"","sources":["src/auth.ts"],"names":[],"mappings":"OAEO,EAAE,eAAe,EAAE,MAAM,WAAW;OACpC,EAAE,aAAa,EAAE,MAAM,qBAAqB;OAC5C,EAAE,UAAU,EAAE;AAErB,eAAO,MAAM,sBAAsB,GAAI,KAAK,eAAe,EAAE,WAAW,OAAO,KAAG,OAAO,CAAC,aAAa,CAqBtG,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,KAAK,eAAe,EAAE,YAAY,UAAU,KAAG,MAAM,GAAG,SAY1F,CAAC"}
package/auth.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import { IncomingMessage } from 'node:http';
2
+ import { ClientOptions } from '@beeper/desktop-api';
3
+ import { McpOptions } from "./options.js";
4
+ export declare const parseClientAuthHeaders: (req: IncomingMessage, required?: boolean) => Partial<ClientOptions>;
5
+ export declare const getStainlessApiKey: (req: IncomingMessage, mcpOptions: McpOptions) => string | undefined;
6
+ //# sourceMappingURL=auth.d.ts.map
package/auth.d.ts.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["src/auth.ts"],"names":[],"mappings":"OAEO,EAAE,eAAe,EAAE,MAAM,WAAW;OACpC,EAAE,aAAa,EAAE,MAAM,qBAAqB;OAC5C,EAAE,UAAU,EAAE;AAErB,eAAO,MAAM,sBAAsB,GAAI,KAAK,eAAe,EAAE,WAAW,OAAO,KAAG,OAAO,CAAC,aAAa,CAqBtG,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,KAAK,eAAe,EAAE,YAAY,UAAU,KAAG,MAAM,GAAG,SAY1F,CAAC"}
package/auth.js ADDED
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.getStainlessApiKey = exports.parseClientAuthHeaders = void 0;
5
+ const parseClientAuthHeaders = (req, required) => {
6
+ if (req.headers.authorization) {
7
+ const scheme = req.headers.authorization.split(' ')[0];
8
+ const value = req.headers.authorization.slice(scheme.length + 1);
9
+ switch (scheme) {
10
+ case 'Bearer':
11
+ return { accessToken: req.headers.authorization.slice('Bearer '.length) };
12
+ default:
13
+ throw new Error('Unsupported authorization scheme. Expected the "Authorization" header to be a supported scheme (Bearer).');
14
+ }
15
+ }
16
+ else if (required) {
17
+ throw new Error('Missing required Authorization header; see WWW-Authenticate header for details.');
18
+ }
19
+ const accessToken = Array.isArray(req.headers['x-beeper-access-token']) ?
20
+ req.headers['x-beeper-access-token'][0]
21
+ : req.headers['x-beeper-access-token'];
22
+ return { accessToken };
23
+ };
24
+ exports.parseClientAuthHeaders = parseClientAuthHeaders;
25
+ const getStainlessApiKey = (req, mcpOptions) => {
26
+ // Try to get the key from the x-stainless-api-key header
27
+ const headerKey = Array.isArray(req.headers['x-stainless-api-key']) ?
28
+ req.headers['x-stainless-api-key'][0]
29
+ : req.headers['x-stainless-api-key'];
30
+ if (headerKey && typeof headerKey === 'string') {
31
+ return headerKey;
32
+ }
33
+ // Fall back to value set in the mcpOptions (e.g. from environment variable), if provided
34
+ return mcpOptions.stainlessApiKey;
35
+ };
36
+ exports.getStainlessApiKey = getStainlessApiKey;
37
+ //# sourceMappingURL=auth.js.map
package/auth.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","sourceRoot":"","sources":["src/auth.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAM/E,MAAM,sBAAsB,GAAG,CAAC,GAAoB,EAAE,QAAkB,EAA0B,EAAE;IACzG,IAAI,GAAG,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;QAC9B,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE,CAAC;QACxD,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACjE,QAAQ,MAAM,EAAE,CAAC;YACf,KAAK,QAAQ;gBACX,OAAO,EAAE,WAAW,EAAE,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;YAC5E;gBACE,MAAM,IAAI,KAAK,CACb,0GAA0G,CAC3G,CAAC;QACN,CAAC;IACH,CAAC;SAAM,IAAI,QAAQ,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,iFAAiF,CAAC,CAAC;IACrG,CAAC;IAED,MAAM,WAAW,GACf,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC;QACnD,GAAG,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC;QACzC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACzC,OAAO,EAAE,WAAW,EAAE,CAAC;AACzB,CAAC,CAAC;AArBW,QAAA,sBAAsB,0BAqBjC;AAEK,MAAM,kBAAkB,GAAG,CAAC,GAAoB,EAAE,UAAsB,EAAsB,EAAE;IACrG,yDAAyD;IACzD,MAAM,SAAS,GACb,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QACjD,GAAG,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QACvC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;IACvC,IAAI,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE,CAAC;QAC/C,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,yFAAyF;IACzF,OAAO,UAAU,CAAC,eAAe,CAAC;AACpC,CAAC,CAAC;AAZW,QAAA,kBAAkB,sBAY7B"}
package/auth.mjs ADDED
@@ -0,0 +1,32 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+ export const parseClientAuthHeaders = (req, required) => {
3
+ if (req.headers.authorization) {
4
+ const scheme = req.headers.authorization.split(' ')[0];
5
+ const value = req.headers.authorization.slice(scheme.length + 1);
6
+ switch (scheme) {
7
+ case 'Bearer':
8
+ return { accessToken: req.headers.authorization.slice('Bearer '.length) };
9
+ default:
10
+ throw new Error('Unsupported authorization scheme. Expected the "Authorization" header to be a supported scheme (Bearer).');
11
+ }
12
+ }
13
+ else if (required) {
14
+ throw new Error('Missing required Authorization header; see WWW-Authenticate header for details.');
15
+ }
16
+ const accessToken = Array.isArray(req.headers['x-beeper-access-token']) ?
17
+ req.headers['x-beeper-access-token'][0]
18
+ : req.headers['x-beeper-access-token'];
19
+ return { accessToken };
20
+ };
21
+ export const getStainlessApiKey = (req, mcpOptions) => {
22
+ // Try to get the key from the x-stainless-api-key header
23
+ const headerKey = Array.isArray(req.headers['x-stainless-api-key']) ?
24
+ req.headers['x-stainless-api-key'][0]
25
+ : req.headers['x-stainless-api-key'];
26
+ if (headerKey && typeof headerKey === 'string') {
27
+ return headerKey;
28
+ }
29
+ // Fall back to value set in the mcpOptions (e.g. from environment variable), if provided
30
+ return mcpOptions.stainlessApiKey;
31
+ };
32
+ //# sourceMappingURL=auth.mjs.map
package/auth.mjs.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.mjs","sourceRoot":"","sources":["src/auth.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAMtF,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,GAAoB,EAAE,QAAkB,EAA0B,EAAE;IACzG,IAAI,GAAG,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;QAC9B,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE,CAAC;QACxD,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACjE,QAAQ,MAAM,EAAE,CAAC;YACf,KAAK,QAAQ;gBACX,OAAO,EAAE,WAAW,EAAE,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;YAC5E;gBACE,MAAM,IAAI,KAAK,CACb,0GAA0G,CAC3G,CAAC;QACN,CAAC;IACH,CAAC;SAAM,IAAI,QAAQ,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,iFAAiF,CAAC,CAAC;IACrG,CAAC;IAED,MAAM,WAAW,GACf,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC;QACnD,GAAG,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC;QACzC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACzC,OAAO,EAAE,WAAW,EAAE,CAAC;AACzB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,GAAoB,EAAE,UAAsB,EAAsB,EAAE;IACrG,yDAAyD;IACzD,MAAM,SAAS,GACb,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QACjD,GAAG,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QACvC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;IACvC,IAAI,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE,CAAC;QAC/C,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,yFAAyF;IACzF,OAAO,UAAU,CAAC,eAAe,CAAC;AACpC,CAAC,CAAC"}
@@ -1,14 +1,14 @@
1
1
  import { ClientOptions } from '@beeper/desktop-api';
2
2
  export type WorkerInput = {
3
- opts: ClientOptions;
3
+ project_name: string;
4
4
  code: string;
5
+ client_opts: ClientOptions;
6
+ intent?: string | undefined;
5
7
  };
6
- export type WorkerSuccess = {
8
+ export type WorkerOutput = {
9
+ is_error: boolean;
7
10
  result: unknown | null;
8
- logLines: string[];
9
- errLines: string[];
10
- };
11
- export type WorkerError = {
12
- message: string | undefined;
11
+ log_lines: string[];
12
+ err_lines: string[];
13
13
  };
14
14
  //# sourceMappingURL=code-tool-types.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"code-tool-types.d.mts","sourceRoot":"","sources":["src/code-tool-types.ts"],"names":[],"mappings":"OAEO,EAAE,aAAa,EAAE,MAAM,qBAAqB;AAEnD,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AACF,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AACF,MAAM,MAAM,WAAW,GAAG;IAAE,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC"}
1
+ {"version":3,"file":"code-tool-types.d.mts","sourceRoot":"","sources":["src/code-tool-types.ts"],"names":[],"mappings":"OAEO,EAAE,aAAa,EAAE,MAAM,qBAAqB;AAEnD,MAAM,MAAM,WAAW,GAAG;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,aAAa,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC"}
@@ -1,14 +1,14 @@
1
1
  import { ClientOptions } from '@beeper/desktop-api';
2
2
  export type WorkerInput = {
3
- opts: ClientOptions;
3
+ project_name: string;
4
4
  code: string;
5
+ client_opts: ClientOptions;
6
+ intent?: string | undefined;
5
7
  };
6
- export type WorkerSuccess = {
8
+ export type WorkerOutput = {
9
+ is_error: boolean;
7
10
  result: unknown | null;
8
- logLines: string[];
9
- errLines: string[];
10
- };
11
- export type WorkerError = {
12
- message: string | undefined;
11
+ log_lines: string[];
12
+ err_lines: string[];
13
13
  };
14
14
  //# sourceMappingURL=code-tool-types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"code-tool-types.d.ts","sourceRoot":"","sources":["src/code-tool-types.ts"],"names":[],"mappings":"OAEO,EAAE,aAAa,EAAE,MAAM,qBAAqB;AAEnD,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AACF,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AACF,MAAM,MAAM,WAAW,GAAG;IAAE,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC"}
1
+ {"version":3,"file":"code-tool-types.d.ts","sourceRoot":"","sources":["src/code-tool-types.ts"],"names":[],"mappings":"OAEO,EAAE,aAAa,EAAE,MAAM,qBAAqB;AAEnD,MAAM,MAAM,WAAW,GAAG;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,aAAa,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"code-tool-worker.d.mts","sourceRoot":"","sources":["src/code-tool-worker.ts"],"names":[],"mappings":";iBAwJ0B,OAAO,KAAG,OAAO,CAAC,QAAQ,CAAC;;AAwDrD,wBAAyB"}
1
+ {"version":3,"file":"code-tool-worker.d.mts","sourceRoot":"","sources":["src/code-tool-worker.ts"],"names":[],"mappings":";iBA8N0B,OAAO,KAAG,OAAO,CAAC,QAAQ,CAAC;;AAsErD,wBAAyB"}
@@ -1 +1 @@
1
- {"version":3,"file":"code-tool-worker.d.ts","sourceRoot":"","sources":["src/code-tool-worker.ts"],"names":[],"mappings":";iBAwJ0B,OAAO,KAAG,OAAO,CAAC,QAAQ,CAAC;;AAwDrD,wBAAyB"}
1
+ {"version":3,"file":"code-tool-worker.d.ts","sourceRoot":"","sources":["src/code-tool-worker.ts"],"names":[],"mappings":";iBA8N0B,OAAO,KAAG,OAAO,CAAC,QAAQ,CAAC;;AAsErD,wBAAyB"}
@@ -4,38 +4,101 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  return (mod && mod.__esModule) ? mod : { "default": mod };
5
5
  };
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
+ const node_path_1 = __importDefault(require("node:path"));
7
8
  const node_util_1 = __importDefault(require("node:util"));
8
9
  const fuse_js_1 = __importDefault(require("fuse.js"));
9
10
  const typescript_1 = __importDefault(require("typescript"));
10
11
  const desktop_api_1 = require("@beeper/desktop-api");
11
- function getRunFunctionNode(code) {
12
+ function getRunFunctionSource(code) {
12
13
  const sourceFile = typescript_1.default.createSourceFile('code.ts', code, typescript_1.default.ScriptTarget.Latest, true);
14
+ const printer = typescript_1.default.createPrinter();
13
15
  for (const statement of sourceFile.statements) {
14
16
  // Check for top-level function declarations
15
17
  if (typescript_1.default.isFunctionDeclaration(statement)) {
16
18
  if (statement.name?.text === 'run') {
17
- return statement;
19
+ return {
20
+ type: 'declaration',
21
+ client: statement.parameters[0]?.name.getText(),
22
+ code: printer.printNode(typescript_1.default.EmitHint.Unspecified, statement.body, sourceFile),
23
+ };
18
24
  }
19
25
  }
20
26
  // Check for variable declarations: const run = () => {} or const run = function() {}
21
27
  if (typescript_1.default.isVariableStatement(statement)) {
22
28
  for (const declaration of statement.declarationList.declarations) {
23
- if (typescript_1.default.isIdentifier(declaration.name) && declaration.name.text === 'run') {
29
+ if (typescript_1.default.isIdentifier(declaration.name) &&
30
+ declaration.name.text === 'run' &&
24
31
  // Check if it's initialized with a function
25
- if (declaration.initializer &&
26
- (typescript_1.default.isFunctionExpression(declaration.initializer) || typescript_1.default.isArrowFunction(declaration.initializer))) {
27
- return declaration.initializer;
28
- }
32
+ declaration.initializer &&
33
+ (typescript_1.default.isFunctionExpression(declaration.initializer) || typescript_1.default.isArrowFunction(declaration.initializer))) {
34
+ return {
35
+ type: 'expression',
36
+ client: declaration.initializer.parameters[0]?.name.getText(),
37
+ code: printer.printNode(typescript_1.default.EmitHint.Unspecified, declaration.initializer, sourceFile),
38
+ };
29
39
  }
30
40
  }
31
41
  }
32
42
  }
33
43
  return null;
34
44
  }
45
+ function getTSDiagnostics(code) {
46
+ const functionSource = getRunFunctionSource(code);
47
+ const codeWithImport = [
48
+ 'import { BeeperDesktop } from "@beeper/desktop-api";',
49
+ functionSource.type === 'declaration' ?
50
+ `async function run(${functionSource.client}: BeeperDesktop)`
51
+ : `const run: (${functionSource.client}: BeeperDesktop) => Promise<unknown> =`,
52
+ functionSource.code,
53
+ ].join('\n');
54
+ const sourcePath = node_path_1.default.resolve('code.ts');
55
+ const ast = typescript_1.default.createSourceFile(sourcePath, codeWithImport, typescript_1.default.ScriptTarget.Latest, true);
56
+ const options = typescript_1.default.getDefaultCompilerOptions();
57
+ options.target = typescript_1.default.ScriptTarget.Latest;
58
+ options.module = typescript_1.default.ModuleKind.NodeNext;
59
+ options.moduleResolution = typescript_1.default.ModuleResolutionKind.NodeNext;
60
+ const host = typescript_1.default.createCompilerHost(options, true);
61
+ const newHost = {
62
+ ...host,
63
+ getSourceFile: (...args) => {
64
+ if (node_path_1.default.resolve(args[0]) === sourcePath) {
65
+ return ast;
66
+ }
67
+ return host.getSourceFile(...args);
68
+ },
69
+ readFile: (...args) => {
70
+ if (node_path_1.default.resolve(args[0]) === sourcePath) {
71
+ return codeWithImport;
72
+ }
73
+ return host.readFile(...args);
74
+ },
75
+ fileExists: (...args) => {
76
+ if (node_path_1.default.resolve(args[0]) === sourcePath) {
77
+ return true;
78
+ }
79
+ return host.fileExists(...args);
80
+ },
81
+ };
82
+ const program = typescript_1.default.createProgram({
83
+ options,
84
+ rootNames: [sourcePath],
85
+ host: newHost,
86
+ });
87
+ const diagnostics = typescript_1.default.getPreEmitDiagnostics(program, ast);
88
+ return diagnostics.map((d) => {
89
+ const message = typescript_1.default.flattenDiagnosticMessageText(d.messageText, '\n');
90
+ if (!d.file || !d.start)
91
+ return `- ${message}`;
92
+ const { line: lineNumber } = typescript_1.default.getLineAndCharacterOfPosition(d.file, d.start);
93
+ const line = codeWithImport.split('\n').at(lineNumber)?.trim();
94
+ return line ? `- ${message}\n ${line}` : `- ${message}`;
95
+ });
96
+ }
35
97
  const fuse = new fuse_js_1.default([
36
98
  'client.focus',
37
99
  'client.search',
38
100
  'client.accounts.list',
101
+ 'client.accounts.contacts.list',
39
102
  'client.accounts.contacts.search',
40
103
  'client.chats.archive',
41
104
  'client.chats.create',
@@ -44,10 +107,17 @@ const fuse = new fuse_js_1.default([
44
107
  'client.chats.search',
45
108
  'client.chats.reminders.create',
46
109
  'client.chats.reminders.delete',
110
+ 'client.chats.messages.reactions.add',
111
+ 'client.chats.messages.reactions.delete',
47
112
  'client.messages.list',
48
113
  'client.messages.search',
49
114
  'client.messages.send',
115
+ 'client.messages.update',
50
116
  'client.assets.download',
117
+ 'client.assets.serve',
118
+ 'client.assets.upload',
119
+ 'client.assets.uploadBase64',
120
+ 'client.info.retrieve',
51
121
  ], { threshold: 1, shouldSort: true });
52
122
  function getMethodSuggestions(fullyQualifiedMethodName) {
53
123
  return fuse
@@ -119,28 +189,38 @@ function parseError(code, error) {
119
189
  }
120
190
  const fetch = async (req) => {
121
191
  const { opts, code } = (await req.json());
122
- if (code == null) {
192
+ const runFunctionSource = code ? getRunFunctionSource(code) : null;
193
+ if (!runFunctionSource) {
194
+ const message = code ?
195
+ 'The code is missing a top-level `run` function.'
196
+ : 'The code argument is missing. Provide one containing a top-level `run` function.';
123
197
  return Response.json({
124
- message: 'The code param is missing. Provide one containing a top-level `run` function. Write code within this template:\n\n```\nasync function run(client) {\n // Fill this out\n}\n```',
198
+ is_error: true,
199
+ result: `${message} Write code within this template:\n\n\`\`\`\nasync function run(client) {\n // Fill this out\n}\n\`\`\``,
200
+ log_lines: [],
201
+ err_lines: [],
125
202
  }, { status: 400, statusText: 'Code execution error' });
126
203
  }
127
- const runFunctionNode = getRunFunctionNode(code);
128
- if (!runFunctionNode) {
204
+ const diagnostics = getTSDiagnostics(code);
205
+ if (diagnostics.length > 0) {
129
206
  return Response.json({
130
- message: 'The code is missing a top-level `run` function. Write code within this template:\n\n```\nasync function run(client) {\n // Fill this out\n}\n```',
207
+ is_error: true,
208
+ result: `The code contains TypeScript diagnostics:\n${diagnostics.join('\n')}`,
209
+ log_lines: [],
210
+ err_lines: [],
131
211
  }, { status: 400, statusText: 'Code execution error' });
132
212
  }
133
213
  const client = new desktop_api_1.BeeperDesktop({
134
214
  ...opts,
135
215
  });
136
- const logLines = [];
137
- const errLines = [];
216
+ const log_lines = [];
217
+ const err_lines = [];
138
218
  const console = {
139
219
  log: (...args) => {
140
- logLines.push(node_util_1.default.format(...args));
220
+ log_lines.push(node_util_1.default.format(...args));
141
221
  },
142
222
  error: (...args) => {
143
- errLines.push(node_util_1.default.format(...args));
223
+ err_lines.push(node_util_1.default.format(...args));
144
224
  },
145
225
  };
146
226
  try {
@@ -148,14 +228,18 @@ const fetch = async (req) => {
148
228
  eval(`${code}\nrun_ = run;`);
149
229
  const result = await run_(makeSdkProxy(client, { path: ['client'] }));
150
230
  return Response.json({
231
+ is_error: false,
151
232
  result,
152
- logLines,
153
- errLines,
233
+ log_lines,
234
+ err_lines,
154
235
  });
155
236
  }
156
237
  catch (e) {
157
238
  return Response.json({
158
- message: parseError(code, e),
239
+ is_error: true,
240
+ result: parseError(code, e),
241
+ log_lines,
242
+ err_lines,
159
243
  }, { status: 400, statusText: 'Code execution error' });
160
244
  }
161
245
  };