All packages
npm Packages

@cognitiondesk/clientv0.2.0

Lightweight command SDK for assistants, workflows and tasks — no widget UI dependencies.

View on npm backendUrl → api.cognitiondesk.com (default)

Install

Shell
npm install @cognitiondesk/client

Quickstart

Run 2026-09-25 against api.cognitiondesk.com with a throwaway API key and assistant (both deleted after).

JavaScript
import { createCognitionDeskClient } from '@cognitiondesk/client';

// backendUrl is OPTIONAL since 0.2.0: without it, this only ever talks to
// https://api.cognitiondesk.com (DEFAULT_COGNITIONDESK_BACKEND in the
// source). Pass it only if you're talking to a different backend
// (self-hosted, staging).
const client = createCognitionDeskClient({
  apiKey: process.env.COGNITIONDESK_API_KEY,
});

// Run 2026-09-25 against api.cognitiondesk.com with a throwaway key —
// returned exactly the requested text:
const text = await client.invokeAssistantText({
  assistantId: 'YOUR_ASSISTANT_ID',
  prompt: 'Reply with exactly: hello from client test',
  userContext: { platform: 'my-app', conversationId: 'conv-1' },
});
console.log(text); // -> "hello from client test"

API keys vs. Firebase tokens

JavaScript
// "Runtime" methods (invokeAssistant*, streamAssistantEvents, clearThread)
// accept EITHER an API key or a Firebase token.
//
// "Command" methods (assistants.list, getAssistant, patchAssistant,
// workflows.*, tasks.*) ALWAYS require a Firebase token — an API key alone
// gets 403. Verified live: invokeAssistantText with apiKey worked;
// getAssistant with the same key returned 403 "No token provided.".
const withFirebase = createCognitionDeskClient({
  getAuthToken: async () => firebaseAuth.currentUser.getIdToken(),
});
const assistants = await withFirebase.listAssistants();

API

invokeAssistant / invokeAssistantText / invokeAssistantStream / streamAssistantEventsRun the assistant runtime from code, no widget UI. API key or Firebase token.
clearThread(threadId, opts)Reset a conversation thread.
listAssistants / getAssistant / createAssistant / patchAssistant"Command" calls — Firebase token only.
executeCommand(name, params)Raw command execution for anything not wrapped above.
@cognitiondesk/client — CognitionDesk Docs