Explorar o código

Update documentation to reflect chattolib usage

- Replace references to manual protobuf codec with chattolib
- Update WebSocket/ConnectRPC descriptions to chattolib API
- Remove mentions of websockets dependency
- Update RPC endpoint names to chattolib method names
- Add chattolib reference links

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
Liv Klumpp hai 1 semana
pai
achega
020125c041
Modificáronse 2 ficheiros con 23 adicións e 28 borrados
  1. 18 20
      DOCS.md
  2. 5 8
      README.md

+ 18 - 20
DOCS.md

@@ -6,9 +6,9 @@ description: "Set up Hermes Agent as a Chatto bot"
 
 # Chatto Setup
 
-Hermes Agent integrates with [Chatto](https://github.com/chattocorp/chatto), a self-hosted team chat server. The adapter connects via the Chatto WebSocket realtime protocol (binary protobuf) for inbound message delivery and the ConnectRPC JSON API for outbound messages. It processes messages through the Hermes Agent pipeline (including tool use, memory, and reasoning) and responds in real time. It supports text, markdown, threads, reactions, file attachments, typing indicators, and more.
+Hermes Agent integrates with [Chatto](https://github.com/chattocorp/chatto), a self-hosted team chat server. The adapter uses the [chattolib](https://github.com/chattocorp/chattolib) library for all API interactions, including WebSocket realtime connections for inbound message delivery and REST API calls for outbound messages. It processes messages through the Hermes Agent pipeline (including tool use, memory, and reasoning) and responds in real time. It supports text, markdown, threads, reactions, file attachments, typing indicators, and more.
 
-No external Python packages are required beyond `websockets`, which is bundled with Hermes. The adapter includes a pure-stdlib protobuf codec — no `protobuf` library needed.
+The only external dependency is `chattolib[realtime]>=0.4.19`.
 
 Before setup, here's the part most people want to know: how Hermes behaves once it's in your Chatto instance.
 
@@ -89,7 +89,7 @@ The plugin directory should contain:
 ```
 ~/.hermes/plugins/platforms/chatto/
 ├── __init__.py
-├── adapter.py          # Main adapter (WebSocket + ConnectRPC)
+├── adapter.py          # Main adapter (uses chattolib)
 ├── plugin.yaml         # Plugin manifest (env var definitions)
 └── test_adapter.py     # Unit tests
 ```
@@ -184,20 +184,19 @@ You can run `hermes gateway` in the background or as a systemd service for persi
 
 ## Features
 
-### WebSocket Realtime Protocol
+### Realtime Connection
 
-The adapter maintains a persistent WebSocket connection to `/api/realtime` on the Chatto server using the binary protobuf realtime protocol (protocol v1). Inbound events — including room messages, mention notifications, and DM notifications — are decoded from protobuf frames in real time.
+The adapter uses chattolib to maintain a persistent WebSocket connection to the Chatto server for realtime event delivery. Inbound events — including room messages, mention notifications, and DM notifications — are handled through chattolib's event streaming API.
 
-Key protocol details:
+Key features:
 
-- **Client hello** — on connect, the adapter sends a `RealtimeClientHello` with protocol version 1 and a bearer token for authentication.
-- **Subscribe events** — after hello, the adapter subscribes to room timeline events for all watched rooms. A resume cursor is used to avoid replaying old messages after reconnection.
-- **Heartbeat** — the adapter sends ping frames every 30 seconds and expects pong responses. Missed heartbeats trigger a reconnect.
-- **Auto-reconnect** — if the WebSocket drops, the adapter reconnects with exponential backoff (1s → 30s max) and resumes from the last cursor.
+- **Automatic connection management** — chattolib handles authentication, reconnection, and session resilience.
+- **Event streaming** — all realtime events are processed through chattolib's unified event API.
+- **Auto-reconnect** — chattolib automatically reconnects with exponential backoff and resumes from the last cursor.
 
-### ConnectRPC JSON API (Outbound)
+### REST API (Outbound)
 
-All outbound actions — sending messages, reactions, typing indicators, file uploads, etc. — use the Chatto ConnectRPC JSON API over HTTP POST. The adapter handles bearer token authentication and automatic re-login on 401 responses.
+All outbound actions — sending messages, reactions, typing indicators, file uploads, etc. — use chattolib's high-level API methods, which handle authentication and error recovery automatically.
 
 ### Markdown Support
 
@@ -219,11 +218,11 @@ The adapter converts Unicode emoji to Chatto shortcode names internally (e.g., `
 
 ### Message Editing and Deletion
 
-The adapter supports editing existing messages (via `UpdateMessage`) and deleting them (via `DeleteMessage`). This is used for updating processing indicators and can be used by the agent to correct or retract messages.
+The adapter supports editing existing messages (via chattolib's `update_message`) and deleting them (via chattolib's `delete_message`). This is used for updating processing indicators and can be used by the agent to correct or retract messages.
 
 ### Typing Indicators
 
-The adapter broadcasts persistent typing indicators to rooms while the agent is working. This uses the `UpdateTypingIndicator` RPC endpoint and runs as a background task per room, refreshing the indicator until the response is sent.
+The adapter broadcasts persistent typing indicators to rooms while the agent is working. This uses chattolib's `update_typing_indicator` method and runs as a background task per room, refreshing the indicator until the response is sent.
 
 ### Message Batching and Splitting
 
@@ -232,11 +231,11 @@ The adapter broadcasts persistent typing indicators to rooms while the agent is
 
 ### Chunked File / Attachment Upload
 
-File attachments are uploaded via the Chatto chunked asset upload API:
+File attachments are uploaded via chattolib's chunked upload API:
 
-1. `CreateUpload` — initiates an upload session
-2. `UploadChunk` — uploads the file in 256 KB chunks
-3. `CompleteUpload` — finalizes the upload and attaches it to the message
+1. `create_upload` — initiates an upload session
+2. `upload_chunk` — uploads the file in 256 KB chunks
+3. `complete_upload` — finalizes the upload and attaches it to the message
 
 This supports files of any size, streamed in chunks to avoid memory issues.
 
@@ -410,6 +409,5 @@ For more information on securing your Hermes Agent deployment, see the [Security
 ## Notes
 
 - **Self-hosted friendly**: Works with any self-hosted Chatto instance. No cloud account or subscription required.
-- **No extra dependencies**: The adapter uses `websockets` (bundled with Hermes) and a pure-stdlib protobuf codec. No `protobuf` library or other external packages needed.
-- **Pure stdlib protobuf**: The adapter implements just enough of the protobuf binary format to encode/decode Chatto realtime frames — no protoc compilation step, no generated code.
+- **Minimal dependencies**: Only requires `chattolib[realtime]>=0.4.19`.
 - **Resume cursor support**: On reconnect, the adapter resumes from the last event cursor, so no messages are lost or replayed during transient disconnects.

+ 5 - 8
README.md

@@ -70,8 +70,8 @@ gateway:
 
 ## Features
 
-- **WebSocket realtime** — binary protobuf codec for Chatto's realtime protocol (no protobuf library needed)
-- **ConnectRPC REST API** — JSON over HTTP for outbound messages, room discovery, user lookup
+- **Realtime via chattolib** — uses the chattolib library for WebSocket realtime connections
+- **REST API via chattolib** — uses chattolib's high-level API for all outbound operations
 - **Thread support** — `GetThreadEvents` for thread replies, auto-thread creation, proper `threadRootEventId` handling
 - **DM support** — DMs always get a response, no threading in DM rooms
 - **Mention filtering** — `require_mention` (default true) with `free_response_channels` for no-tag rooms
@@ -82,16 +82,13 @@ gateway:
 
 ## How It Works
 
-The adapter connects to Chatto via two channels:
+The adapter uses the chattolib library to connect to Chatto, which handles both WebSocket realtime connections for inbound events and REST API calls for outbound operations.
 
-1. **WebSocket** (`/api/realtime`) — receives realtime events as binary protobuf frames
-2. **ConnectRPC REST** (`/api/connect/`) — sends messages, fetches room events, joins rooms, manages presence
-
-When a message is received, the WebSocket frame is decoded, the message body is fetched via REST, dispatched to the Hermes agent, and the response is sent back via `CreateMessage` with proper threading.
+When a message is received, chattolib processes the event, the message is dispatched to the Hermes agent, and the response is sent back via chattolib's messaging API with proper threading.
 
 ## Tested Against
 
-Chatto v0.4.19. Protocol version 1 (binary protobuf over WebSocket).
+Chatto v0.4.19 with chattolib >=0.4.19.
 
 ## License