anhedral 0.16.0 → 0.18.0

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 (195) hide show
  1. package/README.md +42 -20
  2. package/assets/contracts/LICENSE +201 -0
  3. package/assets/contracts/LICENSE.environment +201 -0
  4. package/assets/contracts/LICENSE.operations +201 -0
  5. package/assets/contracts/deployment-provenance.json +15 -0
  6. package/assets/contracts/environment-provenance.json +11 -0
  7. package/assets/contracts/operations-provenance.json +11 -0
  8. package/assets/launch/application.server.ts.txt +13 -0
  9. package/assets/launch/auth-client.ts.txt +4 -0
  10. package/assets/launch/home.tsx.txt +20 -0
  11. package/assets/launch/minimal-application.server.ts.txt +5 -0
  12. package/assets/launch/minimal-server.ts.txt +7 -0
  13. package/assets/launch/request-context.ts.txt +3 -0
  14. package/assets/launch/root.tsx.txt +27 -0
  15. package/assets/launch/router.tsx.txt +21 -0
  16. package/assets/launch/server.ts.txt +13 -0
  17. package/assets/launch/sign-in.tsx.txt +53 -0
  18. package/assets/launch/styles.css.txt +19 -0
  19. package/assets/security/credential-patterns.d.mts +3 -0
  20. package/assets/security/credential-patterns.mjs +59 -0
  21. package/assets/stack/api-index.ts.txt +6 -1
  22. package/assets/stack/event-retention.sql.txt +10 -0
  23. package/assets/stack/stripe.ts.txt +30 -13
  24. package/assets/ui/UPSTREAM.json +1 -18
  25. package/dist/bin.js +55 -36
  26. package/dist/capabilities.d.ts +1 -1
  27. package/dist/capability-catalog.d.ts +44 -11
  28. package/dist/capability-catalog.js +96 -11
  29. package/dist/capability-command.d.ts +2 -2
  30. package/dist/capability-command.js +178 -27
  31. package/dist/capability-editor.js +6 -5
  32. package/dist/capability-recipes.js +54 -6
  33. package/dist/cli-arguments.d.ts +2 -0
  34. package/dist/cli-arguments.js +101 -50
  35. package/dist/cli-commands.d.ts +1 -1
  36. package/dist/cli-commands.js +30 -6
  37. package/dist/cli-errors.d.ts +18 -0
  38. package/dist/cli-errors.js +63 -0
  39. package/dist/cli-output.d.ts +22 -0
  40. package/dist/cli-output.js +42 -7
  41. package/dist/command-runner.d.ts +1 -0
  42. package/dist/command-runner.js +88 -0
  43. package/dist/command-schema.d.ts +16 -0
  44. package/dist/command-schema.js +390 -21
  45. package/dist/completion.d.ts +2 -0
  46. package/dist/completion.js +201 -0
  47. package/dist/composition.d.ts +35 -0
  48. package/dist/composition.js +28 -0
  49. package/dist/contracts/cli-transport.d.ts +217 -0
  50. package/dist/contracts/cli-transport.js +167 -0
  51. package/dist/contracts/deployment.d.ts +282 -0
  52. package/dist/contracts/deployment.js +234 -0
  53. package/dist/contracts/environment-file.d.ts +7 -0
  54. package/dist/contracts/environment-file.js +112 -0
  55. package/dist/contracts/environment-transport.d.ts +79 -0
  56. package/dist/contracts/environment-transport.js +110 -0
  57. package/dist/contracts/runtime-logs-transport.d.ts +127 -0
  58. package/dist/contracts/runtime-logs-transport.js +50 -0
  59. package/dist/contracts/source-bundle.d.ts +11 -0
  60. package/dist/contracts/source-bundle.js +197 -0
  61. package/dist/contracts/source-profile.d.ts +4 -0
  62. package/dist/contracts/source-profile.js +5 -0
  63. package/dist/contracts/staging-transport.d.ts +79 -0
  64. package/dist/contracts/staging-transport.js +43 -0
  65. package/dist/dependencies.d.ts +10 -4
  66. package/dist/dependencies.js +17 -54
  67. package/dist/index.d.ts +6 -0
  68. package/dist/index.js +4 -0
  69. package/dist/launch.d.ts +21 -0
  70. package/dist/launch.js +250 -0
  71. package/dist/platform-command.d.ts +9 -0
  72. package/dist/platform-command.js +584 -0
  73. package/dist/platform-environment.d.ts +18 -0
  74. package/dist/platform-environment.js +257 -0
  75. package/dist/platform-operations.d.ts +26 -0
  76. package/dist/platform-operations.js +155 -0
  77. package/dist/platform-source.d.ts +8 -0
  78. package/dist/platform-source.js +111 -0
  79. package/dist/platform-state.d.ts +13 -0
  80. package/dist/platform-state.js +207 -0
  81. package/dist/platforms/tanstack.d.ts +8 -0
  82. package/dist/platforms/tanstack.js +155 -0
  83. package/dist/registry/options.js +34 -31
  84. package/dist/registry/resolve.js +2 -0
  85. package/dist/registry/usage.d.ts +4 -1
  86. package/dist/registry/usage.js +58 -4
  87. package/dist/scaffold/documentation.js +17 -48
  88. package/dist/scaffold/styling.d.ts +1 -1
  89. package/dist/scaffold/workspace.js +11 -7
  90. package/dist/stack-registry.d.ts +2 -4
  91. package/dist/stack-registry.js +1 -11
  92. package/dist/standard.js +21 -6
  93. package/dist/transaction.js +28 -3
  94. package/dist/ui-command.d.ts +4 -2
  95. package/dist/ui-command.js +79 -38
  96. package/dist/ui-project.d.ts +2 -0
  97. package/dist/ui-project.js +38 -8
  98. package/dist/util.js +40 -61
  99. package/dist/version.d.ts +1 -1
  100. package/dist/version.js +1 -1
  101. package/docs/capabilities.md +22 -88
  102. package/docs/software-factory.md +189 -16
  103. package/docs/stack-standard.md +6 -18
  104. package/docs/ui.md +9 -22
  105. package/docs/verification.md +6 -1067
  106. package/package.json +33 -22
  107. package/assets/ui/native/_controls.tsx +0 -521
  108. package/assets/ui/native/_core.tsx +0 -118
  109. package/assets/ui/native/_data.tsx +0 -200
  110. package/assets/ui/native/_display.tsx +0 -453
  111. package/assets/ui/native/_feedback.tsx +0 -242
  112. package/assets/ui/native/_legacy-dialog.tsx +0 -38
  113. package/assets/ui/native/_motion.tsx +0 -520
  114. package/assets/ui/native/_overlay.tsx +0 -402
  115. package/assets/ui/native/_selection.tsx +0 -366
  116. package/assets/ui/native/accordion.tsx +0 -1
  117. package/assets/ui/native/alert-dialog.tsx +0 -11
  118. package/assets/ui/native/alert.tsx +0 -1
  119. package/assets/ui/native/aspect-ratio.tsx +0 -1
  120. package/assets/ui/native/attachment.tsx +0 -8
  121. package/assets/ui/native/avatar.tsx +0 -8
  122. package/assets/ui/native/badge.tsx +0 -1
  123. package/assets/ui/native/breadcrumb.tsx +0 -9
  124. package/assets/ui/native/bubble.tsx +0 -1
  125. package/assets/ui/native/button-group.tsx +0 -1
  126. package/assets/ui/native/button.tsx +0 -86
  127. package/assets/ui/native/calendar.tsx +0 -170
  128. package/assets/ui/native/card.tsx +0 -44
  129. package/assets/ui/native/carousel.tsx +0 -1
  130. package/assets/ui/native/chart.tsx +0 -193
  131. package/assets/ui/native/checkbox.tsx +0 -1
  132. package/assets/ui/native/code-block.tsx +0 -137
  133. package/assets/ui/native/collapsible.tsx +0 -1
  134. package/assets/ui/native/combobox.tsx +0 -1
  135. package/assets/ui/native/command.tsx +0 -11
  136. package/assets/ui/native/context-menu.tsx +0 -16
  137. package/assets/ui/native/data-table.tsx +0 -1
  138. package/assets/ui/native/date-picker.tsx +0 -43
  139. package/assets/ui/native/dialog.tsx +0 -15
  140. package/assets/ui/native/direction.tsx +0 -1
  141. package/assets/ui/native/drawer.tsx +0 -10
  142. package/assets/ui/native/dropdown-menu.tsx +0 -16
  143. package/assets/ui/native/empty.tsx +0 -8
  144. package/assets/ui/native/field.tsx +0 -13
  145. package/assets/ui/native/hover-card.tsx +0 -1
  146. package/assets/ui/native/input-group.tsx +0 -8
  147. package/assets/ui/native/input-otp.tsx +0 -1
  148. package/assets/ui/native/input.tsx +0 -28
  149. package/assets/ui/native/item.tsx +0 -12
  150. package/assets/ui/native/kbd.tsx +0 -1
  151. package/assets/ui/native/label.tsx +0 -4
  152. package/assets/ui/native/layout.tsx +0 -26
  153. package/assets/ui/native/marker.tsx +0 -1
  154. package/assets/ui/native/menubar.tsx +0 -17
  155. package/assets/ui/native/message-scroller.tsx +0 -6
  156. package/assets/ui/native/message.tsx +0 -10
  157. package/assets/ui/native/native-select.tsx +0 -1
  158. package/assets/ui/native/navigation-menu.tsx +0 -10
  159. package/assets/ui/native/pagination.tsx +0 -9
  160. package/assets/ui/native/popover.tsx +0 -1
  161. package/assets/ui/native/progress.tsx +0 -1
  162. package/assets/ui/native/questionnaire.tsx +0 -130
  163. package/assets/ui/native/radio-group.tsx +0 -1
  164. package/assets/ui/native/registry.json +0 -1103
  165. package/assets/ui/native/resizable.tsx +0 -1
  166. package/assets/ui/native/scroll-area.tsx +0 -1
  167. package/assets/ui/native/select.tsx +0 -11
  168. package/assets/ui/native/separator.tsx +0 -1
  169. package/assets/ui/native/sheet.tsx +0 -10
  170. package/assets/ui/native/sidebar.tsx +0 -22
  171. package/assets/ui/native/skeleton.tsx +0 -1
  172. package/assets/ui/native/slider.tsx +0 -1
  173. package/assets/ui/native/spinner.tsx +0 -1
  174. package/assets/ui/native/switch.tsx +0 -1
  175. package/assets/ui/native/table.tsx +0 -10
  176. package/assets/ui/native/tabs.tsx +0 -1
  177. package/assets/ui/native/text.tsx +0 -20
  178. package/assets/ui/native/textarea.tsx +0 -1
  179. package/assets/ui/native/theme-switcher.tsx +0 -22
  180. package/assets/ui/native/toast.tsx +0 -11
  181. package/assets/ui/native/toggle-group.tsx +0 -1
  182. package/assets/ui/native/toggle.tsx +0 -1
  183. package/assets/ui/native/tooltip.tsx +0 -1
  184. package/assets/ui/native/trace.tsx +0 -20
  185. package/assets/ui/native/typography.tsx +0 -15
  186. package/assets/ui/theme-storage.ts +0 -25
  187. package/assets/ui/theme.tsx +0 -66
  188. package/dist/platforms/mobile.d.ts +0 -2
  189. package/dist/platforms/mobile.js +0 -137
  190. package/dist/scaffold/expo-runtime.d.ts +0 -3
  191. package/dist/scaffold/expo-runtime.js +0 -42
  192. package/dist/scaffold/native-ui.d.ts +0 -2
  193. package/dist/scaffold/native-ui.js +0 -74
  194. package/docs/anhedral-stack.md +0 -7
  195. package/docs/native-ui.md +0 -102
@@ -0,0 +1,282 @@
1
+ import { z } from "zod";
2
+ /** Portable transport contract. No database, framework or provider imports. */
3
+ export declare const deploymentContractVersion = 1;
4
+ export declare const deploymentDigestSchema: z.ZodString;
5
+ export declare const applicationIdentitySchema: z.ZodEnum<{
6
+ none: "none";
7
+ "better-auth-d1-v1": "better-auth-d1-v1";
8
+ "platform-application-services-v1": "platform-application-services-v1";
9
+ }>;
10
+ export declare const deploymentCapabilitySchema: z.ZodEnum<{
11
+ hono: "hono";
12
+ "database-auth": "database-auth";
13
+ r2: "r2";
14
+ stripe: "stripe";
15
+ realtime: "realtime";
16
+ rtc: "rtc";
17
+ ai: "ai";
18
+ expo: "expo";
19
+ "native-ui": "native-ui";
20
+ revenuecat: "revenuecat";
21
+ wxt: "wxt";
22
+ "side-panel": "side-panel";
23
+ gpui: "gpui";
24
+ }>;
25
+ export declare const cliArtifactSchema: z.ZodObject<{
26
+ version: z.ZodString;
27
+ sourceRevision: z.ZodString;
28
+ packageIntegrity: z.ZodString;
29
+ }, z.core.$strict>;
30
+ export declare const deploymentIntentSchema: z.ZodObject<{
31
+ contractVersion: z.ZodLiteral<1>;
32
+ runtimeProfile: z.ZodString;
33
+ environment: z.ZodEnum<{
34
+ production: "production";
35
+ preview: "preview";
36
+ }>;
37
+ visibility: z.ZodEnum<{
38
+ protected: "protected";
39
+ public: "public";
40
+ }>;
41
+ }, z.core.$strict>;
42
+ /** Source provenance only. Null versions preserve unknown legacy origins honestly. */
43
+ export declare const sourceCompositionSchema: z.ZodObject<{
44
+ contractVersion: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>]>;
45
+ foundation: z.ZodEnum<{
46
+ "next-opennext": "next-opennext";
47
+ "tanstack-start": "tanstack-start";
48
+ }>;
49
+ generatorVersion: z.ZodNullable<z.ZodString>;
50
+ identity: z.ZodEnum<{
51
+ none: "none";
52
+ "better-auth-d1-v1": "better-auth-d1-v1";
53
+ "platform-application-services-v1": "platform-application-services-v1";
54
+ }>;
55
+ capabilities: z.ZodRecord<z.ZodEnum<{
56
+ hono: "hono";
57
+ "database-auth": "database-auth";
58
+ r2: "r2";
59
+ stripe: "stripe";
60
+ realtime: "realtime";
61
+ rtc: "rtc";
62
+ ai: "ai";
63
+ expo: "expo";
64
+ "native-ui": "native-ui";
65
+ revenuecat: "revenuecat";
66
+ wxt: "wxt";
67
+ "side-panel": "side-panel";
68
+ gpui: "gpui";
69
+ }> & z.core.$partial, z.ZodNullable<z.ZodString>>;
70
+ }, z.core.$strict>;
71
+ export declare const deploymentManifestSchema: z.ZodObject<{
72
+ contractVersion: z.ZodLiteral<1>;
73
+ foundation: z.ZodEnum<{
74
+ "next-opennext": "next-opennext";
75
+ "tanstack-start": "tanstack-start";
76
+ }>;
77
+ capabilities: z.ZodArray<z.ZodEnum<{
78
+ hono: "hono";
79
+ "database-auth": "database-auth";
80
+ r2: "r2";
81
+ stripe: "stripe";
82
+ realtime: "realtime";
83
+ rtc: "rtc";
84
+ ai: "ai";
85
+ expo: "expo";
86
+ "native-ui": "native-ui";
87
+ revenuecat: "revenuecat";
88
+ wxt: "wxt";
89
+ "side-panel": "side-panel";
90
+ gpui: "gpui";
91
+ }>>;
92
+ identity: z.ZodEnum<{
93
+ none: "none";
94
+ "better-auth-d1-v1": "better-auth-d1-v1";
95
+ "platform-application-services-v1": "platform-application-services-v1";
96
+ }>;
97
+ cliArtifact: z.ZodObject<{
98
+ version: z.ZodString;
99
+ sourceRevision: z.ZodString;
100
+ packageIntegrity: z.ZodString;
101
+ }, z.core.$strict>;
102
+ intent: z.ZodObject<{
103
+ contractVersion: z.ZodLiteral<1>;
104
+ runtimeProfile: z.ZodString;
105
+ environment: z.ZodEnum<{
106
+ production: "production";
107
+ preview: "preview";
108
+ }>;
109
+ visibility: z.ZodEnum<{
110
+ protected: "protected";
111
+ public: "public";
112
+ }>;
113
+ }, z.core.$strict>;
114
+ }, z.core.$strict>;
115
+ export declare const deploymentSourceSchema: z.ZodObject<{
116
+ inventoryVersion: z.ZodLiteral<2>;
117
+ inventoryProfile: z.ZodString;
118
+ sourceDigest: z.ZodString;
119
+ lockfileDigest: z.ZodString;
120
+ manifestDigest: z.ZodString;
121
+ }, z.core.$strict>;
122
+ export declare const deploymentPlanSchema: z.ZodObject<{
123
+ contractVersion: z.ZodLiteral<1>;
124
+ requestId: z.ZodUUID;
125
+ projectId: z.ZodUUID;
126
+ manifest: z.ZodObject<{
127
+ contractVersion: z.ZodLiteral<1>;
128
+ foundation: z.ZodEnum<{
129
+ "next-opennext": "next-opennext";
130
+ "tanstack-start": "tanstack-start";
131
+ }>;
132
+ capabilities: z.ZodArray<z.ZodEnum<{
133
+ hono: "hono";
134
+ "database-auth": "database-auth";
135
+ r2: "r2";
136
+ stripe: "stripe";
137
+ realtime: "realtime";
138
+ rtc: "rtc";
139
+ ai: "ai";
140
+ expo: "expo";
141
+ "native-ui": "native-ui";
142
+ revenuecat: "revenuecat";
143
+ wxt: "wxt";
144
+ "side-panel": "side-panel";
145
+ gpui: "gpui";
146
+ }>>;
147
+ identity: z.ZodEnum<{
148
+ none: "none";
149
+ "better-auth-d1-v1": "better-auth-d1-v1";
150
+ "platform-application-services-v1": "platform-application-services-v1";
151
+ }>;
152
+ cliArtifact: z.ZodObject<{
153
+ version: z.ZodString;
154
+ sourceRevision: z.ZodString;
155
+ packageIntegrity: z.ZodString;
156
+ }, z.core.$strict>;
157
+ intent: z.ZodObject<{
158
+ contractVersion: z.ZodLiteral<1>;
159
+ runtimeProfile: z.ZodString;
160
+ environment: z.ZodEnum<{
161
+ production: "production";
162
+ preview: "preview";
163
+ }>;
164
+ visibility: z.ZodEnum<{
165
+ protected: "protected";
166
+ public: "public";
167
+ }>;
168
+ }, z.core.$strict>;
169
+ }, z.core.$strict>;
170
+ source: z.ZodObject<{
171
+ inventoryVersion: z.ZodLiteral<2>;
172
+ inventoryProfile: z.ZodString;
173
+ sourceDigest: z.ZodString;
174
+ lockfileDigest: z.ZodString;
175
+ manifestDigest: z.ZodString;
176
+ }, z.core.$strict>;
177
+ policyDigest: z.ZodString;
178
+ runtimeImage: z.ZodString;
179
+ configurationRevision: z.ZodString;
180
+ expectedGeneration: z.ZodNumber;
181
+ migrationDigests: z.ZodArray<z.ZodString>;
182
+ requiredAuthority: z.ZodEnum<{
183
+ preview: "preview";
184
+ "production-approval": "production-approval";
185
+ }>;
186
+ }, z.core.$strict>;
187
+ export declare const deploymentErrorSchema: z.ZodObject<{
188
+ code: z.ZodEnum<{
189
+ INVALID_MANIFEST: "INVALID_MANIFEST";
190
+ UNSUPPORTED_PROFILE: "UNSUPPORTED_PROFILE";
191
+ UNREVIEWED_ARTIFACT: "UNREVIEWED_ARTIFACT";
192
+ IDENTITY_ADAPTER_REQUIRED: "IDENTITY_ADAPTER_REQUIRED";
193
+ UNSUPPORTED_CAPABILITY: "UNSUPPORTED_CAPABILITY";
194
+ STALE_PLAN: "STALE_PLAN";
195
+ AUTHORITY_REQUIRED: "AUTHORITY_REQUIRED";
196
+ OPERATION_PENDING: "OPERATION_PENDING";
197
+ DEPLOYMENT_FAILED: "DEPLOYMENT_FAILED";
198
+ }>;
199
+ message: z.ZodString;
200
+ recovery: z.ZodString;
201
+ stateChanged: z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"unknown">]>;
202
+ operationId: z.ZodNullable<z.ZodUUID>;
203
+ }, z.core.$strict>;
204
+ export declare const deploymentEventSchema: z.ZodObject<{
205
+ sequence: z.ZodNumber;
206
+ state: z.ZodEnum<{
207
+ queued: "queued";
208
+ preparing: "preparing";
209
+ ready: "ready";
210
+ failed: "failed";
211
+ uploading: "uploading";
212
+ building: "building";
213
+ verifying: "verifying";
214
+ "awaiting-approval": "awaiting-approval";
215
+ cancelled: "cancelled";
216
+ }>;
217
+ occurredAt: z.ZodISODateTime;
218
+ contractVersion: z.ZodLiteral<1>;
219
+ operationId: z.ZodUUID;
220
+ requestId: z.ZodUUID;
221
+ }, z.core.$strict>;
222
+ export declare const deploymentResultSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
223
+ status: z.ZodLiteral<"pending">;
224
+ state: z.ZodEnum<{
225
+ queued: "queued";
226
+ preparing: "preparing";
227
+ uploading: "uploading";
228
+ building: "building";
229
+ verifying: "verifying";
230
+ "awaiting-approval": "awaiting-approval";
231
+ }>;
232
+ contractVersion: z.ZodLiteral<1>;
233
+ operationId: z.ZodUUID;
234
+ requestId: z.ZodUUID;
235
+ }, z.core.$strict>, z.ZodObject<{
236
+ status: z.ZodLiteral<"ready">;
237
+ candidateId: z.ZodUUID;
238
+ sourceDigest: z.ZodString;
239
+ artifactDigest: z.ZodString;
240
+ configurationRevision: z.ZodString;
241
+ url: z.ZodURL;
242
+ contractVersion: z.ZodLiteral<1>;
243
+ operationId: z.ZodUUID;
244
+ requestId: z.ZodUUID;
245
+ }, z.core.$strict>, z.ZodObject<{
246
+ status: z.ZodLiteral<"failed">;
247
+ error: z.ZodObject<{
248
+ code: z.ZodEnum<{
249
+ INVALID_MANIFEST: "INVALID_MANIFEST";
250
+ UNSUPPORTED_PROFILE: "UNSUPPORTED_PROFILE";
251
+ UNREVIEWED_ARTIFACT: "UNREVIEWED_ARTIFACT";
252
+ IDENTITY_ADAPTER_REQUIRED: "IDENTITY_ADAPTER_REQUIRED";
253
+ UNSUPPORTED_CAPABILITY: "UNSUPPORTED_CAPABILITY";
254
+ STALE_PLAN: "STALE_PLAN";
255
+ AUTHORITY_REQUIRED: "AUTHORITY_REQUIRED";
256
+ OPERATION_PENDING: "OPERATION_PENDING";
257
+ DEPLOYMENT_FAILED: "DEPLOYMENT_FAILED";
258
+ }>;
259
+ message: z.ZodString;
260
+ recovery: z.ZodString;
261
+ stateChanged: z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"unknown">]>;
262
+ operationId: z.ZodNullable<z.ZodUUID>;
263
+ }, z.core.$strict>;
264
+ contractVersion: z.ZodLiteral<1>;
265
+ operationId: z.ZodUUID;
266
+ requestId: z.ZodUUID;
267
+ }, z.core.$strict>, z.ZodObject<{
268
+ status: z.ZodLiteral<"cancelled">;
269
+ resourcesRetained: z.ZodBoolean;
270
+ contractVersion: z.ZodLiteral<1>;
271
+ operationId: z.ZodUUID;
272
+ requestId: z.ZodUUID;
273
+ }, z.core.$strict>], "status">;
274
+ export type DeploymentManifest = z.infer<typeof deploymentManifestSchema>;
275
+ export type DeploymentPlan = z.infer<typeof deploymentPlanSchema>;
276
+ export type DeploymentSource = z.infer<typeof deploymentSourceSchema>;
277
+ export type DeploymentIntent = z.infer<typeof deploymentIntentSchema>;
278
+ export type DeploymentEvent = z.infer<typeof deploymentEventSchema>;
279
+ export type DeploymentResult = z.infer<typeof deploymentResultSchema>;
280
+ export type DeploymentError = z.infer<typeof deploymentErrorSchema>;
281
+ export type SourceComposition = z.infer<typeof sourceCompositionSchema>;
282
+ export type CliArtifact = z.infer<typeof cliArtifactSchema>;
@@ -0,0 +1,234 @@
1
+ import { z } from "zod";
2
+ /** Portable transport contract. No database, framework or provider imports. */
3
+ export const deploymentContractVersion = 1;
4
+ export const deploymentDigestSchema = z.string().regex(/^[a-f0-9]{64}$/);
5
+ const revisionSchema = z.string().regex(/^[a-f0-9]{40}$/);
6
+ const versionSchema = z.string().regex(/^\d+\.\d+\.\d+(?:-[a-zA-Z0-9.-]+)?$/);
7
+ export const applicationIdentitySchema = z.enum([
8
+ "none",
9
+ "better-auth-d1-v1",
10
+ "platform-application-services-v1",
11
+ ]);
12
+ export const deploymentCapabilitySchema = z.enum([
13
+ "hono",
14
+ "database-auth",
15
+ "r2",
16
+ "stripe",
17
+ "realtime",
18
+ "rtc",
19
+ "ai",
20
+ "expo",
21
+ "native-ui",
22
+ "revenuecat",
23
+ "wxt",
24
+ "side-panel",
25
+ "gpui",
26
+ ]);
27
+ const capabilitiesSchema = z
28
+ .array(deploymentCapabilitySchema)
29
+ .max(13)
30
+ .refine((items) => new Set(items).size === items.length, "Duplicate capabilities.");
31
+ export const cliArtifactSchema = z
32
+ .object({
33
+ version: versionSchema,
34
+ sourceRevision: revisionSchema,
35
+ packageIntegrity: z.string().regex(/^sha512-[A-Za-z0-9+/]{86}==$/),
36
+ })
37
+ .strict();
38
+ export const deploymentIntentSchema = z
39
+ .object({
40
+ contractVersion: z.literal(1),
41
+ runtimeProfile: z.string().regex(/^[a-z][a-z0-9-]{0,63}$/),
42
+ environment: z.enum(["preview", "production"]),
43
+ visibility: z.enum(["protected", "public"]),
44
+ })
45
+ .strict();
46
+ /** Source provenance only. Null versions preserve unknown legacy origins honestly. */
47
+ export const sourceCompositionSchema = z
48
+ .object({
49
+ contractVersion: z.union([z.literal(1), z.literal(2)]),
50
+ foundation: z.enum(["next-opennext", "tanstack-start"]),
51
+ generatorVersion: versionSchema.nullable(),
52
+ identity: applicationIdentitySchema,
53
+ capabilities: z.partialRecord(deploymentCapabilitySchema, versionSchema.nullable()),
54
+ })
55
+ .strict()
56
+ .superRefine((value, ctx) => {
57
+ if ((value.contractVersion === 1) !== (value.foundation === "next-opennext"))
58
+ ctx.addIssue({
59
+ code: "custom",
60
+ path: ["foundation"],
61
+ message: "Source composition version must match its foundation.",
62
+ });
63
+ });
64
+ export const deploymentManifestSchema = z
65
+ .object({
66
+ contractVersion: z.literal(1),
67
+ foundation: z.enum(["next-opennext", "tanstack-start"]),
68
+ capabilities: capabilitiesSchema,
69
+ identity: applicationIdentitySchema,
70
+ cliArtifact: cliArtifactSchema,
71
+ intent: deploymentIntentSchema,
72
+ })
73
+ .strict()
74
+ .superRefine((value, ctx) => {
75
+ const selected = new Set(value.capabilities);
76
+ const tanstack = value.foundation === "tanstack-start";
77
+ if (tanstack !==
78
+ ["anhedral-stack", "progressive-tanstack-v1"].includes(value.intent.runtimeProfile))
79
+ ctx.addIssue({
80
+ code: "custom",
81
+ path: ["intent", "runtimeProfile"],
82
+ message: "Anhedral Stack source requires the anhedral-stack runtime profile.",
83
+ });
84
+ if (tanstack) {
85
+ for (const id of value.capabilities)
86
+ if (!["hono", "database-auth", "r2", "stripe"].includes(id))
87
+ ctx.addIssue({
88
+ code: "custom",
89
+ path: ["capabilities"],
90
+ message: `${id} is outside the Anhedral Stack hosting contract.`,
91
+ });
92
+ if (selected.has("hono") !== selected.has("database-auth"))
93
+ ctx.addIssue({
94
+ code: "custom",
95
+ path: ["capabilities"],
96
+ message: "Anhedral Stack hosting requires Hono and database-auth together.",
97
+ });
98
+ if (value.identity !== (selected.has("database-auth") ? "better-auth-d1-v1" : "none"))
99
+ ctx.addIssue({
100
+ code: "custom",
101
+ path: ["identity"],
102
+ message: "Anhedral Stack hosting preserves standalone Better Auth/D1 identity.",
103
+ });
104
+ }
105
+ const prerequisites = {
106
+ "database-auth": ["hono"],
107
+ r2: ["database-auth"],
108
+ stripe: ["database-auth"],
109
+ realtime: ["database-auth"],
110
+ rtc: ["database-auth"],
111
+ ai: ["database-auth"],
112
+ expo: ["database-auth"],
113
+ "native-ui": ["expo"],
114
+ revenuecat: ["expo", "stripe"],
115
+ wxt: ["database-auth"],
116
+ "side-panel": ["wxt"],
117
+ gpui: ["database-auth"],
118
+ };
119
+ for (const id of value.capabilities)
120
+ for (const parent of prerequisites[id] ?? [])
121
+ if (!selected.has(parent))
122
+ ctx.addIssue({
123
+ code: "custom",
124
+ path: ["capabilities"],
125
+ message: `${id} requires ${parent}.`,
126
+ });
127
+ if (selected.has("database-auth") !== (value.identity !== "none"))
128
+ ctx.addIssue({
129
+ code: "custom",
130
+ path: ["identity"],
131
+ message: "Identity must match database-auth source.",
132
+ });
133
+ });
134
+ export const deploymentSourceSchema = z
135
+ .object({
136
+ inventoryVersion: z.literal(2),
137
+ inventoryProfile: z.string().min(1).max(100),
138
+ sourceDigest: deploymentDigestSchema,
139
+ lockfileDigest: deploymentDigestSchema,
140
+ manifestDigest: deploymentDigestSchema,
141
+ })
142
+ .strict();
143
+ const runtimeImageSchema = z
144
+ .string()
145
+ .regex(/^registry\.[a-z0-9.-]+\/[a-zA-Z0-9/_.-]+@sha256:[a-f0-9]{64}$/);
146
+ export const deploymentPlanSchema = z
147
+ .object({
148
+ contractVersion: z.literal(1),
149
+ requestId: z.uuid(),
150
+ projectId: z.uuid(),
151
+ manifest: deploymentManifestSchema,
152
+ source: deploymentSourceSchema,
153
+ policyDigest: deploymentDigestSchema,
154
+ runtimeImage: runtimeImageSchema,
155
+ configurationRevision: deploymentDigestSchema,
156
+ expectedGeneration: z.number().int().nonnegative(),
157
+ migrationDigests: z.array(deploymentDigestSchema).max(100),
158
+ requiredAuthority: z.enum(["preview", "production-approval"]),
159
+ })
160
+ .strict()
161
+ .refine((plan) => plan.requiredAuthority ===
162
+ (plan.manifest.intent.environment === "production" ? "production-approval" : "preview"), "Production requires exact-candidate approval.");
163
+ export const deploymentErrorSchema = z
164
+ .object({
165
+ code: z.enum([
166
+ "INVALID_MANIFEST",
167
+ "UNSUPPORTED_PROFILE",
168
+ "UNREVIEWED_ARTIFACT",
169
+ "IDENTITY_ADAPTER_REQUIRED",
170
+ "UNSUPPORTED_CAPABILITY",
171
+ "STALE_PLAN",
172
+ "AUTHORITY_REQUIRED",
173
+ "OPERATION_PENDING",
174
+ "DEPLOYMENT_FAILED",
175
+ ]),
176
+ message: z.string().min(1).max(2000),
177
+ recovery: z.string().min(1).max(2000),
178
+ stateChanged: z.union([z.boolean(), z.literal("unknown")]),
179
+ operationId: z.uuid().nullable(),
180
+ })
181
+ .strict();
182
+ const operationStateSchema = z.enum([
183
+ "queued",
184
+ "uploading",
185
+ "building",
186
+ "preparing",
187
+ "verifying",
188
+ "awaiting-approval",
189
+ "ready",
190
+ "failed",
191
+ "cancelled",
192
+ ]);
193
+ const operationFields = {
194
+ contractVersion: z.literal(1),
195
+ operationId: z.uuid(),
196
+ requestId: z.uuid(),
197
+ };
198
+ export const deploymentEventSchema = z
199
+ .object({
200
+ ...operationFields,
201
+ sequence: z.number().int().nonnegative(),
202
+ state: operationStateSchema,
203
+ occurredAt: z.iso.datetime(),
204
+ })
205
+ .strict();
206
+ export const deploymentResultSchema = z.discriminatedUnion("status", [
207
+ z
208
+ .object({
209
+ ...operationFields,
210
+ status: z.literal("pending"),
211
+ state: operationStateSchema.exclude(["ready", "failed", "cancelled"]),
212
+ })
213
+ .strict(),
214
+ z
215
+ .object({
216
+ ...operationFields,
217
+ status: z.literal("ready"),
218
+ candidateId: z.uuid(),
219
+ sourceDigest: deploymentDigestSchema,
220
+ artifactDigest: deploymentDigestSchema,
221
+ configurationRevision: deploymentDigestSchema,
222
+ url: z.url().refine((value) => {
223
+ const url = new URL(value);
224
+ return url.protocol === "https:" && url.origin === value && !url.username && !url.password;
225
+ }),
226
+ })
227
+ .strict(),
228
+ z
229
+ .object({ ...operationFields, status: z.literal("failed"), error: deploymentErrorSchema })
230
+ .strict(),
231
+ z
232
+ .object({ ...operationFields, status: z.literal("cancelled"), resourcesRetained: z.boolean() })
233
+ .strict(),
234
+ ]);
@@ -0,0 +1,7 @@
1
+ /** Literal dotenv parsing only. Never evaluate a shell, interpolate variables,
2
+ * or include input values in errors. The same parser serves browser and CLI. */
3
+ export declare function parseEnvironmentFile(input: string): {
4
+ name: string;
5
+ value: string;
6
+ }[];
7
+ export declare function inferredEnvironmentKind(name: string): "config" | "secret";
@@ -0,0 +1,112 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ import { environmentNameSchema } from "./environment-transport.js";
3
+ /** Literal dotenv parsing only. Never evaluate a shell, interpolate variables,
4
+ * or include input values in errors. The same parser serves browser and CLI. */
5
+ export function parseEnvironmentFile(input) {
6
+ if (input.includes("\0"))
7
+ throw new Error("Environment files cannot contain NUL bytes.");
8
+ if (new TextEncoder().encode(input).length > 65536)
9
+ throw new Error("Environment files support at most 64 KiB.");
10
+ const text = input.replace(/^\uFEFF/, "").replaceAll("\r\n", "\n");
11
+ const entries = [];
12
+ const names = new Set();
13
+ let position = 0, line = 1;
14
+ const fail = (message) => {
15
+ throw new Error(`Line ${line}: ${message}`);
16
+ };
17
+ const space = () => {
18
+ while (text[position] === " " || text[position] === "\t" || text[position] === "\r")
19
+ position++;
20
+ };
21
+ while (position < text.length) {
22
+ space();
23
+ if (text[position] === "#")
24
+ while (position < text.length && text[position] !== "\n")
25
+ position++;
26
+ if (text[position] === "\n") {
27
+ position++;
28
+ line++;
29
+ continue;
30
+ }
31
+ if (position === text.length)
32
+ break;
33
+ if (text.slice(position, position + 7) === "export ") {
34
+ position += 7;
35
+ space();
36
+ }
37
+ const start = position;
38
+ while (position < text.length && /[A-Za-z0-9_]/.test(text[position]))
39
+ position++;
40
+ const name = text.slice(start, position);
41
+ if (!environmentNameSchema.safeParse(name).success)
42
+ fail("Use an uppercase variable name.");
43
+ if (names.has(name))
44
+ fail(`Duplicate variable ${name}.`);
45
+ space();
46
+ if (text[position] !== "=")
47
+ fail(`Expected = after ${name}.`);
48
+ position++;
49
+ space();
50
+ let value = "";
51
+ const quote = text[position];
52
+ if (quote === '"' || quote === "'") {
53
+ position++;
54
+ let closed = false;
55
+ while (position < text.length) {
56
+ const character = text[position++];
57
+ if (character === quote) {
58
+ closed = true;
59
+ break;
60
+ }
61
+ if (character === "\n")
62
+ line++;
63
+ if (character === "\\" && quote === '"') {
64
+ const escaped = text[position];
65
+ const replacements = {
66
+ n: "\n",
67
+ r: "\r",
68
+ t: "\t",
69
+ "\\": "\\",
70
+ '"': '"',
71
+ };
72
+ if (escaped !== undefined && Object.hasOwn(replacements, escaped)) {
73
+ value += replacements[escaped];
74
+ position++;
75
+ continue;
76
+ }
77
+ }
78
+ value += character;
79
+ }
80
+ if (!closed)
81
+ fail(`Unclosed quoted value for ${name}.`);
82
+ space();
83
+ if (position < text.length && text[position] !== "#" && text[position] !== "\n")
84
+ fail(`Unexpected text after ${name}.`);
85
+ }
86
+ else {
87
+ const valueStart = position;
88
+ while (position < text.length && text[position] !== "\n" && text[position] !== "#")
89
+ position++;
90
+ value = text.slice(valueStart, position).trimEnd();
91
+ }
92
+ if (value.length > 16384)
93
+ fail(`Value for ${name} exceeds the supported size.`);
94
+ names.add(name);
95
+ entries.push({ name, value });
96
+ if (entries.length > 128)
97
+ fail("Imports support at most 128 variables.");
98
+ if (text[position] === "#")
99
+ while (position < text.length && text[position] !== "\n")
100
+ position++;
101
+ if (text[position] === "\n") {
102
+ position++;
103
+ line++;
104
+ }
105
+ }
106
+ if (!entries.length)
107
+ throw new Error("The environment file contains no variables.");
108
+ return entries;
109
+ }
110
+ export function inferredEnvironmentKind(name) {
111
+ return /^(NEXT_PUBLIC_|VITE_|PUBLIC_|EXPO_PUBLIC_)/.test(name) ? "config" : "secret";
112
+ }