Handle to a spawned agent subprocess (or test double). ``send_to_agent``: write a JSON-encoded SDK message into the agent's stdin (caller adds a trailing newline if needed). ``messages_from_agent``: async iterator yielding SDK message dicts parsed from the agent's stdout. ``shut
| 54 | |
| 55 | @dataclass |
| 56 | class AgentHandle: |
| 57 | """Handle to a spawned agent subprocess (or test double). |
| 58 | |
| 59 | ``send_to_agent``: write a JSON-encoded SDK message into the agent's |
| 60 | stdin (caller adds a trailing newline if needed). |
| 61 | ``messages_from_agent``: async iterator yielding SDK message dicts |
| 62 | parsed from the agent's stdout. |
| 63 | ``shutdown``: terminate the agent and clean up. |
| 64 | """ |
| 65 | |
| 66 | send_to_agent: Callable[[dict], Awaitable[None]] |
| 67 | messages_from_agent: Callable[[], AsyncIterator[dict]] |
| 68 | shutdown: Callable[[], Awaitable[None]] |
| 69 | |
| 70 | |
| 71 | # ─── HTTP/1.1 minimal parser for POST /sessions ──────────────────────────── |