agents-over-telegram 0.11.3 → 0.11.5
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 +1 -1
- package/docs/HOSTS.md +2 -0
- package/docs/OPERATIONS.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 +17 -1
- package/src/agents_over_telegram/net.py +13 -0
- package/src/agents_over_telegram/transport.py +9 -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.5 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
|
|
package/docs/HOSTS.md
CHANGED
|
@@ -63,6 +63,8 @@ This needs the plugin to be loaded in the session. When the plugin is installed
|
|
|
63
63
|
- The waiter stops when Claude Code exits. It also stops quietly 23 hours after the last turn end. A session that stays idle for longer than that stops waking up until someone sends it a prompt.
|
|
64
64
|
- With [keep-alive](OPERATIONS.md#keep-an-idle-claude-code-session-listening) on, the waiter instead wakes the session once when its 23 hours end. The notice says that there are no new messages and asks the model to end the turn. That turn end starts a new waiter. Only the session's current waiter does this, and only while Claude Code still runs. A waiter that handed over to a newer one, or whose host exited, stays quiet.
|
|
65
65
|
- Each waiter writes one line to `wake.log` in the state directory when it starts and when it exits, with the reason: `woken`, `keep_alive_refresh`, `replaced`, `host_gone`, `parent_changed`, `runtime_moved`, `watch_ended:<reason>`, `error:<type>` or `signal:<name>` (for `SIGTERM`, `SIGHUP` and `SIGINT`). A waiter killed with `SIGKILL` leaves a start line with no exit line. The file is private and holds no message text. Past 256 KB it moves to `wake.log.1`. Read it when a session stopped waking up.
|
|
66
|
+
- Only the session working in the project folder (or a subfolder) is that project's agent. Claude Code gives a worktree session, or any session it starts in another folder, the parent project's `CLAUDE_PROJECT_DIR`. The launcher compares that with the `cwd` in the hook input and stays silent when the session works outside the project, or in a separate git checkout inside it, such as a Claude Code CLI worktree in `<project>/.claude/worktrees/`. Before 0.11.4 such a session ran its own waiter for the parent's client and could take the parent's wake. `AOT_PROJECT_DIR` set explicitly still wins.
|
|
67
|
+
- Do not start `aot watch` with the agent's Monitor tool as an extra waker. Those commands run inside the Claude Code sandbox, which cannot write the AOT state folder, so `aot watch` fails with `storage_error`. The `asyncRewake` hook runs outside the sandbox and is the wake path.
|
|
66
68
|
- The launcher passes exit status 2 on only when the runtime printed a real notice. A runtime that predates `aot wake` fails with status 2 and a usage message, and that must not wake the session.
|
|
67
69
|
|
|
68
70
|
The plugin also declares a monitor that announces new messages. Claude Code starts plugin monitors only in **interactive** terminal sessions. They do not start in `-p` mode, and they did not start in the Claude Code desktop app. The `asyncRewake` hook does run in the desktop app.
|
package/docs/OPERATIONS.md
CHANGED
|
@@ -458,7 +458,7 @@ Only the owner's own replies and reactions are routed this way. AOT keeps every
|
|
|
458
458
|
|
|
459
459
|
| Outcome | Meaning and action |
|
|
460
460
|
| --- | --- |
|
|
461
|
-
| `queued` | Intent is durable, but has not been confirmed as sent. Inspect the reason and retry/backoff state. |
|
|
461
|
+
| `queued` | Intent is durable, but has not been confirmed as sent. Inspect the reason and retry/backoff state. With error `not_connected`, the connection to Telegram failed before the request was sent (for example, the network was not back yet after sleep), so nothing reached the chat; AOT tries again after 30 seconds. |
|
|
462
462
|
| `sending` | A process owns the attempt. A crash can leave an uncertain outcome; restart recovery must not blindly resend. |
|
|
463
463
|
| `sent` | A Telegram acceptance was saved or the operator reconciled an observed acceptance. This is not proof a human read it. |
|
|
464
464
|
| `rejected` | A definite rejection or explicit cancellation is recorded. Inspect status before creating a new intent. |
|
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.5"
|
|
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: 1d1117f7e8f6579e9e6066fc3ebbfb683b1e0a2a86f6eff08c7f9e730e13a453
|
|
3
|
+
# pyproject.toml-sha256: 609cff05b658cb850e4c7ded46c8d594c1da6da0bff770047baee8a47f8c04a7
|
|
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: 1d1117f7e8f6579e9e6066fc3ebbfb683b1e0a2a86f6eff08c7f9e730e13a453
|
|
3
|
+
# pyproject.toml-sha256: 609cff05b658cb850e4c7ded46c8d594c1da6da0bff770047baee8a47f8c04a7
|
|
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.5"
|
|
@@ -21,7 +21,7 @@ import time
|
|
|
21
21
|
from typing import Any
|
|
22
22
|
|
|
23
23
|
from . import compat
|
|
24
|
-
from .transport import TransportError, UnknownSend
|
|
24
|
+
from .transport import NOT_CONNECTED, TransportError, UnknownSend
|
|
25
25
|
from .credentials import CredentialError, private_directory
|
|
26
26
|
from . import judge as judge_module
|
|
27
27
|
from . import markdown
|
|
@@ -161,6 +161,13 @@ def _choice_buttons(notify_id, choices):
|
|
|
161
161
|
|
|
162
162
|
|
|
163
163
|
_MEDIA_KINDS = ('document', 'photo', 'video', 'audio', 'voice', 'animation')
|
|
164
|
+
# A send whose connection failed before the request went out waits this long
|
|
165
|
+
# before the next attempt (issue 150): typically the network is still coming
|
|
166
|
+
# back after sleep.
|
|
167
|
+
NOT_CONNECTED_RETRY = 30
|
|
168
|
+
NOT_CONNECTED_ACTION = (
|
|
169
|
+
'Nothing reached Telegram: the connection failed before the message was sent. AOT sends it again by '
|
|
170
|
+
'itself. Do not send it again; check delivery_status later.')
|
|
164
171
|
MAX_ATTACHMENT_BYTES = 20 * 1024 * 1024 # The Bot API getFile limit.
|
|
165
172
|
MAX_IMAGE_BYTES = 10 * 1024 * 1024 # The Bot API sendPhoto size limit.
|
|
166
173
|
MAX_IMAGE_CAPTION = 1024 # The Bot API caption length limit, label header included.
|
|
@@ -3957,6 +3964,8 @@ class Core:
|
|
|
3957
3964
|
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
3965
|
if row['status'] == 'unknown':
|
|
3959
3966
|
status['next_action'] = UNKNOWN_SEND_ACTION
|
|
3967
|
+
elif row['status'] == 'queued' and row['error'] == NOT_CONNECTED:
|
|
3968
|
+
status['next_action'] = NOT_CONNECTED_ACTION
|
|
3960
3969
|
return status
|
|
3961
3970
|
|
|
3962
3971
|
def delivery_status(self, client_id, outbox_id):
|
|
@@ -4061,6 +4070,9 @@ class Core:
|
|
|
4061
4070
|
# Nothing was sent, so the message waits for the new chat.
|
|
4062
4071
|
status, error, message_id, due = 'queued', 'group_migrated', None, self.clock()
|
|
4063
4072
|
migrated_to = exc.migrate_to_chat_id
|
|
4073
|
+
elif exc.code == NOT_CONNECTED:
|
|
4074
|
+
# Nothing reached Telegram, so a later attempt cannot duplicate it.
|
|
4075
|
+
status, error, message_id, due = 'queued', NOT_CONNECTED, None, self.clock() + NOT_CONNECTED_RETRY
|
|
4064
4076
|
elif isinstance(exc.code, int) and 400 <= exc.code < 500:
|
|
4065
4077
|
status, error, message_id, due = 'rejected', 'telegram_rejected', None, self.clock()
|
|
4066
4078
|
else:
|
|
@@ -4129,6 +4141,8 @@ class Core:
|
|
|
4129
4141
|
# deactivated group, so this reaction cannot follow them.
|
|
4130
4142
|
status, error, due = 'rejected', 'group_migrated', self.clock()
|
|
4131
4143
|
migrated_to = exc.migrate_to_chat_id
|
|
4144
|
+
elif exc.code == NOT_CONNECTED:
|
|
4145
|
+
status, error, due = 'queued', NOT_CONNECTED, self.clock() + NOT_CONNECTED_RETRY
|
|
4132
4146
|
elif isinstance(exc.code, int) and 400 <= exc.code < 500:
|
|
4133
4147
|
status, error, due = 'rejected', 'telegram_rejected', self.clock()
|
|
4134
4148
|
else:
|
|
@@ -4202,6 +4216,8 @@ class Core:
|
|
|
4202
4216
|
wait = exc.retry_after if isinstance(exc.retry_after, (int, float)) and not isinstance(exc.retry_after, bool) and math.isfinite(exc.retry_after) and exc.retry_after > 0 else 60
|
|
4203
4217
|
due = self.clock() + min(wait, 86400)
|
|
4204
4218
|
status, error = 'queued', 'rate_limited'
|
|
4219
|
+
elif exc.code == NOT_CONNECTED and step != 'forward':
|
|
4220
|
+
status, error, due = 'queued', NOT_CONNECTED, self.clock() + NOT_CONNECTED_RETRY
|
|
4205
4221
|
elif step == 'forward' and isinstance(exc.code, int) and 400 <= exc.code < 500:
|
|
4206
4222
|
# The owner already has the text; only the copy of the
|
|
4207
4223
|
# group message failed, for example because it was deleted.
|
|
@@ -117,11 +117,24 @@ def racing_connection(address, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, source_ad
|
|
|
117
117
|
return winner
|
|
118
118
|
|
|
119
119
|
|
|
120
|
+
class NotConnected(OSError):
|
|
121
|
+
"""The TCP connect or TLS handshake failed: no request byte was sent."""
|
|
122
|
+
|
|
123
|
+
|
|
120
124
|
class _RacingHTTPSConnection(http.client.HTTPSConnection):
|
|
121
125
|
def __init__(self, *args, **kwargs):
|
|
122
126
|
super().__init__(*args, **kwargs)
|
|
123
127
|
self._create_connection = racing_connection
|
|
124
128
|
|
|
129
|
+
def connect(self):
|
|
130
|
+
# http.client sends the request only after connect returns. A failure
|
|
131
|
+
# here (no network after sleep, DNS, refused, TLS handshake) means
|
|
132
|
+
# Telegram never received this request, so a send may safely retry.
|
|
133
|
+
try:
|
|
134
|
+
super().connect()
|
|
135
|
+
except Exception as error:
|
|
136
|
+
raise NotConnected(str(error)) from error
|
|
137
|
+
|
|
125
138
|
|
|
126
139
|
class RacingHTTPSHandler(urllib.request.HTTPSHandler):
|
|
127
140
|
"""Replaces urllib's HTTPS handler; everything but the connect is unchanged."""
|
|
@@ -15,7 +15,7 @@ import urllib.error
|
|
|
15
15
|
import urllib.request
|
|
16
16
|
|
|
17
17
|
from . import compat
|
|
18
|
-
from .net import RacingHTTPSHandler
|
|
18
|
+
from .net import NotConnected, RacingHTTPSHandler
|
|
19
19
|
from .credentials import load_token, private_directory, read_private_json, validate_token, write_private_json
|
|
20
20
|
|
|
21
21
|
|
|
@@ -43,6 +43,10 @@ def _migrate_to(parameters):
|
|
|
43
43
|
return target if type(target) is int and target < 0 else None
|
|
44
44
|
|
|
45
45
|
|
|
46
|
+
# The connection to Telegram failed before the request was sent (issue 150).
|
|
47
|
+
NOT_CONNECTED = "not_connected"
|
|
48
|
+
|
|
49
|
+
|
|
46
50
|
class UnknownSend(TransportError):
|
|
47
51
|
def __init__(self, code="unknown_send", retry_after=None):
|
|
48
52
|
super().__init__(code, retry_after)
|
|
@@ -133,6 +137,10 @@ class TelegramTransport:
|
|
|
133
137
|
except TransportError:
|
|
134
138
|
raise
|
|
135
139
|
except Exception as error:
|
|
140
|
+
if sending and (isinstance(error, NotConnected)
|
|
141
|
+
or isinstance(getattr(error, "reason", None), NotConnected)):
|
|
142
|
+
# Nothing reached Telegram: a definite failure, even for a send.
|
|
143
|
+
raise TransportError(NOT_CONNECTED) from None
|
|
136
144
|
if sending:
|
|
137
145
|
raise UnknownSend() from None
|
|
138
146
|
# Named apart, so a call that hung until its timeout can be told
|