Index of every page on this site: llms.txt
All skills
mystenlabs avatar

/walrus-memory

@4d8aa0b
Run it yourself

Walrus Memory (MemWal) — persistent, portable, encrypted memory for AI agents. Use when the user needs to give an AI agent persistent memory across sessions and apps, integrate the @mysten-incubation/memwal TypeScript SDK or Python memwal SDK, set up the Walrus Memory MCP server for Cursor/Claude/Codex, configure remember/recall/analyze/restore operations, manage memory spaces and namespaces, set up delegate keys and accounts, self-host the relayer, or use withMemWal AI middleware (Vercel AI SDK, LangChain, OpenAI SDK). Also use when the user asks about MemWal, Walrus Memory, agent memory, memory spaces, or the memwal-mcp package.

Use this Skill: https://skilld.dev/gh/mystenlabs/walrus-skills/walrus-memory

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

ts-sdk.md

≈2k tokens on demand. Your agent reads this file only when SKILL.md points to it.

TypeScript SDK Reference

Source: https://docs.wal.app/walrus-memory/sdk

The @mysten-incubation/memwal package provides three entry points for integrating Walrus Memory into TypeScript applications.

Entry points

Entry point Import When to use
MemWal @mysten-incubation/memwal Recommended default. Relayer handles embeddings, Seal, and storage.
MemWalManual @mysten-incubation/memwal/manual Client-managed embeddings and local Seal operations. Relayer never sees plaintext.
withMemWal @mysten-incubation/memwal/ai Vercel AI SDK middleware. Auto-recall before generation, auto-save after.

Installation

npm install @mysten-incubation/memwal

For MemWalManual, also install peer dependencies:

npm install @mysten/sui @mysten/seal @mysten/walrus

For withMemWal, also install:

npm install ai zod

MemWal (default client)

Configuration

import { MemWal } from "@mysten-incubation/memwal";

const memwal = MemWal.create({
  key: "<ed25519-private-key-hex>",      // required
  accountId: "<memwal-account-object-id>", // required
  serverUrl: "https://relayer.memory.walrus.xyz", // optional, defaults to managed relayer
  namespace: "my-app",                    // optional, defaults to "default"
});
Property Type Required Default Description
key string Yes Ed25519 delegate private key in hex
accountId string Yes MemWalAccount object ID on Sui
serverUrl string No https://relayer.memory.walrus.xyz Relayer URL
namespace string No "default" Default namespace for memory isolation

Core methods

remember(text, namespace?)

Store a memory. Returns immediately with a job ID (async processing).

const job = await memwal.remember("User prefers dark mode.");
// job = { job_id: "...", status: "running" }
rememberAndWait(text, namespace?, opts?)

Store and wait until the job completes.

const result = await memwal.rememberAndWait("User prefers dark mode.");
// result = { id, job_id, blob_id, owner, namespace }
waitForRememberJob(jobId, opts?)

Poll a previously accepted job until done or failed.

const result = await memwal.waitForRememberJob(job.job_id);
rememberBulk(items)

Submit up to 20 memories in one request. Returns accepted job IDs.

const bulk = await memwal.rememberBulk([
  { text: "Fact 1", namespace: "demo" },
  { text: "Fact 2" },
]);
// bulk = { job_ids: [...], total: 2, status: "running" }
rememberBulkAndWait(items, opts?)

Submit bulk and wait for all jobs to complete.

recall(params)

Search for memories by natural language query.

const result = await memwal.recall({
  query: "What does this user prefer?",
  limit: 5,           // default: 10, alias: topK
  namespace: "my-app", // optional, uses default
  maxDistance: 0.5,    // optional, filters weak matches
});

for (const memory of result.results) {
  console.log(memory.text, memory.distance);
  // distance is cosine distance: lower = more similar
}

RecallParams:

Property Type Default Description
query string required Natural language search query
limit number 10 Max results to return. The server caps it at 100
topK number Alias for limit (wins when both set)
namespace string client default Memory space to search
maxDistance number Drop results with distance >= this value
scoringWeights ScoringWeights Optional composite ranking: blend semantic distance with recency and importance. Omit for plain cosine-distance order
analyze(text, namespace?)

Extract memorable facts from text using an LLM, then store each as a separate memory.

const analyzed = await memwal.analyze(
  "I live in Hanoi, prefer dark mode, and usually work late at night."
);
// analyzed = { job_ids: [...], facts: [...], fact_count: 3, status: "pending" }

Use analyzeAndWait() to wait for all fact jobs to complete.

restore(namespace, limit?)

Rebuild missing vector entries from Walrus for a namespace. Incremental and idempotent.

const result = await memwal.restore("my-app", 50);
// result = { restored: 12, skipped: 38, total: 50, namespace, owner }
health()

Check relayer connectivity. Does not require authentication.

await memwal.health();
compatibility()

Fetch and validate relayer version metadata from /version. Raises MemWalCompatibilityError if the SDK/relayer pair is unsupported.

Lower-level methods

Method Description
rememberManual({ blobId, vector, namespace? }) Register a pre-uploaded blob with a pre-computed vector
recallManual({ vector, limit?, namespace? }) Search with a pre-computed vector (returns blob IDs, no decryption)
embed(text) Generate an embedding vector without storing
getPublicKeyHex() Get hex-encoded public key for the delegate key

MemWalManual

Client-side encryption and embedding. The relayer never sees plaintext.

import { MemWalManual } from "@mysten-incubation/memwal/manual";
  • rememberManual(text, namespace?) — embed locally, Seal encrypt locally, send encrypted payload to relayer
  • recallManual(query, limit?, namespace?) — embed locally, search via relayer, download from Walrus, decrypt locally
  • restore(namespace, limit?) — same as MemWal.restore()

Requires @mysten/sui, @mysten/seal, and @mysten/walrus as peer dependencies.

withMemWal (Vercel AI SDK middleware)

Wraps a Vercel AI SDK model with automatic memory recall and save.

import { generateText } from "ai";
import { withMemWal } from "@mysten-incubation/memwal/ai";
import { openai } from "@ai-sdk/openai";

const model = withMemWal(openai("gpt-4o"), {
  key: process.env.MEMWAL_PRIVATE_KEY!,
  accountId: process.env.MEMWAL_ACCOUNT_ID!,
  serverUrl: process.env.MEMWAL_SERVER_URL,
  namespace: "chatbot-prod",
  maxMemories: 5,    // max memories injected per request (default: 5)
  autoSave: true,    // auto-save facts from conversation (default: true)
  minRelevance: 0.3, // minimum similarity to include (default: 0.3)
});

const result = await generateText({
  model,
  messages: [{ role: "user", content: "What do you know about me?" }],
});

Before generation: reads last user message, runs recall(), filters by minRelevance, injects as system message.

After generation: optionally runs analyze() on user message, saves facts asynchronously.

Account management

import {
  createAccount,
  addDelegateKey,
  removeDelegateKey,
  generateDelegateKey,
} from "@mysten-incubation/memwal/account";
Function Description
generateDelegateKey() Generate new Ed25519 keypair (returns privateKey, publicKey, suiAddress)
createAccount(opts) Create a MemWalAccount onchain (one per Sui address)
addDelegateKey(opts) Add a delegate key to an account (owner only, max 20)
removeDelegateKey(opts) Remove a delegate key from an account (owner only)

Utility functions

import { delegateKeyToSuiAddress, delegateKeyToPublicKey } from "@mysten-incubation/memwal";
Function Description
delegateKeyToSuiAddress(privateKeyHex) Derive Sui address from a delegate private key
delegateKeyToPublicKey(privateKeyHex) Get 32-byte public key from a delegate private key

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts1mo3 checks · Risk SAFE
  • Gen Agent Trust Hub1mo

    This skill provides instructions and references for integrating Walrus Memory, a decentralized and encrypted storage solution for AI agent persistence. It includes setup guides for TypeScript and Python SDKs, as well as a Model Context Protocol (MCP) server. The main security consideration is the inherent attack surface for indirect prompt injection common to agent memory systems.

  • Socket1mo

    No alerts

  • Snyk1mo

    Risk: LOW · No issues

Signed by skilld at 4d8aa0b. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last month.

Steadyupdated 4 months ago

README badge

README badge for mystenlabs/walrus-skills/walrus-memory