@every-app/sdk 0.3.0-rc.1 → 0.3.0-rc.11

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 (181) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +62 -64
  3. package/dist/cloudflare/catalogSettings.generated.d.ts +84 -0
  4. package/dist/cloudflare/catalogSettings.generated.d.ts.map +1 -0
  5. package/dist/cloudflare/catalogSettings.generated.js +175 -0
  6. package/dist/cloudflare/index.d.ts +3 -2
  7. package/dist/cloudflare/index.d.ts.map +1 -1
  8. package/dist/cloudflare/index.js +4 -1
  9. package/dist/cloudflare/sentinel.d.ts +60 -2
  10. package/dist/cloudflare/sentinel.d.ts.map +1 -1
  11. package/dist/cloudflare/sentinel.js +37 -2
  12. package/dist/cloudflare/worker.d.ts +391 -63
  13. package/dist/cloudflare/worker.d.ts.map +1 -1
  14. package/dist/cloudflare/worker.js +394 -108
  15. package/dist/dev/index.d.ts +1 -1
  16. package/dist/dev/index.d.ts.map +1 -1
  17. package/dist/dev/index.js +1 -1
  18. package/dist/dev/keypair.d.ts +2 -0
  19. package/dist/dev/keypair.d.ts.map +1 -1
  20. package/dist/dev/keypair.js +2 -0
  21. package/dist/index.d.ts +6 -0
  22. package/dist/index.d.ts.map +1 -0
  23. package/dist/index.js +5 -0
  24. package/dist/internal/aiDefault.d.ts +205 -0
  25. package/dist/internal/aiDefault.d.ts.map +1 -0
  26. package/dist/internal/aiDefault.js +335 -0
  27. package/dist/internal/aiProviders.d.ts +7 -2
  28. package/dist/internal/aiProviders.d.ts.map +1 -1
  29. package/dist/internal/aiProviders.js +19 -6
  30. package/dist/internal/appSettings.d.ts +82 -4
  31. package/dist/internal/appSettings.d.ts.map +1 -1
  32. package/dist/internal/appSettings.js +204 -29
  33. package/dist/internal/audit.d.ts +108 -0
  34. package/dist/internal/audit.d.ts.map +1 -0
  35. package/dist/internal/audit.js +235 -0
  36. package/dist/internal/capabilities.d.ts +2261 -815
  37. package/dist/internal/capabilities.d.ts.map +1 -1
  38. package/dist/internal/capabilities.js +122 -1034
  39. package/dist/internal/catalog/commerce.d.ts +394 -0
  40. package/dist/internal/catalog/commerce.d.ts.map +1 -0
  41. package/dist/internal/catalog/commerce.js +477 -0
  42. package/dist/internal/catalog/comms.d.ts +375 -0
  43. package/dist/internal/catalog/comms.d.ts.map +1 -0
  44. package/dist/internal/catalog/comms.js +520 -0
  45. package/dist/internal/catalog/index.d.ts +2008 -0
  46. package/dist/internal/catalog/index.d.ts.map +1 -0
  47. package/dist/internal/catalog/index.js +19 -0
  48. package/dist/internal/catalog/inference.d.ts +393 -0
  49. package/dist/internal/catalog/inference.d.ts.map +1 -0
  50. package/dist/internal/catalog/inference.js +460 -0
  51. package/dist/internal/catalog/infra.d.ts +458 -0
  52. package/dist/internal/catalog/infra.d.ts.map +1 -0
  53. package/dist/internal/catalog/infra.js +608 -0
  54. package/dist/internal/catalog/search.d.ts +400 -0
  55. package/dist/internal/catalog/search.d.ts.map +1 -0
  56. package/dist/internal/catalog/search.js +463 -0
  57. package/dist/internal/devProviders.d.ts +2 -2
  58. package/dist/internal/devProviders.d.ts.map +1 -1
  59. package/dist/internal/devProviders.js +19 -1
  60. package/dist/internal/events.d.ts +65 -3
  61. package/dist/internal/events.d.ts.map +1 -1
  62. package/dist/internal/events.js +110 -5
  63. package/dist/internal/gatewaySettings.d.ts +3 -2
  64. package/dist/internal/gatewaySettings.d.ts.map +1 -1
  65. package/dist/internal/gatewaySettings.js +12 -6
  66. package/dist/internal/identity.d.ts +41 -4
  67. package/dist/internal/identity.d.ts.map +1 -1
  68. package/dist/internal/identity.js +48 -10
  69. package/dist/internal/index.d.ts +6 -1
  70. package/dist/internal/index.d.ts.map +1 -1
  71. package/dist/internal/index.js +6 -1
  72. package/dist/internal/members.d.ts +3 -2
  73. package/dist/internal/members.d.ts.map +1 -1
  74. package/dist/internal/oauthBuiltIns.d.ts +101 -0
  75. package/dist/internal/oauthBuiltIns.d.ts.map +1 -0
  76. package/dist/internal/oauthBuiltIns.js +122 -0
  77. package/dist/internal/oauthClient.d.ts +8 -50
  78. package/dist/internal/oauthClient.d.ts.map +1 -1
  79. package/dist/internal/oauthClient.js +2 -177
  80. package/dist/internal/oauthPresets.d.ts +32 -0
  81. package/dist/internal/oauthPresets.d.ts.map +1 -0
  82. package/dist/internal/oauthPresets.js +253 -0
  83. package/dist/internal/oauthScopes.d.ts +43 -100
  84. package/dist/internal/oauthScopes.d.ts.map +1 -1
  85. package/dist/internal/oauthScopes.js +83 -382
  86. package/dist/internal/oauthSpec.d.ts +103 -0
  87. package/dist/internal/oauthSpec.d.ts.map +1 -0
  88. package/dist/internal/oauthSpec.js +520 -0
  89. package/dist/internal/protocol.d.ts +97 -5
  90. package/dist/internal/protocol.d.ts.map +1 -1
  91. package/dist/internal/protocol.js +89 -1
  92. package/dist/internal/providerRegistry.d.ts +17 -6
  93. package/dist/internal/providerRegistry.d.ts.map +1 -1
  94. package/dist/internal/providerRegistry.js +71 -8
  95. package/dist/internal/providerSpec.d.ts +18 -7
  96. package/dist/internal/providerSpec.d.ts.map +1 -1
  97. package/dist/internal/providerSpec.js +420 -34
  98. package/dist/internal/remoteMcp.d.ts.map +1 -1
  99. package/dist/internal/remoteMcp.js +1 -5
  100. package/dist/internal/signInProviders.d.ts +104 -0
  101. package/dist/internal/signInProviders.d.ts.map +1 -0
  102. package/dist/internal/signInProviders.js +245 -0
  103. package/dist/internal/tools.d.ts +5 -4
  104. package/dist/internal/tools.d.ts.map +1 -1
  105. package/dist/internal/tools.js +4 -3
  106. package/dist/manifest.d.ts +267 -0
  107. package/dist/manifest.d.ts.map +1 -0
  108. package/dist/manifest.js +30 -0
  109. package/dist/server/ai.d.ts +111 -0
  110. package/dist/server/ai.d.ts.map +1 -0
  111. package/dist/server/ai.js +145 -0
  112. package/dist/server/aiBinding.d.ts +68 -0
  113. package/dist/server/aiBinding.d.ts.map +1 -0
  114. package/dist/server/aiBinding.js +294 -0
  115. package/dist/server/attribution.d.ts +18 -5
  116. package/dist/server/attribution.d.ts.map +1 -1
  117. package/dist/server/attribution.js +19 -5
  118. package/dist/server/connectUrl.d.ts +16 -0
  119. package/dist/server/connectUrl.d.ts.map +1 -0
  120. package/dist/server/connectUrl.js +40 -0
  121. package/dist/server/context.d.ts +68 -0
  122. package/dist/server/context.d.ts.map +1 -0
  123. package/dist/server/context.js +117 -0
  124. package/dist/server/emailBinding.d.ts +72 -0
  125. package/dist/server/emailBinding.d.ts.map +1 -0
  126. package/dist/server/emailBinding.js +124 -0
  127. package/dist/server/emit.d.ts +1 -1
  128. package/dist/server/emit.d.ts.map +1 -1
  129. package/dist/server/emit.js +7 -7
  130. package/dist/server/env.d.ts +44 -0
  131. package/dist/server/env.d.ts.map +1 -0
  132. package/dist/server/env.js +1 -0
  133. package/dist/server/eventsEndpoint.d.ts +48 -0
  134. package/dist/server/eventsEndpoint.d.ts.map +1 -0
  135. package/dist/server/eventsEndpoint.js +145 -0
  136. package/dist/server/everyApp.d.ts +40 -11
  137. package/dist/server/everyApp.d.ts.map +1 -1
  138. package/dist/server/everyApp.js +116 -6
  139. package/dist/server/fromMcpTools.d.ts +89 -0
  140. package/dist/server/fromMcpTools.d.ts.map +1 -0
  141. package/dist/server/fromMcpTools.js +192 -0
  142. package/dist/server/gatewayFetch.d.ts +42 -18
  143. package/dist/server/gatewayFetch.d.ts.map +1 -1
  144. package/dist/server/gatewayFetch.js +138 -19
  145. package/dist/server/gatewayUrl.d.ts +13 -0
  146. package/dist/server/gatewayUrl.d.ts.map +1 -0
  147. package/dist/server/gatewayUrl.js +34 -0
  148. package/dist/server/index.d.ts +16 -4
  149. package/dist/server/index.d.ts.map +1 -1
  150. package/dist/server/index.js +13 -3
  151. package/dist/server/integrationFetch.d.ts +92 -73
  152. package/dist/server/integrationFetch.d.ts.map +1 -1
  153. package/dist/server/integrationFetch.js +206 -319
  154. package/dist/server/listMembers.d.ts +1 -1
  155. package/dist/server/listMembers.d.ts.map +1 -1
  156. package/dist/server/listMembers.js +8 -11
  157. package/dist/server/refusal.d.ts +55 -0
  158. package/dist/server/refusal.d.ts.map +1 -0
  159. package/dist/server/refusal.js +193 -0
  160. package/dist/server/sendEmail.d.ts +1 -1
  161. package/dist/server/sendEmail.d.ts.map +1 -1
  162. package/dist/server/sendEmail.js +7 -7
  163. package/dist/server/tools.d.ts +7 -2
  164. package/dist/server/tools.d.ts.map +1 -1
  165. package/dist/server/tools.js +2 -1
  166. package/dist/server/toolsEndpoint.d.ts +3 -1
  167. package/dist/server/toolsEndpoint.d.ts.map +1 -1
  168. package/dist/server/toolsEndpoint.js +19 -7
  169. package/dist/server/webhooks.d.ts +56 -0
  170. package/dist/server/webhooks.d.ts.map +1 -0
  171. package/dist/server/webhooks.js +205 -0
  172. package/dist/tanstack-start/index.d.ts +9 -0
  173. package/dist/tanstack-start/index.d.ts.map +1 -0
  174. package/dist/tanstack-start/index.js +29 -0
  175. package/dist/testing/index.d.ts +93 -0
  176. package/dist/testing/index.d.ts.map +1 -0
  177. package/dist/testing/index.js +156 -0
  178. package/package.json +35 -14
  179. package/dist/server/authorizeUrl.d.ts +0 -43
  180. package/dist/server/authorizeUrl.d.ts.map +0 -1
  181. package/dist/server/authorizeUrl.js +0 -110
@@ -16,18 +16,40 @@ export const BUILD_SENTINEL = Object.freeze({
16
16
  // and a string rewrite of it can't hit anything else.
17
17
  workerName: "every-hosted--sentinel",
18
18
  organizationId: "everyapp-hosted-deploy-sentinel",
19
+ /**
20
+ * The Cloudflare account the app is installed in (an AI Gateway's URL
21
+ * holds it). Starts with the Worker name's placeholder, so an install
22
+ * rewrites it before that one.
23
+ */
24
+ accountId: "every-hosted--sentinel-account",
19
25
  /** The gateway's URL, and so the identity issuer. */
20
26
  gatewayUrl: "https://every-hosted--sentinel.invalid",
21
27
  publicKey: "-----BEGIN PUBLIC KEY-----\nEVERYAPPHOSTEDDEPLOYSENTINEL\n-----END PUBLIC KEY-----\n",
22
28
  });
29
+ /** Runtime-independent resource names used by both release installers. */
30
+ export function helperWorkerName(appWorker, helper) {
31
+ const name = `${appWorker}--${helper}`;
32
+ if (name.length > 63)
33
+ throw new Error(`Helper Worker ${name} is longer than Cloudflare's 63 characters; shorten its name in everyapp.config.ts.`);
34
+ return name;
35
+ }
36
+ export function workflowNameFor(workerName, binding) {
37
+ return `${workerName}--${binding.toLowerCase().replaceAll("_", "-")}`;
38
+ }
23
39
  /**
24
40
  * A manifest binding's placeholder: a D1 database's name and id, an R2
25
- * bucket's name, a KV namespace's or Hyperdrive config's id. The installer
26
- * rewrites each by its binding name; the value only has to be recognizable.
41
+ * bucket's, queue's or Vectorize index's name, a KV namespace's, Hyperdrive
42
+ * config's or AI Gateway's id, a Secrets Store secret's store id and name.
43
+ * The installer rewrites each by its binding name; the value only has to
44
+ * be recognizable.
27
45
  */
28
46
  export function resourceSentinel(binding) {
29
47
  return `${BUILD_SENTINEL.workerName}--${binding}`;
30
48
  }
49
+ /** Where an AI Gateway takes requests: `https://gateway.ai.cloudflare.com/v1/<account>/<id>`. */
50
+ export function aiGatewayUrl(accountId, id) {
51
+ return `https://gateway.ai.cloudflare.com/v1/${accountId}/${id}`;
52
+ }
31
53
  /** The target every production build is made for: placeholders throughout. */
32
54
  export function sentinelDeployTarget(manifest) {
33
55
  const byBinding = (bindings, value) => Object.fromEntries((bindings ?? []).map((binding) => [
@@ -38,6 +60,7 @@ export function sentinelDeployTarget(manifest) {
38
60
  return {
39
61
  workerName: BUILD_SENTINEL.workerName,
40
62
  organizationId: BUILD_SENTINEL.organizationId,
63
+ accountId: BUILD_SENTINEL.accountId,
41
64
  gatewayUrl: BUILD_SENTINEL.gatewayUrl,
42
65
  identityPublicKeys: [BUILD_SENTINEL.publicKey],
43
66
  resources: {
@@ -45,6 +68,18 @@ export function sentinelDeployTarget(manifest) {
45
68
  kv: byBinding(resources?.kv, (id) => ({ id })),
46
69
  hyperdrive: byBinding(resources?.hyperdrive?.map((config) => config.name), (id) => ({ id })),
47
70
  r2: byBinding(resources?.r2, (name) => ({ name })),
71
+ ...(resources?.queues?.length
72
+ ? {
73
+ queues: byBinding(resources.queues.map((queue) => queue.name), (name) => ({ name, id: name })),
74
+ }
75
+ : {}),
76
+ vectorize: byBinding(resources?.vectorize?.map((index) => index.name), (name) => ({ name })),
77
+ aiGateway: byBinding(resources?.aiGateway?.map((gateway) => gateway.name), (id) => ({
78
+ id,
79
+ accountId: BUILD_SENTINEL.accountId,
80
+ url: aiGatewayUrl(BUILD_SENTINEL.accountId, id),
81
+ })),
82
+ secretsStore: byBinding(resources?.secretsStore?.map((secret) => secret.name), (placeholder) => ({ storeId: placeholder, secretName: placeholder })),
48
83
  },
49
84
  };
50
85
  }
@@ -1,3 +1,6 @@
1
+ import { DEV_GATEWAY_KEYS } from "./catalogSettings.generated.js";
2
+ import { type AiGatewayValue } from "./sentinel.js";
3
+ export { helperWorkerName, workflowNameFor } from "./sentinel.js";
1
4
  /** A Durable Object or Workflow class, and the helper Worker defining it. */
2
5
  interface ClassResource {
3
6
  readonly name: string;
@@ -13,6 +16,62 @@ interface HyperdriveResource {
13
16
  /** Whether Hyperdrive caches its reads (the deploy's concern; "off" by default). */
14
17
  readonly caching?: "off" | "default";
15
18
  }
19
+ /**
20
+ * How a queue's consumer takes its messages (`@cloudflare/config`'s
21
+ * `QueueConsumerTriggerOptions` but the name), and the helper Worker that
22
+ * consumes, when not the app's own.
23
+ */
24
+ interface QueueConsumerSettings {
25
+ /** A helper Worker (`workers`) that consumes; the app's own when unset. */
26
+ readonly worker?: string;
27
+ readonly maxBatchSize?: number;
28
+ readonly maxBatchTimeout?: number;
29
+ readonly maxRetries?: number;
30
+ readonly maxConcurrency?: number | null;
31
+ readonly retryDelay?: number;
32
+ readonly visibilityTimeoutMs?: number;
33
+ /** Another of the manifest's queue bindings, which takes the messages that ran out of retries. */
34
+ readonly deadLetterQueue?: string;
35
+ }
36
+ /** A queue every Worker of the app produces to, and the Worker that consumes it. */
37
+ interface QueueResource {
38
+ readonly name: string;
39
+ /** `true`: the app's own Worker consumes; settings, maybe naming a helper Worker. */
40
+ readonly consumer?: true | QueueConsumerSettings;
41
+ }
42
+ /**
43
+ * A Vectorize index: `dimensions` and `metric`, or a `preset` (the
44
+ * deploy's concern; the Worker only binds it by name).
45
+ */
46
+ interface VectorizeResource {
47
+ readonly name: string;
48
+ readonly dimensions?: number;
49
+ readonly metric?: string;
50
+ readonly preset?: string;
51
+ }
52
+ /** An AI Gateway of the app's own, which every one of its Workers binds. */
53
+ interface AiGatewayResource {
54
+ readonly name: string;
55
+ /** Whether the gateway logs each request (the deploy's concern; on by default). */
56
+ readonly collectLogs?: boolean;
57
+ /** How long the gateway caches a response, in seconds (the deploy's concern; 0 by default). */
58
+ readonly cacheTtl?: number;
59
+ }
60
+ /**
61
+ * A Cloudflare `send_email` binding and the addresses it may use: the
62
+ * senders, and one destination or a list of them (never both).
63
+ */
64
+ interface SendEmailResource {
65
+ readonly name: string;
66
+ readonly allowedSenderAddresses?: readonly string[];
67
+ readonly destinationAddress?: string;
68
+ readonly allowedDestinationAddresses?: readonly string[];
69
+ }
70
+ /** An Analytics Engine dataset, by binding, and its name when not the default. */
71
+ interface AnalyticsEngineResource {
72
+ readonly name: string;
73
+ readonly dataset?: string;
74
+ }
16
75
  /** Cloudflare's limits for one of the app's Workers. */
17
76
  interface WorkerLimits {
18
77
  readonly cpuMs?: number;
@@ -33,6 +92,74 @@ export interface EveryAppWorkerManifest {
33
92
  workflows?: readonly ClassResource[];
34
93
  /** Hyperdrive configs, named `<app worker>--<binding>` by the deploy. */
35
94
  hyperdrive?: readonly HyperdriveResource[];
95
+ /**
96
+ * Cloudflare Queues, named `<app worker>--<binding>`: every Worker of
97
+ * the app binds each one to produce, and the consumer's Worker gets
98
+ * its trigger.
99
+ */
100
+ queues?: readonly QueueResource[];
101
+ /**
102
+ * Workers AI, by binding (`["AI"]`), which every one of the app's
103
+ * Workers binds: nothing to create, billed to the account. In
104
+ * development it reaches the account only once the app's Vite config
105
+ * turns `remoteBindings` on (see {@link AiBinding}).
106
+ */
107
+ ai?: readonly string[];
108
+ /**
109
+ * Browser Rendering, by binding (`["BROWSER"]`), which every one of the
110
+ * app's Workers binds: nothing to create (Workers Paid). Local in
111
+ * development (see {@link BrowserBinding}).
112
+ */
113
+ browser?: readonly string[];
114
+ /**
115
+ * Cloudflare Images, by binding (`["IMAGES"]`), which every one of the
116
+ * app's Workers binds: nothing to create. Local in development (see
117
+ * {@link ImagesBinding}).
118
+ */
119
+ images?: readonly string[];
120
+ /**
121
+ * Vectorize indexes every one of the app's Workers binds, named
122
+ * `<app worker>--<binding>`. Cloudflare has no local Vectorize: in
123
+ * development each binding reaches the account's index (`dev.remote`),
124
+ * once the Vite plugin's `remoteBindings` is on and `cf auth login` ran.
125
+ */
126
+ vectorize?: readonly VectorizeResource[];
127
+ /**
128
+ * AI Gateways of the app's own, each `<app worker>-<binding>` in the
129
+ * account, bound on every Worker as `{ id, accountId, url }`.
130
+ */
131
+ aiGateway?: readonly AiGatewayResource[];
132
+ /**
133
+ * Cloudflare `send_email` bindings every one of the app's Workers
134
+ * gets, with their addresses; nothing is made in the account.
135
+ */
136
+ sendEmail?: readonly SendEmailResource[];
137
+ /**
138
+ * Secrets Store secrets, by binding (`[{ name: "STRIPE_KEY" }]`), which
139
+ * every one of the app's Workers binds: each a secret in the account's
140
+ * store named `<app worker>--<binding>`, made by the deploy (see
141
+ * {@link SecretsStoreSecretBinding}).
142
+ */
143
+ secretsStore?: readonly {
144
+ readonly name: string;
145
+ }[];
146
+ /**
147
+ * Analytics Engine datasets every one of the app's Workers writes to, by
148
+ * binding: `dataset` as written, else `<app worker>--<binding>`.
149
+ * Nothing to create; `writeDataPoint()` does nothing in development.
150
+ */
151
+ analyticsEngine?: readonly AnalyticsEngineResource[];
152
+ /**
153
+ * Cloudflare Artifacts, by binding (`[{ name: "MEMORY" }]`), which every
154
+ * one of the app's Workers binds: git repos in the namespace
155
+ * `<app worker>--<binding>`, nothing to create. Cloudflare has no local
156
+ * Artifacts: in development each binding reaches the account's
157
+ * namespace of the dev Worker's name (`dev.remote`), once the Vite
158
+ * plugin's `remoteBindings` is on and `cf auth login` ran.
159
+ */
160
+ artifacts?: readonly {
161
+ readonly name: string;
162
+ }[];
36
163
  };
37
164
  /**
38
165
  * Helper Workers deployed beside the app's Worker as
@@ -86,6 +213,20 @@ export interface EveryAppWorkerManifest {
86
213
  secrets?: ReadonlyArray<string | {
87
214
  readonly name: string;
88
215
  }>;
216
+ /**
217
+ * The app's plain settings: values that aren't secrets and differ per
218
+ * install (a PostHog host, a region), as `{ name, why, type, values,
219
+ * default, optional }`. A deployed Worker holds them like its secrets
220
+ * (`everyapp configure <app>` sets them; the deploy writes each
221
+ * default nobody has set), so production builds don't declare them. In
222
+ * development each one set locally (`.dev.vars`, `.env`, as for
223
+ * secrets) is declared as a secret, and one that isn't, but has a
224
+ * default, as text with its default.
225
+ */
226
+ settings?: ReadonlyArray<{
227
+ readonly name: string;
228
+ readonly default?: string;
229
+ }>;
89
230
  }
90
231
  /** The context cf passes to a `defineConfig((ctx) => …)` factory. */
91
232
  export interface EveryAppConfigContext {
@@ -141,6 +282,121 @@ export interface HyperdriveBinding {
141
282
  connectionString?: string;
142
283
  };
143
284
  }
285
+ /** A producer binding to one of the app's queues. */
286
+ export interface QueueBinding {
287
+ type: "queue";
288
+ name: string;
289
+ }
290
+ /** A JSON value the Worker reads as it is: `env.<NAME>` is `value`. */
291
+ export interface JsonBinding<T = unknown> {
292
+ type: "json";
293
+ value: T;
294
+ }
295
+ /**
296
+ * An AI Gateway of the app's own (`resources.aiGateway`): its id, account
297
+ * and URL, which the Worker reads as `env.<NAME>.id` and `env.<NAME>.url`.
298
+ */
299
+ export type AiGatewayBinding = JsonBinding<AiGatewayValue>;
300
+ /**
301
+ * Workers AI (`env.AI.run()`), which cf types as `Ai`. Deployed, it calls
302
+ * the account's Workers AI. Miniflare has none locally: in development the
303
+ * binding is marked remote, so it reaches the account once the app's Vite
304
+ * config sets `remoteBindings: true` (the starter sets it false) and
305
+ * `cf auth login` has run; until then every call throws `Binding AI needs
306
+ * to be run remotely`.
307
+ */
308
+ export interface AiBinding {
309
+ type: "ai";
310
+ dev?: {
311
+ remote?: boolean;
312
+ };
313
+ }
314
+ /**
315
+ * Browser Rendering (`env.BROWSER`, for `@cloudflare/puppeteer` or
316
+ * `@cloudflare/playwright`), which cf types as `BrowserRun`. Deployed, it
317
+ * drives a headless Chrome on Cloudflare (Workers Paid). In development
318
+ * the same binding reaches Miniflare's local stand-in: the first session
319
+ * downloads a Chrome into the global `.wrangler` cache and starts it.
320
+ */
321
+ export interface BrowserBinding {
322
+ type: "browser";
323
+ }
324
+ /**
325
+ * Cloudflare Images (`env.IMAGES.input(stream).transform(…).output(…)`,
326
+ * `env.IMAGES.info(stream)`), which cf types as the runtime's
327
+ * `ImagesBinding`. Deployed, it runs on Cloudflare and bills the account's
328
+ * Images transformations. In development Miniflare answers it locally with
329
+ * sharp, which ships with it.
330
+ */
331
+ export interface ImagesBinding {
332
+ type: "images";
333
+ }
334
+ /**
335
+ * A Vectorize index, by name. `dev.remote` sends development calls to the
336
+ * account's index: Cloudflare has no local Vectorize.
337
+ */
338
+ export interface VectorizeBinding {
339
+ type: "vectorize";
340
+ name: string;
341
+ dev?: {
342
+ remote?: boolean;
343
+ };
344
+ }
345
+ /**
346
+ * A `send_email` binding (cf's `SendEmailBindingOptions`): one destination,
347
+ * a list of them, or neither, and the senders it may use.
348
+ */
349
+ type SendEmailDestination = {
350
+ destinationAddress: string;
351
+ allowedDestinationAddresses?: never;
352
+ } | {
353
+ destinationAddress?: never;
354
+ allowedDestinationAddresses: string[];
355
+ } | {
356
+ destinationAddress?: never;
357
+ allowedDestinationAddresses?: never;
358
+ };
359
+ export type SendEmailBinding = SendEmailDestination & {
360
+ type: "send-email";
361
+ allowedSenderAddresses?: string[];
362
+ };
363
+ /**
364
+ * A Secrets Store secret (`await env.STRIPE_KEY.get()`), which cf types as
365
+ * `SecretsStoreSecret`. Deployed, the secret the deploy made in the
366
+ * account's store; in development, the local store `local` that Miniflare
367
+ * keeps under `.cloudflare/state`, where `get()` throws `Secret "<name>"
368
+ * not found` until the secret is seeded there (`.dev.vars` doesn't reach
369
+ * this binding).
370
+ */
371
+ export interface SecretsStoreSecretBinding {
372
+ type: "secrets-store-secret";
373
+ storeId: string;
374
+ secretName: string;
375
+ }
376
+ /**
377
+ * An Analytics Engine dataset (`env.EVENTS.writeDataPoint({ blobs,
378
+ * doubles, indexes })`), which cf types as `AnalyticsEngineDataset`.
379
+ * Deployed, the dataset exists once written to. In development Miniflare
380
+ * accepts every write and keeps none. cf's shape takes no `dev` options.
381
+ */
382
+ export interface AnalyticsEngineDatasetBinding {
383
+ type: "analytics-engine-dataset";
384
+ name: string;
385
+ }
386
+ /**
387
+ * Cloudflare Artifacts (`await env.MEMORY.create("notes")`,
388
+ * `env.MEMORY.get("notes")`), which cf types as `Artifacts`: git repos in
389
+ * the namespace `<app worker>--<binding>`. The app mints each repo's git
390
+ * tokens itself, and owns their scope and TTL. `dev.remote` sends
391
+ * development calls to the account: Cloudflare has no local Artifacts.
392
+ */
393
+ export interface ArtifactsBinding {
394
+ type: "artifacts";
395
+ namespace: string;
396
+ dev?: {
397
+ remote?: boolean;
398
+ };
399
+ }
144
400
  /**
145
401
  * The app's own Worker, as the bindings of the Durable Objects it defines
146
402
  * name it when its entrypoint is a `cf-worker` module import. cf reads each
@@ -184,7 +440,15 @@ export interface ServiceBinding {
184
440
  export interface VersionMetadataBinding {
185
441
  type: "version-metadata";
186
442
  }
187
- export type EveryAppBinding = TextBinding | SecretBinding | D1Binding | KvBinding | R2Binding | HyperdriveBinding | DurableObjectBinding<string | EveryAppWorkerReference<object>> | WorkflowBinding | GatewayBinding | ServiceBinding | VersionMetadataBinding;
443
+ /**
444
+ * A binding of any Worker these helpers build, each one `InputWorkerConfig`
445
+ * accepts, so a helper Worker's definition passes as the Vite plugin's
446
+ * `auxiliaryWorkers` config. A Durable Object binding names its Worker by
447
+ * name; only the app's own Worker names itself by definition (see
448
+ * {@link EveryAppWorkerReference}), in its typed `env`, which
449
+ * `defineConfig()` takes.
450
+ */
451
+ export type EveryAppBinding = TextBinding | SecretBinding | D1Binding | KvBinding | R2Binding | HyperdriveBinding | QueueBinding | AiBinding | BrowserBinding | ImagesBinding | VectorizeBinding | AiGatewayBinding | JsonBinding<JsonValue> | SendEmailBinding | SecretsStoreSecretBinding | AnalyticsEngineDatasetBinding | ArtifactsBinding | DurableObjectBinding | WorkflowBinding | GatewayBinding | ServiceBinding | VersionMetadataBinding;
188
452
  export interface DurableObjectExport {
189
453
  type: "durable-object";
190
454
  storage: "sqlite";
@@ -208,6 +472,49 @@ type R2Names<M> = M extends {
208
472
  r2: readonly (infer B)[];
209
473
  };
210
474
  } ? B & string : never;
475
+ type AiNames<M> = M extends {
476
+ resources: {
477
+ ai: readonly (infer B)[];
478
+ };
479
+ } ? B & string : never;
480
+ type BrowserNames<M> = M extends {
481
+ resources: {
482
+ browser: readonly (infer B)[];
483
+ };
484
+ } ? B & string : never;
485
+ type ImagesNames<M> = M extends {
486
+ resources: {
487
+ images: readonly (infer B)[];
488
+ };
489
+ } ? B & string : never;
490
+ type VectorizeNames<M> = M extends {
491
+ resources: {
492
+ vectorize: readonly (infer V)[];
493
+ };
494
+ } ? V extends {
495
+ name: infer N extends string;
496
+ } ? N : never : never;
497
+ type AiGatewayNames<M> = M extends {
498
+ resources: {
499
+ aiGateway: readonly (infer G)[];
500
+ };
501
+ } ? G extends {
502
+ name: infer N extends string;
503
+ } ? N : never : never;
504
+ type AnalyticsEngineNames<M> = M extends {
505
+ resources: {
506
+ analyticsEngine: readonly (infer A)[];
507
+ };
508
+ } ? A extends {
509
+ name: infer N extends string;
510
+ } ? N : never : never;
511
+ type ArtifactsNames<M> = M extends {
512
+ resources: {
513
+ artifacts: readonly (infer A)[];
514
+ };
515
+ } ? A extends {
516
+ name: infer N extends string;
517
+ } ? N : never : never;
211
518
  type DurableObjects<M> = M extends {
212
519
  resources: {
213
520
  durableObjects: readonly (infer D)[];
@@ -218,6 +525,27 @@ type Workflows<M> = M extends {
218
525
  workflows: readonly (infer W)[];
219
526
  };
220
527
  } ? W : never;
528
+ type QueueNames<M> = M extends {
529
+ resources: {
530
+ queues: readonly (infer Q)[];
531
+ };
532
+ } ? Q extends {
533
+ name: infer N extends string;
534
+ } ? N : never : never;
535
+ type SendEmailNames<M> = M extends {
536
+ resources: {
537
+ sendEmail: readonly (infer S)[];
538
+ };
539
+ } ? S extends {
540
+ name: infer N extends string;
541
+ } ? N : never : never;
542
+ type SecretsStoreNames<M> = M extends {
543
+ resources: {
544
+ secretsStore: readonly (infer S)[];
545
+ };
546
+ } ? S extends {
547
+ name: infer N extends string;
548
+ } ? N : never : never;
221
549
  type HelperWorkers<M> = M extends {
222
550
  workers: readonly (infer H)[];
223
551
  } ? H : never;
@@ -236,46 +564,6 @@ type DatabaseEnv<M> = M extends {
236
564
  } ? {
237
565
  DATABASE_PROVIDER: TextBinding;
238
566
  } : unknown;
239
- /**
240
- * The gateway secrets holding the keys of the AI providers and capabilities
241
- * an app may ask for, with the settings a provider needs besides its key
242
- * (Workers AI's account). With no gateway in development, the SDK reaches
243
- * them with the developer's own values under the same names. A copy of the
244
- * tables in ../internal, which the Worker loads: the Vite plugin hides
245
- * whatever cloudflare.config.ts imports from the Worker. A test keeps them
246
- * in step.
247
- */
248
- declare const DEV_GATEWAY_KEYS: {
249
- readonly providers: {
250
- readonly openai: readonly ["OPENAI_API_KEY"];
251
- readonly openrouter: readonly ["OPENROUTER_API_KEY"];
252
- readonly "workers-ai": readonly ["WORKERS_AI_API_TOKEN", "CLOUDFLARE_ACCOUNT_ID"];
253
- };
254
- readonly capabilities: {
255
- readonly dataforseo: readonly ["DATAFORSEO_API_KEY"];
256
- readonly context: readonly ["CONTEXT_API_KEY"];
257
- readonly email: readonly ["EMAIL_FROM", "EMAIL_FROM_NAME", "EMAIL_REST_API_TOKEN", "CLOUDFLARE_ACCOUNT_ID", "RESEND_API_KEY", "EMAIL_PROVIDER"];
258
- readonly members: readonly [];
259
- readonly linkedin: readonly ["LINKEDIN_CLIENT_ID", "LINKEDIN_CLIENT_SECRET"];
260
- readonly facebook: readonly ["FACEBOOK_APP_ID", "FACEBOOK_APP_SECRET"];
261
- readonly instagram: readonly ["INSTAGRAM_APP_ID", "INSTAGRAM_APP_SECRET"];
262
- readonly threads: readonly ["THREADS_APP_ID", "THREADS_APP_SECRET"];
263
- readonly youtube: readonly ["YOUTUBE_CLIENT_ID", "YOUTUBE_CLIENT_SECRET"];
264
- readonly tiktok: readonly ["TIKTOK_CLIENT_ID", "TIKTOK_CLIENT_SECRET"];
265
- readonly "tiktok-business": readonly ["TIKTOK_BUSINESS_CLIENT_ID", "TIKTOK_BUSINESS_CLIENT_SECRET"];
266
- readonly reddit: readonly ["REDDIT_CLIENT_ID", "REDDIT_CLIENT_SECRET"];
267
- readonly pinterest: readonly ["PINTEREST_CLIENT_ID", "PINTEREST_CLIENT_SECRET"];
268
- readonly discord: readonly ["DISCORD_CLIENT_ID", "DISCORD_CLIENT_SECRET"];
269
- readonly slack: readonly ["SLACK_CLIENT_ID", "SLACK_CLIENT_SECRET"];
270
- readonly mastodon: readonly ["MASTODON_CLIENT_ID", "MASTODON_CLIENT_SECRET", "MASTODON_URL"];
271
- readonly kick: readonly ["KICK_CLIENT_ID", "KICK_CLIENT_SECRET"];
272
- readonly twitch: readonly ["TWITCH_CLIENT_ID", "TWITCH_CLIENT_SECRET"];
273
- readonly tumblr: readonly ["TUMBLR_CLIENT_ID", "TUMBLR_CLIENT_SECRET"];
274
- readonly dribbble: readonly ["DRIBBBLE_CLIENT_ID", "DRIBBBLE_CLIENT_SECRET"];
275
- readonly "google-workspace": readonly ["GOOGLE_WORKSPACE_CLIENT_ID", "GOOGLE_WORKSPACE_CLIENT_SECRET"];
276
- readonly "microsoft-365": readonly ["MICROSOFT_365_CLIENT_ID", "MICROSOFT_365_CLIENT_SECRET"];
277
- };
278
- };
279
567
  type DevProviderKeys = typeof DEV_GATEWAY_KEYS.providers;
280
568
  type DevCapabilityKeys = typeof DEV_GATEWAY_KEYS.capabilities;
281
569
  /** The gateway keys a developer may set locally for the manifest's providers and capabilities. */
@@ -301,6 +589,26 @@ type ResourceEnv<M, TEntrypoint> = {
301
589
  [B in KvNames<M>]: KvBinding;
302
590
  } & {
303
591
  [B in R2Names<M>]: R2Binding;
592
+ } & {
593
+ [B in QueueNames<M>]: QueueBinding;
594
+ } & {
595
+ [B in AiNames<M>]: AiBinding;
596
+ } & {
597
+ [B in BrowserNames<M>]: BrowserBinding;
598
+ } & {
599
+ [B in ImagesNames<M>]: ImagesBinding;
600
+ } & {
601
+ [B in VectorizeNames<M>]: VectorizeBinding;
602
+ } & {
603
+ [B in AiGatewayNames<M>]: AiGatewayBinding;
604
+ } & {
605
+ [B in SendEmailNames<M>]: SendEmailBinding;
606
+ } & {
607
+ [B in SecretsStoreNames<M>]: SecretsStoreSecretBinding;
608
+ } & {
609
+ [B in AnalyticsEngineNames<M>]: AnalyticsEngineDatasetBinding;
610
+ } & {
611
+ [B in ArtifactsNames<M>]: ArtifactsBinding;
304
612
  } & {
305
613
  [D in DurableObjects<M> as D extends {
306
614
  name: infer N extends string;
@@ -314,9 +622,19 @@ type ResourceEnv<M, TEntrypoint> = {
314
622
  binding: infer B extends string;
315
623
  } ? B : never]: ServiceBinding;
316
624
  };
317
- type SharedEnv = {
625
+ /** A JSON value, as cf's JSON bindings take one. */
626
+ type JsonValue = string | number | boolean | null | JsonValue[] | {
627
+ [key: string]: JsonValue;
628
+ };
629
+ /** `M` without `readonly`, as cf's JSON bindings take their value. */
630
+ type JsonValueOf<M> = M extends readonly (infer E)[] ? JsonValueOf<E>[] : M extends object ? {
631
+ -readonly [K in keyof M]: JsonValueOf<M[K]>;
632
+ } : M;
633
+ type SharedEnv<M> = {
318
634
  EVERYAPP_APP_ID: TextBinding;
635
+ EVERYAPP_MANIFEST: JsonBinding<JsonValueOf<M>>;
319
636
  CF_VERSION_METADATA: VersionMetadataBinding;
637
+ GATEWAY_URL: TextBinding | SecretBinding;
320
638
  };
321
639
  /**
322
640
  * Hyperdrive in production; in development only where a local connection
@@ -337,23 +655,27 @@ type DevEmailEnv<M> = M extends {
337
655
  * Bindings in development: the well-known dev identity, as plain text, and
338
656
  * the developer's own gateway keys (when set).
339
657
  */
340
- export type EveryAppDevEnv<M, TEntrypoint = string> = ResourceEnv<M, TEntrypoint> & SharedEnv & DatabaseEnv<M> & DevEmailEnv<M> & {
658
+ export type EveryAppDevEnv<M, TEntrypoint = string> = ResourceEnv<M, TEntrypoint> & SharedEnv<M> & DatabaseEnv<M> & DevEmailEnv<M> & {
341
659
  EVERYAPP_DEV: TextBinding;
342
660
  EVERYAPP_DEV_CAPABILITIES: TextBinding;
343
661
  /** The specs in `.everyapp/providers/*.json`, when the app has any: providers registered on a gateway, for integrationFetch()'s dev fallback. */
344
662
  EVERYAPP_DEV_PROVIDERS?: TextBinding;
663
+ /** Under `everyapp dev --gateway` (linked dev): the gateway-lite's forwarder and the run's nonce, which the SDK's services call the real Gateway through. */
664
+ EVERYAPP_LINKED_DEV_URL?: TextBinding;
665
+ EVERYAPP_LINKED_DEV_NONCE?: TextBinding;
345
666
  EVERYAPP_IDENTITY_PUBLIC_KEYS: TextBinding;
346
667
  EVERYAPP_IDENTITY_ISSUER: TextBinding;
668
+ /** The stub dev gateway's organization (`dev-org`), so `withOrganization(env.EVERY_APP_ORG_ID, …)` works in development as deployed. */
669
+ EVERY_APP_ORG_ID: TextBinding;
347
670
  } & {
348
671
  [K in DevGatewayKeys<M>]: SecretBinding;
349
672
  };
350
673
  /** Bindings in production: the deployed identity and the gateway binding. */
351
- export type EveryAppDeployEnv<M, TEntrypoint = string> = ResourceEnv<M, TEntrypoint> & SharedEnv & DatabaseEnv<M> & HyperdriveEnv<M> & {
674
+ export type EveryAppDeployEnv<M, TEntrypoint = string> = ResourceEnv<M, TEntrypoint> & SharedEnv<M> & DatabaseEnv<M> & HyperdriveEnv<M> & {
352
675
  EVERYAPP_AUDIENCE: TextBinding;
353
676
  EVERYAPP_IDENTITY_PUBLIC_KEYS: TextBinding;
354
677
  EVERYAPP_IDENTITY_ISSUER: TextBinding;
355
678
  EVERY_APP_GATEWAY: GatewayBinding;
356
- GATEWAY_URL: SecretBinding;
357
679
  /**
358
680
  * The owning organization. The build always declares it; installing a
359
681
  * shared app, which serves every organization, drops it.
@@ -401,6 +723,23 @@ export interface ScheduledTrigger {
401
723
  type: "scheduled";
402
724
  schedule: string;
403
725
  }
726
+ /**
727
+ * Structural copy of cf's queue consumer trigger: the Worker consumes the
728
+ * named queue (its `queue(batch, env)` handler), with these settings.
729
+ */
730
+ export interface QueueConsumerTrigger {
731
+ type: "queue";
732
+ name: string;
733
+ deadLetterQueue?: string;
734
+ maxBatchSize?: number;
735
+ maxBatchTimeout?: number;
736
+ maxConcurrency?: number | null;
737
+ maxRetries?: number;
738
+ retryDelay?: number;
739
+ visibilityTimeoutMs?: number;
740
+ }
741
+ /** A trigger one of the app's Workers may have: its crons, the queues it consumes. */
742
+ export type EveryAppTrigger = ScheduledTrigger | QueueConsumerTrigger;
404
743
  export interface EveryAppWorkerConfig<M, TEntrypoint> {
405
744
  name: string;
406
745
  entrypoint: TEntrypoint;
@@ -408,8 +747,8 @@ export interface EveryAppWorkerConfig<M, TEntrypoint> {
408
747
  compatibilityFlags: string[];
409
748
  workersDev: false;
410
749
  previewUrls: false;
411
- /** The `crons` option's schedules; absent without any. */
412
- triggers?: ScheduledTrigger[];
750
+ /** The `crons` option's schedules and the queues it consumes; absent without any. */
751
+ triggers?: EveryAppTrigger[];
413
752
  /** Near the manifest's `database.region`, once deployed. */
414
753
  placement?: EveryAppPlacement;
415
754
  /** The manifest's `limits`. */
@@ -456,7 +795,7 @@ export interface EveryAppAuxiliaryWorkerConfig<TEntrypoint> {
456
795
  compatibilityFlags: string[];
457
796
  workersDev: false;
458
797
  previewUrls: false;
459
- triggers?: ScheduledTrigger[];
798
+ triggers?: EveryAppTrigger[];
460
799
  placement?: EveryAppPlacement;
461
800
  limits?: {
462
801
  cpuMs?: number;
@@ -469,7 +808,10 @@ export interface EveryAppAuxiliaryWorkerConfig<TEntrypoint> {
469
808
  * Build the definition of one of the app's helper Workers (the manifest's
470
809
  * `workers`), e.g. one that runs a memory-hungry job away from the app's
471
810
  * Worker. It is named `<app worker>--<worker>`, is private like the app, and
472
- * binds the app's D1 databases, KV namespaces and R2 buckets, the classes it defines, and
811
+ * binds the app's and Analytics Engine datasets, the classes it defines, and
812
+ * binds the app's D1 databases, KV namespaces, R2 buckets, Workers AI,
813
+ * Browser Rendering, Images, Vectorize indexes, AI Gateways, `send_email`
814
+ * bindings and Secrets Store secrets, the classes it defines, and
473
815
  * the gateway (with the app's identity, for capabilities). Only the app's
474
816
  * Worker reaches it. Pass it to the Vite plugin:
475
817
  *
@@ -480,19 +822,6 @@ export interface EveryAppAuxiliaryWorkerConfig<TEntrypoint> {
480
822
  * })
481
823
  */
482
824
  export declare function everyAppAuxiliaryWorker<const M extends EveryAppWorkerManifest, TEntrypoint extends string | object>(options: EveryAppAuxiliaryWorkerOptions<M, TEntrypoint>): EveryAppAuxiliaryWorkerConfig<TEntrypoint>;
483
- /**
484
- * A helper Worker's name: `<app worker>--<name>`, within Cloudflare's
485
- * limit. New app ids can't contain `--`, so it is never another app's
486
- * Worker name.
487
- */
488
- export declare function helperWorkerName(appWorker: string, helper: string): string;
489
- /**
490
- * The Workflow a binding defines, named after the app's Worker:
491
- * `every-acme-seo` and `RANK_CHECK` → `every-acme-seo--rank-check`.
492
- * Workflow names are unique in the account, and new app ids can't contain
493
- * `--`, so one app's Workflow is never named like another app's.
494
- */
495
- export declare function workflowNameFor(workerName: string, binding: string): string;
496
825
  /**
497
826
  * The local D1 database id for a binding: a 32-hex string, because
498
827
  * `cf d1 … --local` rejects names. The everyapp CLI computes the same id to
@@ -507,5 +836,4 @@ export declare function localD1Id(workerName: string, binding: string): string;
507
836
  * the file after that object's id. `databaseId` is the {@link localD1Id}.
508
837
  */
509
838
  export declare function localD1Path(root: string, databaseId: string): string;
510
- export {};
511
839
  //# sourceMappingURL=worker.d.ts.map