Metadata-Version: 2.5
Name: traceharbor
Version: 0.3.0
Summary: Local-first observability, debugging and replay workbench for AI agents.
Project-URL: Homepage, https://github.com/DwaipayanDutta/traceharbor
Author: TraceHarbor contributors
License: MIT
License-File: LICENSE
Keywords: ai-agents,debugging,llm,observability,opentelemetry,tracing
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Debuggers
Requires-Python: >=3.11
Requires-Dist: alembic>=1.13
Requires-Dist: fastapi>=0.115
Requires-Dist: pydantic>=2.7
Requires-Dist: sqlalchemy>=2.0.30
Requires-Dist: typer>=0.12
Requires-Dist: uvicorn>=0.30
Provides-Extra: all
Requires-Dist: crewai>=0.80; extra == 'all'
Requires-Dist: langchain-core>=0.3; extra == 'all'
Requires-Dist: langgraph>=0.2; extra == 'all'
Requires-Dist: opentelemetry-api>=1.25; extra == 'all'
Requires-Dist: psycopg[binary]>=3.1; extra == 'all'
Provides-Extra: crewai
Requires-Dist: crewai>=0.80; extra == 'crewai'
Provides-Extra: langchain
Requires-Dist: langchain-core>=0.3; extra == 'langchain'
Provides-Extra: langgraph
Requires-Dist: langgraph>=0.2; extra == 'langgraph'
Provides-Extra: opentelemetry
Requires-Dist: opentelemetry-api>=1.25; extra == 'opentelemetry'
Provides-Extra: postgres
Requires-Dist: psycopg[binary]>=3.1; extra == 'postgres'
Description-Content-Type: text/markdown

<div align="center">

# #The Agent Stack
### ELECTRIC OBSERVABILITY &nbsp;·&nbsp; VOL. 01

![TraceHarbor Poster](traceharbor_poster.png)

`TRACE / 001` &nbsp; `LOCAL-FIRST WORKBENCH` &nbsp; `ALPHA · v0.3.0`

<br/>

# TraceHarbor
### OBSERVE. DEBUG. REPLAY. EVALUATE.

**The local-first debugging and replay workbench for AI agents.**

`2024` &nbsp;·&nbsp; `SEPTEMBER` &nbsp;·&nbsp; `ALPHA`

<br/>

[01 — Overview](#01--what-works-today) &nbsp; / &nbsp; [02 — Install](#02--install--run) &nbsp; / &nbsp; [03 — Instrument](#03--instrument-an-agent) &nbsp; / &nbsp; [04 — CLI](#04--control-panel) &nbsp; / &nbsp; [05 — Privacy](#05--privacy) &nbsp; / &nbsp; [06 — Replay](#06--tracing--replay) &nbsp; / &nbsp; [07 — Architecture](#07--architecture) &nbsp; / &nbsp; [08 — Development](#08--development) &nbsp; / &nbsp; [09 — Roadmap](#09--roadmap)

</div>

---

<div align="center">

> **A flight recorder for AI agents.**
>
> TraceHarbor captures what happened inside an AI agent run — nested spans, inputs, outputs,
> tools, models, tokens, errors and stack traces — stores it **on your machine**
> (SQLite + local files) and presents it in a browser UI.
>
> **No cloud account. No API keys. No Docker. No Node.js needed to run it.**

</div>

---

## 01 / WHAT WORKS TODAY

<sub>v0.3.0 &nbsp;·&nbsp; ALPHA &nbsp;·&nbsp; ROADMAP PHASES 0–3</sub>

<table>
<tr>
<td width="50%" valign="top">

### 01.01 &nbsp; INSTALL & RUN

`pip install` + `tracenest start` → local server + bundled React UI.

Trace list · span tree · inspector · execution graph · timeline · tool inspector · analytics · SSE live updates

### 01.02 &nbsp; PYTHON SDK

- Standard library only — no dependencies at import time
- `init` · `@observe` · `trace()` · `start_span()`
- Sync, async, generators, nested and concurrent spans

### 01.03 &nbsp; RELIABILITY

- Bounded non-blocking queue · batching · retry with backoff
- **Offline buffering** when the server is down
- `flush()` / `shutdown()`

### 01.04 &nbsp; SAFETY RAILS

- Exceptions and stack traces recorded and **re-raised unchanged**
- Return values **never altered**

</td>
<td width="50%" valign="top">

### 01.05 &nbsp; PRIVACY BY DESIGN

- Head sampling · content-capture switches
- Key- and pattern-based **redaction** on client and server

### 01.06 &nbsp; OPTIONAL ECONOMICS

- Token usage when available
- Cost estimated **only** for models you price yourself

### 01.07 &nbsp; REST API v1

Ingest · traces · spans · graph · timeline · projects · API keys · settings · export/import

OpenAPI at `/docs`

### 01.08 &nbsp; CORRECTNESS

- Idempotent ingestion (stable event IDs) · out-of-order tolerant
- Per-project isolation · API-key auth for exposed servers
- Execution graph built **only from observed** parent/link relationships

</td>
</tr>
</table>

---

## 02 / INSTALL & RUN

<sub>GET THE WORKBENCH RUNNING LOCALLY</sub>

```bash
pip install traceharbor
# From a wheel:
# pip install dist/traceharbor-0.3.0-py3-none-any.whl

tracenest start
# Opens http://127.0.0.1:7331
```

```text
╭─────────────────────────────────────────────╮
│                                             │
│   TraceHarbor is running!                    │
│                                             │
│   Dashboard: http://127.0.0.1:7331          │
│   Project:   default                        │
│   Storage:   ~/.tracenest/                  │
│                                             │
│   Press CTRL+C to stop.                     │
│                                             │
╰─────────────────────────────────────────────╯
```

<div align="center">
<sub>
  OPTIONS &nbsp;·&nbsp; <code>--host</code> &nbsp;·&nbsp; <code>--port</code> &nbsp;·&nbsp;
  <code>--data-dir</code> &nbsp;·&nbsp; <code>--no-browser</code> &nbsp;·&nbsp;
  <code>--detach</code> &nbsp;·&nbsp; <code>tracenest stop</code>
</sub>
</div>

---

## 03 / INSTRUMENT AN AGENT

<sub>ADD OBSERVABILITY WITHOUT REWRITING YOUR AGENT</sub>

```python
from tracenest import init, observe, trace, start_span

init(project="my-agent")  # endpoint defaults to http://127.0.0.1:7331

@observe(name="research_agent", span_type="agent")
def research_agent(query: str):
    return retrieve_documents(query)

with trace("research_workflow"):
    research_agent("AI observability")

with start_span("customer_lookup", span_type="tool") as span:
    span.set_attribute("tool.name", "customer_lookup")
    span.set_output(lookup_customer("C102"))
```

<div align="center">
<sub>
  ▶ Runnable, key-free example: <code>examples/basic-python/main.py</code>
  &nbsp;·&nbsp; SDK guide: <code>docs/sdk.md</code>
</sub>
</div>

**If the server is unavailable, your agent is unaffected.**

Events buffer under `<data_dir>/sdk-buffer` and are delivered later.
Check `tracenest.diagnostics()` for dropped/buffered counts.

---

## 04 / CONTROL PANEL

<sub>THE COMMAND LINE IS THE CONTROL SURFACE</sub>

```text
╔══════════════════════════════════════════════════════════════════════════╗
║                                                                          ║
║    ⬤           ◀◀◀           ▶▶           ▶▶▶           ⬛               ║
║   ███          ███          ███           ███          ███               ║
║                                                                          ║
║   START       DOCTOR       PROJECTS       TRACES        STOP             ║
║                                                                          ║
╚══════════════════════════════════════════════════════════════════════════╝
```

```bash
tracenest start
tracenest doctor
tracenest projects list
tracenest traces list
tracenest stop

tracenest import
tracenest keys
tracenest version
tracenest config
```

---

## 05 / PRIVACY

<sub>YOUR TRACES STAY YOURS</sub>

<table>
<tr>
<td width="33%" valign="top">

### ◉ LOCAL BY DEFAULT

Binds to `127.0.0.1`.

Non-local binding requires `--allow-remote` and enables API-key auth.

</td>
<td width="33%" valign="top">

### ◉ ON-DISK OWNERSHIP

Data lives in `~/.tracenest/`:

```text
tracenest.db
artifacts/
config.json
```

Payloads are stored as gzip artifacts with SHA-256 checksums.

</td>
<td width="33%" valign="top">

### ◉ NO PHONING HOME

TraceHarbor sends no telemetry anywhere and needs no external service.

</td>
</tr>
</table>

<div align="center">

**🔒 REDACTION IS ON BY DEFAULT**

Masks sensitive keys (`password`, `api_key`, `authorization`, …) and secret-looking values
(`sk-…`, AWS keys, JWTs, bearer tokens, private keys).

<sub>Redaction is best-effort. Review <code>docs/security.md</code>.</sub>

</div>

---

## 06 / TRACING × REPLAY

<sub>WHAT THE CURRENT BUILD DOES — AND DOES NOT — DO</sub>

<div align="center">

### ⚠ COLLECTION & INSPECTION ONLY

TraceHarbor currently performs collection and inspection only.

Replay modes (playback, deterministic, branch) are designed in
`docs/adr/0006-replay-safety.md` but are **not implemented yet** (Phase 5).

Nothing in the current UI or CLI re-executes your code or tools.

</div>

| Mode | Status | What it does |
|---|---|---|
| Collect & Inspect | ✅ Shipping | Record, persist, visualize |
| Playback replay | ⏳ Phase 5 | Reconstruct from stored events |
| Deterministic replay | ⏳ Phase 5 | Re-run against recorded fixtures |
| Branch replay | ⏳ Phase 5 | Fork from a selected span |

---

## 07 / ARCHITECTURE

<sub>A MODULAR MONOLITH · LOCAL DATA PATH</sub>

```text
         ╭───────────╮
         │  AGENT    │
         ╰─────┬─────╯
               │  @observe
               ▼
         ╭───────────╮    bounded      ╭───────────╮    ╭───────────╮
         │    SDK    │═══ queue ═══▶   │    API    │═══▶│  STORAGE  │
         │  stdlib   │    HTTP batch   │  FastAPI  │    │  SQLite   │
         ╰───────────╯                 ╰─────┬─────╯    ╰───────────╯
               ▲                             │
               │                             │ SSE
        agent runs fine                     ▼
        if server is down           ╭───────────╮
                                     │   WEB UI  │
                                     │   React   │
                                     ╰───────────╯
```

<div align="center">

` sdk/ ` → ` api/ ` → ` core/ ` → ` storage/ ` + ` artifacts/ `

<sub>
  <code>core/</code> is framework-free &nbsp;·&nbsp;
  SQLAlchemy 2 + Alembic &nbsp;·&nbsp; SQLite default
</sub>

<sub>Architecture notes: <code>docs/architecture.md</code></sub>

</div>

---

## 08 / DEVELOPMENT

<sub>BUILD · TEST · VERIFY</sub>

```bash
uv sync --group dev

# Or:
pip install -e . pytest pytest-asyncio httpx ruff mypy build

pytest
# unit · sdk · api · security · integration

ruff check src tests && mypy src

cd frontend && npm install && npm run build
# writes into src/tracenest/web/dist

python scripts/verify_wheel.py
# build + fresh-venv install + e2e
```

<div align="center">
<sub>CI matrix configured for Linux · macOS · Windows (has not been run yet)</sub>

<sub>PostgreSQL backend is planned — SQLite is the supported default today</sub>
</div>

---

## 09 / ROADMAP

<sub>FROM COLLECTION TO A COMPLETE AGENT WORKBENCH</sub>

```text
┌──────────────────────────────────────────────────────────────────┐
│                                                                  │
│   00   FOUNDATION                    ✔  done                     │
│   01   PACKAGE · CLI · SERVER        ✔  done                     │
│   02   SDK · INGESTION               ✔  done                     │
│  ▸03   FULL WORKBENCH             ▶  next                        │
│         overview · graph · timeline · tools · filters            │
│   04   LANGGRAPH · MULTI-AGENT       ⏳  planned                 │
│         failure demo                                             │
│   05   REPLAY                        ⏳  planned                 │
│         playback · deterministic · branch · diff                 │
│   06   EVALUATIONS                   ⏳  planned                 │
│         datasets · experiments                                   │
│   07   INTEGRATIONS · RELEASE        ⏳  planned                 │
│         LangChain · CrewAI · OTLP · Docker                       │
│                                                                  │
└──────────────────────────────────────────────────────────────────┘
```

---

<div align="center">

## LICENSE

**MIT** &nbsp;·&nbsp; © TraceHarbor contributors

<br/>

```text
██████╗ █████╗  ██████╗  ██████╗ ███████╗
██╔══██╗██╔══██╗██╔════╝ ██╔════╝ ██╔════╝
██████╔╝███████║██║      ██║      █████╗
██╔══██╗██╔══██║██║      ██║      ██╔══╝
██████╔╝██║  ██║╚██████╗ ╚██████╗ ███████╗
╚═════╝ ╚═╝  ╚═╝ ╚═════╝  ╚═════╝ ╚══════╝
```

`T R A C E N E S T` &nbsp;·&nbsp; `0.2.0` &nbsp;·&nbsp; `ALPHA`

**OBSERVE / DEBUG / REPLAY / EVALUATE**

<sub>Made on a Friday. For agents that misbehave on Mondays.</sub>

</div>