@lunora/config 1.0.0-alpha.26 → 1.0.0-alpha.261
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +135 -0
- package/README.md +3 -3
- package/dist/cloudflare/index.d.mts +969 -0
- package/dist/cloudflare/index.d.ts +969 -0
- package/dist/cloudflare/index.mjs +1 -0
- package/dist/index.d.mts +864 -921
- package/dist/index.d.ts +864 -921
- package/dist/index.mjs +1 -23
- package/dist/packem_shared/ACCENT-CotPTfv7.mjs +7 -0
- package/dist/packem_shared/AGENT_MODE_ENV-D8MvSwPE.mjs +1 -0
- package/dist/packem_shared/AGENT_RULES_DIR-C54Ta_vz.mjs +1 -0
- package/dist/packem_shared/ALLOW_FORWARDED_ENV-BUndghJx.mjs +1 -0
- package/dist/packem_shared/BINDING_MANIFEST_VERSION-B8dwEKLn.mjs +1 -0
- package/dist/packem_shared/CLOUDFLARE_DRIVER-Ci9oJMYb.mjs +1 -0
- package/dist/packem_shared/CODEGEN_ENV-ZsCxV1kP.mjs +1 -0
- package/dist/packem_shared/COMPOSED_WORKER_ENTRY-Bj793dir.mjs +1 -0
- package/dist/packem_shared/DEFAULT_DEPLOY_TARGET-B-e9mqgX.mjs +1 -0
- package/dist/packem_shared/DEV_BINDINGS_FILE-pyOiNLP4.mjs +4 -0
- package/dist/packem_shared/DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs +6 -0
- package/dist/packem_shared/LINKED_PROJECT_DIR-Ba5qPEwo.mjs +2 -0
- package/dist/packem_shared/LUNORA_EVENT_SOURCE-DYdcDU9G.mjs +1 -0
- package/dist/packem_shared/LUNORA_IGNORED_PATHS-BHABA9u-.mjs +19 -0
- package/dist/packem_shared/LunoraReporter-f277GLNT.mjs +6 -0
- package/dist/packem_shared/PACKAGE_SECRETS_REGISTRY-De7gLGIy.mjs +1 -0
- package/dist/packem_shared/POLICY_SCAFFOLD_ENDPOINT-0QiGKazX.mjs +1 -0
- package/dist/packem_shared/REMOTE_ELIGIBLE_KEYS-D-edJjVY.mjs +1 -0
- package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-SdRHaUwh.mjs +1 -0
- package/dist/packem_shared/SCHEMA_EDIT_ENDPOINT-Dbt0faMd.mjs +1 -0
- package/dist/packem_shared/SEED_ENDPOINT-2B56PN_H.mjs +1 -0
- package/dist/packem_shared/WORKERS_CACHE_MIN_DATE-0k9ABJtF.mjs +1 -0
- package/dist/packem_shared/WRANGLER_FILES-UNW-xY5u.mjs +1 -0
- package/dist/packem_shared/addArgsFor-CWb4cPij.mjs +1 -0
- package/dist/packem_shared/applyAdditiveEdit-CH0VhMJ2.mjs +6 -0
- package/dist/packem_shared/applyStudioAssetCache-DHQEJuuv.mjs +1 -0
- package/dist/packem_shared/assetContentType-CUb5bpbI.mjs +1 -0
- package/dist/packem_shared/buildPackageSecretsBlock-yv9mjKEW.mjs +19 -0
- package/dist/packem_shared/classifyPolicyEdit-D8NwrHxR.mjs +24 -0
- package/dist/packem_shared/collectExportGaps-BJw9LdRV.mjs +2 -0
- package/dist/packem_shared/collectWranglerSecretVariables-D-usPfT8.mjs +1 -0
- package/dist/packem_shared/createConfirm-D5mKTMHj.mjs +7 -0
- package/dist/packem_shared/describePreservedCrons-Ci5r2aph.mjs +1 -0
- package/dist/packem_shared/detectFramework-CUiVEHDQ.mjs +1 -0
- package/dist/packem_shared/discover-info-Vj9d4qYt.mjs +1 -0
- package/dist/packem_shared/discoverAgentInfo-CTdCSfYM.mjs +1 -0
- package/dist/packem_shared/discoverContainerInfo-EhZtEBQs.mjs +1 -0
- package/dist/packem_shared/discoverSchemaInfo-DJvevsCm.mjs +1 -0
- package/dist/packem_shared/discoverWorkflowInfo-BsPvlo6O.mjs +1 -0
- package/dist/packem_shared/interpretRemote-CQ06qpjM.mjs +1 -0
- package/dist/packem_shared/jsonc-edit-BZgQIdAH.mjs +1 -0
- package/dist/packem_shared/lunora-manifest-V77OcyFC.mjs +6 -0
- package/dist/packem_shared/package-secrets-registry-DvtTiK4b.mjs +1 -0
- package/dist/packem_shared/parseDevVariable-teAAahVD.mjs +1 -0
- package/dist/packem_shared/parseSchema-D1Wbr1qv.mjs +1 -0
- package/dist/packem_shared/policy-scaffold.d-D2H4_G01.d.mts +86 -0
- package/dist/packem_shared/policy-scaffold.d-D2H4_G01.d.ts +86 -0
- package/dist/packem_shared/reconcileWranglerCompatibilityDate-7OO_xaKR.mjs +1 -0
- package/dist/packem_shared/renderStudioHtml-ByowDtMl.mjs +15 -0
- package/dist/packem_shared/runPostCodegenHook-CVrOTiGB.mjs +1 -0
- package/dist/packem_shared/schema-info.d-DvKkJ7HJ.d.mts +331 -0
- package/dist/packem_shared/schema-info.d-DvKkJ7HJ.d.ts +331 -0
- package/dist/packem_shared/serveJsonHandler-Dv0EdCb9.mjs +1 -0
- package/dist/packem_shared/streamContainerLogs-0nko1qpv.mjs +2 -0
- package/dist/packem_shared/wranglerToAlchemy-SDoS_XY0.mjs +6 -0
- package/dist/packem_shared/write-atomic-9d9xs5ON.mjs +1 -0
- package/dist/studio-host/index.d.mts +250 -95
- package/dist/studio-host/index.d.ts +250 -95
- package/dist/studio-host/index.mjs +1 -7
- package/package.json +15 -7
- package/dist/packem_shared/ACCENT-DW1XJn8i.mjs +0 -40
- package/dist/packem_shared/AGENT_RULES_DIR-lcgC08aE.mjs +0 -40
- package/dist/packem_shared/DEV_VARS_EXAMPLE_FILE-dJPNTEnK.mjs +0 -37
- package/dist/packem_shared/LINKED_PROJECT_DIR-CXwXzV_C.mjs +0 -52
- package/dist/packem_shared/LUNORA_CONFIG_FILE-CtcIcB5-.mjs +0 -34
- package/dist/packem_shared/LUNORA_EVENT_SOURCE-D2fDeGB6.mjs +0 -86
- package/dist/packem_shared/LunoraReporter-Ci-bDCK9.mjs +0 -70
- package/dist/packem_shared/PACKAGE_SECRETS_REGISTRY-B8t_SdoZ.mjs +0 -70
- package/dist/packem_shared/POLICY_SCAFFOLD_ENDPOINT-CiC2IGKx.mjs +0 -103
- package/dist/packem_shared/REMOTE_ELIGIBLE_KEYS-BC7_e9Bz.mjs +0 -105
- package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-2YYyWJUq.mjs +0 -561
- package/dist/packem_shared/SCHEMA_EDIT_ENDPOINT-Df-Wrix-.mjs +0 -99
- package/dist/packem_shared/SEED_ENDPOINT-DVCjaGO-.mjs +0 -61
- package/dist/packem_shared/WRANGLER_FILES-DwSuC-Kn.mjs +0 -25
- package/dist/packem_shared/applyAdditiveEdit-C-snTFEV.mjs +0 -228
- package/dist/packem_shared/buildPackageSecretsBlock-DWDKHViT.mjs +0 -243
- package/dist/packem_shared/classifyPolicyEdit-BHeAqF8P.mjs +0 -99
- package/dist/packem_shared/createConfirm-fvpdgJ9s.mjs +0 -100
- package/dist/packem_shared/detectFramework-Br-BcPBq.mjs +0 -41
- package/dist/packem_shared/discoverContainerInfo-BXFs6Wav.mjs +0 -19
- package/dist/packem_shared/discoverSchemaInfo-BB-CKlTK.mjs +0 -25
- package/dist/packem_shared/discoverWorkflowInfo-CedvR0mn.mjs +0 -19
- package/dist/packem_shared/inferLunoraBindings-ByMwG-gH.mjs +0 -352
- package/dist/packem_shared/loadStudioAssets-Csk5RS4E.mjs +0 -28
- package/dist/packem_shared/parseDevVariable-CJiq2IwE.mjs +0 -30
- package/dist/packem_shared/parseSchema-DSeyktvG.mjs +0 -107
- package/dist/packem_shared/policy-scaffold.d-DCmwn7zQ.d.mts +0 -74
- package/dist/packem_shared/policy-scaffold.d-DCmwn7zQ.d.ts +0 -74
- package/dist/packem_shared/reconcileWranglerBindings-Cruwwx1M.mjs +0 -334
- package/dist/packem_shared/renderStudioHtml-449Ysn75.mjs +0 -37
- package/dist/packem_shared/serveJsonHandler-B4OLTGLS.mjs +0 -86
- package/dist/packem_shared/streamContainerLogs-BZ4cOZwH.mjs +0 -157
package/dist/index.mjs
CHANGED
|
@@ -1,23 +1 @@
|
|
|
1
|
-
|
|
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-CTdCSfYM.mjs";import{AGENT_RULES_DIR as i,AGENT_RULES_HINT as l,AGENT_RULES_HINT_ENV as n,LUNORA_SKILL_NAMES as p,ROOT_SKILL_NAME as _,claimAgentRulesHint as c,detectAgentRules as d}from"./packem_shared/AGENT_RULES_DIR-C54Ta_vz.mjs";import{CODEGEN_ENV as m,isCodegenDisabled as D}from"./packem_shared/CODEGEN_ENV-ZsCxV1kP.mjs";import{discoverContainerInfo as f}from"./packem_shared/discoverContainerInfo-EhZtEBQs.mjs";import{streamContainerLogs as N}from"./packem_shared/streamContainerLogs-0nko1qpv.mjs";import{detectFramework as R,projectUsesUmbrella as T,readProjectDependencyNames as g}from"./packem_shared/detectFramework-CUiVEHDQ.mjs";import{DEV_BINDINGS_FILE as x,DEV_DAEMON_ENV as V,DEV_HANDOFF_ENV as P,DEV_LOG_FILE as u,DEV_LOG_FILE_ENV as O,DEV_STATE_DIR as F,DEV_STATE_FILE as C,claimDevServerState as G,clearDevServerState as U,isDevServerReady as b,isProcessAlive as M,isRecordedProcessCurrent as y,readDevServerState as k,readLiveDevServerState as B,updateDevServerState as w,writeDevServerState as K}from"./packem_shared/DEV_BINDINGS_FILE-pyOiNLP4.mjs";import{DEV_VARS_EXAMPLE_FILE as H,DEV_VARS_FILE as Y,DEV_VARS_KEY_PATTERN as h,escapeRegExp as W,parseDevVariableEntries as J,removeDevVariableLine as q,upsertDevVariableLine as X}from"./packem_shared/DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{DEFAULT_DEPLOY_TARGET as Q,deployTargetIds as Z,isRunnableTarget as $,resolveDeployDriver as ee,runnableTargetIds as re}from"./packem_shared/DEFAULT_DEPLOY_TARGET-B-e9mqgX.mjs";import{COMPOSED_WORKER_ENTRY as te,GENERATED_CLASS_MODULES as ae,inferLunoraBindings as Ee,packageNamesFromBindings as se}from"./packem_shared/COMPOSED_WORKER_ENTRY-Bj793dir.mjs";import{LINKED_PROJECT_DIR as le,LINKED_PROJECT_FILE as ne,readLinkedProject as pe,writeLinkedProject as _e}from"./packem_shared/LINKED_PROJECT_DIR-Ba5qPEwo.mjs";import{LUNORA_IGNORED_PATHS as de,applyLintIgnores as Se,detectLintTools as me}from"./packem_shared/LUNORA_IGNORED_PATHS-BHABA9u-.mjs";import{LUNORA_EVENT_SOURCE as Ae,formatLunoraEvent as fe}from"./packem_shared/LUNORA_EVENT_SOURCE-DYdcDU9G.mjs";import{default as Ne}from"./packem_shared/LunoraReporter-f277GLNT.mjs";import{addArgsFor as Re,detectInstalledManagers as Te,detectPackageManager as ge,execArgsFor as Ie,installArgsFor as xe,runScriptArgsFor as Ve,runScriptCommand as Pe}from"./packem_shared/addArgsFor-CWb4cPij.mjs";import{P as Oe,s as Fe}from"./packem_shared/package-secrets-registry-DvtTiK4b.mjs";import{runPostCodegenHook as Ge}from"./packem_shared/runPostCodegenHook-CVrOTiGB.mjs";import{interpretRemote as be,readProjectRemotePreference as Me,readProjectTarget as ye,resolveProjectTarget as ke,resolveTargetOrThrow as Be}from"./packem_shared/interpretRemote-CQ06qpjM.mjs";import{createConfirm as Ke,isInteractive as je,promptMultiSelect as He,promptSelect as Ye,promptText as he,promptYesNo as We}from"./packem_shared/createConfirm-D5mKTMHj.mjs";import{buildPackageSecretsBlock as qe,ensureDevVariables as Xe,ensureDevVarsExample as ze,fillDevSecrets as Qe,generateSecretValue as Ze,isMintableSecretKey as $e,isPlaceholderValue as er,planDevSecretsFill as rr,planDevVariablesAugment as or,planDevVariablesScaffold as tr,requiredSecrets as ar,writeDevVariablesFileAtomically as Er}from"./packem_shared/buildPackageSecretsBlock-yv9mjKEW.mjs";import{applyAdditiveEdit as ir,classifyEdit as lr}from"./packem_shared/applyAdditiveEdit-CH0VhMJ2.mjs";import{parseSchema as pr}from"./packem_shared/parseSchema-D1Wbr1qv.mjs";import{classifyPolicyEdit as cr,resolveServerModule as dr,scaffoldPolicyFile as Sr,wireRlsIntoProcedure as mr}from"./packem_shared/classifyPolicyEdit-D8NwrHxR.mjs";import{discoverSchemaInfo as Ar}from"./packem_shared/discoverSchemaInfo-DJvevsCm.mjs";import{ACCENT as Lr,BADGES as Nr,BADGE_COLUMN_WIDTH as vr,LUNA_ART as Rr,LUNA_BUNNY as Tr,LUNA_NAME as gr,LUNA_SIGNOFF as Ir,STEP_BADGE_NAMES as xr,badgeLead as Vr,badgeWidth as Pr,padBadge as ur,paintAnswer as Or,paintBadge as Fr}from"./packem_shared/ACCENT-CotPTfv7.mjs";import{discoverWorkflowInfo as Gr}from"./packem_shared/discoverWorkflowInfo-BsPvlo6O.mjs";export{Lr as ACCENT,o as AGENT_MODE_ENV,i as AGENT_RULES_DIR,l as AGENT_RULES_HINT,n as AGENT_RULES_HINT_ENV,Nr as BADGES,vr as BADGE_COLUMN_WIDTH,m as CODEGEN_ENV,te as COMPOSED_WORKER_ENTRY,Q as DEFAULT_DEPLOY_TARGET,x as DEV_BINDINGS_FILE,V as DEV_DAEMON_ENV,P as DEV_HANDOFF_ENV,u as DEV_LOG_FILE,O as DEV_LOG_FILE_ENV,F as DEV_STATE_DIR,C as DEV_STATE_FILE,H as DEV_VARS_EXAMPLE_FILE,Y as DEV_VARS_FILE,h as DEV_VARS_KEY_PATTERN,ae as GENERATED_CLASS_MODULES,le as LINKED_PROJECT_DIR,ne as LINKED_PROJECT_FILE,Rr as LUNA_ART,Tr as LUNA_BUNNY,gr as LUNA_NAME,Ir as LUNA_SIGNOFF,Ae as LUNORA_EVENT_SOURCE,de as LUNORA_IGNORED_PATHS,p as LUNORA_SKILL_NAMES,Ne as LunoraReporter,Oe as PACKAGE_SECRETS_REGISTRY,_ as ROOT_SKILL_NAME,xr as STEP_BADGE_NAMES,Re as addArgsFor,ir as applyAdditiveEdit,Se as applyLintIgnores,Vr as badgeLead,Pr as badgeWidth,qe as buildPackageSecretsBlock,c as claimAgentRulesHint,G as claimDevServerState,lr as classifyEdit,cr as classifyPolicyEdit,U as clearDevServerState,Ke as createConfirm,Z as deployTargetIds,d as detectAgentRules,t as detectAiAgent,R as detectFramework,Te as detectInstalledManagers,me as detectLintTools,ge as detectPackageManager,E as discoverAgentInfo,f as discoverContainerInfo,Ar as discoverSchemaInfo,Gr as discoverWorkflowInfo,Xe as ensureDevVariables,ze as ensureDevVarsExample,W as escapeRegExp,Ie as execArgsFor,Qe as fillDevSecrets,fe as formatLunoraEvent,Ze as generateSecretValue,Ee as inferLunoraBindings,xe as installArgsFor,be as interpretRemote,D as isCodegenDisabled,b as isDevServerReady,je as isInteractive,$e as isMintableSecretKey,er as isPlaceholderValue,M as isProcessAlive,y as isRecordedProcessCurrent,$ as isRunnableTarget,se as packageNamesFromBindings,ur as padBadge,Or as paintAnswer,Fr as paintBadge,J as parseDevVariableEntries,pr as parseSchema,rr as planDevSecretsFill,or as planDevVariablesAugment,tr as planDevVariablesScaffold,T as projectUsesUmbrella,He as promptMultiSelect,Ye as promptSelect,he as promptText,We as promptYesNo,k as readDevServerState,pe as readLinkedProject,B as readLiveDevServerState,g as readProjectDependencyNames,Me as readProjectRemotePreference,ye as readProjectTarget,q as removeDevVariableLine,ar as requiredSecrets,ee as resolveDeployDriver,ke as resolveProjectTarget,dr as resolveServerModule,Be as resolveTargetOrThrow,Ge as runPostCodegenHook,Ve as runScriptArgsFor,Pe as runScriptCommand,re as runnableTargetIds,Sr as scaffoldPolicyFile,Fe as secretsForPackages,N as streamContainerLogs,w as updateDevServerState,X as upsertDevVariableLine,mr as wireRlsIntoProcedure,K as writeDevServerState,Er as writeDevVariablesFileAtomically,_e 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";const a=".agents/skills",t="LUNORA_RULES_HINT_SHOWN",i=["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"],c="lunora",_="Lunora AI rules not installed — run `lunora rules install` so your coding agent knows how to use Lunora.",m=()=>process.env[t]==="1"?!1:(process.env[t]="1",!0),u=(n,e)=>l(n,a,e,"SKILL.md"),N=n=>{const e=[],o=[];for(const r of i)s(u(n,r))?e.push(r):o.push(r);return{installed:s(u(n,c)),missing:o,present:e}};export{a as AGENT_RULES_DIR,_ as AGENT_RULES_HINT,t as AGENT_RULES_HINT_ENV,i as LUNORA_SKILL_NAMES,c as ROOT_SKILL_NAME,m as claimAgentRulesHint,N 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 c}from"./wranglerToAlchemy-SDoS_XY0.mjs";const u=1,l=new Set(["$schema","account_id","compatibility_date","compatibility_flags","keep_vars","main","migrations","minify","name","observability","placement","routes","rules","triggers","upload_source_maps","vars","workers_dev"]),p=e=>Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0)),a=[{bindingKey:"binding",field:"analytics_engine_datasets",resourceKey:"dataset",type:"analytics_engine"},{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:"pipeline",type:"pipeline"},{bindingKey:"binding",field:"r2_buckets",resourceKey:"bucket_name",type:"r2"},{bindingKey:"binding",field:"vectorize",resourceKey:"index_name",type:"vectorize"},{bindingKey:"binding",field:"workflows",resourceKey:"name",type:"workflow"}],d=[{field:"ai",type:"ai"},{field:"assets",type:"assets"},{field:"browser",type:"browser"},{field:"images",type:"images"}],y=new Set([...a.map(e=>e.field),...d.map(e=>e.field),"durable_objects","queues"]),o=(e,t)=>{const s=t===void 0?void 0:e[t];return typeof s=="string"&&s!==""?s:void 0},b=(e,t)=>{const s=[];for(const n of a)for(const i of e[n.field]??[]){const r=o(i,n.bindingKey);if(r===void 0){t.push(n.field);continue}s.push({binding:r,className:o(i,"class_name"),resource:o(i,n.resourceKey),resourceId:o(i,n.resourceIdKey),type:n.type})}return s},m=(e,t)=>{const s=c(e),n=[];for(const i of e.durable_objects?.bindings??[]){if(i.name===void 0||i.name===""){t.push("durable_objects");continue}n.push({binding:i.name,className:i.class_name,sqlite:i.script_name===void 0&&i.class_name!==void 0?s.has(i.class_name):void 0,type:"durable_object"})}return n},_=(e,t)=>{const s=[];for(const n of e.queues?.producers??[]){if(n.binding===void 0||n.binding===""){t.push("queues.producers");continue}s.push({binding:n.binding,resource:n.queue,type:"queue_producer"})}for(const n of e.queues?.consumers??[]){if(n.queue===void 0||n.queue===""){t.push("queues.consumers");continue}s.push({binding:n.queue,resource:n.queue,type:"queue_consumer"})}return s},g=(e,t)=>[...b(e,t),...m(e,t),..._(e,t),...d.filter(s=>e[s.field]?.binding!==void 0).map(s=>({binding:e[s.field]?.binding,type:s.type}))],v=e=>{const t=[],s=g(e,t).map(i=>p(i)).toSorted((i,r)=>i.type.localeCompare(r.type)||i.binding.localeCompare(r.binding)),n=[...Object.keys(e).filter(i=>!l.has(i)&&!y.has(i)),...t.map(i=>`${i} (entry with no binding name)`)].toSorted((i,r)=>i.localeCompare(r));return{bindings:s,...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:n,vars:Object.keys(e.vars??{}).toSorted((i,r)=>i.localeCompare(r)),version:u}};export{u as BINDING_MANIFEST_VERSION,v as buildBindingManifest};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const r={deploy:o=>{const n=o.preview===!0?["versions","upload"]:["deploy"];return o.entry!==void 0&&n.push(o.entry),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 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 l,statSync as w,readFileSync as b,readdirSync as j}from"node:fs";import{init as Y,parse as f}from"es-module-lexer";import{discoverAgentInfo as K}from"./discoverAgentInfo-CTdCSfYM.mjs";import{WRANGLER_FILES as W,readWranglerJsonc as M}from"./WRANGLER_FILES-UNW-xY5u.mjs";import{discoverContainerInfo as G}from"./discoverContainerInfo-EhZtEBQs.mjs";import{escapeRegExp as D}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{discoverFlags as X,FLAGS_FILENAME as q,discoverQueues as H,QUEUES_FILENAME as Q}from"@lunora/codegen";import{d as C}from"./discover-info-Vj9d4qYt.mjs";import{discoverSchemaInfo as V}from"./discoverSchemaInfo-DJvevsCm.mjs";import{discoverWorkflowInfo as J}from"./discoverWorkflowInfo-BsPvlo6O.mjs";import{join as c}from"node:path";const z=(e,s)=>{const{error:t,value:r}=C(e,s,q,X);return t===void 0?{flags:r}:{error:t}},Z=(e,s)=>{const{error:t,value:r}=C(e,s,Q,H);return t===void 0?{queues:r??[]}:{error:t,queues:[]}},ee=new Set([".cjs",".cts",".js",".jsx",".mjs",".mts",".ts",".tsx"]),R="_generated",se=new Set([".git",".lunora-cache",".wrangler","dist",R,"node_modules"]),re=["lunora","src"],te=["src/server.ts","src/server/index.ts","src/server/index.tsx","src/index.ts","src/worker.ts"],ne=new Set(["build","coverage","dist",R,"node_modules","out","target"]),oe=new Set([".client",".server"]),ae=/[/\\]/u,ie=e=>{const s=[];for(const t of e.split(ae))t===""||t==="."||(t===".."&&s.length>0&&s.at(-1)!==".."?s.pop():s.push(t));return s},ce=e=>ie(e).slice(0,-1).some(s=>ne.has(s)||s.startsWith(".")&&!oe.has(s)),g={SchedulerDO:"SCHEDULER",SessionDO:"SESSION",ShardDO:"SHARD"},v=Object.keys(g),qe=e=>Object.hasOwn(g,e),ue=/\benv\s*\.\s*DB\b/,le=/\benv\s*\.\s*AI\b/,P=/\bctx\s*\.\s*pipelines\b/,L=/\bctx\s*\.\s*r2sql\b/,B=/^\s*import\s+type\b/,de=new Set(["@lunora/agent","@lunora/agent/sandbox"]),pe=e=>{const s=e.indexOf("{");if(s===-1)return"";const t=e.indexOf("}",s+1);return t===-1?e.slice(s+1):e.slice(s+1,t)},me=/\btype\s+browserTool\b/,be=/\bbrowserTool\b/,fe=/import\s+\{[^}]*\bbrowserTool\b[^}]*\}\s+from\s+["']@lunora\/agent(?:\/sandbox)?["']/,ge=e=>{if(B.test(e))return!1;const s=pe(e);return be.test(s)&&!me.test(s)},Ee=e=>{try{const[s]=f(e);return s.some(t=>t.n!==void 0&&de.has(t.n)&&ge(e.slice(t.ss,t.se)))}catch{return fe.test(e)}},E={usesAi:{pattern:/\bfrom\s+["']@lunora\/ai["']/,source:"@lunora/ai"},usesAnalytics:{pattern:/\bfrom\s+["']@lunora\/bindings\/analytics["']/,source:"@lunora/bindings/analytics"},usesAuth:{pattern:/\bfrom\s+["']@lunora\/auth["']/,source:"@lunora/auth"},usesBrowser:{pattern:/\bfrom\s+["']@lunora\/browser["']/,source:"@lunora/browser"},usesHyperdrive:{pattern:/\bfrom\s+["']@lunora\/hyperdrive["']/,source:"@lunora/hyperdrive"},usesImages:{pattern:/\bfrom\s+["']@lunora\/bindings\/images["']/,source:"@lunora/bindings/images"},usesKv:{pattern:/\bfrom\s+["']@lunora\/bindings\/kv["']/,source:"@lunora/bindings/kv"},usesMail:{pattern:/\bfrom\s+["']@lunora\/mail["']/,source:"@lunora/mail"},usesNotify:{pattern:/\bfrom\s+["']@lunora\/notify["']/,source:"@lunora/notify"},usesPayment:{pattern:/\bfrom\s+["']@lunora\/payment["']/,source:"@lunora/payment"},usesPipelines:{pattern:P,source:"@lunora/bindings/pipelines"},usesR2sql:{pattern:L,source:"@lunora/bindings/r2sql"},usesScheduler:{pattern:/\bfrom\s+["']@lunora\/scheduler["']/,source:"@lunora/scheduler"},usesStorage:{pattern:/\bfrom\s+["']@lunora\/storage["']/,source:"@lunora/storage"},usesX402Charge:{pattern:/\bfrom\s+["']@lunora\/x402\/charge["']/,source:"@lunora/x402/charge"},usesX402Pay:{pattern:/\bfrom\s+["']@lunora\/x402\/pay["']/,source:"@lunora/x402/pay"}},p=Object.keys(E),he="STRIPE_SECRET_KEY + STRIPE_WEBHOOK_SECRET (Stripe) or POLAR_ACCESS_TOKEN + POLAR_WEBHOOK_SECRET (Polar)",k=[...p,"needsD1"],Se=()=>{const e={};for(const s of k)e[s]=!1;return e},d=Object.freeze(Se()),x=(e,s)=>{const t={};for(const r of k)t[r]=e[r]||s[r];return t},_e=e=>{for(const s of p)if(E[s].source===e)return{...d,[s]:!0};return d},Re=e=>{const[s]=f(e);let t=d;for(const r of s){const n=r.n;!n||B.test(e.slice(r.ss,r.se))||(t=x(t,_e(n)))}return t},xe=e=>{const s={...d};for(const t of p)s[t]=E[t].pattern.test(e);return s},ye=e=>{let s;try{s=Re(e)}catch{s=xe(e)}return x(s,{...d,needsD1:ue.test(e),usesAi:le.test(e),usesPipelines:P.test(e),usesR2sql:L.test(e)})},y=(e,s)=>{let t;try{t=j(e,{withFileTypes:!0})}catch{return}for(const r of t){if(r.isDirectory()){se.has(r.name)||y(c(e,r.name),s);continue}const n=r.name.lastIndexOf(".");n!==-1&&ee.has(r.name.slice(n))&&s.push(c(e,r.name))}},Oe="virtual:lunora/worker",Ie=["ShardDO"],He=["agents","containers","scheduler","workflows"],Ae="src/worker.ts",Ne=e=>{for(const s of W){const t=c(e,s);if(!l(t))continue;const{parsed:r}=M(t),n=r?.main;if(n===Oe)return{composed:!0};const a=c(e,Ae);if(l(a))return{composed:!1,path:a};if(typeof n=="string"&&!ce(n)&&l(c(e,n)))return{composed:!1,path:c(e,n)};break}for(const s of te){const t=c(e,s);if(l(t))return{composed:!1,path:t}}return{composed:!1}},Te=/(?:^|[\s,{])type$/u,$=(e,s)=>{const t=s.ls>=0?s.ls:s.s;return Te.test(e.slice(0,t).trimEnd())},F=(e,s)=>{const t=D(s);return new RegExp(String.raw`\bexport\s+type\s+${t}\b`,"u").test(e)||new RegExp(String.raw`\bexport\s+type\s*\{[^}]*\b${t}\b`,"u").test(e)||new RegExp(String.raw`\bexport\s+\{[^}]*\btype\s+${t}\b`,"u").test(e)},ve=e=>{const s=b(e,"utf8");let t;try{const[,r]=f(s);t=new Set(r.filter(n=>!$(s,n)).map(n=>n.n))}catch{t=new Set(v.filter(r=>new RegExp(String.raw`\bexport\b[^\n;]*\b${r}\b`,"u").test(s)&&!F(s,r)))}return v.filter(r=>t.has(r)).map(r=>({binding:g[r],className:r}))},_=(e,s,t)=>{if(s.length===0)return[];if(e.composed)return s.map(o=>({...o,exported:!0}));if(e.path===void 0)return s.map(o=>({...o,exported:!1}));const r=b(e.path,"utf8"),n=new RegExp(String.raw`\bexport\s*\*\s*from\s*["'][^"']*_generated\/${t}(?:\.js)?["']`).test(r);let a;try{const[,o]=f(r);a=new Set(o.filter(i=>!$(r,i)).map(i=>i.n))}catch{a=new Set(s.map(o=>o.className).filter(o=>new RegExp(String.raw`\bexport\b[^\n;]*\b${D(o)}\b`,"u").test(r)&&!F(r,o)))}return s.map(o=>{const i=n||a.has(o.className);return{...o,exported:i}})},we=(e,s)=>V(e,s).info?.hasD1GlobalTable??!1,De=(e,s)=>{let t=d;for(const r of s){const n=c(e,r);if(!l(n)||!w(n).isDirectory())continue;const a=[];y(n,a);for(const o of a)t=x(t,ye(b(o,"utf8")))}return t},Ce=(e,s)=>{const t=c(e,s);if(!l(t)||!w(t).isDirectory())return!1;const r=[];return y(t,r),r.some(n=>Ee(b(n,"utf8")))},Pe=(e,s,t)=>[...e.map(r=>r.exported?`${r.bindingName}/${r.className} (container "${r.exportName}" declared and exported)`:`hint: container "${r.exportName}" is declared but ${r.className} is not exported by the worker entry — add \`export * from "./lunora/_generated/containers"\``),...s.map(r=>r.exported?`${r.bindingName}/${r.className} (workflow "${r.exportName}" declared and exported)`:`hint: workflow "${r.exportName}" is declared but ${r.className} is not exported by the worker entry — add \`export * from "./lunora/_generated/workflows"\``),...t.map(r=>r.exported?`${r.bindingName}/${r.className} (agent "${r.exportName}" declared and exported)`:`hint: agent "${r.exportName}" is declared but ${r.className} is not exported by the worker entry — add \`export * from "./lunora/_generated/agents"\``)],Le=(e,s)=>[[e.usesAi,"AI (@lunora/ai imported or env.AI used)"],[e.usesAuth&&!s.has("SessionDO"),"hint: @lunora/auth is imported; its tables are D1-backed by default. For DO-backed auth (what @better-auth/scim needs), pass `namespace` to .auth() and export the generated auth DO class"],[e.usesScheduler&&!s.has("SchedulerDO"),"hint: @lunora/scheduler is imported but no SchedulerDO is exported by the worker entry"],[e.usesStorage,"hint: @lunora/storage is imported; add an r2_buckets binding (bucket binding names are user-defined)"],[e.usesMail,"hint: @lunora/mail is imported; set RESEND_API_KEY in .dev.vars (obtain at https://resend.com/api-keys)"],[e.usesPayment,`hint: @lunora/payment is imported; set the provider secrets in .dev.vars — ${he}`],[e.usesBrowser,"browser (@lunora/browser imported) — self-describing { binding: BROWSER }"],[e.usesImages,"images (@lunora/bindings/images imported) — self-describing { binding: IMAGES }"],[e.usesAnalytics,"analytics_engine_datasets (@lunora/bindings/analytics imported) — self-describing { binding: ANALYTICS, dataset }"],[e.usesKv,"hint: @lunora/bindings/kv is imported; add a kv_namespaces binding ({ binding, id }) and pass env.<BINDING> to createKv() — the namespace id can't be auto-provisioned"],[e.usesHyperdrive,"hint: @lunora/hyperdrive is imported; run 'wrangler hyperdrive create' and add a 'hyperdrive' binding ({ binding, id }) — the id can't be auto-provisioned"],[e.usesPipelines,"hint: ctx.pipelines is used; run 'wrangler pipelines create <name>' and add a 'pipelines' binding ({ binding, pipeline }) — the pipeline resource can't be auto-provisioned"],[e.usesX402Charge,"hint: @lunora/x402/charge is imported; set the recipient wallet address as a [vars] entry (the var name is yours to choose) and pass it to the charge config — the x402 facilitator settles USDC to that address"],[e.usesX402Pay,"hint: @lunora/x402/pay is imported (ActionCtx-only, spends real funds); add a secrets_store_secrets[] binding for the agent wallet key (name it to match signer.secretName) and pair the pay rail with a spend policy — ctx.secrets reads a Secrets Store binding, not .dev.vars, so the key can't be auto-provisioned"]].filter(([r])=>r).map(([,r])=>r),Be=(e,s,t,r=[],n=[],a=[])=>{const o=new Set(e.map(u=>u.className)),i=e.map(u=>`${u.binding}/${u.className} (exported by worker entry)`);return s&&i.push("DB (.global() table declared)"),i.push(...Pe(r,n,a),...Le(t,o)),i},Qe=async e=>{await Y;const s=e.schemaDir??"lunora",t=e.scanDirs??re,r=De(e.projectRoot,t),n={...r,usesBrowser:r.usesBrowser||Ce(e.projectRoot,s)},a=Ne(e.projectRoot);let o;a.composed?o=[...Ie,...l(c(e.projectRoot,s,R,"scheduler.ts"))?["SchedulerDO"]:[]].map(T=>({binding:g[T],className:T})):o=a.path===void 0?[]:ve(a.path);const i=n.needsD1||we(e.projectRoot,s),u=_(a,G(e.projectRoot,s).containers,"containers"),O=_(a,J(e.projectRoot,s).workflows,"workflows"),I=_(a,K(e.projectRoot,s).agents,"agents"),U=[...Z(e.projectRoot,s).queues],{flags:m}=z(e.projectRoot,s),h=m?.provider==="flagship"&&m.mode==="binding"?m.bindingName:void 0,A={};for(const S of p)A[S]=n[S];const N=Be(o,i,n,u,O,I);return h!==void 0&&N.push(`hint: lunora/flags.ts uses Flagship in binding mode; add a flagship binding ({ binding: "${h}", app_id }) — the app_id can't be auto-provisioned`),{agents:I,containers:u,durableObjects:o,flagshipBinding:h,needsD1:i,queues:U,signals:N,usesFlags:m!==void 0,workflows:O,...A}},Ve=e=>{const s=[];for(const t of p)e[t]&&s.push(E[t].source);return s};export{Ie as COMPOSED_ENTRY_DURABLE_OBJECTS,Ae as COMPOSED_WORKER_ENTRY,He as GENERATED_CLASS_MODULES,R as GENERATED_DIRECTORY,Oe as LUNORA_WORKER_VIRTUAL_ID,ne as NON_SOURCE_DIRECTORIES,oe as SOURCE_DOT_DIRECTORIES,te as WORKER_ENTRY_FALLBACKS,Qe as inferLunoraBindings,qe as isFrameworkDurableObject,ce as isGeneratedOutput,Ve as packageNamesFromBindings,Ne as resolveWorkerEntry};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import t from"./CLOUDFLARE_DRIVER-Ci9oJMYb.mjs";const l={id:"node",name:"Node"},a="cloudflare",n={cloudflare:t,node:l},r=()=>Object.keys(n).toSorted((o,e)=>o.localeCompare(e)),s=(o=a)=>{const e=n[o];if(e===void 0)throw new Error(`unknown deploy target "${o}" — available targets: ${r().join(", ")}`);return e},c=o=>Object.hasOwn(n,o)&&s(o).toolchain!==void 0,i=()=>r().filter(o=>c(o));export{a as DEFAULT_DEPLOY_TARGET,r as deployTargetIds,c as isRunnableTarget,s as resolveDeployDriver,i as runnableTargetIds};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{mkdirSync as _,writeFileSync as E,rmSync as N,existsSync as D,readFileSync as l}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",x="LUNORA_DEV_LOG_FILE",C="LUNORA_DEV_HANDOFF_PID",m=r=>r!==null&&typeof r=="object",d=(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=l(`/proc/${String(r)}/stat`,"utf8"),t=e.slice(e.lastIndexOf(")")+2).split(" "),i=Number(t[19]),s=l("/proc/stat","utf8").split(`
|
|
2
|
+
`).find(a=>a.startsWith("btime ")),o=Number(s?.slice(6));return!Number.isFinite(i)||!Number.isFinite(o)?void 0:o*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(l(e,"utf8"))}catch{return}if(!m(t)||typeof t.pid!="number")return;const i=d(t,"url");if(i!==void 0)return{background:t.background===!0,logFile:d(t,"logFile"),mode:t.mode==="vite"?"vite":"cli",pid:t.pid,readyAt:d(t,"readyAt"),startedAt:d(t,"startedAt"),studioUrl:d(t,"studioUrl"),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}},M=(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},U=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)!==void 0}},P=(r,e,t)=>{const i=n(r,v),s=`${JSON.stringify(e,void 0,2)}
|
|
4
|
+
`;for(let o=0;o<2;o+=1)try{return _(n(r,u),{recursive:!0}),E(i,s,{encoding:"utf8",flag:"wx"}),{ok:!0}}catch(a){if(a.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,C as DEV_HANDOFF_ENV,h as DEV_LOG_FILE,x as DEV_LOG_FILE_ENV,u as DEV_STATE_DIR,v as DEV_STATE_FILE,P as claimDevServerState,O as clearDevServerState,U as isDevServerReady,p as isProcessAlive,b as isRecordedProcessCurrent,f as readDevServerState,F as readLiveDevServerState,M 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,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 f=r=>{if(typeof r=="string")return 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}=${f(n)}`).join(" "),p="lunora",l="__root__",e=r=>typeof r=="string"?r:"",a=r=>Array.isArray(r)?r.filter(t=>typeof t=="string"):[],g=r=>typeof r=="number"&&Number.isFinite(r)?`${String(Math.round(r))}ms`:"?ms",h=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},u=(r,t)=>{const n=e(t.shard);return n===""||n===l?r:`${r}@${n}`},y=(r,t)=>{const n=r.outcome==="error",o=[u(t,r),n?"error":"ok",g(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(" ")}},j=r=>{const t=m(r);if(!t)return;const n=e(t.function)||"<unknown>";if(t.type==="log"){const o=[`${u(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:h(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,j as formatLunoraEvent};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import{existsSync as g,readFileSync as m,writeFileSync as d}from"node:fs";import{join as l,dirname as x}from"node:path";import{parse as v}from"jsonc-parser";import{readProjectDependencyNames as F}from"./detectFramework-CUiVEHDQ.mjs";import{a as $}from"./jsonc-edit-BZgQIdAH.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}},k=Object.keys(f),y=(e,n)=>f[n].configFiles.map(t=>l(e,t)).find(t=>g(t)),w=(e,n)=>{let t=e;for(;;){const s=y(t,n);if(s!==void 0)return s;if(g(l(t,".git")))return;const i=x(t);if(i===t)return;t=i}},j=(e,n)=>{const t=y(e,n);if(t!==void 0)return{action:"extend",path:t};const s=g(l(e,".git")),i=f[n].shadowable&&!s?w(x(e),n):void 0,[a=""]=f[n].configFiles;return i===void 0?{action:"create",path:l(e,a)}:{action:"report",path:i}},J=e=>{const n=F(e),t=()=>{try{return JSON.parse(m(l(e,"package.json"),"utf8")).prettier!==void 0}catch{return!1}};return k.filter(s=>f[s].packages.some(i=>n.has(i))||y(e,s)!==void 0||s==="prettier"&&t())},L="# Lunora generated + derived artifacts",O=e=>{const n=l(e,".prettierignore"),t=g(n)?m(n,"utf8"):void 0,s=t===void 0?[]:t.split(`
|
|
2
|
+
`).map(o=>o.trim()),i=c.filter(o=>!s.includes(o));if(i.length===0)return{path:n,status:t===void 0?"created":"unchanged",tool:"prettier"};const a=`${L}
|
|
3
|
+
${i.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,s)=>{const i=g(e),a=i?m(e,"utf8"):`{}
|
|
9
|
+
`;let r=v(a)??{};for(const u of n)r=r!==null&&typeof r=="object"?r[u]:void 0;const h=Array.isArray(r)?r:[],b=t.filter(u=>!h.includes(u));return b.length===0&&i?{path:e,status:"unchanged",tool:s}:(d(e,$(a,n,[...h,...b]),"utf8"),{path:e,status:i?"updated":"created",tool:s})},S=(e,n)=>`"${e}": [${n.map(t=>`"${t}"`).join(", ")}]`,I=()=>S("files.includes",c.map(e=>`!${e.endsWith("/")?`${e}**`:e}`)),P=e=>{const{action:n,path:t}=j(e,"oxlint");return n==="report"?{path:t,snippet:S("ignorePatterns",c),status:"manual",tool:"oxlint"}:A(t,["ignorePatterns"],c,"oxlint")},E=e=>{const{action:n,path:t}=j(e,"biome");if(n==="report")return{path:t,snippet:I(),status:"manual",tool:"biome"};const s=n==="extend",i=s?m(t,"utf8"):`{}
|
|
10
|
+
`,o=(v(i)??{}).files??{};if(Array.isArray(o.ignore))return A(t,["files","ignore"],c,"biome");const r=Array.isArray(o.includes)?o.includes:[],h=r.length===0?["**"]:r,u=c.map(p=>`!${p.endsWith("/")?`${p}**`:p}`).filter(p=>!r.includes(p));return u.length===0&&s?{path:t,status:"unchanged",tool:"biome"}:(d(t,$(i,["files","includes"],[...h,...u]),"utf8"),{path:t,status:s?"updated":"created",tool:"biome"})},T=()=>`{
|
|
11
|
+
// Lunora generated + derived artifacts.
|
|
12
|
+
ignores: [${c.map(e=>`"${e.endsWith("/")?`${e}**`:e}"`).join(", ")}],
|
|
13
|
+
}`,W=e=>{const{action:n,path:t}=j(e,"eslint"),s=T();if(n!=="create"){const a=m(t,"utf8"),o=c.every(r=>a.includes(r))?"unchanged":"manual";return{path:t,...o==="manual"?{snippet:s}:{},status:o,tool:"eslint"}}const i=l(e,"eslint.config.mjs");return d(i,`// Flat config. Add your own entries alongside the ignores below.
|
|
14
|
+
export default [
|
|
15
|
+
${s.replaceAll(`
|
|
16
|
+
`,`
|
|
17
|
+
`)},
|
|
18
|
+
];
|
|
19
|
+
`,"utf8"),{path:i,status:"created",tool:"eslint"}},_={biome:E,eslint:W,oxlint:P,prettier:O},M=(e,n)=>n.map(t=>{try{return _[t](e)}catch(s){return{message:s instanceof Error?s.message:String(s),path:e,status:"failed",tool:t}}});export{c as LUNORA_IGNORED_PATHS,M as applyLintIgnores,J as detectLintTools};
|
|
@@ -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-DvtTiK4b.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-D8NwrHxR.mjs";import{w as c,r as h}from"./write-atomic-9d9xs5ON.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 d,rmSync as f}from"node:fs";import{a as g}from"./jsonc-edit-BZgQIdAH.mjs";import{findWranglerFile as m,readWranglerJsonc as b}from"./WRANGLER_FILES-UNW-xY5u.mjs";import{join as y}from"node:path";const u={ai:{label:"AI",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"}},h=Object.keys(u),p=(e,r)=>typeof e.binding=="string"?e.binding:r,l=(e,r,n,a)=>{const t=[];for(const[o,s]of r.entries())s!=null&&t.push({binding:p(s,`#${String(o)}`),kind:n,path:[...a,o],section:e});return t},E=(e,r)=>{const{label:n,shape:a}=u[e];if(a==="array"){const o=r[e]??[];return l(e,o,n,[])}if(a==="producers")return l(e,r.queues?.producers??[],n,["producers"]);const t=r.ai;return t==null?[]:[{binding:p(t,e),kind:n,path:[],section:e}]},v=e=>h.flatMap(r=>E(r,e)),R=(e,r)=>{let n=e;for(const a of r)n=g(n,[a.section,...a.path,"remote"],!0);return n},i=()=>{},S=e=>{let r=!1;return()=>{if(!r){r=!0;try{f(e,{force:!0,recursive:!0})}catch{}}}};let c=0;const B=()=>(c+=1,`.wrangler.lunora-remote.${String(process.pid)}.${String(c)}.jsonc`),w=e=>{if(!e.enabled)return{cleanup:i,enabled:!1,remoteBindings:[]};const r=m(e.projectRoot);if(!r)return{cleanup:i,enabled:!0,reason:"wrangler.jsonc not found",remoteBindings:[]};const{parsed:n,text:a}=b(r);if(n===void 0)return{cleanup:i,enabled:!0,reason:`failed to parse ${r} as JSONC`,remoteBindings:[]};const t=v(n);if(t.length===0)return{cleanup:i,enabled:!0,reason:"no remote-eligible bindings to proxy",remoteBindings:[]};const o=y(e.projectRoot,B());return d(o,R(a,t),"utf8"),{cleanup:S(o),configPath:o,enabled:!0,remoteBindings:t}},j=e=>{if(e===void 0)return!1;const r=e.trim().toLowerCase();return r==="1"||r==="true"},x=e=>e.flag===!0||j(e.envValue)?!0:e.configPreference??!1;export{u as REMOTE_ELIGIBLE_KEYS,R as injectRemoteFlags,j as isRemoteEnvEnabled,w as materializeRemoteWranglerConfig,v as planRemoteBindings,x as resolveRemoteEnabled};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync as f,readFileSync as B,readdirSync as J}from"node:fs";import{join as p,dirname as R,extname as w,basename as W}from"node:path";import{COMPOSED_WORKER_ENTRY as Z,LUNORA_WORKER_VIRTUAL_ID as E,isGeneratedOutput as ee,WORKER_ENTRY_FALLBACKS as te,GENERATED_DIRECTORY as se,COMPOSED_ENTRY_DURABLE_OBJECTS as F,GENERATED_CLASS_MODULES as P,SOURCE_DOT_DIRECTORIES as ne,NON_SOURCE_DIRECTORIES as ie,isFrameworkDurableObject as ae}from"./COMPOSED_WORKER_ENTRY-Bj793dir.mjs";import{discoverSchemaInfo as oe}from"./discoverSchemaInfo-DJvevsCm.mjs";import{Project as re,Node as m}from"ts-morph";import{isCacheEnabled as ce,WORKERS_CACHE_MIN_DATE as k}from"./WORKERS_CACHE_MIN_DATE-0k9ABJtF.mjs";import{findWranglerFile as de,readWranglerJsonc as le}from"./WRANGLER_FILES-UNW-xY5u.mjs";const ue=new Set(["1","enabled","on","true","yes"]),me=e=>typeof e=="string"&&ue.has(e.trim().toLowerCase()),$=[".ts",".tsx",".mts",".cts"],S=new Set($),pe=new Set([".cjs",".js",".mjs"]),A="default",N={".cjs":[".cts"],".js":[".ts",".tsx"],".mjs":[".mts"]},ge=250,fe=(e,t,n)=>{const s=p(t,Z);if(f(s))return{origin:"declared",path:s};if(e===E)return{origin:"composed"};const i=()=>{const r=te.map(c=>p(t,c)).find(c=>f(c));return r===void 0?void 0:{origin:"probed",path:r}};if(typeof e!="string"||e.length===0||ee(e))return i();const a=p(R(n),e),o=w(a);if(!(!S.has(o)&&!pe.has(o)))return f(a)?{origin:"declared",path:a}:{origin:"absent",path:a}},q=(e,t)=>{if(m.isIdentifier(e)){t.add(e.getText());return}if(m.isObjectBindingPattern(e)||m.isArrayBindingPattern(e))for(const n of e.getElements())m.isBindingElement(n)&&q(n.getNameNode(),t)},be=(e,t)=>{const n=[];for(const s of e.getExportDeclarations())if(!s.isTypeOnly()){if(s.isNamespaceExport()){const i=s.getNamespaceExport();i===void 0?n.push(s.getModuleSpecifierValue()??""):t.add(i.getName());continue}for(const i of s.getNamedExports())i.isTypeOnly()||t.add(i.getAliasNode()?.getText()??i.getName())}return n},he=(e,t)=>{for(const n of e.getVariableStatements().filter(s=>s.getExportKeyword()!==void 0))for(const s of n.getDeclarations())q(s.getNameNode(),t);for(const n of[...e.getClasses(),...e.getFunctions(),...e.getEnums()]){if(n.getExportKeyword()===void 0)continue;const s=n.isDefaultExport()?A:n.getName();s!==void 0&&t.add(s)}e.getExportAssignments().length>0&&t.add(A)},G=(e,t)=>{const n=new re({compilerOptions:{allowJs:!0},skipFileDependencyResolution:!0,skipLoadingLibFiles:!0,useInMemoryFileSystem:!0}),s=n.createSourceFile(e,t,{overwrite:!0});return n.getProgram().compilerObject.getSyntacticDiagnostics(s.compilerNode).length>0?void 0:s},ye=(e,t)=>{if(!t.startsWith("./")&&!t.startsWith("../"))return;const n=p(R(e),t),s=w(n),i=S.has(s)||N[s]!==void 0,a=i?n.slice(0,-s.length):n;return[...S.has(s)?[n]:[],...(N[s]??[]).map(r=>`${a}${r}`),...i?[]:$.map(r=>`${n}${r}`),...i||s.length===0?$.map(r=>p(a,`index${r}`)):[]].find(r=>f(r))},K=e=>{const t=new Set,n=new Set([e]),s=[e];for(;s.length>0;){if(n.size-1>ge)return;const i=s.pop();let a;try{a=B(i,"utf8")}catch{return}const o=G(W(i),a);if(o===void 0)return;const r=be(o,t);he(o,t);for(const c of r){const d=ye(i,c);if(d===void 0)return;n.has(d)||(n.add(d),s.push(d))}}return t},ve=(e,t)=>{const n={exports:void 0,kind:"composed",path:E},s=p(e,t,se);if(!f(s))return n;const i=new Set(F);for(const a of P){const o=p(s,`${a}.ts`);if(!f(o))continue;const r=K(o);if(r===void 0)return n;for(const c of r)i.add(c)}return{exports:i,kind:"composed",path:E}},_e=(e,t,n)=>{if(e===void 0||e.origin==="absent")return;if(e.origin==="composed")return ve(t,n);const s=K(e.path);if(!(e.origin==="probed"&&s!==void 0&&!s.has(A)))return{exports:s,kind:"authored",path:e.path}},Ee=new Set([".cjs",".cts",".js",".jsx",".mjs",".mts",".ts",".tsx"]),$e=2e3,D="defineTable",x="defineApp",Se=e=>{const t=[],n=[];let s;try{s=J(e,{withFileTypes:!0})}catch{return{files:t,subdirectories:n}}for(const i of s)i.isDirectory()?i.name.startsWith(".")&&!ne.has(i.name)||ie.has(i.name)||n.push(p(e,i.name)):Ee.has(w(i.name))&&t.push(p(e,i.name));return{files:t,subdirectories:n}},Y=(e,t)=>{const n=new Set;for(const s of e.getImportDeclarations())for(const i of s.getNamedImports())!i.isTypeOnly()&&i.getName()===t&&n.add(i.getAliasNode()?.getText()??i.getName());return n},Ae=(e,t)=>{let n=!1;return e.forEachDescendant((s,i)=>{if(!m.isCallExpression(s))return;const a=s.getExpression();m.isIdentifier(a)&&t.has(a.getText())&&(n=!0,i.stop())}),n},Re=e=>{let t=e;for(;m.isCallExpression(t)||m.isPropertyAccessExpression(t);)t=t.getExpression();return t},we=(e,t)=>{const n=Re(e);return m.isIdentifier(n)&&t.has(n.getText())},H={global:/\.\s*global\s*\(/u,hyperdriveGlobal:/\.\s*hyperdriveGlobal\s*\(/u,vectors:/\.\s*vectors\s*\(/u},je=e=>Object.hasOwn(H,e),Oe=(e,t)=>{const n=new Set,s=new Set([D,...Y(e,D)]);return e.forEachDescendant(i=>{if(!m.isCallExpression(i))return;const a=i.getExpression();if(!m.isPropertyAccessExpression(a)||we(a,s))return;const o=a.getName();je(o)&&t.has(o)&&n.add(o)}),n},ke=(e,t)=>{let n;try{n=B(e,"utf8")}catch{return}const s=new Set([...t].filter(a=>H[a].test(n)));if(s.size===0&&!n.includes(x))return;const i=G(W(e),n);return i===void 0?{chained:s,composes:!1}:{chained:Oe(i,s),composes:Ae(i,Y(i,x))}},Ne=(e,t)=>{const n=[e],s=new Set;let i=0,a;const o=r=>{if(i+=1,i>$e)return!1;const c=ke(r,t);for(const d of c?.chained??[])s.add(d);return c?.composes&&(a??=r),!0};for(;n.length>0;){const r=n.pop(),{files:c,subdirectories:d}=Se(r);n.push(...d);for(const l of c){if(!o(l))return;if(a!==void 0&&s.size===t.size)return{chained:s,site:a}}}return a===void 0?void 0:{chained:s,site:a}},M="2026-04-07",St="web_socket_auto_reply_to_close",I=/^\d{4}-\d{2}-\d{2}$/,C=["containers","d1_databases","durable_objects","kv_namespaces","queues","r2_buckets","secrets_store_secrets","services","tail_consumers","vars","vectorize","workflows"],T=["assets","compatibility_date","exports","logpush","main","migrations","observability","placement"],V=(e,t)=>{if(t===void 0)return{merged:e,unverifiedKeys:[]};const n=e.env?.[t];if(n===void 0){const r=Object.keys(e.env??{}).toSorted((d,l)=>d.localeCompare(l)),c=r.length>0?` (declared: ${r.join(", ")}).`:" (no environments are declared).";return{error:`--env "${t}" names no environment declared in wrangler.jsonc's "env" block${c}`,merged:e,unverifiedKeys:[]}}const s={...e},i=Object.keys(n).filter(r=>r!=="env");for(const r of i)T.includes(r)&&(s[r]=n[r]);for(const r of C)s[r]=n[r];const a=new Set([...C,...T]),o=i.filter(r=>!a.has(r)).map(String);return{merged:s,unverifiedKeys:o}},De=(e,t,n)=>{if(t.length===0)return;const s=e.vectorize??[],i=new Set(s.filter(Boolean).map(a=>a?.index_name));for(const a of t)i.has(a)||n.push(`schema declares vector index "${a}"; wrangler "vectorize" must include a binding with index_name "${a}"`)},xe=new Set(["basic","dev","lite","standard","standard-1","standard-2","standard-3","standard-4"]),Me={disk_mb:2e4,memory_mib:12288,vcpu:4},Ie=(e,t,n)=>{const s=e.instance_type;if(s===void 0)return;if(typeof s=="string"){xe.has(s)||n.push(`${t} has unknown instance_type "${s}" — expected lite, basic, standard-1..4, or a custom { vcpu, memory_mib, disk_mb } object`);return}for(const[r,c]of Object.entries(Me)){const d=s[r];d!==void 0&&(typeof d!="number"||d<=0||d>c)&&n.push(`${t} custom instance_type ${r} must be a positive number ≤ ${String(c)} (got ${String(d)})`)}const{disk_mb:i,memory_mib:a,vcpu:o}=s;if(typeof o=="number"&&typeof a=="number"&&a<o*3072&&n.push(`${t} custom instance_type needs ≥ 3 GiB (3072 MiB) memory per vCPU (got ${String(a)} MiB for ${String(o)} vCPU)`),typeof a=="number"&&typeof i=="number"){const r=Math.floor(a/1024*2e3);i>r&&n.push(`${t} custom instance_type allows ≤ 2 GB disk per GiB memory (≤ ${String(r)} MB for ${String(a)} MiB memory; got ${String(i)} MB)`)}},Ce=(e,t,n)=>{const{boundClasses:s,classKinds:i,errors:a,warnings:o}=n;if(!e||typeof e!="object"||typeof e.class_name!="string"||e.class_name.length===0){a.push(`${t} must have a non-empty "class_name" naming its container-enabled Durable Object class`);return}(typeof e.image!="string"||e.image.length===0)&&a.push(`${t} ("${e.class_name}") must have an "image" — a Dockerfile path or a registry reference`),s.has(e.class_name)||a.push(`${t} class "${e.class_name}" has no matching durable_objects binding — your dev server auto-reconciles this on startup; add { "name": "...", "class_name": "${e.class_name}" } to fix it by hand`);const r=i.get(e.class_name);r!=="sqlite"&&a.push(r==="classic"?`${t} class "${e.class_name}" is registered via "new_classes" but containers require SQLite-backed DOs — move it to "new_sqlite_classes"`:`${t} class "${e.class_name}" is missing from migrations — add a migration entry with "new_sqlite_classes": ["${e.class_name}"]`),Ie(e,`${t} ("${e.class_name}")`,a),e.max_instances===void 0&&o.push(`${t} ("${e.class_name}") declares no max_instances — set a cap so a traffic spike can't fan out unbounded container spend`)},u=e=>typeof e=="string"&&e.length>0,g=e=>Array.isArray(e)?e.filter(t=>t!==null&&typeof t=="object"):[],_=e=>Array.isArray(e)?e.filter(t=>u(t)):[],Q=e=>{const t=new Map;for(const n of g(e)){for(const s of _(n.new_classes))t.set(s,"classic");for(const s of _(n.new_sqlite_classes))t.set(s,"sqlite");for(const s of g(n.renamed_classes))if(u(s.from)&&u(s.to)){const i=t.get(s.from)??"sqlite";t.delete(s.from),t.set(s.to,i)}for(const s of _(n.deleted_classes))t.delete(s)}return t},Te=e=>new Set(Q(e).keys()),Le=(e,t)=>{const n=Te(e.migrations);for(const s of g(e.durable_objects?.bindings))s.script_name===void 0&&u(s.class_name)&&!n.has(s.class_name)&&t.push(`durable_objects.bindings declares class "${s.class_name}" but it is missing from migrations — add a migration entry with "new_sqlite_classes": ["${s.class_name}"] (or "new_classes" for a non-SQLite-backed class), or let the dev server auto-reconcile it on the next start`)},Ue=(e,t,n)=>{if(e.containers===void 0)return;if(!Array.isArray(e.containers)){t.push("containers must be an array of { class_name, image, ... } entries");return}const s=e.containers;if(s.length===0)return;const i=new Set(g(e.durable_objects?.bindings).map(o=>o.class_name)),a=Q(e.migrations);for(const[o,r]of s.entries())Ce(r,`containers[${String(o)}]`,{boundClasses:i,classKinds:a,errors:t,warnings:n});e.observability?.enabled!==!0&&n.push('containers are configured but observability is not enabled — container logs will not be captured (add { "observability": { "enabled": true } })')},j=e=>e,y=(e,t,n,s)=>{if(e!==void 0){if(!Array.isArray(e)){s.push(n.arrayMessage);return}for(const[i,a]of j(e).entries()){const o=`${t}[${String(i)}]`;if(!a||typeof a!="object"){s.push(n.objectMessage(o));continue}for(const r of n.fields)u(a[r.field])||s.push(r.message(o))}}},Be={arrayMessage:"workflows must be an array of { name, binding, class_name } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the Workflow binding (e.g. WORKFLOW_ORDER_PIPELINE)`},{field:"class_name",message:e=>`${e} must have a non-empty "class_name" naming the exported WorkflowEntrypoint class`},{field:"name",message:e=>`${e} must have a non-empty "name" naming the deployed workflow`}],objectMessage:e=>`${e} must be a { name, binding, class_name } object`},We={arrayMessage:"queues.producers must be an array of { binding, queue } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the Queue producer (e.g. QUEUE_EMAIL)`},{field:"queue",message:e=>`${e} must have a non-empty "queue" naming the deployed queue`}],objectMessage:e=>`${e} must be a { binding, queue } object`},Fe={arrayMessage:"queues.consumers must be an array of { queue } entries",fields:[{field:"queue",message:e=>`${e} must have a non-empty "queue" naming the consumed queue`}],objectMessage:e=>`${e} must be a { queue } object`},Pe=(e,t)=>{if(e.queues!==void 0){if(typeof e.queues!="object"||Array.isArray(e.queues)){t.push("queues must be a { producers, consumers } object");return}y(e.queues.producers,"queues.producers",We,t),y(e.queues.consumers,"queues.consumers",Fe,t)}},qe={arrayMessage:"secrets_store_secrets must be an array of { binding, store_id, secret_name } entries",fields:["binding","store_id","secret_name"].map(e=>({field:e,message:t=>`${t} must have a non-empty "${e}"`})),objectMessage:e=>`${e} must be a { binding, store_id, secret_name } object`},Ge=[{arrayMessage:"kv_namespaces must be an array of { binding, id } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the KV namespace binding`,hintField:"id",hintMessage:(e,t)=>`${e} ("${t}") has no "id" — run \`wrangler kv namespace create\` and set the namespace id, or the binding can't resolve`,key:"kv_namespaces"},{arrayMessage:"flagship must be an array of { binding, app_id } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Flagship binding`,hintField:"app_id",hintMessage:(e,t)=>`${e} ("${t}") has no "app_id" — create a Flagship app and set its id, or the binding can't resolve`,key:"flagship"},{arrayMessage:"hyperdrive must be an array of { binding, id } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Hyperdrive binding`,hintField:"id",hintMessage:(e,t)=>`${e} ("${t}") has no "id" — run \`wrangler hyperdrive create\` and set the id, or the binding can't connect`,key:"hyperdrive"},{arrayMessage:"pipelines must be an array of { binding, stream } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Pipelines binding`,hintField:["stream","pipeline"],hintMessage:(e,t)=>`${e} ("${t}") has no "stream" — run \`wrangler pipelines create <name>\` and set the stream name, or the binding can't resolve`,key:"pipelines"},{arrayMessage:"analytics_engine_datasets must be an array of { binding, dataset } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Analytics Engine binding`,hintField:"dataset",hintMessage:(e,t)=>`${e} ("${t}") has no "dataset" — it defaults to the binding name; set it explicitly to avoid drift`,key:"analytics_engine_datasets"}],Ke=(e,t,n,s)=>{const i=e[t.key];if(i!==void 0){if(!Array.isArray(i)){n.push(t.arrayMessage);return}for(const[a,o]of j(i).entries()){const r=`${t.key}[${String(a)}]`;if(!o||typeof o!="object"||!u(o.binding)){n.push(t.bindingMessage(r));continue}(typeof t.hintField=="string"?[t.hintField]:t.hintField).some(d=>u(o[d]))||s.push(t.hintMessage(r,o.binding))}}},Ye=[{key:"browser",message:'browser must be an object with a non-empty "binding" (e.g. { "binding": "BROWSER" })'},{key:"images",message:'images must be an object with a non-empty "binding" (e.g. { "binding": "IMAGES" })'}],He=(e,t,n)=>{const s=e[t.key];s!==void 0&&(typeof s!="object"||s===null||Array.isArray(s)||!u(s.binding))&&n.push(t.message)},Ve=[{arrayMessage:"services must be an array of { binding, service, entrypoint? } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the service binding`},{field:"service",message:e=>`${e} must have a non-empty "service" naming the target Worker`}],key:"services",objectMessage:e=>`${e} must be a { binding, service, entrypoint? } object`},{arrayMessage:"dispatch_namespaces must be an array of { binding, namespace } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding"`},{field:"namespace",message:e=>`${e} must have a non-empty "namespace" naming the dispatch namespace`}],key:"dispatch_namespaces",objectMessage:e=>`${e} must be a { binding, namespace } object`},{arrayMessage:"mtls_certificates must be an array of { binding, certificate_id } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding"`},{field:"certificate_id",message:e=>`${e} must have a non-empty "certificate_id" (upload via \`wrangler mtls-certificate upload\`)`}],key:"mtls_certificates",objectMessage:e=>`${e} must be a { binding, certificate_id } object`},{arrayMessage:"r2_buckets must be an array of { binding, bucket_name } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the R2 bucket binding`},{field:"bucket_name",message:e=>`${e} must have a non-empty "bucket_name" naming the deployed bucket`}],key:"r2_buckets",objectMessage:e=>`${e} must be a { binding, bucket_name } object`}],Qe=(e,t,n)=>{t?.hasD1GlobalTable&&!g(e.d1_databases).some(s=>s.binding==="DB")&&n.push('schema declares .global() tables; d1_databases must include a binding named "DB" — your dev server auto-reconciles this on startup, or add the binding manually'),t?.hasHyperdriveGlobalTable&&g(e.hyperdrive).length===0&&n.push('schema declares .global({ backend: "hyperdrive" }) tables; wrangler must declare a hyperdrive binding for `.hyperdriveGlobal({ exec })` to read — run `wrangler hyperdrive create <name> --connection-string=...` and add `"hyperdrive": [{ "binding": "HYPERDRIVE", "id": "<id>" }]` (any binding name works; your `exec` selector picks it)')},Xe=(e,t)=>{const{d1_databases:n}=e;if(n!==void 0){if(!Array.isArray(n)){t.push("d1_databases must be an array of { binding, database_id | database_name } entries");return}for(const[s,i]of j(n).entries()){const a=`d1_databases[${String(s)}]`;if(!i||typeof i!="object"){t.push(`${a} must be a { binding, database_id | database_name } object`);continue}u(i.binding)||t.push(`${a} must have a non-empty "binding" naming the D1 binding`),!u(i.database_id)&&!u(i.database_name)&&t.push(`${a} must have a "database_id" or a "database_name" — run \`wrangler d1 create\` and set one, or the binding can't resolve`)}}},ze=(e,t,n)=>{const s=e.send_email;if(s===void 0)return;if(!Array.isArray(s)){t.push("send_email must be an array of { name, destination_address? } entries");return}const i=s;for(const[a,o]of i.entries())(!o||typeof o!="object"||typeof o.name!="string"||o.name.length===0)&&n.push(`send_email[${String(a)}] has no non-empty "name" naming the send-email binding — set one before deploying`)},Je=(e,t)=>{e.logpush!==void 0&&typeof e.logpush!="boolean"&&t.push('logpush must be a boolean (set "logpush": true to enable Cloudflare Logpush)')},L=3e5,Ze=(e,t)=>{const{limits:n}=e;if(n===void 0)return;if(typeof n!="object"||Array.isArray(n)){t.push('limits must be an object (e.g. { "cpu_ms": 30000 })');return}const s=n.cpu_ms;if(s!==void 0){if(typeof s!="number"||!Number.isFinite(s)||!Number.isInteger(s)||s<=0){t.push("limits.cpu_ms must be a positive integer number of milliseconds");return}s>L&&t.push(`limits.cpu_ms must be at most ${String(L)} (Cloudflare's per-invocation ceiling)`)}},U=new Set(["off","smart","targeted"]),et=(e,t)=>{const{placement:n}=e;if(n===void 0)return;if(typeof n!="object"||n===null||Array.isArray(n)){t.push('placement must be an object (e.g. { "mode": "smart" })');return}const{mode:s}=n;s!==void 0&&(typeof s!="string"||!U.has(s))&&t.push(`placement.mode must be one of ${[...U].map(i=>`"${i}"`).join(", ")}`)},tt=(e,t)=>{const{observability:n}=e;if(n===void 0)return;if(typeof n!="object"||Array.isArray(n)){t.push('observability must be an object (e.g. { "enabled": true, "head_sampling_rate": 1 })');return}const s=(i,a)=>{i!==void 0&&(typeof i!="number"||Number.isNaN(i)||i<0||i>1)&&t.push(`${a} must be a number in [0, 1] (the fraction of requests sampled)`)};s(n.head_sampling_rate,"observability.head_sampling_rate"),n.logs!==void 0&&(typeof n.logs!="object"||Array.isArray(n.logs)?t.push("observability.logs must be an object"):(s(n.logs.head_sampling_rate,"observability.logs.head_sampling_rate"),n.logs.invocation_logs!==void 0&&typeof n.logs.invocation_logs!="boolean"&&t.push('observability.logs.invocation_logs must be a boolean (set "invocation_logs": true to keep per-invocation summaries)')))},st=(e,t)=>{const{cache:n}=e;if(n!==void 0){if(typeof n!="object"||n===null||Array.isArray(n)){t.push('cache must be an object (e.g. { "enabled": true })');return}n.enabled!==void 0&&typeof n.enabled!="boolean"&&t.push("cache.enabled must be a boolean (true or false)")}},nt=(e,t)=>{const{exports:n}=e;if(n!==void 0){if(typeof n!="object"||n===null||Array.isArray(n)){t.push("exports must be an object keyed by entrypoint name");return}for(const[s,i]of Object.entries(n)){if(typeof i!="object"||i===null){t.push(`exports["${s}"] must be an object`);continue}i.type!==void 0&&typeof i.type!="string"&&t.push(`exports["${s}"].type must be a string`),i.cache!==void 0&&(typeof i.cache!="object"||i.cache===null||Array.isArray(i.cache)?t.push(`exports["${s}"].cache must be an object`):i.cache.enabled!==void 0&&typeof i.cache.enabled!="boolean"&&t.push(`exports["${s}"].cache.enabled must be a boolean`))}}},it=(e,t)=>{const{assets:n}=e;if(n!==void 0){if(typeof n!="object"||Array.isArray(n)){t.push('assets must be an object (e.g. { "directory": "./dist/client", "binding": "ASSETS" })');return}(typeof n.directory!="string"||n.directory.length===0)&&t.push('assets must declare a non-empty "directory" pointing at the built client output (e.g. "./dist/client")'),n.binding!==void 0&&(typeof n.binding!="string"||n.binding.length===0)&&t.push('assets.binding must be a non-empty string (e.g. "ASSETS")'),n.html_handling!==void 0&&typeof n.html_handling!="string"&&t.push("assets.html_handling must be a string"),n.not_found_handling!==void 0&&typeof n.not_found_handling!="string"&&t.push("assets.not_found_handling must be a string")}},at=(e,t)=>{const n=e.tail_consumers;if(n===void 0)return;if(!Array.isArray(n)){t.push("tail_consumers must be an array of { service, environment? } entries");return}const s=n;for(const[i,a]of s.entries())(!a||typeof a!="object"||typeof a.service!="string"||a.service.length===0)&&t.push(`tail_consumers[${String(i)}] must have a non-empty "service" naming the consumer Worker`)},At=(e,t)=>{const n=e.tail_consumers??[];return n.some(i=>!!i&&i?.service===t.service&&i?.environment===t.environment)?e:{...e,tail_consumers:[...n,t]}},ot=(e,t)=>{const{vars:n}=e;if(!n||typeof n!="object")return;const s=n.LUNORA_ALLOWED_ORIGINS,i=n.LUNORA_CORS_ALLOW_CREDENTIALS,a=typeof s=="string"&&s.split(",").some(r=>r.trim()==="*"),o=me(i);a&&o&&t.push('vars.LUNORA_ALLOWED_ORIGINS includes a "*" wildcard while vars.LUNORA_CORS_ALLOW_CREDENTIALS is on — browsers reject this combination and it defeats the allowlist; name explicit origins or drop credentials')},rt=e=>g(e.durable_objects?.bindings).some(t=>t.class_name==="SchedulerDO"&&t.script_name===void 0),v="LUNORA_ORIGIN_URL",ct=(e,t,n)=>{if(!rt(e)||u(e.vars?.[v]))return;const s=t===void 0?"vars":`env.${t}.vars`,i=t===void 0?"":` --env ${t}`;n.push(`durable_objects.bindings declares the SchedulerDO but ${s}.${v} is unset — the DO reads its dispatch origin from its own env and refuses to schedule without it, so every ctx.scheduler.runAfter/runAt fails with ORIGIN_NOT_CONFIGURED. Set ${s}.${v} to the worker's public URL, or \`wrangler secret put ${v}${i}\` (ignore this if it is already set as a secret or in the dashboard).`)},dt=(e,t,n)=>{const{error:s,merged:i,unverifiedKeys:a}=V(e,t);return s!==void 0?{error:s,wrangler:i}:(a.length>0&&n.push(`env.${String(t)} overrides ${a.join(", ")}, which this validator doesn't have a verified inheritance rule for — validated against the TOP-LEVEL value only. Double-check ${a.length===1?"it":"them"} by hand for "${String(t)}".`),{wrangler:i})},X=(e,t,n)=>{const s=[],i=[];if(!e||typeof e!="object")return s.push("wrangler config is not a valid object"),{errors:s,valid:!1,warnings:i};const{error:a,wrangler:o}=dt(e,n,i);if(a!==void 0)return s.push(a),{errors:s,valid:!1,warnings:i};g(o.durable_objects?.bindings).find(l=>l.name==="SHARD"&&l.class_name==="ShardDO")||s.push('durable_objects.bindings must include { "name": "SHARD", "class_name": "ShardDO" } — your dev server auto-reconciles this on startup, or add the binding manually'),Le(o,s);const d=o.compatibility_date??"";d&&!I.test(d)?s.push(`compatibility_date must be in YYYY-MM-DD format (got "${d}")`):d<M&&s.push(`compatibility_date must be >= "${M}" (got "${d||"<missing>"}")`),ce(o)&&I.test(d)&&d<k&&s.push(`cache.enabled requires compatibility_date >= "${k}" (got "${d||"<missing>"}")`),Qe(o,t,s),Xe(o,s),De(o,t?.vectorIndexNames??[],s),at(o,s),Ue(o,s,i),y(o.workflows,"workflows",Be,s),Pe(o,s),y(o.secrets_store_secrets,"secrets_store_secrets",qe,s);for(const l of Ge)Ke(o,l,s,i);for(const l of Ve)y(o[l.key],l.key,l,s);for(const l of Ye)He(o,l,s);return ze(o,s,i),Je(o,s),Ze(o,s),et(o,s),tt(o,s),it(o,s),st(o,s),nt(o,s),ot(o,s),ct(o,n,i),{errors:s,valid:s.length===0,warnings:i}},Rt=X,z=e=>Array.isArray(e)?e:[],lt=(e,t,n)=>{const s=[];for(const i of z(e)){const a=i?.image;typeof a!="string"||!(a.startsWith("./")||a.startsWith("../")||a.startsWith("/")||a.includes("Dockerfile"))||f(a.startsWith("/")?a:p(t,a))||s.push(`containers image "${a}" does not exist (resolved relative to ${n}); create the Dockerfile or point image at a registry reference`)}return s},ut=(e,t)=>{const n=e?.vectorIndexNames??[],s=[];if(n.length>0&&s.push({message:a=>`schema declares vector index(es) ${n.map(o=>`"${o}"`).join(", ")} but nothing chains .vectors(...) onto defineApp() (composed in: ${a}) — \`ctx.vectors\` is then a throwing stub and buildWorkerOptions rejects EVERY request, /_lunora/health included. Add \`.vectors((env) => ({ ${String(n[0])}: env.<BINDING> }))\` to the chain.`,method:"vectors"}),e?.hasD1GlobalTable&&s.push({message:a=>`schema declares .global() table(s) but nothing chains .global(...) onto defineApp() (composed in: ${a}) — 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"}),e?.hasHyperdriveGlobalTable&&s.push({message:a=>`schema declares .global({ backend: "hyperdrive" }) table(s) but nothing chains .hyperdriveGlobal(...) onto defineApp() (composed in: ${a}) — 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 i=Ne(t,new Set(s.map(a=>a.method)));return i===void 0?[]:s.filter(a=>!i.chained.has(a.method)).map(a=>a.message(i.site))},mt="does not export it",pt=(e,t)=>{if(t!=="composed")return`Re-export it from the module that defines it (\`export { ${e} } from "./…";\`), or add it to the app builder's own export (\`export const { ${e} } = app;\`).`;const n=`it exports ${F.join(", ")}, SchedulerDO when its binding is declared, and every class codegen emits from your ${P.map(s=>`${s}.ts`).join(" / ")} declarations`;return ae(e)?`\`@lunora/vite\` generates that entry — ${n}, and ${e} is not among them. Class-A composition does not carry ${e}, 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: ${n}. Declare "${e}" in one of those and re-run \`lunora codegen\`, or drop the binding.`},gt=(e,t)=>{const n=t.exports;if(n===void 0)return[];const s=[];for(const a of g(e.durable_objects?.bindings))typeof a.class_name=="string"&&a.class_name.length>0&&a.script_name===void 0&&s.push({className:a.class_name,label:"durable_objects.bindings"});for(const a of z(e.workflows))typeof a?.class_name=="string"&&a.class_name.length>0&&a.script_name===void 0&&s.push({className:a.class_name,label:"workflows"});return s.filter(a=>!n.has(a.className)).map(a=>`${a.label} declares class "${a.className}" but the ${t.kind==="composed"?"composed class-A worker entry":"worker entry"} (${t.path}) ${mt} — wrangler refuses to bundle a Worker whose ${a.label==="workflows"?"Workflow":"Durable Object"} classes are not exported. ${pt(a.className,t.kind)}`)},ft=e=>e?.origin!=="absent"?[]:[`main is set but no readable file is there (looked in ${e.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.`],wt=e=>{const t=e.schemaDir??"lunora",n=de(e.projectRoot);if(!n){const b=`wrangler.jsonc not found in ${e.projectRoot}; create one declaring at least the SHARD durable object binding.`;return{problems:[b],report:{errors:[b],valid:!1,warnings:[]},wranglerPath:void 0}}const{parsed:s}=le(n);if(s===void 0){const b=`failed to parse ${n} as JSONC.`;return{problems:[b],report:{errors:[b],valid:!1,warnings:[]},wranglerPath:n}}const{error:i,merged:a}=V(s,e.environment);if(i!==void 0)return{problems:[i],report:{errors:[i],valid:!1,warnings:[]},wranglerPath:n};const{error:o,info:r}=oe(e.projectRoot,t),c=X(s,r,e.environment);o!==void 0&&c.warnings.push(`schema parse failed in ${t}/schema.ts: ${o}`);const d=R(n),l=fe(a.main,e.projectRoot,n),O=_e(l,e.projectRoot,t);c.errors.push(...lt(a.containers??[],d,n)),c.warnings.push(...ft(l)),O!==void 0&&c.errors.push(...gt(a,O)),c.errors.push(...ut(r,e.projectRoot));const h=a.assets?.directory;if(typeof h=="string"&&h.length>0){const b=h.startsWith("/")?h:p(d,h);f(b)||c.warnings.push(`assets.directory "${h}" does not exist yet — it is created by the client build; run the build before deploy`)}return c.valid=c.errors.length===0,{problems:c.errors,report:c,wranglerPath:n}};export{M as REQUIRED_COMPATIBILITY_DATE,St as REQUIRED_FLAG,mt as UNEXPORTED_CLASS_MARKER,V as mergeWranglerEnvironment,g as objectBindingEntries,_ as stringEntries,Rt as validateWrangler,X as validateWranglerConfig,wt as validateWranglerProject,At as withTailConsumer};
|
|
@@ -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-9d9xs5ON.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
|
+
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 @@
|
|
|
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=n=>u.has(n),m=n=>{try{return o(n,["--version"],{shell:process.platform==="win32",stdio:"ignore",timeout:5e3}).status===0}catch{return!1}},p=(n=m)=>a.filter(r=>n(r)),A=n=>({args:["install"],command:n}),y=(n,r,t={})=>{const e=t.dev===!0;return n==="npm"?{args:["install",...e?["--save-dev"]:[],...r],command:"npm"}:n==="bun"?{args:["add",...e?["-d"]:[],...r],command:"bun"}:{args:["add",...e?["-D"]:[],...r],command:n}},M=n=>{try{return i(n).packageManager}catch{}const r=c();if(r!==void 0){const e=r.name==="cnpm"?"npm":r.name;if(d(e))return e}const[t]=p();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.")},b=(n,r,t)=>n==="yarn"?{args:[r,...t],command:"yarn"}:n==="bun"?{args:["x",r,...t],command:"bun"}:n==="npm"?{args:["--",r,...t],command:"npx"}:{args:["exec",r,...t],command:"pnpm"},E=(n,r)=>({args:["run",r],command:n}),v=(n,r)=>n==="npm"?`npm run ${r}`:n==="bun"?`bun run ${r}`:`${n} ${r}`;export{y as addArgsFor,p as detectInstalledManagers,M as detectPackageManager,b as execArgsFor,A as installArgsFor,E as runScriptArgsFor,v as runScriptCommand};
|
|
@@ -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
|
+
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 @@
|
|
|
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-DvtTiK4b.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,24 @@
|
|
|
1
|
+
import{Project as p,SyntaxKind as o}from"ts-morph";import{projectUsesUmbrella as u}from"./detectFramework-CUiVEHDQ.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{writeFileSync as T,readFileSync as R}from"node:fs";import{join as M}from"node:path";import{containerBuildTag as W}from"@lunora/container";import{parseTree as L,findNodeAtLocation as Q}from"jsonc-parser";import{DEV_VARS_FILE as K,parseDevVariableEntries as U}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{a as x}from"./jsonc-edit-BZgQIdAH.mjs";import{r as Y,a as F}from"./lunora-manifest-V77OcyFC.mjs";import{findWranglerFile as G,readWranglerJsonc as H}from"./WRANGLER_FILES-UNW-xY5u.mjs";import{objectBindingEntries as q,stringEntries as E}from"./REQUIRED_COMPATIBILITY_DATE-SdRHaUwh.mjs";const I="<replace-with-d1-create-id>",J=e=>[["container","containers",e.containers],["workflow","workflows",e.workflows],["agent","agents",e.agents]].flatMap(([s,t,a])=>a.filter(o=>!o.exported).map(({className:o,exportName:c})=>({className:o,exportName:c,kind:s,module:t}))),k="PIPELINES",V=(e,n)=>{const s=e.flagshipBinding!==void 0&&!(n?.flagship??[]).some(o=>o.binding===e.flagshipBinding),t=e.usesPipelines&&!(n?.pipelines??[]).some(o=>o.binding===k);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 "${k}" pipelines binding exists; run 'wrangler pipelines create <name>' and add a 'pipelines' binding ({ binding: "${k}", pipeline }) — codegen resolves this one name, and the pipeline resource can't be auto-provisioned.`],[s,`lunora/flags.ts uses Flagship in binding mode but no flagship binding "${e.flagshipBinding??""}" exists; add a flagship entry ({ binding: "${e.flagshipBinding??""}", app_id }) — the app_id can't be auto-provisioned.`]].filter(([o])=>o).map(([,o])=>o)},z=e=>[[e.usesX402Charge,"@lunora/x402/charge is used; set the recipient wallet address as a [vars] entry (the var name is your choice) and pass it to the charge config — the x402 facilitator settles USDC to that address."],[e.usesX402Pay,"@lunora/x402/pay is used (ActionCtx-only, spends real funds); add a secrets_store_secrets[] binding holding the agent wallet key (binding name == signer.secretName) and pair the pay rail with a spend policy — ctx.secrets reads a Secrets Store binding, not .dev.vars."]].filter(([s])=>s).map(([,s])=>s),N=(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.`),X=(e,n)=>{const s=new Set([...e.workflows,...e.agents].map(t=>t.className));return s.size===0?[]:(n.workflows??[]).flatMap(t=>{const a=t.class_name;return a===void 0||s.has(a)?[]:[`wrangler.jsonc declares workflows[] entry "${a}" but no defineWorkflow/defineAgent export generates that class — a leftover from a rename will fail the deploy (wrangler rejects a class_name the worker does not export). Remove it if it is not hand-wired.`]})},Z=(e,n)=>{if(e.queues.length===0)return[];const s=new Set(e.queues.map(a=>a.name)),t=new Set(e.queues.map(a=>a.bindingName));return[...(n.queues?.consumers??[]).flatMap(a=>{const{queue:o}=a;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(a=>{const{binding:o}=a;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.`]})]},ee=(e,n)=>[...X(e,n),...Z(e,n)],j=[{keys:["STRIPE_SECRET_KEY","STRIPE_WEBHOOK_SECRET"],label:"Stripe"},{keys:["POLAR_ACCESS_TOKEN","POLAR_WEBHOOK_SECRET"],label:"Polar"},{keys:["CREEM_API_KEY","CREEM_WEBHOOK_SECRET"],label:"Creem"},{keys:["AUTUMN_SECRET_KEY","AUTUMN_WEBHOOK_SECRET"],label:"Autumn"},{keys:["DODO_PAYMENTS_API_KEY","DODO_PAYMENTS_WEBHOOK_KEY"],label:"Dodo Payments"}],ne=()=>j.map(({keys:e,label:n})=>`${e[0]} + ${e[1]} (${n})`).join(" or "),se=e=>{let n;try{n=R(M(e,K),"utf8")}catch{return!1}const s=new Map(U(n).map(t=>[t.key,t.value]));return j.some(({keys:t})=>t.every(a=>(s.get(a)??"")!==""))},O=(e,n,s)=>{const t=new Set(e.durableObjects.map(d=>d.className)),a=[],o=(s?.r2_buckets?.length??0)>0,c=(s?.d1_databases?.some(d=>d.binding==="DB")??!1)||e.needsD1;return e.usesStorage&&!o&&a.push("@lunora/storage is used but R2 bucket bindings have user-defined names; add an r2_buckets entry and pass env.<BINDING> to createStorage()."),e.usesAuth&&!t.has("SessionDO")&&!c&&a.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")&&a.push("@lunora/scheduler is used but the worker entry exports no SchedulerDO; export it so the SCHEDULER binding can be provisioned."),a.push(...N("container","containers",e.containers),...N("workflow","workflows",e.workflows),...N("agent","agents",e.agents)),e.containers.length>0&&s?.observability?.enabled===!1&&a.push("containers are declared but observability is explicitly disabled in wrangler.jsonc — container logs will not be captured."),e.usesPayment&&!se(n)&&a.push(`@lunora/payment is used; set one provider's secret pair in .dev.vars — ${ne()}.`),a.push(...z(e),...V(e,s)),s!==void 0&&a.push(...ee(e,s)),a},te=e=>{const n=new Set(q(e).map(t=>t.tag));let s=1;for(;n.has(`v${String(s)}`);)s+=1;return`v${String(s)}`},oe=e=>{const n=new Set;for(const s of q(e)){for(const t of E(s.deleted_classes))n.delete(t);for(const{from:t,to:a}of q(s.renamed_classes))t!==void 0&&n.delete(t),a!==void 0&&n.add(a);for(const t of[...E(s.new_classes),...E(s.new_sqlite_classes)])n.add(t)}return n},ae=(e,n,s)=>{const t=n.durable_objects?.bindings??[],a=new Set(t.map(l=>l.name)),o=s.filter(l=>!a.has(l.binding));let c=e;const d=[];if(o.length>0){const l=[...t,...o.map(b=>({class_name:b.className,name:b.binding}))];c=x(c,["durable_objects","bindings"],l),d.push(...o.map(b=>`${b.binding}/${b.className}`))}const p=n.migrations??[],r=s.map(l=>l.className).filter(l=>!oe(p).has(l));if(r.length>0){const l=[...p,{new_sqlite_classes:r,tag:te(p)}];c=x(c,["migrations"],l)}return{added:d,text:c}},ie=(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",a=[...s,{binding:"DB",database_id:I,database_name:t}];return{added:["DB (D1)"],text:x(e,["d1_databases"],a)}},$=(e,n,s,t,a)=>{const o=n[s]?.binding;return typeof o=="string"&&o.length>0?{added:[],text:e}:{added:[a],text:x(e,[s],{binding:t})}},re=(e,n)=>(n.analytics_engine_datasets?.length??0)>0?{added:[],text:e}:{added:["ANALYTICS (Analytics Engine)"],text:x(e,["analytics_engine_datasets"],[{binding:"ANALYTICS",dataset:"ANALYTICS"}])},de=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},ce=e=>e.image.kind==="dockerfile"?e.image.dockerfilePath:e.image.kind==="registry"?e.image.reference:W(e.exportName),ue=e=>{const n={class_name:e.className,image:ce(e)};return e.image.kind==="dockerfile"&&(n.image_build_context=e.image.buildContext),e.buildArgs!==void 0&&e.image.kind!=="registry"&&(n.image_vars=e.buildArgs),e.instanceType!==void 0&&(n.instance_type=de(e.instanceType)),e.maxInstances!==void 0&&(n.max_instances=e.maxInstances),e.name!==void 0&&(n.name=e.name),e.rollout?.stepPercentage!==void 0&&(n.rollout_step_percentage=e.rollout.stepPercentage),e.rollout?.gracePeriodSeconds!==void 0&&(n.rollout_active_grace_period=e.rollout.gracePeriodSeconds),n},le=(e,n,s)=>{const t=n.containers??[],a=new Set(t.map(d=>d.class_name)),o=s.filter(d=>!a.has(d.className));if(o.length===0)return{added:[],text:e};const c=x(e,["containers"],[...t,...o.map(d=>ue(d))]);return{added:o.map(d=>`containers/${d.className}`),text:c}},ge=(e,n)=>{if(n.observability!==void 0)return{added:[],text:e};const s=x(e,["observability"],{enabled:!0,head_sampling_rate:1});return{added:["observability"],text:s}},B=e=>({binding:e.bindingName,class_name:e.className,name:e.name}),me=(e,n,s,t=[])=>{const a=n.workflows??[],o=new Set(a.map(r=>r.class_name)),c=s.filter(r=>!o.has(r.className)),d=t.filter(r=>!o.has(r.className));if(c.length===0&&d.length===0)return{added:[],text:e};const p=x(e,["workflows"],[...a,...c.map(r=>B(r)),...d.map(r=>B(r))]);return{added:[...c.map(r=>`workflows/${r.className}`),...d.map(r=>`workflows/${r.className}`)],text:p}},pe=[["maxBatchSize","max_batch_size"],["maxBatchTimeout","max_batch_timeout"],["maxRetries","max_retries"],["deadLetterQueue","dead_letter_queue"],["retryDelay","retry_delay"]],D=e=>Object.fromEntries(pe.filter(([n])=>e.tuning[n]!==void 0).map(([n,s])=>[s,e.tuning[n]])),A="queueTuning",be=/^[\t ]*(?:,[\t ]*)?(?:\/\/[^\n\r]*)?\r?\n/u,he=/^[\t ]*,/u,fe=(e,n)=>{const s=L(e),t=s===void 0?void 0:Q(s,[...n])?.parent;if(t?.type==="property"){const a=t.offset+t.length,o=e.lastIndexOf(`
|
|
2
|
+
`,t.offset-1)+1,c=be.exec(e.slice(a));if(c!==null&&e.slice(o,t.offset).trim()===""){const d=t.parent?.children??[],p=d.indexOf(t),r=p===d.length-1&&p>0?d[p-1]:void 0,l=r===void 0?void 0:he.exec(e.slice(r.offset+r.length))??void 0;return(l===void 0||r===void 0?e.slice(0,o):e.slice(0,r.offset+r.length)+e.slice(r.offset+r.length+l[0].length,o))+e.slice(a+c[0].length)}}return x(e,n,void 0)},P=(e,n,s,t,a,o=new Set)=>{const c=s.join("."),d={},p=[],r=[];let l=e;return{entries:n.map((u,f)=>{const g=t(u);if(g===void 0||u.queue===void 0)return u;const v=Object.fromEntries(Object.entries(D(g)).filter(([m])=>!o.has(m))),w=Object.entries(a[u.queue]??{}).filter(([m])=>!Object.hasOwn(v,m)),_=Object.entries(v).filter(([m,i])=>u[m]!==i),y=w.filter(([m,i])=>u[m]===i).map(([m])=>m),S=Object.fromEntries(Object.entries({...u,...v}).filter(([m])=>!y.includes(m)));for(const[m,i]of _)l=x(l,[...s,f,m],i);for(const m of y)l=fe(l,[...s,f,m]);for(const[m,i]of w){const h=u[m];h!==void 0&&h!==i&&r.push(`${c}/${u.queue}: ${m} is no longer declared by defineQueue, but it was changed by hand to ${JSON.stringify(h)} from the declared ${JSON.stringify(i)}, so it was kept. Delete it from wrangler.jsonc if it should go.`)}return(_.length>0||y.length>0)&&p.push(`${c}/${u.queue} (${[..._.map(([m])=>m),...y.map(m=>`removed ${m}`)].join(", ")})`),Object.keys(v).length>0&&(d[u.queue]=v),S}),owned:d,text:l,updated:p,warnings:r}},ve=(e,n,s,t)=>{const a=n.queues??{},o=a.producers??[],c=a.consumers??[],d=new Set(o.map(g=>g.binding)),p=new Set(c.map(g=>g.queue)),r=s.filter(g=>!d.has(g.bindingName)),l=s.filter(g=>!p.has(g.name)),b=P(e,c,["queues","consumers"],g=>s.find(v=>v.name===g.queue),t);let u=b.text;const f={...b.owned};if(r.length>0||l.length>0){const g=[...o,...r.map(w=>({binding:w.bindingName,queue:w.name}))],v=[...b.entries,...l.map(w=>({queue:w.name,...w.mode==="pull"?{type:"http_pull"}:{},...D(w)}))];for(const w of l){const _=D(w);Object.keys(_).length>0&&(f[w.name]=_)}u=x(u,["queues"],{consumers:v,producers:g})}return{added:[...r.map(g=>`queues.producers/${g.bindingName}`),...l.map(g=>`queues.consumers/${g.name}`)],owned:f,text:u,updated:b.updated,warnings:b.warnings}},we=(e,n,s,t,a)=>{const o=n.env?.[t],c=o?.queues?.consumers??[],d=o?.queues?.producers??[],p=u=>{const f=d.find(g=>g.queue===u.queue)?.binding;return f!==void 0?s.find(g=>g.bindingName===f):s.find(g=>g.name===u.queue&&!d.some(v=>v.binding===g.bindingName))},r=P(e,c,["env",t,"queues","consumers"],p,a,new Set(["dead_letter_queue"])),l=c.filter(u=>u.queue!==void 0&&p(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.`),b=c.flatMap(u=>{const f=p(u)?.tuning.deadLetterQueue;return f===void 0||u.dead_letter_queue!==void 0?[]:[`env.${t}.queues.consumers/${String(u.queue)}: defineQueue declares deadLetterQueue "${f}", 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:r.owned,text:r.text,updated:r.updated,warnings:[...r.warnings,...b,...l]}},_e=(e,n)=>{if(e?.lunoraIsForeign===!0)return n.push(`${e.path}: \`lunora\` is not an object, so the queue tuning ownership record cannot be read or written — an option removed from defineQueue stays deployed.`),{};const s=e?.lunora?.[A],t=a=>typeof a=="object"&&a!==null&&!Array.isArray(a);return s===void 0?{}:!t(s)||!Object.values(s).every(a=>t(a)&&Object.values(a).every(o=>t(o)))?(n.push(`${e?.path??"package.json"}: \`lunora.${A}\` 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},xe=(e,n,s)=>{const t=Object.fromEntries(Object.entries({...n,...s}).filter(([,a])=>Object.keys(a).length>0));F(e,A,Object.keys(t).length===0?void 0:t)},Ae=(e,n,s)=>{const t=G(e),a=J(n);if(!t)return{added:[],changed:!1,exportGaps:a,reason:"wrangler.jsonc not found",updated:[],warnings:O(n,e)};const{parsed:o,text:c}=H(t);if(o===void 0)return{added:[],changed:!1,exportGaps:a,reason:`failed to parse ${t} as JSONC`,updated:[],warnings:O(n,e),wranglerPath:t};const d=O(n,e,o);if(s!==void 0){const i=o.env?.[s]!==void 0;d.push(i?`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 p=n.containers.filter(i=>i.exported),r=n.agents.filter(i=>i.exported&&i.voice===!0&&i.voiceBindingName!==void 0&&i.voiceClassName!==void 0),l=[...n.durableObjects,...p.map(i=>({binding:i.bindingName,className:i.className})),...r.map(i=>({binding:i.voiceBindingName,className:i.voiceClassName}))],b=n.workflows.filter(i=>i.exported),u=n.agents.filter(i=>i.exported),f=Y(e),g=_e(f,d),v={},w=[{enabled:!0,run:i=>ae(i,o,l)},{enabled:n.needsD1,run:i=>ie(i,o)},{enabled:n.usesAi,run:i=>$(i,o,"ai","AI","AI (Workers AI)")},{enabled:n.usesBrowser,run:i=>$(i,o,"browser","BROWSER","BROWSER (Browser Rendering)")},{enabled:n.usesImages,run:i=>$(i,o,"images","IMAGES","IMAGES (Cloudflare Images)")},{enabled:n.usesAnalytics,run:i=>re(i,o)},{enabled:!0,run:i=>ge(i,o)},{enabled:p.length>0,run:i=>le(i,o,p)},{enabled:b.length>0||u.length>0,run:i=>me(i,o,b,u)},{enabled:n.queues.length>0,run:i=>{const h=ve(i,o,n.queues,g.queues??{});return v.queues=h.owned,h}},...s===void 0||o.env?.[s]===void 0?[]:[{enabled:n.queues.length>0,run:i=>{const h=`env.${s}.queues`,C=we(i,o,n.queues,s,g[h]??{});return v[h]=C.owned,C}}]];let _=c;const y=[],S=[];for(const i of w){if(!i.enabled)continue;const h=i.run(_);_=h.text,y.push(...h.added),S.push(...h.updated??[]),d.push(...h.warnings??[])}const m=i=>{if(!(f===void 0||Object.keys(v).length===0))try{xe(f,g,v)}catch(h){d.push(`${i?"wrangler.jsonc was updated, but ":""}recording the queue tuning reconcile owns in ${f.path} (lunora.queueTuning) failed: ${h instanceof Error?h.message:String(h)}. Until it is recorded, an option removed from defineQueue stays deployed.`)}};return y.includes("DB (D1)")&&d.push(`wrote a DB binding with a placeholder database_id ("${I}") — run \`wrangler d1 create <name>\` and replace it before deploying.`),_===c?(m(!1),{added:[],changed:!1,exportGaps:a,reason:"bindings already in sync",updated:[],warnings:d,wranglerPath:t}):(T(t,_,"utf8"),m(!0),{added:y,changed:!0,exportGaps:a,updated:S,warnings:d,wranglerPath:t})};export{J as collectExportGaps,Ae as reconcileWranglerBindings};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{relative as s}from"node:path";import{secretKindOf as a,redact as c}from"@lunora/codegen";import{i as f,a as d}from"./package-secrets-registry-DvtTiK4b.mjs";import{isPlaceholderValue as l}from"./buildPackageSecretsBlock-yv9mjKEW.mjs";import{findWranglerFile as m,readWranglerJsonc as u}from"./WRANGLER_FILES-UNW-xY5u.mjs";const p=8,g=(e,r)=>{if(e===void 0)return[];const n=[];for(const[t,i]of Object.entries(e)){if(typeof i!="string"||l(i)||f(t))continue;const o=a(i)??(d(t)&&i.length>=p?"secret_named_var":void 0);o!==void 0&&n.push({file:r,key:t,kind:o,preview:c(i)})}return n},V=e=>{const r=m(e);if(r===void 0)return[];const{parsed:n}=u(r);return n===void 0?[]:g(n.vars,s(e,r))};export{V as collectWranglerSecretVariables,g as scanWranglerVariablesForSecrets};
|
|
@@ -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-V77OcyFC.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{existsSync as c,readFileSync as o}from"node:fs";import{join as d}from"node:path";const l=[{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"}],n={class:"C",framework:"none"},a=e=>{const s=d(e,"package.json");if(!c(s))return new Set;try{const t=o(s,"utf8"),r=JSON.parse(t);return new Set([...Object.keys(r.dependencies??{}),...Object.keys(r.devDependencies??{})])}catch{return new Set}},p=e=>a(e).has("lunorash"),f=e=>{const s=a(e);if(s.size===0)return n;for(const t of l)if(s.has(t.dependency))return{class:t.class,framework:t.framework};return n};export{f as detectFramework,p as projectUsesUmbrella,a as readProjectDependencyNames};
|
|
@@ -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-Vj9d4qYt.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-Vj9d4qYt.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 m}from"node:fs";import{discoverSchema as c,isHyperdriveGlobalTable as l,isD1GlobalTable as d}from"@lunora/codegen";import{Project as f}from"ts-morph";import{join as b}from"node:path";const y=(s,n)=>{const t=b(s,n,"schema.ts");if(!m(t))return{info:void 0};try{const a=new f({skipAddingFilesFromTsConfig:!0,useInMemoryFileSystem:!1}),r=c(a,t,s),i=e=>r.tables.find(o=>o.name===e)?.shape??{};return{info:{hasD1GlobalTable:r.tables.some(e=>d(e)),hasHyperdriveGlobalTable:r.tables.some(e=>l(e)),vectorIndexNames:r.vectorIndexes.map(e=>e.name),vectorMetadata:r.vectorIndexes.flatMap(e=>(e.metadata??[]).map(o=>({index:e.name,kind:i(e.table)[o]?.kind,property:o})))}}}catch(a){return{error:a instanceof Error?a.message:String(a),info:void 0}}};export{y as discoverSchemaInfo};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{discoverWorkflows as f,WORKFLOWS_FILENAME as i}from"@lunora/codegen";import{d as t}from"./discover-info-Vj9d4qYt.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
|
+
import{readProjectConfigLiterals as o,readProjectTarget as n}from"@lunora/codegen";import{DEFAULT_DEPLOY_TARGET as c,resolveDeployDriver as a}from"./DEFAULT_DEPLOY_TARGET-B-e9mqgX.mjs";const s=e=>{if(typeof e=="boolean")return e;if(e!==null&&typeof e=="object")return!0},g=e=>s(o(e).remote),i=e=>n(e),T=(e,r)=>r??i(e)??c,j=(e,r)=>{const t=T(e,r);return a(t),t};export{s as interpretRemote,g as readProjectRemotePreference,i as readProjectTarget,T as resolveProjectTarget,j as resolveTargetOrThrow};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{modify as a,applyEdits as n}from"jsonc-parser";const p={formattingOptions:{insertSpaces:!0,tabSize:4}},e=(t,s,i)=>{const o=a(t,[...s],i,p);return o.length>0?n(t,o):t};export{p as F,e as a};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{existsSync as O,readFileSync as b,writeFileSync as N}from"node:fs";import{applyEdits as $,modify as S,parseTree as h,findNodeAtLocation as g}from"jsonc-parser";import{join as A}from"node:path";const F=/^([\t ]+)"/mu,J=n=>{const o=F.exec(n)?.[1]??" ";return{eol:n.includes(`\r
|
|
2
|
+
`)?`\r
|
|
3
|
+
`:`
|
|
4
|
+
`,insertSpaces:!o.startsWith(" "),tabSize:o.length}},K=n=>{const o=A(n,"package.json");if(O(o))try{const t=b(o,"utf8"),{lunora:r}=JSON.parse(t),e=typeof r=="object"&&r!==null&&!Array.isArray(r);return{lunora:e?r:void 0,lunoraIsForeign:r!==void 0&&!e,path:o,text:t}}catch{return}},p=n=>JSON.stringify(n,(o,t)=>typeof t=="object"&&t!==null&&!Array.isArray(t)?Object.fromEntries(Object.entries(t).toSorted(([r],[e])=>r.localeCompare(e))):t),j=(n,o,t)=>{const r=J(n),e=r.insertSpaces===!1?" ":" ".repeat(r.tabSize??4),i=r.eol??`
|
|
5
|
+
`,c=e.repeat(o.length),a=JSON.stringify(t,void 0,e).split(`
|
|
6
|
+
`).join(i+c),l=h(n),f=l===void 0?void 0:g(l,[...o]);if(f!==void 0)return n.slice(0,f.offset)+a+n.slice(f.offset+f.length);let s=l;l!==void 0&&o.length>1&&(s=g(l,o.slice(0,-1)));const y=JSON.stringify(o.at(-1));if(s===void 0&&o.length>1)return j(n,o.slice(0,-1),{[o.at(-1)]:t});if(s?.type!=="object")return $(n,S(n,[...o],t,{formattingOptions:r}));const d=s.children?.at(-1);if(d===void 0){const v=`${i}${c}${y}: ${a}${i}${e.repeat(o.length-1)}`;return`${n.slice(0,s.offset+1)}${v}${n.slice(s.offset+s.length-1)}`}const u=d.offset+d.length;return`${n.slice(0,u)},${i}${c}${y}: ${a}${n.slice(u)}`},k=(n,o,t)=>{const r=Object.keys(n.lunora??{}).every(c=>c===o);if(n.lunoraIsForeign||p(n.lunora?.[o])===p(t))return;const e=t===void 0&&r?["lunora"]:["lunora",o],i=t===void 0?$(n.text,S(n.text,e,void 0,{})):j(n.text,e,t);i!==n.text&&N(n.path,i,"utf8")};export{k as a,J as f,K as r};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const a=e=>e.endsWith("S")?e.slice(0,-1):e,r=e=>e.replaceAll(/([a-z\d])([A-Z])/gu,"$1_$2").toUpperCase().split(/[_-]+/u).filter(s=>s.length>0),n=new Set(["CREDENTIAL","DSN","PASSPHRASE","PASSWD","PASSWORD","SECRET","TOKEN"]),c=["ACCESS_KEY","API_KEY","ENCRYPTION_KEY","PRIVATE_KEY","SIGNING_KEY"],i=new RegExp(`(?:${[...n,...c.map(e=>e.replaceAll("_",""))].join("|")})S?$`,"iu"),p=e=>r(e).some(s=>s==="PUBLIC"||s==="PUBLISHABLE"),d=e=>{if(p(e))return!1;const s=r(e);if(s.some(o=>n.has(a(o))))return!0;const t=a(s.join("_"));return c.some(o=>t===o||t.endsWith(`_${o}`))||i.test(e)},h=[{description:"Bearer token the local Lunora Studio uses to call the worker's admin endpoints (data browser, schema edits) in dev. Generate with: openssl rand -hex 32",docsUrl:"https://lunora.sh/docs/packages/studio",key:"LUNORA_ADMIN_TOKEN",placeholderValue:"replace-with-openssl-rand-hex-32"}],u=["BETTER_AUTH_SECRET","STORAGE_SIGNING_SECRET"],l={"@lunora/auth":[{description:"32-byte random secret used to sign sessions and tokens. Generate with: openssl rand -hex 32",docsUrl:"https://lunora.sh/docs/packages/auth#secrets",key:"AUTH_SECRET",placeholderValue:"replace-with-openssl-rand-hex-32"},{description:"Public base URL of your worker (used by better-auth for redirects and cookie domain). For local dev this is typically http://localhost:8787",docsUrl:"https://lunora.sh/docs/packages/auth#secrets",key:"AUTH_URL",placeholderValue:"http://localhost:8787"}],"@lunora/bindings/r2sql":[{description:"Cloudflare API token with R2 SQL read access, for `ctx.r2sql`. Create at https://dash.cloudflare.com/profile/api-tokens with the R2 SQL permission.",docsUrl:"https://lunora.sh/docs/packages/bindings#r2-sql",key:"R2_SQL_TOKEN",placeholderValue:"<your-r2-sql-api-token>"},{description:"Cloudflare account id the R2 SQL queries run against. Falls back to CLOUDFLARE_ACCOUNT_ID when unset.",docsUrl:"https://lunora.sh/docs/packages/bindings#r2-sql",key:"R2_SQL_ACCOUNT_ID",placeholderValue:"<your-cloudflare-account-id>"},{description:"Name of the R2 bucket holding the Iceberg tables `ctx.r2sql` queries.",docsUrl:"https://lunora.sh/docs/packages/bindings#r2-sql",key:"R2_SQL_BUCKET",placeholderValue:"<your-r2-sql-bucket>"}],"@lunora/mail":[{description:"Resend API key for sending transactional email via @lunora/mail. Obtain at https://resend.com/api-keys",docsUrl:"https://lunora.sh/docs/packages/mail#secrets",key:"RESEND_API_KEY",placeholderValue:"<your-resend-api-key>"}],"@lunora/notify":[{description:"Public VAPID key (base64url) for Web Push. Generate a keypair once with: npx web-push generate-vapid-keys — the public key is also shipped to the browser to subscribe.",docsUrl:"https://lunora.sh/docs/packages/notify#web-push",key:"VAPID_PUBLIC_KEY",placeholderValue:"<your-vapid-public-key>"},{description:"Private VAPID key (base64url) for Web Push — the application-server signing key. Generate with: npx web-push generate-vapid-keys",docsUrl:"https://lunora.sh/docs/packages/notify#web-push",key:"VAPID_PRIVATE_KEY",placeholderValue:"<your-vapid-private-key>"},{description:"VAPID `sub` contact — a mailto: or https: URL identifying the application server (e.g. mailto:you@example.com).",docsUrl:"https://lunora.sh/docs/packages/notify#web-push",key:"VAPID_SUBJECT",placeholderValue:"mailto:you@example.com"},{description:"Firebase project id for FCM (HTTP v1) push. Found in the Firebase console project settings.",docsUrl:"https://lunora.sh/docs/packages/notify#fcm",key:"FCM_PROJECT_ID",placeholderValue:"<your-firebase-project-id>"},{description:"OAuth2 access token for FCM (HTTP v1). Convenient for dev but expires — in production supply a getAccessToken() in defineNotify instead. Obtain via the Google Cloud SDK / a service account.",docsUrl:"https://lunora.sh/docs/packages/notify#fcm",key:"FCM_ACCESS_TOKEN",placeholderValue:"<your-fcm-access-token>"}],"@lunora/payment":[{description:"Stripe secret key (sk_test_…). Required when using the Stripe adapter. Obtain at https://dashboard.stripe.com/apikeys",docsUrl:"https://lunora.sh/docs/packages/payment#stripe",key:"STRIPE_SECRET_KEY",placeholderValue:"<your-stripe-secret-key>"},{description:"Stripe webhook signing secret (whsec_…) for verifying event payloads. Obtain at https://dashboard.stripe.com/webhooks",docsUrl:"https://lunora.sh/docs/packages/payment#stripe",key:"STRIPE_WEBHOOK_SECRET",placeholderValue:"<your-stripe-webhook-secret>"},{description:"Polar access token for the Polar payment adapter. Obtain at https://polar.sh/settings/tokens",docsUrl:"https://lunora.sh/docs/packages/payment#polar",key:"POLAR_ACCESS_TOKEN",placeholderValue:"<your-polar-access-token>"},{description:"Polar webhook secret for verifying event payloads from Polar. Obtain at https://polar.sh/settings/webhooks",docsUrl:"https://lunora.sh/docs/packages/payment#polar",key:"POLAR_WEBHOOK_SECRET",placeholderValue:"<your-polar-webhook-secret>"},{description:"Autumn secret key (am_sk_…) for the Autumn payment adapter. Obtain at https://app.useautumn.com/dev",docsUrl:"https://lunora.sh/docs/packages/payment#autumn",key:"AUTUMN_SECRET_KEY",placeholderValue:"<your-autumn-secret-key>"},{description:"Autumn webhook signing secret for verifying Standard Webhooks event payloads. Obtain from your Autumn dashboard webhook settings.",docsUrl:"https://lunora.sh/docs/packages/payment#autumn",key:"AUTUMN_WEBHOOK_SECRET",placeholderValue:"<your-autumn-webhook-secret>"},{description:"Dodo Payments API key (bearer token) for the Dodo Payments adapter. Obtain at https://app.dodopayments.com/developer/api-keys",docsUrl:"https://lunora.sh/docs/packages/payment#dodo-payments",key:"DODO_PAYMENTS_API_KEY",placeholderValue:"<your-dodo-payments-api-key>"},{description:"Dodo Payments webhook signing secret (whsec_…) for verifying event payloads. Obtain at https://app.dodopayments.com/developer/webhooks",docsUrl:"https://lunora.sh/docs/packages/payment#dodo-payments",key:"DODO_PAYMENTS_WEBHOOK_KEY",placeholderValue:"<your-dodo-payments-webhook-secret>"},{description:"Creem API key for the Creem payment adapter. Obtain at https://www.creem.io/dashboard/developers",docsUrl:"https://lunora.sh/docs/packages/payment#creem",key:"CREEM_API_KEY",placeholderValue:"<your-creem-api-key>"},{description:"Creem webhook signing secret for verifying the creem-signature header. Obtain from your Creem dashboard webhook settings.",docsUrl:"https://lunora.sh/docs/packages/payment#creem",key:"CREEM_WEBHOOK_SECRET",placeholderValue:"<your-creem-webhook-secret>"}]},y=new Set([...u,...[...h,...Object.values(l).flat()].filter(e=>d(e.key)&&!e.placeholderValue.startsWith("<")).map(e=>e.key)]),k=e=>{const s=[];for(const t of e){const o=l[t];o!==void 0&&s.push(...o)}return s};export{h as C,y as M,l as P,d as a,p as i,k as s};
|