The best way to control Claude Code, Codex and more from any computer or phone

main
md 52 lines 1.4 KB
Rendered Raw
1 # Cloudflare: Flue
2
3 Deploys a [Flue](https://flueframework.com) agent app to Cloudflare Workers
4 with `Cloudflare.Website.Vite`. `vite.config.ts` is Flue's documented
5 Cloudflare setup, unchanged:
6
7 ```ts
8 plugins: [flue(), cloudflare({ config: flueWorkerConfig() })];
9 ```
10
11 Alchemy builds and serves the Worker in place of `@cloudflare/vite-plugin`, so
12 the Worker settings Flue contributes through `flueWorkerConfig()` are declared
13 in `alchemy.run.ts` instead of `wrangler.jsonc`:
14
15 - `main: "virtual:flue/worker"`, Flue's generated Worker entry.
16 - The `nodejs_compat` flag and a compatibility date of 2026-04-01 or later.
17 - One Durable Object per `'use agent'` agent. The `Assistant` agent in
18 `src/agents/assistant.ts` is the class `FlueAssistantAgent`, bound as
19 `FLUE_ASSISTANT_AGENT`.
20 - The Workers AI binding (`AI`), which the agent's `cloudflare/...` model
21 calls go through, so no provider API key is needed.
22
23 `src/app.ts` is the route map: a Hono app with `/api/ping` and the agent
24 mounted at `/agents/assistant`.
25
26 ## Deploy
27
28 ```sh
29 bun run deploy
30 ```
31
32 Talk to the agent with `@flue/sdk`:
33
34 ```ts
35 import { createFlueClient } from "@flue/sdk";
36
37 const client = createFlueClient({ url: `${url}/agents/assistant/demo-1` });
38 const admission = await client.send({ message: { kind: "user", body: "Hello!" } });
39 const { text } = await client.read(admission);
40 ```
41
42 ## Develop
43
44 ```sh
45 bun run dev
46 ```
47
48 ## Destroy
49
50 ```sh
51 bun run destroy
52 ```