agents-over-telegram 0.11.0

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.
Files changed (52) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +141 -0
  3. package/docs/BOT_EXCHANGES.md +121 -0
  4. package/docs/COMPATIBILITY.md +110 -0
  5. package/docs/DIRECT_DISPATCH.md +155 -0
  6. package/docs/HOSTS.md +244 -0
  7. package/docs/IMPLEMENTATION_STATUS.md +205 -0
  8. package/docs/LIVE_VALIDATION.md +35 -0
  9. package/docs/MACOS_SERVICE.md +89 -0
  10. package/docs/OPERATIONS.md +568 -0
  11. package/docs/REACTIONS.md +51 -0
  12. package/docs/RELAY.md +115 -0
  13. package/docs/RELEASING.md +45 -0
  14. package/docs/schemas/mcp.schema.json +120 -0
  15. package/docs/schemas/sources.json +9 -0
  16. package/integrations/pi/agents-over-telegram.ts +154 -0
  17. package/package.json +41 -0
  18. package/pyproject.toml +37 -0
  19. package/requirements/build.txt +18 -0
  20. package/requirements/runtime.txt +532 -0
  21. package/scripts/bootstrap_runtime.py +402 -0
  22. package/skills/telegram-coordinate/SKILL.md +67 -0
  23. package/skills/telegram-setup/SKILL.md +81 -0
  24. package/src/agents_over_telegram/__init__.py +2 -0
  25. package/src/agents_over_telegram/__main__.py +2 -0
  26. package/src/agents_over_telegram/appserver_client.py +400 -0
  27. package/src/agents_over_telegram/cli.py +851 -0
  28. package/src/agents_over_telegram/codex_trust.py +206 -0
  29. package/src/agents_over_telegram/compat.py +207 -0
  30. package/src/agents_over_telegram/core.py +4253 -0
  31. package/src/agents_over_telegram/credentials.py +108 -0
  32. package/src/agents_over_telegram/demo.py +85 -0
  33. package/src/agents_over_telegram/desktop_bridge.py +537 -0
  34. package/src/agents_over_telegram/desktop_dispatcher.py +680 -0
  35. package/src/agents_over_telegram/dispatcher.py +260 -0
  36. package/src/agents_over_telegram/host_config.py +125 -0
  37. package/src/agents_over_telegram/hosts.py +590 -0
  38. package/src/agents_over_telegram/judge.py +230 -0
  39. package/src/agents_over_telegram/macos_process.py +133 -0
  40. package/src/agents_over_telegram/markdown.py +127 -0
  41. package/src/agents_over_telegram/mcp_server.py +652 -0
  42. package/src/agents_over_telegram/net.py +130 -0
  43. package/src/agents_over_telegram/onboarding.py +719 -0
  44. package/src/agents_over_telegram/push.py +421 -0
  45. package/src/agents_over_telegram/relay.py +380 -0
  46. package/src/agents_over_telegram/relay_api.py +591 -0
  47. package/src/agents_over_telegram/relay_watch.py +171 -0
  48. package/src/agents_over_telegram/serve.py +626 -0
  49. package/src/agents_over_telegram/settings_panel.py +216 -0
  50. package/src/agents_over_telegram/transport.py +720 -0
  51. package/src/agents_over_telegram/webhook.py +219 -0
  52. package/uv.lock +1011 -0
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,141 @@
1
+ # Agents over Telegram
2
+
3
+ Agents over Telegram (AOT) connects a coding agent project to a Telegram group or forum topic. You register **one bot once** and reuse it for many logical agents, each in its own project and conversation. Telegram shows the real shared bot, and each message carries a label that names the logical agent.
4
+
5
+ ## Supported agent hosts
6
+
7
+ Version 0.11.0 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
+
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
+
11
+ ## Before you start
12
+
13
+ - **Linux or macOS.** Windows support is new and only tested in CI so far; see [Windows](docs/OPERATIONS.md#windows).
14
+ - **Python 3.11 or newer** with virtual-environment support. The agent prepares AOT's own runtime from it. uv is optional. On Debian or Ubuntu, install `python3-venv` if your Python does not include it. If Python is missing, see the official [Python downloads](https://www.python.org/downloads/).
15
+ - **A Telegram bot.** Create one with `@BotFather` if you do not have one for AOT yet. Add it to a dedicated group, or to a forum topic. Pairing works in a group or a forum topic only, not in a direct chat with the bot.
16
+
17
+ ## Install AOT for your host (once)
18
+
19
+ Run the command for your host once. It installs the setup skill and the host's hooks, extension or plugin for your user, so every project can use them.
20
+
21
+ | Host | Install command |
22
+ |---|---|
23
+ | Claude Code | `claude plugin marketplace add fourlastor/agents-over-telegram && claude plugin install agents-over-telegram@agents-over-telegram --scope user` |
24
+ | Codex | `codex plugin marketplace add fourlastor/agents-over-telegram && codex plugin add agents-over-telegram@agents-over-telegram` |
25
+ | Pi | `pi install git:github.com/fourlastor/agents-over-telegram` |
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
+ | 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
+
29
+ The Antigravity install works for both the `agy` CLI and the desktop app. In Codex, review and trust the plugin hooks once (the desktop app's hook review, or `/hooks` in the Codex CLI). Codex asks again after every plugin update.
30
+
31
+ ## Connect a project
32
+
33
+ 1. **Open the project and ask the agent "Connect this agent to Telegram".** The agent prepares AOT's runtime and runs setup for this project.
34
+ 2. **The first time on a machine only:** if your bot is not registered here yet, the agent gives you one command to run in your own terminal. It asks for the bot token in a hidden prompt, so the token never passes through the chat.
35
+ 3. **Post the pairing command.** The agent gives you a command such as `/pair@YourBot 1A2B3C4D5E6F`. Post it in the project's group or topic, then tell the agent you posted it. The agent finishes the connection and reports the group it connected to.
36
+ 4. **Ask "Telegram status"** at any time to check the bot and the destination.
37
+
38
+ There is no second confirmation. The pairing code is single-use, expires after ten minutes and is shown only on your machine. When your bot already has connections, only their owner can complete a pairing by posting a code. A code that someone else posts stays pending, and you decide about it in your terminal. When the bot has no connection yet, the first post of the code connects, and the agent shows you where.
39
+
40
+ One project folder is one logical agent: every chat in that folder shares its Telegram identity. Use separate folders for separate agents. Setup writes `.aot-profile.json`, `.aot-runtime.json` and the host's MCP entry into the project. These files hold this machine's paths and the client id, not secrets. Setup adds the files it owns to the repository's local `.git/info/exclude`, and warns when git already tracks one of them.
41
+
42
+ In this README, `aot` means the runtime executable that setup names in the project's `.aot-runtime.json`. It is not a command on `PATH`. From the project folder, you can run it like this:
43
+
44
+ ```sh
45
+ "$(python3 -c 'import json;print(json.load(open(".aot-runtime.json"))["executable"])')" tool messages_poll
46
+ ```
47
+
48
+ For the terminal commands, offline bootstrap and existing-account options, see [local setup](docs/OPERATIONS.md#codex-setup). Host details, such as idle listening in the Codex desktop app, are in [agent hosts](docs/HOSTS.md).
49
+
50
+ ## Updates
51
+
52
+ Update the host install the same way you installed it, then ask the agent to "update Agents over Telegram". The setup skill prepares the new runtime and moves the project to it with `setup --prepare-only`. The project keeps its client, its pairing and its allowed senders. In Claude Code the MCP server and hooks switch to the new runtime without a restart; see the [setup skill](skills/telegram-setup/SKILL.md#update-a-project-to-a-newer-version).
53
+
54
+ ## What an agent can do
55
+
56
+ The agent uses these MCP tools. Each tool works only on the agent's own connection.
57
+
58
+ | Tool | What it does |
59
+ |---|---|
60
+ | `messages_poll`, `messages_ack` | Read new deliveries, then confirm them after handling. |
61
+ | `message_send` | Send a labeled message. It can reply to a message (`reply_to`) and attach one image (`image_path`: PNG, JPEG, WebP or GIF, up to 10 MB). |
62
+ | `message_react` | Set or remove the bot's emoji reaction on a message in the agent's own group or topic. |
63
+ | `messages_history` | Read captured messages from the last 24 hours. |
64
+ | `attachment_fetch` | Download a file from an incoming message into private local state. |
65
+ | `owner_notify` | Send a short private notice to the owner. It is off until the owner turns it on. |
66
+ | `delivery_status` | Check the outcome of a send, reaction or owner notice without sending again. |
67
+ | `connection_status`, `connections_list`, `accounts_status` | Show the bot, the destination, the pause state and the next step. |
68
+ | `connection_begin`, `connection_pause`, `connection_disconnect` | Start a pairing, pause or resume, or revoke this agent's connection. |
69
+
70
+ `message_send` and `owner_notify` show a small Markdown subset formatted in Telegram: inline code, code blocks, bold, italic, strikethrough, http(s) links, headings (shown bold) and bullets. AOT escapes everything else, so other Markdown, such as a table, shows as written. The agent label line always stays plain. If Telegram cannot parse the formatting, AOT sends the plain text instead. Approval requests are never formatted, so a link there always shows its target. In incoming messages, AOT writes code, code blocks and link targets back as Markdown, so the agent still sees them.
71
+
72
+ Incoming deliveries carry more than text:
73
+
74
+ - **Media.** A new connection accepts documents, photos, videos, audio, voice notes and animations. The agent downloads them with `attachment_fetch`. When the owner turns media off, a media message still arrives with a `media_refused` list instead of files.
75
+ - **Quoted replies and forwards.** A reply carries the message it replies to under `reply_to_message`, and the selected part under `reply_to_message.quote` when it quotes only part of it. A forwarded message carries its origin under `forwarded_from`.
76
+ - **Reactions.** People's reactions arrive as deliveries of kind `reaction`. Telegram sends reactions to a bot only while the bot is an administrator in the group. See [message reactions](docs/REACTIONS.md).
77
+
78
+ You can ask the agent in plain words, for example **"Telegram status"**, **"Pause Telegram"**, **"Resume Telegram"**, **"Show recent Telegram context"** or **"React 👍 to that message"**.
79
+
80
+ ## Owner settings
81
+
82
+ The owner changes settings for one connection with `aot delivery-settings`. The command without options prints the current settings. The owner can also send **/settings** to the bot in a private chat to get a panel with every agent's settings as buttons (an ordinary button menu while Telegram refuses widgets from bots); see [settings panel](docs/OPERATIONS.md#settings-panel-in-telegram). For the panel and approvals to answer even while every agent is busy, run the [always-on collector](docs/OPERATIONS.md#always-on-collector) with `aot serve --install`. [Local operations](docs/OPERATIONS.md#addressed-only-delivery-and-group-context) explains every option.
83
+
84
+ | Option | Default | Effect |
85
+ |---|---|---|
86
+ | `--filter all\|addressed` | `all` | With `addressed`, AOT delivers only messages that mention the bot, reply to it or address a command to it, plus a person's quick follow-ups to such a message. It keeps the other messages as context. |
87
+ | `--context on\|off` | `off` | Keeps messages from senders who are not allowed as context. AOT never delivers them. |
88
+ | `--media on\|off` | `on` for new connections | Accepts media files. A connection paired before 0.9.4 keeps its earlier setting, which was off. |
89
+ | `--reaction-wake own_messages\|all\|none` | `own_messages` | Chooses which reactions AOT delivers. |
90
+ | `--wake-interval SECONDS` | `0` | Batches wake-up notices. After one notice, AOT waits this long and then announces everything that arrived in one notice. |
91
+ | `--wake-exempt addressed,owner\|addressed\|owner\|none` | `addressed,owner` | Chooses which messages AOT still announces at once during the wake interval. |
92
+ | `--model-judge on\|off` | `off` | With `--filter addressed`, asks a decision model (Jev, Cloudflare Clef or a self-hosted Clef) whether a person's message kept as context is meant for this agent, and delivers it if so. Needs `aot judge-config set`, and sends recent group messages to that model. See [model-judged wake decision](docs/OPERATIONS.md#model-judged-wake-decision). |
93
+ | `--auto-allow on\|off` | `off` | Adds every person and bot who posts in the group or topic to the allowed senders, for groups where everyone is trusted. Asks the owner to confirm at a terminal, or with Telegram buttons when no terminal is attached. Remove a sender with `allow-sender --remove`. See [auto-allow](docs/OPERATIONS.md#auto-allow-in-a-trusted-group). |
94
+ | `--owner-notify on\|off` | `off` | Allows `owner_notify` for this connection. |
95
+
96
+ **Owner notices.** With `owner_notify`, an agent can reach the owner in a private chat with the bot, for a decision, a blocker or an approval. AOT allows at most 3 notices per agent in any rolling hour and 10 in any rolling day. The owner must send `/start` to the bot once in a private chat, because Telegram does not let a bot start a private chat. The bot answers to confirm it is ready. See [notify the owner privately](docs/OPERATIONS.md#notify-the-owner-privately).
97
+
98
+ **Suspended connections.** AOT suspends a connection when the bot is removed or loses the right to post, or when the bound topic is closed or edited. AOT keeps queued messages. After fixing the cause, the owner runs `aot unsuspend` on this computer. It checks with Telegram first. See [clear a suspended connection](docs/OPERATIONS.md#clear-a-suspended-connection).
99
+
100
+ **Group upgrades.** When Telegram turns a group into a supergroup, the group gets a new chat id. AOT moves the connection to the new chat id by itself, with its allowed senders, held messages and queued sends. The owner does nothing. A connection that an older AOT version suspended for this reason moves when the owner runs `aot unsuspend`. See [group upgrades](docs/OPERATIONS.md#group-upgrades-to-a-supergroup).
101
+
102
+ ## How messages arrive
103
+
104
+ AOT collects Telegram updates into a local inbox for each connection. In Claude Code, Pi, Amp and Antigravity, the host integration collects while the host is open. In Codex, the plugin hooks collect at most every 10 seconds during a turn, and the optional `relay-desktop` listener collects while it runs. Setup starts no background service.
105
+
106
+ The `relay-desktop` listener uses native Codex queueing and a wake URL to wake an existing local chat. It does not queue a wake while the chat is busy, because the Codex hooks then deliver the notice inside that turn. When a queue command ends without a receipt, the listener settles the result itself from the desktop's own records. See [listen with the desktop](docs/DIRECT_DISPATCH.md).
107
+
108
+ In a supergroup without forum topics, a reply reaches the group's connection. Telegram marks such a reply with a thread id, but AOT reads that id as a topic only in a forum.
109
+
110
+ Status and history read local records only. They do not contact Telegram or send messages. History covers messages that AOT captured locally. It is not a full transcript of the group.
111
+
112
+ ## Documentation
113
+
114
+ - [Agent hosts: Claude Code, Codex, Pi and Amp](docs/HOSTS.md)
115
+ - [Guided setup, owner settings, local controls and advanced CLI](docs/OPERATIONS.md)
116
+ - [Message reactions](docs/REACTIONS.md)
117
+ - [Listen with the normally opened desktop](docs/DIRECT_DISPATCH.md)
118
+ - [Bot-to-bot exchanges](docs/BOT_EXCHANGES.md)
119
+ - [Shared binding procedure and older model-mediated relay](docs/RELAY.md)
120
+ - [Compatibility and evidence boundaries](docs/COMPATIBILITY.md)
121
+ - [macOS service](docs/MACOS_SERVICE.md)
122
+ - [Live validation and deliberate receiver migration](docs/LIVE_VALIDATION.md)
123
+ - [Implementation and validation evidence](docs/IMPLEMENTATION_STATUS.md)
124
+ - [Original proposal](PROPOSAL.md) and [handoff](HANDOFF.md)
125
+
126
+ ## Development
127
+
128
+ The development workflow uses uv; ordinary plugin setup does not need it. From the source root:
129
+
130
+ ```sh
131
+ uv sync --frozen --extra dev
132
+ .venv/bin/aot demo
133
+ .venv/bin/python -m pytest -q
134
+ .venv/bin/python scripts/validate_package.py
135
+ ```
136
+
137
+ The demo and the tests use isolated fake state. They need no token and do not call Telegram. `scripts/e2e_fake.py` prepares an isolated fake-Telegram project for any host and injects test messages, so you can check a real Claude Code, Codex, Pi or Amp process end to end without a token. See [what was tested](docs/HOSTS.md#what-was-tested).
138
+
139
+ A release is a version tag: pushing `vX.Y.Z` publishes the npm package and creates the GitHub release. See [releasing](docs/RELEASING.md).
140
+
141
+ Licensed under [Apache 2.0](LICENSE).
@@ -0,0 +1,121 @@
1
+ # Proposed bounded external bot exchanges
2
+
3
+ This opt-in policy separates new external bot requests. Deployment and activation require a deliberate local operator decision. A source update alone does not enable it.
4
+
5
+ All automated sends are bounded by rolling rate limits, not by lifetime counters. Each conversation may send at most 30 messages in any rolling hour. Each agent may send at most 60 messages in any rolling hour across all its conversations. When an older send leaves a window, sending can continue. A long agent exchange therefore slows down when it is too busy, but it does not have to wait for a human to post. When the owner does post in a conversation, that conversation's window starts again at once. The operator can change all limits; see [rolling send limits](#rolling-send-limits).
6
+
7
+ When an agent reaches its ceiling, all its Telegram sends stop until the window frees space, including replies to the owner. A busy loop with a bot can therefore keep an agent from answering the owner for up to an hour. The `client_limit` error tells the agent to report this in its local session, because it cannot send over Telegram.
8
+
9
+ The per-agent ceiling is what bounds the total. Without it, an agent that rotates through old conversations, or a bot that replies to old agent messages, would get a fresh 30 per hour in every conversation it can reach. The number of reachable conversations grows with every owner message.
10
+
11
+ ## Contract
12
+
13
+ | Situation | Behavior |
14
+ | --- | --- |
15
+ | No enabled policy for this client and external bot | Preserve the legacy persistent `bot:CLIENT:SENDER` chain. Its rolling conversation limit applies. |
16
+ | Enabled policy; a new, admitted, unsolicited bot message | Assign a server-derived `bot-root:CLIENT:SENDER:MESSAGE_ID` exchange. Message text cannot select the ID. |
17
+ | Bot replies to a known sent publication | Inherit that publication's conversation and its rolling window. The per-agent ceiling still bounds the agent's replies across all such conversations. |
18
+ | Any sender edits an already captured message | Reuse its original conversation, even after policy disable or unknown-send recovery. |
19
+ | Unseen edit or reply to an unknown publication | Use the legacy chain; do not mint a new root. |
20
+ | Any conversation | Allow at most 30 reserved sends in a rolling hour (configurable). A new message from the owner in this conversation, including a reply to an agent message, starts its window again. Edits, other humans, bots, ACK, restart, policy toggles, and owner messages in other conversations do not. |
21
+ | Any agent (client), across all its conversations | Allow at most 60 reserved sends in a rolling hour (configurable). This holds whether or not a bot exchange policy is enabled. Owner messages do not reset it. |
22
+ | Participating external bot pair | Allow at most 32 reserved sends in a rolling hour across its exchanges (configurable). Attach a pair to a human-started conversation when a real bot reply joins it. |
23
+ | Outbound reply with an explicit different conversation | Reject it with `reply_conversation_mismatch`. Without an explicit conversation, use the actual reply lineage. |
24
+
25
+ The core cannot prove that two unsolicited messages concern different semantic tasks. The rolling pair budget bounds bots that repeatedly post new roots instead of preserving reply lineage. It is a second limit, not evidence that every new root is independent work. Correct peers should reply to the actual message and keep the supplied conversation ID.
26
+
27
+ Reservations count queued, sent, rejected and unknown publications. No automatic refund follows a rejection or an uncertain send. Reusing a valid idempotency key does not consume a second reservation. Every new reservation and all budget checks occur in the existing transaction before network activity. Shared-bot broker sends use the same rolling conversation limit; if they continue an exchange with an external pair, that pair's rolling budget also applies.
28
+
29
+ Reaching the conversation limit returns `conversation_limit`. Reaching the per-agent ceiling returns `client_limit`. Reaching the pair limit returns `bot_pair_limit`. When several pairs are full, the error reports the latest time at which all of them have room. All three failures occur before an outbox intent is created, so nothing is sent or queued. There is no automatic retry, relay through another client, or invented conversation ID. The error tells the agent what happened and when to try again:
30
+
31
+ | Field | Meaning |
32
+ | --- | --- |
33
+ | `message` | Plain explanation: which limit was reached, the current usage, that nothing was sent, how long to wait, and that the agent must not switch conversations to avoid the limit. It tells the agent to stop and tell the human if the work cannot wait. It does not name the commands that change limits. |
34
+ | `limit`, `window_seconds` | The limit that applied, for example 30 sends per 3600 seconds. This includes any active operator grant. |
35
+ | `sent_in_window` | How many sends the window already holds. |
36
+ | `retry_after_seconds`, `retry_at`, `retry_at_utc` | The earliest time one more send fits, as a delay, a Unix timestamp, and an ISO 8601 UTC time. |
37
+
38
+ The agent should wait until `retry_at` and then retry the same send in the same conversation. A rejected send creates no outbox record, so the same idempotency key is valid for the retry. The timestamp does not prove that an old request is still appropriate to answer.
39
+
40
+ ## Rolling send limits
41
+
42
+ The operator sets the limits once for the whole state directory. Every agent process that uses this bot reads them from the shared state, so they always agree. No MCP tool can change them.
43
+
44
+ | Limit | Default | Allowed range |
45
+ | --- | --- | --- |
46
+ | Sends per conversation per window | 30 | 1–1000 |
47
+ | Conversation window | 3600 seconds | 60–86400 seconds |
48
+ | Sends per agent across all conversations per window | 60 | 1–1000 |
49
+ | Agent window | 3600 seconds | 60–86400 seconds |
50
+ | Sends per external bot pair per window | 32 | 1–1000 |
51
+ | Pair window | 3600 seconds | 60–86400 seconds |
52
+
53
+ ```sh
54
+ # Inspect the current limits.
55
+ "$AOT_BIN" --state-dir "$AOT_STATE" exchange-limits
56
+
57
+ # Change one or more limits. Options you omit keep their current value.
58
+ "$AOT_BIN" --state-dir "$AOT_STATE" exchange-limits \
59
+ --conversation-send-limit 60 --conversation-window-seconds 3600 \
60
+ --reason "Long agent coordination runs"
61
+
62
+ # Return to the built-in defaults.
63
+ "$AOT_BIN" --state-dir "$AOT_STATE" exchange-limits --reset --reason "Back to defaults"
64
+ ```
65
+
66
+ A change needs a reason and takes effect on the next send. Running processes do not need a restart.
67
+
68
+ A change also needs a human at a terminal. The command prints the change and continues only after someone types `yes`. Without a terminal it fails with `operator_confirmation_required`. Agents usually run commands without a terminal, so this stops an agent from lifting its own limit by accident. It is not a security boundary: agents run as the same Unix user and could drive a terminal on purpose. Inspecting the limits never asks.
69
+
70
+ The limits slow a loop between agents; they do not stop it. With the defaults, one looping agent can still send 60 messages an hour, and each one can wake another agent. Lower the limits if that cost is too high.
71
+
72
+ ## Local operator control
73
+
74
+ An operator can raise the rolling limit of one existing conversation for a short time, after an explicit human request:
75
+
76
+ ```sh
77
+ "$AOT_BIN" --state-dir "$AOT_STATE" conversation-budget \
78
+ --client-file "$AOT_CLIENT" --conversation-id EXISTING_CONVERSATION \
79
+ --additional-sends 16 --duration-seconds 50400 \
80
+ --reason "Human authorized a quota-break handoff"
81
+ ```
82
+
83
+ Omit the last three options to inspect the allowance. While a grant is active, the conversation may send up to `--additional-sends` more messages in each rolling window. A grant adds at most 32 sends and lasts at most 24 hours.
84
+ Only a client that already takes part in the conversation can create a grant. The grant then raises the limit for every sender in that conversation, because all their sends count toward the same window. It preserves counters, reply lineage, and idempotency records. The per-agent ceiling still applies on top of a grant. Granting needs the same typed confirmation at a terminal as `exchange-limits`. Without a terminal, the owner can [approve the grant in Telegram](OPERATIONS.md#approve-a-change-in-telegram) instead. Grants made by older versions were lifetime allowances; they do not apply to rolling windows and are ignored.
85
+ The grant is recorded in an append-only table. It does not change the rolling pair budget, queue limits, sender permissions, or pause state.
86
+ No MCP tool can grant an allowance. Existing processes must load the updated core to use it; older cores keep the default cap.
87
+ Status and grant commands do not recover interrupted sends. Expired grants do not reopen a conversation.
88
+
89
+ Only an already allowed external bot's verified numeric sender ID can receive this policy. The command does not grant a sender, change the group, or install a listener. No MCP tool can enable it.
90
+
91
+ Use the selected project's existing runtime, state, and protected client file. These are illustrative commands; do not execute enablement during source review:
92
+
93
+ ```sh
94
+ "$AOT_BIN" --state-dir "$AOT_STATE" bot-exchange-policy \
95
+ --client-file "$AOT_CLIENT" --sender-id VERIFIED_EXTERNAL_BOT_ID
96
+
97
+ # Only after the operator reviews and authorizes the new bounds:
98
+ "$AOT_BIN" --state-dir "$AOT_STATE" bot-exchange-policy \
99
+ --client-file "$AOT_CLIENT" --sender-id VERIFIED_EXTERNAL_BOT_ID --enable
100
+ ```
101
+
102
+ Omitting `--enable` and `--disable` inspects the current policy. Inspection and policy changes do not recover interrupted sends. `--disable` prevents future independent root creation. It creates no memberships for a pair that has never been enabled; memberships and rolling reservations already created stay enforced. Re-enabling does not reset them. Human/non-bot senders and unknown bot IDs are refused. Existing destination, sender, pause, suspension, rate, queue and deduplication checks remain in force.
103
+
104
+ ## Additive migration
105
+
106
+ 1. Prepare and validate this source in an isolated runtime using fake transport. Review the proposed bounds before deployment.
107
+ 2. Coordinate a maintenance window for the selected account. Preserve a protected backup and account for pending or uncertain sends through the existing owner. Keep one receiver; do not inspect or copy credentials into a report.
108
+ 3. Move all cooperating local MCP/collector processes to the reviewed runtime. A plugin cache update alone does not change an existing project runtime. Do not mix old and new cores after policy enablement.
109
+ 4. Initialization adds `bot_exchange_policies`, `bot_exchange_members` and indexes. Existing conversations, send counts, inbox conversation IDs, ACKs, outbox records and idempotency keys are not rewritten. All policies default to disabled.
110
+ 5. Inspect the intended allowed bot and its scope. After explicit authorization, enable only that pair. Legacy outbox reservations and captured historical conversations with that verified bot then participate in its rolling budget.
111
+ 6. Validate with a genuinely new, authorized bot request. Do not replay or reroute a blocked old reply. Verify actual handling, one publication, ACK, and persistent counters after restart.
112
+
113
+ The new root policy applies to messages admitted after enablement. Already captured work keeps its original conversation. It does not automatically retry, reclassify, or resend any previously blocked status update.
114
+
115
+ For rollback, disable future root creation and review outstanding exchanges first. Preserve the new state. An older binary does not enforce the new pair budget on retained new-root conversations; do not downgrade an active opted-in account and claim the same guarantees. Restoring a pre-migration backup can also lose newly collected updates. Use the existing deliberate receiver handoff procedure rather than copying cursors or deleting tables.
116
+
117
+ ## Offline verification
118
+
119
+ `tests/test_bot_exchanges.py` covers legacy schema migration without counter changes, a fresh independent exchange after legacy exhaustion, reply lineage sharing its conversation window, edits across policy disable, unknown replies and edits, a storm of fresh roots, rolling boundary behavior, restart and toggle persistence, uncertain/rejected sends, idempotency, concurrent last-slot allocation, sender/destination isolation, human-started lineage, reply budget borrowing, clock rollback, explicit CLI controls, disable without prior enablement, and human edit lineage after unknown-send recovery.
120
+
121
+ These checks use temporary state and `FakeTransport`. They do not establish live activation, cross-version operation, or compatibility with a peer that deliberately drops reply lineage. Keep live activation separate from this proposal.
@@ -0,0 +1,110 @@
1
+ # Compatibility and evidence boundaries
2
+
3
+ This is a local Python 3.11+ MVP using the pinned official Python MCP SDK `1.30.0` stdio interface. It does not implement MCP 2.0 Events. Linux and macOS/POSIX are supported execution targets. Since 0.9.30 the core, setup, the runtime bootstrap and `aot serve` also run on Windows: CI runs the test suite and a real bootstrap there, but no host (Claude Code, Codex) has been tried on a Windows machine yet; see [Windows](OPERATIONS.md#windows). Platform coverage is limited to the host and checks recorded in the implementation test report. Native scoped Codex tools were exercised live on 2026-10-19; Windows, curated-store submission and plugin UI installation remain untested. The macOS native listener checks are scoped below.
4
+
5
+ | Surface | Package support and limit |
6
+ | --- | --- |
7
+ | Python MCP client over stdio | Independent processes sharing one bot/state database with separate capabilities passed offline SDK interoperability tests. |
8
+ | Codex native scoped tools | Live checks covered same-bot broker delivery/deduplication and Alpha pause/queued intake/resume/reply/ack while Beta remained usable. |
9
+ | Codex desktop plugin UI | Normal installation declares skills and onboarding, with no plugin MCP server. UI installation, enablement and automatic skill/setup-button discovery remain untested; see the versioned validation record. |
10
+ | Runtime bootstrap | The packaged bootstrap requires local Python 3.11+ and prepares a stable private runtime from the installed plugin. uv is optional; its absence selects Python venv/ensurepip and private-environment pip, which require the corresponding Python support modules. No separately maintained source checkout is required. It does not install prerequisites, select a live account or start listening. |
11
+ | Codex marketplace CLI | The root `.agents/plugins` catalog names the marketplace and plugin `agents-over-telegram`. Native CLI registration and installation passed from the public `fourlastor/agents-over-telegram` GitHub repository in an empty Codex home, followed by runtime bootstrap and fresh fake scoped MCP checks. |
12
+ | Exact-project setup | Guided onboarding selects the bootstrap-returned executable for a new project and preserves the runtime already configured for an existing one. It prepares a private profile reference and one native project `telegram` MCP entry. Reload/reopen the project chat to load it. Only the exact directory selects that profile; all chats in the project share its identity. The user decides project trust in Codex. |
13
+ | Claude | Deferred. No Claude-specific command or integration is claimed. |
14
+ | One global plugin MCP entry across several Codex chats | The server cannot tell these chats apart. All callers using that entry share its selected client permissions. This is not a per-chat isolation mode. |
15
+ | Separate scoped stdio configurations | Supported authentication boundary: each configuration points to a different private client file. The core authorizes the resulting connection on every request. |
16
+ | ChatGPT web / Cloud | This package needs a local executable and private local state; no hosted endpoint or cloud relay is provided. |
17
+ | Recent captured context | `messages_history` / CLI `history` provide a scoped, bounded, paginated 24-hour local view including acknowledged inbound, own outbound statuses and broker metadata. Reads do not collect, send, claim, acknowledge or replay. |
18
+ | Complete preconnection Telegram history | Not provided. The view cannot retrieve updates already consumed elsewhere, prebinding omissions, or unconfigured/disallowed message bodies; no old-bridge history import exists. |
19
+ | Normal-launch desktop listener | `relay-desktop` uses the installed native Codex queue and OS wake URL for an existing local chat. Automatic Telegram collection, same-local-chat wake, native poll/reply/ack passed on normally launched Linux desktop with bundled Codex 0.163.0-alpha.10.2. Ledger confirms one sent reply and zero pending; the user also confirmed the reply is visible in Telegram. |
20
+ | Older model-mediated relay | A bounded watcher reports to a running relay chat, which calls native `send_message_to_thread`. One live idle-target wake/reply/ack check passed. This is a secondary experimental route; the plugin cannot invoke that host tool externally. |
21
+ | Experimental shared-backend dispatcher | `relay-dispatch` passed a manually launched live idle-target wake/reply/ack check using the optional bridge. Its special desktop startup is not required by the normal-launch listener and is not the default setup. The corrected bridge child-startup gate still lacks a final GUI restart check. |
22
+ | Listener lifecycle | On-demand remains the default. Explicit `relay-desktop` listening runs for a chosen duration with the normally opened desktop; it needs no relay model. Setup installs no service, autostart or scheduler. Stored messages and ordinary MCP notifications alone do not create turns. |
23
+ | MCP Events | Not implemented. The documented callback integration is a separate possible adapter, not evidence of local wakeup. |
24
+ | Several machines with the same bot | Unsupported without external receiver coordination. A local file lock cannot exclude a receiver on another host. |
25
+ | Same OS user | Trusted local processes. Private files and scoped MCP authorization do not isolate a malicious process already running as the same user. |
26
+
27
+ ## Package formats
28
+
29
+ The Codex package has one manifest, `.codex-plugin/plugin.json`. It declares the skills in `skills/`, the onboarding skill and the hooks in `codex/hooks.json`. The package root contains no `plugin.json`, `mcp.json` or `.mcp.json`, and the manifest declares no `mcpServers`. [Official package documentation](https://developers.openai.com/plugins/build/plugins)
30
+
31
+ Up to version 0.8.0 the package also had a root `plugin.json` in the Agent Plugins 1.0.0 format. That file was removed because Codex uses it instead of `.codex-plugin/plugin.json` when both exist, and Codex loads no hooks for an Agent Plugins package. With Codex CLI 0.163.0, `plugin/read` reported no hooks for 0.8.0 and all four hooks once the root file was gone. Adding `hooks` to the root manifest's `extensions.com.openai` object did not help. The Codex 0.163.0 source code confirms both results. [Agent hosts](HOSTS.md#how-the-codex-plugin-hooks-were-checked) has the full check.
32
+
33
+ Guided setup writes a native project MCP configuration using a stable `aot` executable and one private client file. The setup skill invokes the packaged runtime bootstrap for a new installation; merely loading the plugin does not execute the bootstrap. Since 0.8.0 the Codex manifest also references `codex/hooks.json`. Version 0.8.0 claimed that Codex loads these as plugin hooks, but the root `plugin.json` stopped Codex from loading them (see above). Without that file, Codex lists them as plugin hooks that the human must trust; see [agent hosts](HOSTS.md#codex). The normal Codex plugin still has no MCP launcher to configure. The bootstrap copies the required source and builds a non-editable environment outside the plugin cache. The pip path pins and hash-checks runtime and build dependencies from shipped requirements, using compatible wheels. The existing uv path retains frozen runtime resolution; its isolated build dependencies do not gain the pip path's transitive hash pinning. It uses existing uv when available, otherwise Python 3.11+ venv/ensurepip and pip inside the new environment. It does not install uv or use global pip, and performs no Telegram setup or listening. Pip offline installation requires a populated compatible wheelhouse for the shipped runtime and build requirements; uv offline installation uses its cache. Existing project configurations keep their chosen executable; a plugin update alone does not migrate them. The optional advanced `plugin-render` command synthesizes a private package whose `.codex-plugin/plugin.json` points at a `.mcp.json` stdio declaration with the selected absolute runtime/state/client paths. This one-client package must stay scoped to its intended callers and must not be enabled globally. The bundled launcher is used only by explicit advanced configurations; it requires absolute `AOT_EXECUTABLE`, `AOT_STATE_DIR`, and `AOT_CLIENT_FILE` paths and fails closed if any is absent. [Official desktop-only plugin documentation](https://developers.openai.com/plugins/deploy/desktop-only)
34
+
35
+ The repository also carries a Claude Code plugin in `.claude-plugin/plugin.json`, with its marketplace in `.claude-plugin/marketplace.json`. Its MCP server, hooks (`claude/hooks.json`) and monitor (`claude/monitors.json`) start through `scripts/aot_host_launch.py`. The Claude hooks and monitor live outside the default `hooks/` and `monitors/` folders, so Codex does not load them, and there is still no root `mcp.json` or `.mcp.json`. `claude plugin validate` passes for both files. Pi and Amp integrations live in `integrations/`. See [agent hosts](HOSTS.md).
36
+
37
+ The repository's `.agents/plugins/marketplace.json` declares marketplace `agents-over-telegram` with plugin source `./`. The installed Codex CLI accepts `codex plugin marketplace add fourlastor/agents-over-telegram` followed by `codex plugin add agents-over-telegram@agents-over-telegram`. The 0.7.0 local registration and installation passed with isolated `HOME` and `CODEX_HOME`. Bootstrap ran from that installed cache and reused the same runtime on repetition. After both source-package and installed-cache directories were moved away, runtime help and imports still worked from the private virtual environment. Fresh fake Alpha/Beta setup, native MCP scope, read-only status, pause and history checks also passed. Online dependency installation and a fresh offline bootstrap under a long path containing spaces passed. That version's full suite passed **534 tests in 21.15 seconds**; package and setup-skill validation passed. The development workspace records this check in `outputs/first-run-smoke.json`. These results predate the optional-uv pip fallback; its validation is recorded separately in [implementation status](IMPLEMENTATION_STATUS.md).
38
+
39
+ The 0.7.1 online first-run check also passed without an available uv executable. With `PATH=/usr/bin:/bin`, default bootstrap selected pip from a native CLI-installed plugin cache, reused its runtime on repetition, and still worked after both source/cache copies were moved away. Runtime help, imports and `pip check` passed, followed by fresh fake Alpha/Beta pairing, scoped MCP, status, pause and history checks. The interpreter was a full CPython 3.13.7 installation with ensurepip; no interpreter download or uv dependency cache was needed during the check. The implementation workspace records this result in `outputs/uv-free-smoke.json`. A fresh offline pip install and the same scoped MCP checks also passed using a 35-wheel compatible wheelhouse with network index access disabled. The full 0.7.1 suite passed **561 tests in 21.95 seconds**, including 39 bootstrap tests. The existing uv path also passed a fresh offline bootstrap. Offline pip evidence is recorded in `outputs/uv-free-offline-smoke.json`; these checks used fake Telegram only.
40
+
41
+ The public [fourlastor/agents-over-telegram repository](https://github.com/fourlastor/agents-over-telegram) was published under Apache-2.0 at commit `7ebd567`. A genuine remote CLI install passed in empty `HOME`/`CODEX_HOME`: GitHub marketplace retrieval and plugin installation, source/metadata/lock/license verification, default pip bootstrap without uv, repeat reuse, cache-independent runtime imports and `pip check`, then fresh fake Alpha/Beta scoped MCP checks. Evidence: `outputs/github-install-smoke.json` in the implementation workspace. Desktop install UI, automatic onboarding-button invocation and fresh real-bot registration remain untested; earlier live Telegram tests cover separately recorded existing-account flows.
42
+
43
+ The optional `extensions.com.openai.onboardingSkill` in `.codex-plugin/plugin.json` points to the packaged `telegram-setup` skill. Validation checks its existence and containment, including symlink escape. With Codex CLI 0.163.0, `plugin/read` resolved it to `telegram-setup` after a local install, both before and after the root `plugin.json` was removed. This does not prove the host invoked onboarding. [Official onboarding documentation](https://developers.openai.com/plugins/build/plugins#add-an-onboarding-skill)
44
+
45
+ The vendored MCP schema in `docs/schemas/` was retrieved on 2026-10-19; `sources.json` records its source URL and SHA-256 digest. `scripts/validate_package.py` uses it offline to check the server entries of a rendered `.mcp.json`. The script also rejects a root `plugin.json` or `mcp.json` and checks the manifest identity, the marketplace and the referenced local paths, including the hooks file. It does not claim to validate all OpenAI extension semantics or prove acceptance by a desktop host. [MCP schema](https://agent-plugins.org/schemas/1.0.0/mcp.schema.json)
46
+
47
+ OpenAI documents MCP Events for Work web, desktop Work with Cloud selected, and dots. This MVP's local stdio server has no event subscription or callback implementation. Do not infer local Codex wakeup support from that documentation. [Official MCP Events documentation](https://developers.openai.com/plugins/build/mcp-events)
48
+
49
+ ## Normal-launch local desktop boundary
50
+
51
+ The [desktop listener](DIRECT_DISPATCH.md) leaves ChatGPT's usual app-list launch and native backend intact. It validates the exact local thread and project, writes a fixed notice through native `codex queue`, and opens `codex://threads/wake/THREAD_UUID` through the operating system. Project scope, client capability, state directory and fake/live mode must continue to match. Telegram messages cannot authorize or change a mapping.
52
+
53
+ Version 0.7.2 replaces the exact-version gate with a read-only `codex queue --help` capability check for `--thread` and `--message`. Unknown version strings may proceed when those capabilities and the existing Linux process, schema and routing checks pass. This is an eligibility check, not a claim that every future Codex release or desktop wake implementation has been validated. The live-tested build remains **0.163.0-alpha.10.2**. macOS support is described below; Windows is not supported by this adapter.
54
+
55
+ The native queue delivers a **user-role** notice. Its text is a trusted fixed local instruction to check the scoped inbox, never Telegram text or sender-supplied instructions. This differs from the experimental app-server dispatcher's tool-output provenance. The target retrieves actual Telegram messages through its existing scoped tools and treats them as untrusted external input.
56
+
57
+ A live probe on **2026-10-19** used the normally launched Linux desktop and its bundled native Codex **0.163.0-alpha.10.2** with the existing local Alpha UUID. The desktop retained its ordinary stdio backend with no bridge or WebSocket launch override. External native queueing plus the OS wake URL started a new turn, which successfully called `telegram.connection_status` once and verified the expected identity. A repeated wake URL with the native queue empty created no extra turn over an observed interval of at least five seconds. No `send_message_to_thread` forwarding or Telegram publication was used. Evidence: `outputs/native-queue-live-probe.json`.
58
+
59
+ A subsequent live `relay-desktop` test passed the automatic Telegram round trip. Its collector captured `/test@ab_aot_tester_bot normal-idle-1` as incoming message **22**, queued the fixed notice and opened the wake URL. The same existing local Alpha UUID `01a153ec-3a02-7cb1-9168-b23584e47381` completed turn `01a154e3-9697-7f61-b4b5-92e9a854bbdb` using one native `messages_poll`, one `message_send` and acknowledgment after the outbox recorded `sent`. Telegram reply **23** references message 22 and uses idempotency key `normal-idle-1-reply`; Alpha finished with zero pending deliveries. The queue receipt is `01a154e3-941f-70f1-9c85-e166c3b6cb52`. The normal desktop retained its native direct stdio backend, with no manual wake or model forwarding after the marker arrived. The notification was accepted on attempt one and the target turn completed in **39.3 seconds**. Native tools and persisted delivery records confirm the result; the user also confirmed the reply is visible in Telegram. The development workspace records the receipts in `outputs/normal-startup-validation.json`; that external evidence file is not part of the portable package.
60
+
61
+ The 0.6.0 automated suite passed **502 tests in 20.97 seconds**; this predates the first-run bootstrap changes. Broader live busy-target, approval and lifecycle checks remain separate work. Other Linux Codex builds and Windows have not been validated for this adapter. The newer macOS checks below are distinct from this Linux result. Queue commands and desktop wake routing are installed-build capabilities rather than a claimed portable MCP feature.
62
+
63
+ The listener records the enqueue attempt before the native command and stores its returned queue ID before opening the wake URL. If enqueue success is ambiguous, it holds the handoff rather than blindly adding another notice. When the queue ID is known, recovery retries only the wake URL. A successful OS opener exit is not proof of model completion or Telegram handling. Inbox leases, acknowledgment and publication remain the target's separate operations; the listener and optional collector never perform them or flush the outbox.
64
+
65
+ The adapter checks for an existing desktop before enqueueing and opening the URL. It does not intentionally launch a closed app, but the check and OS opener are not atomic; a close/open race can let the OS launch the app normally. Stopping the listener prevents new attempts but does not remove a previously queued notice or cancel a running turn. No system service, scheduler or custom app launcher is installed.
66
+
67
+ ## Earlier experimental routes
68
+
69
+ The [model-mediated relay](RELAY.md) uses the same collector, scoped binding and durable notification ledger. A running relay chat forwards fixed notices through native `send_message_to_thread`; it needs the human's authorization for that target. Its repeated bounded waits may return to the model while idle. One live idle-target wake/reply/ack test passed, but the parent chat must stay running. This is a secondary option, not the current normal-launch procedure.
70
+
71
+ `relay-dispatch` connects to an explicitly shared app-server and injects a fixed tool-output notice with empty user input. It accepts a protected local Unix WebSocket or an authenticated literal-loopback WebSocket and leaves approvals and dynamic tool handling to the desktop owner. It neither discovers a normal stdio backend nor starts another runtime over saved conversation files. An accepted notification remains separate from turn completion, inbox acknowledgment and Telegram publication.
72
+
73
+ The optional `aot-codex-bridge` test adapter exposes that shared endpoint while preserving the desktop's stdio ownership. An earlier manually launched bounded dispatcher passed a real Telegram idle-wake/reply/ack check. The corrected bridge child-startup gate has isolated coverage but lacks its final real-GUI restart check. This adapter requires a special startup command and is retained only as experimental infrastructure; it is unnecessary for `relay-desktop`.
74
+
75
+ An isolated native proxy fixture passed **15 checks**, and a native SSH-hosted desktop fixture passed visible idle wakeup with a canned model. The latter used a different remote chat, retained 31 dynamic `codex_app` tools, and did not establish separate coordination MCP, real Telegram handling or ordinary local-chat behavior. Evidence: `outputs/wrapper-free-validation.json` and `work/native-ssh/desktop-wake-result.json`.
76
+
77
+ A native local restart fixture passed **12 checks**, preserving its UUID/history and invoking its project MCP tool after switching to a native Unix listener. Static inspection found that this special startup path misses the fresh coordination MCP pipe environment and the stdio-only trusted environment for `artifact_session`. It does not establish full desktop tool parity. These launch experiments are not required for the normal-launch route. Evidence: `work/direct-probe/native-restart-persistence-result.json` and `work/wakeup-investigation/local-native-attach-audit.json`.
78
+
79
+ ## Telegram limits
80
+
81
+ The routing unit is one registered bot plus numeric group ID and optional numeric topic ID. A destination binds to one logical agent. Same-bot coordination uses an explicit internal broker delivery because publication by the shared bot cannot be assumed to reappear as a `getUpdates` item. A visible logical-agent label is not a separate Telegram-authenticated identity.
82
+
83
+ Telegram's webhook and `getUpdates` receivers are mutually exclusive. Updates are retained by Telegram for at most 24 hours, and a higher offset confirms earlier updates; the core persists its received batch before advancing its local cursor. Extended offline periods can therefore leave unrecoverable upstream gaps. [Telegram getting updates](https://core.telegram.org/bots/api#getting-updates)
84
+
85
+ The 24-hour local history view and Telegram's update retention are separate limits. Snapshot pagination fixes a 24-hour event-time window with a 15-minute cursor lifetime. It reads captured local records and can include acknowledged messages; it does not query Telegram history or establish that every message from the preceding day was captured. The window does not delete older stored records.
86
+
87
+ Telegram visibility depends on destination settings and the bot's permissions. Its bot-to-bot mode and addressed/reply behavior require live verification in the selected group. This build does not change BotFather settings, webhooks, or group permissions. [Telegram bot communication](https://core.telegram.org/bots/features#bot-to-bot-communication)
88
+
89
+
90
+ ## macOS native queue validation
91
+
92
+ On 2026-10-19 the adapter was exercised on macOS with the normally running ChatGPT app (bundle ID `com.openai.codex`, app version `26.1013.40934`). No wrapper launcher, Accessibility automation, copied Codex home or replacement backend was used. Read-only capability inspection found `queue --thread --message`; Darwin process inspection matched the app and its direct same-user native stdio backend with the same Codex home.
93
+
94
+ One fixed local notice was queued to the existing development chat: the native CLI returned a valid queue receipt and `/usr/bin/open -a` accepted the UUID-only wake URL for the same validated app. The target was already busy. These observations establish native queue and OS handoff acceptance, **not** idle model wake, Telegram intake, a Telegram reply, or inbox acknowledgment. The new bot was not paired during this check. The Linux `normal-idle-1` round trip above remains separate evidence.
95
+
96
+ Tests cover both macOS bundle layouts, the bundled CLI wrapper routing alias, exact UUID URLs pinned to the selected app, owner/process/start-time guards, malformed process arguments, filtering of unrelated environment fields, blocked routing overrides, duplicate/indirect backends and denied process inspection. Linux process and subprocess tests run on both hosts with disposable metadata; a Darwin-only smoke test checks the actual libproc/sysctl ABI against the test process itself.
97
+
98
+ The complete macOS suite passed with **614 tests passed, 2 skipped** using Python 3.13.16. Package/schema validation also passed. Socket-test fixture directories are canonicalized so macOS's `/var` symlink is not mistaken for an unsafe application endpoint; production socket checks remain strict. The experimental shared-backend wrapper also handles Darwin's EPERM for an already exited leader only after libproc positively reports an empty process group, with failures preserved for live, nonempty or uninspectable groups. No process-group permission error is ignored solely because the leader exited.
99
+
100
+ Follow-up observation from the same macOS probe: after the preceding busy turn completed, the exact fixed queue notice automatically appeared as a user message in a new turn of the same development chat. No relay model forwarded it. This verifies delivery to a model turn after a busy target finishes, in addition to the CLI receipt and OS URL acceptance. At that stage, a fresh arrival while the target was already idle was untested. The development project had no Telegram profile or loaded Telegram MCP tools, so no real inbox was polled and no deliveries were acknowledged. The later paired tests are recorded below.
101
+
102
+ ## macOS follow-up: idle and busy tests
103
+
104
+ Follow-up live checks on 2026-10-19 used the same normally launched macOS desktop and a dedicated operator-owned bot, with the existing target's scoped Telegram MCP tools. The idle test passed: intake to model start was 1.116 seconds; intake to sent receipt was 24.72 seconds. The ledger contained one sent reply, an acknowledged input and zero pending messages. The operator confirmed the reply in Telegram. This extends the earlier busy-queue probe; it does not turn a queue receipt into proof of immediate busy-turn delivery.
105
+
106
+ A separate busy test exposed the limit: the native notice remained queued while the existing turn continued. An operator-installed `PostToolUse` hook then supplied a fixed pending-inbox notice at a tool boundary. After correcting its interpreter to use the plugin Python runtime, a fresh message produced one sent reply in **24.603 seconds**, one acknowledgment and zero pending messages. The same work turn remained active before and after handling. No manual Steer, inter-task forwarding or target restart delivered that fresh marker. The reply was independently visible in Telegram.
107
+
108
+ The hook is a **local integration, not part of this release**. The check does not prove interruption during a model request, a long-running tool, or unsupported tool paths. Hook trust was reviewed in the CLI because `/hooks` was unavailable in the tested desktop UI. See the [hook constraints](DIRECT_DISPATCH.md#busy-sessions-and-hooks).
109
+
110
+ An explicitly requested user LaunchAgent also ran the listener with `--duration 0 --collect`. Graceful termination followed by automatic launchd recovery preserved the ledger without duplicate notifications. Desktop reopen and subsequent Telegram handling passed. An OS reboot, automatic desktop startup before login, network-outage recovery, and a multi-day unattended run were **not** exercised. Existing operator power management was retained. The manual service procedure is in [continuous listening on macOS](MACOS_SERVICE.md).