@lunora/config 1.0.0-alpha.289 → 1.0.0-alpha.290
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/dist/cloudflare/index.d.mts +7 -1
- package/dist/cloudflare/index.d.ts +7 -1
- package/dist/cloudflare/index.mjs +1 -1
- package/dist/index.d.mts +74 -3
- package/dist/index.d.ts +74 -3
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/CLOUDFLARE_DRIVER-Ci3VIqnk.mjs +1 -0
- package/dist/packem_shared/DEFAULT_DEPLOY_TARGET-CfoV0tDu.mjs +1 -0
- package/dist/packem_shared/REMOTE_ELIGIBLE_KEYS-ikHvqvS5.mjs +1 -0
- package/dist/packem_shared/acceptsConnection-DHhUYGjT.mjs +2 -0
- package/dist/packem_shared/celld-config-D-L6uskI.mjs +3 -0
- package/dist/packem_shared/collectExportGaps-CIYe_DRY.mjs +2 -0
- package/dist/packem_shared/{describePreservedCrons-Ci5r2aph.mjs → describePreservedCrons-7gaDLxWx.mjs} +1 -1
- package/dist/packem_shared/inferLunoraBindings-DXLEJY9w.mjs +1 -0
- package/dist/packem_shared/{interpretRemote-T4emJRPB.mjs → interpretRemote-C9yJC_ZK.mjs} +1 -1
- package/dist/packem_shared/{lunora-manifest-V77OcyFC.mjs → lunora-manifest-v90ZUbVp.mjs} +2 -2
- package/dist/packem_shared/reconcile-services-3dn35zgy.mjs +1 -0
- package/dist/packem_shared/reconcileBindingsSafely-VBbLYoAx.mjs +1 -0
- package/dist/packem_shared/{schema-info.d-CxMdnVt9.d.mts → schema-info.d-fEhxTb9k.d.mts} +7 -1
- package/dist/packem_shared/{schema-info.d-CxMdnVt9.d.ts → schema-info.d-fEhxTb9k.d.ts} +7 -1
- package/dist/packem_shared/startCelldDevSession-BLFsd6jG.mjs +1 -0
- package/package.json +3 -3
- package/dist/packem_shared/CLOUDFLARE_DRIVER-DUE6r-Pg.mjs +0 -1
- package/dist/packem_shared/DEFAULT_DEPLOY_TARGET-Bl4jTTmt.mjs +0 -2
- package/dist/packem_shared/REMOTE_ELIGIBLE_KEYS-D72UkJEq.mjs +0 -1
- package/dist/packem_shared/collectExportGaps-FC62nUj0.mjs +0 -2
- package/dist/packem_shared/inferLunoraBindings-hCgGQAGN.mjs +0 -1
- package/dist/packem_shared/reconcileBindingsSafely-JuzaIkAp.mjs +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DeployDriver, G as GeneratedClassModule, I as InferredBindings, S as SchemaInfo } from "../packem_shared/schema-info.d-
|
|
1
|
+
import { D as DeployDriver, G as GeneratedClassModule, I as InferredBindings, S as SchemaInfo } from "../packem_shared/schema-info.d-fEhxTb9k.mjs";
|
|
2
2
|
import { WranglerVariableIR } from '@lunora/codegen';
|
|
3
3
|
/** Apply one structural jsonc edit and return the rewritten text (a no-op edit returns the input). */
|
|
4
4
|
declare const applyModify: (text: string, path: ReadonlyArray<number | string>, value: unknown) => string;
|
|
@@ -295,6 +295,12 @@ interface ReconcileBindingsResult {
|
|
|
295
295
|
added: string[];
|
|
296
296
|
/** `true` when `wrangler.jsonc` was rewritten. */
|
|
297
297
|
changed: boolean;
|
|
298
|
+
/** What was written to the SvelteKit / Nuxt dev sidecar's own config, when anything was. */
|
|
299
|
+
devConfig?: {
|
|
300
|
+
added: string[];
|
|
301
|
+
path: string;
|
|
302
|
+
updated: string[];
|
|
303
|
+
};
|
|
298
304
|
/**
|
|
299
305
|
* Declared containers/workflows the worker entry doesn't re-export — the
|
|
300
306
|
* structured form of the corresponding `warnings` entries, for the dev error
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DeployDriver, G as GeneratedClassModule, I as InferredBindings, S as SchemaInfo } from "../packem_shared/schema-info.d-
|
|
1
|
+
import { D as DeployDriver, G as GeneratedClassModule, I as InferredBindings, S as SchemaInfo } from "../packem_shared/schema-info.d-fEhxTb9k.js";
|
|
2
2
|
import { WranglerVariableIR } from '@lunora/codegen';
|
|
3
3
|
/** Apply one structural jsonc edit and return the rewritten text (a no-op edit returns the input). */
|
|
4
4
|
declare const applyModify: (text: string, path: ReadonlyArray<number | string>, value: unknown) => string;
|
|
@@ -295,6 +295,12 @@ interface ReconcileBindingsResult {
|
|
|
295
295
|
added: string[];
|
|
296
296
|
/** `true` when `wrangler.jsonc` was rewritten. */
|
|
297
297
|
changed: boolean;
|
|
298
|
+
/** What was written to the SvelteKit / Nuxt dev sidecar's own config, when anything was. */
|
|
299
|
+
devConfig?: {
|
|
300
|
+
added: string[];
|
|
301
|
+
path: string;
|
|
302
|
+
updated: string[];
|
|
303
|
+
};
|
|
298
304
|
/**
|
|
299
305
|
* Declared containers/workflows the worker entry doesn't re-export — the
|
|
300
306
|
* structured form of the corresponding `warnings` entries, for the dev error
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{applyModify as o}from"../packem_shared/applyModify-DKP2l6S9.mjs";import{assertWranglerSatisfiesSchema as n}from"../packem_shared/assertWranglerSatisfiesSchema-BiABHeMv.mjs";import{BINDING_MANIFEST_VERSION as t,buildBindingManifest as i}from"../packem_shared/BINDING_MANIFEST_VERSION-vItUTnHk.mjs";import{default as E}from"../packem_shared/CLOUDFLARE_DRIVER-
|
|
1
|
+
import{applyModify as o}from"../packem_shared/applyModify-DKP2l6S9.mjs";import{assertWranglerSatisfiesSchema as n}from"../packem_shared/assertWranglerSatisfiesSchema-BiABHeMv.mjs";import{BINDING_MANIFEST_VERSION as t,buildBindingManifest as i}from"../packem_shared/BINDING_MANIFEST_VERSION-vItUTnHk.mjs";import{default as E}from"../packem_shared/CLOUDFLARE_DRIVER-Ci3VIqnk.mjs";import{collectExportGaps as s,reconcileWranglerBindings as c}from"../packem_shared/collectExportGaps-CIYe_DRY.mjs";import{reconcileWranglerCompatibilityDate as p}from"../packem_shared/reconcileWranglerCompatibilityDate-hocXEuRA.mjs";import{describePreservedCrons as x,reconcileWranglerCrons as d}from"../packem_shared/describePreservedCrons-7gaDLxWx.mjs";import{reconcileBindingsSafely as I,reconcileWranglerExtras as _}from"../packem_shared/reconcileBindingsSafely-VBbLYoAx.mjs";import{REMOTE_ELIGIBLE_KEYS as S,injectRemoteFlags as A,isRemoteEnvEnabled as D,materializeRemoteWranglerConfig as L,planRemoteBindings as T,resolveRemoteEnabled as b}from"../packem_shared/REMOTE_ELIGIBLE_KEYS-ikHvqvS5.mjs";import{withTailConsumer as B}from"../packem_shared/withTailConsumer-B1NoKIsj.mjs";import{WORKERS_CACHE_MIN_DATE as M,isCacheEnabled as N}from"../packem_shared/WORKERS_CACHE_MIN_DATE-0k9ABJtF.mjs";import{mergeWranglerEnvironment as y}from"../packem_shared/mergeWranglerEnvironment-DOKJUNH8.mjs";import{WRANGLER_FILES as h,findWranglerFile as P,readWranglerJsonc as U}from"../packem_shared/WRANGLER_FILES-UNW-xY5u.mjs";import{UNEXPORTED_CLASS_MARKER as u,validateWranglerProject as K}from"../packem_shared/UNEXPORTED_CLASS_MARKER-CugcZbPf.mjs";import{collectWranglerSecretVariables as w,scanWranglerVariablesForSecrets as Q}from"../packem_shared/collectWranglerSecretVariables-D-usPfT8.mjs";import{wranglerToAlchemy as z}from"../packem_shared/wranglerToAlchemy-BMOQYRyw.mjs";import{REQUIRED_COMPATIBILITY_DATE as J,REQUIRED_FLAG as X,validateWrangler as k,validateWranglerConfig as q}from"../packem_shared/REQUIRED_COMPATIBILITY_DATE-jTnj2MPJ.mjs";export{t as BINDING_MANIFEST_VERSION,E as CLOUDFLARE_DRIVER,S as REMOTE_ELIGIBLE_KEYS,J as REQUIRED_COMPATIBILITY_DATE,X as REQUIRED_FLAG,u as UNEXPORTED_CLASS_MARKER,M as WORKERS_CACHE_MIN_DATE,h as WRANGLER_FILES,o as applyModify,n as assertWranglerSatisfiesSchema,i as buildBindingManifest,s as collectExportGaps,w as collectWranglerSecretVariables,x as describePreservedCrons,P as findWranglerFile,A as injectRemoteFlags,N as isCacheEnabled,D as isRemoteEnvEnabled,L as materializeRemoteWranglerConfig,y as mergeWranglerEnvironment,T as planRemoteBindings,U as readWranglerJsonc,I as reconcileBindingsSafely,c as reconcileWranglerBindings,p as reconcileWranglerCompatibilityDate,d as reconcileWranglerCrons,_ as reconcileWranglerExtras,b as resolveRemoteEnabled,Q as scanWranglerVariablesForSecrets,k as validateWrangler,q as validateWranglerConfig,K as validateWranglerProject,B as withTailConsumer,z as wranglerToAlchemy};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { AgentIR, ContainerIR, WorkflowIR, CodegenResult } from '@lunora/codegen';
|
|
2
2
|
export type { AgentIR, ContainerIR, WorkflowIR } from '@lunora/codegen';
|
|
3
|
+
import { ChildProcess } from 'node:child_process';
|
|
3
4
|
import { Writable } from 'node:stream';
|
|
4
|
-
import { T as ToolchainCommand, D as DeployDriver, P as ProjectionPurpose } from "./packem_shared/schema-info.d-
|
|
5
|
-
export { C as COMPOSED_WORKER_ENTRY, type a as DeployRequest, type b as DevRequest, type c as DiscoverSchemaInfoResult, type d as DriverToolchain, e as GENERATED_CLASS_MODULES, type G as GeneratedClassModule, type f as InferOptions, type g as InferredAgent, type I as InferredBindings, type h as InferredContainer, type i as InferredWorkflow, type j as ProjectedConfig, type S as SchemaInfo, type k as SecretRequest, type l as TailRequest, m as discoverSchemaInfo, n as inferLunoraBindings, p as packageNamesFromBindings } from "./packem_shared/schema-info.d-
|
|
5
|
+
import { T as ToolchainCommand, D as DeployDriver, P as ProjectionPurpose } from "./packem_shared/schema-info.d-fEhxTb9k.mjs";
|
|
6
|
+
export { C as COMPOSED_WORKER_ENTRY, type a as DeployRequest, type b as DevRequest, type c as DiscoverSchemaInfoResult, type d as DriverToolchain, e as GENERATED_CLASS_MODULES, type G as GeneratedClassModule, type f as InferOptions, type g as InferredAgent, type I as InferredBindings, type h as InferredContainer, type i as InferredWorkflow, type j as ProjectedConfig, type S as SchemaInfo, type k as SecretRequest, type l as TailRequest, m as discoverSchemaInfo, n as inferLunoraBindings, p as packageNamesFromBindings } from "./packem_shared/schema-info.d-fEhxTb9k.mjs";
|
|
6
7
|
export { type A as AdditivePolicyEdit, type D as DestructivePolicyEdit, type P as PolicyEdit, type a as PolicyScaffoldFailureReason, type b as ScaffoldFileResult, type S as ScaffoldPolicyEdit, type c as WireResult, type W as WireRlsEdit, d as classifyPolicyEdit, r as resolveServerModule, s as scaffoldPolicyFile, w as wireRlsIntoProcedure } from "./packem_shared/policy-scaffold.d-D2H4_G01.mjs";
|
|
7
8
|
interface DiscoverAgentInfoResult {
|
|
8
9
|
/** Discovered agent definitions; `[]` when none are declared or parsing failed. */
|
|
@@ -117,6 +118,76 @@ interface AgentRulesStatus {
|
|
|
117
118
|
* hint.
|
|
118
119
|
*/
|
|
119
120
|
declare const detectAgentRules: (projectRoot: string) => AgentRulesStatus;
|
|
121
|
+
/** Spawns the process — injectable so tests run without the binary. */
|
|
122
|
+
type DevProcessSpawner = (command: string, args: ReadonlyArray<string>, options: {
|
|
123
|
+
cwd: string;
|
|
124
|
+
shell: boolean;
|
|
125
|
+
}) => ChildProcess;
|
|
126
|
+
interface DevProcessOptions {
|
|
127
|
+
args: ReadonlyArray<string>;
|
|
128
|
+
command: string;
|
|
129
|
+
cwd: string;
|
|
130
|
+
/** Names the process in errors, e.g. `wrangler dev`. */
|
|
131
|
+
label: string;
|
|
132
|
+
/** The error when `command` is not on PATH, naming the fix. */
|
|
133
|
+
notFound: string;
|
|
134
|
+
/** One line of output; the remainder after the last newline is flushed when the stream ends. */
|
|
135
|
+
onLine: (line: string, stream: "stderr" | "stdout") => void;
|
|
136
|
+
port: number;
|
|
137
|
+
readyTimeoutMs: number;
|
|
138
|
+
/** Windows `.cmd` shims only launch through a shell. */
|
|
139
|
+
shell?: boolean;
|
|
140
|
+
/** Aborting it stops the process while it is still starting; the start then rejects. */
|
|
141
|
+
signal?: AbortSignal;
|
|
142
|
+
spawn?: DevProcessSpawner;
|
|
143
|
+
}
|
|
144
|
+
interface DevProcess {
|
|
145
|
+
/** Resolves with the exit code when the process exits without {@link DevProcess.stop} asking it to. */
|
|
146
|
+
crashed: Promise<number>;
|
|
147
|
+
/** Terminate it; resolves once it has exited. */
|
|
148
|
+
stop: () => Promise<void>;
|
|
149
|
+
}
|
|
150
|
+
/** `true` once something accepts a TCP connection on `port`. */
|
|
151
|
+
declare const acceptsConnection: (port: number) => Promise<boolean>;
|
|
152
|
+
/**
|
|
153
|
+
* Spawn the process and resolve once it accepts connections on `port`; reject,
|
|
154
|
+
* with the process stopped, when it cannot be spawned, exits first, or misses
|
|
155
|
+
* the deadline. The caller checks the port is free beforehand: the probe cannot
|
|
156
|
+
* tell this process from another one already listening there.
|
|
157
|
+
*/
|
|
158
|
+
declare const startDevProcess: (options: DevProcessOptions) => Promise<DevProcess>;
|
|
159
|
+
/**
|
|
160
|
+
* Where a line came from: `celld` (the app, and the session's own notices) or
|
|
161
|
+
* `celld:<worker>`, and `stderr` for a session notice that reports a failure.
|
|
162
|
+
*/
|
|
163
|
+
interface CelldLineOrigin {
|
|
164
|
+
stream: "stderr" | "stdout";
|
|
165
|
+
tag: string;
|
|
166
|
+
}
|
|
167
|
+
interface CelldDevSessionOptions {
|
|
168
|
+
/** Prints one non-empty line of the session's output. */
|
|
169
|
+
log: (line: string, origin: CelldLineOrigin) => void;
|
|
170
|
+
/** Port the app serves on. */
|
|
171
|
+
port: number;
|
|
172
|
+
projectRoot: string;
|
|
173
|
+
spawn?: DevProcessSpawner;
|
|
174
|
+
}
|
|
175
|
+
interface CelldDevSession {
|
|
176
|
+
/**
|
|
177
|
+
* Resolves with an exit code once the app is gone without {@link CelldDevSession.stop}
|
|
178
|
+
* asking: its `celld dev` crashed, or did not come back after a restart.
|
|
179
|
+
*/
|
|
180
|
+
exited: Promise<number>;
|
|
181
|
+
/** Stop watching, cut short a restart in flight, then stop the app. */
|
|
182
|
+
stop: () => Promise<void>;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Start the session: register every service, run the app, then watch the
|
|
186
|
+
* service folders. Resolves once the app accepts connections; rejects, with
|
|
187
|
+
* nothing left running, when a service or the app cannot start — including an
|
|
188
|
+
* app `celld dev` cannot run at all (a Vite virtual `main`).
|
|
189
|
+
*/
|
|
190
|
+
declare const startCelldDevSession: (options: CelldDevSessionOptions) => Promise<CelldDevSession>;
|
|
120
191
|
/**
|
|
121
192
|
* The environment switch that turns codegen off — the other spelling of
|
|
122
193
|
* `lunora dev --no-codegen`.
|
|
@@ -1354,4 +1425,4 @@ declare const badgeWidth: (_spec: BadgeSpec) => number;
|
|
|
1354
1425
|
declare const paintBadge: (spec: BadgeSpec) => string;
|
|
1355
1426
|
/** Dim continuation text (a step's chosen answer, shown under the question). */
|
|
1356
1427
|
declare const paintAnswer: (text: string) => string;
|
|
1357
|
-
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, CODEGEN_ENV, type ClaimDevServerStateResult, type ContainerLogLevel, type ContainerLogLine, type ContainerLogSource, type ContainerLogStreamHandle, type ContainerLogStreamOptions, DEFAULT_DEPLOY_TARGET, DEV_BINDINGS_FILE, DEV_DAEMON_ENV, DEV_HANDOFF_ENV, DEV_LOG_FILE, DEV_LOG_FILE_ENV, DEV_STATE_DIR, DEV_STATE_FILE, DEV_VARS_EXAMPLE_FILE, DEV_VARS_FILE, DEV_VARS_KEY_PATTERN, DEV_WORKER_ENV_VALUE, DEV_WORKER_ENV_VAR, type DeployDriver, type DestructiveEdit, type DetectedFramework, type DevSecretsFillPlan, type DevServerMode, type DevServerState, type DiscoverAgentInfoResult, type DiscoverContainerInfoResult, type DiscoverWorkflowInfoResult, type DockerLike, type EnsureDevVariablesDeps, type EnsureDevVariablesResult, type EnsureDevVariablesStatus, type FillDevSecretsResult, type FindingLogger, type FrameworkClass, type FrameworkDetection, type HookLogger, type HookSpawnDescriptor, type HookSpawner, LINKED_PROJECT_DIR, LINKED_PROJECT_FILE, LUNA_ART, LUNA_BUNNY, LUNA_NAME, LUNA_SIGNOFF, LUNORA_EVENT_SOURCE, LUNORA_IGNORED_PATHS, LUNORA_SKILL_NAMES, LUNORA_TAG, type LevelBadgeName, type LinkedProject, type LintIgnoreOutcome, type LintIgnoreStatus, type LintTool, type LunoraFormattedLine, type LunoraLineLevel, LunoraReporter, type MultiSelectOption, PACKAGE_SECRETS_REGISTRY, type PackageManager, type PackageManagerProbe, type ParseSchemaResult, type PostCodegenHookResult, type ProjectionPurpose, ROOT_SKILL_NAME, type RemotePreference, STEP_BADGE_NAMES, type ScaffoldPlan, type SchemaColumn, type SchemaEdit, type SchemaIndex, type SchemaTable, type SecretEntry, type SelectOption, type StepBadgeName, type ToolchainCommand, type ToolchainInvocation, addArgsFor, advisoryLine, applyAdditiveEdit, applyLintIgnores, badgeLead, badgeWidth, blockingFindingsMessage, buildPackageSecretsBlock, claimAgentRulesHint, claimDevServerState, classifyEdit, clearDevServerState, createConfirm, deployTargetIds, detectAgentRules, detectAiAgent, detectFramework, detectInstalledManagers, detectLintTools, detectPackageManager, discoverAgentInfo, discoverContainerInfo, discoverWorkflowInfo, ensureDevVariables, ensureDevVariablesExample as ensureDevVarsExample, ensureDevWorkerEnv, escapeRegExp, execArgsFor, fillDevSecrets, formatLunoraEvent, generateSecretValue, installArgsFor, interpretRemote, isCodegenDisabled, isDevServerReady, isInteractive, isMintableSecretKey, isPlaceholderValue, isProcessAlive, isRecordedProcessCurrent, isRunnableTarget, lunoraLine, padBadge, paintAnswer, paintBadge, parseDevVariableEntries, parseSchema, planDevSecretsFill, planDevVariablesAugment, planDevVariablesScaffold, planToolchainInvocation, projectUsesUmbrella, promptMultiSelect, promptSelect, promptText, promptYesNo, readDevServerState, readLinkedProject, readLiveDevServerState, readProjectDependencyNames, readProjectRemotePreference, readProjectTarget, removeDevVariableLine, reportCodegenFindings, requiredSecrets, resolveDeployDriver, resolveProjectTarget, resolveTargetOrThrow, runPostCodegenHook, runScriptArgsFor, runScriptCommand, runnableTargetIds, secretsForPackages, streamContainerLogs, targetRunsOwnDevServer, toolchainExecArgs, updateDevServerState, upsertDevVariableLine, writeDevServerState, writeDevVariablesFileAtomically, writeLinkedProject };
|
|
1428
|
+
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, CODEGEN_ENV, type CelldDevSession, type CelldDevSessionOptions, type CelldLineOrigin, type ClaimDevServerStateResult, type ContainerLogLevel, type ContainerLogLine, type ContainerLogSource, type ContainerLogStreamHandle, type ContainerLogStreamOptions, DEFAULT_DEPLOY_TARGET, DEV_BINDINGS_FILE, DEV_DAEMON_ENV, DEV_HANDOFF_ENV, DEV_LOG_FILE, DEV_LOG_FILE_ENV, DEV_STATE_DIR, DEV_STATE_FILE, DEV_VARS_EXAMPLE_FILE, DEV_VARS_FILE, DEV_VARS_KEY_PATTERN, DEV_WORKER_ENV_VALUE, DEV_WORKER_ENV_VAR, type DeployDriver, type DestructiveEdit, type DetectedFramework, type DevProcess, type DevProcessOptions, type DevProcessSpawner, type DevSecretsFillPlan, type DevServerMode, type DevServerState, type DiscoverAgentInfoResult, type DiscoverContainerInfoResult, type DiscoverWorkflowInfoResult, type DockerLike, type EnsureDevVariablesDeps, type EnsureDevVariablesResult, type EnsureDevVariablesStatus, type FillDevSecretsResult, type FindingLogger, type FrameworkClass, type FrameworkDetection, type HookLogger, type HookSpawnDescriptor, type HookSpawner, LINKED_PROJECT_DIR, LINKED_PROJECT_FILE, LUNA_ART, LUNA_BUNNY, LUNA_NAME, LUNA_SIGNOFF, LUNORA_EVENT_SOURCE, LUNORA_IGNORED_PATHS, LUNORA_SKILL_NAMES, LUNORA_TAG, type LevelBadgeName, type LinkedProject, type LintIgnoreOutcome, type LintIgnoreStatus, type LintTool, type LunoraFormattedLine, type LunoraLineLevel, LunoraReporter, type MultiSelectOption, PACKAGE_SECRETS_REGISTRY, type PackageManager, type PackageManagerProbe, type ParseSchemaResult, type PostCodegenHookResult, type ProjectionPurpose, ROOT_SKILL_NAME, type RemotePreference, STEP_BADGE_NAMES, type ScaffoldPlan, type SchemaColumn, type SchemaEdit, type SchemaIndex, type SchemaTable, type SecretEntry, type SelectOption, type StepBadgeName, type ToolchainCommand, type ToolchainInvocation, acceptsConnection, addArgsFor, advisoryLine, applyAdditiveEdit, applyLintIgnores, badgeLead, badgeWidth, blockingFindingsMessage, buildPackageSecretsBlock, claimAgentRulesHint, claimDevServerState, classifyEdit, clearDevServerState, createConfirm, deployTargetIds, detectAgentRules, detectAiAgent, detectFramework, detectInstalledManagers, detectLintTools, detectPackageManager, discoverAgentInfo, discoverContainerInfo, discoverWorkflowInfo, ensureDevVariables, ensureDevVariablesExample as ensureDevVarsExample, ensureDevWorkerEnv, escapeRegExp, execArgsFor, fillDevSecrets, formatLunoraEvent, generateSecretValue, installArgsFor, interpretRemote, isCodegenDisabled, isDevServerReady, isInteractive, isMintableSecretKey, isPlaceholderValue, isProcessAlive, isRecordedProcessCurrent, isRunnableTarget, lunoraLine, padBadge, paintAnswer, paintBadge, parseDevVariableEntries, parseSchema, planDevSecretsFill, planDevVariablesAugment, planDevVariablesScaffold, planToolchainInvocation, projectUsesUmbrella, promptMultiSelect, promptSelect, promptText, promptYesNo, readDevServerState, readLinkedProject, readLiveDevServerState, readProjectDependencyNames, readProjectRemotePreference, readProjectTarget, removeDevVariableLine, reportCodegenFindings, requiredSecrets, resolveDeployDriver, resolveProjectTarget, resolveTargetOrThrow, runPostCodegenHook, runScriptArgsFor, runScriptCommand, runnableTargetIds, secretsForPackages, startCelldDevSession, startDevProcess, streamContainerLogs, targetRunsOwnDevServer, toolchainExecArgs, updateDevServerState, upsertDevVariableLine, writeDevServerState, writeDevVariablesFileAtomically, writeLinkedProject };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { AgentIR, ContainerIR, WorkflowIR, CodegenResult } from '@lunora/codegen';
|
|
2
2
|
export type { AgentIR, ContainerIR, WorkflowIR } from '@lunora/codegen';
|
|
3
|
+
import { ChildProcess } from 'node:child_process';
|
|
3
4
|
import { Writable } from 'node:stream';
|
|
4
|
-
import { T as ToolchainCommand, D as DeployDriver, P as ProjectionPurpose } from "./packem_shared/schema-info.d-
|
|
5
|
-
export { C as COMPOSED_WORKER_ENTRY, type a as DeployRequest, type b as DevRequest, type c as DiscoverSchemaInfoResult, type d as DriverToolchain, e as GENERATED_CLASS_MODULES, type G as GeneratedClassModule, type f as InferOptions, type g as InferredAgent, type I as InferredBindings, type h as InferredContainer, type i as InferredWorkflow, type j as ProjectedConfig, type S as SchemaInfo, type k as SecretRequest, type l as TailRequest, m as discoverSchemaInfo, n as inferLunoraBindings, p as packageNamesFromBindings } from "./packem_shared/schema-info.d-
|
|
5
|
+
import { T as ToolchainCommand, D as DeployDriver, P as ProjectionPurpose } from "./packem_shared/schema-info.d-fEhxTb9k.js";
|
|
6
|
+
export { C as COMPOSED_WORKER_ENTRY, type a as DeployRequest, type b as DevRequest, type c as DiscoverSchemaInfoResult, type d as DriverToolchain, e as GENERATED_CLASS_MODULES, type G as GeneratedClassModule, type f as InferOptions, type g as InferredAgent, type I as InferredBindings, type h as InferredContainer, type i as InferredWorkflow, type j as ProjectedConfig, type S as SchemaInfo, type k as SecretRequest, type l as TailRequest, m as discoverSchemaInfo, n as inferLunoraBindings, p as packageNamesFromBindings } from "./packem_shared/schema-info.d-fEhxTb9k.js";
|
|
6
7
|
export { type A as AdditivePolicyEdit, type D as DestructivePolicyEdit, type P as PolicyEdit, type a as PolicyScaffoldFailureReason, type b as ScaffoldFileResult, type S as ScaffoldPolicyEdit, type c as WireResult, type W as WireRlsEdit, d as classifyPolicyEdit, r as resolveServerModule, s as scaffoldPolicyFile, w as wireRlsIntoProcedure } from "./packem_shared/policy-scaffold.d-D2H4_G01.js";
|
|
7
8
|
interface DiscoverAgentInfoResult {
|
|
8
9
|
/** Discovered agent definitions; `[]` when none are declared or parsing failed. */
|
|
@@ -117,6 +118,76 @@ interface AgentRulesStatus {
|
|
|
117
118
|
* hint.
|
|
118
119
|
*/
|
|
119
120
|
declare const detectAgentRules: (projectRoot: string) => AgentRulesStatus;
|
|
121
|
+
/** Spawns the process — injectable so tests run without the binary. */
|
|
122
|
+
type DevProcessSpawner = (command: string, args: ReadonlyArray<string>, options: {
|
|
123
|
+
cwd: string;
|
|
124
|
+
shell: boolean;
|
|
125
|
+
}) => ChildProcess;
|
|
126
|
+
interface DevProcessOptions {
|
|
127
|
+
args: ReadonlyArray<string>;
|
|
128
|
+
command: string;
|
|
129
|
+
cwd: string;
|
|
130
|
+
/** Names the process in errors, e.g. `wrangler dev`. */
|
|
131
|
+
label: string;
|
|
132
|
+
/** The error when `command` is not on PATH, naming the fix. */
|
|
133
|
+
notFound: string;
|
|
134
|
+
/** One line of output; the remainder after the last newline is flushed when the stream ends. */
|
|
135
|
+
onLine: (line: string, stream: "stderr" | "stdout") => void;
|
|
136
|
+
port: number;
|
|
137
|
+
readyTimeoutMs: number;
|
|
138
|
+
/** Windows `.cmd` shims only launch through a shell. */
|
|
139
|
+
shell?: boolean;
|
|
140
|
+
/** Aborting it stops the process while it is still starting; the start then rejects. */
|
|
141
|
+
signal?: AbortSignal;
|
|
142
|
+
spawn?: DevProcessSpawner;
|
|
143
|
+
}
|
|
144
|
+
interface DevProcess {
|
|
145
|
+
/** Resolves with the exit code when the process exits without {@link DevProcess.stop} asking it to. */
|
|
146
|
+
crashed: Promise<number>;
|
|
147
|
+
/** Terminate it; resolves once it has exited. */
|
|
148
|
+
stop: () => Promise<void>;
|
|
149
|
+
}
|
|
150
|
+
/** `true` once something accepts a TCP connection on `port`. */
|
|
151
|
+
declare const acceptsConnection: (port: number) => Promise<boolean>;
|
|
152
|
+
/**
|
|
153
|
+
* Spawn the process and resolve once it accepts connections on `port`; reject,
|
|
154
|
+
* with the process stopped, when it cannot be spawned, exits first, or misses
|
|
155
|
+
* the deadline. The caller checks the port is free beforehand: the probe cannot
|
|
156
|
+
* tell this process from another one already listening there.
|
|
157
|
+
*/
|
|
158
|
+
declare const startDevProcess: (options: DevProcessOptions) => Promise<DevProcess>;
|
|
159
|
+
/**
|
|
160
|
+
* Where a line came from: `celld` (the app, and the session's own notices) or
|
|
161
|
+
* `celld:<worker>`, and `stderr` for a session notice that reports a failure.
|
|
162
|
+
*/
|
|
163
|
+
interface CelldLineOrigin {
|
|
164
|
+
stream: "stderr" | "stdout";
|
|
165
|
+
tag: string;
|
|
166
|
+
}
|
|
167
|
+
interface CelldDevSessionOptions {
|
|
168
|
+
/** Prints one non-empty line of the session's output. */
|
|
169
|
+
log: (line: string, origin: CelldLineOrigin) => void;
|
|
170
|
+
/** Port the app serves on. */
|
|
171
|
+
port: number;
|
|
172
|
+
projectRoot: string;
|
|
173
|
+
spawn?: DevProcessSpawner;
|
|
174
|
+
}
|
|
175
|
+
interface CelldDevSession {
|
|
176
|
+
/**
|
|
177
|
+
* Resolves with an exit code once the app is gone without {@link CelldDevSession.stop}
|
|
178
|
+
* asking: its `celld dev` crashed, or did not come back after a restart.
|
|
179
|
+
*/
|
|
180
|
+
exited: Promise<number>;
|
|
181
|
+
/** Stop watching, cut short a restart in flight, then stop the app. */
|
|
182
|
+
stop: () => Promise<void>;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Start the session: register every service, run the app, then watch the
|
|
186
|
+
* service folders. Resolves once the app accepts connections; rejects, with
|
|
187
|
+
* nothing left running, when a service or the app cannot start — including an
|
|
188
|
+
* app `celld dev` cannot run at all (a Vite virtual `main`).
|
|
189
|
+
*/
|
|
190
|
+
declare const startCelldDevSession: (options: CelldDevSessionOptions) => Promise<CelldDevSession>;
|
|
120
191
|
/**
|
|
121
192
|
* The environment switch that turns codegen off — the other spelling of
|
|
122
193
|
* `lunora dev --no-codegen`.
|
|
@@ -1354,4 +1425,4 @@ declare const badgeWidth: (_spec: BadgeSpec) => number;
|
|
|
1354
1425
|
declare const paintBadge: (spec: BadgeSpec) => string;
|
|
1355
1426
|
/** Dim continuation text (a step's chosen answer, shown under the question). */
|
|
1356
1427
|
declare const paintAnswer: (text: string) => string;
|
|
1357
|
-
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, CODEGEN_ENV, type ClaimDevServerStateResult, type ContainerLogLevel, type ContainerLogLine, type ContainerLogSource, type ContainerLogStreamHandle, type ContainerLogStreamOptions, DEFAULT_DEPLOY_TARGET, DEV_BINDINGS_FILE, DEV_DAEMON_ENV, DEV_HANDOFF_ENV, DEV_LOG_FILE, DEV_LOG_FILE_ENV, DEV_STATE_DIR, DEV_STATE_FILE, DEV_VARS_EXAMPLE_FILE, DEV_VARS_FILE, DEV_VARS_KEY_PATTERN, DEV_WORKER_ENV_VALUE, DEV_WORKER_ENV_VAR, type DeployDriver, type DestructiveEdit, type DetectedFramework, type DevSecretsFillPlan, type DevServerMode, type DevServerState, type DiscoverAgentInfoResult, type DiscoverContainerInfoResult, type DiscoverWorkflowInfoResult, type DockerLike, type EnsureDevVariablesDeps, type EnsureDevVariablesResult, type EnsureDevVariablesStatus, type FillDevSecretsResult, type FindingLogger, type FrameworkClass, type FrameworkDetection, type HookLogger, type HookSpawnDescriptor, type HookSpawner, LINKED_PROJECT_DIR, LINKED_PROJECT_FILE, LUNA_ART, LUNA_BUNNY, LUNA_NAME, LUNA_SIGNOFF, LUNORA_EVENT_SOURCE, LUNORA_IGNORED_PATHS, LUNORA_SKILL_NAMES, LUNORA_TAG, type LevelBadgeName, type LinkedProject, type LintIgnoreOutcome, type LintIgnoreStatus, type LintTool, type LunoraFormattedLine, type LunoraLineLevel, LunoraReporter, type MultiSelectOption, PACKAGE_SECRETS_REGISTRY, type PackageManager, type PackageManagerProbe, type ParseSchemaResult, type PostCodegenHookResult, type ProjectionPurpose, ROOT_SKILL_NAME, type RemotePreference, STEP_BADGE_NAMES, type ScaffoldPlan, type SchemaColumn, type SchemaEdit, type SchemaIndex, type SchemaTable, type SecretEntry, type SelectOption, type StepBadgeName, type ToolchainCommand, type ToolchainInvocation, addArgsFor, advisoryLine, applyAdditiveEdit, applyLintIgnores, badgeLead, badgeWidth, blockingFindingsMessage, buildPackageSecretsBlock, claimAgentRulesHint, claimDevServerState, classifyEdit, clearDevServerState, createConfirm, deployTargetIds, detectAgentRules, detectAiAgent, detectFramework, detectInstalledManagers, detectLintTools, detectPackageManager, discoverAgentInfo, discoverContainerInfo, discoverWorkflowInfo, ensureDevVariables, ensureDevVariablesExample as ensureDevVarsExample, ensureDevWorkerEnv, escapeRegExp, execArgsFor, fillDevSecrets, formatLunoraEvent, generateSecretValue, installArgsFor, interpretRemote, isCodegenDisabled, isDevServerReady, isInteractive, isMintableSecretKey, isPlaceholderValue, isProcessAlive, isRecordedProcessCurrent, isRunnableTarget, lunoraLine, padBadge, paintAnswer, paintBadge, parseDevVariableEntries, parseSchema, planDevSecretsFill, planDevVariablesAugment, planDevVariablesScaffold, planToolchainInvocation, projectUsesUmbrella, promptMultiSelect, promptSelect, promptText, promptYesNo, readDevServerState, readLinkedProject, readLiveDevServerState, readProjectDependencyNames, readProjectRemotePreference, readProjectTarget, removeDevVariableLine, reportCodegenFindings, requiredSecrets, resolveDeployDriver, resolveProjectTarget, resolveTargetOrThrow, runPostCodegenHook, runScriptArgsFor, runScriptCommand, runnableTargetIds, secretsForPackages, streamContainerLogs, targetRunsOwnDevServer, toolchainExecArgs, updateDevServerState, upsertDevVariableLine, writeDevServerState, writeDevVariablesFileAtomically, writeLinkedProject };
|
|
1428
|
+
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, CODEGEN_ENV, type CelldDevSession, type CelldDevSessionOptions, type CelldLineOrigin, type ClaimDevServerStateResult, type ContainerLogLevel, type ContainerLogLine, type ContainerLogSource, type ContainerLogStreamHandle, type ContainerLogStreamOptions, DEFAULT_DEPLOY_TARGET, DEV_BINDINGS_FILE, DEV_DAEMON_ENV, DEV_HANDOFF_ENV, DEV_LOG_FILE, DEV_LOG_FILE_ENV, DEV_STATE_DIR, DEV_STATE_FILE, DEV_VARS_EXAMPLE_FILE, DEV_VARS_FILE, DEV_VARS_KEY_PATTERN, DEV_WORKER_ENV_VALUE, DEV_WORKER_ENV_VAR, type DeployDriver, type DestructiveEdit, type DetectedFramework, type DevProcess, type DevProcessOptions, type DevProcessSpawner, type DevSecretsFillPlan, type DevServerMode, type DevServerState, type DiscoverAgentInfoResult, type DiscoverContainerInfoResult, type DiscoverWorkflowInfoResult, type DockerLike, type EnsureDevVariablesDeps, type EnsureDevVariablesResult, type EnsureDevVariablesStatus, type FillDevSecretsResult, type FindingLogger, type FrameworkClass, type FrameworkDetection, type HookLogger, type HookSpawnDescriptor, type HookSpawner, LINKED_PROJECT_DIR, LINKED_PROJECT_FILE, LUNA_ART, LUNA_BUNNY, LUNA_NAME, LUNA_SIGNOFF, LUNORA_EVENT_SOURCE, LUNORA_IGNORED_PATHS, LUNORA_SKILL_NAMES, LUNORA_TAG, type LevelBadgeName, type LinkedProject, type LintIgnoreOutcome, type LintIgnoreStatus, type LintTool, type LunoraFormattedLine, type LunoraLineLevel, LunoraReporter, type MultiSelectOption, PACKAGE_SECRETS_REGISTRY, type PackageManager, type PackageManagerProbe, type ParseSchemaResult, type PostCodegenHookResult, type ProjectionPurpose, ROOT_SKILL_NAME, type RemotePreference, STEP_BADGE_NAMES, type ScaffoldPlan, type SchemaColumn, type SchemaEdit, type SchemaIndex, type SchemaTable, type SecretEntry, type SelectOption, type StepBadgeName, type ToolchainCommand, type ToolchainInvocation, acceptsConnection, addArgsFor, advisoryLine, applyAdditiveEdit, applyLintIgnores, badgeLead, badgeWidth, blockingFindingsMessage, buildPackageSecretsBlock, claimAgentRulesHint, claimDevServerState, classifyEdit, clearDevServerState, createConfirm, deployTargetIds, detectAgentRules, detectAiAgent, detectFramework, detectInstalledManagers, detectLintTools, detectPackageManager, discoverAgentInfo, discoverContainerInfo, discoverWorkflowInfo, ensureDevVariables, ensureDevVariablesExample as ensureDevVarsExample, ensureDevWorkerEnv, escapeRegExp, execArgsFor, fillDevSecrets, formatLunoraEvent, generateSecretValue, installArgsFor, interpretRemote, isCodegenDisabled, isDevServerReady, isInteractive, isMintableSecretKey, isPlaceholderValue, isProcessAlive, isRecordedProcessCurrent, isRunnableTarget, lunoraLine, padBadge, paintAnswer, paintBadge, parseDevVariableEntries, parseSchema, planDevSecretsFill, planDevVariablesAugment, planDevVariablesScaffold, planToolchainInvocation, projectUsesUmbrella, promptMultiSelect, promptSelect, promptText, promptYesNo, readDevServerState, readLinkedProject, readLiveDevServerState, readProjectDependencyNames, readProjectRemotePreference, readProjectTarget, removeDevVariableLine, reportCodegenFindings, requiredSecrets, resolveDeployDriver, resolveProjectTarget, resolveTargetOrThrow, runPostCodegenHook, runScriptArgsFor, runScriptCommand, runnableTargetIds, secretsForPackages, startCelldDevSession, startDevProcess, streamContainerLogs, targetRunsOwnDevServer, toolchainExecArgs, updateDevServerState, upsertDevVariableLine, writeDevServerState, writeDevVariablesFileAtomically, writeLinkedProject };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AGENT_MODE_ENV as o,detectAiAgent as t}from"./packem_shared/AGENT_MODE_ENV-D8MvSwPE.mjs";import{discoverAgentInfo as
|
|
1
|
+
import{AGENT_MODE_ENV as o,detectAiAgent as t}from"./packem_shared/AGENT_MODE_ENV-D8MvSwPE.mjs";import{discoverAgentInfo as s}from"./packem_shared/discoverAgentInfo-CTdCSfYM.mjs";import{AGENT_RULES_DIR as i,AGENT_RULES_HINT as n,AGENT_RULES_HINT_ENV as l,LUNORA_SKILL_NAMES as p,ROOT_SKILL_NAME as _,claimAgentRulesHint as c,detectAgentRules as d}from"./packem_shared/AGENT_RULES_DIR-C54Ta_vz.mjs";import{startCelldDevSession as m}from"./packem_shared/startCelldDevSession-BLFsd6jG.mjs";import{CODEGEN_ENV as S,isCodegenDisabled as f}from"./packem_shared/CODEGEN_ENV-ZsCxV1kP.mjs";import{discoverContainerInfo as L}from"./packem_shared/discoverContainerInfo-EhZtEBQs.mjs";import{streamContainerLogs as R}from"./packem_shared/streamContainerLogs-0nko1qpv.mjs";import{detectFramework as T,projectUsesUmbrella as x,readProjectDependencyNames as V}from"./packem_shared/detectFramework-CUiVEHDQ.mjs";import{acceptsConnection as P,startDevProcess as u}from"./packem_shared/acceptsConnection-DHhUYGjT.mjs";import{DEV_BINDINGS_FILE as F,DEV_DAEMON_ENV as C,DEV_HANDOFF_ENV as U,DEV_LOG_FILE as G,DEV_LOG_FILE_ENV as b,DEV_STATE_DIR as M,DEV_STATE_FILE as y,claimDevServerState as k,clearDevServerState as B,isDevServerReady as K,isProcessAlive as w,isRecordedProcessCurrent as h,readDevServerState as j,readLiveDevServerState as H,updateDevServerState as W,writeDevServerState as Y}from"./packem_shared/DEV_BINDINGS_FILE-pyOiNLP4.mjs";import{DEV_VARS_EXAMPLE_FILE as q,DEV_VARS_FILE as X,DEV_VARS_KEY_PATTERN as z,escapeRegExp as Q,parseDevVariableEntries as Z,removeDevVariableLine as $,upsertDevVariableLine as ee}from"./packem_shared/DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{DEV_WORKER_ENV_VALUE as oe,DEV_WORKER_ENV_VAR as te,ensureDevWorkerEnv as ae}from"./packem_shared/DEV_WORKER_ENV_VALUE-DwGANZVw.mjs";import{DEFAULT_DEPLOY_TARGET as Ee,deployTargetIds as ie,isRunnableTarget as ne,planToolchainInvocation as le,resolveDeployDriver as pe,runnableTargetIds as _e,targetRunsOwnDevServer as ce}from"./packem_shared/DEFAULT_DEPLOY_TARGET-CfoV0tDu.mjs";import{inferLunoraBindings as De,packageNamesFromBindings as me}from"./packem_shared/inferLunoraBindings-DXLEJY9w.mjs";import{LINKED_PROJECT_DIR as Se,LINKED_PROJECT_FILE as fe,readLinkedProject as ve,writeLinkedProject as Le}from"./packem_shared/LINKED_PROJECT_DIR-Ba5qPEwo.mjs";import{LUNORA_IGNORED_PATHS as Re,applyLintIgnores as ge,detectLintTools as Te}from"./packem_shared/LUNORA_IGNORED_PATHS-B0-PPvRp.mjs";import{LUNORA_TAG as Ve,advisoryLine as Ie,blockingFindingsMessage as Pe,lunoraLine as ue,reportCodegenFindings as Oe}from"./packem_shared/LUNORA_TAG-CiQM3BkI.mjs";import{LUNORA_EVENT_SOURCE as Ce,formatLunoraEvent as Ue}from"./packem_shared/LUNORA_EVENT_SOURCE-DYdcDU9G.mjs";import{default as be}from"./packem_shared/LunoraReporter-f277GLNT.mjs";import{addArgsFor as ye,detectInstalledManagers as ke,detectPackageManager as Be,execArgsFor as Ke,installArgsFor as we,runScriptArgsFor as he,runScriptCommand as je,toolchainExecArgs as He}from"./packem_shared/addArgsFor-CYZKhNIo.mjs";import{P as Ye,s as Je}from"./packem_shared/package-secrets-registry-DvtTiK4b.mjs";import{runPostCodegenHook as Xe}from"./packem_shared/runPostCodegenHook-B0T1q2YI.mjs";import{interpretRemote as Qe,readProjectRemotePreference as Ze,readProjectTarget as $e,resolveProjectTarget as er,resolveTargetOrThrow as rr}from"./packem_shared/interpretRemote-C9yJC_ZK.mjs";import{createConfirm as tr,isInteractive as ar,promptMultiSelect as sr,promptSelect as Er,promptText as ir,promptYesNo as nr}from"./packem_shared/createConfirm-D5mKTMHj.mjs";import{buildPackageSecretsBlock as pr,ensureDevVariables as _r,ensureDevVarsExample as cr,fillDevSecrets as dr,generateSecretValue as Dr,isMintableSecretKey as mr,isPlaceholderValue as Ar,planDevSecretsFill as Sr,planDevVariablesAugment as fr,planDevVariablesScaffold as vr,requiredSecrets as Lr,writeDevVariablesFileAtomically as Nr}from"./packem_shared/buildPackageSecretsBlock-yv9mjKEW.mjs";import{applyAdditiveEdit as gr,classifyEdit as Tr}from"./packem_shared/applyAdditiveEdit-CH0VhMJ2.mjs";import{parseSchema as Vr}from"./packem_shared/parseSchema-D1Wbr1qv.mjs";import{classifyPolicyEdit as Pr,resolveServerModule as ur,scaffoldPolicyFile as Or,wireRlsIntoProcedure as Fr}from"./packem_shared/classifyPolicyEdit-D8NwrHxR.mjs";import{discoverSchemaInfo as Ur}from"./packem_shared/discoverSchemaInfo-DJvevsCm.mjs";import{ACCENT as br,BADGES as Mr,BADGE_COLUMN_WIDTH as yr,LUNA_ART as kr,LUNA_BUNNY as Br,LUNA_NAME as Kr,LUNA_SIGNOFF as wr,STEP_BADGE_NAMES as hr,badgeLead as jr,badgeWidth as Hr,padBadge as Wr,paintAnswer as Yr,paintBadge as Jr}from"./packem_shared/ACCENT-CotPTfv7.mjs";import{COMPOSED_WORKER_ENTRY as Xr,GENERATED_CLASS_MODULES as zr}from"./packem_shared/COMPOSED_WORKER_ENTRY-C69wqbSP.mjs";import{discoverWorkflowInfo as Zr}from"./packem_shared/discoverWorkflowInfo-BsPvlo6O.mjs";export{br as ACCENT,o as AGENT_MODE_ENV,i as AGENT_RULES_DIR,n as AGENT_RULES_HINT,l as AGENT_RULES_HINT_ENV,Mr as BADGES,yr as BADGE_COLUMN_WIDTH,S as CODEGEN_ENV,Xr as COMPOSED_WORKER_ENTRY,Ee as DEFAULT_DEPLOY_TARGET,F as DEV_BINDINGS_FILE,C as DEV_DAEMON_ENV,U as DEV_HANDOFF_ENV,G as DEV_LOG_FILE,b as DEV_LOG_FILE_ENV,M as DEV_STATE_DIR,y as DEV_STATE_FILE,q as DEV_VARS_EXAMPLE_FILE,X as DEV_VARS_FILE,z as DEV_VARS_KEY_PATTERN,oe as DEV_WORKER_ENV_VALUE,te as DEV_WORKER_ENV_VAR,zr as GENERATED_CLASS_MODULES,Se as LINKED_PROJECT_DIR,fe as LINKED_PROJECT_FILE,kr as LUNA_ART,Br as LUNA_BUNNY,Kr as LUNA_NAME,wr as LUNA_SIGNOFF,Ce as LUNORA_EVENT_SOURCE,Re as LUNORA_IGNORED_PATHS,p as LUNORA_SKILL_NAMES,Ve as LUNORA_TAG,be as LunoraReporter,Ye as PACKAGE_SECRETS_REGISTRY,_ as ROOT_SKILL_NAME,hr as STEP_BADGE_NAMES,P as acceptsConnection,ye as addArgsFor,Ie as advisoryLine,gr as applyAdditiveEdit,ge as applyLintIgnores,jr as badgeLead,Hr as badgeWidth,Pe as blockingFindingsMessage,pr as buildPackageSecretsBlock,c as claimAgentRulesHint,k as claimDevServerState,Tr as classifyEdit,Pr as classifyPolicyEdit,B as clearDevServerState,tr as createConfirm,ie as deployTargetIds,d as detectAgentRules,t as detectAiAgent,T as detectFramework,ke as detectInstalledManagers,Te as detectLintTools,Be as detectPackageManager,s as discoverAgentInfo,L as discoverContainerInfo,Ur as discoverSchemaInfo,Zr as discoverWorkflowInfo,_r as ensureDevVariables,cr as ensureDevVarsExample,ae as ensureDevWorkerEnv,Q as escapeRegExp,Ke as execArgsFor,dr as fillDevSecrets,Ue as formatLunoraEvent,Dr as generateSecretValue,De as inferLunoraBindings,we as installArgsFor,Qe as interpretRemote,f as isCodegenDisabled,K as isDevServerReady,ar as isInteractive,mr as isMintableSecretKey,Ar as isPlaceholderValue,w as isProcessAlive,h as isRecordedProcessCurrent,ne as isRunnableTarget,ue as lunoraLine,me as packageNamesFromBindings,Wr as padBadge,Yr as paintAnswer,Jr as paintBadge,Z as parseDevVariableEntries,Vr as parseSchema,Sr as planDevSecretsFill,fr as planDevVariablesAugment,vr as planDevVariablesScaffold,le as planToolchainInvocation,x as projectUsesUmbrella,sr as promptMultiSelect,Er as promptSelect,ir as promptText,nr as promptYesNo,j as readDevServerState,ve as readLinkedProject,H as readLiveDevServerState,V as readProjectDependencyNames,Ze as readProjectRemotePreference,$e as readProjectTarget,$ as removeDevVariableLine,Oe as reportCodegenFindings,Lr as requiredSecrets,pe as resolveDeployDriver,er as resolveProjectTarget,ur as resolveServerModule,rr as resolveTargetOrThrow,Xe as runPostCodegenHook,he as runScriptArgsFor,je as runScriptCommand,_e as runnableTargetIds,Or as scaffoldPolicyFile,Je as secretsForPackages,m as startCelldDevSession,u as startDevProcess,R as streamContainerLogs,ce as targetRunsOwnDevServer,He as toolchainExecArgs,W as updateDevServerState,ee as upsertDevVariableLine,Fr as wireRlsIntoProcedure,Y as writeDevServerState,Nr as writeDevVariablesFileAtomically,Le as writeLinkedProject};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const r={devServer:"workerd",prebuildsContainerImages:!0,deploy:o=>{const n=o.preview===!0?["versions","upload"]:["deploy"];return o.entry!==void 0&&n.push(o.entry),o.configPath!==void 0&&n.push("--config",o.configPath),o.environment!==void 0&&n.push("--env",o.environment),o.temporary===!0&&n.push("--temporary"),o.dryRun===!0&&n.push("--dry-run"),o.outDir!==void 0&&n.push("--outdir",o.outDir,"--metafile"),{args:n,tool:"wrangler"}},dev:o=>{const n=["dev"];return o.configPath!==void 0&&n.push("--config",o.configPath),o.environment!==void 0&&n.push("--env",o.environment),n.push(...o.extraArgs??[]),{args:n,tool:"wrangler"}},secretList:o=>{const n=["secret","list","--format","json"];return o.environment!==void 0&&n.push("--env",o.environment),o.temporary===!0&&n.push("--temporary"),{args:n,tool:"wrangler"}},secretPut:o=>{const n=["secret","put",o.key??""];return o.environment!==void 0&&n.push("--env",o.environment),o.temporary===!0&&n.push("--temporary"),{args:n,tool:"wrangler"}},tail:o=>{const n=["tail"];return o.worker!==void 0&&n.push(o.worker),o.environment!==void 0&&n.push("--env",o.environment),o.format!==void 0&&n.push("--format",o.format),o.status!==void 0&&n.push("--status",o.status),o.search!==void 0&&n.push("--search",o.search),o.temporary===!0&&n.push("--temporary"),{args:n,tool:"wrangler"}}},i={id:"cloudflare",name:"Cloudflare",toolchain:r};export{i as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{p as a}from"./celld-config-D-L6uskI.mjs";import s from"./CLOUDFLARE_DRIVER-Ci3VIqnk.mjs";const p=[["entry","`celld deploy` deploys the config's `main`; a composed framework entry has no celld equivalent yet"],["environment","celld has no Wrangler environments — deploy a separate config per environment"],["outDir","`celld deploy` does not write its bundle to disk"],["preview","celld has no preview versions — a deploy replaces the fleet's current deployment"],["temporary","celld has no short-lived accounts — it deploys to the fleet bucket in CELLD_BUCKET"]],l=e=>{if(e===void 0)throw new Error("the celld driver runs the projected wrangler config — pass `configPath` from `projectConfig`");return e},v={deploy:e=>{const o=p.find(([r])=>e[r]!==void 0&&e[r]!==!1);if(o!==void 0)throw new Error(o[1]);return{args:["deploy",l(e.configPath),...e.dryRun===!0?["--dry-run"]:[]],onPath:!0,tool:"celld"}},devServer:"own",prebuildsContainerImages:!1,dev:e=>{if(e.environment!==void 0)throw new Error("celld has no Wrangler environments — `celld dev` runs the top-level config");return{args:["dev",l(e.configPath),...e.extraArgs??[]],onPath:!0,tool:"celld"}}},f={id:"celld",name:"celld",projectConfig:a,toolchain:v},h={id:"node",name:"Node"},m="cloudflare",t={celld:f,cloudflare:s,node:h},d=()=>Object.keys(t).toSorted((e,o)=>e.localeCompare(o)),c=(e=m)=>{const o=t[e];if(o===void 0)throw new Error(`unknown deploy target "${e}" — available targets: ${d().join(", ")}`);return o},g=e=>Object.hasOwn(t,e)&&c(e).toolchain!==void 0,y=()=>d().filter(e=>g(e)),D=e=>c(e).toolchain?.devServer==="own",O=(e,o,r,i)=>{const n=e.projectConfig?.(o,r);return{command:i(n?.configPath),commit:()=>n?.write(),projection:n===void 0?void 0:{configPath:n.configPath,dropped:n.dropped}}};export{m as DEFAULT_DEPLOY_TARGET,d as deployTargetIds,g as isRunnableTarget,O as planToolchainInvocation,c as resolveDeployDriver,y as runnableTargetIds,D as targetRunsOwnDevServer};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{writeFileSync as p,rmSync as m}from"node:fs";import{applyModify as g}from"./applyModify-DKP2l6S9.mjs";import{r as b}from"./lunora-manifest-v90ZUbVp.mjs";import{o as h}from"./reconcile-services-3dn35zgy.mjs";import{findWranglerFile as y,readWranglerJsonc as v}from"./WRANGLER_FILES-UNW-xY5u.mjs";import{join as E}from"node:path";const d={ai:{label:"AI",shape:"object"},d1_databases:{label:"D1",shape:"array"},kv_namespaces:{label:"KV",shape:"array"},queues:{label:"Queue",shape:"producers"},r2_buckets:{label:"R2",shape:"array"},services:{label:"Service",shape:"array"},vectorize:{label:"Vectorize",shape:"array"}},S=Object.keys(d),f=(e,r)=>typeof e.binding=="string"?e.binding:r,c=(e,r,n,t)=>{const o=[];for(const[a,i]of r.entries())i!=null&&o.push({binding:f(i,`#${String(a)}`),kind:n,path:[...t,a],section:e});return o},R=(e,r)=>{const{label:n,shape:t}=d[e];if(t==="array"){const a=r[e]??[];return c(e,a,n,[])}if(t==="producers")return c(e,r.queues?.producers??[],n,["producers"]);const o=r.ai;return o==null?[]:[{binding:f(o,e),kind:n,path:[],section:e}]},B=e=>S.flatMap(r=>R(r,e)),j=(e,r)=>{let n=e;for(const t of r)n=g(n,[t.section,...t.path,"remote"],!0);return n},s=()=>{},_=e=>{let r=!1;return()=>{if(!r){r=!0;try{m(e,{force:!0,recursive:!0})}catch{}}}};let u=0;const C=()=>(u+=1,`.wrangler.lunora-remote.${String(process.pid)}.${String(u)}.jsonc`),O=e=>{if(!e.enabled)return{cleanup:s,enabled:!1,remoteBindings:[]};const r=y(e.projectRoot);if(!r)return{cleanup:s,enabled:!0,reason:"wrangler.jsonc not found",remoteBindings:[]};const{parsed:n,text:t}=v(r);if(n===void 0)return{cleanup:s,enabled:!0,reason:`failed to parse ${r} as JSONC`,remoteBindings:[]};const o=h(b(e.projectRoot)),a=B(n).filter(l=>l.section!=="services"||!o.has(l.binding));if(a.length===0)return{cleanup:s,enabled:!0,reason:"no remote-eligible bindings to proxy",remoteBindings:[]};const i=E(e.projectRoot,C());return p(i,j(t,a),"utf8"),{cleanup:_(i),configPath:i,enabled:!0,remoteBindings:a}},w=e=>{if(e===void 0)return!1;const r=e.trim().toLowerCase();return r==="1"||r==="true"},$=e=>e.flag===!0||w(e.envValue)?!0:e.configPreference??!1;export{d as REMOTE_ELIGIBLE_KEYS,j as injectRemoteFlags,w as isRemoteEnvEnabled,O as materializeRemoteWranglerConfig,B as planRemoteBindings,$ as resolveRemoteEnabled};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{spawn as f}from"node:child_process";import{connect as h}from"node:net";const m=150,p=5e3,E=(e,t,r)=>f(e,[...t],{cwd:r.cwd,shell:r.shell,stdio:["ignore","pipe","pipe"]}),x=async e=>new Promise(t=>{const r=h({host:"127.0.0.1",port:e}),o=s=>{r.destroy(),t(s)};r.once("connect",()=>{o(!0)}),r.once("error",()=>{o(!1)})}),d=(e,t)=>{let r="";e?.setEncoding("utf8"),e?.on("data",o=>{r+=o;const s=r.split(`
|
|
2
|
+
`);r=s.pop()??"";for(const a of s)t(a)}),e?.once("end",()=>{r!==""&&(t(r),r="")})},w=e=>e.exitCode!==null||e.signalCode!==null,L=async e=>{const t=(e.spawn??E)(e.command,e.args,{cwd:e.cwd,shell:e.shell===!0});let r=!1,o,s;d(t.stdout,n=>{e.onLine(n,"stdout")}),d(t.stderr,n=>{e.onLine(n,"stderr")}),t.once("error",n=>{o=n.code==="ENOENT"?new Error(e.notFound):n}),t.once("exit",n=>{s??=new Error(`${e.label} exited with code ${String(n)} before it was ready`)});const a=new Promise(n=>{t.once("exit",i=>{r||n(i??1)})}),l=()=>{t.kill("SIGKILL")};process.once("exit",l);const c=async()=>{r=!0,process.removeListener("exit",l),!w(t)&&await new Promise(n=>{const i=setTimeout(()=>{t.kill("SIGKILL")},p);t.once("exit",()=>{clearTimeout(i),n()}),t.kill("SIGTERM")})},u=Date.now()+e.readyTimeoutMs;for(;Date.now()<u;){const n=o??s;if(n!==void 0)throw process.removeListener("exit",l),n;if(e.signal?.aborted===!0)throw await c(),new Error(`${e.label} was stopped before it was ready`);if(await x(e.port)){if(w(t))throw await c(),new Error(`the server on port ${String(e.port)} is not the ${e.label} started here — it exited while something else took the port`);return{crashed:a,stop:c}}await new Promise(i=>{setTimeout(i,m)})}throw await c(),new Error(`${e.label} did not accept connections on port ${String(e.port)} within ${String(e.readyTimeoutMs/1e3)}s`)};export{x as acceptsConnection,L as startDevProcess};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{writeFileSync as $,rmSync as V,existsSync as b,readFileSync as j}from"node:fs";import{dirname as E,resolve as h,join as y,sep as g,relative as v,isAbsolute as R}from"node:path";import{findWranglerFile as W,readWranglerJsonc as x}from"./WRANGLER_FILES-UNW-xY5u.mjs";import{DEV_VARS_FILE as F,parseDevVariableEntries as L}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";const B=".celld.wrangler.json",Y=y(".wrangler","deploy","config.json"),J=new Set(["$schema","assets","compatibility_date","compatibility_flags","containers","d1_databases","define","durable_objects","kv_namespaces","main","migrations","name","no_bundle","queues","r2_buckets","rules","services","triggers","vars","worker_loaders","workflows"]),K=new Set(["class_name","image","instance_type","max_instances","name","runtime"]),q=new Set(["CompiledWasm","Data","Text"]),G=/\r?\n/u,M=/[!*?[]/u,U=/[.[]/u,X=["deleted_classes","new_classes","renamed_classes","transferred_classes"],l=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),O=e=>Array.isArray(e)&&e.length===0||l(e)&&Object.values(e).every(t=>O(t)),z=e=>Array.isArray(e)?e.map(t=>{if(!l(t))return t;const s=X.find(r=>t[r]!==void 0);if(s!==void 0)throw new Error(`migration "${String(t.tag)}" uses \`${s}\`, which celld refuses — celld accepts only \`new_sqlite_classes\` migrations`);return{new_sqlite_classes:t.new_sqlite_classes,tag:t.tag}}):e,H=(e,t)=>Array.isArray(e)?e.map((s,r)=>l(s)?Object.fromEntries(Object.entries(s).filter(([n])=>{const o=K.has(n);return o||t.push(`containers[${String(r)}].${n}`),o})):s):e,Q=(e,t)=>Array.isArray(e)?e.filter((s,r)=>{const n=l(s)&&typeof s.type=="string"&&q.has(s.type);return n||t.push(`rules[${String(r)}]`),n}):e,Z=e=>{const t=[],s={};for(const[r,n]of Object.entries(l(e)?e:{}))l(n)&&n.type==="workflow"?t.push({binding:r,class_name:r,name:n.name}):s[r]=n;return{bindings:t,rest:s}},k=e=>{const t=[],s={},r=Z(e.exports),n={...e,exports:r.rest};for(const[o,i]of Object.entries(n)){if(!J.has(o)){O(i)||t.push(o);continue}switch(o){case"containers":{s[o]=H(i,t);break}case"migrations":{s[o]=z(i);break}case"rules":{s[o]=Q(i,t);break}default:s[o]=i}}if(r.bindings.length>0){const o=Array.isArray(s.workflows)?s.workflows:[];s.workflows=[...o,...r.bindings]}return{config:s,dropped:t}},ee=e=>{const[t=[],...s]=e.map(n=>h(n).split(g));let r=0;for(;r<t.length&&s.every(n=>n[r]===t[r]);)r+=1;return t.slice(0,r).join(g)||g},C=(e,t,s)=>{const r=o=>v(s,h(t,o)).split(g).join("/"),n={...e};return typeof e.main=="string"&&(n.main=r(e.main)),l(e.assets)&&typeof e.assets.directory=="string"&&(n.assets={...e.assets,directory:r(e.assets.directory)}),n},se=e=>{const t=y(e,".assetsignore");if(!b(t))return;const s=j(t,"utf8").split(G).map(r=>r.trim()).filter(r=>r!==""&&!r.startsWith("#")).filter(r=>M.test(r)||b(y(e,r)));if(s.length>0)throw new Error(`${t} hides ${s.join(", ")} from the assets, and celld has no .assetsignore — remove those files from ${e} first`);return t},re=(e,t)=>{const s=y(e,Y);if(!b(s))throw new Error(`wrangler \`main\` is the Vite virtual module "${t}", so celld deploys the Vite build output — and there is none yet. Run the project's build (\`vite build\`) first`);const{configPath:r}=JSON.parse(j(s,"utf8"));if(typeof r!="string")throw new TypeError(`${s} names no configPath`);return h(E(s),r)},A=e=>{const{parsed:t}=x(e);if(t===void 0)throw new Error(`${e} is not valid JSONC`);return t},D=(e,t,s,r)=>{const{d1_databases:n}=e;if(!Array.isArray(n)||r===s)return e;const o=Array.isArray(t.d1_databases)?t.d1_databases.filter(i=>l(i)):[];return{...e,d1_databases:n.map(i=>{if(!l(i))return i;const a=o.find(w=>w.binding===i.binding),c=a?.migrations_dir,f=h(s,typeof c=="string"?c:"migrations"),d=b(f)?{...i,migrations_dir:v(r,f).split(g).join("/")}:i,u=a?.migrations_pattern;return typeof u=="string"?{...d,migrations_pattern:v(r,h(s,u)).split(g).join("/")}:d})}},te=(e,t,s,r)=>{const{main:n}=s;if(typeof n!="string"||!n.startsWith("virtual:"))return{fromBuild:!1,source:s,sourcePath:t};if(r==="dev")throw new Error(`wrangler \`main\` is the Vite virtual module "${n}", which only a Vite build can resolve — \`celld dev\` rebuilds from a source file. Use \`vite dev\` for the dev loop and \`lunora deploy\` to ship the build to celld, or point \`main\` at a worker file`);const o=re(e,n);return{fromBuild:!0,source:A(o),sourcePath:o}},ne=(e,t,s,r,n)=>{const o=t.filter(c=>Object.hasOwn(s,c.split(U)[0]??c));let i=e;e.no_bundle!==void 0&&(i=Object.fromEntries(Object.entries(e).filter(([c])=>c!=="no_bundle")),o.push("no_bundle (celld re-bundles the build output)"));const a=r===void 0?void 0:se(r);return a!==void 0&&o.push(`${v(n,a)} (matched no files)`),{assetsIgnore:a,projected:i,reported:o}},I=e=>{const t=l(e.vars)?e.vars:{};return{...e,vars:{WORKER_ENV:"development",...t}}},le=(e,t)=>{const s=W(e);if(s===void 0)throw new Error(`no wrangler.jsonc or wrangler.json in ${e} — celld deploys from the project's Wrangler config`);const r=A(s),{fromBuild:n,source:o,sourcePath:i}=te(e,s,r,t),a=E(i),{config:c,dropped:f}=k(o),{assets:d}=o,u=l(d)&&typeof d.directory=="string"?h(a,d.directory):void 0,w=typeof o.main=="string"?E(h(a,o.main)):void 0,p=ee([a,w,u].filter(T=>T!==void 0));if(!n&&p!==a)throw new Error(`wrangler \`main\` and \`assets.directory\` must sit inside ${a} — celld resolves everything against the config's directory`);const _=D(C(c,a,p),r,e,p),m=n?ne(_,f,r,u,p):{assetsIgnore:void 0,projected:_,reported:f},N=t==="dev"?I(m.projected):m.projected,S=y(p,B),P=`${JSON.stringify(N,void 0,4)}
|
|
2
|
+
`;return{configPath:S,dropped:m.reported,write:()=>{$(S,P),m.assetsIgnore!==void 0&&V(m.assetsIgnore)}}},de=(e,t)=>{const s=A(t),r=E(t),{config:n,dropped:o}=k(s),i=typeof s.name=="string"?s.name:"service",a=v(e,r);if(a===".."||a.startsWith(`..${g}`)||R(a))throw new Error(`service ${i} (${r}) must sit inside ${e} — celld dev runs it from a config beside the app's`);const c=y(r,F),f=b(c)?Object.fromEntries(L(j(c,"utf8")).map(({key:_,value:m})=>[_,m])):{},d=D(C(n,r,e),s,r,e),u=l(d.vars)?d.vars:{},w=y(e,`.celld.service.${i.replaceAll(/[^\w.-]/gu,"-")}.wrangler.json`),p=`${JSON.stringify(I({...d,vars:{...u,...f}}),void 0,4)}
|
|
3
|
+
`;return{configPath:w,dropped:o,write:()=>{$(w,p)}}};export{de as a,le as p};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{readFileSync as W,writeFileSync as Y}from"node:fs";import{createRequire as G}from"node:module";import{join as M}from"node:path";import{containerBuildTag as H}from"@lunora/container";import{applyModify as x}from"./applyModify-DKP2l6S9.mjs";import{a as J,r as R}from"./lunora-manifest-v90ZUbVp.mjs";import{parseTree as V,findNodeAtLocation as X}from"jsonc-parser";import{r as z,a as Z,b as ee,c as ne}from"./reconcile-services-3dn35zgy.mjs";import{DEV_VARS_FILE as se,parseDevVariableEntries as te}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{packageNamesFromBindings as oe}from"./inferLunoraBindings-DXLEJY9w.mjs";import{requiredSecrets as re}from"./buildPackageSecretsBlock-yv9mjKEW.mjs";import{w as ie,m as ae,s as L,o as I,n as j,p as de}from"./validate-bindings-Dnf1t0SY.mjs";import{findWranglerFile as ce,readWranglerJsonc as le}from"./WRANGLER_FILES-UNW-xY5u.mjs";const ue=[["maxBatchSize","max_batch_size"],["maxBatchTimeout","max_batch_timeout"],["maxRetries","max_retries"],["deadLetterQueue","dead_letter_queue"],["retryDelay","retry_delay"]],P=e=>Object.fromEntries(ue.filter(([n])=>e.tuning[n]!==void 0).map(([n,s])=>[s,e.tuning[n]])),B="queueTuning",ge=/^[\t ]*(?:,[\t ]*)?(?:\/\/[^\n\r]*)?\r?\n/u,pe=/^[\t ]*,/u,me=(e,n)=>{const s=V(e),t=s===void 0?void 0:X(s,[...n])?.parent;if(t?.type==="property"){const r=t.offset+t.length,o=e.lastIndexOf(`
|
|
2
|
+
`,t.offset-1)+1,l=ge.exec(e.slice(r));if(l!==null&&e.slice(o,t.offset).trim()===""){const u=t.parent?.children??[],h=u.indexOf(t),a=h===u.length-1&&h>0?u[h-1]:void 0,d=a===void 0?void 0:pe.exec(e.slice(a.offset+a.length))??void 0;return(d===void 0||a===void 0?e.slice(0,o):e.slice(0,a.offset+a.length)+e.slice(a.offset+a.length+d[0].length,o))+e.slice(r+l[0].length)}}return x(e,n,void 0)},K=(e,n,s,t,r,o=new Set)=>{const l=s.join("."),u={},h=[],a=[];let d=e;return{entries:n.map((c,v)=>{const g=t(c);if(g===void 0||c.queue===void 0)return c;const m=Object.fromEntries(Object.entries(P(g)).filter(([f])=>!o.has(f))),b=Object.entries(r[c.queue]??{}).filter(([f])=>!Object.hasOwn(m,f)),w=Object.entries(m).filter(([f,_])=>c[f]!==_),k=b.filter(([f,_])=>c[f]===_).map(([f])=>f),S=Object.fromEntries(Object.entries({...c,...m}).filter(([f])=>!k.includes(f)));for(const[f,_]of w)d=x(d,[...s,v,f],_);for(const f of k)d=me(d,[...s,v,f]);for(const[f,_]of b){const N=c[f];N!==void 0&&N!==_&&a.push(`${l}/${c.queue}: ${f} is no longer declared by defineQueue, but it was changed by hand to ${JSON.stringify(N)} from the declared ${JSON.stringify(_)}, so it was kept. Delete it from wrangler.jsonc if it should go.`)}return(w.length>0||k.length>0)&&h.push(`${l}/${c.queue} (${[...w.map(([f])=>f),...k.map(f=>`removed ${f}`)].join(", ")})`),Object.keys(m).length>0&&(u[c.queue]=m),S}),owned:u,text:d,updated:h,warnings:a}},fe=(e,n,s,t)=>{const r=n.queues??{},o=r.producers??[],l=r.consumers??[],u=new Set(o.map(g=>g.binding)),h=new Set(l.map(g=>g.queue)),a=s.filter(g=>!u.has(g.bindingName)),d=s.filter(g=>!h.has(g.name)),p=K(e,l,["queues","consumers"],g=>s.find(m=>m.name===g.queue),t);let c=p.text;const v={...p.owned};if(a.length>0||d.length>0){const g=[...o,...a.map(b=>({binding:b.bindingName,queue:b.name}))],m=[...p.entries,...d.map(b=>({queue:b.name,...b.mode==="pull"?{type:"http_pull"}:{},...P(b)}))];for(const b of d){const w=P(b);Object.keys(w).length>0&&(v[b.name]=w)}c=x(c,["queues"],{consumers:m,producers:g})}return{added:[...a.map(g=>`queues.producers/${g.bindingName}`),...d.map(g=>`queues.consumers/${g.name}`)],owned:v,text:c,updated:p.updated,warnings:p.warnings}},he=(e,n,s,t,r)=>{const o=n.env?.[t],l=o?.queues?.consumers??[],u=o?.queues?.producers??[],h=c=>{const v=u.find(g=>g.queue===c.queue)?.binding;return v!==void 0?s.find(g=>g.bindingName===v):s.find(g=>g.name===c.queue&&!u.some(m=>m.binding===g.bindingName))},a=K(e,l,["env",t,"queues","consumers"],h,r,new Set(["dead_letter_queue"])),d=l.filter(c=>c.queue!==void 0&&h(c)===void 0).map(c=>`env.${t}.queues.consumers/${String(c.queue)}: no defineQueue export matches it — this block declares no producer mapping one of their bindings to "${String(c.queue)}", and no export is named that — so it was not retuned. A consumer for a queue another worker produces is skipped the same way.`),p=l.flatMap(c=>{const v=h(c)?.tuning.deadLetterQueue;return v===void 0||c.dead_letter_queue!==void 0?[]:[`env.${t}.queues.consumers/${String(c.queue)}: defineQueue declares deadLetterQueue "${v}", but this consumer has no dead_letter_queue, so its exhausted messages are dropped. Queue names differ per environment, so reconcile does not write it here; add it by hand.`]});return{added:[],owned:a.owned,text:a.text,updated:a.updated,warnings:[...a.warnings,...p,...d]}},be=(e,n)=>{if(e?.lunoraIsForeign===!0)return n.push(`${e.path}: \`lunora\` is not an object, so the queue tuning ownership record cannot be read or written — an option removed from defineQueue stays deployed.`),{};const s=e?.lunora?.[B],t=r=>typeof r=="object"&&r!==null&&!Array.isArray(r);return s===void 0?{}:!t(s)||!Object.values(s).every(r=>t(r)&&Object.values(r).every(o=>t(o)))?(n.push(`${e?.path??"package.json"}: \`lunora.${B}\` is not a map of scope → queue → fields, so it is ignored — an option removed from defineQueue stays deployed until the next pass records it again.`),{}):s},ve=(e,n,s)=>{const t=Object.fromEntries(Object.entries({...n,...s}).filter(([,r])=>Object.keys(r).length>0));J(e,B,Object.keys(t).length===0?void 0:t)},A="PIPELINES",we=(e,n)=>{const s=e.flagshipBinding!==void 0&&!(n?.flagship??[]).some(o=>o.binding===e.flagshipBinding),t=e.usesPipelines&&!(n?.pipelines??[]).some(o=>o.binding===A);return[[e.usesKv&&(n?.kv_namespaces?.length??0)===0,"@lunora/bindings/kv is used but no kv_namespaces binding exists; add a kv_namespaces entry ({ binding, id }) and pass env.<BINDING> to createKv() — the namespace id can't be auto-provisioned."],[e.usesHyperdrive&&(n?.hyperdrive?.length??0)===0,"@lunora/hyperdrive is used but no hyperdrive binding exists; run 'wrangler hyperdrive create' and add a 'hyperdrive' binding ({ binding, id }) — the id can't be auto-provisioned."],[t,`ctx.pipelines is used but no "${A}" pipelines binding exists; run 'wrangler pipelines create <name>' and add a 'pipelines' binding ({ binding: "${A}", stream }) — codegen resolves this one name, and the pipeline resource can't be auto-provisioned.`],[s,`lunora/flags.ts uses Flagship in binding mode but no flagship binding "${e.flagshipBinding??""}" exists; add a flagship entry ({ binding: "${e.flagshipBinding??""}", app_id }) — the app_id can't be auto-provisioned.`]].filter(([o])=>o).map(([,o])=>o)},ye=e=>[[e.usesX402Charge,"@lunora/x402/charge is used; set the recipient wallet address as a [vars] entry (the var name is your choice) and pass it to the charge config — the x402 facilitator settles USDC to that address."],[e.usesX402Pay,"@lunora/x402/pay is used (ActionCtx-only, spends real funds); add a secrets_store_secrets[] binding holding the agent wallet key (binding name == signer.secretName) and pair the pay rail with a spend policy — ctx.secrets reads a Secrets Store binding, not .dev.vars."]].filter(([s])=>s).map(([,s])=>s),C=(e,n,s)=>s.filter(t=>!t.exported).map(t=>`${e} "${t.exportName}" is declared but ${t.className} is not exported by the worker entry; add \`export * from "./lunora/_generated/${n}"\` so its binding can be provisioned.`),_e=(e,n)=>{const s=new Set([...e.workflows,...e.agents].map(o=>o.className));if(s.size===0)return[];const t=Object.entries(n.exports??{}).flatMap(([o,l])=>l?.type==="workflow"?[o]:[]),r=(n.workflows??[]).flatMap(o=>o.class_name===void 0||o.script_name!==void 0?[]:[o.class_name]);return[...new Set([...t,...r])].filter(o=>!s.has(o)).map(o=>`wrangler.jsonc declares workflow "${o}" but no defineWorkflow/defineAgent export generates that class — a leftover from a rename will fail the deploy (wrangler rejects a class the worker does not export). Remove it if it is not hand-wired.`)},xe=(e,n)=>{if(e.queues.length===0)return[];const s=new Set(e.queues.map(r=>r.name)),t=new Set(e.queues.map(r=>r.bindingName));return[...(n.queues?.consumers??[]).flatMap(r=>{const{queue:o}=r;return o===void 0||s.has(o)?[]:[`wrangler.jsonc subscribes queues.consumers[] to "${o}" but no defineQueue export declares that queue — a leftover from a rename keeps delivering batches this worker has no handler for (they retry to exhaustion, then drop or dead-letter). Remove it if it is not hand-wired.`]}),...(n.queues?.producers??[]).flatMap(r=>{const{binding:o}=r;return o===void 0||t.has(o)?[]:[`wrangler.jsonc declares queues.producers[] binding "${o}" but no defineQueue export declares it — a leftover from a rename. Remove it if it is not hand-wired.`]})]},ke=(e,n)=>[..._e(e,n),...xe(e,n)],Q=[{keys:["STRIPE_SECRET_KEY","STRIPE_WEBHOOK_SECRET"],label:"Stripe"},{keys:["POLAR_ACCESS_TOKEN","POLAR_WEBHOOK_SECRET"],label:"Polar"},{keys:["CREEM_API_KEY","CREEM_WEBHOOK_SECRET"],label:"Creem"},{keys:["AUTUMN_SECRET_KEY","AUTUMN_WEBHOOK_SECRET"],label:"Autumn"},{keys:["DODO_PAYMENTS_API_KEY","DODO_PAYMENTS_WEBHOOK_KEY"],label:"Dodo Payments"}],Se=()=>Q.map(({keys:e,label:n})=>`${e[0]} + ${e[1]} (${n})`).join(" or "),Oe=e=>{let n;try{n=W(M(e,se),"utf8")}catch{return!1}const s=new Map(te(n).map(t=>[t.key,t.value]));return Q.some(({keys:t})=>t.every(r=>(s.get(r)??"")!==""))},Ne=(e,n)=>{const s=n?.secrets?.required;if(!Array.isArray(s))return[];const t=new Set(s),r=re(oe(e)).map(o=>o.key).filter(o=>!t.has(o));return r.length===0?[]:[`wrangler.jsonc declares secrets.required without ${r.join(", ")}, which this app needs — wrangler dev loads only the listed keys from .dev.vars, so add ${r.length===1?"it":"them"} to secrets.required.`]},D=(e,n,s)=>{const t=new Set(e.durableObjects.map(u=>u.className)),r=[],o=(s?.r2_buckets?.length??0)>0,l=(s?.d1_databases?.some(u=>u.binding==="DB")??!1)||e.needsD1;return e.usesStorage&&!o&&r.push("@lunora/storage is used but R2 bucket bindings have user-defined names; add an r2_buckets entry and pass env.<BINDING> to createStorage()."),e.usesAuth&&!t.has("SessionDO")&&!l&&r.push("@lunora/auth is used but the worker entry exports no SessionDO; sessions are D1-backed, or export SessionDO to enable DO-backed sessions."),e.usesScheduler&&!t.has("SchedulerDO")&&r.push("@lunora/scheduler is used but the worker entry exports no SchedulerDO; export it so the SCHEDULER binding can be provisioned."),r.push(...C("container","containers",e.containers),...C("workflow","workflows",e.workflows),...C("agent","agents",e.agents)),e.containers.length>0&&s?.observability?.enabled===!1&&r.push("containers are declared but observability is explicitly disabled in wrangler.jsonc — container logs will not be captured."),e.usesPayment&&!Oe(n)&&r.push(`@lunora/payment is used; set one provider's secret pair in .dev.vars — ${Se()}.`),r.push(...ye(e),...we(e,s),...Ne(e,s)),s!==void 0&&r.push(...ke(e,s)),r},F="<replace-with-d1-create-id>",Ee=e=>[["container","containers",e.containers],["workflow","workflows",e.workflows],["agent","agents",e.agents]].flatMap(([s,t,r])=>r.filter(o=>!o.exported).map(({className:o,exportName:l})=>({className:o,exportName:l,kind:s,module:t}))),$e=e=>{const n=new Set(I(e).map(t=>t.tag));let s=1;for(;n.has(`v${String(s)}`);)s+=1;return`v${String(s)}`},qe=e=>{const n=new Set;for(const s of I(e)){for(const t of j(s.deleted_classes))n.delete(t);for(const{from:t,to:r}of I(s.renamed_classes))t!==void 0&&n.delete(t),r!==void 0&&n.add(r);for(const t of[...j(s.new_classes),...j(s.new_sqlite_classes)])n.add(t)}return n},je=(e,n,s)=>{const t=n.durable_objects?.bindings??[],r=new Set(t.map(d=>d.name)),o=s.filter(d=>!r.has(d.binding));let l=e;const u=[];if(o.length>0){const d=[...t,...o.map(p=>({class_name:p.className,name:p.binding}))];l=x(l,["durable_objects","bindings"],d),u.push(...o.map(p=>`${p.binding}/${p.className}`))}const h=n.migrations??[],a=s.map(d=>d.className).filter(d=>!qe(h).has(d));if(a.length>0){const d=[...h,{new_sqlite_classes:a,tag:$e(h)}];l=x(l,["migrations"],d)}return{added:u,text:l}},Ae=(e,n)=>{const s=n.d1_databases??[];if(s.some(o=>o.binding==="DB"))return{added:[],text:e};const t=typeof n.name=="string"&&n.name.length>0?n.name:"lunora",r=[...s,{binding:"DB",database_id:F,database_name:t}];return{added:["DB (D1)"],text:x(e,["d1_databases"],r)}},T=(e,n,s,t,r)=>{const o=n[s]?.binding;return typeof o=="string"&&o.length>0?{added:[],text:e}:{added:[r],text:x(e,[s],{binding:t})}},Ce=(e,n)=>(n.analytics_engine_datasets?.length??0)>0?{added:[],text:e}:{added:["ANALYTICS (Analytics Engine)"],text:x(e,["analytics_engine_datasets"],[{binding:"ANALYTICS",dataset:"ANALYTICS"}])},De=(e,n)=>{const s=n.worker_loaders??[];return s.some(t=>t.binding==="LOADER")?{added:[],text:e}:{added:["LOADER (Worker Loader)"],text:x(e,["worker_loaders"],[...s,{binding:"LOADER"}])}},Te=e=>{if(typeof e=="string")return e;const n={};return e.diskMb!==void 0&&(n.disk_mb=e.diskMb),e.memoryMib!==void 0&&(n.memory_mib=e.memoryMib),e.vcpu!==void 0&&(n.vcpu=e.vcpu),n},Ie=e=>{const{image:n}=e;return n.kind==="dockerfile"?n.dockerfilePath:n.kind==="registry"?n.reference:H(e.exportName)},U=e=>{const n={};for(const[s,t]of Object.entries(e.images??{}))n[s]=t.kind==="registry"?{image:t.reference}:{build_context:t.buildContext,dockerfile:t.dockerfilePath,...e.buildArgs===void 0?{}:{build_vars:e.buildArgs}};return{class_name:e.className,scheduling_policy:"durable_object",...Object.keys(n).length>0?{images:n}:{},...e.name===void 0?{}:{name:e.name}}},Pe=e=>{if(e.schedulingPolicy==="durable_object")return U(e);const{image:n}=e,s={class_name:e.className,image:Ie(e)};return n.kind==="dockerfile"&&(s.image_build_context=n.buildContext),e.buildArgs!==void 0&&n.kind!=="registry"&&(s.image_vars=e.buildArgs),e.instanceType!==void 0&&(s.instance_type=Te(e.instanceType)),e.maxInstances!==void 0&&(s.max_instances=e.maxInstances),e.name!==void 0&&(s.name=e.name),e.rollout?.stepPercentage!==void 0&&(s.rollout_step_percentage=e.rollout.stepPercentage),e.rollout?.gracePeriodSeconds!==void 0&&(s.rollout_active_grace_period=e.rollout.gracePeriodSeconds),s},Be=(e,n,s)=>{const t=n.containers??[],r=new Set(t.map(a=>a.class_name)),o=s.filter(a=>!r.has(a.className));let l=o.length===0?e:x(e,["containers"],[...t,...o.map(a=>Pe(a))]);const u=[],h=[];for(const[a,d]of t.entries()){const p=s.find(g=>g.className===d.class_name);if(p===void 0)continue;const c=p.schedulingPolicy??"default";if((d.scheduling_policy??"default")!==c){h.push(`containers/${p.className} has scheduling_policy "${d.scheduling_policy??"default"}" in wrangler.jsonc but defineContainer "${p.exportName}" declares "${c}" — the policy is immutable, so replace the entry (and its container application) by hand.`);continue}const v=p.schedulingPolicy==="durable_object"?U(p).images:void 0;v!==void 0&&JSON.stringify(d.images)!==JSON.stringify(v)&&(l=x(l,["containers",a,"images"],v),u.push(`containers/${p.className}.images`))}return{added:o.map(a=>`containers/${a.className}`),text:l,updated:u,warnings:h}},Re=(e,n)=>{if(n.observability!==void 0)return{added:[],text:e};const s=x(e,["observability"],{enabled:!0,head_sampling_rate:1});return{added:["observability"],text:s}},We=[{minimum:[4,142],name:"wrangler"},{minimum:[1,61],name:"@cloudflare/vite-plugin"}],Me=(e,n)=>{try{const s=G(M(e,"package.json")).resolve(`${n}/package.json`),[t=0,r=0]=String(JSON.parse(W(s,"utf8")).version).split(".").map(Number);return[t,r]}catch{return}},Le=e=>{const n=We.flatMap(({minimum:s,name:t})=>{const r=Me(e,t);return r!==void 0&&(r[0]<s[0]||r[0]===s[0]&&r[1]<s[1])?[`${t} ${r.join(".")} (needs >= ${s.join(".")})`]:[]});return n.length===0?void 0:`workflows are declared in wrangler \`exports\`, which ${n.join(" and ")} cannot run — reconcile left workflows[] untouched. Upgrade (\`pnpm add -D wrangler@^4.143.1 @cloudflare/vite-plugin@^1.62.1\`) and re-run.`},Ke=e=>Object.entries(e.env??{}).flatMap(([n,s])=>Array.isArray(s?.workflows)?[`env.${n}.workflows declares workflow bindings, but Lunora now declares workflows in \`exports\` and resolves them on ctx.exports — move them to that environment's own \`exports\` by hand.`]:[]),Qe=(e,n,s)=>{let t=e;const r=[],o=[];for(const l of s){const u=n[l.className];if(u?.type==="workflow")for(const{of:h,path:a}of de){const d=h(l),p=L(u,a),c=`exports/${l.className}.${a.join(".")}`;if(d===void 0){p!==void 0&&o.push(`${c} is set in wrangler.jsonc but defineWorkflow "${l.exportName}" does not declare it — reconcile leaves it in place. Remove it by hand if it was dropped from the definition.`);continue}JSON.stringify(p)!==JSON.stringify(d)&&(t=x(t,["exports",l.className,...a],d),r.push(c))}}return{text:t,updated:r,warnings:o}},Fe=(e,n,s,t,r)=>{if(r!==void 0)return{added:[],text:e,warnings:[r]};const o=[...s.map(m=>({settings:ie(m),workflow:m})),...t.map(m=>({settings:{},workflow:m}))],l=new Set(o.map(({workflow:m})=>m.className)),u=n.workflows??[],h=u.filter(m=>m.script_name===void 0&&m.class_name!==void 0&&l.has(m.class_name)),a=n.exports??{},d=[],p=[],c=[];let v=e;for(const{settings:m,workflow:b}of o){if(a[b.className]!==void 0&&a[b.className]!==null)continue;const w=h.find(f=>f.class_name===b.className),k=Object.fromEntries(ae.flatMap(f=>{const _=L(w,[f]);return _===void 0?[]:[[f,_]]})),S=w?.name??b.name;w?.name!==void 0&&w.name!==b.name&&c.push(`workflows/${b.className} is deployed as "${w.name}" but declared as "${b.name}" — its export keeps "${w.name}" so running instances survive. Change the declaration to match, or rename deliberately (it starts a new, empty workflow).`),v=x(v,["exports",b.className],{type:"workflow",...k,...m,name:S}),(w===void 0?d:p).push(`exports/${b.className}`)}if(h.length>0){const m=u.filter(b=>!h.includes(b));v=x(v,["workflows"],m.length===0?void 0:m),p.push(...h.map(b=>`workflows/${String(b.class_name)} → exports`))}c.push(...Ke(n));const g=Qe(v,a,s);return{added:d,text:g.text,updated:[...p,...g.updated],warnings:[...c,...g.warnings]}},on=(e,n,s)=>{const t=ce(e),r=Ee(n);if(!t)return{added:[],changed:!1,exportGaps:r,reason:"wrangler.jsonc not found",updated:[],warnings:D(n,e)};const{parsed:o,text:l}=le(t);if(o===void 0)return{added:[],changed:!1,exportGaps:r,reason:`failed to parse ${t} as JSONC`,updated:[],warnings:D(n,e),wranglerPath:t};const u=D(n,e,o);if(s!==void 0){const i=o.env?.[s]!==void 0;u.push(i?`auto-provisioned bindings are written to the top level of wrangler.jsonc only (queue consumers "env.${s}" already declares are retuned, nothing is added) — "env.${s}" has its own (non-inheritable) bindings and must be reconciled by hand; \`lunora deploy --env ${s}\` now validates them, so a gap here will be reported at deploy time.`:`--env "${s}" was requested but wrangler.jsonc declares no "env.${s}" block — auto-provisioned bindings are written to the top level only and will not apply to that environment.`)}const h=n.containers.filter(i=>i.exported),a=n.agents.filter(i=>i.exported&&i.voice===!0&&i.voiceBindingName!==void 0&&i.voiceClassName!==void 0),d=[...n.durableObjects,...h.map(i=>({binding:i.bindingName,className:i.className})),...a.map(i=>({binding:i.voiceBindingName,className:i.voiceClassName}))],p=n.workflows.filter(i=>i.exported),c=n.agents.filter(i=>i.exported),v=R(e),g=be(v,u),m={},b=z(v);let w;const k=[{enabled:!0,run:i=>je(i,o,d)},{enabled:n.needsD1,run:i=>Ae(i,o)},{enabled:n.usesAi,run:i=>T(i,o,"ai","AI","AI (Workers AI)")},{enabled:n.usesBrowser,run:i=>T(i,o,"browser","BROWSER","BROWSER (Browser Rendering)")},{enabled:n.usesImages,run:i=>T(i,o,"images","IMAGES","IMAGES (Cloudflare Images)")},{enabled:n.usesAnalytics,run:i=>Ce(i,o)},{enabled:n.usesWorkerLoader,run:i=>De(i,o)},{enabled:!0,run:i=>Re(i,o)},{enabled:h.length>0,run:i=>Be(i,o,h)},{enabled:p.length>0||c.length>0,run:i=>Fe(i,o,p,c,Le(e))},{enabled:n.queues.length>0,run:i=>{const y=fe(i,o,n.queues,g.queues??{});return m.queues=y.owned,y}},{enabled:n.services!==void 0&&(n.services.length>0||Object.keys(b).length>0),run:i=>{const y=Z(i,o,n.services??[],b);return w=y.owned,y}},...s===void 0||o.env?.[s]===void 0?[]:[{enabled:n.queues.length>0,run:i=>{const y=`env.${s}.queues`,E=he(i,o,n.queues,s,g[y]??{});return m[y]=E.owned,E}}]];let S=l;const f=[],_=[];for(const i of k){if(!i.enabled)continue;const y=i.run(S);S=y.text,f.push(...y.added),_.push(...y.updated??[]),u.push(...y.warnings??[])}const N=i=>{if(v===void 0)return;const y=w,E=[...Object.keys(m).length>0?[{consequence:"an option removed from defineQueue stays deployed",key:"queueTuning",label:"queue tuning",write:O=>{ve(O,g,m)}}]:[],...y===void 0?[]:[{consequence:"a service removed from lunora.config stays bound",key:"services",label:"service bindings",write:O=>{ne(O,y)}}]];for(const O of E)try{O.write(R(e)??v)}catch(q){u.push(`${i?"wrangler.jsonc was updated, but ":""}recording the ${O.label} reconcile owns in ${v.path} (lunora.${O.key}) failed: ${q instanceof Error?q.message:String(q)}. Until it is recorded, ${O.consequence}.`)}};let $;if(n.services!==void 0){const i=ee(e,n.services,b);u.push(...i.warnings),w={...w,...i.owned},$=i.added.length>0||i.updated.length>0?{added:i.added,path:i.path,updated:i.updated}:void 0}return f.includes("DB (D1)")&&u.push(`wrote a DB binding with a placeholder database_id ("${F}") — run \`wrangler d1 create <name>\` and replace it before deploying.`),S===l?(N(!1),{added:f,changed:!1,devConfig:$,exportGaps:r,reason:"bindings already in sync",updated:_,warnings:u,wranglerPath:t}):(Y(t,S,"utf8"),N(!0),{added:f,changed:!0,devConfig:$,exportGaps:r,updated:_,warnings:u,wranglerPath:t})};export{Ee as collectExportGaps,on as reconcileWranglerBindings};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{writeFileSync as u}from"node:fs";import{modify as y,applyEdits as w}from"jsonc-parser";import{r as m,f as v,a as $}from"./lunora-manifest-
|
|
1
|
+
import{writeFileSync as u}from"node:fs";import{modify as y,applyEdits as w}from"jsonc-parser";import{r as m,f as v,a as $}from"./lunora-manifest-v90ZUbVp.mjs";import{findWranglerFile as x,readWranglerJsonc as C}from"./WRANGLER_FILES-UNW-xY5u.mjs";const b=(r,n)=>r.length===n.length&&r.every((e,t)=>e===n[t]),j=(r,n)=>{if(r?.lunoraIsForeign===!0)return n.push(`${r.path}: \`lunora\` is not an object, so the cron ownership record cannot be read or written — a removed cron will keep firing.`),[];const e=r?.lunora?.crons;if(e===void 0)return[];if(!Array.isArray(e))return n.push(`${r?.path??"package.json"}: \`lunora.crons\` is not an array of cron expressions — the crons it recorded are now treated as hand-written and will not be cleared.`),[];const t=e.filter(o=>typeof o=="string");return t.length!==e.length&&n.push(`${r?.path??"package.json"}: \`lunora.crons\` dropped ${String(e.length-t.length)} non-string entry(s) — anything it recorded there is now treated as hand-written and will not be cleared.`),t},k=(r,n)=>{$(r,"crons",n.length===0?void 0:[...n])},W=(r,n)=>{const e=x(r);if(!e)return{changed:!1,preserved:[],reason:"wrangler.jsonc not found",warnings:[]};const{parsed:t,text:o}=C(e);if(t===void 0)return{changed:!1,preserved:[],reason:`failed to parse ${e} as JSONC`,warnings:[],wranglerPath:e};const g=Array.isArray(t.triggers?.crons)?t.triggers.crons.filter(i=>typeof i=="string"):[],c=[...n],s=[],d=m(r),p=j(d,s),a=g.filter(i=>!c.includes(i)&&!p.includes(i)),l=[...c,...a],f=()=>{d!==void 0&&k(d,c)};if(b(g,l))return f(),{changed:!1,preserved:a,reason:"triggers.crons already in sync",warnings:s,wranglerPath:e};const h=y(o,["triggers","crons"],l,{formattingOptions:v(o)});return h.length===0?{changed:!1,preserved:a,reason:"no structural edit produced",warnings:s,wranglerPath:e}:(u(e,w(o,h),"utf8"),f(),{changed:!0,preserved:a,warnings:s,wranglerPath:e})},J=r=>r.length===0?void 0:`kept ${String(r.length)} hand-written cron trigger(s): ${r.join(", ")}`;export{J as describePreservedCrons,W as reconcileWranglerCrons};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync as _,statSync as O,readFileSync as D,readdirSync as U}from"node:fs";import{discoverFlags as Y,FLAGS_FILENAME as M,discoverQueues as W,QUEUES_FILENAME as G,readServiceBindings as K}from"@lunora/codegen";import{parse as C,init as X}from"es-module-lexer";import{discoverAgentInfo as q}from"./discoverAgentInfo-CTdCSfYM.mjs";import{discoverContainerInfo as H}from"./discoverContainerInfo-EhZtEBQs.mjs";import{d as w}from"./discover-info-Vj9d4qYt.mjs";import{escapeRegExp as Q}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{discoverSchemaInfo as V}from"./discoverSchemaInfo-DJvevsCm.mjs";import{resolveWorkerEntry as J,COMPOSED_ENTRY_DURABLE_OBJECTS as z,GENERATED_MODULE_DURABLE_OBJECTS as Z,GENERATED_DIRECTORY as k,DURABLE_OBJECT_BINDINGS as ee,detectExportedDurableObjects as se,detectClassExports as y}from"./COMPOSED_WORKER_ENTRY-C69wqbSP.mjs";import{discoverWorkflowInfo as re}from"./discoverWorkflowInfo-BsPvlo6O.mjs";import{join as m}from"node:path";const oe=(e,s)=>{const{error:o,value:r}=w(e,s,M,Y);return o===void 0?{flags:r}:{error:o}},L=/^\s*import\s+type\b/,te=new Set(["@lunora/agent","@lunora/agent/sandbox"]),h=["browserTool","jsCodeTool"],v=Object.fromEntries(h.map(e=>{const s=Q(e);return[e,{fallback:new RegExp(String.raw`import\s+\{[^}]*\b${s}\b[^}]*\}\s+from\s+["']@lunora\/agent(?:\/sandbox)?["']`,"u"),name:new RegExp(String.raw`\b${s}\b`,"u"),typeSpecifier:new RegExp(String.raw`\btype\s+${s}\b`,"u")}]})),ne=e=>{const s=e.indexOf("{");if(s===-1)return"";const o=e.indexOf("}",s+1);return o===-1?e.slice(s+1):e.slice(s+1,o)},ae=(e,s)=>{if(L.test(e))return!1;const o=ne(e);return v[s].name.test(o)&&!v[s].typeSpecifier.test(o)},ie=e=>{let s;try{const[o]=C(e);s=o.filter(r=>r.n!==void 0&&te.has(r.n)).map(r=>e.slice(r.ss,r.se))}catch{s=void 0}return Object.fromEntries(h.map(o=>[o,s===void 0?v[o].fallback.test(e):s.some(r=>ae(r,o))]))},ce=(e,s)=>{const{error:o,value:r}=w(e,s,G,W);return o===void 0?{queues:r??[]}:{error:o,queues:[]}},de=new Set([".cjs",".cts",".js",".jsx",".mjs",".mts",".ts",".tsx"]),ue=new Set([".git",".lunora-cache",".wrangler","dist",k,"node_modules"]),le=["lunora","src"],pe=/\benv\s*\.\s*DB\b/,me=/\benv\s*\.\s*AI\b/,P=/\bctx\s*\.\s*pipelines\b/,B=/\bctx\s*\.\s*r2sql\b/,E={usesAi:{pattern:/\bfrom\s+["']@lunora\/ai["']/,source:"@lunora/ai"},usesAnalytics:{pattern:/\bfrom\s+["']@lunora\/bindings\/analytics["']/,source:"@lunora/bindings/analytics"},usesAuth:{pattern:/\bfrom\s+["']@lunora\/auth["']/,source:"@lunora/auth"},usesBrowser:{pattern:/\bfrom\s+["']@lunora\/browser["']/,source:"@lunora/browser"},usesHyperdrive:{pattern:/\bfrom\s+["']@lunora\/hyperdrive["']/,source:"@lunora/hyperdrive"},usesImages:{pattern:/\bfrom\s+["']@lunora\/bindings\/images["']/,source:"@lunora/bindings/images"},usesKv:{pattern:/\bfrom\s+["']@lunora\/bindings\/kv["']/,source:"@lunora/bindings/kv"},usesMail:{pattern:/\bfrom\s+["']@lunora\/mail["']/,source:"@lunora/mail"},usesNotify:{pattern:/\bfrom\s+["']@lunora\/notify["']/,source:"@lunora/notify"},usesPayment:{pattern:/\bfrom\s+["']@lunora\/payment["']/,source:"@lunora/payment"},usesPipelines:{pattern:P,source:"@lunora/bindings/pipelines"},usesR2sql:{pattern:B,source:"@lunora/bindings/r2sql"},usesScheduler:{pattern:/\bfrom\s+["']@lunora\/scheduler["']/,source:"@lunora/scheduler"},usesStorage:{pattern:/\bfrom\s+["']@lunora\/storage["']/,source:"@lunora/storage"},usesX402Charge:{pattern:/\bfrom\s+["']@lunora\/x402\/charge["']/,source:"@lunora/x402/charge"},usesX402Pay:{pattern:/\bfrom\s+["']@lunora\/x402\/pay["']/,source:"@lunora/x402/pay"}},f=Object.keys(E),fe="STRIPE_SECRET_KEY + STRIPE_WEBHOOK_SECRET (Stripe) or POLAR_ACCESS_TOKEN + POLAR_WEBHOOK_SECRET (Polar)",j=[...f,"needsD1","usesWorkerLoader"],be=()=>{const e={};for(const s of j)e[s]=!1;return e},l=Object.freeze(be()),x=(e,s)=>{const o={};for(const r of j)o[r]=e[r]||s[r];return o},ge=e=>{for(const s of f)if(E[s].source===e)return{...l,[s]:!0};return l},he=e=>{const[s]=C(e);let o=l;for(const r of s){const t=r.n;!t||L.test(e.slice(r.ss,r.se))||(o=x(o,ge(t)))}return o},Ee=e=>{const s={...l};for(const o of f)s[o]=E[o].pattern.test(e);return s},Se=e=>{let s;try{s=he(e)}catch{s=Ee(e)}return x(s,{...l,needsD1:pe.test(e),usesAi:me.test(e),usesPipelines:P.test(e),usesR2sql:B.test(e)})},R=(e,s)=>{let o;try{o=U(e,{withFileTypes:!0})}catch{return}for(const r of o){if(r.isDirectory()){ue.has(r.name)||R(m(e,r.name),s);continue}const t=r.name.lastIndexOf(".");t!==-1&&de.has(r.name.slice(t))&&s.push(m(e,r.name))}},ye=(e,s)=>V(e,s).info?.hasD1GlobalTable??!1,ve=(e,s)=>{let o=l;for(const r of s){const t=m(e,r);if(!_(t)||!O(t).isDirectory())continue;const n=[];R(t,n);for(const a of n)o=x(o,Se(D(a,"utf8")))}return o},_e=(e,s)=>{const o=m(e,s),r=Object.fromEntries(h.map(n=>[n,!1]));if(!_(o)||!O(o).isDirectory())return r;const t=[];R(o,t);for(const n of t){const a=ie(D(n,"utf8"));for(const i of h)r[i]||=a[i]}return r},xe=(e,s,o)=>[...e.map(r=>r.exported?`${r.bindingName}/${r.className} (container "${r.exportName}" declared and exported)`:`hint: container "${r.exportName}" is declared but ${r.className} is not exported by the worker entry — add \`export * from "./lunora/_generated/containers"\``),...s.map(r=>r.exported?`exports.${r.className} (workflow "${r.exportName}" declared and exported)`:`hint: workflow "${r.exportName}" is declared but ${r.className} is not exported by the worker entry — add \`export * from "./lunora/_generated/workflows"\``),...o.map(r=>r.exported?`exports.${r.className} (agent "${r.exportName}" declared and exported)`:`hint: agent "${r.exportName}" is declared but ${r.className} is not exported by the worker entry — add \`export * from "./lunora/_generated/agents"\``)],Re=(e,s)=>[[e.usesAi,"AI (@lunora/ai imported or env.AI used)"],[e.usesAuth&&!s.has("SessionDO"),"hint: @lunora/auth is imported; its tables are D1-backed by default. For DO-backed auth (what @better-auth/scim needs), pass `namespace` to .auth() and export the generated auth DO class"],[e.usesScheduler&&!s.has("SchedulerDO"),"hint: @lunora/scheduler is imported but no SchedulerDO is exported by the worker entry"],[e.usesStorage,"hint: @lunora/storage is imported; add an r2_buckets binding (bucket binding names are user-defined)"],[e.usesMail,"hint: @lunora/mail is imported; set RESEND_API_KEY in .dev.vars (obtain at https://resend.com/api-keys)"],[e.usesPayment,`hint: @lunora/payment is imported; set the provider secrets in .dev.vars — ${fe}`],[e.usesBrowser,"browser (@lunora/browser imported) — self-describing { binding: BROWSER }"],[e.usesImages,"images (@lunora/bindings/images imported) — self-describing { binding: IMAGES }"],[e.usesAnalytics,"analytics_engine_datasets (@lunora/bindings/analytics imported) — self-describing { binding: ANALYTICS, dataset }"],[e.usesWorkerLoader,"worker_loaders (jsCodeTool imported in lunora/) — self-describing { binding: LOADER }"],[e.usesKv,"hint: @lunora/bindings/kv is imported; add a kv_namespaces binding ({ binding, id }) and pass env.<BINDING> to createKv() — the namespace id can't be auto-provisioned"],[e.usesHyperdrive,"hint: @lunora/hyperdrive is imported; run 'wrangler hyperdrive create' and add a 'hyperdrive' binding ({ binding, id }) — the id can't be auto-provisioned"],[e.usesPipelines,"hint: ctx.pipelines is used; run 'wrangler pipelines create <name>' and add a 'pipelines' binding ({ binding, stream }) — the pipeline resource can't be auto-provisioned"],[e.usesX402Charge,"hint: @lunora/x402/charge is imported; set the recipient wallet address as a [vars] entry (the var name is yours to choose) and pass it to the charge config — the x402 facilitator settles USDC to that address"],[e.usesX402Pay,"hint: @lunora/x402/pay is imported (ActionCtx-only, spends real funds); add a secrets_store_secrets[] binding for the agent wallet key (name it to match signer.secretName) and pair the pay rail with a spend policy — ctx.secrets reads a Secrets Store binding, not .dev.vars, so the key can't be auto-provisioned"]].filter(([r])=>r).map(([,r])=>r),Ie=(e,s,o,r=[],t=[],n=[])=>{const a=new Set(e.map(c=>c.className)),i=e.map(c=>`${c.binding}/${c.className} (exported by worker entry)`);return s&&i.push("DB (.global() table declared)"),i.push(...xe(r,t,n),...Re(o,a)),i},je=async e=>{await X;const s=e.schemaDir??"lunora",o=e.scanDirs??le,r=ve(e.projectRoot,o),t=_e(e.projectRoot,s),n={...r,usesBrowser:r.usesBrowser||t.browserTool,usesWorkerLoader:t.jsCodeTool},a=J(e.projectRoot);let i;a.composed?i=[...z,...Object.entries(Z).filter(([u])=>_(m(e.projectRoot,s,k,`${u}.ts`))).map(([,u])=>u)].map(u=>({binding:ee[u],className:u})):i=a.path===void 0?[]:se(a.path);const c=n.needsD1||ye(e.projectRoot,s),I=y(a,H(e.projectRoot,s).containers,"containers"),A=y(a,re(e.projectRoot,s).workflows,"workflows"),N=y(a,q(e.projectRoot,s).agents,"agents"),$=[...ce(e.projectRoot,s).queues],{flags:b}=oe(e.projectRoot,s),S=b?.provider==="flagship"&&b.mode==="binding"?b.bindingName:void 0,T={};for(const d of f)T[d]=n[d];const g=Ie(i,c,n,I,A,N);S!==void 0&&g.push(`hint: lunora/flags.ts uses Flagship in binding mode; add a flagship binding ({ binding: "${S}", app_id }) — the app_id can't be auto-provisioned`);const p=K(e.projectRoot),F=p.error===void 0?p.services:void 0;return p.error!==void 0&&g.push(`hint: lunora.config \`services\` not reconciled — ${p.error}`),g.push(...p.services.map(d=>`${d.binding} → ${d.worker} (lunora.config services.${d.name})`)),{agents:N,containers:I,durableObjects:i,flagshipBinding:S,needsD1:c,queues:$,services:F,signals:g,usesFlags:b!==void 0,usesWorkerLoader:n.usesWorkerLoader,workflows:A,...T}},$e=e=>{const s=[];for(const o of f)e[o]&&s.push(E[o].source);return s};export{je as inferLunoraBindings,$e as packageNamesFromBindings};
|
|
@@ -1 +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-
|
|
1
|
+
import{readProjectConfigLiterals as o,readProjectTarget as n}from"@lunora/codegen";import{DEFAULT_DEPLOY_TARGET as c,resolveDeployDriver as a}from"./DEFAULT_DEPLOY_TARGET-CfoV0tDu.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};
|
|
@@ -2,5 +2,5 @@ import{existsSync as O,readFileSync as b,writeFileSync as N}from"node:fs";import
|
|
|
2
2
|
`)?`\r
|
|
3
3
|
`:`
|
|
4
4
|
`,insertSpaces:!o.startsWith(" "),tabSize:o.length}},K=n=>{const o=A(n,"package.json");if(O(o))try{const t=b(o,"utf8"),{lunora:r}=JSON.parse(t),e=typeof r=="object"&&r!==null&&!Array.isArray(r);return{lunora:e?r:void 0,lunoraIsForeign:r!==void 0&&!e,path:o,text:t}}catch{return}},p=n=>JSON.stringify(n,(o,t)=>typeof t=="object"&&t!==null&&!Array.isArray(t)?Object.fromEntries(Object.entries(t).toSorted(([r],[e])=>r.localeCompare(e))):t),j=(n,o,t)=>{const r=J(n),e=r.insertSpaces===!1?" ":" ".repeat(r.tabSize??4),i=r.eol??`
|
|
5
|
-
`,c=e.repeat(o.length),
|
|
6
|
-
`).join(i+c),l=h(n),
|
|
5
|
+
`,c=e.repeat(o.length),f=JSON.stringify(t,void 0,e).split(`
|
|
6
|
+
`).join(i+c),l=h(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 v=`${i}${c}${y}: ${f}${i}${e.repeat(o.length-1)}`;return`${n.slice(0,s.offset+1)}${v}${n.slice(s.offset+s.length-1)}`}const u=d.offset+d.length;return`${n.slice(0,u)},${i}${c}${y}: ${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&&N(n.path,i,"utf8")};export{k as a,p as c,J as f,K as r};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync as C,writeFileSync as k}from"node:fs";import{applyModify as _}from"./applyModify-DKP2l6S9.mjs";import{c as h,a as A}from"./lunora-manifest-v90ZUbVp.mjs";import{readWranglerJsonc as D}from"./WRANGLER_FILES-UNW-xY5u.mjs";import{join as F}from"node:path";const O="services",$="services",S="wrangler.dev.jsonc",f="dev:services",M=(n,t)=>{const s=t===void 0?n.worker:n.envWorkers[t]??`${n.worker}-${t}`;return{binding:n.binding,...n.entrypoint===void 0?{}:{entrypoint:n.entrypoint},service:s}},g=n=>typeof n?.binding=="string"?n.binding:"",b=(n,t,s,d,p,o)=>{const i=t.join("."),r=new Map(d.map(e=>[e.binding,M(e,o)])),a=s.filter(e=>!p.has(g(e))),w=new Set(a.map(e=>g(e))),c=new Map(s.filter(e=>p.has(g(e))).map(e=>[g(e),e])),u=[...r].filter(([e])=>!w.has(e)),v=[...a,...u.map(([,e])=>e)],m=u.filter(([e])=>!c.has(e)).map(([e,l])=>`${i}/${e} → ${l.service??""}`),y=[...u.filter(([e,l])=>c.has(e)&&h(c.get(e))!==h(l)).map(([e])=>`${i}/${e}`),...[...c.keys()].filter(e=>!r.has(e)).map(e=>`${i}/${e} (removed)`)],x=a.filter(e=>r.has(g(e))&&h(e)!==h(r.get(g(e)))).map(e=>`${i}: the hand-written "${g(e)}" entry is left as is — remove it to let lunora.config \`services\` manage that binding.`),E=m.length>0||y.length>0,j=v.length===0?void 0:v;return{added:m,owned:u.map(([e])=>e).toSorted((e,l)=>e.localeCompare(l)),text:E?_(n,t,j):n,updated:y,warnings:x}},V=n=>{const t=n?.lunora?.[O];return typeof t!="object"||t===null||Array.isArray(t)?{}:Object.fromEntries(Object.entries(t).filter(s=>Array.isArray(s[1])&&s[1].every(d=>typeof d=="string")))},G=n=>new Set(V(n)[$]),L=(n,t,s,d)=>{const p=[{current:t.services??[],path:[$]},...Object.entries(t.env??{}).map(([i,r])=>({current:r?.services??[],environment:i,path:["env",i,"services"]}))],o={added:[],owned:{},text:n,updated:[],warnings:[]};for(const{current:i,environment:r,path:a}of p){const w=a.join("."),c=b(o.text,a,i,s,new Set(d[w]),r);o.text=c.text,o.added.push(...c.added),o.updated?.push(...c.updated??[]),o.warnings?.push(...c.warnings??[]),c.owned.length>0&&(o.owned[w]=c.owned)}return o},N=(n,t,s)=>{const d=F(n,S),p={added:[],path:d,updated:[],warnings:[]};if(t.length===0&&s[f]===void 0)return{...p,owned:{}};const{parsed:o,text:i}=C(d)?D(d):{parsed:void 0,text:""};if(o===void 0){const a=s[f];return{...p,owned:a===void 0||a.length===0?{}:{[f]:a}}}const r=b(i,["services"],o.services??[],t,new Set(s[f]),void 0);return r.text!==i&&k(d,r.text,"utf8"),{added:r.added,owned:r.owned.length>0?{[f]:r.owned}:{},path:d,updated:r.updated??[],warnings:(r.warnings??[]).map(a=>`${S} ${a}`)}},J=(n,t)=>{A(n,O,Object.keys(t).length===0?void 0:t)};export{L as a,N as b,J as c,G as o,V as r};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{inferLunoraBindings as p}from"./inferLunoraBindings-DXLEJY9w.mjs";import{LUNORA_TAG as r}from"./LUNORA_TAG-CiQM3BkI.mjs";import{reconcileWranglerBindings as $}from"./collectExportGaps-CIYe_DRY.mjs";import{reconcileWranglerCompatibilityDate as g}from"./reconcileWranglerCompatibilityDate-hocXEuRA.mjs";import{reconcileWranglerCrons as m,describePreservedCrons as w}from"./describePreservedCrons-7gaDLxWx.mjs";const j=async(i,t,o)=>{try{const n=await p({projectRoot:i.projectRoot,schemaDir:i.schemaDir}),e=$(i.projectRoot,n),a=e.wranglerPath??"wrangler.jsonc";if(e.added.length>0&&t.info?.(`${r} inferred bindings → ${e.added.join(", ")} (written to ${a})`),e.updated.length>0&&t.info?.(`${r} updated bindings → ${e.updated.join(", ")} (written to ${a})`),e.devConfig!==void 0){const{added:s,path:d,updated:f}=e.devConfig;t.info?.(`${r} dev sidecar bindings → ${[...s,...f].join(", ")} (written to ${d})`)}for(const s of e.warnings)t.warn(`${r} ${s}`);e.exportGaps.length>0&&o?.(e.exportGaps)}catch(n){const e=n instanceof Error?n.message:String(n);t.warn(`${r} binding inference skipped: ${e}`)}},c=new Map,u=(i,t,o)=>{try{const n=m(i,t);n.changed&&o.info?.(`${r} synced ${t.length.toFixed(0)} cron trigger(s) into ${n.wranglerPath??"wrangler.jsonc"}`);for(const s of n.warnings)o.warn(`${r} ${s}`);const e=n.preserved.join("\0"),a=w(n.preserved);a!==void 0&&(n.changed||c.get(i)!==e)&&o.info?.(`${r} ${a}`),c.set(i,e)}catch(n){const e=n instanceof Error?n.message:String(n);o.warn(`${r} cron trigger sync skipped: ${e}`)}try{const n=g(i);n.changed&&o.info?.(`${r} bumped compatibility_date to ${n.date??"unknown"} (Workers Cache enabled) → ${n.wranglerPath??"wrangler.jsonc"}`)}catch(n){const e=n instanceof Error?n.message:String(n);o.warn(`${r} compatibility date sync skipped: ${e}`)}};export{j as reconcileBindingsSafely,u as reconcileWranglerExtras};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AgentIR, ContainerIR, QueueIR, WorkflowIR } from '@lunora/codegen';
|
|
1
|
+
import { AgentIR, ContainerIR, QueueIR, ServiceBindingIR, WorkflowIR } from '@lunora/codegen';
|
|
2
2
|
/**
|
|
3
3
|
* `DeployDriver` — the provider-neutral seam between a Lunora command and the
|
|
4
4
|
* host CLI that carries it out (plan 114, §5.3).
|
|
@@ -277,6 +277,12 @@ interface InferredBindings {
|
|
|
277
277
|
needsD1: boolean;
|
|
278
278
|
/** Queues declared in `lunora/queues.ts` → reconciled into `queues.producers[]` / `queues.consumers[]`. */
|
|
279
279
|
queues: InferredQueue[];
|
|
280
|
+
/**
|
|
281
|
+
* Sibling Workers declared in `lunora.config` `services` → reconciled into
|
|
282
|
+
* `services[]` (plan 457). `undefined` when the declaration is unreadable, so
|
|
283
|
+
* reconcile leaves every entry alone rather than removing the owned ones.
|
|
284
|
+
*/
|
|
285
|
+
services: ServiceBindingIR[] | undefined;
|
|
280
286
|
/** Human-readable provenance for each inferred binding / hint, for logging. */
|
|
281
287
|
signals: string[];
|
|
282
288
|
/** `@lunora/ai` is imported or `env.AI` is used → needs the `ai` Workers AI binding. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AgentIR, ContainerIR, QueueIR, WorkflowIR } from '@lunora/codegen';
|
|
1
|
+
import { AgentIR, ContainerIR, QueueIR, ServiceBindingIR, WorkflowIR } from '@lunora/codegen';
|
|
2
2
|
/**
|
|
3
3
|
* `DeployDriver` — the provider-neutral seam between a Lunora command and the
|
|
4
4
|
* host CLI that carries it out (plan 114, §5.3).
|
|
@@ -277,6 +277,12 @@ interface InferredBindings {
|
|
|
277
277
|
needsD1: boolean;
|
|
278
278
|
/** Queues declared in `lunora/queues.ts` → reconciled into `queues.producers[]` / `queues.consumers[]`. */
|
|
279
279
|
queues: InferredQueue[];
|
|
280
|
+
/**
|
|
281
|
+
* Sibling Workers declared in `lunora.config` `services` → reconciled into
|
|
282
|
+
* `services[]` (plan 457). `undefined` when the declaration is unreadable, so
|
|
283
|
+
* reconcile leaves every entry alone rather than removing the owned ones.
|
|
284
|
+
*/
|
|
285
|
+
services: ServiceBindingIR[] | undefined;
|
|
280
286
|
/** Human-readable provenance for each inferred binding / hint, for logging. */
|
|
281
287
|
signals: string[];
|
|
282
288
|
/** `@lunora/ai` is imported or `env.AI` is used → needs the `ai` Workers AI binding. */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{watch as A}from"node:fs";import{createServer as _}from"node:net";import{dirname as C}from"node:path";import{readServiceBindings as R}from"@lunora/codegen";import{acceptsConnection as b,startDevProcess as M}from"./acceptsConnection-DHhUYGjT.mjs";import{p as D,a as x}from"./celld-config-D-L6uskI.mjs";const N=6e4,O=200,j=new Set([".celld",".wrangler","node_modules"]),I=/[/\\]/u,B=async()=>new Promise((r,a)=>{const s=_();s.once("error",a),s.listen(0,"127.0.0.1",()=>{const o=s.address();s.close(()=>{r(typeof o=="object"&&o!==null?o.port:0)})})}),F=r=>r?.split(I).some(a=>j.has(a))===!0,G=(r,a,s)=>{let o;const c=A(r,{recursive:!0},(l,w)=>{F(w)||(clearTimeout(o),o=setTimeout(a,O))}),i=()=>{clearTimeout(o),c.close()};return c.once("error",l=>{i(),s(l)}),{close:i}},H=r=>r instanceof Error?r.message:String(r),J=async r=>{const{log:a,port:s,projectRoot:o}=r,c=(t,e="stdout")=>{a(t,{stream:e,tag:"celld"})};if(await b(s))throw new Error(`port ${String(s)} is already in use — stop whatever is serving there (another dev server?), or pick another worker port`);const i=R(o);if(i.error!==void 0)throw new Error(`could not read the lunora.config services: ${i.error}`);const l=D(o,"dev");l.write();const w=C(l.configPath),m=[...new Map(i.services.map(t=>[t.wranglerPath,t])).values()],p=new AbortController,h=()=>p.signal.aborted,v=async(t,e,n)=>M({args:["dev",t,"--port",String(n)],command:"celld",cwd:o,label:"celld dev",notFound:"`celld` was not found on PATH — install it (https://celld.dev) to run the celld target",onLine:T=>{T.trim()!==""&&a(T,{stream:"stdout",tag:e})},port:n,readyTimeoutMs:N,signal:p.signal,spawn:r.spawn}),S=async t=>{const e=x(w,t.wranglerPath);e.write(),c(`registering service ${t.worker} in the local dev state`),await(await v(e.configPath,`celld:${t.worker}`,await B())).stop()};for(const t of m)await S(t);let g=()=>{};const E=new Promise(t=>{g=t}),y=async()=>{const t=await v(l.configPath,"celld",s);return t.crashed.then(g).catch(()=>{}),t};let d=await y();const $=async t=>{await d.stop();let e;try{await S(t)}catch(n){e=n instanceof Error?n:new Error(String(n))}if(!h()){try{d=await y()}catch(n){throw h()||g(1),n}if(e!==void 0)throw e}};let f=Promise.resolve();const k=t=>{c(`service ${t.worker} changed — restarting`),f=f.then(async()=>$(t)).catch(e=>{h()||c(`service ${t.worker} failed to restart: ${H(e)}`,"stderr")})},P=[],u=()=>{for(const t of P)t.close()};try{for(const t of m)P.push(G(C(t.wranglerPath),()=>{k(t)},e=>{c(`stopped watching service ${t.worker}: ${e.message} — restart the dev server to pick up its edits`,"stderr")}))}catch(t){throw u(),await d.stop(),t}return E.then(u).catch(()=>{}),{exited:E,stop:async()=>{p.abort(),u(),await f,await d.stop()}}};export{J as startCelldDevSession};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/config",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.290",
|
|
4
4
|
"description": "Internal shared CLI + Vite config layer for Lunora: wrangler.jsonc validation, binding inference, and .dev.vars scaffolding",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bindings",
|
|
@@ -54,10 +54,10 @@
|
|
|
54
54
|
"access": "public"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@lunora/codegen": "1.0.0-alpha.
|
|
57
|
+
"@lunora/codegen": "1.0.0-alpha.245",
|
|
58
58
|
"@lunora/container": "1.0.0-alpha.64",
|
|
59
59
|
"@lunora/errors": "1.0.0-alpha.48",
|
|
60
|
-
"@lunora/seed": "1.0.0-alpha.
|
|
60
|
+
"@lunora/seed": "1.0.0-alpha.175",
|
|
61
61
|
"@visulima/colorize": "2.1.1",
|
|
62
62
|
"@visulima/find-ai-runner": "1.0.2",
|
|
63
63
|
"@visulima/package": "5.0.20",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const n={devServer:"workerd",prebuildsContainerImages:!0,deploy:o=>{const r=o.preview===!0?["versions","upload"]:["deploy"];return o.entry!==void 0&&r.push(o.entry),o.environment!==void 0&&r.push("--env",o.environment),o.temporary===!0&&r.push("--temporary"),o.dryRun===!0&&r.push("--dry-run"),o.outDir!==void 0&&r.push("--outdir",o.outDir,"--metafile"),{args:r,tool:"wrangler"}},dev:o=>{const r=["dev"];return o.configPath!==void 0&&r.push("--config",o.configPath),o.environment!==void 0&&r.push("--env",o.environment),r.push(...o.extraArgs??[]),{args:r,tool:"wrangler"}},secretList:o=>{const r=["secret","list","--format","json"];return o.environment!==void 0&&r.push("--env",o.environment),o.temporary===!0&&r.push("--temporary"),{args:r,tool:"wrangler"}},secretPut:o=>{const r=["secret","put",o.key??""];return o.environment!==void 0&&r.push("--env",o.environment),o.temporary===!0&&r.push("--temporary"),{args:r,tool:"wrangler"}},tail:o=>{const r=["tail"];return o.worker!==void 0&&r.push(o.worker),o.environment!==void 0&&r.push("--env",o.environment),o.format!==void 0&&r.push("--format",o.format),o.status!==void 0&&r.push("--status",o.status),o.search!==void 0&&r.push("--search",o.search),o.temporary===!0&&r.push("--temporary"),{args:r,tool:"wrangler"}}},i={id:"cloudflare",name:"Cloudflare",toolchain:n};export{i as default};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{writeFileSync as L,rmSync as N,existsSync as v,readFileSync as A}from"node:fs";import{dirname as E,resolve as d,join as y,sep as u,relative as w}from"node:path";import{findWranglerFile as $,readWranglerJsonc as V}from"./WRANGLER_FILES-UNW-xY5u.mjs";import W from"./CLOUDFLARE_DRIVER-DUE6r-Pg.mjs";const Y=".celld.wrangler.json",x=y(".wrangler","deploy","config.json"),F=new Set(["$schema","assets","compatibility_date","compatibility_flags","containers","d1_databases","define","durable_objects","kv_namespaces","main","migrations","name","no_bundle","queues","r2_buckets","rules","services","triggers","vars","worker_loaders","workflows"]),U=new Set(["class_name","image","instance_type","max_instances","name","runtime"]),B=new Set(["CompiledWasm","Data","Text"]),K=/\r?\n/u,G=/[!*?[]/u,J=/[.[]/u,M=["deleted_classes","new_classes","renamed_classes","transferred_classes"],c=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),P=e=>Array.isArray(e)&&e.length===0||c(e)&&Object.values(e).every(r=>P(r)),H=e=>Array.isArray(e)?e.map(r=>{if(!c(r))return r;const t=M.find(n=>r[n]!==void 0);if(t!==void 0)throw new Error(`migration "${String(r.tag)}" uses \`${t}\`, which celld refuses — celld accepts only \`new_sqlite_classes\` migrations`);return{new_sqlite_classes:r.new_sqlite_classes,tag:r.tag}}):e,X=(e,r)=>Array.isArray(e)?e.map((t,n)=>c(t)?Object.fromEntries(Object.entries(t).filter(([s])=>{const o=U.has(s);return o||r.push(`containers[${String(n)}].${s}`),o})):t):e,q=(e,r)=>Array.isArray(e)?e.filter((t,n)=>{const s=c(t)&&typeof t.type=="string"&&B.has(t.type);return s||r.push(`rules[${String(n)}]`),s}):e,z=e=>{const r=[],t={};for(const[n,s]of Object.entries(c(e)?e:{}))c(s)&&s.type==="workflow"?r.push({binding:n,class_name:n,name:s.name}):t[n]=s;return{bindings:r,rest:t}},Q=e=>{const r=[],t={},n=z(e.exports),s={...e,exports:n.rest};for(const[o,i]of Object.entries(s)){if(!F.has(o)){P(i)||r.push(o);continue}switch(o){case"containers":{t[o]=X(i,r);break}case"migrations":{t[o]=H(i);break}case"rules":{t[o]=q(i,r);break}default:t[o]=i}}if(n.bindings.length>0){const o=Array.isArray(t.workflows)?t.workflows:[];t.workflows=[...o,...n.bindings]}return{config:t,dropped:r}},Z=e=>{const[r=[],...t]=e.map(s=>d(s).split(u));let n=0;for(;n<r.length&&t.every(s=>s[n]===r[n]);)n+=1;return r.slice(0,n).join(u)||u},ee=(e,r,t)=>{const n=o=>w(t,d(r,o)).split(u).join("/"),s={...e};return typeof e.main=="string"&&(s.main=n(e.main)),c(e.assets)&&typeof e.assets.directory=="string"&&(s.assets={...e.assets,directory:n(e.assets.directory)}),s},re=e=>{const r=y(e,".assetsignore");if(!v(r))return;const t=A(r,"utf8").split(K).map(n=>n.trim()).filter(n=>n!==""&&!n.startsWith("#")).filter(n=>G.test(n)||v(y(e,n)));if(t.length>0)throw new Error(`${r} hides ${t.join(", ")} from the assets, and celld has no .assetsignore — remove those files from ${e} first`);return r},te=(e,r)=>{const t=y(e,x);if(!v(t))throw new Error(`wrangler \`main\` is the Vite virtual module "${r}", so celld deploys the Vite build output — and there is none yet. Run the project's build (\`vite build\`) first`);const{configPath:n}=JSON.parse(A(t,"utf8"));if(typeof n!="string")throw new TypeError(`${t} names no configPath`);return d(E(t),n)},S=e=>{const{parsed:r}=V(e);if(r===void 0)throw new Error(`${e} is not valid JSONC`);return r},ne=(e,r,t,n)=>{const{d1_databases:s}=e;if(!Array.isArray(s)||n===t)return e;const o=Array.isArray(r.d1_databases)?r.d1_databases.filter(i=>c(i)):[];return{...e,d1_databases:s.map(i=>{if(!c(i))return i;const a=o.find(b=>b.binding===i.binding),l=a?.migrations_dir,p=d(t,typeof l=="string"?l:"migrations"),f=v(p)?{...i,migrations_dir:w(n,p).split(u).join("/")}:i,m=a?.migrations_pattern;return typeof m=="string"?{...f,migrations_pattern:w(n,d(t,m)).split(u).join("/")}:f})}},se=(e,r,t,n)=>{const{main:s}=t;if(typeof s!="string"||!s.startsWith("virtual:"))return{fromBuild:!1,source:t,sourcePath:r};if(n==="dev")throw new Error(`wrangler \`main\` is the Vite virtual module "${s}", which only a Vite build can resolve — \`celld dev\` rebuilds from a source file. Use \`vite dev\` for the dev loop and \`lunora deploy\` to ship the build to celld, or point \`main\` at a worker file`);const o=te(e,s);return{fromBuild:!0,source:S(o),sourcePath:o}},oe=(e,r,t,n,s)=>{const o=r.filter(l=>Object.hasOwn(t,l.split(J)[0]??l));let i=e;e.no_bundle!==void 0&&(i=Object.fromEntries(Object.entries(e).filter(([l])=>l!=="no_bundle")),o.push("no_bundle (celld re-bundles the build output)"));const a=n===void 0?void 0:re(n);return a!==void 0&&o.push(`${w(s,a)} (matched no files)`),{assetsIgnore:a,projected:i,reported:o}},ie=e=>{const r=c(e.vars)?e.vars:{};return{...e,vars:{WORKER_ENV:"development",...r}}},ae=(e,r)=>{const t=$(e);if(t===void 0)throw new Error(`no wrangler.jsonc or wrangler.json in ${e} — celld deploys from the project's Wrangler config`);const n=S(t),{fromBuild:s,source:o,sourcePath:i}=se(e,t,n,r),a=E(i),{config:l,dropped:p}=Q(o),{assets:f}=o,m=c(f)&&typeof f.directory=="string"?d(a,f.directory):void 0,b=typeof o.main=="string"?E(d(a,o.main)):void 0,h=Z([a,b,m].filter(k=>k!==void 0));if(!s&&h!==a)throw new Error(`wrangler \`main\` and \`assets.directory\` must sit inside ${a} — celld resolves everything against the config's directory`);const j=ne(ee(l,a,h),n,e,h),g=s?oe(j,p,n,m,h):{assetsIgnore:void 0,projected:j,reported:p},R=r==="dev"?ie(g.projected):g.projected,O=y(h,Y),T=`${JSON.stringify(R,void 0,4)}
|
|
2
|
-
`;return{configPath:O,dropped:g.reported,write:()=>{L(O,T),g.assetsIgnore!==void 0&&N(g.assetsIgnore)}}},ce=[["entry","`celld deploy` deploys the config's `main`; a composed framework entry has no celld equivalent yet"],["environment","celld has no Wrangler environments — deploy a separate config per environment"],["outDir","`celld deploy` does not write its bundle to disk"],["preview","celld has no preview versions — a deploy replaces the fleet's current deployment"],["temporary","celld has no short-lived accounts — it deploys to the fleet bucket in CELLD_BUCKET"]],D=e=>{if(e===void 0)throw new Error("the celld driver runs the projected wrangler config — pass `configPath` from `projectConfig`");return e},le={deploy:e=>{const r=ce.find(([t])=>e[t]!==void 0&&e[t]!==!1);if(r!==void 0)throw new Error(r[1]);return{args:["deploy",D(e.configPath),...e.dryRun===!0?["--dry-run"]:[]],onPath:!0,tool:"celld"}},devServer:"own",prebuildsContainerImages:!1,dev:e=>{if(e.environment!==void 0)throw new Error("celld has no Wrangler environments — `celld dev` runs the top-level config");return{args:["dev",D(e.configPath),...e.extraArgs??[]],onPath:!0,tool:"celld"}}},de={id:"celld",name:"celld",projectConfig:ae,toolchain:le},fe={id:"node",name:"Node"},ue="cloudflare",_={celld:de,cloudflare:W,node:fe},C=()=>Object.keys(_).toSorted((e,r)=>e.localeCompare(r)),I=(e=ue)=>{const r=_[e];if(r===void 0)throw new Error(`unknown deploy target "${e}" — available targets: ${C().join(", ")}`);return r},pe=e=>Object.hasOwn(_,e)&&I(e).toolchain!==void 0,ve=()=>C().filter(e=>pe(e)),we=e=>I(e).toolchain?.devServer==="own",be=(e,r,t,n)=>{const s=e.projectConfig?.(r,t);return{command:n(s?.configPath),commit:()=>s?.write(),projection:s===void 0?void 0:{configPath:s.configPath,dropped:s.dropped}}};export{ue as DEFAULT_DEPLOY_TARGET,C as deployTargetIds,pe as isRunnableTarget,be as planToolchainInvocation,I as resolveDeployDriver,ve as runnableTargetIds,we as targetRunsOwnDevServer};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{writeFileSync as d,rmSync as f}from"node:fs";import{applyModify as g}from"./applyModify-DKP2l6S9.mjs";import{findWranglerFile as m,readWranglerJsonc as b}from"./WRANGLER_FILES-UNW-xY5u.mjs";import{join as y}from"node:path";const u={ai:{label:"AI",shape:"object"},d1_databases:{label:"D1",shape:"array"},kv_namespaces:{label:"KV",shape:"array"},queues:{label:"Queue",shape:"producers"},r2_buckets:{label:"R2",shape:"array"},services:{label:"Service",shape:"array"},vectorize:{label:"Vectorize",shape:"array"}},h=Object.keys(u),p=(e,r)=>typeof e.binding=="string"?e.binding:r,l=(e,r,n,a)=>{const t=[];for(const[o,s]of r.entries())s!=null&&t.push({binding:p(s,`#${String(o)}`),kind:n,path:[...a,o],section:e});return t},E=(e,r)=>{const{label:n,shape:a}=u[e];if(a==="array"){const o=r[e]??[];return l(e,o,n,[])}if(a==="producers")return l(e,r.queues?.producers??[],n,["producers"]);const t=r.ai;return t==null?[]:[{binding:p(t,e),kind:n,path:[],section:e}]},v=e=>h.flatMap(r=>E(r,e)),R=(e,r)=>{let n=e;for(const a of r)n=g(n,[a.section,...a.path,"remote"],!0);return n},i=()=>{},S=e=>{let r=!1;return()=>{if(!r){r=!0;try{f(e,{force:!0,recursive:!0})}catch{}}}};let c=0;const B=()=>(c+=1,`.wrangler.lunora-remote.${String(process.pid)}.${String(c)}.jsonc`),w=e=>{if(!e.enabled)return{cleanup:i,enabled:!1,remoteBindings:[]};const r=m(e.projectRoot);if(!r)return{cleanup:i,enabled:!0,reason:"wrangler.jsonc not found",remoteBindings:[]};const{parsed:n,text:a}=b(r);if(n===void 0)return{cleanup:i,enabled:!0,reason:`failed to parse ${r} as JSONC`,remoteBindings:[]};const t=v(n);if(t.length===0)return{cleanup:i,enabled:!0,reason:"no remote-eligible bindings to proxy",remoteBindings:[]};const o=y(e.projectRoot,B());return d(o,R(a,t),"utf8"),{cleanup:S(o),configPath:o,enabled:!0,remoteBindings:t}},j=e=>{if(e===void 0)return!1;const r=e.trim().toLowerCase();return r==="1"||r==="true"},x=e=>e.flag===!0||j(e.envValue)?!0:e.configPreference??!1;export{u as REMOTE_ELIGIBLE_KEYS,R as injectRemoteFlags,j as isRemoteEnvEnabled,w as materializeRemoteWranglerConfig,v as planRemoteBindings,x as resolveRemoteEnabled};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{readFileSync as C,writeFileSync as M}from"node:fs";import{createRequire as L}from"node:module";import{join as T}from"node:path";import{containerBuildTag as K}from"@lunora/container";import{applyModify as y}from"./applyModify-DKP2l6S9.mjs";import{a as Q,r as F}from"./lunora-manifest-V77OcyFC.mjs";import{parseTree as U,findNodeAtLocation as Y}from"jsonc-parser";import{DEV_VARS_FILE as G,parseDevVariableEntries as H}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{packageNamesFromBindings as J}from"./inferLunoraBindings-hCgGQAGN.mjs";import{requiredSecrets as V}from"./buildPackageSecretsBlock-yv9mjKEW.mjs";import{w as X,m as z,s as I,o as q,n as S,p as Z}from"./validate-bindings-Dnf1t0SY.mjs";import{findWranglerFile as ee,readWranglerJsonc as ne}from"./WRANGLER_FILES-UNW-xY5u.mjs";const se=[["maxBatchSize","max_batch_size"],["maxBatchTimeout","max_batch_timeout"],["maxRetries","max_retries"],["deadLetterQueue","dead_letter_queue"],["retryDelay","retry_delay"]],j=e=>Object.fromEntries(se.filter(([n])=>e.tuning[n]!==void 0).map(([n,s])=>[s,e.tuning[n]])),A="queueTuning",te=/^[\t ]*(?:,[\t ]*)?(?:\/\/[^\n\r]*)?\r?\n/u,oe=/^[\t ]*,/u,re=(e,n)=>{const s=U(e),t=s===void 0?void 0:Y(s,[...n])?.parent;if(t?.type==="property"){const r=t.offset+t.length,o=e.lastIndexOf(`
|
|
2
|
-
`,t.offset-1)+1,l=te.exec(e.slice(r));if(l!==null&&e.slice(o,t.offset).trim()===""){const u=t.parent?.children??[],f=u.indexOf(t),i=f===u.length-1&&f>0?u[f-1]:void 0,d=i===void 0?void 0:oe.exec(e.slice(i.offset+i.length))??void 0;return(d===void 0||i===void 0?e.slice(0,o):e.slice(0,i.offset+i.length)+e.slice(i.offset+i.length+d[0].length,o))+e.slice(r+l[0].length)}}return y(e,n,void 0)},P=(e,n,s,t,r,o=new Set)=>{const l=s.join("."),u={},f=[],i=[];let d=e;return{entries:n.map((c,w)=>{const g=t(c);if(g===void 0||c.queue===void 0)return c;const m=Object.fromEntries(Object.entries(j(g)).filter(([h])=>!o.has(h))),b=Object.entries(r[c.queue]??{}).filter(([h])=>!Object.hasOwn(m,h)),v=Object.entries(m).filter(([h,a])=>c[h]!==a),x=b.filter(([h,a])=>c[h]===a).map(([h])=>h),k=Object.fromEntries(Object.entries({...c,...m}).filter(([h])=>!x.includes(h)));for(const[h,a]of v)d=y(d,[...s,w,h],a);for(const h of x)d=re(d,[...s,w,h]);for(const[h,a]of b){const _=c[h];_!==void 0&&_!==a&&i.push(`${l}/${c.queue}: ${h} is no longer declared by defineQueue, but it was changed by hand to ${JSON.stringify(_)} from the declared ${JSON.stringify(a)}, so it was kept. Delete it from wrangler.jsonc if it should go.`)}return(v.length>0||x.length>0)&&f.push(`${l}/${c.queue} (${[...v.map(([h])=>h),...x.map(h=>`removed ${h}`)].join(", ")})`),Object.keys(m).length>0&&(u[c.queue]=m),k}),owned:u,text:d,updated:f,warnings:i}},ae=(e,n,s,t)=>{const r=n.queues??{},o=r.producers??[],l=r.consumers??[],u=new Set(o.map(g=>g.binding)),f=new Set(l.map(g=>g.queue)),i=s.filter(g=>!u.has(g.bindingName)),d=s.filter(g=>!f.has(g.name)),p=P(e,l,["queues","consumers"],g=>s.find(m=>m.name===g.queue),t);let c=p.text;const w={...p.owned};if(i.length>0||d.length>0){const g=[...o,...i.map(b=>({binding:b.bindingName,queue:b.name}))],m=[...p.entries,...d.map(b=>({queue:b.name,...b.mode==="pull"?{type:"http_pull"}:{},...j(b)}))];for(const b of d){const v=j(b);Object.keys(v).length>0&&(w[b.name]=v)}c=y(c,["queues"],{consumers:m,producers:g})}return{added:[...i.map(g=>`queues.producers/${g.bindingName}`),...d.map(g=>`queues.consumers/${g.name}`)],owned:w,text:c,updated:p.updated,warnings:p.warnings}},ie=(e,n,s,t,r)=>{const o=n.env?.[t],l=o?.queues?.consumers??[],u=o?.queues?.producers??[],f=c=>{const w=u.find(g=>g.queue===c.queue)?.binding;return w!==void 0?s.find(g=>g.bindingName===w):s.find(g=>g.name===c.queue&&!u.some(m=>m.binding===g.bindingName))},i=P(e,l,["env",t,"queues","consumers"],f,r,new Set(["dead_letter_queue"])),d=l.filter(c=>c.queue!==void 0&&f(c)===void 0).map(c=>`env.${t}.queues.consumers/${String(c.queue)}: no defineQueue export matches it — this block declares no producer mapping one of their bindings to "${String(c.queue)}", and no export is named that — so it was not retuned. A consumer for a queue another worker produces is skipped the same way.`),p=l.flatMap(c=>{const w=f(c)?.tuning.deadLetterQueue;return w===void 0||c.dead_letter_queue!==void 0?[]:[`env.${t}.queues.consumers/${String(c.queue)}: defineQueue declares deadLetterQueue "${w}", but this consumer has no dead_letter_queue, so its exhausted messages are dropped. Queue names differ per environment, so reconcile does not write it here; add it by hand.`]});return{added:[],owned:i.owned,text:i.text,updated:i.updated,warnings:[...i.warnings,...p,...d]}},de=(e,n)=>{if(e?.lunoraIsForeign===!0)return n.push(`${e.path}: \`lunora\` is not an object, so the queue tuning ownership record cannot be read or written — an option removed from defineQueue stays deployed.`),{};const s=e?.lunora?.[A],t=r=>typeof r=="object"&&r!==null&&!Array.isArray(r);return s===void 0?{}:!t(s)||!Object.values(s).every(r=>t(r)&&Object.values(r).every(o=>t(o)))?(n.push(`${e?.path??"package.json"}: \`lunora.${A}\` is not a map of scope → queue → fields, so it is ignored — an option removed from defineQueue stays deployed until the next pass records it again.`),{}):s},ce=(e,n,s)=>{const t=Object.fromEntries(Object.entries({...n,...s}).filter(([,r])=>Object.keys(r).length>0));Q(e,A,Object.keys(t).length===0?void 0:t)},O="PIPELINES",le=(e,n)=>{const s=e.flagshipBinding!==void 0&&!(n?.flagship??[]).some(o=>o.binding===e.flagshipBinding),t=e.usesPipelines&&!(n?.pipelines??[]).some(o=>o.binding===O);return[[e.usesKv&&(n?.kv_namespaces?.length??0)===0,"@lunora/bindings/kv is used but no kv_namespaces binding exists; add a kv_namespaces entry ({ binding, id }) and pass env.<BINDING> to createKv() — the namespace id can't be auto-provisioned."],[e.usesHyperdrive&&(n?.hyperdrive?.length??0)===0,"@lunora/hyperdrive is used but no hyperdrive binding exists; run 'wrangler hyperdrive create' and add a 'hyperdrive' binding ({ binding, id }) — the id can't be auto-provisioned."],[t,`ctx.pipelines is used but no "${O}" pipelines binding exists; run 'wrangler pipelines create <name>' and add a 'pipelines' binding ({ binding: "${O}", stream }) — codegen resolves this one name, and the pipeline resource can't be auto-provisioned.`],[s,`lunora/flags.ts uses Flagship in binding mode but no flagship binding "${e.flagshipBinding??""}" exists; add a flagship entry ({ binding: "${e.flagshipBinding??""}", app_id }) — the app_id can't be auto-provisioned.`]].filter(([o])=>o).map(([,o])=>o)},ue=e=>[[e.usesX402Charge,"@lunora/x402/charge is used; set the recipient wallet address as a [vars] entry (the var name is your choice) and pass it to the charge config — the x402 facilitator settles USDC to that address."],[e.usesX402Pay,"@lunora/x402/pay is used (ActionCtx-only, spends real funds); add a secrets_store_secrets[] binding holding the agent wallet key (binding name == signer.secretName) and pair the pay rail with a spend policy — ctx.secrets reads a Secrets Store binding, not .dev.vars."]].filter(([s])=>s).map(([,s])=>s),N=(e,n,s)=>s.filter(t=>!t.exported).map(t=>`${e} "${t.exportName}" is declared but ${t.className} is not exported by the worker entry; add \`export * from "./lunora/_generated/${n}"\` so its binding can be provisioned.`),ge=(e,n)=>{const s=new Set([...e.workflows,...e.agents].map(o=>o.className));if(s.size===0)return[];const t=Object.entries(n.exports??{}).flatMap(([o,l])=>l?.type==="workflow"?[o]:[]),r=(n.workflows??[]).flatMap(o=>o.class_name===void 0||o.script_name!==void 0?[]:[o.class_name]);return[...new Set([...t,...r])].filter(o=>!s.has(o)).map(o=>`wrangler.jsonc declares workflow "${o}" but no defineWorkflow/defineAgent export generates that class — a leftover from a rename will fail the deploy (wrangler rejects a class the worker does not export). Remove it if it is not hand-wired.`)},pe=(e,n)=>{if(e.queues.length===0)return[];const s=new Set(e.queues.map(r=>r.name)),t=new Set(e.queues.map(r=>r.bindingName));return[...(n.queues?.consumers??[]).flatMap(r=>{const{queue:o}=r;return o===void 0||s.has(o)?[]:[`wrangler.jsonc subscribes queues.consumers[] to "${o}" but no defineQueue export declares that queue — a leftover from a rename keeps delivering batches this worker has no handler for (they retry to exhaustion, then drop or dead-letter). Remove it if it is not hand-wired.`]}),...(n.queues?.producers??[]).flatMap(r=>{const{binding:o}=r;return o===void 0||t.has(o)?[]:[`wrangler.jsonc declares queues.producers[] binding "${o}" but no defineQueue export declares it — a leftover from a rename. Remove it if it is not hand-wired.`]})]},me=(e,n)=>[...ge(e,n),...pe(e,n)],R=[{keys:["STRIPE_SECRET_KEY","STRIPE_WEBHOOK_SECRET"],label:"Stripe"},{keys:["POLAR_ACCESS_TOKEN","POLAR_WEBHOOK_SECRET"],label:"Polar"},{keys:["CREEM_API_KEY","CREEM_WEBHOOK_SECRET"],label:"Creem"},{keys:["AUTUMN_SECRET_KEY","AUTUMN_WEBHOOK_SECRET"],label:"Autumn"},{keys:["DODO_PAYMENTS_API_KEY","DODO_PAYMENTS_WEBHOOK_KEY"],label:"Dodo Payments"}],fe=()=>R.map(({keys:e,label:n})=>`${e[0]} + ${e[1]} (${n})`).join(" or "),he=e=>{let n;try{n=C(T(e,G),"utf8")}catch{return!1}const s=new Map(H(n).map(t=>[t.key,t.value]));return R.some(({keys:t})=>t.every(r=>(s.get(r)??"")!==""))},be=(e,n)=>{const s=n?.secrets?.required;if(!Array.isArray(s))return[];const t=new Set(s),r=V(J(e)).map(o=>o.key).filter(o=>!t.has(o));return r.length===0?[]:[`wrangler.jsonc declares secrets.required without ${r.join(", ")}, which this app needs — wrangler dev loads only the listed keys from .dev.vars, so add ${r.length===1?"it":"them"} to secrets.required.`]},E=(e,n,s)=>{const t=new Set(e.durableObjects.map(u=>u.className)),r=[],o=(s?.r2_buckets?.length??0)>0,l=(s?.d1_databases?.some(u=>u.binding==="DB")??!1)||e.needsD1;return e.usesStorage&&!o&&r.push("@lunora/storage is used but R2 bucket bindings have user-defined names; add an r2_buckets entry and pass env.<BINDING> to createStorage()."),e.usesAuth&&!t.has("SessionDO")&&!l&&r.push("@lunora/auth is used but the worker entry exports no SessionDO; sessions are D1-backed, or export SessionDO to enable DO-backed sessions."),e.usesScheduler&&!t.has("SchedulerDO")&&r.push("@lunora/scheduler is used but the worker entry exports no SchedulerDO; export it so the SCHEDULER binding can be provisioned."),r.push(...N("container","containers",e.containers),...N("workflow","workflows",e.workflows),...N("agent","agents",e.agents)),e.containers.length>0&&s?.observability?.enabled===!1&&r.push("containers are declared but observability is explicitly disabled in wrangler.jsonc — container logs will not be captured."),e.usesPayment&&!he(n)&&r.push(`@lunora/payment is used; set one provider's secret pair in .dev.vars — ${fe()}.`),r.push(...ue(e),...le(e,s),...be(e,s)),s!==void 0&&r.push(...me(e,s)),r},B="<replace-with-d1-create-id>",we=e=>[["container","containers",e.containers],["workflow","workflows",e.workflows],["agent","agents",e.agents]].flatMap(([s,t,r])=>r.filter(o=>!o.exported).map(({className:o,exportName:l})=>({className:o,exportName:l,kind:s,module:t}))),ve=e=>{const n=new Set(q(e).map(t=>t.tag));let s=1;for(;n.has(`v${String(s)}`);)s+=1;return`v${String(s)}`},_e=e=>{const n=new Set;for(const s of q(e)){for(const t of S(s.deleted_classes))n.delete(t);for(const{from:t,to:r}of q(s.renamed_classes))t!==void 0&&n.delete(t),r!==void 0&&n.add(r);for(const t of[...S(s.new_classes),...S(s.new_sqlite_classes)])n.add(t)}return n},ye=(e,n,s)=>{const t=n.durable_objects?.bindings??[],r=new Set(t.map(d=>d.name)),o=s.filter(d=>!r.has(d.binding));let l=e;const u=[];if(o.length>0){const d=[...t,...o.map(p=>({class_name:p.className,name:p.binding}))];l=y(l,["durable_objects","bindings"],d),u.push(...o.map(p=>`${p.binding}/${p.className}`))}const f=n.migrations??[],i=s.map(d=>d.className).filter(d=>!_e(f).has(d));if(i.length>0){const d=[...f,{new_sqlite_classes:i,tag:ve(f)}];l=y(l,["migrations"],d)}return{added:u,text:l}},xe=(e,n)=>{const s=n.d1_databases??[];if(s.some(o=>o.binding==="DB"))return{added:[],text:e};const t=typeof n.name=="string"&&n.name.length>0?n.name:"lunora",r=[...s,{binding:"DB",database_id:B,database_name:t}];return{added:["DB (D1)"],text:y(e,["d1_databases"],r)}},$=(e,n,s,t,r)=>{const o=n[s]?.binding;return typeof o=="string"&&o.length>0?{added:[],text:e}:{added:[r],text:y(e,[s],{binding:t})}},ke=(e,n)=>(n.analytics_engine_datasets?.length??0)>0?{added:[],text:e}:{added:["ANALYTICS (Analytics Engine)"],text:y(e,["analytics_engine_datasets"],[{binding:"ANALYTICS",dataset:"ANALYTICS"}])},Se=(e,n)=>{const s=n.worker_loaders??[];return s.some(t=>t.binding==="LOADER")?{added:[],text:e}:{added:["LOADER (Worker Loader)"],text:y(e,["worker_loaders"],[...s,{binding:"LOADER"}])}},Oe=e=>{if(typeof e=="string")return e;const n={};return e.diskMb!==void 0&&(n.disk_mb=e.diskMb),e.memoryMib!==void 0&&(n.memory_mib=e.memoryMib),e.vcpu!==void 0&&(n.vcpu=e.vcpu),n},Ne=e=>{const{image:n}=e;return n.kind==="dockerfile"?n.dockerfilePath:n.kind==="registry"?n.reference:K(e.exportName)},W=e=>{const n={};for(const[s,t]of Object.entries(e.images??{}))n[s]=t.kind==="registry"?{image:t.reference}:{build_context:t.buildContext,dockerfile:t.dockerfilePath,...e.buildArgs===void 0?{}:{build_vars:e.buildArgs}};return{class_name:e.className,scheduling_policy:"durable_object",...Object.keys(n).length>0?{images:n}:{},...e.name===void 0?{}:{name:e.name}}},Ee=e=>{if(e.schedulingPolicy==="durable_object")return W(e);const{image:n}=e,s={class_name:e.className,image:Ne(e)};return n.kind==="dockerfile"&&(s.image_build_context=n.buildContext),e.buildArgs!==void 0&&n.kind!=="registry"&&(s.image_vars=e.buildArgs),e.instanceType!==void 0&&(s.instance_type=Oe(e.instanceType)),e.maxInstances!==void 0&&(s.max_instances=e.maxInstances),e.name!==void 0&&(s.name=e.name),e.rollout?.stepPercentage!==void 0&&(s.rollout_step_percentage=e.rollout.stepPercentage),e.rollout?.gracePeriodSeconds!==void 0&&(s.rollout_active_grace_period=e.rollout.gracePeriodSeconds),s},$e=(e,n,s)=>{const t=n.containers??[],r=new Set(t.map(i=>i.class_name)),o=s.filter(i=>!r.has(i.className));let l=o.length===0?e:y(e,["containers"],[...t,...o.map(i=>Ee(i))]);const u=[],f=[];for(const[i,d]of t.entries()){const p=s.find(g=>g.className===d.class_name);if(p===void 0)continue;const c=p.schedulingPolicy??"default";if((d.scheduling_policy??"default")!==c){f.push(`containers/${p.className} has scheduling_policy "${d.scheduling_policy??"default"}" in wrangler.jsonc but defineContainer "${p.exportName}" declares "${c}" — the policy is immutable, so replace the entry (and its container application) by hand.`);continue}const w=p.schedulingPolicy==="durable_object"?W(p).images:void 0;w!==void 0&&JSON.stringify(d.images)!==JSON.stringify(w)&&(l=y(l,["containers",i,"images"],w),u.push(`containers/${p.className}.images`))}return{added:o.map(i=>`containers/${i.className}`),text:l,updated:u,warnings:f}},qe=(e,n)=>{if(n.observability!==void 0)return{added:[],text:e};const s=y(e,["observability"],{enabled:!0,head_sampling_rate:1});return{added:["observability"],text:s}},je=[{minimum:[4,142],name:"wrangler"},{minimum:[1,61],name:"@cloudflare/vite-plugin"}],Ae=(e,n)=>{try{const s=L(T(e,"package.json")).resolve(`${n}/package.json`),[t=0,r=0]=String(JSON.parse(C(s,"utf8")).version).split(".").map(Number);return[t,r]}catch{return}},De=e=>{const n=je.flatMap(({minimum:s,name:t})=>{const r=Ae(e,t);return r!==void 0&&(r[0]<s[0]||r[0]===s[0]&&r[1]<s[1])?[`${t} ${r.join(".")} (needs >= ${s.join(".")})`]:[]});return n.length===0?void 0:`workflows are declared in wrangler \`exports\`, which ${n.join(" and ")} cannot run — reconcile left workflows[] untouched. Upgrade (\`pnpm add -D wrangler@^4.143.1 @cloudflare/vite-plugin@^1.62.1\`) and re-run.`},Ce=e=>Object.entries(e.env??{}).flatMap(([n,s])=>Array.isArray(s?.workflows)?[`env.${n}.workflows declares workflow bindings, but Lunora now declares workflows in \`exports\` and resolves them on ctx.exports — move them to that environment's own \`exports\` by hand.`]:[]),Te=(e,n,s)=>{let t=e;const r=[],o=[];for(const l of s){const u=n[l.className];if(u?.type==="workflow")for(const{of:f,path:i}of Z){const d=f(l),p=I(u,i),c=`exports/${l.className}.${i.join(".")}`;if(d===void 0){p!==void 0&&o.push(`${c} is set in wrangler.jsonc but defineWorkflow "${l.exportName}" does not declare it — reconcile leaves it in place. Remove it by hand if it was dropped from the definition.`);continue}JSON.stringify(p)!==JSON.stringify(d)&&(t=y(t,["exports",l.className,...i],d),r.push(c))}}return{text:t,updated:r,warnings:o}},Ie=(e,n,s,t,r)=>{if(r!==void 0)return{added:[],text:e,warnings:[r]};const o=[...s.map(m=>({settings:X(m),workflow:m})),...t.map(m=>({settings:{},workflow:m}))],l=new Set(o.map(({workflow:m})=>m.className)),u=n.workflows??[],f=u.filter(m=>m.script_name===void 0&&m.class_name!==void 0&&l.has(m.class_name)),i=n.exports??{},d=[],p=[],c=[];let w=e;for(const{settings:m,workflow:b}of o){if(i[b.className]!==void 0&&i[b.className]!==null)continue;const v=f.find(h=>h.class_name===b.className),x=Object.fromEntries(z.flatMap(h=>{const a=I(v,[h]);return a===void 0?[]:[[h,a]]})),k=v?.name??b.name;v?.name!==void 0&&v.name!==b.name&&c.push(`workflows/${b.className} is deployed as "${v.name}" but declared as "${b.name}" — its export keeps "${v.name}" so running instances survive. Change the declaration to match, or rename deliberately (it starts a new, empty workflow).`),w=y(w,["exports",b.className],{type:"workflow",...x,...m,name:k}),(v===void 0?d:p).push(`exports/${b.className}`)}if(f.length>0){const m=u.filter(b=>!f.includes(b));w=y(w,["workflows"],m.length===0?void 0:m),p.push(...f.map(b=>`workflows/${String(b.class_name)} → exports`))}c.push(...Ce(n));const g=Te(w,i,s);return{added:d,text:g.text,updated:[...p,...g.updated],warnings:[...c,...g.warnings]}},He=(e,n,s)=>{const t=ee(e),r=we(n);if(!t)return{added:[],changed:!1,exportGaps:r,reason:"wrangler.jsonc not found",updated:[],warnings:E(n,e)};const{parsed:o,text:l}=ne(t);if(o===void 0)return{added:[],changed:!1,exportGaps:r,reason:`failed to parse ${t} as JSONC`,updated:[],warnings:E(n,e),wranglerPath:t};const u=E(n,e,o);if(s!==void 0){const a=o.env?.[s]!==void 0;u.push(a?`auto-provisioned bindings are written to the top level of wrangler.jsonc only (queue consumers "env.${s}" already declares are retuned, nothing is added) — "env.${s}" has its own (non-inheritable) bindings and must be reconciled by hand; \`lunora deploy --env ${s}\` now validates them, so a gap here will be reported at deploy time.`:`--env "${s}" was requested but wrangler.jsonc declares no "env.${s}" block — auto-provisioned bindings are written to the top level only and will not apply to that environment.`)}const f=n.containers.filter(a=>a.exported),i=n.agents.filter(a=>a.exported&&a.voice===!0&&a.voiceBindingName!==void 0&&a.voiceClassName!==void 0),d=[...n.durableObjects,...f.map(a=>({binding:a.bindingName,className:a.className})),...i.map(a=>({binding:a.voiceBindingName,className:a.voiceClassName}))],p=n.workflows.filter(a=>a.exported),c=n.agents.filter(a=>a.exported),w=F(e),g=de(w,u),m={},b=[{enabled:!0,run:a=>ye(a,o,d)},{enabled:n.needsD1,run:a=>xe(a,o)},{enabled:n.usesAi,run:a=>$(a,o,"ai","AI","AI (Workers AI)")},{enabled:n.usesBrowser,run:a=>$(a,o,"browser","BROWSER","BROWSER (Browser Rendering)")},{enabled:n.usesImages,run:a=>$(a,o,"images","IMAGES","IMAGES (Cloudflare Images)")},{enabled:n.usesAnalytics,run:a=>ke(a,o)},{enabled:n.usesWorkerLoader,run:a=>Se(a,o)},{enabled:!0,run:a=>qe(a,o)},{enabled:f.length>0,run:a=>$e(a,o,f)},{enabled:p.length>0||c.length>0,run:a=>Ie(a,o,p,c,De(e))},{enabled:n.queues.length>0,run:a=>{const _=ae(a,o,n.queues,g.queues??{});return m.queues=_.owned,_}},...s===void 0||o.env?.[s]===void 0?[]:[{enabled:n.queues.length>0,run:a=>{const _=`env.${s}.queues`,D=ie(a,o,n.queues,s,g[_]??{});return m[_]=D.owned,D}}]];let v=l;const x=[],k=[];for(const a of b){if(!a.enabled)continue;const _=a.run(v);v=_.text,x.push(..._.added),k.push(..._.updated??[]),u.push(..._.warnings??[])}const h=a=>{if(!(w===void 0||Object.keys(m).length===0))try{ce(w,g,m)}catch(_){u.push(`${a?"wrangler.jsonc was updated, but ":""}recording the queue tuning reconcile owns in ${w.path} (lunora.queueTuning) failed: ${_ instanceof Error?_.message:String(_)}. Until it is recorded, an option removed from defineQueue stays deployed.`)}};return x.includes("DB (D1)")&&u.push(`wrote a DB binding with a placeholder database_id ("${B}") — run \`wrangler d1 create <name>\` and replace it before deploying.`),v===l?(h(!1),{added:[],changed:!1,exportGaps:r,reason:"bindings already in sync",updated:[],warnings:u,wranglerPath:t}):(M(t,v,"utf8"),h(!0),{added:x,changed:!0,exportGaps:r,updated:k,warnings:u,wranglerPath:t})};export{we as collectExportGaps,He as reconcileWranglerBindings};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{existsSync as S,statSync as T,readFileSync as O,readdirSync as $}from"node:fs";import{parse as D,init as F}from"es-module-lexer";import{discoverAgentInfo as U}from"./discoverAgentInfo-CTdCSfYM.mjs";import{discoverContainerInfo as Y}from"./discoverContainerInfo-EhZtEBQs.mjs";import{discoverFlags as M,FLAGS_FILENAME as W,discoverQueues as G,QUEUES_FILENAME as K}from"@lunora/codegen";import{d as C}from"./discover-info-Vj9d4qYt.mjs";import{escapeRegExp as X}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{discoverSchemaInfo as q}from"./discoverSchemaInfo-DJvevsCm.mjs";import{resolveWorkerEntry as H,COMPOSED_ENTRY_DURABLE_OBJECTS as Q,GENERATED_MODULE_DURABLE_OBJECTS as V,GENERATED_DIRECTORY as w,DURABLE_OBJECT_BINDINGS as J,detectExportedDurableObjects as z,detectClassExports as E}from"./COMPOSED_WORKER_ENTRY-C69wqbSP.mjs";import{discoverWorkflowInfo as Z}from"./discoverWorkflowInfo-BsPvlo6O.mjs";import{join as l}from"node:path";const ee=(e,s)=>{const{error:t,value:r}=C(e,s,W,M);return t===void 0?{flags:r}:{error:t}},L=/^\s*import\s+type\b/,se=new Set(["@lunora/agent","@lunora/agent/sandbox"]),f=["browserTool","jsCodeTool"],y=Object.fromEntries(f.map(e=>{const s=X(e);return[e,{fallback:new RegExp(String.raw`import\s+\{[^}]*\b${s}\b[^}]*\}\s+from\s+["']@lunora\/agent(?:\/sandbox)?["']`,"u"),name:new RegExp(String.raw`\b${s}\b`,"u"),typeSpecifier:new RegExp(String.raw`\btype\s+${s}\b`,"u")}]})),re=e=>{const s=e.indexOf("{");if(s===-1)return"";const t=e.indexOf("}",s+1);return t===-1?e.slice(s+1):e.slice(s+1,t)},te=(e,s)=>{if(L.test(e))return!1;const t=re(e);return y[s].name.test(t)&&!y[s].typeSpecifier.test(t)},oe=e=>{let s;try{const[t]=D(e);s=t.filter(r=>r.n!==void 0&&se.has(r.n)).map(r=>e.slice(r.ss,r.se))}catch{s=void 0}return Object.fromEntries(f.map(t=>[t,s===void 0?y[t].fallback.test(e):s.some(r=>te(r,t))]))},ne=(e,s)=>{const{error:t,value:r}=C(e,s,K,G);return t===void 0?{queues:r??[]}:{error:t,queues:[]}},ae=new Set([".cjs",".cts",".js",".jsx",".mjs",".mts",".ts",".tsx"]),ie=new Set([".git",".lunora-cache",".wrangler","dist",w,"node_modules"]),ce=["lunora","src"],de=/\benv\s*\.\s*DB\b/,ue=/\benv\s*\.\s*AI\b/,k=/\bctx\s*\.\s*pipelines\b/,P=/\bctx\s*\.\s*r2sql\b/,b={usesAi:{pattern:/\bfrom\s+["']@lunora\/ai["']/,source:"@lunora/ai"},usesAnalytics:{pattern:/\bfrom\s+["']@lunora\/bindings\/analytics["']/,source:"@lunora/bindings/analytics"},usesAuth:{pattern:/\bfrom\s+["']@lunora\/auth["']/,source:"@lunora/auth"},usesBrowser:{pattern:/\bfrom\s+["']@lunora\/browser["']/,source:"@lunora/browser"},usesHyperdrive:{pattern:/\bfrom\s+["']@lunora\/hyperdrive["']/,source:"@lunora/hyperdrive"},usesImages:{pattern:/\bfrom\s+["']@lunora\/bindings\/images["']/,source:"@lunora/bindings/images"},usesKv:{pattern:/\bfrom\s+["']@lunora\/bindings\/kv["']/,source:"@lunora/bindings/kv"},usesMail:{pattern:/\bfrom\s+["']@lunora\/mail["']/,source:"@lunora/mail"},usesNotify:{pattern:/\bfrom\s+["']@lunora\/notify["']/,source:"@lunora/notify"},usesPayment:{pattern:/\bfrom\s+["']@lunora\/payment["']/,source:"@lunora/payment"},usesPipelines:{pattern:k,source:"@lunora/bindings/pipelines"},usesR2sql:{pattern:P,source:"@lunora/bindings/r2sql"},usesScheduler:{pattern:/\bfrom\s+["']@lunora\/scheduler["']/,source:"@lunora/scheduler"},usesStorage:{pattern:/\bfrom\s+["']@lunora\/storage["']/,source:"@lunora/storage"},usesX402Charge:{pattern:/\bfrom\s+["']@lunora\/x402\/charge["']/,source:"@lunora/x402/charge"},usesX402Pay:{pattern:/\bfrom\s+["']@lunora\/x402\/pay["']/,source:"@lunora/x402/pay"}},p=Object.keys(b),le="STRIPE_SECRET_KEY + STRIPE_WEBHOOK_SECRET (Stripe) or POLAR_ACCESS_TOKEN + POLAR_WEBHOOK_SECRET (Polar)",B=[...p,"needsD1","usesWorkerLoader"],pe=()=>{const e={};for(const s of B)e[s]=!1;return e},u=Object.freeze(pe()),_=(e,s)=>{const t={};for(const r of B)t[r]=e[r]||s[r];return t},me=e=>{for(const s of p)if(b[s].source===e)return{...u,[s]:!0};return u},fe=e=>{const[s]=D(e);let t=u;for(const r of s){const o=r.n;!o||L.test(e.slice(r.ss,r.se))||(t=_(t,me(o)))}return t},be=e=>{const s={...u};for(const t of p)s[t]=b[t].pattern.test(e);return s},ge=e=>{let s;try{s=fe(e)}catch{s=be(e)}return _(s,{...u,needsD1:de.test(e),usesAi:ue.test(e),usesPipelines:k.test(e),usesR2sql:P.test(e)})},x=(e,s)=>{let t;try{t=$(e,{withFileTypes:!0})}catch{return}for(const r of t){if(r.isDirectory()){ie.has(r.name)||x(l(e,r.name),s);continue}const o=r.name.lastIndexOf(".");o!==-1&&ae.has(r.name.slice(o))&&s.push(l(e,r.name))}},he=(e,s)=>q(e,s).info?.hasD1GlobalTable??!1,Ee=(e,s)=>{let t=u;for(const r of s){const o=l(e,r);if(!S(o)||!T(o).isDirectory())continue;const n=[];x(o,n);for(const a of n)t=_(t,ge(O(a,"utf8")))}return t},ye=(e,s)=>{const t=l(e,s),r=Object.fromEntries(f.map(n=>[n,!1]));if(!S(t)||!T(t).isDirectory())return r;const o=[];x(t,o);for(const n of o){const a=oe(O(n,"utf8"));for(const i of f)r[i]||=a[i]}return r},Se=(e,s,t)=>[...e.map(r=>r.exported?`${r.bindingName}/${r.className} (container "${r.exportName}" declared and exported)`:`hint: container "${r.exportName}" is declared but ${r.className} is not exported by the worker entry — add \`export * from "./lunora/_generated/containers"\``),...s.map(r=>r.exported?`exports.${r.className} (workflow "${r.exportName}" declared and exported)`:`hint: workflow "${r.exportName}" is declared but ${r.className} is not exported by the worker entry — add \`export * from "./lunora/_generated/workflows"\``),...t.map(r=>r.exported?`exports.${r.className} (agent "${r.exportName}" declared and exported)`:`hint: agent "${r.exportName}" is declared but ${r.className} is not exported by the worker entry — add \`export * from "./lunora/_generated/agents"\``)],_e=(e,s)=>[[e.usesAi,"AI (@lunora/ai imported or env.AI used)"],[e.usesAuth&&!s.has("SessionDO"),"hint: @lunora/auth is imported; its tables are D1-backed by default. For DO-backed auth (what @better-auth/scim needs), pass `namespace` to .auth() and export the generated auth DO class"],[e.usesScheduler&&!s.has("SchedulerDO"),"hint: @lunora/scheduler is imported but no SchedulerDO is exported by the worker entry"],[e.usesStorage,"hint: @lunora/storage is imported; add an r2_buckets binding (bucket binding names are user-defined)"],[e.usesMail,"hint: @lunora/mail is imported; set RESEND_API_KEY in .dev.vars (obtain at https://resend.com/api-keys)"],[e.usesPayment,`hint: @lunora/payment is imported; set the provider secrets in .dev.vars — ${le}`],[e.usesBrowser,"browser (@lunora/browser imported) — self-describing { binding: BROWSER }"],[e.usesImages,"images (@lunora/bindings/images imported) — self-describing { binding: IMAGES }"],[e.usesAnalytics,"analytics_engine_datasets (@lunora/bindings/analytics imported) — self-describing { binding: ANALYTICS, dataset }"],[e.usesWorkerLoader,"worker_loaders (jsCodeTool imported in lunora/) — self-describing { binding: LOADER }"],[e.usesKv,"hint: @lunora/bindings/kv is imported; add a kv_namespaces binding ({ binding, id }) and pass env.<BINDING> to createKv() — the namespace id can't be auto-provisioned"],[e.usesHyperdrive,"hint: @lunora/hyperdrive is imported; run 'wrangler hyperdrive create' and add a 'hyperdrive' binding ({ binding, id }) — the id can't be auto-provisioned"],[e.usesPipelines,"hint: ctx.pipelines is used; run 'wrangler pipelines create <name>' and add a 'pipelines' binding ({ binding, stream }) — the pipeline resource can't be auto-provisioned"],[e.usesX402Charge,"hint: @lunora/x402/charge is imported; set the recipient wallet address as a [vars] entry (the var name is yours to choose) and pass it to the charge config — the x402 facilitator settles USDC to that address"],[e.usesX402Pay,"hint: @lunora/x402/pay is imported (ActionCtx-only, spends real funds); add a secrets_store_secrets[] binding for the agent wallet key (name it to match signer.secretName) and pair the pay rail with a spend policy — ctx.secrets reads a Secrets Store binding, not .dev.vars, so the key can't be auto-provisioned"]].filter(([r])=>r).map(([,r])=>r),xe=(e,s,t,r=[],o=[],n=[])=>{const a=new Set(e.map(c=>c.className)),i=e.map(c=>`${c.binding}/${c.className} (exported by worker entry)`);return s&&i.push("DB (.global() table declared)"),i.push(...Se(r,o,n),..._e(t,a)),i},ke=async e=>{await F;const s=e.schemaDir??"lunora",t=e.scanDirs??ce,r=Ee(e.projectRoot,t),o=ye(e.projectRoot,s),n={...r,usesBrowser:r.usesBrowser||o.browserTool,usesWorkerLoader:o.jsCodeTool},a=H(e.projectRoot);let i;a.composed?i=[...Q,...Object.entries(V).filter(([d])=>S(l(e.projectRoot,s,w,`${d}.ts`))).map(([,d])=>d)].map(d=>({binding:J[d],className:d})):i=a.path===void 0?[]:z(a.path);const c=n.needsD1||he(e.projectRoot,s),v=E(a,Y(e.projectRoot,s).containers,"containers"),I=E(a,Z(e.projectRoot,s).workflows,"workflows"),R=E(a,U(e.projectRoot,s).agents,"agents"),j=[...ne(e.projectRoot,s).queues],{flags:m}=ee(e.projectRoot,s),g=m?.provider==="flagship"&&m.mode==="binding"?m.bindingName:void 0,A={};for(const h of p)A[h]=n[h];const N=xe(i,c,n,v,I,R);return g!==void 0&&N.push(`hint: lunora/flags.ts uses Flagship in binding mode; add a flagship binding ({ binding: "${g}", app_id }) — the app_id can't be auto-provisioned`),{agents:R,containers:v,durableObjects:i,flagshipBinding:g,needsD1:c,queues:j,signals:N,usesFlags:m!==void 0,usesWorkerLoader:n.usesWorkerLoader,workflows:I,...A}},Pe=e=>{const s=[];for(const t of p)e[t]&&s.push(b[t].source);return s};export{ke as inferLunoraBindings,Pe as packageNamesFromBindings};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{inferLunoraBindings as d}from"./inferLunoraBindings-hCgGQAGN.mjs";import{LUNORA_TAG as r}from"./LUNORA_TAG-CiQM3BkI.mjs";import{reconcileWranglerBindings as f}from"./collectExportGaps-FC62nUj0.mjs";import{reconcileWranglerCompatibilityDate as p}from"./reconcileWranglerCompatibilityDate-hocXEuRA.mjs";import{reconcileWranglerCrons as g,describePreservedCrons as $}from"./describePreservedCrons-Ci5r2aph.mjs";const b=async(i,a,t)=>{try{const n=await d({projectRoot:i.projectRoot,schemaDir:i.schemaDir}),e=f(i.projectRoot,n),o=e.wranglerPath??"wrangler.jsonc";e.added.length>0&&a.info?.(`${r} inferred bindings → ${e.added.join(", ")} (written to ${o})`),e.updated.length>0&&a.info?.(`${r} updated bindings → ${e.updated.join(", ")} (written to ${o})`);for(const s of e.warnings)a.warn(`${r} ${s}`);e.exportGaps.length>0&&t?.(e.exportGaps)}catch(n){const e=n instanceof Error?n.message:String(n);a.warn(`${r} binding inference skipped: ${e}`)}},c=new Map,j=(i,a,t)=>{try{const n=g(i,a);n.changed&&t.info?.(`${r} synced ${a.length.toFixed(0)} cron trigger(s) into ${n.wranglerPath??"wrangler.jsonc"}`);for(const s of n.warnings)t.warn(`${r} ${s}`);const e=n.preserved.join("\0"),o=$(n.preserved);o!==void 0&&(n.changed||c.get(i)!==e)&&t.info?.(`${r} ${o}`),c.set(i,e)}catch(n){const e=n instanceof Error?n.message:String(n);t.warn(`${r} cron trigger sync skipped: ${e}`)}try{const n=p(i);n.changed&&t.info?.(`${r} bumped compatibility_date to ${n.date??"unknown"} (Workers Cache enabled) → ${n.wranglerPath??"wrangler.jsonc"}`)}catch(n){const e=n instanceof Error?n.message:String(n);t.warn(`${r} compatibility date sync skipped: ${e}`)}};export{b as reconcileBindingsSafely,j as reconcileWranglerExtras};
|