@elizaos/plugin-twitter 1.2.0 → 1.2.2

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.
package/README.md CHANGED
@@ -17,7 +17,7 @@ This package provides Twitter/X integration for the Eliza AI agent using the off
17
17
  TWITTER_API_SECRET_KEY=xxx
18
18
  TWITTER_ACCESS_TOKEN=xxx
19
19
  TWITTER_ACCESS_TOKEN_SECRET=xxx
20
- TWITTER_POST_ENABLE=true
20
+ TWITTER_ENABLE_POST=true
21
21
  TWITTER_POST_IMMEDIATELY=true
22
22
  ```
23
23
  5. **Run:** `bun start`
@@ -34,6 +34,7 @@ This package provides Twitter/X integration for the Eliza AI agent using the off
34
34
  - ✅ **Advanced timeline algorithms** with weighted scoring
35
35
  - ✅ **Comprehensive caching system**
36
36
  - ✅ **Built-in rate limiting and retry mechanisms**
37
+ - ✅ **Discovery service** for autonomous content discovery and growth
37
38
 
38
39
  ## Prerequisites
39
40
 
@@ -122,12 +123,11 @@ TWITTER_ACCESS_TOKEN_SECRET=your_token_secret_here # Regenerate after permissi
122
123
 
123
124
  # Basic Configuration
124
125
  TWITTER_DRY_RUN=false # Set to true to test without posting
125
- TWITTER_POST_ENABLE=true # Set to true to enable auto-posting
126
+ TWITTER_ENABLE_POST=true # Enable autonomous tweet posting
126
127
 
127
128
  # Optional: Posting Configuration
128
129
  TWITTER_POST_IMMEDIATELY=true # Post on startup (great for testing)
129
- TWITTER_POST_INTERVAL_MIN=90 # Minimum minutes between posts
130
- TWITTER_POST_INTERVAL_MAX=180 # Maximum minutes between posts
130
+ TWITTER_POST_INTERVAL=120 # Minutes between posts (default: 120)
131
131
  ```
132
132
 
133
133
  ### Step 5: Run Your Bot
@@ -162,41 +162,91 @@ TWITTER_API_SECRET_KEY= # Consumer API Secret
162
162
  TWITTER_ACCESS_TOKEN= # Access Token (with write permissions)
163
163
  TWITTER_ACCESS_TOKEN_SECRET= # Access Token Secret
164
164
 
165
- # Basic Configuration
165
+ # Core Configuration
166
166
  TWITTER_DRY_RUN=false # Set to true for testing without posting
167
167
  TWITTER_TARGET_USERS= # Comma-separated usernames to target (use "*" for all)
168
168
  TWITTER_RETRY_LIMIT=5 # Maximum retry attempts for failed operations
169
- TWITTER_POLL_INTERVAL=120 # Timeline polling interval (seconds)
170
-
171
- # Post Generation Settings
172
- TWITTER_POST_ENABLE=false # Enable autonomous tweet posting
173
- TWITTER_POST_INTERVAL_MIN=90 # Minimum interval between posts (minutes)
174
- TWITTER_POST_INTERVAL_MAX=180 # Maximum interval between posts (minutes)
175
- TWITTER_POST_IMMEDIATELY=false # Post immediately on startup
176
- TWITTER_POST_INTERVAL_VARIANCE=0.2 # Random variance factor for posting intervals
177
-
178
- # Interaction Settings
179
- TWITTER_SEARCH_ENABLE=true # Enable timeline monitoring and interactions
180
- TWITTER_INTERACTION_INTERVAL_MIN=15 # Minimum interval between interactions (minutes)
181
- TWITTER_INTERACTION_INTERVAL_MAX=30 # Maximum interval between interactions (minutes)
182
- TWITTER_INTERACTION_INTERVAL_VARIANCE=0.3 # Random variance for interaction intervals
183
- TWITTER_AUTO_RESPOND_MENTIONS=true # Automatically respond to mentions
184
- TWITTER_AUTO_RESPOND_REPLIES=true # Automatically respond to replies
185
- TWITTER_MAX_INTERACTIONS_PER_RUN=10 # Maximum interactions processed per cycle
186
-
187
- # Timeline Algorithm Configuration
188
- TWITTER_TIMELINE_ALGORITHM=weighted # Algorithm: "weighted" or "latest"
189
- TWITTER_TIMELINE_USER_BASED_WEIGHT=3 # Weight for user-based scoring
190
- TWITTER_TIMELINE_TIME_BASED_WEIGHT=2 # Weight for time-based scoring
191
- TWITTER_TIMELINE_RELEVANCE_WEIGHT=5 # Weight for relevance scoring
192
-
193
- # Advanced Settings
194
- TWITTER_MAX_TWEET_LENGTH=4000 # Maximum tweet length (for threads)
195
- TWITTER_DM_ONLY=false # Only interact via direct messages
196
- TWITTER_ENABLE_ACTION_PROCESSING=false # Enable timeline action processing
197
- TWITTER_ACTION_INTERVAL=240 # Action processing interval (minutes)
169
+
170
+ # Feature Toggles
171
+ TWITTER_ENABLE_POST=false # Enable autonomous tweet posting
172
+ TWITTER_ENABLE_REPLIES=true # Enable mention and reply handling
173
+ TWITTER_ENABLE_ACTIONS=false # Enable timeline actions (likes, retweets, quotes)
174
+ TWITTER_ENABLE_DISCOVERY= # Enable discovery service (defaults to true if ACTIONS enabled)
175
+
176
+ # Timing Configuration (all in minutes)
177
+ TWITTER_POST_INTERVAL=120 # Interval between autonomous posts (default: 120)
178
+ TWITTER_ENGAGEMENT_INTERVAL=30 # Interval for all interaction cycles (default: 30)
179
+ TWITTER_DISCOVERY_INTERVAL=30 # Interval for discovery cycles (default: 30)
180
+
181
+ # Engagement Limits
182
+ TWITTER_MAX_ENGAGEMENTS_PER_RUN=10 # Maximum interactions per engagement cycle
183
+ TWITTER_MAX_TWEET_LENGTH=280 # Maximum tweet length
184
+
185
+ # Discovery Service Settings
186
+ TWITTER_MIN_FOLLOWER_COUNT=100 # Minimum followers for accounts to follow
187
+ TWITTER_MAX_FOLLOWS_PER_CYCLE=5 # Maximum accounts to follow per discovery cycle
198
188
  ```
199
189
 
190
+ ## 🔍 Discovery Service
191
+
192
+ The Twitter Discovery Service enables autonomous content discovery and engagement, helping your agent build a following and interact with relevant content on Twitter.
193
+
194
+ ### Overview
195
+
196
+ The discovery service autonomously:
197
+ - Searches for content related to your agent's topics
198
+ - Identifies high-quality accounts to follow
199
+ - Engages with relevant tweets through likes, replies, and quotes
200
+ - Builds up your agent's timeline by following interesting accounts
201
+
202
+ ### Configuration
203
+
204
+ ```bash
205
+ # Enable discovery service (defaults to true if TWITTER_ENABLE_ACTIONS=true)
206
+ TWITTER_ENABLE_DISCOVERY=true
207
+
208
+ # Discovery interval in minutes (default: 30)
209
+ TWITTER_DISCOVERY_INTERVAL=30
210
+
211
+ # Minimum follower count for accounts to follow (default: 100)
212
+ TWITTER_MIN_FOLLOWER_COUNT=100
213
+
214
+ # Maximum accounts to follow per cycle (default: 5)
215
+ TWITTER_MAX_FOLLOWS_PER_CYCLE=5
216
+
217
+ # Maximum engagements per cycle (default: 10)
218
+ TWITTER_MAX_ENGAGEMENTS_PER_RUN=10
219
+ ```
220
+
221
+ ### How It Works
222
+
223
+ 1. **Content Discovery**: Searches for tweets containing your agent's topics
224
+ 2. **Account Scoring**: Scores accounts based on quality (follower count) and relevance
225
+ 3. **Tweet Scoring**: Scores tweets for engagement based on relevance:
226
+ - Like: score > 0.6
227
+ - Reply: score > 0.8
228
+ - Quote: score > 0.85
229
+ 4. **Memory System**: Tracks engaged tweets and followed accounts to avoid duplicates
230
+
231
+ ### Character Configuration
232
+
233
+ The discovery service uses your agent's character configuration:
234
+
235
+ ```json
236
+ {
237
+ "name": "YourAgent",
238
+ "topics": [
239
+ "artificial intelligence",
240
+ "machine learning",
241
+ "web3",
242
+ "blockchain"
243
+ ],
244
+ "bio": "AI researcher interested in decentralized systems"
245
+ }
246
+ ```
247
+
248
+ If topics aren't specified, the service extracts them from the bio.
249
+
200
250
  ## 🎯 Common Use Cases
201
251
 
202
252
  ### Just Want to Post Tweets?
@@ -208,9 +258,10 @@ TWITTER_API_SECRET_KEY=xxx
208
258
  TWITTER_ACCESS_TOKEN=xxx # Must have write permissions!
209
259
  TWITTER_ACCESS_TOKEN_SECRET=xxx
210
260
 
211
- TWITTER_POST_ENABLE=true
261
+ TWITTER_ENABLE_POST=true
212
262
  TWITTER_POST_IMMEDIATELY=true # Great for testing
213
- TWITTER_SEARCH_ENABLE=false # Disable interactions
263
+ TWITTER_ENABLE_REPLIES=false # Disable interactions
264
+ TWITTER_ENABLE_ACTIONS=false # Disable timeline actions
214
265
  ```
215
266
 
216
267
  ### Want Full Interaction Bot?
@@ -222,10 +273,10 @@ TWITTER_API_SECRET_KEY=xxx
222
273
  TWITTER_ACCESS_TOKEN=xxx
223
274
  TWITTER_ACCESS_TOKEN_SECRET=xxx
224
275
 
225
- TWITTER_POST_ENABLE=true
226
- TWITTER_SEARCH_ENABLE=true
227
- TWITTER_AUTO_RESPOND_MENTIONS=true
228
- TWITTER_AUTO_RESPOND_REPLIES=true
276
+ TWITTER_ENABLE_POST=true
277
+ TWITTER_ENABLE_REPLIES=true
278
+ TWITTER_ENABLE_ACTIONS=true # Enables likes, retweets, quotes
279
+ TWITTER_ENABLE_DISCOVERY=true # Enables growth features
229
280
  ```
230
281
 
231
282
  ### Testing Without Posting?
@@ -233,7 +284,7 @@ TWITTER_AUTO_RESPOND_REPLIES=true
233
284
  ```bash
234
285
  # Dry run mode
235
286
  TWITTER_DRY_RUN=true # Simulates all actions
236
- TWITTER_POST_ENABLE=true
287
+ TWITTER_ENABLE_POST=true
237
288
  TWITTER_POST_IMMEDIATELY=true
238
289
  ```
239
290
 
@@ -265,7 +316,7 @@ Wrong credentials or using OAuth 2.0 instead of OAuth 1.0a.
265
316
  ### Bot Not Posting Automatically
266
317
 
267
318
  **Checklist:**
268
- - ✅ Is `TWITTER_POST_ENABLE=true`?
319
+ - ✅ Is `TWITTER_ENABLE_POST=true`?
269
320
  - ✅ Is `@elizaos/plugin-bootstrap` installed?
270
321
  - ✅ Does your character have `postExamples`?
271
322
  - ✅ Check logs for "Twitter posting is ENABLED"
@@ -290,17 +341,11 @@ Your tokens may have been revoked or regenerated.
290
341
 
291
342
  ## 📚 Advanced Features
292
343
 
293
- ### Timeline Algorithms
294
-
295
- **Weighted Algorithm** (default):
296
- - Combines user relationship, time, and relevance scores
297
- - Prioritizes tweets from important users
298
- - Balances recent content with relevant older content
344
+ ### Timeline Processing
299
345
 
300
- **Latest Algorithm**:
301
- - Processes tweets in chronological order
302
- - Simpler, more predictable behavior
303
- - Good for high-volume timelines
346
+ The plugin supports two main approaches:
347
+ - **Timeline Actions**: Process home timeline for likes, retweets, and quotes
348
+ - **Targeted Interactions**: Reply to mentions and specific users
304
349
 
305
350
  ### Target User Configuration
306
351
 
@@ -317,14 +362,10 @@ TWITTER_TARGET_USERS=*
317
362
 
318
363
  ### Natural Posting Intervals
319
364
 
320
- All intervals support variance for more human-like behavior:
321
- ```bash
322
- # Base interval: 90-180 minutes
323
- TWITTER_POST_INTERVAL_MIN=90
324
- TWITTER_POST_INTERVAL_MAX=180
325
- # With 20% variance: actual range ~72-216 minutes
326
- TWITTER_POST_INTERVAL_VARIANCE=0.2
327
- ```
365
+ The plugin adds variance to all intervals for more human-like behavior:
366
+ - Post intervals vary by ±20% by default
367
+ - Discovery intervals vary by ±10 minutes
368
+ - Engagement intervals vary based on activity
328
369
 
329
370
  ### Request Queue & Rate Limiting
330
371
 
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { IAgentRuntime, Memory, State, ChannelType, Plugin, Service, UUID } from '@elizaos/core';
1
+ import * as _elizaos_core from '@elizaos/core';
2
+ import { Service, IAgentRuntime, Memory, UUID, State, ChannelType } from '@elizaos/core';
2
3
  import * as twitter_api_v2 from 'twitter-api-v2';
3
4
  import { TwitterApi, PollV2, TTweetv2Expansion, TTweetv2TweetField, TTweetv2PollField, TTweetv2MediaField, TTweetv2UserField, TTweetv2PlaceField } from 'twitter-api-v2';
4
5
 
@@ -761,78 +762,14 @@ declare class Client {
761
762
  fetchQuotedTweetsPage(tweetId: string, maxQuotes?: number, cursor?: string): Promise<QueryTweetsResponse>;
762
763
  }
763
764
 
764
- /**
765
- * Class representing a client for interacting with Twitter.
766
- */
767
- declare class TwitterInteractionClient {
768
- client: ClientBase;
769
- runtime: IAgentRuntime;
770
- private isDryRun;
771
- private state;
772
- /**
773
- * Constructor for setting up a new instance with the provided client, runtime, and state.
774
- * @param {ClientBase} client - The client being used for communication.
775
- * @param {IAgentRuntime} runtime - The runtime environment for the agent.
776
- * @param {any} state - The initial state of the agent.
777
- */
778
- constructor(client: ClientBase, runtime: IAgentRuntime, state: any);
779
- /**
780
- * Asynchronously starts the process of handling Twitter interactions on a loop.
781
- * Uses an interval based on the 'TWITTER_POLL_INTERVAL' setting, or defaults to 2 minutes if not set.
782
- */
783
- start(): Promise<void>;
784
- /**
785
- * Asynchronously handles Twitter interactions by checking for mentions, processing tweets, and updating the last checked tweet ID.
786
- */
787
- handleTwitterInteractions(): Promise<void>;
788
- /**
789
- * Processes all incoming tweets that mention the bot.
790
- * For each new tweet:
791
- * - Ensures world, room, and connection exist
792
- * - Saves the tweet as memory
793
- * - Emits thread-related events (THREAD_CREATED / THREAD_UPDATED)
794
- * - Delegates tweet content to `handleTweet` for reply generation
795
- *
796
- * Note: MENTION_RECEIVED is currently disabled (see TODO below)
797
- */
798
- processMentionTweets(mentionCandidates: Tweet$1[]): Promise<void>;
799
- /**
800
- * Handles Twitter interactions such as likes, retweets, and quotes.
801
- * For each interaction:
802
- * - Creates a memory object
803
- * - Emits platform-specific events (LIKE_RECEIVED, RETWEET_RECEIVED, QUOTE_RECEIVED)
804
- * - Emits a generic REACTION_RECEIVED event with metadata
805
- */
806
- handleInteraction(interaction: TwitterInteractionPayload): Promise<void>;
807
- /**
808
- * Handles a tweet by processing its content, formatting it, generating image descriptions,
809
- * saving the tweet if it doesn't already exist, determining if a response should be sent,
810
- * composing a response prompt, generating a response based on the prompt, handling the response
811
- * tweet, and saving information about the response.
812
- *
813
- * @param {object} params - The parameters object containing the tweet, message, and thread.
814
- * @param {Tweet} params.tweet - The tweet object to handle.
815
- * @param {Memory} params.message - The memory object associated with the tweet.
816
- * @param {Tweet[]} params.thread - The array of tweets in the thread.
817
- * @returns {object} - An object containing the text of the response and any relevant actions.
818
- */
819
- handleTweet({ tweet, message, thread, }: {
820
- tweet: Tweet$1;
821
- message: Memory;
822
- thread: Tweet$1[];
823
- }): Promise<{
824
- text: string;
825
- actions: string[];
826
- }>;
827
- /**
828
- * Build a conversation thread based on a given tweet.
829
- *
830
- * @param {Tweet} tweet - The tweet to start the thread from.
831
- * @param {number} [maxReplies=10] - The maximum number of replies to include in the thread.
832
- * @returns {Promise<Tweet[]>} The conversation thread as an array of tweets.
833
- */
834
- buildConversationThread(tweet: Tweet$1, maxReplies?: number): Promise<Tweet$1[]>;
835
- private createMemoryObject;
765
+ declare class TwitterService extends Service {
766
+ static serviceType: string;
767
+ capabilityDescription: string;
768
+ private static instance;
769
+ constructor(runtime?: IAgentRuntime);
770
+ static getInstance(): TwitterService;
771
+ static start(runtime: IAgentRuntime): Promise<TwitterService>;
772
+ stop(): Promise<void>;
836
773
  }
837
774
 
838
775
  /**
@@ -844,6 +781,7 @@ declare class TwitterPostClient {
844
781
  twitterUsername: string;
845
782
  private isDryRun;
846
783
  private state;
784
+ private isRunning;
847
785
  /**
848
786
  * Constructor for initializing a new Twitter client with the provided client, runtime, and state
849
787
  * @param {ClientBase} client - The client used for interacting with Twitter API
@@ -851,6 +789,10 @@ declare class TwitterPostClient {
851
789
  * @param {any} state - The state object containing configuration settings
852
790
  */
853
791
  constructor(client: ClientBase, runtime: IAgentRuntime, state: any);
792
+ /**
793
+ * Stops the Twitter post client
794
+ */
795
+ stop(): Promise<void>;
854
796
  /**
855
797
  * Starts the Twitter post client, setting up a loop to periodically generate new tweets.
856
798
  */
@@ -867,7 +809,6 @@ declare class TwitterPostClient {
867
809
  * @returns {Promise<any>} The result from the Twitter API
868
810
  */
869
811
  private postToTwitter;
870
- stop(): Promise<void>;
871
812
  }
872
813
 
873
814
  /**
@@ -906,6 +847,29 @@ type Tweet = {
906
847
  thread: any[];
907
848
  permanentUrl: string;
908
849
  };
850
+ /**
851
+ * Twitter-specific memory interface
852
+ */
853
+ interface TwitterMemory extends Memory {
854
+ content: {
855
+ source: "twitter";
856
+ text?: string;
857
+ type?: string;
858
+ targetId?: string;
859
+ [key: string]: any;
860
+ };
861
+ roomId: UUID;
862
+ }
863
+ /**
864
+ * Twitter-specific interaction memory
865
+ */
866
+ interface TwitterInteractionMemory extends TwitterMemory {
867
+ content: {
868
+ type: string;
869
+ source: "twitter";
870
+ targetId?: string;
871
+ };
872
+ }
909
873
  /**
910
874
  * Twitter-specific interaction payload
911
875
  */
@@ -943,6 +907,8 @@ type TwitterProfile = {
943
907
  declare class RequestQueue {
944
908
  private queue;
945
909
  private processing;
910
+ private maxRetries;
911
+ private retryAttempts;
946
912
  /**
947
913
  * Asynchronously adds a request to the queue, then processes the queue.
948
914
  *
@@ -1047,6 +1013,122 @@ declare class ClientBase {
1047
1013
  formatTweetToInteraction(tweet: any): TwitterInteractionPayload | null;
1048
1014
  }
1049
1015
 
1016
+ /**
1017
+ * The TwitterInteractionClient class manages Twitter interactions,
1018
+ * including handling mentions, managing timelines, and engaging with other users.
1019
+ * It extends the base Twitter client functionality to provide mention handling,
1020
+ * user interaction, and follow change detection capabilities.
1021
+ *
1022
+ * @extends ClientBase
1023
+ */
1024
+ declare class TwitterInteractionClient {
1025
+ client: ClientBase;
1026
+ runtime: IAgentRuntime;
1027
+ twitterUsername: string;
1028
+ private twitterUserId;
1029
+ private isDryRun;
1030
+ private state;
1031
+ private isRunning;
1032
+ private lastProcessedTimestamp;
1033
+ /**
1034
+ * Constructor to initialize the Twitter interaction client with runtime and state management.
1035
+ *
1036
+ * @param {ClientBase} client - The client instance.
1037
+ * @param {IAgentRuntime} runtime - The runtime instance for agent operations.
1038
+ * @param {any} state - The state object containing configuration settings.
1039
+ */
1040
+ constructor(client: ClientBase, runtime: IAgentRuntime, state: any);
1041
+ /**
1042
+ * Asynchronously starts the process of handling Twitter interactions on a loop.
1043
+ * Uses the unified TWITTER_ENGAGEMENT_INTERVAL setting.
1044
+ */
1045
+ start(): Promise<void>;
1046
+ /**
1047
+ * Stops the Twitter interaction client
1048
+ */
1049
+ stop(): Promise<void>;
1050
+ /**
1051
+ * Asynchronously handles Twitter interactions by checking for mentions and target user posts.
1052
+ */
1053
+ handleTwitterInteractions(): Promise<void>;
1054
+ /**
1055
+ * Handle mentions and replies
1056
+ */
1057
+ private handleMentions;
1058
+ /**
1059
+ * Handle autonomous engagement with target users' posts
1060
+ */
1061
+ private handleTargetUserPosts;
1062
+ /**
1063
+ * Process tweets from target users for potential engagement
1064
+ */
1065
+ private processTargetUserTweets;
1066
+ /**
1067
+ * Process timeline for engagement when wildcard is configured
1068
+ */
1069
+ private processTimelineForEngagement;
1070
+ /**
1071
+ * Determine if the bot should engage with a specific tweet
1072
+ */
1073
+ private shouldEngageWithTweet;
1074
+ /**
1075
+ * Ensure tweet context exists (world, room, entity)
1076
+ */
1077
+ private ensureTweetContext;
1078
+ /**
1079
+ * Engage with a tweet by generating and sending a reply
1080
+ */
1081
+ private engageWithTweet;
1082
+ /**
1083
+ * Processes all incoming tweets that mention the bot.
1084
+ * For each new tweet:
1085
+ * - Ensures world, room, and connection exist
1086
+ * - Saves the tweet as memory
1087
+ * - Emits thread-related events (THREAD_CREATED / THREAD_UPDATED)
1088
+ * - Delegates tweet content to `handleTweet` for reply generation
1089
+ *
1090
+ * Note: MENTION_RECEIVED is currently disabled (see TODO below)
1091
+ */
1092
+ processMentionTweets(mentionCandidates: Tweet$1[]): Promise<void>;
1093
+ /**
1094
+ * Handles Twitter interactions such as likes, retweets, and quotes.
1095
+ * For each interaction:
1096
+ * - Creates a memory object
1097
+ * - Emits platform-specific events (LIKE_RECEIVED, RETWEET_RECEIVED, QUOTE_RECEIVED)
1098
+ * - Emits a generic REACTION_RECEIVED event with metadata
1099
+ */
1100
+ handleInteraction(interaction: TwitterInteractionPayload): Promise<void>;
1101
+ /**
1102
+ * Creates a memory object for a given Twitter interaction.
1103
+ *
1104
+ * @param {string} type - The type of interaction (e.g., 'like', 'retweet', 'quote').
1105
+ * @param {string} id - The unique identifier for the interaction.
1106
+ * @param {string} userId - The ID of the user who initiated the interaction.
1107
+ * @param {string} conversationId - The ID of the conversation context.
1108
+ * @returns {TwitterInteractionMemory} The constructed memory object.
1109
+ */
1110
+ createMemoryObject(type: string, id: string, userId: string, conversationId: string): TwitterInteractionMemory;
1111
+ /**
1112
+ * Asynchronously handles a tweet by generating a response and sending it.
1113
+ * This method processes the tweet content, determines if a response is needed,
1114
+ * generates appropriate response text, and sends the tweet reply.
1115
+ *
1116
+ * @param {object} params - The parameters object containing the tweet, message, and thread.
1117
+ * @param {Tweet} params.tweet - The tweet object to handle.
1118
+ * @param {Memory} params.message - The memory object associated with the tweet.
1119
+ * @param {Tweet[]} params.thread - The array of tweets in the thread.
1120
+ * @returns {object} - An object containing the text of the response and any relevant actions.
1121
+ */
1122
+ handleTweet({ tweet, message, thread, }: {
1123
+ tweet: Tweet$1;
1124
+ message: Memory;
1125
+ thread: Tweet$1[];
1126
+ }): Promise<{
1127
+ text: string;
1128
+ actions: string[];
1129
+ }>;
1130
+ }
1131
+
1050
1132
  declare enum TIMELINE_TYPE {
1051
1133
  ForYou = "foryou",
1052
1134
  Following = "following"
@@ -1058,8 +1140,10 @@ declare class TwitterTimelineClient {
1058
1140
  isDryRun: boolean;
1059
1141
  timelineType: TIMELINE_TYPE;
1060
1142
  private state;
1143
+ private isRunning;
1061
1144
  constructor(client: ClientBase, runtime: IAgentRuntime, state: any);
1062
1145
  start(): Promise<void>;
1146
+ stop(): Promise<void>;
1063
1147
  getTimeline(count: number): Promise<Tweet$1[]>;
1064
1148
  createTweetId(runtime: IAgentRuntime, tweet: Tweet$1): `${string}-${string}-${string}-${string}-${string}`;
1065
1149
  formMessage(runtime: IAgentRuntime, tweet: Tweet$1): {
@@ -1087,48 +1171,59 @@ declare class TwitterTimelineClient {
1087
1171
  handleReplyAction(tweet: Tweet$1): Promise<void>;
1088
1172
  }
1089
1173
 
1174
+ declare class TwitterDiscoveryClient {
1175
+ private client;
1176
+ private twitterClient;
1177
+ private runtime;
1178
+ private config;
1179
+ private isRunning;
1180
+ private isDryRun;
1181
+ constructor(client: ClientBase, runtime: IAgentRuntime, state: any);
1182
+ private buildDiscoveryConfig;
1183
+ private extractTopicsFromBio;
1184
+ start(): Promise<void>;
1185
+ stop(): Promise<void>;
1186
+ private runDiscoveryCycle;
1187
+ private discoverContent;
1188
+ private discoverFromTopics;
1189
+ private discoverFromThreads;
1190
+ private discoverFromPopularAccounts;
1191
+ private scoreTweet;
1192
+ private scoreAccount;
1193
+ private processAccounts;
1194
+ private processTweets;
1195
+ private checkIfFollowing;
1196
+ private generateReply;
1197
+ private generateQuote;
1198
+ private saveEngagementMemory;
1199
+ private saveFollowMemory;
1200
+ private delay;
1201
+ }
1202
+
1090
1203
  /**
1091
1204
  * A manager that orchestrates all specialized Twitter logic:
1092
1205
  * - client: base operations (login, timeline caching, etc.)
1093
1206
  * - post: autonomous posting logic
1094
- * - search: searching tweets / replying logic
1095
- * - interaction: handling mentions, replies
1096
- * - space: launching and managing Twitter Spaces (optional)
1097
- */
1098
- /**
1099
- * TwitterClientInstance class that implements ITwitterClient interface.
1100
- *
1101
- * @class
1102
- * @implements {ITwitterClient}
1207
+ * - interaction: handling mentions, replies, and autonomous targeting
1208
+ * - timeline: processing timeline for actions (likes, retweets, replies)
1209
+ * - discovery: autonomous content discovery and engagement
1103
1210
  */
1104
1211
  declare class TwitterClientInstance implements ITwitterClient {
1105
1212
  client: ClientBase;
1106
1213
  post: TwitterPostClient;
1107
1214
  interaction: TwitterInteractionClient;
1108
1215
  timeline?: TwitterTimelineClient;
1216
+ discovery?: TwitterDiscoveryClient;
1109
1217
  service: TwitterService;
1110
1218
  constructor(runtime: IAgentRuntime, state: any);
1111
1219
  }
1112
- declare class TwitterService extends Service {
1113
- static serviceType: string;
1114
- capabilityDescription: string;
1115
- private static instance;
1116
- private clients;
1117
- static getInstance(): TwitterService;
1118
- createClient(runtime: IAgentRuntime, clientId: string, state: any): Promise<TwitterClientInstance>;
1119
- /**
1120
- * Emits a standardized WORLD_JOINED event for Twitter
1121
- * @param runtime The agent runtime
1122
- * @param client The Twitter client instance
1123
- */
1124
- private emitServerJoinedEvent;
1125
- getClient(clientId: string, agentId: UUID): TwitterClientInstance | undefined;
1126
- stopClient(clientId: string, agentId: UUID): Promise<void>;
1127
- static start(runtime: IAgentRuntime): Promise<TwitterService>;
1128
- stop(): Promise<void>;
1129
- stopAllClients(): Promise<void>;
1130
- private getClientKey;
1131
- }
1132
- declare const twitterPlugin: Plugin;
1220
+ declare function startTwitterClient(runtime: IAgentRuntime): Promise<void>;
1221
+ declare const TwitterPlugin: {
1222
+ name: string;
1223
+ description: string;
1224
+ actions: _elizaos_core.Action[];
1225
+ services: (typeof TwitterService)[];
1226
+ init: typeof startTwitterClient;
1227
+ };
1133
1228
 
1134
- export { TwitterClientInstance, TwitterService, twitterPlugin as default };
1229
+ export { TwitterClientInstance, TwitterPlugin, TwitterPlugin as default };