constella-sdk is not on npm yet. Until it is, call the HTTP routes (the client below is about 20 lines), or email us for the package.import { Constella } from "constella-sdk";
// Your own memory
const constella = new Constella({ key: process.env.CONSTELLA_API_KEY, client: "my-script" });
await constella.me.memory.add({ text: "We ship on Fridays.", id: "team:ship-day" });
const { sources } = await constella.me.memory.recall("when do we ship?");
// Your app's users
const app = new Constella({ key: process.env.CONSTELLA_APP_KEY });
await app.users("u_123").memory.add({ text: "Prefers short answers." });
Without the SDK
const API = "https://api.constella.app/platform/v1";
export async function callTool(name: string, args: Record<string, unknown>, uid?: string) {
const path = uid ? `/users/${encodeURIComponent(uid)}/tools/${name}` : `/me/tools/${name}`;
const res = await fetch(API + path, {
method: "POST",
headers: {
Authorization: `Bearer ${uid ? process.env.CONSTELLA_APP_KEY : process.env.CONSTELLA_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ arguments: args }),
});
const body = await res.json();
if (!res.ok) throw new Error(`${body.detail?.code}: ${body.detail?.message}`);
return body.result;
}