@elizaos/plugin-twitter 1.0.9 → 1.0.14
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 +345 -111
- package/dist/index.d.ts +186 -1076
- package/dist/index.js +2079 -8017
- package/dist/index.js.map +1 -1
- package/package.json +118 -138
- package/dist/chunk-PZ5AY32C.js +0 -10
- package/dist/chunk-PZ5AY32C.js.map +0 -1
- package/dist/node-L7ZVN5QV.js +0 -40
- package/dist/node-L7ZVN5QV.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,308 +1,40 @@
|
|
|
1
|
-
import { IAgentRuntime, Memory, State, ChannelType, Plugin
|
|
2
|
-
import
|
|
3
|
-
import { PollV2, TTweetv2Expansion, TTweetv2TweetField, TTweetv2PollField, TTweetv2MediaField, TTweetv2UserField, TTweetv2PlaceField } from 'twitter-api-v2';
|
|
4
|
-
import { EventEmitter } from 'node:events';
|
|
1
|
+
import { IAgentRuntime, Memory, State, ChannelType, Plugin, Service, UUID } from '@elizaos/core';
|
|
2
|
+
import * as twitter_api_v2 from 'twitter-api-v2';
|
|
3
|
+
import { TwitterApi, PollV2, TTweetv2Expansion, TTweetv2TweetField, TTweetv2PollField, TTweetv2MediaField, TTweetv2UserField, TTweetv2PlaceField } from 'twitter-api-v2';
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
|
-
*
|
|
8
|
-
* with the first element being input of type RequestInfo or URL,
|
|
9
|
-
* and the second element being init of type RequestInit or optional if not provided.
|
|
6
|
+
* Twitter API v2 authentication using developer credentials
|
|
10
7
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
* completes, and is stateless. It is safe to return a new response object.
|
|
22
|
-
* @param {Response} response The response object.
|
|
23
|
-
* @returns {Response|Promise<Response>} The transformed response object.
|
|
24
|
-
*/
|
|
25
|
-
interface FetchTransformOptions {
|
|
8
|
+
declare class TwitterAuth {
|
|
9
|
+
private appKey;
|
|
10
|
+
private appSecret;
|
|
11
|
+
private accessToken;
|
|
12
|
+
private accessSecret;
|
|
13
|
+
private v2Client;
|
|
14
|
+
private authenticated;
|
|
15
|
+
private profile?;
|
|
16
|
+
constructor(appKey: string, appSecret: string, accessToken: string, accessSecret: string);
|
|
17
|
+
private initializeClient;
|
|
26
18
|
/**
|
|
27
|
-
*
|
|
28
|
-
* parameters have been configured, and is stateless. It is safe to return new request options
|
|
29
|
-
* objects.
|
|
30
|
-
* @param args The request options.
|
|
31
|
-
* @returns The transformed request options.
|
|
19
|
+
* Get the Twitter API v2 client
|
|
32
20
|
*/
|
|
33
|
-
|
|
21
|
+
getV2Client(): TwitterApi;
|
|
34
22
|
/**
|
|
35
|
-
*
|
|
36
|
-
* completes, and is stateless. It is safe to return a new response object.
|
|
37
|
-
* @param response The response object.
|
|
38
|
-
* @returns The transformed response object.
|
|
23
|
+
* Check if authenticated
|
|
39
24
|
*/
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
* @property {number} [followersCount] - The number of followers the user has.
|
|
54
|
-
* @property {number} [followingCount] - The number of users the user is following.
|
|
55
|
-
* @property {number} [friendsCount] - The number of friends the user has.
|
|
56
|
-
* @property {number} [mediaCount] - The number of media items the user has posted.
|
|
57
|
-
* @property {number} [statusesCount] - The number of statuses the user has posted.
|
|
58
|
-
* @property {boolean} [isPrivate] - Indicates if the user's profile is private.
|
|
59
|
-
* @property {boolean} [isVerified] - Indicates if the user account is verified.
|
|
60
|
-
* @property {boolean} [isBlueVerified] - Indicates if the user account has blue verification badge.
|
|
61
|
-
* @property {Date} [joined] - The date the user joined the platform.
|
|
62
|
-
* @property {number} [likesCount] - The number of likes the user has received.
|
|
63
|
-
* @property {number} [listedCount] - The number of times the user has been listed.
|
|
64
|
-
* @property {string} location - The user's location.
|
|
65
|
-
* @property {string} [name] - The user's name.
|
|
66
|
-
* @property {string[]} [pinnedTweetIds] - The IDs of the user's pinned tweets.
|
|
67
|
-
* @property {number} [tweetsCount] - The number of tweets the user has posted.
|
|
68
|
-
* @property {string} [url] - The user's website URL.
|
|
69
|
-
* @property {string} [userId] - The unique user ID.
|
|
70
|
-
* @property {string} [username] - The user's username.
|
|
71
|
-
* @property {string} [website] - The user's website.
|
|
72
|
-
* @property {boolean} [canDm] - Indicates if the user can receive direct messages.
|
|
73
|
-
*/
|
|
74
|
-
interface Profile {
|
|
75
|
-
avatar?: string;
|
|
76
|
-
banner?: string;
|
|
77
|
-
biography?: string;
|
|
78
|
-
birthday?: string;
|
|
79
|
-
followersCount?: number;
|
|
80
|
-
followingCount?: number;
|
|
81
|
-
friendsCount?: number;
|
|
82
|
-
mediaCount?: number;
|
|
83
|
-
statusesCount?: number;
|
|
84
|
-
isPrivate?: boolean;
|
|
85
|
-
isVerified?: boolean;
|
|
86
|
-
isBlueVerified?: boolean;
|
|
87
|
-
joined?: Date;
|
|
88
|
-
likesCount?: number;
|
|
89
|
-
listedCount?: number;
|
|
90
|
-
location: string;
|
|
91
|
-
name?: string;
|
|
92
|
-
pinnedTweetIds?: string[];
|
|
93
|
-
tweetsCount?: number;
|
|
94
|
-
url?: string;
|
|
95
|
-
userId?: string;
|
|
96
|
-
username?: string;
|
|
97
|
-
website?: string;
|
|
98
|
-
canDm?: boolean;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Interface representing a GrokMessage object.
|
|
103
|
-
* @interface
|
|
104
|
-
* @property {string} role - The role of the message, can be either "user" or "assistant".
|
|
105
|
-
* @property {string} content - The content of the message.
|
|
106
|
-
*/
|
|
107
|
-
interface GrokMessage {
|
|
108
|
-
role: "user" | "assistant";
|
|
109
|
-
content: string;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Interface for specifying options when using GrokChat.
|
|
113
|
-
* @typedef {Object} GrokChatOptions
|
|
114
|
-
* @property {GrokMessage[]} messages - Array of GrokMessage objects
|
|
115
|
-
* @property {string} [conversationId] - Optional ID for the conversation. Will create new if not provided
|
|
116
|
-
* @property {boolean} [returnSearchResults] - Flag to indicate whether to return search results
|
|
117
|
-
* @property {boolean} [returnCitations] - Flag to indicate whether to return citations
|
|
118
|
-
*/
|
|
119
|
-
interface GrokChatOptions {
|
|
120
|
-
messages: GrokMessage[];
|
|
121
|
-
conversationId?: string;
|
|
122
|
-
returnSearchResults?: boolean;
|
|
123
|
-
returnCitations?: boolean;
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Interface representing a Grok rate limit response.
|
|
127
|
-
* @typedef { Object } GrokRateLimit
|
|
128
|
-
* @property { boolean } isRateLimited - Flag indicating if the rate limit is in effect.
|
|
129
|
-
* @property { string } message - The message associated with the rate limit.
|
|
130
|
-
* @property { Object } upsellInfo - Object containing additional information about the rate limit (optional).
|
|
131
|
-
* @property { string } upsellInfo.usageLimit - The usage limit imposed by the rate limit.
|
|
132
|
-
* @property { string } upsellInfo.quotaDuration - The duration of the quota for the rate limit.
|
|
133
|
-
* @property { string } upsellInfo.title - The title related to the rate limit.
|
|
134
|
-
* @property { string } upsellInfo.message - Additional message related to the rate limit.
|
|
135
|
-
*/
|
|
136
|
-
interface GrokRateLimit {
|
|
137
|
-
isRateLimited: boolean;
|
|
138
|
-
message: string;
|
|
139
|
-
upsellInfo?: {
|
|
140
|
-
usageLimit: string;
|
|
141
|
-
quotaDuration: string;
|
|
142
|
-
title: string;
|
|
143
|
-
message: string;
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Interface for the response from the GrokChat API.
|
|
148
|
-
* @typedef {object} GrokChatResponse
|
|
149
|
-
* @property {string} conversationId - The ID of the conversation.
|
|
150
|
-
* @property {string} message - The message content.
|
|
151
|
-
* @property {Array<GrokMessage>} messages - An array of GrokMessage objects.
|
|
152
|
-
* @property {Array<any>} [webResults] - Optional array of web results.
|
|
153
|
-
* @property {object} [metadata] - Optional metadata object.
|
|
154
|
-
* @property {object} [rateLimit] - Optional rate limit information.
|
|
155
|
-
*/
|
|
156
|
-
interface GrokChatResponse {
|
|
157
|
-
conversationId: string;
|
|
158
|
-
message: string;
|
|
159
|
-
messages: GrokMessage[];
|
|
160
|
-
webResults?: any[];
|
|
161
|
-
metadata?: any;
|
|
162
|
-
rateLimit?: GrokRateLimit;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Represents a direct message object.
|
|
167
|
-
* @typedef {Object} DirectMessage
|
|
168
|
-
* @property {string} id - The unique identifier of the direct message.
|
|
169
|
-
* @property {string} text - The text content of the direct message.
|
|
170
|
-
* @property {string} senderId - The unique identifier of the sender of the direct message.
|
|
171
|
-
* @property {string} recipientId - The unique identifier of the recipient of the direct message.
|
|
172
|
-
* @property {string} createdAt - The timestamp when the direct message was created.
|
|
173
|
-
* @property {string[]} [mediaUrls] - An optional array of URLs for any media included in the direct message.
|
|
174
|
-
* @property {string} [senderScreenName] - The screen name of the sender of the direct message.
|
|
175
|
-
* @property {string} [recipientScreenName] - The screen name of the recipient of the direct message.
|
|
176
|
-
*/
|
|
177
|
-
interface DirectMessage {
|
|
178
|
-
id: string;
|
|
179
|
-
text: string;
|
|
180
|
-
senderId: string;
|
|
181
|
-
recipientId: string;
|
|
182
|
-
createdAt: string;
|
|
183
|
-
mediaUrls?: string[];
|
|
184
|
-
senderScreenName?: string;
|
|
185
|
-
recipientScreenName?: string;
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Represents a direct message conversation.
|
|
189
|
-
* @typedef {Object} DirectMessageConversation
|
|
190
|
-
* @property {string} conversationId - The ID of the conversation.
|
|
191
|
-
* @property {DirectMessage[]} messages - An array of DirectMessage objects representing the messages in the conversation.
|
|
192
|
-
* @property {Object[]} participants - An array of participant objects with IDs and screen names.
|
|
193
|
-
* @property {string} participants.id - The ID of the participant.
|
|
194
|
-
* @property {string} participants.screenName - The screen name of the participant.
|
|
195
|
-
*/
|
|
196
|
-
interface DirectMessageConversation {
|
|
197
|
-
conversationId: string;
|
|
198
|
-
messages: DirectMessage[];
|
|
199
|
-
participants: {
|
|
200
|
-
id: string;
|
|
201
|
-
screenName: string;
|
|
202
|
-
}[];
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Interface representing the response of direct messages.
|
|
206
|
-
* @typedef {Object} DirectMessagesResponse
|
|
207
|
-
* @property {DirectMessageConversation[]} conversations - Array of direct message conversations.
|
|
208
|
-
* @property {TwitterUser[]} users - Array of Twitter users.
|
|
209
|
-
* @property {string} [cursor] - Optional cursor for pagination.
|
|
210
|
-
* @property {string} [lastSeenEventId] - Optional ID of the last seen event.
|
|
211
|
-
* @property {string} [trustedLastSeenEventId] - Optional ID of the last seen trusted event.
|
|
212
|
-
* @property {string} [untrustedLastSeenEventId] - Optional ID of the last seen untrusted event.
|
|
213
|
-
* @property {Object} [inboxTimelines] - Optional object containing trusted and untrusted inbox timelines.
|
|
214
|
-
* @property {Object} [inboxTimelines.trusted] - Object containing status and optional minimum entry ID for trusted inbox timeline.
|
|
215
|
-
* @property {string} inboxTimelines.trusted.status - Status of the trusted inbox timeline.
|
|
216
|
-
* @property {string} [inboxTimelines.trusted.minEntryId] - Optional minimum entry ID for the trusted inbox timeline.
|
|
217
|
-
* @property {Object} [inboxTimelines.untrusted] - Object containing status and optional minimum entry ID for untrusted inbox timeline.
|
|
218
|
-
* @property {string} inboxTimelines.untrusted.status - Status of the untrusted inbox timeline.
|
|
219
|
-
* @property {string} [inboxTimelines.untrusted.minEntryId] - Optional minimum entry ID for the untrusted inbox timeline.
|
|
220
|
-
* @property {string} userId - ID of the user.
|
|
221
|
-
*/
|
|
222
|
-
interface DirectMessagesResponse {
|
|
223
|
-
conversations: DirectMessageConversation[];
|
|
224
|
-
users: TwitterUser[];
|
|
225
|
-
cursor?: string;
|
|
226
|
-
lastSeenEventId?: string;
|
|
227
|
-
trustedLastSeenEventId?: string;
|
|
228
|
-
untrustedLastSeenEventId?: string;
|
|
229
|
-
inboxTimelines?: {
|
|
230
|
-
trusted?: {
|
|
231
|
-
status: string;
|
|
232
|
-
minEntryId?: string;
|
|
233
|
-
};
|
|
234
|
-
untrusted?: {
|
|
235
|
-
status: string;
|
|
236
|
-
minEntryId?: string;
|
|
237
|
-
};
|
|
238
|
-
};
|
|
239
|
-
userId: string;
|
|
240
|
-
}
|
|
241
|
-
/**
|
|
242
|
-
* Interface representing a Twitter user.
|
|
243
|
-
* @property {string} id - The unique identifier of the user.
|
|
244
|
-
* @property {string} screenName - The user's screen name.
|
|
245
|
-
* @property {string} name - The user's full name.
|
|
246
|
-
* @property {string} profileImageUrl - The URL of the user's profile image.
|
|
247
|
-
* @property {string} [description] - The user's profile description.
|
|
248
|
-
* @property {boolean} [verified] - Whether the user is a verified account.
|
|
249
|
-
* @property {boolean} [protected] - Whether the user has a protected account.
|
|
250
|
-
* @property {number} [followersCount] - The number of followers the user has.
|
|
251
|
-
* @property {number} [friendsCount] - The number of friends the user has.
|
|
252
|
-
*/
|
|
253
|
-
interface TwitterUser {
|
|
254
|
-
id: string;
|
|
255
|
-
screenName: string;
|
|
256
|
-
name: string;
|
|
257
|
-
profileImageUrl: string;
|
|
258
|
-
description?: string;
|
|
259
|
-
verified?: boolean;
|
|
260
|
-
protected?: boolean;
|
|
261
|
-
followersCount?: number;
|
|
262
|
-
friendsCount?: number;
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* Interface representing the response of sending a direct message.
|
|
266
|
-
* @typedef {Object} SendDirectMessageResponse
|
|
267
|
-
* @property {Array<{message: {id: string, time: string, affects_sort: boolean, conversation_id: string, message_data: {id: string, time: string, recipient_id: string, sender_id: string, text: string}}}>} entries - Array of message entries.
|
|
268
|
-
* @property {Object.<string, TwitterUser>} users - Record of Twitter users.
|
|
269
|
-
*/
|
|
270
|
-
interface SendDirectMessageResponse {
|
|
271
|
-
entries: {
|
|
272
|
-
message: {
|
|
273
|
-
id: string;
|
|
274
|
-
time: string;
|
|
275
|
-
affects_sort: boolean;
|
|
276
|
-
conversation_id: string;
|
|
277
|
-
message_data: {
|
|
278
|
-
id: string;
|
|
279
|
-
time: string;
|
|
280
|
-
recipient_id: string;
|
|
281
|
-
sender_id: string;
|
|
282
|
-
text: string;
|
|
283
|
-
};
|
|
284
|
-
};
|
|
285
|
-
}[];
|
|
286
|
-
users: Record<string, TwitterUser>;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
/**
|
|
290
|
-
* Interface representing a timeline article.
|
|
291
|
-
* @typedef {Object} TimelineArticle
|
|
292
|
-
* @property {string} id - The unique identifier for the article.
|
|
293
|
-
* @property {string} articleId - The identifier for the article.
|
|
294
|
-
* @property {string} title - The title of the article.
|
|
295
|
-
* @property {string} previewText - The preview text of the article.
|
|
296
|
-
* @property {string} [coverMediaUrl] - The URL of the cover media for the article. (Optional)
|
|
297
|
-
* @property {string} text - The main text content of the article.
|
|
298
|
-
*/
|
|
299
|
-
interface TimelineArticle {
|
|
300
|
-
id: string;
|
|
301
|
-
articleId: string;
|
|
302
|
-
title: string;
|
|
303
|
-
previewText: string;
|
|
304
|
-
coverMediaUrl?: string;
|
|
305
|
-
text: string;
|
|
25
|
+
isLoggedIn(): Promise<boolean>;
|
|
26
|
+
/**
|
|
27
|
+
* Get current user profile
|
|
28
|
+
*/
|
|
29
|
+
me(): Promise<Profile | undefined>;
|
|
30
|
+
/**
|
|
31
|
+
* Logout (clear credentials)
|
|
32
|
+
*/
|
|
33
|
+
logout(): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* For compatibility - always returns true since we use API keys
|
|
36
|
+
*/
|
|
37
|
+
hasToken(): boolean;
|
|
306
38
|
}
|
|
307
39
|
|
|
308
40
|
/**
|
|
@@ -486,16 +218,11 @@ interface Retweeter {
|
|
|
486
218
|
type TweetQuery = Partial<Tweet$1> | ((tweet: Tweet$1) => boolean | Promise<boolean>);
|
|
487
219
|
|
|
488
220
|
/**
|
|
489
|
-
*
|
|
490
|
-
* and the `previous` can be used to fetch the previous results (or results created after the
|
|
491
|
-
* initial request)
|
|
221
|
+
* Common types for Twitter plugin API responses
|
|
492
222
|
*/
|
|
223
|
+
|
|
493
224
|
/**
|
|
494
|
-
*
|
|
495
|
-
* @typedef {Object} QueryTweetsResponse
|
|
496
|
-
* @property {Tweet[]} tweets - An array of Tweet objects.
|
|
497
|
-
* @property {string} [next] - Optional. The token for fetching the next page of tweets.
|
|
498
|
-
* @property {string} [previous] - Optional. The token for fetching the previous page of tweets.
|
|
225
|
+
* Response for paginated tweets queries
|
|
499
226
|
*/
|
|
500
227
|
interface QueryTweetsResponse {
|
|
501
228
|
tweets: Tweet$1[];
|
|
@@ -503,13 +230,84 @@ interface QueryTweetsResponse {
|
|
|
503
230
|
previous?: string;
|
|
504
231
|
}
|
|
505
232
|
/**
|
|
506
|
-
*
|
|
233
|
+
* Response for paginated profiles queries
|
|
507
234
|
*/
|
|
508
235
|
interface QueryProfilesResponse {
|
|
509
236
|
profiles: Profile[];
|
|
510
237
|
next?: string;
|
|
511
238
|
previous?: string;
|
|
512
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
|
+
}
|
|
513
311
|
|
|
514
312
|
/**
|
|
515
313
|
* The categories that can be used in Twitter searches.
|
|
@@ -526,202 +324,6 @@ declare enum SearchMode {
|
|
|
526
324
|
Users = 4
|
|
527
325
|
}
|
|
528
326
|
|
|
529
|
-
/**
|
|
530
|
-
* Represents a Community that can host Spaces.
|
|
531
|
-
*/
|
|
532
|
-
/**
|
|
533
|
-
* Represents a community entity.
|
|
534
|
-
* @typedef {object} Community
|
|
535
|
-
* @property {string} id - The ID of the community.
|
|
536
|
-
* @property {string} name - The name of the community.
|
|
537
|
-
* @property {string} rest_id - The ID of the associated restaurant.
|
|
538
|
-
*/
|
|
539
|
-
interface Community {
|
|
540
|
-
id: string;
|
|
541
|
-
name: string;
|
|
542
|
-
rest_id: string;
|
|
543
|
-
}
|
|
544
|
-
/**
|
|
545
|
-
* Represents a Subtopic within a Category.
|
|
546
|
-
*/
|
|
547
|
-
interface Subtopic {
|
|
548
|
-
icon_url: string;
|
|
549
|
-
name: string;
|
|
550
|
-
topic_id: string;
|
|
551
|
-
}
|
|
552
|
-
/**
|
|
553
|
-
* Represents the result details of a Creator.
|
|
554
|
-
*/
|
|
555
|
-
interface CreatorResult {
|
|
556
|
-
__typename: string;
|
|
557
|
-
id: string;
|
|
558
|
-
rest_id: string;
|
|
559
|
-
affiliates_highlighted_label: Record<string, any>;
|
|
560
|
-
has_graduated_access: boolean;
|
|
561
|
-
is_blue_verified: boolean;
|
|
562
|
-
profile_image_shape: string;
|
|
563
|
-
legacy: {
|
|
564
|
-
following: boolean;
|
|
565
|
-
can_dm: boolean;
|
|
566
|
-
can_media_tag: boolean;
|
|
567
|
-
created_at: string;
|
|
568
|
-
default_profile: boolean;
|
|
569
|
-
default_profile_image: boolean;
|
|
570
|
-
description: string;
|
|
571
|
-
entities: {
|
|
572
|
-
description: {
|
|
573
|
-
urls: any[];
|
|
574
|
-
};
|
|
575
|
-
};
|
|
576
|
-
fast_followers_count: number;
|
|
577
|
-
favourites_count: number;
|
|
578
|
-
followers_count: number;
|
|
579
|
-
friends_count: number;
|
|
580
|
-
has_custom_timelines: boolean;
|
|
581
|
-
is_translator: boolean;
|
|
582
|
-
listed_count: number;
|
|
583
|
-
location: string;
|
|
584
|
-
media_count: number;
|
|
585
|
-
name: string;
|
|
586
|
-
needs_phone_verification: boolean;
|
|
587
|
-
normal_followers_count: number;
|
|
588
|
-
pinned_tweet_ids_str: string[];
|
|
589
|
-
possibly_sensitive: boolean;
|
|
590
|
-
profile_image_url_https: string;
|
|
591
|
-
profile_interstitial_type: string;
|
|
592
|
-
screen_name: string;
|
|
593
|
-
statuses_count: number;
|
|
594
|
-
translator_type: string;
|
|
595
|
-
verified: boolean;
|
|
596
|
-
want_retweets: boolean;
|
|
597
|
-
withheld_in_countries: string[];
|
|
598
|
-
};
|
|
599
|
-
tipjar_settings: Record<string, any>;
|
|
600
|
-
}
|
|
601
|
-
/**
|
|
602
|
-
* Represents user results within an Admin.
|
|
603
|
-
*/
|
|
604
|
-
interface UserResults {
|
|
605
|
-
rest_id: string;
|
|
606
|
-
result: {
|
|
607
|
-
__typename: string;
|
|
608
|
-
identity_profile_labels_highlighted_label: Record<string, any>;
|
|
609
|
-
is_blue_verified: boolean;
|
|
610
|
-
legacy: Record<string, any>;
|
|
611
|
-
};
|
|
612
|
-
}
|
|
613
|
-
/**
|
|
614
|
-
* Represents an Admin participant in an Audio Space.
|
|
615
|
-
*/
|
|
616
|
-
interface Admin {
|
|
617
|
-
periscope_user_id: string;
|
|
618
|
-
start: number;
|
|
619
|
-
twitter_screen_name: string;
|
|
620
|
-
display_name: string;
|
|
621
|
-
avatar_url: string;
|
|
622
|
-
is_verified: boolean;
|
|
623
|
-
is_muted_by_admin: boolean;
|
|
624
|
-
is_muted_by_guest: boolean;
|
|
625
|
-
user_results: UserResults;
|
|
626
|
-
}
|
|
627
|
-
/**
|
|
628
|
-
* Represents Participants in an Audio Space.
|
|
629
|
-
*/
|
|
630
|
-
interface Participants {
|
|
631
|
-
total: number;
|
|
632
|
-
admins: Admin[];
|
|
633
|
-
speakers: any[];
|
|
634
|
-
listeners: any[];
|
|
635
|
-
}
|
|
636
|
-
/**
|
|
637
|
-
* Represents Metadata of an Audio Space.
|
|
638
|
-
*/
|
|
639
|
-
interface Metadata {
|
|
640
|
-
rest_id: string;
|
|
641
|
-
state: string;
|
|
642
|
-
media_key: string;
|
|
643
|
-
created_at: number;
|
|
644
|
-
started_at: number;
|
|
645
|
-
ended_at: string;
|
|
646
|
-
updated_at: number;
|
|
647
|
-
content_type: string;
|
|
648
|
-
creator_results: {
|
|
649
|
-
result: CreatorResult;
|
|
650
|
-
};
|
|
651
|
-
conversation_controls: number;
|
|
652
|
-
disallow_join: boolean;
|
|
653
|
-
is_employee_only: boolean;
|
|
654
|
-
is_locked: boolean;
|
|
655
|
-
is_muted: boolean;
|
|
656
|
-
is_space_available_for_clipping: boolean;
|
|
657
|
-
is_space_available_for_replay: boolean;
|
|
658
|
-
narrow_cast_space_type: number;
|
|
659
|
-
no_incognito: boolean;
|
|
660
|
-
total_replay_watched: number;
|
|
661
|
-
total_live_listeners: number;
|
|
662
|
-
tweet_results: Record<string, any>;
|
|
663
|
-
max_guest_sessions: number;
|
|
664
|
-
max_admin_capacity: number;
|
|
665
|
-
}
|
|
666
|
-
/**
|
|
667
|
-
* Represents Sharings within an Audio Space.
|
|
668
|
-
*/
|
|
669
|
-
interface Sharings {
|
|
670
|
-
items: any[];
|
|
671
|
-
slice_info: Record<string, any>;
|
|
672
|
-
}
|
|
673
|
-
/**
|
|
674
|
-
* Represents an Audio Space.
|
|
675
|
-
*/
|
|
676
|
-
interface AudioSpace {
|
|
677
|
-
metadata: Metadata;
|
|
678
|
-
is_subscribed: boolean;
|
|
679
|
-
participants: Participants;
|
|
680
|
-
sharings: Sharings;
|
|
681
|
-
}
|
|
682
|
-
interface LiveVideoSource {
|
|
683
|
-
location: string;
|
|
684
|
-
noRedirectPlaybackUrl: string;
|
|
685
|
-
status: string;
|
|
686
|
-
streamType: string;
|
|
687
|
-
}
|
|
688
|
-
interface LiveVideoStreamStatus {
|
|
689
|
-
source: LiveVideoSource;
|
|
690
|
-
sessionId: string;
|
|
691
|
-
chatToken: string;
|
|
692
|
-
lifecycleToken: string;
|
|
693
|
-
shareUrl: string;
|
|
694
|
-
chatPermissionType: string;
|
|
695
|
-
}
|
|
696
|
-
interface LoginTwitterTokenResponse {
|
|
697
|
-
cookie: string;
|
|
698
|
-
user: {
|
|
699
|
-
class_name: string;
|
|
700
|
-
id: string;
|
|
701
|
-
created_at: string;
|
|
702
|
-
is_beta_user: boolean;
|
|
703
|
-
is_employee: boolean;
|
|
704
|
-
is_twitter_verified: boolean;
|
|
705
|
-
verified_type: number;
|
|
706
|
-
is_bluebird_user: boolean;
|
|
707
|
-
twitter_screen_name: string;
|
|
708
|
-
username: string;
|
|
709
|
-
display_name: string;
|
|
710
|
-
description: string;
|
|
711
|
-
profile_image_urls: {
|
|
712
|
-
url: string;
|
|
713
|
-
ssl_url: string;
|
|
714
|
-
width: number;
|
|
715
|
-
height: number;
|
|
716
|
-
}[];
|
|
717
|
-
twitter_id: string;
|
|
718
|
-
initials: string;
|
|
719
|
-
n_followers: number;
|
|
720
|
-
n_following: number;
|
|
721
|
-
};
|
|
722
|
-
type: string;
|
|
723
|
-
}
|
|
724
|
-
|
|
725
327
|
/**
|
|
726
328
|
* An alternative fetch function to use instead of the default fetch function. This may be useful
|
|
727
329
|
* in nonstandard runtime environments, such as edge workers.
|
|
@@ -744,26 +346,17 @@ interface ClientOptions {
|
|
|
744
346
|
transform: Partial<FetchTransformOptions>;
|
|
745
347
|
}
|
|
746
348
|
/**
|
|
747
|
-
* An interface to Twitter's
|
|
349
|
+
* An interface to Twitter's API v2.
|
|
748
350
|
* - Reusing Client objects is recommended to minimize the time spent authenticating unnecessarily.
|
|
749
351
|
*/
|
|
750
352
|
declare class Client {
|
|
751
353
|
private readonly options?;
|
|
752
|
-
private auth
|
|
753
|
-
private authTrends;
|
|
754
|
-
private token;
|
|
354
|
+
private auth?;
|
|
755
355
|
/**
|
|
756
356
|
* Creates a new Client object.
|
|
757
|
-
* - Clients maintain their own guest tokens for Twitter's internal API.
|
|
758
357
|
* - Reusing Client objects is recommended to minimize the time spent authenticating unnecessarily.
|
|
759
358
|
*/
|
|
760
359
|
constructor(options?: Partial<ClientOptions>);
|
|
761
|
-
/**
|
|
762
|
-
* Initializes auth properties using a guest token.
|
|
763
|
-
* Used when creating a new instance of this class, and when logging out.
|
|
764
|
-
* @internal
|
|
765
|
-
*/
|
|
766
|
-
private useGuestAuth;
|
|
767
360
|
/**
|
|
768
361
|
* Fetches a Twitter profile.
|
|
769
362
|
* @param username The Twitter username of the profile to fetch, without an `@` at the beginning.
|
|
@@ -855,19 +448,21 @@ declare class Client {
|
|
|
855
448
|
*/
|
|
856
449
|
fetchProfileFollowers(userId: string, maxProfiles: number, cursor?: string): Promise<QueryProfilesResponse>;
|
|
857
450
|
/**
|
|
858
|
-
* 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.
|
|
859
453
|
* @param count The number of tweets to fetch.
|
|
860
|
-
* @param seenTweetIds An array of tweet IDs that have already been seen.
|
|
861
|
-
* @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.
|
|
862
456
|
*/
|
|
863
|
-
fetchHomeTimeline(count: number, seenTweetIds: string[]): Promise<
|
|
457
|
+
fetchHomeTimeline(count: number, seenTweetIds: string[]): Promise<Tweet$1[]>;
|
|
864
458
|
/**
|
|
865
|
-
* 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.
|
|
866
461
|
* @param count The number of tweets to fetch.
|
|
867
|
-
* @param seenTweetIds An array of tweet IDs that have already been seen.
|
|
868
|
-
* @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.
|
|
869
464
|
*/
|
|
870
|
-
fetchFollowingTimeline(count: number, seenTweetIds: string[]): Promise<
|
|
465
|
+
fetchFollowingTimeline(count: number, seenTweetIds: string[]): Promise<Tweet$1[]>;
|
|
871
466
|
getUserTweets(userId: string, maxTweets?: number, cursor?: string): Promise<{
|
|
872
467
|
tweets: Tweet$1[];
|
|
873
468
|
next?: string;
|
|
@@ -902,11 +497,19 @@ declare class Client {
|
|
|
902
497
|
sendTweet(text: string, replyToTweetId?: string, mediaData?: {
|
|
903
498
|
data: Buffer;
|
|
904
499
|
mediaType: string;
|
|
905
|
-
}[], hideLinkPreview?: boolean): Promise<
|
|
500
|
+
}[], hideLinkPreview?: boolean): Promise<{
|
|
501
|
+
ok: boolean;
|
|
502
|
+
json: () => Promise<twitter_api_v2.TweetV2PostTweetResult>;
|
|
503
|
+
data: twitter_api_v2.TweetV2PostTweetResult;
|
|
504
|
+
}>;
|
|
906
505
|
sendNoteTweet(text: string, replyToTweetId?: string, mediaData?: {
|
|
907
506
|
data: Buffer;
|
|
908
507
|
mediaType: string;
|
|
909
|
-
}[]): Promise<
|
|
508
|
+
}[]): Promise<{
|
|
509
|
+
ok: boolean;
|
|
510
|
+
json: () => Promise<twitter_api_v2.TweetV2PostTweetResult>;
|
|
511
|
+
data: twitter_api_v2.TweetV2PostTweetResult;
|
|
512
|
+
}>;
|
|
910
513
|
/**
|
|
911
514
|
* Send a long tweet (Note Tweet)
|
|
912
515
|
* @param text The text of the tweet
|
|
@@ -917,7 +520,11 @@ declare class Client {
|
|
|
917
520
|
sendLongTweet(text: string, replyToTweetId?: string, mediaData?: {
|
|
918
521
|
data: Buffer;
|
|
919
522
|
mediaType: string;
|
|
920
|
-
}[]): Promise<
|
|
523
|
+
}[]): Promise<{
|
|
524
|
+
ok: boolean;
|
|
525
|
+
json: () => Promise<twitter_api_v2.TweetV2PostTweetResult>;
|
|
526
|
+
data: twitter_api_v2.TweetV2PostTweetResult;
|
|
527
|
+
}>;
|
|
921
528
|
/**
|
|
922
529
|
* Send a tweet
|
|
923
530
|
* @param text The text of the tweet
|
|
@@ -1034,10 +641,20 @@ declare class Client {
|
|
|
1034
641
|
placeFields?: TTweetv2PlaceField[];
|
|
1035
642
|
}): Promise<Tweet$1[]>;
|
|
1036
643
|
/**
|
|
1037
|
-
*
|
|
1038
|
-
* @
|
|
644
|
+
* Updates the authentication state for the client.
|
|
645
|
+
* @param auth The new authentication.
|
|
646
|
+
*/
|
|
647
|
+
updateAuth(auth: TwitterAuth): void;
|
|
648
|
+
/**
|
|
649
|
+
* Get current authentication credentials
|
|
650
|
+
* @returns {TwitterAuth | null} Current authentication or null if not authenticated
|
|
1039
651
|
*/
|
|
1040
|
-
|
|
652
|
+
getAuth(): TwitterAuth | null;
|
|
653
|
+
/**
|
|
654
|
+
* Check if client is properly authenticated with Twitter API v2 credentials
|
|
655
|
+
* @returns {boolean} True if authenticated
|
|
656
|
+
*/
|
|
657
|
+
isAuthenticated(): boolean;
|
|
1041
658
|
/**
|
|
1042
659
|
* Returns if the client is logged in as a real user.
|
|
1043
660
|
* @returns `true` if the client is logged in with a real user account; otherwise `false`.
|
|
@@ -1049,46 +666,18 @@ declare class Client {
|
|
|
1049
666
|
*/
|
|
1050
667
|
me(): Promise<Profile | undefined>;
|
|
1051
668
|
/**
|
|
1052
|
-
* Login to Twitter
|
|
1053
|
-
*
|
|
1054
|
-
* @param
|
|
1055
|
-
* @param
|
|
1056
|
-
* @param
|
|
1057
|
-
* @param twoFactorSecret The secret to generate two factor authentication tokens with, if you have two factor authentication enabled.
|
|
669
|
+
* Login to Twitter using API v2 credentials only.
|
|
670
|
+
* @param appKey The API key
|
|
671
|
+
* @param appSecret The API secret key
|
|
672
|
+
* @param accessToken The access token
|
|
673
|
+
* @param accessSecret The access token secret
|
|
1058
674
|
*/
|
|
1059
675
|
login(username: string, password: string, email?: string, twoFactorSecret?: string, appKey?: string, appSecret?: string, accessToken?: string, accessSecret?: string): Promise<void>;
|
|
1060
676
|
/**
|
|
1061
677
|
* Log out of Twitter.
|
|
678
|
+
* Note: With API v2, logout is not applicable as we use API credentials.
|
|
1062
679
|
*/
|
|
1063
680
|
logout(): Promise<void>;
|
|
1064
|
-
/**
|
|
1065
|
-
* Retrieves all cookies for the current session.
|
|
1066
|
-
* @returns All cookies for the current session.
|
|
1067
|
-
*/
|
|
1068
|
-
getCookies(): Promise<Cookie[]>;
|
|
1069
|
-
/**
|
|
1070
|
-
* Set cookies for the current session.
|
|
1071
|
-
* @param cookies The cookies to set for the current session.
|
|
1072
|
-
*/
|
|
1073
|
-
setCookies(cookies: (string | Cookie)[]): Promise<void>;
|
|
1074
|
-
/**
|
|
1075
|
-
* Clear all cookies for the current session.
|
|
1076
|
-
*/
|
|
1077
|
-
clearCookies(): Promise<void>;
|
|
1078
|
-
/**
|
|
1079
|
-
* Sets the optional cookie to be used in requests.
|
|
1080
|
-
* @param _cookie The cookie to be used in requests.
|
|
1081
|
-
* @deprecated This function no longer represents any part of Twitter's auth flow.
|
|
1082
|
-
* @returns This client instance.
|
|
1083
|
-
*/
|
|
1084
|
-
withCookie(_cookie: string): Client;
|
|
1085
|
-
/**
|
|
1086
|
-
* Sets the optional CSRF token to be used in requests.
|
|
1087
|
-
* @param _token The CSRF token to be used in requests.
|
|
1088
|
-
* @deprecated This function no longer represents any part of Twitter's auth flow.
|
|
1089
|
-
* @returns This client instance.
|
|
1090
|
-
*/
|
|
1091
|
-
withXCsrfToken(_token: string): Client;
|
|
1092
681
|
/**
|
|
1093
682
|
* Sends a quote tweet.
|
|
1094
683
|
* @param text The text of the tweet.
|
|
@@ -1101,13 +690,17 @@ declare class Client {
|
|
|
1101
690
|
data: Buffer;
|
|
1102
691
|
mediaType: string;
|
|
1103
692
|
}[];
|
|
1104
|
-
}): Promise<
|
|
693
|
+
}): Promise<{
|
|
694
|
+
ok: boolean;
|
|
695
|
+
json: () => Promise<twitter_api_v2.TweetV2PostTweetResult>;
|
|
696
|
+
data: twitter_api_v2.TweetV2PostTweetResult;
|
|
697
|
+
}>;
|
|
1105
698
|
/**
|
|
1106
699
|
* Delete a tweet with the given ID.
|
|
1107
700
|
* @param tweetId The ID of the tweet to delete.
|
|
1108
701
|
* @returns A promise that resolves when the tweet is deleted.
|
|
1109
702
|
*/
|
|
1110
|
-
deleteTweet(tweetId: string): Promise<
|
|
703
|
+
deleteTweet(tweetId: string): Promise<any>;
|
|
1111
704
|
/**
|
|
1112
705
|
* Likes a tweet with the given tweet ID.
|
|
1113
706
|
* @param tweetId The ID of the tweet to like.
|
|
@@ -1128,86 +721,22 @@ declare class Client {
|
|
|
1128
721
|
followUser(userName: string): Promise<void>;
|
|
1129
722
|
/**
|
|
1130
723
|
* Fetches direct message conversations
|
|
1131
|
-
*
|
|
1132
|
-
* @param
|
|
1133
|
-
* @
|
|
724
|
+
* Note: This functionality requires additional permissions and is not implemented in the current Twitter API v2 wrapper
|
|
725
|
+
* @param userId User ID
|
|
726
|
+
* @param cursor Pagination cursor
|
|
727
|
+
* @returns Array of DM conversations
|
|
1134
728
|
*/
|
|
1135
|
-
getDirectMessageConversations(userId: string, cursor?: string): Promise<
|
|
729
|
+
getDirectMessageConversations(userId: string, cursor?: string): Promise<any>;
|
|
1136
730
|
/**
|
|
1137
731
|
* Sends a direct message to a user.
|
|
1138
|
-
*
|
|
1139
|
-
* @param
|
|
1140
|
-
* @
|
|
732
|
+
* Note: This functionality requires additional permissions and is not implemented in the current Twitter API v2 wrapper
|
|
733
|
+
* @param conversationId The ID of the conversation
|
|
734
|
+
* @param text The text of the message
|
|
735
|
+
* @returns The response from the Twitter API
|
|
1141
736
|
*/
|
|
1142
|
-
sendDirectMessage(conversationId: string, text: string): Promise<
|
|
737
|
+
sendDirectMessage(conversationId: string, text: string): Promise<any>;
|
|
1143
738
|
private getAuthOptions;
|
|
1144
739
|
private handleResponse;
|
|
1145
|
-
/**
|
|
1146
|
-
* Retrieves the details of an Audio Space by its ID.
|
|
1147
|
-
* @param id The ID of the Audio Space.
|
|
1148
|
-
* @returns The details of the Audio Space.
|
|
1149
|
-
*/
|
|
1150
|
-
getAudioSpaceById(id: string): Promise<AudioSpace>;
|
|
1151
|
-
/**
|
|
1152
|
-
* Retrieves available space topics.
|
|
1153
|
-
* @returns An array of space topics.
|
|
1154
|
-
*/
|
|
1155
|
-
browseSpaceTopics(): Promise<Subtopic[]>;
|
|
1156
|
-
/**
|
|
1157
|
-
* Retrieves available communities.
|
|
1158
|
-
* @returns An array of communities.
|
|
1159
|
-
*/
|
|
1160
|
-
communitySelectQuery(): Promise<Community[]>;
|
|
1161
|
-
/**
|
|
1162
|
-
* Retrieves the status of an Audio Space stream by its media key.
|
|
1163
|
-
* @param mediaKey The media key of the Audio Space.
|
|
1164
|
-
* @returns The status of the Audio Space stream.
|
|
1165
|
-
*/
|
|
1166
|
-
getAudioSpaceStreamStatus(mediaKey: string): Promise<LiveVideoStreamStatus>;
|
|
1167
|
-
/**
|
|
1168
|
-
* Retrieves the status of an Audio Space by its ID.
|
|
1169
|
-
* This method internally fetches the Audio Space to obtain the media key,
|
|
1170
|
-
* then retrieves the stream status using the media key.
|
|
1171
|
-
* @param audioSpaceId The ID of the Audio Space.
|
|
1172
|
-
* @returns The status of the Audio Space stream.
|
|
1173
|
-
*/
|
|
1174
|
-
getAudioSpaceStatus(audioSpaceId: string): Promise<LiveVideoStreamStatus>;
|
|
1175
|
-
/**
|
|
1176
|
-
* Authenticates Periscope to obtain a token.
|
|
1177
|
-
* @returns The Periscope authentication token.
|
|
1178
|
-
*/
|
|
1179
|
-
authenticatePeriscope(): Promise<string>;
|
|
1180
|
-
/**
|
|
1181
|
-
* Logs in to Twitter via Proxsee using the Periscope JWT.
|
|
1182
|
-
* @param jwt The JWT obtained from AuthenticatePeriscope.
|
|
1183
|
-
* @returns The response containing the cookie and user information.
|
|
1184
|
-
*/
|
|
1185
|
-
loginTwitterToken(jwt: string): Promise<LoginTwitterTokenResponse>;
|
|
1186
|
-
/**
|
|
1187
|
-
* Orchestrates the flow: get token -> login -> return Periscope cookie
|
|
1188
|
-
*/
|
|
1189
|
-
getPeriscopeCookie(): Promise<string>;
|
|
1190
|
-
/**
|
|
1191
|
-
* Fetches a article (long form tweet) by its ID.
|
|
1192
|
-
* @param id The ID of the article to fetch. In the format of (http://x.com/i/article/id)
|
|
1193
|
-
* @returns The {@link TimelineArticle} object, or `null` if it couldn't be fetched.
|
|
1194
|
-
*/
|
|
1195
|
-
getArticle(id: string): Promise<TimelineArticle | null>;
|
|
1196
|
-
/**
|
|
1197
|
-
* Creates a new conversation with Grok.
|
|
1198
|
-
* @returns A promise that resolves to the conversation ID string.
|
|
1199
|
-
*/
|
|
1200
|
-
createGrokConversation(): Promise<string>;
|
|
1201
|
-
/**
|
|
1202
|
-
* Interact with Grok in a chat-like manner.
|
|
1203
|
-
* @param options The options for the Grok chat interaction.
|
|
1204
|
-
* @param {GrokMessage[]} options.messages - Array of messages in the conversation.
|
|
1205
|
-
* @param {string} [options.conversationId] - Optional ID of an existing conversation.
|
|
1206
|
-
* @param {boolean} [options.returnSearchResults] - Whether to return search results.
|
|
1207
|
-
* @param {boolean} [options.returnCitations] - Whether to return citations.
|
|
1208
|
-
* @returns A promise that resolves to the Grok chat response.
|
|
1209
|
-
*/
|
|
1210
|
-
grokChat(options: GrokChatOptions): Promise<GrokChatResponse>;
|
|
1211
740
|
/**
|
|
1212
741
|
* Retrieves all users who retweeted the given tweet.
|
|
1213
742
|
* @param tweetId The ID of the tweet.
|
|
@@ -1215,336 +744,21 @@ declare class Client {
|
|
|
1215
744
|
*/
|
|
1216
745
|
getRetweetersOfTweet(tweetId: string): Promise<Retweeter[]>;
|
|
1217
746
|
/**
|
|
1218
|
-
* Fetches all tweets
|
|
1219
|
-
*
|
|
1220
|
-
* @param
|
|
1221
|
-
* @
|
|
1222
|
-
* @returns An array of all Tweet objects referencing the given tweet.
|
|
1223
|
-
*/
|
|
1224
|
-
getAllQuotedTweets(quotedTweetId: string, maxTweetsPerPage?: number): Promise<Tweet$1[]>;
|
|
1225
|
-
}
|
|
1226
|
-
|
|
1227
|
-
/**
|
|
1228
|
-
* Interface representing the configuration options for a space participant.
|
|
1229
|
-
* @typedef {object} SpaceParticipantConfig
|
|
1230
|
-
* @property {string} spaceId - The unique identifier for the space.
|
|
1231
|
-
* @property {boolean} [debug] - Optional flag for enabling debug mode.
|
|
1232
|
-
*/
|
|
1233
|
-
interface SpaceParticipantConfig {
|
|
1234
|
-
spaceId: string;
|
|
1235
|
-
debug?: boolean;
|
|
1236
|
-
}
|
|
1237
|
-
/**
|
|
1238
|
-
* Manages joining an existing Space in listener mode,
|
|
1239
|
-
* and optionally becoming a speaker via WebRTC (Janus).
|
|
1240
|
-
*/
|
|
1241
|
-
/**
|
|
1242
|
-
* Class representing a participant in a space.
|
|
1243
|
-
* @extends EventEmitter
|
|
1244
|
-
*/
|
|
1245
|
-
declare class SpaceParticipant extends EventEmitter {
|
|
1246
|
-
private readonly client;
|
|
1247
|
-
private readonly spaceId;
|
|
1248
|
-
private readonly debug;
|
|
1249
|
-
private readonly logger;
|
|
1250
|
-
private cookie?;
|
|
1251
|
-
private authToken?;
|
|
1252
|
-
private chatJwtToken?;
|
|
1253
|
-
private chatToken?;
|
|
1254
|
-
private chatClient?;
|
|
1255
|
-
private lifecycleToken?;
|
|
1256
|
-
private watchSession?;
|
|
1257
|
-
private hlsUrl?;
|
|
1258
|
-
private sessionUUID?;
|
|
1259
|
-
private janusJwt?;
|
|
1260
|
-
private webrtcGwUrl?;
|
|
1261
|
-
private janusClient?;
|
|
1262
|
-
private plugins;
|
|
1263
|
-
constructor(client: Client, config: SpaceParticipantConfig);
|
|
1264
|
-
/**
|
|
1265
|
-
* Adds a plugin and calls its onAttach immediately.
|
|
1266
|
-
* init() or onJanusReady() will be invoked later at the appropriate time.
|
|
1267
|
-
*/
|
|
1268
|
-
use(plugin: Plugin, config?: Record<string, any>): this;
|
|
1269
|
-
/**
|
|
1270
|
-
* Joins the Space as a listener: obtains HLS, chat token, etc.
|
|
1271
|
-
*/
|
|
1272
|
-
joinAsListener(): Promise<void>;
|
|
1273
|
-
/**
|
|
1274
|
-
* Returns the HLS URL if you want to consume the stream as a listener.
|
|
1275
|
-
*/
|
|
1276
|
-
getHlsUrl(): string | undefined;
|
|
1277
|
-
/**
|
|
1278
|
-
* Submits a speaker request using /audiospace/request/submit.
|
|
1279
|
-
* Returns the sessionUUID used to track approval.
|
|
1280
|
-
*/
|
|
1281
|
-
requestSpeaker(): Promise<{
|
|
1282
|
-
sessionUUID: string;
|
|
1283
|
-
}>;
|
|
1284
|
-
/**
|
|
1285
|
-
* Cancels a previously submitted speaker request using /audiospace/request/cancel.
|
|
1286
|
-
* This requires a valid sessionUUID from requestSpeaker() first.
|
|
1287
|
-
*/
|
|
1288
|
-
cancelSpeakerRequest(): Promise<void>;
|
|
1289
|
-
/**
|
|
1290
|
-
* Once the host approves our speaker request, we perform Janus negotiation
|
|
1291
|
-
* to become a speaker.
|
|
1292
|
-
*/
|
|
1293
|
-
becomeSpeaker(): Promise<void>;
|
|
1294
|
-
/**
|
|
1295
|
-
* Removes self from the speaker role and transitions back to a listener.
|
|
1296
|
-
*/
|
|
1297
|
-
removeFromSpeaker(): Promise<void>;
|
|
1298
|
-
/**
|
|
1299
|
-
* Leaves the Space gracefully:
|
|
1300
|
-
* - Stop Janus if we were a speaker
|
|
1301
|
-
* - Stop watching as a viewer
|
|
1302
|
-
* - Disconnect chat
|
|
1303
|
-
*/
|
|
1304
|
-
leaveSpace(): Promise<void>;
|
|
1305
|
-
/**
|
|
1306
|
-
* Pushes PCM audio frames if we're speaker; otherwise logs a warning.
|
|
1307
|
-
*/
|
|
1308
|
-
pushAudio(samples: Int16Array, sampleRate: number): void;
|
|
1309
|
-
/**
|
|
1310
|
-
* Internal handler for incoming PCM frames from Janus, forwarded to plugin.onAudioData if present.
|
|
1311
|
-
*/
|
|
1312
|
-
private handleAudioData;
|
|
1313
|
-
/**
|
|
1314
|
-
* Sets up chat events: "occupancyUpdate", "newSpeakerAccepted", etc.
|
|
747
|
+
* Fetches all quoted tweets for a given tweet ID, handling pagination automatically.
|
|
748
|
+
* @param tweetId The ID of the tweet to fetch quotes for.
|
|
749
|
+
* @param maxQuotes Maximum number of quotes to return (default: 100).
|
|
750
|
+
* @returns An array of all quoted tweets.
|
|
1315
751
|
*/
|
|
1316
|
-
|
|
752
|
+
fetchAllQuotedTweets(tweetId: string, maxQuotes?: number): Promise<Tweet$1[]>;
|
|
1317
753
|
/**
|
|
1318
|
-
*
|
|
754
|
+
* Fetches quoted tweets for a given tweet ID.
|
|
755
|
+
* This method now uses a generator function internally but maintains backward compatibility.
|
|
756
|
+
* @param tweetId The ID of the tweet to fetch quotes for.
|
|
757
|
+
* @param maxQuotes Maximum number of quotes to return.
|
|
758
|
+
* @param cursor Optional cursor for pagination.
|
|
759
|
+
* @returns A promise that resolves to a QueryTweetsResponse containing tweets and the next cursor.
|
|
1319
760
|
*/
|
|
1320
|
-
|
|
1321
|
-
/**
|
|
1322
|
-
* Unmute self if we are speaker: calls /audiospace/unmuteSpeaker with our sessionUUID.
|
|
1323
|
-
*/
|
|
1324
|
-
unmuteSelf(): Promise<void>;
|
|
1325
|
-
}
|
|
1326
|
-
|
|
1327
|
-
/**
|
|
1328
|
-
* Basic PCM audio frame properties.
|
|
1329
|
-
*/
|
|
1330
|
-
/**
|
|
1331
|
-
* Represents audio data with specified characteristics.
|
|
1332
|
-
* @typedef {Object} AudioData
|
|
1333
|
-
* @property {number} bitsPerSample - Bits per sample (e.g., 16).
|
|
1334
|
-
* @property {number} sampleRate - The sample rate in Hz (e.g., 48000 for 48kHz).
|
|
1335
|
-
* @property {number} channelCount - Number of channels (e.g., 1 for mono, 2 for stereo).
|
|
1336
|
-
* @property {number} numberOfFrames - Number of frames (samples per channel).
|
|
1337
|
-
* @property {Int16Array} samples - The raw PCM data for all channels (interleaved if stereo).
|
|
1338
|
-
*/
|
|
1339
|
-
interface AudioData {
|
|
1340
|
-
/**
|
|
1341
|
-
* Bits per sample (e.g., 16).
|
|
1342
|
-
*/
|
|
1343
|
-
bitsPerSample: number;
|
|
1344
|
-
/**
|
|
1345
|
-
* The sample rate in Hz (e.g., 48000 for 48kHz).
|
|
1346
|
-
*/
|
|
1347
|
-
sampleRate: number;
|
|
1348
|
-
/**
|
|
1349
|
-
* Number of channels (e.g., 1 for mono, 2 for stereo).
|
|
1350
|
-
*/
|
|
1351
|
-
channelCount: number;
|
|
1352
|
-
/**
|
|
1353
|
-
* Number of frames (samples per channel).
|
|
1354
|
-
*/
|
|
1355
|
-
numberOfFrames: number;
|
|
1356
|
-
/**
|
|
1357
|
-
* The raw PCM data for all channels (interleaved if stereo).
|
|
1358
|
-
*/
|
|
1359
|
-
samples: Int16Array;
|
|
1360
|
-
}
|
|
1361
|
-
/**
|
|
1362
|
-
* PCM audio data with an associated user ID, indicating which speaker produced it.
|
|
1363
|
-
*/
|
|
1364
|
-
interface AudioDataWithUser extends AudioData {
|
|
1365
|
-
/**
|
|
1366
|
-
* The ID of the speaker or user who produced this audio frame.
|
|
1367
|
-
*/
|
|
1368
|
-
userId: string;
|
|
1369
|
-
}
|
|
1370
|
-
/**
|
|
1371
|
-
* Response structure after creating a broadcast on Periscope/Twitter.
|
|
1372
|
-
*/
|
|
1373
|
-
interface BroadcastCreated {
|
|
1374
|
-
room_id: string;
|
|
1375
|
-
credential: string;
|
|
1376
|
-
stream_name: string;
|
|
1377
|
-
webrtc_gw_url: string;
|
|
1378
|
-
broadcast: {
|
|
1379
|
-
user_id: string;
|
|
1380
|
-
twitter_id: string;
|
|
1381
|
-
media_key: string;
|
|
1382
|
-
};
|
|
1383
|
-
access_token: string;
|
|
1384
|
-
endpoint: string;
|
|
1385
|
-
share_url: string;
|
|
1386
|
-
stream_url: string;
|
|
1387
|
-
}
|
|
1388
|
-
/**
|
|
1389
|
-
* Defines a plugin interface for both Space (broadcast host) and SpaceParticipant (listener/speaker).
|
|
1390
|
-
*
|
|
1391
|
-
* Lifecycle hooks:
|
|
1392
|
-
* - onAttach(...) is called immediately after .use(plugin).
|
|
1393
|
-
* - init(...) is called after the space or participant has joined in basic mode (listener + chat).
|
|
1394
|
-
* - onJanusReady(...) is called if/when a JanusClient is created (i.e., speaker mode).
|
|
1395
|
-
* - onAudioData(...) is called upon receiving raw PCM frames from a speaker.
|
|
1396
|
-
* - cleanup(...) is called when the space/participant stops or the plugin is removed.
|
|
1397
|
-
*/
|
|
1398
|
-
interface Plugin {
|
|
1399
|
-
/**
|
|
1400
|
-
* Called immediately when the plugin is added via .use(plugin).
|
|
1401
|
-
* Usually used for initial references or minimal setup.
|
|
1402
|
-
*/
|
|
1403
|
-
onAttach?(params: {
|
|
1404
|
-
space: Space | SpaceParticipant;
|
|
1405
|
-
pluginConfig?: Record<string, any>;
|
|
1406
|
-
}): void;
|
|
1407
|
-
/**
|
|
1408
|
-
* Called once the space/participant has fully initialized basic features (chat, HLS, etc.).
|
|
1409
|
-
* This is the ideal place to finalize setup for plugins that do not require Janus/speaker mode.
|
|
1410
|
-
*/
|
|
1411
|
-
init?(params: {
|
|
1412
|
-
space: Space | SpaceParticipant;
|
|
1413
|
-
pluginConfig?: Record<string, any>;
|
|
1414
|
-
}): void;
|
|
1415
|
-
/**
|
|
1416
|
-
* Called if/when a JanusClient becomes available (e.g., user becomes a speaker).
|
|
1417
|
-
* Plugins that need direct Janus interactions can implement logic here.
|
|
1418
|
-
*/
|
|
1419
|
-
onJanusReady?(janusClient: any): void;
|
|
1420
|
-
/**
|
|
1421
|
-
* Called whenever raw PCM audio frames arrive from a speaker.
|
|
1422
|
-
* Useful for speech-to-text, analytics, or logging.
|
|
1423
|
-
*/
|
|
1424
|
-
onAudioData?(data: AudioDataWithUser): void;
|
|
1425
|
-
/**
|
|
1426
|
-
* Cleanup lifecycle hook, invoked when the plugin is removed or the space/participant stops.
|
|
1427
|
-
* Allows releasing resources, stopping timers, or closing file handles.
|
|
1428
|
-
*/
|
|
1429
|
-
cleanup?(): void;
|
|
1430
|
-
}
|
|
1431
|
-
/**
|
|
1432
|
-
* Stores information about a speaker in a Space (host perspective).
|
|
1433
|
-
*/
|
|
1434
|
-
interface SpeakerInfo {
|
|
1435
|
-
userId: string;
|
|
1436
|
-
sessionUUID: string;
|
|
1437
|
-
janusParticipantId?: number;
|
|
1438
|
-
}
|
|
1439
|
-
interface SpaceConfig {
|
|
1440
|
-
mode: 'BROADCAST' | 'LISTEN' | 'INTERACTIVE';
|
|
1441
|
-
title?: string;
|
|
1442
|
-
description?: string;
|
|
1443
|
-
languages?: string[];
|
|
1444
|
-
debug?: boolean;
|
|
1445
|
-
record: boolean;
|
|
1446
|
-
}
|
|
1447
|
-
|
|
1448
|
-
/**
|
|
1449
|
-
* Manages the creation of a new Space (broadcast host):
|
|
1450
|
-
* 1) Creates the broadcast on Periscope
|
|
1451
|
-
* 2) Sets up Janus WebRTC for audio
|
|
1452
|
-
* 3) Optionally creates a ChatClient for interactive mode
|
|
1453
|
-
* 4) Allows managing (approve/remove) speakers, pushing audio, etc.
|
|
1454
|
-
*/
|
|
1455
|
-
/**
|
|
1456
|
-
* Represents a space that can be used for communication and collaboration.
|
|
1457
|
-
* Extends the EventEmitter class and contains properties for debugging, logging, Janus client, chat client, authentication token,
|
|
1458
|
-
* and broadcast information.
|
|
1459
|
-
*/
|
|
1460
|
-
declare class Space extends EventEmitter {
|
|
1461
|
-
private readonly client;
|
|
1462
|
-
private readonly debug;
|
|
1463
|
-
private readonly logger;
|
|
1464
|
-
private janusClient?;
|
|
1465
|
-
private chatClient?;
|
|
1466
|
-
private authToken?;
|
|
1467
|
-
private broadcastInfo?;
|
|
1468
|
-
private isInitialized;
|
|
1469
|
-
private plugins;
|
|
1470
|
-
private speakers;
|
|
1471
|
-
constructor(client: Client, options?: {
|
|
1472
|
-
debug?: boolean;
|
|
1473
|
-
});
|
|
1474
|
-
/**
|
|
1475
|
-
* Registers a plugin and calls its onAttach(...).
|
|
1476
|
-
* init(...) will be invoked once initialization is complete.
|
|
1477
|
-
*/
|
|
1478
|
-
use(plugin: Plugin, config?: Record<string, any>): this;
|
|
1479
|
-
/**
|
|
1480
|
-
* Main entry point to create and initialize the Space broadcast.
|
|
1481
|
-
*/
|
|
1482
|
-
initialize(config: SpaceConfig): Promise<BroadcastCreated>;
|
|
1483
|
-
/**
|
|
1484
|
-
* Send an emoji reaction via chat, if interactive.
|
|
1485
|
-
*/
|
|
1486
|
-
reactWithEmoji(emoji: string): void;
|
|
1487
|
-
/**
|
|
1488
|
-
* Internal method to wire up chat events if interactive.
|
|
1489
|
-
*/
|
|
1490
|
-
private setupChatEvents;
|
|
1491
|
-
/**
|
|
1492
|
-
* Approves a speaker request on Twitter side, then calls Janus to subscribe their audio.
|
|
1493
|
-
*/
|
|
1494
|
-
approveSpeaker(userId: string, sessionUUID: string): Promise<void>;
|
|
1495
|
-
/**
|
|
1496
|
-
* Approve request => calls /api/v1/audiospace/request/approve
|
|
1497
|
-
*/
|
|
1498
|
-
private callApproveEndpoint;
|
|
1499
|
-
/**
|
|
1500
|
-
* Removes a speaker from the Twitter side, then unsubscribes in Janus if needed.
|
|
1501
|
-
*/
|
|
1502
|
-
removeSpeaker(userId: string): Promise<void>;
|
|
1503
|
-
/**
|
|
1504
|
-
* Twitter's /api/v1/audiospace/stream/eject call
|
|
1505
|
-
*/
|
|
1506
|
-
private callRemoveEndpoint;
|
|
1507
|
-
/**
|
|
1508
|
-
* Push PCM audio frames if you're the host. Usually you'd do this if you're capturing
|
|
1509
|
-
* microphone input from the host side.
|
|
1510
|
-
*/
|
|
1511
|
-
pushAudio(samples: Int16Array, sampleRate: number): void;
|
|
1512
|
-
/**
|
|
1513
|
-
* Handler for PCM from other speakers, forwarded to plugin.onAudioData
|
|
1514
|
-
*/
|
|
1515
|
-
private handleAudioData;
|
|
1516
|
-
/**
|
|
1517
|
-
* Gracefully shut down this Space: destroy the Janus room, end the broadcast, etc.
|
|
1518
|
-
*/
|
|
1519
|
-
finalizeSpace(): Promise<void>;
|
|
1520
|
-
/**
|
|
1521
|
-
* Calls /api/v1/audiospace/admin/endAudiospace on Twitter side.
|
|
1522
|
-
*/
|
|
1523
|
-
private endAudiospace;
|
|
1524
|
-
/**
|
|
1525
|
-
* Retrieves an array of known speakers in this Space (by userId and sessionUUID).
|
|
1526
|
-
*/
|
|
1527
|
-
getSpeakers(): SpeakerInfo[];
|
|
1528
|
-
/**
|
|
1529
|
-
* Mute the host (yourself). For the host, session_uuid = '' (empty).
|
|
1530
|
-
*/
|
|
1531
|
-
muteHost(): Promise<void>;
|
|
1532
|
-
/**
|
|
1533
|
-
* Unmute the host (yourself).
|
|
1534
|
-
*/
|
|
1535
|
-
unmuteHost(): Promise<void>;
|
|
1536
|
-
/**
|
|
1537
|
-
* Mute a specific speaker. We'll retrieve sessionUUID from our local map.
|
|
1538
|
-
*/
|
|
1539
|
-
muteSpeaker(userId: string): Promise<void>;
|
|
1540
|
-
/**
|
|
1541
|
-
* Unmute a specific speaker. We'll retrieve sessionUUID from local map.
|
|
1542
|
-
*/
|
|
1543
|
-
unmuteSpeaker(userId: string): Promise<void>;
|
|
1544
|
-
/**
|
|
1545
|
-
* Stop the broadcast entirely, performing finalizeSpace() plus plugin cleanup.
|
|
1546
|
-
*/
|
|
1547
|
-
stop(): Promise<void>;
|
|
761
|
+
fetchQuotedTweetsPage(tweetId: string, maxQuotes?: number, cursor?: string): Promise<QueryTweetsResponse>;
|
|
1548
762
|
}
|
|
1549
763
|
|
|
1550
764
|
/**
|
|
@@ -1657,116 +871,17 @@ declare class TwitterPostClient {
|
|
|
1657
871
|
}
|
|
1658
872
|
|
|
1659
873
|
/**
|
|
1660
|
-
*
|
|
1661
|
-
*
|
|
1662
|
-
* @
|
|
1663
|
-
* @
|
|
1664
|
-
* @property {
|
|
1665
|
-
* @property {
|
|
1666
|
-
* @property {string} IDLE - Indicates that the space is not currently being used.
|
|
1667
|
-
*/
|
|
1668
|
-
declare enum SpaceActivity {
|
|
1669
|
-
HOSTING = "hosting",
|
|
1670
|
-
PARTICIPATING = "participating",
|
|
1671
|
-
IDLE = "idle"
|
|
1672
|
-
}
|
|
1673
|
-
/**
|
|
1674
|
-
* An enum representing the activity role of a participant.
|
|
1675
|
-
* @enum {string}
|
|
1676
|
-
* @readonly
|
|
1677
|
-
* @property {string} LISTENER - Represents a participant who is a listener.
|
|
1678
|
-
* @property {string} SPEAKER - Represents a participant who is a speaker.
|
|
1679
|
-
* @property {string} PENDING - Represents a participant whose activity is pending.
|
|
1680
|
-
*/
|
|
1681
|
-
declare enum ParticipantActivity {
|
|
1682
|
-
LISTENER = "listener",
|
|
1683
|
-
SPEAKER = "speaker",
|
|
1684
|
-
PENDING = "pending"
|
|
1685
|
-
}
|
|
1686
|
-
/**
|
|
1687
|
-
* Main class: manage a Twitter Space with N speakers max, speaker queue, filler messages, etc.
|
|
1688
|
-
*/
|
|
1689
|
-
/**
|
|
1690
|
-
* Represents a client for interacting with Twitter Spaces.
|
|
1691
|
-
* * @class
|
|
1692
|
-
* @property { IAgentRuntime } runtime - The agent runtime for the client.
|
|
1693
|
-
* @property { ClientBase } client - The base client for making requests.
|
|
1694
|
-
* @property { Client } twitterClient - The Twitter client for interacting with Twitter API.
|
|
1695
|
-
* @property {Space | undefined} currentSpace - The current Twitter Space the client is connected to (if any).
|
|
1696
|
-
* @property {string | undefined} spaceId - The ID of the Twitter Space the client is connected to (if any).
|
|
1697
|
-
* @property {number | undefined} startedAt - The timestamp when the client was started.
|
|
1698
|
-
* @property {NodeJS.Timeout | undefined} checkInterval - The interval for checking the status of the Twitter Space.
|
|
1699
|
-
* @property {number | undefined} lastSpaceEndedAt - The timestamp of when the last Twitter Space ended.
|
|
1700
|
-
*/
|
|
1701
|
-
declare class TwitterSpaceClient {
|
|
1702
|
-
private runtime;
|
|
1703
|
-
private client;
|
|
1704
|
-
private twitterClient;
|
|
1705
|
-
private currentSpace?;
|
|
1706
|
-
private spaceId?;
|
|
1707
|
-
private startedAt?;
|
|
1708
|
-
private checkInterval?;
|
|
1709
|
-
private lastSpaceEndedAt?;
|
|
1710
|
-
private sttTtsPlugin?;
|
|
1711
|
-
spaceStatus: SpaceActivity;
|
|
1712
|
-
private spaceParticipant;
|
|
1713
|
-
participantStatus: ParticipantActivity;
|
|
1714
|
-
/**
|
|
1715
|
-
* We now store an array of active speakers, not just 1
|
|
1716
|
-
*/
|
|
1717
|
-
private activeSpeakers;
|
|
1718
|
-
private speakerQueue;
|
|
1719
|
-
private decisionOptions;
|
|
1720
|
-
constructor(client: ClientBase, runtime: IAgentRuntime);
|
|
1721
|
-
/**
|
|
1722
|
-
* Periodic check to launch or manage space
|
|
1723
|
-
*/
|
|
1724
|
-
startPeriodicSpaceCheck(): Promise<void>;
|
|
1725
|
-
stopPeriodicCheck(): void;
|
|
1726
|
-
private shouldLaunchSpace;
|
|
1727
|
-
private generateSpaceConfig;
|
|
1728
|
-
startSpace(config: SpaceConfig): Promise<void>;
|
|
1729
|
-
/**
|
|
1730
|
-
* Periodic management: check durations, remove extras, maybe accept new from queue
|
|
1731
|
-
*/
|
|
1732
|
-
private manageCurrentSpace;
|
|
1733
|
-
/**
|
|
1734
|
-
* If we have available slots, accept new speakers from the queue
|
|
1735
|
-
*/
|
|
1736
|
-
private acceptSpeakersFromQueueIfNeeded;
|
|
1737
|
-
private handleSpeakerRequest;
|
|
1738
|
-
private acceptSpeaker;
|
|
1739
|
-
private removeSpeaker;
|
|
1740
|
-
/**
|
|
1741
|
-
* If more than maxSpeakers are found, remove extras
|
|
1742
|
-
* Also update activeSpeakers array
|
|
1743
|
-
*/
|
|
1744
|
-
private kickExtraSpeakers;
|
|
1745
|
-
stopSpace(): Promise<void>;
|
|
1746
|
-
startParticipant(spaceId: string): Promise<string>;
|
|
1747
|
-
manageParticipant(): Promise<void>;
|
|
1748
|
-
stopParticipant(): Promise<void>;
|
|
1749
|
-
/**
|
|
1750
|
-
* waitForApproval waits until "newSpeakerAccepted" matches our sessionUUID,
|
|
1751
|
-
* then calls becomeSpeaker() or rejects after a given timeout.
|
|
1752
|
-
*/
|
|
1753
|
-
waitForApproval(participant: SpaceParticipant, sessionUUID: string, timeoutMs?: number): Promise<void>;
|
|
1754
|
-
}
|
|
1755
|
-
|
|
1756
|
-
/**
|
|
1757
|
-
* Interface for a Twitter client.
|
|
1758
|
-
*
|
|
1759
|
-
* @property {ClientBase} client - The base client for making requests.
|
|
1760
|
-
* @property {TwitterPostClient} post - The client for posting on Twitter.
|
|
1761
|
-
* @property {TwitterInteractionClient} interaction - The client for interacting with tweets.
|
|
1762
|
-
* @property {TwitterSpaceClient} [space] - The client for managing Twitter spaces (optional).
|
|
1763
|
-
* @property {TwitterService} service - The service provider for Twitter API.
|
|
874
|
+
* @interface ITwitterClient
|
|
875
|
+
* Represents the main Twitter client interface for interacting with Twitter's API.
|
|
876
|
+
* @property {ClientBase} client - The base client for Twitter operations.
|
|
877
|
+
* @property {TwitterPostClient} post - The client for managing Twitter posts.
|
|
878
|
+
* @property {TwitterInteractionClient} interaction - The client for managing Twitter interactions.
|
|
879
|
+
* @property {TwitterService} service - The main Twitter service instance.
|
|
1764
880
|
*/
|
|
1765
881
|
interface ITwitterClient {
|
|
1766
882
|
client: ClientBase;
|
|
1767
883
|
post: TwitterPostClient;
|
|
1768
884
|
interaction: TwitterInteractionClient;
|
|
1769
|
-
space?: TwitterSpaceClient;
|
|
1770
885
|
service: TwitterService;
|
|
1771
886
|
}
|
|
1772
887
|
/**
|
|
@@ -1908,7 +1023,6 @@ declare class ClientBase {
|
|
|
1908
1023
|
* @param {number} [maxDepth=3] - The maximum depth allowed for parsing nested quotes/retweets.
|
|
1909
1024
|
* @returns {Tweet} The parsed Tweet object.
|
|
1910
1025
|
*/
|
|
1911
|
-
parseTweet(raw: any, depth?: number, maxDepth?: number): Tweet$1;
|
|
1912
1026
|
state: any;
|
|
1913
1027
|
constructor(runtime: IAgentRuntime, state: any);
|
|
1914
1028
|
init(): Promise<void>;
|
|
@@ -1919,15 +1033,12 @@ declare class ClientBase {
|
|
|
1919
1033
|
fetchHomeTimeline(count: number, following?: boolean): Promise<Tweet$1[]>;
|
|
1920
1034
|
fetchSearchTweets(query: string, maxTweets: number, searchMode: SearchMode, cursor?: string): Promise<QueryTweetsResponse>;
|
|
1921
1035
|
private populateTimeline;
|
|
1922
|
-
setCookiesFromArray(cookiesArray: any[]): Promise<void>;
|
|
1923
1036
|
saveRequestMessage(message: Memory, state: State): Promise<void>;
|
|
1924
1037
|
loadLatestCheckedTweetId(): Promise<void>;
|
|
1925
1038
|
cacheLatestCheckedTweetId(): Promise<void>;
|
|
1926
1039
|
getCachedTimeline(): Promise<Tweet$1[] | undefined>;
|
|
1927
1040
|
cacheTimeline(timeline: Tweet$1[]): Promise<void>;
|
|
1928
1041
|
cacheMentions(mentions: Tweet$1[]): Promise<void>;
|
|
1929
|
-
getCachedCookies(username: string): Promise<any[]>;
|
|
1930
|
-
cacheCookies(username: string, cookies: any[]): Promise<void>;
|
|
1931
1042
|
fetchProfile(username: string): Promise<TwitterProfile>;
|
|
1932
1043
|
/**
|
|
1933
1044
|
* Fetches recent interactions (likes, retweets, quotes) for the authenticated user's tweets
|
|
@@ -1995,7 +1106,6 @@ declare class TwitterClientInstance implements ITwitterClient {
|
|
|
1995
1106
|
post: TwitterPostClient;
|
|
1996
1107
|
interaction: TwitterInteractionClient;
|
|
1997
1108
|
timeline?: TwitterTimelineClient;
|
|
1998
|
-
space?: TwitterSpaceClient;
|
|
1999
1109
|
service: TwitterService;
|
|
2000
1110
|
constructor(runtime: IAgentRuntime, state: any);
|
|
2001
1111
|
}
|
|
@@ -2019,6 +1129,6 @@ declare class TwitterService extends Service {
|
|
|
2019
1129
|
stopAllClients(): Promise<void>;
|
|
2020
1130
|
private getClientKey;
|
|
2021
1131
|
}
|
|
2022
|
-
declare const twitterPlugin: Plugin
|
|
1132
|
+
declare const twitterPlugin: Plugin;
|
|
2023
1133
|
|
|
2024
1134
|
export { TwitterClientInstance, TwitterService, twitterPlugin as default };
|