@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
@@ -1,29 +0,0 @@
1
- import type * as Shared from '@beeper/desktop-api/resources/shared';
2
- import type * as ChatsAPI from '@beeper/desktop-api/resources/chats/chats';
3
- import { ToolCallResult } from "../tools/types.js";
4
- type Message = Shared.Message;
5
- type Chat = ChatsAPI.Chat;
6
- type User = Shared.User;
7
- type MessageReaction = NonNullable<Message['reactions']>[number];
8
- export declare const formatRelativeDate: (date: Date) => string;
9
- export declare const formatBytes: (bytes: number, decimals?: number) => string;
10
- export declare function groupReactions(reactions: MessageReaction[]): {
11
- [key: string]: MessageReaction[];
12
- };
13
- export declare const getParticipantName: (participant: User, preferFirstName?: boolean) => string;
14
- export declare const createOpenLink: (baseURL: string, localChatIDOrChatID: string, messageKey?: string) => string;
15
- export declare const formatParticipantsToMarkdown: (participants: User[] | undefined, limit?: number) => string;
16
- export declare const formatReactionsToMarkdown: (reactions: Message["reactions"], participants?: Map<string, User>) => string;
17
- export declare const formatAttachmentToMarkdown: (attachment: Shared.Attachment | undefined) => string;
18
- export declare const formatChatToMarkdown: (chat: Chat, baseURL: string | undefined) => string;
19
- export declare const mapMessagesToText: (output: Shared.MessagesCursorSearch, input?: {
20
- query?: string;
21
- sender?: string;
22
- mediaTypes?: string[];
23
- }, ctx?: {
24
- apiBaseURL?: string;
25
- maxTextLength?: number;
26
- }) => string;
27
- export declare function asMarkdownContentResult(text: string | string[]): ToolCallResult;
28
- export {};
29
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/handlers/utils.ts"],"names":[],"mappings":"OAUO,KAAK,KAAK,MAAM,MAAM,sCAAsC;OAC5D,KAAK,KAAK,QAAQ,MAAM,2CAA2C;OACnE,EAAE,cAAc,EAAE;AAIzB,KAAK,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;AAC9B,KAAK,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC;AAC1B,KAAK,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;AACxB,KAAK,eAAe,GAAG,WAAW,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AAEjE,eAAO,MAAM,kBAAkB,GAAI,MAAM,IAAI,WAwB5C,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,EAAE,iBAAY,WAQtD,CAAC;AAKF,wBAAgB,cAAc,CAAC,SAAS,EAAE,eAAe,EAAE,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,EAAE,CAAA;CAAE,CASjG;AAED,eAAO,MAAM,kBAAkB,GAAI,aAAa,IAAI,EAAE,kBAAkB,OAAO,KAAG,MAOhE,CAAC;AAEnB,eAAO,MAAM,cAAc,GAAI,SAAS,MAAM,EAAE,qBAAqB,MAAM,EAAE,aAAa,MAAM,WACG,CAAC;AAEpG,eAAO,MAAM,4BAA4B,GAAI,cAAc,IAAI,EAAE,GAAG,SAAS,EAAE,cAAS,KAAG,MAc1F,CAAC;AAEF,eAAO,MAAM,yBAAyB,GACpC,WAAW,OAAO,CAAC,WAAW,CAAC,EAC/B,eAAe,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,KAC/B,MA8BF,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAI,YAAY,MAAM,CAAC,UAAU,GAAG,SAAS,KAAG,MA2BtF,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,MAAM,IAAI,EAAE,SAAS,MAAM,GAAG,SAAS,KAAG,MAqB9E,CAAC;AAkBF,eAAO,MAAM,iBAAiB,GAC5B,QAAQ,MAAM,CAAC,oBAAoB,EACnC,QAAQ;IACN,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB,EACD,MAAM;IAAE,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAA;CAAE,WAgKtD,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,cAAc,CAS/E"}
package/handlers/utils.js DELETED
@@ -1,296 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mapMessagesToText = exports.formatChatToMarkdown = exports.formatAttachmentToMarkdown = exports.formatReactionsToMarkdown = exports.formatParticipantsToMarkdown = exports.createOpenLink = exports.getParticipantName = exports.formatBytes = exports.formatRelativeDate = void 0;
4
- exports.groupReactions = groupReactions;
5
- exports.asMarkdownContentResult = asMarkdownContentResult;
6
- const date_fns_1 = require("date-fns");
7
- const MILLIS_IN_WEEK = 86400000 * 7;
8
- const formatRelativeDate = (date) => {
9
- const timeDifference = (0, date_fns_1.differenceInMilliseconds)((0, date_fns_1.endOfDay)(new Date()), date);
10
- if ((0, date_fns_1.isToday)(date))
11
- return 'Today';
12
- if ((0, date_fns_1.isYesterday)(date))
13
- return 'Yesterday';
14
- return new Intl.DateTimeFormat('default', timeDifference < MILLIS_IN_WEEK ?
15
- {
16
- weekday: 'long',
17
- }
18
- : (0, date_fns_1.isSameYear)(date, new Date()) ?
19
- {
20
- weekday: 'short',
21
- month: 'short',
22
- day: 'numeric',
23
- }
24
- : {
25
- year: 'numeric',
26
- month: 'short',
27
- day: 'numeric',
28
- }).format(date);
29
- };
30
- exports.formatRelativeDate = formatRelativeDate;
31
- const formatBytes = (bytes, decimals = 0) => {
32
- if (bytes === 0)
33
- return '0 B';
34
- const k = 1024;
35
- const sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
36
- const i = Math.floor(Math.log(bytes) / Math.log(k));
37
- return `${Math.floor(parseFloat((bytes / k ** i).toFixed(decimals)))}${sizes[i]}`;
38
- };
39
- exports.formatBytes = formatBytes;
40
- const skinToneRegex = /\uD83C[\uDFFB-\uDFFF]/g;
41
- const removeSkinTone = (emojiString) => emojiString.replace(skinToneRegex, '');
42
- function groupReactions(reactions) {
43
- const map = {};
44
- reactions.forEach((reaction) => {
45
- if (!reaction.reactionKey)
46
- return;
47
- const key = removeSkinTone(reaction.reactionKey);
48
- map[key] || (map[key] = []);
49
- map[key].push(reaction);
50
- });
51
- return map;
52
- }
53
- const getParticipantName = (participant, preferFirstName) => participant.fullName && preferFirstName ?
54
- participant.fullName.split(' ')[0]
55
- : participant.fullName ||
56
- participant.username ||
57
- participant.email ||
58
- participant.phoneNumber ||
59
- participant.id;
60
- exports.getParticipantName = getParticipantName;
61
- const createOpenLink = (baseURL, localChatIDOrChatID, messageKey) => `${baseURL}/open/${encodeURIComponent(localChatIDOrChatID)}${messageKey ? `/${messageKey}` : ''}`;
62
- exports.createOpenLink = createOpenLink;
63
- const formatParticipantsToMarkdown = (participants, limit = 3) => {
64
- if (!participants || participants.length === 0)
65
- return '';
66
- const names = participants
67
- .slice(0, limit)
68
- .map((p) => p.fullName || p.username || p.id)
69
- .filter(Boolean);
70
- if (participants.length > limit) {
71
- const othersCount = participants.length - limit;
72
- names.push(`& ${othersCount} other${othersCount === 1 ? '' : 's'}`);
73
- }
74
- return names.join(', ');
75
- };
76
- exports.formatParticipantsToMarkdown = formatParticipantsToMarkdown;
77
- const formatReactionsToMarkdown = (reactions, participants) => {
78
- if (!reactions || reactions.length === 0)
79
- return '';
80
- const reactionMap = groupReactions(reactions);
81
- const reactionParts = [];
82
- for (const [reactionKey, reactionList] of Object.entries(reactionMap)) {
83
- const count = reactionList.length;
84
- const reactorNames = reactionList
85
- .slice(0, 5)
86
- .map((r) => {
87
- if (!r.participantID)
88
- return null;
89
- const participant = participants?.get(r.participantID);
90
- return participant ? (0, exports.getParticipantName)(participant) : r.participantID;
91
- })
92
- .filter(Boolean);
93
- let reactorInfo = '';
94
- if (reactorNames.length > 0) {
95
- if (count > 5) {
96
- const othersCount = count - 5;
97
- reactorInfo = ` (${reactorNames.join(', ')} & ${othersCount} other${othersCount === 1 ? '' : 's'})`;
98
- }
99
- else {
100
- reactorInfo = ` (${reactorNames.join(', ')})`;
101
- }
102
- }
103
- reactionParts.push(`${reactionKey} ${count}${reactorInfo}`);
104
- }
105
- return reactionParts.length > 0 ? ` [${reactionParts.join(' ')}]` : '';
106
- };
107
- exports.formatReactionsToMarkdown = formatReactionsToMarkdown;
108
- const formatAttachmentToMarkdown = (attachment) => {
109
- if (!attachment)
110
- return '';
111
- const typeEmoji = {
112
- img: '🖼',
113
- video: '🎥',
114
- audio: '🎵',
115
- unknown: '📎',
116
- }[attachment.type] || '📎';
117
- const fileName = attachment.fileName || 'file';
118
- const url = attachment.srcURL || '';
119
- const hasBothDimensions = typeof attachment.size?.width === 'number' && typeof attachment.size?.height === 'number';
120
- const metaInfo = [];
121
- if (attachment.fileSize) {
122
- metaInfo.push((0, exports.formatBytes)(attachment.fileSize));
123
- }
124
- if (hasBothDimensions) {
125
- metaInfo.push(`${attachment.size.width}x${attachment.size.height}`);
126
- }
127
- const metaString = metaInfo.length > 0 ? ` (${metaInfo.join(', ')})` : '';
128
- return `\n${typeEmoji} [${fileName}](${url})${metaString}`;
129
- };
130
- exports.formatAttachmentToMarkdown = formatAttachmentToMarkdown;
131
- const formatChatToMarkdown = (chat, baseURL) => {
132
- const openURL = baseURL ? (0, exports.createOpenLink)(baseURL, chat.localChatID ?? chat.id) : undefined;
133
- const title = openURL ? `[${chat.title}](${openURL})` : chat.title;
134
- const participantList = chat.participants?.items ? (0, exports.formatParticipantsToMarkdown)(chat.participants.items, 3) : '';
135
- const participantInfo = participantList ? ` with ${participantList}` : '';
136
- const lines = [];
137
- lines.push(`\n## ${title} (chatID: ${chat.localChatID})`);
138
- let chatLine = `Chat on ${chat.network}${participantInfo}.`;
139
- if (typeof chat.unreadCount === 'number' && chat.unreadCount > 0) {
140
- chatLine += ` It has ${chat.unreadCount} unread message${chat.unreadCount === 1 ? '' : 's'}.`;
141
- }
142
- lines.push(chatLine);
143
- lines.push(`**Type**: ${chat.type}`);
144
- if (chat.lastActivity)
145
- lines.push(`**Last Activity**: ${chat.lastActivity}`);
146
- const status = [];
147
- if (chat.isArchived)
148
- status.push('archived');
149
- if (chat.isMuted)
150
- status.push('muted');
151
- if (chat.isPinned)
152
- status.push('pinned');
153
- if (status.length > 0)
154
- lines.push(`This chat is ${status.join(', ')}.`);
155
- return lines.join('\n');
156
- };
157
- exports.formatChatToMarkdown = formatChatToMarkdown;
158
- const parseLocalDateKey = (key) => {
159
- const parsed = (0, date_fns_1.parse)(key, 'yyyy-MM-dd', new Date());
160
- if (isNaN(parsed.getTime())) {
161
- throw new Error(`Invalid date key: ${key}`);
162
- }
163
- return parsed;
164
- };
165
- const mapMessagesToText = (output, input, ctx) => {
166
- const { items, hasMore } = output;
167
- const chats = output?.body?.chats ?? {};
168
- const messageCount = items.length;
169
- const chatCount = Object.keys(chats).length;
170
- // Determine if search filters would cause gaps in timeline
171
- // Gaps occur when filtering by: query text, sender, or media types
172
- // Gaps do NOT occur when only filtering by: chatIDs, accountIDs, chatType, or date ranges
173
- const hasGapCausingFilters = input && (input.query || input.sender || (input.mediaTypes && input.mediaTypes.length > 0));
174
- const paginationInfo = [];
175
- if (messageCount === 0) {
176
- if (!chats || chatCount === 0) {
177
- paginationInfo.push('No matching chats found');
178
- }
179
- else {
180
- paginationInfo.push(`No messages found in ${chatCount} chat${chatCount === 1 ? '' : 's'}`);
181
- }
182
- }
183
- else if (hasMore) {
184
- paginationInfo.push(`Found ${messageCount}+ messages across ${chatCount} chat${chatCount === 1 ? '' : 's'} (showing ${messageCount})`);
185
- if (output.oldestCursor) {
186
- paginationInfo.push(`Next page (older): cursor='${output.oldestCursor}', direction='before'`);
187
- }
188
- if (output.newestCursor) {
189
- paginationInfo.push(`Previous page (newer): cursor='${output.newestCursor}', direction='after'`);
190
- }
191
- }
192
- else {
193
- paginationInfo.push(`Found ${messageCount} message${messageCount === 1 ? '' : 's'} across ${chatCount} chat${chatCount === 1 ? '' : 's'} (complete)`);
194
- }
195
- if (hasGapCausingFilters && messageCount > 0) {
196
- paginationInfo.push('⚠️ Filtered results: only showing messages matching your search criteria.');
197
- }
198
- const messagesByChat = new Map();
199
- for (const message of items) {
200
- const chatMessages = messagesByChat.get(message.chatID) || [];
201
- chatMessages.push(message);
202
- messagesByChat.set(message.chatID, chatMessages);
203
- }
204
- const chatSummaries = [];
205
- for (const [chatID, messages] of messagesByChat) {
206
- const chat = chats[chatID];
207
- if (chat) {
208
- chatSummaries.push(`# ${chat.title} [${messages.length} message${messages.length === 1 ? '' : 's'}]`);
209
- }
210
- }
211
- const headerLines = [...paginationInfo, '', ...chatSummaries];
212
- const summary = headerLines.join('\n');
213
- const chatSections = [];
214
- for (const [chatID, messages] of messagesByChat) {
215
- const chat = chats[chatID];
216
- if (!chat)
217
- continue;
218
- const participantList = chat.participants?.items ? (0, exports.formatParticipantsToMarkdown)(chat.participants.items, 3) : '';
219
- const participantInfo = participantList ? ` with ${participantList}` : '';
220
- const openURL = ctx?.apiBaseURL ? (0, exports.createOpenLink)(ctx.apiBaseURL, chat.localChatID ?? chat.id) : undefined;
221
- const title = openURL ? `[${chat.title}](${openURL})` : chat.title;
222
- chatSections.push(`# ${title} (chatID: ${chat.localChatID})`);
223
- chatSections.push(`Chat on ${chat.network}${participantInfo}.`);
224
- chatSections.push('');
225
- const messagesByDate = new Map();
226
- for (const message of messages) {
227
- const dateKey = (0, date_fns_1.format)(new Date(message.timestamp), 'yyyy-MM-dd');
228
- const dateMessages = messagesByDate.get(dateKey) || [];
229
- dateMessages.push(message);
230
- messagesByDate.set(dateKey, dateMessages);
231
- }
232
- const sortedDates = Array.from(messagesByDate.keys()).sort();
233
- const participantMap = chat?.participants?.items ?
234
- new Map(chat.participants.items.map((p) => [p.id, p]))
235
- : undefined;
236
- for (let i = 0; i < sortedDates.length; i++) {
237
- const dateKey = sortedDates[i];
238
- const dateObj = parseLocalDateKey(dateKey);
239
- const relativeTime = (0, exports.formatRelativeDate)(dateObj);
240
- chatSections.push(`## ${relativeTime} (${dateKey})`);
241
- chatSections.push('');
242
- const dateMessages = messagesByDate.get(dateKey) || [];
243
- dateMessages.sort((a, b) => new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime());
244
- for (const message of dateMessages) {
245
- const time = new Date(message.timestamp);
246
- const timeStr = (0, date_fns_1.format)(time, 'HH:mm');
247
- const baseSenderName = message.senderName || message.senderID;
248
- const senderName = message.isSender ? `${baseSenderName} (You)` : baseSenderName;
249
- const maxTextLength = ctx?.maxTextLength ?? 1000;
250
- let text = message.text || '';
251
- if (text && text.length > maxTextLength) {
252
- const remainingChars = text.length - maxTextLength;
253
- text = text.substring(0, maxTextLength) + `... [+${remainingChars} chars]`;
254
- }
255
- const attachment = message.attachments?.[0]; // Assume single attachment
256
- const attachmentChatID = chat.localChatID ?? chat.id;
257
- const attachmentLink = attachment && attachmentChatID ?
258
- `\n📎 [${attachment.fileName || 'attachment'}](beeper-mcp://attachments/${attachmentChatID}/${message.id}/0)`
259
- : '';
260
- const reactionsStr = (0, exports.formatReactionsToMarkdown)(message.reactions, participantMap);
261
- const sortKeyLink = chat.localChatID ?
262
- `([open at sort key](${(0, exports.createOpenLink)(ctx?.apiBaseURL || '', chat.localChatID, String(message.sortKey))}))`
263
- : `(sortKey: ${message.sortKey})`;
264
- const messageStr = `**${senderName}** (${timeStr}): ${text}${attachmentLink}${reactionsStr} ${sortKeyLink}`;
265
- chatSections.push(messageStr);
266
- chatSections.push('');
267
- }
268
- // Add date gap indicator when dates are not consecutive
269
- if (i < sortedDates.length - 1) {
270
- const nextDateKey = sortedDates[i + 1];
271
- const currentDate = parseLocalDateKey(dateKey);
272
- const nextDate = parseLocalDateKey(nextDateKey);
273
- const dayDiff = (0, date_fns_1.differenceInDays)(nextDate, currentDate);
274
- // Only show gap if dates are not consecutive
275
- if (dayDiff > 1) {
276
- const gapDays = dayDiff - 1;
277
- chatSections.push(`*[... ${gapDays} day${gapDays === 1 ? '' : 's'} gap ...]*`);
278
- chatSections.push('');
279
- }
280
- }
281
- }
282
- }
283
- return [summary, '', ...chatSections].join('\n');
284
- };
285
- exports.mapMessagesToText = mapMessagesToText;
286
- function asMarkdownContentResult(text) {
287
- return {
288
- content: [
289
- {
290
- type: 'text',
291
- text: Array.isArray(text) ? text.join('\n') : text,
292
- },
293
- ],
294
- };
295
- }
296
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/handlers/utils.ts"],"names":[],"mappings":";;;AA4DA,wCASC;AA8SD,0DASC;AA5XD,uCASkB;AAKlB,MAAM,cAAc,GAAG,QAAQ,GAAG,CAAC,CAAC;AAO7B,MAAM,kBAAkB,GAAG,CAAC,IAAU,EAAE,EAAE;IAC/C,MAAM,cAAc,GAAG,IAAA,mCAAwB,EAAC,IAAA,mBAAQ,EAAC,IAAI,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;IAE5E,IAAI,IAAA,kBAAO,EAAC,IAAI,CAAC;QAAE,OAAO,OAAO,CAAC;IAClC,IAAI,IAAA,sBAAW,EAAC,IAAI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AC,EAAE,CAAC;gBAC/B,MAAM,WAAW,GAAG,WAAW,CAAC,CAAC,GAAG,CAAC,CAAE,CAAC;gBACxC,MAAM,WAAW,GAAG,iBAAiB,CAAC,OAAQ,CAAC,CAAC;gBAChD,MAAM,QAAQ,GAAG,iBAAiB,CAAC,WAAW,CAAC,CAAC;gBAChD,MAAM,OAAO,GAAG,IAAA,2BAAgB,EAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;gBAExD,6CAA6C;gBAC7C,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;oBAChB,MAAM,OAAO,GAAG,OAAO,GAAG,CAAC,CAAC;oBAC5B,YAAY,CAAC,IAAI,CAAC,SAAS,OAAO,OAAO,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC;oBAC/E,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBACxB,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,CAAC,OAAO,EAAE,EAAE,EAAE,GAAG,YAAY,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACnD,CAAC,CAAC;AAvKW,QAAA,iBAAiB,qBAuK5B;AAEF,SAAgB,uBAAuB,CAAC,IAAuB;IAC7D,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI;aACnD;SACF;KACF,CAAC;AACJ,CAAC"}
@@ -1,282 +0,0 @@
1
- import { differenceInMilliseconds, differenceInDays, endOfDay, format, isToday, isYesterday, isSameYear, parse, } from 'date-fns';
2
- const MILLIS_IN_WEEK = 86400000 * 7;
3
- export const formatRelativeDate = (date) => {
4
- const timeDifference = differenceInMilliseconds(endOfDay(new Date()), date);
5
- if (isToday(date))
6
- return 'Today';
7
- if (isYesterday(date))
8
- return 'Yesterday';
9
- return new Intl.DateTimeFormat('default', timeDifference < MILLIS_IN_WEEK ?
10
- {
11
- weekday: 'long',
12
- }
13
- : isSameYear(date, new Date()) ?
14
- {
15
- weekday: 'short',
16
- month: 'short',
17
- day: 'numeric',
18
- }
19
- : {
20
- year: 'numeric',
21
- month: 'short',
22
- day: 'numeric',
23
- }).format(date);
24
- };
25
- export const formatBytes = (bytes, decimals = 0) => {
26
- if (bytes === 0)
27
- return '0 B';
28
- const k = 1024;
29
- const sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
30
- const i = Math.floor(Math.log(bytes) / Math.log(k));
31
- return `${Math.floor(parseFloat((bytes / k ** i).toFixed(decimals)))}${sizes[i]}`;
32
- };
33
- const skinToneRegex = /\uD83C[\uDFFB-\uDFFF]/g;
34
- const removeSkinTone = (emojiString) => emojiString.replace(skinToneRegex, '');
35
- export function groupReactions(reactions) {
36
- const map = {};
37
- reactions.forEach((reaction) => {
38
- if (!reaction.reactionKey)
39
- return;
40
- const key = removeSkinTone(reaction.reactionKey);
41
- map[key] || (map[key] = []);
42
- map[key].push(reaction);
43
- });
44
- return map;
45
- }
46
- export const getParticipantName = (participant, preferFirstName) => participant.fullName && preferFirstName ?
47
- participant.fullName.split(' ')[0]
48
- : participant.fullName ||
49
- participant.username ||
50
- participant.email ||
51
- participant.phoneNumber ||
52
- participant.id;
53
- export const createOpenLink = (baseURL, localChatIDOrChatID, messageKey) => `${baseURL}/open/${encodeURIComponent(localChatIDOrChatID)}${messageKey ? `/${messageKey}` : ''}`;
54
- export const formatParticipantsToMarkdown = (participants, limit = 3) => {
55
- if (!participants || participants.length === 0)
56
- return '';
57
- const names = participants
58
- .slice(0, limit)
59
- .map((p) => p.fullName || p.username || p.id)
60
- .filter(Boolean);
61
- if (participants.length > limit) {
62
- const othersCount = participants.length - limit;
63
- names.push(`& ${othersCount} other${othersCount === 1 ? '' : 's'}`);
64
- }
65
- return names.join(', ');
66
- };
67
- export const formatReactionsToMarkdown = (reactions, participants) => {
68
- if (!reactions || reactions.length === 0)
69
- return '';
70
- const reactionMap = groupReactions(reactions);
71
- const reactionParts = [];
72
- for (const [reactionKey, reactionList] of Object.entries(reactionMap)) {
73
- const count = reactionList.length;
74
- const reactorNames = reactionList
75
- .slice(0, 5)
76
- .map((r) => {
77
- if (!r.participantID)
78
- return null;
79
- const participant = participants?.get(r.participantID);
80
- return participant ? getParticipantName(participant) : r.participantID;
81
- })
82
- .filter(Boolean);
83
- let reactorInfo = '';
84
- if (reactorNames.length > 0) {
85
- if (count > 5) {
86
- const othersCount = count - 5;
87
- reactorInfo = ` (${reactorNames.join(', ')} & ${othersCount} other${othersCount === 1 ? '' : 's'})`;
88
- }
89
- else {
90
- reactorInfo = ` (${reactorNames.join(', ')})`;
91
- }
92
- }
93
- reactionParts.push(`${reactionKey} ${count}${reactorInfo}`);
94
- }
95
- return reactionParts.length > 0 ? ` [${reactionParts.join(' ')}]` : '';
96
- };
97
- export const formatAttachmentToMarkdown = (attachment) => {
98
- if (!attachment)
99
- return '';
100
- const typeEmoji = {
101
- img: '🖼',
102
- video: '🎥',
103
- audio: '🎵',
104
- unknown: '📎',
105
- }[attachment.type] || '📎';
106
- const fileName = attachment.fileName || 'file';
107
- const url = attachment.srcURL || '';
108
- const hasBothDimensions = typeof attachment.size?.width === 'number' && typeof attachment.size?.height === 'number';
109
- const metaInfo = [];
110
- if (attachment.fileSize) {
111
- metaInfo.push(formatBytes(attachment.fileSize));
112
- }
113
- if (hasBothDimensions) {
114
- metaInfo.push(`${attachment.size.width}x${attachment.size.height}`);
115
- }
116
- const metaString = metaInfo.length > 0 ? ` (${metaInfo.join(', ')})` : '';
117
- return `\n${typeEmoji} [${fileName}](${url})${metaString}`;
118
- };
119
- export const formatChatToMarkdown = (chat, baseURL) => {
120
- const openURL = baseURL ? createOpenLink(baseURL, chat.localChatID ?? chat.id) : undefined;
121
- const title = openURL ? `[${chat.title}](${openURL})` : chat.title;
122
- const participantList = chat.participants?.items ? formatParticipantsToMarkdown(chat.participants.items, 3) : '';
123
- const participantInfo = participantList ? ` with ${participantList}` : '';
124
- const lines = [];
125
- lines.push(`\n## ${title} (chatID: ${chat.localChatID})`);
126
- let chatLine = `Chat on ${chat.network}${participantInfo}.`;
127
- if (typeof chat.unreadCount === 'number' && chat.unreadCount > 0) {
128
- chatLine += ` It has ${chat.unreadCount} unread message${chat.unreadCount === 1 ? '' : 's'}.`;
129
- }
130
- lines.push(chatLine);
131
- lines.push(`**Type**: ${chat.type}`);
132
- if (chat.lastActivity)
133
- lines.push(`**Last Activity**: ${chat.lastActivity}`);
134
- const status = [];
135
- if (chat.isArchived)
136
- status.push('archived');
137
- if (chat.isMuted)
138
- status.push('muted');
139
- if (chat.isPinned)
140
- status.push('pinned');
141
- if (status.length > 0)
142
- lines.push(`This chat is ${status.join(', ')}.`);
143
- return lines.join('\n');
144
- };
145
- const parseLocalDateKey = (key) => {
146
- const parsed = parse(key, 'yyyy-MM-dd', new Date());
147
- if (isNaN(parsed.getTime())) {
148
- throw new Error(`Invalid date key: ${key}`);
149
- }
150
- return parsed;
151
- };
152
- export const mapMessagesToText = (output, input, ctx) => {
153
- const { items, hasMore } = output;
154
- const chats = output?.body?.chats ?? {};
155
- const messageCount = items.length;
156
- const chatCount = Object.keys(chats).length;
157
- // Determine if search filters would cause gaps in timeline
158
- // Gaps occur when filtering by: query text, sender, or media types
159
- // Gaps do NOT occur when only filtering by: chatIDs, accountIDs, chatType, or date ranges
160
- const hasGapCausingFilters = input && (input.query || input.sender || (input.mediaTypes && input.mediaTypes.length > 0));
161
- const paginationInfo = [];
162
- if (messageCount === 0) {
163
- if (!chats || chatCount === 0) {
164
- paginationInfo.push('No matching chats found');
165
- }
166
- else {
167
- paginationInfo.push(`No messages found in ${chatCount} chat${chatCount === 1 ? '' : 's'}`);
168
- }
169
- }
170
- else if (hasMore) {
171
- paginationInfo.push(`Found ${messageCount}+ messages across ${chatCount} chat${chatCount === 1 ? '' : 's'} (showing ${messageCount})`);
172
- if (output.oldestCursor) {
173
- paginationInfo.push(`Next page (older): cursor='${output.oldestCursor}', direction='before'`);
174
- }
175
- if (output.newestCursor) {
176
- paginationInfo.push(`Previous page (newer): cursor='${output.newestCursor}', direction='after'`);
177
- }
178
- }
179
- else {
180
- paginationInfo.push(`Found ${messageCount} message${messageCount === 1 ? '' : 's'} across ${chatCount} chat${chatCount === 1 ? '' : 's'} (complete)`);
181
- }
182
- if (hasGapCausingFilters && messageCount > 0) {
183
- paginationInfo.push('⚠️ Filtered results: only showing messages matching your search criteria.');
184
- }
185
- const messagesByChat = new Map();
186
- for (const message of items) {
187
- const chatMessages = messagesByChat.get(message.chatID) || [];
188
- chatMessages.push(message);
189
- messagesByChat.set(message.chatID, chatMessages);
190
- }
191
- const chatSummaries = [];
192
- for (const [chatID, messages] of messagesByChat) {
193
- const chat = chats[chatID];
194
- if (chat) {
195
- chatSummaries.push(`# ${chat.title} [${messages.length} message${messages.length === 1 ? '' : 's'}]`);
196
- }
197
- }
198
- const headerLines = [...paginationInfo, '', ...chatSummaries];
199
- const summary = headerLines.join('\n');
200
- const chatSections = [];
201
- for (const [chatID, messages] of messagesByChat) {
202
- const chat = chats[chatID];
203
- if (!chat)
204
- continue;
205
- const participantList = chat.participants?.items ? formatParticipantsToMarkdown(chat.participants.items, 3) : '';
206
- const participantInfo = participantList ? ` with ${participantList}` : '';
207
- const openURL = ctx?.apiBaseURL ? createOpenLink(ctx.apiBaseURL, chat.localChatID ?? chat.id) : undefined;
208
- const title = openURL ? `[${chat.title}](${openURL})` : chat.title;
209
- chatSections.push(`# ${title} (chatID: ${chat.localChatID})`);
210
- chatSections.push(`Chat on ${chat.network}${participantInfo}.`);
211
- chatSections.push('');
212
- const messagesByDate = new Map();
213
- for (const message of messages) {
214
- const dateKey = format(new Date(message.timestamp), 'yyyy-MM-dd');
215
- const dateMessages = messagesByDate.get(dateKey) || [];
216
- dateMessages.push(message);
217
- messagesByDate.set(dateKey, dateMessages);
218
- }
219
- const sortedDates = Array.from(messagesByDate.keys()).sort();
220
- const participantMap = chat?.participants?.items ?
221
- new Map(chat.participants.items.map((p) => [p.id, p]))
222
- : undefined;
223
- for (let i = 0; i < sortedDates.length; i++) {
224
- const dateKey = sortedDates[i];
225
- const dateObj = parseLocalDateKey(dateKey);
226
- const relativeTime = formatRelativeDate(dateObj);
227
- chatSections.push(`## ${relativeTime} (${dateKey})`);
228
- chatSections.push('');
229
- const dateMessages = messagesByDate.get(dateKey) || [];
230
- dateMessages.sort((a, b) => new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime());
231
- for (const message of dateMessages) {
232
- const time = new Date(message.timestamp);
233
- const timeStr = format(time, 'HH:mm');
234
- const baseSenderName = message.senderName || message.senderID;
235
- const senderName = message.isSender ? `${baseSenderName} (You)` : baseSenderName;
236
- const maxTextLength = ctx?.maxTextLength ?? 1000;
237
- let text = message.text || '';
238
- if (text && text.length > maxTextLength) {
239
- const remainingChars = text.length - maxTextLength;
240
- text = text.substring(0, maxTextLength) + `... [+${remainingChars} chars]`;
241
- }
242
- const attachment = message.attachments?.[0]; // Assume single attachment
243
- const attachmentChatID = chat.localChatID ?? chat.id;
244
- const attachmentLink = attachment && attachmentChatID ?
245
- `\n📎 [${attachment.fileName || 'attachment'}](beeper-mcp://attachments/${attachmentChatID}/${message.id}/0)`
246
- : '';
247
- const reactionsStr = formatReactionsToMarkdown(message.reactions, participantMap);
248
- const sortKeyLink = chat.localChatID ?
249
- `([open at sort key](${createOpenLink(ctx?.apiBaseURL || '', chat.localChatID, String(message.sortKey))}))`
250
- : `(sortKey: ${message.sortKey})`;
251
- const messageStr = `**${senderName}** (${timeStr}): ${text}${attachmentLink}${reactionsStr} ${sortKeyLink}`;
252
- chatSections.push(messageStr);
253
- chatSections.push('');
254
- }
255
- // Add date gap indicator when dates are not consecutive
256
- if (i < sortedDates.length - 1) {
257
- const nextDateKey = sortedDates[i + 1];
258
- const currentDate = parseLocalDateKey(dateKey);
259
- const nextDate = parseLocalDateKey(nextDateKey);
260
- const dayDiff = differenceInDays(nextDate, currentDate);
261
- // Only show gap if dates are not consecutive
262
- if (dayDiff > 1) {
263
- const gapDays = dayDiff - 1;
264
- chatSections.push(`*[... ${gapDays} day${gapDays === 1 ? '' : 's'} gap ...]*`);
265
- chatSections.push('');
266
- }
267
- }
268
- }
269
- }
270
- return [summary, '', ...chatSections].join('\n');
271
- };
272
- export function asMarkdownContentResult(text) {
273
- return {
274
- content: [
275
- {
276
- type: 'text',
277
- text: Array.isArray(text) ? text.join('\n') : text,
278
- },
279
- ],
280
- };
281
- }
282
- //# sourceMappingURL=utils.mjs.map