Skip to content

aryza0x/engram-sdk

Repository files navigation

Engram SDK

Persistent memory, self-funded payments, and verifiable actions for AI agents.

npm npm tests build license node

Filecoin Onchain Cloud · Lit Protocol / Vincent · Squid Router (Axelar) · ERC-8004

Live Dashboard · Documentation

SDK on npm (engramjs) · MCP on npm (@engram-sdk/mcp)


Most AI agents are brilliant reasoners trapped in amnesiac, dependent shells — they can't persist across restarts, can't fund themselves, and leave no verifiable trace of their actions. Engram is the backend that fixes that.

A framework-agnostic SDK built on the Filecoin Onchain Cloud, Lit Protocol's Vincent + Naga, and the Axelar-powered Squid Router — Engram gives agents the four primitives they're missing: the ability to remember, pay, share context, and prove their actions, without any human in the loop.


Table of Contents

The AI Lobotomy Problem

Every time an AI agent's process restarts, it is lobotomized. Its entire working memory — decisions, context, learned state — is wiped. What survives lives in databases that operators control, that agents can't fund, and that carry no cryptographic proof of what was actually stored.

This is not a memory problem. It's an infrastructure problem, and it creates a hard ceiling on what agents can actually do:

Agents can't persist. Context is lost across restarts, deployments, and machines. An agent that reasoned its way to a complex conclusion has no way to carry that conclusion forward.

Agents can't pay. They depend on humans to top up wallets, approve transactions, and manage keys. True autonomy stops at the payment layer.

Agents can't prove. There's no on-chain record of what an agent decided, stored, or spent. Every action is unverifiable and deniable.

Agents can't share. Handing context to another agent requires centralized middleware, shared databases, or manual intervention.

The result: agents that are brilliant reasoners trapped in amnesiac, dependent shells.


The Engram Answer

Engram replaces the fragile human-dependent layer with protocol-native infrastructure that agents control directly.

What agents need What Engram provides
Memory that survives restarts Content-addressed storage on Filecoin Onchain Cloud — immutable, replicated, TTL-enforced
A wallet they own Lit Protocol's Vincent — PKP-based smart accounts provisioned to the agent, not the operator
Funds without humans Axelar-powered Squid Router — bridge any token from any chain into USDFC automatically
Proof of actions ERC-8004 on-chain attestations — every store operation can produce an immutable on-chain receipt
A portable identity ERC-8004 IdentityRegistry on Base Sepolia — each agent has a DID it carries across deployments
Context handoff to other agents Signed capability tokens — cryptographically scoped, expiring, verifiable delegation

PL Genesis

The protocols Engram is built on — FOC, Lit Protocol, and ERC-8004 are the core infrastructure the SDK runs on.

Protocol What Engram uses it for
Filecoin Onchain Cloud Content-addressed memory storage. Every store() submits a Synapse deal; the agent pays USDFC directly from its own wallet.
Lit Protocol / Vincent PKP-based smart accounts provisioned to the agent. The operator never holds the agent's funds or signing keys.
Lit Protocol V1 / Naga Payload encryption at rest. encrypt: true calls Lit before submitting to Filecoin; retrieval decrypts transparently using the agent's PKP.
Axelar / Squid Router Autonomous cross-chain funding. The agent bridges from any token on any chain to USDFC when its balance runs low — no human top-up.
ERC-8004 IdentityRegistry Portable agent DID registered on Base Sepolia. Persists across restarts and deployments.
ERC-8004 ReputationRegistry On-chain receipt for every store() — CID, timestamp, agent DID — written when attestOnChain: true.
EngramIndexRegistry Custom on-chain pointer to the agent's latest CID index snapshot on Filecoin. The anchor for cold-key recovery (restore()).

Tracks

AI & Robotics is the primary fit. The track explicitly names ERC-8004, agent identity, and inter-agent payment rails as the infrastructure it wants built. Engram provides all three — cryptographic proof of agent actions via the ReputationRegistry, portable identity via the IdentityRegistry, and autonomous payments via Vincent + Squid Router.

Infrastructure & Digital Rights is the secondary fit. The track is about giving humans data ownership, encrypted storage, and censorship-resistant infrastructure. Engram applies those same guarantees to agents — memory stored on Filecoin that only the agent's key can retrieve, Lit Protocol encryption so the storage provider never sees plaintext, and ERC-8004 attestations that make every action auditable. The digital rights problem for agents is structurally identical to the one the track is trying to solve for humans.


Filecoin Onchain Cloud

Storage deals are submitted via the Synapse SDK, paid in USDFC from the agent's Vincent smart account. Every store() call:

  1. Resolves replication factor and TTL from the Auto-Policy Engine (critical → 5× replication, 365-day TTL)
  2. Enforces the maxSpendUSDFC budget guard before any network call
  3. If the USDFC balance is below the estimated cost, Squid Router bridges funds autonomously
  4. Submits the deal to Filecoin — agent pays directly, no operator approval
  5. Returns a StorageReceipt: CID, deal ID, TTL timestamp, USDFC spent

Retrieval fetches by CID and decrypts automatically if the payload was encrypted. The EngramIndexRegistry on-chain pointer enables full memory reconstruction from a private key alone — no server, no database.


Lit Protocol — Vincent and Naga

Vincent provisions a PKP-based smart account to the agent at SDK init. All on-chain spend — Filecoin storage deals, Axelar bridge transactions — is signed by the agent's PKP. The operator configures the agent but does not control its wallet.

Naga (Lit Protocol V1) handles encryption when encrypt: true is set. The payload is encrypted before leaving the process, with an access condition tied to the agent's DID. The storage provider on Filecoin only ever sees ciphertext. Decryption happens automatically on retrieve() using the same PKP.

const receipt = await sdk.store(reasoningChain, { priority: 'critical', encrypt: true });
const data    = await sdk.retrieve(receipt.cid); // Lit decrypts using agent PKP

ERC-8004

Three registries are active on Base Sepolia:

Registry Role
IdentityRegistry Agent DID derived from the operator private key. Registered once, portable across every deployment.
ReputationRegistry Attestation written after each store() — what was stored, the CID, when, and by which agent. Immutable and queryable by any third party.
EngramIndexRegistry Holds the latest index CID pointer. restore() reads this to reconstruct the agent's full memory map from a cold key.

The packages/identity package handles registration, attestation writes, and index pointer updates. Errors surface as typed RegistrationFailedError with structured context.


Live Demo & Quickstart

Live links

Replay provenance

The live site at https://engramsdk.dev/ is not a mocked UI demo. It is a replay of real Engram agent activity and transaction history that already happened on Filecoin mainnet.

What you are seeing in the dashboard reflects actual executed operations, including storage lifecycle events and on-chain proofs captured from production activity on Filecoin Mainnet.

For local verification, see agent-log.json, which contains the replay source events (for example BRIDGE_ROUTE_QUOTED, STORE, DELEGATE_ISSUED, DELEGATION_VERIFIED, and RESTORE_COMPLETE) plus concrete transaction metadata like bridgeTxHash.

Quickstart commands

pnpm demo          # autonomous agent flow + delegation + restore/lobotomy
pnpm demo:restore  # restore/lobotomy mode only
pnpm demo:agent-b  # delegated retrieval path for Agent B
pnpm swarm         # 3-agent incident-response swarm
pnpm swarm:restore # swarm restore phase

Demo scenarios

  • pnpm demo (demo/agent.ts): A GPT-4o-mini langchain agent self-provisions its Vincent wallet and ERC-8004 identity, runs an autonomous research loop, offloads context to Filecoin at 80% capacity, resolves cross-chain USDC -> USDFC funding via Squid when needed, delegates memory access to Agent B, and then passes the Lobotomy Test by restoring from on-chain history + Filecoin CIDs after local wipe.
  • pnpm swarm (demo/swarm.ts): A Commander coordinates Analyst and Verifier agents through a security incident. Findings are stored to Filecoin, delegated via signed capability tokens, and verified across agents. The Commander is intentionally hard-killed mid-run, restored from ERC-8004-linked history, and completes a final brief with CID-backed provenance for each claim.

Verifiable Links (Contracts, TXs, Deals)

Below are concrete, replay-backed artifacts you can click and independently verify.

Contract links

Surface Network Address Explorer
IdentityRegistry Base Sepolia (84532) 0x8004A818BFB912233c491871b3d84c89A494BD9e View
ReputationRegistry Base Sepolia (84532) 0x8004B663056A597Dffe9eCcC1965A193B7388713 View
EngramIndexRegistry Filecoin Calibration (314159) 0xd29f61333b857a5e0DB47E70413F5Fb21120F6E1 View
EngramIndexRegistry Filecoin Mainnet (314) 0xC2f7174c76bEdb8Ba2518E5BF22c8C6298C8c536 View

TX hashes

Event Network Hash Explorer
ERC-8004 agent registration Base Sepolia 0xd6e92243259b09c25972cffdb3885d08ebac3567843f92243702bea856cf976e View
Cross-chain USDC -> USDFC bridge Axelar GMP 0x942a272e3bd58ba6cf92c44b9de7551f1ee4b1deb7aba63bd50b44a83de97445 View

Mainnet Storage deals / CIDs

Artifact Value Link
Primary memory CID (STORE) bafkzcibe263qcc4ksgs6b6fgxjplxcrtqyyvghhn24z42ormvgzqtjbzmuzlgrx6e4 CDN
Delegation token CID bafkzcibciucbb6qmbsnpdonr6qqltq24jjvn23o6yazxm7a6m4hptu2eg4ntuky CDN
Restore index CID bafkzcibdzyaqjvyncb3zruf752zxtn66zt7vnrpbao4c4xdabjd5h5xjjpgk5eia CDN

In this replay, the logged dealId mirrors the CID value returned by the storage layer. Full raw event history lives in agent-log.json.


The Lobotomy Test

The definitive test for any agent memory system: wipe everything and see what survives.

Engram is designed to pass it. Here's what recovery looks like from a cold private key alone:

import { restore } from 'engramjs';

// New machine. No local files. Just the agent's private key.
const index = await restore({ operatorPrivateKey });

// Engram resolves the on-chain EngramIndexRegistry pointer,
// fetches the CID index from Filecoin, and reconstructs the full memory map.
// The agent is back.

console.log(`Recovered ${index.cids.length} memories`);
for (const cid of index.cids) {
  const memory = await sdk.retrieve(cid);
  // full data, fully decrypted, exactly as it was stored
}

How it works under the hood:

restore(privateKey)
 │
 ├─ Derive agent DID from private key
 ├─ Query EngramIndexRegistry on-chain → fetch latest index CID pointer
 ├─ Fetch index snapshot from Filecoin by CID
 ├─ Reconstruct full CID map { cid → { expiryDate, policy } }
 └─ Return populated index — agent is fully restored

No server. No database. No operator. Just the key and the chain.


How It Works

store — the full path

sdk.store(data, { priority: 'critical', encrypt: true })
 │
 ├─ 1. Auto-Policy Engine resolves storage parameters
 │       priority: 'critical' → replication: 5, ttlDays: 365, encrypt: true
 │       explicit overrides always win over policy defaults
 │
 ├─ 2. Budget guard enforced before any network call
 │       runningSpend + estimatedCost must be ≤ maxSpendUSDFC
 │
 ├─ 3. (if funds low) Squid Router bridges autonomously
 │       USDC / ETH / any supported token → USDFC on Filecoin
 │       no human approval required
 │
 ├─ 4. (if encrypt: true) Lit Protocol / Vincent encrypts payload
 │       PKP access condition tied to agent DID
 │       ciphertext only — plaintext never leaves the process unencrypted
 │
 ├─ 5. Synapse SDK submits storage deal on Filecoin Onchain Cloud
 │       agent's Vincent smart account pays USDFC directly
 │       returns CID + deal confirmation
 │
 ├─ 6. (if attestOnChain: true) ERC-8004 ReputationRegistry
 │       writes on-chain receipt: what was stored, when, by whom
 │       immutable, timestamped, signed by agent DID
 │
 ├─ 7. EngramIndexRegistry updated with new CID pointer
 │       enables cold-key recovery (the Lobotomy Test)
 │
 └─ 8. Return StorageReceipt { cid, dealId, ttlTimestamp, spendUSDFC, policy, attestationTx }

retrieve

sdk.retrieve(cid)
 │
 ├─ Fetch from Filecoin by CID
 ├─ (if encrypted) Lit Protocol decrypts using agent PKP
 └─ Return original payload — type preserved

Memory lifecycle

Method Purpose
store(data, opts?) Persist to Filecoin. Returns receipt with CID and optional attestation tx.
retrieve(cid, opts?) Fetch and auto-decrypt.
renew(cid, opts?) Extend TTL near expiry. Designed for scheduled cron.
prune(cid) Remove from active index. Data stays on Filecoin (immutable).
restore(opts) Reconstruct full memory map from private key alone.
delegate(sdk, cid, did, opts?) Issue a signed, expiring capability token to another agent.
verifyDelegation(sdk, tokenCid, did) Verify a token — checks signature, recipient, and expiry.

Install

npm install engramjs

MCP server (for Cursor, Claude Desktop, or any MCP client):

npx @engram-sdk/mcp

Configuration

Full production configuration

import { EngramSDK } from 'engramjs';
import { createProvider } from '@engram-sdk/providers';

const storageProvider = await createProvider(); // Synapse by default

const sdk = new EngramSDK({
  storageProvider,

  // Credentials
  operatorPrivateKey: process.env.OPERATOR_PRIVATE_KEY, // signs on-chain txs
  vincentApiKey: process.env.VINCENT_SECRET_API_KEY, // Vincent smart account

  // Network
  network: 'calibration', // 'mainnet' for production

  // Budget controls — enforced before every store()
  maxSpendUSDFC: 10, // cumulative ceiling
  renewThresholdDays: 14, // renew X days before expiry
  safetyMarginPct: 20, // add 20% buffer to cost estimates

  // Behavior
  attestOnChain: true, // write ERC-8004 receipt after every store
  agentName: 'my-agent',
  logPath: './agent_log.json',
  verbose: false,
});

Local dev / tests — zero keys, zero network calls

import { EngramSDK } from 'engramjs';
import { MockStorageProvider } from '@engram-sdk/providers/mock';

const sdk = new EngramSDK({
  storageProvider: new MockStorageProvider(),
  maxSpendUSDFC: 10,
});

// Fully functional — store, retrieve, renew, prune all work.
// MockStorageProvider simulates latency and tracks spend.

API Reference

store(data, options?)

sdk.store(data: unknown, options?: StoreOptions): Promise<StorageReceipt>
const receipt = await sdk.store(
  { messages: conversationHistory, stepCount: 142 },
  { priority: 'critical', encrypt: true },
);

// receipt.cid            → 'bafy...'
// receipt.dealId         → Filecoin deal identifier
// receipt.ttlTimestamp   → Date  (365 days for 'critical')
// receipt.spendUSDFC     → 0.04
// receipt.policy         → { replication: 5, ttlDays: 365, encrypt: true }
// receipt.attestationTx  → '0x...'  (if attestOnChain: true)

Priority levels:

priority Replication TTL Encrypt default Use for
critical 365 days true Decisions, reasoning chains, identity state
standard (default) 90 days false General working memory
temporary 7 days false Intermediate results, drafts
ephemeral 1 day false Session state, scratch data

Explicit options always override priority defaults:

await sdk.store(data, {
  priority: 'standard',
  replication: 5, // override: store more copies
  ttlDays: 180, // override: custom retention
  encrypt: true, // override: force encrypt
});

retrieve(cid, options?)

sdk.retrieve(cid: string, options?: RetrieveOptions): Promise<unknown>

Fetches from Filecoin and decrypts automatically if the payload was encrypted.

const data = await sdk.retrieve(receipt.cid);

renew(cid, options?)

sdk.renew(cid: string, options?: RenewOptions): Promise<RenewResult>

Submits a renewal deal if within the renewThresholdDays window. Idempotent — safe to run on a schedule.

const result = await sdk.renew('bafy...');
// result.renewed         → true | false
// result.daysUntilExpiry → 11
// result.newTtlTimestamp → Date  (if renewed)

prune(cid)

sdk.prune(cid: string): Promise<PruneResult>

Removes a CID from the active memory index and logs a PRUNE event. Data on Filecoin is immutable — prune manages the index, not the underlying storage.


delegate(sdk, cid, recipientDID, options?)

Issue a signed capability token granting another agent read access to a specific memory:

import { delegate } from 'engramjs';

const { tokenCid, token } = await delegate(sdk, receipt.cid, partnerAgentDID, {
  ttlHours: 24,
});
// tokenCid       → 'bafy...'  share this CID with the recipient
// token.signature → '0x...'
// token.expiresAt → ISO string
// token.scope     → 'agent/read'

verifyDelegation(sdk, tokenCid, callerDID)

import { verifyDelegation } from 'engramjs';

const token = await verifyDelegation(sdk, tokenCid, callerDID);
// Throws DelegationVerificationError — wrong recipient or invalid signature
// Throws DelegationExpiredError     — token past expiresAt

Auto-Policy Engine

A pure, deterministic function — no side effects, fully testable in isolation:

import { resolvePolicy } from 'engramjs';

resolvePolicy({ priority: 'critical' });
// → { replication: 5, ttlDays: 365, encrypt: true }

resolvePolicy({ priority: 'standard', replication: 5, ttlDays: 180 });
// → { replication: 5, ttlDays: 180, encrypt: false }
// explicit fields always win over priority defaults

Error Handling

All errors are typed and carry structured context:

import {
  BudgetExceededError, // spend would exceed maxSpendUSDFC
  InsufficientBalanceError, // USDFC balance too low
  StorageDealFailedError, // Filecoin deal failed
  DecryptionFailedError, // Lit Protocol decryption error
  DelegationVerificationError, // wrong recipient or invalid signature
  DelegationExpiredError, // token past expiresAt
  RegistrationFailedError, // ERC-8004 registration failed
} from 'engramjs';

try {
  await sdk.store(largePayload, { priority: 'critical' });
} catch (err) {
  if (err instanceof BudgetExceededError) {
    // err.maxSpend      → 10 (configured ceiling)
    // err.currentSpend  → 9.8 (running total)
    // err.estimatedCost → 0.4 (projected cost of this operation)
  }
  if (err instanceof InsufficientBalanceError) {
    // err.required  → USDFC needed
    // err.available → current agent balance
    // → trigger sdk funding flow or alert operator
  }
}

MCP Server

Engram ships a standalone MCP server that exposes the full SDK as tools — usable directly from Cursor, Claude Desktop, or any MCP-compatible client. No integration code required.

Start

OPERATOR_PRIVATE_KEY=0x... ENGRAM_NETWORK=calibration npx @engram-sdk/mcp
# → [engram:mcp] Server listening on http://localhost:3456/mcp

Connect from Cursor

Create .cursor/mcp.json in your project:

{
  "mcpServers": {
    "engram": { "url": "http://localhost:3456/mcp" }
  }
}

Connect from Claude Desktop

Add to claude_desktop_config.json:

{
  "mcpServers": {
    "engram": { "url": "http://localhost:3456/mcp" }
  }
}

Available tools

Tool What it does
engram_store Store any JSON to Filecoin with policy resolution. Returns CID.
engram_retrieve Fetch by CID. Auto-decrypts encrypted payloads.
engram_renew Extend TTL before expiry.
engram_prune Remove CID from active index.
engram_delegate Issue a signed capability token to another agent.
engram_verify_delegation Verify a capability token — sig, expiry, recipient.
engram_restore Rebuild local index from EngramIndexRegistry + Filecoin snapshot.
engram_status Show running spend, active CIDs, identity, provider, and budget.
# Health check
curl http://localhost:3456/health
# → { "status": "ok", "tools": ["engram_store", "engram_retrieve", ...] }

Framework Adapters

OpenClaw

The OpenClaw adapter is a lifecycle hook — install it once and every agent session is automatically snapshotted to Filecoin on command:new and restored from Filecoin on agent:bootstrap. Zero changes to your agent code.

openclaw hooks install ./packages/adapters/openclaw
agent:bootstrap  → reads last CID from disk
                 → fetches snapshot from Filecoin
                 → injects ENGRAM_MEMORY.md into bootstrapFiles
                 → agent starts with full prior context

command:new      → snapshots current session to Filecoin
                 → saves CID locally
                 → agent carries memory into next session

The agent never goes blank between sessions.


LangChain

import {
  EngramStoreTool,
  EngramRetrieveTool,
} from 'engramjs/adapters/langchain';
import { createOpenAIFunctionsAgent } from 'langchain/agents';

const tools = [new EngramStoreTool(sdk), new EngramRetrieveTool(sdk)];
const agent = await createOpenAIFunctionsAgent({ llm, tools, prompt });
// Every decision the agent makes can be persisted to Filecoin
// and recalled in future sessions by CID

LlamaIndex

import { EngramWriter, EngramReader } from 'engramjs/adapters/llamaindex';

const writer = new EngramWriter(sdk);
const cid = await writer.store(document);

const reader = new EngramReader(sdk);
const doc = await reader.loadData(cid);

Architecture

┌──────────────────────────────────────────────────────────────────────┐
│                        Your Agent / App                              │
│              LangChain · LlamaIndex · MCP · custom loop              │
└────────────────────────────────┬─────────────────────────────────────┘
                                 │
                                 ▼
┌──────────────────────────────────────────────────────────────────────┐
│                          engramjs SDK                                │
│                                                                      │
│  ┌──────────────────┐   ┌───────────────┐   ┌─────────────────────┐  │
│  │  Auto-Policy     │   │  Budget Guard │   │  Logger + Errors    │  │
│  │  Engine          │   │  maxSpendUSDFC│   │  typed, structured  │  │
│  └──────────────────┘   └───────────────┘   └─────────────────────┘  │
│                                                                      │
│  ┌───────────────────────────────┐  ┌──────────────────────────────┐ │
│  │  Identity + Delegation        │  │  Wallet + Encryption         │ │
│  │                               │  │                              │ │
│  │  ERC-8004 IdentityRegistry    │  │  Lit Protocol / Vincent      │ │
│  │  ERC-8004 ReputationRegistry  │  │  PKP-based smart accounts    │ │
│  │  EngramIndexRegistry          │  │  Squid Router (Axelar)       │ │
│  │  Capability token delegation  │  │  Multichain → USDFC          │ │
│  └───────────────────────────────┘  └──────────────────────────────┘ │
└─────────────────┬────────────────────────────────────────────────────┘
                  │
      ┌───────────┴────────────┐
      ▼                        ▼
┌───────────────────┐  ┌─────────────────────────────┐
│  StorageProvider  │  │  Base Sepolia (on-chain)     │
│                   │  │                             │
│  Synapse SDK      │  │  IdentityRegistry (ERC-8004)│
│  ↓                │  │  ReputationRegistry         │
│  Filecoin         │  │  EngramIndexRegistry        │
│  Onchain Cloud    │  │  ↑                          │
│  (USDFC deals)    │  │  recovery anchor for        │
│                   │  │  the Lobotomy Test          │
└───────────────────┘  └─────────────────────────────┘

Beyond Ops-Only Tools

CLI-first storage tooling is excellent for setup, uploads, wallet checks, and provider operations. Engram includes those operational concerns, but its core value is agent-native memory behavior:

  • Multi-agent delegation — issue and verify signed capability tokens for cross-agent context handoff.
  • Verifiable memory handoff — Agent A can delegate a specific CID to Agent B with expiry + recipient checks.
  • Restore / Lobotomy recovery — wipe local index, recover memory map from on-chain index pointer + Filecoin snapshot.
  • Lifecycle semantics for agentsstore/retrieve/renew/prune with deterministic policy, budget guardrails, and optional on-chain receipts.

In short: ops commands are part of Engram, not the product boundary.


Two Adoption Paths

5-minute path (local + one offload)

Goal: prove the memory lifecycle quickly with zero chain risk.

  1. Use MockStorageProvider
  2. Store one payload
  3. Retrieve by returned CID
  4. Confirm logs and policy behavior
import { EngramSDK } from 'engramjs';
import { createProvider } from '@engram-sdk/providers';

const sdk = new EngramSDK({
  storageProvider: await createProvider('mock'),
  maxSpendUSDFC: 5,
});

const receipt = await sdk.store({ note: 'hello engram' }, { priority: 'standard' });
const data = await sdk.retrieve(receipt.cid);
console.log(receipt.cid, data);

Production path (live provider + attestation + restore drill)

Goal: run with real persistence, verifiability, and disaster-recovery confidence.

  1. Use live provider (synapse) on calibration or mainnet
  2. Enable attestOnChain
  3. Run normal store/retrieve/renew/prune operations
  4. Run restore drill (restore() or demo restore mode) to validate cold-start recovery
import { EngramSDK } from 'engramjs';
import { createProvider } from '@engram-sdk/providers';

const sdk = new EngramSDK({
  storageProvider: await createProvider('synapse'),
  operatorPrivateKey: process.env.OPERATOR_PRIVATE_KEY,
  vincentApiKey: process.env.VINCENT_SECRET_API_KEY,
  network: 'mainnet',
  attestOnChain: true,
  maxSpendUSDFC: 250,
  renewThresholdDays: 21,
  safetyMarginPct: 25,
});

For a full end-to-end example (delegation + restore), run pnpm demo.


Agent Skills

For AI agents consuming this repo/docs:

These files are optimized for tool-using agents and keep outputs consistent with Engram semantics.


Testing

All tests run against MockStorageProvider — zero network calls, zero keys, zero USDFC needed.

pnpm test            # 72 tests, all passing
pnpm test:watch      # watch mode for development
pnpm test:coverage   # coverage report

Tests cover:

  • Policy engine (pure function — 11 cases)
  • Store / retrieve / renew / prune lifecycle (14 cases)
  • Budget enforcement and typed errors (8 cases)
  • Capability delegation — issue, verify, reject expired, reject tampered (6 cases)
  • Wallet helpers (18 cases)

Development

git clone https://github.com/aryza0x/engram-sdk
cd engram-sdk
pnpm install

pnpm build        # compile all packages (tsc -b, topological order)
pnpm test         # run full test suite
pnpm mcp-server   # start MCP server locally

cp .env.example .env   # fill in keys
pnpm demo              # run the full autonomous agent demo
pnpm swarm             # multi-agent swarm demo

Monorepo layout

packages/
  core/        EngramSDK class, policy engine, types, errors
  identity/    ERC-8004 registration, attestation, restore
  delegation/  Capability token issuance + verification
  wallet/      Lit Protocol / Vincent PKP wallet helpers
  mcp/         MCP server + CLI binary (npx @engram-sdk/mcp)
  sdk/         Published as 'engramjs' — re-exports everything above
providers/
  synapse.ts   Filecoin Onchain Cloud via Synapse SDK
  mock.ts      In-process mock — deterministic, zero network
demo/
  agent.ts     Autonomous agent: context offload loop, self-funding, restore
  swarm.ts     Multi-agent swarm with capability delegation
  dashboard/   Real-time React dashboard (Vite + SSE)

Contributing

Pull requests are welcome. For significant changes, open an issue first to discuss the approach. All submissions must pass pnpm test and pnpm build.


License

MIT

About

Persistent memory, self-funded payments, and verifiable actions for AI agents.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors