Command, protocol, and transport types for connecting assistant-ui runtimes across execution boundaries.
API Reference
AssistantTransportCommand
AssistantTransportCommandtype: "add-message"AssistantTransportConnectionMetadata
AssistantTransportConnectionMetadatapendingCommands: AssistantTransportCommand[]isSending: booleantoolStatuses: Record<string, ToolExecutionStatus>AssistantTransportProtocol
AssistantTransportProtocoltoString: () => stringcharAt: (pos: number) => stringcharCodeAt: (index: number) => numberconcat: (...strings: string[]) => stringindexOf: (searchString: string, position?: number) => numberlastIndexOf: (searchString: string, position?: number) => numberlocaleCompare: { (that: string): number; (that: string, locales?: string | string[], options?: Intl.CollatorOptions): number; (that: string, locales?: Intl.LocalesArgument, options?: Intl.CollatorOptions): number; }match: { (regexp: string | RegExp): RegExpMatchArray | null; (matcher: { [Symbol.match](string: string): RegExpMatchArray | null; }): RegExpMatchArray | null; }replace: { (searchValue: string | RegExp, replaceValue: string): string; (searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string; (searchValue: { [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; }, replacer: (substring: string, ...args: any[]) => string): string; }search: { (regexp: string | RegExp): number; (searcher: { [Symbol.search](string: string): number; }): number; }slice: (start?: number, end?: number) => stringsplit: { (separator: string | RegExp, limit?: number): string[]; (splitter: { [Symbol.split](string: string, limit?: number): string[]; }, limit?: number): string[]; }substring: (start: number, end?: number) => stringtoLowerCase: () => stringtoLocaleLowerCase: { (locales?: string | string[]): string; (locales?: Intl.LocalesArgument): string; }toUpperCase: () => stringtoLocaleUpperCase: { (locales?: string | string[]): string; (locales?: Intl.LocalesArgument): string; }trim: () => stringlength: numbersubstr: (from: number, length?: number) => stringvalueOf: () => stringcodePointAt: (pos: number) => numberincludes: (searchString: string, position?: number) => booleanendsWith: (searchString: string, endPosition?: number) => booleannormalize: { (form: "NFC" | "NFD" | "NFKC" | "NFKD"): string; (form?: string): string; }repeat: (count: number) => stringstartsWith: (searchString: string, position?: number) => booleananchor: (name: string) => stringbig: () => stringblink: () => stringbold: () => stringfixed: () => stringfontcolor: (color: string) => stringfontsize: { (size: number): string; (size: string): string; }italics: () => stringlink: (url: string) => stringsmall: () => stringstrike: () => stringsub: () => stringsup: () => stringpadStart: (maxLength: number, fillString?: string) => stringpadEnd: (maxLength: number, fillString?: string) => stringtrimEnd: () => stringtrimStart: () => stringtrimLeft: () => stringtrimRight: () => stringmatchAll: (regexp: RegExp) => RegExpStringIterator<RegExpExecArray>replaceAll: { (searchValue: string | RegExp, replaceValue: string): string; (searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; }at: (index: number) => stringSendCommandsRequestBody
SendCommandsRequestBodycommands: QueuedCommand[]state: unknownsystem?: stringtools?: Record<string, unknown>callSettings?: LanguageModelV1CallSettingsmaxTokens?: numbertemperature?: numbertopP?: numberpresencePenalty?: numberfrequencyPenalty?: numberseed?: numberheaders?: Record<string, string | undefined>config?: LanguageModelConfigapiKey?: stringbaseUrl?: stringmodelName?: stringthreadId: string | nullparentId?: string | nulluseAssistantTransportRuntime
useAssistantTransportRuntimeoptions: AssistantTransportOptions<T>initialState: Tapi: stringresumeApi?: stringprotocol?: AssistantTransportProtocolconverter: AssistantTransportStateConverter<T>headers: HeadersValue | (() => Promise<HeadersValue>)append: (name: string, value: string) => voidThe **`append()`** method of the Headers interface appends a new value onto an existing header inside a Headers object, or adds the header if it does not already exist. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/append)
delete: (name: string) => voidThe **`delete()`** method of the Headers interface deletes a header from the current Headers object. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/delete)
get: (name: string) => string | nullThe **`get()`** method of the Headers interface returns a byte string of all the values of a header within a Headers object with a given name. If the requested header doesn't exist in the Headers object, it returns null. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/get)
getSetCookie: () => string[]The **`getSetCookie()`** method of the Headers interface returns an array containing the values of all Set-Cookie headers associated with a response. This allows Headers objects to handle having multiple Set-Cookie headers, which wasn't possible prior to its implementation. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/getSetCookie)
has: (name: string) => booleanThe **`has()`** method of the Headers interface returns a boolean stating whether a Headers object contains a certain header. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/has)
set: (name: string, value: string) => voidThe **`set()`** method of the Headers interface sets a new value for an existing header inside a Headers object, or adds the header if it does not already exist. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/set)
forEach: (callbackfn: (value: string, key: string, parent: Headers) => void, thisArg?: any) => voidentries: () => HeadersIterator<[string, string]>Returns an iterator allowing to go through all key/value pairs contained in this object.
keys: () => HeadersIterator<string>Returns an iterator allowing to go through all keys of the key/value pairs contained in this object.
values: () => HeadersIterator<string>Returns an iterator allowing to go through all values of the key/value pairs contained in this object.
body?: object | (() => Promise<object | undefined>)prepareSendCommandsRequest?: (
body: SendCommandsRequestBody,
) => Record<string, unknown> | Promise<Record<string, unknown>>Transform the request body before it is sent to the API. Receives the fully assembled body and returns the (potentially transformed) body.
onResponse?: (response: Response) => voidonFinish?: () => voidonError?: (
error: Error,
params: {
commands: AssistantTransportCommand[];
updateState: (updater: (state: T) => T) => void;
},
) => void | Promise<void>onCancel?: (params: {
commands: AssistantTransportCommand[];
updateState: (updater: (state: T) => T) => void;
error?: Error;
}) => voidCalled when commands are cancelled. When an error occurs, queued commands are automatically cancelled after `onError` settles. In this case, the `error` parameter contains the error that caused the cancellation.
capabilities?: AssistantTransportOptions["capabilities"]edit?: booleanadapters?: AssistantTransportOptions["adapters"]attachments?: AttachmentAdapteraccept: stringadd: (state: { file: File; }) => Promise<PendingAttachment> | AsyncGenerator<PendingAttachment, void>remove: (attachment: Attachment) => Promise<void>send: (attachment: PendingAttachment) => Promise<CompleteAttachment>history?: ThreadHistoryAdapterload: () => Promise<ExportedMessageRepository & { unstable_resume?: boolean; }>resume?: (options: ChatModelRunOptions) => AsyncGenerator<ChatModelRunResult, void, unknown>append: (item: ExportedMessageRepositoryItem) => Promise<void>withFormat?: <TMessage, TStorageFormat extends Record<string, unknown>>(formatAdapter: MessageFormatAdapter<TMessage, TStorageFormat>) => GenericThreadHistoryAdapter<TMessage>Required when used with `useAISDKRuntime` / `useChatRuntime`.
useAssistantTransportSendCommand
const useAssistantTransportSendCommand: () => (command: AssistantTransportCommand) => void;useAssistantTransportState
function useAssistantTransportState(): UserExternalState;