Metadata-Version: 2.4
Name: ptm-sdk
Version: 0.1.0
Summary: Local-first developer SDK for logging and monitoring M2M agent transactions, with optional PTAPI cloud sync
Project-URL: Homepage, https://github.com/Git332/Post-Transaction-Monitoring
Project-URL: Repository, https://github.com/Git332/Post-Transaction-Monitoring
Author: Git332
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.11
Requires-Dist: httpx>=0.27
Requires-Dist: pydantic>=2.9
Provides-Extra: dev
Requires-Dist: mypy>=1.13; extra == 'dev'
Requires-Dist: pytest>=8.3; extra == 'dev'
Requires-Dist: ruff>=0.7; extra == 'dev'
Description-Content-Type: text/markdown

# ptm-sdk

Local-first logging and anomaly checks for M2M agent transactions. No server,
no signup, no sales conversation — everything runs on your own machine in a
local SQLite file. Optionally forwards to a PTAPI cloud instance if you want
cross-party reconciliation, which a purely local tool can't provide on its
own.

## Usage

```python
from datetime import datetime, UTC
from ptm_sdk import PTMLocalClient

client = PTMLocalClient()  # defaults to ~/.ptm/local.db

event = client.log_event(
    agent_id="agent-1",
    transaction_type="payment",
    counterparty_id="vendor-1",
    amount=250,
    currency="USD",
    occurred_at=datetime.now(UTC),
    status="success",
)
print(event.anomaly_flags)  # e.g. [] or ["amount_outlier"]

client.query(agent_id="agent-1", has_anomaly=True)
```

Enable cloud sync by also passing `cloud_api_key`/`cloud_ingest_url` (get an
API key via `POST /tenants/provision` on your PTAPI instance):

```python
client = PTMLocalClient(
    cloud_api_key="ptmk_...",
    cloud_ingest_url="https://your-ptapi-instance/events/ingest",
)
```

## CLI

```bash
ptm-sdk log --agent-id agent-1 --transaction-type payment \
    --counterparty-id vendor-1 --amount 250 --currency USD --status success
ptm-sdk query --agent-id agent-1 --has-anomaly
```

Pass `--db-path` to any command to use a DB file other than the default
`~/.ptm/local.db`.

## Development

```bash
pip install -e ".[dev]"
pytest
ruff check .
mypy src/ptm_sdk
```

## Releasing

Published to [PyPI](https://pypi.org/project/ptm-sdk/) via GitHub Actions
Trusted Publishing (OIDC) — no token stored anywhere
(`.github/workflows/publish.yml`). One-time setup on PyPI: Account Settings →
Publishing → add a pending publisher with owner `Git332`, repo
`Post-Transaction-Monitoring`, workflow `publish.yml`, environment `pypi-ptm-sdk`.

To cut a release: bump `version` in `pyproject.toml`, then push a tag matching
`ptm-sdk-vX.Y.Z` (or create a GitHub Release from that tag) — this triggers
the publish job for this package only.
