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

@cellstate/sdk

v0.5.7

Published

TypeScript SDK for CELLSTATE — persistent agent memory and multi-agent coordination

Readme

@cellstate/sdk

TypeScript SDK for CELLSTATE — persistent agent memory and multi-agent coordination.

Installation

bun add @cellstate/sdk

Quick Start

import { CellstateClient } from '@cellstate/sdk';

const client = new CellstateClient({
  apiKey: process.env.CELLSTATE_API_KEY!,
  tenantId: 'your-tenant-id',
  // Optional: baseUrl defaults to https://cst.batterypack.dev
});

// Create a trajectory (task container)
const trajectory = await client.trajectories.create({
  name: 'Build feature X',
  description: 'Implement new user authentication',
});

// Create a scope (context window)
const scope = await client.scopes.create({
  trajectory_id: trajectory.trajectory_id,
  name: 'Implementation phase',
  token_budget: 8000,
});

// Store an artifact (extracted value)
await client.artifacts.create({
  trajectory_id: trajectory.trajectory_id,
  scope_id: scope.scope_id,
  artifact_type: 'Code',
  name: 'auth-handler.ts',
  content: 'export function authenticate() {...}',
  source_turn: 1,
  extraction_method: 'Explicit',
  ttl: 'Persistent',
});

// Create a note (cross-trajectory knowledge)
await client.notes.create({
  note_type: 'Convention',
  title: 'Always use async/await',
  content: 'Prefer async/await over .then() chains for readability.',
  source_trajectory_ids: [trajectory.trajectory_id],
  source_artifact_ids: [],
  ttl: 'Persistent',
});

Core Concepts

Hierarchy

TENANT (Isolation boundary)
  └── TRAJECTORY (Task/Goal)
        ├── SCOPE (Context window)
        │     └── TURN (Ephemeral message)
        ├── ARTIFACT (Persists - valuable outputs)
        └── NOTE (Cross-trajectory knowledge)

Memory Types

| Type | Lifespan | Example | |------|----------|---------| | Ephemeral | Scope only | Current messages (Turns) | | Episodic | Configurable | Saved outputs (Artifacts) | | Semantic | Long-term | Learned knowledge (Notes) |

What Survives?

When a Scope closes:

  • ❌ Turns are deleted (ephemeral)
  • ✅ Artifacts persist
  • ✅ Notes persist

SimpleMemory (3-Method API)

For quick integrations, use the simplified API:

import { SimpleMemory } from '@cellstate/sdk';

const memory = new SimpleMemory({
  apiKey: process.env.CELLSTATE_API_KEY!,
  tenantId: process.env.CELLSTATE_TENANT_ID!,
});

// Store memories
await memory.add('User prefers dark mode');
await memory.add('function greet() {...}', { type: 'artifact', artifactType: 'Code' });

// Search memories
const results = await memory.search('preferences');

// Get context for LLM injection
const context = await memory.getContext('user preferences');
// Returns XML-formatted context ready for system prompt

AG-UI Headless Primitives

Framework-agnostic building blocks for CopilotKit and AG-UI compatible apps:

import { createAgUiAdapter } from '@cellstate/sdk';

// Create headless adapter - no framework, just TypeScript
const adapter = createAgUiAdapter({
  threadId: 'trajectory-123',
  runId: 'scope-456',
});

// Subscribe to AG-UI events
adapter.onEvent((event) => {
  switch (event.type) {
    case 'TEXT_MESSAGE_CONTENT':
      appendToUI(event.delta);
      break;
    case 'TOOL_CALL_START':
      showToolIndicator(event.toolCallName);
      break;
  }
});

// Feed CELLSTATE stream events through the adapter
websocket.onmessage = (e) => {
  adapter.processEvent(JSON.parse(e.data));
};

Wrap with your framework of choice - React, Vue, Svelte, or vanilla JS. See docs/recipes/copilotkit.md for full examples.

API Reference

Managers

| Manager | Resource | Description | |---------|----------|-------------| | client.trajectories | Trajectory | Task containers | | client.scopes | Scope | Context windows with token budgets | | client.artifacts | Artifact | Extracted valuable outputs | | client.notes | Note | Cross-trajectory knowledge | | client.turns | Turn | Ephemeral conversation messages | | client.agents | Agent | Agent registration and lifecycle | | client.locks | Lock | Distributed locking | | client.messages | Message | Inter-agent messaging | | client.delegations | Delegation | Task delegation | | client.handoffs | Handoff | Context handoffs | | client.search | - | Global search | | client.packConfig | - | pack validation/parsing | | client.batch | - | Bulk CRUD operations | | client.edges | Edge | Graph relationships | | client.summarizationPolicies | SummarizationPolicy | Summarization policies | | client.summarizationRequests | SummarizationRequest | Summarization requests | | client.workingSet | WorkingSetEntry | Agent working set |

Common Operations

// CRUD operations
const item = await client.trajectories.create({ name: 'Task' });
const item = await client.trajectories.get(id);
const items = await client.trajectories.list({ status: 'Active' });
const item = await client.trajectories.update(id, { name: 'Updated' });
await client.trajectories.delete(id);

// Search
const results = await client.search.search({
  query: 'authentication',
  entity_types: ['Artifact', 'Note'],
});

// Multi-agent coordination
await client.agents.register({ agent_type: 'coder', capabilities: ['write_code'] });
await client.delegations.create({ from_agent_id, to_agent_id, task_description: '...' });
await client.locks.acquire({ resource_type: 'trajectory', resource_id: id, mode: 'Exclusive' });

Error Handling

import { CellstateError, NotFoundError, ValidationError } from '@cellstate/sdk';

try {
  await client.trajectories.get('nonexistent');
} catch (error) {
  if (error instanceof NotFoundError) {
    console.log('Trajectory not found');
  } else if (error instanceof ValidationError) {
    console.log('Validation errors:', error.validationErrors);
  } else if (error instanceof CellstateError) {
    console.log('API error:', error.code, error.message);
  }
}

Configuration

const client = new CellstateClient({
  baseUrl: 'https://cst.batterypack.dev',  // API endpoint
  apiKey: 'your-api-key',               // Required
  tenantId: 'your-tenant-id',           // Required
  timeout: 30000,                        // Request timeout (ms)
  headers: { 'X-Custom': 'value' },     // Custom headers
});

License

Apache-2.0