@rein-ai/client
v1.0.0
Published
Client SDK for connecting to a rein server
Readme
@rein-ai/client
Client SDK for connecting to a rein server. Works in Node.js and browsers.
Install
npm install @rein-ai/clientUsage
import { ReinClient } from "@rein-ai/client";
const client = new ReinClient("http://localhost:4800");
// Sessions
const sessions = await client.listSessions({ project: "myproject" });
const session = await client.createSession("my-session-id", { project: "myproject" });
const single = await client.getSession("my-session-id");
await client.deleteSession("my-session-id");
// Send commands
await client.sendPrompt("session-id", "fix the bug");
await client.sendAbort("session-id");
// Stream artifacts (SSE)
const stream = client.streamArtifacts("session-id");
stream.onSnapshot = (artifact) => console.log("history:", artifact);
stream.onCreated = (artifact) => console.log("new:", artifact);
stream.onUpdated = (seq, field, append, set) => console.log("update:", seq, field);
// ... later
stream.close();
// Stream session changes (SSE)
const sessions$ = client.streamSessions({ project: "myproject" });
sessions$.onSnapshot = (session) => console.log("session:", session);
sessions$.onCreated = (session) => console.log("new session:", session);
sessions$.onUpdated = (id, fields) => console.log("updated:", id, fields);
sessions$.onRemoved = (id) => console.log("removed:", id);
// ... later
sessions$.close();API
new ReinClient(baseUrl: string)
Create a client targeting the specified rein server.
Session Management
listSessions(filter?)— List sessions, optionally filtered by projectcreateSession(id, options?)— Create a session with optional projectgetSession(id)— Get a session by ID (returnsnullif not found)deleteSession(id)— Delete a session
Commands
sendPrompt(sessionId, text)— Send a prompt to a sessionsendAbort(sessionId)— Abort the current operation
Streaming
streamArtifacts(sessionId, options?)— SSE stream of artifact events (onSnapshot,onCreated,onUpdated)streamSessions(filter?)— SSE stream of session lifecycle events (onSnapshot,onCreated,onUpdated,onRemoved)
Both return objects with a close() method to disconnect.
