Open History to see the last commit
1import * as Context from "effect/Context";
2import * as Effect from "effect/Effect";
3import * as Stdio from "effect/Stdio";
4import * as Layer from "effect/Layer";
5import * as Schema from "effect/Schema";
6import * as Scope from "effect/Scope";
7import * as Stream from "effect/Stream";
8import * as RpcClient from "effect/unstable/rpc/RpcClient";
9import * as RpcServer from "effect/unstable/rpc/RpcServer";
10import { ChildProcessSpawner } from "effect/unstable/process";
11
12import * as AcpError from "./errors.ts";
13import * as AcpProtocol from "./protocol.ts";
14import * as AcpRpcs from "./rpc.ts";
15import * as AcpSchema from "./_generated/schema.gen.ts";
16import { AGENT_METHODS, CLIENT_METHODS } from "./_generated/meta.gen.ts";
17import {
18 callRpc,
19 decodeExtNotificationRegistration,
20 decodeExtRequestRegistration,
21 runHandler,
22} from "./_internal/shared.ts";
23import { makeChildStdio, makeTerminationError } from "./_internal/stdio.ts";
24
25export interface AcpClientOptions {
26 readonly logIncoming?: boolean;
27 readonly logOutgoing?: boolean;
28 readonly logger?: (event: AcpProtocol.AcpProtocolLogEvent) => Effect.Effect<void, never>;
29}
30
31type AcpClientRaw = {
32 readonly notifications: Stream.Stream<AcpProtocol.AcpIncomingNotification>;
33 readonly request: (method: string, payload: unknown) => Effect.Effect<unknown, AcpError.AcpError>;
34 readonly notify: (method: string, payload: unknown) => Effect.Effect<void, AcpError.AcpError>;
35};
36
37export interface AcpClientShape {
38 readonly raw: AcpClientRaw;
39 readonly agent: {
40 /**
41 * Initializes the ACP session and negotiates capabilities.
42 * @see https://agentclientprotocol.com/protocol/schema#initialize
43 */
44 readonly initialize: (
45 payload: AcpSchema.InitializeRequest,
46 ) => Effect.Effect<AcpSchema.InitializeResponse, AcpError.AcpError>;
47 /**
48 * Performs ACP authentication when the agent requires it.
49 * @see https://agentclientprotocol.com/protocol/schema#authenticate
50 */
51 readonly authenticate: (
52 payload: AcpSchema.AuthenticateRequest,
53 ) => Effect.Effect<AcpSchema.AuthenticateResponse, AcpError.AcpError>;
54 /**
55 * Logs out the current ACP identity.
56 * @see https://agentclientprotocol.com/protocol/schema#logout
57 */
58 readonly logout: (
59 payload: AcpSchema.LogoutRequest,
60 ) => Effect.Effect<AcpSchema.LogoutResponse, AcpError.AcpError>;
61 /**
62 * Starts a new ACP session.
63 * @see https://agentclientprotocol.com/protocol/schema#session/new
64 */
65 readonly createSession: (
66 payload: AcpSchema.NewSessionRequest,
67 ) => Effect.Effect<AcpSchema.NewSessionResponse, AcpError.AcpError>;
68 /**
69 * Loads a previously saved ACP session.
70 * @see https://agentclientprotocol.com/protocol/schema#session/load
71 */
72 readonly loadSession: (
73 payload: AcpSchema.LoadSessionRequest,
74 ) => Effect.Effect<AcpSchema.LoadSessionResponse, AcpError.AcpError>;
75 /**
76 * Lists available ACP sessions.
77 * @see https://agentclientprotocol.com/protocol/schema#session/list
78 */
79 readonly listSessions: (
80 payload: AcpSchema.ListSessionsRequest,
81 ) => Effect.Effect<AcpSchema.ListSessionsResponse, AcpError.AcpError>;
82 /**
83 * Forks an ACP session.
84 * @see https://agentclientprotocol.com/protocol/schema#session/fork
85 */
86 readonly forkSession: (
87 payload: AcpSchema.ForkSessionRequest,
88 ) => Effect.Effect<AcpSchema.ForkSessionResponse, AcpError.AcpError>;
89 /**
90 * Resumes an ACP session.
91 * @see https://agentclientprotocol.com/protocol/schema#session/resume
92 */
93 readonly resumeSession: (
94 payload: AcpSchema.ResumeSessionRequest,
95 ) => Effect.Effect<AcpSchema.ResumeSessionResponse, AcpError.AcpError>;
96 /**
97 * Closes an ACP session.
98 * @see https://agentclientprotocol.com/protocol/schema#session/close
99 */
100 readonly closeSession: (
101 payload: AcpSchema.CloseSessionRequest,
102 ) => Effect.Effect<AcpSchema.CloseSessionResponse, AcpError.AcpError>;
103 /**
104 * Selects the active model for a session.
105 * @see https://agentclientprotocol.com/protocol/schema#session/set_model
106 */
107 readonly setSessionModel: (
108 payload: AcpSchema.SetSessionModelRequest,
109 ) => Effect.Effect<AcpSchema.SetSessionModelResponse, AcpError.AcpError>;
110 /**
111 * Updates a session configuration option.
112 * @see https://agentclientprotocol.com/protocol/schema#session/set_config_option
113 */
114 readonly setSessionConfigOption: (
115 payload: AcpSchema.SetSessionConfigOptionRequest,
116 ) => Effect.Effect<AcpSchema.SetSessionConfigOptionResponse, AcpError.AcpError>;
117 /**
118 * Sends a prompt turn to the agent.
119 * @see https://agentclientprotocol.com/protocol/schema#session/prompt
120 */
121 readonly prompt: (
122 payload: AcpSchema.PromptRequest,
123 ) => Effect.Effect<AcpSchema.PromptResponse, AcpError.AcpError>;
124 /**
125 * Sends a real ACP `session/cancel` notification.
126 * @see https://agentclientprotocol.com/protocol/schema#session/cancel
127 */
128 readonly cancel: (
129 payload: AcpSchema.CancelNotification,
130 ) => Effect.Effect<void, AcpError.AcpError>;
131 };
132 /**
133 * Registers a handler for `session/request_permission`.
134 * @see https://agentclientprotocol.com/protocol/schema#session/request_permission
135 */
136 readonly handleRequestPermission: (
137 handler: (
138 request: AcpSchema.RequestPermissionRequest,
139 ) => Effect.Effect<AcpSchema.RequestPermissionResponse, AcpError.AcpError>,
140 ) => Effect.Effect<void>;
141 /**
142 * Registers a handler for `session/elicitation`.
143 * @see https://agentclientprotocol.com/protocol/schema#session/elicitation
144 */
145 readonly handleElicitation: (
146 handler: (
147 request: AcpSchema.ElicitationRequest,
148 ) => Effect.Effect<AcpSchema.ElicitationResponse, AcpError.AcpError>,
149 ) => Effect.Effect<void>;
150 /**
151 * Registers a handler for `fs/read_text_file`.
152 * @see https://agentclientprotocol.com/protocol/schema#fs/read_text_file
153 */
154 readonly handleReadTextFile: (
155 handler: (
156 request: AcpSchema.ReadTextFileRequest,
157 ) => Effect.Effect<AcpSchema.ReadTextFileResponse, AcpError.AcpError>,
158 ) => Effect.Effect<void>;
159 /**
160 * Registers a handler for `fs/write_text_file`.
161 * @see https://agentclientprotocol.com/protocol/schema#fs/write_text_file
162 */
163 readonly handleWriteTextFile: (
164 handler: (
165 request: AcpSchema.WriteTextFileRequest,
166 ) => Effect.Effect<AcpSchema.WriteTextFileResponse | void, AcpError.AcpError>,
167 ) => Effect.Effect<void>;
168 /**
169 * Registers a handler for `terminal/create`.
170 * @see https://agentclientprotocol.com/protocol/schema#terminal/create
171 */
172 readonly handleCreateTerminal: (
173 handler: (
174 request: AcpSchema.CreateTerminalRequest,
175 ) => Effect.Effect<AcpSchema.CreateTerminalResponse, AcpError.AcpError>,
176 ) => Effect.Effect<void>;
177 /**
178 * Registers a handler for `terminal/output`.
179 * @see https://agentclientprotocol.com/protocol/schema#terminal/output
180 */
181 readonly handleTerminalOutput: (
182 handler: (
183 request: AcpSchema.TerminalOutputRequest,
184 ) => Effect.Effect<AcpSchema.TerminalOutputResponse, AcpError.AcpError>,
185 ) => Effect.Effect<void>;
186 /**
187 * Registers a handler for `terminal/wait_for_exit`.
188 * @see https://agentclientprotocol.com/protocol/schema#terminal/wait_for_exit
189 */
190 readonly handleTerminalWaitForExit: (
191 handler: (
192 request: AcpSchema.WaitForTerminalExitRequest,
193 ) => Effect.Effect<AcpSchema.WaitForTerminalExitResponse, AcpError.AcpError>,
194 ) => Effect.Effect<void>;
195 /**
196 * Registers a handler for `terminal/kill`.
197 * @see https://agentclientprotocol.com/protocol/schema#terminal/kill
198 */
199 readonly handleTerminalKill: (
200 handler: (
201 request: AcpSchema.KillTerminalRequest,
202 ) => Effect.Effect<AcpSchema.KillTerminalResponse | void, AcpError.AcpError>,
203 ) => Effect.Effect<void>;
204 /**
205 * Registers a handler for `terminal/release`.
206 * @see https://agentclientprotocol.com/protocol/schema#terminal/release
207 */
208 readonly handleTerminalRelease: (
209 handler: (
210 request: AcpSchema.ReleaseTerminalRequest,
211 ) => Effect.Effect<AcpSchema.ReleaseTerminalResponse | void, AcpError.AcpError>,
212 ) => Effect.Effect<void>;
213 /**
214 * Registers a handler for `session/update`.
215 * @see https://agentclientprotocol.com/protocol/schema#session/update
216 */
217 readonly handleSessionUpdate: (
218 handler: (
219 notification: AcpSchema.SessionNotification,
220 ) => Effect.Effect<void, AcpError.AcpError>,
221 ) => Effect.Effect<void>;
222 /**
223 * Registers a handler for `session/elicitation/complete`.
224 * @see https://agentclientprotocol.com/protocol/schema#session/elicitation/complete
225 */
226 readonly handleElicitationComplete: (
227 handler: (
228 notification: AcpSchema.ElicitationCompleteNotification,
229 ) => Effect.Effect<void, AcpError.AcpError>,
230 ) => Effect.Effect<void>;
231 /**
232 * Registers a fallback extension request handler.
233 * @see https://agentclientprotocol.com/protocol/extensibility
234 */
235 readonly handleUnknownExtRequest: (
236 handler: (method: string, params: unknown) => Effect.Effect<unknown, AcpError.AcpError>,
237 ) => Effect.Effect<void>;
238 /**
239 * Registers a fallback extension notification handler.
240 * @see https://agentclientprotocol.com/protocol/extensibility
241 */
242 readonly handleUnknownExtNotification: (
243 handler: (method: string, params: unknown) => Effect.Effect<void, AcpError.AcpError>,
244 ) => Effect.Effect<void>;
245 /**
246 * Registers a typed extension request handler.
247 * @see https://agentclientprotocol.com/protocol/extensibility
248 */
249 readonly handleExtRequest: <A, I>(
250 method: string,
251 payload: Schema.Codec<A, I>,
252 handler: (payload: A) => Effect.Effect<unknown, AcpError.AcpError>,
253 ) => Effect.Effect<void>;
254 /**
255 * Registers a typed extension notification handler.
256 * @see https://agentclientprotocol.com/protocol/extensibility
257 */
258 readonly handleExtNotification: <A, I>(
259 method: string,
260 payload: Schema.Codec<A, I>,
261 handler: (payload: A) => Effect.Effect<void, AcpError.AcpError>,
262 ) => Effect.Effect<void>;
263}
264
265export class AcpClient extends Context.Service<AcpClient, AcpClientShape>()(
266 "effect-acp/AcpClient",
267) {}
268
269interface AcpCoreRequestHandlers {
270 requestPermission?: (
271 request: AcpSchema.RequestPermissionRequest,
272 ) => Effect.Effect<AcpSchema.RequestPermissionResponse, AcpError.AcpError>;
273 elicitation?: (
274 request: AcpSchema.ElicitationRequest,
275 ) => Effect.Effect<AcpSchema.ElicitationResponse, AcpError.AcpError>;
276 readTextFile?: (
277 request: AcpSchema.ReadTextFileRequest,
278 ) => Effect.Effect<AcpSchema.ReadTextFileResponse, AcpError.AcpError>;
279 writeTextFile?: (
280 request: AcpSchema.WriteTextFileRequest,
281 ) => Effect.Effect<AcpSchema.WriteTextFileResponse | void, AcpError.AcpError>;
282 createTerminal?: (
283 request: AcpSchema.CreateTerminalRequest,
284 ) => Effect.Effect<AcpSchema.CreateTerminalResponse, AcpError.AcpError>;
285 terminalOutput?: (
286 request: AcpSchema.TerminalOutputRequest,
287 ) => Effect.Effect<AcpSchema.TerminalOutputResponse, AcpError.AcpError>;
288 terminalWaitForExit?: (
289 request: AcpSchema.WaitForTerminalExitRequest,
290 ) => Effect.Effect<AcpSchema.WaitForTerminalExitResponse, AcpError.AcpError>;
291 terminalKill?: (
292 request: AcpSchema.KillTerminalRequest,
293 ) => Effect.Effect<AcpSchema.KillTerminalResponse | void, AcpError.AcpError>;
294 terminalRelease?: (
295 request: AcpSchema.ReleaseTerminalRequest,
296 ) => Effect.Effect<AcpSchema.ReleaseTerminalResponse | void, AcpError.AcpError>;
297}
298
299interface AcpNotificationHandlers {
300 readonly sessionUpdate: BufferedNotificationHandler<AcpSchema.SessionNotification>;
301 readonly elicitationComplete: BufferedNotificationHandler<AcpSchema.ElicitationCompleteNotification>;
302}
303
304interface BufferedNotificationHandler<A> {
305 readonly handlers: Array<(notification: A) => Effect.Effect<void, AcpError.AcpError>>;
306 readonly pending: Array<A>;
307}
308
309export const make = Effect.fn("effect-acp/AcpClient.make")(function* (
310 stdio: Stdio.Stdio,
311 options: AcpClientOptions = {},
312 terminationError?: Effect.Effect<AcpError.AcpError>,
313): Effect.fn.Return<AcpClientShape, never, Scope.Scope> {
314 const coreHandlers: AcpCoreRequestHandlers = {};
315 const notificationHandlers: AcpNotificationHandlers = {
316 sessionUpdate: { handlers: [], pending: [] },
317 elicitationComplete: { handlers: [], pending: [] },
318 };
319 const extRequestHandlers = new Map<
320 string,
321 (params: unknown) => Effect.Effect<unknown, AcpError.AcpError>
322 >();
323 const extNotificationHandlers = new Map<
324 string,
325 (params: unknown) => Effect.Effect<void, AcpError.AcpError>
326 >();
327 let unknownExtRequestHandler:
328 | ((method: string, params: unknown) => Effect.Effect<unknown, AcpError.AcpError>)
329 | undefined;
330 let unknownExtNotificationHandler:
331 | ((method: string, params: unknown) => Effect.Effect<void, AcpError.AcpError>)
332 | undefined;
333
334 const runNotificationHandlers = <A>(
335 registration: BufferedNotificationHandler<A>,
336 notification: A,
337 ) =>
338 Effect.forEach(
339 registration.handlers,
340 (handler) => handler(notification).pipe(Effect.catch(() => Effect.void)),
341 { discard: true },
342 );
343
344 const flushBufferedNotifications = <A>(registration: BufferedNotificationHandler<A>) =>
345 Effect.suspend(() => {
346 if (registration.handlers.length === 0 || registration.pending.length === 0) {
347 return Effect.void;
348 }
349 const pending = registration.pending.splice(0, registration.pending.length);
350 return Effect.forEach(
351 pending,
352 (notification) => runNotificationHandlers(registration, notification),
353 {
354 discard: true,
355 },
356 );
357 });
358
359 const dispatchNotification = (notification: AcpProtocol.AcpIncomingNotification) => {
360 switch (notification._tag) {
361 case "SessionUpdate": {
362 if (notificationHandlers.sessionUpdate.handlers.length === 0) {
363 notificationHandlers.sessionUpdate.pending.push(notification.params);
364 return Effect.void;
365 }
366 return runNotificationHandlers(notificationHandlers.sessionUpdate, notification.params);
367 }
368 case "ElicitationComplete": {
369 if (notificationHandlers.elicitationComplete.handlers.length === 0) {
370 notificationHandlers.elicitationComplete.pending.push(notification.params);
371 return Effect.void;
372 }
373 return runNotificationHandlers(
374 notificationHandlers.elicitationComplete,
375 notification.params,
376 );
377 }
378 case "ExtNotification": {
379 const handler = extNotificationHandlers.get(notification.method);
380 if (handler) {
381 return handler(notification.params);
382 }
383 return unknownExtNotificationHandler
384 ? unknownExtNotificationHandler(notification.method, notification.params)
385 : Effect.void;
386 }
387 }
388 };
389
390 const dispatchExtRequest = (method: string, params: unknown) => {
391 const handler = extRequestHandlers.get(method);
392 if (handler) {
393 return handler(params);
394 }
395 return unknownExtRequestHandler
396 ? unknownExtRequestHandler(method, params)
397 : Effect.fail(AcpError.AcpRequestError.methodNotFound(method));
398 };
399
400 const transport = yield* AcpProtocol.makeAcpPatchedProtocol({
401 stdio: stdio,
402 ...(terminationError ? { terminationError } : {}),
403 serverRequestMethods: new Set(AcpRpcs.ClientRpcs.requests.keys()),
404 ...(options.logIncoming !== undefined ? { logIncoming: options.logIncoming } : {}),
405 ...(options.logOutgoing !== undefined ? { logOutgoing: options.logOutgoing } : {}),
406 ...(options.logger ? { logger: options.logger } : {}),
407 onNotification: dispatchNotification,
408 onExtRequest: dispatchExtRequest,
409 });
410
411 const clientHandlerLayer = AcpRpcs.ClientRpcs.toLayer(
412 AcpRpcs.ClientRpcs.of({
413 [CLIENT_METHODS.session_request_permission]: (payload) =>
414 runHandler(
415 coreHandlers.requestPermission,
416 payload,
417 CLIENT_METHODS.session_request_permission,
418 ),
419 [CLIENT_METHODS.session_elicitation]: (payload) =>
420 runHandler(coreHandlers.elicitation, payload, CLIENT_METHODS.session_elicitation),
421 [CLIENT_METHODS.fs_read_text_file]: (payload) =>
422 runHandler(coreHandlers.readTextFile, payload, CLIENT_METHODS.fs_read_text_file),
423 [CLIENT_METHODS.fs_write_text_file]: (payload) =>
424 runHandler(coreHandlers.writeTextFile, payload, CLIENT_METHODS.fs_write_text_file).pipe(
425 Effect.map((result) => result ?? {}),
426 ),
427 [CLIENT_METHODS.terminal_create]: (payload) =>
428 runHandler(coreHandlers.createTerminal, payload, CLIENT_METHODS.terminal_create),
429 [CLIENT_METHODS.terminal_output]: (payload) =>
430 runHandler(coreHandlers.terminalOutput, payload, CLIENT_METHODS.terminal_output),
431 [CLIENT_METHODS.terminal_wait_for_exit]: (payload) =>
432 runHandler(
433 coreHandlers.terminalWaitForExit,
434 payload,
435 CLIENT_METHODS.terminal_wait_for_exit,
436 ),
437 [CLIENT_METHODS.terminal_kill]: (payload) =>
438 runHandler(coreHandlers.terminalKill, payload, CLIENT_METHODS.terminal_kill).pipe(
439 Effect.map((result) => result ?? {}),
440 ),
441 [CLIENT_METHODS.terminal_release]: (payload) =>
442 runHandler(coreHandlers.terminalRelease, payload, CLIENT_METHODS.terminal_release).pipe(
443 Effect.map((result) => result ?? {}),
444 ),
445 }),
446 );
447
448 yield* RpcServer.make(AcpRpcs.ClientRpcs).pipe(
449 Effect.provideService(RpcServer.Protocol, transport.serverProtocol),
450 Effect.provide(clientHandlerLayer),
451 Effect.forkScoped,
452 );
453
454 let nextRpcRequestId = 1n << 32n;
455 const rpc = yield* RpcClient.make(AcpRpcs.AgentRpcs, {
456 generateRequestId: () => nextRpcRequestId++ as never,
457 }).pipe(Effect.provideService(RpcClient.Protocol, transport.clientProtocol));
458
459 return AcpClient.of({
460 raw: {
461 notifications: transport.incoming,
462 request: transport.request,
463 notify: transport.notify,
464 },
465 agent: {
466 initialize: (payload) => callRpc(rpc[AGENT_METHODS.initialize](payload)),
467 authenticate: (payload) => callRpc(rpc[AGENT_METHODS.authenticate](payload)),
468 logout: (payload) => callRpc(rpc[AGENT_METHODS.logout](payload)),
469 createSession: (payload) => callRpc(rpc[AGENT_METHODS.session_new](payload)),
470 loadSession: (payload) => callRpc(rpc[AGENT_METHODS.session_load](payload)),
471 listSessions: (payload) => callRpc(rpc[AGENT_METHODS.session_list](payload)),
472 forkSession: (payload) => callRpc(rpc[AGENT_METHODS.session_fork](payload)),
473 resumeSession: (payload) => callRpc(rpc[AGENT_METHODS.session_resume](payload)),
474 closeSession: (payload) => callRpc(rpc[AGENT_METHODS.session_close](payload)),
475 setSessionModel: (payload) => callRpc(rpc[AGENT_METHODS.session_set_model](payload)),
476 setSessionConfigOption: (payload) =>
477 callRpc(rpc[AGENT_METHODS.session_set_config_option](payload)),
478 prompt: (payload) => callRpc(rpc[AGENT_METHODS.session_prompt](payload)),
479 cancel: (payload) => transport.notify(AGENT_METHODS.session_cancel, payload),
480 },
481 handleRequestPermission: (handler) =>
482 Effect.suspend(() => {
483 coreHandlers.requestPermission = handler;
484 return Effect.void;
485 }),
486 handleElicitation: (handler) =>
487 Effect.suspend(() => {
488 coreHandlers.elicitation = handler;
489 return Effect.void;
490 }),
491 handleReadTextFile: (handler) =>
492 Effect.suspend(() => {
493 coreHandlers.readTextFile = handler;
494 return Effect.void;
495 }),
496 handleWriteTextFile: (handler) =>
497 Effect.suspend(() => {
498 coreHandlers.writeTextFile = handler;
499 return Effect.void;
500 }),
501 handleCreateTerminal: (handler) =>
502 Effect.suspend(() => {
503 coreHandlers.createTerminal = handler;
504 return Effect.void;
505 }),
506 handleTerminalOutput: (handler) =>
507 Effect.suspend(() => {
508 coreHandlers.terminalOutput = handler;
509 return Effect.void;
510 }),
511 handleTerminalWaitForExit: (handler) =>
512 Effect.suspend(() => {
513 coreHandlers.terminalWaitForExit = handler;
514 return Effect.void;
515 }),
516 handleTerminalKill: (handler) =>
517 Effect.suspend(() => {
518 coreHandlers.terminalKill = handler;
519 return Effect.void;
520 }),
521 handleTerminalRelease: (handler) =>
522 Effect.suspend(() => {
523 coreHandlers.terminalRelease = handler;
524 return Effect.void;
525 }),
526 handleSessionUpdate: (handler) =>
527 Effect.suspend(() => {
528 notificationHandlers.sessionUpdate.handlers.push(handler);
529 return flushBufferedNotifications(notificationHandlers.sessionUpdate);
530 }),
531 handleElicitationComplete: (handler) =>
532 Effect.suspend(() => {
533 notificationHandlers.elicitationComplete.handlers.push(handler);
534 return flushBufferedNotifications(notificationHandlers.elicitationComplete);
535 }),
536 handleUnknownExtRequest: (handler) =>
537 Effect.suspend(() => {
538 unknownExtRequestHandler = handler;
539 return Effect.void;
540 }),
541 handleUnknownExtNotification: (handler) =>
542 Effect.suspend(() => {
543 unknownExtNotificationHandler = handler;
544 return Effect.void;
545 }),
546 handleExtRequest: (method, payload, handler) =>
547 Effect.suspend(() => {
548 extRequestHandlers.set(method, decodeExtRequestRegistration(method, payload, handler));
549 return Effect.void;
550 }),
551 handleExtNotification: (method, payload, handler) =>
552 Effect.suspend(() => {
553 extNotificationHandlers.set(
554 method,
555 decodeExtNotificationRegistration(method, payload, handler),
556 );
557 return Effect.void;
558 }),
559 });
560});
561
562export const layerChildProcess = (
563 handle: ChildProcessSpawner.ChildProcessHandle,
564 options: AcpClientOptions = {},
565): Layer.Layer<AcpClient> => {
566 const stdio = makeChildStdio(handle);
567 const terminationError = makeTerminationError(handle);
568 return Layer.effect(AcpClient, make(stdio, options, terminationError));
569};