Skip to main content

Decentralised AI agent memory SDK — powered by Shelby Protocol and Aptos

Project description

shelmem

License: MIT Python Shelby Testnet

Decentralised AI agent memory SDK for Python.

Store agent memories on Shelby Protocol's decentralised hot storage with on-chain proof via Aptos.

Install

pip install shelmem

Usage

from shelmem import ShelMem

mem = ShelMem(
    supabase_url="https://your-project.supabase.co",
    supabase_key="your-service-role-key",
    shelby_api_key="your-shelby-api-key",        # optional
    aptos_private_key="your-ed25519-private-key", # required when mock=False
    network="testnet",                             # testnet | shelbynet
    mock=True,                                     # default: True
)

write()

Store a memory for an agent. Async method.

result = await mem.write(
    agent_id="agent-001",
    memory="User prefers concise responses",
    context="preferences",
    metadata={"source": "chat"},  # optional
)

print(result.shelby_object_id)  # shelby://...
print(result.aptos_tx_hash)     # 0x...
print(result.timestamp)         # 2025-01-15T10:30:00Z

recall()

Retrieve memories for an agent. Async method.

memories = await mem.recall(
    agent_id="agent-001",
    context="preferences",  # optional
    limit=10,               # optional, default 10
)

for m in memories:
    print(m.memory, m.context, m.timestamp, m.aptos_tx_hash)

delete()

Remove a memory by its Supabase row ID. Synchronous method.

mem.delete("uuid-of-memory-row")

How It Works

  1. write() encodes the memory to UTF-8 bytes, uploads to Shelby via HTTP gateway, records metadata in Supabase, and returns the Shelby address + Aptos proof
  2. recall() queries Supabase metadata by agent_id/context, downloads content bytes from Shelby, and returns decoded strings
  3. Every write produces a shelby:// address and an Aptos transaction hash as cryptographic proof

Mock Mode

By default, mock=True generates deterministic hash-based addresses without network calls. Set mock=False and provide aptos_private_key to write to the live Shelby testnet.

Environment Variables

The SDK reads these if not passed in the constructor:

Variable Description
SHELBY_API_KEY Shelby Protocol API key
SHELBY_ACCOUNT_PRIVATE_KEY Ed25519 private key for signing
SHELBY_NETWORK testnet or shelbynet
SHELBY_MOCK true or false
SUPABASE_URL Supabase project URL
SUPABASE_ANON_KEY Supabase anon/service key

Types

@dataclass
class WriteResult:
    shelby_object_id: str
    aptos_tx_hash: str
    timestamp: str

@dataclass
class MemoryRecord:
    memory: str
    context: str
    timestamp: str
    aptos_tx_hash: str

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shelmem-0.1.0.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

shelmem-0.1.0-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file shelmem-0.1.0.tar.gz.

File metadata

  • Download URL: shelmem-0.1.0.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for shelmem-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e2012c37edcbe25e282add00a97399b301ff8063980cb712b290cfb5cca9b5bc
MD5 8a0bfd0d993013b7c49c811bc0c49a16
BLAKE2b-256 005533e5610b0441a271085355c1b3c34ee04fe970fd653b13753ab9e9b72e10

See more details on using hashes here.

File details

Details for the file shelmem-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: shelmem-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for shelmem-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 516733550e2d8066b71000a6bb6bcb45f714db86e2b52edeb9f15f571de389c9
MD5 3dfa4ee47dd8247fbb0aa1350e1f9046
BLAKE2b-256 bc0fb003973266b08661860155e1421a9e28049a1a867ae136c918662813c1a1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page