@kernl-sdk/protocol
For AI agents: These reference docs help coding agents understand the kernl SDK. If your agent gets stuck, share this page with it.
Standard interfaces and types for AI model providers and realtime communication.
Language Models
Type-safe interfaces for chat completion APIs:
import type { LanguageModel, LanguageModelMessage } from '@kernl-sdk/protocol';
const messages: LanguageModelMessage[] = [
{ role: 'system', content: 'You are a helpful assistant.' },
{ role: 'user', content: 'Hello!' },
];Embedding Models
Interfaces for text embedding APIs:
import type { EmbeddingModel, EmbeddingResult } from '@kernl-sdk/protocol';Realtime
Protocol types for voice/streaming communication:
import type {
RealtimeClientEvent,
RealtimeServerEvent,
SessionConfig,
} from '@kernl-sdk/protocol';Standard interfaces and types for AI model providers.
Classes
| Class | Description |
|---|---|
| RealtimeError | Error from a realtime session. |
Interfaces
| Interface | Description |
|---|---|
| AbortEvent | Stream event indicating the agent execution was aborted. |
| ActivityEndEvent | Client event to signal end of user activity (manual VAD). |
| ActivityStartEvent | Client event to signal start of user activity (manual VAD). |
| AssistantMessage | - |
| AudioConfig | Audio format configuration for input and output. |
| AudioFormat | Audio format specification. |
| AudioInputAppendEvent | Client event to append audio to the input buffer. |
| AudioInputClearedEvent | Server event confirming the audio input buffer has been cleared. |
| AudioInputClearEvent | Client event to clear the audio input buffer. |
| AudioInputCommitEvent | Client event to commit the audio input buffer as a user message. |
| AudioInputCommittedEvent | Server event confirming the audio input buffer has been committed. |
| AudioOutputDeltaEvent | Server event containing an audio output chunk. |
| AudioOutputDoneEvent | Server event indicating audio output is complete. |
| DataPart | Represents a structured data segment (e.g., JSON) within a message or artifact. |
| EmbeddingModel | Embedding model interface. |
| EmbeddingModelRequest | - |
| EmbeddingModelRequestSettings | - |
| EmbeddingModelResponse | The response from an embedding model. |
| EmbeddingModelUsage | Usage information for an embedding model call. |
| ErrorEvent | Stream event indicating an error occurred during execution. |
| FilePartWithData | A file with inline data (base64 string or binary). |
| FilePartWithUri | A file referenced by URI. |
| FinishEvent | Stream event indicating the completion of agent execution. |
| ItemCreatedEvent | Server event indicating an item has been added to the conversation. |
| ItemCreateEvent | Client event to add an item to the conversation. |
| ItemDeletedEvent | Server event indicating an item has been deleted. |
| ItemDeleteEvent | Client event to delete an item from the conversation. |
| ItemTruncatedEvent | Server event indicating an item has been truncated. |
| ItemTruncateEvent | Client event to truncate assistant audio at a specific timestamp. |
| LanguageModel | Defines the standard interface for language model providers in kernl. |
| LanguageModelFinishReason | Reason why a language model finished generating a response. |
| LanguageModelItemBase | Shared base for language model items. |
| LanguageModelRequest | A request to a large language model. |
| LanguageModelRequestSettings | Settings to use when calling an LLM. |
| LanguageModelResponse | The base response interface for a language model. |
| LanguageModelResponseJSON | JSON response format. |
| LanguageModelResponseText | Text response format. |
| LanguageModelUsage | Usage information for a language model call. |
| MessageBase | - |
| ModelSettingsText | - |
| PartBase | Defines base properties common to all message or artifact parts. |
| Provider | Provider for language, text embedding, and image generation models. |
| RawEvent | Stream event containing raw provider-specific data. |
| RealtimeAuthenticateOptions | Options for authenticating with a realtime provider. |
| RealtimeChannel | Base interface for audio I/O channels. |
| RealtimeConnection | An active bidirectional connection to a realtime model. |
| RealtimeConnectOptions | - |
| RealtimeEventBase | Base interface for all realtime events. |
| RealtimeModel | A realtime model that can establish bidirectional streaming connections. |
| RealtimeResponseConfig | Configuration for creating a response (for response.create event). |
| RealtimeSession | A realtime session as returned from the server. |
| RealtimeSessionConfig | Configuration for a realtime session. |
| RealtimeTransport | A transport factory for custom connection mechanisms (e.g., WebRTC). |
| RealtimeUsage | Token usage information for a response. |
| Reasoning | Reasoning that the model has generated. |
| ReasoningDeltaEvent | Stream event containing a delta (chunk) of reasoning output. |
| ReasoningEndEvent | Stream event indicating the end of reasoning output. |
| ReasoningStartEvent | Stream event indicating the start of reasoning output. |
| ResponseCancelEvent | Client event to cancel an in-progress response. |
| ResponseCreatedEvent | Server event indicating a response has been created. |
| ResponseCreateEvent | Client event to trigger a model response. |
| ResponseDoneEvent | Server event indicating a response is complete. |
| ResponseInterruptedEvent | Server event indicating a response has been interrupted. |
| SessionCreatedEvent | Server event indicating the session has been created. |
| SessionErrorEvent | Server event indicating a session error. |
| SessionResumeConfig | Configuration for resuming a previous session. |
| SessionUpdatedEvent | Server event indicating the session configuration has been updated. |
| SessionUpdateEvent | Client event to update session configuration. |
| SharedBase | - |
| SpeechStartedEvent | Server event indicating speech has been detected (VAD). |
| SpeechStoppedEvent | Server event indicating speech has stopped (VAD). |
| StartEvent | Stream event indicating the start of agent execution. |
| StreamEventBase | Base interface for all stream events. |
| SystemMessage | - |
| TextDeltaEvent | Stream event containing a delta (chunk) of text output. |
| TextEndEvent | Stream event indicating the end of a text output. |
| TextOutputDeltaEvent | Server event containing a text output chunk. |
| TextOutputEvent | Server event containing the complete text output. |
| TextPart | Text that the model has generated. |
| TextStartEvent | Stream event indicating the start of a text output. |
| ToolCall | Tool calls that the model has generated. |
| ToolCallEvent | Server event indicating the model wants to call a tool. |
| ToolCancelledEvent | Server event indicating a tool call has been cancelled. |
| ToolDeltaEvent | Server event containing a tool call arguments chunk. |
| ToolInputDeltaEvent | Stream event containing a delta (chunk) of tool input. |
| ToolInputEndEvent | Stream event indicating the end of tool input generation. |
| ToolInputStartEvent | Stream event indicating the start of tool input generation. |
| ToolResult | Result of a tool call that has been executed by the provider. |
| ToolResultEvent | Client event to submit a tool result. |
| ToolStartEvent | Server event indicating a tool call has started. |
| TranscriptInputDeltaEvent | Server event containing an input transcription chunk. |
| TranscriptInputEvent | Server event containing the complete input transcription. |
| TranscriptOutputDeltaEvent | Server event containing an output transcription chunk. |
| TranscriptOutputEvent | Server event containing the complete output transcription. |
| TurnDetectionConfig | Turn detection / VAD configuration. |
| UserMessage | - |
| VoiceConfig | Voice configuration for audio output. |
| WebSocketLike | Minimal WebSocket interface matching the standard WebSocket API. |
Type Aliases
| Type Alias | Description |
|---|---|
| ClientCredential | A client credential for browser-based realtime connections. |
| Embedding | An embedding is a vector, i.e. an array of numbers. It is e.g. used to represent a text as a vector of word embeddings. |
| FilePart | A file that has been generated by the model or referenced by URI. |
| JSONArray | - |
| JSONObject | - |
| JSONValue | A JSON value can be a string, number, boolean, object, array, or null. JSON values can be serialized and deserialized by the JSON.stringify and JSON.parse methods. |
| LanguageModelFunctionTool | A tool has a name, a description, and a set of parameters. |
| LanguageModelItem | - |
| LanguageModelProviderTool | The configuration of a tool that is defined by the provider. |
| LanguageModelResponseItem | A subset of LanguageModelItem that excludes items that wouldn't make sense for a model to generate (e.g. system/user messages, tool results). |
| LanguageModelResponseType | Response format specification for language model output. |
| LanguageModelStreamEvent | Union of all language model stream events. |
| LanguageModelTool | - |
| LanguageModelToolChoice | - |
| Message | - |
| MessagePart | - |
| ModelSettingsReasoning | Configuration options for model reasoning |
| ModelSettingsReasoningEffort | Constrains effort on reasoning for reasoning models. |
| RealtimeChannelEvents | Events emitted by a realtime channel. |
| RealtimeClientEvent | Union of all client → server events. |
| RealtimeConnectionEvents | Events emitted by a realtime connection. |
| RealtimeModality | Output modality for realtime sessions. |
| RealtimeServerEvent | Union of all server → client events. |
| RealtimeToolChoice | Tool choice behavior for realtime sessions. |
| ResponseStatus | Status of a response. |
| SharedProviderMetadata | Additional provider-specific metadata. |
| SharedProviderOptions | - |
| SharedWarning | Warning from the model provider for this call. The call will proceed, but e.g. some settings might not be supported, which can lead to suboptimal results. |
| ToolCallState | State of a tool call execution. |
| TransportStatus | Status of a realtime transport connection. |
| WebSocketConstructor | WebSocket constructor type for cross-platform compatibility. |
Variables
| Variable | Description |
|---|---|
| COMPLETED | - |
| DEAD | Task is being removed from the system. Final cleanup in progress, about to be fully deleted. |
| FAILED | - |
| IN_PROGRESS | Protocol Constants |
| INTERRUPTIBLE | Task is sleeping/blocked, waiting for a condition. Can be woken up by: - The condition being met (e.g., approval granted) - A signal (e.g., user cancellation) |
| RUNNING | Task is either: - Currently executing - In run queue waiting to be scheduled (might want to differentiate between running + queued here) |
| STOPPED | Task has been stopped by a signal (SIGSTOP). Will remain stopped until explicitly continued (SIGCONT). |
| UNINTERRUPTIBLE | Task is sleeping/blocked and CANNOT be interrupted by signals. Only wakes when the condition is met. |
| WS_CLOSED | - |
| WS_CLOSING | - |
| WS_CONNECTING | - |
| WS_OPEN | - |
| ZOMBIE | Task has finished execution but hasn't been cleaned up yet. Waiting for parent to read exit status (wait/waitpid). |