UNPKG

@mastra/core

Version:

Mastra is a framework for building AI-powered applications and agents with a modern TypeScript stack.

49 lines 2.13 kB
import type { Lock, QueueEntry, StateAdapter } from 'chat'; import type { MemoryStorage } from '../storage/domains/memory/base.js'; /** * Chat SDK StateAdapter backed by Mastra storage. * * Thread subscriptions are persisted to the Mastra `MemoryStorage` domain * using thread metadata (`channel_subscribed`), so they survive restarts. * * Cache, locks, and dedup keys remain in-memory — they are inherently * short-lived (seconds to minutes) and don't need persistence. */ export declare class MastraStateAdapter implements StateAdapter { private memoryStore; private connected; private connectPromise; private readonly cache; private readonly locks; private readonly lists; private readonly queues; constructor(memoryStore: MemoryStorage); connect(): Promise<void>; disconnect(): Promise<void>; subscribe(threadId: string): Promise<void>; unsubscribe(threadId: string): Promise<void>; isSubscribed(threadId: string): Promise<boolean>; get<T = unknown>(key: string): Promise<T | null>; set<T = unknown>(key: string, value: T, ttlMs?: number): Promise<void>; setIfNotExists(key: string, value: unknown, ttlMs?: number): Promise<boolean>; delete(key: string): Promise<void>; appendToList(key: string, value: unknown, options?: { maxLength?: number; ttlMs?: number; }): Promise<void>; getList<T = unknown>(key: string): Promise<T[]>; acquireLock(threadId: string, ttlMs: number): Promise<Lock | null>; releaseLock(lock: Lock): Promise<void>; extendLock(lock: Lock, ttlMs: number): Promise<boolean>; forceReleaseLock(threadId: string): Promise<void>; enqueue(threadId: string, entry: QueueEntry, maxSize: number): Promise<number>; dequeue(threadId: string): Promise<QueueEntry | null>; queueDepth(threadId: string): Promise<number>; private cleanExpiredLocks; /** * Find a Mastra thread by its external (SDK) thread ID. * External thread IDs are stored in `channel_externalThreadId` metadata. */ private findThreadByExternalId; } //# sourceMappingURL=state-adapter.d.ts.map