Open History to see the last commit
1import * as Path from "effect/Path";
2import * as AcpError from "./errors.ts";
3import * as Effect from "effect/Effect";
4import * as Deferred from "effect/Deferred";
5import * as Fiber from "effect/Fiber";
6import * as Queue from "effect/Queue";
7import * as Schema from "effect/Schema";
8import * as Stream from "effect/Stream";
9import * as Ref from "effect/Ref";
10import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process";
11
12import { it, assert } from "@effect/vitest";
13import * as NodeServices from "@effect/platform-node/NodeServices";
14
15import * as AcpSchema from "./_generated/schema.gen.ts";
16import * as AcpProtocol from "./protocol.ts";
17import {
18 encodeJsonl,
19 jsonRpcNotification,
20 jsonRpcRequest,
21 jsonRpcResponse,
22} from "./_internal/shared.ts";
23import { makeInMemoryStdio, makeTerminationError, makeChildStdio } from "./_internal/stdio.ts";
24
25const SessionCancelNotification = jsonRpcNotification(
26 "session/cancel",
27 AcpSchema.CancelNotification,
28);
29const SessionUpdateNotification = jsonRpcNotification(
30 "session/update",
31 AcpSchema.SessionNotification,
32);
33const ElicitationCompleteNotification = jsonRpcNotification(
34 "session/elicitation/complete",
35 AcpSchema.ElicitationCompleteNotification,
36);
37const RequestPermissionRequest = jsonRpcRequest(
38 "session/request_permission",
39 AcpSchema.RequestPermissionRequest,
40);
41const RequestPermissionResponse = jsonRpcResponse(AcpSchema.RequestPermissionResponse);
42const ExtRequest = jsonRpcRequest("x/test", Schema.Struct({ hello: Schema.String }));
43const ExtResponse = jsonRpcResponse(Schema.Struct({ ok: Schema.Boolean }));
44const decodeSessionCancelNotification = Schema.decodeEffect(
45 Schema.fromJsonString(SessionCancelNotification),
46);
47const decodeExtRequest = Schema.decodeEffect(Schema.fromJsonString(ExtRequest));
48const decodeExtResponse = Schema.decodeEffect(Schema.fromJsonString(ExtResponse));
49const decodeRequestPermissionResponse = Schema.decodeEffect(
50 Schema.fromJsonString(RequestPermissionResponse),
51);
52const encodeUnknownJsonString = Schema.encodeUnknownSync(Schema.fromJsonString(Schema.Unknown));
53const encoder = new TextEncoder();
54const mockPeerPath = Effect.map(Effect.service(Path.Path), (path) =>
55 path.join(import.meta.dirname, "../test/fixtures/acp-mock-peer.ts"),
56);
57const mockPeerArgs = (path: string) => [path];
58
59const makeHandle = (env?: Record<string, string>) =>
60 Effect.gen(function* () {
61 const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
62 const path = yield* Path.Path;
63 const command = ChildProcess.make(process.execPath, mockPeerArgs(yield* mockPeerPath), {
64 cwd: path.join(import.meta.dirname, ".."),
65 ...(env ? { env: { ...process.env, ...env } } : {}),
66 });
67 return yield* spawner.spawn(command);
68 });
69
70it.layer(NodeServices.layer)("effect-acp protocol", (it) => {
71 it.effect(
72 "emits exact JSON-RPC notifications and decodes inbound session/update and elicitation completion",
73 () =>
74 Effect.gen(function* () {
75 const { stdio, input, output } = yield* makeInMemoryStdio();
76 const transport = yield* AcpProtocol.makeAcpPatchedProtocol({
77 stdio,
78 serverRequestMethods: new Set(),
79 });
80
81 const notifications =
82 yield* Deferred.make<ReadonlyArray<AcpProtocol.AcpIncomingNotification>>();
83 yield* transport.incoming.pipe(
84 Stream.take(2),
85 Stream.runCollect,
86 Effect.flatMap((notificationChunk) => Deferred.succeed(notifications, notificationChunk)),
87 Effect.forkScoped,
88 );
89
90 yield* transport.notify("session/cancel", { sessionId: "session-1" });
91 const outbound = yield* Queue.take(output);
92 assert.deepEqual(yield* decodeSessionCancelNotification(outbound), {
93 jsonrpc: "2.0",
94 method: "session/cancel",
95 params: {
96 sessionId: "session-1",
97 },
98 });
99
100 yield* Queue.offer(
101 input,
102 yield* encodeJsonl(SessionUpdateNotification, {
103 jsonrpc: "2.0",
104 method: "session/update",
105 params: {
106 sessionId: "session-1",
107 update: {
108 sessionUpdate: "plan",
109 entries: [
110 {
111 content: "Inspect repository",
112 priority: "high",
113 status: "in_progress",
114 },
115 ],
116 },
117 },
118 }),
119 );
120
121 yield* Queue.offer(
122 input,
123 yield* encodeJsonl(ElicitationCompleteNotification, {
124 jsonrpc: "2.0",
125 method: "session/elicitation/complete",
126 params: {
127 elicitationId: "elicitation-1",
128 },
129 }),
130 );
131
132 const [update, completion] = yield* Deferred.await(notifications);
133 assert.equal(update?._tag, "SessionUpdate");
134 assert.equal(completion?._tag, "ElicitationComplete");
135 }),
136 );
137
138 it.effect("keeps only recent raw notifications after their callbacks run", () =>
139 Effect.gen(function* () {
140 const { stdio, input } = yield* makeInMemoryStdio();
141 const handled = yield* Deferred.make<void>();
142 let handledCount = 0;
143 const transport = yield* AcpProtocol.makeAcpPatchedProtocol({
144 stdio,
145 serverRequestMethods: new Set(),
146 onNotification: () =>
147 Effect.sync(() => ++handledCount).pipe(
148 Effect.flatMap((count) =>
149 count === 64 ? Deferred.succeed(handled, undefined).pipe(Effect.asVoid) : Effect.void,
150 ),
151 ),
152 });
153
154 const messages = Array.from({ length: 64 }, (_, index) =>
155 encodeUnknownJsonString({
156 jsonrpc: "2.0",
157 method: "x/performance",
158 params: { index },
159 }),
160 );
161 yield* Queue.offer(input, encoder.encode(`${messages.join("\n")}\n`));
162 yield* Deferred.await(handled);
163
164 const retained = yield* transport.incoming.pipe(Stream.take(32), Stream.runCollect);
165
166 assert.equal(handledCount, 64);
167 assert.equal(retained.length, 32);
168 assert.deepEqual(retained[0]?.params, { index: 32 });
169 assert.deepEqual(retained[31]?.params, { index: 63 });
170 }),
171 );
172
173 it.effect("keeps invalid core notification values only in the schema cause", () =>
174 Effect.gen(function* () {
175 const secret = "acp-core-notification-secret-sentinel";
176 const { stdio, input } = yield* makeInMemoryStdio();
177 const termination = yield* Deferred.make<AcpError.AcpError>();
178 yield* AcpProtocol.makeAcpPatchedProtocol({
179 stdio,
180 serverRequestMethods: new Set(),
181 onTermination: (error) => Deferred.succeed(termination, error).pipe(Effect.asVoid),
182 });
183
184 yield* Queue.offer(
185 input,
186 encoder.encode(
187 `${encodeUnknownJsonString({
188 jsonrpc: "2.0",
189 method: "session/update",
190 params: {
191 sessionId: { secret },
192 update: {
193 sessionUpdate: "plan",
194 entries: [],
195 },
196 },
197 })}\n`,
198 ),
199 );
200
201 const error = yield* Deferred.await(termination);
202 assert.instanceOf(error, AcpError.AcpProtocolParseError);
203 const parseError = error as AcpError.AcpProtocolParseError;
204 const { cause, ...directDiagnostics } = parseError;
205 assert.equal(parseError.operation, "decode-notification-payload");
206 assert.equal(parseError.method, "session/update");
207 assert.isAbove(parseError.issueCount ?? 0, 0);
208 assert.include(parseError.issueKinds ?? [], "Pointer");
209 assert.isAbove(parseError.maximumPathDepth ?? 0, 0);
210 assert.isTrue(Schema.isSchemaError(cause));
211 assert.notInclude(parseError.message, secret);
212 assert.notInclude(encodeUnknownJsonString(directDiagnostics), secret);
213 }),
214 );
215
216 it.effect("logs outgoing notifications when logOutgoing is enabled", () =>
217 Effect.gen(function* () {
218 const { stdio } = yield* makeInMemoryStdio();
219 const events: Array<AcpProtocol.AcpProtocolLogEvent> = [];
220 const transport = yield* AcpProtocol.makeAcpPatchedProtocol({
221 stdio,
222 serverRequestMethods: new Set(),
223 logOutgoing: true,
224 logger: (event) =>
225 Effect.sync(() => {
226 events.push(event);
227 }),
228 });
229
230 yield* transport.notify("session/cancel", { sessionId: "session-1" });
231
232 // A notification must not carry `id` or `headers`. Grok CLI drops frames that do.
233 assert.deepEqual(events, [
234 {
235 direction: "outgoing",
236 stage: "decoded",
237 payload: {
238 _tag: "Notification",
239 tag: "session/cancel",
240 payload: {
241 sessionId: "session-1",
242 },
243 },
244 },
245 {
246 direction: "outgoing",
247 stage: "raw",
248 payload:
249 '{"jsonrpc":"2.0","method":"session/cancel","params":{"sessionId":"session-1"}}\n',
250 },
251 ]);
252 }),
253 );
254
255 it.effect("logs decode failures without copying the cause or wire payload", () =>
256 Effect.gen(function* () {
257 const secret = "acp-wire-secret-sentinel";
258 const { stdio, input } = yield* makeInMemoryStdio();
259 const events: Array<AcpProtocol.AcpProtocolLogEvent> = [];
260 const termination = yield* Deferred.make<AcpError.AcpError>();
261 yield* AcpProtocol.makeAcpPatchedProtocol({
262 stdio,
263 serverRequestMethods: new Set(),
264 logIncoming: true,
265 logger: (event) =>
266 Effect.sync(() => {
267 events.push(event);
268 }),
269 onTermination: (error) => Deferred.succeed(termination, error).pipe(Effect.asVoid),
270 });
271
272 yield* Queue.offer(input, encoder.encode(`{"secret":"${secret}"\n`));
273 yield* Deferred.await(termination);
274
275 const event = events.find(({ stage }) => stage === "decode_failed");
276 assert.deepEqual(event, {
277 direction: "incoming",
278 stage: "decode_failed",
279 payload: {
280 operation: "decode-wire-message",
281 },
282 });
283 assert.notInclude(encodeUnknownJsonString(event), secret);
284 }),
285 );
286
287 it.effect("fails notification encoding through the declared ACP error channel", () =>
288 Effect.gen(function* () {
289 const { stdio } = yield* makeInMemoryStdio();
290 const transport = yield* AcpProtocol.makeAcpPatchedProtocol({
291 stdio,
292 serverRequestMethods: new Set(),
293 });
294
295 // Notifications encode through Schema, so the cause is the schema failure rather
296 // than the raw TypeError JSON.stringify throws. The ACP error shape is what callers see.
297 const bigintError = yield* transport.notify("x/test", 1n).pipe(Effect.flip);
298 assert.instanceOf(bigintError, AcpError.AcpProtocolParseError);
299 assert.equal(bigintError.operation, "encode-message");
300 assert.equal(bigintError.method, "x/test");
301 assert.isDefined(bigintError.cause);
302 assert.equal(
303 bigintError.message,
304 "ACP protocol operation 'encode-message' failed for method 'x/test'.",
305 );
306
307 const circular: Record<string, unknown> = {};
308 circular.self = circular;
309 const circularError = yield* transport.notify("x/test", circular).pipe(Effect.flip);
310 assert.instanceOf(circularError, AcpError.AcpProtocolParseError);
311 assert.equal(circularError.operation, "encode-message");
312 assert.equal(circularError.method, "x/test");
313 assert.isDefined(circularError.cause);
314
315 const requestError = yield* transport.request("x/request", 1n).pipe(
316 Effect.match({
317 onFailure: (error) => error,
318 onSuccess: () => assert.fail("Expected request encoding to fail"),
319 }),
320 );
321 assert.instanceOf(requestError, AcpError.AcpProtocolParseError);
322 assert.deepInclude(requestError, {
323 operation: "encode-message",
324 method: "x/request",
325 requestId: 1,
326 });
327 }),
328 );
329
330 it.effect("supports generic extension requests over the patched transport", () =>
331 Effect.gen(function* () {
332 const { stdio, input, output } = yield* makeInMemoryStdio();
333 const transport = yield* AcpProtocol.makeAcpPatchedProtocol({
334 stdio,
335 serverRequestMethods: new Set(),
336 });
337
338 const response = yield* transport
339 .request("x/test", { hello: "world" })
340 .pipe(Effect.forkScoped);
341 const outbound = yield* Queue.take(output);
342 assert.deepEqual(yield* decodeExtRequest(outbound), {
343 jsonrpc: "2.0",
344 id: 1,
345 method: "x/test",
346 params: {
347 hello: "world",
348 },
349 headers: [],
350 });
351
352 yield* Queue.offer(
353 input,
354 yield* encodeJsonl(ExtResponse, {
355 jsonrpc: "2.0",
356 id: 1,
357 result: {
358 ok: true,
359 },
360 }),
361 );
362
363 const resolved = yield* Fiber.join(response);
364 assert.deepEqual(resolved, { ok: true });
365 }),
366 );
367
368 it.effect("correlates extension response errors with the originating request", () =>
369 Effect.gen(function* () {
370 const { stdio, input, output } = yield* makeInMemoryStdio();
371 const transport = yield* AcpProtocol.makeAcpPatchedProtocol({
372 stdio,
373 serverRequestMethods: new Set(),
374 });
375
376 const response = yield* transport
377 .request("x/private", { hello: "world" })
378 .pipe(Effect.forkScoped);
379 yield* Queue.take(output);
380 yield* Queue.offer(
381 input,
382 encoder.encode(
383 `${encodeUnknownJsonString({
384 jsonrpc: "2.0",
385 id: 1,
386 error: {
387 _tag: "Cause",
388 code: -32602,
389 message: "Invalid params",
390 data: [
391 {
392 _tag: "Fail",
393 error: {
394 code: -32602,
395 message: "Invalid params",
396 data: { field: "hello" },
397 },
398 },
399 ],
400 },
401 })}\n`,
402 ),
403 );
404
405 const error = yield* Fiber.join(response).pipe(
406 Effect.match({
407 onFailure: (error) => error,
408 onSuccess: () => assert.fail("Expected extension request to fail"),
409 }),
410 );
411 assert.instanceOf(error, AcpError.AcpRequestError);
412 assert.deepInclude(error, {
413 code: -32602,
414 errorMessage: "Invalid params",
415 method: "x/private",
416 requestId: 1,
417 operation: "receive-response",
418 });
419 }),
420 );
421
422 it.effect("preserves numeric ids for inbound extension requests", () =>
423 Effect.gen(function* () {
424 const { stdio, input, output } = yield* makeInMemoryStdio();
425 yield* AcpProtocol.makeAcpPatchedProtocol({
426 stdio,
427 serverRequestMethods: new Set(),
428 onExtRequest: () => Effect.succeed({ ok: true }),
429 });
430
431 yield* Queue.offer(
432 input,
433 yield* encodeJsonl(ExtRequest, {
434 jsonrpc: "2.0",
435 id: 7,
436 method: "x/test",
437 params: {
438 hello: "world",
439 },
440 headers: [],
441 }),
442 );
443
444 const outbound = yield* Queue.take(output);
445 assert.deepEqual(yield* decodeExtResponse(outbound), {
446 jsonrpc: "2.0",
447 id: 7,
448 result: {
449 ok: true,
450 },
451 });
452 }),
453 );
454
455 it.effect("preserves zero-valued ids for inbound core client requests", () =>
456 Effect.gen(function* () {
457 const { stdio, input, output } = yield* makeInMemoryStdio();
458 const transport = yield* AcpProtocol.makeAcpPatchedProtocol({
459 stdio,
460 serverRequestMethods: new Set(["session/request_permission"]),
461 });
462 const inboundRequest = yield* Deferred.make<unknown>();
463
464 yield* transport.serverProtocol
465 .run((_clientId, message) => Deferred.succeed(inboundRequest, message).pipe(Effect.asVoid))
466 .pipe(Effect.forkScoped);
467
468 yield* Queue.offer(
469 input,
470 yield* encodeJsonl(RequestPermissionRequest, {
471 jsonrpc: "2.0",
472 id: 0,
473 method: "session/request_permission",
474 params: {
475 sessionId: "session-1",
476 toolCall: {
477 toolCallId: "tool-1",
478 title: "Allow mock action",
479 },
480 options: [{ optionId: "allow", name: "Allow", kind: "allow_once" }],
481 },
482 headers: [],
483 }),
484 );
485
486 const message = yield* Deferred.await(inboundRequest);
487 assert.deepEqual(message, {
488 _tag: "Request",
489 id: 0,
490 tag: "session/request_permission",
491 payload: {
492 sessionId: "session-1",
493 toolCall: {
494 toolCallId: "tool-1",
495 title: "Allow mock action",
496 },
497 options: [{ optionId: "allow", name: "Allow", kind: "allow_once" }],
498 },
499 headers: [],
500 });
501
502 yield* transport.serverProtocol.send(0, {
503 _tag: "Exit",
504 requestId: 0,
505 exit: {
506 _tag: "Success",
507 value: {
508 outcome: {
509 outcome: "selected",
510 optionId: "allow",
511 },
512 },
513 },
514 });
515
516 const outbound = yield* Queue.take(output);
517 assert.deepEqual(yield* decodeRequestPermissionResponse(outbound), {
518 jsonrpc: "2.0",
519 id: 0,
520 result: {
521 outcome: {
522 outcome: "selected",
523 optionId: "allow",
524 },
525 },
526 });
527 }),
528 );
529
530 it.effect("cleans up interrupted extension requests before a late response arrives", () =>
531 Effect.gen(function* () {
532 const { stdio, input, output } = yield* makeInMemoryStdio();
533 const transport = yield* AcpProtocol.makeAcpPatchedProtocol({
534 stdio,
535 serverRequestMethods: new Set(),
536 });
537 const lateResponse = yield* Deferred.make<unknown>();
538
539 yield* transport.clientProtocol
540 .run(0, (message) => Deferred.succeed(lateResponse, message).pipe(Effect.asVoid))
541 .pipe(Effect.forkScoped);
542
543 const response = yield* transport
544 .request("x/test", { hello: "world" })
545 .pipe(Effect.forkScoped);
546 const outbound = yield* Queue.take(output);
547 assert.deepEqual(yield* decodeExtRequest(outbound), {
548 jsonrpc: "2.0",
549 id: 1,
550 method: "x/test",
551 params: {
552 hello: "world",
553 },
554 headers: [],
555 });
556
557 yield* Fiber.interrupt(response);
558 yield* Queue.offer(
559 input,
560 yield* encodeJsonl(ExtResponse, {
561 jsonrpc: "2.0",
562 id: 1,
563 result: {
564 ok: true,
565 },
566 }),
567 );
568
569 const message = yield* Deferred.await(lateResponse);
570 assert.deepEqual(message, {
571 _tag: "Exit",
572 requestId: 1,
573 exit: {
574 _tag: "Success",
575 value: {
576 ok: true,
577 },
578 },
579 });
580 }),
581 );
582
583 it.effect("propagates the real child exit code when the input stream ends", () =>
584 Effect.gen(function* () {
585 const handle = yield* makeHandle({ ACP_MOCK_EXIT_IMMEDIATELY_CODE: "7" });
586 const firstMessage = yield* Deferred.make<unknown>();
587 const termination = yield* Deferred.make<AcpError.AcpError>();
588 const transport = yield* AcpProtocol.makeAcpPatchedProtocol({
589 stdio: makeChildStdio(handle),
590 terminationError: makeTerminationError(handle),
591 serverRequestMethods: new Set(),
592 onTermination: (error) => Deferred.succeed(termination, error).pipe(Effect.asVoid),
593 });
594
595 yield* transport.clientProtocol
596 .run(0, (message) => Deferred.succeed(firstMessage, message).pipe(Effect.asVoid))
597 .pipe(Effect.forkScoped);
598
599 const message = yield* Deferred.await(firstMessage);
600 const exitError = yield* Deferred.await(termination);
601 assert.instanceOf(exitError, AcpError.AcpProcessExitedError);
602 assert.equal((exitError as AcpError.AcpProcessExitedError).code, 7);
603 assert.equal((message as { readonly _tag?: string })._tag, "ClientProtocolError");
604 const defect = (message as { readonly error: { readonly reason: unknown } }).error.reason as {
605 readonly _tag: string;
606 readonly message: string;
607 readonly cause: unknown;
608 };
609 assert.equal(defect._tag, "RpcClientDefect");
610 assert.equal(defect.message, "ACP protocol terminated.");
611 assert.instanceOf(defect.cause, AcpError.AcpProcessExitedError);
612 assert.equal((defect.cause as AcpError.AcpProcessExitedError).code, 7);
613 }),
614 );
615
616 it.effect("classifies an input stream ending without inventing a cause", () =>
617 Effect.gen(function* () {
618 const { stdio, input } = yield* makeInMemoryStdio();
619 const termination = yield* Deferred.make<AcpError.AcpError>();
620 yield* AcpProtocol.makeAcpPatchedProtocol({
621 stdio,
622 serverRequestMethods: new Set(),
623 onTermination: (error) => Deferred.succeed(termination, error).pipe(Effect.asVoid),
624 });
625
626 yield* Queue.end(input);
627
628 const error = yield* Deferred.await(termination);
629 assert.instanceOf(error, AcpError.AcpInputStreamEndedError);
630 assert.equal(error.message, "ACP input stream ended.");
631 assert.equal("cause" in error, false);
632 }),
633 );
634
635 it.effect("does not emit a second process-exit error after a decode failure", () =>
636 Effect.gen(function* () {
637 const handle = yield* makeHandle({
638 ACP_MOCK_MALFORMED_OUTPUT: "1",
639 ACP_MOCK_MALFORMED_OUTPUT_EXIT_CODE: "23",
640 });
641 const terminationCalls = yield* Ref.make(0);
642 const firstMessage = yield* Deferred.make<unknown>();
643 const transport = yield* AcpProtocol.makeAcpPatchedProtocol({
644 stdio: makeChildStdio(handle),
645 terminationError: makeTerminationError(handle),
646 serverRequestMethods: new Set(),
647 onTermination: () => Ref.update(terminationCalls, (count) => count + 1),
648 });
649
650 yield* transport.clientProtocol
651 .run(0, (message) => Deferred.succeed(firstMessage, message).pipe(Effect.asVoid))
652 .pipe(Effect.forkScoped);
653
654 const message = yield* Deferred.await(firstMessage);
655 assert.equal(yield* Ref.get(terminationCalls), 1);
656 assert.equal((message as { readonly _tag?: string })._tag, "ClientProtocolError");
657 const defect = (message as { readonly error: { readonly reason: unknown } }).error.reason as {
658 readonly _tag: string;
659 readonly message: string;
660 readonly cause: unknown;
661 };
662 assert.equal(defect._tag, "RpcClientDefect");
663 assert.equal(defect.message, "ACP protocol terminated.");
664 assert.instanceOf(defect.cause, AcpError.AcpProtocolParseError);
665 }),
666 );
667
668 it.effect("keeps client send failure messages independent from the cause", () =>
669 Effect.gen(function* () {
670 const { stdio } = yield* makeInMemoryStdio();
671 const transport = yield* AcpProtocol.makeAcpPatchedProtocol({
672 stdio,
673 serverRequestMethods: new Set(),
674 });
675
676 const failure = yield* transport.clientProtocol
677 .send(0, {
678 _tag: "Request",
679 id: "request-1",
680 tag: "x/test",
681 payload: 1n,
682 headers: [],
683 })
684 .pipe(Effect.flip);
685 const defect = failure.reason as {
686 readonly _tag: string;
687 readonly message: string;
688 readonly cause: unknown;
689 };
690
691 assert.equal(defect._tag, "RpcClientDefect");
692 assert.equal(defect.message, "Failed to send ACP protocol message.");
693 assert.instanceOf(defect.cause, AcpError.AcpProtocolParseError);
694 }),
695 );
696
697 it.effect("fails pending extension requests with the propagated exit code", () =>
698 Effect.gen(function* () {
699 const { stdio, input, output } = yield* makeInMemoryStdio();
700 const transport = yield* AcpProtocol.makeAcpPatchedProtocol({
701 stdio,
702 terminationError: Effect.succeed(new AcpError.AcpProcessExitedError({ code: 0 })),
703 serverRequestMethods: new Set(),
704 });
705
706 const response = yield* transport
707 .request("x/test", { hello: "world" })
708 .pipe(Effect.forkScoped);
709 yield* Queue.take(output);
710 yield* Queue.end(input);
711
712 const error = yield* Fiber.join(response).pipe(
713 Effect.match({
714 onFailure: (error) => error,
715 onSuccess: () => assert.fail("Expected request to fail after process exit"),
716 }),
717 );
718 assert.instanceOf(error, AcpError.AcpProcessExitedError);
719 assert.equal(error.code, 0);
720 }),
721 );
722});