Conversations — core API
Generated reference for @aparte/core. Conversations and their storage, and the history of one conversation with its branches.
On this page
Classes
Section titled “Classes”AparteConversationController
Section titled “AparteConversationController”Defined in: packages/core/src/conversations/conversation-controller.ts:83
Connects an AparteChatBinding to a AparteConversationManager.
Responsibilities:
- Load messages when
setConversationId(id)is called. - Lazily create a conversation on the first user
aparte-sendif none active. - Persist updates triggered by
aparte-path-changed(branch nav, retry, edit). - Dispatch
aparte-abortwhen the active conversation changes mid-stream.
Usage:
const controller = new AparteConversationController(binding);
const stop = controller.bind();
controller.setConversationId('abc-123');
// …
stop();Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new AparteConversationController(binding, options?): AparteConversationController;Defined in: packages/core/src/conversations/conversation-controller.ts:137
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
binding | AparteChatBinding |
options | AparteConversationControllerOptions |
Returns
Section titled “Returns”Accessors
Section titled “Accessors”activeId
Section titled “activeId”Get Signature
Section titled “Get Signature”get activeId(): string | null;Defined in: packages/core/src/conversations/conversation-controller.ts:143
The current active conversation id (null when none selected).
Returns
Section titled “Returns”string | null
Methods
Section titled “Methods”bind()
Section titled “bind()”bind(): () => void;Defined in: packages/core/src/conversations/conversation-controller.ts:200
Attach event listeners to the binding host. Returns an unbind function.
Returns
Section titled “Returns”() => void
unbind()
Section titled “unbind()”unbind(): void;Defined in: packages/core/src/conversations/conversation-controller.ts:321
Returns
Section titled “Returns”void
setConversationId()
Section titled “setConversationId()”setConversationId(id): Promise<void>;Defined in: packages/core/src/conversations/conversation-controller.ts:385
Switch to (or clear) the active conversation.
null: clears the binding and deselects in the manager.- any id: loads the conversation’s messages into the binding.
Idempotent: calling with the current id forces a re-snapshot from the manager (handy when external mutations could have desynchronised the binding, or when a user re-selects the already-active conv from a sidebar). Streams are only aborted on an actual id change so a same-id reload never kills an in-flight response.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
id | string | null |
Returns
Section titled “Returns”Promise<void>
AparteConversationManager
Section titled “AparteConversationManager”Defined in: packages/core/src/conversations/conversation-manager.ts:126
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new AparteConversationManager(adapter, options?): AparteConversationManager;Defined in: packages/core/src/conversations/conversation-manager.ts:143
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
adapter | AparteStorageAdapter |
options? | ConversationManagerOptions |
Returns
Section titled “Returns”Accessors
Section titled “Accessors”initialized
Section titled “initialized”Get Signature
Section titled “Get Signature”get initialized(): boolean;Defined in: packages/core/src/conversations/conversation-manager.ts:278
Whether init() has completed at least once. Consumers use this to
distinguish “manager still hydrating from storage” from “manager
hydrated, conversations is genuinely empty”. The conversation-controller
relies on this to defer clearing the binding during the IndexedDB
hydration window (Angular APP_INITIALIZER race).
Returns
Section titled “Returns”boolean
conversations
Section titled “conversations”Get Signature
Section titled “Get Signature”get conversations(): AparteConversation[];Defined in: packages/core/src/conversations/conversation-manager.ts:284
Returns
Section titled “Returns”activeId
Section titled “activeId”Get Signature
Section titled “Get Signature”get activeId(): string | null;Defined in: packages/core/src/conversations/conversation-manager.ts:288
Returns
Section titled “Returns”string | null
active
Section titled “active”Get Signature
Section titled “Get Signature”get active(): AparteConversation | null;Defined in: packages/core/src/conversations/conversation-manager.ts:292
Returns
Section titled “Returns”AparteConversation | null
activeConversations
Section titled “activeConversations”Get Signature
Section titled “Get Signature”get activeConversations(): AparteConversation[];Defined in: packages/core/src/conversations/conversation-manager.ts:298
Active conversations (not archived), newest first.
Returns
Section titled “Returns”archivedConversations
Section titled “archivedConversations”Get Signature
Section titled “Get Signature”get archivedConversations(): AparteConversation[];Defined in: packages/core/src/conversations/conversation-manager.ts:305
Archived conversations, newest first.
Returns
Section titled “Returns”Methods
Section titled “Methods”setTitleProvider()
Section titled “setTitleProvider()”setTitleProvider(provider): void;Defined in: packages/core/src/conversations/conversation-manager.ts:156
Replace how a new conversation is titled from its first user message.
null restores the default (the message’s text). The provider is consulted
once per conversation, on that first message; updateTitle is untouched.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
provider | | AparteConversationTitleProvider | null |
Returns
Section titled “Returns”void
getTitleProvider()
Section titled “getTitleProvider()”getTitleProvider():
| AparteConversationTitleProvider
| null;Defined in: packages/core/src/conversations/conversation-manager.ts:161
The registered title provider, or null when the default applies.
Returns
Section titled “Returns”| AparteConversationTitleProvider
| null
init()
Section titled “init()”init(): Promise<void>;Defined in: packages/core/src/conversations/conversation-manager.ts:174
Load all conversations from the adapter. Call once at app startup.
A later call re-reads the list from the store: rows it no longer lists are dropped, and a conversation whose messages are already in memory keeps them — so the one on screen goes on being persisted.
Returns
Section titled “Returns”Promise<void>
isLoaded()
Section titled “isLoaded()”isLoaded(id): boolean;Defined in: packages/core/src/conversations/conversation-manager.ts:221
Whether a conversation’s messages are in memory (always, without split storage).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
id | string |
Returns
Section titled “Returns”boolean
ensureFull()
Section titled “ensureFull()”ensureFull(id): Promise<boolean>;Defined in: packages/core/src/conversations/conversation-manager.ts:233
Fetch a conversation’s messages through the adapter’s loadFull(), the first time
they are needed; later calls resolve at once. The row keeps its place and its meta;
the messages (and the tree) come from the full record, and a message written to
the row while the fetch ran goes after them. Resolves false when the store has no
such record (or answers with another id) — the row is then NOT loaded, and says so,
rather than counting as an empty conversation.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
id | string |
Returns
Section titled “Returns”Promise<boolean>
createNew()
Section titled “createNew()”createNew(title?): Promise<AparteConversation>;Defined in: packages/core/src/conversations/conversation-manager.ts:318
Create a new empty conversation, persist it, and make it active. Untitled by
default: the list shows its locale’s newChat word for an empty title, so the
store never carries an English string a French UI would then display.
Parameters
Section titled “Parameters”| Parameter | Type | Default value |
|---|---|---|
title | string | '' |
Returns
Section titled “Returns”Promise<AparteConversation>
select()
Section titled “select()”select(id): void;Defined in: packages/core/src/conversations/conversation-manager.ts:350
Switch active conversation without touching storage.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
id | string |
Returns
Section titled “Returns”void
clearActive()
Section titled “clearActive()”clearActive(): void;Defined in: packages/core/src/conversations/conversation-manager.ts:357
Deselect the active conversation (no conv selected).
Returns
Section titled “Returns”void
addMessage()
Section titled “addMessage()”addMessage(convId, msg): Promise<void>;Defined in: packages/core/src/conversations/conversation-manager.ts:371
Append a message to a conversation. Auto-generates title from first user message.
One append at a time per conversation: two sends that overlap (a suggestion and a quick type, coalesced into one new conversation) both suspend before reading the record — for the messages, then for the title provider — so both used to read a conversation with no user message in it yet, and the second one’s text became the title.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
convId | string |
msg | AparteMessage |
Returns
Section titled “Returns”Promise<void>
updateMessages()
Section titled “updateMessages()”updateMessages(
convId,
messages,
tree?): Promise<void>;Defined in: packages/core/src/conversations/conversation-manager.ts:418
Replace the flat active-path messages and optionally the full branch tree.
messages is always written (active path, for sidebar/title/compat).
tree is written when provided — it carries the full branching topology.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
convId | string |
messages | AparteMessage[] |
tree? | ExportedMessageRepository |
Returns
Section titled “Returns”Promise<void>
delete()
Section titled “delete()”delete(id): Promise<void>;Defined in: packages/core/src/conversations/conversation-manager.ts:482
Permanently delete a conversation.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
id | string |
Returns
Section titled “Returns”Promise<void>
archive()
Section titled “archive()”archive(id): Promise<void>;Defined in: packages/core/src/conversations/conversation-manager.ts:491
Archive a conversation (soft-delete).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
id | string |
Returns
Section titled “Returns”Promise<void>
unarchive()
Section titled “unarchive()”unarchive(id): Promise<void>;Defined in: packages/core/src/conversations/conversation-manager.ts:526
Restore an archived conversation.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
id | string |
Returns
Section titled “Returns”Promise<void>
pin(id): Promise<void>;Defined in: packages/core/src/conversations/conversation-manager.ts:540
Pin a conversation, which the list shows in its “Pinned” group first. Metadata
only, like archive: updatedAt keeps the conversation’s real chronological slot
for the day it is unpinned. An adapter that has pin() gets the call; one that
does not gets the whole record through save().
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
id | string |
Returns
Section titled “Returns”Promise<void>
unpin()
Section titled “unpin()”unpin(id): Promise<void>;Defined in: packages/core/src/conversations/conversation-manager.ts:546
Unpin a conversation. Metadata only — see pin().
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
id | string |
Returns
Section titled “Returns”Promise<void>
updateTitle()
Section titled “updateTitle()”updateTitle(id, title): Promise<void>;Defined in: packages/core/src/conversations/conversation-manager.ts:555
Update the title manually. The full input is preserved — UI surfaces
(sidebar list, topbar) are responsible for visual truncation via CSS
(min-w-0 + truncate). Auto-titles produced internally by
_autoTitle() remain capped at a sensible length on input.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
id | string |
title | string |
Returns
Section titled “Returns”Promise<void>
subscribe()
Section titled “subscribe()”subscribe(listener): () => void;Defined in: packages/core/src/conversations/conversation-manager.ts:576
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
listener | AparteConversationsListener |
Returns
Section titled “Returns”() => void
AparteMessageRepository
Section titled “AparteMessageRepository”Defined in: packages/core/src/runtime/message-repository.ts:54
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new AparteMessageRepository(): AparteMessageRepository;Returns
Section titled “Returns”Accessors
Section titled “Accessors”headId
Section titled “headId”Get Signature
Section titled “Get Signature”get headId(): string | null;Defined in: packages/core/src/runtime/message-repository.ts:62
ID of the currently active leaf message
Returns
Section titled “Returns”string | null
Methods
Section titled “Methods”getMessages()
Section titled “getMessages()”getMessages(): AparteMessage[];Defined in: packages/core/src/runtime/message-repository.ts:70
Returns the messages on the currently active path, root → head. O(depth).
Returns
Section titled “Returns”getMessage()
Section titled “getMessage()”getMessage(id):
| {
parentId: string | null;
message: AparteMessage;
index: number;
}
| undefined;Defined in: packages/core/src/runtime/message-repository.ts:88
Returns metadata about a specific message, or undefined if not found.
Read methods (getMessage, getMessageById, getBranches) all return
undefined / [] for unknown ids — never throw — so callers can do a
single existence check at the top of a flow rather than wrapping every
call in try/catch.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
id | string |
Returns
Section titled “Returns”| {
parentId: string | null;
message: AparteMessage;
index: number;
}
| undefined
getMessageById()
Section titled “getMessageById()”getMessageById(id): AparteMessage | undefined;Defined in: packages/core/src/runtime/message-repository.ts:102
Returns the mutable message reference, or undefined if not found.
Mutations to the returned object are reflected in getMessages().
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
id | string |
Returns
Section titled “Returns”AparteMessage | undefined
getAllMessages()
Section titled “getAllMessages()”getAllMessages(): AparteMessage[];Defined in: packages/core/src/runtime/message-repository.ts:115
Every message the tree holds — every branch, not just the active path.
getMessages() walks head → root, so a question about the whole conversation
(“is anything still streaming?”) answered from it could not see a turn that a
retry had just taken off the path — and the viewport wrote that turn’s remaining
segments into the bubble which replaced it. No order is promised beyond
insertion: a caller that needs the topology reads export().
Returns
Section titled “Returns”getBranches()
Section titled “getBranches()”getBranches(messageId): string[];Defined in: packages/core/src/runtime/message-repository.ts:126
Returns the IDs of all siblings of messageId
(i.e. all children of its parent, including itself).
Use this to build branch-picker UI.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
messageId | string |
Returns
Section titled “Returns”string[]
addOrUpdateMessage()
Section titled “addOrUpdateMessage()”addOrUpdateMessage(parentId, message): void;Defined in: packages/core/src/runtime/message-repository.ts:140
Add a new message as a child of parentId (null = root).
If a message with the same id already exists, updates its data
and re-links it under the correct parent.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
parentId | string | null |
message | AparteMessage |
Returns
Section titled “Returns”void
switchToBranch()
Section titled “switchToBranch()”switchToBranch(messageId): void;Defined in: packages/core/src/runtime/message-repository.ts:182
Switch the active branch to messageId.
Updates next on the parent chain so getMessages() reflects the change.
Advances head to the deepest active node in the new branch.
Silent no-op for unknown ids — mutation methods (switchToBranch,
resetHead, updateMessage, clearChildren) never throw.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
messageId | string |
Returns
Section titled “Returns”void
resetHead()
Section titled “resetHead()”resetHead(messageId): void;Defined in: packages/core/src/runtime/message-repository.ts:200
Remove all descendants of messageId (inclusive) and, when the head was among
them, set head to the parent of messageId. Used by edit/truncate flows.
A head in a branch this call did not touch stays where it is: it used to be relocated regardless, which took the active path out of the version the reader was on for a truncate somewhere else entirely.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
messageId | string | The first message to remove |
Returns
Section titled “Returns”void
updateMessage()
Section titled “updateMessage()”updateMessage(messageId, updates): void;Defined in: packages/core/src/runtime/message-repository.ts:233
Update a message’s data without changing its position in the tree.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
messageId | string |
updates | Partial<AparteMessage> |
Returns
Section titled “Returns”void
clearChildren()
Section titled “clearChildren()”clearChildren(parentId): void;Defined in: packages/core/src/runtime/message-repository.ts:244
Remove ALL children of parentId (and their descendants) and set head
to parentId. Used by edit to discard every previous response before
re-generating — ensures the new response starts with sibling count = 1.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
parentId | string |
Returns
Section titled “Returns”void
clear()
Section titled “clear()”clear(): void;Defined in: packages/core/src/runtime/message-repository.ts:261
Remove all messages and reset to empty state.
Returns
Section titled “Returns”void
import()
Section titled “import()”import(exported): void;Defined in: packages/core/src/runtime/message-repository.ts:274
Import a previously-exported snapshot, rebuilding the full tree and
restoring the active head. Replaces any existing content (calls clear()
first). Messages must be in topological order (parent before child) —
this is guaranteed by export() since _nodes is an insertion-order
Map and parents are always inserted before their children.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
exported | ExportedMessageRepository |
Returns
Section titled “Returns”void
export()
Section titled “export()”export(): ExportedMessageRepository;Defined in: packages/core/src/runtime/message-repository.ts:321
Export the full tree for serialisation or debugging. Compatible with the assistant-ui ExportedMessageRepository format.
Walked from the root through each node’s children, so a parent is always
written before its children. It used to iterate _nodes in insertion order and
call that topological — which holds until _relink re-parents an EXISTING node
under one inserted after it (addOrUpdateMessage with a known id and a newer
parent). The snapshot then listed the child first, and import() threw “parent
not found” on the very tree this method had just produced.
Returns
Section titled “Returns”Variables
Section titled “Variables”APARTE_CONVERSATION_SCHEMA_VERSION
Section titled “APARTE_CONVERSATION_SCHEMA_VERSION”const APARTE_CONVERSATION_SCHEMA_VERSION: 2;Defined in: packages/core/src/conversations/types.ts:14
Current schema version for AparteConversation. Bump when the persisted
shape evolves so adapters / migrations can branch on it.
v1: monolithic — messages[] inline on the conversation row, attachment
url was a session-scoped blob URL (lost on reload), artifacts inline
in segments only.
v2: split — meta-only conversation row; messages and attachments (with real
Blobs) get their own table. Sidebar can list without loading full payloads.
Interfaces
Section titled “Interfaces”AparteChatBinding
Section titled “AparteChatBinding”Defined in: packages/core/src/conversations/conversation-controller.ts:19
Abstract binding between a chat UI and the conversation lifecycle.
Each framework wrapper (Angular, React, Vue, Svelte) provides an implementation that knows how to mutate its own message list. The controller orchestrates loading, persistence and abort using only this interface, keeping the conversation engine fully framework-agnostic.
Properties
Section titled “Properties”hostId
Section titled “hostId”readonly hostId: string;Defined in: packages/core/src/conversations/conversation-controller.ts:21
Stable id of the host element (used as targetId for scoped events).
readonly host: HTMLElement;Defined in: packages/core/src/conversations/conversation-controller.ts:23
The element that emits/receives aparte-send and aparte-path-changed.
Methods
Section titled “Methods”setMessages()
Section titled “setMessages()”setMessages(messages): void;Defined in: packages/core/src/conversations/conversation-controller.ts:25
Replace the entire message list (used when switching conversations).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
messages | AparteMessage[] |
Returns
Section titled “Returns”void
appendMessage()
Section titled “appendMessage()”appendMessage(message): void;Defined in: packages/core/src/conversations/conversation-controller.ts:27
Append a single message (used for the optimistic user-msg on send).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
message | AparteMessage |
Returns
Section titled “Returns”void
getMessages()
Section titled “getMessages()”getMessages(): AparteMessage[];Defined in: packages/core/src/conversations/conversation-controller.ts:29
Read the current message list.
Returns
Section titled “Returns”clearMessages()
Section titled “clearMessages()”clearMessages(options?): void;Defined in: packages/core/src/conversations/conversation-controller.ts:31
Clear all messages (e.g. when starting a new conversation).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options? | { revokeAttachments?: boolean; } |
options.revokeAttachments? | boolean |
Returns
Section titled “Returns”void
setLoading()?
Section titled “setLoading()?”optional setLoading(loading): void;Defined in: packages/core/src/conversations/conversation-controller.ts:36
The transcript is on its way, or no longer: a conversation was chosen and its
messages are being fetched. The DOM binding sets the viewport’s loading.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
loading | boolean |
Returns
Section titled “Returns”void
exportTree()?
Section titled “exportTree()?”optional exportTree(): ExportedMessageRepository | undefined;Defined in: packages/core/src/conversations/conversation-controller.ts:42
Export the full conversation tree for persistence.
Optional: only available when the binding wraps a AparteMessageRepository
(e.g. the vanilla viewport). Returns undefined when not supported.
Returns
Section titled “Returns”ExportedMessageRepository | undefined
importTree()?
Section titled “importTree()?”optional importTree(tree): void;Defined in: packages/core/src/conversations/conversation-controller.ts:49
Import a previously-persisted tree snapshot, restoring full branch
topology. Called by the controller after setMessages (which handles
cleanup) when the loaded conversation carries a tree field.
Optional: falls back to the flat setMessages load when absent.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
tree | ExportedMessageRepository |
Returns
Section titled “Returns”void
AparteConversationControllerOptions
Section titled “AparteConversationControllerOptions”Defined in: packages/core/src/conversations/conversation-controller.ts:52
Properties
Section titled “Properties”manager?
Section titled “manager?”optional manager?: AparteConversationManager;Defined in: packages/core/src/conversations/conversation-controller.ts:57
Conversation manager. If omitted, the controller resolves it from
aparteGlobalConfig.getConversationManager() when first needed.
onConversationCreated?
Section titled “onConversationCreated?”optional onConversationCreated?: (id) => void;Defined in: packages/core/src/conversations/conversation-controller.ts:62
Called whenever a new conversation is created lazily (on first user message in an empty thread). Useful for the parent app to sync the URL.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
id | string |
Returns
Section titled “Returns”void
ConversationManagerOptions
Section titled “ConversationManagerOptions”Defined in: packages/core/src/conversations/conversation-manager.ts:22
Properties
Section titled “Properties”titleProvider?
Section titled “titleProvider?”optional titleProvider?: AparteConversationTitleProvider;Defined in: packages/core/src/conversations/conversation-manager.ts:27
Titles a new conversation from its first user message, instead of the default
(the message’s text). Same as calling setTitleProvider after construction.
retention?
Section titled “retention?”optional retention?: {
maxMessages: number;
};Defined in: packages/core/src/conversations/conversation-manager.ts:35
Opt-in history retention. When set, updateMessages() trims a persisted
conversation to at most maxMessages on the active path (dropping the
oldest history and the branches hanging off it) before writing to storage.
Omit for unbounded history (the default) — retention is a deliberate
consumer choice, never silent.
maxMessages
Section titled “maxMessages”maxMessages: number;AparteConversation
Section titled “AparteConversation”Defined in: packages/core/src/conversations/types.ts:19
A single conversation (thread) — framework-agnostic.
Properties
Section titled “Properties”id: string;Defined in: packages/core/src/conversations/types.ts:20
title: string;Defined in: packages/core/src/conversations/types.ts:27
The title. Decided by the manager from the first user message (the text as
typed, or what the title provider returns), or typed by the user. Empty when
the conversation has no text yet: the list shows its locale’s newChat word,
and the store never carries a UI string.
autoTitle?
Section titled “autoTitle?”optional autoTitle?: boolean;Defined in: packages/core/src/conversations/types.ts:35
true while the title is the manager’s decision. Editing the first user
message then re-titles; a title typed by the user (updateTitle) clears it
and is kept whatever happens to the messages. Absent on records written
before this field existed, which reads as “typed”: an old title is never
overwritten.
createdAt
Section titled “createdAt”createdAt: number;Defined in: packages/core/src/conversations/types.ts:36
updatedAt
Section titled “updatedAt”updatedAt: number;Defined in: packages/core/src/conversations/types.ts:37
messages
Section titled “messages”messages: AparteMessage[];Defined in: packages/core/src/conversations/types.ts:38
optional tree?: ExportedMessageRepository;Defined in: packages/core/src/conversations/types.ts:47
Full branching tree snapshot. When present, the conversation has branch
history (edits, retries, sibling responses) and is loaded via importTree
rather than the flat messages array.
messages always mirrors the active path for backward-compatibility
(sidebar previews, title generation, adapters that only read flat arrays).
archivedAt?
Section titled “archivedAt?”optional archivedAt?: number;Defined in: packages/core/src/conversations/types.ts:49
When truthy the conversation is archived (hidden from the main list).
pinnedAt?
Section titled “pinnedAt?”optional pinnedAt?: number;Defined in: packages/core/src/conversations/types.ts:51
When truthy the conversation is pinned at the top of the list.
schemaVersion?
Section titled “schemaVersion?”optional schemaVersion?: number;Defined in: packages/core/src/conversations/types.ts:56
Schema version of this record. Absent on legacy data (pre-versioning):
adapters should treat undefined as version 0 and migrate on read.
AparteConversationMeta
Section titled “AparteConversationMeta”Defined in: packages/core/src/conversations/types.ts:64
Lightweight conversation meta — what’s needed to render the sidebar without
loading the full message history. Returned by loadMeta() and stored as a
dedicated row by split-storage adapters.
Properties
Section titled “Properties”id: string;Defined in: packages/core/src/conversations/types.ts:65
title: string;Defined in: packages/core/src/conversations/types.ts:66
createdAt
Section titled “createdAt”createdAt: number;Defined in: packages/core/src/conversations/types.ts:67
updatedAt
Section titled “updatedAt”updatedAt: number;Defined in: packages/core/src/conversations/types.ts:68
archivedAt?
Section titled “archivedAt?”optional archivedAt?: number;Defined in: packages/core/src/conversations/types.ts:69
pinnedAt?
Section titled “pinnedAt?”optional pinnedAt?: number;Defined in: packages/core/src/conversations/types.ts:70
schemaVersion?
Section titled “schemaVersion?”optional schemaVersion?: number;Defined in: packages/core/src/conversations/types.ts:72
Persisted schema version of the row.
AparteAttachmentRow
Section titled “AparteAttachmentRow”Defined in: packages/core/src/conversations/types.ts:81
Persisted attachment with the actual Blob — survives page reloads, unlike
the session-scoped URL.createObjectURL() stored on AparteMessage.
Adapters that split storage MUST keep the blob here and reconstruct the
url on demand.
Properties
Section titled “Properties”id: string;Defined in: packages/core/src/conversations/types.ts:82
convId
Section titled “convId”convId: string;Defined in: packages/core/src/conversations/types.ts:83
msgId: string;Defined in: packages/core/src/conversations/types.ts:84
name: string;Defined in: packages/core/src/conversations/types.ts:85
mimeType
Section titled “mimeType”mimeType: string;Defined in: packages/core/src/conversations/types.ts:86
size: number;Defined in: packages/core/src/conversations/types.ts:87
blob: Blob;Defined in: packages/core/src/conversations/types.ts:88
AparteStorageAdapter
Section titled “AparteStorageAdapter”Defined in: packages/core/src/conversations/types.ts:109
Implement this interface to provide persistence for conversations. All methods are async so any backend (IndexedDB, SQLite WASM, REST API…) can be used. The AparteConversationManager never touches storage directly.
The first three methods (loadAll, save, delete) form the minimum
viable adapter — everything else is optional and lets richer backends
expose split-storage features (fast meta listing, attachment blobs).
What is NOT here, on purpose: memory facts, a settings key/value store, an
artifact gallery index. Each is a product’s own table — the shape of a “memory
fact” or of a settings entry is the app’s decision — and a public contract
carrying one app’s schema binds every other adapter to it. An app that needs
them extends this interface in its own code. Nor is a row’s own bookkeeping: a
folder id, a cached last-message preview, a message count and a token total are
things a store computes for itself, so they live on the adapter’s own row shape
rather than on AparteConversation / AparteConversationMeta.
Methods
Section titled “Methods”loadAll()
Section titled “loadAll()”loadAll(): Promise<AparteConversation[]>;Defined in: packages/core/src/conversations/types.ts:111
Return all stored conversations (full payload), ordered by updatedAt desc.
Returns
Section titled “Returns”Promise<AparteConversation[]>
save()
Section titled “save()”save(conv): Promise<void>;Defined in: packages/core/src/conversations/types.ts:113
Upsert a conversation (create or update).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
conv | AparteConversation |
Returns
Section titled “Returns”Promise<void>
delete()
Section titled “delete()”delete(id): Promise<void>;Defined in: packages/core/src/conversations/types.ts:115
Permanently delete a conversation by id (cascades related rows).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
id | string |
Returns
Section titled “Returns”Promise<void>
archive()?
Section titled “archive()?”optional archive(id): Promise<void>;Defined in: packages/core/src/conversations/types.ts:117
Archive a conversation (soft-delete). Optional.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
id | string |
Returns
Section titled “Returns”Promise<void>
unarchive()?
Section titled “unarchive()?”optional unarchive(id): Promise<void>;Defined in: packages/core/src/conversations/types.ts:119
Restore an archived conversation. Optional.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
id | string |
Returns
Section titled “Returns”Promise<void>
loadMeta()?
Section titled “loadMeta()?”optional loadMeta(): Promise<AparteConversationMeta[]>;Defined in: packages/core/src/conversations/types.ts:128
Fast sidebar listing. Returns lightweight meta only (no messages).
Order is updatedAt desc. Adapters without split storage can omit
this — callers should fall back to loadAll() mapping to meta.
Returns
Section titled “Returns”Promise<AparteConversationMeta[]>
loadFull()?
Section titled “loadFull()?”optional loadFull(id): Promise<AparteConversation | null>;Defined in: packages/core/src/conversations/types.ts:130
Lazy-load a single conversation’s full payload by id.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
id | string |
Returns
Section titled “Returns”Promise<AparteConversation | null>
pin()?
Section titled “pin()?”optional pin(id): Promise<void>;Defined in: packages/core/src/conversations/types.ts:132
Pin/unpin (pinnedAt-aware sidebar sort).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
id | string |
Returns
Section titled “Returns”Promise<void>
unpin()?
Section titled “unpin()?”optional unpin(id): Promise<void>;Defined in: packages/core/src/conversations/types.ts:133
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
id | string |
Returns
Section titled “Returns”Promise<void>
rename()?
Section titled “rename()?”optional rename(id, title): Promise<void>;Defined in: packages/core/src/conversations/types.ts:135
Update only the conversation title (avoids rewriting messages).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
id | string |
title | string |
Returns
Section titled “Returns”Promise<void>
loadAttachments()?
Section titled “loadAttachments()?”optional loadAttachments(msgId): Promise<AparteAttachmentRow[]>;Defined in: packages/core/src/conversations/types.ts:140
Persisted attachment blobs for a single message.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
msgId | string |
Returns
Section titled “Returns”Promise<AparteAttachmentRow[]>
Type Aliases
Section titled “Type Aliases”AparteConversationsListener
Section titled “AparteConversationsListener”type AparteConversationsListener = (conversations) => void;Defined in: packages/core/src/conversations/conversation-manager.ts:9
What AparteConversationManager.subscribe calls with the list, on every change.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
conversations | AparteConversation[] |
Returns
Section titled “Returns”void
AparteConversationTitleProvider
Section titled “AparteConversationTitleProvider”type AparteConversationTitleProvider = (text, message) => string | Promise<string>;Defined in: packages/core/src/conversations/conversation-manager.ts:20
Titles a conversation from its first user message.
Receives the message’s text and the message itself, and returns the title —
synchronously or not. An empty answer, or a throw, leaves
the default title (the text as typed), so a titler that fails never loses the
message from the sidebar. Registered with AparteConversationManager.setTitleProvider;
@aparte/plugin-titler binds one to an aparte-titler model.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
text | string |
message | AparteMessage |
Returns
Section titled “Returns”string | Promise<string>
ExportedMessageRepository
Section titled “ExportedMessageRepository”type ExportedMessageRepository = {
headId: string | null;
messages: {
message: AparteMessage;
parentId: string | null;
}[];
};Defined in: packages/core/src/runtime/message-repository.ts:38
Exported format — compatible with serialisation
Properties
Section titled “Properties”headId
Section titled “headId”headId: string | null;Defined in: packages/core/src/runtime/message-repository.ts:39
messages
Section titled “messages”messages: {
message: AparteMessage;
parentId: string | null;
}[];Defined in: packages/core/src/runtime/message-repository.ts:40
message
Section titled “message”message: AparteMessage;parentId
Section titled “parentId”parentId: string | null;Event details
Section titled “Event details”AparteConversationLoadedDetail
Section titled “AparteConversationLoadedDetail”Defined in: packages/core/src/conversations/types.ts:152
Detail payload for aparte-conversation-loaded.
Dispatched by the conversation controller on the chat’s host, bubbling, once a
conversation’s messages are on screen — after a load that succeeded and that the user
did not leave meanwhile. The moment to resume a turn a server loop paused (AparteClient
does it on its own), to scroll or to measure.
aparte-conversation-loaded
Properties
Section titled “Properties”targetId
Section titled “targetId”targetId: string;Defined in: packages/core/src/conversations/types.ts:154
The chat’s host id — the targetId every scoped event carries.
conversationId
Section titled “conversationId”conversationId: string;Defined in: packages/core/src/conversations/types.ts:155