@pollen-robotics/reachy-mini-sdk 1.11.0-rc.1 → 1.12.0-dev.0.main.2f2e2ba
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/APP_CREATION_GUIDE.md +90 -41
- package/README.md +1 -1
- package/dist/lib/message-chunks.d.ts +22 -0
- package/dist/lib/message-chunks.d.ts.map +1 -0
- package/dist/lib/message-chunks.js +51 -0
- package/dist/lib/message-chunks.js.map +1 -0
- package/dist/lib/message-chunks.test.d.ts +2 -0
- package/dist/lib/message-chunks.test.d.ts.map +1 -0
- package/dist/lib/message-chunks.test.js +53 -0
- package/dist/lib/message-chunks.test.js.map +1 -0
- package/dist/lib/reachy-mini.d.ts.map +1 -1
- package/dist/lib/reachy-mini.js +9 -1
- package/dist/lib/reachy-mini.js.map +1 -1
- package/dist/lib/version.d.ts +1 -1
- package/dist/lib/version.d.ts.map +1 -1
- package/dist/lib/version.js +1 -1
- package/dist/lib/version.js.map +1 -1
- package/host/README.md +2 -2
- package/host/dist/chunks/{centralRest-vcOOpQK6.js → centralRest-K3a9U_Sk.js} +104 -82
- package/host/dist/chunks/{index-BrKBhTE0.js → index-B79tSfbK.js} +1 -1
- package/host/dist/chunks/{mountHost-CNQYkWZ4.js → mountHost-CMP4uYnZ.js} +1480 -1482
- package/host/dist/entry/auto.js +2 -2
- package/host/dist/entry/embed.js +2 -2
- package/host/dist/index.js +3 -3
- package/host/dist/lib/protocol.js +2 -2
- package/package.json +1 -1
package/APP_CREATION_GUIDE.md
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
# App Creation Guide
|
|
2
2
|
|
|
3
|
-
> ### Use `@pollen-robotics/reachy-mini-sdk
|
|
3
|
+
> ### Use the latest `@pollen-robotics/reachy-mini-sdk` release
|
|
4
4
|
>
|
|
5
|
-
>
|
|
6
|
-
>
|
|
7
|
-
>
|
|
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;
|
|
@@ -127,7 +130,8 @@ npm run dev
|
|
|
127
130
|
```
|
|
128
131
|
|
|
129
132
|
All three reference apps pin `@pollen-robotics/reachy-mini-sdk` to
|
|
130
|
-
the same
|
|
133
|
+
the same exact version (the latest npm release) in their
|
|
134
|
+
`package.json` - see [§10 SDK version pinning](#10-sdk-version-pinning).
|
|
131
135
|
|
|
132
136
|
> **Prefer a no-build path?** You can also ship the app as a single
|
|
133
137
|
> `index.html` with the SDK loaded from a CDN. No `package.json`, no
|
|
@@ -363,6 +367,7 @@ The resolved `handle` exposes:
|
|
|
363
367
|
interface ConnectedHandle<TConfig> {
|
|
364
368
|
// Live state at boot
|
|
365
369
|
reachy: ReachyMiniInstance; // SDK instance, session live, robot awake
|
|
370
|
+
media: RobotMedia; // WebRTC streams - see "Video: use `handle.media`"
|
|
366
371
|
theme: 'dark' | 'light';
|
|
367
372
|
config: TConfig | null;
|
|
368
373
|
appName: string;
|
|
@@ -385,6 +390,41 @@ The API is intentionally minimal. If you need a custom channel
|
|
|
385
390
|
between host and embed, file a feature request - we'll add it as
|
|
386
391
|
a typed message rather than expose a free-form sink.
|
|
387
392
|
|
|
393
|
+
### Video: use `handle.media`
|
|
394
|
+
|
|
395
|
+
`connectToHost()` resolves only *after* the WebRTC handshake is
|
|
396
|
+
complete. By the time your app mounts, the SDK's one-shot
|
|
397
|
+
`videoTrack` event and the underlying `pc.ontrack` have **already
|
|
398
|
+
fired**. So `reachy.attachVideo(el)` installs a listener that never
|
|
399
|
+
fires, and an embed never calls `startSession()` again: the element
|
|
400
|
+
stays black forever, with no error anywhere.
|
|
401
|
+
|
|
402
|
+
`handle.media` exists for exactly this. It replays the streams from a
|
|
403
|
+
synchronous snapshot of the peer connection's receivers, so a
|
|
404
|
+
late-mounting consumer sees the camera immediately:
|
|
405
|
+
|
|
406
|
+
```ts
|
|
407
|
+
interface RobotMedia {
|
|
408
|
+
attachVideo(el: HTMLVideoElement): () => void; // returns a detach fn
|
|
409
|
+
readonly robotStream: MediaStream | null; // robot video + audio
|
|
410
|
+
readonly micStream: MediaStream | null; // local mic, if enabled
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
const handle = await connectToHost();
|
|
414
|
+
const detach = handle.media.attachVideo(videoEl);
|
|
415
|
+
handle.onLeave(() => detach());
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
There is no equivalent race for the data channel, mute toggles, motor
|
|
419
|
+
commands or state updates: the bridge resolves only once ICE **and**
|
|
420
|
+
the data channel are connected, and state events keep arriving (every
|
|
421
|
+
~500 ms, or ~30 Hz after `subscribePose()`). Keep calling `reachy.setHeadRpyDeg(...)`,
|
|
422
|
+
`reachy.setMicMuted(...)` and `reachy.addEventListener('state', ...)`
|
|
423
|
+
directly.
|
|
424
|
+
|
|
425
|
+
`reachy.attachVideo()` remains correct in a **standalone** app
|
|
426
|
+
(`mountHost`), where your code runs before the session starts.
|
|
427
|
+
|
|
388
428
|
### Typing your config
|
|
389
429
|
|
|
390
430
|
`connectToHost<T>()` types the `config` field; runtime validation
|
|
@@ -645,30 +685,31 @@ Pin yours the same way - mixing versions across `@pollen-robotics/reachy-mini-sd
|
|
|
645
685
|
`@pollen-robotics/reachy-mini-sdk/host`, and the daemon on the robot
|
|
646
686
|
produces hard-to-debug protocol drift.
|
|
647
687
|
|
|
648
|
-
|
|
688
|
+
Install the latest stable release from
|
|
689
|
+
[npm](https://www.npmjs.com/package/@pollen-robotics/reachy-mini-sdk):
|
|
649
690
|
|
|
650
|
-
```
|
|
651
|
-
|
|
652
|
-
"dependencies": {
|
|
653
|
-
"@pollen-robotics/reachy-mini-sdk": "1.8.0"
|
|
654
|
-
}
|
|
655
|
-
}
|
|
691
|
+
```bash
|
|
692
|
+
npm install @pollen-robotics/reachy-mini-sdk@latest
|
|
656
693
|
```
|
|
657
694
|
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
the
|
|
662
|
-
tracking a newer
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
695
|
+
npm writes the exact resolved version into your `package.json`. npm
|
|
696
|
+
versions are immutable, so pinning the exact version is fully
|
|
697
|
+
reproducible — no commit suffix needed. The stable release is
|
|
698
|
+
validated end-to-end against the host shell + daemon. **Use the exact
|
|
699
|
+
version string npm writes** unless you're explicitly tracking a newer
|
|
700
|
+
release. In all cases the version must be **`>= 1.8.0`** — older
|
|
701
|
+
releases predate the host shell + protocol v1 contract and are not
|
|
702
|
+
supported.
|
|
703
|
+
|
|
704
|
+
> The source of truth for "what's current" is the
|
|
705
|
+
> [npm package page](https://www.npmjs.com/package/@pollen-robotics/reachy-mini-sdk)
|
|
706
|
+
> (`npm view @pollen-robotics/reachy-mini-sdk version` works too), and
|
|
707
|
+
> whichever string is currently shared by [`reachy_mini_minimal_conversation`'s
|
|
666
708
|
> `package.json`](https://huggingface.co/spaces/pollen-robotics/reachy_mini_minimal_conversation/blob/main/package.json),
|
|
667
709
|
> [`reachy_mini_emotions`'s `package.json`](https://huggingface.co/spaces/pollen-robotics/reachy_mini_emotions/blob/main/package.json),
|
|
668
710
|
> 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
711
|
|
|
671
|
-
### Why pin a specific build (not `^
|
|
712
|
+
### Why pin a specific build (not `^x.y.z` or a major like `@1`)?
|
|
672
713
|
|
|
673
714
|
The host shell, the embed adapter (`connectToHost`), the SDK, and the
|
|
674
715
|
robot daemon negotiate over a versioned WebRTC data-channel protocol.
|
|
@@ -920,16 +961,18 @@ my-bare-app/
|
|
|
920
961
|
|
|
921
962
|
**Importing the SDK from a CDN**
|
|
922
963
|
|
|
923
|
-
Pin to an exact
|
|
924
|
-
`package.json
|
|
925
|
-
|
|
926
|
-
|
|
964
|
+
Pin to an exact version - **the same string you would use in
|
|
965
|
+
`package.json`**, i.e. the latest release shown on
|
|
966
|
+
[npm](https://www.npmjs.com/package/@pollen-robotics/reachy-mini-sdk)
|
|
967
|
+
(see [§10 SDK version pinning](#10-sdk-version-pinning)). Substitute it
|
|
968
|
+
for `<version>` below. jsDelivr's `/+esm` suffix tells the CDN to bundle
|
|
969
|
+
the package to ESM at the edge:
|
|
927
970
|
|
|
928
971
|
```html
|
|
929
972
|
<script type="module">
|
|
930
|
-
import { ReachyMini } from "https://cdn.jsdelivr.net/npm/@pollen-robotics/reachy-mini-sdk
|
|
931
|
-
import { mountHost } from "https://cdn.jsdelivr.net/npm/@pollen-robotics/reachy-mini-sdk
|
|
932
|
-
import { connectToHost } from "https://cdn.jsdelivr.net/npm/@pollen-robotics/reachy-mini-sdk
|
|
973
|
+
import { ReachyMini } from "https://cdn.jsdelivr.net/npm/@pollen-robotics/reachy-mini-sdk@<version>/+esm";
|
|
974
|
+
import { mountHost } from "https://cdn.jsdelivr.net/npm/@pollen-robotics/reachy-mini-sdk@<version>/host/dist/entry/auto.js";
|
|
975
|
+
import { connectToHost } from "https://cdn.jsdelivr.net/npm/@pollen-robotics/reachy-mini-sdk@<version>/host/dist/entry/embed.js";
|
|
933
976
|
|
|
934
977
|
window.ReachyMini = ReachyMini;
|
|
935
978
|
window.dispatchEvent(new Event("reachymini:ready"));
|
|
@@ -993,9 +1036,10 @@ shell without touching your motion code. The four-step recipe:
|
|
|
993
1036
|
import { ReachyMini } from "https://cdn.jsdelivr.net/gh/pollen-robotics/reachy_mini@v1.7.2/js/reachy-mini.js";
|
|
994
1037
|
|
|
995
1038
|
// AFTER (modern host shell, same SDK runtime API)
|
|
996
|
-
|
|
997
|
-
import {
|
|
998
|
-
import {
|
|
1039
|
+
// <version> = latest release on npm (see §10 SDK version pinning)
|
|
1040
|
+
import { ReachyMini } from "https://cdn.jsdelivr.net/npm/@pollen-robotics/reachy-mini-sdk@<version>/+esm";
|
|
1041
|
+
import { mountHost } from "https://cdn.jsdelivr.net/npm/@pollen-robotics/reachy-mini-sdk@<version>/host/dist/entry/auto.js";
|
|
1042
|
+
import { connectToHost } from "https://cdn.jsdelivr.net/npm/@pollen-robotics/reachy-mini-sdk@<version>/host/dist/entry/embed.js";
|
|
999
1043
|
```
|
|
1000
1044
|
|
|
1001
1045
|
2. **Branch on `?embedded=1`.** Wrap your existing app boot in:
|
|
@@ -1030,8 +1074,11 @@ shell without touching your motion code. The four-step recipe:
|
|
|
1030
1074
|
only exists on the modern SDK; if you weren't using it, nothing
|
|
1031
1075
|
changes. If you reached into private fields like `robot._pc`
|
|
1032
1076
|
(RTCPeerConnection), prefer the public alternatives:
|
|
1033
|
-
`
|
|
1034
|
-
`mountHost` for bidirectional audio.
|
|
1077
|
+
`handle.media.attachVideo(videoEl)` for video, `enableMicrophone: true`
|
|
1078
|
+
on `mountHost` for bidirectional audio. Once embedded, use
|
|
1079
|
+
`handle.media.attachVideo()` and **not** `robot.attachVideo()`: the
|
|
1080
|
+
latter silently no-ops because the handshake completed before your
|
|
1081
|
+
app mounted (see [§5 Video](#video-use-handlemedia)).
|
|
1035
1082
|
|
|
1036
1083
|
Your `README.md` frontmatter doesn't need any changes: `sdk: static`
|
|
1037
1084
|
and `hf_oauth: true` work for both variants. You can still skip
|
|
@@ -1467,7 +1514,9 @@ rolled out by the SDK team, not by every app team.
|
|
|
1467
1514
|
- App bundles (`index-<hash>.js`): hashed by Vite, cache-busted
|
|
1468
1515
|
on deploy.
|
|
1469
1516
|
- `@pollen-robotics/reachy-mini-sdk` in `package.json`: pinned to
|
|
1470
|
-
an **exact version** (
|
|
1517
|
+
an **exact version** (the latest release on
|
|
1518
|
+
[npm](https://www.npmjs.com/package/@pollen-robotics/reachy-mini-sdk)),
|
|
1519
|
+
not a range. See
|
|
1471
1520
|
[§10 SDK version pinning](#10-sdk-version-pinning).
|
|
1472
1521
|
- `@pollen-robotics/reachy-mini-sdk/host` subpath imports: same
|
|
1473
1522
|
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).
|
|
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","sourceRo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CAAC,IAAI,CAAC,EAAE,CAAC,CAA4B,CAAC;IACjE,CAAC;CACJ"}
|
|
@@ -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,KAAK,CAAC,OAAgC,EAAE,EAAU,EAAE,IAAY;IACrE,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAA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B,GACvF,OAAO,CAAC,MAAM,CAAC;IAqCZ,iBAAiB,CACnB,QAAQ,EAAE,MAAM,EAChB,EAAE,SAAgB,EAAE,GAAE,wBAA6B,GACpD,OAAO,CAAC;QAAE,OAAO,EAAE,IAAI,CAAA;KAAE,CAAC;IAkB7B,WAAW,CAAC,QAAQ,GAAE,MAAM,GAAG,IAAW,GAAG,OAAO;IAWpD,OAAO,CAAC,KAAK;IAOb,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"}
|
package/dist/lib/reachy-mini.js
CHANGED
|
@@ -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
|
-
|
|
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') {
|