Skip to content

electric-sql/transport

Repository files navigation

Memento polaroid icon

Durable Transport & Durable Session

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

Durable Transport plugins integrate at the pluggable Transport / Connection Adapter level to provide resilience and resumability.

SDK-agnostic packages:

SDK-specific adapters:

Demos:

Durable Session

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:

Demo:

Usage

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-transport

You 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" --json

Caveats

Some dependencies are still currently workspace dependencies. See pnpm-workspace.yaml for details.

About

Durable Streams based durable transport and session implementations for TanStack AI and the Vercel AI SDK.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published