@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
@@ -1,50 +1,144 @@
1
- import { D as DestructivePolicyEdit, S as ScaffoldPolicyEdit, W as WireRlsEdit } from "../packem_shared/policy-scaffold.d-DCmwn7zQ.mjs";
2
1
  import { IncomingMessage, ServerResponse } from 'node:http';
3
- /** Parse a single `KEY=value` (optionally quoted) out of a `.dev.vars` body. */
2
+ import { CodegenOptions } from '@lunora/codegen';
3
+ import { D as DestructivePolicyEdit, S as ScaffoldPolicyEdit, W as WireRlsEdit } from "../packem_shared/policy-scaffold.d-D2H4_G01.mjs";
4
+ /**
5
+ * Parse a single `KEY=value` (optionally quoted) out of a `.dev.vars` body,
6
+ * returning `undefined` when the key is absent or its value is empty. A thin
7
+ * wrapper over {@link parseDevVariableEntries} — the single owner of the
8
+ * `.dev.vars` line grammar — so the key-validation, comment-skip, and quote-strip
9
+ * rules can't drift from every other reader/writer of the file.
10
+ */
4
11
  declare const parseDevVariable: (contents: string, key: string) => string | undefined;
5
12
  /**
6
- * Resolve the worker's admin token so the studio can auto-authenticate in
7
- * dev. Prefers the `LUNORA_ADMIN_TOKEN` env var, then the project's `.dev.vars`
8
- * — the same file `@cloudflare/vite-plugin` / `wrangler dev` feed the worker, so
9
- * the token the studio sends matches the one the worker's admin gate
10
- * verifies. Returns `undefined` when neither is set (the studio then prompts).
11
- */
13
+ * Resolve the worker's admin token so the studio can auto-authenticate in dev.
14
+ *
15
+ * The ONLY source is the project's `.dev.vars` — the file
16
+ * `@cloudflare/vite-plugin` / `wrangler dev` feed the local worker, and
17
+ * therefore the only token the worker's admin gate can verify. A shell-exported
18
+ * `LUNORA_ADMIN_TOKEN` (the documented way to run `lunora backup` /
19
+ * `lunora deploy --migrate` against **production**) never reaches the local
20
+ * worker's `env`, so embedding it would both fail the gate and put a production
21
+ * bearer into every `/__lunora` document served on the developer's machine.
22
+ * When the two disagree we say so once and keep using `.dev.vars`.
23
+ *
24
+ * Returns `undefined` when `.dev.vars` carries no token (the studio then prompts).
25
+ */
12
26
  declare const resolveAdminToken: (root: string) => string | undefined;
27
+ /**
28
+ * A cheap change stamp for the project's `.dev.vars` (`"0"` when absent), so a
29
+ * host that caches the Studio document can re-render it when the admin token is
30
+ * edited mid-session instead of embedding the one read at startup.
31
+ */
32
+ declare const devVariablesStamp: (root: string) => string;
33
+ /**
34
+ * The host's project configuration, forwarded verbatim to the handler. Separate
35
+ * from `projectRoot` (which every host has) because these two come from the
36
+ * host's own Lunora options.
37
+ */
38
+ interface LocalEndpointContext {
39
+ /** API-spec mode the host runs codegen with, so a studio edit regenerates the same spec files. */
40
+ readonly apiSpec?: CodegenOptions["apiSpec"];
41
+ /** Lazy function mode the host runs codegen with, so a studio edit preserves the generated registry. */
42
+ readonly lazyFunctions?: CodegenOptions["lazyFunctions"];
43
+ /** Override the lunora subdirectory name. Defaults to `"lunora"`. */
44
+ readonly schemaDirectory?: string;
45
+ }
46
+ /** A request adapted from a host transport, passed to a local-dev handler. */
47
+ interface LocalEndpointRequest extends LocalEndpointContext {
48
+ /** Parsed JSON body of the request (`undefined` for `GET` / an empty body). */
49
+ readonly body?: unknown;
50
+ /** HTTP method. */
51
+ readonly method: string;
52
+ /** Project root containing the `lunora/` directory. */
53
+ readonly projectRoot: string;
54
+ }
55
+ /** A response a local-dev handler returns, serialised back as JSON with its status. */
56
+ interface LocalEndpointResponse {
57
+ readonly body: unknown;
58
+ readonly status: number;
59
+ }
60
+ /** A transport-agnostic local-dev handler (schema edit, policy scaffold). */
61
+ type LocalEndpointHandler = (request: LocalEndpointRequest) => LocalEndpointResponse | Promise<LocalEndpointResponse>;
62
+ /**
63
+ * Adapt a `node:http` request/response pair to a transport-agnostic local-dev
64
+ * handler. `GET` carries no body (the schema editor uses it to read the parsed
65
+ * schema); every other method has its body read + JSON-parsed first. The
66
+ * handler's `{ status, body }` is serialised back as JSON. A malformed body is a
67
+ * `400`; an unexpected throw (e.g. the body-size guard) is a `500`.
68
+ *
69
+ * `context` carries the host's own Lunora options through to the handler: its
70
+ * `schemaDirectory` (so a custom `schemaDir` targets the right directory instead
71
+ * of defaulting to `"lunora"`) and its `apiSpec`, so a studio edit regenerates
72
+ * with the same options the host's own codegen run uses.
73
+ */
74
+ declare const serveJsonHandler: (request: IncomingMessage, response: ServerResponse, handle: LocalEndpointHandler, projectRoot: string, context?: LocalEndpointContext) => void;
75
+ /**
76
+ * Endpoint path both dev hosts mount the handler at. Sits under the double-underscore
77
+ * prefix, clear of the CLI's `/_lunora/*` worker proxy.
78
+ */
79
+ declare const ADVISOR_PROCEDURES_ENDPOINT = "/__lunora/advisor-procedures";
80
+ declare const handleAdvisorProceduresRequest: (request: LocalEndpointRequest) => Promise<LocalEndpointResponse>;
81
+ /**
82
+ * Send a studio static asset (the stylesheet, the `studio.js` entry, a chunk or
83
+ * a source map): cache headers and `304` via {@link applyStudioAssetCache}, then
84
+ * the body — brotli- or gzip-compressed when the client accepts it. Neither the
85
+ * Vite dev server nor `lunora dev` compresses on its own, so without this the
86
+ * studio's first load is the full raw bundle.
87
+ *
88
+ * `Vary: Accept-Encoding` is set on every answer, `304` included, so a cache
89
+ * never hands a compressed body to a client that didn't ask for one. The weak
90
+ * ETag is shared across encodings: a weak tag means "semantically equivalent",
91
+ * which a re-encoding is (the convention nginx follows too).
92
+ */
93
+ declare const sendStudioAsset: (request: IncomingMessage, response: ServerResponse, body: Buffer, contentType: string, fileName: string, stamp: number | undefined) => void;
94
+ /**
95
+ * Send the studio's SPA document. It embeds the admin token, so it is
96
+ * `no-store` — not merely revalidated — and carries no ETag: a cached `304` for
97
+ * a token-bearing document would be its own bug.
98
+ */
99
+ declare const sendStudioDocument: (response: ServerResponse, body: Buffer | string) => void;
13
100
  /** Config injected into the studio document before the bundle loads. */
14
101
  interface StudioHtmlConfig {
15
102
  /** Admin token sent with admin requests; omitted (and not injected) when unset. */
16
103
  readonly adminToken?: string;
104
+ /**
105
+ * The host mounts `/__lunora/advisor-procedures`, so the Advisors Health tab can
106
+ * score. Injected as `window.__LUNORA_ADVISOR_PROCEDURES__`. A separate flag from
107
+ * {@link StudioHtmlConfig.schemaEditable}: a host can serve the schema editor
108
+ * without this route, and the tab would then fetch a page that is not there.
109
+ */
110
+ readonly advisorProcedures?: boolean;
17
111
  /** Router basepath the studio mounts under (e.g. `/__lunora`, or `/` for a root server). */
18
112
  readonly basePath: string;
19
113
  /**
20
- * Make the data browser editable (insert/edit/delete rows). Injected as
21
- * `window.__LUNORA_DATA_EDITABLE__` for the bundle to read. The loopback-only
22
- * dev hosts (the Vite `/__lunora` route, the CLI studio server) set this so a
23
- * developer can edit; a static deploy leaves it off (read-only) by default.
24
- */
114
+ * Make the data browser editable (insert/edit/delete rows). Injected as
115
+ * `window.__LUNORA_DATA_EDITABLE__` for the bundle to read. The loopback-only
116
+ * dev hosts (the Vite `/__lunora` route, the CLI studio server) set this so a
117
+ * developer can edit; a static deploy leaves it off (read-only) by default.
118
+ */
25
119
  readonly dataEditable?: boolean;
26
120
  /**
27
- * Whether the project's Lunora agent skills ("rules") are installed. Injected
28
- * as `window.__LUNORA_RULES_INSTALLED__` **only when `false`**, so the studio
29
- * shows a "rules not installed" banner on the loopback dev hosts (which detect
30
- * it) and stays quiet on a static deploy (which leaves it unset).
31
- */
121
+ * Whether the project's Lunora agent skills ("rules") are installed. Injected
122
+ * as `window.__LUNORA_RULES_INSTALLED__` **only when `false`**, so the studio
123
+ * shows a "rules not installed" banner on the loopback dev hosts (which detect
124
+ * it) and stays quiet on a static deploy (which leaves it unset).
125
+ */
32
126
  readonly rulesInstalled?: boolean;
33
127
  /**
34
- * Enable the function runner's "Run as identity" tool (execute a function as a
35
- * chosen user to test auth/RLS). Injected as `window.__LUNORA_RUN_AS_IDENTITY__`.
36
- * Like {@link StudioHtmlConfig.dataEditable}, only the loopback-only dev hosts set
37
- * this — forging an identity is a developer-only affordance; a static deploy
38
- * leaves it off so the control never renders.
39
- */
128
+ * Enable the function runner's "Run as identity" tool (execute a function as a
129
+ * chosen user to test auth/RLS). Injected as `window.__LUNORA_RUN_AS_IDENTITY__`.
130
+ * Like {@link StudioHtmlConfig.dataEditable}, only the loopback-only dev hosts set
131
+ * this — forging an identity is a developer-only affordance; a static deploy
132
+ * leaves it off so the control never renders.
133
+ */
40
134
  readonly runAsIdentity?: boolean;
41
135
  /**
42
- * Enable the visual schema editor (add table / column / index, written back to
43
- * `lunora/schema.ts` + codegen). Injected as `window.__LUNORA_SCHEMA_EDITABLE__`.
44
- * Like {@link StudioHtmlConfig.dataEditable}, only the loopback-only dev hosts
45
- * set this — editing source + running codegen needs the project's filesystem and
46
- * toolchain, so a static deploy leaves it off and the diagram stays read-only.
47
- */
136
+ * Enable the visual schema editor (add table / column / index, written back to
137
+ * `lunora/schema.ts` + codegen). Injected as `window.__LUNORA_SCHEMA_EDITABLE__`.
138
+ * Like {@link StudioHtmlConfig.dataEditable}, only the loopback-only dev hosts
139
+ * set this — editing source + running codegen needs the project's filesystem and
140
+ * toolchain, so a static deploy leaves it off and the diagram stays read-only.
141
+ */
48
142
  readonly schemaEditable?: boolean;
49
143
  /** URL the studio bundle is served from (absolute, host-relative). */
50
144
  readonly scriptSrc: string;
@@ -61,62 +155,121 @@ interface StudioAssets {
61
155
  readonly styles: Buffer;
62
156
  }
63
157
  /**
64
- * Read the prebuilt static studio files shipped by `@lunora/studio`
65
- * (`dist/standalone/studio.js` + `dist/styles.css`). Returns `undefined` —
66
- * with a one-time warning — when the optional package isn't installed or hasn't
67
- * been built, so a missing studio never breaks the dev server.
68
- *
69
- * `resolveFrom` controls where `@lunora/studio` is resolved from. It defaults
70
- * to this module's own location, which is correct once this code is inlined into
71
- * a host package (`@lunora/vite` / `@lunora/cli`) that has `@lunora/studio`
72
- * installed — node walks up from the host's `dist` to find it.
73
- */
158
+ * Read the prebuilt static studio files shipped by `@lunora/studio`
159
+ * (`dist/standalone/studio.js` + `dist/styles.css`). Returns `undefined` —
160
+ * with a one-time warning — when the optional package isn't installed or hasn't
161
+ * been built, so a missing studio never breaks the dev server.
162
+ *
163
+ * `resolveFrom` controls where `@lunora/studio` is resolved from. It defaults
164
+ * to this module's own location, which is correct once this code is inlined into
165
+ * a host package (`@lunora/vite` / `@lunora/cli`) that has `@lunora/studio`
166
+ * installed — node walks up from the host's `dist` to find it.
167
+ */
74
168
  declare const loadStudioAssets: (logger?: WarnLogger, resolveFrom?: string) => StudioAssets | undefined;
75
169
  /**
76
- * A freshness stamp for the studio assets: the latest mtime (ms) of the resolved
77
- * `studio.js` / `styles.css`, or `undefined` when they can't be resolved. Hosts
78
- * cache {@link loadStudioAssets} for the dev session but compare this stamp per
79
- * request, so a `@lunora/studio` rebuild mid-session is picked up live — no dev
80
- * server restart needed.
81
- */
170
+ * A freshness stamp for the studio assets: the latest mtime (ms) of the resolved
171
+ * `studio.js` / `styles.css`, or `undefined` when they can't be resolved. Hosts
172
+ * cache {@link loadStudioAssets} for the dev session but compare this stamp per
173
+ * request, so a `@lunora/studio` rebuild mid-session is picked up live — no dev
174
+ * server restart needed.
175
+ */
82
176
  declare const studioAssetsStamp: (resolveFrom?: string) => number | undefined;
83
177
  /**
84
- * Absolute path of the built standalone directory — `@lunora/studio`'s
85
- * `dist/standalone`, where the `studio.js` entry and its code-split `chunk-*.js`
86
- * siblings live — or `undefined` when the studio isn't installed/built. The
87
- * standalone bundle is emitted with esbuild `splitting`, so the hosts must serve
88
- * the whole directory (not two fixed paths); this resolves its root.
89
- */
178
+ * Absolute path of the built standalone directory — `@lunora/studio`'s
179
+ * `dist/standalone`, where the `studio.js` entry and its code-split `chunk-*.js`
180
+ * siblings live — or `undefined` when the studio isn't installed/built. The
181
+ * standalone bundle is emitted with esbuild `splitting`, so the hosts must serve
182
+ * the whole directory (not two fixed paths); this resolves its root.
183
+ */
90
184
  declare const resolveStandaloneDirectory: (resolveFrom?: string) => string | undefined;
91
185
  /**
92
- * Read a single file from the standalone directory by its plain filename (the
93
- * `studio.js` entry, a `chunk-*.js`, or a `.map`). **Path-traversal-safe** via
94
- * {@link resolveContainedFile}: only a lone filename resolving to a direct child
95
- * of the standalone directory is served — any separator, `..`, NUL, or absolute
96
- * path is rejected — so a request like `../../etc/passwd` can never escape it.
97
- * Returns the bytes, or `undefined` when the studio isn't built or the name
98
- * doesn't resolve to a file inside the directory (the host answers that 404).
99
- */
186
+ * Read a single file from the standalone directory by its plain filename (the
187
+ * `studio.js` entry, a `chunk-*.js`, or a `.map`). **Path-traversal-safe** via
188
+ * {@link resolveContainedFile}: only a lone filename resolving to a direct child
189
+ * of the standalone directory is served — any separator, `..`, NUL, or absolute
190
+ * path is rejected — so a request like `../../etc/passwd` can never escape it.
191
+ * Returns the bytes, or `undefined` when the studio isn't built or the name
192
+ * doesn't resolve to a file inside the directory (the host answers that 404).
193
+ */
100
194
  declare const readStandaloneAsset: (fileName: string, resolveFrom?: string) => Buffer | undefined;
101
195
  /**
102
- * True when `pathname` addresses a standalone JS module — the `studio.js` entry
103
- * or one of its code-split `chunk-*.js` siblings (and their `.map`s). Shared by
104
- * the CLI and Vite hosts so both route the same request shapes to the directory
105
- * server; the stylesheet is matched separately at each host's own style path.
106
- */
196
+ * True when `pathname` addresses a standalone JS module — the `studio.js` entry
197
+ * or one of its code-split `chunk-*.js` siblings (and their `.map`s). Shared by
198
+ * the CLI and Vite hosts so both route the same request shapes to the directory
199
+ * server; the stylesheet is matched separately at each host's own style path.
200
+ */
107
201
  declare const isStandaloneModulePath: (pathname: string) => boolean;
108
202
  /**
109
- * Content-Type for a served standalone asset, by extension: `.css` → CSS,
110
- * `.map` → JSON (a source map), everything else (the `.js` entry + chunks) →
111
- * JavaScript. Shared by the CLI and Vite hosts so the MIME decision lives in one
112
- * place.
113
- */
203
+ * Content-Type for a served standalone asset, by extension: `.css` → CSS,
204
+ * `.map` → JSON (a source map), everything else (the `.js` entry + chunks) →
205
+ * JavaScript. Shared by the CLI and Vite hosts so the MIME decision lives in one
206
+ * place.
207
+ */
114
208
  declare const assetContentType: (fileName: string) => string;
115
209
  /**
116
- * Endpoint path both dev hosts mount the handler at. A sibling of the schema
117
- * editor's `/__lunora/schema-edit`; the double underscore keeps it clear of the
118
- * CLI's `/_lunora/*` worker proxy (single underscore).
119
- */
210
+ * Cache a studio host's rendered document, re-rendering it whenever `.dev.vars`
211
+ * under `root` changes. The document embeds the admin token, which is edited
212
+ * mid-session (rotation, the first `lunora dev` run writing it), so a document
213
+ * cached past such an edit would hand the studio a token the worker rejects.
214
+ *
215
+ * Every call costs one `stat` ({@link devVariablesStamp}); `render` runs on the
216
+ * first call and again only after the stamp moves. The stamp is taken before
217
+ * `render` reads the file, so a write landing between the two is seen as a
218
+ * change on the next call rather than cached under the newer stamp.
219
+ */
220
+ declare const createStudioDocumentCache: <T>(root: string, render: () => T) => (() => T);
221
+ /** Dev-server path the studio SPA is served from. */
222
+ declare const STUDIO_PATH = "/__lunora";
223
+ /** Static asset routes the studio document references. */
224
+ declare const STUDIO_SCRIPT_PATH: string;
225
+ declare const STUDIO_STYLE_PATH: string;
226
+ interface StudioMiddlewareOptions extends LocalEndpointContext {
227
+ /**
228
+ * The dev server's base path as configured (`"/"`, `"/app/"`). The studio's
229
+ * mount moves with it. Defaults to `"/"`.
230
+ */
231
+ base?: string;
232
+ /**
233
+ * The host's config binds beyond loopback — see {@link isNonLoopbackHost},
234
+ * which both bundler hosts derive this from. Refused outright, on top of the
235
+ * per-request transport check.
236
+ */
237
+ isNonLoopbackBind: boolean;
238
+ logger?: WarnLogger;
239
+ /** Directory holding `lunora/` and `.dev.vars`. */
240
+ projectRoot: string;
241
+ }
242
+ /**
243
+ * A dev server's CONFIGURED host asks to bind beyond loopback — `--host`
244
+ * (`true`), `0.0.0.0`, a LAN address. `undefined` means the host was never
245
+ * set, which is the bundler's default and not an intent to expose, whatever
246
+ * that default binds.
247
+ */
248
+ declare const isNonLoopbackHost: (host: unknown) => boolean;
249
+ /** Where the studio is mounted under a dev server's `base` — the path a startup banner announces. */
250
+ declare const studioMountPath: (base?: string) => string;
251
+ /**
252
+ * The pathname of a request's `url`, the way every studio host routes on it:
253
+ * query dropped, and dot segments resolved — so `/_lunora/../x` routes as the
254
+ * `/x` it will reach, not as a `/_lunora` path. A url `URL` cannot parse falls
255
+ * back to a plain query strip.
256
+ */
257
+ declare const requestPathname: (url: string) => string;
258
+ /**
259
+ * Connect-style middleware that serves the static studio at {@link STUDIO_PATH}.
260
+ * Both bundler dev servers mount it — Vite's `server.middlewares` and Rsbuild's
261
+ * — so the studio lives at the same URL whichever one runs the app.
262
+ *
263
+ * Caches the asset bytes but re-reads them when the built files change on disk
264
+ * (compared via {@link studioAssetsStamp}), so a `@lunora/studio` rebuild is
265
+ * picked up live without a dev server restart.
266
+ */
267
+ declare const createStudioMiddleware: (options: StudioMiddlewareOptions) => ((request: IncomingMessage, response: ServerResponse, next: () => void) => void);
268
+ /**
269
+ * Endpoint path both dev hosts mount the handler at. A sibling of the schema
270
+ * editor's `/__lunora/schema-edit`; the double underscore keeps it clear of the
271
+ * CLI's `/_lunora/*` worker proxy (single underscore).
272
+ */
120
273
  declare const POLICY_SCAFFOLD_ENDPOINT = "/__lunora/policy-scaffold";
121
274
  /** A `wireRls` request additionally carries the procedure's source-file path. */
122
275
  interface WirePolicyEdit extends WireRlsEdit {
@@ -127,8 +280,12 @@ interface WirePolicyEdit extends WireRlsEdit {
127
280
  type PolicyScaffoldBody = DestructivePolicyEdit | ScaffoldPolicyEdit | WirePolicyEdit;
128
281
  /** A request adapted from the host transport. */
129
282
  interface PolicyScaffoldRequest {
283
+ /** API-spec mode the host runs codegen with; forwarded to the regeneration. */
284
+ readonly apiSpec?: CodegenOptions["apiSpec"];
130
285
  /** Parsed JSON body of the `POST`. */
131
286
  readonly body?: unknown;
287
+ /** Lazy function mode the host runs codegen with; forwarded to the regeneration. */
288
+ readonly lazyFunctions?: CodegenOptions["lazyFunctions"];
132
289
  /** HTTP method — only `POST` is handled. */
133
290
  readonly method: string;
134
291
  /** Project root containing the `lunora/` directory. */
@@ -142,31 +299,35 @@ interface PolicyScaffoldResponse {
142
299
  readonly status: number;
143
300
  }
144
301
  /**
145
- * Handle a policy-scaffold request. Pure over its inputs apart from the file
146
- * I/O + codegen it performs on an applied edit; safe to unit-test against a
147
- * temp project directory.
148
- */
302
+ * Handle a policy-scaffold request. Pure over its inputs apart from the file
303
+ * I/O + codegen it performs on an applied edit; safe to unit-test against a
304
+ * temp project directory.
305
+ */
149
306
  declare const handlePolicyScaffoldRequest: (request: PolicyScaffoldRequest) => PolicyScaffoldResponse;
150
307
  /**
151
- * Render the single-page document that boots the studio. Emitted verbatim —
152
- * never through a bundler/transform — so the studio stays a static tool,
153
- * decoupled from the host project's build. A small inline script publishes the
154
- * per-server config on `globalThis` before the bundle loads: the mount basepath
155
- * (so the router stays under its mount), the admin token when present (so the
156
- * studio auto-authenticates instead of prompting), and an editable flag when the
157
- * host is a loopback dev server (so the data browser allows edits).
158
- */
308
+ * Render the single-page document that boots the studio. Emitted verbatim —
309
+ * never through a bundler/transform — so the studio stays a static tool,
310
+ * decoupled from the host project's build. A small inline script publishes the
311
+ * per-server config on `globalThis` before the bundle loads: the mount basepath
312
+ * (so the router stays under its mount), the admin token when present (so the
313
+ * studio auto-authenticates instead of prompting), and an editable flag when the
314
+ * host is a loopback dev server (so the data browser allows edits).
315
+ */
159
316
  declare const renderStudioHtml: (config: StudioHtmlConfig) => string;
160
317
  /**
161
- * Endpoint path both dev hosts mount the handler at. Distinct from the CLI's
162
- * `/_lunora/*` worker proxy (single underscore), so a schema edit is never
163
- * forwarded to the worker.
164
- */
318
+ * Endpoint path both dev hosts mount the handler at. Distinct from the CLI's
319
+ * `/_lunora/*` worker proxy (single underscore), so a schema edit is never
320
+ * forwarded to the worker.
321
+ */
165
322
  declare const SCHEMA_EDIT_ENDPOINT = "/__lunora/schema-edit";
166
323
  /** A request adapted from the host transport. */
167
324
  interface SchemaEditRequest {
325
+ /** API-spec mode the host runs codegen with; forwarded to the regeneration. */
326
+ readonly apiSpec?: CodegenOptions["apiSpec"];
168
327
  /** Parsed JSON body for a `POST`; ignored for `GET`. */
169
328
  readonly body?: unknown;
329
+ /** Lazy function mode the host runs codegen with; forwarded to the regeneration. */
330
+ readonly lazyFunctions?: CodegenOptions["lazyFunctions"];
170
331
  /** HTTP method (`GET` / `POST`). */
171
332
  readonly method: string;
172
333
  /** Project root containing the `lunora/` directory. */
@@ -180,28 +341,28 @@ interface SchemaEditResponse {
180
341
  readonly status: number;
181
342
  }
182
343
  /**
183
- * Handle a schema-edit request. Pure over its inputs apart from the file I/O +
184
- * codegen it performs on a `POST` additive edit; safe to unit-test against a
185
- * temp project directory.
186
- */
344
+ * Handle a schema-edit request. Pure over its inputs apart from the file I/O +
345
+ * codegen it performs on a `POST` additive edit; safe to unit-test against a
346
+ * temp project directory.
347
+ */
187
348
  declare const handleSchemaEditRequest: (request: SchemaEditRequest) => SchemaEditResponse;
188
349
  /**
189
- * Endpoint path both dev hosts mount the handler at. A sibling of the schema
190
- * editor's `/__lunora/schema-edit`; the double underscore keeps it clear of the
191
- * CLI's `/_lunora/*` worker proxy (single underscore).
192
- */
350
+ * Endpoint path both dev hosts mount the handler at. A sibling of the schema
351
+ * editor's `/__lunora/schema-edit`; the double underscore keeps it clear of the
352
+ * CLI's `/_lunora/*` worker proxy (single underscore).
353
+ */
193
354
  declare const SEED_ENDPOINT = "/__lunora/seed";
194
355
  /** Body the host transport adapts from a `POST` — one generate-rows request. */
195
356
  interface SeedRequestBody {
196
357
  /** How many rows to generate (clamped to `[1, MAX_SEED_ROWS]`). */
197
358
  readonly count?: number;
198
359
  /**
199
- * Ids of rows that already exist in the live DB, keyed by referenced table.
200
- * Foreign keys resolve against these, and every referenced parent table
201
- * present here is treated as covered — so the generator links to existing
202
- * rows instead of fabricating new parent rows. The studio samples these from
203
- * the target table's FK columns before calling.
204
- */
360
+ * Ids of rows that already exist in the live DB, keyed by referenced table.
361
+ * Foreign keys resolve against these, and every referenced parent table
362
+ * present here is treated as covered — so the generator links to existing
363
+ * rows instead of fabricating new parent rows. The studio samples these from
364
+ * the target table's FK columns before calling.
365
+ */
205
366
  readonly existingIds?: Readonly<Record<string, ReadonlyArray<string>>>;
206
367
  /** Deterministic mapping selector — same value yields identical rows. */
207
368
  readonly seed?: number;
@@ -225,35 +386,109 @@ interface SeedResponse {
225
386
  readonly status: number;
226
387
  }
227
388
  /**
228
- * Handle a generate-rows request: statically lift the schema, generate `count`
229
- * rows for `table` (linking foreign keys to the supplied existing ids rather
230
- * than fabricating parents), and return them JSON-safe for the client to insert.
231
- */
232
- declare const handleSeedRequest: (request: SeedRequest) => SeedResponse;
233
- /** A request adapted from a host transport, passed to a local-dev handler. */
234
- interface LocalEndpointRequest {
235
- /** Parsed JSON body of the request (`undefined` for `GET` / an empty body). */
236
- readonly body?: unknown;
237
- /** HTTP method. */
238
- readonly method: string;
239
- /** Project root containing the `lunora/` directory. */
240
- readonly projectRoot: string;
241
- /** Override the lunora subdirectory name. Defaults to `"lunora"`. */
242
- readonly schemaDirectory?: string;
243
- }
244
- /** A response a local-dev handler returns, serialised back as JSON with its status. */
245
- interface LocalEndpointResponse {
246
- readonly body: unknown;
247
- readonly status: number;
248
- }
249
- /** A transport-agnostic local-dev handler (schema edit, policy scaffold). */
250
- type LocalEndpointHandler = (request: LocalEndpointRequest) => LocalEndpointResponse;
251
- /**
252
- * Adapt a `node:http` request/response pair to a transport-agnostic local-dev
253
- * handler. `GET` carries no body (the schema editor uses it to read the parsed
254
- * schema); every other method has its body read + JSON-parsed first. The
255
- * handler's `{ status, body }` is serialised back as JSON. A malformed body is a
256
- * `400`; an unexpected throw (e.g. the body-size guard) is a `500`.
257
- */
258
- declare const serveJsonHandler: (request: IncomingMessage, response: ServerResponse, handle: LocalEndpointHandler, projectRoot: string) => void;
259
- export { type LocalEndpointHandler, type LocalEndpointRequest, type LocalEndpointResponse, POLICY_SCAFFOLD_ENDPOINT, type PolicyScaffoldBody, type PolicyScaffoldRequest, type PolicyScaffoldResponse, SCHEMA_EDIT_ENDPOINT, SEED_ENDPOINT, type SchemaEditRequest, type SchemaEditResponse, type SeedRequest, type SeedRequestBody, type SeedResponse, type StudioAssets, type StudioHtmlConfig, type WarnLogger, type WirePolicyEdit, assetContentType, handlePolicyScaffoldRequest, handleSchemaEditRequest, handleSeedRequest, isStandaloneModulePath, loadStudioAssets, parseDevVariable, readStandaloneAsset, renderStudioHtml, resolveAdminToken, resolveStandaloneDirectory, serveJsonHandler, studioAssetsStamp };
389
+ * Handle a generate-rows request: statically lift the schema, generate `count`
390
+ * rows for `table` (linking foreign keys to the supplied existing ids rather
391
+ * than fabricating parents), and return them JSON-safe for the client to insert.
392
+ *
393
+ * Only the requested table's rows are ever returned, so a foreign key with no
394
+ * `existingIds` to resolve against is answered with `409
395
+ * fk-parents-empty` naming the parent tables — the endpoint refuses
396
+ * rather than hand back children whose parents it just dropped.
397
+ *
398
+ * `@lunora/seed` is imported here, on the first request, not at module scope:
399
+ * it pulls in faker, which every dev server paid at startup for a button most
400
+ * sessions never press.
401
+ */
402
+ declare const handleSeedRequest: (request: SeedRequest) => Promise<SeedResponse>;
403
+ /**
404
+ * Suffix of the temporary file a studio handler writes and renames over its
405
+ * target. A watcher that sees every file has to ignore it: its events are part
406
+ * of the handler's write, not a change of their own.
407
+ */
408
+ declare const STUDIO_WRITE_TEMP_SUFFIX = ".lunora-tmp";
409
+ /**
410
+ * Whether a watcher event for `path` is the echo of a studio write. Returns true,
411
+ * and spends the record, only when the file still holds the text that was written.
412
+ */
413
+ declare const consumeStudioWrite: (path: string, now?: number) => boolean;
414
+ /** A single header value, lower-cased and trimmed; `undefined` when absent or array-valued. */
415
+ declare const headerValue: (raw: string | string[] | undefined) => string | undefined;
416
+ /**
417
+ * True for an IPv4/IPv6 loopback peer (`127.0.0.0/8`, `::1`, and the
418
+ * IPv4-mapped `::ffff:127.x`). A missing address means we cannot read the
419
+ * transport (e.g. a mocked request in tests) — treated as loopback so the
420
+ * config-derived gate stays the source of truth there; on a real Vite/Node
421
+ * server `remoteAddress` is always populated.
422
+ */
423
+ declare const isLoopbackAddress: (remoteAddress: string | undefined) => boolean;
424
+ /**
425
+ * Explicit opt-out for the forwarding-header refusal below — set to `"1"` to
426
+ * allow a proxied request through once you've confirmed the forwarding is
427
+ * your own trusted dev tunnel (Codespaces, devcontainers, Gitpod, Cloud
428
+ * Workstations, ngrok, a Docker reverse proxy, …), not an attacker's relay.
429
+ * Does not relax the socket-peer or `Host` checks — only this one.
430
+ */
431
+ declare const ALLOW_FORWARDED_ENV = "LUNORA_STUDIO_ALLOW_FORWARDED";
432
+ /**
433
+ * Per-request transport gate, independent of a host's config-derived bind
434
+ * intent (e.g. Vite's `isNonLoopbackBind`, the CLI's `isLoopback`). In Vite
435
+ * middleware mode the real bind belongs to the embedding server (so the
436
+ * config check measures the wrong thing); here we read the actual socket peer
437
+ * and the `Host` header. Returns a refusal reason, or `undefined` when the
438
+ * connection is loopback-local.
439
+ *
440
+ * `logger`, when supplied, gets a `warnOnce` line for a forwarding-header
441
+ * refusal — naming the specific header seen and the {@link ALLOW_FORWARDED_ENV}
442
+ * escape hatch — so the failure points at its cause in the terminal running
443
+ * the dev server, not just as an opaque 403 in the browser.
444
+ */
445
+ declare const transportRejectionReason: (request: IncomingMessage, logger?: WarnLogger) => string | undefined;
446
+ export { ADVISOR_PROCEDURES_ENDPOINT, ALLOW_FORWARDED_ENV, type LocalEndpointContext, type LocalEndpointHandler, type LocalEndpointRequest, type LocalEndpointResponse, POLICY_SCAFFOLD_ENDPOINT, type PolicyScaffoldBody, type PolicyScaffoldRequest, type PolicyScaffoldResponse, SCHEMA_EDIT_ENDPOINT, SEED_ENDPOINT, STUDIO_PATH, STUDIO_SCRIPT_PATH, STUDIO_STYLE_PATH, STUDIO_WRITE_TEMP_SUFFIX, type SchemaEditRequest, type SchemaEditResponse, type SeedRequest, type SeedRequestBody, type SeedResponse, type StudioAssets, type StudioHtmlConfig, type StudioMiddlewareOptions, type WarnLogger, type WirePolicyEdit, assetContentType, consumeStudioWrite, createStudioDocumentCache, createStudioMiddleware,
447
+ /**
448
+ * `@lunora/config/studio-host` — internal, build-time-shared helpers for hosting
449
+ * the prebuilt `@lunora/studio` SPA during local dev.
450
+ *
451
+ * Three dev hosts serve the studio from this code, so it behaves identically
452
+ * regardless of how the project is run:
453
+ * - `@lunora/vite` and `@lunora/rspack` mount `createStudioMiddleware` on their
454
+ * dev server at `/__lunora` — same routing, same URL.
455
+ * - `@lunora/cli` (`lunora dev`) serves it from a standalone Node HTTP server
456
+ * with its own routing (a root mount, and a read-only shell off loopback).
457
+ *
458
+ * The genuinely shared parts live here: render the host HTML with per-server
459
+ * config injected, resolve the admin token the same way the worker does, gate
460
+ * the transport, and load the prebuilt asset bytes.
461
+ */
462
+ devVariablesStamp, handleAdvisorProceduresRequest, handlePolicyScaffoldRequest, handleSchemaEditRequest, handleSeedRequest, headerValue, isLoopbackAddress, isNonLoopbackHost, isStandaloneModulePath, loadStudioAssets,
463
+ /**
464
+ * `@lunora/config/studio-host` — internal, build-time-shared helpers for hosting
465
+ * the prebuilt `@lunora/studio` SPA during local dev.
466
+ *
467
+ * Three dev hosts serve the studio from this code, so it behaves identically
468
+ * regardless of how the project is run:
469
+ * - `@lunora/vite` and `@lunora/rspack` mount `createStudioMiddleware` on their
470
+ * dev server at `/__lunora` — same routing, same URL.
471
+ * - `@lunora/cli` (`lunora dev`) serves it from a standalone Node HTTP server
472
+ * with its own routing (a root mount, and a read-only shell off loopback).
473
+ *
474
+ * The genuinely shared parts live here: render the host HTML with per-server
475
+ * config injected, resolve the admin token the same way the worker does, gate
476
+ * the transport, and load the prebuilt asset bytes.
477
+ */
478
+ parseDevVariable, readStandaloneAsset, renderStudioHtml, requestPathname,
479
+ /**
480
+ * `@lunora/config/studio-host` — internal, build-time-shared helpers for hosting
481
+ * the prebuilt `@lunora/studio` SPA during local dev.
482
+ *
483
+ * Three dev hosts serve the studio from this code, so it behaves identically
484
+ * regardless of how the project is run:
485
+ * - `@lunora/vite` and `@lunora/rspack` mount `createStudioMiddleware` on their
486
+ * dev server at `/__lunora` — same routing, same URL.
487
+ * - `@lunora/cli` (`lunora dev`) serves it from a standalone Node HTTP server
488
+ * with its own routing (a root mount, and a read-only shell off loopback).
489
+ *
490
+ * The genuinely shared parts live here: render the host HTML with per-server
491
+ * config injected, resolve the admin token the same way the worker does, gate
492
+ * the transport, and load the prebuilt asset bytes.
493
+ */
494
+ resolveAdminToken, resolveStandaloneDirectory, sendStudioAsset, sendStudioDocument, serveJsonHandler, studioAssetsStamp, studioMountPath, transportRejectionReason };