Skip to content

Defined in: packages/core/src/client/aparte-client.ts:307

AparteClient

The “Automatic Transmission” for Aparte. Connects the UI events (aparte-send) to the AI Providers (chat). Handles:

  • Listening to send events
  • Resolving API keys
  • Calling the appropriate Provider
  • Streaming the response back to the UI
  • Tool use: awaiting handlers and re-calling the provider
typescript
const client = new AparteClient({
  keyResolver: (providerId) => process.env[providerId.toUpperCase() + '_KEY']
});
client.start();
ts
new AparteClient(options?): AparteClient;

Defined in: packages/core/src/client/aparte-client.ts:385

A keyResolver becomes a key source on the client’s config at once, before start(), so everything that needs a key can use it — the model selector’s list included. autoRegister (on by default) installs core’s built-in renderers on that config.

ParameterType
optionsAparteClientOptions

AparteClient

ts
start(): void;

Defined in: packages/core/src/client/aparte-client.ts:480

Answer the chats: listen on window for aparte-send, aparte-retry, aparte-edit, aparte-abort and aparte-conversation-loaded. Nothing streams before this is called. Starting a stopped client puts its keyResolver back on the config.

void

ts
stop(): void;

Defined in: packages/core/src/client/aparte-client.ts:531

Stop answering: abort the reply in flight, take this client’s keyResolver off the config, and remove the listeners.

void

ts
abort(): void;

Defined in: packages/core/src/client/aparte-client.ts:573

Abort the current streaming response and all active tool calls. Dispatches aparte-message-aborted on the target element.

void

ts
resumeDeferred(target?): Promise<boolean>;

Defined in: packages/core/src/client/aparte-client.ts:1983

Answer a turn a server loop paused, when the conversation comes back — a reload, a conversation reopened days later. The last reply’s paused calls (they carry the server’s ticket) are put to the person again, or run in the page, and the loop resumes on the server, into the same bubble.

Called on its own when a conversation manager loads a conversation (aparte-conversation-loaded); call it yourself after setMessages if you load conversations another way. Resolves true when a resume ran, false when there was nothing to resume.

ParameterTypeDescription
target?string | HTMLElementThe chat — an element, or its id. Defaults to the one targetResolver names, else the first on the page.

Promise<boolean>


Defined in: packages/core/src/host/aparte-chat-host.ts:166

ts
new AparteChatHost(binding, options?): AparteChatHost;

Defined in: packages/core/src/host/aparte-chat-host.ts:203

ParameterType
bindingAparteChatHostBinding
optionsAparteChatHostOptions

AparteChatHost

ts
get streamingId(): string | null;

Defined in: packages/core/src/host/aparte-chat-host.ts:257

string | null

ts
get isStreaming(): boolean;

Defined in: packages/core/src/host/aparte-chat-host.ts:258

boolean

ts
get conversationController(): 
  | AparteConversationController
  | undefined;

Defined in: packages/core/src/host/aparte-chat-host.ts:261

The internally-managed conversation controller (created in bind).

| AparteConversationController | undefined

ts
bind(): () => void;

Defined in: packages/core/src/host/aparte-chat-host.ts:216

Install the host-method surface + event listeners and create the conversation controller. Returns a teardown function; call once after the view (viewport + composer) has mounted.

() => void

ts
unbind(): void;

Defined in: packages/core/src/host/aparte-chat-host.ts:242

void

ts
clearRenderCache(): void;

Defined in: packages/core/src/host/aparte-chat-host.ts:266

Clear the bubble-render cache (e.g. when the host clears messages externally).

void

ts
setConversationId(id): Promise<void>;

Defined in: packages/core/src/host/aparte-chat-host.ts:285

Load / switch the active conversation via the controller.

ParameterType
idstring | null

Promise<void>

ts
appendMessage(message, options?): void;

Defined in: packages/core/src/host/aparte-chat-host.ts:382

Append a message optimistically (streaming writes target the new last).

Deliberately does NOT call onMessagesChange (unlike the other mutations): setMessages updates the wrapper’s OWN render list, but onMessagesChange is the OUTBOUND “the user changed the list” notification. During an optimistic append the wrapper’s local list can lag a controlled parent’s (the parent added a user message that hasn’t propagated back yet), so echoing the local list to the parent would overwrite the parent’s authoritative list and drop that message — a real race the Angular wrapper spec guards (“optimistic-append + parent-push race”). onMessageAppended is the append-specific signal instead.

ParameterType
messageAparteMessage
options?{ historical?: boolean; }
options.historical?boolean

void

ts
updateMessage(messageId, updates): void;

Defined in: packages/core/src/host/aparte-chat-host.ts:415

Atomic partial update of a message by id.

ParameterType
messageIdstring
updatesPartial<AparteMessage>

void

ts
updateLastMessage(content, options?): void;

Defined in: packages/core/src/host/aparte-chat-host.ts:441

Append/replace the last message content (streaming text).

ParameterType
contentstring
options?{ append?: boolean; }
options.append?boolean

void

ts
addSegment(segment): void;

Defined in: packages/core/src/host/aparte-chat-host.ts:454

Add a segment to the last message (immediate bubble + state sync).

ParameterType
segmentAparteSegment

void

ts
updateSegment(segmentId, updates): void;

Defined in: packages/core/src/host/aparte-chat-host.ts:485

Update a segment in the last message in place.

ParameterType
segmentIdstring
updatesPartial<AparteSegment>

void

ts
removeSegment(segmentId): void;

Defined in: packages/core/src/host/aparte-chat-host.ts:505

Remove a transient segment (a status row the host added itself).

ParameterType
segmentIdstring

void

ts
appendToSegment(segmentId, content): void;

Defined in: packages/core/src/host/aparte-chat-host.ts:538

Append text to a segment’s content in the last message — the streaming path for thinking blocks, tool pills and any segment that grows token by token.

Two writes, deliberately asymmetric:

  1. straight into the bubble, every chunk, so the text appears immediately — the same direct path appendToken uses;
  2. into the framework’s message list, coalesced to once per frame.

It used to do only (2), synchronously: a full list rebuild plus setMessages + onMessagesChange for every chunk, i.e. one complete framework render per token. At 60 tok/s from a local model that is unusable, and nothing in the imperative API hinted that appendToSegment cost so much more than injectTokenStream. Consumers had to write their own rAF batcher.

Any structural change flushes the buffer first (see _flushStreamState), so ordering is never observable.

ParameterType
segmentIdstring
contentstring

void

ts
getMessages(): AparteMessage[];

Defined in: packages/core/src/host/aparte-chat-host.ts:642

Read the current message list.

AparteMessage[]

ts
clearMessages(options?): void;

Defined in: packages/core/src/host/aparte-chat-host.ts:651

Clear all messages + reset viewport state. The option travels to the viewport untouched: a compaction passes { revokeAttachments: false } because it re-appends the turns it keeps and revokes the dropped ones’ object URLs itself — under a framework wrapper this bridge used to drop the argument, and every surviving attachment came back broken.

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

void

ts
addBranch(messageId): number;

Defined in: packages/core/src/host/aparte-chat-host.ts:658

Create a new branch from a message (returns the new sibling index).

ParameterType
messageIdstring

number

ts
addSiblingOf(existingId, newMessage): string | null;

Defined in: packages/core/src/host/aparte-chat-host.ts:664

Add a sibling of an existing message (returns the new id).

ParameterType
existingIdstring
newMessageAparteMessage

string | null

ts
truncateFrom(messageId): void;

Defined in: packages/core/src/host/aparte-chat-host.ts:670

Remove a message and all descendants (edit flow).

ParameterType
messageIdstring

void

ts
truncateResponsesAfter(userMessageId): void;

Defined in: packages/core/src/host/aparte-chat-host.ts:680

Keep up to and including a user message, drop later responses (retry).

ParameterType
userMessageIdstring

void

ts
streamTokens(messageId, tokens): Promise<void>;

Defined in: packages/core/src/host/aparte-chat-host.ts:704

Drive a manual token stream into the viewport. Sets the streaming guard, appends each token, completes the message at the end. Per-framework wrappers adapt their native stream type (RxJS Observable, AsyncIterable, ReadableStream) into this.

Each token reaches the bubble immediately and the framework’s message list is synced once per frame (same discipline as appendToSegment), with a guaranteed flush before completion and on abort. Before that sync existed the two disagreed: the DOM had the reply, the framework list still held content: '' — so any re-render from state wiped it, and a custom bubble (which renders from that state) showed nothing at all.

ParameterType
messageIdstring
tokensAsyncIterable<string>

Promise<void>

ts
stopTokenStream(): void;

Defined in: packages/core/src/host/aparte-chat-host.ts:790

Abort an in-flight streamTokens loop.

void

ts
syncBubbles(): void;

Defined in: packages/core/src/host/aparte-chat-host.ts:808

Reconcile rendered bubbles with the current message list. The framework calls this from its reactive message-change hook after rendering; the last message is always re-synced (streaming), others only once.

void

ts
syncRepoFromMessages(): void;

Defined in: packages/core/src/host/aparte-chat-host.ts:824

Rebuild the viewport’s internal repo from the message list before branch operations (streaming fills the framework state but not the repo).

void


ts
function createAgentStreamRunner(options): AparteStreamRunner;

Defined in: packages/core/src/client/agent-runner.ts:37

An AparteStreamRunner that runs AparteClient’s loop on YOUR server — the one createAparteAgentHandler serves — and replays its events here, where the client’s adapter draws them exactly as it draws a loop run in the page.

ts
const client = new AparteClient({ streamRunner: createAgentStreamRunner({ endpoint: '/api/agent' }) });

The page needs no provider of its own: the server runs the model. A provider and model the page selects anyway travel with the turn, and the server uses them.

A pipe, nothing more. It sees no message and no segment, so it opens no panel and runs no tool: when the server suspends a run, the CLIENT asks the person or runs the browser tool, then calls this runner again with the answers in deferral — the same path it takes when a conversation with a paused call is reloaded days later.

ParameterType
optionsAgentStreamRunnerOptions

AparteStreamRunner


ts
function createStreamAdapter(opts): StreamRunEmitter;

Defined in: packages/core/src/client/stream-adapter.ts:104

Build the event → DOM adapter for one streamed message. Returns a synchronous AparteStreamRunEmitter to hand to runStreamAgent as its emitter. Reproduces the inline loop’s targetElement.* call sequence exactly (validated by the engine parity test against the real loop).

ParameterType
optsCreateStreamAdapterOptions

StreamRunEmitter


ts
function readableToAsyncIterable(stream, signal): AsyncIterable<AparteStreamEvent>;

Defined in: packages/core/src/client/stream-adapter.ts:323

Bridge a ReadableStream (what the transport returns) to the AsyncIterable<AparteStreamEvent> runStreamAgent consumes, cancelling the reader synchronously on abort so a user “stop” cuts the in-flight read. Used by AparteClient when building transportCall for the runner. Mirrors the inline loop’s reader.read() loop + reader.cancel().

ParameterType
streamReadableStream<AparteStreamEvent>
signalAbortSignal

AsyncIterable<AparteStreamEvent>


Defined in: packages/core/src/client/agent-runner.ts:7

ts
endpoint: string;

Defined in: packages/core/src/client/agent-runner.ts:9

The route that serves createAparteAgentHandler, e.g. /api/agent.

ts
optional headers?: 
  | Record<string, string>
  | (() => 
  | Record<string, string>
  | Promise<Record<string, string>>);

Defined in: packages/core/src/client/agent-runner.ts:11

Sent with every request; a function is called per request (a fresh token each time).

ts
optional fetch?: {
  (input, init?): Promise<Response>;
  (input, init?): Promise<Response>;
};

Defined in: packages/core/src/client/agent-runner.ts:13

ts
(input, init?): Promise<Response>;

MDN Reference

ParameterType
inputRequestInfo | URL
init?RequestInit

Promise<Response>

ts
(input, init?): Promise<Response>;

MDN Reference

ParameterType
inputstring | Request | URL
init?RequestInit

Promise<Response>

the global fetch

ts
optional credentials?: RequestCredentials;

Defined in: packages/core/src/client/agent-runner.ts:15

For a cross-origin endpoint that authenticates by cookie.


Defined in: packages/core/src/client/aparte-client.ts:98

Configuration options for AparteClient

ts
optional keyResolver?: (providerId) => 
  | string
  | Record<string, string>
  | Promise<string | Record<string, string> | null | undefined>
  | null
  | undefined;

Defined in: packages/core/src/client/aparte-client.ts:103

Function to resolve API keys for a given provider. Can return a string (key) or a full configuration object.

ParameterType
providerIdstring

| string | Record<string, string> | Promise<string | Record<string, string> | null | undefined> | null | undefined

ts
optional approvalResolver?: AparteToolApprovalResolver;

Defined in: packages/core/src/client/aparte-client.ts:122

Custom human-in-the-loop approval resolver for tools marked needsApproval. Without one, the gate asks at the composer through requestUserInput, like every other request for the user. Inject this to decide from the call itself — it receives (call, signal) — or to drive approval from a headless source (CLI / webhook) with no DOM.

It owns the WHOLE decision: with one injected, an AparteApprovalPolicy registered through setApprovalPolicy() — and therefore @aparte/plugin-approval’s modes — is not consulted at all, neither for the gate nor for the answer, and the tool’s own needsApproval decides which calls reach this resolver. Rule on the call here, or drop this option and use a policy; do not expect both.

On a refusal it may return an instruction (the user’s words) or a reason (nobody spoke), which the model reads as the tool result.

ts
optional streamRunner?: AparteStreamRunner;

Defined in: packages/core/src/client/aparte-client.ts:131

The stream-loop runner. Default: @aparte/engine’s runStreamAgent, rendered through the core adapter (createStreamAdapter). Set it to wrap that loop — (opts) => runStreamAgent({ ...opts, onHistoryAppend }) for a host that owns its transcript — or to replace it with a loop of your own that emits the same events. Same injection pattern as approvalResolver. See AparteStreamRunner.

ts
optional requestInterceptor?: (request) => 
  | AparteChatRequest
| Promise<AparteChatRequest>;

Defined in: packages/core/src/client/aparte-client.ts:136

Optional request interceptor to modify the chat request before sending.

ParameterType
requestAparteChatRequest

| AparteChatRequest | Promise<AparteChatRequest>

ts
optional autoRegister?: boolean;

Defined in: packages/core/src/client/aparte-client.ts:148

Whether to register core’s default segment renderers.

Rarely needed either way: the built-ins install themselves the first time a segment needs one, so leaving this alone just works. Set it to false to keep them out entirely — a decision that is remembered, so nothing installs them later; register your own with registerSegmentRenderer. Do it at startup, before the first segment renders.

ts
true
ts
optional history?: 
  | "none"
  | "viewport"
  | ((viewportMessages) => AparteChatMessage[]);

Defined in: packages/core/src/client/aparte-client.ts:161

Conversation history strategy:

  • ‘viewport’ (default) — sends every user/assistant turn up to the last answered one. A turn that errored, or is still in flight (‘streaming’ / ‘pending’), is held back and does not move that cutoff; a turn a host seeded with NO status counts as answered, so a restored or server-rendered transcript goes out as history without inventing a status for it.
  • ‘none’ — sends only the current message (original behavior)
  • function — custom: receives viewport messages, returns AparteChatMessage[]
ts
optional targetResolver?: () => HTMLElement | null;

Defined in: packages/core/src/client/aparte-client.ts:171

Optional resolver that returns the host element exposing appendMessage. Use this when the default event-bubble walk cannot reach the host (e.g. Angular re-renders detach the input element mid-flight).

HTMLElement | null

ts
targetResolver: () => document.querySelector('aparte-chat')
ts
optional scopeToTargetId?: string;

Defined in: packages/core/src/client/aparte-client.ts:185

Scope this client to a specific target element id. When set, the client will only handle aparte-send, aparte-retry, aparte-edit and aparte-abort events whose detail.targetId matches this id. This allows multiple AparteClient instances (one per conversation) to coexist on the same page without interfering with each other.

ts
// Two independent conversations:
new AparteClient({ scopeToTargetId: 'chat-left' }).start();
new AparteClient({ scopeToTargetId: 'chat-right' }).start();
ts
optional maxTurns?: number;

Defined in: packages/core/src/client/aparte-client.ts:193

Maximum number of agentic tool-call loop turns before the loop is forcibly stopped and an error segment is shown. Prevents infinite loops. Individual tools can override this via AparteTool.maxTurns.

ts
10
ts
optional toolTimeoutMs?: number;

Defined in: packages/core/src/client/aparte-client.ts:199

Per-call ceiling (ms) for a tool handler to resolve before its signal is aborted. Defaults to 5 minutes — the same default, and the same option name, as runStreamAgent, so the value means one thing whichever loop runs.

ts
optional echoUserMessage?: boolean;

Defined in: packages/core/src/client/aparte-client.ts:214

Whether a send appends the optimistic USER bubble before the reply streams.

Default true — and opt-OUT on purpose: the bubble used to be the host’s job on every path, everyone wrote the same aparte-send handler, and whoever forgot shipped a chat where the person cannot see what they typed. It compiles, it streams, and nothing errors.

Pass false when the host owns its transcript and appends the user message itself — the four framework wrappers do (their ConversationController is that owner) and pass it. The wire cannot double either way: the history builder already excludes trailing unanswered user messages.

ts
optional rawFileInject?: "none" | "all" | "images-only";

Defined in: packages/core/src/client/aparte-client.ts:234

Controls which files attached by the user are injected as raw content parts in the LLM request.

  • 'all' (default) — images as base64, text files as code-fenced text
  • 'images-only' — only images are injected; text/binary documents are left for the application layer (e.g. a RAG pipeline) to handle
  • 'none' — no files are injected as content parts; ALL file types (including images) are routed to the application layer. Used when images go through a captioning pipeline before RAG ingest, so the chat context only ever sees retrieved text — never raw image bytes. Saves bytes on every turn and matches the offline-first intent (read file once at upload, retrieve text-only forever after).

Set 'images-only' when a requestInterceptor retrieves relevant document chunks and injects them as a system message instead, to avoid flooding the context window with full file contents.

ts
optional fileInjectFilter?: (file) => boolean;

Defined in: packages/core/src/client/aparte-client.ts:247

Per-file veto on top of rawFileInject: called for each file the mode would inject; return false to keep that file out of the request. The file still rides on the aparte-send event for the application layer (upload, RAG). Use it to block sensitive names while keeping the default inline UX:

ts
fileInjectFilter: (f) => !/(^|\.)env$|\.(pem|key)$/i.test(f.name)
ParameterType
fileFile

boolean

ts
optional config?: AparteConfig;

Defined in: packages/core/src/client/aparte-client.ts:255

Config this client reads (providers, model selection, tools, system prompt). Defaults to aparteGlobalConfig. Pass a host’s instance config when scoping a client to one chat among several (pairs with scopeToTargetId).


Defined in: packages/core/src/client/stream-adapter.ts:71

The imperative surface the adapter drives (subset of AparteChatTargetElement). Every method is optional so a partial/mock target degrades gracefully.

ts
optional updateMessage(id, updates): void;

Defined in: packages/core/src/client/stream-adapter.ts:72

ParameterType
idstring
updatesPartial<AparteMessage>

void

ts
optional updateLastMessage(content, options?): void;

Defined in: packages/core/src/client/stream-adapter.ts:73

ParameterType
contentstring
options?{ append?: boolean; }
options.append?boolean

void

ts
optional addSegment(segment): void;

Defined in: packages/core/src/client/stream-adapter.ts:74

ParameterType
segmentAparteSegment

void

ts
optional updateSegment(segmentId, updates): void;

Defined in: packages/core/src/client/stream-adapter.ts:75

ParameterType
segmentIdstring
updatesPartial<AparteSegment>

void

ts
optional typeName(text): void;

Defined in: packages/core/src/client/stream-adapter.ts:76

ParameterType
textstring

void

ts
optional setUsage(id, usage): void;

Defined in: packages/core/src/client/stream-adapter.ts:77

ParameterType
idstring
usageAparteUsage

void

ts
dispatchEvent(event): boolean;

Defined in: packages/core/src/client/stream-adapter.ts:78

ParameterType
eventEvent

boolean


Defined in: packages/core/src/client/stream-adapter.ts:81

ts
target: StreamAdapterTarget;

Defined in: packages/core/src/client/stream-adapter.ts:83

The chat target element the events are rendered onto.

ts
config: AparteConfig;

Defined in: packages/core/src/client/stream-adapter.ts:85

Config for tool-renderer lookup + per-tool style injection.

ts
messageId: string;

Defined in: packages/core/src/client/stream-adapter.ts:87

The streamed assistant message id (carried in the run events).

ts
optional targetId?: string;

Defined in: packages/core/src/client/stream-adapter.ts:95

The id of the CHAT the target belongs to, stamped on every lifecycle event the adapter dispatches. The target is whatever renders — a shell’s .viewport, which has no id of its own — so it cannot be read off the target, and an unstamped event is read as “for every chat on the page”. Omitted, the dispatcher falls back to target.id, which is right for the viewport-only chat shape.


Defined in: packages/core/src/host/aparte-chat-host.ts:80

Everything AparteChatHost needs from the framework, expressed without any framework types. Each wrapper (Angular signals, React state, Vue refs, Svelte stores) implements these ~10 closures over its own reactive message list.

ts
readonly hostId: string;

Defined in: packages/core/src/host/aparte-chat-host.ts:82

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

ts
readonly host: HTMLElement;

Defined in: packages/core/src/host/aparte-chat-host.ts:84

The element AparteClient drives + that emits lifecycle/path events.

ts
readonly viewport: HTMLElement | null;

Defined in: packages/core/src/host/aparte-chat-host.ts:86

The <aparte-chat-viewport> element (branch ops, token append, bubbles).

ts
getMessages(): AparteMessage[];

Defined in: packages/core/src/host/aparte-chat-host.ts:89

Read the current message list (a snapshot).

AparteMessage[]

ts
setMessages(messages): void;

Defined in: packages/core/src/host/aparte-chat-host.ts:91

Replace the framework’s message list (triggers its re-render).

ParameterType
messagesAparteMessage[]

void

ts
optional onMessagesChange(messages): void;

Defined in: packages/core/src/host/aparte-chat-host.ts:94

Notify the consumer that messages changed (drives messagesChange).

ParameterType
messagesAparteMessage[]

void

ts
optional onMessageAppended(message): void;

Defined in: packages/core/src/host/aparte-chat-host.ts:96

Notify the consumer a message was appended (drives messageAppended).

ParameterType
messageAparteMessage

void

ts
optional onTypingChange(isTyping): void;

Defined in: packages/core/src/host/aparte-chat-host.ts:98

Flip the typing/“thinking” indicator.

ParameterType
isTypingboolean

void

ts
optional onStreamingChange(streamingId): void;

Defined in: packages/core/src/host/aparte-chat-host.ts:100

Streaming target id changed (drives isStreaming).

ParameterType
streamingIdstring | null

void

ts
afterRender(cb): void;

Defined in: packages/core/src/host/aparte-chat-host.ts:102

Run a callback after the framework has applied the latest render.

ParameterType
cb() => void

void

ts
optional resetComposer(): void;

Defined in: packages/core/src/host/aparte-chat-host.ts:104

Reset the composer (clear text/attachments) on conversation swap.

void

ts
optional onLoadingChange(loading): void;

Defined in: packages/core/src/host/aparte-chat-host.ts:116

The transcript is on its way (true) or has arrived (false): the controller’s wait, forwarded so a wrapper that draws its own DOM can draw the wait — the skeleton, the empty state kept off, the composer disabled.

Declaring it makes the wait YOURS, aria-busy included: the host stops writing the viewport’s loading attribute and leaves it to you, because two writers with two ideas of when the wait ends is how a wrapper came to draw a skeleton over a transcript the attribute said had arrived. A binding without this callback keeps the attribute written for it.

ParameterType
loadingboolean

void


Defined in: packages/core/src/host/aparte-chat-host.ts:119

ts
optional layoutTransitionMs?: number;

Defined in: packages/core/src/host/aparte-chat-host.ts:121

Forwarded to viewport.configure({ layoutTransitionMs }) when > 0.

ts
optional conversationId?: string | null;

Defined in: packages/core/src/host/aparte-chat-host.ts:123

Initial conversation id to load when the controller is created.

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

Defined in: packages/core/src/host/aparte-chat-host.ts:125

Called when the controller lazily creates a conversation on first send.

ParameterType
idstring

void

ts
optional config?: AparteConfig;

Defined in: packages/core/src/host/aparte-chat-host.ts:133

Instance config for this chat. When provided, bind marks the host element as a [data-aparte-host] boundary so every Aparte component inside it (bubbles, composer, renderers) resolves THIS config instead of the global aparteGlobalConfig — the seam that lets several independently-configured chats coexist on one page. Omit to keep the global-config behaviour.


ts
type AparteToolApprovalResolver = (call, signal) => Promise<{
  approved: boolean;
  payload?: unknown;
  instruction?: string;
  reason?: string;
}>;

Defined in: packages/core/src/client/aparte-client.ts:69

Resolves a human-in-the-loop tool approval for a needsApproval tool call. Resolves { approved, payload? }; the signal aborts a pending decision.

It receives the CALL, not just its id. You cannot ask a person “run this?” without naming what — the built-in channel needs the tool’s name for its question, and an id alone forced a lookup table filled by one event and read by another, which is the shape that breaks in silence.

ParameterType
call{ id: string; name: string; input: Record<string, unknown>; }
call.idstring
call.namestring
call.inputRecord<string, unknown>
signalAbortSignal

Promise<{ approved: boolean; payload?: unknown; instruction?: string; reason?: string; }>


ts
type AparteStreamRunEvent = StreamRunEvent;

Defined in: packages/core/src/client/stream-adapter.ts:40

The DOM-free run events @aparte/engine’s runStreamAgent emits — engine’s StreamRunEvent, under core’s name. See packages/engine/src/agent/stream-events.ts for the per-event _streamLoop mapping notes.


ts
type AparteStreamRunEmitter = StreamRunEmitter;

Defined in: packages/core/src/client/stream-adapter.ts:43

Synchronous, ordered event sink — engine’s StreamRunEmitter.


ts
type AparteStreamRunOptions = StreamRunOptions;

Defined in: packages/core/src/client/stream-adapter.ts:52

Options for an injected AparteStreamRunner — engine’s StreamRunOptions. AparteClient builds these from its config / provider / transport and hands them to the runner; core’s request, message and tool types are assignable to the structural ones the engine declares, and that assignment is checked where it is made rather than in a guard beside it.


ts
type AparteStreamRunner = (opts) => Promise<StreamUsage | undefined>;

Defined in: packages/core/src/client/stream-adapter.ts:65

A headless structured-stream loop injected via AparteClientOptions.streamRunner — the seam by which a host wraps or replaces the loop AparteClient runs, which is @aparte/engine’s runStreamAgent by default.

runStreamAgent IS this type — pass it, do not cast it. An earlier version of this comment advised a cast “if the duck-typed shapes don’t line up”, which is how the two packages’ message types drifted apart unnoticed and shipped a streamRunner: runStreamAgent that did not compile on five docs pages and a README. The alias makes that drift a typecheck error in the composition itself.

ParameterType
optsAparteStreamRunOptions

Promise<StreamUsage | undefined>