Commit 1f4c2ce
feat(slack): api primitives subpath (vercel/chat#548, #559)
Port of upstream aba6aa9 (api/client.ts) and 6ed4a43 (api/extra.ts) —
adds chat_sdk.adapters.slack.api, a runtime-free subpath exposed upstream
as @chat-adapter/slack/api. Provides fetch-based primitives for calling
Slack Web API methods (call_slack_api), posting/updating/deleting messages
(post_slack_message, post_slack_ephemeral, update_slack_message,
delete_slack_message), sending interaction response_url payloads
(send_slack_response_url), uploading files through Slack's external upload
flow (upload_slack_files), fetching private Slack file URLs with bearer
auth (fetch_slack_file), fetching thread replies with cursor pagination
(fetch_slack_thread_replies), and opening modal views (open_slack_view) —
without the full Slack adapter, slack_sdk, Socket Mode, or the chat
runtime.
Importing this subpath never imports an HTTP client: the default fetch
lazily imports httpx only when a request is actually made (matching the
high-level adapter's optional-httpx pattern), and any async HTTP stack can
be injected via the fetch= parameter. SlackBotToken is declared locally
rather than imported from the adapter's types module, so the subpath stays
self-contained and runtime-free — mirroring upstream's independent
declaration in api/client.ts.
Python-specific notes: option objects become keyword-only arguments;
camelCase request fields are emitted at the Slack serialization boundary
(markdown_text, reply_broadcast, thread_ts, ...) while the API is
snake_case. Python-specific hardening (divergences, see
docs/UPSTREAM_SYNC.md Known Non-Parity): send_slack_response_url requires
an https://*.slack.com URL and fetch_slack_file requires a Slack-owned
file host before forwarding the bearer token (SSRF / token-leak guards
mirroring the high-level adapter); upstream validates neither.
Tests port api/index.test.ts and api/boundary.test.ts with injected
AsyncMock fetches (no network), plus the two divergence guards.
https://claude.ai/code/session_013zwTcMek5rNqBTQvs2oF641 parent 852c189 commit 1f4c2ce
2 files changed
Lines changed: 1165 additions & 0 deletions
0 commit comments