@lazyneoaz/metachat 5.0.0 → 5.1.0

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
@@ -1128,6 +1128,12 @@ declare function startRecovery(ctx: any, runtime: RecoveryRuntime, options?: Rec
1128
1128
  declare const SILENT_WINDOW_MS: number;
1129
1129
  /** How long to wait for traffic after an active ping before declaring death. */
1130
1130
  declare const PING_GRACE_MS: number;
1131
+ interface RealtimeHealthOptions {
1132
+ /** Silent window before a socket is considered suspect (default 30 min). */
1133
+ silentWindowMs?: number;
1134
+ /** Grace after a ping before the socket may be declared dead (default 60 s). */
1135
+ pingGraceMs?: number;
1136
+ }
1131
1137
  interface RealtimeHealthState {
1132
1138
  /** Whether the transport currently reports itself connected. */
1133
1139
  connected: boolean;
@@ -1155,7 +1161,11 @@ declare class RealtimeHealth {
1155
1161
  private forcedReconnects;
1156
1162
  private lastPingAt;
1157
1163
  private startedAt;
1158
- constructor(now?: () => number);
1164
+ private silentWindowMs;
1165
+ private pingGraceMs;
1166
+ /** Consecutive pings sent without any resulting frame. */
1167
+ private silentPings;
1168
+ constructor(now?: () => number, options?: RealtimeHealthOptions);
1159
1169
  /** Record any inbound frame (message, pong, anything from the broker). */
1160
1170
  noteFrame(): void;
1161
1171
  /** Record a successful connect. */
@@ -1169,8 +1179,8 @@ declare class RealtimeHealth {
1169
1179
  * Decide what to do about the current socket.
1170
1180
  *
1171
1181
  * - `disconnected` — the transport already knows it is down; reconnect.
1172
- * - `dead` — connected on paper, silent past the window, and a ping raised no
1173
- * traffic within the grace period; reconnect.
1182
+ * - `dead` — connected on paper, silent well past the window, and repeated
1183
+ * pings raised no traffic at all; reconnect.
1174
1184
  * - `suspect` — silent past the window but a ping was only just sent; wait.
1175
1185
  * - `quiet` — silent but inside the window; normal.
1176
1186
  * - `healthy` — recent traffic.
@@ -1182,7 +1192,7 @@ declare class RealtimeHealth {
1182
1192
  noteForcedReconnect(): void;
1183
1193
  }
1184
1194
  interface RealtimeSupervisorOptions {
1185
- /** How often to evaluate the socket. Jittered. Default 3 min. */
1195
+ /** How often to evaluate the socket. Jittered. Default 10 min. */
1186
1196
  intervalMs?: number;
1187
1197
  /** Ask the transport to reconnect (fresh socket) — must be idempotent. */
1188
1198
  reconnect: (reason: string) => void;
@@ -1192,6 +1202,11 @@ interface RealtimeSupervisorOptions {
1192
1202
  isConnected: () => boolean;
1193
1203
  /** Observe verdict changes (logging). */
1194
1204
  onVerdict?: (state: RealtimeHealthState) => void;
1205
+ /** Silent window / ping grace overrides. */
1206
+ silentWindowMs?: number;
1207
+ pingGraceMs?: number;
1208
+ /** Use an existing health tracker instead of creating a private one. */
1209
+ health?: RealtimeHealth;
1195
1210
  }
1196
1211
  /**
1197
1212
  * A lightweight supervisor that keeps ONE realtime socket honest: it pings a
@@ -1235,6 +1250,36 @@ interface AcquireResult {
1235
1250
  */
1236
1251
  declare function acquireCookies(jar: any, credentials: LoginCredentials$1, globalOptions: LoginOptions$1): Promise<AcquireResult>;
1237
1252
 
1253
+ interface UploadedAttachment {
1254
+ [key: string]: any;
1255
+ }
1256
+ declare function cleanJsonResponse(value: any): any;
1257
+ declare function uploadMercuryAttachment(ctx: any, defaultFuncs: any, attachment: any): Promise<UploadedAttachment>;
1258
+ /**
1259
+ * Upload a single image for use as a group/thread image. Uses the Mercury
1260
+ * `images_only=true` endpoint so Facebook returns an `image_id`.
1261
+ */
1262
+ declare function uploadGroupImage(ctx: any, defaultFuncs: any, image: any): Promise<any>;
1263
+
1264
+ /**
1265
+ * Shared reaction validation for every surface that sends a reaction.
1266
+ * Facebook accepts any single emoji; a whitelist silently rejects valid picks.
1267
+ */
1268
+ declare const CORE_REACTIONS: string[];
1269
+ declare const REACTION_ALIASES: Record<string, string>;
1270
+ declare function isReactionEmoji(value: unknown): boolean;
1271
+ declare function normalizeReaction(value: unknown, options?: {
1272
+ allowRemove?: boolean;
1273
+ forceCustom?: boolean;
1274
+ }): string;
1275
+
1276
+ /**
1277
+ * Facebook "non-critical" errors (e.g. 1357004) are retryable and must not be
1278
+ * treated as auth failures or checkpoints.
1279
+ */
1280
+ declare function isNonCriticalError(value: any): boolean;
1281
+ declare function retryOnNonCritical<T = any>(operation: () => Promise<T>, refresh: () => void | Promise<void>): Promise<T>;
1282
+
1238
1283
  type ApiContext = ApiContext$1;
1239
1284
  type ApiInternal = Api;
1240
1285
  type DefaultFuncs = DefaultFuncs$1;
@@ -1245,4 +1290,4 @@ declare const _default: typeof login$1 & {
1245
1290
  default: typeof login$1;
1246
1291
  };
1247
1292
 
1248
- export { type API, type AddedStickerPackInfo, type AiTheme, type AnyAttachment, type ApiContext, type ApiInternal, type Attachment, type AudioAttachment, type BrowserProfile, 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, 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, collectSessionCookies, _default as default, defaultBrowserProfile, ensureCometTokens, extractCookies, extractCookiesFromBody, extractCookiesFromJar, extractCookiesFromSetCookie, extractCurrentUser, getFingerprintParams, getHeaders, getWebSocketHeaders, hasAuthenticatedSession, humanDelay, invalidateCometTokens, isAuthFailure, isBreakerOpen, isLoggedOutDocument, isStaleTokenError, login$1 as login, missingSessionCookies, normalizeBrowserProfile, noteAction, noteAuthFailure, noteCheckpoint, noteRateLimit, paceRequest, publicTypes, randomUserAgent, refreshSessionCookies, repairSession, reserveRequest, resetBreaker, resolveProfile, retryDelay, safetySnapshot, sleep, startLiveness, startRealtimeSupervisor, startRecovery, tripBreaker, warmUpSession, withCometTokens, withSessionRetry };
1293
+ 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 };
package/dist/index.d.ts CHANGED
@@ -1128,6 +1128,12 @@ declare function startRecovery(ctx: any, runtime: RecoveryRuntime, options?: Rec
1128
1128
  declare const SILENT_WINDOW_MS: number;
1129
1129
  /** How long to wait for traffic after an active ping before declaring death. */
1130
1130
  declare const PING_GRACE_MS: number;
1131
+ interface RealtimeHealthOptions {
1132
+ /** Silent window before a socket is considered suspect (default 30 min). */
1133
+ silentWindowMs?: number;
1134
+ /** Grace after a ping before the socket may be declared dead (default 60 s). */
1135
+ pingGraceMs?: number;
1136
+ }
1131
1137
  interface RealtimeHealthState {
1132
1138
  /** Whether the transport currently reports itself connected. */
1133
1139
  connected: boolean;
@@ -1155,7 +1161,11 @@ declare class RealtimeHealth {
1155
1161
  private forcedReconnects;
1156
1162
  private lastPingAt;
1157
1163
  private startedAt;
1158
- constructor(now?: () => number);
1164
+ private silentWindowMs;
1165
+ private pingGraceMs;
1166
+ /** Consecutive pings sent without any resulting frame. */
1167
+ private silentPings;
1168
+ constructor(now?: () => number, options?: RealtimeHealthOptions);
1159
1169
  /** Record any inbound frame (message, pong, anything from the broker). */
1160
1170
  noteFrame(): void;
1161
1171
  /** Record a successful connect. */
@@ -1169,8 +1179,8 @@ declare class RealtimeHealth {
1169
1179
  * Decide what to do about the current socket.
1170
1180
  *
1171
1181
  * - `disconnected` — the transport already knows it is down; reconnect.
1172
- * - `dead` — connected on paper, silent past the window, and a ping raised no
1173
- * traffic within the grace period; reconnect.
1182
+ * - `dead` — connected on paper, silent well past the window, and repeated
1183
+ * pings raised no traffic at all; reconnect.
1174
1184
  * - `suspect` — silent past the window but a ping was only just sent; wait.
1175
1185
  * - `quiet` — silent but inside the window; normal.
1176
1186
  * - `healthy` — recent traffic.
@@ -1182,7 +1192,7 @@ declare class RealtimeHealth {
1182
1192
  noteForcedReconnect(): void;
1183
1193
  }
1184
1194
  interface RealtimeSupervisorOptions {
1185
- /** How often to evaluate the socket. Jittered. Default 3 min. */
1195
+ /** How often to evaluate the socket. Jittered. Default 10 min. */
1186
1196
  intervalMs?: number;
1187
1197
  /** Ask the transport to reconnect (fresh socket) — must be idempotent. */
1188
1198
  reconnect: (reason: string) => void;
@@ -1192,6 +1202,11 @@ interface RealtimeSupervisorOptions {
1192
1202
  isConnected: () => boolean;
1193
1203
  /** Observe verdict changes (logging). */
1194
1204
  onVerdict?: (state: RealtimeHealthState) => void;
1205
+ /** Silent window / ping grace overrides. */
1206
+ silentWindowMs?: number;
1207
+ pingGraceMs?: number;
1208
+ /** Use an existing health tracker instead of creating a private one. */
1209
+ health?: RealtimeHealth;
1195
1210
  }
1196
1211
  /**
1197
1212
  * A lightweight supervisor that keeps ONE realtime socket honest: it pings a
@@ -1235,6 +1250,36 @@ interface AcquireResult {
1235
1250
  */
1236
1251
  declare function acquireCookies(jar: any, credentials: LoginCredentials$1, globalOptions: LoginOptions$1): Promise<AcquireResult>;
1237
1252
 
1253
+ interface UploadedAttachment {
1254
+ [key: string]: any;
1255
+ }
1256
+ declare function cleanJsonResponse(value: any): any;
1257
+ declare function uploadMercuryAttachment(ctx: any, defaultFuncs: any, attachment: any): Promise<UploadedAttachment>;
1258
+ /**
1259
+ * Upload a single image for use as a group/thread image. Uses the Mercury
1260
+ * `images_only=true` endpoint so Facebook returns an `image_id`.
1261
+ */
1262
+ declare function uploadGroupImage(ctx: any, defaultFuncs: any, image: any): Promise<any>;
1263
+
1264
+ /**
1265
+ * Shared reaction validation for every surface that sends a reaction.
1266
+ * Facebook accepts any single emoji; a whitelist silently rejects valid picks.
1267
+ */
1268
+ declare const CORE_REACTIONS: string[];
1269
+ declare const REACTION_ALIASES: Record<string, string>;
1270
+ declare function isReactionEmoji(value: unknown): boolean;
1271
+ declare function normalizeReaction(value: unknown, options?: {
1272
+ allowRemove?: boolean;
1273
+ forceCustom?: boolean;
1274
+ }): string;
1275
+
1276
+ /**
1277
+ * Facebook "non-critical" errors (e.g. 1357004) are retryable and must not be
1278
+ * treated as auth failures or checkpoints.
1279
+ */
1280
+ declare function isNonCriticalError(value: any): boolean;
1281
+ declare function retryOnNonCritical<T = any>(operation: () => Promise<T>, refresh: () => void | Promise<void>): Promise<T>;
1282
+
1238
1283
  type ApiContext = ApiContext$1;
1239
1284
  type ApiInternal = Api;
1240
1285
  type DefaultFuncs = DefaultFuncs$1;
@@ -1245,4 +1290,4 @@ declare const _default: typeof login$1 & {
1245
1290
  default: typeof login$1;
1246
1291
  };
1247
1292
 
1248
- export { type API, type AddedStickerPackInfo, type AiTheme, type AnyAttachment, type ApiContext, type ApiInternal, type Attachment, type AudioAttachment, type BrowserProfile, 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, 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, collectSessionCookies, _default as default, defaultBrowserProfile, ensureCometTokens, extractCookies, extractCookiesFromBody, extractCookiesFromJar, extractCookiesFromSetCookie, extractCurrentUser, getFingerprintParams, getHeaders, getWebSocketHeaders, hasAuthenticatedSession, humanDelay, invalidateCometTokens, isAuthFailure, isBreakerOpen, isLoggedOutDocument, isStaleTokenError, login$1 as login, missingSessionCookies, normalizeBrowserProfile, noteAction, noteAuthFailure, noteCheckpoint, noteRateLimit, paceRequest, publicTypes, randomUserAgent, refreshSessionCookies, repairSession, reserveRequest, resetBreaker, resolveProfile, retryDelay, safetySnapshot, sleep, startLiveness, startRealtimeSupervisor, startRecovery, tripBreaker, warmUpSession, withCometTokens, withSessionRetry };
1293
+ 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 };