qbraid_core.services.agents.AgentSessionRegistryManager

class qbraid_core.services.agents.AgentSessionRegistryManager(registry_path=None)

Manages the local agent session registry at ~/.qbraid/sessions.json.

Provides CRUD operations with file locking for cross-process safety.

__init__(registry_path=None)

Methods

__init__([registry_path])

batch_update()

Context manager for batch registry modifications.

deregister_session([session_id, pid, tool])

Mark a session as stopped.

find_by_pid(pid)

Find an active session by PID.

find_by_prefix(prefix)

Find the first session whose session_id starts with the given prefix.

find_by_tool(tool)

Find all active sessions for a given tool.

get_active_sessions()

Return all sessions that are not stopped or errored.

get_session(session_id)

Get a session by ID.

load_registry()

Load the registry from disk.

merge_discovered_sessions(discovered)

Merge discovered sessions into the registry.

prune_dead_sessions()

Check all active sessions for dead PIDs and mark them stopped.

refresh_discovered_sessions([threshold_s, ...])

Refresh activity status for discovered (external) sessions.

register_from_hook_payload(data)

Register an agent session from a hook payload dict.

register_session(session)

Add or update a session in the registry.

save_registry()

Write the registry to disk atomically.

search_sessions(*[, tool, status, tags, ...])

Search sessions with flexible filter criteria.

update_session(session_id, **updates)

Update fields on an existing session.

write_server_info(port, pid[, token])

Write ~/.qbraid/server.json with connection info.

Attributes

registry_path

Path to the registry file.