voxgraph 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.
@@ -0,0 +1,14 @@
1
+ # Voxgraph SDK — environment variables
2
+ # Copy to .env and fill in your values.
3
+
4
+ # Required: your API key from the Voxgraph dashboard
5
+ VOXGRAPH_API_KEY=vxg_your_api_key_here
6
+
7
+ # Optional: UUID of your agent (from the Voxgraph dashboard)
8
+ # VOXGRAPH_AGENT_ID=550e8400-e29b-41d4-a716-446655440000
9
+
10
+ # Optional: prompt branch to use (default: "main")
11
+ # VOXGRAPH_ENVIRONMENT=main
12
+
13
+ # Optional: enable verbose SDK debug logging (default: false)
14
+ # VOXGRAPH_DEBUG=false
@@ -0,0 +1,87 @@
1
+ name: CI / Publish
2
+
3
+ on:
4
+ push:
5
+ branches: ["main"]
6
+ tags: ["v*.*.*"]
7
+ pull_request:
8
+ branches: ["main"]
9
+
10
+ # Deny all permissions by default — each job grants only what it needs.
11
+ permissions: read-all
12
+
13
+ # Cancel in-progress runs on the same branch/tag to save Actions minutes.
14
+ concurrency:
15
+ group: ${{ github.workflow }}-${{ github.ref }}
16
+ cancel-in-progress: ${{ !startsWith(github.ref, 'refs/tags/') }}
17
+
18
+ jobs:
19
+ # ──────────────────────────────────────────────────────────────────
20
+ # Job 1: Run the full test suite on every push and PR
21
+ # ──────────────────────────────────────────────────────────────────
22
+ test:
23
+ name: Test (Python ${{ matrix.python-version }})
24
+ runs-on: ubuntu-latest
25
+ permissions:
26
+ contents: read
27
+ strategy:
28
+ fail-fast: false
29
+ matrix:
30
+ python-version: ["3.10", "3.11", "3.12", "3.13"]
31
+
32
+ steps:
33
+ # SHA-pinned to prevent supply-chain attacks via tag mutation.
34
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
35
+
36
+ - name: Set up Python ${{ matrix.python-version }}
37
+ uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
38
+ with:
39
+ python-version: ${{ matrix.python-version }}
40
+
41
+ - name: Install uv
42
+ uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5.4.2
43
+
44
+ - name: Install dependencies (dev extras)
45
+ run: uv sync --extra dev
46
+
47
+ - name: Run tests
48
+ run: uv run pytest tests/ -v --tb=short
49
+
50
+ # ──────────────────────────────────────────────────────────────────
51
+ # Job 2: Build + publish to PyPI — ONLY on a v*.*.* tag push.
52
+ # Uses PyPI Trusted Publisher (OIDC) — no API token required.
53
+ # Generates PEP 740 provenance attestations for supply-chain transparency.
54
+ # ──────────────────────────────────────────────────────────────────
55
+ publish:
56
+ name: Publish to PyPI
57
+ needs: test # tests must pass first
58
+ if: startsWith(github.ref, 'refs/tags/v')
59
+ runs-on: ubuntu-latest
60
+ permissions:
61
+ contents: read
62
+ id-token: write # required for OIDC token minting
63
+ attestations: write # required for provenance attestation
64
+
65
+ environment:
66
+ name: pypi
67
+ url: https://pypi.org/project/voxgraph/
68
+
69
+ steps:
70
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
71
+
72
+ - name: Set up Python
73
+ uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
74
+ with:
75
+ python-version: "3.12"
76
+
77
+ - name: Install uv
78
+ uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5.4.2
79
+
80
+ - name: Build distribution packages
81
+ run: uv build
82
+
83
+ - name: Publish to PyPI
84
+ uses: pypa/gh-action-pypi-publish@release/v1
85
+ with:
86
+ attestations: true # PEP 740 — cryptographic provenance proof
87
+ # No username/password needed — OIDC handles authentication.
@@ -0,0 +1,35 @@
1
+ # Virtual environments
2
+ .venv/
3
+ venv/
4
+ env/
5
+
6
+ # Python bytecode
7
+ __pycache__/
8
+ *.py[cod]
9
+ *$py.class
10
+
11
+ # Build / packaging
12
+ dist/
13
+ build/
14
+ *.egg-info/
15
+ *.egg
16
+
17
+ # Tool caches
18
+ .pytest_cache/
19
+ .mypy_cache/
20
+ .ruff_cache/
21
+
22
+ # Environment / secrets
23
+ .env
24
+
25
+ # IDE
26
+ .vscode/
27
+ .idea/
28
+
29
+ # OS junk
30
+ .DS_Store
31
+ Thumbs.db
32
+
33
+ # Dev scratch / debug output
34
+ out.txt
35
+ test_audio_hook.py
voxgraph-0.2.0/LICENSE ADDED
@@ -0,0 +1,92 @@
1
+ Elastic License 2.0
2
+
3
+ URL: https://www.elastic.co/licensing/elastic-license
4
+
5
+ ## Acceptance
6
+
7
+ By using the software, you agree to all of the terms and conditions below.
8
+
9
+ ## Copyright License
10
+
11
+ The licensor grants you a non-exclusive, royalty-free, worldwide,
12
+ non-sublicensable, non-transferable license to use, copy, distribute, make
13
+ available, and prepare derivative works of the software, in each case subject
14
+ to the limitations and conditions below.
15
+
16
+ ## Limitations
17
+
18
+ You may not provide the software to third parties as a hosted or managed
19
+ service, where the service provides users with access to any substantial set of
20
+ the features or functionality of the software.
21
+
22
+ You may not move, change, disable, or circumvent the license key functionality
23
+ in the software, and you may not remove or obscure any functionality in the
24
+ software that is protected by the license key.
25
+
26
+ You may not alter, remove, or obscure any licensing, copyright, or other notices
27
+ of the licensor in the software. Any use of the licensor's trademarks is subject
28
+ to applicable law.
29
+
30
+ ## Patents
31
+
32
+ The licensor grants you a license, under any patent claims the licensor can
33
+ license, or becomes able to license, to make, have made, use, sell, offer for
34
+ sale, import and have imported the software, in each case subject to the
35
+ limitations and conditions in this license. This license does not cover any
36
+ patent claims that you cause to be infringed by modifications or additions to
37
+ the software. If you or your company make any written claim that the software
38
+ infringes or contributes to infringement of any patent, your patent license for
39
+ the software granted under these terms ends immediately. If your company makes
40
+ such a claim, your patent license ends immediately for work on behalf of your
41
+ company.
42
+
43
+ ## Notices
44
+
45
+ You must ensure that anyone who gets a copy of any part of the software from you
46
+ also gets a copy of these terms.
47
+
48
+ If you modify the software, you must include in any modified copies of the
49
+ software prominent notices stating that you have modified the software.
50
+
51
+ ## No Other Rights
52
+
53
+ These terms do not imply any licenses other than those expressly granted in
54
+ these terms.
55
+
56
+ ## Termination
57
+
58
+ If you use the software in violation of these terms, such use is not licensed,
59
+ and your licenses will automatically terminate. If the licensor provides you
60
+ with a notice of your violation, and you cease all violation of this license no
61
+ later than 30 days after you receive that notice, your licenses will be
62
+ reinstated retroactively. However, if you violate these terms after such
63
+ reinstatement, any additional violation of these terms will cause your licenses
64
+ to terminate automatically and permanently.
65
+
66
+ ## No Liability
67
+
68
+ *As far as the law allows, the software comes as is, without any warranty or
69
+ condition, and the licensor will not be liable to you for any damages arising
70
+ out of these terms or the use or nature of the software, under any kind of
71
+ legal claim.*
72
+
73
+ ## Definitions
74
+
75
+ The **licensor** is the entity offering these terms, and the **software** is the
76
+ software the licensor makes available under these terms, including any portion
77
+ of it.
78
+
79
+ **you** refers to the individual or entity agreeing to these terms.
80
+
81
+ **your company** is any legal entity, sole proprietorship, or other kind of
82
+ organization that you work for, plus all organizations that have control over,
83
+ are under the control of, or are under common control with that organization.
84
+ **control** means ownership of substantially all the assets of an entity, or the
85
+ power to direct its management and policies by vote, contract, or otherwise.
86
+ Control can be direct or indirect.
87
+
88
+ **your licenses** are all the licenses granted to you for the software under
89
+ these terms.
90
+
91
+ **use** includes copying, distributing, making available, and preparing
92
+ derivative works of the software.
@@ -0,0 +1,300 @@
1
+ Metadata-Version: 2.4
2
+ Name: voxgraph
3
+ Version: 0.2.0
4
+ Summary: Observability SDK for LiveKit voice agents — captures prompts, metrics, logs, and latency data.
5
+ Project-URL: Homepage, https://voxgraph.io
6
+ Project-URL: Repository, https://github.com/voxgraph/voxgraph-sdk
7
+ Project-URL: Documentation, https://docs.voxgraph.io/sdk
8
+ License: Elastic License 2.0
9
+
10
+ URL: https://www.elastic.co/licensing/elastic-license
11
+
12
+ ## Acceptance
13
+
14
+ By using the software, you agree to all of the terms and conditions below.
15
+
16
+ ## Copyright License
17
+
18
+ The licensor grants you a non-exclusive, royalty-free, worldwide,
19
+ non-sublicensable, non-transferable license to use, copy, distribute, make
20
+ available, and prepare derivative works of the software, in each case subject
21
+ to the limitations and conditions below.
22
+
23
+ ## Limitations
24
+
25
+ You may not provide the software to third parties as a hosted or managed
26
+ service, where the service provides users with access to any substantial set of
27
+ the features or functionality of the software.
28
+
29
+ You may not move, change, disable, or circumvent the license key functionality
30
+ in the software, and you may not remove or obscure any functionality in the
31
+ software that is protected by the license key.
32
+
33
+ You may not alter, remove, or obscure any licensing, copyright, or other notices
34
+ of the licensor in the software. Any use of the licensor's trademarks is subject
35
+ to applicable law.
36
+
37
+ ## Patents
38
+
39
+ The licensor grants you a license, under any patent claims the licensor can
40
+ license, or becomes able to license, to make, have made, use, sell, offer for
41
+ sale, import and have imported the software, in each case subject to the
42
+ limitations and conditions in this license. This license does not cover any
43
+ patent claims that you cause to be infringed by modifications or additions to
44
+ the software. If you or your company make any written claim that the software
45
+ infringes or contributes to infringement of any patent, your patent license for
46
+ the software granted under these terms ends immediately. If your company makes
47
+ such a claim, your patent license ends immediately for work on behalf of your
48
+ company.
49
+
50
+ ## Notices
51
+
52
+ You must ensure that anyone who gets a copy of any part of the software from you
53
+ also gets a copy of these terms.
54
+
55
+ If you modify the software, you must include in any modified copies of the
56
+ software prominent notices stating that you have modified the software.
57
+
58
+ ## No Other Rights
59
+
60
+ These terms do not imply any licenses other than those expressly granted in
61
+ these terms.
62
+
63
+ ## Termination
64
+
65
+ If you use the software in violation of these terms, such use is not licensed,
66
+ and your licenses will automatically terminate. If the licensor provides you
67
+ with a notice of your violation, and you cease all violation of this license no
68
+ later than 30 days after you receive that notice, your licenses will be
69
+ reinstated retroactively. However, if you violate these terms after such
70
+ reinstatement, any additional violation of these terms will cause your licenses
71
+ to terminate automatically and permanently.
72
+
73
+ ## No Liability
74
+
75
+ *As far as the law allows, the software comes as is, without any warranty or
76
+ condition, and the licensor will not be liable to you for any damages arising
77
+ out of these terms or the use or nature of the software, under any kind of
78
+ legal claim.*
79
+
80
+ ## Definitions
81
+
82
+ The **licensor** is the entity offering these terms, and the **software** is the
83
+ software the licensor makes available under these terms, including any portion
84
+ of it.
85
+
86
+ **you** refers to the individual or entity agreeing to these terms.
87
+
88
+ **your company** is any legal entity, sole proprietorship, or other kind of
89
+ organization that you work for, plus all organizations that have control over,
90
+ are under the control of, or are under common control with that organization.
91
+ **control** means ownership of substantially all the assets of an entity, or the
92
+ power to direct its management and policies by vote, contract, or otherwise.
93
+ Control can be direct or indirect.
94
+
95
+ **your licenses** are all the licenses granted to you for the software under
96
+ these terms.
97
+
98
+ **use** includes copying, distributing, making available, and preparing
99
+ derivative works of the software.
100
+ License-File: LICENSE
101
+ Classifier: Development Status :: 5 - Production/Stable
102
+ Classifier: Intended Audience :: Developers
103
+ Classifier: License :: Other/Proprietary License
104
+ Classifier: Programming Language :: Python :: 3
105
+ Classifier: Programming Language :: Python :: 3.10
106
+ Classifier: Programming Language :: Python :: 3.11
107
+ Classifier: Programming Language :: Python :: 3.12
108
+ Classifier: Programming Language :: Python :: 3.13
109
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
110
+ Classifier: Topic :: System :: Monitoring
111
+ Classifier: Typing :: Typed
112
+ Requires-Python: >=3.10
113
+ Requires-Dist: av>=12.0
114
+ Requires-Dist: httpx>=0.25
115
+ Requires-Dist: livekit-agents<2.0,>=1.0
116
+ Requires-Dist: pydantic>=2.0
117
+ Provides-Extra: dev
118
+ Requires-Dist: mypy>=1.10; extra == 'dev'
119
+ Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
120
+ Requires-Dist: pytest>=8.0; extra == 'dev'
121
+ Requires-Dist: ruff>=0.5; extra == 'dev'
122
+ Description-Content-Type: text/markdown
123
+
124
+ # Voxgraph SDK
125
+
126
+ > Observability for LiveKit Voice Agents — see what happens inside the "black box" between user speech and agent response.
127
+
128
+ [![Python](https://img.shields.io/badge/python-3.10+-blue.svg)](https://python.org)
129
+ [![License](https://img.shields.io/badge/license-Elastic%20License%202.0-lightgrey.svg)](LICENSE)
130
+ [![Typed](https://img.shields.io/badge/typing-typed-brightgreen.svg)](https://peps.python.org/pep-0561/)
131
+
132
+ ## Access
133
+
134
+ > **This SDK requires a Voxgraph API key.**
135
+ >
136
+ > The SDK sends telemetry exclusively to the Voxgraph backend. Without a valid API key issued by Voxgraph, all telemetry is silently discarded. Contact your Voxgraph account team to obtain credentials.
137
+
138
+ ## What does it do?
139
+
140
+ LiveKit tells you *the voice was slow*. Voxgraph tells you **why your code made the voice slow**.
141
+
142
+ The Voxgraph SDK wraps your LiveKit `AgentSession` and captures:
143
+
144
+ | Signal | Detail |
145
+ |---|---|
146
+ | **Logs** | Contextually linked to conversation turns |
147
+ | **Prompts** | Versioned & captured per session |
148
+ | **Latency** | Code-level waterfall (STT → Your Code → LLM → TTS) |
149
+ | **Costs** | Token/USD breakdown per turn |
150
+ | **Metrics** | Structured, typed, and batched |
151
+
152
+ ## Quick Start
153
+
154
+ ### Install
155
+
156
+ ```bash
157
+ pip install voxgraph
158
+ ```
159
+
160
+ ### Integrate (2 lines of change)
161
+
162
+ ```python
163
+ from livekit.agents import AgentSession, Agent, AgentServer
164
+ from voxgraph import VoxSession # ← add this import
165
+
166
+ class MyAgent(Agent):
167
+ def __init__(self):
168
+ super().__init__(instructions="You are a helpful assistant.")
169
+
170
+ async def on_enter(self):
171
+ self.session.generate_reply()
172
+
173
+ server = AgentServer()
174
+
175
+ @server.rtc_session()
176
+ async def entrypoint(ctx):
177
+ session = AgentSession(
178
+ stt="deepgram/nova-3:multi",
179
+ llm="openai/gpt-4.1-mini",
180
+ tts="cartesia/sonic-3",
181
+ )
182
+
183
+ # ← Wrap with VoxSession — one arg, done
184
+ vox = VoxSession(session, api_key="vxg_...", agent_id="<your-agent-id>")
185
+
186
+ await vox.start(agent=MyAgent(), room=ctx.room)
187
+ # Shutdown callback is auto-registered via get_job_context()
188
+ ```
189
+
190
+ That's it. The SDK automatically:
191
+ - ✅ Captures session report at call end (transcripts, latency, tool calls, events)
192
+ - ✅ Aggregates LLM token counts, STT audio duration, TTS character counts
193
+ - ✅ Tags your Python logs with the current session context
194
+ - ✅ Sends telemetry to the Voxgraph backend in non-blocking batches
195
+ - ✅ Drains all buffered data on session shutdown (cancel-safe)
196
+
197
+ ## VoxSession Parameters
198
+
199
+ ```python
200
+ VoxSession(
201
+ session,
202
+ api_key="vxg_...",
203
+ agent_id="...",
204
+ environment="main",
205
+ tags={},
206
+ enable_recording=False,
207
+ )
208
+ ```
209
+
210
+ | Parameter | Type | Default | Description |
211
+ |---|---|---|---|
212
+ | `session` | `AgentSession` | *(required)* | The LiveKit `AgentSession` to observe |
213
+ | `api_key` | `str \| None` | `None` | Voxgraph API key. Falls back to `VOXGRAPH_API_KEY` env var if not passed. A warning is emitted and telemetry is discarded if neither is set. |
214
+ | `agent_id` | `str \| None` | `None` | UUID of your agent from the Voxgraph dashboard. Required for prompt fetch and usage attribution. Falls back to `VOXGRAPH_AGENT_ID` env var. |
215
+ | `environment` | `str \| None` | `"main"` | Prompt branch to fetch (`"main"`, `"dev"`, `"staging"`, etc.). Falls back to `VOXGRAPH_ENVIRONMENT` env var. |
216
+ | `tags` | `dict[str, str] \| None` | `{}` | Arbitrary key-value metadata attached to the session report (e.g. `{"customer_tier": "enterprise"}`). |
217
+ | `enable_recording` | `bool` | `False` | When `True`, captures session audio (user mic + agent TTS as stereo Opus/OGG) and uploads it to Voxgraph-managed storage. See [Session Recording](#session-recording). |
218
+
219
+ ## Debug Mode
220
+
221
+ Set `VOXGRAPH_DEBUG=true` to see captured telemetry printed to stdout without sending it to the backend:
222
+
223
+ ```bash
224
+ VOXGRAPH_DEBUG=true python agent.py console
225
+ ```
226
+
227
+ ## Session Recording
228
+
229
+ To capture full session audio (user mic + agent TTS as a stereo Opus/OGG file):
230
+
231
+ ```python
232
+ vox = VoxSession(session, api_key="vxg_abc123", enable_recording=True)
233
+ ```
234
+
235
+ > **⚠️ Recording & Consent — Operator Responsibility**
236
+ >
237
+ > Setting `enable_recording=True` captures audio from **both** call participants and uploads it to Voxgraph-managed S3 storage. Recording is **disabled by default** (`enable_recording=False`).
238
+ >
239
+ > As the operator deploying this SDK, **you are solely responsible** for:
240
+ > - Obtaining explicit user consent before enabling recording
241
+ > - Complying with applicable laws in your jurisdiction, including:
242
+ > - **GDPR** (EU) — voice recordings may qualify as biometric data; explicit prior consent required
243
+ > - **CCPA/CPRA** (California) — voice recordings are biometric information; notice at collection required
244
+ > - **US wiretapping laws** — ~13 states (CA, IL, FL, MA, WA, etc.) require all-party consent; phone calls (`call_channel: "phone"`) carry the strictest requirements
245
+ > - **EU AI Act** (August 2026) — AI-human interactions must be disclosed
246
+
247
+ ## Context-Aware Logging
248
+
249
+ Any Python logger automatically gets tagged with the current session:
250
+
251
+ ```python
252
+ import logging
253
+ logger = logging.getLogger(__name__)
254
+
255
+ @function_tool
256
+ async def check_inventory(ctx, product_id: str):
257
+ logger.info(f"Checking stock for {product_id}") # ← automatically tagged
258
+ result = await db.query(product_id)
259
+ return result
260
+ ```
261
+
262
+ Or use the pre-configured structured logger:
263
+
264
+ ```python
265
+ from voxgraph import vox_logger
266
+
267
+ vox_logger.info("Querying database", product_id=123, stock=True)
268
+ # Output: {"event": "Querying database", "product_id": 123, "vox_session_id": "vox_...", ...}
269
+ ```
270
+
271
+ ## Architecture
272
+
273
+ ```
274
+ Your Agent Code
275
+
276
+
277
+ ┌─────────────────────┐
278
+ │ VoxSession │ ← Composition wrapper (does NOT extend AgentSession)
279
+ │ │
280
+ │ ┌───────────────┐ │
281
+ │ │ Log Handler │ │ ← Tags Python logs with ContextVar session ID
282
+ │ └───────┬───────┘ │
283
+ │ │ │
284
+ │ ┌───────▼───────┐ │
285
+ │ │ Telemetry │ │ ← Async queue → batched HTTP with retry + backoff
286
+ │ │ Sender │ │
287
+ │ └───────────────┘ │
288
+ │ │
289
+ │ ┌───────────────┐ │
290
+ │ │ AudioRecorder │ │ ← Optional. RecorderIO + S3 streaming upload
291
+ │ └───────────────┘ │
292
+ └─────────────────────┘
293
+
294
+
295
+ Voxgraph Backend
296
+ ```
297
+
298
+ ## License
299
+
300
+ [Elastic License 2.0](LICENSE) — free to use, not for competing hosted services.