void 0.1.6 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENT_PROMPT.md +15 -0
- package/README.md +62 -123
- package/dist/auth-BdsJ0Aff.d.mts +43 -0
- package/dist/auth-cmd-Dx8oPKZC.mjs +43 -0
- package/dist/auth-migrations-BAtAck2g.mjs +117 -0
- package/dist/better-auth-shared-C9_GHSkR.d.mts +71 -0
- package/dist/better-auth-shared-CdYmQGry.mjs +163 -0
- package/dist/cache-W82I8ihI.mjs +47 -0
- package/dist/cancel-deploy-BOBTqqh0.mjs +59 -0
- package/dist/cf-access-Dee5cXxL.mjs +22 -0
- package/dist/chunk-DJd-R1mw.mjs +34 -0
- package/dist/cli/cli.d.mts +1 -0
- package/dist/cli/cli.mjs +1807 -0
- package/dist/client-snXOjrp1.mjs +565 -0
- package/dist/collect-CjeZgz5D.mjs +55 -0
- package/dist/config-BIa9HwVX.mjs +573 -0
- package/dist/config-BzM9Dy7T.mjs +37 -0
- package/dist/config-CvHtTM0q.mjs +30 -0
- package/dist/create-project-BIA15W7z.mjs +90 -0
- package/dist/db-DsRoMcfN.mjs +895 -0
- package/dist/defer-DcxEsVH1.mjs +49 -0
- package/dist/delete-DAP6yDc7.mjs +64 -0
- package/dist/deploy-BPKblFx6.mjs +2424 -0
- package/dist/discover-B7FkXBLB.mjs +40 -0
- package/dist/dist-DUyXJLkq.mjs +2667 -0
- package/dist/dist-Dayj3gCK.mjs +1287 -0
- package/dist/domain-BGofcQ6I.mjs +79 -0
- package/dist/dotenv-DwO4ti0Z.mjs +173 -0
- package/dist/drizzle-NnudE_UN.mjs +232 -0
- package/dist/env-CyG3tvU0.mjs +301 -0
- package/dist/env-helpers-Dr9Y7RnE.d.mts +52 -0
- package/dist/env-raw-BDL4TvdN.mjs +32 -0
- package/dist/env-types-DknSA4SO.mjs +64 -0
- package/dist/env-validation-DJKjR_8q.mjs +163 -0
- package/dist/fetch-error-BQ8sZ5Nd.mjs +266 -0
- package/dist/fetch-error-CVZ5CGA-.d.mts +20 -0
- package/dist/gen-U0Ktr4Zd.mjs +761 -0
- package/dist/handler-B0ds0OHJ.d.mts +269 -0
- package/dist/head-P-egrtFE.d.mts +45 -0
- package/dist/headers-DCXc7mDs.mjs +279 -0
- package/dist/index.d.mts +32 -0
- package/dist/index.mjs +4695 -0
- package/dist/init-C7wS5iGP.mjs +2625 -0
- package/dist/link-p2R6NbgN.mjs +49 -0
- package/dist/list-Bfel-QLc.mjs +113 -0
- package/dist/log-DXdqnmhF.mjs +26 -0
- package/dist/login-CkcXUiIu.mjs +72 -0
- package/dist/logs-DmkrRvx6.mjs +98 -0
- package/dist/magic-string.es-D6g9UnIy.mjs +1011 -0
- package/dist/mcp-CaQzfeUi.mjs +373 -0
- package/dist/node-DDfXj10V.mjs +54 -0
- package/dist/output-BwlcIYSR.mjs +139 -0
- package/dist/pages/client.d.mts +198 -0
- package/dist/pages/client.mjs +980 -0
- package/dist/pages/head-client.d.mts +15 -0
- package/dist/pages/head-client.mjs +90 -0
- package/dist/pages/head.d.mts +2 -0
- package/dist/pages/head.mjs +112 -0
- package/dist/pages/index.d.mts +38 -0
- package/dist/pages/index.mjs +76 -0
- package/dist/pages/islands-plugin.d.mts +50 -0
- package/dist/pages/islands-plugin.mjs +195 -0
- package/dist/pages/prefetch.d.mts +31 -0
- package/dist/pages/prefetch.mjs +90 -0
- package/dist/pages/protocol.d.mts +3 -0
- package/dist/pages/protocol.mjs +193 -0
- package/dist/pages/serialize.d.mts +10 -0
- package/dist/pages/serialize.mjs +14 -0
- package/dist/pathe.M-eThtNZ-D-kmWkCS.mjs +150 -0
- package/dist/plugin-inference-oZ6Ybu2_.mjs +2447 -0
- package/dist/prepare-BAtWufvm.mjs +99 -0
- package/dist/preset-D4I73kT4.mjs +221 -0
- package/dist/project-TqORyHn8.mjs +72 -0
- package/dist/project-cmd-B7lQp3F3.mjs +67 -0
- package/dist/project-slug-CKam8lF9.mjs +11 -0
- package/dist/project-tsconfig-DfkESbDL.mjs +63 -0
- package/dist/protocol-BWzXs2A2.d.mts +34 -0
- package/dist/providers-B3aMxWzP.mjs +67 -0
- package/dist/resolve-project-Br5BR03U.mjs +29 -0
- package/dist/rollback-gyC59l7U.mjs +92 -0
- package/dist/route-types-DReF1gUY.mjs +255 -0
- package/dist/routes-stub.d.mts +55 -0
- package/dist/routes-stub.mjs +1 -0
- package/dist/runner-6Ep3fNQu.mjs +123 -0
- package/dist/runner-pg-D0wWHYnr.mjs +57 -0
- package/dist/runtime/ai.d.mts +127 -0
- package/dist/runtime/ai.mjs +348 -0
- package/dist/runtime/auth-client-react.d.mts +8 -0
- package/dist/runtime/auth-client-react.mjs +6 -0
- package/dist/runtime/auth-client-solid.d.mts +8 -0
- package/dist/runtime/auth-client-solid.mjs +6 -0
- package/dist/runtime/auth-client-svelte.d.mts +8 -0
- package/dist/runtime/auth-client-svelte.mjs +6 -0
- package/dist/runtime/auth-client-vue.d.mts +8 -0
- package/dist/runtime/auth-client-vue.mjs +6 -0
- package/dist/runtime/auth-client.d.mts +8 -0
- package/dist/runtime/auth-client.mjs +6 -0
- package/dist/runtime/auth.d.mts +2 -0
- package/dist/runtime/auth.mjs +22 -0
- package/dist/runtime/better-auth-pg.d.mts +11 -0
- package/dist/runtime/better-auth-pg.mjs +51 -0
- package/dist/runtime/better-auth.d.mts +11 -0
- package/dist/runtime/better-auth.mjs +33 -0
- package/dist/runtime/client.d.mts +6 -0
- package/dist/runtime/client.mjs +5 -0
- package/dist/runtime/db-pg.d.mts +2 -0
- package/dist/runtime/db-pg.mjs +1 -0
- package/dist/runtime/db.d.mts +17 -0
- package/dist/runtime/db.mjs +30 -0
- package/dist/runtime/drizzle-arktype.d.mts +1 -0
- package/dist/runtime/drizzle-arktype.mjs +2 -0
- package/dist/runtime/drizzle-valibot.d.mts +1 -0
- package/dist/runtime/drizzle-valibot.mjs +2 -0
- package/dist/runtime/drizzle-zod.d.mts +1 -0
- package/dist/runtime/drizzle-zod.mjs +2 -0
- package/dist/runtime/env-helpers.d.mts +2 -0
- package/dist/runtime/env-helpers.mjs +173 -0
- package/dist/runtime/env-public-client.d.mts +22 -0
- package/dist/runtime/env-public-client.mjs +54 -0
- package/dist/runtime/env-public.d.mts +143 -0
- package/dist/runtime/env-public.mjs +366 -0
- package/dist/runtime/env.d.mts +13 -0
- package/dist/runtime/env.mjs +51 -0
- package/dist/runtime/fetch-stream.d.mts +51 -0
- package/dist/runtime/fetch-stream.mjs +81 -0
- package/dist/runtime/fetch.d.mts +59 -0
- package/dist/runtime/fetch.mjs +18 -0
- package/dist/runtime/handler.d.mts +3 -0
- package/dist/runtime/handler.mjs +85 -0
- package/dist/runtime/isr.d.mts +26 -0
- package/dist/runtime/isr.mjs +43 -0
- package/dist/runtime/kv.d.mts +48 -0
- package/dist/runtime/kv.mjs +106 -0
- package/dist/runtime/log.d.mts +24 -0
- package/dist/runtime/log.mjs +31 -0
- package/dist/runtime/migration-handler-pg.d.mts +6 -0
- package/dist/runtime/migration-handler-pg.mjs +85 -0
- package/dist/runtime/migration-handler.d.mts +19 -0
- package/dist/runtime/migration-handler.mjs +92 -0
- package/dist/runtime/queues.d.mts +7 -0
- package/dist/runtime/queues.mjs +8 -0
- package/dist/runtime/remote/binding-handler.d.mts +15 -0
- package/dist/runtime/remote/binding-handler.mjs +208 -0
- package/dist/runtime/remote/index.d.mts +8 -0
- package/dist/runtime/remote/index.mjs +461 -0
- package/dist/runtime/response.d.mts +14 -0
- package/dist/runtime/response.mjs +30 -0
- package/dist/runtime/sandbox.d.mts +17 -0
- package/dist/runtime/sandbox.mjs +19 -0
- package/dist/runtime/schema-d1.d.mts +1 -0
- package/dist/runtime/schema-d1.mjs +2 -0
- package/dist/runtime/schema-pg.d.mts +1 -0
- package/dist/runtime/schema-pg.mjs +2 -0
- package/dist/runtime/seed.d.mts +30 -0
- package/dist/runtime/seed.mjs +6 -0
- package/dist/runtime/storage.d.mts +7 -0
- package/dist/runtime/storage.mjs +14 -0
- package/dist/runtime/validator.d.mts +2 -0
- package/dist/runtime/validator.mjs +72 -0
- package/dist/runtime/ws-server.d.mts +26 -0
- package/dist/runtime/ws-server.mjs +296 -0
- package/dist/runtime/ws.d.mts +123 -0
- package/dist/runtime/ws.mjs +103 -0
- package/dist/scan-Ba4hFwlH.mjs +324 -0
- package/dist/scan-C6HMEIdW.mjs +318 -0
- package/dist/secret-CeRSukgM.mjs +109 -0
- package/dist/skills-ipldjlKE.mjs +62 -0
- package/dist/standard-schema-9CRjx-uR.d.mts +42 -0
- package/dist/subcommand-prompt-BKjuNAPb.mjs +349 -0
- package/dist/sveltekit.d.mts +20 -0
- package/dist/sveltekit.mjs +61 -0
- package/dist/types-mHOEwpW4.d.mts +57 -0
- package/dist/validate-CaMavMxu.mjs +146 -0
- package/dist/yarn-pnp-BFqMV_bl.mjs +196 -0
- package/getting-started-prompt.txt +26 -0
- package/package.json +322 -30
- package/schema.json +364 -0
- package/skills/migrate-vite-cloudflare-to-void/SKILL.md +175 -0
- package/skills/void/SKILL.md +75 -0
- package/skills/void/command/void.md +7 -0
- package/skills/void/docs/guide/ai.md +235 -0
- package/skills/void/docs/guide/app-types.md +103 -0
- package/skills/void/docs/guide/auth.md +257 -0
- package/skills/void/docs/guide/database/d1.md +106 -0
- package/skills/void/docs/guide/database/postgresql.md +106 -0
- package/skills/void/docs/guide/database.md +418 -0
- package/skills/void/docs/guide/deployment.md +98 -0
- package/skills/void/docs/guide/edge/headers.md +79 -0
- package/skills/void/docs/guide/edge/prerendering.md +83 -0
- package/skills/void/docs/guide/edge/redirects.md +116 -0
- package/skills/void/docs/guide/edge/revalidation.md +131 -0
- package/skills/void/docs/guide/edge/rewrites.md +354 -0
- package/skills/void/docs/guide/edge/static-assets.md +72 -0
- package/skills/void/docs/guide/env-vars.md +298 -0
- package/skills/void/docs/guide/index.md +80 -0
- package/skills/void/docs/guide/jobs.md +91 -0
- package/skills/void/docs/guide/kv.md +107 -0
- package/skills/void/docs/guide/pages-routing/actions-and-forms.md +419 -0
- package/skills/void/docs/guide/pages-routing/head.md +130 -0
- package/skills/void/docs/guide/pages-routing/islands.md +405 -0
- package/skills/void/docs/guide/pages-routing/layouts.md +362 -0
- package/skills/void/docs/guide/pages-routing/loaders.md +267 -0
- package/skills/void/docs/guide/pages-routing/markdown.md +625 -0
- package/skills/void/docs/guide/pages-routing/overview.md +236 -0
- package/skills/void/docs/guide/pages-routing/view-transitions.md +140 -0
- package/skills/void/docs/guide/queues.md +140 -0
- package/skills/void/docs/guide/quickstart.md +233 -0
- package/skills/void/docs/guide/remote-dev.md +67 -0
- package/skills/void/docs/guide/sandboxes.md +82 -0
- package/skills/void/docs/guide/server-routing.md +246 -0
- package/skills/void/docs/guide/ssg.md +74 -0
- package/skills/void/docs/guide/ssr.md +105 -0
- package/skills/void/docs/guide/storage.md +67 -0
- package/skills/void/docs/guide/type-safety.md +179 -0
- package/skills/void/docs/guide/typed-fetch.md +113 -0
- package/skills/void/docs/guide/websockets.md +190 -0
- package/skills/void/docs/index.md +48 -0
- package/skills/void/docs/integrations/agents.md +84 -0
- package/skills/void/docs/integrations/cloudflare.md +284 -0
- package/skills/void/docs/integrations/frameworks/analog.md +182 -0
- package/skills/void/docs/integrations/frameworks/astro.md +197 -0
- package/skills/void/docs/integrations/frameworks/nuxt.md +164 -0
- package/skills/void/docs/integrations/frameworks/overview.md +136 -0
- package/skills/void/docs/integrations/frameworks/react-router.md +137 -0
- package/skills/void/docs/integrations/frameworks/sveltekit.md +191 -0
- package/skills/void/docs/integrations/frameworks/tanstack-start.md +140 -0
- package/skills/void/docs/integrations/hono.md +97 -0
- package/skills/void/docs/integrations/nodejs-bun-deno.md +210 -0
- package/skills/void/docs/node_modules/@iconify/vue/README.md +408 -0
- package/skills/void/docs/node_modules/@iconify/vue/offline/readme.md +5 -0
- package/skills/void/docs/node_modules/@voidzero-dev/vitepress-theme/README.md +103 -0
- package/skills/void/docs/node_modules/oxc-minify/README.md +78 -0
- package/skills/void/docs/node_modules/reka-ui/README.md +80 -0
- package/skills/void/docs/node_modules/vitepress/README.md +28 -0
- package/skills/void/docs/node_modules/vitepress/template/api-examples.md +49 -0
- package/skills/void/docs/node_modules/vitepress/template/index.md +28 -0
- package/skills/void/docs/node_modules/vitepress/template/markdown-examples.md +85 -0
- package/skills/void/docs/node_modules/vitepress-plugin-group-icons/README.md +101 -0
- package/skills/void/docs/node_modules/void/AGENTS.md +204 -0
- package/skills/void/docs/node_modules/void/AGENT_PROMPT.md +15 -0
- package/skills/void/docs/node_modules/void/README.md +89 -0
- package/skills/void/docs/node_modules/void/node_modules/@clack/prompts/CHANGELOG.md +591 -0
- package/skills/void/docs/node_modules/void/node_modules/@clack/prompts/README.md +375 -0
- package/skills/void/docs/node_modules/void/node_modules/@cloudflare/sandbox/README.md +174 -0
- package/skills/void/docs/node_modules/void/node_modules/@cloudflare/vite-plugin/README.md +37 -0
- package/skills/void/docs/node_modules/void/node_modules/@cloudflare/workers-types/README.md +135 -0
- package/skills/void/docs/node_modules/void/node_modules/@electric-sql/pglite/README.md +189 -0
- package/skills/void/docs/node_modules/void/node_modules/@hono/oauth-providers/CHANGELOG.md +143 -0
- package/skills/void/docs/node_modules/void/node_modules/@hono/oauth-providers/README.md +1272 -0
- package/skills/void/docs/node_modules/void/node_modules/@napi-rs/keyring/README.md +19 -0
- package/skills/void/docs/node_modules/void/node_modules/@types/better-sqlite3/README.md +15 -0
- package/skills/void/docs/node_modules/void/node_modules/@types/node/README.md +15 -0
- package/skills/void/docs/node_modules/void/node_modules/@types/pg/README.md +15 -0
- package/skills/void/docs/node_modules/void/node_modules/@typescript/native-preview/README.md +22 -0
- package/skills/void/docs/node_modules/void/node_modules/@typescript/native-preview/vendor/vscode-jsonrpc/README.md +69 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/README.md +152 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/@shikijs/engine-javascript/README.md +9 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/@shikijs/transformers/README.md +9 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/@types/node/README.md +15 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/gray-matter/CHANGELOG.md +24 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/gray-matter/README.md +565 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/markdown-exit/README.md +124 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/markdown-it-anchor/README.md +600 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/markdown-it-attrs/README.md +386 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/markdown-it-container/README.md +95 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/markdown-it-emoji/README.md +101 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/pathe/README.md +73 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/shiki/README.md +15 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/tinyglobby/README.md +25 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/tsdown/README.md +55 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite/LICENSE.md +2230 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite/README.md +20 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vue/README.md +58 -0
- package/skills/void/docs/node_modules/void/node_modules/arktype/README.md +165 -0
- package/skills/void/docs/node_modules/void/node_modules/better-auth/LICENSE.md +20 -0
- package/skills/void/docs/node_modules/void/node_modules/better-auth/README.md +32 -0
- package/skills/void/docs/node_modules/void/node_modules/better-sqlite3/README.md +99 -0
- package/skills/void/docs/node_modules/void/node_modules/blake3-jit/README.md +108 -0
- package/skills/void/docs/node_modules/void/node_modules/drizzle-arktype/README.md +51 -0
- package/skills/void/docs/node_modules/void/node_modules/drizzle-kit/README.md +79 -0
- package/skills/void/docs/node_modules/void/node_modules/drizzle-orm/README.md +44 -0
- package/skills/void/docs/node_modules/void/node_modules/drizzle-valibot/README.md +51 -0
- package/skills/void/docs/node_modules/void/node_modules/drizzle-zod/README.md +65 -0
- package/skills/void/docs/node_modules/void/node_modules/es-module-lexer/README.md +390 -0
- package/skills/void/docs/node_modules/void/node_modules/estree-walker/README.md +48 -0
- package/skills/void/docs/node_modules/void/node_modules/hono/README.md +85 -0
- package/skills/void/docs/node_modules/void/node_modules/ignore/README.md +452 -0
- package/skills/void/docs/node_modules/void/node_modules/jsonc-parser/CHANGELOG.md +76 -0
- package/{LICENSE → skills/void/docs/node_modules/void/node_modules/jsonc-parser/LICENSE.md} +21 -21
- package/skills/void/docs/node_modules/void/node_modules/jsonc-parser/README.md +364 -0
- package/skills/void/docs/node_modules/void/node_modules/jsonc-parser/SECURITY.md +41 -0
- package/skills/void/docs/node_modules/void/node_modules/magic-string/README.md +325 -0
- package/skills/void/docs/node_modules/void/node_modules/ofetch/README.md +398 -0
- package/skills/void/docs/node_modules/void/node_modules/pathe/README.md +73 -0
- package/skills/void/docs/node_modules/void/node_modules/pg/README.md +95 -0
- package/skills/void/docs/node_modules/void/node_modules/pglite-server/LICENSE.md +21 -0
- package/skills/void/docs/node_modules/void/node_modules/pglite-server/README.md +135 -0
- package/skills/void/docs/node_modules/void/node_modules/picocolors/README.md +21 -0
- package/skills/void/docs/node_modules/void/node_modules/tinyglobby/README.md +25 -0
- package/skills/void/docs/node_modules/void/node_modules/tsdown/README.md +55 -0
- package/skills/void/docs/node_modules/void/node_modules/valibot/LICENSE.md +9 -0
- package/skills/void/docs/node_modules/void/node_modules/valibot/README.md +94 -0
- package/skills/void/docs/node_modules/void/node_modules/vite/LICENSE.md +2230 -0
- package/skills/void/docs/node_modules/void/node_modules/vite/README.md +20 -0
- package/skills/void/docs/node_modules/void/node_modules/wrangler/README.md +63 -0
- package/skills/void/docs/node_modules/void/node_modules/zod/README.md +191 -0
- package/skills/void/docs/node_modules/void/skills/migrate-vite-cloudflare-to-void/SKILL.md +175 -0
- package/skills/void/docs/node_modules/void/skills/void/SKILL.md +75 -0
- package/skills/void/docs/node_modules/void/skills/void/command/void.md +7 -0
- package/skills/void/docs/reference/api.md +917 -0
- package/skills/void/docs/reference/cli.md +561 -0
- package/skills/void/docs/reference/config.md +408 -0
- package/skills/void/docs/reference/resource-inference.md +149 -0
- package/skills/void/docs/reference/structure.md +176 -0
- package/.npmignore +0 -29
- package/.travis.yml +0 -9
- package/favicon.ico +0 -0
- package/index.js +0 -14
- package/lib/Job.js +0 -150
- package/lib/Void.js +0 -99
- package/lib/scan.js +0 -19
- package/test/credentials.js +0 -20
- package/test/job.js +0 -64
- package/test/static/dir1/test6.html +0 -0
- package/test/static/dir2/test7.html +0 -0
- package/test/static/dir2/test8.html +0 -0
- package/test/static/dir2/test9.html +0 -0
- package/test/static/test1.html +0 -0
- package/test/static/test2.html +0 -0
- package/test/static/test3.html +0 -0
- package/test/void.js +0 -31
- /package/{test/static/dir1/test4.html → skills/void/docs/integrations/auth-providers.md} +0 -0
- /package/{test/static/dir1/test5.html → skills/void/docs/integrations/payment-processors.md} +0 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
//#region src/runtime/ai-types.d.ts
|
|
2
|
+
type ThirdPartyProvider = "openai" | "anthropic" | "google-ai-studio" | "groq" | "mistral" | "grok" | "deepseek" | "openrouter" | "perplexity" | "cohere" | "cerebras" | "huggingface" | "replicate" | "baseten" | "cartesia" | "deepgram" | "elevenlabs" | "fal" | "ideogram" | "parallel";
|
|
3
|
+
type ThirdPartyModel = `${ThirdPartyProvider}/${string}`;
|
|
4
|
+
type ChatContent = string | Array<{
|
|
5
|
+
type: "text";
|
|
6
|
+
text: string;
|
|
7
|
+
} | {
|
|
8
|
+
type: "image_url";
|
|
9
|
+
image_url: {
|
|
10
|
+
url: string;
|
|
11
|
+
detail?: "auto" | "low" | "high";
|
|
12
|
+
};
|
|
13
|
+
}>;
|
|
14
|
+
interface ChatMessage {
|
|
15
|
+
role: "system" | "user" | "assistant";
|
|
16
|
+
content: ChatContent;
|
|
17
|
+
}
|
|
18
|
+
interface ChatCompletionInputs {
|
|
19
|
+
messages: Array<ChatMessage>;
|
|
20
|
+
temperature?: number;
|
|
21
|
+
max_tokens?: number;
|
|
22
|
+
top_p?: number;
|
|
23
|
+
frequency_penalty?: number;
|
|
24
|
+
presence_penalty?: number;
|
|
25
|
+
stop?: string | Array<string>;
|
|
26
|
+
stream?: boolean;
|
|
27
|
+
}
|
|
28
|
+
interface ChatCompletionResponse {
|
|
29
|
+
id: string;
|
|
30
|
+
object: string;
|
|
31
|
+
created: number;
|
|
32
|
+
model: string;
|
|
33
|
+
choices: Array<ChatCompletionChoice>;
|
|
34
|
+
usage: ChatCompletionUsage;
|
|
35
|
+
}
|
|
36
|
+
interface ChatCompletionChoice {
|
|
37
|
+
index: number;
|
|
38
|
+
message: ChatMessage;
|
|
39
|
+
finish_reason: string;
|
|
40
|
+
}
|
|
41
|
+
interface ChatCompletionUsage {
|
|
42
|
+
prompt_tokens: number;
|
|
43
|
+
completion_tokens: number;
|
|
44
|
+
total_tokens: number;
|
|
45
|
+
}
|
|
46
|
+
interface ChatCompletionChunk {
|
|
47
|
+
id: string;
|
|
48
|
+
choices: Array<{
|
|
49
|
+
index: number;
|
|
50
|
+
delta: {
|
|
51
|
+
role?: string;
|
|
52
|
+
content?: string;
|
|
53
|
+
};
|
|
54
|
+
finish_reason: string | null;
|
|
55
|
+
}>;
|
|
56
|
+
}
|
|
57
|
+
type ImageGatewayEndpoint = "images/generations" | "images/edits";
|
|
58
|
+
type ImageFileInput = Blob | ArrayBuffer | ArrayBufferView | {
|
|
59
|
+
data: string;
|
|
60
|
+
name?: string;
|
|
61
|
+
type?: string;
|
|
62
|
+
};
|
|
63
|
+
interface ImageGenerationInputs {
|
|
64
|
+
prompt: string;
|
|
65
|
+
n?: number;
|
|
66
|
+
size?: string;
|
|
67
|
+
quality?: string;
|
|
68
|
+
response_format?: "url" | "b64_json";
|
|
69
|
+
user?: string;
|
|
70
|
+
[key: string]: unknown;
|
|
71
|
+
}
|
|
72
|
+
interface ImageGenerationData {
|
|
73
|
+
url?: string;
|
|
74
|
+
b64_json?: string;
|
|
75
|
+
revised_prompt?: string;
|
|
76
|
+
}
|
|
77
|
+
interface ImageGenerationResponse {
|
|
78
|
+
created?: number;
|
|
79
|
+
data: Array<ImageGenerationData>;
|
|
80
|
+
usage?: unknown;
|
|
81
|
+
[key: string]: unknown;
|
|
82
|
+
}
|
|
83
|
+
interface ImageGenerationOptions {
|
|
84
|
+
endpoint?: "images/generations";
|
|
85
|
+
[key: string]: unknown;
|
|
86
|
+
}
|
|
87
|
+
interface ImageEditOptions {
|
|
88
|
+
endpoint: "images/edits";
|
|
89
|
+
[key: string]: unknown;
|
|
90
|
+
}
|
|
91
|
+
interface ImageEditInputs {
|
|
92
|
+
prompt: string;
|
|
93
|
+
image: ImageFileInput | Array<ImageFileInput>;
|
|
94
|
+
mask?: ImageFileInput;
|
|
95
|
+
n?: number;
|
|
96
|
+
size?: string;
|
|
97
|
+
response_format?: "url" | "b64_json";
|
|
98
|
+
user?: string;
|
|
99
|
+
[key: string]: unknown;
|
|
100
|
+
}
|
|
101
|
+
//#endregion
|
|
102
|
+
//#region src/runtime/ai.d.ts
|
|
103
|
+
/**
|
|
104
|
+
* Extended AI interface with a convenience `stream()` method.
|
|
105
|
+
*
|
|
106
|
+
* `stream()` calls `ai.run()` with `stream: true` and wraps the result
|
|
107
|
+
* in a `Response` with SSE headers — ready to return from a route handler.
|
|
108
|
+
*/
|
|
109
|
+
interface VoidAi extends Omit<Ai, "run"> {
|
|
110
|
+
/** Workers AI inference (existing) */
|
|
111
|
+
run<Name extends keyof AiModels>(model: Name, inputs: AiModels[Name]["inputs"], options?: AiOptions): Promise<AiModels[Name]["postProcessedOutputs"]>;
|
|
112
|
+
/** Third-party chat completions (OpenAI, Anthropic, etc.) */
|
|
113
|
+
run(model: ThirdPartyModel, inputs: ChatCompletionInputs, options?: AiOptions): Promise<ChatCompletionResponse>;
|
|
114
|
+
/** Image generation. Returns the proxy response so callers can return or parse it. */
|
|
115
|
+
image<Name extends keyof AiModels>(model: Name, inputs: AiModels[Name]["inputs"], options?: ImageGenerationOptions): Promise<Response>;
|
|
116
|
+
/** Third-party image generation or editing through AI Gateway. */
|
|
117
|
+
image(model: ThirdPartyModel, inputs: ImageEditInputs, options: ImageEditOptions): Promise<Response>;
|
|
118
|
+
/** Third-party image generation through AI Gateway. */
|
|
119
|
+
image(model: ThirdPartyModel, inputs: ImageGenerationInputs, options?: ImageGenerationOptions): Promise<Response>;
|
|
120
|
+
/** Stream Workers AI response as SSE */
|
|
121
|
+
stream<Name extends keyof AiModels>(model: Name, inputs: Omit<AiModels[Name]["inputs"], "stream">, options?: AiOptions): Promise<Response>;
|
|
122
|
+
/** Stream third-party chat completions as SSE */
|
|
123
|
+
stream(model: ThirdPartyModel, inputs: Omit<ChatCompletionInputs, "stream">, options?: AiOptions): Promise<Response>;
|
|
124
|
+
}
|
|
125
|
+
declare const ai: VoidAi;
|
|
126
|
+
//#endregion
|
|
127
|
+
export { type ChatCompletionChoice, type ChatCompletionChunk, type ChatCompletionInputs, type ChatCompletionResponse, type ChatCompletionUsage, type ChatContent, type ChatMessage, type ImageEditInputs, type ImageEditOptions, type ImageFileInput, type ImageGatewayEndpoint, type ImageGenerationData, type ImageGenerationInputs, type ImageGenerationOptions, type ImageGenerationResponse, type ThirdPartyModel, type ThirdPartyProvider, VoidAi, ai };
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
import { t as cfAccessHeaders } from "../cf-access-Dee5cXxL.mjs";
|
|
2
|
+
import { i as getRawRuntimeEnv } from "../env-raw-BDL4TvdN.mjs";
|
|
3
|
+
//#region src/runtime/ai-types.ts
|
|
4
|
+
/** Maps provider prefix to expected env var name for the API key */
|
|
5
|
+
const PROVIDER_KEY_MAP = {
|
|
6
|
+
openai: "OPENAI_API_KEY",
|
|
7
|
+
anthropic: "ANTHROPIC_API_KEY",
|
|
8
|
+
"google-ai-studio": "GOOGLE_API_KEY",
|
|
9
|
+
groq: "GROQ_API_KEY",
|
|
10
|
+
mistral: "MISTRAL_API_KEY",
|
|
11
|
+
grok: "GROK_API_KEY",
|
|
12
|
+
deepseek: "DEEPSEEK_API_KEY",
|
|
13
|
+
openrouter: "OPENROUTER_API_KEY",
|
|
14
|
+
perplexity: "PERPLEXITY_API_KEY",
|
|
15
|
+
cohere: "COHERE_API_KEY",
|
|
16
|
+
cerebras: "CEREBRAS_API_KEY",
|
|
17
|
+
huggingface: "HUGGINGFACE_API_KEY",
|
|
18
|
+
replicate: "REPLICATE_API_KEY",
|
|
19
|
+
baseten: "BASETEN_API_KEY",
|
|
20
|
+
cartesia: "CARTESIA_API_KEY",
|
|
21
|
+
deepgram: "DEEPGRAM_API_KEY",
|
|
22
|
+
elevenlabs: "ELEVENLABS_API_KEY",
|
|
23
|
+
fal: "FAL_API_KEY",
|
|
24
|
+
ideogram: "IDEOGRAM_API_KEY",
|
|
25
|
+
parallel: "PARALLEL_API_KEY"
|
|
26
|
+
};
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/runtime/ai.ts
|
|
29
|
+
const PROXY_URL = "https://proxy.void.cloud/ai";
|
|
30
|
+
const STAGING_PROXY_URL = "https://proxy.staging.void.cloud/ai";
|
|
31
|
+
const VOID_FILE_MARKER = "__voidFile";
|
|
32
|
+
function hasStreamFlag(value) {
|
|
33
|
+
return typeof value === "object" && value !== null && "stream" in value;
|
|
34
|
+
}
|
|
35
|
+
function isThirdPartyModel(model) {
|
|
36
|
+
return model.split("/")[0] in PROVIDER_KEY_MAP;
|
|
37
|
+
}
|
|
38
|
+
function mediaTypeFromContentType(contentType) {
|
|
39
|
+
if (!contentType) return null;
|
|
40
|
+
const [mediaType] = contentType.split(";", 1);
|
|
41
|
+
return mediaType?.trim().toLowerCase() || null;
|
|
42
|
+
}
|
|
43
|
+
function isJsonMediaType(mediaType) {
|
|
44
|
+
if (mediaType === "application/json") return true;
|
|
45
|
+
const slash = mediaType?.indexOf("/") ?? -1;
|
|
46
|
+
return Boolean(mediaType && slash >= 0 && mediaType.slice(slash + 1).endsWith("+json"));
|
|
47
|
+
}
|
|
48
|
+
async function readProxyResult(response) {
|
|
49
|
+
if (isJsonMediaType(mediaTypeFromContentType(response.headers.get("content-type")))) return response.json();
|
|
50
|
+
return response.blob();
|
|
51
|
+
}
|
|
52
|
+
function hasResponseMethod(value) {
|
|
53
|
+
return typeof value === "object" && value !== null && "response" in value && typeof value.response === "function";
|
|
54
|
+
}
|
|
55
|
+
function isBinaryView(value) {
|
|
56
|
+
return ArrayBuffer.isView(value);
|
|
57
|
+
}
|
|
58
|
+
function copyBinaryView(value) {
|
|
59
|
+
const bytes = new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
|
|
60
|
+
const copy = new Uint8Array(bytes.byteLength);
|
|
61
|
+
copy.set(bytes);
|
|
62
|
+
return copy.buffer;
|
|
63
|
+
}
|
|
64
|
+
function bytesToBase64(bytes) {
|
|
65
|
+
let binary = "";
|
|
66
|
+
const chunkSize = 32768;
|
|
67
|
+
for (let i = 0; i < bytes.length; i += chunkSize) binary += String.fromCharCode(...bytes.subarray(i, i + chunkSize));
|
|
68
|
+
return btoa(binary);
|
|
69
|
+
}
|
|
70
|
+
function arrayBufferToBase64(buffer) {
|
|
71
|
+
return bytesToBase64(new Uint8Array(buffer));
|
|
72
|
+
}
|
|
73
|
+
function isFileLikeRecord(value) {
|
|
74
|
+
return typeof value.data === "string" && (value.name === void 0 || typeof value.name === "string") && (value.type === void 0 || typeof value.type === "string");
|
|
75
|
+
}
|
|
76
|
+
function fileNameFromBlob(value) {
|
|
77
|
+
const name = value.name;
|
|
78
|
+
return typeof name === "string" && name.length > 0 ? name : void 0;
|
|
79
|
+
}
|
|
80
|
+
async function serializeProxyValue(value, serializeDataObjectAsFile = false) {
|
|
81
|
+
if (value instanceof Blob) return {
|
|
82
|
+
[VOID_FILE_MARKER]: true,
|
|
83
|
+
data: arrayBufferToBase64(await value.arrayBuffer()),
|
|
84
|
+
name: fileNameFromBlob(value),
|
|
85
|
+
type: value.type || void 0
|
|
86
|
+
};
|
|
87
|
+
if (value instanceof ArrayBuffer) return {
|
|
88
|
+
[VOID_FILE_MARKER]: true,
|
|
89
|
+
data: arrayBufferToBase64(value),
|
|
90
|
+
type: "application/octet-stream"
|
|
91
|
+
};
|
|
92
|
+
if (isBinaryView(value)) return {
|
|
93
|
+
[VOID_FILE_MARKER]: true,
|
|
94
|
+
data: arrayBufferToBase64(copyBinaryView(value)),
|
|
95
|
+
type: "application/octet-stream"
|
|
96
|
+
};
|
|
97
|
+
if (Array.isArray(value)) return Promise.all(value.map((item) => serializeProxyValue(item, serializeDataObjectAsFile)));
|
|
98
|
+
if (typeof value === "object" && value !== null) {
|
|
99
|
+
const record = value;
|
|
100
|
+
if (serializeDataObjectAsFile && isFileLikeRecord(record)) return {
|
|
101
|
+
[VOID_FILE_MARKER]: true,
|
|
102
|
+
data: record.data,
|
|
103
|
+
name: record.name,
|
|
104
|
+
type: record.type
|
|
105
|
+
};
|
|
106
|
+
const serialized = {};
|
|
107
|
+
for (const [key, nestedValue] of Object.entries(record)) serialized[key] = await serializeProxyValue(nestedValue, key === "image" || key === "mask");
|
|
108
|
+
return serialized;
|
|
109
|
+
}
|
|
110
|
+
return value;
|
|
111
|
+
}
|
|
112
|
+
async function serializeImageInputs(inputs, endpoint) {
|
|
113
|
+
return endpoint === "images/edits" ? serializeProxyValue(inputs) : inputs;
|
|
114
|
+
}
|
|
115
|
+
async function responseFromResult(result) {
|
|
116
|
+
if (result instanceof Response) return result;
|
|
117
|
+
if (hasResponseMethod(result)) return result.response();
|
|
118
|
+
if (result instanceof Blob) return new Response(result, { headers: result.type ? { "content-type": result.type } : void 0 });
|
|
119
|
+
if (result instanceof ReadableStream) return new Response(result, { headers: { "content-type": "application/octet-stream" } });
|
|
120
|
+
if (result instanceof ArrayBuffer) return new Response(result, { headers: { "content-type": "application/octet-stream" } });
|
|
121
|
+
if (isBinaryView(result)) return new Response(copyBinaryView(result), { headers: { "content-type": "application/octet-stream" } });
|
|
122
|
+
return Response.json(result);
|
|
123
|
+
}
|
|
124
|
+
function splitImageOptions(options) {
|
|
125
|
+
if (typeof options !== "object" || options === null) return {
|
|
126
|
+
endpoint: "images/generations",
|
|
127
|
+
runOptions: void 0
|
|
128
|
+
};
|
|
129
|
+
const { endpoint, ...runOptions } = options;
|
|
130
|
+
return {
|
|
131
|
+
endpoint: typeof endpoint === "string" ? endpoint : "images/generations",
|
|
132
|
+
runOptions: Object.keys(runOptions).length > 0 ? runOptions : void 0
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
function resolveProviderKey(model, runtimeEnv) {
|
|
136
|
+
const provider = model.split("/")[0];
|
|
137
|
+
const envVar = PROVIDER_KEY_MAP[provider];
|
|
138
|
+
if (!envVar) throw new Error(`ai: Unknown provider '${provider}'. Use one of: ${Object.keys(PROVIDER_KEY_MAP).join(", ")}.`);
|
|
139
|
+
const key = runtimeEnv[envVar];
|
|
140
|
+
if (typeof key !== "string" || key.length === 0) throw new Error(`ai: Missing ${envVar} secret. Add it as a project secret for provider '${provider}'.`);
|
|
141
|
+
return key;
|
|
142
|
+
}
|
|
143
|
+
function getProxyUrl(runtimeEnv) {
|
|
144
|
+
const custom = runtimeEnv.__VOID_PROXY_URL;
|
|
145
|
+
if (typeof custom === "string" && custom.length > 0) return custom + "/ai";
|
|
146
|
+
return runtimeEnv.__VOID_STAGING ? STAGING_PROXY_URL : PROXY_URL;
|
|
147
|
+
}
|
|
148
|
+
function resolveBackend() {
|
|
149
|
+
const runtimeEnv = getRawRuntimeEnv();
|
|
150
|
+
const proxy = runtimeEnv.__VOID_PROXY;
|
|
151
|
+
if (proxy) return makeServiceBindingBackend(proxy, runtimeEnv);
|
|
152
|
+
const token = runtimeEnv.__VOID_TOKEN;
|
|
153
|
+
const projectId = runtimeEnv.__VOID_PROJECT_ID;
|
|
154
|
+
if (typeof token === "string" && typeof projectId === "string") return makeHttpBackend(token, projectId, runtimeEnv);
|
|
155
|
+
const directAi = runtimeEnv.AI;
|
|
156
|
+
if (directAi) return {
|
|
157
|
+
run: directAi.run.bind(directAi),
|
|
158
|
+
async image(model, inputs, options) {
|
|
159
|
+
const { runOptions } = splitImageOptions(options);
|
|
160
|
+
return responseFromResult(await directAi.run(model, inputs, runOptions));
|
|
161
|
+
},
|
|
162
|
+
models: directAi.models.bind(directAi),
|
|
163
|
+
toMarkdown: directAi.toMarkdown?.bind(directAi) ?? unsupported("toMarkdown")
|
|
164
|
+
};
|
|
165
|
+
throw new Error("ai: Not available. Run `void auth login` and `void project link` first.");
|
|
166
|
+
}
|
|
167
|
+
function unsupported(method) {
|
|
168
|
+
return () => {
|
|
169
|
+
throw new Error(`ai: ai.${method}() is not supported in this environment.`);
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
function makeServiceBindingBackend(proxy, runtimeEnv) {
|
|
173
|
+
async function proxyFetch(action, body) {
|
|
174
|
+
const res = await proxy.fetch(`https://ai-proxy/ai/${action}`, {
|
|
175
|
+
method: "POST",
|
|
176
|
+
headers: { "content-type": "application/json" },
|
|
177
|
+
body: JSON.stringify({
|
|
178
|
+
action,
|
|
179
|
+
...body
|
|
180
|
+
})
|
|
181
|
+
});
|
|
182
|
+
if (!res.ok) {
|
|
183
|
+
const text = await res.text();
|
|
184
|
+
throw new Error(`ai: Proxy request failed with ${res.status}: '${text}'.`);
|
|
185
|
+
}
|
|
186
|
+
return res;
|
|
187
|
+
}
|
|
188
|
+
return {
|
|
189
|
+
async run(model, inputs, options) {
|
|
190
|
+
const projectId = runtimeEnv.__PROJECT_ID;
|
|
191
|
+
const aiToken = runtimeEnv.__VOID_PROXY_TOKEN;
|
|
192
|
+
if (isThirdPartyModel(model)) {
|
|
193
|
+
const res = await proxyFetch("gateway", {
|
|
194
|
+
model,
|
|
195
|
+
inputs,
|
|
196
|
+
providerKey: resolveProviderKey(model, runtimeEnv),
|
|
197
|
+
projectId,
|
|
198
|
+
aiToken
|
|
199
|
+
});
|
|
200
|
+
if (hasStreamFlag(inputs) && inputs.stream) return res.body;
|
|
201
|
+
return readProxyResult(res);
|
|
202
|
+
}
|
|
203
|
+
const res = await proxyFetch("run", {
|
|
204
|
+
model,
|
|
205
|
+
inputs,
|
|
206
|
+
options,
|
|
207
|
+
projectId,
|
|
208
|
+
aiToken
|
|
209
|
+
});
|
|
210
|
+
if (hasStreamFlag(inputs) && inputs.stream) return res.body;
|
|
211
|
+
return readProxyResult(res);
|
|
212
|
+
},
|
|
213
|
+
async image(model, inputs, options) {
|
|
214
|
+
const projectId = runtimeEnv.__PROJECT_ID;
|
|
215
|
+
const aiToken = runtimeEnv.__VOID_PROXY_TOKEN;
|
|
216
|
+
const { endpoint, runOptions } = splitImageOptions(options);
|
|
217
|
+
if (isThirdPartyModel(model)) {
|
|
218
|
+
const providerKey = resolveProviderKey(model, runtimeEnv);
|
|
219
|
+
return proxyFetch("gateway", {
|
|
220
|
+
model,
|
|
221
|
+
endpoint,
|
|
222
|
+
inputs: await serializeImageInputs(inputs, endpoint),
|
|
223
|
+
providerKey,
|
|
224
|
+
projectId,
|
|
225
|
+
aiToken
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
return proxyFetch("run", {
|
|
229
|
+
model,
|
|
230
|
+
inputs,
|
|
231
|
+
options: runOptions,
|
|
232
|
+
projectId,
|
|
233
|
+
aiToken
|
|
234
|
+
});
|
|
235
|
+
},
|
|
236
|
+
async models(params) {
|
|
237
|
+
const projectId = runtimeEnv.__PROJECT_ID;
|
|
238
|
+
const aiToken = runtimeEnv.__VOID_PROXY_TOKEN;
|
|
239
|
+
return (await proxyFetch("models", {
|
|
240
|
+
inputs: params,
|
|
241
|
+
projectId,
|
|
242
|
+
aiToken
|
|
243
|
+
})).json();
|
|
244
|
+
},
|
|
245
|
+
async toMarkdown(items, options) {
|
|
246
|
+
const projectId = runtimeEnv.__PROJECT_ID;
|
|
247
|
+
const aiToken = runtimeEnv.__VOID_PROXY_TOKEN;
|
|
248
|
+
return (await proxyFetch("toMarkdown", {
|
|
249
|
+
inputs: items,
|
|
250
|
+
options,
|
|
251
|
+
projectId,
|
|
252
|
+
aiToken
|
|
253
|
+
})).json();
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
function makeHttpBackend(token, projectId, runtimeEnv) {
|
|
258
|
+
const base = getProxyUrl(runtimeEnv);
|
|
259
|
+
const headers = {
|
|
260
|
+
"content-type": "application/json",
|
|
261
|
+
authorization: `Bearer ${token}`,
|
|
262
|
+
...cfAccessHeaders(runtimeEnv)
|
|
263
|
+
};
|
|
264
|
+
async function proxyFetch(action, body) {
|
|
265
|
+
const res = await fetch(`${base}/${action}`, {
|
|
266
|
+
method: "POST",
|
|
267
|
+
headers,
|
|
268
|
+
body: JSON.stringify({
|
|
269
|
+
action,
|
|
270
|
+
...body,
|
|
271
|
+
projectId
|
|
272
|
+
})
|
|
273
|
+
});
|
|
274
|
+
if (!res.ok) {
|
|
275
|
+
const text = await res.text();
|
|
276
|
+
throw new Error(`ai: Proxy request failed with ${res.status}: '${text}'.`);
|
|
277
|
+
}
|
|
278
|
+
return res;
|
|
279
|
+
}
|
|
280
|
+
return {
|
|
281
|
+
async run(model, inputs, options) {
|
|
282
|
+
if (isThirdPartyModel(model)) {
|
|
283
|
+
const res = await proxyFetch("gateway", {
|
|
284
|
+
model,
|
|
285
|
+
inputs,
|
|
286
|
+
providerKey: resolveProviderKey(model, runtimeEnv)
|
|
287
|
+
});
|
|
288
|
+
if (hasStreamFlag(inputs) && inputs.stream) return res.body;
|
|
289
|
+
return readProxyResult(res);
|
|
290
|
+
}
|
|
291
|
+
const res = await proxyFetch("run", {
|
|
292
|
+
model,
|
|
293
|
+
inputs,
|
|
294
|
+
options
|
|
295
|
+
});
|
|
296
|
+
if (hasStreamFlag(inputs) && inputs.stream) return res.body;
|
|
297
|
+
return readProxyResult(res);
|
|
298
|
+
},
|
|
299
|
+
async image(model, inputs, options) {
|
|
300
|
+
const { endpoint, runOptions } = splitImageOptions(options);
|
|
301
|
+
if (isThirdPartyModel(model)) {
|
|
302
|
+
const providerKey = resolveProviderKey(model, runtimeEnv);
|
|
303
|
+
return proxyFetch("gateway", {
|
|
304
|
+
model,
|
|
305
|
+
endpoint,
|
|
306
|
+
inputs: await serializeImageInputs(inputs, endpoint),
|
|
307
|
+
providerKey
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
return proxyFetch("run", {
|
|
311
|
+
model,
|
|
312
|
+
inputs,
|
|
313
|
+
options: runOptions
|
|
314
|
+
});
|
|
315
|
+
},
|
|
316
|
+
async models(params) {
|
|
317
|
+
return (await proxyFetch("models", { inputs: params })).json();
|
|
318
|
+
},
|
|
319
|
+
async toMarkdown(items, options) {
|
|
320
|
+
return (await proxyFetch("toMarkdown", {
|
|
321
|
+
inputs: items,
|
|
322
|
+
options
|
|
323
|
+
})).json();
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
let _backend;
|
|
328
|
+
function backend() {
|
|
329
|
+
return _backend ??= resolveBackend();
|
|
330
|
+
}
|
|
331
|
+
const ai = new Proxy({}, { get(_, prop) {
|
|
332
|
+
if (prop === "stream") return async (model, inputs, options) => {
|
|
333
|
+
const body = await backend().run(model, {
|
|
334
|
+
...inputs,
|
|
335
|
+
stream: true
|
|
336
|
+
}, options);
|
|
337
|
+
return new Response(body, { headers: {
|
|
338
|
+
"content-type": "text/event-stream",
|
|
339
|
+
"cache-control": "no-cache"
|
|
340
|
+
} });
|
|
341
|
+
};
|
|
342
|
+
if (prop === "run") return backend().run;
|
|
343
|
+
if (prop === "image") return backend().image;
|
|
344
|
+
if (prop === "models") return backend().models;
|
|
345
|
+
if (prop === "toMarkdown") return backend().toMarkdown;
|
|
346
|
+
} });
|
|
347
|
+
//#endregion
|
|
348
|
+
export { ai };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createAuthClient as createAuthClient$1 } from "better-auth/react";
|
|
2
|
+
|
|
3
|
+
//#region src/runtime/auth-client-react.d.ts
|
|
4
|
+
declare const createAuthClient: typeof createAuthClient$1;
|
|
5
|
+
type BetterAuthClientInstance = ReturnType<typeof createAuthClient>;
|
|
6
|
+
declare const auth: BetterAuthClientInstance;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { auth, createAuthClient };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createAuthClient as createAuthClient$1 } from "better-auth/react";
|
|
2
|
+
//#region src/runtime/auth-client-react.ts
|
|
3
|
+
const createAuthClient = createAuthClient$1;
|
|
4
|
+
const auth = createAuthClient$1({ basePath: "/api/auth" });
|
|
5
|
+
//#endregion
|
|
6
|
+
export { auth, createAuthClient };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createAuthClient as createAuthClient$1 } from "better-auth/solid";
|
|
2
|
+
|
|
3
|
+
//#region src/runtime/auth-client-solid.d.ts
|
|
4
|
+
declare const createAuthClient: typeof createAuthClient$1;
|
|
5
|
+
type BetterAuthClientInstance = ReturnType<typeof createAuthClient>;
|
|
6
|
+
declare const auth: BetterAuthClientInstance;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { auth, createAuthClient };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createAuthClient as createAuthClient$1 } from "better-auth/solid";
|
|
2
|
+
//#region src/runtime/auth-client-solid.ts
|
|
3
|
+
const createAuthClient = createAuthClient$1;
|
|
4
|
+
const auth = createAuthClient$1({ basePath: "/api/auth" });
|
|
5
|
+
//#endregion
|
|
6
|
+
export { auth, createAuthClient };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createAuthClient as createAuthClient$1 } from "better-auth/svelte";
|
|
2
|
+
|
|
3
|
+
//#region src/runtime/auth-client-svelte.d.ts
|
|
4
|
+
declare const createAuthClient: typeof createAuthClient$1;
|
|
5
|
+
type BetterAuthClientInstance = ReturnType<typeof createAuthClient>;
|
|
6
|
+
declare const auth: BetterAuthClientInstance;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { auth, createAuthClient };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createAuthClient as createAuthClient$1 } from "better-auth/svelte";
|
|
2
|
+
//#region src/runtime/auth-client-svelte.ts
|
|
3
|
+
const createAuthClient = createAuthClient$1;
|
|
4
|
+
const auth = createAuthClient$1({ basePath: "/api/auth" });
|
|
5
|
+
//#endregion
|
|
6
|
+
export { auth, createAuthClient };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createAuthClient as createAuthClient$1 } from "better-auth/vue";
|
|
2
|
+
|
|
3
|
+
//#region src/runtime/auth-client-vue.d.ts
|
|
4
|
+
declare const createAuthClient: typeof createAuthClient$1;
|
|
5
|
+
type BetterAuthClientInstance = ReturnType<typeof createAuthClient>;
|
|
6
|
+
declare const auth: BetterAuthClientInstance;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { auth, createAuthClient };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createAuthClient as createAuthClient$1 } from "better-auth/vue";
|
|
2
|
+
//#region src/runtime/auth-client-vue.ts
|
|
3
|
+
const createAuthClient = createAuthClient$1;
|
|
4
|
+
const auth = createAuthClient$1({ basePath: "/api/auth" });
|
|
5
|
+
//#endregion
|
|
6
|
+
export { auth, createAuthClient };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createAuthClient as createAuthClient$1 } from "better-auth/client";
|
|
2
|
+
|
|
3
|
+
//#region src/runtime/auth-client.d.ts
|
|
4
|
+
declare const createAuthClient: typeof createAuthClient$1;
|
|
5
|
+
type BetterAuthClientInstance = ReturnType<typeof createAuthClient>;
|
|
6
|
+
declare const auth: BetterAuthClientInstance;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { auth, createAuthClient };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createAuthClient as createAuthClient$1 } from "better-auth/client";
|
|
2
|
+
//#region src/runtime/auth-client.ts
|
|
3
|
+
const createAuthClient = createAuthClient$1;
|
|
4
|
+
const auth = createAuthClient$1({ basePath: "/api/auth" });
|
|
5
|
+
//#endregion
|
|
6
|
+
export { auth, createAuthClient };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as VoidAuthConfigContext, c as getSession, i as VoidAuthConfig, l as getUser, n as AuthState, o as authContext, r as AuthUser, s as defineAuth, t as AuthSession, u as requireAuth } from "../auth-BdsJ0Aff.mjs";
|
|
2
|
+
export { AuthSession, AuthState, AuthUser, VoidAuthConfig, VoidAuthConfigContext, authContext, defineAuth, getSession, getUser, requireAuth };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
+
import { HTTPException } from "hono/http-exception";
|
|
3
|
+
//#region src/runtime/auth.ts
|
|
4
|
+
const AUTH_CONTEXT_SYMBOL = Symbol.for("void.authContext.v1");
|
|
5
|
+
const globalWithAuthContext = globalThis;
|
|
6
|
+
const authContext = globalWithAuthContext[AUTH_CONTEXT_SYMBOL] ?? (globalWithAuthContext[AUTH_CONTEXT_SYMBOL] = new AsyncLocalStorage());
|
|
7
|
+
function defineAuth(config) {
|
|
8
|
+
return config;
|
|
9
|
+
}
|
|
10
|
+
function getUser() {
|
|
11
|
+
return authContext.getStore()?.user ?? null;
|
|
12
|
+
}
|
|
13
|
+
function getSession() {
|
|
14
|
+
return authContext.getStore()?.state ?? null;
|
|
15
|
+
}
|
|
16
|
+
function requireAuth(c) {
|
|
17
|
+
const user = c.get("user");
|
|
18
|
+
if (!user) throw new HTTPException(401, { message: "Unauthorized" });
|
|
19
|
+
return user;
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { authContext, defineAuth, getSession, getUser, requireAuth };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { i as VoidAuthRuntimeOptions, n as VoidAuthEnv, r as VoidAuthRuntimeApi, t as VoidAuthDialect } from "../better-auth-shared-C9_GHSkR.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/runtime/better-auth-pg.d.ts
|
|
4
|
+
declare const resolveVoidAuthOptions: VoidAuthRuntimeApi["resolveVoidAuthOptions"];
|
|
5
|
+
declare const createVoidAuth: VoidAuthRuntimeApi["createVoidAuth"];
|
|
6
|
+
declare const resolveVoidAuthState: VoidAuthRuntimeApi["resolveVoidAuthState"];
|
|
7
|
+
declare const runVoidAuthMiddleware: VoidAuthRuntimeApi["runVoidAuthMiddleware"];
|
|
8
|
+
declare const handleVoidAuthRequest: VoidAuthRuntimeApi["handleVoidAuthRequest"];
|
|
9
|
+
declare const runVoidAuthMigrations: VoidAuthRuntimeApi["runVoidAuthMigrations"];
|
|
10
|
+
//#endregion
|
|
11
|
+
export { type VoidAuthDialect, type VoidAuthEnv, type VoidAuthRuntimeOptions, createVoidAuth, handleVoidAuthRequest, resolveVoidAuthOptions, resolveVoidAuthState, runVoidAuthMiddleware, runVoidAuthMigrations };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { t as applyPgAuthMigrations } from "../auth-migrations-BAtAck2g.mjs";
|
|
2
|
+
import { t as createVoidAuthRuntime } from "../better-auth-shared-CdYmQGry.mjs";
|
|
3
|
+
//#region src/runtime/better-auth-pg.ts
|
|
4
|
+
function resolveConnectionString(env) {
|
|
5
|
+
const connectionString = typeof env.DATABASE_URL === "string" && env.DATABASE_URL.length > 0 ? env.DATABASE_URL : typeof env.HYPERDRIVE?.connectionString === "string" && env.HYPERDRIVE.connectionString.length > 0 ? env.HYPERDRIVE.connectionString : void 0;
|
|
6
|
+
if (!connectionString) throw new Error("auth: Better Auth requires DATABASE_URL for local PostgreSQL dev or HYPERDRIVE in production.");
|
|
7
|
+
return connectionString;
|
|
8
|
+
}
|
|
9
|
+
async function resolveDatabase(env) {
|
|
10
|
+
const { default: pg } = await import("pg");
|
|
11
|
+
const connectionString = resolveConnectionString(env);
|
|
12
|
+
const pool = new pg.Pool({
|
|
13
|
+
connectionString,
|
|
14
|
+
max: 1
|
|
15
|
+
});
|
|
16
|
+
return {
|
|
17
|
+
database: pool,
|
|
18
|
+
async dispose() {
|
|
19
|
+
await pool.end();
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
async function runPostgresAuthMigrations(_request, env, runtime, migrationSchema) {
|
|
24
|
+
if (!migrationSchema) throw new Error("auth: Migration schema is unavailable.");
|
|
25
|
+
if (runtime.dialect !== "postgresql") throw new Error(`auth: Runtime mismatch. Expected postgresql, received '${runtime.dialect}'.`);
|
|
26
|
+
if (migrationSchema.dialect !== "postgresql") throw new Error(`auth: Runtime mismatch. Expected postgresql, received '${migrationSchema.dialect}'.`);
|
|
27
|
+
const { Client } = await import("pg");
|
|
28
|
+
const client = new Client({ connectionString: resolveConnectionString(env) });
|
|
29
|
+
await client.connect();
|
|
30
|
+
try {
|
|
31
|
+
await applyPgAuthMigrations({
|
|
32
|
+
async all(sql, params) {
|
|
33
|
+
return (await client.query(sql, params)).rows;
|
|
34
|
+
},
|
|
35
|
+
async run(sql, params) {
|
|
36
|
+
await client.query(sql, params);
|
|
37
|
+
}
|
|
38
|
+
}, migrationSchema);
|
|
39
|
+
} finally {
|
|
40
|
+
await client.end();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const runtime = createVoidAuthRuntime("postgresql", resolveDatabase, runPostgresAuthMigrations);
|
|
44
|
+
const resolveVoidAuthOptions = runtime.resolveVoidAuthOptions;
|
|
45
|
+
const createVoidAuth = runtime.createVoidAuth;
|
|
46
|
+
const resolveVoidAuthState = runtime.resolveVoidAuthState;
|
|
47
|
+
const runVoidAuthMiddleware = runtime.runVoidAuthMiddleware;
|
|
48
|
+
const handleVoidAuthRequest = runtime.handleVoidAuthRequest;
|
|
49
|
+
const runVoidAuthMigrations = runtime.runVoidAuthMigrations;
|
|
50
|
+
//#endregion
|
|
51
|
+
export { createVoidAuth, handleVoidAuthRequest, resolveVoidAuthOptions, resolveVoidAuthState, runVoidAuthMiddleware, runVoidAuthMigrations };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { i as VoidAuthRuntimeOptions, n as VoidAuthEnv, r as VoidAuthRuntimeApi, t as VoidAuthDialect } from "../better-auth-shared-C9_GHSkR.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/runtime/better-auth.d.ts
|
|
4
|
+
declare const resolveVoidAuthOptions: VoidAuthRuntimeApi["resolveVoidAuthOptions"];
|
|
5
|
+
declare const createVoidAuth: VoidAuthRuntimeApi["createVoidAuth"];
|
|
6
|
+
declare const resolveVoidAuthState: VoidAuthRuntimeApi["resolveVoidAuthState"];
|
|
7
|
+
declare const runVoidAuthMiddleware: VoidAuthRuntimeApi["runVoidAuthMiddleware"];
|
|
8
|
+
declare const handleVoidAuthRequest: VoidAuthRuntimeApi["handleVoidAuthRequest"];
|
|
9
|
+
declare const runVoidAuthMigrations: VoidAuthRuntimeApi["runVoidAuthMigrations"];
|
|
10
|
+
//#endregion
|
|
11
|
+
export { type VoidAuthDialect, type VoidAuthEnv, type VoidAuthRuntimeOptions, createVoidAuth, handleVoidAuthRequest, resolveVoidAuthOptions, resolveVoidAuthState, runVoidAuthMiddleware, runVoidAuthMigrations };
|