claude-memory-layer 1.0.35 → 1.0.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8067,7 +8067,7 @@ var sessionsRouter = new Hono();
8067
8067
  sessionsRouter.get("/", async (c) => {
8068
8068
  const page = parseInt(c.req.query("page") || "1", 10);
8069
8069
  const pageSize = parseInt(c.req.query("pageSize") || "20", 10);
8070
- const memoryService = getServiceFromQuery(c);
8070
+ const memoryService = getLightweightServiceFromQuery(c);
8071
8071
  try {
8072
8072
  await memoryService.initialize();
8073
8073
  const recentEvents = await memoryService.getRecentEvents(1e3);
@@ -8111,7 +8111,7 @@ sessionsRouter.get("/", async (c) => {
8111
8111
  });
8112
8112
  sessionsRouter.get("/:id", async (c) => {
8113
8113
  const { id } = c.req.param();
8114
- const memoryService = getServiceFromQuery(c);
8114
+ const memoryService = getLightweightServiceFromQuery(c);
8115
8115
  try {
8116
8116
  await memoryService.initialize();
8117
8117
  const events = await memoryService.getSessionHistory(id);
@@ -8157,7 +8157,7 @@ eventsRouter.get("/", async (c) => {
8157
8157
  const q = (c.req.query("q") || "").trim().toLowerCase();
8158
8158
  const limit = parseInt(c.req.query("limit") || "100", 10);
8159
8159
  const offset = parseInt(c.req.query("offset") || "0", 10);
8160
- const memoryService = getServiceFromQuery(c);
8160
+ const memoryService = getLightweightServiceFromQuery(c);
8161
8161
  try {
8162
8162
  await memoryService.initialize();
8163
8163
  let events;
@@ -8213,7 +8213,7 @@ eventsRouter.get("/", async (c) => {
8213
8213
  });
8214
8214
  eventsRouter.get("/:id", async (c) => {
8215
8215
  const { id } = c.req.param();
8216
- const memoryService = getServiceFromQuery(c);
8216
+ const memoryService = getLightweightServiceFromQuery(c);
8217
8217
  try {
8218
8218
  await memoryService.initialize();
8219
8219
  const recentEvents = await memoryService.getRecentEvents(1e4);
@@ -8252,6 +8252,10 @@ eventsRouter.get("/:id", async (c) => {
8252
8252
  // src/apps/server/api/search.ts
8253
8253
  import { Hono as Hono3 } from "hono";
8254
8254
  var searchRouter = new Hono3();
8255
+ function isEmbeddingBackendUnavailable(error) {
8256
+ const message = error instanceof Error ? error.message : String(error);
8257
+ return /model file path or buffer|onnxruntime|transformers|embedding backend/i.test(message);
8258
+ }
8255
8259
  searchRouter.post("/", async (c) => {
8256
8260
  const memoryService = getServiceFromQuery(c);
8257
8261
  try {
@@ -8293,15 +8297,41 @@ searchRouter.post("/", async (c) => {
8293
8297
  });
8294
8298
  searchRouter.post("/disclosure", async (c) => {
8295
8299
  let memoryService;
8300
+ let body;
8296
8301
  try {
8297
- const body = await c.req.json();
8302
+ body = await c.req.json();
8298
8303
  if (!body.query) {
8299
8304
  return c.json({ error: "Query is required" }, 400);
8300
8305
  }
8301
- memoryService = body.options?.strategy === "fast" ? getLightweightServiceFromQuery(c) : getServiceFromQuery(c);
8302
- await memoryService.initialize();
8303
- const result = await memoryService.searchDisclosure(body.query, body.options);
8304
- return c.json(result);
8306
+ const useFastStrategy = body.options?.strategy === "fast";
8307
+ memoryService = useFastStrategy ? getLightweightServiceFromQuery(c) : getServiceFromQuery(c);
8308
+ try {
8309
+ await memoryService.initialize();
8310
+ const result = await memoryService.searchDisclosure(body.query, body.options);
8311
+ return c.json(result);
8312
+ } catch (error) {
8313
+ if (!useFastStrategy && isEmbeddingBackendUnavailable(error)) {
8314
+ await memoryService.shutdown();
8315
+ memoryService = getLightweightServiceFromQuery(c);
8316
+ await memoryService.initialize();
8317
+ const result = await memoryService.searchDisclosure(body.query, {
8318
+ ...body.options,
8319
+ strategy: "fast"
8320
+ });
8321
+ return c.json({
8322
+ ...result,
8323
+ meta: {
8324
+ ...result.meta,
8325
+ fallbackApplied: true,
8326
+ fallbackTrace: [
8327
+ ...result.meta.fallbackTrace || [],
8328
+ "fallback:embedding-backend-unavailable:fast"
8329
+ ]
8330
+ }
8331
+ });
8332
+ }
8333
+ throw error;
8334
+ }
8305
8335
  } catch (error) {
8306
8336
  return c.json({ error: error.message }, 500);
8307
8337
  } finally {
@@ -8309,7 +8339,7 @@ searchRouter.post("/disclosure", async (c) => {
8309
8339
  }
8310
8340
  });
8311
8341
  searchRouter.get("/disclosure/:resultId/expand", async (c) => {
8312
- const memoryService = getServiceFromQuery(c);
8342
+ const memoryService = getLightweightServiceFromQuery(c);
8313
8343
  try {
8314
8344
  const resultId = c.req.param("resultId");
8315
8345
  const rawWindowSize = c.req.query("windowSize");
@@ -8329,7 +8359,7 @@ searchRouter.get("/disclosure/:resultId/expand", async (c) => {
8329
8359
  }
8330
8360
  });
8331
8361
  searchRouter.get("/disclosure/:resultId/source", async (c) => {
8332
- const memoryService = getServiceFromQuery(c);
8362
+ const memoryService = getLightweightServiceFromQuery(c);
8333
8363
  try {
8334
8364
  const resultId = c.req.param("resultId");
8335
8365
  const result = await memoryService.sourceDisclosure(resultId);