import type { AskCardDispatcher, AskResult, PendingAsk } from '../../core/ask-types.js'; import { replyMessage, sendMessage, updateMessage } from './client.js'; /** 旧单选即答动作(保留兼容旧卡片回调;Task 5 新增 ask_submit 路径)。 */ export declare const ASK_SELECT_ACTION = "ask_select"; /** 新多问 Submit 动作(form 内提交按钮携带此 action)。 */ export declare const ASK_SUBMIT_ACTION = "ask_submit"; /** 累积勾选动作。飞书会 silent-drop form + select_static,所以 v0.1.8 用按钮态。 */ export declare const ASK_TOGGLE_ACTION = "ask_toggle"; export interface AskCardActionData { operator?: { open_id?: string; }; action?: { value?: Record; form_value?: Record; }; } export interface AskCardDispatcherDeps { sendMessage?: typeof sendMessage; replyMessage?: typeof replyMessage; updateMessage?: typeof updateMessage; } export declare function createLarkAskCardDispatcher(deps?: AskCardDispatcherDeps): AskCardDispatcher; /** * Classify a Feishu card-send failure into "worth retrying" vs "give up now" * (codex P1-3). PURE + exported so the retry decision is unit-tested directly * (executable decision seam) rather than asserted against source text. * * Retryable (transient — a re-send with the same uuid may succeed / dedupe): * - a well-known transient Lark business code (TRANSIENT_LARK_CODES), checked * FIRST so it wins even on an HTTP 400 or a 2xx-body business error * - no HTTP response at all (network reset, DNS, timeout) * - HTTP 429 (rate limited) or any 5xx (server-side) * Not retryable (deterministic — re-sending repeats the same failure): * - HTTP 4xx other than 429 (bad request, permission, not found) * - message withdrawn (target gone) * - anything we can't positively classify → fail closed (retry is unsafe when * we can't prove idempotency). * * Extraction mirrors bot-registry.formatLarkError: status at `response.status` * or `.status`; Feishu code at `response.data.code` / `.code` / message tail. */ export declare function classifyAskDispatchError(err: unknown): { retryable: boolean; detail: string; }; export declare function isAskCardAction(action?: string): boolean; export declare function handleAskCardAction(data: AskCardActionData): Promise<{ toast: { type: string; content: string; }; } | Record | undefined>; /** * 构建 ask 卡片 JSON 字符串。 * * 未 settle 时: * - 单问单选:每个选项一个按钮,点击即 settle(旧 ask_select 语义) * - 多问或多选:每个选项一个按钮用于累积勾选,最后用 Submit settle * * 注意:飞书服务端会 silent-drop `form` 内的 select_static / multi_select_static, * 所以这里只使用稳定的 `action` + `button` 结构。 * * 已 settle 时:渲染状态摘要,展示每问的选中标签(answered),或超时/失效信息。 */ export declare function buildAskCard(ask: PendingAsk, result?: AskResult, opts?: { confirmEmptyArmed?: boolean; }): string; /** * 防御式解析 Lark form_value,将每个 q 字段的编码选项解析为选中 key 数组。 * * 字段值可能为: * - string[](multi_select_static 多选) * - string(select_static 单选,或 comma/semicolon 分隔的字符串) * * 每个编码值格式为 `::`,只收集 prefix 匹配的条目并剥去前缀。 * 导出供单元测试直接调用。 */ export declare function parseFormSelections(formValue: Record, questionCount: number): string[][]; //# sourceMappingURL=ask-card.d.ts.map