( engine: ExecutionEngine<E>, capabilities: ClientCapabilities, fn: (client: Client) => Promise<void>, config?: Partial<ExecutorMcpServerConfig<E>>, )
| 131 | }; |
| 132 | |
| 133 | const withClient = async <E extends Cause.YieldableError>( |
| 134 | engine: ExecutionEngine<E>, |
| 135 | capabilities: ClientCapabilities, |
| 136 | fn: (client: Client) => Promise<void>, |
| 137 | config?: Partial<ExecutorMcpServerConfig<E>>, |
| 138 | ) => { |
| 139 | const mcpServer = await Effect.runPromise( |
| 140 | createExecutorMcpServer({ |
| 141 | engine, |
| 142 | loadAppShellHtml: () => Promise.resolve(SHELL_HTML), |
| 143 | // Artifacts are on by default and nearly every test in this file |
| 144 | // exercises the artifact surface; spelled out here anyway so the cases |
| 145 | // that assert the OFF surface (`artifactsEnabled: false`) read as the |
| 146 | // deliberate contrast. The default (no flag at all) is proved directly |
| 147 | // in the opt-out describe block. |
| 148 | artifactsEnabled: true, |
| 149 | ...config, |
| 150 | } as ExecutorMcpServerConfig<E>), |
| 151 | ); |
| 152 | const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair(); |
| 153 | const client = new Client({ name: "test-client", version: "1.0.0" }, { capabilities }); |
| 154 | await mcpServer.connect(serverTransport); |
| 155 | await client.connect(clientTransport); |
| 156 | // oxlint-disable-next-line executor/no-try-catch-or-throw -- boundary: test helper must close MCP transports after async client assertions |
| 157 | try { |
| 158 | await fn(client); |
| 159 | } finally { |
| 160 | await clientTransport.close(); |
| 161 | await serverTransport.close(); |
| 162 | } |
| 163 | }; |
| 164 | |
| 165 | const SHELL_HTML = "<!doctype html><html><body><div id='root'></div></body></html>"; |
| 166 |
no test coverage detected