@lunora/config 1.0.0-alpha.29 → 1.0.0-alpha.291

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 (114) hide show
  1. package/LICENSE.md +135 -0
  2. package/README.md +3 -3
  3. package/dist/cloudflare/index.d.mts +1065 -0
  4. package/dist/cloudflare/index.d.ts +1065 -0
  5. package/dist/cloudflare/index.mjs +1 -0
  6. package/dist/index.d.mts +1024 -918
  7. package/dist/index.d.ts +1024 -918
  8. package/dist/index.mjs +1 -23
  9. package/dist/packem_shared/ACCENT-CotPTfv7.mjs +7 -0
  10. package/dist/packem_shared/AGENT_MODE_ENV-D8MvSwPE.mjs +1 -0
  11. package/dist/packem_shared/AGENT_RULES_DIR-C54Ta_vz.mjs +1 -0
  12. package/dist/packem_shared/ALLOW_FORWARDED_ENV-BUndghJx.mjs +1 -0
  13. package/dist/packem_shared/BINDING_MANIFEST_VERSION-vItUTnHk.mjs +1 -0
  14. package/dist/packem_shared/CLOUDFLARE_DRIVER-Ci3VIqnk.mjs +1 -0
  15. package/dist/packem_shared/CODEGEN_ENV-ZsCxV1kP.mjs +1 -0
  16. package/dist/packem_shared/COMPOSED_WORKER_ENTRY-C69wqbSP.mjs +1 -0
  17. package/dist/packem_shared/DEFAULT_DEPLOY_TARGET-CfoV0tDu.mjs +1 -0
  18. package/dist/packem_shared/DEV_BINDINGS_FILE-pyOiNLP4.mjs +4 -0
  19. package/dist/packem_shared/DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs +6 -0
  20. package/dist/packem_shared/DEV_WORKER_ENV_VALUE-DwGANZVw.mjs +1 -0
  21. package/dist/packem_shared/LINKED_PROJECT_DIR-Ba5qPEwo.mjs +2 -0
  22. package/dist/packem_shared/LUNORA_EVENT_SOURCE-DYdcDU9G.mjs +1 -0
  23. package/dist/packem_shared/LUNORA_IGNORED_PATHS-B0-PPvRp.mjs +19 -0
  24. package/dist/packem_shared/LUNORA_TAG-CiQM3BkI.mjs +1 -0
  25. package/dist/packem_shared/LunoraReporter-f277GLNT.mjs +6 -0
  26. package/dist/packem_shared/PACKAGE_SECRETS_REGISTRY-De7gLGIy.mjs +1 -0
  27. package/dist/packem_shared/POLICY_SCAFFOLD_ENDPOINT-0QiGKazX.mjs +1 -0
  28. package/dist/packem_shared/REMOTE_ELIGIBLE_KEYS-ikHvqvS5.mjs +1 -0
  29. package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-jTnj2MPJ.mjs +1 -0
  30. package/dist/packem_shared/SCHEMA_EDIT_ENDPOINT-Dbt0faMd.mjs +1 -0
  31. package/dist/packem_shared/SEED_ENDPOINT-2B56PN_H.mjs +1 -0
  32. package/dist/packem_shared/STUDIO_PATH-BZI8go9A.mjs +1 -0
  33. package/dist/packem_shared/UNEXPORTED_CLASS_MARKER-CugcZbPf.mjs +1 -0
  34. package/dist/packem_shared/WORKERS_CACHE_MIN_DATE-0k9ABJtF.mjs +1 -0
  35. package/dist/packem_shared/WRANGLER_FILES-UNW-xY5u.mjs +1 -0
  36. package/dist/packem_shared/acceptsConnection-DHhUYGjT.mjs +2 -0
  37. package/dist/packem_shared/addArgsFor-CYZKhNIo.mjs +1 -0
  38. package/dist/packem_shared/applyAdditiveEdit-CH0VhMJ2.mjs +6 -0
  39. package/dist/packem_shared/applyModify-DKP2l6S9.mjs +1 -0
  40. package/dist/packem_shared/applyStudioAssetCache-DHQEJuuv.mjs +1 -0
  41. package/dist/packem_shared/assertWranglerSatisfiesSchema-BiABHeMv.mjs +3 -0
  42. package/dist/packem_shared/assetContentType-CUb5bpbI.mjs +1 -0
  43. package/dist/packem_shared/buildPackageSecretsBlock-yv9mjKEW.mjs +19 -0
  44. package/dist/packem_shared/celld-config-D-L6uskI.mjs +3 -0
  45. package/dist/packem_shared/classifyPolicyEdit-D8NwrHxR.mjs +24 -0
  46. package/dist/packem_shared/collectExportGaps-CIYe_DRY.mjs +2 -0
  47. package/dist/packem_shared/collectWranglerSecretVariables-D-usPfT8.mjs +1 -0
  48. package/dist/packem_shared/createConfirm-D5mKTMHj.mjs +7 -0
  49. package/dist/packem_shared/describePreservedCrons-7gaDLxWx.mjs +1 -0
  50. package/dist/packem_shared/detectFramework-CUiVEHDQ.mjs +1 -0
  51. package/dist/packem_shared/discover-info-Vj9d4qYt.mjs +1 -0
  52. package/dist/packem_shared/discoverAgentInfo-CTdCSfYM.mjs +1 -0
  53. package/dist/packem_shared/discoverContainerInfo-EhZtEBQs.mjs +1 -0
  54. package/dist/packem_shared/discoverSchemaInfo-DJvevsCm.mjs +1 -0
  55. package/dist/packem_shared/discoverWorkflowInfo-BsPvlo6O.mjs +1 -0
  56. package/dist/packem_shared/inferLunoraBindings-DXLEJY9w.mjs +1 -0
  57. package/dist/packem_shared/interpretRemote-C9yJC_ZK.mjs +1 -0
  58. package/dist/packem_shared/lunora-manifest-v90ZUbVp.mjs +6 -0
  59. package/dist/packem_shared/mergeWranglerEnvironment-DOKJUNH8.mjs +1 -0
  60. package/dist/packem_shared/package-secrets-registry-DvtTiK4b.mjs +1 -0
  61. package/dist/packem_shared/parseDevVariable-teAAahVD.mjs +1 -0
  62. package/dist/packem_shared/parseSchema-D1Wbr1qv.mjs +1 -0
  63. package/dist/packem_shared/policy-scaffold.d-D2H4_G01.d.mts +86 -0
  64. package/dist/packem_shared/policy-scaffold.d-D2H4_G01.d.ts +86 -0
  65. package/dist/packem_shared/reconcile-services-3dn35zgy.mjs +1 -0
  66. package/dist/packem_shared/reconcileBindingsSafely-VBbLYoAx.mjs +1 -0
  67. package/dist/packem_shared/reconcileWranglerCompatibilityDate-hocXEuRA.mjs +1 -0
  68. package/dist/packem_shared/renderStudioHtml-ByowDtMl.mjs +15 -0
  69. package/dist/packem_shared/runPostCodegenHook-B0T1q2YI.mjs +1 -0
  70. package/dist/packem_shared/schema-info.d-fEhxTb9k.d.mts +397 -0
  71. package/dist/packem_shared/schema-info.d-fEhxTb9k.d.ts +397 -0
  72. package/dist/packem_shared/serveJsonHandler-Dv0EdCb9.mjs +1 -0
  73. package/dist/packem_shared/startCelldDevSession-BLFsd6jG.mjs +1 -0
  74. package/dist/packem_shared/streamContainerLogs-0nko1qpv.mjs +2 -0
  75. package/dist/packem_shared/validate-bindings-Dnf1t0SY.mjs +1 -0
  76. package/dist/packem_shared/withTailConsumer-B1NoKIsj.mjs +1 -0
  77. package/dist/packem_shared/wranglerToAlchemy-BMOQYRyw.mjs +6 -0
  78. package/dist/packem_shared/write-atomic-9d9xs5ON.mjs +1 -0
  79. package/dist/studio-host/index.d.mts +314 -110
  80. package/dist/studio-host/index.d.ts +314 -110
  81. package/dist/studio-host/index.mjs +1 -7
  82. package/package.json +15 -7
  83. package/dist/packem_shared/ACCENT-DW1XJn8i.mjs +0 -40
  84. package/dist/packem_shared/AGENT_RULES_DIR-lcgC08aE.mjs +0 -40
  85. package/dist/packem_shared/DEV_VARS_EXAMPLE_FILE-dJPNTEnK.mjs +0 -37
  86. package/dist/packem_shared/LINKED_PROJECT_DIR-CXwXzV_C.mjs +0 -52
  87. package/dist/packem_shared/LUNORA_CONFIG_FILE-CtcIcB5-.mjs +0 -34
  88. package/dist/packem_shared/LUNORA_EVENT_SOURCE-D2fDeGB6.mjs +0 -86
  89. package/dist/packem_shared/LunoraReporter-Ci-bDCK9.mjs +0 -70
  90. package/dist/packem_shared/PACKAGE_SECRETS_REGISTRY-B8t_SdoZ.mjs +0 -70
  91. package/dist/packem_shared/POLICY_SCAFFOLD_ENDPOINT-CiC2IGKx.mjs +0 -103
  92. package/dist/packem_shared/REMOTE_ELIGIBLE_KEYS-BC7_e9Bz.mjs +0 -105
  93. package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-2YYyWJUq.mjs +0 -561
  94. package/dist/packem_shared/SCHEMA_EDIT_ENDPOINT-Df-Wrix-.mjs +0 -99
  95. package/dist/packem_shared/SEED_ENDPOINT-DVCjaGO-.mjs +0 -61
  96. package/dist/packem_shared/WRANGLER_FILES-DwSuC-Kn.mjs +0 -25
  97. package/dist/packem_shared/applyAdditiveEdit-C-snTFEV.mjs +0 -228
  98. package/dist/packem_shared/buildPackageSecretsBlock-DWDKHViT.mjs +0 -243
  99. package/dist/packem_shared/classifyPolicyEdit-BHeAqF8P.mjs +0 -99
  100. package/dist/packem_shared/createConfirm-fvpdgJ9s.mjs +0 -100
  101. package/dist/packem_shared/detectFramework-Br-BcPBq.mjs +0 -41
  102. package/dist/packem_shared/discoverContainerInfo-BXFs6Wav.mjs +0 -19
  103. package/dist/packem_shared/discoverSchemaInfo-BB-CKlTK.mjs +0 -25
  104. package/dist/packem_shared/discoverWorkflowInfo-CedvR0mn.mjs +0 -19
  105. package/dist/packem_shared/inferLunoraBindings-ByMwG-gH.mjs +0 -352
  106. package/dist/packem_shared/loadStudioAssets-Csk5RS4E.mjs +0 -28
  107. package/dist/packem_shared/parseDevVariable-CJiq2IwE.mjs +0 -30
  108. package/dist/packem_shared/parseSchema-DSeyktvG.mjs +0 -107
  109. package/dist/packem_shared/policy-scaffold.d-DCmwn7zQ.d.mts +0 -74
  110. package/dist/packem_shared/policy-scaffold.d-DCmwn7zQ.d.ts +0 -74
  111. package/dist/packem_shared/reconcileWranglerBindings-Cruwwx1M.mjs +0 -334
  112. package/dist/packem_shared/renderStudioHtml-449Ysn75.mjs +0 -37
  113. package/dist/packem_shared/serveJsonHandler-B4OLTGLS.mjs +0 -86
  114. package/dist/packem_shared/streamContainerLogs-BZ4cOZwH.mjs +0 -157
@@ -0,0 +1,1065 @@
1
+ import { D as DeployDriver, G as GeneratedClassModule, I as InferredBindings, S as SchemaInfo } from "../packem_shared/schema-info.d-fEhxTb9k.mjs";
2
+ import { WranglerVariableIR } from '@lunora/codegen';
3
+ /** Apply one structural jsonc edit and return the rewritten text (a no-op edit returns the input). */
4
+ declare const applyModify: (text: string, path: ReadonlyArray<number | string>, value: unknown) => string;
5
+ /** The project coordinates the validator needs. */
6
+ interface AssertWranglerOptions {
7
+ /** Absolute path to the project root holding `wrangler.jsonc`. */
8
+ projectRoot: string;
9
+ /** The schema directory, relative to `projectRoot` (usually `"lunora"`). */
10
+ schemaDir: string;
11
+ }
12
+ /**
13
+ * Throw unless `wrangler.jsonc` satisfies the schema's binding requirements.
14
+ *
15
+ * Non-blocking validator warnings go to `warn`. `remedy` closes both error
16
+ * messages — the caller's own "and restart the dev server" / "and rebuild" —
17
+ * since that is the only part a reader acts on differently per front-end.
18
+ *
19
+ * Must run AFTER binding provisioning: the bindings this requires are largely the
20
+ * ones Lunora writes itself, so validating first fails the very first build of any
21
+ * project that declares a `.global()` table or a container.
22
+ */
23
+ declare const assertWranglerSatisfiesSchema: (options: AssertWranglerOptions, warn: (message: string) => void, remedy: string) => void;
24
+ /**
25
+ * Translate a `wrangler.jsonc` into an [Alchemy](https://alchemy.run) program.
26
+ *
27
+ * # Why translate rather than ask for a second config
28
+ *
29
+ * `wrangler.jsonc` is already the source of truth for what an app needs, and
30
+ * Lunora already infers and reconciles it — `inferLunoraBindings` decides that
31
+ * a project needs a shard namespace and a bucket, `reconcileWranglerBindings`
32
+ * writes them. Asking a developer to restate all of that in an
33
+ * `alchemy.run.ts` would give the project two sources of truth that drift, and
34
+ * the drift would surface as a deploy that provisions something the app does
35
+ * not bind.
36
+ *
37
+ * So Alchemy is an implementation detail of `deploy`, not a thing to configure:
38
+ * read the config, emit the program, run it.
39
+ *
40
+ * # Why this emits source rather than calling Alchemy
41
+ *
42
+ * `alchemy@0.93` has thirty dependencies, nine of them Node-shaped —
43
+ * `wrangler`, `miniflare`, `esbuild`, `execa`, `find-process`, `glob`, `open`,
44
+ * `proper-lockfile`, `signal-exit`. `@lunora/config` is imported by
45
+ * `@lunora/vite`, so importing Alchemy here would push that tree into every
46
+ * project that merely wanted to read `lunora.config.*`, and into any bundle
47
+ * targeting workerd — where none of it survives.
48
+ *
49
+ * Emitting text keeps this module pure and dependency-free. Alchemy is invoked
50
+ * as a CLI against the generated file, so it only has to exist on the machine
51
+ * that deploys.
52
+ *
53
+ * # Adoption, not re-creation
54
+ *
55
+ * Every resource is emitted with `adopt: true`. A project translated from an
56
+ * existing `wrangler.jsonc` already *has* its D1 database and its bucket, with
57
+ * data in them. Without adoption Alchemy would treat them as new and try to
58
+ * create alongside — the one outcome a deploy must never have.
59
+ */
60
+ /** A Durable Object binding as `wrangler.jsonc` spells it. */
61
+ interface WranglerDurableObjectBinding$1 {
62
+ class_name?: string;
63
+ name?: string;
64
+ script_name?: string;
65
+ }
66
+ /** The slice of `wrangler.jsonc` that translates into Alchemy resources. */
67
+ interface WranglerConfigShape {
68
+ compatibility_date?: string;
69
+ compatibility_flags?: ReadonlyArray<string>;
70
+ d1_databases?: ReadonlyArray<{
71
+ binding?: string;
72
+ database_id?: string;
73
+ database_name?: string;
74
+ }>;
75
+ durable_objects?: {
76
+ bindings?: ReadonlyArray<WranglerDurableObjectBinding$1>;
77
+ };
78
+ kv_namespaces?: ReadonlyArray<{
79
+ binding?: string;
80
+ id?: string;
81
+ }>;
82
+ main?: string;
83
+ /** `new_sqlite_classes` marks which DO classes get SQLite storage — Alchemy needs that per namespace. */
84
+ migrations?: ReadonlyArray<{
85
+ new_classes?: ReadonlyArray<string>;
86
+ new_sqlite_classes?: ReadonlyArray<string>;
87
+ }>;
88
+ name?: string;
89
+ /** Only `producers` translate; a `consumers` entry is dropped and reported as `queues.consumers`. */
90
+ queues?: {
91
+ consumers?: ReadonlyArray<{
92
+ queue?: string;
93
+ }>;
94
+ producers?: ReadonlyArray<{
95
+ binding?: string;
96
+ queue?: string;
97
+ }>;
98
+ };
99
+ r2_buckets?: ReadonlyArray<{
100
+ binding?: string;
101
+ bucket_name?: string;
102
+ }>;
103
+ triggers?: {
104
+ crons?: ReadonlyArray<string>;
105
+ };
106
+ vars?: Readonly<Record<string, unknown>>;
107
+ }
108
+ /** What the translation could not carry over, so the caller can say so out loud. */
109
+ interface AlchemyTranslation {
110
+ /** The emitted program source. */
111
+ source: string;
112
+ /**
113
+ * Bindings present in `wrangler.jsonc` that this translation drops.
114
+ *
115
+ * Reported rather than silently omitted: a deploy that quietly loses a
116
+ * Vectorize index produces a worker whose `env.POSTS_SEARCH` is undefined
117
+ * at runtime, and nothing in the build says why.
118
+ */
119
+ unsupported: ReadonlyArray<string>;
120
+ }
121
+ /**
122
+ * Translate a parsed `wrangler.jsonc` into an Alchemy program.
123
+ *
124
+ * Pure: it reads nothing and writes nothing, so the caller decides where the
125
+ * source lands and the whole thing stays testable as a string comparison.
126
+ * @param config The parsed `wrangler.jsonc`.
127
+ * @returns the program source, plus whatever could not be carried over.
128
+ */
129
+ declare const wranglerToAlchemy: (config: WranglerConfigShape) => AlchemyTranslation;
130
+ /** Schema version of the emitted document, so a consumer can gate on shape changes. */
131
+ declare const BINDING_MANIFEST_VERSION = 1;
132
+ /**
133
+ * One resource the built Worker expects to be bound to. `binding` is the name the
134
+ * Worker reads off `env`; the remaining fields are whatever identifies the
135
+ * resource for that type, omitted when the config does not carry them (an id
136
+ * Lunora could not mint is absent here exactly as it is absent from the config).
137
+ */
138
+ interface BindingRequirement {
139
+ /** The `env` property name the Worker reads. */
140
+ binding: string;
141
+ /**
142
+ * Durable Object / Workflow / Container class the Worker must export. Present
143
+ * for the class-backed binding types, so a deployer can assert the bundle
144
+ * exports it before publishing.
145
+ */
146
+ className?: string;
147
+ /** Bucket name (`r2`), database name (`d1`), dataset (`analytics_engine`), queue name (`queue`), index (`vectorize`), stream (`pipeline`), namespace (`artifacts`). */
148
+ resource?: string;
149
+ /** Remote resource id, when the config declares one (`d1`, `kv`, `hyperdrive`, `vpc_service`, `vpc_network`). */
150
+ resourceId?: string;
151
+ /** For `durable_object`: whether the class uses SQLite storage (`new_sqlite_classes`). */
152
+ sqlite?: boolean;
153
+ /** The kind of resource, keyed to the wrangler section it came from. */
154
+ type: "ai" | "analytics_engine" | "artifacts" | "assets" | "browser" | "container" | "d1" | "durable_object" | "hyperdrive" | "images" | "kv" | "media" | "pipeline" | "queue_consumer" | "queue_producer" | "r2" | "stream" | "vectorize" | "vpc_network" | "vpc_service" | "workflow";
155
+ }
156
+ /** The document the `lunora build --emit-bindings` flag writes. */
157
+ interface BindingManifest {
158
+ /** Every resource the Worker expects, sorted by `type` then `binding` so the file is diff-stable. */
159
+ bindings: ReadonlyArray<BindingRequirement>;
160
+ /** `compatibility_date`, when declared. */
161
+ compatibilityDate?: string;
162
+ /** `compatibility_flags`, when declared. */
163
+ compatibilityFlags?: ReadonlyArray<string>;
164
+ /** Cron expressions the Worker must be triggered on (`triggers.crons`). */
165
+ crons: ReadonlyArray<string>;
166
+ /** Worker name from `wrangler.jsonc`. */
167
+ name?: string;
168
+ /**
169
+ * Wrangler sections present in the config that this version does not model,
170
+ * by field name. Empty for a fully-understood config; non-empty is a prompt to
171
+ * extend the collector, and is surfaced to the user rather than silently
172
+ * dropped.
173
+ */
174
+ unknown: ReadonlyArray<string>;
175
+ /** Names of `vars` entries. Values are deliberately excluded — a manifest is committed and read by CI, and a `vars` entry can hold a value a project would rather not publish. */
176
+ vars: ReadonlyArray<string>;
177
+ /** Schema version — {@link BINDING_MANIFEST_VERSION}. */
178
+ version: number;
179
+ }
180
+ /**
181
+ * The wider config this reads. {@link WranglerConfigShape} covers what the
182
+ * Alchemy translation models; a manifest additionally reports the sections that
183
+ * translation lists as unsupported, so those are declared here.
184
+ */
185
+ interface ManifestConfigShape extends WranglerConfigShape {
186
+ ai?: {
187
+ binding?: string;
188
+ };
189
+ analytics_engine_datasets?: ReadonlyArray<{
190
+ binding?: string;
191
+ dataset?: string;
192
+ }>;
193
+ artifacts?: ReadonlyArray<{
194
+ binding?: string;
195
+ namespace?: string;
196
+ }>;
197
+ /** Static assets carry a real `binding` the Worker reads (`env.ASSETS`). */
198
+ assets?: {
199
+ binding?: string;
200
+ directory?: string;
201
+ };
202
+ browser?: {
203
+ binding?: string;
204
+ };
205
+ containers?: ReadonlyArray<{
206
+ class_name?: string;
207
+ image?: string;
208
+ max_instances?: number;
209
+ }>;
210
+ /** Top-level exports; only `type: "workflow"` entries map to a binding requirement (see {@link collectWorkflowExports}). */
211
+ exports?: Record<string, {
212
+ name?: string;
213
+ type?: string;
214
+ } | null | undefined>;
215
+ hyperdrive?: ReadonlyArray<{
216
+ binding?: string;
217
+ id?: string;
218
+ }>;
219
+ images?: {
220
+ binding?: string;
221
+ };
222
+ media?: {
223
+ binding?: string;
224
+ };
225
+ /** `pipeline` is wrangler's deprecated spelling of `stream`; both are read. */
226
+ pipelines?: ReadonlyArray<{
227
+ binding?: string;
228
+ pipeline?: string;
229
+ stream?: string;
230
+ }>;
231
+ /** Adds `consumers` — the Alchemy translation models producers only. */
232
+ queues?: {
233
+ consumers?: ReadonlyArray<{
234
+ queue?: string;
235
+ }>;
236
+ producers?: ReadonlyArray<{
237
+ binding?: string;
238
+ queue?: string;
239
+ }>;
240
+ };
241
+ stream?: {
242
+ binding?: string;
243
+ };
244
+ vectorize?: ReadonlyArray<{
245
+ binding?: string;
246
+ index_name?: string;
247
+ }>;
248
+ vpc_networks?: ReadonlyArray<{
249
+ binding?: string;
250
+ network_id?: string;
251
+ tunnel_id?: string;
252
+ }>;
253
+ vpc_services?: ReadonlyArray<{
254
+ binding?: string;
255
+ service_id?: string;
256
+ }>;
257
+ workflows?: ReadonlyArray<{
258
+ binding?: string;
259
+ class_name?: string;
260
+ name?: string;
261
+ }>;
262
+ }
263
+ /**
264
+ * Build the manifest for a parsed `wrangler.jsonc`.
265
+ *
266
+ * Pure: reads nothing and writes nothing, so the caller decides where the
267
+ * document lands and the mapping stays testable as a plain object comparison.
268
+ * @param config The parsed, already-reconciled `wrangler.jsonc`.
269
+ * @returns the requirements document.
270
+ */
271
+ declare const buildBindingManifest: (config: ManifestConfigShape) => BindingManifest;
272
+ /** The Cloudflare deploy driver. */
273
+ declare const CLOUDFLARE_DRIVER: DeployDriver;
274
+ /**
275
+ * A container/workflow that is declared (so codegen emits its class) but the
276
+ * worker entry never re-exports — the one wiring step the generators can't always
277
+ * do for the developer. wrangler rejects a `class_name` the deployed worker
278
+ * doesn't export, so a deploy fails late on this; surfacing it as structured data
279
+ * lets the Vite plugin raise it in the dev error overlay (not just the console)
280
+ * the moment the gap appears. The human-readable form is also folded into
281
+ * {@link ReconcileBindingsResult.warnings}.
282
+ */
283
+ interface ExportGap {
284
+ /** Generated class wrangler needs exported, e.g. `OrderPipelineWorkflow`. */
285
+ className: string;
286
+ /** The `lunora/{agents,containers,workflows}.ts` export name, e.g. `orderPipeline`. */
287
+ exportName: string;
288
+ /** Which declaration is unexported. */
289
+ kind: "agent" | "container" | "workflow";
290
+ /** The `_generated/{module}` to re-export from, e.g. `workflows`. */
291
+ module: GeneratedClassModule;
292
+ }
293
+ interface ReconcileBindingsResult {
294
+ /** Short labels for each binding written (e.g. `"SCHEDULER/SchedulerDO"`). */
295
+ added: string[];
296
+ /** `true` when `wrangler.jsonc` was rewritten. */
297
+ changed: boolean;
298
+ /** What was written to the SvelteKit / Nuxt dev sidecar's own config, when anything was. */
299
+ devConfig?: {
300
+ added: string[];
301
+ path: string;
302
+ updated: string[];
303
+ };
304
+ /**
305
+ * Declared containers/workflows the worker entry doesn't re-export — the
306
+ * structured form of the corresponding `warnings` entries, for the dev error
307
+ * overlay. Empty when every declaration is wired.
308
+ */
309
+ exportGaps: ExportGap[];
310
+ /** Reason reconciliation was skipped, for logging. */
311
+ reason?: string;
312
+ /**
313
+ * Short labels for each EXISTING entry whose settings were brought in line
314
+ * with its declaration (e.g. `"queues.consumers/receipt-queue (max_retries)"`).
315
+ * Kept apart from `added` so a retune is not logged as a new binding.
316
+ */
317
+ updated: string[];
318
+ /** Non-fatal hints for capabilities that cannot be auto-provisioned. */
319
+ warnings: string[];
320
+ /** Resolved wrangler path, or `undefined` when none was found. */
321
+ wranglerPath?: string;
322
+ }
323
+ /**
324
+ * The declared-but-not-re-exported containers and workflows, as structured
325
+ * {@link ExportGap}s. The same gaps `collectWarnings` renders into prose — kept
326
+ * here as data so the Vite plugin can raise them in the error overlay with a
327
+ * precise remediation, rather than re-parsing the warning strings.
328
+ *
329
+ * Exported because reconciliation is not the only caller that needs the answer:
330
+ * `lunora codegen` and `lunora doctor` both want the gaps WITHOUT rewriting
331
+ * `wrangler.jsonc`, which is the rest of what {@link reconcileWranglerBindings}
332
+ * does. Deriving them again from `inferred.{containers,workflows,agents}` at each
333
+ * call site is how one kind ends up silently uncovered.
334
+ */
335
+ declare const collectExportGaps: (inferred: InferredBindings) => ExportGap[];
336
+ /**
337
+ * Reconcile inferred Durable Object / D1 bindings into `wrangler.jsonc`.
338
+ *
339
+ * Writes only when something is missing; returns `changed: false` when the
340
+ * config already satisfies the inferred needs.
341
+ *
342
+ * `environment`, when passed, does NOT change where this provisions — every
343
+ * step below still only ADDS to the TOP-LEVEL config; wrangler's `env.<name>`
344
+ * blocks have no auto-provisioning path today. The one write into the block is
345
+ * {@link reconcileEnvQueues}, which retunes queue consumers the block already
346
+ * declares and adds nothing. Otherwise it is used only to emit an
347
+ * advisory warning, because bindings (`durable_objects`, `d1_databases`, …)
348
+ * are non-inheritable (see `wrangler-environment.ts`'s `NON_INHERITABLE_KEYS`):
349
+ * a `--env production` deploy needs its OWN copy of each one, and silently
350
+ * writing only to the top level would leave that gap unmentioned. Extending
351
+ * the JSONC writer itself to target `env.<name>.*` idempotently for every
352
+ * binding kind here is a separate, larger change (each of the ~10 pipeline
353
+ * steps below reads AND writes the top-level path) that this fix does not
354
+ * attempt — `lunora deploy --env <name>` now VALIDATES the env-scoped view
355
+ * (closing the reported gap), it just doesn't yet auto-provision it.
356
+ */
357
+ declare const reconcileWranglerBindings: (projectRoot: string, inferred: InferredBindings, environment?: string) => ReconcileBindingsResult;
358
+ interface ReconcileCompatibilityDateResult {
359
+ /** `true` when `wrangler.jsonc` was rewritten. */
360
+ changed: boolean;
361
+ /** The new date value, or the existing one when unchanged. */
362
+ date: string | undefined;
363
+ /** Human-readable reason when reconciliation was skipped. */
364
+ reason?: string;
365
+ /** Resolved wrangler path, or `undefined` when none was found. */
366
+ wranglerPath?: string;
367
+ }
368
+ /**
369
+ * Reconcile the `compatibility_date` in `wrangler.jsonc` when Workers Cache
370
+ * is enabled but the date is below the minimum required.
371
+ */
372
+ declare const reconcileWranglerCompatibilityDate: (projectRoot: string) => ReconcileCompatibilityDateResult;
373
+ interface ReconcileResult {
374
+ /** `true` when the wrangler config's `triggers.crons` was rewritten. */
375
+ changed: boolean;
376
+ /**
377
+ * Entries left in `triggers.crons` that this reconciler did not generate and
378
+ * does not own — a hand-written `backupCron` trigger, or anything already
379
+ * there before ownership was first recorded. Non-empty means the array is
380
+ * NOT the codegen-derived set, which is the surprising half of what this
381
+ * does and the one thing worth printing.
382
+ */
383
+ preserved: string[];
384
+ /** Human-readable reason when reconciliation was skipped (for logging). */
385
+ reason?: string;
386
+ /**
387
+ * Problems with the ownership record itself, for the caller to `warn`. A
388
+ * damaged `lunora.crons` is not fatal — the reconciler degrades to add-only
389
+ * — but the degradation is invisible: the generated cron it wrote last pass
390
+ * is reported back as hand-written and is then kept for good. Silence is
391
+ * what turns a merge conflict into a permanent orphan.
392
+ */
393
+ warnings: string[];
394
+ /** Resolved wrangler path, or `undefined` when none was found. */
395
+ wranglerPath?: string;
396
+ }
397
+ /**
398
+ * Reconcile the codegen-derived cron schedules into the project's wrangler
399
+ * config `triggers.crons` array, preserving comments and formatting via
400
+ * `jsonc-parser`'s structural edits.
401
+ *
402
+ * **This does not own the whole array.** Two runtime cron surfaces live on
403
+ * `createWorker` rather than in `lunora/crons.ts`: `backupCron` (the nightly
404
+ * NDJSON backup) and `crons` (handlers keyed by expression). Replacing the array
405
+ * wholesale deleted both on the next `lunora deploy` or dev-server schema save,
406
+ * silently — the nightly backup simply stopped. So an entry this reconciler did
407
+ * not generate is the user's, is kept, and is reported in
408
+ * {@link ReconcileResult.preserved}.
409
+ *
410
+ * Codegen now scans the worker entry for both, so the STATIC case arrives in
411
+ * `cronTriggers` like any declared cron — kept because it is generated, and
412
+ * cleared when the entry stops declaring it. What it cannot resolve is the
413
+ * dynamic case, and that case is supported: `.extend((env) => ({ backupCron:
414
+ * env.NIGHTLY_CRON }))` is the documented escape hatch, and its value exists
415
+ * only at runtime. That residue — plus a computed `crons` key, a spread options
416
+ * object, and anything a project put in `triggers.crons` for its own reasons —
417
+ * is what the preserve rule below is for. It is not redundant with discovery; it
418
+ * is the half discovery provably cannot reach.
419
+ *
420
+ * Ownership is recorded in the project's `package.json` under `lunora.crons`,
421
+ * which is why a REMOVED generated cron still gets cleared (it is in the record
422
+ * and no longer in `cronTriggers`) while a hand-written one never is. Three
423
+ * properties pick that location:
424
+ *
425
+ * COMMITTED, so it survives a fresh clone. Gitignored `.lunora/` state does not:
426
+ * a CI-only deploy finds none, and falling back to add-only there leaves a
427
+ * removed cron firing forever.
428
+ *
429
+ * VALID JSON, so `wrangler.json` — a supported config name — behaves exactly like
430
+ * `wrangler.jsonc`. A `//` marker inside the config does not: wrangler tolerates
431
+ * one in either (both go through its JSONC parser), but the project's own
432
+ * `JSON.parse`, its deploy wrapper and its editor's JSON schema validation all
433
+ * break the moment a `.json` grows a comment. Nor can the record be a plain key
434
+ * in the wrangler config — wrangler reports unknown fields ("Unexpected fields
435
+ * found in top-level field") on every command.
436
+ *
437
+ * READ AND WRITTEN AT ONE ADDRESS. A comment has to be found textually on the way
438
+ * in and positioned structurally on the way out, and those are not the same
439
+ * place: a stale duplicate higher in the file was read as the record and deleted
440
+ * the user's backup trigger.
441
+ *
442
+ * The wrangler config is rewritten only when an entry actually moves, so
443
+ * {@link ReconcileResult.changed} means what a `synced N cron trigger(s)` log
444
+ * claims it means.
445
+ *
446
+ * A project with nothing recorded yet — one predating this, or one with no
447
+ * manifest — treats every entry as the user's, which is the safe direction: a
448
+ * wrongly-kept trigger costs one no-op invocation, a wrongly-deleted one
449
+ * silently ends the backups. It becomes precise after a codegen run that still
450
+ * declares the cron; upgrading and deleting a cron in the same change records an
451
+ * empty set, and that orphan is then kept for good.
452
+ *
453
+ * This intentionally writes the SAME `triggers.crons` shape the
454
+ * `@lunora/config` validator accepts, so the wrangler validator never fights the
455
+ * generated value.
456
+ */
457
+ declare const reconcileWranglerCrons: (projectRoot: string, cronTriggers: ReadonlyArray<string>) => ReconcileResult;
458
+ /**
459
+ * The one log line worth printing for a reconcile that kept entries it does not
460
+ * own, or `undefined` when it owned the whole array. Lives here rather than in
461
+ * each caller because `lunora deploy` and the Vite plugin print it verbatim and
462
+ * had already drifted into two copies of the same sentence.
463
+ */
464
+ declare const describePreservedCrons: (preserved: ReadonlyArray<string>) => string | undefined;
465
+ /** The project coordinates every reconciler here needs. */
466
+ interface ReconcileProject {
467
+ /** Absolute path to the project root holding `wrangler.jsonc`. */
468
+ projectRoot: string;
469
+ /** The schema directory, relative to `projectRoot` (usually `"lunora"`). */
470
+ schemaDir: string;
471
+ }
472
+ /** The two logger methods every reconciler here needs; `info` is optional on Vite's. */
473
+ interface ReconcileLogger {
474
+ info?: (message: string) => void;
475
+ warn: (message: string) => void;
476
+ }
477
+ /**
478
+ * Infer the Cloudflare bindings the project's code implies and reconcile them
479
+ * into `wrangler.jsonc` (Durable Objects, their migration classes, and the
480
+ * `DB` D1 binding for `.global()` schemas). Best-effort and idempotent — runs
481
+ * once at startup so the user never hand-writes binding boilerplate. A failure
482
+ * here must never abort codegen; the wrangler validator reports real problems.
483
+ *
484
+ * `onExportGaps` (dev only) is invoked when a declared container/workflow isn't
485
+ * re-exported by the worker entry, so the caller can raise it in the browser
486
+ * error overlay in addition to the console warning.
487
+ */
488
+ declare const reconcileBindingsSafely: (options: ReconcileProject, logger: ReconcileLogger, onExportGaps?: (gaps: ReadonlyArray<ExportGap>) => void) => Promise<void>;
489
+ /** Reconcile cron triggers and the compatibility date into `wrangler.jsonc`. */
490
+ declare const reconcileWranglerExtras: (projectRoot: string, cronTriggers: ReadonlyArray<string>, logger: ReconcileLogger) => void;
491
+ /**
492
+ * The wrangler config sections Lunora can safely flip to remote mode in dev,
493
+ * each with the human label used in logs and the structural `shape` the entry
494
+ * lives in.
495
+ *
496
+ * `"array"` is a top-level array of binding objects (`d1_databases`,
497
+ * `kv_namespaces`, `r2_buckets`, `vectorize`, `services`). `"producers"` is
498
+ * `queues.producers[]` — consumers are NOT remoted (their schema has no `remote`
499
+ * field) and the edit path is two levels deep. `"object"` is a single binding
500
+ * object, not an array (`ai`), whose edit path targets the section key directly.
501
+ *
502
+ * Every kind here was confirmed against `wrangler/config-schema.json`: the
503
+ * entry's schema declares a `remote` property. Deliberately omits
504
+ * `durable_objects` (no CF remote-DO mode; shards stay local) and sections whose
505
+ * schema has no `remote` field (`hyperdrive`, `analytics_engine_datasets`,
506
+ * `secrets_store_secrets`, queue consumers, …). Widening further is a one-line
507
+ * table edit.
508
+ */
509
+ declare const REMOTE_ELIGIBLE_KEYS: {
510
+ readonly ai: {
511
+ readonly label: "AI";
512
+ readonly shape: "object";
513
+ };
514
+ readonly d1_databases: {
515
+ readonly label: "D1";
516
+ readonly shape: "array";
517
+ };
518
+ readonly kv_namespaces: {
519
+ readonly label: "KV";
520
+ readonly shape: "array";
521
+ };
522
+ readonly queues: {
523
+ readonly label: "Queue";
524
+ readonly shape: "producers";
525
+ };
526
+ readonly r2_buckets: {
527
+ readonly label: "R2";
528
+ readonly shape: "array";
529
+ };
530
+ readonly services: {
531
+ readonly label: "Service";
532
+ readonly shape: "array";
533
+ };
534
+ readonly vectorize: {
535
+ readonly label: "Vectorize";
536
+ readonly shape: "array";
537
+ };
538
+ };
539
+ type RemoteEligibleKey = keyof typeof REMOTE_ELIGIBLE_KEYS;
540
+ /** One binding object as it appears in any eligible section. */
541
+ interface BindingEntry {
542
+ binding?: string;
543
+ remote?: boolean;
544
+ }
545
+ /** One binding entry we mark remote, with enough provenance to log + edit it. */
546
+ interface RemoteBindingPlan {
547
+ /** The binding name as declared in the config (e.g. `"DB"`, `"FILES"`). */
548
+ binding: string;
549
+ /** Short kind label for logging (`"D1"`, `"KV"`, `"R2"`, `"Vectorize"`, …). */
550
+ kind: string;
551
+ /**
552
+ * The jsonc edit path within {@link RemoteBindingPlan.section}, relative to
553
+ * the section key: `[index]` for an `"array"` section, `["producers", index]`
554
+ * for a queue producer, or `[]` for the single-object `ai` section. The
555
+ * materializer prepends the section key and appends `"remote"`.
556
+ */
557
+ path: ReadonlyArray<number | string>;
558
+ /** The wrangler config key the entry lives under. */
559
+ section: RemoteEligibleKey;
560
+ }
561
+ /** The structural slice of a wrangler config the remote planner reads. */
562
+ interface RemoteWranglerShape {
563
+ ai?: BindingEntry | null;
564
+ d1_databases?: ReadonlyArray<BindingEntry | null | undefined>;
565
+ kv_namespaces?: ReadonlyArray<BindingEntry | null | undefined>;
566
+ queues?: {
567
+ producers?: ReadonlyArray<BindingEntry | null | undefined>;
568
+ } | null;
569
+ r2_buckets?: ReadonlyArray<BindingEntry | null | undefined>;
570
+ services?: ReadonlyArray<BindingEntry | null | undefined>;
571
+ vectorize?: ReadonlyArray<BindingEntry | null | undefined>;
572
+ }
573
+ /**
574
+ * Inspect a parsed wrangler config and list every eligible binding that should
575
+ * be flipped to remote mode. Pure — no file-system access, no mutation. An
576
+ * entry already carrying `"remote": true` is still reported (so logging is
577
+ * complete) but the materializer's edit is a harmless no-op for it.
578
+ */
579
+ declare const planRemoteBindings: (parsed: RemoteWranglerShape) => RemoteBindingPlan[];
580
+ /**
581
+ * Inject `"remote": true` onto each planned binding in the config `text`,
582
+ * comment-preservingly via jsonc edits. Pure string→string; the edits target
583
+ * disjoint entries so applying them sequentially is safe. The edit path is
584
+ * `[section, ...plan.path, "remote"]`, which resolves to the array element, the
585
+ * `queues.producers[i]` entry, or the single `ai` object as the plan demands.
586
+ */
587
+ declare const injectRemoteFlags: (text: string, plans: ReadonlyArray<RemoteBindingPlan>) => string;
588
+ interface MaterializeOptions {
589
+ /** When `false`, the call is a no-op (returns `enabled: false`). */
590
+ enabled: boolean;
591
+ projectRoot: string;
592
+ }
593
+ interface MaterializeResult {
594
+ /**
595
+ * Removes the generated temp config file. Always present and always safe to
596
+ * call: it is idempotent, a no-op when nothing was written (disabled /
597
+ * fall-through cases), and never throws if the path is already gone. The dev
598
+ * command calls this on every exit path (normal, signal, error).
599
+ */
600
+ cleanup: () => void;
601
+ /**
602
+ * Absolute path to the generated temp config to pass to
603
+ * `wrangler dev --config`. `undefined` when remote mode is disabled, no
604
+ * wrangler config was found, it failed to parse, or it declared no eligible
605
+ * binding (nothing to remote — run plain local dev).
606
+ */
607
+ configPath?: string;
608
+ /** Whether remote mode was requested at all. */
609
+ enabled: boolean;
610
+ /** Why no temp config was produced, for logging (only set when none was). */
611
+ reason?: string;
612
+ /** The bindings flipped to remote, for the dev banner. */
613
+ remoteBindings: RemoteBindingPlan[];
614
+ }
615
+ /**
616
+ * Produce a temporary wrangler config with `"remote": true` on every eligible
617
+ * binding, so `lunora dev` can run `wrangler dev --config <temp>` against the
618
+ * deployed D1/KV/R2 without touching the user's file.
619
+ *
620
+ * The temp file is written as a sibling of the source `wrangler.jsonc` (in the
621
+ * project root), NOT an OS temp dir: wrangler resolves a config's relative paths
622
+ * (`main`, `assets`, `migrations_dir`, …) against the **config file's own
623
+ * directory**, so a temp config in `/tmp` would make wrangler look for
624
+ * `/tmp/src/server.ts` and fail to start the worker. Keeping it beside the real
625
+ * config preserves those relative paths. Returns `configPath: undefined` (with a
626
+ * `reason`) for every fall-through case so the caller degrades to plain local
627
+ * dev instead of failing.
628
+ */
629
+ declare const materializeRemoteWranglerConfig: (options: MaterializeOptions) => MaterializeResult;
630
+ /**
631
+ * Parse a `LUNORA_REMOTE` env value into the on/off decision. Truthy when set to
632
+ * `"1"` or `"true"` (case-insensitive); anything else — unset, `"0"`, `"false"`,
633
+ * empty — is off. Mirrors the `"1" | "true"` convention used across the runtime.
634
+ */
635
+ declare const isRemoteEnvEnabled: (value: string | undefined) => boolean;
636
+ /** The three inputs that can switch remote-binding dev on, in precedence order. */
637
+ interface RemoteEnableInputs {
638
+ /**
639
+ * The `remote` preference from `lunora.config.*` (the lowest-priority signal).
640
+ * `undefined` means "no project preference"; an explicit `false` here loses
641
+ * to neither the flag nor the env when those are absent — it just stays off.
642
+ */
643
+ configPreference?: boolean;
644
+ /** The raw `LUNORA_REMOTE` env value (parsed with {@link isRemoteEnvEnabled}). */
645
+ envValue?: string;
646
+ /** The explicit `--remote` CLI flag — `true` when passed, `undefined`/`false` otherwise. */
647
+ flag?: boolean;
648
+ }
649
+ /**
650
+ * Resolve whether remote-binding dev is on, with a clear precedence:
651
+ *
652
+ * 1. an explicit `--remote` flag (highest — a deliberate per-invocation choice),
653
+ * 2. then `LUNORA_REMOTE` in the environment,
654
+ * 3. then the `remote` key in `lunora.config.*` (lowest — a project default).
655
+ *
656
+ * The flag and env are one-directional (they can only turn remote *on*); only
657
+ * the config preference carries a meaningful `false`, and it applies solely when
658
+ * neither stronger signal is present. So a project that sets `"remote": false`
659
+ * is still overridable per-run by `--remote` or `LUNORA_REMOTE=1`.
660
+ */
661
+ declare const resolveRemoteEnabled: (inputs: RemoteEnableInputs) => boolean;
662
+ /** The `wrangler.jsonc` shape the validator reads, and the report it returns. */
663
+ interface WranglerDurableObjectBinding {
664
+ class_name?: string;
665
+ name?: string;
666
+ /** Present when the class lives in ANOTHER Worker — then it is that script's to export, not this entry's. */
667
+ script_name?: string;
668
+ }
669
+ /**
670
+ * A `tail_consumers` entry: a Worker that receives this Worker's tail events
671
+ * (logs, exceptions, fetch metadata) for forwarding to an external sink. See
672
+ * `withTailConsumer` for the wiring helper.
673
+ */
674
+ interface TailConsumer {
675
+ /** Optional Cloudflare environment of the consumer Worker. */
676
+ environment?: string;
677
+ /** Name of the Worker that consumes tail events. */
678
+ service?: string;
679
+ }
680
+ /** A wrangler `containers[]` entry (parsed from untrusted JSONC). */
681
+ interface WranglerContainerEntry {
682
+ class_name?: string;
683
+ image?: string;
684
+ /** Named images under the `durable_object` scheduling policy. */
685
+ images?: Record<string, {
686
+ build_context?: string;
687
+ build_vars?: Record<string, string>;
688
+ dockerfile?: string;
689
+ image?: string;
690
+ } | null | undefined>;
691
+ instance_type?: string | {
692
+ disk_mb?: number;
693
+ memory_mib?: number;
694
+ vcpu?: number;
695
+ };
696
+ max_instances?: number;
697
+ scheduling_policy?: string;
698
+ }
699
+ /**
700
+ * A wrangler `workflows[]` entry (parsed from untrusted JSONC). Unlike
701
+ * containers, workflows are NOT Durable Objects — the entry stands alone (no
702
+ * `durable_objects` binding, no migration class).
703
+ */
704
+ interface WranglerWorkflowEntry {
705
+ binding?: string;
706
+ class_name?: string;
707
+ /** `{ success_retention?, error_retention? }` durations; shape-checked by `validateWorkflowSettings`. */
708
+ default_retention?: unknown;
709
+ /** `{ steps? }`; shape-checked by `validateWorkflowSettings`. */
710
+ limits?: unknown;
711
+ name?: string;
712
+ /** Cron strings that each start an instance; shape-checked by `validateWorkflowSettings`. */
713
+ schedules?: unknown;
714
+ /** Present when the class lives in ANOTHER Worker — then it is that script's to export. */
715
+ script_name?: string;
716
+ }
717
+ /** A wrangler `queues.producers[]` entry — a `Queue` binding sending to `queue`. */
718
+ interface WranglerQueueProducer {
719
+ binding?: string;
720
+ delivery_delay?: number;
721
+ queue?: string;
722
+ }
723
+ /** A wrangler `queues.consumers[]` entry — push (worker) or `type: "http_pull"`. */
724
+ interface WranglerQueueConsumer {
725
+ dead_letter_queue?: string;
726
+ max_batch_size?: number;
727
+ max_batch_timeout?: number;
728
+ max_retries?: number;
729
+ queue?: string;
730
+ retry_delay?: number;
731
+ type?: string;
732
+ }
733
+ interface WranglerConfig {
734
+ ai?: {
735
+ binding?: unknown;
736
+ } | null;
737
+ analytics_engine_datasets?: ReadonlyArray<{
738
+ binding?: string;
739
+ dataset?: string;
740
+ } | null | undefined>;
741
+ artifacts?: ReadonlyArray<{
742
+ binding?: string;
743
+ namespace?: string;
744
+ remote?: boolean;
745
+ } | null | undefined>;
746
+ assets?: {
747
+ binding?: string;
748
+ directory?: string;
749
+ html_handling?: string;
750
+ not_found_handling?: string;
751
+ };
752
+ browser?: {
753
+ binding?: string;
754
+ };
755
+ cache?: {
756
+ enabled?: boolean;
757
+ } | null;
758
+ compatibility_date?: string;
759
+ compatibility_flags?: ReadonlyArray<string>;
760
+ containers?: ReadonlyArray<WranglerContainerEntry | null | undefined>;
761
+ d1_databases?: ReadonlyArray<{
762
+ binding?: string;
763
+ database_id?: string;
764
+ database_name?: string;
765
+ migrations_dir?: string;
766
+ migrations_pattern?: string;
767
+ } | null | undefined>;
768
+ dispatch_namespaces?: ReadonlyArray<{
769
+ binding?: string;
770
+ namespace?: string;
771
+ outbound?: unknown;
772
+ } | null | undefined>;
773
+ durable_objects?: {
774
+ bindings?: ReadonlyArray<WranglerDurableObjectBinding>;
775
+ };
776
+ env?: Record<string, WranglerConfig>;
777
+ exports?: Record<string, {
778
+ cache?: {
779
+ enabled?: boolean;
780
+ } | null;
781
+ default_retention?: unknown;
782
+ limits?: unknown;
783
+ name?: unknown;
784
+ schedules?: unknown;
785
+ type?: string;
786
+ } | null> | null;
787
+ flagship?: ReadonlyArray<{
788
+ app_id?: string;
789
+ binding?: string;
790
+ } | null | undefined>;
791
+ hyperdrive?: ReadonlyArray<{
792
+ binding?: string;
793
+ id?: string;
794
+ localConnectionString?: string;
795
+ } | null | undefined>;
796
+ images?: {
797
+ binding?: string;
798
+ };
799
+ kv_namespaces?: ReadonlyArray<{
800
+ binding?: string;
801
+ id?: string;
802
+ } | null | undefined>;
803
+ limits?: {
804
+ cpu_ms?: number;
805
+ };
806
+ logpush?: boolean;
807
+ main?: string;
808
+ media?: {
809
+ binding?: string;
810
+ };
811
+ migrations?: ReadonlyArray<{
812
+ deleted_classes?: ReadonlyArray<string>;
813
+ new_classes?: ReadonlyArray<string>;
814
+ new_sqlite_classes?: ReadonlyArray<string>;
815
+ renamed_classes?: ReadonlyArray<{
816
+ from?: string;
817
+ to?: string;
818
+ } | null | undefined>;
819
+ } | null | undefined>;
820
+ mtls_certificates?: ReadonlyArray<{
821
+ binding?: string;
822
+ certificate_id?: string;
823
+ } | null | undefined>;
824
+ observability?: {
825
+ enabled?: boolean;
826
+ head_sampling_rate?: number;
827
+ logs?: {
828
+ enabled?: boolean;
829
+ head_sampling_rate?: number;
830
+ invocation_logs?: boolean;
831
+ };
832
+ };
833
+ pipelines?: ReadonlyArray<{
834
+ binding?: string;
835
+ pipeline?: string;
836
+ stream?: string;
837
+ } | null | undefined>;
838
+ placement?: {
839
+ host?: string;
840
+ hostname?: string;
841
+ mode?: string;
842
+ region?: string;
843
+ };
844
+ queues?: {
845
+ consumers?: ReadonlyArray<WranglerQueueConsumer | null | undefined>;
846
+ producers?: ReadonlyArray<WranglerQueueProducer | null | undefined>;
847
+ };
848
+ r2_buckets?: ReadonlyArray<{
849
+ binding?: string;
850
+ bucket_name?: string;
851
+ } | null | undefined>;
852
+ secrets?: {
853
+ required?: unknown;
854
+ } | null;
855
+ secrets_store_secrets?: ReadonlyArray<{
856
+ binding?: string;
857
+ secret_name?: string;
858
+ store_id?: string;
859
+ } | null | undefined>;
860
+ send_email?: ReadonlyArray<{
861
+ allowed_destination_addresses?: ReadonlyArray<string>;
862
+ destination_address?: string;
863
+ name?: string;
864
+ } | null | undefined>;
865
+ services?: ReadonlyArray<{
866
+ binding?: string;
867
+ entrypoint?: string;
868
+ environment?: string;
869
+ service?: string;
870
+ } | null | undefined>;
871
+ stream?: {
872
+ binding?: string;
873
+ };
874
+ tail_consumers?: ReadonlyArray<TailConsumer | null | undefined>;
875
+ vars?: Record<string, unknown>;
876
+ vectorize?: ReadonlyArray<{
877
+ binding?: string;
878
+ index_name?: string;
879
+ } | null | undefined>;
880
+ vpc_networks?: ReadonlyArray<{
881
+ binding?: string;
882
+ network_id?: string;
883
+ remote?: boolean;
884
+ tunnel_id?: string;
885
+ } | null | undefined>;
886
+ vpc_services?: ReadonlyArray<{
887
+ binding?: string;
888
+ remote?: boolean;
889
+ service_id?: string;
890
+ } | null | undefined>;
891
+ workflows?: ReadonlyArray<WranglerWorkflowEntry | null | undefined>;
892
+ }
893
+ interface WranglerValidationReport {
894
+ errors: string[];
895
+ valid: boolean;
896
+ warnings: string[];
897
+ }
898
+ /**
899
+ * Return a new `WranglerConfig` with `consumer` present in `tail_consumers`,
900
+ * wiring this Worker to forward its tail events (logs/exceptions) to another
901
+ * Worker that fans them out to an external sink. Pure and idempotent: an
902
+ * existing entry with the same `service` + `environment` is left untouched
903
+ * rather than duplicated, so it is safe to call on every codegen/deploy.
904
+ */
905
+ declare const withTailConsumer: (wrangler: WranglerConfig, consumer: TailConsumer) => WranglerConfig;
906
+ /**
907
+ * Single source of truth for "does this wrangler config enable Workers
908
+ * Cache?" and "what compatibility_date does that require?".
909
+ *
910
+ * Before this module, `reconcile-compatibility-date.ts` (auto-bump) and
911
+ * `wrangler-validator.ts` (validation) each carried their own
912
+ * `WORKERS_CACHE_MIN_DATE` literal and their own top-level/`exports[]`
913
+ * cache-enabled walk — two copies of the same fact that could silently drift
914
+ * apart (a date bumped in one file without the other would either validate a
915
+ * config the reconciler wouldn't produce, or vice versa).
916
+ */
917
+ /** The `compatibility_date` Workers Cache (`cache.enabled: true`) requires. */
918
+ declare const WORKERS_CACHE_MIN_DATE = "2026-05-01";
919
+ /** The subset of a parsed `wrangler.jsonc` the cache-enabled check reads. */
920
+ interface WranglerCacheShape {
921
+ cache?: {
922
+ enabled?: boolean;
923
+ } | null;
924
+ exports?: Record<string, {
925
+ cache?: {
926
+ enabled?: boolean;
927
+ } | null;
928
+ } | null> | null;
929
+ }
930
+ /**
931
+ * Whether Workers Cache is enabled anywhere in a parsed wrangler config — the
932
+ * top-level `cache.enabled` toggle, or a per-export override in
933
+ * `exports[name].cache.enabled` (Workers can scope cache per named export).
934
+ * `undefined`/`null` (an unparsed or absent config) is treated as disabled.
935
+ */
936
+ declare const isCacheEnabled: (parsed: WranglerCacheShape | null | undefined) => boolean;
937
+ interface WranglerEnvironmentMerge {
938
+ /** Set when `environment` names no `env.<name>` block declared in the config — the caller should treat this as a hard validation failure. */
939
+ error?: string;
940
+ /** The env-scoped view: `wrangler` unchanged when `environment` is `undefined`, otherwise merged per {@link NON_INHERITABLE_KEYS} / {@link INHERITABLE_KEYS}. */
941
+ merged: WranglerConfig;
942
+ /**
943
+ * Keys the env block overrides whose inheritance status this validator
944
+ * cannot verify (not in either table above) — validated against the
945
+ * TOP-LEVEL value only, per the "do not guess" rule; the override is
946
+ * silently ignored for validation purposes. The caller logs this ONCE
947
+ * (not per key) so an unusual `env.<name>` block doesn't spam warnings.
948
+ */
949
+ unverifiedKeys: string[];
950
+ }
951
+ /**
952
+ * Resolve the config view `wrangler deploy --env <environment>` will actually
953
+ * use. Undefined `environment` returns `wrangler` unchanged — the top-level
954
+ * config is what a plain `wrangler deploy` reads, same as today.
955
+ *
956
+ * Deliberately independent of any other merge in this module: called fresh
957
+ * from the ORIGINAL `wrangler` each time (see both call sites), so there is
958
+ * no risk of merging an already-merged config and silently losing the
959
+ * top-level fallback a second merge pass would no longer have access to.
960
+ */
961
+ declare const mergeWranglerEnvironment: (wrangler: WranglerConfig, environment: string | undefined) => WranglerEnvironmentMerge;
962
+ /** Candidate wrangler config filenames, in the order every consumer probes them. */
963
+ declare const WRANGLER_FILES: readonly ["wrangler.jsonc", "wrangler.json"];
964
+ /** Locate the project's wrangler config, or `undefined` when none exists. */
965
+ declare const findWranglerFile: (projectRoot: string) => string | undefined;
966
+ interface ReadWranglerResult<T> {
967
+ /** Parsed config, or `undefined` when the file was not valid JSONC. */
968
+ parsed: T | undefined;
969
+ /** Raw file text — needed for comment-preserving `modify`/`applyEdits`. */
970
+ text: string;
971
+ }
972
+ /**
973
+ * Read and JSONC-parse a wrangler config file. Returns the raw `text` (for
974
+ * structural edits) alongside `parsed`, which is `undefined` when the file is
975
+ * not valid JSONC or does not parse to an object. Allows trailing commas, as
976
+ * wrangler does.
977
+ */
978
+ declare const readWranglerJsonc: <T = unknown>(wranglerPath: string) => ReadWranglerResult<T>;
979
+ interface WranglerProjectValidationOptions {
980
+ /**
981
+ * Cloudflare environment to validate against `env.<name>` in
982
+ * wrangler.jsonc. See {@link mergeWranglerEnvironment} for which keys
983
+ * inherit the top-level value vs must be redeclared per environment.
984
+ * Omit to validate the top-level config only (unchanged default).
985
+ */
986
+ environment?: string;
987
+ projectRoot: string;
988
+ schemaDir?: string;
989
+ }
990
+ interface WranglerProjectValidationResult {
991
+ problems: ReadonlyArray<string>;
992
+ report: WranglerValidationReport;
993
+ wranglerPath: string | undefined;
994
+ }
995
+ /**
996
+ * The phrase every unexported-class error carries.
997
+ *
998
+ * Exported because it is a CONTRACT, not prose: `lunora doctor` picks these
999
+ * errors out of the report by substring to raise its own finding, and the
1000
+ * validator's report is a flat `string[]`. Until the report entries carry a
1001
+ * code, a copy-edit here would silently disable that check — so the copy-edit
1002
+ * has to go through this constant.
1003
+ */
1004
+ declare const UNEXPORTED_CLASS_MARKER = "does not export it";
1005
+ /**
1006
+ * File-system aware variant: reads `wrangler.jsonc`/`wrangler.json` from
1007
+ * the given project root, discovers the schema (if any), and delegates to
1008
+ * `validateWranglerConfig`. Returns the legacy
1009
+ * `{ problems, wranglerPath }` shape plus the structured `report`.
1010
+ */
1011
+ declare const validateWranglerProject: (options: WranglerProjectValidationOptions) => WranglerProjectValidationResult;
1012
+ /**
1013
+ * Pure scan of a `vars` map for plaintext secrets — the FS-free core, exported for
1014
+ * unit tests. A variable is flagged when, for a **string** value that is neither a
1015
+ * placeholder nor a public/publishable key, EITHER the value matches a known
1016
+ * secret shape (`secretKindOf`) OR the key name strongly implies a secret and the
1017
+ * value is long enough to plausibly be one. `kind` is the matched shape, or
1018
+ * `secret_named_var` for the key-name path.
1019
+ */
1020
+ declare const scanWranglerVariablesForSecrets: (variables: Record<string, unknown> | undefined, file: string) => WranglerVariableIR[];
1021
+ /**
1022
+ * Read the project's `wrangler.jsonc` and return its plaintext-secret `vars` as IR
1023
+ * for the `plaintext_secret_in_wrangler_vars` lint. Returns `[]` when there is no
1024
+ * wrangler config, it doesn't parse, or nothing looks like a secret. Scans the
1025
+ * top-level `vars` block (mirroring the existing `validateCorsVariables` scope);
1026
+ * per-environment `env.<name>.vars` overrides are out of scope for now.
1027
+ */
1028
+ declare const collectWranglerSecretVariables: (projectRoot: string) => WranglerVariableIR[];
1029
+ declare const REQUIRED_COMPATIBILITY_DATE: string;
1030
+ declare const REQUIRED_FLAG: string;
1031
+ /**
1032
+ * Pure validator: given a parsed `WranglerConfig` object and an optional
1033
+ * `SchemaInfo`, produce a structured report. Performs no I/O.
1034
+ *
1035
+ * `environment`, when set, validates the `env.<environment>` view
1036
+ * ({@link mergeWranglerEnvironment}) instead of the top-level config — e.g. a
1037
+ * `durable_objects` binding present only at the top level is a validation
1038
+ * FAILURE for `--env production` if `env.production` doesn't repeat it,
1039
+ * because `durable_objects` is non-inheritable and wrangler will not carry it
1040
+ * over. Omit `environment` to validate the top level only (unchanged default).
1041
+ */
1042
+ declare const validateWranglerConfig: (wranglerInput: WranglerConfig | undefined, schema?: SchemaInfo, environment?: string) => WranglerValidationReport;
1043
+ /**
1044
+ * Convenience alias matching the original task-spec signature
1045
+ * `validateWrangler(wranglerJson, schema)` returning
1046
+ * `{ valid, errors, warnings }`.
1047
+ */
1048
+ declare const validateWrangler: typeof validateWranglerConfig;
1049
+ export { type AlchemyTranslation, type AssertWranglerOptions, BINDING_MANIFEST_VERSION, type BindingManifest, type BindingRequirement, CLOUDFLARE_DRIVER, type ExportGap, type ManifestConfigShape, type MaterializeOptions, type MaterializeResult, REMOTE_ELIGIBLE_KEYS, REQUIRED_COMPATIBILITY_DATE, REQUIRED_FLAG, type ReadWranglerResult, type ReconcileBindingsResult, type ReconcileCompatibilityDateResult, type ReconcileResult as ReconcileCronsResult, type ReconcileProject, type RemoteBindingPlan, type RemoteEnableInputs, type RemoteWranglerShape, type TailConsumer, UNEXPORTED_CLASS_MARKER, WORKERS_CACHE_MIN_DATE, WRANGLER_FILES, type WranglerCacheShape, type WranglerConfig, type WranglerConfigShape, type WranglerContainerEntry, type WranglerEnvironmentMerge, type WranglerProjectValidationOptions, type WranglerProjectValidationResult, type WranglerValidationReport, type WranglerWorkflowEntry,
1050
+ /**
1051
+ * `@lunora/config/cloudflare` — the wrangler layer.
1052
+ *
1053
+ * Everything here speaks `wrangler.jsonc`: validating it, reconciling inferred
1054
+ * bindings/crons/compatibility-date into it, resolving remote bindings, and the
1055
+ * `DeployDriver` that ties them together for `--target cloudflare`.
1056
+ *
1057
+ * Split out from the package root so `@lunora/config` itself stays
1058
+ * provider-neutral. The root keeps what any target needs — the `DeployDriver`
1059
+ * contract, the driver registry, project config and target resolution,
1060
+ * `.dev.vars` grammar, binding *inference* — while emission and validation,
1061
+ * which are wrangler-shaped by definition, live behind this subpath.
1062
+ * Plan 114 §5.3 (D6): a package carrying real provider code isolates it behind a
1063
+ * subpath rather than relocating wholesale.
1064
+ */
1065
+ applyModify, assertWranglerSatisfiesSchema, buildBindingManifest, collectExportGaps, collectWranglerSecretVariables, describePreservedCrons, findWranglerFile, injectRemoteFlags, isCacheEnabled, isRemoteEnvEnabled, materializeRemoteWranglerConfig, mergeWranglerEnvironment, planRemoteBindings, readWranglerJsonc, reconcileBindingsSafely, reconcileWranglerBindings, reconcileWranglerCompatibilityDate, reconcileWranglerCrons, reconcileWranglerExtras, resolveRemoteEnabled, scanWranglerVariablesForSecrets, validateWrangler, validateWranglerConfig, validateWranglerProject, withTailConsumer, wranglerToAlchemy };