Eai. Sandbox. PTYPool
(eai v1.0.0)
Copy Markdown
GenServer pool managing per-session PTY processes and task dispatching.
Summary
Functions
Returns a specification to start this module under a supervisor.
Clear a completed task from PTY session state.
Execute command asynchronously in a PTY session.
Force reset a PTY session (kill processes, clear state).
Callback implementation for GenServer.init/1.
Set interrupt flag for a PTY session (injects Ctrl+C on next poll).
List all active PTY sessions.
Send raw input to PTY (for interactive prompts, Ctrl+C, etc.).
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
Clear a completed task from PTY session state.
Internal use (cache cleanup).
Options
pty_session_id(string) — Session.task_id(string) — Task to clear.
Returns
`:ok` or `{:error, reason}`
Execute command asynchronously in a PTY session.
Submits command to PTY, returns task_id immediately. Results collected via ResultCollector.get/1.
Options
pty_session_id(string) — PTY session for isolation. Default:"default"cmd(string) — Shell command or script (may contain sentinels).task_id(string, optional) — Custom task ID. Auto-generated if omitted.
Returns
`{:ok, task_id}` or `{:error, reason}`Example
iex> Eai.Sandbox.PTYPool.exec_async("default", "ls -la")
{:ok, "task_1234567890"}
Force reset a PTY session (kill processes, clear state).
Use after hang or corruption. PTY recreated on next command.
Options
pty_session_id(string) — Session to reset.
Returns
`:ok` or `{:error, reason}`
Callback implementation for GenServer.init/1.
Set interrupt flag for a PTY session (injects Ctrl+C on next poll).
Internal use (called by Chat.interrupt!).
Options
pty_session_id(string) — Session to interrupt.
Returns
`:ok` or `{:error, reason}`
List all active PTY sessions.
Returns
List of session IDs: `["default", "task_1", ...]`
Send raw input to PTY (for interactive prompts, Ctrl+C, etc.).
Options
pty_session_id(string) — Target session.input(string) — Raw input to send. Supports escape sequences:\n= newline,\r= carriage return,\t= tab\x03= Ctrl+C,\x04= Ctrl+D,\x1a= Ctrl+Z
Example
iex> Eai.Sandbox.PTYPool.write_raw("default", "\x03") # Send Ctrl+C
:ok