import { EventEmitter } from 'events'; import { Agent } from '../core/agent'; import { AgentSwarm } from '../core/agent-swarm'; /** * Configuration for the Twitter connector */ export interface TwitterConnectorConfig { username?: string; password?: string; email?: string; apiKey?: string; apiSecret?: string; accessToken?: string; accessSecret?: string; monitorKeywords?: string[]; monitorUsers?: string[]; autoReply?: boolean; pollInterval?: number; headless?: boolean; } /** * Internal Tweet interface to abstract away the library-specific implementation */ export interface Tweet { id: string; text: string; author: { id: string; username: string; name: string; }; createdAt: Date; isRetweet: boolean; isReply: boolean; inReplyToId?: string; inReplyToUser?: string; } /** * Twitter connector to integrate agents with Twitter * Uses agent-twitter-client to connect to Twitter without requiring API keys */ export declare class TwitterConnector extends EventEmitter { config: TwitterConnectorConfig; private agent?; private swarm?; private logger; private connected; private scraper; private monitorInterval; private lastCheckedTweets; private browser; private page; /** * Creates a new Twitter connector * * @param config - Configuration for the connector */ constructor(config: TwitterConnectorConfig); /** * Connects an agent to Twitter * * @param agent - The agent to connect * @returns Promise resolving when connected */ connect(agent: Agent | AgentSwarm): Promise; /** * Logs in to Twitter using browser automation * * @param username - Twitter username * @param password - Twitter password * @param email - Optional email for verification */ private browserLogin; /** * Disconnects from Twitter * * @returns Promise resolving when disconnected */ disconnect(): Promise; /** * Posts a tweet * * @param content - The content of the tweet * @param replyTo - Optional tweet ID to reply to * @returns Promise resolving to the tweet ID */ tweet(content: string, replyTo?: string): Promise; /** * Posts a tweet using browser automation * * @param content - The content of the tweet */ private postTweetWithBrowser; /** * Posts a reply to a tweet using browser automation * * @param content - The content of the reply * @param tweetId - The ID of the tweet to reply to */ private postReplyWithBrowser; /** * Retweets a tweet * * @param tweetId - ID of the tweet to retweet * @returns Promise resolving when completed */ retweet(tweetId: string): Promise; /** * Retweets a tweet using browser automation * * @param tweetId - ID of the tweet to retweet */ private retweetWithBrowser; /** * Likes a tweet * * @param tweetId - ID of the tweet to like * @returns Promise resolving when completed */ like(tweetId: string): Promise; /** * Likes a tweet using browser automation * * @param tweetId - ID of the tweet to like */ private likeWithBrowser; /** * Gets a specific tweet by ID * * @param tweetId - ID of the tweet to get * @returns Promise resolving to the tweet */ getTweet(tweetId: string): Promise; /** * Gets tweets from a user * * @param username - Twitter username to get tweets from * @param count - Maximum number of tweets to get * @returns Promise resolving to an array of tweets */ getUserTweets(username: string, count?: number): Promise; /** * Searches for tweets * * @param query - Search query * @param count - Maximum number of tweets to return * @returns Promise resolving to an array of tweets */ searchTweets(query: string, count?: number): Promise; /** * Gets current Twitter trends * * @returns Promise resolving to an array of trend items */ getTrends(): Promise>; /** * Follow a Twitter user * * @param username - Username of the account to follow * @returns Promise resolving when completed */ follow(username: string): Promise; /** * Send a question to Twitter's Grok AI if available in the library * * @param question - The question to ask Grok * @param conversationId - Optional existing conversation ID * @returns Promise resolving to Grok's response */ askGrok(question: string, conversationId?: string): Promise; /** * Sets up monitoring for tweets * Polls periodically for new tweets from monitored users and keywords */ private setupMonitoring; /** * Checks for new tweets from monitored users and keywords */ private checkForNewTweets; /** * Handles auto-reply to a tweet * * @param tweet - The tweet to reply to */ private handleAutoReply; /** * Converts a library-specific tweet to our internal format * * @param tweet - The tweet from the library * @returns Converted tweet in our internal format */ private convertToTweet; }