mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 05:20:43 +00:00
fix(memory): preserve dreams path bridge behavior
This commit is contained in:
@@ -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 () => {
|
||||
|
||||
@@ -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/");
|
||||
|
||||
@@ -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));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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]]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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 });
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user