From bf1a8eebbaea1e5b199aa2f29aa85cee59d7a830 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Wed, 29 Apr 2026 13:25:34 +0100 Subject: [PATCH] fix(memory): preserve dreams path bridge behavior --- .../memory-host-sdk/src/host/internal.test.ts | 4 +-- packages/memory-host-sdk/src/host/internal.ts | 2 +- .../host/backend-config.test.ts | 9 +++++- .../host/embeddings-remote-fetch.test.ts | 29 ++++++++++++++++++- src/memory-host-sdk/host/post-json.test.ts | 27 ++++++++++++++++- 5 files changed, 65 insertions(+), 6 deletions(-) diff --git a/packages/memory-host-sdk/src/host/internal.test.ts b/packages/memory-host-sdk/src/host/internal.test.ts index 3222d6d3197..ad10444ec0f 100644 --- a/packages/memory-host-sdk/src/host/internal.test.ts +++ b/packages/memory-host-sdk/src/host/internal.test.ts @@ -78,9 +78,9 @@ describe("memory host SDK package internals", () => { ]); }); - it("keeps package-specific dreams path casing", () => { + it("allows top-level dreams path casing variants", () => { expect(isMemoryPath("dreams.md")).toBe(true); - expect(isMemoryPath("DREAMS.md")).toBe(false); + expect(isMemoryPath("DREAMS.md")).toBe(true); }); it("builds markdown and multimodal file entries", async () => { diff --git a/packages/memory-host-sdk/src/host/internal.ts b/packages/memory-host-sdk/src/host/internal.ts index 4357ef6a9dc..162cac93d64 100644 --- a/packages/memory-host-sdk/src/host/internal.ts +++ b/packages/memory-host-sdk/src/host/internal.ts @@ -88,7 +88,7 @@ export function isMemoryPath(relPath: string): boolean { if (!normalized) { return false; } - if (normalized === CANONICAL_ROOT_MEMORY_FILENAME || normalized === "dreams.md") { + if (normalized === CANONICAL_ROOT_MEMORY_FILENAME || normalized.toLowerCase() === "dreams.md") { return true; } return normalized.startsWith("memory/"); diff --git a/src/memory-host-sdk/host/backend-config.test.ts b/src/memory-host-sdk/host/backend-config.test.ts index d0abfb71d68..2fdf3156caf 100644 --- a/src/memory-host-sdk/host/backend-config.test.ts +++ b/src/memory-host-sdk/host/backend-config.test.ts @@ -1 +1,8 @@ -import "../../../packages/memory-host-sdk/src/host/backend-config.test.js"; +import { describe, expect, it } from "vitest"; +import { resolveMemoryBackendConfig } from "./backend-config.js"; + +describe("memory-host-sdk backend-config bridge", () => { + it("exports the package-owned backend resolver", () => { + expect(resolveMemoryBackendConfig).toEqual(expect.any(Function)); + }); +}); diff --git a/src/memory-host-sdk/host/embeddings-remote-fetch.test.ts b/src/memory-host-sdk/host/embeddings-remote-fetch.test.ts index e8e412994c7..cf8fa4d5c3e 100644 --- a/src/memory-host-sdk/host/embeddings-remote-fetch.test.ts +++ b/src/memory-host-sdk/host/embeddings-remote-fetch.test.ts @@ -1 +1,28 @@ -import "../../../packages/memory-host-sdk/src/host/embeddings-remote-fetch.test.js"; +import { describe, expect, it, vi } from "vitest"; +import { fetchRemoteEmbeddingVectors } from "./embeddings-remote-fetch.js"; + +describe("fetchRemoteEmbeddingVectors", () => { + it("maps remote embedding response data through an injected fetch", async () => { + const fetchImpl = vi.fn( + async () => + new Response( + JSON.stringify({ data: [{ embedding: [0.1, 0.2] }, {}, { embedding: [0.3] }] }), + { + status: 200, + headers: { "content-type": "application/json" }, + }, + ), + ) as typeof fetch; + + const vectors = await fetchRemoteEmbeddingVectors({ + url: "https://example.com/v1/embeddings", + headers: { Authorization: "Bearer test" }, + ssrfPolicy: { allowedHostnames: ["example.com"] }, + fetchImpl, + body: { input: ["one", "two", "three"] }, + errorPrefix: "embedding fetch failed", + }); + + expect(vectors).toEqual([[0.1, 0.2], [], [0.3]]); + }); +}); diff --git a/src/memory-host-sdk/host/post-json.test.ts b/src/memory-host-sdk/host/post-json.test.ts index 0ecaafff39e..a29b2389908 100644 --- a/src/memory-host-sdk/host/post-json.test.ts +++ b/src/memory-host-sdk/host/post-json.test.ts @@ -1 +1,26 @@ -import "../../../packages/memory-host-sdk/src/host/post-json.test.js"; +import { describe, expect, it, vi } from "vitest"; +import { postJson } from "./post-json.js"; + +describe("postJson", () => { + it("parses JSON from an injected fetch response", async () => { + const fetchImpl = vi.fn( + async () => + new Response(JSON.stringify({ ok: true }), { + status: 200, + headers: { "content-type": "application/json" }, + }), + ) as typeof fetch; + + const result = await postJson({ + url: "https://example.com/v1/post", + headers: { Authorization: "Bearer test" }, + ssrfPolicy: { allowedHostnames: ["example.com"] }, + fetchImpl, + body: { input: ["x"] }, + errorPrefix: "post failed", + parse: (payload) => payload, + }); + + expect(result).toEqual({ ok: true }); + }); +});