npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@synerise/ai-assistant-core

v0.2.0

Published

Core component and API helpers for embedding the Synerise AI Assistant in Preact applications.

Downloads

430

Readme

@synerise/ai-assistant-core

Core component and API helpers for embedding the Synerise AI Assistant in Preact applications.


Requirements

This package is designed for the Synerise platform. To use it you need:

  • An active Synerise tenant and a tracker key
  • Network access to https://api.synerise.com (or your custom Synerise API endpoint)
  • Preact 10 in your application

If you don't have a Synerise account, visit synerise.com.


Which package do I need?

| Your stack | Package | | --- | --- | | Vanilla JS / no bundler / <script> tag | @synerise/ai-assistant-sdk | | React 18 | @synerise/ai-assistant-react | | Preact | @synerise/ai-assistant-core (this package) | | Build a custom chat UI from primitives | @synerise/ai-assistant-ui |

How packages relate

@synerise/ai-assistant-core  ──>  @synerise/ai-assistant-ui

core provides the high-level AIAssistant component with chat lifecycle, API integration, error handling, streaming, etc. ui provides only visual primitives.


Installation

npm install @synerise/ai-assistant-core preact
# or
pnpm add @synerise/ai-assistant-core preact
# or
yarn add @synerise/ai-assistant-core preact

Peer dependencies

  • preact ^10.26.9

What this package provides

  • AIAssistant — Preact component with built-in chat lifecycle handling
  • assistantApi — direct API helpers (initChat, sendChatMessage, getChatMessages)
  • Constants — message types, chat states, error types, operation types
  • Errors — typed ApiError and NetworkError classes
  • Re-exports from @synerise/ai-assistant-uiBaseChat, Icon, action/message constants, theme types

Quick start

import { AIAssistant } from "@synerise/ai-assistant-core";

export function SupportChat() {
  return (
    <AIAssistant
      apiUrl="https://api.synerise.com/gen-ai/v3/ai-assistant"
      context={{ profileId: "user-123" }}
      additionalContextValues={{ segment: "premium" }}
      displayMode="bordered"
      onPromptSuccess={(response) => {
        console.log("threadId:", response.meta.threadId);
      }}
      onCustomAction={({ actionName, params }) => {
        console.log("custom action:", actionName, params);
      }}
    />
  );
}

Important props

| Prop | Type | Description | | --- | --- | --- | | apiUrl | string | Base assistant API URL | | context | Context | Per-request context object | | additionalContextValues | AdditionalContextValues | Per-request metadata | | displayMode | "drawer" \| "bordered" | UI layout | | onPromptSuccess | (response) => void | Required. Called after init/message response | | onCustomAction | ({ actionName, params }) => void | Called when the assistant emits a custom action | | threadId | string | If provided, loads an existing conversation | | stream | boolean | Enables SSE mode (text/event-stream) | | fastMode | boolean | Appends fastMode=true query param | | authParams | { code, clientUUID } | Auth payload (alternative to XSRF cookie auth) | | disableXSRFToken | boolean | Skip XSRF token header in fetch calls |


Conversation flow

   ┌──────────┐  initChat()    ┌─────────────┐
   │  init    ├───────────────>│  threadId   │
   └──────────┘                └──────┬──────┘
                                      │
   ┌──────────┐  sendChatMessage()    │
   │  user    ├───────────────────────┤
   │  message │                       │
   └──────────┘                       │
                                      v
                            ┌─────────────────┐
                            │  assistant      │
                            │  response       │
                            │  (POST or SSE)  │
                            └─────────┬───────┘
                                      v
                          onPromptSuccess(response)

AIAssistant orchestrates the entire flow internally. Use assistantApi directly only if you need custom UX (e.g. headless integration).


Direct API usage

import { assistantApi } from "@synerise/ai-assistant-core";

const initResponse = await assistantApi.initChat({
  apiUrl: "https://api.synerise.com/gen-ai/v3/ai-assistant",
  context: { profileId: "user-123" },
  additionalContextValues: { segment: "premium" },
  message: null,
});

const threadId = initResponse?.meta.threadId;

if (threadId) {
  const response = await assistantApi.sendChatMessage({
    apiUrl: "https://api.synerise.com/gen-ai/v3/ai-assistant",
    threadId,
    message: "Show me products for trail running",
    context: { profileId: "user-123" },
    additionalContextValues: { segment: "premium" },
  });

  console.log(response.data.messages);
}

Error handling

import { ApiError, NetworkError, AI_ASSISTANT_ERROR_TYPE } from "@synerise/ai-assistant-core";

try {
  await assistantApi.initChat({ /* ... */ });
} catch (error) {
  if (error instanceof ApiError) {
    console.error("API error:", error.body.errorCode, error.body.message);
    console.error("trace id:", error.body.traceId);
  } else if (error instanceof NetworkError) {
    console.error("Network error — check connectivity");
  }
}

AI_ASSISTANT_ERROR_TYPE enumerates the error types surfaced by the chat component callbacks.


Exports

  • AIAssistant
  • assistantApi (initChat, sendChatMessage, getChatMessages)
  • BaseChat, Icon (re-exported from @synerise/ai-assistant-ui)
  • AI_ASSISTANT_MESSAGE_ELEMENT_TYPE, AI_ASSISTANT_MESSAGE_TYPE, AI_ASSISTANT_ERROR_TYPE, AI_ASSISTANT_OPERATION, CHAT_STATE, CHAT_ACTION_TYPE, CHAT_MESSAGE_TYPE
  • ApiError, NetworkError
  • TypeScript types from AIAssistant.types

Troubleshooting

  • document is not defined — this package is browser-only (uses cookies, fetch, DOM). Render only on the client in SSR frameworks.
  • 401 / 403 from API — verify your tracker key, that apiUrl matches your tenant, and that disableXSRFToken matches your tenant's auth flow.
  • CORS errors — your tenant must allow your origin. Contact Synerise support.
  • Using from React — install @synerise/ai-assistant-react instead, which provides a typed React wrapper.

Support

For technical and licensing inquiries: [email protected].

License

Proprietary. See LICENSE.