@lunora/config 1.0.0-alpha.190 → 1.0.0-alpha.192

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.
@@ -1,4 +1,4 @@
1
- import { D as DeployDriver, I as InferredBindings, S as SchemaInfo } from "../packem_shared/schema-info.d-DS0bUsWE.mjs";
1
+ import { D as DeployDriver, I as InferredBindings, S as SchemaInfo } from "../packem_shared/schema-info.d-BRnrGpR1.mjs";
2
2
  import { WranglerVariableIR } from '@lunora/codegen';
3
3
  /**
4
4
  * Translate a `wrangler.jsonc` into an [Alchemy](https://alchemy.run) program.
@@ -707,7 +707,10 @@ interface WranglerConfig {
707
707
  stream?: string;
708
708
  } | null | undefined>;
709
709
  placement?: {
710
+ host?: string;
711
+ hostname?: string;
710
712
  mode?: string;
713
+ region?: string;
711
714
  };
712
715
  queues?: {
713
716
  consumers?: ReadonlyArray<WranglerQueueConsumer | null | undefined>;
@@ -746,6 +749,31 @@ interface WranglerValidationReport {
746
749
  valid: boolean;
747
750
  warnings: string[];
748
751
  }
752
+ interface WranglerEnvironmentMerge {
753
+ /** Set when `environment` names no `env.<name>` block declared in the config — the caller should treat this as a hard validation failure. */
754
+ error?: string;
755
+ /** The env-scoped view: `wrangler` unchanged when `environment` is `undefined`, otherwise merged per {@link NON_INHERITABLE_KEYS} / {@link INHERITABLE_KEYS}. */
756
+ merged: WranglerConfig;
757
+ /**
758
+ * Keys the env block overrides whose inheritance status this validator
759
+ * cannot verify (not in either table above) — validated against the
760
+ * TOP-LEVEL value only, per the "do not guess" rule; the override is
761
+ * silently ignored for validation purposes. The caller logs this ONCE
762
+ * (not per key) so an unusual `env.<name>` block doesn't spam warnings.
763
+ */
764
+ unverifiedKeys: string[];
765
+ }
766
+ /**
767
+ * Resolve the config view `wrangler deploy --env <environment>` will actually
768
+ * use. Undefined `environment` returns `wrangler` unchanged — the top-level
769
+ * config is what a plain `wrangler deploy` reads, same as today.
770
+ *
771
+ * Deliberately independent of any other merge in this module: called fresh
772
+ * from the ORIGINAL `wrangler` each time (see both call sites), so there is
773
+ * no risk of merging an already-merged config and silently losing the
774
+ * top-level fallback a second merge pass would no longer have access to.
775
+ */
776
+ declare const mergeWranglerEnvironment: (wrangler: WranglerConfig, environment: string | undefined) => WranglerEnvironmentMerge;
749
777
  /**
750
778
  * Return a new `WranglerConfig` with `consumer` present in `tail_consumers`,
751
779
  * wiring this Worker to forward its tail events (logs/exceptions) to another
@@ -843,4 +871,4 @@ type BindingRequirement, CLOUDFLARE_DRIVER, type ExportGap,
843
871
  * Plan 114 §5.3 (D6): a package carrying real provider code isolates it behind a
844
872
  * subpath rather than relocating wholesale.
845
873
  */
846
- 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 RemoteBindingPlan, type RemoteEnableInputs, type RemoteWranglerShape, type TailConsumer, WORKERS_CACHE_MIN_DATE, WRANGLER_FILES, type WranglerCacheShape, type WranglerConfig, type WranglerConfigShape, type WranglerContainerEntry, type WranglerProjectValidationOptions, type WranglerProjectValidationResult, type WranglerValidationReport, type WranglerWorkflowEntry, buildBindingManifest, collectExportGaps, collectWranglerSecretVariables, findWranglerFile, injectRemoteFlags, isCacheEnabled, isRemoteEnvEnabled, materializeRemoteWranglerConfig, planRemoteBindings, readWranglerJsonc, reconcileWranglerBindings, reconcileWranglerCompatibilityDate, reconcileWranglerCrons, resolveRemoteEnabled, scanWranglerVariablesForSecrets, validateWrangler, validateWranglerConfig, validateWranglerProject, withTailConsumer, wranglerToAlchemy };
874
+ 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 RemoteBindingPlan, type RemoteEnableInputs, type RemoteWranglerShape, type TailConsumer, WORKERS_CACHE_MIN_DATE, WRANGLER_FILES, type WranglerCacheShape, type WranglerConfig, type WranglerConfigShape, type WranglerContainerEntry, type WranglerEnvironmentMerge, type WranglerProjectValidationOptions, type WranglerProjectValidationResult, type WranglerValidationReport, type WranglerWorkflowEntry, buildBindingManifest, collectExportGaps, collectWranglerSecretVariables, findWranglerFile, injectRemoteFlags, isCacheEnabled, isRemoteEnvEnabled, materializeRemoteWranglerConfig, mergeWranglerEnvironment, planRemoteBindings, readWranglerJsonc, reconcileWranglerBindings, reconcileWranglerCompatibilityDate, reconcileWranglerCrons, resolveRemoteEnabled, scanWranglerVariablesForSecrets, validateWrangler, validateWranglerConfig, validateWranglerProject, withTailConsumer, wranglerToAlchemy };
@@ -1,4 +1,4 @@
1
- import { D as DeployDriver, I as InferredBindings, S as SchemaInfo } from "../packem_shared/schema-info.d-DS0bUsWE.js";
1
+ import { D as DeployDriver, I as InferredBindings, S as SchemaInfo } from "../packem_shared/schema-info.d-BRnrGpR1.js";
2
2
  import { WranglerVariableIR } from '@lunora/codegen';
3
3
  /**
4
4
  * Translate a `wrangler.jsonc` into an [Alchemy](https://alchemy.run) program.
@@ -707,7 +707,10 @@ interface WranglerConfig {
707
707
  stream?: string;
708
708
  } | null | undefined>;
709
709
  placement?: {
710
+ host?: string;
711
+ hostname?: string;
710
712
  mode?: string;
713
+ region?: string;
711
714
  };
712
715
  queues?: {
713
716
  consumers?: ReadonlyArray<WranglerQueueConsumer | null | undefined>;
@@ -746,6 +749,31 @@ interface WranglerValidationReport {
746
749
  valid: boolean;
747
750
  warnings: string[];
748
751
  }
752
+ interface WranglerEnvironmentMerge {
753
+ /** Set when `environment` names no `env.<name>` block declared in the config — the caller should treat this as a hard validation failure. */
754
+ error?: string;
755
+ /** The env-scoped view: `wrangler` unchanged when `environment` is `undefined`, otherwise merged per {@link NON_INHERITABLE_KEYS} / {@link INHERITABLE_KEYS}. */
756
+ merged: WranglerConfig;
757
+ /**
758
+ * Keys the env block overrides whose inheritance status this validator
759
+ * cannot verify (not in either table above) — validated against the
760
+ * TOP-LEVEL value only, per the "do not guess" rule; the override is
761
+ * silently ignored for validation purposes. The caller logs this ONCE
762
+ * (not per key) so an unusual `env.<name>` block doesn't spam warnings.
763
+ */
764
+ unverifiedKeys: string[];
765
+ }
766
+ /**
767
+ * Resolve the config view `wrangler deploy --env <environment>` will actually
768
+ * use. Undefined `environment` returns `wrangler` unchanged — the top-level
769
+ * config is what a plain `wrangler deploy` reads, same as today.
770
+ *
771
+ * Deliberately independent of any other merge in this module: called fresh
772
+ * from the ORIGINAL `wrangler` each time (see both call sites), so there is
773
+ * no risk of merging an already-merged config and silently losing the
774
+ * top-level fallback a second merge pass would no longer have access to.
775
+ */
776
+ declare const mergeWranglerEnvironment: (wrangler: WranglerConfig, environment: string | undefined) => WranglerEnvironmentMerge;
749
777
  /**
750
778
  * Return a new `WranglerConfig` with `consumer` present in `tail_consumers`,
751
779
  * wiring this Worker to forward its tail events (logs/exceptions) to another
@@ -843,4 +871,4 @@ type BindingRequirement, CLOUDFLARE_DRIVER, type ExportGap,
843
871
  * Plan 114 §5.3 (D6): a package carrying real provider code isolates it behind a
844
872
  * subpath rather than relocating wholesale.
845
873
  */
846
- 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 RemoteBindingPlan, type RemoteEnableInputs, type RemoteWranglerShape, type TailConsumer, WORKERS_CACHE_MIN_DATE, WRANGLER_FILES, type WranglerCacheShape, type WranglerConfig, type WranglerConfigShape, type WranglerContainerEntry, type WranglerProjectValidationOptions, type WranglerProjectValidationResult, type WranglerValidationReport, type WranglerWorkflowEntry, buildBindingManifest, collectExportGaps, collectWranglerSecretVariables, findWranglerFile, injectRemoteFlags, isCacheEnabled, isRemoteEnvEnabled, materializeRemoteWranglerConfig, planRemoteBindings, readWranglerJsonc, reconcileWranglerBindings, reconcileWranglerCompatibilityDate, reconcileWranglerCrons, resolveRemoteEnabled, scanWranglerVariablesForSecrets, validateWrangler, validateWranglerConfig, validateWranglerProject, withTailConsumer, wranglerToAlchemy };
874
+ 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 RemoteBindingPlan, type RemoteEnableInputs, type RemoteWranglerShape, type TailConsumer, WORKERS_CACHE_MIN_DATE, WRANGLER_FILES, type WranglerCacheShape, type WranglerConfig, type WranglerConfigShape, type WranglerContainerEntry, type WranglerEnvironmentMerge, type WranglerProjectValidationOptions, type WranglerProjectValidationResult, type WranglerValidationReport, type WranglerWorkflowEntry, buildBindingManifest, collectExportGaps, collectWranglerSecretVariables, findWranglerFile, injectRemoteFlags, isCacheEnabled, isRemoteEnvEnabled, materializeRemoteWranglerConfig, mergeWranglerEnvironment, planRemoteBindings, readWranglerJsonc, reconcileWranglerBindings, reconcileWranglerCompatibilityDate, reconcileWranglerCrons, resolveRemoteEnabled, scanWranglerVariablesForSecrets, validateWrangler, validateWranglerConfig, validateWranglerProject, withTailConsumer, wranglerToAlchemy };
@@ -1 +1 @@
1
- import{BINDING_MANIFEST_VERSION as o,buildBindingManifest as a}from"../packem_shared/BINDING_MANIFEST_VERSION-Cd00jVOf.mjs";import{C as n}from"../packem_shared/cloudflare-driver-BRcsrarS.mjs";import{collectExportGaps as i,reconcileWranglerBindings as E}from"../packem_shared/collectExportGaps-DHLZ7ulq.mjs";import{reconcileWranglerCompatibilityDate as c}from"../packem_shared/reconcileWranglerCompatibilityDate-7OO_xaKR.mjs";import{reconcileWranglerCrons as R}from"../packem_shared/reconcileWranglerCrons-COMb6ICf.mjs";import{REMOTE_ELIGIBLE_KEYS as f,injectRemoteFlags as p,isRemoteEnvEnabled as I,materializeRemoteWranglerConfig as W,planRemoteBindings as d,resolveRemoteEnabled as x}from"../packem_shared/REMOTE_ELIGIBLE_KEYS-D-edJjVY.mjs";import{WORKERS_CACHE_MIN_DATE as C,isCacheEnabled as A}from"../packem_shared/WORKERS_CACHE_MIN_DATE-0k9ABJtF.mjs";import{WRANGLER_FILES as L,findWranglerFile as T,readWranglerJsonc as b}from"../packem_shared/WRANGLER_FILES-UNW-xY5u.mjs";import{collectWranglerSecretVariables as S,scanWranglerVariablesForSecrets as B}from"../packem_shared/collectWranglerSecretVariables-DSTHPYsC.mjs";import{wranglerToAlchemy as v}from"../packem_shared/wranglerToAlchemy-CX9nCwtu.mjs";import{REQUIRED_COMPATIBILITY_DATE as M,REQUIRED_FLAG as O,validateWrangler as V,validateWranglerConfig as h,validateWranglerProject as U,withTailConsumer as j}from"../packem_shared/REQUIRED_COMPATIBILITY_DATE-lT_LQGqV.mjs";export{o as BINDING_MANIFEST_VERSION,n as CLOUDFLARE_DRIVER,f as REMOTE_ELIGIBLE_KEYS,M as REQUIRED_COMPATIBILITY_DATE,O as REQUIRED_FLAG,C as WORKERS_CACHE_MIN_DATE,L as WRANGLER_FILES,a as buildBindingManifest,i as collectExportGaps,S as collectWranglerSecretVariables,T as findWranglerFile,p as injectRemoteFlags,A as isCacheEnabled,I as isRemoteEnvEnabled,W as materializeRemoteWranglerConfig,d as planRemoteBindings,b as readWranglerJsonc,E as reconcileWranglerBindings,c as reconcileWranglerCompatibilityDate,R as reconcileWranglerCrons,x as resolveRemoteEnabled,B as scanWranglerVariablesForSecrets,V as validateWrangler,h as validateWranglerConfig,U as validateWranglerProject,j as withTailConsumer,v as wranglerToAlchemy};
1
+ import{BINDING_MANIFEST_VERSION as o,buildBindingManifest as a}from"../packem_shared/BINDING_MANIFEST_VERSION-Cd00jVOf.mjs";import{C as l}from"../packem_shared/cloudflare-driver-CWf_lB-q.mjs";import{collectExportGaps as i,reconcileWranglerBindings as E}from"../packem_shared/collectExportGaps-CHgJxlgR.mjs";import{reconcileWranglerCompatibilityDate as g}from"../packem_shared/reconcileWranglerCompatibilityDate-7OO_xaKR.mjs";import{reconcileWranglerCrons as R}from"../packem_shared/reconcileWranglerCrons-COMb6ICf.mjs";import{REMOTE_ELIGIBLE_KEYS as f,injectRemoteFlags as p,isRemoteEnvEnabled as I,materializeRemoteWranglerConfig as W,planRemoteBindings as d,resolveRemoteEnabled as x}from"../packem_shared/REMOTE_ELIGIBLE_KEYS-D-edJjVY.mjs";import{WORKERS_CACHE_MIN_DATE as C,isCacheEnabled as A}from"../packem_shared/WORKERS_CACHE_MIN_DATE-0k9ABJtF.mjs";import{WRANGLER_FILES as L,findWranglerFile as T,readWranglerJsonc as b}from"../packem_shared/WRANGLER_FILES-UNW-xY5u.mjs";import{collectWranglerSecretVariables as S,scanWranglerVariablesForSecrets as v}from"../packem_shared/collectWranglerSecretVariables-DSTHPYsC.mjs";import{wranglerToAlchemy as N}from"../packem_shared/wranglerToAlchemy-CX9nCwtu.mjs";import{REQUIRED_COMPATIBILITY_DATE as M,REQUIRED_FLAG as O,mergeWranglerEnvironment as V,validateWrangler as h,validateWranglerConfig as U,validateWranglerProject as j,withTailConsumer as u}from"../packem_shared/REQUIRED_COMPATIBILITY_DATE-iWKnSx2C.mjs";export{o as BINDING_MANIFEST_VERSION,l as CLOUDFLARE_DRIVER,f as REMOTE_ELIGIBLE_KEYS,M as REQUIRED_COMPATIBILITY_DATE,O as REQUIRED_FLAG,C as WORKERS_CACHE_MIN_DATE,L as WRANGLER_FILES,a as buildBindingManifest,i as collectExportGaps,S as collectWranglerSecretVariables,T as findWranglerFile,p as injectRemoteFlags,A as isCacheEnabled,I as isRemoteEnvEnabled,W as materializeRemoteWranglerConfig,V as mergeWranglerEnvironment,d as planRemoteBindings,b as readWranglerJsonc,E as reconcileWranglerBindings,g as reconcileWranglerCompatibilityDate,R as reconcileWranglerCrons,x as resolveRemoteEnabled,v as scanWranglerVariablesForSecrets,h as validateWrangler,U as validateWranglerConfig,j as validateWranglerProject,u as withTailConsumer,N as wranglerToAlchemy};
package/dist/index.d.mts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { AgentIR, ContainerIR, WorkflowIR } from '@lunora/codegen';
2
2
  export type { AgentIR, ContainerIR, WorkflowIR } from '@lunora/codegen';
3
3
  import { Writable } from 'node:stream';
4
- import { D as DeployDriver } from "./packem_shared/schema-info.d-DS0bUsWE.mjs";
5
- export { type a as DeployRequest, type b as DevRequest, type c as DiscoverSchemaInfoResult, type d as DriverContext, type e as DriverToolchain, type f as InferOptions, type g as InferredAgent, type I as InferredBindings, type h as InferredContainer, type i as InferredWorkflow, type N as NamedResource, type P as ProvisionResult, type R as ResourceGraph, type S as SchemaInfo, type j as SecretRequest, type k as ShardNamespaceResource, type T as TailRequest, type l as ToolchainCommand, m as discoverSchemaInfo, n as inferLunoraBindings, p as packageNamesFromBindings } from "./packem_shared/schema-info.d-DS0bUsWE.mjs";
4
+ import { D as DeployDriver } from "./packem_shared/schema-info.d-BRnrGpR1.mjs";
5
+ export { C as COMPOSED_WORKER_ENTRY, type a as DeployRequest, type b as DevRequest, type c as DiscoverSchemaInfoResult, type d as DriverContext, type e as DriverToolchain, type f as InferOptions, type g as InferredAgent, type I as InferredBindings, type h as InferredContainer, type i as InferredWorkflow, type N as NamedResource, type P as ProvisionResult, type R as ResourceGraph, type S as SchemaInfo, type j as SecretRequest, type k as ShardNamespaceResource, type T as TailRequest, type l as ToolchainCommand, m as discoverSchemaInfo, n as inferLunoraBindings, p as packageNamesFromBindings } from "./packem_shared/schema-info.d-BRnrGpR1.mjs";
6
6
  export { type A as AdditivePolicyEdit, type D as DestructivePolicyEdit, type P as PolicyEdit, type a as PolicyScaffoldFailureReason, type b as ScaffoldFileResult, type S as ScaffoldPolicyEdit, type c as WireResult, type W as WireRlsEdit, d as classifyPolicyEdit, r as resolveServerModule, s as scaffoldPolicyFile, w as wireRlsIntoProcedure } from "./packem_shared/policy-scaffold.d-D2H4_G01.mjs";
7
7
  interface DiscoverAgentInfoResult {
8
8
  /** Discovered agent definitions; `[]` when none are declared or parsing failed. */
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { AgentIR, ContainerIR, WorkflowIR } from '@lunora/codegen';
2
2
  export type { AgentIR, ContainerIR, WorkflowIR } from '@lunora/codegen';
3
3
  import { Writable } from 'node:stream';
4
- import { D as DeployDriver } from "./packem_shared/schema-info.d-DS0bUsWE.js";
5
- export { type a as DeployRequest, type b as DevRequest, type c as DiscoverSchemaInfoResult, type d as DriverContext, type e as DriverToolchain, type f as InferOptions, type g as InferredAgent, type I as InferredBindings, type h as InferredContainer, type i as InferredWorkflow, type N as NamedResource, type P as ProvisionResult, type R as ResourceGraph, type S as SchemaInfo, type j as SecretRequest, type k as ShardNamespaceResource, type T as TailRequest, type l as ToolchainCommand, m as discoverSchemaInfo, n as inferLunoraBindings, p as packageNamesFromBindings } from "./packem_shared/schema-info.d-DS0bUsWE.js";
4
+ import { D as DeployDriver } from "./packem_shared/schema-info.d-BRnrGpR1.js";
5
+ export { C as COMPOSED_WORKER_ENTRY, type a as DeployRequest, type b as DevRequest, type c as DiscoverSchemaInfoResult, type d as DriverContext, type e as DriverToolchain, type f as InferOptions, type g as InferredAgent, type I as InferredBindings, type h as InferredContainer, type i as InferredWorkflow, type N as NamedResource, type P as ProvisionResult, type R as ResourceGraph, type S as SchemaInfo, type j as SecretRequest, type k as ShardNamespaceResource, type T as TailRequest, type l as ToolchainCommand, m as discoverSchemaInfo, n as inferLunoraBindings, p as packageNamesFromBindings } from "./packem_shared/schema-info.d-BRnrGpR1.js";
6
6
  export { type A as AdditivePolicyEdit, type D as DestructivePolicyEdit, type P as PolicyEdit, type a as PolicyScaffoldFailureReason, type b as ScaffoldFileResult, type S as ScaffoldPolicyEdit, type c as WireResult, type W as WireRlsEdit, d as classifyPolicyEdit, r as resolveServerModule, s as scaffoldPolicyFile, w as wireRlsIntoProcedure } from "./packem_shared/policy-scaffold.d-D2H4_G01.js";
7
7
  interface DiscoverAgentInfoResult {
8
8
  /** Discovered agent definitions; `[]` when none are declared or parsing failed. */
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{AGENT_MODE_ENV as o,detectAiAgent as t}from"./packem_shared/AGENT_MODE_ENV-D8MvSwPE.mjs";import{discoverAgentInfo as s}from"./packem_shared/discoverAgentInfo-CTdCSfYM.mjs";import{AGENT_RULES_DIR as E,AGENT_RULES_HINT as l,AGENT_RULES_HINT_ENV as n,LUNORA_SKILL_NAMES as p,ROOT_SKILL_NAME as _,claimAgentRulesHint as c,detectAgentRules as d}from"./packem_shared/AGENT_RULES_DIR-3-Sx1gHU.mjs";import{CODEGEN_ENV as A,isCodegenDisabled as D}from"./packem_shared/CODEGEN_ENV-ZsCxV1kP.mjs";import{discoverContainerInfo as f}from"./packem_shared/discoverContainerInfo-EhZtEBQs.mjs";import{streamContainerLogs as N}from"./packem_shared/streamContainerLogs-0nko1qpv.mjs";import{detectFramework as T,projectUsesUmbrella as I,readProjectDependencyNames as R}from"./packem_shared/detectFramework-CUiVEHDQ.mjs";import{DEV_BINDINGS_FILE as x,DEV_DAEMON_ENV as V,DEV_HANDOFF_ENV as P,DEV_LOG_FILE as u,DEV_LOG_FILE_ENV as F,DEV_STATE_DIR as O,DEV_STATE_FILE as C,claimDevServerState as G,clearDevServerState as U,isDevServerReady as b,isProcessAlive as M,isRecordedProcessCurrent as y,readDevServerState as k,readLiveDevServerState as B,updateDevServerState as w,writeDevServerState as j}from"./packem_shared/DEV_BINDINGS_FILE-pyOiNLP4.mjs";import{DEV_VARS_EXAMPLE_FILE as K,DEV_VARS_FILE as h,DEV_VARS_KEY_PATTERN as Y,escapeRegExp as W,parseDevVariableEntries as J,removeDevVariableLine as q,upsertDevVariableLine as X}from"./packem_shared/DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{DEFAULT_DEPLOY_TARGET as Q,deployTargetIds as Z,isRunnableTarget as $,resolveDeployDriver as ee,runnableTargetIds as re}from"./packem_shared/DEFAULT_DEPLOY_TARGET-DpDlbJNG.mjs";import{inferLunoraBindings as te,packageNamesFromBindings as ae}from"./packem_shared/inferLunoraBindings-7kPfAt6p.mjs";import{LINKED_PROJECT_DIR as ie,LINKED_PROJECT_FILE as Ee,readLinkedProject as le,writeLinkedProject as ne}from"./packem_shared/LINKED_PROJECT_DIR-Ba5qPEwo.mjs";import{LUNORA_IGNORED_PATHS as _e,applyLintIgnores as ce,detectLintTools as de}from"./packem_shared/LUNORA_IGNORED_PATHS-BHABA9u-.mjs";import{LUNORA_EVENT_SOURCE as Ae,formatLunoraEvent as De}from"./packem_shared/LUNORA_EVENT_SOURCE-DYdcDU9G.mjs";import{default as fe}from"./packem_shared/LunoraReporter-f277GLNT.mjs";import{addArgsFor as Ne,detectInstalledManagers as ve,detectPackageManager as Te,execArgsFor as Ie,installArgsFor as Re,runScriptArgsFor as ge,runScriptCommand as xe}from"./packem_shared/addArgsFor-B4D4zvM0.mjs";import{P as Pe,s as ue}from"./packem_shared/package-secrets-registry-CFZ5bA8L.mjs";import{runPostCodegenHook as Oe}from"./packem_shared/runPostCodegenHook-BF3XTBFz.mjs";import{LUNORA_CONFIG_FILE as Ge,interpretRemote as Ue,readProjectRemotePreference as be,readProjectTarget as Me,resolveProjectTarget as ye,resolveTargetOrThrow as ke}from"./packem_shared/LUNORA_CONFIG_FILE-CJqaLqNo.mjs";import{createConfirm as we,isInteractive as je,promptMultiSelect as He,promptSelect as Ke,promptText as he,promptYesNo as Ye}from"./packem_shared/createConfirm-D5mKTMHj.mjs";import{buildPackageSecretsBlock as Je,ensureDevVariables as qe,ensureDevVarsExample as Xe,fillDevSecrets as ze,generateSecretValue as Qe,isMintableSecretKey as Ze,isPlaceholderValue as $e,planDevSecretsFill as er,planDevVariablesAugment as rr,planDevVariablesScaffold as or,requiredSecrets as tr,writeDevVariablesFileAtomically as ar}from"./packem_shared/buildPackageSecretsBlock-8PWr25wv.mjs";import{applyAdditiveEdit as ir,classifyEdit as Er}from"./packem_shared/applyAdditiveEdit-CH0VhMJ2.mjs";import{parseSchema as nr}from"./packem_shared/parseSchema-D1Wbr1qv.mjs";import{classifyPolicyEdit as _r,resolveServerModule as cr,scaffoldPolicyFile as dr,wireRlsIntoProcedure as mr}from"./packem_shared/classifyPolicyEdit-D8NwrHxR.mjs";import{discoverSchemaInfo as Dr}from"./packem_shared/discoverSchemaInfo-Bg2CUZXG.mjs";import{ACCENT as fr,BADGES as Lr,BADGE_COLUMN_WIDTH as Nr,LUNA_ART as vr,LUNA_BUNNY as Tr,LUNA_NAME as Ir,LUNA_SIGNOFF as Rr,STEP_BADGE_NAMES as gr,badgeLead as xr,badgeWidth as Vr,padBadge as Pr,paintAnswer as ur,paintBadge as Fr}from"./packem_shared/ACCENT-CotPTfv7.mjs";import{discoverWorkflowInfo as Cr}from"./packem_shared/discoverWorkflowInfo-BsPvlo6O.mjs";export{fr as ACCENT,o as AGENT_MODE_ENV,E as AGENT_RULES_DIR,l as AGENT_RULES_HINT,n as AGENT_RULES_HINT_ENV,Lr as BADGES,Nr as BADGE_COLUMN_WIDTH,A as CODEGEN_ENV,Q as DEFAULT_DEPLOY_TARGET,x as DEV_BINDINGS_FILE,V as DEV_DAEMON_ENV,P as DEV_HANDOFF_ENV,u as DEV_LOG_FILE,F as DEV_LOG_FILE_ENV,O as DEV_STATE_DIR,C as DEV_STATE_FILE,K as DEV_VARS_EXAMPLE_FILE,h as DEV_VARS_FILE,Y as DEV_VARS_KEY_PATTERN,ie as LINKED_PROJECT_DIR,Ee as LINKED_PROJECT_FILE,vr as LUNA_ART,Tr as LUNA_BUNNY,Ir as LUNA_NAME,Rr as LUNA_SIGNOFF,Ge as LUNORA_CONFIG_FILE,Ae as LUNORA_EVENT_SOURCE,_e as LUNORA_IGNORED_PATHS,p as LUNORA_SKILL_NAMES,fe as LunoraReporter,Pe as PACKAGE_SECRETS_REGISTRY,_ as ROOT_SKILL_NAME,gr as STEP_BADGE_NAMES,Ne as addArgsFor,ir as applyAdditiveEdit,ce as applyLintIgnores,xr as badgeLead,Vr as badgeWidth,Je as buildPackageSecretsBlock,c as claimAgentRulesHint,G as claimDevServerState,Er as classifyEdit,_r as classifyPolicyEdit,U as clearDevServerState,we as createConfirm,Z as deployTargetIds,d as detectAgentRules,t as detectAiAgent,T as detectFramework,ve as detectInstalledManagers,de as detectLintTools,Te as detectPackageManager,s as discoverAgentInfo,f as discoverContainerInfo,Dr as discoverSchemaInfo,Cr as discoverWorkflowInfo,qe as ensureDevVariables,Xe as ensureDevVarsExample,W as escapeRegExp,Ie as execArgsFor,ze as fillDevSecrets,De as formatLunoraEvent,Qe as generateSecretValue,te as inferLunoraBindings,Re as installArgsFor,Ue as interpretRemote,D as isCodegenDisabled,b as isDevServerReady,je as isInteractive,Ze as isMintableSecretKey,$e as isPlaceholderValue,M as isProcessAlive,y as isRecordedProcessCurrent,$ as isRunnableTarget,ae as packageNamesFromBindings,Pr as padBadge,ur as paintAnswer,Fr as paintBadge,J as parseDevVariableEntries,nr as parseSchema,er as planDevSecretsFill,rr as planDevVariablesAugment,or as planDevVariablesScaffold,I as projectUsesUmbrella,He as promptMultiSelect,Ke as promptSelect,he as promptText,Ye as promptYesNo,k as readDevServerState,le as readLinkedProject,B as readLiveDevServerState,R as readProjectDependencyNames,be as readProjectRemotePreference,Me as readProjectTarget,q as removeDevVariableLine,tr as requiredSecrets,ee as resolveDeployDriver,ye as resolveProjectTarget,cr as resolveServerModule,ke as resolveTargetOrThrow,Oe as runPostCodegenHook,ge as runScriptArgsFor,xe as runScriptCommand,re as runnableTargetIds,dr as scaffoldPolicyFile,ue as secretsForPackages,N as streamContainerLogs,w as updateDevServerState,X as upsertDevVariableLine,mr as wireRlsIntoProcedure,j as writeDevServerState,ar as writeDevVariablesFileAtomically,ne as writeLinkedProject};
1
+ import{AGENT_MODE_ENV as o,detectAiAgent as t}from"./packem_shared/AGENT_MODE_ENV-D8MvSwPE.mjs";import{discoverAgentInfo as E}from"./packem_shared/discoverAgentInfo-CTdCSfYM.mjs";import{AGENT_RULES_DIR as i,AGENT_RULES_HINT as l,AGENT_RULES_HINT_ENV as n,LUNORA_SKILL_NAMES as p,ROOT_SKILL_NAME as _,claimAgentRulesHint as c,detectAgentRules as d}from"./packem_shared/AGENT_RULES_DIR-3-Sx1gHU.mjs";import{CODEGEN_ENV as A,isCodegenDisabled as D}from"./packem_shared/CODEGEN_ENV-ZsCxV1kP.mjs";import{discoverContainerInfo as f}from"./packem_shared/discoverContainerInfo-EhZtEBQs.mjs";import{streamContainerLogs as L}from"./packem_shared/streamContainerLogs-0nko1qpv.mjs";import{detectFramework as R,projectUsesUmbrella as T,readProjectDependencyNames as I}from"./packem_shared/detectFramework-CUiVEHDQ.mjs";import{DEV_BINDINGS_FILE as x,DEV_DAEMON_ENV as V,DEV_HANDOFF_ENV as P,DEV_LOG_FILE as u,DEV_LOG_FILE_ENV as F,DEV_STATE_DIR as O,DEV_STATE_FILE as C,claimDevServerState as G,clearDevServerState as U,isDevServerReady as b,isProcessAlive as M,isRecordedProcessCurrent as y,readDevServerState as k,readLiveDevServerState as B,updateDevServerState as w,writeDevServerState as K}from"./packem_shared/DEV_BINDINGS_FILE-pyOiNLP4.mjs";import{DEV_VARS_EXAMPLE_FILE as H,DEV_VARS_FILE as Y,DEV_VARS_KEY_PATTERN as h,escapeRegExp as W,parseDevVariableEntries as J,removeDevVariableLine as q,upsertDevVariableLine as X}from"./packem_shared/DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{DEFAULT_DEPLOY_TARGET as Q,deployTargetIds as Z,isRunnableTarget as $,resolveDeployDriver as ee,runnableTargetIds as re}from"./packem_shared/DEFAULT_DEPLOY_TARGET-De4Ps8C8.mjs";import{COMPOSED_WORKER_ENTRY as te,inferLunoraBindings as ae,packageNamesFromBindings as Ee}from"./packem_shared/COMPOSED_WORKER_ENTRY-CAPCs3GJ.mjs";import{LINKED_PROJECT_DIR as ie,LINKED_PROJECT_FILE as le,readLinkedProject as ne,writeLinkedProject as pe}from"./packem_shared/LINKED_PROJECT_DIR-Ba5qPEwo.mjs";import{LUNORA_IGNORED_PATHS as ce,applyLintIgnores as de,detectLintTools as me}from"./packem_shared/LUNORA_IGNORED_PATHS-BHABA9u-.mjs";import{LUNORA_EVENT_SOURCE as De,formatLunoraEvent as Se}from"./packem_shared/LUNORA_EVENT_SOURCE-DYdcDU9G.mjs";import{default as Ne}from"./packem_shared/LunoraReporter-f277GLNT.mjs";import{addArgsFor as ve,detectInstalledManagers as Re,detectPackageManager as Te,execArgsFor as Ie,installArgsFor as ge,runScriptArgsFor as xe,runScriptCommand as Ve}from"./packem_shared/addArgsFor-B4D4zvM0.mjs";import{P as ue,s as Fe}from"./packem_shared/package-secrets-registry-CFZ5bA8L.mjs";import{runPostCodegenHook as Ce}from"./packem_shared/runPostCodegenHook-BF3XTBFz.mjs";import{LUNORA_CONFIG_FILE as Ue,interpretRemote as be,readProjectRemotePreference as Me,readProjectTarget as ye,resolveProjectTarget as ke,resolveTargetOrThrow as Be}from"./packem_shared/LUNORA_CONFIG_FILE-DFoqHCyP.mjs";import{createConfirm as Ke,isInteractive as je,promptMultiSelect as He,promptSelect as Ye,promptText as he,promptYesNo as We}from"./packem_shared/createConfirm-D5mKTMHj.mjs";import{buildPackageSecretsBlock as qe,ensureDevVariables as Xe,ensureDevVarsExample as ze,fillDevSecrets as Qe,generateSecretValue as Ze,isMintableSecretKey as $e,isPlaceholderValue as er,planDevSecretsFill as rr,planDevVariablesAugment as or,planDevVariablesScaffold as tr,requiredSecrets as ar,writeDevVariablesFileAtomically as Er}from"./packem_shared/buildPackageSecretsBlock-8PWr25wv.mjs";import{applyAdditiveEdit as ir,classifyEdit as lr}from"./packem_shared/applyAdditiveEdit-CH0VhMJ2.mjs";import{parseSchema as pr}from"./packem_shared/parseSchema-D1Wbr1qv.mjs";import{classifyPolicyEdit as cr,resolveServerModule as dr,scaffoldPolicyFile as mr,wireRlsIntoProcedure as Ar}from"./packem_shared/classifyPolicyEdit-D8NwrHxR.mjs";import{discoverSchemaInfo as Sr}from"./packem_shared/discoverSchemaInfo-Bg2CUZXG.mjs";import{ACCENT as Nr,BADGES as Lr,BADGE_COLUMN_WIDTH as vr,LUNA_ART as Rr,LUNA_BUNNY as Tr,LUNA_NAME as Ir,LUNA_SIGNOFF as gr,STEP_BADGE_NAMES as xr,badgeLead as Vr,badgeWidth as Pr,padBadge as ur,paintAnswer as Fr,paintBadge as Or}from"./packem_shared/ACCENT-CotPTfv7.mjs";import{discoverWorkflowInfo as Gr}from"./packem_shared/discoverWorkflowInfo-BsPvlo6O.mjs";export{Nr as ACCENT,o as AGENT_MODE_ENV,i as AGENT_RULES_DIR,l as AGENT_RULES_HINT,n as AGENT_RULES_HINT_ENV,Lr as BADGES,vr as BADGE_COLUMN_WIDTH,A as CODEGEN_ENV,te as COMPOSED_WORKER_ENTRY,Q as DEFAULT_DEPLOY_TARGET,x as DEV_BINDINGS_FILE,V as DEV_DAEMON_ENV,P as DEV_HANDOFF_ENV,u as DEV_LOG_FILE,F as DEV_LOG_FILE_ENV,O as DEV_STATE_DIR,C as DEV_STATE_FILE,H as DEV_VARS_EXAMPLE_FILE,Y as DEV_VARS_FILE,h as DEV_VARS_KEY_PATTERN,ie as LINKED_PROJECT_DIR,le as LINKED_PROJECT_FILE,Rr as LUNA_ART,Tr as LUNA_BUNNY,Ir as LUNA_NAME,gr as LUNA_SIGNOFF,Ue as LUNORA_CONFIG_FILE,De as LUNORA_EVENT_SOURCE,ce as LUNORA_IGNORED_PATHS,p as LUNORA_SKILL_NAMES,Ne as LunoraReporter,ue as PACKAGE_SECRETS_REGISTRY,_ as ROOT_SKILL_NAME,xr as STEP_BADGE_NAMES,ve as addArgsFor,ir as applyAdditiveEdit,de as applyLintIgnores,Vr as badgeLead,Pr as badgeWidth,qe as buildPackageSecretsBlock,c as claimAgentRulesHint,G as claimDevServerState,lr as classifyEdit,cr as classifyPolicyEdit,U as clearDevServerState,Ke as createConfirm,Z as deployTargetIds,d as detectAgentRules,t as detectAiAgent,R as detectFramework,Re as detectInstalledManagers,me as detectLintTools,Te as detectPackageManager,E as discoverAgentInfo,f as discoverContainerInfo,Sr as discoverSchemaInfo,Gr as discoverWorkflowInfo,Xe as ensureDevVariables,ze as ensureDevVarsExample,W as escapeRegExp,Ie as execArgsFor,Qe as fillDevSecrets,Se as formatLunoraEvent,Ze as generateSecretValue,ae as inferLunoraBindings,ge as installArgsFor,be as interpretRemote,D as isCodegenDisabled,b as isDevServerReady,je as isInteractive,$e as isMintableSecretKey,er as isPlaceholderValue,M as isProcessAlive,y as isRecordedProcessCurrent,$ as isRunnableTarget,Ee as packageNamesFromBindings,ur as padBadge,Fr as paintAnswer,Or as paintBadge,J as parseDevVariableEntries,pr as parseSchema,rr as planDevSecretsFill,or as planDevVariablesAugment,tr as planDevVariablesScaffold,T as projectUsesUmbrella,He as promptMultiSelect,Ye as promptSelect,he as promptText,We as promptYesNo,k as readDevServerState,ne as readLinkedProject,B as readLiveDevServerState,I as readProjectDependencyNames,Me as readProjectRemotePreference,ye as readProjectTarget,q as removeDevVariableLine,ar as requiredSecrets,ee as resolveDeployDriver,ke as resolveProjectTarget,dr as resolveServerModule,Be as resolveTargetOrThrow,Ce as runPostCodegenHook,xe as runScriptArgsFor,Ve as runScriptCommand,re as runnableTargetIds,mr as scaffoldPolicyFile,Fe as secretsForPackages,L as streamContainerLogs,w as updateDevServerState,X as upsertDevVariableLine,Ar as wireRlsIntoProcedure,K as writeDevServerState,Er as writeDevVariablesFileAtomically,pe as writeLinkedProject};
@@ -0,0 +1 @@
1
+ import"./COMPOSED_WORKER_ENTRY-CAPCs3GJ.mjs";import{C as a}from"./cloudflare-driver-CWf_lB-q.mjs";import"./collectExportGaps-CHgJxlgR.mjs";import"./reconcileWranglerCompatibilityDate-7OO_xaKR.mjs";import"./reconcileWranglerCrons-COMb6ICf.mjs";export{a as default};
@@ -0,0 +1 @@
1
+ import{existsSync as d,statSync as v,readFileSync as f,readdirSync as B}from"node:fs";import{init as k,parse as g}from"es-module-lexer";import{discoverAgentInfo as $}from"./discoverAgentInfo-CTdCSfYM.mjs";import{WRANGLER_FILES as F,readWranglerJsonc as Y}from"./WRANGLER_FILES-UNW-xY5u.mjs";import{discoverContainerInfo as U}from"./discoverContainerInfo-EhZtEBQs.mjs";import{escapeRegExp as T}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{discoverFlags as j,FLAGS_FILENAME as K,discoverQueues as W,QUEUES_FILENAME as M}from"@lunora/codegen";import{d as w}from"./discover-info-Vj9d4qYt.mjs";import{discoverSchemaInfo as X}from"./discoverSchemaInfo-Bg2CUZXG.mjs";import{discoverWorkflowInfo as G}from"./discoverWorkflowInfo-BsPvlo6O.mjs";import{join as c}from"node:path";const H=(e,s)=>{const{error:t,value:r}=w(e,s,K,j);return t===void 0?{flags:r}:{error:t}},V=(e,s)=>{const{error:t,value:r}=w(e,s,M,W);return t===void 0?{queues:r??[]}:{error:t,queues:[]}},q=new Set([".cjs",".cts",".js",".jsx",".mjs",".mts",".ts",".tsx"]),J=new Set([".git",".lunora-cache",".wrangler","_generated","dist","node_modules"]),Q=["lunora","src"],z=["src/server/index.ts","src/server/index.tsx","src/index.ts","src/worker.ts"],_={SchedulerDO:"SCHEDULER",SessionDO:"SESSION",ShardDO:"SHARD"},N=Object.keys(_),Z={SchedulerDO:/\btype\s+SchedulerDO\b/,SessionDO:/\btype\s+SessionDO\b/,ShardDO:/\btype\s+ShardDO\b/},ee=/\benv\s*\.\s*DB\b/,se=/\benv\s*\.\s*AI\b/,D=/\bctx\s*\.\s*pipelines\b/,P=/^\s*import\s+type\b/,re=new Set(["@lunora/agent","@lunora/agent/sandbox"]),te=e=>{const s=e.indexOf("{");if(s===-1)return"";const t=e.indexOf("}",s+1);return t===-1?e.slice(s+1):e.slice(s+1,t)},ne=/\btype\s+browserTool\b/,oe=/\bbrowserTool\b/,ae=/import\s+\{[^}]*\bbrowserTool\b[^}]*\}\s+from\s+["']@lunora\/agent(?:\/sandbox)?["']/,ie=e=>{if(P.test(e))return!1;const s=te(e);return oe.test(s)&&!ne.test(s)},ce=e=>{try{const[s]=g(e);return s.some(t=>t.n!==void 0&&re.has(t.n)&&ie(e.slice(t.ss,t.se)))}catch{return ae.test(e)}},h={usesAi:{pattern:/\bfrom\s+["']@lunora\/ai["']/,source:"@lunora/ai"},usesAnalytics:{pattern:/\bfrom\s+["']@lunora\/bindings\/analytics["']/,source:"@lunora/bindings/analytics"},usesAuth:{pattern:/\bfrom\s+["']@lunora\/auth["']/,source:"@lunora/auth"},usesBrowser:{pattern:/\bfrom\s+["']@lunora\/browser["']/,source:"@lunora/browser"},usesHyperdrive:{pattern:/\bfrom\s+["']@lunora\/hyperdrive["']/,source:"@lunora/hyperdrive"},usesImages:{pattern:/\bfrom\s+["']@lunora\/bindings\/images["']/,source:"@lunora/bindings/images"},usesKv:{pattern:/\bfrom\s+["']@lunora\/bindings\/kv["']/,source:"@lunora/bindings/kv"},usesMail:{pattern:/\bfrom\s+["']@lunora\/mail["']/,source:"@lunora/mail"},usesPayment:{pattern:/\bfrom\s+["']@lunora\/payment["']/,source:"@lunora/payment"},usesPipelines:{pattern:D,source:"@lunora/bindings/pipelines"},usesScheduler:{pattern:/\bfrom\s+["']@lunora\/scheduler["']/,source:"@lunora/scheduler"},usesStorage:{pattern:/\bfrom\s+["']@lunora\/storage["']/,source:"@lunora/storage"},usesX402Charge:{pattern:/\bfrom\s+["']@lunora\/x402\/charge["']/,source:"@lunora/x402/charge"},usesX402Pay:{pattern:/\bfrom\s+["']@lunora\/x402\/pay["']/,source:"@lunora/x402/pay"}},m=Object.keys(h),ue="STRIPE_SECRET_KEY + STRIPE_WEBHOOK_SECRET (Stripe) or POLAR_ACCESS_TOKEN + POLAR_WEBHOOK_SECRET (Polar)",C=[...m,"needsD1"],de=()=>{const e={};for(const s of C)e[s]=!1;return e},l=Object.freeze(de()),x=(e,s)=>{const t={};for(const r of C)t[r]=e[r]||s[r];return t},le=e=>{for(const s of m)if(h[s].source===e)return{...l,[s]:!0};return l},pe=e=>{const[s]=g(e);let t=l;for(const r of s){const n=r.n;!n||P.test(e.slice(r.ss,r.se))||(t=x(t,le(n)))}return t},me=e=>{const s={...l};for(const t of m)s[t]=h[t].pattern.test(e);return s},be=e=>{let s;try{s=pe(e)}catch{s=me(e)}return x(s,{...l,needsD1:ee.test(e),usesAi:se.test(e),usesPipelines:D.test(e)})},y=(e,s)=>{let t;try{t=B(e,{withFileTypes:!0})}catch{return}for(const r of t){if(r.isDirectory()){J.has(r.name)||y(c(e,r.name),s);continue}const n=r.name.lastIndexOf(".");n!==-1&&q.has(r.name.slice(n))&&s.push(c(e,r.name))}},fe="virtual:lunora/worker",ge=["ShardDO"],he="src/worker.ts",Ee=e=>{for(const s of F){const t=c(e,s);if(!d(t))continue;const{parsed:r}=Y(t),n=r?.main;if(n===fe)return{composed:!0};const a=c(e,he);if(d(a))return{composed:!1,path:a};if(typeof n=="string"&&d(c(e,n)))return{composed:!1,path:c(e,n)};break}for(const s of z){const t=c(e,s);if(d(t))return{composed:!1,path:t}}return{composed:!1}},Se=e=>{const s=f(e,"utf8");let t;try{const[,r]=g(s);t=new Set(r.map(n=>n.n))}catch{t=new Set(N.filter(r=>new RegExp(String.raw`\bexport\b[^\n;]*\b${r}\b`).test(s)))}return N.filter(r=>t.has(r)&&!Z[r].test(s)).map(r=>({binding:_[r],className:r}))},_e=/(?:^|[\s,{])type$/u,xe=(e,s)=>{const t=s.ls>=0?s.ls:s.s;return _e.test(e.slice(0,t).trimEnd())},ye=(e,s)=>{const t=T(s);return new RegExp(String.raw`\bexport\s+type\s+${t}\b`,"u").test(e)||new RegExp(String.raw`\bexport\s+type\s*\{[^}]*\b${t}\b`,"u").test(e)||new RegExp(String.raw`\bexport\s+\{[^}]*\btype\s+${t}\b`,"u").test(e)},S=(e,s,t)=>{if(s.length===0)return[];if(e.composed)return s.map(o=>({...o,exported:!0}));if(e.path===void 0)return s.map(o=>({...o,exported:!1}));const r=f(e.path,"utf8"),n=new RegExp(String.raw`\bexport\s*\*\s*from\s*["'][^"']*_generated\/${t}(?:\.js)?["']`).test(r);let a;try{const[,o]=g(r);a=new Set(o.filter(i=>!xe(r,i)).map(i=>i.n))}catch{a=new Set(s.map(o=>o.className).filter(o=>new RegExp(String.raw`\bexport\b[^\n;]*\b${T(o)}\b`,"u").test(r)&&!ye(r,o)))}return s.map(o=>{const i=n||a.has(o.className);return{...o,exported:i}})},Re=(e,s)=>X(e,s).info?.hasGlobalTable??!1,Oe=(e,s)=>{let t=l;for(const r of s){const n=c(e,r);if(!d(n)||!v(n).isDirectory())continue;const a=[];y(n,a);for(const o of a)t=x(t,be(f(o,"utf8")))}return t},Ie=(e,s)=>{const t=c(e,s);if(!d(t)||!v(t).isDirectory())return!1;const r=[];return y(t,r),r.some(n=>ce(f(n,"utf8")))},Ae=(e,s,t)=>[...e.map(r=>r.exported?`${r.bindingName}/${r.className} (container "${r.exportName}" declared and exported)`:`hint: container "${r.exportName}" is declared but ${r.className} is not exported by the worker entry — add \`export * from "./lunora/_generated/containers"\``),...s.map(r=>r.exported?`${r.bindingName}/${r.className} (workflow "${r.exportName}" declared and exported)`:`hint: workflow "${r.exportName}" is declared but ${r.className} is not exported by the worker entry — add \`export * from "./lunora/_generated/workflows"\``),...t.map(r=>r.exported?`${r.bindingName}/${r.className} (agent "${r.exportName}" declared and exported)`:`hint: agent "${r.exportName}" is declared but ${r.className} is not exported by the worker entry — add \`export * from "./lunora/_generated/agents"\``)],Ne=(e,s)=>[[e.usesAi,"AI (@lunora/ai imported or env.AI 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: @lunora/scheduler is imported but no SchedulerDO is exported by the worker entry"],[e.usesStorage,"hint: @lunora/storage is imported; add an r2_buckets binding (bucket binding names are user-defined)"],[e.usesMail,"hint: @lunora/mail is imported; set RESEND_API_KEY in .dev.vars (obtain at https://resend.com/api-keys)"],[e.usesPayment,`hint: @lunora/payment is imported; set the provider secrets in .dev.vars — ${ue}`],[e.usesBrowser,"browser (@lunora/browser imported) — self-describing { binding: BROWSER }"],[e.usesImages,"images (@lunora/bindings/images imported) — self-describing { binding: IMAGES }"],[e.usesAnalytics,"analytics_engine_datasets (@lunora/bindings/analytics imported) — self-describing { binding: ANALYTICS, dataset }"],[e.usesKv,"hint: @lunora/bindings/kv is imported; add a kv_namespaces binding ({ binding, id }) and pass env.<BINDING> to createKv() — the namespace id can't be auto-provisioned"],[e.usesHyperdrive,"hint: @lunora/hyperdrive is imported; run 'wrangler hyperdrive create' and add a 'hyperdrive' binding ({ binding, id }) — the id can't be auto-provisioned"],[e.usesPipelines,"hint: ctx.pipelines is used; run 'wrangler pipelines create <name>' and add a 'pipelines' binding ({ binding, pipeline }) — the pipeline resource can't be auto-provisioned"],[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.usesX402Pay,"hint: @lunora/x402/pay is imported (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(([r])=>r).map(([,r])=>r),ve=(e,s,t,r=[],n=[],a=[])=>{const o=new Set(e.map(u=>u.className)),i=e.map(u=>`${u.binding}/${u.className} (exported by worker entry)`);return s&&i.push("DB (.global() table declared)"),i.push(...Ae(r,n,a),...Ne(t,o)),i},Ue=async e=>{await k;const s=e.schemaDir??"lunora",t=e.scanDirs??Q,r=Oe(e.projectRoot,t),n={...r,usesBrowser:r.usesBrowser||Ie(e.projectRoot,s)},a=Ee(e.projectRoot);let o;a.composed?o=ge.map(p=>({binding:_[p],className:p})):o=a.path===void 0?[]:Se(a.path);const i=n.needsD1||Re(e.projectRoot,s),u=S(a,U(e.projectRoot,s).containers,"containers"),R=S(a,G(e.projectRoot,s).workflows,"workflows"),O=S(a,$(e.projectRoot,s).agents,"agents"),L=[...V(e.projectRoot,s).queues],{flags:b}=H(e.projectRoot,s),E=b?.provider==="flagship"&&b.mode==="binding"?b.bindingName:void 0,I={};for(const p of m)I[p]=n[p];const A=ve(o,i,n,u,R,O);return E!==void 0&&A.push(`hint: lunora/flags.ts uses Flagship in binding mode; add a flagship binding ({ binding: "${E}", app_id }) — the app_id can't be auto-provisioned`),{agents:O,containers:u,durableObjects:o,flagshipBinding:E,needsD1:i,queues:L,signals:A,usesFlags:b!==void 0,workflows:R,...I}},je=e=>{const s=[];for(const t of m)e[t]&&s.push(h[t].source);return s};export{he as COMPOSED_WORKER_ENTRY,fe as LUNORA_WORKER_VIRTUAL_ID,z as WORKER_ENTRY_FALLBACKS,Ue as inferLunoraBindings,xe as isTypeOnlyExportEntry,je as packageNamesFromBindings,Ee as resolveWorkerEntry};
@@ -0,0 +1 @@
1
+ import{t as a,C as d}from"./cloudflare-driver-CWf_lB-q.mjs";import{inferLunoraBindings as s}from"./COMPOSED_WORKER_ENTRY-CAPCs3GJ.mjs";const l=[{detect:e=>e.containers.length>0,warning:"containers have no Node equivalent in @lunora/platform-node — ctx.containers will be unavailable"}],p={id:"node",infer:async e=>a(await s({projectRoot:e.projectRoot}),e.crons??[]),name:"Node",provision:async e=>{let n;try{n=a(await s({projectRoot:e.projectRoot}),e.crons??[])}catch(r){const i=r instanceof Error?r.message:String(r);return{added:[],changed:!1,warnings:[`requirement inference skipped: ${i}`]}}const t=l.filter(r=>r.detect(n)).map(r=>r.warning);return n.crons.length>0&&t.push(`${String(n.crons.length)} cron expression(s) declared, and NOTHING dispatches them on this target: no runtime walks the generated LUNORA_CRONS map into SchedulerHost.cron. Schedule the work explicitly (ctx.scheduler.runAfter/runAt) or deploy to a target with cron dispatch`),{added:[],changed:!1,warnings:t}}},h="cloudflare",o={cloudflare:d,node:p},c=()=>Object.keys(o).toSorted((e,n)=>e.localeCompare(n)),g=(e=h)=>{const n=o[e];if(n===void 0)throw new Error(`unknown deploy target "${e}" — available targets: ${c().join(", ")}`);return n},u=e=>Object.hasOwn(o,e)&&g(e).toolchain!==void 0,m=()=>c().filter(e=>u(e));export{h as DEFAULT_DEPLOY_TARGET,c as deployTargetIds,u as isRunnableTarget,g as resolveDeployDriver,m as runnableTargetIds};
@@ -1 +1 @@
1
- import{existsSync as c,readFileSync as i}from"node:fs";import{readProjectTarget as s}from"@lunora/codegen";import{parse as a}from"jsonc-parser";import{DEFAULT_DEPLOY_TARGET as f,resolveDeployDriver as m}from"./DEFAULT_DEPLOY_TARGET-DpDlbJNG.mjs";import{join as p}from"node:path";const l="lunora.json",d=r=>{if(typeof r=="boolean")return r;if(r!==null&&typeof r=="object")return!0},u=r=>{const e=p(r,l);if(!c(e))return;let t;try{t=i(e,"utf8")}catch{return}const n=[],o=a(t,n,{allowTrailingComma:!0});if(!(n.length>0||o===null||typeof o!="object"))return o},h=r=>d(u(r)?.remote),g=r=>s(r),j=(r,e)=>e??g(r)??f,D=(r,e)=>{const t=j(r,e);return m(t),t};export{l as LUNORA_CONFIG_FILE,d as interpretRemote,h as readProjectRemotePreference,g as readProjectTarget,j as resolveProjectTarget,D as resolveTargetOrThrow};
1
+ import{existsSync as c,readFileSync as i}from"node:fs";import{readProjectTarget as s}from"@lunora/codegen";import{parse as a}from"jsonc-parser";import{DEFAULT_DEPLOY_TARGET as f,resolveDeployDriver as m}from"./DEFAULT_DEPLOY_TARGET-De4Ps8C8.mjs";import{join as p}from"node:path";const l="lunora.json",d=r=>{if(typeof r=="boolean")return r;if(r!==null&&typeof r=="object")return!0},u=r=>{const e=p(r,l);if(!c(e))return;let t;try{t=i(e,"utf8")}catch{return}const n=[],o=a(t,n,{allowTrailingComma:!0});if(!(n.length>0||o===null||typeof o!="object"))return o},h=r=>d(u(r)?.remote),g=r=>s(r),j=(r,e)=>e??g(r)??f,D=(r,e)=>{const t=j(r,e);return m(t),t};export{l as LUNORA_CONFIG_FILE,d as interpretRemote,h as readProjectRemotePreference,g as readProjectTarget,j as resolveProjectTarget,D as resolveTargetOrThrow};
@@ -0,0 +1 @@
1
+ import{existsSync as g,readFileSync as N}from"node:fs";import{dirname as R,join as f}from"node:path";import{COMPOSED_WORKER_ENTRY as x,WORKER_ENTRY_FALLBACKS as I}from"./COMPOSED_WORKER_ENTRY-CAPCs3GJ.mjs";import{discoverSchemaInfo as L}from"./discoverSchemaInfo-Bg2CUZXG.mjs";import{isCacheEnabled as C,WORKERS_CACHE_MIN_DATE as _}from"./WORKERS_CACHE_MIN_DATE-0k9ABJtF.mjs";import{findWranglerFile as T,readWranglerJsonc as B}from"./WRANGLER_FILES-UNW-xY5u.mjs";const W=new Set(["1","enabled","on","true","yes"]),q=e=>typeof e=="string"&&W.has(e.trim().toLowerCase()),v="2026-04-07",We="web_socket_auto_reply_to_close",E=/^\d{4}-\d{2}-\d{2}$/,$=["containers","d1_databases","durable_objects","kv_namespaces","queues","r2_buckets","secrets_store_secrets","services","tail_consumers","vars","vectorize","workflows"],S=["assets","compatibility_date","exports","logpush","main","migrations","observability","placement"],k=(e,s)=>{if(s===void 0)return{merged:e,unverifiedKeys:[]};const t=e.env?.[s];if(t===void 0){const r=Object.keys(e.env??{}).toSorted((c,d)=>c.localeCompare(d)),l=r.length>0?` (declared: ${r.join(", ")}).`:" (no environments are declared).";return{error:`--env "${s}" names no environment declared in wrangler.jsonc's "env" block${l}`,merged:e,unverifiedKeys:[]}}const n={...e},i=Object.keys(t).filter(r=>r!=="env");for(const r of i)S.includes(r)&&(n[r]=t[r]);for(const r of $)n[r]=t[r];const a=new Set([...$,...S]),o=i.filter(r=>!a.has(r)).map(String);return{merged:n,unverifiedKeys:o}},U=(e,s,t)=>{if(s.length===0)return;const n=e.vectorize??[],i=new Set(n.filter(Boolean).map(a=>a?.index_name));for(const a of s)i.has(a)||t.push(`schema declares vector index "${a}"; wrangler "vectorize" must include a binding with index_name "${a}"`)},P=new Set(["basic","dev","lite","standard","standard-1","standard-2","standard-3","standard-4"]),F={disk_mb:2e4,memory_mib:12288,vcpu:4},K=(e,s,t)=>{const n=e.instance_type;if(n===void 0)return;if(typeof n=="string"){P.has(n)||t.push(`${s} has unknown instance_type "${n}" — expected lite, basic, standard-1..4, or a custom { vcpu, memory_mib, disk_mb } object`);return}for(const[r,l]of Object.entries(F)){const c=n[r];c!==void 0&&(typeof c!="number"||c<=0||c>l)&&t.push(`${s} custom instance_type ${r} must be a positive number ≤ ${String(l)} (got ${String(c)})`)}const{disk_mb:i,memory_mib:a,vcpu:o}=n;if(typeof o=="number"&&typeof a=="number"&&a<o*3072&&t.push(`${s} custom instance_type needs ≥ 3 GiB (3072 MiB) memory per vCPU (got ${String(a)} MiB for ${String(o)} vCPU)`),typeof a=="number"&&typeof i=="number"){const r=Math.floor(a/1024*2e3);i>r&&t.push(`${s} custom instance_type allows ≤ 2 GB disk per GiB memory (≤ ${String(r)} MB for ${String(a)} MiB memory; got ${String(i)} MB)`)}},G=(e,s,t)=>{const{boundClasses:n,classKinds:i,errors:a,warnings:o}=t;if(!e||typeof e!="object"||typeof e.class_name!="string"||e.class_name.length===0){a.push(`${s} must have a non-empty "class_name" naming its container-enabled Durable Object class`);return}(typeof e.image!="string"||e.image.length===0)&&a.push(`${s} ("${e.class_name}") must have an "image" — a Dockerfile path or a registry reference`),n.has(e.class_name)||a.push(`${s} class "${e.class_name}" has no matching durable_objects binding — your dev server auto-reconciles this on startup; add { "name": "...", "class_name": "${e.class_name}" } to fix it by hand`);const r=i.get(e.class_name);r!=="sqlite"&&a.push(r==="classic"?`${s} class "${e.class_name}" is registered via "new_classes" but containers require SQLite-backed DOs — move it to "new_sqlite_classes"`:`${s} class "${e.class_name}" is missing from migrations — add a migration entry with "new_sqlite_classes": ["${e.class_name}"]`),K(e,`${s} ("${e.class_name}")`,a),e.max_instances===void 0&&o.push(`${s} ("${e.class_name}") declares no max_instances — set a cap so a traffic spike can't fan out unbounded container spend`)},m=e=>typeof e=="string"&&e.length>0,b=e=>Array.isArray(e)?e.filter(s=>s!==null&&typeof s=="object"):[],h=e=>Array.isArray(e)?e.filter(s=>m(s)):[],M=e=>{const s=new Map;for(const t of b(e)){for(const n of h(t.new_classes))s.set(n,"classic");for(const n of h(t.new_sqlite_classes))s.set(n,"sqlite");for(const n of b(t.renamed_classes))if(m(n.from)&&m(n.to)){const i=s.get(n.from)??"sqlite";s.delete(n.from),s.set(n.to,i)}for(const n of h(t.deleted_classes))s.delete(n)}return s},Y=e=>new Set(M(e).keys()),Q=(e,s)=>{const t=Y(e.migrations);for(const n of b(e.durable_objects?.bindings))n.script_name===void 0&&m(n.class_name)&&!t.has(n.class_name)&&s.push(`durable_objects.bindings declares class "${n.class_name}" but it is missing from migrations — add a migration entry with "new_sqlite_classes": ["${n.class_name}"] (or "new_classes" for a non-SQLite-backed class), or let the dev server auto-reconcile it on the next start`)},H=(e,s,t)=>{if(e.containers===void 0)return;if(!Array.isArray(e.containers)){s.push("containers must be an array of { class_name, image, ... } entries");return}const n=e.containers;if(n.length===0)return;const i=new Set(b(e.durable_objects?.bindings).map(o=>o.class_name)),a=M(e.migrations);for(const[o,r]of n.entries())G(r,`containers[${String(o)}]`,{boundClasses:i,classKinds:a,errors:s,warnings:t});e.observability?.enabled!==!0&&t.push('containers are configured but observability is not enabled — container logs will not be captured (add { "observability": { "enabled": true } })')},y=e=>e,p=(e,s,t,n)=>{if(e!==void 0){if(!Array.isArray(e)){n.push(t.arrayMessage);return}for(const[i,a]of y(e).entries()){const o=`${s}[${String(i)}]`;if(!a||typeof a!="object"){n.push(t.objectMessage(o));continue}for(const r of t.fields)m(a[r.field])||n.push(r.message(o))}}},V={arrayMessage:"workflows must be an array of { name, binding, class_name } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the Workflow binding (e.g. WORKFLOW_ORDER_PIPELINE)`},{field:"class_name",message:e=>`${e} must have a non-empty "class_name" naming the exported WorkflowEntrypoint class`},{field:"name",message:e=>`${e} must have a non-empty "name" naming the deployed workflow`}],objectMessage:e=>`${e} must be a { name, binding, class_name } object`},z={arrayMessage:"queues.producers must be an array of { binding, queue } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the Queue producer (e.g. QUEUE_EMAIL)`},{field:"queue",message:e=>`${e} must have a non-empty "queue" naming the deployed queue`}],objectMessage:e=>`${e} must be a { binding, queue } object`},X={arrayMessage:"queues.consumers must be an array of { queue } entries",fields:[{field:"queue",message:e=>`${e} must have a non-empty "queue" naming the consumed queue`}],objectMessage:e=>`${e} must be a { queue } object`},J=(e,s)=>{if(e.queues!==void 0){if(typeof e.queues!="object"||Array.isArray(e.queues)){s.push("queues must be a { producers, consumers } object");return}p(e.queues.producers,"queues.producers",z,s),p(e.queues.consumers,"queues.consumers",X,s)}},Z={arrayMessage:"secrets_store_secrets must be an array of { binding, store_id, secret_name } entries",fields:["binding","store_id","secret_name"].map(e=>({field:e,message:s=>`${s} must have a non-empty "${e}"`})),objectMessage:e=>`${e} must be a { binding, store_id, secret_name } object`},ee=[{arrayMessage:"kv_namespaces must be an array of { binding, id } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the KV namespace binding`,hintField:"id",hintMessage:(e,s)=>`${e} ("${s}") has no "id" — run \`wrangler kv namespace create\` and set the namespace id, or the binding can't resolve`,key:"kv_namespaces"},{arrayMessage:"flagship must be an array of { binding, app_id } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Flagship binding`,hintField:"app_id",hintMessage:(e,s)=>`${e} ("${s}") has no "app_id" — create a Flagship app and set its id, or the binding can't resolve`,key:"flagship"},{arrayMessage:"hyperdrive must be an array of { binding, id } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Hyperdrive binding`,hintField:"id",hintMessage:(e,s)=>`${e} ("${s}") has no "id" — run \`wrangler hyperdrive create\` and set the id, or the binding can't connect`,key:"hyperdrive"},{arrayMessage:"pipelines must be an array of { binding, stream } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Pipelines binding`,hintField:["stream","pipeline"],hintMessage:(e,s)=>`${e} ("${s}") has no "stream" — run \`wrangler pipelines create <name>\` and set the stream name, or the binding can't resolve`,key:"pipelines"},{arrayMessage:"analytics_engine_datasets must be an array of { binding, dataset } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Analytics Engine binding`,hintField:"dataset",hintMessage:(e,s)=>`${e} ("${s}") has no "dataset" — it defaults to the binding name; set it explicitly to avoid drift`,key:"analytics_engine_datasets"}],se=(e,s,t,n)=>{const i=e[s.key];if(i!==void 0){if(!Array.isArray(i)){t.push(s.arrayMessage);return}for(const[a,o]of y(i).entries()){const r=`${s.key}[${String(a)}]`;if(!o||typeof o!="object"||!m(o.binding)){t.push(s.bindingMessage(r));continue}(typeof s.hintField=="string"?[s.hintField]:s.hintField).some(c=>m(o[c]))||n.push(s.hintMessage(r,o.binding))}}},ne=[{key:"browser",message:'browser must be an object with a non-empty "binding" (e.g. { "binding": "BROWSER" })'},{key:"images",message:'images must be an object with a non-empty "binding" (e.g. { "binding": "IMAGES" })'}],te=(e,s,t)=>{const n=e[s.key];n!==void 0&&(typeof n!="object"||n===null||Array.isArray(n)||!m(n.binding))&&t.push(s.message)},ie=[{arrayMessage:"services must be an array of { binding, service, entrypoint? } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the service binding`},{field:"service",message:e=>`${e} must have a non-empty "service" naming the target Worker`}],key:"services",objectMessage:e=>`${e} must be a { binding, service, entrypoint? } object`},{arrayMessage:"dispatch_namespaces must be an array of { binding, namespace } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding"`},{field:"namespace",message:e=>`${e} must have a non-empty "namespace" naming the dispatch namespace`}],key:"dispatch_namespaces",objectMessage:e=>`${e} must be a { binding, namespace } object`},{arrayMessage:"mtls_certificates must be an array of { binding, certificate_id } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding"`},{field:"certificate_id",message:e=>`${e} must have a non-empty "certificate_id" (upload via \`wrangler mtls-certificate upload\`)`}],key:"mtls_certificates",objectMessage:e=>`${e} must be a { binding, certificate_id } object`},{arrayMessage:"r2_buckets must be an array of { binding, bucket_name } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the R2 bucket binding`},{field:"bucket_name",message:e=>`${e} must have a non-empty "bucket_name" naming the deployed bucket`}],key:"r2_buckets",objectMessage:e=>`${e} must be a { binding, bucket_name } object`}],ae=(e,s)=>{const{d1_databases:t}=e;if(t!==void 0){if(!Array.isArray(t)){s.push("d1_databases must be an array of { binding, database_id | database_name } entries");return}for(const[n,i]of y(t).entries()){const a=`d1_databases[${String(n)}]`;if(!i||typeof i!="object"){s.push(`${a} must be a { binding, database_id | database_name } object`);continue}m(i.binding)||s.push(`${a} must have a non-empty "binding" naming the D1 binding`),!m(i.database_id)&&!m(i.database_name)&&s.push(`${a} must have a "database_id" or a "database_name" — run \`wrangler d1 create\` and set one, or the binding can't resolve`)}}},oe=(e,s,t)=>{const n=e.send_email;if(n===void 0)return;if(!Array.isArray(n)){s.push("send_email must be an array of { name, destination_address? } entries");return}const i=n;for(const[a,o]of i.entries())(!o||typeof o!="object"||typeof o.name!="string"||o.name.length===0)&&t.push(`send_email[${String(a)}] has no non-empty "name" naming the send-email binding — set one before deploying`)},re=(e,s)=>{e.logpush!==void 0&&typeof e.logpush!="boolean"&&s.push('logpush must be a boolean (set "logpush": true to enable Cloudflare Logpush)')},A=new Set(["off","smart","targeted"]),ce=(e,s)=>{const{placement:t}=e;if(t===void 0)return;if(typeof t!="object"||t===null||Array.isArray(t)){s.push('placement must be an object (e.g. { "mode": "smart" })');return}const{mode:n}=t;n!==void 0&&(typeof n!="string"||!A.has(n))&&s.push(`placement.mode must be one of ${[...A].map(i=>`"${i}"`).join(", ")}`)},de=(e,s)=>{const{observability:t}=e;if(t===void 0)return;if(typeof t!="object"||Array.isArray(t)){s.push('observability must be an object (e.g. { "enabled": true, "head_sampling_rate": 1 })');return}const n=(i,a)=>{i!==void 0&&(typeof i!="number"||Number.isNaN(i)||i<0||i>1)&&s.push(`${a} must be a number in [0, 1] (the fraction of requests sampled)`)};n(t.head_sampling_rate,"observability.head_sampling_rate"),t.logs!==void 0&&(typeof t.logs!="object"||Array.isArray(t.logs)?s.push("observability.logs must be an object"):n(t.logs.head_sampling_rate,"observability.logs.head_sampling_rate"))},le=(e,s)=>{const{cache:t}=e;if(t!==void 0){if(typeof t!="object"||t===null||Array.isArray(t)){s.push('cache must be an object (e.g. { "enabled": true })');return}t.enabled!==void 0&&typeof t.enabled!="boolean"&&s.push("cache.enabled must be a boolean (true or false)")}},me=(e,s)=>{const{exports:t}=e;if(t!==void 0){if(typeof t!="object"||t===null||Array.isArray(t)){s.push("exports must be an object keyed by entrypoint name");return}for(const[n,i]of Object.entries(t)){if(typeof i!="object"||i===null){s.push(`exports["${n}"] must be an object`);continue}i.type!==void 0&&typeof i.type!="string"&&s.push(`exports["${n}"].type must be a string`),i.cache!==void 0&&(typeof i.cache!="object"||i.cache===null||Array.isArray(i.cache)?s.push(`exports["${n}"].cache must be an object`):i.cache.enabled!==void 0&&typeof i.cache.enabled!="boolean"&&s.push(`exports["${n}"].cache.enabled must be a boolean`))}}},ue=(e,s)=>{const{assets:t}=e;if(t!==void 0){if(typeof t!="object"||Array.isArray(t)){s.push('assets must be an object (e.g. { "directory": "./dist/client", "binding": "ASSETS" })');return}(typeof t.directory!="string"||t.directory.length===0)&&s.push('assets must declare a non-empty "directory" pointing at the built client output (e.g. "./dist/client")'),t.binding!==void 0&&(typeof t.binding!="string"||t.binding.length===0)&&s.push('assets.binding must be a non-empty string (e.g. "ASSETS")'),t.html_handling!==void 0&&typeof t.html_handling!="string"&&s.push("assets.html_handling must be a string"),t.not_found_handling!==void 0&&typeof t.not_found_handling!="string"&&s.push("assets.not_found_handling must be a string")}},be=(e,s)=>{const t=e.tail_consumers;if(t===void 0)return;if(!Array.isArray(t)){s.push("tail_consumers must be an array of { service, environment? } entries");return}const n=t;for(const[i,a]of n.entries())(!a||typeof a!="object"||typeof a.service!="string"||a.service.length===0)&&s.push(`tail_consumers[${String(i)}] must have a non-empty "service" naming the consumer Worker`)},qe=(e,s)=>{const t=e.tail_consumers??[];return t.some(i=>!!i&&i?.service===s.service&&i?.environment===s.environment)?e:{...e,tail_consumers:[...t,s]}},ge=(e,s)=>{const{vars:t}=e;if(!t||typeof t!="object")return;const n=t.LUNORA_ALLOWED_ORIGINS,i=t.LUNORA_CORS_ALLOW_CREDENTIALS,a=typeof n=="string"&&n.split(",").some(r=>r.trim()==="*"),o=q(i);a&&o&&s.push('vars.LUNORA_ALLOWED_ORIGINS includes a "*" wildcard while vars.LUNORA_CORS_ALLOW_CREDENTIALS is on — browsers reject this combination and it defeats the allowlist; name explicit origins or drop credentials')},fe=(e,s,t)=>{const{error:n,merged:i,unverifiedKeys:a}=k(e,s);return n!==void 0?{error:n,wrangler:i}:(a.length>0&&t.push(`env.${String(s)} overrides ${a.join(", ")}, which this validator doesn't have a verified inheritance rule for — validated against the TOP-LEVEL value only. Double-check ${a.length===1?"it":"them"} by hand for "${String(s)}".`),{wrangler:i})},w=(e,s,t)=>{const n=[],i=[];if(!e||typeof e!="object")return n.push("wrangler config is not a valid object"),{errors:n,valid:!1,warnings:i};const{error:a,wrangler:o}=fe(e,t,i);if(a!==void 0)return n.push(a),{errors:n,valid:!1,warnings:i};b(o.durable_objects?.bindings).find(d=>d.name==="SHARD"&&d.class_name==="ShardDO")||n.push('durable_objects.bindings must include { "name": "SHARD", "class_name": "ShardDO" } — your dev server auto-reconciles this on startup, or add the binding manually'),Q(o,n);const c=o.compatibility_date??"";c&&!E.test(c)?n.push(`compatibility_date must be in YYYY-MM-DD format (got "${c}")`):c<v&&n.push(`compatibility_date must be >= "${v}" (got "${c||"<missing>"}")`),C(o)&&E.test(c)&&c<_&&n.push(`cache.enabled requires compatibility_date >= "${_}" (got "${c||"<missing>"}")`),s?.hasGlobalTable&&(b(o.d1_databases).find(D=>D.binding==="DB")||n.push('schema declares .global() tables; d1_databases must include a binding named "DB" — your dev server auto-reconciles this on startup, or add the binding manually')),ae(o,n),U(o,s?.vectorIndexNames??[],n),be(o,n),H(o,n,i),p(o.workflows,"workflows",V,n),J(o,n),p(o.secrets_store_secrets,"secrets_store_secrets",Z,n);for(const d of ee)se(o,d,n,i);for(const d of ie)p(o[d.key],d.key,d,n);for(const d of ne)te(o,d,n);return oe(o,n,i),re(o,n),ce(o,n),de(o,n),ue(o,n),le(o,n),me(o,n),ge(o,n),{errors:n,valid:n.length===0,warnings:i}},Ue=w,O=e=>Array.isArray(e)?e:[],pe=(e,s,t)=>{const n=[];for(const i of O(e)){const a=i?.image;typeof a!="string"||!(a.startsWith("./")||a.startsWith("../")||a.startsWith("/")||a.includes("Dockerfile"))||g(a.startsWith("/")?a:f(s,a))||n.push(`containers image "${a}" does not exist (resolved relative to ${t}); create the Dockerfile or point image at a registry reference`)}return n},he=(e,s,t)=>{const n=f(s,x);if(g(n))return n;if(typeof e=="string"&&e.length>0){const i=f(R(t),e);return g(i)?i:void 0}return I.map(i=>f(s,i)).find(i=>g(i))},ye=/\/\/[^\n]*|\/\*.*?\*\/|"[^"\n]*"|'[^'\n]*'|`[^`]*`/gsu,_e=e=>e.replaceAll(ye,s=>s.replaceAll(/[^\n]/gu," ")),ve=/\bexport\s*\*\s*(?:as\s+\w+\s*)?from\b/u,Ee=/\bexport\b/gu,$e=/^\s*(?:(?:abstract|async|declare|default)\s+)*/u,Se=/^(?:class|const|function|let|var)\s+(?<name>[$A-Z_a-z][\w$]*)/u,Ae=/^\s*(?:const|let|var)\s*\{/u,je=/^[$A-Z_a-z][\w$]*/u,Re=/^type\b/u,ke=/\s+/u,Me=e=>{const s=[];for(const t of e.split(",")){const n=t.trim().split(ke).filter(Boolean),i=n.at(-1);i!==void 0&&n[0]!=="type"&&s.push(i)}return s},we=e=>{const s=[];for(const t of e.split(",")){const n=t.includes(":")?t.slice(t.indexOf(":")+1):t,i=je.exec(n.trim());i&&s.push(i[0])}return s},j=e=>{const s=e.indexOf("{"),t=e.indexOf("}",s);return s===-1||t===-1?void 0:e.slice(s+1,t)},Oe=e=>{const s=e.trimStart();if(Re.test(s))return[];if(s.startsWith("{")){const n=j(s);return n===void 0?[]:Me(n)}if(Ae.test(e)){const n=j(e);return n===void 0?[]:we(n)}const t=Se.exec(e.replace($e,""));return t?.groups?.name===void 0?[]:[t.groups.name]},De=e=>{const s=new Set;for(const t of e.matchAll(Ee))for(const n of Oe(e.slice(t.index+6)))s.add(n);return s},Ne=(e,s,t)=>{const n=he(e.main,s,t);if(n===void 0)return[];let i;try{i=N(n,"utf8")}catch{return[]}const a=_e(i);if(ve.test(a))return[];const o=[];for(const c of b(e.durable_objects?.bindings))typeof c.class_name=="string"&&c.class_name.length>0&&c.script_name===void 0&&o.push({className:c.class_name,label:"durable_objects.bindings"});for(const c of O(e.workflows))typeof c?.class_name=="string"&&c.class_name.length>0&&c.script_name===void 0&&o.push({className:c.class_name,label:"workflows"});const r=De(a);return o.filter(c=>!r.has(c.className)).map(c=>`${c.label} declares class "${c.className}" but the worker entry (${n}) does not export it — wrangler refuses to bundle a Worker whose Durable Object classes are not exported. Add \`export { ${c.className} } from "…";\` to the entry.`)},Pe=e=>{const s=e.schemaDir??"lunora",t=T(e.projectRoot);if(!t){const u=`wrangler.jsonc not found in ${e.projectRoot}; create one declaring at least the SHARD durable object binding.`;return{problems:[u],report:{errors:[u],valid:!1,warnings:[]},wranglerPath:void 0}}const{parsed:n}=B(t);if(n===void 0){const u=`failed to parse ${t} as JSONC.`;return{problems:[u],report:{errors:[u],valid:!1,warnings:[]},wranglerPath:t}}const{error:i,merged:a}=k(n,e.environment);if(i!==void 0)return{problems:[i],report:{errors:[i],valid:!1,warnings:[]},wranglerPath:t};const{error:o,info:r}=L(e.projectRoot,s),l=w(n,r,e.environment);o!==void 0&&l.warnings.push(`schema parse failed in ${s}/schema.ts: ${o}`);const c=R(t);l.errors.push(...pe(a.containers??[],c,t)),l.warnings.push(...Ne(a,e.projectRoot,t));const d=a.assets?.directory;if(typeof d=="string"&&d.length>0){const u=d.startsWith("/")?d:f(c,d);g(u)||l.warnings.push(`assets.directory "${d}" does not exist yet — it is created by the client build; run the build before deploy`)}return l.valid=l.errors.length===0,{problems:l.errors,report:l,wranglerPath:t}};export{v as REQUIRED_COMPATIBILITY_DATE,We as REQUIRED_FLAG,k as mergeWranglerEnvironment,b as objectBindingEntries,h as stringEntries,Ue as validateWrangler,w as validateWranglerConfig,Pe as validateWranglerProject,qe as withTailConsumer};
@@ -0,0 +1 @@
1
+ import{inferLunoraBindings as c}from"./COMPOSED_WORKER_ENTRY-CAPCs3GJ.mjs";import{reconcileWranglerBindings as p}from"./collectExportGaps-CHgJxlgR.mjs";import{reconcileWranglerCompatibilityDate as g}from"./reconcileWranglerCompatibilityDate-7OO_xaKR.mjs";import{reconcileWranglerCrons as m}from"./reconcileWranglerCrons-COMb6ICf.mjs";const l=(n,r)=>{const e=n.durableObjects.map(o=>({className:o.className,exported:!0,name:o.binding})),a=n.queues.map(o=>({name:o.name})),i=n.workflows.map(o=>({exported:o.exported,name:o.exportName}));return{containers:n.containers.map(o=>({exported:o.exported,name:o.exportName})),crons:[...r],globalDatabase:n.needsD1,keyValueStore:n.usesKv,objectStorage:n.usesStorage,queues:a,shardNamespaces:e,signals:[...n.signals],workflows:i}},s=(n,r)=>{try{const e=r();return{added:e.added??[],changed:e.changed,configPath:e.wranglerPath,warnings:e.warnings??[]}}catch(e){const a=e instanceof Error?e.message:String(e);return{added:[],changed:!1,warnings:[`${n} skipped: ${a}`]}}},f={deploy:n=>{const r=n.preview===!0?["versions","upload"]:["deploy"];return n.entry!==void 0&&r.push(n.entry),n.environment!==void 0&&r.push("--env",n.environment),n.temporary===!0&&r.push("--temporary"),n.dryRun===!0&&r.push("--dry-run"),n.outDir!==void 0&&r.push("--outdir",n.outDir,"--metafile"),{args:r,tool:"wrangler"}},dev:n=>{const r=["dev"];return n.configPath!==void 0&&r.push("--config",n.configPath),n.environment!==void 0&&r.push("--env",n.environment),r.push(...n.extraArgs??[]),{args:r,tool:"wrangler"}},secretList:n=>{const r=["secret","list","--format","json"];return n.environment!==void 0&&r.push("--env",n.environment),n.temporary===!0&&r.push("--temporary"),{args:r,tool:"wrangler"}},secretPut:n=>{const r=["secret","put",n.key??""];return n.environment!==void 0&&r.push("--env",n.environment),n.temporary===!0&&r.push("--temporary"),{args:r,tool:"wrangler"}},tail:n=>{const r=["tail"];return n.worker!==void 0&&r.push(n.worker),n.environment!==void 0&&r.push("--env",n.environment),n.format!==void 0&&r.push("--format",n.format),n.status!==void 0&&r.push("--status",n.status),n.search!==void 0&&r.push("--search",n.search),n.temporary===!0&&r.push("--temporary"),{args:r,tool:"wrangler"}}},w={id:"cloudflare",infer:async n=>{const r=await c({projectRoot:n.projectRoot});return l(r,n.crons??[])},name:"Cloudflare",provision:async n=>{const r=n.crons??[],e=await(async()=>{try{const o=await c({projectRoot:n.projectRoot});return s("binding inference",()=>p(n.projectRoot,o))}catch(o){const d=o instanceof Error?o.message:String(o);return{added:[],changed:!1,warnings:[`binding inference skipped: ${d}`]}}})(),a=s("compatibility date sync",()=>g(n.projectRoot)),i=s("cron trigger sync",()=>m(n.projectRoot,r)),t=[e,{...a,added:a.changed?["compatibility_date"]:[]},{...i,added:i.changed?[`${String(r.length)} cron trigger(s)`]:[]}];return{added:t.flatMap(o=>o.added),changed:t.some(o=>o.changed),configPath:t.find(o=>o.configPath!==void 0)?.configPath,warnings:t.flatMap(o=>o.warnings)}},toolchain:f};export{w as C,l as t};
@@ -0,0 +1 @@
1
+ import{writeFileSync as D,readFileSync as B}from"node:fs";import{join as C}from"node:path";import{containerBuildTag as A}from"@lunora/container";import{DEV_VARS_FILE as O,parseDevVariableEntries as P}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{a as b}from"./jsonc-edit-BZgQIdAH.mjs";import{findWranglerFile as R,readWranglerJsonc as $}from"./WRANGLER_FILES-UNW-xY5u.mjs";import{objectBindingEntries as w,stringEntries as v}from"./REQUIRED_COMPATIBILITY_DATE-iWKnSx2C.mjs";const N="<replace-with-d1-create-id>",I=e=>[["container","containers",e.containers],["workflow","workflows",e.workflows],["agent","agents",e.agents]].flatMap(([n,t,i])=>i.filter(o=>!o.exported).map(({className:o,exportName:c})=>({className:o,exportName:c,kind:n,module:t}))),T=(e,s)=>{const n=e.flagshipBinding!==void 0&&!(s?.flagship??[]).some(i=>i.binding===e.flagshipBinding);return[[e.usesKv&&(s?.kv_namespaces?.length??0)===0,"@lunora/bindings/kv is used but no kv_namespaces binding exists; add a kv_namespaces entry ({ binding, id }) and pass env.<BINDING> to createKv() — the namespace id can't be auto-provisioned."],[e.usesHyperdrive&&(s?.hyperdrive?.length??0)===0,"@lunora/hyperdrive is used but no hyperdrive binding exists; run 'wrangler hyperdrive create' and add a 'hyperdrive' binding ({ binding, id }) — the id can't be auto-provisioned."],[e.usesPipelines&&(s?.pipelines?.length??0)===0,"ctx.pipelines is used but no pipelines binding exists; run 'wrangler pipelines create <name>' and add a 'pipelines' binding ({ binding, pipeline }) — the pipeline resource can't be auto-provisioned."],[n,`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(([i])=>i).map(([,i])=>i)},M=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.usesX402Pay,"@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(([n])=>n).map(([,n])=>n),_=(e,s,n)=>n.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/${s}"\` so its binding can be provisioned.`),k=[{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"}],W=()=>k.map(({keys:e,label:s})=>`${e[0]} + ${e[1]} (${s})`).join(" or "),K=e=>{let s;try{s=B(C(e,O),"utf8")}catch{return!1}const n=new Map(P(s).map(t=>[t.key,t.value]));return k.some(({keys:t})=>t.every(i=>(n.get(i)??"")!==""))},x=(e,s,n)=>{const t=new Set(e.durableObjects.map(d=>d.className)),i=[],o=(n?.r2_buckets?.length??0)>0,c=(n?.d1_databases?.some(d=>d.binding==="DB")??!1)||e.needsD1;return e.usesStorage&&!o&&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&&!t.has("SessionDO")&&!c&&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&&!t.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(..._("container","containers",e.containers),..._("workflow","workflows",e.workflows),..._("agent","agents",e.agents)),e.containers.length>0&&n?.observability?.enabled===!1&&i.push("containers are declared but observability is explicitly disabled in wrangler.jsonc — container logs will not be captured."),e.usesPayment&&!K(s)&&i.push(`@lunora/payment is used; set one provider's secret pair in .dev.vars — ${W()}.`),i.push(...M(e),...T(e,n)),i},L=e=>{const s=new Set(w(e).map(t=>t.tag));let n=1;for(;s.has(`v${String(n)}`);)n+=1;return`v${String(n)}`},Y=e=>{const s=new Set;for(const n of w(e)){for(const t of v(n.deleted_classes))s.delete(t);for(const{from:t,to:i}of w(n.renamed_classes))t!==void 0&&s.delete(t),i!==void 0&&s.add(i);for(const t of[...v(n.new_classes),...v(n.new_sqlite_classes)])s.add(t)}return s},H=(e,s,n)=>{const t=s.durable_objects?.bindings??[],i=new Set(t.map(u=>u.name)),o=n.filter(u=>!i.has(u.binding));let c=e;const d=[];if(o.length>0){const u=[...t,...o.map(p=>({class_name:p.className,name:p.binding}))];c=b(c,["durable_objects","bindings"],u),d.push(...o.map(p=>`${p.binding}/${p.className}`))}const g=s.migrations??[],l=n.map(u=>u.className).filter(u=>!Y(g).has(u));if(l.length>0){const u=[...g,{new_sqlite_classes:l,tag:L(g)}];c=b(c,["migrations"],u)}return{added:d,text:c}},j=(e,s)=>{const n=s.d1_databases??[];if(n.some(o=>o.binding==="DB"))return{added:[],text:e};const t=typeof s.name=="string"&&s.name.length>0?s.name:"lunora",i=[...n,{binding:"DB",database_id:N,database_name:t}];return{added:["DB (D1)"],text:b(e,["d1_databases"],i)}},y=(e,s,n,t,i)=>{const o=s[n]?.binding;return typeof o=="string"&&o.length>0?{added:[],text:e}:{added:[i],text:b(e,[n],{binding:t})}},F=(e,s)=>(s.analytics_engine_datasets?.length??0)>0?{added:[],text:e}:{added:["ANALYTICS (Analytics Engine)"],text:b(e,["analytics_engine_datasets"],[{binding:"ANALYTICS",dataset:"ANALYTICS"}])},G=e=>{if(typeof e=="string")return e;const s={};return e.diskMb!==void 0&&(s.disk_mb=e.diskMb),e.memoryMib!==void 0&&(s.memory_mib=e.memoryMib),e.vcpu!==void 0&&(s.vcpu=e.vcpu),s},U=e=>e.image.kind==="dockerfile"?e.image.dockerfilePath:e.image.kind==="registry"?e.image.reference:A(e.exportName),V=e=>{const s={class_name:e.className,image:U(e)};return e.image.kind==="dockerfile"&&(s.image_build_context=e.image.buildContext),e.buildArgs!==void 0&&e.image.kind!=="registry"&&(s.image_vars=e.buildArgs),e.instanceType!==void 0&&(s.instance_type=G(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},z=(e,s,n)=>{const t=s.containers??[],i=new Set(t.map(d=>d.class_name)),o=n.filter(d=>!i.has(d.className));if(o.length===0)return{added:[],text:e};const c=b(e,["containers"],[...t,...o.map(d=>V(d))]);return{added:o.map(d=>`containers/${d.className}`),text:c}},Q=(e,s)=>{if(s.observability!==void 0)return{added:[],text:e};const n=b(e,["observability"],{enabled:!0,head_sampling_rate:1});return{added:["observability"],text:n}},E=e=>({binding:e.bindingName,class_name:e.className,name:e.name}),X=(e,s,n,t=[])=>{const i=s.workflows??[],o=new Set(i.map(l=>l.class_name)),c=n.filter(l=>!o.has(l.className)),d=t.filter(l=>!o.has(l.className));if(c.length===0&&d.length===0)return{added:[],text:e};const g=b(e,["workflows"],[...i,...c.map(l=>E(l)),...d.map(l=>E(l))]);return{added:[...c.map(l=>`workflows/${l.className}`),...d.map(l=>`workflows/${l.className}`)],text:g}},J=(e,s,n)=>{const t=s.queues??{},i=t.producers??[],o=t.consumers??[],c=new Set(i.map(r=>r.binding)),d=new Set(o.map(r=>r.queue)),g=n.filter(r=>!c.has(r.bindingName)),l=n.filter(r=>!d.has(r.name));if(g.length===0&&l.length===0)return{added:[],text:e};const u=[...i,...g.map(r=>({binding:r.bindingName,queue:r.name}))],p=[...o,...l.map(r=>{const m={queue:r.name};return r.mode==="pull"&&(m.type="http_pull"),r.tuning.maxBatchSize!==void 0&&(m.max_batch_size=r.tuning.maxBatchSize),r.tuning.maxBatchTimeout!==void 0&&(m.max_batch_timeout=r.tuning.maxBatchTimeout),r.tuning.maxRetries!==void 0&&(m.max_retries=r.tuning.maxRetries),r.tuning.deadLetterQueue!==void 0&&(m.dead_letter_queue=r.tuning.deadLetterQueue),r.tuning.retryDelay!==void 0&&(m.retry_delay=r.tuning.retryDelay),m})],h=b(e,["queues"],{consumers:p,producers:u});return{added:[...g.map(r=>`queues.producers/${r.bindingName}`),...l.map(r=>`queues.consumers/${r.name}`)],text:h}},ie=(e,s,n)=>{const t=R(e),i=I(s);if(!t)return{added:[],changed:!1,exportGaps:i,reason:"wrangler.jsonc not found",warnings:x(s,e)};const{parsed:o,text:c}=$(t);if(o===void 0)return{added:[],changed:!1,exportGaps:i,reason:`failed to parse ${t} as JSONC`,warnings:x(s,e),wranglerPath:t};const d=x(s,e,o);if(n!==void 0){const a=o.env?.[n]!==void 0;d.push(a?`auto-provisioned bindings are written to the top level of wrangler.jsonc only — "env.${n}" has its own (non-inheritable) bindings and must be reconciled by hand; \`lunora deploy --env ${n}\` now validates them, so a gap here will be reported at deploy time.`:`--env "${n}" was requested but wrangler.jsonc declares no "env.${n}" block — auto-provisioned bindings are written to the top level only and will not apply to that environment.`)}const g=s.containers.filter(a=>a.exported),l=s.agents.filter(a=>a.exported&&a.voice===!0&&a.voiceBindingName!==void 0&&a.voiceClassName!==void 0),u=[...s.durableObjects,...g.map(a=>({binding:a.bindingName,className:a.className})),...l.map(a=>({binding:a.voiceBindingName,className:a.voiceClassName}))],p=s.workflows.filter(a=>a.exported),h=s.agents.filter(a=>a.exported),r=[{enabled:!0,run:a=>H(a,o,u)},{enabled:s.needsD1,run:a=>j(a,o)},{enabled:s.usesAi,run:a=>y(a,o,"ai","AI","AI (Workers AI)")},{enabled:s.usesBrowser,run:a=>y(a,o,"browser","BROWSER","BROWSER (Browser Rendering)")},{enabled:s.usesImages,run:a=>y(a,o,"images","IMAGES","IMAGES (Cloudflare Images)")},{enabled:s.usesAnalytics,run:a=>F(a,o)},{enabled:!0,run:a=>Q(a,o)},{enabled:g.length>0,run:a=>z(a,o,g)},{enabled:p.length>0||h.length>0,run:a=>X(a,o,p,h)},{enabled:s.queues.length>0,run:a=>J(a,o,s.queues)}];let m=c;const f=[];for(const a of r){if(!a.enabled)continue;const S=a.run(m);m=S.text,f.push(...S.added)}return f.includes("DB (D1)")&&d.push(`wrote a DB binding with a placeholder database_id ("${N}") — run \`wrangler d1 create <name>\` and replace it before deploying.`),m===c?{added:[],changed:!1,exportGaps:i,reason:"bindings already in sync",warnings:d,wranglerPath:t}:(D(t,m,"utf8"),{added:f,changed:!0,exportGaps:i,warnings:d,wranglerPath:t})};export{I as collectExportGaps,ie as reconcileWranglerBindings};
@@ -316,6 +316,21 @@ interface InferOptions {
316
316
  /** Lunora source directory holding `schema.ts`. Defaults to `lunora`. */
317
317
  schemaDir?: string;
318
318
  }
319
+ /**
320
+ * The class-B composed entry. `lunora deploy` passes this file to wrangler as
321
+ * the positional script whenever it exists, overriding `wrangler.main` — so it
322
+ * is what actually gets bundled and what wrangler checks its DO/Workflow
323
+ * bindings against. `main` in a class-B project names the framework adapter's
324
+ * build output (`.svelte-kit/cloudflare/_worker.js`, `dist/_worker.js`), which
325
+ * exists after `vite build` and exports only the SSR fetch handler. Lexing that
326
+ * instead read every declared class as unexported: nothing provisioned, plus a
327
+ * "add `export * from …`" warning the user cannot silence.
328
+ *
329
+ * Exported, not documented-as-duplicated: the CLI's `resolveComposedWorkerEntry`
330
+ * imports this constant, so the deploy's positional entry and the file this
331
+ * module lexes for exported classes cannot drift apart.
332
+ */
333
+ declare const COMPOSED_WORKER_ENTRY = "src/worker.ts";
319
334
  /**
320
335
  * Scan a Lunora project and report which Cloudflare bindings its code implies.
321
336
  * Read-only: performs no writes. Binding provisioning is driven by the worker
@@ -372,4 +387,4 @@ interface DiscoverSchemaInfoResult {
372
387
  * parse failure is a warning (validator) or simply ignorable (inference).
373
388
  */
374
389
  declare const discoverSchemaInfo: (projectRoot: string, schemaDirectory: string) => DiscoverSchemaInfoResult;
375
- export { DeployDriver as D, InferredBindings as I, NamedResource as N, ProvisionResult as P, ResourceGraph as R, SchemaInfo as S, TailRequest as T, DeployRequest as a, DevRequest as b, DiscoverSchemaInfoResult as c, DriverContext as d, DriverToolchain as e, InferOptions as f, InferredAgent as g, InferredContainer as h, InferredWorkflow as i, SecretRequest as j, ShardNamespaceResource as k, ToolchainCommand as l, discoverSchemaInfo as m, inferLunoraBindings as n, packageNamesFromBindings as p };
390
+ export { COMPOSED_WORKER_ENTRY as C, DeployDriver as D, InferredBindings as I, NamedResource as N, ProvisionResult as P, ResourceGraph as R, SchemaInfo as S, TailRequest as T, DeployRequest as a, DevRequest as b, DiscoverSchemaInfoResult as c, DriverContext as d, DriverToolchain as e, InferOptions as f, InferredAgent as g, InferredContainer as h, InferredWorkflow as i, SecretRequest as j, ShardNamespaceResource as k, ToolchainCommand as l, discoverSchemaInfo as m, inferLunoraBindings as n, packageNamesFromBindings as p };
@@ -316,6 +316,21 @@ interface InferOptions {
316
316
  /** Lunora source directory holding `schema.ts`. Defaults to `lunora`. */
317
317
  schemaDir?: string;
318
318
  }
319
+ /**
320
+ * The class-B composed entry. `lunora deploy` passes this file to wrangler as
321
+ * the positional script whenever it exists, overriding `wrangler.main` — so it
322
+ * is what actually gets bundled and what wrangler checks its DO/Workflow
323
+ * bindings against. `main` in a class-B project names the framework adapter's
324
+ * build output (`.svelte-kit/cloudflare/_worker.js`, `dist/_worker.js`), which
325
+ * exists after `vite build` and exports only the SSR fetch handler. Lexing that
326
+ * instead read every declared class as unexported: nothing provisioned, plus a
327
+ * "add `export * from …`" warning the user cannot silence.
328
+ *
329
+ * Exported, not documented-as-duplicated: the CLI's `resolveComposedWorkerEntry`
330
+ * imports this constant, so the deploy's positional entry and the file this
331
+ * module lexes for exported classes cannot drift apart.
332
+ */
333
+ declare const COMPOSED_WORKER_ENTRY = "src/worker.ts";
319
334
  /**
320
335
  * Scan a Lunora project and report which Cloudflare bindings its code implies.
321
336
  * Read-only: performs no writes. Binding provisioning is driven by the worker
@@ -372,4 +387,4 @@ interface DiscoverSchemaInfoResult {
372
387
  * parse failure is a warning (validator) or simply ignorable (inference).
373
388
  */
374
389
  declare const discoverSchemaInfo: (projectRoot: string, schemaDirectory: string) => DiscoverSchemaInfoResult;
375
- export { DeployDriver as D, InferredBindings as I, NamedResource as N, ProvisionResult as P, ResourceGraph as R, SchemaInfo as S, TailRequest as T, DeployRequest as a, DevRequest as b, DiscoverSchemaInfoResult as c, DriverContext as d, DriverToolchain as e, InferOptions as f, InferredAgent as g, InferredContainer as h, InferredWorkflow as i, SecretRequest as j, ShardNamespaceResource as k, ToolchainCommand as l, discoverSchemaInfo as m, inferLunoraBindings as n, packageNamesFromBindings as p };
390
+ export { COMPOSED_WORKER_ENTRY as C, DeployDriver as D, InferredBindings as I, NamedResource as N, ProvisionResult as P, ResourceGraph as R, SchemaInfo as S, TailRequest as T, DeployRequest as a, DevRequest as b, DiscoverSchemaInfoResult as c, DriverContext as d, DriverToolchain as e, InferOptions as f, InferredAgent as g, InferredContainer as h, InferredWorkflow as i, SecretRequest as j, ShardNamespaceResource as k, ToolchainCommand as l, discoverSchemaInfo as m, inferLunoraBindings as n, packageNamesFromBindings as p };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/config",
3
- "version": "1.0.0-alpha.190",
3
+ "version": "1.0.0-alpha.192",
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",
@@ -1 +0,0 @@
1
- import"./inferLunoraBindings-7kPfAt6p.mjs";import{C as a}from"./cloudflare-driver-BRcsrarS.mjs";import"./collectExportGaps-DHLZ7ulq.mjs";import"./reconcileWranglerCompatibilityDate-7OO_xaKR.mjs";import"./reconcileWranglerCrons-COMb6ICf.mjs";export{a as default};
@@ -1 +0,0 @@
1
- import{t as a,C as d}from"./cloudflare-driver-BRcsrarS.mjs";import{inferLunoraBindings as s}from"./inferLunoraBindings-7kPfAt6p.mjs";const l=[{detect:e=>e.containers.length>0,warning:"containers have no Node equivalent in @lunora/platform-node — ctx.containers will be unavailable"}],p={id:"node",infer:async e=>a(await s({projectRoot:e.projectRoot}),e.crons??[]),name:"Node",provision:async e=>{let n;try{n=a(await s({projectRoot:e.projectRoot}),e.crons??[])}catch(r){const i=r instanceof Error?r.message:String(r);return{added:[],changed:!1,warnings:[`requirement inference skipped: ${i}`]}}const t=l.filter(r=>r.detect(n)).map(r=>r.warning);return n.crons.length>0&&t.push(`${String(n.crons.length)} cron expression(s) declared, and NOTHING dispatches them on this target: no runtime walks the generated LUNORA_CRONS map into SchedulerHost.cron. Schedule the work explicitly (ctx.scheduler.runAfter/runAt) or deploy to a target with cron dispatch`),{added:[],changed:!1,warnings:t}}},h="cloudflare",o={cloudflare:d,node:p},c=()=>Object.keys(o).toSorted((e,n)=>e.localeCompare(n)),g=(e=h)=>{const n=o[e];if(n===void 0)throw new Error(`unknown deploy target "${e}" — available targets: ${c().join(", ")}`);return n},u=e=>Object.hasOwn(o,e)&&g(e).toolchain!==void 0,m=()=>c().filter(e=>u(e));export{h as DEFAULT_DEPLOY_TARGET,c as deployTargetIds,u as isRunnableTarget,g as resolveDeployDriver,m as runnableTargetIds};
@@ -1 +0,0 @@
1
- import{existsSync as f,readFileSync as O}from"node:fs";import{dirname as j,join as p}from"node:path";import{WORKER_ENTRY_FALLBACKS as D}from"./inferLunoraBindings-7kPfAt6p.mjs";import{discoverSchemaInfo as x}from"./discoverSchemaInfo-Bg2CUZXG.mjs";import{isCacheEnabled as N,WORKERS_CACHE_MIN_DATE as _}from"./WORKERS_CACHE_MIN_DATE-0k9ABJtF.mjs";import{findWranglerFile as I,readWranglerJsonc as L}from"./WRANGLER_FILES-UNW-xY5u.mjs";const C=new Set(["1","enabled","on","true","yes"]),T=e=>typeof e=="string"&&C.has(e.trim().toLowerCase()),v="2026-04-07",Ce="web_socket_auto_reply_to_close",E=/^\d{4}-\d{2}-\d{2}$/,$=["d1_databases","durable_objects","kv_namespaces","queues","r2_buckets","secrets_store_secrets","services","tail_consumers","vars","vectorize","workflows"],S=["assets","compatibility_date","exports","logpush","main","migrations","observability","placement"],R=(e,s)=>{if(s===void 0)return{merged:e,unverifiedKeys:[]};const t=e.env?.[s];if(t===void 0){const r=Object.keys(e.env??{}).toSorted((c,d)=>c.localeCompare(d)),l=r.length>0?` (declared: ${r.join(", ")}).`:" (no environments are declared).";return{error:`--env "${s}" names no environment declared in wrangler.jsonc's "env" block${l}`,merged:e,unverifiedKeys:[]}}const n={...e},i=Object.keys(t).filter(r=>r!=="env");for(const r of i)S.includes(r)&&(n[r]=t[r]);for(const r of $)n[r]=t[r];const a=new Set([...$,...S]),o=i.filter(r=>!a.has(r)).map(String);return{merged:n,unverifiedKeys:o}},B=(e,s,t)=>{if(s.length===0)return;const n=e.vectorize??[],i=new Set(n.filter(Boolean).map(a=>a?.index_name));for(const a of s)i.has(a)||t.push(`schema declares vector index "${a}"; wrangler "vectorize" must include a binding with index_name "${a}"`)},W=new Set(["basic","dev","lite","standard","standard-1","standard-2","standard-3","standard-4"]),q={disk_mb:2e4,memory_mib:12288,vcpu:4},U=(e,s,t)=>{const n=e.instance_type;if(n===void 0)return;if(typeof n=="string"){W.has(n)||t.push(`${s} has unknown instance_type "${n}" — expected lite, basic, standard-1..4, or a custom { vcpu, memory_mib, disk_mb } object`);return}for(const[r,l]of Object.entries(q)){const c=n[r];c!==void 0&&(typeof c!="number"||c<=0||c>l)&&t.push(`${s} custom instance_type ${r} must be a positive number ≤ ${String(l)} (got ${String(c)})`)}const{disk_mb:i,memory_mib:a,vcpu:o}=n;if(typeof o=="number"&&typeof a=="number"&&a<o*3072&&t.push(`${s} custom instance_type needs ≥ 3 GiB (3072 MiB) memory per vCPU (got ${String(a)} MiB for ${String(o)} vCPU)`),typeof a=="number"&&typeof i=="number"){const r=Math.floor(a/1024*2e3);i>r&&t.push(`${s} custom instance_type allows ≤ 2 GB disk per GiB memory (≤ ${String(r)} MB for ${String(a)} MiB memory; got ${String(i)} MB)`)}},F=(e,s,t)=>{const{boundClasses:n,classKinds:i,errors:a,warnings:o}=t;if(!e||typeof e!="object"||typeof e.class_name!="string"||e.class_name.length===0){a.push(`${s} must have a non-empty "class_name" naming its container-enabled Durable Object class`);return}(typeof e.image!="string"||e.image.length===0)&&a.push(`${s} ("${e.class_name}") must have an "image" — a Dockerfile path or a registry reference`),n.has(e.class_name)||a.push(`${s} class "${e.class_name}" has no matching durable_objects binding — your dev server auto-reconciles this on startup; add { "name": "...", "class_name": "${e.class_name}" } to fix it by hand`);const r=i.get(e.class_name);r!=="sqlite"&&a.push(r==="classic"?`${s} class "${e.class_name}" is registered via "new_classes" but containers require SQLite-backed DOs — move it to "new_sqlite_classes"`:`${s} class "${e.class_name}" is missing from migrations — add a migration entry with "new_sqlite_classes": ["${e.class_name}"]`),U(e,`${s} ("${e.class_name}")`,a),e.max_instances===void 0&&o.push(`${s} ("${e.class_name}") declares no max_instances — set a cap so a traffic spike can't fan out unbounded container spend`)},m=e=>typeof e=="string"&&e.length>0,b=e=>Array.isArray(e)?e.filter(s=>s!==null&&typeof s=="object"):[],h=e=>Array.isArray(e)?e.filter(s=>m(s)):[],k=e=>{const s=new Map;for(const t of b(e)){for(const n of h(t.new_classes))s.set(n,"classic");for(const n of h(t.new_sqlite_classes))s.set(n,"sqlite");for(const n of b(t.renamed_classes))if(m(n.from)&&m(n.to)){const i=s.get(n.from)??"sqlite";s.delete(n.from),s.set(n.to,i)}for(const n of h(t.deleted_classes))s.delete(n)}return s},P=e=>new Set(k(e).keys()),K=(e,s)=>{const t=P(e.migrations);for(const n of b(e.durable_objects?.bindings))n.script_name===void 0&&m(n.class_name)&&!t.has(n.class_name)&&s.push(`durable_objects.bindings declares class "${n.class_name}" but it is missing from migrations — add a migration entry with "new_sqlite_classes": ["${n.class_name}"] (or "new_classes" for a non-SQLite-backed class), or let the dev server auto-reconcile it on the next start`)},G=(e,s,t)=>{if(e.containers===void 0)return;if(!Array.isArray(e.containers)){s.push("containers must be an array of { class_name, image, ... } entries");return}const n=e.containers;if(n.length===0)return;const i=new Set(b(e.durable_objects?.bindings).map(o=>o.class_name)),a=k(e.migrations);for(const[o,r]of n.entries())F(r,`containers[${String(o)}]`,{boundClasses:i,classKinds:a,errors:s,warnings:t});e.observability?.enabled!==!0&&t.push('containers are configured but observability is not enabled — container logs will not be captured (add { "observability": { "enabled": true } })')},y=e=>e,g=(e,s,t,n)=>{if(e!==void 0){if(!Array.isArray(e)){n.push(t.arrayMessage);return}for(const[i,a]of y(e).entries()){const o=`${s}[${String(i)}]`;if(!a||typeof a!="object"){n.push(t.objectMessage(o));continue}for(const r of t.fields)m(a[r.field])||n.push(r.message(o))}}},Y={arrayMessage:"workflows must be an array of { name, binding, class_name } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the Workflow binding (e.g. WORKFLOW_ORDER_PIPELINE)`},{field:"class_name",message:e=>`${e} must have a non-empty "class_name" naming the exported WorkflowEntrypoint class`},{field:"name",message:e=>`${e} must have a non-empty "name" naming the deployed workflow`}],objectMessage:e=>`${e} must be a { name, binding, class_name } object`},Q={arrayMessage:"queues.producers must be an array of { binding, queue } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the Queue producer (e.g. QUEUE_EMAIL)`},{field:"queue",message:e=>`${e} must have a non-empty "queue" naming the deployed queue`}],objectMessage:e=>`${e} must be a { binding, queue } object`},H={arrayMessage:"queues.consumers must be an array of { queue } entries",fields:[{field:"queue",message:e=>`${e} must have a non-empty "queue" naming the consumed queue`}],objectMessage:e=>`${e} must be a { queue } object`},V=(e,s)=>{if(e.queues!==void 0){if(typeof e.queues!="object"||Array.isArray(e.queues)){s.push("queues must be a { producers, consumers } object");return}g(e.queues.producers,"queues.producers",Q,s),g(e.queues.consumers,"queues.consumers",H,s)}},z={arrayMessage:"secrets_store_secrets must be an array of { binding, store_id, secret_name } entries",fields:["binding","store_id","secret_name"].map(e=>({field:e,message:s=>`${s} must have a non-empty "${e}"`})),objectMessage:e=>`${e} must be a { binding, store_id, secret_name } object`},X=[{arrayMessage:"kv_namespaces must be an array of { binding, id } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the KV namespace binding`,hintField:"id",hintMessage:(e,s)=>`${e} ("${s}") has no "id" — run \`wrangler kv namespace create\` and set the namespace id, or the binding can't resolve`,key:"kv_namespaces"},{arrayMessage:"flagship must be an array of { binding, app_id } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Flagship binding`,hintField:"app_id",hintMessage:(e,s)=>`${e} ("${s}") has no "app_id" — create a Flagship app and set its id, or the binding can't resolve`,key:"flagship"},{arrayMessage:"hyperdrive must be an array of { binding, id } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Hyperdrive binding`,hintField:"id",hintMessage:(e,s)=>`${e} ("${s}") has no "id" — run \`wrangler hyperdrive create\` and set the id, or the binding can't connect`,key:"hyperdrive"},{arrayMessage:"pipelines must be an array of { binding, stream } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Pipelines binding`,hintField:["stream","pipeline"],hintMessage:(e,s)=>`${e} ("${s}") has no "stream" — run \`wrangler pipelines create <name>\` and set the stream name, or the binding can't resolve`,key:"pipelines"},{arrayMessage:"analytics_engine_datasets must be an array of { binding, dataset } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Analytics Engine binding`,hintField:"dataset",hintMessage:(e,s)=>`${e} ("${s}") has no "dataset" — it defaults to the binding name; set it explicitly to avoid drift`,key:"analytics_engine_datasets"}],J=(e,s,t,n)=>{const i=e[s.key];if(i!==void 0){if(!Array.isArray(i)){t.push(s.arrayMessage);return}for(const[a,o]of y(i).entries()){const r=`${s.key}[${String(a)}]`;if(!o||typeof o!="object"||!m(o.binding)){t.push(s.bindingMessage(r));continue}(typeof s.hintField=="string"?[s.hintField]:s.hintField).some(c=>m(o[c]))||n.push(s.hintMessage(r,o.binding))}}},Z=[{key:"browser",message:'browser must be an object with a non-empty "binding" (e.g. { "binding": "BROWSER" })'},{key:"images",message:'images must be an object with a non-empty "binding" (e.g. { "binding": "IMAGES" })'}],ee=(e,s,t)=>{const n=e[s.key];n!==void 0&&(typeof n!="object"||Array.isArray(n)||!m(n.binding))&&t.push(s.message)},se=[{arrayMessage:"services must be an array of { binding, service, entrypoint? } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the service binding`},{field:"service",message:e=>`${e} must have a non-empty "service" naming the target Worker`}],key:"services",objectMessage:e=>`${e} must be a { binding, service, entrypoint? } object`},{arrayMessage:"dispatch_namespaces must be an array of { binding, namespace } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding"`},{field:"namespace",message:e=>`${e} must have a non-empty "namespace" naming the dispatch namespace`}],key:"dispatch_namespaces",objectMessage:e=>`${e} must be a { binding, namespace } object`},{arrayMessage:"mtls_certificates must be an array of { binding, certificate_id } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding"`},{field:"certificate_id",message:e=>`${e} must have a non-empty "certificate_id" (upload via \`wrangler mtls-certificate upload\`)`}],key:"mtls_certificates",objectMessage:e=>`${e} must be a { binding, certificate_id } object`},{arrayMessage:"r2_buckets must be an array of { binding, bucket_name } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the R2 bucket binding`},{field:"bucket_name",message:e=>`${e} must have a non-empty "bucket_name" naming the deployed bucket`}],key:"r2_buckets",objectMessage:e=>`${e} must be a { binding, bucket_name } object`}],ne=(e,s)=>{const{d1_databases:t}=e;if(t!==void 0){if(!Array.isArray(t)){s.push("d1_databases must be an array of { binding, database_id | database_name } entries");return}for(const[n,i]of y(t).entries()){const a=`d1_databases[${String(n)}]`;if(!i||typeof i!="object"){s.push(`${a} must be a { binding, database_id | database_name } object`);continue}m(i.binding)||s.push(`${a} must have a non-empty "binding" naming the D1 binding`),!m(i.database_id)&&!m(i.database_name)&&s.push(`${a} must have a "database_id" or a "database_name" — run \`wrangler d1 create\` and set one, or the binding can't resolve`)}}},te=(e,s,t)=>{const n=e.send_email;if(n===void 0)return;if(!Array.isArray(n)){s.push("send_email must be an array of { name, destination_address? } entries");return}const i=n;for(const[a,o]of i.entries())(!o||typeof o!="object"||typeof o.name!="string"||o.name.length===0)&&t.push(`send_email[${String(a)}] has no non-empty "name" naming the send-email binding — set one before deploying`)},ie=(e,s)=>{e.logpush!==void 0&&typeof e.logpush!="boolean"&&s.push('logpush must be a boolean (set "logpush": true to enable Cloudflare Logpush)')},ae=(e,s)=>{const{placement:t}=e;if(t!==void 0){if(typeof t!="object"||Array.isArray(t)){s.push('placement must be an object (e.g. { "mode": "smart" })');return}t.mode!==void 0&&t.mode!=="smart"&&s.push('placement.mode must be "smart" (the only supported Smart Placement mode)')}},oe=(e,s)=>{const{observability:t}=e;if(t===void 0)return;if(typeof t!="object"||Array.isArray(t)){s.push('observability must be an object (e.g. { "enabled": true, "head_sampling_rate": 1 })');return}const n=(i,a)=>{i!==void 0&&(typeof i!="number"||Number.isNaN(i)||i<0||i>1)&&s.push(`${a} must be a number in [0, 1] (the fraction of requests sampled)`)};n(t.head_sampling_rate,"observability.head_sampling_rate"),t.logs!==void 0&&(typeof t.logs!="object"||Array.isArray(t.logs)?s.push("observability.logs must be an object"):n(t.logs.head_sampling_rate,"observability.logs.head_sampling_rate"))},re=(e,s)=>{const{cache:t}=e;if(t!==void 0){if(typeof t!="object"||t===null||Array.isArray(t)){s.push('cache must be an object (e.g. { "enabled": true })');return}t.enabled!==void 0&&typeof t.enabled!="boolean"&&s.push("cache.enabled must be a boolean (true or false)")}},ce=(e,s)=>{const{exports:t}=e;if(t!==void 0){if(typeof t!="object"||t===null||Array.isArray(t)){s.push("exports must be an object keyed by entrypoint name");return}for(const[n,i]of Object.entries(t)){if(typeof i!="object"||i===null){s.push(`exports["${n}"] must be an object`);continue}i.type!==void 0&&typeof i.type!="string"&&s.push(`exports["${n}"].type must be a string`),i.cache!==void 0&&(typeof i.cache!="object"||i.cache===null||Array.isArray(i.cache)?s.push(`exports["${n}"].cache must be an object`):i.cache.enabled!==void 0&&typeof i.cache.enabled!="boolean"&&s.push(`exports["${n}"].cache.enabled must be a boolean`))}}},de=(e,s)=>{const{assets:t}=e;if(t!==void 0){if(typeof t!="object"||Array.isArray(t)){s.push('assets must be an object (e.g. { "directory": "./dist/client", "binding": "ASSETS" })');return}(typeof t.directory!="string"||t.directory.length===0)&&s.push('assets must declare a non-empty "directory" pointing at the built client output (e.g. "./dist/client")'),t.binding!==void 0&&(typeof t.binding!="string"||t.binding.length===0)&&s.push('assets.binding must be a non-empty string (e.g. "ASSETS")'),t.html_handling!==void 0&&typeof t.html_handling!="string"&&s.push("assets.html_handling must be a string"),t.not_found_handling!==void 0&&typeof t.not_found_handling!="string"&&s.push("assets.not_found_handling must be a string")}},le=(e,s)=>{const t=e.tail_consumers;if(t===void 0)return;if(!Array.isArray(t)){s.push("tail_consumers must be an array of { service, environment? } entries");return}const n=t;for(const[i,a]of n.entries())(!a||typeof a!="object"||typeof a.service!="string"||a.service.length===0)&&s.push(`tail_consumers[${String(i)}] must have a non-empty "service" naming the consumer Worker`)},Te=(e,s)=>{const t=e.tail_consumers??[];return t.some(i=>!!i&&i?.service===s.service&&i?.environment===s.environment)?e:{...e,tail_consumers:[...t,s]}},me=(e,s)=>{const{vars:t}=e;if(!t||typeof t!="object")return;const n=t.LUNORA_ALLOWED_ORIGINS,i=t.LUNORA_CORS_ALLOW_CREDENTIALS,a=typeof n=="string"&&n.split(",").some(r=>r.trim()==="*"),o=T(i);a&&o&&s.push('vars.LUNORA_ALLOWED_ORIGINS includes a "*" wildcard while vars.LUNORA_CORS_ALLOW_CREDENTIALS is on — browsers reject this combination and it defeats the allowlist; name explicit origins or drop credentials')},ue=(e,s,t)=>{const{error:n,merged:i,unverifiedKeys:a}=R(e,s);return n!==void 0?{error:n,wrangler:i}:(a.length>0&&t.push(`env.${String(s)} overrides ${a.join(", ")}, which this validator doesn't have a verified inheritance rule for — validated against the TOP-LEVEL value only. Double-check ${a.length===1?"it":"them"} by hand for "${String(s)}".`),{wrangler:i})},M=(e,s,t)=>{const n=[],i=[];if(!e||typeof e!="object")return n.push("wrangler config is not a valid object"),{errors:n,valid:!1,warnings:i};const{error:a,wrangler:o}=ue(e,t,i);if(a!==void 0)return n.push(a),{errors:n,valid:!1,warnings:i};b(o.durable_objects?.bindings).find(d=>d.name==="SHARD"&&d.class_name==="ShardDO")||n.push('durable_objects.bindings must include { "name": "SHARD", "class_name": "ShardDO" } — your dev server auto-reconciles this on startup, or add the binding manually'),K(o,n);const c=o.compatibility_date??"";c&&!E.test(c)?n.push(`compatibility_date must be in YYYY-MM-DD format (got "${c}")`):c<v&&n.push(`compatibility_date must be >= "${v}" (got "${c||"<missing>"}")`),N(o)&&E.test(c)&&c<_&&n.push(`cache.enabled requires compatibility_date >= "${_}" (got "${c||"<missing>"}")`),s?.hasGlobalTable&&(b(o.d1_databases).find(w=>w.binding==="DB")||n.push('schema declares .global() tables; d1_databases must include a binding named "DB" — your dev server auto-reconciles this on startup, or add the binding manually')),ne(o,n),B(o,s?.vectorIndexNames??[],n),le(o,n),G(o,n,i),g(o.workflows,"workflows",Y,n),V(o,n),g(o.secrets_store_secrets,"secrets_store_secrets",z,n);for(const d of X)J(o,d,n,i);for(const d of se)g(o[d.key],d.key,d,n);for(const d of Z)ee(o,d,n);return te(o,n,i),ie(o,n),ae(o,n),oe(o,n),de(o,n),re(o,n),ce(o,n),me(o,n),{errors:n,valid:n.length===0,warnings:i}},Be=M,be=(e,s,t)=>{const n=[];for(const i of e){const a=i?.image;typeof a!="string"||!(a.startsWith("./")||a.startsWith("../")||a.startsWith("/")||a.includes("Dockerfile"))||f(a.startsWith("/")?a:p(s,a))||n.push(`containers image "${a}" does not exist (resolved relative to ${t}); create the Dockerfile or point image at a registry reference`)}return n},ge=(e,s,t)=>{if(typeof e=="string"&&e.length>0){const n=p(j(t),e);return f(n)?n:void 0}return D.map(n=>p(s,n)).find(n=>f(n))},fe=/\/\/[^\n]*|\/\*.*?\*\/|"[^"\n]*"|'[^'\n]*'|`[^`]*`/gsu,pe=e=>e.replaceAll(fe,s=>s.replaceAll(/[^\n]/gu," ")),he=/\bexport\s*\*\s*(?:as\s+\w+\s*)?from\b/u,ye=/\bexport\b/gu,_e=/^\s*(?:(?:abstract|async|declare|default)\s+)*/u,ve=/^(?:class|const|function|let|var)\s+(?<name>[$A-Z_a-z][\w$]*)/u,Ee=/^\s*(?:const|let|var)\s*\{/u,$e=/^[$A-Z_a-z][\w$]*/u,Se=/^type\b/u,Ae=/\s+/u,je=e=>{const s=[];for(const t of e.split(",")){const n=t.trim().split(Ae).filter(Boolean),i=n.at(-1);i!==void 0&&n[0]!=="type"&&s.push(i)}return s},Re=e=>{const s=[];for(const t of e.split(",")){const n=t.includes(":")?t.slice(t.indexOf(":")+1):t,i=$e.exec(n.trim());i&&s.push(i[0])}return s},A=e=>{const s=e.indexOf("{"),t=e.indexOf("}",s);return s===-1||t===-1?void 0:e.slice(s+1,t)},ke=e=>{const s=e.trimStart();if(Se.test(s))return[];if(s.startsWith("{")){const n=A(s);return n===void 0?[]:je(n)}if(Ee.test(e)){const n=A(e);return n===void 0?[]:Re(n)}const t=ve.exec(e.replace(_e,""));return t?.groups?.name===void 0?[]:[t.groups.name]},Me=e=>{const s=new Set;for(const t of e.matchAll(ye))for(const n of ke(e.slice(t.index+6)))s.add(n);return s},we=(e,s,t)=>{const n=ge(e.main,s,t);if(n===void 0)return[];let i;try{i=O(n,"utf8")}catch{return[]}const a=pe(i);if(he.test(a))return[];const o=[];for(const c of b(e.durable_objects?.bindings))typeof c.class_name=="string"&&c.class_name.length>0&&c.script_name===void 0&&o.push({className:c.class_name,label:"durable_objects.bindings"});for(const c of e.workflows??[])typeof c?.class_name=="string"&&c.class_name.length>0&&c.script_name===void 0&&o.push({className:c.class_name,label:"workflows"});const r=Me(a);return o.filter(c=>!r.has(c.className)).map(c=>`${c.label} declares class "${c.className}" but the worker entry (${n}) does not export it — wrangler refuses to bundle a Worker whose Durable Object classes are not exported. Add \`export { ${c.className} } from "…";\` to the entry.`)},We=e=>{const s=e.schemaDir??"lunora",t=I(e.projectRoot);if(!t){const u=`wrangler.jsonc not found in ${e.projectRoot}; create one declaring at least the SHARD durable object binding.`;return{problems:[u],report:{errors:[u],valid:!1,warnings:[]},wranglerPath:void 0}}const{parsed:n}=L(t);if(n===void 0){const u=`failed to parse ${t} as JSONC.`;return{problems:[u],report:{errors:[u],valid:!1,warnings:[]},wranglerPath:t}}const{error:i,merged:a}=R(n,e.environment);if(i!==void 0)return{problems:[i],report:{errors:[i],valid:!1,warnings:[]},wranglerPath:t};const{error:o,info:r}=x(e.projectRoot,s),l=M(n,r,e.environment);o!==void 0&&l.warnings.push(`schema parse failed in ${s}/schema.ts: ${o}`);const c=j(t);l.errors.push(...be(a.containers??[],c,t)),l.warnings.push(...we(a,e.projectRoot,t));const d=a.assets?.directory;if(typeof d=="string"&&d.length>0){const u=d.startsWith("/")?d:p(c,d);f(u)||l.warnings.push(`assets.directory "${d}" does not exist yet — it is created by the client build; run the build before deploy`)}return l.valid=l.errors.length===0,{problems:l.errors,report:l,wranglerPath:t}};export{v as REQUIRED_COMPATIBILITY_DATE,Ce as REQUIRED_FLAG,Be as validateWrangler,M as validateWranglerConfig,We as validateWranglerProject,Te as withTailConsumer};
@@ -1 +0,0 @@
1
- import{inferLunoraBindings as c}from"./inferLunoraBindings-7kPfAt6p.mjs";import{reconcileWranglerBindings as p}from"./collectExportGaps-DHLZ7ulq.mjs";import{reconcileWranglerCompatibilityDate as g}from"./reconcileWranglerCompatibilityDate-7OO_xaKR.mjs";import{reconcileWranglerCrons as m}from"./reconcileWranglerCrons-COMb6ICf.mjs";const l=(n,r)=>{const e=n.durableObjects.map(o=>({className:o.className,exported:!0,name:o.binding})),a=n.queues.map(o=>({name:o.name})),i=n.workflows.map(o=>({exported:o.exported,name:o.exportName}));return{containers:n.containers.map(o=>({exported:o.exported,name:o.exportName})),crons:[...r],globalDatabase:n.needsD1,keyValueStore:n.usesKv,objectStorage:n.usesStorage,queues:a,shardNamespaces:e,signals:[...n.signals],workflows:i}},s=(n,r)=>{try{const e=r();return{added:e.added??[],changed:e.changed,configPath:e.wranglerPath,warnings:e.warnings??[]}}catch(e){const a=e instanceof Error?e.message:String(e);return{added:[],changed:!1,warnings:[`${n} skipped: ${a}`]}}},f={deploy:n=>{const r=n.preview===!0?["versions","upload"]:["deploy"];return n.entry!==void 0&&r.push(n.entry),n.environment!==void 0&&r.push("--env",n.environment),n.temporary===!0&&r.push("--temporary"),n.dryRun===!0&&r.push("--dry-run"),n.outDir!==void 0&&r.push("--outdir",n.outDir,"--metafile"),{args:r,tool:"wrangler"}},dev:n=>{const r=["dev"];return n.configPath!==void 0&&r.push("--config",n.configPath),n.environment!==void 0&&r.push("--env",n.environment),r.push(...n.extraArgs??[]),{args:r,tool:"wrangler"}},secretList:n=>{const r=["secret","list","--format","json"];return n.environment!==void 0&&r.push("--env",n.environment),n.temporary===!0&&r.push("--temporary"),{args:r,tool:"wrangler"}},secretPut:n=>{const r=["secret","put",n.key??""];return n.environment!==void 0&&r.push("--env",n.environment),n.temporary===!0&&r.push("--temporary"),{args:r,tool:"wrangler"}},tail:n=>{const r=["tail"];return n.worker!==void 0&&r.push(n.worker),n.environment!==void 0&&r.push("--env",n.environment),n.format!==void 0&&r.push("--format",n.format),n.status!==void 0&&r.push("--status",n.status),n.search!==void 0&&r.push("--search",n.search),n.temporary===!0&&r.push("--temporary"),{args:r,tool:"wrangler"}}},w={id:"cloudflare",infer:async n=>{const r=await c({projectRoot:n.projectRoot});return l(r,n.crons??[])},name:"Cloudflare",provision:async n=>{const r=n.crons??[],e=await(async()=>{try{const o=await c({projectRoot:n.projectRoot});return s("binding inference",()=>p(n.projectRoot,o))}catch(o){const d=o instanceof Error?o.message:String(o);return{added:[],changed:!1,warnings:[`binding inference skipped: ${d}`]}}})(),a=s("compatibility date sync",()=>g(n.projectRoot)),i=s("cron trigger sync",()=>m(n.projectRoot,r)),t=[e,{...a,added:a.changed?["compatibility_date"]:[]},{...i,added:i.changed?[`${String(r.length)} cron trigger(s)`]:[]}];return{added:t.flatMap(o=>o.added),changed:t.some(o=>o.changed),configPath:t.find(o=>o.configPath!==void 0)?.configPath,warnings:t.flatMap(o=>o.warnings)}},toolchain:f};export{w as C,l as t};
@@ -1 +0,0 @@
1
- import{writeFileSync as k,readFileSync as N}from"node:fs";import{join as D}from"node:path";import{containerBuildTag as B}from"@lunora/container";import{DEV_VARS_FILE as A,parseDevVariableEntries as C}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{a as b}from"./jsonc-edit-BZgQIdAH.mjs";import{findWranglerFile as O,readWranglerJsonc as P}from"./WRANGLER_FILES-UNW-xY5u.mjs";const S="<replace-with-d1-create-id>",R=e=>[["container","containers",e.containers],["workflow","workflows",e.workflows],["agent","agents",e.agents]].flatMap(([s,a,o])=>o.filter(i=>!i.exported).map(({className:i,exportName:c})=>({className:i,exportName:c,kind:s,module:a}))),$=(e,n)=>{const s=e.flagshipBinding!==void 0&&!(n?.flagship??[]).some(o=>o.binding===e.flagshipBinding);return[[e.usesKv&&(n?.kv_namespaces?.length??0)===0,"@lunora/bindings/kv is used but no kv_namespaces binding exists; add a kv_namespaces entry ({ binding, id }) and pass env.<BINDING> to createKv() — the namespace id can't be auto-provisioned."],[e.usesHyperdrive&&(n?.hyperdrive?.length??0)===0,"@lunora/hyperdrive is used but no hyperdrive binding exists; run 'wrangler hyperdrive create' and add a 'hyperdrive' binding ({ binding, id }) — the id can't be auto-provisioned."],[e.usesPipelines&&(n?.pipelines?.length??0)===0,"ctx.pipelines is used but no pipelines binding exists; run 'wrangler pipelines create <name>' and add a 'pipelines' binding ({ binding, pipeline }) — the pipeline resource can't be auto-provisioned."],[s,`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(([o])=>o).map(([,o])=>o)},I=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.usesX402Pay,"@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),_=(e,n,s)=>s.filter(a=>!a.exported).map(a=>`${e} "${a.exportName}" is declared but ${a.className} is not exported by the worker entry; add \`export * from "./lunora/_generated/${n}"\` so its binding can be provisioned.`),E=[{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"}],T=()=>E.map(({keys:e,label:n})=>`${e[0]} + ${e[1]} (${n})`).join(" or "),M=e=>{let n;try{n=N(D(e,A),"utf8")}catch{return!1}const s=new Map(C(n).map(a=>[a.key,a.value]));return E.some(({keys:a})=>a.every(o=>(s.get(o)??"")!==""))},f=(e,n,s)=>{const a=new Set(e.durableObjects.map(d=>d.className)),o=[],i=(s?.r2_buckets?.length??0)>0,c=(s?.d1_databases?.some(d=>d.binding==="DB")??!1)||e.needsD1;return e.usesStorage&&!i&&o.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&&!a.has("SessionDO")&&!c&&o.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&&!a.has("SchedulerDO")&&o.push("@lunora/scheduler is used but the worker entry exports no SchedulerDO; export it so the SCHEDULER binding can be provisioned."),o.push(..._("container","containers",e.containers),..._("workflow","workflows",e.workflows),..._("agent","agents",e.agents)),e.containers.length>0&&s?.observability?.enabled===!1&&o.push("containers are declared but observability is explicitly disabled in wrangler.jsonc — container logs will not be captured."),e.usesPayment&&!M(n)&&o.push(`@lunora/payment is used; set one provider's secret pair in .dev.vars — ${T()}.`),o.push(...I(e),...$(e,s)),o},W=e=>{const n=new Set(e.map(a=>a.tag));let s=1;for(;n.has(`v${String(s)}`);)s+=1;return`v${String(s)}`},K=(e,n,s)=>{const a=n.durable_objects?.bindings??[],o=new Set(a.map(u=>u.name)),i=s.filter(u=>!o.has(u.binding));let c=e;const d=[];if(i.length>0){const u=[...a,...i.map(p=>({class_name:p.className,name:p.binding}))];c=b(c,["durable_objects","bindings"],u),d.push(...i.map(p=>`${p.binding}/${p.className}`))}const g=n.migrations??[],l=new Set(g.flatMap(u=>[...u.new_sqlite_classes??[],...u.new_classes??[]])),h=s.map(u=>u.className).filter(u=>!l.has(u));if(h.length>0){const u=[...g,{new_sqlite_classes:h,tag:W(g)}];c=b(c,["migrations"],u)}return{added:d,text:c}},L=(e,n)=>{const s=n.d1_databases??[];if(s.some(i=>i.binding==="DB"))return{added:[],text:e};const a=typeof n.name=="string"&&n.name.length>0?n.name:"lunora",o=[...s,{binding:"DB",database_id:S,database_name:a}];return{added:["DB (D1)"],text:b(e,["d1_databases"],o)}},x=(e,n,s,a,o)=>{const i=n[s]?.binding;return typeof i=="string"&&i.length>0?{added:[],text:e}:{added:[o],text:b(e,[s],{binding:a})}},Y=(e,n)=>(n.analytics_engine_datasets?.length??0)>0?{added:[],text:e}:{added:["ANALYTICS (Analytics Engine)"],text:b(e,["analytics_engine_datasets"],[{binding:"ANALYTICS",dataset:"ANALYTICS"}])},H=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},F=e=>e.image.kind==="dockerfile"?e.image.dockerfilePath:e.image.kind==="registry"?e.image.reference:B(e.exportName),j=e=>{const n={class_name:e.className,image:F(e)};return e.image.kind==="dockerfile"&&(n.image_build_context=e.image.buildContext),e.buildArgs!==void 0&&e.image.kind!=="registry"&&(n.image_vars=e.buildArgs),e.instanceType!==void 0&&(n.instance_type=H(e.instanceType)),e.maxInstances!==void 0&&(n.max_instances=e.maxInstances),e.name!==void 0&&(n.name=e.name),e.rollout?.stepPercentage!==void 0&&(n.rollout_step_percentage=e.rollout.stepPercentage),e.rollout?.gracePeriodSeconds!==void 0&&(n.rollout_active_grace_period=e.rollout.gracePeriodSeconds),n},G=(e,n,s)=>{const a=n.containers??[],o=new Set(a.map(d=>d.class_name)),i=s.filter(d=>!o.has(d.className));if(i.length===0)return{added:[],text:e};const c=b(e,["containers"],[...a,...i.map(d=>j(d))]);return{added:i.map(d=>`containers/${d.className}`),text:c}},U=(e,n)=>{if(n.observability!==void 0)return{added:[],text:e};const s=b(e,["observability"],{enabled:!0,head_sampling_rate:1});return{added:["observability"],text:s}},w=e=>({binding:e.bindingName,class_name:e.className,name:e.name}),V=(e,n,s,a=[])=>{const o=n.workflows??[],i=new Set(o.map(l=>l.class_name)),c=s.filter(l=>!i.has(l.className)),d=a.filter(l=>!i.has(l.className));if(c.length===0&&d.length===0)return{added:[],text:e};const g=b(e,["workflows"],[...o,...c.map(l=>w(l)),...d.map(l=>w(l))]);return{added:[...c.map(l=>`workflows/${l.className}`),...d.map(l=>`workflows/${l.className}`)],text:g}},z=(e,n,s)=>{const a=n.queues??{},o=a.producers??[],i=a.consumers??[],c=new Set(o.map(r=>r.binding)),d=new Set(i.map(r=>r.queue)),g=s.filter(r=>!c.has(r.bindingName)),l=s.filter(r=>!d.has(r.name));if(g.length===0&&l.length===0)return{added:[],text:e};const h=[...o,...g.map(r=>({binding:r.bindingName,queue:r.name}))],u=[...i,...l.map(r=>{const m={queue:r.name};return r.mode==="pull"&&(m.type="http_pull"),r.tuning.maxBatchSize!==void 0&&(m.max_batch_size=r.tuning.maxBatchSize),r.tuning.maxBatchTimeout!==void 0&&(m.max_batch_timeout=r.tuning.maxBatchTimeout),r.tuning.maxRetries!==void 0&&(m.max_retries=r.tuning.maxRetries),r.tuning.deadLetterQueue!==void 0&&(m.dead_letter_queue=r.tuning.deadLetterQueue),r.tuning.retryDelay!==void 0&&(m.retry_delay=r.tuning.retryDelay),m})],p=b(e,["queues"],{consumers:u,producers:h});return{added:[...g.map(r=>`queues.producers/${r.bindingName}`),...l.map(r=>`queues.consumers/${r.name}`)],text:p}},ne=(e,n,s)=>{const a=O(e),o=R(n);if(!a)return{added:[],changed:!1,exportGaps:o,reason:"wrangler.jsonc not found",warnings:f(n,e)};const{parsed:i,text:c}=P(a);if(i===void 0)return{added:[],changed:!1,exportGaps:o,reason:`failed to parse ${a} as JSONC`,warnings:f(n,e),wranglerPath:a};const d=f(n,e,i);if(s!==void 0){const t=i.env?.[s]!==void 0;d.push(t?`auto-provisioned bindings are written to the top level of wrangler.jsonc only — "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 g=n.containers.filter(t=>t.exported),l=n.agents.filter(t=>t.exported&&t.voice===!0&&t.voiceBindingName!==void 0&&t.voiceClassName!==void 0),h=[...n.durableObjects,...g.map(t=>({binding:t.bindingName,className:t.className})),...l.map(t=>({binding:t.voiceBindingName,className:t.voiceClassName}))],u=n.workflows.filter(t=>t.exported),p=n.agents.filter(t=>t.exported),r=[{enabled:!0,run:t=>K(t,i,h)},{enabled:n.needsD1,run:t=>L(t,i)},{enabled:n.usesAi,run:t=>x(t,i,"ai","AI","AI (Workers AI)")},{enabled:n.usesBrowser,run:t=>x(t,i,"browser","BROWSER","BROWSER (Browser Rendering)")},{enabled:n.usesImages,run:t=>x(t,i,"images","IMAGES","IMAGES (Cloudflare Images)")},{enabled:n.usesAnalytics,run:t=>Y(t,i)},{enabled:!0,run:t=>U(t,i)},{enabled:g.length>0,run:t=>G(t,i,g)},{enabled:u.length>0||p.length>0,run:t=>V(t,i,u,p)},{enabled:n.queues.length>0,run:t=>z(t,i,n.queues)}];let m=c;const v=[];for(const t of r){if(!t.enabled)continue;const y=t.run(m);m=y.text,v.push(...y.added)}return v.includes("DB (D1)")&&d.push(`wrote a DB binding with a placeholder database_id ("${S}") — run \`wrangler d1 create <name>\` and replace it before deploying.`),m===c?{added:[],changed:!1,exportGaps:o,reason:"bindings already in sync",warnings:d,wranglerPath:a}:(k(a,m,"utf8"),{added:v,changed:!0,exportGaps:o,warnings:d,wranglerPath:a})};export{R as collectExportGaps,ne as reconcileWranglerBindings};
@@ -1 +0,0 @@
1
- import{existsSync as p,statSync as v,readFileSync as f,readdirSync as B}from"node:fs";import{init as k,parse as g}from"es-module-lexer";import{discoverAgentInfo as $}from"./discoverAgentInfo-CTdCSfYM.mjs";import{WRANGLER_FILES as F,readWranglerJsonc as Y}from"./WRANGLER_FILES-UNW-xY5u.mjs";import{discoverContainerInfo as j}from"./discoverContainerInfo-EhZtEBQs.mjs";import{escapeRegExp as T}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{discoverFlags as U,FLAGS_FILENAME as K,discoverQueues as W,QUEUES_FILENAME as M}from"@lunora/codegen";import{d as w}from"./discover-info-Vj9d4qYt.mjs";import{discoverSchemaInfo as X}from"./discoverSchemaInfo-Bg2CUZXG.mjs";import{discoverWorkflowInfo as G}from"./discoverWorkflowInfo-BsPvlo6O.mjs";import{join as c}from"node:path";const H=(e,s)=>{const{error:t,value:r}=w(e,s,K,U);return t===void 0?{flags:r}:{error:t}},V=(e,s)=>{const{error:t,value:r}=w(e,s,M,W);return t===void 0?{queues:r??[]}:{error:t,queues:[]}},q=new Set([".cjs",".cts",".js",".jsx",".mjs",".mts",".ts",".tsx"]),J=new Set([".git",".lunora-cache",".wrangler","_generated","dist","node_modules"]),Q=["lunora","src"],z=["src/server/index.ts","src/server/index.tsx","src/index.ts","src/worker.ts"],_={SchedulerDO:"SCHEDULER",SessionDO:"SESSION",ShardDO:"SHARD"},N=Object.keys(_),Z={SchedulerDO:/\btype\s+SchedulerDO\b/,SessionDO:/\btype\s+SessionDO\b/,ShardDO:/\btype\s+ShardDO\b/},ee=/\benv\s*\.\s*DB\b/,se=/\benv\s*\.\s*AI\b/,D=/\bctx\s*\.\s*pipelines\b/,C=/^\s*import\s+type\b/,re=new Set(["@lunora/agent","@lunora/agent/sandbox"]),te=e=>{const s=e.indexOf("{");if(s===-1)return"";const t=e.indexOf("}",s+1);return t===-1?e.slice(s+1):e.slice(s+1,t)},ne=/\btype\s+browserTool\b/,oe=/\bbrowserTool\b/,ae=/import\s+\{[^}]*\bbrowserTool\b[^}]*\}\s+from\s+["']@lunora\/agent(?:\/sandbox)?["']/,ie=e=>{if(C.test(e))return!1;const s=te(e);return oe.test(s)&&!ne.test(s)},ce=e=>{try{const[s]=g(e);return s.some(t=>t.n!==void 0&&re.has(t.n)&&ie(e.slice(t.ss,t.se)))}catch{return ae.test(e)}},h={usesAi:{pattern:/\bfrom\s+["']@lunora\/ai["']/,source:"@lunora/ai"},usesAnalytics:{pattern:/\bfrom\s+["']@lunora\/bindings\/analytics["']/,source:"@lunora/bindings/analytics"},usesAuth:{pattern:/\bfrom\s+["']@lunora\/auth["']/,source:"@lunora/auth"},usesBrowser:{pattern:/\bfrom\s+["']@lunora\/browser["']/,source:"@lunora/browser"},usesHyperdrive:{pattern:/\bfrom\s+["']@lunora\/hyperdrive["']/,source:"@lunora/hyperdrive"},usesImages:{pattern:/\bfrom\s+["']@lunora\/bindings\/images["']/,source:"@lunora/bindings/images"},usesKv:{pattern:/\bfrom\s+["']@lunora\/bindings\/kv["']/,source:"@lunora/bindings/kv"},usesMail:{pattern:/\bfrom\s+["']@lunora\/mail["']/,source:"@lunora/mail"},usesPayment:{pattern:/\bfrom\s+["']@lunora\/payment["']/,source:"@lunora/payment"},usesPipelines:{pattern:D,source:"@lunora/bindings/pipelines"},usesScheduler:{pattern:/\bfrom\s+["']@lunora\/scheduler["']/,source:"@lunora/scheduler"},usesStorage:{pattern:/\bfrom\s+["']@lunora\/storage["']/,source:"@lunora/storage"},usesX402Charge:{pattern:/\bfrom\s+["']@lunora\/x402\/charge["']/,source:"@lunora/x402/charge"},usesX402Pay:{pattern:/\bfrom\s+["']@lunora\/x402\/pay["']/,source:"@lunora/x402/pay"}},m=Object.keys(h),ue="STRIPE_SECRET_KEY + STRIPE_WEBHOOK_SECRET (Stripe) or POLAR_ACCESS_TOKEN + POLAR_WEBHOOK_SECRET (Polar)",P=[...m,"needsD1"],de=()=>{const e={};for(const s of P)e[s]=!1;return e},d=Object.freeze(de()),x=(e,s)=>{const t={};for(const r of P)t[r]=e[r]||s[r];return t},le=e=>{for(const s of m)if(h[s].source===e)return{...d,[s]:!0};return d},pe=e=>{const[s]=g(e);let t=d;for(const r of s){const n=r.n;!n||C.test(e.slice(r.ss,r.se))||(t=x(t,le(n)))}return t},me=e=>{const s={...d};for(const t of m)s[t]=h[t].pattern.test(e);return s},be=e=>{let s;try{s=pe(e)}catch{s=me(e)}return x(s,{...d,needsD1:ee.test(e),usesAi:se.test(e),usesPipelines:D.test(e)})},y=(e,s)=>{let t;try{t=B(e,{withFileTypes:!0})}catch{return}for(const r of t){if(r.isDirectory()){J.has(r.name)||y(c(e,r.name),s);continue}const n=r.name.lastIndexOf(".");n!==-1&&q.has(r.name.slice(n))&&s.push(c(e,r.name))}},fe="virtual:lunora/worker",ge=["ShardDO"],he=e=>{for(const s of F){const t=c(e,s);if(!p(t))continue;const{parsed:r}=Y(t),n=r?.main;if(n===fe)return{composed:!0};if(typeof n=="string"&&p(c(e,n)))return{composed:!1,path:c(e,n)};break}for(const s of z){const t=c(e,s);if(p(t))return{composed:!1,path:t}}return{composed:!1}},Ee=e=>{const s=f(e,"utf8");let t;try{const[,r]=g(s);t=new Set(r.map(n=>n.n))}catch{t=new Set(N.filter(r=>new RegExp(String.raw`\bexport\b[^\n;]*\b${r}\b`).test(s)))}return N.filter(r=>t.has(r)&&!Z[r].test(s)).map(r=>({binding:_[r],className:r}))},Se=/(?:^|[\s,{])type$/u,_e=(e,s)=>{const t=s.ls>=0?s.ls:s.s;return Se.test(e.slice(0,t).trimEnd())},xe=(e,s)=>{const t=T(s);return new RegExp(String.raw`\bexport\s+type\s+${t}\b`,"u").test(e)||new RegExp(String.raw`\bexport\s+type\s*\{[^}]*\b${t}\b`,"u").test(e)||new RegExp(String.raw`\bexport\s+\{[^}]*\btype\s+${t}\b`,"u").test(e)},S=(e,s,t)=>{if(s.length===0)return[];if(e.composed)return s.map(o=>({...o,exported:!0}));if(e.path===void 0)return s.map(o=>({...o,exported:!1}));const r=f(e.path,"utf8"),n=new RegExp(String.raw`\bexport\s*\*\s*from\s*["'][^"']*_generated\/${t}(?:\.js)?["']`).test(r);let a;try{const[,o]=g(r);a=new Set(o.filter(i=>!_e(r,i)).map(i=>i.n))}catch{a=new Set(s.map(o=>o.className).filter(o=>new RegExp(String.raw`\bexport\b[^\n;]*\b${T(o)}\b`,"u").test(r)&&!xe(r,o)))}return s.map(o=>{const i=n||a.has(o.className);return{...o,exported:i}})},ye=(e,s)=>X(e,s).info?.hasGlobalTable??!1,Re=(e,s)=>{let t=d;for(const r of s){const n=c(e,r);if(!p(n)||!v(n).isDirectory())continue;const a=[];y(n,a);for(const o of a)t=x(t,be(f(o,"utf8")))}return t},Oe=(e,s)=>{const t=c(e,s);if(!p(t)||!v(t).isDirectory())return!1;const r=[];return y(t,r),r.some(n=>ce(f(n,"utf8")))},Ie=(e,s,t)=>[...e.map(r=>r.exported?`${r.bindingName}/${r.className} (container "${r.exportName}" declared and exported)`:`hint: container "${r.exportName}" is declared but ${r.className} is not exported by the worker entry — add \`export * from "./lunora/_generated/containers"\``),...s.map(r=>r.exported?`${r.bindingName}/${r.className} (workflow "${r.exportName}" declared and exported)`:`hint: workflow "${r.exportName}" is declared but ${r.className} is not exported by the worker entry — add \`export * from "./lunora/_generated/workflows"\``),...t.map(r=>r.exported?`${r.bindingName}/${r.className} (agent "${r.exportName}" declared and exported)`:`hint: agent "${r.exportName}" is declared but ${r.className} is not exported by the worker entry — add \`export * from "./lunora/_generated/agents"\``)],Ae=(e,s)=>[[e.usesAi,"AI (@lunora/ai imported or env.AI 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: @lunora/scheduler is imported but no SchedulerDO is exported by the worker entry"],[e.usesStorage,"hint: @lunora/storage is imported; add an r2_buckets binding (bucket binding names are user-defined)"],[e.usesMail,"hint: @lunora/mail is imported; set RESEND_API_KEY in .dev.vars (obtain at https://resend.com/api-keys)"],[e.usesPayment,`hint: @lunora/payment is imported; set the provider secrets in .dev.vars — ${ue}`],[e.usesBrowser,"browser (@lunora/browser imported) — self-describing { binding: BROWSER }"],[e.usesImages,"images (@lunora/bindings/images imported) — self-describing { binding: IMAGES }"],[e.usesAnalytics,"analytics_engine_datasets (@lunora/bindings/analytics imported) — self-describing { binding: ANALYTICS, dataset }"],[e.usesKv,"hint: @lunora/bindings/kv is imported; add a kv_namespaces binding ({ binding, id }) and pass env.<BINDING> to createKv() — the namespace id can't be auto-provisioned"],[e.usesHyperdrive,"hint: @lunora/hyperdrive is imported; run 'wrangler hyperdrive create' and add a 'hyperdrive' binding ({ binding, id }) — the id can't be auto-provisioned"],[e.usesPipelines,"hint: ctx.pipelines is used; run 'wrangler pipelines create <name>' and add a 'pipelines' binding ({ binding, pipeline }) — the pipeline resource can't be auto-provisioned"],[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.usesX402Pay,"hint: @lunora/x402/pay is imported (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(([r])=>r).map(([,r])=>r),Ne=(e,s,t,r=[],n=[],a=[])=>{const o=new Set(e.map(u=>u.className)),i=e.map(u=>`${u.binding}/${u.className} (exported by worker entry)`);return s&&i.push("DB (.global() table declared)"),i.push(...Ie(r,n,a),...Ae(t,o)),i},Ye=async e=>{await k;const s=e.schemaDir??"lunora",t=e.scanDirs??Q,r=Re(e.projectRoot,t),n={...r,usesBrowser:r.usesBrowser||Oe(e.projectRoot,s)},a=he(e.projectRoot);let o;a.composed?o=ge.map(l=>({binding:_[l],className:l})):o=a.path===void 0?[]:Ee(a.path);const i=n.needsD1||ye(e.projectRoot,s),u=S(a,j(e.projectRoot,s).containers,"containers"),R=S(a,G(e.projectRoot,s).workflows,"workflows"),O=S(a,$(e.projectRoot,s).agents,"agents"),L=[...V(e.projectRoot,s).queues],{flags:b}=H(e.projectRoot,s),E=b?.provider==="flagship"&&b.mode==="binding"?b.bindingName:void 0,I={};for(const l of m)I[l]=n[l];const A=Ne(o,i,n,u,R,O);return E!==void 0&&A.push(`hint: lunora/flags.ts uses Flagship in binding mode; add a flagship binding ({ binding: "${E}", app_id }) — the app_id can't be auto-provisioned`),{agents:O,containers:u,durableObjects:o,flagshipBinding:E,needsD1:i,queues:L,signals:A,usesFlags:b!==void 0,workflows:R,...I}},je=e=>{const s=[];for(const t of m)e[t]&&s.push(h[t].source);return s};export{fe as LUNORA_WORKER_VIRTUAL_ID,z as WORKER_ENTRY_FALLBACKS,Ye as inferLunoraBindings,_e as isTypeOnlyExportEntry,je as packageNamesFromBindings,he as resolveWorkerEntry};