A lean TypeScript client for Node: typed messaging, reply waiting, and live events.
When you're ready to build on Minds: add this library to the server side of your project so your app can use your Minds. You keep shaping the product (screens, flows, what users see); your coding agent can wire up the connection in code using a clear, consistent interface instead of guessing at raw API calls.
humanId is resolved from your Builder API key automatically. Pass listMinds({ humanId }) when you need an explicit override.
Conversations
Bind a stable alias (e.g. main) to a Mind before messaging:
await client.ensureConversation("main", mindId);
ensureConversation is idempotent — if the alias already exists for that Mind, the existing conversation is returned.Lower-level helpers when you manage aliases yourself:
sendMessage requires alias and messageText. Optional attachments accept outbound objects — prefer a public HTTPS url with fileName and mimeType:
await client.sendMessage({ alias: "main", messageText: "Summarize this PDF in one sentence.", attachments: [ { url: "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf", fileName: "dummy.pdf", mimeType: "application/pdf", extension: "pdf", }, ],});
Image URLs use the same shape (mimeType: "image/png", etc.). Mind replies on getHistory, waitForReply, and SSE events may include inbound artifacts — for example:
// One attachment on a Mind reply (PDF; artifact body truncated){ artifactId: "7388b65d-144a-49ff-a4dc-cb7c23ded982", slug: "whale_watchtower_skill_artifact_1_0_5", logicalType: "document", mimeType: "application/pdf", extension: "pdf", artifact: "JVBERi0xLjQK...",}
Outbound send uses content for inline payloads; inbound replies use artifact for the same role. slug and logicalType are optional strings, treat values as hints, not a fixed enum. See the API reference for field details.getLatestHistoryFingerprint returns the fingerprint of the newest message — pass it as after on getHistory to fetch only newer rows, or as afterFingerprint before waitForReply so you spot replies that arrived after you sent.
for await (const event of client.eventsIterator({ alias: "main" })) { console.log(event.fingerprint, event.messageText);}
Pass signal on iterator or subscribe options to cancel when your process shuts down.
Errors
Failed HTTP calls throw MindsApiError with status, code, and message. Map 401/403 to a missing or revoked Builder API key; 429 may include retry guidance.