@lunora/config 1.0.0-alpha.33 → 1.0.0-alpha.330

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 (126) hide show
  1. package/LICENSE.md +135 -0
  2. package/README.md +3 -3
  3. package/dist/cloudflare/index.d.mts +1232 -0
  4. package/dist/cloudflare/index.d.ts +1232 -0
  5. package/dist/cloudflare/index.mjs +1 -0
  6. package/dist/index.d.mts +1051 -917
  7. package/dist/index.d.ts +1051 -917
  8. package/dist/index.mjs +1 -23
  9. package/dist/packem_shared/ACCENT-CotPTfv7.mjs +7 -0
  10. package/dist/packem_shared/AGENT_MODE_ENV-D8MvSwPE.mjs +1 -0
  11. package/dist/packem_shared/AGENT_RULES_DIR-HrrbNZPy.mjs +1 -0
  12. package/dist/packem_shared/ALLOW_FORWARDED_ENV-BUndghJx.mjs +1 -0
  13. package/dist/packem_shared/BINDING_MANIFEST_VERSION-CfXEYG8e.mjs +1 -0
  14. package/dist/packem_shared/CLOUDFLARE_CLI_CONFIG_WARNING_ENV-BKMrOuXV.mjs +1 -0
  15. package/dist/packem_shared/CLOUDFLARE_DRIVER-Ci3VIqnk.mjs +1 -0
  16. package/dist/packem_shared/CLOUDFLARE_TOOLCHAIN_VERSIONS-DV5E_f_q.mjs +1 -0
  17. package/dist/packem_shared/CODEGEN_ENV-ZsCxV1kP.mjs +1 -0
  18. package/dist/packem_shared/COMPOSED_WORKER_ENTRY-Ciiba5g_.mjs +1 -0
  19. package/dist/packem_shared/DEFAULT_DEPLOY_TARGET-CfoV0tDu.mjs +1 -0
  20. package/dist/packem_shared/DEFAULT_OBSERVABILITY-bN6UkTMx.mjs +1 -0
  21. package/dist/packem_shared/DEV_BINDINGS_FILE-C0ZN_XlP.mjs +4 -0
  22. package/dist/packem_shared/DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs +6 -0
  23. package/dist/packem_shared/DEV_WORKER_ENV_VALUE-jek0qc2i.mjs +1 -0
  24. package/dist/packem_shared/GLOBAL_FETCH_STRICTLY_PUBLIC_FLAG-f8CnJha3.mjs +1 -0
  25. package/dist/packem_shared/LINKED_PROJECT_DIR-Ba5qPEwo.mjs +2 -0
  26. package/dist/packem_shared/LUNORA_EVENT_SOURCE-B9ZVohjO.mjs +1 -0
  27. package/dist/packem_shared/LUNORA_IGNORED_PATHS-U93uPxrW.mjs +19 -0
  28. package/dist/packem_shared/LUNORA_TAG-CiQM3BkI.mjs +1 -0
  29. package/dist/packem_shared/LunoraReporter-f277GLNT.mjs +6 -0
  30. package/dist/packem_shared/PACKAGE_SECRETS_REGISTRY-38Plje8b.mjs +1 -0
  31. package/dist/packem_shared/POLICY_SCAFFOLD_ENDPOINT-BquzWeBo.mjs +1 -0
  32. package/dist/packem_shared/REMOTE_ELIGIBLE_KEYS-BrOO_a0V.mjs +1 -0
  33. package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-OLQlG0oj.mjs +1 -0
  34. package/dist/packem_shared/SCHEMA_EDIT_ENDPOINT-DrZLd5rF.mjs +1 -0
  35. package/dist/packem_shared/SEED_ENDPOINT-2B56PN_H.mjs +1 -0
  36. package/dist/packem_shared/STUDIO_PATH-B-rhpKZU.mjs +1 -0
  37. package/dist/packem_shared/UNEXPORTED_CLASS_MARKER-IAK9PiDz.mjs +1 -0
  38. package/dist/packem_shared/WORKERS_CACHE_MIN_DATE-0k9ABJtF.mjs +1 -0
  39. package/dist/packem_shared/WRANGLER_FILES-UNW-xY5u.mjs +1 -0
  40. package/dist/packem_shared/acceptsConnection-DHhUYGjT.mjs +2 -0
  41. package/dist/packem_shared/addArgsFor-CYZKhNIo.mjs +1 -0
  42. package/dist/packem_shared/applyAdditiveEdit-CH0VhMJ2.mjs +6 -0
  43. package/dist/packem_shared/applyModify-DKP2l6S9.mjs +1 -0
  44. package/dist/packem_shared/applyStudioAssetCache-DHQEJuuv.mjs +1 -0
  45. package/dist/packem_shared/assertWranglerSatisfiesSchema-Dy0WXvP8.mjs +3 -0
  46. package/dist/packem_shared/assetContentType-CUb5bpbI.mjs +1 -0
  47. package/dist/packem_shared/buildPackageSecretsBlock-xaAqLu5K.mjs +19 -0
  48. package/dist/packem_shared/celld-config-D-L6uskI.mjs +3 -0
  49. package/dist/packem_shared/classifyPolicyEdit-DJi9Fk8G.mjs +24 -0
  50. package/dist/packem_shared/collectExportGaps-DKFdh_rd.mjs +2 -0
  51. package/dist/packem_shared/createConfirm-D5mKTMHj.mjs +7 -0
  52. package/dist/packem_shared/describePreservedCrons-C5KPuPy3.mjs +1 -0
  53. package/dist/packem_shared/detectFramework-Dfpvu6rD.mjs +1 -0
  54. package/dist/packem_shared/discover-info-DC2MrAIM.mjs +1 -0
  55. package/dist/packem_shared/discoverAgentInfo-pqFMJBtJ.mjs +1 -0
  56. package/dist/packem_shared/discoverContainerInfo-MI3HIHmJ.mjs +1 -0
  57. package/dist/packem_shared/discoverSchemaInfo-BLe1EVI8.mjs +1 -0
  58. package/dist/packem_shared/discoverWorkflowInfo-zW7Tt0Tn.mjs +1 -0
  59. package/dist/packem_shared/guards-Buu_E7mP.mjs +1 -0
  60. package/dist/packem_shared/infer-bindings-BsgN5eCm.mjs +1 -0
  61. package/dist/packem_shared/infer-bindings.d-RLlCg7Zn.d.mts +467 -0
  62. package/dist/packem_shared/infer-bindings.d-RLlCg7Zn.d.ts +467 -0
  63. package/dist/packem_shared/inferLunoraBindings-BCWWtftG.mjs +1 -0
  64. package/dist/packem_shared/interpretRemote-C9yJC_ZK.mjs +1 -0
  65. package/dist/packem_shared/lunora-manifest-DuH_Cmyu.mjs +6 -0
  66. package/dist/packem_shared/materializeServiceDevConfigs-KfEZ8o__.mjs +1 -0
  67. package/dist/packem_shared/mergeWranglerEnvironment-DXiB-HcS.mjs +1 -0
  68. package/dist/packem_shared/package-secrets-registry-BeheNwsP.mjs +1 -0
  69. package/dist/packem_shared/parseDevVariable-teAAahVD.mjs +1 -0
  70. package/dist/packem_shared/parseSchema-D1Wbr1qv.mjs +1 -0
  71. package/dist/packem_shared/policy-scaffold.d-D2H4_G01.d.mts +86 -0
  72. package/dist/packem_shared/policy-scaffold.d-D2H4_G01.d.ts +86 -0
  73. package/dist/packem_shared/process-tree-once-Ou4SfxKM.mjs +1 -0
  74. package/dist/packem_shared/readProjectDependencies-l3uhUKjo.mjs +1 -0
  75. package/dist/packem_shared/reconcile-services-DFqH4eMQ.mjs +1 -0
  76. package/dist/packem_shared/reconcileBindingsSafely-DOOsXXB7.mjs +1 -0
  77. package/dist/packem_shared/reconcileWranglerCompatibilityDate-hocXEuRA.mjs +1 -0
  78. package/dist/packem_shared/renderStudioHtml-ByowDtMl.mjs +15 -0
  79. package/dist/packem_shared/resolveSchemaDirectory-Ca5P6KuP.mjs +1 -0
  80. package/dist/packem_shared/runPostCodegenHook-Dx3yTsYZ.mjs +1 -0
  81. package/dist/packem_shared/scanWranglerVariablesForSecrets-BF-791aw.mjs +1 -0
  82. package/dist/packem_shared/serveJsonHandler-Dv0EdCb9.mjs +1 -0
  83. package/dist/packem_shared/startCelldDevSession-BLFsd6jG.mjs +1 -0
  84. package/dist/packem_shared/streamContainerLogs-0nko1qpv.mjs +2 -0
  85. package/dist/packem_shared/validate-bindings-CvNBF3U4.mjs +1 -0
  86. package/dist/packem_shared/withTailConsumer-DngzpJMK.mjs +1 -0
  87. package/dist/packem_shared/worker-entry-checks-AIASCYl7.mjs +1 -0
  88. package/dist/packem_shared/wranglerCodegenInputs-DBtq3faO.mjs +1 -0
  89. package/dist/packem_shared/wranglerToAlchemy-CBO2ucRm.mjs +6 -0
  90. package/dist/packem_shared/write-atomic-COUkUylA.mjs +1 -0
  91. package/dist/studio-host/index.d.mts +314 -110
  92. package/dist/studio-host/index.d.ts +314 -110
  93. package/dist/studio-host/index.mjs +1 -7
  94. package/package.json +16 -7
  95. package/dist/packem_shared/ACCENT-DW1XJn8i.mjs +0 -40
  96. package/dist/packem_shared/AGENT_RULES_DIR-lcgC08aE.mjs +0 -40
  97. package/dist/packem_shared/DEV_VARS_EXAMPLE_FILE-dJPNTEnK.mjs +0 -37
  98. package/dist/packem_shared/LINKED_PROJECT_DIR-CXwXzV_C.mjs +0 -52
  99. package/dist/packem_shared/LUNORA_CONFIG_FILE-CtcIcB5-.mjs +0 -34
  100. package/dist/packem_shared/LUNORA_EVENT_SOURCE-D2fDeGB6.mjs +0 -86
  101. package/dist/packem_shared/LunoraReporter-Ci-bDCK9.mjs +0 -70
  102. package/dist/packem_shared/PACKAGE_SECRETS_REGISTRY-B8t_SdoZ.mjs +0 -70
  103. package/dist/packem_shared/POLICY_SCAFFOLD_ENDPOINT-CiC2IGKx.mjs +0 -103
  104. package/dist/packem_shared/REMOTE_ELIGIBLE_KEYS-BC7_e9Bz.mjs +0 -105
  105. package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-2YYyWJUq.mjs +0 -561
  106. package/dist/packem_shared/SCHEMA_EDIT_ENDPOINT-Df-Wrix-.mjs +0 -99
  107. package/dist/packem_shared/SEED_ENDPOINT-DVCjaGO-.mjs +0 -61
  108. package/dist/packem_shared/WRANGLER_FILES-DwSuC-Kn.mjs +0 -25
  109. package/dist/packem_shared/applyAdditiveEdit-C-snTFEV.mjs +0 -228
  110. package/dist/packem_shared/buildPackageSecretsBlock-DWDKHViT.mjs +0 -243
  111. package/dist/packem_shared/classifyPolicyEdit-BHeAqF8P.mjs +0 -99
  112. package/dist/packem_shared/createConfirm-fvpdgJ9s.mjs +0 -100
  113. package/dist/packem_shared/detectFramework-Br-BcPBq.mjs +0 -41
  114. package/dist/packem_shared/discoverContainerInfo-BXFs6Wav.mjs +0 -19
  115. package/dist/packem_shared/discoverSchemaInfo-BB-CKlTK.mjs +0 -25
  116. package/dist/packem_shared/discoverWorkflowInfo-CedvR0mn.mjs +0 -19
  117. package/dist/packem_shared/inferLunoraBindings-ByMwG-gH.mjs +0 -352
  118. package/dist/packem_shared/loadStudioAssets-Csk5RS4E.mjs +0 -28
  119. package/dist/packem_shared/parseDevVariable-CJiq2IwE.mjs +0 -30
  120. package/dist/packem_shared/parseSchema-DSeyktvG.mjs +0 -107
  121. package/dist/packem_shared/policy-scaffold.d-DCmwn7zQ.d.mts +0 -74
  122. package/dist/packem_shared/policy-scaffold.d-DCmwn7zQ.d.ts +0 -74
  123. package/dist/packem_shared/reconcileWranglerBindings-Cruwwx1M.mjs +0 -334
  124. package/dist/packem_shared/renderStudioHtml-449Ysn75.mjs +0 -37
  125. package/dist/packem_shared/serveJsonHandler-B4OLTGLS.mjs +0 -86
  126. 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-DWDKHViT.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 l,ROOT_SKILL_NAME as c,claimAgentRulesHint as p,detectAgentRules as d}from"./packem_shared/AGENT_RULES_DIR-HrrbNZPy.mjs";import{startCelldDevSession as A}from"./packem_shared/startCelldDevSession-BLFsd6jG.mjs";import{CODEGEN_ENV as m,isCodegenDisabled as f}from"./packem_shared/CODEGEN_ENV-ZsCxV1kP.mjs";import{discoverContainerInfo as R}from"./packem_shared/discoverContainerInfo-MI3HIHmJ.mjs";import{streamContainerLogs as N}from"./packem_shared/streamContainerLogs-0nko1qpv.mjs";import{detectFramework as g,projectUsesUmbrella as x}from"./packem_shared/detectFramework-Dfpvu6rD.mjs";import{acceptsConnection as I,startDevProcess as O}from"./packem_shared/acceptsConnection-DHhUYGjT.mjs";import{DEV_BINDINGS_FILE as u,DEV_DAEMON_ENV as C,DEV_HANDOFF_ENV as F,DEV_LOG_FILE as U,DEV_LOG_FILE_ENV as M,DEV_STATE_DIR as G,DEV_STATE_FILE as B,claimDevServerState as b,clearDevServerState as y,isDevServerReady as k,isProcessAlive as j,isRecordedProcessCurrent as K,readDevServerState as w,readLiveDevServerState as h,updateDevServerState as H,writeDevServerState as W}from"./packem_shared/DEV_BINDINGS_FILE-C0ZN_XlP.mjs";import{DEV_VARS_EXAMPLE_FILE as J,DEV_VARS_FILE as q,DEV_VARS_KEY_PATTERN as X,escapeRegExp as z,parseDevVariableEntries as Q,removeDevVariableLine as Z,upsertDevVariableLine as $}from"./packem_shared/DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{DEV_WORKER_ENV_VALUE as re,DEV_WORKER_ENV_VAR as oe,ensureDevWorkerEnv as te}from"./packem_shared/DEV_WORKER_ENV_VALUE-jek0qc2i.mjs";import{DEFAULT_DEPLOY_TARGET as Ee,deployTargetIds as se,isRunnableTarget as ie,planToolchainInvocation as ne,resolveDeployDriver as _e,runnableTargetIds as le,targetRunsOwnDevServer as ce}from"./packem_shared/DEFAULT_DEPLOY_TARGET-CfoV0tDu.mjs";import{i as de,s as De}from"./packem_shared/infer-bindings-BsgN5eCm.mjs";import{LINKED_PROJECT_DIR as Se,LINKED_PROJECT_FILE as me,readLinkedProject as fe,writeLinkedProject as Le}from"./packem_shared/LINKED_PROJECT_DIR-Ba5qPEwo.mjs";import{LUNORA_IGNORED_PATHS as ve,applyLintIgnores as Ne,detectLintTools as Te}from"./packem_shared/LUNORA_IGNORED_PATHS-U93uPxrW.mjs";import{LUNORA_TAG as xe,advisoryLine as Ve,blockingFindingsMessage as Ie,lunoraLine as Oe,reportCodegenFindings as Pe}from"./packem_shared/LUNORA_TAG-CiQM3BkI.mjs";import{LUNORA_EVENT_SOURCE as Ce,formatLunoraEvent as Fe}from"./packem_shared/LUNORA_EVENT_SOURCE-B9ZVohjO.mjs";import{default as Me}from"./packem_shared/LunoraReporter-f277GLNT.mjs";import{addArgsFor as Be,detectInstalledManagers as be,detectPackageManager as ye,execArgsFor as ke,installArgsFor as je,runScriptArgsFor as Ke,runScriptCommand as we,toolchainExecArgs as he}from"./packem_shared/addArgsFor-CYZKhNIo.mjs";import{P as We,s as Ye}from"./packem_shared/package-secrets-registry-BeheNwsP.mjs";import{runPostCodegenHook as qe}from"./packem_shared/runPostCodegenHook-Dx3yTsYZ.mjs";import{interpretRemote as ze,readProjectRemotePreference as Qe,readProjectTarget as Ze,resolveProjectTarget as $e,resolveTargetOrThrow as er}from"./packem_shared/interpretRemote-C9yJC_ZK.mjs";import{readProjectDependencies as or,readProjectDependencyNames as tr,readProjectManifest as ar}from"./packem_shared/readProjectDependencies-l3uhUKjo.mjs";import{createConfirm as sr,isInteractive as ir,promptMultiSelect as nr,promptSelect as _r,promptText as lr,promptYesNo as cr}from"./packem_shared/createConfirm-D5mKTMHj.mjs";import{default as dr}from"./packem_shared/resolveSchemaDirectory-Ca5P6KuP.mjs";import{buildPackageSecretsBlock as Ar,ensureDevVariables as Sr,ensureDevVarsExample as mr,fillDevSecrets as fr,generateSecretValue as Lr,isMintableSecretKey as Rr,isPlaceholderValue as vr,planDevSecretsFill as Nr,planDevVariablesAugment as Tr,planDevVariablesScaffold as gr,requiredSecrets as xr,writeDevVariablesFileAtomically as Vr}from"./packem_shared/buildPackageSecretsBlock-xaAqLu5K.mjs";import{applyAdditiveEdit as Or,classifyEdit as Pr}from"./packem_shared/applyAdditiveEdit-CH0VhMJ2.mjs";import{parseSchema as Cr}from"./packem_shared/parseSchema-D1Wbr1qv.mjs";import{classifyPolicyEdit as Ur,resolveServerModule as Mr,scaffoldPolicyFile as Gr,wireRlsIntoProcedure as Br}from"./packem_shared/classifyPolicyEdit-DJi9Fk8G.mjs";import{discoverSchemaInfo as yr}from"./packem_shared/discoverSchemaInfo-BLe1EVI8.mjs";import{ACCENT as jr,BADGES as Kr,BADGE_COLUMN_WIDTH as wr,LUNA_ART as hr,LUNA_BUNNY as Hr,LUNA_NAME as Wr,LUNA_SIGNOFF as Yr,STEP_BADGE_NAMES as Jr,badgeLead as qr,badgeWidth as Xr,padBadge as zr,paintAnswer as Qr,paintBadge as Zr}from"./packem_shared/ACCENT-CotPTfv7.mjs";import{COMPOSED_WORKER_ENTRY as eo,DURABLE_OBJECT_BINDINGS as ro,GENERATED_CLASS_MODULES as oo,GENERATED_MODULE_DURABLE_OBJECTS as to,MERGED_DURABLE_OBJECTS_MODULE as ao,isMergedProject as Eo,isMergedRoleModule as so}from"./packem_shared/COMPOSED_WORKER_ENTRY-Ciiba5g_.mjs";import{discoverWorkflowInfo as no}from"./packem_shared/discoverWorkflowInfo-zW7Tt0Tn.mjs";export{jr as ACCENT,o as AGENT_MODE_ENV,i as AGENT_RULES_DIR,n as AGENT_RULES_HINT,_ as AGENT_RULES_HINT_ENV,Kr as BADGES,wr as BADGE_COLUMN_WIDTH,m as CODEGEN_ENV,eo as COMPOSED_WORKER_ENTRY,Ee as DEFAULT_DEPLOY_TARGET,u as DEV_BINDINGS_FILE,C as DEV_DAEMON_ENV,F as DEV_HANDOFF_ENV,U as DEV_LOG_FILE,M as DEV_LOG_FILE_ENV,G as DEV_STATE_DIR,B as DEV_STATE_FILE,J as DEV_VARS_EXAMPLE_FILE,q as DEV_VARS_FILE,X as DEV_VARS_KEY_PATTERN,re as DEV_WORKER_ENV_VALUE,oe as DEV_WORKER_ENV_VAR,ro as DURABLE_OBJECT_BINDINGS,oo as GENERATED_CLASS_MODULES,to as GENERATED_MODULE_DURABLE_OBJECTS,Se as LINKED_PROJECT_DIR,me as LINKED_PROJECT_FILE,hr as LUNA_ART,Hr as LUNA_BUNNY,Wr as LUNA_NAME,Yr as LUNA_SIGNOFF,Ce as LUNORA_EVENT_SOURCE,ve as LUNORA_IGNORED_PATHS,l as LUNORA_SKILL_NAMES,xe as LUNORA_TAG,Me as LunoraReporter,ao as MERGED_DURABLE_OBJECTS_MODULE,We as PACKAGE_SECRETS_REGISTRY,c as ROOT_SKILL_NAME,Jr as STEP_BADGE_NAMES,I as acceptsConnection,Be as addArgsFor,Ve as advisoryLine,Or as applyAdditiveEdit,Ne as applyLintIgnores,qr as badgeLead,Xr as badgeWidth,Ie as blockingFindingsMessage,Ar as buildPackageSecretsBlock,p as claimAgentRulesHint,b as claimDevServerState,Pr as classifyEdit,Ur as classifyPolicyEdit,y as clearDevServerState,sr as createConfirm,se as deployTargetIds,d as detectAgentRules,t as detectAiAgent,g as detectFramework,be as detectInstalledManagers,Te as detectLintTools,ye as detectPackageManager,E as discoverAgentInfo,R as discoverContainerInfo,yr as discoverSchemaInfo,no as discoverWorkflowInfo,Sr as ensureDevVariables,mr as ensureDevVarsExample,te as ensureDevWorkerEnv,z as escapeRegExp,ke as execArgsFor,fr as fillDevSecrets,Fe as formatLunoraEvent,Lr as generateSecretValue,de as inferLunoraBindings,je as installArgsFor,ze as interpretRemote,f as isCodegenDisabled,k as isDevServerReady,ir as isInteractive,Eo as isMergedProject,so as isMergedRoleModule,Rr as isMintableSecretKey,vr as isPlaceholderValue,j as isProcessAlive,K as isRecordedProcessCurrent,ie as isRunnableTarget,Oe as lunoraLine,zr as padBadge,Qr as paintAnswer,Zr as paintBadge,Q as parseDevVariableEntries,Cr as parseSchema,Nr as planDevSecretsFill,Tr as planDevVariablesAugment,gr as planDevVariablesScaffold,ne as planToolchainInvocation,x as projectUsesUmbrella,nr as promptMultiSelect,_r as promptSelect,lr as promptText,cr as promptYesNo,w as readDevServerState,fe as readLinkedProject,h as readLiveDevServerState,or as readProjectDependencies,tr as readProjectDependencyNames,ar as readProjectManifest,Qe as readProjectRemotePreference,Ze as readProjectTarget,Z as removeDevVariableLine,Pe as reportCodegenFindings,xr as requiredSecrets,_e as resolveDeployDriver,$e as resolveProjectTarget,dr as resolveSchemaDirectory,Mr as resolveServerModule,er as resolveTargetOrThrow,qe as runPostCodegenHook,Ke as runScriptArgsFor,we as runScriptCommand,le as runnableTargetIds,Gr as scaffoldPolicyFile,De as secretSourcesFromBindings,Ye as secretsForPackages,A as startCelldDevSession,O as startDevProcess,N as streamContainerLogs,ce as targetRunsOwnDevServer,he as toolchainExecArgs,H as updateDevServerState,$ as upsertDevVariableLine,Br as wireRlsIntoProcedure,W as writeDevServerState,Vr as writeDevVariablesFileAtomically,Le 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 l}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"],p="lunora",N="Lunora AI rules not installed — run `lunora rules install` so your coding agent knows how to use Lunora.",d=()=>a(i),t=(n,o)=>l(n,u,o,"SKILL.md"),g=n=>{const o=[],r=[];for(const e of c)s(t(n,e))?o.push(e):r.push(e);return{installed:s(t(n,p)),missing:r,present:o}};export{u as AGENT_RULES_DIR,N as AGENT_RULES_HINT,i as AGENT_RULES_HINT_ENV,c as LUNORA_SKILL_NAMES,p as ROOT_SKILL_NAME,d 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"}},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 s="LUNORA_CODEGEN",t=o=>{const e=o?.trim().toLowerCase();return e==="0"||e==="false"};export{s as CODEGEN_ENV,t as isCodegenDisabled};
@@ -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-Ci3VIqnk.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-xaAqLu5K.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{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{describeErrorLevelFindings as c,sortedUniqueNames as d}from"@lunora/codegen";import{paintBadge as t,BADGES as r}from"./ACCENT-CotPTfv7.mjs";const a=t(r.lunora),v=n=>`${a} ${n}`,m={ERROR:r.error,INFO:r.info,WARN:r.warn},s=(n,i,e,o)=>`${t(m[n])} ${i}: ${e} — ${o}`,g=(n,i)=>{for(const e of n.advisories){const o=s(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=s(e.level==="error"?"ERROR":"WARN",e.name,e.message,e.remediation);e.level==="error"?i.error(o):i.warn(o)}},$=n=>{const{advisoryNames:i,platformDiagnosticNames:e}=c(n),o=d([...i,...e]);if(o.length===0)return;const l=o.length===1?"advisory/platform diagnostic":"advisories/platform diagnostics";return`${a} ${String(o.length)} ERROR-level ${l} (${o.join(", ")}) — see the log above for detail.`};export{a as LUNORA_TAG,s as advisoryLine,$ as blockingFindingsMessage,v as lunoraLine,g as reportCodegenFindings};
@@ -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-COUkUylA.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{writeFileSync as m,rmSync as b}from"node:fs";import{applyModify as g}from"./applyModify-DKP2l6S9.mjs";import{r as h}from"./lunora-manifest-DuH_Cmyu.mjs";import{o as y}from"./reconcile-services-DFqH4eMQ.mjs";import{findWranglerFile as S,readWranglerJsonc as v}from"./WRANGLER_FILES-UNW-xY5u.mjs";import{join as E}from"node:path";const l={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"}},j=Object.keys(l),d=(e,r)=>typeof e.binding=="string"?e.binding:r,u=(e,r,n,a)=>{const s=[];for(const[o,t]of r.entries())t!=null&&s.push({binding:d(t,`#${String(o)}`),kind:n,path:[...a,o],section:e});return s},p=(e,r)=>l[e].shape===r,R=(e,r)=>{const{label:n}=l[e];if(p(e,"array"))return u(e,r[e]??[],n,[]);if(p(e,"object")){const a=r[e];return a==null?[]:[{binding:d(a,e),kind:n,path:[],section:e}]}return u(e,r.queues?.producers??[],n,["producers"])},_=e=>j.flatMap(r=>R(r,e)),B=(e,r)=>{let n=e;for(const a of r)n=g(n,[a.section,...a.path,"remote"],!0);return n},i=()=>{},I=e=>{let r=!1;return()=>{if(!r){r=!0;try{b(e,{force:!0,recursive:!0})}catch{}}}};let f=0;const C=()=>(f+=1,`.wrangler.lunora-remote.${String(process.pid)}.${String(f)}.jsonc`),O=e=>{if(!e.enabled)return{cleanup:i,enabled:!1,remoteBindings:[]};const r=S(e.projectRoot);if(!r)return{cleanup:i,enabled:!0,reason:"wrangler.jsonc not found",remoteBindings:[]};const{parsed:n,text:a}=v(r);if(n===void 0)return{cleanup:i,enabled:!0,reason:`failed to parse ${r} as JSONC`,remoteBindings:[]};const s=y(h(e.projectRoot)),o=_(n).filter(c=>c.section!=="services"||!s.has(c.binding));if(o.length===0)return{cleanup:i,enabled:!0,reason:"no remote-eligible bindings to proxy",remoteBindings:[]};const t=E(e.projectRoot,C());return m(t,B(a,o),"utf8"),{cleanup:I(t),configPath:t,enabled:!0,remoteBindings:o}},L=e=>{if(e===void 0)return!1;const r=e.trim().toLowerCase();return r==="1"||r==="true"},$=e=>e.flag===!0||L(e.envValue)?!0:e.configPreference??!1;export{l as REMOTE_ELIGIBLE_KEYS,I as createCleanup,B as injectRemoteFlags,L as isRemoteEnvEnabled,O as materializeRemoteWranglerConfig,_ as planRemoteBindings,$ 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-CvNBF3U4.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-DngzpJMK.mjs";import{isCacheEnabled as H,WORKERS_CACHE_MIN_DATE as b}from"./WORKERS_CACHE_MIN_DATE-0k9ABJtF.mjs";import{mergeWranglerEnvironment as Y}from"./mergeWranglerEnvironment-DXiB-HcS.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-COUkUylA.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-HrrbNZPy.mjs";import{handlePolicyScaffoldRequest as v,POLICY_SCAFFOLD_ENDPOINT as L}from"./POLICY_SCAFFOLD_ENDPOINT-BquzWeBo.mjs";import R from"./renderStudioHtml-ByowDtMl.mjs";import{handleSchemaEditRequest as b,SCHEMA_EDIT_ENDPOINT as x}from"./SCHEMA_EDIT_ENDPOINT-DrZLd5rF.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",M=`${d}/studio.js`,m=`${d}/styles.css`,p=/\/$/,U={[L]:v,[x]:b,[$]:k},q=new Set(["127.0.0.1","::1","localhost"]),X=t=>t!==void 0&&t!==!1&&!q.has(t),y=t=>t===void 0||t==="/"?"":t.replace(p,""),Z=t=>`${y(t)}${d}`,T=(t,n,c)=>{t.statusCode=200,t.setHeader("Content-Type",c),t.end(n)},w=t=>{try{return new URL(t,"http://localhost").pathname}catch{const n=t.indexOf("?");return n===-1?t:t.slice(0,n)}},tt=t=>{const{logger:n,projectRoot:c}=t,u=y(t.base);let l,f,S;const P=(o,s,e)=>{const i=H();if((l===void 0||i!==f)&&(l=N(n),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 a=o===m,r=o.slice(o.lastIndexOf("/")+1);if(O(s,e,r,i))return;if(a){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,s,e)=>{const i=w(o.url??"").replace(p,""),a=u!==""&&i.startsWith(u)?i.slice(u.length):i;if(a!==d&&!a.startsWith(`${d}/`)){e();return}if(t.isNonLoopbackBind||j(o,n)!==void 0){s.statusCode=403,s.setHeader("Content-Type","text/plain"),s.end("Lunora studio is only available on loopback hosts in dev.");return}const r=U[a];if(r!==void 0){g(o,s,r,c,{apiSpec:t.apiSpec,schemaDirectory:t.schemaDirectory});return}if(a===m||_(a)){P(a,o,s);return}S??=R({adminToken:A(c),basePath:d,dataEditable:!0,rulesInstalled:E(c).installed,runAsIdentity:!0,schemaEditable:!0,scriptSrc:M,styleHref:m}),I(s,S)}};export{d as STUDIO_PATH,M as STUDIO_SCRIPT_PATH,m as STUDIO_STYLE_PATH,tt as createStudioMiddleware,X as isNonLoopbackHost,w 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-BLe1EVI8.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-CvNBF3U4.mjs";import{validateSchedulerOrigin as x}from"./withTailConsumer-DngzpJMK.mjs";import{l as O,r as _,s as A}from"./worker-entry-checks-AIASCYl7.mjs";import{mergeWranglerEnvironment as S}from"./mergeWranglerEnvironment-DXiB-HcS.mjs";import{findWranglerFile as W,readWranglerJsonc as C}from"./WRANGLER_FILES-UNW-xY5u.mjs";import{validateWranglerConfig as T}from"./REQUIRED_COMPATIBILITY_DATE-OLQlG0oj.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-CiQM3BkI.mjs";import{validateWranglerProject as l}from"./UNEXPORTED_CLASS_MARKER-IAK9PiDz.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,19 @@
1
+ import{randomBytes as V}from"node:crypto";import{existsSync as y,readFileSync as f,writeFileSync as _,renameSync as A,rmSync as x,statSync as b}from"node:fs";import{join as g}from"node:path";import{LunoraError as L}from"@lunora/errors";import{DEV_VARS_FILE as u,DEV_VARS_EXAMPLE_FILE as m,parseDevVariableLine as h,parseDevVariableEntries as K,DEV_VARS_NEWLINE as C}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{C as R,M,s as F}from"./package-secrets-registry-BeheNwsP.mjs";const D=e=>[...R,...F(e)],S=32,j=["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"],T=/[.*+?^${}()|[\]\\]/gu,z=/[a-z0-9]$/u,N=e=>{const t=e.trim().toLowerCase();return t===""||t.startsWith("<")&&t.endsWith(">")?!0:j.some(r=>{const s=r.replaceAll(T,String.raw`\$&`),o=z.test(r)?`(^|[^a-z0-9])${s}([^a-z0-9]|$)`:`(^|[^a-z0-9])${s}`;return new RegExp(o,"u").test(t)})},p=e=>V(e).toString("hex"),B=e=>M.has(e),H=(e,t,r)=>B(e)&&N(t)?r(S):void 0,se=(e=p)=>e(S),P=(e,t,r)=>e.split(C).map(s=>{const n=h(s),o=n?H(n.key,n.value,t):void 0;return!n||o===void 0?s:(r.push(n.key),`${n.key}="${o}"`)}),I=e=>{if(e.devVarsExists)return{status:"exists"};if(e.exampleContent===void 0)return{status:"no-example"};const t=[];return{content:P(e.exampleContent,e.randomHex??p,t).join(`
2
+ `),generatedKeys:t,status:"generate"}},W=e=>e.includes('"')||e.includes("\\")?"":e.replaceAll("\r",String.raw`\r`).replaceAll(`
3
+ `,String.raw`\n`),E=e=>{const t=e.randomHex??p,r=new Set(K(e.existingContent).map(d=>d.key)),s=[],n=[],o=[];for(const d of e.exampleContent.split(C)){const i=h(d);if(!i||r.has(i.key))continue;const a=H(i.key,i.value,t);o.push(i.key),a===void 0?s.push(`${i.key}="${W(i.value)}"`):(n.push(i.key),s.push(`${i.key}="${a}"`))}return{additions:s,generatedKeys:n,missingKeys:o}},w=e=>e.length>0?` (generated ${e.join(", ")})`:"",$=(e,t,r={})=>{const s=`${e}.tmp-${String(process.pid)}`;try{_(s,t,{encoding:"utf8",...r}),A(s,e)}catch(n){throw x(s,{force:!0}),n}},re=(e,t)=>{$(e,t,{mode:384})},k=5,v=e=>{try{const t=b(e);return{mtimeMs:t.mtimeMs,size:t.size}}catch{return}},G=(e,t)=>e===void 0||t===void 0?!1:e.mtimeMs===t.mtimeMs&&e.size===t.size,O=(e,t)=>{for(let r=0;r<k;r+=1){const s=v(e),n=f(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)}-${V(6).toString("hex")}`;try{_(a,i,{encoding:"utf8",mode:384});const c=v(e);if(!G(s,c)){x(a,{force:!0});continue}return A(a,e),o}catch(c){throw x(a,{force:!0}),c}}throw new L("INTERNAL",`Failed to append to ${e} after ${String(k)} attempts — a concurrent writer kept winning the race.`)},oe=async e=>{const t=g(e.cwd,u),r=g(e.cwd,m);if(!y(r))return{addedKeys:[],generatedKeys:[],status:"no-example"};const s=f(r,"utf8");if(!y(t)){const l=I({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 ${m} (secrets auto-filled)?`)?y(t)?{addedKeys:[],generatedKeys:[],status:"skipped-exists"}:($(t,l.content,{flag:"wx",mode:384}),e.info(`Created ${u}${w(l.generatedKeys)}.`),{addedKeys:[],generatedKeys:l.generatedKeys,status:"generated"}):(e.info(`Skipped — copy ${m} to ${u} and fill it in when you're ready.`),{addedKeys:[],generatedKeys:[],status:"declined"})}const n=E({existingContent:f(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 ${m} (${o}). Add them?`)))return e.info(`Skipped — add ${o} to ${u} when you're ready.`),{addedKeys:[],generatedKeys:[],status:"declined"};const a=O(t,l=>E({existingContent:l,exampleContent:s,randomHex:e.randomHex}).additions).map(l=>h(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(", ")}${w(c)}.`),{addedKeys:a,generatedKeys:c,status:"augmented"}},U=e=>[`# ${e.description}`,`# Docs: ${e.docsUrl}`,`${e.key}="${e.placeholderValue}"`].join(`
8
+ `),X=(e,t)=>{const r=D(e).filter(s=>!t.has(s.key));return r.length===0?"":r.map(s=>U(s)).join(`
9
+
10
+ `)},ie=(e,t)=>{const r=g(e,m),s=y(r)?f(r,"utf8"):"",n=new Set(K(s).map(i=>i.key)),o=X(t,n);if(o==="")return[];const d=s.length>0&&!s.endsWith(`
11
+ `)?`
12
+ `:"";return $(r,`${s}${d}
13
+ ${o}
14
+ `),D(t).filter(i=>!n.has(i.key)).map(i=>i.key)},Y=e=>{const t=e.randomHex??p,r=[],s=P(e.existingContent,t,r),n=new Set(K(e.existingContent).map(c=>c.key)),o=[],d=[];for(const c of R)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}},ae=e=>{const t=g(e.cwd,u),r=y(t),s=r?f(t,"utf8"):"",n=Y({existingContent:s,randomHex:e.randomHex});if(n.filledKeys.length===0&&n.addedKeys.length===0)return{addedKeys:[],filledKeys:[],status:"unchanged"};$(t,n.content,{mode:384});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{X as buildPackageSecretsBlock,oe as ensureDevVariables,ie as ensureDevVarsExample,ae as fillDevSecrets,se as generateSecretValue,B as isMintableSecretKey,N as isPlaceholderValue,Y as planDevSecretsFill,E as planDevVariablesAugment,I as planDevVariablesScaffold,D as requiredSecrets,re 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,2 @@
1
+ import{readFileSync as V,writeFileSync as X}from"node:fs";import{createRequire as z}from"node:module";import{join as F}from"node:path";import{containerBuildTag as Z}from"@lunora/container";import{readJsonSync as ee}from"@visulima/fs";import{applyModify as S}from"./applyModify-DKP2l6S9.mjs";import{a as ne,r as M}from"./lunora-manifest-DuH_Cmyu.mjs";import{parseTree as se,findNodeAtLocation as te}from"jsonc-parser";import{r as oe,a as ie,b as re,c as ae}from"./reconcile-services-DFqH4eMQ.mjs";import{a as de,s as ce}from"./infer-bindings-BsgN5eCm.mjs";import{DEV_VARS_FILE as le,parseDevVariableEntries as ue}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{requiredSecrets as ge}from"./buildPackageSecretsBlock-xaAqLu5K.mjs";import{w as me,m as pe,s as Q,o as B,n as C,p as fe}from"./validate-bindings-CvNBF3U4.mjs";import{s as be}from"./worker-entry-checks-AIASCYl7.mjs";import{DEFAULT_OBSERVABILITY as he}from"./DEFAULT_OBSERVABILITY-bN6UkTMx.mjs";import{findWranglerFile as we,readWranglerJsonc as ve}from"./WRANGLER_FILES-UNW-xY5u.mjs";const _e=[["maxBatchSize","max_batch_size"],["maxBatchTimeout","max_batch_timeout"],["maxConcurrency","max_concurrency"],["maxRetries","max_retries"],["deadLetterQueue","dead_letter_queue"],["retryDelay","retry_delay"]],R=e=>Object.fromEntries(_e.filter(([n])=>e.tuning[n]!==void 0).map(([n,s])=>[s,e.tuning[n]])),P="queueTuning",ye=/^[\t ]*(?:,[\t ]*)?(?:\/\/[^\n\r]*)?\r?\n/u,Se=/^[\t ]*,/u,xe=(e,n)=>{const s=se(e),t=s===void 0?void 0:te(s,[...n])?.parent;if(t?.type==="property"){const i=t.offset+t.length,o=e.lastIndexOf(`
2
+ `,t.offset-1)+1,d=ye.exec(e.slice(i));if(d!==null&&e.slice(o,t.offset).trim()===""){const a=t.parent?.children??[],b=a.indexOf(t),c=b===a.length-1&&b>0?a[b-1]:void 0,l=c===void 0?void 0:Se.exec(e.slice(c.offset+c.length))??void 0;return(l===void 0||c===void 0?e.slice(0,o):e.slice(0,c.offset+c.length)+e.slice(c.offset+c.length+l[0].length,o))+e.slice(i+d[0].length)}}return S(e,n,void 0)},Y=(e,n,s,t,i,o=new Set)=>{const d=s.join("."),a={},b=[],c=[];let l=e;return{entries:n.map((u,w)=>{const g=t(u);if(g===void 0||u.queue===void 0)return u;const p=Object.fromEntries(Object.entries(R(g)).filter(([f])=>!o.has(f))),h=Object.entries(i[u.queue]??{}).filter(([f])=>!Object.hasOwn(p,f)),v=Object.entries(p).filter(([f,y])=>u[f]!==y),x=h.filter(([f,y])=>u[f]===y).map(([f])=>f),N=Object.fromEntries(Object.entries({...u,...p}).filter(([f])=>!x.includes(f)));for(const[f,y]of v)l=S(l,[...s,w,f],y);for(const f of x)l=xe(l,[...s,w,f]);for(const[f,y]of h){const E=u[f];E!==void 0&&E!==y&&c.push(`${d}/${u.queue}: ${f} is no longer declared by defineQueue, but it was changed by hand to ${JSON.stringify(E)} from the declared ${JSON.stringify(y)}, so it was kept. Delete it from wrangler.jsonc if it should go.`)}return(v.length>0||x.length>0)&&b.push(`${d}/${u.queue} (${[...v.map(([f])=>f),...x.map(f=>`removed ${f}`)].join(", ")})`),Object.keys(p).length>0&&(a[u.queue]=p),N}),owned:a,text:l,updated:b,warnings:c}},Ne=(e,n,s,t)=>{const i=n.queues??{},o=i.producers??[],d=i.consumers??[],a=new Set(o.map(g=>g?.binding)),b=new Set(d.map(g=>g.queue)),c=s.filter(g=>!a.has(g.bindingName)),l=s.filter(g=>!b.has(g.name)),m=Y(e,d,["queues","consumers"],g=>s.find(p=>p.name===g.queue),t);let u=m.text;const w={...m.owned};if(c.length>0||l.length>0){const g=[...o,...c.map(h=>({binding:h.bindingName,queue:h.name}))],p=[...m.entries,...l.map(h=>({queue:h.name,...h.mode==="pull"?{type:"http_pull"}:{},...R(h)}))];for(const h of l){const v=R(h);Object.keys(v).length>0&&(w[h.name]=v)}u=S(u,["queues"],{consumers:p,producers:g})}return{added:[...c.map(g=>`queues.producers/${g.bindingName}`),...l.map(g=>`queues.consumers/${g.name}`)],owned:w,text:u,updated:m.updated,warnings:m.warnings}},Oe=(e,n,s,t,i)=>{const o=n.env?.[t],d=o?.queues?.consumers??[],a=o?.queues?.producers??[],b=u=>{const w=a.find(g=>g?.queue===u.queue)?.binding;return w!==void 0?s.find(g=>g.bindingName===w):s.find(g=>g.name===u.queue&&!a.some(p=>p?.binding===g.bindingName))},c=Y(e,d,["env",t,"queues","consumers"],b,i,new Set(["dead_letter_queue"])),l=d.filter(u=>u.queue!==void 0&&b(u)===void 0).map(u=>`env.${t}.queues.consumers/${String(u.queue)}: no defineQueue export matches it — this block declares no producer mapping one of their bindings to "${String(u.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.`),m=d.flatMap(u=>{const w=b(u)?.tuning.deadLetterQueue;return w===void 0||u.dead_letter_queue!==void 0?[]:[`env.${t}.queues.consumers/${String(u.queue)}: defineQueue declares deadLetterQueue "${w}", 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:c.owned,text:c.text,updated:c.updated,warnings:[...c.warnings,...m,...l]}},Ee=(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?.[P],t=i=>typeof i=="object"&&i!==null&&!Array.isArray(i);return s===void 0?{}:!t(s)||!Object.values(s).every(i=>t(i)&&Object.values(i).every(o=>t(o)))?(n.push(`${e?.path??"package.json"}: \`lunora.${P}\` 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},ke=(e,n,s)=>{const t=Object.fromEntries(Object.entries({...n,...s}).filter(([,i])=>Object.keys(i).length>0));ne(e,P,Object.keys(t).length===0?void 0:t)},j="PIPELINES",I="ARTIFACTS",$e=(e,n)=>{const s=e.flagshipBinding!==void 0&&!(n?.flagship??[]).some(a=>a.binding===e.flagshipBinding),t=e.usesPipelines&&!(n?.pipelines??[]).some(a=>a.binding===j),i=e.usesArtifacts?n?.artifacts??[]:[],o=i.some(a=>a.binding===I)?[]:i.flatMap(a=>a.binding===void 0?[]:[a.binding]);return[[e.usesKv&&(n?.kv_namespaces?.length??0)===0,"@lunora/bindings/kv is used but no kv_namespaces binding exists; add a kv_namespaces entry ({ binding, id }) and pass env.<BINDING> to createKv() — the namespace id can't be auto-provisioned."],[e.usesHyperdrive&&(n?.hyperdrive?.length??0)===0,"@lunora/hyperdrive is used but no hyperdrive binding exists; run 'wrangler hyperdrive create' and add a 'hyperdrive' binding ({ binding, id }) — the id can't be auto-provisioned."],[t,`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.`],[e.usesArtifacts&&i.length===0,de(e.jurisdiction)],[o.length>0,`ctx.artifacts is used and ${o.map(a=>`"${a}"`).join(", ")} ${o.length===1?"is":"are"} bound, but none is named "${I}"; make sure \`.artifacts()\` on defineApp points ctx.artifacts at it — otherwise it reads env.${I} and throws.`],[s,`lunora/flags.ts uses Flagship in binding mode but no flagship binding "${e.flagshipBinding??""}" exists; add a flagship entry ({ binding: "${e.flagshipBinding??""}", app_id }) — the app_id can't be auto-provisioned.`]].filter(([a])=>a).map(([,a])=>a)},Ae=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),D=(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(o=>o.className));if(s.size===0)return[];const t=Object.entries(n.exports??{}).flatMap(([o,d])=>d?.type==="workflow"?[o]:[]),i=(n.workflows??[]).flatMap(o=>o.class_name===void 0||o.script_name!==void 0?[]:[o.class_name]);return[...new Set([...t,...i])].filter(o=>!s.has(o)).map(o=>`wrangler.jsonc declares workflow "${o}" 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.`)},Ce=(e,n)=>{if(e.queues.length===0)return[];const s=new Set(e.queues.map(i=>i.name)),t=new Set(e.queues.map(i=>i.bindingName));return[...(n.queues?.consumers??[]).flatMap(i=>{const{queue:o}=i;return o===void 0||s.has(o)?[]:[`wrangler.jsonc subscribes queues.consumers[] to "${o}" 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(i=>{const o=i?.binding;return o===void 0||t.has(o)?[]:[`wrangler.jsonc declares queues.producers[] binding "${o}" but no defineQueue export declares it — a leftover from a rename. Remove it if it is not hand-wired.`]})]},je=(e,n)=>[...qe(e,n),...Ce(e,n)],G=[{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"}],Ie=()=>G.map(({keys:e,label:n})=>`${e[0]} + ${e[1]} (${n})`).join(" or "),De=e=>{let n;try{n=V(F(e,le),"utf8")}catch{return!1}const s=new Map(ue(n).map(t=>[t.key,t.value]));return G.some(({keys:t})=>t.every(i=>(s.get(i)??"")!==""))},Te=(e,n)=>{const s=n?.secrets?.required;if(!Array.isArray(s))return[];const t=new Set(s),i=ge(ce(e)).map(o=>o.key).filter(o=>!t.has(o));return i.length===0?[]:[`wrangler.jsonc declares secrets.required without ${i.join(", ")}, which this app needs — wrangler dev loads only the listed keys from .dev.vars, so add ${i.length===1?"it":"them"} to secrets.required.`]},T=(e,n,s)=>{const t=new Set(e.durableObjects.map(a=>a.className)),i=[],o=(s?.r2_buckets?.length??0)>0,d=(s?.d1_databases?.some(a=>a.binding==="DB")??!1)||e.needsD1;return e.usesStorage&&!o&&i.push("@lunora/storage is used but R2 bucket bindings have user-defined names; add an r2_buckets entry and pass env.<BINDING> to createStorage()."),e.usesAuth&&!t.has("SessionDO")&&!d&&i.push("@lunora/auth is used but the worker entry exports no SessionDO; sessions are D1-backed, or export SessionDO to enable DO-backed sessions."),e.usesScheduler&&!t.has("SchedulerDO")&&i.push("@lunora/scheduler is used but the worker entry exports no SchedulerDO; export it so the SCHEDULER binding can be provisioned."),i.push(...D("container","containers",e.containers),...D("workflow","workflows",e.workflows),...D("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&&!De(n)&&i.push(`@lunora/payment is used; set one provider's secret pair in .dev.vars — ${Ie()}.`),i.push(...Ae(e),...$e(e,s),...Te(e,s)),s!==void 0&&i.push(...je(e,s)),i},U="<replace-with-d1-create-id>",Be=e=>[["container","containers",e.containers],["workflow","workflows",e.workflows],["agent","agents",e.agents]].flatMap(([s,t,i])=>i.filter(o=>!o.exported).map(({className:o,exportName:d})=>({className:o,exportName:d,kind:s,module:t}))),Re=e=>{const n=new Set(B(e).map(t=>t.tag));let s=1;for(;n.has(`v${String(s)}`);)s+=1;return`v${String(s)}`},Pe=e=>{const n=new Set;for(const s of B(e)){for(const t of C(s.deleted_classes))n.delete(t);for(const{from:t,to:i}of B(s.renamed_classes))t!==void 0&&n.delete(t),i!==void 0&&n.add(i);for(const t of[...C(s.new_classes),...C(s.new_sqlite_classes)])n.add(t)}return n},Le=(e,n,s)=>{const t=n.durable_objects?.bindings??[],i=new Set(t.map(l=>l.name)),o=s.filter(l=>!i.has(l.binding));let d=e;const a=[];if(o.length>0){const l=[...t,...o.map(m=>({class_name:m.className,name:m.binding}))];d=S(d,["durable_objects","bindings"],l),a.push(...o.map(m=>`${m.binding}/${m.className}`))}const b=n.migrations??[],c=s.map(l=>l.className).filter(l=>!Pe(b).has(l));if(c.length>0){const l=[...b,{new_sqlite_classes:c,tag:Re(b)}];d=S(d,["migrations"],l)}return{added:a,text:d}},We=(e,n)=>{const s=n.d1_databases??[];if(s.some(o=>o.binding==="DB"))return{added:[],text:e};const t=typeof n.name=="string"&&n.name.length>0?n.name:"lunora",i=[...s,{binding:"DB",database_id:U,database_name:t}];return{added:["DB (D1)"],text:S(e,["d1_databases"],i)}},Me={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)"}},$=(e,n,s)=>{const{binding:t,label:i}=Me[s],o=n[s]?.binding;return typeof o=="string"&&o.length>0?{added:[],text:e}:{added:[i],text:S(e,[s],{binding:t})}},Ke=(e,n)=>e.usesAnalyticsSql&&be(n,new Set(["analyticsSql"]))?.chained.has("analyticsSql")!==!0,Fe=new Set(["ratelimits","send_email"]),Qe=["durable_objects","logfwdr","unsafe"],Ye=new Set(["data_blobs","text_blobs","vars","wasm_modules"]),W=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),L=(e,n,s)=>W(e)&&e[n]===s,Ge=(e,n,s)=>{if(Ye.has(e))return W(n)&&Object.hasOwn(n,s);const t=Fe.has(e)?"name":"binding";return Array.isArray(n)?n.some(i=>L(i,t,s)):L(n,"binding",s)},Ue=(e,n)=>{const s=e,t=Object.entries(s).find(([o,d])=>o!=="env"&&Ge(o,d,n));if(t!==void 0)return t[0];for(const o of Qe){const d=s[o];if(W(d)&&Array.isArray(d.bindings)&&d.bindings.some(a=>L(a,"name",n)))return`${o}.bindings`}if(e.queues?.producers?.some(o=>o?.binding===n)===!0)return"queues.producers";const i=e.secrets?.required;if(Array.isArray(i)&&i.includes(n))return"secrets.required"},K=(e,n,s,t,i)=>{if((n[s]?.length??0)>0)return{added:[],text:e};const o=Ue(n,t.binding);return o!==void 0?{added:[],text:e,warnings:[`${s}: not adding ${JSON.stringify(t)} — the name "${t.binding}" is already bound by \`${o}\` in wrangler.jsonc. Add a ${s} entry under another binding name and point the matching \`defineApp()\` override at it.`]}:{added:[i],text:S(e,[s],[t])}},He=(e,n)=>{const s=n.worker_loaders??[];return s.some(t=>t.binding==="LOADER")?{added:[],text:e}:{added:["LOADER (Worker Loader)"],text:S(e,["worker_loaders"],[...s,{binding:"LOADER"}])}},Je=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},Ve=e=>{const{image:n}=e;return n.kind==="dockerfile"?n.dockerfilePath:n.kind==="registry"?n.reference:Z(e.exportName)},H=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}}},Xe=e=>{if(e.schedulingPolicy==="durable_object")return H(e);const{image:n}=e,s={class_name:e.className,image:Ve(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=Je(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},ze=(e,n,s)=>{const t=n.containers??[],i=new Set(t.map(c=>c.class_name)),o=s.filter(c=>!i.has(c.className));let d=o.length===0?e:S(e,["containers"],[...t,...o.map(c=>Xe(c))]);const a=[],b=[];for(const[c,l]of t.entries()){const m=s.find(g=>g.className===l.class_name);if(m===void 0)continue;const u=m.schedulingPolicy??"default";if((l.scheduling_policy??"default")!==u){b.push(`containers/${m.className} has scheduling_policy "${l.scheduling_policy??"default"}" in wrangler.jsonc but defineContainer "${m.exportName}" declares "${u}" — the policy is immutable, so replace the entry (and its container application) by hand.`);continue}const w=m.schedulingPolicy==="durable_object"?H(m).images:void 0;w!==void 0&&JSON.stringify(l.images)!==JSON.stringify(w)&&(d=S(d,["containers",c,"images"],w),a.push(`containers/${m.className}.images`))}return{added:o.map(c=>`containers/${c.className}`),text:d,updated:a,warnings:b}},Ze=(e,n)=>{if(n.observability!==void 0)return{added:[],text:e};const s=S(e,["observability"],{...he});return{added:["observability"],text:s}},J=[{minimum:[4,142],name:"wrangler"},{minimum:[1,61],name:"@cloudflare/vite-plugin"}],en=J.map(({minimum:e,name:n})=>`${n}@^${e.join(".")}.0`).join(" "),nn=(e,n)=>{try{const s=z(F(e,"package.json")).resolve(`${n}/package.json`),[t=0,i=0]=String(ee(s).version).split(".").map(Number);return[t,i]}catch{return}},sn=e=>{const n=J.flatMap(({minimum:s,name:t})=>{const i=nn(e,t);return i!==void 0&&(i[0]<s[0]||i[0]===s[0]&&i[1]<s[1])?[`${t} ${i.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 ${en}\`) and re-run.`},tn=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.`]:[]),on=(e,n,s)=>{let t=e;const i=[],o=[];for(const d of s){const a=n[d.className];if(a?.type==="workflow")for(const{of:b,path:c}of fe){const l=b(d),m=Q(a,c),u=`exports/${d.className}.${c.join(".")}`;if(l===void 0){m!==void 0&&o.push(`${u} is set in wrangler.jsonc but defineWorkflow "${d.exportName}" does not declare it — reconcile leaves it in place. Remove it by hand if it was dropped from the definition.`);continue}JSON.stringify(m)!==JSON.stringify(l)&&(t=S(t,["exports",d.className,...c],l),i.push(u))}}return{text:t,updated:i,warnings:o}},rn=(e,n,s,t,i)=>{if(i!==void 0)return{added:[],text:e,warnings:[i]};const o=[...s.map(p=>({settings:me(p),workflow:p})),...t.map(p=>({settings:{},workflow:p}))],d=new Set(o.map(({workflow:p})=>p.className)),a=n.workflows??[],b=a.filter(p=>p.script_name===void 0&&p.class_name!==void 0&&d.has(p.class_name)),c=n.exports??{},l=[],m=[],u=[];let w=e;for(const{settings:p,workflow:h}of o){if(c[h.className]!==void 0&&c[h.className]!==null)continue;const v=b.find(f=>f.class_name===h.className),x=Object.fromEntries(pe.flatMap(f=>{const y=Q(v,[f]);return y===void 0?[]:[[f,y]]})),N=v?.name??h.name;v?.name!==void 0&&v.name!==h.name&&u.push(`workflows/${h.className} is deployed as "${v.name}" but declared as "${h.name}" — its export keeps "${v.name}" so running instances survive. Change the declaration to match, or rename deliberately (it starts a new, empty workflow).`),w=S(w,["exports",h.className],{type:"workflow",...x,...p,name:N}),(v===void 0?l:m).push(`exports/${h.className}`)}if(b.length>0){const p=a.filter(h=>!b.includes(h));w=S(w,["workflows"],p.length===0?void 0:p),m.push(...b.map(h=>`workflows/${String(h.class_name)} → exports`))}u.push(...tn(n));const g=on(w,c,s);return{added:l,text:g.text,updated:[...m,...g.updated],warnings:[...u,...g.warnings]}},xn=(e,n,s)=>{const t=we(e),i=Be(n);if(!t)return{added:[],changed:!1,exportGaps:i,reason:"wrangler.jsonc not found",updated:[],warnings:T(n,e)};const{parsed:o,text:d}=ve(t);if(o===void 0)return{added:[],changed:!1,exportGaps:i,reason:`failed to parse ${t} as JSONC`,updated:[],warnings:T(n,e),wranglerPath:t};const a=T(n,e,o);if(s!==void 0){const r=o.env?.[s]!==void 0;a.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 b=n.containers.filter(r=>r.exported),c=n.agents.filter(r=>r.exported&&r.voice===!0&&r.voiceBindingName!==void 0&&r.voiceClassName!==void 0),l=[...n.durableObjects,...b.map(r=>({binding:r.bindingName,className:r.className})),...c.map(r=>({binding:r.voiceBindingName,className:r.voiceClassName}))],m=n.workflows.filter(r=>r.exported),u=n.agents.filter(r=>r.exported),w=M(e),g=Ee(w,a),p={},h=oe(w);let v;const x=[{enabled:!0,run:r=>Le(r,o,l)},{enabled:n.needsD1,run:r=>We(r,o)},{enabled:n.usesAi,run:r=>$(r,o,"ai")},{enabled:n.usesAiSearch,run:r=>K(r,o,"ai_search_namespaces",{binding:"AI_SEARCH",namespace:"default"},"AI_SEARCH (AI Search namespace)")},{enabled:Ke(n,e),run:r=>$(r,o,"analytics")},{enabled:n.usesBrowser,run:r=>$(r,o,"browser")},{enabled:n.usesImages,run:r=>$(r,o,"images")},{enabled:n.usesAnalytics,run:r=>K(r,o,"analytics_engine_datasets",{binding:"ANALYTICS",dataset:"ANALYTICS"},"ANALYTICS (Analytics Engine)")},{enabled:n.usesWorkerLoader,run:r=>He(r,o)},{enabled:!0,run:r=>Ze(r,o)},{enabled:b.length>0,run:r=>ze(r,o,b)},{enabled:m.length>0||u.length>0,run:r=>rn(r,o,m,u,sn(e))},{enabled:n.queues.length>0,run:r=>{const _=Ne(r,o,n.queues,g.queues??{});return p.queues=_.owned,_}},{enabled:n.services!==void 0&&(n.services.length>0||Object.keys(h).length>0),run:r=>{const _=ie(r,o,n.services??[],h);return v=_.owned,_}},...s===void 0||o.env?.[s]===void 0?[]:[{enabled:n.queues.length>0,run:r=>{const _=`env.${s}.queues`,k=Oe(r,o,n.queues,s,g[_]??{});return p[_]=k.owned,k}}]];let N=d;const f=[],y=[];for(const r of x){if(!r.enabled)continue;const _=r.run(N);N=_.text,f.push(..._.added),y.push(..._.updated??[]),a.push(..._.warnings??[])}const E=r=>{if(w===void 0)return;const _=v,k=[...Object.keys(p).length>0?[{consequence:"an option removed from defineQueue stays deployed",key:"queueTuning",label:"queue tuning",write:O=>{ke(O,g,p)}}]:[],..._===void 0?[]:[{consequence:"a service removed from lunora.config stays bound",key:"services",label:"service bindings",write:O=>{ae(O,_)}}]];for(const O of k)try{O.write(M(e)??w)}catch(q){a.push(`${r?"wrangler.jsonc was updated, but ":""}recording the ${O.label} reconcile owns in ${w.path} (lunora.${O.key}) failed: ${q instanceof Error?q.message:String(q)}. Until it is recorded, ${O.consequence}.`)}};let A;if(n.services!==void 0){const r=re(e,n.services,h);a.push(...r.warnings),v={...v,...r.owned},A=r.added.length>0||r.updated.length>0?{added:r.added,path:r.path,updated:r.updated}:void 0}return f.includes("DB (D1)")&&a.push(`wrote a DB binding with a placeholder database_id ("${U}") — run \`wrangler d1 create <name>\` and replace it before deploying.`),N===d?(E(!1),{added:f,changed:!1,devConfig:A,exportGaps:i,reason:"bindings already in sync",updated:y,warnings:a,wranglerPath:t}):(X(t,N,"utf8"),E(!0),{added:f,changed:!0,devConfig:A,exportGaps:i,updated:y,warnings:a,wranglerPath:t})};export{Be as collectExportGaps,xn as reconcileWranglerBindings};
@@ -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
+ import{writeFileSync as u}from"node:fs";import{modify as y,applyEdits as w}from"jsonc-parser";import{r as m,f as v,a as $}from"./lunora-manifest-DuH_Cmyu.mjs";import{findWranglerFile as x,readWranglerJsonc as C}from"./WRANGLER_FILES-UNW-xY5u.mjs";const b=(r,n)=>r.length===n.length&&r.every((e,t)=>e===n[t]),j=(r,n)=>{if(r?.lunoraIsForeign===!0)return n.push(`${r.path}: \`lunora\` is not an object, so the cron ownership record cannot be read or written — a removed cron will keep firing.`),[];const e=r?.lunora?.crons;if(e===void 0)return[];if(!Array.isArray(e))return n.push(`${r?.path??"package.json"}: \`lunora.crons\` is not an array of cron expressions — the crons it recorded are now treated as hand-written and will not be cleared.`),[];const t=e.filter(o=>typeof o=="string");return t.length!==e.length&&n.push(`${r?.path??"package.json"}: \`lunora.crons\` dropped ${String(e.length-t.length)} non-string entry(s) — anything it recorded there is now treated as hand-written and will not be cleared.`),t},k=(r,n)=>{$(r,"crons",n.length===0?void 0:[...n])},W=(r,n)=>{const e=x(r);if(!e)return{changed:!1,preserved:[],reason:"wrangler.jsonc not found",warnings:[]};const{parsed:t,text:o}=C(e);if(t===void 0)return{changed:!1,preserved:[],reason:`failed to parse ${e} as JSONC`,warnings:[],wranglerPath:e};const g=Array.isArray(t.triggers?.crons)?t.triggers.crons.filter(i=>typeof i=="string"):[],c=[...n],s=[],d=m(r),p=j(d,s),a=g.filter(i=>!c.includes(i)&&!p.includes(i)),l=[...c,...a],f=()=>{d!==void 0&&k(d,c)};if(b(g,l))return f(),{changed:!1,preserved:a,reason:"triggers.crons already in sync",warnings:s,wranglerPath:e};const h=y(o,["triggers","crons"],l,{formattingOptions:v(o)});return h.length===0?{changed:!1,preserved:a,reason:"no structural edit produced",warnings:s,wranglerPath:e}:(u(e,w(o,h),"utf8"),f(),{changed:!0,preserved:a,warnings:s,wranglerPath:e})},J=r=>r.length===0?void 0:`kept ${String(r.length)} hand-written cron trigger(s): ${r.join(", ")}`;export{J as describePreservedCrons,W as reconcileWranglerCrons};
@@ -0,0 +1 @@
1
+ import{readProjectDependencyNames as a}from"./readProjectDependencies-l3uhUKjo.mjs";const n=[{class:"A",dependency:"@tanstack/react-start",framework:"tanstack-start"},{class:"A",dependency:"@tanstack/solid-start",framework:"tanstack-start-solid"},{class:"A",dependency:"@react-router/dev",framework:"react-router"},{class:"A",dependency:"vinext",framework:"vinext"},{class:"A",dependency:"@solidjs/start",framework:"solid-start"},{class:"A",dependency:"solid-start",framework:"solid-start"},{class:"B",dependency:"@sveltejs/kit",framework:"sveltekit"},{class:"B",dependency:"nuxt",framework:"nuxt"},{class:"B",dependency:"astro",framework:"astro"}],t={class:"C",framework:"none"},o=e=>a(e).has("lunorash"),d=e=>{const r=a(e);if(r.size===0)return t;for(const s of n)if(r.has(s.dependency))return{class:s.class,framework:s.framework};return t};export{d as detectFramework,o as projectUsesUmbrella};
@@ -0,0 +1 @@
1
+ import{existsSync as m}from"node:fs";import{Project as f}from"ts-morph";import{join as t}from"node:path";const p=(e,o,n,s,i={})=>{if(!m(t(e,o,n??"")))return{};try{const r=new f({skipAddingFilesFromTsConfig:!0,useInMemoryFileSystem:!1,...i});return{value:s(r,t(e,o))}}catch(r){return{error:r instanceof Error?r.message:String(r)}}};export{p as d};
@@ -0,0 +1 @@
1
+ import{discoverAgents as s,AGENTS_FILENAME as n}from"@lunora/codegen";import{d as i}from"./discover-info-DC2MrAIM.mjs";const v=(o,e)=>{const{error:r,value:t}=i(o,e,n,s);return r===void 0?{agents:t??[]}:{agents:[],error:r}};export{v as discoverAgentInfo};
@@ -0,0 +1 @@
1
+ import{discoverContainers as i,CONTAINERS_FILENAME as t}from"@lunora/codegen";import{d as s}from"./discover-info-DC2MrAIM.mjs";const d=(r,e)=>{const{error:o,value:n}=s(r,e,t,i,{skipFileDependencyResolution:!0});return o===void 0?{containers:n??[]}:{containers:[],error:o}};export{d as discoverContainerInfo};
@@ -0,0 +1 @@
1
+ import{existsSync as c}from"node:fs";import{discoverSchema as l,isHyperdriveGlobalTable as d,isD1GlobalTable as f}from"@lunora/codegen";import{Project as b}from"ts-morph";import{join as u}from"node:path";const a=n=>{if(n?.kind==="optional")return a(n.inner);if(n?.kind==="union"){const o=new Set((n.members??[]).filter(i=>i.kind!=="null").map(i=>a(i)));return o.size===1?[...o][0]:n.kind}return n?.kind},S=(n,o)=>{const i=u(n,o,"schema.ts");if(!c(i))return{info:void 0};try{const s=new b({skipAddingFilesFromTsConfig:!0,useInMemoryFileSystem:!1}),r=l(s,i,n),m=e=>r.tables.find(t=>t.name===e)?.shape??{};return{info:{hasD1GlobalTable:r.tables.some(e=>f(e)),hasHyperdriveGlobalTable:r.tables.some(e=>d(e)),...r.jurisdiction===void 0?{}:{jurisdiction:r.jurisdiction},vectorIndexNames:r.vectorIndexes.map(e=>e.name),vectorMetadata:r.vectorIndexes.flatMap(e=>(e.metadata??[]).map(t=>({index:e.name,kind:a(m(e.table)[t]),property:t})))}}}catch(s){return{error:s instanceof Error?s.message:String(s),info:void 0}}};export{S as discoverSchemaInfo};
@@ -0,0 +1 @@
1
+ import{discoverWorkflows as f,WORKFLOWS_FILENAME as i}from"@lunora/codegen";import{d as t}from"./discover-info-DC2MrAIM.mjs";const d=(r,s)=>{const{error:o,value:e}=t(r,s,i,f);return o===void 0?{workflows:e??[]}:{error:o,workflows:[]}};export{d as discoverWorkflowInfo};
@@ -0,0 +1 @@
1
+ const n=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),s=t=>typeof t=="string"&&t.length>0;export{s as a,n as i};