@lunora/config 1.0.0-alpha.47 → 1.0.0-alpha.471

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. package/LICENSE.md +336 -104
  2. package/README.md +6 -6
  3. package/dist/celld/index.d.mts +77 -0
  4. package/dist/celld/index.d.ts +77 -0
  5. package/dist/celld/index.mjs +1 -0
  6. package/dist/celld-names/index.d.mts +57 -0
  7. package/dist/celld-names/index.d.ts +57 -0
  8. package/dist/celld-names/index.mjs +1 -0
  9. package/dist/cli/index.d.mts +2 -0
  10. package/dist/cli/index.d.ts +2 -0
  11. package/dist/cli/index.mjs +1 -0
  12. package/dist/cloudflare/index.d.mts +941 -0
  13. package/dist/cloudflare/index.d.ts +941 -0
  14. package/dist/cloudflare/index.mjs +1 -0
  15. package/dist/index.d.mts +1068 -1044
  16. package/dist/index.d.ts +1068 -1044
  17. package/dist/index.mjs +1 -25
  18. package/dist/packem_shared/ACCENT-CotPTfv7.mjs +7 -0
  19. package/dist/packem_shared/ADVISOR_PROCEDURES_ENDPOINT-BPnqzAgT.mjs +1 -0
  20. package/dist/packem_shared/AGENT_MODE_ENV-D8MvSwPE.mjs +1 -0
  21. package/dist/packem_shared/AGENT_RULES_DIR-Bd6JPtNa.mjs +1 -0
  22. package/dist/packem_shared/ALLOW_FORWARDED_ENV-BUndghJx.mjs +1 -0
  23. package/dist/packem_shared/BINDING_MANIFEST_VERSION-CR06-eW7.mjs +1 -0
  24. package/dist/packem_shared/BUILD_ROOT_ENV-Dg4MV3wY.mjs +1 -0
  25. package/dist/packem_shared/CELLD_RELEASE_ASSETS_DIRECTORY-YBhEotjs.mjs +1 -0
  26. package/dist/packem_shared/CLOUDFLARE_CLI_CONFIG_WARNING_ENV-75Y5zVF8.mjs +1 -0
  27. package/dist/packem_shared/CLOUDFLARE_DRIVER-DbmpoIcg.mjs +1 -0
  28. package/dist/packem_shared/CLOUDFLARE_TOOLCHAIN_VERSIONS-DWyZ_2QM.mjs +1 -0
  29. package/dist/packem_shared/COMPOSED_WORKER_ENTRY-LpLlp-aF.mjs +1 -0
  30. package/dist/packem_shared/D1_PLACEHOLDER_ID-ZnDjVymH.mjs +1 -0
  31. package/dist/packem_shared/DEFAULT_DEPLOY_TARGET-BlvZ242-.mjs +1 -0
  32. package/dist/packem_shared/DEFAULT_OBSERVABILITY-CPLADr5u.mjs +1 -0
  33. package/dist/packem_shared/DEV_BINDINGS_FILE-BUTedHwq.mjs +4 -0
  34. package/dist/packem_shared/DEV_VARS_EXAMPLE_FILE-hBT89IXh.mjs +6 -0
  35. package/dist/packem_shared/DEV_WORKER_ENV_VALUE-FoysLtF0.mjs +1 -0
  36. package/dist/packem_shared/GLOBAL_FETCH_STRICTLY_PUBLIC_FLAG-f8CnJha3.mjs +1 -0
  37. package/dist/packem_shared/LINKED_PROJECT_DIR-Ba5qPEwo.mjs +2 -0
  38. package/dist/packem_shared/LUNORA_EVENT_SOURCE-Cq0oj0_9.mjs +9 -0
  39. package/dist/packem_shared/LUNORA_IGNORED_PATHS-U93uPxrW.mjs +19 -0
  40. package/dist/packem_shared/LUNORA_TAG-DQTGPqcJ.mjs +1 -0
  41. package/dist/packem_shared/LunoraReporter-f277GLNT.mjs +6 -0
  42. package/dist/packem_shared/MissingBuildOutputError-BAyekzof.mjs +1 -0
  43. package/dist/packem_shared/PACKAGE_SECRETS_REGISTRY-CPWkw-qE.mjs +1 -0
  44. package/dist/packem_shared/POLICY_SCAFFOLD_ENDPOINT-BiQ1zNsR.mjs +1 -0
  45. package/dist/packem_shared/REMOTE_ELIGIBLE_KEYS-DgmXfSuu.mjs +1 -0
  46. package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-BqFeetpX.mjs +1 -0
  47. package/dist/packem_shared/SCHEMA_EDIT_ENDPOINT-D296PlpV.mjs +1 -0
  48. package/dist/packem_shared/SEED_ENDPOINT-C1fhrehH.mjs +1 -0
  49. package/dist/packem_shared/STUDIO_PATH-CvVcvTbQ.mjs +1 -0
  50. package/dist/packem_shared/STUDIO_WRITE_TEMP_SUFFIX-BTTELz3K.mjs +1 -0
  51. package/dist/packem_shared/UNEXPORTED_CLASS_MARKER-BZEXldUo.mjs +1 -0
  52. package/dist/packem_shared/WORKERS_CACHE_MIN_DATE-0k9ABJtF.mjs +1 -0
  53. package/dist/packem_shared/WRANGLER_FILES-BF8PUjuo.mjs +1 -0
  54. package/dist/packem_shared/acceptsConnection-DHhUYGjT.mjs +2 -0
  55. package/dist/packem_shared/addArgsFor-CYZKhNIo.mjs +1 -0
  56. package/dist/packem_shared/applyAdditiveEdit-DEwPKcJg.mjs +6 -0
  57. package/dist/packem_shared/applyModify-DKP2l6S9.mjs +1 -0
  58. package/dist/packem_shared/assertBuildTargetMatches-D11J7F38.mjs +1 -0
  59. package/dist/packem_shared/assertWranglerSatisfiesSchema-_70vhvqk.mjs +3 -0
  60. package/dist/packem_shared/asset-headers-CPuEX21i.mjs +4 -0
  61. package/dist/packem_shared/assetContentType-CUb5bpbI.mjs +1 -0
  62. package/dist/packem_shared/binding-manifest.d-BRdoMhGE.d.mts +593 -0
  63. package/dist/packem_shared/binding-manifest.d-BRdoMhGE.d.ts +593 -0
  64. package/dist/packem_shared/bindingsNeedingDatabase-3KyGflIq.mjs +3 -0
  65. package/dist/packem_shared/blockingFindingsMessage-BQ9z7cie.mjs +1 -0
  66. package/dist/packem_shared/buildPackageSecretsBlock-DrSD60vH.mjs +19 -0
  67. package/dist/packem_shared/canonicalPath-DrfMiT3U.mjs +1 -0
  68. package/dist/packem_shared/celld-binding-id-9MiUoteo.mjs +1 -0
  69. package/dist/packem_shared/celld-config-Ef1RZ02t.mjs +3 -0
  70. package/dist/packem_shared/checkDevEnv-BwZSVBbB.mjs +3 -0
  71. package/dist/packem_shared/classifyPolicyEdit-DJi9Fk8G.mjs +24 -0
  72. package/dist/packem_shared/clearApiSpecMarker-DMGpP41V.mjs +2 -0
  73. package/dist/packem_shared/collectExportGaps-DvirOIVB.mjs +2 -0
  74. package/dist/packem_shared/createConfirm-D5mKTMHj.mjs +7 -0
  75. package/dist/packem_shared/createDiscoveryCache-npJI4uej.mjs +1 -0
  76. package/dist/packem_shared/createStudioDocumentCache-XBG1aWbl.mjs +1 -0
  77. package/dist/packem_shared/deploy-driver.d-CHVNQFV2.d.mts +190 -0
  78. package/dist/packem_shared/deploy-driver.d-CHVNQFV2.d.ts +190 -0
  79. package/dist/packem_shared/describePreservedCrons-i5XT6rtl.mjs +1 -0
  80. package/dist/packem_shared/describeWithheld-CN3D-4pU.mjs +1 -0
  81. package/dist/packem_shared/detectFramework-Dfpvu6rD.mjs +1 -0
  82. package/dist/packem_shared/devTriggerHints-CN_RJxWW.mjs +1 -0
  83. package/dist/packem_shared/devVariablesStamp-BQkGEn9d.mjs +1 -0
  84. package/dist/packem_shared/discover-info-DC2MrAIM.mjs +1 -0
  85. package/dist/packem_shared/discoverAgentInfo-pqFMJBtJ.mjs +1 -0
  86. package/dist/packem_shared/discoverContainerInfo-DzXr7Vm3.mjs +1 -0
  87. package/dist/packem_shared/discoverSchemaInfo-DRPnqgif.mjs +1 -0
  88. package/dist/packem_shared/discoverWorkflowInfo-zW7Tt0Tn.mjs +1 -0
  89. package/dist/packem_shared/emitProjectAssetHeaders-BdqdTVN3.mjs +1 -0
  90. package/dist/packem_shared/ensureGitignoreEntries-Tsk8Qkw7.mjs +7 -0
  91. package/dist/packem_shared/env-flag-u4B05gLp.mjs +1 -0
  92. package/dist/packem_shared/hasCloudflareCredentials-ByCrwaLT.mjs +1 -0
  93. package/dist/packem_shared/index.d-BoUSSRrk.d.mts +270 -0
  94. package/dist/packem_shared/index.d-C1nVDcie.d.ts +270 -0
  95. package/dist/packem_shared/inferLunoraBindings-BUk28bSQ.mjs +1 -0
  96. package/dist/packem_shared/is-plain-object-CWxHeOY1.mjs +1 -0
  97. package/dist/packem_shared/is-within-directory-DRMw89rK.mjs +1 -0
  98. package/dist/packem_shared/isOwnedStudioAssets-CHII-uIX.mjs +1 -0
  99. package/dist/packem_shared/materializeServiceDevConfigs-CdmKflBp.mjs +1 -0
  100. package/dist/packem_shared/mergeWranglerEnvironment-CxT2PV1N.mjs +1 -0
  101. package/dist/packem_shared/parseSchema-D1Wbr1qv.mjs +1 -0
  102. package/dist/packem_shared/pendingBindingChanges-DkVojIQe.mjs +1 -0
  103. package/dist/packem_shared/placeholder-ids.d-DvGHP6bl.d.mts +338 -0
  104. package/dist/packem_shared/placeholder-ids.d-DvGHP6bl.d.ts +338 -0
  105. package/dist/packem_shared/policy-scaffold.d-D2H4_G01.d.mts +86 -0
  106. package/dist/packem_shared/policy-scaffold.d-D2H4_G01.d.ts +86 -0
  107. package/dist/packem_shared/probeCelldToolchain-DxDttfHy.mjs +1 -0
  108. package/dist/packem_shared/process-tree-once-Ou4SfxKM.mjs +1 -0
  109. package/dist/packem_shared/queue-info-D38n7YdX.mjs +1 -0
  110. package/dist/packem_shared/readManifest-Cighz3WC.mjs +6 -0
  111. package/dist/packem_shared/readProjectDependencies-l3uhUKjo.mjs +1 -0
  112. package/dist/packem_shared/reconcile-services-CjgIJKim.mjs +1 -0
  113. package/dist/packem_shared/reconcileWranglerBindings-D6B81UKU.mjs +1 -0
  114. package/dist/packem_shared/reconcileWranglerCompatibilityDate-Cj94osA-.mjs +1 -0
  115. package/dist/packem_shared/renderStudioHtml-CRDTNivi.mjs +15 -0
  116. package/dist/packem_shared/resolveLocalWorkerEnv-C1s-quRt.mjs +1 -0
  117. package/dist/packem_shared/resolveSchemaDirectory-Ca5P6KuP.mjs +1 -0
  118. package/dist/packem_shared/runPostCodegenHook-Dx3yTsYZ.mjs +1 -0
  119. package/dist/packem_shared/scanWranglerVariablesForSecrets-DmdOBmwn.mjs +1 -0
  120. package/dist/packem_shared/secret-key-xi4VK8Jw.mjs +1 -0
  121. package/dist/packem_shared/sendStudioAsset-B81Pex91.mjs +1 -0
  122. package/dist/packem_shared/serveJsonHandler-B8_GE6QC.mjs +1 -0
  123. package/dist/packem_shared/spa-assets-wX8rTPEQ.mjs +1 -0
  124. package/dist/packem_shared/startCelldDevSession-DfuDVsha.mjs +1 -0
  125. package/dist/packem_shared/streamContainerLogs-0nko1qpv.mjs +2 -0
  126. package/dist/packem_shared/studio-assets-BKWx838V.mjs +1 -0
  127. package/dist/packem_shared/validate-bindings-DSMH8bRQ.mjs +1 -0
  128. package/dist/packem_shared/withTailConsumer-BXOIqXxv.mjs +1 -0
  129. package/dist/packem_shared/wranglerCodegenInputs-B8iRZZZw.mjs +1 -0
  130. package/dist/packem_shared/wranglerToAlchemy-ClIdvJFu.mjs +5 -0
  131. package/dist/packem_shared/write-atomic-9sY2z8DB.mjs +3 -0
  132. package/dist/packem_shared/writeAssetHeaders-C5igmezc.mjs +1 -0
  133. package/dist/studio-host/index.d.mts +371 -136
  134. package/dist/studio-host/index.d.ts +371 -136
  135. package/dist/studio-host/index.mjs +1 -7
  136. package/package.json +43 -10
  137. package/dist/packem_shared/ACCENT-DW1XJn8i.mjs +0 -40
  138. package/dist/packem_shared/AGENT_MODE_ENV-DM1Siczo.mjs +0 -17
  139. package/dist/packem_shared/AGENT_RULES_DIR-lcgC08aE.mjs +0 -40
  140. package/dist/packem_shared/DEV_DAEMON_ENV-FIEtW7Fz.mjs +0 -163
  141. package/dist/packem_shared/DEV_VARS_EXAMPLE_FILE-dJPNTEnK.mjs +0 -37
  142. package/dist/packem_shared/LINKED_PROJECT_DIR-CXwXzV_C.mjs +0 -52
  143. package/dist/packem_shared/LUNORA_CONFIG_FILE-CtcIcB5-.mjs +0 -34
  144. package/dist/packem_shared/LUNORA_EVENT_SOURCE-D2fDeGB6.mjs +0 -86
  145. package/dist/packem_shared/LunoraReporter-Ci-bDCK9.mjs +0 -70
  146. package/dist/packem_shared/PACKAGE_SECRETS_REGISTRY-B8t_SdoZ.mjs +0 -70
  147. package/dist/packem_shared/POLICY_SCAFFOLD_ENDPOINT-8bNMHGiu.mjs +0 -104
  148. package/dist/packem_shared/REMOTE_ELIGIBLE_KEYS-BC7_e9Bz.mjs +0 -105
  149. package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-2YYyWJUq.mjs +0 -561
  150. package/dist/packem_shared/SCHEMA_EDIT_ENDPOINT-Df-Wrix-.mjs +0 -99
  151. package/dist/packem_shared/SEED_ENDPOINT-DVCjaGO-.mjs +0 -61
  152. package/dist/packem_shared/WRANGLER_FILES-DwSuC-Kn.mjs +0 -25
  153. package/dist/packem_shared/applyAdditiveEdit-C-snTFEV.mjs +0 -228
  154. package/dist/packem_shared/assetContentType-ByZjeV3D.mjs +0 -72
  155. package/dist/packem_shared/buildPackageSecretsBlock-B8iSX1Zo.mjs +0 -281
  156. package/dist/packem_shared/classifyPolicyEdit-BHeAqF8P.mjs +0 -99
  157. package/dist/packem_shared/createConfirm-fvpdgJ9s.mjs +0 -100
  158. package/dist/packem_shared/detectFramework-U08038Yp.mjs +0 -41
  159. package/dist/packem_shared/discoverContainerInfo-BXFs6Wav.mjs +0 -19
  160. package/dist/packem_shared/discoverSchemaInfo-BB-CKlTK.mjs +0 -25
  161. package/dist/packem_shared/discoverWorkflowInfo-CedvR0mn.mjs +0 -19
  162. package/dist/packem_shared/inferLunoraBindings-ByMwG-gH.mjs +0 -352
  163. package/dist/packem_shared/parseDevVariable-CJiq2IwE.mjs +0 -30
  164. package/dist/packem_shared/parseSchema-DSeyktvG.mjs +0 -107
  165. package/dist/packem_shared/policy-scaffold.d-DCmwn7zQ.d.mts +0 -74
  166. package/dist/packem_shared/policy-scaffold.d-DCmwn7zQ.d.ts +0 -74
  167. package/dist/packem_shared/reconcileWranglerBindings-Cruwwx1M.mjs +0 -334
  168. package/dist/packem_shared/renderStudioHtml-449Ysn75.mjs +0 -37
  169. package/dist/packem_shared/serveJsonHandler-B4OLTGLS.mjs +0 -86
  170. package/dist/packem_shared/streamContainerLogs-BZ4cOZwH.mjs +0 -157
package/dist/index.d.mts CHANGED
@@ -1,8 +1,47 @@
1
- import { ContainerIR, WorkflowIR, QueueIR } from '@lunora/codegen';
2
- export type { ContainerIR, WorkflowIR } from '@lunora/codegen';
1
+ import { AgentIR, ContainerIR, WorkflowIR, CodegenResult } from '@lunora/codegen';
2
+ export { type AgentIR, type ContainerIR, ENV_FILENAME, type WorkflowIR } from '@lunora/codegen';
3
+ export { A as ACCENT, a as AGENT_RULES_DIR, b as AGENT_RULES_HINT, c as AGENT_RULES_HINT_ENV, type d as AgentRulesStatus, B as BADGES, e as BADGE_COLUMN_WIDTH, type f as BadgeName, type g as BadgeSpec, D as DEFAULT_DEPLOY_TARGET, L as LUNA_ART, h as LUNA_BUNNY, i as LUNA_NAME, j as LUNA_SIGNOFF, k as LUNORA_SKILL_NAMES, l as LUNORA_TAG, type m as LevelBadgeName, n as LunoraReporter, type P as PackageManager, type o as PackageManagerProbe, R as ROOT_SKILL_NAME, S as STEP_BADGE_NAMES, type p as StepBadgeName, type T as ToolchainInvocation, q as addArgsFor, r as advisoryLine, s as badgeLead, t as badgeWidth, u as claimAgentRulesHint, v as deployTargetIds, w as detectAgentRules, x as detectInstalledManagers, y as detectPackageManager, z as execArgsFor, C as installArgsFor, E as isRunnableTarget, F as lunoraLine, G as padBadge, H as paintAnswer, I as paintBadge, J as planToolchainInvocation, K as readProjectDependencies, M as readProjectDependencyNames, N as readProjectManifest, O as resolveDeployDriver, Q as runScriptArgsFor, U as runScriptCommand, V as runnableTargetIds, W as targetRunsOwnDevServer, X as toolchainExecArgs } from "./packem_shared/index.d-BoUSSRrk.mjs";
4
+ import { ChildProcess } from 'node:child_process';
5
+ import { D as DiscoveryCache } from "./packem_shared/placeholder-ids.d-DvGHP6bl.mjs";
6
+ export { C as COMPOSED_WORKER_ENTRY, a as D1_PLACEHOLDER_ID, b as DURABLE_OBJECT_BINDINGS, type c as DiscoverSchemaInfoResult, d as GENERATED_CLASS_MODULES, e as GENERATED_MODULE_DURABLE_OBJECTS, type G as GeneratedClassModule, type f as InferOptions, type g as InferredAgent, type I as InferredBindings, type h as InferredContainer, type i as InferredWorkflow, M as MERGED_DURABLE_OBJECTS_MODULE, type S as SchemaInfo, j as createDiscoveryCache, k as discoverSchemaInfo, l as inferLunoraBindings, m as isMergedProject, n as isMergedRoleModule, s as secretSourcesFromBindings } from "./packem_shared/placeholder-ids.d-DvGHP6bl.mjs";
3
7
  import { Writable } from 'node:stream';
4
- import 'ts-morph';
5
- export { type A as AdditivePolicyEdit, type D as DestructivePolicyEdit, type P as PolicyEdit, type a as PolicyScaffoldFailureReason, type b as ScaffoldFileResult, type S as ScaffoldPolicyEdit, type c as WireResult, type W as WireRlsEdit, d as classifyPolicyEdit, s as scaffoldPolicyFile, w as wireRlsIntoProcedure } from "./packem_shared/policy-scaffold.d-DCmwn7zQ.mjs";
8
+ export type { D as DeployDriver, a as DeployRequest, b as DevRequest, c as DriverToolchain, P as ProjectedConfig, d as ProjectionPurpose, S as SecretRequest, T as TailRequest, e as ToolchainCommand } from "./packem_shared/deploy-driver.d-CHVNQFV2.mjs";
9
+ export { type A as AdditivePolicyEdit, type D as DestructivePolicyEdit, type P as PolicyEdit, type a as PolicyScaffoldFailureReason, type b as ScaffoldFileResult, type S as ScaffoldPolicyEdit, type c as WireResult, type W as WireRlsEdit, d as classifyPolicyEdit, r as resolveServerModule, s as scaffoldPolicyFile, w as wireRlsIntoProcedure } from "./packem_shared/policy-scaffold.d-D2H4_G01.mjs";
10
+ interface DiscoverAgentInfoResult {
11
+ /** Discovered agent definitions; `[]` when none are declared or parsing failed. */
12
+ agents: ReadonlyArray<AgentIR>;
13
+ /** Parse error message, when `lunora/agents.ts` exists but could not be analyzed. */
14
+ error?: string;
15
+ }
16
+ /**
17
+ * Discover the project's `defineAgent` declarations. Returns `{ agents: [] }`
18
+ * when the project has no `lunora/agents.ts` (not an error), or
19
+ * `{ agents: [], error }` when the file exists but could not be parsed — callers
20
+ * decide whether that is a warning (validator) or ignorable (inference).
21
+ */
22
+ declare const discoverAgentInfo: (projectRoot: string, schemaDirectory: string) => DiscoverAgentInfoResult;
23
+ interface DiscoverContainerInfoResult {
24
+ /** Discovered container definitions; `[]` when none are declared or parsing failed. */
25
+ containers: ReadonlyArray<ContainerIR>;
26
+ /** Parse error message, when `lunora/containers.ts` exists but could not be analyzed. */
27
+ error?: string;
28
+ }
29
+ /** Discover the container facts, memoised on `cache` when one is given. */
30
+ declare const discoverContainerInfo: (projectRoot: string, schemaDirectory: string, cache?: DiscoveryCache) => DiscoverContainerInfoResult;
31
+ interface DiscoverWorkflowInfoResult {
32
+ /** Parse error message, when `lunora/workflows.ts` exists but could not be analyzed. */
33
+ error?: string;
34
+ /** Discovered workflow definitions; `[]` when none are declared or parsing failed. */
35
+ workflows: ReadonlyArray<WorkflowIR>;
36
+ }
37
+ /**
38
+ * Discover the project's `defineWorkflow` declarations. Returns
39
+ * `{ workflows: [] }` when the project has no `lunora/workflows.ts` (not an
40
+ * error), or `{ workflows: [], error }` when the file exists but could not be
41
+ * parsed — callers decide whether that is a warning (validator) or ignorable
42
+ * (inference).
43
+ */
44
+ declare const discoverWorkflowInfo: (projectRoot: string, schemaDirectory: string) => DiscoverWorkflowInfoResult;
6
45
  /** Minimal env shape — `process.env` structurally, injectable for tests. */
7
46
  type EnvLike = Readonly<Record<string, string | undefined>>;
8
47
  /** One detected agent: which tool, and which env var gave it away. */
@@ -15,79 +54,199 @@ interface AgentDetection {
15
54
  /** Env var that forces agent mode on (`1`/`true`) or off (`0`/`false`), overriding detection. */
16
55
  declare const AGENT_MODE_ENV = "LUNORA_AGENT_MODE";
17
56
  /**
18
- * Detect the AI agent driving this process, or `undefined` when none is.
19
- * `LUNORA_AGENT_MODE` wins over `@visulima/find-ai-runner`'s marker table in
20
- * both directions. Pure — pass a custom `env` in tests.
21
- */
57
+ * Detect the AI agent driving this process, or `undefined` when none is.
58
+ * `LUNORA_AGENT_MODE` wins over `@visulima/find-ai-runner`'s marker table in
59
+ * both directions. Pure — pass a custom `env` in tests.
60
+ */
22
61
  declare const detectAiAgent: (env?: EnvLike) => AgentDetection | undefined;
23
- /**
24
- * Project-relative directory the Lunora agent skills ("rules") install into.
25
- * This is the portable [Agent Skills](https://tanstack.com/intent/latest/docs/registry)
26
- * location — Cursor, Claude Code, and GitHub Copilot all discover skills here.
27
- */
28
- declare const AGENT_RULES_DIR = ".agents/skills";
29
- /** Env var the once-per-process-tree hint guard ({@link claimAgentRulesHint}) sets. */
30
- declare const AGENT_RULES_HINT_ENV = "LUNORA_RULES_HINT_SHOWN";
31
- /**
32
- * The Lunora agent skills shipped by `@lunora/cli`. The first entry (`lunora`)
33
- * is the router skill — its presence is what {@link detectAgentRules} treats as
34
- * "rules installed", since every other skill is reachable through it.
35
- */
36
- declare const LUNORA_SKILL_NAMES: ReadonlyArray<string>;
37
- /** The router skill whose presence marks the rule set as installed. */
38
- declare const ROOT_SKILL_NAME = "lunora";
39
- /**
40
- * The single "rules not installed" message shared by every surface (the CLI
41
- * `lunora dev` summary and the Vite dev plugin), so the wording and the
42
- * pointer at `lunora rules install` stay identical wherever it appears.
43
- */
44
- declare const AGENT_RULES_HINT = "Lunora AI rules not installed — run `lunora rules install` so your coding agent knows how to use Lunora.";
45
- /**
46
- * Process-tree guard so the hint is emitted at most once. The first surface to
47
- * print it sets {@link AGENT_RULES_HINT_ENV} on `process.env`; later surfaces (a
48
- * Vite dev-server restart, or a child process that inherited the env) read it
49
- * and stay quiet. Returns `true` the first time, `false` afterwards.
50
- */
51
- declare const claimAgentRulesHint: () => boolean;
52
- interface AgentRulesStatus {
53
- /**
54
- * True when the `lunora` router skill is installed. We key on the router
55
- * (not "all nine present") so a project that intentionally trims the set
56
- * still counts as installed and isn't nagged.
57
- */
58
- readonly installed: boolean;
59
- /** Skill names with no `SKILL.md` under `&lt;root>/.agents/skills/&lt;name>/`. */
60
- readonly missing: ReadonlyArray<string>;
61
- /** Skill names found under `&lt;root>/.agents/skills/&lt;name>/SKILL.md`. */
62
- readonly present: ReadonlyArray<string>;
62
+ /** The API specs codegen can emit; `"openapi"` is codegen's own default. */
63
+ type MarkedApiSpec = "both" | "none" | "openapi" | "openrpc";
64
+ /**
65
+ * Record which API spec the bundler plugin's codegen emitted. The CLI's deploy runs the plugin's build
66
+ * before its own codegen, and that codegen must emit the same spec, or it deletes the files the plugin
67
+ * wrote. The plugin is the only place its option is read, so it leaves the answer here.
68
+ */
69
+ declare const writeApiSpecMarker: (projectRoot: string, apiSpec: MarkedApiSpec | undefined) => void;
70
+ /** Forget a recorded spec, so the next read sees only what a new client build writes. */
71
+ declare const clearApiSpecMarker: (projectRoot: string) => void;
72
+ /** The spec the last plugin codegen recorded, or `undefined` when there is no readable record. */
73
+ declare const readApiSpecMarker: (projectRoot: string) => MarkedApiSpec | undefined;
74
+ /**
75
+ * A deploy target needs the project's client build output, and none exists yet. The CLI tells this apart from an option a
76
+ * target refuses: a run that is about to build creates that output and defers the check to after its build.
77
+ */
78
+ declare class MissingBuildOutputError extends Error {}
79
+ /**
80
+ * The absolute path with symlinks resolved, so two spellings of one directory compare equal. A path that does not exist yet
81
+ * resolves through its nearest existing ancestor, since the CLI and the plugin often name a `.lunora` directory before creating it.
82
+ */
83
+ declare const canonicalPath: (path: string) => string;
84
+ interface CelldCommandResult {
85
+ code: number;
86
+ /** The launch error (`EACCES`) of a command that exists but could not start. */
87
+ error?: string;
88
+ stdout: string;
89
+ }
90
+ /** Runs one command and resolves its output; `undefined` when it does not exist (not on PATH). */
91
+ type CelldCommandRunner = (command: string, args: ReadonlyArray<string>) => Promise<CelldCommandResult | undefined>;
92
+ interface CelldToolchainProbeOptions {
93
+ /** A `--dry-run` deploy bundles but writes nothing, so it does not need the bucket. */
94
+ dryRun?: boolean;
95
+ /** The environment `CELLD_BUCKET` and `CELLD_ESBUILD` are read from, and the tools are looked up and run with. */
96
+ env?: Readonly<Record<string, string | undefined>>;
97
+ /** `deploy` also needs the fleet bucket; a dev session does not. */
98
+ purpose: "deploy" | "dev";
99
+ /** Injected for tests; defaults to running the command with `execFile`. */
100
+ run?: CelldCommandRunner;
101
+ }
102
+ interface CelldToolchainProbe {
103
+ /** Problems that stop the deploy or dev session. */
104
+ errors: string[];
105
+ /** Problems that do not stop it. */
106
+ warnings: string[];
63
107
  }
64
108
  /**
65
- * Detect whether the Lunora agent skills are installed in `projectRoot` by
66
- * checking the skills folder for each `SKILL.md`. Pure filesystem reads, safe to
67
- * call on every dev-server / CLI startup — the CLI, the Vite plugin, and the
68
- * studio host all use it to decide whether to surface the "rules not installed"
69
- * hint.
70
- */
71
- declare const detectAgentRules: (projectRoot: string) => AgentRulesStatus;
72
- interface DiscoverContainerInfoResult {
73
- /** Discovered container definitions; `[]` when none are declared or parsing failed. */
74
- containers: ReadonlyArray<ContainerIR>;
75
- /** Parse error message, when `lunora/containers.ts` exists but could not be analyzed. */
76
- error?: string;
109
+ * Check the celld toolchain a deploy or dev session will run.
110
+ * @returns the errors that stop it and the warnings that do not. Nothing is written.
111
+ */
112
+ declare const probeCelldToolchain: (options: CelldToolchainProbeOptions) => Promise<CelldToolchainProbe>;
113
+ /** Spawns the process — injectable so tests run without the binary. */
114
+ type DevProcessSpawner = (command: string, args: ReadonlyArray<string>, options: {
115
+ cwd: string;
116
+ shell: boolean;
117
+ }) => ChildProcess;
118
+ interface DevProcessOptions {
119
+ args: ReadonlyArray<string>;
120
+ command: string;
121
+ cwd: string;
122
+ /** Names the process in errors, e.g. `wrangler dev`. */
123
+ label: string;
124
+ /** The error when `command` is not on PATH, naming the fix. */
125
+ notFound: string;
126
+ /** One line of output; the remainder after the last newline is flushed when the stream ends. */
127
+ onLine: (line: string, stream: "stderr" | "stdout") => void;
128
+ port: number;
129
+ readyTimeoutMs: number;
130
+ /** Windows `.cmd` shims only launch through a shell. */
131
+ shell?: boolean;
132
+ /** Aborting it stops the process while it is still starting; the start then rejects. */
133
+ signal?: AbortSignal;
134
+ spawn?: DevProcessSpawner;
135
+ }
136
+ interface DevProcess {
137
+ /** Resolves with the exit code when the process exits without {@link DevProcess.stop} asking it to. */
138
+ crashed: Promise<number>;
139
+ /** Terminate it; resolves once it has exited. */
140
+ stop: () => Promise<void>;
141
+ }
142
+ /** `true` once something accepts a TCP connection on `port`. */
143
+ declare const acceptsConnection: (port: number) => Promise<boolean>;
144
+ /**
145
+ * Spawn the process and resolve once it accepts connections on `port`; reject,
146
+ * with the process stopped, when it cannot be spawned, exits first, or misses
147
+ * the deadline. The caller checks the port is free beforehand: the probe cannot
148
+ * tell this process from another one already listening there.
149
+ */
150
+ declare const startDevProcess: (options: DevProcessOptions) => Promise<DevProcess>;
151
+ /**
152
+ * Where a line came from: `celld` (the app, and the session's own notices) or
153
+ * `celld:<worker>`, and `stderr` for a session notice that reports a failure.
154
+ */
155
+ interface CelldLineOrigin {
156
+ stream: "stderr" | "stdout";
157
+ tag: string;
158
+ }
159
+ interface CelldDevSessionOptions {
160
+ /** Prints one non-empty line of the session's output. */
161
+ log: (line: string, origin: CelldLineOrigin) => void;
162
+ /** Port the app serves on. */
163
+ port: number;
164
+ /** Checks the celld toolchain before anything starts; defaults to the host's `celld` and `PATH`. */
165
+ probe?: () => Promise<CelldToolchainProbe>;
166
+ projectRoot: string;
167
+ spawn?: DevProcessSpawner;
168
+ }
169
+ interface CelldDevSession {
170
+ /**
171
+ * Resolves with an exit code once the app is gone without {@link CelldDevSession.stop}
172
+ * asking: its `celld dev` crashed, or did not come back after a restart.
173
+ */
174
+ exited: Promise<number>;
175
+ /** Stop watching, cut short a restart in flight, then stop the app. */
176
+ stop: () => Promise<void>;
77
177
  }
78
178
  /**
79
- * Discover the project's `defineContainer` declarations. Returns
80
- * `{ containers: [] }` when the project has no `lunora/containers.ts` (not an
81
- * error), or `{ containers: [], error }` when the file exists but could not be
82
- * parsed — callers decide whether that is a warning (validator) or ignorable
83
- * (inference).
84
- */
85
- declare const discoverContainerInfo: (projectRoot: string, schemaDirectory: string) => DiscoverContainerInfoResult;
179
+ * Write the app's dev projection without starting anything, for a `--no-worker`
180
+ * run whose external runner executes `celld dev` on it. The toolchain is probed
181
+ * first, so a missing tool leaves the project untouched, as a session does.
182
+ * @returns the warnings that do not stop it; throws, with nothing written, when a tool is missing.
183
+ */
184
+ declare const writeCelldDevProjection: (options: {
185
+ probe?: () => Promise<CelldToolchainProbe>;
186
+ projectRoot: string;
187
+ }) => Promise<string[]>;
188
+ /**
189
+ * Start the session: register every service, run the app, then watch the
190
+ * service folders. Resolves once the app accepts connections; rejects, with
191
+ * nothing left running, when a service or the app cannot start — including an
192
+ * app `celld dev` cannot run at all (a Vite virtual `main`).
193
+ */
194
+ declare const startCelldDevSession: (options: CelldDevSessionOptions) => Promise<CelldDevSession>;
195
+ /**
196
+ * The environment switch that turns codegen off — the other spelling of
197
+ * `lunora dev --no-codegen`.
198
+ *
199
+ * The flag alone could not reach the Vite flavors: there the codegen watch lives
200
+ * in `@lunora/vite`, inside the framework dev server the CLI spawns as a separate
201
+ * process, which re-parses its own argv and never sees it. So the flag travels as
202
+ * this variable, and both the plugin and the CLI's own watcher read it — one
203
+ * switch, one meaning, every flavor.
204
+ *
205
+ * It is a DEV switch. `vite build` ignores it deliberately: skipping generation
206
+ * there would also skip the ERROR-level advisory gate that fails the build.
207
+ *
208
+ * One-directional, like `LUNORA_REMOTE`: it can turn codegen off, nothing turns
209
+ * it back on. Settable by hand for a project that runs its framework dev script
210
+ * directly rather than through `lunora dev`.
211
+ */
212
+ /** Env var that turns codegen off when it spells `0` / `false`. Unset means on. */
213
+ declare const CODEGEN_ENV = "LUNORA_CODEGEN";
214
+ /** Env var the CLI sets to `0` when `--no-strict-advisories` opts out, so a framework build does not fail on ERROR-level advisories. */
215
+ declare const STRICT_ADVISORIES_ENV = "LUNORA_STRICT_ADVISORIES";
216
+ /** Env var that enables lazy function imports for codegen when it spells `1` / `true`. */
217
+ declare const LAZY_FUNCTIONS_ENV = "LUNORA_LAZY_FUNCTIONS";
218
+ /** The project root the CLI started a client build for. Only that root's plugin checks {@link BUILD_TARGET_ENV} against itself. */
219
+ declare const BUILD_ROOT_ENV = "LUNORA_BUILD_ROOT";
220
+ /**
221
+ * Env var the CLI sets on the client build it spawns (`lunora build` and `lunora deploy`): the target it resolved for this run.
222
+ * A plugin whose own `target` option names another one refuses to build, so the artifact cannot
223
+ * describe a target the deploy will not ship to.
224
+ */
225
+ declare const BUILD_TARGET_ENV = "LUNORA_BUILD_TARGET";
226
+ /** Env var the CLI sets to the path the Vite plugin writes its server metafile to. Unset means the default under `.lunora/`. */
227
+ declare const BUNDLE_META_PATH_ENV = "LUNORA_BUNDLE_META_PATH";
228
+ /**
229
+ * Where a plain `vite build` (no {@link BUNDLE_META_PATH_ENV}) writes the server metafile. Only a prebuilt worker
230
+ * (`frameworkBuild: false`) reads it back, so the CLI clears it before its own client build.
231
+ */
232
+ declare const DEFAULT_BUNDLE_META_PATH: string;
233
+ /**
234
+ * Whether a {@link CODEGEN_ENV} value spells an explicit "off".
235
+ *
236
+ * Takes the VALUE, not the environment, mirroring `isRemoteEnvEnabled` in
237
+ * `./cloudflare/remote-bindings` — the same package's existing answer to the same
238
+ * question, with the opposite polarity.
239
+ */
240
+ declare const isCodegenDisabled: (value: string | undefined) => boolean;
241
+ /** Whether a {@link LAZY_FUNCTIONS_ENV} value explicitly opts into lazy imports. */
242
+ declare const isLazyFunctionsEnabled: (value: string | undefined) => boolean;
243
+ /** Either opt-in enables lazy function imports: the explicit option or {@link LAZY_FUNCTIONS_ENV}. `false` does not veto the environment. */
244
+ declare const resolveLazyFunctions: (flag?: boolean) => boolean;
86
245
  /** Severity a container output line is surfaced at: `stderr` → `error`, `stdout` → `info`. */
87
246
  type ContainerLogLevel = "error" | "info";
88
247
  /** One declared container to follow, identified by the names codegen lifts from `defineContainer`. */
89
248
  interface ContainerLogSource {
90
- /** Generated Durable Object class name, e.g. `TranscoderContainer`. Wrangler's dev image is `cloudflare-dev/&lt;lowercased>`. */
249
+ /** Generated Durable Object class name, e.g. `TranscoderContainer`. Wrangler's dev image is `cloudflare-dev/<lowercased>`. */
91
250
  className: string;
92
251
  /** The `lunora/containers.ts` export name, e.g. `transcoder` — used as the display tag. */
93
252
  exportName: string;
@@ -147,25 +306,25 @@ interface DockerLike {
147
306
  };
148
307
  }
149
308
  /**
150
- * Follow the local Docker logs of every declared container, emitting each output
151
- * line through `onLine` tagged with its export name. Polls for containers (they
152
- * start lazily on first request and may be replaced on restart), attaches once
153
- * per container id, and drops streams whose container has gone. Returns
154
- * immediately with a `close()` handle; all work happens asynchronously.
155
- */
309
+ * Follow the local Docker logs of every declared container, emitting each output
310
+ * line through `onLine` tagged with its export name. Polls for containers (they
311
+ * start lazily on first request and may be replaced on restart), attaches once
312
+ * per container id, and drops streams whose container has gone. Returns
313
+ * immediately with a `close()` handle; all work happens asynchronously.
314
+ */
156
315
  declare const streamContainerLogs: (options: ContainerLogStreamOptions) => ContainerLogStreamHandle;
157
316
  /**
158
- * The meta-frameworks Lunora can compose with, plus `"none"` for a standalone
159
- * SPA / SSR-less project (the current default). Mirrors PLAN4 §2.4.
160
- */
161
- type DetectedFramework = "astro" | "none" | "nuxt" | "react-router" | "solid-start" | "sveltekit" | "tanstack-start" | "tanstack-start-solid";
162
- /**
163
- * void's class model (PLAN4 §3). Class A is Vite-native and Lunora owns the
164
- * worker entry (`createWorker({ httpRouter })`). Class B frameworks own their own
165
- * Cloudflare adapter, so Lunora injects its worker composition into the
166
- * framework's server entry via hooks (PLAN4 M4). Class C is non-CF / SSR-less —
167
- * ship the client adapter + a standalone Lunora worker (today's default).
168
- */
317
+ * The meta-frameworks Lunora can compose with, plus `"none"` for a standalone
318
+ * SPA / SSR-less project (the current default). Mirrors PLAN4 §2.4.
319
+ */
320
+ type DetectedFramework = "astro" | "none" | "nuxt" | "react-router" | "solid-start" | "sveltekit" | "tanstack-start" | "tanstack-start-solid" | "vinext";
321
+ /**
322
+ * void's class model (PLAN4 §3). Class A is Vite-native and Lunora owns the
323
+ * worker entry (`createWorker({ httpRouter })`). Class B frameworks own their own
324
+ * Cloudflare adapter, so Lunora injects its worker composition into the
325
+ * framework's server entry via hooks (PLAN4 M4). Class C is non-CF / SSR-less —
326
+ * ship the client adapter + a standalone Lunora worker (today's default).
327
+ */
169
328
  type FrameworkClass = "A" | "B" | "C";
170
329
  interface FrameworkDetection {
171
330
  /** void's composition class for the detected framework. */
@@ -174,21 +333,89 @@ interface FrameworkDetection {
174
333
  framework: DetectedFramework;
175
334
  }
176
335
  /**
177
- * Read and parse the project `package.json`, returning its merged
178
- * `dependencies` + `devDependencies` name set (empty on any failure). Public
179
- * so sibling consumers (e.g. the CLI's Vite-project detection) share one
180
- * best-effort reader instead of re-parsing `package.json` themselves.
181
- */
182
- declare const readProjectDependencyNames: (root: string) => ReadonlySet<string>;
183
- /**
184
- * Detect which meta-framework a project uses by inspecting its `package.json`
185
- * dependencies, and classify it under void's class-A/B/C model (PLAN4 §3).
186
- *
187
- * Pure and best-effort: never throws. An unknown / missing / malformed
188
- * `package.json` yields `{ framework: "none", class: "C" }` so the standalone
189
- * SPA flow is preserved.
190
- */
336
+ * Whether the project depends on the unscoped `lunorash` umbrella rather than
337
+ * the granular `@lunora/*` packages.
338
+ *
339
+ * Every generator that writes an import INTO the user's project has to ask:
340
+ * an umbrella-only install — the default for every starter template — never
341
+ * installs `@lunora/server`, so under pnpm's strict layout a scaffolded
342
+ * `from "@lunora/server"` is unresolvable and the worker stops bundling.
343
+ * Codegen answers the same question from its own dependency set
344
+ * (`dependencies.has("lunorash")`); this is that answer for every consumer
345
+ * that has only a project root.
346
+ */
347
+ declare const projectUsesUmbrella: (root: string) => boolean;
348
+ /**
349
+ * Detect which meta-framework a project uses by inspecting its `package.json`
350
+ * dependencies, and classify it under void's class-A/B/C model (PLAN4 §3).
351
+ *
352
+ * Pure and best-effort: never throws. An unknown / missing / malformed
353
+ * `package.json` yields `{ framework: "none", class: "C" }` so the standalone
354
+ * SPA flow is preserved.
355
+ */
191
356
  declare const detectFramework: (root: string) => FrameworkDetection;
357
+ /** One key the contract rejected; `message` is already secret-redacted. */
358
+ interface EnvKeyFailure {
359
+ /** The env key that failed. */
360
+ key: string;
361
+ /** Redacted human-readable reason. */
362
+ message: string;
363
+ }
364
+ /** What {@link checkDevEnv} found. */
365
+ type DevEnvCheck = {
366
+ error: string;
367
+ kind: "unloadable";
368
+ } | {
369
+ failures: EnvKeyFailure[];
370
+ kind: "invalid";
371
+ sources: string[];
372
+ } | {
373
+ kind: "absent";
374
+ } | {
375
+ kind: "valid";
376
+ };
377
+ interface DevEnvCheckOptions {
378
+ /**
379
+ * The wrangler config the dev worker runs, when it is not the project's
380
+ * `wrangler.jsonc` — the SvelteKit / Nuxt sidecar runs `wrangler.dev.jsonc`.
381
+ * Its vars, its bindings, and the `.dev.vars` / `.env` beside it are read.
382
+ */
383
+ configPath?: string;
384
+ /** The wrangler environment the dev worker runs; defaults to `CLOUDFLARE_ENV`, which wrangler reads too. */
385
+ environment?: string;
386
+ /**
387
+ * Imports `lunora/env.ts` and answers its module namespace. Defaults to a
388
+ * cache-free `jiti` import, so an edited contract is read fresh.
389
+ */
390
+ load?: (path: string) => Promise<unknown>;
391
+ /** Defaults to `process.env`. */
392
+ processEnv?: Record<string, string | undefined>;
393
+ projectRoot: string;
394
+ schemaDirectory: string;
395
+ /** `--var` values the dev worker is started with; they win over the config's `vars` and over `.dev.vars` / `.env`, as in wrangler. */
396
+ vars?: Readonly<Record<string, string>>;
397
+ /** Binding names the dev session leaves out of the worker (a logged-out `ai` / `artifacts`), so they are not exempt. */
398
+ withheld?: ReadonlyArray<string>;
399
+ }
400
+ /**
401
+ * Run the project's env contract against its local worker env. Never throws:
402
+ * anything that stops the check — a contract that cannot be loaded on the host
403
+ * (a `cloudflare:` import, a tsconfig path alias jiti does not read), an
404
+ * unreadable `.dev.vars`, a wrangler config whose bindings cannot be read —
405
+ * answers `unloadable` with the reason, secrets redacted.
406
+ */
407
+ declare const checkDevEnv: (options: DevEnvCheckOptions) => Promise<DevEnvCheck>;
408
+ /**
409
+ * The one log line {@link checkDevEnv}'s result deserves, with its level — or
410
+ * `undefined` when there is nothing to say. `wasInvalid` is what the previous
411
+ * check of the same server found, so a check that passes again says so.
412
+ */
413
+ declare const describeDevEnvCheck: (check: DevEnvCheck, schemaDirectory: string, { wasInvalid }?: {
414
+ wasInvalid?: boolean;
415
+ }) => undefined | {
416
+ level: "info" | "warn";
417
+ message: string;
418
+ };
192
419
  /** Directory holding per-checkout Lunora state (gitignored by convention). */
193
420
  declare const DEV_STATE_DIR = ".lunora";
194
421
  /** The dev-server state filename, relative to the project root. */
@@ -196,23 +423,32 @@ declare const DEV_STATE_FILE: string;
196
423
  /** Log file a backgrounded dev server's output is captured to, relative to the project root. */
197
424
  declare const DEV_LOG_FILE: string;
198
425
  /**
199
- * Marker env `lunora dev --background` sets on the detached server process
200
- * (the daemon `lunora dev` or `vite dev`), so it records itself as
201
- * `background: true` — and, for the CLI daemon, never re-detects an agent and
202
- * recurses into background mode again.
203
- */
426
+ * Where `lunora dev` writes the binding manifest by default, relative to the
427
+ * project root.
428
+ *
429
+ * A fixed path so a supervisor can read it without being told one, and next to
430
+ * the state record because the two are read together: this says what the Worker
431
+ * needs and where it will serve, `dev.json` says whether it is serving yet.
432
+ */
433
+ declare const DEV_BINDINGS_FILE: string;
434
+ /**
435
+ * Marker env `lunora dev --background` sets on the detached server process
436
+ * (the daemon `lunora dev` or `vite dev`), so it records itself as
437
+ * `background: true` — and, for the CLI daemon, never re-detects an agent and
438
+ * recurses into background mode again.
439
+ */
204
440
  declare const DEV_DAEMON_ENV = "LUNORA_DEV_DAEMON";
205
441
  /** Env carrying the capture-log path into the detached server, recorded in the state file. */
206
442
  declare const DEV_LOG_FILE_ENV = "LUNORA_DEV_LOG_FILE";
207
443
  /**
208
- * Env carrying the PID of a parent that holds a *provisional* state record it
209
- * expects the child dev server to supersede. The CLI claims `.lunora/dev.json`
210
- * with its own PID before spawning the real server (closing the duplicate-start
211
- * race for the vite flavor and the wrangler daemon), then hands its PID down
212
- * via this variable; the child's claim (see {@link claimDevServerState}'s
213
- * `supersedePid`) may replace exactly that record with the authoritative
214
- * URL + PID.
215
- */
444
+ * Env carrying the PID of a parent that holds a *provisional* state record it
445
+ * expects the child dev server to supersede. The CLI claims `.lunora/dev.json`
446
+ * with its own PID before spawning the real server (closing the duplicate-start
447
+ * race for the vite flavor and the wrangler daemon), then hands its PID down
448
+ * via this variable; the child's claim (see {@link claimDevServerState}'s
449
+ * `supersedePid`) may replace exactly that record with the authoritative
450
+ * URL + PID.
451
+ */
216
452
  declare const DEV_HANDOFF_ENV = "LUNORA_DEV_HANDOFF_PID";
217
453
  /** How the recorded dev server runs. */
218
454
  type DevServerMode = "cli" | "vite";
@@ -220,70 +456,135 @@ type DevServerMode = "cli" | "vite";
220
456
  interface DevServerState {
221
457
  /** Whether the server was detached into the background (`lunora dev --background`). */
222
458
  background?: boolean;
459
+ /**
460
+ * PID of the background launcher that wrote a provisional record. It stays when
461
+ * the launcher re-points `pid` at its child, so only that launcher's handoff
462
+ * (see {@link DEV_HANDOFF_ENV}) replaces the record, never another launch's child.
463
+ */
464
+ launcherPid?: number;
223
465
  /** Absolute path of the log file capturing the server's output, when captured. */
224
466
  logFile?: string;
225
467
  /** `"cli"` for the `lunora dev` wrangler orchestration, `"vite"` for a Vite dev server. */
226
468
  mode: DevServerMode;
227
469
  /** PID of the process to signal for shutdown (the orchestrating CLI or the Vite process). */
228
470
  pid: number;
471
+ /**
472
+ * `true` while the record is the background launcher's placeholder: `pid` is
473
+ * the launcher (or, after the launcher stopped waiting, the detached child it
474
+ * spawned) and `url` is the origin it guessed before anything listened. The
475
+ * server replaces the whole record with its own pid and resolved URL once it
476
+ * starts, which drops this flag. A provisional record never means a server
477
+ * is serving.
478
+ */
479
+ provisional?: boolean;
480
+ /**
481
+ * ISO-8601 stamp marking when the server at {@link DevServerState.url} was
482
+ * first observed accepting requests — absent until then.
483
+ *
484
+ * The rest of this record exists as soon as the server is STARTING: `url` is
485
+ * the origin it intends to serve on and `pid` is a process that exists, both
486
+ * written before anything is listening. That is enough to find and stop a
487
+ * server, and not enough for a task runner deciding when to start the next
488
+ * thing — which is what this field is for. Poll it rather than sleeping.
489
+ *
490
+ * Deliberately a claim about `url` and nothing else. `lunora dev` observes it
491
+ * by probing; `@lunora/vite` observes it from the listen callback, since its
492
+ * record is only written once Vite has resolved that URL. Both are honest
493
+ * about the one origin this record advertises — neither says anything about a
494
+ * sidecar on another port.
495
+ *
496
+ * Absent forever is a legitimate outcome: a server that never binds, or one
497
+ * slower than the probe was willing to wait. Treat missing as "not ready
498
+ * yet", never as "will never be ready".
499
+ */
500
+ readyAt?: string;
229
501
  /** ISO-8601 stamp written at startup, purely informational (drives `status` uptime). */
230
502
  startedAt?: string;
231
503
  /** The embedded studio server's URL, when it runs. */
232
504
  studioUrl?: string;
505
+ /**
506
+ * The public quick-tunnel URL `lunora dev --tunnel` was assigned, once
507
+ * cloudflared reports it — absent without `--tunnel`, before the URL
508
+ * arrives, and after the tunnel closes. Lets a `--background` start and
509
+ * `lunora dev status` show a URL that otherwise only reaches the log.
510
+ */
511
+ tunnelUrl?: string;
233
512
  /** The primary URL serving the worker/app. */
234
513
  url: string;
235
514
  }
236
515
  /**
237
- * True when a process with `pid` is currently alive AND signalable by this
238
- * user. Signal `0` performs the existence check without delivering anything.
239
- *
240
- * `EPERM` ("alive but another user's process") deliberately counts as NOT
241
- * alive here: every dev server this module tracks was spawned by the current
242
- * user, so a PID we cannot signal is by definition a recycled PID — treating
243
- * it as running would wedge the lockfile permanently and aim `dev stop`'s
244
- * kill escalation at an innocent process.
245
- */
516
+ * True when a process with `pid` is currently alive AND signalable by this
517
+ * user. Signal `0` performs the existence check without delivering anything.
518
+ *
519
+ * `EPERM` ("alive but another user's process") deliberately counts as NOT
520
+ * alive here: every dev server this module tracks was spawned by the current
521
+ * user, so a PID we cannot signal is by definition a recycled PID — treating
522
+ * it as running would wedge the lockfile permanently and aim `dev stop`'s
523
+ * kill escalation at an innocent process.
524
+ */
246
525
  declare const isProcessAlive: (pid: number) => boolean;
247
526
  /**
248
- * True when the record's PID verifiably still refers to the dev server that
249
- * wrote the record — not merely "some process exists with that number".
250
- * Guards against PID reuse: a server process necessarily starts BEFORE its
251
- * record is written, so a process that started after `startedAt` (+ skew) is
252
- * a recycled PID wearing the corpse's number. The start-time check runs only
253
- * where the platform exposes it (Linux); elsewhere liveness alone decides.
254
- */
527
+ * True when the record's PID verifiably still refers to the dev server that
528
+ * wrote the record — not merely "some process exists with that number".
529
+ * Guards against PID reuse: a server process necessarily starts BEFORE its
530
+ * record is written, so a process that started after `startedAt` (+ skew) is
531
+ * a recycled PID wearing the corpse's number. The start-time check runs only
532
+ * where the platform exposes it (Linux); elsewhere liveness alone decides.
533
+ */
255
534
  declare const isRecordedProcessCurrent: (state: DevServerState) => boolean;
256
535
  /**
257
- * Read the state record from `.lunora/dev.json`, or `undefined` when there is
258
- * no usable record. Best-effort; performs NO liveness check — use
259
- * {@link readLiveDevServerState} for "is a dev server actually running".
260
- */
536
+ * Read the state record from `.lunora/dev.json`, or `undefined` when there is
537
+ * no usable record. Best-effort; performs NO liveness check — use
538
+ * {@link readLiveDevServerState} for "is a dev server actually running".
539
+ */
261
540
  declare const readDevServerState: (projectRoot: string) => DevServerState | undefined;
262
541
  /**
263
- * Write the state record to `.lunora/dev.json`, creating the `.lunora/`
264
- * directory when absent. Returns the absolute path written, or `undefined`
265
- * when the write failed (state is convenience metadata — a read-only checkout
266
- * must never crash dev startup).
267
- */
542
+ * Write the state record to `.lunora/dev.json`, creating the `.lunora/`
543
+ * directory when absent. Returns the absolute path written, or `undefined`
544
+ * when the write failed (state is convenience metadata — a read-only checkout
545
+ * must never crash dev startup).
546
+ */
268
547
  declare const writeDevServerState: (projectRoot: string, state: DevServerState) => string | undefined;
269
548
  /**
270
- * Merge `patch` into the existing state record, when one exists. Used by the
271
- * CLI to stamp `background`/`logFile` onto the record the Vite plugin wrote.
272
- * Returns the merged record, or `undefined` when there was nothing to update.
273
- */
274
- declare const updateDevServerState: (projectRoot: string, patch: Partial<DevServerState>) => DevServerState | undefined;
275
- /**
276
- * Remove `.lunora/dev.json`. Idempotent and never throws. When `expectedPid`
277
- * is given, the file is only removed while it still records that PID — so a
278
- * shutting-down server can't clobber the record a newer server just wrote.
279
- */
549
+ * Merge `patch` into the existing state record, when one exists. Used by the
550
+ * CLI to stamp `background`/`logFile` onto the record the Vite plugin wrote.
551
+ * Returns the merged record, or `undefined` when there was nothing to update.
552
+ *
553
+ * Pass `expectedPid` to patch only while the record still belongs to that
554
+ * process — the counterpart to {@link clearDevServerState}'s guard, and needed
555
+ * by any patch that can land LATE. A readiness stamp is the case in point: this
556
+ * process's server can answer after a newer one has replaced the record, and an
557
+ * unguarded merge would mark that newer server ready on the old one's behalf.
558
+ */
559
+ declare const updateDevServerState: (projectRoot: string, patch: Partial<DevServerState>, options?: {
560
+ expectedPid?: number;
561
+ }) => DevServerState | undefined;
562
+ /**
563
+ * Whether a record reports a server that is accepting requests, as opposed to
564
+ * one that has merely started. Lives here so the CLI's `status`, its JSON
565
+ * output, and any future reader cannot each invent their own answer.
566
+ */
567
+ declare const isDevServerReady: (state: Pick<DevServerState, "readyAt"> | undefined) => boolean;
568
+ /** Where a recorded dev server is in its start, as {@link devServerPhase} names it. */
569
+ type DevServerPhase = "launching" | "ready" | "starting";
570
+ /**
571
+ * `launching` while the record is still the background launcher's placeholder
572
+ * (its pid and URL change once the server starts), `starting` once the server
573
+ * recorded itself but has not answered, `ready` once it has.
574
+ */
575
+ declare const devServerPhase: (state: Pick<DevServerState, "provisional" | "readyAt">) => DevServerPhase;
576
+ /**
577
+ * Remove `.lunora/dev.json`. Idempotent and never throws. When `expectedPid`
578
+ * is given, the file is only removed while it still records that PID — so a
579
+ * shutting-down server can't clobber the record a newer server just wrote.
580
+ */
280
581
  declare const clearDevServerState: (projectRoot: string, expectedPid?: number) => void;
281
582
  /**
282
- * The state record of a dev server that is verifiably running right now, or
283
- * `undefined`. A record whose PID is dead — or recycled onto a different
284
- * process (see {@link isRecordedProcessCurrent}) — is stale: it is cleared on
285
- * the spot so subsequent starts don't keep re-reading a corpse.
286
- */
583
+ * The state record of a dev server that is verifiably running right now, or
584
+ * `undefined`. A record whose PID is dead — or recycled onto a different
585
+ * process (see {@link isRecordedProcessCurrent}) — is stale: it is cleared on
586
+ * the spot so subsequent starts don't keep re-reading a corpse.
587
+ */
287
588
  declare const readLiveDevServerState: (projectRoot: string) => DevServerState | undefined;
288
589
  /** Result of {@link claimDevServerState}: claimed, or lost to the live server already recorded. */
289
590
  interface ClaimDevServerStateResult {
@@ -295,162 +596,162 @@ interface ClaimDevServerStateResult {
295
596
  declare const claimDevServerState: (projectRoot: string, state: DevServerState, options?: {
296
597
  supersedePid?: number;
297
598
  }) => ClaimDevServerStateResult;
599
+ interface DevTriggerHintOptions {
600
+ /** The wrangler environment the dev worker runs; defaults to `CLOUDFLARE_ENV`, which wrangler reads too. */
601
+ environment?: string;
602
+ projectRoot: string;
603
+ /**
604
+ * The dev worker's scheduled-trigger endpoint (no query), when the dev server
605
+ * exposes one, for a ready-to-run `curl`. Omitted, the cron hint names only
606
+ * the Studio page.
607
+ */
608
+ scheduledUrl?: string;
609
+ /** The schema directory the project declares its queues under. */
610
+ schemaDirectory: string;
611
+ /** The Studio's root URL (`…/__lunora`), or `undefined` when it is not served. */
612
+ studioUrl?: string;
613
+ }
614
+ /** One hint row; each dev banner lays it out with {@link formatDevBannerRow}. */
615
+ interface DevTriggerHint {
616
+ label: "Crons" | "Queues";
617
+ text: string;
618
+ }
298
619
  /**
299
- * The `.dev.vars` line grammar — one owner, shared by every reader/writer of the
300
- * file so the format can't drift between packages. `@lunora/cli`'s `env`
301
- * command (parse/serialize) and `@lunora/config`'s scaffolder (comment-
302
- * preserving rewrite) do different *transforms*, but they agree on these
303
- * primitives: the filename, what a `KEY` looks like, how lines split, and how
304
- * quotes strip.
305
- */
620
+ * The hint rows for the project's crons and queues — empty when it declares
621
+ * neither, when `wrangler.jsonc` is missing or unparseable, or when there is no
622
+ * surface to point at. Never throws: it only decorates a startup banner.
623
+ */
624
+ declare const devTriggerHints: (options: DevTriggerHintOptions) => DevTriggerHint[];
625
+ /**
626
+ * One ` ➜ Label: value` banner row, the label padded to `width` (colon
627
+ * included) so the values line up. `style` decorates the arrow and the label
628
+ * after padding, so escape codes never count toward the width — Vite's banner
629
+ * colours both, `lunora dev`'s colours neither. A label wider than `width` gets
630
+ * no padding rather than an error.
631
+ */
632
+ declare const formatDevBannerRow: (label: string, value: string, width: number, style?: {
633
+ arrow?: (text: string) => string;
634
+ label?: (text: string) => string;
635
+ }) => string;
306
636
  /** The conventional filename for local Cloudflare dev secrets (gitignored). */
307
637
  declare const DEV_VARS_FILE: string;
308
638
  /** Its committed, secret-free counterpart that scaffolding reads from. */
309
639
  declare const DEV_VARS_EXAMPLE_FILE: string;
310
- /** A bare `KEY` identifier — the part left of `=` in a `.dev.vars` line. */
640
+ /**
641
+ * A bare `KEY` identifier accepted on the **write** path — `lunora env set`,
642
+ * `env unset`, `env generate`, and {@link upsertDevVariableLine}'s line
643
+ * targeting. Deliberately stricter than what the reader accepts: dotenv keys
644
+ * are `[\w.-]+`, but a key we *write* stays a conventional env-var name so it
645
+ * needs no quoting and round-trips through every consumer. Never use this to
646
+ * decide whether a line in an existing file counts — that is the reader's job.
647
+ */
311
648
  declare const DEV_VARS_KEY_PATTERN: RegExp;
312
- /** Splits file content into lines on either newline style. */
313
-
314
- /**
315
- * Parse `.dev.vars` content into its `{ key, value }` entries, in file order,
316
- * with values unquoted and comments/blank/invalid lines dropped. The canonical
317
- * read of the whole file — callers that just want the variables (rather than a
318
- * comment-preserving rewrite) use this instead of hand-rolling the split loop.
319
- */
649
+ /**
650
+ * Parse `.dev.vars` content into its `{ key, value }` entries, in file order.
651
+ *
652
+ * Delegates to dotenv's own `parse()` — the literal function `wrangler dev` /
653
+ * `@cloudflare/vite-plugin` run over this file before handing the variables to
654
+ * the worker. Using the library rather than a compatible reimplementation is
655
+ * the point: every line the worker sees, Lunora reads identically, including
656
+ * `export `-prefixed lines, dotted/dashed keys, `KEY: value` separators,
657
+ * quote stripping (single/double/backtick), `\n`/`\r` expansion inside double
658
+ * quotes, `#` comments ending unquoted values, and multi-line quoted values.
659
+ * Duplicate keys resolve last-wins, at the key's first position — dotenv
660
+ * returns an object, so a repeated key overwrites in place.
661
+ *
662
+ * The canonical read of the whole file: every reader of `.dev.vars` (and of
663
+ * `.dev.vars.example`) goes through here or through {@link
664
+ * parseDevVariableLine} below, so the format cannot drift between packages.
665
+ */
320
666
  declare const parseDevVariableEntries: (content: string) => {
321
667
  key: string;
322
668
  value: string;
323
669
  }[];
324
- interface DiscoverWorkflowInfoResult {
325
- /** Parse error message, when `lunora/workflows.ts` exists but could not be analyzed. */
326
- error?: string;
327
- /** Discovered workflow definitions; `[]` when none are declared or parsing failed. */
328
- workflows: ReadonlyArray<WorkflowIR>;
329
- }
330
- /**
331
- * Discover the project's `defineWorkflow` declarations. Returns
332
- * `{ workflows: [] }` when the project has no `lunora/workflows.ts` (not an
333
- * error), or `{ workflows: [], error }` when the file exists but could not be
334
- * parsed — callers decide whether that is a warning (validator) or ignorable
335
- * (inference).
336
- */
337
- declare const discoverWorkflowInfo: (projectRoot: string, schemaDirectory: string) => DiscoverWorkflowInfoResult;
338
- interface DurableObjectSpec {
339
- binding: string;
340
- className: string;
341
- }
342
- /**
343
- * A `defineContainer` declaration plus whether its generated DO class is
344
- * exported by the worker entry. Only exported containers are safe to
345
- * provision — wrangler rejects a `containers[].class_name` (and its Durable
346
- * Object binding) that the worker doesn't export.
347
- */
348
- interface InferredContainer extends ContainerIR {
349
- exported: boolean;
350
- }
351
- /**
352
- * A `defineWorkflow` declaration plus whether its generated
353
- * `WorkflowEntrypoint` class is exported by the worker entry. Only exported
354
- * workflows are safe to provision — wrangler rejects a `workflows[].class_name`
355
- * the worker doesn't export. Workflows are NOT Durable Objects, so this never
356
- * implies a `durable_objects` binding or migration.
357
- */
358
- interface InferredWorkflow extends WorkflowIR {
359
- exported: boolean;
360
- }
361
- /**
362
- * A queue declared in `lunora/queues.ts`. Unlike workflows, a queue needs no
363
- * worker-entry class export (its `queue()` handler rides `createWorker`), so
364
- * there is no `exported` flag — every declared queue is reconcilable into the
365
- * wrangler `queues.producers[]` / `queues.consumers[]`.
366
- */
367
- type InferredQueue = QueueIR;
368
- interface InferredBindings {
369
- /** Containers declared in `lunora/containers.ts` (exported or not — see {@link InferredContainer.exported}). */
370
- containers: InferredContainer[];
371
- /** Durable Objects the worker entry exports → safe to bind. */
372
- durableObjects: DurableObjectSpec[];
373
- /**
374
- * The wrangler `flagship[].binding` name implied by `lunora/flags.ts` when it
375
- * uses the Flagship provider in binding mode — `undefined` for HTTP-mode
376
- * Flagship, a custom OpenFeature provider, or no flags. The binding needs an
377
- * un-mintable `app_id`, so it is reconciled as a hint, not auto-written.
378
- */
379
- flagshipBinding?: string;
380
- /** Schema declares a `.global()` table → needs the `DB` D1 binding. */
381
- needsD1: boolean;
382
- /** Queues declared in `lunora/queues.ts` → reconciled into `queues.producers[]` / `queues.consumers[]`. */
383
- queues: InferredQueue[];
384
- /** Human-readable provenance for each inferred binding / hint, for logging. */
385
- signals: string[];
386
- /** `@lunora/ai` is imported or `env.AI` is used → needs the `ai` Workers AI binding. */
387
- usesAi: boolean;
388
- /** `@lunora/bindings/analytics` is imported → self-describing `analytics_engine_datasets` binding (auto-writeable). */
389
- usesAnalytics: boolean;
390
- /** `@lunora/auth` is imported (sessions may be D1- or `SessionDO`-backed). */
391
- usesAuth: boolean;
392
- /** `@lunora/browser` is imported → self-describing `browser` binding (auto-writeable). */
393
- usesBrowser: boolean;
394
- /** `lunora/flags.ts` declares a feature-flag provider (any OpenFeature provider — Flagship or custom). */
395
- usesFlags: boolean;
396
- /** `@lunora/hyperdrive` is imported (binding needs an un-mintable remote `id`; hint-only). */
397
- usesHyperdrive: boolean;
398
- /** `@lunora/bindings/images` is imported → self-describing `images` binding (auto-writeable). */
399
- usesImages: boolean;
400
- /** `@lunora/bindings/kv` is imported (namespace binding name + id are user-defined; hint-only). */
401
- usesKv: boolean;
402
- /** `@lunora/mail` is imported (Resend API key must be set in `.dev.vars`; no binding). */
403
- usesMail: boolean;
404
- /** `@lunora/payment` is imported (provider secrets must be set in `.dev.vars`; no binding). */
405
- usesPayment: boolean;
406
- /** `ctx.pipelines` is used (binding needs an un-mintable remote pipeline name; hint-only). */
407
- usesPipelines: boolean;
408
- /** `@lunora/scheduler` is imported. */
409
- usesScheduler: boolean;
410
- /** `@lunora/storage` is imported (R2 bucket binding name is user-defined). */
411
- usesStorage: boolean;
412
- /** Workflows declared in `lunora/workflows.ts` (exported or not — see {@link InferredWorkflow.exported}). */
413
- workflows: InferredWorkflow[];
414
- }
415
- interface InferOptions {
416
- projectRoot: string;
417
- /** Directories (relative to root) to scan. Defaults to `lunora` + `src`. */
418
- scanDirs?: ReadonlyArray<string>;
419
- /** Lunora source directory holding `schema.ts`. Defaults to `lunora`. */
420
- schemaDir?: string;
421
- }
422
670
  /**
423
- * Scan a Lunora project and report which Cloudflare bindings its code implies.
424
- * Read-only: performs no writes. Binding provisioning is driven by the worker
425
- * entry's Durable Object exports plus the schema's D1 need; capability imports
426
- * surface as hints.
427
- */
428
- declare const inferLunoraBindings: (options: InferOptions) => Promise<InferredBindings>;
429
- /**
430
- * Derive the list of `@lunora/*` package names that are actively used by a
431
- * project, based on its already-resolved {@link InferredBindings}.
432
- *
433
- * This is the canonical bridge between binding inference and the package-aware
434
- * `.dev.vars.example` scaffolding in `scaffold-dev-variables.ts`. The result is
435
- * a stable, predictable slice of {@link CAPABILITY_SOURCES} source values,
436
- * filtered to the flags that are `true` in `bindings` — in CAPABILITY_SOURCES
437
- * declaration order.
438
- */
439
- declare const packageNamesFromBindings: (bindings: InferredBindings) => string[];
671
+ * A dotenv-format file (`.dev.vars`, `.env`, …) as a record, through
672
+ * {@link parseDevVariableEntries} — or `undefined` when the file does not exist.
673
+ * Any other read failure (a directory, no permission) throws, as it makes
674
+ * `wrangler dev` refuse a `.dev.vars`; a caller that reads a broken file as
675
+ * unset catches it.
676
+ */
677
+ declare const readDevVariablesRecord: (path: string) => Record<string, string> | undefined;
678
+ /** The `.env` files `wrangler dev` reads for `environment`, in load order (later wins) — its `getDefaultEnvFiles`. */
679
+ declare const wranglerDotenvFiles: (environment?: string) => string[];
680
+ /**
681
+ * Escape a runtime string for safe literal interpolation into a `RegExp`
682
+ * source. The one canonical implementation — `@lunora/config`'s own
683
+ * `infer-bindings.ts` (type-only-export detection) and `@lunora/cli`'s `env`
684
+ * command both need this and used to carry their own (functionally
685
+ * identical) copy; grammar this fundamental gets one owner like everything
686
+ * else in this module.
687
+ */
688
+ declare const escapeRegExp: (value: string) => string;
689
+ /**
690
+ * Surgically upsert a single `KEY="value"` line in raw `.dev.vars` content,
691
+ * leaving every comment, blank line, and untouched entry verbatim. Rebuilding
692
+ * the whole file from the parsed entry map (an earlier approach) silently
693
+ * dropped all `# …` comments and blank lines — including the documentation the
694
+ * registry installer and scaffolder write — and re-quoted lines the user never
695
+ * touched. If the key already has a line it is replaced in place; otherwise the
696
+ * new line is appended with a single trailing newline. Always quotes the value
697
+ * to preserve a whitespace round-trip; callers (`env set`, `env generate --set`,
698
+ * `deploy`'s minted-secret disclosure) reject newline/`"`/`\` up front so the
699
+ * verbatim quote is safe.
700
+ *
701
+ * Duplicate lines for the key are collapsed down to exactly one. The shared
702
+ * read path is last-wins — dotenv overwrites the key as it walks the file — so
703
+ * replacing only the first match would leave a later, untouched duplicate
704
+ * still winning at read time, i.e. a `set` that silently didn't take effect.
705
+ */
706
+ declare const upsertDevVariableLine: (content: string, key: string, value: string) => string;
707
+ /**
708
+ * Surgically remove every `.dev.vars` line defining `key` (and its own line
709
+ * terminator), preserving all other lines, comments, and blanks verbatim.
710
+ * Backs `lunora env unset`.
711
+ */
712
+ declare const removeDevVariableLine: (content: string, key: string) => string;
713
+ /**
714
+ * Worker env var the dev tooling sets so the Lunora runtime recognises a
715
+ * development deployment (`@lunora/do`'s `isDevEnvironment`) and therefore
716
+ * streams every RPC dispatch summary to the terminal, keeps argument/error
717
+ * detail unredacted, and runs the studio security audit with `dev: true`.
718
+ */
719
+ declare const DEV_WORKER_ENV_VAR = "WORKER_ENV";
720
+ /** The value that flags a dev deployment. */
721
+ declare const DEV_WORKER_ENV_VALUE = "development";
722
+ /**
723
+ * Top up `.dev.vars` with the dev-environment flag unless the project already
724
+ * declares it (in `.dev.vars` itself, or in the wrangler config's `vars`).
725
+ */
726
+ declare const ensureDevWorkerEnv: (projectRoot: string, info: (message: string) => void) => void;
727
+ /**
728
+ * Make sure the `.gitignore` in `directory` covers every pattern in `patterns`,
729
+ * appending only the ones it lacks. A no-op once they are all present, so a
730
+ * second call changes nothing.
731
+ *
732
+ * ORDER IS LOAD-BEARING: git is last-match-wins, so a negation only works while
733
+ * it sits below every pattern that would otherwise catch its file. An appended
734
+ * pattern lands BELOW whatever the file already had, so when anything is
735
+ * appended every negation in `patterns` is re-stated after the additions.
736
+ * @param directory The directory whose `.gitignore` is ensured; the patterns are relative to it.
737
+ * @param patterns The `.gitignore` lines the directory must carry.
738
+ * @returns The patterns appended, empty when the file already covered them all.
739
+ */
740
+ declare const ensureGitignoreEntries: (directory: string, patterns: ReadonlyArray<string>) => string[];
440
741
  /** Directory holding per-checkout Lunora state (gitignored by convention). */
441
742
  declare const LINKED_PROJECT_DIR = ".lunora";
442
743
  /** The canonical link filename, relative to the project root. */
443
744
  declare const LINKED_PROJECT_FILE: string;
444
745
  /**
445
- * The link record persisted to `.lunora/project.json`. Every field is optional
446
- * so a partially-populated link (e.g. a worker name with no URL yet) still
447
- * round-trips. `linkedAt` is an ISO-8601 stamp written at link time, purely
448
- * informational.
449
- */
746
+ * The link record persisted to `.lunora/project.json`. Every field is optional
747
+ * so a partially-populated link (e.g. a worker name with no URL yet) still
748
+ * round-trips. `linkedAt` is an ISO-8601 stamp written at link time, purely
749
+ * informational.
750
+ */
450
751
  interface LinkedProject {
451
752
  /** Cloudflare account id the worker lives under, when known. */
452
753
  account?: string;
453
- /** Cloudflare environment name (`wrangler … --env &lt;env>`), when scoped. */
754
+ /** Cloudflare environment name (`wrangler … --env <env>`), when scoped. */
454
755
  env?: string;
455
756
  /** ISO-8601 timestamp recorded when the link was written. */
456
757
  linkedAt?: string;
@@ -460,34 +761,133 @@ interface LinkedProject {
460
761
  workerUrl?: string;
461
762
  }
462
763
  /**
463
- * Read the link record from `.lunora/project.json`, or `undefined` when there
464
- * is no usable link. Best-effort: a missing file, parse error, or unexpected
465
- * shape all collapse to `undefined`.
466
- */
764
+ * Read the link record from `.lunora/project.json`, or `undefined` when there
765
+ * is no usable link. Best-effort: a missing file, parse error, or unexpected
766
+ * shape all collapse to `undefined`.
767
+ */
467
768
  declare const readLinkedProject: (projectRoot: string) => LinkedProject | undefined;
468
769
  /**
469
- * Write the link record to `.lunora/project.json`, creating the `.lunora/`
470
- * directory when absent. Only defined fields are persisted (so an empty value
471
- * never clobbers a known one). Returns the absolute path written.
472
- */
770
+ * Write the link record to `.lunora/project.json`, creating the `.lunora/`
771
+ * directory when absent. Only defined fields are persisted (so an empty value
772
+ * never clobbers a known one). Returns the absolute path written.
773
+ */
473
774
  declare const writeLinkedProject: (projectRoot: string, link: LinkedProject) => string;
474
775
  /**
475
- * Shared formatter for the structured log events the Lunora runtime emits to the
476
- * worker's `console` during development. Both the CLI `dev` command and the Vite
477
- * plugin pipe worker output through `formatLunoraEvent` so a developer sees
478
- * attributed, readable lines instead of raw JSON.
479
- *
480
- * The runtime emits two event shapes, each a single `console` line tagged
481
- * `source: "lunora"` (see `@lunora/do`'s `request-log.ts`): a `type: "log"`
482
- * event per `ctx.log.*` call, and a `type: "request"` event per RPC dispatch
483
- * (opt-in for successful calls, always for errors).
484
- *
485
- * This module is intentionally dependency-free and colour-free: it returns the
486
- * severity plus a plain display string, leaving ANSI/level colouring to each
487
- * caller (the CLI routes through its `pail` logger; the Vite plugin dims inline).
488
- * Any line that is not a lunora event returns `undefined`, signalling the caller
489
- * to pass it through unchanged.
490
- */
776
+ * The generated and derived paths a linter or formatter should skip, in
777
+ * gitignore syntax relative to the project root.
778
+ *
779
+ * Committed-on-purpose entries are in here too, deliberately: being tracked by
780
+ * git says nothing about whether a human should be asked to reformat it.
781
+ */
782
+ declare const LUNORA_IGNORED_PATHS: ReadonlyArray<string>;
783
+ /** A linter or formatter this module knows how to configure. */
784
+ type LintTool = "biome" | "eslint" | "oxlint" | "prettier";
785
+ /**
786
+ * What happened to one tool's configuration.
787
+ *
788
+ * `"manual"` is not a failure — it means the change is correct but not safe to
789
+ * make automatically, and {@link LintIgnoreOutcome.snippet} carries what to
790
+ * paste. `"failed"` IS a failure, but only of this step: the command that
791
+ * triggered it had already done its real work, so it is reported rather than
792
+ * thrown.
793
+ */
794
+ type LintIgnoreStatus = "created" | "failed" | "manual" | "unchanged" | "updated";
795
+ interface LintIgnoreOutcome {
796
+ /** For `"failed"`: why the writer could not run. The command itself still succeeded. */
797
+ message?: string;
798
+ /** Config file that was written, or the one the user must edit for `"manual"`. */
799
+ path: string;
800
+ /** For `"manual"`: the exact text to add. */
801
+ snippet?: string;
802
+ status: LintIgnoreStatus;
803
+ tool: LintTool;
804
+ }
805
+ /**
806
+ * Which linters/formatters this project already uses, by declared dependency or
807
+ * config file on disk.
808
+ *
809
+ * Both signals matter: a dependency without a config is a tool about to be
810
+ * configured, and a config without a dependency is a tool installed globally or
811
+ * hoisted from a monorepo root. Missing either one means silently skipping a
812
+ * tool the project genuinely runs.
813
+ */
814
+ declare const detectLintTools: (projectRoot: string) => LintTool[];
815
+ /**
816
+ * Add {@link LUNORA_IGNORED_PATHS} to each tool's configuration.
817
+ *
818
+ * Idempotent: every writer appends only what is missing, so re-running after a
819
+ * `lunora add` neither duplicates entries nor disturbs a project's own rules.
820
+ * @param projectRoot The project to configure.
821
+ * @param tools Which tools to configure — normally {@link detectLintTools}'s result, or the user's selection at `init`.
822
+ * @returns one outcome per tool, in the order given.
823
+ */
824
+ declare const applyLintIgnores: (projectRoot: string, tools: ReadonlyArray<LintTool>) => LintIgnoreOutcome[];
825
+ /** The slice of one wrangler environment (or the top level) the env is assembled from. */
826
+ interface WorkerEnvScope {
827
+ secrets?: {
828
+ required?: unknown;
829
+ } | null;
830
+ vars?: Record<string, unknown> | null;
831
+ }
832
+ interface LocalWorkerEnvOptions {
833
+ /** The parsed wrangler config, or `undefined` when the project has none. */
834
+ config: (WorkerEnvScope & {
835
+ env?: Record<string, WorkerEnvScope | null | undefined> | null;
836
+ }) | undefined;
837
+ /** Where the wrangler config lives; wrangler reads `.dev.vars` and `.env` beside it. */
838
+ configPath: string | undefined;
839
+ /** The wrangler environment (`--env` / `CLOUDFLARE_ENV`), when one is active. */
840
+ environment?: string;
841
+ /** Defaults to `process.env`. */
842
+ processEnv?: Record<string, string | undefined>;
843
+ /** Where to look when there is no wrangler config. */
844
+ projectRoot: string;
845
+ /** `--var` values the worker is started with: applied last, over `.dev.vars` / `.env`, as wrangler applies its input bindings. */
846
+ vars?: Readonly<Record<string, string>>;
847
+ }
848
+ interface LocalWorkerEnv {
849
+ env: Record<string, unknown>;
850
+ /** What contributed, in order (`wrangler vars`, `.dev.vars`, `.env`, `process.env`, …), for a log line. */
851
+ sources: string[];
852
+ }
853
+ /** Assemble the local dev worker's env; see the module comment. Throws where wrangler would refuse to start. */
854
+ declare const resolveLocalWorkerEnv: (options: LocalWorkerEnvOptions) => LocalWorkerEnv;
855
+ /** The three channels a bundler plugin reports through; `console` satisfies it, as does Rspack's `Logger`. */
856
+ interface FindingLogger {
857
+ error: (message: string) => void;
858
+ warn: (message: string) => void;
859
+ }
860
+ /**
861
+ * Print every schema advisory and platform-portability diagnostic a codegen run
862
+ * produced, each on its own level-appropriate channel.
863
+ *
864
+ * Codegen returns these without printing — each caller presents them through its
865
+ * own channel. Both bundler plugins present them identically, so this is that one
866
+ * presentation: severity → logger method, rendered by {@link advisoryLine}. It
867
+ * lives here rather than in either plugin because the loops were copied verbatim
868
+ * between them, and a copy is how `vite build` and `rspack build` start
869
+ * disagreeing about what a schema problem looks like.
870
+ *
871
+ * Reporting only — {@link blockingFindingsMessage} decides what BLOCKS.
872
+ */
873
+ declare const reportCodegenFindings: (result: Pick<CodegenResult, "advisories" | "platformDiagnostics">, logger: FindingLogger) => void;
874
+ /**
875
+ * The one aggregated line a bundler plugin fails a production build with, or
876
+ * `undefined` when nothing is ERROR-level.
877
+ *
878
+ * An ERROR advisory says a call throws at runtime; an `error` platform
879
+ * diagnostic says the emitted surface does not match the declared target. Both
880
+ * are wrong output, not style, so `vite build` / `rspack build` / `lunora deploy`
881
+ * all refuse them.
882
+ *
883
+ * The filter+dedup+sort behind it stays in `@lunora/codegen` (shared with the CLI
884
+ * gates); only the wording and the fold of the two categories live here, which is
885
+ * presentation — and presentation is what this module owns, which is also why
886
+ * this needs no `tag` parameter: {@link LUNORA_TAG} is right above it.
887
+ */
888
+ declare const blockingFindingsMessage: (result: Pick<CodegenResult, "advisories" | "platformDiagnostics">, options?: {
889
+ strictAdvisories?: boolean;
890
+ }) => string | undefined;
491
891
  /** Severity a formatted line should be surfaced at, mapped onto the three logger channels. */
492
892
  type LunoraLineLevel = "error" | "info" | "warn";
493
893
  /** A formatted lunora event: the channel to surface it on, the display text, and which event produced it. */
@@ -502,45 +902,12 @@ interface LunoraFormattedLine {
502
902
  /** Stable `source` tag every lunora console event carries. Mirrors `REQUEST_LOG_EVENT_SOURCE` in `@lunora/do`. */
503
903
  declare const LUNORA_EVENT_SOURCE = "lunora";
504
904
  /**
505
- * Parse a single worker-output line and, when it is a lunora structured event,
506
- * return its severity plus display text. Returns `undefined` for anything else —
507
- * non-JSON lines, JSON that isn't a lunora event, or an unrecognised event type
508
- * — so the caller passes the original line through untouched. Pure and total.
509
- */
905
+ * Parse a single worker-output line and, when it is a lunora structured event,
906
+ * return its severity plus display text. Returns `undefined` for anything else —
907
+ * non-JSON lines, JSON that isn't a lunora event, or an unrecognised event type
908
+ * — so the caller passes the original line through untouched. Pure and total.
909
+ */
510
910
  declare const formatLunoraEvent: (line: string) => LunoraFormattedLine | undefined;
511
- declare class LunoraReporter {
512
- #private;
513
- setStdout(stdout: NodeJS.WriteStream): void;
514
- setStderr(stderr: NodeJS.WriteStream): void;
515
- log(meta: unknown): void;
516
- }
517
- /**
518
- * Per-package secret-requirements registry for `.dev.vars` scaffolding.
519
- *
520
- * Each entry maps a `@lunora/*` package name → the secrets it requires at
521
- * runtime, expressed as `{ key, description, docsUrl }` records. The scaffolder
522
- * in {@link ./scaffold-dev-variables} reads this registry to emit package-aware
523
- * `.dev.vars.example` entries (placeholders + inline doc-pointer comments).
524
- *
525
- * ## Adding a new add-on
526
- *
527
- * When a new `@lunora/*` package requires runtime secrets, add one entry to
528
- * {@link PACKAGE_SECRETS_REGISTRY} keyed by its exact npm package name. Each
529
- * `SecretEntry` in the array needs:
530
- *
531
- * - `key` — the env-var name the package reads from `env` (e.g. `RESEND_API_KEY`).
532
- * - `description` — one line describing the secret and how to obtain it.
533
- * - `docsUrl` — a stable URL to the package/provider docs.
534
- *
535
- * The registry lives in `@lunora/config` so that add-ons themselves never need
536
- * to depend on it (no circular coupling). Add-ons document their secrets in
537
- * their own READMEs; the registry duplicates that knowledge in a machine-readable
538
- * form that the scaffolder can consume.
539
- *
540
- * **Never write a real secret value** in this file — `placeholderValue` entries
541
- * are the only allowed values (they must pass `isPlaceholderValue` from
542
- * scaffold-dev-variables).
543
- */
544
911
  /** A single secret variable required by a package. */
545
912
  interface SecretEntry {
546
913
  /** One sentence describing what this secret is and how to obtain it. */
@@ -550,96 +917,186 @@ interface SecretEntry {
550
917
  /** The env-var key as it appears in `.dev.vars`, e.g. `AUTH_SECRET`. */
551
918
  key: string;
552
919
  /**
553
- * The placeholder value written into `.dev.vars.example`.
554
- * Must pass `isPlaceholderValue` from scaffold-dev-variables so the
555
- * scaffolder regenerates it when generating `.dev.vars`. Use angle-bracket
556
- * conventions or a recognised marker like `replace-with-openssl-rand-hex-32`.
557
- * Non-secret env-vars (e.g. `AUTH_URL`) may carry a real default value.
558
- */
920
+ * The placeholder value written into `.dev.vars.example`.
921
+ * Must pass `isPlaceholderValue` from scaffold-dev-variables so the
922
+ * scaffolder regenerates it when generating `.dev.vars`. Use angle-bracket
923
+ * conventions or a recognised marker like `replace-with-openssl-rand-hex-32`.
924
+ * Non-secret env-vars (e.g. `AUTH_URL`) may carry a real default value.
925
+ */
559
926
  placeholderValue: string;
560
927
  }
561
928
  /**
562
- * Secrets every Lunora project needs regardless of which capability packages are
563
- * installed — scaffolded into `.dev.vars` always. `LUNORA_ADMIN_TOKEN` is the
564
- * bearer the local Studio uses to call the worker's admin endpoints (the data
565
- * browser, schema edits) in dev; the worker reads the SAME `.dev.vars` value via
566
- * its admin gate, so both agree and the Studio authenticates without a prompt.
567
- * Without it, every `/_lunora/admin/*` call is `ADMIN_FORBIDDEN` (403).
568
- */
569
-
570
- /**
571
- * The canonical registry of per-package secret requirements.
572
- *
573
- * Keys are exact npm package names (e.g. `"@lunora/auth"`). Values are
574
- * non-empty arrays of {@link SecretEntry} — one entry per required secret key.
575
- *
576
- * The scaffolder in `scaffold-dev-variables.ts` calls
577
- * {@link secretsForPackages} to resolve the applicable entries from this map
578
- * given the set of detected capability package names.
579
- */
929
+ * The canonical registry of per-package secret requirements.
930
+ *
931
+ * Keys are exact npm package names (e.g. `"@lunora/auth"`). Values are
932
+ * non-empty arrays of {@link SecretEntry} — one entry per required secret key.
933
+ *
934
+ * The scaffolder in `scaffold-dev-variables.ts` calls
935
+ * {@link secretsForPackages} to resolve the applicable entries from this map
936
+ * given the set of detected capability package names.
937
+ */
580
938
  declare const PACKAGE_SECRETS_REGISTRY: Readonly<Record<string, ReadonlyArray<SecretEntry>>>;
581
939
  /**
582
- * Collect all secret entries required by the given set of package names. The
583
- * order follows the order of `packageNames` (stable, predictable output), and
584
- * within each package the entries are returned in registry declaration order.
585
- *
586
- * Only packages present in {@link PACKAGE_SECRETS_REGISTRY} contribute entries;
587
- * unknown package names are silently ignored — this makes the call site resilient
588
- * to future capability flags whose packages have no secrets.
589
- */
940
+ * The keys a project may mint, given its secret sources. The relay key is withheld only from a project that just constructs
941
+ * `EventLogDOClient`: that worker must take its host's value, so a fresh one would only be refused. Every other project mints it,
942
+ * including one with no relay source at all, where a generated value is never read and so does no harm.
943
+ */
944
+ declare const mintableSecretKeysFor: (packageNames: ReadonlyArray<string>) => ReadonlySet<string>;
590
945
  declare const secretsForPackages: (packageNames: ReadonlyArray<string>) => SecretEntry[];
591
- /** The canonical project-config filename probed at the project root. */
592
- declare const LUNORA_CONFIG_FILE = "lunora.json";
593
- /**
594
- * The parsed `remote` preference from `lunora.json`:
595
- *
596
- * - `true` / `false` — the boolean form: enable or explicitly disable remote dev.
597
- * - `undefined` — no usable preference (file absent, key absent, or malformed).
598
- *
599
- * The object form (scoping which binding kinds go remote) is reserved for a
600
- * future increment; for now an object value is treated as "enabled" (truthy
601
- * presence) so forward-written configs still turn remote on.
602
- */
603
- type RemotePreference = boolean | undefined;
604
- /** The structural slice of `lunora.json` Lunora reads. */
605
- interface LunoraProjectConfig {
606
- remote?: unknown;
946
+ /**
947
+ * The two channels this needs from a caller's logger. Deliberately structural
948
+ * and this small: the CLI's `Logger`, Vite's `server.config.logger` shim, and a
949
+ * two-line test double all satisfy it without any of them being imported here.
950
+ */
951
+ interface HookLogger {
952
+ error: (message: string) => void;
953
+ info: (message: string) => void;
954
+ }
955
+ /** What a spawner is handed. A superset-accepting spawner (the CLI's) satisfies this. */
956
+ interface HookSpawnDescriptor {
957
+ args: ReadonlyArray<string>;
958
+ command: string;
959
+ cwd?: string;
960
+ /**
961
+ * Route the child's stdout to the parent's stderr (fd 2). Set whenever the
962
+ * caller's own stdout is a machine-readable stream — `--format json`, or
963
+ * `lunora dev`'s NDJSON — since a `postcodegen` script that prints anything
964
+ * would otherwise interleave with and corrupt it.
965
+ */
966
+ stdoutToStderr?: boolean;
607
967
  }
968
+ /** Run a child process and resolve with its exit code. Injectable so tests need no subprocess. */
969
+ type HookSpawner = (descriptor: HookSpawnDescriptor) => Promise<{
970
+ code: number;
971
+ }>;
972
+ interface PostCodegenHookResult {
973
+ /**
974
+ * The hook's failure message, when it ran and did not succeed.
975
+ *
976
+ * Already logged by the time a caller sees it — read it only to decide
977
+ * whether to ABORT, and to carry into a structured result. Logging it again
978
+ * double-reports.
979
+ */
980
+ error?: string;
981
+ /** True when a `postcodegen` script existed and was invoked. */
982
+ ran: boolean;
983
+ }
984
+ /**
985
+ * Run the project's `postcodegen` script, if it declares one.
986
+ *
987
+ * A failure is reported here and returned rather than thrown, so every caller
988
+ * gets identical reporting and is left with only the decision that actually
989
+ * differs between them: whether it blocks. `deploy` and `prepare` must abort —
990
+ * the whole point is not shipping output the project considers unfinished —
991
+ * while a dev watch loop must not, since the next edit is the chance to fix it.
992
+ *
993
+ * Reporting used to be the caller's job, and all three copied the same
994
+ * `logger.error(result.error)` line. That made "was this surfaced?" a convention
995
+ * rather than a guarantee, and a fourth caller had no way to know it owed one.
996
+ * @returns whether the hook ran, and its (already-logged) error message when it failed.
997
+ */
998
+ declare const runPostCodegenHook: (options: {
999
+ cwd: string;
1000
+ logger: HookLogger;
1001
+ spawner?: HookSpawner;
1002
+ /** See {@link HookSpawnDescriptor.stdoutToStderr}. */
1003
+ stdoutToStderr?: boolean;
1004
+ }) => Promise<PostCodegenHookResult>;
1005
+ /**
1006
+ * The parsed `remote` preference from `lunora.config.*`:
1007
+ *
1008
+ * - `true` / `false` — the boolean form: enable or explicitly disable remote dev.
1009
+ * - `undefined` — no usable preference (file absent, key absent, or malformed).
1010
+ *
1011
+ * The object form (scoping which binding kinds go remote) is reserved for a
1012
+ * future increment; for now an object value is treated as "enabled" (truthy
1013
+ * presence) so forward-written configs still turn remote on.
1014
+ */
1015
+ type RemotePreference = boolean | undefined;
608
1016
  /**
609
- * Interpret a raw `remote` value into a tri-state preference. A boolean passes
610
- * through; an object is treated as enabled (the documented-but-not-yet-honored
611
- * scoping form is still an opt-in); anything else (string, number, null) is no
612
- * preference.
613
- */
1017
+ * Interpret a raw `remote` value into a tri-state preference. A boolean passes
1018
+ * through; an object is treated as enabled (the documented-but-not-yet-honored
1019
+ * scoping form is still an opt-in); anything else (string, number, null) is no
1020
+ * preference.
1021
+ */
614
1022
  declare const interpretRemote: (value: unknown) => RemotePreference;
615
1023
  /**
616
- * Read the project's `remote` preference from `lunora.json`, or `undefined` when
617
- * there's no usable preference. Best-effort: never throws — a missing file,
618
- * parse error, or unexpected shape all collapse to `undefined` so the caller
619
- * falls through to the env/flag layers.
620
- */
1024
+ * Read the project's `remote` preference, or `undefined` when there is no
1025
+ * usable one — the caller then falls through to the env/flag layers.
1026
+ */
621
1027
  declare const readProjectRemotePreference: (projectRoot: string) => RemotePreference;
622
1028
  /**
623
- * Whether we can interactively prompt — stdin must be a TTY. In CI / piped
624
- * contexts this is false, and callers should fall back to a non-interactive
625
- * default (skip, or require an explicit `--yes`) rather than hang on a read.
626
- */
1029
+ * Read the project's deploy `target` from `lunora.config.*`, or `undefined` when
1030
+ * absent.
1031
+ *
1032
+ * Delegates to `@lunora/codegen` rather than re-reading the file here.
1033
+ * `runCodegen` has to resolve the same key without this package (config
1034
+ * depends on codegen, not the reverse), so the parser lives there and this is a
1035
+ * re-export — two readers of one key is exactly the kind of copy that drifts.
1036
+ */
1037
+ declare const readProjectTarget: (projectRoot: string) => string | undefined;
1038
+ /**
1039
+ * Resolve the deploy target for a command: an explicit `--target` wins, then
1040
+ * `lunora.config.*`, then the registry default.
1041
+ *
1042
+ * **This is the canonical resolution point, and the reason it is one place.**
1043
+ * Codegen tailors the emitted `ctx.*` surface to a target while deploy picks
1044
+ * the driver that ships it. Resolve those separately and they can disagree,
1045
+ * producing an app that builds cleanly and fails at runtime with nothing in the
1046
+ * build to explain it. Every caller — CLI commands, the Vite plugin,
1047
+ * `runCodegen`'s own fallback — resolves through here or through
1048
+ * {@link resolveTargetOrThrow}, so there is exactly one precedence order to
1049
+ * reason about.
1050
+ */
1051
+ declare const resolveProjectTarget: (projectRoot: string, explicit?: string) => string;
1052
+ /**
1053
+ * Resolve the deploy target as {@link resolveProjectTarget} does, then reject
1054
+ * one that no registered driver serves.
1055
+ *
1056
+ * Lives here rather than in `@lunora/cli` because nothing about it is
1057
+ * CLI-shaped and the Vite plugin needs the same guard — a validator only the
1058
+ * CLI could reach left `vite build` emitting the default surface for a
1059
+ * mis-declared target, silently.
1060
+ *
1061
+ * Callers that go on to resolve a driver get this for free; the ones that never
1062
+ * look a driver up — codegen, the Vite plugin — need it, because otherwise
1063
+ * nothing in their path ever rejects the name.
1064
+ * @param projectRoot Directory containing `lunora.config.*`.
1065
+ * @param explicit A caller-supplied target, if any.
1066
+ * @throws when the resolved target names no registered driver.
1067
+ * @returns the resolved, registered target id.
1068
+ */
1069
+ declare const resolveTargetOrThrow: (projectRoot: string, explicit?: string) => string;
1070
+ /**
1071
+ * Refuse a plugin-resolved target that differs from the one the CLI resolved
1072
+ * for this run. The CLI's `--target` guard only sees the config file, so a target set
1073
+ * in a plugin's options would otherwise slip past it. A no-op outside a CLI build,
1074
+ * where {@link BUILD_TARGET_ENV} is unset.
1075
+ * @param target The target the plugin resolved.
1076
+ * @throws when the CLI resolved a different target.
1077
+ */
1078
+ declare const assertBuildTargetMatches: (target: string, projectRoot: string) => void;
1079
+ /**
1080
+ * Whether we can interactively prompt — stdin must be a TTY. In CI / piped
1081
+ * contexts this is false, and callers should fall back to a non-interactive
1082
+ * default (skip, or require an explicit `--yes`) rather than hang on a read.
1083
+ */
627
1084
  declare const isInteractive: () => boolean;
628
1085
  /**
629
- * Ask a yes/no question on stdin. With `defaultYes`, an empty answer (just
630
- * Enter) counts as yes and the prompt should read `[Y/n]`; otherwise empty is
631
- * no (`[y/N]`). Shared by the CLI (`reset`, `dev`) and the Vite dev server.
632
- */
1086
+ * Ask a yes/no question on stdin. With `defaultYes`, an empty answer (just
1087
+ * Enter) counts as yes and the prompt should read `[Y/n]`; otherwise empty is
1088
+ * no (`[y/N]`). Shared by the CLI (`reset`, `dev`) and the Vite dev server.
1089
+ */
633
1090
  declare const promptYesNo: (prompt: string, options?: {
634
1091
  defaultYes?: boolean;
635
1092
  }) => Promise<boolean>;
636
1093
  /**
637
- * Build a default-yes `confirm(message)` for the scaffolders' `ensureDevVariables`:
638
- * an interactive `[Y/n]` prompt (optionally prefixed, e.g. `"[lunora] "`) when
639
- * stdin is a TTY, or an immediate `false` otherwise — so CI declines silently
640
- * instead of blocking. Keeps the "non-interactive ⇒ decline" policy in one place
641
- * rather than re-stated at every call site.
642
- */
1094
+ * Build a default-yes `confirm(message)` for the scaffolders' `ensureDevVariables`:
1095
+ * an interactive `[Y/n]` prompt (optionally prefixed, e.g. `"[lunora] "`) when
1096
+ * stdin is a TTY, or an immediate `false` otherwise — so CI declines silently
1097
+ * instead of blocking. Keeps the "non-interactive ⇒ decline" policy in one place
1098
+ * rather than re-stated at every call site.
1099
+ */
643
1100
  declare const createConfirm: (prefix?: string) => ((message: string) => Promise<boolean>);
644
1101
  /** One choice in a {@link promptSelect} list. `value` is returned; `label` (and optional `description`) are shown. */
645
1102
  interface SelectOption<T extends string> {
@@ -648,272 +1105,87 @@ interface SelectOption<T extends string> {
648
1105
  value: T;
649
1106
  }
650
1107
  /**
651
- * Ask the user to pick one option from a numbered list on stdin. Accepts the
652
- * 1-based number or the option's `value`/`label` typed verbatim; an empty answer
653
- * (just Enter) takes `settings.default`. In a non-interactive context (CI /
654
- * piped — no TTY) it never reads and returns `settings.default` (or `undefined`),
655
- * mirroring {@link createConfirm}'s "non-interactive ⇒ fall back" policy so
656
- * automation never blocks.
657
- */
1108
+ * Ask the user to pick one option from a numbered list on stdin. Accepts the
1109
+ * 1-based number or the option's `value`/`label` typed verbatim; an empty answer
1110
+ * (just Enter) takes `settings.default`. In a non-interactive context (CI /
1111
+ * piped — no TTY) it never reads and returns `settings.default` (or `undefined`),
1112
+ * mirroring {@link createConfirm}'s "non-interactive ⇒ fall back" policy so
1113
+ * automation never blocks.
1114
+ */
658
1115
  declare const promptSelect: <T extends string>(message: string, options: ReadonlyArray<SelectOption<T>>, settings?: {
659
1116
  default?: T;
660
1117
  }) => Promise<T | undefined>;
1118
+ /**
1119
+ * Ask a free-text question on stdin, returning the trimmed answer. An empty
1120
+ * answer (just Enter) takes `settings.default`. In a non-interactive context
1121
+ * (CI / piped — no TTY) it never reads and returns `settings.default` (or
1122
+ * `undefined`), mirroring {@link promptSelect}'s "non-interactive ⇒ fall back"
1123
+ * policy so automation never blocks.
1124
+ */
1125
+ declare const promptText: (message: string, settings?: {
1126
+ default?: string;
1127
+ }) => Promise<string | undefined>;
661
1128
  /** One choice in a {@link promptMultiSelect} list. Identical shape to {@link SelectOption}; `value` is returned when picked. */
662
1129
  type MultiSelectOption<T extends string> = SelectOption<T>;
663
1130
  /**
664
- * Ask the user to pick zero or more options from a numbered list on stdin.
665
- * Accepts a comma- or space-separated list of 1-based numbers and/or option
666
- * `value`/`label`s typed verbatim; an empty answer (just Enter) takes
667
- * `settings.defaults`. In a non-interactive context (CI / piped — no TTY) it
668
- * never reads and returns `settings.defaults ?? []`, mirroring {@link promptSelect}'s
669
- * "non-interactive ⇒ fall back" policy so automation never blocks. Unknown
670
- * tokens are ignored; the returned list is de-duplicated and preserves option
671
- * order.
672
- */
1131
+ * Ask the user to pick zero or more options from a numbered list on stdin.
1132
+ * Accepts a comma- or space-separated list of 1-based numbers and/or option
1133
+ * `value`/`label`s typed verbatim; an empty answer (just Enter) takes
1134
+ * `settings.defaults`. In a non-interactive context (CI / piped — no TTY) it
1135
+ * never reads and returns `settings.defaults ?? []`, mirroring {@link promptSelect}'s
1136
+ * "non-interactive ⇒ fall back" policy so automation never blocks. Unknown
1137
+ * tokens are ignored; the returned list is de-duplicated and preserves option
1138
+ * order.
1139
+ */
673
1140
  declare const promptMultiSelect: <T extends string>(message: string, options: ReadonlyArray<MultiSelectOption<T>>, settings?: {
674
1141
  defaults?: ReadonlyArray<T>;
675
1142
  }) => Promise<T[]>;
676
1143
  /**
677
- * A container/workflow that is declared (so codegen emits its class) but the
678
- * worker entry never re-exports — the one wiring step the generators can't always
679
- * do for the developer. wrangler rejects a `class_name` the deployed worker
680
- * doesn't export, so a deploy fails late on this; surfacing it as structured data
681
- * lets the Vite plugin raise it in the dev error overlay (not just the console)
682
- * the moment the gap appears. The human-readable form is also folded into
683
- * {@link ReconcileBindingsResult.warnings}.
684
- */
685
- interface ExportGap {
686
- /** Generated class wrangler needs exported, e.g. `OrderPipelineWorkflow`. */
687
- className: string;
688
- /** The `lunora/{containers,workflows}.ts` export name, e.g. `orderPipeline`. */
689
- exportName: string;
690
- /** Which declaration is unexported. */
691
- kind: "container" | "workflow";
692
- /** The `_generated/{module}` to re-export from, e.g. `workflows`. */
693
- module: "containers" | "workflows";
694
- }
695
- interface ReconcileBindingsResult {
696
- /** Short labels for each binding written (e.g. `"SCHEDULER/SchedulerDO"`). */
697
- added: string[];
698
- /** `true` when `wrangler.jsonc` was rewritten. */
699
- changed: boolean;
700
- /**
701
- * Declared containers/workflows the worker entry doesn't re-export — the
702
- * structured form of the corresponding `warnings` entries, for the dev error
703
- * overlay. Empty when every declaration is wired.
704
- */
705
- exportGaps: ExportGap[];
706
- /** Reason reconciliation was skipped, for logging. */
707
- reason?: string;
708
- /** Non-fatal hints for capabilities that cannot be auto-provisioned. */
709
- warnings: string[];
710
- /** Resolved wrangler path, or `undefined` when none was found. */
711
- wranglerPath?: string;
712
- }
713
- /**
714
- * Reconcile inferred Durable Object / D1 bindings into `wrangler.jsonc`.
715
- *
716
- * Writes only when something is missing; returns `changed: false` when the
717
- * config already satisfies the inferred needs.
718
- */
719
- declare const reconcileWranglerBindings: (projectRoot: string, inferred: InferredBindings) => ReconcileBindingsResult;
720
- /**
721
- * The wrangler config sections Lunora can safely flip to remote mode in dev,
722
- * each with the human label used in logs and the structural `shape` the entry
723
- * lives in.
724
- *
725
- * `"array"` is a top-level array of binding objects (`d1_databases`,
726
- * `kv_namespaces`, `r2_buckets`, `vectorize`, `services`). `"producers"` is
727
- * `queues.producers[]` — consumers are NOT remoted (their schema has no `remote`
728
- * field) and the edit path is two levels deep. `"object"` is a single binding
729
- * object, not an array (`ai`), whose edit path targets the section key directly.
730
- *
731
- * Every kind here was confirmed against `wrangler/config-schema.json`: the
732
- * entry's schema declares a `remote` property. Deliberately omits
733
- * `durable_objects` (no CF remote-DO mode; shards stay local) and sections whose
734
- * schema has no `remote` field (`hyperdrive`, `analytics_engine_datasets`,
735
- * `secrets_store_secrets`, queue consumers, …). Widening further is a one-line
736
- * table edit.
737
- */
738
- declare const REMOTE_ELIGIBLE_KEYS: {
739
- readonly ai: {
740
- readonly label: "AI";
741
- readonly shape: "object";
742
- };
743
- readonly d1_databases: {
744
- readonly label: "D1";
745
- readonly shape: "array";
746
- };
747
- readonly kv_namespaces: {
748
- readonly label: "KV";
749
- readonly shape: "array";
750
- };
751
- readonly queues: {
752
- readonly label: "Queue";
753
- readonly shape: "producers";
754
- };
755
- readonly r2_buckets: {
756
- readonly label: "R2";
757
- readonly shape: "array";
758
- };
759
- readonly services: {
760
- readonly label: "Service";
761
- readonly shape: "array";
762
- };
763
- readonly vectorize: {
764
- readonly label: "Vectorize";
765
- readonly shape: "array";
766
- };
767
- };
768
- type RemoteEligibleKey = keyof typeof REMOTE_ELIGIBLE_KEYS;
769
- /** One binding object as it appears in any eligible section. */
770
- interface BindingEntry {
771
- binding?: string;
772
- remote?: boolean;
773
- }
774
- /** One binding entry we mark remote, with enough provenance to log + edit it. */
775
- interface RemoteBindingPlan {
776
- /** The binding name as declared in the config (e.g. `"DB"`, `"FILES"`). */
777
- binding: string;
778
- /** Short kind label for logging (`"D1"`, `"KV"`, `"R2"`, `"Vectorize"`, …). */
779
- kind: string;
780
- /**
781
- * The jsonc edit path within {@link RemoteBindingPlan.section}, relative to
782
- * the section key: `[index]` for an `"array"` section, `["producers", index]`
783
- * for a queue producer, or `[]` for the single-object `ai` section. The
784
- * materializer prepends the section key and appends `"remote"`.
785
- */
786
- path: ReadonlyArray<number | string>;
787
- /** The wrangler config key the entry lives under. */
788
- section: RemoteEligibleKey;
789
- }
790
- /** The structural slice of a wrangler config the remote planner reads. */
791
- interface RemoteWranglerShape {
792
- ai?: BindingEntry | null;
793
- d1_databases?: ReadonlyArray<BindingEntry | null | undefined>;
794
- kv_namespaces?: ReadonlyArray<BindingEntry | null | undefined>;
795
- queues?: {
796
- producers?: ReadonlyArray<BindingEntry | null | undefined>;
797
- } | null;
798
- r2_buckets?: ReadonlyArray<BindingEntry | null | undefined>;
799
- services?: ReadonlyArray<BindingEntry | null | undefined>;
800
- vectorize?: ReadonlyArray<BindingEntry | null | undefined>;
801
- }
802
- /**
803
- * Inspect a parsed wrangler config and list every eligible binding that should
804
- * be flipped to remote mode. Pure — no file-system access, no mutation. An
805
- * entry already carrying `"remote": true` is still reported (so logging is
806
- * complete) but the materializer's edit is a harmless no-op for it.
807
- */
808
- declare const planRemoteBindings: (parsed: RemoteWranglerShape) => RemoteBindingPlan[];
809
- /**
810
- * Inject `"remote": true` onto each planned binding in the config `text`,
811
- * comment-preservingly via jsonc edits. Pure string→string; the edits target
812
- * disjoint entries so applying them sequentially is safe. The edit path is
813
- * `[section, ...plan.path, "remote"]`, which resolves to the array element, the
814
- * `queues.producers[i]` entry, or the single `ai` object as the plan demands.
815
- */
816
- declare const injectRemoteFlags: (text: string, plans: ReadonlyArray<RemoteBindingPlan>) => string;
817
- interface MaterializeOptions {
818
- /** When `false`, the call is a no-op (returns `enabled: false`). */
819
- enabled: boolean;
820
- projectRoot: string;
821
- }
822
- interface MaterializeResult {
823
- /**
824
- * Removes the generated temp config file. Always present and always safe to
825
- * call: it is idempotent, a no-op when nothing was written (disabled /
826
- * fall-through cases), and never throws if the path is already gone. The dev
827
- * command calls this on every exit path (normal, signal, error).
828
- */
829
- cleanup: () => void;
830
- /**
831
- * Absolute path to the generated temp config to pass to
832
- * `wrangler dev --config`. `undefined` when remote mode is disabled, no
833
- * wrangler config was found, it failed to parse, or it declared no eligible
834
- * binding (nothing to remote — run plain local dev).
835
- */
836
- configPath?: string;
837
- /** Whether remote mode was requested at all. */
838
- enabled: boolean;
839
- /** Why no temp config was produced, for logging (only set when none was). */
840
- reason?: string;
841
- /** The bindings flipped to remote, for the dev banner. */
842
- remoteBindings: RemoteBindingPlan[];
843
- }
844
- /**
845
- * Produce a temporary wrangler config with `"remote": true` on every eligible
846
- * binding, so `lunora dev` can run `wrangler dev --config &lt;temp>` against the
847
- * deployed D1/KV/R2 without touching the user's file.
848
- *
849
- * The temp file is written as a sibling of the source `wrangler.jsonc` (in the
850
- * project root), NOT an OS temp dir: wrangler resolves a config's relative paths
851
- * (`main`, `assets`, `migrations_dir`, …) against the **config file's own
852
- * directory**, so a temp config in `/tmp` would make wrangler look for
853
- * `/tmp/src/server.ts` and fail to start the worker. Keeping it beside the real
854
- * config preserves those relative paths. Returns `configPath: undefined` (with a
855
- * `reason`) for every fall-through case so the caller degrades to plain local
856
- * dev instead of failing.
857
- */
858
- declare const materializeRemoteWranglerConfig: (options: MaterializeOptions) => MaterializeResult;
859
- /**
860
- * Parse a `LUNORA_REMOTE` env value into the on/off decision. Truthy when set to
861
- * `"1"` or `"true"` (case-insensitive); anything else — unset, `"0"`, `"false"`,
862
- * empty — is off. Mirrors the `"1" | "true"` convention used across the runtime.
863
- */
864
- declare const isRemoteEnvEnabled: (value: string | undefined) => boolean;
865
- /** The three inputs that can switch remote-binding dev on, in precedence order. */
866
- interface RemoteEnableInputs {
867
- /**
868
- * The `remote` preference from `lunora.json` (the lowest-priority signal).
869
- * `undefined` means "no project preference"; an explicit `false` here loses
870
- * to neither the flag nor the env when those are absent — it just stays off.
871
- */
872
- configPreference?: boolean;
873
- /** The raw `LUNORA_REMOTE` env value (parsed with {@link isRemoteEnvEnabled}). */
874
- envValue?: string;
875
- /** The explicit `--remote` CLI flag — `true` when passed, `undefined`/`false` otherwise. */
876
- flag?: boolean;
877
- }
878
- /**
879
- * Resolve whether remote-binding dev is on, with a clear precedence:
880
- *
881
- * 1. an explicit `--remote` flag (highest — a deliberate per-invocation choice),
882
- * 2. then `LUNORA_REMOTE` in the environment,
883
- * 3. then the `remote` key in `lunora.json` (lowest — a project default).
884
- *
885
- * The flag and env are one-directional (they can only turn remote *on*); only
886
- * the config preference carries a meaningful `false`, and it applies solely when
887
- * neither stronger signal is present. So a project that sets `"remote": false`
888
- * is still overridable per-run by `--remote` or `LUNORA_REMOTE=1`.
889
- */
890
- declare const resolveRemoteEnabled: (inputs: RemoteEnableInputs) => boolean;
1144
+ * The project's Lunora source directory (the plugin's `schemaDir`), read the way
1145
+ * `@lunora/vite` sees it: the `schemaDir` string literal passed to the `lunora()`
1146
+ * call in `vite.config.*`, else `"lunora"`. The CLI commands that scan the
1147
+ * project (`dev`, `deploy`, `doctor`, `env`, `codegen`) resolve it here, so a
1148
+ * project that moved its functions to `backend/` gets its `ctx.*` reads and
1149
+ * schema facts read from `backend/` instead of from a directory that does not
1150
+ * exist.
1151
+ *
1152
+ * Parsed, never evaluated: a CLI command must not run the project's build
1153
+ * config. A computed `schemaDir`, or a plugin reached any other way, is not seen
1154
+ * and falls back to the default — the same answer as before this was read.
1155
+ */
1156
+ declare const resolveSchemaDirectory: (projectRoot: string) => string;
891
1157
  /** Core (always-scaffolded) secrets followed by the package-specific ones for the detected capabilities. */
892
1158
  declare const requiredSecrets: (packageNames: ReadonlyArray<string>) => SecretEntry[];
893
1159
  /**
894
- * Whether an (already-unquoted) value looks like a fill-me-in placeholder —
895
- * empty, angle-bracketed, or containing a known marker — rather than a real
896
- * value. Used both when scaffolding (which values to regenerate) and by
897
- * `lunora env doctor` (which set values are still unfilled).
898
- */
1160
+ * Whether an (already-unquoted) value looks like a fill-me-in placeholder —
1161
+ * empty, angle-bracketed, or containing a known marker — rather than a real
1162
+ * value. Used both when scaffolding (which values to regenerate) and by
1163
+ * `lunora env doctor` (which set values are still unfilled).
1164
+ */
899
1165
  declare const isPlaceholderValue: (value: string) => boolean;
900
1166
  /**
901
- * True for a secret-looking key whose value Lunora can mint locally (a random
902
- * 32-byte hex, like `openssl rand -hex 32`) — e.g. `AUTH_SECRET`,
903
- * `LUNORA_ADMIN_TOKEN`, `STORAGE_SIGNING_SECRET`. False for provider-issued keys
904
- * ({@link PROVIDER_SECRET_KEYS}) and any non-secret key.
905
- */
906
- declare const isMintableSecretKey: (key: string) => boolean;
1167
+ * True for a secret key the registry says Lunora can mint locally (a random
1168
+ * 32-byte hex, like `openssl rand -hex 32`) — `AUTH_SECRET`,
1169
+ * `LUNORA_ADMIN_TOKEN`, `STORAGE_SIGNING_SECRET`, …
1170
+ *
1171
+ * Registry membership, NOT the key's name shape, is the rule. A secret-looking
1172
+ * key nothing in the registry declares (`OPENAI_API_KEY`,
1173
+ * `GITHUB_CLIENT_SECRET`, a project's own `*_TOKEN`) is provider-issued as far
1174
+ * as Lunora knows, so minting for it would write a value the provider rejects at
1175
+ * runtime — over the developer's own half-filled `.dev.vars` — and hide the gap
1176
+ * from `lunora env doctor`, whose job is to report it as unfilled.
1177
+ */
1178
+ declare const isMintableSecretKey: (key: string, value: string, mintable?: ReadonlySet<string>) => boolean;
907
1179
  /** Mint a fresh strong secret value — 64 hex chars (32 bytes), like `openssl rand -hex 32`. */
908
1180
  declare const generateSecretValue: (randomHex?: (bytes: number) => string) => string;
909
1181
  /**
910
- * The outcome of planning a scaffold — a discriminated union so the orchestrator
911
- * never has to re-derive whether `content` is present.
912
- *
913
- * `exists`: `.dev.vars` is already there; nothing to do.
914
- * `no-example`: nothing to scaffold from (stay silent — the project may not use secrets).
915
- * `generate`: write `content`, a copy of the example with secret-looking placeholders replaced by fresh random hex (`generatedKeys` lists which).
916
- */
1182
+ * The outcome of planning a scaffold — a discriminated union so the orchestrator
1183
+ * never has to re-derive whether `content` is present.
1184
+ *
1185
+ * `exists`: `.dev.vars` is already there; nothing to do.
1186
+ * `no-example`: nothing to scaffold from (stay silent — the project may not use secrets).
1187
+ * `generate`: write `content`, a copy of the example with secret-looking placeholders replaced by fresh random hex (`generatedKeys` lists which).
1188
+ */
917
1189
  type ScaffoldPlan = {
918
1190
  content: string;
919
1191
  generatedKeys: string[];
@@ -926,7 +1198,8 @@ type ScaffoldPlan = {
926
1198
  /** Decide whether (and what) to scaffold. Pure — given the current state of the two files. */
927
1199
  declare const planDevVariablesScaffold: (input: {
928
1200
  devVarsExists: boolean;
929
- exampleContent: string | undefined; /** Injectable for deterministic tests; defaults to `crypto.randomBytes`. */
1201
+ exampleContent: string | undefined;
1202
+ /** Injectable for deterministic tests; defaults to `crypto.randomBytes`. */
930
1203
  randomHex?: (bytes: number) => string;
931
1204
  }) => ScaffoldPlan;
932
1205
  interface AugmentPlan {
@@ -938,32 +1211,35 @@ interface AugmentPlan {
938
1211
  missingKeys: string[];
939
1212
  }
940
1213
  /**
941
- * Plan how to top up an existing `.dev.vars` from the example: every example key
942
- * not already present becomes an appended line (secret placeholders filled with
943
- * fresh random hex, other values copied). Pure — no I/O. Empty `missingKeys`
944
- * means the file is already complete.
945
- */
1214
+ * Plan how to top up an existing `.dev.vars` from the example: every example key
1215
+ * not already present becomes an appended line (secret placeholders filled with
1216
+ * fresh random hex, other values copied). Pure — no I/O. Empty `missingKeys`
1217
+ * means the file is already complete.
1218
+ */
946
1219
  declare const planDevVariablesAugment: (input: {
947
1220
  exampleContent: string;
948
- existingContent: string; /** Injectable for deterministic tests; defaults to `crypto.randomBytes`. */
1221
+ existingContent: string;
1222
+ /** Injectable for deterministic tests; defaults to `crypto.randomBytes`. */
949
1223
  randomHex?: (bytes: number) => string;
950
1224
  }) => AugmentPlan;
951
1225
  interface EnsureDevVariablesDeps {
952
1226
  /**
953
- * Ask the user to confirm generating the file. Return `true` to generate.
954
- * Consumers pass a TTY-aware prompt; in non-interactive contexts they should
955
- * resolve `false` (we then report `"declined"` and the caller can hint).
956
- */
1227
+ * Ask the user to confirm generating the file. Return `true` to generate.
1228
+ * Consumers pass a TTY-aware prompt; in non-interactive contexts they should
1229
+ * resolve `false` (we then report `"declined"` and the caller can hint).
1230
+ */
957
1231
  confirm: (message: string) => Promise<boolean>;
958
1232
  cwd: string;
959
1233
  /** Emit a human-facing line (success / hint). */
960
1234
  info: (message: string) => void;
961
1235
  /** Injectable for tests; defaults to `crypto.randomBytes` hex. */
962
1236
  randomHex?: (bytes: number) => string;
1237
+ /** Emit a warning; defaults to {@link EnsureDevVariablesDeps.info}. */
1238
+ warn?: (message: string) => void;
963
1239
  /** Generate without prompting (e.g. a `--yes` flag). */
964
1240
  yes?: boolean;
965
1241
  }
966
- type EnsureDevVariablesStatus = "augmented" | "declined" | "exists" | "generated" | "no-example" | "skipped-exists";
1242
+ type EnsureDevVariablesStatus = "augmented" | "declined" | "exists" | "generated" | "no-example" | "skipped-exists" | "unreadable";
967
1243
  interface EnsureDevVariablesResult {
968
1244
  /** Keys appended to an existing file, when `status` is `"augmented"`. */
969
1245
  addedKeys: string[];
@@ -972,41 +1248,53 @@ interface EnsureDevVariablesResult {
972
1248
  status: EnsureDevVariablesStatus;
973
1249
  }
974
1250
  /**
975
- * Reconcile the project's `.dev.vars` with its `.dev.vars.example`:
976
- *
977
- * - file missing → offer to generate it (secret placeholders auto-filled);
978
- * - file present but missing keys the example lists → offer to append them;
979
- * - file present and complete → nothing to do.
980
- *
981
- * Prompts via `confirm` (skipped when `yes`); never overwrites existing values.
982
- * Returns what happened so the caller can tailor any follow-up. Shared by
983
- * `lunora dev` and the `@lunora/vite` dev server. All side effects funnel
984
- * through `confirm`/`info`/`randomHex`.
985
- */
1251
+ * Atomically (over)write a `.dev.vars`-shaped file, owner-only. For a file
1252
+ * holding secrets a torn write would destroy every other local value alongside
1253
+ * the new one, and the new value itself has no other recoverable copy if it
1254
+ * was never disclosed anywhere else (Cloudflare secrets are write-only).
1255
+ * Exported so a caller writing to a `.dev.vars`-shaped path outside this
1256
+ * module (`lunora deploy`'s minted-secret disclosure) reuses this instead of
1257
+ * hand-rolling another copy of the pattern.
1258
+ */
1259
+ declare const writeDevVariablesFileAtomically: (path: string, content: string) => void;
1260
+ /**
1261
+ * Reconcile the project's `.dev.vars` with its `.dev.vars.example`:
1262
+ *
1263
+ * - file missing → offer to generate it (secret placeholders auto-filled);
1264
+ * - file present but missing keys the example lists → offer to append them;
1265
+ * - file present and complete → nothing to do;
1266
+ * - either one not a readable file (a directory, no permission) → one warning,
1267
+ * status `"unreadable"`, nothing written.
1268
+ *
1269
+ * Prompts via `confirm` (skipped when `yes`); never overwrites existing values.
1270
+ * Returns what happened so the caller can tailor any follow-up. Shared by
1271
+ * `lunora dev` and the `@lunora/vite` dev server. All side effects funnel
1272
+ * through `confirm`/`info`/`randomHex`.
1273
+ */
986
1274
  declare const ensureDevVariables: (deps: EnsureDevVariablesDeps) => Promise<EnsureDevVariablesResult>;
987
1275
  /**
988
- * Build the text that should be merged into `.dev.vars.example` for the given
989
- * set of package names. Only entries whose key is not already present in
990
- * `existingKeys` are included (additive / idempotent). Returns an empty string
991
- * when there is nothing to add.
992
- *
993
- * The output is grouped by package with a blank-line separator so the file
994
- * reads cleanly when multiple packages each contribute several keys.
995
- *
996
- * **Safety invariant:** this function never writes a real secret — every value
997
- * in the output is the entry's `placeholderValue`.
998
- */
1276
+ * Build the text that should be merged into `.dev.vars.example` for the given
1277
+ * set of package names. Only entries whose key is not already present in
1278
+ * `existingKeys` are included (additive / idempotent). Returns an empty string
1279
+ * when there is nothing to add.
1280
+ *
1281
+ * The output is grouped by package with a blank-line separator so the file
1282
+ * reads cleanly when multiple packages each contribute several keys.
1283
+ *
1284
+ * **Safety invariant:** this function never writes a real secret — every value
1285
+ * in the output is the entry's `placeholderValue`.
1286
+ */
999
1287
  declare const buildPackageSecretsBlock: (packageNames: ReadonlyArray<string>, existingKeys: ReadonlySet<string>) => string;
1000
1288
  /**
1001
- * Write (or update) `.dev.vars.example` so that it contains the secrets
1002
- * required by `packageNames`. Existing lines are never removed or rewritten;
1003
- * new entries are appended (with a blank-line separator after existing content).
1004
- *
1005
- * Idempotent: re-running with the same `packageNames` does not duplicate keys
1006
- * already in the file. Returns the list of keys that were actually appended.
1007
- *
1008
- * **Safety invariant:** only placeholder values are written — no real secrets.
1009
- */
1289
+ * Write (or update) `.dev.vars.example` so that it contains the secrets
1290
+ * required by `packageNames`. Existing lines are never removed or rewritten;
1291
+ * new entries are appended (with a blank-line separator after existing content).
1292
+ *
1293
+ * Idempotent: re-running with the same `packageNames` does not duplicate keys
1294
+ * already in the file. Returns the list of keys that were actually appended.
1295
+ *
1296
+ * **Safety invariant:** only placeholder values are written — no real secrets.
1297
+ */
1010
1298
  declare const ensureDevVariablesExample: (cwd: string, packageNames: ReadonlyArray<string>) => string[];
1011
1299
  interface DevSecretsFillPlan {
1012
1300
  /** {@link CORE_SECRETS} keys appended because they were absent (each generated). */
@@ -1017,21 +1305,24 @@ interface DevSecretsFillPlan {
1017
1305
  filledKeys: string[];
1018
1306
  }
1019
1307
  /**
1020
- * Plan the in-place generation of dev secrets for a `.dev.vars`. First, every
1021
- * line whose KEY looks like a secret (`*_SECRET`, `*_TOKEN`, `*_KEY`,
1022
- * `*_PASSWORD`) and whose value is empty or a placeholder gets a freshly
1023
- * generated value — so a `lunora add`-scaffolded `.dev.vars` (which writes each
1024
- * secret blank) becomes usable on `lunora dev` / `vite dev` without the user
1025
- * running `openssl` by hand. Second, any {@link CORE_SECRETS} key absent from
1026
- * the file is appended (generated) — notably `LUNORA_ADMIN_TOKEN`, which the
1027
- * local Studio needs to call the worker's admin gate in dev (without it the
1028
- * Studio shows its login gate).
1029
- *
1030
- * Pure (given `randomHex`): real (non-placeholder) values are never touched, and
1031
- * comments + non-secret entries are preserved verbatim.
1032
- */
1308
+ * Plan the in-place generation of dev secrets for a `.dev.vars`. First, every
1309
+ * line whose key is {@link isMintableSecretKey mintable} — registry membership,
1310
+ * NOT the key's name shape — and whose value is empty or a placeholder gets a
1311
+ * freshly generated value, so a `lunora add`-scaffolded `.dev.vars` (which
1312
+ * writes each secret blank) becomes usable on `lunora dev` / `vite dev` without
1313
+ * the user running `openssl` by hand. A provider-issued key (`OPENAI_API_KEY`,
1314
+ * `STRIPE_SECRET_KEY`) is left verbatim so `lunora env doctor` can still report
1315
+ * it as unfilled. Second, any {@link CORE_SECRETS} key absent from
1316
+ * the file is appended (generated) — notably `LUNORA_ADMIN_TOKEN`, which the
1317
+ * local Studio needs to call the worker's admin gate in dev (without it the
1318
+ * Studio shows its login gate).
1319
+ *
1320
+ * Pure (given `randomHex`): real (non-placeholder) values are never touched, and
1321
+ * comments + non-secret entries are preserved verbatim.
1322
+ */
1033
1323
  declare const planDevSecretsFill: (input: {
1034
1324
  existingContent: string;
1325
+ mintable?: ReadonlySet<string>;
1035
1326
  randomHex?: (bytes: number) => string;
1036
1327
  }) => DevSecretsFillPlan;
1037
1328
  interface FillDevSecretsResult {
@@ -1043,25 +1334,43 @@ interface FillDevSecretsResult {
1043
1334
  status: "created" | "filled" | "unchanged";
1044
1335
  }
1045
1336
  /**
1046
- * Generate any missing/empty dev secrets in the project's `.dev.vars`, in place.
1047
- *
1048
- * Complements {@link ensureDevVariables} (which scaffolds `.dev.vars` from
1049
- * `.dev.vars.example`). A `lunora add`-scaffolded project writes secrets blank
1050
- * straight into `.dev.vars` (no example) and never includes `LUNORA_ADMIN_TOKEN`
1051
- * — so the worker boots with empty secrets and the Studio shows its login gate.
1052
- * This fills those gaps at dev startup, so both `lunora dev` and the
1053
- * `@lunora/vite` dev server give a working project with zero manual `openssl`.
1054
- *
1055
- * Never overwrites a real (non-placeholder) value. The write is atomic + owner-
1056
- * only (temp + rename, `mode: 0o600`), matching the other `.dev.vars` writers.
1057
- */
1337
+ * Generate any missing/empty dev secrets in the project's `.dev.vars`, in place.
1338
+ *
1339
+ * Complements {@link ensureDevVariables} (which scaffolds `.dev.vars` from
1340
+ * `.dev.vars.example`). A `lunora add`-scaffolded project writes secrets blank
1341
+ * straight into `.dev.vars` (no example) and never includes `LUNORA_ADMIN_TOKEN`
1342
+ * — so the worker boots with empty secrets and the Studio shows its login gate.
1343
+ * This fills those gaps at dev startup, so both `lunora dev` and the
1344
+ * `@lunora/vite` dev server give a working project with zero manual `openssl`.
1345
+ *
1346
+ * Never overwrites a real (non-placeholder) value. Two writers, on purpose: when
1347
+ * the file does not exist yet, the create goes through {@link createExclusively}
1348
+ * and loses to a peer that creates it first; when it exists, the fill rewrites
1349
+ * it through {@link atomicWrite} (temp + rename, owner-only) with the keys it
1350
+ * just read and planned against.
1351
+ */
1058
1352
  declare const fillDevSecrets: (deps: {
1059
1353
  cwd: string;
1060
1354
  info?: (message: string) => void;
1061
1355
  randomHex?: (bytes: number) => string;
1356
+ /**
1357
+ * The project's secret sources (`secretSourcesFromBindings`). They narrow what is minted to the keys its role needs. Omit them to mint
1358
+ * every registry key.
1359
+ */
1360
+ secretSources?: ReadonlyArray<string>;
1062
1361
  }) => FillDevSecretsResult;
1362
+ /** Storage backends `.global()` accepts. A closed union, so it is never free text. */
1363
+ type GlobalBackend = "d1" | "hyperdrive";
1063
1364
  /** Add a new table to `defineSchema({ ... })`. */
1064
1365
  interface AddTableEdit {
1366
+ /**
1367
+ * Mark the table `.global()`. Pass `{}` for the D1 default, or a backend for
1368
+ * an external store — `lunora introspect` uses `{ backend: "hyperdrive" }`
1369
+ * because the rows live in the database it read.
1370
+ */
1371
+ readonly global?: {
1372
+ readonly backend?: GlobalBackend;
1373
+ };
1065
1374
  readonly kind: "addTable";
1066
1375
  readonly table: string;
1067
1376
  }
@@ -1071,11 +1380,11 @@ interface AddOptionalColumnEdit {
1071
1380
  readonly kind: "addOptionalColumn";
1072
1381
  readonly table: string;
1073
1382
  /**
1074
- * Inner validator expression text WITHOUT the `v.optional(...)` wrapper, e.g.
1075
- * `v.string()`. Always wrapped in `v.optional(...)` on apply, because only
1076
- * optional columns are additive-safe (a required column needs a backfill
1077
- * migration).
1078
- */
1383
+ * Inner validator expression text WITHOUT the `v.optional(...)` wrapper, e.g.
1384
+ * `v.string()`. Always wrapped in `v.optional(...)` on apply, because only
1385
+ * optional columns are additive-safe (a required column needs a backfill
1386
+ * migration).
1387
+ */
1079
1388
  readonly validator: string;
1080
1389
  }
1081
1390
  /** Add a secondary index to an existing table. */
@@ -1089,9 +1398,9 @@ interface AddIndexEdit {
1089
1398
  /** Additive edits — the only requests {@link applyAdditiveEdit} applies. */
1090
1399
  type AdditiveEdit = AddIndexEdit | AddOptionalColumnEdit | AddTableEdit;
1091
1400
  /**
1092
- * Destructive edits — never applied directly; routed to the migration handoff
1093
- * (plan 024 Item 5). Carried as data so the editor can describe the request.
1094
- */
1401
+ * Destructive edits — never applied directly; routed to the migration handoff
1402
+ * (plan 024 Item 5). Carried as data so the editor can describe the request.
1403
+ */
1095
1404
  interface DestructiveEdit {
1096
1405
  readonly column?: string;
1097
1406
  readonly kind: "changeColumnType" | "dropColumn" | "dropTable" | "makeRequired" | "renameColumn";
@@ -1102,9 +1411,9 @@ interface DestructiveEdit {
1102
1411
  /** Any edit the editor can request. */
1103
1412
  type SchemaEdit = AdditiveEdit | DestructiveEdit;
1104
1413
  /**
1105
- * Classify an edit request. Additive edits ({@link AdditiveEdit}) apply
1106
- * directly; everything else changes stored data and is destructive.
1107
- */
1414
+ * Classify an edit request. Additive edits ({@link AdditiveEdit}) apply
1415
+ * directly; everything else changes stored data and is destructive.
1416
+ */
1108
1417
  declare const classifyEdit: (edit: SchemaEdit) => "additive" | "destructive";
1109
1418
  /** Failure reasons an additive edit can report. */
1110
1419
  type ApplyFailureReason = "aliased-define-schema" | "destructive" | "duplicate-column" | "duplicate-index" | "duplicate-table" | "invalid-identifier" | "invalid-validator" | "no-define-schema" | "non-object-argument" | "unknown-table";
@@ -1117,10 +1426,10 @@ type ApplyEditResult = {
1117
1426
  text: string;
1118
1427
  };
1119
1428
  /**
1120
- * Apply an **additive** edit to a schema source string, preserving formatting.
1121
- * Destructive edits are refused with `{ ok: false, reason: "destructive" }`;
1122
- * route them through the migration handoff (plan 024 Item 5).
1123
- */
1429
+ * Apply an **additive** edit to a schema source string, preserving formatting.
1430
+ * Destructive edits are refused with `{ ok: false, reason: "destructive" }`;
1431
+ * route them through the migration handoff (plan 024 Item 5).
1432
+ */
1124
1433
  declare const applyAdditiveEdit: (source: string, edit: SchemaEdit) => ApplyEditResult;
1125
1434
  /** A single declared column: its name and the raw validator expression text. */
1126
1435
  interface SchemaColumn {
@@ -1159,294 +1468,9 @@ type ParseSchemaResult = {
1159
1468
  tables: ReadonlyArray<SchemaTable>;
1160
1469
  };
1161
1470
  /**
1162
- * Every `CallExpression` at or below a node. `getDescendantsOfKind` excludes the
1163
- * node itself, but a table initializer often is the outermost call in the
1164
- * `defineTable(...).global().index(...)` chain, so include it explicitly.
1165
- */
1166
-
1167
- /**
1168
- * Parse the tables (with typed columns + indexes) out of a `lunora/schema.ts`
1169
- * source string. Returns a tagged result so callers can render a helpful
1170
- * message per failure mode without throwing.
1171
- */
1471
+ * Parse the tables (with typed columns + indexes) out of a `lunora/schema.ts`
1472
+ * source string. Returns a tagged result so callers can render a helpful
1473
+ * message per failure mode without throwing.
1474
+ */
1172
1475
  declare const parseSchema: (source: string) => ParseSchemaResult;
1173
- interface SchemaInfo {
1174
- /** Whether the lunora schema declares any `.global()` table. */
1175
- hasGlobalTable: boolean;
1176
- /** Names of vector indexes declared via `.vectorize()` / `defineVectorIndex()`. */
1177
- vectorIndexNames?: ReadonlyArray<string>;
1178
- }
1179
- interface DiscoverSchemaInfoResult {
1180
- /** Parse error message, when the schema exists but could not be analyzed. */
1181
- error?: string;
1182
- /** Schema facts, or `undefined` when no `schema.ts` exists or parsing failed. */
1183
- info: SchemaInfo | undefined;
1184
- }
1185
- /**
1186
- * Discover {@link SchemaInfo} for a project. Returns `{ info: undefined }` when
1187
- * the project declares no `schema.ts` (not an error), or `{ info: undefined,
1188
- * error }` when a present schema could not be parsed — callers decide whether a
1189
- * parse failure is a warning (validator) or simply ignorable (inference).
1190
- */
1191
- declare const discoverSchemaInfo: (projectRoot: string, schemaDirectory: string) => DiscoverSchemaInfoResult;
1192
- /**
1193
- * A badge: the short colored label that prefixes a line. `bg`/`fg` are hex so the
1194
- * same value drives both colorize's `bgHex().hex()` and the tui `&lt;Text>` props.
1195
- */
1196
- interface BadgeSpec {
1197
- bg: `#${string}`;
1198
- fg: `#${string}`;
1199
- text: string;
1200
- }
1201
- /** Lunora purple — the accent shared with the CLI prompt frames. */
1202
- declare const ACCENT: `#${string}`;
1203
- /** Standard log-level badge names (the restyled base output). */
1204
- type LevelBadgeName = "debug" | "error" | "info" | "success" | "warn";
1205
- /** Step-phase badge names (the create-astro-style flow transcript). */
1206
- type StepBadgeName = "add" | "deps" | "dir" | "git" | "lunora" | "next" | "tmpl";
1207
- type BadgeName = LevelBadgeName | StepBadgeName;
1208
- /** The ordered step-phase names, used to register custom pail log types. */
1209
- declare const STEP_BADGE_NAMES: ReadonlyArray<StepBadgeName>;
1210
- /**
1211
- * Every badge, keyed by name. Levels get their conventional colors (red/amber/
1212
- * green/blue/grey); step phases follow create-astro's green→purple→cyan rhythm.
1213
- */
1214
- declare const BADGES: Record<BadgeName, BadgeSpec>;
1215
- /**
1216
- * Luna, the mascot: the folklore rabbit-in-the-moon — a bunny tucked inside the
1217
- * moon disc. Pure ASCII so it renders the same everywhere (including piped logs).
1218
- * The CLI signs off the `init` flow with it, the way create-astro closes with
1219
- * Houston.
1220
- */
1221
- declare const LUNA_NAME = "Luna";
1222
- declare const LUNA_SIGNOFF = "Safe travels, voyager.";
1223
- declare const LUNA_BUNNY: string;
1224
- /**
1225
- * {@link LUNA_BUNNY} with its leading newline stripped, ready to render inline
1226
- * (beside the name + sign-off). Both render paths — the tui mascot frame and the
1227
- * pail off-TTY fallback — use this so neither re-implements the strip.
1228
- */
1229
- declare const LUNA_ART: string;
1230
- /** The colored part of a badge — the word with one space of padding each side. */
1231
- declare const padBadge: (text: string) => string;
1232
- /** Leading spaces that right-align a badge's box within the gutter. */
1233
- declare const badgeLead: (text: string) => string;
1234
- /** Total columns a rendered badge column occupies (lead + box), constant across badges. */
1235
- declare const BADGE_COLUMN_WIDTH: number;
1236
- /** Columns a rendered badge occupies — the gutter-aligned column width. */
1237
- declare const badgeWidth: (_spec: BadgeSpec) => number;
1238
- /** Paint a badge as an ANSI string (the non-tui path): right-aligning spaces + the colored box. */
1239
- declare const paintBadge: (spec: BadgeSpec) => string;
1240
- /** Dim continuation text (a step's chosen answer, shown under the question). */
1241
- declare const paintAnswer: (text: string) => string;
1242
- /** Candidate wrangler config filenames, in the order every consumer probes them. */
1243
- declare const WRANGLER_FILES: readonly ["wrangler.jsonc", "wrangler.json"];
1244
- /** Locate the project's wrangler config, or `undefined` when none exists. */
1245
- declare const findWranglerFile: (projectRoot: string) => string | undefined;
1246
- interface ReadWranglerResult<T> {
1247
- /** Parsed config, or `undefined` when the file was not valid JSONC. */
1248
- parsed: T | undefined;
1249
- /** Raw file text — needed for comment-preserving `modify`/`applyEdits`. */
1250
- text: string;
1251
- }
1252
- /**
1253
- * Read and JSONC-parse a wrangler config file. Returns the raw `text` (for
1254
- * structural edits) alongside `parsed`, which is `undefined` when the file is
1255
- * not valid JSONC or does not parse to an object. Allows trailing commas, as
1256
- * wrangler does.
1257
- */
1258
- declare const readWranglerJsonc: <T = unknown>(wranglerPath: string) => ReadWranglerResult<T>;
1259
- declare const REQUIRED_COMPATIBILITY_DATE: string;
1260
- declare const REQUIRED_FLAG: string;
1261
- interface WranglerDurableObjectBinding {
1262
- class_name?: string;
1263
- name?: string;
1264
- }
1265
- /**
1266
- * A `tail_consumers` entry: a Worker that receives this Worker's tail events
1267
- * (logs, exceptions, fetch metadata) for forwarding to an external sink. See
1268
- * `withTailConsumer` for the wiring helper.
1269
- */
1270
- interface TailConsumer {
1271
- /** Optional Cloudflare environment of the consumer Worker. */
1272
- environment?: string;
1273
- /** Name of the Worker that consumes tail events. */
1274
- service?: string;
1275
- }
1276
- /** A wrangler `containers[]` entry (parsed from untrusted JSONC). */
1277
- interface WranglerContainerEntry {
1278
- class_name?: string;
1279
- image?: string;
1280
- instance_type?: string | {
1281
- disk_mb?: number;
1282
- memory_mib?: number;
1283
- vcpu?: number;
1284
- };
1285
- max_instances?: number;
1286
- }
1287
- /**
1288
- * A wrangler `workflows[]` entry (parsed from untrusted JSONC). Unlike
1289
- * containers, workflows are NOT Durable Objects — the entry stands alone (no
1290
- * `durable_objects` binding, no migration class).
1291
- */
1292
- interface WranglerWorkflowEntry {
1293
- binding?: string;
1294
- class_name?: string;
1295
- name?: string;
1296
- }
1297
- /** A wrangler `queues.producers[]` entry — a `Queue` binding sending to `queue`. */
1298
- interface WranglerQueueProducer {
1299
- binding?: string;
1300
- delivery_delay?: number;
1301
- queue?: string;
1302
- }
1303
- /** A wrangler `queues.consumers[]` entry — push (worker) or `type: "http_pull"`. */
1304
- interface WranglerQueueConsumer {
1305
- dead_letter_queue?: string;
1306
- max_batch_size?: number;
1307
- max_batch_timeout?: number;
1308
- max_retries?: number;
1309
- queue?: string;
1310
- retry_delay?: number;
1311
- type?: string;
1312
- }
1313
- interface WranglerConfig {
1314
- analytics_engine_datasets?: ReadonlyArray<{
1315
- binding?: string;
1316
- dataset?: string;
1317
- } | null | undefined>;
1318
- assets?: {
1319
- binding?: string;
1320
- directory?: string;
1321
- html_handling?: string;
1322
- not_found_handling?: string;
1323
- };
1324
- browser?: {
1325
- binding?: string;
1326
- };
1327
- compatibility_date?: string;
1328
- compatibility_flags?: ReadonlyArray<string>;
1329
- containers?: ReadonlyArray<WranglerContainerEntry | null | undefined>;
1330
- d1_databases?: ReadonlyArray<{
1331
- binding?: string;
1332
- }>;
1333
- dispatch_namespaces?: ReadonlyArray<{
1334
- binding?: string;
1335
- namespace?: string;
1336
- outbound?: unknown;
1337
- } | null | undefined>;
1338
- durable_objects?: {
1339
- bindings?: ReadonlyArray<WranglerDurableObjectBinding>;
1340
- };
1341
- flagship?: ReadonlyArray<{
1342
- app_id?: string;
1343
- binding?: string;
1344
- } | null | undefined>;
1345
- hyperdrive?: ReadonlyArray<{
1346
- binding?: string;
1347
- id?: string;
1348
- localConnectionString?: string;
1349
- } | null | undefined>;
1350
- images?: {
1351
- binding?: string;
1352
- };
1353
- kv_namespaces?: ReadonlyArray<{
1354
- binding?: string;
1355
- id?: string;
1356
- } | null | undefined>;
1357
- logpush?: boolean;
1358
- migrations?: ReadonlyArray<{
1359
- new_classes?: ReadonlyArray<string>;
1360
- new_sqlite_classes?: ReadonlyArray<string>;
1361
- } | null | undefined>;
1362
- mtls_certificates?: ReadonlyArray<{
1363
- binding?: string;
1364
- certificate_id?: string;
1365
- } | null | undefined>;
1366
- observability?: {
1367
- enabled?: boolean;
1368
- head_sampling_rate?: number;
1369
- logs?: {
1370
- enabled?: boolean;
1371
- head_sampling_rate?: number;
1372
- };
1373
- };
1374
- pipelines?: ReadonlyArray<{
1375
- binding?: string;
1376
- pipeline?: string;
1377
- } | null | undefined>;
1378
- placement?: {
1379
- mode?: string;
1380
- };
1381
- queues?: {
1382
- consumers?: ReadonlyArray<WranglerQueueConsumer | null | undefined>;
1383
- producers?: ReadonlyArray<WranglerQueueProducer | null | undefined>;
1384
- };
1385
- r2_buckets?: ReadonlyArray<{
1386
- binding?: string;
1387
- }>;
1388
- secrets_store_secrets?: ReadonlyArray<{
1389
- binding?: string;
1390
- secret_name?: string;
1391
- store_id?: string;
1392
- } | null | undefined>;
1393
- send_email?: ReadonlyArray<{
1394
- allowed_destination_addresses?: ReadonlyArray<string>;
1395
- destination_address?: string;
1396
- name?: string;
1397
- } | null | undefined>;
1398
- services?: ReadonlyArray<{
1399
- binding?: string;
1400
- entrypoint?: string;
1401
- environment?: string;
1402
- service?: string;
1403
- } | null | undefined>;
1404
- tail_consumers?: ReadonlyArray<TailConsumer | null | undefined>;
1405
- vars?: Record<string, unknown>;
1406
- vectorize?: ReadonlyArray<{
1407
- binding?: string;
1408
- index_name?: string;
1409
- } | null | undefined>;
1410
- workflows?: ReadonlyArray<WranglerWorkflowEntry | null | undefined>;
1411
- }
1412
- interface WranglerValidationReport {
1413
- errors: string[];
1414
- valid: boolean;
1415
- warnings: string[];
1416
- }
1417
- /**
1418
- * Return a new `WranglerConfig` with `consumer` present in `tail_consumers`,
1419
- * wiring this Worker to forward its tail events (logs/exceptions) to another
1420
- * Worker that fans them out to an external sink. Pure and idempotent: an
1421
- * existing entry with the same `service` + `environment` is left untouched
1422
- * rather than duplicated, so it is safe to call on every codegen/deploy.
1423
- */
1424
- declare const withTailConsumer: (wrangler: WranglerConfig, consumer: TailConsumer) => WranglerConfig;
1425
- /**
1426
- * Pure validator: given a parsed `WranglerConfig` object and an optional
1427
- * `SchemaInfo`, produce a structured report. Performs no I/O.
1428
- */
1429
- declare const validateWranglerConfig: (wrangler: WranglerConfig | undefined, schema?: SchemaInfo) => WranglerValidationReport;
1430
- /**
1431
- * Convenience alias matching the original task-spec signature
1432
- * `validateWrangler(wranglerJson, schema)` returning
1433
- * `{ valid, errors, warnings }`.
1434
- */
1435
- declare const validateWrangler: typeof validateWranglerConfig;
1436
- interface WranglerProjectValidationOptions {
1437
- projectRoot: string;
1438
- schemaDir?: string;
1439
- }
1440
- interface WranglerProjectValidationResult {
1441
- problems: ReadonlyArray<string>;
1442
- report: WranglerValidationReport;
1443
- wranglerPath: string | undefined;
1444
- }
1445
- /**
1446
- * File-system aware variant: reads `wrangler.jsonc`/`wrangler.json` from
1447
- * the given project root, discovers the schema (if any), and delegates to
1448
- * `validateWranglerConfig`. Returns the legacy
1449
- * `{ problems, wranglerPath }` shape plus the structured `report`.
1450
- */
1451
- declare const validateWranglerProject: (options: WranglerProjectValidationOptions) => WranglerProjectValidationResult;
1452
- export { ACCENT, AGENT_MODE_ENV, AGENT_RULES_DIR, AGENT_RULES_HINT, AGENT_RULES_HINT_ENV, type AddIndexEdit, type AddOptionalColumnEdit, type AddTableEdit, type AdditiveEdit, type AgentDetection, type AgentRulesStatus, type ApplyEditResult, type ApplyFailureReason, type AugmentPlan, BADGES, BADGE_COLUMN_WIDTH, type BadgeName, type BadgeSpec, type ClaimDevServerStateResult, type ContainerLogLevel, type ContainerLogLine, type ContainerLogSource, type ContainerLogStreamHandle, type ContainerLogStreamOptions, DEV_DAEMON_ENV, DEV_HANDOFF_ENV, DEV_LOG_FILE, DEV_LOG_FILE_ENV, DEV_STATE_DIR, DEV_STATE_FILE, DEV_VARS_EXAMPLE_FILE, DEV_VARS_FILE, DEV_VARS_KEY_PATTERN, type DestructiveEdit, type DetectedFramework, type DevSecretsFillPlan, type DevServerMode, type DevServerState, type DiscoverContainerInfoResult, type DiscoverSchemaInfoResult, type DiscoverWorkflowInfoResult, type DockerLike, type EnsureDevVariablesDeps, type EnsureDevVariablesResult, type EnsureDevVariablesStatus, type ExportGap, type FillDevSecretsResult, type FrameworkClass, type FrameworkDetection, type InferOptions, type InferredBindings, type InferredContainer, type InferredWorkflow, LINKED_PROJECT_DIR, LINKED_PROJECT_FILE, LUNA_ART, LUNA_BUNNY, LUNA_NAME, LUNA_SIGNOFF, LUNORA_CONFIG_FILE, LUNORA_EVENT_SOURCE, LUNORA_SKILL_NAMES, type LevelBadgeName, type LinkedProject, type LunoraFormattedLine, type LunoraLineLevel, type LunoraProjectConfig, LunoraReporter, type MaterializeOptions, type MaterializeResult, type MultiSelectOption, PACKAGE_SECRETS_REGISTRY, type ParseSchemaResult, REMOTE_ELIGIBLE_KEYS, REQUIRED_COMPATIBILITY_DATE, REQUIRED_FLAG, ROOT_SKILL_NAME, type ReadWranglerResult, type ReconcileBindingsResult, type RemoteBindingPlan, type RemoteEnableInputs, type RemotePreference, type RemoteWranglerShape, STEP_BADGE_NAMES, type ScaffoldPlan, type SchemaColumn, type SchemaEdit, type SchemaIndex, type SchemaInfo, type SchemaTable, type SecretEntry, type SelectOption, type StepBadgeName, type TailConsumer, WRANGLER_FILES, type WranglerConfig, type WranglerContainerEntry, type WranglerProjectValidationOptions, type WranglerProjectValidationResult, type WranglerValidationReport, type WranglerWorkflowEntry, applyAdditiveEdit, badgeLead, badgeWidth, buildPackageSecretsBlock, claimAgentRulesHint, claimDevServerState, classifyEdit, clearDevServerState, createConfirm, detectAgentRules, detectAiAgent, detectFramework, discoverContainerInfo, discoverSchemaInfo, discoverWorkflowInfo, ensureDevVariables, ensureDevVariablesExample as ensureDevVarsExample, fillDevSecrets, findWranglerFile, formatLunoraEvent, generateSecretValue, inferLunoraBindings, injectRemoteFlags, interpretRemote, isInteractive, isMintableSecretKey, isPlaceholderValue, isProcessAlive, isRecordedProcessCurrent, isRemoteEnvEnabled, materializeRemoteWranglerConfig, packageNamesFromBindings, padBadge, paintAnswer, paintBadge, parseDevVariableEntries, parseSchema, planDevSecretsFill, planDevVariablesAugment, planDevVariablesScaffold, planRemoteBindings, promptMultiSelect, promptSelect, promptYesNo, readDevServerState, readLinkedProject, readLiveDevServerState, readProjectDependencyNames, readProjectRemotePreference, readWranglerJsonc, reconcileWranglerBindings, requiredSecrets, resolveRemoteEnabled, secretsForPackages, streamContainerLogs, updateDevServerState, validateWrangler, validateWranglerConfig, validateWranglerProject, withTailConsumer, writeDevServerState, writeLinkedProject };
1476
+ export { AGENT_MODE_ENV, type AddIndexEdit, type AddOptionalColumnEdit, type AddTableEdit, type AdditiveEdit, type AgentDetection, type ApplyEditResult, type ApplyFailureReason, type AugmentPlan, BUILD_ROOT_ENV, BUILD_TARGET_ENV, BUNDLE_META_PATH_ENV, CODEGEN_ENV, type CelldDevSession, type CelldDevSessionOptions, type CelldLineOrigin, type CelldToolchainProbe, type CelldToolchainProbeOptions, type ClaimDevServerStateResult, type ContainerLogLevel, type ContainerLogLine, type ContainerLogSource, type ContainerLogStreamHandle, type ContainerLogStreamOptions, DEFAULT_BUNDLE_META_PATH, DEV_BINDINGS_FILE, DEV_DAEMON_ENV, DEV_HANDOFF_ENV, DEV_LOG_FILE, DEV_LOG_FILE_ENV, DEV_STATE_DIR, DEV_STATE_FILE, DEV_VARS_EXAMPLE_FILE, DEV_VARS_FILE, DEV_VARS_KEY_PATTERN, DEV_WORKER_ENV_VALUE, DEV_WORKER_ENV_VAR, type DestructiveEdit, type DetectedFramework, type DevEnvCheck, type DevEnvCheckOptions, type DevProcess, type DevProcessOptions, type DevProcessSpawner, type DevSecretsFillPlan, type DevServerMode, type DevServerPhase, type DevServerState, type DevTriggerHint, type DevTriggerHintOptions, type DiscoverAgentInfoResult, type DiscoverContainerInfoResult, type DiscoverWorkflowInfoResult, type DiscoveryCache, type DockerLike, type EnsureDevVariablesDeps, type EnsureDevVariablesResult, type EnsureDevVariablesStatus, type EnvKeyFailure, type FillDevSecretsResult, type FindingLogger, type FrameworkClass, type FrameworkDetection, type HookLogger, type HookSpawnDescriptor, type HookSpawner, LAZY_FUNCTIONS_ENV, LINKED_PROJECT_DIR, LINKED_PROJECT_FILE, LUNORA_EVENT_SOURCE, LUNORA_IGNORED_PATHS, type LinkedProject, type LintIgnoreOutcome, type LintIgnoreStatus, type LintTool, type LocalWorkerEnv, type LocalWorkerEnvOptions, type LunoraFormattedLine, type LunoraLineLevel, type MarkedApiSpec, MissingBuildOutputError, type MultiSelectOption, PACKAGE_SECRETS_REGISTRY, type ParseSchemaResult, type PostCodegenHookResult, type RemotePreference, STRICT_ADVISORIES_ENV, type ScaffoldPlan, type SchemaColumn, type SchemaEdit, type SchemaIndex, type SchemaTable, type SecretEntry, type SelectOption, acceptsConnection, applyAdditiveEdit, applyLintIgnores, assertBuildTargetMatches, blockingFindingsMessage, buildPackageSecretsBlock, canonicalPath, checkDevEnv, claimDevServerState, classifyEdit, clearApiSpecMarker, clearDevServerState, createConfirm, describeDevEnvCheck, detectAiAgent, detectFramework, detectLintTools, devServerPhase, devTriggerHints, discoverAgentInfo, discoverContainerInfo, discoverWorkflowInfo, ensureDevVariables, ensureDevVariablesExample as ensureDevVarsExample, ensureDevWorkerEnv, ensureGitignoreEntries, escapeRegExp, fillDevSecrets, formatDevBannerRow, formatLunoraEvent, generateSecretValue, interpretRemote, isCodegenDisabled, isDevServerReady, isInteractive, isLazyFunctionsEnabled, isMintableSecretKey, isPlaceholderValue, isProcessAlive, isRecordedProcessCurrent, mintableSecretKeysFor, parseDevVariableEntries, parseSchema, planDevSecretsFill, planDevVariablesAugment, planDevVariablesScaffold, probeCelldToolchain, projectUsesUmbrella, promptMultiSelect, promptSelect, promptText, promptYesNo, readApiSpecMarker, readDevServerState, readDevVariablesRecord, readLinkedProject, readLiveDevServerState, readProjectRemotePreference, readProjectTarget, removeDevVariableLine, reportCodegenFindings, requiredSecrets, resolveLazyFunctions, resolveLocalWorkerEnv, resolveProjectTarget, resolveSchemaDirectory, resolveTargetOrThrow, runPostCodegenHook, secretsForPackages, startCelldDevSession, startDevProcess, streamContainerLogs, updateDevServerState, upsertDevVariableLine, wranglerDotenvFiles, writeApiSpecMarker, writeCelldDevProjection, writeDevServerState, writeDevVariablesFileAtomically, writeLinkedProject };