UNPKG

recallbricks-sdk

Version:

TypeScript SDK for writing memory chunks to RecallBricks persistent memory infrastructure.

37 lines (32 loc) 835 B
// recallbricks-sdk.ts export class RecallBricks { static async write({ userId, projectId, text, type, tags, baseUrl = process.env.RECALLBRICKS_BASE_URL, }: { userId: string; projectId: string; text: string; type: string; tags: string[]; baseUrl?: string; }) { if (!baseUrl) { throw new Error("❌ Missing RECALLBRICKS_BASE_URL in env or argument"); } const res = await fetch(`${baseUrl}/api/write`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ userId, projectId, text, type, tags }), }); if (!res.ok) { const errorText = await res.text(); throw new Error(`❌ Write failed: ${res.status} ${errorText}`); } return res.json(); } }