/** * Wicked Memory in 15 lines. Needs: npm i viem tsx (add @x402/fetch @x402/evm and a wallet holding a * little USDC on Base to pay per search instead of using a key) * * npx tsx quickstart.ts */ import { generatePrivateKey } from "viem/accounts"; import { WickedMemory } from "./wicked-memory"; // curl -O https://memory.wickedapi.com/clients/wicked-memory.ts // Your agent's identity IS its wallet: memories are scoped to it and nobody else can read them. const privateKey = (process.env.AGENT_KEY as `0x${string}`) ?? generatePrivateKey(); const mem = new WickedMemory({ privateKey, apiKey: process.env.WICKED_MEMORY_KEY }); // free community key: see /llms.txt console.log("agent wallet:", mem.address); const saved = await mem.store("The user prefers dark mode and compact tables.", { tags: ["preferences"] }); console.log("stored:", saved.data.id); for (const hit of (await mem.search("what UI does the user like?", { limit: 3 })).data) { console.log(hit.score?.toFixed(2), hit.content); } // Facts change: update never overwrites, it creates a new version and keeps the history. const next = await mem.update(saved.data.id, { content: "The user now prefers light mode and compact tables." }); for (const v of (await mem.history(next.data.current.id)).data) { console.log(v.valid_from, "->", v.valid_until ?? "current", "|", v.content); } await mem.remove(next.data.current.id); // hard delete; only a content-free audit row remains