Skip to content

Client command API

diosc() is the global command function the widget installs. Call it with a command name and its arguments. Calls made before the widget finishes loading are queued and replayed in order.

import { loadDiosc } from '@dioschub/client';
const { diosc } = loadDiosc({ backendUrl: 'https://your-hub.example.com', apiKey: 'YOUR_EMBED_KEY' });
diosc('open');

Types referenced below are exported from @dioschub/client.

CommandDescription
diosc('config', config: DioscConfig)Apply configuration. See DioscConfig.
diosc('bindHeaders', factory | null)Provide extra headers for the host bind endpoint. The factory runs on every bind cycle (sync or async). null clears it.
CommandDescription
diosc('tool', name: string, handler)Register a browser tool the assistant may call.
diosc('browserAdapter', adapter | null)Declare the host’s browser-intent surface. null clears it.
diosc('mentionProvider', query | null)Register an @-mention resolver. null clears it. See Composer mentions.
diosc('consensusView', pattern: string | RegExp, descriptor | null)Render the consensus dialog’s detail body for matching tools. Returns an unregister function. See Consensus views.
CommandDescription
diosc('observe', 'navigation', observer)Feed the assistant page context on every route change.
diosc('invoke', input: string, pageContext?): Promise<void>Send a message programmatically, with optional page context.
CommandDescription
diosc('on', event, handler): UnsubscribeSubscribe to one event. See Web component API → Events.
diosc('onAny', handler): UnsubscribeSubscribe to every event; the handler receives (event, payload).
CommandDescription
diosc('connect'): Promise<void>Open the connection.
diosc('disconnect')Close the connection.
diosc('reauth')Re-run the host bind flow on the live connection; call after host auth state changes, e.g. an anonymous visitor signs in. No-op when not connected.
diosc('fetchAssistantConfig'): Promise<void>Refetch the assistant’s configuration.
CommandDescription
diosc('open')Expand the panel.
diosc('close')Collapse to the launcher.
diosc('toggle')Flip between open and closed.
diosc('setPosition', 'bottom-left' | 'bottom-right')Anchor the launcher to a corner. See Widget placement.

Approval decisions are not global commands: there is no diosc('approve'). A global approve would let any script on the host page auto-approve the assistant’s actions, which the consensus model exists to prevent. The built-in consensus dialog resolves every approval, and there is no host-rendered alternative at any tier. You can restyle the dialog’s detail body per tool with diosc('consensusView', …) — that surface reports field edits but carries no verdict channel.

CommandDescription
diosc('cancelStream')Stop the in-progress response.
CommandDescription
diosc('fetchSessionList', options?: { limit?, cursor? })Load the session list over the socket.
diosc('fetchSessionListViaREST', options?: { limit?, cursor?, status? }): Promise<void>Load the session list over REST.
diosc('searchSessions', options: { query, limit?, status? }): Promise<void>Search sessions.
diosc('clearSessionSearch'): Promise<void>Clear an active session search.
diosc('loadSession', sessionId: string)Open a session by id.
diosc('startNewSession')Start a new session.
diosc('renameSession', sessionId: string, name: string)Rename a session.
diosc('pinSession', sessionId: string, isPinned: boolean)Pin or unpin a session.

The object passed to diosc('config', …). All fields are optional.

FieldTypeDescription
backendUrlstringBackend URL for the WebSocket/REST connection.
apiKeystringEmbed key.
assistantIdstringAssistant ID. Auto-detected from the config fetch if omitted.
bindEndpointstringYour host endpoint that authenticates the user and forwards identity to DioscHub’s /auth/bind. The widget POSTs { wsId } to it with credentials. See Identity & auth.
verbosebooleanVerbose logging.
autoConnectbooleanConnect automatically on initialization.
reconnectAttemptsnumberNumber of reconnection attempts.
reconnectDelaynumberReconnection delay (ms).
reconnectDelayMaxnumberMaximum reconnection delay (ms).
connectionTimeoutnumberConnection timeout (ms).