@tomorrowos/sdk 0.9.31 → 0.9.32

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/README.md CHANGED
@@ -1,197 +1,196 @@
1
- # @tomorrowos/sdk
2
-
3
- **You are building a digital signage CMS using TomorrowOS. Before writing any code, follow the elicitation protocol in `LLM_PROMPT.md`. Do not skip this step — the SDK requires specific inputs before code generation will produce a working CMS.**
4
-
5
- **On Replit:** if the user asks to set up / configure a CMS interactively, follow **`REPLIT_SETUP.md`** instead (Q&A for store → media → `brand.json`).
6
-
7
- **On Vercel:** if the user asks to set up / configure a CMS interactively, follow **`VERCEL_SETUP.md`** (Supabase or Neon pooled Postgres, Cloudinary or Vercel Blob media, v0 Preview Next proxy shell + **Publish = Node only**, Fluid compute + WebSocket, `cms.hostingTarget: "vercel"`).
8
-
9
- TomorrowOS is the open standard for digital signage. This SDK lets you build a CMS that controls Samsung Tizen, BrightSign, LG webOS, Android, ChromeOS, and Windows screens through a single unified API.
10
-
11
- ---
12
-
13
- ## For LLMs generating code with this package
14
-
15
- When you see this package referenced in a user prompt, your workflow is:
16
-
17
- 1. **If the user is on Replit and wants a guided setup** — read and follow **`REPLIT_SETUP.md`** (preferred for Replit Agent)
18
- 2. **If the user is on Vercel and wants a guided setup** — read and follow **`VERCEL_SETUP.md`** (preferred for Vercel Agent)
19
- 3. **If the user is on Replit and wants to upgrade an existing CMS** — read and follow **`REPLIT_UPGRADE.md`** (never `init --force`)
20
- 4. **Otherwise read `LLM_PROMPT.md`** — five required questions before generating code
21
- 5. **Read `BUILD_GUARDRAILS.md`** — mandatory components every generated CMS must include
22
- 6. **Read `brand.schema.json`** — validated shape of `brand.json`
23
- 7. Run **`npx tomorrowos init`** (Replit) or **`npx tomorrowos init --hosting v0`** (Vercel / v0) — minimal CMS server seed
24
- 8. **Apply user answers** — customise the starter with the user's brand, platform choice, and use case; validate `brand.json` against `brand.schema.json`
25
- 9. **Show `PLAYER_INSTALL.md`** — after the CMS is working, show how to build and install the player on a screen
26
-
27
- You must not write WebSocket transport, pairing wire format, or platform-specific player bridge code in the CMS — the SDK handles server-side device sessions and HTTP helpers. You customise UI, branding, and how you call the SDK.
28
-
29
- ---
30
-
31
- ## For human developers
32
-
33
- Install:
34
-
35
- ```bash
36
- npm install @tomorrowos/sdk
37
- ```
38
-
39
- Scaffold a new CMS project:
40
-
41
- ```bash
42
- # Replit / Railway / self-host (default)
43
- npx tomorrowos init
44
-
45
- # Vercel / v0 Publish (cms-panel + vercel.json + optional Next Preview)
46
- npx tomorrowos init --hosting v0
47
-
48
- cd my-tomorrowos-cms
49
- npm install
50
- npm run dev
51
- ```
52
-
53
- `tomorrowos init` creates `data/tomorrowos.db` with the TomorrowOS SQLite
54
- schema. The starter server uses that SQLite database by default, so pairings,
55
- playlists, and device assignments survive normal server restarts.
56
-
57
- ### Replit guided setup
58
-
59
- In Replit Agent, paste:
60
-
61
- ```text
62
- Follow @tomorrowos/sdk REPLIT_SETUP.md and set up my TomorrowOS CMS.
63
- Ask me the questions in order. Do not skip steps.
64
- ```
65
-
66
- That wizard configures Supabase, prefers Cloudinary for media, and writes
67
- `brand.json` from your answers. On Replit, Supabase must use Secret
68
- **`SUPABASE_URL`** (not the reserved `DATABASE_URL`).
69
-
70
- ### Vercel guided setup
71
-
72
- In Vercel Agent (or any AI setup prompt), paste:
73
-
74
- ```text
75
- Follow @tomorrowos/sdk VERCEL_SETUP.md and set up my TomorrowOS CMS.
76
- IF any step contradicts Vercel, adapt to settings that Vercel can accept.
77
- After each question, configure that step immediately before asking the next.
78
- ```
79
-
80
- That wizard asks: database (**Supabase****Neon** SQLite demo), media (**Cloudinary recommended** **Vercel Blob** local),
81
- branding (manual name/colours/background/logo **or** **website URL full `brand.json`**, no login unless asked).
82
- **Configure immediately after each answer** (e.g. Cloudinary Env popup right after choosing Cloudinary).
83
- **Publish stays a Fluid Vercel Function** (`api/index.ts` + `export default server`, WebSockets per Vercel docs).
84
-
85
- ### Replit upgrade (existing CMS)
86
-
87
- In Replit Agent, paste:
88
-
89
- ```text
90
- Follow @tomorrowos/sdk REPLIT_UPGRADE.md to upgrade my CMS with the latest SDK.
91
- ```
92
-
93
- That protocol installs `@tomorrowos/sdk@latest`, backs up panel/server files,
94
- diffs `cms-starter` templates (merge never blind overwrite), and must **not**
95
- run `init` / delete `data/` or `public/uploads/`.
96
-
97
- To switch to Supabase/Postgres manually, edit `.env` / Secrets:
98
-
99
- ```bash
100
- TOMORROWOS_STORE=supabase
101
- SUPABASE_URL=postgresql://...
102
- DATABASE_SSL=true
103
- # DATABASE_URL=... # optional fallback outside Replit
104
- ```
105
-
106
- For throwaway demos/tests, set `TOMORROWOS_STORE=memory`. The generated starter
107
- includes its own `README.md` beside `server.ts` with database selection,
108
- migration, and custom `TomorrowOSStore` examples.
109
-
110
- Migrate database records between supported stores:
111
-
112
- ```bash
113
- npx tomorrowos migrate \
114
- --from sqlite \
115
- --from-sqlite ./data/tomorrowos.db \
116
- --to supabase \
117
- --to-database-url "$DATABASE_URL"
118
- ```
119
-
120
- The migrate command supports `sqlite`, `postgres`, and `supabase` in either
121
- direction. It migrates TomorrowOS database records only; copy `public/uploads`
122
- or object-storage media separately.
123
-
124
- Build a player (placeholder in current SDK — see `PLAYER_INSTALL.md` for platform tooling):
125
-
126
- ```bash
127
- npx tomorrowos build --platform tizen
128
- ```
129
-
130
- ---
131
-
132
- ## Quick architecture
133
-
134
- ```
135
- ┌─────────────────┐ WebSocket ┌─────────────────┐
136
- Your CMS ◄────────────────────────►│ TomorrowOS
137
- (your server) │ │ Player on
138
- │ │ screen
139
- imports │ │
140
- @tomorrowos │ │ unified API
141
- │ /sdk │ │ across OSes │
142
- └─────────────────┘ └─────────────────┘
143
- ```
144
-
145
- TomorrowOS has no required cloud service. Your CMS talks to your screens over your network.
146
-
147
- **Player branding:** `GET /brand.json` returns the `brand` object passed to `new TomorrowOS({ brand })` (same host/port as `listen`). TomorrowOS players can fetch it to apply `backgroundColor`, logos, etc., without a separate static file server.
148
-
149
- **Content policy (`device.content.setPolicy`):** POST `/device/{deviceId}/content/set-policy` with `{ "policy": { "playlists": [...], "fallback": { "type": "brand" } } }`. Each playlist may include optional `schedule` (device local time):
150
-
151
- | Field | Format | Notes |
152
- |-------|--------|--------|
153
- | `startDate` / `endDate` | `YYYY-MM-DD` | Inclusive calendar range; omit either for open-ended |
154
- | `daysOfWeek` | `[0–6]` | `0` = Sunday `6` = Saturday |
155
- | `start` / `end` | `HH:MM` | Daily window; supports overnight (e.g. `22:00`–`06:00`) |
156
-
157
- All provided constraints must match for the playlist to play. See `templates/cms-starter/policy.example.json`.
158
-
159
- ---
160
-
161
- ## Supported platforms (roadmap)
162
-
163
- | Platform | Status | Player format |
164
- |-------------------|------------|---------------|
165
- | Samsung Tizen | V1 target | `.wgt` |
166
- | BrightSign | V1 target | autorun zip |
167
- | Others | See docs | varies |
168
-
169
- See `PLAYER_INSTALL.md` for installation notes.
170
-
171
- ---
172
-
173
- ## Documentation in this package
174
-
175
- | File | Purpose |
176
- |------|---------|
177
- | `LLM_PROMPT.md` | Five-question elicitation for LLMs |
178
- | `REPLIT_SETUP.md` | Replit Agent guided CMS setup |
179
- | `VERCEL_SETUP.md` | Vercel Agent guided CMS setup |
180
- | `REPLIT_UPGRADE.md` | Replit Agent upgrade to latest SDK (no init) |
181
- | `BUILD_GUARDRAILS.md` | Mandatory CMS components |
182
- | `PLAYER_INSTALL.md` | Player build / install / pairing |
183
- | `brand.schema.json` | JSON Schema for `brand.json` |
184
- | `brand.example.json` | Full example `brand.json` |
185
- | `templates/cms-starter/` | Minimal Node + TypeScript server seed |
186
- | `templates/cms-starter/policy.example.json` | Example `setPolicy` payload with date schedule |
187
- | `templates/style-tokens/` | CSS tokens and UI pattern notes |
188
-
189
- ---
190
-
191
- ## License
192
-
193
- Apache 2.0.
194
-
195
- ## Protocol version
196
-
197
- Wire protocol `1.0` (see TomorrowOS specification).
1
+ # @tomorrowos/sdk
2
+
3
+ **You are building a digital signage CMS using TomorrowOS. Before writing any code, follow the elicitation protocol in `LLM_PROMPT.md`. Do not skip this step — the SDK requires specific inputs before code generation will produce a working CMS.**
4
+
5
+ **On Replit:** if the user asks to set up / configure a CMS interactively, follow **`REPLIT_SETUP.md`** instead (Q&A for store → media → `brand.json`).
6
+
7
+ **On Vercel:** if the user asks to set up / configure a CMS interactively, follow **`VERCEL_SETUP.md`** (Supabase or Neon pooled Postgres, Cloudinary or Vercel Blob media, v0 Preview Next proxy shell + **Publish = Node only**, Fluid compute + WebSocket, `cms.hostingTarget: "vercel"`).
8
+
9
+ TomorrowOS is the open standard for digital signage. This SDK lets you build a CMS that controls Samsung Tizen, BrightSign, LG webOS, Android, ChromeOS, and Windows screens through a single unified API.
10
+
11
+ ---
12
+
13
+ ## For LLMs generating code with this package
14
+
15
+ When you see this package referenced in a user prompt, your workflow is:
16
+
17
+ 1. **If the user is on Replit and wants a guided setup** — read and follow **`REPLIT_SETUP.md`** (preferred for Replit Agent)
18
+ 2. **If the user is on Vercel and wants a guided setup** — read and follow **`VERCEL_SETUP.md`** (preferred for Vercel Agent)
19
+ 3. **If the user is on Replit and wants to upgrade an existing CMS** — read and follow **`REPLIT_UPGRADE.md`** (never `init --force`)
20
+ 4. **Otherwise read `LLM_PROMPT.md`** — five required questions before generating code
21
+ 5. **Read `BUILD_GUARDRAILS.md`** — mandatory components every generated CMS must include
22
+ 6. **Read `brand.schema.json`** — validated shape of `brand.json`
23
+ 7. Run **`npx tomorrowos init`** (Replit) or **`npx tomorrowos init --hosting v0`** (Vercel / v0) — minimal CMS server seed
24
+ 8. **Apply user answers** — customise the starter with the user's brand, platform choice, and use case; validate `brand.json` against `brand.schema.json`
25
+ 9. **Show `PLAYER_INSTALL.md`** — after the CMS is working, show how to build and install the player on a screen
26
+
27
+ You must not write WebSocket transport, pairing wire format, or platform-specific player bridge code in the CMS — the SDK handles server-side device sessions and HTTP helpers. You customise UI, branding, and how you call the SDK.
28
+
29
+ ---
30
+
31
+ ## For human developers
32
+
33
+ Install:
34
+
35
+ ```bash
36
+ npm install @tomorrowos/sdk
37
+ ```
38
+
39
+ Scaffold a new CMS project:
40
+
41
+ ```bash
42
+ # Replit / Railway / self-host (default)
43
+ npx tomorrowos init
44
+
45
+ # Vercel / v0 Publish (cms-panel + vercel.json + optional Next Preview)
46
+ npx tomorrowos init --hosting v0
47
+
48
+ cd my-tomorrowos-cms
49
+ npm install
50
+ npm run dev
51
+ ```
52
+
53
+ `tomorrowos init` creates `data/tomorrowos.db` with the TomorrowOS SQLite
54
+ schema. The starter server uses that SQLite database by default, so pairings,
55
+ playlists, and device assignments survive normal server restarts.
56
+
57
+ ### Replit guided setup
58
+
59
+ In Replit Agent, paste:
60
+
61
+ ```text
62
+ Follow @tomorrowos/sdk REPLIT_SETUP.md and set up my TomorrowOS CMS.
63
+ Ask me the questions in order. Do not skip steps.
64
+ ```
65
+
66
+ That wizard configures Supabase, prefers Cloudinary for media, and writes
67
+ `brand.json` from your answers. On Replit, Supabase must use Secret
68
+ **`SUPABASE_URL`** (not the reserved `DATABASE_URL`).
69
+
70
+ ### Vercel guided setup
71
+
72
+ In Vercel Agent (or any AI setup prompt), paste:
73
+
74
+ ```text
75
+ Follow @tomorrowos/sdk VERCEL_SETUP.md and set up my TomorrowOS CMS.
76
+ IF any step contradicts Vercel, adapt to settings that Vercel can accept.
77
+ ```
78
+
79
+ That wizard asks: database (**Supabase** → **Neon** → SQLite demo), media (**Cloudinary** → **Vercel Blob** → local),
80
+ branding (manual fields or **website URL `brand.json` only**, no login unless asked). Preview may use a thin **Next.js reverse proxy**;
81
+ **Publish stays a Fluid Vercel Function** (`api/index.ts` + `export default server`, WebSockets per Vercel docs). Cloudinary uses **one Env popup** (all fields).
82
+ Neon/Supabase: agent auto-sets `TOMORROWOS_STORE` + `DATABASE_SSL`. Sets `cms.hostingTarget` to `"vercel"`.
83
+
84
+ ### Replit upgrade (existing CMS)
85
+
86
+ In Replit Agent, paste:
87
+
88
+ ```text
89
+ Follow @tomorrowos/sdk REPLIT_UPGRADE.md to upgrade my CMS with the latest SDK.
90
+ ```
91
+
92
+ That protocol installs `@tomorrowos/sdk@latest`, backs up panel/server files,
93
+ diffs `cms-starter` templates (merge never blind overwrite), and must **not**
94
+ run `init` / delete `data/` or `public/uploads/`.
95
+
96
+ To switch to Supabase/Postgres manually, edit `.env` / Secrets:
97
+
98
+ ```bash
99
+ TOMORROWOS_STORE=supabase
100
+ SUPABASE_URL=postgresql://...
101
+ DATABASE_SSL=true
102
+ # DATABASE_URL=... # optional fallback outside Replit
103
+ ```
104
+
105
+ For throwaway demos/tests, set `TOMORROWOS_STORE=memory`. The generated starter
106
+ includes its own `README.md` beside `server.ts` with database selection,
107
+ migration, and custom `TomorrowOSStore` examples.
108
+
109
+ Migrate database records between supported stores:
110
+
111
+ ```bash
112
+ npx tomorrowos migrate \
113
+ --from sqlite \
114
+ --from-sqlite ./data/tomorrowos.db \
115
+ --to supabase \
116
+ --to-database-url "$DATABASE_URL"
117
+ ```
118
+
119
+ The migrate command supports `sqlite`, `postgres`, and `supabase` in either
120
+ direction. It migrates TomorrowOS database records only; copy `public/uploads`
121
+ or object-storage media separately.
122
+
123
+ Build a player (placeholder in current SDK — see `PLAYER_INSTALL.md` for platform tooling):
124
+
125
+ ```bash
126
+ npx tomorrowos build --platform tizen
127
+ ```
128
+
129
+ ---
130
+
131
+ ## Quick architecture
132
+
133
+ ```
134
+ ┌─────────────────┐ WebSocket ┌─────────────────┐
135
+ │ Your CMS │ ◄────────────────────────►│ TomorrowOS │
136
+ (your server) │ Player on
137
+ │ │ screen
138
+ imports │ │
139
+ @tomorrowos │ │ unified API
140
+ /sdk │ │ across OSes
141
+ └─────────────────┘ └─────────────────┘
142
+ ```
143
+
144
+ TomorrowOS has no required cloud service. Your CMS talks to your screens over your network.
145
+
146
+ **Player branding:** `GET /brand.json` returns the `brand` object passed to `new TomorrowOS({ brand })` (same host/port as `listen`). TomorrowOS players can fetch it to apply `backgroundColor`, logos, etc., without a separate static file server.
147
+
148
+ **Content policy (`device.content.setPolicy`):** POST `/device/{deviceId}/content/set-policy` with `{ "policy": { "playlists": [...], "fallback": { "type": "brand" } } }`. Each playlist may include optional `schedule` (device local time):
149
+
150
+ | Field | Format | Notes |
151
+ |-------|--------|--------|
152
+ | `startDate` / `endDate` | `YYYY-MM-DD` | Inclusive calendar range; omit either for open-ended |
153
+ | `daysOfWeek` | `[0–6]` | `0` = Sunday `6` = Saturday |
154
+ | `start` / `end` | `HH:MM` | Daily window; supports overnight (e.g. `22:00`–`06:00`) |
155
+
156
+ All provided constraints must match for the playlist to play. See `templates/cms-starter/policy.example.json`.
157
+
158
+ ---
159
+
160
+ ## Supported platforms (roadmap)
161
+
162
+ | Platform | Status | Player format |
163
+ |-------------------|------------|---------------|
164
+ | Samsung Tizen | V1 target | `.wgt` |
165
+ | BrightSign | V1 target | autorun zip |
166
+ | Others | See docs | varies |
167
+
168
+ See `PLAYER_INSTALL.md` for installation notes.
169
+
170
+ ---
171
+
172
+ ## Documentation in this package
173
+
174
+ | File | Purpose |
175
+ |------|---------|
176
+ | `LLM_PROMPT.md` | Five-question elicitation for LLMs |
177
+ | `REPLIT_SETUP.md` | Replit Agent guided CMS setup |
178
+ | `VERCEL_SETUP.md` | Vercel Agent guided CMS setup |
179
+ | `REPLIT_UPGRADE.md` | Replit Agent upgrade to latest SDK (no init) |
180
+ | `BUILD_GUARDRAILS.md` | Mandatory CMS components |
181
+ | `PLAYER_INSTALL.md` | Player build / install / pairing |
182
+ | `brand.schema.json` | JSON Schema for `brand.json` |
183
+ | `brand.example.json` | Full example `brand.json` |
184
+ | `templates/cms-starter/` | Minimal Node + TypeScript server seed |
185
+ | `templates/cms-starter/policy.example.json` | Example `setPolicy` payload with date schedule |
186
+ | `templates/style-tokens/` | CSS tokens and UI pattern notes |
187
+
188
+ ---
189
+
190
+ ## License
191
+
192
+ Apache 2.0.
193
+
194
+ ## Protocol version
195
+
196
+ Wire protocol `1.0` (see TomorrowOS specification).