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.
@@ -8079,7 +8079,7 @@ var sessionsRouter = new Hono();
8079
8079
  sessionsRouter.get("/", async (c) => {
8080
8080
  const page = parseInt(c.req.query("page") || "1", 10);
8081
8081
  const pageSize = parseInt(c.req.query("pageSize") || "20", 10);
8082
- const memoryService = getServiceFromQuery(c);
8082
+ const memoryService = getLightweightServiceFromQuery(c);
8083
8083
  try {
8084
8084
  await memoryService.initialize();
8085
8085
  const recentEvents = await memoryService.getRecentEvents(1e3);
@@ -8123,7 +8123,7 @@ sessionsRouter.get("/", async (c) => {
8123
8123
  });
8124
8124
  sessionsRouter.get("/:id", async (c) => {
8125
8125
  const { id } = c.req.param();
8126
- const memoryService = getServiceFromQuery(c);
8126
+ const memoryService = getLightweightServiceFromQuery(c);
8127
8127
  try {
8128
8128
  await memoryService.initialize();
8129
8129
  const events = await memoryService.getSessionHistory(id);
@@ -8169,7 +8169,7 @@ eventsRouter.get("/", async (c) => {
8169
8169
  const q = (c.req.query("q") || "").trim().toLowerCase();
8170
8170
  const limit = parseInt(c.req.query("limit") || "100", 10);
8171
8171
  const offset = parseInt(c.req.query("offset") || "0", 10);
8172
- const memoryService = getServiceFromQuery(c);
8172
+ const memoryService = getLightweightServiceFromQuery(c);
8173
8173
  try {
8174
8174
  await memoryService.initialize();
8175
8175
  let events;
@@ -8225,7 +8225,7 @@ eventsRouter.get("/", async (c) => {
8225
8225
  });
8226
8226
  eventsRouter.get("/:id", async (c) => {
8227
8227
  const { id } = c.req.param();
8228
- const memoryService = getServiceFromQuery(c);
8228
+ const memoryService = getLightweightServiceFromQuery(c);
8229
8229
  try {
8230
8230
  await memoryService.initialize();
8231
8231
  const recentEvents = await memoryService.getRecentEvents(1e4);
@@ -8264,6 +8264,10 @@ eventsRouter.get("/:id", async (c) => {
8264
8264
  // src/apps/server/api/search.ts
8265
8265
  import { Hono as Hono3 } from "hono";
8266
8266
  var searchRouter = new Hono3();
8267
+ function isEmbeddingBackendUnavailable(error) {
8268
+ const message = error instanceof Error ? error.message : String(error);
8269
+ return /model file path or buffer|onnxruntime|transformers|embedding backend/i.test(message);
8270
+ }
8267
8271
  searchRouter.post("/", async (c) => {
8268
8272
  const memoryService = getServiceFromQuery(c);
8269
8273
  try {
@@ -8305,15 +8309,41 @@ searchRouter.post("/", async (c) => {
8305
8309
  });
8306
8310
  searchRouter.post("/disclosure", async (c) => {
8307
8311
  let memoryService;
8312
+ let body;
8308
8313
  try {
8309
- const body = await c.req.json();
8314
+ body = await c.req.json();
8310
8315
  if (!body.query) {
8311
8316
  return c.json({ error: "Query is required" }, 400);
8312
8317
  }
8313
- memoryService = body.options?.strategy === "fast" ? getLightweightServiceFromQuery(c) : getServiceFromQuery(c);
8314
- await memoryService.initialize();
8315
- const result = await memoryService.searchDisclosure(body.query, body.options);
8316
- return c.json(result);
8318
+ const useFastStrategy = body.options?.strategy === "fast";
8319
+ memoryService = useFastStrategy ? getLightweightServiceFromQuery(c) : getServiceFromQuery(c);
8320
+ try {
8321
+ await memoryService.initialize();
8322
+ const result = await memoryService.searchDisclosure(body.query, body.options);
8323
+ return c.json(result);
8324
+ } catch (error) {
8325
+ if (!useFastStrategy && isEmbeddingBackendUnavailable(error)) {
8326
+ await memoryService.shutdown();
8327
+ memoryService = getLightweightServiceFromQuery(c);
8328
+ await memoryService.initialize();
8329
+ const result = await memoryService.searchDisclosure(body.query, {
8330
+ ...body.options,
8331
+ strategy: "fast"
8332
+ });
8333
+ return c.json({
8334
+ ...result,
8335
+ meta: {
8336
+ ...result.meta,
8337
+ fallbackApplied: true,
8338
+ fallbackTrace: [
8339
+ ...result.meta.fallbackTrace || [],
8340
+ "fallback:embedding-backend-unavailable:fast"
8341
+ ]
8342
+ }
8343
+ });
8344
+ }
8345
+ throw error;
8346
+ }
8317
8347
  } catch (error) {
8318
8348
  return c.json({ error: error.message }, 500);
8319
8349
  } finally {
@@ -8321,7 +8351,7 @@ searchRouter.post("/disclosure", async (c) => {
8321
8351
  }
8322
8352
  });
8323
8353
  searchRouter.get("/disclosure/:resultId/expand", async (c) => {
8324
- const memoryService = getServiceFromQuery(c);
8354
+ const memoryService = getLightweightServiceFromQuery(c);
8325
8355
  try {
8326
8356
  const resultId = c.req.param("resultId");
8327
8357
  const rawWindowSize = c.req.query("windowSize");
@@ -8341,7 +8371,7 @@ searchRouter.get("/disclosure/:resultId/expand", async (c) => {
8341
8371
  }
8342
8372
  });
8343
8373
  searchRouter.get("/disclosure/:resultId/source", async (c) => {
8344
- const memoryService = getServiceFromQuery(c);
8374
+ const memoryService = getLightweightServiceFromQuery(c);
8345
8375
  try {
8346
8376
  const resultId = c.req.param("resultId");
8347
8377
  const result = await memoryService.sourceDisclosure(resultId);