import { EventEmitter } from 'events'; import { Agent } from '../core/agent'; import { AgentSwarm } from '../core/agent-swarm'; /** * Configuration for the Twitter connector */ export interface BrowserTwitterConnectorConfig { username?: string; password?: string; email?: string; monitorKeywords?: string[]; monitorUsers?: string[]; autoReply?: boolean; pollInterval?: number; headless?: boolean; debug?: boolean; } /** * Internal Tweet interface */ export interface Tweet { id?: string; text: string; author: { id?: string; username?: string; name?: string; }; createdAt?: Date; isRetweet?: boolean; isReply?: boolean; inReplyToId?: string; inReplyToUser?: string; } /** * Enhanced interface for interaction events (mentions, replies, etc.) */ export interface TwitterInteraction { id: string; text: string; author: string; username: string; type: 'mention' | 'reply' | 'keyword'; originalTweetId?: string; timestamp: string; keywords?: string[]; } /** * Browser-based Twitter connector to integrate agents with Twitter * Uses direct browser automation without relying on Twitter API */ export declare class BrowserTwitterConnector extends EventEmitter { config: BrowserTwitterConnectorConfig; private agent?; private swarm?; private browser; private page; private connected; private monitorInterval; private monitorTimer; private logger; private processedTweets; private monitorKeywords; /** * Creates a new Browser Twitter connector * * @param config - Configuration options */ constructor(config: BrowserTwitterConnectorConfig); /** * Connects to Twitter with browser automation * * @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 to Twitter using browser automation * * @param content - The content of the tweet * @param replyToId - Optional tweet ID to reply to * @returns Promise resolving to a tweet ID or confirmation string */ tweet(content: string, replyToId?: 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; /** * Sets up enhanced monitoring for tweets, mentions, and replies */ private setupMonitoring; /** * Comprehensive monitoring of Twitter timeline, mentions, and replies */ private monitorTimeline; /** * Safely check for replies with error handling and recovery */ private safelyCheckForReplies; /** * Check for mentions of our account */ private checkForMentions; /** * Check for replies to our tweets (improved version) */ private checkForReplies; /** * Check the general timeline for monitored keywords */ private checkGeneralTimeline; /** * Generate a reply to a tweet using the agent * * @param tweetText - The text of the tweet to reply to * @param authorName - The author of the tweet * @param interactionType - The type of interaction * @param originalTweetId - Optional original tweet ID for context * @returns Promise resolving to the reply text */ private generateReply; /** * Reply to a tweet (wrapper around postReplyWithBrowser) * * @param tweetId - The ID of the tweet to reply to * @param replyText - The text of the reply */ private replyToTweet; /** * Gets login status based on current browser state */ private get isLoggedIn(); /** * Checks for tweets that match monitoring criteria (legacy method kept for compatibility) */ private checkForTweets; /** * Likes a tweet (not fully implemented) * * @param tweetId - The ID of the tweet to like */ like(tweetId: string): Promise; /** * Retweets a tweet (not fully implemented) * * @param tweetId - The ID of the tweet to retweet */ retweet(tweetId: string): Promise; /** * Follows a user (not fully implemented) * * @param username - The username of the user to follow */ follow(username: string): Promise; /** * Gets a tweet by ID using browser automation * * @param tweetId - The ID of the tweet to fetch * @returns Promise resolving to the tweet object */ getTweet(tweetId: string): Promise; }