@somewhere-cloud/cli 0.38.154 → 0.38.155

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 (142) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/docs/adopt.md +39 -0
  3. package/dist/docs/analytics.md +161 -0
  4. package/dist/docs/api-reference.md +339 -0
  5. package/dist/docs/api-surface.md +2067 -0
  6. package/dist/docs/app-mcp.md +162 -0
  7. package/dist/docs/architecture-patterns.md +334 -0
  8. package/dist/docs/auth-client.md +531 -0
  9. package/dist/docs/billing.md +76 -0
  10. package/dist/docs/browser.md +639 -0
  11. package/dist/docs/calendar.md +298 -0
  12. package/dist/docs/changes.md +323 -0
  13. package/dist/docs/cli.md +407 -0
  14. package/dist/docs/common-mistakes.md +199 -0
  15. package/dist/docs/connect-agent.md +72 -0
  16. package/dist/docs/cors.md +114 -0
  17. package/dist/docs/cron.md +167 -0
  18. package/dist/docs/database-engine.md +167 -0
  19. package/dist/docs/declared-data.md +1656 -0
  20. package/dist/docs/declared-files.md +475 -0
  21. package/dist/docs/deploy-intelligence.md +188 -0
  22. package/dist/docs/deploy.md +733 -0
  23. package/dist/docs/design-system.md +273 -0
  24. package/dist/docs/dev-environments.md +496 -0
  25. package/dist/docs/domain-ownership.md +31 -0
  26. package/dist/docs/domains.md +370 -0
  27. package/dist/docs/feedback.md +88 -0
  28. package/dist/docs/file-tools.md +116 -0
  29. package/dist/docs/functions.md +489 -0
  30. package/dist/docs/getting-started.md +238 -0
  31. package/dist/docs/github.md +95 -0
  32. package/dist/docs/google-calendar.md +212 -0
  33. package/dist/docs/groups.md +836 -0
  34. package/dist/docs/guarantees.md +58 -0
  35. package/dist/docs/handled-for-you.md +224 -0
  36. package/dist/docs/inspect.md +171 -0
  37. package/dist/docs/limits.md +68 -0
  38. package/dist/docs/live-data.md +197 -0
  39. package/dist/docs/live.md +92 -0
  40. package/dist/docs/local-dev.md +30 -0
  41. package/dist/docs/migration-supabase.md +58 -0
  42. package/dist/docs/payments.md +1102 -0
  43. package/dist/docs/portability.md +194 -0
  44. package/dist/docs/postgres.md +301 -0
  45. package/dist/docs/pricing-comparison.md +42 -0
  46. package/dist/docs/pricing.md +39 -0
  47. package/dist/docs/project-groups.md +107 -0
  48. package/dist/docs/projects.md +380 -0
  49. package/dist/docs/recipe-ai-agent.md +112 -0
  50. package/dist/docs/recipe-ai-features.md +227 -0
  51. package/dist/docs/recipe-ai-receipts.md +783 -0
  52. package/dist/docs/recipe-background-jobs.md +369 -0
  53. package/dist/docs/recipe-booking.md +348 -0
  54. package/dist/docs/recipe-csv-import.md +390 -0
  55. package/dist/docs/recipe-ecommerce.md +127 -0
  56. package/dist/docs/recipe-email.md +282 -0
  57. package/dist/docs/recipe-escalation.md +133 -0
  58. package/dist/docs/recipe-file-uploads.md +159 -0
  59. package/dist/docs/recipe-import-app.md +110 -0
  60. package/dist/docs/recipe-login.md +457 -0
  61. package/dist/docs/recipe-multi-chat.md +198 -0
  62. package/dist/docs/recipe-paid-api.md +161 -0
  63. package/dist/docs/recipe-pdfs.md +205 -0
  64. package/dist/docs/recipe-push-notifications.md +107 -0
  65. package/dist/docs/recipe-seo.md +200 -0
  66. package/dist/docs/recipe-signed-in-app.md +330 -0
  67. package/dist/docs/render.md +99 -0
  68. package/dist/docs/rooms.md +554 -0
  69. package/dist/docs/sdk.md +287 -0
  70. package/dist/docs/sdks.md +24 -0
  71. package/dist/docs/search.md +199 -0
  72. package/dist/docs/security-model.md +168 -0
  73. package/dist/docs/setup.md +212 -0
  74. package/dist/docs/smoke.md +102 -0
  75. package/dist/docs/speed.md +298 -0
  76. package/dist/docs/sql-compatibility.md +96 -0
  77. package/dist/docs/sw.agent.md +248 -0
  78. package/dist/docs/sw.ai.md +1291 -0
  79. package/dist/docs/sw.auth.md +1811 -0
  80. package/dist/docs/sw.billing.md +171 -0
  81. package/dist/docs/sw.db.md +2128 -0
  82. package/dist/docs/sw.email.md +661 -0
  83. package/dist/docs/sw.endpoint.md +187 -0
  84. package/dist/docs/sw.env.md +303 -0
  85. package/dist/docs/sw.fetch.md +115 -0
  86. package/dist/docs/sw.fs.md +424 -0
  87. package/dist/docs/sw.groups.md +836 -0
  88. package/dist/docs/sw.image.md +69 -0
  89. package/dist/docs/sw.jobs.md +520 -0
  90. package/dist/docs/sw.logs.md +61 -0
  91. package/dist/docs/sw.mail.md +106 -0
  92. package/dist/docs/sw.notifications.md +78 -0
  93. package/dist/docs/sw.push.md +161 -0
  94. package/dist/docs/sw.rateLimit.md +67 -0
  95. package/dist/docs/sw.web.md +128 -0
  96. package/dist/docs/tasks.md +269 -0
  97. package/dist/docs/test.md +220 -0
  98. package/dist/docs/tool-reference-account.md +7 -0
  99. package/dist/docs/tool-reference-ai.md +121 -0
  100. package/dist/docs/tool-reference-analytics.md +37 -0
  101. package/dist/docs/tool-reference-api.md +19 -0
  102. package/dist/docs/tool-reference-artifacts.md +35 -0
  103. package/dist/docs/tool-reference-auth.md +163 -0
  104. package/dist/docs/tool-reference-browser.md +114 -0
  105. package/dist/docs/tool-reference-code.md +26 -0
  106. package/dist/docs/tool-reference-connect.md +21 -0
  107. package/dist/docs/tool-reference-cron.md +48 -0
  108. package/dist/docs/tool-reference-db.md +282 -0
  109. package/dist/docs/tool-reference-domains.md +107 -0
  110. package/dist/docs/tool-reference-email.md +55 -0
  111. package/dist/docs/tool-reference-env.md +19 -0
  112. package/dist/docs/tool-reference-feedback.md +56 -0
  113. package/dist/docs/tool-reference-fs.md +265 -0
  114. package/dist/docs/tool-reference-github.md +57 -0
  115. package/dist/docs/tool-reference-groups.md +85 -0
  116. package/dist/docs/tool-reference-help.md +29 -0
  117. package/dist/docs/tool-reference-jobs.md +39 -0
  118. package/dist/docs/tool-reference-live.md +48 -0
  119. package/dist/docs/tool-reference-logs.md +16 -0
  120. package/dist/docs/tool-reference-payments.md +44 -0
  121. package/dist/docs/tool-reference-project.md +706 -0
  122. package/dist/docs/tool-reference-push.md +78 -0
  123. package/dist/docs/tool-reference-rate-limit.md +18 -0
  124. package/dist/docs/tool-reference-search.md +68 -0
  125. package/dist/docs/tool-reference-security.md +42 -0
  126. package/dist/docs/tool-reference-smoke.md +17 -0
  127. package/dist/docs/tool-reference-stock-photos.md +20 -0
  128. package/dist/docs/tool-reference-tasks.md +73 -0
  129. package/dist/docs/tool-reference-telegram.md +32 -0
  130. package/dist/docs/tool-reference-usage.md +9 -0
  131. package/dist/docs/tool-reference-web.md +71 -0
  132. package/dist/docs/tool-reference-webhooks.md +9 -0
  133. package/dist/docs/troubleshooting.md +411 -0
  134. package/dist/docs/typed-functions.md +94 -0
  135. package/dist/docs/verify-before-deploy.md +67 -0
  136. package/dist/docs/vs-supabase.md +75 -0
  137. package/dist/docs/vs-vercel.md +103 -0
  138. package/dist/lib/bundle.js +303 -221
  139. package/dist/lib/bundle.js.map +3 -3
  140. package/dist/types/lib/test-session.d.ts +8 -0
  141. package/npm-shrinkwrap.json +2 -2
  142. package/package.json +3 -2
@@ -0,0 +1,407 @@
1
+ # @somewhere-cloud/cli — full command reference
2
+
3
+ When a shell is available, the CLI is the primary platform surface. It has
4
+ first-class commands for routine operator work,
5
+ `somewhere call <tool> '<json>'` for every platform tool, and
6
+ `somewhere run <script>` to execute code against your live project without
7
+ deploying. Nothing else needs installing: no MCP setup is required to use the
8
+ CLI, and on a persistent machine you install and log in once. MCP is for
9
+ connected clients without a shell (Claude.ai, ChatGPT and other MCP hosts).
10
+ Start with the working loop below. The CLI and its local MCP bridge share
11
+ one login; a Claude.ai or ChatGPT connection uses its own OAuth session.
12
+
13
+ ## The working loop
14
+
15
+ For an existing Somewhere app, start with `somewhere pull <app>` in a fresh
16
+ folder. Then edit and run the working loop. `somewhere help <command>` prints
17
+ every flag.
18
+
19
+ | Step | Command | What it tells you |
20
+ |---|---|---|
21
+ | Deploy | `somewhere deploy` | Publishes raw source and prints the live URL. |
22
+ | Verify | `somewhere verify [--flow flow.json]` | Runs the live app at desktop and phone sizes: named steps, console/network health, both screenshots. |
23
+ | Inspect | `somewhere browser [target]` | One page: screenshot, snapshot, DOM, network, or an evaluated expression. |
24
+ | Diagnose | `somewhere logs --tail 10`, `somewhere errors` | Recent function output, then failures split into refused and exception. `errors` also works on a temporary project. |
25
+ | Email | `somewhere email test-inbox <address>` | Mail sent to `<name>@<subdomain>.test.somewhere.site` — sign-in email and your own sends — with the magic link. |
26
+
27
+ MCP clients use the same platform tools. Through the Claude directory
28
+ connector, `run_code` cannot generate AI media or move money. The Advisor is
29
+ optional on both surfaces.
30
+
31
+ Ask before destructive or paid actions unless the user already authorized them.
32
+
33
+ No account yet? Deploy the current directory immediately:
34
+
35
+ ```bash
36
+ npx -y @somewhere-cloud/cli@latest deploy
37
+ ```
38
+
39
+ The anonymous command returns a live URL and claim link; login is optional until
40
+ you decide to keep the project.
41
+
42
+ ```bash
43
+ npm i -g @somewhere-cloud/cli
44
+ somewhere signup # no account yet — opens the sign-up page (from 0.30.1)
45
+ somewhere login # opens a browser; session lands in ~/.somewhere/config.json
46
+ ```
47
+
48
+ `somewhere login` prints a short device code and opens a page where you
49
+ approve this machine by name. If you are not signed in yet, that page signs you
50
+ in first. It has no way to create an account, so `somewhere signup` is the
51
+ front door for a stranger: it prints the sign-up URL as plain text before it
52
+ opens anything, so a headless agent can relay a link it can read, then tells you
53
+ to run `somewhere login`.
54
+
55
+ The same session powers the CLI, the MCP bridge, and `somewhere deploy`.
56
+ The CLI signs in only two ways: a person approves it in the browser (the
57
+ device code `somewhere login` prints), or it uses a saved `smt_` key
58
+ (`somewhere auth set`). An agent without a person at hand needs that key.
59
+ Do not pass an API key for a human setup flow; the `smt_` key is for CI/CD.
60
+
61
+ `somewhere deploy` ships raw source (`src/`, `index.html`, `public/`,
62
+ `package.json`, `api/`) unless you explicitly opt into `--prebuilt`. The
63
+ normal path has no local build step. → docs({ topic: 'deploy' }).
64
+
65
+ ## Global commands and flags
66
+
67
+ | Command | Flags | What it does |
68
+ |---|---|---|
69
+ | `somewhere --version` | `-V`, `--version` | Print the CLI version. |
70
+ | `somewhere --help` | `-h`, `--help` | Print top-level help. |
71
+ | `somewhere help [command]` | none | Print help for one command. |
72
+
73
+ ## Auth
74
+
75
+ | Command | Flags | What it does |
76
+ |---|---|---|
77
+ | `somewhere signup` | none | Create an account — prints the sign-up URL and opens it. (from 0.30.1) |
78
+ | `somewhere login` | `--signup`, `--browser-callback` | Authenticate with the device-code browser flow. `--signup` opens account creation instead; `--browser-callback` signs in with Google in the browser and receives the key on a localhost port. (from 0.30.1) |
79
+ | `somewhere logout` | none | Revoke and remove stored credentials. |
80
+ | `somewhere whoami` | `--json` | Show current user info; `--json` prints the raw account response. |
81
+ | `somewhere auth` | none | Credential command group. |
82
+ | `somewhere auth login` | none | Authenticate with the browser flow. |
83
+ | `somewhere auth set` | none | Save an `smt_` token from standard input, `SOMEWHERE_TOKEN`, or the hidden prompt. Positional tokens are refused. |
84
+ | `somewhere auth status` | none | Show current login state, device ID, and key name. |
85
+ | `somewhere auth print-token` | none | Print the current `smt_` token to stdout for shell scripts. |
86
+ | `somewhere auth roles grant <user> <role>` | `--project <ref>`, `--json` | Give an app user an app role declared in `db/schema.ts` `appRoles`; `<user>` is the address they signed up with or their app user id. |
87
+ | `somewhere auth roles revoke <user> <role>` | `--project <ref>`, `--json` | Take an app role away, whoever granted it. |
88
+ | `somewhere auth roles list` | `--project <ref>`, `--user <user>`, `--role <role>`, `--json` | Who holds which app role, with the roles the live schema declares. |
89
+
90
+ ## Projects
91
+
92
+ | Command | Flags | What it does |
93
+ |---|---|---|
94
+ | `somewhere init` | `--name <name>`, `--link`, `--project <ref>`, `--bare`, `--template <name>`, `--features <ids>`, `--ui <mode>`, `--catalog`, `--dry-run`, `--json` | Initialize a project in the current directory. An empty directory gets the recommended React + TypeScript starter with sign-in (`--template minimal`: without; `--ui headless`: plain views, no CSS); `--bare` links without starter files. `--catalog --json` lists the modules `--features` accepts (no login, project or files); `--dry-run` prints the file plan. `--name` skips the prompt; `--link` links a folder that already contains source, or scaffolds an unpublished project in an empty folder. Init installs the pinned dependencies when it writes a starter. |
95
+ | `somewhere project` | none | Project command group. |
96
+ | `somewhere project create <name>` | `--subdomain <subdomain>`, `--json` | Create a new project. |
97
+ | `somewhere project list` | `--json` | List all projects. |
98
+ | `somewhere project view [name-or-id]` | `--json` | View project details. |
99
+ | `somewhere project delete <name-or-id>` | `--json` | Tombstone a project, take its hosts offline, and start the 30-day recovery period. |
100
+ | `somewhere project allowed-origins list` / `set` | `--project`, `--clear`, `--json` | Show or replace the project's exact cross-origin allowlist. |
101
+ | `somewhere call project_allowed_origins_set '<json>'` | `--json` | Replace the project's cross-origin allowlist, which is for THIRD-PARTY origins only (owner or platform admin only). Pass `"allowed_origins": []` to clear it. → docs({ topic: 'cors' }). |
102
+ | `somewhere status [project]` | `--json` | Show current project, active release, and hosted workspace status. For version history use `somewhere deploys`. `--json` prints `project`, `deployment`, `workspace` and, when the plan doesn't include previews, `deployment_entitlement` with its code. When previews are unavailable, status still reports production and exits successfully. |
103
+ | `somewhere open [project]` | `--dashboard` | Open the project URL in your browser; `--dashboard` opens the dashboard. |
104
+
105
+ ## Advisor
106
+
107
+ Ask how to build or diagnose a problem in plain language. The Advisor uses your question, the facts sent with it and public docs; it reads nothing itself. Signed in, in a folder linked to an app, the CLI reads that app's overview (pages, routes and their sign-in rule, tables, scheduled jobs) and last deploy with your sign-in and sends them with the question, and says so in one line. It keeps your last three questions and answers in that folder's `.somewhere/` for 30 minutes and sends them with a follow-up; `--new` starts over and `--no-context` sends only the question. It never sends file contents, rows, env values, users or your previous commands. Generic questions work without login.
108
+
109
+ | Command | Flags | What it does |
110
+ |---|---|---|
111
+ | `somewhere advisor "<question>"` | `--json`, `--no-context`, `--new` | Ask the platform advisor. `--json` wraps the question and answer; `--no-context` sends only the question (no app, earlier questions or file); `--new` forgets this folder's earlier questions. No previous-command context is attached. |
112
+ | `somewhere advisor --resume <request-id>` | `--json` | Continue waiting for the same saved durable request. |
113
+ | `somewhere advisor --status <request-id>` | `--json` | Inspect a saved durable request once. |
114
+ | `somewhere advisor --cancel <request-id>` | `--json` | Request cancellation of the same saved durable request. Cancellation can race completion. |
115
+
116
+ ### Saved requests
117
+
118
+ The saved-request commands require CLI 0.37.3 or later and a request ID
119
+ returned by the platform. If the answer has no saved request ID, use the
120
+ ordinary question command.
121
+
122
+ For a durable request, the CLI saves its handle and prints the reconnect command before waiting. Closing the terminal or pressing Ctrl-C stops waiting; it does not cancel the request. Reconnect using the same CLI configuration and owning account. Anonymous receipts are private capabilities; do not share them. After a disconnect, resume the saved request to avoid starting a second answer.
123
+
124
+ Durable requests have no fixed answer deadline, but provider failures, unavailable response records and bounded documentation rounds can leave an answer incomplete. Read its stated limits and verify the proposed behavior in your app. A connection timeout does not by itself mean the model stopped. Explicit `--async` requests do not retain file excerpts.
125
+
126
+ ## Platform tools and operator workflows
127
+
128
+ | Command | Flags | What it does |
129
+ |---|---|---|
130
+ | `somewhere catalog` | `--json` | Browse the live platform tool catalog. |
131
+ | `somewhere call <tool> '<json>'` | `--all-projects`, `--json` | Invoke any platform tool by name (the MCP implementation). Run `somewhere call --list --json` to enumerate names and input schemas. In a linked directory, a tool that takes `project_id` runs against the linked project unless the JSON names one, and says so on stderr; `--all-projects` omits this project default; the tool's own scope still applies. |
132
+ | `somewhere tasks list` | filters, `--json` | List tasks. Use `somewhere tasks get/create/update` to read and maintain the task system without an editor. |
133
+ | `somewhere feedback list` | `--project <ref>`, `--json` | Read feedback from the app’s users in the project owner inbox; `somewhere feedback submit <message>` adds to it. For a platform bug, use `somewhere call support_ticket` (see `feedback`). |
134
+ | `somewhere grep <pattern>` | `--project <ref>`, `--glob <glob>`, `--json` | Regex-search deployed source and print stable `file:line` matches. |
135
+ | `somewhere usage [project]` | `--period <period>`, `--json` | Show account or project usage through `usage_summary`. |
136
+
137
+ ## Deploy and pull
138
+
139
+ | Command | Flags | What it does |
140
+ |---|---|---|
141
+ | `somewhere deploy [dir]` | `-m, --message <text>`, `--project <ref>`, `--scope <scope>`, `--dry-run`, `--include <paths>`, `--replace-functions`, `--prebuilt`, `--temporary`, `--new`, `--force`, `--yes`, `--json` | Deploy a directory to the linked or specified project. `-m` supplies an optional version note (at most 200 characters). `--include` publishes a root file the deploy would otherwise hold back. `--scope functions` deploys backend only; `--scope static` deploys site files only. `--dry-run` prints the diff without deploying. `--replace-functions` removes deployed functions missing locally. `--prebuilt` opts into bundled output. `--temporary` creates a temporary workspace without an account. `--new` publishes to a new project and updates the folder’s link. `--force --yes` overwrites remote changes without prompting. |
142
+ | `somewhere pull [project]` | `--out <dir>`, `--force`, `--json` | Download the live deployed source files and scaffold local typecheck files when absent. `--out` defaults to the current directory. In a linked folder it is the safe update when live is newer: unedited files move to live, local edits and local-only files stay, and it stops if a file changed both here and live. `--force` replaces local edits with live; it never deletes files a deploy would not upload. |
143
+ | `somewhere typecheck [dir]` | `--json`, `--deploy`, `--watch`, `--hook <host>` | Run `tsc --noEmit` over the project. `--deploy`: the deploy's narrower reference check, no `tsconfig.json` needed. `--watch` re-checks on save; never deploys. `--hook` is what `somewhere hooks install` runs. It regenerates `__somewhere_data.d.ts` and `__somewhere_files.d.ts` from `db/schema.ts`; CLI 0.37.47+ starters `.gitignore` them. |
144
+ | `somewhere lint [dir]` | `--json`, `--generic` | Check source offline (no login, network or file changes) for secrets, `db/schema.ts` declarations, directory index routes, request input choosing a server write's owner, and `sw.email.send` awaited in a loop. Warnings only; authorization and type correctness are not assessed. `--generic` adds the project's installed Oxlint. Exit 0 with warnings; 2 if source was skipped or `--generic` failed or found no Oxlint. |
145
+ | `somewhere hooks install [dir]` | `--host <host>`, `--json` | Add an after-edit `typecheck --deploy` check to this project's own agent settings (`.claude/settings.json`, `.codex/hooks.json` or `.cursor/hooks.json`; never user-wide), merged with existing hooks. Hosts: `claude-code` (default), `codex`, `cursor`. Edits made through shell commands are not checked; run `somewhere typecheck --deploy --watch` for those. |
146
+ | `somewhere rollback [project]` | `-y, --yes`, `--json` | Select the previous retained production release. By default this changes code without restoring data. |
147
+ | `somewhere restore <version>` | `--project <ref>`, `-y, --yes`, `--json` | Make an earlier version live again by number (MCP `project_restore_version`). Free can restore retained deploys from the last 24 hours. Paid plans can restore any retained version. Restoring by number leaves the database schema and data unchanged. Nothing is re-uploaded; `somewhere pull` then brings the folder to it. |
148
+ | `somewhere deploys` | `--project <ref>`, `--json` | List versions, times, notes and available restore commands. |
149
+ | `somewhere deploys note <version> <message>` | `--project <ref>`, `--json` | Set or correct the note on an existing version. |
150
+ | `somewhere file <path> --version <number>` | `--project <ref>` | Print one source file from a retained production version. Redirect stdout to save it. |
151
+ | `somewhere deploy-check [dir]` | `--project <ref>`, `--run <path>`, `-X, --method <method>`, `-d, --body <json>`, `-q, --query <querystring>`, `--json` | Upload source for a server-side dry compile without deploying. `--run` instead runs one handler with development bindings, on every plan. |
152
+
153
+ ## Project file storage
154
+
155
+ For the full file-tool surface, use `somewhere call fs_<verb> '<json>'`.
156
+ `somewhere call --list --json` lists each tool's required arguments.
157
+
158
+ | Command | Flags | What it does |
159
+ |---|---|---|
160
+ | `somewhere fs put <local> <remote>` | `--project <slug>`, `--content-type <type>`, `--json` | Stream a local file into project storage. |
161
+ | `somewhere fs get <remote> <local>` | `--project <slug>`, `--json` | Stream a stored file to disk. |
162
+ | `somewhere fs ls <remote>` | `--project <slug>`, `--json` | List a directory in project storage. |
163
+ | `somewhere fs rm <remote>` | `--project <slug>`, `--json` | Remove a file or directory from project storage. |
164
+
165
+ ## Database
166
+
167
+ | Command | Flags | What it does |
168
+ |---|---|---|
169
+ | `somewhere db` | none | Database command group. |
170
+ | `somewhere db query <sql>` | `--project <id>`, `--json` | Run SQL against the project database. |
171
+ | `somewhere db dump` | `--project <id>`, `-o, --output <file>`, `--json` | Export the full database as SQL. |
172
+ | `somewhere db tables` | `--project <id>`, `--json` | List tables in the project database. |
173
+
174
+ ## Environment, logs, and errors
175
+
176
+ | Command | Flags | What it does |
177
+ |---|---|---|
178
+ | `somewhere env` | none | Environment variable command group. |
179
+ | `somewhere env list` | `--project <id>`, `--json` | List names, scope, visibility, labels and references. Values are not returned. |
180
+ | `somewhere env pull` | `--project <id>`, `--out <file>`, `--force`, `--json` | Write a local env template for the local-dev loop. Values are not included. |
181
+ | `somewhere env set <key> [value]` | `--project <id>`, `--stdin`, `--public` / `--private`, `--scope all|dev|prod`, `--provider <label>`, `--purpose <description>`, `--json` | Save or rotate a value. Use `--stdin` to keep a secret out of process arguments. New values are server-only. |
182
+ | `somewhere env delete <key>` | `--project <id>`, `--json` | Delete an environment variable. |
183
+ | `somewhere logs [project]` | `--level <level>`, `--source <source>`, `--function <route>`, `--endpoint <path>`, `--since <duration>`, `--tail <n>`, `--follow`, `--trace <id>`, `--json` | Show recent logs. `--tail` defaults to 20; `--follow` keeps polling; `--trace` shows one failed request's lines and stack. |
184
+ | `somewhere errors [project]` | `--limit <n>`, `--exceptions`, `--json` | Show recent failures with a `kind` column: **refused** for a 4xx your own handler returned on purpose, **exception** for an uncaught throw or a 5xx. The summary counts exceptions, deliberate refusals and platform diagnostics separately. `--exceptions` hides deliberate refusals; platform diagnostic failures stay visible. `--limit` defaults to 20 and caps at 100. |
185
+
186
+ ## Local execution and inspection
187
+
188
+ | Command | Flags | What it does |
189
+ |---|---|---|
190
+ | `somewhere dev` | `--project <id>`, `--port <port>`, `--open` | Frontend hot reload on localhost with the project's own Vite (installed in the project); API requests are proxied to your deployed project, so backend code runs only after deploy or preview. `--port` defaults to 8787. Install the frontend's Vite dependencies first (`npm install`). |
191
+ | `somewhere preview` | `--project <id>`, `--once` | `--once` syncs, prints the preview link and the promote command, and exits instead of watching. Each preview link works once; `somewhere preview link` mints another for the open preview. Every save goes to a private hosted URL; production keeps serving what was last promoted. Every plan for signed-in accounts; Free allows three open previews. The session starts with an isolated copy of managed data. Projects with a separate raw SQL database rehearse raw SQL migrations on a test project. |
192
+ | `somewhere run <script>` | `--project <id>`, `--timeout <ms>`, `--include-env`, `--arg <name=value>`, `--json` | Run a one-off ES module script once against the live project bindings. `--timeout` defaults to 10000 and caps at 30000. Output limits: the result is capped at 256 KB (cut to a preview with a notice); logs keep at most 100 entries; each log message is cut at 64 KB with a `[truncated: …]` marker at its end; all logs together stop at 4 MB, followed by one final `[logs truncated: …]` entry; `logs_truncated: true` is set when entries were dropped by either limit; the error message and stack are each cut at 64 KB; a returned `session` over 64 KB is not stored and the call answers `SESSION_TOO_LARGE`. |
193
+ | `somewhere browser [target]` | `--project <ref>`, `--url <url>`, `--path <path>`, `--wait <selector>`, `--eval <js>`, `--screenshot`, `--snapshot`, `--viewport <size>`, `--store`, `--include <sections>`, `--extract`, `--session <id>`, `--close <session>`, `--auth-user <email|user_id>`, `--json` | Inspect and drive a web page. Without `--project`, works against any public URL; with `--project`, verifies a deployed app. `--viewport` accepts `desktop` or `mobile`; `--include` accepts `network`, `dom`, and/or `markdown`; `--session` keeps one live page, with its sign-in, across calls until closed, idle 5 minutes or 10 minutes old (an ended one restarts signed out). `--close <session>` closes it in the selected or linked project (or `--project <ref>`). `--auth-user <email|user_id>` starts signed in as a managed test user (`somewhere docs browser`). `--path`, `--wait` and `--eval` combine with action flags: the path first, then the actions, then the wait and eval. |
194
+ | `somewhere verify [target]` | `--project <ref>`, `--url <url>`, `--path <path>`, `--flow <file.json>`, `--json`, `--out <file>`, `--schema`, `--keep-test-users`, `--keep-actors`, `--close-actors`, `--resume-page` | Run one action flow across desktop and phone viewports and return named steps, page/console/network health, and both screenshots. Omit the flow for a default page-health check. `--path /settings` opens that path on the linked or selected app; use it without `--url`. A flow with `actors` and `journey` runs several users, each in their own browser (`docs({ topic: 'browser' })`); `--keep-test-users` keeps the test users made for `test_user` actors; `--keep-actors` keeps signed-in actors between runs, `--close-actors` closes them, `--resume-page` continues kept pages (warm, not fresh-release evidence). `--schema` prints both flow forms. `--out` writes the full report to a new private file and prints a bounded summary (JSON with `--json`). |
195
+ | `somewhere api <method> <path>` | `-d, --data <json>`, `--raw` | Make a raw API call with auth attached. `--raw` prints non-JSON responses as-is. |
196
+
197
+ If `somewhere run` or the `run_code` tool returns `CODE_RUN_NOT_STARTED`
198
+ (HTTP 502 from the runner), credential preparation failed before the script
199
+ started. Nothing ran; a later identical request can succeed.
200
+
201
+ A script that reaches its own time limit can return HTTP 200 with a `TIMEOUT`
202
+ error and its logs. If the platform has not received the complete result within
203
+ that limit plus 500 ms from invocation, it returns HTTP 408 `CODE_TIMEOUT`
204
+ without the script's logs. This does not confirm execution stopped or undo
205
+ completed effects. Retrying runs the script again and can repeat those effects.
206
+ Setup before invocation and saving returned session data can add time to the
207
+ whole request.
208
+
209
+ One-off runs allow 30 starts per minute per project and 60 per minute across
210
+ an owning account's projects. A refusal returns HTTP 429 `RATE_LIMITED` with
211
+ `Retry-After` and `retry_after_ms`; no run credential is created. If the limit
212
+ cannot be checked within two seconds, the response is HTTP 503
213
+ `RATE_LIMIT_UNAVAILABLE` and nothing runs.
214
+
215
+ Pass per-run values with `somewhere run script.mjs --arg label=trial --arg limit=10`.
216
+ The script receives them as `export default async (sw, args) => { ... }`:
217
+ `args.limit` is the string `"10"`. The object is read-only and defaults to
218
+ `{}`. These inputs stay separate from project env and saved sessions.
219
+ Use project secrets with `--include-env` for credentials; command-line arguments
220
+ can appear in shell history and process listings.
221
+
222
+ ## Docs and MCP
223
+
224
+ | Command | Flags | What it does |
225
+ |---|---|---|
226
+ | `somewhere docs [topic]` | `--list`, `--full`, `--section <id>`, `--json` | With no topic, prints the topic index; `somewhere docs search <term>` lists matching sections with the command that opens each, and `somewhere docs --full` prints the whole manual. When the installed CLI is a minor release or more behind the one the docs describe, `somewhere docs` says so. The bundle topics are `start`, `docs`, `guides`, `security`, `migration` and `llms`; any single capability topic from the index — `somewhere docs cli`, `somewhere docs sw.db` — prints that page. |
227
+ | `somewhere mcp` | none | Run the Somewhere MCP server over stdio. |
228
+ | `somewhere mcp install <host>` | none | Configure an MCP host to use Somewhere. Supported hosts are `codex`, `claude-code`, and `cursor`. |
229
+ | `somewhere mcp doctor` | none | Check MCP setup: login, token validity, server reachability, and host configs. |
230
+
231
+ ## Keeping the CLI current
232
+
233
+ A project records the CLI version it was built with: `somewhere init` writes it as the `@somewhere-cloud/cli` devDependency in `package.json`, and a linked folder without one gets `cli_version` in `.somewhere.json` at its first deploy. A different CLI run in that project prints one line naming both versions and hands the command to the pinned version when it is installed in `node_modules`; `somewhere upgrade` moves the project to the CLI you are running and prints the changelog entries in between.
234
+
235
+ | Command | Flags | What it does |
236
+ |---|---|---|
237
+ | `somewhere upgrade` | `--json` | Move this project's recorded CLI version to the running CLI and print the CHANGELOG.md entries between the two. Run `npx -y @somewhere-cloud/cli@latest upgrade` for the newest release, then `npm install` when the pin is in `package.json`. Agent skills are not changed; `somewhere skills update` refreshes them. |
238
+ | `somewhere update` | `--check` | Update the CLI to the latest published version through npm. `--check` only reports whether an update is available. A refused update exits non-zero and prints `npm i -g @somewhere-cloud/cli@latest`. CLI 0.37.0 and older cannot update themselves (they refuse every current release as having no signed provenance); install the latest with that npm command. |
239
+
240
+ ## deploy — what gets published, and what is held back
241
+
242
+ A project root usually holds more than the app. Coding agents keep notes,
243
+ TODOs, transcripts and scratch logs next to the code, and publishing one of
244
+ those to a live URL is a privacy incident, not a cosmetic mistake.
245
+
246
+ So the root is filtered by publish surface, not by "everything that is not a
247
+ dotfile" (from 0.30.1). A root file is published when it is a known app-surface
248
+ name or extension, when something in the published source references it by
249
+ name, or when you opted it in. Everything else is held back — and named, never
250
+ dropped silently:
251
+
252
+ ```
253
+ Not published: 3 local files (notes, tests, tooling) stay on your machine. See them: somewhere deploy --list-unpublished
254
+ ```
255
+
256
+ Run `somewhere deploy --list-unpublished` to see the specific files and
257
+ why each stays local.
258
+
259
+ Unreferenced operational files also stay local: root folders `scripts`, `fixtures`,
260
+ `e2e`, `tooling`, `tools`, `design-v2`, `build`, `out`,
261
+ `storybook-static`, `artifacts` and `reports`; `__fixtures__`,
262
+ `test-fixtures`, `test-results`, `playwright-report` and `coverage` at any
263
+ depth; and `.log`/`.jsonl` files. Files named by app imports, HTML/CSS references
264
+ or URL paths are retained, including their transitive imports and assets under
265
+ `public`. Dynamic paths that cannot be discovered need an explicit include.
266
+ Other app folders, including `src`, `public`, `api`, assets and invented
267
+ folder names, keep their normal behavior. Existing test-file, dotfile and
268
+ sensitive-file rules still apply; an include cannot publish a secret.
269
+
270
+ To publish one on purpose:
271
+
272
+ ```bash
273
+ somewhere deploy --include NOTES.md # once; comma-separate or repeat for several
274
+ ```
275
+
276
+ or make it permanent with a `!` line in `.somewhereignore`:
277
+
278
+ ```
279
+ !NOTES.md
280
+ ```
281
+
282
+ `.somewhereignore` is read alongside `.gitignore`: plain patterns exclude
283
+ files from the deploy, and a leading `!` publishes one the filter would
284
+ otherwise hold back.
285
+
286
+ ## deploy-check — the server-side compile oracle
287
+
288
+ `deploy-check` uploads source to the exact compiler used by deploy, but writes
289
+ nothing and makes nothing live. It catches server-only bundling and import
290
+ resolution failures that a local typecheck cannot see. For the full local
291
+ compiler diagnostic when a summary only shows the first line, run
292
+ `npx tsc --noEmit --pretty false` from the app root. For a reusable column
293
+ projection, define the array with `as const` so its elements keep their
294
+ literal column-name types.
295
+
296
+ ```bash
297
+ somewhere deploy-check
298
+ somewhere deploy-check --run /api/hello -X POST -d '{"name":"Ada"}'
299
+ somewhere deploy-check --json
300
+ ```
301
+
302
+ Use `--run` to invoke one handler from your function source with the
303
+ method, body and query string you supply, without deploying. Static and client
304
+ files are skipped. It works on every plan, requires editor access and never
305
+ uses your live database.
306
+
307
+ | Project | Handler access |
308
+ | --- | --- |
309
+ | Has a live release, or the plan does not include `somewhere preview` | No database or network. A `sw.db` call returns `409 DRAFT_DB_NOT_ISOLATED`; rate limits are not evaluated. |
310
+ | No live release and the plan includes preview | Uses the development database when available; writes persist, network calls are allowed and rate limits are evaluated. If only a live database exists, the check is refused with `409 DRAFT_DB_NOT_ISOLATED`. |
311
+
312
+ For the no-database case, a schema containing visitor tables stops the check before execution with `503 DRAFT_DB_NOT_ISOLATED`. Use a preview or the live route for those handlers.
313
+
314
+ Both cases use the values saved for development in project settings. Run database-dependent
315
+ checks on a preview or the live route when `--run` has no database.
316
+
317
+ On plans
318
+ without `somewhere preview`, each project gets 60 handler checks per hour
319
+ (`429 RATE_LIMITED` after that).
320
+
321
+ ## browser — verify the live app, not just the deploy response
322
+
323
+ ```bash
324
+ somewhere browser https://my-app.somewhere.site
325
+ somewhere browser --project my-app --path /login --wait '#email' --snapshot
326
+ somewhere browser https://example.com --include network,dom --json
327
+ ```
328
+
329
+ It exits non-zero when a step fails, a request fails, or page JavaScript throws.
330
+ Use EYES mode (a public URL, no project) for any page; use `--project` for an
331
+ owned app and optional stored screenshots.
332
+
333
+ **Local and hosted are two halves of one command.** A `localhost` or
334
+ `127.0.0.1` target — the app `somewhere dev` is serving — is driven by the
335
+ browser already installed on your machine, because a browser running on the
336
+ platform can never reach an address only your machine serves (from 0.30.0). Each
337
+ local run gets an empty throwaway profile, so it never reads or writes your real
338
+ one, and if there is no browser at all the command says so and names the
339
+ environment variable that points at one. The flags only the hosted half can
340
+ honour — `--store`, `--session`, `--extract`, and any `--include`
341
+ section other than `dom` — are refused by name rather than silently dropped
342
+ from a report that would still look complete. Everything else, including
343
+ `--screenshot`, `--wait`, `--eval`, `--snapshot` and
344
+ `--viewport`, behaves the same on both halves; `--snapshot` requests the
345
+ interactive-element outline it prints. So the same command checks the app before
346
+ it is deployed and after.
347
+
348
+ ## api — authenticated REST escape hatch
349
+
350
+ ```bash
351
+ somewhere api GET /v1/projects
352
+ somewhere api POST /v1/db/query -d '{"project_id":"my-app","sql":"SELECT 1"}'
353
+ somewhere api POST /v1/db/dump -d '{"project_id":"my-app"}' --raw
354
+ ```
355
+
356
+ The CLI attaches auth automatically. `-d` sends a JSON body. JSON parsing is
357
+ the default; use `--raw` only for a successful non-JSON response, such as the
358
+ SQL text `/v1/db/dump` returns. `/v1/db/dump` takes `POST` with the
359
+ project in the body; without `project_id` it answers 400 `VALIDATION_ERROR`.
360
+
361
+ ## update
362
+
363
+ ```bash
364
+ somewhere update --check
365
+ somewhere update
366
+ ```
367
+
368
+ The first command only compares the installed version with npm; the second
369
+ installs the current `@somewhere-cloud/cli` globally.
370
+
371
+ ## Anonymous `deploy --json` contract
372
+
373
+ A temporary (signed-out) deploy keeps the server deploy result, the same
374
+ fields an authenticated deploy prints (for example `version`, `release_id`,
375
+ `warnings` and `stage_timing_ms`). It sets `url` to the live URL the CLI
376
+ displays and adds three claim fields: `claim_url`, `expires_at` and
377
+ `claim_connects_agent`. `next_step` appears only in human-readable output.
378
+
379
+ <!-- CLI_DEPLOY_JSON_SCHEMA_BEGIN -->
380
+ ```json
381
+ {
382
+ "url": "https://<subdomain>.somewhere.site",
383
+ "version": 1,
384
+ "release_id": "rel_…",
385
+ "warnings": [],
386
+ "stage_timing_ms": { "deploy_total": 4200 },
387
+ "claim_url": "https://somewhere.cloud/claim/swtc_…",
388
+ "expires_at": "<ISO-8601 timestamp>",
389
+ "claim_connects_agent": true
390
+ }
391
+ ```
392
+ <!-- CLI_DEPLOY_JSON_SCHEMA_END -->
393
+
394
+ The sample shows a few of the server's fields; every other field the deploy
395
+ API returns is kept as it is. `expires_at` is `null` when the session has no expiry
396
+ on record. `claim_connects_agent` is `true` only when the claim page can
397
+ connect this CLI without another sign-in.
398
+
399
+ For an authenticated deploy, `--json` prints the server deploy result without
400
+ adding the temporary-session claim metadata. Both modes include the `--verify`
401
+ outcome fields when verification runs: `deployment_outcome: "live"` and
402
+ `verification` (or `verification_error`), plus `next_steps` when verification
403
+ fails.
404
+
405
+ To talk to the platform from app code (browser / Node), use the client SDK
406
+ instead → docs({ topic: 'sdk' }). To serve the app on localhost while you build
407
+ it, and to typecheck before you ship — see docs({ topic: 'local-dev' }).
@@ -0,0 +1,199 @@
1
+ # Common Mistakes — Things real users have hit
2
+
3
+ **STOP.** Before writing any code, check if the platform already
4
+ handles it. Eight rules cover most of the wasted-time tickets:
5
+
6
+ - ❌ Don't build a `messages` or `conversations` table for chat
7
+ history → use `conversation_id` on `sw.ai.chat()`. The platform
8
+ loads, persists, and truncates history for you.
9
+ - ❌ Don't write `getCookie()` / token-parsing helpers →
10
+ `sw.auth.fromRequest(req)` reads cookie + Bearer header and returns
11
+ the validated user (or null) in one call.
12
+ - ❌ Don't write visitor-session management → declare `owner({ visitors: true })`
13
+ on the table; the platform issues the visitor session and moves its rows to
14
+ the account on sign-in. If the move would conflict with the account's rows or
15
+ cannot be confirmed, the rows stay with the visitor session the sign-in replaced
16
+ (`declared-data` → `visitors`).
17
+ - ❌ Don't hand-roll Stripe webhook handling — see the `payments` topic
18
+ for the supported flow.
19
+ - ❌ Don't deploy a single-file change via MCP `project_deploy` — a full
20
+ deploy replaces the project's static files with the ones you send (functions
21
+ you omit stay live unless you pass `replace_functions: true`). Use
22
+ `project_patch` for a single file or the `somewhere deploy` CLI for a
23
+ full deploy.
24
+ - ❌ Don't wrap `sw.*` in blind retry loops → a thrown `sw.*` error
25
+ carries its `code` and `status`; when present, `retry` says whether
26
+ trying again can help and `retry_after_ms` says when. Follow them. Never
27
+ repeat a write whose outcome is unknown until you have checked whether it
28
+ happened.
29
+ - ❌ Don't call `https://api.somewhere.cloud/v1/...` from inside a
30
+ deployed function → use `sw.*` (same authenticated runtime surface,
31
+ no developer-key or hand-built platform request).
32
+ - ❌ Don't set env vars for platform services (`SOMEWHERE_API_KEY`,
33
+ database URLs, etc.) → `sw.*` is already authenticated. Env vars
34
+ are for YOUR external services (e.g. a payment provider, an SMS API,
35
+ your own AI key, etc).
36
+
37
+ The rest of this topic is the *long* list of failure modes from real
38
+ support tickets. Skim once.
39
+
40
+ ## 1. Calling api.somewhere.cloud from inside a deployed function
41
+
42
+ **Wrong:**
43
+ ```typescript
44
+ // inside a deployed function
45
+ const res = await fetch('https://api.somewhere.cloud/v1/db/query', {
46
+ headers: { Authorization: 'Bearer smt_...' },
47
+ ...
48
+ })
49
+ ```
50
+
51
+ **Right:**
52
+ ```typescript
53
+ const res = await sw.db.from('contacts', { limit: 50 }) // res.data is the rows
54
+ ```
55
+
56
+ Inside a deployed function, `sw.*` reaches the platform with the
57
+ function’s own credentials — no API key to manage. Use the REST surface
58
+ (`api.somewhere.cloud`) from trusted developer tools, CI and external
59
+ servers. Browser app features use the starter’s cookie session and the
60
+ generated data and file clients.
61
+
62
+ ## 2. Using project_deploy when you meant project_patch
63
+
64
+ `project_deploy` **replaces** the project's static files. If you pass
65
+ `{ files: { "index.html": "..." } }`, every other static file is deleted.
66
+ Functions you omit stay live; `replace_functions: true` removes them.
67
+ `scope: 'functions'` leaves static files untouched, and `scope: 'static'`
68
+ leaves functions untouched (`deploy` →
69
+ `projectdeploy-replaces-files-preserves-omitted-functions-by-default`).
70
+
71
+ For a single-file edit, use `project_patch`.
72
+ `{ path, content }` rewrites the file, and
73
+ `{ path, find, replace }` does a server-side substring swap (~200
74
+ bytes on the wire). The platform auto-routes the path to static or
75
+ function. Use a `files` map to write several whole files in one patch,
76
+ or `edits` for ordered substring replacements across files. Each patch names
77
+ the release it edits as `base_release_id`: the `active_release_id` from
78
+ `project_export` (`deploy` → `projectpatch-incremental`).
79
+
80
+ ## 3. Putting tokens or JWTs in URLs
81
+
82
+ Don't do this:
83
+ ```text
84
+ https://my-app.somewhere.site/dashboard?token=eyJhbGc...
85
+ ```
86
+
87
+ Tokens in query strings end up in:
88
+ - Browser history
89
+ - Server access logs
90
+ - HTTP referrer headers when the page links out
91
+ - Anyone watching over your shoulder
92
+
93
+ Use cookies (httpOnly, secure, sameSite) or the `Authorization: Bearer`
94
+ header. The auth flows the platform ships with already do this — only
95
+ break the pattern if you have a very specific reason.
96
+
97
+ ## 4. Putting smt_ keys in browser-accessible code
98
+
99
+ The `smt_` developer key is admin. It can read every project, deploy
100
+ code, change env vars. If it leaks (committed to GitHub, embedded in
101
+ JavaScript bundle, dropped in browser localStorage) someone can take
102
+ over the account.
103
+
104
+ Use the smt_ key only in trusted developer tools:
105
+ - Your local terminal and the CLI
106
+ - CI/CD secrets
107
+ - Administrative server code you run for developer operations
108
+
109
+ App features inside a deployed function use `sw.*`, which is already
110
+ authenticated.
111
+
112
+ For browser sign-in, keep the starter’s auth route and cookie session
113
+ (docs({ topic: 'auth-client' })). The platform stores the session in an
114
+ HttpOnly cookie; your UI does not need to parse or store a token.
115
+
116
+ ## 5. Reasoning models with too-low max_tokens
117
+
118
+ Reasoning models (models that enable reasoning) think first, then answer. The `<thinking>`
119
+ block consumes tokens. If `max_tokens` is too small, the model burns
120
+ its budget on reasoning and returns no answer at all —
121
+ `MODEL_EMPTY_RESPONSE` at HTTP 422, `retry: false`, with the stop
122
+ reason and token counts in `data`. Raise the budget; do not retry and
123
+ do not switch model.
124
+
125
+ **Wrong:** `max_tokens: 500` for a reasoning model.
126
+ **Right:** `max_tokens: 4000` minimum, `8000+` is safer.
127
+
128
+ For non-reasoning models (Claude and Luna) 500 is fine.
129
+
130
+ ## 6. sw.fs.write camelCase vs snake_case
131
+
132
+ The `sw.fs.write` binding accepts both `contentType` (camelCase) and
133
+ `content_type` (snake_case) for the MIME type. Other fields are
134
+ camelCase only. Pick one style per project for consistency, but the
135
+ platform tolerates either on this option.
136
+
137
+ ```typescript
138
+ // api/weekly-report.ts — POST generates a report on the server
139
+ export default async (req: Request, sw: SomewhereRuntimeContext): Promise<Response> => {
140
+ if (req.method !== 'POST') return new Response('Method not allowed', { status: 405, headers: { Allow: 'POST' } })
141
+ const user = await sw.auth.requireUser(req)
142
+ const csv = 'period,total\nweekly,42\n'
143
+ const path = '/reports/' + user.id + '/weekly.csv'
144
+ await sw.fs.server.write(path, csv, {
145
+ contentType: 'text/csv' // or content_type — both work
146
+ })
147
+ return Response.json({ path })
148
+ }
149
+ ```
150
+
151
+ ## 7. "My deploy didn't update the live site"
152
+
153
+ A successful production deploy or patch publishes an immutable release
154
+ and makes it active; a dry run only checks the proposed change. If the live site
155
+ looks stale, it's almost always one of:
156
+
157
+ - Browser or CDN cache. Hard-reload (Cmd-Shift-R), or check with
158
+ `curl -sI https://{subdomain}.somewhere.site`.
159
+ - The deploy hit a different project than you think (wrong
160
+ `project_id`).
161
+ - A location that has not picked up the new release yet; how long it can
162
+ serve the previous one is in `speed` → `pages-and-assets`.
163
+
164
+ ## 8. Auth emails not arriving
165
+
166
+ The platform sends auth emails (signup confirmation, password reset)
167
+ from `noreply@somewhere.cloud` by default. That domain is not on your
168
+ project — it's the platform's. Some email providers flag it as
169
+ suspicious because the sending domain doesn't match your app's domain.
170
+
171
+ Fix: [verify a sender domain](https://somewhere.cloud/docs/sw.email.txt#your-own-sender-domain). Once verified, auth emails go out from `noreply@yourdomain.com`.
172
+
173
+ ## 9. A changed env var is not visible yet
174
+
175
+ Check the save response's `requires_deploy` field. An existing project
176
+ needs one ordinary raw-source production deploy before live env updates
177
+ work. New projects are ready after their first deploy. Once the save response
178
+ says `requires_deploy: false`, production `sw.env.MY_KEY` reads inside
179
+ the handler use the current value on new requests within 60
180
+ seconds, without another deploy. Public browser values, including one made private or
181
+ deleted, reach new page loads in the same window; reload an already open page. A preview keeps its captured values until you
182
+ create a new preview snapshot.
183
+
184
+ ## 10. Libraries that need a different import or setup
185
+
186
+ Most npm packages work as they are: declare them in `package.json` and the
187
+ platform bundles them on deploy. Your pages carry no Content-Security-Policy
188
+ unless your app adds one, so browser libraries that use `eval` or blob workers
189
+ load normally. These are the cases that need a change:
190
+
191
+ | Library or need | Where | Use this |
192
+ |---|---|---|
193
+ | Node built-ins | Function | Import every built-in with the `node:` prefix: `import { createHash } from 'node:crypto'`. A bare `'crypto'`, `'fs'` or `'path'` fails to build. |
194
+ | A package with no `exports` field and no root `index.js` (pdf-lib) | Function | Import its ESM file directly: `import { PDFDocument } from 'pdf-lib/dist/pdf-lib.esm.js'`. A plain `'pdf-lib'` import fails to build. |
195
+ | Native modules: sharp, canvas, native bcrypt | Function | They cannot load. Serve resized images through `sw.image.resize` URLs; verify bcrypt hashes with `sw.crypto.bcrypt.verify`; draw in the browser, or print HTML with `sw.render.pdf`. |
196
+ | WebAssembly | Function | A `.wasm` import does not build in a function. Run WebAssembly in the browser. |
197
+ | ffmpeg | Both | A function bundles JavaScript only, so the ffmpeg binary is not available. Use ffmpeg.wasm in the browser with its single-thread core (`@ffmpeg/core`); pages are not cross-origin isolated, so the multi-thread core has no `SharedArrayBuffer`. |
198
+ | PDF.js, react-pdf | Browser | Set `pdfjs.GlobalWorkerOptions.workerSrc` to a CDN URL at `pdfjs.version`, or copy `pdf.worker.min.mjs` into `public/`. The compiler does not rewrite `new URL('…', import.meta.url)` or `?url` / `?worker` imports (`recipe-pdfs`). |
199
+ | lottie-web | Browser | Works, full build included. `lottie-web/build/player/lottie_light` is the smaller build when you need no expressions. |