Studio Sessions
Session summaries, transcript entries, and session store contracts.
Import from @anvia/studio.
Transcript Entries
type StudioTranscriptChatEntry = {
entryId: number;
kind: "message";
role: "user" | "assistant";
text: string;
traceId?: string;
};
type StudioTranscriptReasoningEntry = {
entryId: number;
kind: "reasoning";
reasoningId?: string;
text: string;
};
type StudioTranscriptToolEntry = {
entryId: number;
kind: "tool";
toolName: string;
callId?: string;
args?: string;
result?: string;
childEvents?: StudioTranscriptChildAgentEvent[];
approval?: StudioToolApprovalTranscript;
question?: StudioToolQuestionTranscript;
};
type StudioTranscriptChildAgentEvent =
| {
kind: "message";
agentId: string;
agentName?: string;
text: string;
}
| {
kind: "reasoning";
agentId: string;
agentName?: string;
reasoningId?: string;
text: string;
}
| {
kind: "tool";
agentId: string;
agentName?: string;
toolName: string;
callId?: string;
args?: string;
result?: string;
};
type StudioTranscriptEntry =
| StudioTranscriptChatEntry
| StudioTranscriptReasoningEntry
| StudioTranscriptToolEntry;Purpose: UI-friendly transcript model derived from messages and stream events.
Return behavior: persisted inside StudioSession.transcript.
Notable errors: none directly.
Session Types
type StudioSessionSummary = {
id: string;
agentId: string;
title?: string;
createdAt: string;
updatedAt: string;
messageCount: number;
metadata?: JsonObject;
};
type StudioSession = StudioSessionSummary & {
messages: Message[];
transcript: StudioTranscriptEntry[];
};Purpose: session list and detail contracts.
Return behavior: stores return summaries for lists and full sessions for detail.
Notable errors: none directly.
Session Store Inputs
type StudioSessionCreateInput = {
id: string;
agentId: string;
title?: string;
metadata?: JsonObject;
};
type StudioSessionListOptions = {
agentId?: string;
limit: number;
};
type StudioSessionRunStatus = "running" | "success" | "error";
type StudioSessionRunTranscriptInput = {
id: string;
runId: string;
title?: string;
transcript: StudioTranscriptEntry[];
status: StudioSessionRunStatus;
error?: JsonValue;
};
type StudioSessionLogLevel = "debug" | "info" | "warn" | "error";
type StudioSessionLogCategory =
| "session"
| "run"
| "memory"
| "prompt"
| "model"
| "tool"
| "approval"
| "question"
| "api";
type StudioSessionLogEntry = {
id: string;
sessionId: string;
runId?: string;
sequence: number;
timestamp: string;
level: StudioSessionLogLevel;
category: StudioSessionLogCategory;
event: string;
message: string;
metadata?: JsonObject;
};
type StudioSessionLogAppendInput = {
sessionId: string;
runId?: string;
level: StudioSessionLogLevel;
category: StudioSessionLogCategory;
event: string;
message: string;
metadata?: JsonObject;
};
type StudioSessionLogListOptions = {
sessionId: string;
limit: number;
after?: number;
};
type StudioSessionLogEvent = {
type: "session_log";
log: StudioSessionLogEntry;
};Purpose: arguments for session store methods.
Return behavior: used by StudioSessionStore and streaming session log events.
Notable errors: store implementations may reject invalid or conflicting inputs.
StudioSessionStore
type StudioSessionStore = MemoryStore & {
readonly kind?: string;
listSessions(options: StudioSessionListOptions): StudioSessionSummary[] | Promise<StudioSessionSummary[]>;
createSession(input: StudioSessionCreateInput): StudioSessionSummary | Promise<StudioSessionSummary>;
getSession(id: string): StudioSession | undefined | Promise<StudioSession | undefined>;
saveSessionRunTranscript(
input: StudioSessionRunTranscriptInput,
): StudioSession | undefined | Promise<StudioSession | undefined>;
appendSessionLog?(input: StudioSessionLogAppendInput): StudioSessionLogEntry | Promise<StudioSessionLogEntry>;
listSessionLogs?(options: StudioSessionLogListOptions): StudioSessionLogEntry[] | Promise<StudioSessionLogEntry[]>;
deleteSession?(id: string): boolean | Promise<boolean>;
};Purpose: persistence adapter for Studio sessions.
Return behavior: methods may be sync or async. Because the store extends MemoryStore, it also loads, appends, and clears model messages for Studio-backed sessions. Log methods are optional for custom stores; the default SQLite store implements them.
Notable errors: persistence failures should throw or reject.
