slashvibe-mcp 0.3.21 → 0.3.22

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 (229) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +280 -47
  3. package/config.js +36 -31
  4. package/crypto.js +1 -6
  5. package/discord.js +19 -19
  6. package/index.js +217 -207
  7. package/intelligence/index.js +2 -9
  8. package/intelligence/infer.js +10 -16
  9. package/intelligence/patterns.js +23 -18
  10. package/intelligence/proactive.js +16 -15
  11. package/intelligence/serendipity.js +57 -20
  12. package/memory.js +13 -8
  13. package/notify.js +39 -14
  14. package/package.json +27 -20
  15. package/presence.js +2 -2
  16. package/prompts.js +5 -9
  17. package/protocol/index.js +123 -87
  18. package/protocol/telegram-commands.js +36 -37
  19. package/store/api.js +358 -529
  20. package/store/local.js +9 -10
  21. package/store/profiles.js +48 -192
  22. package/store/reservations.js +2 -9
  23. package/store/skills.js +69 -71
  24. package/store/sqlite.js +355 -0
  25. package/tools/_actions.js +48 -387
  26. package/tools/_connection-queue.js +45 -56
  27. package/tools/_discovery-enhanced.js +52 -57
  28. package/tools/_discovery.js +87 -185
  29. package/tools/{l2-status.js → _experimental/l2-status.js} +68 -70
  30. package/tools/{shipback.js → _experimental/shipback.js} +4 -3
  31. package/tools/_proactive-discovery.js +60 -73
  32. package/tools/_shared/index.js +41 -64
  33. package/tools/admin-inbox.js +10 -15
  34. package/tools/agents.js +1 -1
  35. package/tools/artifact-create.js +13 -23
  36. package/tools/artifact-view.js +4 -4
  37. package/tools/{_deprecated/back.js → back.js} +1 -1
  38. package/tools/bye.js +3 -5
  39. package/tools/consent.js +2 -2
  40. package/tools/context.js +9 -10
  41. package/tools/crossword.js +3 -2
  42. package/tools/discover.js +94 -356
  43. package/tools/dm.js +27 -86
  44. package/tools/doctor.js +12 -41
  45. package/tools/drawing.js +34 -20
  46. package/tools/echo.js +11 -11
  47. package/tools/feed.js +30 -58
  48. package/tools/follow.js +64 -187
  49. package/tools/{_deprecated/forget.js → forget.js} +4 -7
  50. package/tools/game.js +144 -48
  51. package/tools/handoff.js +6 -8
  52. package/tools/help.js +3 -3
  53. package/tools/idea.js +15 -27
  54. package/tools/inbox.js +121 -293
  55. package/tools/init.js +54 -151
  56. package/tools/invite.js +8 -21
  57. package/tools/migrate.js +27 -24
  58. package/tools/multiplayer-game.js +50 -40
  59. package/tools/{_deprecated/mute.js → mute.js} +4 -3
  60. package/tools/notifications.js +58 -48
  61. package/tools/observe.js +12 -15
  62. package/tools/onboarding.js +8 -11
  63. package/tools/open.js +13 -144
  64. package/tools/party-game.js +23 -12
  65. package/tools/patterns.js +2 -1
  66. package/tools/ping.js +5 -7
  67. package/tools/react.js +28 -30
  68. package/tools/{_deprecated/recall.js → recall.js} +5 -10
  69. package/tools/release.js +4 -2
  70. package/tools/{_deprecated/remember.js → remember.js} +4 -6
  71. package/tools/report.js +2 -2
  72. package/tools/request.js +6 -26
  73. package/tools/reserve.js +1 -1
  74. package/tools/session-fork.js +97 -0
  75. package/tools/session-save.js +109 -0
  76. package/tools/settings.js +30 -99
  77. package/tools/ship.js +74 -56
  78. package/tools/{_deprecated/skills-exchange.js → skills-exchange.js} +38 -39
  79. package/tools/social-inbox.js +22 -28
  80. package/tools/social-post.js +24 -27
  81. package/tools/solo-game.js +54 -46
  82. package/tools/start.js +14 -148
  83. package/tools/status.js +21 -68
  84. package/tools/submit.js +4 -2
  85. package/tools/suggest-tags.js +36 -33
  86. package/tools/summarize.js +19 -16
  87. package/tools/tag-suggestions.js +72 -73
  88. package/tools/test.js +1 -1
  89. package/tools/{_deprecated/tictactoe.js → tictactoe.js} +26 -26
  90. package/tools/token.js +4 -4
  91. package/tools/update.js +1 -2
  92. package/tools/watch.js +132 -112
  93. package/tools/who.js +20 -40
  94. package/tools/{_deprecated/wordassociation.js → wordassociation.js} +23 -20
  95. package/tools/workshop-buddy.js +52 -53
  96. package/tools/x-mentions.js +0 -1
  97. package/tools/x-reply.js +0 -1
  98. package/twitter.js +14 -20
  99. package/version.json +8 -10
  100. package/analytics.js +0 -107
  101. package/auth-store.js +0 -148
  102. package/auto-update.js +0 -130
  103. package/bridges/bridge-monitor.js +0 -388
  104. package/bridges/discord-bot.js +0 -431
  105. package/bridges/farcaster.js +0 -299
  106. package/bridges/telegram.js +0 -261
  107. package/bridges/webhook-health.js +0 -420
  108. package/bridges/webhook-server.js +0 -437
  109. package/bridges/whatsapp.js +0 -441
  110. package/bridges/x-webhook.js +0 -423
  111. package/games/arcade.js +0 -406
  112. package/games/chess.js +0 -451
  113. package/games/colorguess.js +0 -343
  114. package/games/crossword-words.js +0 -171
  115. package/games/crossword.js +0 -461
  116. package/games/drawing.js +0 -347
  117. package/games/gameroulette.js +0 -300
  118. package/games/gamerouter.js +0 -336
  119. package/games/gamestatus.js +0 -337
  120. package/games/guessnumber.js +0 -209
  121. package/games/hangman.js +0 -279
  122. package/games/memory.js +0 -338
  123. package/games/multiplayer-tictactoe.js +0 -389
  124. package/games/pixelart.js +0 -399
  125. package/games/quickduel.js +0 -354
  126. package/games/riddle.js +0 -371
  127. package/games/rockpaperscissors.js +0 -291
  128. package/games/snake.js +0 -406
  129. package/games/storybuilder.js +0 -343
  130. package/games/tictactoe.js +0 -345
  131. package/games/twentyquestions.js +0 -286
  132. package/games/twotruths.js +0 -207
  133. package/games/werewolf.js +0 -508
  134. package/games/wordassociation.js +0 -247
  135. package/games/wordchain.js +0 -135
  136. package/intelligence/interests.js +0 -369
  137. package/notification-emitter.js +0 -77
  138. package/setup.js +0 -480
  139. package/smart-inbox.js +0 -276
  140. package/tools/_deprecated/auto-suggest-connections.js +0 -304
  141. package/tools/_deprecated/bootstrap-skills.js +0 -231
  142. package/tools/_deprecated/bridge-dashboard.js +0 -342
  143. package/tools/_deprecated/bridge-health.js +0 -400
  144. package/tools/_deprecated/bridge-live.js +0 -384
  145. package/tools/_deprecated/bridges.js +0 -383
  146. package/tools/_deprecated/colorguess.js +0 -281
  147. package/tools/_deprecated/discover-insights.js +0 -379
  148. package/tools/_deprecated/discover-momentum.js +0 -256
  149. package/tools/_deprecated/discovery-analytics.js +0 -345
  150. package/tools/_deprecated/discovery-auto-suggest.js +0 -275
  151. package/tools/_deprecated/discovery-bootstrap.js +0 -267
  152. package/tools/_deprecated/discovery-daily.js +0 -375
  153. package/tools/_deprecated/discovery-dashboard.js +0 -385
  154. package/tools/_deprecated/discovery-digest.js +0 -314
  155. package/tools/_deprecated/discovery-hub.js +0 -357
  156. package/tools/_deprecated/discovery-insights.js +0 -384
  157. package/tools/_deprecated/discovery-momentum.js +0 -281
  158. package/tools/_deprecated/discovery-monitor.js +0 -319
  159. package/tools/_deprecated/discovery-proactive.js +0 -300
  160. package/tools/_deprecated/draw.js +0 -317
  161. package/tools/_deprecated/farcaster.js +0 -307
  162. package/tools/_deprecated/games-catalog.js +0 -376
  163. package/tools/_deprecated/games.js +0 -313
  164. package/tools/_deprecated/guessnumber.js +0 -194
  165. package/tools/_deprecated/hangman.js +0 -129
  166. package/tools/_deprecated/multiplayer-tictactoe.js +0 -303
  167. package/tools/_deprecated/riddle.js +0 -240
  168. package/tools/_deprecated/run-bootstrap.js +0 -69
  169. package/tools/_deprecated/skills-analytics.js +0 -349
  170. package/tools/_deprecated/skills-bootstrap.js +0 -301
  171. package/tools/_deprecated/skills-dashboard.js +0 -268
  172. package/tools/_deprecated/skills.js +0 -380
  173. package/tools/_deprecated/smart-intro.js +0 -353
  174. package/tools/_deprecated/storybuilder.js +0 -331
  175. package/tools/_deprecated/telegram-bot.js +0 -183
  176. package/tools/_deprecated/telegram-setup.js +0 -214
  177. package/tools/_deprecated/twentyquestions.js +0 -143
  178. package/tools/_shared.js +0 -234
  179. package/tools/_work-context.js +0 -338
  180. package/tools/_work-context.manual-test.js +0 -199
  181. package/tools/_work-context.test.js +0 -260
  182. package/tools/activity.js +0 -220
  183. package/tools/agent-treasury.js +0 -288
  184. package/tools/analytics.js +0 -191
  185. package/tools/approve.js +0 -197
  186. package/tools/arcade.js +0 -173
  187. package/tools/artifacts-price.js +0 -107
  188. package/tools/ask-expert.js +0 -160
  189. package/tools/available.js +0 -120
  190. package/tools/become-expert.js +0 -150
  191. package/tools/broadcast.js +0 -325
  192. package/tools/chat.js +0 -202
  193. package/tools/collaborative-drawing.js +0 -286
  194. package/tools/connection-status.js +0 -178
  195. package/tools/earnings.js +0 -126
  196. package/tools/friends.js +0 -207
  197. package/tools/genesis.js +0 -233
  198. package/tools/gig-browse.js +0 -206
  199. package/tools/gig-complete.js +0 -144
  200. package/tools/health.js +0 -87
  201. package/tools/leaderboard.js +0 -117
  202. package/tools/lib/git-apply.js +0 -206
  203. package/tools/lib/git-bundle.js +0 -407
  204. package/tools/mint.js +0 -377
  205. package/tools/plan.js +0 -225
  206. package/tools/profile.js +0 -219
  207. package/tools/proof-of-work.js +0 -144
  208. package/tools/pulse.js +0 -218
  209. package/tools/reply.js +0 -166
  210. package/tools/reputation.js +0 -175
  211. package/tools/schedule.js +0 -367
  212. package/tools/search-messages.js +0 -123
  213. package/tools/session.js +0 -467
  214. package/tools/session_price.js +0 -128
  215. package/tools/smart-check.js +0 -201
  216. package/tools/social-processor.js +0 -445
  217. package/tools/streak.js +0 -147
  218. package/tools/stuck.js +0 -297
  219. package/tools/subscribe.js +0 -148
  220. package/tools/subscriptions.js +0 -134
  221. package/tools/tip.js +0 -193
  222. package/tools/wallet.js +0 -269
  223. package/tools/webhook-test.js +0 -388
  224. package/tools/withdraw.js +0 -145
  225. package/tools/work-summary.js +0 -96
  226. package/tools/workshop.js +0 -327
  227. /package/tools/{l2-bridge.js → _experimental/l2-bridge.js} +0 -0
  228. /package/tools/{l2.js → _experimental/l2.js} +0 -0
  229. /package/tools/{_deprecated/away.js → away.js} +0 -0
@@ -1,431 +0,0 @@
1
- /**
2
- * /vibe Discord Bot Bridge
3
- *
4
- * Two-way Discord integration using Discord.js bot API.
5
- * Complements discord.js webhook functionality with full bot features.
6
- */
7
-
8
- const config = require('../config');
9
-
10
- /**
11
- * Get Discord bot credentials from config
12
- */
13
- function getBotToken() {
14
- const cfg = config.load();
15
- return cfg.discord_bot_token || process.env.DISCORD_BOT_TOKEN || null;
16
- }
17
-
18
- /**
19
- * Get guild ID from config (optional - bot can work in any server)
20
- */
21
- function getGuildId() {
22
- const cfg = config.load();
23
- return cfg.discord_guild_id || process.env.DISCORD_GUILD_ID || null;
24
- }
25
-
26
- /**
27
- * Check if Discord bot is configured
28
- */
29
- function isConfigured() {
30
- return !!getBotToken();
31
- }
32
-
33
- /**
34
- * Make authenticated request to Discord API
35
- */
36
- async function discordRequest(method, endpoint, body = null) {
37
- const token = getBotToken();
38
- if (!token) throw new Error('Discord bot token not configured');
39
-
40
- const url = `https://discord.com/api/v10${endpoint}`;
41
-
42
- const headers = {
43
- 'Authorization': `Bot ${token}`,
44
- 'Content-Type': 'application/json'
45
- };
46
-
47
- const response = await fetch(url, {
48
- method,
49
- headers,
50
- body: body ? JSON.stringify(body) : undefined
51
- });
52
-
53
- if (!response.ok) {
54
- const error = await response.text();
55
- throw new Error(`Discord API error ${response.status}: ${error}`);
56
- }
57
-
58
- // Some endpoints return 204 No Content
59
- if (response.status === 204) {
60
- return null;
61
- }
62
-
63
- return response.json();
64
- }
65
-
66
- /**
67
- * Get bot user info
68
- */
69
- async function getBotInfo() {
70
- return discordRequest('GET', '/users/@me');
71
- }
72
-
73
- /**
74
- * Get guilds (servers) the bot is in
75
- */
76
- async function getGuilds() {
77
- return discordRequest('GET', '/users/@me/guilds');
78
- }
79
-
80
- /**
81
- * Get channels in a guild
82
- */
83
- async function getChannels(guildId) {
84
- return discordRequest('GET', `/guilds/${guildId}/channels`);
85
- }
86
-
87
- /**
88
- * Send message to a channel
89
- */
90
- async function sendMessage(channelId, content, options = {}) {
91
- const body = {
92
- content,
93
- embeds: options.embeds || undefined,
94
- reply: options.replyTo ? { message_id: options.replyTo } : undefined,
95
- flags: options.silent ? 4096 : undefined // SUPPRESS_NOTIFICATIONS
96
- };
97
-
98
- return discordRequest('POST', `/channels/${channelId}/messages`, body);
99
- }
100
-
101
- /**
102
- * Get recent messages from a channel
103
- */
104
- async function getMessages(channelId, limit = 50, before = null) {
105
- let endpoint = `/channels/${channelId}/messages?limit=${limit}`;
106
- if (before) endpoint += `&before=${before}`;
107
-
108
- return discordRequest('GET', endpoint);
109
- }
110
-
111
- /**
112
- * Create a DM channel with a user
113
- */
114
- async function createDM(userId) {
115
- return discordRequest('POST', '/users/@me/channels', {
116
- recipient_id: userId
117
- });
118
- }
119
-
120
- /**
121
- * Send DM to user
122
- */
123
- async function sendDM(userId, content, options = {}) {
124
- // Create DM channel first
125
- const dmChannel = await createDM(userId);
126
- return sendMessage(dmChannel.id, content, options);
127
- }
128
-
129
- /**
130
- * Process Discord message into standardized format
131
- */
132
- function processMessage(message) {
133
- const author = message.author;
134
- const channel = message.channel_id;
135
-
136
- // Skip bot messages
137
- if (author.bot) return null;
138
-
139
- return {
140
- id: `discord:${message.id}`,
141
- channel: 'discord',
142
- type: message.guild_id ? 'channel' : 'dm',
143
- from: {
144
- id: author.id,
145
- handle: author.username,
146
- name: author.global_name || author.username,
147
- discriminator: author.discriminator
148
- },
149
- content: message.content || '[embed/media]',
150
- timestamp: message.timestamp,
151
- channelId: channel,
152
- guildId: message.guild_id || null,
153
- mentions: message.mentions || [],
154
- embeds: message.embeds || [],
155
- attachments: message.attachments || [],
156
- raw: message
157
- };
158
- }
159
-
160
- /**
161
- * Parse /vibe commands from Discord messages
162
- */
163
- function parseVibeCommand(content) {
164
- const trimmed = content.trim();
165
-
166
- // !status mood [note]
167
- const statusMatch = trimmed.match(/^!status\s+(\w+)(?:\s+(.+))?$/);
168
- if (statusMatch) {
169
- return {
170
- command: 'status',
171
- params: {
172
- mood: statusMatch[1],
173
- note: statusMatch[2] || null
174
- }
175
- };
176
- }
177
-
178
- // !who
179
- if (trimmed === '!who') {
180
- return { command: 'who' };
181
- }
182
-
183
- // !ship [message]
184
- const shipMatch = trimmed.match(/^!ship(?:\s+(.+))?$/);
185
- if (shipMatch) {
186
- return {
187
- command: 'ship',
188
- params: {
189
- message: shipMatch[1] || null
190
- }
191
- };
192
- }
193
-
194
- // !dm @user message
195
- const dmMatch = trimmed.match(/^!dm\s+<@!?(\d+)>\s+(.+)$/);
196
- if (dmMatch) {
197
- return {
198
- command: 'dm',
199
- params: {
200
- userId: dmMatch[1],
201
- message: dmMatch[2]
202
- }
203
- };
204
- }
205
-
206
- // !vibe message (forward to /vibe)
207
- const vibeMatch = trimmed.match(/^!vibe\s+(.+)$/);
208
- if (vibeMatch) {
209
- return {
210
- command: 'vibe',
211
- params: {
212
- message: vibeMatch[1]
213
- }
214
- };
215
- }
216
-
217
- return null;
218
- }
219
-
220
- /**
221
- * Send /vibe activity notification to Discord
222
- */
223
- async function notifyActivity(channelId, activity) {
224
- const { handle, action, context } = activity;
225
-
226
- const embed = {
227
- color: 0x6B8FFF, // /vibe blue
228
- description: `🔔 **@${handle}** ${action}`,
229
- footer: { text: context || 'slashvibe.dev' },
230
- timestamp: new Date().toISOString()
231
- };
232
-
233
- return sendMessage(channelId, '', { embeds: [embed] });
234
- }
235
-
236
- /**
237
- * Send /vibe status update to Discord
238
- */
239
- async function notifyStatus(channelId, handle, mood, note) {
240
- const moodEmoji = {
241
- 'shipping': '🔥',
242
- 'debugging': '🐛',
243
- 'deep': '🧠',
244
- 'afk': '☕',
245
- 'celebrating': '🎉',
246
- 'pairing': '👯'
247
- };
248
-
249
- const emoji = moodEmoji[mood] || '●';
250
- let description = `${emoji} **@${handle}** is ${mood}`;
251
-
252
- if (note) {
253
- description += `\n_"${note}"_`;
254
- }
255
-
256
- const embed = {
257
- color: 0x9B59B6, // Purple for status
258
- description,
259
- timestamp: new Date().toISOString()
260
- };
261
-
262
- return sendMessage(channelId, '', { embeds: [embed] });
263
- }
264
-
265
- /**
266
- * Forward message from /vibe to Discord
267
- */
268
- async function forwardFromVibe(channelId, handle, message, context = null) {
269
- const embed = {
270
- color: 0x2ECC71, // Green for /vibe messages
271
- author: {
272
- name: `@${handle}`,
273
- icon_url: 'https://slashvibe.dev/vibe-icon.png'
274
- },
275
- description: message,
276
- footer: { text: context || '/vibe' },
277
- timestamp: new Date().toISOString()
278
- };
279
-
280
- return sendMessage(channelId, '', { embeds: [embed] });
281
- }
282
-
283
- /**
284
- * Create embed for /vibe announcements
285
- */
286
- function createVibeEmbed(title, description, color = 0x6B8FFF, fields = []) {
287
- return {
288
- color,
289
- title,
290
- description,
291
- fields,
292
- footer: {
293
- text: 'slashvibe.dev',
294
- icon_url: 'https://slashvibe.dev/vibe-icon.png'
295
- },
296
- timestamp: new Date().toISOString()
297
- };
298
- }
299
-
300
- /**
301
- * Send who's online list to Discord
302
- */
303
- async function sendOnlineList(channelId, users) {
304
- if (users.length === 0) {
305
- const embed = createVibeEmbed(
306
- '🤫 Room is quiet...',
307
- 'No one is currently active in /vibe.'
308
- );
309
- return sendMessage(channelId, '', { embeds: [embed] });
310
- }
311
-
312
- const fields = users.map(u => {
313
- const mood = u.mood ? ` (${u.mood})` : '';
314
- return {
315
- name: `@${u.handle}${mood}`,
316
- value: u.one_liner || 'building',
317
- inline: true
318
- };
319
- });
320
-
321
- const embed = createVibeEmbed(
322
- `👥 ${users.length} online in /vibe`,
323
- 'Current activity:',
324
- 0x2ECC71,
325
- fields
326
- );
327
-
328
- return sendMessage(channelId, '', { embeds: [embed] });
329
- }
330
-
331
- /**
332
- * Handle Discord slash commands
333
- */
334
- async function registerSlashCommands(guildId = null) {
335
- const commands = [
336
- {
337
- name: 'vibe',
338
- description: 'Send message to /vibe',
339
- options: [
340
- {
341
- name: 'message',
342
- description: 'Message to send',
343
- type: 3, // STRING
344
- required: true
345
- }
346
- ]
347
- },
348
- {
349
- name: 'status',
350
- description: 'Update your /vibe status',
351
- options: [
352
- {
353
- name: 'mood',
354
- description: 'Your current mood/activity',
355
- type: 3, // STRING
356
- required: true,
357
- choices: [
358
- { name: '🔥 shipping', value: 'shipping' },
359
- { name: '🐛 debugging', value: 'debugging' },
360
- { name: '🧠 deep work', value: 'deep' },
361
- { name: '☕ away', value: 'afk' },
362
- { name: '🎉 celebrating', value: 'celebrating' },
363
- { name: '👯 pairing', value: 'pairing' }
364
- ]
365
- },
366
- {
367
- name: 'note',
368
- description: 'Optional note about what you\'re working on',
369
- type: 3, // STRING
370
- required: false
371
- }
372
- ]
373
- },
374
- {
375
- name: 'who',
376
- description: 'See who\'s online in /vibe'
377
- }
378
- ];
379
-
380
- const endpoint = guildId
381
- ? `/applications/@me/guilds/${guildId}/commands`
382
- : '/applications/@me/commands';
383
-
384
- // Register each command
385
- for (const command of commands) {
386
- await discordRequest('POST', endpoint, command);
387
- }
388
-
389
- return commands.length;
390
- }
391
-
392
- /**
393
- * Set up Discord bot webhook for receiving interactions
394
- */
395
- async function setupInteractionEndpoint(publicKey, endpointUrl) {
396
- // This would typically be done in Discord Developer Portal
397
- // But we can validate the setup here
398
-
399
- if (!publicKey || !endpointUrl) {
400
- throw new Error('Need both public key and endpoint URL for interactions');
401
- }
402
-
403
- // The actual webhook setup happens in Discord Developer Portal
404
- return {
405
- message: 'Interaction endpoint configured. Set this URL in Discord Developer Portal:',
406
- url: endpointUrl,
407
- publicKey: publicKey
408
- };
409
- }
410
-
411
- module.exports = {
412
- isConfigured,
413
- getBotToken,
414
- getGuildId,
415
- getBotInfo,
416
- getGuilds,
417
- getChannels,
418
- getMessages,
419
- sendMessage,
420
- sendDM,
421
- createDM,
422
- processMessage,
423
- parseVibeCommand,
424
- notifyActivity,
425
- notifyStatus,
426
- forwardFromVibe,
427
- sendOnlineList,
428
- createVibeEmbed,
429
- registerSlashCommands,
430
- setupInteractionEndpoint
431
- };
@@ -1,299 +0,0 @@
1
- /**
2
- * /vibe Farcaster Bridge
3
- *
4
- * Connects /vibe to Farcaster via Neynar API for web3 social integration.
5
- * - Read: Casts, mentions, replies
6
- * - Write: Casts, replies
7
- * - Channel integration: Post to specific channels
8
- */
9
-
10
- const config = require('../config');
11
-
12
- /**
13
- * Get Farcaster credentials from config
14
- */
15
- function getCredentials() {
16
- const cfg = config.load();
17
- return {
18
- apiKey: cfg.neynar_api_key || process.env.NEYNAR_API_KEY || null,
19
- signerUuid: cfg.farcaster_signer_uuid || process.env.FARCASTER_SIGNER_UUID || null,
20
- fid: cfg.farcaster_fid || process.env.FARCASTER_FID || null
21
- };
22
- }
23
-
24
- /**
25
- * Check if Farcaster bridge is configured
26
- */
27
- function isConfigured() {
28
- const creds = getCredentials();
29
- return !!(creds.apiKey && creds.signerUuid && creds.fid);
30
- }
31
-
32
- /**
33
- * Make authenticated request to Neynar API
34
- */
35
- async function neynarRequest(method, endpoint, params = {}, body = null) {
36
- const { apiKey } = getCredentials();
37
- if (!apiKey) throw new Error('Neynar API key not configured');
38
-
39
- const baseUrl = 'https://api.neynar.com/v2';
40
- let url = `${baseUrl}${endpoint}`;
41
-
42
- const headers = {
43
- 'accept': 'application/json',
44
- 'api_key': apiKey
45
- };
46
-
47
- // GET requests: params in URL
48
- if (method === 'GET' && Object.keys(params).length > 0) {
49
- url += '?' + new URLSearchParams(params);
50
- }
51
-
52
- // POST/PUT requests: body as JSON
53
- if (body && (method === 'POST' || method === 'PUT')) {
54
- headers['content-type'] = 'application/json';
55
- }
56
-
57
- const response = await fetch(url, {
58
- method,
59
- headers,
60
- body: body ? JSON.stringify(body) : undefined
61
- });
62
-
63
- if (!response.ok) {
64
- const error = await response.text();
65
- throw new Error(`Neynar API error ${response.status}: ${error}`);
66
- }
67
-
68
- return response.json();
69
- }
70
-
71
- /**
72
- * Get user info by FID
73
- */
74
- async function getUser(fid = null) {
75
- const { fid: defaultFid } = getCredentials();
76
- const targetFid = fid || defaultFid;
77
-
78
- if (!targetFid) throw new Error('No FID specified');
79
-
80
- return neynarRequest('GET', '/farcaster/user/bulk', {
81
- fids: targetFid.toString()
82
- });
83
- }
84
-
85
- /**
86
- * Get casts from user's feed
87
- */
88
- async function getFeed(fid = null, limit = 25) {
89
- const { fid: defaultFid } = getCredentials();
90
- const targetFid = fid || defaultFid;
91
-
92
- if (!targetFid) throw new Error('No FID specified');
93
-
94
- return neynarRequest('GET', '/farcaster/feed/user', {
95
- fid: targetFid.toString(),
96
- limit: limit.toString()
97
- });
98
- }
99
-
100
- /**
101
- * Get mentions for user
102
- */
103
- async function getMentions(fid = null, limit = 25) {
104
- const { fid: defaultFid } = getCredentials();
105
- const targetFid = fid || defaultFid;
106
-
107
- if (!targetFid) throw new Error('No FID specified');
108
-
109
- return neynarRequest('GET', '/farcaster/notifications', {
110
- fid: targetFid.toString(),
111
- type: 'mentions',
112
- limit: limit.toString()
113
- });
114
- }
115
-
116
- /**
117
- * Get cast by hash
118
- */
119
- async function getCast(castHash) {
120
- return neynarRequest('GET', '/farcaster/cast', {
121
- identifier: castHash,
122
- type: 'hash'
123
- });
124
- }
125
-
126
- /**
127
- * Publish a cast
128
- */
129
- async function publishCast(text, options = {}) {
130
- const { signerUuid } = getCredentials();
131
- if (!signerUuid) throw new Error('Signer UUID not configured');
132
-
133
- const body = {
134
- signer_uuid: signerUuid,
135
- text
136
- };
137
-
138
- // Reply to another cast
139
- if (options.replyTo) {
140
- body.parent = options.replyTo;
141
- }
142
-
143
- // Post to specific channel
144
- if (options.channel) {
145
- body.channel_id = options.channel;
146
- }
147
-
148
- // Add embeds (links, images)
149
- if (options.embeds && options.embeds.length > 0) {
150
- body.embeds = options.embeds;
151
- }
152
-
153
- return neynarRequest('POST', '/farcaster/cast', {}, body);
154
- }
155
-
156
- /**
157
- * React to a cast (like/recast)
158
- */
159
- async function reactToCast(castHash, reaction = 'like') {
160
- const { signerUuid } = getCredentials();
161
- if (!signerUuid) throw new Error('Signer UUID not configured');
162
-
163
- const body = {
164
- signer_uuid: signerUuid,
165
- target: castHash,
166
- reaction_type: reaction // 'like' or 'recast'
167
- };
168
-
169
- return neynarRequest('POST', '/farcaster/reaction', {}, body);
170
- }
171
-
172
- /**
173
- * Follow a user
174
- */
175
- async function followUser(targetFid) {
176
- const { signerUuid } = getCredentials();
177
- if (!signerUuid) throw new Error('Signer UUID not configured');
178
-
179
- const body = {
180
- signer_uuid: signerUuid,
181
- target_fids: [parseInt(targetFid)]
182
- };
183
-
184
- return neynarRequest('POST', '/farcaster/follows', {}, body);
185
- }
186
-
187
- /**
188
- * Get trending casts in a channel
189
- */
190
- async function getChannelFeed(channelId, limit = 25) {
191
- return neynarRequest('GET', '/farcaster/feed/channels', {
192
- channel_ids: channelId,
193
- limit: limit.toString()
194
- });
195
- }
196
-
197
- /**
198
- * Search for casts
199
- */
200
- async function searchCasts(query, limit = 25) {
201
- return neynarRequest('GET', '/farcaster/cast/search', {
202
- q: query,
203
- limit: limit.toString()
204
- });
205
- }
206
-
207
- /**
208
- * Get user's followers
209
- */
210
- async function getFollowers(fid = null, limit = 100) {
211
- const { fid: defaultFid } = getCredentials();
212
- const targetFid = fid || defaultFid;
213
-
214
- if (!targetFid) throw new Error('No FID specified');
215
-
216
- return neynarRequest('GET', '/farcaster/followers', {
217
- fid: targetFid.toString(),
218
- limit: limit.toString()
219
- });
220
- }
221
-
222
- /**
223
- * Get user's following
224
- */
225
- async function getFollowing(fid = null, limit = 100) {
226
- const { fid: defaultFid } = getCredentials();
227
- const targetFid = fid || defaultFid;
228
-
229
- if (!targetFid) throw new Error('No FID specified');
230
-
231
- return neynarRequest('GET', '/farcaster/following', {
232
- fid: targetFid.toString(),
233
- limit: limit.toString()
234
- });
235
- }
236
-
237
- /**
238
- * Process cast data into standardized format for /vibe
239
- */
240
- function processCast(cast) {
241
- const author = cast.author;
242
-
243
- return {
244
- id: `farcaster:${cast.hash}`,
245
- channel: 'farcaster',
246
- type: 'cast',
247
- from: {
248
- id: author.fid.toString(),
249
- handle: author.username,
250
- name: author.display_name || author.username
251
- },
252
- content: cast.text || '[media]',
253
- timestamp: cast.timestamp,
254
- hash: cast.hash,
255
- replies: cast.replies?.count || 0,
256
- reactions: cast.reactions?.likes_count || 0,
257
- recasts: cast.reactions?.recasts_count || 0,
258
- channel_id: cast.channel?.id || null,
259
- parent_hash: cast.parent_hash || null,
260
- embeds: cast.embeds || [],
261
- raw: cast
262
- };
263
- }
264
-
265
- /**
266
- * Get relevant channels for /vibe users
267
- */
268
- function getRecommendedChannels() {
269
- return [
270
- { id: 'dev', name: 'Development' },
271
- { id: 'builders', name: 'Builders' },
272
- { id: 'startups', name: 'Startups' },
273
- { id: 'crypto-dev', name: 'Crypto Development' },
274
- { id: 'base', name: 'Base' },
275
- { id: 'ethereum', name: 'Ethereum' },
276
- { id: 'farcaster', name: 'Farcaster' },
277
- { id: 'design', name: 'Design' },
278
- { id: 'product', name: 'Product' },
279
- { id: 'ai', name: 'AI' }
280
- ];
281
- }
282
-
283
- module.exports = {
284
- isConfigured,
285
- getCredentials,
286
- getUser,
287
- getFeed,
288
- getMentions,
289
- getCast,
290
- publishCast,
291
- reactToCast,
292
- followUser,
293
- getChannelFeed,
294
- searchCasts,
295
- getFollowers,
296
- getFollowing,
297
- processCast,
298
- getRecommendedChannels
299
- };