A thread is a linear sequence of turns that maintains a chronological record of interactions between the user and the AI.
inheritance
Cell<typeof ThreadJson>
model_name
type string
model
type Model
turns
type IndexedCollection<Turn>
enabled
type boolean
content
type string
length
type number
token_count
type number
content_preview
type string
constructor
type new (options: ThreadOptions): Thread
options
add_turn
Add a turn to this thread.
type (turn: Turn): void
turn
voidadd_user_turn
Create and add a user turn with the given content.
type (content: string, request?: { created: string & $brand<"Datetime">; provider_name: "ollama" | "claude" | "chatgpt" | "gemini"; model: string; prompt: string; completion_messages?: { ...; }[] | undefined; } | undefined): Turn
content
stringrequest?
{ created: string & $brand<"Datetime">; provider_name: "ollama" | "claude" | "chatgpt" | "gemini"; model: string; prompt: string; completion_messages?: { [x: string]: unknown; role: string; content: string; }[] | undefined; } | undefinedadd_assistant_turn
Create and add an assistant turn with the given content.
type (content: string, json?: Partial<{ id: string & $brand<"Uuid">; created: string & $brand<"Datetime">; updated: string & $brand<"Datetime">; part_ids: (string & $brand<...>)[]; ... 4 more ...; error_message?: string | undefined; }> | undefined): Turn
content
stringjson?
Partial<{ id: string & $brand<"Uuid">; created: string & $brand<"Datetime">; updated: string & $brand<"Datetime">; part_ids: (string & $brand<"Uuid">)[]; ... 4 more ...; error_message?: string | undefined; }> | undefinedadd_system_turn
Create and add a system turn with the given content.
type (content: string): Turn
content
stringadd_turn_from_part
Create and add a turn from a part.
type (part: PartUnion, role: string): Turn
part
role
stringremove_all_turns
Remove all turns from this thread.
type (): void
voidsend_message
Send a message to the AI and create corresponding turns. Returns null if provider is unavailable (defensive check - UI should prevent this).
type (content: string): Promise<Turn | null>
content
stringPromise<Turn | null>switch_model
type (model_id: string & $brand<"Uuid">): void
model_id
string & $brand<"Uuid">void