feat(api): local HTTP/REST API for memory (#85) - #122
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThis PR introduces a complete local HTTP/REST API for taOSmd memory operations. It adds a reusable async service layer that wraps the underlying API, a stdlib-only HTTP server with background asyncio concurrency, CLI integration via a ChangesLocal HTTP/REST API
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Possibly related PRs
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Adds a local HTTP/REST activation surface for taOSmd memory, plus a small shared service layer the upcoming MCP server (#84) reuses. This addresses the "API/HTTP is WIP" gap noted in memory-landscape comparisons.
Endpoints
GET /health->{"status":"ok","version"}POST /ingest{text, agent}-> ingest result ({archived, agent, data_dir})POST /search{query, agent, limit?}->{"hits":[...]}GET /search?q=&agent=&limit=->{"hits":[...]}GET /pending?agent=->{"pending":[...]}POST /pending/resolve{id, decision, note?}-> resolve resultErrors return JSON with the right status: 400 (bad input / malformed JSON), 404 (unknown route), 500 (unhandled, with message).
Design
http.server.ThreadingHTTPServer+BaseHTTPRequestHandler,json,threading. Nothing added to requirements.127.0.0.1by default (localhost only). Pass--host 0.0.0.0to expose on the LAN. No auth: fine on localhost (any local process already has the Python API); gate it yourself if you bind to a routable address. The startup banner says which mode is active.taosmd serve. Python API, CLI, and standalone use are unchanged.agentand forwards it to the service layer, honouring the same isolation as the Python API.taosmd/service.pywrapstaosmd.apiinto adapter-agnostic functions (ingest,search,pending_list,pending_resolve,stats). It reuses_ensure_stores/ the stores cache /TAOSMD_DATA_DIRhandling so behaviour matches the Python API exactly. The MCP server (Add MCP server interface for memory (retrieve / ingest / review) #84) sits on the same core.asyncio.runper request, all async service calls are dispatched onto one long-lived background event-loop thread. Every DB op runs in a single context, sequentially, like the single-threaded Python API.CLI
taosmd serve --host 127.0.0.1 --port 7833 [--serve-data-dir ...]Tests
tests/test_http_server.py(8 tests): boots the server on an ephemeral port in a thread with an isolated tmp data dir and a patched embedder (offline, no model). Covers health, ingest->search round-trip, GET-style search, 400 on bad JSON, 400 on missing field, 404 on unknown route, empty pending, and bad pending-resolve input. Full suite: 319 passed.Closes #85
Summary by CodeRabbit