@neta-art/cohub
v1.10.2
Published
Cohub SDK for spaces, sessions, checkpoints, and realtime agent collaboration.
Readme
@neta-art/cohub
Cohub SDK for interacting with spaces, sessions, checkpoints, and realtime agent collaboration.
Install
npm install @neta-art/cohubQuick start
import { createCohubClient } from "@neta-art/cohub";
import type { ContentBlock } from "@neta-art/cohub";
const client = createCohubClient({
getAccessToken: async () => localStorage.getItem("token"),
});
const content: ContentBlock[] = [{ type: "text", text: "Hello" }];The SDK connects to production by default:
- API:
https://api.cohub.run - WebSocket:
wss://gateway.cohub.run/ws
Use development with ENV=dev in Node.js:
ENV=dev node app.jsOr select it explicitly in code:
const client = createCohubClient({
env: "dev",
getAccessToken: async () => localStorage.getItem("token"),
});Development uses:
- API:
https://api-dev.cohub.run - WebSocket:
wss://gateway-dev.cohub.run/ws
Custom endpoints are still supported when needed:
const client = createCohubClient({
baseUrl: "https://api.example.com",
getAccessToken: async () => localStorage.getItem("token"),
websocket: {
url: "https://gateway.example.com",
},
});Spaces and sessions
A Space is a live, isolated working environment where users and agents create together.
const created = await client.spaces.create({ name: "Demo" });
const space = client.space(created.space.id);
const sessionResult = await space.sessions.create({ title: "Planning" });
const session = space.session(sessionResult.session.id);
await session.messages.send({
content: [{ type: "text", text: "Help me plan the next steps" }],
});Session subscriptions
const stop = session.subscribe({
progress(event) {
console.log("progress", event.payload);
},
finalized(event) {
console.log("done", event.payload);
},
});
stop();