@ultrst-armada/kloks 2.0.3 → 2.0.5

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 (81) hide show
  1. package/package.json +6 -1
  2. package/packages/backend/dist/api/index.js +2 -1
  3. package/packages/backend/dist/{chunk-5F5V7NAG.js → chunk-5Y7K7HAT.js} +4 -1
  4. package/packages/backend/dist/{chunk-SQKG3S6P.js → chunk-AUNIGE6Q.js} +2 -2
  5. package/packages/backend/dist/chunk-BRNWUIH5.js +197 -0
  6. package/packages/backend/dist/{chunk-NY2SQOXI.js → chunk-CDRHYO44.js} +4 -1
  7. package/packages/backend/dist/{chunk-ZBNSK26X.js → chunk-CV55JMT7.js} +6 -5
  8. package/packages/backend/dist/{chunk-OWMQLML7.js → chunk-EMSSTOOK.js} +33 -2
  9. package/packages/backend/dist/chunk-FSOOAU6G.js +1132 -0
  10. package/packages/backend/dist/chunk-GVMVYC6C.js +0 -0
  11. package/packages/backend/dist/chunk-I6T64MLT.js +171 -0
  12. package/packages/backend/dist/chunk-ICVDGH2I.js +889 -0
  13. package/packages/backend/dist/chunk-IP6XWQU2.js +48 -0
  14. package/packages/backend/dist/chunk-IRNQXVYA.js +746 -0
  15. package/packages/backend/dist/{chunk-POLVHTHJ.js → chunk-KCPQWJBO.js} +4 -1
  16. package/packages/backend/dist/chunk-LC6ULEM2.js +125 -0
  17. package/packages/backend/dist/{chunk-NTKUQVCQ.js → chunk-LMUMMVTU.js} +14 -2
  18. package/packages/backend/dist/chunk-LMY6MGFD.js +78 -0
  19. package/packages/backend/dist/{chunk-OQRQCDS6.js → chunk-TRJVVNO7.js} +2 -2
  20. package/packages/backend/dist/{chunk-KPLDYX5Z.js → chunk-TRP76UR2.js} +33 -26
  21. package/packages/backend/dist/{chunk-FK3OAUXM.js → chunk-WYEVA4RC.js} +4 -2
  22. package/packages/backend/dist/{chunk-Z6G32NQQ.js → chunk-XKUWLO2M.js} +12 -9
  23. package/packages/backend/dist/{chunk-OXEP3AP6.js → chunk-Z2CT2MJ2.js} +158 -1
  24. package/packages/backend/dist/control-plane/index.js +3 -1
  25. package/packages/backend/dist/core/b2DirectCore.test.d.ts +1 -0
  26. package/packages/backend/dist/core/cloudflareIntegrationCore.test.d.ts +1 -0
  27. package/packages/backend/dist/core/googleDriveOAuthCore.d.ts +51 -0
  28. package/packages/backend/dist/core/googleDriveOAuthCore.test.d.ts +1 -0
  29. package/packages/backend/dist/core/index.d.ts +3 -0
  30. package/packages/backend/dist/core/storageConnectionCore.d.ts +136 -0
  31. package/packages/backend/dist/core/storageConnectionCore.test.d.ts +1 -0
  32. package/packages/backend/dist/core/storageConnectionRuntimeCore.d.ts +57 -0
  33. package/packages/backend/dist/core/storageConnectionRuntimeCore.test.d.ts +1 -0
  34. package/packages/backend/dist/core/storageContracts.d.ts +77 -0
  35. package/packages/backend/dist/core/storageProviderRegistry.d.ts +7 -0
  36. package/packages/backend/dist/core/systemCredentialsCore.d.ts +46 -0
  37. package/packages/backend/dist/core/unifiedDb.d.ts +12 -2
  38. package/packages/backend/dist/core/unifiedDb.errors.test.d.ts +1 -0
  39. package/packages/backend/dist/core/unifiedDbNodeAdapter.d.ts +6 -0
  40. package/packages/backend/dist/core/workspaceBucketSyncCore.d.ts +3 -4
  41. package/packages/backend/dist/core/workspaceBucketSyncCore.test.d.ts +1 -0
  42. package/packages/backend/dist/core/workspaceCore.d.ts +25 -6
  43. package/packages/backend/dist/core/workspaceDataCore.test.d.ts +1 -0
  44. package/packages/backend/dist/core/workspaceFileCore.d.ts +25 -7
  45. package/packages/backend/dist/core/workspaceFileCore.test.d.ts +1 -0
  46. package/packages/backend/dist/core/workspaceFileNodeAdapter.d.ts +6 -0
  47. package/packages/backend/dist/core/workspaceStorageDetailsCore.d.ts +4 -8
  48. package/packages/backend/dist/core/workspaceStorageDetailsCore.test.d.ts +1 -0
  49. package/packages/backend/dist/development/index.js +1 -1
  50. package/packages/backend/dist/development/playwrightInspectionService.js +1 -1
  51. package/packages/backend/dist/development/playwrightInspectionSupport.d.ts +1 -0
  52. package/packages/backend/dist/index.js +22 -16
  53. package/packages/backend/dist/krnl-services.d.ts +0 -22
  54. package/packages/backend/dist/krnl-services.js +8 -19
  55. package/packages/backend/dist/krnl-services.node.d.ts +28 -0
  56. package/packages/backend/dist/node.d.ts +3 -0
  57. package/packages/backend/dist/node.js +645 -463
  58. package/packages/backend/dist/resolver/index.js +13 -0
  59. package/packages/backend/dist/resolver/systemDatabaseUrl.d.ts +16 -12
  60. package/packages/backend/dist/services/node.js +12 -10
  61. package/packages/backend/dist/srkl/index.js +6 -4
  62. package/packages/backend/dist/storage/B2DirectClient.d.ts +7 -13
  63. package/packages/backend/dist/storage/B2DirectClient.test.d.ts +1 -0
  64. package/packages/backend/dist/storage/GoogleDriveWorkspaceService.d.ts +5 -0
  65. package/packages/backend/dist/storage/index.js +4 -3
  66. package/packages/backend/dist/storage/node.js +7 -6
  67. package/packages/backend/dist/storage-workspace.js +1 -1
  68. package/packages/backend/dist/workspace/index.js +2 -1
  69. package/packages/backend/dist/workspace/node.js +12 -7
  70. package/packages/backend/dist/workspaceFileCore-UURQPP62.js +28 -0
  71. package/packages/backend/package.json +8 -3
  72. package/packages/services/dist/index.js +8 -2
  73. package/packages/state-graph/dist/browser.js +16 -16
  74. package/packages/state-graph/dist/index.js +16 -16
  75. package/packages/backend/dist/chunk-4QEMALXF.js +0 -90
  76. package/packages/backend/dist/chunk-AOZSDRNY.js +0 -159
  77. package/packages/backend/dist/chunk-GYSZ6CAX.js +0 -19
  78. package/packages/backend/dist/chunk-JCMB7BIM.js +0 -211
  79. package/packages/backend/dist/chunk-JGUWYVOL.js +0 -570
  80. package/packages/backend/dist/chunk-LMOM7CST.js +0 -427
  81. package/packages/state-graph/dist/{chunk-UKTICGGV.js → chunk-YUJC367F.js} +3 -3
@@ -0,0 +1,136 @@
1
+ /**
2
+ * @file storageConnectionCore.ts
3
+ * @description Fetch-native user storage connection registry.
4
+ *
5
+ * User-owned connection records remain compatible with the existing
6
+ * app_profiles.srkl.storage_connections shape. Secrets are read only by
7
+ * server-side operations; all list/create/test results use an allow-list
8
+ * projection with opaque connection IDs.
9
+ */
10
+ import { GoogleDriveWorkspaceService, type GoogleDriveWorkspaceFolder, type GoogleDriveWorkspaceTokens } from '../storage/GoogleDriveWorkspaceService.js';
11
+ export type StorageProviderId = 'backblaze_b2' | 'google_drive';
12
+ export interface StorageProviderCapability {
13
+ id: StorageProviderId;
14
+ displayName: string;
15
+ enabled: boolean;
16
+ availabilityReason?: string;
17
+ canSelectExistingConnection: boolean;
18
+ canCreateConnection: boolean;
19
+ requiredConfigurationFields: string[];
20
+ authorizationMode: 'application_key' | 'oauth2';
21
+ discoveryCapabilities: {
22
+ accounts: boolean;
23
+ buckets: boolean;
24
+ folders: boolean;
25
+ };
26
+ }
27
+ export interface PublicStorageConnection {
28
+ id: string;
29
+ provider: string;
30
+ label: string;
31
+ role?: 'primary' | 'redundant_clone';
32
+ enabled?: boolean;
33
+ createdAt?: string;
34
+ updatedAt?: string;
35
+ testedAt?: string;
36
+ testStatus?: string;
37
+ latencyMs?: number;
38
+ b2BucketName?: string;
39
+ bucketName?: string;
40
+ b2Region?: string;
41
+ b2Endpoint?: string;
42
+ googleEmail?: string;
43
+ googleAccountId?: string;
44
+ googleRootFolderId?: string;
45
+ googleRootFolderName?: string;
46
+ }
47
+ type StorageQuery = (sql: string, params?: unknown[]) => Promise<{
48
+ rows: Array<Record<string, any>>;
49
+ }>;
50
+ export declare function toPublicStorageConnection(raw: Record<string, any>): PublicStorageConnection | null;
51
+ /** Internal server-only connection resolution for storage engines; never expose through HTTP. */
52
+ export declare function listUserStorageConnectionsWithSecrets(userId: string, query?: StorageQuery): Promise<Record<string, any>[]>;
53
+ /** Set the primary marker/** Set the primary marker without changing an existing workspace's explicit association. */
54
+ export declare function setPrimaryUserStorageConnection(userId: string, connectionId: string, query?: StorageQuery): Promise<PublicStorageConnection[]>;
55
+ /** Delete only unreferenced connections; workspace associations must never become dangling. */
56
+ export declare function deleteUserStorageConnection(userId: string, connectionId: string, query?: StorageQuery): Promise<PublicStorageConnection[]>;
57
+ /** Browser-safe list of all existing connections owned by a verified user. */
58
+ export declare function listUserStorageConnections(userId: string, query?: StorageQuery): Promise<PublicStorageConnection[]>;
59
+ /** Server-only credential resolver. Never return this object from an HTTP API. */
60
+ export declare function resolveUserStorageConnectionSecret(userId: string, connectionId?: string, query?: StorageQuery, provider?: string): Promise<Record<string, any> | null>;
61
+ /**
62
+ * Resolve the persisted workspace association for an owner-bound connection.
63
+ * The folder prefix is a lookup constraint only; the returned workspace data
64
+ * is sourced from the saved user profile and is never constructed from caller
65
+ * supplied storage roots.
66
+ */
67
+ export declare function resolveUserWorkspaceStorageAssociation(userId: string, connectionId: string, folderPrefix: string, query?: StorageQuery): Promise<Record<string, any> | null>;
68
+ export declare function testBackblazeCredentials(keyId: string, applicationKey: string): Promise<{
69
+ success: boolean;
70
+ accountId?: string;
71
+ buckets: Array<{
72
+ id: string;
73
+ name: string;
74
+ type?: string;
75
+ }>;
76
+ error?: string;
77
+ }>;
78
+ /** Validate credentials and bucket access before persisting the user-owned connection. */
79
+ export declare function createBackblazeStorageConnection(input: {
80
+ userId: string;
81
+ label?: string;
82
+ keyId: string;
83
+ applicationKey: string;
84
+ bucketName: string;
85
+ region?: string;
86
+ endpoint?: string;
87
+ }, query?: StorageQuery): Promise<PublicStorageConnection>;
88
+ /** List buckets for a saved connection without returning its credentials. */
89
+ export declare function listBackblazeBucketsForConnection(userId: string, connectionId: string, query?: StorageQuery): Promise<Array<{
90
+ id: string;
91
+ name: string;
92
+ type?: string;
93
+ }>>;
94
+ export interface GoogleDriveSystemOAuthConfiguration {
95
+ clientId: string;
96
+ clientSecret: string;
97
+ redirectUri: string;
98
+ stateSecret: string;
99
+ allowedReturnOrigins: string[];
100
+ }
101
+ /** Resolve system-owned Google OAuth configuration from the canonical system credential record. */
102
+ export declare function getSystemGoogleOAuthConfiguration(query?: StorageQuery): Promise<GoogleDriveSystemOAuthConfiguration>;
103
+ /** Only capability metadata is exposed; client secrets stay in the system credential store. */
104
+ export declare function getStorageProviderCapabilities(query?: StorageQuery): Promise<StorageProviderCapability[]>;
105
+ /** Persist an exchanged or refreshed Google token set against the verified owner. */
106
+ export declare function persistGoogleDriveTokens(userId: string, connectionId: string, tokens: GoogleDriveWorkspaceTokens, query?: StorageQuery): Promise<PublicStorageConnection>;
107
+ /** Construct a server-only Fetch-based Drive client for an owned connection. */
108
+ export declare function createGoogleDriveWorkspaceClient(userId: string, connectionId: string, query?: StorageQuery, rootFolderId?: string): Promise<GoogleDriveWorkspaceService>;
109
+ /** Complete the system-configured OAuth exchange and save the resulting user connection. */
110
+ export declare function completeGoogleDriveAuthorization(userId: string, code: string, query?: StorageQuery): Promise<PublicStorageConnection>;
111
+ /** List Drive folders after verifying that the connection belongs to this user. */
112
+ export declare function listGoogleDriveFoldersForConnection(userId: string, connectionId: string, parentFolderId?: string, query?: StorageQuery): Promise<GoogleDriveWorkspaceFolder[]>;
113
+ /** Validate and persist the selected Drive root against the user-owned connection. */
114
+ export declare function selectGoogleDriveRootFolder(userId: string, connectionId: string, folderId: string, query?: StorageQuery): Promise<GoogleDriveWorkspaceFolder>;
115
+ /** Server-only Google Drive file operations; secrets and tokens remain in the user connection. */
116
+ export declare function testGoogleDriveConnectionForUser(userId: string, connectionId: string, query?: StorageQuery): Promise<{
117
+ success: boolean;
118
+ latencyMs: number;
119
+ error?: string;
120
+ email?: string;
121
+ }>;
122
+ export declare function writeGoogleDriveFileForConnection(userId: string, connectionId: string, path: string, data: string | Uint8Array, contentType?: string, query?: StorageQuery): Promise<void>;
123
+ export declare function readGoogleDriveFileForConnection(userId: string, connectionId: string, path: string, query?: StorageQuery): Promise<Uint8Array | null>;
124
+ export declare function deleteGoogleDriveFileForConnection(userId: string, connectionId: string, path: string, query?: StorageQuery): Promise<void>;
125
+ export declare function listGoogleDriveFilesForConnection(userId: string, connectionId: string, path?: string, query?: StorageQuery): Promise<Array<{
126
+ path: string;
127
+ size: number;
128
+ modifiedAt: number;
129
+ isFolder?: boolean;
130
+ }>>;
131
+ /** Return the authenticated user's Google account identity without exposing OAuth tokens. */
132
+ export declare function getGoogleDriveAccountIdentityForUser(userId: string, connectionId: string, query?: StorageQuery): Promise<{
133
+ accountId: string;
134
+ email?: string;
135
+ }>;
136
+ export {};
@@ -0,0 +1,57 @@
1
+ /**
2
+ * @file storageConnectionRuntimeCore.ts
3
+ * @description Server-side workspace file operations against user-owned
4
+ * storage connections. Connection secrets never cross this service boundary.
5
+ */
6
+ export declare function writeUserWorkspaceStorageFile(input: {
7
+ userId: string;
8
+ connectionId: string;
9
+ folderPrefix: string;
10
+ relativePath: string;
11
+ content: string | Uint8Array;
12
+ contentType?: string;
13
+ bucketName?: string;
14
+ rootFolderId?: string;
15
+ env?: Record<string, unknown>;
16
+ }): Promise<{
17
+ success: true;
18
+ }>;
19
+ export declare function readUserWorkspaceStorageFile(input: {
20
+ userId: string;
21
+ connectionId: string;
22
+ folderPrefix: string;
23
+ relativePath: string;
24
+ bucketName?: string;
25
+ rootFolderId?: string;
26
+ env?: Record<string, unknown>;
27
+ }): Promise<Uint8Array | null>;
28
+ export declare function deleteUserWorkspaceStorageFile(input: {
29
+ userId: string;
30
+ connectionId: string;
31
+ folderPrefix: string;
32
+ relativePath: string;
33
+ bucketName?: string;
34
+ rootFolderId?: string;
35
+ env?: Record<string, unknown>;
36
+ }): Promise<boolean>;
37
+ export declare function listUserWorkspaceStorageFiles(input: {
38
+ userId: string;
39
+ connectionId: string;
40
+ folderPrefix: string;
41
+ subPrefix?: string;
42
+ bucketName?: string;
43
+ rootFolderId?: string;
44
+ env?: Record<string, unknown>;
45
+ }): Promise<Array<{
46
+ fileName: string;
47
+ sizeBytes: number;
48
+ uploadTimestamp?: number;
49
+ }>>;
50
+ export declare function deleteUserWorkspaceStorageFolder(input: {
51
+ userId: string;
52
+ connectionId: string;
53
+ folderPrefix: string;
54
+ bucketName?: string;
55
+ rootFolderId?: string;
56
+ env?: Record<string, unknown>;
57
+ }): Promise<void>;
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Canonical storage provider and user-owned connection contracts.
3
+ * Secrets are server-only fields and are never part of StorageConnectionPublic.
4
+ */
5
+ export type StorageProviderId = 'local_fs' | 'backblaze_b2' | 'google_drive' | 'cloudflare_r2' | 'aws_s3';
6
+ export type StorageAuthorizationMode = 'none' | 'credentials' | 'oauth2';
7
+ export interface StorageConfigurationField {
8
+ id: string;
9
+ label: string;
10
+ type: 'text' | 'password' | 'email';
11
+ required: boolean;
12
+ secret?: boolean;
13
+ placeholder?: string;
14
+ }
15
+ export interface StorageProviderCapability {
16
+ id: StorageProviderId;
17
+ displayName: string;
18
+ description: string;
19
+ enabled: boolean;
20
+ unavailableReason?: string;
21
+ canSelectExistingConnection: boolean;
22
+ canCreateConnection: boolean;
23
+ authorizationMode: StorageAuthorizationMode;
24
+ configurationFields: StorageConfigurationField[];
25
+ supportsAccountDiscovery: boolean;
26
+ supportsBucketDiscovery: boolean;
27
+ supportsFolderDiscovery: boolean;
28
+ }
29
+ export interface StorageConnectionPublic {
30
+ id: string;
31
+ provider: StorageProviderId;
32
+ label: string;
33
+ role?: 'primary' | 'redundant_clone';
34
+ enabled: boolean;
35
+ createdAt: string;
36
+ updatedAt?: string;
37
+ testedAt?: string;
38
+ testStatus?: 'ok' | 'error';
39
+ latencyMs?: number;
40
+ bucketName?: string;
41
+ b2BucketName?: string;
42
+ b2Region?: string;
43
+ b2Endpoint?: string;
44
+ bucketNames?: string[];
45
+ googleEmail?: string;
46
+ googleAccountId?: string;
47
+ googleRootFolderId?: string;
48
+ googleRootFolderName?: string;
49
+ authorizationState?: 'connected' | 'expired' | 'pending' | 'error';
50
+ metadata?: Record<string, unknown>;
51
+ }
52
+ export interface BackblazeBucketInfo {
53
+ bucketId: string;
54
+ bucketName: string;
55
+ bucketType?: string;
56
+ accountId?: string;
57
+ }
58
+ export interface GoogleDriveConnectionTokens {
59
+ accessToken: string;
60
+ refreshToken?: string;
61
+ expiresAt?: number;
62
+ tokenType?: string;
63
+ }
64
+ /** Internal-only shape. Never return this from an HTTP/browser-facing operation. */
65
+ export interface StorageConnectionInternal extends StorageConnectionPublic {
66
+ b2KeyId?: string;
67
+ b2ApplicationKey?: string;
68
+ accessKeyId?: string;
69
+ secretAccessKey?: string;
70
+ r2AccessKeyId?: string;
71
+ r2SecretAccessKey?: string;
72
+ s3AccessKeyId?: string;
73
+ s3SecretAccessKey?: string;
74
+ googleAccessToken?: string;
75
+ googleAccessTokenExpiresAt?: number;
76
+ googleRefreshToken?: string;
77
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Canonical storage provider registry. Application UIs consume these
3
+ * capabilities instead of maintaining provider allow-lists of their own.
4
+ */
5
+ import type { StorageProviderCapability } from './storageContracts.js';
6
+ import { type SystemQuery } from './systemCredentialsCore.js';
7
+ export declare function getStorageProviderCapabilities(queryDb: SystemQuery): Promise<StorageProviderCapability[]>;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * System-owned provider configuration reader.
3
+ * Reads the existing ultrst-credentials record; user OAuth tokens live elsewhere.
4
+ */
5
+ export type SystemQuery = (sql: string, params?: unknown[]) => Promise<{
6
+ rows: any[];
7
+ rowCount?: number;
8
+ }>;
9
+ export interface SystemCredentialsRecord {
10
+ id: string;
11
+ credentials: Record<string, any>;
12
+ created_at?: string;
13
+ updated_at?: string;
14
+ }
15
+ export interface GoogleDriveOAuthConfiguration {
16
+ clientId: string;
17
+ clientSecret: string;
18
+ redirectUri: string;
19
+ stateSecret: string;
20
+ allowedReturnOrigins: string[];
21
+ }
22
+ /** Read the existing system record without DDL, inserts, or other bootstrap writes. */
23
+ export declare function readSystemCredentialsRecord(queryDb: SystemQuery, targetId?: string): Promise<SystemCredentialsRecord>;
24
+ /** Keep the existing system credential table/schema; do not introduce app-specific env variables. */
25
+ export declare function getSystemCredentialsRecord(queryDb: SystemQuery, targetId?: string): Promise<SystemCredentialsRecord>;
26
+ /**
27
+ * Provider configuration is system-owned. This helper never reads a user's
28
+ * Google tokens and is intended for server-side service operations only.
29
+ */
30
+ export declare function getGoogleDriveOAuthConfiguration(queryDb: SystemQuery): Promise<GoogleDriveOAuthConfiguration>;
31
+ /** Resolve an already-installed wrapping key. Decryption must never mint a replacement. */
32
+ export declare function getStorageConnectionEncryptionKey(queryDb: SystemQuery): Promise<string>;
33
+ /**
34
+ * System-owned AES-256 wrapping key for user-scoped storage provider secrets.
35
+ * Existing keys are never silently replaced: doing so would make already
36
+ * encrypted connections irrecoverable. The SQL update merges only this nested
37
+ * key into the latest JSONB row, so concurrent OAuth/config writes are retained.
38
+ *
39
+ * Rotation is deliberately not automatic. A future rotation must retain the
40
+ * current key as a decrypt-only version, decrypt and re-encrypt every user
41
+ * connection envelope (including legacy SRKL profiles) under the new version,
42
+ * verify the complete migration, and only then retire the previous key. Until
43
+ * that migration exists, unsupported versions fail closed rather than losing
44
+ * access to stored credentials.
45
+ */
46
+ export declare function getOrCreateStorageConnectionEncryptionKey(queryDb: SystemQuery): Promise<string>;
@@ -1,12 +1,22 @@
1
1
  /**
2
2
  * @file unifiedDb.ts
3
- * @description Isomorphic Database Client using Neon Serverless HTTP driver for Qwnsr.
4
- * Operates identically across Node.js, Vercel Serverless, and Cloudflare Workers.
3
+ * @description Canonical isomorphic database client using the Neon Serverless HTTP driver.
4
+ * The normalized SYSTEM_DATABASE_URL contract is resolved in one shared location.
5
5
  */
6
+ type SystemEnvironmentResolver = () => Record<string, unknown>;
7
+ /** Installed only by the explicit Node backend entrypoint. */
8
+ export declare function configureUnifiedDatabaseEnvironmentResolver(resolver: SystemEnvironmentResolver | null): void;
6
9
  export interface UnifiedQueryResult<T = any> {
7
10
  rows: T[];
8
11
  rowCount: number;
9
12
  }
10
13
  export declare function cleanDbUrl(url?: unknown): string;
14
+ /**
15
+ * Fully normalized Worker/Fetch env objects carry all three canonical keys,
16
+ * even when unset. Such an object is authoritative and must not be masked by
17
+ * process.env. Partial service context objects (for example {WORKSPACE_APP_ID})
18
+ * retain the Node compatibility fallback used by existing callers.
19
+ */
11
20
  export declare function getUnifiedDbUrl(env?: Record<string, unknown>): string;
12
21
  export declare function queryUnifiedDb<T = any>(sqlText: string, params?: any[], env?: Record<string, unknown>): Promise<UnifiedQueryResult<T>>;
22
+ export {};
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @file unifiedDbNodeAdapter.ts
3
+ * @description Node-only source of default system configuration.
4
+ * This module is installed only by the explicit /backend/node entrypoint.
5
+ */
6
+ export {};
@@ -1,10 +1,9 @@
1
1
  /**
2
2
  * @file workspaceBucketSyncCore.ts
3
- * @description Workspace Backblaze B2 Direct Storage Synchronization.
4
- * Directly handles folder creation, file uploads (workspace.json, ecosystem.json), and cleanup.
5
- * Conforms to Law L2, L3, L9 (< 200 lines).
3
+ * @description Initialize and synchronize workspace metadata to the exact
4
+ * user-owned storage connection associated with a workspace.
6
5
  */
7
- export declare function resolveWorkspaceConnection(profiles: any, workspace: any): any;
6
+ export declare function resolveWorkspaceConnection(profiles: any, workspace: any, appId?: string): any;
8
7
  export declare function syncWorkspaceCreateToBucket(workspace: any, connection: any, env?: Record<string, unknown>): Promise<void>;
9
8
  export declare function syncWorkspaceDeleteToBucket(workspace: any, connection: any, env?: Record<string, unknown>): Promise<void>;
10
9
  export declare function syncWorkspaceDataToBucket(workspace: any, connection: any, data: any, env?: Record<string, unknown>): Promise<void>;
@@ -6,21 +6,40 @@
6
6
  */
7
7
  export { loadWorkspaceData, saveWorkspaceData, renameAppInWorkspaceData } from './workspaceDataCore.js';
8
8
  export { getWorkspaceStorageDetails } from './workspaceStorageDetailsCore.js';
9
- export declare function findUserWorkspace(workspaceId: string, env?: Record<string, unknown>): Promise<{
10
- user: any;
9
+ /**
10
+ * Resolve a workspace only within the supplied authenticated owner context.
11
+ * The owner ID must come from the server's verified Luth principal, never from
12
+ * request-body data. Workspace IDs are not authorization credentials.
13
+ */
14
+ export declare function findUserWorkspace(workspaceId: string, env?: Record<string, unknown>, verifiedUserId?: string): Promise<{
15
+ user: Record<string, any>;
11
16
  workspace: any;
12
- connection: any;
17
+ connection: Record<string, any>;
13
18
  }>;
14
19
  export declare function getWorkspaces(userId?: string, env?: Record<string, unknown>): Promise<{
15
20
  success: boolean;
16
21
  workspaces: any[];
17
22
  activeWorkspaceId: any;
18
- storage_connections: any;
23
+ storage_connections: import("./storageConnectionCore.js").PublicStorageConnection[];
19
24
  }>;
20
25
  export declare function createWorkspace(userId: string, wsData: any, env?: Record<string, unknown>): Promise<{
21
26
  success: boolean;
22
- workspace: any;
23
- workspaces: any[];
27
+ workspace: {
28
+ createdAt: string;
29
+ updatedAt: string;
30
+ googleRootFolderId?: string;
31
+ googleRootFolderName?: string;
32
+ b2BucketName?: string;
33
+ storageConnectionId?: string;
34
+ localFolderName: string;
35
+ localFolderKey: string;
36
+ workspacePath: string;
37
+ storageProvider: string;
38
+ description?: any;
39
+ id: string;
40
+ name: string;
41
+ };
42
+ workspaces: any;
24
43
  }>;
25
44
  export declare function updateWorkspace(userId: string, params: any, env?: Record<string, unknown>): Promise<{
26
45
  success: boolean;
@@ -1,16 +1,34 @@
1
1
  /**
2
2
  * @file workspaceFileCore.ts
3
- * @description Universal Workspace File IO Abstraction.
4
- * Routes reads, writes, and deletions to Local Disk or Backblaze B2 Object Storage (< 200 lines).
3
+ * @description Fetch-compatible workspace file IO for B2, Google Drive, and local storage.
4
+ * This portable module has no Node imports. Local filesystem behavior is
5
+ * supplied only by the explicitly Node-specific entrypoint adapter.
5
6
  */
7
+ /**
8
+ * Local filesystem adapter injection. The portable module has no Node imports;
9
+ * the explicit /backend/node entrypoint installs the Node implementation.
10
+ */
11
+ export interface LocalWorkspaceFileAdapter {
12
+ write(path: string, content: Uint8Array): Promise<void>;
13
+ read(path: string): Promise<Uint8Array | null>;
14
+ delete(path: string): Promise<boolean>;
15
+ list(path: string): Promise<Array<{
16
+ fileName: string;
17
+ sizeBytes: number;
18
+ }>>;
19
+ deleteFolder(path: string): Promise<void>;
20
+ }
21
+ export declare function configureLocalWorkspaceFileAdapter(adapter: LocalWorkspaceFileAdapter | null): void;
22
+ export declare function normalizeWorkspaceStoragePath(value: string, allowEmpty?: boolean): string;
6
23
  export declare function getWorkspaceFolderPrefix(workspace: any): string;
7
24
  export declare function isB2Workspace(workspace: any, connection: any): boolean;
8
- export declare function writeWorkspaceFile(workspace: any, connection: any, relativePath: string, content: string | Uint8Array, contentType?: string): Promise<void>;
9
- export declare function readWorkspaceFile(workspace: any, connection: any, relativePath: string): Promise<Uint8Array | null>;
10
- export declare function deleteWorkspaceFile(workspace: any, connection: any, relativePath: string): Promise<boolean>;
11
- export declare function listWorkspaceFiles(workspace: any, connection: any, subPrefix?: string): Promise<Array<{
25
+ export declare function isGoogleDriveWorkspace(workspace: any, connection: any): boolean;
26
+ export declare function writeWorkspaceFile(workspace: any, connection: any, relativePath: string, content: string | Uint8Array, contentType?: string, env?: Record<string, unknown>): Promise<void>;
27
+ export declare function readWorkspaceFile(workspace: any, connection: any, relativePath: string, env?: Record<string, unknown>): Promise<Uint8Array | null>;
28
+ export declare function deleteWorkspaceFile(workspace: any, connection: any, relativePath: string, env?: Record<string, unknown>): Promise<boolean>;
29
+ export declare function listWorkspaceFiles(workspace: any, connection: any, subPrefix?: string, env?: Record<string, unknown>): Promise<Array<{
12
30
  fileName: string;
13
31
  sizeBytes: number;
14
32
  uploadTimestamp?: number;
15
33
  }>>;
16
- export declare function deleteWorkspaceFolder(workspace: any, connection: any): Promise<void>;
34
+ export declare function deleteWorkspaceFolder(workspace: any, connection: any, env?: Record<string, unknown>): Promise<void>;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @file workspaceFileNodeAdapter.ts
3
+ * @description Node-only local filesystem implementation for workspace file IO.
4
+ * Imported only by the explicit @ultrst-armada/kloks/backend/node entrypoint.
5
+ */
6
+ export {};
@@ -3,7 +3,7 @@
3
3
  * @description Inspection of workspace cloud storage directly via Backblaze B2.
4
4
  * Runs identically in Node.js, Vercel Serverless, and Cloudflare Workers (< 200 lines).
5
5
  */
6
- export declare function getWorkspaceStorageDetails(workspaceId: string, env?: Record<string, unknown>): Promise<{
6
+ export declare function getWorkspaceStorageDetails(workspaceId: string, env?: Record<string, unknown>, verifiedUserId?: string): Promise<{
7
7
  success: boolean;
8
8
  error: string;
9
9
  workspaceId?: undefined;
@@ -18,7 +18,7 @@ export declare function getWorkspaceStorageDetails(workspaceId: string, env?: Re
18
18
  success: boolean;
19
19
  workspaceId: string;
20
20
  storageProvider: any;
21
- connection: any;
21
+ connection: import("./storageConnectionCore.js").PublicStorageConnection;
22
22
  folderPrefix: any;
23
23
  localStats: {
24
24
  exists: boolean;
@@ -33,11 +33,7 @@ export declare function getWorkspaceStorageDetails(workspaceId: string, env?: Re
33
33
  success: boolean;
34
34
  workspaceId: string;
35
35
  storageProvider: string;
36
- connection: {
37
- id: any;
38
- label: any;
39
- provider: any;
40
- };
36
+ connection: import("./storageConnectionCore.js").PublicStorageConnection;
41
37
  folderPrefix: any;
42
38
  bucket: {
43
39
  name: any;
@@ -81,7 +77,7 @@ export declare function getWorkspaceStorageDetails(workspaceId: string, env?: Re
81
77
  success: boolean;
82
78
  workspaceId: string;
83
79
  storageProvider: string;
84
- error: any;
80
+ error: string;
85
81
  folderPrefix: any;
86
82
  connection?: undefined;
87
83
  localStats?: undefined;
@@ -2,7 +2,7 @@ import {
2
2
  PlaywrightInspectionRuntime,
3
3
  PlaywrightInspectionServiceDefinition,
4
4
  PlaywrightInspectionServiceFacade
5
- } from "../chunk-NTKUQVCQ.js";
5
+ } from "../chunk-LMUMMVTU.js";
6
6
  import "../chunk-YEGS4HTA.js";
7
7
  import {
8
8
  WebContainerServiceDefinition,
@@ -2,7 +2,7 @@ import {
2
2
  PlaywrightInspectionRuntime,
3
3
  PlaywrightInspectionServiceDefinition,
4
4
  PlaywrightInspectionServiceFacade
5
- } from "../chunk-NTKUQVCQ.js";
5
+ } from "../chunk-LMUMMVTU.js";
6
6
  export {
7
7
  PlaywrightInspectionRuntime,
8
8
  PlaywrightInspectionServiceDefinition,
@@ -36,6 +36,7 @@ export type BrowserLike = {
36
36
  type PlaywrightModule = {
37
37
  chromium: {
38
38
  launch(options: object): Promise<BrowserLike>;
39
+ executablePath?: () => string;
39
40
  };
40
41
  };
41
42
  export declare function findSystemChromiumExecutable(): string | undefined;
@@ -1,19 +1,24 @@
1
1
  import "./chunk-RABSY2JU.js";
2
+ import "./chunk-GVMVYC6C.js";
2
3
  import "./chunk-2Y2EXYDK.js";
3
- import {
4
- resolveSystemDatabaseUrl,
5
- tryResolveSystemDatabaseUrl
6
- } from "./chunk-GYSZ6CAX.js";
7
4
  import "./chunk-DAG2L4RN.js";
8
5
  import {
9
6
  WorkspaceCloneSyncEngine
10
- } from "./chunk-NY2SQOXI.js";
7
+ } from "./chunk-CDRHYO44.js";
8
+ import {
9
+ isSecretMasked,
10
+ normalizeBackblazeCredentials,
11
+ resolveBackblazeEndpoint
12
+ } from "./chunk-HUY4272L.js";
13
+ import {
14
+ BaseStorageAdapter
15
+ } from "./chunk-5Y7K7HAT.js";
11
16
  import {
12
17
  BaseApiRoute,
13
18
  createSSEResponse,
14
19
  withAuth,
15
20
  withCors
16
- } from "./chunk-POLVHTHJ.js";
21
+ } from "./chunk-KCPQWJBO.js";
17
22
  import {
18
23
  LuthAuthClient,
19
24
  LuthAuthClient2,
@@ -47,21 +52,20 @@ import {
47
52
  WebSocketTransport,
48
53
  createBackendClient
49
54
  } from "./chunk-NIP22V2G.js";
50
- import {
51
- isSecretMasked,
52
- normalizeBackblazeCredentials,
53
- resolveBackblazeEndpoint
54
- } from "./chunk-HUY4272L.js";
55
- import {
56
- BaseStorageAdapter
57
- } from "./chunk-5F5V7NAG.js";
55
+ import "./chunk-LMY6MGFD.js";
58
56
  import {
59
57
  authorizeB2,
60
58
  b2DownloadFile,
61
59
  b2ListBuckets,
62
60
  b2ListFileNames,
63
- b2UploadFile
64
- } from "./chunk-4QEMALXF.js";
61
+ b2UploadFile2 as b2UploadFile
62
+ } from "./chunk-I6T64MLT.js";
63
+ import {
64
+ normalizeSystemEnvironment,
65
+ resolveSystemDatabaseUrl,
66
+ resolveSystemDatabaseUrlCandidates,
67
+ tryResolveSystemDatabaseUrl
68
+ } from "./chunk-IP6XWQU2.js";
65
69
  export {
66
70
  BackendClient,
67
71
  BackendRegistry,
@@ -99,10 +103,12 @@ export {
99
103
  createSSEResponse,
100
104
  isSecretMasked,
101
105
  normalizeBackblazeCredentials,
106
+ normalizeSystemEnvironment,
102
107
  resolveBackblazeEndpoint,
103
108
  resolveClientEnvironment,
104
109
  resolveClientOrigin,
105
110
  resolveSystemDatabaseUrl,
111
+ resolveSystemDatabaseUrlCandidates,
106
112
  tryResolveSystemDatabaseUrl,
107
113
  withAuth,
108
114
  withCors