Pre-launch — Gluecron is in final validation. Public signups and git hosting for non-owner users open after launch review.
CodeIssuesPull RequestsActionsSecurityInsightsSettings
✨ AI
More
Blame · Line-by-line history

memory.ts

Each line is annotated with the commit that last touched it. Click any SHA to jump to that commit and see the surrounding change.

memory.tsBlame50 lines · 1 contributor
d0bc8c2Claude1/**
2 * Memory API routes — read/write platform memory for AI continuity.
3 *
4 * These endpoints let the AI subsystem (and admin tools) persist and
5 * retrieve learned context across sessions and requests.
6 */
7
8import { Hono } from "hono";
9import { requireAuth } from "../middleware/auth";
10import type { AuthEnv } from "../middleware/auth";
11import { memoryStore, memoryRecall, memorySummary } from "../lib/memory";
12
13const memory = new Hono<AuthEnv>();
14
15memory.get("/api/memory/recall", requireAuth, async (c) => {
16 const query = c.req.query("q") || "*";
17 const category = c.req.query("category");
18 const limit = parseInt(c.req.query("limit") || "10", 10);
19
20 const results = await memoryRecall(query, { category, limit });
21 return c.json({ results });
22});
23
24memory.post("/api/memory/store", requireAuth, async (c) => {
25 const body = await c.req.json().catch(() => ({}));
26 const { key, value, category, confidence, scope, language } = body as Record<
27 string,
28 string | number | undefined
29 >;
30
31 if (!key || !value) {
32 return c.json({ error: "key and value are required" }, 400);
33 }
34
35 await memoryStore(String(key), String(value), {
36 category: category ? String(category) : undefined,
37 confidence: typeof confidence === "number" ? confidence : undefined,
38 scope: scope ? String(scope) : undefined,
39 language: language ? String(language) : undefined,
40 });
41
42 return c.json({ stored: true });
43});
44
45memory.get("/api/memory/summary", requireAuth, async (c) => {
46 const summary = await memorySummary();
47 return c.json({ summary });
48});
49
50export default memory;