MCPcopy Create free account
hub / github.com/github/copilot-sdk / _session_lifecycle_event_from_dict

Function _session_lifecycle_event_from_dict

python/copilot/client.py:985–1002  ·  view source on GitHub ↗

Construct the correct :class:`SessionLifecycleEvent` variant from a wire dict.

(data: dict)

Source from the content-addressed store, hash-verified

983
984
985def _session_lifecycle_event_from_dict(data: dict) -> SessionLifecycleEvent:
986 """Construct the correct :class:`SessionLifecycleEvent` variant from a wire dict."""
987 metadata = None
988 if "metadata" in data and data["metadata"]:
989 metadata = SessionLifecycleEventMetadata.from_dict(data["metadata"])
990 session_id = data.get("sessionId", "")
991 event_type = data.get("type")
992 if event_type == "session.created":
993 return SessionCreatedEvent(session_id=session_id, metadata=metadata)
994 if event_type == "session.deleted":
995 return SessionDeletedEvent(session_id=session_id, metadata=metadata)
996 if event_type == "session.foreground":
997 return SessionForegroundEvent(session_id=session_id, metadata=metadata)
998 if event_type == "session.background":
999 return SessionBackgroundEvent(session_id=session_id, metadata=metadata)
1000 # Default to ``session.updated`` for unknown event types so consumers
1001 # keep working across server upgrades.
1002 return SessionUpdatedEvent(session_id=session_id, metadata=metadata)
1003
1004
1005SessionLifecycleHandler = Callable[[SessionLifecycleEvent], None]

Callers 1

handle_notificationMethod · 0.85

Calls 7

SessionCreatedEventClass · 0.70
SessionDeletedEventClass · 0.70
SessionUpdatedEventClass · 0.70
from_dictMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…