Skip to content

Defined in: packages/core/src/conversations/conversation-controller.ts:107

Connects an AparteChatBinding to a AparteConversationManager.

Responsibilities:

  • Load messages when setConversationId(id) is called.
  • Lazily create a conversation on the first user aparte-send if none active.
  • Persist updates triggered by aparte-path-changed (branch nav, retry, edit).
  • Dispatch aparte-abort when the active conversation changes mid-stream.

Usage:

ts
const controller = new AparteConversationController(binding);
const stop = controller.bind();
controller.setConversationId('abc-123');
// …
stop();
ts
new AparteConversationController(binding, options?): AparteConversationController;

Defined in: packages/core/src/conversations/conversation-controller.ts:167

ParameterType
bindingAparteChatBinding
optionsAparteConversationControllerOptions

AparteConversationController

ts
get activeId(): string | null;

Defined in: packages/core/src/conversations/conversation-controller.ts:173

The current active conversation id (null when none selected).

string | null

ts
bind(): () => void;

Defined in: packages/core/src/conversations/conversation-controller.ts:263

Attach event listeners to the binding host. Returns an unbind function.

() => void

ts
unbind(): void;

Defined in: packages/core/src/conversations/conversation-controller.ts:416

void

ts
setConversationId(id): Promise<void>;

Defined in: packages/core/src/conversations/conversation-controller.ts:495

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.

ParameterType
idstring | null

Promise<void>


Defined in: packages/core/src/conversations/conversation-manager.ts:190

ts
new AparteConversationManager(adapter, options?): AparteConversationManager;

Defined in: packages/core/src/conversations/conversation-manager.ts:212

ParameterType
adapterAparteStorageAdapter
options?ConversationManagerOptions

AparteConversationManager

ts
get adapter(): AparteStorageAdapter;

Defined in: packages/core/src/conversations/conversation-manager.ts:208

The store this manager writes to.

AparteStorageAdapter

ts
get initialized(): boolean;

Defined in: packages/core/src/conversations/conversation-manager.ts:347

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).

boolean

ts
get conversations(): AparteConversation[];

Defined in: packages/core/src/conversations/conversation-manager.ts:353

AparteConversation[]

ts
get activeId(): string | null;

Defined in: packages/core/src/conversations/conversation-manager.ts:357

string | null

ts
get active(): AparteConversation | null;

Defined in: packages/core/src/conversations/conversation-manager.ts:361

AparteConversation | null

ts
get activeConversations(): AparteConversation[];

Defined in: packages/core/src/conversations/conversation-manager.ts:367

Active conversations (not archived), newest first.

AparteConversation[]

ts
get archivedConversations(): AparteConversation[];

Defined in: packages/core/src/conversations/conversation-manager.ts:374

Archived conversations, newest first.

AparteConversation[]

ts
setTitleProvider(provider): void;

Defined in: packages/core/src/conversations/conversation-manager.ts:225

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.

ParameterType
provider| AparteConversationTitleProvider | null

void

ts
getTitleProvider(): 
  | AparteConversationTitleProvider
  | null;

Defined in: packages/core/src/conversations/conversation-manager.ts:230

The registered title provider, or null when the default applies.

| AparteConversationTitleProvider | null

ts
init(): Promise<void>;

Defined in: packages/core/src/conversations/conversation-manager.ts:243

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.

Promise<void>

ts
isLoaded(id): boolean;

Defined in: packages/core/src/conversations/conversation-manager.ts:290

Whether a conversation’s messages are in memory (always, without split storage).

ParameterType
idstring

boolean

ts
ensureFull(id): Promise<boolean>;

Defined in: packages/core/src/conversations/conversation-manager.ts:302

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.

ParameterType
idstring

Promise<boolean>

ts
createNew(title?): Promise<AparteConversation>;

Defined in: packages/core/src/conversations/conversation-manager.ts:387

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.

ParameterTypeDefault value
titlestring''

Promise<AparteConversation>

ts
select(id): void;

Defined in: packages/core/src/conversations/conversation-manager.ts:419

Switch active conversation without touching storage.

ParameterType
idstring

void

ts
clearActive(): void;

Defined in: packages/core/src/conversations/conversation-manager.ts:426

Deselect the active conversation (no conv selected).

void

ts
addMessage(convId, msg): Promise<void>;

Defined in: packages/core/src/conversations/conversation-manager.ts:440

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 the queue keeps the second one from reading a conversation with no user message in it yet and taking its text as the title.

ParameterType
convIdstring
msgAparteMessage

Promise<void>

ts
updateMessages(
   convId, 
   messages, 
tree?): Promise<void>;

Defined in: packages/core/src/conversations/conversation-manager.ts:488

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.

ParameterType
convIdstring
messagesAparteMessage[]
tree?ExportedMessageRepository

Promise<void>

ts
delete(id): Promise<void>;

Defined in: packages/core/src/conversations/conversation-manager.ts:566

Permanently delete a conversation.

ParameterType
idstring

Promise<void>

ts
archive(id): Promise<void>;

Defined in: packages/core/src/conversations/conversation-manager.ts:575

Archive a conversation (soft-delete).

ParameterType
idstring

Promise<void>

ts
unarchive(id): Promise<void>;

Defined in: packages/core/src/conversations/conversation-manager.ts:610

Restore an archived conversation.

ParameterType
idstring

Promise<void>

ts
pin(id): Promise<void>;

Defined in: packages/core/src/conversations/conversation-manager.ts:624

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().

ParameterType
idstring

Promise<void>

ts
unpin(id): Promise<void>;

Defined in: packages/core/src/conversations/conversation-manager.ts:630

Unpin a conversation. Metadata only — see pin().

ParameterType
idstring

Promise<void>

ts
updateTitle(id, title): Promise<void>;

Defined in: packages/core/src/conversations/conversation-manager.ts:639

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.

ParameterType
idstring
titlestring

Promise<void>

ts
subscribe(listener): () => void;

Defined in: packages/core/src/conversations/conversation-manager.ts:660

ParameterType
listenerAparteConversationsListener

() => void


Defined in: packages/core/src/runtime/message-repository.ts:54

ts
new AparteMessageRepository(): AparteMessageRepository;

AparteMessageRepository

ts
get headId(): string | null;

Defined in: packages/core/src/runtime/message-repository.ts:62

ID of the currently active leaf message

string | null

ts
getMessages(): AparteMessage[];

Defined in: packages/core/src/runtime/message-repository.ts:70

Returns the messages on the currently active path, root → head. O(depth).

AparteMessage[]

ts
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.

ParameterType
idstring

| { parentId: string | null; message: AparteMessage; index: number; } | undefined

ts
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().

ParameterType
idstring

AparteMessage | undefined

ts
getAllMessages(): AparteMessage[];

Defined in: packages/core/src/runtime/message-repository.ts:114

Every message the tree holds — every branch, not just the active path.

Unlike getMessages(), which walks head → root, this also sees a turn that a retry has taken off the active path, so it answers questions about the whole conversation (“is anything still streaming?”). No order is promised beyond insertion: a caller that needs the topology reads export().

AparteMessage[]

ts
getBranches(messageId): string[];

Defined in: packages/core/src/runtime/message-repository.ts:125

Returns the IDs of all siblings of messageId (i.e. all children of its parent, including itself). Use this to build branch-picker UI.

ParameterType
messageIdstring

string[]

ts
addOrUpdateMessage(parentId, message): void;

Defined in: packages/core/src/runtime/message-repository.ts:139

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.

ParameterType
parentIdstring | null
messageAparteMessage

void

ts
switchToBranch(messageId): void;

Defined in: packages/core/src/runtime/message-repository.ts:181

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.

ParameterType
messageIdstring

void

ts
resetHead(messageId): void;

Defined in: packages/core/src/runtime/message-repository.ts:197

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.

ParameterTypeDescription
messageIdstringThe first message to remove

void

ts
updateMessage(messageId, updates): void;

Defined in: packages/core/src/runtime/message-repository.ts:230

Update a message’s data without changing its position in the tree.

ParameterType
messageIdstring
updatesPartial<AparteMessage>

void

ts
clearChildren(parentId): void;

Defined in: packages/core/src/runtime/message-repository.ts:241

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.

ParameterType
parentIdstring

void

ts
clear(): void;

Defined in: packages/core/src/runtime/message-repository.ts:258

Remove all messages and reset to empty state.

void

ts
import(exported): void;

Defined in: packages/core/src/runtime/message-repository.ts:270

Import a previously-exported snapshot, rebuilding the full tree and restoring the active head. Replaces any existing content (calls clear() first). export() writes messages in topological order (parent before child), which is the order this expects.

ParameterType
exportedExportedMessageRepository

void

ts
export(): ExportedMessageRepository;

Defined in: packages/core/src/runtime/message-repository.ts:314

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, even after addOrUpdateMessage re-parented an existing node under a newer one; import() relies on that order.

ExportedMessageRepository


ts
function historyFromCheckpoint(path): {
  summary?: string;
  messages: AparteMessage[];
};

Defined in: packages/core/src/context/checkpoint.ts:25

The part of a path the model reads, and the summary that stands for the rest.

A checkpoint is contextSummary on a message: from it on the model reads the summary in place of everything before. The LAST message carrying one wins — a later checkpoint was written over the earlier summary (it asked for an update of it), so the earlier one is already inside it. Everything before the winner is dropped from the result, a legacy compaction: true message included: that notice is itself part of what the checkpoint summarised, and sending it beside the summary would say the same thing twice.

With no checkpoint the path comes back unchanged and no summary is returned, so a caller can use it unconditionally. Nothing is deleted from the transcript — this reads a path and returns a view of it.

Call it on the FULL path, the unanswered user message at its end included: the checkpoint can sit on that very message (a turn retried after an overflow), and the summary still has to go out before it.

AparteClient applies it to every history it builds. A history function handed to the client receives the whole transcript and can call this itself.

ParameterType
pathAparteMessage[]
ts
{
  summary?: string;
  messages: AparteMessage[];
}
ts
optional summary?: string;
ts
messages: AparteMessage[];

ts
function estimateTokens(text): number;

Defined in: packages/core/src/context/measure.ts:17

Token heuristic (FR ~3.5 chars/tok, EN ~4 chars/tok).

Accurate to ±10% — enough for budgeting, and it avoids a tokenizer, which costs ~5ms per message × N (too slow to run on every turn) and is one more dependency per model family. It is the ONE estimate: the compaction plugin’s budget and selector, the gauge, and the number the client records on a reply all read it, so the figures they show and the decisions they take cannot disagree about what a message costs.

ParameterType
textstring | null | undefined

number


ts
function estimateWireTokens(messages): number;

Defined in: packages/core/src/context/measure.ts:79

The estimate of what the wire sends for these messages: the same serialisation the client builds its history with (wireMessages) — a reply’s thinking is not sent, its text is, and a tool call and its result count as the envelope and the tool message the wire carries. A failed turn and one still in flight send nothing.

Not estimateTokens(message.content): assistant replies keep their text in segments with content empty, so that sum would read a whole conversation as free.

ParameterType
messagesAparteMessage[]

number


ts
function measureContext(input): AparteContextMeasure;

Defined in: packages/core/src/context/measure.ts:218

The one measure of the context window, for the gauge and for the compaction plugin.

used is the last reply’s REAL usage while nothing the model reads has changed since it: the reply is the last message of the path, and no checkpoint was written after it. Once something has (a message was added, a compaction ran), the real number describes a request that will not be sent again, so used becomes an estimate of the request that WOULD be sent — the system prompts, the tool definitions, the checkpoint’s summary and the messages after it — scaled by k, how far the heuristic was off on the last reply: its real input tokens over the estimate recorded when it was sent (AparteMessage.contextEstimate), clamped to [0.5, 3] so one odd reply cannot throw the reading, and 1 when the reply has no estimate. After a compaction the reading is therefore the size of the new, smaller view, never the stale one from before it, and never a k computed against a history the reply did not see.

k compares like with like or it is 1. The estimate is of the FIRST request a turn sent and the usage is of its LAST call, which also read the calls and their results, so a reply that called tools says nothing about the heuristic’s error and counts as 1. A request the heuristic could not read whole (an image) records no estimate at all.

While nothing has changed, used is what the NEXT request will carry: the input the provider reported, plus the reply as it goes back on the wire. A provider’s output count includes the reasoning it generated, and a reply’s thinking is not sent again, so for a reply that thought the answer is read from the transcript (the part after its last call, which is all the final call added to what it read) and not from the output count.

The parts are not scaled: they stay the raw estimates, so a reader can see what the measure is made of.

ParameterType
inputAparteContextMeasureInput

AparteContextMeasure


ts
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.


Defined in: packages/core/src/context/measure.ts:121

What fills the model’s window, as one reading. used is the total the gauge draws; parts say where it goes.

The parts are RAW estimates (the character heuristic, uncalibrated), so they are labelled as estimates wherever they are shown and need not add up to used: the difference, other, is what the heuristic cannot see — a server loop’s own system prompt and tools, the chat template’s tokens, the heuristic’s own error.

ts
optional window?: number;

Defined in: packages/core/src/context/measure.ts:123

The window used is measured against, when one is known.

ts
used: number;

Defined in: packages/core/src/context/measure.ts:125

Tokens in use: the last reply’s reported usage, or an estimate of the request the next turn would send.

ts
estimated: boolean;

Defined in: packages/core/src/context/measure.ts:127

true when used is an estimate — something changed in what the model reads since the last reply reported.

ts
parts: {
  system: number;
  tools: number;
  summary: number;
  messages: number;
};

Defined in: packages/core/src/context/measure.ts:129

Raw estimates, in tokens, of what the model reads: the system prompts, the tool definitions, the checkpoint’s summary, the messages after it.

ts
system: number;
ts
tools: number;
ts
summary: number;
ts
messages: number;
ts
other: number;

Defined in: packages/core/src/context/measure.ts:131

used less the parts, never below zero.


Defined in: packages/core/src/context/measure.ts:135

What measureContext reads.

ts
messages: AparteMessage[];

Defined in: packages/core/src/context/measure.ts:137

The ACTIVE path of the conversation, checkpoint and all — not the view after it.

ts
config: AparteConfig;

Defined in: packages/core/src/context/measure.ts:139

The config that resolves the system prompt, the tools and the current model.

ts
optional windowOverride?: number | null;

Defined in: packages/core/src/context/measure.ts:141

A window that wins over the current model’s, for a page that knows better (the gauge’s window attribute).

ts
optional viewChanged?: boolean;

Defined in: packages/core/src/context/measure.ts:147

The caller knows what the model reads has changed since the last reply although the messages cannot say so — a Restore takes checkpoints off, and nothing is left on the path to date it. Forces an estimate.


Defined in: packages/core/src/conversations/conversation-controller.ts:24

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.

ts
readonly hostId: string;

Defined in: packages/core/src/conversations/conversation-controller.ts:26

Stable id of the host element (used as targetId for scoped events).

ts
readonly host: HTMLElement;

Defined in: packages/core/src/conversations/conversation-controller.ts:28

The element that emits/receives aparte-send and aparte-path-changed.

ts
setMessages(messages): void;

Defined in: packages/core/src/conversations/conversation-controller.ts:30

Replace the entire message list (used when switching conversations).

ParameterType
messagesAparteMessage[]

void

ts
appendMessage(message): void;

Defined in: packages/core/src/conversations/conversation-controller.ts:32

Append a single message (used for the optimistic user-msg on send).

ParameterType
messageAparteMessage

void

ts
getMessages(): AparteMessage[];

Defined in: packages/core/src/conversations/conversation-controller.ts:34

Read the current message list.

AparteMessage[]

ts
clearMessages(options?): void;

Defined in: packages/core/src/conversations/conversation-controller.ts:36

Clear all messages (e.g. when starting a new conversation).

ParameterType
options?{ revokeAttachments?: boolean; }
options.revokeAttachments?boolean

void

ts
optional setLoading(loading): void;

Defined in: packages/core/src/conversations/conversation-controller.ts:41

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.

ParameterType
loadingboolean

void

ts
optional exportTree(): ExportedMessageRepository | undefined;

Defined in: packages/core/src/conversations/conversation-controller.ts:47

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.

ExportedMessageRepository | undefined

ts
optional importTree(tree): void;

Defined in: packages/core/src/conversations/conversation-controller.ts:54

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.

ParameterType
treeExportedMessageRepository

void

ts
optional afterRender(cb): void;

Defined in: packages/core/src/conversations/conversation-controller.ts:61

Run a callback after the framework has applied its latest render. Optional: a binding whose list is current the moment it is written (the vanilla viewport) leaves it out. One that renders late — a transcript kept in a framework store — declares it, so a save waits for the list to arrive instead of writing the old one.

ParameterType
cb() => void

void


Defined in: packages/core/src/conversations/conversation-controller.ts:70

ts
optional keepDrafts?: boolean;

Defined in: packages/core/src/conversations/conversation-controller.ts:76

Keep what was typed in each conversation, and give it back on return. In memory, unless the storage adapter has loadDraft and saveDraft. A pill comes back as its text. Default: false.

ts
optional manager?: AparteConversationManager;

Defined in: packages/core/src/conversations/conversation-controller.ts:81

Conversation manager. If omitted, the controller resolves it from aparteGlobalConfig.getConversationManager() when first needed.

ts
optional onConversationCreated?: (id) => void;

Defined in: packages/core/src/conversations/conversation-controller.ts:86

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.

ParameterType
idstring

void


Defined in: packages/core/src/conversations/conversation-manager.ts:23

ts
optional titleProvider?: AparteConversationTitleProvider;

Defined in: packages/core/src/conversations/conversation-manager.ts:28

Titles a new conversation from its first user message, instead of the default (the message’s text). Same as calling setTitleProvider after construction.

ts
optional retention?: {
  maxMessages: number;
};

Defined in: packages/core/src/conversations/conversation-manager.ts:36

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.

ts
maxMessages: number;

Defined in: packages/core/src/conversations/types.ts:19

A single conversation (thread) — framework-agnostic.

ts
id: string;

Defined in: packages/core/src/conversations/types.ts:20

ts
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.

ts
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.

ts
createdAt: number;

Defined in: packages/core/src/conversations/types.ts:36

ts
updatedAt: number;

Defined in: packages/core/src/conversations/types.ts:37

ts
messages: AparteMessage[];

Defined in: packages/core/src/conversations/types.ts:38

ts
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).

ts
optional archivedAt?: number;

Defined in: packages/core/src/conversations/types.ts:49

When truthy the conversation is archived (hidden from the main list).

ts
optional pinnedAt?: number;

Defined in: packages/core/src/conversations/types.ts:51

When truthy the conversation is pinned at the top of the list.

ts
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.


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.

ts
id: string;

Defined in: packages/core/src/conversations/types.ts:65

ts
title: string;

Defined in: packages/core/src/conversations/types.ts:66

ts
createdAt: number;

Defined in: packages/core/src/conversations/types.ts:67

ts
updatedAt: number;

Defined in: packages/core/src/conversations/types.ts:68

ts
optional archivedAt?: number;

Defined in: packages/core/src/conversations/types.ts:69

ts
optional pinnedAt?: number;

Defined in: packages/core/src/conversations/types.ts:70

ts
optional schemaVersion?: number;

Defined in: packages/core/src/conversations/types.ts:72

Persisted schema version of the row.


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.

ts
id: string;

Defined in: packages/core/src/conversations/types.ts:82

ts
convId: string;

Defined in: packages/core/src/conversations/types.ts:83

ts
msgId: string;

Defined in: packages/core/src/conversations/types.ts:84

ts
name: string;

Defined in: packages/core/src/conversations/types.ts:85

ts
mimeType: string;

Defined in: packages/core/src/conversations/types.ts:86

ts
size: number;

Defined in: packages/core/src/conversations/types.ts:87

ts
blob: Blob;

Defined in: packages/core/src/conversations/types.ts:88


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.

ts
loadAll(): Promise<AparteConversation[]>;

Defined in: packages/core/src/conversations/types.ts:111

Return all stored conversations (full payload), ordered by updatedAt desc.

Promise<AparteConversation[]>

ts
save(conv): Promise<void>;

Defined in: packages/core/src/conversations/types.ts:113

Upsert a conversation (create or update).

ParameterType
convAparteConversation

Promise<void>

ts
delete(id): Promise<void>;

Defined in: packages/core/src/conversations/types.ts:115

Permanently delete a conversation by id (cascades related rows).

ParameterType
idstring

Promise<void>

ts
optional loadDraft(id): Promise<string | null | undefined>;

Defined in: packages/core/src/conversations/types.ts:117

What was typed and not sent, with keepDrafts on. Optional, with saveDraft.

ParameterType
idstring

Promise<string | null | undefined>

ts
optional saveDraft(id, text): Promise<void>;

Defined in: packages/core/src/conversations/types.ts:119

Keep a draft. Must not touch the conversation’s updatedAt. An empty text means none.

ParameterType
idstring
textstring

Promise<void>

ts
optional archive(id): Promise<void>;

Defined in: packages/core/src/conversations/types.ts:121

Archive a conversation (soft-delete). Optional.

ParameterType
idstring

Promise<void>

ts
optional unarchive(id): Promise<void>;

Defined in: packages/core/src/conversations/types.ts:123

Restore an archived conversation. Optional.

ParameterType
idstring

Promise<void>

ts
optional loadMeta(): Promise<AparteConversationMeta[]>;

Defined in: packages/core/src/conversations/types.ts:132

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.

Promise<AparteConversationMeta[]>

ts
optional loadFull(id): Promise<AparteConversation | null>;

Defined in: packages/core/src/conversations/types.ts:134

Lazy-load a single conversation’s full payload by id.

ParameterType
idstring

Promise<AparteConversation | null>

ts
optional pin(id): Promise<void>;

Defined in: packages/core/src/conversations/types.ts:136

Pin/unpin (pinnedAt-aware sidebar sort).

ParameterType
idstring

Promise<void>

ts
optional unpin(id): Promise<void>;

Defined in: packages/core/src/conversations/types.ts:137

ParameterType
idstring

Promise<void>

ts
optional rename(id, title): Promise<void>;

Defined in: packages/core/src/conversations/types.ts:139

Update only the conversation title (avoids rewriting messages).

ParameterType
idstring
titlestring

Promise<void>

ts
optional loadAttachments(msgId): Promise<AparteAttachmentRow[]>;

Defined in: packages/core/src/conversations/types.ts:144

Persisted attachment blobs for a single message.

ParameterType
msgIdstring

Promise<AparteAttachmentRow[]>


ts
type AparteConversationsListener = (conversations) => void;

Defined in: packages/core/src/conversations/conversation-manager.ts:10

What AparteConversationManager.subscribe calls with the list, on every change.

ParameterType
conversationsAparteConversation[]

void


ts
type AparteConversationTitleProvider = (text, message) => string | Promise<string>;

Defined in: packages/core/src/conversations/conversation-manager.ts:21

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.

ParameterType
textstring
messageAparteMessage

string | Promise<string>


ts
type AparteConversationStatus = "running" | "waiting";

Defined in: packages/core/src/conversations/conversation-status.ts:19

What a conversation is doing, as its row says it: running while an AI answers in it, waiting while its turn waits on the page — a run paused on a question, an approval or a browser tool, the one state a conversation keeps after the person has gone elsewhere.


ts
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

ts
headId: string | null;

Defined in: packages/core/src/runtime/message-repository.ts:39

ts
messages: {
  message: AparteMessage;
  parentId: string | null;
}[];

Defined in: packages/core/src/runtime/message-repository.ts:40

ts
message: AparteMessage;
ts
parentId: string | null;

Defined in: packages/core/src/conversations/types.ts:156

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

ts
targetId: string;

Defined in: packages/core/src/conversations/types.ts:158

The chat’s host id — the targetId every scoped event carries.

ts
conversationId: string;

Defined in: packages/core/src/conversations/types.ts:159