@ours.network/tg-connector 0.5.0 → 0.5.1-nightly.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +92 -153
- package/dist/cli.js +91 -117
- package/dist/connector.js +1861 -1911
- package/docs/voice-message-contract.md +8 -2
- package/package.json +4 -5
- package/dist/mufl_code/ED9CAFA60E1A0884E2CBC8E71BA8A137488A14763C57587D25AEC4BAD7F58C81.muflo +0 -0
- package/dist/mufl_code/actor.mu +0 -1937
- package/dist/mufl_code/config.mufl +0 -27
- package/dist/mufl_code/core/COMMERCIAL-LICENCE.md +0 -25
- package/dist/mufl_code/core/COMPATIBILITY.md +0 -221
- package/dist/mufl_code/core/CONTRIBUTING.md +0 -37
- package/dist/mufl_code/core/LICENSE +0 -98
- package/dist/mufl_code/core/NOTIFICATIONS_CONTRACT.md +0 -290
- package/dist/mufl_code/core/README.md +0 -91
- package/dist/mufl_code/core/SECURITY.md +0 -40
- package/dist/mufl_code/core/TRADEMARKS.md +0 -24
- package/dist/mufl_code/core/a2a_capabilities.mm +0 -449
- package/dist/mufl_code/core/a2a_cluster.mm +0 -601
- package/dist/mufl_code/core/a2a_control.mm +0 -90
- package/dist/mufl_code/core/a2a_messaging.mm +0 -4817
- package/dist/mufl_code/core/a2a_monitoring.mm +0 -94
- package/dist/mufl_code/core/a2a_notification_integration.mm +0 -144
- package/dist/mufl_code/core/a2a_notifications.mm +0 -1127
- package/dist/mufl_code/core/a2a_protocol.mm +0 -246
- package/dist/mufl_code/core/a2a_versions.mm +0 -801
- package/dist/mufl_code/core/config.mufl +0 -29
- package/dist/mufl_code/core/docs/.vitepress/config.mts +0 -58
- package/dist/mufl_code/core/docs/citations.json +0 -688
- package/dist/mufl_code/core/docs/guide/01-vendor-the-core.md +0 -50
- package/dist/mufl_code/core/docs/guide/02-configure-and-compile.md +0 -100
- package/dist/mufl_code/core/docs/guide/03-wire-the-host.md +0 -154
- package/dist/mufl_code/core/docs/guide/04-connect-and-message.md +0 -156
- package/dist/mufl_code/core/docs/guide/05-test-your-app.md +0 -75
- package/dist/mufl_code/core/docs/guide/index.md +0 -63
- package/dist/mufl_code/core/docs/how-it-works/capabilities-and-control.md +0 -77
- package/dist/mufl_code/core/docs/how-it-works/cluster.md +0 -65
- package/dist/mufl_code/core/docs/how-it-works/identity.md +0 -56
- package/dist/mufl_code/core/docs/how-it-works/invites-and-contacts.md +0 -76
- package/dist/mufl_code/core/docs/how-it-works/messaging.md +0 -55
- package/dist/mufl_code/core/docs/how-it-works/monitoring-and-config.md +0 -72
- package/dist/mufl_code/core/docs/how-it-works/overview.md +0 -45
- package/dist/mufl_code/core/docs/how-it-works/versioning.md +0 -116
- package/dist/mufl_code/core/docs/index.md +0 -27
- package/dist/mufl_code/core/docs/package-lock.json +0 -3467
- package/dist/mufl_code/core/docs/package.json +0 -15
- package/dist/mufl_code/core/docs/reference/contributing.md +0 -26
- package/dist/mufl_code/core/docs/reference/glossary.md +0 -108
- package/dist/mufl_code/core/docs/reference/implementations.md +0 -23
- package/dist/mufl_code/core/docs/reference/modules.md +0 -19
- package/dist/mufl_code/core/docs/scripts/check-citations.mjs +0 -36
- package/dist/mufl_code/core/docs/scripts/check-denylist.mjs +0 -30
- package/dist/mufl_code/core/docs/scripts/gen-llms.mjs +0 -32
- package/dist/mufl_code/core/docs/workflows/cluster.md +0 -89
- package/dist/mufl_code/core/docs/workflows/contact-exchange.md +0 -60
- package/dist/mufl_code/core/docs/workflows/contact-restore.md +0 -60
- package/dist/mufl_code/core/docs/workflows/control-verbs.md +0 -70
- package/dist/mufl_code/core/docs/workflows/index.md +0 -57
- package/dist/mufl_code/core/docs/workflows/introductions.md +0 -60
- package/dist/mufl_code/core/docs/workflows/messaging.md +0 -75
- package/dist/mufl_code/core/docs/workflows/monitoring.md +0 -84
- package/dist/mufl_code/core/docs/workflows/notifications.md +0 -109
- package/dist/mufl_code/core/release-notes/0.1.md +0 -60
- package/dist/mufl_code/core/release-notes/0.3.md +0 -22
- package/dist/mufl_code/core/release-notes/0.4.md +0 -97
- package/dist/mufl_code/core/tests/README.md +0 -83
- package/dist/mufl_code/core/tests/compat/README.md +0 -82
- package/dist/mufl_code/core/tests/compat/compat.mjs +0 -245
- package/dist/mufl_code/core/tests/compat/compat_peer.mjs +0 -146
- package/dist/mufl_code/core/tests/compat/run_compat.sh +0 -96
- package/dist/mufl_code/core/tests/corpus.mjs +0 -139
- package/dist/mufl_code/core/tests/corpus_actor.mu +0 -242
- package/dist/mufl_code/core/tests/fatcompile_actor.mu +0 -52
- package/dist/mufl_code/core/tests/mig.mjs +0 -805
- package/dist/mufl_code/core/tests/mig_actor.mu +0 -518
- package/dist/mufl_code/core/tests/migapp.mjs +0 -431
- package/dist/mufl_code/core/tests/migapp_actor.mu +0 -294
- package/dist/mufl_code/core/tests/mufl_semantics/run.sh +0 -69
- package/dist/mufl_code/core/tests/mufl_semantics/t11_three_version.mufl +0 -47
- package/dist/mufl_code/core/tests/mufl_semantics/t2_extra_fields.mufl +0 -11
- package/dist/mufl_code/core/tests/mufl_semantics/t7_runtime.mufl +0 -30
- package/dist/mufl_code/core/tests/mufl_semantics/t9_passthrough.mufl +0 -19
- package/dist/mufl_code/core/tests/mufl_semantics/t_str_order.mufl +0 -19
- package/dist/mufl_code/core/tests/notif.mjs +0 -755
- package/dist/mufl_code/core/tests/notif_actor.mu +0 -450
- package/dist/mufl_code/core/tests/protocol_container.mm +0 -18
- package/dist/mufl_code/core/tests/run.sh +0 -65
- package/dist/mufl_code/core/tests/run_corpus.sh +0 -51
- package/dist/mufl_code/core/tests/run_fatcompile.sh +0 -40
- package/dist/mufl_code/core/tests/run_mig.sh +0 -51
- package/dist/mufl_code/core/tests/run_migapp.sh +0 -51
- package/dist/mufl_code/core/tests/run_notif.sh +0 -57
- package/dist/mufl_code/core/tests/test.mjs +0 -750
- package/dist/mufl_code/core/tests/test_actor.mu +0 -564
- package/dist/mufl_code/core/tests/test_common.mjs +0 -93
- package/dist/mufl_code/core/version.mm +0 -24
- package/dist/mufl_code/protocol_container.mm +0 -18
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ loop.
|
|
|
12
12
|
chat B ─┤ Telegram │ (demux by chat-key) │
|
|
13
13
|
topic#7 ┘ └──┬──────────┬──────────┬───────┘
|
|
14
14
|
▼ ▼ ▼
|
|
15
|
-
identity A identity B identity C ←
|
|
15
|
+
identity A identity B identity C ← daemon identity per chat-key
|
|
16
16
|
│ │ │ send_message
|
|
17
17
|
▼ ▼ ▼
|
|
18
18
|
Agent X Agent X Agent Y ← same agent can serve many
|
|
@@ -24,7 +24,7 @@ Two layers:
|
|
|
24
24
|
(`add_bot`). One token == one `getUpdates` poll loop (Telegram allows only one
|
|
25
25
|
consumer per token). The loop demultiplexes each update to a route by **chat-key**
|
|
26
26
|
(`chatId`, or `chatId:threadId` for a forum topic).
|
|
27
|
-
- **Route** — one
|
|
27
|
+
- **Route** — one ours identity in the shared daemon pinned to one chat-key,
|
|
28
28
|
bridged to one proxy agent. A route **references its bot by name**, so the token
|
|
29
29
|
lives in exactly one place; many routes share a bot. The invite a route emits is
|
|
30
30
|
byte-compatible with the ours `add_contact` tool.
|
|
@@ -47,14 +47,15 @@ customers; escalate refunds to a human").
|
|
|
47
47
|
context). The connector mints a fresh identity, sets its name + bio, and prints
|
|
48
48
|
an **invite blob**.
|
|
49
49
|
3. You paste that blob into your proxy agent via its `add_contact`. The connector
|
|
50
|
-
|
|
50
|
+
route identity — already live through the daemon — completes the encrypted-channel handshake.
|
|
51
51
|
4. From then on:
|
|
52
52
|
- every message in that chat/topic is forwarded to its agent as a JSON
|
|
53
53
|
**message envelope** (sender + chat metadata, reply/forward context, and any
|
|
54
54
|
attached file via the core 3.1 file channel — see
|
|
55
55
|
[Message envelope](#message-envelope) and [File transfer](#file-transfer-core-31));
|
|
56
|
-
- every message the agent sends back is delivered to that same chat/topic
|
|
57
|
-
|
|
56
|
+
- every message the agent sends back is delivered to that same chat/topic with
|
|
57
|
+
Markdown formatting and exact reply threading when `reply_to.wire_id` is
|
|
58
|
+
available; a file the agent sends is delivered with `sendDocument`.
|
|
58
59
|
5. Re-run `add_new_connection` with the **same `--bot`** and a different
|
|
59
60
|
`--chat-id`/`--thread-id` to add more routes on the one bot. Point two routes at
|
|
60
61
|
the same agent and it sees two distinct contacts (distinct bios) — one per chat.
|
|
@@ -67,11 +68,14 @@ both modes; Telegram voice notes retain the protocol MIME marker
|
|
|
67
68
|
`audio/ogg; x-ours-kind=voice-message`, allowing the receiving daemon to invoke
|
|
68
69
|
its native voice-transcription path even when no companion text is sent.
|
|
69
70
|
|
|
70
|
-
Messages are end-to-end encrypted between the connector
|
|
71
|
+
Messages are end-to-end encrypted between the connector's route identity and the agent (ADAPT
|
|
71
72
|
encrypted channels). The connector never persists message bodies to disk — only the
|
|
72
|
-
bot registry (`bot name`, `token`, `@username`),
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
bot registry (`bot name`, `token`, `@username`), route metadata (`bot name`,
|
|
74
|
+
`chat id`, `thread id`, `bio`, `peer cid`, and stable daemon lease), and a bounded
|
|
75
|
+
30-day wire-id ↔ Telegram-message-id map with per-route receipt settings. Those
|
|
76
|
+
persisted route names are also the connector's simple list of identities it
|
|
77
|
+
created. The list is organizational bookkeeping, not an authorization or
|
|
78
|
+
provenance boundary; identity keys and packet state stay in the shared daemon.
|
|
75
79
|
|
|
76
80
|
### Routing rules
|
|
77
81
|
|
|
@@ -109,102 +113,6 @@ In a **privacy-mode** group only the `/id@<bot_username>` form is delivered (see
|
|
|
109
113
|
note above); in DMs and privacy-off groups bare `/id` works too. In a group with
|
|
110
114
|
several bots, only the one named in `/id@<bot_username>` answers.
|
|
111
115
|
|
|
112
|
-
### Reply threading
|
|
113
|
-
|
|
114
|
-
An agent's answer can arrive in Telegram **as a reply to the message that prompted
|
|
115
|
-
it**, so a busy group chat stays readable. The mechanism is one mapping:
|
|
116
|
-
|
|
117
|
-
1. an inbound Telegram message is sent to the agent as ours `wire_id` **W**, and the
|
|
118
|
-
route records `W → (chat id, message id)` in `messages.json` in its state dir;
|
|
119
|
-
2. the agent answers with `reply_to_wire_id = W` (the `send_message` tool already
|
|
120
|
-
supports it);
|
|
121
|
-
3. the connector resolves **W** back to that Telegram message and sends with
|
|
122
|
-
`reply_parameters.message_id`.
|
|
123
|
-
|
|
124
|
-
**It only works when the agent fills `reply_to_wire_id`.** An agent that does not
|
|
125
|
-
gets ordinary un-threaded messages — that is a property of the sender, not a
|
|
126
|
-
connector fault, so it is worth putting in the persona of any role that writes to
|
|
127
|
-
Telegram. If a pointer resolves to nothing (never mapped, or older than the 30-day
|
|
128
|
-
retention below) the message is delivered **plain**; a "similar" or most-recent
|
|
129
|
-
message is never substituted.
|
|
130
|
-
|
|
131
|
-
The map is persistent (it survives a daemon restart), holds **no message content** —
|
|
132
|
-
only chat/message ids, the contact id and the receipt state — and is pruned at
|
|
133
|
-
**30 days** / 2000 rows per route, oldest first.
|
|
134
|
-
|
|
135
|
-
### Delivery & read receipts as reactions
|
|
136
|
-
|
|
137
|
-
When the agent's node confirms a message, the connector puts a **reaction** on the
|
|
138
|
-
originating Telegram message: 👀 when it was **delivered**, then 👌 once the agent
|
|
139
|
-
has **read** it (its `get` path). Because a bot may hold **at most one reaction per
|
|
140
|
-
message**, read *replaces* delivered rather than sitting beside it.
|
|
141
|
-
|
|
142
|
-
The confirmations themselves are core 0.7.0 receipts, not something the connector
|
|
143
|
-
invents: emission is gated on both sides' `core.receipts.*` capabilities (the
|
|
144
|
-
connector declares `emit` and `receive`), and application is **monotonic** per
|
|
145
|
-
(peer, message) over `unknown < sent < delivered < read` — a duplicate or
|
|
146
|
-
out-of-order receipt changes nothing. Receipts are **best-effort UX**: a missing
|
|
147
|
-
reaction does **not** mean the message failed to arrive, and a Telegram refusal on a
|
|
148
|
-
reaction (reactions disabled in the chat, message deleted) is logged and never
|
|
149
|
-
affects message delivery.
|
|
150
|
-
|
|
151
|
-
> **The agent side has to emit them.** A peer only sends receipts if *it* advertises
|
|
152
|
-
> `core.receipts.emit`. Against an agent node that does not, the reactions simply
|
|
153
|
-
> never appear — everything else keeps working.
|
|
154
|
-
|
|
155
|
-
Per **connection** (not per bot — `/receipts off` on one route leaves the others
|
|
156
|
-
alone), in the route's own chat:
|
|
157
|
-
|
|
158
|
-
```
|
|
159
|
-
/receipts on # turn delivery/read reactions on for this connection
|
|
160
|
-
/receipts off # …and off
|
|
161
|
-
/receipts status # show the current setting and emoji
|
|
162
|
-
/emoji delivered <e> # set the "delivered" reaction
|
|
163
|
-
/emoji read <e> # set the "read" reaction
|
|
164
|
-
/emoji reset # back to 👀 / 👌
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
Commands are parsed **in connector code**, never passed to the agent, and are
|
|
168
|
-
answered in the chat. An emoji is validated against Telegram's fixed
|
|
169
|
-
bot-reaction list **before** it is saved, with the valid set in the error —
|
|
170
|
-
note that ✅ is *not* on that list, which is why the `read` default is 👌.
|
|
171
|
-
|
|
172
|
-
### `/help` and the slash menu
|
|
173
|
-
|
|
174
|
-
**`/help`** is answered by the connector itself: it lists the commands the
|
|
175
|
-
connector owns (`/help`, `/id`, `/receipts`, `/emoji`) and the current receipt
|
|
176
|
-
settings for that connection. It works in a chat with no route yet too — you get
|
|
177
|
-
the command list and a pointer to `/id`.
|
|
178
|
-
|
|
179
|
-
The same list is registered with Telegram via `setMyCommands` at **default
|
|
180
|
-
scope** when a bot starts polling, so a client offers the commands in its slash
|
|
181
|
-
menu as you type. Registration is cosmetic and best-effort: if it fails it is
|
|
182
|
-
logged, and every command still works when typed by hand.
|
|
183
|
-
|
|
184
|
-
> **Only these four commands are intercepted.** Everything else you send is
|
|
185
|
-
> relayed to the agent exactly as typed, *including* text that starts with a
|
|
186
|
-
> slash — `/deploy prod` reaches the agent, and so does `/help me write the
|
|
187
|
-
> release note`, because only a **bare** `/help` is treated as the command.
|
|
188
|
-
|
|
189
|
-
### Message formatting
|
|
190
|
-
|
|
191
|
-
Formatting is preserved **in both directions**.
|
|
192
|
-
|
|
193
|
-
- **Telegram → agent.** A message's `entities` / `caption_entities` (bold, italic,
|
|
194
|
-
underline, strikethrough, spoiler, code, `pre` with its language, blockquote,
|
|
195
|
-
links and mentions) are folded into **Markdown** in the message text, so the
|
|
196
|
-
agent reads the formatting instead of losing it. Offsets are UTF-16 code units
|
|
197
|
-
and are treated as such. A `custom_emoji` is premium-only and degrades to the
|
|
198
|
-
stand-in glyph Telegram already put in the text. A message with no entities is
|
|
199
|
-
passed through byte-for-byte.
|
|
200
|
-
- **Agent → Telegram.** The agent's Markdown is rendered as `MarkdownV2`, escaping
|
|
201
|
-
the **text leaves only** (all 18 reserved characters — one unescaped `.` would
|
|
202
|
-
fail the whole send). Emphasis is deliberately conservative: `foo_bar_baz` and
|
|
203
|
-
`2*3*4` stay literal. The 4096-character limit is applied to the **escaped**
|
|
204
|
-
text. **If Telegram rejects the markup, the same text is resent with no
|
|
205
|
-
`parse_mode`** and the original refusal is logged — the message always wins over
|
|
206
|
-
its styling.
|
|
207
|
-
|
|
208
116
|
### Message envelope
|
|
209
117
|
|
|
210
118
|
Each inbound Telegram message is forwarded to the agent as a single **JSON
|
|
@@ -259,19 +167,46 @@ distinct from `send_message`, so files and text are always separate messages.
|
|
|
259
167
|
read files from the file channel and correlate by `attachment.wire_id`** — an
|
|
260
168
|
agent that still expects inline base64 will not see the bytes.
|
|
261
169
|
- **Outbound (agent → Telegram).** A file the agent sends arrives via
|
|
262
|
-
`receive_file`, is stored in the
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
170
|
+
`receive_file`, is stored in the daemon's durable per-identity history, and is
|
|
171
|
+
delivered to the chat (and forum topic, if pinned) with Telegram
|
|
172
|
+
**`sendDocument`** — preserving the original filename. The connector first
|
|
173
|
+
lists unread metadata, reads the immutable blob, uploads it to Telegram, and
|
|
174
|
+
only then acknowledges that exact `wire_id` with selected `getFiles`.
|
|
266
175
|
- **Caps.** Inbound media is bounded by `attachmentMaxBytes`
|
|
267
176
|
(`OURS_TG_ATTACHMENT_MAX_BYTES`, **10 MB**, under Telegram's 20 MB bot
|
|
268
177
|
download limit). A file a contact sends outbound is bounded by
|
|
269
178
|
`outboundFileMaxBytes` (`OURS_TG_OUTBOUND_FILE_MAX_BYTES`, **50 MB**,
|
|
270
179
|
Telegram's `sendDocument` upper bound); an over-cap outbound file is skipped and
|
|
271
180
|
logged.
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
181
|
+
|
|
182
|
+
### Replies, formatting, and receipts
|
|
183
|
+
|
|
184
|
+
- Telegram entities (bold, italic, code, links, quotes, and related formatting)
|
|
185
|
+
are converted to Markdown for the agent. Agent Markdown is rendered as
|
|
186
|
+
Telegram MarkdownV2, with a plain-text fallback if Telegram rejects the parse.
|
|
187
|
+
- The bounded wire-id map lets agent `reply_to.wire_id` pointers become native
|
|
188
|
+
Telegram replies. Telegram replies are likewise sent with a structured ours
|
|
189
|
+
reply pointer when their exact mapped message is still retained. Missing or
|
|
190
|
+
expired mappings degrade to an unthreaded message; the connector never guesses.
|
|
191
|
+
- Delivery and read receipts become one Telegram reaction per message (`👀` then
|
|
192
|
+
`👌` by default). `/receipts` and `/emoji` configure them per route, and
|
|
193
|
+
`/help` reports the active settings. Receipt state is monotonic and is caught
|
|
194
|
+
up from durable outbound history after a restart or `sync_required` event.
|
|
195
|
+
|
|
196
|
+
### External delivery boundary
|
|
197
|
+
|
|
198
|
+
Agent messages are delivered oldest-first from the daemon's durable history.
|
|
199
|
+
The connector uses `listIncomingMessages` plus `getHistoryItem` to inspect one
|
|
200
|
+
unread body without changing state, sends it to Telegram, then acknowledges it
|
|
201
|
+
with `getMessages({limit:1})` and verifies the returned `wire_id` is the one it
|
|
202
|
+
just delivered. Per-route single-flight drains prevent concurrent notifications
|
|
203
|
+
from racing acknowledgements. Telegram failures leave the oldest item unread.
|
|
204
|
+
|
|
205
|
+
There is one unavoidable external side-effect window: if Telegram accepts a
|
|
206
|
+
message or file and the process crashes before the daemon acknowledgement, the
|
|
207
|
+
item stays unread and may be delivered again after restart. The connector favors
|
|
208
|
+
recoverability over silently losing content and does not depend on removed
|
|
209
|
+
defer/requeue or conversation-policy APIs.
|
|
275
210
|
|
|
276
211
|
### Voice transcription (speech-to-text)
|
|
277
212
|
|
|
@@ -296,8 +231,15 @@ added for provenance:
|
|
|
296
231
|
}
|
|
297
232
|
```
|
|
298
233
|
|
|
299
|
-
- **Opt-in
|
|
300
|
-
|
|
234
|
+
- **Opt-in, and it covers THIS PROCESS ONLY.** Off by default
|
|
235
|
+
(`sttEnabled:false`), which means *the connector* sends no audio to a
|
|
236
|
+
speech-to-text provider. It does **not** mean the audio is never transcribed:
|
|
237
|
+
the connector is a client of an ours daemon, and **the daemon runs its own
|
|
238
|
+
speech-to-text** when the receiving side pulls a voice note — under
|
|
239
|
+
configuration this connector's operator does not control and may not know
|
|
240
|
+
exists. When the connector was its own host, `sttEnabled:false` did cover the
|
|
241
|
+
whole path; attached, it no longer can. Turn it on and supply a key to
|
|
242
|
+
transcribe here as well (see [Configuration](#configuration)).
|
|
301
243
|
- **No transcoding.** Telegram voice is **OGG/Opus**, which OpenAI-compatible
|
|
302
244
|
transcription endpoints accept directly — the connector adds **no ffmpeg** and no
|
|
303
245
|
new dependency (just built-in `fetch`).
|
|
@@ -351,9 +293,11 @@ npm install
|
|
|
351
293
|
npm run build
|
|
352
294
|
```
|
|
353
295
|
|
|
354
|
-
Requires Node ≥ 20
|
|
355
|
-
|
|
356
|
-
|
|
296
|
+
Requires Node ≥ 20, and **an ours daemon already running on this box** — the
|
|
297
|
+
connector attaches to it over `/api/v1` and drives it through
|
|
298
|
+
[`@ours.network/sdk`](https://www.npmjs.com/package/@ours.network/sdk). It runs
|
|
299
|
+
no engine of its own: there is no native ADAPT SDK and no MUFL packet here, so
|
|
300
|
+
nothing beyond `npm install` is resolved at runtime.
|
|
357
301
|
|
|
358
302
|
## Usage
|
|
359
303
|
|
|
@@ -366,7 +310,8 @@ ours-tg-connector add_bot supportbot 123456:ABC...
|
|
|
366
310
|
|
|
367
311
|
ours-tg-connector list_bots # name, @username, masked token, route count
|
|
368
312
|
|
|
369
|
-
# 2. create a route on that bot (auto-starts the
|
|
313
|
+
# 2. create a route on that bot (auto-starts the connector process if needed;
|
|
314
|
+
# the shared ours daemon must already be running) and print an invite
|
|
370
315
|
ours-tg-connector add_new_connection \
|
|
371
316
|
--name support \
|
|
372
317
|
--bot supportbot \
|
|
@@ -383,10 +328,10 @@ ours-tg-connector add_new_connection \
|
|
|
383
328
|
--bio "ACME forum, #billing topic"
|
|
384
329
|
|
|
385
330
|
ours-tg-connector list_connections # routes grouped by bot
|
|
386
|
-
ours-tg-connector remove_connection sales
|
|
331
|
+
ours-tg-connector remove_connection sales # removes the route and its name-listed daemon identity
|
|
387
332
|
ours-tg-connector remove_bot supportbot # refused while any route still uses it
|
|
388
333
|
|
|
389
|
-
#
|
|
334
|
+
# connector-process lifecycle (never starts or stops the shared ours daemon)
|
|
390
335
|
ours-tg-connector start | stop | restart | status
|
|
391
336
|
ours-tg-connector serve # foreground (debugging)
|
|
392
337
|
|
|
@@ -394,9 +339,6 @@ ours-tg-connector serve # foreground (debugging)
|
|
|
394
339
|
ours-tg-connector install-service # systemd (Linux) / launchd (macOS)
|
|
395
340
|
ours-tg-connector uninstall-service
|
|
396
341
|
|
|
397
|
-
# manage a bridge from the ours messenger control plane
|
|
398
|
-
ours-tg-connector cp_invite supportbot # invite to add the messenger as a contact
|
|
399
|
-
ours-tg-connector bind_proxy supportbot <contact> # start binding it (prints a 6-digit code)
|
|
400
342
|
```
|
|
401
343
|
|
|
402
344
|
`install-service` registers a **user-level** service running `serve`, bakes the
|
|
@@ -419,6 +361,13 @@ topic within that chat. `--bio` is the context the agent reads about this chat
|
|
|
419
361
|
route for any chat the bot sees that no other route claims. Reuse the same `--bot`
|
|
420
362
|
across routes to multiplex one bot over many chats/topics.
|
|
421
363
|
|
|
364
|
+
`remove_connection` releases that route's daemon lease, then removes the daemon
|
|
365
|
+
identity by its recorded route name and deletes the local route record. Because
|
|
366
|
+
the ownership list is intentionally name-only, an operator who manually removes
|
|
367
|
+
and recreates a same-name identity has deliberately replaced it; removing the
|
|
368
|
+
route can remove that replacement too. Use the `ours` operator CLI to repair
|
|
369
|
+
orphaned or deliberately replaced identities.
|
|
370
|
+
|
|
422
371
|
## Configuration
|
|
423
372
|
|
|
424
373
|
Precedence per field: **env var > `config.json` > default**. The config file is
|
|
@@ -426,7 +375,8 @@ Precedence per field: **env var > `config.json` > default**. The config file is
|
|
|
426
375
|
|
|
427
376
|
| field | env var | default |
|
|
428
377
|
|----------------|---------------------------|-------------------------------------------------|
|
|
429
|
-
|
|
|
378
|
+
| daemon URL | `OURS_TG_DAEMON_URL` | `''` (the SDK's own default selection) |
|
|
379
|
+
| daemon state dir | `OURS_TG_DAEMON_STATE_DIR` | `''` (the SDK's own default selection) |
|
|
430
380
|
| control port | `OURS_TG_CONTROL_PORT` | `3051` (localhost only) |
|
|
431
381
|
| state dir | `OURS_TG_STATE_DIR` | `~/.ours-telegram` |
|
|
432
382
|
| poll timeout | `OURS_TG_POLL_TIMEOUT` | `30` (seconds, Telegram long-poll) |
|
|
@@ -436,7 +386,7 @@ Precedence per field: **env var > `config.json` > default**. The config file is
|
|
|
436
386
|
| retry backoff | `OURS_TG_FETCH_RETRY_BASE_MS` | `300` (base delay between those retries; grows exponentially with jitter) |
|
|
437
387
|
| attachment cap | `OURS_TG_ATTACHMENT_MAX_BYTES` | `10485760` (10 MB; larger inbound media forwarded as a metadata-only stub) |
|
|
438
388
|
| 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) |
|
|
439
|
-
| STT enabled | `OURS_TG_STT_ENABLED` | `false` (
|
|
389
|
+
| STT enabled | `OURS_TG_STT_ENABLED` | `false` (whether **this connector** transcribes voice; the attached daemon runs its own STT regardless — see [Voice](#voice-messages--speech-to-text)) |
|
|
440
390
|
| STT API key | `OURS_TG_STT_API_KEY` | `''` (secret; env preferred — masked if placed in `config.json`, never logged) |
|
|
441
391
|
| STT base URL | `OURS_TG_STT_BASE_URL` | `https://api.openai.com/v1` (OpenAI-compatible endpoint root; e.g. `https://api.groq.com/openai/v1` or a self-hosted whisper server) |
|
|
442
392
|
| STT model | `OURS_TG_STT_MODEL` | `whisper-1` (e.g. `whisper-large-v3-turbo` on Groq) |
|
|
@@ -446,39 +396,28 @@ Precedence per field: **env var > `config.json` > default**. The config file is
|
|
|
446
396
|
| STT timeout | `OURS_TG_STT_TIMEOUT_MS` | `60000` (per-transcription abort deadline, ms) |
|
|
447
397
|
| forward voice audio | `OURS_TG_FORWARD_VOICE_AUDIO` | `false` (also `send_file` the `.ogg` alongside a successful transcript) |
|
|
448
398
|
|
|
399
|
+
`OURS_TG_DAEMON_URL` and `OURS_TG_DAEMON_STATE_DIR` are a coherent pair: set
|
|
400
|
+
both or neither. SDK 2 refuses an explicitly selected endpoint without its state
|
|
401
|
+
directory before reading a daemon token. Legacy `OURS_INSTANCE` is rejected, and
|
|
402
|
+
`OURS_AUTOSTART`/`autoStart` are ignored. This connector never embeds or starts an
|
|
403
|
+
ours daemon; operate the shared daemon separately with `ours daemon start` or
|
|
404
|
+
`ours daemon install-service`.
|
|
405
|
+
|
|
449
406
|
The control API is bound to `127.0.0.1` and unauthenticated — it manages bot
|
|
450
407
|
tokens, so do not expose the control port off-host.
|
|
451
408
|
|
|
452
|
-
## Control plane (
|
|
453
|
-
|
|
454
|
-
Each bridge is a self-sovereign ours node that can be **managed from the
|
|
455
|
-
ours messenger control plane** over the encrypted a2a_control
|
|
456
|
-
channel — no extra ports. The connector advertises an app manifest
|
|
457
|
-
(`network.ours.telegram-connector`) with a `core.configuration` capability, so the
|
|
458
|
-
messenger renders its generic config form for it. Two fields are configurable
|
|
459
|
-
live (no restart):
|
|
409
|
+
## Control plane (removed)
|
|
460
410
|
|
|
461
|
-
|
|
462
|
-
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
Bind it once:
|
|
468
|
-
|
|
469
|
-
```sh
|
|
470
|
-
# 1. add the messenger as a contact of the bridge node
|
|
471
|
-
ours-tg-connector cp_invite supportbot
|
|
472
|
-
# → paste the invite into the messenger (add contact / add node)
|
|
473
|
-
|
|
474
|
-
# 2. start the bind ceremony for that contact; read out the 6-digit code
|
|
475
|
-
ours-tg-connector bind_proxy supportbot <messenger-contact-name-or-cid>
|
|
476
|
-
# → enter the code in the messenger Control Panel (out-of-band, 5 min, 3 tries)
|
|
477
|
-
```
|
|
411
|
+
The connector used to be a **managed node**: it advertised an app manifest
|
|
412
|
+
(`network.ours.telegram-connector`) and the ours messenger could bind to it over
|
|
413
|
+
the a2a_control channel and edit the allowed chat id and denial message live.
|
|
414
|
+
That is gone — messenger manageability was removed by ruling, and with it the
|
|
415
|
+
`cp_invite` and `bind_proxy` commands, the `get_manifest` / `get_config` /
|
|
416
|
+
`set_config` verbs, and the bind ceremony.
|
|
478
417
|
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
418
|
+
A route is configured when it is created (`add_new_connection`) and changed by
|
|
419
|
+
removing it and adding it back. There is no live reconfiguration path, and
|
|
420
|
+
nothing to bind.
|
|
482
421
|
|
|
483
422
|
## Learn more
|
|
484
423
|
|