Metadata-Version: 2.4
Name: trajectory-sdk
Version: 0.6.4
Summary: Generated Trajectory API client and high-level workflows
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: httpx
Requires-Dist: pathspec>=0.12
Requires-Dist: pydantic>=2.0
Provides-Extra: cli
Requires-Dist: claude-agent-sdk>=0.1.0; extra == "cli"
Requires-Dist: harbor>=0.4.0; python_version == "3.12" and extra == "cli"
Dynamic: license-file

# Trajectory SDK

Generated Python client for the Trajectory API, with high-level workflows for uploading
trajectories, telemetry, and runtime-backed benchmarks.

## Install

```bash
pip install trajectory-sdk
```

Install the optional agent and Harbor integrations used by the full CLI with:

```bash
pip install "trajectory-sdk[cli]"
```

## Quick start

Set `TRAJECTORY_API_KEY`, then create a client:

```python
from trajectory import Client

client = Client()
benchmarks = client.benchmarks.list(limit=10)
```

The generated resource methods map directly to the public HTTP API. Higher-level operations that
coordinate multiple API calls are available from `trajectory.lib`:

```python
from trajectory import Client
from trajectory.lib import ingest_events

client = Client()
result = ingest_events(
    client,
    [
        {
            "event_type": "agent.completed",
            "session_id": "session-123",
            "timestamp": "2026-08-28T00:00:00+00:00",
            "properties": {"model": "example-model"},
        }
    ],
)
print(result.ingested, result.skipped)
```

## Command line

The package installs a handwritten `trajectory` command that delegates API operations to the same
generated client and high-level workflows:

```bash
export TRAJECTORY_API_KEY="tj_key_..."

trajectory trajectories upload trajectories.json --dataset my-dataset
trajectory telemetry ingest events.json
trajectory traces upload trajectories.json --events events.json --dataset my-dataset
trajectory secrets set OPENAI_API_KEY
trajectory secrets list
```

API-backed commands use a 30-minute timeout by default. Override it with `--timeout SECONDS`.
The existing repository and benchmark tools remain available from the new CLI package:

```bash
trajectory bench validate ./benchmark
trajectory bench push ./benchmark --build-images
trajectory extract harness
```

## Development

```bash
uv run pytest
uv run ruff check .
uv run ruff format --check .
```

The generated client lives in `src/trajectory/`. Handwritten workflows live in
`src/trajectory/lib/`, the handwritten CLI lives in `cmd/trajectory/cli/trajectory_cli/`, and tests live in
`tests/`.

## License

[Apache 2.0](LICENSE)
