thalovant 0.4.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 (40) hide show
  1. thalovant-0.4.0/.gitignore +14 -0
  2. thalovant-0.4.0/LICENSE +21 -0
  3. thalovant-0.4.0/PKG-INFO +334 -0
  4. thalovant-0.4.0/README.md +293 -0
  5. thalovant-0.4.0/docs/api-reference.md +190 -0
  6. thalovant-0.4.0/docs/assets/stylesheets/extra.css +23 -0
  7. thalovant-0.4.0/docs/cli.md +85 -0
  8. thalovant-0.4.0/docs/concepts.md +56 -0
  9. thalovant-0.4.0/docs/deployment.md +52 -0
  10. thalovant-0.4.0/docs/guides/conversations-and-agents.md +87 -0
  11. thalovant-0.4.0/docs/index.md +100 -0
  12. thalovant-0.4.0/docs/quickstart.md +80 -0
  13. thalovant-0.4.0/docs/reference/agent.md +5 -0
  14. thalovant-0.4.0/docs/reference/client.md +5 -0
  15. thalovant-0.4.0/docs/reference/context.md +3 -0
  16. thalovant-0.4.0/docs/reference/conversation.md +5 -0
  17. thalovant-0.4.0/docs/reference/errors.md +3 -0
  18. thalovant-0.4.0/docs/reference/events.md +12 -0
  19. thalovant-0.4.0/docs/reference/identity.md +3 -0
  20. thalovant-0.4.0/docs/reference/models.md +9 -0
  21. thalovant-0.4.0/docs/reference/rich.md +3 -0
  22. thalovant-0.4.0/mkdocs.yml +104 -0
  23. thalovant-0.4.0/pyproject.toml +68 -0
  24. thalovant-0.4.0/src/thalovant/__init__.py +65 -0
  25. thalovant-0.4.0/src/thalovant/agent.py +208 -0
  26. thalovant-0.4.0/src/thalovant/cli.py +170 -0
  27. thalovant-0.4.0/src/thalovant/client.py +811 -0
  28. thalovant-0.4.0/src/thalovant/context.py +85 -0
  29. thalovant-0.4.0/src/thalovant/conversation.py +344 -0
  30. thalovant-0.4.0/src/thalovant/errors.py +21 -0
  31. thalovant-0.4.0/src/thalovant/events.py +294 -0
  32. thalovant-0.4.0/src/thalovant/identity.py +176 -0
  33. thalovant-0.4.0/src/thalovant/models.py +125 -0
  34. thalovant-0.4.0/src/thalovant/py.typed +1 -0
  35. thalovant-0.4.0/src/thalovant/rich.py +184 -0
  36. thalovant-0.4.0/src/thalovant/subscriptions.py +34 -0
  37. thalovant-0.4.0/src/thalovant/transport.py +387 -0
  38. thalovant-0.4.0/tests/test_cli.py +97 -0
  39. thalovant-0.4.0/tests/test_client.py +523 -0
  40. thalovant-0.4.0/tests/test_identity.py +77 -0
@@ -0,0 +1,14 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ .pytest_cache/
4
+ .ruff_cache/
5
+ .mypy_cache/
6
+ .coverage
7
+ htmlcov/
8
+ dist/
9
+ build/
10
+ site/
11
+ *.egg-info/
12
+ .venv/
13
+ .env
14
+ _identity.json
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Thalovant
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,334 @@
1
+ Metadata-Version: 2.4
2
+ Name: thalovant
3
+ Version: 0.4.0
4
+ Summary: Python SDK and CLI for direct Thalovant hub HTTPS clients and agents
5
+ Project-URL: Homepage, https://thalovant.com
6
+ Project-URL: Documentation, https://docs.thalovant.com/developers/sdks/python/
7
+ Project-URL: Repository, https://github.com/thalovant/thalovant-python-sdk
8
+ Project-URL: Issues, https://github.com/thalovant/thalovant-python-sdk/issues
9
+ Author: Thalovant
10
+ Maintainer: Thalovant
11
+ License-Expression: MIT
12
+ License-File: LICENSE
13
+ Keywords: agent,assistant,iot,sdk,thalovant,voice
14
+ Classifier: Development Status :: 3 - Alpha
15
+ Classifier: Framework :: AsyncIO
16
+ Classifier: Intended Audience :: Developers
17
+ Classifier: License :: OSI Approved :: MIT License
18
+ Classifier: Natural Language :: English
19
+ Classifier: Operating System :: OS Independent
20
+ Classifier: Programming Language :: Python :: 3
21
+ Classifier: Programming Language :: Python :: 3 :: Only
22
+ Classifier: Programming Language :: Python :: 3.10
23
+ Classifier: Programming Language :: Python :: 3.11
24
+ Classifier: Programming Language :: Python :: 3.12
25
+ Classifier: Programming Language :: Python :: 3.13
26
+ Classifier: Programming Language :: Python :: 3.14
27
+ Classifier: Topic :: Communications
28
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
29
+ Requires-Python: >=3.10
30
+ Requires-Dist: hivemind-bus-client>=0.4.4
31
+ Requires-Dist: requests>=2.31.0
32
+ Provides-Extra: dev
33
+ Requires-Dist: build>=1.2; extra == 'dev'
34
+ Requires-Dist: pytest>=8.0; extra == 'dev'
35
+ Requires-Dist: twine>=6.0; extra == 'dev'
36
+ Provides-Extra: docs
37
+ Requires-Dist: mkdocs-material>=9.5; extra == 'docs'
38
+ Requires-Dist: mkdocs>=1.6; extra == 'docs'
39
+ Requires-Dist: mkdocstrings[python]>=0.25; extra == 'docs'
40
+ Description-Content-Type: text/markdown
41
+
42
+ # Thalovant Python SDK
43
+
44
+ The Thalovant Python SDK is the developer layer for direct Thalovant hub access.
45
+ Thalovant provisions client identities and policy; this SDK connects directly to
46
+ the hub endpoint over the HTTPS data plane.
47
+
48
+ ```text
49
+ Thalovant API / dashboard -> provision identity and policy
50
+ Python SDK / CLI -> direct hub HTTPS data-plane connection
51
+ Hub runtime -> skills, events, and replies
52
+ ```
53
+
54
+ Full documentation: <https://docs.thalovant.com/developers/sdks/python/>
55
+
56
+ ## Install
57
+
58
+ ```bash
59
+ pip install thalovant
60
+ ```
61
+
62
+ For local SDK development:
63
+
64
+ ```bash
65
+ pip install -e ".[dev]"
66
+ ```
67
+
68
+ ## Quick Start
69
+
70
+ Download or copy the client identity created in Thalovant, then:
71
+
72
+ ```python
73
+ from thalovant import ThalovantClient
74
+
75
+ with ThalovantClient.from_identity_file("_identity.json") as client:
76
+ reply = client.ask("Tell me a short clean joke.")
77
+ print(reply.text)
78
+ ```
79
+
80
+ For async apps and agent runtimes:
81
+
82
+ ```python
83
+ import asyncio
84
+ from thalovant import AsyncThalovantClient
85
+
86
+
87
+ async def main():
88
+ async with AsyncThalovantClient.from_identity_file("_identity.json") as client:
89
+ reply = await client.ask("What time is it?")
90
+ print(reply.text)
91
+
92
+
93
+ asyncio.run(main())
94
+ ```
95
+
96
+ ## Identity
97
+
98
+ The identity file uses the same fields produced for Thalovant hub clients:
99
+
100
+ ```json
101
+ {
102
+ "access_key": "client-access-key",
103
+ "password": "client-password",
104
+ "crypto_key": "optional-preshared-key",
105
+ "site_id": "my-client-site",
106
+ "default_master": "https://hub.example.com",
107
+ "default_port": 443,
108
+ "default_path": "/public"
109
+ }
110
+ ```
111
+
112
+ Environment variables are also supported:
113
+
114
+ ```bash
115
+ export THALOVANT_ACCESS_KEY=...
116
+ export THALOVANT_PASSWORD=...
117
+ export THALOVANT_CRYPTO_KEY=...
118
+ export THALOVANT_SITE_ID=...
119
+ export THALOVANT_HUB_HTTP_HOST=https://hub.example.com
120
+ export THALOVANT_HUB_HTTP_PORT=443
121
+ export THALOVANT_HUB_HTTP_PATH=/public
122
+ ```
123
+
124
+ ```python
125
+ from thalovant import ThalovantClient
126
+
127
+ with ThalovantClient.from_env() as client:
128
+ print(client.ask("Tell me a joke").text)
129
+ ```
130
+
131
+ Keep identity files secret. They are client credentials, not public API keys.
132
+
133
+ ## Conversations
134
+
135
+ Use a conversation when multiple messages should share a stable session and
136
+ correlation context:
137
+
138
+ ```python
139
+ from thalovant import ThalovantClient
140
+
141
+ with ThalovantClient.from_identity_file("_identity.json") as client:
142
+ with client.conversation(lang="en-us") as convo:
143
+ first = convo.ask("Remember that my favorite color is blue.")
144
+ second = convo.ask("What color did I mention?")
145
+ print(second.text)
146
+ ```
147
+
148
+ Conversation helpers add session and request metadata automatically. When the
149
+ hub echoes that metadata, SDK listeners filter unrelated events from other
150
+ sessions.
151
+
152
+ ## Client Context
153
+
154
+ Use `build_client_context` when a web, mobile, kiosk, or service client needs
155
+ to pass user, device, channel, and platform metadata to skills:
156
+
157
+ ```python
158
+ from thalovant import ThalovantClient, build_client_context
159
+
160
+ context = build_client_context(
161
+ user_id="user-42",
162
+ user_name="Ada",
163
+ auth_provider="oidc",
164
+ roles=["member"],
165
+ platform="kiosk",
166
+ source="checkout-kiosk",
167
+ channel="chat",
168
+ )
169
+
170
+ with ThalovantClient.from_identity_file("_identity.json") as client:
171
+ reply = client.ask("Show the next instruction.", context=context)
172
+ ```
173
+
174
+ Provider-specific fields can still be passed through `context` or `metadata`.
175
+ The SDK keeps the public helper generic.
176
+
177
+ ## Actions And Exact Inputs
178
+
179
+ Use `send_action` for button/quick-reply payloads, and `send_code` for exact
180
+ values such as QR codes, serial numbers, asset IDs, or scanned labels:
181
+
182
+ ```python
183
+ with client.conversation(session_id="work-session") as convo:
184
+ convo.send_action('/choose{"id":"42"}', title="Choose item")
185
+ convo.send_code("SN-001-XYZ", kind="qr", label="serial")
186
+ ```
187
+
188
+ Both helpers still emit normal `recognizer_loop:utterance` events, but add
189
+ generic `input` metadata so downstream skills can distinguish typed/scanned
190
+ values from speech transcription.
191
+
192
+ ## Rich Responses
193
+
194
+ Assistant responses can include text, choices, images, attachments, and tables.
195
+ Use `reply.display_items()` or `event.display_items()` to render a UI without
196
+ hand-parsing common rich media payloads:
197
+
198
+ ```python
199
+ reply = client.ask("Show matching parts.")
200
+
201
+ for item in reply.display_items(max_text_chars=600):
202
+ if item.kind == "text":
203
+ print(item.text)
204
+ elif item.kind == "choices":
205
+ print([choice["title"] for choice in item.data])
206
+ ```
207
+
208
+ ## Agents
209
+
210
+ Use `ThalovantAgent` for long-running synchronous workers:
211
+
212
+ ```python
213
+ from thalovant import ThalovantAgent, EVENT_SPEAK
214
+
215
+ agent = ThalovantAgent.from_identity_file("_identity.json")
216
+
217
+
218
+ @agent.on(EVENT_SPEAK)
219
+ def handle_speak(event):
220
+ print(event.text)
221
+
222
+
223
+ agent.run_forever()
224
+ ```
225
+
226
+ Async agents work the same way:
227
+
228
+ ```python
229
+ import asyncio
230
+ from thalovant import AsyncThalovantAgent, EVENT_SPEAK
231
+
232
+ agent = AsyncThalovantAgent.from_identity_file("_identity.json")
233
+
234
+
235
+ @agent.on(EVENT_SPEAK)
236
+ async def handle_speak(event):
237
+ print(event.text)
238
+
239
+
240
+ asyncio.run(agent.run_forever())
241
+ ```
242
+
243
+ ## CLI
244
+
245
+ The package installs a `thalovant` command for smoke tests and operational
246
+ debugging:
247
+
248
+ ```bash
249
+ thalovant --identity _identity.json doctor
250
+ thalovant --identity _identity.json health
251
+ thalovant --identity _identity.json ask "Tell me a joke"
252
+ thalovant --identity _identity.json listen speak --timeout 30 --max-events 3
253
+ thalovant --identity _identity.json emit recognizer_loop:utterance \
254
+ --data '{"utterances":["hello"],"lang":"en-us"}'
255
+ ```
256
+
257
+ Add `--json` to commands that return structured output.
258
+
259
+ ## Events
260
+
261
+ For common flows, prefer helpers over raw event strings:
262
+
263
+ ```python
264
+ from thalovant import EVENT_SPEAK, ThalovantClient
265
+
266
+ with ThalovantClient.from_identity_file("_identity.json") as client:
267
+ for event in client.listen(EVENT_SPEAK, timeout=30, max_events=1):
268
+ print(event.text)
269
+ ```
270
+
271
+ Use `emit` when you already know the hub event shape:
272
+
273
+ ```python
274
+ from thalovant import EVENT_RECOGNIZER_LOOP_UTTERANCE, ThalovantClient
275
+
276
+ with ThalovantClient.from_identity_file("_identity.json") as client:
277
+ client.emit(
278
+ EVENT_RECOGNIZER_LOOP_UTTERANCE,
279
+ {"utterances": ["turn on the lights"], "lang": "en-us"},
280
+ )
281
+ ```
282
+
283
+ `ThalovantEvent` normalizes common fields:
284
+
285
+ - `event.text`
286
+ - `event.utterances`
287
+ - `event.session_id`
288
+ - `event.request_id`
289
+ - `event.is_failure`
290
+ - `event.is_policy_denied`
291
+
292
+ ## Diagnostics
293
+
294
+ Use `doctor()` before debugging application code:
295
+
296
+ ```python
297
+ with ThalovantClient.from_identity_file("_identity.json") as client:
298
+ report = client.doctor()
299
+ print(report.format())
300
+ ```
301
+
302
+ The report checks identity shape, endpoint configuration, hub connection,
303
+ handshake completion, and the live HTTP polling thread.
304
+
305
+ ## Documentation
306
+
307
+ The canonical public documentation lives on the Thalovant docs site:
308
+
309
+ - Website: <https://docs.thalovant.com/developers/sdks/python/>
310
+
311
+ This repository also keeps generated API reference material for maintainers:
312
+
313
+ - Local preview: `pip install -e ".[docs]" && mkdocs serve`
314
+ - Build check: `mkdocs build --strict`
315
+
316
+ ## Notes
317
+
318
+ - This SDK is the developer convenience layer. It does not proxy messages
319
+ through the Thalovant API.
320
+ - The Thalovant API remains the control plane for creating clients, rotating or
321
+ revoking identity material, and managing ACL/policy.
322
+ - The data plane is direct hub protocol traffic from this SDK to the hub
323
+ listener.
324
+
325
+ ## Publishing
326
+
327
+ This repository is configured for PyPI trusted publishing through
328
+ `.github/workflows/publish.yml`. Use these values in the PyPI publisher form:
329
+
330
+ - PyPI Project Name: `thalovant`
331
+ - Owner: `thalovant`
332
+ - Repository name: `thalovant-python-sdk`
333
+ - Workflow name: `publish.yml`
334
+ - Environment name: `pypi`
@@ -0,0 +1,293 @@
1
+ # Thalovant Python SDK
2
+
3
+ The Thalovant Python SDK is the developer layer for direct Thalovant hub access.
4
+ Thalovant provisions client identities and policy; this SDK connects directly to
5
+ the hub endpoint over the HTTPS data plane.
6
+
7
+ ```text
8
+ Thalovant API / dashboard -> provision identity and policy
9
+ Python SDK / CLI -> direct hub HTTPS data-plane connection
10
+ Hub runtime -> skills, events, and replies
11
+ ```
12
+
13
+ Full documentation: <https://docs.thalovant.com/developers/sdks/python/>
14
+
15
+ ## Install
16
+
17
+ ```bash
18
+ pip install thalovant
19
+ ```
20
+
21
+ For local SDK development:
22
+
23
+ ```bash
24
+ pip install -e ".[dev]"
25
+ ```
26
+
27
+ ## Quick Start
28
+
29
+ Download or copy the client identity created in Thalovant, then:
30
+
31
+ ```python
32
+ from thalovant import ThalovantClient
33
+
34
+ with ThalovantClient.from_identity_file("_identity.json") as client:
35
+ reply = client.ask("Tell me a short clean joke.")
36
+ print(reply.text)
37
+ ```
38
+
39
+ For async apps and agent runtimes:
40
+
41
+ ```python
42
+ import asyncio
43
+ from thalovant import AsyncThalovantClient
44
+
45
+
46
+ async def main():
47
+ async with AsyncThalovantClient.from_identity_file("_identity.json") as client:
48
+ reply = await client.ask("What time is it?")
49
+ print(reply.text)
50
+
51
+
52
+ asyncio.run(main())
53
+ ```
54
+
55
+ ## Identity
56
+
57
+ The identity file uses the same fields produced for Thalovant hub clients:
58
+
59
+ ```json
60
+ {
61
+ "access_key": "client-access-key",
62
+ "password": "client-password",
63
+ "crypto_key": "optional-preshared-key",
64
+ "site_id": "my-client-site",
65
+ "default_master": "https://hub.example.com",
66
+ "default_port": 443,
67
+ "default_path": "/public"
68
+ }
69
+ ```
70
+
71
+ Environment variables are also supported:
72
+
73
+ ```bash
74
+ export THALOVANT_ACCESS_KEY=...
75
+ export THALOVANT_PASSWORD=...
76
+ export THALOVANT_CRYPTO_KEY=...
77
+ export THALOVANT_SITE_ID=...
78
+ export THALOVANT_HUB_HTTP_HOST=https://hub.example.com
79
+ export THALOVANT_HUB_HTTP_PORT=443
80
+ export THALOVANT_HUB_HTTP_PATH=/public
81
+ ```
82
+
83
+ ```python
84
+ from thalovant import ThalovantClient
85
+
86
+ with ThalovantClient.from_env() as client:
87
+ print(client.ask("Tell me a joke").text)
88
+ ```
89
+
90
+ Keep identity files secret. They are client credentials, not public API keys.
91
+
92
+ ## Conversations
93
+
94
+ Use a conversation when multiple messages should share a stable session and
95
+ correlation context:
96
+
97
+ ```python
98
+ from thalovant import ThalovantClient
99
+
100
+ with ThalovantClient.from_identity_file("_identity.json") as client:
101
+ with client.conversation(lang="en-us") as convo:
102
+ first = convo.ask("Remember that my favorite color is blue.")
103
+ second = convo.ask("What color did I mention?")
104
+ print(second.text)
105
+ ```
106
+
107
+ Conversation helpers add session and request metadata automatically. When the
108
+ hub echoes that metadata, SDK listeners filter unrelated events from other
109
+ sessions.
110
+
111
+ ## Client Context
112
+
113
+ Use `build_client_context` when a web, mobile, kiosk, or service client needs
114
+ to pass user, device, channel, and platform metadata to skills:
115
+
116
+ ```python
117
+ from thalovant import ThalovantClient, build_client_context
118
+
119
+ context = build_client_context(
120
+ user_id="user-42",
121
+ user_name="Ada",
122
+ auth_provider="oidc",
123
+ roles=["member"],
124
+ platform="kiosk",
125
+ source="checkout-kiosk",
126
+ channel="chat",
127
+ )
128
+
129
+ with ThalovantClient.from_identity_file("_identity.json") as client:
130
+ reply = client.ask("Show the next instruction.", context=context)
131
+ ```
132
+
133
+ Provider-specific fields can still be passed through `context` or `metadata`.
134
+ The SDK keeps the public helper generic.
135
+
136
+ ## Actions And Exact Inputs
137
+
138
+ Use `send_action` for button/quick-reply payloads, and `send_code` for exact
139
+ values such as QR codes, serial numbers, asset IDs, or scanned labels:
140
+
141
+ ```python
142
+ with client.conversation(session_id="work-session") as convo:
143
+ convo.send_action('/choose{"id":"42"}', title="Choose item")
144
+ convo.send_code("SN-001-XYZ", kind="qr", label="serial")
145
+ ```
146
+
147
+ Both helpers still emit normal `recognizer_loop:utterance` events, but add
148
+ generic `input` metadata so downstream skills can distinguish typed/scanned
149
+ values from speech transcription.
150
+
151
+ ## Rich Responses
152
+
153
+ Assistant responses can include text, choices, images, attachments, and tables.
154
+ Use `reply.display_items()` or `event.display_items()` to render a UI without
155
+ hand-parsing common rich media payloads:
156
+
157
+ ```python
158
+ reply = client.ask("Show matching parts.")
159
+
160
+ for item in reply.display_items(max_text_chars=600):
161
+ if item.kind == "text":
162
+ print(item.text)
163
+ elif item.kind == "choices":
164
+ print([choice["title"] for choice in item.data])
165
+ ```
166
+
167
+ ## Agents
168
+
169
+ Use `ThalovantAgent` for long-running synchronous workers:
170
+
171
+ ```python
172
+ from thalovant import ThalovantAgent, EVENT_SPEAK
173
+
174
+ agent = ThalovantAgent.from_identity_file("_identity.json")
175
+
176
+
177
+ @agent.on(EVENT_SPEAK)
178
+ def handle_speak(event):
179
+ print(event.text)
180
+
181
+
182
+ agent.run_forever()
183
+ ```
184
+
185
+ Async agents work the same way:
186
+
187
+ ```python
188
+ import asyncio
189
+ from thalovant import AsyncThalovantAgent, EVENT_SPEAK
190
+
191
+ agent = AsyncThalovantAgent.from_identity_file("_identity.json")
192
+
193
+
194
+ @agent.on(EVENT_SPEAK)
195
+ async def handle_speak(event):
196
+ print(event.text)
197
+
198
+
199
+ asyncio.run(agent.run_forever())
200
+ ```
201
+
202
+ ## CLI
203
+
204
+ The package installs a `thalovant` command for smoke tests and operational
205
+ debugging:
206
+
207
+ ```bash
208
+ thalovant --identity _identity.json doctor
209
+ thalovant --identity _identity.json health
210
+ thalovant --identity _identity.json ask "Tell me a joke"
211
+ thalovant --identity _identity.json listen speak --timeout 30 --max-events 3
212
+ thalovant --identity _identity.json emit recognizer_loop:utterance \
213
+ --data '{"utterances":["hello"],"lang":"en-us"}'
214
+ ```
215
+
216
+ Add `--json` to commands that return structured output.
217
+
218
+ ## Events
219
+
220
+ For common flows, prefer helpers over raw event strings:
221
+
222
+ ```python
223
+ from thalovant import EVENT_SPEAK, ThalovantClient
224
+
225
+ with ThalovantClient.from_identity_file("_identity.json") as client:
226
+ for event in client.listen(EVENT_SPEAK, timeout=30, max_events=1):
227
+ print(event.text)
228
+ ```
229
+
230
+ Use `emit` when you already know the hub event shape:
231
+
232
+ ```python
233
+ from thalovant import EVENT_RECOGNIZER_LOOP_UTTERANCE, ThalovantClient
234
+
235
+ with ThalovantClient.from_identity_file("_identity.json") as client:
236
+ client.emit(
237
+ EVENT_RECOGNIZER_LOOP_UTTERANCE,
238
+ {"utterances": ["turn on the lights"], "lang": "en-us"},
239
+ )
240
+ ```
241
+
242
+ `ThalovantEvent` normalizes common fields:
243
+
244
+ - `event.text`
245
+ - `event.utterances`
246
+ - `event.session_id`
247
+ - `event.request_id`
248
+ - `event.is_failure`
249
+ - `event.is_policy_denied`
250
+
251
+ ## Diagnostics
252
+
253
+ Use `doctor()` before debugging application code:
254
+
255
+ ```python
256
+ with ThalovantClient.from_identity_file("_identity.json") as client:
257
+ report = client.doctor()
258
+ print(report.format())
259
+ ```
260
+
261
+ The report checks identity shape, endpoint configuration, hub connection,
262
+ handshake completion, and the live HTTP polling thread.
263
+
264
+ ## Documentation
265
+
266
+ The canonical public documentation lives on the Thalovant docs site:
267
+
268
+ - Website: <https://docs.thalovant.com/developers/sdks/python/>
269
+
270
+ This repository also keeps generated API reference material for maintainers:
271
+
272
+ - Local preview: `pip install -e ".[docs]" && mkdocs serve`
273
+ - Build check: `mkdocs build --strict`
274
+
275
+ ## Notes
276
+
277
+ - This SDK is the developer convenience layer. It does not proxy messages
278
+ through the Thalovant API.
279
+ - The Thalovant API remains the control plane for creating clients, rotating or
280
+ revoking identity material, and managing ACL/policy.
281
+ - The data plane is direct hub protocol traffic from this SDK to the hub
282
+ listener.
283
+
284
+ ## Publishing
285
+
286
+ This repository is configured for PyPI trusted publishing through
287
+ `.github/workflows/publish.yml`. Use these values in the PyPI publisher form:
288
+
289
+ - PyPI Project Name: `thalovant`
290
+ - Owner: `thalovant`
291
+ - Repository name: `thalovant-python-sdk`
292
+ - Workflow name: `publish.yml`
293
+ - Environment name: `pypi`