Skip to main content

TypeScript Types

shared/types.ts is the single source of truth for all TypeScript interfaces shared between the client and server. Both sides import from this file, ensuring type consistency across the entire application.

Session Types​

Session​

Represents a full chat session including all messages.

interface Session {
id: string;
title: string;
templateId?: string;
projectId?: string;
createdAt: string;
updatedAt: string;
messages: Message[];
}

Message​

A single message within a session.

interface Message {
id: string;
role: "user" | "assistant";
content: string;
source?: "voice" | "text";
timestamp: string;
isError?: boolean;
}

SessionMeta​

Session metadata without the full message array — used for listing sessions efficiently.

type SessionMeta = Omit<Session, "messages"> & {
messageCount: number;
};

Project Types​

Project​

A project that groups related sessions together.

interface Project {
id: string;
name: string;
description: string;
color: string;
createdAt: string;
updatedAt: string;
}

ProjectMeta​

Project metadata enriched with a count of associated sessions.

type ProjectMeta = Project & {
sessionCount: number;
};

Template Types​

Template​

A prompt template with its full content.

interface Template {
id: string;
title: string;
description: string;
category: string;
tags: string[];
source: "local" | "community";
content: string;
author?: string;
version?: string;
variables?: TemplateVariable[];
createdAt: string;
updatedAt: string;
}

TemplateVariable​

Defines a variable placeholder within a template.

interface TemplateVariable {
name: string;
label: string;
default?: string;
required?: boolean;
}

TemplateMeta​

Template metadata without the content body — used for listing templates.

type TemplateMeta = Omit<Template, "content">;

Vosk STT Model Types​

VoskModelManifest​

Describes a Vosk speech-to-text model as listed in the manifest.

interface VoskModelManifest {
id: string;
name: string;
language: string;
size: string;
accuracy: string;
minRAM: string;
url: string;
default: boolean;
}

VoskModelInfo​

Extends the manifest with runtime status information.

type VoskModelInfo = VoskModelManifest & {
downloaded: boolean;
active: boolean;
};

AI / Settings Types​

AIProviderConfig​

Configuration for a single AI provider.

interface AIProviderConfig {
apiKey: string;
model: string;
baseUrl: string;
}

AISettings​

All AI-related settings, supporting multiple providers.

interface AISettings {
provider: string;
providers: Record<string, AIProviderConfig>;
systemPrompt?: string;
temperature?: number;
maxTokens?: number;
thinkingEnabled?: boolean;
planMode?: boolean;
positivePrompt?: string;
negativePrompt?: string;
}

Settings​

Top-level application settings object.

interface Settings {
ai: AISettings;
stt: {
activeModel: string;
sampleRate: number;
};
general: {
theme: string;
};
onboarding: {
completed: boolean;
};
}

WebSocket / STT Event Types​

TranscriptEvent​

Emitted by the STT WebSocket when speech is recognized.

interface TranscriptEvent {
type: "partial" | "final";
text: string;
}

STTError​

Emitted when an STT error occurs.

interface STTError {
type: "error";
message: string;
}

STTReady​

Emitted when the STT WebSocket is ready to receive audio.

interface STTReady {
type: "ready";
}

Document Types​

AttachedDocument​

Represents a document attached to a session message.

interface AttachedDocument {
id: string;
name: string;
type: string;
content: string;
size: number;
}

API Types​

GenerateRequest​

Request body for the /api/generate endpoint.

interface GenerateRequest {
systemPrompt: string;
messages: Message[];
stream?: boolean;
temperature?: number;
maxTokens?: number;
thinkingEnabled?: boolean;
}

ApiResponse<T>​

Standard API success response wrapper.

interface ApiResponse<T> {
ok: true;
data: T;
}

ApiError​

Standard API error response.

interface ApiError {
ok: false;
error: string;
}