(
httpExchanges: Array<{
url: string;
requestBody: string;
responseBody: string;
}>,
options?: { toolResultNormalizers?: ToolResultNormalizer[] },
)
| 35 | }); |
| 36 | |
| 37 | async function createProxy( |
| 38 | httpExchanges: Array<{ |
| 39 | url: string; |
| 40 | requestBody: string; |
| 41 | responseBody: string; |
| 42 | }>, |
| 43 | options?: { toolResultNormalizers?: ToolResultNormalizer[] }, |
| 44 | ) { |
| 45 | const outputPath = path.join(tempDir, "output.yaml"); |
| 46 | const proxy = new ReplayingCapiProxy( |
| 47 | "http://localhost", |
| 48 | outputPath, |
| 49 | workDir, |
| 50 | ); |
| 51 | |
| 52 | for (const normalizer of options?.toolResultNormalizers ?? []) { |
| 53 | proxy.addToolResultNormalizer(normalizer.toolName, normalizer.normalizer); |
| 54 | } |
| 55 | |
| 56 | for (const exchange of httpExchanges) { |
| 57 | (proxy.exchanges as Array<unknown>).push({ |
| 58 | request: { |
| 59 | url: exchange.url, |
| 60 | method: "POST", |
| 61 | body: exchange.requestBody, |
| 62 | }, |
| 63 | response: { statusCode: 200, body: exchange.responseBody }, |
| 64 | }); |
| 65 | } |
| 66 | |
| 67 | await proxy.stop(); |
| 68 | return outputPath; |
| 69 | } |
| 70 | |
| 71 | async function readYamlOutput(outputPath: string): Promise<NormalizedData> { |
| 72 | const content = await readFile(outputPath, "utf-8"); |
no test coverage detected
searching dependent graphs…