zidane-ui/ adapters
Browser-safe ChatHost implementations that connect the chat components to an agent.
import { … } from 'zidane-ui/adapters'ui/src/adapters/index.ts
Use zidane-ui/adapters to back the chat components with a real run: createRunHost, createWorkerHost with exposeRunHost, createSseHost and createServerHost. The protocol constants and codecs are exported for custom transports. Connecting a host sets each one up and lists their limits.
import { createRunHost } from 'zidane-ui/adapters'
const host = createRunHost({
async run({ prompt, emit }) {
emit({ kind: 'markdown', text: 'Looking ', streaming: true })
emit({ kind: 'markdown', text: `it up: ${prompt}`, streaming: true })
},
})
await host.send?.({ sessionId: 's1', prompt: 'hello' })Functions#
applyLiveEventFunction#
One live event folded into a transcript (now stamps arrival on tool rows and thinking lanes).
Generic over the event type so the desktop app's GuiStreamEvent lanes fold the same way.
attachmentsFromPreviewsFunction#
ChatAttachment previews → zidane's prompt attachments (base64, no data-URL prefix).
closeThinkingSegmentFunction#
zidane's live event rule, re-exported for the adapters' public entry. It
lives with the session stream store (chat/headless/streams/), which
folds every transcript with it.
createBrowserAppearanceHostFunction#
Creates an AppearanceHost over the browser's storage: prefs and boot.
createBrowserKeybindingsHostFunction#
Creates a KeybindingsHost over the browser's storage: the overrides and save.
createBrowserWorkspaceHostFunction#
Creates the web app's WorkspaceHost: layouts in browser storage, and the server's extension panels.
createLiveStateFunction#
Creates the stores a ChatHost exposes: the session list, per-session transcripts, and pending interactions.
createRunHostFunction#
Creates a ChatHost around a run function. Sessions, transcripts, and pending interactions live in memory; the app supplies the agent through run.
createServerApprovalsHostFunction#
Creates an ApprovalsHost on a running zidane-server.
createServerClientFunction#
The zidane-server client the server adapter speaks through: zidane's own browser client
(zidane/ipc/browser), re-exported so an app reaches it from the kit. Share one client
between the chat host and the other areas' hosts on the same server.
createServerComposerHostFunction#
Creates a ComposerHost over a zidane-server client.
createServerExtensionModuleLoaderFunction#
Creates a loader of extension ui.tsx modules from zidane-server: each bundle where the folder's
listing says, by its hash, linked against modules. A bundle URL the server no longer knows (it
restarted since the listing) is looked up again in a fresh listing, once.
createServerExtensionsHostFunction#
Creates an ExtensionsHost over a zidane-server client.
createServerFilesHostFunction#
Creates a FilesHost on a running zidane-server.
createServerGitHostFunction#
Creates a GitHost over a zidane-server client.
createServerHostFunction#
Creates a ChatHost on a running zidane-server. Pass a shared client, or the url
and token (and client options) to create one.
createServerMachinesHostFunction#
Creates a MachinesHost on a running zidane-server.
createServerOnboardingHostFunction#
Creates an OnboardingHost on a running zidane-server.
createServerPaletteHostFunction#
Creates a PaletteHost over a zidane-server client.
createServerSessionHostFunction#
Creates a SessionHost over a zidane-server client.
createServerSettingsHostFunction#
Creates a SettingsHost on a running zidane-server.
createServerSidebarHostFunction#
Creates a SidebarHost over a zidane-server client.
createServerTerminalHostFunction#
Creates a TerminalHost on a running zidane-server.
createServerWebviewSourcesFunction#
Creates the webview URL source over zidane-server: a file source is minted once per folder
(POST /zidane/extensions/webview?cwd=&id=, with the token) into a URL under an unguessable ticket,
served sandboxed with no network: the page talks to its extension only through the RPC bridge.
createSseHostFunction#
Creates a ChatHost over HTTP and server-sent events, talking to a handler from createSseHandler. Actions are POSTs and each watched transcript is one streaming GET that resumes after a drop.
createSseParserFunction#
Creates an incremental text/event-stream parser that follows the WHATWG interpretation. Used instead of EventSource so requests can carry headers.
createStreamPacerFunction#
Creates a pacer that feeds apply (a run's emit, a live state's apply).
createWorkerHostFunction#
Creates a ChatHost in the page whose runs execute in a Web Worker. Sessions, transcripts, and interactions stay in the page; the worker runs the agent through exposeRunHost.
decodeFromWorkerFunction#
Checks a message the page received from the worker. Returns the FromWorker message, 'version' when it speaks another protocol version, or null when it is not a protocol message.
decodeToWorkerFunction#
A protocol message for the worker, or why not: 'version' (another protocol version), null (not ours).
encodeSseRecordFunction#
One SSE record on the wire (data is single-line JSON, so one data: field).
exposeRunHostFunction#
Serve run to the page over scope (default: the worker's global scope).
Returns a function that stops listening.
finishLiveFunction#
A run ended: close the blocks still marked streaming and every thinking lane still open.
formatCursorFunction#
Builds a stream cursor, the Last-Event-ID value that names a record.
installExtensionHostModulesFunction#
Puts modules in the host module map linked bundles read (merged over what is there).
linkExtensionModuleFunction#
Rewrites a bundle's imports of host modules into reads of the host module map, so the code runs as a module with no imports. A bare import the map has no module for fails, every one named. Relative and URL imports are left alone (a self-contained bundle has none).
parseCursorFunction#
Parses a cursor from formatCursor. Returns null for a missing or malformed cursor.
toChatModelProvidersFunction#
Converts the server's model list into the model picker's providers.
toChatSessionFunction#
Converts a zidane server's session row into a ChatSession. The project root becomes the group, the main session is pinned, and the model id gets its provider prefix.
toSidebarListSessionFunction#
Converts a zidane server's session row into a SidebarListSession: the chat session plus its folder and space.
Classes#
ExtensionModuleLinkErrorClass#
A bundle that imports something the app does not provide.
ExtensionModuleLoadErrorClass#
A bundle that could not be loaded: not listed, did not bundle, or the server refused.
ServerCallErrorClass#
A call the server answered with an error: its JSON-RPC code and data.
ServerConnectionErrorClass#
A call that couldn't be answered: the connection dropped, or the client was refused or closed.
Constants#
EXTENSION_HOST_MODULES_GLOBALConstant#
The global the linked bundles read host modules from.
SERVER_AUTH_CHECK_PATHConstant#
The path of a zidane-server's auth check, relative to its WebSocket URL's origin (same as SERVER_AUTH_PATH).
SERVER_MACHINES_HOST_IDConstant#
The id the server goes by until its handshake names it (hello.hostId).
SSE_PROTOCOL_HEADERConstant#
Name of the response header that carries the protocol version.
SSE_PROTOCOL_VERSIONConstant#
Version of the HTTP and server-sent-events protocol between createSseHost and createSseHandler.
WORKER_PROTOCOL_VERSIONConstant#
Version of the postMessage protocol between createWorkerHost and exposeRunHost. A side drops messages of another version.
Interfaces#
BrowserAppearanceHostOptionsInterface#
Options of createBrowserAppearanceHost.
BrowserKeybindingsHostOptionsInterface#
Options of createBrowserKeybindingsHost.
BrowserWorkspaceHostOptionsInterface#
Options for createBrowserWorkspaceHost.
ExtensionsClientAnnounceInterface#
What the window says about itself (ui.client.announce).
HydrateResponseInterface#
Body of GET /sessions/:id/events: the transcript so far, plus what a client needs to start streaming.
LinkedExtensionModuleInterface#
A linked bundle: its code, and the host modules it reads.
LiveStateInterface#
The client half of the live transcript: the stores a ChatHost exposes, fed by live events. Shared by every adapter.
LiveStateOptionsInterface#
Options for createLiveState.
LiveTranscriptInterface#
One session's live transcript: its state store and the echo bookkeeping.
MessageEndpointInterface#
What both ends need of a Worker / DedicatedWorkerGlobalScope / MessagePort.
RunContextInterface#
What createRunHost hands to the run function for one sent prompt.
RunHostInterface#
The ChatHost createRunHost returns, plus what only an in-memory host can do.
RunHostOptionsInterface#
Options for createRunHost.
SendBodyInterface#
Body of POST /sessions/:id/send.
ServerApprovalsHostOptionsInterface#
Options for createServerApprovalsHost.
ServerClientInterface#
A connection to a zidane-server: typed calls, signals and its state.
ServerClientOptionsInterface#
Options for createServerClient.
ServerComposerHostInterface#
The ComposerHost createServerComposerHost returns.
ServerComposerHostOptionsInterface#
Options for createServerComposerHost.
ServerExtensionAssetsAccessInterface#
Where the server serves the extensions' assets (webview pages), and the token they are fetched with.
ServerExtensionCommandsInterface#
The commands, with the keymap mode on top for the session the window shows.
ServerExtensionCommandWireInterface#
A command as this host lists it: the kit's wire, plus where its keybinding fires.
ServerExtensionDialogsInterface#
Dialogs, with the form field check.
ServerExtensionModuleLoaderInterface#
What createServerExtensionModuleLoader returns.
ServerExtensionModuleLoaderOptionsInterface#
Options for createServerExtensionModuleLoader.
ServerExtensionsHostInterface#
The ExtensionsHost createServerExtensionsHost returns.
ServerExtensionsHostOptionsInterface#
Options for createServerExtensionsHost.
ServerFilesHostOptionsInterface#
Options for createServerFilesHost.
ServerGitHostOptionsInterface#
Options for createServerGitHost.
ServerHostInterface#
The ChatHost createServerHost returns, plus the connection.
ServerMachinesHostInterface#
The MachinesHost createServerMachinesHost returns.
ServerMachinesHostOptionsInterface#
Options for createServerMachinesHost.
ServerOnboardingHostInterface#
The OnboardingHost createServerOnboardingHost returns.
ServerOnboardingHostOptionsInterface#
Options for createServerOnboardingHost.
ServerPaletteHostInterface#
The PaletteHost createServerPaletteHost returns.
ServerPaletteHostOptionsInterface#
Options for createServerPaletteHost.
ServerSessionHostInterface#
The SessionHost createServerSessionHost returns.
ServerSessionHostOptionsInterface#
Options for createServerSessionHost.
ServerSettingsHostInterface#
The SettingsHost createServerSettingsHost returns.
ServerSettingsHostOptionsInterface#
Options for createServerSettingsHost.
ServerSidebarHostOptionsInterface#
Options for createServerSidebarHost.
ServerTerminalHostOptionsInterface#
Options for createServerTerminalHost.
ServerWebviewSourcesInterface#
Webview URLs from zidane-server, for ExtensionWebview's resolveSrc.
ServerWebviewSourcesOptionsInterface#
Options for createServerWebviewSources.
SseHostInterface#
The ChatHost createSseHost returns, plus the stream controls.
SseHostOptionsInterface#
Options for createSseHost.
SseParserInterface#
An incremental parser created by createSseParser.
SseRecordInterface#
An incremental text/event-stream parser (the WHATWG "event stream
interpretation"): feed it decoded text in any chunking, it calls onRecord
for each dispatched record. Used instead of EventSource so requests can
carry headers (auth) and the client controls reconnects.
StreamPacerInterface#
What createStreamPacer returns.
StreamPacerOptionsInterface#
Options of createStreamPacer.
WorkerHostOptionsInterface#
Options for createWorkerHost: the RunHostOptions except run, plus newRunId.
WorkerRunInputInterface#
The prompt the page sends to start a run in the worker.
Types#
AnswerBodyType#
Body of POST /interactions/:requestId/answer.
ExtensionFlowStepHandlerType#
Answers one sign-in step of an integration flow: the value for a step that asks (undefined cancels).
ExtensionHostModuleType#
A module namespace (import * as React from 'react').
ExtensionHostModulesType#
Host modules by specifier: what the app hands the extensions' components.
ExtensionHostModuleSourcesType#
Host modules by specifier, each a namespace or a loader of one (a function resolving the namespace): a loader runs the first time a bundle imports its specifier, so the app's first load stays small.
ExtensionModuleLoadType#
Loads an extension's ui.tsx module: its exports by name (zidane-ui/extensions' ExtensionModuleLoader).
FromWorkerType#
A message from the worker to the page: ready, a live event, an ask request, steerable, or done when the run ends.
RunFnType#
Runs the agent for one prompt. Called once per sent prompt with a RunContext. The run ends when the returned promise settles; a rejection shows as an error row.
ServerClientStateType#
Where a ServerClient's connection is.
ServerExtensionBundleType#
One extension's bundle in the folder's listing: where it is (relative to the server's origin), or why it did not bundle.
ServerExtensionBundleLookupType#
Where an extension's bundle is, from the folder's current listing (ServerExtensionsHost.bundle);
fresh: list again first (the listed URL went stale). undefined: it has none.
ServerHostOptionsType#
Options for createServerHost: a client to share, or what to create one with.
ServerRefusalType#
Why a server refused this client for good: token (unknown or revoked), the server's
admission refusals (origin not allowed, insecure-transport, untrusted-proxy, a
scope it may not connect with), or a protocol the two don't share.
StreamRecordType#
One record of a session's event stream: a transcript event, a run state change, an interaction raised or resolved, a session update, or a reset that tells the client to hydrate again.
ToWorkerType#
A message from the page to the worker: send starts a run, interrupt aborts it, steer passes guidance to it, and answer returns the user's reply to a request.