Messages and segments — core API
Generated reference for @aparte/core. A message and the segments it is made of, the parser that builds them from a stream, the renderers that draw them, and the errors.
On this page
- Overview
- Classes
-
Functions
- parseAparteEventStream()
- parseMarkdownToSegments()
- renderCitations()
- renderCodeLanguages()
- toToolCallView()
- defineMountedToolRenderer()
- defineMountedSegmentRenderer()
- registerSegmentRenderer()
- overrideSegmentRenderer()
- declineDefaultRenderers()
- installDefaultRenderersOnce()
- unregisterSegmentRenderer()
- getSegmentRenderer()
- getAllRenderers()
- collectRendererStyles()
- registerDefaultRenderers()
- contentToText()
-
Interfaces
- AparteThinkingDelimiterPair
- AparteStreamParserOptions
- AparteParserState
- AparteParserResult
- AparteRenderCodeLanguagesOptions
- AparteTextPart
- AparteImagePart
- AparteChatMessage
- AparteChatRequest
- AparteRequestMeta
- AparteUsage
- AparteStreamEventMap
- AparteCompactorRequest
- AparteCompactor
- AparteSendEventDetail
- AparteSiblingInfo
- AparteCommandScope
- AparteCommandContext
- AparteCommand
- AparteChatImperativeApi
- AparteUiHandle
- AparteAIModel
- ModelLoadProgress
- AparteAIProviderMetadata
- AparteAIProviderConfigField
- AparteAIProviderConfigSchema
- AparteModelConfig
- AparteAttachment
- AparteTurnSummaryOptions
- AparteBubbleActionsConfig
- AparteHostHandlersConfig
- AparteContextSummary
- AparteMessage
- AparteAttachmentState
- AparteComposerToken
- AparteMessageToken
- AparteComposerCaret
- AparteViewportConfig
- AparteInputConfig
- AparteContentParser
- AparteSegmentBase
- AparteSegmentTiming
- AparteTextSegment
- AparteSource
- AparteCitation
- AparteThinkingSegment
- AparteCodeSegment
- AparteErrorSegment
- AparteToolCallSegment
- AparteCustomSegment
- AparteSegmentTypes
- AparteSegmentRenderer
- AparteSegmentUpdateEventDetail
- AparteStreamBlockMatch
- AparteStreamBlock
- AparteTool
- AparteToolCall
- AparteApprovalRuling
- AparteToolResult
- AparteToolContext
- AparteToolDisplay
- AparteToolRenderer
- AparteToolCallView
- AparteMountedView
-
Type Aliases
- AparteContentPart
- AparteFinishReason
- AparteStreamEvent
- AparteChatResponse
- AparteCompactorReason
- AparteCompactorOutcome
- AparteAttrValue
- AparteTemplateAttrs
- ModelStatus
- AparteAIProvider
- AparteStatus
- AparteBubbleRole
- AparteBubbleActionName
- AparteSegmentDefaults
- AparteSegment
- AparteSegmentType
- AparteSegmentMount
- AparteThemeVariables
- AparteApprovalPolicy
- AparteToolHandler
- AparteToolSummary
- AparteToolInputFormatter
- AparteToolMatcher
- AparteToolDetails
- AparteToolMount
- Enumerations
-
Event details
- AparteMessageDoneEventDetail
- AparteModelChangeEventDetail
- AparteLinkClickEventDetail
- AparteBranchNavigateEventDetail
- ApartePathChangedEventDetail
- AparteRetryEventDetail
- AparteEditEventDetail
- AparteCollectCommandsEventDetail
- AparteTriggerSelectEventDetail
- AparteFeedbackReasonEventDetail
- AparteFeedbackEventDetail
- AparteActionEventDetail
- AparteMessageInfoEventDetail
- AparteMessageStartEventDetail
- AparteMessageErrorEventDetail
- AparteMessagePausedEventDetail
- AparteMessageResumedEventDetail
- AparteMessageAbortedEventDetail
- AparteAbortEventDetail
- AparteCompactEventDetail
- AparteCompactStartEventDetail
- AparteCompactDoneEventDetail
- AparteCompactErrorEventDetail
- AparteAttachmentPreviewEventDetail
- AparteApprovalModeChangeEventDetail
- AparteToolApprovalRequestDetail
Classes
Section titled “Classes”AparteStreamParser
Section titled “AparteStreamParser”Defined in: packages/core/src/parsers/aparte-stream-parser.ts:93
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new AparteStreamParser(options?): AparteStreamParser;Defined in: packages/core/src/parsers/aparte-stream-parser.ts:109
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options | AparteStreamParserOptions |
Returns
Section titled “Returns”Methods
Section titled “Methods”parse()
Section titled “parse()”parse(chunk): AparteParserResult;Defined in: packages/core/src/parsers/aparte-stream-parser.ts:131
Parse a chunk of streamed content Call this for each chunk received from the LLM
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
chunk | string |
Returns
Section titled “Returns”finalize()
Section titled “finalize()”finalize(): AparteSegment[];Defined in: packages/core/src/parsers/aparte-stream-parser.ts:164
Finalize parsing - flush any remaining content as text
Returns
Section titled “Returns”reset()
Section titled “reset()”reset(): void;Defined in: packages/core/src/parsers/aparte-stream-parser.ts:210
Reset parser state
Returns
Section titled “Returns”void
getState()
Section titled “getState()”getState(): Readonly<AparteParserState>;Defined in: packages/core/src/parsers/aparte-stream-parser.ts:218
Get current parser state (for debugging/inspection)
Returns
Section titled “Returns”Readonly<AparteParserState>
AparteError
Section titled “AparteError”Defined in: packages/core/src/types/errors.ts:39
Extends
Section titled “Extends”Error
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new AparteError(
message,
code,
data?,
originalError?,
httpStatus?): AparteError;Defined in: packages/core/src/types/errors.ts:40
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
message | string |
code | AparteErrorCode |
data? | Record<string, unknown> |
originalError? | unknown |
httpStatus? | number |
Returns
Section titled “Returns”Overrides
Section titled “Overrides”Error.constructorProperties
Section titled “Properties”message
Section titled “message”message: string;Defined in: packages/core/src/types/errors.ts:41
Inherited from
Section titled “Inherited from”Error.messagecode: AparteErrorCode;Defined in: packages/core/src/types/errors.ts:42
optional data?: Record<string, unknown>;Defined in: packages/core/src/types/errors.ts:43
originalError?
Section titled “originalError?”optional originalError?: unknown;Defined in: packages/core/src/types/errors.ts:44
httpStatus?
Section titled “httpStatus?”optional httpStatus?: number;Defined in: packages/core/src/types/errors.ts:45
Methods
Section titled “Methods”codeForStatus()
Section titled “codeForStatus()”static codeForStatus(status): AparteErrorCode | undefined;Defined in: packages/core/src/types/errors.ts:56
The code an HTTP status stands for — the table the enum’s own comments promise.
undefined for a status the enum does not name (a 404 can be a wrong model or a
wrong URL; the message says which, a code would guess).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
status | number | undefined |
Returns
Section titled “Returns”AparteErrorCode | undefined
from()
Section titled “from()”static from(
error,
defaultCode?,
defaultStatus?): AparteError;Defined in: packages/core/src/types/errors.ts:68
Parameters
Section titled “Parameters”| Parameter | Type | Default value |
|---|---|---|
error | unknown | undefined |
defaultCode | AparteErrorCode | AparteErrorCode.UNKNOWN_ERROR |
defaultStatus? | number | undefined |
Returns
Section titled “Returns”Functions
Section titled “Functions”parseAparteEventStream()
Section titled “parseAparteEventStream()”function parseAparteEventStream(stream): ReadableStream<AparteStreamEvent>;Defined in: packages/core/src/parsers/aparte-event-stream.ts:15
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
stream | ReadableStream<Uint8Array<ArrayBufferLike>> |
Returns
Section titled “Returns”ReadableStream<AparteStreamEvent>
parseMarkdownToSegments()
Section titled “parseMarkdownToSegments()”function parseMarkdownToSegments(content, options?): AparteSegment[];Defined in: packages/core/src/parsers/aparte-stream-parser.ts:717
Parse a complete markdown string into segments Use this for non-streaming scenarios
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
content | string |
options? | AparteStreamParserOptions |
Returns
Section titled “Returns”renderCitations()
Section titled “renderCitations()”function renderCitations(root, segment): void;Defined in: packages/core/src/renderers/citations.ts:260
Draw the chips of a text segment’s citations in its rendered Markdown. Idempotent: the same segment drawn again changes nothing; text written anew (a reply streaming) gets its chips again, keeping the focus and an open card on the chip that replaces theirs. Call it after writing a segment’s Markdown into an element of your own.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
root | Element |
segment | AparteTextSegment |
Returns
Section titled “Returns”void
renderCodeLanguages()
Section titled “renderCodeLanguages()”function renderCodeLanguages(root, options?): void;Defined in: packages/core/src/renderers/code-languages.ts:502
Draw every placeholder under root whose language has a renderer.
Core calls it wherever it writes Markdown or a code block; call it yourself after writing a provider’s HTML into an element of your own (a custom segment renderer). Idempotent and cheap when nothing changed, and a no-op where no renderer is registered.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
root | Element |
options | AparteRenderCodeLanguagesOptions |
Returns
Section titled “Returns”void
toToolCallView()
Section titled “toToolCallView()”function toToolCallView<I, R>(segment): AparteToolCallView<I, R>;Defined in: packages/core/src/renderers/mounted-renderer.ts:36
The fields of a call a card draws from, read from its segment.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
I | unknown |
R | unknown |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
segment | AparteToolCallSegment |
Returns
Section titled “Returns”AparteToolCallView<I, R>
defineMountedToolRenderer()
Section titled “defineMountedToolRenderer()”function defineMountedToolRenderer(mount): AparteToolRenderer;Defined in: packages/core/src/renderers/mounted-renderer.ts:70
A tool renderer from a mount function: register it with registerToolRenderer (or
overrideToolRenderer, to take it off again later).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
mount | AparteToolMount |
Returns
Section titled “Returns”Example
Section titled “Example”aparteGlobalConfig.registerToolRenderer('get_weather', defineMountedToolRenderer((host, view) => {
const card = document.createElement('weather-card');
card.data = view;
host.append(card);
return { update: (next) => { card.data = next; }, destroy: () => card.remove() };
}));defineMountedSegmentRenderer()
Section titled “defineMountedSegmentRenderer()”function defineMountedSegmentRenderer<T>(type, mount): AparteSegmentRenderer<T>;Defined in: packages/core/src/renderers/mounted-renderer.ts:95
A segment renderer from a mount function, for your own segment type: register it with
registerSegmentRenderer (or overrideSegmentRenderer).
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T extends AparteSegmentBase |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
type | string |
mount | AparteSegmentMount<T> |
Returns
Section titled “Returns”registerSegmentRenderer()
Section titled “registerSegmentRenderer()”function registerSegmentRenderer<T>(renderer, config?): void;Defined in: packages/core/src/renderers/segment-renderers.ts:110
Register a segment renderer.
config defaults to the ambient render config, which at app startup — no
element, no active render — is the global singleton. That is the right default:
a chat with its own config inherits global registrations. Pass a config
explicitly only to give ONE chat a renderer the others must not have.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T extends AparteSegmentBase |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
renderer | AparteSegmentRenderer<T> |
config | AparteConfig |
Returns
Section titled “Returns”void
overrideSegmentRenderer()
Section titled “overrideSegmentRenderer()”function overrideSegmentRenderer<T>(renderer, config?): () => void;Defined in: packages/core/src/renderers/segment-renderers.ts:137
Put renderer over whatever draws its type, and get back the function that takes it off
again — the registration a component makes for as long as it is mounted.
Overrides stack per type. The function restores what was there before THIS override;
taking off one that is no longer on top changes nothing on screen, so of two components
declaring the same type the newer wins and unmounting the older keeps it. When the last
one goes, the type is drawn by what drew it before the first — another registration, or
core’s own renderer for a built-in type like code or text. Segments on screen follow
each change. The returned function is safe to call twice.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T extends AparteSegmentBase |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
renderer | AparteSegmentRenderer<T> |
config | AparteConfig |
Returns
Section titled “Returns”() => void
declineDefaultRenderers()
Section titled “declineDefaultRenderers()”function declineDefaultRenderers(config?): void;Defined in: packages/core/src/renderers/segment-renderers.ts:190
Remember that the app declined the built-in renderers, so installDefaultRenderersOnce stays out of the way for good.
AparteClient({ autoRegister: false }) is the one caller. Without this latch the
lazy install below would quietly turn that option into a no-op.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
config | AparteConfig |
Returns
Section titled “Returns”void
installDefaultRenderersOnce()
Section titled “installDefaultRenderersOnce()”function installDefaultRenderersOnce(config?): void;Defined in: packages/core/src/renderers/segment-renderers.ts:208
Fill in the built-in renderers for the types nobody has claimed — called by the bubble the first time a segment has no renderer.
Why lazily and not at import time: registerDefaultRenderers() is called by
new AparteClient(), and an app on the bring-your-own-loop path — the one the guide
tells you not to construct a client on — never makes that call. Without this sweep
it would render [Unknown segment type: text] for every reply, with bubbles,
streaming and scrolling all working, which reads as a bug in the consumer’s own
loop rather than as a missing call.
Strictly additive: a type someone registered themselves is never replaced, so a
custom text renderer survives the sweep triggered by a code segment.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
config | AparteConfig |
Returns
Section titled “Returns”void
unregisterSegmentRenderer()
Section titled “unregisterSegmentRenderer()”function unregisterSegmentRenderer(type, config?): void;Defined in: packages/core/src/renderers/segment-renderers.ts:222
Unregister a segment renderer. Segments of this type on screen are drawn again by what resolves now (the global registration, for an instance config), or left unrendered.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
type | string |
config | AparteConfig |
Returns
Section titled “Returns”void
getSegmentRenderer()
Section titled “getSegmentRenderer()”function getSegmentRenderer(type, config?):
| AparteSegmentRenderer<AparteSegmentBase>
| undefined;Defined in: packages/core/src/renderers/segment-renderers.ts:232
Get renderer for a segment type
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
type | string |
config | AparteConfig |
Returns
Section titled “Returns”| AparteSegmentRenderer<AparteSegmentBase>
| undefined
getAllRenderers()
Section titled “getAllRenderers()”function getAllRenderers(config?): readonly AparteSegmentRenderer<AparteSegmentBase>[];Defined in: packages/core/src/renderers/segment-renderers.ts:242
Get all registered renderers
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
config | AparteConfig |
Returns
Section titled “Returns”readonly AparteSegmentRenderer<AparteSegmentBase>[]
collectRendererStyles()
Section titled “collectRendererStyles()”function collectRendererStyles(config?): string;Defined in: packages/core/src/renderers/segment-renderers.ts:252
Collect all renderer styles for one config.
Its OWN renderers, not the inherited view: a config that inherits the global’s renderers also inherits their stylesheet, which the global already injected.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
config | AparteConfig |
Returns
Section titled “Returns”string
registerDefaultRenderers()
Section titled “registerDefaultRenderers()”function registerDefaultRenderers(config?): void;Defined in: packages/core/src/renderers/segment-renderers.ts:333
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
config | AparteConfig |
Returns
Section titled “Returns”void
contentToText()
Section titled “contentToText()”function contentToText(content): string;Defined in: packages/core/src/types/chat.ts:43
Extract plain text from a string | AparteContentPart[] content value.
Use this in providers and app-layer code whenever you need the text-only representation.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
content | string | AparteContentPart[] |
Returns
Section titled “Returns”string
Interfaces
Section titled “Interfaces”AparteThinkingDelimiterPair
Section titled “AparteThinkingDelimiterPair”Defined in: packages/core/src/parsers/aparte-stream-parser.ts:27
One inline thinking-block delimiter pair (open/close tag).
Properties
Section titled “Properties”start: string;Defined in: packages/core/src/parsers/aparte-stream-parser.ts:28
end: string;Defined in: packages/core/src/parsers/aparte-stream-parser.ts:29
AparteStreamParserOptions
Section titled “AparteStreamParserOptions”Defined in: packages/core/src/parsers/aparte-stream-parser.ts:32
Properties
Section titled “Properties”thinkingDelimiters?
Section titled “thinkingDelimiters?”optional thinkingDelimiters?:
| AparteThinkingDelimiterPair
| AparteThinkingDelimiterPair[];Defined in: packages/core/src/parsers/aparte-stream-parser.ts:41
Inline thinking-block delimiters — for a model that streams its reasoning
inline in the content (rather than on a separate reasoning channel).
Accepts one pair or several; the parser opens a thinking segment at
whichever pair appears first. Default recognizes BOTH common conventions:
<think>…</think> (DeepSeek-R1, QwQ, most local GGUF reasoning models) and
<thinking>…</thinking> (Claude-style). Pass your own to override.
blocks?
Section titled “blocks?”optional blocks?: AparteStreamBlock[];Defined in: packages/core/src/parsers/aparte-stream-parser.ts:48
Tagged blocks to recognise in the prose — <tag attr="…">…</tag> — each turned
into the segment its grammar builds. The stream adapter passes the blocks
registered on the config (registerStreamBlock); pass your own when you drive
the parser yourself. See AparteStreamBlock.
autoGenerateIds?
Section titled “autoGenerateIds?”optional autoGenerateIds?: boolean;Defined in: packages/core/src/parsers/aparte-stream-parser.ts:50
Auto-generate segment IDs (default: true)
idPrefix?
Section titled “idPrefix?”optional idPrefix?: string;Defined in: packages/core/src/parsers/aparte-stream-parser.ts:52
ID prefix for generated segments
AparteParserState
Section titled “AparteParserState”Defined in: packages/core/src/parsers/aparte-stream-parser.ts:61
Properties
Section titled “Properties”mode: "text" | "thinking" | "code" | "block";Defined in: packages/core/src/parsers/aparte-stream-parser.ts:63
Current parser mode
buffer
Section titled “buffer”buffer: string;Defined in: packages/core/src/parsers/aparte-stream-parser.ts:65
Buffer for incomplete patterns
codeLanguage?
Section titled “codeLanguage?”optional codeLanguage?: string;Defined in: packages/core/src/parsers/aparte-stream-parser.ts:67
Current code block language
thinkingEnd?
Section titled “thinkingEnd?”optional thinkingEnd?: string;Defined in: packages/core/src/parsers/aparte-stream-parser.ts:69
Close delimiter of the thinking pair currently open (multi-delimiter support)
blockEnd?
Section titled “blockEnd?”optional blockEnd?: string;Defined in: packages/core/src/parsers/aparte-stream-parser.ts:71
Closing tag of the registered block currently open (</tag>).
segments
Section titled “segments”segments: AparteSegment[];Defined in: packages/core/src/parsers/aparte-stream-parser.ts:73
Accumulated segments
activeSegment
Section titled “activeSegment”activeSegment: AparteSegment | null;Defined in: packages/core/src/parsers/aparte-stream-parser.ts:75
Current active segment being built
segmentCounter
Section titled “segmentCounter”segmentCounter: number;Defined in: packages/core/src/parsers/aparte-stream-parser.ts:77
Counter for generating IDs
AparteParserResult
Section titled “AparteParserResult”Defined in: packages/core/src/parsers/aparte-stream-parser.ts:80
Properties
Section titled “Properties”segments
Section titled “segments”segments: AparteSegment[];Defined in: packages/core/src/parsers/aparte-stream-parser.ts:82
Parsed segments
remaining
Section titled “remaining”remaining: string;Defined in: packages/core/src/parsers/aparte-stream-parser.ts:84
Remaining buffer (incomplete patterns)
state: AparteParserState;Defined in: packages/core/src/parsers/aparte-stream-parser.ts:86
Current parser state
AparteRenderCodeLanguagesOptions
Section titled “AparteRenderCodeLanguagesOptions”Defined in: packages/core/src/renderers/code-languages.ts:54
Properties
Section titled “Properties”streaming?
Section titled “streaming?”optional streaming?: boolean;Defined in: packages/core/src/renderers/code-languages.ts:56
The content is still streaming: its last source, and any marked open, are still arriving.
refresh?
Section titled “refresh?”optional refresh?: boolean;Defined in: packages/core/src/renderers/code-languages.ts:61
Only redraw what is drawn already, where what it depends on moved (a renderer’s
cacheKey, a theme). For a renderer reacting to its own change, over a whole page.
language?
Section titled “language?”optional language?: string;Defined in: packages/core/src/renderers/code-languages.ts:63
Only this language.
AparteTextPart
Section titled “AparteTextPart”Defined in: packages/core/src/types/chat.ts:15
Plain text content part
Properties
Section titled “Properties”type: "text";Defined in: packages/core/src/types/chat.ts:16
text: string;Defined in: packages/core/src/types/chat.ts:17
AparteImagePart
Section titled “AparteImagePart”Defined in: packages/core/src/types/chat.ts:25
Image content part.
image must be a base64 data URL: data:image/png;base64,...
The data URL encodes the MIME type, making it consumable by all providers.
Properties
Section titled “Properties”type: "image";Defined in: packages/core/src/types/chat.ts:26
image: string;Defined in: packages/core/src/types/chat.ts:27
mimeType?
Section titled “mimeType?”optional mimeType?: string;Defined in: packages/core/src/types/chat.ts:28
AparteChatMessage
Section titled “AparteChatMessage”Defined in: packages/core/src/types/chat.ts:51
Properties
Section titled “Properties”role: "user" | "assistant" | "system" | "tool";Defined in: packages/core/src/types/chat.ts:52
content
Section titled “content”content: string | AparteContentPart[];Defined in: packages/core/src/types/chat.ts:60
Message content — either a plain string (backward compatible) or an array of typed content parts: text and images. A binary the model cannot read is not a content part; see the note on AparteContentPart.
Use contentToText(content) to extract the text-only representation.
toolCalls?
Section titled “toolCalls?”optional toolCalls?: AparteToolCall[];Defined in: packages/core/src/types/chat.ts:65
On an assistant message: the tool calls the model made this turn, grouped.
content is what it said before them — '' when it said nothing.
toolCallId?
Section titled “toolCallId?”optional toolCallId?: string;Defined in: packages/core/src/types/chat.ts:67
On a tool message: the id of the call, in the preceding assistant message, that it answers.
toolName?
Section titled “toolName?”optional toolName?: string;Defined in: packages/core/src/types/chat.ts:75
On a tool message: the name of the tool that ran.
Optional, and worth setting: a wire format that names the tool on the result (the AI SDK does) otherwise has to scan back for the call that declared the id, which a hand-built history need not contain.
AparteChatRequest
Section titled “AparteChatRequest”Defined in: packages/core/src/types/chat.ts:84
The request one turn sends to a provider.
Provider-specific options are not fields of the request: a provider reads its option off
_meta, the namespaced bag, which reaches it untouched.
Properties
Section titled “Properties”messages
Section titled “messages”messages: AparteChatMessage[];Defined in: packages/core/src/types/chat.ts:85
modelId
Section titled “modelId”modelId: string;Defined in: packages/core/src/types/chat.ts:86
temperature?
Section titled “temperature?”optional temperature?: number;Defined in: packages/core/src/types/chat.ts:87
maxTokens?
Section titled “maxTokens?”optional maxTokens?: number;Defined in: packages/core/src/types/chat.ts:88
stream?
Section titled “stream?”optional stream?: boolean;Defined in: packages/core/src/types/chat.ts:89
tools?
Section titled “tools?”optional tools?: AparteTool[];Defined in: packages/core/src/types/chat.ts:91
Tools the AI is allowed to call
optional seed?: number;Defined in: packages/core/src/types/chat.ts:101
Random seed for reproducibility. Passed through verbatim by the providers that support it (OpenAI-compatible endpoints, the AI SDK bridge, the transformers worker); Anthropic exposes none, so it is ignored there.
Nothing sets it for you: a retry varies its answer by sampling
(temperature), not by seeding. Set it from a requestInterceptor when you
need reproducible runs.
toolChoice?
Section titled “toolChoice?”optional toolChoice?:
| "auto"
| "none"
| {
name: string;
input?: Record<string, unknown>;
};Defined in: packages/core/src/types/chat.ts:113
Controls which tool the model must call — mirrors OpenAI tool_choice / Anthropic tool_choice.
- ‘auto’ : model decides (default when tools are present)
- ‘none’ : no tools injected this turn — model answers directly
- { name } : model MUST call this tool (provider injects a strong directive)
- { name, input }: synthetic call — the agent loop (
runStreamAgent, or the runner you injected) bypasses the LLM entirely and runs the handler directly with the provided input, then re-calls the LLM with the tool message in history.
AparteRequestMeta
Section titled “AparteRequestMeta”Defined in: packages/core/src/types/chat.ts:133
The well-known keys of AparteChatRequest._meta. Two: prefixSegments, read by core’s
client and not by the loop, and compaction, which @aparte/plugin-compaction sets for
a transport to route on; the rest of the bag is the consumer’s (index signature).
An artifact is a plugin’s convention, so no artifact key is defined here.
Indexable
Section titled “Indexable”[key: string]: unknownConsumer-specific context (open channel).
Properties
Section titled “Properties”prefixSegments?
Section titled “prefixSegments?”optional prefixSegments?: AparteSegment[];Defined in: packages/core/src/types/chat.ts:140
Segments to show at the top of the assistant’s turn before the model has said
anything — a “planning” thinking block a host wants visible from the first
frame, a status row. Added right after the turn flips to streaming, in this
order, and never sent to the model.
compaction?
Section titled “compaction?”optional compaction?: true;Defined in: packages/core/src/types/chat.ts:146
Set by @aparte/plugin-compaction on the summarisation request, and on nothing
else. A backend transport can route it — a cheaper model, a shorter timeout —
without inspecting the messages to guess what the request is for.
tokens?
Section titled “tokens?”optional tokens?: AparteMessageToken[];Defined in: packages/core/src/types/chat.ts:148
The tokens of the message being sent, with what the app put in their data.
AparteUsage
Section titled “AparteUsage”Defined in: packages/core/src/types/chat.ts:156
Token usage reported by the AI provider after a completed response.
Properties
Section titled “Properties”inputTokens
Section titled “inputTokens”inputTokens: number;Defined in: packages/core/src/types/chat.ts:158
Tokens in the prompt / conversation history sent to the model
outputTokens
Section titled “outputTokens”outputTokens: number;Defined in: packages/core/src/types/chat.ts:160
Tokens generated by the model
totalTokens?
Section titled “totalTokens?”optional totalTokens?: number;Defined in: packages/core/src/types/chat.ts:162
Total tokens (inputTokens + outputTokens). Populated when the provider reports it.
cacheReadTokens?
Section titled “cacheReadTokens?”optional cacheReadTokens?: number;Defined in: packages/core/src/types/chat.ts:164
Tokens read from the provider’s prompt cache (Anthropic, OpenAI).
durationMs?
Section titled “durationMs?”optional durationMs?: number;Defined in: packages/core/src/types/chat.ts:166
Wall-clock generation time in milliseconds (provider-measured). Used to compute tokens/sec.
ttftMs?
Section titled “ttftMs?”optional ttftMs?: number;Defined in: packages/core/src/types/chat.ts:170
Time to first token in ms — the prefill / TTFT phase.
decodeMs?
Section titled “decodeMs?”optional decodeMs?: number;Defined in: packages/core/src/types/chat.ts:172
Decode-phase wall time in ms (≈ durationMs − ttftMs).
decodeTokens?
Section titled “decodeTokens?”optional decodeTokens?: number;Defined in: packages/core/src/types/chat.ts:174
Tokens emitted during the decode phase (outputTokens minus the first).
wallMs?
Section titled “wallMs?”optional wallMs?: number;Defined in: packages/core/src/types/chat.ts:176
Total turn wall-clock time in ms, measured client-side across all phases.
modelId?
Section titled “modelId?”optional modelId?: string;Defined in: packages/core/src/types/chat.ts:178
Id of the model that produced this response.
device?
Section titled “device?”optional device?: string;Defined in: packages/core/src/types/chat.ts:180
Compute device used for this response (‘webgpu’ | ‘wasm’ | …).
phases?
Section titled “phases?”optional phases?: AparteUsage[];Defined in: packages/core/src/types/chat.ts:186
Per-call breakdown when a single turn used several provider calls (e.g. a tool-use round-trip or a mid-turn model swap). Absent for a plain single-call turn. Each entry is the AparteUsage of one provider call.
AparteStreamEventMap
Section titled “AparteStreamEventMap”Defined in: packages/core/src/types/chat.ts:209
Normalized stream event map — extensible via declaration merging.
Example
Section titled “Example”// In a plugin or app:
declare module '@aparte/core' {
interface AparteStreamEventMap {
tool_call: { name: string; arguments: string }
}
}Properties
Section titled “Properties”text: {
delta: string;
};Defined in: packages/core/src/types/chat.ts:210
delta: string;thinking
Section titled “thinking”thinking: {
delta: string;
};Defined in: packages/core/src/types/chat.ts:211
delta: string;done: {
usage?: AparteUsage;
finishReason?: AparteFinishReason;
};Defined in: packages/core/src/types/chat.ts:213
Emitted when the stream ends. May carry token usage and the finish reason reported by the provider.
usage?
Section titled “usage?”optional usage?: AparteUsage;finishReason?
Section titled “finishReason?”optional finishReason?: AparteFinishReason;error: {
message: string;
code?: AparteErrorCode;
};Defined in: packages/core/src/types/chat.ts:218
A failure mid-stream. code names it when the provider can tell (an overflowing prompt
is USAGE_CONTEXT_EXCEEDED), so the client can act on the code instead of reading prose.
message
Section titled “message”message: string;optional code?: AparteErrorCode;tool_use
Section titled “tool_use”tool_use: AparteToolCall;Defined in: packages/core/src/types/chat.ts:219
sources
Section titled “sources”sources: {
sources: AparteSource[];
citations?: AparteCitation[];
};Defined in: packages/core/src/types/chat.ts:225
The sources the reply draws on, and where it cites them: offsets into the text this
model call has streamed so far (every text delta, joined). Sent once, or as they
arrive; a later event adds to the earlier ones.
sources
Section titled “sources”sources: AparteSource[];citations?
Section titled “citations?”optional citations?: AparteCitation[];AparteCompactorRequest
Section titled “AparteCompactorRequest”Defined in: packages/core/src/types/compactor.ts:14
What a compactor is asked to do — one chat, named by its element and, when it has one, its id.
Properties
Section titled “Properties”target
Section titled “target”target: Element | null;Defined in: packages/core/src/types/compactor.ts:16
The chat’s element. Passed, not only its id: a chat inside a shadow root is not found by id.
targetId?
Section titled “targetId?”optional targetId?: string;Defined in: packages/core/src/types/compactor.ts:18
The chat’s id, when it has one.
force?
Section titled “force?”optional force?: boolean;Defined in: packages/core/src/types/compactor.ts:20
Compact even when the policy would not (below the threshold, after repeated failures).
exclude?
Section titled “exclude?”optional exclude?: string[];Defined in: packages/core/src/types/compactor.ts:26
Ids of messages that belong to a turn being prepared — the user message and the reply placeholder of a send or retry in progress. They are not summarised and do not count as “a turn in flight”.
reason?
Section titled “reason?”optional reason?: AparteCompactorReason;Defined in: packages/core/src/types/compactor.ts:27
signal?
Section titled “signal?”optional signal?: AbortSignal;Defined in: packages/core/src/types/compactor.ts:33
Aborted when the turn the compaction serves is stopped — the client’s Stop or a
programmatic abort() / stop(). The compactor cancels its summary then, so a
stopped turn neither pays for one nor writes a checkpoint into a chat left behind.
AparteCompactor
Section titled “AparteCompactor”Defined in: packages/core/src/types/compactor.ts:74
The seam between the parts of core that need the context made smaller (the gauge’s
Compact now, a separator’s Retry, the client before a send and after an overflow) and
whatever makes it smaller. @aparte/plugin-compaction registers itself as the compactor
with AparteConfig.setCompactor(); core never compacts by itself.
It is a seam and not an event because the caller needs the answer: the client rebuilds a request once the summary is written, and a button shows that it is working.
Methods
Section titled “Methods”compact()
Section titled “compact()”compact(request): Promise<AparteCompactorOutcome>;Defined in: packages/core/src/types/compactor.ts:76
Compact one chat. Never rejects.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
request | AparteCompactorRequest |
Returns
Section titled “Returns”Promise<AparteCompactorOutcome>
settled()
Section titled “settled()”settled(targetId?): Promise<void>;Defined in: packages/core/src/types/compactor.ts:78
Resolves when no compaction of this chat is running — a send never races a summary.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
targetId? | string |
Returns
Section titled “Returns”Promise<void>
beforeSend()?
Section titled “beforeSend()?”optional beforeSend(request): Promise<boolean>;Defined in: packages/core/src/types/compactor.ts:83
Before a send’s request goes out, with the estimate of that request. Resolves true
when it compacted, so the caller builds the request again.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
request | { target: Element | null; targetId?: string; exclude: string[]; requestTokens: number; signal?: AbortSignal; } | - |
request.target | Element | null | - |
request.targetId? | string | - |
request.exclude | string[] | The turn being prepared: its user message and reply placeholder. |
request.requestTokens | number | The estimate, in tokens, of the request about to be sent. |
request.signal? | AbortSignal | Aborted when the turn is stopped; the compactor cancels any summary it started for it. |
Returns
Section titled “Returns”Promise<boolean>
preview()?
Section titled “preview()?”optional preview(request):
| {
messages: number;
tokens: number;
}
| null;Defined in: packages/core/src/types/compactor.ts:98
What compacting now would do: how many messages it would summarise and the tokens that
would free, or null when there is nothing to do. The gauge offers “Compact now” only
when this returns something.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
request | { target: Element | null; targetId?: string; } |
request.target | Element | null |
request.targetId? | string |
Returns
Section titled “Returns”| {
messages: number;
tokens: number;
}
| null
AparteSendEventDetail
Section titled “AparteSendEventDetail”Defined in: packages/core/src/types/events.ts:22
Detail payload for aparte-send custom event Emitted when user sends a message via the input component
Properties
Section titled “Properties”content
Section titled “content”content: string;Defined in: packages/core/src/types/events.ts:24
The message content being sent
timestamp
Section titled “timestamp”timestamp: number;Defined in: packages/core/src/types/events.ts:27
Timestamp of the send action
targetId?
Section titled “targetId?”optional targetId?: string;Defined in: packages/core/src/types/events.ts:36
ID of the chat this send belongs to: the composer’s target attribute, or the id
of the <aparte-chat> / [data-aparte-chat] host above it — the same resolution
the composer’s receive side (_isForThisComposer) uses, so the two halves of the
channel cannot disagree about which chat is which.
Used by AparteClient to find the host without DOM traversal.
files?
Section titled “files?”optional files?: File[];Defined in: packages/core/src/types/events.ts:39
Files attached to this message (populated by composer attachments)
modelId?
Section titled “modelId?”optional modelId?: string;Defined in: packages/core/src/types/events.ts:49
Send THIS message to a specific model, overriding the config’s default for one turn — a per-message model picker.
AparteClient honours both fields. The composer never sends them: dispatch your
own aparte-send with them, or set them on the detail from a listener that runs
before the client’s (capture phase).
providerId?
Section titled “providerId?”optional providerId?: string;Defined in: packages/core/src/types/events.ts:51
The provider that modelId belongs to; defaults to the config’s defaultProvider.
tokens?
Section titled “tokens?”optional tokens?: AparteMessageToken[];Defined in: packages/core/src/types/events.ts:57
The tokens the draft held (see AparteComposerToken). AparteClient keeps them on the
user message and passes them to the request as _meta.tokens.
optional meta?: Record<string, unknown>;Defined in: packages/core/src/types/events.ts:64
Data to go with this message and not in its text. AparteClient keeps it as the user
message’s metadata and merges it into the request’s _meta. The composer never sets
it: add it from a listener that runs before the client’s (capture phase).
AparteSiblingInfo
Section titled “AparteSiblingInfo”Defined in: packages/core/src/types/events.ts:128
Per-message sibling metadata carried by aparte-path-changed.
index is 0-based; UI renders it as index + 1 / count.
Properties
Section titled “Properties”id: string;Defined in: packages/core/src/types/events.ts:130
Message id
count: number;Defined in: packages/core/src/types/events.ts:132
Total number of siblings (including this one). 1 = no branch picker.
index: number;Defined in: packages/core/src/types/events.ts:134
0-based position of this message among its siblings.
AparteCommandScope
Section titled “AparteCommandScope”Defined in: packages/core/src/types/events.ts:218
The chat a command acts on.
Extended by
Section titled “Extended by”Properties
Section titled “Properties”config
Section titled “config”config: AparteConfig;Defined in: packages/core/src/types/events.ts:219
composer
Section titled “composer”composer: AparteComposer;Defined in: packages/core/src/types/events.ts:220
chat: HTMLElement | null;Defined in: packages/core/src/types/events.ts:222
The <aparte-chat> or [data-aparte-chat] above the composer.
targetId
Section titled “targetId”targetId: string | undefined;Defined in: packages/core/src/types/events.ts:224
The id aparte-* events name this chat by.
AparteCommandContext
Section titled “AparteCommandContext”Defined in: packages/core/src/types/events.ts:228
What a command receives when it is chosen.
Extends
Section titled “Extends”Properties
Section titled “Properties”config
Section titled “config”config: AparteConfig;Defined in: packages/core/src/types/events.ts:219
Inherited from
Section titled “Inherited from”composer
Section titled “composer”composer: AparteComposer;Defined in: packages/core/src/types/events.ts:220
Inherited from
Section titled “Inherited from”chat: HTMLElement | null;Defined in: packages/core/src/types/events.ts:222
The <aparte-chat> or [data-aparte-chat] above the composer.
Inherited from
Section titled “Inherited from”targetId
Section titled “targetId”targetId: string | undefined;Defined in: packages/core/src/types/events.ts:224
The id aparte-* events name this chat by.
Inherited from
Section titled “Inherited from”query: string;Defined in: packages/core/src/types/events.ts:229
input: AparteComposerInput;Defined in: packages/core/src/types/events.ts:230
Methods
Section titled “Methods”notify()
Section titled “notify()”notify(text): void;Defined in: packages/core/src/types/events.ts:232
Say something beside the composer for a few seconds: why a command did nothing.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
text | string |
Returns
Section titled “Returns”void
AparteCommand
Section titled “AparteCommand”Defined in: packages/core/src/types/events.ts:236
A command a plugin or an app adds to @aparte/plugin-triggers’ menu.
Properties
Section titled “Properties”id: string;Defined in: packages/core/src/types/events.ts:238
The same id twice: the last one answering wins.
optional name?: string;Defined in: packages/core/src/types/events.ts:240
What is typed after the trigger. Defaults to id.
label?
Section titled “label?”optional label?: string;Defined in: packages/core/src/types/events.ts:242
Defaults to the trigger followed by name.
description?
Section titled “description?”optional description?: string;Defined in: packages/core/src/types/events.ts:243
optional icon?: string | HTMLElement;Defined in: packages/core/src/types/events.ts:245
A core icon’s name, a short text such as an emoji, or an element.
group?
Section titled “group?”optional group?: string;Defined in: packages/core/src/types/events.ts:246
keywords?
Section titled “keywords?”optional keywords?: readonly string[];Defined in: packages/core/src/types/events.ts:247
order?
Section titled “order?”optional order?: number;Defined in: packages/core/src/types/events.ts:249
Lower comes first. Default 100.
hidden?
Section titled “hidden?”optional hidden?: boolean;Defined in: packages/core/src/types/events.ts:250
enabled?
Section titled “enabled?”optional enabled?: (scope) => boolean;Defined in: packages/core/src/types/events.ts:252
Asked each time the menu opens. A command that cannot act here is not listed.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
scope | AparteCommandScope |
Returns
Section titled “Returns”boolean
optional run?: (context) => void | Promise<void>;Defined in: packages/core/src/types/events.ts:253
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
context | AparteCommandContext |
Returns
Section titled “Returns”void | Promise<void>
children?
Section titled “children?”optional children?:
| readonly AparteCommand[]
| ((scope) => readonly AparteCommand[]);Defined in: packages/core/src/types/events.ts:254
AparteChatImperativeApi
Section titled “AparteChatImperativeApi”Defined in: packages/core/src/types/imperative-api.ts:14
The canonical imperative surface a framework <AparteChat> exposes (React’s
ref handle, Vue/Svelte’s instance, Angular’s component). All four delegate to
the framework-agnostic AparteChatHost, so this ONE contract is the single
source of truth, and each wrapper enforces it against the compiler — React via
the ref-handle type on a return-annotated useImperativeHandle, Angular via
implements, Vue via satisfies on defineExpose, Svelte via a type-checked
parity factory — so a missing or mistyped method is a build error in that
wrapper, not a silent divergence.
Properties
Section titled “Properties”appendMessage
Section titled “appendMessage”appendMessage: (message, options?) => void;Defined in: packages/core/src/types/imperative-api.ts:23
Append a message. { historical: true } says it is RESTORED, not live: its
segments are adopted as they are — no fresh timing stamps, isStreaming forced
off — the way a stored conversation is loaded, so a tool call read back from
your own backend renders settled rather than spinning. Use it when you replay
history one message at a time; a live turn passes nothing.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
message | AparteMessage |
options? | { historical?: boolean; } |
options.historical? | boolean |
Returns
Section titled “Returns”void
updateMessage
Section titled “updateMessage”updateMessage: (messageId, updates) => void;Defined in: packages/core/src/types/imperative-api.ts:24
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
messageId | string |
updates | Partial<AparteMessage> |
Returns
Section titled “Returns”void
updateLastMessage
Section titled “updateLastMessage”updateLastMessage: (content, options?) => void;Defined in: packages/core/src/types/imperative-api.ts:25
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
content | string |
options? | { append?: boolean; } |
options.append? | boolean |
Returns
Section titled “Returns”void
addSegment
Section titled “addSegment”addSegment: (segment) => void;Defined in: packages/core/src/types/imperative-api.ts:26
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
segment | AparteSegment |
Returns
Section titled “Returns”void
updateSegment
Section titled “updateSegment”updateSegment: (segmentId, updates) => void;Defined in: packages/core/src/types/imperative-api.ts:27
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
segmentId | string |
updates | Partial<AparteSegment> |
Returns
Section titled “Returns”void
removeSegment
Section titled “removeSegment”removeSegment: (segmentId) => void;Defined in: packages/core/src/types/imperative-api.ts:28
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
segmentId | string |
Returns
Section titled “Returns”void
appendToSegment
Section titled “appendToSegment”appendToSegment: (segmentId, content) => void;Defined in: packages/core/src/types/imperative-api.ts:42
Append text to a segment of the last message — the streaming path for a thinking block, a tool pill, or any segment that grows token by token.
Each chunk is written straight into the bubble, and the framework’s message list is synced once per frame rather than per chunk, so streaming a segment costs about one render per frame instead of one per token.
Note that segments and content are mutually exclusive at render time: as
soon as a message has segments the bubble hides its plain content, so a
message driven by injectTokenStream (which writes content) can’t also show
a thinking segment — put the text in a segment of its own instead.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
segmentId | string |
content | string |
Returns
Section titled “Returns”void
getMessages
Section titled “getMessages”getMessages: () => AparteMessage[];Defined in: packages/core/src/types/imperative-api.ts:43
Returns
Section titled “Returns”clearMessages
Section titled “clearMessages”clearMessages: (options?) => void;Defined in: packages/core/src/types/imperative-api.ts:44
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options? | { revokeAttachments?: boolean; } |
options.revokeAttachments? | boolean |
Returns
Section titled “Returns”void
addBranch
Section titled “addBranch”addBranch: (messageId) => number;Defined in: packages/core/src/types/imperative-api.ts:46
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
messageId | string |
Returns
Section titled “Returns”number
addSiblingOf
Section titled “addSiblingOf”addSiblingOf: (existingId, message) => string | null;Defined in: packages/core/src/types/imperative-api.ts:47
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
existingId | string |
message | AparteMessage |
Returns
Section titled “Returns”string | null
truncateFrom
Section titled “truncateFrom”truncateFrom: (messageId) => void;Defined in: packages/core/src/types/imperative-api.ts:48
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
messageId | string |
Returns
Section titled “Returns”void
truncateResponsesAfter
Section titled “truncateResponsesAfter”truncateResponsesAfter: (userMessageId) => void;Defined in: packages/core/src/types/imperative-api.ts:49
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
userMessageId | string |
Returns
Section titled “Returns”void
injectTokenStream
Section titled “injectTokenStream”injectTokenStream: (messageId, tokens) => Promise<void>;Defined in: packages/core/src/types/imperative-api.ts:66
Stream tokens into a message from your own loop (no AparteClient
involved). It sends the turn’s lifecycle events itself — aparte-message-start,
then -done, -aborted or -error — so the composer shows Stop, its Stop
cancels the stream, and the conversation manager saves the reply. Resolves when
the iterable completes; the message is then marked complete.
If messageId doesn’t exist the viewport auto-creates an empty
assistant message — but only in its internal repo, NOT in the
framework’s message state. In a wrapper, call
appendMessage({ id, role: 'assistant', content: '' , timestamp: Date.now() })
first so both stay in sync. Starting a new stream cancels the previous
one; stopTokenStream cancels explicitly. See the
“Bring your own loop” guide.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
messageId | string |
tokens | AsyncIterable<string> |
Returns
Section titled “Returns”Promise<void>
stopTokenStream
Section titled “stopTokenStream”stopTokenStream: () => void;Defined in: packages/core/src/types/imperative-api.ts:68
Abort an in-flight injectTokenStream loop (the source iterable is return()ed).
Returns
Section titled “Returns”void
setConversationId
Section titled “setConversationId”setConversationId: (id) => Promise<void>;Defined in: packages/core/src/types/imperative-api.ts:70
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
id | string | null |
Returns
Section titled “Returns”Promise<void>
scrollToBottom
Section titled “scrollToBottom”scrollToBottom: () => void;Defined in: packages/core/src/types/imperative-api.ts:72
Returns
Section titled “Returns”void
focusInput
Section titled “focusInput”focusInput: () => void;Defined in: packages/core/src/types/imperative-api.ts:73
Returns
Section titled “Returns”void
isStreaming
Section titled “isStreaming”isStreaming: () => boolean;Defined in: packages/core/src/types/imperative-api.ts:74
Returns
Section titled “Returns”boolean
getViewport
Section titled “getViewport”getViewport: () => HTMLElement | null;Defined in: packages/core/src/types/imperative-api.ts:76
The <aparte-chat-viewport> element — same getViewport() on all four wrappers.
Returns
Section titled “Returns”HTMLElement | null
AparteUiHandle
Section titled “AparteUiHandle”Defined in: packages/core/src/types/imperative-api.ts:89
The imperative surface every framework <AparteUi> proxy exposes — React’s ref
handle, Vue’s template ref, Svelte’s bind:this, Angular’s @ViewChild.
It lives here for the same reason AparteChatImperativeApi does: it was
hand-copied into all four wrappers, each docblock promising “the same contract on
all four”, and it had already drifted once (two of them returned
HTMLElement | null / unknown instead of the generic form). One declaration, four
re-exports, and a divergence is a compile error rather than a promise in prose.
Methods
Section titled “Methods”getElement()
Section titled “getElement()”getElement<T>(): T | null;Defined in: packages/core/src/types/imperative-api.ts:91
The proxied custom element, once mounted.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
T extends HTMLElement | HTMLElement |
Returns
Section titled “Returns”T | null
callMethod()
Section titled “callMethod()”callMethod<T>(methodName, ...args): T | undefined;Defined in: packages/core/src/types/imperative-api.ts:93
Call a method on it — the escape hatch for an element-specific API.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
T | unknown |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
methodName | string |
…args | unknown[] |
Returns
Section titled “Returns”T | undefined
AparteAIModel
Section titled “AparteAIModel”Defined in: packages/core/src/types/model-provider.ts:31
Represents an AI model that can be selected by the user.
Example
Section titled “Example”const model: AparteAIModel = {
id: 'gpt-4-turbo',
name: 'GPT-4 Turbo',
contextWindow: 128000,
capabilities: ['vision', 'function_calling', 'streaming']
};Properties
Section titled “Properties”id: string;Defined in: packages/core/src/types/model-provider.ts:33
Unique identifier for the model (e.g., ‘gpt-4-turbo’, ‘claude-3-opus’)
name: string;Defined in: packages/core/src/types/model-provider.ts:36
Human-readable display name
contextWindow?
Section titled “contextWindow?”optional contextWindow?: number;Defined in: packages/core/src/types/model-provider.ts:39
Optional context window size in tokens
pricing?
Section titled “pricing?”optional pricing?: {
input: number;
output: number;
};Defined in: packages/core/src/types/model-provider.ts:42
Optional pricing information (per 1M tokens)
input: number;output
Section titled “output”output: number;capabilities?
Section titled “capabilities?”optional capabilities?: ("streaming" | "code" | "vision" | "function_calling" | "reasoning")[];Defined in: packages/core/src/types/model-provider.ts:48
Optional capability flags
description?
Section titled “description?”optional description?: string;Defined in: packages/core/src/types/model-provider.ts:51
Optional short description shown in model pickers
metadata?
Section titled “metadata?”optional metadata?: Record<string, unknown>;Defined in: packages/core/src/types/model-provider.ts:54
Optional metadata for custom properties
ModelLoadProgress
Section titled “ModelLoadProgress”Defined in: packages/core/src/types/model-provider.ts:76
Progress update emitted during model preparation (download + load).
Passed to the onProgress callback of AparteAIProvider.prepareModel().
Properties
Section titled “Properties”status
Section titled “status”status: "error" | "downloading" | "loading" | "cached" | "ready";Defined in: packages/core/src/types/model-provider.ts:78
Current phase of the preparation
optional file?: string;Defined in: packages/core/src/types/model-provider.ts:80
File currently being processed (e.g. “model.safetensors”)
progress?
Section titled “progress?”optional progress?: number;Defined in: packages/core/src/types/model-provider.ts:82
Progress percentage 0–100
message?
Section titled “message?”optional message?: string;Defined in: packages/core/src/types/model-provider.ts:84
Optional human-readable message
AparteAIProviderMetadata
Section titled “AparteAIProviderMetadata”Defined in: packages/core/src/types/model-provider.ts:94
Brand metadata for an AI provider, used for visual selection and onboarding.
Properties
Section titled “Properties”name: string;Defined in: packages/core/src/types/model-provider.ts:96
Human-readable display name
id: string;Defined in: packages/core/src/types/model-provider.ts:99
Provider ID
optional icon?: string;Defined in: packages/core/src/types/model-provider.ts:105
Brand icon. Can be an SVG string, a data URI, or a key for AparteIconProvider.
color?
Section titled “color?”optional color?: string;Defined in: packages/core/src/types/model-provider.ts:108
Brand primary color (hex or CSS variable)
description?
Section titled “description?”optional description?: string;Defined in: packages/core/src/types/model-provider.ts:111
Short tag line or description
hasFreeModels?
Section titled “hasFreeModels?”optional hasFreeModels?: boolean;Defined in: packages/core/src/types/model-provider.ts:114
Whether the provider offers free models or Tiers
isLocal?
Section titled “isLocal?”optional isLocal?: boolean;Defined in: packages/core/src/types/model-provider.ts:117
Whether the provider runs locally on the user machine
helpUrl?
Section titled “helpUrl?”optional helpUrl?: string;Defined in: packages/core/src/types/model-provider.ts:120
URL to the provider’s API key management page or documentation
configSchema?
Section titled “configSchema?”optional configSchema?: AparteAIProviderConfigSchema;Defined in: packages/core/src/types/model-provider.ts:123
Configuration schema for the onboarding UI
AparteAIProviderConfigField
Section titled “AparteAIProviderConfigField”Defined in: packages/core/src/types/model-provider.ts:129
Definition of a configuration field for the provider
Properties
Section titled “Properties”id: string;Defined in: packages/core/src/types/model-provider.ts:131
Unique identifier for the field (e.g., ‘apiKey’, ‘endpoint’)
type: "text" | "password" | "url";Defined in: packages/core/src/types/model-provider.ts:133
Basic type for the input field
label: string;Defined in: packages/core/src/types/model-provider.ts:135
Human readable label (e.g., ‘API Key’, ‘Sever URL’)
placeholder?
Section titled “placeholder?”optional placeholder?: string;Defined in: packages/core/src/types/model-provider.ts:137
Placeholder hint
defaultValue?
Section titled “defaultValue?”optional defaultValue?: string;Defined in: packages/core/src/types/model-provider.ts:139
Initial value
required?
Section titled “required?”optional required?: boolean;Defined in: packages/core/src/types/model-provider.ts:141
Whether the field is mandatory to start
isAdvanced?
Section titled “isAdvanced?”optional isAdvanced?: boolean;Defined in: packages/core/src/types/model-provider.ts:143
If true, the field is hidden behind an ‘Advanced’ toggle in UI
AparteAIProviderConfigSchema
Section titled “AparteAIProviderConfigSchema”Defined in: packages/core/src/types/model-provider.ts:149
Encapsulates all configuration fields for a provider
Properties
Section titled “Properties”fields
Section titled “fields”fields: AparteAIProviderConfigField[];Defined in: packages/core/src/types/model-provider.ts:150
AparteModelConfig
Section titled “AparteModelConfig”Defined in: packages/core/src/types/model-provider.ts:331
Configuration options for model selection behavior.
Properties
Section titled “Properties”enabledProviders?
Section titled “enabledProviders?”optional enabledProviders?: string[];Defined in: packages/core/src/types/model-provider.ts:333
Which providers to enable (all if omitted)
modelFilters?
Section titled “modelFilters?”optional modelFilters?: Record<string, string[]>;Defined in: packages/core/src/types/model-provider.ts:336
Filter models by provider
defaultProvider?
Section titled “defaultProvider?”optional defaultProvider?: string;Defined in: packages/core/src/types/model-provider.ts:339
Default provider ID
defaultModel?
Section titled “defaultModel?”optional defaultModel?: string;Defined in: packages/core/src/types/model-provider.ts:342
Default model ID
AparteAttachment
Section titled “AparteAttachment”Defined in: packages/core/src/types/models.ts:34
Attachment interface for media and file support Future-proof structure for images, audio, documents, etc.
Properties
Section titled “Properties”id: string;Defined in: packages/core/src/types/models.ts:36
Unique identifier for the attachment
name: string;Defined in: packages/core/src/types/models.ts:39
Display name of the attachment
type: string;Defined in: packages/core/src/types/models.ts:42
MIME type (e.g., ‘image/png’, ‘application/pdf’)
url: string;Defined in: packages/core/src/types/models.ts:45
URL or data URI to access the attachment
optional size?: number;Defined in: packages/core/src/types/models.ts:48
Optional file size in bytes
thumbnailUrl?
Section titled “thumbnailUrl?”optional thumbnailUrl?: string;Defined in: packages/core/src/types/models.ts:51
Optional thumbnail URL for previews
metadata?
Section titled “metadata?”optional metadata?: Record<string, unknown>;Defined in: packages/core/src/types/models.ts:54
Optional metadata for custom properties
optional blob?: Blob;Defined in: packages/core/src/types/models.ts:62
Binary payload. Set at message-creation time (File from upload) so the
persistence adapter can save it to its attachments table. Stripped from
the serialised message row — the adapter reconstructs url via
URL.createObjectURL(blob) on hydration. Not serialised to JSON.
AparteTurnSummaryOptions
Section titled “AparteTurnSummaryOptions”Defined in: packages/core/src/types/models.ts:102
See AparteConfig.setTurnSummary.
Properties
Section titled “Properties”openWhileRunning?
Section titled “openWhileRunning?”optional openWhileRunning?: boolean;Defined in: packages/core/src/types/models.ts:104
Keep a fold open while its steps run, and close it when they are done (default: closed).
AparteBubbleActionsConfig
Section titled “AparteBubbleActionsConfig”Defined in: packages/core/src/types/models.ts:107
Properties
Section titled “Properties”optional copy?: boolean;Defined in: packages/core/src/types/models.ts:109
Copy message text to clipboard — the one action core honors alone. Default: false
retry?
Section titled “retry?”optional retry?: boolean;Defined in: packages/core/src/types/models.ts:111
Retry / regenerate the response (assistant bubbles). Needs a host to re-send. Default: false
optional edit?: boolean;Defined in: packages/core/src/types/models.ts:113
Edit the sent message inline (user bubbles). Needs a host to keep the new text. Default: false
feedback?
Section titled “feedback?”optional feedback?: boolean;Defined in: packages/core/src/types/models.ts:115
Thumbs-up / thumbs-down feedback (assistant bubbles). Needs a listener. Default: false
feedbackReasons?
Section titled “feedbackReasons?”optional feedbackReasons?: readonly string[];Defined in: packages/core/src/types/models.ts:120
Reasons to offer after a thumbs-down, in your words and language. One press sends
aparte-feedback-reason; aparte-feedback has already gone out with the thumb.
optional info?: boolean;Defined in: packages/core/src/types/models.ts:126
The details (“i”) button, which opens the app-owned stats popover by
emitting aparte-message-info (assistant bubbles). Rendered only when the
message also carries a usage — no numbers, nothing to show. Default: false
optional user?: AparteBubbleActionName[];Defined in: packages/core/src/types/models.ts:128
Explicit, ordered action set for USER bubbles. Example: ['edit', 'copy'].
assistant?
Section titled “assistant?”optional assistant?: AparteBubbleActionName[];Defined in: packages/core/src/types/models.ts:130
Explicit, ordered action set for ASSISTANT bubbles. Example: ['copy', 'thumbUp', 'thumbDown', 'retry'].
AparteHostHandlersConfig
Section titled “AparteHostHandlersConfig”Defined in: packages/core/src/types/models.ts:146
The affordances core RENDERS but cannot COMPLETE — each one only asks, through a
DOM event, and the app does the work. Declare what your app actually handles
with aparteGlobalConfig.setHostHandlers(); everything else stays out of the UI
rather than showing a control that answers to nobody.
aparteGlobalConfig.setHostHandlers({ attachmentPreview: true }); // you open a lightboxThese are declarations, not callbacks: the event (aparte-attachment-preview)
is unchanged, and you keep listening for it wherever you already do.
Properties
Section titled “Properties”attachmentPreview?
Section titled “attachmentPreview?”optional attachmentPreview?: boolean;Defined in: packages/core/src/types/models.ts:152
Clicking an image attachment asks for a full-size preview
(aparte-attachment-preview) — core owns no lightbox. Until declared, the
tile is inert and is not signalled as a button. Default: false
filePreview?
Section titled “filePreview?”optional filePreview?: boolean;Defined in: packages/core/src/types/models.ts:160
Clicking a file — not an image — in a sent message asks for it to be opened, with the
same aparte-attachment-preview and its type. Its own declaration, so a lightbox
written for images is never handed a PDF: you claim files when you open them, in a
new tab for instance. Only a file whose URL a tab can open (an object URL, a remote
one) becomes a button. Default: false
AparteContextSummary
Section titled “AparteContextSummary”Defined in: packages/core/src/types/models.ts:169
A checkpoint over a kept history: what the model reads in place of the messages
before the one that carries it. Written by whoever summarises
(@aparte/plugin-compaction, or a host summarising by other means) onto the first
kept message as AparteMessage.contextSummary.
Properties
Section titled “Properties”summary
Section titled “summary”summary: string;Defined in: packages/core/src/types/models.ts:171
What the model reads in place of every message before this one on the path.
count: number;Defined in: packages/core/src/types/models.ts:174
How many messages of the path the summary stands for — the separator’s “N”.
createdAt
Section titled “createdAt”createdAt: number;Defined in: packages/core/src/types/models.ts:177
When the summary was written, in epoch milliseconds.
AparteMessage
Section titled “AparteMessage”Defined in: packages/core/src/types/models.ts:184
Core message structure for the chat Supports both simple content and rich multi-segment content
Properties
Section titled “Properties”id: string;Defined in: packages/core/src/types/models.ts:186
Unique identifier for the message
role: AparteBubbleRole;Defined in: packages/core/src/types/models.ts:189
Role of the message sender
content?
Section titled “content?”optional content?: string;Defined in: packages/core/src/types/models.ts:195
Simple text content (for basic messages)
Use segments for rich content with multiple parts
segments?
Section titled “segments?”optional segments?: AparteSegment[];Defined in: packages/core/src/types/models.ts:201
Rich content segments (thinking, code, tool calls, artifacts, …)
Takes precedence over content if provided
timestamp
Section titled “timestamp”timestamp: number;Defined in: packages/core/src/types/models.ts:204
Unix timestamp of message creation
isStreaming?
Section titled “isStreaming?”optional isStreaming?: boolean;Defined in: packages/core/src/types/models.ts:207
Whether the message is still being streamed
status?
Section titled “status?”optional status?: AparteStatus;Defined in: packages/core/src/types/models.ts:210
Current status of the message
attachments?
Section titled “attachments?”optional attachments?: AparteAttachment[];Defined in: packages/core/src/types/models.ts:213
Optional attachments (images, files, etc.)
usage?
Section titled “usage?”optional usage?: AparteUsage;Defined in: packages/core/src/types/models.ts:216
Token usage + timing reported by the provider for assistant messages.
finishReason?
Section titled “finishReason?”optional finishReason?: AparteFinishReason;Defined in: packages/core/src/types/models.ts:223
Why the model stopped writing this reply, when the provider said. Kept with the
message, so a reply cut off at the length limit ('length') still says so after a
reload.
model?
Section titled “model?”optional model?: {
providerId: string;
modelId: string;
temperature?: number;
};Defined in: packages/core/src/types/models.ts:230
The provider, model and temperature an assistant turn ran on, written by
AparteClient when the turn starts. A turn a server paused is resumed on them after
a reload (resumeDeferred), not on whatever model is selected by then.
providerId
Section titled “providerId”providerId: string;modelId
Section titled “modelId”modelId: string;temperature?
Section titled “temperature?”optional temperature?: number;compaction?
Section titled “compaction?”optional compaction?: true;Defined in: packages/core/src/types/models.ts:242
This message is the summary @aparte/plugin-compaction injected in place of the
turns it summarised (a host that summarises by other means sets the flag too). Its role is user — the summary is context handed to the
model, and a system message mid-conversation is refused by some providers —
but it is not something the user said: the bubble draws a separator in its place
(“Earlier messages were summarised”, with the summary behind Show summary; no
count and no Restore, since an older compaction replaced the turns) and the history
sends it under a fixed preamble saying what it is. A compaction that keeps the
messages writes AparteMessage.contextSummary instead.
contextSummary?
Section titled “contextSummary?”optional contextSummary?: AparteContextSummary;Defined in: packages/core/src/types/models.ts:253
A checkpoint: from this message on, the model reads contextSummary.summary in
place of every message before it on the path. Nothing before it is deleted — the
reader still scrolls up to them, a host still stores them — only what goes to the
model is shortened (historyFromCheckpoint). It sits on the first KEPT message,
which is a user message, so the history still alternates its roles.
Absent and undefined mean the same thing: no checkpoint here.
contextEstimate?
Section titled “contextEstimate?”optional contextEstimate?: number;Defined in: packages/core/src/types/models.ts:262
The estimate, in tokens, of the request that produced this reply, recorded by
AparteClient when it sends. Read back beside the provider’s real input count
(usage.inputTokens) to calibrate the context measure: the ratio of the two says
how far the character heuristic is off for this model and this conversation.
Absent when the request carried a part the heuristic cannot count (an image).
tokens?
Section titled “tokens?”optional tokens?: AparteMessageToken[];Defined in: packages/core/src/types/models.ts:268
The tokens this message was written with (mentions, a picked file), each with its
place in content. The bubble draws them as they looked in the composer.
metadata?
Section titled “metadata?”optional metadata?: Record<string, unknown>;Defined in: packages/core/src/types/models.ts:271
Optional metadata for custom properties
AparteAttachmentState
Section titled “AparteAttachmentState”Defined in: packages/core/src/types/models.ts:275
How the upload of a picked file is going (composer.setAttachmentState).
Properties
Section titled “Properties”status
Section titled “status”status: "error" | "uploading" | "done";Defined in: packages/core/src/types/models.ts:276
progress?
Section titled “progress?”optional progress?: number;Defined in: packages/core/src/types/models.ts:278
From 0 to 100. Without it, an uploading file shows a moving bar.
AparteComposerToken
Section titled “AparteComposerToken”Defined in: packages/core/src/types/models.ts:282
A pill in the composer: what it shows, and what the message says in its place.
Extended by
Section titled “Extended by”Properties
Section titled “Properties”label: string;Defined in: packages/core/src/types/models.ts:284
What the pill shows.
optional text?: string;Defined in: packages/core/src/types/models.ts:286
What the message contains in its place. Defaults to label.
optional kind?: string;Defined in: packages/core/src/types/models.ts:288
A name of your own, mention or file. Reaches the page as data-kind on the pill.
optional data?: unknown;Defined in: packages/core/src/types/models.ts:290
Whatever the app wants back with the message: an id, a path. Never shown; must survive JSON.
AparteMessageToken
Section titled “AparteMessageToken”Defined in: packages/core/src/types/models.ts:294
A token of a sent message, with where it sits in content (end excluded).
Extends
Section titled “Extends”Properties
Section titled “Properties”label: string;Defined in: packages/core/src/types/models.ts:284
What the pill shows.
Inherited from
Section titled “Inherited from”optional kind?: string;Defined in: packages/core/src/types/models.ts:288
A name of your own, mention or file. Reaches the page as data-kind on the pill.
Inherited from
Section titled “Inherited from”optional data?: unknown;Defined in: packages/core/src/types/models.ts:290
Whatever the app wants back with the message: an id, a path. Never shown; must survive JSON.
Inherited from
Section titled “Inherited from”text: string;Defined in: packages/core/src/types/models.ts:295
What the message contains in its place. Defaults to label.
Overrides
Section titled “Overrides”start: number;Defined in: packages/core/src/types/models.ts:296
end: number;Defined in: packages/core/src/types/models.ts:297
AparteComposerCaret
Section titled “AparteComposerCaret”Defined in: packages/core/src/types/models.ts:301
The caret in a draft. Offsets count one unit per character, per line break and per token.
Properties
Section titled “Properties”text: string;Defined in: packages/core/src/types/models.ts:303
The draft, where each token is one U+FFFC character.
offset
Section titled “offset”offset: number;Defined in: packages/core/src/types/models.ts:304
AparteViewportConfig
Section titled “AparteViewportConfig”Defined in: packages/core/src/types/models.ts:312
Configuration options for AparteChatViewport
Properties
Section titled “Properties”scrollThreshold?
Section titled “scrollThreshold?”optional scrollThreshold?: number;Defined in: packages/core/src/types/models.ts:314
Threshold in pixels for smart scroll detection
maxRenderedBubbles?
Section titled “maxRenderedBubbles?”optional maxRenderedBubbles?: number;Defined in: packages/core/src/types/models.ts:322
DOM render cap: the max number of bubbles kept in the DOM at once (a perf ceiling for very long conversations). This does NOT evict messages from the conversation model — the full tree and its persistence snapshot stay intact. Defaults to 1000.
layoutTransitionMs?
Section titled “layoutTransitionMs?”optional layoutTransitionMs?: number;Defined in: packages/core/src/types/models.ts:330
Duration in milliseconds to freeze spacer recalculation after resetSpacer().
Set this to the duration of any CSS layout transition in the host app
(e.g. the flex animation that moves the composer from center to bottom).
Defaults to 0 (no freeze). Example: 350 when transition: flex 0.3s ease is used.
AparteInputConfig
Section titled “AparteInputConfig”Defined in: packages/core/src/types/models.ts:334
Configuration options for the composer input.
Properties
Section titled “Properties”placeholder?
Section titled “placeholder?”optional placeholder?: string;Defined in: packages/core/src/types/models.ts:336
Placeholder text for the input
maxHeight?
Section titled “maxHeight?”optional maxHeight?: number;Defined in: packages/core/src/types/models.ts:339
Maximum height in pixels for auto-expand
minHeight?
Section titled “minHeight?”optional minHeight?: number;Defined in: packages/core/src/types/models.ts:342
Minimum height in pixels
AparteContentParser
Section titled “AparteContentParser”Defined in: packages/core/src/types/parsers.ts:15
Content parser plugin interface for external parsers Allows integration of Markdown, code highlighting, LaTeX, etc. without adding dependencies to the core
Properties
Section titled “Properties”id: string;Defined in: packages/core/src/types/parsers.ts:17
Unique identifier for the parser
priority
Section titled “priority”priority: number;Defined in: packages/core/src/types/parsers.ts:20
Priority for parser execution (higher = first)
Methods
Section titled “Methods”canParse()
Section titled “canParse()”canParse(content): boolean;Defined in: packages/core/src/types/parsers.ts:27
Check if this parser can handle the content
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
content | string | Raw content to check |
Returns
Section titled “Returns”boolean
true if parser should process this content
parse()
Section titled “parse()”parse(content): string;Defined in: packages/core/src/types/parsers.ts:34
Parse content and return transformed output
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
content | string | Raw content to parse |
Returns
Section titled “Returns”string
Parsed HTML string or transformed content
AparteSegmentBase
Section titled “AparteSegmentBase”Defined in: packages/core/src/types/segments.ts:11
Base segment interface - all segments extend this
Extended by
Section titled “Extended by”AparteTextSegmentAparteThinkingSegmentAparteCodeSegmentAparteCustomSegmentAparteToolCallSegmentAparteErrorSegment
Properties
Section titled “Properties”id: string;Defined in: packages/core/src/types/segments.ts:13
Unique segment identifier
type: string;Defined in: packages/core/src/types/segments.ts:16
Segment type discriminator
isStreaming?
Section titled “isStreaming?”optional isStreaming?: boolean;Defined in: packages/core/src/types/segments.ts:19
Whether segment is currently being streamed
fallback?
Section titled “fallback?”optional fallback?: string;Defined in: packages/core/src/types/segments.ts:36
One sentence standing in for the segment when no renderer claims its type —
DRAWN for every type, not only for custom.
It is the answer to a real moment: a conversation replayed in another app, a
client that loads its views lazily, an export. Core draws it as text (no markup)
under .aparte-segment-fallback. Supplying one also silences the “no renderer”
developer warning: an author who wrote a fallback has already said this can happen.
In the HISTORY sent back to the model it stands in for the segment only where core
does not serialise the type itself — custom, and any type core does not know (a
registered block grammar’s, a plugin’s). A text or a code segment contributes
its content and nothing else; thinking and tool_call are left out of the history
on purpose (segmentsToWireText states why), and so is error.
messageId?
Section titled “messageId?”optional messageId?: string;Defined in: packages/core/src/types/segments.ts:55
Id of the message this segment belongs to. Stamped on insertion.
index?
Section titled “index?”optional index?: number;Defined in: packages/core/src/types/segments.ts:61
Position in the owning message’s segments[], maintained across
insertions and removals.
optional meta?: Record<string, unknown> & {
aparte?: AparteSegmentTiming;
};Defined in: packages/core/src/types/segments.ts:71
Extras the producer of the segment knows — token counts, cost, compute
device — plus aparte, the one sub-object core writes.
Everything except meta.aparte is yours: fill it with
updateSegment(segmentId, { meta }), which MERGES rather than replaces.
Mirrors AparteMessage.metadata.
Type Declaration
Section titled “Type Declaration”aparte?
Section titled “aparte?”optional aparte?: AparteSegmentTiming;AparteSegmentTiming
Section titled “AparteSegmentTiming”Defined in: packages/core/src/types/segments.ts:93
What core measured about a segment. Lives in meta.aparte, not on the segment.
No protocol carries a timestamp on a content block: Anthropic’s
blocks have none (and neither does the message), OpenAI’s output_text part is
{annotations, logprobs, text, type} with created_at on the item above it, and the
AI SDK’s UIMessage.parts have none either. What the AI SDK does have is a metadata
bag whose canonical example is literally { createdAt, model, totalTokens } — at the
message level. A per-block id has industry precedent; per-block time has none.
So this is a local measurement, and the shape says so. It stays typed, and it is
namespaced under
aparte because meta is the consumer’s: a flat startedAt there would collide
with a key of their own.
Core reads it through segmentDuration and isSegmentSettled. It draws
one number, and only when asked: a reasoning block with showDuration reads its
duration once settled. Every other display of it is the app’s.
Properties
Section titled “Properties”startedAt?
Section titled “startedAt?”optional startedAt?: number;Defined in: packages/core/src/types/segments.ts:95
Epoch ms when the segment entered a LIVE transcript. Absent for history.
endedAt?
Section titled “endedAt?”optional endedAt?: number;Defined in: packages/core/src/types/segments.ts:111
Epoch ms when content last arrived on this segment.
It ADVANCES while the segment streams and freezes when the segment settles, so
endedAt - startedAt is a live duration during a turn and a final one after it
— ask isSegmentSettled(segment) which you are looking at.
Why not simply “when it finished”: the two obvious rules are both wrong, and measurably. Closing at the end of the turn makes a reasoning block span the whole answer that followed it (2s of thinking before a 20s reply reads ”22s”). Closing when the next segment opens is the same error, smaller — a gap of ten seconds before the next segment is counted as thinking, while the person watching knows nothing happened. The last delta is the only moment the segment itself can vouch for.
AparteTextSegment
Section titled “AparteTextSegment”Defined in: packages/core/src/types/segments.ts:120
Text segment - plain text content
Example
Section titled “Example”{ id: 's1', type: 'text', content: 'A transport is the object that talks to the model.' }Extends
Section titled “Extends”Properties
Section titled “Properties”id: string;Defined in: packages/core/src/types/segments.ts:13
Unique segment identifier
Inherited from
Section titled “Inherited from”isStreaming?
Section titled “isStreaming?”optional isStreaming?: boolean;Defined in: packages/core/src/types/segments.ts:19
Whether segment is currently being streamed
Inherited from
Section titled “Inherited from”fallback?
Section titled “fallback?”optional fallback?: string;Defined in: packages/core/src/types/segments.ts:36
One sentence standing in for the segment when no renderer claims its type —
DRAWN for every type, not only for custom.
It is the answer to a real moment: a conversation replayed in another app, a
client that loads its views lazily, an export. Core draws it as text (no markup)
under .aparte-segment-fallback. Supplying one also silences the “no renderer”
developer warning: an author who wrote a fallback has already said this can happen.
In the HISTORY sent back to the model it stands in for the segment only where core
does not serialise the type itself — custom, and any type core does not know (a
registered block grammar’s, a plugin’s). A text or a code segment contributes
its content and nothing else; thinking and tool_call are left out of the history
on purpose (segmentsToWireText states why), and so is error.
Inherited from
Section titled “Inherited from”messageId?
Section titled “messageId?”optional messageId?: string;Defined in: packages/core/src/types/segments.ts:55
Id of the message this segment belongs to. Stamped on insertion.
Inherited from
Section titled “Inherited from”index?
Section titled “index?”optional index?: number;Defined in: packages/core/src/types/segments.ts:61
Position in the owning message’s segments[], maintained across
insertions and removals.
Inherited from
Section titled “Inherited from”optional meta?: Record<string, unknown> & {
aparte?: AparteSegmentTiming;
};Defined in: packages/core/src/types/segments.ts:71
Extras the producer of the segment knows — token counts, cost, compute
device — plus aparte, the one sub-object core writes.
Everything except meta.aparte is yours: fill it with
updateSegment(segmentId, { meta }), which MERGES rather than replaces.
Mirrors AparteMessage.metadata.
Type Declaration
Section titled “Type Declaration”aparte?
Section titled “aparte?”optional aparte?: AparteSegmentTiming;Inherited from
Section titled “Inherited from”type: "text";Defined in: packages/core/src/types/segments.ts:121
Segment type discriminator
Overrides
Section titled “Overrides”content
Section titled “content”content: string;Defined in: packages/core/src/types/segments.ts:122
sources?
Section titled “sources?”optional sources?: AparteSource[];Defined in: packages/core/src/types/segments.ts:127
The sources this text draws on — a web search’s results, the documents it quotes. The bubble lists them under the reply; a AparteCitation places a chip in the text.
citations?
Section titled “citations?”optional citations?: AparteCitation[];Defined in: packages/core/src/types/segments.ts:129
Where in content each source is cited: a chip at the end of the passage.
AparteSource
Section titled “AparteSource”Defined in: packages/core/src/types/segments.ts:133
One source a reply draws on. Shown by its domain, its title in the card and the list.
Properties
Section titled “Properties”id: string;Defined in: packages/core/src/types/segments.ts:135
Unique within the message; what a AparteCitation names.
optional url?: string;Defined in: packages/core/src/types/segments.ts:137
Only https:, http: and the like are linked (the sanitizer’s URL policy).
title?
Section titled “title?”optional title?: string;Defined in: packages/core/src/types/segments.ts:138
snippet?
Section titled “snippet?”optional snippet?: string;Defined in: packages/core/src/types/segments.ts:140
A short excerpt, shown in the card.
AparteCitation
Section titled “AparteCitation”Defined in: packages/core/src/types/segments.ts:151
A passage of a text segment that cites sources: offsets into the segment’s content,
in UTF-16 code units (JavaScript string indices), end exclusive. The chip goes at the
end of the passage — after its punctuation, never inside code, emphasis or a link.
Example
Section titled “Example”{ end: 42, sources: ['s1', 's3'] }Properties
Section titled “Properties”start?
Section titled “start?”optional start?: number;Defined in: packages/core/src/types/segments.ts:152
end: number;Defined in: packages/core/src/types/segments.ts:153
sources
Section titled “sources”sources: string[];Defined in: packages/core/src/types/segments.ts:155
Ids of the AparteSources, in the order the card pages through them.
marker?
Section titled “marker?”optional marker?: boolean;Defined in: packages/core/src/types/segments.ts:160
[start, end) is a marker the model wrote for the citation (Perplexity’s [1]): the
chip takes its place on screen. The text itself is left as it was written.
AparteThinkingSegment
Section titled “AparteThinkingSegment”Defined in: packages/core/src/types/segments.ts:193
Thinking/reasoning segment - collapsible.
A literal <think>…</think> in a reply is read as reasoning on every path — while
it streams and when the reply is restored from storage — so a message that merely
quotes the tag in its prose becomes this segment rather than text; and reasoning is
deliberately not sent back to the model, so those words leave the wire history with
it. Models whose reasoning is marked differently are handled by the parser’s
thinkingDelimiters.
Example
Section titled “Example”// No `collapsed` key, so it renders CLOSED — see the field's own note below.
{
id: 's1',
type: 'thinking',
label: 'Reasoning',
content: 'The question is about transports, so name the two and say where the key lives.',
}Extends
Section titled “Extends”Properties
Section titled “Properties”id: string;Defined in: packages/core/src/types/segments.ts:13
Unique segment identifier
Inherited from
Section titled “Inherited from”isStreaming?
Section titled “isStreaming?”optional isStreaming?: boolean;Defined in: packages/core/src/types/segments.ts:19
Whether segment is currently being streamed
Inherited from
Section titled “Inherited from”fallback?
Section titled “fallback?”optional fallback?: string;Defined in: packages/core/src/types/segments.ts:36
One sentence standing in for the segment when no renderer claims its type —
DRAWN for every type, not only for custom.
It is the answer to a real moment: a conversation replayed in another app, a
client that loads its views lazily, an export. Core draws it as text (no markup)
under .aparte-segment-fallback. Supplying one also silences the “no renderer”
developer warning: an author who wrote a fallback has already said this can happen.
In the HISTORY sent back to the model it stands in for the segment only where core
does not serialise the type itself — custom, and any type core does not know (a
registered block grammar’s, a plugin’s). A text or a code segment contributes
its content and nothing else; thinking and tool_call are left out of the history
on purpose (segmentsToWireText states why), and so is error.
Inherited from
Section titled “Inherited from”messageId?
Section titled “messageId?”optional messageId?: string;Defined in: packages/core/src/types/segments.ts:55
Id of the message this segment belongs to. Stamped on insertion.
Inherited from
Section titled “Inherited from”index?
Section titled “index?”optional index?: number;Defined in: packages/core/src/types/segments.ts:61
Position in the owning message’s segments[], maintained across
insertions and removals.
Inherited from
Section titled “Inherited from”optional meta?: Record<string, unknown> & {
aparte?: AparteSegmentTiming;
};Defined in: packages/core/src/types/segments.ts:71
Extras the producer of the segment knows — token counts, cost, compute
device — plus aparte, the one sub-object core writes.
Everything except meta.aparte is yours: fill it with
updateSegment(segmentId, { meta }), which MERGES rather than replaces.
Mirrors AparteMessage.metadata.
Type Declaration
Section titled “Type Declaration”aparte?
Section titled “aparte?”optional aparte?: AparteSegmentTiming;Inherited from
Section titled “Inherited from”type: "thinking";Defined in: packages/core/src/types/segments.ts:194
Segment type discriminator
Overrides
Section titled “Overrides”content
Section titled “content”content: string;Defined in: packages/core/src/types/segments.ts:195
collapsed?
Section titled “collapsed?”optional collapsed?: boolean;Defined in: packages/core/src/types/segments.ts:202
Open the block. Absent means CLOSED — a reasoning block is a disclosure, and the reader opens it. The content is behind a click, streaming or settled.
false opens one on purpose.
label?
Section titled “label?”optional label?: string;Defined in: packages/core/src/types/segments.ts:203
showDuration?
Section titled “showDuration?”optional showDuration?: boolean;Defined in: packages/core/src/types/segments.ts:214
Once settled, read “Thought for 8s” rather than “Thought”. Off by default: the
duration is measured in the browser, from the first reasoning delta to the last,
which is the model’s thinking time only when the provider streams its reasoning — a
provider that sends it in one piece would read “1s”, and a reload shows it only if
the stored segment kept its meta. Usually turned on for every block with
setSegmentDefaults('thinking', { showDuration: true }), which a block restored
from storage follows too (it is read when the block is drawn); the block’s own
field wins.
AparteCodeSegment
Section titled “AparteCodeSegment”Defined in: packages/core/src/types/segments.ts:232
Code segment - syntax highlighted code block
Highlighting is a plugin you opt into; with none installed the block renders plain, which is what core’s zero-dependency promise costs here.
Example
Section titled “Example”{
* id: 's1',
* type: 'code',
* language: 'ts',
* filename: 'transport.ts',
* content: "const transport = new AparteBackendTransport({ endpoint: '/api/chat' });",
* }Extends
Section titled “Extends”Properties
Section titled “Properties”id: string;Defined in: packages/core/src/types/segments.ts:13
Unique segment identifier
Inherited from
Section titled “Inherited from”isStreaming?
Section titled “isStreaming?”optional isStreaming?: boolean;Defined in: packages/core/src/types/segments.ts:19
Whether segment is currently being streamed
Inherited from
Section titled “Inherited from”fallback?
Section titled “fallback?”optional fallback?: string;Defined in: packages/core/src/types/segments.ts:36
One sentence standing in for the segment when no renderer claims its type —
DRAWN for every type, not only for custom.
It is the answer to a real moment: a conversation replayed in another app, a
client that loads its views lazily, an export. Core draws it as text (no markup)
under .aparte-segment-fallback. Supplying one also silences the “no renderer”
developer warning: an author who wrote a fallback has already said this can happen.
In the HISTORY sent back to the model it stands in for the segment only where core
does not serialise the type itself — custom, and any type core does not know (a
registered block grammar’s, a plugin’s). A text or a code segment contributes
its content and nothing else; thinking and tool_call are left out of the history
on purpose (segmentsToWireText states why), and so is error.
Inherited from
Section titled “Inherited from”messageId?
Section titled “messageId?”optional messageId?: string;Defined in: packages/core/src/types/segments.ts:55
Id of the message this segment belongs to. Stamped on insertion.
Inherited from
Section titled “Inherited from”index?
Section titled “index?”optional index?: number;Defined in: packages/core/src/types/segments.ts:61
Position in the owning message’s segments[], maintained across
insertions and removals.
Inherited from
Section titled “Inherited from”optional meta?: Record<string, unknown> & {
aparte?: AparteSegmentTiming;
};Defined in: packages/core/src/types/segments.ts:71
Extras the producer of the segment knows — token counts, cost, compute
device — plus aparte, the one sub-object core writes.
Everything except meta.aparte is yours: fill it with
updateSegment(segmentId, { meta }), which MERGES rather than replaces.
Mirrors AparteMessage.metadata.
Type Declaration
Section titled “Type Declaration”aparte?
Section titled “aparte?”optional aparte?: AparteSegmentTiming;Inherited from
Section titled “Inherited from”type: "code";Defined in: packages/core/src/types/segments.ts:233
Segment type discriminator
Overrides
Section titled “Overrides”content
Section titled “content”content: string;Defined in: packages/core/src/types/segments.ts:234
language?
Section titled “language?”optional language?: string;Defined in: packages/core/src/types/segments.ts:235
filename?
Section titled “filename?”optional filename?: string;Defined in: packages/core/src/types/segments.ts:236
AparteErrorSegment
Section titled “AparteErrorSegment”Defined in: packages/core/src/types/segments.ts:253
Error segment
A failure card inside the turn that produced it, rather than a toast somewhere else on the page — so the reader can see which question failed.
Example
Section titled “Example”{
* id: 's1',
* type: 'error',
* content: 'The model did not answer.',
* details: 'HTTP 429 — rate limited. Retrying in 20s.',
* }Extends
Section titled “Extends”Properties
Section titled “Properties”id: string;Defined in: packages/core/src/types/segments.ts:13
Unique segment identifier
Inherited from
Section titled “Inherited from”isStreaming?
Section titled “isStreaming?”optional isStreaming?: boolean;Defined in: packages/core/src/types/segments.ts:19
Whether segment is currently being streamed
Inherited from
Section titled “Inherited from”fallback?
Section titled “fallback?”optional fallback?: string;Defined in: packages/core/src/types/segments.ts:36
One sentence standing in for the segment when no renderer claims its type —
DRAWN for every type, not only for custom.
It is the answer to a real moment: a conversation replayed in another app, a
client that loads its views lazily, an export. Core draws it as text (no markup)
under .aparte-segment-fallback. Supplying one also silences the “no renderer”
developer warning: an author who wrote a fallback has already said this can happen.
In the HISTORY sent back to the model it stands in for the segment only where core
does not serialise the type itself — custom, and any type core does not know (a
registered block grammar’s, a plugin’s). A text or a code segment contributes
its content and nothing else; thinking and tool_call are left out of the history
on purpose (segmentsToWireText states why), and so is error.
Inherited from
Section titled “Inherited from”messageId?
Section titled “messageId?”optional messageId?: string;Defined in: packages/core/src/types/segments.ts:55
Id of the message this segment belongs to. Stamped on insertion.
Inherited from
Section titled “Inherited from”index?
Section titled “index?”optional index?: number;Defined in: packages/core/src/types/segments.ts:61
Position in the owning message’s segments[], maintained across
insertions and removals.
Inherited from
Section titled “Inherited from”optional meta?: Record<string, unknown> & {
aparte?: AparteSegmentTiming;
};Defined in: packages/core/src/types/segments.ts:71
Extras the producer of the segment knows — token counts, cost, compute
device — plus aparte, the one sub-object core writes.
Everything except meta.aparte is yours: fill it with
updateSegment(segmentId, { meta }), which MERGES rather than replaces.
Mirrors AparteMessage.metadata.
Type Declaration
Section titled “Type Declaration”aparte?
Section titled “aparte?”optional aparte?: AparteSegmentTiming;Inherited from
Section titled “Inherited from”type: "error";Defined in: packages/core/src/types/segments.ts:254
Segment type discriminator
Overrides
Section titled “Overrides”content
Section titled “content”content: string;Defined in: packages/core/src/types/segments.ts:261
The error’s own message, for storage, the console and a custom error renderer. The default alert shows it only for an error that keeps its own words (the turn limit, a setup error, an app’s own code); for any other code it shows the sentence the code reads as, in the reader’s language.
details?
Section titled “details?”optional details?: string;Defined in: packages/core/src/types/segments.ts:263
Text the alert shows under the message, in a block — a stack, a status line an app chooses to show.
optional code?: string;Defined in: packages/core/src/types/segments.ts:270
A machine-readable code for the app to branch on — an AparteErrorCode value when
core made the error (AparteErrorCode.MAX_TURNS_EXCEEDED, PROVIDER_ERROR…). Never drawn
itself: it picks the sentence the alert shows, the alert carries it as
data-error-code, and a custom error renderer receives it.
AparteToolCallSegment
Section titled “AparteToolCallSegment”Defined in: packages/core/src/types/segments.ts:285
Tool call segment - rendered while waiting for a tool handler to resolve
Example
Section titled “Example”{
* id: 's1',
* type: 'tool_call',
* status: 'resolved',
* toolCall: { id: 'call_1', name: 'get_weather', input: { city: 'Lille' } },
* result: '11°C, overcast.',
* }Extends
Section titled “Extends”Properties
Section titled “Properties”id: string;Defined in: packages/core/src/types/segments.ts:13
Unique segment identifier
Inherited from
Section titled “Inherited from”isStreaming?
Section titled “isStreaming?”optional isStreaming?: boolean;Defined in: packages/core/src/types/segments.ts:19
Whether segment is currently being streamed
Inherited from
Section titled “Inherited from”fallback?
Section titled “fallback?”optional fallback?: string;Defined in: packages/core/src/types/segments.ts:36
One sentence standing in for the segment when no renderer claims its type —
DRAWN for every type, not only for custom.
It is the answer to a real moment: a conversation replayed in another app, a
client that loads its views lazily, an export. Core draws it as text (no markup)
under .aparte-segment-fallback. Supplying one also silences the “no renderer”
developer warning: an author who wrote a fallback has already said this can happen.
In the HISTORY sent back to the model it stands in for the segment only where core
does not serialise the type itself — custom, and any type core does not know (a
registered block grammar’s, a plugin’s). A text or a code segment contributes
its content and nothing else; thinking and tool_call are left out of the history
on purpose (segmentsToWireText states why), and so is error.
Inherited from
Section titled “Inherited from”messageId?
Section titled “messageId?”optional messageId?: string;Defined in: packages/core/src/types/segments.ts:55
Id of the message this segment belongs to. Stamped on insertion.
Inherited from
Section titled “Inherited from”index?
Section titled “index?”optional index?: number;Defined in: packages/core/src/types/segments.ts:61
Position in the owning message’s segments[], maintained across
insertions and removals.
Inherited from
Section titled “Inherited from”optional meta?: Record<string, unknown> & {
aparte?: AparteSegmentTiming;
};Defined in: packages/core/src/types/segments.ts:71
Extras the producer of the segment knows — token counts, cost, compute
device — plus aparte, the one sub-object core writes.
Everything except meta.aparte is yours: fill it with
updateSegment(segmentId, { meta }), which MERGES rather than replaces.
Mirrors AparteMessage.metadata.
Type Declaration
Section titled “Type Declaration”aparte?
Section titled “aparte?”optional aparte?: AparteSegmentTiming;Inherited from
Section titled “Inherited from”type: "tool_call";Defined in: packages/core/src/types/segments.ts:286
Segment type discriminator
Overrides
Section titled “Overrides”toolCall
Section titled “toolCall”toolCall: AparteToolCall;Defined in: packages/core/src/types/segments.ts:287
status
Section titled “status”status:
| "pending"
| "resolved"
| "aborted"
| "awaiting-approval"
| "rejected"
| "failed";Defined in: packages/core/src/types/segments.ts:293
awaiting-approval — paused for a human decision; rejected — the human (or a
policy) declined to run it; aborted — stopped, timed out, or nothing could run
it; failed — the handler threw, and result carries the crash’s one line.
result?
Section titled “result?”optional result?: string;Defined in: packages/core/src/types/segments.ts:294
structuredResult?
Section titled “structuredResult?”optional structuredResult?: unknown;Defined in: packages/core/src/types/segments.ts:296
The handler’s structuredContent, when it returned one — the value behind result’s prose.
deferred?
Section titled “deferred?”optional deferred?: {
reason: "approval" | "external" | "queued";
ticket?: string;
};Defined in: packages/core/src/types/segments.ts:304
Set when a server loop (createAparteAgentHandler) suspended its run on this call:
why it waits — a person’s decision (approval), a tool the page runs
(external), or nothing but its turn (queued) — and the server’s signed
continuation. Saved with the conversation, so a reload can still answer it
(AparteClient.resumeDeferred).
reason
Section titled “reason”reason: "approval" | "external" | "queued";ticket?
Section titled “ticket?”optional ticket?: string;refusal?
Section titled “refusal?”optional refusal?: {
by: StreamRefusalOrigin;
instruction?: string;
};Defined in: packages/core/src/types/segments.ts:311
On a rejected call, who refused it — a person, a policy, or the loop because an
earlier call of the same step was refused — and what the person typed instead.
result is the sentence the MODEL read; this is what a row tells a person, in their
language. Absent on a call refused by a runner that does not say.
by: StreamRefusalOrigin;instruction?
Section titled “instruction?”optional instruction?: string;abortCause?
Section titled “abortCause?”optional abortCause?: StreamAbortCause | "turn-limit";Defined in: packages/core/src/types/segments.ts:316
On an aborted call, why: a Stop, its handler’s timeout, no handler here, a gate
with nobody to ask, or its own turn limit. Absent when the run ended before it.
collapsed?
Section titled “collapsed?”optional collapsed?: boolean;Defined in: packages/core/src/types/segments.ts:322
Whether the row’s disclosure starts closed. Absent: closed, unless the tool’s display
says open. setSegmentDefaults('tool_call', { collapsed: false }) opens every row;
like reasoning’s, it is read when the row is drawn and never forced on an update.
AparteCustomSegment
Section titled “AparteCustomSegment”Defined in: packages/core/src/types/segments.ts:361
Custom segment - one escape hatch for the views an app draws itself.
Renderers are keyed on type, so subType never reaches the registry: you
register ONE renderer for custom and switch on subType inside it, with fallback
as the default branch. Independent views take their own type instead — register a
chart renderer for a chart — and custom is for a family of small views an app
would rather keep behind one key.
Example
Section titled “Example”registerSegmentRenderer<AparteCustomSegment>({
type: 'custom',
render(segment) {
const data = (segment.data ?? {}) as Record<string, unknown>;
const el = document.createElement('div');
switch (segment.subType) {
case 'weather':
el.className = 'weather';
el.textContent = `${data['city']} — ${data['celsius']}°C`;
break;
case 'poll':
el.className = 'poll';
el.textContent = String(data['question']);
break;
default:
// A subType this build does not know: the sentence, not nothing.
el.textContent = segment.fallback ?? '';
}
return el;
},
});
// The segments that renderer draws:
{ id: 's1', type: 'custom', subType: 'weather', data: { city: 'Lille', celsius: 11 } }
{ id: 's2', type: 'custom', subType: 'gantt', fallback: 'Three tasks, ending Friday.' }Extends
Section titled “Extends”Properties
Section titled “Properties”id: string;Defined in: packages/core/src/types/segments.ts:13
Unique segment identifier
Inherited from
Section titled “Inherited from”isStreaming?
Section titled “isStreaming?”optional isStreaming?: boolean;Defined in: packages/core/src/types/segments.ts:19
Whether segment is currently being streamed
Inherited from
Section titled “Inherited from”fallback?
Section titled “fallback?”optional fallback?: string;Defined in: packages/core/src/types/segments.ts:36
One sentence standing in for the segment when no renderer claims its type —
DRAWN for every type, not only for custom.
It is the answer to a real moment: a conversation replayed in another app, a
client that loads its views lazily, an export. Core draws it as text (no markup)
under .aparte-segment-fallback. Supplying one also silences the “no renderer”
developer warning: an author who wrote a fallback has already said this can happen.
In the HISTORY sent back to the model it stands in for the segment only where core
does not serialise the type itself — custom, and any type core does not know (a
registered block grammar’s, a plugin’s). A text or a code segment contributes
its content and nothing else; thinking and tool_call are left out of the history
on purpose (segmentsToWireText states why), and so is error.
Inherited from
Section titled “Inherited from”messageId?
Section titled “messageId?”optional messageId?: string;Defined in: packages/core/src/types/segments.ts:55
Id of the message this segment belongs to. Stamped on insertion.
Inherited from
Section titled “Inherited from”index?
Section titled “index?”optional index?: number;Defined in: packages/core/src/types/segments.ts:61
Position in the owning message’s segments[], maintained across
insertions and removals.
Inherited from
Section titled “Inherited from”optional meta?: Record<string, unknown> & {
aparte?: AparteSegmentTiming;
};Defined in: packages/core/src/types/segments.ts:71
Extras the producer of the segment knows — token counts, cost, compute
device — plus aparte, the one sub-object core writes.
Everything except meta.aparte is yours: fill it with
updateSegment(segmentId, { meta }), which MERGES rather than replaces.
Mirrors AparteMessage.metadata.
Type Declaration
Section titled “Type Declaration”aparte?
Section titled “aparte?”optional aparte?: AparteSegmentTiming;Inherited from
Section titled “Inherited from”type: "custom";Defined in: packages/core/src/types/segments.ts:362
Segment type discriminator
Overrides
Section titled “Overrides”subType
Section titled “subType”subType: string;Defined in: packages/core/src/types/segments.ts:364
Which view inside the custom renderer draws this segment (e.g. ‘weather’, ‘poll’, ‘onboarding’).
optional data?: unknown;Defined in: packages/core/src/types/segments.ts:366
Arbitrary data payload for the component
AparteSegmentTypes
Section titled “AparteSegmentTypes”Defined in: packages/core/src/types/segments.ts:402
The segment types an app or a plugin adds, one key per type, merged into this interface;
each one joins AparteSegment, so addSegment, appendMessage and
AparteMessage.segments take it without a cast.
Example
Section titled “Example”declare module '@aparte/core' {
interface AparteSegmentTypes {
chart: AparteSegmentBase & { type: 'chart'; data: { label: string; value: number }[] };
}
}
viewport.addSegment('a1', { id: 'c1', type: 'chart', data: [{ label: 'Q1', value: 4 }] });AparteSegmentRenderer
Section titled “AparteSegmentRenderer”Defined in: packages/core/src/types/segments.ts:415
Segment renderer interface for custom segment types Implement this to add new segment renderers
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
T extends AparteSegmentBase | AparteSegmentBase |
Properties
Section titled “Properties”type: string;Defined in: packages/core/src/types/segments.ts:417
Segment type this renderer handles
Methods
Section titled “Methods”render()
Section titled “render()”render(segment): string | HTMLElement;Defined in: packages/core/src/types/segments.ts:433
Render a segment to either an HTML string or a ready DOM element.
Return a string for simple markup (inserted via innerHTML) — the built-in
renderers do this. Return an HTMLElement to skip innerHTML entirely: you
can attach event listeners and framework nodes directly, and there is no
innerHTML XSS surface for values you interpolate. Either way, setup() (if
provided) runs afterwards with the resulting element. For in-place streaming
updates to find your element, keep a data-segment-id="<segment.id>" on its
root (or implement update()).
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
segment | T | Segment data to render |
Returns
Section titled “Returns”string | HTMLElement
HTML string or a DOM element
getStyles()?
Section titled “getStyles()?”optional getStyles(): string;Defined in: packages/core/src/types/segments.ts:439
Optional: Get CSS styles for this segment type
Returns
Section titled “Returns”string
CSS string to inject
setup()?
Section titled “setup()?”optional setup(element, segment): void;Defined in: packages/core/src/types/segments.ts:446
Optional: Setup interactivity after render
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
element | HTMLElement | The rendered DOM element |
segment | T | Segment data |
Returns
Section titled “Returns”void
update()?
Section titled “update()?”optional update(element, segment): void;Defined in: packages/core/src/types/segments.ts:454
Optional: In-place DOM update during streaming. When provided, called instead of re-rendering the full element. Must not add/remove child nodes — only mutate attributes or textContent so the MutationObserver (childList) doesn’t fire and scroll stays stable.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
element | HTMLElement |
segment | T |
Returns
Section titled “Returns”void
relabel()?
Section titled “relabel()?”optional relabel(element, segment): void;Defined in: packages/core/src/types/segments.ts:478
Optional: re-read the CONFIG-DERIVED text of an already-rendered segment — an icon from the icon provider, a label from the locale.
Called when the config changes (a language switch, a new icon set), on every
segment already on screen. Bound by the same rule as update(): must not
add or remove child nodes — only attributes and textContent — so the
viewport’s childList observer stays quiet and scroll does not move.
This exists because the obvious alternative does not work. Re-rendering the
segments container to pick up a new locale destroys state the DOM owns and the
segment data does not: a mounted sandboxed artifact preview, a reasoning block
the reader expanded by clicking <summary> (which never writes back to
collapsed), scroll position inside a long terminal, the focus on an
Approve/Reject gate, and the buffered lookahead of the incremental Markdown
parser mid-stream. It also fires container-wide childList mutations, which is
exactly what the rule above forbids.
Implement it only if the rendered output contains text or icons that came from
the config. A renderer whose chrome is entirely its own data — progress,
text — correctly does not, exactly as it does not implement update().
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
element | HTMLElement |
segment | T |
Returns
Section titled “Returns”void
cleanup()?
Section titled “cleanup()?”optional cleanup(element, segment): void;Defined in: packages/core/src/types/segments.ts:500
Optional: the element render() returned is gone for good — unmount what you
mounted in it.
Called once per element, with the element and the segment’s latest state, when it
leaves the page for good: replaced by a new render() (a segment redrawn, a message
redrawn in a new frame, this renderer replaced by another registration), its segment
removed, or its message removed. Never for update() or relabel(), and never for
a message a framework only MOVED: a bubble taken out and put back before the next
microtask keeps its elements. A bubble that comes back after a longer absence (a
framework’s keep-alive cache, a reused route) draws its segments again, so a
renderer sees render/setup once more after its cleanup.
A renderer that replaces its own element inside update() cleans up what it
replaced itself: the bubble then follows the new element and calls this for it.
This hook was declared long before anything called it; it is called now.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
element | HTMLElement | The DOM element leaving |
segment | T | The segment it was last drawn or updated with |
Returns
Section titled “Returns”void
AparteSegmentUpdateEventDetail
Section titled “AparteSegmentUpdateEventDetail”Defined in: packages/core/src/types/segments.ts:512
Event when segment content is updated during streaming
Properties
Section titled “Properties”messageId
Section titled “messageId”messageId: string;Defined in: packages/core/src/types/segments.ts:513
segmentId
Section titled “segmentId”segmentId: string;Defined in: packages/core/src/types/segments.ts:514
content
Section titled “content”content: string;Defined in: packages/core/src/types/segments.ts:515
append?
Section titled “append?”optional append?: boolean;Defined in: packages/core/src/types/segments.ts:516
AparteStreamBlockMatch
Section titled “AparteStreamBlockMatch”Defined in: packages/core/src/types/stream-blocks.ts:24
What the parser hands to AparteStreamBlock.toSegment when a block opens.
Properties
Section titled “Properties”attrs: Record<string, string>;Defined in: packages/core/src/types/stream-blocks.ts:30
The opening tag’s attributes, as written: type="text/html", title='Notes'
and lang=fr all parse; the values are verbatim, never trimmed or decoded.
The model wrote them — treat them as untrusted, like every segment field.
id: string;Defined in: packages/core/src/types/stream-blocks.ts:32
The id the parser generated for the segment (its usual prefix + uuid).
AparteStreamBlock
Section titled “AparteStreamBlock”Defined in: packages/core/src/types/stream-blocks.ts:45
A block grammar: the tag, and the segment its body becomes.
The parser owns everything after toSegment returns: it appends each delta
to segment.content, sets isStreaming while the block is open and clears it at
</tag> (or at the end of the stream). So the segment MUST carry a content
string — the one field core touches — and the rest of its shape is yours:
a type of your own, registered with registerSegmentRenderer, or a built-in
one if the block is merely another way of spelling it.
Properties
Section titled “Properties”tag: string;Defined in: packages/core/src/types/stream-blocks.ts:51
The tag name without brackets: artifact recognises <artifact …> … </artifact>.
Matched exactly and case-sensitively, and only as a whole name — <artifacts>
does not open an artifact block. Letters, digits, - and _.
toSegment
Section titled “toSegment”toSegment: (match) => AparteSegmentBase & {
content: string;
};Defined in: packages/core/src/types/stream-blocks.ts:56
Build the segment at the opening tag, with an empty content. Called once per
block; the parser fills the body in afterwards.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
match | AparteStreamBlockMatch |
Returns
Section titled “Returns”AparteSegmentBase & {
content: string;
}
AparteTool
Section titled “AparteTool”Defined in: packages/core/src/types/tools.ts:10
Definition of a tool the AI can call
Properties
Section titled “Properties”name: string;Defined in: packages/core/src/types/tools.ts:11
description
Section titled “description”description: string;Defined in: packages/core/src/types/tools.ts:12
inputSchema
Section titled “inputSchema”inputSchema: Record<string, unknown>;Defined in: packages/core/src/types/tools.ts:14
JSON Schema object describing the tool’s input parameters
systemPrompt?
Section titled “systemPrompt?”optional systemPrompt?: string;Defined in: packages/core/src/types/tools.ts:16
System prompt injected automatically when this tool is registered — tells the AI when and why to use it
maxTurns?
Section titled “maxTurns?”optional maxTurns?: number;Defined in: packages/core/src/types/tools.ts:21
Maximum number of agentic loop turns before aborting.
Overrides the global maxTurns in AparteClientOptions for this specific tool.
needsApproval?
Section titled “needsApproval?”optional needsApproval?: boolean;Defined in: packages/core/src/types/tools.ts:37
When true, the agent loop pauses before running this tool’s handler and waits for a human decision — “human in the loop”.
The decision is asked AT THE COMPOSER, through the same requestUserInput
a tool handler calls: every request for the user is answered in one place.
The row in the transcript is the anchor, naming which tool is waiting, and
holds nothing clickable. An approvalResolver on AparteClientOptions
answers it programmatically instead.
On a refusal the rest of the turn is skipped — no later tool call of the same turn runs — and then the model gets a turn to answer it, so it can say what it will do instead. The refusal may carry the user’s own words.
AparteToolCall
Section titled “AparteToolCall”Defined in: packages/core/src/types/tools.ts:60
A tool call emitted by the AI during streaming
Properties
Section titled “Properties”id: string;Defined in: packages/core/src/types/tools.ts:61
name: string;Defined in: packages/core/src/types/tools.ts:62
input: Record<string, unknown>;Defined in: packages/core/src/types/tools.ts:63
AparteApprovalRuling
Section titled “AparteApprovalRuling”Defined in: packages/core/src/types/tools.ts:74
What an approval policy says about one call.
allow runs it without asking; ask puts it to the person the way a
needsApproval tool is put to them; deny refuses it on the spot, and reason is
the sentence the model reads about that refusal — verbatim, because nobody said
anything (“Plan mode: write_file changes files; only read-only tools run.”).
Properties
Section titled “Properties”verdict
Section titled “verdict”verdict: "allow" | "ask" | "deny";Defined in: packages/core/src/types/tools.ts:75
reason?
Section titled “reason?”optional reason?: string;Defined in: packages/core/src/types/tools.ts:76
AparteToolResult
Section titled “AparteToolResult”Defined in: packages/core/src/types/tools.ts:98
Result returned after a tool handler resolves
Properties
Section titled “Properties”toolCallId
Section titled “toolCallId”toolCallId: string;Defined in: packages/core/src/types/tools.ts:99
content
Section titled “content”content: string;Defined in: packages/core/src/types/tools.ts:101
What the model reads.
structuredContent?
Section titled “structuredContent?”optional structuredContent?: unknown;Defined in: packages/core/src/types/tools.ts:108
The same result as a value, for a renderer or the host — MCP’s name for exactly
this field, beside content. Optional and additive: a handler that returns prose
alone behaves as before, and the model never sees this. It lands on the
transcript’s segment as AparteToolCallSegment.structuredResult.
AparteToolContext
Section titled “AparteToolContext”Defined in: packages/core/src/types/tools.ts:136
Which chat a tool handler is running for.
Optional and third, so a handler that does not need it ignores it.
A handler needs it to reach the right instance: requestUserInput resolves its
presenter with resolveConfig(request.target ?? null), so without a target it
resolves against the GLOBAL config, finds no presenter on an instance config, and
rejects with an AparteElicitationAbortError (name 'AbortError', reason
'no-presenter'): nothing is shown. Pass target from this context.
The loop supplies it — runStreamAgent, or the runner you injected — so
a handler behaves the same whichever one is running.
Properties
Section titled “Properties”request?
Section titled “request?”optional request?: Request;Defined in: packages/core/src/types/tools.ts:142
On the server (createAparteAgentHandler): the request being served — the one that
started the run, or, for a call answered after a pause, the one that resumed it — for
a tool that checks who is calling. The model chose the arguments, not the caller.
target?
Section titled “target?”optional target?: HTMLElement;Defined in: packages/core/src/types/tools.ts:148
The chat element this turn belongs to. Pass it as target to
requestUserInput (or to anything else that resolves a config from the DOM)
and the right instance answers.
config?
Section titled “config?”optional config?: unknown;Defined in: packages/core/src/types/tools.ts:153
The resolved config for this chat, for a handler that needs it without going through the DOM — a handler running in a worker, or one reading a provider.
AparteToolDisplay
Section titled “AparteToolDisplay”Defined in: packages/core/src/types/tools.ts:197
How a tool’s calls are shown — registered with registerToolDisplay(matcher, display).
Every field is optional; what is left out keeps core’s default row. The tool’s NAME is
the app’s wire format and core never turns it into words on its own: label is how an
app gives a person something better to read than web_search.
Properties
Section titled “Properties”label?
Section titled “label?”optional label?: string | ((segment) => string);Defined in: packages/core/src/types/tools.ts:203
What the row and the approval question call the tool, in place of its identifier. Plain text, never HTML. A function reads the call (its status, its input); one that throws falls back to the identifier.
optional icon?:
| keyof AparteIconProvider
| string & {
};Defined in: packages/core/src/types/tools.ts:208
The row’s glyph: an icon-provider key (file, edit, terminal… — or search,
globe from @aparte/core/icons once registered). Unknown keys fall back to tool.
summary?
Section titled “summary?”optional summary?: AparteToolSummary;Defined in: packages/core/src/types/tools.ts:210
What the call targets, after the label — see AparteToolSummary.
formatInput?
Section titled “formatInput?”optional formatInput?: AparteToolInputFormatter;Defined in: packages/core/src/types/tools.ts:212
The arguments as a person reads them — see AparteToolInputFormatter.
hidden?
Section titled “hidden?”optional hidden?: boolean;Defined in: packages/core/src/types/tools.ts:217
Draw nothing for these calls. The call stays in the message, in storage and in the model’s history; an approval it needs is still asked.
optional open?: boolean;Defined in: packages/core/src/types/tools.ts:219
Open the row’s disclosure by default (a segment’s own collapsed wins).
details?
Section titled “details?”optional details?: false | AparteToolDetails;Defined in: packages/core/src/types/tools.ts:227
What is behind the line. Left out, Input and Output: the arguments and the result,
a developer’s view. false, nothing: the line alone, with no disclosure, for a chat
whose reader should not be one click from raw JSON (open and a segment’s
collapsed then have nothing to open). A function: what it returns, in place of
Input and Output — see AparteToolDetails.
quiet?
Section titled “quiet?”optional quiet?: boolean;Defined in: packages/core/src/types/tools.ts:245
The line a person reads in a conversational chat — on unless a display says false.
While the call runs, the label shimmers (aparte-shimmer) instead of a spinner and
“Running”; once it is done, nothing marks success — the label’s tense says it, so
write one that reads the status (“Searching the web…” / “Searched the web” / a plain
“Search the web” for the rest). Under reduced motion the shimmer holds still, so that
label is what says the call runs. A wait
for approval, a refusal, a failure and a stop still show their word and note. The
words it does not show are still read by a screen reader. The target is set in the
chat’s font and the chevron moves to the end of the line; the row carries
data-quiet for a stylesheet of your own.
false is an agent’s row: a spinner and “Running”, then “Done”. Like every field it
comes from the one entry that applies, so registerToolDisplay('*', { quiet: false })
reaches the tools with no entry of their own; a tool that has one says quiet: false
there too.
AparteToolRenderer
Section titled “AparteToolRenderer”Defined in: packages/core/src/types/tools.ts:275
Per-tool segment renderer. Registered via aparteGlobalConfig.registerToolRenderer(toolName, renderer). When the AI calls a tool, this renderer controls what appears in the bubble for that specific tool instead of the generic tool_call renderer.
Return an empty string from render() to render nothing (e.g. for UI-only tools like ask_user).
Properties
Section titled “Properties”render
Section titled “render”render: (segment) => string | HTMLElement;Defined in: packages/core/src/types/tools.ts:305
Render the tool-call segment, as an HTML string or a ready DOM element.
The segment carries model-chosen data. segment.toolCall.input is
whatever the model decided to pass, and segment.result is whatever the tool
returned — on the SEGMENT, because AparteToolCall is { id, name, input }
and nothing else (there is no segment.toolCall.result).
Both values are untrusted.
Return an HTMLElement and there is no innerHTML surface at all — set
textContent, attach listeners, insert framework nodes. That is the safe
default and the reason this arm exists.
Return a string and core inserts it with innerHTML, so every
interpolated value must go through escapeHtml (text position) or
escapeAttr (inside an attribute). The natural first thing to write here is
`<div>Searching for ${s.toolCall.input.query}</div>`, and that is a direct
model-to-DOM XSS in the host page’s origin.
Return an empty string to render nothing (e.g. a UI-only tool like
ask_user).
The root you return is the segment’s element in the bubble: core stamps
data-segment-id="<segment.id>" on it if you did not, so an update to the
call (its result landing, an approval decision) is patched into that element
rather than rebuilding every segment of the bubble — a rebuild destroys a
mounted artifact preview, collapses an opened reasoning block and drops the
focus. Keep your markup’s root a single element for that reason.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
segment | AparteToolCallSegment |
Returns
Section titled “Returns”string | HTMLElement
setup?
Section titled “setup?”optional setup?: (element, segment) => void;Defined in: packages/core/src/types/tools.ts:307
Optional DOM setup (event listeners etc.) called after HTML is injected
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
element | HTMLElement |
segment | AparteToolCallSegment |
Returns
Section titled “Returns”void
update?
Section titled “update?”optional update?: (element, segment) => void;Defined in: packages/core/src/types/tools.ts:316
Patch the element in place when the call changes — its result landing, an
approval decided, a failed status. Without it core rebuilds your markup from
render() on every change, which is right for a receipt and wrong for anything
with state: a mounted preview, an opened disclosure, a focused control are all
lost in a rebuild. Same contract as AparteSegmentRenderer.update: never
re-render, never touch what the reader opened.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
element | HTMLElement |
segment | AparteToolCallSegment |
Returns
Section titled “Returns”void
relabel?
Section titled “relabel?”optional relabel?: (element, segment) => void;Defined in: packages/core/src/types/tools.ts:323
Re-read the locale and the icon provider without touching the DOM shape —
called on every config change (setLocale, setIconProvider, reset()), for
as long as the element is on the page. Add or remove no child node; replace
text and glyphs only.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
element | HTMLElement |
segment | AparteToolCallSegment |
Returns
Section titled “Returns”void
cleanup?
Section titled “cleanup?”optional cleanup?: (element, segment) => void;Defined in: packages/core/src/types/tools.ts:340
The element render() returned is gone for good: unmount what you mounted in it.
Called once per element, with the element and the call’s latest segment, when it
leaves the page for good — replaced by a new render(), its segment removed, its
message redrawn, its message removed, or its renderer replaced (a renderer
registered or unregistered for this tool redraws the calls already on screen). Never
for update() or relabel(), and never for a message a framework only MOVED: a
bubble taken out and put back before the next microtask keeps its elements. Always called
on the renderer that drew the element, even when another one has been registered
since.
A framework component mounted in setup() is unmounted here; without it, it keeps
running (and keeps its subscriptions) after its card is gone. The same hook, under
the same name, as AparteSegmentRenderer.cleanup.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
element | HTMLElement |
segment | AparteToolCallSegment |
Returns
Section titled “Returns”void
getStyles?
Section titled “getStyles?”optional getStyles?: () => string;Defined in: packages/core/src/types/tools.ts:342
Optional CSS to inject once into document.head
Returns
Section titled “Returns”string
AparteToolCallView
Section titled “AparteToolCallView”Defined in: packages/core/src/types/tools.ts:350
One tool call as a component of yours draws it: the fields a card reads, in one object,
the same in every framework. input is what the model passed and result what the tool
answered — both model-chosen, so treat them as untrusted when you render them.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
I | unknown |
R | unknown |
Properties
Section titled “Properties”readonly id: string;Defined in: packages/core/src/types/tools.ts:352
The call’s id, as the model issued it.
readonly name: string;Defined in: packages/core/src/types/tools.ts:354
The tool’s name.
readonly input: I;Defined in: packages/core/src/types/tools.ts:356
The arguments the model passed.
status
Section titled “status”readonly status:
| "pending"
| "resolved"
| "aborted"
| "awaiting-approval"
| "rejected"
| "failed";Defined in: packages/core/src/types/tools.ts:358
Where the call stands: running, waiting for a person, done, refused, stopped or failed.
result?
Section titled “result?”readonly optional result?: string;Defined in: packages/core/src/types/tools.ts:360
The tool’s answer as text, once it has one.
structuredResult?
Section titled “structuredResult?”readonly optional structuredResult?: R;Defined in: packages/core/src/types/tools.ts:362
The tool’s answer as data, when it returned some.
deferred?
Section titled “deferred?”readonly optional deferred?: {
reason: "approval" | "external" | "queued";
ticket?: string;
};Defined in: packages/core/src/types/tools.ts:364
Why the call was left to someone else (an approval, an external runner, a queue).
reason
Section titled “reason”reason: "approval" | "external" | "queued";ticket?
Section titled “ticket?”optional ticket?: string;refusal?
Section titled “refusal?”readonly optional refusal?: {
by: StreamRefusalOrigin;
instruction?: string;
};Defined in: packages/core/src/types/tools.ts:366
Who refused the call, and what they said.
by: StreamRefusalOrigin;instruction?
Section titled “instruction?”optional instruction?: string;abortCause?
Section titled “abortCause?”readonly optional abortCause?: StreamAbortCause | "turn-limit";Defined in: packages/core/src/types/tools.ts:368
Why the call was stopped.
segment
Section titled “segment”readonly segment: AparteToolCallSegment;Defined in: packages/core/src/types/tools.ts:370
The segment itself, for anything the fields above do not carry.
AparteMountedView
Section titled “AparteMountedView”Defined in: packages/core/src/types/tools.ts:377
Something mounted in an element core created — a framework component, usually — and the two things core does with it: hand it a newer state, and take it down.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
V |
Methods
Section titled “Methods”update()
Section titled “update()”update(view): void;Defined in: packages/core/src/types/tools.ts:379
A newer state of what it draws: re-render in place, keep local state.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
view | V |
Returns
Section titled “Returns”void
destroy()
Section titled “destroy()”destroy(): void;Defined in: packages/core/src/types/tools.ts:381
Its element is leaving for good: unmount.
Returns
Section titled “Returns”void
Type Aliases
Section titled “Type Aliases”AparteContentPart
Section titled “AparteContentPart”type AparteContentPart =
| AparteTextPart
| AparteImagePart;Defined in: packages/core/src/types/chat.ts:37
Discriminated union of all content part types.
Only text and image parts exist: the client inlines images and text files and drops other attachments (PDF, audio) with a warning at the point the file is dropped.
AparteFinishReason
Section titled “AparteFinishReason”type AparteFinishReason = "stop" | "length" | "content-filter" | "tool-calls" | "error" | "other";Defined in: packages/core/src/types/chat.ts:196
Why the model stopped writing, as the provider reported it. The values are the AI SDK’s:
'length' is the one core acts on — the reply hit the output limit or the context window
and is cut off, which a finished reply must not look like. A provider maps its own
vocabulary (finish_reason: "tool_calls", stop_reason: "max_tokens"…) onto these, and
anything it cannot place is 'other'.
AparteStreamEvent
Section titled “AparteStreamEvent”type AparteStreamEvent = { [K in keyof AparteStreamEventMap]: { type: K } & AparteStreamEventMap[K] }[keyof AparteStreamEventMap];Defined in: packages/core/src/types/chat.ts:229
Discriminated union derived from AparteStreamEventMap — stays in sync automatically.
AparteChatResponse
Section titled “AparteChatResponse”type AparteChatResponse = ReadableStream<AparteStreamEvent> | string;Defined in: packages/core/src/types/chat.ts:233
AparteCompactorReason
Section titled “AparteCompactorReason”type AparteCompactorReason = "manual" | "retry" | "overflow" | "auto";Defined in: packages/core/src/types/compactor.ts:11
Why a compactor was asked.
manual is a person’s click (the gauge’s Compact now, a separator’s Retry), auto the
policy’s own decision after a turn or before a send, retry an attempt made again after
a failure, overflow the model refusing a request as over its window — the one that
has to run, whatever the back-off says.
AparteCompactorOutcome
Section titled “AparteCompactorOutcome”type AparteCompactorOutcome =
| {
ok: true;
skipped: true;
reason: NonNullable<AparteCompactDoneEventDetail["reason"]>;
targetId?: string;
}
| {
ok: true;
skipped: false;
summary: string;
kept: number;
dropped: number;
messageId?: string;
count?: number;
targetId?: string;
}
| {
ok: false;
error: string;
targetId?: string;
messageId?: string;
};Defined in: packages/core/src/types/compactor.ts:41
How a compaction ended. It never rejects: a refusal and a failure are outcomes, so the
caller reads ok and does not need a try. The same information goes out as
aparte-compact-done / aparte-compact-error.
Union Members
Section titled “Union Members”Type Literal
Section titled “Type Literal”{
ok: true;
skipped: true;
reason: NonNullable<AparteCompactDoneEventDetail["reason"]>;
targetId?: string;
}ok: true;skipped
Section titled “skipped”skipped: true;reason
Section titled “reason”reason: NonNullable<AparteCompactDoneEventDetail["reason"]>;Why nothing was done — the same list aparte-compact-done carries.
targetId?
Section titled “targetId?”optional targetId?: string;Type Literal
Section titled “Type Literal”{
ok: true;
skipped: false;
summary: string;
kept: number;
dropped: number;
messageId?: string;
count?: number;
targetId?: string;
}ok: true;skipped
Section titled “skipped”skipped: false;summary
Section titled “summary”summary: string;kept: number;Messages kept verbatim after the summary.
dropped
Section titled “dropped”dropped: number;Messages this compaction summarised.
messageId?
Section titled “messageId?”optional messageId?: string;The message that now carries the checkpoint.
count?
Section titled “count?”optional count?: number;Messages of the path the checkpoint stands for, an earlier summary’s included.
targetId?
Section titled “targetId?”optional targetId?: string;Type Literal
Section titled “Type Literal”{
ok: false;
error: string;
targetId?: string;
messageId?: string;
}AparteAttrValue
Section titled “AparteAttrValue”type AparteAttrValue<T> = T extends boolean ? "" | null | undefined : T extends number ? number | string : T;Defined in: packages/core/src/types/element-attributes.ts:38
One attribute as a TEMPLATE must write it.
A presence attribute becomes '' | undefined, never boolean, and that is not
pedantry — it is the same trap in all three template languages. React and Vue
stringify what they set on a custom element, so disabled={false} renders
disabled="false", and an element that tests hasAttribute reads that as ON. The
right spelling is streaming={… ? '' : undefined}; this type makes it the only one
that type-checks.
Svelte 5 shapes the SETTERS: it assigns the PROPERTY
whenever the element has a setter for it (set_custom_element_data checks
get_setters(node)), so an accessor-backed presence attribute receives the ''
this union promises as a property value. Every presence setter therefore treats
'' as ON (presenceOn in utils/presence.ts) — one spelling, both paths.
null is in the union alongside undefined because all three treat it as REMOVE,
and Vue templates write exactly that (:streaming="… ? '' : null").
A numeric attribute takes a number or the string it becomes, because both read naturally in a template.
Angular does NOT use this: its directives take boolean through booleanAttribute
and write the attribute themselves, so a consumer there writes [disabled]="busy".
That difference is the whole reason this is a mapping and not the declared type.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T |
AparteTemplateAttrs
Section titled “AparteTemplateAttrs”type AparteTemplateAttrs<T> = { [K in keyof T]?: AparteAttrValue<NonNullable<T[K]>> };Defined in: packages/core/src/types/element-attributes.ts:43
An element’s attribute surface, in template spelling. Used by three of four wrappers.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T |
ModelStatus
Section titled “ModelStatus”type ModelStatus = "ready" | "cached" | "not-downloaded";Defined in: packages/core/src/types/model-provider.ts:67
Availability status of a model, as reported by the provider.
Provider-agnostic: Transformers.js checks the Cache API, Ollama checks pulled models, LM Studio checks VRAM, etc.
AparteAIProvider
Section titled “AparteAIProvider”type AparteAIProvider =
| AparteAIProviderCore & AparteAIProviderFormat & AparteAIProviderAuth & Partial<AparteAIProviderChat>
| AparteAIProviderCore & AparteAIProviderChat & Partial<AparteAIProviderFormat> & AparteAIProviderAuthMembers;Defined in: packages/core/src/types/model-provider.ts:320
An AI provider (e.g. OpenRouter, OpenAI, Transformers.js).
A union, not one interface, because there are two mutually sufficient ways
to be a provider and the compiler should say which one you implemented. A single
interface with optional members, discriminated only at RUNTIME by isFormatAdapter(),
would let { id, getMetadata, getModels } typecheck, register, and then fail on the
first message with nothing at build time to warn you.
Every member of both surfaces stays reachable on the union (optional on the arm
that does not require it), so runtime probes like typeof p.buildRequest === 'function' and isFormatAdapter() narrowing keep working. A provider
implementing both surfaces is valid and satisfies the format arm.
Examples
Section titled “Examples”A format adapter — a transport does the call
const provider: AparteAIProvider = {
id: 'openrouter',
getMetadata: () => ({ name: 'OpenRouter', id: 'openrouter', icon: '<svg/>', color: '#000' }),
getModels: () => [],
defaultEndpoint: 'https://openrouter.ai/api/v1',
buildRequest: (req) => ({ path: '/chat/completions', body: req }),
authHeaders: (key) => ({ Authorization: `Bearer ${key}` }),
parseStream: (body) => body as unknown as ReadableStream<AparteStreamEvent>,
};A provider owning its own I/O
const local: AparteAIProvider = {
id: 'transformers',
getMetadata: () => ({ name: 'Transformers.js', id: 'transformers', icon: '<svg/>', color: '#000' }),
getModels: () => [],
chat: async (request) => runLocally(request),
};AparteStatus
Section titled “AparteStatus”type AparteStatus = "idle" | "pending" | "streaming" | "completed" | "error" | "success";Defined in: packages/core/src/types/models.ts:17
Generic status type for flow management Used to drive loading indicators, error states, and transitions without coupling to any specific data source
AparteBubbleRole
Section titled “AparteBubbleRole”type AparteBubbleRole = "user" | "assistant";Defined in: packages/core/src/types/models.ts:24
Role of a message sender in the conversation
AparteBubbleActionName
Section titled “AparteBubbleActionName”type AparteBubbleActionName = "copy" | "edit" | "retry" | "thumbUp" | "thumbDown" | "info";Defined in: packages/core/src/types/models.ts:77
Names of the individual action-bar buttons, used for explicit per-role
ordered configuration (see AparteBubbleActionsConfig.user / .assistant).
AparteSegmentDefaults
Section titled “AparteSegmentDefaults”type AparteSegmentDefaults = Readonly<Record<string, unknown>>;Defined in: packages/core/src/types/segments.ts:172
Field defaults for one segment TYPE, merged when a segment enters a message.
A record and not a Partial<AparteSegment> on purpose: the type key is a string,
a consumer’s own segment type is as valid as a built-in one, and its fields cannot
be known here. What CANNOT be defaulted is identity — id, type, messageId,
index, startedAt, endedAt are refused, because a default id would give
every segment in a conversation the same one.
AparteSegment
Section titled “AparteSegment”type AparteSegment =
| AparteTextSegment
| AparteThinkingSegment
| AparteCodeSegment
| AparteErrorSegment
| AparteCustomSegment
| AparteToolCallSegment
| AparteSegmentTypes[keyof AparteSegmentTypes];Defined in: packages/core/src/types/segments.ts:379
All built-in segment types. An artifact is not one of them any more: it is a
convention an app teaches its model, and @aparte/plugin-artifacts registers its
segment — a type of its own, through registerSegmentRenderer and
registerStreamBlock — the way any consumer registers a chart or a citation.
AparteSegmentType
Section titled “AparteSegmentType”type AparteSegmentType = AparteSegment["type"];Defined in: packages/core/src/types/segments.ts:405
Segment type discriminator values
AparteSegmentMount
Section titled “AparteSegmentMount”type AparteSegmentMount<T> = (host, segment) => AparteMountedView;Defined in: packages/core/src/types/segments.ts:504
Mount your component for one segment in host, and say how to update and destroy it.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
T extends AparteSegmentBase | AparteSegmentBase |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
host | HTMLElement |
segment | T |
Returns
Section titled “Returns”AparteThemeVariables
Section titled “AparteThemeVariables”type AparteThemeVariables = { [K in `--aparte-${string}`]?: string };Defined in: packages/core/src/types/theming.ts:34
Any aparté CSS custom property, for typing a theme object or a style record:
const brand: AparteThemeVariables = {
'--aparte-primary': '#b45309',
'--aparte-surface-1': '#ffffff',
};This was a hand-written list of 33 named properties, and it could not work. Ten of the 33 named variables were neither declared nor read anywhere in aparté — so the type autocompleted ten knobs that did nothing — while the real surface is 254 tokens, meaning even the 23 live members were an arbitrary slice presented as the whole. A hand-maintained mirror of a stylesheet that size is wrong the day after it is written, and nothing could tell you.
What this trades away, stated rather than glossed: autocomplete, and catching a
typo in the part after --aparte-. What it buys is that the type cannot lie. The
discoverable list is the generated
CSS variables reference, which
is swept from the source on every build and marks which tokens aparté actually
reads.
AparteApprovalPolicy
Section titled “AparteApprovalPolicy”type AparteApprovalPolicy = (call, tool) => AparteApprovalRuling | undefined;Defined in: packages/core/src/types/tools.ts:92
Decides, per CALL, whether a tool runs, asks, or is refused.
A tool’s own needsApproval is a declaration about the tool; a policy is a decision
about the call — the same run_command can be a read (ls) or an execution, and a
mode (“plan”: read-only, “auto”: never ask) is a policy the host switches, not a
flag on twenty definitions. Registered with setApprovalPolicy(); the client’s
default approval channel consults it before asking. Return undefined to have no
opinion, in which case the tool’s needsApproval decides as before.
Pure and synchronous: it is evaluated once to decide whether the call pauses at all (so an allowed call never flashes “awaiting approval”) and once to answer.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
call | AparteToolCall |
tool | AparteTool | undefined |
Returns
Section titled “Returns”AparteApprovalRuling | undefined
AparteToolHandler
Section titled “AparteToolHandler”type AparteToolHandler = (call, signal, context?) => Promise<AparteToolResult>;Defined in: packages/core/src/types/tools.ts:116
Handler function for a registered tool. Receives the tool call and an AbortSignal (fires after timeout or on cancellation). Must resolve with a AparteToolResult.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
call | AparteToolCall |
signal | AbortSignal |
context? | AparteToolContext |
Returns
Section titled “Returns”Promise<AparteToolResult>
AparteToolSummary
Section titled “AparteToolSummary”type AparteToolSummary = (segment) => string;Defined in: packages/core/src/types/tools.ts:169
What a call targets, in one line: the text the DEFAULT tool row shows after the
tool’s name — read_file skills.json rather than read_file alone.
Registered via aparteGlobalConfig.registerToolSummary(toolName, summary).
The name says which tool ran; this says to what, without opening the disclosure.
The row, its states and its disclosure stay core’s, so a host that only wants that
one line does not re-implement them in an AparteToolRenderer.
Return plain text: it is written as text, never parsed as HTML. Return '' to show
nothing. segment.toolCall.input is whatever the model chose, so read it
defensively — a summary that throws shows nothing rather than breaking the row.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
segment | AparteToolCallSegment |
Returns
Section titled “Returns”string
AparteToolInputFormatter
Section titled “AparteToolInputFormatter”type AparteToolInputFormatter = (input) => string;Defined in: packages/core/src/types/tools.ts:181
A tool’s arguments as a person reads them: the text the approval panel shows under its question and the default tool row shows behind its disclosure — one formatter for both, so the two cannot disagree. Registered via aparteGlobalConfig.registerToolInputFormatter(toolName, formatter).
Without one, both show the arguments as the model sent them, pretty-printed JSON. Return
plain text: it is written as text, never parsed as HTML; '' shows no arguments at all.
input is whatever the model chose, so read it defensively — a formatter that throws
falls back to the JSON.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
input | Record<string, unknown> |
Returns
Section titled “Returns”string
AparteToolMatcher
Section titled “AparteToolMatcher”type AparteToolMatcher = string | RegExp;Defined in: packages/core/src/types/tools.ts:188
Which tools a registration names: one exact name, a RegExp tested against the name
(name.search(re) !== -1, so a g flag is harmless), or '*' for every tool nothing
more specific describes.
AparteToolDetails
Section titled “AparteToolDetails”type AparteToolDetails = (segment) => HTMLElement | string;Defined in: packages/core/src/types/tools.ts:265
What a row shows behind its line, in place of Input and Output: a list of sources for a search, a sentence for a write. Called when the row is drawn and on every update of the call, so it can read the status and the result as they land — and on a language switch, whose words are written into the nodes already there when the shape is the same.
Return an HTMLElement and nothing goes through innerHTML. Return a string and
core inserts it as HTML after the config’s HTML sanitizer (setHtmlSanitizer, as for
Markdown): what it shows comes from a tool’s result, so a script or an event handler in
it is removed. Escape the call’s values all the same (escapeHtml): the sanitizer keeps
markup that is harmless but can still mislead. Return '' for nothing behind the
line yet: no disclosure, which appears once there is something (a result, say).
A function that throws costs the row its detail, never its line, and never falls back
to the raw Input and Output. Register the same function rather than a new closure each
time: a different details redraws the messages on screen.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
segment | AparteToolCallSegment |
Returns
Section titled “Returns”HTMLElement | string
AparteToolMount
Section titled “AparteToolMount”type AparteToolMount = (host, view) => AparteMountedView<AparteToolCallView>;Defined in: packages/core/src/types/tools.ts:385
Mount your component for one tool call in host, and say how to update and destroy it.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
host | HTMLElement |
view | AparteToolCallView |
Returns
Section titled “Returns”AparteMountedView<AparteToolCallView>
Enumerations
Section titled “Enumerations”AparteErrorCode
Section titled “AparteErrorCode”Defined in: packages/core/src/types/errors.ts:2
Enumeration Members
Section titled “Enumeration Members”CONFIG_NO_PROVIDER
Section titled “CONFIG_NO_PROVIDER”CONFIG_NO_PROVIDER: "CONFIG_NO_PROVIDER";Defined in: packages/core/src/types/errors.ts:4
CONFIG_MISSING_KEY
Section titled “CONFIG_MISSING_KEY”CONFIG_MISSING_KEY: "CONFIG_MISSING_KEY";Defined in: packages/core/src/types/errors.ts:5
CONFIG_INVALID_KEY
Section titled “CONFIG_INVALID_KEY”CONFIG_INVALID_KEY: "CONFIG_INVALID_KEY";Defined in: packages/core/src/types/errors.ts:6
CONFIG_INVALID_MODEL
Section titled “CONFIG_INVALID_MODEL”CONFIG_INVALID_MODEL: "CONFIG_INVALID_MODEL";Defined in: packages/core/src/types/errors.ts:7
USAGE_RATE_LIMIT
Section titled “USAGE_RATE_LIMIT”USAGE_RATE_LIMIT: "USAGE_RATE_LIMIT";Defined in: packages/core/src/types/errors.ts:10
USAGE_CONTEXT_EXCEEDED
Section titled “USAGE_CONTEXT_EXCEEDED”USAGE_CONTEXT_EXCEEDED: "USAGE_CONTEXT_EXCEEDED";Defined in: packages/core/src/types/errors.ts:11
USAGE_BAD_REQUEST
Section titled “USAGE_BAD_REQUEST”USAGE_BAD_REQUEST: "USAGE_BAD_REQUEST";Defined in: packages/core/src/types/errors.ts:12
NET_OFFLINE
Section titled “NET_OFFLINE”NET_OFFLINE: "NET_OFFLINE";Defined in: packages/core/src/types/errors.ts:15
NET_TIMEOUT
Section titled “NET_TIMEOUT”NET_TIMEOUT: "NET_TIMEOUT";Defined in: packages/core/src/types/errors.ts:16
NET_ERROR
Section titled “NET_ERROR”NET_ERROR: "NET_ERROR";Defined in: packages/core/src/types/errors.ts:17
PROVIDER_ERROR
Section titled “PROVIDER_ERROR”PROVIDER_ERROR: "PROVIDER_ERROR";Defined in: packages/core/src/types/errors.ts:20
PROVIDER_UNAVAILABLE
Section titled “PROVIDER_UNAVAILABLE”PROVIDER_UNAVAILABLE: "PROVIDER_UNAVAILABLE";Defined in: packages/core/src/types/errors.ts:21
PROVIDER_POLICY
Section titled “PROVIDER_POLICY”PROVIDER_POLICY: "PROVIDER_POLICY";Defined in: packages/core/src/types/errors.ts:22
PROVIDER_MISCONFIGURED
Section titled “PROVIDER_MISCONFIGURED”PROVIDER_MISCONFIGURED: "PROVIDER_MISCONFIGURED";Defined in: packages/core/src/types/errors.ts:29
The provider was reached but is set up so it cannot answer — an n8n workflow that is not published, waits for credentials, streams nothing or answers without a text field. Waiting will not mend it: the person reads a sentence that asks for no retry, the developer reads what to change.
MAX_TURNS_EXCEEDED
Section titled “MAX_TURNS_EXCEEDED”MAX_TURNS_EXCEEDED: "MAX_TURNS_EXCEEDED";Defined in: packages/core/src/types/errors.ts:33
The turn reached maxTurns: the loop stopped asking the model, to avoid an endless loop.
UNKNOWN_ERROR
Section titled “UNKNOWN_ERROR”UNKNOWN_ERROR: "UNKNOWN_ERROR";Defined in: packages/core/src/types/errors.ts:36
Event details
Section titled “Event details”AparteMessageDoneEventDetail
Section titled “AparteMessageDoneEventDetail”Defined in: packages/core/src/types/events.ts:78
Detail payload for aparte-message-done.
Dispatched when a turn finishes normally. Carries token usage when the provider
reports it.
aparte-message-done
Properties
Section titled “Properties”targetId?
Section titled “targetId?”optional targetId?: string;Defined in: packages/core/src/types/events.ts:86
Id of the <aparte-chat> host that produced this turn, when it has one.
Stamped by the client’s lifecycle dispatcher on EVERY lifecycle event so several chats on one page stay isolated — a composer reacts only to its own host’s turn.
messageId
Section titled “messageId”messageId: string;Defined in: packages/core/src/types/events.ts:87
role: string;Defined in: packages/core/src/types/events.ts:88
usage?
Section titled “usage?”optional usage?: AparteUsage;Defined in: packages/core/src/types/events.ts:90
Token usage for the completed response, if reported by the provider.
finishReason?
Section titled “finishReason?”optional finishReason?: AparteFinishReason;Defined in: packages/core/src/types/events.ts:92
Why the model stopped writing, if the provider said — 'length' means the reply is cut off.
AparteModelChangeEventDetail
Section titled “AparteModelChangeEventDetail”Defined in: packages/core/src/types/events.ts:106
Detail payload for aparte-model-change.
Dispatched by @aparte/plugin-model-selector when the user picks a different
provider or model — the clearest cross-package contract in the set.
aparte-model-change
Properties
Section titled “Properties”providerId?
Section titled “providerId?”optional providerId?: string;Defined in: packages/core/src/types/events.ts:108
Selected provider ID (e.g., ‘openrouter’, ‘gemini’)
modelId
Section titled “modelId”modelId: string;Defined in: packages/core/src/types/events.ts:111
Selected model ID (e.g., ‘gpt-4-turbo’, ‘claude-3-opus’)
previousModelId?
Section titled “previousModelId?”optional previousModelId?: string;Defined in: packages/core/src/types/events.ts:114
Previous model ID if changed
previousProviderId?
Section titled “previousProviderId?”optional previousProviderId?: string;Defined in: packages/core/src/types/events.ts:117
Previous provider ID if changed
AparteLinkClickEventDetail
Section titled “AparteLinkClickEventDetail”Defined in: packages/core/src/types/events.ts:147
Detail payload for aparte-link-click.
Dispatched by the bubble, cancelable, when a link in a message body is about to be
followed — a link the MODEL wrote. preventDefault() on the event keeps the browser
from navigating, so a host routes the link itself (an external browser, a
confirmation, an embedded view) without intercepting the DOM. With no listener the
browser follows it; the sanitizer has made an external URL open in a new tab.
aparte-link-click
Properties
Section titled “Properties”href: string;Defined in: packages/core/src/types/events.ts:149
The href as written on the anchor, after sanitization.
anchor
Section titled “anchor”anchor: HTMLAnchorElement;Defined in: packages/core/src/types/events.ts:151
The anchor itself, for a host that wants its text or its rel.
messageId
Section titled “messageId”messageId: string | null;Defined in: packages/core/src/types/events.ts:153
The message the link sits in, or null for a bubble mounted without one.
AparteBranchNavigateEventDetail
Section titled “AparteBranchNavigateEventDetail”Defined in: packages/core/src/types/events.ts:163
Detail payload for aparte-branch-navigate.
Dispatched by the bubble’s branch-picker buttons; the viewport listens
(bubbling) and calls navigateBranch(messageId, direction) on its repo.
aparte-branch-navigate
Properties
Section titled “Properties”messageId
Section titled “messageId”messageId: string;Defined in: packages/core/src/types/events.ts:165
Message id whose siblings should be navigated
direction
Section titled “direction”direction: "prev" | "next";Defined in: packages/core/src/types/events.ts:167
‘prev’ = move to previous sibling, ‘next’ = move to next sibling
ApartePathChangedEventDetail
Section titled “ApartePathChangedEventDetail”Defined in: packages/core/src/types/events.ts:178
Detail payload for aparte-path-changed.
Dispatched by the viewport in framework-managed mode after the active
path of the conversation tree changes (sibling switch, retry, edit, etc.).
Consumers (Angular wrapper) reconcile their signal/state from this payload.
aparte-path-changed
Properties
Section titled “Properties”messages
Section titled “messages”messages: AparteMessage[];Defined in: packages/core/src/types/events.ts:180
Messages on the new active path, root → head.
siblings
Section titled “siblings”siblings: AparteSiblingInfo[];Defined in: packages/core/src/types/events.ts:182
Sibling metadata, one entry per message on the path.
AparteRetryEventDetail
Section titled “AparteRetryEventDetail”Defined in: packages/core/src/types/events.ts:193
Detail payload for aparte-retry.
Dispatched by the assistant bubble’s “Retry” action. Picked up by the
AparteClient, which calls addSiblingOf on the target viewport and streams
a fresh response into the new sibling.
aparte-retry
Properties
Section titled “Properties”messageId
Section titled “messageId”messageId: string;Defined in: packages/core/src/types/events.ts:195
Message id of the assistant response being retried (its sibling will be created).
targetId?
Section titled “targetId?”optional targetId?: string;Defined in: packages/core/src/types/events.ts:197
Optional id of the host element (aparte-chat) — used by scopeToTargetId.
AparteEditEventDetail
Section titled “AparteEditEventDetail”Defined in: packages/core/src/types/events.ts:208
Detail payload for aparte-edit.
Dispatched by the user bubble after the user confirms an inline edit.
Picked up by the AparteClient, which truncates the existing responses to
this message and re-streams a new one.
aparte-edit
Properties
Section titled “Properties”messageId
Section titled “messageId”messageId: string;Defined in: packages/core/src/types/events.ts:210
Message id of the user message being edited.
content
Section titled “content”content: string;Defined in: packages/core/src/types/events.ts:212
New content submitted by the user.
targetId?
Section titled “targetId?”optional targetId?: string;Defined in: packages/core/src/types/events.ts:214
Optional id of the host element (aparte-chat) — used by scopeToTargetId.
AparteCollectCommandsEventDetail
Section titled “AparteCollectCommandsEventDetail”Defined in: packages/core/src/types/events.ts:265
Detail payload for aparte-collect-commands, sent up when a menu of
@aparte/plugin-triggers opens. A plugin that has a command listens on window, checks
config is its own, and calls add. Core only names the shape: it reads none of it, and
neither side imports the other.
aparte-collect-commands
Properties
Section titled “Properties”config
Section titled “config”config: AparteConfig;Defined in: packages/core/src/types/events.ts:266
chat: HTMLElement | null;Defined in: packages/core/src/types/events.ts:267
composer
Section titled “composer”composer: AparteComposer;Defined in: packages/core/src/types/events.ts:268
Methods
Section titled “Methods”add(command): void;Defined in: packages/core/src/types/events.ts:269
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
command | AparteCommand |
Returns
Section titled “Returns”void
AparteTriggerSelectEventDetail
Section titled “AparteTriggerSelectEventDetail”Defined in: packages/core/src/types/events.ts:278
Detail payload for aparte-trigger-select, sent when a row of
@aparte/plugin-triggers’ menu is chosen. preventDefault() leaves the draft untouched.
aparte-trigger-select
Properties
Section titled “Properties”trigger
Section titled “trigger”trigger: {
char: string;
};Defined in: packages/core/src/types/events.ts:279
char: string;item: {
id: string;
label: string;
data?: unknown;
};Defined in: packages/core/src/types/events.ts:280
id: string;label: string;optional data?: unknown;query: string;Defined in: packages/core/src/types/events.ts:281
AparteFeedbackReasonEventDetail
Section titled “AparteFeedbackReasonEventDetail”Defined in: packages/core/src/types/events.ts:290
Detail payload for aparte-feedback-reason: why a reply got a thumbs-down, picked from
setBubbleActions({ feedbackReasons }).
aparte-feedback-reason
Properties
Section titled “Properties”messageId
Section titled “messageId”messageId: string;Defined in: packages/core/src/types/events.ts:291
reason
Section titled “reason”reason: string;Defined in: packages/core/src/types/events.ts:292
AparteFeedbackEventDetail
Section titled “AparteFeedbackEventDetail”Defined in: packages/core/src/types/events.ts:301
Detail payload for aparte-feedback.
Dispatched by the assistant bubble’s thumbs-up / thumbs-down buttons.
aparte-feedback
Properties
Section titled “Properties”messageId
Section titled “messageId”messageId: string;Defined in: packages/core/src/types/events.ts:303
Message id receiving the feedback.
value: "positive" | "negative";Defined in: packages/core/src/types/events.ts:305
‘positive’ for thumbs-up, ‘negative’ for thumbs-down.
AparteActionEventDetail
Section titled “AparteActionEventDetail”Defined in: packages/core/src/types/events.ts:317
Detail payload for aparte-action.
Dispatched by a custom action button (registered via aparteGlobalConfig.registerAction)
in a message-bubble toolbar. Apps listen (bubbling) and dispatch on actionId.
Mirrors the built-in bubble events (retry/feedback) so custom actions are wired
the same way in every framework and in vanilla.
aparte-action
Properties
Section titled “Properties”actionId
Section titled “actionId”actionId: string;Defined in: packages/core/src/types/events.ts:319
The registered action’s id (from AparteAction.id).
zone: "bubble";Defined in: packages/core/src/types/events.ts:321
Which zone the action was clicked in.
messageId?
Section titled “messageId?”optional messageId?: string;Defined in: packages/core/src/types/events.ts:323
Message id of the bubble the action was clicked on.
optional role?: "user" | "assistant";Defined in: packages/core/src/types/events.ts:325
Role of that bubble.
targetId?
Section titled “targetId?”optional targetId?: string;Defined in: packages/core/src/types/events.ts:327
Optional host element id (aparte-chat) — same use as retry/edit’s targetId.
AparteMessageInfoEventDetail
Section titled “AparteMessageInfoEventDetail”Defined in: packages/core/src/types/events.ts:337
Detail payload for aparte-message-info.
Dispatched by the assistant bubble’s info (“i”) action button. Apps
listen (bubbling) and present a stats popover for the completed response.
aparte-message-info
Properties
Section titled “Properties”messageId
Section titled “messageId”messageId: string;Defined in: packages/core/src/types/events.ts:339
Message id whose stats should be shown.
usage?
Section titled “usage?”optional usage?: AparteUsage;Defined in: packages/core/src/types/events.ts:341
Token usage + timing for the message, when available.
AparteMessageStartEventDetail
Section titled “AparteMessageStartEventDetail”Defined in: packages/core/src/types/events.ts:364
Detail payload for aparte-message-start.
Dispatched when a turn begins, before the first token. The composer and the
conversation controller both use it to enter their streaming state.
aparte-message-start
Properties
Section titled “Properties”targetId?
Section titled “targetId?”optional targetId?: string;Defined in: packages/core/src/types/events.ts:366
Host element id, when the <aparte-chat> has one.
messageId
Section titled “messageId”messageId: string;Defined in: packages/core/src/types/events.ts:368
Id of the assistant message about to stream.
role: string;Defined in: packages/core/src/types/events.ts:370
Role of the message being created — 'assistant' in every current path.
AparteMessageErrorEventDetail
Section titled “AparteMessageErrorEventDetail”Defined in: packages/core/src/types/events.ts:380
Detail payload for aparte-message-error.
Dispatched when a turn fails. Four core components listen for it, and it is the
event guides/troubleshooting.md tells you to bind to surface a failure.
aparte-message-error
Properties
Section titled “Properties”targetId?
Section titled “targetId?”optional targetId?: string;Defined in: packages/core/src/types/events.ts:382
Host element id, when the <aparte-chat> has one.
messageId
Section titled “messageId”messageId: string;Defined in: packages/core/src/types/events.ts:384
Id of the message that failed.
error: AparteError;Defined in: packages/core/src/types/events.ts:386
The failure, with its code — not a string, unlike aparte-compact-error.
AparteMessagePausedEventDetail
Section titled “AparteMessagePausedEventDetail”Defined in: packages/core/src/types/events.ts:399
Detail payload for aparte-message-paused.
Dispatched when a server loop pauses the turn on calls only the page can answer — an
approval, a browser tool. The turn is not over (aparte-message-done follows the
resume), but the reply is worth saving now: its paused calls carry the server’s
ticket, and a conversation saved here can still be answered after a reload. The
conversation manager persists on it.
aparte-message-paused
Properties
Section titled “Properties”targetId?
Section titled “targetId?”optional targetId?: string;Defined in: packages/core/src/types/events.ts:401
Host element id, when the <aparte-chat> has one.
messageId
Section titled “messageId”messageId: string;Defined in: packages/core/src/types/events.ts:403
Id of the paused reply.
AparteMessageResumedEventDetail
Section titled “AparteMessageResumedEventDetail”Defined in: packages/core/src/types/events.ts:415
Detail payload for aparte-message-resumed.
Dispatched when a paused turn goes on: the page answered the paused calls (a person’s
decision, a browser tool) and the run starts again, into the same reply. The other half
of aparte-message-paused — what the turn does between the two is wait for the page;
after this one, it runs again until aparte-message-done.
aparte-message-resumed
Properties
Section titled “Properties”targetId?
Section titled “targetId?”optional targetId?: string;Defined in: packages/core/src/types/events.ts:417
Host element id, when the <aparte-chat> has one.
messageId
Section titled “messageId”messageId: string;Defined in: packages/core/src/types/events.ts:419
Id of the reply the run goes on in.
AparteMessageAbortedEventDetail
Section titled “AparteMessageAbortedEventDetail”Defined in: packages/core/src/types/events.ts:428
Detail payload for aparte-message-aborted.
Dispatched when the user stops a turn.
aparte-message-aborted
Properties
Section titled “Properties”targetId?
Section titled “targetId?”optional targetId?: string;Defined in: packages/core/src/types/events.ts:430
Host element id, when the <aparte-chat> has one.
messageId?
Section titled “messageId?”optional messageId?: string;Defined in: packages/core/src/types/events.ts:436
Id of the aborted message — OPTIONAL, and that is not laziness: the composer
dispatches this event on its own with only a targetId, because a user can
press Stop during the pre-flight window before any message id exists.
AparteAbortEventDetail
Section titled “AparteAbortEventDetail”Defined in: packages/core/src/types/events.ts:448
Detail payload for aparte-abort — a COMMAND, not a notification.
AparteClient listens for it on window; a bring-your-own-composer consumer
dispatches it to stop a stream. Nothing in core dispatches it on the consumer’s
behalf, so its shape is documented here.
aparte-abort
Properties
Section titled “Properties”targetId?
Section titled “targetId?”optional targetId?: string;Defined in: packages/core/src/types/events.ts:450
Which chat to stop. Omit on a single-chat page.
AparteCompactEventDetail
Section titled “AparteCompactEventDetail”Defined in: packages/core/src/types/events.ts:463
Detail payload for aparte-compact — a COMMAND dispatched on window to ask for
the conversation so far to be summarised.
A host dispatches it from a button, and the context gauge’s Retry does when no compactor
is registered; @aparte/plugin-compaction is what answers it. Core itself neither
listens for it nor compacts — the events below are the plugin’s.
aparte-compact
Properties
Section titled “Properties”targetId?
Section titled “targetId?”optional targetId?: string;Defined in: packages/core/src/types/events.ts:465
Which chat to compact. Omit on a single-chat page.
optional auto?: boolean;Defined in: packages/core/src/types/events.ts:471
true when the request is an automatic one, made without a person asking (an app’s
own trigger). The plugin counts such a request against its back-off (two failures stop
the automatic attempts), which a button’s request never is.
AparteCompactStartEventDetail
Section titled “AparteCompactStartEventDetail”Defined in: packages/core/src/types/events.ts:481
Detail payload for aparte-compact-start — the summarisation began. The point for a
host to show a spinner: summarising a long conversation is a model call and takes as
long as one.
aparte-compact-start
Properties
Section titled “Properties”targetId?
Section titled “targetId?”optional targetId?: string;Defined in: packages/core/src/types/events.ts:483
The chat being compacted, when it has an id.
messageId?
Section titled “messageId?”optional messageId?: string;Defined in: packages/core/src/types/events.ts:489
The message the checkpoint will sit on — the first message kept verbatim. The transcript draws its “Summarising the context…” line above that message while the summary is being written.
AparteCompactDoneEventDetail
Section titled “AparteCompactDoneEventDetail”Defined in: packages/core/src/types/events.ts:501
Detail payload for aparte-compact-done.
A union flattened to optional fields, because the two outcomes carry different
payloads and a consumer cannot guess which: nothing to compact sends
{ skipped: true, reason }, a real compaction sends { summary, kept, dropped }.
aparte-compact-done
Properties
Section titled “Properties”skipped?
Section titled “skipped?”optional skipped?: boolean;Defined in: packages/core/src/types/events.ts:503
true when there was nothing worth summarising; the other two are absent.
reason?
Section titled “reason?”optional reason?: "streaming" | "empty" | "nothing-to-drop" | "running" | "no-window";Defined in: packages/core/src/types/events.ts:510
Why it was skipped: empty (no messages), nothing-to-drop (the selector kept
everything), running (a compaction was already in flight), streaming (a turn
is in flight in the transcript), no-window (the model declares no context window
and nothing else sizes the summary request).
summary?
Section titled “summary?”optional summary?: string;Defined in: packages/core/src/types/events.ts:512
The summary that replaced the compacted turns.
optional kept?: number;Defined in: packages/core/src/types/events.ts:514
How many messages were kept verbatim after the summary.
dropped?
Section titled “dropped?”optional dropped?: number;Defined in: packages/core/src/types/events.ts:516
How many messages the summary replaced.
targetId?
Section titled “targetId?”optional targetId?: string;Defined in: packages/core/src/types/events.ts:518
The chat that was compacted, when it has an id — so a gauge on a multi-chat page resets only its own.
messageId?
Section titled “messageId?”optional messageId?: string;Defined in: packages/core/src/types/events.ts:523
The message that now carries the checkpoint (AparteMessage.contextSummary), or,
on a restore, the message whose separator Restore was pressed on.
count?
Section titled “count?”optional count?: number;Defined in: packages/core/src/types/events.ts:525
How many messages of the path the checkpoint stands for, an earlier summary’s included.
restored?
Section titled “restored?”optional restored?: boolean;Defined in: packages/core/src/types/events.ts:531
true when this is not a compaction but a Restore: every checkpoint was removed
from the transcript and the model reads the original messages again. summary,
kept and dropped are absent.
AparteCompactErrorEventDetail
Section titled “AparteCompactErrorEventDetail”Defined in: packages/core/src/types/events.ts:542
Detail payload for aparte-compact-error.
Note the asymmetry with aparte-message-error, which is deliberate rather than
hidden: error here is a plain string, not an AparteError.
aparte-compact-error
Properties
Section titled “Properties”error: string;Defined in: packages/core/src/types/events.ts:544
Human-readable failure reason.
targetId?
Section titled “targetId?”optional targetId?: string;Defined in: packages/core/src/types/events.ts:546
The chat the compaction was for, when it has an id.
messageId?
Section titled “messageId?”optional messageId?: string;Defined in: packages/core/src/types/events.ts:551
The message the failed checkpoint would have sat on, when it got that far — the transcript turns its “Summarising the context…” line into a failure with a Retry.
aborted?
Section titled “aborted?”optional aborted?: true;Defined in: packages/core/src/types/events.ts:558
The compaction was cancelled — a Stop, an abort(), a Restore — rather than failed.
Nothing went wrong and nothing is offered: the transcript and the gauge clear their
“Summarising the context…” instead of showing a failure with a Retry, which would
bring back a summary the person just turned away.
AparteAttachmentPreviewEventDetail
Section titled “AparteAttachmentPreviewEventDetail”Defined in: packages/core/src/types/events.ts:574
Detail payload for aparte-attachment-preview.
Dispatched when a user clicks an image tile, once setHostHandlers({ attachmentPreview: true }) has declared that you will open a lightbox — or, with filePreview: true, a
file tile in a sent message whose URL a tab can open. Without the declaration the tile
is not interactive at all.
aparte-attachment-preview
Properties
Section titled “Properties”url: string;Defined in: packages/core/src/types/events.ts:576
Object URL or remote URL of the image or the file.
name: string;Defined in: packages/core/src/types/events.ts:578
File name, or '' when the attachment carries none.
type: string;Defined in: packages/core/src/types/events.ts:580
The MIME type, '' when unknown: an image to show in a lightbox, another file to open in a tab.
AparteApprovalModeChangeEventDetail
Section titled “AparteApprovalModeChangeEventDetail”Defined in: packages/core/src/types/events.ts:595
Detail for aparte-approval-mode-change — dispatched by @aparte/plugin-approval’s
<aparte-approval-mode> after the person switched the approval mode. Bubbles and
crosses shadow roots, so a host can persist the choice from any ancestor.
Declared here, like aparte-model-change, because a listener in any framework reads
e.detail through the typed event map. The values are the plugin’s four modes
(plan, ask, auto-edit, auto); typed as strings so core names none of them.
aparte-approval-mode-change
Properties
Section titled “Properties”mode: string;Defined in: packages/core/src/types/events.ts:597
The mode just switched to.
previousMode
Section titled “previousMode”previousMode: string;Defined in: packages/core/src/types/events.ts:599
The mode it replaced.
AparteToolApprovalRequestDetail
Section titled “AparteToolApprovalRequestDetail”Defined in: packages/core/src/types/tools.ts:53
Detail for aparte-tool-approval-request — emitted by the loop when a tool
marked needsApproval is about to run.
Listen for it to present the decision yourself. Core’s own gate asks at the COMPOSER
(<aparte-elicitation> renders the panel there), and the transcript row shows only a
state — there is no Approve/Reject control in a bubble.
With no presenter and no approvalResolver, every needsApproval call aborts with
nothing clickable on screen.
aparte-tool-approval-request
Properties
Section titled “Properties”toolCallId
Section titled “toolCallId”toolCallId: string;Defined in: packages/core/src/types/tools.ts:54
toolName
Section titled “toolName”toolName: string;Defined in: packages/core/src/types/tools.ts:55
input: Record<string, unknown>;Defined in: packages/core/src/types/tools.ts:56