@tomorrowos/sdk 0.9.27 → 0.9.28

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/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.6` — pairs with `@tomorrowos/sdk` packages that ship `templates/cms-starter` and this file.
8
+ > Protocol id: `vercel-setup/1.7` — pairs with `@tomorrowos/sdk` packages that ship `templates/cms-starter` and this file.
9
9
 
10
10
  ## User trigger (copy-paste)
11
11
 
@@ -19,7 +19,8 @@ If any step contradicts Vercel, adapt to settings Vercel can accept (document th
19
19
  After all setup questions are answered (including Cloudinary or Vercel Blob Env Vars if you chose those), configure and deploy — minimal verification only (Control Panel at /). Prefer Supabase Session pooler URL or Neon pooled URL. Do not treat sandbox ENETUNREACH / IPv6 :5432 errors as a hard setup failure when a pooler URL is configured for production.
20
20
  Question 3 only updates brand.json from colours/logo/name (a website URL is brand reference only — do not add CMS login/auth unless the user explicitly asks). Do not skip steps.
21
21
  Use Next.js only as a v0/Preview shell with a reverse proxy; Production Publish must remain pure Node TomorrowOS.listen (not Next).
22
- Before claiming Publish works: Framework Preset must be Other/null (not Next.js), startCommand must run TomorrowOS Node, GET /status on the production URL must return JSON (not HTML), and GET / must return the Control Panel (not 404 NOT_FOUND).
22
+ Before claiming Publish works: Framework Preset must be Other/null (not Next.js), package.json `start` must run TomorrowOS Node, GET /status on the production URL must return JSON (not HTML), and GET / must return the Control Panel (not 404 NOT_FOUND).
23
+ Do not put startCommand or processes in vercel.json (v0 schema rejects them). Do not move server.ts into api/.
23
24
  ```
24
25
 
25
26
  Alternate triggers:
@@ -252,14 +253,21 @@ Use the pattern in **Runtime & Vercel deploy rules** below. On Publish, **do not
252
253
 
253
254
  ### A3 — `vercel.json` (Production)
254
255
 
256
+ **v0 / `.v0/vercel.deploy.json` schema:** only a **minimal** object is valid. These keys are **rejected** — never add them:
257
+
258
+ - ❌ `startCommand`
259
+ - ❌ `processes`
260
+ - ❌ `routes` / `rewrites` to fake API routing
261
+ - ❌ `outputDirectory: "public"` or `"."`
262
+
263
+ Vercel discovers the start command from **`package.json` → `"start": "tsx server.ts"`**, not from `vercel.json`.
264
+
255
265
  ```json
256
266
  {
257
267
  "fluid": true,
258
268
  "framework": null,
259
269
  "installCommand": "npm install",
260
- "buildCommand": "npm run build",
261
- "startCommand": "npm run start",
262
- "outputDirectory": null
270
+ "buildCommand": "npm run build"
263
271
  }
264
272
  ```
265
273
 
@@ -267,9 +275,10 @@ Use `pnpm` / `yarn` equivalents if the project uses them.
267
275
 
268
276
  **Critical:**
269
277
 
270
- - `"outputDirectory": null` **never** `"public"`, `"."`, or `"public if exists"`
271
- - `"startCommand"` must be explicit when the dashboard keeps defaulting to static
272
- - `"buildCommand"` must be the no-op `npm run build` — **never** `next build` for Production
278
+ - **Do not** add `startCommand` to `vercel.json` (invalid in v0; redundant on full Vercel — use `package.json` `start`)
279
+ - **Do not** set `outputDirectory` to `public` or `.`
280
+ - `"buildCommand"` must run the no-op `npm run build` — **never** `next build` for Production
281
+ - Set **Output Directory empty** in the **Vercel dashboard** (Scheme A4) — that is where static-vs-Node is decided, not via invalid `vercel.json` keys
273
282
 
274
283
  ### A4 — Vercel Project Settings (dashboard or API — mandatory)
275
284
 
@@ -294,14 +303,43 @@ If Framework Preset still shows **Next.js** after `vercel.json`: **patch via Ver
294
303
  4. Control Panel **does not** show `Unexpected token 'T'` / CMS unreachable
295
304
  5. Framework Preset = Other; Fluid on
296
305
 
297
- If (2) fails but (3) passes → **static `public/` trap**. Re-apply A3 + A4; confirm `startCommand`; redeploy. **Do not** add `api/` catch-all.
306
+ If (2) fails but (3) passes → **static `public/` trap**. Re-apply A3 + A4; confirm dashboard Start Command + empty Output Directory; redeploy. **Do not** add `api/` catch-all. **Do not** move `server.ts` into `api/`.
298
307
 
299
308
  ### A6 — What Scheme A does **not** require
300
309
 
301
310
  - ❌ No changes to `@tomorrowos/sdk` package code
302
- - ❌ No `(req, res)` handler refactor
311
+ - ❌ No `(req, res)` serverless handler refactor
303
312
  - ❌ No `next build` / `next start` on Production
304
- - ❌ No root `api/` directory for the CMS server
313
+ - ❌ No root `api/` directory (`api/index.ts`, `api/[...].ts`, `api/[[...slug]].ts`)
314
+ - ❌ No `rewrites` so only `/api/status` works while `/status` stays 404
315
+ - ❌ No renaming `start` → `dev` with `tsx watch` for Production
316
+ - ❌ No `@vercel/node` handler that calls non-existent `tomorrowos.getStatus()`
317
+
318
+ ### A7 — If v0 Publish still serves static `public/` (Path B)
319
+
320
+ When **v0 Publish** keeps returning the static trap (`/` HTML OK, `/status` HTML, `Unexpected token 'T'`) **after** Scheme A is correct, the v0 deploy pipeline may not be starting the Fluid Node server.
321
+
322
+ **Path B — deploy outside v0 Publish (recommended):**
323
+
324
+ 1. Keep Scheme A layout (root `server.ts`, Next only under `preview/`, minimal `vercel.json`).
325
+ 2. Connect the repo to **Vercel Git** or run **`vercel --prod`** from the project root (full Vercel CLI / dashboard deploy — not the v0 “Publish” button).
326
+ 3. In **Vercel Dashboard → Project → Settings → General**: Framework = **Other**, Output Directory = **empty**, Build = `npm run build`, **override** Install/Start if needed so Production runs `npm run start`.
327
+ 4. Redeploy; verify `curl https://PROD/status` → JSON.
328
+
329
+ **Path C — if Vercel cannot run TomorrowOS Node + WebSocket reliably:**
330
+
331
+ Host the CMS on **Railway**, **Fly.io**, or **Replit Publish** (long-lived Node). Use v0/Vercel only for Preview/demo if needed.
332
+
333
+ ### A8 — Undo a broken Agent “api/ migration”
334
+
335
+ If an Agent moved `server.ts` → `api/index.ts` / `api/[...].ts` and only `/api/status` returns JSON:
336
+
337
+ 1. **Restore** `server.ts` at **project root** (from git or `templates/cms-starter/server.ts`).
338
+ 2. **Delete** root `api/index.ts`, `api/[...].ts`, `api/[[...slug]].ts` (Preview proxy may stay under `preview/app/` only).
339
+ 3. Revert `package.json` `start` to `tsx server.ts` (not `tsx watch` for Production).
340
+ 4. Apply minimal `vercel.json` (A3) — no `startCommand`, no `rewrites`.
341
+ 5. Dashboard: Framework Other, Output empty, Fluid on.
342
+ 6. Redeploy via Path B if v0 Publish still fails.
305
343
 
306
344
  ---
307
345
 
@@ -448,13 +486,13 @@ Write `vercel.json` so Production cannot be mistaken for Next. Minimum:
448
486
  "fluid": true,
449
487
  "framework": null,
450
488
  "installCommand": "npm install",
451
- "buildCommand": "npm run build",
452
- "startCommand": "npm run start",
453
- "outputDirectory": null
489
+ "buildCommand": "npm run build"
454
490
  }
455
491
  ```
456
492
 
457
- Use `pnpm` / `yarn` variants of install/build/start if that is the project’s package manager.
493
+ Use `pnpm` / `yarn` variants of install/build if that is the project’s package manager.
494
+
495
+ **Do not** add `startCommand`, `processes`, or `outputDirectory` to `vercel.json` when v0 schema rejects them. Start = `package.json` `"start": "tsx server.ts"`. Output Directory = **empty in dashboard**.
458
496
 
459
497
  **Also force Project Settings (dashboard or Vercel API) — this is mandatory (see Scheme A4):**
460
498
 
@@ -464,7 +502,7 @@ Use `pnpm` / `yarn` variants of install/build/start if that is the project’s p
464
502
  | Install Command | `npm install` (or pnpm/yarn) |
465
503
  | Build Command | `npm run build` (no-op exit 0) |
466
504
  | Output Directory | **empty / null** — **NOT `public`** |
467
- | Start Command | `npm run start` → `tsx server.ts` (or `.mts`) — **explicit in `vercel.json` too** |
505
+ | Start Command | `npm run start` → `tsx server.ts` (or `.mts`) — set in **dashboard**, not `vercel.json` |
468
506
  | Fluid compute | **On** |
469
507
 
470
508
  If `next` / `next.config.*` exist for Preview and the dashboard still auto-selects Next.js:
@@ -766,7 +804,7 @@ Then (**Scheme A — mandatory for Publish**):
766
804
 
767
805
  1. Keep **`server.ts`** at **project root** with top-level `listen()` + `export default server`.
768
806
  2. If Preview needs Next: **move** `next.config.*`, `app/`, Next `tsconfig` / `postcss` / `next-env.d.ts` into **`preview/`** — remove them from root so Production is not mistaken for Next/static.
769
- 3. Write `vercel.json` per **Scheme A3** (`fluid`, `framework: null`, `startCommand`, `outputDirectory: null`).
807
+ 3. Write `vercel.json` per **Scheme A3** (`fluid`, `framework: null`, no-op `buildCommand` — **no** `startCommand`).
770
808
  4. **Force Project Settings** per **Scheme A4** (Framework = Other, Output Directory empty, Start = `npm run start`, Fluid on). Patch dashboard via API if it still says Next.js.
771
809
  5. Do **not** add root `api/` catch-all for raw `http.Server`.
772
810
  6. Do **not** add `.replit*`.
@@ -818,7 +856,7 @@ vercel --prod
818
856
  6. Production `GET /status` returns **JSON** — **not** HTML (`Unexpected token 'T'` means this failed)
819
857
  7. Production `GET /` returns Control Panel HTML — **not** `404: NOT_FOUND`
820
858
 
821
- If step 6 fails but step 7 passes: **static `public/` trap** — Vercel is not running Node. Re-apply Scheme A3–A4; do **not** invent `api/` + `routes`.
859
+ If step 6 fails but step 7 passes: **static `public/` trap** — Vercel is not running Node. Re-apply Scheme A3–A4; try **Path B** (Git / `vercel --prod`); do **not** invent `api/` + `rewrites`.
822
860
 
823
861
  Tell the user:
824
862
 
@@ -846,8 +884,11 @@ Tell the user:
846
884
  | Symptom | Likely cause | Fix |
847
885
  |---------|--------------|-----|
848
886
  | Publish `404: NOT_FOUND` | Framework Preset still **Next.js** / no Node start | Scheme A: Framework = **Other**, Start = `npm run start`, Output empty, Fluid on; redeploy |
849
- | Panel loads but **CMS unreachable** / `Unexpected token 'T', "The page c"...` | **`public/` deployed as static site** — no Node running | Scheme A: `outputDirectory: null`, explicit `startCommand`, move Next to `preview/`; verify `GET /status` returns JSON |
850
- | `vercel inspect` shows Output = `public if it exists` | Framework=Other static default | Force Output Directory **empty** in dashboard + `outputDirectory: null`; ensure root `server.ts` + `startCommand` |
887
+ | Panel loads but **CMS unreachable** / `Unexpected token 'T', "The page c"...` | **`public/` deployed as static site** — no Node running | Scheme A: Output empty in dashboard, `start` in package.json; undo any `api/` migration; try **Path B** deploy |
888
+ | Only `/api/status` returns JSON, `/status` is 404 | Wrong **api/ serverless** migration + broken rewrites | **A8 undo:** restore root `server.ts`, delete root `api/*`; never accept this as “fixed” |
889
+ | `vercel.json` error: invalid `startCommand` | v0 schema rejects it | Remove from `vercel.json`; use `package.json` `start` + dashboard Start Command |
890
+ | Agent moved server to `api/`, added `@vercel/node` handler | Off-protocol serverless refactor | **A8 undo** — TomorrowOS needs one root `listen()` server, not per-request handlers |
891
+ | `vercel inspect` shows Output = `public if it exists` | Framework=Other static default | Force Output Directory **empty** in dashboard; root `server.ts`; Path B redeploy |
851
892
  | Build runs `next build` / missing routes-manifest | Next auto-detected from root `next.config` / `app/` | Move Next to `preview/`; Framework null/Other; `build` = no-op |
852
893
  | Preview blank but logs show TomorrowOS listening | v0 Next intercepts public port | Add Next reverse proxy → internal TomorrowOS port |
853
894
  | Preview works, Publish broken / Next-only | Production still on Next | Switch Production entry to `tsx server.ts` / `export default server` |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tomorrowos/sdk",
3
- "version": "0.9.27",
3
+ "version": "0.9.28",
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.27",
3
+ "version": "0.9.28",
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.27",
16
+ "@tomorrowos/sdk": "^0.9.28",
17
17
  "dotenv": "^17.2.3",
18
18
  "tsx": "^4.19.0"
19
19
  },