@lunora/config 1.0.0-alpha.39 → 1.0.0-alpha.390

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/LICENSE.md +135 -0
  2. package/README.md +3 -3
  3. package/dist/cli/index.d.mts +2 -0
  4. package/dist/cli/index.d.ts +2 -0
  5. package/dist/cli/index.mjs +1 -0
  6. package/dist/cloudflare/index.d.mts +1306 -0
  7. package/dist/cloudflare/index.d.ts +1306 -0
  8. package/dist/cloudflare/index.mjs +1 -0
  9. package/dist/index.d.mts +845 -974
  10. package/dist/index.d.ts +845 -974
  11. package/dist/index.mjs +1 -23
  12. package/dist/packem_shared/ACCENT-CotPTfv7.mjs +7 -0
  13. package/dist/packem_shared/AGENT_MODE_ENV-D8MvSwPE.mjs +1 -0
  14. package/dist/packem_shared/AGENT_RULES_DIR-Bd6JPtNa.mjs +1 -0
  15. package/dist/packem_shared/ALLOW_FORWARDED_ENV-BUndghJx.mjs +1 -0
  16. package/dist/packem_shared/BINDING_MANIFEST_VERSION-CfXEYG8e.mjs +1 -0
  17. package/dist/packem_shared/CLOUDFLARE_CLI_CONFIG_WARNING_ENV-BKMrOuXV.mjs +1 -0
  18. package/dist/packem_shared/CLOUDFLARE_DRIVER-CULavrYO.mjs +1 -0
  19. package/dist/packem_shared/CLOUDFLARE_TOOLCHAIN_VERSIONS-DV5E_f_q.mjs +1 -0
  20. package/dist/packem_shared/CODEGEN_ENV-CkUo3_GU.mjs +1 -0
  21. package/dist/packem_shared/COMPOSED_WORKER_ENTRY-Ciiba5g_.mjs +1 -0
  22. package/dist/packem_shared/DEFAULT_DEPLOY_TARGET-rR7buNQw.mjs +1 -0
  23. package/dist/packem_shared/DEFAULT_OBSERVABILITY-bN6UkTMx.mjs +1 -0
  24. package/dist/packem_shared/DEV_BINDINGS_FILE-C0ZN_XlP.mjs +4 -0
  25. package/dist/packem_shared/DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs +6 -0
  26. package/dist/packem_shared/DEV_WORKER_ENV_VALUE-CARjGoAv.mjs +1 -0
  27. package/dist/packem_shared/GLOBAL_FETCH_STRICTLY_PUBLIC_FLAG-f8CnJha3.mjs +1 -0
  28. package/dist/packem_shared/HYPERDRIVE_PLACEHOLDER_ID-ChryQmwG.mjs +2 -0
  29. package/dist/packem_shared/LINKED_PROJECT_DIR-Ba5qPEwo.mjs +2 -0
  30. package/dist/packem_shared/LUNORA_EVENT_SOURCE-B9ZVohjO.mjs +1 -0
  31. package/dist/packem_shared/LUNORA_IGNORED_PATHS-U93uPxrW.mjs +19 -0
  32. package/dist/packem_shared/LUNORA_TAG-DQTGPqcJ.mjs +1 -0
  33. package/dist/packem_shared/LunoraReporter-f277GLNT.mjs +6 -0
  34. package/dist/packem_shared/PACKAGE_SECRETS_REGISTRY-DI99PpTL.mjs +1 -0
  35. package/dist/packem_shared/POLICY_SCAFFOLD_ENDPOINT-BGmCp5gf.mjs +1 -0
  36. package/dist/packem_shared/REMOTE_ELIGIBLE_KEYS-DnbYTTWX.mjs +1 -0
  37. package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-D4UcOP_t.mjs +1 -0
  38. package/dist/packem_shared/SCHEMA_EDIT_ENDPOINT-oGE8lMFF.mjs +1 -0
  39. package/dist/packem_shared/SEED_ENDPOINT-2B56PN_H.mjs +1 -0
  40. package/dist/packem_shared/STUDIO_PATH-DEi8zoNu.mjs +1 -0
  41. package/dist/packem_shared/UNEXPORTED_CLASS_MARKER-mdcw5KDY.mjs +1 -0
  42. package/dist/packem_shared/WORKERS_CACHE_MIN_DATE-0k9ABJtF.mjs +1 -0
  43. package/dist/packem_shared/WRANGLER_FILES-UNW-xY5u.mjs +1 -0
  44. package/dist/packem_shared/acceptsConnection-DHhUYGjT.mjs +2 -0
  45. package/dist/packem_shared/addArgsFor-CYZKhNIo.mjs +1 -0
  46. package/dist/packem_shared/applyAdditiveEdit-CH0VhMJ2.mjs +6 -0
  47. package/dist/packem_shared/applyModify-DKP2l6S9.mjs +1 -0
  48. package/dist/packem_shared/applyStudioAssetCache-DHQEJuuv.mjs +1 -0
  49. package/dist/packem_shared/assertWranglerSatisfiesSchema-B4DcaiJY.mjs +3 -0
  50. package/dist/packem_shared/assetContentType-CUb5bpbI.mjs +1 -0
  51. package/dist/packem_shared/bindingsNeedingDatabase-6eD6Qtqf.mjs +3 -0
  52. package/dist/packem_shared/blockingFindingsMessage-BVbijPdn.mjs +1 -0
  53. package/dist/packem_shared/buildPackageSecretsBlock-C5WZfMwe.mjs +19 -0
  54. package/dist/packem_shared/celld-config-D-L6uskI.mjs +3 -0
  55. package/dist/packem_shared/classifyPolicyEdit-DJi9Fk8G.mjs +24 -0
  56. package/dist/packem_shared/createConfirm-D5mKTMHj.mjs +7 -0
  57. package/dist/packem_shared/createDiscoveryCache-npJI4uej.mjs +1 -0
  58. package/dist/packem_shared/deploy-driver.d-Cl96-c1l.d.mts +184 -0
  59. package/dist/packem_shared/deploy-driver.d-Cl96-c1l.d.ts +184 -0
  60. package/dist/packem_shared/describePreservedCrons-C5KPuPy3.mjs +1 -0
  61. package/dist/packem_shared/describeWithheld-CbyzZjZF.mjs +1 -0
  62. package/dist/packem_shared/detectFramework-Dfpvu6rD.mjs +1 -0
  63. package/dist/packem_shared/discover-info-DC2MrAIM.mjs +1 -0
  64. package/dist/packem_shared/discoverAgentInfo-pqFMJBtJ.mjs +1 -0
  65. package/dist/packem_shared/discoverContainerInfo-DzXr7Vm3.mjs +1 -0
  66. package/dist/packem_shared/discoverSchemaInfo-BBRlXZop.mjs +1 -0
  67. package/dist/packem_shared/discoverWorkflowInfo-zW7Tt0Tn.mjs +1 -0
  68. package/dist/packem_shared/guards-Buu_E7mP.mjs +1 -0
  69. package/dist/packem_shared/hasCloudflareCredentials-CNPVIVBb.mjs +1 -0
  70. package/dist/packem_shared/index.d-Cmx4jMFV.d.ts +270 -0
  71. package/dist/packem_shared/index.d-DkNi7r6E.d.mts +270 -0
  72. package/dist/packem_shared/infer-bindings.d-BNrKAI1c.d.mts +300 -0
  73. package/dist/packem_shared/infer-bindings.d-BNrKAI1c.d.ts +300 -0
  74. package/dist/packem_shared/inferLunoraBindings-BT4-fwiQ.mjs +1 -0
  75. package/dist/packem_shared/interpretRemote-CcmGeGZ_.mjs +1 -0
  76. package/dist/packem_shared/lunora-manifest-DuH_Cmyu.mjs +6 -0
  77. package/dist/packem_shared/materializeServiceDevConfigs-k_oLCcBT.mjs +1 -0
  78. package/dist/packem_shared/mergeWranglerEnvironment-D5ekKj5x.mjs +1 -0
  79. package/dist/packem_shared/package-secrets-registry-BEJELdls.mjs +1 -0
  80. package/dist/packem_shared/parseDevVariable-teAAahVD.mjs +1 -0
  81. package/dist/packem_shared/parseSchema-D1Wbr1qv.mjs +1 -0
  82. package/dist/packem_shared/policy-scaffold.d-D2H4_G01.d.mts +86 -0
  83. package/dist/packem_shared/policy-scaffold.d-D2H4_G01.d.ts +86 -0
  84. package/dist/packem_shared/process-tree-once-Ou4SfxKM.mjs +1 -0
  85. package/dist/packem_shared/readProjectDependencies-l3uhUKjo.mjs +1 -0
  86. package/dist/packem_shared/reconcile-services-DFqH4eMQ.mjs +1 -0
  87. package/dist/packem_shared/reconcileBindingsSafely-Bpi7q5vG.mjs +1 -0
  88. package/dist/packem_shared/reconcileWranglerCompatibilityDate-hocXEuRA.mjs +1 -0
  89. package/dist/packem_shared/renderStudioHtml-ByowDtMl.mjs +15 -0
  90. package/dist/packem_shared/resolveSchemaDirectory-Ca5P6KuP.mjs +1 -0
  91. package/dist/packem_shared/runPostCodegenHook-Dx3yTsYZ.mjs +1 -0
  92. package/dist/packem_shared/scanWranglerVariablesForSecrets-CZDS9y2i.mjs +1 -0
  93. package/dist/packem_shared/serveJsonHandler-Dv0EdCb9.mjs +1 -0
  94. package/dist/packem_shared/startCelldDevSession-BLFsd6jG.mjs +1 -0
  95. package/dist/packem_shared/streamContainerLogs-0nko1qpv.mjs +2 -0
  96. package/dist/packem_shared/validate-bindings-PVHSAU6M.mjs +1 -0
  97. package/dist/packem_shared/withTailConsumer-CF3pk_Ov.mjs +1 -0
  98. package/dist/packem_shared/worker-entry-checks-AIASCYl7.mjs +1 -0
  99. package/dist/packem_shared/wranglerCodegenInputs-UqO5e_qJ.mjs +1 -0
  100. package/dist/packem_shared/wranglerToAlchemy-CBO2ucRm.mjs +6 -0
  101. package/dist/packem_shared/write-atomic-zfU6flfm.mjs +1 -0
  102. package/dist/studio-host/index.d.mts +320 -110
  103. package/dist/studio-host/index.d.ts +320 -110
  104. package/dist/studio-host/index.mjs +1 -7
  105. package/package.json +32 -7
  106. package/dist/packem_shared/ACCENT-DW1XJn8i.mjs +0 -40
  107. package/dist/packem_shared/AGENT_RULES_DIR-lcgC08aE.mjs +0 -40
  108. package/dist/packem_shared/DEV_VARS_EXAMPLE_FILE-dJPNTEnK.mjs +0 -37
  109. package/dist/packem_shared/LINKED_PROJECT_DIR-CXwXzV_C.mjs +0 -52
  110. package/dist/packem_shared/LUNORA_CONFIG_FILE-CtcIcB5-.mjs +0 -34
  111. package/dist/packem_shared/LUNORA_EVENT_SOURCE-D2fDeGB6.mjs +0 -86
  112. package/dist/packem_shared/LunoraReporter-Ci-bDCK9.mjs +0 -70
  113. package/dist/packem_shared/PACKAGE_SECRETS_REGISTRY-B8t_SdoZ.mjs +0 -70
  114. package/dist/packem_shared/POLICY_SCAFFOLD_ENDPOINT-CiC2IGKx.mjs +0 -103
  115. package/dist/packem_shared/REMOTE_ELIGIBLE_KEYS-BC7_e9Bz.mjs +0 -105
  116. package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-2YYyWJUq.mjs +0 -561
  117. package/dist/packem_shared/SCHEMA_EDIT_ENDPOINT-Df-Wrix-.mjs +0 -99
  118. package/dist/packem_shared/SEED_ENDPOINT-DVCjaGO-.mjs +0 -61
  119. package/dist/packem_shared/WRANGLER_FILES-DwSuC-Kn.mjs +0 -25
  120. package/dist/packem_shared/applyAdditiveEdit-C-snTFEV.mjs +0 -228
  121. package/dist/packem_shared/buildPackageSecretsBlock-BCHtfQ2A.mjs +0 -280
  122. package/dist/packem_shared/classifyPolicyEdit-BHeAqF8P.mjs +0 -99
  123. package/dist/packem_shared/createConfirm-fvpdgJ9s.mjs +0 -100
  124. package/dist/packem_shared/detectFramework-Br-BcPBq.mjs +0 -41
  125. package/dist/packem_shared/discoverContainerInfo-BXFs6Wav.mjs +0 -19
  126. package/dist/packem_shared/discoverSchemaInfo-BB-CKlTK.mjs +0 -25
  127. package/dist/packem_shared/discoverWorkflowInfo-CedvR0mn.mjs +0 -19
  128. package/dist/packem_shared/inferLunoraBindings-ByMwG-gH.mjs +0 -352
  129. package/dist/packem_shared/loadStudioAssets-Csk5RS4E.mjs +0 -28
  130. package/dist/packem_shared/parseDevVariable-CJiq2IwE.mjs +0 -30
  131. package/dist/packem_shared/parseSchema-DSeyktvG.mjs +0 -107
  132. package/dist/packem_shared/policy-scaffold.d-DCmwn7zQ.d.mts +0 -74
  133. package/dist/packem_shared/policy-scaffold.d-DCmwn7zQ.d.ts +0 -74
  134. package/dist/packem_shared/reconcileWranglerBindings-Cruwwx1M.mjs +0 -334
  135. package/dist/packem_shared/renderStudioHtml-449Ysn75.mjs +0 -37
  136. package/dist/packem_shared/serveJsonHandler-B4OLTGLS.mjs +0 -86
  137. package/dist/packem_shared/streamContainerLogs-BZ4cOZwH.mjs +0 -157
@@ -0,0 +1,184 @@
1
+ /**
2
+ * `DeployDriver` — the provider-neutral seam between a Lunora command and the
3
+ * host CLI that carries it out (plan 114, §5.3).
4
+ *
5
+ * The seam is the **toolchain surface**: which command a host runs to deploy,
6
+ * serve, tail, or set a secret. A driver only *describes* that command
7
+ * ({@link ToolchainCommand}); it never spawns. The CLI keeps ownership of
8
+ * running it — package-manager resolution (`pnpm exec` / `npx --` / `bun x`)
9
+ * and the injected spawner its tests substitute — so the driver stays free of
10
+ * process concerns and remains trivially testable as a pure function.
11
+ *
12
+ * Each request type below is deliberately neutral: `preview`, `environment`,
13
+ * `temporary` are concepts, not wrangler flags. A second host maps the same
14
+ * request onto its own CLI without the caller changing.
15
+ *
16
+ * Three drivers are registered: Cloudflare (`cloudflare/cloudflare-driver.ts`)
17
+ * and celld (`celld/celld-driver.ts`), which ship toolchains, and Node
18
+ * (`node/node-driver.ts`), which has none — it is a codegen target, and
19
+ * `lunora deploy` / `lunora dev` refuse it at selection.
20
+ *
21
+ * **What this seam deliberately does NOT carry: configuration inference.** It
22
+ * used to, through an `infer`/`provision` pair over a provider-neutral
23
+ * `ResourceGraph`. Nothing ever called either one — every consumer reads
24
+ * `.toolchain` or just validates the target — and the arm rotted in place: the
25
+ * Node driver was *only* `infer` + `provision`, so its report of what that
26
+ * target cannot serve (containers, undispatched crons) could not reach an
27
+ * operator however wrong the app was. The reason it never got wired is worth
28
+ * keeping: writing real host configuration needs the host's own encodings —
29
+ * binding names, DO class wiring, migration tags — which a neutral graph
30
+ * necessarily discards, so `provision` re-derived them anyway and the graph was
31
+ * decorative. A second target that needs to share inference should grow the
32
+ * seam back with a caller attached, and with an encoding escape hatch.
33
+ */
34
+ /**
35
+ * A host CLI invocation, described but not run.
36
+ *
37
+ * `tool` is the binary name only (`"wrangler"`); the caller resolves how to
38
+ * execute it through the project's package manager (see `toolchainExecArgs`).
39
+ * Keeping that split means a driver never has to know whether the project uses
40
+ * pnpm, npm, yarn, or bun.
41
+ */
42
+ interface ToolchainCommand {
43
+ /** Arguments for {@link ToolchainCommand.tool}. */
44
+ args: ReadonlyArray<string>;
45
+ /**
46
+ * The tool is a standalone binary installed on `PATH`, not a project
47
+ * dependency: run it directly. Going through the package manager would be
48
+ * wrong for it — `npx --` / `bun x` fetch an npm package of the same name
49
+ * when none is installed locally, which for a non-npm binary is somebody
50
+ * else's code.
51
+ */
52
+ onPath?: boolean;
53
+ /** The host CLI binary, e.g. `"wrangler"`. */
54
+ tool: string;
55
+ }
56
+ /** Neutral options for a deploy. */
57
+ interface DeployRequest {
58
+ /** Host config file to deploy, when the flow uses a projected one (see {@link DeployDriver.projectConfig}). */
59
+ configPath?: string;
60
+ /** Validate and bundle without publishing — nothing ships. */
61
+ dryRun?: boolean;
62
+ /** Deploy this entry file instead of the host config's default (framework composition). */
63
+ entry?: string;
64
+ /** Named deployment environment, when the host supports them. */
65
+ environment?: string;
66
+ /** Write the built bundle (and any build metadata) to this directory. */
67
+ outDir?: string;
68
+ /** Upload a preview/versioned artifact instead of taking production traffic. */
69
+ preview?: boolean;
70
+ /** Deploy to a short-lived, unauthenticated account where the host offers one. */
71
+ temporary?: boolean;
72
+ }
73
+ /** Neutral options for a local dev server. */
74
+ interface DevRequest {
75
+ /** Host config file to run against, when the flow uses a generated one. */
76
+ configPath?: string;
77
+ /** Named environment. */
78
+ environment?: string;
79
+ /** Extra host-specific flags the caller has already resolved. */
80
+ extraArgs?: ReadonlyArray<string>;
81
+ }
82
+ /** Neutral options for tailing live logs. */
83
+ interface TailRequest {
84
+ /** Named environment. */
85
+ environment?: string;
86
+ /** Output format the host tail supports (`"json"`, `"pretty"`, …). */
87
+ format?: string;
88
+ /** Free-text filter. */
89
+ search?: string;
90
+ /** Status filter (`"error"`, `"ok"`, …). */
91
+ status?: string;
92
+ /** Tail a short-lived account's deployment. */
93
+ temporary?: boolean;
94
+ /** Tail a specific deployed worker/service by name, when the host addresses them individually. */
95
+ worker?: string;
96
+ }
97
+ /** Neutral options for reading or writing deployment secrets. */
98
+ interface SecretRequest {
99
+ /** Named environment. */
100
+ environment?: string;
101
+ /** The secret's name — required for `put`, unused for `list`. */
102
+ key?: string;
103
+ /** Operate against a short-lived account. */
104
+ temporary?: boolean;
105
+ }
106
+ /**
107
+ * The host's command-line surface. Optional as a whole: a host with no vendor
108
+ * CLI (the Node target; a hypothetical API-driven one) declares none, and
109
+ * `isRunnableTarget` refuses it for the commands that would have to shell out.
110
+ *
111
+ * `deploy` and `dev` are what make a target runnable. The secret and tail
112
+ * commands are optional on their own, because a runnable host can simply not
113
+ * have them — celld keeps configuration in plain `vars` and has no log tail —
114
+ * and the commands that need one say so rather than guessing a substitute.
115
+ */
116
+ interface DriverToolchain {
117
+ /** The command that deploys the app. */
118
+ deploy: (request: DeployRequest) => ToolchainCommand;
119
+ /** The command that runs a local dev server. */
120
+ dev: (request: DevRequest) => ToolchainCommand;
121
+ /**
122
+ * Where `lunora dev` runs the worker. `"workerd"`: `wrangler dev`, or the
123
+ * Vite plugin's `@cloudflare/vite-plugin`, whichever flavor the project
124
+ * picks. `"own"`: the host's dev server ({@link DriverToolchain.dev}) on
125
+ * the projected config, always the standalone flavor — neither Vite nor a
126
+ * framework sidecar can serve the worker on that runtime.
127
+ */
128
+ readonly devServer: "own" | "workerd";
129
+ /**
130
+ * Whether `lunora deploy` builds and pushes container images itself
131
+ * (railpack, into the host's registry) before `deploy`. `false` when the
132
+ * host CLI builds each image from its Dockerfile during the deploy.
133
+ */
134
+ readonly prebuildsContainerImages: boolean;
135
+ /** The command that writes many secrets in one call, as a JSON object of name to value on stdin. Optional: hosts without it get one `secretPut` per key. */
136
+ secretBulk?: (request: SecretRequest) => ToolchainCommand;
137
+ /** The command that lists remote secret names, when the host has a secret store. */
138
+ secretList?: (request: SecretRequest) => ToolchainCommand;
139
+ /** The command that writes one secret, when the host has a secret store. Its value is passed on stdin, never argv. */
140
+ secretPut?: (request: SecretRequest) => ToolchainCommand;
141
+ /** The command that tails live logs, when the host has one. */
142
+ tail?: (request: TailRequest) => ToolchainCommand;
143
+ }
144
+ /** What a {@link DeployDriver.projectConfig} projection is for — a dev server may need a different source than a deploy. */
145
+ type ProjectionPurpose = "deploy" | "dev";
146
+ /**
147
+ * The result of {@link DeployDriver.projectConfig}: a plan, not yet on disk.
148
+ * The caller validates the request it is for (the toolchain's argv builder
149
+ * refuses unsupported options), then calls `write` — so a refused command
150
+ * changes nothing.
151
+ */
152
+ interface ProjectedConfig {
153
+ /** Where the projection goes, to pass as the request's `configPath`. */
154
+ configPath: string;
155
+ /** Every key removed, as a dotted path (`observability`, `containers[0].rollout_step_percentage`). */
156
+ dropped: ReadonlyArray<string>;
157
+ /** Write the projection (and any build-artifact cleanup it planned). */
158
+ write: () => void;
159
+ }
160
+ /** A deploy target's implementation: an identity the registry resolves, and the host CLI surface (if any) behind it. */
161
+ interface DeployDriver {
162
+ /** The target id this driver serves (`"cloudflare"`, …) — matches codegen's `target`. */
163
+ readonly id: string;
164
+ /** Human-readable target name, for logs. */
165
+ readonly name: string;
166
+ /**
167
+ * Rewrite the project's wrangler config into the form this host's CLI
168
+ * accepts, and return the file to hand `deploy`/`dev` as `configPath`.
169
+ * Absent when the host reads the project's config as-is (Cloudflare).
170
+ *
171
+ * Needed because Lunora's reconcilers and templates write Cloudflare-only
172
+ * keys (`observability`, `limits`, …) that a Workers-compatible host with a
173
+ * strict config reader refuses outright. `dropped` names what was removed,
174
+ * so the caller can say so instead of silently deploying less than the
175
+ * config describes.
176
+ */
177
+ readonly projectConfig?: (projectRoot: string, purpose: ProjectionPurpose) => ProjectedConfig;
178
+ /**
179
+ * The host's command-line surface, or `undefined` for a host that has none.
180
+ * Pure: these build argv, they never spawn.
181
+ */
182
+ readonly toolchain?: DriverToolchain;
183
+ }
184
+ export { DeployDriver as D, ProjectedConfig as P, SecretRequest as S, TailRequest as T, DeployRequest as a, DevRequest as b, DriverToolchain as c, ProjectionPurpose as d, ToolchainCommand as e };
@@ -0,0 +1,184 @@
1
+ /**
2
+ * `DeployDriver` — the provider-neutral seam between a Lunora command and the
3
+ * host CLI that carries it out (plan 114, §5.3).
4
+ *
5
+ * The seam is the **toolchain surface**: which command a host runs to deploy,
6
+ * serve, tail, or set a secret. A driver only *describes* that command
7
+ * ({@link ToolchainCommand}); it never spawns. The CLI keeps ownership of
8
+ * running it — package-manager resolution (`pnpm exec` / `npx --` / `bun x`)
9
+ * and the injected spawner its tests substitute — so the driver stays free of
10
+ * process concerns and remains trivially testable as a pure function.
11
+ *
12
+ * Each request type below is deliberately neutral: `preview`, `environment`,
13
+ * `temporary` are concepts, not wrangler flags. A second host maps the same
14
+ * request onto its own CLI without the caller changing.
15
+ *
16
+ * Three drivers are registered: Cloudflare (`cloudflare/cloudflare-driver.ts`)
17
+ * and celld (`celld/celld-driver.ts`), which ship toolchains, and Node
18
+ * (`node/node-driver.ts`), which has none — it is a codegen target, and
19
+ * `lunora deploy` / `lunora dev` refuse it at selection.
20
+ *
21
+ * **What this seam deliberately does NOT carry: configuration inference.** It
22
+ * used to, through an `infer`/`provision` pair over a provider-neutral
23
+ * `ResourceGraph`. Nothing ever called either one — every consumer reads
24
+ * `.toolchain` or just validates the target — and the arm rotted in place: the
25
+ * Node driver was *only* `infer` + `provision`, so its report of what that
26
+ * target cannot serve (containers, undispatched crons) could not reach an
27
+ * operator however wrong the app was. The reason it never got wired is worth
28
+ * keeping: writing real host configuration needs the host's own encodings —
29
+ * binding names, DO class wiring, migration tags — which a neutral graph
30
+ * necessarily discards, so `provision` re-derived them anyway and the graph was
31
+ * decorative. A second target that needs to share inference should grow the
32
+ * seam back with a caller attached, and with an encoding escape hatch.
33
+ */
34
+ /**
35
+ * A host CLI invocation, described but not run.
36
+ *
37
+ * `tool` is the binary name only (`"wrangler"`); the caller resolves how to
38
+ * execute it through the project's package manager (see `toolchainExecArgs`).
39
+ * Keeping that split means a driver never has to know whether the project uses
40
+ * pnpm, npm, yarn, or bun.
41
+ */
42
+ interface ToolchainCommand {
43
+ /** Arguments for {@link ToolchainCommand.tool}. */
44
+ args: ReadonlyArray<string>;
45
+ /**
46
+ * The tool is a standalone binary installed on `PATH`, not a project
47
+ * dependency: run it directly. Going through the package manager would be
48
+ * wrong for it — `npx --` / `bun x` fetch an npm package of the same name
49
+ * when none is installed locally, which for a non-npm binary is somebody
50
+ * else's code.
51
+ */
52
+ onPath?: boolean;
53
+ /** The host CLI binary, e.g. `"wrangler"`. */
54
+ tool: string;
55
+ }
56
+ /** Neutral options for a deploy. */
57
+ interface DeployRequest {
58
+ /** Host config file to deploy, when the flow uses a projected one (see {@link DeployDriver.projectConfig}). */
59
+ configPath?: string;
60
+ /** Validate and bundle without publishing — nothing ships. */
61
+ dryRun?: boolean;
62
+ /** Deploy this entry file instead of the host config's default (framework composition). */
63
+ entry?: string;
64
+ /** Named deployment environment, when the host supports them. */
65
+ environment?: string;
66
+ /** Write the built bundle (and any build metadata) to this directory. */
67
+ outDir?: string;
68
+ /** Upload a preview/versioned artifact instead of taking production traffic. */
69
+ preview?: boolean;
70
+ /** Deploy to a short-lived, unauthenticated account where the host offers one. */
71
+ temporary?: boolean;
72
+ }
73
+ /** Neutral options for a local dev server. */
74
+ interface DevRequest {
75
+ /** Host config file to run against, when the flow uses a generated one. */
76
+ configPath?: string;
77
+ /** Named environment. */
78
+ environment?: string;
79
+ /** Extra host-specific flags the caller has already resolved. */
80
+ extraArgs?: ReadonlyArray<string>;
81
+ }
82
+ /** Neutral options for tailing live logs. */
83
+ interface TailRequest {
84
+ /** Named environment. */
85
+ environment?: string;
86
+ /** Output format the host tail supports (`"json"`, `"pretty"`, …). */
87
+ format?: string;
88
+ /** Free-text filter. */
89
+ search?: string;
90
+ /** Status filter (`"error"`, `"ok"`, …). */
91
+ status?: string;
92
+ /** Tail a short-lived account's deployment. */
93
+ temporary?: boolean;
94
+ /** Tail a specific deployed worker/service by name, when the host addresses them individually. */
95
+ worker?: string;
96
+ }
97
+ /** Neutral options for reading or writing deployment secrets. */
98
+ interface SecretRequest {
99
+ /** Named environment. */
100
+ environment?: string;
101
+ /** The secret's name — required for `put`, unused for `list`. */
102
+ key?: string;
103
+ /** Operate against a short-lived account. */
104
+ temporary?: boolean;
105
+ }
106
+ /**
107
+ * The host's command-line surface. Optional as a whole: a host with no vendor
108
+ * CLI (the Node target; a hypothetical API-driven one) declares none, and
109
+ * `isRunnableTarget` refuses it for the commands that would have to shell out.
110
+ *
111
+ * `deploy` and `dev` are what make a target runnable. The secret and tail
112
+ * commands are optional on their own, because a runnable host can simply not
113
+ * have them — celld keeps configuration in plain `vars` and has no log tail —
114
+ * and the commands that need one say so rather than guessing a substitute.
115
+ */
116
+ interface DriverToolchain {
117
+ /** The command that deploys the app. */
118
+ deploy: (request: DeployRequest) => ToolchainCommand;
119
+ /** The command that runs a local dev server. */
120
+ dev: (request: DevRequest) => ToolchainCommand;
121
+ /**
122
+ * Where `lunora dev` runs the worker. `"workerd"`: `wrangler dev`, or the
123
+ * Vite plugin's `@cloudflare/vite-plugin`, whichever flavor the project
124
+ * picks. `"own"`: the host's dev server ({@link DriverToolchain.dev}) on
125
+ * the projected config, always the standalone flavor — neither Vite nor a
126
+ * framework sidecar can serve the worker on that runtime.
127
+ */
128
+ readonly devServer: "own" | "workerd";
129
+ /**
130
+ * Whether `lunora deploy` builds and pushes container images itself
131
+ * (railpack, into the host's registry) before `deploy`. `false` when the
132
+ * host CLI builds each image from its Dockerfile during the deploy.
133
+ */
134
+ readonly prebuildsContainerImages: boolean;
135
+ /** The command that writes many secrets in one call, as a JSON object of name to value on stdin. Optional: hosts without it get one `secretPut` per key. */
136
+ secretBulk?: (request: SecretRequest) => ToolchainCommand;
137
+ /** The command that lists remote secret names, when the host has a secret store. */
138
+ secretList?: (request: SecretRequest) => ToolchainCommand;
139
+ /** The command that writes one secret, when the host has a secret store. Its value is passed on stdin, never argv. */
140
+ secretPut?: (request: SecretRequest) => ToolchainCommand;
141
+ /** The command that tails live logs, when the host has one. */
142
+ tail?: (request: TailRequest) => ToolchainCommand;
143
+ }
144
+ /** What a {@link DeployDriver.projectConfig} projection is for — a dev server may need a different source than a deploy. */
145
+ type ProjectionPurpose = "deploy" | "dev";
146
+ /**
147
+ * The result of {@link DeployDriver.projectConfig}: a plan, not yet on disk.
148
+ * The caller validates the request it is for (the toolchain's argv builder
149
+ * refuses unsupported options), then calls `write` — so a refused command
150
+ * changes nothing.
151
+ */
152
+ interface ProjectedConfig {
153
+ /** Where the projection goes, to pass as the request's `configPath`. */
154
+ configPath: string;
155
+ /** Every key removed, as a dotted path (`observability`, `containers[0].rollout_step_percentage`). */
156
+ dropped: ReadonlyArray<string>;
157
+ /** Write the projection (and any build-artifact cleanup it planned). */
158
+ write: () => void;
159
+ }
160
+ /** A deploy target's implementation: an identity the registry resolves, and the host CLI surface (if any) behind it. */
161
+ interface DeployDriver {
162
+ /** The target id this driver serves (`"cloudflare"`, …) — matches codegen's `target`. */
163
+ readonly id: string;
164
+ /** Human-readable target name, for logs. */
165
+ readonly name: string;
166
+ /**
167
+ * Rewrite the project's wrangler config into the form this host's CLI
168
+ * accepts, and return the file to hand `deploy`/`dev` as `configPath`.
169
+ * Absent when the host reads the project's config as-is (Cloudflare).
170
+ *
171
+ * Needed because Lunora's reconcilers and templates write Cloudflare-only
172
+ * keys (`observability`, `limits`, …) that a Workers-compatible host with a
173
+ * strict config reader refuses outright. `dropped` names what was removed,
174
+ * so the caller can say so instead of silently deploying less than the
175
+ * config describes.
176
+ */
177
+ readonly projectConfig?: (projectRoot: string, purpose: ProjectionPurpose) => ProjectedConfig;
178
+ /**
179
+ * The host's command-line surface, or `undefined` for a host that has none.
180
+ * Pure: these build argv, they never spawn.
181
+ */
182
+ readonly toolchain?: DriverToolchain;
183
+ }
184
+ export { DeployDriver as D, ProjectedConfig as P, SecretRequest as S, TailRequest as T, DeployRequest as a, DevRequest as b, DriverToolchain as c, ProjectionPurpose as d, ToolchainCommand as e };
@@ -0,0 +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-DuH_Cmyu.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{rmSync as l,readdirSync as c,writeFileSync as u}from"node:fs";import{join as a}from"node:path";const d=/^\.wrangler\.lunora-(?:dev|service)\.(\d+)\.\d+\.jsonc$/;let s=0;const f=n=>(s+=1,`.wrangler.lunora-${n}.${String(process.pid)}.${String(s)}.jsonc`),g=n=>{try{return process.kill(n,0),!0}catch(r){return r.code==="EPERM"}},p=n=>{let r;try{r=c(n)}catch{return}for(const t of r){const e=d.exec(t);if(!(e===null||Number(e[1])===process.pid||g(Number(e[1]))))try{l(a(n,t),{force:!0})}catch{}}},w=()=>{},m=n=>{let r=!1;return()=>{if(!r){r=!0;try{l(n,{force:!0})}catch{}}}},y=(n,r,t)=>{p(n);const e=a(n,f(r));return u(e,t,"utf8"),{cleanup:m(e),configPath:e}},b=(n,r)=>{const t=n?.ai,e=n?.artifacts,i=(Array.isArray(e)?e:[]).flatMap(o=>typeof o?.binding=="string"?[o.binding]:[]);return t==null&&i.length===0?[]:r()?[]:[...t==null?[]:[{binding:typeof t.binding=="string"?t.binding:"AI",kind:"ai"}],...i.map(o=>({binding:o,kind:"artifacts"}))]},v=({binding:n,kind:r})=>r==="ai"?`Workers AI is off in this dev session (${n} binding left out): no usable Cloudflare login found, and Workers AI only runs remotely. \`@cf/…\` models will throw; AI SDK models and \`LUNORA_AI_PROXY_URL\` slugs still work. Run \`wrangler login\` or set CLOUDFLARE_API_TOKEN to turn it on.`:`Artifacts is off in this dev session (${n} binding left out): no usable Cloudflare login found, and Artifacts only runs remotely. \`ctx.artifacts\` will throw. Run \`wrangler login\` or set CLOUDFLARE_API_TOKEN to turn it on.`;export{d as STALE_DEV_CONFIG,m as createCleanup,v as describeWithheld,f as devConfigBasename,w as noopCleanup,p as sweepStaleDevConfigs,b as withheldBindings,y as writeDevConfig};
@@ -0,0 +1 @@
1
+ import{readProjectDependencyNames as a}from"./readProjectDependencies-l3uhUKjo.mjs";const n=[{class:"A",dependency:"@tanstack/react-start",framework:"tanstack-start"},{class:"A",dependency:"@tanstack/solid-start",framework:"tanstack-start-solid"},{class:"A",dependency:"@react-router/dev",framework:"react-router"},{class:"A",dependency:"vinext",framework:"vinext"},{class:"A",dependency:"@solidjs/start",framework:"solid-start"},{class:"A",dependency:"solid-start",framework:"solid-start"},{class:"B",dependency:"@sveltejs/kit",framework:"sveltekit"},{class:"B",dependency:"nuxt",framework:"nuxt"},{class:"B",dependency:"astro",framework:"astro"}],t={class:"C",framework:"none"},o=e=>a(e).has("lunorash"),d=e=>{const r=a(e);if(r.size===0)return t;for(const s of n)if(r.has(s.dependency))return{class:s.class,framework:s.framework};return t};export{d as detectFramework,o as projectUsesUmbrella};
@@ -0,0 +1 @@
1
+ import{existsSync as m}from"node:fs";import{Project as f}from"ts-morph";import{join as t}from"node:path";const p=(e,o,n,s,i={})=>{if(!m(t(e,o,n??"")))return{};try{const r=new f({skipAddingFilesFromTsConfig:!0,useInMemoryFileSystem:!1,...i});return{value:s(r,t(e,o))}}catch(r){return{error:r instanceof Error?r.message:String(r)}}};export{p as d};
@@ -0,0 +1 @@
1
+ import{discoverAgents as s,AGENTS_FILENAME as n}from"@lunora/codegen";import{d as i}from"./discover-info-DC2MrAIM.mjs";const v=(o,e)=>{const{error:r,value:t}=i(o,e,n,s);return r===void 0?{agents:t??[]}:{agents:[],error:r}};export{v as discoverAgentInfo};
@@ -0,0 +1 @@
1
+ import{discoverContainers as s,CONTAINERS_FILENAME as t}from"@lunora/codegen";import{d}from"./discover-info-DC2MrAIM.mjs";const e=(n,o)=>{const{error:r,value:i}=d(n,o,t,s,{skipFileDependencyResolution:!0});return r===void 0?{containers:i??[]}:{containers:[],error:r}},I=(n,o,r)=>r===void 0?e(n,o):r.memo(`containers:${n}:${o}`,()=>e(n,o));export{I as discoverContainerInfo};
@@ -0,0 +1 @@
1
+ import{existsSync as d}from"node:fs";import{discoverSchema as l,isHyperdriveGlobalTable as f,isD1GlobalTable as b}from"@lunora/codegen";import{Project as u}from"ts-morph";import{join as p}from"node:path";const a=e=>{if(e?.kind==="optional")return a(e.inner);if(e?.kind==="union"){const s=new Set((e.members??[]).filter(i=>i.kind!=="null").map(i=>a(i)));return s.size===1?[...s][0]:e.kind}return e?.kind},m=(e,s)=>{const i=p(e,s,"schema.ts");if(!d(i))return{info:void 0};try{const o=new u({skipAddingFilesFromTsConfig:!0,useInMemoryFileSystem:!1}),r=l(o,i,e),c=n=>r.tables.find(t=>t.name===n)?.shape??{};return{info:{hasD1GlobalTable:r.tables.some(n=>b(n)),hasHyperdriveGlobalTable:r.tables.some(n=>f(n)),...r.jurisdiction===void 0?{}:{jurisdiction:r.jurisdiction},vectorIndexNames:r.vectorIndexes.map(n=>n.name),vectorMetadata:r.vectorIndexes.flatMap(n=>(n.metadata??[]).map(t=>({index:n.name,kind:a(c(n.table)[t]),property:t})))}}}catch(o){return{error:o instanceof Error?o.message:String(o),info:void 0}}},I=(e,s,i)=>i===void 0?m(e,s):i.memo(`schema:${e}:${s}`,()=>m(e,s));export{I as discoverSchemaInfo};
@@ -0,0 +1 @@
1
+ import{discoverWorkflows as f,WORKFLOWS_FILENAME as i}from"@lunora/codegen";import{d as t}from"./discover-info-DC2MrAIM.mjs";const d=(r,s)=>{const{error:o,value:e}=t(r,s,i,f);return o===void 0?{workflows:e??[]}:{error:o,workflows:[]}};export{d as discoverWorkflowInfo};
@@ -0,0 +1 @@
1
+ const n=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),s=t=>typeof t=="string"&&t.length>0;export{s as a,n as i};
@@ -0,0 +1 @@
1
+ import{spawnSync as m}from"node:child_process";import{readFileSync as L,readdirSync as A,existsSync as O}from"node:fs";import{homedir as S}from"node:os";import{join as r,dirname as d}from"node:path";const v=[".env",".env.local",".env.development",".env.development.local"],E=["CLOUDFLARE_API_TOKEN","CF_API_TOKEN"],g=["CLOUDFLARE_API_KEY","CF_API_KEY"],u=["CLOUDFLARE_EMAIL","CF_EMAIL"],w=new Set([...E,...g,...u]),p=/^export\s+/u,D=/\r?\n/u,I=/"loggedIn"\s*:\s*false/u,T=/"loggedIn"\s*:\s*true/u,C=1e4,f=new Map,h=/^(["'])(.*)\1$/u,a=t=>t!==void 0&&t.trim()!=="",F=(t,e)=>[e,t.XDG_CONFIG_HOME,r(e,"Library","Preferences"),r(e,".config"),t.APPDATA===void 0?void 0:r(t.APPDATA,"xdg.config"),r(e,"AppData","Roaming","xdg.config")].filter(o=>a(o)),K=t=>{try{return A(t).length>0}catch{return!1}},P=t=>{for(let e=t;;e=d(e)){const o=r(e,"node_modules","wrangler","bin","wrangler.js");if(O(o))return o;if(d(e)===e)return}},R=(t,e)=>{const o=f.get(t);if(o!==void 0&&(!o.loggedOut||Date.now()-o.at<C))return o.loggedOut;const s=P(t);if(s===void 0)return!1;const{stdout:i}=m(process.execPath,[s,"whoami","--json"],{cwd:t,encoding:"utf8",env:{...e,WRANGLER_SEND_METRICS:"false"},stdio:["ignore","pipe","ignore"],timeout:1e4}),n=I.test(i);return(n||T.test(i))&&f.set(t,{at:Date.now(),loggedOut:n}),n},y=t=>{const e=new Set;for(const o of v){let s;try{s=L(r(t,o),"utf8")}catch{continue}for(const i of s.split(D)){const n=i.trim().replace(p,""),c=n.indexOf("=");if(n.startsWith("#")||c===-1)continue;const l=n.slice(0,c).trim(),_=n.slice(c+1).trim().replace(h,"$2");w.has(l)&&a(_)&&e.add(l)}}return e},U=(t={})=>{const e=t.env??process.env,o=t.projectRoot===void 0?new Set:y(t.projectRoot),s=n=>a(e[n])||o.has(n);return E.some(n=>s(n))||g.some(n=>s(n))&&u.some(n=>s(n))?!0:F(e,t.home??S()).some(n=>K(r(n,".wrangler","config")))&&(t.projectRoot===void 0||!R(t.projectRoot,e))};export{U as hasCloudflareCredentials};