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.
- package/README.md +42 -20
- package/assets/contracts/LICENSE +201 -0
- package/assets/contracts/LICENSE.environment +201 -0
- package/assets/contracts/LICENSE.operations +201 -0
- package/assets/contracts/deployment-provenance.json +15 -0
- package/assets/contracts/environment-provenance.json +11 -0
- package/assets/contracts/operations-provenance.json +11 -0
- package/assets/launch/application.server.ts.txt +13 -0
- package/assets/launch/auth-client.ts.txt +4 -0
- package/assets/launch/home.tsx.txt +20 -0
- package/assets/launch/minimal-application.server.ts.txt +5 -0
- package/assets/launch/minimal-server.ts.txt +7 -0
- package/assets/launch/request-context.ts.txt +3 -0
- package/assets/launch/root.tsx.txt +27 -0
- package/assets/launch/router.tsx.txt +21 -0
- package/assets/launch/server.ts.txt +13 -0
- package/assets/launch/sign-in.tsx.txt +53 -0
- package/assets/launch/styles.css.txt +19 -0
- package/assets/security/credential-patterns.d.mts +3 -0
- package/assets/security/credential-patterns.mjs +59 -0
- package/assets/stack/api-index.ts.txt +6 -1
- package/assets/stack/event-retention.sql.txt +10 -0
- package/assets/stack/stripe.ts.txt +30 -13
- package/assets/ui/UPSTREAM.json +1 -18
- package/dist/bin.js +55 -36
- package/dist/capabilities.d.ts +1 -1
- package/dist/capability-catalog.d.ts +44 -11
- package/dist/capability-catalog.js +96 -11
- package/dist/capability-command.d.ts +2 -2
- package/dist/capability-command.js +178 -27
- package/dist/capability-editor.js +6 -5
- package/dist/capability-recipes.js +54 -6
- package/dist/cli-arguments.d.ts +2 -0
- package/dist/cli-arguments.js +101 -50
- package/dist/cli-commands.d.ts +1 -1
- package/dist/cli-commands.js +30 -6
- package/dist/cli-errors.d.ts +18 -0
- package/dist/cli-errors.js +63 -0
- package/dist/cli-output.d.ts +22 -0
- package/dist/cli-output.js +42 -7
- package/dist/command-runner.d.ts +1 -0
- package/dist/command-runner.js +88 -0
- package/dist/command-schema.d.ts +16 -0
- package/dist/command-schema.js +390 -21
- package/dist/completion.d.ts +2 -0
- package/dist/completion.js +201 -0
- package/dist/composition.d.ts +35 -0
- package/dist/composition.js +28 -0
- package/dist/contracts/cli-transport.d.ts +217 -0
- package/dist/contracts/cli-transport.js +167 -0
- package/dist/contracts/deployment.d.ts +282 -0
- package/dist/contracts/deployment.js +234 -0
- package/dist/contracts/environment-file.d.ts +7 -0
- package/dist/contracts/environment-file.js +112 -0
- package/dist/contracts/environment-transport.d.ts +79 -0
- package/dist/contracts/environment-transport.js +110 -0
- package/dist/contracts/runtime-logs-transport.d.ts +127 -0
- package/dist/contracts/runtime-logs-transport.js +50 -0
- package/dist/contracts/source-bundle.d.ts +11 -0
- package/dist/contracts/source-bundle.js +197 -0
- package/dist/contracts/source-profile.d.ts +4 -0
- package/dist/contracts/source-profile.js +5 -0
- package/dist/contracts/staging-transport.d.ts +79 -0
- package/dist/contracts/staging-transport.js +43 -0
- package/dist/dependencies.d.ts +10 -4
- package/dist/dependencies.js +17 -54
- package/dist/index.d.ts +6 -0
- package/dist/index.js +4 -0
- package/dist/launch.d.ts +21 -0
- package/dist/launch.js +250 -0
- package/dist/platform-command.d.ts +9 -0
- package/dist/platform-command.js +584 -0
- package/dist/platform-environment.d.ts +18 -0
- package/dist/platform-environment.js +257 -0
- package/dist/platform-operations.d.ts +26 -0
- package/dist/platform-operations.js +155 -0
- package/dist/platform-source.d.ts +8 -0
- package/dist/platform-source.js +111 -0
- package/dist/platform-state.d.ts +13 -0
- package/dist/platform-state.js +207 -0
- package/dist/platforms/tanstack.d.ts +8 -0
- package/dist/platforms/tanstack.js +155 -0
- package/dist/registry/options.js +34 -31
- package/dist/registry/resolve.js +2 -0
- package/dist/registry/usage.d.ts +4 -1
- package/dist/registry/usage.js +58 -4
- package/dist/scaffold/documentation.js +17 -48
- package/dist/scaffold/styling.d.ts +1 -1
- package/dist/scaffold/workspace.js +11 -7
- package/dist/stack-registry.d.ts +2 -4
- package/dist/stack-registry.js +1 -11
- package/dist/standard.js +21 -6
- package/dist/transaction.js +28 -3
- package/dist/ui-command.d.ts +4 -2
- package/dist/ui-command.js +79 -38
- package/dist/ui-project.d.ts +2 -0
- package/dist/ui-project.js +38 -8
- package/dist/util.js +40 -61
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/capabilities.md +22 -88
- package/docs/software-factory.md +189 -16
- package/docs/stack-standard.md +6 -18
- package/docs/ui.md +9 -22
- package/docs/verification.md +6 -1067
- package/package.json +33 -22
- package/assets/ui/native/_controls.tsx +0 -521
- package/assets/ui/native/_core.tsx +0 -118
- package/assets/ui/native/_data.tsx +0 -200
- package/assets/ui/native/_display.tsx +0 -453
- package/assets/ui/native/_feedback.tsx +0 -242
- package/assets/ui/native/_legacy-dialog.tsx +0 -38
- package/assets/ui/native/_motion.tsx +0 -520
- package/assets/ui/native/_overlay.tsx +0 -402
- package/assets/ui/native/_selection.tsx +0 -366
- package/assets/ui/native/accordion.tsx +0 -1
- package/assets/ui/native/alert-dialog.tsx +0 -11
- package/assets/ui/native/alert.tsx +0 -1
- package/assets/ui/native/aspect-ratio.tsx +0 -1
- package/assets/ui/native/attachment.tsx +0 -8
- package/assets/ui/native/avatar.tsx +0 -8
- package/assets/ui/native/badge.tsx +0 -1
- package/assets/ui/native/breadcrumb.tsx +0 -9
- package/assets/ui/native/bubble.tsx +0 -1
- package/assets/ui/native/button-group.tsx +0 -1
- package/assets/ui/native/button.tsx +0 -86
- package/assets/ui/native/calendar.tsx +0 -170
- package/assets/ui/native/card.tsx +0 -44
- package/assets/ui/native/carousel.tsx +0 -1
- package/assets/ui/native/chart.tsx +0 -193
- package/assets/ui/native/checkbox.tsx +0 -1
- package/assets/ui/native/code-block.tsx +0 -137
- package/assets/ui/native/collapsible.tsx +0 -1
- package/assets/ui/native/combobox.tsx +0 -1
- package/assets/ui/native/command.tsx +0 -11
- package/assets/ui/native/context-menu.tsx +0 -16
- package/assets/ui/native/data-table.tsx +0 -1
- package/assets/ui/native/date-picker.tsx +0 -43
- package/assets/ui/native/dialog.tsx +0 -15
- package/assets/ui/native/direction.tsx +0 -1
- package/assets/ui/native/drawer.tsx +0 -10
- package/assets/ui/native/dropdown-menu.tsx +0 -16
- package/assets/ui/native/empty.tsx +0 -8
- package/assets/ui/native/field.tsx +0 -13
- package/assets/ui/native/hover-card.tsx +0 -1
- package/assets/ui/native/input-group.tsx +0 -8
- package/assets/ui/native/input-otp.tsx +0 -1
- package/assets/ui/native/input.tsx +0 -28
- package/assets/ui/native/item.tsx +0 -12
- package/assets/ui/native/kbd.tsx +0 -1
- package/assets/ui/native/label.tsx +0 -4
- package/assets/ui/native/layout.tsx +0 -26
- package/assets/ui/native/marker.tsx +0 -1
- package/assets/ui/native/menubar.tsx +0 -17
- package/assets/ui/native/message-scroller.tsx +0 -6
- package/assets/ui/native/message.tsx +0 -10
- package/assets/ui/native/native-select.tsx +0 -1
- package/assets/ui/native/navigation-menu.tsx +0 -10
- package/assets/ui/native/pagination.tsx +0 -9
- package/assets/ui/native/popover.tsx +0 -1
- package/assets/ui/native/progress.tsx +0 -1
- package/assets/ui/native/questionnaire.tsx +0 -130
- package/assets/ui/native/radio-group.tsx +0 -1
- package/assets/ui/native/registry.json +0 -1103
- package/assets/ui/native/resizable.tsx +0 -1
- package/assets/ui/native/scroll-area.tsx +0 -1
- package/assets/ui/native/select.tsx +0 -11
- package/assets/ui/native/separator.tsx +0 -1
- package/assets/ui/native/sheet.tsx +0 -10
- package/assets/ui/native/sidebar.tsx +0 -22
- package/assets/ui/native/skeleton.tsx +0 -1
- package/assets/ui/native/slider.tsx +0 -1
- package/assets/ui/native/spinner.tsx +0 -1
- package/assets/ui/native/switch.tsx +0 -1
- package/assets/ui/native/table.tsx +0 -10
- package/assets/ui/native/tabs.tsx +0 -1
- package/assets/ui/native/text.tsx +0 -20
- package/assets/ui/native/textarea.tsx +0 -1
- package/assets/ui/native/theme-switcher.tsx +0 -22
- package/assets/ui/native/toast.tsx +0 -11
- package/assets/ui/native/toggle-group.tsx +0 -1
- package/assets/ui/native/toggle.tsx +0 -1
- package/assets/ui/native/tooltip.tsx +0 -1
- package/assets/ui/native/trace.tsx +0 -20
- package/assets/ui/native/typography.tsx +0 -15
- package/assets/ui/theme-storage.ts +0 -25
- package/assets/ui/theme.tsx +0 -66
- package/dist/platforms/mobile.d.ts +0 -2
- package/dist/platforms/mobile.js +0 -137
- package/dist/scaffold/expo-runtime.d.ts +0 -3
- package/dist/scaffold/expo-runtime.js +0 -42
- package/dist/scaffold/native-ui.d.ts +0 -2
- package/dist/scaffold/native-ui.js +0 -74
- package/docs/anhedral-stack.md +0 -7
- package/docs/native-ui.md +0 -102
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { Capability } from './capability-catalog.js';
|
|
3
|
+
export declare const launchCompositionSchema: z.ZodObject<{
|
|
4
|
+
generatorVersion: z.ZodNullable<z.ZodString>;
|
|
5
|
+
identity: 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
|
+
capabilities: z.ZodRecord<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
|
+
}> & z.core.$partial, z.ZodNullable<z.ZodString>>;
|
|
25
|
+
contractVersion: z.ZodLiteral<2>;
|
|
26
|
+
foundation: z.ZodLiteral<"tanstack-start">;
|
|
27
|
+
}, z.core.$strict>;
|
|
28
|
+
/** Local source provenance is never a hosting receipt or a provider activation claim. */
|
|
29
|
+
export declare function composeSourceProvenance(previous: unknown, installed: readonly Capability[], additions: readonly Capability[]): {
|
|
30
|
+
contractVersion: 1 | 2;
|
|
31
|
+
foundation: "next-opennext" | "tanstack-start";
|
|
32
|
+
generatorVersion: string | null;
|
|
33
|
+
identity: "none" | "better-auth-d1-v1" | "platform-application-services-v1";
|
|
34
|
+
capabilities: Partial<Record<"hono" | "database-auth" | "r2" | "stripe" | "realtime" | "rtc" | "ai" | "expo" | "native-ui" | "revenuecat" | "wxt" | "side-panel" | "gpui", string | null>>;
|
|
35
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { sourceCompositionSchema } from './contracts/deployment.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { GENERATOR_VERSION } from './version.js';
|
|
4
|
+
// Narrow the shared source contract for the launch generator; runtime admission remains server-owned.
|
|
5
|
+
export const launchCompositionSchema = sourceCompositionSchema.safeExtend({
|
|
6
|
+
contractVersion: z.literal(2),
|
|
7
|
+
foundation: z.literal('tanstack-start'),
|
|
8
|
+
});
|
|
9
|
+
const compositionSchema = sourceCompositionSchema;
|
|
10
|
+
/** Local source provenance is never a hosting receipt or a provider activation claim. */
|
|
11
|
+
export function composeSourceProvenance(previous, installed, additions) {
|
|
12
|
+
const old = previous === undefined ? undefined : compositionSchema.parse(previous);
|
|
13
|
+
if (old && Object.keys(old.capabilities).some((id) => !installed.includes(id)))
|
|
14
|
+
throw Error('Composition provenance disagrees with installed source; reconcile anhedral.json.');
|
|
15
|
+
const identity = installed.includes('database-auth') ? 'better-auth-d1-v1' : 'none';
|
|
16
|
+
if (old && old.identity !== 'none' && old.identity !== identity)
|
|
17
|
+
throw Error('Preserve existing application identity; an explicit adapter is required.');
|
|
18
|
+
return compositionSchema.parse({
|
|
19
|
+
contractVersion: old?.contractVersion ?? 1,
|
|
20
|
+
foundation: old?.foundation ?? 'next-opennext',
|
|
21
|
+
generatorVersion: old?.generatorVersion ?? null,
|
|
22
|
+
identity,
|
|
23
|
+
capabilities: Object.fromEntries(installed.map((id) => [
|
|
24
|
+
id,
|
|
25
|
+
additions.includes(id) ? GENERATOR_VERSION : (old?.capabilities[id] ?? null),
|
|
26
|
+
])),
|
|
27
|
+
});
|
|
28
|
+
}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const CLI_CLIENT_ID = "anhedral-cli";
|
|
3
|
+
export declare const SOURCE_LIMITS: {
|
|
4
|
+
readonly bytes: number;
|
|
5
|
+
readonly archiveBytes: number;
|
|
6
|
+
readonly files: 2000;
|
|
7
|
+
readonly chunkBytes: number;
|
|
8
|
+
};
|
|
9
|
+
export declare const uploadExcluded: RegExp;
|
|
10
|
+
export declare const uploadSecret: RegExp;
|
|
11
|
+
export declare const sourceHashSchema: z.ZodString;
|
|
12
|
+
export declare const cliDeviceSchema: z.ZodObject<{
|
|
13
|
+
device_code: z.ZodString;
|
|
14
|
+
user_code: z.ZodString;
|
|
15
|
+
verification_uri: z.ZodURL;
|
|
16
|
+
verification_uri_complete: z.ZodURL;
|
|
17
|
+
expires_in: z.ZodNumber;
|
|
18
|
+
interval: z.ZodNumber;
|
|
19
|
+
}, z.core.$strip>;
|
|
20
|
+
export declare const cliLoginSchema: z.ZodObject<{
|
|
21
|
+
protocol: z.ZodLiteral<1>;
|
|
22
|
+
token: z.ZodString;
|
|
23
|
+
expiresAt: z.ZodISODateTime;
|
|
24
|
+
}, z.core.$strict>;
|
|
25
|
+
export declare const cliLinkSchema: z.ZodObject<{
|
|
26
|
+
protocol: z.ZodLiteral<1>;
|
|
27
|
+
projectId: z.ZodUUID;
|
|
28
|
+
teamId: z.ZodUUID;
|
|
29
|
+
principalId: z.ZodUUID;
|
|
30
|
+
name: z.ZodString;
|
|
31
|
+
}, z.core.$strict>;
|
|
32
|
+
export declare const sourceUploadInputSchema: z.ZodObject<{
|
|
33
|
+
protocol: z.ZodLiteral<1>;
|
|
34
|
+
requestId: z.ZodUUID;
|
|
35
|
+
projectId: z.ZodUUID;
|
|
36
|
+
teamId: z.ZodUUID;
|
|
37
|
+
archiveDigest: z.ZodString;
|
|
38
|
+
archiveBytes: z.ZodNumber;
|
|
39
|
+
inventoryDigest: z.ZodString;
|
|
40
|
+
cliVersion: z.ZodString;
|
|
41
|
+
chunks: z.ZodArray<z.ZodString>;
|
|
42
|
+
}, z.core.$strict>;
|
|
43
|
+
export declare const sourceUploadReceiptSchema: z.ZodObject<{
|
|
44
|
+
protocol: z.ZodLiteral<1>;
|
|
45
|
+
id: z.ZodUUID;
|
|
46
|
+
requestId: z.ZodUUID;
|
|
47
|
+
projectId: z.ZodUUID;
|
|
48
|
+
archiveDigest: z.ZodString;
|
|
49
|
+
inventoryDigest: z.ZodString;
|
|
50
|
+
received: z.ZodArray<z.ZodNumber>;
|
|
51
|
+
state: z.ZodEnum<{
|
|
52
|
+
uploading: "uploading";
|
|
53
|
+
cancelled: "cancelled";
|
|
54
|
+
sealed: "sealed";
|
|
55
|
+
}>;
|
|
56
|
+
expiresAt: z.ZodISODateTime;
|
|
57
|
+
sourceRevision: z.ZodNullable<z.ZodString>;
|
|
58
|
+
}, z.core.$strict>;
|
|
59
|
+
export type SourceUploadInput = z.infer<typeof sourceUploadInputSchema>;
|
|
60
|
+
/** High-confidence credential material must not enter a source checkpoint. */
|
|
61
|
+
export declare function sourceContainsCredential(bytes: Uint8Array): boolean;
|
|
62
|
+
/** Planning reserves source only. It cannot grant a runtime, preview or deployment. */
|
|
63
|
+
export declare const cliPlanInputSchema: z.ZodObject<{
|
|
64
|
+
protocol: z.ZodLiteral<1>;
|
|
65
|
+
requestId: z.ZodUUID;
|
|
66
|
+
uploadId: z.ZodUUID;
|
|
67
|
+
manifest: z.ZodObject<{
|
|
68
|
+
contractVersion: z.ZodLiteral<1>;
|
|
69
|
+
foundation: z.ZodEnum<{
|
|
70
|
+
"next-opennext": "next-opennext";
|
|
71
|
+
"tanstack-start": "tanstack-start";
|
|
72
|
+
}>;
|
|
73
|
+
capabilities: z.ZodArray<z.ZodEnum<{
|
|
74
|
+
hono: "hono";
|
|
75
|
+
"database-auth": "database-auth";
|
|
76
|
+
r2: "r2";
|
|
77
|
+
stripe: "stripe";
|
|
78
|
+
realtime: "realtime";
|
|
79
|
+
rtc: "rtc";
|
|
80
|
+
ai: "ai";
|
|
81
|
+
expo: "expo";
|
|
82
|
+
"native-ui": "native-ui";
|
|
83
|
+
revenuecat: "revenuecat";
|
|
84
|
+
wxt: "wxt";
|
|
85
|
+
"side-panel": "side-panel";
|
|
86
|
+
gpui: "gpui";
|
|
87
|
+
}>>;
|
|
88
|
+
identity: z.ZodEnum<{
|
|
89
|
+
none: "none";
|
|
90
|
+
"better-auth-d1-v1": "better-auth-d1-v1";
|
|
91
|
+
"platform-application-services-v1": "platform-application-services-v1";
|
|
92
|
+
}>;
|
|
93
|
+
cliArtifact: z.ZodObject<{
|
|
94
|
+
version: z.ZodString;
|
|
95
|
+
sourceRevision: z.ZodString;
|
|
96
|
+
packageIntegrity: z.ZodString;
|
|
97
|
+
}, z.core.$strict>;
|
|
98
|
+
intent: z.ZodObject<{
|
|
99
|
+
contractVersion: z.ZodLiteral<1>;
|
|
100
|
+
runtimeProfile: z.ZodString;
|
|
101
|
+
environment: z.ZodEnum<{
|
|
102
|
+
production: "production";
|
|
103
|
+
preview: "preview";
|
|
104
|
+
}>;
|
|
105
|
+
visibility: z.ZodEnum<{
|
|
106
|
+
protected: "protected";
|
|
107
|
+
public: "public";
|
|
108
|
+
}>;
|
|
109
|
+
}, z.core.$strict>;
|
|
110
|
+
}, z.core.$strict>;
|
|
111
|
+
}, z.core.$strict>;
|
|
112
|
+
export declare const cliPlanSchema: z.ZodObject<{
|
|
113
|
+
protocol: z.ZodLiteral<1>;
|
|
114
|
+
id: z.ZodUUID;
|
|
115
|
+
requestId: z.ZodUUID;
|
|
116
|
+
projectId: z.ZodUUID;
|
|
117
|
+
uploadId: z.ZodUUID;
|
|
118
|
+
digest: z.ZodString;
|
|
119
|
+
manifest: z.ZodObject<{
|
|
120
|
+
contractVersion: z.ZodLiteral<1>;
|
|
121
|
+
foundation: z.ZodEnum<{
|
|
122
|
+
"next-opennext": "next-opennext";
|
|
123
|
+
"tanstack-start": "tanstack-start";
|
|
124
|
+
}>;
|
|
125
|
+
capabilities: z.ZodArray<z.ZodEnum<{
|
|
126
|
+
hono: "hono";
|
|
127
|
+
"database-auth": "database-auth";
|
|
128
|
+
r2: "r2";
|
|
129
|
+
stripe: "stripe";
|
|
130
|
+
realtime: "realtime";
|
|
131
|
+
rtc: "rtc";
|
|
132
|
+
ai: "ai";
|
|
133
|
+
expo: "expo";
|
|
134
|
+
"native-ui": "native-ui";
|
|
135
|
+
revenuecat: "revenuecat";
|
|
136
|
+
wxt: "wxt";
|
|
137
|
+
"side-panel": "side-panel";
|
|
138
|
+
gpui: "gpui";
|
|
139
|
+
}>>;
|
|
140
|
+
identity: z.ZodEnum<{
|
|
141
|
+
none: "none";
|
|
142
|
+
"better-auth-d1-v1": "better-auth-d1-v1";
|
|
143
|
+
"platform-application-services-v1": "platform-application-services-v1";
|
|
144
|
+
}>;
|
|
145
|
+
cliArtifact: z.ZodObject<{
|
|
146
|
+
version: z.ZodString;
|
|
147
|
+
sourceRevision: z.ZodString;
|
|
148
|
+
packageIntegrity: z.ZodString;
|
|
149
|
+
}, z.core.$strict>;
|
|
150
|
+
intent: z.ZodObject<{
|
|
151
|
+
contractVersion: z.ZodLiteral<1>;
|
|
152
|
+
runtimeProfile: z.ZodString;
|
|
153
|
+
environment: z.ZodEnum<{
|
|
154
|
+
production: "production";
|
|
155
|
+
preview: "preview";
|
|
156
|
+
}>;
|
|
157
|
+
visibility: z.ZodEnum<{
|
|
158
|
+
protected: "protected";
|
|
159
|
+
public: "public";
|
|
160
|
+
}>;
|
|
161
|
+
}, z.core.$strict>;
|
|
162
|
+
}, z.core.$strict>;
|
|
163
|
+
sourceRevision: z.ZodString;
|
|
164
|
+
inventoryDigest: z.ZodString;
|
|
165
|
+
lockDigest: z.ZodString;
|
|
166
|
+
routing: z.ZodObject<{
|
|
167
|
+
generation: z.ZodNumber;
|
|
168
|
+
activeReleaseId: z.ZodNullable<z.ZodUUID>;
|
|
169
|
+
desiredReleaseId: z.ZodNullable<z.ZodUUID>;
|
|
170
|
+
}, z.core.$strict>;
|
|
171
|
+
routingRevision: z.ZodString;
|
|
172
|
+
expectedGeneration: z.ZodNumber;
|
|
173
|
+
policyDigest: z.ZodString;
|
|
174
|
+
migrationDigests: z.ZodArray<z.ZodString>;
|
|
175
|
+
expiresAt: z.ZodISODateTime;
|
|
176
|
+
runtimeImage: z.ZodNull;
|
|
177
|
+
configurationRevision: z.ZodNull;
|
|
178
|
+
artifactVerified: z.ZodLiteral<false>;
|
|
179
|
+
hostedAdmission: z.ZodLiteral<false>;
|
|
180
|
+
identityAction: z.ZodLiteral<"preserve">;
|
|
181
|
+
blockers: z.ZodTuple<[z.ZodLiteral<"HOSTED_ADMISSION_DISABLED">, z.ZodLiteral<"ARTIFACT_UNREVIEWED">, z.ZodLiteral<"CONFIGURATION_UNVERIFIED">], null>;
|
|
182
|
+
}, z.core.$strict>;
|
|
183
|
+
export declare const cliPrepareInputSchema: z.ZodObject<{
|
|
184
|
+
protocol: z.ZodLiteral<1>;
|
|
185
|
+
requestId: z.ZodUUID;
|
|
186
|
+
planId: z.ZodUUID;
|
|
187
|
+
planDigest: z.ZodString;
|
|
188
|
+
}, z.core.$strict>;
|
|
189
|
+
export declare const cliPreparationSchema: z.ZodObject<{
|
|
190
|
+
protocol: z.ZodLiteral<1>;
|
|
191
|
+
planId: z.ZodUUID;
|
|
192
|
+
planDigest: z.ZodString;
|
|
193
|
+
candidateId: z.ZodUUID;
|
|
194
|
+
sourceRevision: z.ZodString;
|
|
195
|
+
state: z.ZodEnum<{
|
|
196
|
+
ready: "ready";
|
|
197
|
+
failed: "failed";
|
|
198
|
+
building: "building";
|
|
199
|
+
"awaiting-runtime": "awaiting-runtime";
|
|
200
|
+
built: "built";
|
|
201
|
+
}>;
|
|
202
|
+
buildDigest: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
203
|
+
error: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
204
|
+
admission: z.ZodOptional<z.ZodNullable<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
205
|
+
policyDigest: z.ZodString;
|
|
206
|
+
image: z.ZodString;
|
|
207
|
+
scope: z.ZodLiteral<"isolated-build">;
|
|
208
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
209
|
+
policyDigest: z.ZodString;
|
|
210
|
+
image: z.ZodString;
|
|
211
|
+
scope: z.ZodLiteral<"candidate-workspace">;
|
|
212
|
+
}, z.core.$strict>], "scope">>>;
|
|
213
|
+
hostedAdmission: z.ZodBoolean;
|
|
214
|
+
identityAction: z.ZodLiteral<"preserve">;
|
|
215
|
+
}, z.core.$strict>;
|
|
216
|
+
/** Canonical JSON for immutable plan and request digests across SQL JSONB and clients. */
|
|
217
|
+
export declare function canonicalCliJson(value: unknown): string;
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { deploymentManifestSchema } from "./deployment.js";
|
|
3
|
+
export const CLI_CLIENT_ID = "anhedral-cli";
|
|
4
|
+
export const SOURCE_LIMITS = {
|
|
5
|
+
bytes: 16 * 1024 * 1024,
|
|
6
|
+
archiveBytes: 24 * 1024 * 1024,
|
|
7
|
+
files: 2000,
|
|
8
|
+
chunkBytes: 1024 * 1024,
|
|
9
|
+
};
|
|
10
|
+
export const uploadExcluded = /(?:^|\/)(?:\.artifacts|coverage|\.cache|\.DS_Store)(?:\/|$)/;
|
|
11
|
+
export const uploadSecret = /(?:^|\/)(?:\.aws|\.ssh|\.gnupg|\.npmrc|\.netrc|\.pypirc|credentials(?:\.[^/]*)?|[^/]*\.(?:pem|key|p12|pfx))(?:\/|$)/i;
|
|
12
|
+
export const sourceHashSchema = z.string().regex(/^[a-f0-9]{64}$/);
|
|
13
|
+
export const cliDeviceSchema = z.object({
|
|
14
|
+
device_code: z.string().min(20).max(191),
|
|
15
|
+
user_code: z.string().min(4).max(40),
|
|
16
|
+
verification_uri: z.url(),
|
|
17
|
+
verification_uri_complete: z.url(),
|
|
18
|
+
expires_in: z.number().int().positive().max(600),
|
|
19
|
+
interval: z.number().int().min(1).max(30),
|
|
20
|
+
});
|
|
21
|
+
export const cliLoginSchema = z
|
|
22
|
+
.object({
|
|
23
|
+
protocol: z.literal(1),
|
|
24
|
+
token: z.string().regex(/^acl_[a-f0-9]{64}$/),
|
|
25
|
+
expiresAt: z.iso.datetime(),
|
|
26
|
+
})
|
|
27
|
+
.strict();
|
|
28
|
+
export const cliLinkSchema = z
|
|
29
|
+
.object({
|
|
30
|
+
protocol: z.literal(1),
|
|
31
|
+
projectId: z.uuid(),
|
|
32
|
+
teamId: z.uuid(),
|
|
33
|
+
principalId: z.uuid(),
|
|
34
|
+
name: z.string().min(1).max(200),
|
|
35
|
+
})
|
|
36
|
+
.strict();
|
|
37
|
+
export const sourceUploadInputSchema = z
|
|
38
|
+
.object({
|
|
39
|
+
protocol: z.literal(1),
|
|
40
|
+
requestId: z.uuid(),
|
|
41
|
+
projectId: z.uuid(),
|
|
42
|
+
teamId: z.uuid(),
|
|
43
|
+
archiveDigest: sourceHashSchema,
|
|
44
|
+
archiveBytes: z.number().int().positive().max(SOURCE_LIMITS.bytes),
|
|
45
|
+
inventoryDigest: sourceHashSchema,
|
|
46
|
+
cliVersion: z.string().regex(/^\d+\.\d+\.\d+(?:-[a-zA-Z0-9.-]+)?$/),
|
|
47
|
+
chunks: z.array(sourceHashSchema).min(1).max(16),
|
|
48
|
+
})
|
|
49
|
+
.strict()
|
|
50
|
+
.refine((v) => v.chunks.length === Math.ceil(v.archiveBytes / SOURCE_LIMITS.chunkBytes), "Chunk count differs from archive size.");
|
|
51
|
+
export const sourceUploadReceiptSchema = z
|
|
52
|
+
.object({
|
|
53
|
+
protocol: z.literal(1),
|
|
54
|
+
id: z.uuid(),
|
|
55
|
+
requestId: z.uuid(),
|
|
56
|
+
projectId: z.uuid(),
|
|
57
|
+
archiveDigest: sourceHashSchema,
|
|
58
|
+
inventoryDigest: sourceHashSchema,
|
|
59
|
+
received: z.array(z.number().int().min(0).max(15)).max(16),
|
|
60
|
+
state: z.enum(["uploading", "sealed", "cancelled"]),
|
|
61
|
+
expiresAt: z.iso.datetime(),
|
|
62
|
+
sourceRevision: sourceHashSchema.nullable(),
|
|
63
|
+
})
|
|
64
|
+
.strict();
|
|
65
|
+
/** High-confidence credential material must not enter a source checkpoint. */
|
|
66
|
+
export function sourceContainsCredential(bytes) {
|
|
67
|
+
return /\bacl_[a-f0-9]{64}\b|"device_code"\s*:\s*"[A-Za-z0-9_-]{20,191}"|-----BEGIN (?:[A-Z ]+ )?PRIVATE KEY-----|\bAKIA[A-Z0-9]{16}\b|\bnpm_[A-Za-z0-9]{36}\b|\bsk-proj-[A-Za-z0-9_-]{30,}|\b(?:sk|rk)_(?:live|test)_[A-Za-z0-9]{24,}/.test(new TextDecoder().decode(bytes));
|
|
68
|
+
}
|
|
69
|
+
/** Planning reserves source only. It cannot grant a runtime, preview or deployment. */
|
|
70
|
+
export const cliPlanInputSchema = z
|
|
71
|
+
.object({
|
|
72
|
+
protocol: z.literal(1),
|
|
73
|
+
requestId: z.uuid(),
|
|
74
|
+
uploadId: z.uuid(),
|
|
75
|
+
manifest: deploymentManifestSchema,
|
|
76
|
+
})
|
|
77
|
+
.strict();
|
|
78
|
+
export const cliPlanSchema = z
|
|
79
|
+
.object({
|
|
80
|
+
protocol: z.literal(1),
|
|
81
|
+
id: z.uuid(),
|
|
82
|
+
requestId: z.uuid(),
|
|
83
|
+
projectId: z.uuid(),
|
|
84
|
+
uploadId: z.uuid(),
|
|
85
|
+
digest: sourceHashSchema,
|
|
86
|
+
manifest: deploymentManifestSchema,
|
|
87
|
+
sourceRevision: sourceHashSchema,
|
|
88
|
+
inventoryDigest: sourceHashSchema,
|
|
89
|
+
lockDigest: sourceHashSchema,
|
|
90
|
+
routing: z
|
|
91
|
+
.object({
|
|
92
|
+
generation: z.number().int().nonnegative(),
|
|
93
|
+
activeReleaseId: z.uuid().nullable(),
|
|
94
|
+
desiredReleaseId: z.uuid().nullable(),
|
|
95
|
+
})
|
|
96
|
+
.strict(),
|
|
97
|
+
routingRevision: sourceHashSchema,
|
|
98
|
+
expectedGeneration: z.number().int().nonnegative(),
|
|
99
|
+
policyDigest: sourceHashSchema,
|
|
100
|
+
migrationDigests: z.array(sourceHashSchema).max(100),
|
|
101
|
+
expiresAt: z.iso.datetime(),
|
|
102
|
+
runtimeImage: z.null(),
|
|
103
|
+
configurationRevision: z.null(),
|
|
104
|
+
artifactVerified: z.literal(false),
|
|
105
|
+
hostedAdmission: z.literal(false),
|
|
106
|
+
identityAction: z.literal("preserve"),
|
|
107
|
+
blockers: z.tuple([
|
|
108
|
+
z.literal("HOSTED_ADMISSION_DISABLED"),
|
|
109
|
+
z.literal("ARTIFACT_UNREVIEWED"),
|
|
110
|
+
z.literal("CONFIGURATION_UNVERIFIED"),
|
|
111
|
+
]),
|
|
112
|
+
})
|
|
113
|
+
.strict();
|
|
114
|
+
export const cliPrepareInputSchema = z
|
|
115
|
+
.object({
|
|
116
|
+
protocol: z.literal(1),
|
|
117
|
+
requestId: z.uuid(),
|
|
118
|
+
planId: z.uuid(),
|
|
119
|
+
planDigest: sourceHashSchema,
|
|
120
|
+
})
|
|
121
|
+
.strict();
|
|
122
|
+
export const cliPreparationSchema = z
|
|
123
|
+
.object({
|
|
124
|
+
protocol: z.literal(1),
|
|
125
|
+
planId: z.uuid(),
|
|
126
|
+
planDigest: sourceHashSchema,
|
|
127
|
+
candidateId: z.uuid(),
|
|
128
|
+
sourceRevision: sourceHashSchema,
|
|
129
|
+
state: z.enum(["awaiting-runtime", "building", "built", "ready", "failed"]),
|
|
130
|
+
buildDigest: sourceHashSchema.nullable().optional(),
|
|
131
|
+
error: z.string().max(300).nullable().optional(),
|
|
132
|
+
admission: z
|
|
133
|
+
.discriminatedUnion("scope", [
|
|
134
|
+
z
|
|
135
|
+
.object({
|
|
136
|
+
policyDigest: sourceHashSchema,
|
|
137
|
+
image: z.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
138
|
+
scope: z.literal("isolated-build"),
|
|
139
|
+
})
|
|
140
|
+
.strict(),
|
|
141
|
+
z
|
|
142
|
+
.object({
|
|
143
|
+
policyDigest: sourceHashSchema,
|
|
144
|
+
image: z
|
|
145
|
+
.string()
|
|
146
|
+
.regex(/^registry\.[a-z0-9.-]+\/[a-zA-Z0-9/_.-]+@sha256:[a-f0-9]{64}$/),
|
|
147
|
+
scope: z.literal("candidate-workspace"),
|
|
148
|
+
})
|
|
149
|
+
.strict(),
|
|
150
|
+
])
|
|
151
|
+
.nullable()
|
|
152
|
+
.optional(),
|
|
153
|
+
hostedAdmission: z.boolean(),
|
|
154
|
+
identityAction: z.literal("preserve"),
|
|
155
|
+
})
|
|
156
|
+
.strict();
|
|
157
|
+
/** Canonical JSON for immutable plan and request digests across SQL JSONB and clients. */
|
|
158
|
+
export function canonicalCliJson(value) {
|
|
159
|
+
if (Array.isArray(value))
|
|
160
|
+
return `[${value.map(canonicalCliJson).join(",")}]`;
|
|
161
|
+
if (value !== null && typeof value === "object")
|
|
162
|
+
return `{${Object.entries(value)
|
|
163
|
+
.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
|
|
164
|
+
.map(([key, v]) => `${JSON.stringify(key)}:${canonicalCliJson(v)}`)
|
|
165
|
+
.join(",")}}`;
|
|
166
|
+
return JSON.stringify(value);
|
|
167
|
+
}
|