/** * Groups action helpers — single source of truth for the * `/api/groups/:chatId/*` action routes that used to live inline in * `dashboard.ts`. * * Each helper returns a `HandlerResult { status, body }` so the dashboard route * and the HMAC-gated `/__daemon/groups/...` route render the same * response. Behaviour is byte-equivalent to the original inline implementation; * all IO flows through `deps`. */ export interface DaemonHandle { larkAppId: string; ipcPort: number; botName?: string; } /** Minimum session shape required by the cascade-close predicate. */ export interface SessionLikeForClose { chatId: string; larkAppId: string; } export interface GroupsActionDeps { /** Iterate currently-online daemons, sorted however the dashboard wants. */ registryList: () => Iterable; /** Look up one daemon by larkAppId; returns undefined if offline / unknown. */ registryGetByAppId: (appId: string) => DaemonHandle | undefined; /** Proxy a request to the named daemon. Mirrors `dashboard.ts:proxyToDaemon`. */ proxyToDaemon: (larkAppId: string, daemonPath: string, init: RequestInit) => Promise; /** Close sessions matching a predicate. Returns an opaque list (we just pass it through). */ closeSessionsMatching: (predicate: (s: SessionLikeForClose) => boolean) => Promise; /** Override for tests; defaults to global fetch in production. */ fetch?: typeof fetch; /** Drop the central read snapshot after a successful membership/config mutation. */ invalidateGroups?: () => void; } export interface HandlerResult { status: number; body: unknown; /** Optional response headers — currently unused (all responses are JSON). */ headers?: Record; } /** * POST /api/groups/:chatId/add-bots — find any daemon already in chat, proxy * the body verbatim. The first inChat daemon wins (deterministic by * registry-list ordering). Response is the upstream raw body. */ export declare function addBotsToGroup(chatId: string, bodyRaw: string, deps: GroupsActionDeps): Promise; /** * POST /api/groups/:chatId/disband — proxy to the named bot's daemon. On * success, cascade-close every session in this chat (cross-bot). Response * shape: `{ ...upstreamJson, closedSessions }`. */ export declare function disbandGroup(chatId: string, bodyParsed: unknown, deps: GroupsActionDeps): Promise; /** * POST /api/groups/:chatId/leave — selected bots leave the chat in parallel. * Each is membership-checked first so a stale UI cache shows `not_in_chat` * rather than a generic Lark error. On per-bot success, that bot's sessions * in the chat are cascade-closed. Response shape: `{ result: PerBotResult[] }`. */ export declare function leaveGroup(chatId: string, bodyParsed: unknown, deps: GroupsActionDeps): Promise; /** * PUT /api/groups/:chatId/oncall/:appId — bind / update the per-(chat × bot) * oncall workingDir. Internal proxy path is `/api/oncall/:chatId` PUT on the * named bot's daemon. Body (workingDir JSON) is forwarded verbatim. */ export declare function bindOncall(chatId: string, appId: string, bodyRaw: string, deps: GroupsActionDeps): Promise; /** * DELETE /api/groups/:chatId/oncall/:appId — unbind the per-(chat × bot) * oncall. Internal proxy path is `/api/oncall/:chatId` DELETE. */ export declare function unbindOncall(chatId: string, appId: string, deps: GroupsActionDeps): Promise; //# sourceMappingURL=groups-action-helpers.d.ts.map