Metadata-Version: 2.4
Name: dedroom
Version: 0.5.0
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Rust
Classifier: Topic :: Software Development :: Build Tools
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Dist: pytest ; extra == 'dev'
Requires-Dist: pytest-asyncio ; extra == 'dev'
Provides-Extra: all
Provides-Extra: dev
License-File: LICENSE
Summary: Unified agent runtime: loop detection + context compression for AI coding agents
Keywords: ai-agent,claude-code,copilot,codex,aider,cursor,cline,loop-detection,context-compression,proxy,token-savings
Author: DedrooM contributors
Requires-Python: >=3.10
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: documentation, https://github.com/Devaretanmay/dedroom#readme
Project-URL: homepage, https://github.com/Devaretanmay/dedroom
Project-URL: repository, https://github.com/Devaretanmay/dedroom

# DedrooM

**Loop detection + context compression for AI coding agents.**

[![PyPI version](https://img.shields.io/pypi/v/dedroom.svg)](https://pypi.org/project/dedroom/)
[![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](LICENSE)

DedrooM sits between your AI agent and the LLM provider to:

- **Detect and block infinite loops** — saves wasted API calls when tools repeat
- **Compress context** — reduces token usage by 60–95% without changing behavior
- **Intelligence Engine** — parses thoughts locally, injects proactive mentor coaching, tracks trust scores, and learns from failures
- **Redact sensitive data** — strip API keys, tokens, and secrets from tool outputs
- **Track ROI** — attribution engine shows exactly how much each tool saves

---

## Quick Start

```bash
pip install dedroom

# Start the proxy daemon and route your agent through it
dedroom init
eval "$(dedroom init)"       # Sets ANTHROPIC_BASE_URL and OPENAI_BASE_URL

# Use your agent as normal
claude          # now routed through DedrooM
codex           # works immediately

# Check status and stop
dedroom status  # Show running state, PID, uptime, tokens saved
dedroom stop    # Stop the daemon
```

### One-shot alternative (no daemon)

```bash
dedroom wrap claude   # Starts proxy, launches agent, cleans up on exit
```

---

## Commands

| Command | Description |
|---|---|
| `init` | Start proxy daemon and print shell exports |
| `status` | Show proxy status, PID, uptime, savings |
| `stop` | Stop the daemon |
| `wrap <agent>` | Start proxy + launch agent |
| `unwrap <agent>` | Restore config to pre-wrap state |
| `doctor` | Run health checks |
| `report` | Show per-tool compression report |
| `proxy` | Start standalone proxy server |

### Use any LLM provider (not just OpenAI/Anthropic)

```bash
# DeepSeek API
dedroom wrap claude \
  --upstream-url https://api.deepseek.com \
  --api-key "sk-your-key"

# Local Ollama
dedroom wrap aider \
  --upstream-url http://localhost:11434/v1
```

---

## Python API

```python
from dedroom import DedrooM

pipeline = DedrooM("""
loop_detection:
  max_repeats: 3
""")

# Check for loops (0 = Allow)
verdict = pipeline.verify("write_file", '{"path": "/tmp/x.txt"}')

# Full pipeline
result = pipeline.process_tool("write_file", '{}', tool_result)
print(f"Blocked: {result['is_blocked']}")
print(f"Saved {result['original_tokens'] - result['compressed_tokens']} tokens")
```

---

## Benchmarks

| Payload | Raw Tokens | With DedrooM | Reduction |
|---------|:----------:|:------------:|:---------:|
| Repeated directory listing (1MB) | 483,672 | 177,245 | **63.4%** |
| Large source file | 18,331 | 14,167 | **22.7%** |
| Build log | 284 | 284 | **0%** (no redundancy) |

- **Loop detection latency:** ~1.3ms per tool call (negligible vs 2-10s LLM roundtrip)
- **Pipeline throughput:** 5.4µs (in-memory) / 260µs (SQLite)

---

## Development

```bash
git clone https://github.com/Devaretanmay/dedroom
cd dedroom

# Build Rust binaries
cargo build -p dedroom-cli -p dedroom-proxy

# Install Python package in dev mode
pip install -e .

# Run tests
pytest python/tests/
```

