Types
A guided tour through every type users typically touch. For full mechanical signatures see Generated API.
Connection
ConnectionStatus
type ConnectionStatus = 'disconnected' | 'connecting' | 'connected';Emitted on the status event and returned by client.getStatus().
AutopilotClientOptions
interface AutopilotClientOptions {
conversationUrl: string;
transports?: ('websocket' | 'polling')[];
reconnection?: boolean;
reconnectionAttempts?: number;
reconnectionDelay?: number;
}Passed to client.connect(). Only conversationUrl is required. See Connection.
Functions
AutopilotFunctionDefinition<TArgs, TResult>
interface AutopilotFunctionDefinition<TArgs = unknown, TResult = unknown> {
name: string;
description?: string;
parameters?: Record<string, unknown>; // JSON Schema
handler: (
args: TArgs,
context: AutopilotFunctionInvocationContext,
) => TResult | Promise<TResult>;
sensitive?: boolean; // require user confirmation before each call
}Argument to registerFunction. parameters is JSON Schema. When sensitive is true the call is routed through the ConfirmationHandler registered via setConfirmationHandler; see Sensitive functions.
AutopilotFunctionInvocationContext
interface AutopilotFunctionInvocationContext {
id: string;
name: string;
timestamp?: number;
}Passed as the second argument to your handler. id matches the call's id in functionCallBegin / functionCallEnd events.
AutopilotFunctionDescriptor
interface AutopilotFunctionDescriptor {
name: string;
description?: string;
parameters?: Record<string, unknown>;
source: 'client';
}The server-facing view of a registered function. Returned by getRegisteredFunctions() and stored in store.registeredFunctions.
AutopilotFunctionCallRequest<TArgs>
interface AutopilotFunctionCallRequest<TArgs = unknown> {
id: string;
name: string;
arguments: TArgs;
timestamp?: number;
}Payload of the functionCall / functionSuccess / functionError events.
ConfirmationDecision
type ConfirmationDecision = 'allow' | 'deny';ConfirmationRequest
interface ConfirmationRequest {
id: string; // mirrors the call request id
name: string;
arguments: unknown;
timestamp?: number;
}The argument passed to a ConfirmationHandler.
ConfirmationHandler
type ConfirmationHandler = (
request: ConfirmationRequest,
) => Promise<ConfirmationDecision> | ConfirmationDecision;Registered via client.setConfirmationHandler(handler). If no handler is set, sensitive calls are denied automatically; if the handler throws, the rejection is treated as a deny.
Context
AutopilotContextState
interface AutopilotContextState {
[key: string]: unknown;
}Free-form, syncs as JSON Patches at /autopilot/context. See Context.
Conversation
Conversation
interface Conversation {
token: string;
app_key: string;
user_id: number | null;
vendor_id: number;
vendor_app_id: number;
vendor_client_id: number | null;
vendor_channel: string | null;
parameters: object;
created_at: string;
modified_at: string | null;
api_path: string;
relay_url: string;
relay_path: string;
}Returned by getConversation(). relay_url and relay_path are what the client connects to over Socket.IO.
ConversationMessage
interface ConversationMessage {
role: string; // 'user' | 'assistant' | 'system' | 'error' | …
creator: string;
message: string;
has_been_modified?: boolean;
created_at?: string;
function_calls?: FunctionCall[];
function_response?: string | null;
versions?: ConversationMessageVersion[];
}The role field is not typed as a union because the server can introduce new roles. The bar treats anything that is not user/assistant/error as a tool/system message and hides it from visibleMessages.
FunctionCall
interface FunctionCall {
id: string;
name: string;
arguments: Record<string, any>;
result?: string | null;
status?: 'pending' | 'executing' | 'completed';
}Attached to ConversationMessage.function_calls for assistant messages that involve tool use.
ConversationResponse
interface ConversationResponse {
conversation: Conversation;
data: ConversationMessage[];
meta?: unknown;
pending_ask_user?: AskUserPrompt[];
}Shape returned by fetchConversation() and interactWithConversation(). pending_ask_user is present when the server is suspended waiting for the user to answer one or more structured questions (see Ask user).
AskUserPrompt
type AskUserPromptType = 'text' | 'bool' | 'radiolist' | 'checklist';
interface AskUserOption { value: string; label: string }
interface AskUserPrompt {
id: string;
type: AskUserPromptType;
question: string;
arguments?: {
yes_label?: string; no_label?: string; // bool
placeholder?: string; multiline?: boolean; // text
options?: AskUserOption[]; // radiolist / checklist
};
}
// Answer value per type: text/radiolist → string, bool → boolean, checklist → string[]
type AskUserResult = string | boolean | string[];
interface AskUserResponseItem { id: string; result: AskUserResult }Posted back via respondToAskUser(responses).
Events
AutopilotClientEvents
A 23-key interface mapping every event name to its payload type. See Events for the full catalog. The on/once/off API is typed against this interface:
client.on('messageAdded', ({ message, index }) => {
// message: ConversationMessage, index: number — inferred from AutopilotClientEvents.messageAdded
});