@pollen-robotics/reachy-mini-sdk 1.11.0 → 1.12.0-dev.0.main.3cd1a23

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.
@@ -1,20 +1,23 @@
1
1
  # App Creation Guide
2
2
 
3
- > ### Use `@pollen-robotics/reachy-mini-sdk@1.8.0` today
3
+ > ### Use the latest `@pollen-robotics/reachy-mini-sdk` release
4
4
  >
5
- > Every reference app pins the same SDK release: **`1.8.0`** (the
6
- > stable npm release; npm versions are immutable, so this is fully
7
- > reproducible — no commit suffix needed). The host shell, the embed
5
+ > Install the latest stable release from
6
+ > [npm](https://www.npmjs.com/package/@pollen-robotics/reachy-mini-sdk):
7
+ >
8
+ > ```bash
9
+ > npm install @pollen-robotics/reachy-mini-sdk@latest
10
+ > ```
11
+ >
12
+ > This pins the exact resolved version in your `package.json` (npm
13
+ > versions are immutable, so this is fully reproducible). The minimum
14
+ > supported version is **`1.8.0`** — anything older predates the host
15
+ > shell contract described here. Every
16
+ > reference app pins the same SDK release. The host shell, the embed
8
17
  > adapter, the SDK runtime, and the daemon on the robot are validated
9
18
  > end-to-end against that release. Mixing versions across these
10
19
  > boundaries causes silent protocol drift - see
11
20
  > [§10 SDK version pinning](#10-sdk-version-pinning).
12
- >
13
- > Add this to your `package.json`:
14
- >
15
- > ```json
16
- > { "dependencies": { "@pollen-robotics/reachy-mini-sdk": "1.8.0" } }
17
- > ```
18
21
 
19
22
  **This is the single source of truth for building a Reachy Mini JS
20
23
  app.** [`../AGENTS.md`](../AGENTS.md) at the repo root points here;
@@ -111,13 +114,14 @@ Pick the reference closest to your needs and clone its repo from Hugging Face:
111
114
 
112
115
  | Reference app | Stack | Use it for |
113
116
  |-------------------------------------|-----------------------------|---------------------------------------------|
114
- | [`pollen-robotics/reachy_mini_minimal_conversation`](https://huggingface.co/spaces/pollen-robotics/reachy_mini_minimal_conversation) | **Vanilla TS + Vite** | Smallest bundled runtime, no framework |
115
- | [`pollen-robotics/reachy_mini_emotions`](https://huggingface.co/spaces/pollen-robotics/reachy_mini_emotions) | React 19 + MUI 7 + Vite | UI-rich app with rich components / theming |
116
- | [`pollen-robotics/reachy_mini_telepresence`](https://huggingface.co/spaces/pollen-robotics/reachy_mini_telepresence) | React 19 + MUI 7 + Vite | App with camera / media streams |
117
+ | [`tfrere/minimal-conversation`](https://huggingface.co/spaces/tfrere/minimal-conversation) | **Vanilla TS + Vite** | Smallest bundled runtime, no framework |
118
+ | [`pollen-robotics/emotions`](https://huggingface.co/spaces/pollen-robotics/emotions) | React 19 + MUI 7 + Vite | UI-rich app with rich components / theming |
119
+ | [`pollen-robotics/telepresence`](https://huggingface.co/spaces/pollen-robotics/telepresence) | React 19 + MUI 7 + Vite | App with camera / media streams |
120
+ | [`pollen-robotics/sdk-js-demo-app`](https://huggingface.co/spaces/pollen-robotics/sdk-js-demo-app) | Vanilla TS + Vite | Tour of every SDK primitive |
117
121
 
118
122
  ```bash
119
123
  # Example: start from the vanilla TS template
120
- git clone https://huggingface.co/spaces/pollen-robotics/reachy_mini_minimal_conversation my_new_app
124
+ git clone https://huggingface.co/spaces/tfrere/minimal-conversation my_new_app
121
125
  cd my_new_app
122
126
  # Edit package.json `name`, README frontmatter (`title`, `emoji`,
123
127
  # `short_description`), public/icon.svg, and src/embed.ts to your app.
@@ -126,8 +130,9 @@ npm run dev
126
130
  # → http://localhost:5173
127
131
  ```
128
132
 
129
- All three reference apps pin `@pollen-robotics/reachy-mini-sdk` to
130
- the same RC version in their `package.json` - see [§10 SDK version pinning](#10-sdk-version-pinning).
133
+ All reference apps pin `@pollen-robotics/reachy-mini-sdk` to
134
+ the same exact version (the latest npm release) in their
135
+ `package.json` - see [§10 SDK version pinning](#10-sdk-version-pinning).
131
136
 
132
137
  > **Prefer a no-build path?** You can also ship the app as a single
133
138
  > `index.html` with the SDK loaded from a CDN. No `package.json`, no
@@ -363,6 +368,7 @@ The resolved `handle` exposes:
363
368
  interface ConnectedHandle<TConfig> {
364
369
  // Live state at boot
365
370
  reachy: ReachyMiniInstance; // SDK instance, session live, robot awake
371
+ media: RobotMedia; // WebRTC streams - see "Video: use `handle.media`"
366
372
  theme: 'dark' | 'light';
367
373
  config: TConfig | null;
368
374
  appName: string;
@@ -385,6 +391,41 @@ The API is intentionally minimal. If you need a custom channel
385
391
  between host and embed, file a feature request - we'll add it as
386
392
  a typed message rather than expose a free-form sink.
387
393
 
394
+ ### Video: use `handle.media`
395
+
396
+ `connectToHost()` resolves only *after* the WebRTC handshake is
397
+ complete. By the time your app mounts, the SDK's one-shot
398
+ `videoTrack` event and the underlying `pc.ontrack` have **already
399
+ fired**. So `reachy.attachVideo(el)` installs a listener that never
400
+ fires, and an embed never calls `startSession()` again: the element
401
+ stays black forever, with no error anywhere.
402
+
403
+ `handle.media` exists for exactly this. It replays the streams from a
404
+ synchronous snapshot of the peer connection's receivers, so a
405
+ late-mounting consumer sees the camera immediately:
406
+
407
+ ```ts
408
+ interface RobotMedia {
409
+ attachVideo(el: HTMLVideoElement): () => void; // returns a detach fn
410
+ readonly robotStream: MediaStream | null; // robot video + audio
411
+ readonly micStream: MediaStream | null; // local mic, if enabled
412
+ }
413
+
414
+ const handle = await connectToHost();
415
+ const detach = handle.media.attachVideo(videoEl);
416
+ handle.onLeave(() => detach());
417
+ ```
418
+
419
+ There is no equivalent race for the data channel, mute toggles, motor
420
+ commands or state updates: the bridge resolves only once ICE **and**
421
+ the data channel are connected, and state events keep arriving (every
422
+ ~500 ms, or ~30 Hz after `subscribePose()`). Keep calling `reachy.setHeadRpyDeg(...)`,
423
+ `reachy.setMicMuted(...)` and `reachy.addEventListener('state', ...)`
424
+ directly.
425
+
426
+ `reachy.attachVideo()` remains correct in a **standalone** app
427
+ (`mountHost`), where your code runs before the session starts.
428
+
388
429
  ### Typing your config
389
430
 
390
431
  `connectToHost<T>()` types the `config` field; runtime validation
@@ -645,30 +686,31 @@ Pin yours the same way - mixing versions across `@pollen-robotics/reachy-mini-sd
645
686
  `@pollen-robotics/reachy-mini-sdk/host`, and the daemon on the robot
646
687
  produces hard-to-debug protocol drift.
647
688
 
648
- The current pinned version across all three reference apps:
689
+ Install the latest stable release from
690
+ [npm](https://www.npmjs.com/package/@pollen-robotics/reachy-mini-sdk):
649
691
 
650
- ```json
651
- {
652
- "dependencies": {
653
- "@pollen-robotics/reachy-mini-sdk": "1.8.0"
654
- }
655
- }
692
+ ```bash
693
+ npm install @pollen-robotics/reachy-mini-sdk@latest
656
694
  ```
657
695
 
658
- This is the stable `1.8.0` npm release, validated end-to-end against
659
- the host shell + daemon. npm versions are immutable, so pinning the
660
- exact version is fully reproducible — no commit suffix needed. **Use
661
- the same string in your `package.json`** unless you're explicitly
662
- tracking a newer release.
663
-
664
- > When a newer release is published, the source of truth is whichever
665
- > string is currently shared by [`reachy_mini_minimal_conversation`'s
666
- > `package.json`](https://huggingface.co/spaces/pollen-robotics/reachy_mini_minimal_conversation/blob/main/package.json),
667
- > [`reachy_mini_emotions`'s `package.json`](https://huggingface.co/spaces/pollen-robotics/reachy_mini_emotions/blob/main/package.json),
668
- > and [`reachy_mini_telepresence`'s `package.json`](https://huggingface.co/spaces/pollen-robotics/reachy_mini_telepresence/blob/main/package.json).
669
- > If those three diverge, fall back to whatever this guide says.
670
-
671
- ### Why pin a specific build (not `^1.8.0` or a major like `@1`)?
696
+ npm writes the exact resolved version into your `package.json`. npm
697
+ versions are immutable, so pinning the exact version is fully
698
+ reproducible — no commit suffix needed. The stable release is
699
+ validated end-to-end against the host shell + daemon. **Use the exact
700
+ version string npm writes** unless you're explicitly tracking a newer
701
+ release. In all cases the version must be **`>= 1.8.0`** — older
702
+ releases predate the host shell + protocol v1 contract and are not
703
+ supported.
704
+
705
+ > The source of truth for "what's current" is the
706
+ > [npm package page](https://www.npmjs.com/package/@pollen-robotics/reachy-mini-sdk)
707
+ > (`npm view @pollen-robotics/reachy-mini-sdk version` works too), and
708
+ > whichever string is currently shared by [`minimal-conversation`'s
709
+ > `package.json`](https://huggingface.co/spaces/tfrere/minimal-conversation/blob/main/package.json),
710
+ > [`emotions`'s `package.json`](https://huggingface.co/spaces/pollen-robotics/emotions/blob/main/package.json),
711
+ > and [`telepresence`'s `package.json`](https://huggingface.co/spaces/pollen-robotics/telepresence/blob/main/package.json).
712
+
713
+ ### Why pin a specific build (not `^x.y.z` or a major like `@1`)?
672
714
 
673
715
  The host shell, the embed adapter (`connectToHost`), the SDK, and the
674
716
  robot daemon negotiate over a versioned WebRTC data-channel protocol.
@@ -920,16 +962,18 @@ my-bare-app/
920
962
 
921
963
  **Importing the SDK from a CDN**
922
964
 
923
- Pin to an exact build SHA - **the same string you would use in
924
- `package.json`** (see [§10 SDK version pinning](#10-sdk-version-pinning)).
925
- jsDelivr's `/+esm` suffix tells the CDN to bundle the package to ESM at
926
- the edge:
965
+ Pin to an exact version - **the same string you would use in
966
+ `package.json`**, i.e. the latest release shown on
967
+ [npm](https://www.npmjs.com/package/@pollen-robotics/reachy-mini-sdk)
968
+ (see [§10 SDK version pinning](#10-sdk-version-pinning)). Substitute it
969
+ for `<version>` below. jsDelivr's `/+esm` suffix tells the CDN to bundle
970
+ the package to ESM at the edge:
927
971
 
928
972
  ```html
929
973
  <script type="module">
930
- import { ReachyMini } from "https://cdn.jsdelivr.net/npm/@pollen-robotics/reachy-mini-sdk@1.8.0/+esm";
931
- import { mountHost } from "https://cdn.jsdelivr.net/npm/@pollen-robotics/reachy-mini-sdk@1.8.0/host/dist/entry/auto.js";
932
- import { connectToHost } from "https://cdn.jsdelivr.net/npm/@pollen-robotics/reachy-mini-sdk@1.8.0/host/dist/entry/embed.js";
974
+ import { ReachyMini } from "https://cdn.jsdelivr.net/npm/@pollen-robotics/reachy-mini-sdk@<version>/+esm";
975
+ import { mountHost } from "https://cdn.jsdelivr.net/npm/@pollen-robotics/reachy-mini-sdk@<version>/host/dist/entry/auto.js";
976
+ import { connectToHost } from "https://cdn.jsdelivr.net/npm/@pollen-robotics/reachy-mini-sdk@<version>/host/dist/entry/embed.js";
933
977
 
934
978
  window.ReachyMini = ReachyMini;
935
979
  window.dispatchEvent(new Event("reachymini:ready"));
@@ -993,9 +1037,10 @@ shell without touching your motion code. The four-step recipe:
993
1037
  import { ReachyMini } from "https://cdn.jsdelivr.net/gh/pollen-robotics/reachy_mini@v1.7.2/js/reachy-mini.js";
994
1038
 
995
1039
  // AFTER (modern host shell, same SDK runtime API)
996
- import { ReachyMini } from "https://cdn.jsdelivr.net/npm/@pollen-robotics/reachy-mini-sdk@1.8.0/+esm";
997
- import { mountHost } from "https://cdn.jsdelivr.net/npm/@pollen-robotics/reachy-mini-sdk@1.8.0/host/dist/entry/auto.js";
998
- import { connectToHost } from "https://cdn.jsdelivr.net/npm/@pollen-robotics/reachy-mini-sdk@1.8.0/host/dist/entry/embed.js";
1040
+ // <version> = latest release on npm (see §10 SDK version pinning)
1041
+ import { ReachyMini } from "https://cdn.jsdelivr.net/npm/@pollen-robotics/reachy-mini-sdk@<version>/+esm";
1042
+ import { mountHost } from "https://cdn.jsdelivr.net/npm/@pollen-robotics/reachy-mini-sdk@<version>/host/dist/entry/auto.js";
1043
+ import { connectToHost } from "https://cdn.jsdelivr.net/npm/@pollen-robotics/reachy-mini-sdk@<version>/host/dist/entry/embed.js";
999
1044
  ```
1000
1045
 
1001
1046
  2. **Branch on `?embedded=1`.** Wrap your existing app boot in:
@@ -1030,8 +1075,11 @@ shell without touching your motion code. The four-step recipe:
1030
1075
  only exists on the modern SDK; if you weren't using it, nothing
1031
1076
  changes. If you reached into private fields like `robot._pc`
1032
1077
  (RTCPeerConnection), prefer the public alternatives:
1033
- `robot.attachVideo(videoEl)` for video, `enableMicrophone: true` on
1034
- `mountHost` for bidirectional audio.
1078
+ `handle.media.attachVideo(videoEl)` for video, `enableMicrophone: true`
1079
+ on `mountHost` for bidirectional audio. Once embedded, use
1080
+ `handle.media.attachVideo()` and **not** `robot.attachVideo()`: the
1081
+ latter silently no-ops because the handshake completed before your
1082
+ app mounted (see [§5 Video](#video-use-handlemedia)).
1035
1083
 
1036
1084
  Your `README.md` frontmatter doesn't need any changes: `sdk: static`
1037
1085
  and `hf_oauth: true` work for both variants. You can still skip
@@ -1467,7 +1515,9 @@ rolled out by the SDK team, not by every app team.
1467
1515
  - App bundles (`index-<hash>.js`): hashed by Vite, cache-busted
1468
1516
  on deploy.
1469
1517
  - `@pollen-robotics/reachy-mini-sdk` in `package.json`: pinned to
1470
- an **exact version** (today: `1.8.0`), not a range. See
1518
+ an **exact version** (the latest release on
1519
+ [npm](https://www.npmjs.com/package/@pollen-robotics/reachy-mini-sdk)),
1520
+ not a range. See
1471
1521
  [§10 SDK version pinning](#10-sdk-version-pinning).
1472
1522
  - `@pollen-robotics/reachy-mini-sdk/host` subpath imports: same
1473
1523
  pin, same package.
package/README.md CHANGED
@@ -98,7 +98,7 @@ See the JSDoc header in [`reachy-mini-sdk.js`](./reachy-mini-sdk.js) for the ful
98
98
 
99
99
  For Hugging Face Spaces apps that need OAuth + a robot picker + iframe lifecycle management:
100
100
 
101
- - **[`APP_CREATION_GUIDE.md`](./APP_CREATION_GUIDE.md)** — single source of truth for app authors (scaffold, `sdk: static` deploy, host ↔ embed contract, invariants). Today's SDK pin: `1.8.0`.
101
+ - **[`APP_CREATION_GUIDE.md`](./APP_CREATION_GUIDE.md)** — single source of truth for app authors (scaffold, `sdk: static` deploy, host ↔ embed contract, invariants). SDK pin: the latest stable release on [npm](https://www.npmjs.com/package/@pollen-robotics/reachy-mini-sdk).
102
102
  - [`host/README.md`](./host/README.md) — one-page tour of the host package layout
103
103
 
104
104
  ## Migration from `@pollen-robotics/reachy-mini-host`
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Reassembly of daemon messages too large for one data channel frame.
3
+ *
4
+ * The data channel silently drops any message over 64 KiB, so the daemon
5
+ * splits larger ones into ordered `message_chunk` frames (see
6
+ * `split_for_data_channel` in `reachy_mini/media/webrtc_utils.py`). Each
7
+ * carries a slice of the original text in `data`; joined in order they are
8
+ * the message the daemon meant to send.
9
+ *
10
+ * One instance per control channel: the channel is ordered, and a new
11
+ * channel means a new session, so nothing survives across the two.
12
+ */
13
+ export declare class MessageReassembler {
14
+ private readonly _partials;
15
+ /**
16
+ * Feed one parsed frame. Returns the message to handle: the frame itself
17
+ * when it is not a chunk, the reassembled message when this chunk
18
+ * completes one, or `null` while a message is still arriving.
19
+ */
20
+ accept(frame: Record<string, unknown>): Record<string, unknown> | null;
21
+ }
22
+ //# sourceMappingURL=message-chunks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message-chunks.d.ts","sourceRoot":"","sources":["../../lib/message-chunks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,qBAAa,kBAAkB;IAC3B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA+B;IAEzD;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;CA+BzE"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Reassembly of daemon messages too large for one data channel frame.
3
+ *
4
+ * The data channel silently drops any message over 64 KiB, so the daemon
5
+ * splits larger ones into ordered `message_chunk` frames (see
6
+ * `split_for_data_channel` in `reachy_mini/media/webrtc_utils.py`). Each
7
+ * carries a slice of the original text in `data`; joined in order they are
8
+ * the message the daemon meant to send.
9
+ *
10
+ * One instance per control channel: the channel is ordered, and a new
11
+ * channel means a new session, so nothing survives across the two.
12
+ */
13
+ /** Upper bound on one reassembled message, against a runaway sender. */
14
+ const MAX_CHUNKS = 4096;
15
+ export class MessageReassembler {
16
+ _partials = new Map();
17
+ /**
18
+ * Feed one parsed frame. Returns the message to handle: the frame itself
19
+ * when it is not a chunk, the reassembled message when this chunk
20
+ * completes one, or `null` while a message is still arriving.
21
+ */
22
+ accept(frame) {
23
+ if (frame.type !== 'message_chunk')
24
+ return frame;
25
+ const { id, index, count, data } = frame;
26
+ if (typeof id !== 'string' ||
27
+ typeof index !== 'number' ||
28
+ typeof count !== 'number' ||
29
+ typeof data !== 'string' ||
30
+ count < 1 ||
31
+ count > MAX_CHUNKS) {
32
+ return null;
33
+ }
34
+ let parts = this._partials.get(id);
35
+ if (index === 0) {
36
+ parts = [];
37
+ this._partials.set(id, parts);
38
+ }
39
+ // The channel is ordered, so a gap means the message is lost.
40
+ if (!parts || index !== parts.length) {
41
+ this._partials.delete(id);
42
+ return null;
43
+ }
44
+ parts.push(data);
45
+ if (parts.length < count)
46
+ return null;
47
+ this._partials.delete(id);
48
+ return JSON.parse(parts.join(''));
49
+ }
50
+ }
51
+ //# sourceMappingURL=message-chunks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message-chunks.js","sourceRoot":"","sources":["../../lib/message-chunks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,wEAAwE;AACxE,MAAM,UAAU,GAAG,IAAI,CAAC;AAExB,MAAM,OAAO,kBAAkB;IACV,SAAS,GAAG,IAAI,GAAG,EAAoB,CAAC;IAEzD;;;;OAIG;IACH,MAAM,CAAC,KAA8B;QACjC,IAAI,KAAK,CAAC,IAAI,KAAK,eAAe;YAAE,OAAO,KAAK,CAAC;QACjD,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;QACzC,IACI,OAAO,EAAE,KAAK,QAAQ;YACtB,OAAO,KAAK,KAAK,QAAQ;YACzB,OAAO,KAAK,KAAK,QAAQ;YACzB,OAAO,IAAI,KAAK,QAAQ;YACxB,KAAK,GAAG,CAAC;YACT,KAAK,GAAG,UAAU,EACpB,CAAC;YACC,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,IAAI,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACnC,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;YACd,KAAK,GAAG,EAAE,CAAC;YACX,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;QAClC,CAAC;QACD,8DAA8D;QAC9D,IAAI,CAAC,KAAK,IAAI,KAAK,KAAK,KAAK,CAAC,MAAM,EAAE,CAAC;YACnC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YAC1B,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjB,IAAI,KAAK,CAAC,MAAM,GAAG,KAAK;YAAE,OAAO,IAAI,CAAC;QAEtC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAC1B,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAA4B,CAAC;IACjE,CAAC;CACJ"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=message-chunks.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message-chunks.test.d.ts","sourceRoot":"","sources":["../../lib/message-chunks.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * MessageReassembler tests.
3
+ *
4
+ * The frames are the ones the daemon's `split_for_data_channel` produces:
5
+ * ordered `message_chunk` frames whose `data` slices join back into the
6
+ * original JSON text.
7
+ */
8
+ import { describe, expect, it } from 'vitest';
9
+ import { MessageReassembler } from './message-chunks.js';
10
+ /** Split like the daemon does, into `size`-character slices. */
11
+ function chunk(message, id, size) {
12
+ const text = JSON.stringify(message);
13
+ const parts = [];
14
+ for (let i = 0; i < text.length; i += size)
15
+ parts.push(text.slice(i, i + size));
16
+ return parts.map((data, index) => ({ type: 'message_chunk', id, index, count: parts.length, data }));
17
+ }
18
+ describe('MessageReassembler', () => {
19
+ it('passes a frame that is not a chunk straight through', () => {
20
+ const frame = { jsonrpc: '2.0', id: 1, result: 'ok' };
21
+ expect(new MessageReassembler().accept(frame)).toBe(frame);
22
+ });
23
+ it('returns the message once its last chunk lands', () => {
24
+ const reply = { jsonrpc: '2.0', id: 'sorry_bro', result: { svg: '<svg/>'.repeat(5000) } };
25
+ const frames = chunk(reply, 'a', 4096);
26
+ const reassembler = new MessageReassembler();
27
+ const results = frames.map((f) => reassembler.accept(f));
28
+ expect(results.slice(0, -1).every((r) => r === null)).toBe(true);
29
+ expect(results.at(-1)).toEqual(reply);
30
+ });
31
+ it('keeps two messages apart when their chunks interleave', () => {
32
+ const first = { jsonrpc: '2.0', id: 1, result: 'a'.repeat(9000) };
33
+ const second = { jsonrpc: '2.0', id: 2, result: 'b'.repeat(9000) };
34
+ const [a, b] = [chunk(first, 'one', 4096), chunk(second, 'two', 4096)];
35
+ const reassembler = new MessageReassembler();
36
+ const done = [0, 1, 2]
37
+ .flatMap((i) => [a[i], b[i]])
38
+ .map((f) => reassembler.accept(f))
39
+ .filter((r) => r !== null);
40
+ expect(done).toEqual([first, second]);
41
+ });
42
+ it('drops a message with a missing chunk instead of corrupting it', () => {
43
+ const frames = chunk({ jsonrpc: '2.0', id: 1, result: 'x'.repeat(9000) }, 'a', 4096);
44
+ const reassembler = new MessageReassembler();
45
+ expect(reassembler.accept(frames[0])).toBeNull();
46
+ expect(reassembler.accept(frames[2])).toBeNull();
47
+ // The next message still reassembles.
48
+ const next = { jsonrpc: '2.0', id: 2, result: 'ok' };
49
+ const again = chunk(next, 'b', 8);
50
+ expect(again.map((f) => reassembler.accept(f)).at(-1)).toEqual(next);
51
+ });
52
+ });
53
+ //# sourceMappingURL=message-chunks.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message-chunks.test.js","sourceRoot":"","sources":["../../lib/message-chunks.test.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,gEAAgE;AAChE,SAAS,KA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,OAAO,CAAC,iBAAiB;YAOX,sBAAsB;YAStB,aAAa;IA4B3B,OAAO,CAAC,YAAY;IAMpB;;;;;;OAMG;IACH,OAAO,CAAC,CAAC,GAAG,OAAO,EACf,MAAM,EAAE,MAAM,EACd,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,EACpC,IAAI,GAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAO,GAClC,OAAO,CAAC,CAAC,CAAC;IAOb;;;OAGG;IACH,cAAc,CACV,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,GAC9C,MAAM,IAAI;IAYb,OAAO,CAAC,iBAAiB;IAgBzB,OAAO,CAAC,kBAAkB;YA0BZ,uBAAuB;IAiCrC,OAAO,CAAC,iBAAiB;YA6CX,kBAAkB;IA2DhC;;;;OAIG;IACH,OAAO,CAAC,mBAAmB;IAkK3B,sEAAsE;IACtE,OAAO,CAAC,oBAAoB;CAe/B"}
@@ -6,6 +6,7 @@
6
6
  import { oauthHandleRedirectIfPresent, oauthLoginUrl, } from '@huggingface/hub';
7
7
  import { createLogger } from './logger.js';
8
8
  import { degToRad, rpyToMatrix } from './math.js';
9
+ import { MessageReassembler } from './message-chunks.js';
9
10
  import { BroadcastTimeoutError, PendingReplies, SLOT_ROUNDTRIP_TIMEOUT_MS } from './pending-replies.js';
10
11
  import { SessionSupervisor } from './session-supervisor.js';
11
12
  import { SDK_VERSION } from './version.js';
@@ -626,7 +627,14 @@ export class ReachyMini extends EventTarget {
626
627
  this._dcOpen = true;
627
628
  this._checkSessionReady();
628
629
  };
629
- this._dc.onmessage = (ev) => this._handleRobotMessage(JSON.parse(ev.data));
630
+ // Replies over 64 KiB arrive as ordered chunks; one
631
+ // reassembler per channel, so nothing leaks across sessions.
632
+ const reassembler = new MessageReassembler();
633
+ this._dc.onmessage = (ev) => {
634
+ const msg = reassembler.accept(JSON.parse(ev.data));
635
+ if (msg)
636
+ this._handleRobotMessage(msg);
637
+ };
630
638
  };
631
639
  this._sendToServer({ type: 'startSession', peerId: robotId }).then((r) => {
632
640
  if (r?.type === 'sessionRejected') {