| 1 | import * as Cloudflare from "@/Cloudflare"; |
| 2 | import * as pathe from "pathe"; |
| 3 | |
| 4 | /** |
| 5 | * Async (non-Effect) Worker declaring the Workers AI binding via |
| 6 | * `env: { AI: Cloudflare.Workers.AI() }`. `InferEnv` maps the marker to the |
| 7 | * native `Ai` runtime handle, so the handler calls `env.AI.run(...)` |
| 8 | * directly. |
| 9 | */ |
| 10 | export const AiAsyncWorker = Cloudflare.Worker("AiAsyncWorker", { |
| 11 | main: pathe.resolve(import.meta.dirname, "AiAsyncHandler.ts"), |
| 12 | env: { |
| 13 | AI: Cloudflare.Workers.AI(), |
| 14 | }, |
| 15 | }); |
| 16 | |
| 17 | export type AiAsyncWorkerEnv = Cloudflare.InferEnv<typeof AiAsyncWorker>; |