fix(memory): preserve dreams path bridge behavior · openclaw/openclaw@bf1a8ee
steipete
·
2026-04-29
·
via Recent Commits to openclaw:main
File tree
packages/memory-host-sdk/src/host
| Original file line number | Diff line number | Diff line change |
|---|
@@ -78,9 +78,9 @@ describe("memory host SDK package internals", () => {
|
78 | 78 | ]); |
79 | 79 | }); |
80 | 80 | |
81 | | -it("keeps package-specific dreams path casing", () => { |
| 81 | +it("allows top-level dreams path casing variants", () => { |
82 | 82 | expect(isMemoryPath("dreams.md")).toBe(true); |
83 | | -expect(isMemoryPath("DREAMS.md")).toBe(false); |
| 83 | +expect(isMemoryPath("DREAMS.md")).toBe(true); |
84 | 84 | }); |
85 | 85 | |
86 | 86 | it("builds markdown and multimodal file entries", async () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -88,7 +88,7 @@ export function isMemoryPath(relPath: string): boolean {
|
88 | 88 | if (!normalized) { |
89 | 89 | return false; |
90 | 90 | } |
91 | | -if (normalized === CANONICAL_ROOT_MEMORY_FILENAME || normalized === "dreams.md") { |
| 91 | +if (normalized === CANONICAL_ROOT_MEMORY_FILENAME || normalized.toLowerCase() === "dreams.md") { |
92 | 92 | return true; |
93 | 93 | } |
94 | 94 | return normalized.startsWith("memory/"); |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | | -import "../../../packages/memory-host-sdk/src/host/backend-config.test.js"; |
| 1 | +import { describe, expect, it } from "vitest"; |
| 2 | +import { resolveMemoryBackendConfig } from "./backend-config.js"; |
| 3 | + |
| 4 | +describe("memory-host-sdk backend-config bridge", () => { |
| 5 | +it("exports the package-owned backend resolver", () => { |
| 6 | +expect(resolveMemoryBackendConfig).toEqual(expect.any(Function)); |
| 7 | +}); |
| 8 | +}); |
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | | -import "../../../packages/memory-host-sdk/src/host/embeddings-remote-fetch.test.js"; |
| 1 | +import { describe, expect, it, vi } from "vitest"; |
| 2 | +import { fetchRemoteEmbeddingVectors } from "./embeddings-remote-fetch.js"; |
| 3 | + |
| 4 | +describe("fetchRemoteEmbeddingVectors", () => { |
| 5 | +it("maps remote embedding response data through an injected fetch", async () => { |
| 6 | +const fetchImpl = vi.fn( |
| 7 | +async () => |
| 8 | +new Response( |
| 9 | +JSON.stringify({ data: [{ embedding: [0.1, 0.2] }, {}, { embedding: [0.3] }] }), |
| 10 | +{ |
| 11 | +status: 200, |
| 12 | +headers: { "content-type": "application/json" }, |
| 13 | +}, |
| 14 | +), |
| 15 | +) as typeof fetch; |
| 16 | + |
| 17 | +const vectors = await fetchRemoteEmbeddingVectors({ |
| 18 | +url: "https://example.com/v1/embeddings", |
| 19 | +headers: { Authorization: "Bearer test" }, |
| 20 | +ssrfPolicy: { allowedHostnames: ["example.com"] }, |
| 21 | + fetchImpl, |
| 22 | +body: { input: ["one", "two", "three"] }, |
| 23 | +errorPrefix: "embedding fetch failed", |
| 24 | +}); |
| 25 | + |
| 26 | +expect(vectors).toEqual([[0.1, 0.2], [], [0.3]]); |
| 27 | +}); |
| 28 | +}); |
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | | -import "../../../packages/memory-host-sdk/src/host/post-json.test.js"; |
| 1 | +import { describe, expect, it, vi } from "vitest"; |
| 2 | +import { postJson } from "./post-json.js"; |
| 3 | + |
| 4 | +describe("postJson", () => { |
| 5 | +it("parses JSON from an injected fetch response", async () => { |
| 6 | +const fetchImpl = vi.fn( |
| 7 | +async () => |
| 8 | +new Response(JSON.stringify({ ok: true }), { |
| 9 | +status: 200, |
| 10 | +headers: { "content-type": "application/json" }, |
| 11 | +}), |
| 12 | +) as typeof fetch; |
| 13 | + |
| 14 | +const result = await postJson({ |
| 15 | +url: "https://example.com/v1/post", |
| 16 | +headers: { Authorization: "Bearer test" }, |
| 17 | +ssrfPolicy: { allowedHostnames: ["example.com"] }, |
| 18 | + fetchImpl, |
| 19 | +body: { input: ["x"] }, |
| 20 | +errorPrefix: "post failed", |
| 21 | +parse: (payload) => payload, |
| 22 | +}); |
| 23 | + |
| 24 | +expect(result).toEqual({ ok: true }); |
| 25 | +}); |
| 26 | +}); |
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。