Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

ai-persistence

БесплатноБез исполняемых скриптовНе проверен

Durability and state persistence for TanStack AI chats with @tanstack/ai-persistence. Routes to server chat persistence (withPersistence), client persistence…

TanStackот TanStack★ 3 396 звёзд на GitHub

Об этом скилле

TanStack AI Persistence

Builds on the ai-core skill in @tanstack/ai, and usually ai-core/chat-experience.

TanStack AI splits delivery durability from state persistence. They share no code and solve different problems.

Layer Answers Package / API
Delivery durability Reconnect to a stream still running memoryStream / @tanstack/ai-durable-stream on the response; see resumable streams docs
State persistence What is the conversation, later? Client persistence on useChat + server withPersistence from @tanstack/ai-persistence

A replayable stream is not a saved conversation. A saved conversation is not a live stream. Production apps often use both.

Persistence is a contract, not a database

@tanstack/ai-persistence ships the store interfaces, the middleware that drives them, an in-memory reference backend, and a conformance testkit. It does not ship a backend for your database, and you do not need one: implement the stores against whatever you already run — Postgres, SQLite, D1, Mongo — and hand the result to withPersistence. The core never inspects your tables.

Ships in the package What it is
MessageStore / RunStore / InterruptStore / MetadataStore The four chat state contracts
GenerationRunStore / ArtifactStore / BlobStore The generation contracts (job lifecycle + bytes)
withPersistence / withGenerationPersistence Chat + generation middleware
memoryPersistence() In-process reference backend, all seven stores (dev, tests)
reconstructChat / reconstructGeneration Server hydrate route helpers (chat / generation)
retrieveArtifact / retrieveBlob Serve persisted generation-media bytes back
LockStore / withLocks / InMemoryLockStore (from @tanstack/ai/locks) Coordination, not this package — see ai-core/locks
@tanstack/ai-persistence/testkit runPersistenceConformance gate (chat state stores)

Chat vs generation stores. Chat persistence keys on threadId and uses messages + optional runs / interrupts / metadata. Generation persistence keys on its own runId and uses generationRuns (required by withGenerationPersistence) plus an optional artifacts + blobs pair — provide both or neither — to store the generated media bytes at blob key artifacts/<runId>/<artifactId>. A generation run's identity is its own runId, but threadId is required on the record: it is the stable slot successive runs fill, and findLatestForThread — the only query that hydrates a run — keys on it. To build the R2/D1-backed byte stores for a Worker, see ai-persistence/build-cloudflare-artifact-store.

Where bytes land. Default blob key is artifacts/<runId>/<artifactId>. Pass storageKey to withGenerationPersistence for your own folder structure — it receives { artifactId, runId, threadId, role, activity, path, mimeType, name } and returns the key. Server-side only (a browser-supplied key is path traversal + cross-tenant writes). The resolved key is recorded on ArtifactRecord.blobKey because it is no longer derivable; read record.blobKey, never recompute it. blobKey is required. 0.x records without it are not supported: retrieveBlob throws for them. Backfill blob_key before upgrading. A non-unique key overwrites, so include artifactId unless that is intended.

Byte storage stores generated output, not prompt URLs. Provider result URLs expire, so they are downloaded and kept. Prompt media sent as base64 (source: { type: 'data' }) is stored too. Prompt media sent as a URL is NOT fetched — that URL is caller-supplied, so downloading it server-side is an SSRF vector, and the bytes are redundant. Apps that genuinely need a durable copy opt in with allowInputUrl, a predicate so the check can't be skipped: allowInputUrl: ({ url }) => url.hostname.endsWith('.cdn.example.com'). Never suggest () => true. All artifact fetches are http/https-only, timed out (artifactFetchTimeoutMs) and size-capped (maxArtifactBytes); input fetches also b

Полный SKILL.md на GitHub

Установить ai-persistence в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

build-cloudflare-adapter/SKILL.mdbuild-cloudflare-artifact-store/SKILL.mdbuild-custom-adapter/SKILL.mdbuild-drizzle-adapter/SKILL.mdbuild-prisma-adapter/SKILL.mdserver/SKILL.mdstores/SKILL.md

FAQ

Что делает скилл ai-persistence?

Durability and state persistence for TanStack AI chats with @tanstack/ai-persistence. Routes to server chat persistence (withPersistence), client persistence (localStorage/IndexedDB), the store contracts, and adapter recipes. Distinguishes delivery durability (resumable streams) from conversation state. Use when conversations must survive reloads, multi-device, approvals, or server restarts — NOT for stream reconnect alone.

Как установить скилл ai-persistence?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл ai-persistence запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить ai-persistence с