(
organizationId: string,
options: BuildOptions & { readonly caps?: ClientCapabilities } = {},
)
| 131 | // them connected to an in-memory MCP client. Shaped as an acquireRelease so |
| 132 | // the transport teardown is guaranteed when the test scope closes. |
| 133 | const openSession = ( |
| 134 | organizationId: string, |
| 135 | options: BuildOptions & { readonly caps?: ClientCapabilities } = {}, |
| 136 | ) => |
| 137 | Effect.acquireRelease( |
| 138 | Effect.gen(function* () { |
| 139 | const executor = yield* buildScopedExecutor(organizationId, `Org ${organizationId}`, options); |
| 140 | const engine = createExecutionEngine({ executor, codeExecutor: makeQuickJsExecutor() }); |
| 141 | const mcpServer = yield* createExecutorMcpServer({ |
| 142 | engine, |
| 143 | elicitationMode: options.elicitationMode ? { mode: options.elicitationMode } : undefined, |
| 144 | }); |
| 145 | const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair(); |
| 146 | const client = new Client( |
| 147 | { name: "cloud-e2e-test", version: "1.0.0" }, |
| 148 | { capabilities: options.caps ?? ELICITATION_CAPS }, |
| 149 | ); |
| 150 | yield* Effect.promise(() => mcpServer.connect(serverTransport)); |
| 151 | yield* Effect.promise(() => client.connect(clientTransport)); |
| 152 | return { client, clientTransport, serverTransport }; |
| 153 | }), |
| 154 | ({ clientTransport, serverTransport }) => |
| 155 | Effect.all( |
| 156 | [ |
| 157 | Effect.tryPromise({ |
| 158 | try: () => clientTransport.close(), |
| 159 | catch: (cause) => cause, |
| 160 | }).pipe(Effect.ignore), |
| 161 | Effect.tryPromise({ |
| 162 | try: () => serverTransport.close(), |
| 163 | catch: (cause) => cause, |
| 164 | }).pipe(Effect.ignore), |
| 165 | ], |
| 166 | { discard: true }, |
| 167 | ), |
| 168 | ).pipe(Effect.map(({ client }) => ({ client }))); |
| 169 | |
| 170 | const nextOrgId = (() => { |
| 171 | let seq = 0; |
no test coverage detected