@lunora/config 1.0.0-alpha.6 → 1.0.0-alpha.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +6 -0
- package/__assets__/package-og.svg +1 -1
- package/dist/index.d.mts +372 -6
- package/dist/index.d.ts +372 -6
- package/dist/index.mjs +12 -7
- package/dist/packem_shared/AGENT_MODE_ENV-B5R7jpY7.mjs +17 -0
- package/dist/packem_shared/DEV_DAEMON_ENV-FIEtW7Fz.mjs +163 -0
- package/dist/packem_shared/{PACKAGE_SECRETS_REGISTRY-CySy5vR_.mjs → PACKAGE_SECRETS_REGISTRY-BeRSvrl5.mjs} +45 -1
- package/dist/packem_shared/{POLICY_SCAFFOLD_ENDPOINT-CiC2IGKx.mjs → POLICY_SCAFFOLD_ENDPOINT-8bNMHGiu.mjs} +2 -1
- package/dist/packem_shared/{REQUIRED_COMPATIBILITY_DATE-ycqievRl.mjs → REQUIRED_COMPATIBILITY_DATE-DYYxY_If.mjs} +133 -1
- package/dist/packem_shared/assetContentType-ByZjeV3D.mjs +72 -0
- package/dist/packem_shared/{buildPackageSecretsBlock-S74dgmwy.mjs → buildPackageSecretsBlock-BDXX0mKG.mjs} +114 -20
- package/dist/packem_shared/collectWranglerSecretVariables-Red5H-4V.mjs +56 -0
- package/dist/packem_shared/{detectFramework-Br-BcPBq.mjs → detectFramework-U08038Yp.mjs} +3 -3
- package/dist/packem_shared/{discoverSchemaInfo-DWtypqpP.mjs → discoverSchemaInfo-BB-CKlTK.mjs} +1 -1
- package/dist/packem_shared/{inferLunoraBindings-XNJH4pup.mjs → inferLunoraBindings-BadOK1UZ.mjs} +77 -13
- package/dist/packem_shared/{reconcileWranglerBindings-DTHmqTbL.mjs → reconcileWranglerBindings-BZdPBnpZ.mjs} +74 -4
- package/dist/packem_shared/reconcileWranglerCompatibilityDate-CYY0rVnJ.mjs +34 -0
- package/dist/packem_shared/streamContainerLogs-BZ4cOZwH.mjs +157 -0
- package/dist/studio-host/index.d.mts +33 -1
- package/dist/studio-host/index.d.ts +33 -1
- package/dist/studio-host/index.mjs +2 -2
- package/package.json +11 -8
- package/dist/packem_shared/loadStudioAssets-Csk5RS4E.mjs +0 -28
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,25 @@
|
|
|
1
|
-
import { ContainerIR, WorkflowIR } from '@lunora/codegen';
|
|
1
|
+
import { ContainerIR, WorkflowIR, QueueIR, WranglerVariableIR } from '@lunora/codegen';
|
|
2
2
|
export type { ContainerIR, WorkflowIR } from '@lunora/codegen';
|
|
3
|
+
import { Writable } from 'node:stream';
|
|
3
4
|
import 'ts-morph';
|
|
4
5
|
export { type A as AdditivePolicyEdit, type D as DestructivePolicyEdit, type P as PolicyEdit, type a as PolicyScaffoldFailureReason, type b as ScaffoldFileResult, type S as ScaffoldPolicyEdit, type c as WireResult, type W as WireRlsEdit, d as classifyPolicyEdit, s as scaffoldPolicyFile, w as wireRlsIntoProcedure } from "./packem_shared/policy-scaffold.d-DCmwn7zQ.mjs";
|
|
6
|
+
/** Minimal env shape — `process.env` structurally, injectable for tests. */
|
|
7
|
+
type EnvLike = Readonly<Record<string, string | undefined>>;
|
|
8
|
+
/** One detected agent: which tool, and which env var gave it away. */
|
|
9
|
+
interface AgentDetection {
|
|
10
|
+
/** Human-readable agent name, for the "agent detected" log line. */
|
|
11
|
+
name: string;
|
|
12
|
+
/** The environment variable that matched. */
|
|
13
|
+
variable: string;
|
|
14
|
+
}
|
|
15
|
+
/** Env var that forces agent mode on (`1`/`true`) or off (`0`/`false`), overriding detection. */
|
|
16
|
+
declare const AGENT_MODE_ENV = "LUNORA_AGENT_MODE";
|
|
17
|
+
/**
|
|
18
|
+
* Detect the AI agent driving this process, or `undefined` when none is.
|
|
19
|
+
* `LUNORA_AGENT_MODE` wins over `@visulima/find-ai-runner`'s marker table in
|
|
20
|
+
* both directions. Pure — pass a custom `env` in tests.
|
|
21
|
+
*/
|
|
22
|
+
declare const detectAiAgent: (env?: EnvLike) => AgentDetection | undefined;
|
|
5
23
|
/**
|
|
6
24
|
* Project-relative directory the Lunora agent skills ("rules") install into.
|
|
7
25
|
* This is the portable [Agent Skills](https://tanstack.com/intent/latest/docs/registry)
|
|
@@ -65,6 +83,77 @@ interface DiscoverContainerInfoResult {
|
|
|
65
83
|
* (inference).
|
|
66
84
|
*/
|
|
67
85
|
declare const discoverContainerInfo: (projectRoot: string, schemaDirectory: string) => DiscoverContainerInfoResult;
|
|
86
|
+
/** Severity a container output line is surfaced at: `stderr` → `error`, `stdout` → `info`. */
|
|
87
|
+
type ContainerLogLevel = "error" | "info";
|
|
88
|
+
/** One declared container to follow, identified by the names codegen lifts from `defineContainer`. */
|
|
89
|
+
interface ContainerLogSource {
|
|
90
|
+
/** Generated Durable Object class name, e.g. `TranscoderContainer`. Wrangler's dev image is `cloudflare-dev/<lowercased>`. */
|
|
91
|
+
className: string;
|
|
92
|
+
/** The `lunora/containers.ts` export name, e.g. `transcoder` — used as the display tag. */
|
|
93
|
+
exportName: string;
|
|
94
|
+
}
|
|
95
|
+
/** A single line of container output handed back to the caller. */
|
|
96
|
+
interface ContainerLogLine {
|
|
97
|
+
/** `"error"` for the container's stderr, `"info"` for its stdout. */
|
|
98
|
+
level: ContainerLogLevel;
|
|
99
|
+
/** The container's export name (`transcoder`), for tagging the line. */
|
|
100
|
+
name: string;
|
|
101
|
+
/** One output line, with the trailing newline (and any `\r`) stripped. */
|
|
102
|
+
text: string;
|
|
103
|
+
}
|
|
104
|
+
interface ContainerLogStreamOptions {
|
|
105
|
+
/** The declared containers to follow. An empty list yields an inert handle. */
|
|
106
|
+
containers: ReadonlyArray<ContainerLogSource>;
|
|
107
|
+
/** Injected Docker client — defaults to a real lazily-imported `dockerode` instance. Tests pass a stub. */
|
|
108
|
+
docker?: DockerLike;
|
|
109
|
+
/** Called once per container output line. */
|
|
110
|
+
onLine: (line: ContainerLogLine) => void;
|
|
111
|
+
/** Called once when the Docker engine can't be reached (re-armed after it recovers). Defaults to silent. */
|
|
112
|
+
onUnavailable?: (message: string) => void;
|
|
113
|
+
/** Poll interval override, in ms. */
|
|
114
|
+
pollIntervalMs?: number;
|
|
115
|
+
}
|
|
116
|
+
/** Handle controlling a running log stream. */
|
|
117
|
+
interface ContainerLogStreamHandle {
|
|
118
|
+
/** Stop polling and tear down every attached log stream. Idempotent. */
|
|
119
|
+
close: () => void;
|
|
120
|
+
}
|
|
121
|
+
/** The minimal structural slice of a `dockerode` log stream this module consumes. */
|
|
122
|
+
interface DockerLogStream {
|
|
123
|
+
destroy: () => void;
|
|
124
|
+
on: (event: "data" | "end" | "error", listener: (chunk?: Buffer) => void) => void;
|
|
125
|
+
}
|
|
126
|
+
/** The minimal structural slice of a `dockerode` instance this module consumes. */
|
|
127
|
+
interface DockerLike {
|
|
128
|
+
getContainer: (id: string) => {
|
|
129
|
+
logs: (options: {
|
|
130
|
+
follow: true;
|
|
131
|
+
stderr: true;
|
|
132
|
+
stdout: true;
|
|
133
|
+
tail: "all";
|
|
134
|
+
timestamps: false;
|
|
135
|
+
}) => Promise<DockerLogStream>;
|
|
136
|
+
};
|
|
137
|
+
listContainers: (options: {
|
|
138
|
+
filters: {
|
|
139
|
+
status: ["running"];
|
|
140
|
+
};
|
|
141
|
+
}) => Promise<{
|
|
142
|
+
Id: string;
|
|
143
|
+
Image: string;
|
|
144
|
+
}[]>;
|
|
145
|
+
modem: {
|
|
146
|
+
demuxStream: (stream: DockerLogStream, stdout: Writable, stderr: Writable) => void;
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Follow the local Docker logs of every declared container, emitting each output
|
|
151
|
+
* line through `onLine` tagged with its export name. Polls for containers (they
|
|
152
|
+
* start lazily on first request and may be replaced on restart), attaches once
|
|
153
|
+
* per container id, and drops streams whose container has gone. Returns
|
|
154
|
+
* immediately with a `close()` handle; all work happens asynchronously.
|
|
155
|
+
*/
|
|
156
|
+
declare const streamContainerLogs: (options: ContainerLogStreamOptions) => ContainerLogStreamHandle;
|
|
68
157
|
/**
|
|
69
158
|
* The meta-frameworks Lunora can compose with, plus `"none"` for a standalone
|
|
70
159
|
* SPA / SSR-less project (the current default). Mirrors PLAN4 §2.4.
|
|
@@ -85,6 +174,13 @@ interface FrameworkDetection {
|
|
|
85
174
|
framework: DetectedFramework;
|
|
86
175
|
}
|
|
87
176
|
/**
|
|
177
|
+
* Read and parse the project `package.json`, returning its merged
|
|
178
|
+
* `dependencies` + `devDependencies` name set (empty on any failure). Public
|
|
179
|
+
* so sibling consumers (e.g. the CLI's Vite-project detection) share one
|
|
180
|
+
* best-effort reader instead of re-parsing `package.json` themselves.
|
|
181
|
+
*/
|
|
182
|
+
declare const readProjectDependencyNames: (root: string) => ReadonlySet<string>;
|
|
183
|
+
/**
|
|
88
184
|
* Detect which meta-framework a project uses by inspecting its `package.json`
|
|
89
185
|
* dependencies, and classify it under void's class-A/B/C model (PLAN4 §3).
|
|
90
186
|
*
|
|
@@ -93,6 +189,112 @@ interface FrameworkDetection {
|
|
|
93
189
|
* SPA flow is preserved.
|
|
94
190
|
*/
|
|
95
191
|
declare const detectFramework: (root: string) => FrameworkDetection;
|
|
192
|
+
/** Directory holding per-checkout Lunora state (gitignored by convention). */
|
|
193
|
+
declare const DEV_STATE_DIR = ".lunora";
|
|
194
|
+
/** The dev-server state filename, relative to the project root. */
|
|
195
|
+
declare const DEV_STATE_FILE: string;
|
|
196
|
+
/** Log file a backgrounded dev server's output is captured to, relative to the project root. */
|
|
197
|
+
declare const DEV_LOG_FILE: string;
|
|
198
|
+
/**
|
|
199
|
+
* Marker env `lunora dev --background` sets on the detached server process
|
|
200
|
+
* (the daemon `lunora dev` or `vite dev`), so it records itself as
|
|
201
|
+
* `background: true` — and, for the CLI daemon, never re-detects an agent and
|
|
202
|
+
* recurses into background mode again.
|
|
203
|
+
*/
|
|
204
|
+
declare const DEV_DAEMON_ENV = "LUNORA_DEV_DAEMON";
|
|
205
|
+
/** Env carrying the capture-log path into the detached server, recorded in the state file. */
|
|
206
|
+
declare const DEV_LOG_FILE_ENV = "LUNORA_DEV_LOG_FILE";
|
|
207
|
+
/**
|
|
208
|
+
* Env carrying the PID of a parent that holds a *provisional* state record it
|
|
209
|
+
* expects the child dev server to supersede. The CLI claims `.lunora/dev.json`
|
|
210
|
+
* with its own PID before spawning the real server (closing the duplicate-start
|
|
211
|
+
* race for the vite flavor and the wrangler daemon), then hands its PID down
|
|
212
|
+
* via this variable; the child's claim (see {@link claimDevServerState}'s
|
|
213
|
+
* `supersedePid`) may replace exactly that record with the authoritative
|
|
214
|
+
* URL + PID.
|
|
215
|
+
*/
|
|
216
|
+
declare const DEV_HANDOFF_ENV = "LUNORA_DEV_HANDOFF_PID";
|
|
217
|
+
/** How the recorded dev server runs. */
|
|
218
|
+
type DevServerMode = "cli" | "vite";
|
|
219
|
+
/** The state record persisted to `.lunora/dev.json`. */
|
|
220
|
+
interface DevServerState {
|
|
221
|
+
/** Whether the server was detached into the background (`lunora dev --background`). */
|
|
222
|
+
background?: boolean;
|
|
223
|
+
/** Absolute path of the log file capturing the server's output, when captured. */
|
|
224
|
+
logFile?: string;
|
|
225
|
+
/** `"cli"` for the `lunora dev` wrangler orchestration, `"vite"` for a Vite dev server. */
|
|
226
|
+
mode: DevServerMode;
|
|
227
|
+
/** PID of the process to signal for shutdown (the orchestrating CLI or the Vite process). */
|
|
228
|
+
pid: number;
|
|
229
|
+
/** ISO-8601 stamp written at startup, purely informational (drives `status` uptime). */
|
|
230
|
+
startedAt?: string;
|
|
231
|
+
/** The embedded studio server's URL, when it runs. */
|
|
232
|
+
studioUrl?: string;
|
|
233
|
+
/** The primary URL serving the worker/app. */
|
|
234
|
+
url: string;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* True when a process with `pid` is currently alive AND signalable by this
|
|
238
|
+
* user. Signal `0` performs the existence check without delivering anything.
|
|
239
|
+
*
|
|
240
|
+
* `EPERM` ("alive but another user's process") deliberately counts as NOT
|
|
241
|
+
* alive here: every dev server this module tracks was spawned by the current
|
|
242
|
+
* user, so a PID we cannot signal is by definition a recycled PID — treating
|
|
243
|
+
* it as running would wedge the lockfile permanently and aim `dev stop`'s
|
|
244
|
+
* kill escalation at an innocent process.
|
|
245
|
+
*/
|
|
246
|
+
declare const isProcessAlive: (pid: number) => boolean;
|
|
247
|
+
/**
|
|
248
|
+
* True when the record's PID verifiably still refers to the dev server that
|
|
249
|
+
* wrote the record — not merely "some process exists with that number".
|
|
250
|
+
* Guards against PID reuse: a server process necessarily starts BEFORE its
|
|
251
|
+
* record is written, so a process that started after `startedAt` (+ skew) is
|
|
252
|
+
* a recycled PID wearing the corpse's number. The start-time check runs only
|
|
253
|
+
* where the platform exposes it (Linux); elsewhere liveness alone decides.
|
|
254
|
+
*/
|
|
255
|
+
declare const isRecordedProcessCurrent: (state: DevServerState) => boolean;
|
|
256
|
+
/**
|
|
257
|
+
* Read the state record from `.lunora/dev.json`, or `undefined` when there is
|
|
258
|
+
* no usable record. Best-effort; performs NO liveness check — use
|
|
259
|
+
* {@link readLiveDevServerState} for "is a dev server actually running".
|
|
260
|
+
*/
|
|
261
|
+
declare const readDevServerState: (projectRoot: string) => DevServerState | undefined;
|
|
262
|
+
/**
|
|
263
|
+
* Write the state record to `.lunora/dev.json`, creating the `.lunora/`
|
|
264
|
+
* directory when absent. Returns the absolute path written, or `undefined`
|
|
265
|
+
* when the write failed (state is convenience metadata — a read-only checkout
|
|
266
|
+
* must never crash dev startup).
|
|
267
|
+
*/
|
|
268
|
+
declare const writeDevServerState: (projectRoot: string, state: DevServerState) => string | undefined;
|
|
269
|
+
/**
|
|
270
|
+
* Merge `patch` into the existing state record, when one exists. Used by the
|
|
271
|
+
* CLI to stamp `background`/`logFile` onto the record the Vite plugin wrote.
|
|
272
|
+
* Returns the merged record, or `undefined` when there was nothing to update.
|
|
273
|
+
*/
|
|
274
|
+
declare const updateDevServerState: (projectRoot: string, patch: Partial<DevServerState>) => DevServerState | undefined;
|
|
275
|
+
/**
|
|
276
|
+
* Remove `.lunora/dev.json`. Idempotent and never throws. When `expectedPid`
|
|
277
|
+
* is given, the file is only removed while it still records that PID — so a
|
|
278
|
+
* shutting-down server can't clobber the record a newer server just wrote.
|
|
279
|
+
*/
|
|
280
|
+
declare const clearDevServerState: (projectRoot: string, expectedPid?: number) => void;
|
|
281
|
+
/**
|
|
282
|
+
* The state record of a dev server that is verifiably running right now, or
|
|
283
|
+
* `undefined`. A record whose PID is dead — or recycled onto a different
|
|
284
|
+
* process (see {@link isRecordedProcessCurrent}) — is stale: it is cleared on
|
|
285
|
+
* the spot so subsequent starts don't keep re-reading a corpse.
|
|
286
|
+
*/
|
|
287
|
+
declare const readLiveDevServerState: (projectRoot: string) => DevServerState | undefined;
|
|
288
|
+
/** Result of {@link claimDevServerState}: claimed, or lost to the live server already recorded. */
|
|
289
|
+
interface ClaimDevServerStateResult {
|
|
290
|
+
/** The live record that won the race, when `ok` is `false`. */
|
|
291
|
+
existing?: DevServerState;
|
|
292
|
+
/** Whether this process now owns the record. */
|
|
293
|
+
ok: boolean;
|
|
294
|
+
}
|
|
295
|
+
declare const claimDevServerState: (projectRoot: string, state: DevServerState, options?: {
|
|
296
|
+
supersedePid?: number;
|
|
297
|
+
}) => ClaimDevServerStateResult;
|
|
96
298
|
/**
|
|
97
299
|
* The `.dev.vars` line grammar — one owner, shared by every reader/writer of the
|
|
98
300
|
* file so the format can't drift between packages. `@lunora/cli`'s `env`
|
|
@@ -156,39 +358,61 @@ interface InferredContainer extends ContainerIR {
|
|
|
156
358
|
interface InferredWorkflow extends WorkflowIR {
|
|
157
359
|
exported: boolean;
|
|
158
360
|
}
|
|
361
|
+
/**
|
|
362
|
+
* A queue declared in `lunora/queues.ts`. Unlike workflows, a queue needs no
|
|
363
|
+
* worker-entry class export (its `queue()` handler rides `createWorker`), so
|
|
364
|
+
* there is no `exported` flag — every declared queue is reconcilable into the
|
|
365
|
+
* wrangler `queues.producers[]` / `queues.consumers[]`.
|
|
366
|
+
*/
|
|
367
|
+
type InferredQueue = QueueIR;
|
|
159
368
|
interface InferredBindings {
|
|
160
369
|
/** Containers declared in `lunora/containers.ts` (exported or not — see {@link InferredContainer.exported}). */
|
|
161
370
|
containers: InferredContainer[];
|
|
162
371
|
/** Durable Objects the worker entry exports → safe to bind. */
|
|
163
372
|
durableObjects: DurableObjectSpec[];
|
|
373
|
+
/**
|
|
374
|
+
* The wrangler `flagship[].binding` name implied by `lunora/flags.ts` when it
|
|
375
|
+
* uses the Flagship provider in binding mode — `undefined` for HTTP-mode
|
|
376
|
+
* Flagship, a custom OpenFeature provider, or no flags. The binding needs an
|
|
377
|
+
* un-mintable `app_id`, so it is reconciled as a hint, not auto-written.
|
|
378
|
+
*/
|
|
379
|
+
flagshipBinding?: string;
|
|
164
380
|
/** Schema declares a `.global()` table → needs the `DB` D1 binding. */
|
|
165
381
|
needsD1: boolean;
|
|
382
|
+
/** Queues declared in `lunora/queues.ts` → reconciled into `queues.producers[]` / `queues.consumers[]`. */
|
|
383
|
+
queues: InferredQueue[];
|
|
166
384
|
/** Human-readable provenance for each inferred binding / hint, for logging. */
|
|
167
385
|
signals: string[];
|
|
168
386
|
/** `@lunora/ai` is imported or `env.AI` is used → needs the `ai` Workers AI binding. */
|
|
169
387
|
usesAi: boolean;
|
|
170
|
-
/** `@lunora/analytics` is imported → self-describing `analytics_engine_datasets` binding (auto-writeable). */
|
|
388
|
+
/** `@lunora/bindings/analytics` is imported → self-describing `analytics_engine_datasets` binding (auto-writeable). */
|
|
171
389
|
usesAnalytics: boolean;
|
|
172
390
|
/** `@lunora/auth` is imported (sessions may be D1- or `SessionDO`-backed). */
|
|
173
391
|
usesAuth: boolean;
|
|
174
392
|
/** `@lunora/browser` is imported → self-describing `browser` binding (auto-writeable). */
|
|
175
393
|
usesBrowser: boolean;
|
|
394
|
+
/** `lunora/flags.ts` declares a feature-flag provider (any OpenFeature provider — Flagship or custom). */
|
|
395
|
+
usesFlags: boolean;
|
|
176
396
|
/** `@lunora/hyperdrive` is imported (binding needs an un-mintable remote `id`; hint-only). */
|
|
177
397
|
usesHyperdrive: boolean;
|
|
178
|
-
/** `@lunora/images` is imported → self-describing `images` binding (auto-writeable). */
|
|
398
|
+
/** `@lunora/bindings/images` is imported → self-describing `images` binding (auto-writeable). */
|
|
179
399
|
usesImages: boolean;
|
|
180
|
-
/** `@lunora/kv` is imported (namespace binding name + id are user-defined; hint-only). */
|
|
400
|
+
/** `@lunora/bindings/kv` is imported (namespace binding name + id are user-defined; hint-only). */
|
|
181
401
|
usesKv: boolean;
|
|
182
402
|
/** `@lunora/mail` is imported (Resend API key must be set in `.dev.vars`; no binding). */
|
|
183
403
|
usesMail: boolean;
|
|
184
404
|
/** `@lunora/payment` is imported (provider secrets must be set in `.dev.vars`; no binding). */
|
|
185
405
|
usesPayment: boolean;
|
|
186
|
-
/**
|
|
406
|
+
/** `ctx.pipelines` is used (binding needs an un-mintable remote pipeline name; hint-only). */
|
|
187
407
|
usesPipelines: boolean;
|
|
188
408
|
/** `@lunora/scheduler` is imported. */
|
|
189
409
|
usesScheduler: boolean;
|
|
190
410
|
/** `@lunora/storage` is imported (R2 bucket binding name is user-defined). */
|
|
191
411
|
usesStorage: boolean;
|
|
412
|
+
/** `@lunora/x402/charge` is imported — the charge rail settles USDC to a recipient address (a public `[vars]` entry, user-named; hint-only). */
|
|
413
|
+
usesX402Charge: boolean;
|
|
414
|
+
/** `@lunora/x402/pay` is imported — the agent-wallet pay rail signs from a Secrets Store binding paired with a spend policy (ActionCtx-only; hint-only). */
|
|
415
|
+
usesX402Pay: boolean;
|
|
192
416
|
/** Workflows declared in `lunora/workflows.ts` (exported or not — see {@link InferredWorkflow.exported}). */
|
|
193
417
|
workflows: InferredWorkflow[];
|
|
194
418
|
}
|
|
@@ -338,6 +562,15 @@ interface SecretEntry {
|
|
|
338
562
|
*/
|
|
339
563
|
placeholderValue: string;
|
|
340
564
|
}
|
|
565
|
+
/**
|
|
566
|
+
* Secrets every Lunora project needs regardless of which capability packages are
|
|
567
|
+
* installed — scaffolded into `.dev.vars` always. `LUNORA_ADMIN_TOKEN` is the
|
|
568
|
+
* bearer the local Studio uses to call the worker's admin endpoints (the data
|
|
569
|
+
* browser, schema edits) in dev; the worker reads the SAME `.dev.vars` value via
|
|
570
|
+
* its admin gate, so both agree and the Studio authenticates without a prompt.
|
|
571
|
+
* Without it, every `/_lunora/admin/*` call is `ADMIN_FORBIDDEN` (403).
|
|
572
|
+
*/
|
|
573
|
+
|
|
341
574
|
/**
|
|
342
575
|
* The canonical registry of per-package secret requirements.
|
|
343
576
|
*
|
|
@@ -488,6 +721,21 @@ interface ReconcileBindingsResult {
|
|
|
488
721
|
* config already satisfies the inferred needs.
|
|
489
722
|
*/
|
|
490
723
|
declare const reconcileWranglerBindings: (projectRoot: string, inferred: InferredBindings) => ReconcileBindingsResult;
|
|
724
|
+
interface ReconcileCompatibilityDateResult {
|
|
725
|
+
/** `true` when `wrangler.jsonc` was rewritten. */
|
|
726
|
+
changed: boolean;
|
|
727
|
+
/** The new date value, or the existing one when unchanged. */
|
|
728
|
+
date: string | undefined;
|
|
729
|
+
/** Human-readable reason when reconciliation was skipped. */
|
|
730
|
+
reason?: string;
|
|
731
|
+
/** Resolved wrangler path, or `undefined` when none was found. */
|
|
732
|
+
wranglerPath?: string;
|
|
733
|
+
}
|
|
734
|
+
/**
|
|
735
|
+
* Reconcile the `compatibility_date` in `wrangler.jsonc` when Workers Cache
|
|
736
|
+
* is enabled but the date is below the minimum required.
|
|
737
|
+
*/
|
|
738
|
+
declare const reconcileWranglerCompatibilityDate: (projectRoot: string) => ReconcileCompatibilityDateResult;
|
|
491
739
|
/**
|
|
492
740
|
* The wrangler config sections Lunora can safely flip to remote mode in dev,
|
|
493
741
|
* each with the human label used in logs and the structural `shape` the entry
|
|
@@ -659,6 +907,8 @@ interface RemoteEnableInputs {
|
|
|
659
907
|
* is still overridable per-run by `--remote` or `LUNORA_REMOTE=1`.
|
|
660
908
|
*/
|
|
661
909
|
declare const resolveRemoteEnabled: (inputs: RemoteEnableInputs) => boolean;
|
|
910
|
+
/** Core (always-scaffolded) secrets followed by the package-specific ones for the detected capabilities. */
|
|
911
|
+
declare const requiredSecrets: (packageNames: ReadonlyArray<string>) => SecretEntry[];
|
|
662
912
|
/**
|
|
663
913
|
* Whether an (already-unquoted) value looks like a fill-me-in placeholder —
|
|
664
914
|
* empty, angle-bracketed, or containing a known marker — rather than a real
|
|
@@ -667,6 +917,15 @@ declare const resolveRemoteEnabled: (inputs: RemoteEnableInputs) => boolean;
|
|
|
667
917
|
*/
|
|
668
918
|
declare const isPlaceholderValue: (value: string) => boolean;
|
|
669
919
|
/**
|
|
920
|
+
* True for a secret-looking key whose value Lunora can mint locally (a random
|
|
921
|
+
* 32-byte hex, like `openssl rand -hex 32`) — e.g. `AUTH_SECRET`,
|
|
922
|
+
* `LUNORA_ADMIN_TOKEN`, `STORAGE_SIGNING_SECRET`. False for provider-issued keys
|
|
923
|
+
* ({@link PROVIDER_SECRET_KEYS}) and any non-secret key.
|
|
924
|
+
*/
|
|
925
|
+
declare const isMintableSecretKey: (key: string) => boolean;
|
|
926
|
+
/** Mint a fresh strong secret value — 64 hex chars (32 bytes), like `openssl rand -hex 32`. */
|
|
927
|
+
declare const generateSecretValue: (randomHex?: (bytes: number) => string) => string;
|
|
928
|
+
/**
|
|
670
929
|
* The outcome of planning a scaffold — a discriminated union so the orchestrator
|
|
671
930
|
* never has to re-derive whether `content` is present.
|
|
672
931
|
*
|
|
@@ -768,6 +1027,58 @@ declare const buildPackageSecretsBlock: (packageNames: ReadonlyArray<string>, ex
|
|
|
768
1027
|
* **Safety invariant:** only placeholder values are written — no real secrets.
|
|
769
1028
|
*/
|
|
770
1029
|
declare const ensureDevVariablesExample: (cwd: string, packageNames: ReadonlyArray<string>) => string[];
|
|
1030
|
+
interface DevSecretsFillPlan {
|
|
1031
|
+
/** {@link CORE_SECRETS} keys appended because they were absent (each generated). */
|
|
1032
|
+
addedKeys: string[];
|
|
1033
|
+
/** The full new file content to write. */
|
|
1034
|
+
content: string;
|
|
1035
|
+
/** Existing empty/placeholder secret-keyed entries filled with fresh values. */
|
|
1036
|
+
filledKeys: string[];
|
|
1037
|
+
}
|
|
1038
|
+
/**
|
|
1039
|
+
* Plan the in-place generation of dev secrets for a `.dev.vars`. First, every
|
|
1040
|
+
* line whose KEY looks like a secret (`*_SECRET`, `*_TOKEN`, `*_KEY`,
|
|
1041
|
+
* `*_PASSWORD`) and whose value is empty or a placeholder gets a freshly
|
|
1042
|
+
* generated value — so a `lunora add`-scaffolded `.dev.vars` (which writes each
|
|
1043
|
+
* secret blank) becomes usable on `lunora dev` / `vite dev` without the user
|
|
1044
|
+
* running `openssl` by hand. Second, any {@link CORE_SECRETS} key absent from
|
|
1045
|
+
* the file is appended (generated) — notably `LUNORA_ADMIN_TOKEN`, which the
|
|
1046
|
+
* local Studio needs to call the worker's admin gate in dev (without it the
|
|
1047
|
+
* Studio shows its login gate).
|
|
1048
|
+
*
|
|
1049
|
+
* Pure (given `randomHex`): real (non-placeholder) values are never touched, and
|
|
1050
|
+
* comments + non-secret entries are preserved verbatim.
|
|
1051
|
+
*/
|
|
1052
|
+
declare const planDevSecretsFill: (input: {
|
|
1053
|
+
existingContent: string;
|
|
1054
|
+
randomHex?: (bytes: number) => string;
|
|
1055
|
+
}) => DevSecretsFillPlan;
|
|
1056
|
+
interface FillDevSecretsResult {
|
|
1057
|
+
/** Core secret keys appended (generated) because they were missing. */
|
|
1058
|
+
addedKeys: string[];
|
|
1059
|
+
/** Existing empty/placeholder secrets filled with generated values. */
|
|
1060
|
+
filledKeys: string[];
|
|
1061
|
+
/** `created` = no `.dev.vars` existed; `filled` = topped up an existing one; `unchanged` = nothing to do. */
|
|
1062
|
+
status: "created" | "filled" | "unchanged";
|
|
1063
|
+
}
|
|
1064
|
+
/**
|
|
1065
|
+
* Generate any missing/empty dev secrets in the project's `.dev.vars`, in place.
|
|
1066
|
+
*
|
|
1067
|
+
* Complements {@link ensureDevVariables} (which scaffolds `.dev.vars` from
|
|
1068
|
+
* `.dev.vars.example`). A `lunora add`-scaffolded project writes secrets blank
|
|
1069
|
+
* straight into `.dev.vars` (no example) and never includes `LUNORA_ADMIN_TOKEN`
|
|
1070
|
+
* — so the worker boots with empty secrets and the Studio shows its login gate.
|
|
1071
|
+
* This fills those gaps at dev startup, so both `lunora dev` and the
|
|
1072
|
+
* `@lunora/vite` dev server give a working project with zero manual `openssl`.
|
|
1073
|
+
*
|
|
1074
|
+
* Never overwrites a real (non-placeholder) value. The write is atomic + owner-
|
|
1075
|
+
* only (temp + rename, `mode: 0o600`), matching the other `.dev.vars` writers.
|
|
1076
|
+
*/
|
|
1077
|
+
declare const fillDevSecrets: (deps: {
|
|
1078
|
+
cwd: string;
|
|
1079
|
+
info?: (message: string) => void;
|
|
1080
|
+
randomHex?: (bytes: number) => string;
|
|
1081
|
+
}) => FillDevSecretsResult;
|
|
771
1082
|
/** Add a new table to `defineSchema({ ... })`. */
|
|
772
1083
|
interface AddTableEdit {
|
|
773
1084
|
readonly kind: "addTable";
|
|
@@ -964,6 +1275,23 @@ interface ReadWranglerResult<T> {
|
|
|
964
1275
|
* wrangler does.
|
|
965
1276
|
*/
|
|
966
1277
|
declare const readWranglerJsonc: <T = unknown>(wranglerPath: string) => ReadWranglerResult<T>;
|
|
1278
|
+
/**
|
|
1279
|
+
* Pure scan of a `vars` map for plaintext secrets — the FS-free core, exported for
|
|
1280
|
+
* unit tests. A variable is flagged when, for a **string** value that is neither a
|
|
1281
|
+
* placeholder nor a public/publishable key, EITHER the value matches a known
|
|
1282
|
+
* secret shape (`secretKindOf`) OR the key name strongly implies a secret and the
|
|
1283
|
+
* value is long enough to plausibly be one. `kind` is the matched shape, or
|
|
1284
|
+
* `secret_named_var` for the key-name path.
|
|
1285
|
+
*/
|
|
1286
|
+
declare const scanWranglerVariablesForSecrets: (variables: Record<string, unknown> | undefined, file: string) => WranglerVariableIR[];
|
|
1287
|
+
/**
|
|
1288
|
+
* Read the project's `wrangler.jsonc` and return its plaintext-secret `vars` as IR
|
|
1289
|
+
* for the `plaintext_secret_in_wrangler_vars` lint. Returns `[]` when there is no
|
|
1290
|
+
* wrangler config, it doesn't parse, or nothing looks like a secret. Scans the
|
|
1291
|
+
* top-level `vars` block (mirroring the existing `validateCorsVariables` scope);
|
|
1292
|
+
* per-environment `env.<name>.vars` overrides are out of scope for now.
|
|
1293
|
+
*/
|
|
1294
|
+
declare const collectWranglerSecretVariables: (projectRoot: string) => WranglerVariableIR[];
|
|
967
1295
|
declare const REQUIRED_COMPATIBILITY_DATE: string;
|
|
968
1296
|
declare const REQUIRED_FLAG: string;
|
|
969
1297
|
interface WranglerDurableObjectBinding {
|
|
@@ -1002,6 +1330,22 @@ interface WranglerWorkflowEntry {
|
|
|
1002
1330
|
class_name?: string;
|
|
1003
1331
|
name?: string;
|
|
1004
1332
|
}
|
|
1333
|
+
/** A wrangler `queues.producers[]` entry — a `Queue` binding sending to `queue`. */
|
|
1334
|
+
interface WranglerQueueProducer {
|
|
1335
|
+
binding?: string;
|
|
1336
|
+
delivery_delay?: number;
|
|
1337
|
+
queue?: string;
|
|
1338
|
+
}
|
|
1339
|
+
/** A wrangler `queues.consumers[]` entry — push (worker) or `type: "http_pull"`. */
|
|
1340
|
+
interface WranglerQueueConsumer {
|
|
1341
|
+
dead_letter_queue?: string;
|
|
1342
|
+
max_batch_size?: number;
|
|
1343
|
+
max_batch_timeout?: number;
|
|
1344
|
+
max_retries?: number;
|
|
1345
|
+
queue?: string;
|
|
1346
|
+
retry_delay?: number;
|
|
1347
|
+
type?: string;
|
|
1348
|
+
}
|
|
1005
1349
|
interface WranglerConfig {
|
|
1006
1350
|
analytics_engine_datasets?: ReadonlyArray<{
|
|
1007
1351
|
binding?: string;
|
|
@@ -1016,6 +1360,9 @@ interface WranglerConfig {
|
|
|
1016
1360
|
browser?: {
|
|
1017
1361
|
binding?: string;
|
|
1018
1362
|
};
|
|
1363
|
+
cache?: {
|
|
1364
|
+
enabled?: boolean;
|
|
1365
|
+
} | null;
|
|
1019
1366
|
compatibility_date?: string;
|
|
1020
1367
|
compatibility_flags?: ReadonlyArray<string>;
|
|
1021
1368
|
containers?: ReadonlyArray<WranglerContainerEntry | null | undefined>;
|
|
@@ -1030,6 +1377,16 @@ interface WranglerConfig {
|
|
|
1030
1377
|
durable_objects?: {
|
|
1031
1378
|
bindings?: ReadonlyArray<WranglerDurableObjectBinding>;
|
|
1032
1379
|
};
|
|
1380
|
+
exports?: Record<string, {
|
|
1381
|
+
cache?: {
|
|
1382
|
+
enabled?: boolean;
|
|
1383
|
+
} | null;
|
|
1384
|
+
type?: string;
|
|
1385
|
+
} | null> | null;
|
|
1386
|
+
flagship?: ReadonlyArray<{
|
|
1387
|
+
app_id?: string;
|
|
1388
|
+
binding?: string;
|
|
1389
|
+
} | null | undefined>;
|
|
1033
1390
|
hyperdrive?: ReadonlyArray<{
|
|
1034
1391
|
binding?: string;
|
|
1035
1392
|
id?: string;
|
|
@@ -1066,9 +1423,18 @@ interface WranglerConfig {
|
|
|
1066
1423
|
placement?: {
|
|
1067
1424
|
mode?: string;
|
|
1068
1425
|
};
|
|
1426
|
+
queues?: {
|
|
1427
|
+
consumers?: ReadonlyArray<WranglerQueueConsumer | null | undefined>;
|
|
1428
|
+
producers?: ReadonlyArray<WranglerQueueProducer | null | undefined>;
|
|
1429
|
+
};
|
|
1069
1430
|
r2_buckets?: ReadonlyArray<{
|
|
1070
1431
|
binding?: string;
|
|
1071
1432
|
}>;
|
|
1433
|
+
secrets_store_secrets?: ReadonlyArray<{
|
|
1434
|
+
binding?: string;
|
|
1435
|
+
secret_name?: string;
|
|
1436
|
+
store_id?: string;
|
|
1437
|
+
} | null | undefined>;
|
|
1072
1438
|
send_email?: ReadonlyArray<{
|
|
1073
1439
|
allowed_destination_addresses?: ReadonlyArray<string>;
|
|
1074
1440
|
destination_address?: string;
|
|
@@ -1128,4 +1494,4 @@ interface WranglerProjectValidationResult {
|
|
|
1128
1494
|
* `{ problems, wranglerPath }` shape plus the structured `report`.
|
|
1129
1495
|
*/
|
|
1130
1496
|
declare const validateWranglerProject: (options: WranglerProjectValidationOptions) => WranglerProjectValidationResult;
|
|
1131
|
-
export { ACCENT, AGENT_RULES_DIR, AGENT_RULES_HINT, AGENT_RULES_HINT_ENV, type AddIndexEdit, type AddOptionalColumnEdit, type AddTableEdit, type AdditiveEdit, type AgentRulesStatus, type ApplyEditResult, type ApplyFailureReason, type AugmentPlan, BADGES, BADGE_COLUMN_WIDTH, type BadgeName, type BadgeSpec, DEV_VARS_EXAMPLE_FILE, DEV_VARS_FILE, DEV_VARS_KEY_PATTERN, type DestructiveEdit, type DetectedFramework, type DiscoverContainerInfoResult, type DiscoverSchemaInfoResult, type DiscoverWorkflowInfoResult, type EnsureDevVariablesDeps, type EnsureDevVariablesResult, type EnsureDevVariablesStatus, type ExportGap, type FrameworkClass, type FrameworkDetection, type InferOptions, type InferredBindings, type InferredContainer, type InferredWorkflow, LINKED_PROJECT_DIR, LINKED_PROJECT_FILE, LUNA_ART, LUNA_BUNNY, LUNA_NAME, LUNA_SIGNOFF, LUNORA_CONFIG_FILE, LUNORA_EVENT_SOURCE, LUNORA_SKILL_NAMES, type LevelBadgeName, type LinkedProject, type LunoraFormattedLine, type LunoraLineLevel, type LunoraProjectConfig, LunoraReporter, type MaterializeOptions, type MaterializeResult, type MultiSelectOption, PACKAGE_SECRETS_REGISTRY, type ParseSchemaResult, REMOTE_ELIGIBLE_KEYS, REQUIRED_COMPATIBILITY_DATE, REQUIRED_FLAG, ROOT_SKILL_NAME, type ReadWranglerResult, type ReconcileBindingsResult, type RemoteBindingPlan, type RemoteEnableInputs, type RemotePreference, type RemoteWranglerShape, STEP_BADGE_NAMES, type ScaffoldPlan, type SchemaColumn, type SchemaEdit, type SchemaIndex, type SchemaInfo, type SchemaTable, type SecretEntry, type SelectOption, type StepBadgeName, type TailConsumer, WRANGLER_FILES, type WranglerConfig, type WranglerContainerEntry, type WranglerProjectValidationOptions, type WranglerProjectValidationResult, type WranglerValidationReport, type WranglerWorkflowEntry, applyAdditiveEdit, badgeLead, badgeWidth, buildPackageSecretsBlock, claimAgentRulesHint, classifyEdit, createConfirm, detectAgentRules, detectFramework, discoverContainerInfo, discoverSchemaInfo, discoverWorkflowInfo, ensureDevVariables, ensureDevVariablesExample as ensureDevVarsExample, findWranglerFile, formatLunoraEvent, inferLunoraBindings, injectRemoteFlags, interpretRemote, isInteractive, isPlaceholderValue, isRemoteEnvEnabled, materializeRemoteWranglerConfig, packageNamesFromBindings, padBadge, paintAnswer, paintBadge, parseDevVariableEntries, parseSchema, planDevVariablesAugment, planDevVariablesScaffold, planRemoteBindings, promptMultiSelect, promptSelect, promptYesNo, readLinkedProject, readProjectRemotePreference, readWranglerJsonc, reconcileWranglerBindings, resolveRemoteEnabled, secretsForPackages, validateWrangler, validateWranglerConfig, validateWranglerProject, withTailConsumer, writeLinkedProject };
|
|
1497
|
+
export { ACCENT, AGENT_MODE_ENV, AGENT_RULES_DIR, AGENT_RULES_HINT, AGENT_RULES_HINT_ENV, type AddIndexEdit, type AddOptionalColumnEdit, type AddTableEdit, type AdditiveEdit, type AgentDetection, type AgentRulesStatus, type ApplyEditResult, type ApplyFailureReason, type AugmentPlan, BADGES, BADGE_COLUMN_WIDTH, type BadgeName, type BadgeSpec, type ClaimDevServerStateResult, type ContainerLogLevel, type ContainerLogLine, type ContainerLogSource, type ContainerLogStreamHandle, type ContainerLogStreamOptions, DEV_DAEMON_ENV, DEV_HANDOFF_ENV, DEV_LOG_FILE, DEV_LOG_FILE_ENV, DEV_STATE_DIR, DEV_STATE_FILE, DEV_VARS_EXAMPLE_FILE, DEV_VARS_FILE, DEV_VARS_KEY_PATTERN, type DestructiveEdit, type DetectedFramework, type DevSecretsFillPlan, type DevServerMode, type DevServerState, type DiscoverContainerInfoResult, type DiscoverSchemaInfoResult, type DiscoverWorkflowInfoResult, type DockerLike, type EnsureDevVariablesDeps, type EnsureDevVariablesResult, type EnsureDevVariablesStatus, type ExportGap, type FillDevSecretsResult, type FrameworkClass, type FrameworkDetection, type InferOptions, type InferredBindings, type InferredContainer, type InferredWorkflow, LINKED_PROJECT_DIR, LINKED_PROJECT_FILE, LUNA_ART, LUNA_BUNNY, LUNA_NAME, LUNA_SIGNOFF, LUNORA_CONFIG_FILE, LUNORA_EVENT_SOURCE, LUNORA_SKILL_NAMES, type LevelBadgeName, type LinkedProject, type LunoraFormattedLine, type LunoraLineLevel, type LunoraProjectConfig, LunoraReporter, type MaterializeOptions, type MaterializeResult, type MultiSelectOption, PACKAGE_SECRETS_REGISTRY, type ParseSchemaResult, REMOTE_ELIGIBLE_KEYS, REQUIRED_COMPATIBILITY_DATE, REQUIRED_FLAG, ROOT_SKILL_NAME, type ReadWranglerResult, type ReconcileBindingsResult, type ReconcileCompatibilityDateResult, type RemoteBindingPlan, type RemoteEnableInputs, type RemotePreference, type RemoteWranglerShape, STEP_BADGE_NAMES, type ScaffoldPlan, type SchemaColumn, type SchemaEdit, type SchemaIndex, type SchemaInfo, type SchemaTable, type SecretEntry, type SelectOption, type StepBadgeName, type TailConsumer, WRANGLER_FILES, type WranglerConfig, type WranglerContainerEntry, type WranglerProjectValidationOptions, type WranglerProjectValidationResult, type WranglerValidationReport, type WranglerWorkflowEntry, applyAdditiveEdit, badgeLead, badgeWidth, buildPackageSecretsBlock, claimAgentRulesHint, claimDevServerState, classifyEdit, clearDevServerState, collectWranglerSecretVariables, createConfirm, detectAgentRules, detectAiAgent, detectFramework, discoverContainerInfo, discoverSchemaInfo, discoverWorkflowInfo, ensureDevVariables, ensureDevVariablesExample as ensureDevVarsExample, fillDevSecrets, findWranglerFile, formatLunoraEvent, generateSecretValue, inferLunoraBindings, injectRemoteFlags, interpretRemote, isInteractive, isMintableSecretKey, isPlaceholderValue, isProcessAlive, isRecordedProcessCurrent, isRemoteEnvEnabled, materializeRemoteWranglerConfig, packageNamesFromBindings, padBadge, paintAnswer, paintBadge, parseDevVariableEntries, parseSchema, planDevSecretsFill, planDevVariablesAugment, planDevVariablesScaffold, planRemoteBindings, promptMultiSelect, promptSelect, promptYesNo, readDevServerState, readLinkedProject, readLiveDevServerState, readProjectDependencyNames, readProjectRemotePreference, readWranglerJsonc, reconcileWranglerBindings, reconcileWranglerCompatibilityDate, requiredSecrets, resolveRemoteEnabled, scanWranglerVariablesForSecrets, secretsForPackages, streamContainerLogs, updateDevServerState, validateWrangler, validateWranglerConfig, validateWranglerProject, withTailConsumer, writeDevServerState, writeLinkedProject };
|