@elizaos/plugin-twitter 1.0.13 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +277 -133
- package/dist/index.d.ts +102 -169
- package/dist/index.js +588 -1261
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -37,146 +37,6 @@ declare class TwitterAuth {
|
|
|
37
37
|
hasToken(): boolean;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
/**
|
|
41
|
-
* Represents an array type for parameters used in the fetch function,
|
|
42
|
-
* with the first element being input of type RequestInfo or URL,
|
|
43
|
-
* and the second element being init of type RequestInit or optional if not provided.
|
|
44
|
-
*/
|
|
45
|
-
type FetchParameters = [input: RequestInfo | URL, init?: RequestInit];
|
|
46
|
-
/**
|
|
47
|
-
* @typedef {Object} FetchTransformOptions
|
|
48
|
-
* @property {Function} request Transforms the request options before a request is made. This executes after all of the default
|
|
49
|
-
* parameters have been configured, and is stateless. It is safe to return new request options
|
|
50
|
-
* objects.
|
|
51
|
-
* @param {FetchParameters} args The request options.
|
|
52
|
-
* @returns {FetchParameters|Promise<FetchParameters>} The transformed request options.
|
|
53
|
-
*
|
|
54
|
-
* @property {Function} response Transforms the response after a request completes. This executes immediately after the request
|
|
55
|
-
* completes, and is stateless. It is safe to return a new response object.
|
|
56
|
-
* @param {Response} response The response object.
|
|
57
|
-
* @returns {Response|Promise<Response>} The transformed response object.
|
|
58
|
-
*/
|
|
59
|
-
interface FetchTransformOptions {
|
|
60
|
-
/**
|
|
61
|
-
* Transforms the request options before a request is made. This executes after all of the default
|
|
62
|
-
* parameters have been configured, and is stateless. It is safe to return new request options
|
|
63
|
-
* objects.
|
|
64
|
-
* @param args The request options.
|
|
65
|
-
* @returns The transformed request options.
|
|
66
|
-
*/
|
|
67
|
-
request: (...args: FetchParameters) => FetchParameters | Promise<FetchParameters>;
|
|
68
|
-
/**
|
|
69
|
-
* Transforms the response after a request completes. This executes immediately after the request
|
|
70
|
-
* completes, and is stateless. It is safe to return a new response object.
|
|
71
|
-
* @param response The response object.
|
|
72
|
-
* @returns The transformed response object.
|
|
73
|
-
*/
|
|
74
|
-
response: (response: Response) => Response | Promise<Response>;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* A parsed profile object.
|
|
79
|
-
*/
|
|
80
|
-
/**
|
|
81
|
-
* Interface representing a user profile.
|
|
82
|
-
* @typedef {Object} Profile
|
|
83
|
-
* @property {string} [avatar] - The URL to the user's avatar.
|
|
84
|
-
* @property {string} [banner] - The URL to the user's banner image.
|
|
85
|
-
* @property {string} [biography] - The user's biography.
|
|
86
|
-
* @property {string} [birthday] - The user's birthday.
|
|
87
|
-
* @property {number} [followersCount] - The number of followers the user has.
|
|
88
|
-
* @property {number} [followingCount] - The number of users the user is following.
|
|
89
|
-
* @property {number} [friendsCount] - The number of friends the user has.
|
|
90
|
-
* @property {number} [mediaCount] - The number of media items the user has posted.
|
|
91
|
-
* @property {number} [statusesCount] - The number of statuses the user has posted.
|
|
92
|
-
* @property {boolean} [isPrivate] - Indicates if the user's profile is private.
|
|
93
|
-
* @property {boolean} [isVerified] - Indicates if the user account is verified.
|
|
94
|
-
* @property {boolean} [isBlueVerified] - Indicates if the user account has blue verification badge.
|
|
95
|
-
* @property {Date} [joined] - The date the user joined the platform.
|
|
96
|
-
* @property {number} [likesCount] - The number of likes the user has received.
|
|
97
|
-
* @property {number} [listedCount] - The number of times the user has been listed.
|
|
98
|
-
* @property {string} location - The user's location.
|
|
99
|
-
* @property {string} [name] - The user's name.
|
|
100
|
-
* @property {string[]} [pinnedTweetIds] - The IDs of the user's pinned tweets.
|
|
101
|
-
* @property {number} [tweetsCount] - The number of tweets the user has posted.
|
|
102
|
-
* @property {string} [url] - The user's website URL.
|
|
103
|
-
* @property {string} [userId] - The unique user ID.
|
|
104
|
-
* @property {string} [username] - The user's username.
|
|
105
|
-
* @property {string} [website] - The user's website.
|
|
106
|
-
* @property {boolean} [canDm] - Indicates if the user can receive direct messages.
|
|
107
|
-
*/
|
|
108
|
-
interface Profile {
|
|
109
|
-
avatar?: string;
|
|
110
|
-
banner?: string;
|
|
111
|
-
biography?: string;
|
|
112
|
-
birthday?: string;
|
|
113
|
-
followersCount?: number;
|
|
114
|
-
followingCount?: number;
|
|
115
|
-
friendsCount?: number;
|
|
116
|
-
mediaCount?: number;
|
|
117
|
-
statusesCount?: number;
|
|
118
|
-
isPrivate?: boolean;
|
|
119
|
-
isVerified?: boolean;
|
|
120
|
-
isBlueVerified?: boolean;
|
|
121
|
-
joined?: Date;
|
|
122
|
-
likesCount?: number;
|
|
123
|
-
listedCount?: number;
|
|
124
|
-
location: string;
|
|
125
|
-
name?: string;
|
|
126
|
-
pinnedTweetIds?: string[];
|
|
127
|
-
tweetsCount?: number;
|
|
128
|
-
url?: string;
|
|
129
|
-
userId?: string;
|
|
130
|
-
username?: string;
|
|
131
|
-
website?: string;
|
|
132
|
-
canDm?: boolean;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* A paginated tweets API response. The `next` field can be used to fetch the next page of results,
|
|
137
|
-
* and the `previous` can be used to fetch the previous results (or results created after the
|
|
138
|
-
* initial request)
|
|
139
|
-
*/
|
|
140
|
-
/**
|
|
141
|
-
* Interface representing the response from a query tweets request.
|
|
142
|
-
* @typedef {Object} QueryTweetsResponse
|
|
143
|
-
* @property {Tweet[]} tweets - An array of Tweet objects.
|
|
144
|
-
* @property {string} [next] - Optional. The token for fetching the next page of tweets.
|
|
145
|
-
* @property {string} [previous] - Optional. The token for fetching the previous page of tweets.
|
|
146
|
-
*/
|
|
147
|
-
interface QueryTweetsResponse {
|
|
148
|
-
tweets: Tweet$1[];
|
|
149
|
-
next?: string;
|
|
150
|
-
previous?: string;
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* A paginated profiles API response. The `next` field can be used to fetch the next page of results.
|
|
154
|
-
*/
|
|
155
|
-
interface QueryProfilesResponse {
|
|
156
|
-
profiles: Profile[];
|
|
157
|
-
next?: string;
|
|
158
|
-
previous?: string;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Interface representing a timeline article.
|
|
163
|
-
* @typedef {Object} TimelineArticle
|
|
164
|
-
* @property {string} id - The unique identifier for the article.
|
|
165
|
-
* @property {string} articleId - The identifier for the article.
|
|
166
|
-
* @property {string} title - The title of the article.
|
|
167
|
-
* @property {string} previewText - The preview text of the article.
|
|
168
|
-
* @property {string} [coverMediaUrl] - The URL of the cover media for the article. (Optional)
|
|
169
|
-
* @property {string} text - The main text content of the article.
|
|
170
|
-
*/
|
|
171
|
-
interface TimelineArticle {
|
|
172
|
-
id: string;
|
|
173
|
-
articleId: string;
|
|
174
|
-
title: string;
|
|
175
|
-
previewText: string;
|
|
176
|
-
coverMediaUrl?: string;
|
|
177
|
-
text: string;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
40
|
/**
|
|
181
41
|
* Interface representing a mention.
|
|
182
42
|
* @typedef {Object} Mention
|
|
@@ -357,6 +217,98 @@ interface Retweeter {
|
|
|
357
217
|
}
|
|
358
218
|
type TweetQuery = Partial<Tweet$1> | ((tweet: Tweet$1) => boolean | Promise<boolean>);
|
|
359
219
|
|
|
220
|
+
/**
|
|
221
|
+
* Common types for Twitter plugin API responses
|
|
222
|
+
*/
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Response for paginated tweets queries
|
|
226
|
+
*/
|
|
227
|
+
interface QueryTweetsResponse {
|
|
228
|
+
tweets: Tweet$1[];
|
|
229
|
+
next?: string;
|
|
230
|
+
previous?: string;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Response for paginated profiles queries
|
|
234
|
+
*/
|
|
235
|
+
interface QueryProfilesResponse {
|
|
236
|
+
profiles: Profile[];
|
|
237
|
+
next?: string;
|
|
238
|
+
previous?: string;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Options for request transformation
|
|
242
|
+
*/
|
|
243
|
+
interface FetchTransformOptions {
|
|
244
|
+
/**
|
|
245
|
+
* Transforms the request options before a request is made.
|
|
246
|
+
*/
|
|
247
|
+
request: (...args: [input: RequestInfo | URL, init?: RequestInit]) => [input: RequestInfo | URL, init?: RequestInit] | Promise<[input: RequestInfo | URL, init?: RequestInit]>;
|
|
248
|
+
/**
|
|
249
|
+
* Transforms the response after a request completes.
|
|
250
|
+
*/
|
|
251
|
+
response: (response: Response) => Response | Promise<Response>;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* A parsed profile object.
|
|
256
|
+
*/
|
|
257
|
+
/**
|
|
258
|
+
* Interface representing a user profile.
|
|
259
|
+
* @typedef {Object} Profile
|
|
260
|
+
* @property {string} [avatar] - The URL to the user's avatar.
|
|
261
|
+
* @property {string} [banner] - The URL to the user's banner image.
|
|
262
|
+
* @property {string} [biography] - The user's biography.
|
|
263
|
+
* @property {string} [birthday] - The user's birthday.
|
|
264
|
+
* @property {number} [followersCount] - The number of followers the user has.
|
|
265
|
+
* @property {number} [followingCount] - The number of users the user is following.
|
|
266
|
+
* @property {number} [friendsCount] - The number of friends the user has.
|
|
267
|
+
* @property {number} [mediaCount] - The number of media items the user has posted.
|
|
268
|
+
* @property {number} [statusesCount] - The number of statuses the user has posted.
|
|
269
|
+
* @property {boolean} [isPrivate] - Indicates if the user's profile is private.
|
|
270
|
+
* @property {boolean} [isVerified] - Indicates if the user account is verified.
|
|
271
|
+
* @property {boolean} [isBlueVerified] - Indicates if the user account has blue verification badge.
|
|
272
|
+
* @property {Date} [joined] - The date the user joined the platform.
|
|
273
|
+
* @property {number} [likesCount] - The number of likes the user has received.
|
|
274
|
+
* @property {number} [listedCount] - The number of times the user has been listed.
|
|
275
|
+
* @property {string} location - The user's location.
|
|
276
|
+
* @property {string} [name] - The user's name.
|
|
277
|
+
* @property {string[]} [pinnedTweetIds] - The IDs of the user's pinned tweets.
|
|
278
|
+
* @property {number} [tweetsCount] - The number of tweets the user has posted.
|
|
279
|
+
* @property {string} [url] - The user's website URL.
|
|
280
|
+
* @property {string} [userId] - The unique user ID.
|
|
281
|
+
* @property {string} [username] - The user's username.
|
|
282
|
+
* @property {string} [website] - The user's website.
|
|
283
|
+
* @property {boolean} [canDm] - Indicates if the user can receive direct messages.
|
|
284
|
+
*/
|
|
285
|
+
interface Profile {
|
|
286
|
+
avatar?: string;
|
|
287
|
+
banner?: string;
|
|
288
|
+
biography?: string;
|
|
289
|
+
birthday?: string;
|
|
290
|
+
followersCount?: number;
|
|
291
|
+
followingCount?: number;
|
|
292
|
+
friendsCount?: number;
|
|
293
|
+
mediaCount?: number;
|
|
294
|
+
statusesCount?: number;
|
|
295
|
+
isPrivate?: boolean;
|
|
296
|
+
isVerified?: boolean;
|
|
297
|
+
isBlueVerified?: boolean;
|
|
298
|
+
joined?: Date;
|
|
299
|
+
likesCount?: number;
|
|
300
|
+
listedCount?: number;
|
|
301
|
+
location: string;
|
|
302
|
+
name?: string;
|
|
303
|
+
pinnedTweetIds?: string[];
|
|
304
|
+
tweetsCount?: number;
|
|
305
|
+
url?: string;
|
|
306
|
+
userId?: string;
|
|
307
|
+
username?: string;
|
|
308
|
+
website?: string;
|
|
309
|
+
canDm?: boolean;
|
|
310
|
+
}
|
|
311
|
+
|
|
360
312
|
/**
|
|
361
313
|
* The categories that can be used in Twitter searches.
|
|
362
314
|
*/
|
|
@@ -496,19 +448,21 @@ declare class Client {
|
|
|
496
448
|
*/
|
|
497
449
|
fetchProfileFollowers(userId: string, maxProfiles: number, cursor?: string): Promise<QueryProfilesResponse>;
|
|
498
450
|
/**
|
|
499
|
-
* Fetches the home timeline for the current user
|
|
451
|
+
* Fetches the home timeline for the current user using Twitter API v2.
|
|
452
|
+
* Note: Twitter API v2 doesn't distinguish between "For You" and "Following" feeds.
|
|
500
453
|
* @param count The number of tweets to fetch.
|
|
501
|
-
* @param seenTweetIds An array of tweet IDs that have already been seen.
|
|
502
|
-
* @returns A promise that resolves to
|
|
454
|
+
* @param seenTweetIds An array of tweet IDs that have already been seen (not used in v2).
|
|
455
|
+
* @returns A promise that resolves to an array of tweets.
|
|
503
456
|
*/
|
|
504
|
-
fetchHomeTimeline(count: number, seenTweetIds: string[]): Promise<
|
|
457
|
+
fetchHomeTimeline(count: number, seenTweetIds: string[]): Promise<Tweet$1[]>;
|
|
505
458
|
/**
|
|
506
|
-
* Fetches the home timeline for the current user
|
|
459
|
+
* Fetches the home timeline for the current user (same as fetchHomeTimeline in v2).
|
|
460
|
+
* Twitter API v2 doesn't provide separate "Following" timeline endpoint.
|
|
507
461
|
* @param count The number of tweets to fetch.
|
|
508
|
-
* @param seenTweetIds An array of tweet IDs that have already been seen.
|
|
509
|
-
* @returns A promise that resolves to
|
|
462
|
+
* @param seenTweetIds An array of tweet IDs that have already been seen (not used in v2).
|
|
463
|
+
* @returns A promise that resolves to an array of tweets.
|
|
510
464
|
*/
|
|
511
|
-
fetchFollowingTimeline(count: number, seenTweetIds: string[]): Promise<
|
|
465
|
+
fetchFollowingTimeline(count: number, seenTweetIds: string[]): Promise<Tweet$1[]>;
|
|
512
466
|
getUserTweets(userId: string, maxTweets?: number, cursor?: string): Promise<{
|
|
513
467
|
tweets: Tweet$1[];
|
|
514
468
|
next?: string;
|
|
@@ -724,20 +678,6 @@ declare class Client {
|
|
|
724
678
|
* Note: With API v2, logout is not applicable as we use API credentials.
|
|
725
679
|
*/
|
|
726
680
|
logout(): Promise<void>;
|
|
727
|
-
/**
|
|
728
|
-
* Sets the optional cookie to be used in requests.
|
|
729
|
-
* @param _cookie The cookie to be used in requests.
|
|
730
|
-
* @deprecated This function no longer represents any part of Twitter's auth flow.
|
|
731
|
-
* @returns This client instance.
|
|
732
|
-
*/
|
|
733
|
-
withCookie(_cookie: string): Client;
|
|
734
|
-
/**
|
|
735
|
-
* Sets the optional CSRF token to be used in requests.
|
|
736
|
-
* @param _token The CSRF token to be used in requests.
|
|
737
|
-
* @deprecated This function no longer represents any part of Twitter's auth flow.
|
|
738
|
-
* @returns This client instance.
|
|
739
|
-
*/
|
|
740
|
-
withXCsrfToken(_token: string): Client;
|
|
741
681
|
/**
|
|
742
682
|
* Sends a quote tweet.
|
|
743
683
|
* @param text The text of the tweet.
|
|
@@ -797,12 +737,6 @@ declare class Client {
|
|
|
797
737
|
sendDirectMessage(conversationId: string, text: string): Promise<any>;
|
|
798
738
|
private getAuthOptions;
|
|
799
739
|
private handleResponse;
|
|
800
|
-
/**
|
|
801
|
-
* Fetches a article (long form tweet) by its ID.
|
|
802
|
-
* @param id The ID of the article to fetch. In the format of (http://x.com/i/article/id)
|
|
803
|
-
* @returns The {@link TimelineArticle} object, or `null` if it couldn't be fetched.
|
|
804
|
-
*/
|
|
805
|
-
getArticle(id: string): Promise<TimelineArticle | null>;
|
|
806
740
|
/**
|
|
807
741
|
* Retrieves all users who retweeted the given tweet.
|
|
808
742
|
* @param tweetId The ID of the tweet.
|
|
@@ -1089,7 +1023,6 @@ declare class ClientBase {
|
|
|
1089
1023
|
* @param {number} [maxDepth=3] - The maximum depth allowed for parsing nested quotes/retweets.
|
|
1090
1024
|
* @returns {Tweet} The parsed Tweet object.
|
|
1091
1025
|
*/
|
|
1092
|
-
parseTweet(raw: any, depth?: number, maxDepth?: number): Tweet$1;
|
|
1093
1026
|
state: any;
|
|
1094
1027
|
constructor(runtime: IAgentRuntime, state: any);
|
|
1095
1028
|
init(): Promise<void>;
|