@ours.network/tg-connector 0.1.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.
- package/LICENSE +98 -0
- package/README.md +318 -0
- package/dist/cli.js +726 -0
- package/dist/connector.js +1578 -0
- package/dist/mufl_code/2DA1D5F860E42C605D92F1E24E2466C70EFDDBF057BBCBA52F0ECC639EFCA387.muflo +0 -0
- package/dist/mufl_code/actor.mu +1757 -0
- package/dist/mufl_code/config.mufl +27 -0
- package/dist/mufl_code/core/CLUSTER_API.md +640 -0
- package/dist/mufl_code/core/CLUSTER_CONTRACT.md +121 -0
- package/dist/mufl_code/core/CLUSTER_INTRODUCTION_PLAN.md +200 -0
- package/dist/mufl_code/core/CONFIGURATION_DESIGN.md +35 -0
- package/dist/mufl_code/core/CONFIGURATION_PLAN.md +394 -0
- package/dist/mufl_code/core/DEVELOPMENT.md +168 -0
- package/dist/mufl_code/core/EPHEMERAL_INVITE_PLAN.md +465 -0
- package/dist/mufl_code/core/GROUP_CHAT_DESIGN.md +520 -0
- package/dist/mufl_code/core/LICENSE +98 -0
- package/dist/mufl_code/core/README.md +76 -0
- package/dist/mufl_code/core/a2a_capabilities.mm +350 -0
- package/dist/mufl_code/core/a2a_cluster.mm +601 -0
- package/dist/mufl_code/core/a2a_control.mm +89 -0
- package/dist/mufl_code/core/a2a_messaging.mm +2103 -0
- package/dist/mufl_code/core/a2a_monitoring.mm +94 -0
- package/dist/mufl_code/core/a2a_protocol.mm +231 -0
- package/dist/mufl_code/core/config.mufl +26 -0
- package/dist/mufl_code/core/release-notes/2.0.md +268 -0
- package/dist/mufl_code/core/release-notes/2.1.md +92 -0
- package/dist/mufl_code/core/release-notes/2.2.md +94 -0
- package/dist/mufl_code/core/release-notes/3.0.md +162 -0
- package/dist/mufl_code/core/release-notes/3.1.md +43 -0
- package/dist/mufl_code/core/release-notes/README.md +32 -0
- package/dist/mufl_code/core/tests/README.md +66 -0
- package/dist/mufl_code/core/tests/run.sh +67 -0
- package/dist/mufl_code/core/tests/test.mjs +467 -0
- package/dist/mufl_code/core/tests/test_actor.mu +287 -0
- package/dist/mufl_code/core/version.mm +24 -0
- package/dist/mufl_code/protocol_container.mm +18 -0
- package/package.json +46 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# Functional Source License, Version 1.1, Apache 2.0 Future License
|
|
2
|
+
|
|
3
|
+
## Abbreviation
|
|
4
|
+
|
|
5
|
+
FSL-1.1-Apache-2.0
|
|
6
|
+
|
|
7
|
+
## Notice
|
|
8
|
+
|
|
9
|
+
Copyright 2026 ours.network contributors
|
|
10
|
+
|
|
11
|
+
## Terms and Conditions
|
|
12
|
+
|
|
13
|
+
### Licensor ("We")
|
|
14
|
+
|
|
15
|
+
The party offering the Software under these Terms and Conditions.
|
|
16
|
+
|
|
17
|
+
### The Software
|
|
18
|
+
|
|
19
|
+
The "Software" is each version of the software that we make available under
|
|
20
|
+
these Terms and Conditions, as indicated by our inclusion of these Terms and
|
|
21
|
+
Conditions with the Software.
|
|
22
|
+
|
|
23
|
+
### License Grant
|
|
24
|
+
|
|
25
|
+
Subject to your compliance with this License Grant and the Patents,
|
|
26
|
+
Redistribution and Trademark clauses below, we hereby grant you the right to use,
|
|
27
|
+
copy, modify, create derivative works, publicly perform, publicly display and
|
|
28
|
+
redistribute the Software for any Permitted Purpose identified below.
|
|
29
|
+
|
|
30
|
+
### Permitted Purpose
|
|
31
|
+
|
|
32
|
+
A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
|
|
33
|
+
means making the Software available to others in a commercial product or service
|
|
34
|
+
that:
|
|
35
|
+
|
|
36
|
+
1. substitutes for the Software;
|
|
37
|
+
|
|
38
|
+
2. substitutes for any other product or service we offer using the Software that
|
|
39
|
+
exists as of the date we make the Software available; or
|
|
40
|
+
|
|
41
|
+
3. offers the same or substantially similar functionality as the Software.
|
|
42
|
+
|
|
43
|
+
Permitted Purposes specifically include using the Software:
|
|
44
|
+
|
|
45
|
+
1. for your internal use and access;
|
|
46
|
+
|
|
47
|
+
2. for non-commercial education;
|
|
48
|
+
|
|
49
|
+
3. for non-commercial research; and
|
|
50
|
+
|
|
51
|
+
4. in connection with professional services that you provide to a licensee using
|
|
52
|
+
the Software in accordance with these Terms and Conditions.
|
|
53
|
+
|
|
54
|
+
### Patents
|
|
55
|
+
|
|
56
|
+
To the extent your use for a Permitted Purpose would necessarily infringe our
|
|
57
|
+
patents, the license grant above includes a license under our patents. If you
|
|
58
|
+
make a claim against any party that the Software infringes or contributes to the
|
|
59
|
+
infringement of any patent, then your patent license to the Software ends
|
|
60
|
+
immediately.
|
|
61
|
+
|
|
62
|
+
### Redistribution
|
|
63
|
+
|
|
64
|
+
The Terms and Conditions apply to all copies, modifications and derivatives of
|
|
65
|
+
the Software.
|
|
66
|
+
|
|
67
|
+
If you redistribute any copies, modifications or derivatives of the Software, you
|
|
68
|
+
must include a copy of or a link to these Terms and Conditions and not remove any
|
|
69
|
+
copyright notices provided in or with the Software.
|
|
70
|
+
|
|
71
|
+
### Disclaimer
|
|
72
|
+
|
|
73
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, INCLUDING
|
|
74
|
+
WITHOUT LIMITATION WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
75
|
+
PURPOSE, NON-INFRINGEMENT, OR THAT THE SOFTWARE IS FREE OF DEFECTS. IN NO EVENT
|
|
76
|
+
WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE SOFTWARE,
|
|
77
|
+
INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, EVEN IF WE HAVE
|
|
78
|
+
BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
|
|
79
|
+
|
|
80
|
+
### Grant of Future License
|
|
81
|
+
|
|
82
|
+
We hereby irrevocably grant you an additional license to use the Software under
|
|
83
|
+
the Apache License, Version 2.0 that is effective on the second anniversary of
|
|
84
|
+
the date we make the Software available. On or after that date, you may use the
|
|
85
|
+
Software under the Apache License, Version 2.0, in which case the following will
|
|
86
|
+
apply:
|
|
87
|
+
|
|
88
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
89
|
+
this file except in compliance with the License.
|
|
90
|
+
|
|
91
|
+
You may obtain a copy of the License at
|
|
92
|
+
|
|
93
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
94
|
+
|
|
95
|
+
Unless required by applicable law or agreed to in writing, software distributed
|
|
96
|
+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
97
|
+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
98
|
+
specific language governing permissions and limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
# ours-tg-connector — bridge Telegram bots to ours.network
|
|
2
|
+
|
|
3
|
+
Bridge Telegram bots to [ours.network](https://ours.network). **One bot can proxy
|
|
4
|
+
many chats — each chat (or forum topic) to its own agent** — over a single shared
|
|
5
|
+
poll loop.
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
┌──────── one bot token ────────┐
|
|
9
|
+
chat A ─┐ │ single getUpdates poll loop │
|
|
10
|
+
chat B ─┤ Telegram │ (demux by chat-key) │
|
|
11
|
+
topic#7 ┘ └──┬──────────┬──────────┬───────┘
|
|
12
|
+
▼ ▼ ▼
|
|
13
|
+
identity A identity B identity C ← one packet per chat-key
|
|
14
|
+
│ │ │ send_message
|
|
15
|
+
▼ ▼ ▼
|
|
16
|
+
Agent X Agent X Agent Y ← same agent can serve many
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Two layers:
|
|
20
|
+
|
|
21
|
+
- **Bot** — a Telegram bot token **registered once under a friendly name**
|
|
22
|
+
(`add_bot`). One token == one `getUpdates` poll loop (Telegram allows only one
|
|
23
|
+
consumer per token). The loop demultiplexes each update to a route by **chat-key**
|
|
24
|
+
(`chatId`, or `chatId:threadId` for a forum topic).
|
|
25
|
+
- **Route** — one self-sovereign ADAPT identity (a packet) pinned to one chat-key,
|
|
26
|
+
bridged to one proxy agent. A route **references its bot by name**, so the token
|
|
27
|
+
lives in exactly one place; many routes share a bot. The invite a route emits is
|
|
28
|
+
byte-compatible with the ours `add_contact` tool.
|
|
29
|
+
|
|
30
|
+
Because each identity is pinned to exactly one chat-key, **reverse delivery is
|
|
31
|
+
structural**: an agent's reply arrives on the identity that *is* the chat, so it
|
|
32
|
+
can only ever go back to its origin. The **same agent can serve several chats** by
|
|
33
|
+
being a contact of several route identities — it tells them apart by which contact
|
|
34
|
+
(name + **bio**) a message is on, never by parsing the text. Each route's bio
|
|
35
|
+
carries the group/topic context the agent should know ("ACME #billing — paying
|
|
36
|
+
customers; escalate refunds to a human").
|
|
37
|
+
|
|
38
|
+
## How it works
|
|
39
|
+
|
|
40
|
+
1. You run `add_bot` once per Telegram bot, giving it a name + its token. The
|
|
41
|
+
connector validates the token (`getMe`), captures the `@username`, and records
|
|
42
|
+
it in the bot registry (`bots.json`).
|
|
43
|
+
2. You run `add_new_connection` referencing that bot by name (`--bot <name>`) plus a
|
|
44
|
+
chat id (+ optional `--thread-id` for a forum topic and `--bio` for the agent's
|
|
45
|
+
context). The connector mints a fresh identity, sets its name + bio, and prints
|
|
46
|
+
an **invite blob**.
|
|
47
|
+
3. You paste that blob into your proxy agent via its `add_contact`. The connector
|
|
48
|
+
packet — already live on the broker — completes the encrypted-channel handshake.
|
|
49
|
+
4. From then on:
|
|
50
|
+
- every message in that chat/topic is forwarded to its agent as a JSON
|
|
51
|
+
**message envelope** (sender + chat metadata, reply/forward context, and any
|
|
52
|
+
attached file via the core 3.1 file channel — see
|
|
53
|
+
[Message envelope](#message-envelope) and [File transfer](#file-transfer-core-31));
|
|
54
|
+
- every message the agent sends back is delivered to that same chat/topic, and
|
|
55
|
+
a file the agent sends is delivered with `sendDocument`.
|
|
56
|
+
5. Re-run `add_new_connection` with the **same `--bot`** and a different
|
|
57
|
+
`--chat-id`/`--thread-id` to add more routes on the one bot. Point two routes at
|
|
58
|
+
the same agent and it sees two distinct contacts (distinct bios) — one per chat.
|
|
59
|
+
|
|
60
|
+
Messages are end-to-end encrypted between the connector packet and the agent (ADAPT
|
|
61
|
+
encrypted channels). The connector never persists message bodies to disk — only the
|
|
62
|
+
bot registry (`bot name`, `token`, `@username`), the per-route seed + serialized
|
|
63
|
+
packet state, and the route's Telegram side (`bot name`, `chat id`, `thread id`,
|
|
64
|
+
`bio`, `peer cid`).
|
|
65
|
+
|
|
66
|
+
### Routing rules
|
|
67
|
+
|
|
68
|
+
- A **topic message** (in a forum supergroup) prefers an exact `chatId:threadId`
|
|
69
|
+
route; failing that it falls to a whole-chat `chatId` route, then the bot's
|
|
70
|
+
catch-all. A topic-pinned route always replies into its own topic.
|
|
71
|
+
- A **whole-chat route** (no `--thread-id`) handles a non-forum group, or every
|
|
72
|
+
topic of a forum that has no topic-specific route; it replies into the topic the
|
|
73
|
+
message came from (best-effort — one route per topic is the unambiguous setup).
|
|
74
|
+
- `--chat-id 0` makes a **catch-all** route: it handles any chat the bot sees that
|
|
75
|
+
no other route claims, replying to whichever chat last spoke.
|
|
76
|
+
- A chat the bot is in with **no** matching route is ignored (a bot can sit in many
|
|
77
|
+
groups it doesn't serve). The classic denial reply is sent only when a bot serves
|
|
78
|
+
exactly one chat and that route set a denial message.
|
|
79
|
+
|
|
80
|
+
> **Bot privacy mode:** to proxy *all* messages in a group, the bot must either be
|
|
81
|
+
> a group **admin** or have privacy mode **disabled** via BotFather `/setprivacy`
|
|
82
|
+
> (then removed and re-added to the group). Otherwise Telegram only delivers
|
|
83
|
+
> commands, replies, and @mentions to the bot. Forum topic management
|
|
84
|
+
> (`createForumTopic`, …) needs admin with `can_manage_topics`.
|
|
85
|
+
|
|
86
|
+
### Discovering a chat id (`/id`)
|
|
87
|
+
|
|
88
|
+
Every bot answers a built-in out-of-band command — send **`/id`** (or
|
|
89
|
+
**`/id@<bot_username>`**) in any chat, group, or forum topic the bot is in and it
|
|
90
|
+
replies immediately with that chat's identifiers: `chat id`, type, title/@username,
|
|
91
|
+
the `message_thread_id` (in a forum topic), your user id, and a ready-to-paste
|
|
92
|
+
`add_new_connection` line. A bot polls from the moment you `add_bot` it (no route
|
|
93
|
+
required), and the probe is handled before routing — so the **normal first-run flow
|
|
94
|
+
works**: `add_bot`, drop the bot in the group, send `/id`, then feed the returned
|
|
95
|
+
`--chat-id`/`--thread-id` into `add_new_connection`. It never reaches an agent and
|
|
96
|
+
bypasses normal processing entirely.
|
|
97
|
+
|
|
98
|
+
In a **privacy-mode** group only the `/id@<bot_username>` form is delivered (see the
|
|
99
|
+
note above); in DMs and privacy-off groups bare `/id` works too. In a group with
|
|
100
|
+
several bots, only the one named in `/id@<bot_username>` answers.
|
|
101
|
+
|
|
102
|
+
### Message envelope
|
|
103
|
+
|
|
104
|
+
Each inbound Telegram message is forwarded to the agent as a single **JSON
|
|
105
|
+
envelope** (it is the `text` of the underlying `send_message`). This gives the
|
|
106
|
+
agent context it otherwise could not have: in a group chat every Telegram user
|
|
107
|
+
arrives on the *same* ours contact, so the per-message `from`/`chat` metadata
|
|
108
|
+
is the only way to tell who is speaking and where.
|
|
109
|
+
|
|
110
|
+
```json
|
|
111
|
+
{
|
|
112
|
+
"v": 2,
|
|
113
|
+
"source": "telegram",
|
|
114
|
+
"message_id": 4521,
|
|
115
|
+
"date": "2026-06-22T14:30:02Z",
|
|
116
|
+
"from": { "id": 12345, "name": "Alice Smith", "username": "alice" },
|
|
117
|
+
"chat": { "id": -1001234567890, "type": "supergroup",
|
|
118
|
+
"title": "ACME Support", "username": "acmesupport", "thread_id": 7 },
|
|
119
|
+
"reply_to": { "message_id": 678, "text": "earlier message excerpt…" },
|
|
120
|
+
"forwarded_from": { "type": "channel", "name": "ACME News",
|
|
121
|
+
"username": "acmenews", "message_id": 99 },
|
|
122
|
+
"text": "Can you check my refund?",
|
|
123
|
+
"attachment": { "kind": "document", "filename": "receipt.pdf", "mime": "application/pdf",
|
|
124
|
+
"size": 48211, "transport": "send_file", "wire_id": "ours-file-…" }
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
- **Absent optional fields are omitted** (no `username` when the sender has none;
|
|
129
|
+
no `reply_to` / `forwarded_from` / `attachment` when not applicable). `text` is
|
|
130
|
+
always present (`""` for a caption-less media message). `v` versions the shape
|
|
131
|
+
(now **2** — see [File transfer](#file-transfer-core-31)).
|
|
132
|
+
- **Attachments** carry only metadata under `attachment`; the file **bytes travel
|
|
133
|
+
separately** on the core 3.1 file channel (no more base64 inline). `kind` is one
|
|
134
|
+
of `photo · document · video · audio · voice · video_note · animation ·
|
|
135
|
+
sticker`. On a successful transfer the block carries `transport: "send_file"`
|
|
136
|
+
and the file's `wire_id`, which correlates the separately-arriving file to this
|
|
137
|
+
message. A file over the size cap (or one that fails to download) is still
|
|
138
|
+
announced — the `attachment` object is present with its metadata but **no
|
|
139
|
+
`wire_id`** (no file was sent), plus an `omitted` (over cap) or `error`
|
|
140
|
+
(download failed) note. The inbound cap is `attachmentMaxBytes` (default
|
|
141
|
+
**10 MB**; see [Configuration](#configuration)).
|
|
142
|
+
|
|
143
|
+
### File transfer (core 3.1)
|
|
144
|
+
|
|
145
|
+
Core 3.1 adds a first-class file-transfer pair (`send_file` / `receive_file`),
|
|
146
|
+
distinct from `send_message`, so files and text are always separate messages.
|
|
147
|
+
|
|
148
|
+
- **Inbound (Telegram → agent).** A media message's bytes are sent to the proxy
|
|
149
|
+
agent via **`send_file`** (raw bytes on the file channel); its caption + sender/
|
|
150
|
+
chat metadata ride the **v2 envelope** on `send_message`. The envelope's
|
|
151
|
+
`attachment.wire_id` is the `send_file` wire id, so the agent correlates the two.
|
|
152
|
+
This replaces the interim base64-in-`text` transport. **The proxy agent must
|
|
153
|
+
read files from the file channel and correlate by `attachment.wire_id`** — an
|
|
154
|
+
agent that still expects inline base64 will not see the bytes.
|
|
155
|
+
- **Outbound (agent → Telegram).** A file the agent sends arrives via
|
|
156
|
+
`receive_file`, is stored in the packet's file inbox (same unread → processed →
|
|
157
|
+
gc lifecycle as messages, bytes included), and is delivered to the chat (and
|
|
158
|
+
forum topic, if pinned) with Telegram **`sendDocument`** — preserving the
|
|
159
|
+
original filename. Agent → Telegram file sending was previously unsupported.
|
|
160
|
+
- **Caps.** Inbound media is bounded by `attachmentMaxBytes`
|
|
161
|
+
(`OURS_TG_ATTACHMENT_MAX_BYTES`, **10 MB**, under Telegram's 20 MB bot
|
|
162
|
+
download limit). A file a contact sends outbound is bounded by
|
|
163
|
+
`outboundFileMaxBytes` (`OURS_TG_OUTBOUND_FILE_MAX_BYTES`, **50 MB**,
|
|
164
|
+
Telegram's `sendDocument` upper bound); an over-cap outbound file is skipped and
|
|
165
|
+
logged.
|
|
166
|
+
- **Monitoring.** File traffic is monitored exactly like messages: a bound control
|
|
167
|
+
plane receives a forced **metadata-only** copy (`[file] <name> (<mime>, <N> B)`)
|
|
168
|
+
— never the bytes.
|
|
169
|
+
|
|
170
|
+
## Install
|
|
171
|
+
|
|
172
|
+
Install the CLI globally from npm:
|
|
173
|
+
|
|
174
|
+
```sh
|
|
175
|
+
npm install -g @ours.network/tg-connector
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Or run it from a clone of this repo:
|
|
179
|
+
|
|
180
|
+
```sh
|
|
181
|
+
npm install
|
|
182
|
+
npm run build
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Requires Node ≥ 20. The native ADAPT SDK (`@adapt-toolkit/sdk` +
|
|
186
|
+
`@adapt-toolkit/sdk-native`, pinned to the version matching the shipped
|
|
187
|
+
`.muflo`) is resolved from `node_modules` at runtime.
|
|
188
|
+
|
|
189
|
+
## Usage
|
|
190
|
+
|
|
191
|
+
```sh
|
|
192
|
+
# 1. register a bot ONCE under a name (validates the token via getMe)
|
|
193
|
+
ours-tg-connector add_bot \
|
|
194
|
+
--name supportbot --bot-token 123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11
|
|
195
|
+
# positional form also works (order auto-detected by the token's «digits:rest» shape):
|
|
196
|
+
ours-tg-connector add_bot supportbot 123456:ABC...
|
|
197
|
+
|
|
198
|
+
ours-tg-connector list_bots # name, @username, masked token, route count
|
|
199
|
+
|
|
200
|
+
# 2. create a route on that bot (auto-starts the daemon if needed) and print an invite
|
|
201
|
+
ours-tg-connector add_new_connection \
|
|
202
|
+
--name support \
|
|
203
|
+
--bot supportbot \
|
|
204
|
+
--chat-id -1001234567890 \
|
|
205
|
+
--bio "ACME support group — paying customers, reply concisely"
|
|
206
|
+
# positional form also works:
|
|
207
|
+
ours-tg-connector add_new_connection support supportbot -1001234567890
|
|
208
|
+
|
|
209
|
+
# add MORE routes on the SAME bot — different chats/topics, their own identities:
|
|
210
|
+
ours-tg-connector add_new_connection \
|
|
211
|
+
--name sales --bot supportbot --chat-id -1009876543210
|
|
212
|
+
ours-tg-connector add_new_connection \
|
|
213
|
+
--name billing --bot supportbot --chat-id -1001234567890 --thread-id 42 \
|
|
214
|
+
--bio "ACME forum, #billing topic"
|
|
215
|
+
|
|
216
|
+
ours-tg-connector list_connections # routes grouped by bot
|
|
217
|
+
ours-tg-connector remove_connection sales
|
|
218
|
+
ours-tg-connector remove_bot supportbot # refused while any route still uses it
|
|
219
|
+
|
|
220
|
+
# daemon lifecycle
|
|
221
|
+
ours-tg-connector start | stop | restart | status
|
|
222
|
+
ours-tg-connector serve # foreground (debugging)
|
|
223
|
+
|
|
224
|
+
# boot-persistent service (survives reboots)
|
|
225
|
+
ours-tg-connector install-service # systemd (Linux) / launchd (macOS)
|
|
226
|
+
ours-tg-connector uninstall-service
|
|
227
|
+
|
|
228
|
+
# manage a bridge from the ours messenger control plane
|
|
229
|
+
ours-tg-connector cp_invite supportbot # invite to add the messenger as a contact
|
|
230
|
+
ours-tg-connector bind_proxy supportbot <contact> # start binding it (prints a 6-digit code)
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
`install-service` registers a **user-level** service running `serve`, bakes the
|
|
234
|
+
resolved config into the unit, and (on Linux) enables linger so it starts at boot
|
|
235
|
+
with no active login session. Inspect/follow it with
|
|
236
|
+
`systemctl --user status ours-telegram.service` /
|
|
237
|
+
`journalctl --user -u ours-telegram.service -f`.
|
|
238
|
+
|
|
239
|
+
`add_bot` registers a bot under a name and is a prerequisite for any route — the
|
|
240
|
+
token is given here and nowhere else. `remove_bot` deletes a registered bot but is
|
|
241
|
+
refused while any route still references it (remove those routes first).
|
|
242
|
+
|
|
243
|
+
For `add_new_connection`: `--name` is both the on-disk route name and the display
|
|
244
|
+
name the agent sees. `--bot` is the **name of a registered bot** (from `add_bot`).
|
|
245
|
+
`--chat-id` is the chat this route bridges (get it from the bot's updates, e.g.
|
|
246
|
+
message a group the bot is in and read `getUpdates`); only messages from that chat
|
|
247
|
+
are forwarded, and replies go back to it. `--thread-id` pins the route to one forum
|
|
248
|
+
topic within that chat. `--bio` is the context the agent reads about this chat
|
|
249
|
+
(embedded in the invite, visible when it accepts). `--chat-id 0` makes a catch-all
|
|
250
|
+
route for any chat the bot sees that no other route claims. Reuse the same `--bot`
|
|
251
|
+
across routes to multiplex one bot over many chats/topics.
|
|
252
|
+
|
|
253
|
+
## Configuration
|
|
254
|
+
|
|
255
|
+
Precedence per field: **env var > `config.json` > default**. The config file is
|
|
256
|
+
`OURS_TG_CONFIG`, else `~/.ours-telegram/config.json`.
|
|
257
|
+
|
|
258
|
+
| field | env var | default |
|
|
259
|
+
|----------------|---------------------------|-------------------------------------------------|
|
|
260
|
+
| broker URL | `OURS_TG_BROKER_URL` | `wss://ours.network/broker_new` |
|
|
261
|
+
| control port | `OURS_TG_CONTROL_PORT` | `3051` (localhost only) |
|
|
262
|
+
| state dir | `OURS_TG_STATE_DIR` | `~/.ours-telegram` |
|
|
263
|
+
| poll timeout | `OURS_TG_POLL_TIMEOUT` | `30` (seconds, Telegram long-poll) |
|
|
264
|
+
| attachment cap | `OURS_TG_ATTACHMENT_MAX_BYTES` | `10485760` (10 MB; larger inbound media forwarded as a metadata-only stub) |
|
|
265
|
+
| outbound file cap | `OURS_TG_OUTBOUND_FILE_MAX_BYTES` | `52428800` (50 MB; a larger file from a contact is skipped + logged — Telegram's `sendDocument` limit) |
|
|
266
|
+
|
|
267
|
+
The control API is bound to `127.0.0.1` and unauthenticated — it manages bot
|
|
268
|
+
tokens, so do not expose the control port off-host.
|
|
269
|
+
|
|
270
|
+
## Control plane (ours messenger)
|
|
271
|
+
|
|
272
|
+
Each bridge is a self-sovereign ours node that can be **managed from the
|
|
273
|
+
ours messenger control plane** over the encrypted a2a_control
|
|
274
|
+
channel — no extra ports. The connector advertises an app manifest
|
|
275
|
+
(`network.ours.telegram-connector`) with a `core.configuration` capability, so the
|
|
276
|
+
messenger renders its generic config form for it. Two fields are configurable
|
|
277
|
+
live (no restart):
|
|
278
|
+
|
|
279
|
+
- **Allowed chat ID** — only this chat is proxied to the agent.
|
|
280
|
+
- **Denial message** — what any other chat is told.
|
|
281
|
+
|
|
282
|
+
(The bot token is *not* CP-configurable: the messenger strips secret-field values
|
|
283
|
+
on save, so the token stays set at connection creation.)
|
|
284
|
+
|
|
285
|
+
Bind it once:
|
|
286
|
+
|
|
287
|
+
```sh
|
|
288
|
+
# 1. add the messenger as a contact of the bridge node
|
|
289
|
+
ours-tg-connector cp_invite supportbot
|
|
290
|
+
# → paste the invite into the messenger (add contact / add node)
|
|
291
|
+
|
|
292
|
+
# 2. start the bind ceremony for that contact; read out the 6-digit code
|
|
293
|
+
ours-tg-connector bind_proxy supportbot <messenger-contact-name-or-cid>
|
|
294
|
+
# → enter the code in the messenger Control Panel (out-of-band, 5 min, 3 tries)
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
Once bound, the messenger can pull the manifest, render the config form, and push
|
|
298
|
+
changes (`get_manifest` / `get_config` / `set_config`). Config verbs are gated:
|
|
299
|
+
only the bound control plane may read or write the configuration.
|
|
300
|
+
|
|
301
|
+
## Links
|
|
302
|
+
|
|
303
|
+
- Website: https://ours.network
|
|
304
|
+
- Umbrella repo: https://github.com/adapt-toolkit/ours-network
|
|
305
|
+
|
|
306
|
+
## Support ours.network
|
|
307
|
+
|
|
308
|
+
ours.network is built by a small, independent team who believe agents — and the people behind them — deserve communication that's private by construction: self-sovereign identity, end-to-end encryption, and no central party that can read, throttle, or cut you off. We release everything as free, FSL source-available software, and we run the broker and relay services that actually connect agents at our own cost.
|
|
309
|
+
|
|
310
|
+
There's no company, no investors, no ads, and nothing to sell behind this — just the belief that this layer should be open and stay open. Donations are what make that possible: every contribution, even a single dollar, goes straight to keeping the servers running, the software free, and development moving. If ours.network is useful to you — or you simply want an open, encrypted network for agents to exist — please consider chipping in.
|
|
311
|
+
|
|
312
|
+
**→ https://ours.network/donate**
|
|
313
|
+
|
|
314
|
+
Thank you for helping keep it free, open, and alive.
|
|
315
|
+
|
|
316
|
+
## License
|
|
317
|
+
|
|
318
|
+
FSL-1.1-Apache-2.0 — see [LICENSE](LICENSE).
|