Module 18: Terminal Operations
Execute shell commands on the client through the terminal API.What Youβll Learn
- The four-step terminal lifecycle: create, wait, output, release
- Implementing terminal handlers on the client
- Using the terminal API from the agent side
The Code
Client: Implement terminal handlers
Agent: Use terminal API
Terminal Lifecycle
| Step | Agent calls | Client handles | Purpose |
|---|---|---|---|
| 1 | createTerminal() | createTerminalHandler | Spawn process |
| 2 | waitForTerminalExit() | waitForTerminalExitHandler | Block until done |
| 3 | getTerminalOutput() | terminalOutputHandler | Read stdout/stderr |
| 4 | releaseTerminal() | releaseTerminalHandler | Clean up resources |
The SDK also provides
context.execute() as a convenience method that combines all four steps.