(
engine: ExecutionEngine<E>,
capabilities: ClientCapabilities,
fn: (client: Client) => Promise<void>,
config?: Pick<
ExecutorMcpServerConfig<E>,
"debug" | "elicitationMode" | "browserApprovalStore" | "pausedExecutionHooks"
>,
)
| 45 | |
| 46 | /** Connect a real MCP Client to our executor MCP server over in-memory transports. */ |
| 47 | const withClient = async <E extends Cause.YieldableError>( |
| 48 | engine: ExecutionEngine<E>, |
| 49 | capabilities: ClientCapabilities, |
| 50 | fn: (client: Client) => Promise<void>, |
| 51 | config?: Pick< |
| 52 | ExecutorMcpServerConfig<E>, |
| 53 | "debug" | "elicitationMode" | "browserApprovalStore" | "pausedExecutionHooks" |
| 54 | >, |
| 55 | ) => { |
| 56 | const mcpServer = await Effect.runPromise(createExecutorMcpServer({ engine, ...config })); |
| 57 | const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair(); |
| 58 | const client = new Client({ name: "test-client", version: "1.0.0" }, { capabilities }); |
| 59 | await mcpServer.connect(serverTransport); |
| 60 | await client.connect(clientTransport); |
| 61 | // oxlint-disable-next-line executor/no-try-catch-or-throw -- boundary: test helper must close MCP transports after async client assertions |
| 62 | try { |
| 63 | await fn(client); |
| 64 | } finally { |
| 65 | await clientTransport.close(); |
| 66 | await serverTransport.close(); |
| 67 | } |
| 68 | }; |
| 69 | |
| 70 | const withNativeClient = async <E extends Cause.YieldableError>( |
| 71 | engine: ExecutionEngine<E>, |
no test coverage detected