feat: add pty monitoring

This commit is contained in:
h
2026-05-23 00:37:28 +02:00
parent 3394617163
commit 27e6e5a1bf
2 changed files with 38 additions and 3 deletions
+12
View File
@@ -149,6 +149,18 @@ class ClaudeCodeBackend:
def live_session_count(self) -> int:
return len(self._sessions)
@property
def live_sessions(self) -> dict[str, PtyClaudeProcess]:
"""Snapshot of live PTY processes keyed by ``session_id``.
Returned dict is a copy — caller may iterate freely without
worrying about concurrent ``complete()`` calls reshuffling
``_sessions`` (which is keyed by history fingerprint, not
``session_id``). Intended for debug surfaces (e.g. admin
terminal viewer) that need to look up a session by id.
"""
return {s.session_id: s.pty for s in self._sessions.values()}
async def complete(self, messages: list[Mapping[str, Any]]) -> AsyncIterator[Event]:
"""Run one turn against the matching session (or spawn one).