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

@agentstate/sdk

v0.1.3

Published

TypeScript SDK for AgentState — conversation history for AI agents

Downloads

7,153

Readme

@agentstate/sdk

TypeScript SDK for AgentState — conversation history database-as-a-service for AI agents.

Installation

npm install @agentstate/sdk

Install optional LangGraph support when using the checkpoint adapter:

npm install @agentstate/sdk @langchain/langgraph-checkpoint

Quick Start

import { AgentState } from "@agentstate/sdk";

const client = new AgentState({ apiKey: process.env.AGENTSTATE_API_KEY! });

// Store a conversation
const conv = await client.createConversation({
  messages: [
    { role: "user", content: "What is AgentState?" },
    { role: "assistant", content: "A conversation history database for AI agents." },
  ],
});

// Retrieve it later
const saved = await client.getConversation(conv.id);
console.log(saved.messages);

Available Methods

Conversations

  • createConversation(data) — Create a conversation with optional messages, title, and metadata
  • getConversation(id) — Get a conversation with all its messages
  • getConversationByExternalId(externalId) — Look up a conversation by your own external ID
  • listConversations(params?) — List conversations with cursor-based pagination
  • updateConversation(id, data) — Update title or metadata
  • deleteConversation(id) — Delete a conversation

Messages

  • appendMessages(conversationId, messages) — Append messages to an existing conversation
  • listMessages(conversationId, params?) — List messages with pagination

AI Features

  • generateTitle(conversationId) — Auto-generate a title from conversation content
  • generateFollowUps(conversationId) — Generate follow-up questions

Export

  • exportConversations(ids?) — Export all or selected conversations with messages

State Platform

These helpers target /v1/states:

  • upsertState(stateKey, data, options?) — Create or replace state for a key
  • getState(stateKey, params?) — Read latest or historical state
  • queryStates(query?) — Query by agent, tags, timestamps, JSON path, or cursor
  • deleteState(stateKey, params?) — Delete state with optional lease and idempotency
  • listStateEvents(stateKey, params?, options?) — Read event history or watch with a capability token
  • createStateLease(stateKey, data) / renewStateLease(id, data, options?) / releaseStateLease(id, options?) — Manage write leases
  • createCapabilityToken(data) / listCapabilityTokens() / revokeCapabilityToken(id) — Manage scoped state tokens
  • createClaim(data) / listClaims(params?) / getClaim(id) / verifyClaim(id) — Create and verify deterministic claims
const state = await client.upsertState("assistant/session-123", {
  agent_id: "assistant",
  data: { step: "collecting_requirements" },
  tags: ["session"],
}, {
  idempotencyKey: "session-123-step-1",
});

const capability = await client.createCapabilityToken({
  name: "session watcher",
  state_key: state.state_key,
  scopes: ["state:watch", "lease:write"],
  expires_at: Date.now() + 60 * 60 * 1000,
});

const events = await client.listStateEvents(state.state_key, { after: 0 }, {
  capabilityToken: capability.token,
});

const claim = await client.createClaim({
  subject_type: "state",
  subject_id: state.state_key,
  statement: "Session reached planning step",
  evidence: [{
    kind: "json_value",
    source: state.state_key,
    data: events.data.at(-1)?.data ?? {},
    json_path: "$.step",
    expected_value: "planning",
  }],
});

await client.verifyClaim(claim.id);

AI SDK and LangGraph state adapters

@agentstate/sdk/ai-sdk

import {
  createAISDKChatStore,
  createAISDKRSCStateStore,
} from "@agentstate/sdk/ai-sdk";

const chatStore = createAISDKChatStore(client, {
  stateKeyPrefix: "agentstate/ai-sdk/chat",
});

const rscStore = createAISDKRSCStateStore(client, {
  stateKey: "thread-1",
});

@agentstate/sdk/langgraph

import { AgentStateCheckpointSaver } from "@agentstate/sdk/langgraph";

const saver = new AgentStateCheckpointSaver(client);
await saver.put(
  { configurable: { thread_id: "thread-1", checkpoint_ns: "" } },
  { id: "cp-1" },
  {},
  {},
);

See agentstate LangGraph runtime docs for example usage.

Error Handling

All API errors throw an AgentStateError with code, status, and message fields:

import { AgentState, AgentStateError } from "@agentstate/sdk";

try {
  await client.getConversation("nonexistent-id");
} catch (err) {
  if (err instanceof AgentStateError) {
    console.error(err.code);    // e.g. "NOT_FOUND"
    console.error(err.status);  // e.g. 404
    console.error(err.message); // Human-readable message
  }
}

Documentation

License

MIT