@ours.network/tg-connector 0.3.2 → 0.3.3-nightly.1

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 (96) hide show
  1. package/README.md +27 -35
  2. package/dist/cli.js +16 -68
  3. package/dist/connector.js +53220 -8213
  4. package/docs/voice-message-contract.md +8 -2
  5. package/package.json +3 -5
  6. package/dist/mufl_code/8A84AD8E225F186F666D3EAB2AFF777A4B9BB1B9C7CCF45CF364497EF16CF3E5.muflo +0 -0
  7. package/dist/mufl_code/actor.mu +0 -1833
  8. package/dist/mufl_code/config.mufl +0 -27
  9. package/dist/mufl_code/core/COMMERCIAL-LICENCE.md +0 -25
  10. package/dist/mufl_code/core/COMPATIBILITY.md +0 -221
  11. package/dist/mufl_code/core/CONTRIBUTING.md +0 -37
  12. package/dist/mufl_code/core/LICENSE +0 -98
  13. package/dist/mufl_code/core/NOTIFICATIONS_CONTRACT.md +0 -290
  14. package/dist/mufl_code/core/README.md +0 -91
  15. package/dist/mufl_code/core/SECURITY.md +0 -40
  16. package/dist/mufl_code/core/TRADEMARKS.md +0 -24
  17. package/dist/mufl_code/core/a2a_capabilities.mm +0 -449
  18. package/dist/mufl_code/core/a2a_cluster.mm +0 -601
  19. package/dist/mufl_code/core/a2a_control.mm +0 -90
  20. package/dist/mufl_code/core/a2a_messaging.mm +0 -4817
  21. package/dist/mufl_code/core/a2a_monitoring.mm +0 -94
  22. package/dist/mufl_code/core/a2a_notification_integration.mm +0 -144
  23. package/dist/mufl_code/core/a2a_notifications.mm +0 -1127
  24. package/dist/mufl_code/core/a2a_protocol.mm +0 -246
  25. package/dist/mufl_code/core/a2a_versions.mm +0 -801
  26. package/dist/mufl_code/core/config.mufl +0 -29
  27. package/dist/mufl_code/core/docs/.vitepress/config.mts +0 -58
  28. package/dist/mufl_code/core/docs/citations.json +0 -688
  29. package/dist/mufl_code/core/docs/guide/01-vendor-the-core.md +0 -50
  30. package/dist/mufl_code/core/docs/guide/02-configure-and-compile.md +0 -100
  31. package/dist/mufl_code/core/docs/guide/03-wire-the-host.md +0 -154
  32. package/dist/mufl_code/core/docs/guide/04-connect-and-message.md +0 -156
  33. package/dist/mufl_code/core/docs/guide/05-test-your-app.md +0 -75
  34. package/dist/mufl_code/core/docs/guide/index.md +0 -63
  35. package/dist/mufl_code/core/docs/how-it-works/capabilities-and-control.md +0 -77
  36. package/dist/mufl_code/core/docs/how-it-works/cluster.md +0 -65
  37. package/dist/mufl_code/core/docs/how-it-works/identity.md +0 -56
  38. package/dist/mufl_code/core/docs/how-it-works/invites-and-contacts.md +0 -76
  39. package/dist/mufl_code/core/docs/how-it-works/messaging.md +0 -55
  40. package/dist/mufl_code/core/docs/how-it-works/monitoring-and-config.md +0 -72
  41. package/dist/mufl_code/core/docs/how-it-works/overview.md +0 -45
  42. package/dist/mufl_code/core/docs/how-it-works/versioning.md +0 -116
  43. package/dist/mufl_code/core/docs/index.md +0 -27
  44. package/dist/mufl_code/core/docs/package-lock.json +0 -3467
  45. package/dist/mufl_code/core/docs/package.json +0 -15
  46. package/dist/mufl_code/core/docs/reference/contributing.md +0 -26
  47. package/dist/mufl_code/core/docs/reference/glossary.md +0 -108
  48. package/dist/mufl_code/core/docs/reference/implementations.md +0 -23
  49. package/dist/mufl_code/core/docs/reference/modules.md +0 -19
  50. package/dist/mufl_code/core/docs/scripts/check-citations.mjs +0 -36
  51. package/dist/mufl_code/core/docs/scripts/check-denylist.mjs +0 -30
  52. package/dist/mufl_code/core/docs/scripts/gen-llms.mjs +0 -32
  53. package/dist/mufl_code/core/docs/workflows/cluster.md +0 -89
  54. package/dist/mufl_code/core/docs/workflows/contact-exchange.md +0 -60
  55. package/dist/mufl_code/core/docs/workflows/contact-restore.md +0 -60
  56. package/dist/mufl_code/core/docs/workflows/control-verbs.md +0 -70
  57. package/dist/mufl_code/core/docs/workflows/index.md +0 -57
  58. package/dist/mufl_code/core/docs/workflows/introductions.md +0 -60
  59. package/dist/mufl_code/core/docs/workflows/messaging.md +0 -75
  60. package/dist/mufl_code/core/docs/workflows/monitoring.md +0 -84
  61. package/dist/mufl_code/core/docs/workflows/notifications.md +0 -109
  62. package/dist/mufl_code/core/release-notes/0.1.md +0 -60
  63. package/dist/mufl_code/core/release-notes/0.3.md +0 -22
  64. package/dist/mufl_code/core/release-notes/0.4.md +0 -97
  65. package/dist/mufl_code/core/tests/README.md +0 -83
  66. package/dist/mufl_code/core/tests/compat/README.md +0 -82
  67. package/dist/mufl_code/core/tests/compat/compat.mjs +0 -245
  68. package/dist/mufl_code/core/tests/compat/compat_peer.mjs +0 -146
  69. package/dist/mufl_code/core/tests/compat/run_compat.sh +0 -96
  70. package/dist/mufl_code/core/tests/corpus.mjs +0 -139
  71. package/dist/mufl_code/core/tests/corpus_actor.mu +0 -242
  72. package/dist/mufl_code/core/tests/fatcompile_actor.mu +0 -52
  73. package/dist/mufl_code/core/tests/mig.mjs +0 -805
  74. package/dist/mufl_code/core/tests/mig_actor.mu +0 -518
  75. package/dist/mufl_code/core/tests/migapp.mjs +0 -431
  76. package/dist/mufl_code/core/tests/migapp_actor.mu +0 -294
  77. package/dist/mufl_code/core/tests/mufl_semantics/run.sh +0 -69
  78. package/dist/mufl_code/core/tests/mufl_semantics/t11_three_version.mufl +0 -47
  79. package/dist/mufl_code/core/tests/mufl_semantics/t2_extra_fields.mufl +0 -11
  80. package/dist/mufl_code/core/tests/mufl_semantics/t7_runtime.mufl +0 -30
  81. package/dist/mufl_code/core/tests/mufl_semantics/t9_passthrough.mufl +0 -19
  82. package/dist/mufl_code/core/tests/mufl_semantics/t_str_order.mufl +0 -19
  83. package/dist/mufl_code/core/tests/notif.mjs +0 -755
  84. package/dist/mufl_code/core/tests/notif_actor.mu +0 -450
  85. package/dist/mufl_code/core/tests/protocol_container.mm +0 -18
  86. package/dist/mufl_code/core/tests/run.sh +0 -65
  87. package/dist/mufl_code/core/tests/run_corpus.sh +0 -51
  88. package/dist/mufl_code/core/tests/run_fatcompile.sh +0 -40
  89. package/dist/mufl_code/core/tests/run_mig.sh +0 -51
  90. package/dist/mufl_code/core/tests/run_migapp.sh +0 -51
  91. package/dist/mufl_code/core/tests/run_notif.sh +0 -57
  92. package/dist/mufl_code/core/tests/test.mjs +0 -750
  93. package/dist/mufl_code/core/tests/test_actor.mu +0 -564
  94. package/dist/mufl_code/core/tests/test_common.mjs +0 -93
  95. package/dist/mufl_code/core/version.mm +0 -24
  96. package/dist/mufl_code/protocol_container.mm +0 -18
package/README.md CHANGED
@@ -200,8 +200,15 @@ added for provenance:
200
200
  }
201
201
  ```
202
202
 
203
- - **Opt-in.** Off by default (`sttEnabled:false`) — behaviour is then byte-identical
204
- to today. Turn it on and supply a key (see [Configuration](#configuration)).
203
+ - **Opt-in, and it covers THIS PROCESS ONLY.** Off by default
204
+ (`sttEnabled:false`), which means *the connector* sends no audio to a
205
+ speech-to-text provider. It does **not** mean the audio is never transcribed:
206
+ the connector is a client of an ours daemon, and **the daemon runs its own
207
+ speech-to-text** when the receiving side pulls a voice note — under
208
+ configuration this connector's operator does not control and may not know
209
+ exists. When the connector was its own host, `sttEnabled:false` did cover the
210
+ whole path; attached, it no longer can. Turn it on and supply a key to
211
+ transcribe here as well (see [Configuration](#configuration)).
205
212
  - **No transcoding.** Telegram voice is **OGG/Opus**, which OpenAI-compatible
206
213
  transcription endpoints accept directly — the connector adds **no ffmpeg** and no
207
214
  new dependency (just built-in `fetch`).
@@ -255,9 +262,11 @@ npm install
255
262
  npm run build
256
263
  ```
257
264
 
258
- Requires Node ≥ 20. The native ADAPT SDK (`@adapt-toolkit/sdk` +
259
- `@adapt-toolkit/sdk-native`, pinned to the version matching the shipped
260
- `.muflo`) is resolved from `node_modules` at runtime.
265
+ Requires Node ≥ 20, and **an ours daemon already running on this box** — the
266
+ connector attaches to it over `/api/v1` and drives it through
267
+ [`@ours.network/sdk`](https://www.npmjs.com/package/@ours.network/sdk). It runs
268
+ no engine of its own: there is no native ADAPT SDK and no MUFL packet here, so
269
+ nothing beyond `npm install` is resolved at runtime.
261
270
 
262
271
  ## Usage
263
272
 
@@ -330,7 +339,8 @@ Precedence per field: **env var > `config.json` > default**. The config file is
330
339
 
331
340
  | field | env var | default |
332
341
  |----------------|---------------------------|-------------------------------------------------|
333
- | broker URL | `OURS_TG_BROKER_URL` | `wss://broker1.ours.network` |
342
+ | daemon URL | `OURS_TG_DAEMON_URL` | `''` (the SDK's own default selection) |
343
+ | daemon state dir | `OURS_TG_DAEMON_STATE_DIR` | `''` (the SDK's own default selection) |
334
344
  | control port | `OURS_TG_CONTROL_PORT` | `3051` (localhost only) |
335
345
  | state dir | `OURS_TG_STATE_DIR` | `~/.ours-telegram` |
336
346
  | poll timeout | `OURS_TG_POLL_TIMEOUT` | `30` (seconds, Telegram long-poll) |
@@ -340,7 +350,7 @@ Precedence per field: **env var > `config.json` > default**. The config file is
340
350
  | retry backoff | `OURS_TG_FETCH_RETRY_BASE_MS` | `300` (base delay between those retries; grows exponentially with jitter) |
341
351
  | attachment cap | `OURS_TG_ATTACHMENT_MAX_BYTES` | `10485760` (10 MB; larger inbound media forwarded as a metadata-only stub) |
342
352
  | 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) |
343
- | STT enabled | `OURS_TG_STT_ENABLED` | `false` (master switch for voice transcription; off ⇒ byte-identical to today) |
353
+ | 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)) |
344
354
  | STT API key | `OURS_TG_STT_API_KEY` | `''` (secret; env preferred — masked if placed in `config.json`, never logged) |
345
355
  | 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) |
346
356
  | STT model | `OURS_TG_STT_MODEL` | `whisper-1` (e.g. `whisper-large-v3-turbo` on Groq) |
@@ -353,36 +363,18 @@ Precedence per field: **env var > `config.json` > default**. The config file is
353
363
  The control API is bound to `127.0.0.1` and unauthenticated — it manages bot
354
364
  tokens, so do not expose the control port off-host.
355
365
 
356
- ## Control plane (ours messenger)
366
+ ## Control plane (removed)
357
367
 
358
- Each bridge is a self-sovereign ours node that can be **managed from the
359
- ours messenger control plane** over the encrypted a2a_control
360
- channel — no extra ports. The connector advertises an app manifest
361
- (`network.ours.telegram-connector`) with a `core.configuration` capability, so the
362
- messenger renders its generic config form for it. Two fields are configurable
363
- live (no restart):
368
+ The connector used to be a **managed node**: it advertised an app manifest
369
+ (`network.ours.telegram-connector`) and the ours messenger could bind to it over
370
+ the a2a_control channel and edit the allowed chat id and denial message live.
371
+ That is gone — messenger manageability was removed by ruling, and with it the
372
+ `cp_invite` and `bind_proxy` commands, the `get_manifest` / `get_config` /
373
+ `set_config` verbs, and the bind ceremony.
364
374
 
365
- - **Allowed chat ID** — only this chat is proxied to the agent.
366
- - **Denial message** — what any other chat is told.
367
-
368
- (The bot token is *not* CP-configurable: the messenger strips secret-field values
369
- on save, so the token stays set at connection creation.)
370
-
371
- Bind it once:
372
-
373
- ```sh
374
- # 1. add the messenger as a contact of the bridge node
375
- ours-tg-connector cp_invite supportbot
376
- # → paste the invite into the messenger (add contact / add node)
377
-
378
- # 2. start the bind ceremony for that contact; read out the 6-digit code
379
- ours-tg-connector bind_proxy supportbot <messenger-contact-name-or-cid>
380
- # → enter the code in the messenger Control Panel (out-of-band, 5 min, 3 tries)
381
- ```
382
-
383
- Once bound, the messenger can pull the manifest, render the config form, and push
384
- changes (`get_manifest` / `get_config` / `set_config`). Config verbs are gated:
385
- only the bound control plane may read or write the configuration.
375
+ A route is configured when it is created (`add_new_connection`) and changed by
376
+ removing it and adding it back. There is no live reconfiguration path, and
377
+ nothing to bind.
386
378
 
387
379
  ## Learn more
388
380
 
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
+ import { createRequire as __tgCreateRequire } from 'node:module'; const require = __tgCreateRequire(import.meta.url);
3
3
 
4
4
  // src/cli.ts
5
5
  import { spawn, spawnSync } from "node:child_process";
@@ -14,7 +14,8 @@ import * as fs from "node:fs";
14
14
  import { homedir } from "node:os";
15
15
  import { resolve, join, dirname } from "node:path";
16
16
  var DEFAULT_CONFIG = {
17
- brokerUrl: "wss://broker1.ours.network",
17
+ daemonUrl: "",
18
+ daemonStateDir: "",
18
19
  controlPort: 3051,
19
20
  stateDir: resolve(homedir(), ".ours-telegram"),
20
21
  pollTimeoutSec: 30,
@@ -54,7 +55,8 @@ function readFileConfig() {
54
55
  return {};
55
56
  }
56
57
  const out2 = {};
57
- if (typeof parsed.brokerUrl === "string") out2.brokerUrl = parsed.brokerUrl;
58
+ if (typeof parsed.daemonUrl === "string") out2.daemonUrl = parsed.daemonUrl;
59
+ if (typeof parsed.daemonStateDir === "string") out2.daemonStateDir = resolve(parsed.daemonStateDir);
58
60
  if (typeof parsed.controlPort === "number" && Number.isFinite(parsed.controlPort)) out2.controlPort = parsed.controlPort;
59
61
  if (typeof parsed.stateDir === "string") out2.stateDir = resolve(parsed.stateDir);
60
62
  if (typeof parsed.pollTimeoutSec === "number" && Number.isFinite(parsed.pollTimeoutSec)) {
@@ -101,7 +103,11 @@ function envBool(name) {
101
103
  function loadConfig() {
102
104
  const file = readFileConfig();
103
105
  return {
104
- brokerUrl: process.env.OURS_TG_BROKER_URL ?? file.brokerUrl ?? DEFAULT_CONFIG.brokerUrl,
106
+ // NOTE: no OURS_TG_BROKER_URL any more. The connector does not talk to a
107
+ // broker — the daemon does. A stale one in a config file is now ignored
108
+ // rather than half-honoured.
109
+ daemonUrl: process.env.OURS_TG_DAEMON_URL ?? file.daemonUrl ?? DEFAULT_CONFIG.daemonUrl,
110
+ daemonStateDir: process.env.OURS_TG_DAEMON_STATE_DIR ?? file.daemonStateDir ?? DEFAULT_CONFIG.daemonStateDir,
105
111
  controlPort: envInt("OURS_TG_CONTROL_PORT") ?? file.controlPort ?? DEFAULT_CONFIG.controlPort,
106
112
  stateDir: resolve(process.env.OURS_TG_STATE_DIR ?? file.stateDir ?? DEFAULT_CONFIG.stateDir),
107
113
  pollTimeoutSec: envInt("OURS_TG_POLL_TIMEOUT") ?? file.pollTimeoutSec ?? DEFAULT_CONFIG.pollTimeoutSec,
@@ -212,7 +218,7 @@ async function cmdStart() {
212
218
  const ready = await waitForPort(PORT);
213
219
  if (ready) {
214
220
  out(`up on ${BASE}`);
215
- out(` broker: ${CONFIG.brokerUrl}`);
221
+ out(` daemon: ${CONFIG.daemonUrl || "(default selection)"}`);
216
222
  out(` state: ${STATE_DIR}`);
217
223
  out(` logs: ${LOG_PATH}`);
218
224
  } else {
@@ -257,7 +263,7 @@ async function cmdStatus() {
257
263
  out("ours-tg-connector: running");
258
264
  if (pid) out(` pid: ${pid}`);
259
265
  out(` url: ${BASE} ${up ? "(reachable)" : "(port not answering!)"}`);
260
- out(` broker: ${CONFIG.brokerUrl}`);
266
+ out(` daemon: ${CONFIG.daemonUrl || "(default selection)"}`);
261
267
  out(` state: ${STATE_DIR}`);
262
268
  out(` logs: ${LOG_PATH}`);
263
269
  if (up) {
@@ -458,54 +464,6 @@ async function cmdListConnections() {
458
464
  }
459
465
  }
460
466
  }
461
- async function cmdCpInvite(name) {
462
- if (!name) {
463
- err("cp_invite requires a connection name.");
464
- process.exit(1);
465
- }
466
- if (!await portOpen(PORT)) {
467
- err("daemon not running \u2014 start it first.");
468
- process.exit(1);
469
- }
470
- const res = await fetch(`${BASE}/connections/${encodeURIComponent(name)}/cp-invite`, { method: "POST" });
471
- const body = await res.json();
472
- if (!body.ok || !body.invite) {
473
- err(`cp_invite failed: ${body.error ?? `HTTP ${res.status}`}`);
474
- process.exit(1);
475
- }
476
- out("");
477
- out(`Add the messenger control plane as a contact of "${name}".`);
478
- out("Paste this invite into the messenger (add contact / add node):");
479
- out("");
480
- out(body.invite);
481
- out("");
482
- out(`Once it is a contact, bind it: ours-tg-connector bind_proxy ${name} <contact-name-or-cid>`);
483
- }
484
- async function cmdBindProxy(name, contact) {
485
- if (!name || !contact) {
486
- err("bind_proxy requires <connection-name> <contact-name-or-cid>.");
487
- process.exit(1);
488
- }
489
- if (!await portOpen(PORT)) {
490
- err("daemon not running \u2014 start it first.");
491
- process.exit(1);
492
- }
493
- const res = await fetch(`${BASE}/connections/${encodeURIComponent(name)}/bind`, {
494
- method: "POST",
495
- headers: { "Content-Type": "application/json" },
496
- body: JSON.stringify({ contact })
497
- });
498
- const body = await res.json();
499
- if (!body.ok || !body.code) {
500
- err(`bind_proxy failed: ${body.error ?? `HTTP ${res.status}`}`);
501
- process.exit(1);
502
- }
503
- out("");
504
- out(`Verification code: ${body.code}`);
505
- out("");
506
- out("Enter it in the messenger Control Panel within 5 minutes (3 attempts).");
507
- out("Do NOT send it over ours \u2014 it must travel out-of-band (this terminal counts).");
508
- }
509
467
  async function cmdRemoveConnection(name) {
510
468
  if (!name) {
511
469
  err("remove_connection requires a connection name.");
@@ -537,7 +495,8 @@ function run(cmd, args) {
537
495
  }
538
496
  function serviceEnv() {
539
497
  return {
540
- OURS_TG_BROKER_URL: CONFIG.brokerUrl,
498
+ OURS_TG_DAEMON_URL: CONFIG.daemonUrl,
499
+ OURS_TG_DAEMON_STATE_DIR: CONFIG.daemonStateDir,
541
500
  OURS_TG_CONTROL_PORT: String(CONFIG.controlPort),
542
501
  OURS_TG_STATE_DIR: STATE_DIR,
543
502
  OURS_TG_POLL_TIMEOUT: String(CONFIG.pollTimeoutSec)
@@ -675,10 +634,6 @@ function usage() {
675
634
  out(" list_connections list configured routes grouped by bot");
676
635
  out(" remove_connection <name> delete a route and its state");
677
636
  out("");
678
- out(" control plane (ours messenger):");
679
- out(" cp_invite <name> print an invite to add the messenger as a contact");
680
- out(" bind_proxy <name> <contact> start binding the messenger as control plane (prints a 6-digit code)");
681
- out("");
682
637
  out(" start start the daemon in the background");
683
638
  out(" stop stop the running daemon");
684
639
  out(" restart stop then start");
@@ -690,7 +645,8 @@ function usage() {
690
645
  out("");
691
646
  out("Config precedence (per field): env var > config.json > default.");
692
647
  out(" config.json: OURS_TG_CONFIG, else ~/.ours-telegram/config.json");
693
- out(" env: OURS_TG_BROKER_URL, OURS_TG_CONTROL_PORT (3051), OURS_TG_STATE_DIR, OURS_TG_POLL_TIMEOUT (30)");
648
+ out(" env: OURS_TG_DAEMON_URL + OURS_TG_DAEMON_STATE_DIR (both, or neither), OURS_TG_CONTROL_PORT (3051),");
649
+ out(" OURS_TG_STATE_DIR, OURS_TG_POLL_TIMEOUT (30)");
694
650
  }
695
651
  async function main() {
696
652
  const cmd = process.argv[2] ?? "help";
@@ -741,14 +697,6 @@ async function main() {
741
697
  case "remove":
742
698
  await cmdRemoveConnection(process.argv[3]);
743
699
  break;
744
- case "cp_invite":
745
- case "cp-invite":
746
- await cmdCpInvite(process.argv[3]);
747
- break;
748
- case "bind_proxy":
749
- case "bind-proxy":
750
- await cmdBindProxy(process.argv[3], process.argv[4]);
751
- break;
752
700
  case "start":
753
701
  await cmdStart();
754
702
  break;