feat(03-01): extend session metadata and PID tracking
- Add idle_timeout field (default 600s) to session metadata - Add get_session_timeout() helper to SessionManager - Add pid property to ClaudeSubprocess for PID tracking - Enables lifecycle management to query timeout values and track process PIDs
This commit is contained in:
parent
488d94ebcf
commit
74f12a13fc
2 changed files with 28 additions and 1 deletions
|
|
@ -113,6 +113,16 @@ class ClaudeSubprocess:
|
||||||
"""Return whether subprocess process is running."""
|
"""Return whether subprocess process is running."""
|
||||||
return self._process is not None and self._process.returncode is None
|
return self._process is not None and self._process.returncode is None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def pid(self) -> Optional[int]:
|
||||||
|
"""
|
||||||
|
Return process ID of running subprocess.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
PID if process is running, None otherwise
|
||||||
|
"""
|
||||||
|
return self._process.pid if self._process and self._process.returncode is None else None
|
||||||
|
|
||||||
async def start(self) -> None:
|
async def start(self) -> None:
|
||||||
"""
|
"""
|
||||||
Start the persistent Claude Code subprocess.
|
Start the persistent Claude Code subprocess.
|
||||||
|
|
|
||||||
|
|
@ -162,7 +162,8 @@ class SessionManager:
|
||||||
"last_active": now,
|
"last_active": now,
|
||||||
"persona": persona,
|
"persona": persona,
|
||||||
"pid": None,
|
"pid": None,
|
||||||
"status": "idle"
|
"status": "idle",
|
||||||
|
"idle_timeout": 600
|
||||||
}
|
}
|
||||||
self._write_metadata(name, metadata)
|
self._write_metadata(name, metadata)
|
||||||
|
|
||||||
|
|
@ -293,6 +294,22 @@ class SessionManager:
|
||||||
self._write_metadata(name, metadata)
|
self._write_metadata(name, metadata)
|
||||||
logger.debug(f"Updated session '{name}': {kwargs}")
|
logger.debug(f"Updated session '{name}': {kwargs}")
|
||||||
|
|
||||||
|
def get_session_timeout(self, name: str) -> int:
|
||||||
|
"""
|
||||||
|
Get session idle timeout in seconds.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
name: Session name
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Idle timeout in seconds (defaults to 600s if not set)
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
ValueError: If session does not exist
|
||||||
|
"""
|
||||||
|
metadata = self._read_metadata(name)
|
||||||
|
return metadata.get('idle_timeout', 600)
|
||||||
|
|
||||||
def session_exists(self, name: str) -> bool:
|
def session_exists(self, name: str) -> bool:
|
||||||
"""
|
"""
|
||||||
Check if session exists.
|
Check if session exists.
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue