Overview
Thehcom term command provides terminal administration for PTY-managed agent instances. Query terminal screens, inject text/enter for approvals, and enable debug logging.
Screen Query
View the current terminal screen of running agents.Query All PTY Instances
Query Specific Agent
lines[]- Screen lines (array of strings)size[rows,cols]- Terminal dimensionscursor[row,col]- Cursor position (0-indexed)ready- Whether agent is ready for inputprompt_empty- Whether input buffer is emptyinput_text- Current text in input buffer
JSON Example
Text Injection
Inject text or enter key into agent terminal (for approvals, input).Inject Text Only
Inject Text + Enter
Inject Enter Only
Use Cases
Remote Approvals
Automated Workflows
Debug & Recovery
PTY Debug Logging
Enable detailed logging for PTY instances (screen updates, input, output).Enable Debug Logging
Disable Debug Logging
Check Debug Status
List Debug Logs
~/.hcom/.tmp/logs/pty_debug/
Technical Details
PTY Instances
Only agents launched withhcom N claude|gemini|codex|opencode have PTY support. These register inject ports in the notify_endpoints table.
Detection:
- PTY instances have inject ports (TCP localhost)
- Non-PTY instances (vanilla, ad-hoc) do not support term commands
Inject Protocol
- Text injection: TCP write to inject port
- Enter injection: Send
\r(carriage return) - 100ms delay between text and enter
- Non-blocking (fire and forget)
Screen Query Protocol
- Send
\x00SCREEN\nto inject port - Receive JSON response
- 2 second timeout
Debug Logging
When enabled:- Instances check flag file every ~10s
- Logs all PTY events (input, output, screen updates)
- Separate log file per instance
- No automatic cleanup (manual deletion required)
Error Handling
No Inject Port
hcom N <tool>, not vanilla.
No Response
hcom list.
Not Found
hcom list to see available agents.
Examples
Monitor Agent Screens
Approval Automation
Debug PTY Issues
Remote Control
Limitations
- PTY instances only (not vanilla or ad-hoc)
- No support for ANSI colors in screen dump
- Inject is fire-and-forget (no confirmation)
- Debug logs are not rotated
- Screen query shows rendered text only (no styling)
Tips
- Use
--jsonfor programmatic parsing - Check
readyfield before injecting - Use
--enterfor most operations - Enable debug logging only when needed (verbose output)
- Query screen before inject to verify state
- Use display names (resolves to full names automatically)
See Also
- hcom list - Agent status
- hcom status - System diagnostics
- hcom kill - Terminate agents