# Quickstart

[View the complete Quickstart example on GitHub](https://github.com/rivet-dev/agentos/tree/main/examples/apps-hello-world).

### Install

```sh
npm add @rivet-dev/agentos @rivet-dev/agentos-apps
npm add @hono/node-server hono
npm add --save-dev tsx
npm pkg set type=module
```

### Setup the server

Setup the HTTP server that will serve requests for AI-generated apps. Also set
up the actors that power the deployments.

src/server.ts:

```ts
import { serve } from "@hono/node-server";
import { appsRouter } from "@rivet-dev/agentos-apps";
import { Hono } from "hono";
import { registry } from "./actors.js";

// Start the actor registry before routing applications.
registry.start();

const server = new Hono();

// Mount every deployed application at /apps/:appId.
server.route("/apps", appsRouter);

// Serve the host router over HTTP.
serve({
	fetch: server.fetch,
	port: 3000,
});
```

src/actors.ts:

```ts
import { setup } from "@rivet-dev/agentos";
import { setupApps } from "@rivet-dev/agentos-apps";

const { appsActors } = setupApps();

export const registry = setup({
	use: {
		// These actors manage app deployments and scaling.
		...appsActors,
	},
});
```

Run the server:

```sh
npx tsx src/server.ts
```

### Deploy an AI-generated app

Pass generated files directly to `deployApp()`. This can be called by an agent,
an upload endpoint, or any other part of your system:

src/deploy.ts:

```ts
import { deployApp } from "@rivet-dev/agentos-apps";

// An agent, upload endpoint, or any other part of the system can call
// deployApp() with the files it generated.
await deployApp({
	appId: "hello-world",
	files: {
		"package.json": JSON.stringify({
			name: "hello-world-app",
			version: "0.0.0",
			private: true,
			type: "module",
			main: "src/index.ts",
			dependencies: {
				hono: "^4.12.9",
			},
		}),
		"src/index.ts": `
import { Hono } from "hono";

const app = new Hono();

// Serve the application's frontend.
app.get("/", (c) => c.html("<h1>Hello from agentOS Apps</h1>"));

// Serve a REST API request from the same application.
app.get("/api/hello", (c) => c.json({ message: "Hello from agentOS Apps" }));

export default app;
`,
	},
});
```

```sh
npx tsx src/deploy.ts
```

### Visit the AI-generated app

Open `http://localhost:3000/apps/hello-world/`. Pass this URL to agents,
frontends, or any other part of your system that needs to visit the deployment.

### Deploy
