@tomorrowos/sdk 0.9.46 → 0.9.51

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/LOVABLE_SETUP.md CHANGED
@@ -347,7 +347,7 @@ Copy the same keys to the **Node host** env.
347
347
  "start": "tsx server.ts"
348
348
  },
349
349
  "dependencies": {
350
- "@tomorrowos/sdk": "^0.9.44",
350
+ "@tomorrowos/sdk": "^0.9.51",
351
351
  "dotenv": "^17.2.3",
352
352
  "tsx": "^4.19.0"
353
353
  }
@@ -1,6 +1,6 @@
1
1
  # Vercel / v0 閳?Verbatim question bank
2
2
 
3
- > **Protocol:** `vercel-questions/1.0` (pairs with `VERCEL_SETUP.md` 1.9+ / `@tomorrowos/sdk` 0.9.44+)
3
+ > **Protocol:** `vercel-questions/1.0` (pairs with `VERCEL_SETUP.md` 1.9+ / `@tomorrowos/sdk` 0.9.51+)
4
4
  > **For Agents:** When asking the user a setup question, **copy-paste the block below for that step EXACTLY**.
5
5
  > Do **not** paraphrase, reorder, rename options, or invent alternatives (no S3, no Supabase Storage, no 閳ユ窂lob recommended閳? no 閳ユ竸isable media閳?.
6
6
  > After each answer, configure per `VERCEL_SETUP.md`, then paste the **next** block.
package/VERCEL_SETUP.md CHANGED
@@ -5,7 +5,7 @@
5
5
  >
6
6
  > **On Vercel, this file is the setup questionnaire** (not `REPLIT_SETUP.md`, not `LLM_PROMPT.md`).
7
7
  >
8
- > Protocol id: `vercel-setup/1.9` ? pairs with `@tomorrowos/sdk` **0.9.44+** (`templates/cms-starter-v0`, Fluid Functions WebSockets).
8
+ > Protocol id: `vercel-setup/1.9` pairs with `@tomorrowos/sdk` **0.9.51+** (`templates/cms-starter-v0`, Fluid Functions WebSockets).
9
9
  >
10
10
  > **Questions source of truth:** `VERCEL_QUESTIONS.md` ? Agents must **open that file and paste each Q block verbatim**. Do not paraphrase.
11
11
  > **Copy questions verbatim from `VERCEL_QUESTIONS.md`.** Do not invent alternate Q2 options (no ?Supabase Storage?? no S3, no ?disable media?? no making Blob the recommended option).
@@ -104,6 +104,9 @@ export declare class TomorrowOS extends EventEmitter {
104
104
  private readonly devices;
105
105
  private readonly pendingDeviceMeta;
106
106
  private readonly deviceLogs;
107
+ /** Last device.ping (or bind) time — used to drop half-open sockets after power loss. */
108
+ private readonly deviceLastHeartbeatMs;
109
+ private heartbeatSweepTimer;
107
110
  private httpServer;
108
111
  private wss;
109
112
  private staticRoot;
@@ -149,8 +152,8 @@ export declare class TomorrowOS extends EventEmitter {
149
152
  pushed: boolean;
150
153
  }>;
151
154
  /**
152
- * Clear the daily on/off timer. The player keeps its current mute / power-save
153
- * state until a new timer is set.
155
+ * Clear the daily on/off timer and push null to the device.
156
+ * Connected players drop the schedule and turn the screen back on.
154
157
  */
155
158
  clearDeviceOnOffTimer(deviceId: string): Promise<{
156
159
  deviceId: string;
@@ -175,6 +178,9 @@ export declare class TomorrowOS extends EventEmitter {
175
178
  * hello overwriting a healthy reconnect with a dead peer).
176
179
  */
177
180
  private bindDeviceSocket;
181
+ private touchDeviceHeartbeat;
182
+ private startDeviceHeartbeatSweep;
183
+ private sweepStaleDeviceHeartbeats;
178
184
  /** Wait briefly for the device WebSocket to appear (first-pair hello races). */
179
185
  private waitForOpenDeviceSocket;
180
186
  private sendPairingVerified;
@@ -1 +1 @@
1
- {"version":3,"file":"tomorrowos.d.ts","sourceRoot":"","sources":["../src/tomorrowos.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,IAAI,MAAM,MAAM,CAAC;AAYxB,OAAO,EAAE,eAAe,EAAE,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAChF,OAAO,KAAK,EACV,gBAAgB,EAKhB,eAAe,EAEhB,MAAM,kBAAkB,CAAC;AAe1B,YAAY,EACV,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,aAAa,EACd,MAAM,oBAAoB,CAAC;AAE5B,MAAM,WAA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AqG9B,OAAO,CAAC,iBAAiB;IAWzB,OAAO,CAAC,gBAAgB;CA2KzB"}
@@ -13,6 +13,9 @@ import { probeVideoDurationMs } from "./media-probe.js";
13
13
  import { contentHashHex, storeUploadIfNeeded } from "./upload-storage.js";
14
14
  import { detectPrimaryLanIpv4 } from "./lan-address.js";
15
15
  import { buildServerStatus } from "./server-status.js";
16
+ /** Mark offline if no device.ping within this window (power-loss / half-open TCP). */
17
+ const DEVICE_HEARTBEAT_TIMEOUT_MS = 30_000;
18
+ const DEVICE_HEARTBEAT_SWEEP_MS = 10_000;
16
19
  function normalizeDevicePlatform(platform, system) {
17
20
  const explicit = typeof platform === "string" ? platform.trim().toLowerCase() : "";
18
21
  if (explicit)
@@ -232,6 +235,9 @@ export class TomorrowOS extends EventEmitter {
232
235
  devices = new Map();
233
236
  pendingDeviceMeta = new Map();
234
237
  deviceLogs = new Map();
238
+ /** Last device.ping (or bind) time — used to drop half-open sockets after power loss. */
239
+ deviceLastHeartbeatMs = new Map();
240
+ heartbeatSweepTimer = null;
235
241
  httpServer = null;
236
242
  wss = null;
237
243
  staticRoot = null;
@@ -475,8 +481,8 @@ export class TomorrowOS extends EventEmitter {
475
481
  return { deviceId: id, onOffTimer, pushed };
476
482
  }
477
483
  /**
478
- * Clear the daily on/off timer. The player keeps its current mute / power-save
479
- * state until a new timer is set.
484
+ * Clear the daily on/off timer and push null to the device.
485
+ * Connected players drop the schedule and turn the screen back on.
480
486
  */
481
487
  async clearDeviceOnOffTimer(deviceId) {
482
488
  const id = String(deviceId || "").trim();
@@ -585,8 +591,43 @@ export class TomorrowOS extends EventEmitter {
585
591
  return false;
586
592
  ws.deviceId = deviceId;
587
593
  this.devices.set(deviceId, ws);
594
+ this.touchDeviceHeartbeat(deviceId);
588
595
  return true;
589
596
  }
597
+ touchDeviceHeartbeat(deviceId) {
598
+ const id = String(deviceId || "").trim();
599
+ if (!id)
600
+ return;
601
+ this.deviceLastHeartbeatMs.set(id, Date.now());
602
+ }
603
+ startDeviceHeartbeatSweep() {
604
+ if (this.heartbeatSweepTimer)
605
+ return;
606
+ this.heartbeatSweepTimer = setInterval(() => {
607
+ this.sweepStaleDeviceHeartbeats();
608
+ }, DEVICE_HEARTBEAT_SWEEP_MS);
609
+ // Unref so the timer does not keep serverless/local processes alive alone.
610
+ const timer = this.heartbeatSweepTimer;
611
+ if (typeof timer.unref === "function")
612
+ timer.unref();
613
+ }
614
+ sweepStaleDeviceHeartbeats() {
615
+ const now = Date.now();
616
+ for (const [deviceId, ws] of this.devices) {
617
+ if (ws.readyState !== WebSocket.OPEN)
618
+ continue;
619
+ const last = this.deviceLastHeartbeatMs.get(deviceId);
620
+ // Not yet touched (should be rare) — give a full timeout window from now.
621
+ if (last == null) {
622
+ this.touchDeviceHeartbeat(deviceId);
623
+ continue;
624
+ }
625
+ if (now - last < DEVICE_HEARTBEAT_TIMEOUT_MS)
626
+ continue;
627
+ console.warn(`[TomorrowOS] device heartbeat timeout (${DEVICE_HEARTBEAT_TIMEOUT_MS}ms): ${deviceId}`);
628
+ this.forceDeviceOffline(deviceId);
629
+ }
630
+ }
590
631
  /** Wait briefly for the device WebSocket to appear (first-pair hello races). */
591
632
  async waitForOpenDeviceSocket(deviceId, timeoutMs = 5000) {
592
633
  const deadline = Date.now() + timeoutMs;
@@ -719,6 +760,7 @@ export class TomorrowOS extends EventEmitter {
719
760
  this.devices.delete(deviceId);
720
761
  }
721
762
  }
763
+ this.deviceLastHeartbeatMs.delete(deviceId);
722
764
  void this.touchPairedOffline(deviceId);
723
765
  this.emit("device.offline", {
724
766
  deviceId,
@@ -871,6 +913,7 @@ export class TomorrowOS extends EventEmitter {
871
913
  this.handleConnection(ws);
872
914
  });
873
915
  this.serverStartedAt = new Date().toISOString();
916
+ this.startDeviceHeartbeatSweep();
874
917
  const onVercel = Boolean(process.env.VERCEL);
875
918
  const shouldListen = options.autoListen ?? !onVercel;
876
919
  if (shouldListen) {
@@ -1728,6 +1771,7 @@ export class TomorrowOS extends EventEmitter {
1728
1771
  }));
1729
1772
  const deviceId = ws.deviceId;
1730
1773
  if (deviceId) {
1774
+ this.touchDeviceHeartbeat(deviceId);
1731
1775
  const timestamp = typeof msg.timestamp === "string" && msg.timestamp.trim()
1732
1776
  ? msg.timestamp
1733
1777
  : new Date().toISOString();
@@ -1763,6 +1807,7 @@ export class TomorrowOS extends EventEmitter {
1763
1807
  if (this.devices.get(id) !== ws)
1764
1808
  return;
1765
1809
  this.devices.delete(id);
1810
+ this.deviceLastHeartbeatMs.delete(id);
1766
1811
  void this.touchPairedOffline(id);
1767
1812
  this.emit("device.offline", {
1768
1813
  deviceId: id,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tomorrowos/sdk",
3
- "version": "0.9.46",
3
+ "version": "0.9.51",
4
4
  "description": "TomorrowOS CMS server SDK - WebSocket transport, pairing, device commands, optional static CMS UI. Includes CLI (tomorrowos init / build) and starter templates.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "my-cms",
3
- "version": "0.9.44",
3
+ "version": "0.9.51",
4
4
  "description": "CMS server on @tomorrowos/sdk. Add your UI (React, static files, etc.) alongside this server.",
5
5
  "private": true,
6
6
  "type": "module",
@@ -13,7 +13,7 @@
13
13
  "build-player": "tomorrowos build --platform tizen"
14
14
  },
15
15
  "dependencies": {
16
- "@tomorrowos/sdk": "^0.9.44",
16
+ "@tomorrowos/sdk": "^0.9.51",
17
17
  "dotenv": "^17.2.3",
18
18
  "tsx": "^4.19.0"
19
19
  },
@@ -187,7 +187,7 @@
187
187
  <h2>On / off timer</h2>
188
188
  <p class="hint" id="onOffTimerModalHint">
189
189
  Daily on/off times follow the device clock. Off blacks the screen; the player stays powered and connected to the CMS.
190
- Removing the timer stops the schedule and leaves the screen in its current on or off state until you set a timer again.
190
+ Removing the timer clears the schedule and turns the screen back on.
191
191
  </p>
192
192
  <div class="on-off-timer-grid">
193
193
  <label class="field-label">
@@ -1999,7 +1999,7 @@ async function removeOnOffTimerModal() {
1999
1999
 
2000
2000
  if (
2001
2001
  !confirm(
2002
- "Remove the on/off timer? The screen will stay in its current on or off state until you set a timer again."
2002
+ "Remove the on/off timer? The schedule will be cleared and the screen will turn back on."
2003
2003
  )
2004
2004
  ) {
2005
2005
  return;
@@ -187,7 +187,7 @@
187
187
  <h2>On / off timer</h2>
188
188
  <p class="hint" id="onOffTimerModalHint">
189
189
  Daily on/off times follow the device clock. Off blacks the screen; the player stays powered and connected to the CMS.
190
- Removing the timer stops the schedule and leaves the screen in its current on or off state until you set a timer again.
190
+ Removing the timer clears the schedule and turns the screen back on.
191
191
  </p>
192
192
  <div class="on-off-timer-grid">
193
193
  <label class="field-label">
@@ -2000,7 +2000,7 @@ async function removeOnOffTimerModal() {
2000
2000
 
2001
2001
  if (
2002
2002
  !confirm(
2003
- "Remove the on/off timer? The screen will stay in its current on or off state until you set a timer again."
2003
+ "Remove the on/off timer? The schedule will be cleared and the screen will turn back on."
2004
2004
  )
2005
2005
  ) {
2006
2006
  return;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "my-cms",
3
- "version": "0.9.44",
3
+ "version": "0.9.51",
4
4
  "description": "TomorrowOS CMS for Vercel / v0 Publish (Fluid Function + WebSockets + optional Next Preview).",
5
5
  "private": true,
6
6
  "type": "module",
@@ -17,7 +17,7 @@
17
17
  "build-player": "tomorrowos build --platform tizen"
18
18
  },
19
19
  "dependencies": {
20
- "@tomorrowos/sdk": "^0.9.44",
20
+ "@tomorrowos/sdk": "^0.9.51",
21
21
  "dotenv": "^17.2.3",
22
22
  "tsx": "^4.19.0"
23
23
  },