Metadata-Version: 2.4
Name: channelkit
Version: 0.1.0a1
Classifier: Development Status :: 3 - Alpha
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Rust
License-File: LICENSE
License-File: THIRD_PARTY_NOTICES.txt
Summary: Rust-backed Slack and WhatsApp messaging adapters for application-owned agents
Keywords: agents,slack,whatsapp,messaging,rust
Author-email: Mykhailo Chalyi <mike@chaliy.name>
License-Expression: MIT
Requires-Python: >=3.10
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Repository, https://github.com/everruns/channelkit

# Channelkit for Python

Native Python bindings to Channelkit's Rust Slack and WhatsApp adapters. A library
for application-owned agents: no server, database, agent runtime, or background worker.

```sh
python -m pip install 'channelkit==0.1.0a1'
```

```python
import asyncio
import os
from channelkit import Slack, text

slack = Slack("support", os.environ["SLACK_TEAM_ID"],
              os.environ["SLACK_BOT_TOKEN"], os.environ["SLACK_SIGNING_SECRET"])

async def main():
    receipt = await slack.post(slack.conversation(os.environ["SLACK_TEST_CHANNEL"]),
                               text("Hello from Rust-backed Python!"))
    print(receipt["status"])  # accepted, not delivery confirmation

asyncio.run(main())
```

## Signed webhooks and replies

Pass the **original request bytes**, headers, method and query to `receive`.
The returned `events` use the Rust JSON model (`event["kind"]["Message"]`,
`Action`, `Reaction`, etc.). Verification is synchronous; outbound methods are
async and release the GIL. Only your host decides when to accept the HTTP request,
store/deduplicate events, authorize actions, and start agent work.

```python
# Inside your host's request handler, before sending its HTTP response:
ingress = slack.receive(raw_body, request_headers)
for event in ingress["events"]:
    message = event["kind"].get("Message")
    if message and message["mentioned"]:
        await slack.reply(message, "I received your message")
# Return ingress["response"]["status"], content_type and body from your host.
# A durable host should persist accepted events before acknowledging them.
```

`WhatsApp(installation, phone_number_id, token, app_secret, verify_token)`
verifies Meta signatures and GET verification challenges. `reply(message, text)`
uses the verified message's timestamp for WhatsApp's customer-service window.
`post` leaves window enforcement to Meta; a provider window rejection is
reported as `ReplyWindowClosed`. For outbound conversations, use `await whatsapp.send_template(target, "approved_template", "en_US")` with
an approved template and an opted-in recipient. No templates or recipients are
created automatically.

## API and failure contracts

Both adapters expose `conversation`, `receive`, `post`, `reply`, `react`, `edit`,
`delete`, `history`, and `typing`; WhatsApp also exposes `send_template`.
Provider-specific unsupported operations fail explicitly. Helpers `text`,
`markdown`, `card(title, body, [{"id": "approve", "label": "Approve"}])`,
`conversation`, and Unicode-aware `split_text` are validated by Rust.
Type hints ship with the package.

Catch `ChannelkitError` and inspect `code`, `details`, `retry_after_ms`, and
`confirmed`. `DeliveryUnknown` must **never** be blindly retried.
`PartialDelivery` includes confirmed message references and `details["source"]`.
No automatic retries occur. A cancelled task or host timeout is also not proof
that a send was rejected; retain pending work and reconcile before recovery. Provider bodies and credentials are redacted from
errors. Keep credentials in your host's secret manager; never log request headers.

`provider_capabilities` describes the underlying Rust provider. This initial
binding does **not** expose the coordinator, durable hooks, streaming, media,
Slack-specific extensions, or other provider adapters. Use Rust for those APIs.
The host owns long-running approvals, persistence, recovery, and authorization.

CPython 3.10+ (regular GIL builds): macOS 11+ arm64/x64, Windows x64, and
Linux x64 glibc 2.35+. No musl, free-threaded Python, or other-platform claim.

## Sources of inspiration

Channelkit draws on [Chat SDK](https://chat-sdk.dev/),
[BerriAI agentchat](https://github.com/BerriAI/agentchat),
[Bashkit](https://github.com/everruns/bashkit), and
[Everruns](https://github.com/everruns/everruns).
The native bridge uses [PyO3](https://pyo3.rs/) and
[pyo3-async-runtimes](https://github.com/PyO3/pyo3-async-runtimes).

[Project](https://github.com/everruns/channelkit) ·
[MIT license](LICENSE)

