Metadata-Version: 2.4
Name: klyra
Version: 3.0.0
Summary: Klyra — enterprise AI engineering gateway and cost-optimization proxy for Claude Code.
Author: Klyra
License: Copyright (c) 2026 Klyra. All rights reserved.
        
        This repository is proprietary unless a separate written license grants additional
        rights. No permission is granted to redistribute, sublicense, or commercially
        exploit the source code without written authorization from the copyright holder.
        
Project-URL: Homepage, https://klyralabs.io
Keywords: claude-code,anthropic,proxy,cost-optimization,llm
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Operating System :: OS Independent
Classifier: License :: Other/Proprietary License
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: fastapi==0.128.2
Requires-Dist: uvicorn==0.48.0
Requires-Dist: httpx==0.28.1
Requires-Dist: rich==15.0.0
Requires-Dist: typer==0.26.3
Requires-Dist: python-dotenv==1.2.2
Provides-Extra: dev
Requires-Dist: pytest==9.0.2; extra == "dev"
Dynamic: license-file

# Klyra V3.0 — Enterprise Control Plane

Claude Code → Klyra → Anthropic.

Klyra is a local-first optimization and organization control layer for Claude Code.

## Install

```bash
pip install klyra
klyra start
```

Then in another terminal:

```bash
export ANTHROPIC_BASE_URL="http://127.0.0.1:8787"
claude
```

(PowerShell: `$env:ANTHROPIC_BASE_URL="http://127.0.0.1:8787"`)

That's it — Claude Code works exactly as before, with Klyra optimizing transparently
in between. No config file or account setup required for local use. To go back to
unoptimized Claude Code, just unset `ANTHROPIC_BASE_URL`.

## V2.4 focus

This release closes the most important product-readiness gaps discovered during the
v2.x review:

- organization-scoped authentication and session revocation
- verified machine API-key identity for proxy traffic
- real policy enforcement and repository-optimization control
- organization optimization enable/disable switch
- daily/monthly hard budget enforcement
- explicit global optimization kill switch
- outcome attribution separate from usage-verified savings
- authenticated organization dashboard
- security, install, API, architecture and rollback documentation
- pinned runtime dependencies
- CI regression suite
- semantic tool-output classification for shell, git, search, file, test, build and package-manager workflows
- deterministic low-risk tool-noise compaction
- failure/summary preservation and fail-open tool analysis
- organization policy control for tool intelligence

## Security model

### Local development

Loopback proxy traffic (`127.0.0.1` / `::1`) can use the configured local identity
for backwards-compatible Claude Code setup.

### Remote deployment

Remote proxy clients must authenticate with:

`X-Klyra-API-Key: <organization machine key>`

Set:

`KLYRA_REQUIRE_PROXY_AUTH=1`

Klyra derives organization and user identity from the verified machine key. It
does not trust `X-Klyra-Org-Id` or `X-Klyra-User-Id` for authenticated remote
traffic.

## Running from source (development)

```powershell
py -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install -r requirements.txt
python -m klyra start
```

Then in another terminal:

```powershell
$env:ANTHROPIC_BASE_URL="http://127.0.0.1:8787"
claude
```

Configure an owner password:

```powershell
python -m klyra org-password
```

Organization dashboard:

`http://127.0.0.1:8787/org`

## Policies and budgets

Organization policy controls:

- context optimization
- tool optimization
- repository optimization
- prompt caching
- minimum confidence
- optimization enabled/disabled
- daily budget
- monthly budget
- hard budget enforcement

Disabling optimization is a transparent-pass-through mode.

Set `KLYRA_KILL_SWITCH=1` for an emergency optimization bypass while keeping
the proxy available.

## Savings accounting

Klyra distinguishes:

1. optimization candidate
2. applied optimization
3. usage-verified/counterfactual dollar saving
4. task outcome (`accepted`, `reverted`, `failed`, `unconfirmed`)

Klyra does not treat an estimated optimization as a realized financial saving.

## Agent / tool intelligence

Klyra classifies tool results by workflow before optimizing them. Git diffs and file reads are observe-only because semantic loss is too risky. Search and file-discovery results may compact exact duplicate lines. Test, build and package-manager output may compact repeated PASS/progress noise while preserving failures, tracebacks, summaries and unique lines. The engine is deterministic and fail-open.

Set `tool_intelligence` in the organization policy to disable this analysis independently of ordinary tool optimization.

## Repository intelligence

Repository inspection is local-only and fail-open. It can inventory files,
Git state, referenced paths, and safe duplicate repository/tool snapshots.
Repository source is not uploaded by the optimizer.

## Documentation

- `docs/INSTALL.md`
- `docs/API.md`
- `docs/ARCHITECTURE.md`
- `docs/DATA_HANDLING.md`
- `docs/ROLLBACK.md`
- `SECURITY.md`
- `CONTRIBUTING.md`

## Validation

Current release:

```text
31 passed
Python compilation: PASS
CLI help: PASS
```

The CI workflow runs the same regression suite on Python 3.11, 3.12 and 3.13.

## V2.5 Adaptive Context & Tool Planner

Klyra now infers the current task intent and produces deterministic relevance/preservation decisions for tool results. Failures and summaries remain protected, while only the existing lossless optimizers may mutate eligible noise.

## Internal Git + GitHub workspace (V2.6)

Klyra includes organization-scoped Git-style workflows and GitHub integration. See `docs_git_layer.md` for commands, session querying, branch descriptions, and token handling.

## V2.8 Semantic Safety Layer

Klyra adds a conservative structural-semantic redundancy detector for large tool outputs. It normalizes volatile metadata such as timestamps, durations, and counters, then identifies highly similar repeated output blocks. Only safe tool categories are eligible, and blocks containing failures or summaries are protected. This layer is deterministic and does not call an LLM or send source code to a secondary model. Disable it per organization with `semantic_optimization: false`.


## V2.8 Billing-Grade Economics

V2.8 adds canonical Anthropic usage parsing, versioned pricing, separate verified cache and estimated optimization savings, 5-minute/1-hour cache accounting, live telemetry, and non-streaming proxy support. See `docs/V2_8_BILLING.md`.

## Klyra V3.0 — Enterprise Control Plane

V3.0 unifies Klyra's organization boundary, authenticated identity, RBAC, scoped API access, gateway authorization, billing-grade economics, usage analytics and auditability into an enterprise control-plane foundation.

See `docs/V3_0_ENTERPRISE_CONTROL_PLANE.md` for the architecture and API model.
