@lunora/config 1.0.0-alpha.36 → 1.0.0-alpha.361

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/LICENSE.md +135 -0
  2. package/README.md +3 -3
  3. package/dist/cli/index.d.mts +2 -0
  4. package/dist/cli/index.d.ts +2 -0
  5. package/dist/cli/index.mjs +1 -0
  6. package/dist/cloudflare/index.d.mts +1253 -0
  7. package/dist/cloudflare/index.d.ts +1253 -0
  8. package/dist/cloudflare/index.mjs +1 -0
  9. package/dist/index.d.mts +839 -974
  10. package/dist/index.d.ts +839 -974
  11. package/dist/index.mjs +1 -23
  12. package/dist/packem_shared/ACCENT-CotPTfv7.mjs +7 -0
  13. package/dist/packem_shared/AGENT_MODE_ENV-D8MvSwPE.mjs +1 -0
  14. package/dist/packem_shared/AGENT_RULES_DIR-HrrbNZPy.mjs +1 -0
  15. package/dist/packem_shared/ALLOW_FORWARDED_ENV-BUndghJx.mjs +1 -0
  16. package/dist/packem_shared/BINDING_MANIFEST_VERSION-CfXEYG8e.mjs +1 -0
  17. package/dist/packem_shared/CLOUDFLARE_CLI_CONFIG_WARNING_ENV-BKMrOuXV.mjs +1 -0
  18. package/dist/packem_shared/CLOUDFLARE_DRIVER-CULavrYO.mjs +1 -0
  19. package/dist/packem_shared/CLOUDFLARE_TOOLCHAIN_VERSIONS-DV5E_f_q.mjs +1 -0
  20. package/dist/packem_shared/CODEGEN_ENV-ZsCxV1kP.mjs +1 -0
  21. package/dist/packem_shared/COMPOSED_WORKER_ENTRY-Ciiba5g_.mjs +1 -0
  22. package/dist/packem_shared/DEFAULT_DEPLOY_TARGET-rR7buNQw.mjs +1 -0
  23. package/dist/packem_shared/DEFAULT_OBSERVABILITY-bN6UkTMx.mjs +1 -0
  24. package/dist/packem_shared/DEV_BINDINGS_FILE-C0ZN_XlP.mjs +4 -0
  25. package/dist/packem_shared/DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs +6 -0
  26. package/dist/packem_shared/DEV_WORKER_ENV_VALUE-2XFXmRrP.mjs +1 -0
  27. package/dist/packem_shared/GLOBAL_FETCH_STRICTLY_PUBLIC_FLAG-f8CnJha3.mjs +1 -0
  28. package/dist/packem_shared/LINKED_PROJECT_DIR-Ba5qPEwo.mjs +2 -0
  29. package/dist/packem_shared/LUNORA_EVENT_SOURCE-B9ZVohjO.mjs +1 -0
  30. package/dist/packem_shared/LUNORA_IGNORED_PATHS-U93uPxrW.mjs +19 -0
  31. package/dist/packem_shared/LUNORA_TAG-DQTGPqcJ.mjs +1 -0
  32. package/dist/packem_shared/LunoraReporter-f277GLNT.mjs +6 -0
  33. package/dist/packem_shared/PACKAGE_SECRETS_REGISTRY-38Plje8b.mjs +1 -0
  34. package/dist/packem_shared/POLICY_SCAFFOLD_ENDPOINT-BmJYwAy2.mjs +1 -0
  35. package/dist/packem_shared/REMOTE_ELIGIBLE_KEYS-PLeh_74E.mjs +1 -0
  36. package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-OLQlG0oj.mjs +1 -0
  37. package/dist/packem_shared/SCHEMA_EDIT_ENDPOINT-BeTxqCuQ.mjs +1 -0
  38. package/dist/packem_shared/SEED_ENDPOINT-2B56PN_H.mjs +1 -0
  39. package/dist/packem_shared/STUDIO_PATH-CSx_psKS.mjs +1 -0
  40. package/dist/packem_shared/UNEXPORTED_CLASS_MARKER-DwJCN8fX.mjs +1 -0
  41. package/dist/packem_shared/WORKERS_CACHE_MIN_DATE-0k9ABJtF.mjs +1 -0
  42. package/dist/packem_shared/WRANGLER_FILES-UNW-xY5u.mjs +1 -0
  43. package/dist/packem_shared/acceptsConnection-DHhUYGjT.mjs +2 -0
  44. package/dist/packem_shared/addArgsFor-CYZKhNIo.mjs +1 -0
  45. package/dist/packem_shared/applyAdditiveEdit-CH0VhMJ2.mjs +6 -0
  46. package/dist/packem_shared/applyModify-DKP2l6S9.mjs +1 -0
  47. package/dist/packem_shared/applyStudioAssetCache-DHQEJuuv.mjs +1 -0
  48. package/dist/packem_shared/assertWranglerSatisfiesSchema-D4FA4jKB.mjs +3 -0
  49. package/dist/packem_shared/assetContentType-CUb5bpbI.mjs +1 -0
  50. package/dist/packem_shared/blockingFindingsMessage-BVbijPdn.mjs +1 -0
  51. package/dist/packem_shared/buildPackageSecretsBlock-BWV_VxqV.mjs +19 -0
  52. package/dist/packem_shared/celld-config-D-L6uskI.mjs +3 -0
  53. package/dist/packem_shared/classifyPolicyEdit-DJi9Fk8G.mjs +24 -0
  54. package/dist/packem_shared/collectExportGaps-BPuhGH2J.mjs +2 -0
  55. package/dist/packem_shared/createConfirm-D5mKTMHj.mjs +7 -0
  56. package/dist/packem_shared/createDiscoveryCache-npJI4uej.mjs +1 -0
  57. package/dist/packem_shared/deploy-driver.d-Cl96-c1l.d.mts +184 -0
  58. package/dist/packem_shared/deploy-driver.d-Cl96-c1l.d.ts +184 -0
  59. package/dist/packem_shared/describePreservedCrons-C5KPuPy3.mjs +1 -0
  60. package/dist/packem_shared/describeWithheldWorkersAi-IIxe3TuI.mjs +1 -0
  61. package/dist/packem_shared/detectFramework-Dfpvu6rD.mjs +1 -0
  62. package/dist/packem_shared/discover-info-DC2MrAIM.mjs +1 -0
  63. package/dist/packem_shared/discoverAgentInfo-pqFMJBtJ.mjs +1 -0
  64. package/dist/packem_shared/discoverContainerInfo-DzXr7Vm3.mjs +1 -0
  65. package/dist/packem_shared/discoverSchemaInfo-BBRlXZop.mjs +1 -0
  66. package/dist/packem_shared/discoverWorkflowInfo-zW7Tt0Tn.mjs +1 -0
  67. package/dist/packem_shared/guards-Buu_E7mP.mjs +1 -0
  68. package/dist/packem_shared/hasCloudflareCredentials-byvHpEiD.mjs +1 -0
  69. package/dist/packem_shared/index.d-Cmx4jMFV.d.ts +270 -0
  70. package/dist/packem_shared/index.d-DkNi7r6E.d.mts +270 -0
  71. package/dist/packem_shared/infer-bindings-C1NFOdMi.mjs +1 -0
  72. package/dist/packem_shared/infer-bindings.d-eFzcOnRh.d.mts +297 -0
  73. package/dist/packem_shared/infer-bindings.d-eFzcOnRh.d.ts +297 -0
  74. package/dist/packem_shared/inferLunoraBindings-Gp_7yyIo.mjs +1 -0
  75. package/dist/packem_shared/interpretRemote-CcmGeGZ_.mjs +1 -0
  76. package/dist/packem_shared/lunora-manifest-DuH_Cmyu.mjs +6 -0
  77. package/dist/packem_shared/materializeServiceDevConfigs-DLUHefD-.mjs +1 -0
  78. package/dist/packem_shared/mergeWranglerEnvironment-DXiB-HcS.mjs +1 -0
  79. package/dist/packem_shared/package-secrets-registry-BeheNwsP.mjs +1 -0
  80. package/dist/packem_shared/parseDevVariable-teAAahVD.mjs +1 -0
  81. package/dist/packem_shared/parseSchema-D1Wbr1qv.mjs +1 -0
  82. package/dist/packem_shared/policy-scaffold.d-D2H4_G01.d.mts +86 -0
  83. package/dist/packem_shared/policy-scaffold.d-D2H4_G01.d.ts +86 -0
  84. package/dist/packem_shared/process-tree-once-Ou4SfxKM.mjs +1 -0
  85. package/dist/packem_shared/readProjectDependencies-l3uhUKjo.mjs +1 -0
  86. package/dist/packem_shared/reconcile-services-DFqH4eMQ.mjs +1 -0
  87. package/dist/packem_shared/reconcileBindingsSafely-BEwmwy0q.mjs +1 -0
  88. package/dist/packem_shared/reconcileWranglerCompatibilityDate-hocXEuRA.mjs +1 -0
  89. package/dist/packem_shared/renderStudioHtml-ByowDtMl.mjs +15 -0
  90. package/dist/packem_shared/resolveSchemaDirectory-Ca5P6KuP.mjs +1 -0
  91. package/dist/packem_shared/runPostCodegenHook-Dx3yTsYZ.mjs +1 -0
  92. package/dist/packem_shared/scanWranglerVariablesForSecrets-BFTVje1q.mjs +1 -0
  93. package/dist/packem_shared/serveJsonHandler-Dv0EdCb9.mjs +1 -0
  94. package/dist/packem_shared/startCelldDevSession-BLFsd6jG.mjs +1 -0
  95. package/dist/packem_shared/streamContainerLogs-0nko1qpv.mjs +2 -0
  96. package/dist/packem_shared/validate-bindings-CvNBF3U4.mjs +1 -0
  97. package/dist/packem_shared/withTailConsumer-DngzpJMK.mjs +1 -0
  98. package/dist/packem_shared/worker-entry-checks-AIASCYl7.mjs +1 -0
  99. package/dist/packem_shared/wranglerCodegenInputs-CbisphsH.mjs +1 -0
  100. package/dist/packem_shared/wranglerToAlchemy-CBO2ucRm.mjs +6 -0
  101. package/dist/packem_shared/write-atomic-CK6VZaPI.mjs +1 -0
  102. package/dist/studio-host/index.d.mts +314 -110
  103. package/dist/studio-host/index.d.ts +314 -110
  104. package/dist/studio-host/index.mjs +1 -7
  105. package/package.json +20 -7
  106. package/dist/packem_shared/ACCENT-DW1XJn8i.mjs +0 -40
  107. package/dist/packem_shared/AGENT_RULES_DIR-lcgC08aE.mjs +0 -40
  108. package/dist/packem_shared/DEV_VARS_EXAMPLE_FILE-dJPNTEnK.mjs +0 -37
  109. package/dist/packem_shared/LINKED_PROJECT_DIR-CXwXzV_C.mjs +0 -52
  110. package/dist/packem_shared/LUNORA_CONFIG_FILE-CtcIcB5-.mjs +0 -34
  111. package/dist/packem_shared/LUNORA_EVENT_SOURCE-D2fDeGB6.mjs +0 -86
  112. package/dist/packem_shared/LunoraReporter-Ci-bDCK9.mjs +0 -70
  113. package/dist/packem_shared/PACKAGE_SECRETS_REGISTRY-B8t_SdoZ.mjs +0 -70
  114. package/dist/packem_shared/POLICY_SCAFFOLD_ENDPOINT-CiC2IGKx.mjs +0 -103
  115. package/dist/packem_shared/REMOTE_ELIGIBLE_KEYS-BC7_e9Bz.mjs +0 -105
  116. package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-2YYyWJUq.mjs +0 -561
  117. package/dist/packem_shared/SCHEMA_EDIT_ENDPOINT-Df-Wrix-.mjs +0 -99
  118. package/dist/packem_shared/SEED_ENDPOINT-DVCjaGO-.mjs +0 -61
  119. package/dist/packem_shared/WRANGLER_FILES-DwSuC-Kn.mjs +0 -25
  120. package/dist/packem_shared/applyAdditiveEdit-C-snTFEV.mjs +0 -228
  121. package/dist/packem_shared/buildPackageSecretsBlock-DWDKHViT.mjs +0 -243
  122. package/dist/packem_shared/classifyPolicyEdit-BHeAqF8P.mjs +0 -99
  123. package/dist/packem_shared/createConfirm-fvpdgJ9s.mjs +0 -100
  124. package/dist/packem_shared/detectFramework-Br-BcPBq.mjs +0 -41
  125. package/dist/packem_shared/discoverContainerInfo-BXFs6Wav.mjs +0 -19
  126. package/dist/packem_shared/discoverSchemaInfo-BB-CKlTK.mjs +0 -25
  127. package/dist/packem_shared/discoverWorkflowInfo-CedvR0mn.mjs +0 -19
  128. package/dist/packem_shared/inferLunoraBindings-ByMwG-gH.mjs +0 -352
  129. package/dist/packem_shared/loadStudioAssets-Csk5RS4E.mjs +0 -28
  130. package/dist/packem_shared/parseDevVariable-CJiq2IwE.mjs +0 -30
  131. package/dist/packem_shared/parseSchema-DSeyktvG.mjs +0 -107
  132. package/dist/packem_shared/policy-scaffold.d-DCmwn7zQ.d.mts +0 -74
  133. package/dist/packem_shared/policy-scaffold.d-DCmwn7zQ.d.ts +0 -74
  134. package/dist/packem_shared/reconcileWranglerBindings-Cruwwx1M.mjs +0 -334
  135. package/dist/packem_shared/renderStudioHtml-449Ysn75.mjs +0 -37
  136. package/dist/packem_shared/serveJsonHandler-B4OLTGLS.mjs +0 -86
  137. package/dist/packem_shared/streamContainerLogs-BZ4cOZwH.mjs +0 -157
@@ -0,0 +1,297 @@
1
+ import { SchemaIR, AgentIR, ContainerIR, QueueIR, ServiceBindingIR, WorkflowIR } from '@lunora/codegen';
2
+ /**
3
+ * An invocation-scoped memo for project discovery. A CLI command creates one,
4
+ * threads it through every `discover*` / `inferLunoraBindings` call it makes,
5
+ * and clears it after anything rewrites the sources discovery reads (codegen).
6
+ * Deliberately not module-level: tests and long-lived processes never see a
7
+ * stale result.
8
+ */
9
+ interface DiscoveryCache {
10
+ /** Drop every memoised result. */
11
+ clear: () => void;
12
+ /** Return the result memoised under `key`, computing it on first use. */
13
+ memo: <T>(key: string, compute: () => T) => T;
14
+ }
15
+ declare const createDiscoveryCache: () => DiscoveryCache;
16
+ /** One filterable Vectorize metadata property a schema declares. */
17
+ interface VectorMetadataDeclaration {
18
+ /** The vector index the property belongs to. */
19
+ index: string;
20
+ /**
21
+ * The validator kind behind the column, with `v.optional(...)` and a
22
+ * nullable union unwrapped (metadata columns are usually optional), or
23
+ * `undefined` when the column isn't in the owning table's shape. Callers map it to the Vectorize
24
+ * metadata type; a kind that can't be filtered on is reported, not indexed.
25
+ */
26
+ kind: string | undefined;
27
+ /** Column mirrored into vector metadata. */
28
+ property: string;
29
+ }
30
+ interface SchemaInfo {
31
+ /**
32
+ * Whether the schema declares a **D1-backed** `.global()` table — the only
33
+ * flavour that needs the `DB` binding and the app's `.global({ d1 })` chain.
34
+ * A `.global({ backend: "hyperdrive" })` table needs neither, and counting it
35
+ * here demanded a D1 database of a project that has none.
36
+ */
37
+ hasD1GlobalTable: boolean;
38
+ /** Whether the schema declares a `.global({ backend: "hyperdrive" })` table — needs the app's `.hyperdriveGlobal(...)` chain instead. Required, not optional: the only producer always knows the answer, and `?` made every consumer read a two-valued fact as three-valued. */
39
+ hasHyperdriveGlobalTable: boolean;
40
+ /**
41
+ * Data-residency jurisdiction declared via `defineSchema(...).jurisdiction("…")`.
42
+ * It pins the app's Durable Objects only; KV namespaces and R2 buckets carry
43
+ * their own jurisdiction, set when they are created.
44
+ */
45
+ jurisdiction?: SchemaIR["jurisdiction"];
46
+ /** Names of vector indexes declared via `.vectorize()` / `defineVectorIndex()`. */
47
+ vectorIndexNames?: ReadonlyArray<string>;
48
+ /**
49
+ * Metadata properties declared filterable on a vector index. Cloudflare
50
+ * needs an explicit metadata index per property before a `filter` can match
51
+ * anything, so deploy provisions these and doctor reports them.
52
+ */
53
+ vectorMetadata?: ReadonlyArray<VectorMetadataDeclaration>;
54
+ }
55
+ interface DiscoverSchemaInfoResult {
56
+ /** Parse error message, when the schema exists but could not be analyzed. */
57
+ error?: string;
58
+ /** Schema facts, or `undefined` when no `schema.ts` exists or parsing failed. */
59
+ info: SchemaInfo | undefined;
60
+ }
61
+ /** Discover the schema facts, memoised on `cache` when one is given. */
62
+ declare const discoverSchemaInfo: (projectRoot: string, schemaDirectory: string, cache?: DiscoveryCache) => DiscoverSchemaInfoResult;
63
+ interface DurableObjectSpec {
64
+ binding: string;
65
+ className: string;
66
+ }
67
+ /**
68
+ * Canonical Durable Object class → binding name. wrangler requires the worker
69
+ * to export a class of this exact name, so detection keys on the class name.
70
+ */
71
+ declare const DURABLE_OBJECT_BINDINGS: {
72
+ readonly LunoraDO: "SHARD";
73
+ readonly SchedulerDO: "SCHEDULER";
74
+ readonly SessionDO: "SESSION";
75
+ readonly ShardDO: "SHARD";
76
+ readonly ShardRegistryDO: "SHARD_REGISTRY";
77
+ };
78
+ type DurableObjectClass = keyof typeof DURABLE_OBJECT_BINDINGS;
79
+ /**
80
+ * The `_generated/` modules that hold a generated Durable Object / Workflow
81
+ * class — one per class kind a project can declare. wrangler validates every
82
+ * `class_name` against the worker's exports, so this is the set a worker entry
83
+ * re-exports (and the set the composed class-A entry star-re-exports for the
84
+ * kinds the project has).
85
+ *
86
+ * Owned here because four places need it and they must not drift:
87
+ * `@lunora/vite` emits one star re-export per entry, the wrangler validator
88
+ * DECIDES the composed entry's exports from it, `reconcile-bindings` types its
89
+ * export-gap `module` field on it, and this module's own `detectClassExports`
90
+ * probes the same names.
91
+ *
92
+ * `scheduler` carries no `define*` declarations of its own — codegen writes it
93
+ * off `hasScheduler` purely so the composed class-A entry has a `SchedulerDO`
94
+ * to forward. Its presence is therefore the ONLY signal the plugin and the
95
+ * validator need, and it is the same signal that decides whether the builder
96
+ * has a `.scheduler()` method at all. `@lunora/vite` depends on `@lunora/config`, so config
97
+ * owning it is the direction the dependency graph allows.
98
+ */
99
+ declare const GENERATED_CLASS_MODULES: readonly ["agents", "containers", "scheduler", "shardRegistry", "workflows"];
100
+ /** One {@link GENERATED_CLASS_MODULES} entry. */
101
+ type GeneratedClassModule = (typeof GENERATED_CLASS_MODULES)[number];
102
+ /**
103
+ * The framework Durable Object each class module forwards, for the modules that
104
+ * carry one: codegen writes them off the same signal that gives the builder the
105
+ * matching method, so the module's existence means the composed entry exports
106
+ * the class.
107
+ */
108
+ declare const GENERATED_MODULE_DURABLE_OBJECTS: Partial<Record<GeneratedClassModule, DurableObjectClass>>;
109
+ /** The `_generated/` module codegen writes when `lunora.config` opts in to the merge. */
110
+ declare const MERGED_DURABLE_OBJECTS_MODULE: "durableObjects";
111
+ /**
112
+ * Whether the project merges its Durable Objects: codegen wrote the merge
113
+ * module. The one test the composed entry, binding inference and the export
114
+ * validator all ask — the same "module existence is the signal" rule the
115
+ * scheduler and registry modules follow.
116
+ */
117
+ declare const isMergedProject: (generatedDirectory: string) => boolean;
118
+ /** Whether `module` holds a class the merged class hosts — imported into it, never re-exported. */
119
+ declare const isMergedRoleModule: (module: string) => boolean;
120
+ /**
121
+ * The class-B composed entry. `lunora deploy` passes this file to wrangler as
122
+ * the positional script whenever it exists, overriding `wrangler.main` — so it
123
+ * is what actually gets bundled and what wrangler checks its DO/Workflow
124
+ * bindings against. `main` in a class-B project names the framework adapter's
125
+ * build output (`.svelte-kit/cloudflare/_worker.js`, `dist/_worker.js`), which
126
+ * exists after `vite build` and exports only the SSR fetch handler. Lexing that
127
+ * instead read every declared class as unexported: nothing provisioned, plus a
128
+ * "add `export * from …`" warning the user cannot silence.
129
+ *
130
+ * Exported, not documented-as-duplicated: the CLI's `resolveComposedWorkerEntry`
131
+ * imports this constant, so the deploy's positional entry and the file this
132
+ * module lexes for exported classes cannot drift apart.
133
+ */
134
+ declare const COMPOSED_WORKER_ENTRY = "src/worker.ts";
135
+ /**
136
+ * A `defineContainer` declaration plus whether its generated DO class is
137
+ * exported by the worker entry. Only exported containers are safe to
138
+ * provision — wrangler rejects a `containers[].class_name` (and its Durable
139
+ * Object binding) that the worker doesn't export.
140
+ */
141
+ type InferredContainer = ContainerIR & {
142
+ exported: boolean;
143
+ };
144
+ /**
145
+ * A `defineWorkflow` declaration plus whether its generated
146
+ * `WorkflowEntrypoint` class is exported by the worker entry. Only exported
147
+ * workflows are safe to provision — wrangler rejects an `exports.<Class>`
148
+ * workflow the worker doesn't export. Workflows are NOT Durable Objects, so this never
149
+ * implies a `durable_objects` binding or migration.
150
+ */
151
+ interface InferredWorkflow extends WorkflowIR {
152
+ exported: boolean;
153
+ }
154
+ /**
155
+ * A `defineAgent` declaration plus whether its generated agent
156
+ * `WorkflowEntrypoint` class (e.g. `SupportAgentWorkflow`) is exported by the
157
+ * worker entry. An agent compiles onto a Cloudflare Workflow, so — exactly like
158
+ * {@link InferredWorkflow} — only exported agents are safe to provision
159
+ * (wrangler rejects an `exports.<Class>` workflow the worker doesn't export), and
160
+ * an agent is NOT a Durable Object (no `durable_objects` binding or migration).
161
+ */
162
+ interface InferredAgent extends AgentIR {
163
+ exported: boolean;
164
+ }
165
+ /**
166
+ * A queue declared in `lunora/queues.ts`. Unlike workflows, a queue needs no
167
+ * worker-entry class export (its `queue()` handler rides `createWorker`), so
168
+ * there is no `exported` flag — every declared queue is reconcilable into the
169
+ * wrangler `queues.producers[]` / `queues.consumers[]`.
170
+ */
171
+ type InferredQueue = QueueIR;
172
+ interface InferredBindings {
173
+ /** Agents declared in `lunora/agents.ts` (exported or not — see {@link InferredAgent.exported}); reconciled into wrangler `exports`. */
174
+ agents: InferredAgent[];
175
+ /** Containers declared in `lunora/containers.ts` (exported or not — see {@link InferredContainer.exported}). */
176
+ containers: InferredContainer[];
177
+ /** Durable Objects the worker entry exports → safe to bind. */
178
+ durableObjects: DurableObjectSpec[];
179
+ /**
180
+ * The wrangler `flagship[].binding` name implied by `lunora/flags.ts` when it
181
+ * uses the Flagship provider in binding mode — `undefined` for HTTP-mode
182
+ * Flagship, a custom OpenFeature provider, or no flags. The binding needs an
183
+ * un-mintable `app_id`, so it is reconciled as a hint, not auto-written.
184
+ */
185
+ flagshipBinding?: string;
186
+ /**
187
+ * The schema's `.jurisdiction("…")`, when it declares one. Read by the binding
188
+ * hints whose resource takes its residency at creation (Artifacts), so the
189
+ * hint can name the jurisdiction to create it in.
190
+ */
191
+ jurisdiction?: SchemaInfo["jurisdiction"];
192
+ /** Schema declares a `.global()` table → needs the `DB` D1 binding. */
193
+ needsD1: boolean;
194
+ /** Queues declared in `lunora/queues.ts` → reconciled into `queues.producers[]` / `queues.consumers[]`. */
195
+ queues: InferredQueue[];
196
+ /**
197
+ * Sibling Workers declared in `lunora.config` `services` → reconciled into
198
+ * `services[]` (plan 457). `undefined` when the declaration is unreadable, so
199
+ * reconcile leaves every entry alone rather than removing the owned ones.
200
+ */
201
+ services: ServiceBindingIR[] | undefined;
202
+ /** Human-readable provenance for each inferred binding / hint, for logging. */
203
+ signals: string[];
204
+ /** `@lunora/ai` is imported, `ctx.ai` read, or `env.AI` used → needs the `ai` Workers AI binding. */
205
+ usesAi: boolean;
206
+ /** `@lunora/bindings/ai-search` is value-imported or `ctx.aiSearch` read → self-describing `ai_search_namespaces` binding (`AI_SEARCH` on namespace `default`; auto-writeable). */
207
+ usesAiSearch: boolean;
208
+ /** `@lunora/bindings/analytics` is imported or `ctx.analytics` read → self-describing `analytics_engine_datasets` binding (auto-writeable). */
209
+ usesAnalytics: boolean;
210
+ /** `@lunora/bindings/analytics-sql` is value-imported or `ctx.analyticsSql` read → self-describing `analytics` binding (`{ binding: ANALYTICS_SQL }`; auto-writeable, wrangler >= 4.145.0). */
211
+ usesAnalyticsSql: boolean;
212
+ /**
213
+ * `ctx.artifacts` is read or `@lunora/bindings/artifacts` value-imported.
214
+ * Hint-only: the first repo `create()` against a missing namespace creates it
215
+ * UNRESTRICTED, and a namespace's jurisdiction can never change after that,
216
+ * so Lunora never writes the binding for you.
217
+ */
218
+ usesArtifacts: boolean;
219
+ /** `@lunora/auth` is imported (sessions may be D1- or `SessionDO`-backed). */
220
+ usesAuth: boolean;
221
+ /** `@lunora/browser` is imported or `ctx.browser` read → self-describing `browser` binding (auto-writeable). */
222
+ usesBrowser: boolean;
223
+ /** `@lunora/auth/cimd/workers` is imported → needs the `global_fetch_strictly_public` compatibility flag (no binding; `lunora doctor` checks it). */
224
+ usesCimdWorkers: boolean;
225
+ /** `lunora/flags.ts` declares a feature-flag provider (any OpenFeature provider — Flagship or custom). */
226
+ usesFlags: boolean;
227
+ /** `@lunora/hyperdrive` is imported or `ctx.sql` read (binding needs an un-mintable remote `id`; hint-only). */
228
+ usesHyperdrive: boolean;
229
+ /** `@lunora/bindings/images` is imported or `ctx.images` read → self-describing `images` binding (auto-writeable). */
230
+ usesImages: boolean;
231
+ /** `@lunora/bindings/kv` is imported or `ctx.kv` read (namespace binding name + id are user-defined; hint-only). */
232
+ usesKv: boolean;
233
+ /** `@lunora/mail` is imported (Resend API key must be set in `.dev.vars`; no binding). No `ctx.mail` helper exists, so only the import counts. */
234
+ usesMail: boolean;
235
+ /** `@lunora/notify` is imported or `ctx.notify` read (no binding; channel secrets ride `usesNotifyFcm` / `usesNotifyWebPush`). */
236
+ usesNotify: boolean;
237
+ /** `lunora/notify.ts` configures the `fcm` channel → the `FCM_*` secrets in `.dev.vars`. */
238
+ usesNotifyFcm: boolean;
239
+ /** `lunora/notify.ts` configures the `webPush` channel → the `VAPID_*` secrets in `.dev.vars`. */
240
+ usesNotifyWebPush: boolean;
241
+ /** `@lunora/payment/autumn` is imported → the Autumn secrets in `.dev.vars` (no binding). */
242
+ usesPaymentAutumn: boolean;
243
+ /** `@lunora/payment/creem` is imported → the Creem secrets in `.dev.vars` (no binding). */
244
+ usesPaymentCreem: boolean;
245
+ /** `@lunora/payment/dodopayments` is imported → the Dodo Payments secrets in `.dev.vars` (no binding). */
246
+ usesPaymentDodopayments: boolean;
247
+ /** `@lunora/payment/polar` is imported → the Polar secrets in `.dev.vars` (no binding). */
248
+ usesPaymentPolar: boolean;
249
+ /** `@lunora/payment` is imported or `ctx.payments` read (provider secrets must be set in `.dev.vars`; no binding). */
250
+ usesPayments: boolean;
251
+ /** `@lunora/payment/stripe` is imported → the Stripe secrets in `.dev.vars` (no binding). */
252
+ usesPaymentStripe: boolean;
253
+ /** `@lunora/bindings/pipelines` is value-imported or `ctx.pipelines` read (binding needs an un-mintable remote pipeline name; hint-only). */
254
+ usesPipelines: boolean;
255
+ /** `@lunora/bindings/r2sql` is value-imported or `ctx.r2sql` read (needs the `R2_SQL_*` secrets in `.dev.vars`; no binding). */
256
+ usesR2sql: boolean;
257
+ /** `@lunora/scheduler` is imported or `ctx.scheduler` read. */
258
+ usesScheduler: boolean;
259
+ /** `@lunora/storage` is imported or `ctx.storage` read under `lunora/` (R2 bucket binding name is user-defined). */
260
+ usesStorage: boolean;
261
+ /** `jsCodeTool` is imported from `@lunora/agent` in `lunora/` → self-describing `worker_loaders` binding (`LOADER`). */
262
+ usesWorkerLoader: boolean;
263
+ /** `@lunora/x402/pay` is imported or `ctx.x402` read — the agent-wallet pay rail signs from a Secrets Store binding paired with a spend policy (ActionCtx-only; hint-only). */
264
+ usesX402: boolean;
265
+ /** `@lunora/x402/charge` is imported — the charge rail settles USDC to a recipient address (a public `[vars]` entry, user-named; hint-only). */
266
+ usesX402Charge: boolean;
267
+ /** Workflows declared in `lunora/workflows.ts` (exported or not — see {@link InferredWorkflow.exported}). */
268
+ workflows: InferredWorkflow[];
269
+ }
270
+ interface InferOptions {
271
+ /** Memoises the source scans, so one CLI invocation parses the project once. */
272
+ cache?: DiscoveryCache;
273
+ projectRoot: string;
274
+ /** Directories (relative to root) to scan. Defaults to `lunora` + `src`. */
275
+ scanDirs?: ReadonlyArray<string>;
276
+ /** Lunora source directory holding `schema.ts`. Defaults to `lunora`. */
277
+ schemaDir?: string;
278
+ }
279
+ /**
280
+ * Scan a Lunora project and report which Cloudflare bindings its code implies.
281
+ * Read-only: performs no writes. Binding provisioning is driven by the worker
282
+ * entry's Durable Object exports plus the schema's D1 need; capability imports
283
+ * surface as hints.
284
+ */
285
+ declare const inferLunoraBindings: (options: InferOptions) => Promise<InferredBindings>;
286
+ /**
287
+ * The secret sources a project uses — the {@link PACKAGE_SECRETS_REGISTRY} keys
288
+ * whose secrets it needs, derived from its already-resolved {@link InferredBindings}.
289
+ *
290
+ * This is the canonical bridge between binding inference and the
291
+ * `.dev.vars.example` scaffolding in `scaffold-dev-variables.ts`. The result is
292
+ * {@link FLAG_PACKAGES}' sources whose flag is `true` in `bindings` — in
293
+ * flag-name order — followed by the configured `@lunora/notify` channels
294
+ * ({@link NOTIFY_CHANNEL_SECRETS}), keeping only sources that carry secrets.
295
+ */
296
+ declare const secretSourcesFromBindings: (bindings: InferredBindings) => string[];
297
+ export { COMPOSED_WORKER_ENTRY as C, DiscoveryCache as D, GENERATED_CLASS_MODULES as G, InferOptions as I, MERGED_DURABLE_OBJECTS_MODULE as M, SchemaInfo as S, DURABLE_OBJECT_BINDINGS as a, DiscoverSchemaInfoResult as b, GENERATED_MODULE_DURABLE_OBJECTS as c, GeneratedClassModule as d, InferredAgent as e, InferredBindings as f, InferredContainer as g, InferredWorkflow as h, createDiscoveryCache as i, discoverSchemaInfo as j, inferLunoraBindings as k, isMergedProject as l, isMergedRoleModule as m, secretSourcesFromBindings as s };
@@ -0,0 +1,297 @@
1
+ import { SchemaIR, AgentIR, ContainerIR, QueueIR, ServiceBindingIR, WorkflowIR } from '@lunora/codegen';
2
+ /**
3
+ * An invocation-scoped memo for project discovery. A CLI command creates one,
4
+ * threads it through every `discover*` / `inferLunoraBindings` call it makes,
5
+ * and clears it after anything rewrites the sources discovery reads (codegen).
6
+ * Deliberately not module-level: tests and long-lived processes never see a
7
+ * stale result.
8
+ */
9
+ interface DiscoveryCache {
10
+ /** Drop every memoised result. */
11
+ clear: () => void;
12
+ /** Return the result memoised under `key`, computing it on first use. */
13
+ memo: <T>(key: string, compute: () => T) => T;
14
+ }
15
+ declare const createDiscoveryCache: () => DiscoveryCache;
16
+ /** One filterable Vectorize metadata property a schema declares. */
17
+ interface VectorMetadataDeclaration {
18
+ /** The vector index the property belongs to. */
19
+ index: string;
20
+ /**
21
+ * The validator kind behind the column, with `v.optional(...)` and a
22
+ * nullable union unwrapped (metadata columns are usually optional), or
23
+ * `undefined` when the column isn't in the owning table's shape. Callers map it to the Vectorize
24
+ * metadata type; a kind that can't be filtered on is reported, not indexed.
25
+ */
26
+ kind: string | undefined;
27
+ /** Column mirrored into vector metadata. */
28
+ property: string;
29
+ }
30
+ interface SchemaInfo {
31
+ /**
32
+ * Whether the schema declares a **D1-backed** `.global()` table — the only
33
+ * flavour that needs the `DB` binding and the app's `.global({ d1 })` chain.
34
+ * A `.global({ backend: "hyperdrive" })` table needs neither, and counting it
35
+ * here demanded a D1 database of a project that has none.
36
+ */
37
+ hasD1GlobalTable: boolean;
38
+ /** Whether the schema declares a `.global({ backend: "hyperdrive" })` table — needs the app's `.hyperdriveGlobal(...)` chain instead. Required, not optional: the only producer always knows the answer, and `?` made every consumer read a two-valued fact as three-valued. */
39
+ hasHyperdriveGlobalTable: boolean;
40
+ /**
41
+ * Data-residency jurisdiction declared via `defineSchema(...).jurisdiction("…")`.
42
+ * It pins the app's Durable Objects only; KV namespaces and R2 buckets carry
43
+ * their own jurisdiction, set when they are created.
44
+ */
45
+ jurisdiction?: SchemaIR["jurisdiction"];
46
+ /** Names of vector indexes declared via `.vectorize()` / `defineVectorIndex()`. */
47
+ vectorIndexNames?: ReadonlyArray<string>;
48
+ /**
49
+ * Metadata properties declared filterable on a vector index. Cloudflare
50
+ * needs an explicit metadata index per property before a `filter` can match
51
+ * anything, so deploy provisions these and doctor reports them.
52
+ */
53
+ vectorMetadata?: ReadonlyArray<VectorMetadataDeclaration>;
54
+ }
55
+ interface DiscoverSchemaInfoResult {
56
+ /** Parse error message, when the schema exists but could not be analyzed. */
57
+ error?: string;
58
+ /** Schema facts, or `undefined` when no `schema.ts` exists or parsing failed. */
59
+ info: SchemaInfo | undefined;
60
+ }
61
+ /** Discover the schema facts, memoised on `cache` when one is given. */
62
+ declare const discoverSchemaInfo: (projectRoot: string, schemaDirectory: string, cache?: DiscoveryCache) => DiscoverSchemaInfoResult;
63
+ interface DurableObjectSpec {
64
+ binding: string;
65
+ className: string;
66
+ }
67
+ /**
68
+ * Canonical Durable Object class → binding name. wrangler requires the worker
69
+ * to export a class of this exact name, so detection keys on the class name.
70
+ */
71
+ declare const DURABLE_OBJECT_BINDINGS: {
72
+ readonly LunoraDO: "SHARD";
73
+ readonly SchedulerDO: "SCHEDULER";
74
+ readonly SessionDO: "SESSION";
75
+ readonly ShardDO: "SHARD";
76
+ readonly ShardRegistryDO: "SHARD_REGISTRY";
77
+ };
78
+ type DurableObjectClass = keyof typeof DURABLE_OBJECT_BINDINGS;
79
+ /**
80
+ * The `_generated/` modules that hold a generated Durable Object / Workflow
81
+ * class — one per class kind a project can declare. wrangler validates every
82
+ * `class_name` against the worker's exports, so this is the set a worker entry
83
+ * re-exports (and the set the composed class-A entry star-re-exports for the
84
+ * kinds the project has).
85
+ *
86
+ * Owned here because four places need it and they must not drift:
87
+ * `@lunora/vite` emits one star re-export per entry, the wrangler validator
88
+ * DECIDES the composed entry's exports from it, `reconcile-bindings` types its
89
+ * export-gap `module` field on it, and this module's own `detectClassExports`
90
+ * probes the same names.
91
+ *
92
+ * `scheduler` carries no `define*` declarations of its own — codegen writes it
93
+ * off `hasScheduler` purely so the composed class-A entry has a `SchedulerDO`
94
+ * to forward. Its presence is therefore the ONLY signal the plugin and the
95
+ * validator need, and it is the same signal that decides whether the builder
96
+ * has a `.scheduler()` method at all. `@lunora/vite` depends on `@lunora/config`, so config
97
+ * owning it is the direction the dependency graph allows.
98
+ */
99
+ declare const GENERATED_CLASS_MODULES: readonly ["agents", "containers", "scheduler", "shardRegistry", "workflows"];
100
+ /** One {@link GENERATED_CLASS_MODULES} entry. */
101
+ type GeneratedClassModule = (typeof GENERATED_CLASS_MODULES)[number];
102
+ /**
103
+ * The framework Durable Object each class module forwards, for the modules that
104
+ * carry one: codegen writes them off the same signal that gives the builder the
105
+ * matching method, so the module's existence means the composed entry exports
106
+ * the class.
107
+ */
108
+ declare const GENERATED_MODULE_DURABLE_OBJECTS: Partial<Record<GeneratedClassModule, DurableObjectClass>>;
109
+ /** The `_generated/` module codegen writes when `lunora.config` opts in to the merge. */
110
+ declare const MERGED_DURABLE_OBJECTS_MODULE: "durableObjects";
111
+ /**
112
+ * Whether the project merges its Durable Objects: codegen wrote the merge
113
+ * module. The one test the composed entry, binding inference and the export
114
+ * validator all ask — the same "module existence is the signal" rule the
115
+ * scheduler and registry modules follow.
116
+ */
117
+ declare const isMergedProject: (generatedDirectory: string) => boolean;
118
+ /** Whether `module` holds a class the merged class hosts — imported into it, never re-exported. */
119
+ declare const isMergedRoleModule: (module: string) => boolean;
120
+ /**
121
+ * The class-B composed entry. `lunora deploy` passes this file to wrangler as
122
+ * the positional script whenever it exists, overriding `wrangler.main` — so it
123
+ * is what actually gets bundled and what wrangler checks its DO/Workflow
124
+ * bindings against. `main` in a class-B project names the framework adapter's
125
+ * build output (`.svelte-kit/cloudflare/_worker.js`, `dist/_worker.js`), which
126
+ * exists after `vite build` and exports only the SSR fetch handler. Lexing that
127
+ * instead read every declared class as unexported: nothing provisioned, plus a
128
+ * "add `export * from …`" warning the user cannot silence.
129
+ *
130
+ * Exported, not documented-as-duplicated: the CLI's `resolveComposedWorkerEntry`
131
+ * imports this constant, so the deploy's positional entry and the file this
132
+ * module lexes for exported classes cannot drift apart.
133
+ */
134
+ declare const COMPOSED_WORKER_ENTRY = "src/worker.ts";
135
+ /**
136
+ * A `defineContainer` declaration plus whether its generated DO class is
137
+ * exported by the worker entry. Only exported containers are safe to
138
+ * provision — wrangler rejects a `containers[].class_name` (and its Durable
139
+ * Object binding) that the worker doesn't export.
140
+ */
141
+ type InferredContainer = ContainerIR & {
142
+ exported: boolean;
143
+ };
144
+ /**
145
+ * A `defineWorkflow` declaration plus whether its generated
146
+ * `WorkflowEntrypoint` class is exported by the worker entry. Only exported
147
+ * workflows are safe to provision — wrangler rejects an `exports.<Class>`
148
+ * workflow the worker doesn't export. Workflows are NOT Durable Objects, so this never
149
+ * implies a `durable_objects` binding or migration.
150
+ */
151
+ interface InferredWorkflow extends WorkflowIR {
152
+ exported: boolean;
153
+ }
154
+ /**
155
+ * A `defineAgent` declaration plus whether its generated agent
156
+ * `WorkflowEntrypoint` class (e.g. `SupportAgentWorkflow`) is exported by the
157
+ * worker entry. An agent compiles onto a Cloudflare Workflow, so — exactly like
158
+ * {@link InferredWorkflow} — only exported agents are safe to provision
159
+ * (wrangler rejects an `exports.<Class>` workflow the worker doesn't export), and
160
+ * an agent is NOT a Durable Object (no `durable_objects` binding or migration).
161
+ */
162
+ interface InferredAgent extends AgentIR {
163
+ exported: boolean;
164
+ }
165
+ /**
166
+ * A queue declared in `lunora/queues.ts`. Unlike workflows, a queue needs no
167
+ * worker-entry class export (its `queue()` handler rides `createWorker`), so
168
+ * there is no `exported` flag — every declared queue is reconcilable into the
169
+ * wrangler `queues.producers[]` / `queues.consumers[]`.
170
+ */
171
+ type InferredQueue = QueueIR;
172
+ interface InferredBindings {
173
+ /** Agents declared in `lunora/agents.ts` (exported or not — see {@link InferredAgent.exported}); reconciled into wrangler `exports`. */
174
+ agents: InferredAgent[];
175
+ /** Containers declared in `lunora/containers.ts` (exported or not — see {@link InferredContainer.exported}). */
176
+ containers: InferredContainer[];
177
+ /** Durable Objects the worker entry exports → safe to bind. */
178
+ durableObjects: DurableObjectSpec[];
179
+ /**
180
+ * The wrangler `flagship[].binding` name implied by `lunora/flags.ts` when it
181
+ * uses the Flagship provider in binding mode — `undefined` for HTTP-mode
182
+ * Flagship, a custom OpenFeature provider, or no flags. The binding needs an
183
+ * un-mintable `app_id`, so it is reconciled as a hint, not auto-written.
184
+ */
185
+ flagshipBinding?: string;
186
+ /**
187
+ * The schema's `.jurisdiction("…")`, when it declares one. Read by the binding
188
+ * hints whose resource takes its residency at creation (Artifacts), so the
189
+ * hint can name the jurisdiction to create it in.
190
+ */
191
+ jurisdiction?: SchemaInfo["jurisdiction"];
192
+ /** Schema declares a `.global()` table → needs the `DB` D1 binding. */
193
+ needsD1: boolean;
194
+ /** Queues declared in `lunora/queues.ts` → reconciled into `queues.producers[]` / `queues.consumers[]`. */
195
+ queues: InferredQueue[];
196
+ /**
197
+ * Sibling Workers declared in `lunora.config` `services` → reconciled into
198
+ * `services[]` (plan 457). `undefined` when the declaration is unreadable, so
199
+ * reconcile leaves every entry alone rather than removing the owned ones.
200
+ */
201
+ services: ServiceBindingIR[] | undefined;
202
+ /** Human-readable provenance for each inferred binding / hint, for logging. */
203
+ signals: string[];
204
+ /** `@lunora/ai` is imported, `ctx.ai` read, or `env.AI` used → needs the `ai` Workers AI binding. */
205
+ usesAi: boolean;
206
+ /** `@lunora/bindings/ai-search` is value-imported or `ctx.aiSearch` read → self-describing `ai_search_namespaces` binding (`AI_SEARCH` on namespace `default`; auto-writeable). */
207
+ usesAiSearch: boolean;
208
+ /** `@lunora/bindings/analytics` is imported or `ctx.analytics` read → self-describing `analytics_engine_datasets` binding (auto-writeable). */
209
+ usesAnalytics: boolean;
210
+ /** `@lunora/bindings/analytics-sql` is value-imported or `ctx.analyticsSql` read → self-describing `analytics` binding (`{ binding: ANALYTICS_SQL }`; auto-writeable, wrangler >= 4.145.0). */
211
+ usesAnalyticsSql: boolean;
212
+ /**
213
+ * `ctx.artifacts` is read or `@lunora/bindings/artifacts` value-imported.
214
+ * Hint-only: the first repo `create()` against a missing namespace creates it
215
+ * UNRESTRICTED, and a namespace's jurisdiction can never change after that,
216
+ * so Lunora never writes the binding for you.
217
+ */
218
+ usesArtifacts: boolean;
219
+ /** `@lunora/auth` is imported (sessions may be D1- or `SessionDO`-backed). */
220
+ usesAuth: boolean;
221
+ /** `@lunora/browser` is imported or `ctx.browser` read → self-describing `browser` binding (auto-writeable). */
222
+ usesBrowser: boolean;
223
+ /** `@lunora/auth/cimd/workers` is imported → needs the `global_fetch_strictly_public` compatibility flag (no binding; `lunora doctor` checks it). */
224
+ usesCimdWorkers: boolean;
225
+ /** `lunora/flags.ts` declares a feature-flag provider (any OpenFeature provider — Flagship or custom). */
226
+ usesFlags: boolean;
227
+ /** `@lunora/hyperdrive` is imported or `ctx.sql` read (binding needs an un-mintable remote `id`; hint-only). */
228
+ usesHyperdrive: boolean;
229
+ /** `@lunora/bindings/images` is imported or `ctx.images` read → self-describing `images` binding (auto-writeable). */
230
+ usesImages: boolean;
231
+ /** `@lunora/bindings/kv` is imported or `ctx.kv` read (namespace binding name + id are user-defined; hint-only). */
232
+ usesKv: boolean;
233
+ /** `@lunora/mail` is imported (Resend API key must be set in `.dev.vars`; no binding). No `ctx.mail` helper exists, so only the import counts. */
234
+ usesMail: boolean;
235
+ /** `@lunora/notify` is imported or `ctx.notify` read (no binding; channel secrets ride `usesNotifyFcm` / `usesNotifyWebPush`). */
236
+ usesNotify: boolean;
237
+ /** `lunora/notify.ts` configures the `fcm` channel → the `FCM_*` secrets in `.dev.vars`. */
238
+ usesNotifyFcm: boolean;
239
+ /** `lunora/notify.ts` configures the `webPush` channel → the `VAPID_*` secrets in `.dev.vars`. */
240
+ usesNotifyWebPush: boolean;
241
+ /** `@lunora/payment/autumn` is imported → the Autumn secrets in `.dev.vars` (no binding). */
242
+ usesPaymentAutumn: boolean;
243
+ /** `@lunora/payment/creem` is imported → the Creem secrets in `.dev.vars` (no binding). */
244
+ usesPaymentCreem: boolean;
245
+ /** `@lunora/payment/dodopayments` is imported → the Dodo Payments secrets in `.dev.vars` (no binding). */
246
+ usesPaymentDodopayments: boolean;
247
+ /** `@lunora/payment/polar` is imported → the Polar secrets in `.dev.vars` (no binding). */
248
+ usesPaymentPolar: boolean;
249
+ /** `@lunora/payment` is imported or `ctx.payments` read (provider secrets must be set in `.dev.vars`; no binding). */
250
+ usesPayments: boolean;
251
+ /** `@lunora/payment/stripe` is imported → the Stripe secrets in `.dev.vars` (no binding). */
252
+ usesPaymentStripe: boolean;
253
+ /** `@lunora/bindings/pipelines` is value-imported or `ctx.pipelines` read (binding needs an un-mintable remote pipeline name; hint-only). */
254
+ usesPipelines: boolean;
255
+ /** `@lunora/bindings/r2sql` is value-imported or `ctx.r2sql` read (needs the `R2_SQL_*` secrets in `.dev.vars`; no binding). */
256
+ usesR2sql: boolean;
257
+ /** `@lunora/scheduler` is imported or `ctx.scheduler` read. */
258
+ usesScheduler: boolean;
259
+ /** `@lunora/storage` is imported or `ctx.storage` read under `lunora/` (R2 bucket binding name is user-defined). */
260
+ usesStorage: boolean;
261
+ /** `jsCodeTool` is imported from `@lunora/agent` in `lunora/` → self-describing `worker_loaders` binding (`LOADER`). */
262
+ usesWorkerLoader: boolean;
263
+ /** `@lunora/x402/pay` is imported or `ctx.x402` read — the agent-wallet pay rail signs from a Secrets Store binding paired with a spend policy (ActionCtx-only; hint-only). */
264
+ usesX402: boolean;
265
+ /** `@lunora/x402/charge` is imported — the charge rail settles USDC to a recipient address (a public `[vars]` entry, user-named; hint-only). */
266
+ usesX402Charge: boolean;
267
+ /** Workflows declared in `lunora/workflows.ts` (exported or not — see {@link InferredWorkflow.exported}). */
268
+ workflows: InferredWorkflow[];
269
+ }
270
+ interface InferOptions {
271
+ /** Memoises the source scans, so one CLI invocation parses the project once. */
272
+ cache?: DiscoveryCache;
273
+ projectRoot: string;
274
+ /** Directories (relative to root) to scan. Defaults to `lunora` + `src`. */
275
+ scanDirs?: ReadonlyArray<string>;
276
+ /** Lunora source directory holding `schema.ts`. Defaults to `lunora`. */
277
+ schemaDir?: string;
278
+ }
279
+ /**
280
+ * Scan a Lunora project and report which Cloudflare bindings its code implies.
281
+ * Read-only: performs no writes. Binding provisioning is driven by the worker
282
+ * entry's Durable Object exports plus the schema's D1 need; capability imports
283
+ * surface as hints.
284
+ */
285
+ declare const inferLunoraBindings: (options: InferOptions) => Promise<InferredBindings>;
286
+ /**
287
+ * The secret sources a project uses — the {@link PACKAGE_SECRETS_REGISTRY} keys
288
+ * whose secrets it needs, derived from its already-resolved {@link InferredBindings}.
289
+ *
290
+ * This is the canonical bridge between binding inference and the
291
+ * `.dev.vars.example` scaffolding in `scaffold-dev-variables.ts`. The result is
292
+ * {@link FLAG_PACKAGES}' sources whose flag is `true` in `bindings` — in
293
+ * flag-name order — followed by the configured `@lunora/notify` channels
294
+ * ({@link NOTIFY_CHANNEL_SECRETS}), keeping only sources that carry secrets.
295
+ */
296
+ declare const secretSourcesFromBindings: (bindings: InferredBindings) => string[];
297
+ export { COMPOSED_WORKER_ENTRY as C, DiscoveryCache as D, GENERATED_CLASS_MODULES as G, InferOptions as I, MERGED_DURABLE_OBJECTS_MODULE as M, SchemaInfo as S, DURABLE_OBJECT_BINDINGS as a, DiscoverSchemaInfoResult as b, GENERATED_MODULE_DURABLE_OBJECTS as c, GeneratedClassModule as d, InferredAgent as e, InferredBindings as f, InferredContainer as g, InferredWorkflow as h, createDiscoveryCache as i, discoverSchemaInfo as j, inferLunoraBindings as k, isMergedProject as l, isMergedRoleModule as m, secretSourcesFromBindings as s };
@@ -0,0 +1 @@
1
+ import"./discoverAgentInfo-pqFMJBtJ.mjs";import{i as c,s as d}from"./infer-bindings-C1NFOdMi.mjs";import"./discoverContainerInfo-DzXr7Vm3.mjs";import"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import"./discover-info-DC2MrAIM.mjs";import"./package-secrets-registry-BeheNwsP.mjs";import"./discoverSchemaInfo-BBRlXZop.mjs";import"./COMPOSED_WORKER_ENTRY-Ciiba5g_.mjs";import"./discoverWorkflowInfo-zW7Tt0Tn.mjs";export{c as inferLunoraBindings,d as secretSourcesFromBindings};
@@ -0,0 +1 @@
1
+ import{readProjectConfigLiterals as o,readProjectTarget as n}from"@lunora/codegen";import{DEFAULT_DEPLOY_TARGET as c,resolveDeployDriver as a}from"./DEFAULT_DEPLOY_TARGET-rR7buNQw.mjs";const s=e=>{if(typeof e=="boolean")return e;if(e!==null&&typeof e=="object")return!0},g=e=>s(o(e).remote),i=e=>n(e),T=(e,r)=>r??i(e)??c,j=(e,r)=>{const t=T(e,r);return a(t),t};export{s as interpretRemote,g as readProjectRemotePreference,i as readProjectTarget,T as resolveProjectTarget,j as resolveTargetOrThrow};
@@ -0,0 +1,6 @@
1
+ import{readFileSync as b,writeFileSync as v}from"node:fs";import{applyEdits as $,modify as S,parseTree as N,findNodeAtLocation as g}from"jsonc-parser";import{join as h}from"node:path";const A=/^([\t ]+)"/mu,F=n=>{const o=A.exec(n)?.[1]??" ";return{eol:n.includes(`\r
2
+ `)?`\r
3
+ `:`
4
+ `,insertSpaces:!o.startsWith(" "),tabSize:o.length}},I=n=>{const o=h(n,"package.json");try{const t=b(o,"utf8"),{lunora:r}=JSON.parse(t),e=typeof r=="object"&&r!==null&&!Array.isArray(r);return{lunora:e?r:void 0,lunoraIsForeign:r!==void 0&&!e,path:o,text:t}}catch{return}},p=n=>JSON.stringify(n,(o,t)=>typeof t=="object"&&t!==null&&!Array.isArray(t)?Object.fromEntries(Object.entries(t).toSorted(([r],[e])=>r.localeCompare(e))):t),j=(n,o,t)=>{const r=F(n),e=r.insertSpaces===!1?" ":" ".repeat(r.tabSize??4),i=r.eol??`
5
+ `,c=e.repeat(o.length),f=JSON.stringify(t,void 0,e).split(`
6
+ `).join(i+c),l=N(n),a=l===void 0?void 0:g(l,[...o]);if(a!==void 0)return n.slice(0,a.offset)+f+n.slice(a.offset+a.length);let s=l;l!==void 0&&o.length>1&&(s=g(l,o.slice(0,-1)));const y=JSON.stringify(o.at(-1));if(s===void 0&&o.length>1)return j(n,o.slice(0,-1),{[o.at(-1)]:t});if(s?.type!=="object")return $(n,S(n,[...o],t,{formattingOptions:r}));const d=s.children?.at(-1);if(d===void 0){const O=`${i}${c}${y}: ${f}${i}${e.repeat(o.length-1)}`;return`${n.slice(0,s.offset+1)}${O}${n.slice(s.offset+s.length-1)}`}const u=d.offset+d.length;return`${n.slice(0,u)},${i}${c}${y}: ${f}${n.slice(u)}`},K=(n,o,t)=>{const r=Object.keys(n.lunora??{}).every(c=>c===o);if(n.lunoraIsForeign||p(n.lunora?.[o])===p(t))return;const e=t===void 0&&r?["lunora"]:["lunora",o],i=t===void 0?$(n.text,S(n.text,e,void 0,{})):j(n.text,e,t);i!==n.text&&v(n.path,i,"utf8")};export{K as a,p as c,F as f,I as r};
@@ -0,0 +1 @@
1
+ import{isAbsolute as f,dirname as p,resolve as m}from"node:path";import{applyModify as l}from"./applyModify-DKP2l6S9.mjs";import{hasCloudflareCredentials as h}from"./hasCloudflareCredentials-byvHpEiD.mjs";import{withheldWorkersAi as u,writeDevConfig as v}from"./describeWithheldWorkersAi-IIxe3TuI.mjs";import{readWranglerJsonc as w}from"./WRANGLER_FILES-UNW-xY5u.mjs";const g=(t,r)=>{const{parsed:e,text:n}=w(t),o=e?.build,c=u(e?.ai,r.hasCredentials??(()=>h({projectRoot:r.projectRoot}))),d=typeof o?.command=="string"&&o.command!==""&&!(typeof o.cwd=="string"&&f(o.cwd));if(!d&&c===void 0)return{configPath:t};const s=p(t);let i=n;c!==void 0&&(i=l(i,["ai"],void 0)),d&&(i=l(i,["build","cwd"],m(s,typeof o.cwd=="string"?o.cwd:".")));const a=v(s,"service",i);return{cleanup:a.cleanup,configPath:a.configPath,withheld:c}},j=(t,r)=>{const e=t.map(o=>g(o,r)),n=e.flatMap(o=>o.cleanup===void 0?[]:[o.cleanup]);return{cleanup:()=>{for(const o of n)o()},configPaths:e.map(o=>o.configPath),withheld:e.flatMap(o=>o.withheld===void 0?[]:[o.withheld])}};export{j as materializeServiceDevConfigs};
@@ -0,0 +1 @@
1
+ const c=["ai_search","ai_search_namespaces","analytics","artifacts","containers","d1_databases","durable_objects","k2","kv_namespaces","queues","r2_buckets","secrets","secrets_store_secrets","services","tail_consumers","vars","vectorize","workflows"],i=["assets","compatibility_date","compatibility_flags","exports","logpush","main","migrations","observability","placement"],m=(s,n)=>{if(n===void 0)return{merged:s,unverifiedKeys:[]};const t=s.env?.[n];if(t===void 0){const e=Object.keys(s.env??{}).toSorted((v,f)=>v.localeCompare(f)),l=e.length>0?` (declared: ${e.join(", ")}).`:" (no environments are declared).";return{error:`--env "${n}" names no environment declared in wrangler.jsonc's "env" block${l}`,merged:s,unverifiedKeys:[]}}const o={...s},r=Object.keys(t).filter(e=>e!=="env");for(const e of r)i.includes(e)&&(o[e]=t[e]);for(const e of c)o[e]=t[e];const a=new Set([...c,...i]),d=r.filter(e=>!a.has(e)).map(String);return{merged:o,unverifiedKeys:d}};export{c as NON_INHERITABLE_KEYS,m as mergeWranglerEnvironment};
@@ -0,0 +1 @@
1
+ const t=e=>e.endsWith("S")?e.slice(0,-1):e,r=e=>e.replaceAll(/([a-z\d])([A-Z])/gu,"$1_$2").toUpperCase().split(/[_-]+/u).filter(s=>s.length>0),n=new Set(["CREDENTIAL","DSN","PASSPHRASE","PASSWD","PASSWORD","SECRET","TOKEN"]),c=["ACCESS_KEY","API_KEY","ENCRYPTION_KEY","PRIVATE_KEY","SIGNING_KEY"],p=new RegExp(`(?:${[...n,...c.map(e=>e.replaceAll("_",""))].join("|")})S?$`,"iu"),i=e=>r(e).some(s=>s==="PUBLIC"||s==="PUBLISHABLE"),d=e=>{if(i(e))return!1;const s=r(e);if(s.some(o=>n.has(t(o))))return!0;const a=t(s.join("_"));return c.some(o=>a===o||a.endsWith(`_${o}`))||p.test(e)},h=[{description:"Bearer token the local Lunora Studio uses to call the worker's admin endpoints (data browser, schema edits) in dev. Generate with: openssl rand -hex 32",docsUrl:"https://lunora.sh/docs/packages/studio",key:"LUNORA_ADMIN_TOKEN",placeholderValue:"replace-with-openssl-rand-hex-32"}],u=["BETTER_AUTH_SECRET","STORAGE_SIGNING_SECRET"],l={"@lunora/auth":[{description:"32-byte random secret used to sign sessions and tokens. Generate with: openssl rand -hex 32",docsUrl:"https://lunora.sh/docs/packages/auth#secrets",key:"AUTH_SECRET",placeholderValue:"replace-with-openssl-rand-hex-32"},{description:"Public base URL of your worker (used by better-auth for redirects and cookie domain). For local dev this is typically http://localhost:8787",docsUrl:"https://lunora.sh/docs/packages/auth#secrets",key:"AUTH_URL",placeholderValue:"http://localhost:8787"}],"@lunora/bindings/r2sql":[{description:"Cloudflare API token with R2 SQL read access, for `ctx.r2sql`. Create at https://dash.cloudflare.com/profile/api-tokens with the R2 SQL permission.",docsUrl:"https://lunora.sh/docs/packages/bindings#r2-sql",key:"R2_SQL_TOKEN",placeholderValue:"<your-r2-sql-api-token>"},{description:"Cloudflare account id the R2 SQL queries run against. Falls back to CLOUDFLARE_ACCOUNT_ID when unset.",docsUrl:"https://lunora.sh/docs/packages/bindings#r2-sql",key:"R2_SQL_ACCOUNT_ID",placeholderValue:"<your-cloudflare-account-id>"},{description:"Name of the R2 bucket holding the Iceberg tables `ctx.r2sql` queries.",docsUrl:"https://lunora.sh/docs/packages/bindings#r2-sql",key:"R2_SQL_BUCKET",placeholderValue:"<your-r2-sql-bucket>"}],"@lunora/mail":[{description:"Resend API key for sending transactional email via @lunora/mail. Obtain at https://resend.com/api-keys",docsUrl:"https://lunora.sh/docs/packages/mail#secrets",key:"RESEND_API_KEY",placeholderValue:"<your-resend-api-key>"}],"@lunora/notify:fcm":[{description:"Firebase project id for FCM (HTTP v1) push. Found in the Firebase console project settings.",docsUrl:"https://lunora.sh/docs/packages/notify#fcm",key:"FCM_PROJECT_ID",placeholderValue:"<your-firebase-project-id>"},{description:"OAuth2 access token for FCM (HTTP v1). Convenient for dev but expires — in production supply a getAccessToken() in defineNotify instead. Obtain via the Google Cloud SDK / a service account.",docsUrl:"https://lunora.sh/docs/packages/notify#fcm",key:"FCM_ACCESS_TOKEN",placeholderValue:"<your-fcm-access-token>"}],"@lunora/notify:webPush":[{description:"Public VAPID key (base64url) for Web Push. Generate a keypair once with: npx web-push generate-vapid-keys — the public key is also shipped to the browser to subscribe.",docsUrl:"https://lunora.sh/docs/packages/notify#web-push",key:"VAPID_PUBLIC_KEY",placeholderValue:"<your-vapid-public-key>"},{description:"Private VAPID key (base64url) for Web Push — the application-server signing key. Generate with: npx web-push generate-vapid-keys",docsUrl:"https://lunora.sh/docs/packages/notify#web-push",key:"VAPID_PRIVATE_KEY",placeholderValue:"<your-vapid-private-key>"},{description:"VAPID `sub` contact — a mailto: or https: URL identifying the application server (e.g. mailto:you@example.com).",docsUrl:"https://lunora.sh/docs/packages/notify#web-push",key:"VAPID_SUBJECT",placeholderValue:"mailto:you@example.com"}],"@lunora/payment/autumn":[{description:"Autumn secret key (am_sk_…) for the Autumn payment adapter. Obtain at https://app.useautumn.com/dev",docsUrl:"https://lunora.sh/docs/packages/payment#autumn",key:"AUTUMN_SECRET_KEY",placeholderValue:"<your-autumn-secret-key>"},{description:"Autumn webhook signing secret for verifying Standard Webhooks event payloads. Obtain from your Autumn dashboard webhook settings.",docsUrl:"https://lunora.sh/docs/packages/payment#autumn",key:"AUTUMN_WEBHOOK_SECRET",placeholderValue:"<your-autumn-webhook-secret>"}],"@lunora/payment/creem":[{description:"Creem API key for the Creem payment adapter. Obtain at https://www.creem.io/dashboard/developers",docsUrl:"https://lunora.sh/docs/packages/payment#creem",key:"CREEM_API_KEY",placeholderValue:"<your-creem-api-key>"},{description:"Creem webhook signing secret for verifying the creem-signature header. Obtain from your Creem dashboard webhook settings.",docsUrl:"https://lunora.sh/docs/packages/payment#creem",key:"CREEM_WEBHOOK_SECRET",placeholderValue:"<your-creem-webhook-secret>"}],"@lunora/payment/dodopayments":[{description:"Dodo Payments API key (bearer token) for the Dodo Payments adapter. Obtain at https://app.dodopayments.com/developer/api-keys",docsUrl:"https://lunora.sh/docs/packages/payment#dodo-payments",key:"DODO_PAYMENTS_API_KEY",placeholderValue:"<your-dodo-payments-api-key>"},{description:"Dodo Payments webhook signing secret (whsec_…) for verifying event payloads. Obtain at https://app.dodopayments.com/developer/webhooks",docsUrl:"https://lunora.sh/docs/packages/payment#dodo-payments",key:"DODO_PAYMENTS_WEBHOOK_KEY",placeholderValue:"<your-dodo-payments-webhook-secret>"}],"@lunora/payment/polar":[{description:"Polar access token for the Polar payment adapter. Obtain at https://polar.sh/settings/tokens",docsUrl:"https://lunora.sh/docs/packages/payment#polar",key:"POLAR_ACCESS_TOKEN",placeholderValue:"<your-polar-access-token>"},{description:"Polar webhook secret for verifying event payloads from Polar. Obtain at https://polar.sh/settings/webhooks",docsUrl:"https://lunora.sh/docs/packages/payment#polar",key:"POLAR_WEBHOOK_SECRET",placeholderValue:"<your-polar-webhook-secret>"}],"@lunora/payment/stripe":[{description:"Stripe secret key (sk_test_…). Required when using the Stripe adapter. Obtain at https://dashboard.stripe.com/apikeys",docsUrl:"https://lunora.sh/docs/packages/payment#stripe",key:"STRIPE_SECRET_KEY",placeholderValue:"<your-stripe-secret-key>"},{description:"Stripe webhook signing secret (whsec_…) for verifying event payloads. Obtain at https://dashboard.stripe.com/webhooks",docsUrl:"https://lunora.sh/docs/packages/payment#stripe",key:"STRIPE_WEBHOOK_SECRET",placeholderValue:"<your-stripe-webhook-secret>"}]},y=new Set([...u,...[...h,...Object.values(l).flat()].filter(e=>d(e.key)&&!e.placeholderValue.startsWith("<")).map(e=>e.key)]),k=e=>{const s=[];for(const a of e){const o=l[a];o!==void 0&&s.push(...o)}return s};export{h as C,y as M,l as P,d as a,i,k as s};
@@ -0,0 +1 @@
1
+ import{readFileSync as n}from"node:fs";import{join as s}from"node:path";import{parseDevVariableEntries as i}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";const a=(o,r)=>{const e=i(o).find(t=>t.key===r);return e===void 0||e.value===""?void 0:e.value},d=o=>{let r;try{r=a(n(s(o,".dev.vars"),"utf8"),"LUNORA_ADMIN_TOKEN")}catch{r=void 0}const e=process.env.LUNORA_ADMIN_TOKEN;return typeof e=="string"&&e!==""&&e!==r&&console.warn("[lunora] LUNORA_ADMIN_TOKEN is exported in this shell but differs from .dev.vars — the local worker only verifies the .dev.vars token, so the studio uses that one."),r};export{a as parseDevVariable,d as resolveAdminToken};