Durable Streams based durable transport and session implementations for TanStack AI and the Vercel AI SDK.
See the Durable Sessions — the key pattern for collaborative AI blog post for more information.
Durable Transport plugins integrate at the pluggable Transport / Connection Adapter level to provide resilience and resumability.
SDK-agnostic packages:
@durable-streams/transport— protocol-agnostic transport library with proxy-aware fetch client and storage utilities@durable-streams/transport-proxy— node service that proxies backend API requests via Durable Streams
SDK-specific adapters:
@durable-streams/tanstack-ai-transport— TanStack AI Connection Adapter@durable-streams/ai-transport— Vercel AI SDK Transport
Demos:
The Durable Sessions pattern swaps out the request <> response based interaction paradigm of the AI SDKs for a sync-based pattern based on TanStack DB. Persistence and addressability is provided by a Durable Stream, using the @durable-streams/state protocol.
The Durable Stream provides persistence and addressability. The sync-based architecture naturally supports multi-tab, multi-device and multi-user. The session supports multi-agent and real-time presence.
You can use this pattern to build genuinely collaborative AI apps that support both real-time and asynchronous collaboration. Everything is reactive and type-safe, with zero changes to your actual AI engineering code.
Packages:
@electric-sql/durable-session— core session implementation withDurableChatimplementation@electric-sql/durable-session-proxy— session proxy service@electric-sql/react-durable-session— React bindings (useDurableChathook)
Demo:
pnpm i
pnpm build
pnpm test
# In one terminal
pnpm backend:up # Starts Durable Streams server on port 3001
pnpm dev:session-proxy # Starts session proxy for session demo
# pnpm dev:proxy # for transport demos
# In another terminal
pnpm dev:demo tanstack-ai-durable-session
# pnpm dev:demo tanstack-ai-durable-transport
# pnpm dev:demo vercel-ai-sdk-durable-transportYou can also use the @durable-streams CLI to write directly to a stream, in order to demonstrate "out of band writes" e.g.:
source .env
cd demos/tanstack-ai-durable-session
cat example.json | durable-stream-dev write "sessions/default" --jsonSome dependencies are still currently workspace dependencies. See pnpm-workspace.yaml for details.