| 32 | |
| 33 | // happy-dom's fetch applies CORS, so the origin probes use node:http. |
| 34 | const probeStatus = ( |
| 35 | url: string, |
| 36 | options: { |
| 37 | readonly method?: string |
| 38 | readonly headers: Record<string, string> |
| 39 | }, |
| 40 | body = "" |
| 41 | ) => |
| 42 | Effect.promise( |
| 43 | () => |
| 44 | new Promise<number>((resolve, reject) => { |
| 45 | const req = request(url, options, (res) => { |
| 46 | res.resume() |
| 47 | res.on("end", () => resolve(res.statusCode ?? 0)) |
| 48 | }) |
| 49 | req.on("upgrade", (res, socket) => { |
| 50 | socket.destroy() |
| 51 | resolve(res.statusCode ?? 0) |
| 52 | }) |
| 53 | req.on("error", reject) |
| 54 | req.end(body) |
| 55 | }) |
| 56 | ) |
| 57 | |
| 58 | const makeAgent = Effect.fnUntraced(function*(base: string) { |
| 59 | const transport = yield* McpClient.http({ |