livekit-plugins-spatialreal 1.4.0__tar.gz → 1.4.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: livekit-plugins-spatialreal
3
- Version: 1.4.0
3
+ Version: 1.4.3
4
4
  Summary: Agent Framework plugin for SpatialReal Avatar
5
5
  Project-URL: Documentation, https://docs.spatialreal.com
6
6
  Project-URL: Website, https://www.spatialreal.ai/
@@ -22,7 +22,7 @@ Classifier: Topic :: Multimedia :: Sound/Audio
22
22
  Classifier: Topic :: Multimedia :: Video
23
23
  Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
24
24
  Requires-Python: >=3.10.0
25
- Requires-Dist: avatarkit>=0.1.3
25
+ Requires-Dist: avatarkit>=0.1.4
26
26
  Requires-Dist: livekit-agents>=1.2.9
27
27
  Description-Content-Type: text/markdown
28
28
 
@@ -115,12 +115,16 @@ Main class for integrating SpatialReal avatars with LiveKit agents.
115
115
  | `console_endpoint_url` | `str` | Custom console endpoint URL |
116
116
  | `ingress_endpoint_url` | `str` | Custom ingress endpoint URL |
117
117
  | `avatar_participant_identity` | `str` | LiveKit identity for avatar participant |
118
+ | `idle_timeout_seconds` | `int` | LiveKit egress idle timeout in seconds (`0` uses server defaults) |
118
119
 
119
120
  #### Methods
120
121
 
121
122
  - `start(agent_session, room, *, livekit_url, livekit_api_key, livekit_api_secret)`: Start the avatar session and hook into the agent's audio output.
122
123
  - `aclose()`: Clean up avatar session resources.
123
124
 
125
+ When starting, the plugin automatically sets `lk.publish_on_behalf` to the
126
+ agent participant identity for avatar worker association in LiveKit frontends.
127
+
124
128
  ### `SpatialRealException`
125
129
 
126
130
  Exception raised for SpatialReal-related errors.
@@ -87,12 +87,16 @@ Main class for integrating SpatialReal avatars with LiveKit agents.
87
87
  | `console_endpoint_url` | `str` | Custom console endpoint URL |
88
88
  | `ingress_endpoint_url` | `str` | Custom ingress endpoint URL |
89
89
  | `avatar_participant_identity` | `str` | LiveKit identity for avatar participant |
90
+ | `idle_timeout_seconds` | `int` | LiveKit egress idle timeout in seconds (`0` uses server defaults) |
90
91
 
91
92
  #### Methods
92
93
 
93
94
  - `start(agent_session, room, *, livekit_url, livekit_api_key, livekit_api_secret)`: Start the avatar session and hook into the agent's audio output.
94
95
  - `aclose()`: Clean up avatar session resources.
95
96
 
97
+ When starting, the plugin automatically sets `lk.publish_on_behalf` to the
98
+ agent participant identity for avatar worker association in LiveKit frontends.
99
+
96
100
  ### `SpatialRealException`
97
101
 
98
102
  Exception raised for SpatialReal-related errors.
@@ -10,6 +10,7 @@ from __future__ import annotations
10
10
  import asyncio
11
11
  import os
12
12
  from datetime import datetime, timedelta, timezone
13
+ from typing import Any
13
14
 
14
15
  from avatarkit import (
15
16
  AvatarSession as AvatarkitSession,
@@ -55,6 +56,8 @@ class AvatarSession:
55
56
  ingress_endpoint_url: Ingress endpoint URL. Falls back to
56
57
  SPATIALREAL_INGRESS_ENDPOINT env var or default.
57
58
  avatar_participant_identity: LiveKit identity for the avatar participant.
59
+ idle_timeout_seconds: Idle timeout in seconds for the egress connection.
60
+ A value of 0 uses server defaults.
58
61
 
59
62
  Usage:
60
63
  avatar = AvatarSession()
@@ -70,6 +73,7 @@ class AvatarSession:
70
73
  console_endpoint_url: str | None = None,
71
74
  ingress_endpoint_url: str | None = None,
72
75
  avatar_participant_identity: str | None = None,
76
+ idle_timeout_seconds: int = 0,
73
77
  ) -> None:
74
78
  # Resolve API key
75
79
  self._api_key = api_key or os.getenv("SPATIALREAL_API_KEY")
@@ -101,6 +105,10 @@ class AvatarSession:
101
105
  # Avatar participant configuration
102
106
  self._avatar_participant_identity = avatar_participant_identity or DEFAULT_AVATAR_PARTICIPANT_IDENTITY
103
107
 
108
+ if idle_timeout_seconds < 0:
109
+ raise SpatialRealException("idle_timeout_seconds must be greater than or equal to 0")
110
+ self._idle_timeout_seconds = idle_timeout_seconds
111
+
104
112
  # Internal state
105
113
  self._avatarkit_session: AvatarkitSession | None = None
106
114
  self._agent_session: AgentSession | None = None
@@ -145,18 +153,24 @@ class AvatarSession:
145
153
  )
146
154
 
147
155
  room_name = room.name
156
+ agent_participant_identity = room.local_participant.identity
148
157
  logger.info(f"Initializing SpatialReal avatar session for room: {room_name}")
149
158
  logger.debug(f"Console endpoint: {self._console_endpoint_url}")
150
159
  logger.debug(f"Ingress endpoint: {self._ingress_endpoint_url}")
151
160
 
161
+ egress_attributes = {"lk.publish_on_behalf": agent_participant_identity}
162
+
152
163
  # Create LiveKit egress configuration for the avatar to join the room
153
- livekit_egress = LiveKitEgressConfig(
154
- url=lk_url,
155
- api_key=lk_api_key,
156
- api_secret=lk_api_secret,
157
- room_name=room_name,
158
- publisher_id=self._avatar_participant_identity,
159
- )
164
+ livekit_egress_kwargs: dict[str, Any] = {
165
+ "url": lk_url,
166
+ "api_key": lk_api_key,
167
+ "api_secret": lk_api_secret,
168
+ "room_name": room_name,
169
+ "publisher_id": self._avatar_participant_identity,
170
+ "extra_attributes": egress_attributes,
171
+ "idle_timeout": self._idle_timeout_seconds,
172
+ }
173
+ livekit_egress = LiveKitEgressConfig(**livekit_egress_kwargs)
160
174
 
161
175
  # Create avatar session with LiveKit egress mode
162
176
  self._avatarkit_session = new_avatar_session(
@@ -0,0 +1 @@
1
+ __version__ = "1.4.3"
@@ -27,7 +27,7 @@ classifiers = [
27
27
  ]
28
28
  dependencies = [
29
29
  "livekit-agents>=1.2.9",
30
- "avatarkit>=0.1.3",
30
+ "avatarkit>=0.1.4",
31
31
  ]
32
32
 
33
33
  [project.urls]
@@ -1 +0,0 @@
1
- __version__ = "1.4.0"