@elizaos/plugin-twitter 1.0.8 → 1.0.13
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 +181 -91
- package/dist/index.d.ts +126 -949
- package/dist/index.js +2021 -7284
- package/dist/index.js.map +1 -1
- package/package.json +202 -21
- 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,7 +1,41 @@
|
|
|
1
|
-
import { IAgentRuntime, Memory, State, ChannelType, Plugin
|
|
2
|
-
import
|
|
3
|
-
import { PollV2, TTweetv2Expansion, TTweetv2TweetField, TTweetv2PollField, TTweetv2MediaField, TTweetv2UserField, TTweetv2PlaceField } from 'twitter-api-v2';
|
|
4
|
-
|
|
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';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Twitter API v2 authentication using developer credentials
|
|
7
|
+
*/
|
|
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;
|
|
18
|
+
/**
|
|
19
|
+
* Get the Twitter API v2 client
|
|
20
|
+
*/
|
|
21
|
+
getV2Client(): TwitterApi;
|
|
22
|
+
/**
|
|
23
|
+
* Check if authenticated
|
|
24
|
+
*/
|
|
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;
|
|
38
|
+
}
|
|
5
39
|
|
|
6
40
|
/**
|
|
7
41
|
* Represents an array type for parameters used in the fetch function,
|
|
@@ -99,191 +133,29 @@ interface Profile {
|
|
|
99
133
|
}
|
|
100
134
|
|
|
101
135
|
/**
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
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.
|
|
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)
|
|
221
139
|
*/
|
|
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
140
|
/**
|
|
242
|
-
* Interface representing a
|
|
243
|
-
* @
|
|
244
|
-
* @property {
|
|
245
|
-
* @property {string}
|
|
246
|
-
* @property {string}
|
|
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.
|
|
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.
|
|
252
146
|
*/
|
|
253
|
-
interface
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
profileImageUrl: string;
|
|
258
|
-
description?: string;
|
|
259
|
-
verified?: boolean;
|
|
260
|
-
protected?: boolean;
|
|
261
|
-
followersCount?: number;
|
|
262
|
-
friendsCount?: number;
|
|
147
|
+
interface QueryTweetsResponse {
|
|
148
|
+
tweets: Tweet$1[];
|
|
149
|
+
next?: string;
|
|
150
|
+
previous?: string;
|
|
263
151
|
}
|
|
264
152
|
/**
|
|
265
|
-
*
|
|
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.
|
|
153
|
+
* A paginated profiles API response. The `next` field can be used to fetch the next page of results.
|
|
269
154
|
*/
|
|
270
|
-
interface
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
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>;
|
|
155
|
+
interface QueryProfilesResponse {
|
|
156
|
+
profiles: Profile[];
|
|
157
|
+
next?: string;
|
|
158
|
+
previous?: string;
|
|
287
159
|
}
|
|
288
160
|
|
|
289
161
|
/**
|
|
@@ -485,32 +357,6 @@ interface Retweeter {
|
|
|
485
357
|
}
|
|
486
358
|
type TweetQuery = Partial<Tweet$1> | ((tweet: Tweet$1) => boolean | Promise<boolean>);
|
|
487
359
|
|
|
488
|
-
/**
|
|
489
|
-
* A paginated tweets API response. The `next` field can be used to fetch the next page of results,
|
|
490
|
-
* and the `previous` can be used to fetch the previous results (or results created after the
|
|
491
|
-
* initial request)
|
|
492
|
-
*/
|
|
493
|
-
/**
|
|
494
|
-
* Interface representing the response from a query tweets request.
|
|
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.
|
|
499
|
-
*/
|
|
500
|
-
interface QueryTweetsResponse {
|
|
501
|
-
tweets: Tweet$1[];
|
|
502
|
-
next?: string;
|
|
503
|
-
previous?: string;
|
|
504
|
-
}
|
|
505
|
-
/**
|
|
506
|
-
* A paginated profiles API response. The `next` field can be used to fetch the next page of results.
|
|
507
|
-
*/
|
|
508
|
-
interface QueryProfilesResponse {
|
|
509
|
-
profiles: Profile[];
|
|
510
|
-
next?: string;
|
|
511
|
-
previous?: string;
|
|
512
|
-
}
|
|
513
|
-
|
|
514
360
|
/**
|
|
515
361
|
* The categories that can be used in Twitter searches.
|
|
516
362
|
*/
|
|
@@ -526,202 +372,6 @@ declare enum SearchMode {
|
|
|
526
372
|
Users = 4
|
|
527
373
|
}
|
|
528
374
|
|
|
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
375
|
/**
|
|
726
376
|
* An alternative fetch function to use instead of the default fetch function. This may be useful
|
|
727
377
|
* in nonstandard runtime environments, such as edge workers.
|
|
@@ -744,26 +394,17 @@ interface ClientOptions {
|
|
|
744
394
|
transform: Partial<FetchTransformOptions>;
|
|
745
395
|
}
|
|
746
396
|
/**
|
|
747
|
-
* An interface to Twitter's
|
|
397
|
+
* An interface to Twitter's API v2.
|
|
748
398
|
* - Reusing Client objects is recommended to minimize the time spent authenticating unnecessarily.
|
|
749
399
|
*/
|
|
750
400
|
declare class Client {
|
|
751
401
|
private readonly options?;
|
|
752
|
-
private auth
|
|
753
|
-
private authTrends;
|
|
754
|
-
private token;
|
|
402
|
+
private auth?;
|
|
755
403
|
/**
|
|
756
404
|
* Creates a new Client object.
|
|
757
|
-
* - Clients maintain their own guest tokens for Twitter's internal API.
|
|
758
405
|
* - Reusing Client objects is recommended to minimize the time spent authenticating unnecessarily.
|
|
759
406
|
*/
|
|
760
407
|
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
408
|
/**
|
|
768
409
|
* Fetches a Twitter profile.
|
|
769
410
|
* @param username The Twitter username of the profile to fetch, without an `@` at the beginning.
|
|
@@ -902,11 +543,19 @@ declare class Client {
|
|
|
902
543
|
sendTweet(text: string, replyToTweetId?: string, mediaData?: {
|
|
903
544
|
data: Buffer;
|
|
904
545
|
mediaType: string;
|
|
905
|
-
}[], hideLinkPreview?: boolean): Promise<
|
|
546
|
+
}[], hideLinkPreview?: boolean): Promise<{
|
|
547
|
+
ok: boolean;
|
|
548
|
+
json: () => Promise<twitter_api_v2.TweetV2PostTweetResult>;
|
|
549
|
+
data: twitter_api_v2.TweetV2PostTweetResult;
|
|
550
|
+
}>;
|
|
906
551
|
sendNoteTweet(text: string, replyToTweetId?: string, mediaData?: {
|
|
907
552
|
data: Buffer;
|
|
908
553
|
mediaType: string;
|
|
909
|
-
}[]): Promise<
|
|
554
|
+
}[]): Promise<{
|
|
555
|
+
ok: boolean;
|
|
556
|
+
json: () => Promise<twitter_api_v2.TweetV2PostTweetResult>;
|
|
557
|
+
data: twitter_api_v2.TweetV2PostTweetResult;
|
|
558
|
+
}>;
|
|
910
559
|
/**
|
|
911
560
|
* Send a long tweet (Note Tweet)
|
|
912
561
|
* @param text The text of the tweet
|
|
@@ -917,7 +566,11 @@ declare class Client {
|
|
|
917
566
|
sendLongTweet(text: string, replyToTweetId?: string, mediaData?: {
|
|
918
567
|
data: Buffer;
|
|
919
568
|
mediaType: string;
|
|
920
|
-
}[]): Promise<
|
|
569
|
+
}[]): Promise<{
|
|
570
|
+
ok: boolean;
|
|
571
|
+
json: () => Promise<twitter_api_v2.TweetV2PostTweetResult>;
|
|
572
|
+
data: twitter_api_v2.TweetV2PostTweetResult;
|
|
573
|
+
}>;
|
|
921
574
|
/**
|
|
922
575
|
* Send a tweet
|
|
923
576
|
* @param text The text of the tweet
|
|
@@ -1034,10 +687,20 @@ declare class Client {
|
|
|
1034
687
|
placeFields?: TTweetv2PlaceField[];
|
|
1035
688
|
}): Promise<Tweet$1[]>;
|
|
1036
689
|
/**
|
|
1037
|
-
*
|
|
1038
|
-
* @
|
|
690
|
+
* Updates the authentication state for the client.
|
|
691
|
+
* @param auth The new authentication.
|
|
692
|
+
*/
|
|
693
|
+
updateAuth(auth: TwitterAuth): void;
|
|
694
|
+
/**
|
|
695
|
+
* Get current authentication credentials
|
|
696
|
+
* @returns {TwitterAuth | null} Current authentication or null if not authenticated
|
|
697
|
+
*/
|
|
698
|
+
getAuth(): TwitterAuth | null;
|
|
699
|
+
/**
|
|
700
|
+
* Check if client is properly authenticated with Twitter API v2 credentials
|
|
701
|
+
* @returns {boolean} True if authenticated
|
|
1039
702
|
*/
|
|
1040
|
-
|
|
703
|
+
isAuthenticated(): boolean;
|
|
1041
704
|
/**
|
|
1042
705
|
* Returns if the client is logged in as a real user.
|
|
1043
706
|
* @returns `true` if the client is logged in with a real user account; otherwise `false`.
|
|
@@ -1049,32 +712,18 @@ declare class Client {
|
|
|
1049
712
|
*/
|
|
1050
713
|
me(): Promise<Profile | undefined>;
|
|
1051
714
|
/**
|
|
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.
|
|
715
|
+
* Login to Twitter using API v2 credentials only.
|
|
716
|
+
* @param appKey The API key
|
|
717
|
+
* @param appSecret The API secret key
|
|
718
|
+
* @param accessToken The access token
|
|
719
|
+
* @param accessSecret The access token secret
|
|
1058
720
|
*/
|
|
1059
721
|
login(username: string, password: string, email?: string, twoFactorSecret?: string, appKey?: string, appSecret?: string, accessToken?: string, accessSecret?: string): Promise<void>;
|
|
1060
722
|
/**
|
|
1061
723
|
* Log out of Twitter.
|
|
724
|
+
* Note: With API v2, logout is not applicable as we use API credentials.
|
|
1062
725
|
*/
|
|
1063
726
|
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
727
|
/**
|
|
1079
728
|
* Sets the optional cookie to be used in requests.
|
|
1080
729
|
* @param _cookie The cookie to be used in requests.
|
|
@@ -1101,13 +750,17 @@ declare class Client {
|
|
|
1101
750
|
data: Buffer;
|
|
1102
751
|
mediaType: string;
|
|
1103
752
|
}[];
|
|
1104
|
-
}): Promise<
|
|
753
|
+
}): Promise<{
|
|
754
|
+
ok: boolean;
|
|
755
|
+
json: () => Promise<twitter_api_v2.TweetV2PostTweetResult>;
|
|
756
|
+
data: twitter_api_v2.TweetV2PostTweetResult;
|
|
757
|
+
}>;
|
|
1105
758
|
/**
|
|
1106
759
|
* Delete a tweet with the given ID.
|
|
1107
760
|
* @param tweetId The ID of the tweet to delete.
|
|
1108
761
|
* @returns A promise that resolves when the tweet is deleted.
|
|
1109
762
|
*/
|
|
1110
|
-
deleteTweet(tweetId: string): Promise<
|
|
763
|
+
deleteTweet(tweetId: string): Promise<any>;
|
|
1111
764
|
/**
|
|
1112
765
|
* Likes a tweet with the given tweet ID.
|
|
1113
766
|
* @param tweetId The ID of the tweet to like.
|
|
@@ -1128,86 +781,28 @@ declare class Client {
|
|
|
1128
781
|
followUser(userName: string): Promise<void>;
|
|
1129
782
|
/**
|
|
1130
783
|
* Fetches direct message conversations
|
|
1131
|
-
*
|
|
1132
|
-
* @param
|
|
1133
|
-
* @
|
|
784
|
+
* Note: This functionality requires additional permissions and is not implemented in the current Twitter API v2 wrapper
|
|
785
|
+
* @param userId User ID
|
|
786
|
+
* @param cursor Pagination cursor
|
|
787
|
+
* @returns Array of DM conversations
|
|
1134
788
|
*/
|
|
1135
|
-
getDirectMessageConversations(userId: string, cursor?: string): Promise<
|
|
789
|
+
getDirectMessageConversations(userId: string, cursor?: string): Promise<any>;
|
|
1136
790
|
/**
|
|
1137
791
|
* Sends a direct message to a user.
|
|
1138
|
-
*
|
|
1139
|
-
* @param
|
|
1140
|
-
* @
|
|
792
|
+
* Note: This functionality requires additional permissions and is not implemented in the current Twitter API v2 wrapper
|
|
793
|
+
* @param conversationId The ID of the conversation
|
|
794
|
+
* @param text The text of the message
|
|
795
|
+
* @returns The response from the Twitter API
|
|
1141
796
|
*/
|
|
1142
|
-
sendDirectMessage(conversationId: string, text: string): Promise<
|
|
797
|
+
sendDirectMessage(conversationId: string, text: string): Promise<any>;
|
|
1143
798
|
private getAuthOptions;
|
|
1144
799
|
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
800
|
/**
|
|
1191
801
|
* Fetches a article (long form tweet) by its ID.
|
|
1192
802
|
* @param id The ID of the article to fetch. In the format of (http://x.com/i/article/id)
|
|
1193
803
|
* @returns The {@link TimelineArticle} object, or `null` if it couldn't be fetched.
|
|
1194
804
|
*/
|
|
1195
805
|
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
806
|
/**
|
|
1212
807
|
* Retrieves all users who retweeted the given tweet.
|
|
1213
808
|
* @param tweetId The ID of the tweet.
|
|
@@ -1215,336 +810,21 @@ declare class Client {
|
|
|
1215
810
|
*/
|
|
1216
811
|
getRetweetersOfTweet(tweetId: string): Promise<Retweeter[]>;
|
|
1217
812
|
/**
|
|
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.
|
|
813
|
+
* Fetches all quoted tweets for a given tweet ID, handling pagination automatically.
|
|
814
|
+
* @param tweetId The ID of the tweet to fetch quotes for.
|
|
815
|
+
* @param maxQuotes Maximum number of quotes to return (default: 100).
|
|
816
|
+
* @returns An array of all quoted tweets.
|
|
1307
817
|
*/
|
|
1308
|
-
|
|
818
|
+
fetchAllQuotedTweets(tweetId: string, maxQuotes?: number): Promise<Tweet$1[]>;
|
|
1309
819
|
/**
|
|
1310
|
-
*
|
|
820
|
+
* Fetches quoted tweets for a given tweet ID.
|
|
821
|
+
* This method now uses a generator function internally but maintains backward compatibility.
|
|
822
|
+
* @param tweetId The ID of the tweet to fetch quotes for.
|
|
823
|
+
* @param maxQuotes Maximum number of quotes to return.
|
|
824
|
+
* @param cursor Optional cursor for pagination.
|
|
825
|
+
* @returns A promise that resolves to a QueryTweetsResponse containing tweets and the next cursor.
|
|
1311
826
|
*/
|
|
1312
|
-
|
|
1313
|
-
/**
|
|
1314
|
-
* Sets up chat events: "occupancyUpdate", "newSpeakerAccepted", etc.
|
|
1315
|
-
*/
|
|
1316
|
-
private setupChatEvents;
|
|
1317
|
-
/**
|
|
1318
|
-
* Mute self if we are speaker: calls /audiospace/muteSpeaker with our sessionUUID.
|
|
1319
|
-
*/
|
|
1320
|
-
muteSelf(): Promise<void>;
|
|
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>;
|
|
827
|
+
fetchQuotedTweetsPage(tweetId: string, maxQuotes?: number, cursor?: string): Promise<QueryTweetsResponse>;
|
|
1548
828
|
}
|
|
1549
829
|
|
|
1550
830
|
/**
|
|
@@ -1657,116 +937,17 @@ declare class TwitterPostClient {
|
|
|
1657
937
|
}
|
|
1658
938
|
|
|
1659
939
|
/**
|
|
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.
|
|
940
|
+
* @interface ITwitterClient
|
|
941
|
+
* Represents the main Twitter client interface for interacting with Twitter's API.
|
|
942
|
+
* @property {ClientBase} client - The base client for Twitter operations.
|
|
943
|
+
* @property {TwitterPostClient} post - The client for managing Twitter posts.
|
|
944
|
+
* @property {TwitterInteractionClient} interaction - The client for managing Twitter interactions.
|
|
945
|
+
* @property {TwitterService} service - The main Twitter service instance.
|
|
1764
946
|
*/
|
|
1765
947
|
interface ITwitterClient {
|
|
1766
948
|
client: ClientBase;
|
|
1767
949
|
post: TwitterPostClient;
|
|
1768
950
|
interaction: TwitterInteractionClient;
|
|
1769
|
-
space?: TwitterSpaceClient;
|
|
1770
951
|
service: TwitterService;
|
|
1771
952
|
}
|
|
1772
953
|
/**
|
|
@@ -1919,15 +1100,12 @@ declare class ClientBase {
|
|
|
1919
1100
|
fetchHomeTimeline(count: number, following?: boolean): Promise<Tweet$1[]>;
|
|
1920
1101
|
fetchSearchTweets(query: string, maxTweets: number, searchMode: SearchMode, cursor?: string): Promise<QueryTweetsResponse>;
|
|
1921
1102
|
private populateTimeline;
|
|
1922
|
-
setCookiesFromArray(cookiesArray: any[]): Promise<void>;
|
|
1923
1103
|
saveRequestMessage(message: Memory, state: State): Promise<void>;
|
|
1924
1104
|
loadLatestCheckedTweetId(): Promise<void>;
|
|
1925
1105
|
cacheLatestCheckedTweetId(): Promise<void>;
|
|
1926
1106
|
getCachedTimeline(): Promise<Tweet$1[] | undefined>;
|
|
1927
1107
|
cacheTimeline(timeline: Tweet$1[]): Promise<void>;
|
|
1928
1108
|
cacheMentions(mentions: Tweet$1[]): Promise<void>;
|
|
1929
|
-
getCachedCookies(username: string): Promise<any[]>;
|
|
1930
|
-
cacheCookies(username: string, cookies: any[]): Promise<void>;
|
|
1931
1109
|
fetchProfile(username: string): Promise<TwitterProfile>;
|
|
1932
1110
|
/**
|
|
1933
1111
|
* Fetches recent interactions (likes, retweets, quotes) for the authenticated user's tweets
|
|
@@ -1995,7 +1173,6 @@ declare class TwitterClientInstance implements ITwitterClient {
|
|
|
1995
1173
|
post: TwitterPostClient;
|
|
1996
1174
|
interaction: TwitterInteractionClient;
|
|
1997
1175
|
timeline?: TwitterTimelineClient;
|
|
1998
|
-
space?: TwitterSpaceClient;
|
|
1999
1176
|
service: TwitterService;
|
|
2000
1177
|
constructor(runtime: IAgentRuntime, state: any);
|
|
2001
1178
|
}
|
|
@@ -2019,6 +1196,6 @@ declare class TwitterService extends Service {
|
|
|
2019
1196
|
stopAllClients(): Promise<void>;
|
|
2020
1197
|
private getClientKey;
|
|
2021
1198
|
}
|
|
2022
|
-
declare const twitterPlugin: Plugin
|
|
1199
|
+
declare const twitterPlugin: Plugin;
|
|
2023
1200
|
|
|
2024
1201
|
export { TwitterClientInstance, TwitterService, twitterPlugin as default };
|