@happyvertical/smrt-app-runtime 0.51.31 → 0.51.33

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.
@@ -0,0 +1,122 @@
1
+ /**
2
+ * Application-side composition for public self-hosted and managed-cloud
3
+ * runtimes. Provider credentials and vendor clients remain in their owning
4
+ * adapters; this module validates the selected seams, owns the PostgreSQL
5
+ * connection lifecycle, and exposes orchestration-safe diagnostics.
6
+ */
7
+ import { type ApplicationRuntimeProfile, type AssetStorageProvider, type AuthenticationProvider, type ResolvedApplicationRuntime, type RuntimeProviderOverrides, type SecretProvider } from '@happyvertical/smrt-config';
8
+ import { ScheduleRunner, type ScheduleRunnerConfig, TaskRunner, type TaskRunnerConfig } from '@happyvertical/smrt-jobs';
9
+ import { SessionService } from '@happyvertical/smrt-users';
10
+ import type { DatabaseInterface } from '@happyvertical/sql';
11
+ export type DeployedApplicationRuntimeProfile = Exclude<ApplicationRuntimeProfile, 'local'>;
12
+ export type PublicAuthenticationProvider = Exclude<AuthenticationProvider, 'owner-bootstrap'>;
13
+ export type DeployedRuntimeComponent = 'database' | 'authentication' | 'assets' | 'secrets';
14
+ /**
15
+ * A provider-owned readiness boundary.
16
+ *
17
+ * The callback should prove that required configuration is present and that
18
+ * the provider is usable. It must not return credentials or secret values.
19
+ */
20
+ export interface DeployedProviderBinding<Provider extends string> {
21
+ readonly provider: Provider;
22
+ readonly readiness: () => Promise<void>;
23
+ }
24
+ /** PostgreSQL connection factory. URLs and credentials stay in this adapter. */
25
+ export interface DeployedDatabaseBinding {
26
+ readonly engine: 'postgres';
27
+ readonly connect: () => Promise<DatabaseInterface>;
28
+ readonly readiness?: (db: DatabaseInterface) => Promise<void>;
29
+ /**
30
+ * Provider-owned cleanup boundary, required before a connection is opened.
31
+ * Keeping cleanup on the binding also covers malformed connection handles.
32
+ */
33
+ readonly close: (db: DatabaseInterface) => Promise<void>;
34
+ }
35
+ export interface DeployedApplicationRuntimeOptions {
36
+ readonly profile: DeployedApplicationRuntimeProfile;
37
+ /** Validated selector overrides; never put credentials in this object. */
38
+ readonly providers?: RuntimeProviderOverrides;
39
+ readonly database: DeployedDatabaseBinding;
40
+ readonly authentication: DeployedProviderBinding<PublicAuthenticationProvider>;
41
+ readonly assets: DeployedProviderBinding<AssetStorageProvider>;
42
+ readonly secrets: DeployedProviderBinding<SecretProvider>;
43
+ /** Explicit, idempotent application migration hook. */
44
+ readonly prepareDatabase?: (db: DatabaseInterface) => Promise<void>;
45
+ }
46
+ export interface DeployedProviderDiagnostic {
47
+ readonly provider: string;
48
+ readonly configured: true;
49
+ }
50
+ export interface DeployedRuntimeDiagnostics {
51
+ readonly schemaVersion: 1;
52
+ readonly runtime: ResolvedApplicationRuntime;
53
+ readonly providers: {
54
+ readonly database: DeployedProviderDiagnostic;
55
+ readonly authentication: DeployedProviderDiagnostic;
56
+ readonly assets: DeployedProviderDiagnostic;
57
+ readonly secrets: DeployedProviderDiagnostic;
58
+ };
59
+ readonly tenancy: {
60
+ readonly mode: 'single-tenant' | 'multi-tenant';
61
+ readonly context: 'defaulted' | 'required';
62
+ readonly isolation: 'application' | 'database-rls';
63
+ readonly rootTenantFallback: 'disabled';
64
+ };
65
+ readonly workers: {
66
+ readonly topology: 'external' | 'scalable';
67
+ readonly taskProcess: 'separate';
68
+ readonly scheduleProcess: 'separate';
69
+ readonly replicas: 'operator-managed' | 'horizontal';
70
+ };
71
+ readonly secretValuesIncluded: false;
72
+ }
73
+ export interface DeployedRuntimeHealth {
74
+ readonly schemaVersion: 1;
75
+ readonly profile: DeployedApplicationRuntimeProfile;
76
+ readonly status: 'healthy' | 'stopped';
77
+ }
78
+ export interface DeployedComponentReadiness {
79
+ readonly status: 'ready' | 'not-ready';
80
+ }
81
+ export interface DeployedRuntimeReadiness {
82
+ readonly schemaVersion: 1;
83
+ readonly profile: DeployedApplicationRuntimeProfile;
84
+ readonly status: 'ready' | 'not-ready';
85
+ readonly components: Readonly<Record<DeployedRuntimeComponent, DeployedComponentReadiness>>;
86
+ readonly secretValuesIncluded: false;
87
+ }
88
+ export type DeployedRuntimeErrorCode = 'invalid_configuration' | 'provider_mismatch' | 'provider_unavailable' | 'tenant_context_required' | 'tenant_context_unauthorized' | 'runtime_stopped';
89
+ /** Stable failure that never includes a provider's underlying error text. */
90
+ export declare class DeployedRuntimeError extends Error {
91
+ readonly code: DeployedRuntimeErrorCode;
92
+ readonly component?: DeployedRuntimeComponent | undefined;
93
+ constructor(code: DeployedRuntimeErrorCode, message: string, component?: DeployedRuntimeComponent | undefined);
94
+ }
95
+ /** Startup failure that retains the only safe retry path for database cleanup. */
96
+ export declare class DeployedRuntimeCleanupError extends DeployedRuntimeError {
97
+ private readonly cleanup;
98
+ private cleaned;
99
+ private cleanupAttempt?;
100
+ constructor(cleanup: () => Promise<void>);
101
+ retryCleanup(): Promise<void>;
102
+ }
103
+ export interface DeployedApplicationRuntime {
104
+ readonly db: DatabaseInterface;
105
+ readonly resolvedRuntime: ResolvedApplicationRuntime;
106
+ restoreSession(sessionId: string): ReturnType<SessionService['loadSessionContext']>;
107
+ createTaskWorker(config?: TaskRunnerConfig): Promise<TaskRunner>;
108
+ createScheduleWorker(config?: ScheduleRunnerConfig): Promise<ScheduleRunner>;
109
+ diagnostics(): DeployedRuntimeDiagnostics;
110
+ health(): DeployedRuntimeHealth;
111
+ readiness(): Promise<DeployedRuntimeReadiness>;
112
+ close(): Promise<void>;
113
+ }
114
+ /**
115
+ * Initialize a self-hosted or cloud application composition.
116
+ *
117
+ * Configuration and provider identity are validated before a connection is
118
+ * opened. Provider readiness and database migrations complete before the
119
+ * runtime is returned. A failed initialization closes the acquired connection.
120
+ */
121
+ export declare function initializeDeployedApplicationRuntime(options: DeployedApplicationRuntimeOptions): Promise<DeployedApplicationRuntime>;
122
+ //# sourceMappingURL=deployed-runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deployed-runtime.d.ts","sourceRoot":"","sources":["../src/deployed-runtime.ts"],"names":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4B,SAAQ,oBAAoB;IAIvD,OAAO,CAAC,QAAQ,CAAC,OAAO;IAHpC,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,cAAc,CAAC,CAAgB;gBAEV,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC;IASnD,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;CAiBpC;AAED,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,EAAE,EAAE,iBAAiB,CAAC;IAC/B,QAAQ,CAAC,eAAe,EAAE,0BAA0B,CAAC;IACrD,cAAc,CACZ,SAAS,EAAE,MAAM,GAChB,UAAU,CAAC,cAAc,CAAC,oBAAoB,CAAC,CAAC,CAAC;IACpD,gBAAgB,CAAC,MAAM,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACjE,oBAAoB,CAAC,MAAM,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAC7E,WAAW,IAAI,0BAA0B,CAAC;IAC1C,MAAM,IAAI,qBAAqB,CAAC;IAChC,SAAS,IAAI,OAAO,CAAC,wBAAwB,CAAC,CAAC;IAC/C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AASD;;;;;;GAMG;AACH,wBAAsB,oCAAoC,CACxD,OAAO,EAAE,iCAAiC,GACzC,OAAO,CAAC,0BAA0B,CAAC,CA0DrC"}
package/dist/index.d.ts CHANGED
@@ -1,394 +1,173 @@
1
- import { ApplicationRuntimeProfile } from '@happyvertical/smrt-config';
2
- import { AssetStorageProvider } from '@happyvertical/smrt-config';
3
- import { AuthenticationProvider } from '@happyvertical/smrt-config';
4
- import { DatabaseInterface } from '@happyvertical/sql';
5
- import { ResolvedApplicationRuntime } from '@happyvertical/smrt-config';
6
- import { RuntimeProviderOverrides } from '@happyvertical/smrt-config';
7
- import { ScheduleRunner } from '@happyvertical/smrt-jobs';
8
- import { ScheduleRunnerConfig } from '@happyvertical/smrt-jobs';
9
- import { SecretProvider } from '@happyvertical/smrt-config';
10
- import { SessionService } from '@happyvertical/smrt-users';
11
- import { TaskRunner } from '@happyvertical/smrt-jobs';
12
- import { TaskRunnerConfig } from '@happyvertical/smrt-jobs';
13
-
14
- declare const CAPABILITY_IDS: readonly ["asset-storage", "authentication", "background-jobs", "database", "paid-capabilities", "secret-storage"];
15
-
16
- declare type CapabilityId = (typeof CAPABILITY_IDS)[number];
17
-
18
- declare type CapabilityStatus = 'available' | 'disabled' | 'unavailable' | 'unknown';
19
-
20
- export declare interface ClaimLocalOwnerInput {
21
- token: string;
22
- name: string;
23
- email: string;
24
- tenantName?: string;
25
- userAgent?: string;
26
- ipAddress?: string;
27
- }
28
-
29
- export declare interface DeployedApplicationRuntime {
30
- readonly db: DatabaseInterface;
31
- readonly resolvedRuntime: ResolvedApplicationRuntime;
32
- restoreSession(sessionId: string): ReturnType<SessionService['loadSessionContext']>;
33
- createTaskWorker(config?: TaskRunnerConfig): Promise<TaskRunner>;
34
- createScheduleWorker(config?: ScheduleRunnerConfig): Promise<ScheduleRunner>;
35
- diagnostics(): DeployedRuntimeDiagnostics;
36
- health(): DeployedRuntimeHealth;
37
- readiness(): Promise<DeployedRuntimeReadiness>;
38
- close(): Promise<void>;
39
- }
40
-
41
- export declare interface DeployedApplicationRuntimeOptions {
42
- readonly profile: DeployedApplicationRuntimeProfile;
43
- /** Validated selector overrides; never put credentials in this object. */
44
- readonly providers?: RuntimeProviderOverrides;
45
- readonly database: DeployedDatabaseBinding;
46
- readonly authentication: DeployedProviderBinding<PublicAuthenticationProvider>;
47
- readonly assets: DeployedProviderBinding<AssetStorageProvider>;
48
- readonly secrets: DeployedProviderBinding<SecretProvider>;
49
- /** Explicit, idempotent application migration hook. */
50
- readonly prepareDatabase?: (db: DatabaseInterface) => Promise<void>;
51
- }
52
-
53
- export declare type DeployedApplicationRuntimeProfile = Exclude<ApplicationRuntimeProfile, 'local'>;
54
-
55
- export declare interface DeployedComponentReadiness {
56
- readonly status: 'ready' | 'not-ready';
57
- }
58
-
59
- /** PostgreSQL connection factory. URLs and credentials stay in this adapter. */
60
- export declare interface DeployedDatabaseBinding {
61
- readonly engine: 'postgres';
62
- readonly connect: () => Promise<DatabaseInterface>;
63
- readonly readiness?: (db: DatabaseInterface) => Promise<void>;
64
- /**
65
- * Provider-owned cleanup boundary, required before a connection is opened.
66
- * Keeping cleanup on the binding also covers malformed connection handles.
67
- */
68
- readonly close: (db: DatabaseInterface) => Promise<void>;
69
- }
70
-
71
- /**
72
- * A provider-owned readiness boundary.
73
- *
74
- * The callback should prove that required configuration is present and that
75
- * the provider is usable. It must not return credentials or secret values.
76
- */
77
- export declare interface DeployedProviderBinding<Provider extends string> {
78
- readonly provider: Provider;
79
- readonly readiness: () => Promise<void>;
80
- }
81
-
82
- export declare interface DeployedProviderDiagnostic {
83
- readonly provider: string;
84
- readonly configured: true;
85
- }
86
-
87
- /** Startup failure that retains the only safe retry path for database cleanup. */
88
- export declare class DeployedRuntimeCleanupError extends DeployedRuntimeError {
89
- private readonly cleanup;
90
- private cleaned;
91
- private cleanupAttempt?;
92
- constructor(cleanup: () => Promise<void>);
93
- retryCleanup(): Promise<void>;
94
- }
95
-
96
- export declare type DeployedRuntimeComponent = 'database' | 'authentication' | 'assets' | 'secrets';
97
-
98
- export declare interface DeployedRuntimeDiagnostics {
99
- readonly schemaVersion: 1;
100
- readonly runtime: ResolvedApplicationRuntime;
101
- readonly providers: {
102
- readonly database: DeployedProviderDiagnostic;
103
- readonly authentication: DeployedProviderDiagnostic;
104
- readonly assets: DeployedProviderDiagnostic;
105
- readonly secrets: DeployedProviderDiagnostic;
106
- };
107
- readonly tenancy: {
108
- readonly mode: 'single-tenant' | 'multi-tenant';
109
- readonly context: 'defaulted' | 'required';
110
- readonly isolation: 'application' | 'database-rls';
111
- readonly rootTenantFallback: 'disabled';
112
- };
113
- readonly workers: {
114
- readonly topology: 'external' | 'scalable';
115
- readonly taskProcess: 'separate';
116
- readonly scheduleProcess: 'separate';
117
- readonly replicas: 'operator-managed' | 'horizontal';
118
- };
119
- readonly secretValuesIncluded: false;
120
- }
121
-
122
- /** Stable failure that never includes a provider's underlying error text. */
123
- export declare class DeployedRuntimeError extends Error {
124
- readonly code: DeployedRuntimeErrorCode;
125
- readonly component?: DeployedRuntimeComponent | undefined;
126
- constructor(code: DeployedRuntimeErrorCode, message: string, component?: DeployedRuntimeComponent | undefined);
127
- }
128
-
129
- export declare type DeployedRuntimeErrorCode = 'invalid_configuration' | 'provider_mismatch' | 'provider_unavailable' | 'tenant_context_required' | 'tenant_context_unauthorized' | 'runtime_stopped';
130
-
131
- export declare interface DeployedRuntimeHealth {
132
- readonly schemaVersion: 1;
133
- readonly profile: DeployedApplicationRuntimeProfile;
134
- readonly status: 'healthy' | 'stopped';
135
- }
136
-
137
- export declare interface DeployedRuntimeReadiness {
138
- readonly schemaVersion: 1;
139
- readonly profile: DeployedApplicationRuntimeProfile;
140
- readonly status: 'ready' | 'not-ready';
141
- readonly components: Readonly<Record<DeployedRuntimeComponent, DeployedComponentReadiness>>;
142
- readonly secretValuesIncluded: false;
143
- }
144
-
145
- /** Encode a package/project identity into a collision-resistant runtime ID. */
146
- export declare function encodeApplicationId(value: string): string;
147
-
148
- declare const ERROR_CODES: readonly ["authentication_unavailable", "database_unavailable", "migration_required", "provider_unavailable", "runtime_stopped", "worker_stale"];
149
-
150
- /**
151
- * Initialize a self-hosted or cloud application composition.
152
- *
153
- * Configuration and provider identity are validated before a connection is
154
- * opened. Provider readiness and database migrations complete before the
155
- * runtime is returned. A failed initialization closes the acquired connection.
156
- */
157
- export declare function initializeDeployedApplicationRuntime(options: DeployedApplicationRuntimeOptions): Promise<DeployedApplicationRuntime>;
158
-
159
- /**
160
- * Initialize or reopen a local application runtime.
161
- *
162
- * A plaintext bootstrap token is returned only when this call creates a new
163
- * invitation. Existing unexpired invitations remain valid but cannot be read
164
- * back because only their HMAC is stored.
165
- */
166
- export declare function initializeLocalApplicationRuntime(options: LocalApplicationRuntimeOptions): Promise<LocalRuntimeInitialization>;
167
-
168
- /** Initialized local runtime used by server startup and onboarding handlers. */
169
- export declare interface LocalApplicationRuntime {
170
- readonly db: DatabaseInterface;
171
- readonly paths: LocalRuntimePaths;
172
- readonly bindHost: string;
173
- readonly resolvedRuntime: ResolvedApplicationRuntime;
174
- readonly backgroundJobsEnabled: boolean;
175
- readonly paidCapabilitiesEnabled: boolean;
176
- ensureBootstrapInvitation(): Promise<LocalOwnerBootstrapInvitation | null>;
177
- rotateBootstrapInvitation(): Promise<LocalOwnerBootstrapInvitation>;
178
- claimOwner(input: ClaimLocalOwnerInput): Promise<LocalOwnerClaimResult>;
179
- restoreSession(sessionId: string): ReturnType<SessionService['loadSessionContext']>;
180
- createEmbeddedJobRunner(config?: TaskRunnerConfig): Promise<TaskRunner>;
181
- diagnostics(): Promise<LocalRuntimeDiagnostics>;
182
- }
183
-
184
- export declare interface LocalApplicationRuntimeOptions extends ResolveLocalRuntimePathsOptions {
185
- /** Actual HTTP bind host. Owner bootstrap refuses non-loopback values. */
186
- bindHost?: string;
187
- /**
188
- * Explicit application migration/schema hook, invoked before identity access.
189
- * It must be idempotent; runtime code never synthesizes application tables.
190
- */
191
- prepareDatabase?: (db: DatabaseInterface) => Promise<void>;
192
- /** Local profile provider overrides (only validated local combinations survive). */
193
- providers?: RuntimeProviderOverrides;
194
- /** Short-lived bootstrap token lifetime. Range: 1..900 seconds. */
195
- bootstrapTtlSeconds?: number;
196
- /** Normal authenticated session lifetime in whole seconds. Minimum 1. */
197
- sessionTtlSeconds?: number;
198
- /** Explicit opt-in for persisted background work. Default false. */
199
- backgroundJobs?: boolean;
200
- /** Explicit opt-in for application-defined paid capabilities. Default false. */
201
- paidCapabilities?: boolean;
202
- /** Testable clock. */
203
- now?: () => Date;
204
- }
205
-
206
- export declare type LocalBootstrapStatus = 'available' | 'expired' | 'claimed' | 'unavailable';
207
-
208
- export declare interface LocalOwnerBootstrapInvitation {
209
- /** Plaintext is returned exactly when a new claim is issued; it is never persisted. */
210
- readonly token: string;
211
- readonly expiresAt: string;
212
- }
213
-
214
- export declare interface LocalOwnerClaimResult {
215
- readonly profileId: string;
216
- readonly userId: string;
217
- readonly tenantId: string;
218
- readonly membershipId: string;
219
- readonly sessionId: string;
220
- }
221
-
222
- /** Secret-free, machine-readable local runtime state. */
223
- export declare interface LocalRuntimeDiagnostics {
224
- readonly schemaVersion: 1;
225
- readonly runtime: ResolvedApplicationRuntime;
226
- readonly bind: {
227
- readonly host: string;
228
- readonly loopback: true;
229
- };
230
- readonly paths: LocalRuntimePaths;
231
- readonly storage: {
232
- readonly database: 'sqlite-file';
233
- readonly assets: 'user-owned-directory';
234
- readonly secrets: 'mode-0600-local-file';
235
- };
236
- readonly bootstrap: {
237
- readonly status: LocalBootstrapStatus;
238
- readonly expiresAt: string | null;
239
- readonly tokenValuesIncluded: false;
240
- readonly tokenHashesIncluded: false;
241
- };
242
- readonly tenancy: {
243
- readonly mode: 'real-default-tenant';
244
- readonly ui: 'hidden';
245
- };
246
- readonly jobs: {
247
- readonly topology: 'inline' | 'embedded';
248
- readonly backgroundEnabled: boolean;
249
- };
250
- readonly paidCapabilitiesEnabled: boolean;
251
- readonly secretValuesIncluded: false;
252
- }
253
-
254
- /** Stable, secret-free local-runtime failure. */
255
- export declare class LocalRuntimeError extends Error {
256
- readonly code: LocalRuntimeErrorCode;
257
- constructor(code: LocalRuntimeErrorCode, message: string);
258
- }
259
-
260
- export declare type LocalRuntimeErrorCode = 'bootstrap_claimed' | 'bootstrap_expired' | 'bootstrap_invalid' | 'bootstrap_unavailable' | 'capability_disabled' | 'invalid_configuration' | 'migration_failed' | 'unsafe_public_exposure';
261
-
262
- export declare interface LocalRuntimeInitialization {
263
- readonly runtime: LocalApplicationRuntime;
264
- readonly bootstrap: LocalOwnerBootstrapInvitation | null;
265
- readonly diagnostics: LocalRuntimeDiagnostics;
266
- }
267
-
268
- /** Paths owned by the local user, outside the source tree by default. */
269
- export declare interface LocalRuntimePaths {
270
- readonly root: string;
271
- readonly database: string;
272
- readonly assets: string;
273
- readonly secrets: string;
274
- readonly applicationSecret: string;
275
- }
276
-
277
- export declare const MAX_RUNTIME_DIAGNOSTIC_ERRORS = 8;
278
-
279
- export declare const MAX_RUNTIME_DIAGNOSTIC_TOOLS = 64;
280
-
281
- /**
282
- * Fixed, secret-free surface for a failed application migration.
283
- *
284
- * A migration driver message is a likely carrier of a connection string,
285
- * credential, filesystem path, or environment value, so the caller's text is
286
- * never surfaced. The original error is retained as a non-enumerable `cause`
287
- * for private logs only.
288
- */
289
- export declare const MIGRATION_FAILED_MESSAGE = "The application migration step failed; run pnpm app:setup and inspect the private migration logs.";
290
-
291
- /**
292
- * Claim the secure local database root before a standalone migration command
293
- * opens SQLite. This does not create application schema or bootstrap records.
294
- */
295
- export declare function prepareLocalDatabaseStorage(options: ResolveLocalRuntimePathsOptions): Promise<LocalRuntimePaths>;
296
-
297
- /**
298
- * Project private local/deployed state into the deterministic public contract.
299
- * Unknown, oversized, nested, accessor-backed, or prohibited values are never
300
- * copied. Invalid error codes become `runtime_error` at ingestion.
301
- */
302
- export declare function projectRuntimeDiagnostics(input: RuntimeDiagnosticsProjectionInput): RuntimeDiagnostics;
303
-
304
- export declare type PublicAuthenticationProvider = Exclude<AuthenticationProvider, 'owner-bootstrap'>;
305
-
306
- /**
307
- * Resolve deterministic user-owned paths and reject source-tree placement.
308
- */
309
- export declare function resolveLocalRuntimePaths(options: ResolveLocalRuntimePathsOptions): LocalRuntimePaths;
310
-
311
- export declare interface ResolveLocalRuntimePathsOptions {
312
- /** Stable application identifier, e.g. `lolaus`. */
313
- appId: string;
314
- /** Explicit user-owned data directory. Defaults to the OS application-data directory. */
315
- dataDirectory?: string;
316
- /** Source checkout to protect from accidental data placement. Defaults to cwd. */
317
- sourceRoot?: string;
318
- /** Testable default-root and filesystem case-sensitivity override. */
319
- platform?: NodeJS.Platform;
320
- /** Testable home-directory override. */
321
- homeDirectory?: string;
322
- /** Testable environment override. */
323
- env?: NodeJS.ProcessEnv;
324
- }
325
-
326
- export declare const RUNTIME_DIAGNOSTICS_SCHEMA_VERSION: 1;
327
-
328
- export declare const RUNTIME_WORKER_FRESHNESS_SECONDS = 120;
329
-
330
- declare type RuntimeDiagnosticErrorCode = (typeof ERROR_CODES)[number] | 'runtime_error';
331
-
332
- /**
333
- * Versioned public diagnostics returned only after application authorization.
334
- * Every field is a fixed allowlist projection; this is intentionally not a
335
- * cleaned or serialized form of either private runtime diagnostics object.
336
- */
337
- export declare interface RuntimeDiagnostics {
338
- readonly schemaVersion: 1;
339
- readonly profile: ApplicationRuntimeProfile | 'unknown';
340
- readonly health: 'healthy' | 'degraded' | 'stopped' | 'unknown';
341
- readonly schema: {
342
- readonly status: 'ready' | 'not-ready' | 'unknown';
343
- readonly migrations: 'current' | 'failed' | 'pending' | 'unknown';
344
- };
345
- readonly capabilities: readonly {
346
- readonly id: CapabilityId;
347
- readonly status: CapabilityStatus;
348
- }[];
349
- readonly tools: {
350
- readonly names: readonly string[];
351
- readonly count: number;
352
- readonly digest: string;
353
- };
354
- readonly operationalDifferences: {
355
- readonly backgroundJobs: 'disabled' | 'enabled';
356
- readonly workerTopology: WorkerTopology;
357
- };
358
- readonly worker: {
359
- readonly topology: WorkerTopology;
360
- readonly liveness: 'alive' | 'not-required' | 'stale' | 'unknown';
361
- readonly heartbeatAt: string | null;
362
- readonly observedAt: string;
363
- };
364
- readonly recentErrors: readonly {
365
- readonly code: RuntimeDiagnosticErrorCode;
366
- readonly at: string;
367
- }[];
368
- }
369
-
370
- export declare interface RuntimeDiagnosticsProjectionInput {
371
- readonly profile?: unknown;
372
- readonly health?: unknown;
373
- readonly schema?: unknown;
374
- readonly capabilities?: unknown;
375
- readonly toolNames?: unknown;
376
- readonly worker?: unknown;
377
- readonly recentErrors?: unknown;
378
- /** Required explicit clock seam; the projector never reads the process clock. */
379
- readonly observedAt?: unknown;
380
- }
381
-
382
- /** Validate an explicit runtime identity. */
383
- export declare function validateApplicationId(value: string): string;
384
-
385
- /**
386
- * Verify an already-initialized local database root without creating or
387
- * changing any filesystem/database artifact. Operator read/copy/import paths
388
- * use this boundary before opening SQLite outside the runtime bootstrap.
389
- */
390
- export declare function validateLocalDatabaseStorage(options: ResolveLocalRuntimePathsOptions): Promise<LocalRuntimePaths>;
391
-
392
- declare type WorkerTopology = 'embedded' | 'external' | 'inline' | 'scalable';
393
-
394
- export { }
1
+ /**
2
+ * Safe, private, single-owner application runtime for the `local` profile.
3
+ *
4
+ * This Node-only subpath owns the small amount of operational composition that
5
+ * does not belong in a generated application: user-owned paths, restrictive
6
+ * local secret material, SQLite tuning, owner bootstrap, and an optional
7
+ * embedded job runner. Domain schema preparation remains an explicit startup
8
+ * step supplied by the application migration layer.
9
+ */
10
+ import { type ResolvedApplicationRuntime, type RuntimeProviderOverrides } from '@happyvertical/smrt-config';
11
+ import { TaskRunner, type TaskRunnerConfig } from '@happyvertical/smrt-jobs';
12
+ import { SessionService } from '@happyvertical/smrt-users';
13
+ import { type DatabaseInterface } from '@happyvertical/sql';
14
+ export * from './deployed-runtime.js';
15
+ export * from './runtime-diagnostics.js';
16
+ /** Paths owned by the local user, outside the source tree by default. */
17
+ export interface LocalRuntimePaths {
18
+ readonly root: string;
19
+ readonly database: string;
20
+ readonly assets: string;
21
+ readonly secrets: string;
22
+ readonly applicationSecret: string;
23
+ }
24
+ export interface ResolveLocalRuntimePathsOptions {
25
+ /** Stable application identifier, e.g. `lolaus`. */
26
+ appId: string;
27
+ /** Explicit user-owned data directory. Defaults to the OS application-data directory. */
28
+ dataDirectory?: string;
29
+ /** Source checkout to protect from accidental data placement. Defaults to cwd. */
30
+ sourceRoot?: string;
31
+ /** Testable default-root and filesystem case-sensitivity override. */
32
+ platform?: NodeJS.Platform;
33
+ /** Testable home-directory override. */
34
+ homeDirectory?: string;
35
+ /** Testable environment override. */
36
+ env?: NodeJS.ProcessEnv;
37
+ }
38
+ export interface LocalApplicationRuntimeOptions extends ResolveLocalRuntimePathsOptions {
39
+ /** Actual HTTP bind host. Owner bootstrap refuses non-loopback values. */
40
+ bindHost?: string;
41
+ /**
42
+ * Explicit application migration/schema hook, invoked before identity access.
43
+ * It must be idempotent; runtime code never synthesizes application tables.
44
+ */
45
+ prepareDatabase?: (db: DatabaseInterface) => Promise<void>;
46
+ /** Local profile provider overrides (only validated local combinations survive). */
47
+ providers?: RuntimeProviderOverrides;
48
+ /** Short-lived bootstrap token lifetime. Range: 1..900 seconds. */
49
+ bootstrapTtlSeconds?: number;
50
+ /** Normal authenticated session lifetime in whole seconds. Minimum 1. */
51
+ sessionTtlSeconds?: number;
52
+ /** Explicit opt-in for persisted background work. Default false. */
53
+ backgroundJobs?: boolean;
54
+ /** Explicit opt-in for application-defined paid capabilities. Default false. */
55
+ paidCapabilities?: boolean;
56
+ /** Testable clock. */
57
+ now?: () => Date;
58
+ }
59
+ /**
60
+ * Claim the secure local database root before a standalone migration command
61
+ * opens SQLite. This does not create application schema or bootstrap records.
62
+ */
63
+ export declare function prepareLocalDatabaseStorage(options: ResolveLocalRuntimePathsOptions): Promise<LocalRuntimePaths>;
64
+ /**
65
+ * Verify an already-initialized local database root without creating or
66
+ * changing any filesystem/database artifact. Operator read/copy/import paths
67
+ * use this boundary before opening SQLite outside the runtime bootstrap.
68
+ */
69
+ export declare function validateLocalDatabaseStorage(options: ResolveLocalRuntimePathsOptions): Promise<LocalRuntimePaths>;
70
+ export interface LocalOwnerBootstrapInvitation {
71
+ /** Plaintext is returned exactly when a new claim is issued; it is never persisted. */
72
+ readonly token: string;
73
+ readonly expiresAt: string;
74
+ }
75
+ export interface LocalRuntimeInitialization {
76
+ readonly runtime: LocalApplicationRuntime;
77
+ readonly bootstrap: LocalOwnerBootstrapInvitation | null;
78
+ readonly diagnostics: LocalRuntimeDiagnostics;
79
+ }
80
+ export interface ClaimLocalOwnerInput {
81
+ token: string;
82
+ name: string;
83
+ email: string;
84
+ tenantName?: string;
85
+ userAgent?: string;
86
+ ipAddress?: string;
87
+ }
88
+ export interface LocalOwnerClaimResult {
89
+ readonly profileId: string;
90
+ readonly userId: string;
91
+ readonly tenantId: string;
92
+ readonly membershipId: string;
93
+ readonly sessionId: string;
94
+ }
95
+ export type LocalBootstrapStatus = 'available' | 'expired' | 'claimed' | 'unavailable';
96
+ /** Secret-free, machine-readable local runtime state. */
97
+ export interface LocalRuntimeDiagnostics {
98
+ readonly schemaVersion: 1;
99
+ readonly runtime: ResolvedApplicationRuntime;
100
+ readonly bind: {
101
+ readonly host: string;
102
+ readonly loopback: true;
103
+ };
104
+ readonly paths: LocalRuntimePaths;
105
+ readonly storage: {
106
+ readonly database: 'sqlite-file';
107
+ readonly assets: 'user-owned-directory';
108
+ readonly secrets: 'mode-0600-local-file';
109
+ };
110
+ readonly bootstrap: {
111
+ readonly status: LocalBootstrapStatus;
112
+ readonly expiresAt: string | null;
113
+ readonly tokenValuesIncluded: false;
114
+ readonly tokenHashesIncluded: false;
115
+ };
116
+ readonly tenancy: {
117
+ readonly mode: 'real-default-tenant';
118
+ readonly ui: 'hidden';
119
+ };
120
+ readonly jobs: {
121
+ readonly topology: 'inline' | 'embedded';
122
+ readonly backgroundEnabled: boolean;
123
+ };
124
+ readonly paidCapabilitiesEnabled: boolean;
125
+ readonly secretValuesIncluded: false;
126
+ }
127
+ export type LocalRuntimeErrorCode = 'bootstrap_claimed' | 'bootstrap_expired' | 'bootstrap_invalid' | 'bootstrap_unavailable' | 'capability_disabled' | 'invalid_configuration' | 'migration_failed' | 'unsafe_public_exposure';
128
+ /**
129
+ * Fixed, secret-free surface for a failed application migration.
130
+ *
131
+ * A migration driver message is a likely carrier of a connection string,
132
+ * credential, filesystem path, or environment value, so the caller's text is
133
+ * never surfaced. The original error is retained as a non-enumerable `cause`
134
+ * for private logs only.
135
+ */
136
+ export declare const MIGRATION_FAILED_MESSAGE = "The application migration step failed; run pnpm app:setup and inspect the private migration logs.";
137
+ /** Stable, secret-free local-runtime failure. */
138
+ export declare class LocalRuntimeError extends Error {
139
+ readonly code: LocalRuntimeErrorCode;
140
+ constructor(code: LocalRuntimeErrorCode, message: string);
141
+ }
142
+ /**
143
+ * Resolve deterministic user-owned paths and reject source-tree placement.
144
+ */
145
+ export declare function resolveLocalRuntimePaths(options: ResolveLocalRuntimePathsOptions): LocalRuntimePaths;
146
+ /**
147
+ * Initialize or reopen a local application runtime.
148
+ *
149
+ * A plaintext bootstrap token is returned only when this call creates a new
150
+ * invitation. Existing unexpired invitations remain valid but cannot be read
151
+ * back because only their HMAC is stored.
152
+ */
153
+ export declare function initializeLocalApplicationRuntime(options: LocalApplicationRuntimeOptions): Promise<LocalRuntimeInitialization>;
154
+ /** Initialized local runtime used by server startup and onboarding handlers. */
155
+ export interface LocalApplicationRuntime {
156
+ readonly db: DatabaseInterface;
157
+ readonly paths: LocalRuntimePaths;
158
+ readonly bindHost: string;
159
+ readonly resolvedRuntime: ResolvedApplicationRuntime;
160
+ readonly backgroundJobsEnabled: boolean;
161
+ readonly paidCapabilitiesEnabled: boolean;
162
+ ensureBootstrapInvitation(): Promise<LocalOwnerBootstrapInvitation | null>;
163
+ rotateBootstrapInvitation(): Promise<LocalOwnerBootstrapInvitation>;
164
+ claimOwner(input: ClaimLocalOwnerInput): Promise<LocalOwnerClaimResult>;
165
+ restoreSession(sessionId: string): ReturnType<SessionService['loadSessionContext']>;
166
+ createEmbeddedJobRunner(config?: TaskRunnerConfig): Promise<TaskRunner>;
167
+ diagnostics(): Promise<LocalRuntimeDiagnostics>;
168
+ }
169
+ /** Validate an explicit runtime identity. */
170
+ export declare function validateApplicationId(value: string): string;
171
+ /** Encode a package/project identity into a collision-resistant runtime ID. */
172
+ export declare function encodeApplicationId(value: string): string;
173
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAoBH,OAAO,EACL,KAAK,0BAA0B,EAC/B,KAAK,wBAAwB,EAE9B,MAAM,4B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M,GAAG,MAAM,CAS3D;AAED,+EAA+E;AAC/E,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAczD"}
@@ -2,7 +2,7 @@
2
2
  "version": "1.0.0",
3
3
  "timestamp": 0,
4
4
  "packageName": "@happyvertical/smrt-app-runtime",
5
- "packageVersion": "0.51.31",
5
+ "packageVersion": "0.51.33",
6
6
  "objects": {},
7
7
  "moduleType": "smrt",
8
8
  "smrtDependencies": [
@@ -0,0 +1,67 @@
1
+ import type { ApplicationRuntimeProfile } from '@happyvertical/smrt-config';
2
+ export declare const RUNTIME_DIAGNOSTICS_SCHEMA_VERSION: 1;
3
+ export declare const MAX_RUNTIME_DIAGNOSTIC_TOOLS = 64;
4
+ export declare const MAX_RUNTIME_DIAGNOSTIC_ERRORS = 8;
5
+ export declare const RUNTIME_WORKER_FRESHNESS_SECONDS = 120;
6
+ declare const CAPABILITY_IDS: readonly ["asset-storage", "authentication", "background-jobs", "database", "paid-capabilities", "secret-storage"];
7
+ declare const ERROR_CODES: readonly ["authentication_unavailable", "database_unavailable", "migration_required", "provider_unavailable", "runtime_stopped", "worker_stale"];
8
+ type CapabilityId = (typeof CAPABILITY_IDS)[number];
9
+ type CapabilityStatus = 'available' | 'disabled' | 'unavailable' | 'unknown';
10
+ type RuntimeDiagnosticErrorCode = (typeof ERROR_CODES)[number] | 'runtime_error';
11
+ type WorkerTopology = 'embedded' | 'external' | 'inline' | 'scalable';
12
+ /**
13
+ * Versioned public diagnostics returned only after application authorization.
14
+ * Every field is a fixed allowlist projection; this is intentionally not a
15
+ * cleaned or serialized form of either private runtime diagnostics object.
16
+ */
17
+ export interface RuntimeDiagnostics {
18
+ readonly schemaVersion: 1;
19
+ readonly profile: ApplicationRuntimeProfile | 'unknown';
20
+ readonly health: 'healthy' | 'degraded' | 'stopped' | 'unknown';
21
+ readonly schema: {
22
+ readonly status: 'ready' | 'not-ready' | 'unknown';
23
+ readonly migrations: 'current' | 'failed' | 'pending' | 'unknown';
24
+ };
25
+ readonly capabilities: readonly {
26
+ readonly id: CapabilityId;
27
+ readonly status: CapabilityStatus;
28
+ }[];
29
+ readonly tools: {
30
+ readonly names: readonly string[];
31
+ readonly count: number;
32
+ readonly digest: string;
33
+ };
34
+ readonly operationalDifferences: {
35
+ readonly backgroundJobs: 'disabled' | 'enabled';
36
+ readonly workerTopology: WorkerTopology;
37
+ };
38
+ readonly worker: {
39
+ readonly topology: WorkerTopology;
40
+ readonly liveness: 'alive' | 'not-required' | 'stale' | 'unknown';
41
+ readonly heartbeatAt: string | null;
42
+ readonly observedAt: string;
43
+ };
44
+ readonly recentErrors: readonly {
45
+ readonly code: RuntimeDiagnosticErrorCode;
46
+ readonly at: string;
47
+ }[];
48
+ }
49
+ export interface RuntimeDiagnosticsProjectionInput {
50
+ readonly profile?: unknown;
51
+ readonly health?: unknown;
52
+ readonly schema?: unknown;
53
+ readonly capabilities?: unknown;
54
+ readonly toolNames?: unknown;
55
+ readonly worker?: unknown;
56
+ readonly recentErrors?: unknown;
57
+ /** Required explicit clock seam; the projector never reads the process clock. */
58
+ readonly observedAt?: unknown;
59
+ }
60
+ /**
61
+ * Project private local/deployed state into the deterministic public contract.
62
+ * Unknown, oversized, nested, accessor-backed, or prohibited values are never
63
+ * copied. Invalid error codes become `runtime_error` at ingestion.
64
+ */
65
+ export declare function projectRuntimeDiagnostics(input: RuntimeDiagnosticsProjectionInput): RuntimeDiagnostics;
66
+ export {};
67
+ //# sourceMappingURL=runtime-diagnostics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-diagnostics.d.ts","sourceRoot":"","sources":["../src/runtime-diagnostics.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAE5E,eAAO,MAAM,kCAAkC,EAAG,CAAU,CAAC;AAC7D,eAAO,MAAM,4BAA4B,KAAK,CAAC;AAC/C,eAAO,MAAM,6BAA6B,IAAI,CAAC;AAC/C,eA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GAAG,SAAS,CAAC;QAChD,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;KACzC,CAAC;IACF,QAAQ,CAAC,MAAM,EAAE;QACf,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;QAClC,QAAQ,CAAC,QAAQ,EAAE,OAAO,GAAG,cAAc,GAAG,OAAO,GAAG,SAAS,CAAC;QAClE,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;QACpC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;KAC7B,CAAC;IACF,QAAQ,CAAC,YAAY,EAAE,SAAS;QAC9B,QAAQ,CAAC,IAAI,EAAE,0BAA0B,CAAC;QAC1C,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;KACrB,EAAE,CAAC;CACL;AAED,MAAM,WAAW,iCAAiC;IAChD,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC;IAChC,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC;IAChC,iFAAiF;IACjF,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,iCAAiC,GACvC,kBAAkB,CAmCpB"}
@@ -3,12 +3,12 @@
3
3
  "sensitiveFieldsExcluded": true,
4
4
  "generatedAt": "1970-01-01T00:00:00.000Z",
5
5
  "packageName": "@happyvertical/smrt-app-runtime",
6
- "packageVersion": "0.51.31",
6
+ "packageVersion": "0.51.33",
7
7
  "sourceManifestPath": "dist/manifest.json",
8
8
  "agentDocPath": "AGENTS.md",
9
9
  "sourceHashes": {
10
- "manifest": "b509c150cfbc61f57a261c1b51c86f8adbc9bffe857ca6a2e4b924ef8b50454a",
11
- "packageJson": "e7f8deaed07536bb2fbd5f8c2db04f5e6f77e1765fca476434632e96cf8b78d5",
10
+ "manifest": "bf904ecc41773498b5c98c418296e3e5fa8922394ba57fb43b6b3ea6ac5a054f",
11
+ "packageJson": "b593168b379c1cfe4de3e4a34229b89efc5bd733ea9102fe696945b03c2cda3e",
12
12
  "agents": "d8202c6d897a78eaf23c048682bd922899605e7ddad595c1341be65544b7000b"
13
13
  },
14
14
  "exports": [
@@ -24,7 +24,7 @@
24
24
  "@happyvertical/sql": "catalog:",
25
25
  "@happyvertical/smrt-vitest": "workspace:*",
26
26
  "@types/node": "24.13.6",
27
- "typescript": "5.9.3",
27
+ "typescript": "6.0.3",
28
28
  "vite": "8.1.4",
29
29
  "vitest": "4.1.10"
30
30
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@happyvertical/smrt-app-runtime",
3
- "version": "0.51.31",
3
+ "version": "0.51.33",
4
4
  "description": "Validated local, self-hosted, and cloud runtime composition for s-m-r-t applications",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -17,18 +17,18 @@
17
17
  "AGENTS.md"
18
18
  ],
19
19
  "dependencies": {
20
- "@happyvertical/smrt-config": "0.51.31",
21
- "@happyvertical/smrt-core": "0.51.31",
22
- "@happyvertical/smrt-jobs": "0.51.31",
23
- "@happyvertical/smrt-profiles": "0.51.31",
24
- "@happyvertical/smrt-tenancy": "0.51.31",
25
- "@happyvertical/smrt-users": "0.51.31",
20
+ "@happyvertical/smrt-config": "0.51.33",
21
+ "@happyvertical/smrt-core": "0.51.33",
22
+ "@happyvertical/smrt-jobs": "0.51.33",
23
+ "@happyvertical/smrt-profiles": "0.51.33",
24
+ "@happyvertical/smrt-tenancy": "0.51.33",
25
+ "@happyvertical/smrt-users": "0.51.33",
26
26
  "@happyvertical/sql": "^0.94.1"
27
27
  },
28
28
  "devDependencies": {
29
- "@happyvertical/smrt-vitest": "0.51.31",
29
+ "@happyvertical/smrt-vitest": "0.51.33",
30
30
  "@types/node": "24.13.6",
31
- "typescript": "5.9.3",
31
+ "typescript": "6.0.3",
32
32
  "vite": "8.1.4",
33
33
  "vitest": "4.1.10"
34
34
  },