@lazyneoaz/metachat 5.1.2 → 6.0.1

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/dist/index.d.mts CHANGED
@@ -831,6 +831,63 @@ declare function retryDelay(attempt: number, baseMs?: number, capMs?: number): n
831
831
  /** Mark a heavy action so the next request gets a longer pause. */
832
832
  declare function noteAction(ctx: any, weight?: "light" | "normal" | "heavy"): void;
833
833
 
834
+ /**
835
+ * Realtime event middleware system (reference `api.useMiddleware` etc.).
836
+ *
837
+ * A middleware is `(event, next) => void | Promise<void>`. Middleware run in
838
+ * registration order; call `next()` to continue, `next(err)` to abort with an
839
+ * error, or `next(false)` to drop the event. Returning false/null from a
840
+ * middleware drops the event.
841
+ */
842
+ type MiddlewareCallback = (err: any, event: any) => void;
843
+ type NextFunction = (arg?: any) => void;
844
+ type MiddlewareFunction = (event: any, next: NextFunction) => any;
845
+ interface RealtimeMiddlewareSystem {
846
+ use: (middleware: string | MiddlewareFunction, fn?: MiddlewareFunction) => () => void;
847
+ remove: (identifier: string | MiddlewareFunction) => boolean;
848
+ clear: () => void;
849
+ list: () => string[];
850
+ setEnabled: (name: string, enabled: boolean) => boolean;
851
+ process: (event: any, finalCallback: MiddlewareCallback) => void;
852
+ wrapCallback: (callback: MiddlewareCallback) => MiddlewareCallback;
853
+ readonly count: number;
854
+ }
855
+ declare function createRealtimeMiddlewareSystem(logger?: (text: string, type?: string) => void): RealtimeMiddlewareSystem;
856
+
857
+ declare function createScheduler(sendMessage: (...args: any[]) => any, logger?: (m: string, l?: string) => void): {
858
+ scheduleMessage: (message: any, threadID: any, when: Date | number | string, options?: any) => string;
859
+ cancelScheduledMessage: (id: string) => boolean;
860
+ getScheduledMessage: (id: string) => {
861
+ id: string;
862
+ message: any;
863
+ threadID: any;
864
+ timestamp: number;
865
+ createdAt: number;
866
+ options: {
867
+ replyMessageID?: string;
868
+ isGroup?: boolean;
869
+ callback?: any;
870
+ };
871
+ timeUntilSend: number;
872
+ };
873
+ listScheduledMessages: () => {
874
+ id: string;
875
+ message: any;
876
+ threadID: any;
877
+ timestamp: number;
878
+ createdAt: number;
879
+ options: {
880
+ replyMessageID?: string;
881
+ isGroup?: boolean;
882
+ callback?: any;
883
+ };
884
+ timeUntilSend: number;
885
+ }[];
886
+ cancelAllScheduledMessages: () => number;
887
+ getScheduledCount: () => number;
888
+ destroy: () => number;
889
+ };
890
+
834
891
  /**
835
892
  * Account safety: a per-session request budget and circuit breaker.
836
893
  *
@@ -1297,4 +1354,4 @@ declare const _default: typeof login$1 & {
1297
1354
  default: typeof login$1;
1298
1355
  };
1299
1356
 
1300
- export { type API, type AddedStickerPackInfo, type AiTheme, type AnyAttachment, type ApiContext, type ApiInternal, type Attachment, type AudioAttachment, type BrowserProfile, CORE_REACTIONS, type Callback, type CommentMessage, type CommentResult, type Coordinates, type DefaultFuncs, type EmojiEvent, type Event, type FileAttachment, type GroupNameEvent, type ListenEvent, type LivenessHandle, type LivenessState, type LoginCredentials, type LoginOptions, type Mention, type Message, type MessageID, type MessageObject, type MessageReply, type MusicTag, type MusicTrack, type NicknameEvent, PING_GRACE_MS, type PhotoAttachment, REACTION_ALIASES, type Reaction, RealtimeHealth, type RealtimeHealthState, type RecoveryEvent, type RecoveryOptions, type RecoveryRuntime, type RecoveryState, RecoverySupervisor, SILENT_WINDOW_MS, type SearchMusicOptions, type SearchMusicResult, type ShareAttachment, type ShareResult, type StickerAttachment, type StickerInfo, type StickerPackInfo, type ThreadID, type ThreadInfo, type ThreadThemeEvent, type TypingIndicator, type UnsendMessageEvent, type UserID, type UserInfo, type VideoAttachment, type WarmUpResult, acquireCookies, applySetCookie, awaitProactiveSlot, canActProactively, cleanJsonResponse, collectSessionCookies, _default as default, defaultBrowserProfile, ensureCometTokens, extractCookies, extractCookiesFromBody, extractCookiesFromJar, extractCookiesFromSetCookie, extractCurrentUser, getFingerprintParams, getHeaders, getWebSocketHeaders, hasAuthenticatedSession, humanDelay, invalidateCometTokens, isAuthFailure, isBreakerOpen, isLoggedOutDocument, isNonCriticalError, isReactionEmoji, isStaleTokenError, login$1 as login, missingSessionCookies, normalizeBrowserProfile, normalizeReaction, noteAction, noteAuthFailure, noteCheckpoint, noteRateLimit, paceRequest, publicTypes, randomUserAgent, refreshSessionCookies, repairSession, reserveRequest, resetBreaker, resolveProfile, retryDelay, retryOnNonCritical, safetySnapshot, sleep, startLiveness, startRealtimeSupervisor, startRecovery, tripBreaker, uploadGroupImage, uploadMercuryAttachment, warmUpSession, withCometTokens, withSessionRetry };
1357
+ export { type API, type AddedStickerPackInfo, type AiTheme, type AnyAttachment, type ApiContext, type ApiInternal, type Attachment, type AudioAttachment, type BrowserProfile, CORE_REACTIONS, type Callback, type CommentMessage, type CommentResult, type Coordinates, type DefaultFuncs, type EmojiEvent, type Event, type FileAttachment, type GroupNameEvent, type ListenEvent, type LivenessHandle, type LivenessState, type LoginCredentials, type LoginOptions, type Mention, type Message, type MessageID, type MessageObject, type MessageReply, type MusicTag, type MusicTrack, type NicknameEvent, PING_GRACE_MS, type PhotoAttachment, REACTION_ALIASES, type Reaction, RealtimeHealth, type RealtimeHealthState, type RecoveryEvent, type RecoveryOptions, type RecoveryRuntime, type RecoveryState, RecoverySupervisor, SILENT_WINDOW_MS, type SearchMusicOptions, type SearchMusicResult, type ShareAttachment, type ShareResult, type StickerAttachment, type StickerInfo, type StickerPackInfo, type ThreadID, type ThreadInfo, type ThreadThemeEvent, type TypingIndicator, type UnsendMessageEvent, type UserID, type UserInfo, type VideoAttachment, type WarmUpResult, acquireCookies, applySetCookie, awaitProactiveSlot, canActProactively, cleanJsonResponse, collectSessionCookies, createRealtimeMiddlewareSystem, createScheduler, _default as default, defaultBrowserProfile, ensureCometTokens, extractCookies, extractCookiesFromBody, extractCookiesFromJar, extractCookiesFromSetCookie, extractCurrentUser, getFingerprintParams, getHeaders, getWebSocketHeaders, hasAuthenticatedSession, humanDelay, invalidateCometTokens, isAuthFailure, isBreakerOpen, isLoggedOutDocument, isNonCriticalError, isReactionEmoji, isStaleTokenError, login$1 as login, missingSessionCookies, normalizeBrowserProfile, normalizeReaction, noteAction, noteAuthFailure, noteCheckpoint, noteRateLimit, paceRequest, publicTypes, randomUserAgent, refreshSessionCookies, repairSession, reserveRequest, resetBreaker, resolveProfile, retryDelay, retryOnNonCritical, safetySnapshot, sleep, startLiveness, startRealtimeSupervisor, startRecovery, tripBreaker, uploadGroupImage, uploadMercuryAttachment, warmUpSession, withCometTokens, withSessionRetry };
package/dist/index.d.ts CHANGED
@@ -831,6 +831,63 @@ declare function retryDelay(attempt: number, baseMs?: number, capMs?: number): n
831
831
  /** Mark a heavy action so the next request gets a longer pause. */
832
832
  declare function noteAction(ctx: any, weight?: "light" | "normal" | "heavy"): void;
833
833
 
834
+ /**
835
+ * Realtime event middleware system (reference `api.useMiddleware` etc.).
836
+ *
837
+ * A middleware is `(event, next) => void | Promise<void>`. Middleware run in
838
+ * registration order; call `next()` to continue, `next(err)` to abort with an
839
+ * error, or `next(false)` to drop the event. Returning false/null from a
840
+ * middleware drops the event.
841
+ */
842
+ type MiddlewareCallback = (err: any, event: any) => void;
843
+ type NextFunction = (arg?: any) => void;
844
+ type MiddlewareFunction = (event: any, next: NextFunction) => any;
845
+ interface RealtimeMiddlewareSystem {
846
+ use: (middleware: string | MiddlewareFunction, fn?: MiddlewareFunction) => () => void;
847
+ remove: (identifier: string | MiddlewareFunction) => boolean;
848
+ clear: () => void;
849
+ list: () => string[];
850
+ setEnabled: (name: string, enabled: boolean) => boolean;
851
+ process: (event: any, finalCallback: MiddlewareCallback) => void;
852
+ wrapCallback: (callback: MiddlewareCallback) => MiddlewareCallback;
853
+ readonly count: number;
854
+ }
855
+ declare function createRealtimeMiddlewareSystem(logger?: (text: string, type?: string) => void): RealtimeMiddlewareSystem;
856
+
857
+ declare function createScheduler(sendMessage: (...args: any[]) => any, logger?: (m: string, l?: string) => void): {
858
+ scheduleMessage: (message: any, threadID: any, when: Date | number | string, options?: any) => string;
859
+ cancelScheduledMessage: (id: string) => boolean;
860
+ getScheduledMessage: (id: string) => {
861
+ id: string;
862
+ message: any;
863
+ threadID: any;
864
+ timestamp: number;
865
+ createdAt: number;
866
+ options: {
867
+ replyMessageID?: string;
868
+ isGroup?: boolean;
869
+ callback?: any;
870
+ };
871
+ timeUntilSend: number;
872
+ };
873
+ listScheduledMessages: () => {
874
+ id: string;
875
+ message: any;
876
+ threadID: any;
877
+ timestamp: number;
878
+ createdAt: number;
879
+ options: {
880
+ replyMessageID?: string;
881
+ isGroup?: boolean;
882
+ callback?: any;
883
+ };
884
+ timeUntilSend: number;
885
+ }[];
886
+ cancelAllScheduledMessages: () => number;
887
+ getScheduledCount: () => number;
888
+ destroy: () => number;
889
+ };
890
+
834
891
  /**
835
892
  * Account safety: a per-session request budget and circuit breaker.
836
893
  *
@@ -1297,4 +1354,4 @@ declare const _default: typeof login$1 & {
1297
1354
  default: typeof login$1;
1298
1355
  };
1299
1356
 
1300
- export { type API, type AddedStickerPackInfo, type AiTheme, type AnyAttachment, type ApiContext, type ApiInternal, type Attachment, type AudioAttachment, type BrowserProfile, CORE_REACTIONS, type Callback, type CommentMessage, type CommentResult, type Coordinates, type DefaultFuncs, type EmojiEvent, type Event, type FileAttachment, type GroupNameEvent, type ListenEvent, type LivenessHandle, type LivenessState, type LoginCredentials, type LoginOptions, type Mention, type Message, type MessageID, type MessageObject, type MessageReply, type MusicTag, type MusicTrack, type NicknameEvent, PING_GRACE_MS, type PhotoAttachment, REACTION_ALIASES, type Reaction, RealtimeHealth, type RealtimeHealthState, type RecoveryEvent, type RecoveryOptions, type RecoveryRuntime, type RecoveryState, RecoverySupervisor, SILENT_WINDOW_MS, type SearchMusicOptions, type SearchMusicResult, type ShareAttachment, type ShareResult, type StickerAttachment, type StickerInfo, type StickerPackInfo, type ThreadID, type ThreadInfo, type ThreadThemeEvent, type TypingIndicator, type UnsendMessageEvent, type UserID, type UserInfo, type VideoAttachment, type WarmUpResult, acquireCookies, applySetCookie, awaitProactiveSlot, canActProactively, cleanJsonResponse, collectSessionCookies, _default as default, defaultBrowserProfile, ensureCometTokens, extractCookies, extractCookiesFromBody, extractCookiesFromJar, extractCookiesFromSetCookie, extractCurrentUser, getFingerprintParams, getHeaders, getWebSocketHeaders, hasAuthenticatedSession, humanDelay, invalidateCometTokens, isAuthFailure, isBreakerOpen, isLoggedOutDocument, isNonCriticalError, isReactionEmoji, isStaleTokenError, login$1 as login, missingSessionCookies, normalizeBrowserProfile, normalizeReaction, noteAction, noteAuthFailure, noteCheckpoint, noteRateLimit, paceRequest, publicTypes, randomUserAgent, refreshSessionCookies, repairSession, reserveRequest, resetBreaker, resolveProfile, retryDelay, retryOnNonCritical, safetySnapshot, sleep, startLiveness, startRealtimeSupervisor, startRecovery, tripBreaker, uploadGroupImage, uploadMercuryAttachment, warmUpSession, withCometTokens, withSessionRetry };
1357
+ export { type API, type AddedStickerPackInfo, type AiTheme, type AnyAttachment, type ApiContext, type ApiInternal, type Attachment, type AudioAttachment, type BrowserProfile, CORE_REACTIONS, type Callback, type CommentMessage, type CommentResult, type Coordinates, type DefaultFuncs, type EmojiEvent, type Event, type FileAttachment, type GroupNameEvent, type ListenEvent, type LivenessHandle, type LivenessState, type LoginCredentials, type LoginOptions, type Mention, type Message, type MessageID, type MessageObject, type MessageReply, type MusicTag, type MusicTrack, type NicknameEvent, PING_GRACE_MS, type PhotoAttachment, REACTION_ALIASES, type Reaction, RealtimeHealth, type RealtimeHealthState, type RecoveryEvent, type RecoveryOptions, type RecoveryRuntime, type RecoveryState, RecoverySupervisor, SILENT_WINDOW_MS, type SearchMusicOptions, type SearchMusicResult, type ShareAttachment, type ShareResult, type StickerAttachment, type StickerInfo, type StickerPackInfo, type ThreadID, type ThreadInfo, type ThreadThemeEvent, type TypingIndicator, type UnsendMessageEvent, type UserID, type UserInfo, type VideoAttachment, type WarmUpResult, acquireCookies, applySetCookie, awaitProactiveSlot, canActProactively, cleanJsonResponse, collectSessionCookies, createRealtimeMiddlewareSystem, createScheduler, _default as default, defaultBrowserProfile, ensureCometTokens, extractCookies, extractCookiesFromBody, extractCookiesFromJar, extractCookiesFromSetCookie, extractCurrentUser, getFingerprintParams, getHeaders, getWebSocketHeaders, hasAuthenticatedSession, humanDelay, invalidateCometTokens, isAuthFailure, isBreakerOpen, isLoggedOutDocument, isNonCriticalError, isReactionEmoji, isStaleTokenError, login$1 as login, missingSessionCookies, normalizeBrowserProfile, normalizeReaction, noteAction, noteAuthFailure, noteCheckpoint, noteRateLimit, paceRequest, publicTypes, randomUserAgent, refreshSessionCookies, repairSession, reserveRequest, resetBreaker, resolveProfile, retryDelay, retryOnNonCritical, safetySnapshot, sleep, startLiveness, startRealtimeSupervisor, startRecovery, tripBreaker, uploadGroupImage, uploadMercuryAttachment, warmUpSession, withCometTokens, withSessionRetry };