@pollen-robotics/reachy-mini-sdk 1.10.0-dev.0.main.b50d97e → 1.10.0-dev.0.main.c8367cd

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 (128) hide show
  1. package/APP_CREATION_GUIDE.md +98 -0
  2. package/dist/lib/central-listener.d.ts +71 -0
  3. package/dist/lib/central-listener.d.ts.map +1 -0
  4. package/dist/lib/central-listener.js +277 -0
  5. package/dist/lib/central-listener.js.map +1 -0
  6. package/dist/lib/central-listener.test.d.ts +2 -0
  7. package/dist/lib/central-listener.test.d.ts.map +1 -0
  8. package/dist/lib/central-listener.test.js +378 -0
  9. package/dist/lib/central-listener.test.js.map +1 -0
  10. package/dist/lib/dc-watchdog.test.d.ts +2 -0
  11. package/dist/lib/dc-watchdog.test.d.ts.map +1 -0
  12. package/dist/lib/dc-watchdog.test.js +154 -0
  13. package/dist/lib/dc-watchdog.test.js.map +1 -0
  14. package/dist/lib/ensure-awake.test.d.ts +2 -0
  15. package/dist/lib/ensure-awake.test.d.ts.map +1 -0
  16. package/dist/lib/ensure-awake.test.js +117 -0
  17. package/dist/lib/ensure-awake.test.js.map +1 -0
  18. package/dist/lib/ice-grace.test.d.ts +2 -0
  19. package/dist/lib/ice-grace.test.d.ts.map +1 -0
  20. package/dist/lib/ice-grace.test.js +211 -0
  21. package/dist/lib/ice-grace.test.js.map +1 -0
  22. package/dist/lib/imu.test.d.ts +2 -0
  23. package/dist/lib/imu.test.d.ts.map +1 -0
  24. package/dist/lib/imu.test.js +78 -0
  25. package/dist/lib/imu.test.js.map +1 -0
  26. package/dist/lib/logger.d.ts +38 -0
  27. package/dist/lib/logger.d.ts.map +1 -0
  28. package/dist/lib/logger.js +81 -0
  29. package/dist/lib/logger.js.map +1 -0
  30. package/dist/lib/pending-replies.d.ts +127 -0
  31. package/dist/lib/pending-replies.d.ts.map +1 -0
  32. package/dist/lib/pending-replies.js +255 -0
  33. package/dist/lib/pending-replies.js.map +1 -0
  34. package/dist/lib/pending-replies.test.d.ts +2 -0
  35. package/dist/lib/pending-replies.test.d.ts.map +1 -0
  36. package/dist/lib/pending-replies.test.js +217 -0
  37. package/dist/lib/pending-replies.test.js.map +1 -0
  38. package/dist/lib/reachy-mini.d.ts +202 -88
  39. package/dist/lib/reachy-mini.d.ts.map +1 -1
  40. package/dist/lib/reachy-mini.js +651 -566
  41. package/dist/lib/reachy-mini.js.map +1 -1
  42. package/dist/lib/redial.test.d.ts +2 -0
  43. package/dist/lib/redial.test.d.ts.map +1 -0
  44. package/dist/lib/redial.test.js +206 -0
  45. package/dist/lib/redial.test.js.map +1 -0
  46. package/dist/lib/request.test.d.ts +2 -0
  47. package/dist/lib/request.test.d.ts.map +1 -0
  48. package/dist/lib/request.test.js +90 -0
  49. package/dist/lib/request.test.js.map +1 -0
  50. package/dist/lib/session-supervisor.d.ts +201 -0
  51. package/dist/lib/session-supervisor.d.ts.map +1 -0
  52. package/dist/lib/session-supervisor.js +520 -0
  53. package/dist/lib/session-supervisor.js.map +1 -0
  54. package/dist/lib/token-store.d.ts +50 -0
  55. package/dist/lib/token-store.d.ts.map +1 -0
  56. package/dist/lib/token-store.js +120 -0
  57. package/dist/lib/token-store.js.map +1 -0
  58. package/dist/lib/token-store.test.d.ts +2 -0
  59. package/dist/lib/token-store.test.d.ts.map +1 -0
  60. package/dist/lib/token-store.test.js +82 -0
  61. package/dist/lib/token-store.test.js.map +1 -0
  62. package/dist/lib/types.d.ts +280 -6
  63. package/dist/lib/types.d.ts.map +1 -1
  64. package/dist/lib/url-helpers.d.ts.map +1 -1
  65. package/dist/lib/url-helpers.js +3 -1
  66. package/dist/lib/url-helpers.js.map +1 -1
  67. package/dist/lib/version.d.ts +2 -0
  68. package/dist/lib/version.d.ts.map +1 -0
  69. package/dist/lib/version.js +5 -0
  70. package/dist/lib/version.js.map +1 -0
  71. package/dist/reachy-mini-sdk.d.ts +15 -1
  72. package/dist/reachy-mini-sdk.d.ts.map +1 -1
  73. package/dist/reachy-mini-sdk.js +12 -0
  74. package/dist/reachy-mini-sdk.js.map +1 -1
  75. package/host/dist/ReachyHost.d.ts.map +1 -1
  76. package/host/dist/chunks/centralRest-uXNMidlL.js +2315 -0
  77. package/host/dist/chunks/index-Beu4GNzi.js +821 -0
  78. package/host/dist/chunks/{mountHost-DjE5zE9R.js → mountHost-BTTF4Uu9.js} +24933 -27488
  79. package/host/dist/components/ConnectingView.d.ts.map +1 -1
  80. package/host/dist/components/DaemonUpdateGate.d.ts +65 -0
  81. package/host/dist/components/DaemonUpdateGate.d.ts.map +1 -0
  82. package/host/dist/components/ErrorView.d.ts.map +1 -1
  83. package/host/dist/components/HostErrorBoundary.d.ts +30 -0
  84. package/host/dist/components/HostErrorBoundary.d.ts.map +1 -0
  85. package/host/dist/components/LeavingView.d.ts.map +1 -1
  86. package/host/dist/components/PickerView.d.ts +16 -14
  87. package/host/dist/components/PickerView.d.ts.map +1 -1
  88. package/host/dist/components/PostOAuthSplash.d.ts +14 -9
  89. package/host/dist/components/PostOAuthSplash.d.ts.map +1 -1
  90. package/host/dist/components/ReachyHostShell.d.ts.map +1 -1
  91. package/host/dist/components/SignInView.d.ts.map +1 -1
  92. package/host/dist/components/TopBar.d.ts +5 -6
  93. package/host/dist/components/TopBar.d.ts.map +1 -1
  94. package/host/dist/components/WelcomeBackOverlay.d.ts.map +1 -1
  95. package/host/dist/embed/index.d.ts +68 -5
  96. package/host/dist/embed/index.d.ts.map +1 -1
  97. package/host/dist/entry/auto.js +2 -2
  98. package/host/dist/entry/embed.d.ts +5 -4
  99. package/host/dist/entry/embed.d.ts.map +1 -1
  100. package/host/dist/entry/embed.js +5 -4
  101. package/host/dist/hooks/useHostBridge.d.ts +35 -1
  102. package/host/dist/hooks/useHostBridge.d.ts.map +1 -1
  103. package/host/dist/hooks/useLatestDaemonVersion.d.ts +7 -0
  104. package/host/dist/hooks/useLatestDaemonVersion.d.ts.map +1 -0
  105. package/host/dist/hooks/useOAuth.d.ts +18 -0
  106. package/host/dist/hooks/useOAuth.d.ts.map +1 -1
  107. package/host/dist/hooks/useRobots.d.ts +0 -2
  108. package/host/dist/hooks/useRobots.d.ts.map +1 -1
  109. package/host/dist/index.d.ts +2 -2
  110. package/host/dist/index.d.ts.map +1 -1
  111. package/host/dist/index.js +11 -10
  112. package/host/dist/lib/daemonRelease.d.ts +84 -0
  113. package/host/dist/lib/daemonRelease.d.ts.map +1 -0
  114. package/host/dist/lib/protocol.d.ts +141 -7
  115. package/host/dist/lib/protocol.d.ts.map +1 -1
  116. package/host/dist/lib/rebootWatch.d.ts +51 -0
  117. package/host/dist/lib/rebootWatch.d.ts.map +1 -0
  118. package/host/dist/lib/sdk-types.d.ts +1 -1
  119. package/host/dist/lib/sdk-types.d.ts.map +1 -1
  120. package/host/dist/lib/sdkStaleness.d.ts +78 -0
  121. package/host/dist/lib/sdkStaleness.d.ts.map +1 -0
  122. package/host/dist/lib/settings.d.ts +16 -5
  123. package/host/dist/lib/settings.d.ts.map +1 -1
  124. package/package.json +11 -4
  125. package/host/dist/chunks/index-lMs2sCXG.js +0 -439
  126. package/host/dist/chunks/reachy-mini-CdsdQLIU.js +0 -1523
  127. package/host/dist/lib/centralListener.d.ts +0 -73
  128. package/host/dist/lib/centralListener.d.ts.map +0 -1
@@ -0,0 +1,201 @@
1
+ /**
2
+ * Session resilience supervisor for the ReachyMini SDK.
3
+ *
4
+ * Owns the three transport-resilience mechanisms so the main class only
5
+ * has to forward browser/pc events and expose narrow accessors:
6
+ *
7
+ * 1. ICE-blip debounce + network awareness — grace windows around
8
+ * `iceConnectionState` transitions (visibility-deferred while the
9
+ * tab is hidden) and `online`/`offline`/`connection.change`
10
+ * forwarding as public events.
11
+ * 2. Automatic session re-dial — the daemon's `webrtcbin` cannot do a
12
+ * standards ICE restart (missing upstream support), so the recovery
13
+ * unit is the whole SESSION: tear down the dead RTCPeerConnection
14
+ * and dial the same robot again through central. Runs inside the
15
+ * SDK so every consumer (host embed, mobile app, third-party apps)
16
+ * inherits it.
17
+ * 3. Data-channel silence watchdog — application-level heartbeat
18
+ * without any daemon change: a streaming session already receives
19
+ * constant inbound traffic (get_state poll replies and/or pushed
20
+ * pose frames), so prolonged TOTAL silence is a dead transport that
21
+ * ICE hasn't noticed yet.
22
+ *
23
+ * The supervisor never touches the RTCPeerConnection, data channel or
24
+ * pending promises directly: every side effect goes through
25
+ * `SessionSupervisorDeps`, implemented by `ReachyMini` as closures over
26
+ * its own private state. That keeps the ownership boundary honest — the
27
+ * class owns the transport, the supervisor owns the RECOVERY POLICY.
28
+ */
29
+ import type { ReachyMiniEventMap } from './types.js';
30
+ /**
31
+ * Everything the supervisor needs from `ReachyMini`, as read accessors
32
+ * and side-effect callbacks. Implemented with arrow closures so every
33
+ * call reads the CURRENT class state (tests stub instance methods and
34
+ * the closures pick the stubs up transparently).
35
+ */
36
+ export interface SessionSupervisorDeps {
37
+ /** Live ICE state, or `null` when no RTCPeerConnection exists. */
38
+ iceState(): RTCIceConnectionState | null;
39
+ /** True while a live RTCPeerConnection exists. */
40
+ hasPc(): boolean;
41
+ /** True once the session reached `streaming`. */
42
+ isStreaming(): boolean;
43
+ /** True while startSession() is mid-handshake (resolvers armed). */
44
+ isMidSetup(): boolean;
45
+ /** True when the signaling SSE feed is down (`state === 'disconnected'`). */
46
+ isSignalingDown(): boolean;
47
+ /** Robot id of the current / last dialed session. */
48
+ selectedRobotId(): string | null;
49
+ /**
50
+ * Reject the pending startSession() promise, if armed, and clear the
51
+ * resolvers. Returns `true` when one was actually pending — the
52
+ * supervisor then leaves the retry decision to the original caller.
53
+ */
54
+ rejectPendingSession(err: Error): boolean;
55
+ /** Re-establish the signaling feed (the SSE died with the network). */
56
+ reconnectSignaling(): Promise<void>;
57
+ /** One dial attempt: the class's full startSession() flow. */
58
+ dial(robotId: string): Promise<void>;
59
+ /** Transport-only teardown between attempts (owned by the class). */
60
+ teardownForRedial(): void;
61
+ /** Send one `get_state` probe over the data channel. */
62
+ nudgeState(): void;
63
+ /** Emit one public event on the instance. */
64
+ emit<K extends keyof ReachyMiniEventMap>(name: K, detail: ReachyMiniEventMap[K]['detail']): void;
65
+ }
66
+ export declare class SessionSupervisor {
67
+ private readonly _deps;
68
+ private _iceGraceTimer;
69
+ private _iceGraceReason;
70
+ private _pendingVisibilityHandler;
71
+ private _onlineHandler;
72
+ private _offlineHandler;
73
+ private _connectionChangeHandler;
74
+ private _autoReconnect;
75
+ private _redialing;
76
+ private _redialWake;
77
+ private _dcWatchdogId;
78
+ private _lastDcInboundAt;
79
+ private _dcWatchdogLastTickAt;
80
+ private _dcSilenceNudged;
81
+ constructor(deps: SessionSupervisorDeps, options: {
82
+ autoReconnect: boolean;
83
+ });
84
+ /** True while the re-dial loop is running. */
85
+ get redialing(): boolean;
86
+ /**
87
+ * Enable/disable the automatic session re-dial at runtime.
88
+ * Disabling also aborts any re-dial already in flight.
89
+ */
90
+ setAutoReconnect(enabled: boolean): void;
91
+ /** Fatal errors carry the classic webrtc `error` payload shape. */
92
+ private _emitError;
93
+ /** ICE healed back to `connected`/`completed`. */
94
+ onIceHealed(): void;
95
+ /**
96
+ * ICE hit `disconnected` — TRANSIENT per spec, debounce before
97
+ * escalating. If the tab is hidden, JS timers are throttled and
98
+ * would fire unpredictably late, so defer the grace window to the
99
+ * next foreground frame.
100
+ */
101
+ onIceDisconnected(): void;
102
+ /**
103
+ * ICE hit `failed` — terminal per spec, but in practice we've seen
104
+ * `failed → connected` on rapid AP roams / BT route changes on iOS.
105
+ * Give the ICE agent a short window to surprise us before rejecting
106
+ * the session.
107
+ */
108
+ onIceFailed(): void;
109
+ /**
110
+ * Cancel any pending ICE grace timer and visibility handler. Called
111
+ * on a healed `connected`/`completed` transition AND from the
112
+ * lifecycle teardown paths so a callback can't fire after the pc
113
+ * is closed.
114
+ */
115
+ clearIceGrace(): void;
116
+ /**
117
+ * Start a grace window. After `ms`, re-check the live ICE state:
118
+ * - If we healed back to `connected`/`completed`, the timer was
119
+ * already cancelled in the pc's state handler, so we never get
120
+ * here.
121
+ * - If we're still in the originally-observed bad state (or
122
+ * worse), surface the error and reject any pending session
123
+ * promise. The original code path is preserved verbatim so
124
+ * downstream consumers see the same `error` payload shape.
125
+ */
126
+ private _scheduleIceGrace;
127
+ /**
128
+ * `disconnected` while the tab is hidden. JS timers are throttled
129
+ * in background tabs (Chrome clamps to ~1 Hz, Safari can pause
130
+ * altogether), so a foreground grace timer would either miss the
131
+ * window or fire long after the connection healed. Wait for the
132
+ * tab to come back, then re-evaluate.
133
+ */
134
+ private _armIceGraceOnVisibility;
135
+ /**
136
+ * Install browser-level network listeners and forward them as
137
+ * public `networkOnline` / `networkOffline` / `networkChange`
138
+ * events on the instance. Idempotent: called from `startSession()`,
139
+ * removed by `uninstallNetworkListeners` on teardown. Reachable
140
+ * only when there's a live `window` (defensive guard for SSR /
141
+ * test environments).
142
+ *
143
+ * `online` / `offline` are semantically about CONNECTIVITY:
144
+ * "does the OS think we can reach the internet". They flip
145
+ * symmetrically.
146
+ *
147
+ * `connection.change` (NetworkInformation API, Chrome / Android
148
+ * WebView only) is semantically about the TRANSPORT: it fires
149
+ * on Wi-Fi → 4G swaps, AP roams, etc. without necessarily going
150
+ * through `offline`. We forward it as its own `networkChange`
151
+ * event rather than aliasing it onto `networkOnline`, so
152
+ * consumers don't have to guess whether they're seeing a real
153
+ * connectivity recovery or a silent transport swap.
154
+ */
155
+ installNetworkListeners(): void;
156
+ /** Counterpart to `installNetworkListeners`. */
157
+ uninstallNetworkListeners(): void;
158
+ /**
159
+ * Escalation funnel for dead-transport signals. Returns `true` when
160
+ * the failure is being handled by a re-dial (callers should then skip
161
+ * their fatal `error` emit). Only fires for an ESTABLISHED session:
162
+ * mid-setup failures keep rejecting the startSession() promise so the
163
+ * original caller stays in charge of retries.
164
+ */
165
+ maybeBeginRedial(cause: string): boolean;
166
+ /**
167
+ * The re-dial loop. One teardown, then up to REDIAL_BACKOFF_MS.length
168
+ * attempts, each preceded by its backoff slot. Every attempt re-runs
169
+ * the normal startSession() flow (and connect() first if the SSE feed
170
+ * died with the network), so a success is indistinguishable from a
171
+ * fresh session: `streaming` re-fires, videoTrack re-attaches, the
172
+ * pose subscription is re-asserted by the session-ready path.
173
+ *
174
+ * Exits early — without emitting anything further — when the user
175
+ * calls stopSession()/disconnect() or dials another robot, all of
176
+ * which flip `_redialing` off via `cancelRedial`.
177
+ */
178
+ private _runRedialLoop;
179
+ /**
180
+ * Cancellable backoff sleep — `cancelRedial` wakes it immediately.
181
+ * A timer firing after a cancel is harmless: the loop re-checks
182
+ * `_redialing` right after every sleep.
183
+ */
184
+ private _redialSleep;
185
+ /**
186
+ * Abort a pending re-dial. Called from stopSession(), disconnect()
187
+ * and an external startSession() — every path where the user (or the
188
+ * consumer app) takes over the session lifecycle.
189
+ */
190
+ cancelRedial(): void;
191
+ /** (Re)start the watchdog. Called when a session reaches ready. */
192
+ startDcWatchdog(): void;
193
+ stopDcWatchdog(): void;
194
+ /**
195
+ * Liveness stamp: every inbound data-channel message — control
196
+ * replies, broadcasts, pose frames — proves the transport is alive.
197
+ */
198
+ stampDcInbound(): void;
199
+ private _dcWatchdogTick;
200
+ }
201
+ //# sourceMappingURL=session-supervisor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-supervisor.d.ts","sourceRoot":"","sources":["../../lib/session-supervisor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAgDrD;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB;IAClC,kEAAkE;IAClE,QAAQ,IAAI,qBAAqB,GAAG,IAAI,CAAC;IACzC,kDAAkD;IAClD,KAAK,IAAI,OAAO,CAAC;IACjB,iDAAiD;IACjD,WAAW,IAAI,OAAO,CAAC;IACvB,oEAAoE;IACpE,UAAU,IAAI,OAAO,CAAC;IACtB,6EAA6E;IAC7E,eAAe,IAAI,OAAO,CAAC;IAC3B,qDAA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