Open History to see the last commit
1import * as Effect from "effect/Effect";
2
3import type * as AcpSchema from "./_generated/schema.gen.ts";
4import type * as AcpError from "./errors.ts";
5
6export interface AcpTerminal {
7 readonly sessionId: string;
8 readonly terminalId: string;
9 /** Reads buffered output from the terminal.
10 * Spec: https://agentclientprotocol.com/protocol/schema#terminal/output
11 */
12 readonly output: Effect.Effect<AcpSchema.TerminalOutputResponse, AcpError.AcpError>;
13 /** Waits for terminal exit and returns the exit result.
14 * Spec: https://agentclientprotocol.com/protocol/schema#terminal/wait_for_exit
15 */
16 readonly waitForExit: Effect.Effect<AcpSchema.WaitForTerminalExitResponse, AcpError.AcpError>;
17 /** Terminates the terminal process.
18 * Spec: https://agentclientprotocol.com/protocol/schema#terminal/kill
19 */
20 readonly kill: Effect.Effect<AcpSchema.KillTerminalResponse, AcpError.AcpError>;
21 /** Releases the terminal handle from the ACP session.
22 * Spec: https://agentclientprotocol.com/protocol/schema#terminal/release
23 */
24 readonly release: Effect.Effect<AcpSchema.ReleaseTerminalResponse, AcpError.AcpError>;
25}
26
27export interface MakeTerminalOptions {
28 readonly sessionId: string;
29 readonly terminalId: string;
30 readonly output: Effect.Effect<AcpSchema.TerminalOutputResponse, AcpError.AcpError>;
31 readonly waitForExit: Effect.Effect<AcpSchema.WaitForTerminalExitResponse, AcpError.AcpError>;
32 readonly kill: Effect.Effect<AcpSchema.KillTerminalResponse, AcpError.AcpError>;
33 readonly release: Effect.Effect<AcpSchema.ReleaseTerminalResponse, AcpError.AcpError>;
34}
35
36export function makeTerminal(options: MakeTerminalOptions): AcpTerminal {
37 return {
38 sessionId: options.sessionId,
39 terminalId: options.terminalId,
40 output: options.output,
41 waitForExit: options.waitForExit,
42 kill: options.kill,
43 release: options.release,
44 };
45}