void 0.9.0 → 0.9.2

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.
Files changed (104) hide show
  1. package/dist/{auth-cmd-BSdoU6dB.mjs → auth-cmd-CPkWrQR9.mjs} +2 -2
  2. package/dist/{better-auth-shared-BxcgLiHN.d.mts → better-auth-shared-CmEQZs1T.d.mts} +2 -2
  3. package/dist/{cache-Cb4Vs95q.mjs → cache-1SVxZ7BK.mjs} +2 -2
  4. package/dist/{cancel-deploy-CLVkqGJB.mjs → cancel-deploy-JaFClLr7.mjs} +1 -1
  5. package/dist/cli/cli.mjs +77 -40
  6. package/dist/{client-CCOKwNUz.mjs → client-DIfOFf1W.mjs} +6 -1
  7. package/dist/{create-project-Dg5hiuDE.mjs → create-project-DCUrFJxa.mjs} +3 -3
  8. package/dist/{db-D7l4OGV1.mjs → db-DiddQC2v.mjs} +191 -19
  9. package/dist/{delete-Bi-gbEHT.mjs → delete-CYknzwXU.mjs} +2 -2
  10. package/dist/{deploy-iR7ug73w.mjs → deploy-CRU9fGjE.mjs} +8 -11
  11. package/dist/{domain-C_atK_X9.mjs → domain-B7RntQ1r.mjs} +13 -28
  12. package/dist/{env-Dc073Aip.mjs → env-Bvw0wMTI.mjs} +1 -1
  13. package/dist/{env-helpers-bupZjGHq.d.mts → env-helpers-Bd2wVdxz.d.mts} +1 -1
  14. package/dist/{gen-CsawhQZz.mjs → gen-CZdNWIaA.mjs} +1 -1
  15. package/dist/{handler-DMSGX5S6.d.mts → handler-xflsMwWM.d.mts} +3 -3
  16. package/dist/index.d.mts +3 -3
  17. package/dist/index.mjs +71 -52
  18. package/dist/{init-CD9yg4Xt.mjs → init-BHupO7Fm.mjs} +7 -7
  19. package/dist/{link-27a64clx.mjs → link-7MoXUMaI.mjs} +3 -3
  20. package/dist/{list-C3Xt_i8a.mjs → list-N2mCHv8q.mjs} +2 -2
  21. package/dist/{login-BZ1Yk9Xw.mjs → login-tt1OmNVg.mjs} +1 -1
  22. package/dist/{logs-CktUaLEr.mjs → logs-Cl7q2CjZ.mjs} +1 -1
  23. package/dist/{mcp-BU7CP6gX.mjs → mcp-BXD35N2J.mjs} +1 -1
  24. package/dist/{node-C2HhnBO_.mjs → node-CHWVVjO6.mjs} +3 -3
  25. package/dist/pages/client.d.mts +1 -1
  26. package/dist/pages/head-client.d.mts +1 -1
  27. package/dist/pages/head.d.mts +1 -1
  28. package/dist/pages/index.d.mts +2 -2
  29. package/dist/pages/index.mjs +1 -1
  30. package/dist/pages/islands-plugin.d.mts +1 -1
  31. package/dist/pages/protocol.d.mts +2 -2
  32. package/dist/pages/protocol.mjs +1 -1
  33. package/dist/{prepare-BNuC8Ds9.mjs → prepare-CrlAVbWS.mjs} +1 -1
  34. package/dist/{preset-Lvi0ORmO.mjs → preset-CIJG2O7a.mjs} +1 -1
  35. package/dist/{project-cmd-DUkWHooP.mjs → project-cmd-CLrqSbqj.mjs} +8 -8
  36. package/dist/{protocol-hjl3Nx5x.d.mts → protocol-DYca39yJ.d.mts} +3 -3
  37. package/dist/proxy-M3pxItg2.mjs +5 -0
  38. package/dist/{rollback-CEjAG9uQ.mjs → rollback-CEbAwbHK.mjs} +1 -1
  39. package/dist/{runner-Cioqe5b2.mjs → runner-DLZ9E_cX.mjs} +1 -1
  40. package/dist/runtime/ai.d.mts +20 -100
  41. package/dist/runtime/ai.mjs +102 -55
  42. package/dist/runtime/auth.d.mts +1 -1
  43. package/dist/runtime/better-auth-pg.d.mts +1 -1
  44. package/dist/runtime/better-auth-pg.mjs +3 -3
  45. package/dist/runtime/better-auth.d.mts +1 -1
  46. package/dist/runtime/better-auth.mjs +2 -2
  47. package/dist/runtime/client-react.d.mts +2 -2
  48. package/dist/runtime/client-react.mjs +1 -1
  49. package/dist/runtime/client-solid.d.mts +2 -2
  50. package/dist/runtime/client-solid.mjs +1 -1
  51. package/dist/runtime/client-svelte.d.mts +2 -2
  52. package/dist/runtime/client-svelte.mjs +1 -1
  53. package/dist/runtime/client-vue.d.mts +2 -2
  54. package/dist/runtime/client-vue.mjs +1 -1
  55. package/dist/runtime/client.d.mts +2 -2
  56. package/dist/runtime/client.mjs +1 -1
  57. package/dist/runtime/env-helpers.d.mts +1 -1
  58. package/dist/runtime/env-public-client.d.mts +1 -1
  59. package/dist/runtime/env-public.d.mts +2 -2
  60. package/dist/runtime/env-public.mjs +1 -1
  61. package/dist/runtime/env.mjs +1 -1
  62. package/dist/runtime/fetch-stream.d.mts +1 -1
  63. package/dist/runtime/fetch-stream.mjs +1 -1
  64. package/dist/runtime/fetch.d.mts +1 -1
  65. package/dist/runtime/fetch.mjs +1 -1
  66. package/dist/runtime/handler.d.mts +1 -1
  67. package/dist/runtime/handler.mjs +1 -1
  68. package/dist/runtime/isr.mjs +1 -1
  69. package/dist/runtime/live.d.mts +2 -2
  70. package/dist/runtime/live.mjs +1 -1
  71. package/dist/runtime/migration-handler-pg.mjs +1 -1
  72. package/dist/runtime/sandbox.mjs +1 -1
  73. package/dist/runtime/validator.d.mts +1 -1
  74. package/dist/runtime/ws-server.d.mts +2 -2
  75. package/dist/runtime/ws.d.mts +3 -3
  76. package/dist/{secret-Dab6XQdb.mjs → secret-C_uTY7xx.mjs} +2 -2
  77. package/dist/{skills-GPm5Kjev.mjs → skills-BRKc--As.mjs} +1 -1
  78. package/package.json +2 -2
  79. package/skills/void/docs/guide/ai.md +109 -51
  80. package/skills/void/docs/guide/auth.md +3 -3
  81. package/skills/void/docs/node_modules/void/AGENTS.md +1 -1
  82. package/skills/void/docs/reference/api.md +9 -2
  83. package/skills/void/docs/reference/cli.md +50 -30
  84. /package/dist/{agents-Dkgafwfr.mjs → agents-MhSzNMiC.mjs} +0 -0
  85. /package/dist/{auth-BL0cU_Sy.d.mts → auth-CDeb2XAl.d.mts} +0 -0
  86. /package/dist/{auth-migrations-DBoTUBvq.mjs → auth-migrations-CuQkjjWE.mjs} +0 -0
  87. /package/dist/{better-auth-shared-pR54mTD2.mjs → better-auth-shared-ChVbrq52.mjs} +0 -0
  88. /package/dist/{defer-BosTTQTi.mjs → defer-CouVukrf.mjs} +0 -0
  89. /package/dist/{drizzle-Bvhm-Uug.mjs → drizzle-2fs1qTgy.mjs} +0 -0
  90. /package/dist/{env-raw-DhK_myJu.mjs → env-raw-RDkMnSTC.mjs} +0 -0
  91. /package/dist/{fetch-error-B8GTcrQw.mjs → fetch-error-BFIoojjf.mjs} +0 -0
  92. /package/dist/{fetch-error-Dn-En6Wg.d.mts → fetch-error-CimrygMq.d.mts} +0 -0
  93. /package/dist/{head-BW_f2L_4.d.mts → head-BsSTGnIe.d.mts} +0 -0
  94. /package/dist/{headers-wAPJigtE.mjs → headers-Y0jshugF.mjs} +0 -0
  95. /package/dist/{package-json-BMdypFnO.mjs → package-json-B2TD0JLu.mjs} +0 -0
  96. /package/dist/{pg-C-ybKyFU.mjs → pg-CMZ_5wsC.mjs} +0 -0
  97. /package/dist/{project-slug-De4UjtD9.mjs → project-slug-rX3kTOfY.mjs} +0 -0
  98. /package/dist/{providers-BVUcW4Jo.d.mts → providers-3Kkv63Ha.d.mts} +0 -0
  99. /package/dist/{resolve-project-CNpUbUHd.mjs → resolve-project-D4O1_fZz.mjs} +0 -0
  100. /package/dist/{runner-pg-D8ciL41o.mjs → runner-pg-Cv9V7ydr.mjs} +0 -0
  101. /package/dist/{standard-schema-DCIm8cwQ.d.mts → standard-schema-Dnsh2vnl.d.mts} +0 -0
  102. /package/dist/{subcommand-prompt-DUaWltdH.mjs → subcommand-prompt-OD-x_Tsm.mjs} +0 -0
  103. /package/dist/{types-s2mK7ar_.d.mts → types-Dm9kep2X.d.mts} +0 -0
  104. /package/dist/{yarn-pnp-BdM0hoCa.mjs → yarn-pnp-0SwYgQxx.mjs} +0 -0
@@ -1,5 +1,5 @@
1
1
  import { i as dim, l as tablePrefix, n as cliTitle, s as import_picocolors } from "./output-DeiS4oEX.mjs";
2
- import { c as getToken, n as PlatformClient, s as getSiteDomain } from "./client-CCOKwNUz.mjs";
2
+ import { c as getToken, n as PlatformClient, s as getSiteDomain } from "./client-DIfOFf1W.mjs";
3
3
  import { c as R, g as ge, y as ye } from "./dist-abzUneor.mjs";
4
4
  //#region src/cli/projects.ts
5
5
  async function runProjectsCommand(root) {
@@ -34,32 +34,32 @@ async function runProjectsCommand(root) {
34
34
  //#region src/cli/project-cmd.ts
35
35
  async function runProjectCommand(root, args) {
36
36
  if (args.subcommand === "status") {
37
- const { runListCommand } = await import("./list-C3Xt_i8a.mjs");
37
+ const { runListCommand } = await import("./list-N2mCHv8q.mjs");
38
38
  return runListCommand(root, args.name || void 0);
39
39
  }
40
40
  if (args.subcommand === "link") {
41
- const { runLink } = await import("./link-27a64clx.mjs");
41
+ const { runLink } = await import("./link-7MoXUMaI.mjs");
42
42
  return runLink(root, args.name || void 0);
43
43
  }
44
44
  if (args.subcommand === "list") return runProjectsCommand(root);
45
45
  if (args.subcommand === "logs") {
46
- const { runLogsCommand } = await import("./logs-CktUaLEr.mjs");
46
+ const { runLogsCommand } = await import("./logs-Cl7q2CjZ.mjs");
47
47
  return runLogsCommand(root, args.filter, args.range, args.deployment || void 0, args.level || void 0);
48
48
  }
49
49
  if (args.subcommand === "rollback") {
50
- const { runRollbackCommand } = await import("./rollback-CEjAG9uQ.mjs");
50
+ const { runRollbackCommand } = await import("./rollback-CEbAwbHK.mjs");
51
51
  return runRollbackCommand(root, args.deployId || void 0);
52
52
  }
53
53
  if (args.subcommand === "cancel") {
54
- const { runCancelDeployCommand } = await import("./cancel-deploy-CLVkqGJB.mjs");
54
+ const { runCancelDeployCommand } = await import("./cancel-deploy-JaFClLr7.mjs");
55
55
  return runCancelDeployCommand(root, args.deployId || void 0);
56
56
  }
57
57
  if (args.subcommand === "delete") {
58
- const { runDeleteCommand } = await import("./delete-Bi-gbEHT.mjs");
58
+ const { runDeleteCommand } = await import("./delete-CYknzwXU.mjs");
59
59
  return runDeleteCommand(root, args.name || void 0, { force: args.force });
60
60
  }
61
61
  if (args.subcommand === "purge-cache") {
62
- const { runPurgeCacheCommand } = await import("./cache-Cb4Vs95q.mjs");
62
+ const { runPurgeCacheCommand } = await import("./cache-1SVxZ7BK.mjs");
63
63
  return runPurgeCacheCommand(root, args.projectSlug || void 0);
64
64
  }
65
65
  }
@@ -1,6 +1,6 @@
1
- import { n as HeadDescriptor, t as HeadConfig } from "./head-BW_f2L_4.mjs";
2
- import { n as CloudContext, t as CloudBindings } from "./handler-DMSGX5S6.mjs";
3
- import { t as DevCssAsset } from "./types-s2mK7ar_.mjs";
1
+ import { n as HeadDescriptor, t as HeadConfig } from "./head-BsSTGnIe.mjs";
2
+ import { n as CloudContext, t as CloudBindings } from "./handler-xflsMwWM.mjs";
3
+ import { t as DevCssAsset } from "./types-Dm9kep2X.mjs";
4
4
 
5
5
  //#region src/pages/protocol.d.ts
6
6
  /** Escape characters that are unsafe inside inline <script> tags to prevent XSS. */
@@ -0,0 +1,5 @@
1
+ //#region src/shared/proxy.ts
2
+ const DEFAULT_PROXY_URL = "https://proxy.void.cloud";
3
+ const STAGING_PROXY_URL = "https://proxy.staging.void.cloud";
4
+ //#endregion
5
+ export { STAGING_PROXY_URL as n, DEFAULT_PROXY_URL as t };
@@ -1,5 +1,5 @@
1
1
  import { a as ensureUtc, i as dim, n as cliTitle, r as createSpinner, s as import_picocolors } from "./output-DeiS4oEX.mjs";
2
- import { c as getToken, n as PlatformClient } from "./client-CCOKwNUz.mjs";
2
+ import { c as getToken, n as PlatformClient } from "./client-DIfOFf1W.mjs";
3
3
  import { _ as me, c as R, g as ge, i as Ee, v as ue, x as q, y as ye } from "./dist-abzUneor.mjs";
4
4
  import { r as readProjectConfig } from "./project-CH9pdo16.mjs";
5
5
  //#region src/cli/rollback.ts
@@ -1,7 +1,7 @@
1
1
  import { a as join, n as dirname } from "./pathe.M-eThtNZ-BrPhGF_K.mjs";
2
2
  import { t as collectMigrations } from "./collect-9rO3JFNM.mjs";
3
3
  import { r as classifyMigration } from "./plan-aD3wRDqF.mjs";
4
- import { n as hasPackageDependency, r as readNearestPackageJson } from "./package-json-BMdypFnO.mjs";
4
+ import { n as hasPackageDependency, r as readNearestPackageJson } from "./package-json-B2TD0JLu.mjs";
5
5
  import { existsSync, mkdirSync } from "node:fs";
6
6
  import { createHash, createHmac } from "node:crypto";
7
7
  //#region src/migrations/runner.ts
@@ -1,102 +1,20 @@
1
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
- type ChatMessage = {
15
- role: "system" | "user" | "assistant";
16
- content: ChatContent;
17
- };
18
- type 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
- type ChatCompletionResponse = {
29
- id: string;
30
- object: string;
31
- created: number;
32
- model: string;
33
- choices: Array<ChatCompletionChoice>;
34
- usage: ChatCompletionUsage;
35
- };
36
- type ChatCompletionChoice = {
37
- index: number;
38
- message: ChatMessage;
39
- finish_reason: string;
40
- };
41
- type ChatCompletionUsage = {
42
- prompt_tokens: number;
43
- completion_tokens: number;
44
- total_tokens: number;
45
- };
46
- type 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";
2
+ type AiProviderName = "openai" | "anthropic" | "google-ai-studio" | "groq" | "mistral" | "grok" | "deepseek" | "openrouter" | "perplexity" | "cohere" | "cerebras" | "huggingface" | "replicate" | "baseten" | "cartesia" | "deepgram" | "elevenlabs" | "fal" | "ideogram" | "parallel";
3
+ type AiProvider = AiProviderName | (string & {});
58
4
  type ImageFileInput = Blob | ArrayBuffer | ArrayBufferView | {
59
5
  data: string;
60
6
  name?: string;
61
7
  type?: string;
62
8
  };
63
- type 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
- type ImageGenerationData = {
73
- url?: string;
74
- b64_json?: string;
75
- revised_prompt?: string;
76
- };
77
- type ImageGenerationResponse = {
78
- created?: number;
79
- data: Array<ImageGenerationData>;
80
- usage?: unknown;
81
- [key: string]: unknown;
82
- };
83
- type ImageGenerationOptions = {
84
- endpoint?: "images/generations";
85
- [key: string]: unknown;
86
- };
87
- type ImageEditOptions = {
88
- endpoint: "images/edits";
89
- [key: string]: unknown;
9
+ type AiProviderOptions = {
10
+ apiKeyEnv?: string;
11
+ apiKeyHeader?: string;
12
+ apiKeyPrefix?: string;
90
13
  };
91
- type 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;
14
+ type AiProviderFetchInit = {
15
+ method?: string;
16
+ headers?: HeadersInit;
17
+ body?: unknown;
100
18
  };
101
19
  //#endregion
102
20
  //#region src/runtime/ai.d.ts
@@ -107,14 +25,16 @@ type ImageEditInputs = {
107
25
  * in a `Response` with SSE headers — ready to return from a route handler.
108
26
  */
109
27
  type VoidAi = Omit<Ai, "run"> & {
110
- /** Workers AI inference (existing) */run<Name extends keyof AiModels>(model: Name, inputs: AiModels[Name]["inputs"], options?: AiOptions): Promise<AiModels[Name]["postProcessedOutputs"]>; /** Third-party chat completions (OpenAI, Anthropic, etc.) */
111
- run(model: ThirdPartyModel, inputs: ChatCompletionInputs, options?: AiOptions): Promise<ChatCompletionResponse>; /** Image generation. Returns the proxy response so callers can return or parse it. */
112
- image<Name extends keyof AiModels>(model: Name, inputs: AiModels[Name]["inputs"], options?: ImageGenerationOptions): Promise<Response>; /** Third-party image generation or editing through AI Gateway. */
113
- image(model: ThirdPartyModel, inputs: ImageEditInputs, options: ImageEditOptions): Promise<Response>; /** Third-party image generation through AI Gateway. */
114
- image(model: ThirdPartyModel, inputs: ImageGenerationInputs, options?: ImageGenerationOptions): Promise<Response>; /** Stream Workers AI response as SSE */
115
- stream<Name extends keyof AiModels>(model: Name, inputs: Omit<AiModels[Name]["inputs"], "stream">, options?: AiOptions): Promise<Response>; /** Stream third-party chat completions as SSE */
116
- stream(model: ThirdPartyModel, inputs: Omit<ChatCompletionInputs, "stream">, options?: AiOptions): Promise<Response>;
28
+ /** Workers AI inference (existing) */run<Name extends keyof AiModels>(model: Name, inputs: AiModels[Name]["inputs"], options?: AiOptions): Promise<AiModels[Name]["postProcessedOutputs"]>; /** Cloudflare AI Gateway model inference. Accepts Cloudflare model IDs unchanged. */
29
+ run(model: string, inputs: unknown, options?: AiOptions): Promise<unknown>; /** Image generation. Returns the proxy response so callers can return or parse it. */
30
+ image<Name extends keyof AiModels>(model: Name, inputs: AiModels[Name]["inputs"], options?: AiOptions): Promise<Response>; /** Cloudflare AI Gateway model inference returned as a Response. */
31
+ image(model: string, inputs: unknown, options?: AiOptions): Promise<Response>; /** Provider-native AI Gateway requests using a project secret for the provider API key. */
32
+ provider(provider: AiProvider, options?: AiProviderOptions): {
33
+ fetch(path: string, init?: AiProviderFetchInit): Promise<Response>;
34
+ }; /** Stream Workers AI response as SSE */
35
+ stream<Name extends keyof AiModels>(model: Name, inputs: Omit<AiModels[Name]["inputs"], "stream">, options?: AiOptions): Promise<Response>; /** Stream any Cloudflare AI Gateway model response as SSE */
36
+ stream(model: string, inputs: Record<string, unknown>, options?: AiOptions): Promise<Response>;
117
37
  };
118
38
  declare const ai: VoidAi;
119
39
  //#endregion
120
- 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 };
40
+ export { type AiProvider, type AiProviderFetchInit, type AiProviderName, type AiProviderOptions, type ImageFileInput, VoidAi, ai };
@@ -1,5 +1,5 @@
1
1
  import { t as cfAccessHeaders } from "../cf-access-DKDsgwOU.mjs";
2
- import { i as getRawRuntimeEnv } from "../env-raw-DhK_myJu.mjs";
2
+ import { i as getRawRuntimeEnv } from "../env-raw-RDkMnSTC.mjs";
3
3
  //#region src/runtime/ai-types.ts
4
4
  /** Maps provider prefix to expected env var name for the API key */
5
5
  const PROVIDER_KEY_MAP = {
@@ -32,9 +32,6 @@ const VOID_FILE_MARKER = "__voidFile";
32
32
  function hasStreamFlag(value) {
33
33
  return typeof value === "object" && value !== null && "stream" in value;
34
34
  }
35
- function isThirdPartyModel(model) {
36
- return model.split("/")[0] in PROVIDER_KEY_MAP;
37
- }
38
35
  function mediaTypeFromContentType(contentType) {
39
36
  if (!contentType) return null;
40
37
  const [mediaType] = contentType.split(";", 1);
@@ -109,8 +106,70 @@ async function serializeProxyValue(value, serializeDataObjectAsFile = false) {
109
106
  }
110
107
  return value;
111
108
  }
112
- async function serializeImageInputs(inputs, endpoint) {
113
- return endpoint === "images/edits" ? serializeProxyValue(inputs) : inputs;
109
+ function formFileName(value, fallback) {
110
+ return fileNameFromBlob(value) ?? fallback;
111
+ }
112
+ async function serializeFormData(form) {
113
+ const entries = [];
114
+ for (const [name, value] of form.entries()) {
115
+ if (typeof value === "string") {
116
+ entries.push({
117
+ name,
118
+ value
119
+ });
120
+ continue;
121
+ }
122
+ entries.push({
123
+ name,
124
+ value: {
125
+ [VOID_FILE_MARKER]: true,
126
+ data: arrayBufferToBase64(await value.arrayBuffer()),
127
+ name: formFileName(value, name),
128
+ type: value.type || void 0
129
+ }
130
+ });
131
+ }
132
+ return {
133
+ type: "form",
134
+ entries
135
+ };
136
+ }
137
+ async function serializeProviderBody(body) {
138
+ if (body === void 0 || body === null) return { type: "none" };
139
+ if (typeof body === "string") return {
140
+ type: "text",
141
+ data: body
142
+ };
143
+ if (body instanceof URLSearchParams) return {
144
+ type: "text",
145
+ data: body.toString(),
146
+ contentType: "application/x-www-form-urlencoded;charset=UTF-8"
147
+ };
148
+ if (body instanceof FormData) return serializeFormData(body);
149
+ if (body instanceof Blob) return {
150
+ type: "base64",
151
+ data: arrayBufferToBase64(await body.arrayBuffer()),
152
+ contentType: body.type || void 0
153
+ };
154
+ if (body instanceof ArrayBuffer) return {
155
+ type: "base64",
156
+ data: arrayBufferToBase64(body)
157
+ };
158
+ if (isBinaryView(body)) return {
159
+ type: "base64",
160
+ data: arrayBufferToBase64(copyBinaryView(body))
161
+ };
162
+ return {
163
+ type: "json",
164
+ value: await serializeProxyValue(body)
165
+ };
166
+ }
167
+ function headersToRecord(headers) {
168
+ if (!headers) return;
169
+ const result = {};
170
+ const normalized = new Headers(headers);
171
+ for (const [key, value] of normalized.entries()) result[key] = value;
172
+ return result;
114
173
  }
115
174
  async function responseFromResult(result) {
116
175
  if (result instanceof Response) return result;
@@ -132,9 +191,8 @@ function splitImageOptions(options) {
132
191
  runOptions: Object.keys(runOptions).length > 0 ? runOptions : void 0
133
192
  };
134
193
  }
135
- function resolveProviderKey(model, runtimeEnv) {
136
- const provider = model.split("/")[0];
137
- const envVar = PROVIDER_KEY_MAP[provider];
194
+ function resolveProviderKey(provider, runtimeEnv, options) {
195
+ const envVar = options?.apiKeyEnv ?? PROVIDER_KEY_MAP[provider];
138
196
  if (!envVar) throw new Error(`ai: Unknown provider '${provider}'. Use one of: ${Object.keys(PROVIDER_KEY_MAP).join(", ")}.`);
139
197
  const key = runtimeEnv[envVar];
140
198
  if (typeof key !== "string" || key.length === 0) throw new Error(`ai: Missing ${envVar} secret. Add it as a project secret for provider '${provider}'.`);
@@ -159,6 +217,7 @@ function resolveBackend() {
159
217
  const { runOptions } = splitImageOptions(options);
160
218
  return responseFromResult(await directAi.run(model, inputs, runOptions));
161
219
  },
220
+ providerFetch: unsupportedProviderFetch,
162
221
  models: directAi.models.bind(directAi),
163
222
  toMarkdown: directAi.toMarkdown?.bind(directAi) ?? unsupported("toMarkdown")
164
223
  };
@@ -169,8 +228,23 @@ function unsupported(method) {
169
228
  throw new Error(`ai: ai.${method}() is not supported in this environment.`);
170
229
  };
171
230
  }
231
+ function unsupportedProviderFetch() {
232
+ throw new Error("ai: ai.provider().fetch() is not supported in this environment.");
233
+ }
234
+ async function providerRequestBody(provider, path, init, options, runtimeEnv) {
235
+ return {
236
+ provider,
237
+ path,
238
+ method: init?.method,
239
+ headers: headersToRecord(init?.headers),
240
+ body: await serializeProviderBody(init?.body),
241
+ providerKey: resolveProviderKey(provider, runtimeEnv, options),
242
+ apiKeyHeader: options?.apiKeyHeader,
243
+ apiKeyPrefix: options?.apiKeyPrefix
244
+ };
245
+ }
172
246
  function makeServiceBindingBackend(proxy, runtimeEnv) {
173
- async function proxyFetch(action, body) {
247
+ async function proxyFetch(action, body, options = {}) {
174
248
  const res = await proxy.fetch(`https://ai-proxy/ai/${action}`, {
175
249
  method: "POST",
176
250
  headers: { "content-type": "application/json" },
@@ -179,7 +253,7 @@ function makeServiceBindingBackend(proxy, runtimeEnv) {
179
253
  ...body
180
254
  })
181
255
  });
182
- if (!res.ok) {
256
+ if (options.throwOnError !== false && !res.ok) {
183
257
  const text = await res.text();
184
258
  throw new Error(`ai: Proxy request failed with ${res.status}: '${text}'.`);
185
259
  }
@@ -189,17 +263,6 @@ function makeServiceBindingBackend(proxy, runtimeEnv) {
189
263
  async run(model, inputs, options) {
190
264
  const projectId = runtimeEnv.__PROJECT_ID;
191
265
  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
266
  const res = await proxyFetch("run", {
204
267
  model,
205
268
  inputs,
@@ -213,18 +276,7 @@ function makeServiceBindingBackend(proxy, runtimeEnv) {
213
276
  async image(model, inputs, options) {
214
277
  const projectId = runtimeEnv.__PROJECT_ID;
215
278
  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
- }
279
+ const { runOptions } = splitImageOptions(options);
228
280
  return proxyFetch("run", {
229
281
  model,
230
282
  inputs,
@@ -233,6 +285,15 @@ function makeServiceBindingBackend(proxy, runtimeEnv) {
233
285
  aiToken
234
286
  });
235
287
  },
288
+ async providerFetch(provider, path, init, options) {
289
+ const projectId = runtimeEnv.__PROJECT_ID;
290
+ const aiToken = runtimeEnv.__VOID_PROXY_TOKEN;
291
+ return proxyFetch("provider", {
292
+ ...await providerRequestBody(provider, path, init, options, runtimeEnv),
293
+ projectId,
294
+ aiToken
295
+ }, { throwOnError: false });
296
+ },
236
297
  async models(params) {
237
298
  const projectId = runtimeEnv.__PROJECT_ID;
238
299
  const aiToken = runtimeEnv.__VOID_PROXY_TOKEN;
@@ -261,7 +322,7 @@ function makeHttpBackend(token, projectId, runtimeEnv) {
261
322
  authorization: `Bearer ${token}`,
262
323
  ...cfAccessHeaders(runtimeEnv)
263
324
  };
264
- async function proxyFetch(action, body) {
325
+ async function proxyFetch(action, body, options = {}) {
265
326
  const res = await fetch(`${base}/${action}`, {
266
327
  method: "POST",
267
328
  headers,
@@ -271,7 +332,7 @@ function makeHttpBackend(token, projectId, runtimeEnv) {
271
332
  projectId
272
333
  })
273
334
  });
274
- if (!res.ok) {
335
+ if (options.throwOnError !== false && !res.ok) {
275
336
  const text = await res.text();
276
337
  throw new Error(`ai: Proxy request failed with ${res.status}: '${text}'.`);
277
338
  }
@@ -279,15 +340,6 @@ function makeHttpBackend(token, projectId, runtimeEnv) {
279
340
  }
280
341
  return {
281
342
  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
343
  const res = await proxyFetch("run", {
292
344
  model,
293
345
  inputs,
@@ -297,22 +349,16 @@ function makeHttpBackend(token, projectId, runtimeEnv) {
297
349
  return readProxyResult(res);
298
350
  },
299
351
  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
- }
352
+ const { runOptions } = splitImageOptions(options);
310
353
  return proxyFetch("run", {
311
354
  model,
312
355
  inputs,
313
356
  options: runOptions
314
357
  });
315
358
  },
359
+ async providerFetch(provider, path, init, options) {
360
+ return proxyFetch("provider", await providerRequestBody(provider, path, init, options, runtimeEnv), { throwOnError: false });
361
+ },
316
362
  async models(params) {
317
363
  return (await proxyFetch("models", { inputs: params })).json();
318
364
  },
@@ -341,6 +387,7 @@ const ai = new Proxy({}, { get(_, prop) {
341
387
  };
342
388
  if (prop === "run") return backend().run;
343
389
  if (prop === "image") return backend().image;
390
+ if (prop === "provider") return (provider, options) => ({ fetch: (path, init) => backend().providerFetch(provider, path, init, options) });
344
391
  if (prop === "models") return backend().models;
345
392
  if (prop === "toMarkdown") return backend().toMarkdown;
346
393
  } });
@@ -1,2 +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-BL0cU_Sy.mjs";
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-CDeb2XAl.mjs";
2
2
  export { AuthSession, AuthState, AuthUser, VoidAuthConfig, VoidAuthConfigContext, authContext, defineAuth, getSession, getUser, requireAuth };
@@ -1,4 +1,4 @@
1
- import { i as VoidAuthRuntimeOptions, n as VoidAuthEnv, r as VoidAuthRuntimeApi, t as VoidAuthDialect } from "../better-auth-shared-BxcgLiHN.mjs";
1
+ import { i as VoidAuthRuntimeOptions, n as VoidAuthEnv, r as VoidAuthRuntimeApi, t as VoidAuthDialect } from "../better-auth-shared-CmEQZs1T.mjs";
2
2
 
3
3
  //#region src/runtime/better-auth-pg.d.ts
4
4
  declare const resolveVoidAuthOptions: VoidAuthRuntimeApi["resolveVoidAuthOptions"];
@@ -1,6 +1,6 @@
1
- import { t as applyPgAuthMigrations } from "../auth-migrations-DBoTUBvq.mjs";
2
- import { t as createVoidAuthRuntime } from "../better-auth-shared-pR54mTD2.mjs";
3
- import { t as disablePgPassFallback } from "../pg-C-ybKyFU.mjs";
1
+ import { t as applyPgAuthMigrations } from "../auth-migrations-CuQkjjWE.mjs";
2
+ import { t as createVoidAuthRuntime } from "../better-auth-shared-ChVbrq52.mjs";
3
+ import { t as disablePgPassFallback } from "../pg-CMZ_5wsC.mjs";
4
4
  //#region src/runtime/better-auth-pg.ts
5
5
  function resolveConnectionString(env) {
6
6
  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;
@@ -1,4 +1,4 @@
1
- import { i as VoidAuthRuntimeOptions, n as VoidAuthEnv, r as VoidAuthRuntimeApi, t as VoidAuthDialect } from "../better-auth-shared-BxcgLiHN.mjs";
1
+ import { i as VoidAuthRuntimeOptions, n as VoidAuthEnv, r as VoidAuthRuntimeApi, t as VoidAuthDialect } from "../better-auth-shared-CmEQZs1T.mjs";
2
2
 
3
3
  //#region src/runtime/better-auth.d.ts
4
4
  declare const resolveVoidAuthOptions: VoidAuthRuntimeApi["resolveVoidAuthOptions"];
@@ -1,5 +1,5 @@
1
- import { n as applySqliteAuthMigrations } from "../auth-migrations-DBoTUBvq.mjs";
2
- import { t as createVoidAuthRuntime } from "../better-auth-shared-pR54mTD2.mjs";
1
+ import { n as applySqliteAuthMigrations } from "../auth-migrations-CuQkjjWE.mjs";
2
+ import { t as createVoidAuthRuntime } from "../better-auth-shared-ChVbrq52.mjs";
3
3
  //#region src/runtime/better-auth.ts
4
4
  async function resolveDatabase(env) {
5
5
  if (!env.DB) throw new Error("auth: Better Auth requires the \"DB\" D1 binding for sqlite apps.");
@@ -1,6 +1,6 @@
1
- import { n as AuthState, r as AuthUser, t as AuthSession } from "../auth-BL0cU_Sy.mjs";
1
+ import { n as AuthState, r as AuthUser, t as AuthSession } from "../auth-CDeb2XAl.mjs";
2
2
  import { auth, createAuthClient } from "./auth-client-react.mjs";
3
- import { t as FetchError } from "../fetch-error-Dn-En6Wg.mjs";
3
+ import { t as FetchError } from "../fetch-error-CimrygMq.mjs";
4
4
  import { fetch } from "./fetch.mjs";
5
5
  import { fetchStream } from "./fetch-stream.mjs";
6
6
  export { type AuthSession, type AuthState, type AuthUser, FetchError, FetchError as StreamError, auth, createAuthClient, fetch, fetchStream };
@@ -1,4 +1,4 @@
1
- import { t as FetchError } from "../fetch-error-B8GTcrQw.mjs";
1
+ import { t as FetchError } from "../fetch-error-BFIoojjf.mjs";
2
2
  import { fetch } from "./fetch.mjs";
3
3
  import { fetchStream } from "./fetch-stream.mjs";
4
4
  import { auth, createAuthClient } from "./auth-client-react.mjs";
@@ -1,6 +1,6 @@
1
- import { n as AuthState, r as AuthUser, t as AuthSession } from "../auth-BL0cU_Sy.mjs";
1
+ import { n as AuthState, r as AuthUser, t as AuthSession } from "../auth-CDeb2XAl.mjs";
2
2
  import { auth, createAuthClient } from "./auth-client-solid.mjs";
3
- import { t as FetchError } from "../fetch-error-Dn-En6Wg.mjs";
3
+ import { t as FetchError } from "../fetch-error-CimrygMq.mjs";
4
4
  import { fetch } from "./fetch.mjs";
5
5
  import { fetchStream } from "./fetch-stream.mjs";
6
6
  export { type AuthSession, type AuthState, type AuthUser, FetchError, FetchError as StreamError, auth, createAuthClient, fetch, fetchStream };
@@ -1,4 +1,4 @@
1
- import { t as FetchError } from "../fetch-error-B8GTcrQw.mjs";
1
+ import { t as FetchError } from "../fetch-error-BFIoojjf.mjs";
2
2
  import { fetch } from "./fetch.mjs";
3
3
  import { fetchStream } from "./fetch-stream.mjs";
4
4
  import { auth, createAuthClient } from "./auth-client-solid.mjs";
@@ -1,6 +1,6 @@
1
- import { n as AuthState, r as AuthUser, t as AuthSession } from "../auth-BL0cU_Sy.mjs";
1
+ import { n as AuthState, r as AuthUser, t as AuthSession } from "../auth-CDeb2XAl.mjs";
2
2
  import { auth, createAuthClient } from "./auth-client-svelte.mjs";
3
- import { t as FetchError } from "../fetch-error-Dn-En6Wg.mjs";
3
+ import { t as FetchError } from "../fetch-error-CimrygMq.mjs";
4
4
  import { fetch } from "./fetch.mjs";
5
5
  import { fetchStream } from "./fetch-stream.mjs";
6
6
  export { type AuthSession, type AuthState, type AuthUser, FetchError, FetchError as StreamError, auth, createAuthClient, fetch, fetchStream };
@@ -1,4 +1,4 @@
1
- import { t as FetchError } from "../fetch-error-B8GTcrQw.mjs";
1
+ import { t as FetchError } from "../fetch-error-BFIoojjf.mjs";
2
2
  import { fetch } from "./fetch.mjs";
3
3
  import { fetchStream } from "./fetch-stream.mjs";
4
4
  import { auth, createAuthClient } from "./auth-client-svelte.mjs";
@@ -1,6 +1,6 @@
1
- import { n as AuthState, r as AuthUser, t as AuthSession } from "../auth-BL0cU_Sy.mjs";
1
+ import { n as AuthState, r as AuthUser, t as AuthSession } from "../auth-CDeb2XAl.mjs";
2
2
  import { auth, createAuthClient } from "./auth-client-vue.mjs";
3
- import { t as FetchError } from "../fetch-error-Dn-En6Wg.mjs";
3
+ import { t as FetchError } from "../fetch-error-CimrygMq.mjs";
4
4
  import { fetch } from "./fetch.mjs";
5
5
  import { fetchStream } from "./fetch-stream.mjs";
6
6
  export { type AuthSession, type AuthState, type AuthUser, FetchError, FetchError as StreamError, auth, createAuthClient, fetch, fetchStream };
@@ -1,4 +1,4 @@
1
- import { t as FetchError } from "../fetch-error-B8GTcrQw.mjs";
1
+ import { t as FetchError } from "../fetch-error-BFIoojjf.mjs";
2
2
  import { fetch } from "./fetch.mjs";
3
3
  import { fetchStream } from "./fetch-stream.mjs";
4
4
  import { auth, createAuthClient } from "./auth-client-vue.mjs";
@@ -1,6 +1,6 @@
1
- import { n as AuthState, r as AuthUser, t as AuthSession } from "../auth-BL0cU_Sy.mjs";
1
+ import { n as AuthState, r as AuthUser, t as AuthSession } from "../auth-CDeb2XAl.mjs";
2
2
  import { auth, createAuthClient } from "./auth-client.mjs";
3
- import { t as FetchError } from "../fetch-error-Dn-En6Wg.mjs";
3
+ import { t as FetchError } from "../fetch-error-CimrygMq.mjs";
4
4
  import { fetch } from "./fetch.mjs";
5
5
  import { fetchStream } from "./fetch-stream.mjs";
6
6
  export { type AuthSession, type AuthState, type AuthUser, FetchError, FetchError as StreamError, auth, createAuthClient, fetch, fetchStream };
@@ -1,4 +1,4 @@
1
- import { t as FetchError } from "../fetch-error-B8GTcrQw.mjs";
1
+ import { t as FetchError } from "../fetch-error-BFIoojjf.mjs";
2
2
  import { fetch } from "./fetch.mjs";
3
3
  import { fetchStream } from "./fetch-stream.mjs";
4
4
  import { auth, createAuthClient } from "./auth-client.mjs";
@@ -1,2 +1,2 @@
1
- import { a as getSecretOverride, c as oneOf, i as email, l as string, n as SECRET_OVERRIDE_SYMBOL, o as json, r as boolean, s as number, t as EnvSchema, u as url } from "../env-helpers-bupZjGHq.mjs";
1
+ import { a as getSecretOverride, c as oneOf, i as email, l as string, n as SECRET_OVERRIDE_SYMBOL, o as json, r as boolean, s as number, t as EnvSchema, u as url } from "../env-helpers-Bd2wVdxz.mjs";
2
2
  export { EnvSchema, SECRET_OVERRIDE_SYMBOL, boolean, email, getSecretOverride, json, number, oneOf, string, url };
@@ -1,4 +1,4 @@
1
- import { c as oneOf, i as email, l as string, o as json, r as boolean, s as number, t as EnvSchema, u as url } from "../env-helpers-bupZjGHq.mjs";
1
+ import { c as oneOf, i as email, l as string, o as json, r as boolean, s as number, t as EnvSchema, u as url } from "../env-helpers-Bd2wVdxz.mjs";
2
2
 
3
3
  //#region src/runtime/env-public-client.d.ts
4
4
  declare const env: Record<string, unknown>;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="@cloudflare/workers-types" />
2
- import { t as StandardSchemaV1 } from "../standard-schema-DCIm8cwQ.mjs";
3
- import { c as oneOf, i as email, l as string, o as json, r as boolean, s as number, t as EnvSchema, u as url } from "../env-helpers-bupZjGHq.mjs";
2
+ import { t as StandardSchemaV1 } from "../standard-schema-Dnsh2vnl.mjs";
3
+ import { c as oneOf, i as email, l as string, o as json, r as boolean, s as number, t as EnvSchema, u as url } from "../env-helpers-Bd2wVdxz.mjs";
4
4
  import * as _$_cloudflare_sandbox0 from "@cloudflare/sandbox";
5
5
 
6
6
  //#region src/runtime/env-public.d.ts
@@ -1,4 +1,4 @@
1
- import { i as getRawRuntimeEnv } from "../env-raw-DhK_myJu.mjs";
1
+ import { i as getRawRuntimeEnv } from "../env-raw-RDkMnSTC.mjs";
2
2
  import { getRuntimeEnv } from "./env.mjs";
3
3
  import { boolean, email, getSecretOverride, json, number, oneOf, string, url } from "./env-helpers.mjs";
4
4
  //#region src/shared/env-mask.ts