Metadata-Version: 2.4
Name: briefcase-ai
Version: 6.0.2
Classifier: Development Status :: 4 - Beta
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Rust
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: MacOS
Classifier: Operating System :: Microsoft :: Windows
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Typing :: Typed
Requires-Dist: tomli>=1.1 ; python_full_version < '3.11'
Requires-Dist: ag2>=0.4 ; extra == 'ag2'
Requires-Dist: briefcase-ai[replay,drift,sanitize,otel,storage,validate,guardrails,rag,rag-chroma,rag-pinecone,rag-weaviate,correlation,external,events,kafka,webhook,gcp-logging,routing,opa,lakefs,vcs,vcs-dvc,vcs-pachyderm,vcs-ducklake,vcs-iceberg,gym,evals,bitemporal,bitemporal-iceberg,bitemporal-glue,compliance,compliance-kms,controls,integrity,langchain,crewai,llamaindex,autogen,ag2,pageindex,openai-agents,mcp,run,engine,receiver,budgets-redis,budgets-postgres,budgets-mysql] ; extra == 'all'
Requires-Dist: autogen-agentchat>=0.4 ; extra == 'autogen'
Requires-Dist: briefcase-ai[bitemporal-iceberg] ; extra == 'bitemporal-glue'
Requires-Dist: boto3>=1.34 ; extra == 'bitemporal-glue'
Requires-Dist: pyiceberg[sql-sqlite,pyiceberg-core]>=0.9 ; extra == 'bitemporal-iceberg'
Requires-Dist: pyarrow>=14 ; extra == 'bitemporal-iceberg'
Requires-Dist: pymysql>=1.1 ; extra == 'budgets-mysql'
Requires-Dist: psycopg[binary]>=3.1 ; extra == 'budgets-postgres'
Requires-Dist: redis>=5 ; extra == 'budgets-redis'
Requires-Dist: boto3>=1.34 ; extra == 'compliance-kms'
Requires-Dist: crewai>=0.86 ; extra == 'crewai'
Requires-Dist: pytest ; extra == 'dev'
Requires-Dist: pytest-mock ; extra == 'dev'
Requires-Dist: pytest-asyncio ; extra == 'dev'
Requires-Dist: pytest-subtests ; extra == 'dev'
Requires-Dist: mypy ; extra == 'dev'
Requires-Dist: flake8 ; extra == 'dev'
Requires-Dist: moto[kms,glue,s3]>=5 ; extra == 'dev'
Requires-Dist: jsonschema>=4.18 ; extra == 'dev'
Requires-Dist: grpcio>=1.60,<2 ; extra == 'engine'
Requires-Dist: protobuf>=4.25 ; extra == 'engine'
Requires-Dist: cryptography>=42 ; extra == 'engine'
Requires-Dist: zstandard>=0.22 ; python_full_version < '3.14' and extra == 'evals'
Requires-Dist: google-cloud-logging>=3.9 ; extra == 'gcp-logging'
Requires-Dist: gymnasium>=0.29 ; extra == 'gym'
Requires-Dist: pynacl>=1.5 ; extra == 'integrity'
Requires-Dist: confluent-kafka>=2.3 ; extra == 'kafka'
Requires-Dist: pykx>=2.5 ; extra == 'kdb'
Requires-Dist: lakefs>=0.1 ; extra == 'lakefs'
Requires-Dist: langchain-core>=0.3 ; extra == 'langchain'
Requires-Dist: llama-index-core>=0.10 ; extra == 'llamaindex'
Requires-Dist: mcp>=1.2,<3 ; extra == 'mcp'
Requires-Dist: httpx>=0.24 ; extra == 'opa'
Requires-Dist: openai-agents>=0.1 ; extra == 'openai-agents'
Requires-Dist: opentelemetry-api>=1.20 ; extra == 'otel'
Requires-Dist: opentelemetry-sdk>=1.20 ; extra == 'otel'
Requires-Dist: opentelemetry-exporter-otlp-proto-grpc>=1.20 ; extra == 'otel'
Requires-Dist: opentelemetry-exporter-otlp-proto-http>=1.20 ; extra == 'otel'
Requires-Dist: pageindex>=0.1 ; extra == 'pageindex'
Requires-Dist: chromadb>=0.4 ; extra == 'rag-chroma'
Requires-Dist: pinecone>=3 ; extra == 'rag-pinecone'
Requires-Dist: weaviate-client>=3,<4 ; extra == 'rag-weaviate'
Requires-Dist: opentelemetry-proto>=1.20 ; extra == 'receiver'
Requires-Dist: grpcio>=1.60,<2 ; extra == 'run'
Requires-Dist: grpcio-reflection>=1.60,<2 ; extra == 'run'
Requires-Dist: protobuf>=4.25 ; extra == 'run'
Requires-Dist: duckdb>=0.9 ; extra == 'vcs-ducklake'
Requires-Dist: dvc>=3 ; extra == 'vcs-dvc'
Requires-Dist: pyiceberg>=0.9 ; extra == 'vcs-iceberg'
Requires-Dist: pachyderm-sdk>=2.8 ; extra == 'vcs-pachyderm'
Provides-Extra: ag2
Provides-Extra: all
Provides-Extra: autogen
Provides-Extra: bitemporal
Provides-Extra: bitemporal-glue
Provides-Extra: bitemporal-iceberg
Provides-Extra: budgets-mysql
Provides-Extra: budgets-postgres
Provides-Extra: budgets-redis
Provides-Extra: compliance
Provides-Extra: compliance-kms
Provides-Extra: controls
Provides-Extra: correlation
Provides-Extra: crewai
Provides-Extra: dev
Provides-Extra: drift
Provides-Extra: engine
Provides-Extra: evals
Provides-Extra: events
Provides-Extra: external
Provides-Extra: gcp-logging
Provides-Extra: guardrails
Provides-Extra: gym
Provides-Extra: integrity
Provides-Extra: kafka
Provides-Extra: kdb
Provides-Extra: lakefs
Provides-Extra: langchain
Provides-Extra: llamaindex
Provides-Extra: mcp
Provides-Extra: opa
Provides-Extra: openai-agents
Provides-Extra: otel
Provides-Extra: pageindex
Provides-Extra: rag
Provides-Extra: rag-chroma
Provides-Extra: rag-pinecone
Provides-Extra: rag-weaviate
Provides-Extra: receiver
Provides-Extra: replay
Provides-Extra: routing
Provides-Extra: run
Provides-Extra: sanitize
Provides-Extra: storage
Provides-Extra: validate
Provides-Extra: vcs
Provides-Extra: vcs-ducklake
Provides-Extra: vcs-dvc
Provides-Extra: vcs-iceberg
Provides-Extra: vcs-pachyderm
Provides-Extra: webhook
License-File: LICENSE
License-File: NOTICE
Summary: Compliance monitoring, auditing, and evaluating third-party artificial intelligence systems and models.
Keywords: ai,observability,decision-tracking,replay,drift
Home-Page: https://briefcaseai.io
Author: Briefcase AI
License-Expression: Apache-2.0
Requires-Python: >=3.9
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Changelog, https://github.com/briefcasebrain/briefcase-ai-sdk/blob/main/CHANGELOG.md
Project-URL: Homepage, https://briefcaseai.io
Project-URL: Issues, https://github.com/briefcasebrain/briefcase-ai-sdk/issues
Project-URL: Repository, https://github.com/briefcasebrain/briefcase-ai-sdk

# Briefcase AI SDK

![License: Apache-2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)

Compliance monitoring, auditing, and evaluating third-party artificial intelligence systems and models.

Enforce controls, record context, replay later.

## Install

```bash
pip install briefcase-ai
```

TypeScript consumers install the focused runtime packages:

```bash
npm install @briefcase-ai/controls @briefcase-ai/runtime
```

`@briefcase-ai/runtime` exposes only explicit subpaths:
`@briefcase-ai/runtime/integrity`, `/lakefs`, `/connectors`, and `/trace`.

## Quick Example

```python
import briefcase

briefcase.observe("console")          # send records to stderr (or "memory" / "runs.jsonl" / an https:// URL)

@briefcase.capture(decision_type="classify_text")
def classify(text: str) -> str:
    return text.upper()

classify("hello world")               # a decision record is emitted
```

`capture` works immediately — no `briefcase.init()` required. Call `init()` only
when you use the native runtime features (storage backends, snapshots). Without a
call to `briefcase.observe(...)` (or `briefcase.setup(exporter=...)`), `@capture`
records decisions but has nowhere to send them.

**Exporters.** `briefcase.observe(...)` accepts `"console"`, `"memory"` (records
collected on `exporter.records`), a `"*.jsonl"` path, an `https://` URL (JSON
batches via the stdlib-only `HTTPExporter`; pass `HTTPExporter(url, token=...)`
for auth), or any `briefcase.exporters.BaseExporter` instance — subclass
`BaseExporter` to ship records to your own backend. The exporter classes are
also importable from the top level (`briefcase.JSONLFileExporter`, …).

**Delivery.** Records are exported on a background thread through a bounded
queue (10,000 records by default; `briefcase.configure_export(...)` tunes the
bound, retries, and timeout). If the exporter cannot keep up, new records are
dropped, counted in `briefcase.export_stats()`, and reported at WARNING. Queued
records are drained at interpreter exit for up to 5 seconds, with no explicit
call; use `briefcase.shutdown(timeout=...)` (or `briefcase.flush()`) to drain
earlier, or before `os._exit`.

**What gets captured.** `@capture` works on functions, coroutines, generators,
and async generators (a generator emits one record when it finishes, with the
collected chunks as output). Cancelled or timed-out async calls are recorded
with `status: "cancelled"`. Records carry a `schema_version`, plus
`workflow_id` / `trace_id` when a `briefcase.correlation` workflow or an
OpenTelemetry span is active. `capture(sample_rate=0.1)` records a fraction of
calls.

**Content rule.** Briefcase records prompt, completion and tool content only
where someone chose to record it. Every automatic path (`briefcase.auto()`
for frameworks and provider SDKs, `briefcase-ai exec`, `connect` and the
receiver, eval records) records none until you opt in with
`capture_content="full"` (or `"hash"`), `--capture-content` / `--keep-content`,
or `BRIEFCASE_CAPTURE_CONTENT=full`. `@capture` on your own function is itself
that choice: it records the function's arguments and return value (pass
`capture_content="hash"` or `"none"` to keep them out).

`import briefcase` does not require the compiled core: the pure-Python surface
(capture, exporters, controls, events, routing) works from a source checkout,
and native-backed names raise a clear `ImportError` only when used.

## Evaluations and RL

Two bridges emit decision records from work that is not a single function call.
Both use the exporter you already configured.

```python
from briefcase.integrations.evals import EvalRun, from_inspect_log, replay

with EvalRun("gsm8k", model="claude-opus-5") as run:   # one eval.case per case,
    run.log_case("q1", inputs=q, outputs=a, passed=a == target)   # one eval.run
print(run.summary()["pass_rate"])

replay(from_inspect_log("logs/2026-08-12_gsm8k.eval"))  # inspect-ai .json/.eval
```

The parsers are stdlib only and never import the eval framework, so a log can be
replayed on a machine that has neither installed. See
[`examples/eval_runs/`](https://github.com/briefcasebrain/briefcase-ai-sdk/tree/main/examples/eval_runs/).

```python
from briefcase.integrations.gym import GuardrailGymEnv, capture_episodes

env = GuardrailGymEnv(guardrail, tasks, injections)  # a guardrail as a gym.Env
env = capture_episodes(env)                          # rl.step / rl.episode records
```

Needs `pip install briefcase-ai[gym]`. See [`examples/rl_gym/`](https://github.com/briefcasebrain/briefcase-ai-sdk/tree/main/examples/rl_gym/).

`capture_episodes` exports on a background thread by default, since step capture
is on the hot path. A script that exits right after `close()` can lose its
records; pass `capture_episodes(env, async_capture=False)` in short runs.
`EvalRun` already defaults to `async_capture=False` for that reason.

## Logging

The library is silent by default (it installs only a `NullHandler`). Turn on
visible logs explicitly:

```python
import briefcase
briefcase.enable_logging("DEBUG")     # or set BRIEFCASE_LOG_LEVEL=DEBUG
```

## Using with AI tools (Cursor, Claude Code, Codex, …)

This repo ships machine-readable usage guidance: [`llms.txt`](https://github.com/briefcasebrain/briefcase-ai-sdk/blob/main/llms.txt) /
[`llms-full.txt`](https://github.com/briefcasebrain/briefcase-ai-sdk/blob/main/llms-full.txt), an [`AGENTS.md`](https://github.com/briefcasebrain/briefcase-ai-sdk/blob/main/AGENTS.md), and copy-paste
editor rules under [`docs/llm/`](https://github.com/briefcasebrain/briefcase-ai-sdk/tree/main/docs/llm/). An MCP server is available via
`pip install briefcase-ai[mcp]` then `briefcase-ai-mcp`.

## Plug-and-play integrations

Connect the coding tools on your machine in one command. Nothing to configure by hand:

```bash
briefcase-ai connect     # detects Claude Code, Codex, Cursor, VS Code Copilot, ...; shows a diff; asks once
briefcase-ai receive     # local OTLP receiver: their telemetry becomes briefcase decision records
```

`connect` writes each tool's telemetry and MCP settings as key-level edits with
a backup, and `briefcase-ai connect --undo` removes exactly what it wrote.
Prompts, responses, tool input, e-mail addresses and host paths are redacted
unless you opt in (`--capture-content` / `--keep-content`). Claude Code and
Cursor work on a bare install; Codex and VS Code Copilot send protobuf, which needs
`pip install 'briefcase-ai[receiver]'`. `briefcase-ai mcp link cursor` prints a
one-click install link for the MCP server. Per-tool details:
[`docs/integrations/`](https://github.com/briefcasebrain/briefcase-ai-sdk/blob/main/docs/integrations/README.md).

## Extras

| Extra | Description |
| --- | --- |
| `replay` | Deterministic replay engine for recorded decisions |
| `drift` | Drift scoring and cost calculation for model outputs |
| `sanitize` | Built-in PII redaction utilities |
| `otel` | OpenTelemetry helpers |
| `storage` | Rust-backed SQLite storage engine |
| `validate` | Prompt validation engine |
| `guardrails` | Guardrail framework, wrappers, and registries |
| `rag` | Versioned embedding pipeline and instrumented retrieval |
| `rag-chroma` / `rag-pinecone` / `rag-weaviate` | Vector-store adapters (each adds its client) |
| `correlation` | Workflow and trace correlation helpers |
| `external` | External data snapshot tracking |
| `events` | Structured event type and emitter interface |
| `kafka` / `webhook` / `gcp-logging` | Event transports and the Cloud Logging exporter (webhook is stdlib) |
| `routing` | Router protocol, agent router, versioned policy registry |
| `opa` | OPA HTTP router with cached decisions and internal-router fallback (adds `httpx`) |
| `lakefs` | lakeFS versioned storage client, branch manager, lineage, staged commits |
| `vcs` | VCS client base protocol plus DVC, Nessie, Pachyderm, ArtiVC, DuckLake, Iceberg, and git-LFS adapters |
| `vcs-dvc` / `vcs-pachyderm` / `vcs-ducklake` / `vcs-iceberg` | Per-provider VCS clients (the rest are HTTP/subprocess based) |
| `gym` | Gymnasium bridge: guardrail env adapter and RL episode capture |
| `evals` | Eval-harness bridge: `EvalRun` logger, inspect-ai / lm-eval parsers (adds `zstandard` for `.eval` archives on Python < 3.14) |
| `bitemporal` | Bitemporal evidence store, as-of views, append-only corrections |
| `bitemporal-iceberg` | pyiceberg-backed bitemporal store (any supported catalog) |
| `bitemporal-glue` | AWS Glue catalog auth for the Iceberg backend (adds `boto3`) |
| `kdb` | kdb+ bitemporal backend (adds KX-licensed `pykx`; excluded from `all`) |
| `compliance` | Examiner bundles joining decision, evidence, and policy version |
| `compliance-kms` | KMS-signed examiner bundles against your own AWS KMS key (adds `boto3`) |
| `controls` | Gateway, quota, throttle classification, and retry (no extra dependencies) |
| `integrity` | Tamper-evident hash chains, canonical JSON, Ed25519 signing over digests and JSON manifests (signing adds `pynacl`) |
| `langchain` / `crewai` / `llamaindex` / `autogen` / `ag2` / `pageindex` / `openai-agents` | Framework auto-instrumentation via `briefcase.auto` (each adds its framework) |
| `mcp` | MCP server (`briefcase-ai-mcp`) exposing the SDK to AI agents |
| `run` | gRPC client for the `briefcase-ai` evaluation-run CLI (adds `grpcio`, `grpcio-reflection`, `protobuf`) |
| `engine` | gRPC client for `briefcase-ai engine`, `graph` and `env` against the licensed Briefcase engine (adds `grpcio`, `protobuf`, `cryptography`; Briefcase AI operates the proprietary engine) |
| `receiver` | OTLP/protobuf decoding for `briefcase-ai receive` (adds `opentelemetry-proto`; OTLP/JSON needs no extra) |
| `budgets-redis` / `budgets-postgres` / `budgets-mysql` | Shared stores for `briefcase.budgets` (each adds its client: `redis`, `psycopg`, `pymysql`) |
| `dev` | Dev tooling: pytest, mypy, flake8, moto (not part of `all`) |
| `all` | Installs every optional extra listed above except `kdb` and `dev` |

Most features are native- or pure-Python-backed and ship with the base package.
These extras are convenience groupings that pull in **no** additional
dependencies: `replay`, `drift`, `sanitize`, `storage`, `validate`,
`guardrails`, `rag`, `correlation`, `external`, `events`, `webhook`, `routing`,
`vcs`, `bitemporal`, `compliance`, and `controls`. The extras that install
third-party packages are `otel`, `kafka`, `gcp-logging`, `opa`, `lakefs`,
`rag-chroma`, `rag-pinecone`, `rag-weaviate`, `vcs-dvc`, `vcs-pachyderm`,
`vcs-ducklake`, `vcs-iceberg`, `gym`, `evals`, `bitemporal-iceberg`,
`bitemporal-glue`, `kdb`, `compliance-kms`, `integrity`, `langchain`, `crewai`,
`llamaindex`, `autogen`, `ag2`, `pageindex`, `openai-agents`, `mcp`, `run`,
`engine`, `receiver`, `budgets-redis`, `budgets-postgres`, and `budgets-mysql`.
`all` installs every one of those except `kdb`; `dev` is the test tooling and is
not part of `all`.

## Managed platform

The free SDK captures decisions, enforces controls, and supports local replay and storage on your own infrastructure. The proprietary engine runs in Briefcase AI’s managed service. A paid entitlement grants access to the service. Engine binaries and images stay with Briefcase AI.

![Free SDK capture and optional managed engine access](docs/features/managed-engine.svg)

Request [managed engine access](https://observe.briefcasebrain.io/engine). If you previously installed a local engine, follow the [migration guide](docs/features/engine.md) before stopping it.

## Telemetry

The SDK can report anonymous usage metrics (SDK version, OS, architecture, backend
type) to help prioritize development. **No personal data or decision content is ever
collected.** Telemetry is only transmitted when a collection endpoint is configured
via `BRIEFCASE_API_URL` (it defaults to `localhost`, i.e. a no-op), and you can
disable it entirely at any time:

```bash
export BRIEFCASE_TELEMETRY=0   # also accepts: false, no, off (case-insensitive)
```

## Links

- Docs: [briefcaseai.io](https://briefcaseai.io)
- GitHub: [github.com/briefcasebrain/briefcase-ai-sdk](https://github.com/briefcasebrain/briefcase-ai-sdk)
- Contributing: [CONTRIBUTING.md](https://github.com/briefcasebrain/briefcase-ai-sdk/blob/main/CONTRIBUTING.md)

