@chirp-dev/chirp-sdk 1.0.2

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.
@@ -0,0 +1,891 @@
1
+ import { Socket } from 'socket.io-client';
2
+
3
+ /**
4
+ * Core API types for the Chirp Bot SDK
5
+ * Based on the Chirp REST API and WebSocket events
6
+ */
7
+ interface User {
8
+ id: string;
9
+ username: string;
10
+ displayName: string;
11
+ avatarUrl: string | null;
12
+ status: 'online' | 'idle' | 'dnd' | 'offline';
13
+ isBot: true;
14
+ botTokenId: string;
15
+ createdAt: string;
16
+ }
17
+ interface PartialUser {
18
+ id: string;
19
+ username: string;
20
+ displayName: string;
21
+ avatarUrl: string | null;
22
+ status?: string;
23
+ isBot?: boolean;
24
+ }
25
+ interface Server {
26
+ id: string;
27
+ name: string;
28
+ iconUrl: string | null;
29
+ ownerId: string;
30
+ createdAt: string;
31
+ memberCount?: number;
32
+ }
33
+ interface ServerMember {
34
+ serverId: string;
35
+ userId: string;
36
+ roles: string[];
37
+ joinedAt: string;
38
+ user: PartialUser;
39
+ }
40
+ interface Channel {
41
+ id: string;
42
+ serverId: string;
43
+ name: string;
44
+ type: 'text' | 'voice' | 'media' | 'forum';
45
+ parentId: string | null;
46
+ position: number;
47
+ permissions?: Record<string, boolean>;
48
+ createdAt: string;
49
+ }
50
+ interface PartialChannel {
51
+ id: string;
52
+ name: string;
53
+ type: string;
54
+ serverId?: string;
55
+ }
56
+ interface Message {
57
+ id: string;
58
+ channel_id: string;
59
+ author: string;
60
+ username: string;
61
+ avatar_url: string | null;
62
+ bot_id?: string;
63
+ user_id?: string;
64
+ content: string;
65
+ created_at: string;
66
+ updated_at?: string;
67
+ edited?: boolean;
68
+ edited_at?: string;
69
+ replying_to_id?: string;
70
+ replying_to_author?: string;
71
+ replying_to_content?: string;
72
+ replyingTo?: MessageReply;
73
+ reactions?: Reaction[];
74
+ attachments?: Attachment[];
75
+ is_bot?: boolean;
76
+ authorAvatar?: string | null;
77
+ server_id?: string;
78
+ everyone_ping?: boolean;
79
+ channelId?: string;
80
+ createdAt?: string;
81
+ updatedAt?: string;
82
+ isEdited?: boolean;
83
+ }
84
+ interface MessageReply {
85
+ id: string;
86
+ content: string;
87
+ author: string;
88
+ }
89
+ interface Reaction {
90
+ id: string;
91
+ messageId: string;
92
+ userId: string;
93
+ emoji: string;
94
+ customEmojiId: string | null;
95
+ createdAt: string;
96
+ }
97
+ interface Attachment {
98
+ id: string;
99
+ messageId: string;
100
+ fileName: string;
101
+ fileSize: number;
102
+ mimeType: string;
103
+ url: string;
104
+ thumbnailUrl?: string;
105
+ width?: number;
106
+ height?: number;
107
+ }
108
+ interface MessageOptions {
109
+ replyTo?: string;
110
+ attachments?: Array<{
111
+ fileName: string;
112
+ file: Blob | Buffer;
113
+ mimeType?: string;
114
+ }>;
115
+ }
116
+ interface BotTokenInfo {
117
+ id: string;
118
+ botUsername: string;
119
+ botAvatarUrl: string | null;
120
+ userId: string;
121
+ createdAt: string;
122
+ lastUsedAt: string | null;
123
+ }
124
+ interface BotServerInfo {
125
+ serverId: string;
126
+ serverName: string;
127
+ serverIconUrl: string | null;
128
+ botUsername: string;
129
+ botAvatarUrl: string | null;
130
+ joinedAt: string;
131
+ }
132
+ interface PaginatedResponse<T> {
133
+ data: T[];
134
+ pagination: {
135
+ page: number;
136
+ limit: number;
137
+ total: number;
138
+ totalPages: number;
139
+ };
140
+ }
141
+ interface APIError$1 {
142
+ message: string;
143
+ statusCode: number;
144
+ code?: string;
145
+ }
146
+ interface ChirpClientOptions {
147
+ token?: string;
148
+ baseUrl?: string;
149
+ wsUrl?: string;
150
+ commandPrefix?: string;
151
+ intents?: Intent[];
152
+ reconnectAttempts?: number;
153
+ reconnectDelay?: number;
154
+ }
155
+ type Intent = 'messages' | 'messageUpdates' | 'userStatus' | 'typing' | 'voice' | 'polls' | 'threads' | 'servers';
156
+ interface Command {
157
+ name: string;
158
+ description: string;
159
+ usage?: string;
160
+ handler: (context: CommandContext$1) => void | Promise<void>;
161
+ }
162
+ interface CommandContext$1 {
163
+ command: string;
164
+ args: string[];
165
+ message: Message;
166
+ channel: Channel;
167
+ client: any;
168
+ api: any;
169
+ }
170
+ interface RESTClient$1 {
171
+ getBotInfo(): Promise<User>;
172
+ getServers(): Promise<Server[]>;
173
+ getBotServers(): Promise<BotServerInfo[]>;
174
+ getChannels(serverId: string): Promise<Channel[]>;
175
+ getMessages(channelId: string, options?: {
176
+ page?: number;
177
+ limit?: number;
178
+ }): Promise<PaginatedResponse<Message>>;
179
+ sendMessage(channelId: string, content: string, options?: {
180
+ replyTo?: string;
181
+ }): Promise<Message>;
182
+ reply(channelId: string, messageId: string, content: string, author: string, originalContent: string): Promise<Message>;
183
+ editMessage(messageId: string, content: string): Promise<Message>;
184
+ deleteMessage(messageId: string): Promise<void>;
185
+ joinServer(inviteCode: string): Promise<Server>;
186
+ leaveServer(serverId: string): Promise<void>;
187
+ }
188
+ declare class Collection<K, V> extends Map<K, V> {
189
+ constructor(entries?: readonly (readonly [K, V])[] | null);
190
+ get(key: K): V | undefined;
191
+ set(key: K, value: V): this;
192
+ find(predicate: (value: V, key: K) => boolean): V | undefined;
193
+ filter(predicate: (value: V, key: K) => boolean): V[];
194
+ first(): V | undefined;
195
+ last(): V | undefined;
196
+ }
197
+
198
+ /**
199
+ * REST API Client for Chirp Bot SDK
200
+ * Extracted and refactored from examples/demo-bot/src/api.js
201
+ */
202
+
203
+ declare class APIError extends Error {
204
+ statusCode: number;
205
+ code?: string;
206
+ constructor(message: string, statusCode: number, code?: string);
207
+ }
208
+ declare class RESTClient {
209
+ private readonly baseUrl;
210
+ private readonly token;
211
+ constructor(baseUrl: string, token: string);
212
+ /**
213
+ * Make an authenticated API request
214
+ */
215
+ private request;
216
+ /**
217
+ * GET request
218
+ */
219
+ private get;
220
+ /**
221
+ * POST request
222
+ */
223
+ private post;
224
+ /**
225
+ * PATCH request
226
+ */
227
+ private patch;
228
+ /**
229
+ * PUT request
230
+ */
231
+ private put;
232
+ /**
233
+ * DELETE request
234
+ */
235
+ private delete;
236
+ /**
237
+ * Get the bot's user information
238
+ */
239
+ getBotInfo(): Promise<User>;
240
+ /**
241
+ * Get the bot's token information
242
+ */
243
+ getTokenInfo(): Promise<BotTokenInfo>;
244
+ /**
245
+ * List all servers the bot has access to
246
+ */
247
+ getServers(): Promise<Server[]>;
248
+ /**
249
+ * List the bot's server memberships with details
250
+ */
251
+ getBotServers(): Promise<BotServerInfo[]>;
252
+ /**
253
+ * Get channels in a server
254
+ */
255
+ getChannels(serverId: string): Promise<Channel[]>;
256
+ /**
257
+ * Get messages in a channel
258
+ */
259
+ getMessages(channelId: string, options?: {
260
+ page?: number;
261
+ limit?: number;
262
+ }): Promise<PaginatedResponse<Message>>;
263
+ /**
264
+ * Send a message to a channel
265
+ */
266
+ sendMessage(channelId: string, content: string, options?: MessageOptions): Promise<Message>;
267
+ /**
268
+ * Reply to a specific message
269
+ */
270
+ reply(channelId: string, messageId: string, content: string, author: string, originalContent: string): Promise<Message>;
271
+ /**
272
+ * Edit a message (only works for bot's own messages)
273
+ */
274
+ editMessage(messageId: string, content: string): Promise<Message>;
275
+ /**
276
+ * Delete a message (only works for bot's own messages)
277
+ */
278
+ deleteMessage(messageId: string): Promise<void>;
279
+ /**
280
+ * Join a server via invite code
281
+ */
282
+ joinServer(inviteCode: string): Promise<Server>;
283
+ /**
284
+ * Leave a server
285
+ */
286
+ leaveServer(serverId: string): Promise<void>;
287
+ }
288
+
289
+ /**
290
+ * Type-safe EventEmitter wrapper around EventEmitter3
291
+ */
292
+ type EventNames<T> = T extends any ? (keyof T & string) : never;
293
+ type EventListener<T, K extends keyof T & string> = T[K] extends (...args: any[]) => any ? T[K] : (...args: any[]) => void;
294
+ /**
295
+ * Type-safe event emitter
296
+ */
297
+ declare class SafeEventEmitter<TEvents extends Record<string, any>> {
298
+ private readonly emitter;
299
+ constructor();
300
+ /**
301
+ * Register an event listener
302
+ */
303
+ on<K extends EventNames<TEvents>>(event: K, listener: EventListener<TEvents, K>): this;
304
+ /**
305
+ * Register a one-time event listener
306
+ */
307
+ once<K extends EventNames<TEvents>>(event: K, listener: EventListener<TEvents, K>): this;
308
+ /**
309
+ * Remove an event listener
310
+ */
311
+ off<K extends EventNames<TEvents>>(event: K, listener: EventListener<TEvents, K>): this;
312
+ /**
313
+ * Emit an event
314
+ */
315
+ emit<K extends EventNames<TEvents>>(event: K, ...args: any[]): boolean;
316
+ /**
317
+ * Remove all listeners for an event or all events
318
+ */
319
+ removeAllListeners<K extends EventNames<TEvents>>(event?: K): this;
320
+ /**
321
+ * Get the count of listeners for an event
322
+ */
323
+ listenerCount<K extends EventNames<TEvents>>(event: K): number;
324
+ }
325
+
326
+ /**
327
+ * Event type definitions for Chirp Bot SDK
328
+ */
329
+
330
+ type ReadyEventHandler = () => void;
331
+ type ErrorHandler = (error: Error) => void;
332
+ type DisconnectedHandler = (reason?: string) => void;
333
+ type ReconnectingHandler = (attemptNumber: number) => void;
334
+ type ReconnectedHandler = (attemptNumber: number) => void;
335
+ type MessageNewHandler = (message: Message, channelId: string) => void;
336
+ type MessageUpdatedHandler = (message: Message, channelId: string) => void;
337
+ type MessageDeletedHandler = (messageId: string, channelId: string) => void;
338
+ type UserStatusHandler = (userId: string, status: 'online' | 'idle' | 'dnd' | 'offline', user: PartialUser) => void;
339
+ type TypingStartHandler = (userId: string, channelId: string) => void;
340
+ type PollVotedHandler = (pollId: string, userId: string, optionId: string) => void;
341
+ type ThreadReopenedHandler = (threadId: string, channelId: string) => void;
342
+ type UserJoinedThreadHandler = (threadId: string, userId: string) => void;
343
+ type VoiceJoinedHandler = (userId: string, channelId: string, serverId: string) => void;
344
+ type VoiceLeftHandler = (userId: string, channelId: string, serverId: string) => void;
345
+ type BotServerJoinedHandler = (serverId: string, serverName: string) => void;
346
+ type BotServerLeftHandler = (serverId: string, serverName: string) => void;
347
+ type SubscriptionAddedHandler = (data: {
348
+ subscriptionId: string;
349
+ channelId: string;
350
+ userId: string;
351
+ tier: string;
352
+ }) => void;
353
+ interface ChirpEvents {
354
+ ready: ReadyEventHandler;
355
+ error: ErrorHandler;
356
+ disconnected: DisconnectedHandler;
357
+ reconnecting: ReconnectingHandler;
358
+ reconnected: ReconnectedHandler;
359
+ 'message:new': MessageNewHandler;
360
+ 'message:updated': MessageUpdatedHandler;
361
+ 'message:deleted': MessageDeletedHandler;
362
+ 'user:status': UserStatusHandler;
363
+ 'typing:start': TypingStartHandler;
364
+ 'poll:voted': PollVotedHandler;
365
+ 'thread:reopened': ThreadReopenedHandler;
366
+ 'user_joined_thread': UserJoinedThreadHandler;
367
+ 'voice:joined': VoiceJoinedHandler;
368
+ 'voice:left': VoiceLeftHandler;
369
+ 'bot:server_joined': BotServerJoinedHandler;
370
+ 'bot:server_left': BotServerLeftHandler;
371
+ 'subscription:added': SubscriptionAddedHandler;
372
+ }
373
+ type ChirpEventName = keyof ChirpEvents;
374
+
375
+ /**
376
+ * Command Manager - handles command registration and execution
377
+ */
378
+
379
+ type ChirpClientInstance = ChirpClient;
380
+ /**
381
+ * Command Manager class
382
+ */
383
+ declare class CommandManager {
384
+ private readonly commands;
385
+ private readonly prefix;
386
+ private client?;
387
+ constructor(prefix?: string);
388
+ /**
389
+ * Set the client reference (called by ChirpClient)
390
+ * @internal
391
+ */
392
+ _setClient(client: ChirpClientInstance): void;
393
+ /**
394
+ * Register a command
395
+ */
396
+ register(command: Command): this;
397
+ register(builder: {
398
+ build(): Command;
399
+ }): this;
400
+ /**
401
+ * Register multiple commands
402
+ */
403
+ registerMany(commands: (Command | {
404
+ build(): Command;
405
+ })[]): this;
406
+ /**
407
+ * Unregister a command
408
+ */
409
+ unregister(name: string): boolean;
410
+ /**
411
+ * Get a command by name
412
+ */
413
+ get(name: string): Command | undefined;
414
+ /**
415
+ * Check if a command exists
416
+ */
417
+ has(name: string): boolean;
418
+ /**
419
+ * Get all registered commands
420
+ */
421
+ getAll(): Map<string, Command>;
422
+ /**
423
+ * Clear all commands
424
+ */
425
+ clear(): void;
426
+ /**
427
+ * Parse a message to check if it's a command
428
+ * Returns { command, args } if it's a command, null otherwise
429
+ */
430
+ parse(message: Message): {
431
+ command: string;
432
+ args: string[];
433
+ } | null;
434
+ /**
435
+ * Execute a command
436
+ * @internal
437
+ */
438
+ execute(commandName: string, args: string[], message: Message, channel: Channel, client: ChirpClientInstance, api: RESTClient$1): Promise<void>;
439
+ }
440
+
441
+ /**
442
+ * Channel Manager - manages channel caching and operations
443
+ */
444
+
445
+ /**
446
+ * Manager for channel operations
447
+ */
448
+ declare class ChannelManager {
449
+ private readonly api;
450
+ readonly cache: Collection<string, Channel>;
451
+ constructor(api: RESTClient$1);
452
+ /**
453
+ * Create a Collection instance (avoiding circular dependency)
454
+ */
455
+ private static createCollection;
456
+ /**
457
+ * Fetch channels for a server
458
+ */
459
+ fetch(serverId: string): Promise<Channel[]>;
460
+ /**
461
+ * Get a channel from cache by ID
462
+ */
463
+ get(channelId: string): Channel | undefined;
464
+ /**
465
+ * Find a channel by name in a server
466
+ */
467
+ findByName(serverId: string, name: string): Channel | undefined;
468
+ /**
469
+ * Get all channels from cache
470
+ */
471
+ getAll(): Collection<string, Channel>;
472
+ /**
473
+ * Clear the channel cache
474
+ */
475
+ clear(): void;
476
+ /**
477
+ * Add or update a channel in cache
478
+ */
479
+ set(channel: Channel): this;
480
+ /**
481
+ * Remove a channel from cache
482
+ */
483
+ delete(channelId: string): boolean;
484
+ }
485
+
486
+ /**
487
+ * Message Manager - manages message operations
488
+ */
489
+
490
+ /**
491
+ * Manager for message operations
492
+ */
493
+ declare class MessageManager {
494
+ private readonly api;
495
+ readonly cache: Collection<string, Message>;
496
+ constructor(api: RESTClient$1);
497
+ /**
498
+ * Create a Collection instance (avoiding circular dependency)
499
+ */
500
+ private static createCollection;
501
+ /**
502
+ * Fetch messages for a channel
503
+ */
504
+ fetch(channelId: string, options?: {
505
+ page?: number;
506
+ limit?: number;
507
+ }): Promise<PaginatedResponse<Message>>;
508
+ /**
509
+ * Send a message to a channel
510
+ */
511
+ send(channelId: string, content: string, options?: MessageOptions): Promise<Message>;
512
+ /**
513
+ * Reply to a message
514
+ */
515
+ reply(channelId: string, messageId: string, content: string, author: string, originalContent: string): Promise<Message>;
516
+ /**
517
+ * Edit a message
518
+ */
519
+ edit(messageId: string, content: string): Promise<Message>;
520
+ /**
521
+ * Delete a message
522
+ */
523
+ delete(messageId: string): Promise<void>;
524
+ /**
525
+ * Get a message from cache by ID
526
+ */
527
+ get(messageId: string): Message | undefined;
528
+ /**
529
+ * Get all messages from cache
530
+ */
531
+ getAll(): Collection<string, Message>;
532
+ /**
533
+ * Clear the message cache
534
+ */
535
+ clear(): void;
536
+ /**
537
+ * Add or update a message in cache
538
+ */
539
+ set(message: Message): this;
540
+ /**
541
+ * Remove a message from cache
542
+ */
543
+ deleteFromCache(messageId: string): boolean;
544
+ }
545
+
546
+ /**
547
+ * Server Manager - manages server caching and operations
548
+ */
549
+
550
+ /**
551
+ * Manager for server operations
552
+ */
553
+ declare class ServerManager {
554
+ private readonly api;
555
+ readonly cache: Collection<string, Server>;
556
+ constructor(api: RESTClient$1);
557
+ /**
558
+ * Create a Collection instance (avoiding circular dependency)
559
+ */
560
+ private static createCollection;
561
+ /**
562
+ * Fetch all servers the bot has access to
563
+ */
564
+ fetch(): Promise<Server[]>;
565
+ /**
566
+ * Fetch the bot's server memberships with details
567
+ */
568
+ fetchBotServers(): Promise<Server[]>;
569
+ /**
570
+ * Join a server via invite code
571
+ */
572
+ join(inviteCode: string): Promise<Server>;
573
+ /**
574
+ * Leave a server
575
+ */
576
+ leave(serverId: string): Promise<void>;
577
+ /**
578
+ * Get a server from cache by ID
579
+ */
580
+ get(serverId: string): Server | undefined;
581
+ /**
582
+ * Find a server by name
583
+ */
584
+ findByName(name: string): Server | undefined;
585
+ /**
586
+ * Get all servers from cache
587
+ */
588
+ getAll(): Collection<string, Server>;
589
+ /**
590
+ * Clear the server cache
591
+ */
592
+ clear(): void;
593
+ /**
594
+ * Add or update a server in cache
595
+ */
596
+ set(server: Server): this;
597
+ /**
598
+ * Remove a server from cache
599
+ */
600
+ delete(serverId: string): boolean;
601
+ }
602
+
603
+ /**
604
+ * Main ChirpClient class
605
+ * The primary entry point for the Chirp Bot SDK
606
+ */
607
+
608
+ /**
609
+ * Connection status enum
610
+ */
611
+ declare enum ConnectionStatus {
612
+ Disconnected = "disconnected",
613
+ Connecting = "connecting",
614
+ Connected = "connected",
615
+ Reconnecting = "reconnecting"
616
+ }
617
+ /**
618
+ * Main Chirp Bot SDK client
619
+ */
620
+ declare class ChirpClient extends SafeEventEmitter<ChirpEvents> {
621
+ readonly options: Required<ChirpClientOptions>;
622
+ readonly commands: CommandManager;
623
+ api: RESTClient;
624
+ user: User | null;
625
+ servers: Collection<string, Server>;
626
+ channels: Collection<string, Channel>;
627
+ ws: Socket;
628
+ channelsManager: ChannelManager;
629
+ messagesManager: MessageManager;
630
+ serversManager: ServerManager;
631
+ private token;
632
+ private baseUrl;
633
+ private wsUrl;
634
+ private socket;
635
+ private status;
636
+ private reconnectAttempts;
637
+ private reconnectTimer;
638
+ private readonly log;
639
+ constructor(options?: ChirpClientOptions);
640
+ /**
641
+ * Connect and authenticate the bot
642
+ */
643
+ login(token?: string): Promise<void>;
644
+ /**
645
+ * Disconnect the bot
646
+ */
647
+ logout(): Promise<void>;
648
+ /**
649
+ * Get current connection status
650
+ */
651
+ getStatus(): ConnectionStatus;
652
+ /**
653
+ * Check if the client is connected
654
+ */
655
+ isConnected(): boolean;
656
+ private fetchInitialData;
657
+ private setupProcessHandlers;
658
+ private connectWebSocket;
659
+ private scheduleReconnect;
660
+ private clearReconnectTimer;
661
+ private setupEventHandlers;
662
+ private hasIntent;
663
+ private handleMessageNew;
664
+ private handleMessageUpdated;
665
+ private handleMessageDeleted;
666
+ private handleUserStatus;
667
+ private handleTypingStart;
668
+ private handlePollVoted;
669
+ private handleThreadReopened;
670
+ private handleUserJoinedThread;
671
+ private handleVoiceJoined;
672
+ private handleVoiceLeft;
673
+ private handleBotServerJoined;
674
+ private handleBotServerLeft;
675
+ private handleSubscriptionAdded;
676
+ }
677
+
678
+ /**
679
+ * Command Context - provides context for command execution
680
+ */
681
+
682
+ type ChirpClientType = any;
683
+ type RESTClientType = any;
684
+ /**
685
+ * Command execution context
686
+ */
687
+ declare class CommandContext implements CommandContext$1 {
688
+ readonly command: string;
689
+ readonly args: string[];
690
+ readonly message: Message;
691
+ readonly channel: Channel;
692
+ readonly client: ChirpClientType;
693
+ readonly api: RESTClientType;
694
+ constructor(command: string, args: string[], message: Message, channel: Channel, client: ChirpClientType, api: RESTClientType);
695
+ /**
696
+ * Reply to the command message
697
+ */
698
+ reply(content: string): Promise<Message>;
699
+ /**
700
+ * Send a message to the same channel
701
+ */
702
+ send(content: string): Promise<Message>;
703
+ /**
704
+ * Edit the bot's response message
705
+ */
706
+ edit(messageId: string, content: string): Promise<Message>;
707
+ /**
708
+ * Delete a message
709
+ */
710
+ delete(messageId: string): Promise<void>;
711
+ /**
712
+ * Get the raw command string
713
+ */
714
+ get rawCommand(): string;
715
+ }
716
+
717
+ /**
718
+ * Command Builder - fluent API for building commands
719
+ */
720
+
721
+ declare class CommandBuilder {
722
+ private name;
723
+ private description;
724
+ private usage?;
725
+ private handler?;
726
+ /**
727
+ * Set the command name
728
+ */
729
+ setName(name: string): this;
730
+ /**
731
+ * Set the command description
732
+ */
733
+ setDescription(description: string): this;
734
+ /**
735
+ * Set the command usage example
736
+ */
737
+ setUsage(usage: string): this;
738
+ /**
739
+ * Set the command handler
740
+ */
741
+ setHandler(handler: (context: CommandContext) => void | Promise<void>): this;
742
+ /**
743
+ * Build the command object
744
+ */
745
+ build(): Command;
746
+ }
747
+
748
+ /**
749
+ * Custom error classes for the Chirp Bot SDK
750
+ */
751
+ /**
752
+ * Base error class for all SDK errors
753
+ */
754
+ declare class ChirpError extends Error {
755
+ constructor(message: string);
756
+ }
757
+ /**
758
+ * Error thrown when authentication fails
759
+ */
760
+ declare class AuthenticationError extends ChirpError {
761
+ constructor(message?: string);
762
+ }
763
+ /**
764
+ * Error thrown when a rate limit is hit
765
+ */
766
+ declare class RateLimitError extends ChirpError {
767
+ readonly retryAfter: number;
768
+ constructor(message: string, retryAfter?: number);
769
+ }
770
+ /**
771
+ * Error thrown when a requested resource is not found
772
+ */
773
+ declare class NotFoundError extends ChirpError {
774
+ constructor(message?: string);
775
+ }
776
+ /**
777
+ * Error thrown when the client lacks permission for an action
778
+ */
779
+ declare class PermissionError extends ChirpError {
780
+ constructor(message?: string);
781
+ }
782
+ /**
783
+ * Error thrown when a request is invalid
784
+ */
785
+ declare class ValidationError extends ChirpError {
786
+ constructor(message?: string);
787
+ }
788
+ /**
789
+ * Error thrown when the WebSocket connection fails
790
+ */
791
+ declare class ConnectionError extends ChirpError {
792
+ constructor(message?: string);
793
+ }
794
+ /**
795
+ * Error thrown when command execution fails
796
+ */
797
+ declare class CommandError extends ChirpError {
798
+ readonly commandName: string;
799
+ constructor(message: string, commandName: string);
800
+ }
801
+
802
+ /**
803
+ * Logger utility for the SDK
804
+ */
805
+ declare enum LogLevel {
806
+ DEBUG = 0,
807
+ INFO = 1,
808
+ WARN = 2,
809
+ ERROR = 3
810
+ }
811
+ declare class Logger {
812
+ private level;
813
+ private prefix;
814
+ constructor(prefix?: string, level?: LogLevel);
815
+ /**
816
+ * Set the log level
817
+ */
818
+ setLevel(level: LogLevel): void;
819
+ /**
820
+ * Format a log message
821
+ */
822
+ private format;
823
+ /**
824
+ * Log a debug message
825
+ */
826
+ debug(message: string, ...args: any[]): void;
827
+ /**
828
+ * Log an info message
829
+ */
830
+ info(message: string, ...args: any[]): void;
831
+ /**
832
+ * Log a warning message
833
+ */
834
+ warn(message: string, ...args: any[]): void;
835
+ /**
836
+ * Log an error message
837
+ */
838
+ error(message: string, ...args: any[]): void;
839
+ /**
840
+ * Create a child logger with a different prefix
841
+ */
842
+ child(prefix: string): Logger;
843
+ }
844
+ /**
845
+ * Default logger instance
846
+ */
847
+ declare const logger: Logger;
848
+
849
+ /**
850
+ * Utility helper functions
851
+ */
852
+ /**
853
+ * Convert a WebSocket URL to HTTP URL
854
+ */
855
+ declare function wsToHttp(wsUrl: string): string;
856
+ /**
857
+ * Convert an HTTP URL to WebSocket URL
858
+ */
859
+ declare function httpToWs(httpUrl: string): string;
860
+ /**
861
+ * Parse command arguments from a string
862
+ * Handles quoted strings as single arguments
863
+ */
864
+ declare function parseArgs(input: string): string[];
865
+ /**
866
+ * Format a user mention
867
+ */
868
+ declare function formatMention(userId: string): string;
869
+ /**
870
+ * Format a channel mention
871
+ */
872
+ declare function formatChannelMention(channelId: string): string;
873
+ /**
874
+ * Extract user IDs from mentions in a message
875
+ */
876
+ declare function extractMentionIds(content: string): string[];
877
+ /**
878
+ * Delay execution for a specified time
879
+ */
880
+ declare function delay(ms: number): Promise<void>;
881
+ /**
882
+ * Retry a function with exponential backoff
883
+ */
884
+ declare function retry<T>(fn: () => Promise<T>, options?: {
885
+ maxAttempts?: number;
886
+ initialDelay?: number;
887
+ maxDelay?: number;
888
+ factor?: number;
889
+ }): Promise<T>;
890
+
891
+ export { APIError, type APIError$1 as APIErrorType, type Attachment, AuthenticationError, type BotServerInfo, type BotTokenInfo, type Channel, ChannelManager, ChirpClient, type ChirpClientOptions, ChirpError, type ChirpEventName, type ChirpEvents, Collection, type Command, CommandBuilder, CommandContext, CommandError, CommandManager, ConnectionError, ConnectionStatus, type CommandContext$1 as ICommandContext, type Intent, LogLevel, Logger, type Message, MessageManager, type MessageOptions, type MessageReply, NotFoundError, type PaginatedResponse, type PartialChannel, type PartialUser, PermissionError, RESTClient, RateLimitError, type Reaction, SafeEventEmitter, type Server, ServerManager, type ServerMember, type User, ValidationError, ChirpClient as default, delay, extractMentionIds, formatChannelMention, formatMention, httpToWs, logger, parseArgs, retry, wsToHttp };