

























@@ -88,14 +88,16 @@ describe("plugin text transforms", () => {
8888) as unknown as { systemPrompt: string; messages: Array<{ content: unknown[] }> };
89899090expect(context.systemPrompt).toBe("Use pine mailbox inside north tower");
91-expect(context.messages[0]?.content[0]).toMatchObject({
92-type: "text",
93-text: "Please use the blue basket",
94-});
95-expect(context.messages[0]?.content[1]).toMatchObject({
96-type: "image",
97-url: "data:image/png;base64,abc",
98-});
91+const textContent = context.messages[0]?.content[0] as
92+| { type?: string; text?: string }
93+| undefined;
94+expect(textContent?.type).toBe("text");
95+expect(textContent?.text).toBe("Please use the blue basket");
96+const imageContent = context.messages[0]?.content[1] as
97+| { type?: string; url?: string }
98+| undefined;
99+expect(imageContent?.type).toBe("image");
100+expect(imageContent?.url).toBe("data:image/png;base64,abc");
99101});
100102101103it("wraps stream functions with inbound and outbound replacements", async () => {
@@ -147,13 +149,10 @@ describe("plugin text transforms", () => {
147149const result = await stream.result();
148150149151expect(capturedContext?.systemPrompt).toBe("Keep red basket untouched here");
150-expect(capturedContext?.messages).toMatchObject([{ role: "user", content: "Use blue basket" }]);
151-expect(events[0]).toMatchObject({
152-type: "text_delta",
153-delta: "red basket on the left shelf",
154-});
155-expect(result.content).toMatchObject([
156-{ type: "text", text: "final red basket on the left shelf" },
157-]);
152+expect(capturedContext?.messages).toEqual([{ role: "user", content: "Use blue basket" }]);
153+const firstEvent = events[0] as { type?: string; delta?: string } | undefined;
154+expect(firstEvent?.type).toBe("text_delta");
155+expect(firstEvent?.delta).toBe("red basket on the left shelf");
156+expect(result.content).toEqual([{ type: "text", text: "final red basket on the left shelf" }]);
158157});
159158});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。