@lunora/config 1.0.0-alpha.405 → 1.0.0-alpha.407

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 (45) hide show
  1. package/dist/cli/index.d.mts +2 -2
  2. package/dist/cli/index.d.ts +2 -2
  3. package/dist/cli/index.mjs +1 -1
  4. package/dist/cloudflare/index.d.mts +5 -97
  5. package/dist/cloudflare/index.d.ts +5 -97
  6. package/dist/cloudflare/index.mjs +1 -1
  7. package/dist/index.d.mts +67 -6
  8. package/dist/index.d.ts +67 -6
  9. package/dist/index.mjs +1 -1
  10. package/dist/packem_shared/D1_PLACEHOLDER_ID-BpUWE6_j.mjs +1 -0
  11. package/dist/packem_shared/{DEFAULT_DEPLOY_TARGET-CnovxJid.mjs → DEFAULT_DEPLOY_TARGET-T8UHP3bB.mjs} +1 -1
  12. package/dist/packem_shared/{DEV_WORKER_ENV_VALUE-CARjGoAv.mjs → DEV_WORKER_ENV_VALUE-Dx-b7eJB.mjs} +1 -1
  13. package/dist/packem_shared/PACKAGE_SECRETS_REGISTRY-CccA2ip9.mjs +1 -0
  14. package/dist/packem_shared/{POLICY_SCAFFOLD_ENDPOINT-BISd53nh.mjs → POLICY_SCAFFOLD_ENDPOINT-BLMGCD5t.mjs} +1 -1
  15. package/dist/packem_shared/{SCHEMA_EDIT_ENDPOINT-B-Xii8Ke.mjs → SCHEMA_EDIT_ENDPOINT-DrPTyuPd.mjs} +1 -1
  16. package/dist/packem_shared/{STUDIO_PATH-rjtY7n7Q.mjs → STUDIO_PATH-CttpqT9E.mjs} +1 -1
  17. package/dist/packem_shared/{assertBuildTargetMatches-Bw7uURKp.mjs → assertBuildTargetMatches-CJI4jNxP.mjs} +1 -1
  18. package/dist/packem_shared/buildPackageSecretsBlock-Cb5Ze3_1.mjs +19 -0
  19. package/dist/packem_shared/celld-config-DeMDgYAu.mjs +3 -0
  20. package/dist/packem_shared/{deploy-driver.d-Cl96-c1l.d.mts → deploy-driver.d-DraUd2R2.d.mts} +2 -0
  21. package/dist/packem_shared/{deploy-driver.d-Cl96-c1l.d.ts → deploy-driver.d-DraUd2R2.d.ts} +2 -0
  22. package/dist/packem_shared/ensureGitignoreEntries-Tsk8Qkw7.mjs +7 -0
  23. package/dist/packem_shared/{index.d-DkNi7r6E.d.mts → index.d-DSqsbmlq.d.mts} +1 -1
  24. package/dist/packem_shared/{index.d-Cmx4jMFV.d.ts → index.d-sZ22Dkwr.d.ts} +1 -1
  25. package/dist/packem_shared/inferLunoraBindings-BHztYpw9.mjs +1 -0
  26. package/dist/packem_shared/package-secrets-registry-Cx0qpPjB.mjs +1 -0
  27. package/dist/packem_shared/probeCelldToolchain-DxDttfHy.mjs +1 -0
  28. package/dist/packem_shared/reconcile-bindings-B3bPJPeQ.mjs +2 -0
  29. package/dist/packem_shared/{infer-bindings.d-C9ktoVW4.d.ts → reconcile-bindings.d-LHrpR4kY.d.mts} +103 -1
  30. package/dist/packem_shared/{infer-bindings.d-C9ktoVW4.d.mts → reconcile-bindings.d-LHrpR4kY.d.ts} +103 -1
  31. package/dist/packem_shared/reconcileBindingsSafely-Br0hhKmd.mjs +1 -0
  32. package/dist/packem_shared/{scanWranglerVariablesForSecrets-CZDS9y2i.mjs → scanWranglerVariablesForSecrets-DXuYZNqq.mjs} +1 -1
  33. package/dist/packem_shared/startCelldDevSession-BI3x-_-q.mjs +1 -0
  34. package/dist/packem_shared/{wranglerCodegenInputs-UqO5e_qJ.mjs → wranglerCodegenInputs-7WopgQo4.mjs} +1 -1
  35. package/dist/packem_shared/{write-atomic-nFihpdk8.mjs → write-atomic-DSo8BGHA.mjs} +1 -1
  36. package/dist/studio-host/index.mjs +1 -1
  37. package/package.json +4 -4
  38. package/dist/packem_shared/HYPERDRIVE_PLACEHOLDER_ID-DPgHQEDf.mjs +0 -2
  39. package/dist/packem_shared/PACKAGE_SECRETS_REGISTRY-DI99PpTL.mjs +0 -1
  40. package/dist/packem_shared/buildPackageSecretsBlock-C5WZfMwe.mjs +0 -19
  41. package/dist/packem_shared/celld-config-Iv0tK526.mjs +0 -3
  42. package/dist/packem_shared/inferLunoraBindings-DMvPygeU.mjs +0 -1
  43. package/dist/packem_shared/package-secrets-registry-BEJELdls.mjs +0 -1
  44. package/dist/packem_shared/reconcileBindingsSafely-xWmrGHnx.mjs +0 -1
  45. package/dist/packem_shared/startCelldDevSession-PHdbwtI5.mjs +0 -1
@@ -183,6 +183,8 @@ interface InferredBindings {
183
183
  * un-mintable `app_id`, so it is reconciled as a hint, not auto-written.
184
184
  */
185
185
  flagshipBinding?: string;
186
+ /** The app hosts the registry (exports or binds `ShardRegistryDO`, or is merged with its module), so it mints the `LUNORA_RELAY_SECRET` its registry checks. */
187
+ hostsShardRegistry: boolean;
186
188
  /**
187
189
  * The schema's `.jurisdiction("…")`, when it declares one. Read by the binding
188
190
  * hints whose resource takes its residency at creation (Artifacts), so the
@@ -297,4 +299,104 @@ declare const inferLunoraBindings: (options: InferOptions) => Promise<InferredBi
297
299
  * ({@link SECRET_SOURCE_FLAGS}), keeping only sources that carry secrets.
298
300
  */
299
301
  declare const secretSourcesFromBindings: (bindings: InferredBindings) => string[];
300
- export { COMPOSED_WORKER_ENTRY as C, DiscoveryCache as D, GeneratedClassModule as G, InferredBindings as I, MERGED_DURABLE_OBJECTS_MODULE as M, SchemaInfo as S, DURABLE_OBJECT_BINDINGS as a, DiscoverSchemaInfoResult as b, GENERATED_CLASS_MODULES as c, GENERATED_MODULE_DURABLE_OBJECTS as d, InferOptions as e, InferredAgent as f, InferredContainer as g, InferredWorkflow as h, createDiscoveryCache as i, discoverSchemaInfo as j, inferLunoraBindings as k, isMergedProject as l, isMergedRoleModule as m, secretSourcesFromBindings as s };
302
+ /**
303
+ * Placeholder `database_id` written for an auto-provisioned `DB` binding. It is
304
+ * intentionally not a valid id so a deploy can't silently target the wrong
305
+ * database; reconciliation warns the user to replace it (see the D1 warning in
306
+ * `reconcileWranglerBindings`).
307
+ */
308
+ declare const D1_PLACEHOLDER_ID = "<replace-with-d1-create-id>";
309
+ /**
310
+ * The `id` reconcile writes on a Hyperdrive binding it adds, and the one the `hyperdrive`
311
+ * registry item ships: wrangler requires a string, and `lunora dev` serves the binding from an
312
+ * embedded Postgres whatever it is. `lunora deploy` swaps in a real id.
313
+ */
314
+ declare const HYPERDRIVE_PLACEHOLDER_ID = "<replace-with-hyperdrive-create-id>";
315
+ /**
316
+ * A container/workflow that is declared (so codegen emits its class) but the
317
+ * worker entry never re-exports — the one wiring step the generators can't always
318
+ * do for the developer. wrangler rejects a `class_name` the deployed worker
319
+ * doesn't export, so a deploy fails late on this; surfacing it as structured data
320
+ * lets the Vite plugin raise it in the dev error overlay (not just the console)
321
+ * the moment the gap appears. The human-readable form is also folded into
322
+ * {@link ReconcileBindingsResult.warnings}.
323
+ */
324
+ interface ExportGap {
325
+ /** Generated class wrangler needs exported, e.g. `OrderPipelineWorkflow`. */
326
+ className: string;
327
+ /** The `lunora/{agents,containers,workflows}.ts` export name, e.g. `orderPipeline`. */
328
+ exportName: string;
329
+ /** Which declaration is unexported. */
330
+ kind: "agent" | "container" | "workflow";
331
+ /** The `_generated/{module}` to re-export from, e.g. `workflows`. */
332
+ module: GeneratedClassModule;
333
+ }
334
+ interface ReconcileBindingsResult {
335
+ /** Short labels for each binding written (e.g. `"SCHEDULER/SchedulerDO"`). */
336
+ added: string[];
337
+ /** `true` when `wrangler.jsonc` was rewritten. */
338
+ changed: boolean;
339
+ /** What was written to the SvelteKit / Nuxt dev sidecar's own config, when anything was. */
340
+ devConfig?: {
341
+ added: string[];
342
+ path: string;
343
+ updated: string[];
344
+ };
345
+ /**
346
+ * Declared containers/workflows the worker entry doesn't re-export — the
347
+ * structured form of the corresponding `warnings` entries, for the dev error
348
+ * overlay. Empty when every declaration is wired.
349
+ */
350
+ exportGaps: ExportGap[];
351
+ /** Reason reconciliation was skipped, for logging. */
352
+ reason?: string;
353
+ /**
354
+ * Short labels for each EXISTING entry whose settings were brought in line
355
+ * with its declaration (e.g. `"queues.consumers/receipt-queue (max_retries)"`).
356
+ * Kept apart from `added` so a retune is not logged as a new binding.
357
+ */
358
+ updated: string[];
359
+ /** Non-fatal hints for capabilities that cannot be auto-provisioned. */
360
+ warnings: string[];
361
+ /** Resolved wrangler path, or `undefined` when none was found. */
362
+ wranglerPath?: string;
363
+ }
364
+ /**
365
+ * The declared-but-not-re-exported containers and workflows, as structured
366
+ * {@link ExportGap}s. The same gaps `collectWarnings` renders into prose — kept
367
+ * here as data so the Vite plugin can raise them in the error overlay with a
368
+ * precise remediation, rather than re-parsing the warning strings.
369
+ *
370
+ * Exported because reconciliation is not the only caller that needs the answer:
371
+ * `lunora codegen` and `lunora doctor` both want the gaps WITHOUT rewriting
372
+ * `wrangler.jsonc`, which is the rest of what {@link reconcileWranglerBindings}
373
+ * does. Deriving them again from `inferred.{containers,workflows,agents}` at each
374
+ * call site is how one kind ends up silently uncovered.
375
+ */
376
+ declare const collectExportGaps: (inferred: InferredBindings) => ExportGap[];
377
+ /**
378
+ * Reconcile inferred Durable Object / D1 bindings into `wrangler.jsonc`.
379
+ *
380
+ * Writes only when something is missing; returns `changed: false` when the
381
+ * config already satisfies the inferred needs.
382
+ *
383
+ * `environment`, when passed, does NOT change where this provisions — every
384
+ * step below still only ADDS to the TOP-LEVEL config; wrangler's `env.<name>`
385
+ * blocks have no auto-provisioning path today. The one write into the block is
386
+ * {@link reconcileEnvQueues}, which retunes queue consumers the block already
387
+ * declares and adds nothing. Otherwise it is used only to emit an
388
+ * advisory warning, because bindings (`durable_objects`, `d1_databases`, …)
389
+ * are non-inheritable (see `wrangler-environment.ts`'s `NON_INHERITABLE_KEYS`):
390
+ * a `--env production` deploy needs its OWN copy of each one, and silently
391
+ * writing only to the top level would leave that gap unmentioned. Extending
392
+ * the JSONC writer itself to target `env.<name>.*` idempotently for every
393
+ * binding kind here is a separate, larger change (each of the ~10 pipeline
394
+ * steps below reads AND writes the top-level path) that this fix does not
395
+ * attempt — `lunora deploy --env <name>` now VALIDATES the env-scoped view
396
+ * (closing the reported gap), it just doesn't yet auto-provision it.
397
+ */
398
+ declare const reconcileWranglerBindings: (projectRoot: string, inferred: InferredBindings, { environment, target }?: {
399
+ environment?: string;
400
+ target?: string;
401
+ }) => ReconcileBindingsResult;
402
+ export { COMPOSED_WORKER_ENTRY as C, DiscoveryCache as D, ExportGap as E, GENERATED_CLASS_MODULES as G, HYPERDRIVE_PLACEHOLDER_ID as H, InferOptions as I, MERGED_DURABLE_OBJECTS_MODULE as M, ReconcileBindingsResult as R, SchemaInfo as S, D1_PLACEHOLDER_ID as a, DURABLE_OBJECT_BINDINGS as b, collectExportGaps as c, DiscoverSchemaInfoResult as d, GENERATED_MODULE_DURABLE_OBJECTS as e, GeneratedClassModule as f, InferredAgent as g, InferredBindings as h, InferredContainer as i, InferredWorkflow as j, createDiscoveryCache as k, discoverSchemaInfo as l, inferLunoraBindings as m, isMergedProject as n, isMergedRoleModule as o, reconcileWranglerBindings as r, secretSourcesFromBindings as s };
@@ -0,0 +1 @@
1
+ import{inferLunoraBindings as g}from"./inferLunoraBindings-BHztYpw9.mjs";import{LUNORA_TAG as r}from"./LUNORA_TAG-DQTGPqcJ.mjs";import{r as p}from"./reconcile-bindings-B3bPJPeQ.mjs";import{reconcileWranglerCompatibilityDate as $}from"./reconcileWranglerCompatibilityDate-hocXEuRA.mjs";import{reconcileWranglerCrons as m,describePreservedCrons as w}from"./describePreservedCrons-C5KPuPy3.mjs";const j=async(i,t,a)=>{try{const n=await g({projectRoot:i.projectRoot,schemaDir:i.schemaDir}),e=p(i.projectRoot,n,{target:i.target}),o=e.wranglerPath??"wrangler.jsonc";if(e.added.length>0&&t.info?.(`${r} inferred bindings → ${e.added.join(", ")} (written to ${o})`),e.updated.length>0&&t.info?.(`${r} updated bindings → ${e.updated.join(", ")} (written to ${o})`),e.devConfig!==void 0){const{added:s,path:d,updated:f}=e.devConfig;t.info?.(`${r} dev sidecar bindings → ${[...s,...f].join(", ")} (written to ${d})`)}for(const s of e.warnings)t.warn(`${r} ${s}`);e.exportGaps.length>0&&a?.(e.exportGaps)}catch(n){const e=n instanceof Error?n.message:String(n);t.warn(`${r} binding inference skipped: ${e}`)}},c=new Map,u=(i,t,a)=>{try{const n=m(i,t);n.changed&&a.info?.(`${r} synced ${t.length.toFixed(0)} cron trigger(s) into ${n.wranglerPath??"wrangler.jsonc"}`);for(const s of n.warnings)a.warn(`${r} ${s}`);const e=n.preserved.join("\0"),o=w(n.preserved);o!==void 0&&(n.changed||c.get(i)!==e)&&a.info?.(`${r} ${o}`),c.set(i,e)}catch(n){const e=n instanceof Error?n.message:String(n);a.warn(`${r} cron trigger sync skipped: ${e}`)}try{const n=$(i);n.changed&&a.info?.(`${r} bumped compatibility_date to ${n.date??"unknown"} (Workers Cache enabled) → ${n.wranglerPath??"wrangler.jsonc"}`)}catch(n){const e=n instanceof Error?n.message:String(n);a.warn(`${r} compatibility date sync skipped: ${e}`)}};export{j as reconcileBindingsSafely,u as reconcileWranglerExtras};
@@ -1 +1 @@
1
- import{secretKindOf as s,redact as c}from"@lunora/codegen";import{i as a,a as f}from"./package-secrets-registry-BEJELdls.mjs";import{isPlaceholderValue as d}from"./buildPackageSecretsBlock-C5WZfMwe.mjs";const u=8,h=(n,o)=>{if(n===void 0)return[];const r=[];for(const[i,e]of Object.entries(n)){if(typeof e!="string"||d(e)||a(i))continue;const t=s(e)??(f(i)&&e.length>=u?"secret_named_var":void 0);t!==void 0&&r.push({file:o,key:i,kind:t,preview:c(e)})}return r};export{h as scanWranglerVariablesForSecrets};
1
+ import{secretKindOf as s,redact as c}from"@lunora/codegen";import{i as a,b as f}from"./package-secrets-registry-Cx0qpPjB.mjs";import{isPlaceholderValue as d}from"./buildPackageSecretsBlock-Cb5Ze3_1.mjs";const u=8,h=(n,o)=>{if(n===void 0)return[];const r=[];for(const[i,e]of Object.entries(n)){if(typeof e!="string"||d(e)||a(i))continue;const t=s(e)??(f(i)&&e.length>=u?"secret_named_var":void 0);t!==void 0&&r.push({file:o,key:i,kind:t,preview:c(e)})}return r};export{h as scanWranglerVariablesForSecrets};
@@ -0,0 +1 @@
1
+ import{watch as _}from"node:fs";import{createServer as j}from"node:net";import{dirname as C}from"node:path";import{readServiceBindings as D}from"@lunora/codegen";import{acceptsConnection as M,startDevProcess as x}from"./acceptsConnection-DHhUYGjT.mjs";import{p as b,a as N}from"./celld-config-DeMDgYAu.mjs";import{probeCelldToolchain as O}from"./probeCelldToolchain-DxDttfHy.mjs";const F=6e4,I=200,B=new Set([".celld",".wrangler","node_modules"]),G=/[/\\]/u,H=async()=>new Promise((e,o)=>{const s=j();s.once("error",o),s.listen(0,"127.0.0.1",()=>{const n=s.address();s.close(()=>{e(typeof n=="object"&&n!==null?n.port:0)})})}),U=e=>e?.split(G).some(o=>B.has(o))===!0,q=(e,o,s)=>{let n;const c=_(e,{recursive:!0},(l,d)=>{U(d)||(clearTimeout(n),n=setTimeout(o,I))}),i=()=>{clearTimeout(n),c.close()};return c.once("error",l=>{i(),s(l)}),{close:i}},L=e=>e instanceof Error?e.message:String(e),$=async()=>O({env:process.env,purpose:"dev"}),X=async e=>{const o=await(e.probe??$)();if(o.errors.length>0)throw new Error(o.errors.join("; "));return b(e.projectRoot,"dev").write(),o.warnings},Z=async e=>{const{log:o,port:s,projectRoot:n}=e,c=(r,t="stdout")=>{o(r,{stream:t,tag:"celld"})},i=await(e.probe??$)();for(const r of i.warnings)c(r,"stderr");if(i.errors.length>0)throw new Error(i.errors.join("; "));if(await M(s))throw new Error(`port ${String(s)} is already in use — stop whatever is serving there (another dev server?), or pick another worker port`);const l=D(n);if(l.error!==void 0)throw new Error(`could not read the lunora.config services: ${l.error}`);const d=b(n,"dev");d.write();const k=C(d.configPath),v=[...new Map(l.services.map(r=>[r.wranglerPath,r])).values()],p=new AbortController,h=()=>p.signal.aborted,m=async(r,t,a)=>x({args:["dev",r,"--port",String(a)],command:"celld",cwd:n,label:"celld dev",notFound:"`celld` was not found on PATH — install it (https://celld.dev) to run the celld target",onLine:T=>{T.trim()!==""&&o(T,{stream:"stdout",tag:t})},port:a,readyTimeoutMs:F,signal:p.signal,spawn:e.spawn}),E=async r=>{const t=N(k,r.wranglerPath);t.write(),c(`registering service ${r.worker} in the local dev state`),await(await m(t.configPath,`celld:${r.worker}`,await H())).stop()};for(const r of v)await E(r);let g=()=>{};const y=new Promise(r=>{g=r}),S=async()=>{const r=await m(d.configPath,"celld",s);return r.crashed.then(g).catch(()=>{}),r};let w=await S();const A=async r=>{await w.stop();let t;try{await E(r)}catch(a){t=a instanceof Error?a:new Error(String(a))}if(!h()){try{w=await S()}catch(a){throw h()||g(1),a}if(t!==void 0)throw t}};let f=Promise.resolve();const R=r=>{c(`service ${r.worker} changed — restarting`),f=f.then(async()=>A(r)).catch(t=>{h()||c(`service ${r.worker} failed to restart: ${L(t)}`,"stderr")})},P=[],u=()=>{for(const r of P)r.close()};try{for(const r of v)P.push(q(C(r.wranglerPath),()=>{R(r)},t=>{c(`stopped watching service ${r.worker}: ${t.message} — restart the dev server to pick up its edits`,"stderr")}))}catch(r){throw u(),await w.stop(),r}return y.then(u).catch(()=>{}),{exited:y,stop:async()=>{p.abort(),u(),await f,await w.stop()}}};export{Z as startCelldDevSession,X as writeCelldDevProjection};
@@ -1 +1 @@
1
- import{relative as t}from"node:path";import{i as o}from"./guards-Buu_E7mP.mjs";import{findWranglerFile as u,readWranglerJsonc as d}from"./WRANGLER_FILES-UNW-xY5u.mjs";import{scanWranglerVariablesForSecrets as l}from"./scanWranglerVariablesForSecrets-CZDS9y2i.mjs";const n=(s,e)=>{const r=s?.producers;return(Array.isArray(r)?r:[]).flatMap(i=>o(i)&&typeof i.binding=="string"&&typeof i.queue=="string"?[{binding:i.binding,queue:i.queue,...e===void 0?{}:{env:e}}]:[])},v=s=>{const e=u(s),r=e===void 0?void 0:d(e).parsed;return e===void 0||r===void 0?{wranglerQueueProducers:[],wranglerVariables:[]}:{wranglerQueueProducers:[...n(r.queues),...Object.entries(r.env??{}).flatMap(([a,i])=>n(i?.queues,a))],wranglerVariables:l(o(r.vars)?r.vars:void 0,t(s,e))}};export{v as wranglerCodegenInputs};
1
+ import{relative as t}from"node:path";import{i as o}from"./guards-Buu_E7mP.mjs";import{findWranglerFile as u,readWranglerJsonc as d}from"./WRANGLER_FILES-UNW-xY5u.mjs";import{scanWranglerVariablesForSecrets as l}from"./scanWranglerVariablesForSecrets-DXuYZNqq.mjs";const n=(s,e)=>{const r=s?.producers;return(Array.isArray(r)?r:[]).flatMap(i=>o(i)&&typeof i.binding=="string"&&typeof i.queue=="string"?[{binding:i.binding,queue:i.queue,...e===void 0?{}:{env:e}}]:[])},v=s=>{const e=u(s),r=e===void 0?void 0:d(e).parsed;return e===void 0||r===void 0?{wranglerQueueProducers:[],wranglerVariables:[]}:{wranglerQueueProducers:[...n(r.queues),...Object.entries(r.env??{}).flatMap(([a,i])=>n(i?.queues,a))],wranglerVariables:l(o(r.vars)?r.vars:void 0,t(s,e))}};export{v as wranglerCodegenInputs};
@@ -1,3 +1,3 @@
1
- import{existsSync as s,statSync as a,writeFileSync as p,renameSync as d,rmSync as g}from"node:fs";import{join as m}from"node:path";import{runCodegen as f,CodegenDiagnosticError as j,refreshCodegenProject as u,createCodegenProject as y,findTsconfig as S,tsconfigFingerprint as C,projectConfigCandidatePaths as h}from"@lunora/codegen";import{wranglerCodegenInputs as l}from"./wranglerCodegenInputs-UqO5e_qJ.mjs";import{isCodegenDisabled as w,CODEGEN_ENV as n}from"./BUILD_ROOT_ENV-Dg4MV3wY.mjs";import{recordStudioWrite as P,STUDIO_WRITE_TEMP_SUFFIX as $}from"./STUDIO_WRITE_TEMP_SUFFIX-BTTELz3K.mjs";const F=o=>({apiSpec:o.apiSpec,lazyFunctions:o.lazyFunctions,lunoraDirectory:o.schemaDirectory??"lunora",projectRoot:o.projectRoot,...l(o.projectRoot)});let r;const c=o=>{const t=a(o);return`${o}:${String(t.mtimeMs)}:${String(t.size)}`},E=o=>{const t=S(o);return[t===void 0?"":`${c(t)}
1
+ import{existsSync as s,statSync as a,writeFileSync as p,renameSync as d,rmSync as g}from"node:fs";import{join as m}from"node:path";import{runCodegen as f,CodegenDiagnosticError as j,refreshCodegenProject as u,createCodegenProject as y,findTsconfig as S,tsconfigFingerprint as C,projectConfigCandidatePaths as h}from"@lunora/codegen";import{wranglerCodegenInputs as l}from"./wranglerCodegenInputs-7WopgQo4.mjs";import{isCodegenDisabled as w,CODEGEN_ENV as n}from"./BUILD_ROOT_ENV-Dg4MV3wY.mjs";import{recordStudioWrite as P,STUDIO_WRITE_TEMP_SUFFIX as $}from"./STUDIO_WRITE_TEMP_SUFFIX-BTTELz3K.mjs";const F=o=>({apiSpec:o.apiSpec,lazyFunctions:o.lazyFunctions,lunoraDirectory:o.schemaDirectory??"lunora",projectRoot:o.projectRoot,...l(o.projectRoot)});let r;const c=o=>{const t=a(o);return`${o}:${String(t.mtimeMs)}:${String(t.size)}`},E=o=>{const t=S(o);return[t===void 0?"":`${c(t)}
2
2
  ${C(t)}`,...h(o).filter(e=>s(e)).map(e=>c(e))].join(`
3
3
  `)},R=o=>{const t=E(o);return r?.lunoraDirectory===o&&r.key===t?(u(r.project,o),r.project):(r={key:t,lunoraDirectory:o,project:y(o)},r.project)},x=(o,t)=>{if(w(process.env[n]))return[`codegen is off (${n}=0 / \`lunora dev --no-codegen\`) — the source was written but \`_generated/\` was NOT regenerated`];try{const e=m(o.projectRoot,o.schemaDirectory??"lunora");f({...F(o),project:R(e)})}catch(e){if(r=void 0,e instanceof j)return[e.message];throw e}return P(t.path,t.text),[]},z=(o,t)=>{const e=`${o}${$}`;try{p(e,t,"utf8"),d(e,o)}catch(i){throw g(e,{force:!0}),i}};export{x as r,z as w};
@@ -1 +1 @@
1
- import{devVariablesStamp as t,parseDevVariable as r,resolveAdminToken as a}from"../packem_shared/devVariablesStamp-Cetr3qFz.mjs";import{applyStudioAssetCache as d,sendStudioDocument as n}from"../packem_shared/applyStudioAssetCache-DHQEJuuv.mjs";import{assetContentType as i,isStandaloneModulePath as l,loadStudioAssets as m,readStandaloneAsset as p,resolveStandaloneDirectory as u,studioAssetsStamp as T}from"../packem_shared/assetContentType-CUb5bpbI.mjs";import{default as D}from"../packem_shared/createStudioDocumentCache-B3Sf1bIl.mjs";import{STUDIO_PATH as c,STUDIO_SCRIPT_PATH as A,STUDIO_STYLE_PATH as E,createStudioMiddleware as P,isNonLoopbackHost as x,requestPathname as I,studioMountPath as O}from"../packem_shared/STUDIO_PATH-rjtY7n7Q.mjs";import{POLICY_SCAFFOLD_ENDPOINT as R,handlePolicyScaffoldRequest as N}from"../packem_shared/POLICY_SCAFFOLD_ENDPOINT-BISd53nh.mjs";import{default as H}from"../packem_shared/renderStudioHtml-ByowDtMl.mjs";import{SCHEMA_EDIT_ENDPOINT as v,handleSchemaEditRequest as F}from"../packem_shared/SCHEMA_EDIT_ENDPOINT-B-Xii8Ke.mjs";import{SEED_ENDPOINT as U,handleSeedRequest as b}from"../packem_shared/SEED_ENDPOINT-2B56PN_H.mjs";import{serveJsonHandler as y}from"../packem_shared/serveJsonHandler-Dv0EdCb9.mjs";import{STUDIO_WRITE_TEMP_SUFFIX as W,consumeStudioWrite as k}from"../packem_shared/STUDIO_WRITE_TEMP_SUFFIX-BTTELz3K.mjs";import{ALLOW_FORWARDED_ENV as j,headerValue as w,isLoopbackAddress as J,transportRejectionReason as X}from"../packem_shared/ALLOW_FORWARDED_ENV-BUndghJx.mjs";export{j as ALLOW_FORWARDED_ENV,R as POLICY_SCAFFOLD_ENDPOINT,v as SCHEMA_EDIT_ENDPOINT,U as SEED_ENDPOINT,c as STUDIO_PATH,A as STUDIO_SCRIPT_PATH,E as STUDIO_STYLE_PATH,W as STUDIO_WRITE_TEMP_SUFFIX,d as applyStudioAssetCache,i as assetContentType,k as consumeStudioWrite,D as createStudioDocumentCache,P as createStudioMiddleware,t as devVariablesStamp,N as handlePolicyScaffoldRequest,F as handleSchemaEditRequest,b as handleSeedRequest,w as headerValue,J as isLoopbackAddress,x as isNonLoopbackHost,l as isStandaloneModulePath,m as loadStudioAssets,r as parseDevVariable,p as readStandaloneAsset,H as renderStudioHtml,I as requestPathname,a as resolveAdminToken,u as resolveStandaloneDirectory,n as sendStudioDocument,y as serveJsonHandler,T as studioAssetsStamp,O as studioMountPath,X as transportRejectionReason};
1
+ import{devVariablesStamp as t,parseDevVariable as r,resolveAdminToken as a}from"../packem_shared/devVariablesStamp-Cetr3qFz.mjs";import{applyStudioAssetCache as d,sendStudioDocument as n}from"../packem_shared/applyStudioAssetCache-DHQEJuuv.mjs";import{assetContentType as i,isStandaloneModulePath as l,loadStudioAssets as m,readStandaloneAsset as p,resolveStandaloneDirectory as u,studioAssetsStamp as T}from"../packem_shared/assetContentType-CUb5bpbI.mjs";import{default as D}from"../packem_shared/createStudioDocumentCache-B3Sf1bIl.mjs";import{STUDIO_PATH as c,STUDIO_SCRIPT_PATH as A,STUDIO_STYLE_PATH as E,createStudioMiddleware as P,isNonLoopbackHost as x,requestPathname as I,studioMountPath as O}from"../packem_shared/STUDIO_PATH-CttpqT9E.mjs";import{POLICY_SCAFFOLD_ENDPOINT as R,handlePolicyScaffoldRequest as N}from"../packem_shared/POLICY_SCAFFOLD_ENDPOINT-BLMGCD5t.mjs";import{default as H}from"../packem_shared/renderStudioHtml-ByowDtMl.mjs";import{SCHEMA_EDIT_ENDPOINT as v,handleSchemaEditRequest as F}from"../packem_shared/SCHEMA_EDIT_ENDPOINT-DrPTyuPd.mjs";import{SEED_ENDPOINT as U,handleSeedRequest as b}from"../packem_shared/SEED_ENDPOINT-2B56PN_H.mjs";import{serveJsonHandler as y}from"../packem_shared/serveJsonHandler-Dv0EdCb9.mjs";import{STUDIO_WRITE_TEMP_SUFFIX as W,consumeStudioWrite as k}from"../packem_shared/STUDIO_WRITE_TEMP_SUFFIX-BTTELz3K.mjs";import{ALLOW_FORWARDED_ENV as j,headerValue as w,isLoopbackAddress as J,transportRejectionReason as X}from"../packem_shared/ALLOW_FORWARDED_ENV-BUndghJx.mjs";export{j as ALLOW_FORWARDED_ENV,R as POLICY_SCAFFOLD_ENDPOINT,v as SCHEMA_EDIT_ENDPOINT,U as SEED_ENDPOINT,c as STUDIO_PATH,A as STUDIO_SCRIPT_PATH,E as STUDIO_STYLE_PATH,W as STUDIO_WRITE_TEMP_SUFFIX,d as applyStudioAssetCache,i as assetContentType,k as consumeStudioWrite,D as createStudioDocumentCache,P as createStudioMiddleware,t as devVariablesStamp,N as handlePolicyScaffoldRequest,F as handleSchemaEditRequest,b as handleSeedRequest,w as headerValue,J as isLoopbackAddress,x as isNonLoopbackHost,l as isStandaloneModulePath,m as loadStudioAssets,r as parseDevVariable,p as readStandaloneAsset,H as renderStudioHtml,I as requestPathname,a as resolveAdminToken,u as resolveStandaloneDirectory,n as sendStudioDocument,y as serveJsonHandler,T as studioAssetsStamp,O as studioMountPath,X as transportRejectionReason};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/config",
3
- "version": "1.0.0-alpha.405",
3
+ "version": "1.0.0-alpha.407",
4
4
  "description": "Internal shared CLI + Vite config layer for Lunora: wrangler.jsonc validation, binding inference, and .dev.vars scaffolding",
5
5
  "keywords": [
6
6
  "bindings",
@@ -58,10 +58,10 @@
58
58
  "access": "public"
59
59
  },
60
60
  "dependencies": {
61
- "@lunora/codegen": "1.0.0-alpha.351",
62
- "@lunora/container": "1.0.0-alpha.91",
61
+ "@lunora/codegen": "1.0.0-alpha.353",
62
+ "@lunora/container": "1.0.0-alpha.92",
63
63
  "@lunora/errors": ">=1.0.0-alpha.51 <2.0.0-0",
64
- "@lunora/seed": "1.0.0-alpha.253",
64
+ "@lunora/seed": "1.0.0-alpha.255",
65
65
  "@visulima/colorize": "2.1.1",
66
66
  "@visulima/find-ai-runner": "1.0.2",
67
67
  "@visulima/fs": "6.0.29",
@@ -1,2 +0,0 @@
1
- import{readFileSync as ee,writeFileSync as ne}from"node:fs";import{createRequire as se}from"node:module";import{join as V}from"node:path";import{containerBuildTag as te}from"@lunora/container";import{readJsonSync as ie}from"@visulima/fs";import{applyModify as w}from"./applyModify-DKP2l6S9.mjs";import{a as oe,r as Y}from"./lunora-manifest-DuH_Cmyu.mjs";import{parseTree as ae,findNodeAtLocation as re}from"jsonc-parser";import{r as de,a as ce,b as le,c as ue}from"./reconcile-services-DFqH4eMQ.mjs";import{DEV_VARS_FILE as ge,parseDevVariableEntries as me}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{secretSourcesFromBindings as pe}from"./inferLunoraBindings-DMvPygeU.mjs";import{requiredSecrets as fe}from"./buildPackageSecretsBlock-C5WZfMwe.mjs";import{w as be,m as he,s as U,o as P,n as T,p as ve}from"./validate-bindings-PVHSAU6M.mjs";import{s as we}from"./worker-entry-checks-AIASCYl7.mjs";import{DEFAULT_OBSERVABILITY as _e}from"./DEFAULT_OBSERVABILITY-bN6UkTMx.mjs";import{findWranglerFile as ye,readWranglerJsonc as Se}from"./WRANGLER_FILES-UNW-xY5u.mjs";const Ee=[["maxBatchSize","max_batch_size"],["maxBatchTimeout","max_batch_timeout"],["maxConcurrency","max_concurrency"],["maxRetries","max_retries"],["deadLetterQueue","dead_letter_queue"],["retryDelay","retry_delay"]],B=e=>Object.fromEntries(Ee.filter(([n])=>e.tuning[n]!==void 0).map(([n,s])=>[s,e.tuning[n]])),L="queueTuning",xe=/^[\t ]*(?:,[\t ]*)?(?:\/\/[^\n\r]*)?\r?\n/u,Ae=/^[\t ]*,/u,Oe=(e,n)=>{const s=ae(e),t=s===void 0?void 0:re(s,[...n])?.parent;if(t?.type==="property"){const o=t.offset+t.length,i=e.lastIndexOf(`
2
- `,t.offset-1)+1,a=xe.exec(e.slice(o));if(a!==null&&e.slice(i,t.offset).trim()===""){const m=t.parent?.children??[],u=m.indexOf(t),d=u===m.length-1&&u>0?m[u-1]:void 0,c=d===void 0?void 0:Ae.exec(e.slice(d.offset+d.length))??void 0;return(c===void 0||d===void 0?e.slice(0,i):e.slice(0,d.offset+d.length)+e.slice(d.offset+d.length+c[0].length,i))+e.slice(o+a[0].length)}}return w(e,n,void 0)},G=(e,n,s,t,o,i=new Set)=>{const a=s.join("."),m={},u=[],d=[];let c=e;return{entries:n.map((l,v)=>{const g=t(l);if(g===void 0||l.queue===void 0)return l;const b=Object.fromEntries(Object.entries(B(g)).filter(([f])=>!i.has(f))),h=Object.entries(o[l.queue]??{}).filter(([f])=>!Object.hasOwn(b,f)),_=Object.entries(b).filter(([f,y])=>l[f]!==y),E=h.filter(([f,y])=>l[f]===y).map(([f])=>f),O=Object.fromEntries(Object.entries({...l,...b}).filter(([f])=>!E.includes(f)));for(const[f,y]of _)c=w(c,[...s,v,f],y);for(const f of E)c=Oe(c,[...s,v,f]);for(const[f,y]of h){const A=l[f];A!==void 0&&A!==y&&d.push(`${a}/${l.queue}: ${f} is no longer declared by defineQueue, but it was changed by hand to ${JSON.stringify(A)} from the declared ${JSON.stringify(y)}, so it was kept. Delete it from wrangler.jsonc if it should go.`)}return(_.length>0||E.length>0)&&u.push(`${a}/${l.queue} (${[..._.map(([f])=>f),...E.map(f=>`removed ${f}`)].join(", ")})`),Object.keys(b).length>0&&(m[l.queue]=b),O}),owned:m,text:c,updated:u,warnings:d}},Ne=(e,n,s,t)=>{const o=n.queues??{},i=o.producers??[],a=o.consumers??[],m=new Set(i.map(g=>g?.binding)),u=new Set(a.map(g=>g.queue)),d=s.filter(g=>!m.has(g.bindingName)),c=s.filter(g=>!u.has(g.name)),p=G(e,a,["queues","consumers"],g=>s.find(b=>b.name===g.queue),t);let l=p.text;const v={...p.owned};if(d.length>0||c.length>0){const g=[...i,...d.map(h=>({binding:h.bindingName,queue:h.name}))],b=[...p.entries,...c.map(h=>({queue:h.name,...h.mode==="pull"?{type:"http_pull"}:{},...B(h)}))];for(const h of c){const _=B(h);Object.keys(_).length>0&&(v[h.name]=_)}l=w(l,["queues"],{consumers:b,producers:g})}return{added:[...d.map(g=>`queues.producers/${g.bindingName}`),...c.map(g=>`queues.consumers/${g.name}`)],owned:v,text:l,updated:p.updated,warnings:p.warnings}},ke=(e,n,s,t,o)=>{const i=n.env?.[t],a=i?.queues?.consumers??[],m=i?.queues?.producers??[],u=l=>{const v=m.find(g=>g?.queue===l.queue)?.binding;return v!==void 0?s.find(g=>g.bindingName===v):s.find(g=>g.name===l.queue&&!m.some(b=>b?.binding===g.bindingName))},d=G(e,a,["env",t,"queues","consumers"],u,o,new Set(["dead_letter_queue"])),c=a.filter(l=>l.queue!==void 0&&u(l)===void 0).map(l=>`env.${t}.queues.consumers/${String(l.queue)}: no defineQueue export matches it — this block declares no producer mapping one of their bindings to "${String(l.queue)}", and no export is named that — so it was not retuned. A consumer for a queue another worker produces is skipped the same way.`),p=a.flatMap(l=>{const v=u(l)?.tuning.deadLetterQueue;return v===void 0||l.dead_letter_queue!==void 0?[]:[`env.${t}.queues.consumers/${String(l.queue)}: defineQueue declares deadLetterQueue "${v}", but this consumer has no dead_letter_queue, so its exhausted messages are dropped. Queue names differ per environment, so reconcile does not write it here; add it by hand.`]});return{added:[],owned:d.owned,text:d.text,updated:d.updated,warnings:[...d.warnings,...p,...c]}},$e=(e,n)=>{if(e?.lunoraIsForeign===!0)return n.push(`${e.path}: \`lunora\` is not an object, so the queue tuning ownership record cannot be read or written — an option removed from defineQueue stays deployed.`),{};const s=e?.lunora?.[L],t=o=>typeof o=="object"&&o!==null&&!Array.isArray(o);return s===void 0?{}:!t(s)||!Object.values(s).every(o=>t(o)&&Object.values(o).every(i=>t(i)))?(n.push(`${e?.path??"package.json"}: \`lunora.${L}\` is not a map of scope → queue → fields, so it is ignored — an option removed from defineQueue stays deployed until the next pass records it again.`),{}):s},Ce=(e,n,s)=>{const t=Object.fromEntries(Object.entries({...n,...s}).filter(([,o])=>Object.keys(o).length>0));oe(e,L,Object.keys(t).length===0?void 0:t)},Ie="https://api.cloudflare.com/client/v4/accounts/<ACCOUNT_ID>/artifacts/namespaces",Te=e=>{const n='add an "artifacts" binding ({ binding: "ARTIFACTS", namespace }) — codegen reads env.ARTIFACTS unless `.artifacts()` on defineApp points ctx.artifacts at another binding';return e===void 0?`ctx.artifacts is used; ${n}. The namespace is created by the first repo create() if it does not exist yet.`:`ctx.artifacts is used and the schema pins data to "${e}"; create the namespace in that jurisdiction BEFORE the first repo, with POST ${Ie} and body { "namespace": "<name>", "jurisdiction": "${e}" }, then ${n}. A namespace's jurisdiction cannot be changed, and one created implicitly by the first repo create() is unrestricted. With CLOUDFLARE_API_TOKEN set, \`lunora deploy\` creates a missing namespace in that jurisdiction for a binding you have added.`},j="PIPELINES",R="ARTIFACTS",je=(e,n,s)=>{const t=n!==void 0&&(s===void 0||s==="cloudflare"),o=e.flagshipBinding!==void 0&&!(n?.flagship??[]).some(d=>d.binding===e.flagshipBinding),i=e.usesPipelines&&!(n?.pipelines??[]).some(d=>d.binding===j),a=e.usesArtifacts?n?.artifacts??[]:[],m=a.some(d=>d.binding===R)?[]:a.flatMap(d=>d.binding===void 0?[]:[d.binding]);return[[e.usesKv&&(n?.kv_namespaces?.length??0)===0&&(!t||e.jurisdiction!==void 0),e.jurisdiction===void 0?'ctx.kv is used but no kv_namespaces binding exists; add one ({ binding: "KV" }) — wrangler creates the namespace on the first deploy.':`ctx.kv is used and the schema pins data to "${e.jurisdiction}"; run \`wrangler kv namespace create <name> --jurisdiction ${e.jurisdiction}\` and add a kv_namespaces entry ({ binding: "KV", id }) — a namespace wrangler creates on deploy is unrestricted.`],[e.usesHyperdrive&&(n?.hyperdrive?.length??0)===0&&!t,'@lunora/hyperdrive is used but no hyperdrive binding exists; add one ({ binding: "HYPERDRIVE", id }) — on a Cloudflare target `lunora deploy` creates the Hyperdrive config from a connection string.'],[e.usesArtifacts&&a.length===0&&(!t||e.jurisdiction!==void 0),Te(e.jurisdiction)],[i,`ctx.pipelines is used but no "${j}" pipelines binding exists; run 'wrangler pipelines create <name>' and add a 'pipelines' binding ({ binding: "${j}", stream }) — codegen resolves this one name, and the pipeline resource can't be auto-provisioned.`],[m.length>0,`ctx.artifacts is used and ${m.map(d=>`"${d}"`).join(", ")} ${m.length===1?"is":"are"} bound, but none is named "${R}"; make sure \`.artifacts()\` on defineApp points ctx.artifacts at it — otherwise it reads env.${R} and throws.`],[o,`lunora/flags.ts uses Flagship in binding mode but no flagship binding "${e.flagshipBinding??""}" exists; add a flagship entry ({ binding: "${e.flagshipBinding??""}", app_id }) — the app_id can't be auto-provisioned.`]].filter(([d])=>d).map(([,d])=>d)},Re=e=>[[e.usesX402Charge,"@lunora/x402/charge is used; set the recipient wallet address as a [vars] entry (the var name is your choice) and pass it to the charge config — the x402 facilitator settles USDC to that address."],[e.usesX402,"@lunora/x402/pay is used (ActionCtx-only, spends real funds); add a secrets_store_secrets[] binding holding the agent wallet key (binding name == signer.secretName) and pair the pay rail with a spend policy — ctx.secrets reads a Secrets Store binding, not .dev.vars."]].filter(([s])=>s).map(([,s])=>s),q=(e,n,s)=>s.filter(t=>!t.exported).map(t=>`${e} "${t.exportName}" is declared but ${t.className} is not exported by the worker entry; add \`export * from "./lunora/_generated/${n}"\` so its binding can be provisioned.`),qe=(e,n)=>{const s=new Set([...e.workflows,...e.agents].map(i=>i.className));if(s.size===0)return[];const t=Object.entries(n.exports??{}).flatMap(([i,a])=>a?.type==="workflow"?[i]:[]),o=(n.workflows??[]).flatMap(i=>i.class_name===void 0||i.script_name!==void 0?[]:[i.class_name]);return[...new Set([...t,...o])].filter(i=>!s.has(i)).map(i=>`wrangler.jsonc declares workflow "${i}" but no defineWorkflow/defineAgent export generates that class — a leftover from a rename will fail the deploy (wrangler rejects a class the worker does not export). Remove it if it is not hand-wired.`)},De=(e,n)=>{if(e.queues.length===0)return[];const s=new Set(e.queues.map(o=>o.name)),t=new Set(e.queues.map(o=>o.bindingName));return[...(n.queues?.consumers??[]).flatMap(o=>{const{queue:i}=o;return i===void 0||s.has(i)?[]:[`wrangler.jsonc subscribes queues.consumers[] to "${i}" but no defineQueue export declares that queue — a leftover from a rename keeps delivering batches this worker has no handler for (they retry to exhaustion, then drop or dead-letter). Remove it if it is not hand-wired.`]}),...(n.queues?.producers??[]).flatMap(o=>{const i=o?.binding;return i===void 0||t.has(i)?[]:[`wrangler.jsonc declares queues.producers[] binding "${i}" but no defineQueue export declares it — a leftover from a rename. Remove it if it is not hand-wired.`]})]},Pe=(e,n)=>[...qe(e,n),...De(e,n)],J=[{keys:["STRIPE_SECRET_KEY","STRIPE_WEBHOOK_SECRET"],label:"Stripe"},{keys:["POLAR_ACCESS_TOKEN","POLAR_WEBHOOK_SECRET"],label:"Polar"},{keys:["CREEM_API_KEY","CREEM_WEBHOOK_SECRET"],label:"Creem"},{keys:["AUTUMN_SECRET_KEY","AUTUMN_WEBHOOK_SECRET"],label:"Autumn"},{keys:["DODO_PAYMENTS_API_KEY","DODO_PAYMENTS_WEBHOOK_KEY"],label:"Dodo Payments"}],Be=()=>J.map(({keys:e,label:n})=>`${e[0]} + ${e[1]} (${n})`).join(" or "),Le=e=>{let n;try{n=ee(V(e,ge),"utf8")}catch{return!1}const s=new Map(me(n).map(t=>[t.key,t.value]));return J.some(({keys:t})=>t.every(o=>(s.get(o)??"")!==""))},We=(e,n)=>{const s=n?.secrets?.required;if(!Array.isArray(s))return[];const t=new Set(s),o=fe(pe(e)).map(i=>i.key).filter(i=>!t.has(i));return o.length===0?[]:[`wrangler.jsonc declares secrets.required without ${o.join(", ")}, which this app needs — wrangler dev loads only the listed keys from .dev.vars, so add ${o.length===1?"it":"them"} to secrets.required.`]},D=(e,n,s,t)=>{const o=new Set(e.durableObjects.map(u=>u.className)),i=[],a=(s?.r2_buckets?.length??0)>0,m=(s?.d1_databases?.some(u=>u.binding==="DB")??!1)||e.needsD1;return e.usesStorage&&!a&&i.push("@lunora/storage is used but R2 bucket bindings have user-defined names; add an r2_buckets entry and pass env.<BINDING> to createStorage()."),e.usesAuth&&!o.has("SessionDO")&&!m&&i.push("@lunora/auth is used but the worker entry exports no SessionDO; sessions are D1-backed, or export SessionDO to enable DO-backed sessions."),e.usesScheduler&&!o.has("SchedulerDO")&&i.push("@lunora/scheduler is used but the worker entry exports no SchedulerDO; export it so the SCHEDULER binding can be provisioned."),i.push(...q("container","containers",e.containers),...q("workflow","workflows",e.workflows),...q("agent","agents",e.agents)),e.containers.length>0&&s?.observability?.enabled===!1&&i.push("containers are declared but observability is explicitly disabled in wrangler.jsonc — container logs will not be captured."),e.usesPayments&&!Le(n)&&i.push(`@lunora/payment is used; set one provider's secret pair in .dev.vars — ${Be()}.`),i.push(...Re(e),...je(e,s,t),...We(e,s)),s!==void 0&&i.push(...Pe(e,s)),i},X="<replace-with-d1-create-id>",Me="<replace-with-hyperdrive-create-id>",Ke=e=>[["container","containers",e.containers],["workflow","workflows",e.workflows],["agent","agents",e.agents]].flatMap(([s,t,o])=>o.filter(i=>!i.exported).map(({className:i,exportName:a})=>({className:i,exportName:a,kind:s,module:t}))),Fe=e=>{const n=new Set(P(e).map(t=>t.tag));let s=1;for(;n.has(`v${String(s)}`);)s+=1;return`v${String(s)}`},He=e=>{const n=new Set;for(const s of P(e)){for(const t of T(s.deleted_classes))n.delete(t);for(const{from:t,to:o}of P(s.renamed_classes))t!==void 0&&n.delete(t),o!==void 0&&n.add(o);for(const t of[...T(s.new_classes),...T(s.new_sqlite_classes)])n.add(t)}return n},Ye=(e,n,s)=>{const t=n.durable_objects?.bindings??[],o=new Set(t.map(c=>c.name)),i=s.filter(c=>!o.has(c.binding));let a=e;const m=[];if(i.length>0){const c=[...t,...i.map(p=>({class_name:p.className,name:p.binding}))];a=w(a,["durable_objects","bindings"],c),m.push(...i.map(p=>`${p.binding}/${p.className}`))}const u=n.migrations??[],d=s.map(c=>c.className).filter(c=>!He(u).has(c));if(d.length>0){const c=[...u,{new_sqlite_classes:d,tag:Fe(u)}];a=w(a,["migrations"],c)}return{added:m,text:a}},Qe=(e,n)=>{const s=n.d1_databases??[];if(s.some(i=>i.binding==="DB"))return{added:[],text:e};const t=typeof n.name=="string"&&n.name.length>0?n.name:"lunora",o=[...s,{binding:"DB",database_id:X,database_name:t}];return{added:["DB (D1)"],text:w(e,["d1_databases"],o)}},Ve={ai:{binding:"AI",label:"AI (Workers AI)"},analytics:{binding:"ANALYTICS_SQL",label:"ANALYTICS_SQL (Analytics SQL)"},browser:{binding:"BROWSER",label:"BROWSER (Browser Rendering)"},images:{binding:"IMAGES",label:"IMAGES (Cloudflare Images)"}},k=(e,n,s)=>{const{binding:t,label:o}=Ve[s],i=n[s]?.binding;return typeof i=="string"&&i.length>0?{added:[],text:e}:{added:[o],text:w(e,[s],{binding:t})}},Ue=(e,n)=>e.usesAnalyticsSql&&we(n,new Set(["analyticsSql"]))?.chained.has("analyticsSql")!==!0,Ge=new Set(["ratelimits","send_email"]),Je=["durable_objects","logfwdr","unsafe"],Xe=new Set(["data_blobs","text_blobs","vars","wasm_modules"]),M=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),W=(e,n,s)=>M(e)&&e[n]===s,ze=(e,n,s)=>{if(Xe.has(e))return M(n)&&Object.hasOwn(n,s);const t=Ge.has(e)?"name":"binding";return Array.isArray(n)?n.some(o=>W(o,t,s)):W(n,"binding",s)},$=(e,n)=>{const s=e,t=Object.entries(s).find(([i,a])=>i!=="env"&&ze(i,a,n));if(t!==void 0)return t[0];for(const i of Je){const a=s[i];if(M(a)&&Array.isArray(a.bindings)&&a.bindings.some(m=>W(m,"name",n)))return`${i}.bindings`}if(e.queues?.producers?.some(i=>i?.binding===n)===!0)return"queues.producers";const o=e.secrets?.required;if(Array.isArray(o)&&o.includes(n))return"secrets.required"},K=(e,n,s)=>`${e}: not adding "${n}" — the name is already bound by \`${s}\` in wrangler.jsonc. Add a ${e} entry under another binding name and point the matching \`defineApp()\` override at it.`,F=e=>e===void 0||e==="cloudflare",Ze=(e,n,s)=>{if(!F(s)||(n.hyperdrive?.length??0)>0)return{added:[],text:e};const t=$(n,"HYPERDRIVE");return t!==void 0?{added:[],text:e,warnings:[K("hyperdrive","HYPERDRIVE",t)]}:{added:["HYPERDRIVE (Hyperdrive, created on deploy)"],text:w(e,["hyperdrive"],[{binding:"HYPERDRIVE",id:Me}])}},en=(e,n,s,t)=>{if(!F(t)||s!==void 0||(n.kv_namespaces?.length??0)>0)return{added:[],text:e};const o=$(n,"KV");return o!==void 0?{added:[],text:e,warnings:[K("kv_namespaces","KV",o)]}:{added:["KV (Workers KV, created on deploy)"],text:w(e,["kv_namespaces"],[{binding:"KV"}])}},nn=(e,n,s,t)=>{if(!F(t)||s!==void 0||(n.artifacts?.length??0)>0)return{added:[],text:e};const o=$(n,"ARTIFACTS");if(o!==void 0)return{added:[],text:e,warnings:[K("artifacts","ARTIFACTS",o)]};const i=typeof n.name=="string"&&n.name.length>0?n.name:"lunora";return{added:["ARTIFACTS (Cloudflare Artifacts)"],text:w(e,["artifacts"],[{binding:"ARTIFACTS",namespace:i}])}},Q=(e,n,s,t,o)=>{if((n[s]?.length??0)>0)return{added:[],text:e};const i=$(n,t.binding);return i!==void 0?{added:[],text:e,warnings:[`${s}: not adding ${JSON.stringify(t)} — the name "${t.binding}" is already bound by \`${i}\` in wrangler.jsonc. Add a ${s} entry under another binding name and point the matching \`defineApp()\` override at it.`]}:{added:[o],text:w(e,[s],[t])}},sn=(e,n)=>{const s=n.worker_loaders??[];return s.some(t=>t.binding==="LOADER")?{added:[],text:e}:{added:["LOADER (Worker Loader)"],text:w(e,["worker_loaders"],[...s,{binding:"LOADER"}])}},tn=e=>{if(typeof e=="string")return e;const n={};return e.diskMb!==void 0&&(n.disk_mb=e.diskMb),e.memoryMib!==void 0&&(n.memory_mib=e.memoryMib),e.vcpu!==void 0&&(n.vcpu=e.vcpu),n},on=e=>{const{image:n}=e;return n.kind==="dockerfile"?n.dockerfilePath:n.kind==="registry"?n.reference:te(e.exportName)},z=e=>{const n={};for(const[s,t]of Object.entries(e.images??{}))n[s]=t.kind==="registry"?{image:t.reference}:{build_context:t.buildContext,dockerfile:t.dockerfilePath,...e.buildArgs===void 0?{}:{build_vars:e.buildArgs}};return{class_name:e.className,scheduling_policy:"durable_object",...Object.keys(n).length>0?{images:n}:{},...e.name===void 0?{}:{name:e.name}}},an=e=>{if(e.schedulingPolicy==="durable_object")return z(e);const{image:n}=e,s={class_name:e.className,image:on(e)};return n.kind==="dockerfile"&&(s.image_build_context=n.buildContext),e.buildArgs!==void 0&&n.kind!=="registry"&&(s.image_vars=e.buildArgs),e.instanceType!==void 0&&(s.instance_type=tn(e.instanceType)),e.maxInstances!==void 0&&(s.max_instances=e.maxInstances),e.name!==void 0&&(s.name=e.name),e.rollout?.stepPercentage!==void 0&&(s.rollout_step_percentage=e.rollout.stepPercentage),e.rollout?.gracePeriodSeconds!==void 0&&(s.rollout_active_grace_period=e.rollout.gracePeriodSeconds),s},rn=(e,n,s)=>{const t=n.containers??[],o=new Set(t.map(d=>d.class_name)),i=s.filter(d=>!o.has(d.className));let a=i.length===0?e:w(e,["containers"],[...t,...i.map(d=>an(d))]);const m=[],u=[];for(const[d,c]of t.entries()){const p=s.find(g=>g.className===c.class_name);if(p===void 0)continue;const l=p.schedulingPolicy??"default";if((c.scheduling_policy??"default")!==l){u.push(`containers/${p.className} has scheduling_policy "${c.scheduling_policy??"default"}" in wrangler.jsonc but defineContainer "${p.exportName}" declares "${l}" — the policy is immutable, so replace the entry (and its container application) by hand.`);continue}const v=p.schedulingPolicy==="durable_object"?z(p).images:void 0;v!==void 0&&JSON.stringify(c.images)!==JSON.stringify(v)&&(a=w(a,["containers",d,"images"],v),m.push(`containers/${p.className}.images`))}return{added:i.map(d=>`containers/${d.className}`),text:a,updated:m,warnings:u}},dn=(e,n)=>{if(n.observability!==void 0)return{added:[],text:e};const s=w(e,["observability"],{..._e});return{added:["observability"],text:s}},cn=(e,n)=>n.upload_source_maps!==void 0?{added:[],text:e}:{added:["upload_source_maps"],text:w(e,["upload_source_maps"],!0)},Z=[{minimum:[4,142],name:"wrangler"},{minimum:[1,61],name:"@cloudflare/vite-plugin"}],ln=Z.map(({minimum:e,name:n})=>`${n}@^${e.join(".")}.0`).join(" "),un=(e,n)=>{try{const s=se(V(e,"package.json")).resolve(`${n}/package.json`),[t=0,o=0]=String(ie(s).version).split(".").map(Number);return[t,o]}catch{return}},gn=e=>{const n=Z.flatMap(({minimum:s,name:t})=>{const o=un(e,t);return o!==void 0&&(o[0]<s[0]||o[0]===s[0]&&o[1]<s[1])?[`${t} ${o.join(".")} (needs >= ${s.join(".")})`]:[]});return n.length===0?void 0:`workflows are declared in wrangler \`exports\`, which ${n.join(" and ")} cannot run — reconcile left workflows[] untouched. Upgrade (\`pnpm add -D ${ln}\`) and re-run.`},mn=e=>Object.entries(e.env??{}).flatMap(([n,s])=>Array.isArray(s?.workflows)?[`env.${n}.workflows declares workflow bindings, but Lunora now declares workflows in \`exports\` and resolves them on ctx.exports — move them to that environment's own \`exports\` by hand.`]:[]),pn=(e,n,s)=>{let t=e;const o=[],i=[];for(const a of s){const m=n[a.className];if(m?.type==="workflow")for(const{of:u,path:d}of ve){const c=u(a),p=U(m,d),l=`exports/${a.className}.${d.join(".")}`;if(c===void 0){p!==void 0&&i.push(`${l} is set in wrangler.jsonc but defineWorkflow "${a.exportName}" does not declare it — reconcile leaves it in place. Remove it by hand if it was dropped from the definition.`);continue}JSON.stringify(p)!==JSON.stringify(c)&&(t=w(t,["exports",a.className,...d],c),o.push(l))}}return{text:t,updated:o,warnings:i}},fn=(e,n,s,t,o)=>{if(o!==void 0)return{added:[],text:e,warnings:[o]};const i=[...s.map(b=>({settings:be(b),workflow:b})),...t.map(b=>({settings:{},workflow:b}))],a=new Set(i.map(({workflow:b})=>b.className)),m=n.workflows??[],u=m.filter(b=>b.script_name===void 0&&b.class_name!==void 0&&a.has(b.class_name)),d=n.exports??{},c=[],p=[],l=[];let v=e;for(const{settings:b,workflow:h}of i){if(d[h.className]!==void 0&&d[h.className]!==null)continue;const _=u.find(f=>f.class_name===h.className),E=Object.fromEntries(he.flatMap(f=>{const y=U(_,[f]);return y===void 0?[]:[[f,y]]})),O=_?.name??h.name;_?.name!==void 0&&_.name!==h.name&&l.push(`workflows/${h.className} is deployed as "${_.name}" but declared as "${h.name}" — its export keeps "${_.name}" so running instances survive. Change the declaration to match, or rename deliberately (it starts a new, empty workflow).`),v=w(v,["exports",h.className],{type:"workflow",...E,...b,name:O}),(_===void 0?c:p).push(`exports/${h.className}`)}if(u.length>0){const b=m.filter(h=>!u.includes(h));v=w(v,["workflows"],b.length===0?void 0:b),p.push(...u.map(h=>`workflows/${String(h.class_name)} → exports`))}l.push(...mn(n));const g=pn(v,d,s);return{added:c,text:g.text,updated:[...p,...g.updated],warnings:[...l,...g.warnings]}},Tn=(e,n,{environment:s,target:t}={})=>{const o=ye(e),i=Ke(n);if(!o)return{added:[],changed:!1,exportGaps:i,reason:"wrangler.jsonc not found",updated:[],warnings:D(n,e)};const{parsed:a,text:m}=Se(o);if(a===void 0)return{added:[],changed:!1,exportGaps:i,reason:`failed to parse ${o} as JSONC`,updated:[],warnings:D(n,e),wranglerPath:o};const u=D(n,e,a,t);if(s!==void 0){const r=a.env?.[s]!==void 0;u.push(r?`auto-provisioned bindings are written to the top level of wrangler.jsonc only (queue consumers "env.${s}" already declares are retuned, nothing is added) — "env.${s}" has its own (non-inheritable) bindings and must be reconciled by hand; \`lunora deploy --env ${s}\` now validates them, so a gap here will be reported at deploy time.`:`--env "${s}" was requested but wrangler.jsonc declares no "env.${s}" block — auto-provisioned bindings are written to the top level only and will not apply to that environment.`)}const d=n.containers.filter(r=>r.exported),c=n.agents.filter(r=>r.exported&&r.voice===!0&&r.voiceBindingName!==void 0&&r.voiceClassName!==void 0),p=[...n.durableObjects,...d.map(r=>({binding:r.bindingName,className:r.className})),...c.map(r=>({binding:r.voiceBindingName,className:r.voiceClassName}))],l=n.workflows.filter(r=>r.exported),v=n.agents.filter(r=>r.exported),g=Y(e),b=$e(g,u),h={},_=de(g);let E;const O=[{enabled:!0,run:r=>Ye(r,a,p)},{enabled:n.needsD1,run:r=>Qe(r,a)},{enabled:n.usesKv,run:r=>en(r,a,n.jurisdiction,t)},{enabled:n.usesHyperdrive,run:r=>Ze(r,a,t)},{enabled:n.usesArtifacts,run:r=>nn(r,a,n.jurisdiction,t)},{enabled:n.usesAi,run:r=>k(r,a,"ai")},{enabled:n.usesAiSearch,run:r=>Q(r,a,"ai_search_namespaces",{binding:"AI_SEARCH",namespace:"default"},"AI_SEARCH (AI Search namespace)")},{enabled:Ue(n,e),run:r=>k(r,a,"analytics")},{enabled:n.usesBrowser,run:r=>k(r,a,"browser")},{enabled:n.usesImages,run:r=>k(r,a,"images")},{enabled:n.usesAnalytics,run:r=>Q(r,a,"analytics_engine_datasets",{binding:"ANALYTICS",dataset:"ANALYTICS"},"ANALYTICS (Analytics Engine)")},{enabled:n.usesWorkerLoader,run:r=>sn(r,a)},{enabled:!0,run:r=>dn(r,a)},{enabled:t===void 0||t==="cloudflare",run:r=>cn(r,a)},{enabled:d.length>0,run:r=>rn(r,a,d)},{enabled:l.length>0||v.length>0,run:r=>fn(r,a,l,v,gn(e))},{enabled:n.queues.length>0,run:r=>{const S=Ne(r,a,n.queues,b.queues??{});return h.queues=S.owned,S}},{enabled:n.services!==void 0&&(n.services.length>0||Object.keys(_).length>0),run:r=>{const S=ce(r,a,n.services??[],_);return E=S.owned,S}},...s===void 0||a.env?.[s]===void 0?[]:[{enabled:n.queues.length>0,run:r=>{const S=`env.${s}.queues`,N=ke(r,a,n.queues,s,b[S]??{});return h[S]=N.owned,N}}]];let f=m;const y=[],A=[];for(const r of O){if(!r.enabled)continue;const S=r.run(f);f=S.text,y.push(...S.added),A.push(...S.updated??[]),u.push(...S.warnings??[])}const H=r=>{if(g===void 0)return;const S=E,N=[...Object.keys(h).length>0?[{consequence:"an option removed from defineQueue stays deployed",key:"queueTuning",label:"queue tuning",write:x=>{Ce(x,b,h)}}]:[],...S===void 0?[]:[{consequence:"a service removed from lunora.config stays bound",key:"services",label:"service bindings",write:x=>{ue(x,S)}}]];for(const x of N)try{x.write(Y(e)??g)}catch(I){u.push(`${r?"wrangler.jsonc was updated, but ":""}recording the ${x.label} reconcile owns in ${g.path} (lunora.${x.key}) failed: ${I instanceof Error?I.message:String(I)}. Until it is recorded, ${x.consequence}.`)}};let C;if(n.services!==void 0){const r=le(e,n.services,_);u.push(...r.warnings),E={...E,...r.owned},C=r.added.length>0||r.updated.length>0?{added:r.added,path:r.path,updated:r.updated}:void 0}return y.includes("DB (D1)")&&u.push(`wrote a DB binding with a placeholder database_id ("${X}") — run \`wrangler d1 create <name>\` and replace it before deploying.`),f===m?(H(!1),{added:y,changed:!1,devConfig:C,exportGaps:i,reason:"bindings already in sync",updated:A,warnings:u,wranglerPath:o}):(ne(o,f,"utf8"),H(!0),{added:y,changed:!0,devConfig:C,exportGaps:i,updated:A,warnings:u,wranglerPath:o})};export{Me as HYPERDRIVE_PLACEHOLDER_ID,Ke as collectExportGaps,Tn as reconcileWranglerBindings};
@@ -1 +0,0 @@
1
- import{C as S,M as a,P as C,s as R}from"./package-secrets-registry-BEJELdls.mjs";export{S as CORE_SECRETS,a as MINTABLE_SECRET_KEYS,C as PACKAGE_SECRETS_REGISTRY,R as secretsForPackages};
@@ -1,19 +0,0 @@
1
- import{randomBytes as _}from"node:crypto";import{existsSync as m,readFileSync as y,writeFileSync as h,linkSync as M,rmSync as g,renameSync as A,statSync as T}from"node:fs";import{join as p}from"node:path";import{LunoraError as F}from"@lunora/errors";import{DEV_VARS_FILE as u,DEV_VARS_EXAMPLE_FILE as f,parseDevVariableLine as $,parseDevVariableEntries as E,DEV_VARS_NEWLINE as C}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{C as P,M as j,s as I}from"./package-secrets-registry-BEJELdls.mjs";const R=e=>[...P,...I(e)],S=32,N=["replace","openssl","changeme","change-me","change_me","change-this","change_this","your-","your_","example","placeholder","todo","fill-me","fill_me","fill-in","fill_in","xxx"],z=/[.*+?^${}()|[\]\\]/gu,B=/[a-z0-9]$/u,W=e=>{const t=e.trim().toLowerCase();return t===""||t.startsWith("<")&&t.endsWith(">")?!0:N.some(r=>{const s=r.replaceAll(z,String.raw`\$&`),o=B.test(r)?`(^|[^a-z0-9])${s}([^a-z0-9]|$)`:`(^|[^a-z0-9])${s}`;return new RegExp(o,"u").test(t)})},x=e=>_(e).toString("hex"),X=e=>j.has(e),D=(e,t,r)=>X(e)&&W(t)?r(S):void 0,ae=(e=x)=>e(S),H=(e,t,r)=>e.split(C).map(s=>{const n=$(s),o=n?D(n.key,n.value,t):void 0;return!n||o===void 0?s:(r.push(n.key),`${n.key}="${o}"`)}),G=e=>{if(e.devVarsExists)return{status:"exists"};if(e.exampleContent===void 0)return{status:"no-example"};const t=[];return{content:H(e.exampleContent,e.randomHex??x,t).join(`
2
- `),generatedKeys:t,status:"generate"}},O=e=>e.includes('"')||e.includes("\\")?"":e.replaceAll("\r",String.raw`\r`).replaceAll(`
3
- `,String.raw`\n`),w=e=>{const t=e.randomHex??x,r=new Set(E(e.existingContent).map(d=>d.key)),s=[],n=[],o=[];for(const d of e.exampleContent.split(C)){const i=$(d);if(!i||r.has(i.key))continue;const a=D(i.key,i.value,t);o.push(i.key),a===void 0?s.push(`${i.key}="${O(i.value)}"`):(n.push(i.key),s.push(`${i.key}="${a}"`))}return{additions:s,generatedKeys:n,missingKeys:o}},k=e=>e.length>0?` (generated ${e.join(", ")})`:"",b=e=>`${e}.tmp-${String(process.pid)}`,K=(e,t,r={})=>{const s=b(e);try{h(s,t,{encoding:"utf8",...r}),A(s,e)}catch(n){throw g(s,{force:!0}),n}},U=(e,t)=>{try{return h(e,t,{encoding:"utf8",flag:"wx",mode:384}),!0}catch(r){if(r.code==="EEXIST")return!1;throw r}},L=(e,t)=>{const r=b(e);try{h(r,t,{encoding:"utf8",flag:"wx",mode:384});try{return M(r,e),!0}catch(s){const{code:n}=s;if(n==="EEXIST")return!1;if(n==="EPERM"||n==="ENOTSUP")return U(e,t);throw s}}finally{g(r,{force:!0})}},ce=(e,t)=>{K(e,t,{mode:384})},v=5,V=e=>{try{const t=T(e);return{mtimeMs:t.mtimeMs,size:t.size}}catch{return}},Y=(e,t)=>e===void 0||t===void 0?!1:e.mtimeMs===t.mtimeMs&&e.size===t.size,q=(e,t)=>{for(let r=0;r<v;r+=1){const s=V(e),n=y(e,"utf8"),o=t(n);if(o.length===0)return[];const d=n.length>0&&!n.endsWith(`
4
- `)?`
5
- `:"",i=`${n}${d}${o.join(`
6
- `)}
7
- `,a=`${e}.tmp-${String(process.pid)}-${_(6).toString("hex")}`;try{h(a,i,{encoding:"utf8",mode:384});const c=V(e);if(!Y(s,c)){g(a,{force:!0});continue}return A(a,e),o}catch(c){throw g(a,{force:!0}),c}}throw new F("INTERNAL",`Failed to append to ${e} after ${String(v)} attempts — a concurrent writer kept winning the race.`)},de=async e=>{const t=p(e.cwd,u),r=p(e.cwd,f);if(!m(r))return{addedKeys:[],generatedKeys:[],status:"no-example"};const s=y(r,"utf8");if(!m(t)){const l=G({devVarsExists:!1,exampleContent:s,randomHex:e.randomHex});return l.status!=="generate"?{addedKeys:[],generatedKeys:[],status:"no-example"}:e.yes===!0||await e.confirm(`No ${u} found. Generate it from ${f} (secrets auto-filled)?`)?L(t,l.content)?(e.info(`Created ${u}${k(l.generatedKeys)}.`),{addedKeys:[],generatedKeys:l.generatedKeys,status:"generated"}):{addedKeys:[],generatedKeys:[],status:"skipped-exists"}:(e.info(`Skipped — copy ${f} to ${u} and fill it in when you're ready.`),{addedKeys:[],generatedKeys:[],status:"declined"})}const n=w({existingContent:y(t,"utf8"),exampleContent:s,randomHex:e.randomHex});if(n.missingKeys.length===0)return{addedKeys:[],generatedKeys:[],status:"exists"};const o=n.missingKeys.join(", ");if(!(e.yes===!0||await e.confirm(`${u} is missing ${String(n.missingKeys.length)} key(s) from ${f} (${o}). Add them?`)))return e.info(`Skipped — add ${o} to ${u} when you're ready.`),{addedKeys:[],generatedKeys:[],status:"declined"};const a=q(t,l=>w({existingContent:l,exampleContent:s,randomHex:e.randomHex}).additions).map(l=>$(l)?.key).filter(l=>l!==void 0);if(a.length===0)return{addedKeys:[],generatedKeys:[],status:"exists"};const c=n.generatedKeys.filter(l=>a.includes(l));return e.info(`Updated ${u} — added ${a.join(", ")}${k(c)}.`),{addedKeys:a,generatedKeys:c,status:"augmented"}},J=e=>[`# ${e.description}`,`# Docs: ${e.docsUrl}`,`${e.key}="${e.placeholderValue}"`].join(`
8
- `),Q=(e,t)=>{const r=R(e).filter(s=>!t.has(s.key));return r.length===0?"":r.map(s=>J(s)).join(`
9
-
10
- `)},le=(e,t)=>{const r=p(e,f),s=m(r)?y(r,"utf8"):"",n=new Set(E(s).map(i=>i.key)),o=Q(t,n);if(o==="")return[];const d=s.length>0&&!s.endsWith(`
11
- `)?`
12
- `:"";return K(r,`${s}${d}
13
- ${o}
14
- `),R(t).filter(i=>!n.has(i.key)).map(i=>i.key)},Z=e=>{const t=e.randomHex??x,r=[],s=H(e.existingContent,t,r),n=new Set(E(e.existingContent).map(c=>c.key)),o=[],d=[];for(const c of P)n.has(c.key)||(o.push(c.key),d.push(`# ${c.description}`,`${c.key}="${t(S)}"`));const i=s.join(`
15
- `);if(d.length===0)return{addedKeys:o,content:i,filledKeys:r};const a=i===""||i.endsWith(`
16
- `)?"":`
17
- `;return{addedKeys:o,content:`${i}${a}${d.join(`
18
- `)}
19
- `,filledKeys:r}},ue=e=>{const t=p(e.cwd,u),r=m(t),s=r?y(t,"utf8"):"",n=Z({existingContent:s,randomHex:e.randomHex});if(n.filledKeys.length===0&&n.addedKeys.length===0)return{addedKeys:[],filledKeys:[],status:"unchanged"};if(r)K(t,n.content,{mode:384});else if(!L(t,n.content))return{addedKeys:[],filledKeys:[],status:"unchanged"};const o=[...n.filledKeys,...n.addedKeys];return e.info?.(`Generated ${String(o.length)} dev secret(s) in ${u}: ${o.join(", ")}`),{addedKeys:n.addedKeys,filledKeys:n.filledKeys,status:r?"filled":"created"}};export{Q as buildPackageSecretsBlock,de as ensureDevVariables,le as ensureDevVarsExample,ue as fillDevSecrets,ae as generateSecretValue,X as isMintableSecretKey,W as isPlaceholderValue,Z as planDevSecretsFill,w as planDevVariablesAugment,G as planDevVariablesScaffold,R as requiredSecrets,ce as writeDevVariablesFileAtomically};
@@ -1,3 +0,0 @@
1
- import{writeFileSync as $,rmSync as V,existsSync as b,readFileSync as j}from"node:fs";import{dirname as E,resolve as h,join as y,sep as g,relative as v,isAbsolute as R}from"node:path";import{MissingBuildOutputError as W}from"./MissingBuildOutputError-BAyekzof.mjs";import{findWranglerFile as x,readWranglerJsonc as B}from"./WRANGLER_FILES-UNW-xY5u.mjs";import{DEV_VARS_FILE as F,parseDevVariableEntries as L}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";const Y=".celld.wrangler.json",J=y(".wrangler","deploy","config.json"),K=new Set(["$schema","assets","compatibility_date","compatibility_flags","containers","d1_databases","define","durable_objects","kv_namespaces","main","migrations","name","no_bundle","queues","r2_buckets","rules","services","triggers","vars","worker_loaders","workflows"]),q=new Set(["class_name","image","instance_type","max_instances","name","runtime"]),M=new Set(["CompiledWasm","Data","Text"]),G=/\r?\n/u,U=/[!*?[]/u,X=/[.[]/u,z=["deleted_classes","new_classes","renamed_classes","transferred_classes"],l=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),O=e=>Array.isArray(e)&&e.length===0||l(e)&&Object.values(e).every(t=>O(t)),H=e=>Array.isArray(e)?e.map(t=>{if(!l(t))return t;const s=z.find(r=>t[r]!==void 0);if(s!==void 0)throw new Error(`migration "${String(t.tag)}" uses \`${s}\`, which celld refuses — celld accepts only \`new_sqlite_classes\` migrations`);return{new_sqlite_classes:t.new_sqlite_classes,tag:t.tag}}):e,Q=(e,t)=>Array.isArray(e)?e.map((s,r)=>l(s)?Object.fromEntries(Object.entries(s).filter(([n])=>{const o=q.has(n);return o||t.push(`containers[${String(r)}].${n}`),o})):s):e,Z=(e,t)=>Array.isArray(e)?e.filter((s,r)=>{const n=l(s)&&typeof s.type=="string"&&M.has(s.type);return n||t.push(`rules[${String(r)}]`),n}):e,ee=e=>{const t=[],s={};for(const[r,n]of Object.entries(l(e)?e:{}))l(n)&&n.type==="workflow"?t.push({binding:r,class_name:r,name:n.name}):s[r]=n;return{bindings:t,rest:s}},k=e=>{const t=[],s={},r=ee(e.exports),n={...e,exports:r.rest};for(const[o,i]of Object.entries(n)){if(!K.has(o)){O(i)||t.push(o);continue}switch(o){case"containers":{s[o]=Q(i,t);break}case"migrations":{s[o]=H(i);break}case"rules":{s[o]=Z(i,t);break}default:s[o]=i}}if(r.bindings.length>0){const o=Array.isArray(s.workflows)?s.workflows:[];s.workflows=[...o,...r.bindings]}return{config:s,dropped:t}},se=e=>{const[t=[],...s]=e.map(n=>h(n).split(g));let r=0;for(;r<t.length&&s.every(n=>n[r]===t[r]);)r+=1;return t.slice(0,r).join(g)||g},C=(e,t,s)=>{const r=o=>v(s,h(t,o)).split(g).join("/"),n={...e};return typeof e.main=="string"&&(n.main=r(e.main)),l(e.assets)&&typeof e.assets.directory=="string"&&(n.assets={...e.assets,directory:r(e.assets.directory)}),n},re=e=>{const t=y(e,".assetsignore");if(!b(t))return;const s=j(t,"utf8").split(G).map(r=>r.trim()).filter(r=>r!==""&&!r.startsWith("#")).filter(r=>U.test(r)||b(y(e,r)));if(s.length>0)throw new Error(`${t} hides ${s.join(", ")} from the assets, and celld has no .assetsignore — remove those files from ${e} first`);return t},te=(e,t)=>{const s=y(e,J);if(!b(s))throw new W(`wrangler \`main\` is the Vite virtual module "${t}", so celld deploys the Vite build output — and there is none yet. Run the project's build (\`vite build\`) first`);const{configPath:r}=JSON.parse(j(s,"utf8"));if(typeof r!="string")throw new TypeError(`${s} names no configPath`);return h(E(s),r)},A=e=>{const{parsed:t}=B(e);if(t===void 0)throw new Error(`${e} is not valid JSONC`);return t},D=(e,t,s,r)=>{const{d1_databases:n}=e;if(!Array.isArray(n)||r===s)return e;const o=Array.isArray(t.d1_databases)?t.d1_databases.filter(i=>l(i)):[];return{...e,d1_databases:n.map(i=>{if(!l(i))return i;const a=o.find(w=>w.binding===i.binding),c=a?.migrations_dir,f=h(s,typeof c=="string"?c:"migrations"),d=b(f)?{...i,migrations_dir:v(r,f).split(g).join("/")}:i,u=a?.migrations_pattern;return typeof u=="string"?{...d,migrations_pattern:v(r,h(s,u)).split(g).join("/")}:d})}},ne=(e,t,s,r)=>{const{main:n}=s;if(typeof n!="string"||!n.startsWith("virtual:"))return{fromBuild:!1,source:s,sourcePath:t};if(r==="dev")throw new Error(`wrangler \`main\` is the Vite virtual module "${n}", which only a Vite build can resolve — \`celld dev\` rebuilds from a source file. Use \`vite dev\` for the dev loop and \`lunora deploy\` to ship the build to celld, or point \`main\` at a worker file`);const o=te(e,n);return{fromBuild:!0,source:A(o),sourcePath:o}},oe=(e,t,s,r,n)=>{const o=t.filter(c=>Object.hasOwn(s,c.split(X)[0]??c));let i=e;e.no_bundle!==void 0&&(i=Object.fromEntries(Object.entries(e).filter(([c])=>c!=="no_bundle")),o.push("no_bundle (celld re-bundles the build output)"));const a=r===void 0?void 0:re(r);return a!==void 0&&o.push(`${v(n,a)} (matched no files)`),{assetsIgnore:a,projected:i,reported:o}},I=e=>{const t=l(e.vars)?e.vars:{};return{...e,vars:{WORKER_ENV:"development",...t}}},fe=(e,t)=>{const s=x(e);if(s===void 0)throw new Error(`no wrangler.jsonc or wrangler.json in ${e} — celld deploys from the project's Wrangler config`);const r=A(s),{fromBuild:n,source:o,sourcePath:i}=ne(e,s,r,t),a=E(i),{config:c,dropped:f}=k(o),{assets:d}=o,u=l(d)&&typeof d.directory=="string"?h(a,d.directory):void 0,w=typeof o.main=="string"?E(h(a,o.main)):void 0,p=se([a,w,u].filter(T=>T!==void 0));if(!n&&p!==a)throw new Error(`wrangler \`main\` and \`assets.directory\` must sit inside ${a} — celld resolves everything against the config's directory`);const _=D(C(c,a,p),r,e,p),m=n?oe(_,f,r,u,p):{assetsIgnore:void 0,projected:_,reported:f},N=t==="dev"?I(m.projected):m.projected,S=y(p,Y),P=`${JSON.stringify(N,void 0,4)}
2
- `;return{configPath:S,dropped:m.reported,write:()=>{$(S,P),m.assetsIgnore!==void 0&&V(m.assetsIgnore)}}},ue=(e,t)=>{const s=A(t),r=E(t),{config:n,dropped:o}=k(s),i=typeof s.name=="string"?s.name:"service",a=v(e,r);if(a===".."||a.startsWith(`..${g}`)||R(a))throw new Error(`service ${i} (${r}) must sit inside ${e} — celld dev runs it from a config beside the app's`);const c=y(r,F),f=b(c)?Object.fromEntries(L(j(c,"utf8")).map(({key:_,value:m})=>[_,m])):{},d=D(C(n,r,e),s,r,e),u=l(d.vars)?d.vars:{},w=y(e,`.celld.service.${i.replaceAll(/[^\w.-]/gu,"-")}.wrangler.json`),p=`${JSON.stringify(I({...d,vars:{...u,...f}}),void 0,4)}
3
- `;return{configPath:w,dropped:o,write:()=>{$(w,p)}}};export{ue as a,fe as p};
@@ -1 +0,0 @@
1
- import{existsSync as P,statSync as j,readFileSync as F,readdirSync as k}from"node:fs";import{discoverFlags as L,FLAGS_FILENAME as B,discoverQueues as G,CAPABILITY_PROBES as T,readServiceBindings as W,discoverNotifyChannels as q,NOTIFY_FILENAME as Y,createTargetScope as K,mayReadCapabilityContext as U,sourceCapabilitySignals as M,foldCapabilitySignals as C,capabilitiesUsedBy as V}from"@lunora/codegen";import{init as H}from"es-module-lexer";import{Project as X}from"ts-morph";import{discoverAgentInfo as Q}from"./discoverAgentInfo-pqFMJBtJ.mjs";import{discoverContainerInfo as J}from"./discoverContainerInfo-DzXr7Vm3.mjs";import{escapeRegExp as z}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{d as I}from"./discover-info-DC2MrAIM.mjs";import{relative as Z,sep as ee,isAbsolute as se,join as y}from"node:path";import{P as te}from"./package-secrets-registry-BEJELdls.mjs";import{discoverSchemaInfo as re}from"./discoverSchemaInfo-BBRlXZop.mjs";import{resolveWorkerEntry as oe,composedEntryDurableObjects as ne,GENERATED_DIRECTORY as x,DURABLE_OBJECT_BINDINGS as ae,detectExportedDurableObjects as ie,detectClassExports as _,isMergedProject as ce}from"./COMPOSED_WORKER_ENTRY-Ciiba5g_.mjs";import{discoverWorkflowInfo as de}from"./discoverWorkflowInfo-zW7Tt0Tn.mjs";const ue=(e,s)=>{const{error:r,value:t}=I(e,s,B,L);return r===void 0?{flags:t}:{error:r}},le=(e,s)=>{const r=Z(s,e);return r!==""&&r!==".."&&!r.startsWith(`..${ee}`)&&!se(r)},me=(e,s)=>{const{error:r,value:t}=I(e,s,void 0,G);return r===void 0?{queues:t??[]}:{error:r,queues:[]}},pe=new Set([".cjs",".cts",".js",".jsx",".mjs",".mts",".ts",".tsx"]),he=new Set([".git",".lunora-cache",".wrangler","dist",x,"node_modules"]),fe=["lunora","src"],ge=/\benv\s*\.\s*DB\b/,be=/\benv\s*\.\s*AI\b/,$=["ai","aiSearch","analytics","analyticsSql","artifacts","browser","hyperdrive","images","kv","mail","notify","payments","pipelines","r2sql","scheduler","storage","x402"],w=e=>`uses${e.charAt(0).toUpperCase()}${e.slice(1)}`,D=[["usesAuth","@lunora/auth"],["usesCimdWorkers","@lunora/auth/cimd/workers"],["usesX402Charge","@lunora/x402/charge"],["usesPaymentAutumn","@lunora/payment/autumn"],["usesPaymentCreem","@lunora/payment/creem"],["usesPaymentDodopayments","@lunora/payment/dodopayments"],["usesPaymentPolar","@lunora/payment/polar"],["usesPaymentStripe","@lunora/payment/stripe"]],N=[...$.map(e=>[w(e),T[e].moduleSpecifier]),...D].toSorted(([e],[s])=>e.localeCompare(s)),ye=[["usesNotifyFcm","@lunora/notify:fcm"],["usesNotifyWebPush","@lunora/notify:webPush"],["usesRequestSecretTool","@lunora/agent:requestSecretTool"]],Se=["@lunora/agent","@lunora/agent/sandbox"],Ee=new RegExp(String.raw`["'\x60](?:${[...N.map(([,e])=>e),...Se].map(e=>z(e)).join("|")})["'\x60]`,"u"),o=e=>{const{contextProperty:s,moduleSpecifier:r}=T[e];return s===void 0?`${r} is imported`:`${r} is imported or ctx.${s} is read`},ve="STRIPE_SECRET_KEY + STRIPE_WEBHOOK_SECRET (Stripe) or POLAR_ACCESS_TOKEN + POLAR_WEBHOOK_SECRET (Polar)",Ae=/\bfrom\s+["']\.{1,2}\//u,O=(e,s)=>{let r;try{r=k(e,{withFileTypes:!0})}catch{return}for(const t of r){if(t.isDirectory()){he.has(t.name)||O(y(e,t.name),s);continue}const n=t.name.lastIndexOf(".");n!==-1&&pe.has(t.name.slice(n))&&s.push(y(e,t.name))}},Re=(e,s,r)=>{const{info:t}=re(e,s,r);return{jurisdiction:t?.jurisdiction,needsD1:t?.hasD1GlobalTable??!1}},_e=(e,s,r)=>{const t=y(e,r),n=new X({compilerOptions:{allowJs:!0},skipAddingFilesFromTsConfig:!0}),c=[],l=[],m=[],u=K();let S=!1,E=!1;for(const d of s){const a=y(e,d);if(!P(a)||!j(a).isDirectory())continue;const h=[];O(a,h);for(const b of h){const i=F(b,"utf8"),v=le(b,t);S||=be.test(i),E||=ge.test(i),(Ee.test(i)||v&&(U(i)||Ae.test(i)))&&(n.createSourceFile(b,i,{overwrite:!0}),c.push({file:b,inLunora:v}))}}for(const{file:d,inLunora:a}of c)(a?l:m).push(M(n.getSourceFileOrThrow(d),u));const p=C(l),A=C([p,...m]),f=new Set([...A.valueImports,...A.dynamicImports]),g=V({contextReads:p.contextReads,valueImports:f});return{...Object.fromEntries([...$.map(d=>[w(d),g.has(d)]),...D.map(([d,a])=>[d,f.has(a)])]),needsD1:E,usesRequestSecretTool:p.requestSecretTool,usesAi:g.has("ai")||S,usesBrowser:g.has("browser")||p.sandboxTools.usesSandboxBrowser,usesWorkerLoader:p.sandboxTools.usesSandboxLoader}},xe=(e,s,r)=>[...e.map(t=>t.exported?`${t.bindingName}/${t.className} (container "${t.exportName}" declared and exported)`:`hint: container "${t.exportName}" is declared but ${t.className} is not exported by the worker entry — add \`export * from "./lunora/_generated/containers"\``),...s.map(t=>t.exported?`exports.${t.className} (workflow "${t.exportName}" declared and exported)`:`hint: workflow "${t.exportName}" is declared but ${t.className} is not exported by the worker entry — add \`export * from "./lunora/_generated/workflows"\``),...r.map(t=>t.exported?`exports.${t.className} (agent "${t.exportName}" declared and exported)`:`hint: agent "${t.exportName}" is declared but ${t.className} is not exported by the worker entry — add \`export * from "./lunora/_generated/agents"\``)],Ie=(e,s,r)=>[[e.usesAi,`AI (${o("ai")}, or env.AI is used)`],[e.usesAuth&&!s.has("SessionDO"),"hint: @lunora/auth is imported; its tables are D1-backed by default. For DO-backed auth (what @better-auth/scim needs), pass `namespace` to .auth() and export the generated auth DO class"],[e.usesScheduler&&!s.has("SchedulerDO"),`hint: ${o("scheduler")}, but no SchedulerDO is exported by the worker entry`],[e.usesStorage,`hint: ${o("storage")}; add an r2_buckets binding (bucket binding names are user-defined)`],[e.usesMail,`hint: ${o("mail")}; set RESEND_API_KEY in .dev.vars (obtain at https://resend.com/api-keys)`],[e.usesPayments,`hint: ${o("payments")}; set the provider secrets in .dev.vars — ${ve}`],[e.usesBrowser,`browser (${o("browser")}, or a sandbox browserTool imported in lunora/) — self-describing { binding: BROWSER }`],[e.usesImages,`images (${o("images")}) — self-describing { binding: IMAGES }`],[e.usesAnalytics,`analytics_engine_datasets (${o("analytics")}) — self-describing { binding: ANALYTICS, dataset }`],[e.usesWorkerLoader,"worker_loaders (jsCodeTool imported in lunora/) — self-describing { binding: LOADER }"],[e.usesAiSearch,`ai_search_namespaces (${o("aiSearch")}) — self-describing { binding: AI_SEARCH, namespace: "default" }; remote-only, so \`lunora dev\` reaches the deployed AI Search service`],[e.usesAnalyticsSql,`analytics (${o("analyticsSql")}) — self-describing { binding: ANALYTICS_SQL }; needs wrangler >= 4.145.0, and is remote-only, so \`lunora dev\` queries the account's live analytics`],[e.usesKv,r.jurisdiction===void 0?`kv_namespaces (${o("kv")}) — { binding: KV } with no id; wrangler creates the namespace on the first deploy`:`hint: ${o("kv")} and the schema pins "${r.jurisdiction}"; create the namespace with --jurisdiction ${r.jurisdiction} and add a kv_namespaces binding ({ binding, id })`],[e.usesHyperdrive,`hyperdrive (${o("hyperdrive")}) — { binding: HYPERDRIVE } with a placeholder id; dev uses an embedded Postgres and \`lunora deploy\` creates the config`],[e.usesPipelines,`hint: ${o("pipelines")}; run 'wrangler pipelines create <name>' and add a 'pipelines' binding ({ binding, stream }) — the pipeline resource can't be auto-provisioned`],[e.usesArtifacts,r.jurisdiction===void 0?`artifacts (${o("artifacts")}) — { binding: ARTIFACTS, namespace }`:`hint: ${o("artifacts")}; the schema pins data to "${r.jurisdiction}", so create the namespace in that jurisdiction first and add { binding: ARTIFACTS, namespace } yourself — \`lunora deploy\` then checks it (a first create() in dev would make it unrestricted)`],[e.usesX402Charge,"hint: @lunora/x402/charge is imported; set the recipient wallet address as a [vars] entry (the var name is yours to choose) and pass it to the charge config — the x402 facilitator settles USDC to that address"],[e.usesX402,`hint: ${o("x402")} (ActionCtx-only, spends real funds); add a secrets_store_secrets[] binding for the agent wallet key (name it to match signer.secretName) and pair the pay rail with a spend policy — ctx.secrets reads a Secrets Store binding, not .dev.vars, so the key can't be auto-provisioned`]].filter(([n])=>n).map(([,n])=>n),Ce=(e,s,r,t=[],n=[],c=[])=>{const l=new Set(e.map(u=>u.className)),m=e.map(u=>`${u.binding}/${u.className} (exported by worker entry)`);return s.needsD1&&m.push("DB (.global() table declared)"),m.push(...xe(t,n,c),...Ie(r,l,s)),m},We=async e=>{await H;const s=e.schemaDir??"lunora",r=e.scanDirs??fe,t=()=>_e(e.projectRoot,r,s),n=e.cache===void 0?t():e.cache.memo(`capabilities:${e.projectRoot}:${s}:${r.join(",")}`,t),c=oe(e.projectRoot);let l;c.composed?l=ne(y(e.projectRoot,s,x)).map(v=>({binding:ae[v],className:v})):l=c.path===void 0?[]:ie(c.path);const m=Re(e.projectRoot,s,e.cache),u={...m,needsD1:n.needsD1||m.needsD1},S=_(c,J(e.projectRoot,s,e.cache).containers,"containers"),E=_(c,de(e.projectRoot,s).workflows,"workflows"),p=_(c,Q(e.projectRoot,s).agents,"agents"),A=[...me(e.projectRoot,s).queues],{flags:f}=ue(e.projectRoot,s),g=I(e.projectRoot,s,Y,q),R=g.error===void 0?g.value:{hasFcm:!0,hasWebPush:!0},d=f?.provider==="flagship"&&f.mode==="binding"?f.bindingName:void 0,a=Ce(l,u,n,S,E,p);!c.composed&&ce(y(e.projectRoot,s,x))&&!l.some(i=>i.className==="LunoraDO")&&a.push("hint: durableObjects.merge is set, but the worker entry exports no LunoraDO — export one built with mergeDurableObjects, or the classes stay separate"),d!==void 0&&a.push(`hint: lunora/flags.ts uses Flagship in binding mode; add a flagship binding ({ binding: "${d}", app_id }) — the app_id can't be auto-provisioned`);const h=W(e.projectRoot),b=h.error===void 0?h.services:void 0;return h.error!==void 0&&a.push(`hint: lunora.config \`services\` not reconciled — ${h.error}`),a.push(...h.services.map(i=>`${i.binding} → ${i.worker} (lunora.config services.${i.name})`)),{...n,agents:p,containers:S,durableObjects:l,flagshipBinding:d,...u.jurisdiction===void 0?{}:{jurisdiction:u.jurisdiction},needsD1:u.needsD1,queues:A,services:b,signals:a,usesFlags:f!==void 0,usesNotifyFcm:R?.hasFcm??!1,usesNotifyWebPush:R?.hasWebPush??!1,workflows:E}},qe=e=>[...N,...ye].filter(([s,r])=>e[s]&&te[r]!==void 0).map(([,s])=>s);export{We as inferLunoraBindings,qe as secretSourcesFromBindings};
@@ -1 +0,0 @@
1
- const a=e=>e.endsWith("S")?e.slice(0,-1):e,r=e=>e.replaceAll(/([a-z\d])([A-Z])/gu,"$1_$2").toUpperCase().split(/[_-]+/u).filter(s=>s.length>0),n=new Set(["CREDENTIAL","DSN","PASSPHRASE","PASSWD","PASSWORD","SECRET","TOKEN"]),c=["ACCESS_KEY","API_KEY","ENCRYPTION_KEY","PRIVATE_KEY","SIGNING_KEY"],p=new RegExp(`(?:${[...n,...c.map(e=>e.replaceAll("_",""))].join("|")})S?$`,"iu"),i=e=>r(e).some(s=>s==="PUBLIC"||s==="PUBLISHABLE"),d=e=>{if(i(e))return!1;const s=r(e);if(s.some(o=>n.has(a(o))))return!0;const t=a(s.join("_"));return c.some(o=>t===o||t.endsWith(`_${o}`))||p.test(e)},h=[{description:"Bearer token the local Lunora Studio uses to call the worker's admin endpoints (data browser, schema edits) in dev. Generate with: openssl rand -hex 32",docsUrl:"https://lunora.sh/docs/packages/studio",key:"LUNORA_ADMIN_TOKEN",placeholderValue:"replace-with-openssl-rand-hex-32"}],u=["BETTER_AUTH_SECRET","STORAGE_SIGNING_SECRET"],l={"@lunora/auth":[{description:"32-byte random secret used to sign sessions and tokens. Generate with: openssl rand -hex 32",docsUrl:"https://lunora.sh/docs/packages/auth#secrets",key:"AUTH_SECRET",placeholderValue:"replace-with-openssl-rand-hex-32"},{description:"Public base URL of your worker (used by better-auth for redirects and cookie domain). For local dev this is typically http://localhost:8787",docsUrl:"https://lunora.sh/docs/packages/auth#secrets",key:"AUTH_URL",placeholderValue:"http://localhost:8787"}],"@lunora/agent:requestSecretTool":[{description:"AES-256 key that seals secret values held for one agent step, base64 of 32 bytes. Generate with: openssl rand -base64 32. Rotate by moving the old value to LUNORA_SECRET_VALUE_KEY_PREVIOUS first.",docsUrl:"https://lunora.sh/docs/packages/agent#secret-values",key:"LUNORA_SECRET_VALUE_KEY",placeholderValue:"<your-base64-32-byte-key>"}],"@lunora/bindings/r2sql":[{description:"Cloudflare API token with R2 SQL read access, for `ctx.r2sql`. Create at https://dash.cloudflare.com/profile/api-tokens with the R2 SQL permission.",docsUrl:"https://lunora.sh/docs/packages/bindings#r2-sql",key:"R2_SQL_TOKEN",placeholderValue:"<your-r2-sql-api-token>"},{description:"Cloudflare account id the R2 SQL queries run against. Falls back to CLOUDFLARE_ACCOUNT_ID when unset.",docsUrl:"https://lunora.sh/docs/packages/bindings#r2-sql",key:"R2_SQL_ACCOUNT_ID",placeholderValue:"<your-cloudflare-account-id>"},{description:"Name of the R2 bucket holding the Iceberg tables `ctx.r2sql` queries.",docsUrl:"https://lunora.sh/docs/packages/bindings#r2-sql",key:"R2_SQL_BUCKET",placeholderValue:"<your-r2-sql-bucket>"}],"@lunora/mail":[{description:"Resend API key for sending transactional email via @lunora/mail. Obtain at https://resend.com/api-keys",docsUrl:"https://lunora.sh/docs/packages/mail#secrets",key:"RESEND_API_KEY",placeholderValue:"<your-resend-api-key>"}],"@lunora/notify:fcm":[{description:"Firebase project id for FCM (HTTP v1) push. Found in the Firebase console project settings.",docsUrl:"https://lunora.sh/docs/packages/notify#fcm",key:"FCM_PROJECT_ID",placeholderValue:"<your-firebase-project-id>"},{description:"OAuth2 access token for FCM (HTTP v1). Convenient for dev but expires — in production supply a getAccessToken() in defineNotify instead. Obtain via the Google Cloud SDK / a service account.",docsUrl:"https://lunora.sh/docs/packages/notify#fcm",key:"FCM_ACCESS_TOKEN",placeholderValue:"<your-fcm-access-token>"}],"@lunora/notify:webPush":[{description:"Public VAPID key (base64url) for Web Push. Generate a keypair once with: npx web-push generate-vapid-keys — the public key is also shipped to the browser to subscribe.",docsUrl:"https://lunora.sh/docs/packages/notify#web-push",key:"VAPID_PUBLIC_KEY",placeholderValue:"<your-vapid-public-key>"},{description:"Private VAPID key (base64url) for Web Push — the application-server signing key. Generate with: npx web-push generate-vapid-keys",docsUrl:"https://lunora.sh/docs/packages/notify#web-push",key:"VAPID_PRIVATE_KEY",placeholderValue:"<your-vapid-private-key>"},{description:"VAPID `sub` contact — a mailto: or https: URL identifying the application server (e.g. mailto:you@example.com).",docsUrl:"https://lunora.sh/docs/packages/notify#web-push",key:"VAPID_SUBJECT",placeholderValue:"mailto:you@example.com"}],"@lunora/payment/autumn":[{description:"Autumn secret key (am_sk_…) for the Autumn payment adapter. Obtain at https://app.useautumn.com/dev",docsUrl:"https://lunora.sh/docs/packages/payment#autumn",key:"AUTUMN_SECRET_KEY",placeholderValue:"<your-autumn-secret-key>"},{description:"Autumn webhook signing secret for verifying Standard Webhooks event payloads. Obtain from your Autumn dashboard webhook settings.",docsUrl:"https://lunora.sh/docs/packages/payment#autumn",key:"AUTUMN_WEBHOOK_SECRET",placeholderValue:"<your-autumn-webhook-secret>"}],"@lunora/payment/creem":[{description:"Creem API key for the Creem payment adapter. Obtain at https://www.creem.io/dashboard/developers",docsUrl:"https://lunora.sh/docs/packages/payment#creem",key:"CREEM_API_KEY",placeholderValue:"<your-creem-api-key>"},{description:"Creem webhook signing secret for verifying the creem-signature header. Obtain from your Creem dashboard webhook settings.",docsUrl:"https://lunora.sh/docs/packages/payment#creem",key:"CREEM_WEBHOOK_SECRET",placeholderValue:"<your-creem-webhook-secret>"}],"@lunora/payment/dodopayments":[{description:"Dodo Payments API key (bearer token) for the Dodo Payments adapter. Obtain at https://app.dodopayments.com/developer/api-keys",docsUrl:"https://lunora.sh/docs/packages/payment#dodo-payments",key:"DODO_PAYMENTS_API_KEY",placeholderValue:"<your-dodo-payments-api-key>"},{description:"Dodo Payments webhook signing secret (whsec_…) for verifying event payloads. Obtain at https://app.dodopayments.com/developer/webhooks",docsUrl:"https://lunora.sh/docs/packages/payment#dodo-payments",key:"DODO_PAYMENTS_WEBHOOK_KEY",placeholderValue:"<your-dodo-payments-webhook-secret>"}],"@lunora/payment/polar":[{description:"Polar access token for the Polar payment adapter. Obtain at https://polar.sh/settings/tokens",docsUrl:"https://lunora.sh/docs/packages/payment#polar",key:"POLAR_ACCESS_TOKEN",placeholderValue:"<your-polar-access-token>"},{description:"Polar webhook secret for verifying event payloads from Polar. Obtain at https://polar.sh/settings/webhooks",docsUrl:"https://lunora.sh/docs/packages/payment#polar",key:"POLAR_WEBHOOK_SECRET",placeholderValue:"<your-polar-webhook-secret>"}],"@lunora/payment/stripe":[{description:"Stripe secret key (sk_test_…). Required when using the Stripe adapter. Obtain at https://dashboard.stripe.com/apikeys",docsUrl:"https://lunora.sh/docs/packages/payment#stripe",key:"STRIPE_SECRET_KEY",placeholderValue:"<your-stripe-secret-key>"},{description:"Stripe webhook signing secret (whsec_…) for verifying event payloads. Obtain at https://dashboard.stripe.com/webhooks",docsUrl:"https://lunora.sh/docs/packages/payment#stripe",key:"STRIPE_WEBHOOK_SECRET",placeholderValue:"<your-stripe-webhook-secret>"}]},y=new Set([...u,...[...h,...Object.values(l).flat()].filter(e=>d(e.key)&&!e.placeholderValue.startsWith("<")).map(e=>e.key)]),k=e=>{const s=[];for(const t of e){const o=l[t];o!==void 0&&s.push(...o)}return s};export{h as C,y as M,l as P,d as a,i,k as s};
@@ -1 +0,0 @@
1
- import{inferLunoraBindings as g}from"./inferLunoraBindings-DMvPygeU.mjs";import{LUNORA_TAG as r}from"./LUNORA_TAG-DQTGPqcJ.mjs";import{reconcileWranglerBindings as p}from"./HYPERDRIVE_PLACEHOLDER_ID-DPgHQEDf.mjs";import{reconcileWranglerCompatibilityDate as $}from"./reconcileWranglerCompatibilityDate-hocXEuRA.mjs";import{reconcileWranglerCrons as m,describePreservedCrons as w}from"./describePreservedCrons-C5KPuPy3.mjs";const j=async(i,t,a)=>{try{const n=await g({projectRoot:i.projectRoot,schemaDir:i.schemaDir}),e=p(i.projectRoot,n,{target:i.target}),o=e.wranglerPath??"wrangler.jsonc";if(e.added.length>0&&t.info?.(`${r} inferred bindings → ${e.added.join(", ")} (written to ${o})`),e.updated.length>0&&t.info?.(`${r} updated bindings → ${e.updated.join(", ")} (written to ${o})`),e.devConfig!==void 0){const{added:s,path:d,updated:f}=e.devConfig;t.info?.(`${r} dev sidecar bindings → ${[...s,...f].join(", ")} (written to ${d})`)}for(const s of e.warnings)t.warn(`${r} ${s}`);e.exportGaps.length>0&&a?.(e.exportGaps)}catch(n){const e=n instanceof Error?n.message:String(n);t.warn(`${r} binding inference skipped: ${e}`)}},c=new Map,u=(i,t,a)=>{try{const n=m(i,t);n.changed&&a.info?.(`${r} synced ${t.length.toFixed(0)} cron trigger(s) into ${n.wranglerPath??"wrangler.jsonc"}`);for(const s of n.warnings)a.warn(`${r} ${s}`);const e=n.preserved.join("\0"),o=w(n.preserved);o!==void 0&&(n.changed||c.get(i)!==e)&&a.info?.(`${r} ${o}`),c.set(i,e)}catch(n){const e=n instanceof Error?n.message:String(n);a.warn(`${r} cron trigger sync skipped: ${e}`)}try{const n=$(i);n.changed&&a.info?.(`${r} bumped compatibility_date to ${n.date??"unknown"} (Workers Cache enabled) → ${n.wranglerPath??"wrangler.jsonc"}`)}catch(n){const e=n instanceof Error?n.message:String(n);a.warn(`${r} compatibility date sync skipped: ${e}`)}};export{j as reconcileBindingsSafely,u as reconcileWranglerExtras};
@@ -1 +0,0 @@
1
- import{watch as A}from"node:fs";import{createServer as _}from"node:net";import{dirname as C}from"node:path";import{readServiceBindings as R}from"@lunora/codegen";import{acceptsConnection as b,startDevProcess as M}from"./acceptsConnection-DHhUYGjT.mjs";import{p as D,a as x}from"./celld-config-Iv0tK526.mjs";const N=6e4,O=200,j=new Set([".celld",".wrangler","node_modules"]),I=/[/\\]/u,B=async()=>new Promise((r,a)=>{const s=_();s.once("error",a),s.listen(0,"127.0.0.1",()=>{const o=s.address();s.close(()=>{r(typeof o=="object"&&o!==null?o.port:0)})})}),F=r=>r?.split(I).some(a=>j.has(a))===!0,G=(r,a,s)=>{let o;const c=A(r,{recursive:!0},(l,w)=>{F(w)||(clearTimeout(o),o=setTimeout(a,O))}),i=()=>{clearTimeout(o),c.close()};return c.once("error",l=>{i(),s(l)}),{close:i}},H=r=>r instanceof Error?r.message:String(r),J=async r=>{const{log:a,port:s,projectRoot:o}=r,c=(t,e="stdout")=>{a(t,{stream:e,tag:"celld"})};if(await b(s))throw new Error(`port ${String(s)} is already in use — stop whatever is serving there (another dev server?), or pick another worker port`);const i=R(o);if(i.error!==void 0)throw new Error(`could not read the lunora.config services: ${i.error}`);const l=D(o,"dev");l.write();const w=C(l.configPath),m=[...new Map(i.services.map(t=>[t.wranglerPath,t])).values()],p=new AbortController,h=()=>p.signal.aborted,v=async(t,e,n)=>M({args:["dev",t,"--port",String(n)],command:"celld",cwd:o,label:"celld dev",notFound:"`celld` was not found on PATH — install it (https://celld.dev) to run the celld target",onLine:T=>{T.trim()!==""&&a(T,{stream:"stdout",tag:e})},port:n,readyTimeoutMs:N,signal:p.signal,spawn:r.spawn}),S=async t=>{const e=x(w,t.wranglerPath);e.write(),c(`registering service ${t.worker} in the local dev state`),await(await v(e.configPath,`celld:${t.worker}`,await B())).stop()};for(const t of m)await S(t);let g=()=>{};const E=new Promise(t=>{g=t}),y=async()=>{const t=await v(l.configPath,"celld",s);return t.crashed.then(g).catch(()=>{}),t};let d=await y();const $=async t=>{await d.stop();let e;try{await S(t)}catch(n){e=n instanceof Error?n:new Error(String(n))}if(!h()){try{d=await y()}catch(n){throw h()||g(1),n}if(e!==void 0)throw e}};let f=Promise.resolve();const k=t=>{c(`service ${t.worker} changed — restarting`),f=f.then(async()=>$(t)).catch(e=>{h()||c(`service ${t.worker} failed to restart: ${H(e)}`,"stderr")})},P=[],u=()=>{for(const t of P)t.close()};try{for(const t of m)P.push(G(C(t.wranglerPath),()=>{k(t)},e=>{c(`stopped watching service ${t.worker}: ${e.message} — restart the dev server to pick up its edits`,"stderr")}))}catch(t){throw u(),await d.stop(),t}return E.then(u).catch(()=>{}),{exited:E,stop:async()=>{p.abort(),u(),await f,await d.stop()}}};export{J as startCelldDevSession};