Skip to content
This repository was archived by the owner on Apr 21, 2026. It is now read-only.

Repository files navigation

@verifiedstate/sdk

The official TypeScript SDK for VerifiedState — verified memory infrastructure for AI agents.

npmLicense: MIT

Install

npm install @verifiedstate/sdk

Quick Start

import{VerifiedStateClient}from'@verifiedstate/sdk';constclient=newVerifiedStateClient({apiKey: 'vs_live_...',baseUrl: 'https://api.verifiedstate.ai',// optional, this is the default});// Store contentconstartifact=awaitclient.ingest({namespace_id: 'your-namespace-uuid',content: 'The user prefers dark mode and uses PostgreSQL.',source_type: 'user_input',});// Extract assertionsconstextracted=awaitclient.extract({namespace_id: 'your-namespace-uuid',artifact_id: artifact.artifact_id,});// Verify an assertionconstreceipt=awaitclient.verify({assertion_id: extracted.assertion_ids[0],namespace_id: 'your-namespace-uuid',});// Query memoryconstresults=awaitclient.query({namespace_id: 'your-namespace-uuid',query_text: 'What database does the user prefer?',});

API Methods

ingest(params)

Store raw content and create an artifact with spans.

constresult=awaitclient.ingest({namespace_id: 'uuid',content: 'Raw text content to store',source_type: 'user_input',// or 'document', 'api', etc.source_id: 'optional-external-id',});// => { artifact_id, span_count, r2_stored }

extract(params)

Extract structured assertions from an artifact using LLM.

constresult=awaitclient.extract({namespace_id: 'uuid',artifact_id: 'artifact-uuid',});// => { assertions_created, assertion_ids }

verify(params)

Run the verification ladder and produce a signed receipt.

constresult=awaitclient.verify({assertion_id: 'assertion-uuid',namespace_id: 'uuid',});// => { receipt_id, status, final_confidence, conflicts_found }

query(params)

Multi-channel retrieval with intent-aware routing.

constresult=awaitclient.query({namespace_id: 'uuid',query_text: 'What is the user'spreferredlanguage?',
mode: 'current',// 'current' | 'point_in_time' | 'trusted'limit: 10,filters: {valid_only: true},});// => { assertions, receipts, total, answerable, channels_used }

Structured queries:

constresult=awaitclient.query({namespace_id: 'uuid',query: {subject: 'user:42',predicate: 'prefers'},});

receipt(receiptId)

Retrieve a verification receipt by ID.

constdetail=awaitclient.receipt('receipt-uuid');// => { receipt, assertion, evidence_spans }

chain(writerPrincipal)

Get the Merkle chain for a writer.

constchain=awaitclient.chain('agent:billing');// => { writer_principal, current_hash, assertion_count, recent_assertions }

compress(params)

Compress an artifact to IR1 format.

constresult=awaitclient.compress({namespace_id: 'uuid',artifact_id: 'artifact-uuid',});// => { encoded_artifact_id, compression_ratio }

decompress(params)

Decompress an encoded artifact.

constresult=awaitclient.decompress({namespace_id: 'uuid',encoded_artifact_id: 'encoded-uuid',});// => { content, verified }

challenge(params)

Challenge an assertion with counter-evidence.

constresult=awaitclient.challenge({assertion_id: 'assertion-uuid',namespace_id: 'uuid',reason: 'Contradicted by updated policy',counter_evidence: 'Policy v2 states...',});// => { challenge_id, status }

retract(params)

Retract an assertion.

constresult=awaitclient.retract({assertion_id: 'assertion-uuid',namespace_id: 'uuid',reason: 'Information no longer valid',});// => { retraction_id, status }

health(namespaceId)

Get memory health metrics.

consthealth=awaitclient.health('namespace-uuid');// => { namespace_id, total_assertions, verified_count, disputed_count, coverage_score }

Proof Meter

Billing attestation for AI agents. Every transaction signed, chained, and independently verifiable.

// Create a spend authorizationconstcap=awaitclient.meter.authorize({namespace_id: 'your-namespace-uuid',authorizedAgentId: 'agent-alpha',maxBudgetCents: 1000,scope: {allowedProviders: ['openai','anthropic']},});// Submit a spend receiptconstreceipt=awaitclient.meter.spend({namespace_id: 'your-namespace-uuid',capabilityId: cap.capability_id,actorId: 'agent-alpha',providerId: 'openai',usageUnit: 'tokens',usageQuantity: 1500,costCents: 45,occurredAt: newDate().toISOString(),});// => { receipt_id, receipt_hash, signature, status: 'verified' }// Check remaining budgetconstbudget=awaitclient.meter.budget(cap.capability_id);// => { spent_cents, remaining_cents, receipt_count, children }// Verify a receipt (cryptographic integrity check)constcheck=awaitclient.meter.verify(receipt.receipt_id);// => { verified: true, checks: { hash_integrity, signature_valid, chain_continuity, merkle_inclusion }}// Settle receipts into a Merkle rootconstsettlement=awaitclient.meter.settle({namespace_id: 'your-namespace-uuid',capabilityId: cap.capability_id,});// => { settlement_id, merkle_root, total_cost_cents, receipt_count }

Real-Time Subscriptions

Subscribe once. Get instant answers.

// Subscribe to your namespaceawaitclient.subscribe(namespaceId);// Four-tier retrieval — automatically takes the fastest pathconstfact=awaitclient.quickQuery(namespaceId,'user|prefers.drink|morning');

Retrieval speed:

  • Existence check: 0.01ms (local filter, no network)
  • Cached facts: <1ms (live in memory via real-time stream)
  • Direct queries: <5ms (pre-computed state)
  • Complex queries: <100ms (full retrieval)

Before VerifiedState: 80ms per query, every time. After VerifiedState: 0.01ms to know if a fact exists, <1ms to retrieve it.

New Methods

  • subscribe(namespaceId) — load filter + cache + start receiving state
  • unsubscribe() — clean up subscription and clear cache
  • refreshFilter(namespaceId) — refresh existence filter (call every ~5 min for long-running agents)
  • quickQuery(namespaceId, slotKey) — four-tier retrieval with automatic fastest path
  • resync(namespaceId) — catch up on missed deltas

Cross-IDE Shared State

VerifiedState works across every MCP-compatible coding tool.

Define something in Claude Code — it's instantly available in Cursor, Windsurf, and every other session connected to the same namespace.

Compatible tools:

  • Claude Code
  • Cursor
  • Windsurf
  • VS Code + Continue
  • Gemini CLI
  • GitHub Copilot
  • Any MCP client

One config, all tools: Add https://mcp.verifiedstate.ai/mcp as an MCP server in your tool of choice.

Error Handling

import{VerifiedStateError}from'@verifiedstate/sdk';try{awaitclient.query({namespace_id: 'uuid',query_text: '...'});}catch(err){if(errinstanceofVerifiedStateError){console.error(err.status,err.message,err.body);}}

License

MIT

About

TypeScript SDK for VerifiedState — verified memory infrastructure for AI agents

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages