⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

electric-sql/transport

Repository files navigation

Memento polaroid icon

Durable Transport & Durable Sessions

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 Sessions

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 4437
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.

Project links

About

Durable Streams based durable transport and session implementations.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published