@lunora/config 1.0.0-alpha.38 → 1.0.0-alpha.381

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/LICENSE.md +135 -0
  2. package/README.md +3 -3
  3. package/dist/cli/index.d.mts +2 -0
  4. package/dist/cli/index.d.ts +2 -0
  5. package/dist/cli/index.mjs +1 -0
  6. package/dist/cloudflare/index.d.mts +1306 -0
  7. package/dist/cloudflare/index.d.ts +1306 -0
  8. package/dist/cloudflare/index.mjs +1 -0
  9. package/dist/index.d.mts +845 -974
  10. package/dist/index.d.ts +845 -974
  11. package/dist/index.mjs +1 -23
  12. package/dist/packem_shared/ACCENT-CotPTfv7.mjs +7 -0
  13. package/dist/packem_shared/AGENT_MODE_ENV-D8MvSwPE.mjs +1 -0
  14. package/dist/packem_shared/AGENT_RULES_DIR-Bd6JPtNa.mjs +1 -0
  15. package/dist/packem_shared/ALLOW_FORWARDED_ENV-BUndghJx.mjs +1 -0
  16. package/dist/packem_shared/BINDING_MANIFEST_VERSION-CfXEYG8e.mjs +1 -0
  17. package/dist/packem_shared/CLOUDFLARE_CLI_CONFIG_WARNING_ENV-BKMrOuXV.mjs +1 -0
  18. package/dist/packem_shared/CLOUDFLARE_DRIVER-CULavrYO.mjs +1 -0
  19. package/dist/packem_shared/CLOUDFLARE_TOOLCHAIN_VERSIONS-DV5E_f_q.mjs +1 -0
  20. package/dist/packem_shared/CODEGEN_ENV-CkUo3_GU.mjs +1 -0
  21. package/dist/packem_shared/COMPOSED_WORKER_ENTRY-Ciiba5g_.mjs +1 -0
  22. package/dist/packem_shared/DEFAULT_DEPLOY_TARGET-rR7buNQw.mjs +1 -0
  23. package/dist/packem_shared/DEFAULT_OBSERVABILITY-bN6UkTMx.mjs +1 -0
  24. package/dist/packem_shared/DEV_BINDINGS_FILE-C0ZN_XlP.mjs +4 -0
  25. package/dist/packem_shared/DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs +6 -0
  26. package/dist/packem_shared/DEV_WORKER_ENV_VALUE-2XFXmRrP.mjs +1 -0
  27. package/dist/packem_shared/GLOBAL_FETCH_STRICTLY_PUBLIC_FLAG-f8CnJha3.mjs +1 -0
  28. package/dist/packem_shared/HYPERDRIVE_PLACEHOLDER_ID-DZn1Fk4-.mjs +2 -0
  29. package/dist/packem_shared/LINKED_PROJECT_DIR-Ba5qPEwo.mjs +2 -0
  30. package/dist/packem_shared/LUNORA_EVENT_SOURCE-B9ZVohjO.mjs +1 -0
  31. package/dist/packem_shared/LUNORA_IGNORED_PATHS-U93uPxrW.mjs +19 -0
  32. package/dist/packem_shared/LUNORA_TAG-DQTGPqcJ.mjs +1 -0
  33. package/dist/packem_shared/LunoraReporter-f277GLNT.mjs +6 -0
  34. package/dist/packem_shared/PACKAGE_SECRETS_REGISTRY-38Plje8b.mjs +1 -0
  35. package/dist/packem_shared/POLICY_SCAFFOLD_ENDPOINT-BlERq9JI.mjs +1 -0
  36. package/dist/packem_shared/REMOTE_ELIGIBLE_KEYS-DnbYTTWX.mjs +1 -0
  37. package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-D4UcOP_t.mjs +1 -0
  38. package/dist/packem_shared/SCHEMA_EDIT_ENDPOINT-DXjL7k72.mjs +1 -0
  39. package/dist/packem_shared/SEED_ENDPOINT-2B56PN_H.mjs +1 -0
  40. package/dist/packem_shared/STUDIO_PATH-CTsEIa6_.mjs +1 -0
  41. package/dist/packem_shared/UNEXPORTED_CLASS_MARKER-mdcw5KDY.mjs +1 -0
  42. package/dist/packem_shared/WORKERS_CACHE_MIN_DATE-0k9ABJtF.mjs +1 -0
  43. package/dist/packem_shared/WRANGLER_FILES-UNW-xY5u.mjs +1 -0
  44. package/dist/packem_shared/acceptsConnection-DHhUYGjT.mjs +2 -0
  45. package/dist/packem_shared/addArgsFor-CYZKhNIo.mjs +1 -0
  46. package/dist/packem_shared/applyAdditiveEdit-CH0VhMJ2.mjs +6 -0
  47. package/dist/packem_shared/applyModify-DKP2l6S9.mjs +1 -0
  48. package/dist/packem_shared/applyStudioAssetCache-DHQEJuuv.mjs +1 -0
  49. package/dist/packem_shared/assertWranglerSatisfiesSchema-B4DcaiJY.mjs +3 -0
  50. package/dist/packem_shared/assetContentType-CUb5bpbI.mjs +1 -0
  51. package/dist/packem_shared/bindingsNeedingDatabase-6eD6Qtqf.mjs +3 -0
  52. package/dist/packem_shared/blockingFindingsMessage-BVbijPdn.mjs +1 -0
  53. package/dist/packem_shared/buildPackageSecretsBlock-BWV_VxqV.mjs +19 -0
  54. package/dist/packem_shared/celld-config-D-L6uskI.mjs +3 -0
  55. package/dist/packem_shared/classifyPolicyEdit-DJi9Fk8G.mjs +24 -0
  56. package/dist/packem_shared/createConfirm-D5mKTMHj.mjs +7 -0
  57. package/dist/packem_shared/createDiscoveryCache-npJI4uej.mjs +1 -0
  58. package/dist/packem_shared/deploy-driver.d-Cl96-c1l.d.mts +184 -0
  59. package/dist/packem_shared/deploy-driver.d-Cl96-c1l.d.ts +184 -0
  60. package/dist/packem_shared/describePreservedCrons-C5KPuPy3.mjs +1 -0
  61. package/dist/packem_shared/describeWithheld-CbyzZjZF.mjs +1 -0
  62. package/dist/packem_shared/detectFramework-Dfpvu6rD.mjs +1 -0
  63. package/dist/packem_shared/discover-info-DC2MrAIM.mjs +1 -0
  64. package/dist/packem_shared/discoverAgentInfo-pqFMJBtJ.mjs +1 -0
  65. package/dist/packem_shared/discoverContainerInfo-DzXr7Vm3.mjs +1 -0
  66. package/dist/packem_shared/discoverSchemaInfo-BBRlXZop.mjs +1 -0
  67. package/dist/packem_shared/discoverWorkflowInfo-zW7Tt0Tn.mjs +1 -0
  68. package/dist/packem_shared/guards-Buu_E7mP.mjs +1 -0
  69. package/dist/packem_shared/hasCloudflareCredentials-CNPVIVBb.mjs +1 -0
  70. package/dist/packem_shared/index.d-Cmx4jMFV.d.ts +270 -0
  71. package/dist/packem_shared/index.d-DkNi7r6E.d.mts +270 -0
  72. package/dist/packem_shared/infer-bindings.d-Dp1zxdUZ.d.mts +298 -0
  73. package/dist/packem_shared/infer-bindings.d-Dp1zxdUZ.d.ts +298 -0
  74. package/dist/packem_shared/inferLunoraBindings-CH8xwMCn.mjs +1 -0
  75. package/dist/packem_shared/interpretRemote-CcmGeGZ_.mjs +1 -0
  76. package/dist/packem_shared/lunora-manifest-DuH_Cmyu.mjs +6 -0
  77. package/dist/packem_shared/materializeServiceDevConfigs-k_oLCcBT.mjs +1 -0
  78. package/dist/packem_shared/mergeWranglerEnvironment-D5ekKj5x.mjs +1 -0
  79. package/dist/packem_shared/package-secrets-registry-BeheNwsP.mjs +1 -0
  80. package/dist/packem_shared/parseDevVariable-teAAahVD.mjs +1 -0
  81. package/dist/packem_shared/parseSchema-D1Wbr1qv.mjs +1 -0
  82. package/dist/packem_shared/policy-scaffold.d-D2H4_G01.d.mts +86 -0
  83. package/dist/packem_shared/policy-scaffold.d-D2H4_G01.d.ts +86 -0
  84. package/dist/packem_shared/process-tree-once-Ou4SfxKM.mjs +1 -0
  85. package/dist/packem_shared/readProjectDependencies-l3uhUKjo.mjs +1 -0
  86. package/dist/packem_shared/reconcile-services-DFqH4eMQ.mjs +1 -0
  87. package/dist/packem_shared/reconcileBindingsSafely-D9H8UIvK.mjs +1 -0
  88. package/dist/packem_shared/reconcileWranglerCompatibilityDate-hocXEuRA.mjs +1 -0
  89. package/dist/packem_shared/renderStudioHtml-ByowDtMl.mjs +15 -0
  90. package/dist/packem_shared/resolveSchemaDirectory-Ca5P6KuP.mjs +1 -0
  91. package/dist/packem_shared/runPostCodegenHook-Dx3yTsYZ.mjs +1 -0
  92. package/dist/packem_shared/scanWranglerVariablesForSecrets-BFTVje1q.mjs +1 -0
  93. package/dist/packem_shared/serveJsonHandler-Dv0EdCb9.mjs +1 -0
  94. package/dist/packem_shared/startCelldDevSession-BLFsd6jG.mjs +1 -0
  95. package/dist/packem_shared/streamContainerLogs-0nko1qpv.mjs +2 -0
  96. package/dist/packem_shared/validate-bindings-PVHSAU6M.mjs +1 -0
  97. package/dist/packem_shared/withTailConsumer-CF3pk_Ov.mjs +1 -0
  98. package/dist/packem_shared/worker-entry-checks-AIASCYl7.mjs +1 -0
  99. package/dist/packem_shared/wranglerCodegenInputs-CbisphsH.mjs +1 -0
  100. package/dist/packem_shared/wranglerToAlchemy-CBO2ucRm.mjs +6 -0
  101. package/dist/packem_shared/write-atomic-CY97nWi1.mjs +1 -0
  102. package/dist/studio-host/index.d.mts +320 -110
  103. package/dist/studio-host/index.d.ts +320 -110
  104. package/dist/studio-host/index.mjs +1 -7
  105. package/package.json +32 -7
  106. package/dist/packem_shared/ACCENT-DW1XJn8i.mjs +0 -40
  107. package/dist/packem_shared/AGENT_RULES_DIR-lcgC08aE.mjs +0 -40
  108. package/dist/packem_shared/DEV_VARS_EXAMPLE_FILE-dJPNTEnK.mjs +0 -37
  109. package/dist/packem_shared/LINKED_PROJECT_DIR-CXwXzV_C.mjs +0 -52
  110. package/dist/packem_shared/LUNORA_CONFIG_FILE-CtcIcB5-.mjs +0 -34
  111. package/dist/packem_shared/LUNORA_EVENT_SOURCE-D2fDeGB6.mjs +0 -86
  112. package/dist/packem_shared/LunoraReporter-Ci-bDCK9.mjs +0 -70
  113. package/dist/packem_shared/PACKAGE_SECRETS_REGISTRY-B8t_SdoZ.mjs +0 -70
  114. package/dist/packem_shared/POLICY_SCAFFOLD_ENDPOINT-CiC2IGKx.mjs +0 -103
  115. package/dist/packem_shared/REMOTE_ELIGIBLE_KEYS-BC7_e9Bz.mjs +0 -105
  116. package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-2YYyWJUq.mjs +0 -561
  117. package/dist/packem_shared/SCHEMA_EDIT_ENDPOINT-Df-Wrix-.mjs +0 -99
  118. package/dist/packem_shared/SEED_ENDPOINT-DVCjaGO-.mjs +0 -61
  119. package/dist/packem_shared/WRANGLER_FILES-DwSuC-Kn.mjs +0 -25
  120. package/dist/packem_shared/applyAdditiveEdit-C-snTFEV.mjs +0 -228
  121. package/dist/packem_shared/buildPackageSecretsBlock-BCHtfQ2A.mjs +0 -280
  122. package/dist/packem_shared/classifyPolicyEdit-BHeAqF8P.mjs +0 -99
  123. package/dist/packem_shared/createConfirm-fvpdgJ9s.mjs +0 -100
  124. package/dist/packem_shared/detectFramework-Br-BcPBq.mjs +0 -41
  125. package/dist/packem_shared/discoverContainerInfo-BXFs6Wav.mjs +0 -19
  126. package/dist/packem_shared/discoverSchemaInfo-BB-CKlTK.mjs +0 -25
  127. package/dist/packem_shared/discoverWorkflowInfo-CedvR0mn.mjs +0 -19
  128. package/dist/packem_shared/inferLunoraBindings-ByMwG-gH.mjs +0 -352
  129. package/dist/packem_shared/loadStudioAssets-Csk5RS4E.mjs +0 -28
  130. package/dist/packem_shared/parseDevVariable-CJiq2IwE.mjs +0 -30
  131. package/dist/packem_shared/parseSchema-DSeyktvG.mjs +0 -107
  132. package/dist/packem_shared/policy-scaffold.d-DCmwn7zQ.d.mts +0 -74
  133. package/dist/packem_shared/policy-scaffold.d-DCmwn7zQ.d.ts +0 -74
  134. package/dist/packem_shared/reconcileWranglerBindings-Cruwwx1M.mjs +0 -334
  135. package/dist/packem_shared/renderStudioHtml-449Ysn75.mjs +0 -37
  136. package/dist/packem_shared/serveJsonHandler-B4OLTGLS.mjs +0 -86
  137. package/dist/packem_shared/streamContainerLogs-BZ4cOZwH.mjs +0 -157
package/dist/index.mjs CHANGED
@@ -1,23 +1 @@
1
- export { AGENT_RULES_DIR, AGENT_RULES_HINT, AGENT_RULES_HINT_ENV, LUNORA_SKILL_NAMES, ROOT_SKILL_NAME, claimAgentRulesHint, detectAgentRules } from './packem_shared/AGENT_RULES_DIR-lcgC08aE.mjs';
2
- export { discoverContainerInfo } from './packem_shared/discoverContainerInfo-BXFs6Wav.mjs';
3
- export { streamContainerLogs } from './packem_shared/streamContainerLogs-BZ4cOZwH.mjs';
4
- export { detectFramework } from './packem_shared/detectFramework-Br-BcPBq.mjs';
5
- export { DEV_VARS_EXAMPLE_FILE, DEV_VARS_FILE, DEV_VARS_KEY_PATTERN, parseDevVariableEntries } from './packem_shared/DEV_VARS_EXAMPLE_FILE-dJPNTEnK.mjs';
6
- export { inferLunoraBindings, packageNamesFromBindings } from './packem_shared/inferLunoraBindings-ByMwG-gH.mjs';
7
- export { LINKED_PROJECT_DIR, LINKED_PROJECT_FILE, readLinkedProject, writeLinkedProject } from './packem_shared/LINKED_PROJECT_DIR-CXwXzV_C.mjs';
8
- export { LUNORA_EVENT_SOURCE, formatLunoraEvent } from './packem_shared/LUNORA_EVENT_SOURCE-D2fDeGB6.mjs';
9
- export { default as LunoraReporter } from './packem_shared/LunoraReporter-Ci-bDCK9.mjs';
10
- export { PACKAGE_SECRETS_REGISTRY, secretsForPackages } from './packem_shared/PACKAGE_SECRETS_REGISTRY-B8t_SdoZ.mjs';
11
- export { LUNORA_CONFIG_FILE, interpretRemote, readProjectRemotePreference } from './packem_shared/LUNORA_CONFIG_FILE-CtcIcB5-.mjs';
12
- export { createConfirm, isInteractive, promptMultiSelect, promptSelect, promptYesNo } from './packem_shared/createConfirm-fvpdgJ9s.mjs';
13
- export { reconcileWranglerBindings } from './packem_shared/reconcileWranglerBindings-Cruwwx1M.mjs';
14
- export { REMOTE_ELIGIBLE_KEYS, injectRemoteFlags, isRemoteEnvEnabled, materializeRemoteWranglerConfig, planRemoteBindings, resolveRemoteEnabled } from './packem_shared/REMOTE_ELIGIBLE_KEYS-BC7_e9Bz.mjs';
15
- export { buildPackageSecretsBlock, ensureDevVariables, ensureDevVarsExample, fillDevSecrets, generateSecretValue, isMintableSecretKey, isPlaceholderValue, planDevSecretsFill, planDevVariablesAugment, planDevVariablesScaffold, requiredSecrets } from './packem_shared/buildPackageSecretsBlock-BCHtfQ2A.mjs';
16
- export { applyAdditiveEdit, classifyEdit } from './packem_shared/applyAdditiveEdit-C-snTFEV.mjs';
17
- export { parseSchema } from './packem_shared/parseSchema-DSeyktvG.mjs';
18
- export { classifyPolicyEdit, scaffoldPolicyFile, wireRlsIntoProcedure } from './packem_shared/classifyPolicyEdit-BHeAqF8P.mjs';
19
- export { discoverSchemaInfo } from './packem_shared/discoverSchemaInfo-BB-CKlTK.mjs';
20
- export { ACCENT, BADGES, BADGE_COLUMN_WIDTH, LUNA_ART, LUNA_BUNNY, LUNA_NAME, LUNA_SIGNOFF, STEP_BADGE_NAMES, badgeLead, badgeWidth, padBadge, paintAnswer, paintBadge } from './packem_shared/ACCENT-DW1XJn8i.mjs';
21
- export { discoverWorkflowInfo } from './packem_shared/discoverWorkflowInfo-CedvR0mn.mjs';
22
- export { WRANGLER_FILES, findWranglerFile, readWranglerJsonc } from './packem_shared/WRANGLER_FILES-DwSuC-Kn.mjs';
23
- export { REQUIRED_COMPATIBILITY_DATE, REQUIRED_FLAG, validateWrangler, validateWranglerConfig, validateWranglerProject, withTailConsumer } from './packem_shared/REQUIRED_COMPATIBILITY_DATE-2YYyWJUq.mjs';
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-pqFMJBtJ.mjs";import{AGENT_RULES_DIR as i,AGENT_RULES_HINT as n,AGENT_RULES_HINT_ENV as _,LUNORA_SKILL_NAMES as c,ROOT_SKILL_NAME as l,claimAgentRulesHint as p,detectAgentRules as d}from"./packem_shared/AGENT_RULES_DIR-Bd6JPtNa.mjs";import{startCelldDevSession as m}from"./packem_shared/startCelldDevSession-BLFsd6jG.mjs";import{CODEGEN_ENV as S,LAZY_FUNCTIONS_ENV as f,isCodegenDisabled as L,isLazyFunctionsEnabled as v,resolveLazyFunctions as N}from"./packem_shared/CODEGEN_ENV-CkUo3_GU.mjs";import{discoverContainerInfo as T}from"./packem_shared/discoverContainerInfo-DzXr7Vm3.mjs";import{streamContainerLogs as x}from"./packem_shared/streamContainerLogs-0nko1qpv.mjs";import{detectFramework as I,projectUsesUmbrella as O}from"./packem_shared/detectFramework-Dfpvu6rD.mjs";import{acceptsConnection as P,startDevProcess as F}from"./packem_shared/acceptsConnection-DHhUYGjT.mjs";import{DEV_BINDINGS_FILE as U,DEV_DAEMON_ENV as M,DEV_HANDOFF_ENV as G,DEV_LOG_FILE as b,DEV_LOG_FILE_ENV as y,DEV_STATE_DIR as B,DEV_STATE_FILE as k,claimDevServerState as j,clearDevServerState as K,isDevServerReady as h,isProcessAlive as w,isRecordedProcessCurrent as H,readDevServerState as W,readLiveDevServerState as Y,updateDevServerState as J,writeDevServerState as z}from"./packem_shared/DEV_BINDINGS_FILE-C0ZN_XlP.mjs";import{DEV_VARS_EXAMPLE_FILE as X,DEV_VARS_FILE as Z,DEV_VARS_KEY_PATTERN as Q,escapeRegExp as $,parseDevVariableEntries as ee,removeDevVariableLine as re,upsertDevVariableLine as oe}from"./packem_shared/DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{DEV_WORKER_ENV_VALUE as ae,DEV_WORKER_ENV_VAR as Ee,ensureDevWorkerEnv as se}from"./packem_shared/DEV_WORKER_ENV_VALUE-2XFXmRrP.mjs";import{createDiscoveryCache as ne}from"./packem_shared/createDiscoveryCache-npJI4uej.mjs";import{DEFAULT_DEPLOY_TARGET as ce,deployTargetIds as le,isRunnableTarget as pe,planToolchainInvocation as de,resolveDeployDriver as De,runnableTargetIds as me,targetRunsOwnDevServer as Ae}from"./packem_shared/DEFAULT_DEPLOY_TARGET-rR7buNQw.mjs";import{inferLunoraBindings as fe,secretSourcesFromBindings as Le}from"./packem_shared/inferLunoraBindings-CH8xwMCn.mjs";import{LINKED_PROJECT_DIR as Ne,LINKED_PROJECT_FILE as Re,readLinkedProject as Te,writeLinkedProject as ge}from"./packem_shared/LINKED_PROJECT_DIR-Ba5qPEwo.mjs";import{LUNORA_IGNORED_PATHS as Ve,applyLintIgnores as Ie,detectLintTools as Oe}from"./packem_shared/LUNORA_IGNORED_PATHS-U93uPxrW.mjs";import{blockingFindingsMessage as Pe,reportCodegenFindings as Fe}from"./packem_shared/blockingFindingsMessage-BVbijPdn.mjs";import{LUNORA_EVENT_SOURCE as Ue,formatLunoraEvent as Me}from"./packem_shared/LUNORA_EVENT_SOURCE-B9ZVohjO.mjs";import{LUNORA_TAG as be,advisoryLine as ye,lunoraLine as Be}from"./packem_shared/LUNORA_TAG-DQTGPqcJ.mjs";import{default as je}from"./packem_shared/LunoraReporter-f277GLNT.mjs";import{addArgsFor as he,detectInstalledManagers as we,detectPackageManager as He,execArgsFor as We,installArgsFor as Ye,runScriptArgsFor as Je,runScriptCommand as ze,toolchainExecArgs as qe}from"./packem_shared/addArgsFor-CYZKhNIo.mjs";import{P as Ze,s as Qe}from"./packem_shared/package-secrets-registry-BeheNwsP.mjs";import{runPostCodegenHook as er}from"./packem_shared/runPostCodegenHook-Dx3yTsYZ.mjs";import{interpretRemote as or,readProjectRemotePreference as tr,readProjectTarget as ar,resolveProjectTarget as Er,resolveTargetOrThrow as sr}from"./packem_shared/interpretRemote-CcmGeGZ_.mjs";import{readProjectDependencies as nr,readProjectDependencyNames as _r,readProjectManifest as cr}from"./packem_shared/readProjectDependencies-l3uhUKjo.mjs";import{createConfirm as pr,isInteractive as dr,promptMultiSelect as Dr,promptSelect as mr,promptText as Ar,promptYesNo as Sr}from"./packem_shared/createConfirm-D5mKTMHj.mjs";import{default as Lr}from"./packem_shared/resolveSchemaDirectory-Ca5P6KuP.mjs";import{buildPackageSecretsBlock as Nr,ensureDevVariables as Rr,ensureDevVarsExample as Tr,fillDevSecrets as gr,generateSecretValue as xr,isMintableSecretKey as Vr,isPlaceholderValue as Ir,planDevSecretsFill as Or,planDevVariablesAugment as ur,planDevVariablesScaffold as Pr,requiredSecrets as Fr,writeDevVariablesFileAtomically as Cr}from"./packem_shared/buildPackageSecretsBlock-BWV_VxqV.mjs";import{applyAdditiveEdit as Mr,classifyEdit as Gr}from"./packem_shared/applyAdditiveEdit-CH0VhMJ2.mjs";import{parseSchema as yr}from"./packem_shared/parseSchema-D1Wbr1qv.mjs";import{classifyPolicyEdit as kr,resolveServerModule as jr,scaffoldPolicyFile as Kr,wireRlsIntoProcedure as hr}from"./packem_shared/classifyPolicyEdit-DJi9Fk8G.mjs";import{discoverSchemaInfo as Hr}from"./packem_shared/discoverSchemaInfo-BBRlXZop.mjs";import{ACCENT as Yr,BADGES as Jr,BADGE_COLUMN_WIDTH as zr,LUNA_ART as qr,LUNA_BUNNY as Xr,LUNA_NAME as Zr,LUNA_SIGNOFF as Qr,STEP_BADGE_NAMES as $r,badgeLead as eo,badgeWidth as ro,padBadge as oo,paintAnswer as to,paintBadge as ao}from"./packem_shared/ACCENT-CotPTfv7.mjs";import{COMPOSED_WORKER_ENTRY as so,DURABLE_OBJECT_BINDINGS as io,GENERATED_CLASS_MODULES as no,GENERATED_MODULE_DURABLE_OBJECTS as _o,MERGED_DURABLE_OBJECTS_MODULE as co,isMergedProject as lo,isMergedRoleModule as po}from"./packem_shared/COMPOSED_WORKER_ENTRY-Ciiba5g_.mjs";import{discoverWorkflowInfo as mo}from"./packem_shared/discoverWorkflowInfo-zW7Tt0Tn.mjs";export{Yr as ACCENT,o as AGENT_MODE_ENV,i as AGENT_RULES_DIR,n as AGENT_RULES_HINT,_ as AGENT_RULES_HINT_ENV,Jr as BADGES,zr as BADGE_COLUMN_WIDTH,S as CODEGEN_ENV,so as COMPOSED_WORKER_ENTRY,ce as DEFAULT_DEPLOY_TARGET,U as DEV_BINDINGS_FILE,M as DEV_DAEMON_ENV,G as DEV_HANDOFF_ENV,b as DEV_LOG_FILE,y as DEV_LOG_FILE_ENV,B as DEV_STATE_DIR,k as DEV_STATE_FILE,X as DEV_VARS_EXAMPLE_FILE,Z as DEV_VARS_FILE,Q as DEV_VARS_KEY_PATTERN,ae as DEV_WORKER_ENV_VALUE,Ee as DEV_WORKER_ENV_VAR,io as DURABLE_OBJECT_BINDINGS,no as GENERATED_CLASS_MODULES,_o as GENERATED_MODULE_DURABLE_OBJECTS,f as LAZY_FUNCTIONS_ENV,Ne as LINKED_PROJECT_DIR,Re as LINKED_PROJECT_FILE,qr as LUNA_ART,Xr as LUNA_BUNNY,Zr as LUNA_NAME,Qr as LUNA_SIGNOFF,Ue as LUNORA_EVENT_SOURCE,Ve as LUNORA_IGNORED_PATHS,c as LUNORA_SKILL_NAMES,be as LUNORA_TAG,je as LunoraReporter,co as MERGED_DURABLE_OBJECTS_MODULE,Ze as PACKAGE_SECRETS_REGISTRY,l as ROOT_SKILL_NAME,$r as STEP_BADGE_NAMES,P as acceptsConnection,he as addArgsFor,ye as advisoryLine,Mr as applyAdditiveEdit,Ie as applyLintIgnores,eo as badgeLead,ro as badgeWidth,Pe as blockingFindingsMessage,Nr as buildPackageSecretsBlock,p as claimAgentRulesHint,j as claimDevServerState,Gr as classifyEdit,kr as classifyPolicyEdit,K as clearDevServerState,pr as createConfirm,ne as createDiscoveryCache,le as deployTargetIds,d as detectAgentRules,t as detectAiAgent,I as detectFramework,we as detectInstalledManagers,Oe as detectLintTools,He as detectPackageManager,E as discoverAgentInfo,T as discoverContainerInfo,Hr as discoverSchemaInfo,mo as discoverWorkflowInfo,Rr as ensureDevVariables,Tr as ensureDevVarsExample,se as ensureDevWorkerEnv,$ as escapeRegExp,We as execArgsFor,gr as fillDevSecrets,Me as formatLunoraEvent,xr as generateSecretValue,fe as inferLunoraBindings,Ye as installArgsFor,or as interpretRemote,L as isCodegenDisabled,h as isDevServerReady,dr as isInteractive,v as isLazyFunctionsEnabled,lo as isMergedProject,po as isMergedRoleModule,Vr as isMintableSecretKey,Ir as isPlaceholderValue,w as isProcessAlive,H as isRecordedProcessCurrent,pe as isRunnableTarget,Be as lunoraLine,oo as padBadge,to as paintAnswer,ao as paintBadge,ee as parseDevVariableEntries,yr as parseSchema,Or as planDevSecretsFill,ur as planDevVariablesAugment,Pr as planDevVariablesScaffold,de as planToolchainInvocation,O as projectUsesUmbrella,Dr as promptMultiSelect,mr as promptSelect,Ar as promptText,Sr as promptYesNo,W as readDevServerState,Te as readLinkedProject,Y as readLiveDevServerState,nr as readProjectDependencies,_r as readProjectDependencyNames,cr as readProjectManifest,tr as readProjectRemotePreference,ar as readProjectTarget,re as removeDevVariableLine,Fe as reportCodegenFindings,Fr as requiredSecrets,De as resolveDeployDriver,N as resolveLazyFunctions,Er as resolveProjectTarget,Lr as resolveSchemaDirectory,jr as resolveServerModule,sr as resolveTargetOrThrow,er as runPostCodegenHook,Je as runScriptArgsFor,ze as runScriptCommand,me as runnableTargetIds,Kr as scaffoldPolicyFile,Le as secretSourcesFromBindings,Qe as secretsForPackages,m as startCelldDevSession,F as startDevProcess,x as streamContainerLogs,Ae as targetRunsOwnDevServer,qe as toolchainExecArgs,J as updateDevServerState,oe as upsertDevVariableLine,hr as wireRlsIntoProcedure,z as writeDevServerState,Cr as writeDevVariablesFileAtomically,ge as writeLinkedProject};
@@ -0,0 +1,7 @@
1
+ import o from"@visulima/colorize";const g="#a855f7",e="#0b0b0b",s=["lunora","dir","tmpl","add","deps","git","next"],x={add:{bg:g,fg:e,text:"add"},debug:{bg:"#6b7280",fg:"#f3f4f6",text:"debug"},deps:{bg:g,fg:e,text:"deps"},dir:{bg:g,fg:e,text:"dir"},error:{bg:"#ef4444",fg:e,text:"error"},git:{bg:"#f59e0b",fg:e,text:"git"},info:{bg:"#3b82f6",fg:e,text:"info"},lunora:{bg:"#22c55e",fg:e,text:"lunora"},next:{bg:"#06b6d4",fg:e,text:"next"},success:{bg:"#22c55e",fg:e,text:"ok"},tmpl:{bg:g,fg:e,text:"tmpl"},warn:{bg:"#f59e0b",fg:e,text:"warn"}},c="Luna",i="Safe travels, voyager.",n=String.raw`
2
+ .-"""""-.
3
+ / (\(\ \
4
+ | ( -.-) |
5
+ \ o(")(") /
6
+ '-._____.-'`,_=n.startsWith(`
7
+ `)?n.slice(1):n,b=6,a=t=>` ${t} `,f=t=>" ".repeat(Math.max(0,b-t.length)),r=b+2,A=t=>r,N=t=>f(t.text)+o.bgHex(t.bg).hex(t.fg).bold(a(t.text)),l=t=>o.dim(t);export{g as ACCENT,x as BADGES,r as BADGE_COLUMN_WIDTH,_ as LUNA_ART,n as LUNA_BUNNY,c as LUNA_NAME,i as LUNA_SIGNOFF,s as STEP_BADGE_NAMES,f as badgeLead,A as badgeWidth,a as padBadge,l as paintAnswer,N as paintBadge};
@@ -0,0 +1 @@
1
+ import{detectAiSession as n}from"@visulima/find-ai-runner";const i="LUNORA_AGENT_MODE",r=o=>{const e=o.trim().toLowerCase();return e==="0"||e==="false"},a=(o=process.env)=>{const e=o[i];if(e!==void 0&&e!=="")return r(e)?void 0:{name:"agent (forced)",variable:i};const t=n(o);return t===void 0?void 0:{name:t.agent,variable:t.signal}};export{i as AGENT_MODE_ENV,a as detectAiAgent};
@@ -0,0 +1 @@
1
+ import{existsSync as s}from"node:fs";import{join as t}from"node:path";import{c as a}from"./process-tree-once-Ou4SfxKM.mjs";const u=".agents/skills",i="LUNORA_RULES_HINT_SHOWN",c=["lunora","lunora-quickstart","lunora-functions","lunora-realtime","lunora-setup-auth","lunora-setup-hyperdrive","lunora-setup-hyperdrive-global","lunora-setup-mail","lunora-setup-scheduler","lunora-setup-storage","lunora-create-package","lunora-migration-helper","lunora-deploy","lunora-performance-audit","lunora-cloudflare-audit"],p="lunora",d="Lunora AI rules not installed — run `lunora rules install` so your coding agent knows how to use Lunora.",N=()=>a(i),l=(n,o)=>t(n,u,o,"SKILL.md"),g=n=>{const o=[],r=[];for(const e of c)s(l(n,e))?o.push(e):r.push(e);return{installed:s(l(n,p)),missing:r,present:o}};export{u as AGENT_RULES_DIR,d as AGENT_RULES_HINT,i as AGENT_RULES_HINT_ENV,c as LUNORA_SKILL_NAMES,p as ROOT_SKILL_NAME,N as claimAgentRulesHint,g as detectAgentRules};
@@ -0,0 +1 @@
1
+ const i=e=>{const o=Array.isArray(e)?e[0]:e;return typeof o=="string"?o.trim().toLowerCase():void 0},d=e=>{if(e===void 0||e==="")return!0;const o=e.toLowerCase(),r=o.startsWith("::ffff:")?o.slice(7):o;return r==="::1"?!0:r.startsWith("127.")},a=e=>{if(e===void 0)return;if(e.startsWith("[")){const r=e.indexOf("]");return r===-1?e.slice(1):e.slice(1,r)}const o=e.indexOf(":");return o===-1?e:e.slice(0,o)},c=new Set(["0.0.0.0","127.0.0.1","::1","localhost"]),u=["x-forwarded-for","x-forwarded-host","x-forwarded-proto","forwarded"],n="LUNORA_STUDIO_ALLOW_FORWARDED",l=()=>process.env[n]==="1",f=(e,o)=>{if(!d(e.socket?.remoteAddress??void 0))return"Lunora studio is only available on loopback connections in dev.";const r=a(i(e.headers?.host));if(r!==void 0&&!c.has(r))return"Lunora studio rejects a non-localhost Host header in dev.";const t=u.find(s=>e.headers?.[s]!==void 0);if(t!==void 0&&!l())return o?.warnOnce?.(`[lunora] studio: refusing a request carrying the "${t}" header — this dev server is being reached through a proxy/tunnel (Codespaces, devcontainers, Gitpod, Cloud Workstations, ngrok, and Docker reverse proxies all add this). If this is YOUR trusted dev tunnel, set ${n}=1 to allow it.`),`Lunora studio refuses a proxied request in dev (saw the "${t}" header). If you're intentionally running behind a trusted dev tunnel/proxy (e.g. Codespaces, devcontainers, Gitpod, ngrok), set ${n}=1 to allow it.`};export{n as ALLOW_FORWARDED_ENV,i as headerValue,d as isLoopbackAddress,f as transportRejectionReason};
@@ -0,0 +1 @@
1
+ import{sqliteClasses as l}from"./wranglerToAlchemy-CBO2ucRm.mjs";const p=1,u=new Set(["$schema","account_id","compatibility_date","compatibility_flags","keep_vars","main","migrations","minify","name","observability","placement","routes","rules","secrets","triggers","upload_source_maps","vars","workers_dev"]),y=e=>Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0)),d=[{bindingKey:"binding",field:"ai_search",resourceKey:"instance_name",type:"ai_search"},{bindingKey:"binding",field:"ai_search_namespaces",resourceKey:"namespace",type:"ai_search_namespace"},{bindingKey:"binding",field:"analytics_engine_datasets",resourceKey:"dataset",type:"analytics_engine"},{bindingKey:"binding",field:"artifacts",resourceKey:"namespace",type:"artifacts"},{bindingKey:"class_name",field:"containers",resourceKey:"image",type:"container"},{bindingKey:"binding",field:"d1_databases",resourceIdKey:"database_id",resourceKey:"database_name",type:"d1"},{bindingKey:"binding",field:"hyperdrive",resourceIdKey:"id",type:"hyperdrive"},{bindingKey:"binding",field:"kv_namespaces",resourceIdKey:"id",type:"kv"},{bindingKey:"binding",field:"pipelines",resourceKey:["stream","pipeline"],type:"pipeline"},{bindingKey:"binding",field:"r2_buckets",resourceKey:"bucket_name",type:"r2"},{bindingKey:"binding",field:"services",resourceKey:"service",type:"service"},{bindingKey:"binding",field:"vectorize",resourceKey:"index_name",type:"vectorize"},{bindingKey:"binding",field:"vpc_networks",resourceIdKey:["tunnel_id","network_id"],type:"vpc_network"},{bindingKey:"binding",field:"vpc_services",resourceIdKey:"service_id",type:"vpc_service"},{bindingKey:"binding",field:"workflows",resourceKey:"name",type:"workflow"}],c=[{field:"ai",type:"ai"},{field:"analytics",type:"analytics_sql"},{field:"assets",type:"assets"},{field:"browser",type:"browser"},{field:"images",type:"images"},{field:"media",type:"media"},{field:"stream",type:"stream"}],b=new Set([...d.map(e=>e.field),...c.map(e=>e.field),"durable_objects","exports","queues"]),a=(e,n)=>(typeof n=="string"?[n]:n??[]).map(i=>e[i]).find(i=>typeof i=="string"&&i!==""),m=(e,n)=>{const s=[];for(const i of d)for(const r of e[i.field]??[]){const t=a(r,i.bindingKey);if(t===void 0){n.push(i.field);continue}s.push({binding:t,className:a(r,"class_name"),resource:a(r,i.resourceKey),resourceId:a(r,i.resourceIdKey),type:i.type})}return s},_=(e,n)=>{const s=l(e),i=[];for(const r of e.durable_objects?.bindings??[]){if(r.name===void 0||r.name===""){n.push("durable_objects");continue}i.push({binding:r.name,className:r.class_name,sqlite:r.script_name===void 0&&r.class_name!==void 0?s.has(r.class_name):void 0,type:"durable_object"})}return i},g=(e,n)=>{const s=[];for(const i of e.queues?.producers??[]){if(i.binding===void 0||i.binding===""){n.push("queues.producers");continue}s.push({binding:i.binding,resource:i.queue,type:"queue_producer"})}for(const i of e.queues?.consumers??[]){if(i.queue===void 0||i.queue===""){n.push("queues.consumers");continue}s.push({binding:i.queue,resource:i.queue,type:"queue_consumer"})}return s},f=(e,n)=>Object.entries(e.exports??{}).flatMap(([s,i])=>i?.type!=="workflow"?(n.push(`exports.${s}`),[]):[{binding:s,className:s,resource:i.name,type:"workflow"}]),v=(e,n,s)=>[...f(e,s),...m(e,n),..._(e,n),...g(e,n),...c.filter(i=>e[i.field]?.binding!==void 0).map(i=>({binding:e[i.field]?.binding,type:i.type}))],h=e=>{const n=[],s=[],i=v(e,n,s).map(t=>y(t)).toSorted((t,o)=>t.type.localeCompare(o.type)||t.binding.localeCompare(o.binding)),r=[...Object.keys(e).filter(t=>!u.has(t)&&!b.has(t)),...n.map(t=>`${t} (entry with no binding name)`),...s].toSorted((t,o)=>t.localeCompare(o));return{bindings:i,...e.compatibility_date===void 0?{}:{compatibilityDate:e.compatibility_date},...e.compatibility_flags===void 0?{}:{compatibilityFlags:e.compatibility_flags},crons:e.triggers?.crons??[],...e.name===void 0?{}:{name:e.name},unknown:r,vars:Object.keys(e.vars??{}).toSorted((t,o)=>t.localeCompare(o)),version:p}};export{p as BINDING_MANIFEST_VERSION,h as buildBindingManifest};
@@ -0,0 +1 @@
1
+ import{existsSync as c}from"node:fs";import{join as t,basename as f}from"node:path";import{i as l,c as d}from"./process-tree-once-Ou4SfxKM.mjs";import{findWranglerFile as u}from"./WRANGLER_FILES-UNW-xY5u.mjs";const m=["cloudflare.config.ts","cloudflare.config.mts","cloudflare.config.js","cloudflare.config.mjs"],g="https://github.com/anolilab/lunora/issues/964",s="LUNORA_CF_CONFIG_WARNING_SHOWN",C=o=>{const n=m.find(a=>c(t(o,a)));if(n===void 0)return;const e=u(o),r=e===void 0?void 0:f(e),i=r===void 0?"in the project root":`next to ${r}`;return{fix:`\`cf\` resource commands (zones, DNS, KV, …) are fine. Don't use \`cf dev\` / \`cf build\` / \`cf deploy\` on a Lunora project until Lunora supports \`cf\` — see ${g}.`,message:`${n} found ${i}. Lunora manages ${r??"the wrangler config"} and never updates a Cloudflare CLI (\`cf\`) config, so \`cf dev\` / \`cf build\` / \`cf deploy\` would run from a stale config, silently missing the bindings, Durable Object classes and migrations Lunora adds.`}},I=(o,n)=>{if(l(s))return!1;const e=C(o);return e===void 0||!d(s)?!1:(n(`${e.message} ${e.fix}`),!0)};export{s as CLOUDFLARE_CLI_CONFIG_WARNING_ENV,C as detectCloudflareCliConfig,I as warnCloudflareCliConfigOnce};
@@ -0,0 +1 @@
1
+ const r={devServer:"workerd",prebuildsContainerImages:!0,deploy:o=>{const n=o.preview===!0?["versions","upload"]:["deploy"];return o.entry!==void 0&&n.push(o.entry),o.configPath!==void 0&&n.push("--config",o.configPath),o.environment!==void 0&&n.push("--env",o.environment),o.temporary===!0&&n.push("--temporary"),o.dryRun===!0&&n.push("--dry-run"),o.outDir!==void 0&&n.push("--outdir",o.outDir,"--metafile"),{args:n,tool:"wrangler"}},dev:o=>{const n=["dev"];return o.configPath!==void 0&&n.push("--config",o.configPath),o.environment!==void 0&&n.push("--env",o.environment),n.push(...o.extraArgs??[]),{args:n,tool:"wrangler"}},secretList:o=>{const n=["secret","list","--format","json"];return o.environment!==void 0&&n.push("--env",o.environment),o.temporary===!0&&n.push("--temporary"),{args:n,tool:"wrangler"}},secretBulk:o=>{const n=["secret","bulk"];return o.environment!==void 0&&n.push("--env",o.environment),o.temporary===!0&&n.push("--temporary"),{args:n,tool:"wrangler"}},secretPut:o=>{const n=["secret","put",o.key??""];return o.environment!==void 0&&n.push("--env",o.environment),o.temporary===!0&&n.push("--temporary"),{args:n,tool:"wrangler"}},tail:o=>{const n=["tail"];return o.worker!==void 0&&n.push(o.worker),o.environment!==void 0&&n.push("--env",o.environment),o.format!==void 0&&n.push("--format",o.format),o.status!==void 0&&n.push("--status",o.status),o.search!==void 0&&n.push("--search",o.search),o.temporary===!0&&n.push("--temporary"),{args:n,tool:"wrangler"}}},i={id:"cloudflare",name:"Cloudflare",toolchain:r};export{i as default};
@@ -0,0 +1 @@
1
+ const e={"@cloudflare/vite-plugin":"^1.62.5","@cloudflare/workers-types":"^5.20261004.1",wrangler:"^4.147.0"};export{e as default};
@@ -0,0 +1 @@
1
+ const t="LUNORA_CODEGEN",n="LUNORA_LAZY_FUNCTIONS",r=e=>{const o=e?.trim().toLowerCase();return o==="0"||o==="false"},s=e=>{const o=e?.trim().toLowerCase();return o==="1"||o==="true"},c=e=>e===!0||s(process.env[n]);export{t as CODEGEN_ENV,n as LAZY_FUNCTIONS_ENV,r as isCodegenDisabled,s as isLazyFunctionsEnabled,c as resolveLazyFunctions};
@@ -0,0 +1 @@
1
+ import{existsSync as E,readFileSync as O}from"node:fs";import{parse as S}from"es-module-lexer";import{WRANGLER_FILES as m,readWranglerJsonc as f}from"./WRANGLER_FILES-UNW-xY5u.mjs";import{escapeRegExp as i}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{join as c}from"node:path";const g="_generated",x=["src/server.ts","src/server/index.ts","src/server/index.tsx","src/index.ts","src/worker.ts"],h=new Set(["build","coverage","dist",g,"node_modules","out","target"]),w=new Set([".client",".server"]),A=/[/\\]/u,L=t=>{const e=[];for(const r of t.split(A))r===""||r==="."||(r===".."&&e.length>0&&e.at(-1)!==".."?e.pop():e.push(r));return e},T=t=>L(t).slice(0,-1).some(e=>h.has(e)||e.startsWith(".")&&!w.has(e)),l={LunoraDO:"SHARD",SchedulerDO:"SCHEDULER",SessionDO:"SESSION",ShardDO:"SHARD",ShardRegistryDO:"SHARD_REGISTRY"},R=Object.keys(l),$=t=>Object.hasOwn(l,t),C="virtual:lunora/worker",d=["ShardDO"],J=["agents","containers","scheduler","shardRegistry","workflows"],u={scheduler:"SchedulerDO",shardRegistry:"ShardRegistryDO"},D="LunoraDO",y=new Set([...d,...Object.values(u)]),B="durableObjects",I=t=>E(c(t,`${B}.ts`)),W=t=>Object.hasOwn(u,t),F=t=>I(t)?[D]:[...d,...Object.entries(u).filter(([e])=>E(c(t,`${e}.ts`))).map(([,e])=>e)],N=t=>t.includes(D)?t.filter(e=>!y.has(e)):[...t],U="src/worker.ts",Y=t=>{for(const e of m){const r=c(t,e);if(!E(r))continue;const{parsed:s}=f(r),o=s?.main;if(o===C)return{composed:!0};const a=c(t,U);if(E(a))return{composed:!1,path:a};if(typeof o=="string"&&!T(o)&&E(c(t,o)))return{composed:!1,path:c(t,o)};break}for(const e of x){const r=c(t,e);if(E(r))return{composed:!1,path:r}}return{composed:!1}},M=/(?:^|[\s,{])type$/u,_=(t,e)=>{const r=e.ls>=0?e.ls:e.s;return M.test(t.slice(0,r).trimEnd())},b=(t,e)=>{const r=i(e);return new RegExp(String.raw`\bexport\s+type\s+${r}\b`,"u").test(t)||new RegExp(String.raw`\bexport\s+type\s*\{[^}]*\b${r}\b`,"u").test(t)||new RegExp(String.raw`\bexport\s+\{[^}]*\btype\s+${r}\b`,"u").test(t)},H=t=>{const e=O(t,"utf8");let r;try{const[,s]=S(e);r=new Set(s.filter(o=>!_(e,o)).map(o=>o.n))}catch{r=new Set(R.filter(s=>new RegExp(String.raw`\bexport\b[^\n;]*\b${s}\b`,"u").test(e)&&!b(e,s)))}return N(R.filter(s=>r.has(s))).map(s=>({binding:l[s],className:s}))},K=(t,e,r)=>{if(e.length===0)return[];if(t.composed)return e.map(n=>({...n,exported:!0}));if(t.path===void 0)return e.map(n=>({...n,exported:!1}));const s=O(t.path,"utf8"),o=new RegExp(String.raw`\bexport\s*\*\s*from\s*["'][^"']*_generated\/${r}(?:\.js)?["']`).test(s);let a;try{const[,n]=S(s);a=new Set(n.filter(p=>!_(s,p)).map(p=>p.n))}catch{a=new Set(e.map(n=>n.className).filter(n=>new RegExp(String.raw`\bexport\b[^\n;]*\b${i(n)}\b`,"u").test(s)&&!b(s,n)))}return e.map(n=>{const p=o||a.has(n.className);return{...n,exported:p}})};export{d as COMPOSED_ENTRY_DURABLE_OBJECTS,U as COMPOSED_WORKER_ENTRY,l as DURABLE_OBJECT_BINDINGS,J as GENERATED_CLASS_MODULES,g as GENERATED_DIRECTORY,u as GENERATED_MODULE_DURABLE_OBJECTS,C as LUNORA_WORKER_VIRTUAL_ID,D as MERGED_DURABLE_OBJECT,B as MERGED_DURABLE_OBJECTS_MODULE,y as MERGED_ROLE_DURABLE_OBJECTS,h as NON_SOURCE_DIRECTORIES,w as SOURCE_DOT_DIRECTORIES,x as WORKER_ENTRY_FALLBACKS,N as collapseMergedDurableObjects,F as composedEntryDurableObjects,K as detectClassExports,H as detectExportedDurableObjects,$ as isFrameworkDurableObject,T as isGeneratedOutput,I as isMergedProject,W as isMergedRoleModule,Y as resolveWorkerEntry};
@@ -0,0 +1 @@
1
+ import{p as a}from"./celld-config-D-L6uskI.mjs";import s from"./CLOUDFLARE_DRIVER-CULavrYO.mjs";const p=[["entry","`celld deploy` deploys the config's `main`; a composed framework entry has no celld equivalent yet"],["environment","celld has no Wrangler environments — deploy a separate config per environment"],["outDir","`celld deploy` does not write its bundle to disk"],["preview","celld has no preview versions — a deploy replaces the fleet's current deployment"],["temporary","celld has no short-lived accounts — it deploys to the fleet bucket in CELLD_BUCKET"]],l=e=>{if(e===void 0)throw new Error("the celld driver runs the projected wrangler config — pass `configPath` from `projectConfig`");return e},v={deploy:e=>{const o=p.find(([r])=>e[r]!==void 0&&e[r]!==!1);if(o!==void 0)throw new Error(o[1]);return{args:["deploy",l(e.configPath),...e.dryRun===!0?["--dry-run"]:[]],onPath:!0,tool:"celld"}},devServer:"own",prebuildsContainerImages:!1,dev:e=>{if(e.environment!==void 0)throw new Error("celld has no Wrangler environments — `celld dev` runs the top-level config");return{args:["dev",l(e.configPath),...e.extraArgs??[]],onPath:!0,tool:"celld"}}},f={id:"celld",name:"celld",projectConfig:a,toolchain:v},h={id:"node",name:"Node"},m="cloudflare",t={celld:f,cloudflare:s,node:h},d=()=>Object.keys(t).toSorted((e,o)=>e.localeCompare(o)),c=(e=m)=>{const o=t[e];if(o===void 0)throw new Error(`unknown deploy target "${e}" — available targets: ${d().join(", ")}`);return o},g=e=>Object.hasOwn(t,e)&&c(e).toolchain!==void 0,y=()=>d().filter(e=>g(e)),D=e=>c(e).toolchain?.devServer==="own",O=(e,o,r,i)=>{const n=e.projectConfig?.(o,r);return{command:i(n?.configPath),commit:()=>n?.write(),projection:n===void 0?void 0:{configPath:n.configPath,dropped:n.dropped}}};export{m as DEFAULT_DEPLOY_TARGET,d as deployTargetIds,g as isRunnableTarget,O as planToolchainInvocation,c as resolveDeployDriver,y as runnableTargetIds,D as targetRunsOwnDevServer};
@@ -0,0 +1 @@
1
+ const a=Object.freeze({enabled:!0,head_sampling_rate:1}),t=1,n=l=>{const e=l??a;return{logs:{enabled:e.logs?.enabled??e.enabled??a.enabled,headSamplingRate:e.logs?.head_sampling_rate??e.head_sampling_rate??t},traces:{enabled:e.traces?.enabled===!0,headSamplingRate:e.traces?.head_sampling_rate??t}}};export{a as DEFAULT_OBSERVABILITY,n as resolveObservabilitySampling};
@@ -0,0 +1,4 @@
1
+ import{mkdirSync as _,writeFileSync as E,rmSync as N,existsSync as D,readFileSync as a}from"node:fs";import{join as n}from"node:path";const u=".lunora",v=n(u,"dev.json"),h=n(u,"dev.log"),k=n(u,"dev-bindings.json"),T="LUNORA_DEV_DAEMON",U="LUNORA_DEV_LOG_FILE",x="LUNORA_DEV_HANDOFF_PID",m=r=>r!==null&&typeof r=="object",o=(r,e)=>{const t=r[e];return typeof t=="string"&&t.length>0?t:void 0},p=r=>{if(!Number.isInteger(r)||r<=0)return!1;try{return process.kill(r,0),!0}catch{return!1}},y=1e4,g=100,A=r=>{if(process.platform==="linux")try{const e=a(`/proc/${String(r)}/stat`,"utf8"),t=e.slice(e.lastIndexOf(")")+2).split(" "),i=Number(t[19]),s=a("/proc/stat","utf8").split(`
2
+ `).find(l=>l.startsWith("btime ")),d=Number(s?.slice(6));return!Number.isFinite(i)||!Number.isFinite(d)?void 0:d*1e3+i/g*1e3}catch{return}},b=r=>{if(!p(r.pid))return!1;const e=r.startedAt===void 0?Number.NaN:Date.parse(r.startedAt);if(Number.isNaN(e))return!0;const t=A(r.pid);return t===void 0||t<=e+y},f=r=>{const e=n(r,v);if(!D(e))return;let t;try{t=JSON.parse(a(e,"utf8"))}catch{return}if(!m(t)||typeof t.pid!="number")return;const i=o(t,"url");if(i!==void 0)return{background:t.background===!0,logFile:o(t,"logFile"),mode:t.mode==="vite"?"vite":"cli",pid:t.pid,readyAt:o(t,"readyAt"),startedAt:o(t,"startedAt"),studioUrl:o(t,"studioUrl"),tunnelUrl:o(t,"tunnelUrl"),url:i}},c=(r,e)=>{try{_(n(r,u),{recursive:!0});const t=n(r,v);return E(t,`${JSON.stringify(e,void 0,2)}
3
+ `,"utf8"),t}catch{return}},C=(r,e,t)=>{const i=f(r);if(i===void 0||t?.expectedPid!==void 0&&i.pid!==t.expectedPid)return;const s={...i,...e};return c(r,s),s},M=r=>r?.readyAt!==void 0,O=(r,e)=>{try{if(e!==void 0){const t=f(r);if(t!==void 0&&t.pid!==e)return}N(n(r,v),{force:!0})}catch{}},F=r=>{const e=f(r);if(e!==void 0){if(b(e))return e;O(r,e.pid)}},I=(r,e,t)=>{const i=F(r);if(i!==void 0)return t!==void 0&&i.pid===t?{ok:c(r,e)!==void 0}:i.pid!==e.pid?{existing:i,ok:!1}:{ok:c(r,{...e,tunnelUrl:e.tunnelUrl??i.tunnelUrl})!==void 0}},P=(r,e,t)=>{const i=n(r,v),s=`${JSON.stringify(e,void 0,2)}
4
+ `;for(let d=0;d<2;d+=1)try{return _(n(r,u),{recursive:!0}),E(i,s,{encoding:"utf8",flag:"wx"}),{ok:!0}}catch(l){if(l.code!=="EEXIST")return{ok:c(r,e)!==void 0};const S=I(r,e,t?.supersedePid);if(S!==void 0)return S}return{ok:c(r,e)!==void 0}};export{k as DEV_BINDINGS_FILE,T as DEV_DAEMON_ENV,x as DEV_HANDOFF_ENV,h as DEV_LOG_FILE,U as DEV_LOG_FILE_ENV,u as DEV_STATE_DIR,v as DEV_STATE_FILE,P as claimDevServerState,O as clearDevServerState,M as isDevServerReady,p as isProcessAlive,b as isRecordedProcessCurrent,f as readDevServerState,F as readLiveDevServerState,C as updateDevServerState,c as writeDevServerState};
@@ -0,0 +1,6 @@
1
+ import{parse as p}from"dotenv";const A=".dev.vars",D=".dev.vars.example",$=/^[A-Za-z_]\w*$/u,d=/\r?\n/u,u=e=>Object.entries(p(e)).map(([t,n])=>({key:t,value:n})),V=e=>u(e)[0],L=e=>e.replaceAll(/[.*+?^${}()|[\]\\]/gu,String.raw`\$&`),_=/(\r?\n)/u,E=(e,t,n)=>{const r=e.split(_),s=[];let a=!1;for(let i=0;i<r.length;i+=2){const o=r[i]??"",c=r[i+1]??"";if(V(o)?.key!==t){s.push(o,c);continue}const l=!a;a=!0,n!==void 0&&l&&s.push(n,c)}return{content:s.join(""),matched:a}},m=(e,t,n)=>{const r=`${t}="${n}"`,s=E(e,t,r);return s.matched?s.content:e===""?`${r}
2
+ `:e.endsWith(`
3
+ `)?`${e}${r}
4
+ `:`${e}
5
+ ${r}
6
+ `},R=(e,t)=>E(e,t,void 0).content;export{D as DEV_VARS_EXAMPLE_FILE,A as DEV_VARS_FILE,$ as DEV_VARS_KEY_PATTERN,d as DEV_VARS_NEWLINE,L as escapeRegExp,u as parseDevVariableEntries,V as parseDevVariableLine,R as removeDevVariableLine,m as upsertDevVariableLine};
@@ -0,0 +1 @@
1
+ import{readFileSync as l}from"node:fs";import{findWranglerFile as m,readWranglerJsonc as E}from"./WRANGLER_FILES-UNW-xY5u.mjs";import{DEV_VARS_FILE as i,parseDevVariableEntries as V,upsertDevVariableLine as c}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{writeDevVariablesFileAtomically as p}from"./buildPackageSecretsBlock-BWV_VxqV.mjs";import{join as v}from"node:path";const n="WORKER_ENV",a="development",d=e=>{const r=m(e);return r===void 0?{}:E(r).parsed?.vars??{}},W=(e,r)=>{const o=v(e,i);let t;try{t=l(o,"utf8")}catch{return}V(t).some(s=>s.key===n)||n in d(e)||(p(o,c(t,n,a)),r(`set ${n}=${a} in ${i} so the dev worker runs in development mode`))};export{a as DEV_WORKER_ENV_VALUE,n as DEV_WORKER_ENV_VAR,W as ensureDevWorkerEnv};
@@ -0,0 +1 @@
1
+ const _="global_fetch_strictly_public";export{_ as default};
@@ -0,0 +1,2 @@
1
+ import{readFileSync as ee,writeFileSync as ne}from"node:fs";import{createRequire as se}from"node:module";import{join as V}from"node:path";import{containerBuildTag as te}from"@lunora/container";import{readJsonSync as ie}from"@visulima/fs";import{applyModify as w}from"./applyModify-DKP2l6S9.mjs";import{a as oe,r as Y}from"./lunora-manifest-DuH_Cmyu.mjs";import{parseTree as ae,findNodeAtLocation as re}from"jsonc-parser";import{r as de,a as ce,b as le,c as ue}from"./reconcile-services-DFqH4eMQ.mjs";import{DEV_VARS_FILE as ge,parseDevVariableEntries as me}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{secretSourcesFromBindings as pe}from"./inferLunoraBindings-CH8xwMCn.mjs";import{requiredSecrets as fe}from"./buildPackageSecretsBlock-BWV_VxqV.mjs";import{w as be,m as he,s as U,o as P,n as T,p as ve}from"./validate-bindings-PVHSAU6M.mjs";import{s as we}from"./worker-entry-checks-AIASCYl7.mjs";import{DEFAULT_OBSERVABILITY as _e}from"./DEFAULT_OBSERVABILITY-bN6UkTMx.mjs";import{findWranglerFile as ye,readWranglerJsonc as Se}from"./WRANGLER_FILES-UNW-xY5u.mjs";const Ee=[["maxBatchSize","max_batch_size"],["maxBatchTimeout","max_batch_timeout"],["maxConcurrency","max_concurrency"],["maxRetries","max_retries"],["deadLetterQueue","dead_letter_queue"],["retryDelay","retry_delay"]],B=e=>Object.fromEntries(Ee.filter(([n])=>e.tuning[n]!==void 0).map(([n,s])=>[s,e.tuning[n]])),L="queueTuning",xe=/^[\t ]*(?:,[\t ]*)?(?:\/\/[^\n\r]*)?\r?\n/u,Ae=/^[\t ]*,/u,Oe=(e,n)=>{const s=ae(e),t=s===void 0?void 0:re(s,[...n])?.parent;if(t?.type==="property"){const o=t.offset+t.length,i=e.lastIndexOf(`
2
+ `,t.offset-1)+1,a=xe.exec(e.slice(o));if(a!==null&&e.slice(i,t.offset).trim()===""){const m=t.parent?.children??[],u=m.indexOf(t),d=u===m.length-1&&u>0?m[u-1]:void 0,c=d===void 0?void 0:Ae.exec(e.slice(d.offset+d.length))??void 0;return(c===void 0||d===void 0?e.slice(0,i):e.slice(0,d.offset+d.length)+e.slice(d.offset+d.length+c[0].length,i))+e.slice(o+a[0].length)}}return w(e,n,void 0)},G=(e,n,s,t,o,i=new Set)=>{const a=s.join("."),m={},u=[],d=[];let c=e;return{entries:n.map((l,v)=>{const g=t(l);if(g===void 0||l.queue===void 0)return l;const b=Object.fromEntries(Object.entries(B(g)).filter(([f])=>!i.has(f))),h=Object.entries(o[l.queue]??{}).filter(([f])=>!Object.hasOwn(b,f)),_=Object.entries(b).filter(([f,y])=>l[f]!==y),E=h.filter(([f,y])=>l[f]===y).map(([f])=>f),O=Object.fromEntries(Object.entries({...l,...b}).filter(([f])=>!E.includes(f)));for(const[f,y]of _)c=w(c,[...s,v,f],y);for(const f of E)c=Oe(c,[...s,v,f]);for(const[f,y]of h){const A=l[f];A!==void 0&&A!==y&&d.push(`${a}/${l.queue}: ${f} is no longer declared by defineQueue, but it was changed by hand to ${JSON.stringify(A)} from the declared ${JSON.stringify(y)}, so it was kept. Delete it from wrangler.jsonc if it should go.`)}return(_.length>0||E.length>0)&&u.push(`${a}/${l.queue} (${[..._.map(([f])=>f),...E.map(f=>`removed ${f}`)].join(", ")})`),Object.keys(b).length>0&&(m[l.queue]=b),O}),owned:m,text:c,updated:u,warnings:d}},Ne=(e,n,s,t)=>{const o=n.queues??{},i=o.producers??[],a=o.consumers??[],m=new Set(i.map(g=>g?.binding)),u=new Set(a.map(g=>g.queue)),d=s.filter(g=>!m.has(g.bindingName)),c=s.filter(g=>!u.has(g.name)),p=G(e,a,["queues","consumers"],g=>s.find(b=>b.name===g.queue),t);let l=p.text;const v={...p.owned};if(d.length>0||c.length>0){const g=[...i,...d.map(h=>({binding:h.bindingName,queue:h.name}))],b=[...p.entries,...c.map(h=>({queue:h.name,...h.mode==="pull"?{type:"http_pull"}:{},...B(h)}))];for(const h of c){const _=B(h);Object.keys(_).length>0&&(v[h.name]=_)}l=w(l,["queues"],{consumers:b,producers:g})}return{added:[...d.map(g=>`queues.producers/${g.bindingName}`),...c.map(g=>`queues.consumers/${g.name}`)],owned:v,text:l,updated:p.updated,warnings:p.warnings}},ke=(e,n,s,t,o)=>{const i=n.env?.[t],a=i?.queues?.consumers??[],m=i?.queues?.producers??[],u=l=>{const v=m.find(g=>g?.queue===l.queue)?.binding;return v!==void 0?s.find(g=>g.bindingName===v):s.find(g=>g.name===l.queue&&!m.some(b=>b?.binding===g.bindingName))},d=G(e,a,["env",t,"queues","consumers"],u,o,new Set(["dead_letter_queue"])),c=a.filter(l=>l.queue!==void 0&&u(l)===void 0).map(l=>`env.${t}.queues.consumers/${String(l.queue)}: no defineQueue export matches it — this block declares no producer mapping one of their bindings to "${String(l.queue)}", and no export is named that — so it was not retuned. A consumer for a queue another worker produces is skipped the same way.`),p=a.flatMap(l=>{const v=u(l)?.tuning.deadLetterQueue;return v===void 0||l.dead_letter_queue!==void 0?[]:[`env.${t}.queues.consumers/${String(l.queue)}: defineQueue declares deadLetterQueue "${v}", but this consumer has no dead_letter_queue, so its exhausted messages are dropped. Queue names differ per environment, so reconcile does not write it here; add it by hand.`]});return{added:[],owned:d.owned,text:d.text,updated:d.updated,warnings:[...d.warnings,...p,...c]}},$e=(e,n)=>{if(e?.lunoraIsForeign===!0)return n.push(`${e.path}: \`lunora\` is not an object, so the queue tuning ownership record cannot be read or written — an option removed from defineQueue stays deployed.`),{};const s=e?.lunora?.[L],t=o=>typeof o=="object"&&o!==null&&!Array.isArray(o);return s===void 0?{}:!t(s)||!Object.values(s).every(o=>t(o)&&Object.values(o).every(i=>t(i)))?(n.push(`${e?.path??"package.json"}: \`lunora.${L}\` is not a map of scope → queue → fields, so it is ignored — an option removed from defineQueue stays deployed until the next pass records it again.`),{}):s},Ce=(e,n,s)=>{const t=Object.fromEntries(Object.entries({...n,...s}).filter(([,o])=>Object.keys(o).length>0));oe(e,L,Object.keys(t).length===0?void 0:t)},Ie="https://api.cloudflare.com/client/v4/accounts/<ACCOUNT_ID>/artifacts/namespaces",Te=e=>{const n='add an "artifacts" binding ({ binding: "ARTIFACTS", namespace }) — codegen reads env.ARTIFACTS unless `.artifacts()` on defineApp points ctx.artifacts at another binding';return e===void 0?`ctx.artifacts is used; ${n}. The namespace is created by the first repo create() if it does not exist yet.`:`ctx.artifacts is used and the schema pins data to "${e}"; create the namespace in that jurisdiction BEFORE the first repo, with POST ${Ie} and body { "namespace": "<name>", "jurisdiction": "${e}" }, then ${n}. A namespace's jurisdiction cannot be changed, and one created implicitly by the first repo create() is unrestricted. With CLOUDFLARE_API_TOKEN set, \`lunora deploy\` creates a missing namespace in that jurisdiction for a binding you have added.`},j="PIPELINES",R="ARTIFACTS",je=(e,n,s)=>{const t=n!==void 0&&(s===void 0||s==="cloudflare"),o=e.flagshipBinding!==void 0&&!(n?.flagship??[]).some(d=>d.binding===e.flagshipBinding),i=e.usesPipelines&&!(n?.pipelines??[]).some(d=>d.binding===j),a=e.usesArtifacts?n?.artifacts??[]:[],m=a.some(d=>d.binding===R)?[]:a.flatMap(d=>d.binding===void 0?[]:[d.binding]);return[[e.usesKv&&(n?.kv_namespaces?.length??0)===0&&(!t||e.jurisdiction!==void 0),e.jurisdiction===void 0?'ctx.kv is used but no kv_namespaces binding exists; add one ({ binding: "KV" }) — wrangler creates the namespace on the first deploy.':`ctx.kv is used and the schema pins data to "${e.jurisdiction}"; run \`wrangler kv namespace create <name> --jurisdiction ${e.jurisdiction}\` and add a kv_namespaces entry ({ binding: "KV", id }) — a namespace wrangler creates on deploy is unrestricted.`],[e.usesHyperdrive&&(n?.hyperdrive?.length??0)===0&&!t,'@lunora/hyperdrive is used but no hyperdrive binding exists; add one ({ binding: "HYPERDRIVE", id }) — on a Cloudflare target `lunora deploy` creates the Hyperdrive config from a connection string.'],[e.usesArtifacts&&a.length===0&&(!t||e.jurisdiction!==void 0),Te(e.jurisdiction)],[i,`ctx.pipelines is used but no "${j}" pipelines binding exists; run 'wrangler pipelines create <name>' and add a 'pipelines' binding ({ binding: "${j}", stream }) — codegen resolves this one name, and the pipeline resource can't be auto-provisioned.`],[m.length>0,`ctx.artifacts is used and ${m.map(d=>`"${d}"`).join(", ")} ${m.length===1?"is":"are"} bound, but none is named "${R}"; make sure \`.artifacts()\` on defineApp points ctx.artifacts at it — otherwise it reads env.${R} and throws.`],[o,`lunora/flags.ts uses Flagship in binding mode but no flagship binding "${e.flagshipBinding??""}" exists; add a flagship entry ({ binding: "${e.flagshipBinding??""}", app_id }) — the app_id can't be auto-provisioned.`]].filter(([d])=>d).map(([,d])=>d)},Re=e=>[[e.usesX402Charge,"@lunora/x402/charge is used; set the recipient wallet address as a [vars] entry (the var name is your choice) and pass it to the charge config — the x402 facilitator settles USDC to that address."],[e.usesX402,"@lunora/x402/pay is used (ActionCtx-only, spends real funds); add a secrets_store_secrets[] binding holding the agent wallet key (binding name == signer.secretName) and pair the pay rail with a spend policy — ctx.secrets reads a Secrets Store binding, not .dev.vars."]].filter(([s])=>s).map(([,s])=>s),q=(e,n,s)=>s.filter(t=>!t.exported).map(t=>`${e} "${t.exportName}" is declared but ${t.className} is not exported by the worker entry; add \`export * from "./lunora/_generated/${n}"\` so its binding can be provisioned.`),qe=(e,n)=>{const s=new Set([...e.workflows,...e.agents].map(i=>i.className));if(s.size===0)return[];const t=Object.entries(n.exports??{}).flatMap(([i,a])=>a?.type==="workflow"?[i]:[]),o=(n.workflows??[]).flatMap(i=>i.class_name===void 0||i.script_name!==void 0?[]:[i.class_name]);return[...new Set([...t,...o])].filter(i=>!s.has(i)).map(i=>`wrangler.jsonc declares workflow "${i}" but no defineWorkflow/defineAgent export generates that class — a leftover from a rename will fail the deploy (wrangler rejects a class the worker does not export). Remove it if it is not hand-wired.`)},De=(e,n)=>{if(e.queues.length===0)return[];const s=new Set(e.queues.map(o=>o.name)),t=new Set(e.queues.map(o=>o.bindingName));return[...(n.queues?.consumers??[]).flatMap(o=>{const{queue:i}=o;return i===void 0||s.has(i)?[]:[`wrangler.jsonc subscribes queues.consumers[] to "${i}" but no defineQueue export declares that queue — a leftover from a rename keeps delivering batches this worker has no handler for (they retry to exhaustion, then drop or dead-letter). Remove it if it is not hand-wired.`]}),...(n.queues?.producers??[]).flatMap(o=>{const i=o?.binding;return i===void 0||t.has(i)?[]:[`wrangler.jsonc declares queues.producers[] binding "${i}" but no defineQueue export declares it — a leftover from a rename. Remove it if it is not hand-wired.`]})]},Pe=(e,n)=>[...qe(e,n),...De(e,n)],J=[{keys:["STRIPE_SECRET_KEY","STRIPE_WEBHOOK_SECRET"],label:"Stripe"},{keys:["POLAR_ACCESS_TOKEN","POLAR_WEBHOOK_SECRET"],label:"Polar"},{keys:["CREEM_API_KEY","CREEM_WEBHOOK_SECRET"],label:"Creem"},{keys:["AUTUMN_SECRET_KEY","AUTUMN_WEBHOOK_SECRET"],label:"Autumn"},{keys:["DODO_PAYMENTS_API_KEY","DODO_PAYMENTS_WEBHOOK_KEY"],label:"Dodo Payments"}],Be=()=>J.map(({keys:e,label:n})=>`${e[0]} + ${e[1]} (${n})`).join(" or "),Le=e=>{let n;try{n=ee(V(e,ge),"utf8")}catch{return!1}const s=new Map(me(n).map(t=>[t.key,t.value]));return J.some(({keys:t})=>t.every(o=>(s.get(o)??"")!==""))},We=(e,n)=>{const s=n?.secrets?.required;if(!Array.isArray(s))return[];const t=new Set(s),o=fe(pe(e)).map(i=>i.key).filter(i=>!t.has(i));return o.length===0?[]:[`wrangler.jsonc declares secrets.required without ${o.join(", ")}, which this app needs — wrangler dev loads only the listed keys from .dev.vars, so add ${o.length===1?"it":"them"} to secrets.required.`]},D=(e,n,s,t)=>{const o=new Set(e.durableObjects.map(u=>u.className)),i=[],a=(s?.r2_buckets?.length??0)>0,m=(s?.d1_databases?.some(u=>u.binding==="DB")??!1)||e.needsD1;return e.usesStorage&&!a&&i.push("@lunora/storage is used but R2 bucket bindings have user-defined names; add an r2_buckets entry and pass env.<BINDING> to createStorage()."),e.usesAuth&&!o.has("SessionDO")&&!m&&i.push("@lunora/auth is used but the worker entry exports no SessionDO; sessions are D1-backed, or export SessionDO to enable DO-backed sessions."),e.usesScheduler&&!o.has("SchedulerDO")&&i.push("@lunora/scheduler is used but the worker entry exports no SchedulerDO; export it so the SCHEDULER binding can be provisioned."),i.push(...q("container","containers",e.containers),...q("workflow","workflows",e.workflows),...q("agent","agents",e.agents)),e.containers.length>0&&s?.observability?.enabled===!1&&i.push("containers are declared but observability is explicitly disabled in wrangler.jsonc — container logs will not be captured."),e.usesPayments&&!Le(n)&&i.push(`@lunora/payment is used; set one provider's secret pair in .dev.vars — ${Be()}.`),i.push(...Re(e),...je(e,s,t),...We(e,s)),s!==void 0&&i.push(...Pe(e,s)),i},X="<replace-with-d1-create-id>",Me="<replace-with-hyperdrive-create-id>",Ke=e=>[["container","containers",e.containers],["workflow","workflows",e.workflows],["agent","agents",e.agents]].flatMap(([s,t,o])=>o.filter(i=>!i.exported).map(({className:i,exportName:a})=>({className:i,exportName:a,kind:s,module:t}))),Fe=e=>{const n=new Set(P(e).map(t=>t.tag));let s=1;for(;n.has(`v${String(s)}`);)s+=1;return`v${String(s)}`},He=e=>{const n=new Set;for(const s of P(e)){for(const t of T(s.deleted_classes))n.delete(t);for(const{from:t,to:o}of P(s.renamed_classes))t!==void 0&&n.delete(t),o!==void 0&&n.add(o);for(const t of[...T(s.new_classes),...T(s.new_sqlite_classes)])n.add(t)}return n},Ye=(e,n,s)=>{const t=n.durable_objects?.bindings??[],o=new Set(t.map(c=>c.name)),i=s.filter(c=>!o.has(c.binding));let a=e;const m=[];if(i.length>0){const c=[...t,...i.map(p=>({class_name:p.className,name:p.binding}))];a=w(a,["durable_objects","bindings"],c),m.push(...i.map(p=>`${p.binding}/${p.className}`))}const u=n.migrations??[],d=s.map(c=>c.className).filter(c=>!He(u).has(c));if(d.length>0){const c=[...u,{new_sqlite_classes:d,tag:Fe(u)}];a=w(a,["migrations"],c)}return{added:m,text:a}},Qe=(e,n)=>{const s=n.d1_databases??[];if(s.some(i=>i.binding==="DB"))return{added:[],text:e};const t=typeof n.name=="string"&&n.name.length>0?n.name:"lunora",o=[...s,{binding:"DB",database_id:X,database_name:t}];return{added:["DB (D1)"],text:w(e,["d1_databases"],o)}},Ve={ai:{binding:"AI",label:"AI (Workers AI)"},analytics:{binding:"ANALYTICS_SQL",label:"ANALYTICS_SQL (Analytics SQL)"},browser:{binding:"BROWSER",label:"BROWSER (Browser Rendering)"},images:{binding:"IMAGES",label:"IMAGES (Cloudflare Images)"}},k=(e,n,s)=>{const{binding:t,label:o}=Ve[s],i=n[s]?.binding;return typeof i=="string"&&i.length>0?{added:[],text:e}:{added:[o],text:w(e,[s],{binding:t})}},Ue=(e,n)=>e.usesAnalyticsSql&&we(n,new Set(["analyticsSql"]))?.chained.has("analyticsSql")!==!0,Ge=new Set(["ratelimits","send_email"]),Je=["durable_objects","logfwdr","unsafe"],Xe=new Set(["data_blobs","text_blobs","vars","wasm_modules"]),M=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),W=(e,n,s)=>M(e)&&e[n]===s,ze=(e,n,s)=>{if(Xe.has(e))return M(n)&&Object.hasOwn(n,s);const t=Ge.has(e)?"name":"binding";return Array.isArray(n)?n.some(o=>W(o,t,s)):W(n,"binding",s)},$=(e,n)=>{const s=e,t=Object.entries(s).find(([i,a])=>i!=="env"&&ze(i,a,n));if(t!==void 0)return t[0];for(const i of Je){const a=s[i];if(M(a)&&Array.isArray(a.bindings)&&a.bindings.some(m=>W(m,"name",n)))return`${i}.bindings`}if(e.queues?.producers?.some(i=>i?.binding===n)===!0)return"queues.producers";const o=e.secrets?.required;if(Array.isArray(o)&&o.includes(n))return"secrets.required"},K=(e,n,s)=>`${e}: not adding "${n}" — the name is already bound by \`${s}\` in wrangler.jsonc. Add a ${e} entry under another binding name and point the matching \`defineApp()\` override at it.`,F=e=>e===void 0||e==="cloudflare",Ze=(e,n,s)=>{if(!F(s)||(n.hyperdrive?.length??0)>0)return{added:[],text:e};const t=$(n,"HYPERDRIVE");return t!==void 0?{added:[],text:e,warnings:[K("hyperdrive","HYPERDRIVE",t)]}:{added:["HYPERDRIVE (Hyperdrive, created on deploy)"],text:w(e,["hyperdrive"],[{binding:"HYPERDRIVE",id:Me}])}},en=(e,n,s,t)=>{if(!F(t)||s!==void 0||(n.kv_namespaces?.length??0)>0)return{added:[],text:e};const o=$(n,"KV");return o!==void 0?{added:[],text:e,warnings:[K("kv_namespaces","KV",o)]}:{added:["KV (Workers KV, created on deploy)"],text:w(e,["kv_namespaces"],[{binding:"KV"}])}},nn=(e,n,s,t)=>{if(!F(t)||s!==void 0||(n.artifacts?.length??0)>0)return{added:[],text:e};const o=$(n,"ARTIFACTS");if(o!==void 0)return{added:[],text:e,warnings:[K("artifacts","ARTIFACTS",o)]};const i=typeof n.name=="string"&&n.name.length>0?n.name:"lunora";return{added:["ARTIFACTS (Cloudflare Artifacts)"],text:w(e,["artifacts"],[{binding:"ARTIFACTS",namespace:i}])}},Q=(e,n,s,t,o)=>{if((n[s]?.length??0)>0)return{added:[],text:e};const i=$(n,t.binding);return i!==void 0?{added:[],text:e,warnings:[`${s}: not adding ${JSON.stringify(t)} — the name "${t.binding}" is already bound by \`${i}\` in wrangler.jsonc. Add a ${s} entry under another binding name and point the matching \`defineApp()\` override at it.`]}:{added:[o],text:w(e,[s],[t])}},sn=(e,n)=>{const s=n.worker_loaders??[];return s.some(t=>t.binding==="LOADER")?{added:[],text:e}:{added:["LOADER (Worker Loader)"],text:w(e,["worker_loaders"],[...s,{binding:"LOADER"}])}},tn=e=>{if(typeof e=="string")return e;const n={};return e.diskMb!==void 0&&(n.disk_mb=e.diskMb),e.memoryMib!==void 0&&(n.memory_mib=e.memoryMib),e.vcpu!==void 0&&(n.vcpu=e.vcpu),n},on=e=>{const{image:n}=e;return n.kind==="dockerfile"?n.dockerfilePath:n.kind==="registry"?n.reference:te(e.exportName)},z=e=>{const n={};for(const[s,t]of Object.entries(e.images??{}))n[s]=t.kind==="registry"?{image:t.reference}:{build_context:t.buildContext,dockerfile:t.dockerfilePath,...e.buildArgs===void 0?{}:{build_vars:e.buildArgs}};return{class_name:e.className,scheduling_policy:"durable_object",...Object.keys(n).length>0?{images:n}:{},...e.name===void 0?{}:{name:e.name}}},an=e=>{if(e.schedulingPolicy==="durable_object")return z(e);const{image:n}=e,s={class_name:e.className,image:on(e)};return n.kind==="dockerfile"&&(s.image_build_context=n.buildContext),e.buildArgs!==void 0&&n.kind!=="registry"&&(s.image_vars=e.buildArgs),e.instanceType!==void 0&&(s.instance_type=tn(e.instanceType)),e.maxInstances!==void 0&&(s.max_instances=e.maxInstances),e.name!==void 0&&(s.name=e.name),e.rollout?.stepPercentage!==void 0&&(s.rollout_step_percentage=e.rollout.stepPercentage),e.rollout?.gracePeriodSeconds!==void 0&&(s.rollout_active_grace_period=e.rollout.gracePeriodSeconds),s},rn=(e,n,s)=>{const t=n.containers??[],o=new Set(t.map(d=>d.class_name)),i=s.filter(d=>!o.has(d.className));let a=i.length===0?e:w(e,["containers"],[...t,...i.map(d=>an(d))]);const m=[],u=[];for(const[d,c]of t.entries()){const p=s.find(g=>g.className===c.class_name);if(p===void 0)continue;const l=p.schedulingPolicy??"default";if((c.scheduling_policy??"default")!==l){u.push(`containers/${p.className} has scheduling_policy "${c.scheduling_policy??"default"}" in wrangler.jsonc but defineContainer "${p.exportName}" declares "${l}" — the policy is immutable, so replace the entry (and its container application) by hand.`);continue}const v=p.schedulingPolicy==="durable_object"?z(p).images:void 0;v!==void 0&&JSON.stringify(c.images)!==JSON.stringify(v)&&(a=w(a,["containers",d,"images"],v),m.push(`containers/${p.className}.images`))}return{added:i.map(d=>`containers/${d.className}`),text:a,updated:m,warnings:u}},dn=(e,n)=>{if(n.observability!==void 0)return{added:[],text:e};const s=w(e,["observability"],{..._e});return{added:["observability"],text:s}},cn=(e,n)=>n.upload_source_maps!==void 0?{added:[],text:e}:{added:["upload_source_maps"],text:w(e,["upload_source_maps"],!0)},Z=[{minimum:[4,142],name:"wrangler"},{minimum:[1,61],name:"@cloudflare/vite-plugin"}],ln=Z.map(({minimum:e,name:n})=>`${n}@^${e.join(".")}.0`).join(" "),un=(e,n)=>{try{const s=se(V(e,"package.json")).resolve(`${n}/package.json`),[t=0,o=0]=String(ie(s).version).split(".").map(Number);return[t,o]}catch{return}},gn=e=>{const n=Z.flatMap(({minimum:s,name:t})=>{const o=un(e,t);return o!==void 0&&(o[0]<s[0]||o[0]===s[0]&&o[1]<s[1])?[`${t} ${o.join(".")} (needs >= ${s.join(".")})`]:[]});return n.length===0?void 0:`workflows are declared in wrangler \`exports\`, which ${n.join(" and ")} cannot run — reconcile left workflows[] untouched. Upgrade (\`pnpm add -D ${ln}\`) and re-run.`},mn=e=>Object.entries(e.env??{}).flatMap(([n,s])=>Array.isArray(s?.workflows)?[`env.${n}.workflows declares workflow bindings, but Lunora now declares workflows in \`exports\` and resolves them on ctx.exports — move them to that environment's own \`exports\` by hand.`]:[]),pn=(e,n,s)=>{let t=e;const o=[],i=[];for(const a of s){const m=n[a.className];if(m?.type==="workflow")for(const{of:u,path:d}of ve){const c=u(a),p=U(m,d),l=`exports/${a.className}.${d.join(".")}`;if(c===void 0){p!==void 0&&i.push(`${l} is set in wrangler.jsonc but defineWorkflow "${a.exportName}" does not declare it — reconcile leaves it in place. Remove it by hand if it was dropped from the definition.`);continue}JSON.stringify(p)!==JSON.stringify(c)&&(t=w(t,["exports",a.className,...d],c),o.push(l))}}return{text:t,updated:o,warnings:i}},fn=(e,n,s,t,o)=>{if(o!==void 0)return{added:[],text:e,warnings:[o]};const i=[...s.map(b=>({settings:be(b),workflow:b})),...t.map(b=>({settings:{},workflow:b}))],a=new Set(i.map(({workflow:b})=>b.className)),m=n.workflows??[],u=m.filter(b=>b.script_name===void 0&&b.class_name!==void 0&&a.has(b.class_name)),d=n.exports??{},c=[],p=[],l=[];let v=e;for(const{settings:b,workflow:h}of i){if(d[h.className]!==void 0&&d[h.className]!==null)continue;const _=u.find(f=>f.class_name===h.className),E=Object.fromEntries(he.flatMap(f=>{const y=U(_,[f]);return y===void 0?[]:[[f,y]]})),O=_?.name??h.name;_?.name!==void 0&&_.name!==h.name&&l.push(`workflows/${h.className} is deployed as "${_.name}" but declared as "${h.name}" — its export keeps "${_.name}" so running instances survive. Change the declaration to match, or rename deliberately (it starts a new, empty workflow).`),v=w(v,["exports",h.className],{type:"workflow",...E,...b,name:O}),(_===void 0?c:p).push(`exports/${h.className}`)}if(u.length>0){const b=m.filter(h=>!u.includes(h));v=w(v,["workflows"],b.length===0?void 0:b),p.push(...u.map(h=>`workflows/${String(h.class_name)} → exports`))}l.push(...mn(n));const g=pn(v,d,s);return{added:c,text:g.text,updated:[...p,...g.updated],warnings:[...l,...g.warnings]}},Tn=(e,n,{environment:s,target:t}={})=>{const o=ye(e),i=Ke(n);if(!o)return{added:[],changed:!1,exportGaps:i,reason:"wrangler.jsonc not found",updated:[],warnings:D(n,e)};const{parsed:a,text:m}=Se(o);if(a===void 0)return{added:[],changed:!1,exportGaps:i,reason:`failed to parse ${o} as JSONC`,updated:[],warnings:D(n,e),wranglerPath:o};const u=D(n,e,a,t);if(s!==void 0){const r=a.env?.[s]!==void 0;u.push(r?`auto-provisioned bindings are written to the top level of wrangler.jsonc only (queue consumers "env.${s}" already declares are retuned, nothing is added) — "env.${s}" has its own (non-inheritable) bindings and must be reconciled by hand; \`lunora deploy --env ${s}\` now validates them, so a gap here will be reported at deploy time.`:`--env "${s}" was requested but wrangler.jsonc declares no "env.${s}" block — auto-provisioned bindings are written to the top level only and will not apply to that environment.`)}const d=n.containers.filter(r=>r.exported),c=n.agents.filter(r=>r.exported&&r.voice===!0&&r.voiceBindingName!==void 0&&r.voiceClassName!==void 0),p=[...n.durableObjects,...d.map(r=>({binding:r.bindingName,className:r.className})),...c.map(r=>({binding:r.voiceBindingName,className:r.voiceClassName}))],l=n.workflows.filter(r=>r.exported),v=n.agents.filter(r=>r.exported),g=Y(e),b=$e(g,u),h={},_=de(g);let E;const O=[{enabled:!0,run:r=>Ye(r,a,p)},{enabled:n.needsD1,run:r=>Qe(r,a)},{enabled:n.usesKv,run:r=>en(r,a,n.jurisdiction,t)},{enabled:n.usesHyperdrive,run:r=>Ze(r,a,t)},{enabled:n.usesArtifacts,run:r=>nn(r,a,n.jurisdiction,t)},{enabled:n.usesAi,run:r=>k(r,a,"ai")},{enabled:n.usesAiSearch,run:r=>Q(r,a,"ai_search_namespaces",{binding:"AI_SEARCH",namespace:"default"},"AI_SEARCH (AI Search namespace)")},{enabled:Ue(n,e),run:r=>k(r,a,"analytics")},{enabled:n.usesBrowser,run:r=>k(r,a,"browser")},{enabled:n.usesImages,run:r=>k(r,a,"images")},{enabled:n.usesAnalytics,run:r=>Q(r,a,"analytics_engine_datasets",{binding:"ANALYTICS",dataset:"ANALYTICS"},"ANALYTICS (Analytics Engine)")},{enabled:n.usesWorkerLoader,run:r=>sn(r,a)},{enabled:!0,run:r=>dn(r,a)},{enabled:t===void 0||t==="cloudflare",run:r=>cn(r,a)},{enabled:d.length>0,run:r=>rn(r,a,d)},{enabled:l.length>0||v.length>0,run:r=>fn(r,a,l,v,gn(e))},{enabled:n.queues.length>0,run:r=>{const S=Ne(r,a,n.queues,b.queues??{});return h.queues=S.owned,S}},{enabled:n.services!==void 0&&(n.services.length>0||Object.keys(_).length>0),run:r=>{const S=ce(r,a,n.services??[],_);return E=S.owned,S}},...s===void 0||a.env?.[s]===void 0?[]:[{enabled:n.queues.length>0,run:r=>{const S=`env.${s}.queues`,N=ke(r,a,n.queues,s,b[S]??{});return h[S]=N.owned,N}}]];let f=m;const y=[],A=[];for(const r of O){if(!r.enabled)continue;const S=r.run(f);f=S.text,y.push(...S.added),A.push(...S.updated??[]),u.push(...S.warnings??[])}const H=r=>{if(g===void 0)return;const S=E,N=[...Object.keys(h).length>0?[{consequence:"an option removed from defineQueue stays deployed",key:"queueTuning",label:"queue tuning",write:x=>{Ce(x,b,h)}}]:[],...S===void 0?[]:[{consequence:"a service removed from lunora.config stays bound",key:"services",label:"service bindings",write:x=>{ue(x,S)}}]];for(const x of N)try{x.write(Y(e)??g)}catch(I){u.push(`${r?"wrangler.jsonc was updated, but ":""}recording the ${x.label} reconcile owns in ${g.path} (lunora.${x.key}) failed: ${I instanceof Error?I.message:String(I)}. Until it is recorded, ${x.consequence}.`)}};let C;if(n.services!==void 0){const r=le(e,n.services,_);u.push(...r.warnings),E={...E,...r.owned},C=r.added.length>0||r.updated.length>0?{added:r.added,path:r.path,updated:r.updated}:void 0}return y.includes("DB (D1)")&&u.push(`wrote a DB binding with a placeholder database_id ("${X}") — run \`wrangler d1 create <name>\` and replace it before deploying.`),f===m?(H(!1),{added:y,changed:!1,devConfig:C,exportGaps:i,reason:"bindings already in sync",updated:A,warnings:u,wranglerPath:o}):(ne(o,f,"utf8"),H(!0),{added:y,changed:!0,devConfig:C,exportGaps:i,updated:A,warnings:u,wranglerPath:o})};export{Me as HYPERDRIVE_PLACEHOLDER_ID,Ke as collectExportGaps,Tn as reconcileWranglerBindings};
@@ -0,0 +1,2 @@
1
+ import{existsSync as u,readFileSync as f,mkdirSync as k,writeFileSync as m}from"node:fs";import{parse as p}from"jsonc-parser";import{join as i}from"node:path";const l=".lunora",d=i(l,"project.json"),v=r=>r!==null&&typeof r=="object",c=(r,o)=>{const e=r[o];return typeof e=="string"&&e.length>0?e:void 0},j=r=>{const o=i(r,d);if(!u(o))return;let e;try{e=f(o,"utf8")}catch{return}const n=[],t=p(e,n,{allowTrailingComma:!0});if(!(n.length>0||!v(t)))return{account:c(t,"account"),env:c(t,"env"),linkedAt:c(t,"linkedAt"),workerName:c(t,"workerName"),workerUrl:c(t,"workerUrl")}},E=(r,o)=>{const e=i(r,l);k(e,{recursive:!0});const n={};for(const a of["account","env","linkedAt","workerName","workerUrl"]){const s=o[a];s!==void 0&&s!==""&&(n[a]=s)}const t=i(r,d);return m(t,`${JSON.stringify(n,void 0,2)}
2
+ `,"utf8"),t};export{l as LINKED_PROJECT_DIR,d as LINKED_PROJECT_FILE,j as readLinkedProject,E as writeLinkedProject};
@@ -0,0 +1 @@
1
+ const u=r=>{if(typeof r=="string")return r;if(r instanceof Error)return String(r);try{return JSON.stringify(r)??String(r)}catch{return String(r)}},d=r=>typeof r!="object"||r===null||Array.isArray(r)?"":Object.entries(r).map(([t,n])=>`${t}=${u(n)}`).join(" "),p="lunora",g="__root__",e=r=>typeof r=="string"?r:"",a=r=>Array.isArray(r)?r.filter(t=>typeof t=="string"):[],h=r=>typeof r=="number"&&Number.isFinite(r)?`${String(Math.round(r))}ms`:"?ms",l=r=>r==="error"||r==="fatal"?"error":r==="warn"?"warn":"info",m=r=>{const t=r.trim();if(!t.startsWith("{")||!t.endsWith("}"))return;let n;try{n=JSON.parse(t)}catch{return}if(typeof n!="object"||n===null)return;const o=n;return o.source===p?o:void 0},f=(r,t)=>{const n=e(t.shard);return n===""||n===g?r:`${r}@${n}`},y=(r,t)=>{const n=r.outcome==="error",o=[f(t,r),n?"error":"ok",h(r.durationMs)],i=a(r.tablesRead),s=a(r.tablesWritten);i.length>0&&o.push(`read[${i.join(",")}]`),s.length>0&&o.push(`write[${s.join(",")}]`),r.cacheHit===!0&&o.push("cached");const c=e(r.error);return n&&c!==""&&o.push(c),{kind:"rpc",level:n?"error":"info",text:o.join(" ")}},$=r=>{const t=e(r.container)||"<unknown>",n=e(r.instance),o=e(r.event)||"event",i=n===""||n==="unknown"?"":`#${n.slice(0,8)}`,s=e(r.message),c=[`container:${t}${i}`,o];return s!==""&&c.push(s),{kind:"log",level:r.event==="error"?"error":"info",text:c.join(" ")}},S=r=>{const t=m(r);if(!t)return;const n=e(t.function)||"<unknown>";if(t.type==="log"){const o=[`${f(n,t)} ${e(t.message)}`.trimEnd()],i=d(t.fields);i!==""&&o.push(i);const s=e(t.traceId);return s!==""&&o.push(`trace=${s.slice(0,8)}`),{kind:"log",level:l(e(t.level)),text:o.join(" ")}}if(t.type==="request")return y(t,n);if(t.type==="container")return $(t)};export{p as LUNORA_EVENT_SOURCE,S as formatLunoraEvent};
@@ -0,0 +1,19 @@
1
+ import{existsSync as g,readFileSync as h,writeFileSync as d}from"node:fs";import{join as p,dirname as x}from"node:path";import{parse as v}from"jsonc-parser";import{applyModify as $}from"./applyModify-DKP2l6S9.mjs";import{readProjectDependencyNames as S,readProjectManifest as w}from"./readProjectDependencies-l3uhUKjo.mjs";const c=["lunora/_generated/","lunora/.lunora-schema.json","lunora.advisor.map.json",".lunora/",".wrangler/"],f={biome:{configFiles:["biome.json","biome.jsonc"],packages:["@biomejs/biome"],shadowable:!0},eslint:{configFiles:["eslint.config.js","eslint.config.mjs","eslint.config.cjs","eslint.config.ts","eslint.config.mts","eslint.config.cts"],packages:["eslint"],shadowable:!0},oxlint:{configFiles:[".oxlintrc.json"],packages:["oxlint"],shadowable:!0},prettier:{configFiles:[".prettierrc",".prettierrc.json",".prettierrc.js",".prettierrc.mjs",".prettierrc.cjs","prettier.config.js","prettier.config.mjs","prettier.config.cjs"],packages:["prettier"],shadowable:!1}},L=Object.keys(f),y=(e,n)=>f[n].configFiles.map(t=>p(e,t)).find(t=>g(t)),k=(e,n)=>{let t=e;for(;;){const i=y(t,n);if(i!==void 0)return i;if(g(p(t,".git")))return;const s=x(t);if(s===t)return;t=s}},j=(e,n)=>{const t=y(e,n);if(t!==void 0)return{action:"extend",path:t};const i=g(p(e,".git")),s=f[n].shadowable&&!i?k(x(e),n):void 0,[a=""]=f[n].configFiles;return s===void 0?{action:"create",path:p(e,a)}:{action:"report",path:s}},U=e=>{const n=S(e),t=()=>w(e)?.prettier!==void 0;return L.filter(i=>f[i].packages.some(s=>n.has(s))||y(e,i)!==void 0||i==="prettier"&&t())},O="# Lunora generated + derived artifacts",I=e=>{const n=p(e,".prettierignore"),t=g(n)?h(n,"utf8"):void 0,i=t===void 0?[]:t.split(`
2
+ `).map(o=>o.trim()),s=c.filter(o=>!i.includes(o));if(s.length===0)return{path:n,status:t===void 0?"created":"unchanged",tool:"prettier"};const a=`${O}
3
+ ${s.join(`
4
+ `)}
5
+ `;return t===void 0?(d(n,a,"utf8"),{path:n,status:"created",tool:"prettier"}):(d(n,`${t.endsWith(`
6
+ `)?t:`${t}
7
+ `}
8
+ ${a}`,"utf8"),{path:n,status:"updated",tool:"prettier"})},A=(e,n,t,i)=>{const s=g(e),a=s?h(e,"utf8"):`{}
9
+ `;let r=v(a)??{};for(const l of n)r=r!==null&&typeof r=="object"?r[l]:void 0;const m=Array.isArray(r)?r:[],b=t.filter(l=>!m.includes(l));return b.length===0&&s?{path:e,status:"unchanged",tool:i}:(d(e,$(a,n,[...m,...b]),"utf8"),{path:e,status:s?"updated":"created",tool:i})},F=(e,n)=>`"${e}": [${n.map(t=>`"${t}"`).join(", ")}]`,P=()=>F("files.includes",c.map(e=>`!${e.endsWith("/")?`${e}**`:e}`)),E=e=>{const{action:n,path:t}=j(e,"oxlint");return n==="report"?{path:t,snippet:F("ignorePatterns",c),status:"manual",tool:"oxlint"}:A(t,["ignorePatterns"],c,"oxlint")},T=e=>{const{action:n,path:t}=j(e,"biome");if(n==="report")return{path:t,snippet:P(),status:"manual",tool:"biome"};const i=n==="extend",s=i?h(t,"utf8"):`{}
10
+ `,o=(v(s)??{}).files??{};if(Array.isArray(o.ignore))return A(t,["files","ignore"],c,"biome");const r=Array.isArray(o.includes)?o.includes:[],m=r.length===0?["**"]:r,l=c.map(u=>`!${u.endsWith("/")?`${u}**`:u}`).filter(u=>!r.includes(u));return l.length===0&&i?{path:t,status:"unchanged",tool:"biome"}:(d(t,$(s,["files","includes"],[...m,...l]),"utf8"),{path:t,status:i?"updated":"created",tool:"biome"})},W=()=>`{
11
+ // Lunora generated + derived artifacts.
12
+ ignores: [${c.map(e=>`"${e.endsWith("/")?`${e}**`:e}"`).join(", ")}],
13
+ }`,_=e=>{const{action:n,path:t}=j(e,"eslint"),i=W();if(n!=="create"){const a=h(t,"utf8"),o=c.every(r=>a.includes(r))?"unchanged":"manual";return{path:t,...o==="manual"?{snippet:i}:{},status:o,tool:"eslint"}}const s=p(e,"eslint.config.mjs");return d(s,`// Flat config. Add your own entries alongside the ignores below.
14
+ export default [
15
+ ${i.replaceAll(`
16
+ `,`
17
+ `)},
18
+ ];
19
+ `,"utf8"),{path:s,status:"created",tool:"eslint"}},C={biome:T,eslint:_,oxlint:E,prettier:I},G=(e,n)=>n.map(t=>{try{return C[t](e)}catch(i){return{message:i instanceof Error?i.message:String(i),path:e,status:"failed",tool:t}}});export{c as LUNORA_IGNORED_PATHS,G as applyLintIgnores,U as detectLintTools};
@@ -0,0 +1 @@
1
+ import{paintBadge as r,BADGES as o}from"./ACCENT-CotPTfv7.mjs";const A=r(o.lunora),e=n=>`${A} ${n}`,R={ERROR:o.error,INFO:o.info,WARN:o.warn},s=(n,t,a,i)=>`${r(R[n])} ${t}: ${a} — ${i}`;export{A as LUNORA_TAG,s as advisoryLine,e as lunoraLine};
@@ -0,0 +1,6 @@
1
+ import{paintBadge as d,badgeWidth as g,BADGES as s}from"./ACCENT-CotPTfv7.mjs";const p={informational:"info",warning:"warn"},f=new Set(["alert","critical","emergency","error","warn","warning"]),l=t=>{if(t in s)return s[t];const e=p[t];return e===void 0?void 0:s[e]},m=t=>{if(t instanceof Error)return`
2
+ ${t.stack??t.message}`;if(typeof t=="object"&&t!==null)try{return` ${JSON.stringify(t)}`}catch{return" [unserializable]"}return` ${String(t)}`},S=t=>{const e=typeof t.message=="string"?t.message:String(t.message),r=t.context??[];return r.length===0?e:e+r.map(n=>m(n)).join("")};class i{#t=process.stdout;#e=process.stderr;setStdout(e){this.#t=e}setStderr(e){this.#e=e}log(e){const r=e,n=l(r.type.name);(f.has(r.type.level??r.type.name)?this.#e:this.#t).write(i.#r(n,S(r)))}static#r(e,r){if(e===void 0)return`${r}
3
+ `;const[n="",...o]=r.split(`
4
+ `),c=" ".repeat(g()+1);return`${[`${d(e)} ${n}`,...o.map(a=>`${c}${a}`)].join(`
5
+ `)}
6
+ `}}export{i as default};
@@ -0,0 +1 @@
1
+ import{C as S,M as a,P as C,s as R}from"./package-secrets-registry-BeheNwsP.mjs";export{S as CORE_SECRETS,a as MINTABLE_SECRET_KEYS,C as PACKAGE_SECRETS_REGISTRY,R as secretsForPackages};
@@ -0,0 +1 @@
1
+ import{existsSync as d,readFileSync as y}from"node:fs";import{join as s,isAbsolute as a,relative as m}from"node:path";import{LunoraError as p}from"@lunora/errors";import{classifyPolicyEdit as k,scaffoldPolicyFile as v,resolveServerModule as l,wireRlsIntoProcedure as b}from"./classifyPolicyEdit-DJi9Fk8G.mjs";import{w as c,r as h}from"./write-atomic-CY97nWi1.mjs";const D="/__lunora/policy-scaffold",u=e=>e==="unknown-procedure"?404:e==="already-wired"||e==="destructive"?409:422,f=(e,o)=>{let r;try{r=h(e)}catch(t){return{body:{error:t instanceof Error?t.message:String(t),ok:!1},status:500}}return{body:{...o,diagnostics:r,ok:!0},status:200}},g=e=>({body:{edit:e,message:"Rewriting an existing policy predicate changes evaluation semantics and must be done by hand. The scaffolder only adds new, deny-by-default rules.",needsManualEdit:!0,ok:!1},status:409}),w=(e,o)=>{const r=v(o,l(e.projectRoot));if(!r.ok)return{body:{error:r.reason,ok:!1},status:u(r.reason)};const t=e.schemaDirectory??"lunora",n=s(e.projectRoot,t,r.fileName);return d(n)?{body:{error:"file-exists",fileName:r.fileName,ok:!1},status:409}:(c(n,r.source),f(e,{fileName:r.fileName}))},R=(e,o,r)=>{if(typeof r!="string"||r.length===0||a(r)||r.includes("\\"))return;const t=s(e,o),n=s(t,`${r}.ts`),i=m(t,n);if(!(i.startsWith("..")||a(i)))return n},N=(e,o)=>{const r=R(e.projectRoot,e.schemaDirectory??"lunora",o.filePath);if(r===void 0||!d(r))return{body:{error:"unknown-procedure",ok:!1},status:404};const t=b(y(r,"utf8"),o,l(e.projectRoot));return t.ok?(c(r,t.text),f(e,{exportName:o.exportName})):{body:{error:t.reason,ok:!1},status:u(t.reason)}},E=e=>{if(e.method!=="POST")return{body:{error:"method-not-allowed",ok:!1},status:405};const{body:o}=e;if(o==null||typeof o!="object"||typeof o.kind!="string")return{body:{error:"invalid-edit",ok:!1},status:400};const r=o;if(k(r)==="destructive")return g(r);if(r.kind==="scaffoldPolicy")return w(e,r);if(r.kind==="wireRls")return N(e,r);throw new p("INTERNAL",`unhandled additive policy edit kind: ${String(r.kind)}`)};export{D as POLICY_SCAFFOLD_ENDPOINT,E as handlePolicyScaffoldRequest};
@@ -0,0 +1 @@
1
+ import{applyModify as g}from"./applyModify-DKP2l6S9.mjs";import{hasCloudflareCredentials as v}from"./hasCloudflareCredentials-CNPVIVBb.mjs";import{withheldBindings as y,writeDevConfig as E,noopCleanup as R}from"./describeWithheld-CbyzZjZF.mjs";import{r as S}from"./lunora-manifest-DuH_Cmyu.mjs";import{o as _}from"./reconcile-services-DFqH4eMQ.mjs";import{findWranglerFile as j,readWranglerJsonc as w}from"./WRANGLER_FILES-UNW-xY5u.mjs";const p={ai:{label:"AI",shape:"object"},ai_search:{label:"AI Search",shape:"array"},ai_search_namespaces:{label:"AI Search namespace",shape:"array"},analytics:{label:"Analytics SQL",shape:"object"},d1_databases:{label:"D1",shape:"array"},kv_namespaces:{label:"KV",shape:"array"},queues:{label:"Queue",shape:"producers"},r2_buckets:{label:"R2",shape:"array"},services:{label:"Service",shape:"array"},vectorize:{label:"Vectorize",shape:"array"}},C=Object.keys(p),m=(e,r)=>typeof e.binding=="string"?e.binding:r,u=(e,r,t,n)=>{const i=[];for(const[s,o]of r.entries())o!=null&&(e==="kv_namespaces"&&(typeof o.id!="string"||o.id==="")||i.push({binding:m(o,`#${String(s)}`),kind:t,path:[...n,s],section:e}));return i},h=(e,r)=>p[e].shape===r,I=(e,r)=>{const{label:t}=p[e];if(h(e,"array"))return u(e,r[e]??[],t,[]);if(h(e,"object")){const n=r[e];return n==null?[]:[{binding:m(n,e),kind:t,path:[],section:e}]}return u(e,r.queues?.producers??[],t,["producers"])},B=e=>C.flatMap(r=>I(r,e)),L=(e,r)=>{let t=e;for(const n of r)t=g(t,[n.section,...n.path,"remote"],!0);return t},W=e=>{const r=a=>({cleanup:R,reason:a,remoteBindings:[],withheld:[]}),t=j(e.projectRoot);if(!t)return r("wrangler.jsonc not found");const{parsed:n,text:i}=w(t);if(n===void 0)return r(`failed to parse ${t} as JSONC`);const s=_(S(e.projectRoot)),o=e.remote?B(n).filter(a=>a.section!=="services"||!s.has(a.binding)):[],l=y(n,e.hasCredentials??(()=>v({projectRoot:e.projectRoot}))),c=l.some(({kind:a})=>a==="ai")?o.filter(a=>a.section!=="ai"):o;if(c.length===0&&l.length===0)return r(e.remote?"no remote-eligible bindings to proxy":void 0);let d=i;for(const{kind:a}of l)d=g(d,[a],void 0);const b=c.length>0?L(d,c):d,f=E(e.projectRoot,"dev",b);return{cleanup:f.cleanup,configPath:f.configPath,remoteBindings:c,withheld:l}},k=e=>{if(e===void 0)return!1;const r=e.trim().toLowerCase();return r==="1"||r==="true"},D=e=>e.flag===!0||k(e.envValue)?!0:e.configPreference??!1;export{p as REMOTE_ELIGIBLE_KEYS,L as injectRemoteFlags,k as isRemoteEnvEnabled,W as materializeDevWranglerConfig,B as planRemoteBindings,D as resolveRemoteEnabled};
@@ -0,0 +1 @@
1
+ import{MERGED_DURABLE_OBJECT as _}from"./COMPOSED_WORKER_ENTRY-Ciiba5g_.mjs";import{o as E,v as h,a as p,b as D,c as O,d as R,e as l,g as y,h as I,H as S,i as $,R as j,S as A,j as k,k as L,W as w,l as B}from"./validate-bindings-PVHSAU6M.mjs";import{validateTailConsumers as T,validateSendEmail as C,validateSecretsRequired as N,validateLogpush as U,validateLimits as G,validatePlacement as P,validateObservability as K,validateAssets as V,validateCache as W,validateExports as M,validateCorsVariables as x,validateSchedulerOrigin as F}from"./withTailConsumer-CF3pk_Ov.mjs";import{isCacheEnabled as H,WORKERS_CACHE_MIN_DATE as b}from"./WORKERS_CACHE_MIN_DATE-0k9ABJtF.mjs";import{mergeWranglerEnvironment as Y}from"./mergeWranglerEnvironment-D5ekKj5x.mjs";const q=i=>typeof i=="object"&&i!==null&&!Array.isArray(i),g=i=>Array.isArray(i)?i.flatMap((a,n)=>q(a)?[[n,a]]:[]):[],m=i=>typeof i.binding=="string"?i.binding:"",J=(i,a,n)=>{for(const[e,s]of g(i.kv_namespaces))typeof s.id=="string"&&s.id!==""||n.push(`kv_namespaces[${String(e)}] ("${m(s)}") is not created yet and the schema pins data to "${a}" — create it with \`wrangler kv namespace create <name> --jurisdiction=${a}\`; a namespace's jurisdiction cannot be changed afterwards`)},Q=(i,a,n)=>{for(const[e,s]of g(i.r2_buckets)){const o=s.jurisdiction;if(o===a)continue;const t=typeof o=="string"?`names the "${o}" jurisdiction`:"names no jurisdiction";n.push(`r2_buckets[${String(e)}] ("${m(s)}") ${t}, but the schema pins data to "${a}" — create the bucket with \`wrangler r2 bucket create <name> --jurisdiction=${a}\` and set "jurisdiction": "${a}" on the binding`)}},z=(i,a,n)=>{const e=a?.jurisdiction;e!==void 0&&(J(i,e,n),Q(i,e,n))},v="2026-04-07",le="web_socket_auto_reply_to_close",u="2026-10-01",f="durable_object_io_tasks_prevent_eviction",X="durable_object_io_tasks_do_not_prevent_eviction",Z=/^\d{4}-\d{2}-\d{2}$/,ee=(i,a,n)=>{i>=u||a.includes(f)||a.includes(X)||n.push(`compatibility_date "${i}" predates "${u}", so pending I/O (waitUntil, cross-Durable-Object RPC, service-binding calls, timers) does not keep a Durable Object alive once its last client disconnects — live-query refreshes and durable streams can be cut off mid-flight. Set compatibility_date >= "${u}" or add the "${f}" compatibility flag`)},te=(i,a,n)=>{const{error:e,merged:s,unverifiedKeys:o}=Y(i,a);return e!==void 0?{error:e,wrangler:s}:(o.length>0&&n.push(`env.${String(a)} overrides ${o.join(", ")}, which this validator doesn't have a verified inheritance rule for — validated against the TOP-LEVEL value only. Double-check ${o.length===1?"it":"them"} by hand for "${String(a)}".`),{wrangler:s})},ie=(i,a,n)=>{const e=[],s=[];if(!i||typeof i!="object")return e.push("wrangler config is not a valid object"),{errors:e,valid:!1,warnings:s};const{error:o,wrangler:t}=te(i,n,s);if(o!==void 0)return e.push(o),{errors:e,valid:!1,warnings:s};E(t.durable_objects?.bindings).find(r=>r.name==="SHARD"&&(r.class_name==="ShardDO"||r.class_name===_))||e.push(`durable_objects.bindings must include { "name": "SHARD", "class_name": "ShardDO" } (or "${_}" when the app merges its Durable Objects) — your dev server auto-reconciles this on startup, or add the binding manually`),h(t,e);const d=t.compatibility_date??"",c=Z.test(d);d&&!c?e.push(`compatibility_date must be in YYYY-MM-DD format (got "${d}")`):d<v&&e.push(`compatibility_date must be >= "${v}" (got "${d||"<missing>"}")`),H(t)&&c&&d<b&&e.push(`cache.enabled requires compatibility_date >= "${b}" (got "${d||"<missing>"}")`),c&&ee(d,t.compatibility_flags??[],s),p(t,a,e),z(t,a,s),D(t,e),O(t,a?.vectorIndexNames??[],e),T(t,e),R(t,e,s),l(t.workflows,"workflows",w,e),y(t,e),I(t,e),l(t.secrets_store_secrets,"secrets_store_secrets",B,e);for(const r of S)$(t,r,e,s);for(const r of j)l(t[r.key],r.key,r,e);for(const r of A)k(t,r,e);return L(t,e),C(t,e,s),N(t,e),U(t,e),G(t,e),P(t,e),K(t,e,s),V(t,e),W(t,e),M(t,e),x(t,e),F(t,n,s),{errors:e,valid:e.length===0,warnings:s}},ue=ie;export{v as REQUIRED_COMPATIBILITY_DATE,le as REQUIRED_FLAG,ue as validateWrangler,ie as validateWranglerConfig};
@@ -0,0 +1 @@
1
+ import{existsSync as a,readFileSync as d}from"node:fs";import{classifyEdit as l,applyAdditiveEdit as c}from"./applyAdditiveEdit-CH0VhMJ2.mjs";import{parseSchema as u}from"./parseSchema-D1Wbr1qv.mjs";import{w as f,r as p}from"./write-atomic-CY97nWi1.mjs";import{join as m}from"node:path";const F="/__lunora/schema-edit",b=t=>t==="destructive"||t==="duplicate-table"||t==="duplicate-column"||t==="duplicate-index"?409:t==="unknown-table"?404:t==="invalid-identifier"||t==="invalid-validator"?400:422,y=t=>({body:{error:t.reason,ok:!1},status:422}),h=t=>{if(!a(t))return{response:{body:{error:"no-schema-file",ok:!1},status:404}};const r=u(d(t,"utf8"));return r.ok?{tables:r.tables}:{response:y(r)}},k=t=>({body:{edit:t,message:"This edit changes stored data and must go through a migration. Review the migration before applying.",needsMigration:!0,ok:!1},status:409}),g=(t,r)=>{const e=t.body;if(e==null||typeof e!="object"||typeof e.kind!="string")return{body:{error:"invalid-edit",ok:!1},status:400};if(l(e)==="destructive")return k(e);if(!a(r))return{body:{error:"no-schema-file",ok:!1},status:404};const o=c(d(r,"utf8"),e);if(!o.ok)return{body:{error:o.reason,ok:!1},status:b(o.reason)};f(r,o.text);let i;try{i=p(t)}catch(s){return{body:{error:s instanceof Error?s.message:String(s),ok:!1},status:500}}const n=u(o.text);return{body:{diagnostics:i,ok:!0,tables:n.ok?n.tables:[]},status:200}},R=t=>{const r=m(t.projectRoot,t.schemaDirectory??"lunora","schema.ts");if(t.method==="GET"){const e=h(r);return"response"in e?e.response:{body:{ok:!0,tables:e.tables},status:200}}return t.method==="POST"?g(t,r):{body:{error:"method-not-allowed",ok:!1},status:405}};export{F as SCHEMA_EDIT_ENDPOINT,R as handleSchemaEditRequest};
@@ -0,0 +1 @@
1
+ import{existsSync as y}from"node:fs";import{discoverSchema as p,schemaFromIr as h}from"@lunora/codegen";import{seedPlan as k}from"@lunora/seed";import{Project as S}from"ts-morph";import{join as g}from"node:path";const P="/__lunora/seed",w=1e3,j=(o,t)=>typeof t=="bigint"?Number(t):t instanceof ArrayBuffer?[...new Uint8Array(t)]:t,N=o=>typeof o!="number"||!Number.isFinite(o)?10:Math.min(Math.max(1,Math.floor(o)),w),A=o=>{if(o.method!=="POST")return{body:{error:"method-not-allowed",ok:!1},status:405};const{body:t}=o;if(t==null||typeof t!="object")return{body:{error:"invalid-request",ok:!1},status:400};const{count:f,existingIds:c,seed:m,table:e}=t;if(typeof e!="string"||e.length===0)return{body:{error:"missing-table",ok:!1},status:400};const l=o.schemaDirectory??"lunora",s=g(o.projectRoot,l,"schema.ts");if(!y(s))return{body:{error:"schema-not-found",ok:!1},status:404};const d=new S({skipAddingFilesFromTsConfig:!0}),n=p(d,s);if(!n.tables.some(r=>r.name===e))return{body:{error:"unknown-table",ok:!1,table:e},status:404};const u=h(n),a=k(u,{existingIds:c??{},defaultCount:N(f),only:[e],seed:m??0}),i=a.filter(r=>r.table!==e).map(r=>r.table);if(i.length>0)return{body:{error:"fk-parents-empty",ok:!1,tables:i},status:409};const b=a.find(r=>r.table===e)?.rows??[];return{body:{ok:!0,rows:JSON.parse(JSON.stringify(b,j))},status:200}};export{P as SEED_ENDPOINT,A as handleSeedRequest};
@@ -0,0 +1 @@
1
+ import{resolveAdminToken as A}from"./parseDevVariable-teAAahVD.mjs";import{sendStudioDocument as I,applyStudioAssetCache as O}from"./applyStudioAssetCache-DHQEJuuv.mjs";import{isStandaloneModulePath as _,studioAssetsStamp as H,loadStudioAssets as N,readStandaloneAsset as C,assetContentType as D}from"./assetContentType-CUb5bpbI.mjs";import{detectAgentRules as E}from"./AGENT_RULES_DIR-Bd6JPtNa.mjs";import{handlePolicyScaffoldRequest as v,POLICY_SCAFFOLD_ENDPOINT as L}from"./POLICY_SCAFFOLD_ENDPOINT-BlERq9JI.mjs";import R from"./renderStudioHtml-ByowDtMl.mjs";import{handleSchemaEditRequest as b,SCHEMA_EDIT_ENDPOINT as x}from"./SCHEMA_EDIT_ENDPOINT-DXjL7k72.mjs";import{handleSeedRequest as k,SEED_ENDPOINT as $}from"./SEED_ENDPOINT-2B56PN_H.mjs";import{serveJsonHandler as g}from"./serveJsonHandler-Dv0EdCb9.mjs";import{transportRejectionReason as j}from"./ALLOW_FORWARDED_ENV-BUndghJx.mjs";const d="/__lunora",F=`${d}/studio.js`,m=`${d}/styles.css`,y=/\/$/,M={[L]:v,[x]:b,[$]:k},U=new Set(["127.0.0.1","::1","localhost"]),X=t=>t!==void 0&&t!==!1&&!U.has(t),P=t=>t===void 0||t==="/"?"":t.replace(y,""),Z=t=>`${P(t)}${d}`,T=(t,a,c)=>{t.statusCode=200,t.setHeader("Content-Type",c),t.end(a)},q=t=>{try{return new URL(t,"http://localhost").pathname}catch{const a=t.indexOf("?");return a===-1?t:t.slice(0,a)}},tt=t=>{const{logger:a,projectRoot:c}=t,u=P(t.base);let l,f,S;const p=(o,n,e)=>{const i=H();if((l===void 0||i!==f)&&(l=N(a),f=i),l===void 0){e.statusCode=501,e.setHeader("Content-Type","text/plain"),e.end("Lunora studio assets not found — install and build @lunora/studio.");return}const s=o===m,r=o.slice(o.lastIndexOf("/")+1);if(O(n,e,r,i))return;if(s){T(e,l.styles,"text/css; charset=utf-8");return}const h=C(r);if(h===void 0){e.statusCode=404,e.setHeader("Content-Type","text/plain"),e.end("Not found");return}T(e,h,D(r))};return(o,n,e)=>{const i=q(o.url??"").replace(y,""),s=u!==""&&i.startsWith(u)?i.slice(u.length):i;if(s!==d&&!s.startsWith(`${d}/`)){e();return}if(t.isNonLoopbackBind||j(o,a)!==void 0){n.statusCode=403,n.setHeader("Content-Type","text/plain"),n.end("Lunora studio is only available on loopback hosts in dev.");return}const r=M[s];if(r!==void 0){g(o,n,r,c,{apiSpec:t.apiSpec,lazyFunctions:t.lazyFunctions,schemaDirectory:t.schemaDirectory});return}if(s===m||_(s)){p(s,o,n);return}S??=R({adminToken:A(c),basePath:d,dataEditable:!0,rulesInstalled:E(c).installed,runAsIdentity:!0,schemaEditable:!0,scriptSrc:F,styleHref:m}),I(n,S)}};export{d as STUDIO_PATH,F as STUDIO_SCRIPT_PATH,m as STUDIO_STYLE_PATH,tt as createStudioMiddleware,X as isNonLoopbackHost,q as requestPathname,Z as studioMountPath};
@@ -0,0 +1 @@
1
+ import{existsSync as h}from"node:fs";import{dirname as y,join as p}from"node:path";import{discoverSchemaInfo as E}from"./discoverSchemaInfo-BBRlXZop.mjs";import{MERGED_DURABLE_OBJECT as i,GENERATED_DIRECTORY as w,MERGED_ROLE_DURABLE_OBJECTS as u,COMPOSED_ENTRY_DURABLE_OBJECTS as $,GENERATED_CLASS_MODULES as k,isFrameworkDurableObject as D}from"./COMPOSED_WORKER_ENTRY-Ciiba5g_.mjs";import{o as R,f as j}from"./validate-bindings-PVHSAU6M.mjs";import{validateSchedulerOrigin as x}from"./withTailConsumer-CF3pk_Ov.mjs";import{l as O,r as _,s as A}from"./worker-entry-checks-AIASCYl7.mjs";import{mergeWranglerEnvironment as S}from"./mergeWranglerEnvironment-D5ekKj5x.mjs";import{findWranglerFile as W,readWranglerJsonc as C}from"./WRANGLER_FILES-UNW-xY5u.mjs";import{validateWranglerConfig as T}from"./REQUIRED_COMPATIBILITY_DATE-D4UcOP_t.mjs";const v=r=>Array.isArray(r)?r:[],L=(r,o,t)=>Object.entries(r?.images??{}).flatMap(([s,n])=>{const e=n?.dockerfile;return typeof e!="string"||h(e.startsWith("/")?e:p(o,e))?[]:[`containers images["${s}"] dockerfile "${e}" does not exist (resolved relative to ${t}); create the Dockerfile`]}),I=(r,o,t)=>{const s=[];for(const n of v(r)){const e=n?.image;typeof e=="string"&&(e.startsWith("./")||e.startsWith("../")||e.startsWith("/")||e.includes("Dockerfile"))&&!h(e.startsWith("/")?e:p(o,e))&&s.push(`containers image "${e}" does not exist (resolved relative to ${t}); create the Dockerfile or point image at a registry reference`),s.push(...L(n,o,t))}return s},P=(r,o)=>{const t=r?.vectorIndexNames??[],s=[];if(t.length>0&&s.push({message:e=>`schema declares vector index(es) ${t.map(l=>`"${l}"`).join(", ")} but nothing chains .vectors(...) onto defineApp() (composed in: ${e}) — \`ctx.vectors\` is then a throwing stub and buildWorkerOptions rejects EVERY request, /_lunora/health included. Add \`.vectors((env) => ({ ${String(t[0])}: env.<BINDING> }))\` to the chain.`,method:"vectors"}),r?.hasD1GlobalTable&&s.push({message:e=>`schema declares .global() table(s) but nothing chains .global(...) onto defineApp() (composed in: ${e}) — the shard then has no global writer, so every read or write of a global table throws INTERNAL ("requires a globalDb writer"). Add \`.global({ d1: (env) => env.DB })\` to the chain.`,method:"global"}),r?.hasHyperdriveGlobalTable&&s.push({message:e=>`schema declares .global({ backend: "hyperdrive" }) table(s) but nothing chains .hyperdriveGlobal(...) onto defineApp() (composed in: ${e}) — the shard then has no global writer, so every read or write of those tables throws INTERNAL. Add \`.hyperdriveGlobal({ engine: "postgres", exec: (env) => buildPgExec(fromPostgresJs(postgres(env.HYPERDRIVE.connectionString))) })\` to the chain (\`buildPgExec\` from \`@lunora/hyperdrive/global\`, \`fromPostgresJs\` from \`@lunora/hyperdrive\`).`,method:"hyperdriveGlobal"}),s.length===0)return[];const n=A(o,new Set(s.map(e=>e.method)));return n===void 0?[]:s.filter(e=>!n.chained.has(e.method)).map(e=>e.message(n.site))},G="does not export it",B=(r,o)=>{if(o.exports?.has(i)===!0&&u.has(r))return`This app merges its Durable Objects (\`durableObjects.merge\` in lunora.config), so ${i} hosts ${r}: bind only \`SHARD\` to "${i}" and drop the SCHEDULER / SHARD_REGISTRY bindings. Do that only if this Worker has never been deployed — a deployed ${r} namespace keeps its data, which the merged class cannot reach; turn \`durableObjects.merge\` off to keep it.`;if(r===i)return`${i} is the merged class (\`durableObjects.merge\` in lunora.config), and merging cannot be undone once deployed: the shard data lives in ${i}. Turn \`durableObjects.merge\` back on. Only a Worker that has never been deployed may rebind SHARD to "ShardDO".`;if(o.kind!=="composed")return`Re-export it from the module that defines it (\`export { ${r} } from "./…";\`), or add it to the app builder's own export (\`export const { ${r} } = app;\`).`;const t=`it exports ${$.join(", ")}, SchedulerDO when its binding is declared, and every class codegen emits from your ${k.map(s=>`${s}.ts`).join(" / ")} declarations`;return D(r)?`\`@lunora/vite\` generates that entry — ${t}, and ${r} is not among them. Class-A composition does not carry ${r}, so drop the binding; a project that needs it has to own its worker entry (add \`src/worker.ts\`, which \`lunora deploy\` bundles in place of \`main\`, and compose \`defineApp()\` there).`:`\`@lunora/vite\` generates that entry, so there is no file to add a re-export to: ${t}. Declare "${r}" in one of those and re-run \`lunora codegen\`, or drop the binding.`},M=(r,o)=>{const t=o.exports;if(t===void 0)return[];const s=[];for(const e of R(r.durable_objects?.bindings))typeof e.class_name=="string"&&e.class_name.length>0&&e.script_name===void 0&&s.push({className:e.class_name,label:"durable_objects.bindings"});for(const e of v(r.workflows))typeof e?.class_name=="string"&&e.class_name.length>0&&e.script_name===void 0&&s.push({className:e.class_name,label:"workflows"});for(const[e,l]of Object.entries(r.exports??{}))l?.type==="workflow"&&s.push({className:e,label:"workflows"});return s.filter(e=>!t.has(e.className)).map(e=>`${e.label} declares class "${e.className}" but the ${o.kind==="composed"?"composed class-A worker entry":"worker entry"} (${o.path}) ${G} — wrangler refuses to bundle a Worker whose ${e.label==="workflows"?"Workflow":"Durable Object"} classes are not exported. ${B(e.className,o)}`)},N=r=>[...j(r.migrations)].filter(o=>u.has(o)).map(o=>`migrations create class "${o}", which this app hosts in ${i} because it merges its Durable Objects (\`durableObjects.merge\`). Before the first deploy, replace "${o}" with "${i}" in new_sqlite_classes; a Worker already deployed with "${o}" keeps its data there and cannot merge — turn \`durableObjects.merge\` off.`),U=r=>r?.origin!=="absent"?[]:[`main is set but no readable file is there (looked in ${r.path}) — wrangler cannot resolve the worker entry, so a deploy will fail there. Point main at the entry that composes your app, or remove it to fall back to the conventional locations.`],Z=r=>{const o=r.schemaDir??"lunora",t=W(r.projectRoot);if(!t){const c=`wrangler.jsonc not found in ${r.projectRoot}; create one declaring at least the SHARD durable object binding.`;return{problems:[c],report:{errors:[c],valid:!1,warnings:[]},wranglerPath:void 0}}const{parsed:s}=C(t);if(s===void 0){const c=`failed to parse ${t} as JSONC.`;return{problems:[c],report:{errors:[c],valid:!1,warnings:[]},wranglerPath:t}}const{error:n,merged:e}=S(s,r.environment);if(n!==void 0)return{problems:[n],report:{errors:[n],valid:!1,warnings:[]},wranglerPath:t};const{error:l,info:f}=E(r.projectRoot,o),a=T(s,f,r.environment);l!==void 0&&a.warnings.push(`schema parse failed in ${o}/schema.ts: ${l}`);const g=y(t),b=O(e.main,r.projectRoot,t),m=_(b,r.projectRoot,o);a.errors.push(...I(e.containers??[],g,t)),a.warnings.push(...U(b)),m!==void 0&&a.errors.push(...M(e,m)),m?.exports?.has(i)===!0&&(a.errors.push(...N(e)),h(p(r.projectRoot,o,w,"scheduler.ts"))&&x(e,r.environment,a.warnings,"the merged LunoraDO hosts the scheduler")),a.errors.push(...P(f,r.projectRoot));const d=e.assets?.directory;if(typeof d=="string"&&d.length>0){const c=d.startsWith("/")?d:p(g,d);h(c)||a.warnings.push(`assets.directory "${d}" does not exist yet — it is created by the client build; run the build before deploy`)}return a.valid=a.errors.length===0,{problems:a.errors,report:a,wranglerPath:t}};export{G as UNEXPORTED_CLASS_MARKER,Z as validateWranglerProject};
@@ -0,0 +1 @@
1
+ const l="2026-05-01",n=e=>{if(!e)return!1;const c=typeof e.cache=="object"&&e.cache!==null&&e.cache.enabled===!0,o=typeof e.exports=="object"&&e.exports!==null&&Object.values(e.exports).some(t=>typeof t=="object"&&t!==null&&t.cache?.enabled===!0);return c||o};export{l as WORKERS_CACHE_MIN_DATE,n as isCacheEnabled};
@@ -0,0 +1 @@
1
+ import{existsSync as e,readFileSync as s}from"node:fs";import{parse as a}from"jsonc-parser";import{join as i}from"node:path";const l=["wrangler.jsonc","wrangler.json"],p=n=>{for(const r of l){const o=i(n,r);if(e(o))return o}},u=n=>{const r=s(n,"utf8"),o=[],t=a(r,o,{allowTrailingComma:!0});return o.length>0||t===null||typeof t!="object"?{parsed:void 0,text:r}:{parsed:t,text:r}};export{l as WRANGLER_FILES,p as findWranglerFile,u as readWranglerJsonc};
@@ -0,0 +1,2 @@
1
+ import{spawn as f}from"node:child_process";import{connect as h}from"node:net";const m=150,p=5e3,E=(e,t,r)=>f(e,[...t],{cwd:r.cwd,shell:r.shell,stdio:["ignore","pipe","pipe"]}),x=async e=>new Promise(t=>{const r=h({host:"127.0.0.1",port:e}),o=s=>{r.destroy(),t(s)};r.once("connect",()=>{o(!0)}),r.once("error",()=>{o(!1)})}),d=(e,t)=>{let r="";e?.setEncoding("utf8"),e?.on("data",o=>{r+=o;const s=r.split(`
2
+ `);r=s.pop()??"";for(const a of s)t(a)}),e?.once("end",()=>{r!==""&&(t(r),r="")})},w=e=>e.exitCode!==null||e.signalCode!==null,L=async e=>{const t=(e.spawn??E)(e.command,e.args,{cwd:e.cwd,shell:e.shell===!0});let r=!1,o,s;d(t.stdout,n=>{e.onLine(n,"stdout")}),d(t.stderr,n=>{e.onLine(n,"stderr")}),t.once("error",n=>{o=n.code==="ENOENT"?new Error(e.notFound):n}),t.once("exit",n=>{s??=new Error(`${e.label} exited with code ${String(n)} before it was ready`)});const a=new Promise(n=>{t.once("exit",i=>{r||n(i??1)})}),l=()=>{t.kill("SIGKILL")};process.once("exit",l);const c=async()=>{r=!0,process.removeListener("exit",l),!w(t)&&await new Promise(n=>{const i=setTimeout(()=>{t.kill("SIGKILL")},p);t.once("exit",()=>{clearTimeout(i),n()}),t.kill("SIGTERM")})},u=Date.now()+e.readyTimeoutMs;for(;Date.now()<u;){const n=o??s;if(n!==void 0)throw process.removeListener("exit",l),n;if(e.signal?.aborted===!0)throw await c(),new Error(`${e.label} was stopped before it was ready`);if(await x(e.port)){if(w(t))throw await c(),new Error(`the server on port ${String(e.port)} is not the ${e.label} started here — it exited while something else took the port`);return{crashed:a,stop:c}}await new Promise(i=>{setTimeout(i,m)})}throw await c(),new Error(`${e.label} did not accept connections on port ${String(e.port)} within ${String(e.readyTimeoutMs/1e3)}s`)};export{x as acceptsConnection,L as startDevProcess};
@@ -0,0 +1 @@
1
+ import{spawnSync as o}from"node:child_process";import{LunoraError as s}from"@lunora/errors";import{findPackageManagerSync as i,identifyInitiatingPackageManager as c}from"@visulima/package/package-manager";const a=["pnpm","bun","yarn","npm"],u=new Set(a),d=r=>u.has(r),l=r=>{try{return o(r,["--version"],{shell:process.platform==="win32",stdio:"ignore",timeout:5e3}).status===0}catch{return!1}},m=(r=l)=>a.filter(n=>r(n)),y=r=>({args:["install"],command:r}),E=(r,n,t={})=>{const e=t.dev===!0;return r==="npm"?{args:["install",...e?["--save-dev"]:[],...n],command:"npm"}:r==="bun"?{args:["add",...e?["-d"]:[],...n],command:"bun"}:{args:["add",...e?["-D"]:[],...n],command:r}},M=r=>{try{return i(r).packageManager}catch{}const n=c();if(n!==void 0){const e=n.name==="cnpm"?"npm":n.name;if(d(e))return e}const[t]=m();if(t!==void 0)return t;throw new s("INTERNAL","Could not detect a package manager: no lock file or `packageManager` field was found, and none (pnpm, bun, yarn, npm) is installed on PATH.")},g=(r,n,t)=>r==="yarn"?{args:[n,...t],command:"yarn"}:r==="bun"?{args:["x",n,...t],command:"bun"}:r==="npm"?{args:["--",n,...t],command:"npx"}:{args:["exec",n,...t],command:"pnpm"},b=(r,n)=>n.onPath===!0?{args:[...n.args],command:n.tool}:g(r,n.tool,n.args),P=(r,n)=>({args:["run",n],command:r}),h=(r,n)=>r==="npm"?`npm run ${n}`:r==="bun"?`bun run ${n}`:`${r} ${n}`;export{E as addArgsFor,m as detectInstalledManagers,M as detectPackageManager,g as execArgsFor,y as installArgsFor,P as runScriptArgsFor,h as runScriptCommand,b as toolchainExecArgs};
@@ -0,0 +1,6 @@
1
+ import{Project as p,SyntaxKind as n}from"ts-morph";import{collectCalls as m}from"./parseSchema-D1Wbr1qv.mjs";const v=/^[A-Za-z_$][\w$]*$/u,b=new Set(["any","array","bigint","boolean","bytes","date","id","literal","null","number","object","optional","record","storage","string","timestamp","union"]),u=e=>{if(e.getKind()===n.ParenthesizedExpression)return u(e.asKindOrThrow(n.ParenthesizedExpression).getExpression());if(e.getKind()!==n.CallExpression)return!1;const t=e.asKindOrThrow(n.CallExpression),r=t.getExpression();if(r.getKind()!==n.PropertyAccessExpression)return!1;const i=r.asKindOrThrow(n.PropertyAccessExpression);return i.getExpression().getKind()!==n.Identifier||i.getExpression().getText()!=="v"||!b.has(i.getName())?!1:t.getArguments().every(s=>c(s))},c=e=>{const t=e.getKind();return t===n.ParenthesizedExpression?c(e.asKindOrThrow(n.ParenthesizedExpression).getExpression()):t===n.StringLiteral||t===n.NumericLiteral||t===n.TrueKeyword||t===n.FalseKeyword||t===n.NullKeyword?!0:t===n.PrefixUnaryExpression?e.asKindOrThrow(n.PrefixUnaryExpression).getOperand().getKind()===n.NumericLiteral:t===n.ObjectLiteralExpression?e.asKindOrThrow(n.ObjectLiteralExpression).getProperties().every(r=>{if(r.getKind()!==n.PropertyAssignment)return!1;const i=r.getInitializer();return i!==void 0&&c(i)}):t===n.ArrayLiteralExpression?e.asKindOrThrow(n.ArrayLiteralExpression).getElements().every(r=>c(r)):u(e)},y=e=>{if(typeof e!="string"||e.trim().length===0)return!1;const t=new p({compilerOptions:{allowJs:!0},useInMemoryFileSystem:!0}),r=t.createSourceFile("validator.ts",`const __v = (${e});`,{overwrite:!0});if(t.getProgram().getSyntacticDiagnostics(r).length>0||r.getStatements().length!==1)return!1;const s=r.getVariableDeclaration("__v")?.getInitializer();return s!==void 0&&u(s)},E=new Set(["addIndex","addOptionalColumn","addTable"]),A=new Set(["d1","hyperdrive"]),T=e=>E.has(e.kind)?"additive":"destructive",d=e=>typeof e=="string"&&v.test(e),h=e=>{if(!d(e.table)||e.kind==="addTable"&&e.global?.backend!==void 0&&!A.has(e.global.backend))return"invalid-identifier";if(e.kind==="addOptionalColumn"){if(!d(e.column))return"invalid-identifier";if(!y(e.validator))return"invalid-validator"}if(e.kind==="addIndex"&&(!d(e.name)||!Array.isArray(e.fields)||!e.fields.every(t=>d(t))))return"invalid-identifier"},O=e=>{const r=new p({compilerOptions:{allowJs:!0},useInMemoryFileSystem:!0}).createSourceFile("schema.ts",e,{overwrite:!0});let i;for(const o of r.getDescendantsOfKind(n.CallExpression))if(o.getExpression().getText()==="defineSchema"){i=o;break}if(i===void 0)return{reason:r.getImportDeclarations().some(l=>l.getNamedImports().some(a=>a.getName()==="defineSchema"&&a.getAliasNode()!==void 0))?"aliased-define-schema":"no-define-schema"};const s=i.getArguments()[0];return s?.getKind()!==n.ObjectLiteralExpression?{reason:"non-object-argument"}:{object:s.asKindOrThrow(n.ObjectLiteralExpression),sourceFile:r}},g=(e,t)=>{for(const r of e.getProperties())if(r.getKind()===n.PropertyAssignment&&r.getNameNode().getText().replaceAll(/["']/gu,"")===t)return r},K=e=>{const t=e.getInitializer(),i=(t===void 0?void 0:m(t).find(s=>s.getExpression().getText()==="defineTable"))?.getArguments()[0];return i?.getKind()===n.ObjectLiteralExpression?i.asKindOrThrow(n.ObjectLiteralExpression):void 0},w=(e,t)=>{if(g(e,t.table)!==void 0)return"duplicate-table";const r=t.global?.backend,i=r===void 0?"":`{ backend: ${JSON.stringify(r)} }`,s=t.global===void 0?"":`.global(${i})`;e.addPropertyAssignment({initializer:`defineTable({
2
+ // Add your column validators here.
3
+ // Example:
4
+ // text: v.string(),
5
+ // createdAt: v.number(),
6
+ })${s}`,name:t.table})},k=(e,t)=>{const r=g(e,t.table);if(r===void 0)return"unknown-table";const i=K(r);if(i===void 0)return"unknown-table";if(i.getProperties().some(o=>o.getKind()===n.PropertyAssignment&&o.getNameNode().getText().replaceAll(/["']/gu,"")===t.column))return"duplicate-column";i.addPropertyAssignment({initializer:`v.optional(${t.validator})`,name:t.column})},S=(e,t)=>{if(e===void 0)return"unknown-table";const r=e.getInitializer();if(r===void 0)return"unknown-table";if(m(r).some(l=>{const a=l.getExpression();if(a.getKind()!==n.PropertyAccessExpression)return!1;const x=a.asKindOrThrow(n.PropertyAccessExpression),[f]=l.getArguments();return x.getName()==="index"&&f?.getKind()===n.StringLiteral&&f.asKindOrThrow(n.StringLiteral).getLiteralText()===t.name}))return"duplicate-index";const s=t.fields.map(l=>JSON.stringify(l)).join(", "),o=t.unique===!0?", { unique: true }":"";e.setInitializer(`${r.getText()}.index(${JSON.stringify(t.name)}, [${s}]${o})`)},N=(e,t)=>{if(T(t)==="destructive")return{ok:!1,reason:"destructive"};const r=t,i=h(r);if(i!==void 0)return{ok:!1,reason:i};const s=O(e);if("reason"in s)return{ok:!1,reason:s.reason};const{object:o,sourceFile:l}=s;let a;return r.kind==="addTable"?a=w(o,r):r.kind==="addOptionalColumn"?a=k(o,r):a=S(g(o,r.table),r),a!==void 0?{ok:!1,reason:a}:{ok:!0,text:l.getFullText()}};export{N as applyAdditiveEdit,T as classifyEdit};
@@ -0,0 +1 @@
1
+ import{modify as p,applyEdits as r}from"jsonc-parser";const s={formattingOptions:{insertSpaces:!0,tabSize:4}},a=(t,i,n)=>{const o=p(t,[...i],n,s);return o.length>0?r(t,o):t};export{s as FORMATTING,a as applyModify};
@@ -0,0 +1 @@
1
+ const n=t=>Array.isArray(t)?t[0]:t,o=(t,e,d,a)=>{if(e.setHeader("Cache-Control","no-cache"),a===void 0)return!1;const r=`W/"${d}-${String(a)}"`;return e.setHeader("ETag",r),n(t.headers?.["if-none-match"])!==r?!1:(e.statusCode=304,e.end(),!0)},c=(t,e)=>{t.statusCode=200,t.setHeader("Cache-Control","no-store"),t.setHeader("Content-Type","text/html; charset=utf-8"),t.end(e)};export{o as applyStudioAssetCache,c as sendStudioDocument};
@@ -0,0 +1,3 @@
1
+ import{LunoraError as n}from"@lunora/errors";import{lunoraLine as i}from"./LUNORA_TAG-DQTGPqcJ.mjs";import{validateWranglerProject as l}from"./UNEXPORTED_CLASS_MARKER-mdcw5KDY.mjs";const m=(e,a,t)=>{const r=l({projectRoot:e.projectRoot,schemaDir:e.schemaDir});if(!r.wranglerPath)throw new n("INTERNAL",["[lunora] wrangler.jsonc not found.",` searched in: ${e.projectRoot}`," create a wrangler.jsonc declaring at least the SHARD durable object binding."].join(`
2
+ `));for(const o of r.report.warnings)a(i(`wrangler validator: ${o}`));if(r.problems.length>0)throw new n("INTERNAL",["[lunora] wrangler configuration is missing bindings required by your schema.",` file: ${r.wranglerPath}`,"",...r.problems.map(o=>` - ${o}`),"",` ${t}`].join(`
3
+ `))};export{m as assertWranglerSatisfiesSchema};
@@ -0,0 +1 @@
1
+ import{readFileSync as o,statSync as i}from"node:fs";import{createRequire as n}from"node:module";import{normalize as u,join as a,relative as c,isAbsolute as d,dirname as l}from"node:path";const j=(t,s=import.meta.url)=>{try{const r=n(s);return{script:o(r.resolve("@lunora/studio/standalone/studio.js")),styles:o(r.resolve("@lunora/studio/styles.css"))}}catch(r){const e=r instanceof Error?r.message:String(r);t?.warnOnce?.(`[lunora] studio assets unavailable (build @lunora/studio?): ${e}`);return}},S=(t=import.meta.url)=>{try{const s=n(t),r=i(s.resolve("@lunora/studio/standalone/studio.js")).mtimeMs,e=i(s.resolve("@lunora/studio/styles.css")).mtimeMs;return Math.max(r,e)}catch{return}},v=(t=import.meta.url)=>{try{return l(n(t).resolve("@lunora/studio/standalone/studio.js"))}catch{return}},m=(t,s)=>{if(s===""||s==="."||s===".."||s.includes("/")||s.includes("\\")||s.includes("\0"))return;const r=u(a(t,s)),e=c(t,r);if(!(e===""||e.startsWith("..")||d(e)||e.includes("/")||e.includes("\\")))return r},f=(t,s=import.meta.url)=>{const r=v(s);if(r===void 0)return;const e=m(r,t);if(e!==void 0)try{return o(e)}catch{return}},M=t=>t.endsWith(".js")||t.endsWith(".js.map"),W=t=>t.endsWith(".css")?"text/css; charset=utf-8":t.endsWith(".map")?"application/json; charset=utf-8":"text/javascript; charset=utf-8";export{W as assetContentType,M as isStandaloneModulePath,j as loadStudioAssets,f as readStandaloneAsset,m as resolveContainedFile,v as resolveStandaloneDirectory,S as studioAssetsStamp};
@@ -0,0 +1,3 @@
1
+ import{createHash as O,randomUUID as v}from"node:crypto";import{mkdirSync as _,rmSync as y,readFileSync as N,writeFileSync as I,linkSync as w,renameSync as R}from"node:fs";import{findWranglerFile as C,readWranglerJsonc as k}from"./WRANGLER_FILES-UNW-xY5u.mjs";import{join as $}from"node:path";const E=["CLOUDFLARE_HYPERDRIVE_LOCAL_CONNECTION_STRING_","WRANGLER_HYPERDRIVE_LOCAL_CONNECTION_STRING_"],p=e=>`${E[0]}${e}`,D="pnpm add -D @electric-sql/pglite @electric-sql/pglite-socket",m="postgres://postgres:postgres@127.0.0.1:1/postgres",A=(e,t,r)=>typeof t.localConnectionString=="string"&&t.localConnectionString!==""||E.some(o=>{const n=r[`${o}${e}`]??"";return n!==""&&n!==m}),H=(e,t,r=t.CLOUDFLARE_ENV,o)=>{const n=o??C(e),i=n===void 0?void 0:k(n).parsed,c=r===void 0||r===""?void 0:i?.env?.[r];return((c===void 0?i?.hyperdrive:c.hyperdrive)??[]).flatMap(a=>typeof a?.binding=="string"&&a.binding!==""&&!A(a.binding,a,t)?[a.binding]:[])},T=async({PGlite:e,PGLiteSocketServer:t,vector:r},o)=>{const n=await e.create({dataDir:o,...r===void 0?{}:{extensions:{vector:r}}});let i;try{i=new t({db:n,host:"127.0.0.1",maxConnections:16,port:0}),await i.start()}catch(a){throw await Promise.allSettled([i?.stop(),n.close()]),a}const[c="127.0.0.1",g="5432"]=i.getServerConn().split(":");return{connectionString:`postgres://postgres:postgres@${c}:${g}/postgres`,stop:async()=>{try{await i.stop()}finally{await n.close()}}}},P=/[^\w-]/gu,F=e=>{const t=e.replaceAll(P,"_");return t===e?e:`${t}-${O("sha256").update(e).digest("hex").slice(0,8)}`},q=e=>{try{return process.kill(e,0),!0}catch(t){return t.code==="EPERM"}},x=e=>{try{const t=JSON.parse(N($(e,"package.json"),"utf8")),r=new Set([...Object.keys(t.dependencies??{}),...Object.keys(t.devDependencies??{})]);return r.has("mysql2")&&!r.has("pg")&&!r.has("postgres")}catch{return!1}},f=new Set,G=()=>{for(const e of f)y(e,{force:!0});f.clear()};let h=!1;const U=()=>{h||(h=!0,process.once("exit",G))},S=e=>{try{const[t="",r=""]=N(e,"utf8").split(`
2
+ `),o=Number.parseInt(t,10);return Number.isInteger(o)?{kind:"pid",pid:o,token:r}:{kind:"garbage",pid:-1,token:""}}catch(t){return{kind:t.code==="ENOENT"?"gone":"unreadable",pid:-1,token:""}}},L=e=>e.kind==="pid"&&e.pid!==process.pid&&q(e.pid),j=(e,t)=>{try{w(e,t)}catch(r){if(r.code!=="EEXIST")throw r;return}return f.add(t),U(),{release:()=>{f.delete(t)&&y(t,{force:!0})}}},W=(e,t)=>{const r=`${e}.stale.${v()}`;try{R(e,r)}catch{return}const o=S(r);try{if(o.token!==t.token&&L(o)){try{w(r,e)}catch{}return{holder:o.pid}}return}finally{y(r,{force:!0})}},M=e=>{const t=`${e}.${String(process.pid)}.${v()}`;I(t,`${String(process.pid)}
3
+ ${v()}`,"utf8");try{for(let r=0;r<3;r+=1){const o=j(t,e);if(o!==void 0)return o;if(f.has(e))return{holder:process.pid};const n=S(e);if(n.kind==="unreadable"||L(n))return{holder:n.pid};const i=n.kind==="gone"?void 0:W(e,n);if(i!==void 0)return i}return{holder:S(e).pid}}finally{y(t,{force:!0})}},V=/@electric-sql\/pglite/u,B=async()=>{try{const[{PGlite:e},{PGLiteSocketServer:t}]=await Promise.all([import("@electric-sql/pglite"),import("@electric-sql/pglite-socket")]),r=await import("@electric-sql/pglite-pgvector").then(o=>o.vector,()=>{});return{createServer:async o=>T({PGlite:e,PGLiteSocketServer:t,vector:r},o)}}catch(e){const{code:t,message:r}=e;if((t==="ERR_MODULE_NOT_FOUND"||t==="MODULE_NOT_FOUND")&&V.test(r??""))return;throw e}},Q=async e=>{try{return{runtime:await e()}}catch(t){return{failure:t instanceof Error?t.message:String(t)}}},J=async(e,t,r)=>{try{const o=await e.createServer(t);return{connectionString:o.connectionString,stop:async()=>{try{await o.stop()}finally{r.release()}}}}catch(o){throw r.release(),o}},X=(e,t)=>`Hyperdrive binding ${e.map(r=>`"${r}"`).join(", ")}: the embedded Postgres is installed but failed to load (${t}), so \`ctx.sql\` will fail to connect in dev. Set ${p(e[0]??"<BINDING>")} to use a database of your own.`,Y=(e,t)=>{const r=e.map(n=>`"${n}"`).join(", "),o=p(e[0]??"<BINDING>");return t?`Hyperdrive binding ${r}: this project's SQL driver is mysql2, and the embedded database speaks PostgreSQL, so \`ctx.sql\` will fail to connect in dev. Set ${o} to a local MySQL connection string.`:`Hyperdrive binding ${r} has no local database, so \`ctx.sql\` will fail to connect in dev. Run \`${D}\` for an embedded Postgres, or set ${o}.`},te=async e=>{const t=e.env??process.env,r=H(e.projectRoot,t,void 0,e.wranglerConfigPath);if(r.length===0)return;const o=new Map,n=s=>{t[p(s)]=m,o.set(s,m)},i=[],c=async()=>{const s=i.splice(0),l=[...o];o.clear();for(const[d,u]of l)t[p(d)]===u&&Reflect.deleteProperty(t,p(d));await Promise.allSettled(s.map(async d=>d.stop()))},g=x(e.projectRoot),{failure:a,runtime:b}=g?{failure:void 0,runtime:void 0}:await Q(e.load??B);if(b===void 0){e.onWarning?.(a===void 0?Y(r,g):X(r,a));for(const s of r)n(s);return{bindings:[],stop:c}}try{for(const s of r){const l=$(e.projectRoot,".wrangler","state","lunora-pglite",F(s));_(l,{recursive:!0});const d=M(`${l}.lock`);if("holder"in d){e.onWarning?.(`Hyperdrive binding "${s}": another process (pid ${String(d.holder)}) has its embedded Postgres open, so \`ctx.sql\` will fail to connect here. Stop it, or set ${p(s)} to use a database of your own.`),n(s);continue}const u=await J(b,l,d);i.push({binding:s,stop:u.stop}),t[p(s)]=u.connectionString,o.set(s,u.connectionString)}}catch(s){e.onWarning?.(`Could not start the embedded Postgres for Hyperdrive: ${s instanceof Error?s.message:String(s)}`),await c();for(const l of r)n(l);return{bindings:[],stop:c}}return{bindings:i.map(({binding:s})=>s),stop:c}};export{H as bindingsNeedingDatabase,G as releaseHeldLocks,T as serveDatabase,te as startLocalHyperdrive};
@@ -0,0 +1 @@
1
+ import{describeErrorLevelFindings as t,sortedUniqueNames as a}from"@lunora/codegen";import{LUNORA_TAG as l,advisoryLine as r}from"./LUNORA_TAG-DQTGPqcJ.mjs";const m=(n,i)=>{for(const e of n.advisories){const o=r(e.level,e.name,e.detail,e.remediation);e.level==="ERROR"?i.error(o):i.warn(o)}for(const e of n.platformDiagnostics){const o=r(e.level==="error"?"ERROR":"WARN",e.name,e.message,e.remediation);e.level==="error"?i.error(o):i.warn(o)}},f=n=>{const{advisoryNames:i,platformDiagnosticNames:e}=t(n),o=a([...i,...e]);if(o.length===0)return;const s=o.length===1?"advisory/platform diagnostic":"advisories/platform diagnostics";return`${l} ${String(o.length)} ERROR-level ${s} (${o.join(", ")}) — see the log above for detail.`};export{f as blockingFindingsMessage,m as reportCodegenFindings};
@@ -0,0 +1,19 @@
1
+ import{randomBytes as _}from"node:crypto";import{existsSync as m,readFileSync as y,writeFileSync as h,linkSync as M,rmSync as g,renameSync as A,statSync as T}from"node:fs";import{join as p}from"node:path";import{LunoraError as F}from"@lunora/errors";import{DEV_VARS_FILE as u,DEV_VARS_EXAMPLE_FILE as f,parseDevVariableLine as $,parseDevVariableEntries as E,DEV_VARS_NEWLINE as C}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{C as P,M as j,s as I}from"./package-secrets-registry-BeheNwsP.mjs";const R=e=>[...P,...I(e)],S=32,N=["replace","openssl","changeme","change-me","change_me","change-this","change_this","your-","your_","example","placeholder","todo","fill-me","fill_me","fill-in","fill_in","xxx"],z=/[.*+?^${}()|[\]\\]/gu,B=/[a-z0-9]$/u,W=e=>{const t=e.trim().toLowerCase();return t===""||t.startsWith("<")&&t.endsWith(">")?!0:N.some(r=>{const s=r.replaceAll(z,String.raw`\$&`),o=B.test(r)?`(^|[^a-z0-9])${s}([^a-z0-9]|$)`:`(^|[^a-z0-9])${s}`;return new RegExp(o,"u").test(t)})},x=e=>_(e).toString("hex"),X=e=>j.has(e),D=(e,t,r)=>X(e)&&W(t)?r(S):void 0,ae=(e=x)=>e(S),H=(e,t,r)=>e.split(C).map(s=>{const n=$(s),o=n?D(n.key,n.value,t):void 0;return!n||o===void 0?s:(r.push(n.key),`${n.key}="${o}"`)}),G=e=>{if(e.devVarsExists)return{status:"exists"};if(e.exampleContent===void 0)return{status:"no-example"};const t=[];return{content:H(e.exampleContent,e.randomHex??x,t).join(`
2
+ `),generatedKeys:t,status:"generate"}},O=e=>e.includes('"')||e.includes("\\")?"":e.replaceAll("\r",String.raw`\r`).replaceAll(`
3
+ `,String.raw`\n`),w=e=>{const t=e.randomHex??x,r=new Set(E(e.existingContent).map(d=>d.key)),s=[],n=[],o=[];for(const d of e.exampleContent.split(C)){const i=$(d);if(!i||r.has(i.key))continue;const a=D(i.key,i.value,t);o.push(i.key),a===void 0?s.push(`${i.key}="${O(i.value)}"`):(n.push(i.key),s.push(`${i.key}="${a}"`))}return{additions:s,generatedKeys:n,missingKeys:o}},k=e=>e.length>0?` (generated ${e.join(", ")})`:"",b=e=>`${e}.tmp-${String(process.pid)}`,K=(e,t,r={})=>{const s=b(e);try{h(s,t,{encoding:"utf8",...r}),A(s,e)}catch(n){throw g(s,{force:!0}),n}},U=(e,t)=>{try{return h(e,t,{encoding:"utf8",flag:"wx",mode:384}),!0}catch(r){if(r.code==="EEXIST")return!1;throw r}},L=(e,t)=>{const r=b(e);try{h(r,t,{encoding:"utf8",flag:"wx",mode:384});try{return M(r,e),!0}catch(s){const{code:n}=s;if(n==="EEXIST")return!1;if(n==="EPERM"||n==="ENOTSUP")return U(e,t);throw s}}finally{g(r,{force:!0})}},ce=(e,t)=>{K(e,t,{mode:384})},v=5,V=e=>{try{const t=T(e);return{mtimeMs:t.mtimeMs,size:t.size}}catch{return}},Y=(e,t)=>e===void 0||t===void 0?!1:e.mtimeMs===t.mtimeMs&&e.size===t.size,q=(e,t)=>{for(let r=0;r<v;r+=1){const s=V(e),n=y(e,"utf8"),o=t(n);if(o.length===0)return[];const d=n.length>0&&!n.endsWith(`
4
+ `)?`
5
+ `:"",i=`${n}${d}${o.join(`
6
+ `)}
7
+ `,a=`${e}.tmp-${String(process.pid)}-${_(6).toString("hex")}`;try{h(a,i,{encoding:"utf8",mode:384});const c=V(e);if(!Y(s,c)){g(a,{force:!0});continue}return A(a,e),o}catch(c){throw g(a,{force:!0}),c}}throw new F("INTERNAL",`Failed to append to ${e} after ${String(v)} attempts — a concurrent writer kept winning the race.`)},de=async e=>{const t=p(e.cwd,u),r=p(e.cwd,f);if(!m(r))return{addedKeys:[],generatedKeys:[],status:"no-example"};const s=y(r,"utf8");if(!m(t)){const l=G({devVarsExists:!1,exampleContent:s,randomHex:e.randomHex});return l.status!=="generate"?{addedKeys:[],generatedKeys:[],status:"no-example"}:e.yes===!0||await e.confirm(`No ${u} found. Generate it from ${f} (secrets auto-filled)?`)?L(t,l.content)?(e.info(`Created ${u}${k(l.generatedKeys)}.`),{addedKeys:[],generatedKeys:l.generatedKeys,status:"generated"}):{addedKeys:[],generatedKeys:[],status:"skipped-exists"}:(e.info(`Skipped — copy ${f} to ${u} and fill it in when you're ready.`),{addedKeys:[],generatedKeys:[],status:"declined"})}const n=w({existingContent:y(t,"utf8"),exampleContent:s,randomHex:e.randomHex});if(n.missingKeys.length===0)return{addedKeys:[],generatedKeys:[],status:"exists"};const o=n.missingKeys.join(", ");if(!(e.yes===!0||await e.confirm(`${u} is missing ${String(n.missingKeys.length)} key(s) from ${f} (${o}). Add them?`)))return e.info(`Skipped — add ${o} to ${u} when you're ready.`),{addedKeys:[],generatedKeys:[],status:"declined"};const a=q(t,l=>w({existingContent:l,exampleContent:s,randomHex:e.randomHex}).additions).map(l=>$(l)?.key).filter(l=>l!==void 0);if(a.length===0)return{addedKeys:[],generatedKeys:[],status:"exists"};const c=n.generatedKeys.filter(l=>a.includes(l));return e.info(`Updated ${u} — added ${a.join(", ")}${k(c)}.`),{addedKeys:a,generatedKeys:c,status:"augmented"}},J=e=>[`# ${e.description}`,`# Docs: ${e.docsUrl}`,`${e.key}="${e.placeholderValue}"`].join(`
8
+ `),Q=(e,t)=>{const r=R(e).filter(s=>!t.has(s.key));return r.length===0?"":r.map(s=>J(s)).join(`
9
+
10
+ `)},le=(e,t)=>{const r=p(e,f),s=m(r)?y(r,"utf8"):"",n=new Set(E(s).map(i=>i.key)),o=Q(t,n);if(o==="")return[];const d=s.length>0&&!s.endsWith(`
11
+ `)?`
12
+ `:"";return K(r,`${s}${d}
13
+ ${o}
14
+ `),R(t).filter(i=>!n.has(i.key)).map(i=>i.key)},Z=e=>{const t=e.randomHex??x,r=[],s=H(e.existingContent,t,r),n=new Set(E(e.existingContent).map(c=>c.key)),o=[],d=[];for(const c of P)n.has(c.key)||(o.push(c.key),d.push(`# ${c.description}`,`${c.key}="${t(S)}"`));const i=s.join(`
15
+ `);if(d.length===0)return{addedKeys:o,content:i,filledKeys:r};const a=i===""||i.endsWith(`
16
+ `)?"":`
17
+ `;return{addedKeys:o,content:`${i}${a}${d.join(`
18
+ `)}
19
+ `,filledKeys:r}},ue=e=>{const t=p(e.cwd,u),r=m(t),s=r?y(t,"utf8"):"",n=Z({existingContent:s,randomHex:e.randomHex});if(n.filledKeys.length===0&&n.addedKeys.length===0)return{addedKeys:[],filledKeys:[],status:"unchanged"};if(r)K(t,n.content,{mode:384});else if(!L(t,n.content))return{addedKeys:[],filledKeys:[],status:"unchanged"};const o=[...n.filledKeys,...n.addedKeys];return e.info?.(`Generated ${String(o.length)} dev secret(s) in ${u}: ${o.join(", ")}`),{addedKeys:n.addedKeys,filledKeys:n.filledKeys,status:r?"filled":"created"}};export{Q as buildPackageSecretsBlock,de as ensureDevVariables,le as ensureDevVarsExample,ue as fillDevSecrets,ae as generateSecretValue,X as isMintableSecretKey,W as isPlaceholderValue,Z as planDevSecretsFill,w as planDevVariablesAugment,G as planDevVariablesScaffold,R as requiredSecrets,ce as writeDevVariablesFileAtomically};
@@ -0,0 +1,3 @@
1
+ import{writeFileSync as $,rmSync as V,existsSync as b,readFileSync as j}from"node:fs";import{dirname as E,resolve as h,join as y,sep as g,relative as v,isAbsolute as R}from"node:path";import{findWranglerFile as W,readWranglerJsonc as x}from"./WRANGLER_FILES-UNW-xY5u.mjs";import{DEV_VARS_FILE as F,parseDevVariableEntries as L}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";const B=".celld.wrangler.json",Y=y(".wrangler","deploy","config.json"),J=new Set(["$schema","assets","compatibility_date","compatibility_flags","containers","d1_databases","define","durable_objects","kv_namespaces","main","migrations","name","no_bundle","queues","r2_buckets","rules","services","triggers","vars","worker_loaders","workflows"]),K=new Set(["class_name","image","instance_type","max_instances","name","runtime"]),q=new Set(["CompiledWasm","Data","Text"]),G=/\r?\n/u,M=/[!*?[]/u,U=/[.[]/u,X=["deleted_classes","new_classes","renamed_classes","transferred_classes"],l=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),O=e=>Array.isArray(e)&&e.length===0||l(e)&&Object.values(e).every(t=>O(t)),z=e=>Array.isArray(e)?e.map(t=>{if(!l(t))return t;const s=X.find(r=>t[r]!==void 0);if(s!==void 0)throw new Error(`migration "${String(t.tag)}" uses \`${s}\`, which celld refuses — celld accepts only \`new_sqlite_classes\` migrations`);return{new_sqlite_classes:t.new_sqlite_classes,tag:t.tag}}):e,H=(e,t)=>Array.isArray(e)?e.map((s,r)=>l(s)?Object.fromEntries(Object.entries(s).filter(([n])=>{const o=K.has(n);return o||t.push(`containers[${String(r)}].${n}`),o})):s):e,Q=(e,t)=>Array.isArray(e)?e.filter((s,r)=>{const n=l(s)&&typeof s.type=="string"&&q.has(s.type);return n||t.push(`rules[${String(r)}]`),n}):e,Z=e=>{const t=[],s={};for(const[r,n]of Object.entries(l(e)?e:{}))l(n)&&n.type==="workflow"?t.push({binding:r,class_name:r,name:n.name}):s[r]=n;return{bindings:t,rest:s}},k=e=>{const t=[],s={},r=Z(e.exports),n={...e,exports:r.rest};for(const[o,i]of Object.entries(n)){if(!J.has(o)){O(i)||t.push(o);continue}switch(o){case"containers":{s[o]=H(i,t);break}case"migrations":{s[o]=z(i);break}case"rules":{s[o]=Q(i,t);break}default:s[o]=i}}if(r.bindings.length>0){const o=Array.isArray(s.workflows)?s.workflows:[];s.workflows=[...o,...r.bindings]}return{config:s,dropped:t}},ee=e=>{const[t=[],...s]=e.map(n=>h(n).split(g));let r=0;for(;r<t.length&&s.every(n=>n[r]===t[r]);)r+=1;return t.slice(0,r).join(g)||g},C=(e,t,s)=>{const r=o=>v(s,h(t,o)).split(g).join("/"),n={...e};return typeof e.main=="string"&&(n.main=r(e.main)),l(e.assets)&&typeof e.assets.directory=="string"&&(n.assets={...e.assets,directory:r(e.assets.directory)}),n},se=e=>{const t=y(e,".assetsignore");if(!b(t))return;const s=j(t,"utf8").split(G).map(r=>r.trim()).filter(r=>r!==""&&!r.startsWith("#")).filter(r=>M.test(r)||b(y(e,r)));if(s.length>0)throw new Error(`${t} hides ${s.join(", ")} from the assets, and celld has no .assetsignore — remove those files from ${e} first`);return t},re=(e,t)=>{const s=y(e,Y);if(!b(s))throw new Error(`wrangler \`main\` is the Vite virtual module "${t}", so celld deploys the Vite build output — and there is none yet. Run the project's build (\`vite build\`) first`);const{configPath:r}=JSON.parse(j(s,"utf8"));if(typeof r!="string")throw new TypeError(`${s} names no configPath`);return h(E(s),r)},A=e=>{const{parsed:t}=x(e);if(t===void 0)throw new Error(`${e} is not valid JSONC`);return t},D=(e,t,s,r)=>{const{d1_databases:n}=e;if(!Array.isArray(n)||r===s)return e;const o=Array.isArray(t.d1_databases)?t.d1_databases.filter(i=>l(i)):[];return{...e,d1_databases:n.map(i=>{if(!l(i))return i;const a=o.find(w=>w.binding===i.binding),c=a?.migrations_dir,f=h(s,typeof c=="string"?c:"migrations"),d=b(f)?{...i,migrations_dir:v(r,f).split(g).join("/")}:i,u=a?.migrations_pattern;return typeof u=="string"?{...d,migrations_pattern:v(r,h(s,u)).split(g).join("/")}:d})}},te=(e,t,s,r)=>{const{main:n}=s;if(typeof n!="string"||!n.startsWith("virtual:"))return{fromBuild:!1,source:s,sourcePath:t};if(r==="dev")throw new Error(`wrangler \`main\` is the Vite virtual module "${n}", which only a Vite build can resolve — \`celld dev\` rebuilds from a source file. Use \`vite dev\` for the dev loop and \`lunora deploy\` to ship the build to celld, or point \`main\` at a worker file`);const o=re(e,n);return{fromBuild:!0,source:A(o),sourcePath:o}},ne=(e,t,s,r,n)=>{const o=t.filter(c=>Object.hasOwn(s,c.split(U)[0]??c));let i=e;e.no_bundle!==void 0&&(i=Object.fromEntries(Object.entries(e).filter(([c])=>c!=="no_bundle")),o.push("no_bundle (celld re-bundles the build output)"));const a=r===void 0?void 0:se(r);return a!==void 0&&o.push(`${v(n,a)} (matched no files)`),{assetsIgnore:a,projected:i,reported:o}},I=e=>{const t=l(e.vars)?e.vars:{};return{...e,vars:{WORKER_ENV:"development",...t}}},le=(e,t)=>{const s=W(e);if(s===void 0)throw new Error(`no wrangler.jsonc or wrangler.json in ${e} — celld deploys from the project's Wrangler config`);const r=A(s),{fromBuild:n,source:o,sourcePath:i}=te(e,s,r,t),a=E(i),{config:c,dropped:f}=k(o),{assets:d}=o,u=l(d)&&typeof d.directory=="string"?h(a,d.directory):void 0,w=typeof o.main=="string"?E(h(a,o.main)):void 0,p=ee([a,w,u].filter(T=>T!==void 0));if(!n&&p!==a)throw new Error(`wrangler \`main\` and \`assets.directory\` must sit inside ${a} — celld resolves everything against the config's directory`);const _=D(C(c,a,p),r,e,p),m=n?ne(_,f,r,u,p):{assetsIgnore:void 0,projected:_,reported:f},N=t==="dev"?I(m.projected):m.projected,S=y(p,B),P=`${JSON.stringify(N,void 0,4)}
2
+ `;return{configPath:S,dropped:m.reported,write:()=>{$(S,P),m.assetsIgnore!==void 0&&V(m.assetsIgnore)}}},de=(e,t)=>{const s=A(t),r=E(t),{config:n,dropped:o}=k(s),i=typeof s.name=="string"?s.name:"service",a=v(e,r);if(a===".."||a.startsWith(`..${g}`)||R(a))throw new Error(`service ${i} (${r}) must sit inside ${e} — celld dev runs it from a config beside the app's`);const c=y(r,F),f=b(c)?Object.fromEntries(L(j(c,"utf8")).map(({key:_,value:m})=>[_,m])):{},d=D(C(n,r,e),s,r,e),u=l(d.vars)?d.vars:{},w=y(e,`.celld.service.${i.replaceAll(/[^\w.-]/gu,"-")}.wrangler.json`),p=`${JSON.stringify(I({...d,vars:{...u,...f}}),void 0,4)}
3
+ `;return{configPath:w,dropped:o,write:()=>{$(w,p)}}};export{de as a,le as p};
@@ -0,0 +1,24 @@
1
+ import{Project as p,SyntaxKind as o}from"ts-morph";import{projectUsesUmbrella as u}from"./detectFramework-Dfpvu6rD.mjs";const f=new Set(["action","mutation","query","stream"]),l=/^[A-Za-z_$][\w$]*$/u,d=new Set(["@lunora/server","lunorash/server"]),y=e=>u(e)?"lunorash/server":"@lunora/server",m=new Set(["scaffoldPolicy","wireRls"]),$=e=>m.has(e.kind)?"additive":"destructive",v=(e,s)=>{if(typeof e.name!="string"||typeof e.table!="string"||!l.test(e.name)||!l.test(e.table))return{ok:!1,reason:"invalid-identifier"};const r=`${e.name}Policies`,t=`${e.name}Roles`,n=JSON.stringify(e.table),i=`import { definePermission, definePolicies, definePolicy, defineRole } from "${s}";
2
+
3
+ /**
4
+ * Access rules for the ${e.table} table — scaffolded by the Lunora studio
5
+ * (plan 025). The \`when\` predicates below DENY by default (\`() => false\`);
6
+ * replace each TODO with the real condition, then wire \`${r}\`
7
+ * into the procedures that read/write ${e.table} via
8
+ * \`.use(rls(${r}, { roles: ${t} }))\`.
9
+ */
10
+ export const ${r} = definePolicies([
11
+ definePolicy({
12
+ on: "read",
13
+ table: ${n},
14
+ // TODO: return \`true\` to allow, a \`WhereInput\` to filter, or \`false\` to deny.
15
+ when: () => false,
16
+ }),
17
+ ]);
18
+
19
+ /** Named permissions \`${r}\` can check with \`ctx.auth.can(...)\`. */
20
+ export const ${e.name}View = definePermission("${e.name}:view");
21
+
22
+ /** Roles that grant the permissions above; register via \`rls(policies, { roles })\`. */
23
+ export const ${t} = [defineRole("${e.name}-admin", { permissions: [${e.name}View] })];
24
+ `;return{fileName:`${e.name}.policies.ts`,ok:!0,source:i}},h=e=>{const s=e.getExpression();if(s.getKind()!==o.PropertyAccessExpression)return;const r=s.asKindOrThrow(o.PropertyAccessExpression);return f.has(r.getName())?r.getExpression():void 0},g=(e,s)=>{const r=e.getImportDeclaration(t=>d.has(t.getModuleSpecifierValue()));if(r===void 0){e.addImportDeclaration({moduleSpecifier:s,namedImports:["rls"]});return}r.getNamedImports().some(t=>t.getName()==="rls")||r.addNamedImport("rls")},w=e=>{const s=e.getDescendantsOfKind(o.CallExpression);e.getKind()===o.CallExpression&&s.push(e.asKindOrThrow(o.CallExpression));for(const r of s){const t=r.getExpression();if(t.getKind()!==o.PropertyAccessExpression)continue;const n=t.asKindOrThrow(o.PropertyAccessExpression),[i]=r.getArguments();if(n.getName()==="use"&&i?.getKind()===o.CallExpression&&i.asKindOrThrow(o.CallExpression).getExpression().getText()==="rls")return!0}return!1},I=(e,s,r)=>{if(typeof s.policies!="string"||!l.test(s.policies))return{ok:!1,reason:"invalid-identifier"};const n=new p({compilerOptions:{allowJs:!0},useInMemoryFileSystem:!0}).createSourceFile("procedure.ts",e,{overwrite:!0}),i=n.getVariableDeclaration(s.exportName),c=i?.getInitializer();if(i===void 0||c?.getKind()!==o.CallExpression)return{ok:!1,reason:"unknown-procedure"};const a=h(c.asKindOrThrow(o.CallExpression));return a===void 0?{ok:!1,reason:"unsupported-procedure-shape"}:w(a)?{ok:!1,reason:"already-wired"}:(a.replaceWithText(`${a.getText()}.use(rls(${s.policies}))`),g(n,r),{ok:!0,text:n.getFullText()})};export{$ as classifyPolicyEdit,y as resolveServerModule,v as scaffoldPolicyFile,I as wireRlsIntoProcedure};
@@ -0,0 +1,7 @@
1
+ import{createInterface as v}from"node:readline";const y=/[\s,]+/u,u=()=>process.stdin.isTTY,d=async a=>{const e=v({input:process.stdin,output:process.stdout});try{return await new Promise(s=>{e.question(a,r=>{s(r)})})}finally{e.close()}},b=async(a,e)=>{const r=(await d(a)).trim().toLowerCase();return r===""?e?.defaultYes===!0:r==="y"||r==="yes"},S=(a="")=>u()?e=>b(`${a}${e} [Y/n] `,{defaultYes:!0}):()=>Promise.resolve(!1),T=async(a,e,s)=>{if(!u()||e.length===0)return s?.default;const r=s?.default===void 0?-1:e.findIndex(n=>n.value===s.default),f=e.map((n,t)=>` ${String(t+1)}) ${n.label}${n.description===void 0?"":` — ${n.description}`}`),m=`${a}
2
+ ${f.join(`
3
+ `)}
4
+ > ${r>=0?`[${String(r+1)}] `:""}`,i=(await d(m)).trim();if(i==="")return s?.default;const c=Number.parseInt(i,10);return Number.isInteger(c)&&c>=1&&c<=e.length?e[c-1]?.value:e.find(n=>n.value===i||n.label.toLowerCase()===i.toLowerCase())?.value??s?.default},g=async(a,e)=>{if(!u())return e?.default;const r=(await d(a)).trim();return r===""?e?.default:r},h=async(a,e,s)=>{const r=s?.defaults??[];if(!u()||e.length===0)return[...r];const f=e.map((t,o)=>` ${String(o+1)}) ${t.label}${t.description===void 0?"":` — ${t.description}`}`),m=r.length===0?"":`[${r.join(", ")}] `,w=`${a} (comma-separated; Enter for default)
5
+ ${f.join(`
6
+ `)}
7
+ > ${m}`,c=(await d(w)).trim();if(c==="")return[...r];const $=c.split(y).map(t=>t.trim()).filter(t=>t!==""),n=new Set;for(const t of $){const o=Number.parseInt(t,10);if(Number.isInteger(o)&&o>=1&&o<=e.length&&String(o)===t){const l=e[o-1]?.value;l!==void 0&&n.add(l);continue}const p=e.find(l=>l.value===t||l.label.toLowerCase()===t.toLowerCase());p!==void 0&&n.add(p.value)}return e.filter(t=>n.has(t.value)).map(t=>t.value)};export{S as createConfirm,u as isInteractive,h as promptMultiSelect,T as promptSelect,g as promptText,b as promptYesNo};
@@ -0,0 +1 @@
1
+ const n=()=>{const e=new Map;return{clear:()=>{e.clear()},memo:(r,c)=>{if(e.has(r))return e.get(r);const t=c();return e.set(r,t),t}}};export{n as createDiscoveryCache};