Showing the changes to packages/effect-codex-app-server/src (2 of 5 files). Show all
Unified · Split
| @@ -121,4 +121,34 @@ it.layer(NodeServices.layer)("effect-codex-app-server client", (it) => { · 120 unmodified lines | ||
| 121 | 121 | ]); |
| 122 | 122 | }), |
| 123 | 123 | ); |
| 124 | + | |
| 125 | + it.effect("initializes a command-backed app-server client", () => | |
| 126 | + Effect.gen(function* () { | |
| 127 | + const path = yield* Path.Path; | |
| 128 | + const scope = yield* Scope.make(); | |
| 129 | + const clientLayer = CodexClient.layerCommand({ | |
| 130 | + command: "bun", | |
| 131 | + args: ["run", yield* mockPeerPath], | |
| 132 | + cwd: path.join(import.meta.dirname, ".."), | |
| 133 | + }); | |
| 134 | + const context = yield* Layer.buildWithScope(clientLayer, scope); | |
| 135 | + | |
| 136 | + const initialized = yield* Effect.gen(function* () { | |
| 137 | + const client = yield* CodexClient.CodexAppServerClient; | |
| 138 | + return yield* client.request("initialize", { | |
| 139 | + clientInfo: { | |
| 140 | + name: "effect-codex-app-server-test", | |
| 141 | + title: "Effect Codex App Server Test", | |
| 142 | + version: "0.0.0", | |
| 143 | + }, | |
| 144 | + capabilities: { | |
| 145 | + experimentalApi: true, | |
| 146 | + optOutNotificationMethods: null, | |
| 147 | + }, | |
| 148 | + }); | |
| 149 | + }).pipe(Effect.provide(context), Effect.ensuring(Scope.close(scope, Exit.void))); | |
| 150 | + | |
| 151 | + assert.equal(initialized.userAgent, "mock-codex-app-server"); | |
| 152 | + }), | |
| 153 | + ); | |
| 124 | 154 | }); |
| @@ -281,7 +281,7 @@ export const layerCommand = ( · 280 unmodified lines | ||
| 281 | 281 | ...(options.env ? { env: { ...process.env, ...options.env } } : {}), |
| 282 | 282 | shell: process.platform === "win32", |
| 283 | 283 | }); |
| 284 | − const handle = yield* spawner.spawn(command).pipe( | |
| 284 | + return yield* spawner.spawn(command).pipe( | |
| 285 | 285 | Effect.mapError( |
| 286 | 286 | (cause) => |
| 287 | 287 | new CodexError.CodexAppServerSpawnError({ |
| @@ -290,9 +290,11 @@ export const layerCommand = ( · 2 unmodified lines | ||
| 290 | 290 | }), |
| 291 | 291 | ), |
| 292 | 292 | ); |
| 293 | − const client = yield* make(makeChildStdio(handle), options, makeTerminationError(handle)); | |
| 294 | − return { client, handle }; | |
| 295 | 293 | }), |
| 296 | − ({ handle }) => handle.kill().pipe(Effect.orDie), | |
| 297 | − ).pipe(Effect.map(({ client }) => client)), | |
| 294 | + (handle) => handle.kill().pipe(Effect.orDie), | |
| 295 | + ).pipe( | |
| 296 | + Effect.flatMap((handle) => | |
| 297 | + make(makeChildStdio(handle), options, makeTerminationError(handle)), | |
| 298 | + ), | |
| 299 | + ), | |
| 298 | 300 | ); |