























@@ -16,6 +16,8 @@ import {
1616type MemoryMultimodalSettings,
1717} from "./multimodal.js";
181819+type FileEntry = NonNullable<Awaited<ReturnType<typeof buildFileEntry>>>;
20+1921let sharedTempRoot = "";
2022let sharedTempId = 0;
2123@@ -38,6 +40,13 @@ function setupTempDirLifecycle(prefix: string): () => string {
3840return () => tmpDir;
3941}
404243+function expectFileEntry(entry: Awaited<ReturnType<typeof buildFileEntry>>): FileEntry {
44+if (!entry) {
45+throw new Error("Expected file entry to be built");
46+}
47+return entry;
48+}
49+4150const multimodal: MemoryMultimodalSettings = {
4251enabled: true,
4352modalities: ["image", "audio"],
@@ -108,15 +117,15 @@ describe("memory host SDK package internals", () => {
108117const imagePath = path.join(tmpDir, "diagram.png");
109118fsSync.writeFileSync(imagePath, Buffer.from("png"));
110119111-const entry = await buildFileEntry(imagePath, tmpDir, multimodal);
112-const built = await buildMultimodalChunkForIndexing(entry!);
120+const entry = expectFileEntry(await buildFileEntry(imagePath, tmpDir, multimodal));
121+const built = await buildMultimodalChunkForIndexing(entry);
113122expect(built?.chunk.embeddingInput?.parts).toEqual([
114123{ type: "text", text: "Image file: diagram.png" },
115124expect.objectContaining({ type: "inline-data", mimeType: "image/png" }),
116125]);
117126118-fsSync.writeFileSync(imagePath, Buffer.alloc(entry!.size + 32, 1));
119-await expect(buildMultimodalChunkForIndexing(entry!)).resolves.toBeNull();
127+fsSync.writeFileSync(imagePath, Buffer.alloc(entry.size + 32, 1));
128+await expect(buildMultimodalChunkForIndexing(entry)).resolves.toBeNull();
120129});
121130122131it("chunks mixed text and preserves surrogate pairs", () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。