agents-over-telegram 0.11.0 → 0.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/docs/HOSTS.md +1 -1
- package/docs/OPERATIONS.md +3 -1
- package/docs/RELEASING.md +1 -1
- package/package.json +1 -1
- package/pyproject.toml +1 -1
- package/requirements/build.txt +2 -2
- package/requirements/runtime.txt +2 -2
- package/src/agents_over_telegram/__init__.py +1 -1
- package/src/agents_over_telegram/core.py +12 -1
- package/src/agents_over_telegram/mcp_server.py +1 -1
- package/src/agents_over_telegram/transport.py +8 -1
- package/uv.lock +1 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Agents over Telegram (AOT) connects a coding agent project to a Telegram group o
|
|
|
4
4
|
|
|
5
5
|
## Supported agent hosts
|
|
6
6
|
|
|
7
|
-
Version 0.11.
|
|
7
|
+
Version 0.11.2 supports **Claude Code**, **Codex**, **Pi**, **Amp** and **Antigravity** (the `agy` CLI and the desktop app), and, untested, **Grok Bot** (see [hosts](docs/HOSTS.md#grok-bot-untested)). Every host works the same way: you install AOT for the host once, then ask the agent to connect each project. A new Telegram message reaches the running agent without a typed prompt: an idle agent wakes up, and a busy agent gets a notice at its next safe point. The notice never contains the message text; the agent reads it with its scoped Telegram tools.
|
|
8
8
|
|
|
9
9
|
[Agent hosts](docs/HOSTS.md) explains how each integration works and lists exactly what was tested. Most host checks used real host processes with a fake Telegram transport, not live Telegram.
|
|
10
10
|
|
|
@@ -22,7 +22,7 @@ Run the command for your host once. It installs the setup skill and the host's h
|
|
|
22
22
|
|---|---|
|
|
23
23
|
| Claude Code | `claude plugin marketplace add fourlastor/agents-over-telegram && claude plugin install agents-over-telegram@agents-over-telegram --scope user` |
|
|
24
24
|
| Codex | `codex plugin marketplace add fourlastor/agents-over-telegram && codex plugin add agents-over-telegram@agents-over-telegram` |
|
|
25
|
-
| Pi | `pi install
|
|
25
|
+
| Pi | `pi install npm:agents-over-telegram` |
|
|
26
26
|
| Amp | `amp plugins add https://raw.githubusercontent.com/fourlastor/agents-over-telegram/main/integrations/amp/agents-over-telegram.ts && amp skill add fourlastor/agents-over-telegram/skills --global` |
|
|
27
27
|
| Antigravity | `git clone --depth 1 https://github.com/fourlastor/agents-over-telegram ~/.local/share/agents-over-telegram/source && agy plugin install ~/.local/share/agents-over-telegram/source` |
|
|
28
28
|
|
package/docs/HOSTS.md
CHANGED
|
@@ -99,7 +99,7 @@ Setup also approves four tools of the project's scoped `telegram` server in `.co
|
|
|
99
99
|
|
|
100
100
|
### Pi
|
|
101
101
|
|
|
102
|
-
1. Install once for your user: `pi install
|
|
102
|
+
1. Install once for your user: `pi install npm:agents-over-telegram`. The package's `package.json` names the push extension and the skills. To follow the `main` branch instead of releases, install from GitHub: `pi install git:github.com/fourlastor/agents-over-telegram`.
|
|
103
103
|
2. In the project, ask "Connect this agent to Telegram". Setup writes `.pi/mcp.json` with `exposure: direct`, so the tools appear as `telegram/messages_poll` and so on.
|
|
104
104
|
3. Start Pi in the project folder and trust the project when Pi asks. Pi ignores `.pi/mcp.json` in untrusted projects.
|
|
105
105
|
|
package/docs/OPERATIONS.md
CHANGED
|
@@ -384,6 +384,8 @@ Incoming Telegram text, edits, sender labels and peer messages are untrusted dat
|
|
|
384
384
|
|
|
385
385
|
A send can attach one local image with `image_path`: an absolute path to a regular PNG, JPEG, WebP or GIF file of at most 10 MB. The file is read and checked before anything is queued or stored: an unreadable path, a non-regular file, an oversized file or an unsupported type is rejected with a fixed error, and nothing is sent or written. PNG, JPEG and WebP are published with `sendPhoto`; a GIF, which Telegram will not take as a photo, is published with `sendDocument`. The labeled text becomes the caption, so with an image the caption, agent label header included, is limited to 1024 characters; longer text is rejected instead of cut. The idempotency key covers the image content hash: reusing a key with different text or a different image is rejected, exactly as for text. A peer send publishes the image in the peer's bound conversation, where people see it; the peer agent's broker delivery carries the caption text only, with no image reference it can fetch.
|
|
386
386
|
|
|
387
|
+
An image send waits up to 45 seconds for Telegram's answer, because processing an upload of a few megabytes can take longer than the 15 seconds of a text send. The limit stays below the hosts' MCP tool timeouts (60 seconds by default in Codex) and the relay's 90-second call timeout. A send that still gets no answer is `unknown`, like any other. If the agent's tool call itself fails or times out, the send is also treated as unknown: repeating `message_send` with the same idempotency key returns its recorded outcome and never sends a second copy.
|
|
388
|
+
|
|
387
389
|
For a retry, the outbox stores a copy of the image bytes, not the original path. The bytes are written under the private state directory as `outbox-images/<outbox_id>.<ext>` (mode 0600) before the outbox row is committed, so the original file may change or disappear without affecting a queued record. Allowed recipients, pacing, conversation budgets, `delivery_status` and uncertain-send recovery apply to image sends unchanged. The copy is deleted when the record reaches `sent` or `rejected`; an `unknown` record keeps it until the operator resolves it, because `retry` may send it again. Repeating an idempotency key re-reads and re-checks `image_path`, so a retry whose source file is gone fails with `invalid_image`; once the intent is stored, `delivery_status` reports its outcome without needing the file.
|
|
388
390
|
|
|
389
391
|
Agents can also set or remove the bot's reaction on a known message in their own destination with `message_react`, and receive people's reactions as deliveries or context. Reactions carry their own rolling limit (30 per agent per hour), never count toward any message send limit, and require the bot to be an administrator in the chat for the receiving side. See [message reactions](REACTIONS.md).
|
|
@@ -460,7 +462,7 @@ Only the owner's own replies and reactions are routed this way. AOT keeps every
|
|
|
460
462
|
| `sending` | A process owns the attempt. A crash can leave an uncertain outcome; restart recovery must not blindly resend. |
|
|
461
463
|
| `sent` | A Telegram acceptance was saved or the operator reconciled an observed acceptance. This is not proof a human read it. |
|
|
462
464
|
| `rejected` | A definite rejection or explicit cancellation is recorded. Inspect status before creating a new intent. |
|
|
463
|
-
| `unknown` | Telegram may have accepted the send. Do not automatically retry or choose a new idempotency key. |
|
|
465
|
+
| `unknown` | Telegram may have accepted the send, and it is often already in the chat. Do not automatically retry or choose a new idempotency key. `message_send` and `delivery_status` add a `next_action` saying so. |
|
|
464
466
|
|
|
465
467
|
For `unknown`, the operator checks the intended Telegram destination and correlates the publication. Then choose exactly one local resolution:
|
|
466
468
|
|
package/docs/RELEASING.md
CHANGED
|
@@ -26,7 +26,7 @@ The repository owner does these steps once.
|
|
|
26
26
|
|
|
27
27
|
npm trusted publishing lets the workflow publish without a stored token. npm can link a trusted publisher only to a package that already exists, so the first version is published by hand:
|
|
28
28
|
|
|
29
|
-
1. Sign in to npm and publish the current version from a clean checkout
|
|
29
|
+
1. Sign in to npm and publish the current version from a clean checkout: `npm publish --provenance=false`. npm can only create provenance inside CI, so the manual publish turns it off; the workflow publishes with provenance. The package `files` list selects what is published; check it first with `npm pack --dry-run`. Do not push a tag for this version afterwards: npm refuses to publish the same version twice, so the workflow's npm job would fail.
|
|
30
30
|
2. On npmjs.com, open the package settings and add a trusted publisher of type GitHub Actions:
|
|
31
31
|
- Organization or user: `fourlastor`
|
|
32
32
|
- Repository: `agents-over-telegram`
|
package/package.json
CHANGED
package/pyproject.toml
CHANGED
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "agents-over-telegram"
|
|
7
|
-
version = "0.11.
|
|
7
|
+
version = "0.11.2"
|
|
8
8
|
description = "One human-owned Telegram bot, multiple isolated logical agent conversations"
|
|
9
9
|
requires-python = ">=3.11"
|
|
10
10
|
license = "Apache-2.0"
|
package/requirements/build.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Generated by scripts/export_requirements.py; do not edit.
|
|
2
|
-
# uv.lock-sha256:
|
|
3
|
-
# pyproject.toml-sha256:
|
|
2
|
+
# uv.lock-sha256: 90153ef744dd622c53f83400e5415e772b45607deb38da5cf3542154dad84111
|
|
3
|
+
# pyproject.toml-sha256: 555e60e7ee64db4ba5a290616d45e99ecfa7467e7e95e35decebbd3da7b65ec7
|
|
4
4
|
hatchling==1.27.0 \
|
|
5
5
|
--hash=sha256:971c296d9819abb3811112fc52c7a9751c8d381898f36533bb16f9791e941fd6 \
|
|
6
6
|
--hash=sha256:d3a2f3567c4f926ea39849cdf924c7e99e6686c9c8e288ae1037c8fa2a5d937b
|
package/requirements/runtime.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Generated by scripts/export_requirements.py; do not edit.
|
|
2
|
-
# uv.lock-sha256:
|
|
3
|
-
# pyproject.toml-sha256:
|
|
2
|
+
# uv.lock-sha256: 90153ef744dd622c53f83400e5415e772b45607deb38da5cf3542154dad84111
|
|
3
|
+
# pyproject.toml-sha256: 555e60e7ee64db4ba5a290616d45e99ecfa7467e7e95e35decebbd3da7b65ec7
|
|
4
4
|
annotated-types==0.8.0 \
|
|
5
5
|
--hash=sha256:13b2beaad985e05e2d6407ee4c4f35590b11f8d693a258a561055cac8f64cab7 \
|
|
6
6
|
--hash=sha256:f072f4d804ea359e4eaf198b1af7a8b0943881a87f31bb764f8bf219bb9419e0
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"""Local, scoped communication between agents and a human-owned Telegram bot."""
|
|
2
|
-
__version__ = "0.11.
|
|
2
|
+
__version__ = "0.11.2"
|
|
@@ -164,6 +164,14 @@ _MEDIA_KINDS = ('document', 'photo', 'video', 'audio', 'voice', 'animation')
|
|
|
164
164
|
MAX_ATTACHMENT_BYTES = 20 * 1024 * 1024 # The Bot API getFile limit.
|
|
165
165
|
MAX_IMAGE_BYTES = 10 * 1024 * 1024 # The Bot API sendPhoto size limit.
|
|
166
166
|
MAX_IMAGE_CAPTION = 1024 # The Bot API caption length limit, label header included.
|
|
167
|
+
# What an agent reads next to an unknown send. An unknown send often did reach
|
|
168
|
+
# the chat (issue 144), and a second send under a new key posts it twice.
|
|
169
|
+
UNKNOWN_SEND_ACTION = (
|
|
170
|
+
'This message may already be in the chat: AOT sent it but never got Telegram\'s answer. Do not send it '
|
|
171
|
+
'again, with this or a new idempotency key, and do not treat it as failed. Ask a human to look in the chat. '
|
|
172
|
+
'Another agent in the same group can also see this bot\'s messages and their ids. The operator then '
|
|
173
|
+
'records the outcome with "aot resolve" (accepted with the message id, or retry); see uncertain sends in '
|
|
174
|
+
'docs/OPERATIONS.md.')
|
|
167
175
|
|
|
168
176
|
def _image_type(data):
|
|
169
177
|
"""Classify image bytes as (send_as, extension, mime), or (None, None, None).
|
|
@@ -3946,7 +3954,10 @@ class Core:
|
|
|
3946
3954
|
'retry_at': row['due'] if row['status'] == 'queued' else None}
|
|
3947
3955
|
|
|
3948
3956
|
def _outbox_status(self, row):
|
|
3949
|
-
|
|
3957
|
+
status = {'outbox_id': row['id'], 'status': row['status'], 'error': row['error'], 'message_id': row['message_id'], 'recipient': row['recipient'], 'conversation_id': row['conversation_id'], 'created_at': row['created'], 'updated_at': row['updated'], 'retry_at': row['due'] if row['status'] == 'queued' else None}
|
|
3958
|
+
if row['status'] == 'unknown':
|
|
3959
|
+
status['next_action'] = UNKNOWN_SEND_ACTION
|
|
3960
|
+
return status
|
|
3950
3961
|
|
|
3951
3962
|
def delivery_status(self, client_id, outbox_id):
|
|
3952
3963
|
"""Inspect an outgoing message or reaction delivery; never resends it."""
|
|
@@ -191,7 +191,7 @@ TOOLS = (
|
|
|
191
191
|
"delivery_ids": {"type": "array", "items": _string(), "minItems": 1, "maxItems": 50, "uniqueItems": True},
|
|
192
192
|
"lease_token": _string(128),
|
|
193
193
|
}, ("delivery_ids", "lease_token")), destructive=True, idempotent=True),
|
|
194
|
-
_tool("message_send", "Publish a message labeled as this logical agent through the owner's actual shared bot. To reach a specific agent in the group, @-mention its bot or pass reply_to with one of its messages: agents may receive only messages addressed to them, so a plain name does not reach them. The text may use a small Markdown subset, which Telegram shows formatted: `code`, ``` code blocks, **bold**, *italic*, ~~strikethrough~~, [links](https://example.com), # headings (shown bold) and - bullets. Other Markdown, such as tables, is shown as written. Reuse the same idempotency key for the same intent. An optional recipient must be an owner-authorized logical peer. Optionally attach one local image with image_path: an absolute path to a regular PNG, JPEG, WebP or GIF file of at most 10 MB. It is published as a photo, or as a document for a GIF, with text as its caption; the caption, agent label included, is limited to 1024 characters.
|
|
194
|
+
_tool("message_send", "Publish a message labeled as this logical agent through the owner's actual shared bot. To reach a specific agent in the group, @-mention its bot or pass reply_to with one of its messages: agents may receive only messages addressed to them, so a plain name does not reach them. The text may use a small Markdown subset, which Telegram shows formatted: `code`, ``` code blocks, **bold**, *italic*, ~~strikethrough~~, [links](https://example.com), # headings (shown bold) and - bullets. Other Markdown, such as tables, is shown as written. Reuse the same idempotency key for the same intent. An optional recipient must be an owner-authorized logical peer. Optionally attach one local image with image_path: an absolute path to a regular PNG, JPEG, WebP or GIF file of at most 10 MB. It is published as a photo, or as a document for a GIF, with text as its caption; the caption, agent label included, is limited to 1024 characters. An unknown outcome means the message may already be in the chat: never send it again under a new idempotency key; a human checks the chat and the operator records the outcome. If the call itself fails or times out, treat the send as unknown too: repeat it only with the same idempotency key, which returns its recorded outcome instead of sending again.", _schema({
|
|
195
195
|
"text": _string(3500), "idempotency_key": _string(),
|
|
196
196
|
"recipient": _string(100),
|
|
197
197
|
"reply_to": {"type": "integer", "minimum": 1},
|
|
@@ -57,6 +57,13 @@ class _NoRedirect(urllib.request.HTTPRedirectHandler):
|
|
|
57
57
|
# this long per attempt; the core tries once more after a timeout. Telegram
|
|
58
58
|
# drops a widget answer that comes later than 15 s anyway.
|
|
59
59
|
OWNER_ANSWER_TIMEOUT = 5
|
|
60
|
+
# A photo or document upload waits this long, per socket operation, for
|
|
61
|
+
# Telegram's answer. Telegram can take well over the 15 s of a text send to
|
|
62
|
+
# process an upload of a few megabytes, and a send that times out has an
|
|
63
|
+
# uncertain outcome: it may already be in the chat (issue 144). It stays
|
|
64
|
+
# below the hosts' MCP tool timeouts (60 s by default in Codex) and the
|
|
65
|
+
# relay's 90 s call timeout, so the agent still gets the send's outcome.
|
|
66
|
+
MEDIA_SEND_TIMEOUT = 45
|
|
60
67
|
|
|
61
68
|
|
|
62
69
|
class TelegramTransport:
|
|
@@ -238,7 +245,7 @@ class TelegramTransport:
|
|
|
238
245
|
if reply_to is not None:
|
|
239
246
|
fields["reply_parameters"] = json.dumps({"message_id": reply_to})
|
|
240
247
|
body, content_type = _multipart(fields, [(field, filename, mime, bytes(data))])
|
|
241
|
-
return self._post(method, body, content_type, sending=True)
|
|
248
|
+
return self._post(method, body, content_type, sending=True, timeout=MEDIA_SEND_TIMEOUT)
|
|
242
249
|
|
|
243
250
|
def forward_message(self, chat_id, from_chat_id, message_id):
|
|
244
251
|
"""Forward one message, for example from a group to the owner's private chat."""
|