estuary-sdk 0.2.5__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 (41) hide show
  1. estuary_sdk-0.2.5/LICENSE +21 -0
  2. estuary_sdk-0.2.5/PKG-INFO +311 -0
  3. estuary_sdk-0.2.5/README.md +277 -0
  4. estuary_sdk-0.2.5/pyproject.toml +86 -0
  5. estuary_sdk-0.2.5/src/estuary_sdk/__init__.py +90 -0
  6. estuary_sdk-0.2.5/src/estuary_sdk/_utils/__init__.py +4 -0
  7. estuary_sdk-0.2.5/src/estuary_sdk/_utils/event_emitter.py +63 -0
  8. estuary_sdk-0.2.5/src/estuary_sdk/_utils/logger.py +17 -0
  9. estuary_sdk-0.2.5/src/estuary_sdk/audio/__init__.py +4 -0
  10. estuary_sdk-0.2.5/src/estuary_sdk/audio/player.py +210 -0
  11. estuary_sdk-0.2.5/src/estuary_sdk/audio/recorder.py +163 -0
  12. estuary_sdk-0.2.5/src/estuary_sdk/client.py +397 -0
  13. estuary_sdk-0.2.5/src/estuary_sdk/connection/__init__.py +3 -0
  14. estuary_sdk-0.2.5/src/estuary_sdk/connection/socket_manager.py +283 -0
  15. estuary_sdk-0.2.5/src/estuary_sdk/errors.py +34 -0
  16. estuary_sdk-0.2.5/src/estuary_sdk/rest/__init__.py +7 -0
  17. estuary_sdk-0.2.5/src/estuary_sdk/rest/characters_client.py +216 -0
  18. estuary_sdk-0.2.5/src/estuary_sdk/rest/generate_client.py +51 -0
  19. estuary_sdk-0.2.5/src/estuary_sdk/rest/memory_client.py +105 -0
  20. estuary_sdk-0.2.5/src/estuary_sdk/rest/players_client.py +71 -0
  21. estuary_sdk-0.2.5/src/estuary_sdk/rest/rest_client.py +111 -0
  22. estuary_sdk-0.2.5/src/estuary_sdk/types.py +874 -0
  23. estuary_sdk-0.2.5/src/estuary_sdk/voice/__init__.py +3 -0
  24. estuary_sdk-0.2.5/src/estuary_sdk/voice/livekit_voice.py +388 -0
  25. estuary_sdk-0.2.5/src/estuary_sdk/voice/voice_manager.py +66 -0
  26. estuary_sdk-0.2.5/src/estuary_sdk/voice/websocket_voice.py +179 -0
  27. estuary_sdk-0.2.5/tests/__init__.py +0 -0
  28. estuary_sdk-0.2.5/tests/conftest.py +9 -0
  29. estuary_sdk-0.2.5/tests/helpers.py +48 -0
  30. estuary_sdk-0.2.5/tests/test_audio_recorder.py +110 -0
  31. estuary_sdk-0.2.5/tests/test_characters_client.py +308 -0
  32. estuary_sdk-0.2.5/tests/test_client.py +93 -0
  33. estuary_sdk-0.2.5/tests/test_event_emitter.py +109 -0
  34. estuary_sdk-0.2.5/tests/test_livekit_voice.py +723 -0
  35. estuary_sdk-0.2.5/tests/test_memory_client.py +410 -0
  36. estuary_sdk-0.2.5/tests/test_players_client.py +247 -0
  37. estuary_sdk-0.2.5/tests/test_rest_client.py +270 -0
  38. estuary_sdk-0.2.5/tests/test_socket_manager.py +45 -0
  39. estuary_sdk-0.2.5/tests/test_types.py +418 -0
  40. estuary_sdk-0.2.5/tests/test_vlm_vision.py +229 -0
  41. estuary_sdk-0.2.5/tests/test_voice.py +153 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 estuary.ai
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,311 @@
1
+ Metadata-Version: 2.1
2
+ Name: estuary-sdk
3
+ Version: 0.2.5
4
+ Summary: Python SDK for the Estuary real-time AI conversation platform
5
+ Author-Email: Estuary <team@estuary-ai.com>
6
+ License: MIT
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Programming Language :: Python :: 3.11
9
+ Classifier: Programming Language :: Python :: 3.12
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Framework :: AsyncIO
13
+ Project-URL: Homepage, https://estuary-ai.com
14
+ Project-URL: Documentation, https://docs.estuary-ai.com
15
+ Project-URL: Repository, https://github.com/estuary-ai/estuary-python-sdk
16
+ Requires-Python: >=3.11
17
+ Requires-Dist: python-socketio[asyncio_client]<6,>=5.11
18
+ Requires-Dist: aiohttp<4,>=3.9
19
+ Provides-Extra: audio
20
+ Requires-Dist: sounddevice<1,>=0.4; extra == "audio"
21
+ Requires-Dist: numpy<3,>=1.24; extra == "audio"
22
+ Provides-Extra: livekit
23
+ Requires-Dist: livekit<2,>=1.0; extra == "livekit"
24
+ Provides-Extra: all
25
+ Requires-Dist: estuary-sdk[audio,livekit]; extra == "all"
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest>=8; extra == "dev"
28
+ Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
29
+ Requires-Dist: black; extra == "dev"
30
+ Requires-Dist: isort; extra == "dev"
31
+ Requires-Dist: flake8; extra == "dev"
32
+ Requires-Dist: mypy; extra == "dev"
33
+ Description-Content-Type: text/markdown
34
+
35
+ # Estuary Python SDK
36
+
37
+ Python SDK for the [Estuary](https://estuary-ai.com) real-time AI conversation platform. Supports text chat, streaming voice (WebSocket and LiveKit WebRTC), vision, and memory.
38
+
39
+ ## Installation
40
+
41
+ ```bash
42
+ pip install estuary-sdk
43
+ ```
44
+
45
+ Install with optional extras:
46
+
47
+ ```bash
48
+ pip install estuary-sdk[audio] # Microphone recording + speaker playback
49
+ pip install estuary-sdk[livekit] # LiveKit WebRTC voice
50
+ pip install estuary-sdk[all] # Everything
51
+ ```
52
+
53
+ Or with PDM:
54
+
55
+ ```bash
56
+ pdm install # Core only
57
+ pdm install -G audio # + audio
58
+ pdm install -G livekit # + LiveKit
59
+ pdm install -G all # Everything
60
+ ```
61
+
62
+ Requires Python 3.11+.
63
+
64
+ ## Getting Your Credentials
65
+
66
+ To use the SDK you need an **API key** and a **character ID** from the [Estuary Dashboard](https://app.estuary-ai.com):
67
+
68
+ 1. **Sign up or log in** at [app.estuary-ai.com](https://app.estuary-ai.com)
69
+ 2. **Create a character** — go to **Characters** and click **Create Character**. Configure your character's name, personality, and voice, then save.
70
+ 3. **Copy the character ID** — on the character's page, copy the UUID shown under the character name (or from the URL).
71
+ 4. **Generate an API key** — go to **Settings → API Keys** and click **Create Key**. Copy the key (it starts with `est_`).
72
+
73
+ Use these values for `api_key` and `character_id` in the examples below.
74
+
75
+ ## Quick Start
76
+
77
+ ```python
78
+ import asyncio
79
+ from estuary_sdk import EstuaryClient, EstuaryConfig, BotResponse
80
+
81
+ async def main():
82
+ config = EstuaryConfig(
83
+ server_url="https://api.estuary-ai.com",
84
+ api_key="est_...",
85
+ character_id="your-character-uuid",
86
+ player_id="player-1",
87
+ )
88
+
89
+ async with EstuaryClient(config) as client:
90
+ client.on("bot_response", lambda r: print(r.text, end="" if not r.is_final else "\n"))
91
+
92
+ await client.connect()
93
+ client.send_text("Hello!")
94
+
95
+ await asyncio.sleep(5) # Wait for response
96
+
97
+ asyncio.run(main())
98
+ ```
99
+
100
+ ## Voice
101
+
102
+ ### Continuous Mode
103
+
104
+ Audio streams continuously. The server uses VAD (voice activity detection) to detect turn boundaries.
105
+
106
+ ```python
107
+ from estuary_sdk import VoiceMode
108
+
109
+ await client.start_voice(VoiceMode.CONTINUOUS)
110
+
111
+ # Send raw PCM16 audio (16-bit signed, mono, 16kHz)
112
+ await client.send_audio(pcm_bytes)
113
+
114
+ await client.stop_voice()
115
+ ```
116
+
117
+ ### Push-to-Talk
118
+
119
+ You control when audio is captured and when the turn ends.
120
+
121
+ ```python
122
+ await client.start_voice(VoiceMode.PUSH_TO_TALK)
123
+
124
+ await client.start_recording()
125
+ await client.send_audio(pcm_bytes)
126
+ await client.stop_recording() # Triggers end-of-turn
127
+
128
+ await client.stop_voice()
129
+ ```
130
+
131
+ ### With Microphone (requires `audio` extra)
132
+
133
+ ```python
134
+ from estuary_sdk.audio import AudioRecorder, AudioPlayer
135
+
136
+ recorder = AudioRecorder(on_audio=client.send_audio)
137
+ player = AudioPlayer()
138
+
139
+ client.on("bot_voice", player.enqueue)
140
+
141
+ await client.start_voice()
142
+ await recorder.start()
143
+ ```
144
+
145
+ ## Streaming Responses
146
+
147
+ Bot responses stream token-by-token. Use `is_final` to detect the complete message.
148
+
149
+ ```python
150
+ def on_bot_response(response: BotResponse):
151
+ if response.is_final:
152
+ print(f"[{response.message_id}] {response.text}")
153
+ else:
154
+ print(response.text, end="", flush=True)
155
+
156
+ client.on("bot_response", on_bot_response)
157
+ ```
158
+
159
+ ## Memory
160
+
161
+ The REST memory API is available after `connect()` via `client.memory`.
162
+
163
+ ```python
164
+ # Search memories
165
+ results = await client.memory.search("favorite color")
166
+
167
+ # List with filters
168
+ memories = await client.memory.get_memories(memory_type="preference", limit=20)
169
+
170
+ # Other endpoints
171
+ stats = await client.memory.get_stats()
172
+ facts = await client.memory.get_core_facts()
173
+ timeline = await client.memory.get_timeline(group_by="week")
174
+ graph = await client.memory.get_graph()
175
+ ```
176
+
177
+ Real-time memory extraction events:
178
+
179
+ ```python
180
+ from estuary_sdk import MemoryUpdatedEvent
181
+
182
+ def on_memory(event: MemoryUpdatedEvent):
183
+ print(f"Extracted {event.memories_extracted} memories")
184
+
185
+ client.on("memory_updated", on_memory)
186
+ ```
187
+
188
+ ## CLI Tester
189
+
190
+ An interactive chat program is included for quick testing:
191
+
192
+ ```bash
193
+ python examples/chat.py --api-key [API_KEY] --character-id [CHARACTER_ID]
194
+ ```
195
+
196
+ Or via PDM:
197
+
198
+ ```bash
199
+ pdm run chat --api-key [API_KEY] --character-id [CHARACTER_ID]
200
+ ```
201
+
202
+ | Flag | Short | Default | Description |
203
+ |------|-------|---------|-------------|
204
+ | `--api-key` | `-k` | *required* | API key |
205
+ | `--character-id` | `-c` | *required* | Character UUID |
206
+ | `--server-url` | `-s` | `https://api.estuary-ai.com` | Server URL |
207
+ | `--player-id` | `-p` | `python-sdk-tester` | Player ID |
208
+ | `--debug` | `-d` | off | Verbose logging |
209
+ | `--text-only` | `-t` | off | Suppress voice responses |
210
+
211
+ In-chat commands: `/quit`, `/voice`, `/stop`, `/memories`, `/help`
212
+
213
+ ## Configuration
214
+
215
+ `EstuaryConfig` fields:
216
+
217
+ | Field | Type | Default | Description |
218
+ |-------|------|---------|-------------|
219
+ | `server_url` | `str` | *required* | Server URL |
220
+ | `api_key` | `str` | *required* | API key |
221
+ | `character_id` | `str` | *required* | Character UUID |
222
+ | `player_id` | `str` | *required* | Player identifier |
223
+ | `audio_sample_rate` | `int` | `16000` | Audio sample rate (Hz) |
224
+ | `auto_reconnect` | `bool` | `True` | Auto-reconnect on disconnect |
225
+ | `max_reconnect_attempts` | `int` | `5` | Max reconnection attempts |
226
+ | `reconnect_delay` | `float` | `1.0` | Initial reconnect delay (seconds) |
227
+ | `debug` | `bool` | `False` | Enable debug logging |
228
+ | `voice_transport` | `str` | `"websocket"` | `"websocket"`, `"livekit"`, or `"auto"` |
229
+ | `realtime_memory` | `bool` | `False` | Enable realtime memory updates |
230
+
231
+ ## Events
232
+
233
+ | Event | Payload | Description |
234
+ |-------|---------|-------------|
235
+ | `connected` | `SessionInfo` | Connected and authenticated |
236
+ | `disconnected` | `str` | Disconnected (reason) |
237
+ | `reconnecting` | `int` | Reconnection attempt number |
238
+ | `connection_state_changed` | `ConnectionState` | State transition |
239
+ | `bot_response` | `BotResponse` | Streaming text response |
240
+ | `bot_voice` | `BotVoice` | Audio chunk (base64) |
241
+ | `stt_response` | `SttResponse` | Speech-to-text result |
242
+ | `interrupt` | `InterruptData` | Bot response interrupted |
243
+ | `quota_exceeded` | `QuotaExceededData` | Usage quota hit |
244
+ | `camera_capture_request` | `CameraCaptureRequest` | Server requests a camera image |
245
+ | `voice_started` | — | Voice session started |
246
+ | `voice_stopped` | — | Voice session stopped |
247
+ | `memory_updated` | `MemoryUpdatedEvent` | New memories extracted |
248
+ | `livekit_connected` | `str` | LiveKit room name |
249
+ | `livekit_disconnected` | — | LiveKit disconnected |
250
+ | `error` | `Exception` | Error occurred |
251
+ | `auth_error` | `str` | Authentication failed |
252
+
253
+ Register listeners with `client.on()`, `client.once()`, or `client.off()`:
254
+
255
+ ```python
256
+ client.on("bot_response", handle_response) # Persistent listener
257
+ client.once("connected", handle_first_connect) # One-time listener
258
+ client.off("bot_response", handle_response) # Remove listener
259
+ ```
260
+
261
+ Both sync and async callbacks are supported.
262
+
263
+ ## Error Handling
264
+
265
+ ```python
266
+ from estuary_sdk import EstuaryError, ErrorCode
267
+
268
+ try:
269
+ await client.connect()
270
+ except EstuaryError as e:
271
+ print(e.code) # ErrorCode enum
272
+ print(e.details) # Optional extra info
273
+ ```
274
+
275
+ Error codes:
276
+
277
+ | Code | Description |
278
+ |------|-------------|
279
+ | `CONNECTION_FAILED` | Could not connect to server |
280
+ | `AUTH_FAILED` | Authentication rejected |
281
+ | `CONNECTION_TIMEOUT` | Connection timed out |
282
+ | `QUOTA_EXCEEDED` | Usage quota exceeded |
283
+ | `VOICE_NOT_SUPPORTED` | Voice not supported |
284
+ | `VOICE_ALREADY_ACTIVE` | Voice session already running |
285
+ | `VOICE_NOT_ACTIVE` | No active voice session |
286
+ | `LIVEKIT_UNAVAILABLE` | LiveKit dependency not installed |
287
+ | `NOT_CONNECTED` | Not connected to server |
288
+ | `REST_ERROR` | REST API request failed |
289
+ | `UNKNOWN` | Unknown error |
290
+
291
+ ## Optional Dependencies
292
+
293
+ | Extra | Packages | Purpose |
294
+ |-------|----------|---------|
295
+ | `audio` | sounddevice, numpy | Microphone capture + speaker playback |
296
+ | `livekit` | livekit | LiveKit WebRTC voice transport |
297
+ | `all` | All of the above | Everything |
298
+ | `dev` | pytest, black, isort, flake8, mypy | Development tools |
299
+
300
+ ## Development
301
+
302
+ ```bash
303
+ cd estuary-python-sdk
304
+ pdm install -G dev
305
+
306
+ pdm run test # pytest
307
+ pdm run format # black
308
+ pdm run lint # flake8
309
+ pdm run sort-imports # isort
310
+ pdm run typecheck # mypy (strict)
311
+ ```
@@ -0,0 +1,277 @@
1
+ # Estuary Python SDK
2
+
3
+ Python SDK for the [Estuary](https://estuary-ai.com) real-time AI conversation platform. Supports text chat, streaming voice (WebSocket and LiveKit WebRTC), vision, and memory.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install estuary-sdk
9
+ ```
10
+
11
+ Install with optional extras:
12
+
13
+ ```bash
14
+ pip install estuary-sdk[audio] # Microphone recording + speaker playback
15
+ pip install estuary-sdk[livekit] # LiveKit WebRTC voice
16
+ pip install estuary-sdk[all] # Everything
17
+ ```
18
+
19
+ Or with PDM:
20
+
21
+ ```bash
22
+ pdm install # Core only
23
+ pdm install -G audio # + audio
24
+ pdm install -G livekit # + LiveKit
25
+ pdm install -G all # Everything
26
+ ```
27
+
28
+ Requires Python 3.11+.
29
+
30
+ ## Getting Your Credentials
31
+
32
+ To use the SDK you need an **API key** and a **character ID** from the [Estuary Dashboard](https://app.estuary-ai.com):
33
+
34
+ 1. **Sign up or log in** at [app.estuary-ai.com](https://app.estuary-ai.com)
35
+ 2. **Create a character** — go to **Characters** and click **Create Character**. Configure your character's name, personality, and voice, then save.
36
+ 3. **Copy the character ID** — on the character's page, copy the UUID shown under the character name (or from the URL).
37
+ 4. **Generate an API key** — go to **Settings → API Keys** and click **Create Key**. Copy the key (it starts with `est_`).
38
+
39
+ Use these values for `api_key` and `character_id` in the examples below.
40
+
41
+ ## Quick Start
42
+
43
+ ```python
44
+ import asyncio
45
+ from estuary_sdk import EstuaryClient, EstuaryConfig, BotResponse
46
+
47
+ async def main():
48
+ config = EstuaryConfig(
49
+ server_url="https://api.estuary-ai.com",
50
+ api_key="est_...",
51
+ character_id="your-character-uuid",
52
+ player_id="player-1",
53
+ )
54
+
55
+ async with EstuaryClient(config) as client:
56
+ client.on("bot_response", lambda r: print(r.text, end="" if not r.is_final else "\n"))
57
+
58
+ await client.connect()
59
+ client.send_text("Hello!")
60
+
61
+ await asyncio.sleep(5) # Wait for response
62
+
63
+ asyncio.run(main())
64
+ ```
65
+
66
+ ## Voice
67
+
68
+ ### Continuous Mode
69
+
70
+ Audio streams continuously. The server uses VAD (voice activity detection) to detect turn boundaries.
71
+
72
+ ```python
73
+ from estuary_sdk import VoiceMode
74
+
75
+ await client.start_voice(VoiceMode.CONTINUOUS)
76
+
77
+ # Send raw PCM16 audio (16-bit signed, mono, 16kHz)
78
+ await client.send_audio(pcm_bytes)
79
+
80
+ await client.stop_voice()
81
+ ```
82
+
83
+ ### Push-to-Talk
84
+
85
+ You control when audio is captured and when the turn ends.
86
+
87
+ ```python
88
+ await client.start_voice(VoiceMode.PUSH_TO_TALK)
89
+
90
+ await client.start_recording()
91
+ await client.send_audio(pcm_bytes)
92
+ await client.stop_recording() # Triggers end-of-turn
93
+
94
+ await client.stop_voice()
95
+ ```
96
+
97
+ ### With Microphone (requires `audio` extra)
98
+
99
+ ```python
100
+ from estuary_sdk.audio import AudioRecorder, AudioPlayer
101
+
102
+ recorder = AudioRecorder(on_audio=client.send_audio)
103
+ player = AudioPlayer()
104
+
105
+ client.on("bot_voice", player.enqueue)
106
+
107
+ await client.start_voice()
108
+ await recorder.start()
109
+ ```
110
+
111
+ ## Streaming Responses
112
+
113
+ Bot responses stream token-by-token. Use `is_final` to detect the complete message.
114
+
115
+ ```python
116
+ def on_bot_response(response: BotResponse):
117
+ if response.is_final:
118
+ print(f"[{response.message_id}] {response.text}")
119
+ else:
120
+ print(response.text, end="", flush=True)
121
+
122
+ client.on("bot_response", on_bot_response)
123
+ ```
124
+
125
+ ## Memory
126
+
127
+ The REST memory API is available after `connect()` via `client.memory`.
128
+
129
+ ```python
130
+ # Search memories
131
+ results = await client.memory.search("favorite color")
132
+
133
+ # List with filters
134
+ memories = await client.memory.get_memories(memory_type="preference", limit=20)
135
+
136
+ # Other endpoints
137
+ stats = await client.memory.get_stats()
138
+ facts = await client.memory.get_core_facts()
139
+ timeline = await client.memory.get_timeline(group_by="week")
140
+ graph = await client.memory.get_graph()
141
+ ```
142
+
143
+ Real-time memory extraction events:
144
+
145
+ ```python
146
+ from estuary_sdk import MemoryUpdatedEvent
147
+
148
+ def on_memory(event: MemoryUpdatedEvent):
149
+ print(f"Extracted {event.memories_extracted} memories")
150
+
151
+ client.on("memory_updated", on_memory)
152
+ ```
153
+
154
+ ## CLI Tester
155
+
156
+ An interactive chat program is included for quick testing:
157
+
158
+ ```bash
159
+ python examples/chat.py --api-key [API_KEY] --character-id [CHARACTER_ID]
160
+ ```
161
+
162
+ Or via PDM:
163
+
164
+ ```bash
165
+ pdm run chat --api-key [API_KEY] --character-id [CHARACTER_ID]
166
+ ```
167
+
168
+ | Flag | Short | Default | Description |
169
+ |------|-------|---------|-------------|
170
+ | `--api-key` | `-k` | *required* | API key |
171
+ | `--character-id` | `-c` | *required* | Character UUID |
172
+ | `--server-url` | `-s` | `https://api.estuary-ai.com` | Server URL |
173
+ | `--player-id` | `-p` | `python-sdk-tester` | Player ID |
174
+ | `--debug` | `-d` | off | Verbose logging |
175
+ | `--text-only` | `-t` | off | Suppress voice responses |
176
+
177
+ In-chat commands: `/quit`, `/voice`, `/stop`, `/memories`, `/help`
178
+
179
+ ## Configuration
180
+
181
+ `EstuaryConfig` fields:
182
+
183
+ | Field | Type | Default | Description |
184
+ |-------|------|---------|-------------|
185
+ | `server_url` | `str` | *required* | Server URL |
186
+ | `api_key` | `str` | *required* | API key |
187
+ | `character_id` | `str` | *required* | Character UUID |
188
+ | `player_id` | `str` | *required* | Player identifier |
189
+ | `audio_sample_rate` | `int` | `16000` | Audio sample rate (Hz) |
190
+ | `auto_reconnect` | `bool` | `True` | Auto-reconnect on disconnect |
191
+ | `max_reconnect_attempts` | `int` | `5` | Max reconnection attempts |
192
+ | `reconnect_delay` | `float` | `1.0` | Initial reconnect delay (seconds) |
193
+ | `debug` | `bool` | `False` | Enable debug logging |
194
+ | `voice_transport` | `str` | `"websocket"` | `"websocket"`, `"livekit"`, or `"auto"` |
195
+ | `realtime_memory` | `bool` | `False` | Enable realtime memory updates |
196
+
197
+ ## Events
198
+
199
+ | Event | Payload | Description |
200
+ |-------|---------|-------------|
201
+ | `connected` | `SessionInfo` | Connected and authenticated |
202
+ | `disconnected` | `str` | Disconnected (reason) |
203
+ | `reconnecting` | `int` | Reconnection attempt number |
204
+ | `connection_state_changed` | `ConnectionState` | State transition |
205
+ | `bot_response` | `BotResponse` | Streaming text response |
206
+ | `bot_voice` | `BotVoice` | Audio chunk (base64) |
207
+ | `stt_response` | `SttResponse` | Speech-to-text result |
208
+ | `interrupt` | `InterruptData` | Bot response interrupted |
209
+ | `quota_exceeded` | `QuotaExceededData` | Usage quota hit |
210
+ | `camera_capture_request` | `CameraCaptureRequest` | Server requests a camera image |
211
+ | `voice_started` | — | Voice session started |
212
+ | `voice_stopped` | — | Voice session stopped |
213
+ | `memory_updated` | `MemoryUpdatedEvent` | New memories extracted |
214
+ | `livekit_connected` | `str` | LiveKit room name |
215
+ | `livekit_disconnected` | — | LiveKit disconnected |
216
+ | `error` | `Exception` | Error occurred |
217
+ | `auth_error` | `str` | Authentication failed |
218
+
219
+ Register listeners with `client.on()`, `client.once()`, or `client.off()`:
220
+
221
+ ```python
222
+ client.on("bot_response", handle_response) # Persistent listener
223
+ client.once("connected", handle_first_connect) # One-time listener
224
+ client.off("bot_response", handle_response) # Remove listener
225
+ ```
226
+
227
+ Both sync and async callbacks are supported.
228
+
229
+ ## Error Handling
230
+
231
+ ```python
232
+ from estuary_sdk import EstuaryError, ErrorCode
233
+
234
+ try:
235
+ await client.connect()
236
+ except EstuaryError as e:
237
+ print(e.code) # ErrorCode enum
238
+ print(e.details) # Optional extra info
239
+ ```
240
+
241
+ Error codes:
242
+
243
+ | Code | Description |
244
+ |------|-------------|
245
+ | `CONNECTION_FAILED` | Could not connect to server |
246
+ | `AUTH_FAILED` | Authentication rejected |
247
+ | `CONNECTION_TIMEOUT` | Connection timed out |
248
+ | `QUOTA_EXCEEDED` | Usage quota exceeded |
249
+ | `VOICE_NOT_SUPPORTED` | Voice not supported |
250
+ | `VOICE_ALREADY_ACTIVE` | Voice session already running |
251
+ | `VOICE_NOT_ACTIVE` | No active voice session |
252
+ | `LIVEKIT_UNAVAILABLE` | LiveKit dependency not installed |
253
+ | `NOT_CONNECTED` | Not connected to server |
254
+ | `REST_ERROR` | REST API request failed |
255
+ | `UNKNOWN` | Unknown error |
256
+
257
+ ## Optional Dependencies
258
+
259
+ | Extra | Packages | Purpose |
260
+ |-------|----------|---------|
261
+ | `audio` | sounddevice, numpy | Microphone capture + speaker playback |
262
+ | `livekit` | livekit | LiveKit WebRTC voice transport |
263
+ | `all` | All of the above | Everything |
264
+ | `dev` | pytest, black, isort, flake8, mypy | Development tools |
265
+
266
+ ## Development
267
+
268
+ ```bash
269
+ cd estuary-python-sdk
270
+ pdm install -G dev
271
+
272
+ pdm run test # pytest
273
+ pdm run format # black
274
+ pdm run lint # flake8
275
+ pdm run sort-imports # isort
276
+ pdm run typecheck # mypy (strict)
277
+ ```
@@ -0,0 +1,86 @@
1
+ [project]
2
+ name = "estuary-sdk"
3
+ version = "0.2.5"
4
+ description = "Python SDK for the Estuary real-time AI conversation platform"
5
+ readme = "README.md"
6
+ authors = [
7
+ { name = "Estuary", email = "team@estuary-ai.com" },
8
+ ]
9
+ requires-python = ">=3.11"
10
+ classifiers = [
11
+ "Programming Language :: Python :: 3",
12
+ "Programming Language :: Python :: 3.11",
13
+ "Programming Language :: Python :: 3.12",
14
+ "License :: OSI Approved :: MIT License",
15
+ "Operating System :: OS Independent",
16
+ "Framework :: AsyncIO",
17
+ ]
18
+ dependencies = [
19
+ "python-socketio[asyncio_client]>=5.11,<6",
20
+ "aiohttp>=3.9,<4",
21
+ ]
22
+
23
+ [project.license]
24
+ text = "MIT"
25
+
26
+ [project.urls]
27
+ Homepage = "https://estuary-ai.com"
28
+ Documentation = "https://docs.estuary-ai.com"
29
+ Repository = "https://github.com/estuary-ai/estuary-python-sdk"
30
+
31
+ [project.optional-dependencies]
32
+ audio = [
33
+ "sounddevice>=0.4,<1",
34
+ "numpy>=1.24,<3",
35
+ ]
36
+ livekit = [
37
+ "livekit>=1.0,<2",
38
+ ]
39
+ all = [
40
+ "estuary-sdk[audio,livekit]",
41
+ ]
42
+ dev = [
43
+ "pytest>=8",
44
+ "pytest-asyncio>=0.23",
45
+ "black",
46
+ "isort",
47
+ "flake8",
48
+ "mypy",
49
+ ]
50
+
51
+ [build-system]
52
+ requires = [
53
+ "pdm-backend",
54
+ ]
55
+ build-backend = "pdm.backend"
56
+
57
+ [tool.pdm]
58
+ distribution = true
59
+
60
+ [tool.pdm.scripts]
61
+ chat = "python examples/chat.py"
62
+ test = "pytest tests/"
63
+ format = "black src/ tests/"
64
+ lint = "flake8 src/ tests/"
65
+ sort-imports = "isort src/ tests/"
66
+ typecheck = "mypy src/"
67
+
68
+ [tool.black]
69
+ line-length = 100
70
+ target-version = [
71
+ "py311",
72
+ ]
73
+
74
+ [tool.isort]
75
+ profile = "black"
76
+ line_length = 100
77
+
78
+ [tool.mypy]
79
+ python_version = "3.11"
80
+ strict = true
81
+
82
+ [tool.pytest.ini_options]
83
+ asyncio_mode = "auto"
84
+ pythonpath = [
85
+ "tests",
86
+ ]