@@ -10,7 +10,6 @@ import { describe, expect, it } from "vitest";
|
10 | 10 | import { |
11 | 11 | applyPluginTextReplacements, |
12 | 12 | mergePluginTextTransforms, |
13 | | -transformStreamContextText, |
14 | 13 | wrapStreamFnTextTransforms, |
15 | 14 | } from "./plugin-text-transforms.js"; |
16 | 15 | |
@@ -72,7 +71,24 @@ describe("plugin text transforms", () => {
|
72 | 71 | }); |
73 | 72 | |
74 | 73 | it("rewrites system prompt and message text content before transport", () => { |
75 | | -const context = transformStreamContextText( |
| 74 | +let capturedContext: Context | undefined; |
| 75 | +const wrapped = wrapStreamFnTextTransforms({ |
| 76 | +streamFn: (_model, context) => { |
| 77 | +capturedContext = context; |
| 78 | +const stream = createAssistantMessageEventStream(); |
| 79 | +stream.end(); |
| 80 | +return stream; |
| 81 | +}, |
| 82 | +input: [ |
| 83 | +{ |
| 84 | +from: /orchid mailbox/g, |
| 85 | +to: "pine mailbox", |
| 86 | +}, |
| 87 | +{ from: /red basket/g, to: "blue basket" }, |
| 88 | +], |
| 89 | +}); |
| 90 | +wrapped( |
| 91 | +model, |
76 | 92 | { |
77 | 93 | systemPrompt: "Use orchid mailbox inside north tower", |
78 | 94 | messages: [ |
@@ -85,14 +101,13 @@ describe("plugin text transforms", () => {
|
85 | 101 | }, |
86 | 102 | ], |
87 | 103 | } as Context, |
88 | | -[ |
89 | | -{ |
90 | | -from: /orchid mailbox/g, |
91 | | -to: "pine mailbox", |
92 | | -}, |
93 | | -{ from: /red basket/g, to: "blue basket" }, |
94 | | -], |
95 | | -) as unknown as { systemPrompt: string; messages: Array<{ content: unknown[] }> }; |
| 104 | +undefined, |
| 105 | +); |
| 106 | + |
| 107 | +const context = capturedContext as unknown as { |
| 108 | +systemPrompt: string; |
| 109 | +messages: Array<{ content: unknown[] }>; |
| 110 | +}; |
96 | 111 | |
97 | 112 | expect(context.systemPrompt).toBe("Use pine mailbox inside north tower"); |
98 | 113 | const textContent = context.messages[0]?.content[0] as |
|