Metadata-Version: 2.4
Name: keel-voice-sidecar
Version: 0.2.1
Summary: Observation-only Keel evidence sidecar for voice agents
Maintainer-email: Keel <hello@keelapi.com>
License-Expression: Apache-2.0
Project-URL: Homepage, https://keelapi.com
Project-URL: Documentation, https://docs.keelapi.com
Keywords: keel,voice-agents,ai-governance,audit-evidence,openai-realtime,elevenlabs,attestation
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Typing :: Typed
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: cryptography<52,>=50
Requires-Dist: httpx<1,>=0.27
Requires-Dist: numpy<3,>=1.26
Requires-Dist: pydantic<3,>=2.7
Requires-Dist: rfc8785<1,>=0.1.4
Requires-Dist: websockets<17,>=16.1.1
Provides-Extra: dev
Requires-Dist: mypy<2,>=1.10; extra == "dev"
Requires-Dist: pytest<10,>=9.0.3; extra == "dev"
Requires-Dist: pytest-asyncio<2,>=1.3; extra == "dev"
Requires-Dist: ruff<1,>=0.5; extra == "dev"
Dynamic: license-file

# keel-voice-sidecar

**EXPERIMENTAL / UNCERTIFIED observation SDK · 0.2.1 · Apache-2.0**

This Python library records signed observations inside a customer-operated voice gateway. The OpenAI Realtime, OpenAI Live and ElevenLabs Agents adapters have been exercised with mocked WebSockets. Live provider sandbox qualification and a fresh-customer end-to-end run are outstanding. Every integration profile is unqualified. The gateway is a separate prerequisite.

## Evaluate locally

Use Python 3.11 or 3.12. Install the release candidate wheel in a virtual environment. For a hosted evaluation, supply an admitted Keel session ID, a project credential, a provider credential and an independently enrolled sidecar public key. The customer owns consent, session admission, gateway operation and the execution of tool callbacks. The gateway controls capture, provider connections and credential custody. Obtain the required customer authorization before capture or provider startup.

Prepare a stable signing key in an owner-controlled directory. Keep the private PEM in the gateway. The command prints the public enrollment record. Have a project administrator enroll that record separately.

```sh
umask 077
keel-voice-prepare-key --path evidence/sidecar.pem --key-id gateway-test > enrollment.json
```

The example takes a configured sidecar so a gateway can supply its own audio sink and handle caller input concurrently. Evidence delivery is awaited on the audio path and can delay audio forwarding. Call `end_session()` explicitly to request an attestation. Finish all caller input and tool operations before the provider receive loop ends. On a final evidence-delivery failure, retain the evidence database and reconcile outstanding or rejected events before treating the session as complete.

```python
from pathlib import Path

from keel_voice_sidecar import VoiceSidecar, VoiceSidecarConfig, to_file


def configure(session_id: str, keel_url: str, keel_key: str, provider_key: str):
    return VoiceSidecarConfig(
        session_id=session_id,
        keel_base_url=keel_url,
        keel_api_key=keel_key,
        openai_api_key=provider_key,
        signing_private_key_path=Path("evidence/sidecar.pem"),
        signing_key_id="gateway-test",
        wal_path=Path("evidence/events.sqlite3"),
    )


async def observe(sidecar: VoiceSidecar, output: Path):
    try:
        await sidecar.start()
        await sidecar.run()
        artifact = await sidecar.end_session()
        return to_file(artifact, output)
    finally:
        await sidecar.close()
```

## What leaves the gateway

The default event emitter sends media and transcript digests, bounded identifiers and codes, counts, timestamps and signatures to the configured HTTPS Keel endpoint. Raw audio travels to the voice provider. A digest can still be linkable. Use opaque IDs and predefined vocabulary for names, reason codes and labels. A short identifier can encode personal data. The SDK cannot determine its meaning.

The session-end request accepts `failed` as a boolean, metadata codes `ended_by` and `reason_code`, and metrics with `meter`, numeric `quantity`, optional `unit` and optional boolean `estimated`. **The separate `request_tool_permit(...)` helper sends its arguments to Keel in full, in both `arguments` and `target.arguments`.** Supply only data intended for the permit service. Receiver callbacks and custom transports are application code.

SQLite stores signed event JSON, session and event identifiers, delivery state and acknowledgement IDs on disk. Treat the database, SQLite journal companions, exported JSONL, attestations and backups as sensitive. On POSIX, use a directory controlled by the gateway user and mode 0600 for database and private key files. Set equivalent access controls on other platforms. Retain the database until reconciliation and verification finish.

## Verify an artifact

Obtain the trusted issuer Ed25519 public key independently. Run a structural and issuer check with:

```sh
keel-voice-verify attestation.json --ca-key issuer.pem --format=json
```

For a newly issued artifact containing wire-event commitments, export the committed rows for **that session only**. The example assumes the gateway has closed its database, an existing private working directory and a new output filename.

```python
import sqlite3
from pathlib import Path


def export_events(database: Path, session_id: str, destination: Path):
    import os
    from contextlib import closing

    with closing(sqlite3.connect(database.resolve().as_uri() + "?mode=ro", uri=True)) as db:
        rows = db.execute(
            "SELECT event_json FROM voice_event_wal "
            "WHERE session_id=? AND status='committed' ORDER BY wal_id",
            (session_id,),
        )
        fd = os.open(destination, os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0o600)
        with os.fdopen(fd, "w", encoding="utf-8") as output:
            for (event,) in rows:
                output.write(event + "\n")
```

```sh
keel-voice-verify attestation.json --ca-key issuer.pem --events events.jsonl \
  --sidecar-key enrollment.json --strict --format=json
```

Strict mode requires checkable sidecar signatures. Historical hash-only artifacts lack the detached commitments needed for that check. Read each status separately. A structurally consistent timestamp receipt is `UNCHECKED`; an absent receipt can be `DEGRADED`. This CLI does not authenticate RFC 3161 tokens. An issuer-signed notice, consent or handoff marker records what was reported. It cannot establish legal sufficiency, delivery to a person, speech suppression, provider execution or a completed human transfer.

Copyright 2026 Keel API, Inc.
