@elizaos/plugin-twitter 1.2.5 → 1.2.7

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/dist/index.d.ts CHANGED
@@ -1,1224 +1,5 @@
1
- import * as _elizaos_core from '@elizaos/core';
2
- import { IAgentRuntime, Memory, UUID, State, ChannelType, Service } from '@elizaos/core';
3
- import * as twitter_api_v2 from 'twitter-api-v2';
4
- import { TwitterApi, PollV2, TTweetv2Expansion, TTweetv2TweetField, TTweetv2PollField, TTweetv2MediaField, TTweetv2UserField, TTweetv2PlaceField } from 'twitter-api-v2';
1
+ import { Plugin } from '@elizaos/core';
5
2
 
6
- /**
7
- * Twitter API v2 authentication using developer credentials
8
- */
9
- declare class TwitterAuth {
10
- private appKey;
11
- private appSecret;
12
- private accessToken;
13
- private accessSecret;
14
- private v2Client;
15
- private authenticated;
16
- private profile?;
17
- constructor(appKey: string, appSecret: string, accessToken: string, accessSecret: string);
18
- private initializeClient;
19
- /**
20
- * Get the Twitter API v2 client
21
- */
22
- getV2Client(): TwitterApi;
23
- /**
24
- * Check if authenticated
25
- */
26
- isLoggedIn(): Promise<boolean>;
27
- /**
28
- * Get current user profile
29
- */
30
- me(): Promise<Profile | undefined>;
31
- /**
32
- * Logout (clear credentials)
33
- */
34
- logout(): Promise<void>;
35
- /**
36
- * For compatibility - always returns true since we use API keys
37
- */
38
- hasToken(): boolean;
39
- }
3
+ declare const TwitterPlugin: Plugin;
40
4
 
41
- /**
42
- * Interface representing a mention.
43
- * @typedef {Object} Mention
44
- * @property {string} id - The unique identifier for the mention.
45
- * @property {string} [username] - The username associated with the mention.
46
- * @property {string} [name] - The name associated with the mention.
47
- */
48
- interface Mention {
49
- id: string;
50
- username?: string;
51
- name?: string;
52
- }
53
- /**
54
- * Interface representing a photo object.
55
- * @interface
56
- * @property {string} id - The unique identifier for the photo.
57
- * @property {string} url - The URL for the photo image.
58
- * @property {string} [alt_text] - The alternative text for the photo image. Optional.
59
- */
60
- interface Photo {
61
- id: string;
62
- url: string;
63
- alt_text: string | undefined;
64
- }
65
- /**
66
- * Interface representing a video object.
67
- * @typedef {Object} Video
68
- * @property {string} id - The unique identifier for the video.
69
- * @property {string} preview - The URL for the preview image of the video.
70
- * @property {string} [url] - The optional URL for the video.
71
- */
72
- interface Video {
73
- id: string;
74
- preview: string;
75
- url?: string;
76
- }
77
- /**
78
- * Interface representing a raw place object.
79
- * @typedef {Object} PlaceRaw
80
- * @property {string} [id] - The unique identifier of the place.
81
- * @property {string} [place_type] - The type of the place.
82
- * @property {string} [name] - The name of the place.
83
- * @property {string} [full_name] - The full name of the place.
84
- * @property {string} [country_code] - The country code of the place.
85
- * @property {string} [country] - The country name of the place.
86
- * @property {Object} [bounding_box] - The bounding box coordinates of the place.
87
- * @property {string} [bounding_box.type] - The type of the bounding box.
88
- * @property {number[][][]} [bounding_box.coordinates] - The coordinates of the bounding box in an array format.
89
- */
90
- interface PlaceRaw {
91
- id?: string;
92
- place_type?: string;
93
- name?: string;
94
- full_name?: string;
95
- country_code?: string;
96
- country?: string;
97
- bounding_box?: {
98
- type?: string;
99
- coordinates?: number[][][];
100
- };
101
- }
102
- /**
103
- * Interface representing poll data.
104
- *
105
- * @property {string} [id] - The unique identifier for the poll.
106
- * @property {string} [end_datetime] - The end date and time for the poll.
107
- * @property {string} [voting_status] - The status of the voting process.
108
- * @property {number} duration_minutes - The duration of the poll in minutes.
109
- * @property {PollOption[]} options - An array of poll options.
110
- */
111
- interface PollData {
112
- id?: string;
113
- end_datetime?: string;
114
- voting_status?: string;
115
- duration_minutes: number;
116
- options: PollOption[];
117
- }
118
- /**
119
- * Interface representing a poll option.
120
- * @typedef {Object} PollOption
121
- * @property {number} [position] - The position of the option.
122
- * @property {string} label - The label of the option.
123
- * @property {number} [votes] - The number of votes for the option.
124
- */
125
- interface PollOption {
126
- position?: number;
127
- label: string;
128
- votes?: number;
129
- }
130
- /**
131
- * A parsed Tweet object.
132
- */
133
- /**
134
- * Represents a Tweet on Twitter.
135
- * @typedef { Object } Tweet
136
- * @property { number } [bookmarkCount] - The number of times this Tweet has been bookmarked.
137
- * @property { string } [conversationId] - The ID of the conversation this Tweet is a part of.
138
- * @property {string[]} hashtags - An array of hashtags mentioned in the Tweet.
139
- * @property { string } [html] - The HTML content of the Tweet.
140
- * @property { string } [id] - The unique ID of the Tweet.
141
- * @property { Tweet } [inReplyToStatus] - The Tweet that this Tweet is in reply to.
142
- * @property { string } [inReplyToStatusId] - The ID of the Tweet that this Tweet is in reply to.
143
- * @property { boolean } [isQuoted] - Indicates if this Tweet is a quote of another Tweet.
144
- * @property { boolean } [isPin] - Indicates if this Tweet is pinned.
145
- * @property { boolean } [isReply] - Indicates if this Tweet is a reply to another Tweet.
146
- * @property { boolean } [isRetweet] - Indicates if this Tweet is a retweet.
147
- * @property { boolean } [isSelfThread] - Indicates if this Tweet is part of a self thread.
148
- * @property { string } [language] - The language of the Tweet.
149
- * @property { number } [likes] - The number of likes on the Tweet.
150
- * @property { string } [name] - The name associated with the Tweet.
151
- * @property {Mention[]} mentions - An array of mentions in the Tweet.
152
- * @property { string } [permanentUrl] - The permanent URL of the Tweet.
153
- * @property {Photo[]} photos - An array of photos attached to the Tweet.
154
- * @property { PlaceRaw } [place] - The place associated with the Tweet.
155
- * @property { Tweet } [quotedStatus] - The quoted Tweet.
156
- * @property { string } [quotedStatusId] - The ID of the quoted Tweet.
157
- * @property { number } [quotes] - The number of times this Tweet has been quoted.
158
- * @property { number } [replies] - The number of replies to the Tweet.
159
- * @property { number } [retweets] - The number of retweets on the Tweet.
160
- * @property { Tweet } [retweetedStatus] - The status that was retweeted.
161
- * @property { string } [retweetedStatusId] - The ID of the retweeted status.
162
- * @property { string } [text] - The text content of the Tweet.
163
- * @property {Tweet[]} thread - An array representing a Twitter thread.
164
- * @property { Date } [timeParsed] - The parsed timestamp of the Tweet.
165
- * @property { number } [timestamp] - The timestamp of the Tweet.
166
- * @property {string[]} urls - An array of URLs mentioned in the Tweet.
167
- * @property { string } [userId] - The ID of the user who posted the Tweet.
168
- * @property { string } [username] - The username of the user who posted the Tweet.
169
- * @property {Video[]} videos - An array of videos attached to the Tweet.
170
- * @property { number } [views] - The number of views on the Tweet.
171
- * @property { boolean } [sensitiveContent] - Indicates if the Tweet contains sensitive content.
172
- * @property {PollV2 | null} [poll] - The poll attached to the Tweet, if any.
173
- */
174
- interface Tweet$1 {
175
- bookmarkCount?: number;
176
- conversationId?: string;
177
- hashtags: string[];
178
- html?: string;
179
- id?: string;
180
- inReplyToStatus?: Tweet$1;
181
- inReplyToStatusId?: string;
182
- isQuoted?: boolean;
183
- isPin?: boolean;
184
- isReply?: boolean;
185
- isRetweet?: boolean;
186
- isSelfThread?: boolean;
187
- language?: string;
188
- likes?: number;
189
- name?: string;
190
- mentions: Mention[];
191
- permanentUrl?: string;
192
- photos: Photo[];
193
- place?: PlaceRaw;
194
- quotedStatus?: Tweet$1;
195
- quotedStatusId?: string;
196
- quotes?: number;
197
- replies?: number;
198
- retweets?: number;
199
- retweetedStatus?: Tweet$1;
200
- retweetedStatusId?: string;
201
- text?: string;
202
- thread: Tweet$1[];
203
- timeParsed?: Date;
204
- timestamp?: number;
205
- urls: string[];
206
- userId?: string;
207
- username?: string;
208
- videos: Video[];
209
- views?: number;
210
- sensitiveContent?: boolean;
211
- poll?: PollV2 | null;
212
- }
213
- interface Retweeter {
214
- rest_id: string;
215
- screen_name: string;
216
- name: string;
217
- description?: string;
218
- }
219
- type TweetQuery = Partial<Tweet$1> | ((tweet: Tweet$1) => boolean | Promise<boolean>);
220
-
221
- /**
222
- * Common types for Twitter plugin API responses
223
- */
224
-
225
- /**
226
- * Response for paginated tweets queries
227
- */
228
- interface QueryTweetsResponse {
229
- tweets: Tweet$1[];
230
- next?: string;
231
- previous?: string;
232
- }
233
- /**
234
- * Response for paginated profiles queries
235
- */
236
- interface QueryProfilesResponse {
237
- profiles: Profile[];
238
- next?: string;
239
- previous?: string;
240
- }
241
- /**
242
- * Options for request transformation
243
- */
244
- interface FetchTransformOptions {
245
- /**
246
- * Transforms the request options before a request is made.
247
- */
248
- request: (...args: [input: RequestInfo | URL, init?: RequestInit]) => [input: RequestInfo | URL, init?: RequestInit] | Promise<[input: RequestInfo | URL, init?: RequestInit]>;
249
- /**
250
- * Transforms the response after a request completes.
251
- */
252
- response: (response: Response) => Response | Promise<Response>;
253
- }
254
-
255
- /**
256
- * A parsed profile object.
257
- */
258
- /**
259
- * Interface representing a user profile.
260
- * @typedef {Object} Profile
261
- * @property {string} [avatar] - The URL to the user's avatar.
262
- * @property {string} [banner] - The URL to the user's banner image.
263
- * @property {string} [biography] - The user's biography.
264
- * @property {string} [birthday] - The user's birthday.
265
- * @property {number} [followersCount] - The number of followers the user has.
266
- * @property {number} [followingCount] - The number of users the user is following.
267
- * @property {number} [friendsCount] - The number of friends the user has.
268
- * @property {number} [mediaCount] - The number of media items the user has posted.
269
- * @property {number} [statusesCount] - The number of statuses the user has posted.
270
- * @property {boolean} [isPrivate] - Indicates if the user's profile is private.
271
- * @property {boolean} [isVerified] - Indicates if the user account is verified.
272
- * @property {boolean} [isBlueVerified] - Indicates if the user account has blue verification badge.
273
- * @property {Date} [joined] - The date the user joined the platform.
274
- * @property {number} [likesCount] - The number of likes the user has received.
275
- * @property {number} [listedCount] - The number of times the user has been listed.
276
- * @property {string} location - The user's location.
277
- * @property {string} [name] - The user's name.
278
- * @property {string[]} [pinnedTweetIds] - The IDs of the user's pinned tweets.
279
- * @property {number} [tweetsCount] - The number of tweets the user has posted.
280
- * @property {string} [url] - The user's website URL.
281
- * @property {string} [userId] - The unique user ID.
282
- * @property {string} [username] - The user's username.
283
- * @property {string} [website] - The user's website.
284
- * @property {boolean} [canDm] - Indicates if the user can receive direct messages.
285
- */
286
- interface Profile {
287
- avatar?: string;
288
- banner?: string;
289
- biography?: string;
290
- birthday?: string;
291
- followersCount?: number;
292
- followingCount?: number;
293
- friendsCount?: number;
294
- mediaCount?: number;
295
- statusesCount?: number;
296
- isPrivate?: boolean;
297
- isVerified?: boolean;
298
- isBlueVerified?: boolean;
299
- joined?: Date;
300
- likesCount?: number;
301
- listedCount?: number;
302
- location: string;
303
- name?: string;
304
- pinnedTweetIds?: string[];
305
- tweetsCount?: number;
306
- url?: string;
307
- userId?: string;
308
- username?: string;
309
- website?: string;
310
- canDm?: boolean;
311
- }
312
-
313
- /**
314
- * The categories that can be used in Twitter searches.
315
- */
316
- /**
317
- * Enum representing different search modes.
318
- * @enum {number}
319
- */
320
- declare enum SearchMode {
321
- Top = 0,
322
- Latest = 1,
323
- Photos = 2,
324
- Videos = 3,
325
- Users = 4
326
- }
327
-
328
- /**
329
- * An alternative fetch function to use instead of the default fetch function. This may be useful
330
- * in nonstandard runtime environments, such as edge workers.
331
- *
332
- * @param {typeof fetch} fetch - The fetch function to use.
333
- *
334
- * @param {Partial<FetchTransformOptions>} transform - Additional options that control how requests
335
- * and responses are processed. This can be used to proxy requests through other hosts, for example.
336
- */
337
- interface ClientOptions {
338
- /**
339
- * An alternative fetch function to use instead of the default fetch function. This may be useful
340
- * in nonstandard runtime environments, such as edge workers.
341
- */
342
- fetch: typeof fetch;
343
- /**
344
- * Additional options that control how requests and responses are processed. This can be used to
345
- * proxy requests through other hosts, for example.
346
- */
347
- transform: Partial<FetchTransformOptions>;
348
- }
349
- /**
350
- * An interface to Twitter's API v2.
351
- * - Reusing Client objects is recommended to minimize the time spent authenticating unnecessarily.
352
- */
353
- declare class Client {
354
- private readonly options?;
355
- private auth?;
356
- /**
357
- * Creates a new Client object.
358
- * - Reusing Client objects is recommended to minimize the time spent authenticating unnecessarily.
359
- */
360
- constructor(options?: Partial<ClientOptions>);
361
- /**
362
- * Fetches a Twitter profile.
363
- * @param username The Twitter username of the profile to fetch, without an `@` at the beginning.
364
- * @returns The requested {@link Profile}.
365
- */
366
- getProfile(username: string): Promise<Profile>;
367
- /**
368
- * Fetches the user ID corresponding to the provided screen name.
369
- * @param screenName The Twitter screen name of the profile to fetch.
370
- * @returns The ID of the corresponding account.
371
- */
372
- getEntityIdByScreenName(screenName: string): Promise<string>;
373
- /**
374
- *
375
- * @param userId The user ID of the profile to fetch.
376
- * @returns The screen name of the corresponding account.
377
- */
378
- getScreenNameByUserId(userId: string): Promise<string>;
379
- /**
380
- * Fetches tweets from Twitter.
381
- * @param query The search query. Any Twitter-compatible query format can be used.
382
- * @param maxTweets The maximum number of tweets to return.
383
- * @param includeReplies Whether or not replies should be included in the response.
384
- * @param searchMode The category filter to apply to the search. Defaults to `Top`.
385
- * @returns An {@link AsyncGenerator} of tweets matching the provided filters.
386
- */
387
- searchTweets(query: string, maxTweets: number, searchMode?: SearchMode): AsyncGenerator<Tweet$1, void>;
388
- /**
389
- * Fetches profiles from Twitter.
390
- * @param query The search query. Any Twitter-compatible query format can be used.
391
- * @param maxProfiles The maximum number of profiles to return.
392
- * @returns An {@link AsyncGenerator} of tweets matching the provided filter(s).
393
- */
394
- searchProfiles(query: string, maxProfiles: number): AsyncGenerator<Profile, void>;
395
- /**
396
- * Fetches tweets from Twitter.
397
- * @param query The search query. Any Twitter-compatible query format can be used.
398
- * @param maxTweets The maximum number of tweets to return.
399
- * @param includeReplies Whether or not replies should be included in the response.
400
- * @param searchMode The category filter to apply to the search. Defaults to `Top`.
401
- * @param cursor The search cursor, which can be passed into further requests for more results.
402
- * @returns A page of results, containing a cursor that can be used in further requests.
403
- */
404
- fetchSearchTweets(query: string, maxTweets: number, searchMode: SearchMode, cursor?: string): Promise<QueryTweetsResponse>;
405
- /**
406
- * Fetches profiles from Twitter.
407
- * @param query The search query. Any Twitter-compatible query format can be used.
408
- * @param maxProfiles The maximum number of profiles to return.
409
- * @param cursor The search cursor, which can be passed into further requests for more results.
410
- * @returns A page of results, containing a cursor that can be used in further requests.
411
- */
412
- fetchSearchProfiles(query: string, maxProfiles: number, cursor?: string): Promise<QueryProfilesResponse>;
413
- /**
414
- * Fetches list tweets from Twitter.
415
- * @param listId The list id
416
- * @param maxTweets The maximum number of tweets to return.
417
- * @param cursor The search cursor, which can be passed into further requests for more results.
418
- * @returns A page of results, containing a cursor that can be used in further requests.
419
- */
420
- fetchListTweets(listId: string, maxTweets: number, cursor?: string): Promise<QueryTweetsResponse>;
421
- /**
422
- * Fetch the profiles a user is following
423
- * @param userId The user whose following should be returned
424
- * @param maxProfiles The maximum number of profiles to return.
425
- * @returns An {@link AsyncGenerator} of following profiles for the provided user.
426
- */
427
- getFollowing(userId: string, maxProfiles: number): AsyncGenerator<Profile, void>;
428
- /**
429
- * Fetch the profiles that follow a user
430
- * @param userId The user whose followers should be returned
431
- * @param maxProfiles The maximum number of profiles to return.
432
- * @returns An {@link AsyncGenerator} of profiles following the provided user.
433
- */
434
- getFollowers(userId: string, maxProfiles: number): AsyncGenerator<Profile, void>;
435
- /**
436
- * Fetches following profiles from Twitter.
437
- * @param userId The user whose following should be returned
438
- * @param maxProfiles The maximum number of profiles to return.
439
- * @param cursor The search cursor, which can be passed into further requests for more results.
440
- * @returns A page of results, containing a cursor that can be used in further requests.
441
- */
442
- fetchProfileFollowing(userId: string, maxProfiles: number, cursor?: string): Promise<QueryProfilesResponse>;
443
- /**
444
- * Fetches profile followers from Twitter.
445
- * @param userId The user whose following should be returned
446
- * @param maxProfiles The maximum number of profiles to return.
447
- * @param cursor The search cursor, which can be passed into further requests for more results.
448
- * @returns A page of results, containing a cursor that can be used in further requests.
449
- */
450
- fetchProfileFollowers(userId: string, maxProfiles: number, cursor?: string): Promise<QueryProfilesResponse>;
451
- /**
452
- * Fetches the home timeline for the current user using Twitter API v2.
453
- * Note: Twitter API v2 doesn't distinguish between "For You" and "Following" feeds.
454
- * @param count The number of tweets to fetch.
455
- * @param seenTweetIds An array of tweet IDs that have already been seen (not used in v2).
456
- * @returns A promise that resolves to an array of tweets.
457
- */
458
- fetchHomeTimeline(count: number, seenTweetIds: string[]): Promise<Tweet$1[]>;
459
- /**
460
- * Fetches the home timeline for the current user (same as fetchHomeTimeline in v2).
461
- * Twitter API v2 doesn't provide separate "Following" timeline endpoint.
462
- * @param count The number of tweets to fetch.
463
- * @param seenTweetIds An array of tweet IDs that have already been seen (not used in v2).
464
- * @returns A promise that resolves to an array of tweets.
465
- */
466
- fetchFollowingTimeline(count: number, seenTweetIds: string[]): Promise<Tweet$1[]>;
467
- getUserTweets(userId: string, maxTweets?: number, cursor?: string): Promise<{
468
- tweets: Tweet$1[];
469
- next?: string;
470
- }>;
471
- getUserTweetsIterator(userId: string, maxTweets?: number): AsyncGenerator<Tweet$1, void>;
472
- /**
473
- * Fetches the current trends from Twitter.
474
- * @returns The current list of trends.
475
- */
476
- getTrends(): Promise<string[]>;
477
- /**
478
- * Fetches tweets from a Twitter user.
479
- * @param user The user whose tweets should be returned.
480
- * @param maxTweets The maximum number of tweets to return. Defaults to `200`.
481
- * @returns An {@link AsyncGenerator} of tweets from the provided user.
482
- */
483
- getTweets(user: string, maxTweets?: number): AsyncGenerator<Tweet$1>;
484
- /**
485
- * Fetches tweets from a Twitter user using their ID.
486
- * @param userId The user whose tweets should be returned.
487
- * @param maxTweets The maximum number of tweets to return. Defaults to `200`.
488
- * @returns An {@link AsyncGenerator} of tweets from the provided user.
489
- */
490
- getTweetsByUserId(userId: string, maxTweets?: number): AsyncGenerator<Tweet$1, void>;
491
- /**
492
- * Send a tweet
493
- * @param text The text of the tweet
494
- * @param tweetId The id of the tweet to reply to
495
- * @param mediaData Optional media data
496
- * @returns
497
- */
498
- sendTweet(text: string, replyToTweetId?: string, mediaData?: {
499
- data: Buffer;
500
- mediaType: string;
501
- }[], hideLinkPreview?: boolean): Promise<{
502
- ok: boolean;
503
- json: () => Promise<twitter_api_v2.TweetV2PostTweetResult>;
504
- data: twitter_api_v2.TweetV2PostTweetResult;
505
- }>;
506
- sendNoteTweet(text: string, replyToTweetId?: string, mediaData?: {
507
- data: Buffer;
508
- mediaType: string;
509
- }[]): Promise<{
510
- ok: boolean;
511
- json: () => Promise<twitter_api_v2.TweetV2PostTweetResult>;
512
- data: twitter_api_v2.TweetV2PostTweetResult;
513
- }>;
514
- /**
515
- * Send a long tweet (Note Tweet)
516
- * @param text The text of the tweet
517
- * @param tweetId The id of the tweet to reply to
518
- * @param mediaData Optional media data
519
- * @returns
520
- */
521
- sendLongTweet(text: string, replyToTweetId?: string, mediaData?: {
522
- data: Buffer;
523
- mediaType: string;
524
- }[]): Promise<{
525
- ok: boolean;
526
- json: () => Promise<twitter_api_v2.TweetV2PostTweetResult>;
527
- data: twitter_api_v2.TweetV2PostTweetResult;
528
- }>;
529
- /**
530
- * Send a tweet
531
- * @param text The text of the tweet
532
- * @param tweetId The id of the tweet to reply to
533
- * @param options The options for the tweet
534
- * @returns
535
- */
536
- sendTweetV2(text: string, replyToTweetId?: string, options?: {
537
- poll?: PollData;
538
- }): Promise<Tweet$1>;
539
- /**
540
- * Fetches tweets and replies from a Twitter user.
541
- * @param user The user whose tweets should be returned.
542
- * @param maxTweets The maximum number of tweets to return. Defaults to `200`.
543
- * @returns An {@link AsyncGenerator} of tweets from the provided user.
544
- */
545
- getTweetsAndReplies(user: string, maxTweets?: number): AsyncGenerator<Tweet$1>;
546
- /**
547
- * Fetches tweets and replies from a Twitter user using their ID.
548
- * @param userId The user whose tweets should be returned.
549
- * @param maxTweets The maximum number of tweets to return. Defaults to `200`.
550
- * @returns An {@link AsyncGenerator} of tweets from the provided user.
551
- */
552
- getTweetsAndRepliesByUserId(userId: string, maxTweets?: number): AsyncGenerator<Tweet$1, void>;
553
- /**
554
- * Fetches the first tweet matching the given query.
555
- *
556
- * Example:
557
- * ```js
558
- * const timeline = client.getTweets('user', 200);
559
- * const retweet = await client.getTweetWhere(timeline, { isRetweet: true });
560
- * ```
561
- * @param tweets The {@link AsyncIterable} of tweets to search through.
562
- * @param query A query to test **all** tweets against. This may be either an
563
- * object of key/value pairs or a predicate. If this query is an object, all
564
- * key/value pairs must match a {@link Tweet} for it to be returned. If this query
565
- * is a predicate, it must resolve to `true` for a {@link Tweet} to be returned.
566
- * - All keys are optional.
567
- * - If specified, the key must be implemented by that of {@link Tweet}.
568
- */
569
- getTweetWhere(tweets: AsyncIterable<Tweet$1>, query: TweetQuery): Promise<Tweet$1 | null>;
570
- /**
571
- * Fetches all tweets matching the given query.
572
- *
573
- * Example:
574
- * ```js
575
- * const timeline = client.getTweets('user', 200);
576
- * const retweets = await client.getTweetsWhere(timeline, { isRetweet: true });
577
- * ```
578
- * @param tweets The {@link AsyncIterable} of tweets to search through.
579
- * @param query A query to test **all** tweets against. This may be either an
580
- * object of key/value pairs or a predicate. If this query is an object, all
581
- * key/value pairs must match a {@link Tweet} for it to be returned. If this query
582
- * is a predicate, it must resolve to `true` for a {@link Tweet} to be returned.
583
- * - All keys are optional.
584
- * - If specified, the key must be implemented by that of {@link Tweet}.
585
- */
586
- getTweetsWhere(tweets: AsyncIterable<Tweet$1>, query: TweetQuery): Promise<Tweet$1[]>;
587
- /**
588
- * Fetches the most recent tweet from a Twitter user.
589
- * @param user The user whose latest tweet should be returned.
590
- * @param includeRetweets Whether or not to include retweets. Defaults to `false`.
591
- * @returns The {@link Tweet} object or `null`/`undefined` if it couldn't be fetched.
592
- */
593
- getLatestTweet(user: string, includeRetweets?: boolean, max?: number): Promise<Tweet$1 | null | undefined>;
594
- /**
595
- * Fetches a single tweet.
596
- * @param id The ID of the tweet to fetch.
597
- * @returns The {@link Tweet} object, or `null` if it couldn't be fetched.
598
- */
599
- getTweet(id: string): Promise<Tweet$1 | null>;
600
- /**
601
- * Fetches a single tweet by ID using the Twitter API v2.
602
- * Allows specifying optional expansions and fields for more detailed data.
603
- *
604
- * @param {string} id - The ID of the tweet to fetch.
605
- * @param {Object} [options] - Optional parameters to customize the tweet data.
606
- * @param {string[]} [options.expansions] - Array of expansions to include, e.g., 'attachments.poll_ids'.
607
- * @param {string[]} [options.tweetFields] - Array of tweet fields to include, e.g., 'created_at', 'public_metrics'.
608
- * @param {string[]} [options.pollFields] - Array of poll fields to include, if the tweet has a poll, e.g., 'options', 'end_datetime'.
609
- * @param {string[]} [options.mediaFields] - Array of media fields to include, if the tweet includes media, e.g., 'url', 'preview_image_url'.
610
- * @param {string[]} [options.userFields] - Array of user fields to include, if user information is requested, e.g., 'username', 'verified'.
611
- * @param {string[]} [options.placeFields] - Array of place fields to include, if the tweet includes location data, e.g., 'full_name', 'country'.
612
- * @returns {Promise<TweetV2 | null>} - The tweet data, including requested expansions and fields.
613
- */
614
- getTweetV2(id: string, options?: {
615
- expansions?: TTweetv2Expansion[];
616
- tweetFields?: TTweetv2TweetField[];
617
- pollFields?: TTweetv2PollField[];
618
- mediaFields?: TTweetv2MediaField[];
619
- userFields?: TTweetv2UserField[];
620
- placeFields?: TTweetv2PlaceField[];
621
- }): Promise<Tweet$1 | null>;
622
- /**
623
- * Fetches multiple tweets by IDs using the Twitter API v2.
624
- * Allows specifying optional expansions and fields for more detailed data.
625
- *
626
- * @param {string[]} ids - Array of tweet IDs to fetch.
627
- * @param {Object} [options] - Optional parameters to customize the tweet data.
628
- * @param {string[]} [options.expansions] - Array of expansions to include, e.g., 'attachments.poll_ids'.
629
- * @param {string[]} [options.tweetFields] - Array of tweet fields to include, e.g., 'created_at', 'public_metrics'.
630
- * @param {string[]} [options.pollFields] - Array of poll fields to include, if tweets contain polls, e.g., 'options', 'end_datetime'.
631
- * @param {string[]} [options.mediaFields] - Array of media fields to include, if tweets contain media, e.g., 'url', 'preview_image_url'.
632
- * @param {string[]} [options.userFields] - Array of user fields to include, if user information is requested, e.g., 'username', 'verified'.
633
- * @param {string[]} [options.placeFields] - Array of place fields to include, if tweets contain location data, e.g., 'full_name', 'country'.
634
- * @returns {Promise<TweetV2[]> } - Array of tweet data, including requested expansions and fields.
635
- */
636
- getTweetsV2(ids: string[], options?: {
637
- expansions?: TTweetv2Expansion[];
638
- tweetFields?: TTweetv2TweetField[];
639
- pollFields?: TTweetv2PollField[];
640
- mediaFields?: TTweetv2MediaField[];
641
- userFields?: TTweetv2UserField[];
642
- placeFields?: TTweetv2PlaceField[];
643
- }): Promise<Tweet$1[]>;
644
- /**
645
- * Updates the authentication state for the client.
646
- * @param auth The new authentication.
647
- */
648
- updateAuth(auth: TwitterAuth): void;
649
- /**
650
- * Get current authentication credentials
651
- * @returns {TwitterAuth | null} Current authentication or null if not authenticated
652
- */
653
- getAuth(): TwitterAuth | null;
654
- /**
655
- * Check if client is properly authenticated with Twitter API v2 credentials
656
- * @returns {boolean} True if authenticated
657
- */
658
- isAuthenticated(): boolean;
659
- /**
660
- * Returns if the client is logged in as a real user.
661
- * @returns `true` if the client is logged in with a real user account; otherwise `false`.
662
- */
663
- isLoggedIn(): Promise<boolean>;
664
- /**
665
- * Returns the currently logged in user
666
- * @returns The currently logged in user
667
- */
668
- me(): Promise<Profile | undefined>;
669
- /**
670
- * Login to Twitter using API v2 credentials only.
671
- * @param appKey The API key
672
- * @param appSecret The API secret key
673
- * @param accessToken The access token
674
- * @param accessSecret The access token secret
675
- */
676
- login(username: string, password: string, email?: string, twoFactorSecret?: string, appKey?: string, appSecret?: string, accessToken?: string, accessSecret?: string): Promise<void>;
677
- /**
678
- * Log out of Twitter.
679
- * Note: With API v2, logout is not applicable as we use API credentials.
680
- */
681
- logout(): Promise<void>;
682
- /**
683
- * Sends a quote tweet.
684
- * @param text The text of the tweet.
685
- * @param quotedTweetId The ID of the tweet to quote.
686
- * @param options Optional parameters, such as media data.
687
- * @returns The response from the Twitter API.
688
- */
689
- sendQuoteTweet(text: string, quotedTweetId: string, options?: {
690
- mediaData: {
691
- data: Buffer;
692
- mediaType: string;
693
- }[];
694
- }): Promise<{
695
- ok: boolean;
696
- json: () => Promise<twitter_api_v2.TweetV2PostTweetResult>;
697
- data: twitter_api_v2.TweetV2PostTweetResult;
698
- }>;
699
- /**
700
- * Delete a tweet with the given ID.
701
- * @param tweetId The ID of the tweet to delete.
702
- * @returns A promise that resolves when the tweet is deleted.
703
- */
704
- deleteTweet(tweetId: string): Promise<any>;
705
- /**
706
- * Likes a tweet with the given tweet ID.
707
- * @param tweetId The ID of the tweet to like.
708
- * @returns A promise that resolves when the tweet is liked.
709
- */
710
- likeTweet(tweetId: string): Promise<void>;
711
- /**
712
- * Retweets a tweet with the given tweet ID.
713
- * @param tweetId The ID of the tweet to retweet.
714
- * @returns A promise that resolves when the tweet is retweeted.
715
- */
716
- retweet(tweetId: string): Promise<void>;
717
- /**
718
- * Follows a user with the given user ID.
719
- * @param userId The user ID of the user to follow.
720
- * @returns A promise that resolves when the user is followed.
721
- */
722
- followUser(userName: string): Promise<void>;
723
- /**
724
- * Fetches direct message conversations
725
- * Note: This functionality requires additional permissions and is not implemented in the current Twitter API v2 wrapper
726
- * @param userId User ID
727
- * @param cursor Pagination cursor
728
- * @returns Array of DM conversations
729
- */
730
- getDirectMessageConversations(userId: string, cursor?: string): Promise<any>;
731
- /**
732
- * Sends a direct message to a user.
733
- * Note: This functionality requires additional permissions and is not implemented in the current Twitter API v2 wrapper
734
- * @param conversationId The ID of the conversation
735
- * @param text The text of the message
736
- * @returns The response from the Twitter API
737
- */
738
- sendDirectMessage(conversationId: string, text: string): Promise<any>;
739
- private getAuthOptions;
740
- private handleResponse;
741
- /**
742
- * Retrieves all users who retweeted the given tweet.
743
- * @param tweetId The ID of the tweet.
744
- * @returns An array of users (retweeters).
745
- */
746
- getRetweetersOfTweet(tweetId: string): Promise<Retweeter[]>;
747
- /**
748
- * Fetches all quoted tweets for a given tweet ID, handling pagination automatically.
749
- * @param tweetId The ID of the tweet to fetch quotes for.
750
- * @param maxQuotes Maximum number of quotes to return (default: 100).
751
- * @returns An array of all quoted tweets.
752
- */
753
- fetchAllQuotedTweets(tweetId: string, maxQuotes?: number): Promise<Tweet$1[]>;
754
- /**
755
- * Fetches quoted tweets for a given tweet ID.
756
- * This method now uses a generator function internally but maintains backward compatibility.
757
- * @param tweetId The ID of the tweet to fetch quotes for.
758
- * @param maxQuotes Maximum number of quotes to return.
759
- * @param cursor Optional cursor for pagination.
760
- * @returns A promise that resolves to a QueryTweetsResponse containing tweets and the next cursor.
761
- */
762
- fetchQuotedTweetsPage(tweetId: string, maxQuotes?: number, cursor?: string): Promise<QueryTweetsResponse>;
763
- }
764
-
765
- /**
766
- * Class representing a Twitter post client for generating and posting tweets.
767
- */
768
- declare class TwitterPostClient {
769
- client: ClientBase;
770
- runtime: IAgentRuntime;
771
- twitterUsername: string;
772
- private isDryRun;
773
- private state;
774
- private isRunning;
775
- /**
776
- * Constructor for initializing a new Twitter client with the provided client, runtime, and state
777
- * @param {ClientBase} client - The client used for interacting with Twitter API
778
- * @param {IAgentRuntime} runtime - The runtime environment for the agent
779
- * @param {any} state - The state object containing configuration settings
780
- */
781
- constructor(client: ClientBase, runtime: IAgentRuntime, state: any);
782
- /**
783
- * Stops the Twitter post client
784
- */
785
- stop(): Promise<void>;
786
- /**
787
- * Starts the Twitter post client, setting up a loop to periodically generate new tweets.
788
- */
789
- start(): Promise<void>;
790
- /**
791
- * Handles the creation and posting of a tweet by emitting standardized events.
792
- * This approach aligns with our platform-independent architecture.
793
- */
794
- generateNewTweet(): Promise<void>;
795
- /**
796
- * Posts content to Twitter
797
- * @param {string} text The tweet text to post
798
- * @param {MediaData[]} mediaData Optional media to attach to the tweet
799
- * @returns {Promise<any>} The result from the Twitter API
800
- */
801
- private postToTwitter;
802
- }
803
-
804
- /**
805
- * @interface ITwitterClient
806
- * Represents the main Twitter client interface for interacting with Twitter's API.
807
- * @property {ClientBase} client - The base client for Twitter operations.
808
- * @property {TwitterPostClient} post - The client for managing Twitter posts.
809
- * @property {TwitterInteractionClient} interaction - The client for managing Twitter interactions.
810
- */
811
- interface ITwitterClient {
812
- client: ClientBase;
813
- post: TwitterPostClient;
814
- interaction: TwitterInteractionClient;
815
- }
816
- /**
817
- * Twitter-specific tweet type
818
- */
819
- type Tweet = {
820
- id: string;
821
- text: string;
822
- userId: string;
823
- username: string;
824
- name: string;
825
- conversationId: string;
826
- inReplyToStatusId?: string;
827
- timestamp: number;
828
- photos: {
829
- url: string;
830
- }[];
831
- mentions: string[];
832
- hashtags: string[];
833
- urls: string[];
834
- videos: any[];
835
- thread: any[];
836
- permanentUrl: string;
837
- };
838
- /**
839
- * Twitter-specific memory interface
840
- */
841
- interface TwitterMemory extends Memory {
842
- content: {
843
- source: "twitter";
844
- text?: string;
845
- type?: string;
846
- targetId?: string;
847
- [key: string]: any;
848
- };
849
- roomId: UUID;
850
- }
851
- /**
852
- * Twitter-specific interaction memory
853
- */
854
- interface TwitterInteractionMemory extends TwitterMemory {
855
- content: {
856
- type: string;
857
- source: "twitter";
858
- targetId?: string;
859
- };
860
- }
861
- /**
862
- * Twitter-specific interaction payload
863
- */
864
- interface TwitterInteractionPayload {
865
- id: string;
866
- type: "like" | "retweet" | "quote";
867
- userId: string;
868
- username: string;
869
- name: string;
870
- targetTweetId: string;
871
- targetTweet: Tweet;
872
- quoteTweet?: Tweet;
873
- retweetId?: string;
874
- }
875
-
876
- /**
877
- * Represents a Twitter Profile.
878
- * @typedef {Object} TwitterProfile
879
- * @property {string} id - The unique identifier of the profile.
880
- * @property {string} username - The username of the profile.
881
- * @property {string} screenName - The screen name of the profile.
882
- * @property {string} bio - The biography of the profile.
883
- * @property {string[]} nicknames - An array of nicknames associated with the profile.
884
- */
885
- type TwitterProfile = {
886
- id: string;
887
- username: string;
888
- screenName: string;
889
- bio: string;
890
- nicknames: string[];
891
- };
892
- /**
893
- * Class representing a request queue for handling asynchronous requests in a controlled manner.
894
- */
895
- declare class RequestQueue {
896
- private queue;
897
- private processing;
898
- private maxRetries;
899
- private retryAttempts;
900
- /**
901
- * Asynchronously adds a request to the queue, then processes the queue.
902
- *
903
- * @template T
904
- * @param {() => Promise<T>} request - The request to be added to the queue
905
- * @returns {Promise<T>} - A promise that resolves with the result of the request or rejects with an error
906
- */
907
- add<T>(request: () => Promise<T>): Promise<T>;
908
- /**
909
- * Asynchronously processes the queue of requests.
910
- *
911
- * @returns A promise that resolves when the queue has been fully processed.
912
- */
913
- private processQueue;
914
- /**
915
- * Implements an exponential backoff strategy for retrying a task.
916
- * @param {number} retryCount - The number of retries attempted so far.
917
- * @returns {Promise<void>} - A promise that resolves after a delay based on the retry count.
918
- */
919
- private exponentialBackoff;
920
- /**
921
- * Asynchronous method that creates a random delay between 1500ms and 3500ms.
922
- *
923
- * @returns A Promise that resolves after the random delay has passed.
924
- */
925
- private randomDelay;
926
- }
927
- /**
928
- * Class representing a base client for interacting with Twitter.
929
- * @extends EventEmitter
930
- */
931
- declare class ClientBase {
932
- static _twitterClients: {
933
- [accountIdentifier: string]: Client;
934
- };
935
- twitterClient: Client;
936
- runtime: IAgentRuntime;
937
- lastCheckedTweetId: bigint | null;
938
- temperature: number;
939
- requestQueue: RequestQueue;
940
- profile: TwitterProfile | null;
941
- /**
942
- * Caches a tweet in the database.
943
- *
944
- * @param {Tweet} tweet - The tweet to cache.
945
- * @returns {Promise<void>} A promise that resolves once the tweet is cached.
946
- */
947
- cacheTweet(tweet: Tweet$1): Promise<void>;
948
- /**
949
- * Retrieves a cached tweet by its ID.
950
- * @param {string} tweetId - The ID of the tweet to retrieve from the cache.
951
- * @returns {Promise<Tweet | undefined>} A Promise that resolves to the cached tweet, or undefined if the tweet is not found in the cache.
952
- */
953
- getCachedTweet(tweetId: string): Promise<Tweet$1 | undefined>;
954
- /**
955
- * Asynchronously retrieves a tweet with the specified ID.
956
- * If the tweet is found in the cache, it is returned from the cache.
957
- * If not, a request is made to the Twitter API to get the tweet, which is then cached and returned.
958
- * @param {string} tweetId - The ID of the tweet to retrieve.
959
- * @returns {Promise<Tweet>} A Promise that resolves to the retrieved tweet.
960
- */
961
- getTweet(tweetId: string): Promise<Tweet$1>;
962
- callback: (self: ClientBase) => any;
963
- /**
964
- * This method is called when the application is ready.
965
- * It throws an error indicating that it is not implemented in the base class
966
- * and should be implemented in the subclass.
967
- */
968
- onReady(): void;
969
- /**
970
- * Parse the raw tweet data into a standardized Tweet object.
971
- */
972
- /**
973
- * Parses a raw tweet object into a structured Tweet object.
974
- *
975
- * @param {any} raw - The raw tweet object to parse.
976
- * @param {number} [depth=0] - The current depth of parsing nested quotes/retweets.
977
- * @param {number} [maxDepth=3] - The maximum depth allowed for parsing nested quotes/retweets.
978
- * @returns {Tweet} The parsed Tweet object.
979
- */
980
- state: any;
981
- constructor(runtime: IAgentRuntime, state: any);
982
- init(): Promise<void>;
983
- fetchOwnPosts(count: number): Promise<Tweet$1[]>;
984
- /**
985
- * Fetch timeline for twitter account, optionally only from followed accounts
986
- */
987
- fetchHomeTimeline(count: number, following?: boolean): Promise<Tweet$1[]>;
988
- fetchSearchTweets(query: string, maxTweets: number, searchMode: SearchMode, cursor?: string): Promise<QueryTweetsResponse>;
989
- private populateTimeline;
990
- saveRequestMessage(message: Memory, state: State): Promise<void>;
991
- loadLatestCheckedTweetId(): Promise<void>;
992
- cacheLatestCheckedTweetId(): Promise<void>;
993
- getCachedTimeline(): Promise<Tweet$1[] | undefined>;
994
- cacheTimeline(timeline: Tweet$1[]): Promise<void>;
995
- cacheMentions(mentions: Tweet$1[]): Promise<void>;
996
- fetchProfile(username: string): Promise<TwitterProfile>;
997
- /**
998
- * Fetches recent interactions (likes, retweets, quotes) for the authenticated user's tweets
999
- */
1000
- fetchInteractions(): Promise<TwitterInteractionPayload[]>;
1001
- formatTweetToInteraction(tweet: any): TwitterInteractionPayload | null;
1002
- }
1003
-
1004
- /**
1005
- * The TwitterInteractionClient class manages Twitter interactions,
1006
- * including handling mentions, managing timelines, and engaging with other users.
1007
- * It extends the base Twitter client functionality to provide mention handling,
1008
- * user interaction, and follow change detection capabilities.
1009
- *
1010
- * @extends ClientBase
1011
- */
1012
- declare class TwitterInteractionClient {
1013
- client: ClientBase;
1014
- runtime: IAgentRuntime;
1015
- twitterUsername: string;
1016
- private twitterUserId;
1017
- private isDryRun;
1018
- private state;
1019
- private isRunning;
1020
- private lastProcessedTimestamp;
1021
- /**
1022
- * Constructor to initialize the Twitter interaction client with runtime and state management.
1023
- *
1024
- * @param {ClientBase} client - The client instance.
1025
- * @param {IAgentRuntime} runtime - The runtime instance for agent operations.
1026
- * @param {any} state - The state object containing configuration settings.
1027
- */
1028
- constructor(client: ClientBase, runtime: IAgentRuntime, state: any);
1029
- /**
1030
- * Asynchronously starts the process of handling Twitter interactions on a loop.
1031
- * Uses the unified TWITTER_ENGAGEMENT_INTERVAL setting.
1032
- */
1033
- start(): Promise<void>;
1034
- /**
1035
- * Stops the Twitter interaction client
1036
- */
1037
- stop(): Promise<void>;
1038
- /**
1039
- * Asynchronously handles Twitter interactions by checking for mentions and target user posts.
1040
- */
1041
- handleTwitterInteractions(): Promise<void>;
1042
- /**
1043
- * Handle mentions and replies
1044
- */
1045
- private handleMentions;
1046
- /**
1047
- * Handle autonomous engagement with target users' posts
1048
- */
1049
- private handleTargetUserPosts;
1050
- /**
1051
- * Process tweets from target users for potential engagement
1052
- */
1053
- private processTargetUserTweets;
1054
- /**
1055
- * Process timeline for engagement when wildcard is configured
1056
- */
1057
- private processTimelineForEngagement;
1058
- /**
1059
- * Determine if the bot should engage with a specific tweet
1060
- */
1061
- private shouldEngageWithTweet;
1062
- /**
1063
- * Ensure tweet context exists (world, room, entity)
1064
- */
1065
- private ensureTweetContext;
1066
- /**
1067
- * Engage with a tweet by generating and sending a reply
1068
- */
1069
- private engageWithTweet;
1070
- /**
1071
- * Processes all incoming tweets that mention the bot.
1072
- * For each new tweet:
1073
- * - Ensures world, room, and connection exist
1074
- * - Saves the tweet as memory
1075
- * - Emits thread-related events (THREAD_CREATED / THREAD_UPDATED)
1076
- * - Delegates tweet content to `handleTweet` for reply generation
1077
- *
1078
- * Note: MENTION_RECEIVED is currently disabled (see TODO below)
1079
- */
1080
- processMentionTweets(mentionCandidates: Tweet$1[]): Promise<void>;
1081
- /**
1082
- * Handles Twitter interactions such as likes, retweets, and quotes.
1083
- * For each interaction:
1084
- * - Creates a memory object
1085
- * - Emits platform-specific events (LIKE_RECEIVED, RETWEET_RECEIVED, QUOTE_RECEIVED)
1086
- * - Emits a generic REACTION_RECEIVED event with metadata
1087
- */
1088
- handleInteraction(interaction: TwitterInteractionPayload): Promise<void>;
1089
- /**
1090
- * Creates a memory object for a given Twitter interaction.
1091
- *
1092
- * @param {string} type - The type of interaction (e.g., 'like', 'retweet', 'quote').
1093
- * @param {string} id - The unique identifier for the interaction.
1094
- * @param {string} userId - The ID of the user who initiated the interaction.
1095
- * @param {string} conversationId - The ID of the conversation context.
1096
- * @returns {TwitterInteractionMemory} The constructed memory object.
1097
- */
1098
- createMemoryObject(type: string, id: string, userId: string, conversationId: string): TwitterInteractionMemory;
1099
- /**
1100
- * Asynchronously handles a tweet by generating a response and sending it.
1101
- * This method processes the tweet content, determines if a response is needed,
1102
- * generates appropriate response text, and sends the tweet reply.
1103
- *
1104
- * @param {object} params - The parameters object containing the tweet, message, and thread.
1105
- * @param {Tweet} params.tweet - The tweet object to handle.
1106
- * @param {Memory} params.message - The memory object associated with the tweet.
1107
- * @param {Tweet[]} params.thread - The array of tweets in the thread.
1108
- * @returns {object} - An object containing the text of the response and any relevant actions.
1109
- */
1110
- handleTweet({ tweet, message, thread, }: {
1111
- tweet: Tweet$1;
1112
- message: Memory;
1113
- thread: Tweet$1[];
1114
- }): Promise<{
1115
- text: string;
1116
- actions: string[];
1117
- }>;
1118
- }
1119
-
1120
- declare enum TIMELINE_TYPE {
1121
- ForYou = "foryou",
1122
- Following = "following"
1123
- }
1124
- declare class TwitterTimelineClient {
1125
- client: ClientBase;
1126
- twitterClient: Client;
1127
- runtime: IAgentRuntime;
1128
- isDryRun: boolean;
1129
- timelineType: TIMELINE_TYPE;
1130
- private state;
1131
- private isRunning;
1132
- constructor(client: ClientBase, runtime: IAgentRuntime, state: any);
1133
- start(): Promise<void>;
1134
- stop(): Promise<void>;
1135
- getTimeline(count: number): Promise<Tweet$1[]>;
1136
- createTweetId(runtime: IAgentRuntime, tweet: Tweet$1): `${string}-${string}-${string}-${string}-${string}`;
1137
- formMessage(runtime: IAgentRuntime, tweet: Tweet$1): {
1138
- id: `${string}-${string}-${string}-${string}-${string}`;
1139
- agentId: `${string}-${string}-${string}-${string}-${string}`;
1140
- content: {
1141
- text: string;
1142
- url: string;
1143
- imageUrls: string[];
1144
- inReplyTo: `${string}-${string}-${string}-${string}-${string}`;
1145
- source: string;
1146
- channelType: ChannelType;
1147
- tweet: Tweet$1;
1148
- };
1149
- entityId: `${string}-${string}-${string}-${string}-${string}`;
1150
- roomId: `${string}-${string}-${string}-${string}-${string}`;
1151
- createdAt: number;
1152
- };
1153
- handleTimeline(): Promise<void>;
1154
- private processTimelineActions;
1155
- private ensureTweetWorldContext;
1156
- handleLikeAction(tweet: Tweet$1): Promise<void>;
1157
- handleRetweetAction(tweet: Tweet$1): Promise<void>;
1158
- handleQuoteAction(tweet: Tweet$1): Promise<void>;
1159
- handleReplyAction(tweet: Tweet$1): Promise<void>;
1160
- }
1161
-
1162
- declare class TwitterDiscoveryClient {
1163
- private client;
1164
- private twitterClient;
1165
- private runtime;
1166
- private config;
1167
- private isRunning;
1168
- private isDryRun;
1169
- constructor(client: ClientBase, runtime: IAgentRuntime, state: any);
1170
- private buildDiscoveryConfig;
1171
- private extractTopicsFromBio;
1172
- start(): Promise<void>;
1173
- stop(): Promise<void>;
1174
- private runDiscoveryCycle;
1175
- private discoverContent;
1176
- private discoverFromTopics;
1177
- private discoverFromThreads;
1178
- private discoverFromPopularAccounts;
1179
- private scoreTweet;
1180
- private scoreAccount;
1181
- private processAccounts;
1182
- private processTweets;
1183
- private checkIfFollowing;
1184
- private generateReply;
1185
- private generateQuote;
1186
- private saveEngagementMemory;
1187
- private saveFollowMemory;
1188
- private delay;
1189
- }
1190
-
1191
- declare class TwitterService extends Service {
1192
- static serviceType: string;
1193
- capabilityDescription: string;
1194
- constructor();
1195
- static start(runtime: IAgentRuntime): Promise<TwitterService>;
1196
- stop(): Promise<void>;
1197
- }
1198
-
1199
- /**
1200
- * A manager that orchestrates all specialized Twitter logic:
1201
- * - client: base operations (login, timeline caching, etc.)
1202
- * - post: autonomous posting logic
1203
- * - interaction: handling mentions, replies, and autonomous targeting
1204
- * - timeline: processing timeline for actions (likes, retweets, replies)
1205
- * - discovery: autonomous content discovery and engagement
1206
- */
1207
- declare class TwitterClientInstance implements ITwitterClient {
1208
- client: ClientBase;
1209
- post: TwitterPostClient;
1210
- interaction: TwitterInteractionClient;
1211
- timeline?: TwitterTimelineClient;
1212
- discovery?: TwitterDiscoveryClient;
1213
- constructor(runtime: IAgentRuntime, state: any);
1214
- }
1215
- declare function startTwitterClient(runtime: IAgentRuntime): Promise<void>;
1216
- declare const TwitterPlugin: {
1217
- name: string;
1218
- description: string;
1219
- actions: _elizaos_core.Action[];
1220
- services: (typeof TwitterService)[];
1221
- init: typeof startTwitterClient;
1222
- };
1223
-
1224
- export { TwitterClientInstance, TwitterPlugin, TwitterPlugin as default };
5
+ export { TwitterPlugin, TwitterPlugin as default };