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

@aiassist-secure/core

v1.0.0

Published

AiAssist Secure TypeScript SDK - Framework-agnostic API client

Readme

@aiassist-secure/core

npm version TypeScript License: MIT

Framework-agnostic TypeScript SDK for AiAssist Secure - The enterprise AI orchestration platform with shadow mode, human-in-the-loop, and real-time typing indicators.

Works in Node.js 18+ and modern browsers.


Features

  • OpenAI-Compatible API - Drop-in replacement syntax
  • Shadow Mode - AI drafts require human approval before sending
  • Human-in-the-Loop - Seamless AI-to-human handoff detection
  • Typing Preview - Real-time "AI is typing..." indicators
  • Streaming - Server-sent events for token-by-token output
  • Managed Workspaces - Persistent conversation threads with context
  • Full TypeScript - Complete type definitions included

Installation

npm install @aiassist-secure/core
# or
yarn add @aiassist-secure/core
# or
pnpm add @aiassist-secure/core

Quick Start

import { AiAssistClient } from '@aiassist-secure/core';

const client = new AiAssistClient({ apiKey: 'aai_your_key' });

// Simple chat completion (OpenAI-compatible)
const response = await client.chat.completions.create({
  messages: [{ role: 'user', content: 'Hello!' }]
});

console.log(response.choices[0].message.content);

Streaming Responses

Get real-time token-by-token output:

const stream = await client.chat.completions.create({
  messages: [{ role: 'user', content: 'Write a haiku about coding' }],
  stream: true
});

for await (const chunk of stream) {
  const content = chunk.choices[0]?.delta?.content;
  if (content) {
    process.stdout.write(content); // Print each token as it arrives
  }
}

Managed Workspaces

Create persistent conversation threads with full context:

// Create a workspace with system prompt and context
const { workspace, messages } = await client.workspaces.create({
  clientId: 'user_123',
  initial_message: 'Hello!',
  system_prompt: 'You are a helpful customer support agent for Acme Inc.',
  context: {
    user_plan: 'enterprise',
    previous_tickets: 3
  }
});

console.log('Workspace ID:', workspace.id);
console.log('AI Response:', messages[0].content);

// Continue the conversation
const response = await client.workspaces.sendMessage(
  workspace.id,
  'I need help with my billing'
);

console.log('Mode:', response.mode); // 'ai' | 'shadow' | 'takeover'
console.log('Response:', response.responses[0].content);

// Get full conversation history
const history = await client.workspaces.getMessages(workspace.id);

Shadow Mode (Enterprise)

In shadow mode, AI drafts require manager approval before being sent to the client. Perfect for training, compliance, and quality assurance:

const response = await client.workspaces.sendMessage(workspace.id, 'Process my refund');

if (response.pending_approval) {
  console.log('AI drafted a response - awaiting manager approval');
  console.log('Draft:', response.responses[0].content);
  
  // The message won't be visible to the end-user until approved
  // Your manager dashboard can approve/reject/edit the draft
}

// Check workspace mode
console.log('Current mode:', response.mode);
// 'ai'      - Fully autonomous
// 'shadow'  - AI drafts, human approves  
// 'takeover' - Human control only

Human-in-the-Loop Detection

Detect when a human agent takes over the conversation:

const response = await client.workspaces.sendMessage(workspace.id, 'I want to speak to a human');

switch (response.mode) {
  case 'ai':
    console.log('AI is handling this conversation');
    break;
  case 'shadow':
    console.log('AI is drafting, but a human will review');
    break;
  case 'takeover':
    console.log('A human agent has taken control');
    // Update your UI to show "Speaking with Support Agent"
    break;
}

Typing Preview

Show real-time "AI is typing..." indicators in your UI:

// Poll for typing status (useful for chat UIs)
const status = await client.workspaces.getTypingStatus(workspace.id);

if (status.is_typing) {
  showTypingIndicator();
  console.log('AI is composing a response...');
} else {
  hideTypingIndicator();
}

End Conversation

Gracefully close conversations with optional feedback:

// End the conversation
await client.workspaces.endConversation(workspace.id);

// Or end with a reason/feedback
await client.workspaces.endConversation(workspace.id, {
  reason: 'resolved',
  feedback: 'Issue was resolved successfully'
});

Configuration Options

const client = new AiAssistClient({
  apiKey: 'aai_your_key',           // Required: Your API key
  baseURL: 'https://api.aiassist.net', // Custom endpoint
  timeout: 30000,                    // Request timeout (ms)
  maxRetries: 3,                     // Retry failed requests
  defaultHeaders: {                  // Custom headers
    'X-Custom-Header': 'value'
  }
});

Error Handling

Typed errors for precise error handling:

import {
  AiAssistClient,
  AuthenticationError,
  RateLimitError,
  APIError
} from '@aiassist-secure/core';

try {
  const response = await client.chat.completions.create({
    messages: [{ role: 'user', content: 'Hello' }]
  });
} catch (error) {
  if (error instanceof AuthenticationError) {
    console.error('Invalid API key - check your credentials');
  } else if (error instanceof RateLimitError) {
    console.error(`Rate limited. Retry after ${error.retryAfter} seconds`);
    // Implement exponential backoff
  } else if (error instanceof APIError) {
    console.error(`API error ${error.status}: ${error.message}`);
  }
}

List Available Models

const models = await client.models.list();

console.log('Available models:');
models.forEach(model => {
  console.log(`- ${model.id}: ${model.context_length} tokens`);
});

// Example output:
// - llama-3.3-70b-versatile: 128000 tokens
// - llama-3.1-8b-instant: 131072 tokens
// - mixtral-8x7b-32768: 32768 tokens

TypeScript Types

Full type definitions included:

import type {
  // Core types
  Message,
  ChatCompletion,
  ChatCompletionChunk,
  ChatCompletionCreateParams,
  
  // Workspace types
  Workspace,
  WorkspaceMessage,
  WorkspaceCreateParams,
  WorkspaceCreateResponse,
  SendMessageResponse,
  WorkspaceMode,        // 'ai' | 'shadow' | 'takeover'
  WorkspaceStatus,      // 'active' | 'ended'
  
  // Client types
  AiAssistClientOptions,
} from '@aiassist-secure/core';

Browser Usage

Works directly in modern browsers via ESM:

<script type="module">
  import { AiAssistClient } from 'https://esm.sh/@aiassist-secure/core';
  
  const client = new AiAssistClient({ 
    apiKey: 'aai_pub_your_domain_scoped_key' 
  });
  
  const response = await client.chat.completions.create({
    messages: [{ role: 'user', content: 'Hello from the browser!' }]
  });
  
  document.getElementById('output').textContent = 
    response.choices[0].message.content;
</script>

Note: Use domain-scoped public keys (aai_pub_*) for browser environments.


Related Packages

| Package | Description | |---------|-------------| | @aiassist-secure/react | React components with built-in UI | | @aiassist-secure/vanilla | Drop-in widget for any website |


Links


License

MIT License - Interchained LLC