@somewhere-cloud/cli 0.38.155 → 0.38.157

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 +8 -1
  2. package/dist/commands/docs.js +1 -1
  3. package/dist/lib/bundle.js +286 -188
  4. package/dist/lib/bundle.js.map +3 -3
  5. package/npm-shrinkwrap.json +2 -2
  6. package/package.json +2 -3
  7. package/dist/docs/adopt.md +0 -39
  8. package/dist/docs/analytics.md +0 -161
  9. package/dist/docs/api-reference.md +0 -339
  10. package/dist/docs/api-surface.md +0 -2067
  11. package/dist/docs/app-mcp.md +0 -162
  12. package/dist/docs/architecture-patterns.md +0 -334
  13. package/dist/docs/auth-client.md +0 -531
  14. package/dist/docs/billing.md +0 -76
  15. package/dist/docs/browser.md +0 -639
  16. package/dist/docs/calendar.md +0 -298
  17. package/dist/docs/changes.md +0 -323
  18. package/dist/docs/cli.md +0 -407
  19. package/dist/docs/common-mistakes.md +0 -199
  20. package/dist/docs/connect-agent.md +0 -72
  21. package/dist/docs/cors.md +0 -114
  22. package/dist/docs/cron.md +0 -167
  23. package/dist/docs/database-engine.md +0 -167
  24. package/dist/docs/declared-data.md +0 -1656
  25. package/dist/docs/declared-files.md +0 -475
  26. package/dist/docs/deploy-intelligence.md +0 -188
  27. package/dist/docs/deploy.md +0 -733
  28. package/dist/docs/design-system.md +0 -273
  29. package/dist/docs/dev-environments.md +0 -496
  30. package/dist/docs/domain-ownership.md +0 -31
  31. package/dist/docs/domains.md +0 -370
  32. package/dist/docs/feedback.md +0 -88
  33. package/dist/docs/file-tools.md +0 -116
  34. package/dist/docs/functions.md +0 -489
  35. package/dist/docs/getting-started.md +0 -238
  36. package/dist/docs/github.md +0 -95
  37. package/dist/docs/google-calendar.md +0 -212
  38. package/dist/docs/groups.md +0 -836
  39. package/dist/docs/guarantees.md +0 -58
  40. package/dist/docs/handled-for-you.md +0 -224
  41. package/dist/docs/inspect.md +0 -171
  42. package/dist/docs/limits.md +0 -68
  43. package/dist/docs/live-data.md +0 -197
  44. package/dist/docs/live.md +0 -92
  45. package/dist/docs/local-dev.md +0 -30
  46. package/dist/docs/migration-supabase.md +0 -58
  47. package/dist/docs/payments.md +0 -1102
  48. package/dist/docs/portability.md +0 -194
  49. package/dist/docs/postgres.md +0 -301
  50. package/dist/docs/pricing-comparison.md +0 -42
  51. package/dist/docs/pricing.md +0 -39
  52. package/dist/docs/project-groups.md +0 -107
  53. package/dist/docs/projects.md +0 -380
  54. package/dist/docs/recipe-ai-agent.md +0 -112
  55. package/dist/docs/recipe-ai-features.md +0 -227
  56. package/dist/docs/recipe-ai-receipts.md +0 -783
  57. package/dist/docs/recipe-background-jobs.md +0 -369
  58. package/dist/docs/recipe-booking.md +0 -348
  59. package/dist/docs/recipe-csv-import.md +0 -390
  60. package/dist/docs/recipe-ecommerce.md +0 -127
  61. package/dist/docs/recipe-email.md +0 -282
  62. package/dist/docs/recipe-escalation.md +0 -133
  63. package/dist/docs/recipe-file-uploads.md +0 -159
  64. package/dist/docs/recipe-import-app.md +0 -110
  65. package/dist/docs/recipe-login.md +0 -457
  66. package/dist/docs/recipe-multi-chat.md +0 -198
  67. package/dist/docs/recipe-paid-api.md +0 -161
  68. package/dist/docs/recipe-pdfs.md +0 -205
  69. package/dist/docs/recipe-push-notifications.md +0 -107
  70. package/dist/docs/recipe-seo.md +0 -200
  71. package/dist/docs/recipe-signed-in-app.md +0 -330
  72. package/dist/docs/render.md +0 -99
  73. package/dist/docs/rooms.md +0 -554
  74. package/dist/docs/sdk.md +0 -287
  75. package/dist/docs/sdks.md +0 -24
  76. package/dist/docs/search.md +0 -199
  77. package/dist/docs/security-model.md +0 -168
  78. package/dist/docs/setup.md +0 -212
  79. package/dist/docs/smoke.md +0 -102
  80. package/dist/docs/speed.md +0 -298
  81. package/dist/docs/sql-compatibility.md +0 -96
  82. package/dist/docs/sw.agent.md +0 -248
  83. package/dist/docs/sw.ai.md +0 -1291
  84. package/dist/docs/sw.auth.md +0 -1811
  85. package/dist/docs/sw.billing.md +0 -171
  86. package/dist/docs/sw.db.md +0 -2128
  87. package/dist/docs/sw.email.md +0 -661
  88. package/dist/docs/sw.endpoint.md +0 -187
  89. package/dist/docs/sw.env.md +0 -303
  90. package/dist/docs/sw.fetch.md +0 -115
  91. package/dist/docs/sw.fs.md +0 -424
  92. package/dist/docs/sw.groups.md +0 -836
  93. package/dist/docs/sw.image.md +0 -69
  94. package/dist/docs/sw.jobs.md +0 -520
  95. package/dist/docs/sw.logs.md +0 -61
  96. package/dist/docs/sw.mail.md +0 -106
  97. package/dist/docs/sw.notifications.md +0 -78
  98. package/dist/docs/sw.push.md +0 -161
  99. package/dist/docs/sw.rateLimit.md +0 -67
  100. package/dist/docs/sw.web.md +0 -128
  101. package/dist/docs/tasks.md +0 -269
  102. package/dist/docs/test.md +0 -220
  103. package/dist/docs/tool-reference-account.md +0 -7
  104. package/dist/docs/tool-reference-ai.md +0 -121
  105. package/dist/docs/tool-reference-analytics.md +0 -37
  106. package/dist/docs/tool-reference-api.md +0 -19
  107. package/dist/docs/tool-reference-artifacts.md +0 -35
  108. package/dist/docs/tool-reference-auth.md +0 -163
  109. package/dist/docs/tool-reference-browser.md +0 -114
  110. package/dist/docs/tool-reference-code.md +0 -26
  111. package/dist/docs/tool-reference-connect.md +0 -21
  112. package/dist/docs/tool-reference-cron.md +0 -48
  113. package/dist/docs/tool-reference-db.md +0 -282
  114. package/dist/docs/tool-reference-domains.md +0 -107
  115. package/dist/docs/tool-reference-email.md +0 -55
  116. package/dist/docs/tool-reference-env.md +0 -19
  117. package/dist/docs/tool-reference-feedback.md +0 -56
  118. package/dist/docs/tool-reference-fs.md +0 -265
  119. package/dist/docs/tool-reference-github.md +0 -57
  120. package/dist/docs/tool-reference-groups.md +0 -85
  121. package/dist/docs/tool-reference-help.md +0 -29
  122. package/dist/docs/tool-reference-jobs.md +0 -39
  123. package/dist/docs/tool-reference-live.md +0 -48
  124. package/dist/docs/tool-reference-logs.md +0 -16
  125. package/dist/docs/tool-reference-payments.md +0 -44
  126. package/dist/docs/tool-reference-project.md +0 -706
  127. package/dist/docs/tool-reference-push.md +0 -78
  128. package/dist/docs/tool-reference-rate-limit.md +0 -18
  129. package/dist/docs/tool-reference-search.md +0 -68
  130. package/dist/docs/tool-reference-security.md +0 -42
  131. package/dist/docs/tool-reference-smoke.md +0 -17
  132. package/dist/docs/tool-reference-stock-photos.md +0 -20
  133. package/dist/docs/tool-reference-tasks.md +0 -73
  134. package/dist/docs/tool-reference-telegram.md +0 -32
  135. package/dist/docs/tool-reference-usage.md +0 -9
  136. package/dist/docs/tool-reference-web.md +0 -71
  137. package/dist/docs/tool-reference-webhooks.md +0 -9
  138. package/dist/docs/troubleshooting.md +0 -411
  139. package/dist/docs/typed-functions.md +0 -94
  140. package/dist/docs/verify-before-deploy.md +0 -67
  141. package/dist/docs/vs-supabase.md +0 -75
  142. package/dist/docs/vs-vercel.md +0 -103
@@ -1,58 +0,0 @@
1
- # Built-in protections — what the platform handles
2
-
3
- Owner tables keep each person's rows separate. Private collections check file
4
- access. Sessions use HttpOnly cookies, and background handlers can verify
5
- signed deliveries with one call. These protections are built into the app
6
- interfaces below.
7
-
8
- Start with a table declared using `owner()` and an upload collection scoped to
9
- its user; their ordinary reads and writes apply the access rules for you.
10
- Use explicit server operations only inside a handler that has checked the
11
- caller's permission. Open `declared-data` and `declared-files` for working
12
- examples, or use the table below to find a specific protection.
13
-
14
- ## Security
15
-
16
- | Protection | What the platform enforces | Your part | Details |
17
- |---|---|---|---|
18
- | Owner-scoped data | On a table declared with `scope: owner()`, the ordinary structured calls `sw.db.from`, `insert`, `update`, `remove` and `tx` act only on the verified user's rows. Without a signed-in user, they fail with `AUTH_REQUIRED`. Once a project declares tables, ordinary `sw.db.query` and `sw.db.batch` are refused. `sw.db.server.query` and `sw.db.server.batch` run reads only. | Write through the structured calls. Server operations, both reads and writes, skip the owner scope, so authorize the caller first. | `declared-data`, `sw.db` → `managed-mode-what-a-dbschemats-does-to-raw-sql` |
19
- | Private files | A declared file collection lets each user list, download and share only the files its `scope` and `client.read` allow, checked on every request. A share link opens one file for anyone holding it until it expires. It stops working when the file is replaced or deleted, or when the person who made it can no longer read the file. In a collection declared `public: true`, anyone can read the files at their public URL, while uploads, replacements and deletions still follow `scope` and `client`. A file written with `sw.fs.write` is private unless you write it public. | Declare a collection for user files, and keep share links short. | `declared-files` |
20
- | Signed background calls | Job, queue and cron deliveries are signed for each attempt, and `sw.jobs.verifyInvocation` accepts a signature once. Only a row-bound job may use managed data as its initiating user, within that row grant. | Call `verifyInvocation(request)` before reading the payload, and answer 403 when it returns `false`. | `sw.jobs` → `job-handler-function` |
21
- | Cookie sessions and origins | A write authenticated by a session cookie must carry the app's `Origin` header, or it fails with `ORIGIN_REQUIRED`. In safe CORS mode, a browser request from an unapproved origin that carries a cookie or `Authorization` is refused with 403 `ORIGIN_NOT_ALLOWED` before your code runs. | Add third-party origins to the project's allowlist. | `cors` → `what-is-refused-and-what-reaches-your-function` |
22
- | Per-project signing keys | Each project's app-user tokens are signed with a key derived for that project. A token issued for one project does not verify in another. | Nothing to configure. | `sw.auth` |
23
- | Single-use credentials | A password-reset token or magic link works once, including under concurrent requests. Refresh tokens rotate. Presenting a rotated one after the grace window revokes that user's refresh tokens and sessions everywhere. | Nothing to configure. With manual tokens, keep the newest refresh token after each refresh. | `sw.auth` → `token-refresh` |
24
- | Checkout | Only server code with the project's credentials creates a checkout. A catalog plan takes its price from the project's billing catalog. A deployed app's success and cancel URLs are accepted on its own addresses and attached custom domains, and other public hosts are refused. | Name a catalog plan. An amount you pass in line items is your handler's to validate. | `payments`, `sw.billing` |
25
- | Outbound requests | `fetch` in a deployed function refuses private and cloud-metadata addresses, checks every redirect, and applies a timeout. The platform's own calls to webhook URLs and to job, queue and cron handlers also refuse those addresses and check each redirect. | Make outbound calls with `fetch`. | `sw.fetch` |
26
- | Platform API access | Every platform API route declares which credentials may call it, and an undeclared route is refused. An app user's token reaches only the routes declared for app users. | Keep developer keys out of browser code. | `security-model` |
27
-
28
- ## Reliability
29
-
30
- We never pause free apps for idleness or paid apps because of a platform change;
31
- our [breaking-change policy](https://somewhere.cloud/docs/changes.txt#how-we-handle-breaking-changes)
32
- explains notice, prepared fixes and the safety exception.
33
-
34
- After each deploy, the after-deploy check loads your public home page in a
35
- browser. A blank page, or one that throws while loading, is warned about,
36
- not rolled back: the release stays live. When the version before it worked,
37
- the warning names it and gives the exact call that puts it back:
38
- `somewhere restore <version> --project <project_id> --yes`, or over MCP `project_rollback({ project_id, version })`. Server code that fails to start is refused before it goes live.
39
- Details: `deploy` → `reliability-guarantees-on-every-deploy`.
40
-
41
- ## Security tools
42
-
43
- Two advisory tools read your function source and report risky code. A finding
44
- from either one never changes or blocks a deploy. Platform checks apply
45
- regardless: the deterministic refusals of a
46
- secret key in source (`SECRET_IN_SOURCE`), a secret in a browser-exposed
47
- variable (`BROWSER_ENV_SECRET`) and a private credential file
48
- (`DEPLOY_PATH_REJECTED`); each refuses the deploy before anything is
49
- published.
50
-
51
- - **`security_review`** (MCP tool): an AI review of the project's deployed
52
- functions. It returns each finding with its severity and a fix. Run it after
53
- a deploy; the review depth and any automatic runs depend on the plan.
54
- - **Deploy scanner:** every deploy checks public handlers for risky shapes, such
55
- as admin calls, a caller-supplied user id or evaluated code. It lists each hit
56
- under `warnings` in the deploy response.
57
-
58
- Both tools in detail: `deploy-intelligence`.
@@ -1,224 +0,0 @@
1
- # Handled for you — the foundation behind your app
2
-
3
- Somewhere combines hosting, functions, identity, data, files, and application services in one project. Your agent can use the project's verified user across those services and declare access rules alongside the source. It does not need to assemble a separate account system, file-permission layer, email sender, and deployment pipeline for each app.
4
-
5
- This is a reference to the work the platform handles today, with links to the implementation contracts. **Automatic** means no additional protection to implement when using the named platform path. **Declare or configure** means you describe your app's intent; the platform enforces or runs it. **Available service** means your app calls it when needed. Availability and allowances vary by plan; [limits](https://somewhere.cloud/docs/limits.txt) and [pricing](https://somewhere.cloud/docs/pricing.txt) are the current reference.
6
-
7
- ## Nothing extra to set up
8
-
9
- These protections are built into the relevant platform service. You do not add a separate library, server, or security recipe for them.
10
-
11
- | Already handled | Where it applies |
12
- |---|---|
13
- | **Password hashing and salting** | Platform password accounts use salted password hashes; the app does not store or compare plaintext passwords. [Auth](https://somewhere.cloud/docs/sw.auth.txt) |
14
- | **Password-guessing protection** | Password sign-in automatically limits attempts per project/source address and per project/account, and locks an account for 15 minutes after 10 consecutive wrong passwords. [Exact limits](https://somewhere.cloud/docs/sw.auth.txt#automatic-password-sign-in-protection) |
15
- | **Generic invalid-login responses** | A missing account and a wrong password receive the same invalid-credentials response; the missing-account path also performs password-hashing work. Your app need not distinguish or expose those cases. [Auth](https://somewhere.cloud/docs/sw.auth.txt) |
16
- | **Browser session cookies** | The starter and cookie auth helpers issue Secure, HttpOnly, host-only session cookies. Page JavaScript cannot read those cookies. Session refresh and logout are provided; hand-written token storage is unnecessary on this path. [Client auth](https://somewhere.cloud/docs/auth-client.txt) |
17
- | **Single-use recovery links** | Password-reset tokens have an expiry and are consumed atomically, so concurrent attempts cannot both use one. A completed reset revokes the user's existing sessions and refresh tokens. [Password recovery](https://somewhere.cloud/docs/sw.auth.txt) |
18
- | **Cross-site request checks (CSRF)** | Cookie-authenticated writes through the platform auth path require an accepted Origin; missing or disallowed origins are refused. The generated data API also checks Origin. This is already part of these paths, not a CSRF package to install. [Auth](https://somewhere.cloud/docs/auth-client.txt) |
19
- | **Outbound address checks (SSRF)** | Deployed function fetches block private, loopback, link-local, and metadata destinations, check DNS answers at request time, and recheck followed redirects. Platform URL-fetching services have their own guarded fetch path. [Outbound requests](https://somewhere.cloud/docs/sw.fetch.txt) |
20
- | **Browser access closed until declared** | A managed table without browser permissions has no browser data access. Only declared operations and permitted columns are available through the generated client and its HTTP endpoint. [Declared data](https://somewhere.cloud/docs/declared-data.txt) |
21
- | **Protected ownership fields** | Structured owner-scoped writes derive ownership from the verified user; browser input cannot nominate another owner or overwrite the platform's author field. [Declared data](https://somewhere.cloud/docs/declared-data.txt) |
22
- | **Private project settings** | New environment values are private by default, including browser-looking names. Publishing a value requires an explicit public choice. Recognized server secrets are refused from public settings, and recognized source-code secret literals are refused at deploy. [Environment](https://somewhere.cloud/docs/sw.env.txt) |
23
- | **Auth email delivery** | Password reset, verification, and magic-link flows use the platform's sender. Auth-email limits and recipient suppression are applied by the platform. [Email](https://somewhere.cloud/docs/sw.email.txt) |
24
- | **Hosted HTTPS and edge delivery** | A project gets an HTTPS address, source compilation, and hosted assets/functions. Network DDoS mitigation comes from the hosting network; it does not replace app-specific abuse rules. [Deploy](https://somewhere.cloud/docs/deploy.txt) · [Network protection](https://developers.cloudflare.com/ddos-protection/about/) |
25
-
26
- Cookie protections apply when using the cookie path; a custom token system does not inherit them by name. Likewise, outbound address checks do not decide whether a user is allowed to trigger your business operation.
27
-
28
- ## Sign-in and account lifecycle
29
-
30
- **Declare or configure:** mount the provided auth route or use the working starter; choose the sign-in methods and which actions require a user. The platform supplies:
31
-
32
- - Registration, password sign-in, session refresh, logout, email verification, password recovery, and account profile operations.
33
- - Session inventory and revocation, so an app can let someone end other sessions without building a token store.
34
- - Magic-link and supported social sign-in flows (Google, GitHub, Discord). Provider registration remains a configuration decision. App users can sign in with a password and an email code, which the app owner turns on for everyone or for those who choose it (`sw.auth` → `email-sign-in-codes`); authenticator-app codes and passkeys are not available.
35
- - A verified request identity for supported data, file, billing, and other user-bound operations. Derive the user from that verified session, never from a user ID the browser submits.
36
- - An optional SDK and React auth components, so an agent can preserve working session behavior while changing the app's layout and styling.
37
-
38
- [Auth API](https://somewhere.cloud/docs/sw.auth.txt) · [Browser setup](https://somewhere.cloud/docs/auth-client.txt) · [SDK](https://somewhere.cloud/docs/sdk.txt)
39
-
40
- ## Database access, from personal notes to teams
41
-
42
- **Declare:** tables, relationships, access scope, and browser operations in `db/schema.ts`. The declaration travels with the release. The platform applies supported schema changes and enforces declared access on generated browser requests and ordinary structured database calls inside functions.
43
-
44
- | Access pattern | What the platform handles |
45
- |---|---|
46
- | **Owner** | Each signed-in user reads and changes their own rows; ownership is assigned from the verified session. |
47
- | **Shared** | Signed-in users can read the shared rows; only a row's author can change or delete it through generated browser access. |
48
- | **Team membership** | Access follows a membership table you name; operation-specific membership can make team access read-only. |
49
- | **Owner or team** | `anyOf` combines owner access with membership permissions without repeating the checks in every handler. |
50
- | **Inherited from a parent** | Child-row access follows the referenced parent's private scope when explicitly declared with `parent`. A relationship alone does not grant access. |
51
- | **Server-only** | The browser has no direct table operations; an authorized function performs the work. |
52
- | **Public reading** | Explicit read columns and, optionally, a publication condition define what signed-out visitors see. Public read access never grants writes. |
53
-
54
- **Field-level access is part of the contract.** Separate read, create, and update lists control returned data and accepted input. A newly added column stays out of the browser when it is absent from an explicit list. `read: true` deliberately selects all supported readable fields; use explicit lists when additions should remain private.
55
-
56
- The platform also provides typed browser access, filtering, ordering, pagination, related-record reads, supported aggregates, and transaction operations. A schema diff reports changes before application; supported additive changes apply, while production column removals and renames are refused. These capabilities reduce repeated query plumbing as well as repeated permission code.
57
-
58
- Shared-table operations inside server functions have a broader service contract than browser authorship rules; protect those handlers accordingly. Intentional server-authority operations and external SQL require your function to authorize its caller. Choosing a public or shared scope is a product decision, not something a platform can infer from a table's name.
59
-
60
- [Declared data](https://somewhere.cloud/docs/declared-data.txt) · [Database operations](https://somewhere.cloud/docs/sw.db.txt) · [SQL capabilities](https://somewhere.cloud/docs/sql-compatibility.txt)
61
-
62
- ## Files and controlled sharing
63
-
64
- **Declare:** file collections alongside tables, including permitted operations, ownership or membership, file types, and size limits. The generated file client handles uploads, listing, metadata, download, replacement, and deletion under that contract.
65
-
66
- - Owner, shared, team, owner-or-team, and server-only collections reuse the access vocabulary. The platform checks membership and ownership on file requests.
67
- - An operation you omit is refused. Public collections are a deliberate declaration and do not grant public upload or deletion.
68
- - Private collections do not become public because someone guesses a storage path. Original filenames do not have to be globally unique.
69
- - Declared-file share links are expiring bearer links. Replacement, deletion, or loss of the issuer's read access invalidates them. Anyone holding a valid link can use it; these are not recipient-bound invitations, and there is no individual-link revocation control on this surface.
70
- - Large uploads and upload URLs are available through the file service, with the applicable upload and plan limits.
71
-
72
- Existing uploads and custom upload endpoints do not automatically join a declared collection; existing files need explicit adoption. Your agent supplies the picker, gallery, document view, or other experience. The platform supplies storage and enforcement. These file links do not automatically authorize a custom endpoint or database-record share.
73
-
74
- [Declared files](https://somewhere.cloud/docs/declared-files.txt) · [File service](https://somewhere.cloud/docs/sw.fs.txt)
75
-
76
- ## Keys, environment values, and external services
77
-
78
- **Automatic for built-in services:** database, auth, files, managed AI, and transactional email use project-bound platform access. An app does not need separate provider keys just to call them.
79
-
80
- **Configure external integrations:** store a key once in project settings, choose its environment scope, and access it from a function. Stored values are encrypted and not returned by management reads. A private value is not made public merely because its name starts with `VITE_` or `REACT_APP_`.
81
-
82
- Public browser configuration has an explicit public setting. Publishable keys still become visible to visitors; storing one in settings does not turn it into a secret. Recognized secret checks catch supported patterns, not every arbitrary string that could be sensitive. After runtime configuration is adopted, production values can change without rebuilding or redeploying the app. New production page loads, and server requests that read settings inside the handler, receive changed values within 60 seconds, including a public value made private or deleted. Existing immutable apps adopt on their next ordinary source deploy; new apps adopt on their first deploy. An already open page does not automatically replace values it has read. Previews keep their captured development configuration, and rollback among adopted releases uses current production configuration rather than restoring old keys.
83
-
84
- [Environment settings and request-time reads](https://somewhere.cloud/docs/sw.env.txt#timing) · [Functions](https://somewhere.cloud/docs/functions.txt)
85
-
86
- ## Email without another account to get started
87
-
88
- **Available service:** transactional email uses a built-in sender, with no sender-domain setup required. It can address the project owner and the project's users who have verified their email address, with no reply-to and a daily limit per project. An arbitrary outside recipient is refused; your own verified sender domain enables the broader sending use cases.
89
-
90
- The platform also handles:
91
-
92
- - A **test inbox for agents**: the project's `*.test.somewhere.site` addresses capture auth and application mail without delivering to a real mailbox. Agents can retrieve the actual link and finish the user journey. Captured application sends do not consume the normal email allowance; retention and capture limits apply.
93
- - Auth emails automatically, including recovery and verification links.
94
- - Idempotent send requests when you supply an idempotency key; send status, history, and delivery-event lookup.
95
- - Bounce and complaint suppression, sending allowances, auth-email rate limits, and project pauses for excessive bounce or complaint rates.
96
- - Received mail for addresses on your custom domain, stored per mailbox and read through the mail API (`/v1/mail`).
97
-
98
- The built-in sender limits recipients to people connected to your project. Provider acceptance means the provider took the message; later delivery events (`delivered`, `bounced`, …) report what happened to it next.
99
-
100
- [Sending and test inbox](https://somewhere.cloud/docs/sw.email.txt) · [Inbound email](https://somewhere.cloud/docs/inbox.txt)
101
-
102
- ## AI without distributing provider keys
103
-
104
- **Available service:** `sw.ai` calls models using platform-managed credentials. The default path uses the account's included allowance, subject to project spend caps and request/token limits. Explicit model selection supports larger or different workloads with the documented billing rules; optional provider credentials let eligible calls bill your provider account directly.
105
-
106
- The service provides streaming, structured outputs, tool-call results, conversation handling, and usage reporting through its documented APIs. The agent-loop primitive adds bounded multi-step execution and tool handling when an app needs it. Your app defines the task, permitted tools, approval decisions, and user-facing behavior.
107
-
108
- OpenAI backs the Advisor, AI security reviews, and generated deploy descriptions. Anthropic backs Sprite's AI editor. These features and the corresponding provider-backed calls in `sw.ai` are available where their providers operate. Sign-in, deploys, hosting and database access are separate from AI provider availability. [Somewhere Terms](https://somewhere.cloud/terms) · [OpenAI supported regions](https://help.openai.com/en/articles/7947663-chatgpt-and-openai-api-supported-countries-and-territories) · [Anthropic supported regions](https://www.anthropic.com/legal/supported-regions)
109
-
110
- [Models and allowances](https://somewhere.cloud/docs/sw.ai.txt) · [Agent loop](https://somewhere.cloud/docs/sw.agent.txt)
111
-
112
- ## Request validation, rate limits, and safe networking
113
-
114
- **Declare:** `sw.endpoint` can combine an auth requirement, a body schema, an action-specific rate limit, and a handler. It is optional; ordinary default-export functions remain supported. Your agent can use the wrapper to avoid repeating the same request checks across routes.
115
-
116
- **Available service:** `sw.rateLimit.check(key, max, windowSeconds)` supplies project-scoped counters without deploying a separate counter service. Your app chooses the key and responds when the allowance is exhausted. Use a verified user, an IP, or an operation key as appropriate. These fixed-window throttles are not exact financial quotas.
117
-
118
- **Automatic controls already present:** password sign-in throttles, auth-email restrictions, and service/plan admission limits. There is no blanket per-user limit that automatically understands every custom endpoint or the cost of calls made with your own outside-provider key.
119
-
120
- The frontend and its functions share an origin, so ordinary same-app requests need no cross-site API setup. External browser origins are a separate CORS configuration. CORS and CSRF protect browser request boundaries; authorization decides who may perform the operation. Outbound fetch helpers add bounded requests, checked redirects, and documented retry behavior; non-idempotent effects need deliberate retry choices.
121
-
122
- [Endpoint wrapper](https://somewhere.cloud/docs/sw.endpoint.txt) · [Rate limits](https://somewhere.cloud/docs/sw.rateLimit.txt) · [CORS](https://somewhere.cloud/docs/cors.txt) · [Outbound fetch](https://somewhere.cloud/docs/sw.fetch.txt)
123
-
124
- ## Payments and feature access
125
-
126
- **Configure:** connect payments, define plans and prices, and select the features that require an entitlement. The platform supplies checkout, payment-event processing, the user-plan flow, entitlement lookups, and subscription-management surfaces.
127
-
128
- For the user-checkout flow, verified identity ties the payment to the user. Functions can check a feature with `sw.billing.has('export')`; the subject comes from the request, not an ID supplied by the browser. React pricing and billing components are available and can be styled by the app.
129
-
130
- Prices, refunds, tax/business obligations, order fulfillment, and custom webhook effects remain app decisions. An ad-hoc payment does not automatically fulfill an order.
131
-
132
- [Payments](https://somewhere.cloud/docs/payments.txt) · [Plans and entitlements](https://somewhere.cloud/docs/sw.billing.txt)
133
-
134
- ## Live updates, background work, and scheduled work
135
-
136
- | Capability | Work the platform takes over | App input |
137
- |---|---|---|
138
- | **Live database views** | A declared read produces a subscription; writes invalidate it and clients re-read through the authorized function. The notification channel carries invalidation, not your rows. | Declare the read and connect the UI; this is not an arbitrary public broadcast channel. |
139
- | **Shared live-data polling** | Poll once and fan out results for the configured data source instead of making every browser poll it. | Write the scheduled poller and declare its snapshot table/live view; choose the source, cadence, and audience. |
140
- | **Durable background jobs** | Admission, execution, status, retry/recovery behavior, and supported idempotency-key handling. | Write an idempotent handler and verify each invocation. Inspect job status when work does not finish; [recovery](https://somewhere.cloud/docs/recipe-background-jobs.txt) explains failed and indeterminate outcomes. |
141
- | **Cron** | Schedule and invoke a configured job or endpoint. | Choose when it runs and what it is authorized to do; schedules work on every plan, with plan-specific count and interval limits. |
142
- | **Notifications** | Built-in email, push, and unified notification APIs. | Choose recipients and message content. Each user turns on push in their own browser, and the app decides who gets notified. |
143
-
144
- [Live views](https://somewhere.cloud/docs/live.txt) · [Live data](https://somewhere.cloud/docs/live-data.txt) · [Jobs](https://somewhere.cloud/docs/sw.jobs.txt) · [Cron](https://somewhere.cloud/docs/cron.txt) · [Notifications](https://somewhere.cloud/docs/sw.notifications.txt)
145
-
146
- ## Deployment, previews, verification, and rollback
147
-
148
- **Automatic on deploy:** compilation of raw React/TypeScript source, dependency resolution, hosting, and built-in checks. You deploy source, not a locally built `dist` directory. The platform distinguishes recognized blocking checks from advisory findings; on-demand AI review is a separate inspection, not proof that every endpoint is authorized correctly.
149
-
150
- **Available tools and workflows:**
151
-
152
- - `somewhere verify` can exercise a supplied journey and return browser evidence, screenshots, console/network findings, and expected-refusal checks. It complements an agent's own Playwright tests. Closing a browser does not erase test data.
153
- - Source export, surgical file patches, generated types, inspection, and the CLI/MCP/API surfaces let an agent work on the same project without reconstructing it from compiled output.
154
- - GitHub-connected deployment and custom domains are available after connection/ownership setup. HTTPS provisioning is handled by the hosting service.
155
- - Hosted previews for signed-in accounts on **every plan** create an isolated, populated database copy, keep production-only secrets out, and gate access. Promotion checks whether production changed. Preview writes never merge into production.
156
- - Previews have copy limits and restricted side effects: no outbound function requests, read-only copied identity rather than a full public sign-in flow, email only to the project's test inbox, and Stripe test-mode payments whose callbacks are withheld from the project webhook. Local `somewhere dev` instead uses the deployed backend; local writes can be production writes.
157
- - Rollback selects a retained release and checks whether its managed schema can safely activate. It is a code/release recovery operation, not a point-in-time restoration of customer rows.
158
- - Smoke checks provide on-demand health probes; recurring checks have plan-dependent availability. Logs and inspection provide evidence when an operation fails.
159
-
160
- [Deploy](https://somewhere.cloud/docs/deploy.txt) · [Previews](https://somewhere.cloud/docs/dev-environments.txt) · [Verification](https://somewhere.cloud/docs/verify-before-deploy.txt) · [Smoke checks](https://somewhere.cloud/docs/smoke.txt) · [Inspection](https://somewhere.cloud/docs/inspect.txt) · [Logs](https://somewhere.cloud/docs/sw.logs.txt)
161
-
162
- ## Other services in the same project
163
-
164
- These are available primitives, not features silently added to every app. Your agent selects the ones the product needs.
165
-
166
- | Need | Built-in service and reference |
167
- |---|---|
168
- | Images, thumbnails, and transformations | [Image service](https://somewhere.cloud/docs/sw.image.txt) |
169
- | PDF generation from a page or template | [Rendering](https://somewhere.cloud/docs/render.txt) |
170
- | Booking availability and reservations | [Calendar](https://somewhere.cloud/docs/calendar.txt) |
171
- | Product events and aggregate reports | [Analytics](https://somewhere.cloud/docs/analytics.txt) |
172
- | File extraction, chunking, indexing, and retrieval after explicit ingestion | [Search](https://somewhere.cloud/docs/search.txt) |
173
- | Reading public web content | [Web](https://somewhere.cloud/docs/sw.web.txt) |
174
- | Notifications to a user's browser, with per-device send history | [Push](https://somewhere.cloud/docs/sw.push.txt) |
175
- | Tickets and work tracking inside a project | [Tasks](https://somewhere.cloud/docs/tasks.txt) |
176
- | Organizing related projects | [Project groups](https://somewhere.cloud/docs/project-groups.txt) |
177
- | Source, table, and database exports | [Portability](https://somewhere.cloud/docs/portability.txt) |
178
- | An external PostgreSQL database | [Postgres connection](https://somewhere.cloud/docs/postgres.txt); provider billing, migrations, and SQL authorization remain with that external database. |
179
-
180
- ## Privacy: what the platform handles and what to ask your human
181
-
182
- The platform already knows the facts a privacy page needs. Call `project_privacy_facts` (or `GET /v1/projects/<id>/privacy`). It reports:
183
- - who signs in to the app and how;
184
- - whether the app sends email, takes payments or uses AI, and through which providers;
185
- - the cookies the platform sets on the app;
186
- - how long things are kept;
187
- - the outside services that handle the app's users' data;
188
- - the tables and files that hold personal data, and the outside domains its source loads.
189
-
190
- Write or check the app's privacy page from these facts instead of guessing. Stored files and storage are private by default. Fonts from Google are served from the app's own address. Unsubscribe is added to mail sent from the app's free address. For optional analytics in Europe, `analytics_consent: { mode: "auto" }` makes the platform ask visitors there with its own small prompt and honour browser privacy signals ([Analytics](https://somewhere.cloud/docs/analytics.txt)).
191
-
192
- Ask your human only what the platform cannot know:
193
- - who runs the app and how people reach them (the name and contact on the privacy page);
194
- - whether the app is aimed at children;
195
- - whether it sends marketing email (which needs a postal address in each message);
196
- - what the app keeps outside the platform, such as a raw SQL table or another service.
197
-
198
- Never tell anyone the app "is compliant"; describe what it does.
199
-
200
- ### Publishing the privacy page
201
-
202
- The platform can publish the page for you at `https://<app>/__sw/privacy`. The page is drawn from the live facts each time it is read, so it stays current as the app changes. Link to it from the app as "Privacy".
203
-
204
- - `GET /v1/projects/<id>/privacy` returns `privacy_page`: whether it is published, its `url`, the stored `owner` and `contact`, and `suggested` values from the account. It also returns `collects`, the sentences of the page's "What we collect" section.
205
- - `PUT /v1/projects/<id>/privacy/page` with `{ "owner": "...", "contact": "..." }` publishes it. `owner` is the person or business that runs the app, 1 to 120 characters. `contact` is an email address or an `https://` address. Calling it again replaces both and the date.
206
- - `DELETE /v1/projects/<id>/privacy/page` unpublishes it. The address then returns 404.
207
-
208
- Both need owner or editor access, and both return the page's `url` and `markdown`. The public page can take up to a minute to show a change.
209
-
210
- The name and contact are shown to the public. Ask your human before publishing them, even the suggested ones.
211
-
212
- ### The person's own data page
213
-
214
- `https://<app>/__sw/my-data` lets a person signed in to your app download a copy of their data or delete their account with the records and files that belong only to them. Before either action, the platform emails a 6-digit code to the account's own address, and the page acts only after the person enters it. The code lasts 10 minutes, works once, and works only for that sign-in and that action. The page makes exactly the person's own calls to `GET /v1/auth/users/me/export` and `DELETE /v1/auth/users/me?erase=owned`, which your app can also make for them.
215
-
216
- Scripts on your app's pages act as the signed-in person: they can read and change whatever that person can. Load only scripts you trust.
217
-
218
- ## What you still decide
219
-
220
- You choose the product behavior: who belongs to a team, what is public, what an administrator may do, what a purchase delivers, and which outside systems are allowed to act. The platform can enforce a declared rule consistently; it cannot choose the right rule from a description like “invoice” or “customer.”
221
-
222
- Test signed-out, owner, wrong-user, and team-membership journeys for the rules you choose. Authorize privileged functions and deliberate server-mode operations. Treat public values and valid bearer links as readable by their holders. Keep recovery/export plans appropriate to the data you hold, and check actual allowances rather than assuming any metered service is unlimited.
223
-
224
- Agents can request `somewhere docs handled-for-you --full` for this whole reference or use `--section <heading-id>` for one area. The [documentation index](https://somewhere.cloud/docs/llms.txt) links the complete topic catalog; [getting started](https://somewhere.cloud/docs/getting-started.txt) provides the shortest build path.
@@ -1,171 +0,0 @@
1
- # Inspect — Read live state before writing
2
-
3
- You open a session and the user says "fix the auth bug in adapted-co"
4
- or "add a /pricing page to my-saas". The local workspace may be
5
- stale, empty, or out-of-date — and another agent (or the user
6
- themselves on another machine) may be editing the same project
7
- right now. Inspecting before writing is the difference between a
8
- clean patch and overwriting someone else's work.
9
-
10
- ## The default inspect-first order
11
-
12
- 1. project_get { project_id }
13
- → Confirms the project exists. Returns subdomain, current code
14
- `version`, custom domain, owner. Save the version for deploy history and diffs.
15
-
16
- 2. project_export { project_id }
17
- → Pulls the live deployed source (static + functions) in one
18
- call. The platform is the authoritative copy. (CLI equivalent:
19
- `somewhere pull <id>` writes it to ./<slug>/.)
20
-
21
- 3. project_deploys { project_id }
22
- → Up to 150 successful releases plus 20 failed attempts, with timestamps. Look
23
- for: deploys in the last hour (someone is active), gaps
24
- between versions (interrupted shipping), unfamiliar deployers.
25
-
26
- 4. deploy_status { project_id }
27
- → Confirms which immutable release is named by
28
- `active_release_id` and served on every project hostname.
29
-
30
- For runtime symptoms, layer on:
31
-
32
- errors { project_id }
33
- → Last 50 runtime errors with stack and request path. Run this
34
- BEFORE assuming the bug is wherever the user pointed you.
35
-
36
- project_logs { project_id, function_path?, since? }
37
- → console.log output from deployed functions. Filter by
38
- function path or time window when investigating a specific
39
- endpoint.
40
-
41
- project_diff_versions { project_id, from, to }
42
- → Per-file delta between two preserved versions: added,
43
- removed, changed (with truncated text previews), plus
44
- function source. Use after a STALE_RELEASE_BASE refusal to see what
45
- the other agent shipped before merging and retrying.
46
-
47
- fs_versions { project_id, path }
48
- → History for a single user-uploaded file (anything written
49
- under /v1/fs/*). NOT for project code — see below.
50
-
51
- ## Two version namespaces, never confused
52
-
53
- There are TWO independent histories. Picking the wrong one is a
54
- common mistake.
55
-
56
- Code history: project_deploys / project_restore_version
57
- Covers files + functions shipped by
58
- project_deploy or project_patch.
59
-
60
- Upload history: fs_versions / fs_restore
61
- Covers user-uploaded files under /v1/fs/* —
62
- uploads, generated PDFs, cached blobs. Each
63
- path has its own version chain.
64
-
65
- `project_restore_version` rolls back code but leaves uploaded
66
- data alone. `fs_restore` rewinds one uploaded file without
67
- touching code. Pick the right tool for what is broken.
68
-
69
- ## Editing what you pulled
70
-
71
- Keep the export's `active_release_id`. Send it as `base_release_id` when you
72
- deploy or patch. A stale release ID returns `STALE_RELEASE_BASE`. On a project
73
- with a production release, omit the numeric `expected_version` field.
74
-
75
- ```text
76
- project_export({ project_id: "adapted-co" })
77
- ```
78
-
79
- Here `version` is 47. After editing:
80
-
81
- ```text
82
- project_patch({
83
- project_id: "adapted-co",
84
- base_release_id: "<active_release_id from project_export>",
85
- path: "api/auth.ts",
86
- content: "<the edited file>"
87
- })
88
- ```
89
-
90
- If another agent deployed between your export and your patch, the platform
91
- refuses the stale release. Use the `base_version` and `active_version` fields
92
- in the 409 response, when present, to inspect the intervening changes:
93
-
94
- ```text
95
- project_diff_versions({ project_id: "adapted-co", from: 47, to: 48 })
96
- ```
97
-
98
- Merge their changes, export again, and retry with that export's
99
- `active_release_id` as `base_release_id`.
100
-
101
- ## Subscribe to deploys in real time
102
-
103
- Every successful `project_deploy` / `project_patch` /
104
- `project_restore_version` publishes a message on the
105
- `system:project` system channel for that project. Subscribe with a
106
- developer key to be notified the instant another agent ships. This is
107
- developer tooling, not an in-function capability:
108
-
109
- events_subscribe_project({ project_id: "my-app" })
110
- // → { channel: "system:project", websocket_url, event_types: [...] }
111
- // open websocket_url; each frame is the envelope below
112
-
113
- Event shape:
114
-
115
- {
116
- event: "deployed" | "patched" | "restored" | "rolled_back",
117
- data: {
118
- version: 49,
119
- by: "user_…", // actor user_id
120
- message: null, // optional deploy message
121
- has_functions: true,
122
- at: "2026-05-12T18:04:11.000Z",
123
- }
124
- }
125
-
126
- A long-running editing agent should subscribe to this channel and
127
- treat any `event: "deployed"` with a higher version than its
128
- last observed version as "stop, re-clone or diff, then retry."
129
-
130
- ## Who deployed v13?
131
-
132
- `project_deploys` now returns each row with a `deployed_by`
133
- object containing the actor's `user_id` and `email`. NULL means
134
- the row was written before actor tracking was added (the project
135
- owner is the safe fallback in that case).
136
-
137
- ## When you can skip the inspect-first dance
138
-
139
- - You just created the project in this session.
140
- - The user says "I'm the only person editing this."
141
- - You are only reading (db_query, project_logs, errors).
142
-
143
- Inspect before writing whenever:
144
-
145
- - The user mentions another machine, another agent, or a
146
- collaborator.
147
- - `project_deploys` shows multiple deploys today.
148
- - You see "I have local edits" or "I cloned this last week".
149
- - The last `project_deploy` response is more than ~10 minutes
150
- old in your conversation — assume someone else may have
151
- shipped since.
152
-
153
- ## Remaining limits (be honest with the user)
154
-
155
- - `project_deploy` is full-replacement for static files (every file
156
- in `files` replaces the live set). Functions are merge-preserved
157
- by default — pass `replace_functions:true` to delete omitted
158
- functions. `dry_run:true` previews the diff before anything writes.
159
- - Single-file optimistic concurrency for `fs_write` does not
160
- exist yet — `base_release_id` is a project-code check, not
161
- a per-file CAS for uploads under /v1/fs/*.
162
-
163
- When either of those limits matters, surface it to the user
164
- instead of pretending the platform has the feature.
165
-
166
- Historical deployed-source file reads are unavailable. Source readers refuse unsupported
167
- `version` or release selectors; `project_diff_versions` shows what changed.
168
- The SEO check reads only the active release and refuses version selectors.
169
- The docs HTTP readers keep their supported `version` (and docs-query filters)
170
- and refuse unsupported selectors.
171
- A history row alone does not guarantee retained source or a restorable build.
@@ -1,68 +0,0 @@
1
- # Limits
2
-
3
- These are the same on every plan. Plan quotas (storage, email, deploys per hour,
4
- the per-file upload size, the monthly AI spend cap) are separate: `GET /v1/pricing` and
5
- docs({ topic: 'pricing' }).
6
-
7
- CPU time counts computation. Time spent waiting for a database or network
8
- response does not use the CPU allowance. An ordinary HTTP function has no
9
- fixed wall-clock deadline while its client stays connected.
10
-
11
- | Ceiling | Value | Instead |
12
- |---|---|---|
13
- | Request body into a function | about 100 MB | Have the browser upload big files straight to file storage with `sw.fs.uploadUrl` |
14
- | Memory shared by concurrent requests in one runtime instance | 128 MB | Stream or process in chunks; move heavy work to `sw.jobs` |
15
- | CPU time per request | 300 s for newly deployed functions | Use `sw.jobs` for work that must finish independently of the browser |
16
- | Wall-clock time per HTTP request | No fixed deadline while the client stays connected | Use `sw.jobs` when work must survive a disconnected client |
17
- | One database record | about 4 MB | Store large values with files (`sw.fs`) and keep the path in the row |
18
- | Environment values | about 5 KB (5,120 bytes) for all of a project's values together | Keep large configuration in files; a save above the limit is refused with 413 `ENV_VALUE_TOO_LARGE` (one value) or `ENV_VALUES_TOO_LARGE` (all values together), naming the key and the limit |
19
- | One uploaded file | per plan (`max_upload_mb` in `GET /v1/pricing`) | Above about 25 MB, use `sw.fs.uploadUrl`; above 90 MB, upload it in parts through its `multipart_url` — docs({ topic: 'sw.fs' }) |
20
- | One deploy | 20 MiB, 1,500 files, 5 MiB of text source | docs({ topic: 'deploy' }) states the deploy limits |
21
-
22
- ## What a runtime limit hit looks like
23
-
24
- A stopped runtime can return HTTP 500 with `FUNCTION_RUNTIME_FAILED` in the
25
- platform's JSON error envelope, `{ ok: false, error, message, request_id }`.
26
- Check the matching project log for the cause: the response alone cannot
27
- distinguish CPU exhaustion, memory exhaustion or a runtime outage. Retry a
28
- write only after checking whether it committed. Your function's own 503
29
- response passes through unchanged.
30
-
31
- Redeploy an older function to adopt the current CPU allowance. Disconnecting
32
- the client can end its request; use `sw.jobs` for durable work. Outbound fetch,
33
- code evaluation and job attempts have their own deadlines, described in their
34
- respective topics. These bound stalled connections and individual attempts.
35
- A request body over the ceiling is refused with 413 before your function runs.
36
-
37
- ## Creating a project with a starter
38
-
39
- `project_create` waits up to 120 seconds for the
40
- starter deploy to answer. If the answer has not arrived, the project still
41
- exists and deployment may still complete. Check `project_deploys` and
42
- `deploy_status` with the returned project ID before deciding what to do next.
43
- Do not create a second project to recover a missing deploy answer.
44
-
45
- ## Monthly AI spend cap
46
-
47
- Each project's AI spending has a monthly cap from your plan
48
- (`ai_spend_cap_cents` in `GET /v1/pricing`), counted per project per
49
- calendar month (UTC). At 80% the owner gets one email, a warning in the
50
- project's logs and on every deploy. At 100% every AI call from the project
51
- is refused with 429 `AI_SPEND_CAP_REACHED` until the month turns; the rest
52
- of the app keeps working. The owner can raise it, lower it or turn it off
53
- for one project with `PATCH /v1/projects/{id}` `{ "ai_spend_cap_cents": … }`
54
- (MCP `project_update`); the prepaid balance still bounds spend.
55
- Details: docs({ topic: 'sw.ai' }).
56
-
57
- ## Usage levels and time left
58
-
59
- Account reads say how close each meter is, so no caller picks its own
60
- thresholds: `GET /v1/usage/summary` gives `level` (`ok`, `warning` from
61
- 80% of the limit, `critical` at 100%) and a plain `level_label` on
62
- `account_database`, `account_files` and each project's `combined_storage`.
63
- The account read (`somewhere whoami --json`, `GET /v1/auth/platform-me`) and
64
- `GET /v1/account/overview` give `trial: { ends_at, days_left }` while a
65
- trial runs (null otherwise), and
66
- `temporary_expires_at` for a temporary account.
67
-
68
- Related: `sw.jobs`, `sw.fs`, `deploy`, `sw.env`, `database-engine`.