@larksuiteoapi/node-sdk 1.61.1 → 1.62.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/types/index.d.ts CHANGED
@@ -110,6 +110,10 @@ interface IClientParams {
110
110
  helpDeskId?: string;
111
111
  helpDeskToken?: string;
112
112
  httpInstance?: HttpInstance;
113
+ /** Caller tag appended to User-Agent as `source/<name>`. */
114
+ source?: string;
115
+ /** @internal Extra bare tokens appended to User-Agent, set by sub-modules. */
116
+ extraUaTags?: string[];
113
117
  }
114
118
  interface IPayload {
115
119
  params?: Record<string, any>;
@@ -5923,7 +5927,7 @@ declare abstract class Client$12 extends Client$13 {
5923
5927
  } | undefined;
5924
5928
  recommend_item_infos?: {
5925
5929
  item_id?: string | undefined;
5926
- item_type?: "application" | "link" | undefined;
5930
+ item_type?: "link" | "application" | undefined;
5927
5931
  name?: string | undefined;
5928
5932
  description?: string | undefined;
5929
5933
  link_url?: string | undefined;
@@ -5940,7 +5944,7 @@ declare abstract class Client$12 extends Client$13 {
5940
5944
  }[] | undefined;
5941
5945
  distributed_recommend_item_infos?: {
5942
5946
  item_id?: string | undefined;
5943
- item_type?: "application" | "link" | undefined;
5947
+ item_type?: "link" | "application" | undefined;
5944
5948
  name?: string | undefined;
5945
5949
  description?: string | undefined;
5946
5950
  link_url?: string | undefined;
@@ -5989,7 +5993,7 @@ declare abstract class Client$12 extends Client$13 {
5989
5993
  } | undefined;
5990
5994
  recommend_item_infos?: {
5991
5995
  item_id?: string | undefined;
5992
- item_type?: "application" | "link" | undefined;
5996
+ item_type?: "link" | "application" | undefined;
5993
5997
  name?: string | undefined;
5994
5998
  description?: string | undefined;
5995
5999
  link_url?: string | undefined;
@@ -6006,7 +6010,7 @@ declare abstract class Client$12 extends Client$13 {
6006
6010
  }[] | undefined;
6007
6011
  distributed_recommend_item_infos?: {
6008
6012
  item_id?: string | undefined;
6009
- item_type?: "application" | "link" | undefined;
6013
+ item_type?: "link" | "application" | undefined;
6010
6014
  name?: string | undefined;
6011
6015
  description?: string | undefined;
6012
6016
  link_url?: string | undefined;
@@ -6769,7 +6773,7 @@ declare abstract class Client$12 extends Client$13 {
6769
6773
  status?: number | undefined;
6770
6774
  scene_type?: number | undefined;
6771
6775
  payment_type?: number | undefined;
6772
- create_source?: "developer_console" | "base" | "app_engine" | "bot_builder" | "aily" | "unknown" | undefined;
6776
+ create_source?: "unknown" | "developer_console" | "base" | "app_engine" | "bot_builder" | "aily" | undefined;
6773
6777
  redirect_urls?: string[] | undefined;
6774
6778
  online_version_id?: string | undefined;
6775
6779
  unaudit_version_id?: string | undefined;
@@ -6846,7 +6850,7 @@ declare abstract class Client$12 extends Client$13 {
6846
6850
  status?: number | undefined;
6847
6851
  scene_type?: number | undefined;
6848
6852
  payment_type?: number | undefined;
6849
- create_source?: "developer_console" | "base" | "app_engine" | "bot_builder" | "aily" | "unknown" | undefined;
6853
+ create_source?: "unknown" | "developer_console" | "base" | "app_engine" | "bot_builder" | "aily" | undefined;
6850
6854
  redirect_urls?: string[] | undefined;
6851
6855
  online_version_id?: string | undefined;
6852
6856
  unaudit_version_id?: string | undefined;
@@ -6935,7 +6939,7 @@ declare abstract class Client$12 extends Client$13 {
6935
6939
  status?: number | undefined;
6936
6940
  scene_type?: number | undefined;
6937
6941
  payment_type?: number | undefined;
6938
- create_source?: "developer_console" | "base" | "app_engine" | "bot_builder" | "aily" | "unknown" | undefined;
6942
+ create_source?: "unknown" | "developer_console" | "base" | "app_engine" | "bot_builder" | "aily" | undefined;
6939
6943
  redirect_urls?: string[] | undefined;
6940
6944
  online_version_id?: string | undefined;
6941
6945
  unaudit_version_id?: string | undefined;
@@ -7444,7 +7448,7 @@ declare abstract class Client$12 extends Client$13 {
7444
7448
  } | undefined;
7445
7449
  recommend_item_infos?: {
7446
7450
  item_id?: string | undefined;
7447
- item_type?: "application" | "link" | undefined;
7451
+ item_type?: "link" | "application" | undefined;
7448
7452
  name?: string | undefined;
7449
7453
  description?: string | undefined;
7450
7454
  link_url?: string | undefined;
@@ -7461,7 +7465,7 @@ declare abstract class Client$12 extends Client$13 {
7461
7465
  }[] | undefined;
7462
7466
  distributed_recommend_item_infos?: {
7463
7467
  item_id?: string | undefined;
7464
- item_type?: "application" | "link" | undefined;
7468
+ item_type?: "link" | "application" | undefined;
7465
7469
  name?: string | undefined;
7466
7470
  description?: string | undefined;
7467
7471
  link_url?: string | undefined;
@@ -7510,7 +7514,7 @@ declare abstract class Client$12 extends Client$13 {
7510
7514
  } | undefined;
7511
7515
  recommend_item_infos?: {
7512
7516
  item_id?: string | undefined;
7513
- item_type?: "application" | "link" | undefined;
7517
+ item_type?: "link" | "application" | undefined;
7514
7518
  name?: string | undefined;
7515
7519
  description?: string | undefined;
7516
7520
  link_url?: string | undefined;
@@ -7527,7 +7531,7 @@ declare abstract class Client$12 extends Client$13 {
7527
7531
  }[] | undefined;
7528
7532
  distributed_recommend_item_infos?: {
7529
7533
  item_id?: string | undefined;
7530
- item_type?: "application" | "link" | undefined;
7534
+ item_type?: "link" | "application" | undefined;
7531
7535
  name?: string | undefined;
7532
7536
  description?: string | undefined;
7533
7537
  link_url?: string | undefined;
@@ -8290,7 +8294,7 @@ declare abstract class Client$12 extends Client$13 {
8290
8294
  status?: number | undefined;
8291
8295
  scene_type?: number | undefined;
8292
8296
  payment_type?: number | undefined;
8293
- create_source?: "developer_console" | "base" | "app_engine" | "bot_builder" | "aily" | "unknown" | undefined;
8297
+ create_source?: "unknown" | "developer_console" | "base" | "app_engine" | "bot_builder" | "aily" | undefined;
8294
8298
  redirect_urls?: string[] | undefined;
8295
8299
  online_version_id?: string | undefined;
8296
8300
  unaudit_version_id?: string | undefined;
@@ -8367,7 +8371,7 @@ declare abstract class Client$12 extends Client$13 {
8367
8371
  status?: number | undefined;
8368
8372
  scene_type?: number | undefined;
8369
8373
  payment_type?: number | undefined;
8370
- create_source?: "developer_console" | "base" | "app_engine" | "bot_builder" | "aily" | "unknown" | undefined;
8374
+ create_source?: "unknown" | "developer_console" | "base" | "app_engine" | "bot_builder" | "aily" | undefined;
8371
8375
  redirect_urls?: string[] | undefined;
8372
8376
  online_version_id?: string | undefined;
8373
8377
  unaudit_version_id?: string | undefined;
@@ -8456,7 +8460,7 @@ declare abstract class Client$12 extends Client$13 {
8456
8460
  status?: number | undefined;
8457
8461
  scene_type?: number | undefined;
8458
8462
  payment_type?: number | undefined;
8459
- create_source?: "developer_console" | "base" | "app_engine" | "bot_builder" | "aily" | "unknown" | undefined;
8463
+ create_source?: "unknown" | "developer_console" | "base" | "app_engine" | "bot_builder" | "aily" | undefined;
8460
8464
  redirect_urls?: string[] | undefined;
8461
8465
  online_version_id?: string | undefined;
8462
8466
  unaudit_version_id?: string | undefined;
@@ -27583,7 +27587,7 @@ declare abstract class Client$U extends Client$V {
27583
27587
  height?: number | undefined;
27584
27588
  text?: {
27585
27589
  text?: string | undefined;
27586
- font_weight?: "regular" | "bold" | undefined;
27590
+ font_weight?: "bold" | "regular" | undefined;
27587
27591
  font_size?: number | undefined;
27588
27592
  horizontal_align?: "left" | "center" | "right" | undefined;
27589
27593
  vertical_align?: "top" | "mid" | "bottom" | undefined;
@@ -27749,7 +27753,7 @@ declare abstract class Client$U extends Client$V {
27749
27753
  captions?: {
27750
27754
  data?: {
27751
27755
  text?: string | undefined;
27752
- font_weight?: "regular" | "bold" | undefined;
27756
+ font_weight?: "bold" | "regular" | undefined;
27753
27757
  font_size?: number | undefined;
27754
27758
  horizontal_align?: "left" | "center" | "right" | undefined;
27755
27759
  vertical_align?: "top" | "mid" | "bottom" | undefined;
@@ -27948,7 +27952,7 @@ declare abstract class Client$U extends Client$V {
27948
27952
  children?: string[] | undefined;
27949
27953
  text?: {
27950
27954
  text?: string | undefined;
27951
- font_weight?: "regular" | "bold" | undefined;
27955
+ font_weight?: "bold" | "regular" | undefined;
27952
27956
  font_size?: number | undefined;
27953
27957
  horizontal_align?: "left" | "center" | "right" | undefined;
27954
27958
  vertical_align?: "top" | "mid" | "bottom" | undefined;
@@ -284507,6 +284511,7 @@ declare class Client extends Client$1 {
284507
284511
  domain: string;
284508
284512
  httpInstance: HttpInstance;
284509
284513
  userAccessToken: UserAccessToken;
284514
+ private readonly userAgent;
284510
284515
  constructor(params: IClientParams);
284511
284516
  formatPayload(payload?: IPayload, options?: IRequestOptions): Promise<Required<IPayload>>;
284512
284517
  request<T = any>(payload: AxiosRequestConfig, options?: IRequestOptions): Promise<T>;
@@ -293047,6 +293052,22 @@ interface IConstructorParams {
293047
293052
  httpInstance?: HttpInstance;
293048
293053
  autoReconnect?: boolean;
293049
293054
  agent?: any;
293055
+ /** Caller tag appended to User-Agent as `source/<name>`. */
293056
+ source?: string;
293057
+ /** @internal Extra bare tokens appended to User-Agent, set by sub-modules. */
293058
+ extraUaTags?: string[];
293059
+ /** Fires once when the first WebSocket handshake succeeds. */
293060
+ onReady?: () => void;
293061
+ /**
293062
+ * Fires when the initial connect fails and the client either cannot retry
293063
+ * (autoReconnect=false) or exhausts `reconnectCount` retries. The callback
293064
+ * receives an Error describing the final failure.
293065
+ */
293066
+ onError?: (err: Error) => void;
293067
+ /** Fires when the client enters the reconnect loop (i.e., after a disconnect). */
293068
+ onReconnecting?: () => void;
293069
+ /** Fires after the reconnect loop successfully re-establishes the connection. */
293070
+ onReconnected?: () => void;
293050
293071
  }
293051
293072
  declare class WSClient {
293052
293073
  private wsConfig;
@@ -293060,7 +293081,21 @@ declare class WSClient {
293060
293081
  private isConnecting;
293061
293082
  private reconnectInfo;
293062
293083
  private agent?;
293084
+ /** User-supplied state-transition callbacks. All optional. */
293085
+ private onReady?;
293086
+ private onError?;
293087
+ private onReconnecting?;
293088
+ private onReconnected?;
293089
+ private readonly userAgent;
293090
+ /** True if the WS has ever connected successfully in this client's
293091
+ * lifetime — used to distinguish first-connect from reconnect. */
293092
+ private hasEverConnected;
293063
293093
  constructor(params: IConstructorParams);
293094
+ /**
293095
+ * Invoke a user-supplied callback safely: no-op if undefined, swallow any
293096
+ * exception to avoid breaking the WS state machine.
293097
+ */
293098
+ private safeInvoke;
293064
293099
  private pullConnectConfig;
293065
293100
  private connect;
293066
293101
  private reConnect;
@@ -293224,4 +293259,547 @@ interface RegisterAppResult {
293224
293259
 
293225
293260
  declare function registerApp(options: RegisterAppOptions): Promise<RegisterAppResult>;
293226
293261
 
293227
- export { AESCipher, Aily, AppType, CAppTicket, CTenantAccessToken, Cache, CardActionHandler, Client, Domain, EventDispatcher, IHandles as EventHandles, HttpInstance, HttpRequestOptions, InteractiveCard, InteractiveCardActionEvent, InteractiveCardActionItem, InteractiveCardButtonActionItem, InteractiveCardDatePickerActionItem, InteractiveCardDivElement, InteractiveCardDividerElement, InteractiveCardElement, InteractiveCardField, InteractiveCardImageElement, InteractiveCardImageItem, InteractiveCardLarkMdItem, InteractiveCardMarkdownElement, InteractiveCardNoteElement, InteractiveCardOverflowActionItem, InteractiveCardPlainTextItem, InteractiveCardSelectMenuActionItem, InteractiveCardTextItem, InteractiveCardTitle, InteractiveCardUrlItem, InterfaceCardActionElement, LoggerLevel, WSClient, adaptDefault, adaptExpress, adaptKoa, adaptKoaRouter, defaultHttpInstance, generateChallenge, messageCard, registerApp, withAll, withHelpDeskCredential, withTenantKey, withTenantToken, withUserAccessToken };
293262
+ type ChatType = 'p2p' | 'group';
293263
+ interface NormalizedMessage {
293264
+ messageId: string;
293265
+ chatId: string;
293266
+ chatType: ChatType;
293267
+ senderId: string;
293268
+ senderName?: string;
293269
+ content: string;
293270
+ rawContentType: string;
293271
+ resources: ResourceDescriptor[];
293272
+ mentions: MentionInfo[];
293273
+ mentionAll: boolean;
293274
+ mentionedBot: boolean;
293275
+ rootId?: string;
293276
+ threadId?: string;
293277
+ replyToMessageId?: string;
293278
+ createTime: number;
293279
+ raw?: unknown;
293280
+ }
293281
+ interface ResourceDescriptor {
293282
+ type: 'image' | 'file' | 'audio' | 'video' | 'sticker';
293283
+ fileKey: string;
293284
+ fileName?: string;
293285
+ durationMs?: number;
293286
+ coverImageKey?: string;
293287
+ }
293288
+ interface MentionInfo {
293289
+ key: string;
293290
+ openId?: string;
293291
+ userId?: string;
293292
+ name?: string;
293293
+ isBot?: boolean;
293294
+ }
293295
+ interface BotIdentity {
293296
+ openId: string;
293297
+ userId?: string;
293298
+ name: string;
293299
+ }
293300
+ type SendInput = {
293301
+ markdown: string;
293302
+ } | {
293303
+ text: string;
293304
+ } | {
293305
+ post: object;
293306
+ } | {
293307
+ image: {
293308
+ source: string | Buffer;
293309
+ };
293310
+ } | {
293311
+ file: {
293312
+ source: string | Buffer;
293313
+ fileName: string;
293314
+ };
293315
+ } | {
293316
+ audio: {
293317
+ source: string | Buffer;
293318
+ duration?: number;
293319
+ };
293320
+ } | {
293321
+ video: {
293322
+ source: string | Buffer;
293323
+ duration?: number;
293324
+ coverImageKey?: string;
293325
+ };
293326
+ } | {
293327
+ card: object;
293328
+ } | {
293329
+ shareChat: {
293330
+ chatId: string;
293331
+ };
293332
+ } | {
293333
+ shareUser: {
293334
+ userId: string;
293335
+ };
293336
+ } | {
293337
+ sticker: {
293338
+ fileKey: string;
293339
+ };
293340
+ };
293341
+ interface MediaSource {
293342
+ source: string | Buffer;
293343
+ }
293344
+ interface SendOptions {
293345
+ replyTo?: string;
293346
+ replyInThread?: boolean;
293347
+ mentions?: MentionInfo[];
293348
+ }
293349
+ interface SendResult {
293350
+ messageId: string;
293351
+ chunkIds?: string[];
293352
+ }
293353
+ type StreamInput = {
293354
+ markdown: MarkdownStreamProducer;
293355
+ } | {
293356
+ card: {
293357
+ initial: object;
293358
+ producer: CardStreamProducer;
293359
+ };
293360
+ };
293361
+ type MarkdownStreamProducer = (controller: MarkdownStreamController) => Promise<void>;
293362
+ type CardStreamProducer = (controller: CardStreamController) => Promise<void>;
293363
+ interface MarkdownStreamController {
293364
+ append(chunk: string): Promise<void>;
293365
+ setContent(full: string): Promise<void>;
293366
+ readonly messageId: string;
293367
+ }
293368
+ interface CardStreamController {
293369
+ update(next: object | ((current: object) => object)): Promise<void>;
293370
+ readonly messageId: string;
293371
+ readonly current: object;
293372
+ }
293373
+ interface EventMap {
293374
+ message: (msg: NormalizedMessage) => void | Promise<void>;
293375
+ reject: (evt: RejectEvent) => void;
293376
+ cardAction: (evt: CardActionEvent) => void | Promise<void>;
293377
+ reaction: (evt: ReactionEvent) => void;
293378
+ botAdded: (evt: BotAddedEvent) => void;
293379
+ comment: (evt: CommentEvent) => void | Promise<void>;
293380
+ error: (err: LarkChannelError) => void;
293381
+ reconnecting: () => void;
293382
+ reconnected: () => void;
293383
+ }
293384
+ type EventName = keyof EventMap;
293385
+ /**
293386
+ * Reason for a {@link RejectEvent}. These are the set of policy-level
293387
+ * decisions that deliberately reject a message and inform the caller.
293388
+ *
293389
+ * Internal defenses (duplicate dedup, stale/expired timestamps, in-flight
293390
+ * processing lock) silently drop their targets — they are not reject
293391
+ * reasons, because the caller cannot act on them meaningfully.
293392
+ */
293393
+ type RejectReason = 'group_not_allowed' | 'sender_not_allowed' | 'no_mention' | 'dm_disabled' | 'mention_all_blocked';
293394
+ interface RejectEvent {
293395
+ messageId: string;
293396
+ chatId: string;
293397
+ senderId: string;
293398
+ reason: RejectReason;
293399
+ }
293400
+ interface CardActionEvent {
293401
+ messageId: string;
293402
+ chatId: string;
293403
+ operator: {
293404
+ openId: string;
293405
+ userId?: string;
293406
+ name?: string;
293407
+ };
293408
+ action: {
293409
+ value: unknown;
293410
+ tag: string;
293411
+ name?: string;
293412
+ option?: string;
293413
+ };
293414
+ }
293415
+ interface ReactionEvent {
293416
+ messageId: string;
293417
+ operator: {
293418
+ openId: string;
293419
+ userId?: string;
293420
+ };
293421
+ emojiType: string;
293422
+ action: 'added' | 'removed';
293423
+ actionTime?: number;
293424
+ }
293425
+ interface BotAddedEvent {
293426
+ chatId: string;
293427
+ operator: {
293428
+ openId: string;
293429
+ userId?: string;
293430
+ };
293431
+ /**
293432
+ * The bot's own name as carried in the `name` field of the Feishu event.
293433
+ * Not the chat's name — that requires a separate `getChatInfo(chatId)`
293434
+ * call, which callers can do on demand.
293435
+ */
293436
+ botName?: string;
293437
+ external?: boolean;
293438
+ raw?: unknown;
293439
+ }
293440
+ interface CommentEvent {
293441
+ fileToken: string;
293442
+ fileType: string;
293443
+ commentId: string;
293444
+ replyId?: string;
293445
+ operator: {
293446
+ openId: string;
293447
+ userId?: string;
293448
+ unionId?: string;
293449
+ };
293450
+ mentionedBot: boolean;
293451
+ timestamp: number;
293452
+ raw?: unknown;
293453
+ }
293454
+ type LarkChannelErrorCode = 'format_error' | 'target_revoked' | 'rate_limited' | 'permission_denied' | 'upload_failed' | 'ssrf_blocked' | 'send_timeout' | 'not_connected' | 'unknown';
293455
+ declare class LarkChannelError extends Error {
293456
+ code: LarkChannelErrorCode;
293457
+ cause?: unknown;
293458
+ context?: {
293459
+ to?: string;
293460
+ messageId?: string;
293461
+ attempt?: number;
293462
+ };
293463
+ constructor(code: LarkChannelErrorCode, message: string, opts?: {
293464
+ cause?: unknown;
293465
+ context?: LarkChannelError['context'];
293466
+ });
293467
+ }
293468
+ interface LarkChannelOptions {
293469
+ appId: string;
293470
+ appSecret: string;
293471
+ transport?: 'websocket' | 'webhook';
293472
+ webhook?: WebhookOptions;
293473
+ safety?: SafetyConfig;
293474
+ policy?: PolicyConfig;
293475
+ outbound?: OutboundConfig;
293476
+ logger?: Logger;
293477
+ loggerLevel?: LoggerLevel;
293478
+ cache?: Cache;
293479
+ domain?: Domain | string;
293480
+ httpInstance?: HttpInstance;
293481
+ /** Caller tag appended to User-Agent as `source/<name>`. */
293482
+ source?: string;
293483
+ includeRawInMessage?: boolean;
293484
+ }
293485
+ interface WebhookOptions {
293486
+ verificationToken?: string;
293487
+ encryptKey?: string;
293488
+ adapter?: 'express' | 'koa' | 'koa-router';
293489
+ }
293490
+ interface SafetyConfig {
293491
+ dedup?: {
293492
+ ttl?: number;
293493
+ maxEntries?: number;
293494
+ sweepIntervalMs?: number;
293495
+ };
293496
+ chatQueue?: {
293497
+ enabled?: boolean;
293498
+ };
293499
+ batch?: {
293500
+ text?: {
293501
+ delayMs?: number;
293502
+ longThresholdChars?: number;
293503
+ longDelayMs?: number;
293504
+ maxMessages?: number;
293505
+ maxChars?: number;
293506
+ };
293507
+ media?: {
293508
+ delayMs?: number;
293509
+ maxItems?: number;
293510
+ };
293511
+ };
293512
+ staleMessageWindowMs?: number;
293513
+ }
293514
+ interface PolicyConfig {
293515
+ groupAllowlist?: string[];
293516
+ dmMode?: 'open' | 'allowlist' | 'pair' | 'disabled';
293517
+ dmAllowlist?: string[];
293518
+ requireMention?: boolean;
293519
+ respondToMentionAll?: boolean;
293520
+ }
293521
+ interface OutboundConfig {
293522
+ textChunkLimit?: number;
293523
+ markdownConverter?: 'builtin' | ((md: string) => object);
293524
+ streamThrottleMs?: number;
293525
+ streamThrottleChars?: number;
293526
+ streamInitialText?: string;
293527
+ ssrfGuard?: boolean | {
293528
+ allowlist?: string[];
293529
+ };
293530
+ /**
293531
+ * Restrict local file paths accepted by media `source` to the listed
293532
+ * directories. When unset, only a POSIX blocklist (`/etc/`, `/proc/`,
293533
+ * `/sys/`, `/dev/`) is enforced as a safety net; when set, every path
293534
+ * must be inside one of these directories and symlink targets are
293535
+ * re-checked after `realpath` resolution.
293536
+ */
293537
+ allowedFileDirs?: string[];
293538
+ retry?: {
293539
+ maxAttempts?: number;
293540
+ baseDelayMs?: number;
293541
+ };
293542
+ }
293543
+ interface ChatInfo {
293544
+ chatId: string;
293545
+ name?: string;
293546
+ description?: string;
293547
+ chatType: 'p2p' | 'group';
293548
+ ownerId?: string;
293549
+ memberCount?: number;
293550
+ }
293551
+ type ResourceType = 'image' | 'file';
293552
+
293553
+ type Unsubscribe = () => void;
293554
+ declare class LarkChannel {
293555
+ readonly rawClient: Client;
293556
+ rawWsClient?: WSClient;
293557
+ botIdentity?: BotIdentity;
293558
+ private readonly opts;
293559
+ private readonly logger;
293560
+ private readonly dispatcher;
293561
+ private readonly handlers;
293562
+ private connectPromise?;
293563
+ private connected;
293564
+ private readonly sender;
293565
+ private readonly safety;
293566
+ constructor(opts: LarkChannelOptions);
293567
+ connect(): Promise<void>;
293568
+ private doConnect;
293569
+ /**
293570
+ * Construct the underlying WSClient and wait for its `onReady` callback —
293571
+ * so `connect()` only resolves after the first WebSocket handshake
293572
+ * actually succeeds. Rejects on `onError` or if the handshake doesn't
293573
+ * complete within `timeoutMs`.
293574
+ *
293575
+ * Also wires `onReconnecting` / `onReconnected` callbacks to emit the
293576
+ * corresponding public events.
293577
+ */
293578
+ private connectWebSocket;
293579
+ disconnect(): Promise<void>;
293580
+ on<K extends EventName>(name: K, handler: EventMap[K]): Unsubscribe;
293581
+ on(handlers: Partial<EventMap>): Unsubscribe;
293582
+ private attachSingle;
293583
+ send(to: string, input: SendInput, opts?: SendOptions): Promise<SendResult>;
293584
+ stream(to: string, input: StreamInput, opts?: SendOptions): Promise<SendResult>;
293585
+ updateCard(messageId: string, card: object): Promise<void>;
293586
+ /**
293587
+ * Edit an already-sent message's text/post content. Uses `im.v1.message.update`
293588
+ * which (per Feishu docs) only supports editing text and rich-text (post)
293589
+ * messages. For cards, use {@link updateCard} instead — a wrong attempt to
293590
+ * use this on a card would hit the same API and fail with a clearer
293591
+ * Feishu-side error.
293592
+ */
293593
+ editMessage(messageId: string, text: string): Promise<void>;
293594
+ recallMessage(messageId: string): Promise<void>;
293595
+ /**
293596
+ * Add an emoji reaction to a message. Returns the `reaction_id` Feishu
293597
+ * assigned — stash it if you want to {@link removeReaction} later,
293598
+ * since the raw `im.message.reaction.*_v1` events don't carry the id.
293599
+ * Only the bot's own reactions can be removed.
293600
+ */
293601
+ addReaction(messageId: string, emojiType: string): Promise<string>;
293602
+ /**
293603
+ * Remove a reaction by its `reaction_id` (the value returned from
293604
+ * {@link addReaction}). Only the bot's own reactions can be removed —
293605
+ * removing a user-added reaction will fail with a Feishu permission
293606
+ * error.
293607
+ */
293608
+ removeReaction(messageId: string, reactionId: string): Promise<void>;
293609
+ /**
293610
+ * Convenience: remove the bot's reaction on `messageId` matching
293611
+ * `emojiType`, without needing the `reaction_id`. Lists the message's
293612
+ * reactions filtered by emoji, picks the one added by this bot
293613
+ * (operator_type === 'app'), and deletes it. Returns `true` if a
293614
+ * matching reaction was found and deleted, `false` otherwise (including
293615
+ * the case where the bot never added that emoji).
293616
+ */
293617
+ removeReactionByEmoji(messageId: string, emojiType: string): Promise<boolean>;
293618
+ downloadResource(fileKey: string, type: ResourceType): Promise<Buffer>;
293619
+ getChatInfo(chatId: string): Promise<ChatInfo>;
293620
+ updatePolicy(partial: Partial<PolicyConfig>): void;
293621
+ getPolicy(): Readonly<PolicyConfig>;
293622
+ private fetchBotIdentity;
293623
+ private registerDispatcherHandlers;
293624
+ private emitError;
293625
+ }
293626
+ declare function createLarkChannel(opts: LarkChannelOptions): LarkChannel;
293627
+
293628
+ interface RawMessageEvent {
293629
+ sender: {
293630
+ sender_id: {
293631
+ open_id?: string;
293632
+ user_id?: string;
293633
+ union_id?: string;
293634
+ };
293635
+ sender_type?: string;
293636
+ tenant_key?: string;
293637
+ };
293638
+ message: {
293639
+ message_id: string;
293640
+ root_id?: string;
293641
+ parent_id?: string;
293642
+ create_time?: string;
293643
+ update_time?: string;
293644
+ chat_id: string;
293645
+ thread_id?: string;
293646
+ chat_type: 'p2p' | 'group';
293647
+ message_type: string;
293648
+ content: string;
293649
+ mentions?: RawMention[];
293650
+ };
293651
+ }
293652
+ interface RawMention {
293653
+ key: string;
293654
+ id: {
293655
+ open_id?: string;
293656
+ user_id?: string;
293657
+ union_id?: string;
293658
+ };
293659
+ name?: string;
293660
+ tenant_key?: string;
293661
+ }
293662
+ interface ApiMessageItem {
293663
+ message_id?: string;
293664
+ upper_message_id?: string;
293665
+ msg_type?: string;
293666
+ body?: {
293667
+ content?: string;
293668
+ };
293669
+ mentions?: RawMention[];
293670
+ sender?: {
293671
+ id?: string;
293672
+ id_type?: string;
293673
+ sender_type?: string;
293674
+ };
293675
+ create_time?: string | number;
293676
+ }
293677
+
293678
+ interface RawCardActionEvent {
293679
+ /**
293680
+ * Current shape (observed from `card.action.trigger` v2): message/chat ids
293681
+ * are nested under `context`. Top-level variants kept as fallback in case
293682
+ * older or alternate surfaces (webhook vs WS, older schema) still deliver
293683
+ * them at the root.
293684
+ */
293685
+ context?: {
293686
+ open_message_id?: string;
293687
+ open_chat_id?: string;
293688
+ };
293689
+ open_message_id?: string;
293690
+ open_chat_id?: string;
293691
+ token?: string;
293692
+ operator?: {
293693
+ open_id?: string;
293694
+ user_id?: string;
293695
+ union_id?: string;
293696
+ name?: string;
293697
+ };
293698
+ action?: {
293699
+ value?: unknown;
293700
+ tag?: string;
293701
+ name?: string;
293702
+ option?: string;
293703
+ timezone?: string;
293704
+ };
293705
+ }
293706
+ declare function normalizeCardAction(event: RawCardActionEvent): CardActionEvent | null;
293707
+
293708
+ interface RawReactionEvent {
293709
+ message_id?: string;
293710
+ reaction_type?: {
293711
+ emoji_type?: string;
293712
+ };
293713
+ operator_type?: string;
293714
+ user_id?: {
293715
+ open_id?: string;
293716
+ user_id?: string | null;
293717
+ union_id?: string;
293718
+ };
293719
+ action_time?: string;
293720
+ }
293721
+ declare function normalizeReaction(event: RawReactionEvent, action: 'added' | 'removed'): ReactionEvent | null;
293722
+
293723
+ interface RawBotAddedEvent {
293724
+ chat_id?: string;
293725
+ operator_id?: {
293726
+ open_id?: string;
293727
+ user_id?: string | null;
293728
+ union_id?: string;
293729
+ };
293730
+ external?: boolean;
293731
+ /** The bot's name (NOT the chat's name). */
293732
+ name?: string;
293733
+ /** The bot's localized names. */
293734
+ i18n_names?: {
293735
+ zh_cn?: string;
293736
+ en_us?: string;
293737
+ ja_jp?: string;
293738
+ };
293739
+ }
293740
+ declare function normalizeBotAdded(event: RawBotAddedEvent, opts?: {
293741
+ includeRaw?: boolean;
293742
+ }): BotAddedEvent | null;
293743
+
293744
+ interface RawCommentEvent {
293745
+ app_id?: string;
293746
+ file_token?: string;
293747
+ file_type?: string;
293748
+ comment_id?: string;
293749
+ reply_id?: string;
293750
+ /** Whether the bot was mentioned. Top-level in current payload. */
293751
+ is_mentioned?: boolean;
293752
+ /** Millisecond timestamp of the event. */
293753
+ create_time?: string;
293754
+ notice_meta?: {
293755
+ from_user_id?: {
293756
+ open_id?: string;
293757
+ user_id?: string | null;
293758
+ union_id?: string;
293759
+ };
293760
+ to_user_id?: {
293761
+ open_id?: string;
293762
+ user_id?: string | null;
293763
+ union_id?: string;
293764
+ };
293765
+ file_token?: string;
293766
+ file_type?: string;
293767
+ timestamp?: string;
293768
+ is_mentioned?: boolean;
293769
+ notice_type?: string;
293770
+ };
293771
+ is_mention?: boolean;
293772
+ user_id?: {
293773
+ open_id?: string;
293774
+ user_id?: string | null;
293775
+ union_id?: string;
293776
+ };
293777
+ action_time?: string;
293778
+ }
293779
+ declare function normalizeComment(event: RawCommentEvent, opts?: {
293780
+ includeRaw?: boolean;
293781
+ }): CommentEvent | null;
293782
+
293783
+ interface NormalizeOptions {
293784
+ botIdentity: BotIdentity;
293785
+ stripBotMentions?: boolean;
293786
+ includeRaw?: boolean;
293787
+ fetchSubMessages?: (messageId: string) => Promise<ApiMessageItem[]>;
293788
+ resolveUserName?: (openId: string) => string | undefined;
293789
+ resolveSenderName?: (openId: string) => string | undefined;
293790
+ batchResolveNames?: (openIds: string[]) => Promise<void>;
293791
+ }
293792
+ /**
293793
+ * Normalize a raw Feishu message event into a NormalizedMessage.
293794
+ *
293795
+ * Pipeline:
293796
+ * 1. Extract mentions → build key/openId maps + bot detection
293797
+ * 2. For `interactive` type, fetch full v2 card content if capability available
293798
+ * 3. Build ConvertContext with injected capabilities
293799
+ * 4. Dispatch to the matching converter (uniform error containment inside)
293800
+ * 5. Run resolveMentions second pass — replace placeholders with @name
293801
+ * 6. Assemble and return NormalizedMessage
293802
+ */
293803
+ declare function normalize(event: RawMessageEvent, opts: NormalizeOptions): Promise<NormalizedMessage>;
293804
+
293805
+ export { AESCipher, Aily, ApiMessageItem, AppType, BotAddedEvent, BotIdentity, CAppTicket, CTenantAccessToken, Cache, CardActionEvent, CardActionHandler, CardStreamController, CardStreamProducer, ChatInfo, ChatType, Client, CommentEvent, Domain, EventDispatcher, IHandles as EventHandles, EventMap, EventName, HttpInstance, HttpRequestOptions, InteractiveCard, InteractiveCardActionEvent, InteractiveCardActionItem, InteractiveCardButtonActionItem, InteractiveCardDatePickerActionItem, InteractiveCardDivElement, InteractiveCardDividerElement, InteractiveCardElement, InteractiveCardField, InteractiveCardImageElement, InteractiveCardImageItem, InteractiveCardLarkMdItem, InteractiveCardMarkdownElement, InteractiveCardNoteElement, InteractiveCardOverflowActionItem, InteractiveCardPlainTextItem, InteractiveCardSelectMenuActionItem, InteractiveCardTextItem, InteractiveCardTitle, InteractiveCardUrlItem, InterfaceCardActionElement, LarkChannel, LarkChannelError, LarkChannelErrorCode, LarkChannelOptions, LoggerLevel, MarkdownStreamController, MarkdownStreamProducer, MediaSource, MentionInfo, NormalizeOptions, NormalizedMessage, OutboundConfig, PolicyConfig, RawBotAddedEvent, RawCardActionEvent, RawCommentEvent, RawMessageEvent, RawReactionEvent, ReactionEvent, RejectEvent, RejectReason, ResourceDescriptor, ResourceType, SafetyConfig, SendInput, SendOptions, SendResult, StreamInput, WSClient, WebhookOptions, adaptDefault, adaptExpress, adaptKoa, adaptKoaRouter, createLarkChannel, defaultHttpInstance, generateChallenge, messageCard, normalize, normalizeBotAdded, normalizeCardAction, normalizeComment, normalizeReaction, registerApp, withAll, withHelpDeskCredential, withTenantKey, withTenantToken, withUserAccessToken };