@elizaos/plugin-twitter 1.2.1 → 1.2.3
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 +101 -55
- package/dist/index.d.ts +194 -106
- package/dist/index.js +6078 -5487
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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,36 +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
|
-
#
|
|
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
|
-
|
|
170
|
-
|
|
171
|
-
#
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
#
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
#
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
# Advanced Settings
|
|
189
|
-
TWITTER_MAX_TWEET_LENGTH=4000 # Maximum tweet length (for threads)
|
|
190
|
-
TWITTER_DM_ONLY=false # Only interact via direct messages
|
|
191
|
-
TWITTER_ENABLE_ACTION_PROCESSING=false # Enable timeline action processing (likes, retweets, replies)
|
|
192
|
-
TWITTER_ACTION_INTERVAL=30 # Timeline action processing interval in MINUTES (default: 30 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
|
|
193
188
|
```
|
|
194
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
|
+
|
|
195
250
|
## 🎯 Common Use Cases
|
|
196
251
|
|
|
197
252
|
### Just Want to Post Tweets?
|
|
@@ -203,9 +258,10 @@ TWITTER_API_SECRET_KEY=xxx
|
|
|
203
258
|
TWITTER_ACCESS_TOKEN=xxx # Must have write permissions!
|
|
204
259
|
TWITTER_ACCESS_TOKEN_SECRET=xxx
|
|
205
260
|
|
|
206
|
-
|
|
261
|
+
TWITTER_ENABLE_POST=true
|
|
207
262
|
TWITTER_POST_IMMEDIATELY=true # Great for testing
|
|
208
|
-
|
|
263
|
+
TWITTER_ENABLE_REPLIES=false # Disable interactions
|
|
264
|
+
TWITTER_ENABLE_ACTIONS=false # Disable timeline actions
|
|
209
265
|
```
|
|
210
266
|
|
|
211
267
|
### Want Full Interaction Bot?
|
|
@@ -217,10 +273,10 @@ TWITTER_API_SECRET_KEY=xxx
|
|
|
217
273
|
TWITTER_ACCESS_TOKEN=xxx
|
|
218
274
|
TWITTER_ACCESS_TOKEN_SECRET=xxx
|
|
219
275
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
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
|
|
224
280
|
```
|
|
225
281
|
|
|
226
282
|
### Testing Without Posting?
|
|
@@ -228,7 +284,7 @@ TWITTER_AUTO_RESPOND_REPLIES=true
|
|
|
228
284
|
```bash
|
|
229
285
|
# Dry run mode
|
|
230
286
|
TWITTER_DRY_RUN=true # Simulates all actions
|
|
231
|
-
|
|
287
|
+
TWITTER_ENABLE_POST=true
|
|
232
288
|
TWITTER_POST_IMMEDIATELY=true
|
|
233
289
|
```
|
|
234
290
|
|
|
@@ -260,7 +316,7 @@ Wrong credentials or using OAuth 2.0 instead of OAuth 1.0a.
|
|
|
260
316
|
### Bot Not Posting Automatically
|
|
261
317
|
|
|
262
318
|
**Checklist:**
|
|
263
|
-
- ✅ Is `
|
|
319
|
+
- ✅ Is `TWITTER_ENABLE_POST=true`?
|
|
264
320
|
- ✅ Is `@elizaos/plugin-bootstrap` installed?
|
|
265
321
|
- ✅ Does your character have `postExamples`?
|
|
266
322
|
- ✅ Check logs for "Twitter posting is ENABLED"
|
|
@@ -285,17 +341,11 @@ Your tokens may have been revoked or regenerated.
|
|
|
285
341
|
|
|
286
342
|
## 📚 Advanced Features
|
|
287
343
|
|
|
288
|
-
### Timeline
|
|
289
|
-
|
|
290
|
-
**Weighted Algorithm** (default):
|
|
291
|
-
- Combines user relationship, time, and relevance scores
|
|
292
|
-
- Prioritizes tweets from important users
|
|
293
|
-
- Balances recent content with relevant older content
|
|
344
|
+
### Timeline Processing
|
|
294
345
|
|
|
295
|
-
|
|
296
|
-
-
|
|
297
|
-
-
|
|
298
|
-
- 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
|
|
299
349
|
|
|
300
350
|
### Target User Configuration
|
|
301
351
|
|
|
@@ -312,14 +362,10 @@ TWITTER_TARGET_USERS=*
|
|
|
312
362
|
|
|
313
363
|
### Natural Posting Intervals
|
|
314
364
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
TWITTER_POST_INTERVAL_MAX=180
|
|
320
|
-
# With 20% variance: actual range ~72-216 minutes
|
|
321
|
-
TWITTER_POST_INTERVAL_VARIANCE=0.2
|
|
322
|
-
```
|
|
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
|
|
323
369
|
|
|
324
370
|
### Request Queue & Rate Limiting
|
|
325
371
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
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,79 +762,13 @@ declare class Client {
|
|
|
761
762
|
fetchQuotedTweetsPage(tweetId: string, maxQuotes?: number, cursor?: string): Promise<QueryTweetsResponse>;
|
|
762
763
|
}
|
|
763
764
|
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
private state;
|
|
772
|
-
private isRunning;
|
|
773
|
-
/**
|
|
774
|
-
* Constructor for setting up a new instance with the provided client, runtime, and state.
|
|
775
|
-
* @param {ClientBase} client - The client being used for communication.
|
|
776
|
-
* @param {IAgentRuntime} runtime - The runtime environment for the agent.
|
|
777
|
-
* @param {any} state - The initial state of the agent.
|
|
778
|
-
*/
|
|
779
|
-
constructor(client: ClientBase, runtime: IAgentRuntime, state: any);
|
|
780
|
-
/**
|
|
781
|
-
* Asynchronously starts the process of handling Twitter interactions on a loop.
|
|
782
|
-
* Uses an interval based on the 'TWITTER_POLL_INTERVAL' setting, or defaults to 2 minutes if not set.
|
|
783
|
-
*/
|
|
784
|
-
start(): Promise<void>;
|
|
785
|
-
/**
|
|
786
|
-
* Asynchronously handles Twitter interactions by checking for mentions, processing tweets, and updating the last checked tweet ID.
|
|
787
|
-
*/
|
|
788
|
-
handleTwitterInteractions(): Promise<void>;
|
|
789
|
-
/**
|
|
790
|
-
* Processes all incoming tweets that mention the bot.
|
|
791
|
-
* For each new tweet:
|
|
792
|
-
* - Ensures world, room, and connection exist
|
|
793
|
-
* - Saves the tweet as memory
|
|
794
|
-
* - Emits thread-related events (THREAD_CREATED / THREAD_UPDATED)
|
|
795
|
-
* - Delegates tweet content to `handleTweet` for reply generation
|
|
796
|
-
*
|
|
797
|
-
* Note: MENTION_RECEIVED is currently disabled (see TODO below)
|
|
798
|
-
*/
|
|
799
|
-
processMentionTweets(mentionCandidates: Tweet$1[]): Promise<void>;
|
|
800
|
-
/**
|
|
801
|
-
* Handles Twitter interactions such as likes, retweets, and quotes.
|
|
802
|
-
* For each interaction:
|
|
803
|
-
* - Creates a memory object
|
|
804
|
-
* - Emits platform-specific events (LIKE_RECEIVED, RETWEET_RECEIVED, QUOTE_RECEIVED)
|
|
805
|
-
* - Emits a generic REACTION_RECEIVED event with metadata
|
|
806
|
-
*/
|
|
807
|
-
handleInteraction(interaction: TwitterInteractionPayload): Promise<void>;
|
|
808
|
-
/**
|
|
809
|
-
* Handles a tweet by processing its content, formatting it, generating image descriptions,
|
|
810
|
-
* saving the tweet if it doesn't already exist, determining if a response should be sent,
|
|
811
|
-
* composing a response prompt, generating a response based on the prompt, handling the response
|
|
812
|
-
* tweet, and saving information about the response.
|
|
813
|
-
*
|
|
814
|
-
* @param {object} params - The parameters object containing the tweet, message, and thread.
|
|
815
|
-
* @param {Tweet} params.tweet - The tweet object to handle.
|
|
816
|
-
* @param {Memory} params.message - The memory object associated with the tweet.
|
|
817
|
-
* @param {Tweet[]} params.thread - The array of tweets in the thread.
|
|
818
|
-
* @returns {object} - An object containing the text of the response and any relevant actions.
|
|
819
|
-
*/
|
|
820
|
-
handleTweet({ tweet, message, thread, }: {
|
|
821
|
-
tweet: Tweet$1;
|
|
822
|
-
message: Memory;
|
|
823
|
-
thread: Tweet$1[];
|
|
824
|
-
}): Promise<{
|
|
825
|
-
text: string;
|
|
826
|
-
actions: string[];
|
|
827
|
-
}>;
|
|
828
|
-
/**
|
|
829
|
-
* Build a conversation thread based on a given tweet.
|
|
830
|
-
*
|
|
831
|
-
* @param {Tweet} tweet - The tweet to start the thread from.
|
|
832
|
-
* @param {number} [maxReplies=10] - The maximum number of replies to include in the thread.
|
|
833
|
-
* @returns {Promise<Tweet[]>} The conversation thread as an array of tweets.
|
|
834
|
-
*/
|
|
835
|
-
buildConversationThread(tweet: Tweet$1, maxReplies?: number): Promise<Tweet$1[]>;
|
|
836
|
-
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>;
|
|
837
772
|
stop(): Promise<void>;
|
|
838
773
|
}
|
|
839
774
|
|
|
@@ -854,6 +789,10 @@ declare class TwitterPostClient {
|
|
|
854
789
|
* @param {any} state - The state object containing configuration settings
|
|
855
790
|
*/
|
|
856
791
|
constructor(client: ClientBase, runtime: IAgentRuntime, state: any);
|
|
792
|
+
/**
|
|
793
|
+
* Stops the Twitter post client
|
|
794
|
+
*/
|
|
795
|
+
stop(): Promise<void>;
|
|
857
796
|
/**
|
|
858
797
|
* Starts the Twitter post client, setting up a loop to periodically generate new tweets.
|
|
859
798
|
*/
|
|
@@ -870,7 +809,6 @@ declare class TwitterPostClient {
|
|
|
870
809
|
* @returns {Promise<any>} The result from the Twitter API
|
|
871
810
|
*/
|
|
872
811
|
private postToTwitter;
|
|
873
|
-
stop(): Promise<void>;
|
|
874
812
|
}
|
|
875
813
|
|
|
876
814
|
/**
|
|
@@ -909,6 +847,29 @@ type Tweet = {
|
|
|
909
847
|
thread: any[];
|
|
910
848
|
permanentUrl: string;
|
|
911
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
|
+
}
|
|
912
873
|
/**
|
|
913
874
|
* Twitter-specific interaction payload
|
|
914
875
|
*/
|
|
@@ -1052,6 +1013,122 @@ declare class ClientBase {
|
|
|
1052
1013
|
formatTweetToInteraction(tweet: any): TwitterInteractionPayload | null;
|
|
1053
1014
|
}
|
|
1054
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
|
+
|
|
1055
1132
|
declare enum TIMELINE_TYPE {
|
|
1056
1133
|
ForYou = "foryou",
|
|
1057
1134
|
Following = "following"
|
|
@@ -1066,6 +1143,7 @@ declare class TwitterTimelineClient {
|
|
|
1066
1143
|
private isRunning;
|
|
1067
1144
|
constructor(client: ClientBase, runtime: IAgentRuntime, state: any);
|
|
1068
1145
|
start(): Promise<void>;
|
|
1146
|
+
stop(): Promise<void>;
|
|
1069
1147
|
getTimeline(count: number): Promise<Tweet$1[]>;
|
|
1070
1148
|
createTweetId(runtime: IAgentRuntime, tweet: Tweet$1): `${string}-${string}-${string}-${string}-${string}`;
|
|
1071
1149
|
formMessage(runtime: IAgentRuntime, tweet: Tweet$1): {
|
|
@@ -1091,51 +1169,61 @@ declare class TwitterTimelineClient {
|
|
|
1091
1169
|
handleRetweetAction(tweet: Tweet$1): Promise<void>;
|
|
1092
1170
|
handleQuoteAction(tweet: Tweet$1): Promise<void>;
|
|
1093
1171
|
handleReplyAction(tweet: Tweet$1): Promise<void>;
|
|
1172
|
+
}
|
|
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>;
|
|
1094
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;
|
|
1095
1201
|
}
|
|
1096
1202
|
|
|
1097
1203
|
/**
|
|
1098
1204
|
* A manager that orchestrates all specialized Twitter logic:
|
|
1099
1205
|
* - client: base operations (login, timeline caching, etc.)
|
|
1100
1206
|
* - post: autonomous posting logic
|
|
1101
|
-
* -
|
|
1102
|
-
* -
|
|
1103
|
-
* -
|
|
1104
|
-
*/
|
|
1105
|
-
/**
|
|
1106
|
-
* TwitterClientInstance class that implements ITwitterClient interface.
|
|
1107
|
-
*
|
|
1108
|
-
* @class
|
|
1109
|
-
* @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
|
|
1110
1210
|
*/
|
|
1111
1211
|
declare class TwitterClientInstance implements ITwitterClient {
|
|
1112
1212
|
client: ClientBase;
|
|
1113
1213
|
post: TwitterPostClient;
|
|
1114
1214
|
interaction: TwitterInteractionClient;
|
|
1115
1215
|
timeline?: TwitterTimelineClient;
|
|
1216
|
+
discovery?: TwitterDiscoveryClient;
|
|
1116
1217
|
service: TwitterService;
|
|
1117
1218
|
constructor(runtime: IAgentRuntime, state: any);
|
|
1118
1219
|
}
|
|
1119
|
-
declare
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
* Emits a standardized WORLD_JOINED event for Twitter
|
|
1128
|
-
* @param runtime The agent runtime
|
|
1129
|
-
* @param client The Twitter client instance
|
|
1130
|
-
*/
|
|
1131
|
-
private emitServerJoinedEvent;
|
|
1132
|
-
getClient(clientId: string, agentId: UUID): TwitterClientInstance | undefined;
|
|
1133
|
-
stopClient(clientId: string, agentId: UUID): Promise<void>;
|
|
1134
|
-
static start(runtime: IAgentRuntime): Promise<TwitterService>;
|
|
1135
|
-
stop(): Promise<void>;
|
|
1136
|
-
stopAllClients(): Promise<void>;
|
|
1137
|
-
private getClientKey;
|
|
1138
|
-
}
|
|
1139
|
-
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
|
+
};
|
|
1140
1228
|
|
|
1141
|
-
export { TwitterClientInstance,
|
|
1229
|
+
export { TwitterClientInstance, TwitterPlugin, TwitterPlugin as default };
|