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

@datacules/agent-identity-store-libsql

v0.13.0

Published

LibSQL (SQLite / Turso) credential store for @datacules/agent-identity — zero server, one npm install, scales to distributed

Downloads

509

Readme

@datacules/agent-identity-store-libsql

LibSQL (SQLite / Turso) persistence layer for the agent-identity framework.

Zero server. Zero native bindings required at runtime. One npm install. Scales from a local embedded file to a globally distributed Turso database by changing a single URL — no code changes.

Install

npm install @datacules/agent-identity-store-libsql

Quick Start

import { createLibSqlStores }    from '@datacules/agent-identity-store-libsql';
import { createRouterFromStore } from '@datacules/agent-identity';

// ── Embedded (zero infrastructure) ──────────────────────────────────────────
const stores = await createLibSqlStores({ url: 'file:./agent-identity.db' });

// ── Distributed (Turso) — one URL swap, no code change ───────────────────────
const stores = await createLibSqlStores({
  url:       process.env.TURSO_URL!,
  authToken: process.env.TURSO_AUTH_TOKEN,
});

// Wire into the router
const router = createRouterFromStore(
  stores.credentialStore,
  rules,
  stores.auditLogger,
);

// Wire into ApprovalManager
const approvals = new ApprovalManager(stores.approvalStore, notifiers);

// Wire into BudgetEnforcer
const budget = new BudgetEnforcer(stores.budgetStore);

What's Included

| Class | Interface | Responsibility | |---|---|---| | LibSqlCredentialStore | CredentialStore | Credential metadata, lifecycle, reservation locks, OIDC revocation | | LibSqlApprovalStore | ApprovalStore | Durable approval request queue | | LibSqlBudgetStore | BudgetStore | Hourly sliding-window counters, daily spend | | LibSqlAuditLogger | MigrationAuditLogger | Durable audit log + migration summary aggregation | | createLibSqlStores() | — | One-call factory: opens connection, bootstraps schema, returns all four | | bootstrapSchema() | — | Run the DDL directly against any Client you supply |

Schema

Six tables are created automatically on first call to createLibSqlStores():

ai_credentials          — credential metadata + OIDC identity fields
ai_reservations         — migration lock records (TTL-based)
ai_approval_requests    — approval workflow state machine
ai_budget_hourly        — sliding-window hourly resolution counters
ai_budget_daily         — daily spend accumulators
ai_audit_log            — full audit trail (standard + migration entries)

All CREATE TABLE statements use IF NOT EXISTS — safe to run on every startup, no migration runner required.

Scaling: Embedded → Distributed

Development / single-instance:
  url: 'file:./agent-identity.db'   ← SQLite file, zero infra
  url: ':memory:'                   ← in-memory, tests and ephemeral agents

Multi-instance / global:
  url: 'libsql://my-db.turso.io'    ← Turso cloud, shared state
  url: 'https://my-db.turso.io'     ← HTTPS mode

The router, approval manager, and budget enforcer see a uniform CredentialStore / ApprovalStore / BudgetStore interface — they don't know or care whether the backing store is local or distributed.

Seeding Credentials

LibSqlCredentialStore exposes an upsert() method (not part of the core interface) for seeding credentials on startup:

await stores.credentialStore.upsert({
  id:       'cred-openai-prod',
  kind:     'fixed',
  name:     'OpenAI Production Key',
  scope:    'all-projects',
  status:   'active',
  provider: 'openai',
  ref:      'openai-prod-slot',
  tags:     ['prod'],
  // Optional: record OIDC identity for revokeByIdentity() support
  identityIssuer:   'https://auth.openai.com',
  identitySubject:  'user-42',
  identityAudience: 'https://api.datacules.com',
});

Combining with Hash-Chain Audit Logging

LibSqlAuditLogger provides durable storage. For tamper-evident logging, wrap it with HashChainAuditLogger from @datacules/agent-identity-audit:

import { HashChainAuditLogger } from '@datacules/agent-identity-audit';

const auditLogger = new HashChainAuditLogger(stores.auditLogger);
// Now every entry is chained AND persisted to SQLite

Test Pattern

All four stores accept a Client in their constructor — inject a mock client in tests without needing a real database:

import { LibSqlCredentialStore } from '@datacules/agent-identity-store-libsql';
import { vi } from 'vitest';

const mockExecute = vi.fn();
const mockClient  = { execute: mockExecute } as never;
const store = new LibSqlCredentialStore(mockClient);

mockExecute.mockResolvedValue({ rows: [...], rowsAffected: 0 });

Part of the agent-identity monorepo by Datacules LLC.