@lunora/config 1.0.0-alpha.97 → 1.0.0-alpha.99

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.
package/dist/index.d.mts CHANGED
@@ -1496,6 +1496,7 @@ interface WranglerConfig {
1496
1496
  pipelines?: ReadonlyArray<{
1497
1497
  binding?: string;
1498
1498
  pipeline?: string;
1499
+ stream?: string;
1499
1500
  } | null | undefined>;
1500
1501
  placement?: {
1501
1502
  mode?: string;
package/dist/index.d.ts CHANGED
@@ -1496,6 +1496,7 @@ interface WranglerConfig {
1496
1496
  pipelines?: ReadonlyArray<{
1497
1497
  binding?: string;
1498
1498
  pipeline?: string;
1499
+ stream?: string;
1499
1500
  } | null | undefined>;
1500
1501
  placement?: {
1501
1502
  mode?: string;
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{AGENT_MODE_ENV as o,detectAiAgent as t}from"./packem_shared/AGENT_MODE_ENV-B54hVQ_w.mjs";import{discoverAgentInfo as E}from"./packem_shared/discoverAgentInfo-BJm0QtoI.mjs";import{AGENT_RULES_DIR as n,AGENT_RULES_HINT as l,AGENT_RULES_HINT_ENV as _,LUNORA_SKILL_NAMES as c,ROOT_SKILL_NAME as s,claimAgentRulesHint as m,detectAgentRules as p}from"./packem_shared/AGENT_RULES_DIR-hP9TiDNx.mjs";import{discoverContainerInfo as d}from"./packem_shared/discoverContainerInfo-CYG9j2LY.mjs";import{streamContainerLogs as A}from"./packem_shared/streamContainerLogs-BPYBNrWS.mjs";import{detectFramework as L,readProjectDependencyNames as D}from"./packem_shared/detectFramework-VTQfCNXy.mjs";import{DEV_DAEMON_ENV as I,DEV_HANDOFF_ENV as v,DEV_LOG_FILE as g,DEV_LOG_FILE_ENV as x,DEV_STATE_DIR as T,DEV_STATE_FILE as V,claimDevServerState as C,clearDevServerState as F,isProcessAlive as P,isRecordedProcessCurrent as O,readDevServerState as u,readLiveDevServerState as G,updateDevServerState as W,writeDevServerState as U}from"./packem_shared/DEV_DAEMON_ENV-D9Z83rlU.mjs";import{DEV_VARS_EXAMPLE_FILE as B,DEV_VARS_FILE as M,DEV_VARS_KEY_PATTERN as K,parseDevVariableEntries as k}from"./packem_shared/DEV_VARS_EXAMPLE_FILE-DX6xGbpr.mjs";import{inferLunoraBindings as w,packageNamesFromBindings as h}from"./packem_shared/inferLunoraBindings-B2y-19KL.mjs";import{LINKED_PROJECT_DIR as H,LINKED_PROJECT_FILE as Y,readLinkedProject as J,writeLinkedProject as Q}from"./packem_shared/LINKED_PROJECT_DIR-CMzUvj-1.mjs";import{LUNORA_EVENT_SOURCE as z,formatLunoraEvent as X}from"./packem_shared/LUNORA_EVENT_SOURCE-ZclWASXS.mjs";import{default as $}from"./packem_shared/LunoraReporter-BnXUqh8t.mjs";import{PACKAGE_SECRETS_REGISTRY as re,secretsForPackages as oe}from"./packem_shared/PACKAGE_SECRETS_REGISTRY-BgmvEPA-.mjs";import{LUNORA_CONFIG_FILE as ae,interpretRemote as Ee,readProjectRemotePreference as ie}from"./packem_shared/LUNORA_CONFIG_FILE-3bpx6TZN.mjs";import{createConfirm as le,isInteractive as _e,promptMultiSelect as ce,promptSelect as se,promptText as me,promptYesNo as pe}from"./packem_shared/createConfirm-7IL0kZyE.mjs";import{reconcileWranglerBindings as de}from"./packem_shared/reconcileWranglerBindings-Dd3tLauZ.mjs";import{reconcileWranglerCompatibilityDate as Ae}from"./packem_shared/reconcileWranglerCompatibilityDate-BXNiEQ7p.mjs";import{reconcileWranglerCrons as Le}from"./packem_shared/reconcileWranglerCrons-BmQa_kGL.mjs";import{REMOTE_ELIGIBLE_KEYS as Ne,injectRemoteFlags as Ie,isRemoteEnvEnabled as ve,materializeRemoteWranglerConfig as ge,planRemoteBindings as xe,resolveRemoteEnabled as Te}from"./packem_shared/REMOTE_ELIGIBLE_KEYS-ws6iE0y-.mjs";import{buildPackageSecretsBlock as Ce,ensureDevVariables as Fe,ensureDevVarsExample as Pe,fillDevSecrets as Oe,generateSecretValue as ue,isMintableSecretKey as Ge,isPlaceholderValue as We,planDevSecretsFill as Ue,planDevVariablesAugment as be,planDevVariablesScaffold as Be,requiredSecrets as Me}from"./packem_shared/buildPackageSecretsBlock-BpvaZzQ8.mjs";import{applyAdditiveEdit as ke,classifyEdit as ye}from"./packem_shared/applyAdditiveEdit-BdcnSa-j.mjs";import{parseSchema as he}from"./packem_shared/parseSchema-BPmtMgmb.mjs";import{classifyPolicyEdit as He,scaffoldPolicyFile as Ye,wireRlsIntoProcedure as Je}from"./packem_shared/classifyPolicyEdit-BzC_MfYK.mjs";import{discoverSchemaInfo as qe}from"./packem_shared/discoverSchemaInfo-C8X9mo-i.mjs";import{ACCENT as Xe,BADGES as Ze,BADGE_COLUMN_WIDTH as $e,LUNA_ART as er,LUNA_BUNNY as rr,LUNA_NAME as or,LUNA_SIGNOFF as tr,STEP_BADGE_NAMES as ar,badgeLead as Er,badgeWidth as ir,padBadge as nr,paintAnswer as lr,paintBadge as _r}from"./packem_shared/ACCENT-CLeV5v0K.mjs";import{WORKERS_CACHE_MIN_DATE as sr,isCacheEnabled as mr}from"./packem_shared/WORKERS_CACHE_MIN_DATE-B1h_wNDN.mjs";import{discoverWorkflowInfo as fr}from"./packem_shared/discoverWorkflowInfo-Bbc0u2gE.mjs";import{WRANGLER_FILES as Sr,findWranglerFile as Ar,readWranglerJsonc as Rr}from"./packem_shared/WRANGLER_FILES-Bi_18Pj6.mjs";import{collectWranglerSecretVariables as Dr,scanWranglerVariablesForSecrets as Nr}from"./packem_shared/collectWranglerSecretVariables-OacEwPmL.mjs";import{REQUIRED_COMPATIBILITY_DATE as vr,REQUIRED_FLAG as gr,validateWrangler as xr,validateWranglerConfig as Tr,validateWranglerProject as Vr,withTailConsumer as Cr}from"./packem_shared/REQUIRED_COMPATIBILITY_DATE-C691-dEr.mjs";export{Xe as ACCENT,o as AGENT_MODE_ENV,n as AGENT_RULES_DIR,l as AGENT_RULES_HINT,_ as AGENT_RULES_HINT_ENV,Ze as BADGES,$e as BADGE_COLUMN_WIDTH,I as DEV_DAEMON_ENV,v as DEV_HANDOFF_ENV,g as DEV_LOG_FILE,x as DEV_LOG_FILE_ENV,T as DEV_STATE_DIR,V as DEV_STATE_FILE,B as DEV_VARS_EXAMPLE_FILE,M as DEV_VARS_FILE,K as DEV_VARS_KEY_PATTERN,H as LINKED_PROJECT_DIR,Y as LINKED_PROJECT_FILE,er as LUNA_ART,rr as LUNA_BUNNY,or as LUNA_NAME,tr as LUNA_SIGNOFF,ae as LUNORA_CONFIG_FILE,z as LUNORA_EVENT_SOURCE,c as LUNORA_SKILL_NAMES,$ as LunoraReporter,re as PACKAGE_SECRETS_REGISTRY,Ne as REMOTE_ELIGIBLE_KEYS,vr as REQUIRED_COMPATIBILITY_DATE,gr as REQUIRED_FLAG,s as ROOT_SKILL_NAME,ar as STEP_BADGE_NAMES,sr as WORKERS_CACHE_MIN_DATE,Sr as WRANGLER_FILES,ke as applyAdditiveEdit,Er as badgeLead,ir as badgeWidth,Ce as buildPackageSecretsBlock,m as claimAgentRulesHint,C as claimDevServerState,ye as classifyEdit,He as classifyPolicyEdit,F as clearDevServerState,Dr as collectWranglerSecretVariables,le as createConfirm,p as detectAgentRules,t as detectAiAgent,L as detectFramework,E as discoverAgentInfo,d as discoverContainerInfo,qe as discoverSchemaInfo,fr as discoverWorkflowInfo,Fe as ensureDevVariables,Pe as ensureDevVarsExample,Oe as fillDevSecrets,Ar as findWranglerFile,X as formatLunoraEvent,ue as generateSecretValue,w as inferLunoraBindings,Ie as injectRemoteFlags,Ee as interpretRemote,mr as isCacheEnabled,_e as isInteractive,Ge as isMintableSecretKey,We as isPlaceholderValue,P as isProcessAlive,O as isRecordedProcessCurrent,ve as isRemoteEnvEnabled,ge as materializeRemoteWranglerConfig,h as packageNamesFromBindings,nr as padBadge,lr as paintAnswer,_r as paintBadge,k as parseDevVariableEntries,he as parseSchema,Ue as planDevSecretsFill,be as planDevVariablesAugment,Be as planDevVariablesScaffold,xe as planRemoteBindings,ce as promptMultiSelect,se as promptSelect,me as promptText,pe as promptYesNo,u as readDevServerState,J as readLinkedProject,G as readLiveDevServerState,D as readProjectDependencyNames,ie as readProjectRemotePreference,Rr as readWranglerJsonc,de as reconcileWranglerBindings,Ae as reconcileWranglerCompatibilityDate,Le as reconcileWranglerCrons,Me as requiredSecrets,Te as resolveRemoteEnabled,Ye as scaffoldPolicyFile,Nr as scanWranglerVariablesForSecrets,oe as secretsForPackages,A as streamContainerLogs,W as updateDevServerState,xr as validateWrangler,Tr as validateWranglerConfig,Vr as validateWranglerProject,Je as wireRlsIntoProcedure,Cr as withTailConsumer,U as writeDevServerState,Q as writeLinkedProject};
1
+ import{AGENT_MODE_ENV as o,detectAiAgent as t}from"./packem_shared/AGENT_MODE_ENV-B54hVQ_w.mjs";import{discoverAgentInfo as E}from"./packem_shared/discoverAgentInfo-BJm0QtoI.mjs";import{AGENT_RULES_DIR as n,AGENT_RULES_HINT as l,AGENT_RULES_HINT_ENV as _,LUNORA_SKILL_NAMES as c,ROOT_SKILL_NAME as s,claimAgentRulesHint as m,detectAgentRules as p}from"./packem_shared/AGENT_RULES_DIR-hP9TiDNx.mjs";import{discoverContainerInfo as d}from"./packem_shared/discoverContainerInfo-CYG9j2LY.mjs";import{streamContainerLogs as A}from"./packem_shared/streamContainerLogs-BPYBNrWS.mjs";import{detectFramework as L,readProjectDependencyNames as D}from"./packem_shared/detectFramework-VTQfCNXy.mjs";import{DEV_DAEMON_ENV as I,DEV_HANDOFF_ENV as v,DEV_LOG_FILE as g,DEV_LOG_FILE_ENV as x,DEV_STATE_DIR as T,DEV_STATE_FILE as V,claimDevServerState as C,clearDevServerState as F,isProcessAlive as P,isRecordedProcessCurrent as O,readDevServerState as u,readLiveDevServerState as G,updateDevServerState as W,writeDevServerState as U}from"./packem_shared/DEV_DAEMON_ENV-D9Z83rlU.mjs";import{DEV_VARS_EXAMPLE_FILE as B,DEV_VARS_FILE as M,DEV_VARS_KEY_PATTERN as K,parseDevVariableEntries as k}from"./packem_shared/DEV_VARS_EXAMPLE_FILE-DX6xGbpr.mjs";import{inferLunoraBindings as w,packageNamesFromBindings as h}from"./packem_shared/inferLunoraBindings-B2y-19KL.mjs";import{LINKED_PROJECT_DIR as H,LINKED_PROJECT_FILE as Y,readLinkedProject as J,writeLinkedProject as Q}from"./packem_shared/LINKED_PROJECT_DIR-CMzUvj-1.mjs";import{LUNORA_EVENT_SOURCE as z,formatLunoraEvent as X}from"./packem_shared/LUNORA_EVENT_SOURCE-ZclWASXS.mjs";import{default as $}from"./packem_shared/LunoraReporter-BnXUqh8t.mjs";import{PACKAGE_SECRETS_REGISTRY as re,secretsForPackages as oe}from"./packem_shared/PACKAGE_SECRETS_REGISTRY-BgmvEPA-.mjs";import{LUNORA_CONFIG_FILE as ae,interpretRemote as Ee,readProjectRemotePreference as ie}from"./packem_shared/LUNORA_CONFIG_FILE-3bpx6TZN.mjs";import{createConfirm as le,isInteractive as _e,promptMultiSelect as ce,promptSelect as se,promptText as me,promptYesNo as pe}from"./packem_shared/createConfirm-7IL0kZyE.mjs";import{reconcileWranglerBindings as de}from"./packem_shared/reconcileWranglerBindings-CHFT6zqp.mjs";import{reconcileWranglerCompatibilityDate as Ae}from"./packem_shared/reconcileWranglerCompatibilityDate-BXNiEQ7p.mjs";import{reconcileWranglerCrons as Le}from"./packem_shared/reconcileWranglerCrons-BmQa_kGL.mjs";import{REMOTE_ELIGIBLE_KEYS as Ne,injectRemoteFlags as Ie,isRemoteEnvEnabled as ve,materializeRemoteWranglerConfig as ge,planRemoteBindings as xe,resolveRemoteEnabled as Te}from"./packem_shared/REMOTE_ELIGIBLE_KEYS-ws6iE0y-.mjs";import{buildPackageSecretsBlock as Ce,ensureDevVariables as Fe,ensureDevVarsExample as Pe,fillDevSecrets as Oe,generateSecretValue as ue,isMintableSecretKey as Ge,isPlaceholderValue as We,planDevSecretsFill as Ue,planDevVariablesAugment as be,planDevVariablesScaffold as Be,requiredSecrets as Me}from"./packem_shared/buildPackageSecretsBlock-BpvaZzQ8.mjs";import{applyAdditiveEdit as ke,classifyEdit as ye}from"./packem_shared/applyAdditiveEdit-BdcnSa-j.mjs";import{parseSchema as he}from"./packem_shared/parseSchema-BPmtMgmb.mjs";import{classifyPolicyEdit as He,scaffoldPolicyFile as Ye,wireRlsIntoProcedure as Je}from"./packem_shared/classifyPolicyEdit-BzC_MfYK.mjs";import{discoverSchemaInfo as qe}from"./packem_shared/discoverSchemaInfo-C8X9mo-i.mjs";import{ACCENT as Xe,BADGES as Ze,BADGE_COLUMN_WIDTH as $e,LUNA_ART as er,LUNA_BUNNY as rr,LUNA_NAME as or,LUNA_SIGNOFF as tr,STEP_BADGE_NAMES as ar,badgeLead as Er,badgeWidth as ir,padBadge as nr,paintAnswer as lr,paintBadge as _r}from"./packem_shared/ACCENT-CLeV5v0K.mjs";import{WORKERS_CACHE_MIN_DATE as sr,isCacheEnabled as mr}from"./packem_shared/WORKERS_CACHE_MIN_DATE-B1h_wNDN.mjs";import{discoverWorkflowInfo as fr}from"./packem_shared/discoverWorkflowInfo-Bbc0u2gE.mjs";import{WRANGLER_FILES as Sr,findWranglerFile as Ar,readWranglerJsonc as Rr}from"./packem_shared/WRANGLER_FILES-Bi_18Pj6.mjs";import{collectWranglerSecretVariables as Dr,scanWranglerVariablesForSecrets as Nr}from"./packem_shared/collectWranglerSecretVariables-OacEwPmL.mjs";import{REQUIRED_COMPATIBILITY_DATE as vr,REQUIRED_FLAG as gr,validateWrangler as xr,validateWranglerConfig as Tr,validateWranglerProject as Vr,withTailConsumer as Cr}from"./packem_shared/REQUIRED_COMPATIBILITY_DATE-XijSB4Zt.mjs";export{Xe as ACCENT,o as AGENT_MODE_ENV,n as AGENT_RULES_DIR,l as AGENT_RULES_HINT,_ as AGENT_RULES_HINT_ENV,Ze as BADGES,$e as BADGE_COLUMN_WIDTH,I as DEV_DAEMON_ENV,v as DEV_HANDOFF_ENV,g as DEV_LOG_FILE,x as DEV_LOG_FILE_ENV,T as DEV_STATE_DIR,V as DEV_STATE_FILE,B as DEV_VARS_EXAMPLE_FILE,M as DEV_VARS_FILE,K as DEV_VARS_KEY_PATTERN,H as LINKED_PROJECT_DIR,Y as LINKED_PROJECT_FILE,er as LUNA_ART,rr as LUNA_BUNNY,or as LUNA_NAME,tr as LUNA_SIGNOFF,ae as LUNORA_CONFIG_FILE,z as LUNORA_EVENT_SOURCE,c as LUNORA_SKILL_NAMES,$ as LunoraReporter,re as PACKAGE_SECRETS_REGISTRY,Ne as REMOTE_ELIGIBLE_KEYS,vr as REQUIRED_COMPATIBILITY_DATE,gr as REQUIRED_FLAG,s as ROOT_SKILL_NAME,ar as STEP_BADGE_NAMES,sr as WORKERS_CACHE_MIN_DATE,Sr as WRANGLER_FILES,ke as applyAdditiveEdit,Er as badgeLead,ir as badgeWidth,Ce as buildPackageSecretsBlock,m as claimAgentRulesHint,C as claimDevServerState,ye as classifyEdit,He as classifyPolicyEdit,F as clearDevServerState,Dr as collectWranglerSecretVariables,le as createConfirm,p as detectAgentRules,t as detectAiAgent,L as detectFramework,E as discoverAgentInfo,d as discoverContainerInfo,qe as discoverSchemaInfo,fr as discoverWorkflowInfo,Fe as ensureDevVariables,Pe as ensureDevVarsExample,Oe as fillDevSecrets,Ar as findWranglerFile,X as formatLunoraEvent,ue as generateSecretValue,w as inferLunoraBindings,Ie as injectRemoteFlags,Ee as interpretRemote,mr as isCacheEnabled,_e as isInteractive,Ge as isMintableSecretKey,We as isPlaceholderValue,P as isProcessAlive,O as isRecordedProcessCurrent,ve as isRemoteEnvEnabled,ge as materializeRemoteWranglerConfig,h as packageNamesFromBindings,nr as padBadge,lr as paintAnswer,_r as paintBadge,k as parseDevVariableEntries,he as parseSchema,Ue as planDevSecretsFill,be as planDevVariablesAugment,Be as planDevVariablesScaffold,xe as planRemoteBindings,ce as promptMultiSelect,se as promptSelect,me as promptText,pe as promptYesNo,u as readDevServerState,J as readLinkedProject,G as readLiveDevServerState,D as readProjectDependencyNames,ie as readProjectRemotePreference,Rr as readWranglerJsonc,de as reconcileWranglerBindings,Ae as reconcileWranglerCompatibilityDate,Le as reconcileWranglerCrons,Me as requiredSecrets,Te as resolveRemoteEnabled,Ye as scaffoldPolicyFile,Nr as scanWranglerVariablesForSecrets,oe as secretsForPackages,A as streamContainerLogs,W as updateDevServerState,xr as validateWrangler,Tr as validateWranglerConfig,Vr as validateWranglerProject,Je as wireRlsIntoProcedure,Cr as withTailConsumer,U as writeDevServerState,Q as writeLinkedProject};
@@ -0,0 +1 @@
1
+ import{existsSync as b}from"node:fs";import{dirname as _,join as h}from"node:path";import{discoverSchemaInfo as v}from"./discoverSchemaInfo-C8X9mo-i.mjs";import{isCacheEnabled as $,WORKERS_CACHE_MIN_DATE as m}from"./WORKERS_CACHE_MIN_DATE-B1h_wNDN.mjs";import{findWranglerFile as j,readWranglerJsonc as w}from"./WRANGLER_FILES-Bi_18Pj6.mjs";const g="2026-04-07",te="web_socket_auto_reply_to_close",p=/^\d{4}-\d{2}-\d{2}$/,A=(e,n,s)=>{if(n.length===0)return;const r=e.vectorize??[],t=new Set(r.filter(Boolean).map(a=>a?.index_name));for(const a of n)t.has(a)||s.push(`schema declares vector index "${a}"; wrangler "vectorize" must include a binding with index_name "${a}"`)},S=new Set(["basic","dev","lite","standard","standard-1","standard-2","standard-3","standard-4"]),k={disk_mb:2e4,memory_mib:12288,vcpu:4},M=(e,n,s)=>{const r=e.instance_type;if(r===void 0)return;if(typeof r=="string"){S.has(r)||s.push(`${n} has unknown instance_type "${r}" — expected lite, basic, standard-1..4, or a custom { vcpu, memory_mib, disk_mb } object`);return}for(const[o,c]of Object.entries(k)){const d=r[o];d!==void 0&&(typeof d!="number"||d<=0||d>c)&&s.push(`${n} custom instance_type ${o} must be a positive number ≤ ${String(c)} (got ${String(d)})`)}const{disk_mb:t,memory_mib:a,vcpu:i}=r;if(typeof i=="number"&&typeof a=="number"&&a<i*3072&&s.push(`${n} custom instance_type needs ≥ 3 GiB (3072 MiB) memory per vCPU (got ${String(a)} MiB for ${String(i)} vCPU)`),typeof a=="number"&&typeof t=="number"){const o=Math.floor(a/1024*2e3);t>o&&s.push(`${n} custom instance_type allows ≤ 2 GB disk per GiB memory (≤ ${String(o)} MB for ${String(a)} MiB memory; got ${String(t)} MB)`)}},q=(e,n,s)=>{const{boundClasses:r,errors:t,nonSqliteClasses:a,sqliteClasses:i,warnings:o}=s;if(!e||typeof e!="object"||typeof e.class_name!="string"||e.class_name.length===0){t.push(`${n} must have a non-empty "class_name" naming its container-enabled Durable Object class`);return}(typeof e.image!="string"||e.image.length===0)&&t.push(`${n} ("${e.class_name}") must have an "image" — a Dockerfile path or a registry reference`),r.has(e.class_name)||t.push(`${n} class "${e.class_name}" has no matching durable_objects binding — run \`lunora dev\` to auto-reconcile wrangler.jsonc, or add { "name": "...", "class_name": "${e.class_name}" }`),i.has(e.class_name)||t.push(a.has(e.class_name)?`${n} class "${e.class_name}" is registered via "new_classes" but containers require SQLite-backed DOs — move it to "new_sqlite_classes"`:`${n} class "${e.class_name}" is missing from migrations — add a migration entry with "new_sqlite_classes": ["${e.class_name}"]`),M(e,`${n} ("${e.class_name}")`,t),e.max_instances===void 0&&o.push(`${n} ("${e.class_name}") declares no max_instances — set a cap so a traffic spike can't fan out unbounded container spend`)},l=e=>Array.isArray(e)?e.filter(n=>n!==null&&typeof n=="object"):[],E=(e,n,s)=>{if(e.containers===void 0)return;if(!Array.isArray(e.containers)){n.push("containers must be an array of { class_name, image, ... } entries");return}const r=e.containers;if(r.length===0)return;const t=new Set(l(e.durable_objects?.bindings).map(c=>c.class_name)),a=e.migrations??[],i=new Set(a.flatMap(c=>[...c?.new_sqlite_classes??[]])),o=new Set(a.flatMap(c=>[...c?.new_classes??[]]));for(const[c,d]of r.entries())q(d,`containers[${String(c)}]`,{boundClasses:t,errors:n,nonSqliteClasses:o,sqliteClasses:i,warnings:s});e.observability?.enabled!==!0&&s.push('containers are configured but observability is not enabled — container logs will not be captured (add { "observability": { "enabled": true } })')},R=(e,n)=>{if(e.workflows===void 0)return;if(!Array.isArray(e.workflows)){n.push("workflows must be an array of { name, binding, class_name } entries");return}const s=e.workflows;for(const[r,t]of s.entries()){const a=`workflows[${String(r)}]`;if(!t||typeof t!="object"){n.push(`${a} must be a { name, binding, class_name } object`);continue}(typeof t.binding!="string"||t.binding.length===0)&&n.push(`${a} must have a non-empty "binding" naming the Workflow binding (e.g. WORKFLOW_ORDER_PIPELINE)`),(typeof t.class_name!="string"||t.class_name.length===0)&&n.push(`${a} must have a non-empty "class_name" naming the exported WorkflowEntrypoint class`),(typeof t.name!="string"||t.name.length===0)&&n.push(`${a} must have a non-empty "name" naming the deployed workflow`)}},O=(e,n)=>{if(e===void 0)return;if(!Array.isArray(e)){n.push("queues.producers must be an array of { binding, queue } entries");return}const s=e;for(const[r,t]of s.entries()){const a=`queues.producers[${String(r)}]`;if(!t||typeof t!="object"){n.push(`${a} must be a { binding, queue } object`);continue}(typeof t.binding!="string"||t.binding.length===0)&&n.push(`${a} must have a non-empty "binding" naming the Queue producer (e.g. QUEUE_EMAIL)`),(typeof t.queue!="string"||t.queue.length===0)&&n.push(`${a} must have a non-empty "queue" naming the deployed queue`)}},D=(e,n)=>{if(e===void 0)return;if(!Array.isArray(e)){n.push("queues.consumers must be an array of { queue } entries");return}const s=e;for(const[r,t]of s.entries()){const a=`queues.consumers[${String(r)}]`;if(!t||typeof t!="object"){n.push(`${a} must be a { queue } object`);continue}(typeof t.queue!="string"||t.queue.length===0)&&n.push(`${a} must have a non-empty "queue" naming the consumed queue`)}},L=(e,n)=>{if(e.queues!==void 0){if(typeof e.queues!="object"||Array.isArray(e.queues)){n.push("queues must be a { producers, consumers } object");return}O(e.queues.producers,n),D(e.queues.consumers,n)}},W=(e,n)=>{if(e.secrets_store_secrets===void 0)return;if(!Array.isArray(e.secrets_store_secrets)){n.push("secrets_store_secrets must be an array of { binding, store_id, secret_name } entries");return}const s=e.secrets_store_secrets;for(const[r,t]of s.entries()){const a=`secrets_store_secrets[${String(r)}]`;if(!t||typeof t!="object"){n.push(`${a} must be a { binding, store_id, secret_name } object`);continue}for(const i of["binding","store_id","secret_name"])(typeof t[i]!="string"||t[i].length===0)&&n.push(`${a} must have a non-empty "${i}"`)}},u=e=>typeof e=="string"&&e.length>0,f=e=>e,C=[{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,n)=>`${e} ("${n}") 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,n)=>`${e} ("${n}") 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,n)=>`${e} ("${n}") 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,n)=>`${e} ("${n}") 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,n)=>`${e} ("${n}") has no "dataset" — it defaults to the binding name; set it explicitly to avoid drift`,key:"analytics_engine_datasets"}],x=(e,n,s,r)=>{const t=e[n.key];if(t!==void 0){if(!Array.isArray(t)){s.push(n.arrayMessage);return}for(const[a,i]of f(t).entries()){const o=`${n.key}[${String(a)}]`;if(!i||typeof i!="object"||!u(i.binding)){s.push(n.bindingMessage(o));continue}(typeof n.hintField=="string"?[n.hintField]:n.hintField).some(c=>u(i[c]))||r.push(n.hintMessage(o,i.binding))}}},I=[{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" })'}],N=(e,n,s)=>{const r=e[n.key];r!==void 0&&(typeof r!="object"||Array.isArray(r)||!u(r.binding))&&s.push(n.message)},B=[{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`}],F=(e,n,s)=>{const r=e[n.key];if(r!==void 0){if(!Array.isArray(r)){s.push(n.arrayMessage);return}for(const[t,a]of f(r).entries()){const i=`${n.key}[${String(t)}]`;if(!a||typeof a!="object"){s.push(n.objectMessage(i));continue}for(const o of n.fields)u(a[o.field])||s.push(o.message(i))}}},P=(e,n,s)=>{const r=e.send_email;if(r===void 0)return;if(!Array.isArray(r)){n.push("send_email must be an array of { name, destination_address? } entries");return}const t=r;for(const[a,i]of t.entries())(!i||typeof i!="object"||typeof i.name!="string"||i.name.length===0)&&s.push(`send_email[${String(a)}] has no non-empty "name" naming the send-email binding — set one before deploying`)},T=(e,n)=>{e.logpush!==void 0&&typeof e.logpush!="boolean"&&n.push('logpush must be a boolean (set "logpush": true to enable Cloudflare Logpush)')},U=(e,n)=>{const{placement:s}=e;if(s!==void 0){if(typeof s!="object"||Array.isArray(s)){n.push('placement must be an object (e.g. { "mode": "smart" })');return}s.mode!==void 0&&s.mode!=="smart"&&n.push('placement.mode must be "smart" (the only supported Smart Placement mode)')}},G=(e,n)=>{const{observability:s}=e;if(s===void 0)return;if(typeof s!="object"||Array.isArray(s)){n.push('observability must be an object (e.g. { "enabled": true, "head_sampling_rate": 1 })');return}const r=(t,a)=>{t!==void 0&&(typeof t!="number"||Number.isNaN(t)||t<0||t>1)&&n.push(`${a} must be a number in [0, 1] (the fraction of requests sampled)`)};r(s.head_sampling_rate,"observability.head_sampling_rate"),s.logs!==void 0&&(typeof s.logs!="object"||Array.isArray(s.logs)?n.push("observability.logs must be an object"):r(s.logs.head_sampling_rate,"observability.logs.head_sampling_rate"))},H=(e,n)=>{const{cache:s}=e;if(s!==void 0){if(typeof s!="object"||s===null||Array.isArray(s)){n.push('cache must be an object (e.g. { "enabled": true })');return}s.enabled!==void 0&&typeof s.enabled!="boolean"&&n.push("cache.enabled must be a boolean (true or false)")}},Q=(e,n)=>{const{exports:s}=e;if(s!==void 0){if(typeof s!="object"||s===null||Array.isArray(s)){n.push("exports must be an object keyed by entrypoint name");return}for(const[r,t]of Object.entries(s)){if(typeof t!="object"||t===null){n.push(`exports["${r}"] must be an object`);continue}t.type!==void 0&&typeof t.type!="string"&&n.push(`exports["${r}"].type must be a string`),t.cache!==void 0&&(typeof t.cache!="object"||t.cache===null||Array.isArray(t.cache)?n.push(`exports["${r}"].cache must be an object`):t.cache.enabled!==void 0&&typeof t.cache.enabled!="boolean"&&n.push(`exports["${r}"].cache.enabled must be a boolean`))}}},Y=(e,n)=>{const{assets:s}=e;if(s!==void 0){if(typeof s!="object"||Array.isArray(s)){n.push('assets must be an object (e.g. { "directory": "./dist/client", "binding": "ASSETS" })');return}(typeof s.directory!="string"||s.directory.length===0)&&n.push('assets must declare a non-empty "directory" pointing at the built client output (e.g. "./dist/client")'),s.binding!==void 0&&(typeof s.binding!="string"||s.binding.length===0)&&n.push('assets.binding must be a non-empty string (e.g. "ASSETS")'),s.html_handling!==void 0&&typeof s.html_handling!="string"&&n.push("assets.html_handling must be a string"),s.not_found_handling!==void 0&&typeof s.not_found_handling!="string"&&n.push("assets.not_found_handling must be a string")}},K=(e,n)=>{const s=e.tail_consumers;if(s===void 0)return;if(!Array.isArray(s)){n.push("tail_consumers must be an array of { service, environment? } entries");return}const r=s;for(const[t,a]of r.entries())(!a||typeof a!="object"||typeof a.service!="string"||a.service.length===0)&&n.push(`tail_consumers[${String(t)}] must have a non-empty "service" naming the consumer Worker`)},ae=(e,n)=>{const s=e.tail_consumers??[];return s.some(r=>!!r&&r?.service===n.service&&r?.environment===n.environment)?e:{...e,tail_consumers:[...s,n]}},z=new Set(["1","enabled","on","true","yes"]),J=(e,n)=>{const{vars:s}=e;if(!s||typeof s!="object")return;const r=s.LUNORA_ALLOWED_ORIGINS,t=s.LUNORA_CORS_ALLOW_CREDENTIALS,a=typeof r=="string"&&r.split(",").some(o=>o.trim()==="*"),i=typeof t=="string"&&z.has(t.trim().toLowerCase());a&&i&&n.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')},y=(e,n)=>{const s=[],r=[];if(!e||typeof e!="object")return s.push("wrangler config is not a valid object"),{errors:s,valid:!1,warnings:r};l(e.durable_objects?.bindings).find(a=>a.name==="SHARD"&&a.class_name==="ShardDO")||s.push('durable_objects.bindings must include { "name": "SHARD", "class_name": "ShardDO" } — run `lunora dev` to auto-reconcile wrangler.jsonc, or add the binding manually');const t=e.compatibility_date??"";t&&!p.test(t)?s.push(`compatibility_date must be in YYYY-MM-DD format (got "${t}")`):t<g&&s.push(`compatibility_date must be >= "${g}" (got "${t||"<missing>"}")`),$(e)&&p.test(t)&&t<m&&s.push(`cache.enabled requires compatibility_date >= "${m}" (got "${t||"<missing>"}")`),n?.hasGlobalTable&&(l(e.d1_databases).find(a=>a.binding==="DB")||s.push('schema declares .global() tables; d1_databases must include a binding named "DB" — run `lunora dev` to auto-reconcile wrangler.jsonc, or add the binding manually')),A(e,n?.vectorIndexNames??[],s),K(e,s),E(e,s,r),R(e,s),L(e,s),W(e,s);for(const a of C)x(e,a,s,r);for(const a of B)F(e,a,s);for(const a of I)N(e,a,s);return P(e,s,r),T(e,s),U(e,s),G(e,s),Y(e,s),H(e,s),Q(e,s),J(e,s),{errors:s,valid:s.length===0,warnings:r}},re=y,V=(e,n,s)=>{const r=[];for(const t of e){const a=t?.image;typeof a!="string"||!(a.startsWith("./")||a.startsWith("../")||a.startsWith("/")||a.includes("Dockerfile"))||b(a.startsWith("/")?a:h(n,a))||r.push(`containers image "${a}" does not exist (resolved relative to ${s}); create the Dockerfile or point image at a registry reference`)}return r},ie=e=>{const n=e.schemaDir??"lunora",s=j(e.projectRoot);if(!s){const d=`wrangler.jsonc not found in ${e.projectRoot}; create one declaring at least the SHARD durable object binding.`;return{problems:[d],report:{errors:[d],valid:!1,warnings:[]},wranglerPath:void 0}}const{parsed:r}=w(s);if(r===void 0){const d=`failed to parse ${s} as JSONC.`;return{problems:[d],report:{errors:[d],valid:!1,warnings:[]},wranglerPath:s}}const{error:t,info:a}=v(e.projectRoot,n),i=y(r,a);t!==void 0&&i.warnings.push(`schema parse failed in ${n}/schema.ts: ${t}`);const o=_(s);i.errors.push(...V(r.containers??[],o,s));const c=r.assets?.directory;if(typeof c=="string"&&c.length>0){const d=c.startsWith("/")?c:h(o,c);b(d)||i.warnings.push(`assets.directory "${c}" does not exist yet — it is created by the client build; run the build before deploy`)}return i.valid=i.errors.length===0,{problems:i.errors,report:i,wranglerPath:s}};export{g as REQUIRED_COMPATIBILITY_DATE,te as REQUIRED_FLAG,re as validateWrangler,y as validateWranglerConfig,ie as validateWranglerProject,ae as withTailConsumer};
@@ -0,0 +1 @@
1
+ import{writeFileSync as N,readFileSync as S}from"node:fs";import{join as k}from"node:path";import{containerBuildTag as E}from"@lunora/container";import{DEV_VARS_FILE as D,parseDevVariableEntries as A}from"./DEV_VARS_EXAMPLE_FILE-DX6xGbpr.mjs";import{e as b}from"./jsonc-edit-BZVpxVA0.mjs";import{findWranglerFile as B,readWranglerJsonc as O}from"./WRANGLER_FILES-Bi_18Pj6.mjs";const v="<replace-with-d1-create-id>",C=e=>{const a=[];for(const n of e.containers)n.exported||a.push({className:n.className,exportName:n.exportName,kind:"container",module:"containers"});for(const n of e.workflows)n.exported||a.push({className:n.className,exportName:n.exportName,kind:"workflow",module:"workflows"});for(const n of e.agents)n.exported||a.push({className:n.className,exportName:n.exportName,kind:"agent",module:"agents"});return a},I=(e,a)=>{const n=e.flagshipBinding!==void 0&&!(a?.flagship??[]).some(s=>s.binding===e.flagshipBinding);return[[e.usesKv&&(a?.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&&(a?.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&&(a?.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(([s])=>s).map(([,s])=>s)},P=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(([a])=>a).map(([,a])=>a),f=(e,a,n)=>n.filter(s=>!s.exported).map(s=>`${e} "${s.exportName}" is declared but ${s.className} is not exported by the worker entry; add \`export * from "./lunora/_generated/${a}"\` so its binding can be provisioned.`),w=[{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"}],R=()=>w.map(({keys:e,label:a})=>`${e[0]} + ${e[1]} (${a})`).join(" or "),T=e=>{let a;try{a=S(k(e,D),"utf8")}catch{return!1}const n=new Map(A(a).map(s=>[s.key,s.value]));return w.some(({keys:s})=>s.every(i=>(n.get(i)??"")!==""))},_=(e,a,n)=>{const s=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&&!s.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&&!s.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(...f("container","containers",e.containers),...f("workflow","workflows",e.workflows),...f("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&&!T(a)&&i.push(`@lunora/payment is used; set one provider's secret pair in .dev.vars — ${R()}.`),i.push(...P(e),...I(e,n)),i},$=e=>{const a=new Set(e.map(s=>s.tag));let n=1;for(;a.has(`v${String(n)}`);)n+=1;return`v${String(n)}`},M=(e,a,n)=>{const s=a.durable_objects?.bindings??[],i=new Set(s.map(u=>u.name)),o=n.filter(u=>!i.has(u.binding));let c=e;const d=[];if(o.length>0){const u=[...s,...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=a.migrations??[],l=new Set(g.flatMap(u=>[...u.new_sqlite_classes??[],...u.new_classes??[]])),h=n.map(u=>u.className).filter(u=>!l.has(u));if(h.length>0){const u=[...g,{new_sqlite_classes:h,tag:$(g)}];c=b(c,["migrations"],u)}return{added:d,text:c}},K=(e,a)=>{const n=a.d1_databases??[];if(n.some(o=>o.binding==="DB"))return{added:[],text:e};const s=typeof a.name=="string"&&a.name.length>0?a.name:"lunora",i=[...n,{binding:"DB",database_id:v,database_name:s}];return{added:["DB (D1)"],text:b(e,["d1_databases"],i)}},x=(e,a,n,s,i)=>{const o=a[n]?.binding;return typeof o=="string"&&o.length>0?{added:[],text:e}:{added:[i],text:b(e,[n],{binding:s})}},q=(e,a)=>(a.analytics_engine_datasets?.length??0)>0?{added:[],text:e}:{added:["ANALYTICS (Analytics Engine)"],text:b(e,["analytics_engine_datasets"],[{binding:"ANALYTICS",dataset:"ANALYTICS"}])},W=e=>{if(typeof e=="string")return e;const a={};return e.diskMb!==void 0&&(a.disk_mb=e.diskMb),e.memoryMib!==void 0&&(a.memory_mib=e.memoryMib),e.vcpu!==void 0&&(a.vcpu=e.vcpu),a},Y=e=>e.image.kind==="dockerfile"?e.image.dockerfilePath:e.image.kind==="registry"?e.image.reference:E(e.exportName),L=e=>{const a={class_name:e.className,image:Y(e)};return e.image.kind==="dockerfile"&&(a.image_build_context=e.image.buildContext),e.buildArgs!==void 0&&e.image.kind!=="registry"&&(a.image_vars=e.buildArgs),e.instanceType!==void 0&&(a.instance_type=W(e.instanceType)),e.maxInstances!==void 0&&(a.max_instances=e.maxInstances),e.name!==void 0&&(a.name=e.name),e.rollout?.stepPercentage!==void 0&&(a.rollout_step_percentage=e.rollout.stepPercentage),e.rollout?.gracePeriodSeconds!==void 0&&(a.rollout_active_grace_period=e.rollout.gracePeriodSeconds),a},j=(e,a,n)=>{const s=a.containers??[],i=new Set(s.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"],[...s,...o.map(d=>L(d))]);return{added:o.map(d=>`containers/${d.className}`),text:c}},G=(e,a)=>{if(a.observability!==void 0)return{added:[],text:e};const n=b(e,["observability"],{enabled:!0,head_sampling_rate:1});return{added:["observability"],text:n}},H=e=>({binding:e.bindingName,class_name:e.className,name:e.name}),U=e=>({binding:e.bindingName,class_name:e.className,name:e.name}),F=(e,a,n,s=[])=>{const i=a.workflows??[],o=new Set(i.map(l=>l.class_name)),c=n.filter(l=>!o.has(l.className)),d=s.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=>H(l)),...d.map(l=>U(l))]);return{added:[...c.map(l=>`workflows/${l.className}`),...d.map(l=>`workflows/${l.className}`)],text:g}},V=(e,a,n)=>{const s=a.queues??{},i=s.producers??[],o=s.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 h=[...i,...g.map(r=>({binding:r.bindingName,queue:r.name}))],u=[...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})],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}},ae=(e,a)=>{const n=B(e),s=C(a);if(!n)return{added:[],changed:!1,exportGaps:s,reason:"wrangler.jsonc not found",warnings:_(a,e)};const{parsed:i,text:o}=O(n);if(i===void 0)return{added:[],changed:!1,exportGaps:s,reason:`failed to parse ${n} as JSONC`,warnings:_(a,e),wranglerPath:n};const c=_(a,e,i),d=a.containers.filter(t=>t.exported),g=a.agents.filter(t=>t.exported&&t.voice===!0&&t.voiceBindingName!==void 0&&t.voiceClassName!==void 0),l=[...a.durableObjects,...d.map(t=>({binding:t.bindingName,className:t.className})),...g.map(t=>({binding:t.voiceBindingName,className:t.voiceClassName}))],h=a.workflows.filter(t=>t.exported),u=a.agents.filter(t=>t.exported),p=[{enabled:!0,run:t=>M(t,i,l)},{enabled:a.needsD1,run:t=>K(t,i)},{enabled:a.usesAi,run:t=>x(t,i,"ai","AI","AI (Workers AI)")},{enabled:a.usesBrowser,run:t=>x(t,i,"browser","BROWSER","BROWSER (Browser Rendering)")},{enabled:a.usesImages,run:t=>x(t,i,"images","IMAGES","IMAGES (Cloudflare Images)")},{enabled:a.usesAnalytics,run:t=>q(t,i)},{enabled:!0,run:t=>G(t,i)},{enabled:d.length>0,run:t=>j(t,i,d)},{enabled:h.length>0||u.length>0,run:t=>F(t,i,h,u)},{enabled:a.queues.length>0,run:t=>V(t,i,a.queues)}];let r=o;const m=[];for(const t of p){if(!t.enabled)continue;const y=t.run(r);r=y.text,m.push(...y.added)}return m.includes("DB (D1)")&&c.push(`wrote a DB binding with a placeholder database_id ("${v}") — run \`wrangler d1 create <name>\` and replace it before deploying.`),r===o?{added:[],changed:!1,exportGaps:s,reason:"bindings already in sync",warnings:c,wranglerPath:n}:(N(n,r,"utf8"),{added:m,changed:!0,exportGaps:s,warnings:c,wranglerPath:n})};export{ae as reconcileWranglerBindings};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/config",
3
- "version": "1.0.0-alpha.97",
3
+ "version": "1.0.0-alpha.99",
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",
@@ -50,10 +50,10 @@
50
50
  "access": "public"
51
51
  },
52
52
  "dependencies": {
53
- "@lunora/codegen": "1.0.0-alpha.71",
53
+ "@lunora/codegen": "1.0.0-alpha.73",
54
54
  "@lunora/container": "1.0.0-alpha.16",
55
55
  "@lunora/errors": "1.0.0-alpha.8",
56
- "@lunora/seed": "1.0.0-alpha.46",
56
+ "@lunora/seed": "1.0.0-alpha.48",
57
57
  "@visulima/colorize": "2.0.0",
58
58
  "@visulima/find-ai-runner": "1.0.0",
59
59
  "dockerode": "^5.0.1",
@@ -1 +0,0 @@
1
- import{existsSync as b}from"node:fs";import{dirname as _,join as h}from"node:path";import{discoverSchemaInfo as v}from"./discoverSchemaInfo-C8X9mo-i.mjs";import{isCacheEnabled as $,WORKERS_CACHE_MIN_DATE as m}from"./WORKERS_CACHE_MIN_DATE-B1h_wNDN.mjs";import{findWranglerFile as j,readWranglerJsonc as w}from"./WRANGLER_FILES-Bi_18Pj6.mjs";const g="2026-04-07",te="web_socket_auto_reply_to_close",p=/^\d{4}-\d{2}-\d{2}$/,A=(e,s,n)=>{if(s.length===0)return;const r=e.vectorize??[],t=new Set(r.filter(Boolean).map(a=>a?.index_name));for(const a of s)t.has(a)||n.push(`schema declares vector index "${a}"; wrangler "vectorize" must include a binding with index_name "${a}"`)},S=new Set(["basic","dev","lite","standard","standard-1","standard-2","standard-3","standard-4"]),k={disk_mb:2e4,memory_mib:12288,vcpu:4},M=(e,s,n)=>{const r=e.instance_type;if(r===void 0)return;if(typeof r=="string"){S.has(r)||n.push(`${s} has unknown instance_type "${r}" — expected lite, basic, standard-1..4, or a custom { vcpu, memory_mib, disk_mb } object`);return}for(const[o,c]of Object.entries(k)){const d=r[o];d!==void 0&&(typeof d!="number"||d<=0||d>c)&&n.push(`${s} custom instance_type ${o} must be a positive number ≤ ${String(c)} (got ${String(d)})`)}const{disk_mb:t,memory_mib:a,vcpu:i}=r;if(typeof i=="number"&&typeof a=="number"&&a<i*3072&&n.push(`${s} custom instance_type needs ≥ 3 GiB (3072 MiB) memory per vCPU (got ${String(a)} MiB for ${String(i)} vCPU)`),typeof a=="number"&&typeof t=="number"){const o=Math.floor(a/1024*2e3);t>o&&n.push(`${s} custom instance_type allows ≤ 2 GB disk per GiB memory (≤ ${String(o)} MB for ${String(a)} MiB memory; got ${String(t)} MB)`)}},q=(e,s,n)=>{const{boundClasses:r,errors:t,nonSqliteClasses:a,sqliteClasses:i,warnings:o}=n;if(!e||typeof e!="object"||typeof e.class_name!="string"||e.class_name.length===0){t.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)&&t.push(`${s} ("${e.class_name}") must have an "image" — a Dockerfile path or a registry reference`),r.has(e.class_name)||t.push(`${s} class "${e.class_name}" has no matching durable_objects binding — run \`lunora dev\` to auto-reconcile wrangler.jsonc, or add { "name": "...", "class_name": "${e.class_name}" }`),i.has(e.class_name)||t.push(a.has(e.class_name)?`${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}"]`),M(e,`${s} ("${e.class_name}")`,t),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`)},l=e=>Array.isArray(e)?e.filter(s=>s!==null&&typeof s=="object"):[],E=(e,s,n)=>{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 r=e.containers;if(r.length===0)return;const t=new Set(l(e.durable_objects?.bindings).map(c=>c.class_name)),a=e.migrations??[],i=new Set(a.flatMap(c=>[...c?.new_sqlite_classes??[]])),o=new Set(a.flatMap(c=>[...c?.new_classes??[]]));for(const[c,d]of r.entries())q(d,`containers[${String(c)}]`,{boundClasses:t,errors:s,nonSqliteClasses:o,sqliteClasses:i,warnings:n});e.observability?.enabled!==!0&&n.push('containers are configured but observability is not enabled — container logs will not be captured (add { "observability": { "enabled": true } })')},R=(e,s)=>{if(e.workflows===void 0)return;if(!Array.isArray(e.workflows)){s.push("workflows must be an array of { name, binding, class_name } entries");return}const n=e.workflows;for(const[r,t]of n.entries()){const a=`workflows[${String(r)}]`;if(!t||typeof t!="object"){s.push(`${a} must be a { name, binding, class_name } object`);continue}(typeof t.binding!="string"||t.binding.length===0)&&s.push(`${a} must have a non-empty "binding" naming the Workflow binding (e.g. WORKFLOW_ORDER_PIPELINE)`),(typeof t.class_name!="string"||t.class_name.length===0)&&s.push(`${a} must have a non-empty "class_name" naming the exported WorkflowEntrypoint class`),(typeof t.name!="string"||t.name.length===0)&&s.push(`${a} must have a non-empty "name" naming the deployed workflow`)}},O=(e,s)=>{if(e===void 0)return;if(!Array.isArray(e)){s.push("queues.producers must be an array of { binding, queue } entries");return}const n=e;for(const[r,t]of n.entries()){const a=`queues.producers[${String(r)}]`;if(!t||typeof t!="object"){s.push(`${a} must be a { binding, queue } object`);continue}(typeof t.binding!="string"||t.binding.length===0)&&s.push(`${a} must have a non-empty "binding" naming the Queue producer (e.g. QUEUE_EMAIL)`),(typeof t.queue!="string"||t.queue.length===0)&&s.push(`${a} must have a non-empty "queue" naming the deployed queue`)}},D=(e,s)=>{if(e===void 0)return;if(!Array.isArray(e)){s.push("queues.consumers must be an array of { queue } entries");return}const n=e;for(const[r,t]of n.entries()){const a=`queues.consumers[${String(r)}]`;if(!t||typeof t!="object"){s.push(`${a} must be a { queue } object`);continue}(typeof t.queue!="string"||t.queue.length===0)&&s.push(`${a} must have a non-empty "queue" naming the consumed queue`)}},L=(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}O(e.queues.producers,s),D(e.queues.consumers,s)}},W=(e,s)=>{if(e.secrets_store_secrets===void 0)return;if(!Array.isArray(e.secrets_store_secrets)){s.push("secrets_store_secrets must be an array of { binding, store_id, secret_name } entries");return}const n=e.secrets_store_secrets;for(const[r,t]of n.entries()){const a=`secrets_store_secrets[${String(r)}]`;if(!t||typeof t!="object"){s.push(`${a} must be a { binding, store_id, secret_name } object`);continue}for(const i of["binding","store_id","secret_name"])(typeof t[i]!="string"||t[i].length===0)&&s.push(`${a} must have a non-empty "${i}"`)}},u=e=>typeof e=="string"&&e.length>0,f=e=>e,C=[{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, pipeline } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Pipelines binding`,hintField:"pipeline",hintMessage:(e,s)=>`${e} ("${s}") has no "pipeline" — run \`wrangler pipelines create <name>\` and set the pipeline 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"}],x=(e,s,n,r)=>{const t=e[s.key];if(t!==void 0){if(!Array.isArray(t)){n.push(s.arrayMessage);return}for(const[a,i]of f(t).entries()){const o=`${s.key}[${String(a)}]`;if(!i||typeof i!="object"||!u(i.binding)){n.push(s.bindingMessage(o));continue}u(i[s.hintField])||r.push(s.hintMessage(o,i.binding))}}},I=[{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" })'}],N=(e,s,n)=>{const r=e[s.key];r!==void 0&&(typeof r!="object"||Array.isArray(r)||!u(r.binding))&&n.push(s.message)},B=[{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`}],F=(e,s,n)=>{const r=e[s.key];if(r!==void 0){if(!Array.isArray(r)){n.push(s.arrayMessage);return}for(const[t,a]of f(r).entries()){const i=`${s.key}[${String(t)}]`;if(!a||typeof a!="object"){n.push(s.objectMessage(i));continue}for(const o of s.fields)u(a[o.field])||n.push(o.message(i))}}},P=(e,s,n)=>{const r=e.send_email;if(r===void 0)return;if(!Array.isArray(r)){s.push("send_email must be an array of { name, destination_address? } entries");return}const t=r;for(const[a,i]of t.entries())(!i||typeof i!="object"||typeof i.name!="string"||i.name.length===0)&&n.push(`send_email[${String(a)}] has no non-empty "name" naming the send-email binding — set one before deploying`)},T=(e,s)=>{e.logpush!==void 0&&typeof e.logpush!="boolean"&&s.push('logpush must be a boolean (set "logpush": true to enable Cloudflare Logpush)')},U=(e,s)=>{const{placement:n}=e;if(n!==void 0){if(typeof n!="object"||Array.isArray(n)){s.push('placement must be an object (e.g. { "mode": "smart" })');return}n.mode!==void 0&&n.mode!=="smart"&&s.push('placement.mode must be "smart" (the only supported Smart Placement mode)')}},G=(e,s)=>{const{observability:n}=e;if(n===void 0)return;if(typeof n!="object"||Array.isArray(n)){s.push('observability must be an object (e.g. { "enabled": true, "head_sampling_rate": 1 })');return}const r=(t,a)=>{t!==void 0&&(typeof t!="number"||Number.isNaN(t)||t<0||t>1)&&s.push(`${a} must be a number in [0, 1] (the fraction of requests sampled)`)};r(n.head_sampling_rate,"observability.head_sampling_rate"),n.logs!==void 0&&(typeof n.logs!="object"||Array.isArray(n.logs)?s.push("observability.logs must be an object"):r(n.logs.head_sampling_rate,"observability.logs.head_sampling_rate"))},H=(e,s)=>{const{cache:n}=e;if(n!==void 0){if(typeof n!="object"||n===null||Array.isArray(n)){s.push('cache must be an object (e.g. { "enabled": true })');return}n.enabled!==void 0&&typeof n.enabled!="boolean"&&s.push("cache.enabled must be a boolean (true or false)")}},Q=(e,s)=>{const{exports:n}=e;if(n!==void 0){if(typeof n!="object"||n===null||Array.isArray(n)){s.push("exports must be an object keyed by entrypoint name");return}for(const[r,t]of Object.entries(n)){if(typeof t!="object"||t===null){s.push(`exports["${r}"] must be an object`);continue}t.type!==void 0&&typeof t.type!="string"&&s.push(`exports["${r}"].type must be a string`),t.cache!==void 0&&(typeof t.cache!="object"||t.cache===null||Array.isArray(t.cache)?s.push(`exports["${r}"].cache must be an object`):t.cache.enabled!==void 0&&typeof t.cache.enabled!="boolean"&&s.push(`exports["${r}"].cache.enabled must be a boolean`))}}},Y=(e,s)=>{const{assets:n}=e;if(n!==void 0){if(typeof n!="object"||Array.isArray(n)){s.push('assets must be an object (e.g. { "directory": "./dist/client", "binding": "ASSETS" })');return}(typeof n.directory!="string"||n.directory.length===0)&&s.push('assets must declare a non-empty "directory" pointing at the built client output (e.g. "./dist/client")'),n.binding!==void 0&&(typeof n.binding!="string"||n.binding.length===0)&&s.push('assets.binding must be a non-empty string (e.g. "ASSETS")'),n.html_handling!==void 0&&typeof n.html_handling!="string"&&s.push("assets.html_handling must be a string"),n.not_found_handling!==void 0&&typeof n.not_found_handling!="string"&&s.push("assets.not_found_handling must be a string")}},K=(e,s)=>{const n=e.tail_consumers;if(n===void 0)return;if(!Array.isArray(n)){s.push("tail_consumers must be an array of { service, environment? } entries");return}const r=n;for(const[t,a]of r.entries())(!a||typeof a!="object"||typeof a.service!="string"||a.service.length===0)&&s.push(`tail_consumers[${String(t)}] must have a non-empty "service" naming the consumer Worker`)},ae=(e,s)=>{const n=e.tail_consumers??[];return n.some(r=>!!r&&r?.service===s.service&&r?.environment===s.environment)?e:{...e,tail_consumers:[...n,s]}},z=new Set(["1","enabled","on","true","yes"]),J=(e,s)=>{const{vars:n}=e;if(!n||typeof n!="object")return;const r=n.LUNORA_ALLOWED_ORIGINS,t=n.LUNORA_CORS_ALLOW_CREDENTIALS,a=typeof r=="string"&&r.split(",").some(o=>o.trim()==="*"),i=typeof t=="string"&&z.has(t.trim().toLowerCase());a&&i&&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')},y=(e,s)=>{const n=[],r=[];if(!e||typeof e!="object")return n.push("wrangler config is not a valid object"),{errors:n,valid:!1,warnings:r};l(e.durable_objects?.bindings).find(a=>a.name==="SHARD"&&a.class_name==="ShardDO")||n.push('durable_objects.bindings must include { "name": "SHARD", "class_name": "ShardDO" } — run `lunora dev` to auto-reconcile wrangler.jsonc, or add the binding manually');const t=e.compatibility_date??"";t&&!p.test(t)?n.push(`compatibility_date must be in YYYY-MM-DD format (got "${t}")`):t<g&&n.push(`compatibility_date must be >= "${g}" (got "${t||"<missing>"}")`),$(e)&&p.test(t)&&t<m&&n.push(`cache.enabled requires compatibility_date >= "${m}" (got "${t||"<missing>"}")`),s?.hasGlobalTable&&(l(e.d1_databases).find(a=>a.binding==="DB")||n.push('schema declares .global() tables; d1_databases must include a binding named "DB" — run `lunora dev` to auto-reconcile wrangler.jsonc, or add the binding manually')),A(e,s?.vectorIndexNames??[],n),K(e,n),E(e,n,r),R(e,n),L(e,n),W(e,n);for(const a of C)x(e,a,n,r);for(const a of B)F(e,a,n);for(const a of I)N(e,a,n);return P(e,n,r),T(e,n),U(e,n),G(e,n),Y(e,n),H(e,n),Q(e,n),J(e,n),{errors:n,valid:n.length===0,warnings:r}},re=y,V=(e,s,n)=>{const r=[];for(const t of e){const a=t?.image;typeof a!="string"||!(a.startsWith("./")||a.startsWith("../")||a.startsWith("/")||a.includes("Dockerfile"))||b(a.startsWith("/")?a:h(s,a))||r.push(`containers image "${a}" does not exist (resolved relative to ${n}); create the Dockerfile or point image at a registry reference`)}return r},ie=e=>{const s=e.schemaDir??"lunora",n=j(e.projectRoot);if(!n){const d=`wrangler.jsonc not found in ${e.projectRoot}; create one declaring at least the SHARD durable object binding.`;return{problems:[d],report:{errors:[d],valid:!1,warnings:[]},wranglerPath:void 0}}const{parsed:r}=w(n);if(r===void 0){const d=`failed to parse ${n} as JSONC.`;return{problems:[d],report:{errors:[d],valid:!1,warnings:[]},wranglerPath:n}}const{error:t,info:a}=v(e.projectRoot,s),i=y(r,a);t!==void 0&&i.warnings.push(`schema parse failed in ${s}/schema.ts: ${t}`);const o=_(n);i.errors.push(...V(r.containers??[],o,n));const c=r.assets?.directory;if(typeof c=="string"&&c.length>0){const d=c.startsWith("/")?c:h(o,c);b(d)||i.warnings.push(`assets.directory "${c}" does not exist yet — it is created by the client build; run the build before deploy`)}return i.valid=i.errors.length===0,{problems:i.errors,report:i,wranglerPath:n}};export{g as REQUIRED_COMPATIBILITY_DATE,te as REQUIRED_FLAG,re as validateWrangler,y as validateWranglerConfig,ie as validateWranglerProject,ae as withTailConsumer};
@@ -1 +0,0 @@
1
- import{writeFileSync as y}from"node:fs";import{containerBuildTag as N}from"@lunora/container";import{e as b}from"./jsonc-edit-BZVpxVA0.mjs";import{findWranglerFile as S,readWranglerJsonc as k}from"./WRANGLER_FILES-Bi_18Pj6.mjs";const w="<replace-with-d1-create-id>",B=e=>{const a=[];for(const n of e.containers)n.exported||a.push({className:n.className,exportName:n.exportName,kind:"container",module:"containers"});for(const n of e.workflows)n.exported||a.push({className:n.className,exportName:n.exportName,kind:"workflow",module:"workflows"});for(const n of e.agents)n.exported||a.push({className:n.className,exportName:n.exportName,kind:"agent",module:"agents"});return a},D=(e,a)=>{const n=e.flagshipBinding!==void 0&&!(a?.flagship??[]).some(s=>s.binding===e.flagshipBinding);return[[e.usesKv&&(a?.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&&(a?.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&&(a?.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(([s])=>s).map(([,s])=>s)},A=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(([a])=>a).map(([,a])=>a),f=(e,a,n)=>n.filter(s=>!s.exported).map(s=>`${e} "${s.exportName}" is declared but ${s.className} is not exported by the worker entry; add \`export * from "./lunora/_generated/${a}"\` so its binding can be provisioned.`),x=(e,a)=>{const n=new Set(e.durableObjects.map(o=>o.className)),s=[],r=(a?.r2_buckets?.length??0)>0,d=(a?.d1_databases?.some(o=>o.binding==="DB")??!1)||e.needsD1;return e.usesStorage&&!r&&s.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&&!n.has("SessionDO")&&!d&&s.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&&!n.has("SchedulerDO")&&s.push("@lunora/scheduler is used but the worker entry exports no SchedulerDO; export it so the SCHEDULER binding can be provisioned."),s.push(...f("container","containers",e.containers),...f("workflow","workflows",e.workflows),...f("agent","agents",e.agents)),e.containers.length>0&&a?.observability?.enabled===!1&&s.push("containers are declared but observability is explicitly disabled in wrangler.jsonc — container logs will not be captured."),e.usesPayment&&s.push("@lunora/payment is used; set the provider secrets in .dev.vars — STRIPE_SECRET_KEY + STRIPE_WEBHOOK_SECRET (Stripe) or POLAR_ACCESS_TOKEN + POLAR_WEBHOOK_SECRET (Polar)."),s.push(...A(e),...D(e,a)),s},E=e=>{const a=new Set(e.map(s=>s.tag));let n=1;for(;a.has(`v${String(n)}`);)n+=1;return`v${String(n)}`},I=(e,a,n)=>{const s=a.durable_objects?.bindings??[],r=new Set(s.map(u=>u.name)),d=n.filter(u=>!r.has(u.binding));let o=e;const c=[];if(d.length>0){const u=[...s,...d.map(m=>({class_name:m.className,name:m.binding}))];o=b(o,["durable_objects","bindings"],u),c.push(...d.map(m=>`${m.binding}/${m.className}`))}const g=a.migrations??[],l=new Set(g.flatMap(u=>[...u.new_sqlite_classes??[],...u.new_classes??[]])),h=n.map(u=>u.className).filter(u=>!l.has(u));if(h.length>0){const u=[...g,{new_sqlite_classes:h,tag:E(g)}];o=b(o,["migrations"],u)}return{added:c,text:o}},O=(e,a)=>{const n=a.d1_databases??[];if(n.some(d=>d.binding==="DB"))return{added:[],text:e};const s=typeof a.name=="string"&&a.name.length>0?a.name:"lunora",r=[...n,{binding:"DB",database_id:w,database_name:s}];return{added:["DB (D1)"],text:b(e,["d1_databases"],r)}},v=(e,a,n,s,r)=>{const d=a[n]?.binding;return typeof d=="string"&&d.length>0?{added:[],text:e}:{added:[r],text:b(e,[n],{binding:s})}},C=(e,a)=>(a.analytics_engine_datasets?.length??0)>0?{added:[],text:e}:{added:["ANALYTICS (Analytics Engine)"],text:b(e,["analytics_engine_datasets"],[{binding:"ANALYTICS",dataset:"ANALYTICS"}])},P=e=>{if(typeof e=="string")return e;const a={};return e.diskMb!==void 0&&(a.disk_mb=e.diskMb),e.memoryMib!==void 0&&(a.memory_mib=e.memoryMib),e.vcpu!==void 0&&(a.vcpu=e.vcpu),a},R=e=>e.image.kind==="dockerfile"?e.image.dockerfilePath:e.image.kind==="registry"?e.image.reference:N(e.exportName),T=e=>{const a={class_name:e.className,image:R(e)};return e.image.kind==="dockerfile"&&(a.image_build_context=e.image.buildContext),e.buildArgs!==void 0&&e.image.kind!=="registry"&&(a.image_vars=e.buildArgs),e.instanceType!==void 0&&(a.instance_type=P(e.instanceType)),e.maxInstances!==void 0&&(a.max_instances=e.maxInstances),e.name!==void 0&&(a.name=e.name),e.rollout?.stepPercentage!==void 0&&(a.rollout_step_percentage=e.rollout.stepPercentage),e.rollout?.gracePeriodSeconds!==void 0&&(a.rollout_active_grace_period=e.rollout.gracePeriodSeconds),a},$=(e,a,n)=>{const s=a.containers??[],r=new Set(s.map(c=>c.class_name)),d=n.filter(c=>!r.has(c.className));if(d.length===0)return{added:[],text:e};const o=b(e,["containers"],[...s,...d.map(c=>T(c))]);return{added:d.map(c=>`containers/${c.className}`),text:o}},q=(e,a)=>{if(a.observability!==void 0)return{added:[],text:e};const n=b(e,["observability"],{enabled:!0,head_sampling_rate:1});return{added:["observability"],text:n}},G=e=>({binding:e.bindingName,class_name:e.className,name:e.name}),L=e=>({binding:e.bindingName,class_name:e.className,name:e.name}),W=(e,a,n,s=[])=>{const r=a.workflows??[],d=new Set(r.map(l=>l.class_name)),o=n.filter(l=>!d.has(l.className)),c=s.filter(l=>!d.has(l.className));if(o.length===0&&c.length===0)return{added:[],text:e};const g=b(e,["workflows"],[...r,...o.map(l=>G(l)),...c.map(l=>L(l))]);return{added:[...o.map(l=>`workflows/${l.className}`),...c.map(l=>`workflows/${l.className}`)],text:g}},M=(e,a,n)=>{const s=a.queues??{},r=s.producers??[],d=s.consumers??[],o=new Set(r.map(i=>i.binding)),c=new Set(d.map(i=>i.queue)),g=n.filter(i=>!o.has(i.bindingName)),l=n.filter(i=>!c.has(i.name));if(g.length===0&&l.length===0)return{added:[],text:e};const h=[...r,...g.map(i=>({binding:i.bindingName,queue:i.name}))],u=[...d,...l.map(i=>{const p={queue:i.name};return i.mode==="pull"&&(p.type="http_pull"),i.tuning.maxBatchSize!==void 0&&(p.max_batch_size=i.tuning.maxBatchSize),i.tuning.maxBatchTimeout!==void 0&&(p.max_batch_timeout=i.tuning.maxBatchTimeout),i.tuning.maxRetries!==void 0&&(p.max_retries=i.tuning.maxRetries),i.tuning.deadLetterQueue!==void 0&&(p.dead_letter_queue=i.tuning.deadLetterQueue),i.tuning.retryDelay!==void 0&&(p.retry_delay=i.tuning.retryDelay),p})],m=b(e,["queues"],{consumers:u,producers:h});return{added:[...g.map(i=>`queues.producers/${i.bindingName}`),...l.map(i=>`queues.consumers/${i.name}`)],text:m}},z=(e,a)=>{const n=S(e),s=B(a);if(!n)return{added:[],changed:!1,exportGaps:s,reason:"wrangler.jsonc not found",warnings:x(a)};const{parsed:r,text:d}=k(n);if(r===void 0)return{added:[],changed:!1,exportGaps:s,reason:`failed to parse ${n} as JSONC`,warnings:x(a),wranglerPath:n};const o=x(a,r),c=a.containers.filter(t=>t.exported),g=a.agents.filter(t=>t.exported&&t.voice===!0&&t.voiceBindingName!==void 0&&t.voiceClassName!==void 0),l=[...a.durableObjects,...c.map(t=>({binding:t.bindingName,className:t.className})),...g.map(t=>({binding:t.voiceBindingName,className:t.voiceClassName}))],h=a.workflows.filter(t=>t.exported),u=a.agents.filter(t=>t.exported),m=[{enabled:!0,run:t=>I(t,r,l)},{enabled:a.needsD1,run:t=>O(t,r)},{enabled:a.usesAi,run:t=>v(t,r,"ai","AI","AI (Workers AI)")},{enabled:a.usesBrowser,run:t=>v(t,r,"browser","BROWSER","BROWSER (Browser Rendering)")},{enabled:a.usesImages,run:t=>v(t,r,"images","IMAGES","IMAGES (Cloudflare Images)")},{enabled:a.usesAnalytics,run:t=>C(t,r)},{enabled:!0,run:t=>q(t,r)},{enabled:c.length>0,run:t=>$(t,r,c)},{enabled:h.length>0||u.length>0,run:t=>W(t,r,h,u)},{enabled:a.queues.length>0,run:t=>M(t,r,a.queues)}];let i=d;const p=[];for(const t of m){if(!t.enabled)continue;const _=t.run(i);i=_.text,p.push(..._.added)}return p.includes("DB (D1)")&&o.push(`wrote a DB binding with a placeholder database_id ("${w}") — run \`wrangler d1 create <name>\` and replace it before deploying.`),i===d?{added:[],changed:!1,exportGaps:s,reason:"bindings already in sync",warnings:o,wranglerPath:n}:(y(n,i,"utf8"),{added:p,changed:!0,exportGaps:s,warnings:o,wranglerPath:n})};export{z as reconcileWranglerBindings};