# Creator runtime options and external backends For centrally configured AI providers, use [the shared AI gateway](/docs/ai-providers.md). Admin assigns providers/models to roles; creators opt into those roles in Studio or MCP, then integrate `Hackemist.ai`. Provider keys stay on the server and no external-origin approval is needed for this gateway. Studio and MCP expose the same project options. Creators configure cloud saves, Hackemist multiplayer rooms, and the exact API or WebSocket origins for their apps. Backend origins require administrator review by default. Operators can enable self-service for accounts with external backend access. The app still needs its own networking and save integration. ## Studio Open **Studio → Cloud saves** to inspect storage/save integration hints and enable automatic localStorage sync when separate runtime hosting is available. Under **Studio → App details → Browser compatibility**, **Multiplayer & connections** enables built-in rooms and shows the operator's service availability, guest policy, and room-size limit. Its copyable SDK starter demonstrates creating/joining a room and sending messages; implement your own UI and app rules using [the room SDK](/docs/multiplayer.md). In **External backend / API / WebSocket**, enter one exact origin per line, such as `https://api.example.com` and `wss://rooms.example.com`. Enter the complete list, including any existing origins you still need. To remove an origin, leave it out of the list. To remove all origins, submit an empty list. - When Studio shows **Save backend origins**, the change takes effect immediately for new launches. The connection note is optional. Saving replaces any pending connection changes and preserves unrelated permissions under review. - When Studio shows **Request external connections**, describe what data the backend receives. An administrator reviews the request under **Admin → Projects → Browser permission requests**. The active list takes effect on fresh launches after approval. After a change, open a fresh **Run draft** session and exercise a real request or WebSocket connection. The publishing checker blocks external destinations by design. Handle service unavailability in your app and verify the live integration in a real preview. Deploy the backend through your own provider. Add its public endpoint URL and client networking logic to the browser build. Keep private API keys, database passwords, service-role credentials, and MCP credentials on the server or in the coding client's secret store. Hackemist serves the static frontend and does not execute uploaded Node/Python servers, install packages, proxy arbitrary requests, or inject private credentials into browser code. Use **Additional browser permissions** for managed service-worker caching, external assets, frames, and forms. The administrator can review the complete profile or configure permissions directly after password confirmation. Pointer capture, immersive WebXR VR/AR, native workers and shared-memory WASM instead follow global Admin switches, enabled by default, and require no project permission request. WebXR and workers automatically use dedicated origins when wildcard hosting is available. Shared memory requires workers and matching cross-origin isolation headers; disabling workers suspends shared memory. Spatial tracking does not grant raw camera or unrelated sensor access; player gestures/consent, supported hardware and a secure context remain necessary. Reopen the app after a permission change; old launches are revoked. ## MCP 1. Call `runtime_options_get` with `project_id`. It returns the active `policy.connect_origins`, reviewed `stored_policy.connect_origins`, `creator_connection_origins`, `connections_self_service`, the opaque `policy_revision`, and the current request, isolation and room status. Use `save_integration_get` with `project_id` and optional `version_id` to inspect source hints and the save-format declaration. The read-only scan is bounded to 64 HTML/JS files, 512 KiB per file, and 2 MiB total. It does not execute code or access player saves. Hints cannot establish that memory-only progress or every gameplay field is persisted. 2. Call `runtime_options_update` with `project_id`, `base_policy_revision` from that response, and any of the boolean fields `auto_save`, `isolated`, or `multiplayer`. Only supplied options change. Enabling `auto_save` also enables `isolated` unless explicitly supplied; disabling saves retains the isolated origin and existing save data. Isolation cannot be disabled while an approved dependent capability is active. 3. Call `connections_request` with `project_id`, the current `policy_revision` as `base_policy_revision`, and the complete `connect_origins` list. When `connections_self_service` is true, the response is `status: "applied"` and any `reason` is optional. Otherwise supply a `reason` of 5–2,000 characters and expect `status: "pending"` until approval. Verify the effective list, open a fresh preview, and exercise a real backend call. 4. For memory-only progress, connect `Hackemist.createProgressStore` with synchronous JSON `capture`, validated `restore`, `initial` and recovery UI callbacks. Await `ready` before player actions; preserve originals and pause for a choice when local/cloud data differ. Replace unconditional lifecycle cache writes with its gated `cacheLocal()`; local cache is not a cloud acknowledgement. The app defines which fields constitute progress. See [SAVE_SDK.md](/docs/save-sdk.md). Integrate external services separately, validate and preview, then publish explicitly. A standalone MCP preview is read-only and cannot open account saves or shared rooms. Test authenticated behavior in the Studio/player bridge; closing or offline operation cannot guarantee an unacknowledged final save. ```json { "name": "runtime_options_update", "arguments": { "project_id": "YOUR_PROJECT_ID", "base_policy_revision": "COPY_CURRENT_POLICY_REVISION_FROM_RUNTIME_OPTIONS_GET", "auto_save": true, "multiplayer": true } } ``` ```json { "name": "connections_request", "arguments": { "project_id": "YOUR_PROJECT_ID", "base_policy_revision": "COPY_NEW_POLICY_REVISION_FROM_PREVIOUS_RESPONSE", "connect_origins": ["https://api.example.com", "wss://rooms.example.com"], "reason": "Our separately hosted backend authenticates players and stores authoritative game state." } } ``` `runtime_options_get` needs `projects:read`; updates and requests need `projects:write`. Current account eligibility, token revocation, ownership, and project binding are checked again in the transaction. An administrator's MCP credential can modify only its own projects. A stale revision returns a conflict: reload current options and explicitly retry. The revision also covers pending request changes, so a stale form cannot silently overwrite a newer request. Safe option changes amend only those fields in the pending request and invalidate its previous review revision. `compatibility_get` includes these runtime options. `compatibility_request` continues to request a **complete** permission profile; start from the returned approved/pending profile and preserve existing permissions. Its policy schema lists all supported booleans and exact-origin arrays. `hosting_info` links this document through `hackemist://docs/connections`. ## Operator availability and backend integration In **Admin → Site settings → External backend connections**, enable **Let eligible creators save backend origins without review** and confirm your current administrator password. The switch defaults to off. Ownership, account and plan permissions, MCP scopes, exact origin validation, and the 20-origin limit still apply. Service workers, external assets, frames, and form destinations continue through their own review. The connection list applies to the whole project, including published and draft versions. The runtime expires affected launches when the list changes. An isolated app can get a different runtime origin after a change, which can affect CORS and browser-only storage. Switching self-service off removes creator-managed origins and keeps manually reviewed origins. Enabling it again starts with no previous creator-managed origins. Pending requests can still be reviewed. A browser tab that has already loaded a policy may keep it until it closes or reloads. If access must end at the backend immediately, revoke its credentials or disable its endpoint. The separate `creator_runtime_options_enabled` setting controls creator changes to isolation, cloud browser saves and rooms. Room activation also requires the global room service to be enabled and a valid stable signing key/service origin. Global disabling of rooms prevents connections even when an app's room option was previously enabled. Cloud browser saves require dedicated runtime origins, `RUNTIME_SUBDOMAINS=true`, a stable `SETTINGS_KEY`, and wildcard DNS/TLS. Production uses separate registrable domains by default or the explicitly configured sibling-domain protections (operator repository reference: `SINGLE_DOMAIN_DEPLOYMENT.md`). Apps can also integrate explicit account saves with [the save SDK](/docs/save-sdk.md). Connection origins control where the player's browser can send requests. Your service must implement its own authentication, authorization, CORS, rate limits, and persistence. In the restricted sandbox the browser's Origin may be `null`. An isolated origin can change with the account, project, or permission profile. Use the actual browser Origin for CORS and authenticate each player separately. Browser third-party-cookie rules still apply. Add the HTTPS origin used by API calls and the WSS origin used by sockets separately. Put URL paths in your app code. ```js // Public browser URLs: replace routes and add your backend's client auth. const response = await fetch('https://api.example.com/state'); if (!response.ok) throw new Error('Backend request failed'); const data = await response.json(); const socket = new WebSocket('wss://rooms.example.com/session'); socket.addEventListener('message', event => { const message = JSON.parse(event.data); // Validate your application's message schema before using it. }); ``` For threaded WASM or isolated app frames/assets, provider CORS/COEP/CORP headers must also support browser isolation. A permission grant cannot repair an incompatible provider. Exact HTTPS/WSS origins are required in production; wildcards, paths, embedded credentials, control/runtime origins, and literal private-network endpoints are rejected. Hackemist rooms offer temporary presence/messages and host-controlled shared state. They do not execute authoritative uploaded game rules. Use an external server for secret answers, authoritative competition engines, payments, large persistent economies, cloud files or long-lived worlds that exceed the native service contract. For bounded durable records, resource roles and declared atomic rules, use [native app services](/docs/native-services.md). Use account save checkpoints for lasting per-player progress. ## HTTP parity - `GET /api/projects/PROJECT_ID/runtime-options` reads the same owned-project status as MCP. - `PUT /api/projects/PROJECT_ID/runtime-options` accepts `{base_policy_revision, auto_save?, isolated?, multiplayer?}`. - `POST /api/projects/PROJECT_ID/runtime-connections/request` accepts `{base_policy_revision, connect_origins, reason?}`. The site's mode determines whether the list is saved immediately or queued for review. Include a reason when review is required. These browser routes use the existing signed-in account and CSRF protection. They do not accept bearer credentials or arbitrary profile fields. Extra capabilities continue through `POST /api/projects/PROJECT_ID/runtime-request` and the administrator review queue.