TenantVault
All operations are scoped to the tenant ID passed to vault.tenant().
typescript
const tenant = vault.tenant("user-123")Methods
remember(input)
Save a memory.
typescript
await tenant.remember({
content: "Prefers dark mode",
type: "preference", // optional, default: "general"
tags: ["ui", "theme"], // optional
ttl: 3600, // optional, seconds until expiry
})Returns the saved Memory object.
recall(filter?)
Query memories. All filters are optional.
typescript
await tenant.recall()
await tenant.recall({ type: "preference" })
await tenant.recall({ tags: ["shopping"] })
await tenant.recall({ search: "dark mode" })
await tenant.recall({ type: "preference", search: "dark", limit: 5 })
await tenant.recall({ includeExpired: true })Returns Memory[].
get(id)
Get a single memory by ID.
typescript
const memory = await tenant.get("cm...")Returns Memory | null.
update(id, input)
Update an existing memory. Only pass fields you want to change.
typescript
await tenant.update("cm...", { content: "Now prefers light mode" })
await tenant.update("cm...", { tags: ["ui"], ttl: 7200 })Returns the updated Memory.
forget(id)
Delete a memory by ID.
typescript
await tenant.forget("cm...")forgetAll()
Delete all memories for this tenant.
typescript
const count = await tenant.forgetAll() // returns number deletedcount(filter?)
Count memories. Accepts the same filters as recall().
typescript
await tenant.count()
await tenant.count({ type: "preference" })Types
typescript
interface Memory {
id: string
tenantId: string
type: string
content: string
metadata: Record<string, unknown> | null
tags: string[]
createdAt: Date
updatedAt: Date
expiresAt: Date | null
}