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

@octavus/client-sdk

v1.0.0

Published

Framework-agnostic client SDK for Octavus agents

Readme

@octavus/client-sdk

Framework-agnostic client SDK for Octavus agents.

Installation

npm install @octavus/client-sdk

Overview

This package provides a framework-agnostic client for streaming Octavus agent responses. It handles message state management, streaming events, and transport abstraction.

For React applications, use @octavus/react instead—it provides React hooks that wrap this SDK.

Quick Start

import { OctavusChat, createHttpTransport } from '@octavus/client-sdk';

// Create transport
const transport = createHttpTransport({
  triggerRequest: (triggerName, input, options) =>
    fetch('/api/octavus', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ sessionId, triggerName, input }),
      signal: options?.signal,
    }),
});

// Create chat client
const chat = new OctavusChat({ transport });

// Subscribe to state changes
const unsubscribe = chat.subscribe(() => {
  console.log('Messages:', chat.messages);
  console.log('Status:', chat.status);
});

// Send a message
await chat.send('user-message', { USER_MESSAGE: 'Hello!' }, { userMessage: { content: 'Hello!' } });

// Cleanup
unsubscribe();

Transports

HTTP Transport (SSE)

Best for Next.js, Express, and HTTP-based applications:

import { createHttpTransport } from '@octavus/client-sdk';

const transport = createHttpTransport({
  triggerRequest: (triggerName, input, options) =>
    fetch('/api/octavus', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ sessionId, triggerName, input }),
      signal: options?.signal,
    }),
});

Socket Transport (WebSocket/SockJS)

Best for real-time applications with persistent connections:

import { createSocketTransport } from '@octavus/client-sdk';

const transport = createSocketTransport({
  connect: () =>
    new Promise((resolve, reject) => {
      const ws = new WebSocket(`wss://api.example.com/stream?sessionId=${sessionId}`);
      ws.onopen = () => resolve(ws);
      ws.onerror = () => reject(new Error('Connection failed'));
    }),
});

// Optional: eagerly connect and monitor state
transport.onConnectionStateChange((state, error) => {
  console.log('Connection state:', state);
});
await transport.connect();

Chat Client

Creating a Chat Instance

const chat = new OctavusChat({
  transport,
  initialMessages: [], // Optional: restore from server
  onError: (error) => console.error(error),
  onFinish: () => console.log('Done'),
  onResourceUpdate: (name, value) => console.log(`Resource ${name}:`, value),
});

Sending Messages

// Text message
await chat.send('user-message', { USER_MESSAGE: message }, { userMessage: { content: message } });

// With file attachments
await chat.send(
  'user-message',
  { USER_MESSAGE: message, FILES: fileRefs },
  { userMessage: { content: message, files: fileRefs } },
);

State Properties

chat.messages; // UIMessage[] - all messages
chat.status; // 'idle' | 'streaming' | 'error'
chat.error; // OctavusError | null

Stopping Generation

chat.stop(); // Stops streaming and finalizes partial content

File Uploads

// Upload files separately (for progress tracking)
const fileRefs = await chat.uploadFiles(fileInput.files, (index, progress) => {
  console.log(`File ${index}: ${progress}%`);
});

// Use the references in a message
await chat.send('user-message', { FILES: fileRefs }, { userMessage: { files: fileRefs } });

Note: File uploads require configuring requestUploadUrls in the chat options.

Message Types

Messages contain ordered parts with typed content:

type UIMessagePart =
  | UITextPart // Text content with streaming status
  | UIReasoningPart // Model reasoning/thinking content
  | UIToolCallPart // Tool call with args, result, and status
  | UIOperationPart // Internal operations (e.g., set-resource)
  | UISourcePart // URL or document sources
  | UIFilePart // File attachments (uploaded or generated)
  | UIObjectPart; // Structured output objects

Each part includes a type discriminator and relevant fields. See TypeScript types for full field definitions.

Error Handling

Errors are structured with type classification:

import { isRateLimitError, isAuthenticationError } from '@octavus/client-sdk';

const chat = new OctavusChat({
  transport,
  onError: (error) => {
    if (isRateLimitError(error)) {
      showRetryButton(error.retryAfter);
    } else if (isAuthenticationError(error)) {
      redirectToLogin();
    }
  },
});

Re-exports

This package re-exports everything from @octavus/core, so you don't need to install it separately.

Related Packages

License

MIT