Connections
Connect KyroActor to your agent via WebSocket or LangChain.
A Connection is the interface between KyroActor and your AI agent. It handles sending messages and waiting for responses.
Connection interface
You can implement this interface for any transport layer. Kyro ships two built-in implementations.
WebSocketConnection
Connects to any WebSocket server that accepts plain text messages and replies in kind.
Install
Usage
Message format
By default, WebSocketConnection sends raw strings and expects raw string replies. If your WebSocket server uses JSON, wrap it with a custom connection:
LangChainConnection
Connects to any LangChain Runnable (chain, agent, or graph) using @langchain/core.
Install
@langchain/core is a peer dependency — install it in your project alongside @kyro/actor.
Usage
Custom connections
Implement the Connection interface directly for any other transport (HTTP, gRPC, etc.):