UNPKG

eve

Version:

Filesystem-first framework for durable backend AI agents that run anywhere.

46 lines (45 loc) 2.09 kB
/** * Card → Slack Block Kit converter. * * The chat SDK's Slack adapter used to walk the cross-platform * `CardElement` AST (the data shape produced by `Card({...})`, * `Actions([...])`, `Button({...})`, etc.) and emit Slack Block Kit * JSON for `chat.postMessage`. We replicate just that conversion here * so authors can keep using the ergonomic card builders without the * `@chat-adapter/slack` runtime. * * Supported shapes: * Card → header + context + image header + children blocks * TextElement → `section`/`context` (style: plain | bold | muted) * ImageElement → `image` block * DividerElement → `divider` * ActionsElement → `actions` with buttons / link buttons / * static_select / radio_buttons * SectionElement → recurses into a sequence of blocks * FieldsElement → `section` with fields * LinkElement → `section` with a `<url|label>` mrkdwn * TableElement → `section` with a mrkdwn approximation * ButtonElement → `button` action element * LinkButtonElement → `button` action element with `url` * * Anything else falls back to the chat SDK's * `cardChildToFallbackText` (a string description) wrapped in a * section block so the message is never silently dropped. */ import { type CardElement } from "#compiled/chat/index.js"; /** * One Slack Block Kit block. Slack accepts a wide enum and adds new * block types over time, so this type stays open-ended. */ export type BlockKitBlock = Record<string, unknown>; /** * Converts a {@link CardElement} into a list of Slack Block Kit blocks * ready to pass to `chat.postMessage`'s `blocks` parameter. */ export declare function cardToBlocks(card: CardElement): BlockKitBlock[]; /** * Best-effort fallback text for a card. `chat.postMessage` sends this * as the `text` field so notifications and accessibility readers still * see something meaningful. */ export declare function cardToFallbackText(card: CardElement): string;