Skip to content

Commit 3dbda49

Browse files
committed
fix: run dynamic app actors inside AgentOS
1 parent 67dc916 commit 3dbda49

37 files changed

Lines changed: 936 additions & 995 deletions

File tree

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ WORKDIR /app
99

1010
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
1111
COPY packages/dynamic-apps/package.json packages/dynamic-apps/package.json
12+
COPY packages/dynamic-apps-core/package.json packages/dynamic-apps-core/package.json
1213
COPY packages/dynamic-apps-builder/package.json packages/dynamic-apps-builder/package.json
1314
COPY benchmarks/dynamic-apps/package.json benchmarks/dynamic-apps/package.json
1415
COPY examples/apps-ai-builder/package.json examples/apps-ai-builder/package.json

benchmarks/dynamic-apps/package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
"private": true,
55
"type": "module",
66
"scripts": {
7-
"benchmark:local": "node --import tsx src/local.ts --host 0.0.0.0",
8-
"benchmark:cloud-stress": "node --import tsx src/cloud-stress.ts",
9-
"benchmark:stress": "node --expose-gc --import tsx src/runtime-stress.ts",
10-
"benchmark:suite": "node --import tsx src/suite.ts",
11-
"deploy:fixture": "node --import tsx src/deploy-fixture.ts",
12-
"load": "node --import tsx src/load.ts",
13-
"start": "node --import tsx src/server.ts --host 0.0.0.0",
7+
"benchmark:local": "npx tsx src/local.ts --host 0.0.0.0",
8+
"benchmark:cloud-stress": "npx tsx src/cloud-stress.ts",
9+
"benchmark:stress": "npx tsx --expose-gc src/runtime-stress.ts",
10+
"benchmark:suite": "npx tsx src/suite.ts",
11+
"deploy:fixture": "npx tsx src/deploy-fixture.ts",
12+
"load": "npx tsx src/load.ts",
13+
"start": "npx tsx src/server.ts --host 0.0.0.0",
1414
"check-types": "tsc --noEmit",
15-
"test": "node --import tsx --test src/load.test.ts"
15+
"test": "npx tsx --test src/load.test.ts"
1616
},
1717
"dependencies": {
1818
"@hono/node-server": "^2.0.11",

benchmarks/dynamic-apps/src/edge.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,7 @@ export function createBenchmarkApplication(): Hono {
101101
) as unknown as ActorApplicationClient;
102102
return actorApplicationClient;
103103
};
104-
const privateRegistry = (request: Request) => {
105-
const headers = new Headers(request.headers);
106-
headers.set("x-agentos-app-registry-dispatch", "1");
107-
return appsRouter.fetch(new Request(request, { headers }));
108-
};
109-
app.all("/api/rivet/*", (c) => privateRegistry(c.req.raw));
104+
app.all("/api/rivet/*", (c) => appsRouter.fetch(c.req.raw));
110105

111106
app.all("/bench/noop", () => {
112107
const startedAt = performance.now();

docs/content/docs/quickstart-core.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ disposes the instance during shutdown.
5959
Pass the listening host on the command line:
6060

6161
```sh
62-
node --import tsx src/server.ts --host 0.0.0.0
62+
npx tsx src/server.ts --host 0.0.0.0
6363
```
6464

6565
</Step>

docs/content/docs/quickstart.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ served by `appsRouter` through a cached agentOS VM.
3333
Run the server normally:
3434

3535
```sh
36-
node --import tsx src/server.ts
36+
npx tsx src/server.ts
3737
```
3838

3939
</Step>
@@ -46,7 +46,7 @@ agent, an upload endpoint, or another trusted control-plane process.
4646
<CodeSnippet file="examples/apps-hello-world/src/deploy.ts" title="src/deploy.ts" />
4747

4848
```sh
49-
node --import tsx src/deploy.ts
49+
npx tsx src/deploy.ts
5050
```
5151

5252
</Step>

docs/content/docs/reference.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ Give an agent the app requirements, let it generate the project files, and pass
99
those files to `deployApp()`. If the build returns TypeScript diagnostics, give
1010
them back to the agent and deploy its repaired files again.
1111

12+
Import `webServerSkill` and `rivetActorsSkill` from
13+
`@rivet-dev/dynamic-apps` and include them in the model prompt. They describe
14+
the supported TypeScript server layout and Rivet actor integration.
15+
1216
[View the complete AI App Builder example](https://github.com/rivet-dev/dynamic-apps/tree/main/examples/apps-ai-builder).
1317

1418
## Planned Improvements
1519

16-
- Automatically include agent skills based on the
17-
[Actors Learn guides](https://rivet.dev/actors/learn/) for better app generation.
1820
- Billing API for tracking and charging for app usage.
1921
- Built-in error reporting for generated apps.

docs/content/docs/routing.mdx

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,15 @@ skill: true
55
---
66

77
The package root exports one router. Mount ordinary application traffic at any
8-
prefix and explicitly dispatch the private `/api/rivet` callback to the same
9-
router:
8+
prefix and forward the private `/api/rivet/*` callback to the same router:
109

1110
```ts
1211
import { appsRouter } from "@rivet-dev/dynamic-apps";
1312
import { Hono } from "hono";
1413

1514
const server = new Hono();
1615

17-
const dispatchRegistry = (request: Request) => {
18-
const headers = new Headers(request.headers);
19-
headers.set("x-agentos-app-registry-dispatch", "1");
20-
return appsRouter.fetch(new Request(request, { headers }));
21-
};
22-
23-
server.all("/api/rivet", (c) => dispatchRegistry(c.req.raw));
24-
server.all("/api/rivet/*", (c) => dispatchRegistry(c.req.raw));
16+
server.all("/api/rivet/*", (c) => appsRouter.fetch(c.req.raw));
2517
server.route("/apps", appsRouter);
2618
```
2719

@@ -30,7 +22,3 @@ This serves `/:appId/*` relative to the mount. For example,
3022
`/api/items?q=1`. A bare `/apps/example` request redirects to
3123
`/apps/example/`.
3224

33-
There is no `createAppsRouter` or router-specific client option in the default
34-
adapter. `appsRouter` creates and reuses its private control client lazily. Once
35-
an active artifact is prepared, warm requests use only the local runtime and
36-
isolate caches: they do not call release storage or a Rivet actor.

examples/apps-ai-builder/fixtures/app/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@
88
"build": "tsc",
99
"check-types": "tsc --noEmit"
1010
},
11+
"dependencies": {
12+
"@hono/node-server": "2.0.11",
13+
"hono": "4.12.9"
14+
},
1115
"devDependencies": {
16+
"@types/node": "22.19.15",
1217
"typescript": "5.7.3"
1318
}
1419
}
Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1-
export default {
2-
fetch(request: Request) {
3-
return Response.json({
4-
message: "Replace this seed with the generated application.",
5-
path: new URL(request.url).pathname,
6-
});
7-
},
8-
};
1+
import { serve } from "@hono/node-server";
2+
import { Hono } from "hono";
3+
4+
const app = new Hono();
5+
6+
app.get("/", (context) =>
7+
context.json({
8+
message: "Replace this seed with the generated application.",
9+
}),
10+
);
11+
12+
serve({
13+
fetch: app.fetch,
14+
port: Number(process.env.PORT ?? 3000),
15+
});

examples/apps-ai-builder/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"private": true,
55
"type": "module",
66
"scripts": {
7-
"start": "node --import tsx src/server.ts",
7+
"start": "npx tsx src/server.ts",
88
"check-types": "tsc --noEmit"
99
},
1010
"dependencies": {

0 commit comments

Comments
 (0)