anhedral 0.11.2 → 0.13.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 (102) hide show
  1. package/README.md +171 -18
  2. package/dist/bin.js +48 -493
  3. package/dist/capabilities.d.ts +3 -3
  4. package/dist/capability-contract.js +16 -1
  5. package/dist/cli-arguments.d.ts +8 -0
  6. package/dist/cli-arguments.js +32 -0
  7. package/dist/cli-commands.d.ts +3 -0
  8. package/dist/cli-commands.js +114 -0
  9. package/dist/cli-delivery.d.ts +3 -0
  10. package/dist/cli-delivery.js +172 -0
  11. package/dist/cli-output.js +231 -205
  12. package/dist/command-schema.js +8 -2
  13. package/dist/command.js +9 -11
  14. package/dist/delivery-evidence.d.ts +62 -0
  15. package/dist/delivery-evidence.js +186 -0
  16. package/dist/delivery.d.ts +3 -40
  17. package/dist/delivery.js +7 -182
  18. package/dist/dependencies.d.ts +7 -1
  19. package/dist/dependencies.js +15 -1
  20. package/dist/index.d.ts +1 -0
  21. package/dist/index.js +1 -0
  22. package/dist/mobile-delivery.d.ts +21 -44
  23. package/dist/mobile-delivery.js +127 -80
  24. package/dist/platforms/mobile.d.ts +1 -1
  25. package/dist/platforms/mobile.js +44 -3
  26. package/dist/project-state.js +4 -1
  27. package/dist/provider-auth.js +9 -3
  28. package/dist/providers/adapters.js +9 -3
  29. package/dist/providers/runtime.js +11 -0
  30. package/dist/readiness.js +4 -2
  31. package/dist/registry/add.js +40 -7
  32. package/dist/registry/options.js +12 -0
  33. package/dist/registry/presets.d.ts +4 -0
  34. package/dist/registry/presets.js +41 -0
  35. package/dist/registry/resolve.d.ts +3 -1
  36. package/dist/registry/resolve.js +40 -14
  37. package/dist/registry/types.d.ts +1 -0
  38. package/dist/registry/usage.js +1 -1
  39. package/dist/runtime-policy.js +4 -1
  40. package/dist/scaffold/api.js +10 -2
  41. package/dist/scaffold/auth.d.ts +1 -1
  42. package/dist/scaffold/auth.js +22 -6
  43. package/dist/scaffold/backend.d.ts +6 -0
  44. package/dist/scaffold/backend.js +224 -0
  45. package/dist/scaffold/billing-config.d.ts +1 -0
  46. package/dist/scaffold/billing-config.js +73 -0
  47. package/dist/scaffold/billing-contracts.d.ts +2 -0
  48. package/dist/scaffold/billing-contracts.js +48 -0
  49. package/dist/scaffold/billing-providers.d.ts +1 -0
  50. package/dist/scaffold/billing-providers.js +249 -0
  51. package/dist/scaffold/billing-schema.d.ts +1 -0
  52. package/dist/scaffold/billing-schema.js +34 -0
  53. package/dist/scaffold/billing-security.d.ts +1 -0
  54. package/dist/scaffold/billing-security.js +46 -0
  55. package/dist/scaffold/billing-server.d.ts +1 -0
  56. package/dist/scaffold/billing-server.js +139 -0
  57. package/dist/scaffold/billing-store.d.ts +1 -0
  58. package/dist/scaffold/billing-store.js +72 -0
  59. package/dist/scaffold/billing.d.ts +2 -0
  60. package/dist/scaffold/billing.js +216 -0
  61. package/dist/scaffold/cloudflare-services.d.ts +8 -0
  62. package/dist/scaffold/cloudflare-services.js +198 -0
  63. package/dist/scaffold/compose.js +2 -0
  64. package/dist/scaffold/database.js +19 -2
  65. package/dist/scaffold/documentation.js +11 -6
  66. package/dist/scaffold/expo-auth.d.ts +3 -0
  67. package/dist/scaffold/expo-auth.js +192 -0
  68. package/dist/scaffold/expo-billing.d.ts +3 -0
  69. package/dist/scaffold/expo-billing.js +292 -0
  70. package/dist/scaffold/expo-runtime.d.ts +3 -0
  71. package/dist/scaffold/expo-runtime.js +134 -0
  72. package/dist/scaffold/integrations.d.ts +2 -1
  73. package/dist/scaffold/integrations.js +7 -2
  74. package/dist/scaffold/stream.d.ts +2 -0
  75. package/dist/scaffold/stream.js +114 -0
  76. package/dist/scaffold/void.js +13 -5
  77. package/dist/scaffold/web.js +2 -0
  78. package/dist/scaffold/workspace.js +6 -1
  79. package/dist/service-readers.js +1 -1
  80. package/dist/services-command.js +8 -6
  81. package/dist/ship.d.ts +15 -15
  82. package/dist/ship.js +3 -1
  83. package/dist/stack-registry.d.ts +13 -2
  84. package/dist/stack-registry.js +152 -16
  85. package/dist/transaction-lock.d.ts +15 -0
  86. package/dist/transaction-lock.js +227 -0
  87. package/dist/transaction.js +2 -208
  88. package/dist/vercel-project.d.ts +101 -0
  89. package/dist/vercel-project.js +305 -0
  90. package/dist/vercel.d.ts +3 -36
  91. package/dist/vercel.js +3 -300
  92. package/dist/version.d.ts +1 -1
  93. package/dist/version.js +1 -1
  94. package/docs/anhedral-stack.md +122 -0
  95. package/docs/software-factory.md +402 -7
  96. package/docs/stack-standard.md +226 -49
  97. package/docs/verification.md +557 -0
  98. package/package.json +7 -7
  99. package/docs/cli-design.md +0 -67
  100. package/docs/plugin-ui.md +0 -102
  101. package/docs/provider-configuration.md +0 -116
  102. package/docs/void-verification.md +0 -185
@@ -0,0 +1,134 @@
1
+ import { writeEnvironmentFile } from './environment.js';
2
+ import { STACK_DEPENDENCIES } from '../dependencies.js';
3
+ import { resourceName } from '../render.js';
4
+ import { json, patchPackage, put, workerConfig } from './files.js';
5
+ /** Expo remains a static universal client. Its Worker owns only assets and API transport. */
6
+ export function scaffoldExpoRuntime({ root, options, has }) {
7
+ const directory = 'apps/mobile';
8
+ const api = has('hono');
9
+ const webPort = has('vinext') || has('next') ? 3001 : 3000;
10
+ json(root, `${directory}/wrangler.jsonc`, {
11
+ ...workerConfig(resourceName(options.name, 'mobile')),
12
+ main: 'worker/index.ts',
13
+ assets: {
14
+ directory: './dist',
15
+ binding: 'ASSETS',
16
+ run_worker_first: ['/api', '/api/*'],
17
+ html_handling: 'auto-trailing-slash',
18
+ not_found_handling: '404-page',
19
+ },
20
+ ...(api ? { services: [{ binding: 'API', service: resourceName(options.name, 'api') }] } : {}),
21
+ });
22
+ patchPackage(root, `${directory}/package.json`, {
23
+ scripts: {
24
+ dev: `pnpm build:web && wrangler dev --port ${webPort} --inspector-port 9230`,
25
+ start: 'expo start -c',
26
+ web: 'pnpm dev',
27
+ build: 'pnpm typecheck && pnpm build:web && pnpm build:worker',
28
+ 'build:worker': 'wrangler deploy --dry-run --outdir .output/worker',
29
+ preview: `pnpm build:web && wrangler dev --port ${webPort} --inspector-port 9230`,
30
+ deploy: 'pnpm build:web && wrangler deploy',
31
+ typecheck: 'tsc --noEmit && pnpm typecheck:worker',
32
+ 'typecheck:worker': 'tsc --project tsconfig.worker.json --noEmit',
33
+ lint: 'eslint app components lib worker --max-warnings 0',
34
+ },
35
+ ...(api ? { dependencies: { '@workspace/contracts': 'workspace:*' } } : {}),
36
+ devDependencies: { wrangler: STACK_DEPENDENCIES.wrangler },
37
+ });
38
+ json(root, `${directory}/tsconfig.worker.json`, {
39
+ compilerOptions: {
40
+ target: 'ES2022',
41
+ lib: ['ES2022', 'DOM', 'DOM.Iterable'],
42
+ module: 'ESNext',
43
+ moduleResolution: 'Bundler',
44
+ strict: true,
45
+ skipLibCheck: true,
46
+ noEmit: true,
47
+ types: [],
48
+ },
49
+ include: ['worker/**/*.ts'],
50
+ });
51
+ put(root, `${directory}/worker/index.ts`, `interface Binding { fetch(request: Request): Promise<Response> }
52
+ interface Env { ASSETS: Binding; ${api ? 'API: Binding;' : ''} }
53
+
54
+ ${api
55
+ ? `// Browser-supplied edge identity headers never cross the API boundary.
56
+ function forwardedHeaders(request: Request): Headers {
57
+ const headers = new Headers();
58
+ for (const name of ['accept', 'content-type', 'cookie', 'origin', 'authorization', 'sec-fetch-site', 'expo-origin', 'idempotency-key']) {
59
+ const value = request.headers.get(name);
60
+ if (value) headers.set(name, value);
61
+ }
62
+ return headers;
63
+ }
64
+ function privateResponse(response: Response): Response {
65
+ const headers = new Headers(response.headers);
66
+ for (const name of ['connection', 'transfer-encoding', 'access-control-allow-origin', 'access-control-allow-credentials']) headers.delete(name);
67
+ headers.set('cache-control', 'private, no-store');
68
+ return new Response(response.body, { status: response.status, headers });
69
+ }
70
+ async function proxyApi(request: Request, env: Env): Promise<Response> {
71
+ const url = new URL(request.url);
72
+ const target = new URL('https://api.internal');
73
+ target.pathname = url.pathname;
74
+ target.search = url.search;
75
+ try {
76
+ const upstream = new Request(new Request(target, request), {
77
+ headers: forwardedHeaders(request), redirect: 'manual',
78
+ signal: AbortSignal.any([request.signal, AbortSignal.timeout(15000)]),
79
+ });
80
+ return privateResponse(await env.API.fetch(upstream));
81
+ } catch {
82
+ return Response.json({ error: 'API unavailable' }, { status: 503, headers: { 'cache-control': 'private, no-store' } });
83
+ }
84
+ }
85
+ `
86
+ : ''}
87
+ export default {
88
+ async fetch(request: Request, env: Env): Promise<Response> {
89
+ const pathname = new URL(request.url).pathname;
90
+ const apiPath = pathname === '/api' || pathname.startsWith('/api/');
91
+ if (!apiPath) return env.ASSETS.fetch(request);
92
+ ${api ? 'return proxyApi(request, env);' : "return Response.json({ error: 'API not configured' }, { status: 404, headers: { 'cache-control': 'private, no-store' } });"}
93
+ },
94
+ };
95
+ `);
96
+ if (!api)
97
+ return;
98
+ put(root, `${directory}/lib/api-client.ts`, `import { Platform } from 'react-native';
99
+ import { createApiClient } from '@workspace/contracts';
100
+
101
+ type Options = NonNullable<Parameters<typeof createApiClient>[1]>;
102
+
103
+ function validProtocol(url: URL): boolean {
104
+ return url.protocol === 'https:' || (__DEV__ && url.protocol === 'http:');
105
+ }
106
+ export function nativeApiOrigin(): string {
107
+ const configured = process.env.EXPO_PUBLIC_API_URL;
108
+ if (!configured) throw new Error('Configure EXPO_PUBLIC_API_URL with the product origin reachable from this device.');
109
+ const origin = new URL(configured);
110
+ if (!validProtocol(origin)) throw new Error('EXPO_PUBLIC_API_URL requires HTTPS outside development.');
111
+ if ([origin.username, origin.password, origin.pathname !== '/', origin.search, origin.hash].some(Boolean))
112
+ throw new Error('EXPO_PUBLIC_API_URL must be an origin without credentials, path, query or fragment.');
113
+ return origin.origin;
114
+ }
115
+ function apiBaseURL(): string {
116
+ if (Platform.OS === 'web') return '/api';
117
+ return nativeApiOrigin() + '/api';
118
+ }
119
+
120
+ // A native auth adapter can provide its own session headers. No server secret belongs here.
121
+ export function createApplicationApiClient(options: Options = {}) {
122
+ const client = () => createApiClient(apiBaseURL(), {
123
+ ...options, credentials: Platform.OS === 'web' ? 'same-origin' : 'omit',
124
+ });
125
+ return {
126
+ health: (init?: RequestInit) => client().health(init),
127
+ session: (init?: RequestInit) => client().session(init),
128
+ };
129
+ }
130
+
131
+ export const api = createApplicationApiClient();
132
+ `);
133
+ writeEnvironmentFile(root, `${directory}/.env.example`, { EXPO_PUBLIC_API_URL: '' });
134
+ }
@@ -1,3 +1,4 @@
1
1
  import type { RecipeContext } from '../registry/types.js';
2
2
  export declare function scaffoldPrivateFiles({ root, runtimeApp }: RecipeContext): void;
3
- export declare function scaffoldRevenueCat({ root }: RecipeContext): void;
3
+ export declare function scaffoldStripe(context: RecipeContext): void;
4
+ export declare function scaffoldRevenueCat(context: RecipeContext): void;
@@ -1,7 +1,12 @@
1
1
  import { put } from './files.js';
2
+ import { scaffoldBilling } from './billing.js';
2
3
  export function scaffoldPrivateFiles({ root, runtimeApp }) {
3
4
  put(root, `apps/${runtimeApp}/private-files.md`, '# Private files\n\nFILES is a private R2 Worker binding. Authenticate the request and enforce file-level product authorization before calling get/put/delete. No public buckets, R2 keys, generic download endpoints, or client credentials are generated. Use the binding directly in Hono or import env from cloudflare:workers in Vinext; explicit OpenNext uses getCloudflareContext.\n');
4
5
  }
5
- export function scaffoldRevenueCat({ root }) {
6
- put(root, 'packages/billing/revenuecat.md', '# RevenueCat + Stripe\n\nConfigure web/App Store/Play Store products and offerings in client-owned accounts. Add the platform SDK to each selected app. Verify signed provider webhooks, reconcile entitlement authority, and keep transactional idempotent credits/quotas separate from subscription status. No payment activation occurs during init.\n');
6
+ export function scaffoldStripe(context) {
7
+ scaffoldBilling(context);
8
+ }
9
+ export function scaffoldRevenueCat(context) {
10
+ scaffoldBilling(context);
11
+ put(context.root, 'packages/billing/revenuecat.md', '# RevenueCat + Stripe\n\nConfigure web/App Store/Play Store products and offerings in client-owned accounts. Add the platform SDK to each selected app. Verify signed provider webhooks, reconcile entitlement authority, and keep transactional idempotent credits/quotas separate from subscription status. No payment activation occurs during init.\n');
7
12
  }
@@ -0,0 +1,2 @@
1
+ import type { RecipeContext } from '../registry/types.js';
2
+ export declare function scaffoldStream({ root, options, runtimeApp }: RecipeContext): void;
@@ -0,0 +1,114 @@
1
+ import { rmSync } from 'node:fs';
2
+ import path from 'node:path';
3
+ import { patchPackage, put, sharedPackage } from './files.js';
4
+ import { writeEnvironmentFile } from './environment.js';
5
+ export function scaffoldStream({ root, options, runtimeApp }) {
6
+ sharedPackage(root, 'stream', '', {});
7
+ rmSync(path.join(root, 'packages/stream/src/index.ts'));
8
+ patchPackage(root, 'packages/stream/package.json', {
9
+ exports: { './server': './src/server.ts' },
10
+ });
11
+ put(root, 'packages/stream/src/server.ts', streamServer);
12
+ put(root, 'packages/stream/README.md', streamGuide);
13
+ const app = `apps/${runtimeApp}`;
14
+ const native = runtimeApp === 'web' && options.hosting === 'vercel';
15
+ writeEnvironmentFile(root, `${app}/${native ? '.env.example' : '.dev.vars.example'}`, {
16
+ STREAM_ACCOUNT_ID: '',
17
+ STREAM_API_TOKEN: '',
18
+ });
19
+ if (!native)
20
+ put(root, `${app}/${runtimeApp === 'api' ? 'src/' : ''}stream-secrets.d.ts`, runtimeApp === 'api'
21
+ ? 'interface Env { STREAM_ACCOUNT_ID: string; STREAM_API_TOKEN: string }\n'
22
+ : 'declare namespace Cloudflare { interface Env { STREAM_ACCOUNT_ID: string; STREAM_API_TOKEN: string } }\n');
23
+ }
24
+ const streamServer = `// Server code only. Never serialize a live input directly to viewers: it contains a publish credential.
25
+ export interface StreamLiveInput {
26
+ uid: string;
27
+ webRTC: { url: string };
28
+ webRTCPlayback: { url: string };
29
+ }
30
+
31
+ function readString(value: unknown): string {
32
+ if (typeof value !== 'string') throw new Error('Stream did not return a WebRTC live input.');
33
+ return value;
34
+ }
35
+
36
+ function readEndpoint(endpoint?: { url?: unknown } | null): { url: string } {
37
+ return { url: readString(endpoint?.url) };
38
+ }
39
+
40
+ function readLiveInput(body: { success?: boolean; result?: Partial<StreamLiveInput> } | null): StreamLiveInput {
41
+ if (body?.success !== true) throw new Error('Stream live input request was unsuccessful.');
42
+ const input = body.result ?? {};
43
+ return { uid: readString(input.uid), webRTC: readEndpoint(input.webRTC), webRTCPlayback: readEndpoint(input.webRTCPlayback) };
44
+ }
45
+
46
+ export function createStream(options: { accountId: string; apiToken: string }) {
47
+ if (!/^[a-f0-9]{32}$/i.test(options.accountId) || !options.apiToken.trim()) {
48
+ throw new Error('Configure server-only STREAM_ACCOUNT_ID and STREAM_API_TOKEN.');
49
+ }
50
+ const base = 'https://api.cloudflare.com/client/v4/accounts/' + options.accountId + '/stream/live_inputs';
51
+ async function request(url: string, init: RequestInit): Promise<StreamLiveInput> {
52
+ const response = await fetch(url, {
53
+ ...init,
54
+ headers: { Authorization: 'Bearer ' + options.apiToken, 'Content-Type': 'application/json' },
55
+ redirect: 'error',
56
+ signal: AbortSignal.timeout(30_000),
57
+ });
58
+ // Do not include provider bodies or URLs in errors: they can contain broadcast credentials.
59
+ if (!response.ok) throw new Error('Stream live input request failed (HTTP ' + response.status + ').');
60
+ const body = await response.json().catch(() => {
61
+ throw new Error('Stream returned an invalid JSON response.');
62
+ }) as { success?: boolean; result?: Partial<StreamLiveInput> } | null;
63
+ return readLiveInput(body);
64
+ }
65
+ return {
66
+ // Call only after creator authorization and quota checks. Persist uid; do not create on every page load.
67
+ // Select playback privacy explicitly. Signed playback still needs application token issuance.
68
+ createLiveInput(input: { name: string; requireSignedURLs: boolean }) {
69
+ if (!input.name.trim() || typeof input.requireSignedURLs !== 'boolean') {
70
+ throw new Error('Supply a stream name and explicit signed-playback policy.');
71
+ }
72
+ return request(base, { method: 'POST', body: JSON.stringify({
73
+ meta: { name: input.name }, recording: { mode: 'off', requireSignedURLs: input.requireSignedURLs },
74
+ }) });
75
+ },
76
+ getLiveInput(uid: string) {
77
+ if (!/^[a-f0-9]{32}$/i.test(uid)) throw new Error('Invalid Stream live input ID.');
78
+ return request(base + '/' + uid, { method: 'GET' });
79
+ },
80
+ };
81
+ }
82
+ `;
83
+ const streamGuide = `# Cloudflare Stream Live WebRTC
84
+
85
+ Optional one-to-many live video using WHIP ingest and WHEP playback. GA since October 15, 2026. This is independent of --realtime Durable Object messaging and --neon-realtime live SQL. For many-to-many calls, review Cloudflare Realtime separately; this package does not scaffold conferencing.
86
+
87
+ ## Server integration
88
+
89
+ Add @workspace/stream as a workspace:* dependency of the server app and import createStream from @workspace/stream/server. Pass { accountId: env.STREAM_ACCOUNT_ID, apiToken: env.STREAM_API_TOKEN }. The factory supports createLiveInput({ name, requireSignedURLs }) and getLiveInput(uid). It returns uid, webRTC.url (secret WHIP ingest) and webRTCPlayback.url (WHEP playback). No browser management client or public management route is generated.
90
+
91
+ Use a customer-owned account with Stream enabled and an account-scoped Stream Write API token. Configure the selected server app's ignored runtime file from its environment example (.env for Void, .dev.vars for Wrangler, .env.local for native Next.js). The root .env.example is an inventory. Configure production secrets explicitly with the selected host; anhedral ship does not activate Stream, create live inputs or install these runtime credentials automatically. There is no Wrangler resource binding for this integration. Never use a public environment prefix for the management token or publish URL.
92
+
93
+ Authorize creators and enforce quotas before creating/retrieving an input. Persist its uid with the owning user/tenant; authorize access before calling getLiveInput. Reuse the input on refresh; reconcile uncertain creates rather than blindly retrying. Return the WHIP URL only to its authorized broadcaster, with Cache-Control: no-store. Anyone possessing it can broadcast. Never return the full input to viewers or put it in logs, committed config, static assets or public build variables. Rotate compromised publish keys through Cloudflare's supported management workflow.
94
+
95
+ Select requireSignedURLs explicitly. For private viewing implement authenticated, short-lived Stream playback token issuance and verify WHEP rejects unsigned, expired and unauthorized access. Hosting protection alone does not protect Cloudflare's media endpoints. Origin restrictions are not user authorization. The helper does not issue playback tokens or establish private media acceptance.
96
+
97
+ ## Browser integration
98
+
99
+ Use native RTCPeerConnection or a Cloudflare-supported WHIP/WHEP client. Follow the official browser tutorial below. Capture camera/microphone only after a user action over HTTPS or localhost; handle denied permissions, device selection and autoplay restrictions. Publish send-only tracks to the authorized WHIP URL; receive audio/video tracks through WHEP. Media flows directly between the browser and Stream, not through a Worker, Durable Object or database. Application routes handle identity, input ownership and authorized endpoint/token issuance.
100
+
101
+ Implement ICE negotiation (including gathering completion or Trickle ICE), failed-connection recovery and bounded retries. Retain the Location session resource from signaling, DELETE it on stop, close RTCPeerConnection and stop local camera/microphone tracks on failure, navigation and sign-out. Implement the player and creator UI for the product; this package is a management foundation, not a finished broadcast feature.
102
+
103
+ ## Limits and acceptance
104
+
105
+ As reviewed October 16, 2026, WHIP ingest and WHEP playback must be paired. Recording, HLS/DASH playback of WHIP inputs, RTMP/SRT-to-WHEP bridging, restreaming and live viewer counts are unsupported. WebRTC usage appears in Stream analytics/billable usage; this does not promise broadcast or player-experience metrics. Delivery billing began October 15 at standard Stream rates; budget viewer-minutes (viewers multiplied by watch time), verify current pricing and account eligibility before activation.
106
+
107
+ Before claiming acceptance, exercise an authorized creator and viewer in separate browsers, denied creator/viewer access, cross-tenant input access, reconnect, camera denial, session teardown and usage visibility. Verify signed playback separately when selected. Scaffolding and local tests do not establish live video, latency or provider readiness.
108
+
109
+ - Release: https://developers.cloudflare.com/changelog/post/2026-10-15-stream-live-webrtc-ga/
110
+ - WebRTC and current limits: https://developers.cloudflare.com/stream/webrtc-beta/
111
+ - Browser tutorial: https://developers.cloudflare.com/stream/examples/browser-based-webrtc/
112
+ - Live input API: https://developers.cloudflare.com/api/resources/stream/subresources/live_inputs/methods/create/
113
+ - Pricing: https://developers.cloudflare.com/stream/pricing/
114
+ `;
@@ -20,14 +20,15 @@ function pinVoidCloudflareAdapter(root) {
20
20
  }
21
21
  /** Fresh-workspace conversion only. Existing applications keep their delivery engine. */
22
22
  export function configureVoidDelivery(root) {
23
- if (existsSync(path.join(root, 'apps/web/open-next.config.ts')))
23
+ if (existsSync(path.join(root, 'apps/web/open-next.config.ts')) ||
24
+ existsSync(path.join(root, 'apps/mobile/worker/index.ts')))
24
25
  return false;
25
26
  for (const app of readdirSync(path.join(root, 'apps'))) {
26
27
  const file = path.join(root, 'apps', app, 'wrangler.jsonc');
27
28
  if (!existsSync(file))
28
29
  continue;
29
30
  const config = readJson(root, `apps/${app}/wrangler.jsonc`);
30
- if (config.queues || config.pipelines)
31
+ if (config.queues || config.pipelines || config.images || config.analytics_engine_datasets)
31
32
  return false;
32
33
  }
33
34
  let configured = false;
@@ -45,7 +46,9 @@ export function configureVoidDelivery(root) {
45
46
  }
46
47
  json(root, `${directory}/anhedral.cloudflare.json`, cloudflare);
47
48
  rmSync(source);
48
- put(root, `${directory}/void.config.ts`, `import { defineConfig } from 'void/config';
49
+ put(root, `${directory}/void.config.ts`, `// Platform tooling requires this per-app declaration; resource bindings remain app-specific.
50
+ // fallow-ignore-file code-duplication
51
+ import { defineConfig } from 'void/config';
49
52
  import declared from './anhedral.cloudflare.json';
50
53
 
51
54
  // Unassigned placeholders are not provider identities. Void records real IDs
@@ -85,7 +88,9 @@ export default defineConfig({
85
88
  put(root, `${directory}/env.example`, '# Copy env.example to .env in this app directory. Void reads one local file per deployable app.\n# Production server values use void secret; VITE_* values must be supplied by the build environment.\n' +
86
89
  [...envKeys].map(([key, value]) => `${key}=${value}`).join('\n') +
87
90
  '\n');
88
- const serverKeys = [...envKeys.keys()].filter((key) => !key.startsWith('NEXT_PUBLIC_') && !key.startsWith('VITE_'));
91
+ const serverKeys = [...envKeys.keys()].filter((key) => !key.startsWith('NEXT_PUBLIC_') &&
92
+ !key.startsWith('VITE_') &&
93
+ !key.startsWith('EXPO_PUBLIC_'));
89
94
  if (app !== 'web' && serverKeys.length) {
90
95
  cloudflare.secrets = { required: serverKeys };
91
96
  json(root, `${directory}/anhedral.cloudflare.json`, cloudflare);
@@ -227,11 +232,14 @@ export function refreshVoidEnvironment(root) {
227
232
  const keys = [...example.matchAll(/^([A-Z][A-Z0-9_]*)=/gm)].map((match) => match[1]);
228
233
  const missing = [...new Set(keys)].filter((key) => !key.startsWith('NEXT_PUBLIC_') &&
229
234
  !key.startsWith('VITE_') &&
235
+ !key.startsWith('EXPO_PUBLIC_') &&
230
236
  !new RegExp(String.raw `\b${key}\s*:`).test(schema));
231
237
  if (app !== 'web' && existsSync(path.join(root, directory, 'anhedral.cloudflare.json'))) {
232
238
  const configFile = `${directory}/anhedral.cloudflare.json`;
233
239
  const config = readJson(root, configFile);
234
- const serverKeys = [...new Set(keys)].filter((key) => !key.startsWith('NEXT_PUBLIC_') && !key.startsWith('VITE_'));
240
+ const serverKeys = [...new Set(keys)].filter((key) => !key.startsWith('NEXT_PUBLIC_') &&
241
+ !key.startsWith('VITE_') &&
242
+ !key.startsWith('EXPO_PUBLIC_'));
235
243
  const secrets = (config.secrets ?? {});
236
244
  config.secrets = {
237
245
  ...secrets,
@@ -1,3 +1,4 @@
1
+ import { scaffoldWebBackend } from './backend.js';
1
2
  import { resourceName } from '../render.js';
2
3
  import { writeEnvironmentFile } from './environment.js';
3
4
  import { STACK_DEPENDENCIES, NEXT_VERCEL_VERSION, NEXT_OPENNEXT_VERSION } from '../dependencies.js';
@@ -125,4 +126,5 @@ export function scaffoldWeb({ root, options, bindings, runtimeApp, has }) {
125
126
  rmSync(path.join(root, 'apps/web', file), { force: true });
126
127
  json(root, 'apps/web/vercel.json', { framework: 'nextjs' });
127
128
  }
129
+ scaffoldWebBackend({ root, options, bindings, runtimeApp, has });
128
130
  }
@@ -73,6 +73,11 @@ function writeTurboConfiguration(root, registry) {
73
73
  ...new Set([
74
74
  ...(turbo.globalEnv ?? []),
75
75
  'VOID_CLOUDFLARE_DEPLOY_BUILD',
76
+ ...(registry.items.some(({ name }) => name === 'expo') ? ['EXPO_PUBLIC_API_URL'] : []),
77
+ ...(registry.items.some(({ name }) => name === 'next') &&
78
+ registry.items.some(({ name }) => name === 'hono')
79
+ ? ['API_URL', 'API_ACCESS_CLIENT_ID', 'API_ACCESS_CLIENT_SECRET']
80
+ : []),
76
81
  'npm_execpath',
77
82
  ...registry.items.flatMap((item) => item.environment),
78
83
  ]),
@@ -244,7 +249,7 @@ process.exitCode = result.status ?? 1;
244
249
  schemaVersion: 1,
245
250
  standard: 'anhedral-application-stack',
246
251
  products: options.products,
247
- hosting: has('next') || has('vinext') ? options.hosting : null,
252
+ hosting: has('next') || has('vinext') || has('expo') ? options.hosting : null,
248
253
  bootstrap: updating
249
254
  ? readProjectSection(root, 'standard').bootstrap
250
255
  : {
@@ -81,7 +81,7 @@ async function d1Query(service, request, sql, params = []) {
81
81
  export async function listServiceTables(service, request) {
82
82
  if (service.kind !== 'd1')
83
83
  throw new Error('Schema browsing is supported for D1 databases.');
84
- const rows = await d1Query(service, request, "SELECT name FROM sqlite_schema WHERE type = 'table' AND name NOT LIKE 'sqlite_%' AND name NOT LIKE '_cf_%' ORDER BY name LIMIT 1001");
84
+ const rows = await d1Query(service, request, "SELECT name FROM sqlite_schema WHERE type = 'table' AND name NOT GLOB 'sqlite_*' AND name NOT GLOB '_cf_*' ORDER BY name LIMIT 1001");
85
85
  if (rows.length > 1000)
86
86
  throw new Error('Database schema exceeds its table limit.');
87
87
  return rows.map((row) => {
@@ -1,19 +1,21 @@
1
1
  import path from 'node:path';
2
+ import { CliArgumentError } from './cli-arguments.js';
2
3
  import { resolveIntegrationService } from './integration-service-readers.js';
3
4
  import { inspectApplication } from './project-inspector.js';
4
5
  import { resolveService, serviceCapabilities, unboundResourceSelectors, } from './service-descriptor.js';
5
6
  import { ServiceDeletionStore } from './service-deletion.js';
6
7
  import { catalogDirectory } from './catalog-registration.js';
7
8
  import { serviceOperation } from './service-operations.js';
9
+ const argumentError = (message) => new CliArgumentError(message, 'Run anhedral services --help.');
8
10
  export async function runServiceCommand(root, input) {
9
11
  const args = input.filter((arg) => arg !== '--json');
10
12
  const action = args.shift();
11
13
  const actions = ['list', 'status', 'metrics', 'tables', 'data', 'delete-plan', 'delete'];
12
14
  if (!action || !actions.includes(action))
13
- throw new Error('Choose a supported services operation.');
15
+ throw argumentError('Choose a supported services operation.');
14
16
  if (action === 'list') {
15
17
  if (args.length)
16
- throw new Error('services list accepts no service selector.');
18
+ throw argumentError('services list accepts no service selector.');
17
19
  const inspection = inspectApplication(root);
18
20
  const keys = [
19
21
  ...inspection.setupProviders.data
@@ -57,14 +59,14 @@ export async function runServiceCommand(root, input) {
57
59
  }
58
60
  const key = args.shift();
59
61
  if (!key || key.startsWith('-') || key.length > 1024)
60
- throw new Error('Choose the exact service key from services list.');
62
+ throw argumentError('Choose the exact service key from services list.');
61
63
  const options = {};
62
64
  for (let i = 0; i < args.length; i += 2) {
63
65
  if (!['--hours', '--table', '--offset', '--token', '--confirm-name', '--cursor'].includes(args[i]) ||
64
66
  options[args[i]] !== undefined ||
65
67
  !args[i + 1] ||
66
68
  args[i + 1].startsWith('-'))
67
- throw new Error('Invalid services options.');
69
+ throw argumentError('Invalid services options.');
68
70
  options[args[i]] = args[i + 1];
69
71
  }
70
72
  const allowed = {
@@ -76,9 +78,9 @@ export async function runServiceCommand(root, input) {
76
78
  delete: ['--token', '--confirm-name'],
77
79
  };
78
80
  if (Object.keys(options).some((option) => !allowed[action].includes(option)))
79
- throw new Error('This services operation does not accept that option.');
81
+ throw argumentError('This services operation does not accept that option.');
80
82
  if (action === 'delete' && (!options['--token'] || !options['--confirm-name']))
81
- throw new Error('Deletion requires its plan token and exact resource name.');
83
+ throw argumentError('Deletion requires its plan token and exact resource name.');
82
84
  const result = await serviceOperation(root, action, key, {
83
85
  hours: options['--hours'] === undefined ? undefined : Number(options['--hours']),
84
86
  table: options['--table'],
package/dist/ship.d.ts CHANGED
@@ -11,7 +11,7 @@ export declare function shipCloudflareApplication(root: string, dryRun?: boolean
11
11
  activated?: true | undefined;
12
12
  nextAction?: string | undefined;
13
13
  projectId: string;
14
- release: import("./delivery.js").Release;
14
+ release: import("./delivery-evidence.js").Release;
15
15
  managementFile: string;
16
16
  productVerification: string;
17
17
  } | ({
@@ -40,7 +40,7 @@ export declare function shipCloudflareApplication(root: string, dryRun?: boolean
40
40
  }>;
41
41
  export declare function shipSelectedVercelApplication(root: string, dryRun?: boolean, run?: DeliveryRunner, send?: typeof fetch, providerEnvironment?: NodeJS.ProcessEnv): Promise<{
42
42
  projectId: string;
43
- release: import("./vercel.js").WebRelease;
43
+ release: import("./vercel-project.js").WebRelease;
44
44
  productVerification: string;
45
45
  } | {
46
46
  integrations: {
@@ -55,7 +55,7 @@ export declare function shipSelectedVercelApplication(root: string, dryRun?: boo
55
55
  mutation: boolean;
56
56
  };
57
57
  mutation: boolean;
58
- project: import("./vercel.js").WebProject;
58
+ project: import("./vercel-project.js").WebProject;
59
59
  checks: string[];
60
60
  deployment: string[];
61
61
  cloudflareServices: string;
@@ -79,19 +79,19 @@ export declare function shipSelectedVercelApplication(root: string, dryRun?: boo
79
79
  }>;
80
80
  /** Each mixed target keeps its own release receipt; this is not a provider transaction. */
81
81
  export declare function shipSelectedStack(root: string, dryRun?: boolean, run?: DeliveryRunner, request?: CloudflareRequest, send?: typeof fetch, providerEnvironment?: NodeJS.ProcessEnv): Promise<{
82
- projectId: string;
83
- release: import("./vercel.js").WebRelease;
84
- productVerification: string;
85
- } | {
86
82
  management: string;
87
83
  state?: "configuration-required" | undefined;
88
84
  deployed?: false | undefined;
89
85
  activated?: true | undefined;
90
86
  nextAction?: string | undefined;
91
87
  projectId: string;
92
- release: import("./delivery.js").Release;
88
+ release: import("./delivery-evidence.js").Release;
93
89
  managementFile: string;
94
90
  productVerification: string;
91
+ } | {
92
+ projectId: string;
93
+ release: import("./vercel-project.js").WebRelease;
94
+ productVerification: string;
95
95
  } | ({
96
96
  project: import("./project-state.js").ApplicationProject;
97
97
  checks: string[][];
@@ -124,7 +124,7 @@ export declare function shipSelectedStack(root: string, dryRun?: boolean, run?:
124
124
  mutation: boolean;
125
125
  };
126
126
  mutation: boolean;
127
- project: import("./vercel.js").WebProject;
127
+ project: import("./vercel-project.js").WebProject;
128
128
  checks: string[];
129
129
  deployment: string[];
130
130
  cloudflareServices: string;
@@ -157,7 +157,7 @@ export declare function shipSelectedStack(root: string, dryRun?: boolean, run?:
157
157
  activated?: true | undefined;
158
158
  nextAction?: string | undefined;
159
159
  projectId: string;
160
- release: import("./delivery.js").Release;
160
+ release: import("./delivery-evidence.js").Release;
161
161
  managementFile: string;
162
162
  productVerification: string;
163
163
  } | {
@@ -188,7 +188,7 @@ export declare function shipSelectedStack(root: string, dryRun?: boolean, run?:
188
188
  activated?: true | undefined;
189
189
  nextAction?: string | undefined;
190
190
  projectId: string;
191
- release: import("./delivery.js").Release;
191
+ release: import("./delivery-evidence.js").Release;
192
192
  managementFile: string;
193
193
  productVerification: string;
194
194
  } | ({
@@ -219,7 +219,7 @@ export declare function shipSelectedStack(root: string, dryRun?: boolean, run?:
219
219
  provider: string;
220
220
  result: {
221
221
  projectId: string;
222
- release: import("./vercel.js").WebRelease;
222
+ release: import("./vercel-project.js").WebRelease;
223
223
  productVerification: string;
224
224
  } | {
225
225
  integrations: {
@@ -234,7 +234,7 @@ export declare function shipSelectedStack(root: string, dryRun?: boolean, run?:
234
234
  mutation: boolean;
235
235
  };
236
236
  mutation: boolean;
237
- project: import("./vercel.js").WebProject;
237
+ project: import("./vercel-project.js").WebProject;
238
238
  checks: string[];
239
239
  deployment: string[];
240
240
  cloudflareServices: string;
@@ -272,7 +272,7 @@ export declare function shipSelectedStack(root: string, dryRun?: boolean, run?:
272
272
  activated?: true | undefined;
273
273
  nextAction?: string | undefined;
274
274
  projectId: string;
275
- release: import("./delivery.js").Release;
275
+ release: import("./delivery-evidence.js").Release;
276
276
  managementFile: string;
277
277
  productVerification: string;
278
278
  } | ({
@@ -327,7 +327,7 @@ export declare function shipSelectedStack(root: string, dryRun?: boolean, run?:
327
327
  audience: "unconfigured" | "public" | "private";
328
328
  provider: string;
329
329
  } | {
330
- project: import("./vercel.js").WebProject;
330
+ project: import("./vercel-project.js").WebProject;
331
331
  checks: string[];
332
332
  deployment: string[];
333
333
  cloudflareServices: string;
package/dist/ship.js CHANGED
@@ -61,7 +61,9 @@ async function executeCloudflareApplication(root, dryRun = false, run = defaultR
61
61
  const environments = mergeRuntimeTargets(runtimeTargets(root, runtime), application);
62
62
  const buildRunner = async (command, args, cwd, env) => {
63
63
  const relative = path.relative(root, cwd).split(path.sep).join('/');
64
- const values = environments[`${relative}/.env`] ?? environments[`${relative}/.dev.vars`];
64
+ const values = environments[`${relative}/.env`] ??
65
+ environments[`${relative}/.dev.vars`] ??
66
+ environments[`${relative}/.env.local`];
65
67
  const environment = runtimeEnvironment(env, values);
66
68
  if (deployment.project.deliveryEngine === 'void' &&
67
69
  command === 'pnpm' &&
@@ -16,9 +16,14 @@ declare const PRODUCT_ITEMS: {
16
16
  r2: ItemDefinition;
17
17
  kv: ItemDefinition;
18
18
  realtime: ItemDefinition;
19
+ stream: ItemDefinition;
19
20
  queues: ItemDefinition;
20
21
  cron: ItemDefinition;
21
22
  workflows: ItemDefinition;
23
+ 'analytics-engine': ItemDefinition;
24
+ images: ItemDefinition;
25
+ realtimekit: ItemDefinition;
26
+ video: ItemDefinition;
22
27
  openai: ItemDefinition;
23
28
  'ai-sdk': ItemDefinition;
24
29
  'workers-ai': ItemDefinition;
@@ -31,7 +36,7 @@ declare const PRODUCT_ITEMS: {
31
36
  styling: ItemDefinition;
32
37
  };
33
38
  export type StandardProduct = keyof typeof PRODUCT_ITEMS;
34
- export declare const STANDARD_PRODUCTS: readonly ("next" | "queues" | "basin" | "vinext" | "hono" | "realtime" | "cron" | "workflows" | "electron" | "wxt" | "expo" | "styling" | "neon" | "d1" | "neon-realtime" | "local-data" | "clerk" | "better-auth" | "r2" | "kv" | "openai" | "ai-sdk" | "workers-ai" | "resend" | "stripe" | "revenuecat" | "sentry" | "posthog")[];
39
+ export declare const STANDARD_PRODUCTS: readonly ("next" | "electron" | "wxt" | "expo" | "vinext" | "realtime" | "workflows" | "styling" | "hono" | "neon" | "d1" | "neon-realtime" | "local-data" | "clerk" | "better-auth" | "r2" | "kv" | "stream" | "queues" | "cron" | "analytics-engine" | "images" | "realtimekit" | "video" | "openai" | "ai-sdk" | "workers-ai" | "resend" | "stripe" | "revenuecat" | "sentry" | "basin" | "posthog")[];
35
40
  declare const DEFINITIONS: {
36
41
  vinext: ItemDefinition;
37
42
  next: ItemDefinition;
@@ -48,9 +53,14 @@ declare const DEFINITIONS: {
48
53
  r2: ItemDefinition;
49
54
  kv: ItemDefinition;
50
55
  realtime: ItemDefinition;
56
+ stream: ItemDefinition;
51
57
  queues: ItemDefinition;
52
58
  cron: ItemDefinition;
53
59
  workflows: ItemDefinition;
60
+ 'analytics-engine': ItemDefinition;
61
+ images: ItemDefinition;
62
+ realtimekit: ItemDefinition;
63
+ video: ItemDefinition;
54
64
  openai: ItemDefinition;
55
65
  'ai-sdk': ItemDefinition;
56
66
  'workers-ai': ItemDefinition;
@@ -64,12 +74,13 @@ declare const DEFINITIONS: {
64
74
  workspace: ItemDefinition;
65
75
  typescript: ItemDefinition;
66
76
  eslint: ItemDefinition;
77
+ 'cloudflare-api': ItemDefinition;
67
78
  ui: ItemDefinition;
68
79
  };
69
80
  export type StackItemId = keyof typeof DEFINITIONS;
70
81
  export declare function getStackDefinition(name: string): ItemDefinition;
71
82
  export declare function getStackItem(name: string): StackRegistryItem;
72
- export declare const STACK_ITEMS: Record<"next" | "queues" | "basin" | "vinext" | "hono" | "realtime" | "cron" | "workflows" | "electron" | "eslint" | "typescript" | "wxt" | "expo" | "ui" | "workspace" | "styling" | "neon" | "d1" | "neon-realtime" | "local-data" | "clerk" | "better-auth" | "r2" | "kv" | "openai" | "ai-sdk" | "workers-ai" | "resend" | "stripe" | "revenuecat" | "sentry" | "posthog", StackRegistryItem>;
83
+ export declare const STACK_ITEMS: Record<"next" | "electron" | "eslint" | "typescript" | "wxt" | "expo" | "vinext" | "realtime" | "workflows" | "ui" | "workspace" | "styling" | "hono" | "neon" | "d1" | "neon-realtime" | "local-data" | "clerk" | "better-auth" | "r2" | "kv" | "stream" | "queues" | "cron" | "analytics-engine" | "images" | "realtimekit" | "cloudflare-api" | "video" | "openai" | "ai-sdk" | "workers-ai" | "resend" | "stripe" | "revenuecat" | "sentry" | "basin" | "posthog", StackRegistryItem>;
73
84
  export declare const STACK_REGISTRY: {
74
85
  schemaVersion: number;
75
86
  name: string;