Commit 1e7b843
feat(slack): block kit primitives subpath (vercel/chat#555, #559)
Port of upstream dbd8dc5 (blocks/index.ts, types.ts, limits.ts,
errors.ts) and 6ed4a43 (blocks/input.ts) — adds
chat_sdk.adapters.slack.blocks, a runtime-free subpath exposed upstream as
@chat-adapter/slack/blocks. Converts Chat SDK-style card objects into
Slack Block Kit blocks (card_to_slack_blocks / card_to_block_kit), a
Markdown fallback (card_to_slack_fallback_text / card_to_fallback_text),
and emoji-placeholder codes (convert_slack_emoji_placeholders), enforcing
docs-backed Slack size limits (LIMITS) for headers, images, actions,
select options, fields, and tables. Also ports the generic input-request
helpers: input_request_to_slack_blocks (buttons / select / radio /
freeform), parse_slack_input_response, build_slack_freeform_view,
parse_slack_freeform_value, and answered_slack_input_blocks — without the
full Slack adapter, slack_sdk, or the chat runtime. The only cross-module
dependency is the sibling format subpath (markdown_bold_to_slack_mrkdwn),
which is itself runtime-free.
Python-specific notes: the card-input shapes (SlackCardElement and
children) are self-contained TypedDicts declared here rather than imported
from chat_sdk.cards, keeping the subpath runtime-free. Input field names
are snake_case (image_url, initial_option, request_id, allow_freeform,
selected_option_value, action_id, block_id), matching chat_sdk.cards and
the Python port convention — upstream uses camelCase. Emitted Block Kit
dicts keep Slack's API field names verbatim (alt_text, action_id,
block_id, static_select, column_settings, raw_text, private_metadata),
which is the Slack serialization boundary. Discriminated-union dispatch on
the literal type key uses per-branch casts / arg-type ignores, mirroring
the high-level adapter's cards.py.
Tests port blocks/index.test.ts and blocks/boundary.test.ts with full
output equality, plus extra coverage of the parse-None and
string-metadata paths.
https://claude.ai/code/session_013zwTcMek5rNqBTQvs2oF641 parent 1f4c2ce commit 1e7b843
6 files changed
Lines changed: 1679 additions & 0 deletions
File tree
- src/chat_sdk/adapters/slack/blocks
- tests
0 commit comments