createPaiSocketIoClient()
Socket.IO AgentClient for createPaiSocketIoServer.
import { createPaiSocketIoClient } from "@pai/client-socketio";
const paiClient = createPaiSocketIoClient({
url: "http://localhost:3001/api/pai",
socketUrl: "http://localhost:3001/pai",
headers: () => ({
"x-user-id": "dev-user",
"x-workspace-id": "dev",
}),
});
const assistant = paiClient.agent("main");url is the HTTP receiver mount. socketUrl is the Socket.IO namespace (default server namespace /pai).
Import
import { createPaiSocketIoClient } from "@pai/client-socketio";Signature
function createPaiSocketIoClient(
options: PaiSocketIoClientOptions,
): PaiSocketIoClient;Parameters
options: PaiSocketIoClientOptions
HTTP client options plus Socket.IO. url is required.
url: string
HTTP receiver mount, same as createPaiHttpClient().
socketUrl: string
Socket.IO namespace URL, for example /pai on the current origin.
headers?: HeadersInit | (() => HeadersInit)
credentials?: RequestCredentials
fetch?: typeof fetch
telemetry?: { serializeContext?(): Record<string, string> }
logger?: PaiLogger | false
logLevel?: "debug" | "info" | "warn" | "error"
socketOptions?: PaiSocketIoOptions
Native manager/socket options. Set path when the Engine.IO path is
not /socket.io.
Returns
A PaiSocketIoClient.
.agent(id) matches createPaiHttpClient().