cm-memory

Overview

cm-memory is a personal memory storage service. It stores memories from various sources (phone screenshots, bookmarks, watch notes, social media), and uses an AI vision model to generate titles, descriptions, and tags. Runs on port 5003.

Authentication: When API_TOKEN is set, all write endpoints (POST/PUT/DELETE) require Authorization: Bearer <token>.

Memory Endpoints

GET /memories

List all memories. Supports search and filtering.

ParamDefaultDescription
qFull-text search across title, description, content, reference
sourceFilter by created_from value
processed0 = unprocessed, 1 = processed, blank = all
page1Page number (20 per page)
GET /memories/<id>

View a single memory with all fields and screenshot.

POST /add-memory

Create a new memory.

Request

{
  "created_by": "mart",           // required
  "created_from": "manual",       // required — see valid values below
  "reference": "https://...",     // optional URL
  "text": "Some text",             // optional
  "images": ["<base64>"],  // optional — JSON array of base64-encoded images
  "audio": "<base64 m4a>", // optional — base64 audio recording
  "people": ["mart", "john"],     // optional — associated people
  "location": "45.50,-73.57",     // optional — GPS coords or place name
  "status": "pending",            // optional — for todos: pending/done/cancelled
  "notifications": ["2026-04-01T09:00:00Z"], // optional — reminder datetimes
  "memory_refs": ["uuid-1"]       // optional — linked memory IDs
}

Common created_from values (any string accepted)

phone_screenshot · phone_url · raindrop · watch · manual · web_clip · twitter · reddit · note · interaction · todo · iphone_status

Response

{ "id": "uuid", "created_at": "2025-01-01T00:00:00+00:00" }
PUT /memories/<id>

Update one or more fields of a memory. Updatable fields: created_by, created_from, reference, text, ai_summary, ai_tags, ai_title, images, ai_processed, ai_processed_at, ai_error, tags, people, location, notifications, status, memory_refs, audio, ai_audio_transcription, ai_image_description.

Response

{ "updated": true, "id": "uuid" }
DELETE /memories/<id>

Permanently delete a memory.

Response

{ "deleted": true, "id": "uuid" }
GET /images/<memory_id>/<filename>

Serve an image file attached to a memory.

GET /audio/<memory_id>/<filename>

Serve an audio file attached to a memory.

AI Processing

GET /compute

View pending memory count and error list.

POST /compute

AI-process up to limit unprocessed memories. Delegates to cm-ai-router for transcription, image description, and analysis. Generates ai_title, ai_summary, and ai_tags.

Request

{ "limit": 10 }  // optional, default 10, max 50

Response

{ "processed": 8, "errors": [{ "id": "uuid", "error": "..." }] }
POST /compute/reset-errors

Reset all memories with ai_error back to unprocessed so they can be retried.

Response

{ "reset": 3 }

Imports

POST /import_raindrop

Fetch new bookmarks from Raindrop.io API. Requires RAINDROP_TOKEN env var.

Response

{ "imported": 12 }
POST /import_reddit

Scrape Reddit saved posts via cm-ai-router Playwright. Requires AI_ROUTER_URL and REDDIT_USERNAME. Browser session in ai-router must be logged in to Reddit.

Response

{ "imported": 5 }
POST /import_twitter

Scrape X/Twitter bookmarks via cm-ai-router Playwright. Requires AI_ROUTER_URL. Browser session in ai-router must be logged in to Twitter/X.

Response

{ "imported": 7 }

Query

POST /query

Run a read-only SQL query against the memories table. Only SELECT statements allowed. Designed for LLMs and external tools to search and analyze memory data.

Request

{
  "sql": "SELECT id, ai_title, status FROM memories WHERE status = ?",
  "params": ["pending"]
}

Response

{
  "columns": ["id", "ai_title", "status"],
  "rows": [{"id": "uuid", "ai_title": "Buy groceries", "status": "pending"}],
  "count": 1
}
Security: Only SELECT queries are allowed. INSERT, UPDATE, DELETE, DROP, ALTER, CREATE, and other write operations are rejected. Max 1000 rows returned.

Utility

GET /history

View request audit log.

ParamDefaultDescription
formathtmlSet to json for JSON output
limit50Max rows (JSON mode)
offset0Skip rows (JSON mode)

Environment Variables

VariableRequiredDescription
API_TOKENNoBearer token for write endpoint auth
AI_ROUTER_URLRequired for computeURL of cm-ai-router for transcription, image description, and analysis
AI_ROUTER_TOKENNoBearer token for cm-ai-router
RAINDROP_TOKENNoRaindrop.io API token
REDDIT_USERNAMENoReddit username for saved posts URL
PORTNoServer port (default: 5003)