fix(memory): preserve dreams path bridge behavior

This commit is contained in:
Peter Steinberger
2026-04-29 13:25:34 +01:00
parent bea75406bb
commit bf1a8eebba
5 changed files with 65 additions and 6 deletions

View File

@@ -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 () => {

View File

@@ -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/");

View File

@@ -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));
});
});

View File

@@ -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]]);
});
});

View File

@@ -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 });
});
});