The TerminalHandle class provides methods to interact with a terminal created by an agent. It allows you to get output, wait for completion, kill processes, and release resources.Terminal handles are typically created by agents and provided to clients for terminal management operations.See the source at lib/src/acp.dart:1126-1213.
Gets the current terminal output without waiting for the command to exit.Returns the current stdout, stderr, and exit status if the command has already completed.
Waits for the terminal command to complete and returns its exit status.This method blocks until the command finishes execution, then returns the exit code that indicates the command’s success or failure.
// Kill a long-running commandawait terminalHandle.kill();// Get the final outputfinal output = await terminalHandle.currentOutput();print('Output before kill: ${output.output}');// Release when doneawait terminalHandle.release();
Releases the terminal and frees all associated resources.If the command is still running, it will be killed. After release, the terminal ID becomes invalid and cannot be used with other terminal methods.Tool calls that already reference this terminal will continue to display its output.
Important: Always call this method when done with the terminal to prevent resource leaks.
Disposes of the terminal handle and releases resources.This is the Dart equivalent of TypeScript’s [Symbol.asyncDispose]. It ensures proper cleanup by calling release().Implements the AsyncDisposable interface.