packages/server-sdk/README.md
The SDK for cliet-side code to connect to the server-side components.
ni @proj-airi/server-sdk -D # from @antfu/ni, can be installed via `npm i -g @antfu/ni`
pnpm i @proj-airi/server-sdk -D
yarn i @proj-airi/server-sdk -D
npm i @proj-airi/server-sdk -D
import { Client } from '@proj-airi/server-sdk'
const client = new Client({
name: 'your airi plugin',
autoConnect: false,
})
await client.connect()
client.onEvent('input:text', async (event) => {
console.info(event.data.text)
})
connect() now resolves when the client is fully ready for use, not just when the websocket transport has opened. In practice that means:
Useful runtime helpers:
client.connectionStatus exposes the current lifecycle stateclient.isReady tells you whether the client has completed authentication + announceclient.send() returns false instead of silently dropping messages when the socket is unavailableclient.sendOrThrow() is available when you want strict delivery semanticsclient.onEvent() returns an unsubscribe function