@elizaos/plugin-farcaster 1.0.2 → 1.7.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 (64) hide show
  1. package/README.md +203 -43
  2. package/dist/__tests__/e2e/scenarios.d.ts +4 -0
  3. package/dist/__tests__/e2e/scenarios.d.ts.map +1 -0
  4. package/dist/__tests__/suite.d.ts +117 -0
  5. package/dist/__tests__/suite.d.ts.map +1 -0
  6. package/dist/__tests__/test-utils.d.ts +29 -0
  7. package/dist/__tests__/test-utils.d.ts.map +1 -0
  8. package/dist/__tests__/types.d.ts +88 -0
  9. package/dist/__tests__/types.d.ts.map +1 -0
  10. package/dist/actions/index.d.ts +4 -0
  11. package/dist/actions/index.d.ts.map +1 -0
  12. package/dist/actions/replyCast.d.ts +3 -0
  13. package/dist/actions/replyCast.d.ts.map +1 -0
  14. package/dist/actions/sendCast.d.ts +3 -0
  15. package/dist/actions/sendCast.d.ts.map +1 -0
  16. package/dist/client.d.ts +26 -0
  17. package/dist/client.d.ts.map +1 -0
  18. package/dist/common/asyncqueue.d.ts +13 -0
  19. package/dist/common/asyncqueue.d.ts.map +1 -0
  20. package/dist/common/callbacks.d.ts +14 -0
  21. package/dist/common/callbacks.d.ts.map +1 -0
  22. package/dist/common/config.d.ts +15 -0
  23. package/dist/common/config.d.ts.map +1 -0
  24. package/dist/common/constants.d.ts +9 -0
  25. package/dist/common/constants.d.ts.map +1 -0
  26. package/dist/common/prompts.d.ts +5 -0
  27. package/dist/common/prompts.d.ts.map +1 -0
  28. package/dist/common/types.d.ts +80 -0
  29. package/dist/common/types.d.ts.map +1 -0
  30. package/dist/common/utils.d.ts +24 -0
  31. package/dist/common/utils.d.ts.map +1 -0
  32. package/dist/events/messageHandler.d.ts +29 -0
  33. package/dist/events/messageHandler.d.ts.map +1 -0
  34. package/dist/index.d.ts +7 -90
  35. package/dist/index.d.ts.map +1 -0
  36. package/dist/index.js +1896 -522
  37. package/dist/index.js.map +35 -1
  38. package/dist/managers/agent.d.ts +21 -0
  39. package/dist/managers/agent.d.ts.map +1 -0
  40. package/dist/managers/interaction-processor.d.ts +12 -0
  41. package/dist/managers/interaction-processor.d.ts.map +1 -0
  42. package/dist/managers/interaction-source.d.ts +50 -0
  43. package/dist/managers/interaction-source.d.ts.map +1 -0
  44. package/dist/managers/interactions.d.ts +49 -0
  45. package/dist/managers/interactions.d.ts.map +1 -0
  46. package/dist/managers/post.d.ts +24 -0
  47. package/dist/managers/post.d.ts.map +1 -0
  48. package/dist/providers/index.d.ts +5 -0
  49. package/dist/providers/index.d.ts.map +1 -0
  50. package/dist/providers/profileProvider.d.ts +3 -0
  51. package/dist/providers/profileProvider.d.ts.map +1 -0
  52. package/dist/providers/threadProvider.d.ts +3 -0
  53. package/dist/providers/threadProvider.d.ts.map +1 -0
  54. package/dist/providers/timelineProvider.d.ts +3 -0
  55. package/dist/providers/timelineProvider.d.ts.map +1 -0
  56. package/dist/routes/webhook.d.ts +3 -0
  57. package/dist/routes/webhook.d.ts.map +1 -0
  58. package/dist/service.d.ts +31 -0
  59. package/dist/service.d.ts.map +1 -0
  60. package/dist/services/CastService.d.ts +142 -0
  61. package/dist/services/CastService.d.ts.map +1 -0
  62. package/dist/services/MessageService.d.ts +50 -0
  63. package/dist/services/MessageService.d.ts.map +1 -0
  64. package/package.json +10 -9
package/README.md CHANGED
@@ -1,26 +1,41 @@
1
1
  # ElizaOS Farcaster Plugin
2
2
 
3
- A plugin for ElizaOS that enables agent integration with the Farcaster social network.
3
+ A comprehensive plugin for ElizaOS that enables AI agents to fully participate in the Farcaster social network with posting, replying, and engagement capabilities.
4
4
 
5
5
  ## Overview
6
6
 
7
- The ElizaOS Farcaster Plugin allows AI agents to interact with the Farcaster social network by:
7
+ The ElizaOS Farcaster Plugin provides a complete integration with Farcaster, allowing AI agents to:
8
8
 
9
- - Publishing original casts (posts)
10
- - Responding to mentions and replies
11
- - Interacting with other users' content
12
- - Processing user engagement automatically
9
+ - **Post & Reply**: Create original casts and reply to conversations
10
+ - **Monitor Mentions**: Track and respond to mentions automatically
11
+ - **Engage with Content**: Like, recast, and interact with other users' posts
12
+ - **Context-Aware Responses**: Maintain conversation threads and context
13
+ - **Real-time Interaction**: Process interactions in real-time with configurable intervals
13
14
 
14
- This plugin leverages the [Neynar API](https://neynar.com) to interact with Farcaster, providing a robust integration between ElizaOS agents and the Farcaster social graph.
15
+ This plugin leverages the [Neynar API](https://neynar.com) and implements full ElizaOS service interfaces for seamless integration.
15
16
 
16
17
  ## Features
17
18
 
18
- - **Automated Posting**: Schedule and publish regular casts with configurable intervals
19
- - **Engagement Monitoring**: Track mentions, replies, and interactions
20
- - **Conversation Threading**: Build and maintain conversation context for natural interactions
21
- - **Dry Run Mode**: Test functionality without actually posting to Farcaster
22
- - **Configurable Settings**: Customize behavior via environment variables
23
- - **Caching**: Efficient caching of profiles and casts for improved performance
19
+ ### Core Services
20
+ - **FarcasterService**: Main service managing agent connections and lifecycle
21
+ - **MessageService**: Implements `IMessageService` for sending/receiving messages
22
+ - **CastService**: Implements `IPostService` for creating and managing casts
23
+
24
+ ### Actions
25
+ - **SEND_CAST**: Post casts based on user requests
26
+ - **REPLY_TO_CAST**: Reply to existing casts with context
27
+
28
+ ### Providers
29
+ - **farcasterProfile**: Provides agent's Farcaster profile information
30
+ - **farcasterTimeline**: Supplies recent timeline casts for context
31
+
32
+ ### Additional Features
33
+ - **Automated Posting**: Schedule and publish regular casts
34
+ - **Engagement Monitoring**: Track mentions and interactions
35
+ - **Conversation Threading**: Maintain conversation context
36
+ - **Metadata Tracking**: Store cast metadata for reference
37
+ - **Health Monitoring**: Built-in health check functionality
38
+ - **Caching**: Efficient caching for improved performance
24
39
 
25
40
  ## Installation
26
41
 
@@ -28,6 +43,75 @@ This plugin leverages the [Neynar API](https://neynar.com) to interact with Farc
28
43
  npm install @elizaos/plugin-farcaster
29
44
  ```
30
45
 
46
+ ## Setup
47
+
48
+ ### 1. Get Farcaster Credentials
49
+
50
+ 1. **Create a Farcaster Account**: If you don't have one, sign up at [Warpcast](https://warpcast.com)
51
+ 2. **Note your FID**: Find your Farcaster ID in your profile settings
52
+ 3. **Get Neynar API Access**:
53
+ - Sign up at [Neynar Developer Portal](https://dev.neynar.com/)
54
+ - Create a new application
55
+ - Copy your API key
56
+ 4. **Create a Signer**:
57
+ - In the Neynar dashboard, go to "Signers"
58
+ - Create a new signer for your FID
59
+ - Copy the Signer UUID
60
+
61
+ ### 2. Configure Environment
62
+
63
+ Copy the example environment file and fill in your credentials:
64
+
65
+ ```bash
66
+ cp env.example .env
67
+ ```
68
+
69
+ Edit `.env` with your credentials:
70
+ ```env
71
+ FARCASTER_FID=your-fid-here
72
+ FARCASTER_NEYNAR_API_KEY=your-api-key-here
73
+ FARCASTER_SIGNER_UUID=your-signer-uuid-here
74
+ FARCASTER_MODE=polling # or 'webhook' for real-time processing
75
+ ```
76
+
77
+ ### 3. Webhook Setup (Recommended for Production)
78
+
79
+ For real-time interaction processing instead of polling, you can configure webhooks:
80
+
81
+ #### Step 1: Set Environment Variable
82
+ ```env
83
+ FARCASTER_MODE=webhook
84
+ ```
85
+
86
+ #### Step 2: Expose Your Server
87
+ If running locally, use ngrok to expose your server:
88
+ ```bash
89
+ # Install ngrok if you haven't already
90
+ npm install -g ngrok
91
+
92
+ # Expose your local server (default port 3000)
93
+ ngrok http 3000
94
+ ```
95
+
96
+ This will give you a URL like: `https://c7120f641530.ngrok-free.app`
97
+
98
+ #### Step 3: Configure Neynar Webhook
99
+ 1. Go to [Neynar Webhook Dashboard](https://dev.neynar.com/webhook)
100
+ 2. Click "New webhook"
101
+ 3. Set the **Target URL** to: `https://your-ngrok-url.ngrok-free.app/farcaster/webhook`
102
+ - Example: `https://c7120f641530.ngrok-free.app/farcaster/webhook`
103
+ 4. Configure **Event Types**:
104
+ - Select `cast.created`
105
+ 5. Set **Filters**:
106
+ - **Mentioned users**: Add your Farcaster username
107
+ - **Parent cast authors**: Add your Farcaster username
108
+
109
+
110
+ #### Step 4: Test Webhook
111
+ Once configured, your agent will receive real-time notifications when:
112
+ - Someone mentions your agent
113
+ - Someone replies to your agent's casts
114
+
31
115
  ## Configuration
32
116
 
33
117
  The plugin requires the following configurations, which can be set via environment variables or ElizaOS runtime settings:
@@ -37,8 +121,9 @@ The plugin requires the following configurations, which can be set via environme
37
121
  | Parameter | Description |
38
122
  | ------------------------------ | -------------------------------------- |
39
123
  | `FARCASTER_NEYNAR_API_KEY` | Neynar API key for accessing Farcaster |
40
- | `FARCASTER_NEYNAR_SIGNER_UUID` | Signer UUID for your Farcaster account |
124
+ | `FARCASTER_SIGNER_UUID` | Signer UUID for your Farcaster account |
41
125
  | `FARCASTER_FID` | Your Farcaster FID (identifier) |
126
+ | `FARCASTER_MODE` | Interaction mode: `polling` or `webhook` |
42
127
 
43
128
  ### Optional Settings
44
129
 
@@ -47,33 +132,67 @@ The plugin requires the following configurations, which can be set via environme
47
132
  | `FARCASTER_DRY_RUN` | Run in simulation mode without posting (true/false) | false |
48
133
  | `MAX_CAST_LENGTH` | Maximum length of casts | 320 |
49
134
  | `FARCASTER_POLL_INTERVAL` | Interval for checking mentions (minutes) | 2 |
50
- | `ENABLE_POST` | Enable automatic posting (true/false) | true |
51
- | `POST_INTERVAL_MIN` | Minimum time between posts (minutes) | 90 |
52
- | `POST_INTERVAL_MAX` | Maximum time between posts (minutes) | 180 |
135
+ | `ENABLE_CAST` | Enable automatic casting (true/false) | true |
136
+ | `CAST_INTERVAL_MIN` | Minimum time between casts (minutes) | 90 |
137
+ | `CAST_INTERVAL_MAX` | Maximum time between casts (minutes) | 180 |
53
138
  | `ENABLE_ACTION_PROCESSING` | Enable processing interactions (true/false) | false |
54
139
  | `ACTION_INTERVAL` | Interval for processing actions (minutes) | 5 |
55
- | `POST_IMMEDIATELY` | Post immediately on startup (true/false) | false |
140
+ | `CAST_IMMEDIATELY` | Cast immediately on startup (true/false) | false |
56
141
  | `MAX_ACTIONS_PROCESSING` | Maximum actions to process in one cycle | 1 |
57
142
  | `ACTION_TIMELINE_TYPE` | Type of timeline to use for actions | ForYou |
58
143
 
59
144
  ## Usage
60
145
 
61
- ### Basic Integration with ElizaOS
146
+ ### Basic Integration
147
+
148
+ 1. **In your agent's character file**:
149
+
150
+ ```json
151
+ {
152
+ "name": "MyFarcasterAgent",
153
+ "bio": "An AI agent on Farcaster",
154
+ "plugins": ["@elizaos/plugin-farcaster"],
155
+ "settings": {
156
+ "FARCASTER_FID": "123456",
157
+ "FARCASTER_NEYNAR_API_KEY": "your-api-key",
158
+ "FARCASTER_SIGNER_UUID": "your-signer-uuid",
159
+ "FARCASTER_MODE": "webhook"
160
+ }
161
+ }
162
+ ```
62
163
 
63
- ```typescript
64
- import { ElizaOS } from '@elizaos/core';
65
- import farcasterPlugin from '@elizaos-plugins/client-farcaster';
164
+ 2. **Start your agent**:
66
165
 
67
- // Initialize ElizaOS
68
- const elizaOs = new ElizaOS({
69
- // ElizaOS configuration
70
- });
166
+ ```bash
167
+ elizaos start --character path/to/character.json
168
+ ```
169
+
170
+ ### Using Actions
171
+
172
+ The plugin provides actions that can be triggered through natural language:
173
+
174
+ ```
175
+ User: "Can you post about the new ElizaOS features on Farcaster?"
176
+ Agent: "I'll post about the new ElizaOS features on Farcaster now."
177
+ [Agent posts to Farcaster]
178
+
179
+ User: "Reply to that cast and thank them for the feedback"
180
+ Agent: "I'll reply with a thank you message."
181
+ [Agent replies to the cast]
182
+ ```
71
183
 
72
- // Register the Farcaster plugin
73
- elizaOs.registerPlugin(farcasterPlugin);
184
+ ### Programmatic Usage
74
185
 
75
- // Start ElizaOS
76
- elizaOs.start();
186
+ ```typescript
187
+ import farcasterPlugin from '@elizaos/plugin-farcaster';
188
+
189
+ // The plugin exports its components
190
+ const { actions, providers, services } = farcasterPlugin;
191
+
192
+ // Access specific services programmatically
193
+ const farcasterService = runtime.getService('farcaster');
194
+ const messageService = farcasterService.getMessageService(agentId);
195
+ const castService = farcasterService.getCastService(agentId);
77
196
  ```
78
197
 
79
198
  ### Customizing Cast Templates
@@ -123,28 +242,69 @@ npm run dev
123
242
 
124
243
  ## Architecture
125
244
 
126
- The client is organized into several core components:
245
+ The plugin is organized into several core components:
127
246
 
128
- - **FarcasterClient**: Base client for interacting with the Farcaster network via Neynar
129
- - **FarcasterPostManager**: Manages autonomous posting schedule and generation
130
- - **FarcasterInteractionManager**: Handles mentions, replies, and other interactions
131
- - **Memory Management**: Stores conversation context and history
247
+ ### Services
248
+ - **FarcasterService**: Main service managing agent lifecycle and health monitoring
249
+ - **MessageService**: Handles sending/receiving messages, implements `IMessageService`
250
+ - **CastService**: Manages casts and interactions, implements `IPostService`
132
251
 
133
- ## Dependencies
252
+ ### Managers
253
+ - **FarcasterClient**: Base client for Neynar API interactions
254
+ - **FarcasterAgentManager**: Manages agent-specific connections
255
+ - **FarcasterInteractionManager**: Handles mentions and replies
256
+ - **FarcasterCastManager**: Manages autonomous casting
134
257
 
135
- - [@neynar/nodejs-sdk](https://www.npmjs.com/package/@neynar/nodejs-sdk): Official SDK for Neynar API
136
- - [@elizaos/core](https://www.npmjs.com/package/@elizaos/core): ElizaOS core framework
258
+ ### Components
259
+ - **Actions**: User-triggered capabilities (SEND_CAST, REPLY_TO_CAST)
260
+ - **Providers**: Context providers for agent awareness
261
+ - **Event Handlers**: Metadata tracking and event processing
137
262
 
138
263
  ## Testing
139
264
 
140
- The client includes comprehensive tests for:
265
+ The plugin includes comprehensive test coverage:
266
+
267
+ ### Unit Tests
268
+ Located in `__tests__/unit/`:
269
+ - Service functionality tests
270
+ - Action validation tests
271
+ - Provider output tests
141
272
 
142
- - Cast creation and management
143
- - Interaction handling
144
- - Timeline processing
273
+ ### E2E Tests
274
+ Located in `__tests__/e2e/`:
275
+ - Real account interactions
276
+ - Full conversation flows
277
+ - Error handling scenarios
145
278
 
146
- Run the tests with:
279
+ ### Running Tests
147
280
 
148
281
  ```bash
282
+ # Run all tests
149
283
  npm test
284
+
285
+ # Run unit tests only
286
+ npm run test:unit
287
+
288
+ # Run E2E tests (requires API keys)
289
+ npm run test:e2e
290
+
291
+ # Run with coverage
292
+ npm run test:coverage
150
293
  ```
294
+
295
+ For E2E tests, ensure your `.env` file contains valid API credentials.
296
+
297
+ ## Dependencies
298
+
299
+ - [@neynar/nodejs-sdk](https://www.npmjs.com/package/@neynar/nodejs-sdk): Official SDK for Neynar API
300
+ - [@elizaos/core](https://www.npmjs.com/package/@elizaos/core): ElizaOS core framework
301
+ - [lru-cache](https://www.npmjs.com/package/lru-cache): Efficient caching
302
+ - [zod](https://www.npmjs.com/package/zod): Schema validation
303
+
304
+ ## Contributing
305
+
306
+ Contributions are welcome! Please ensure all tests pass and add new tests for any new functionality.
307
+
308
+ ## License
309
+
310
+ This plugin is part of the ElizaOS ecosystem and follows the same licensing terms.
@@ -0,0 +1,4 @@
1
+ import { type TestCase } from '@elizaos/core';
2
+ export declare const farcasterE2EScenarios: TestCase[];
3
+ export default farcasterE2EScenarios;
4
+ //# sourceMappingURL=scenarios.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scenarios.d.ts","sourceRoot":"","sources":["../../../src/__tests__/e2e/scenarios.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgD,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAM5F,eAAO,MAAM,qBAAqB,EAAE,QAAQ,EAmV3C,CAAC;AAGF,eAAe,qBAAqB,CAAC"}
@@ -0,0 +1,117 @@
1
+ import { type IAgentRuntime, type TestSuite, type TestCase } from '@elizaos/core';
2
+ /**
3
+ * Represents a Test Suite for Farcaster functionality.
4
+ * This class implements the TestSuite interface.
5
+ * It contains various test cases related to Farcaster operations such as initializing the client,
6
+ * fetching profile, fetching casts, posting casts, and handling cast interactions.
7
+ */
8
+ export declare class FarcasterTestSuite implements TestSuite {
9
+ name: string;
10
+ description: string;
11
+ private manager;
12
+ tests: TestCase[];
13
+ /**
14
+ * Constructor for TestSuite class.
15
+ * Initializes an array of test functions to be executed.
16
+ */
17
+ constructor();
18
+ /**
19
+ * Test that checks if Farcaster is properly configured
20
+ */
21
+ testMockConfiguration(runtime: IAgentRuntime): Promise<void>;
22
+ /**
23
+ * Test service initialization without real credentials
24
+ */
25
+ testMockServiceInit(runtime: IAgentRuntime): Promise<void>;
26
+ /**
27
+ * Asynchronously initializes the Farcaster client for the provided agent runtime.
28
+ *
29
+ * @param {IAgentRuntime} runtime - The agent runtime to use for initializing the Farcaster client.
30
+ * @throws {Error} If the Farcaster client manager is not found or if the Farcaster client fails to initialize.
31
+ */
32
+ testInitializingClient(runtime: IAgentRuntime): Promise<void>;
33
+ /**
34
+ * Asynchronously fetches the profile of a user from Farcaster using the given runtime.
35
+ *
36
+ * @param {IAgentRuntime} runtime The runtime to use for fetching the profile.
37
+ * @returns {Promise<void>} A Promise that resolves when the profile is successfully fetched, or rejects with an error.
38
+ */
39
+ testFetchProfile(runtime: IAgentRuntime): Promise<void>;
40
+ /**
41
+ * Asynchronously fetches the timeline from the Farcaster client.
42
+ *
43
+ * @param {IAgentRuntime} runtime - The agent runtime object.
44
+ * @throws {Error} If there are no casts in the timeline.
45
+ * @throws {Error} If an error occurs while fetching the timeline.
46
+ */
47
+ testFetchTimeline(runtime: IAgentRuntime): Promise<void>;
48
+ /**
49
+ * Asynchronously posts a test cast using the Farcaster API.
50
+ *
51
+ * @param {IAgentRuntime} runtime - The agent runtime object.
52
+ * @returns {Promise<void>} A Promise that resolves when the cast is successfully posted.
53
+ * @throws {Error} If there is an error posting the cast.
54
+ */
55
+ testPostCast(runtime: IAgentRuntime): Promise<void>;
56
+ /**
57
+ * Asynchronously posts an image cast on Farcaster using the provided runtime and cast content.
58
+ * Note: This might need updating based on how images are actually handled in sendCast
59
+ *
60
+ * @param {IAgentRuntime} runtime - The runtime environment for the action.
61
+ * @returns {Promise<void>} A Promise that resolves when the cast is successfully posted.
62
+ * @throws {Error} If there is an error posting the cast.
63
+ */
64
+ testPostImageCast(runtime: IAgentRuntime): Promise<void>;
65
+ /**
66
+ * Asynchronously handles a fake cast response using the given runtime.
67
+ *
68
+ * @param {IAgentRuntime} runtime - The runtime object for the agent
69
+ * @returns {Promise<void>} - A promise that resolves when the cast response is handled
70
+ * @throws {Error} - If there is an error handling the cast response
71
+ */
72
+ testHandleCastResponse(runtime: IAgentRuntime): Promise<void>;
73
+ /**
74
+ * Generates random content for a cast based on the given context.
75
+ *
76
+ * @param {IAgentRuntime} runtime - The runtime environment.
77
+ * @param {string} context - Optional context for the content generation.
78
+ * @returns {Promise<string>} A promise that resolves to the generated cast content.
79
+ */
80
+ private generateRandomCastContent;
81
+ /**
82
+ * Tests the MessageService functionality
83
+ *
84
+ * @param {IAgentRuntime} runtime - The runtime environment.
85
+ * @returns {Promise<void>} A promise that resolves when the test is complete.
86
+ */
87
+ testMessageService(runtime: IAgentRuntime): Promise<void>;
88
+ /**
89
+ * Tests the PostService functionality
90
+ *
91
+ * @param {IAgentRuntime} runtime - The runtime environment.
92
+ * @returns {Promise<void>} A promise that resolves when the test is complete.
93
+ */
94
+ testPostService(runtime: IAgentRuntime): Promise<void>;
95
+ /**
96
+ * Tests real account posting functionality
97
+ *
98
+ * @param {IAgentRuntime} runtime - The runtime environment.
99
+ * @returns {Promise<void>} A promise that resolves when the test is complete.
100
+ */
101
+ testRealAccountPosting(runtime: IAgentRuntime): Promise<void>;
102
+ /**
103
+ * Tests real account interactions (mentions, replies, etc)
104
+ *
105
+ * @param {IAgentRuntime} runtime - The runtime environment.
106
+ * @returns {Promise<void>} A promise that resolves when the test is complete.
107
+ */
108
+ testRealAccountInteractions(runtime: IAgentRuntime): Promise<void>;
109
+ /**
110
+ * Tests message metadata tracking functionality
111
+ *
112
+ * @param {IAgentRuntime} runtime - The runtime environment.
113
+ * @returns {Promise<void>} A promise that resolves when the test is complete.
114
+ */
115
+ testMessageMetadataTracking(runtime: IAgentRuntime): Promise<void>;
116
+ }
117
+ //# sourceMappingURL=suite.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"suite.d.ts","sourceRoot":"","sources":["../../src/__tests__/suite.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAElB,KAAK,SAAS,EAGd,KAAK,QAAQ,EACd,MAAM,eAAe,CAAC;AAOvB;;;;;GAKG;AACH,qBAAa,kBAAmB,YAAW,SAAS;IAClD,IAAI,SAA4B;IAChC,WAAW,SAAmD;IAC9D,OAAO,CAAC,OAAO,CAAsC;IACrD,KAAK,EAAE,QAAQ,EAAE,CAAC;IAElB;;;OAGG;;IAwCH;;OAEG;IACG,qBAAqB,CAAC,OAAO,EAAE,aAAa;IAqBlD;;OAEG;IACG,mBAAmB,CAAC,OAAO,EAAE,aAAa;IA+BhD;;;;;OAKG;IACG,sBAAsB,CAAC,OAAO,EAAE,aAAa;IAmBnD;;;;;OAKG;IACG,gBAAgB,CAAC,OAAO,EAAE,aAAa;IAqB7C;;;;;;OAMG;IACG,iBAAiB,CAAC,OAAO,EAAE,aAAa;IAuB9C;;;;;;OAMG;IACG,YAAY,CAAC,OAAO,EAAE,aAAa;IAoBzC;;;;;;;OAOG;IACG,iBAAiB,CAAC,OAAO,EAAE,aAAa;IAwB9C;;;;;;OAMG;IACG,sBAAsB,CAAC,OAAO,EAAE,aAAa;IA+CnD;;;;;;OAMG;YACW,yBAAyB;IAcvC;;;;;OAKG;IACG,kBAAkB,CAAC,OAAO,EAAE,aAAa;IAuC/C;;;;;OAKG;IACG,eAAe,CAAC,OAAO,EAAE,aAAa;IAsC5C;;;;;OAKG;IACG,sBAAsB,CAAC,OAAO,EAAE,aAAa;IA0CnD;;;;;OAKG;IACG,2BAA2B,CAAC,OAAO,EAAE,aAAa;IAoDxD;;;;;OAKG;IACG,2BAA2B,CAAC,OAAO,EAAE,aAAa;CA4CzD"}
@@ -0,0 +1,29 @@
1
+ import type { FarcasterClient } from '../client';
2
+ import type { Cast, Profile } from '../common/types';
3
+ import type { TestInteraction } from './types';
4
+ export declare function createTestInteraction(cast: Cast, profile: Profile): TestInteraction | null;
5
+ export declare function handleTestInteraction(client: FarcasterClient, interaction: TestInteraction): Promise<{
6
+ success: boolean;
7
+ cast: {
8
+ hash: string;
9
+ text: string;
10
+ parent_hash: string;
11
+ timestamp: string;
12
+ };
13
+ }>;
14
+ export declare function createTestCast(client: FarcasterClient, content: string): Promise<{
15
+ success: boolean;
16
+ cast: NeynarCast;
17
+ }>;
18
+ export declare const TEST_IMAGE_URL = "https://github.com/elizaOS/awesome-eliza/blob/main/assets/eliza-logo.jpg?raw=true";
19
+ export declare const TEST_IMAGE: {
20
+ id: string;
21
+ text: string;
22
+ description: string;
23
+ source: string;
24
+ url: string;
25
+ title: string;
26
+ contentType: string;
27
+ alt_text: string;
28
+ };
29
+ //# sourceMappingURL=test-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-utils.d.ts","sourceRoot":"","sources":["../../src/__tests__/test-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,GAAG,eAAe,GAAG,IAAI,CA+B1F;AAED,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,eAAe,EAAE,WAAW,EAAE,eAAe;;;;;;;;GAuBhG;AAED,wBAAsB,cAAc,CAAC,MAAM,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM;;;GAc5E;AAED,eAAO,MAAM,cAAc,sFAC0D,CAAC;AAEtF,eAAO,MAAM,UAAU;;;;;;;;;CAStB,CAAC"}
@@ -0,0 +1,88 @@
1
+ export interface TestInteraction {
2
+ type: 'RECAST' | 'REPLY' | 'LIKE';
3
+ castId?: string;
4
+ content?: string;
5
+ }
6
+ export interface TestCast {
7
+ hash: string;
8
+ text: string;
9
+ username: string;
10
+ fid: string;
11
+ timestamp: number;
12
+ threadHash: string;
13
+ permanentUrl: string;
14
+ photos: any[];
15
+ hashtags: string[];
16
+ mentions: string[];
17
+ thread: any[];
18
+ urls: string[];
19
+ videos: any[];
20
+ }
21
+ export interface TestImage {
22
+ id: string;
23
+ text: string;
24
+ description: string;
25
+ source: string;
26
+ url: string;
27
+ title: string;
28
+ contentType: string;
29
+ alt_text: string;
30
+ }
31
+ export declare enum ServiceType {
32
+ FARCASTER = "farcaster"
33
+ }
34
+ export interface CastId {
35
+ hash: string;
36
+ fid: string;
37
+ }
38
+ export interface CastStats {
39
+ recasts: number;
40
+ replies: number;
41
+ likes: number;
42
+ }
43
+ export interface Profile {
44
+ fid: string;
45
+ username: string;
46
+ name: string;
47
+ pfp: string;
48
+ }
49
+ export interface Cast {
50
+ hash: string;
51
+ authorFid: string;
52
+ text: string;
53
+ timestamp: Date;
54
+ profile: Profile;
55
+ stats: CastStats;
56
+ }
57
+ export interface FarcasterClient {
58
+ client: {
59
+ fetchProfile: (username: string) => Promise<Profile>;
60
+ fetchUserCasts: (fid: string, limit: number) => Promise<Cast[]>;
61
+ fetchFeed: (limit: number) => Promise<Cast[]>;
62
+ fetchOwnCasts: (limit: number) => Promise<Cast[]>;
63
+ };
64
+ post: {
65
+ postCast: (runtime: any, client: any, text: string, roomId: string, content: string, username: string, media?: any[]) => Promise<void>;
66
+ generateNewCast: () => Promise<void>;
67
+ };
68
+ interaction: {
69
+ handleCast: (params: {
70
+ cast: Cast;
71
+ message: any;
72
+ thread: any[];
73
+ }) => Promise<void>;
74
+ };
75
+ publishCast: (text: string, parent?: CastId) => Promise<{
76
+ success: boolean;
77
+ cast: {
78
+ hash: string;
79
+ author: {
80
+ fid: string;
81
+ };
82
+ text: string;
83
+ timestamp: string;
84
+ parent_hash?: string;
85
+ };
86
+ }>;
87
+ }
88
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/__tests__/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M,EACZ,MAAM,CAAC,EAAE,MAAM,KACZ,OAAO,CAAC;QACX,OAAO,EAAE,OAAO,CAAC;QACjB,IAAI,EAAE;YACJ,IAAI,EAAE,MAAM,CAAC;YACb,MAAM,EAAE;gBAAE,GAAG,EAAE,MAAM,CAAA;aAAE,CAAC;YACxB,IAAI,EAAE,MAAM,CAAC;YACb,SAAS,EAAE,MAAM,CAAC;YAClB,WAAW,CAAC,EAAE,MAAM,CAAC;SACtB,CAAC;KACH,CAAC,CAAC;CACJ"}
@@ -0,0 +1,4 @@
1
+ export { sendCastAction } from './sendCast';
2
+ export { replyCastAction } from './replyCast';
3
+ export declare const farcasterActions: any[];
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/actions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAM9C,eAAO,MAAM,gBAAgB,OAAoC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { type Action } from '@elizaos/core';
2
+ export declare const replyCastAction: Action;
3
+ //# sourceMappingURL=replyCast.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replyCast.d.ts","sourceRoot":"","sources":["../../src/actions/replyCast.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EAKZ,MAAM,eAAe,CAAC;AAKvB,eAAO,MAAM,eAAe,EAAE,MA0G7B,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { type Action } from '@elizaos/core';
2
+ export declare const sendCastAction: Action;
3
+ //# sourceMappingURL=sendCast.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sendCast.d.ts","sourceRoot":"","sources":["../../src/actions/sendCast.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EAMZ,MAAM,eAAe,CAAC;AAIvB,eAAO,MAAM,cAAc,EAAE,MA4G5B,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { Content } from '@elizaos/core';
2
+ import { type NeynarAPIClient } from '@neynar/nodejs-sdk';
3
+ import { Cast as NeynarCast } from '@neynar/nodejs-sdk/build/api';
4
+ import type { Cast, CastId, FidRequest, Profile } from './common/types';
5
+ export declare class FarcasterClient {
6
+ private neynar;
7
+ private signerUuid;
8
+ constructor(opts: {
9
+ neynar: NeynarAPIClient;
10
+ signerUuid: string;
11
+ });
12
+ sendCast({ content, inReplyTo, }: {
13
+ content: Content;
14
+ inReplyTo?: CastId;
15
+ }): Promise<NeynarCast[]>;
16
+ private publishCast;
17
+ getCast(castHash: string): Promise<NeynarCast>;
18
+ getMentions(request: FidRequest): Promise<NeynarCast[]>;
19
+ getProfile(fid: number): Promise<Profile>;
20
+ getTimeline(request: FidRequest): Promise<{
21
+ timeline: Cast[];
22
+ cursor?: string;
23
+ }>;
24
+ clearCache(): void;
25
+ }
26
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAe,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAIlE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAexE,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,UAAU,CAAS;gBACf,IAAI,EAAE;QAAE,MAAM,EAAE,eAAe,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE;IAK3D,QAAQ,CAAC,EACb,OAAO,EACP,SAAS,GACV,EAAE;QACD,OAAO,EAAE,OAAO,CAAC;QACjB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;YAgBX,WAAW;IAsBnB,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAY9C,WAAW,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAkBvD,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAkCzC,WAAW,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC;QAC9C,QAAQ,EAAE,IAAI,EAAE,CAAC;QACjB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;IAqBF,UAAU,IAAI,IAAI;CAInB"}
@@ -0,0 +1,13 @@
1
+ export declare class AsyncQueue {
2
+ private queue;
3
+ private running;
4
+ private emptyListeners;
5
+ private maxConcurrent;
6
+ constructor(maxConcurrent?: number);
7
+ submit<T>(work: () => Promise<T>): Promise<T>;
8
+ private doNextWork;
9
+ size(): Promise<number>;
10
+ waitUntilFinished(): Promise<void>;
11
+ private checkIfEmptyAndNotify;
12
+ }
13
+ //# sourceMappingURL=asyncqueue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asyncqueue.d.ts","sourceRoot":"","sources":["../../src/common/asyncqueue.ts"],"names":[],"mappings":"AAAA,qBAAa,UAAU;IACrB,OAAO,CAAC,KAAK,CAA+B;IAC5C,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,cAAc,CAAsB;IAC5C,OAAO,CAAC,aAAa,CAAS;gBAElB,aAAa,GAAE,MAAU;IAI/B,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;YAarC,UAAU;IAsBlB,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC;IAIvB,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IAUxC,OAAO,CAAC,qBAAqB;CAQ9B"}
@@ -0,0 +1,14 @@
1
+ import { HandlerCallback, IAgentRuntime, Memory, UUID } from '@elizaos/core';
2
+ import { Cast as NeynarCast } from '@neynar/nodejs-sdk/build/api';
3
+ import { FarcasterClient } from '../client';
4
+ import { CastId, FarcasterConfig } from './types';
5
+ export declare function standardCastHandlerCallback({ client, runtime, config, roomId, onCompletion, onError, inReplyTo, }: {
6
+ inReplyTo?: CastId;
7
+ client: FarcasterClient;
8
+ runtime: IAgentRuntime;
9
+ config: FarcasterConfig;
10
+ roomId: UUID;
11
+ onCompletion?: (casts: NeynarCast[], memories: Memory[]) => Promise<void>;
12
+ onError?: (error: unknown) => Promise<void>;
13
+ }): HandlerCallback;
14
+ //# sourceMappingURL=callbacks.d.ts.map