Skip to main content

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.

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

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:

{"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.

Metadata

Release files for 3tears-channels 0.77.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for 3tears-channels 0.77.0
File Size Uploaded Provenance
3tears_channels-0.77.0.tar.gz 202.4 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for 3tears-channels 0.77.0
File Interpreter ABI Platform
3tears_channels-0.77.0-py3-none-any.whl Python 3 none any Details

Total release size: 317.4 kB

Release files / 3tears_channels-0.77.0.tar.gz

Download URL 3tears_channels-0.77.0.tar.gz
Size 202.4 kB
Tags Source
SHA-256 checksum
How to use checksums
cd56eb4a45cd0e36874b0bda129701c96f397a6071fbdf4b8d2b12201449e90e
BLAKE2b-256 checksum
How to use checksums
f9280a730943c25908e36ad2eeb1d8d8222183da2696d7b3ce76170817f568de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Release files / 3tears_channels-0.77.0-py3-none-any.whl

Download URL 3tears_channels-0.77.0-py3-none-any.whl
Size 115.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1037c71cf8a4c4e81abe498e00bcbe21e5281f7061b49641c7c2109ab6c545fd
BLAKE2b-256 checksum
How to use checksums
308d6e20c15bb54ab4cf14fab06cbec43d2d06b1c40369169293366148f0a42e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Security for 3tears-channels 0.77.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for 3tears_channels-0.77.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.77.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page