3tears-channels
0.89.0
0.88.0
0.86.0
0.85.0
0.84.0
0.83.0
0.82.0
0.81.0
0.80.0
0.79.0
0.78.0
0.77.0
0.76.0
0.75.0
0.74.0
0.73.0
0.72.0
0.71.0
0.70.1
0.70.0
0.69.0
0.68.0
0.67.0
0.66.0
0.65.0
0.64.0
0.63.1
0.63.0
0.62.0
0.61.0
0.60.0
0.59.0
0.58.0
0.57.0
0.56.3
0.56.2
0.56.1
0.56.0
0.55.0
0.54.0
0.53.0
0.52.1
0.52.0
0.51.1
0.51.0
0.50.0
0.49.0
0.48.0
0.47.1
0.47.0
0.46.1
0.46.0
0.45.1
0.45.0
0.44.0
0.43.0
0.42.0
0.41.4
0.41.3
0.41.2
0.41.1
0.41.0
0.40.0
0.39.0
0.38.0
0.37.0
0.36.0
0.35.1
0.35.0
0.34.0
0.33.0
0.32.1
0.32.0
0.31.0
0.30.1
0.30.0
0.29.0
0.28.0
0.27.0
0.26.1
0.26.0
0.25.0
0.24.7
0.24.6
0.24.5
0.24.4
0.24.3
0.24.2
0.24.1
0.24.0
0.23.9
0.23.8
0.23.7
0.23.6
0.23.5
0.23.3
0.23.2
0.23.11
0.23.10
0.23.1
0.23.0
0.22.5
0.22.4
0.22.3
0.22.2
0.22.1
0.22.0
0.21.0
0.20.0
0.19.4
0.19.3
0.19.2
0.19.1
0.19.0
0.18.0
0.17.9
0.17.8
0.17.7
0.17.6
0.17.5
0.17.4
0.17.3
0.17.2
0.17.1
0.17.0
0.16.1
0.16.0
0.15.0
0.14.1
0.14.0
0.89.0
0.88.0
0.86.0
0.85.0
0.84.0
0.83.0
0.82.0
0.81.0
0.80.0
0.79.0
0.78.0
0.77.0
0.76.0
0.75.0
0.74.0
0.73.0
0.72.0
0.71.0
0.70.1
0.70.0
0.69.0
0.68.0
0.67.0
0.66.0
0.65.0
0.64.0
0.63.1
0.63.0
0.62.0
0.61.0
0.60.0
0.59.0
0.58.0
0.57.0
0.56.3
0.56.2
0.56.1
0.56.0
0.55.0
0.54.0
0.53.0
0.52.1
0.52.0
0.51.1
0.51.0
0.50.0
0.49.0
0.48.0
0.47.1
0.47.0
0.46.1
0.46.0
0.45.1
0.45.0
0.44.0
0.43.0
0.42.0
0.41.4
0.41.3
0.41.2
0.41.1
0.41.0
0.40.0
0.39.0
0.38.0
0.37.0
0.36.0
0.35.1
0.35.0
0.34.0
0.33.0
0.32.1
0.32.0
0.31.0
0.30.1
0.30.0
0.29.0
0.28.0
0.27.0
0.26.1
0.26.0
0.25.0
0.24.7
0.24.6
0.24.5
0.24.4
0.24.3
0.24.2
0.24.1
0.24.0
0.23.9
0.23.8
0.23.7
0.23.6
0.23.5
0.23.3
0.23.2
0.23.11
0.23.10
0.23.1
0.23.0
0.22.5
0.22.4
0.22.3
0.22.2
0.22.1
0.22.0
0.21.0
0.20.0
0.19.4
0.19.3
0.19.2
0.19.1
0.19.0
0.18.0
0.17.9
0.17.8
0.17.7
0.17.6
0.17.5
0.17.4
0.17.3
0.17.2
0.17.1
0.17.0
0.16.1
0.16.0
0.15.0
0.14.1
0.14.0
توضیحات
Unified message protocol for channel adapters in the 3tears platform
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | 3tears-channels-0.89.0 |
| نام | 3tears-channels |
| نسخه کتابخانه | 0.89.0 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | pace |
| ایمیل نویسنده | - |
| آدرس صفحه اصلی | - |
| آدرس اینترنتی | https://pypi.org/project/3tears-channels/ |
| مجوز | - |
# 3tears-channels
A unified message protocol for the 3tears framework, with adapters for Slack, Discord, and WebSocket clients. Write your agent logic once and deliver it across channels.
```bash
pip install 3tears-channels
```
## What you get
- **One message model** -- `ChannelMessage`, `ChannelResponse`, `ChannelDeliveryMessage`, and `Attachment` carry a request and its reply regardless of channel.
- **Routing** -- `ChannelRouter` and `StreamingChannelRouter` dispatch inbound messages and stream responses back.
- **Slack and Discord** -- payload and rich-formatting builders (`build_slack_blocks`, `build_slack_payload`, `build_discord_embed`, `build_discord_payload`) plus a `should_use_rich_formatting` helper.
- **WebSocket** -- `WebSocketHandler`, `WebSocketProtocol`, a `ConnectionRegistry`, and frame primitives for real-time clients.
- **Rooms and presence** -- `RoomFanout`, `RoomState`, `RoomIndexCollection`, and a three-tier-backed `PresenceCollection` with a `PresenceSweeper` for connection liveness.
- **Email** -- `threetears.channels.mail`: `Mailer` over an `EmailTransport`, an SMTP transport reading its settings per send, `EmailTemplate` substitution with an HTML alternative and `List-Unsubscribe` headers, `send_batch` for many recipients with per-recipient failure isolation, and `BounceReceiver` for HMAC-verified delivery reports. A sibling of the channel adapters rather than one of them -- an email recipient has no conversation and usually no account, so `ChannelDeliveryMessage` does not apply.
## Quickstart
```python
from threetears.channels import ChannelRouter, ChannelMessage, build_slack_blocks
router = ChannelRouter(...)
response = await router.dispatch(ChannelMessage(text="hello", channel="slack", ...))
blocks = build_slack_blocks(response)
```
## WebSocket connection lifetime
`WebSocketHandler` ends a connection on its own in two cases, besides the peer disconnecting.
**The peer stops answering.** Every `heartbeat_interval` seconds (config key, default 30) each open
connection is sent `{"type": "ping"}`. A connection that has sent nothing since the previous ping
is closed with code 1011, and its registry entry, rooms and presence are cleaned up as on a
disconnect. Any frame counts as an answer; an otherwise idle client answers with
`{"type": "pong"}`. A connection busy with a frame (a turn in flight) is not judged until it is
reading again.
**The credential expires.** If the `auth_validator`'s claims include `exp` (unix seconds), the
first frame at or after that time, or the first heartbeat tick of an idle connection, is answered
with the same refusal an unauthenticated connection gets:
```json
{"type": "error", "code": "UNAUTHENTICATED", "message": "access token expired"}
```
and the socket is closed 1008. A client handles it like any `UNAUTHENTICATED` refusal: obtain a
fresh credential and reconnect. Leave `exp` out of the claims for a connection that should not
expire.
A connection that is answering pings also keeps its presence row fresh, so `PresenceSweeper`
does not evict a live member.
## License
MIT. See [LICENSE](LICENSE).
نیازمندی
| مقدار | نام |
|---|---|
| - | 3tears-agent-acl<0.90.0,>=0.89.0 |
| - | 3tears-nats[client]<0.90.0,>=0.89.0 |
| - | 3tears-observe<0.90.0,>=0.89.0 |
| - | 3tears<0.90.0,>=0.89.0 |
| - | pydantic>=2.0 |
| - | sqlalchemy |
| xtr | discord-py>=2.7; |
| xtr | aiohttp>=3.9; |
| xtr | slack-bolt>=1.28; |
| xtr | slack-sdk>=3.41; |
| xtr | 3tears-agent-wake<0.90.0,>=0.89.0; |
| xtr | fastapi>=0.110; |
| xtr | starlette>=0.36; |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.14 | Python |
نحوه نصب
نصب پکیج whl 3tears-channels-0.89.0:
pip install 3tears-channels.whl
نصب پکیج tar.gz 3tears-channels-0.89.0:
pip install 3tears-channels.tar.gz