k2-im 0.1.30 → 0.1.31

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/browser.js CHANGED
@@ -1 +1 @@
1
- export{B as createLazyBrowserApiProtocolClient}from'./chunk-GHZUH7RB.js';import'./chunk-4KPJTXQN.js';import'./chunk-WOT6VMZA.js';
1
+ export{B as createLazyBrowserApiProtocolClient}from'./chunk-SMWPQSGR.js';import'./chunk-CIY4WBFJ.js';import'./chunk-WOT6VMZA.js';
@@ -4,8 +4,8 @@ import { Pinia, Store } from 'pinia';
4
4
  /** 媒体业务类型:实现据此选对象存储逻辑桶;sticker 对应 app-sticker。 */
5
5
  type MediaKind = 'image' | 'video' | 'voice' | 'file' | 'sticker';
6
6
 
7
- /** 会话类型。P0 只用 direct / group。 */
8
- type ConversationType = 'direct' | 'group' | 'channel' | 'supergroup';
7
+ /** 会话类型。P0 只用 direct / group;`robot` 是独立私聊 sibling,不得并入 direct。 */
8
+ type ConversationType = 'direct' | 'group' | 'channel' | 'supergroup' | 'robot';
9
9
  /**
10
10
  * 会话复合身份;`conversationId` 只在对应 `conversationType` 的领域内唯一。
11
11
  *
@@ -42,8 +42,8 @@ interface ConversationDraft$1 {
42
42
  attachments: readonly [];
43
43
  updatedAt: number;
44
44
  }
45
- /** 消息内容类型。sticker=表情/贴图(BMessage contentType=7);call=单聊通话记录(contentType=10);transfer=转账(contentType=16);robot=机器人卡片(contentType=18);miniProgram=小程序分享卡(contentType=22);redPacket=红包卡(contentType=25);game=小游戏(contentType=27);未知 wire 正文统一归一为 unknown。 */
46
- type MessageContentType = 'text' | 'system' | 'image' | 'video' | 'voice' | 'file' | 'sticker' | 'contact' | 'miniProgram' | 'game' | 'transfer' | 'call' | 'redPacket' | 'mediaAlbum' | 'robot' | 'unknown';
45
+ /** 消息内容类型。sticker=表情/贴图(BMessage contentType=7);call=单聊通话记录(contentType=10);transfer=转账(contentType=16);gift=礼品/刮刮卡(contentType=17);robot=机器人卡片(contentType=18);miniProgram=小程序分享卡(contentType=22);redPacket=红包卡(contentType=25);game=小游戏(contentType=27);未知 wire 正文统一归一为 unknown。 */
46
+ type MessageContentType = 'text' | 'system' | 'image' | 'video' | 'voice' | 'file' | 'sticker' | 'contact' | 'miniProgram' | 'game' | 'transfer' | 'gift' | 'call' | 'redPacket' | 'mediaAlbum' | 'robot' | 'unknown';
47
47
  /**
48
48
  * 发送态(客户端态):消息从本地创建到服务端确认的生命周期。
49
49
  * `uploading` 仅媒体消息使用:文件上传阶段(uploading→pending→sending→sent);
@@ -112,6 +112,8 @@ type LastMessageSummary = {
112
112
  gameType: ImGameType;
113
113
  } | {
114
114
  kind: 'transfer';
115
+ } | {
116
+ kind: 'gift';
115
117
  } | {
116
118
  kind: 'call';
117
119
  callKind: ImCallKind;
@@ -311,13 +313,14 @@ type ImGameBody = {
311
313
  * - `default`:0,普通可点卡片
312
314
  * - `board-game`:1,棋牌样式且不可点
313
315
  * - `board-game-link`:2,棋牌样式且可点
316
+ * - `game-preview`:3,气泡内嵌游戏预览 WebView
314
317
  * - `unknown`:必须同时保留 `rawShowType`,不得猜成可点/不可点
315
318
  */
316
- type ImMiniProgramShowType = 'default' | 'board-game' | 'board-game-link' | 'unknown';
319
+ type ImMiniProgramShowType = 'default' | 'board-game' | 'board-game-link' | 'game-preview' | 'unknown';
317
320
  /**
318
321
  * 小程序分享卡片正文(contentType==='miniProgram',协议 BMessage.contentType=22)。
319
322
  *
320
- * @remarks 字段来自 iOS `IMMiniProgramMessageBody` / proto 61-67、80-82、90-93。
323
+ * @remarks 字段来自 iOS `IMMiniProgramMessageBody` / proto 61-67、80-82、90-96。
321
324
  * `currencySource` 对应 proto field 90(无 miniProgram 前缀):`xj` 现金公司、`xy` 信用公司。
322
325
  * `subGameName` 保持服务端 JSON 字符串,不在 Core 解析语种表。打开小程序与 X 币/信用 ID 属于宿主,不进本 DTO。
323
326
  */
@@ -341,6 +344,12 @@ interface ImMiniProgramBody {
341
344
  gamePath?: string;
342
345
  /** 多语言子游戏名 JSON 字符串,例如 `{"ch":"...","en":"..."}`。 */
343
346
  subGameName?: string;
347
+ /** 游戏预览页地址(BMessage.miniProgramGamePreviewUrl,showType=3)。 */
348
+ gamePreviewUrl?: string;
349
+ /** 游戏预览设计宽(BMessage.miniProgramGamePreviewWidth)。 */
350
+ gamePreviewWidth?: number;
351
+ /** 游戏预览设计高(BMessage.miniProgramGamePreviewHeight)。 */
352
+ gamePreviewHeight?: number;
344
353
  }
345
354
  /**
346
355
  * 机器人卡片文本模块(wire `section`)。
@@ -419,6 +428,40 @@ interface ImTransferBody {
419
428
  coinName?: string;
420
429
  coinIcon?: string;
421
430
  }
431
+ /** 礼品类型。协议注释为刮刮卡 1 / 奖品 2;Android 当前会把 WelfareGiftType=0 写进消息,入站必须接受 0。 */
432
+ type ImGiftType = 0 | 1 | 2;
433
+ /** 礼品状态。0 待领取 / 1 已收款 / 2 已退还 / 3 已过期(对齐 iOS IMGiftMessageBody)。 */
434
+ type ImGiftStatus = 0 | 1 | 2 | 3;
435
+ /** 礼品会话类型。1 个人 / 2 群(BMessage.sessionType)。 */
436
+ type ImGiftSessionType = 1 | 2;
437
+ /**
438
+ * 礼品卡片正文(contentType==='gift',协议 BMessage.contentType=17)。
439
+ *
440
+ * @remarks 字段来自 iOS `IMGiftMessageBody` / proto 51-59,并复用转账字段族的 fromUid/toUid/serialNumber。
441
+ * 赠卡 HTTP 属于宿主;本 DTO 只承载会话卡片。H5 出站刮刮卡写 giftType=1。
442
+ */
443
+ interface ImGiftBody {
444
+ fromUid: string;
445
+ toUid: string;
446
+ fromUserName?: string;
447
+ toUserName?: string;
448
+ giftType: ImGiftType;
449
+ giftName: string;
450
+ giftIcon?: string;
451
+ explain?: string;
452
+ state: ImGiftStatus;
453
+ serialNumber: string;
454
+ sessionType: ImGiftSessionType;
455
+ initiateTime: number;
456
+ /** 单张金额的十进制字符串;0 或缺省表示未带金额。 */
457
+ amount?: string;
458
+ receiveTime?: number;
459
+ returnTime?: number;
460
+ isRead?: boolean;
461
+ zhangCount?: string;
462
+ benCount?: string;
463
+ fissionNumber?: string;
464
+ }
422
465
  /** 领域通话媒体类型;已从各端 wire 0/1 对调口径归一,宿主禁止再读 raw callType。 */
423
466
  type ImCallKind = 'audio' | 'video';
424
467
  /**
@@ -577,6 +620,8 @@ interface ImMessageBody {
577
620
  game?: ImGameBody;
578
621
  /** contentType==='transfer' 时的转账卡片。 */
579
622
  transfer?: ImTransferBody;
623
+ /** contentType==='gift' 时的礼品/刮刮卡卡片。 */
624
+ gift?: ImGiftBody;
580
625
  /** contentType==='call' 时的单聊通话记录。 */
581
626
  call?: ImCallRecordBody;
582
627
  /** contentType==='redPacket' 时的红包卡片。 */
@@ -965,7 +1010,7 @@ interface OutboxMessage {
965
1010
  resumePolicy?: 'automatic' | 'manual';
966
1011
  }
967
1012
  /** 当前 SDK 已注册发送策略、因此可作为转发目标的会话类型;supergroup 未注册,继续在编译期排除。 */
968
- type ForwardTargetConversationType = Extract<ConversationType, 'direct' | 'group' | 'channel'>;
1013
+ type ForwardTargetConversationType = Extract<ConversationType, 'direct' | 'group' | 'channel' | 'robot'>;
969
1014
  /** 转发目标会话;运行时仍由 SendStrategyRegistry 复核,避免类型声明与实际装配漂移。 */
970
1015
  interface ForwardTarget {
971
1016
  conversationId: string;
@@ -1857,8 +1902,11 @@ interface ImSessionFavoritePort {
1857
1902
  * 消息、Reaction 与分页边界必须整页原子保存,只有前台实际消费时才进入正常消息流程。
1858
1903
  */
1859
1904
  interface ImRecentHistoryPage {
1860
- /** 缓存记录格式版本;不认识的版本不能当作有效页使用。 */
1861
- version: 1;
1905
+ /**
1906
+ * 缓存记录格式版本;不认识的版本不能当作有效页使用。
1907
+ * v2:小程序 showType=3 / proto 94-96 进入领域正文,旧页必须重新拉网解析。
1908
+ */
1909
+ version: 2;
1862
1910
  /** 当前账号内的精确 GROUP/CHANNEL 会话;direct 没有此远端最近页能力。 */
1863
1911
  conversation: ConversationRef<'group' | 'channel'>;
1864
1912
  /** 成功获取页面的毫秒时间,用于保留期限和按获取时间淘汰。 */
@@ -3069,6 +3117,10 @@ interface MiniProgramMessageOptions {
3069
3117
  interface TransferMessageOptions {
3070
3118
  replyToMessageId?: string;
3071
3119
  }
3120
+ /** 礼品卡片发送选项;正文必须已含福利中心赠送后的流水号与卡面。 */
3121
+ interface GiftMessageOptions {
3122
+ replyToMessageId?: string;
3123
+ }
3072
3124
  /**
3073
3125
  * 媒体合集里的一项:一张图片或一个视频。
3074
3126
  *
@@ -3489,7 +3541,7 @@ interface ConversationPrefetchOptions {
3489
3541
  * skipped 表示当前类型、权限、存储或预算不允许预取;失败不改变正常打开会话的行为。
3490
3542
  */
3491
3543
  interface ConversationPrefetchResult {
3492
- ref: ConversationRef<'direct' | 'group' | 'channel'>;
3544
+ ref: ConversationRef<'direct' | 'group' | 'channel' | 'robot'>;
3493
3545
  status: 'ready' | 'skipped' | 'failed' | 'cancelled';
3494
3546
  reason?: 'unsupported' | 'unavailable' | 'storage-unavailable' | 'budget' | 'page-too-large' | 'decrypt-failed' | 'invalidated' | 'cancelled';
3495
3547
  error?: ImSdkErrorShape;
@@ -3532,7 +3584,7 @@ interface ConversationDraftApi {
3532
3584
  subscribe: (listener: (draft: ConversationDraft | null) => void) => () => void;
3533
3585
  }
3534
3586
  /**
3535
- * 当前账号的跨组件草稿 API;所有动作都要求 direct/GROUP/CHANNEL 精确复合身份。
3587
+ * 当前账号的跨组件草稿 API;所有动作都要求 direct / GROUP / CHANNEL / robot 精确复合身份。
3536
3588
  *
3537
3589
  * @example
3538
3590
  * ```ts
@@ -3556,11 +3608,11 @@ interface ImDraftsApi {
3556
3608
 
3557
3609
  /**
3558
3610
  * SDK 会话列表内部 sibling 路由与会话级写动作。
3559
- * 置顶、免打扰、已读和本地删除都要求精确 `ConversationRef`,并按 direct/GROUP/CHANNEL 独立协议分流。
3611
+ * 置顶、免打扰、已读和本地删除都要求精确 `ConversationRef`,并按 direct/GROUP/CHANNEL/robot 独立协议分流。
3560
3612
  */
3561
3613
 
3562
3614
  /** 当前兼容门面支持的精确会话 ref。 */
3563
- type ImSupportedConversationRef = ConversationRef<'direct' | 'group' | 'channel'>;
3615
+ type ImSupportedConversationRef = ConversationRef<'direct' | 'group' | 'channel' | 'robot'>;
3564
3616
  /**
3565
3617
  * 会话 API 的迁移期入参。优先传完整 ref;旧 string 仅在当前 session 中唯一命中时可用。
3566
3618
  *
@@ -3959,7 +4011,7 @@ interface ImDirectCallsApi {
3959
4011
  * Blob 只经 storage 持久化。异步读取使用运行时代际防止切会话/切账号晚返回,宿主负责最终渲染与 URL 释放。
3960
4012
  */
3961
4013
 
3962
- type ConversationBackgroundConversationType = 'direct' | 'group' | 'channel';
4014
+ type ConversationBackgroundConversationType = 'direct' | 'group' | 'channel' | 'robot';
3963
4015
  interface ConversationBackgroundPreset {
3964
4016
  id: string;
3965
4017
  url: string;
@@ -4119,7 +4171,7 @@ interface ImChannelProfile {
4119
4171
  */
4120
4172
 
4121
4173
  /** default 会话列表支持的精确类型;`supergroup` 继续受产品 Gate 约束。 */
4122
- type ProductConversationListType = 'direct' | 'group' | 'channel';
4174
+ type ProductConversationListType = 'direct' | 'group' | 'channel' | 'robot';
4123
4175
  /** GROUP 会话限制状态;与 CHANNEL 状态保持独立 sibling。 */
4124
4176
  type ImGroupConversationState = GroupSessionState;
4125
4177
  /**
@@ -4178,6 +4230,8 @@ type ConversationLastMessageSummary = {
4178
4230
  kind: 'robot';
4179
4231
  } | {
4180
4232
  kind: 'transfer';
4233
+ } | {
4234
+ kind: 'gift';
4181
4235
  } | {
4182
4236
  kind: 'redPacket';
4183
4237
  } | {
@@ -4333,6 +4387,12 @@ interface DirectConversationCapabilities {
4333
4387
  canUseMessageActions: CapabilityDecision;
4334
4388
  canManageRelationship: CapabilityDecision;
4335
4389
  }
4390
+ interface RobotConversationCapabilities {
4391
+ canSendMessages: CapabilityDecision;
4392
+ canOpenProfile: CapabilityDecision;
4393
+ canUseMessageActions: CapabilityDecision;
4394
+ canReadHistory: CapabilityDecision;
4395
+ }
4336
4396
  /**
4337
4397
  * 普通群能力快照。
4338
4398
  *
@@ -4399,6 +4459,8 @@ type ConversationCapabilitySnapshot = (ConversationCapabilityBase<'direct'> & {
4399
4459
  value: GroupConversationCapabilities;
4400
4460
  }) | (ConversationCapabilityBase<'channel'> & {
4401
4461
  value: ChannelConversationCapabilities;
4462
+ }) | (ConversationCapabilityBase<'robot'> & {
4463
+ value: RobotConversationCapabilities;
4402
4464
  });
4403
4465
  interface ImConversationCapabilitiesApi {
4404
4466
  /** 只读取 SDK 当前本机真相与已刷新过的资料/关系投影,不隐式联网。 */
@@ -4565,7 +4627,7 @@ interface ImMessagesByIdResult<TMessage> {
4565
4627
  */
4566
4628
 
4567
4629
  /** 当前已接线的产品 handle 会话类型;三者只在无会话语义原子层复用。 */
4568
- type ProductHandleConversationType = 'direct' | 'group' | 'channel';
4630
+ type ProductHandleConversationType = 'direct' | 'group' | 'channel' | 'robot';
4569
4631
  /**
4570
4632
  * 会话 handle 初始打开位置。
4571
4633
  *
@@ -4700,6 +4762,12 @@ interface ConversationMessageApi {
4700
4762
  * @remarks CHANNEL 当前产品入口不发送转账,会返回 unsupported。消息固定明文。
4701
4763
  */
4702
4764
  sendTransfer: (transfer: ImTransferBody, options?: TransferMessageOptions) => Promise<SendMessageResult>;
4765
+ /**
4766
+ * 发送礼品卡片。调用方必须先完成福利中心 HTTP 赠送。
4767
+ *
4768
+ * @remarks CHANNEL 当前产品入口不发送礼物,会返回 unsupported。消息固定明文。
4769
+ */
4770
+ sendGift: (gift: ImGiftBody, options?: GiftMessageOptions) => Promise<SendMessageResult>;
4703
4771
  /** 当前用户已选相同 emoji 时移除,否则添加或替换。emoji 必须是协议 token,例如 `[Great]`。 */
4704
4772
  toggleReaction: (messageId: string, emoji: string) => Promise<ImReactionChangeResult>;
4705
4773
  /** 显式添加/替换或移除,供参与者详情等不能用 toggle 猜动作的产品交互。 */
@@ -5539,6 +5607,57 @@ interface ImRequestError {
5539
5607
  */
5540
5608
  type ImRequestErrorHandler = (issue: ImRequestError) => void | Promise<void>;
5541
5609
 
5610
+ /**
5611
+ * 机器人目录产品分页运行时。
5612
+ * 服务端页码封装为绑定账号 runtime 与查询条件的 opaque token;伪造、跨筛选或已消费 token 显式失败。
5613
+ */
5614
+
5615
+ /**
5616
+ * 机器人目录查询范围。
5617
+ *
5618
+ * `catalog` 对齐通讯录「查找机器人」;`conversation` 对齐群/社群资料添加与输入栏已绑定列表。
5619
+ */
5620
+ type ImRobotDirectoryScope = {
5621
+ kind: 'catalog';
5622
+ } | {
5623
+ kind: 'conversation';
5624
+ conversationType: 'group' | 'channel';
5625
+ conversationId: string;
5626
+ /** `bound` 对齐 iOS 输入栏 `search_type=1`。 */
5627
+ filter?: 'bound';
5628
+ };
5629
+ /** 机器人目录项;只保留打开私聊和列表展示所需字段。 */
5630
+ interface ImRobotDirectoryItem {
5631
+ id: string;
5632
+ displayName: string;
5633
+ username?: string;
5634
+ avatarUrl?: string;
5635
+ bound?: boolean;
5636
+ }
5637
+ /** 把机器人绑定或解绑到普通群/社群。 */
5638
+ interface ImRobotConversationBindInput {
5639
+ robotId: string;
5640
+ conversationType: 'group' | 'channel';
5641
+ conversationId: string;
5642
+ }
5643
+ /** 机器人目录页;服务端页码由 SDK token 封装,UI 只能原样续页。 */
5644
+ interface ImRobotDirectoryPage {
5645
+ items: readonly ImRobotDirectoryItem[];
5646
+ nextPageToken?: ImPageToken;
5647
+ exhausted: boolean;
5648
+ }
5649
+ /** 机器人目录产品分页面。 */
5650
+ interface ImRobotsApi {
5651
+ listFirstPage: (options?: {
5652
+ scope?: ImRobotDirectoryScope;
5653
+ keyword?: string;
5654
+ pageSize?: number;
5655
+ }) => Promise<ImRobotDirectoryPage>;
5656
+ listNextPage: (pageToken: ImPageToken) => Promise<ImRobotDirectoryPage>;
5657
+ bindToConversation: (input: ImRobotConversationBindInput) => Promise<void>;
5658
+ unbindFromConversation: (input: ImRobotConversationBindInput) => Promise<void>;
5659
+ }
5660
+
5542
5661
  /**
5543
5662
  * 当前账号本地会话与消息的分场景产品搜索运行时。
5544
5663
  *
@@ -5601,6 +5720,8 @@ interface ImMessageSearchApi {
5601
5720
  inGroup: (conversation: ConversationRef<'group'>, keyword: string) => Promise<ProductMessageSearchPage<MessageContentType>>;
5602
5721
  /** 搜索 CHANNEL 本地历史;当前不调用未闭合的远端 CHANNEL 搜索/定位协议。 */
5603
5722
  inChannel: (conversation: ConversationRef<'channel'>, keyword: string) => Promise<ProductMessageSearchPage<MessageContentType>>;
5723
+ /** 搜索 robot 本地历史;无远端历史,不得回退 direct。 */
5724
+ inRobot: (conversation: ConversationRef<'robot'>, keyword: string) => Promise<ProductMessageSearchPage<MessageContentType>>;
5604
5725
  /** 只搜索文本消息;关键词必填且不能为空。 */
5605
5726
  texts: (conversation: ConversationRef<ProductHandleConversationType>, keyword: string) => Promise<ProductMessageSearchPage<'text'>>;
5606
5727
  /** 只搜索文件消息;省略或传空白关键词时按文件分类浏览。 */
@@ -6130,7 +6251,7 @@ interface AdvancedConversationsApi extends ImConversationsApi, ImConversationBac
6130
6251
  *
6131
6252
  * @internal
6132
6253
  */
6133
- ensureOpenableConversation: (ref: ConversationRef) => Promise<ConversationRef<'direct' | 'group' | 'channel'>>;
6254
+ ensureOpenableConversation: (ref: ConversationRef) => Promise<ConversationRef<'direct' | 'group' | 'channel' | 'robot'>>;
6134
6255
  }
6135
6256
  /**
6136
6257
  * 普通宿主的真实 default client。
@@ -6154,6 +6275,8 @@ interface ImProductClient {
6154
6275
  readonly conversations: ImConversationListApi;
6155
6276
  /** 当前账号完整联系人、群组和社群目录的统一搜索。 */
6156
6277
  readonly directory: ImDirectorySearchApi;
6278
+ /** 机器人公开目录;通讯录查找与群/社群绑定列表共用分页合同。 */
6279
+ readonly robots: ImRobotsApi;
6157
6280
  readonly contacts: ImContactsApi;
6158
6281
  readonly groups: ImGroupsApi;
6159
6282
  readonly channels: ImChannelsApi;
@@ -6203,6 +6326,7 @@ interface ImClient extends Omit<ImProductClient, 'capabilities' | 'channels' | '
6203
6326
  (ref: ConversationRef<'direct'>, options?: ConversationOpenOptions): Promise<ConversationHandle<'direct'>>;
6204
6327
  (ref: ConversationRef<'group'>, options?: ConversationOpenOptions): Promise<ConversationHandle<'group'>>;
6205
6328
  (ref: ConversationRef<'channel'>, options?: ConversationOpenOptions): Promise<ConversationHandle<'channel'>>;
6329
+ (ref: ConversationRef<'robot'>, options?: ConversationOpenOptions): Promise<ConversationHandle<'robot'>>;
6206
6330
  };
6207
6331
  /** 当前账号草稿产品面;按复合身份持久化,handle.draft 委托同一状态源。 */
6208
6332
  drafts: ImDraftsApi;
@@ -6716,7 +6840,7 @@ interface ChatRuntime {
6716
6840
  /** 撤销当前账号创建的全部媒体预览地址并释放 Blob 内存,切账号、退出或销毁时调用。 */
6717
6841
  cleanupLocalMediaBlobs: () => void;
6718
6842
  /** 删除会话时释放该会话绑定的本地媒体预览/播放缓存。 */
6719
- cleanupConversationMediaBlobs: (conversation: ConversationRef<'direct' | 'group' | 'channel'>) => void;
6843
+ cleanupConversationMediaBlobs: (conversation: ConversationRef<'direct' | 'group' | 'channel' | 'robot'>) => void;
6720
6844
  }
6721
6845
 
6722
6846
  /** 当前置顶消息的稳定资料;普通群和社群各自保留明确会话身份。 */