intentkit-websocket
v1.2.0
Published
WebSocket bridge for real-time IntentKit function calls
Downloads
99
Maintainers
Readme
intentkit-websocket
WebSocket bridge for real-time IntentKit function calls. Allows clients to execute IntentKit functions over persistent WebSocket connections.
Install
npm install intentkit-websocket intentkitUsage
import { IntentRegistry, createContext } from 'intentkit';
import { startWebSocketBridge } from 'intentkit-websocket';
const registry = new IntentRegistry().register(/* your functions */);
const context = await createContext({ dbPath: './data.db' });
const handle = await startWebSocketBridge({
registry,
context,
roles: { admin: ['*'] },
defaultRole: 'admin',
port: 3400,
});
console.log(`WebSocket at ${handle.url}`);Protocol
Request
{
"id": 1,
"function": "create_task",
"args": { "title": "Ship v2", "status": "todo" },
"role": "admin"
}Success Response
{
"id": 1,
"success": true,
"result": { "id": 5, "title": "Ship v2", "status": "todo" }
}Error Response
{
"id": 1,
"success": false,
"error": { "code": "NOT_FOUND", "message": "Function \"unknown\" not found" }
}The id field is optional and echoed back for request/response correlation.
License
MIT
