diff --git a/site/public/llms-full.txt b/site/public/llms-full.txt index 11ab7f393b..53f3889029 100644 --- a/site/public/llms-full.txt +++ b/site/public/llms-full.txt @@ -4036,6 +4036,101 @@ The Rivet Rust client provides a way to connect to and interact with actors from _Coming Soon_ For detailed API documentation, please refer to the [RivetKit Rust client implementation](https://github.com/rivet-gg/rivetkit/blob/main/clients/rust). +## Freestyle + +# Freestyle + +Deploy Rivet Actors to [Freestyle.sh](https://freestyle.sh/), a cloud platform for running AI-generated code with built-in security and scalability. + +Freestyle provides built-in security for running untrusted AI-generated code, making it ideal for AI agent applications. Using Rivet, it is easy to deploy your vibe-coded or user-provided RivetKit backends straight to Freestyle. + +Complete example of deploying Rivet actors to Freestyle.sh. + +## Setup + +Install RivetKit and create your registry: + +```bash +npm install rivetkit +``` + +Update your server code to use the serverless engine driver: + +```typescript } +registry.startServerless(, +}); + +// Freestyle uses Deno under the hood for web deployments +// @ts-ignore +Deno.serve(app.fetch); +``` + +**Configuration Requirements:** + +- `endpoint` - Rivet API endpoint (use "api.rivet.gg" for Rivet Cloud) +- `namespace` - Your Rivet namespace for actor isolation +- `inspector.enabled` - Enable debugging and monitoring + +Deploy your application to Freestyle with the correct configuration. Create a deployment script or add this to your existing deployment process: + +```typescript +const FREESTYLE_DOMAIN = "my-domain.style.dev"; // Change to your desired Freestyle domain + +const res = await freestyle.deployWeb(buildDir, `, + RIVET_RUNNER_KIND: "serverless", + // For self-hosted instances: + // RIVET_ENDPOINT: "http://127.0.0.1:6420", + RIVET_ENDPOINT: "api.rivet.gg", + }, + timeout: 60 * 5, // Increases max request lifetime on the runner + entrypoint: "server.ts", // File which starts serverless runner + domains: [FREESTYLE_DOMAIN], + build: false, +}); +``` + +Details on `buildDir` and other settings are available on [Freestyle docs](https://docs.freestyle.sh/web/web). + +Run this deployment script to push your application to Freestyle. + +**Deployment Configuration:** + +- `timeout: 60 * 5` - Set timeout to 5 minutes for actor operations - it's important to keep this high! +- `entrypoint: "server.ts"` - Entry point file with your serverless setup +- `domains` - Your Freestyle domain(s) +- `build: false` - Disable build if you're pre-building your assets + +Update the runner configuration on the Rivet side to connect with your Freestyle deployment. Create a configuration script and run it after your Freestyle deployment is live: + +```typescript +const rivet = new RivetClient(); + +const FREESTYLE_DOMAIN = "my-domain.style.dev"; // Change to your desired Freestyle domain +const RIVET_NAMESPACE = "my-rivet-namespace"; // Change to your Rivet namespace + +await rivet.runnerConfigs.upsert("freestyle-runner", /start`, + runnersMargin: 1, + minRunners: 1, + maxRunners: 1, + slotsPerRunner: 1, + // Must be shorter than Freestyle request `timeout` config + requestLifespan: 60 * 5 - 5, + }, + namespace: RIVET_NAMESPACE, +}); +``` + +Execute this configuration script to register your Freestyle deployment with Rivet. + +**Runner Configuration:** + +- `url` - Freestyle deployment URL with `/start` endpoint +- `runnersMargin` - Buffer of runners to maintain +- `minRunners/maxRunners` - Scaling limits +- `slotsPerRunner` - Concurrent actors per runner +- `requestLifespan` - Request timeout (slightly less than Freestyle timeout) + +Once this configuration script is run, Rivet will be connect with your Freestyle serverless instance and you will be done! ## Build Your Own # Build Your Own diff --git a/site/public/llms.txt b/site/public/llms.txt index 216778ac87..5f0c8d4b3a 100644 --- a/site/public/llms.txt +++ b/site/public/llms.txt @@ -76,6 +76,7 @@ https://rivet.gg/docs/clients/next-js https://rivet.gg/docs/clients/openapi https://rivet.gg/docs/clients/react https://rivet.gg/docs/clients/rust +https://rivet.gg/docs/deploy/freestyle https://rivet.gg/docs/drivers/build-your-own https://rivet.gg/docs/drivers/file-system https://rivet.gg/docs/drivers/memory diff --git a/site/src/content/docs/deploy/freestyle.mdx b/site/src/content/docs/deploy/freestyle.mdx new file mode 100644 index 0000000000..79d38da27f --- /dev/null +++ b/site/src/content/docs/deploy/freestyle.mdx @@ -0,0 +1,136 @@ +# Freestyle + +Deploy Rivet Actors to [Freestyle.sh](https://freestyle.sh/), a cloud platform for running AI-generated code with built-in security and scalability. + +Freestyle provides built-in security for running untrusted AI-generated code, making it ideal for AI agent applications. Using Rivet, it is easy to deploy your vibe-coded or user-provided RivetKit backends straight to Freestyle. + + + +Complete example of deploying Rivet actors to Freestyle.sh. + + + +## Setup + + + + +Install RivetKit + Hono and create your registry: + +```bash +npm install rivetkit hono +``` + + + + + +Update your server code to run the registry through Deno. + +```typescript {{"title":"server.ts"}} +import { registry } from "./registry"; +import { createEngineDriver } from "npm:rivetkit/engine"; +import { upgradeWebSocket } from "hono/deno"; + +const { fetch } = registry.start({ + // Lets us serve the registry via our Deno.serve + // as supported by Freestyle. + disableDefaultServer: true, + getUpgradeWebSocket: () => upgradeWebSocket, + + // Provide RivetKit address of our server + overrideServerAddress: `${process.env.FREESTYLE_ENDPOINT ?? "http://localhost:8080"}/api`, +}); + +// Freestyle uses Deno under the hood for web deployments +// @ts-ignore +Deno.serve(fetch); +``` + +**Configuration Requirements:** + +- `endpoint` - Rivet API endpoint (use "api.rivet.gg" for Rivet Cloud) +- `namespace` - Your Rivet namespace for actor isolation +- `inspector.enabled` - Enable debugging and monitoring + + + + + +Deploy your application to Freestyle with the correct configuration. Create a deployment script or add this to your existing deployment process: + +```typescript +const FREESTYLE_DOMAIN = "my-domain.style.dev"; // Change to your desired Freestyle domain + +const res = await freestyle.deployWeb(buildDir, { + envVars: { + FREESTYLE_ENDPOINT: `https://${FREESTYLE_DOMAIN}`, + RIVET_RUNNER_KIND: "serverless", + // For self-hosted instances: + // RIVET_ENDPOINT: "http://127.0.0.1:6420", + RIVET_ENDPOINT: "api.rivet.gg", + }, + timeout: 60 * 5, // Increases max request lifetime on the runner + entrypoint: "server.ts", // File which starts serverless runner + domains: [FREESTYLE_DOMAIN], + build: false, +}); +``` + +Details on `buildDir` and other settings are available on [Freestyle docs](https://docs.freestyle.sh/web/web). + +Run this deployment script to push your application to Freestyle. + +**Deployment Configuration:** + +- `timeout: 60 * 5` - Set timeout to 5 minutes for actor operations - it's important to keep this high! +- `entrypoint: "server.ts"` - Entry point file with your serverless setup +- `domains` - Your Freestyle domain(s) +- `build: false` - Disable build if you're pre-building your assets + + + + + +Update the runner configuration on the Rivet side to connect with your Freestyle deployment. Create a configuration script and run it after your Freestyle deployment is live: + +```typescript +import { RivetClient } from "rivetkit/client"; + +const rivet = new RivetClient({ + endpoint: "api.rivet.gg", + token: process.env.RIVET_API_TOKEN, +}); + +const FREESTYLE_DOMAIN = "my-domain.style.dev"; // Change to your desired Freestyle domain +const RIVET_NAMESPACE = "my-rivet-namespace"; // Change to your Rivet namespace + +await rivet.runnerConfigs.upsert("freestyle-runner", { + serverless: { + url: `https://${FREESTYLE_DOMAIN}/start`, + runnersMargin: 1, + minRunners: 1, + maxRunners: 1, + slotsPerRunner: 1, + // Must be shorter than Freestyle request `timeout` config + requestLifespan: 60 * 5 - 5, + }, + namespace: RIVET_NAMESPACE, +}); +``` + +Execute this configuration script to register your Freestyle deployment with Rivet. + +**Runner Configuration:** + +- `url` - Freestyle deployment URL with `/start` endpoint +- `runnersMargin` - Buffer of runners to maintain +- `minRunners/maxRunners` - Scaling limits +- `slotsPerRunner` - Concurrent actors per runner +- `requestLifespan` - Request timeout (slightly less than Freestyle timeout) + +Once executed, Rivet will be connected to your Freestyle serverless instance. + + + + diff --git a/site/src/sitemap/mod.ts b/site/src/sitemap/mod.ts index 9dd1ec715e..8a5706f464 100644 --- a/site/src/sitemap/mod.ts +++ b/site/src/sitemap/mod.ts @@ -315,6 +315,17 @@ export const sitemap = [ }, ], }, + { + title: "Deploy", + icon: faSitemap, + collapsible: true, + pages: [ + { + title: "Freestyle", + href: "/docs/deploy/freestyle", + }, + ], + }, { title: "Auth", icon: faKey, diff --git a/site/tailwind.config.ts b/site/tailwind.config.ts index 75046683c0..1b738cf594 100644 --- a/site/tailwind.config.ts +++ b/site/tailwind.config.ts @@ -5,7 +5,7 @@ import type { Config } from "tailwindcss/types/config"; const config = { content: [ "./src/**/*.{ts,tsx,jsx,js,mdx,md}", - "../node_modules/@rivet-gg/components/**/*.{ts,tsx}", + "../node_modules/@rivet-gg/components/src/**/*.{ts,tsx}", ], theme: { extend: {