@ours.network/tg-connector 0.1.7 → 0.1.8-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.
Files changed (99) hide show
  1. package/dist/connector.js +74 -0
  2. package/dist/mufl_code/D812C6070397B0EB11D66D6D33D931C35E9442ACC141C35C51A7904A082B19E0.muflo +0 -0
  3. package/dist/mufl_code/actor.mu +27 -0
  4. package/dist/mufl_code/core/COMMERCIAL-LICENCE.md +25 -0
  5. package/dist/mufl_code/core/COMPATIBILITY.md +221 -0
  6. package/dist/mufl_code/core/CONTRIBUTING.md +37 -0
  7. package/dist/mufl_code/core/LICENSE +1 -1
  8. package/dist/mufl_code/core/NOTIFICATIONS_CONTRACT.md +290 -0
  9. package/dist/mufl_code/core/README.md +64 -49
  10. package/dist/mufl_code/core/SECURITY.md +40 -0
  11. package/dist/mufl_code/core/TRADEMARKS.md +24 -0
  12. package/dist/mufl_code/core/a2a_capabilities.mm +76 -1
  13. package/dist/mufl_code/core/a2a_control.mm +2 -1
  14. package/dist/mufl_code/core/a2a_messaging.mm +1677 -25
  15. package/dist/mufl_code/core/a2a_notifications.mm +1102 -0
  16. package/dist/mufl_code/core/a2a_protocol.mm +16 -1
  17. package/dist/mufl_code/core/a2a_versions.mm +801 -0
  18. package/dist/mufl_code/core/config.mufl +2 -0
  19. package/dist/mufl_code/core/docs/.vitepress/config.mts +58 -0
  20. package/dist/mufl_code/core/docs/citations.json +688 -0
  21. package/dist/mufl_code/core/docs/guide/01-vendor-the-core.md +50 -0
  22. package/dist/mufl_code/core/docs/guide/02-configure-and-compile.md +100 -0
  23. package/dist/mufl_code/core/docs/guide/03-wire-the-host.md +154 -0
  24. package/dist/mufl_code/core/docs/guide/04-connect-and-message.md +156 -0
  25. package/dist/mufl_code/core/docs/guide/05-test-your-app.md +75 -0
  26. package/dist/mufl_code/core/docs/guide/index.md +63 -0
  27. package/dist/mufl_code/core/docs/how-it-works/capabilities-and-control.md +77 -0
  28. package/dist/mufl_code/core/docs/how-it-works/cluster.md +65 -0
  29. package/dist/mufl_code/core/docs/how-it-works/identity.md +56 -0
  30. package/dist/mufl_code/core/docs/how-it-works/invites-and-contacts.md +76 -0
  31. package/dist/mufl_code/core/docs/how-it-works/messaging.md +55 -0
  32. package/dist/mufl_code/core/docs/how-it-works/monitoring-and-config.md +72 -0
  33. package/dist/mufl_code/core/docs/how-it-works/overview.md +45 -0
  34. package/dist/mufl_code/core/docs/how-it-works/versioning.md +116 -0
  35. package/dist/mufl_code/core/docs/index.md +27 -0
  36. package/dist/mufl_code/core/docs/package-lock.json +3467 -0
  37. package/dist/mufl_code/core/docs/package.json +15 -0
  38. package/dist/mufl_code/core/docs/reference/contributing.md +26 -0
  39. package/dist/mufl_code/core/docs/reference/glossary.md +108 -0
  40. package/dist/mufl_code/core/docs/reference/implementations.md +23 -0
  41. package/dist/mufl_code/core/docs/reference/modules.md +19 -0
  42. package/dist/mufl_code/core/docs/scripts/check-citations.mjs +36 -0
  43. package/dist/mufl_code/core/docs/scripts/check-denylist.mjs +30 -0
  44. package/dist/mufl_code/core/docs/scripts/gen-llms.mjs +32 -0
  45. package/dist/mufl_code/core/docs/workflows/cluster.md +89 -0
  46. package/dist/mufl_code/core/docs/workflows/contact-exchange.md +60 -0
  47. package/dist/mufl_code/core/docs/workflows/contact-restore.md +60 -0
  48. package/dist/mufl_code/core/docs/workflows/control-verbs.md +70 -0
  49. package/dist/mufl_code/core/docs/workflows/index.md +57 -0
  50. package/dist/mufl_code/core/docs/workflows/introductions.md +60 -0
  51. package/dist/mufl_code/core/docs/workflows/messaging.md +75 -0
  52. package/dist/mufl_code/core/docs/workflows/monitoring.md +84 -0
  53. package/dist/mufl_code/core/docs/workflows/notifications.md +109 -0
  54. package/dist/mufl_code/core/release-notes/0.1.md +60 -0
  55. package/dist/mufl_code/core/release-notes/0.3.md +22 -0
  56. package/dist/mufl_code/core/release-notes/0.4.md +97 -0
  57. package/dist/mufl_code/core/tests/README.md +17 -0
  58. package/dist/mufl_code/core/tests/corpus.mjs +139 -0
  59. package/dist/mufl_code/core/tests/corpus_actor.mu +242 -0
  60. package/dist/mufl_code/core/tests/fatcompile_actor.mu +52 -0
  61. package/dist/mufl_code/core/tests/mig.mjs +664 -0
  62. package/dist/mufl_code/core/tests/mig_actor.mu +466 -0
  63. package/dist/mufl_code/core/tests/migapp.mjs +431 -0
  64. package/dist/mufl_code/core/tests/migapp_actor.mu +294 -0
  65. package/dist/mufl_code/core/tests/mufl_semantics/run.sh +69 -0
  66. package/dist/mufl_code/core/tests/mufl_semantics/t11_three_version.mufl +47 -0
  67. package/dist/mufl_code/core/tests/mufl_semantics/t2_extra_fields.mufl +11 -0
  68. package/dist/mufl_code/core/tests/mufl_semantics/t7_runtime.mufl +30 -0
  69. package/dist/mufl_code/core/tests/mufl_semantics/t9_passthrough.mufl +19 -0
  70. package/dist/mufl_code/core/tests/mufl_semantics/t_str_order.mufl +19 -0
  71. package/dist/mufl_code/core/tests/notif.mjs +689 -0
  72. package/dist/mufl_code/core/tests/notif_actor.mu +458 -0
  73. package/dist/mufl_code/core/tests/protocol_container.mm +18 -0
  74. package/dist/mufl_code/core/tests/run.sh +8 -10
  75. package/dist/mufl_code/core/tests/run_corpus.sh +51 -0
  76. package/dist/mufl_code/core/tests/run_fatcompile.sh +40 -0
  77. package/dist/mufl_code/core/tests/run_mig.sh +51 -0
  78. package/dist/mufl_code/core/tests/run_migapp.sh +51 -0
  79. package/dist/mufl_code/core/tests/run_notif.sh +55 -0
  80. package/dist/mufl_code/core/tests/test.mjs +291 -49
  81. package/dist/mufl_code/core/tests/test_actor.mu +240 -7
  82. package/dist/mufl_code/core/tests/test_common.mjs +93 -0
  83. package/dist/mufl_code/core/version.mm +1 -1
  84. package/package.json +4 -4
  85. package/dist/mufl_code/2DA1D5F860E42C605D92F1E24E2466C70EFDDBF057BBCBA52F0ECC639EFCA387.muflo +0 -0
  86. package/dist/mufl_code/core/CLUSTER_API.md +0 -640
  87. package/dist/mufl_code/core/CLUSTER_CONTRACT.md +0 -121
  88. package/dist/mufl_code/core/CLUSTER_INTRODUCTION_PLAN.md +0 -200
  89. package/dist/mufl_code/core/CONFIGURATION_DESIGN.md +0 -35
  90. package/dist/mufl_code/core/CONFIGURATION_PLAN.md +0 -394
  91. package/dist/mufl_code/core/DEVELOPMENT.md +0 -168
  92. package/dist/mufl_code/core/EPHEMERAL_INVITE_PLAN.md +0 -465
  93. package/dist/mufl_code/core/GROUP_CHAT_DESIGN.md +0 -520
  94. package/dist/mufl_code/core/release-notes/2.0.md +0 -268
  95. package/dist/mufl_code/core/release-notes/2.1.md +0 -92
  96. package/dist/mufl_code/core/release-notes/2.2.md +0 -94
  97. package/dist/mufl_code/core/release-notes/3.0.md +0 -162
  98. package/dist/mufl_code/core/release-notes/3.1.md +0 -43
  99. package/dist/mufl_code/core/release-notes/README.md +0 -32
@@ -1,4 +1,5 @@
1
- // Self-contained test actor for the core-3.0 ephemeral-invite suite.
1
+ // Self-contained test actor for the core-3.0 ephemeral-invite suite
2
+ // (T/V/RC-series; the a2a_notifications N-series moved to notif_actor.mu).
2
3
  //
3
4
  // DERIVED locally for the core repo — it does NOT vendor any consumer/daemon
4
5
  // source. It loads only the shared core libraries this suite exercises
@@ -8,6 +9,15 @@
8
9
  // a delegation chain), export/import wrappers (migration scenario), and the
9
10
  // `qa_*` probe trns the driver uses to inject adversarial inputs and read state.
10
11
  //
12
+ // It does NOT load a2a_notifications: the compiler bounds meta-stage type-level
13
+ // reduction PER COMPILED UNIT (adapt src/eval/meta_reduction_fuel.h, 1M steps).
14
+ // Loading BOTH a2a_messaging AND a2a_notifications, after the 0.9.0 migration
15
+ // surface landed in a2a_messaging, tips this unit OVER the ceiling. a2a_messaging
16
+ // has ZERO references to a2a_notifications (the dep is one-way), so the
17
+ // notification tests split cleanly into notif_actor.mu (which loads both libs and
18
+ // keeps the COMBINED core+notify export/import round-trip). This unit keeps only
19
+ // the core-half export/import round-trip.
20
+ //
11
21
  // It does NOT load a2a_control / a2a_cluster / a2a_monitoring / a2a_capabilities-
12
22
  // init: the invite redeem flow, send_message, the hierarchy chain, and
13
23
  // export/import do not depend on them. The redeem transactions themselves
@@ -25,6 +35,8 @@ application actor loads libraries
25
35
  key_storage,
26
36
  continuation,
27
37
  encrypted_channel,
38
+ a2a_versions,
39
+ a2a_capabilities,
28
40
  a2a_protocol,
29
41
  a2a_messaging,
30
42
  current_transaction_info,
@@ -52,6 +64,9 @@ application actor loads libraries
52
64
  fn _return_data (payload: any) = (transaction::action::return_data ($kind -> $data, $payload -> payload)).
53
65
  fn _notify_agent (payload: any) = (transaction::action::return_data ($kind -> $notify_agent, $payload -> payload)).
54
66
 
67
+ // Receipt consumer log (core 0.7.0) — the driver's RC-series probe.
68
+ receipts_log is any[] = [].
69
+
55
70
  // Storage hooks: deposit inbound messages; send/remove are no-ops.
56
71
  a2a_messaging::init (
57
72
  $_read_or_abort -> _read_or_abort,
@@ -80,8 +95,14 @@ application actor loads libraries
80
95
  files (_count files|) -> ($sender -> sid, $filename -> fname, $mime -> mt, $wire_id -> wid, $reply_wire -> rw).
81
96
  return [ _notify_agent ($event -> $file_received), _save_state NIL ].
82
97
  },
83
- $on_file_sent -> fn (_: any) -> transaction::action::type[] { return []. }
98
+ $on_file_sent -> fn (_: any) -> transaction::action::type[] { return []. },
99
+ $on_receipt_received -> fn (arg: any) -> transaction::action::type[]
100
+ {
101
+ receipts_log (_count receipts_log|) -> arg.
102
+ return [ _notify_agent ($event -> $receipt_received), _save_state NIL ].
103
+ }
84
104
  ).
105
+
85
106
  }
86
107
 
87
108
  // ---- minimal host surface used by the driver ----
@@ -90,6 +111,7 @@ application actor loads libraries
90
111
  trn receive_message args: any { return a2a_messaging::handle_receive_message args. }
91
112
  trn readonly list_incoming_messages _ { return ($inbox -> inbox). }
92
113
  trn readonly list_incoming_files _ { return ($files -> files). }
114
+
93
115
  // Exercises the metadata-only file monitoring summary directly (the loopback has
94
116
  // no bound control plane, so the format + byte-secrecy are asserted on the helper).
95
117
  trn qa_file_summary _:($filename -> f: str, $mime -> m: str, $data -> d: bin)
@@ -131,7 +153,10 @@ application actor loads libraries
131
153
  return transaction::success [ _return_data ($profile -> (_write profile)) ].
132
154
  }
133
155
 
134
- trn set_delegation _:($cert -> cert_blob: bin, $root_ad -> root_ad_blob: bin, $root_profile -> rp_blob: bin)
156
+ // $cert_v1 (NULLABLE): the SAME chain minted over my v1 (bundle-less) AD, so a
157
+ // down-level to a pre-E2E peer carries a cert whose $role_ad_hash matches the v1
158
+ // AD that peer receives. Verified against _value_id(produce_v1_address_document()).
159
+ trn set_delegation _:($cert -> cert_blob: bin, $root_ad -> root_ad_blob: bin, $root_profile -> rp_blob: bin, $cert_v1 -> cert_v1_blob: bin+)
135
160
  {
136
161
  current_transaction_info::validate_origin_or_abort (transaction::envelope::origin::user,).
137
162
  cert = (_read_or_abort cert_blob) safe a2a_protocol::delegation_cert_t.
@@ -146,12 +171,33 @@ application actor loads libraries
146
171
  a2a_messaging::delegation_cert -> cert.
147
172
  a2a_messaging::root_ad -> new_root_ad.
148
173
  a2a_messaging::root_profile -> rp.
174
+ if cert_v1_blob != NIL
175
+ {
176
+ cert_v1 = (_read_or_abort cert_v1_blob?) safe a2a_protocol::delegation_cert_t.
177
+ v1_ad = address_document::get_my_address_document_versioned(TRUE).
178
+ abort "v1 cert not for me." when (cert_v1 $c $role_cid) != _get_container_id().
179
+ abort "v1 cert AD mismatch." when (cert_v1 $c $role_ad_hash) != (_value_id v1_ad).
180
+ abort "v1 cert root mismatch." when (cert_v1 $c $root_cid) != (cert $c $root_cid).
181
+ abort "v1 cert not root-signed." when key_storage::check_signature_new_container (_value_id (cert_v1 $c)) (cert_v1 $s) (new_root_ad $identity $key_list) != TRUE.
182
+ a2a_messaging::delegation_cert_v1 -> cert_v1.
183
+ }
149
184
  return transaction::success [ _return_data ($delegated -> TRUE), _save_state NIL ].
150
185
  }
151
186
 
187
+ // Expose my v1 (bundle-less) AD so the root can sign a v1-bound delegation cert
188
+ // (the daemon mints this by calling sign_delegation with this blob).
189
+ trn export_v1_address_document _
190
+ {
191
+ v1_ad = address_document::get_my_address_document_versioned(TRUE).
192
+ return transaction::success [ _return_data ($ad -> (_write v1_ad)) ].
193
+ }
194
+
152
195
  // export/import wrappers (migration scenario): the core state under $core, as a
153
196
  // host would compose it. (The app inbox is not part of this suite's migration
154
197
  // assertions, so it is omitted to keep the fixture minimal.)
198
+ // CORE-ONLY (this unit no longer loads a2a_notifications): the COMBINED
199
+ // core+notify round-trip moved to notif_actor.mu/notif.mjs (the unit that
200
+ // loads both libraries). test_actor keeps only the core-half round-trip.
155
201
  trn readonly export_state _ { return ($core -> (a2a_messaging::export_core_state NIL)). }
156
202
  trn import_state data: any
157
203
  {
@@ -208,7 +254,11 @@ application actor loads libraries
208
254
  {
209
255
  inv = (_read_or_abort blob) safe a2a_protocol::invite_eph_t.
210
256
  kpr = _crypto_construct_encryption_keypair (inv $v).
211
- foreign = (_read_or_abort fad) safe address_document_types::t_address_document.
257
+ // Bound `any`, not `safe t_address_document`: the AD is embedded as the
258
+ // `$ad -> any` payload field and re-verified downstream; casting to the
259
+ // full AD type here needlessly deepens meta-stage type reduction (AD-v2
260
+ // embeds t_e2e_bundle) — the per-unit fuel budget is scarce (corpus split).
261
+ foreign = _read_or_abort fad.
212
262
  payload = _write ($ad -> foreign, $cert -> NIL, $root_profile -> NIL, $cp_binding -> NIL, $invite_id -> (inv $d)).
213
263
  data = _crypto_encrypt_message (kpr $secret_key) (inv $k) payload.
214
264
  return transaction::success [
@@ -221,7 +271,7 @@ application actor loads libraries
221
271
  inv = (_read_or_abort blob) safe a2a_protocol::invite_eph_t.
222
272
  kpr = _crypto_construct_encryption_keypair (inv $v).
223
273
  my_ad = address_document::get_my_address_document().
224
- forged is address_document_types::t_address_document = ($version -> (my_ad $version), $identity -> (my_ad $identity), $authorizations -> (,)).
274
+ forged = ($version -> (my_ad $version), $identity -> (my_ad $identity), $authorizations -> (,)). // untyped: embedded as $ad -> any, verified downstream (fuel budget)
225
275
  payload = _write ($ad -> forged, $cert -> NIL, $root_profile -> NIL, $cp_binding -> NIL, $invite_id -> (inv $d)).
226
276
  data = _crypto_encrypt_message (kpr $secret_key) (inv $k) payload.
227
277
  return transaction::success [
@@ -255,6 +305,188 @@ application actor loads libraries
255
305
  ].
256
306
  }
257
307
 
308
+ // ---- cross-version leg-1 senders (PLAN Step 4.1) ----
309
+ // Emit a submit_invite_response whose BOXED payload is the EXACT wire shape
310
+ // of a given core version's sender — the 0.2.0 ($shape "v2": no $name, no
311
+ // $pv), 0.3.0 ("v3": +$name), 0.5.0 ("v5": +$pv/$caps), or a BELOW-FLOOR
312
+ // dialect ("too_old": v2 fields + $pv -> 1, the Addition A/B injection).
313
+ // Sender-side emulation only: the responder-side completion stores are
314
+ // hidden (INV-4), so the inviter-side outcome + the leg-3 ARRIVAL at this
315
+ // packet (visible as its gate abort) are what the driver asserts.
316
+ trn qa_send_versioned_leg1 _:($invite -> blob: bin, $shape -> shape: str, $name -> name: str)
317
+ {
318
+ current_transaction_info::validate_origin_or_abort (transaction::envelope::origin::user,).
319
+ inv = (_read_or_abort blob) safe a2a_protocol::invite_eph_t.
320
+ kpr = _crypto_construct_encryption_keypair (inv $v).
321
+ my_ad = address_document::get_my_address_document().
322
+
323
+ payload is bin+ = NIL.
324
+ if shape == "v2"
325
+ {
326
+ payload -> (_write ($ad -> my_ad, $cert -> NIL, $root_profile -> NIL, $cp_binding -> NIL, $invite_id -> (inv $d))).
327
+ }
328
+ if shape == "v3"
329
+ {
330
+ payload -> (_write ($ad -> my_ad, $cert -> NIL, $root_profile -> NIL, $cp_binding -> NIL, $invite_id -> (inv $d), $name -> name)).
331
+ }
332
+ if shape == "v5"
333
+ {
334
+ // literal 5: this shape emulates a 0.5.0 sender (wire_version moved on).
335
+ payload -> (_write ($ad -> my_ad, $cert -> NIL, $root_profile -> NIL, $cp_binding -> NIL, $invite_id -> (inv $d), $name -> name, $pv -> 5, $caps -> ["core.notifications"])).
336
+ }
337
+ if shape == "too_old"
338
+ {
339
+ payload -> (_write ($ad -> my_ad, $cert -> NIL, $root_profile -> NIL, $cp_binding -> NIL, $invite_id -> (inv $d), $pv -> 1)).
340
+ }
341
+ abort "qa_send_versioned_leg1: unknown shape " + shape when payload == NIL.
342
+
343
+ data = _crypto_encrypt_message (kpr $secret_key) (inv $k) payload?.
344
+ return transaction::success [
345
+ transaction::action::send (inv $c) (
346
+ $name -> "::a2a_messaging::submit_invite_response",
347
+ $targ -> ($invite_id -> (inv $d), $epk -> (kpr $public_key), $v -> (inv $v), $data -> data)
348
+ ),
349
+ _return_data ($sent -> TRUE, $shape -> shape)
350
+ ].
351
+ }
352
+
353
+ // Passive version learning probe: the contact_pv map (cid -> learned wire
354
+ // dialect; absent = nothing learned yet, 0 = pre-0.5 peer).
355
+ trn readonly qa_contact_pv _
356
+ {
357
+ return ($contact_pv -> a2a_messaging::contact_pv, $contact_caps -> a2a_messaging::contact_caps).
358
+ }
359
+
360
+ // Per-cid probes (precise driver assertions, no map-dump parsing):
361
+ // learned dialect (-1 = nothing learned), advertised caps, contact name.
362
+ trn readonly qa_contact_pv_of _:($cid -> cid: global_id)
363
+ {
364
+ p = a2a_messaging::contact_pv cid.
365
+ caps = a2a_messaging::contact_caps cid.
366
+ empty is str[] = [].
367
+ return (
368
+ $pv -> (p == NIL ?? 0 - 1 ; p?),
369
+ $caps -> (caps == NIL ?? empty ; caps?)
370
+ ).
371
+ }
372
+ trn readonly qa_contact_name _:($cid -> cid: global_id)
373
+ {
374
+ c = a2a_messaging::contacts cid.
375
+ return ($name -> (c == NIL ?? "" ; (c? $name))).
376
+ }
377
+
378
+ // Inject a learned capability set for a contact — drives the CAP-1 gate
379
+ // tests (positive-evidence denial vs unknown/empty pass-through).
380
+ trn qa_set_contact_caps _:($cid -> cid: global_id, $caps -> caps: str[])
381
+ {
382
+ current_transaction_info::validate_origin_or_abort (transaction::envelope::origin::user,).
383
+ a2a_messaging::contact_caps cid -> caps.
384
+ return transaction::success [ _return_data ($set -> TRUE), _save_state NIL ].
385
+ }
386
+
387
+ // Inject a learned dialect for a contact — arranges the "peer was v2 at
388
+ // invite time" precondition of the upgrade scenario (V7) on a pair that
389
+ // has a live encrypted channel (V1 proves the real v2 leg-1 learns 2).
390
+ trn qa_set_contact_pv _:($cid -> cid: global_id, $pv -> pv: int)
391
+ {
392
+ current_transaction_info::validate_origin_or_abort (transaction::envelope::origin::user,).
393
+ a2a_messaging::contact_pv cid -> pv.
394
+ return transaction::success [ _return_data ($set -> TRUE), _save_state NIL ].
395
+ }
396
+
397
+ // Emit the EXACT pre-0.5 legacy receive_message $targ — only $text, no
398
+ // $wire_id / $reply_to / $pv — over the established encrypted channel
399
+ // (byte-shape of the deployed 0.2-line sender). Drives the V7 monotonicity
400
+ // assertion: unstamped legacy traffic must never downgrade learned state.
401
+ trn qa_send_legacy_message _:($target -> tgt: global_id, $text -> text: str)
402
+ {
403
+ current_transaction_info::validate_origin_or_abort (transaction::envelope::origin::user,).
404
+ return encrypted_channel::execute_transaction tgt (fn (_) -> transaction::results::type {
405
+ return transaction::success [
406
+ encrypted_channel::send_encrypted_tx tgt (
407
+ $name -> "::actor::receive_message",
408
+ $targ -> ($text -> text)
409
+ ),
410
+ _return_data ($sent -> TRUE)
411
+ ].
412
+ }).
413
+ }
414
+
415
+ // ---- core 0.7.0 receipts QA (RC-series) ----
416
+ trn readonly qa_receipts_log _ { return ($log -> receipts_log). }
417
+ trn readonly qa_receipt_expectation _:($cid -> cid: global_id)
418
+ {
419
+ return ($state -> (a2a_messaging::receipt_expectation cid)).
420
+ }
421
+ // (Re)declare this node's advertised protocol caps — drives the emit gate's
422
+ // self side (a2a_capabilities::init is re-callable; empty handlers, stub
423
+ // describe: receipts ids are $advertise-class, no control verbs).
424
+ trn qa_init_caps _:($advertise -> adv: str[])
425
+ {
426
+ current_transaction_info::validate_origin_or_abort (transaction::envelope::origin::user,).
427
+ a2a_capabilities::init (
428
+ $describe -> fn (_: any) -> a2a_capabilities::app_manifest_t
429
+ {
430
+ return ($version -> 1, $app_id -> "test.actor", $name -> "actor",
431
+ $description -> "", $monitoring_status -> "off", $capabilities -> (,)).
432
+ },
433
+ $supported -> [],
434
+ $handlers -> (,),
435
+ $on_unknown -> fn (_: any) -> transaction::action::type[] { return []. },
436
+ $authorizer -> NIL,
437
+ $advertise -> adv
438
+ ).
439
+ return transaction::success [ _return_data ($set -> TRUE) ].
440
+ }
441
+ // Consumer read-path emission (the get/mark-read moment): appends the core
442
+ // read_receipt_actions for ids just transitioned unread->read.
443
+ trn qa_mark_read _:($contact -> cid: global_id, $wire_ids -> wids: str[])
444
+ {
445
+ current_transaction_info::validate_origin_or_abort (transaction::envelope::origin::user,).
446
+ actions is transaction::action::type[] = [].
447
+ sc a2a_messaging::read_receipt_actions cid wids -- ( -> a)
448
+ {
449
+ actions (_count actions|) -> a.
450
+ }
451
+ actions (_count actions|) -> _return_data ($sent -> ((_count actions) > 0)).
452
+ return transaction::success actions.
453
+ }
454
+ // Raw receipt injector (forward-compat / shape-tolerance cells).
455
+ trn qa_send_raw_receipt _:($target -> tgt: global_id, $kind -> kind: any, $wire_ids -> wids: any)
456
+ {
457
+ current_transaction_info::validate_origin_or_abort (transaction::envelope::origin::user,).
458
+ return encrypted_channel::execute_transaction tgt (fn (_) -> transaction::results::type {
459
+ return transaction::success [
460
+ encrypted_channel::send_encrypted_tx tgt (
461
+ $name -> "::a2a_messaging::receive_receipt",
462
+ $targ -> ($kind -> kind, $wire_ids -> wids, $pv -> a2a_versions::wire_version)
463
+ ),
464
+ _return_data ($sent -> TRUE)
465
+ ].
466
+ }).
467
+ }
468
+
469
+ // Emulate an OLD-dialect sender: a stamped message with an arbitrary $pv
470
+ // (+ wire_id so the receiver's delivered-emission path is actually
471
+ // evaluated, not short-circuited). Drives the RC10 old-peer-silence cell:
472
+ // the receiver LEARNS the stamped pv from this very message (learning
473
+ // precedes the gate — the self-heal mechanism), so presetting maps isn't
474
+ // enough; the message itself must carry the old dialect.
475
+ trn qa_send_stamped_message _:($target -> tgt: global_id, $text -> text: str, $pv -> pv: int, $wire_id -> wid: str)
476
+ {
477
+ current_transaction_info::validate_origin_or_abort (transaction::envelope::origin::user,).
478
+ return encrypted_channel::execute_transaction tgt (fn (_) -> transaction::results::type {
479
+ return transaction::success [
480
+ encrypted_channel::send_encrypted_tx tgt (
481
+ $name -> "::actor::receive_message",
482
+ $targ -> ($text -> text, $wire_id -> wid, $pv -> pv)
483
+ ),
484
+ _return_data ($sent -> TRUE)
485
+ ].
486
+ }).
487
+ }
488
+
489
+
258
490
  // ---- leg-3 isolation helpers ----
259
491
  // A fake invite carrying a chosen inviter cid; the named cid never minted it, so
260
492
  // its leg-2 aborts (unknown invite) and sends no real leg-3 — leaving the
@@ -274,8 +506,8 @@ application actor loads libraries
274
506
  scheme = _crypto_default_scheme_id().
275
507
  kpi = _crypto_construct_encryption_keypair scheme.
276
508
  my_ad = address_document::get_my_address_document().
277
- ad is address_document_types::t_address_document = my_ad.
278
- if mode == "foreign" { ad -> (_read_or_abort fad) safe address_document_types::t_address_document. }
509
+ ad = my_ad as any. // any, not typed AD: embedded as $ad -> any downstream (meta-stage fuel budget)
510
+ if mode == "foreign" { ad -> (_read_or_abort fad). }
279
511
  if mode == "forged" { ad -> ($version -> (my_ad $version), $identity -> (my_ad $identity), $authorizations -> (,)). }
280
512
  payload = _write ($ad -> ad, $cert -> NIL, $root_profile -> NIL, $cp_binding -> NIL, $invite_id -> iid).
281
513
  data = _crypto_encrypt_message (kpi $secret_key) rpk payload.
@@ -284,4 +516,5 @@ application actor loads libraries
284
516
  _return_data ($sent -> TRUE)
285
517
  ].
286
518
  }
519
+
287
520
  }
@@ -0,0 +1,93 @@
1
+ // Shared driver harness for the loopback test suites.
2
+ //
3
+ // Extracted from test.mjs so both test.mjs (T/V/RC-series, messaging-only unit)
4
+ // and notif.mjs (N-series, notifications unit) import ONE copy of the wrapper /
5
+ // packet bootstrap + the mk/wire/mutate/ro/binv/mkPacket/sleep/log helpers
6
+ // instead of duplicating them. Each driver keeps its own tiny scorecard/ok/CUR
7
+ // local (they differ in prose and are trivially cheap).
8
+ //
9
+ // The `wire` handler preserves the protocol_error/notify_agent error-as-data
10
+ // capture verbatim (the V-series Additions A/B assertions read code/message/
11
+ // context/surface off id.errEvents).
12
+ import { resolve } from 'node:path';
13
+ import * as fs from 'node:fs';
14
+ import { adapt_wrapper } from '@adapt-toolkit/sdk/executables';
15
+ import { PacketWrapperConfigurator } from '@adapt-toolkit/sdk/wrappers';
16
+ import { object_to_adapt_value } from '@adapt-toolkit/sdk/wrapper';
17
+
18
+ export const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
19
+
20
+ // Pure per-node state record.
21
+ export function mk(name) {
22
+ return { name, pw: null, cid: '', pending: [], rejects: [], events: [], errEvents: [] };
23
+ }
24
+
25
+ // Build a harness bound to one broker + unit dir. Returns the driver helpers,
26
+ // each of which closes over the shared `wrapper` and unit metadata.
27
+ export async function createHarness({ brokerUrl, unitDir, logTag = 't' }) {
28
+ const UNIT_DIR = resolve(unitDir);
29
+ const unitHash = fs.readdirSync(UNIT_DIR).find((f) => f.endsWith('.muflo')).slice(0, -'.muflo'.length);
30
+ const UNIT = new Uint8Array(fs.readFileSync(resolve(UNIT_DIR, `${unitHash}.muflo`)));
31
+ const log = (...a) => process.stderr.write(`[${logTag}] ${a.join(' ')}\n`);
32
+
33
+ function wire(id) {
34
+ id.pw.on_return_data = (d) => {
35
+ const kind = d.Reduce('kind').Visualize();
36
+ if (kind === 'notify_agent') {
37
+ const ev = d.Reduce('payload').Reduce('event').Visualize();
38
+ id.events.push(ev);
39
+ // Capture the full error-as-data payload for $protocol_error events
40
+ // (Additions A/B assertions read code/message/context off it).
41
+ if (ev === 'protocol_error') {
42
+ const p = d.Reduce('payload');
43
+ id.errEvents.push({
44
+ context: p.Reduce('context').Visualize(),
45
+ message: p.Reduce('message').Visualize(),
46
+ code: p.Reduce('error').Reduce('code').Visualize(),
47
+ errMessage: p.Reduce('error').Reduce('message').Visualize(),
48
+ peerVersion: p.Reduce('error').Reduce('peer_version').Visualize(),
49
+ minSupported: p.Reduce('error').Reduce('min_supported').Visualize(),
50
+ surface: p.Reduce('error').Reduce('surface').Visualize(),
51
+ });
52
+ }
53
+ return;
54
+ }
55
+ if (kind === 'save_state') return;
56
+ const p = id.pending.shift(); if (!p) return;
57
+ clearTimeout(p.timer); p.resolve(d.Reduce('payload'));
58
+ };
59
+ id.pw.on_transaction_failure = (msg) => {
60
+ const p = id.pending.shift();
61
+ if (p) { clearTimeout(p.timer); p.reject(new Error(msg)); }
62
+ else { id.rejects.push(String(msg)); log(`${id.name} inbound rejected:`, String(msg).split('\n')[0]); }
63
+ };
64
+ }
65
+
66
+ const wrapper = await adapt_wrapper.start(['--broker_address', brokerUrl, '--test_mode',
67
+ '--logger_config', '--level', 'WARNING', '--stdout', 'stderr', '--logger_config_end']);
68
+ wrapper.start();
69
+ await sleep(1500);
70
+
71
+ function mutate(id, name, targ) {
72
+ return new Promise((res, rej) => {
73
+ const timer = setTimeout(() => rej(new Error(`${id.name}.${name} timed out`)), 20000);
74
+ id.pending.push({ resolve: res, reject: rej, timer });
75
+ id.pw.add_client_message(object_to_adapt_value({ name, targ }));
76
+ });
77
+ }
78
+ const ro = (id, name, targ) => id.pw.packet.ExecuteTransaction(object_to_adapt_value({ name, targ }));
79
+ const binv = (id, buf) => id.pw.packet.NewBinaryFromBuffer(Buffer.from(buf));
80
+ async function mkPacket(id, seed) {
81
+ const cfg = new PacketWrapperConfigurator();
82
+ cfg.process_arguments(['--unit_hash', unitHash, '--seed_phrase', seed, '--unit_dir_path', UNIT_DIR]);
83
+ await new Promise((res, rej) => {
84
+ const t = setTimeout(() => rej(new Error(`${id.name} create timeout`)), 30000);
85
+ wrapper.packet_manager.create_packet(cfg, (pw) => {
86
+ clearTimeout(t); id.pw = pw; id.cid = pw.packet.GetContainerID().Visualize(); wire(id);
87
+ log(`${id.name} cid ${id.cid.slice(0, 12)}…`); res();
88
+ }, UNIT);
89
+ });
90
+ }
91
+
92
+ return { wrapper, UNIT_DIR, unitHash, mk, wire, mutate, ro, binv, mkPacket, sleep, log };
93
+ }
@@ -17,7 +17,7 @@ library version
17
17
 
18
18
  // This MUST be updated every time we update ANY code in the shared core.
19
19
  hidden {
20
- core_version = create_version 0 2 0.
20
+ core_version = create_version 0 8 0.
21
21
  }
22
22
 
23
23
  fn get_core_version(_) = core_version.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ours.network/tg-connector",
3
- "version": "0.1.7",
3
+ "version": "0.1.8-nightly.2",
4
4
  "description": "Bridge Telegram bots to ours proxy nodes — one ADAPT wrapper hosting N messenger packets, each connecting one Telegram bot to one ours node. Run `ours-tg-connector add_new_connection`.",
5
5
  "type": "module",
6
6
  "license": "FSL-1.1-Apache-2.0",
@@ -35,12 +35,12 @@
35
35
  "test": "for f in tests/*.test.mjs; do echo \"# $f\"; node_modules/.bin/tsx \"$f\" || exit 1; done"
36
36
  },
37
37
  "dependencies": {
38
- "@adapt-toolkit/sdk": "0.9.1",
39
- "@adapt-toolkit/sdk-native": "0.9.1",
38
+ "@adapt-toolkit/sdk": "0.10.8",
39
+ "@adapt-toolkit/sdk-native": "0.10.8",
40
40
  "undici": "^7.28.0"
41
41
  },
42
42
  "devDependencies": {
43
- "@adapt-toolkit/mufl": "0.9.1",
43
+ "@adapt-toolkit/mufl": "0.10.8",
44
44
  "@types/node": "^20.14.0",
45
45
  "esbuild": "^0.24.2",
46
46
  "tsx": "^4.19.0",