Files
vercel__chat/packages/adapter-shared
github-actions[bot] aea4d753de chore(release): version packages (#829)
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @chat-adapter/discord@4.38.1

### Patch Changes

- Updated dependencies [6cb933e]
- Updated dependencies [764e475]
  - chat@4.38.1
  - @chat-adapter/shared@4.38.1
## @chat-adapter/gchat@4.38.1

### Patch Changes

- 3268703: download attachments through the Google Chat media API to
prevent credential exposure
- Updated dependencies [6cb933e]
- Updated dependencies [764e475]
  - chat@4.38.1
  - @chat-adapter/shared@4.38.1
## @chat-adapter/github@4.38.1

### Patch Changes

- Updated dependencies [6cb933e]
- Updated dependencies [764e475]
  - chat@4.38.1
  - @chat-adapter/shared@4.38.1
## @chat-adapter/instagram@4.38.1

### Patch Changes

- Updated dependencies [6cb933e]
- Updated dependencies [764e475]
  - chat@4.38.1
  - @chat-adapter/shared@4.38.1
## @chat-adapter/linear@4.38.1

### Patch Changes

- Updated dependencies [6cb933e]
- Updated dependencies [764e475]
  - chat@4.38.1
  - @chat-adapter/shared@4.38.1
## @chat-adapter/messenger@4.38.1

### Patch Changes

- Updated dependencies [6cb933e]
- Updated dependencies [764e475]
  - chat@4.38.1
  - @chat-adapter/shared@4.38.1
## @chat-adapter/notion@4.38.1

### Patch Changes

- Updated dependencies [6cb933e]
- Updated dependencies [764e475]
  - chat@4.38.1
  - @chat-adapter/shared@4.38.1
## @chat-adapter/shared@4.38.1

### Patch Changes

- Updated dependencies [6cb933e]
- Updated dependencies [764e475]
  - chat@4.38.1
## @chat-adapter/slack@4.38.1

### Patch Changes

- 764e475: preserve pasted Slack tables in parsed message content:
`table` and `data_table` blocks become structured table nodes in
`message.formatted` and tab-separated text in `message.text`. Table
cells render mentions, channels, and links through the same mrkdwn
converter as body text, unfurl and app attachments are excluded, date
cells without a fallback are formatted from their timestamp, and tables
pasted above the message text stay above it. Headerless pasted tables
get an empty header row so GFM re-serialization doesn't promote the
first data row to a header. `SlackEvent.blocks` is now typed with the
exported `SlackMessageBlock` interface.
- Updated dependencies [6cb933e]
- Updated dependencies [764e475]
  - chat@4.38.1
  - @chat-adapter/shared@4.38.1
## @chat-adapter/teams@4.38.1

### Patch Changes

- Updated dependencies [6cb933e]
- Updated dependencies [764e475]
  - chat@4.38.1
  - @chat-adapter/shared@4.38.1
## @chat-adapter/telegram@4.38.1

### Patch Changes

- Updated dependencies [6cb933e]
- Updated dependencies [764e475]
  - chat@4.38.1
  - @chat-adapter/shared@4.38.1
## @chat-adapter/twilio@4.38.1

### Patch Changes

- d8103a1: prevent credentials from being sent to untrusted media
origins
- Updated dependencies [6cb933e]
- Updated dependencies [764e475]
  - chat@4.38.1
  - @chat-adapter/shared@4.38.1
## @chat-adapter/web@4.38.1

### Patch Changes

- Updated dependencies [6cb933e]
- Updated dependencies [764e475]
  - chat@4.38.1
  - @chat-adapter/shared@4.38.1
## @chat-adapter/whatsapp@4.38.1

### Patch Changes

- Updated dependencies [6cb933e]
- Updated dependencies [764e475]
  - chat@4.38.1
  - @chat-adapter/shared@4.38.1
## @chat-adapter/x@4.38.1

### Patch Changes

- Updated dependencies [6cb933e]
- Updated dependencies [764e475]
  - chat@4.38.1
  - @chat-adapter/shared@4.38.1
## chat@4.38.1

### Patch Changes

- 6cb933e: isolate queued and debounced messages by thread when using
channel-scoped locks
- 764e475: `toPlainText` keeps empty table cells so tab-separated
columns stay aligned, and drops table rows with no content (such as
placeholder header rows)
## @chat-adapter/state-ioredis@4.38.1

### Patch Changes

- Updated dependencies [6cb933e]
- Updated dependencies [764e475]
  - chat@4.38.1
## @chat-adapter/state-memory@4.38.1

### Patch Changes

- Updated dependencies [6cb933e]
- Updated dependencies [764e475]
  - chat@4.38.1
## @chat-adapter/state-pg@4.38.1

### Patch Changes

- Updated dependencies [6cb933e]
- Updated dependencies [764e475]
  - chat@4.38.1
## @chat-adapter/state-redis@4.38.1

### Patch Changes

- Updated dependencies [6cb933e]
- Updated dependencies [764e475]
  - chat@4.38.1
## @chat-adapter/tests@4.38.1

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-08-17 22:04:34 +01:00
..
2026-02-27 09:58:28 -08:00

@chat-adapter/shared

npm package: @chat-adapter/shared

Agent Stack MIT License

Shared utilities for Chat SDK adapters. Provides common helpers used across adapter implementations.

Documentation: chat-sdk.dev/docs/contributing/building · Guides: vercel.com/kb/chat-sdk

Installation

pnpm add @chat-adapter/shared

Utilities

Adapter helpers

  • extractCard(message) - extract a CardElement from an AdapterPostableMessage
  • extractFiles(message) - extract FileUpload[] from an AdapterPostableMessage
  • extractPostableAttachments(message) - extract Attachment[] from an AdapterPostableMessage

Buffer conversion

  • toBuffer(input) - convert various inputs (Buffer, Blob, string, URL) to Buffer
  • toBufferSync(input) - synchronous version of toBuffer
  • bufferToDataUri(buffer, mimeType) - convert a Buffer to a data URI string

Card conversion

  • cardToFallbackText(card) - render a CardElement as plain text for platforms that don't support cards
  • createEmojiConverter(platform) - create a function that converts emoji placeholders to platform format
  • mapButtonStyle(style) - map generic button styles to platform-specific variants
  • renderGfmTable(headers, rows) - render a GitHub Flavored Markdown table
  • escapeTableCell(text) - escape pipe characters in table cells

Token encryption

AES-256-GCM helpers for encrypting OAuth tokens at rest before writing them to a state adapter. Used by @chat-adapter/slack and @chat-adapter/linear; available to any adapter that persists credentials.

  • encryptToken(plaintext, key) - encrypt a string and return an EncryptedTokenData envelope (random 12-byte IV per call)
  • decryptToken(data, key) - decrypt an envelope back to the original string
  • decodeKey(encoded) - decode a hex-64 or base64-44 encoded 32-byte key; throws on wrong length
  • isEncryptedTokenData(value) - type guard for distinguishing envelopes from legacy plaintext records
  • EncryptedTokenData - the envelope type ({ data, iv, tag }, all base64)

Error classes

Standardized errors for adapter implementations:

  • AdapterError - base error class
  • AdapterRateLimitError - platform rate limit (includes retryAfter)
  • AuthenticationError - expired or invalid tokens
  • NetworkError - connection failures
  • PermissionError - missing scopes or permissions
  • ResourceNotFoundError - missing channel/thread/message
  • ValidationError - invalid config or input

AI Coding Agents

If you use an AI coding agent such as OpenAI Codex, Claude Code, or Cursor, install the Chat SDK skill so it knows the SDK APIs, adapter patterns, and project conventions before writing code.

npx skills add vercel/chat

The skill references bundled documentation in node_modules/chat/docs, plus adapter guides and starter templates in the published package.

You can also install the Vercel Plugin for a broader agent toolkit — it includes the Chat SDK skill alongside specialist agents, agent slash commands, and more:

npx plugins add vercel/vercel-plugin

The plugin is optional; the skill alone is enough to build with Chat SDK.

For agent-readable documentation, see chat-sdk.dev/llms.txt (page index) or chat-sdk.dev/llms-full.txt (full text).

License

MIT