Packages
Studio Stores
Store bundle types, in-memory store, and optional SQLite session/trace store.
Import from @anvia/studio.
Store Bundle Types
type StudioStores = {
sessions?: StudioSessionStore | false;
traces?: StudioTraceStore;
pipelineLogs?: StudioPipelineLogStore | false;
pipelineRuns?: StudioPipelineRunStore | false;
};
Purpose: optional persistence stores for Studio sessions, traces, pipeline logs, and pipeline run history.
Return behavior: false disables sessions, pipeline logs, or pipeline runs. Omitted traces disable trace routes unless the session store also implements StudioTraceStore. The default in-memory store implements session, trace, pipeline log, and pipeline run storage.
Notable errors: none directly.
Memory Store Types
type StudioMemoryContext = {
sessionId: string;
userId?: string;
metadata?: JsonObject;
};
type StudioMemoryAppendInput = {
context: StudioMemoryContext;
runId: string;
turn: number;
messages: Message[];
};
type StudioMemoryErrorInput = {
context: StudioMemoryContext;
runId: string;
error: unknown;
messages: Message[];
};
type StudioMemoryStore = {
load(context: StudioMemoryContext): Promise<Message[]>;
append(input: StudioMemoryAppendInput): Promise<void>;
clear(context: StudioMemoryContext): Promise<void>;
recordError?(input: StudioMemoryErrorInput): Promise<void>;
};
Purpose: define the persistence contract Studio uses to load, append, clear, and record errors for session memory.
Return behavior: StudioSessionStore extends StudioMemoryStore, so custom session stores must implement these memory methods. recordError is optional and is called when a run fails after memory context is available.
Notable errors: store implementations may reject when persistence operations fail.
In-Memory Store
function createInMemoryStudioStore(): StudioSessionStore &
StudioTraceStore &
StudioPipelineLogStore &
StudioPipelineRunStore;
Purpose: create a process-local Studio store for sessions, traces, pipeline logs, and pipeline run history.
Return behavior: this is the default Studio store when no explicit store is provided.
Notable errors: none directly.
SQLite Store
type SqliteSessionStoreOptions = {
path?: string;
};
function createSqliteSessionStore(
options?: SqliteSessionStoreOptions,
): StudioSessionStore & StudioTraceStore & StudioPipelineLogStore & StudioPipelineRunStore;
Purpose: create a SQLite-backed session, trace, pipeline log, and pipeline run store.
Return behavior: defaults to in-memory SQLite when path is omitted. When used with a file path, Studio creates dedicated anvia_studio_* tables.
Notable errors: throws when node:sqlite is unavailable, the database cannot open, or SQLite operations fail.
