livekit-plugins-facemode 0.1.0__tar.gz → 0.2.0__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.
Files changed (20) hide show
  1. livekit_plugins_facemode-0.2.0/LICENSE +177 -0
  2. livekit_plugins_facemode-0.2.0/PKG-INFO +101 -0
  3. {livekit_plugins_facemode-0.1.0 → livekit_plugins_facemode-0.2.0}/README.md +9 -3
  4. {livekit_plugins_facemode-0.1.0 → livekit_plugins_facemode-0.2.0}/livekit_plugins_facemode/__init__.py +17 -17
  5. {livekit_plugins_facemode-0.1.0 → livekit_plugins_facemode-0.2.0}/livekit_plugins_facemode/exceptions.py +17 -17
  6. livekit_plugins_facemode-0.2.0/livekit_plugins_facemode/version.py +1 -0
  7. livekit_plugins_facemode-0.2.0/livekit_plugins_facemode.egg-info/PKG-INFO +101 -0
  8. {livekit_plugins_facemode-0.1.0 → livekit_plugins_facemode-0.2.0}/pyproject.toml +12 -2
  9. livekit_plugins_facemode-0.1.0/LICENSE +0 -13
  10. livekit_plugins_facemode-0.1.0/PKG-INFO +0 -13
  11. livekit_plugins_facemode-0.1.0/livekit_plugins_facemode/version.py +0 -1
  12. livekit_plugins_facemode-0.1.0/livekit_plugins_facemode.egg-info/PKG-INFO +0 -13
  13. {livekit_plugins_facemode-0.1.0 → livekit_plugins_facemode-0.2.0}/livekit_plugins_facemode/avatar.py +0 -0
  14. {livekit_plugins_facemode-0.1.0 → livekit_plugins_facemode-0.2.0}/livekit_plugins_facemode/models.py +0 -0
  15. {livekit_plugins_facemode-0.1.0 → livekit_plugins_facemode-0.2.0}/livekit_plugins_facemode.egg-info/SOURCES.txt +0 -0
  16. {livekit_plugins_facemode-0.1.0 → livekit_plugins_facemode-0.2.0}/livekit_plugins_facemode.egg-info/dependency_links.txt +0 -0
  17. {livekit_plugins_facemode-0.1.0 → livekit_plugins_facemode-0.2.0}/livekit_plugins_facemode.egg-info/requires.txt +0 -0
  18. {livekit_plugins_facemode-0.1.0 → livekit_plugins_facemode-0.2.0}/livekit_plugins_facemode.egg-info/top_level.txt +0 -0
  19. {livekit_plugins_facemode-0.1.0 → livekit_plugins_facemode-0.2.0}/setup.cfg +0 -0
  20. {livekit_plugins_facemode-0.1.0 → livekit_plugins_facemode-0.2.0}/test/test_ingestion.py +0 -0
@@ -0,0 +1,177 @@
1
+ Copyright 2026 InfinityLevel OPC Private Limited
2
+
3
+ Apache License
4
+ Version 2.0, January 2004
5
+ http://www.apache.org/licenses/
6
+
7
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8
+
9
+ 1. Definitions.
10
+
11
+ "License" shall mean the terms and conditions for use, reproduction,
12
+ and distribution as defined by Sections 1 through 9 of this document.
13
+
14
+ "Licensor" shall mean the copyright owner or entity authorized by
15
+ the copyright owner that is granting the License.
16
+
17
+ "Legal Entity" shall mean the union of the acting entity and all
18
+ other entities that control, are controlled by, or are under common
19
+ control with that entity. For the purposes of this definition,
20
+ "control" means (i) the power, direct or indirect, to cause the
21
+ direction or management of such entity, whether by contract or
22
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
23
+ outstanding shares, or (iii) beneficial ownership of such entity.
24
+
25
+ "You" (or "Your") shall mean an individual or Legal Entity
26
+ exercising permissions granted by this License.
27
+
28
+ "Source" form shall mean the preferred form for making modifications,
29
+ including but not limited to software source code, documentation
30
+ source, and configuration files.
31
+
32
+ "Object" form shall mean any form resulting from mechanical
33
+ transformation or translation of a Source form, including but
34
+ not limited to compiled object code, generated documentation,
35
+ and conversions to other media types.
36
+
37
+ "Work" shall mean the work of authorship, whether in Source or
38
+ Object form, made available under the License, as indicated by a
39
+ copyright notice that is included in or attached to the work
40
+ (an example is provided in the Appendix below).
41
+
42
+ "Derivative Works" shall mean any work, whether in Source or Object
43
+ form, that is based on (or derived from) the Work and for which the
44
+ editorial revisions, annotations, elaborations, or other modifications
45
+ represent, as a whole, an original work of authorship. For the purposes
46
+ of this License, Derivative Works shall not include works that remain
47
+ separable from, or merely link (or bind by name) to the interfaces of,
48
+ the Work and Derivative Works thereof.
49
+
50
+ "Contribution" shall mean any work of authorship, including
51
+ the original version of the Work and any modifications or additions
52
+ to that Work or Derivative Works thereof, that is intentionally
53
+ submitted to Licensor for inclusion in the Work by the copyright owner
54
+ or by an individual or Legal Entity authorized to submit on behalf of
55
+ the copyright owner. For the purposes of this definition, "submitted"
56
+ means any form of electronic, verbal, or written communication sent
57
+ to the Licensor or its representatives, including but not limited to
58
+ communication on electronic mailing lists, source code control systems,
59
+ and issue tracking systems that are managed by, or on behalf of, the
60
+ Licensor for the purpose of discussing and improving the Work, but
61
+ excluding communication that is conspicuously marked or otherwise
62
+ designated in writing by the copyright owner as "Not a Contribution."
63
+
64
+ "Contributor" shall mean Licensor and any individual or Legal Entity
65
+ on behalf of whom a Contribution has been received by Licensor and
66
+ subsequently incorporated within the Work.
67
+
68
+ 2. Grant of Copyright License. Subject to the terms and conditions of
69
+ this License, each Contributor hereby grants to You a perpetual,
70
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
71
+ copyright license to reproduce, prepare Derivative Works of,
72
+ publicly display, publicly perform, sublicense, and distribute the
73
+ Work and such Derivative Works in Source or Object form.
74
+
75
+ 3. Grant of Patent License. Subject to the terms and conditions of
76
+ this License, each Contributor hereby grants to You a perpetual,
77
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
78
+ (except as stated in this section) patent license to make, have made,
79
+ use, offer to sell, sell, import, and otherwise transfer the Work,
80
+ where such license applies only to those patent claims licensable
81
+ by such Contributor that are necessarily infringed by their
82
+ Contribution(s) alone or by combination of their Contribution(s)
83
+ with the Work to which such Contribution(s) was submitted. If You
84
+ institute patent litigation against any entity (including a
85
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
86
+ or a Contribution incorporated within the Work constitutes direct
87
+ or contributory patent infringement, then any patent licenses
88
+ granted to You under this License for that Work shall terminate
89
+ as of the date such litigation is filed.
90
+
91
+ 4. Redistribution. You may reproduce and distribute copies of the
92
+ Work or Derivative Works thereof in any medium, with or without
93
+ modifications, provided that You meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of the
105
+ Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
@@ -0,0 +1,101 @@
1
+ Metadata-Version: 2.4
2
+ Name: livekit-plugins-facemode
3
+ Version: 0.2.0
4
+ Summary: FaceMode avatar integration for LiveKit Agents
5
+ Author: FaceMode
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://facemode.io
8
+ Project-URL: Repository, https://github.com/facemode-by-infinitylevel/facemode-integrations
9
+ Keywords: livekit,agents,avatar,facemode,ai,video,realtime
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Classifier: Topic :: Multimedia :: Video
14
+ Requires-Python: >=3.13
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ Requires-Dist: aiohttp<4,>=3.10
18
+ Requires-Dist: livekit<2,>=1.1
19
+ Requires-Dist: livekit-agents<2,>=1.7
20
+ Requires-Dist: websockets<17,>=14
21
+ Dynamic: license-file
22
+
23
+ # livekit-plugins-facemode
24
+
25
+ FaceMode avatar output for LiveKit Agents Python applications.
26
+
27
+ ## Install
28
+
29
+ ```bash
30
+ pip install livekit-plugins-facemode
31
+ ```
32
+
33
+ From this repository:
34
+
35
+ ```bash
36
+ pip install .
37
+ ```
38
+
39
+ Requires Python 3.13 or later, LiveKit 1.x, and LiveKit Agents 1.7 or later.
40
+
41
+ ## Usage
42
+
43
+ The host application supplies a server-side LiveKit room object. The room token
44
+ must grant the FaceMode worker permission to join, publish, and subscribe in the
45
+ customer room. Keep the token on the server and never log it or expose it to a
46
+ browser client.
47
+
48
+ ```python
49
+ import os
50
+
51
+ from livekit.agents import Agent, AgentSession, room_io
52
+ from livekit_plugins_facemode import AvatarSession
53
+
54
+ avatar = AvatarSession(
55
+ api_key=os.environ["FACEMODE_API_KEY"],
56
+ avatar_id=os.environ.get("FACEMODE_AVATAR_ID", ""),
57
+ )
58
+
59
+ await ctx.connect()
60
+ await avatar.start(
61
+ agent_session,
62
+ ctx.room,
63
+ room={
64
+ "type": "livekit",
65
+ "url": os.environ["LIVEKIT_URL"],
66
+ "token": os.environ["LIVEKIT_TOKEN"],
67
+ },
68
+ )
69
+ await agent_session.start(
70
+ agent=Agent(instructions="You are a helpful assistant."),
71
+ room=ctx.room,
72
+ room_options=room_io.RoomOptions(audio_output=False),
73
+ )
74
+ await avatar.wait_for_join()
75
+ ```
76
+
77
+ `AvatarSession.start()` creates a FaceMode session with the room object. The create response normally returns `ready: true` with the ingestion `url` and a one-time `wsToken` (about 15 minute expiry), so no polling happens in the common path. If worker assignment is still pending, the plugin polls the session endpoint with bounded backoff for up to 240 seconds and stops immediately on `FAILED`/`ENDED` worker states. The initial response's room credentials remain in memory and are not expected in the polling response.
78
+
79
+ The ingestion WebSocket handshake uses the `Sec-WebSocket-Protocol` subprotocol `facemode.<wsToken>` with a 240 second open timeout. When the backend returns optional `ingestion.headers`, the plugin forwards them during the handshake. It disables compression and native WebSocket keepalives in favor of the canonical application `ping`/`pong` messages after negotiation.
80
+
81
+ Pass `input_provider` (one of `deepgram`, `gemini`, `gnani`, `elevenlabs`, `openai`, `cartesia`, `sarvam`, `custom`) to `AvatarSession` when the session should pin a specific upstream input provider; it is omitted from the request otherwise.
82
+
83
+ If the WebSocket transport drops after the protocol has started, the plugin auto-reconnects in the background: it POSTs the session reconnect endpoint for a fresh one-time `wsToken` (a consumed token is never reused), opens a new socket with `facemode.<newToken>`, re-sends the canonical `start` message, and waits for `started` before resuming. Outgoing control `seq` numbers stay monotonic across the reconnect and buffered audio is not replayed. Reconnect is bounded to 2 attempts with backoff and is single-flight; exhaustion surfaces a typed `FaceModeNotReadyError`/`FaceModeAPIError`. Intentional `stop()`, a canonical `ended`, fatal protocol errors, and drops before the first negotiation do not reconnect.
84
+
85
+ Every TTS frame is sent as canonical PCM audio. The plugin locks sample rate and channel count at protocol negotiation and rejects a format change or unaligned 16-bit PCM afterward. `cancel_utterance` is sent when LiveKit interrupts the audio output. Graceful close sends `end_session` and waits briefly for canonical `ended`; `ended` is a protocol acknowledgement, not backend cleanup confirmation.
86
+
87
+ ## Token grants
88
+
89
+ The `room.token` value must allow the worker to join the customer room and
90
+ publish its avatar audio/video tracks. If the token uses a fixed participant
91
+ identity, use `avatar_participant_identity` and make the room policy allow that
92
+ identity. The worker does not create or replace the customer LiveKit room.
93
+
94
+ ## API URL
95
+
96
+ The default API URL is `https://api.facemode.io/api`. Set `api_url` for a
97
+ self-hosted or local backend.
98
+
99
+ ## License
100
+
101
+ Apache-2.0 - see [LICENSE](LICENSE). Part of the [facemode-integrations](https://github.com/facemode-by-infinitylevel/facemode-integrations) monorepo.
@@ -4,16 +4,18 @@ FaceMode avatar output for LiveKit Agents Python applications.
4
4
 
5
5
  ## Install
6
6
 
7
- ```powershell
7
+ ```bash
8
8
  pip install livekit-plugins-facemode
9
9
  ```
10
10
 
11
11
  From this repository:
12
12
 
13
- ```powershell
13
+ ```bash
14
14
  pip install .
15
15
  ```
16
16
 
17
+ Requires Python 3.13 or later, LiveKit 1.x, and LiveKit Agents 1.7 or later.
18
+
17
19
  ## Usage
18
20
 
19
21
  The host application supplies a server-side LiveKit room object. The room token
@@ -52,7 +54,7 @@ await avatar.wait_for_join()
52
54
 
53
55
  `AvatarSession.start()` creates a FaceMode session with the room object. The create response normally returns `ready: true` with the ingestion `url` and a one-time `wsToken` (about 15 minute expiry), so no polling happens in the common path. If worker assignment is still pending, the plugin polls the session endpoint with bounded backoff for up to 240 seconds and stops immediately on `FAILED`/`ENDED` worker states. The initial response's room credentials remain in memory and are not expected in the polling response.
54
56
 
55
- The ingestion WebSocket handshake uses the `Sec-WebSocket-Protocol` subprotocol `facemode.<wsToken>` (the older `aivatar.` prefix is rejected) with a 240 second open timeout. When the backend returns optional `ingestion.headers`, the plugin forwards them during the handshake. It disables compression and native WebSocket keepalives in favor of the canonical application `ping`/`pong` messages after negotiation.
57
+ The ingestion WebSocket handshake uses the `Sec-WebSocket-Protocol` subprotocol `facemode.<wsToken>` with a 240 second open timeout. When the backend returns optional `ingestion.headers`, the plugin forwards them during the handshake. It disables compression and native WebSocket keepalives in favor of the canonical application `ping`/`pong` messages after negotiation.
56
58
 
57
59
  Pass `input_provider` (one of `deepgram`, `gemini`, `gnani`, `elevenlabs`, `openai`, `cartesia`, `sarvam`, `custom`) to `AvatarSession` when the session should pin a specific upstream input provider; it is omitted from the request otherwise.
58
60
 
@@ -71,3 +73,7 @@ identity. The worker does not create or replace the customer LiveKit room.
71
73
 
72
74
  The default API URL is `https://api.facemode.io/api`. Set `api_url` for a
73
75
  self-hosted or local backend.
76
+
77
+ ## License
78
+
79
+ Apache-2.0 - see [LICENSE](LICENSE). Part of the [facemode-integrations](https://github.com/facemode-by-infinitylevel/facemode-integrations) monorepo.
@@ -1,17 +1,17 @@
1
- from .avatar import AvatarSession
2
- from .exceptions import FaceModeAPIError, FaceModeError, FaceModeNotReadyError, FaceModeProtocolError
3
- from .models import IngestionDetails, LiveKitRoom, SessionDetails, SessionRequest
4
- from .version import __version__
5
-
6
- __all__ = [
7
- "AvatarSession",
8
- "FaceModeAPIError",
9
- "FaceModeError",
10
- "FaceModeNotReadyError",
11
- "FaceModeProtocolError",
12
- "IngestionDetails",
13
- "LiveKitRoom",
14
- "SessionDetails",
15
- "SessionRequest",
16
- "__version__",
17
- ]
1
+ from .avatar import AvatarSession
2
+ from .exceptions import FaceModeAPIError, FaceModeError, FaceModeNotReadyError, FaceModeProtocolError
3
+ from .models import IngestionDetails, LiveKitRoom, SessionDetails, SessionRequest
4
+ from .version import __version__
5
+
6
+ __all__ = [
7
+ "AvatarSession",
8
+ "FaceModeAPIError",
9
+ "FaceModeError",
10
+ "FaceModeNotReadyError",
11
+ "FaceModeProtocolError",
12
+ "IngestionDetails",
13
+ "LiveKitRoom",
14
+ "SessionDetails",
15
+ "SessionRequest",
16
+ "__version__",
17
+ ]
@@ -1,17 +1,17 @@
1
- """FaceMode LiveKit plugin exceptions."""
2
-
3
-
4
- class FaceModeError(RuntimeError):
5
- """Base error for FaceMode integration failures."""
6
-
7
-
8
- class FaceModeAPIError(FaceModeError):
9
- """Raised when the FaceMode REST API rejects a request."""
10
-
11
-
12
- class FaceModeProtocolError(FaceModeError):
13
- """Raised when the FaceMode WebSocket reports a protocol error."""
14
-
15
-
16
- class FaceModeNotReadyError(FaceModeError):
17
- """Raised when the avatar does not publish its video track in time."""
1
+ """FaceMode LiveKit plugin exceptions."""
2
+
3
+
4
+ class FaceModeError(RuntimeError):
5
+ """Base error for FaceMode integration failures."""
6
+
7
+
8
+ class FaceModeAPIError(FaceModeError):
9
+ """Raised when the FaceMode REST API rejects a request."""
10
+
11
+
12
+ class FaceModeProtocolError(FaceModeError):
13
+ """Raised when the FaceMode WebSocket reports a protocol error."""
14
+
15
+
16
+ class FaceModeNotReadyError(FaceModeError):
17
+ """Raised when the avatar does not publish its video track in time."""
@@ -0,0 +1 @@
1
+ __version__ = "0.2.0"
@@ -0,0 +1,101 @@
1
+ Metadata-Version: 2.4
2
+ Name: livekit-plugins-facemode
3
+ Version: 0.2.0
4
+ Summary: FaceMode avatar integration for LiveKit Agents
5
+ Author: FaceMode
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://facemode.io
8
+ Project-URL: Repository, https://github.com/facemode-by-infinitylevel/facemode-integrations
9
+ Keywords: livekit,agents,avatar,facemode,ai,video,realtime
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Classifier: Topic :: Multimedia :: Video
14
+ Requires-Python: >=3.13
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ Requires-Dist: aiohttp<4,>=3.10
18
+ Requires-Dist: livekit<2,>=1.1
19
+ Requires-Dist: livekit-agents<2,>=1.7
20
+ Requires-Dist: websockets<17,>=14
21
+ Dynamic: license-file
22
+
23
+ # livekit-plugins-facemode
24
+
25
+ FaceMode avatar output for LiveKit Agents Python applications.
26
+
27
+ ## Install
28
+
29
+ ```bash
30
+ pip install livekit-plugins-facemode
31
+ ```
32
+
33
+ From this repository:
34
+
35
+ ```bash
36
+ pip install .
37
+ ```
38
+
39
+ Requires Python 3.13 or later, LiveKit 1.x, and LiveKit Agents 1.7 or later.
40
+
41
+ ## Usage
42
+
43
+ The host application supplies a server-side LiveKit room object. The room token
44
+ must grant the FaceMode worker permission to join, publish, and subscribe in the
45
+ customer room. Keep the token on the server and never log it or expose it to a
46
+ browser client.
47
+
48
+ ```python
49
+ import os
50
+
51
+ from livekit.agents import Agent, AgentSession, room_io
52
+ from livekit_plugins_facemode import AvatarSession
53
+
54
+ avatar = AvatarSession(
55
+ api_key=os.environ["FACEMODE_API_KEY"],
56
+ avatar_id=os.environ.get("FACEMODE_AVATAR_ID", ""),
57
+ )
58
+
59
+ await ctx.connect()
60
+ await avatar.start(
61
+ agent_session,
62
+ ctx.room,
63
+ room={
64
+ "type": "livekit",
65
+ "url": os.environ["LIVEKIT_URL"],
66
+ "token": os.environ["LIVEKIT_TOKEN"],
67
+ },
68
+ )
69
+ await agent_session.start(
70
+ agent=Agent(instructions="You are a helpful assistant."),
71
+ room=ctx.room,
72
+ room_options=room_io.RoomOptions(audio_output=False),
73
+ )
74
+ await avatar.wait_for_join()
75
+ ```
76
+
77
+ `AvatarSession.start()` creates a FaceMode session with the room object. The create response normally returns `ready: true` with the ingestion `url` and a one-time `wsToken` (about 15 minute expiry), so no polling happens in the common path. If worker assignment is still pending, the plugin polls the session endpoint with bounded backoff for up to 240 seconds and stops immediately on `FAILED`/`ENDED` worker states. The initial response's room credentials remain in memory and are not expected in the polling response.
78
+
79
+ The ingestion WebSocket handshake uses the `Sec-WebSocket-Protocol` subprotocol `facemode.<wsToken>` with a 240 second open timeout. When the backend returns optional `ingestion.headers`, the plugin forwards them during the handshake. It disables compression and native WebSocket keepalives in favor of the canonical application `ping`/`pong` messages after negotiation.
80
+
81
+ Pass `input_provider` (one of `deepgram`, `gemini`, `gnani`, `elevenlabs`, `openai`, `cartesia`, `sarvam`, `custom`) to `AvatarSession` when the session should pin a specific upstream input provider; it is omitted from the request otherwise.
82
+
83
+ If the WebSocket transport drops after the protocol has started, the plugin auto-reconnects in the background: it POSTs the session reconnect endpoint for a fresh one-time `wsToken` (a consumed token is never reused), opens a new socket with `facemode.<newToken>`, re-sends the canonical `start` message, and waits for `started` before resuming. Outgoing control `seq` numbers stay monotonic across the reconnect and buffered audio is not replayed. Reconnect is bounded to 2 attempts with backoff and is single-flight; exhaustion surfaces a typed `FaceModeNotReadyError`/`FaceModeAPIError`. Intentional `stop()`, a canonical `ended`, fatal protocol errors, and drops before the first negotiation do not reconnect.
84
+
85
+ Every TTS frame is sent as canonical PCM audio. The plugin locks sample rate and channel count at protocol negotiation and rejects a format change or unaligned 16-bit PCM afterward. `cancel_utterance` is sent when LiveKit interrupts the audio output. Graceful close sends `end_session` and waits briefly for canonical `ended`; `ended` is a protocol acknowledgement, not backend cleanup confirmation.
86
+
87
+ ## Token grants
88
+
89
+ The `room.token` value must allow the worker to join the customer room and
90
+ publish its avatar audio/video tracks. If the token uses a fixed participant
91
+ identity, use `avatar_participant_identity` and make the room policy allow that
92
+ identity. The worker does not create or replace the customer LiveKit room.
93
+
94
+ ## API URL
95
+
96
+ The default API URL is `https://api.facemode.io/api`. Set `api_url` for a
97
+ self-hosted or local backend.
98
+
99
+ ## License
100
+
101
+ Apache-2.0 - see [LICENSE](LICENSE). Part of the [facemode-integrations](https://github.com/facemode-by-infinitylevel/facemode-integrations) monorepo.
@@ -4,11 +4,17 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "livekit-plugins-facemode"
7
- version = "0.1.0"
7
+ version = "0.2.0"
8
8
  license = "Apache-2.0"
9
9
  license-files = ["LICENSE"]
10
+ readme = "README.md"
11
+ authors = [{name = "FaceMode"}]
12
+ keywords = ["livekit", "agents", "avatar", "facemode", "ai", "video", "realtime"]
10
13
  classifiers = [
11
- "Programming Language :: Python :: 3",
14
+ "Development Status :: 4 - Beta",
15
+ "Intended Audience :: Developers",
16
+ "Programming Language :: Python :: 3.13",
17
+ "Topic :: Multimedia :: Video",
12
18
  ]
13
19
 
14
20
  description = "FaceMode avatar integration for LiveKit Agents"
@@ -20,5 +26,9 @@ dependencies = [
20
26
  "websockets>=14,<17",
21
27
  ]
22
28
 
29
+ [project.urls]
30
+ Homepage = "https://facemode.io"
31
+ Repository = "https://github.com/facemode-by-infinitylevel/facemode-integrations"
32
+
23
33
  [tool.setuptools.packages.find]
24
34
  include = ["livekit_plugins_facemode*"]
@@ -1,13 +0,0 @@
1
- Copyright © 2026 InfinityLevel OPC Private Limited
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License.
5
- You may obtain a copy of the License at
6
-
7
- http://www.apache.org/licenses/LICENSE-2.0
8
-
9
- Unless required by applicable law or agreed to in writing, software
10
- distributed under the License is distributed on an "AS IS" BASIS,
11
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- See the License for the specific language governing permissions and
13
- limitations under the License.
@@ -1,13 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: livekit-plugins-facemode
3
- Version: 0.1.0
4
- Summary: FaceMode avatar integration for LiveKit Agents
5
- License-Expression: Apache-2.0
6
- Classifier: Programming Language :: Python :: 3
7
- Requires-Python: >=3.13
8
- License-File: LICENSE
9
- Requires-Dist: aiohttp<4,>=3.10
10
- Requires-Dist: livekit<2,>=1.1
11
- Requires-Dist: livekit-agents<2,>=1.7
12
- Requires-Dist: websockets<17,>=14
13
- Dynamic: license-file
@@ -1 +0,0 @@
1
- __version__ = "0.1.0"
@@ -1,13 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: livekit-plugins-facemode
3
- Version: 0.1.0
4
- Summary: FaceMode avatar integration for LiveKit Agents
5
- License-Expression: Apache-2.0
6
- Classifier: Programming Language :: Python :: 3
7
- Requires-Python: >=3.13
8
- License-File: LICENSE
9
- Requires-Dist: aiohttp<4,>=3.10
10
- Requires-Dist: livekit<2,>=1.1
11
- Requires-Dist: livekit-agents<2,>=1.7
12
- Requires-Dist: websockets<17,>=14
13
- Dynamic: license-file