export interface ChatBrief { chatId: string; name?: string; description?: string; chatMode?: string; ownerId?: string; /** 群头像 URL(/open-apis/im/v1/chats 的 avatar 字段)。 */ avatar?: string; } /** * List chats the given bot is a member of, draining pagination internally. * Uses /open-apis/im/v1/chats. */ export declare function listChats(larkAppId: string): Promise; /** * Check whether the given bot is a member of the given chat. * Uses /open-apis/im/v1/chats/:chat_id/members/is_in_chat — the bot's own * access token implicitly identifies the bot being checked. * * Errors (chat not found, no permission, etc.) are swallowed and treated as * "not in chat" so callers can use this as a simple boolean predicate. */ export declare function isInChat(larkAppId: string, chatId: string): Promise; export type RenameChatResult = { ok: true; oldName: string; newName: string; changed: boolean; } | { ok: false; error: 'bot_not_in_chat' | 'permission_denied' | 'lark_api_error' | 'rate_limited'; detail?: string; oldName?: string; newName?: string; larkCode?: number; retryAfterSeconds?: number; }; /** * Rename one chat using exactly the supplied bot identity. * * Deliberately does not try another configured bot on failure: callers use * this for session-scoped AI actions, where credential fallback would violate * the "the acting bot must itself be in the chat" boundary. */ export declare function renameChat(larkAppId: string, chatId: string, newName: string, opts?: { beforeUpdate?: () => { ok: true; } | { ok: false; error: 'rate_limited'; retryAfterSeconds: number; }; }): Promise; /** * Create a brand-new chat with `bot_id_list` as initial bot members. The * `creatorLarkAppId` bot becomes the chat's owner and an implicit member; the * other bots in `botIds` are added in the same call. Used by the dashboard's * "Create new group" flow. * * Returns the new chatId on success. Throws on any non-zero Lark response so * the route can surface a real error. We deliberately don't soften failures * here (unlike `isInChat`) because the caller wants to know whether the chat * actually got created. */ export declare function createChat(creatorLarkAppId: string, opts: { name?: string; botIds: string[]; userIds?: string[]; }): Promise<{ chatId: string; invalidBotIds: string[]; invalidUserIds: string[]; }>; /** * Transfer ownership of a chat from the calling bot to a Feishu user. Used * after `createChat` so the dashboard operator (who's been invited as a * member) ends up as the actual owner — otherwise the bot stays group owner * and the user can't manage the chat. * * Calls /open-apis/im/v1/chats/:chat_id with `owner_id` in the body and * `user_id_type=open_id`. The caller's bot must currently be the owner; this * is the case right after createChat since the creator bot is the implicit * owner. * * Defaults to open_id for existing callers. Deferred federation completion can * pass union_id after another deployment has added the user, avoiding any * cross-app open_id handoff. */ export declare function transferChatOwner(ownerLarkAppId: string, chatId: string, newOwnerId: string, userIdType?: 'open_id' | 'union_id'): Promise<{ ok: true; } | { ok: false; error: string; }>; /** * Disband a chat the calling bot OWNS. Used by the session-group birth flow * to clean up an orphan group when the initiating user's invite was rejected * — the group can never serve as a conversation home, so leaving it behind * would strand an empty bot-owned chat in the tenant (PR review). * * Calls DELETE /open-apis/im/v1/chats/:chat_id (owner-only). */ export declare function deleteChat(larkAppId: string, chatId: string): Promise<{ ok: true; } | { ok: false; error: string; }>; /** * Fetch the current owner of a chat (open_id by default, optionally union_id). * Used by group-creator to * verify the post-transfer state when transferChatOwner returns an error — * Lark sometimes ACKs a transfer slowly (e.g. 504 Gateway Timeout) even though * the server-side write succeeded, so a follow-up read disambiguates "really * failed" from "ACK lost". * * Returns undefined when the API itself errors or doesn't include owner_id; * callers treat undefined as "unknown" and keep the original error. */ export declare function getChatOwner(larkAppId: string, chatId: string, userIdType?: 'open_id' | 'union_id'): Promise; /** * Get a shareable join link for a chat — the link others can click to *join* * the group, unlike the applink:// "open chat" URL which only works for members * who are already in the chat. * * Calls POST /open-apis/im/v1/chats/:chat_id/link. Accepted scope is any of * im:chat / im:chat:read / im:chat:readonly (the bot already holds im:chat:read, * verified at startup). `validity_period` is week | year | permanently. * * Not supported for p2p / secret / team chats — those return a non-zero code, * which we surface as an error so the caller can fall back to the applink. */ export declare function getChatShareLink(larkAppId: string, chatId: string, validityPeriod?: 'week' | 'year' | 'permanently'): Promise<{ ok: true; shareLink: string; } | { ok: false; error: string; }>; /** * Disband (delete) a chat. The Lark API only succeeds when the calling bot is * the chat's current owner, OR is the creator AND the app holds * `im:chat:operate_as_owner`. Routes that fan-out to multiple bots can use * this best-effort: try each in-chat bot until one succeeds. */ export declare function disbandChat(larkAppId: string, chatId: string): Promise<{ ok: true; } | { ok: false; error: string; }>; /** * Make the calling bot leave a chat. Per Lark docs, self-removal succeeds * regardless of role (owner/manager/member). Useful when the bot can't disband * (not owner, no operate_as_owner scope) but still wants to detach. */ export declare function leaveChat(larkAppId: string, chatId: string): Promise<{ ok: true; } | { ok: false; error: string; }>; /** * Add bot apps to a chat using a "proxy" bot that's already a member. * Uses /open-apis/im/v1/chats/:chat_id/members with member_id_type=app_id. * Returns per-id result derived from the API's invalid_id_list. * * On total failure (network error, non-zero code) every id reports the same * error so the caller can present a uniform per-id status. */ export declare function addBotToChat(proxyLarkAppId: string, chatId: string, targetLarkAppIds: string[]): Promise<{ id: string; ok: boolean; error?: string; }[]>; /** * Add USERS to an existing chat by **union_id** (tenant-stable, NOT app-scoped * like open_id). Used to pull bot owners into a federated group regardless of * which bot they paired through. Returns the union_ids Lark could not add. * Best-effort: total failure reports all ids invalid. * * Uses /open-apis/im/v1/chats/:chat_id/members with member_id_type=union_id. */ export declare function addUsersToChatByUnionId(proxyLarkAppId: string, chatId: string, unionIds: string[]): Promise<{ invalidUserIds: string[]; }>; /** * 「进群自动拉 owner」:本 bot 被加进群(im.chat.member.bot.added_v1)时,把 * 自己的 owner 拉进群——bot 应始终处于 owner 可见的群里(不打黑工;与 * federated-group 的 owner-in-group 策略同源,这里是单点兜底,使任意来源的 * 拉群动作(/invite、手动添加、平台批量添加)都收敛到同一行为)。 * * 与 handleBotAdded 的 autoStart 流程完全解耦:不受 autoStartOnGroupJoin 开关 * 影响、不 spawn 会话、失败只记日志不打扰群(飞书自身会展示「xx 邀请 xx 入群」 * 系统消息,无需我们再发一条)。 * * 用 open_id + 自身 app scope 即可(owner 是本 bot 配置里的用户,open_id 天然 * 在本 app 域内;chatMembers.create 由本 bot 自己发起,已在群/无权限等一律容错)。 */ export type OwnerGroupJoinResult = 'added' | 'already' | 'skipped' | 'failed'; export declare function autoInviteOwnerOnGroupJoin(larkAppId: string, chatId: string, operatorOpenId?: string): Promise; export interface ChatMemberDisplay { openId: string; name: string; memberType: 'user' | 'bot' | 'unknown'; } export declare function listChatMemberDisplays(larkAppId: string, chatId: string): Promise; //# sourceMappingURL=groups-store.d.ts.map