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>
@chat-adapter/state-pg
npm package:
@chat-adapter/state-pg
Production PostgreSQL state adapter for Chat SDK built with pg (node-postgres). Use this when PostgreSQL is your primary datastore and you want state persistence without a separate Redis dependency.
Documentation: chat-sdk.dev/adapters/official/postgres · Guides: vercel.com/kb/chat-sdk
Installation
pnpm add @chat-adapter/state-pg
Scaffold with the CLI
To scaffold a new Slack bot that uses PostgreSQL for state:
npx create-chat-sdk@latest my-bot --adapter slack postgres
Visit the adapters directory to see other available official and vendor-official adapters.
Usage
createPostgresState() auto-detects POSTGRES_URL (or DATABASE_URL) so you can call it with no arguments:
import { Chat } from "chat";
import { createPostgresState } from "@chat-adapter/state-pg";
const bot = new Chat({
userName: "mybot",
adapters: { /* ... */ },
state: createPostgresState(),
});
To provide a URL explicitly:
const state = createPostgresState({
url: "postgres://postgres:postgres@localhost:5432/chat",
});
Using an existing client
import pg from "pg";
const client = new pg.Pool({ connectionString: process.env.POSTGRES_URL! });
const state = createPostgresState({ client });
Configuration
| Option | Required | Description |
|---|---|---|
url |
No* | Postgres connection URL |
client |
No | Existing pg.Pool instance |
keyPrefix |
No | Prefix for all state rows (default: "chat-sdk") |
logger |
No | Logger instance (defaults to ConsoleLogger("info").child("postgres")) |
*Either url, POSTGRES_URL/DATABASE_URL, or client is required.
Environment variables
POSTGRES_URL=postgres://postgres:postgres@localhost:5432/chat
Data model
The adapter creates these tables automatically on connect():
chat_state_subscriptions
chat_state_locks
chat_state_cache
chat_state_lists
chat_state_queues
All rows are namespaced by key_prefix.
Features
| Feature | Supported |
|---|---|
| Persistence | Yes |
| Multi-instance | Yes |
| Subscriptions | Yes |
| Distributed locking | Yes |
| Key-value caching | Yes (with TTL) |
| Automatic table creation | Yes |
| Key prefix namespacing | Yes |
Locking considerations
The Redis state adapters use atomic SET NX PX for lock acquisition, which is a single atomic operation. The PostgreSQL adapter uses INSERT ... ON CONFLICT DO UPDATE WHERE expires_at <= now(), which relies on Postgres row-level locking. This is safe for most workloads but under extreme contention (many processes competing for the same lock simultaneously) may behave slightly differently than Redis. For high-contention distributed locking, prefer the Redis adapter.
Expired row cleanup
Unlike Redis (which handles TTL expiry natively), PostgreSQL does not automatically delete expired rows. The adapter performs opportunistic cleanup — expired locks are overwritten on the next acquireLock() call, expired cache entries are deleted on the next get() call for that key, and expired queue entries for a given thread are purged on the next enqueue() or dequeue() call. Expired list entries are filtered out on read but never deleted by the adapter.
For high-throughput deployments, you may want to run a periodic cleanup job:
DELETE FROM chat_state_locks WHERE expires_at <= now();
DELETE FROM chat_state_cache WHERE expires_at <= now();
DELETE FROM chat_state_lists WHERE expires_at <= now();
DELETE FROM chat_state_queues WHERE expires_at <= now();
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