fluidsoul

SDK Reference

TypeScript/JavaScript SDK for fluidsoul — sendEvent, refreshContext, getContext.

SDK Reference

The fluidsoul-js package provides a TypeScript/JavaScript client for the fluidsoul API. Works in any environment with the Fetch API: browsers, Node.js 18+, Electron, VS Code extensions, Figma plugins.

Installation

npm install fluidsoul-js

Configuration

import type { FluidsoulConfig } from "fluidsoul-js"

const config: FluidsoulConfig = {
  apiUrl: process.env.FLUIDSOUL_API_URL!,
  token: process.env.FLUIDSOUL_API_TOKEN!,
  workspaceId: process.env.FLUIDSOUL_WORKSPACE_ID!,
}

Core functions

sendEvent

Record a user action event. Call this whenever a user does something meaningful.

import { sendEvent } from "fluidsoul-js"

await sendEvent(config, {
  userId: "user_123",
  eventType: "report_viewed",
  metadata: { category: "analytics" },
})

refreshContext

Trigger a context recomputation for a user.

import { refreshContext } from "fluidsoul-js"

await refreshContext(config, "user_123")

getContext

Fetch the current computed context for a user. Returns null if no context exists.

import { getContext } from "fluidsoul-js"

const ctx = await getContext(config, "user_123")

if (ctx) {
  console.log(ctx.user_category)       // e.g. "analyst"
  console.log(ctx.preferred_mode)       // e.g. "analyst"
  console.log(ctx.feature_priorities)   // e.g. ["reports", "analytics"]
  console.log(ctx.recommended_defaults) // e.g. { default_view: "reports" }
  console.log(ctx.engagement_level)     // "low" | "moderate" | "high"
  console.log(ctx.user_maturity)        // "new" | "intermediate" | "power_user"
}

Types

FluidsoulConfig

FieldTypeDescription
apiUrlstringAPI server URL
tokenstringBearer token
workspaceIdstringWorkspace UUID

UserContext

FieldTypeDescription
user_categorystringClassification result
preferred_modestringDominant dimension value
feature_prioritiesstring[]Features ordered by relevance
recommended_defaultsRecord<string, string>Suggested default settings
engagement_levelstring"low" / "moderate" / "high"
user_maturitystring"new" / "intermediate" / "power_user"
confidence_scoresRecord<string, number>Confidence per inference
explainabilitystring[]Plain-English reasons
user_narrativestring | nullOptional LLM narrative
inference_sourcestring"rules" or "rules+llm"

SendEventInput

FieldTypeRequiredDescription
userIdstringYesUser identifier
eventTypestringYesWhat the user did
metadataRecord<string, unknown>NoExtra details

FluidsoulError

Thrown when an API call fails. Includes status, endpoint, and body.

Error handling

import { FluidsoulError } from "fluidsoul-js"

try {
  await sendEvent(config, input)
} catch (err) {
  if (err instanceof FluidsoulError) {
    console.error(`API error ${err.status}: ${err.message}`)
  }
}

On this page