diff --git a/src/triggers/api.ts b/src/triggers/api.ts index 3c993f5..d4bd5f9 100644 --- a/src/triggers/api.ts +++ b/src/triggers/api.ts @@ -1323,7 +1323,7 @@ export function registerApiTriggers( config: { api_path: "/agentmemory/snapshot/restore", http_method: "POST" }, }); - sdk.registerFunction("api::memories", + sdk.registerFunction("api::memories", async (req: ApiRequest): Promise => { const authErr = checkAuth(req, secret); if (authErr) return authErr; @@ -1339,6 +1339,27 @@ export function registerApiTriggers( config: { api_path: "/agentmemory/memories", http_method: "GET" }, }); + sdk.registerFunction("api::memory-by-id", + async (req: ApiRequest): Promise => { + const authErr = checkAuth(req, secret); + if (authErr) return authErr; + const id = req.path_params?.["id"]; + if (!id || typeof id !== "string") { + return { status_code: 400, body: { error: "id path parameter is required" } }; + } + const memory = await kv.get(KV.memories, id); + if (!memory) { + return { status_code: 404, body: { error: `memory not found: ${id}` } }; + } + return { status_code: 200, body: { memory } }; + }, + ); + sdk.registerTrigger({ + type: "http", + function_id: "api::memory-by-id", + config: { api_path: "/agentmemory/memories/:id", http_method: "GET" }, + }); + sdk.registerFunction("api::semantic-list", async (req: ApiRequest): Promise => { const authErr = checkAuth(req, secret);