* feat(cloud): add Streamable HTTP MCP install guide, stateless onboarding API, and OpenMotion OAuth consent UI * fix(release): point legacy npm install-guide contract check at archived template * fix(cloud,onboarding,oauth): address PR #984 review feedback - Add DSH-compatible dshCardPresentation payload matching detailsSchema (id, title, description, video previewUrl, posterUrl, duration) and update docs/install.md + Zod schema regression coverage - Refactor OAuth 2.1 consent HTML to consume /design-system/ui.css, data-motion-ui, semantic --motion-* tokens, and shared .ui-* controls with zero local palette overrides or color literals - Extract shared inline-onboarding document renderer into shared/inline-onboarding-renderer.ts preserving the native_required external-media guard across CLI and cloud paths - Cache encoded onboarding preview media once per resourceVersion and replace entry-count HTML caching with a 16 MiB byte-bounded LRU cache - Restore local/DSH onboarding default (docs/templates/legacy-npm-install.md) in scripts/install-onboarding.mjs and repair moved relative links - Align canonical repository docs (AGENTS.md, CLAUDE.md, READMEs, release/adapter/skill docs) and fix .codex-plugin/onboarding anchor * test(onboarding,dsh): keep controls and DSH card tests independent of Studio build output * docs(onboarding): repoint legacy local/npm references and anchors to archived guide --------- Co-authored-by: 罗高 <luogao@users.noreply.github.com>
OpenMotion Cloud & Container Deployment
OpenMotion runs as a container-first, stateless cloud stack backed by PostgreSQL 17, Redis 7 (noeviction for BullMQ), and S3-compatible object storage (RustFS locally, S3/R2 in cloud).
Container Architecture
A single multi-target Dockerfile (node:26.11.1-bookworm-slim, matching CI) produces four role-specific images from a shared build cache:
| Target | Contents | Responsibility |
|---|---|---|
api |
Node.js + Studio SPA + /app/fonts/ (no Chromium, no FFmpeg) |
Stateless HTTP/SSE Studio server, Motion API, and Streamable HTTP /mcp endpoint (read_only rootfs). |
worker-media |
Node.js + ffmpeg / ffprobe (no Chromium) |
BullMQ media-ingest, media-generate, and two-phase blob-gc worker (WORKER_ROLE=media). |
worker-render |
Node.js + chromium + ffmpeg + Noto fonts + /app/fonts/ |
Isolated BullMQ render-export worker (WORKER_ROLE=render) with ephemeral /tmp hydration and strict env stripping. |
catalog-sync |
Node.js + template-library/ + library/templates/catalog/ |
One-shot Job syncing built-in and repository templates into S3 CAS (catalog/blobs/{sha256}) and PostgreSQL. |
Both api and worker-render bake the exact same /app/fonts/ catalog (bundled Studio/template fonts and Noto Core/CJK/Color Emoji) so preview typography matches headless Chromium exports without placing browser or media binaries on api.
Local Docker Compose Quick Start (AUTH_MODE=dev)
Prerequisites
- Docker Engine + Docker Compose v2+.
- Memory recommendation (Colima / Docker Desktop): Allocate at least 8 GiB RAM to your Linux VM for smooth 1080p Chromium + FFmpeg exports (e.g.,
colima start --cpu 4 --memory 8). On smaller 3.8 GiB Colima dev VMs, the default Compose limits (RENDER_SHM_SIZE=512m,RENDER_MEM_LIMIT=2g) remain bootable; raise them toRENDER_SHM_SIZE=1gandRENDER_MEM_LIMIT=4gon>= 8 GiBhosts.
Start the Local Stack
cp deploy/.env.example deploy/.env
docker compose -f deploy/docker-compose.yml up -d --build
Startup runs three one-shot bootstrap services automatically before api starts:
s3-init(scripts/init-s3.ts): Creates theopenmotionbucket in RustFS and applies the canonical S3 CORS policy viaPutBucketCorsCommand(GET,HEAD,PUT+Range/ETag/Content-Rangeheaders) required for direct browser uploads and302presigned media playback.db-migrate(src/db/migrate.ts): Applies Drizzle SQL migrations under a PostgreSQL advisory lock.catalog-sync(scripts/sync-catalog-cas.ts): Ingests template blobs intocatalog/blobs/{sha256}and upsertscatalog_templatesmetadata.
Local Endpoints
| Service | Loopback URL | Notes |
|---|---|---|
| OpenMotion Studio & API | http://127.0.0.1:4173 |
Runs with AUTH_MODE=dev, MODEL_GATEWAY_MODE=mock, and a read-only root filesystem (tmpfs: /tmp:size=64m). |
| Remote MCP (Streamable HTTP) | http://127.0.0.1:4173/mcp |
Authenticate with Authorization: Bearer <DEV_PAT> in local dev mode. |
| RustFS S3 API | http://127.0.0.1:9000 |
Signed into browser presigned URLs via S3_PUBLIC_ENDPOINT. Internal containers talk to http://s3:9000. |
| RustFS Console | http://127.0.0.1:9001 |
Sign in with S3_ACCESS_KEY_ID / S3_SECRET_ACCESS_KEY from deploy/.env. |
| PostgreSQL 17 | 127.0.0.1:5432 |
Database openmotion (credentials in deploy/.env). |
Stop containers while keeping volumes (pg_data, redis_data, s3_data):
docker compose -f deploy/docker-compose.yml down
Remove all local state and volumes:
docker compose -f deploy/docker-compose.yml down -v
Connect an AI Agent (Streamable HTTP MCP)
OpenMotion exposes MCP directly over Streamable HTTP at /mcp without any local stdio process or container-exec wrapper.
Install the OpenMotion product Skill in your host Agent:
npx skills add nexu-io/openmotion --skill openmotion
Point your MCP client at the Streamable HTTP endpoint using the DEV_PAT from deploy/.env (default om_pat_devlocal_000000000000000000000000):
{
"mcpServers": {
"openmotion": {
"type": "http",
"url": "http://127.0.0.1:4173/mcp",
"headers": {
"Authorization": "Bearer om_pat_devlocal_000000000000000000000000"
}
}
}
}
In production (AUTH_MODE=oidc), remote MCP clients authenticate via OAuth 2.1 + PKCE (/.well-known/oauth-protected-resource) or workspace-scoped Personal Access Tokens (PATs) created in Studio.
Key Environment Variables
All runtime variables are validated strictly by src/infra/config.ts:
| Variable | Default (Compose) | Purpose |
|---|---|---|
APP_PUBLIC_ORIGIN |
http://127.0.0.1:4173 |
Canonical external origin for OAuth metadata, MCP URLs, S3 CORS, and CSRF checks. |
PREVIEW_PUBLIC_ORIGIN |
(empty) | Optional cookie-less preview origin (e.g. https://preview.openmotion.example.com). When configured on a distinct host, api isolates preview iframes from session cookies and blocks /motion-api/*, /auth/*, /oauth/*, /mcp, and mutations with 403 PREVIEW_ORIGIN_ISOLATED. Leave empty for single-host local Compose dev. |
PREVIEW_TOKEN_TTL_SEC |
900 |
Lifetime (seconds) of HS256 project-scoped preview tokens minted by POST /api/projects/:id/preview-token. |
AUTH_MODE |
dev |
dev for local Compose; oidc required in production (NODE_ENV=production refuses AUTH_MODE=dev unless ALLOW_INSECURE_DEV_AUTH=true). |
DEV_PAT |
om_pat_devlocal_... |
Synthetic local Bearer token for /mcp when AUTH_MODE=dev. |
MCP_MAX_BODY_BYTES |
10485760 |
10 MiB JSON-RPC body cap for large project edits on /mcp. |
MODEL_GATEWAY_MODE |
mock |
mock returns deterministic media fixtures locally; set opendesign + OPENDESIGN_S2S_API_KEY for live media generation. |
S3_ENDPOINT / S3_PUBLIC_ENDPOINT |
http://s3:9000 / http://127.0.0.1:9000 |
Dual S3 clients: internal container I/O vs browser-reachable presigned URLs. |
S3_PRESIGN_CACHE_WINDOW_SEC |
3600 |
UTC time-window alignment (seconds) for cacheable immutable Presigned GET URLs on content-addressed blobs/proxies/thumbnails. |
BLOB_GC_GRACE_SECONDS |
604800 |
7-day grace period (seconds) before Mark-and-Sweep CAS GC physically deletes verified-unreferenced blobs. |
HISTORY_COALESCE_WINDOW_MS |
4000 |
Edit-window duration (ms) for coalescing rapid interactive Studio edits into the head unpinned version (0 disables coalescing). |
SENTRY_WEB_DSN |
(empty) | Optional Sentry public DSN injected into Studio index.html at runtime by api (via @openmotion/observability). Leave empty to disable web Sentry completely. |
SENTRY_ENVIRONMENT / SENTRY_RELEASE |
NODE_ENV / openmotion@<version> |
Runtime Sentry environment and release labels injected alongside SENTRY_WEB_DSN. |
SENTRY_TRACES_SAMPLE_RATE |
0.1 |
Browser performance tracing sample rate in [0, 1] (0 disables performance traces while keeping error capture). |
RENDER_SHM_SIZE / RENDER_MEM_LIMIT |
512m / 2g |
Chromium /dev/shm and container memory limit on worker-render. Raise to 1g–2g / 4g on >= 8 GiB hosts. |
Web Sentry SourceMaps & Observability Guide
Production images never ship .map files (deploy/Dockerfile strips *.map from prod-base, and api returns 404 for *.map when NODE_ENV=production). To build api with embedded deterministic Debug IDs, export matching hidden .js.map files from the shared BuildKit cache, and upload them externally via sentry-cli:
SHA="$(git rev-parse --short HEAD)"
IMAGE_TAG="openmotion-${SHA}"
SENTRY_RELEASE="openmotion@${SHA}"
docker buildx build -f deploy/Dockerfile --target api --build-arg STUDIO_SOURCEMAP=hidden -t "openmotion-api:${IMAGE_TAG}" .
docker buildx build -f deploy/Dockerfile --target studio-sourcemaps --build-arg STUDIO_SOURCEMAP=hidden --output type=local,dest=./dist/studio-sourcemaps .
sentry-cli sourcemaps upload --org "$SENTRY_ORG" --project "$SENTRY_PROJECT" --release "$SENTRY_RELEASE" --url-prefix "~/editor-assets" ./dist/studio-sourcemaps
rm -rf ./dist/studio-sourcemaps
See the full configuration, privacy, metrics, and troubleshooting guide in docs/sentry-observability.md.
Kubernetes + KEDA Deployment (deploy/k8s/)
Production manifests live under deploy/k8s/ and target Kubernetes with an Ingress controller (such as NGINX) and KEDA v2 installed.
1. Provision Secrets & Config
- Review
deploy/k8s/configmap.yamland updateAPP_PUBLIC_ORIGIN,PREVIEW_PUBLIC_ORIGIN,OIDC_ISSUER(OpenMotion supports both asymmetric JWKS IdPs and HS256 ID tokens issued by OpenDesign / Vela Better Auth withdisableJwtPlugin: true; pair withMCP_OAUTH_MODE=proxy),OIDC_CLIENT_ID,OIDC_CALLBACK_URL,MCP_OAUTH_ISSUER,S3_ENDPOINT,S3_PUBLIC_ENDPOINT, andS3_BUCKETfor your cluster. - Provision both
openmotion-secretsandopenmotion-keda-redis-authin namespaceopenmotionusingdeploy/k8s/secret.example.yamlas a template (via External Secrets Operator, Sealed Secrets, or SOPS — never commit live credentials). - Ensure your S3/R2 bucket has the canonical CORS policy applied for both
APP_PUBLIC_ORIGINandPREVIEW_PUBLIC_ORIGIN(runscripts/init-s3.tswith both origin settings or configure the sameGET/HEAD/PUT+Range/ETag/Content-Rangerules via Terraform). - Update
deploy/k8s/ingress.yamlwith both your main Studio domain (motion.example.com) and dedicated cookie-less preview domain (preview.openmotion.example.com) plus TLS certificate secret, and updatedeploy/k8s/networkpolicy.yamlif PostgreSQL, Redis, or S3 run outside the cluster (pin exact PrivateLink / VPC endpoint CIDRs rather than opening0.0.0.0/0toworker-render).
2. Render & Apply Manifests
Preview the rendered Kustomize output:
kubectl kustomize deploy/k8s
Apply the stack:
kubectl apply -k deploy/k8s
Wait for pre-release schema migration and template catalog sync jobs:
kubectl -n openmotion wait --for=condition=complete job/openmotion-db-migrate --timeout=300s
kubectl -n openmotion wait --for=condition=complete job/openmotion-catalog-sync --timeout=900s
Cloud Motion templates
Configure the API with PRISM_CONTENT_ENV=dev for test and prod for production. Set PRISM_PUBLIC_ORIGIN to the public dev delivery origin in the test environment. Production defaults to the public Prism origin. Disable the repository catalog import job for this mode. Contributor checkouts, hosted npm template catalogs and the main-branch publishing workflow retain their existing source selection.
Every catalog read serves the current in-memory snapshot immediately. A new API instance initially serves only the packaged built-ins. Exact published-template requests return HTTP 503 until this instance has a validated directory. After that, an unknown ID returns HTTP 404. The first catalog read that includes Prism triggers a background load, and later reads see the published entries once the complete directory passes validation. At most once per five minutes of activity, one background request per API process checks the manifest. An unchanged publication keeps the current snapshot. A failed refresh keeps serving it and allows a retry after 30 seconds. Studio requests a page of localized cards. Covers and reference media use the published CDN URLs.
The directory does not use PostgreSQL template rows. The four built-in templates are packaged with the API. On an editable template's first clone, its verified files are copied to content-addressed storage and the usual project/version rows are created. Existing projects keep the files they were created from. To roll back to the database-backed catalog, restore its import job and clear the API's Prism settings.
3. Autoscaling & Graceful Export Drain
api: Managed byHorizontalPodAutoscaler(api-hpa.yaml, 2–20 replicas) andPodDisruptionBudget(minAvailable: 1). Ingress disables proxy buffering (proxy-buffering: "off") with 3600s read/send timeouts for SSE (/api/events,/api/render/:id/progress) and Streamable HTTP/mcp.worker-render: Managed by KEDAScaledObject(worker-render-keda.yaml) targeting BullMQrender-export(minReplicaCount: 1,maxReplicaCount: 30,cooldownPeriod: 300, scale-down stabilization300s), paired withterminationGracePeriodSeconds: 1800so in-flight video renders complete and upload cleanly before pod termination.- Prioritized BullMQ v5 note: Because
QueueService.enqueueRenderExportassigns BullMQ priorities (export_render=1,render_thumbnail=5), waiting jobs enter thebull:render-export:prioritizedZSET before transitioning tobull:render-export:active. KEDA's nativeredisscaler evaluates Redis Lists (wait/active), sominReplicaCountdefaults to1(warm pool) to prevent prioritized jobs from deadlocking at zero replicas; lowerminReplicaCountto0only after pairing with a Prometheus/BullMQ ZSET queue-depth trigger.
- Prioritized BullMQ v5 note: Because
4. Security Hardening Summary
- Cookie-less Preview Subdomain Isolation: Setting
PREVIEW_PUBLIC_ORIGIN(e.g.https://preview.openmotion.example.com) alongside the dedicated Ingress rule isolates rendered project HTML/JS previews onto a separate cookie-less origin. TheapiPreview Host Isolation middleware ignores all session cookies, authenticates preview documents via short-lived project-scoped HS256 preview tokens (POST /api/projects/:id/preview-token) and serves their assets through scoped URLs with the same TTL. Studio renews the asset lease through the main origin. Configure the Ingress access log to redact theptquery value and the credential after/preview/~assets/. The API appliesContent-Security-Policy: frame-ancestors 'self' <APP_PUBLIC_ORIGIN>;,Referrer-Policy: no-referrer, andX-Content-Type-Options: nosniff, and immediately rejects/motion-api/*,/auth/*,/oauth/*,/mcp, and any mutating HTTP method with403 PREVIEW_ORIGIN_ISOLATED. - Pod Security
restricted: All pods run non-root (runAsUser: 1000), dropALLLinux capabilities, enforceseccompProfile: RuntimeDefault, disableautomountServiceAccountToken, and mountreadOnlyRootFilesystem: truewith boundedemptyDirscratch mounts (/tmp, plus memory-backed/dev/shmonworker-render). - Least-Privilege Secret Projection:
worker-renderNEVER receivesOPENDESIGN_*,OIDC_*,SESSION_SECRET, orDEV_PATenvironment variables, and strips all remaining infrastructure credentials (DATABASE_URL,REDIS_URL,S3_*) before spawning Chromium/FFmpeg. - Strict Default-Deny
NetworkPolicy:deploy/k8s/networkpolicy.yamldenies all ingress and egress by default acrossopenmotion.worker-renderpermits egress only to cluster DNS and PostgreSQL, Redis, and S3 endpoints — blocking all public internet egress, cloud metadata (169.254.169.254/32), and the Kubernetes API server.