@ultrst-armada/kloks 1.7.1 → 1.9.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 (27) hide show
  1. package/.krusbl-release-attestation.json +3 -3
  2. package/package.json +1 -1
  3. package/packages/backend/dist/{BaseStorageAdapter-6x_BQiB3.d.ts → BaseStorageAdapter-EUCSvJse.d.ts} +1 -0
  4. package/packages/backend/dist/auth/index.d.ts +51 -13
  5. package/packages/backend/dist/auth/index.js +6 -2
  6. package/packages/backend/dist/{chunk-6W7OAGNV.js → chunk-BTMIK44G.js} +84 -1
  7. package/packages/backend/dist/chunk-KKRWZDMN.js +237 -0
  8. package/packages/backend/dist/{chunk-JUPWFW7V.js → chunk-RBQ4CW3T.js} +4 -2
  9. package/packages/backend/dist/{chunk-R45CEV46.js → chunk-SHZAQTIT.js} +4 -234
  10. package/packages/backend/dist/{chunk-7ZT2ZPPH.js → chunk-UMEO6XS4.js} +5 -5
  11. package/packages/backend/dist/{chunk-F6IDQLC2.js → chunk-VKSGYMAH.js} +1 -1
  12. package/packages/backend/dist/{chunk-MPYASJ5A.js → chunk-W6JNJD3Q.js} +1 -1
  13. package/packages/backend/dist/chunk-WTBAG4AV.js +207 -0
  14. package/packages/backend/dist/index.d.ts +43 -4
  15. package/packages/backend/dist/index.js +163 -13
  16. package/packages/backend/dist/krnl-services.js +5 -4
  17. package/packages/backend/dist/services/index.js +3 -2
  18. package/packages/backend/dist/storage/index.d.ts +2 -2
  19. package/packages/backend/dist/storage/index.js +9 -7
  20. package/packages/backend/dist/workspace/index.d.ts +1 -1
  21. package/packages/backend/dist/workspace/index.js +2 -1
  22. package/packages/contracts/dist/index.d.ts +106 -1
  23. package/packages/contracts/dist/index.js +61 -0
  24. package/packages/services/dist/index.d.ts +36 -2
  25. package/packages/services/dist/index.js +251 -0
  26. package/packages/state-graph/dist/index.js +15 -15
  27. package/packages/backend/dist/chunk-ZDH4XI7W.js +0 -140
@@ -32,7 +32,7 @@ import {
32
32
  } from "./chunk-3IUA66RS.js";
33
33
  import {
34
34
  S3Adapter
35
- } from "./chunk-JUPWFW7V.js";
35
+ } from "./chunk-RBQ4CW3T.js";
36
36
  import {
37
37
  RemoteWorkspaceService,
38
38
  SyncEngine,
@@ -48,7 +48,7 @@ import {
48
48
  setWorkingWorkspaceConfig,
49
49
  syncWorkspace,
50
50
  workingWorkspaceService
51
- } from "./chunk-6W7OAGNV.js";
51
+ } from "./chunk-BTMIK44G.js";
52
52
  import {
53
53
  AuthServiceDefinition,
54
54
  AuthServiceFacade,
@@ -82,10 +82,10 @@ import {
82
82
  krnlWorkspaceGraphServiceFacade,
83
83
  krnlWorkspaceServiceDefinition,
84
84
  krnlWorkspaceServiceFacade
85
- } from "./chunk-7ZT2ZPPH.js";
85
+ } from "./chunk-UMEO6XS4.js";
86
86
  import {
87
87
  workspaceGraphService
88
- } from "./chunk-F6IDQLC2.js";
88
+ } from "./chunk-VKSGYMAH.js";
89
89
  import {
90
90
  getPrimarySrklDeploymentUrl,
91
91
  getSrklAccounts,
@@ -93,22 +93,17 @@ import {
93
93
  } from "./chunk-XHADDA75.js";
94
94
  import {
95
95
  BackblazeB2Adapter,
96
- BaseStorageAdapter,
97
- GoogleDriveAdapter,
98
96
  LocalFSAdapter,
99
97
  StorageAdapterFactory,
100
98
  SupabaseStorageAdapter,
101
- createGoogleDriveAuthorizationUrl,
102
99
  ensureS3DirectoryMarker,
103
- exchangeGoogleDriveCode,
104
100
  isSecretMasked,
105
101
  normalizeBackblazeCredentials,
106
102
  permanentDeleteS3Folder,
107
103
  permanentDeleteS3Object,
108
- refreshGoogleDriveAccessToken,
109
104
  renameS3Folder,
110
105
  resolveBackblazeEndpoint
111
- } from "./chunk-R45CEV46.js";
106
+ } from "./chunk-SHZAQTIT.js";
112
107
  import {
113
108
  authorizeB2,
114
109
  b2DownloadFile,
@@ -150,6 +145,13 @@ import {
150
145
  getUnifiedDbUrl,
151
146
  queryUnifiedDb
152
147
  } from "./chunk-VAFCR2MS.js";
148
+ import {
149
+ BaseStorageAdapter,
150
+ GoogleDriveAdapter,
151
+ createGoogleDriveAuthorizationUrl,
152
+ exchangeGoogleDriveCode,
153
+ refreshGoogleDriveAccessToken
154
+ } from "./chunk-KKRWZDMN.js";
153
155
  import {
154
156
  BaseApiRoute,
155
157
  createSSEResponse,
@@ -161,13 +163,15 @@ import {
161
163
  BaseAccountProvider,
162
164
  LocalAccountProvider,
163
165
  PasswordHasher
164
- } from "./chunk-MPYASJ5A.js";
166
+ } from "./chunk-W6JNJD3Q.js";
165
167
  import {
168
+ CanonicalAuthClient,
166
169
  RateLimiter,
167
170
  SessionManager,
171
+ createCanonicalAuthClient,
168
172
  loginSystemUser,
169
173
  resolveUserFromToken
170
- } from "./chunk-ZDH4XI7W.js";
174
+ } from "./chunk-WTBAG4AV.js";
171
175
  import {
172
176
  BackendProvider,
173
177
  useBackend,
@@ -2054,6 +2058,8 @@ async function fetchCloudflareData(payload, rawUserId, env) {
2054
2058
  id: p.name || p.id,
2055
2059
  name: p.name,
2056
2060
  type: "PAGES_PROJECT",
2061
+ providerProjectId: p.id,
2062
+ providerDeploymentId: p.latest_deployment?.id,
2057
2063
  status: p.latest_deployment?.status || "READY",
2058
2064
  framework: "Cloudflare Pages",
2059
2065
  domain: pDomain,
@@ -2188,6 +2194,7 @@ function buildProjectObservability(projects, deployments, user) {
2188
2194
  fastDataTransferFormatted: "100 MB",
2189
2195
  middlewareInvocations: 10,
2190
2196
  middlewareInvocationsFormatted: "10",
2197
+ latestDeploymentId: latestDep?.id,
2191
2198
  latestDeploymentUrl: `https://${cleanDeploymentUrl}`,
2192
2199
  latestDeploymentStatus: displayStatus,
2193
2200
  latestDeploymentCreatedAt: new Date(createdAtTime).toISOString(),
@@ -2205,7 +2212,8 @@ function buildProjectsList(observability) {
2205
2212
  url: po.latestDeploymentUrl,
2206
2213
  domain: po.domains && po.domains[0] || `${po.projectName}.vercel.app`,
2207
2214
  domains: po.domains || [`${po.projectName}.vercel.app`],
2208
- updatedAt: po.latestDeploymentCreatedAt
2215
+ updatedAt: po.latestDeploymentCreatedAt,
2216
+ deploymentId: po.latestDeploymentId
2209
2217
  }));
2210
2218
  }
2211
2219
 
@@ -2374,6 +2382,142 @@ async function fetchVercelData(payload, rawUserId, env) {
2374
2382
  }
2375
2383
  }
2376
2384
 
2385
+ // src/core/deploymentControlCore.ts
2386
+ function firstString(...values) {
2387
+ return values.find((value) => typeof value === "string" && value.trim().length > 0)?.trim() || "";
2388
+ }
2389
+ async function resolveVercelCredentials(payload, userId, env) {
2390
+ const credentials = payload.credentials || {};
2391
+ let token = firstString(payload.token, payload.apiToken, payload.accessToken, credentials.token, credentials.apiToken, credentials.accessToken);
2392
+ let teamId = firstString(payload.teamId, credentials.teamId);
2393
+ if ((!token || !teamId) && userId && (payload.accountId || credentials.accountId)) {
2394
+ const accountId = firstString(payload.accountId, credentials.accountId);
2395
+ const srkl = await getSrklAccounts2(userId, "vercel", env);
2396
+ const account = srkl.accounts?.find((item) => item.id === accountId);
2397
+ const accountCredentials = account?.credentials || account?.metadata?.credentials || {};
2398
+ token ||= firstString(accountCredentials.token, accountCredentials.apiToken, accountCredentials.accessToken);
2399
+ teamId ||= firstString(accountCredentials.teamId);
2400
+ }
2401
+ if (!token) throw new Error("Vercel API token is missing or not configured for this account.");
2402
+ return { token, teamId };
2403
+ }
2404
+ async function resolveCloudflareCredentials(payload, userId, env) {
2405
+ const credentials = payload.credentials || {};
2406
+ let token = firstString(payload.token, payload.apiToken, payload.accessToken, credentials.token, credentials.apiToken, credentials.accessToken);
2407
+ let accountId = firstString(payload.accountId, payload.cfAccountId, payload.accountTag, credentials.accountId, credentials.cfAccountId, credentials.accountTag);
2408
+ let authKey = firstString(payload.authKey, payload.globalApiKey, credentials.authKey, credentials.globalApiKey);
2409
+ let authEmail = firstString(payload.authEmail, payload.email, credentials.authEmail, credentials.email);
2410
+ if (!token && !authKey || !accountId) {
2411
+ const requestedAccountId = firstString(payload.accountId, credentials.accountId);
2412
+ if (userId && requestedAccountId) {
2413
+ const srkl = await getSrklAccounts2(userId, "cloudflare", env);
2414
+ const account = srkl.accounts?.find((item) => item.id === requestedAccountId);
2415
+ const accountCredentials = account?.credentials || account?.metadata?.credentials || {};
2416
+ token ||= firstString(accountCredentials.token, accountCredentials.apiToken, accountCredentials.accessToken);
2417
+ accountId ||= firstString(accountCredentials.accountId, accountCredentials.cfAccountId, accountCredentials.accountTag);
2418
+ authKey ||= firstString(accountCredentials.authKey, accountCredentials.globalApiKey);
2419
+ authEmail ||= firstString(accountCredentials.authEmail, accountCredentials.email);
2420
+ }
2421
+ }
2422
+ if (!token && !authKey) throw new Error("Cloudflare API Token or Global API Key required.");
2423
+ if (!accountId) throw new Error("Cloudflare Account ID is required.");
2424
+ return { token, accountId, authKey, authEmail };
2425
+ }
2426
+ function cloudflareHeaders(token, authKey, authEmail) {
2427
+ const headers = { "Content-Type": "application/json", "User-Agent": "Kloks-DeploymentControl/1.0" };
2428
+ if (token) headers.Authorization = `Bearer ${token}`;
2429
+ else {
2430
+ headers["X-Auth-Key"] = authKey;
2431
+ headers["X-Auth-Email"] = authEmail;
2432
+ }
2433
+ return headers;
2434
+ }
2435
+ async function assertOk(response, provider) {
2436
+ if (response.ok) return;
2437
+ const body = await response.json().catch(() => ({}));
2438
+ const message = body?.error?.message || body?.errors?.[0]?.message || body?.message || response.statusText;
2439
+ throw new Error(`${provider} API error (${response.status}): ${message}`);
2440
+ }
2441
+ async function pauseVercelProject(projectId, payload = {}, userId, env) {
2442
+ if (!projectId?.trim()) throw new Error("Vercel project ID is required.");
2443
+ const { token, teamId } = await resolveVercelCredentials(payload, userId, env);
2444
+ const query = teamId ? `?teamId=${encodeURIComponent(teamId)}` : "";
2445
+ const response = await fetch(`https://api.vercel.com/v1/projects/${encodeURIComponent(projectId)}/pause${query}`, {
2446
+ method: "POST",
2447
+ headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json" }
2448
+ });
2449
+ await assertOk(response, "Vercel");
2450
+ return { success: true, provider: "VERCEL", projectId, controlState: "PAUSED" };
2451
+ }
2452
+ async function resumeVercelProject(projectId, payload = {}, userId, env) {
2453
+ if (!projectId?.trim()) throw new Error("Vercel project ID is required.");
2454
+ const { token, teamId } = await resolveVercelCredentials(payload, userId, env);
2455
+ const query = teamId ? `?teamId=${encodeURIComponent(teamId)}` : "";
2456
+ const response = await fetch(`https://api.vercel.com/v1/projects/${encodeURIComponent(projectId)}/unpause${query}`, {
2457
+ method: "POST",
2458
+ headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json" }
2459
+ });
2460
+ await assertOk(response, "Vercel");
2461
+ return { success: true, provider: "VERCEL", projectId, controlState: "ACTIVE" };
2462
+ }
2463
+ async function pauseCloudflarePagesProject(projectName, payload = {}, userId, env) {
2464
+ if (!projectName?.trim()) throw new Error("Cloudflare Pages project name is required.");
2465
+ const { token, accountId, authKey, authEmail } = await resolveCloudflareCredentials(payload, userId, env);
2466
+ const base = `https://api.cloudflare.com/client/v4/accounts/${encodeURIComponent(accountId)}/pages/projects/${encodeURIComponent(projectName)}`;
2467
+ const currentResponse = await fetch(base, { headers: cloudflareHeaders(token, authKey, authEmail) });
2468
+ await assertOk(currentResponse, "Cloudflare");
2469
+ const current = await currentResponse.json();
2470
+ const config = current?.result?.source?.config;
2471
+ if (!config) throw new Error("Cloudflare Pages project has no source deployment configuration to pause.");
2472
+ const pauseState = {
2473
+ productionDeploymentsEnabled: config.production_deployments_enabled !== false,
2474
+ previewDeploymentSetting: config.preview_deployment_setting || "all"
2475
+ };
2476
+ const updateResponse = await fetch(base, {
2477
+ method: "PATCH",
2478
+ headers: cloudflareHeaders(token, authKey, authEmail),
2479
+ body: JSON.stringify({
2480
+ source: {
2481
+ type: current?.result?.source?.type,
2482
+ config: {
2483
+ ...config,
2484
+ production_deployments_enabled: false,
2485
+ preview_deployment_setting: "none"
2486
+ }
2487
+ }
2488
+ })
2489
+ });
2490
+ await assertOk(updateResponse, "Cloudflare");
2491
+ return { success: true, provider: "CLOUDFLARE", projectId: projectName, controlState: "PAUSED", pauseState };
2492
+ }
2493
+ async function resumeCloudflarePagesProject(projectName, pauseState, payload = {}, userId, env) {
2494
+ if (!projectName?.trim()) throw new Error("Cloudflare Pages project name is required.");
2495
+ if (!pauseState) throw new Error("Cloudflare Pages pause state is required to resume safely.");
2496
+ const { token, accountId, authKey, authEmail } = await resolveCloudflareCredentials(payload, userId, env);
2497
+ const base = `https://api.cloudflare.com/client/v4/accounts/${encodeURIComponent(accountId)}/pages/projects/${encodeURIComponent(projectName)}`;
2498
+ const currentResponse = await fetch(base, { headers: cloudflareHeaders(token, authKey, authEmail) });
2499
+ await assertOk(currentResponse, "Cloudflare");
2500
+ const current = await currentResponse.json();
2501
+ const config = current?.result?.source?.config;
2502
+ if (!config) throw new Error("Cloudflare Pages project has no source deployment configuration to resume.");
2503
+ const updateResponse = await fetch(base, {
2504
+ method: "PATCH",
2505
+ headers: cloudflareHeaders(token, authKey, authEmail),
2506
+ body: JSON.stringify({
2507
+ source: {
2508
+ type: current?.result?.source?.type,
2509
+ config: {
2510
+ ...config,
2511
+ production_deployments_enabled: pauseState.productionDeploymentsEnabled,
2512
+ preview_deployment_setting: pauseState.previewDeploymentSetting
2513
+ }
2514
+ }
2515
+ })
2516
+ });
2517
+ await assertOk(updateResponse, "Cloudflare");
2518
+ return { success: true, provider: "CLOUDFLARE", projectId: projectName, controlState: "ACTIVE" };
2519
+ }
2520
+
2377
2521
  // src/server/wavHelper.ts
2378
2522
  function createWavBuffer(sampleRate, numChannels, samples) {
2379
2523
  const numSamples = samples[0].length;
@@ -4210,6 +4354,7 @@ export {
4210
4354
  BaseStorageAdapter,
4211
4355
  CANONICAL_SRKL_URL,
4212
4356
  CallbackRegistry,
4357
+ CanonicalAuthClient,
4213
4358
  CloudflareResourceFetcher,
4214
4359
  CodeDiagnosticsService,
4215
4360
  CodeValidationRuntime,
@@ -4308,6 +4453,7 @@ export {
4308
4453
  createAssetSubfolder,
4309
4454
  createBackend,
4310
4455
  createBackendClient,
4456
+ createCanonicalAuthClient,
4311
4457
  createCompositeService,
4312
4458
  createCredential,
4313
4459
  createEmptyContract,
@@ -4424,6 +4570,8 @@ export {
4424
4570
  nodeGraphPersistence,
4425
4571
  normalizeBackblazeCredentials,
4426
4572
  parseGraphJsonFile,
4573
+ pauseCloudflarePagesProject,
4574
+ pauseVercelProject,
4427
4575
  permanentDeleteS3Folder,
4428
4576
  permanentDeleteS3Object,
4429
4577
  queryUnifiedDb,
@@ -4442,6 +4590,8 @@ export {
4442
4590
  resolveUserFromToken,
4443
4591
  resolveWorkspaceConnection,
4444
4592
  resolveWorkspaceDir,
4593
+ resumeCloudflarePagesProject,
4594
+ resumeVercelProject,
4445
4595
  sanitizeWorkspaceName,
4446
4596
  saveAssetToGraph,
4447
4597
  saveAssetToPool,
@@ -31,15 +31,16 @@ import {
31
31
  krnlWorkspaceGraphServiceFacade,
32
32
  krnlWorkspaceServiceDefinition,
33
33
  krnlWorkspaceServiceFacade
34
- } from "./chunk-7ZT2ZPPH.js";
35
- import "./chunk-F6IDQLC2.js";
34
+ } from "./chunk-UMEO6XS4.js";
35
+ import "./chunk-VKSGYMAH.js";
36
36
  import "./chunk-XHADDA75.js";
37
- import "./chunk-R45CEV46.js";
37
+ import "./chunk-SHZAQTIT.js";
38
38
  import "./chunk-4QEMALXF.js";
39
39
  import "./chunk-FZKBTF34.js";
40
40
  import "./chunk-6K75XXFD.js";
41
41
  import "./chunk-VAFCR2MS.js";
42
- import "./chunk-ZDH4XI7W.js";
42
+ import "./chunk-KKRWZDMN.js";
43
+ import "./chunk-WTBAG4AV.js";
43
44
  import "./chunk-TY32TUNI.js";
44
45
  export {
45
46
  AuthServiceDefinition,
@@ -14,10 +14,11 @@ import {
14
14
  } from "../chunk-RBF2OGMC.js";
15
15
  import {
16
16
  workspaceGraphService
17
- } from "../chunk-F6IDQLC2.js";
18
- import "../chunk-R45CEV46.js";
17
+ } from "../chunk-VKSGYMAH.js";
18
+ import "../chunk-SHZAQTIT.js";
19
19
  import "../chunk-6K75XXFD.js";
20
20
  import "../chunk-VAFCR2MS.js";
21
+ import "../chunk-KKRWZDMN.js";
21
22
  import "../chunk-TY32TUNI.js";
22
23
  export {
23
24
  CompositeBackend,
@@ -1,5 +1,5 @@
1
- import { B as BaseStorageAdapter, S as StorageConfig, F as FileInfo, D as DeleteFolderResult, R as RenameFolderResult, C as ConnectionTestResult } from '../BaseStorageAdapter-6x_BQiB3.js';
2
- export { a as StorageMode, b as StorageProviderType, U as UploadResult } from '../BaseStorageAdapter-6x_BQiB3.js';
1
+ import { B as BaseStorageAdapter, S as StorageConfig, F as FileInfo, D as DeleteFolderResult, R as RenameFolderResult, C as ConnectionTestResult } from '../BaseStorageAdapter-EUCSvJse.js';
2
+ export { a as StorageMode, b as StorageProviderType, U as UploadResult } from '../BaseStorageAdapter-EUCSvJse.js';
3
3
  import '@ultrst-armada/kloks/functions';
4
4
 
5
5
  declare class LocalFSAdapter extends BaseStorageAdapter {
@@ -1,24 +1,19 @@
1
1
  import {
2
2
  S3Adapter
3
- } from "../chunk-JUPWFW7V.js";
3
+ } from "../chunk-RBQ4CW3T.js";
4
4
  import {
5
5
  BackblazeB2Adapter,
6
- BaseStorageAdapter,
7
- GoogleDriveAdapter,
8
6
  LocalFSAdapter,
9
7
  StorageAdapterFactory,
10
8
  SupabaseStorageAdapter,
11
- createGoogleDriveAuthorizationUrl,
12
9
  ensureS3DirectoryMarker,
13
- exchangeGoogleDriveCode,
14
10
  isSecretMasked,
15
11
  normalizeBackblazeCredentials,
16
12
  permanentDeleteS3Folder,
17
13
  permanentDeleteS3Object,
18
- refreshGoogleDriveAccessToken,
19
14
  renameS3Folder,
20
15
  resolveBackblazeEndpoint
21
- } from "../chunk-R45CEV46.js";
16
+ } from "../chunk-SHZAQTIT.js";
22
17
  import {
23
18
  authorizeB2,
24
19
  b2DownloadFile,
@@ -26,6 +21,13 @@ import {
26
21
  b2ListFileNames,
27
22
  b2UploadFile
28
23
  } from "../chunk-4QEMALXF.js";
24
+ import {
25
+ BaseStorageAdapter,
26
+ GoogleDriveAdapter,
27
+ createGoogleDriveAuthorizationUrl,
28
+ exchangeGoogleDriveCode,
29
+ refreshGoogleDriveAccessToken
30
+ } from "../chunk-KKRWZDMN.js";
29
31
  export {
30
32
  BackblazeB2Adapter,
31
33
  BaseStorageAdapter,
@@ -1,4 +1,4 @@
1
- import { B as BaseStorageAdapter, F as FileInfo } from '../BaseStorageAdapter-6x_BQiB3.js';
1
+ import { B as BaseStorageAdapter, F as FileInfo } from '../BaseStorageAdapter-EUCSvJse.js';
2
2
  import { SkipoBase } from '@ultrst-armada/kloks/functions';
3
3
 
4
4
  interface WorkspaceDescriptor {
@@ -6,13 +6,14 @@ import {
6
6
  WorkspaceFS,
7
7
  remoteWorkspaceService,
8
8
  workingWorkspaceService
9
- } from "../chunk-6W7OAGNV.js";
9
+ } from "../chunk-BTMIK44G.js";
10
10
  import {
11
11
  formatCanonicalWorkspaceFolderName,
12
12
  sanitizeWorkspaceName
13
13
  } from "../chunk-FZKBTF34.js";
14
14
  import "../chunk-6K75XXFD.js";
15
15
  import "../chunk-VAFCR2MS.js";
16
+ import "../chunk-KKRWZDMN.js";
16
17
  export {
17
18
  RemoteWorkspaceService,
18
19
  SyncEngine,
@@ -575,6 +575,111 @@ interface ServiceUISchema {
575
575
  operationBindings: OperationBinding[];
576
576
  }
577
577
 
578
+ type MonacoDiagnosticSeverity = 'error' | 'warning' | 'info' | 'hint';
579
+ interface MonacoDiagnostic {
580
+ message: string;
581
+ severity: MonacoDiagnosticSeverity;
582
+ startLineNumber: number;
583
+ startColumn: number;
584
+ endLineNumber: number;
585
+ endColumn: number;
586
+ code?: string;
587
+ }
588
+ interface MonacoDocument {
589
+ uri: string;
590
+ language: string;
591
+ value: string;
592
+ version: number;
593
+ diagnostics: MonacoDiagnostic[];
594
+ }
595
+ interface MonacoEditorOptions {
596
+ readOnly?: boolean;
597
+ minimap?: boolean;
598
+ fontSize?: number;
599
+ wordWrap?: 'off' | 'on' | 'wordWrapColumn' | 'bounded';
600
+ }
601
+ interface MonacoIdeSession {
602
+ sessionId: string;
603
+ document: MonacoDocument;
604
+ options: MonacoEditorOptions;
605
+ createdAt: number;
606
+ updatedAt: number;
607
+ }
608
+ interface MonacoCreateSessionInput {
609
+ sessionId?: string;
610
+ uri: string;
611
+ language: string;
612
+ value: string;
613
+ options?: MonacoEditorOptions;
614
+ }
615
+ interface MonacoUpdateDocumentInput {
616
+ sessionId: string;
617
+ value: string;
618
+ language?: string;
619
+ }
620
+
621
+ type UIAuthoringContext = 'service' | 'general-component' | 'application';
622
+ type UIAuthoringNodeKind = 'page' | 'section' | 'component';
623
+ interface UIAuthoringNode {
624
+ id: string;
625
+ kind: UIAuthoringNodeKind;
626
+ name: string;
627
+ componentId?: string;
628
+ assetRef?: AssetRef;
629
+ parentId?: string;
630
+ props: Record<string, string | number | boolean>;
631
+ }
632
+ interface UIAuthoringBinding {
633
+ componentId: string;
634
+ property: string;
635
+ target: {
636
+ kind: 'api-input';
637
+ apiId: string;
638
+ field: string;
639
+ fieldType: string;
640
+ } | {
641
+ kind: 'api-output';
642
+ apiId: string;
643
+ field: string;
644
+ fieldType: string;
645
+ };
646
+ }
647
+ interface UIAuthoringOperation {
648
+ operationId: string;
649
+ name: string;
650
+ description?: string;
651
+ inputFields?: Array<{
652
+ name: string;
653
+ type: string;
654
+ }>;
655
+ outputFields?: Array<{
656
+ name: string;
657
+ type: string;
658
+ }>;
659
+ }
660
+ interface UIAuthoringSession {
661
+ sessionId: string;
662
+ context: UIAuthoringContext;
663
+ nodes: UIAuthoringNode[];
664
+ bindings: UIAuthoringBinding[];
665
+ operations: UIAuthoringOperation[];
666
+ metadata: Record<string, string>;
667
+ }
668
+ interface UIAuthoringCreateInput {
669
+ sessionId?: string;
670
+ context: UIAuthoringContext;
671
+ operations?: UIAuthoringOperation[];
672
+ metadata?: Record<string, string>;
673
+ }
674
+ interface UIAuthoringValidation {
675
+ valid: boolean;
676
+ errors: string[];
677
+ warnings: string[];
678
+ }
679
+ declare const UI_AUTHORING_SCHEMA_VERSION = "1.0.0";
680
+ declare function suggestUIComponent(fieldType: string): string;
681
+ declare function buildServiceUISchema(session: UIAuthoringSession): ServiceUISchema;
682
+
578
683
  declare const KLOKS_CANONICAL_CONTRACT: {
579
684
  package: string;
580
685
  version: string;
@@ -594,4 +699,4 @@ declare const KLOKS_CANONICAL_CONTRACT: {
594
699
  validateCompatibility: (consumerSymbols?: string[]) => CompatibilityCheckResult;
595
700
  };
596
701
 
597
- export { type AssetRef, type AudioBusConfig, AudioBusConfigSchema, type AudioHardwareState, AudioHardwareStateSchema, type BackendOperation, BackendOperationSchema, type CompatibilityCheckResult, type ComponentDescriptor, type ContractDiffResult, type ContractSnapshot, ContractSnapshotSchema, type ExportSymbolEntry, type GraphEntityMetadata, GraphEntityMetadataSchema, KLOKS_CANONICAL_CONTRACT, KLOKS_PUBLIC_SURFACE, type MidiCommandType, MidiCommandTypeSchema, type MidiEventPayload, MidiEventPayloadSchema, type NodeDimensions2D, NodeDimensions2DSchema, type NodeHeaderStyle, NodeHeaderStyleSchema, type NodeScreenRect2D, NodeScreenRect2DSchema, type OperationBinding, type PageDescriptor, type PublicContractDefinition, PublicContractDefinitionSchema, QWNSR_REQUIRED_SURFACE, type SectionDescriptor, type ServiceUISchema, type SocketDirection, SocketDirectionSchema, type SocketGeometryConfig, SocketGeometryConfigSchema, type SocketPosition2D, SocketPosition2DSchema, type SocketStyleConfig, SocketStyleConfigSchema, type UIRequirementMode, type WireAnimationConfig, WireAnimationConfigSchema, type WireCurveStyle, WireCurveStyleSchema, type WireEndpoint2D, WireEndpoint2DSchema, type WireVisualConfig, WireVisualConfigSchema, createKloksSnapshot, diffContractSnapshots, validateConsumerSurfaceCompatibility };
702
+ export { type AssetRef, type AudioBusConfig, AudioBusConfigSchema, type AudioHardwareState, AudioHardwareStateSchema, type BackendOperation, BackendOperationSchema, type CompatibilityCheckResult, type ComponentDescriptor, type ContractDiffResult, type ContractSnapshot, ContractSnapshotSchema, type ExportSymbolEntry, type GraphEntityMetadata, GraphEntityMetadataSchema, KLOKS_CANONICAL_CONTRACT, KLOKS_PUBLIC_SURFACE, type MidiCommandType, MidiCommandTypeSchema, type MidiEventPayload, MidiEventPayloadSchema, type MonacoCreateSessionInput, type MonacoDiagnostic, type MonacoDiagnosticSeverity, type MonacoDocument, type MonacoEditorOptions, type MonacoIdeSession, type MonacoUpdateDocumentInput, type NodeDimensions2D, NodeDimensions2DSchema, type NodeHeaderStyle, NodeHeaderStyleSchema, type NodeScreenRect2D, NodeScreenRect2DSchema, type OperationBinding, type PageDescriptor, type PublicContractDefinition, PublicContractDefinitionSchema, QWNSR_REQUIRED_SURFACE, type SectionDescriptor, type ServiceUISchema, type SocketDirection, SocketDirectionSchema, type SocketGeometryConfig, SocketGeometryConfigSchema, type SocketPosition2D, SocketPosition2DSchema, type SocketStyleConfig, SocketStyleConfigSchema, type UIAuthoringBinding, type UIAuthoringContext, type UIAuthoringCreateInput, type UIAuthoringNode, type UIAuthoringNodeKind, type UIAuthoringOperation, type UIAuthoringSession, type UIAuthoringValidation, type UIRequirementMode, UI_AUTHORING_SCHEMA_VERSION, type WireAnimationConfig, WireAnimationConfigSchema, type WireCurveStyle, WireCurveStyleSchema, type WireEndpoint2D, WireEndpoint2DSchema, type WireVisualConfig, WireVisualConfigSchema, buildServiceUISchema, createKloksSnapshot, diffContractSnapshots, suggestUIComponent, validateConsumerSurfaceCompatibility };
@@ -381,6 +381,64 @@ function diffContractSnapshots(previous, current) {
381
381
  };
382
382
  }
383
383
 
384
+ // src/uiAuthoringSchema.ts
385
+ var UI_AUTHORING_SCHEMA_VERSION = "1.0.0";
386
+ function suggestUIComponent(fieldType) {
387
+ const normalized = fieldType.toLowerCase();
388
+ if (normalized === "email") return "TextInput.email";
389
+ if (normalized === "password") return "TextInput.password";
390
+ if (normalized === "boolean" || normalized === "bool") return "ToggleInput";
391
+ if (normalized === "number" || normalized === "integer" || normalized === "float") return "NumberInput";
392
+ if (normalized.includes("date")) return "DateInput";
393
+ return "TextInput";
394
+ }
395
+ function buildServiceUISchema(session) {
396
+ if (session.context !== "service") throw new Error("Service UI schema generation requires service context.");
397
+ const pages = session.nodes.filter((node) => node.kind === "page");
398
+ const sections = session.nodes.filter((node) => node.kind === "section");
399
+ const components = session.nodes.filter((node) => node.kind === "component");
400
+ const assetRefs = components.map((node) => node.assetRef).filter(Boolean);
401
+ return {
402
+ schemaId: `kloks.authored-ui.${session.sessionId}`,
403
+ schemaVersion: UI_AUTHORING_SCHEMA_VERSION,
404
+ serviceId: session.metadata.serviceId || "unknown-service",
405
+ requirementMode: "optional",
406
+ pages: pages.map((page) => ({
407
+ name: page.name,
408
+ sections: sections.filter((section) => section.parentId === page.id).map((section) => ({
409
+ name: section.name,
410
+ assetRef: section.assetRef,
411
+ components: components.filter((component) => component.parentId === section.id).map((component) => ({
412
+ name: component.name,
413
+ assetRef: component.assetRef,
414
+ description: component.props.description
415
+ })),
416
+ description: section.props.description
417
+ })),
418
+ description: page.props.description
419
+ })),
420
+ sections: sections.map((section) => ({
421
+ name: section.name,
422
+ assetRef: section.assetRef,
423
+ components: components.filter((component) => component.parentId === section.id).map((component) => ({
424
+ name: component.name,
425
+ assetRef: component.assetRef
426
+ })),
427
+ description: section.props.description
428
+ })),
429
+ components: components.map((component) => ({
430
+ name: component.name,
431
+ assetRef: component.assetRef,
432
+ description: component.props.description
433
+ })),
434
+ assetRefs,
435
+ operationBindings: session.bindings.map((binding) => ({
436
+ operationId: binding.target.apiId,
437
+ uiPath: binding.componentId
438
+ }))
439
+ };
440
+ }
441
+
384
442
  // src/index.ts
385
443
  var KLOKS_CANONICAL_CONTRACT = {
386
444
  package: "@ultrst-armada/kloks",
@@ -407,11 +465,14 @@ export {
407
465
  SocketGeometryConfigSchema,
408
466
  SocketPosition2DSchema,
409
467
  SocketStyleConfigSchema,
468
+ UI_AUTHORING_SCHEMA_VERSION,
410
469
  WireAnimationConfigSchema,
411
470
  WireCurveStyleSchema,
412
471
  WireEndpoint2DSchema,
413
472
  WireVisualConfigSchema,
473
+ buildServiceUISchema,
414
474
  createKloksSnapshot,
415
475
  diffContractSnapshots,
476
+ suggestUIComponent,
416
477
  validateConsumerSurfaceCompatibility
417
478
  };
@@ -3,7 +3,7 @@ import { ServiceDefinition, IService, EndpointDescriptor, ProtocolAdapter } from
3
3
  import { AdminDatabaseClusterConfig, DatabaseConnectionEntry, UserStorageConnection, AuthState, UserAccount, UserRole, UserWorkspaceRecord } from '@ultrst-armada/kloks/state-graph';
4
4
  export { AuthState, UserAccount, UserRole, UserSession, UserStorageConnection, UserWorkspaceRecord } from '@ultrst-armada/kloks/state-graph';
5
5
  import * as _kloks_contracts from '@ultrst-armada/kloks/contracts';
6
- import { ServiceUISchema } from '@ultrst-armada/kloks/contracts';
6
+ import { ServiceUISchema, MonacoIdeSession, UIAuthoringSession } from '@ultrst-armada/kloks/contracts';
7
7
 
8
8
  interface SystemEnvironmentStatus {
9
9
  databaseUrlConfigured: boolean;
@@ -276,6 +276,40 @@ declare const StorageServiceUISchema: ServiceUISchema;
276
276
 
277
277
  declare const SystemDbServiceUISchema: ServiceUISchema;
278
278
 
279
+ interface MonacoState extends Record<string, unknown> {
280
+ sessions: Record<string, MonacoIdeSession>;
281
+ }
282
+ declare const MonacoIdeServiceDefinition: ServiceDefinition<MonacoState>;
283
+ declare function createMonacoIdeService(): IService<MonacoState>;
284
+ declare const MonacoIdeServiceFacade: {
285
+ id: string;
286
+ name: string;
287
+ version: string;
288
+ runtime: "client";
289
+ deployment: "local";
290
+ definition: ServiceDefinition<MonacoState, Record<string, unknown>>;
291
+ service: IService<MonacoState, Record<string, unknown>>;
292
+ createInstance: typeof createMonacoIdeService;
293
+ execute: <TIn = unknown, TOut = unknown>(operation: string, input?: TIn) => Promise<TOut>;
294
+ };
295
+
296
+ interface UIAuthoringState extends Record<string, unknown> {
297
+ sessions: Record<string, UIAuthoringSession>;
298
+ }
299
+ declare const UIAuthoringServiceDefinition: ServiceDefinition<UIAuthoringState>;
300
+ declare function createUIAuthoringService(): IService<UIAuthoringState>;
301
+ declare const UIAuthoringServiceFacade: {
302
+ id: string;
303
+ name: string;
304
+ version: string;
305
+ runtime: "client";
306
+ deployment: "local";
307
+ definition: ServiceDefinition<UIAuthoringState, Record<string, unknown>>;
308
+ service: IService<UIAuthoringState, Record<string, unknown>>;
309
+ createInstance: typeof createUIAuthoringService;
310
+ execute: <TIn = unknown, TOut = unknown>(operation: string, input?: TIn) => Promise<TOut>;
311
+ };
312
+
279
313
  declare const AuthClientServiceDefinition: ServiceDefinition;
280
314
  declare const AuthClientServiceFacade: {
281
315
  id: string;
@@ -417,4 +451,4 @@ declare const krnlServiceDDefinition: ServiceDefinition<Record<string, unknown>,
417
451
  declare const krnlServiceDFacade: ServiceFacade<Record<string, unknown>, Record<string, unknown>>;
418
452
  declare const krnlExposeServiceD: typeof exposeServiceD;
419
453
 
420
- export { AuthClientServiceDefinition, AuthClientServiceFacade, type AuthListener, AuthService, AuthServiceUISchema, CLEAN_DATABASE_CLUSTER, type CounterState, DEFAULT_CONNECTIONS, type IAuthStore, type MathInput, type ProtocolExposureHandle, STORAGE_KEY_CONNECTIONS, ServiceADefinition, ServiceAFacade, ServiceBDefinition, ServiceBFacade, ServiceCDefinition, ServiceCFacade, ServiceDDefinition, ServiceDFacade, type ServiceFacade, StorageClientServiceDefinition, StorageClientServiceFacade, StorageService, StorageServiceUISchema, SystemDbClientServiceDefinition, SystemDbClientServiceFacade, SystemDbService, SystemDbServiceUISchema, type SystemEnvironmentStatus, type SystemTelemetry, type TelemetryEvents, authService, clearSession, createServiceB, createServiceC, createWorkspace, deleteWorkspace, exposeServiceD, fetchWorkspaces, krnlAuthClientServiceDefinition, krnlAuthClientServiceFacade, krnlCreateServiceB, krnlCreateServiceC, krnlExposeServiceD, krnlServiceADefinition, krnlServiceAFacade, krnlServiceBDefinition, krnlServiceBFacade, krnlServiceCDefinition, krnlServiceCFacade, krnlServiceDDefinition, krnlServiceDFacade, krnlStorageClientServiceDefinition, krnlStorageClientServiceFacade, krnlSystemDbClientServiceDefinition, krnlSystemDbClientServiceFacade, loadDatabase, loginAdmin, loginUser, persistDatabase, register, restoreSession, setActiveWorkspace, setSession, storageService, systemDbService, updateWorkspace, verifyPassword };
454
+ export { AuthClientServiceDefinition, AuthClientServiceFacade, type AuthListener, AuthService, AuthServiceUISchema, CLEAN_DATABASE_CLUSTER, type CounterState, DEFAULT_CONNECTIONS, type IAuthStore, type MathInput, MonacoIdeServiceDefinition, MonacoIdeServiceFacade, type ProtocolExposureHandle, STORAGE_KEY_CONNECTIONS, ServiceADefinition, ServiceAFacade, ServiceBDefinition, ServiceBFacade, ServiceCDefinition, ServiceCFacade, ServiceDDefinition, ServiceDFacade, type ServiceFacade, StorageClientServiceDefinition, StorageClientServiceFacade, StorageService, StorageServiceUISchema, SystemDbClientServiceDefinition, SystemDbClientServiceFacade, SystemDbService, SystemDbServiceUISchema, type SystemEnvironmentStatus, type SystemTelemetry, type TelemetryEvents, UIAuthoringServiceDefinition, UIAuthoringServiceFacade, authService, clearSession, createMonacoIdeService, createServiceB, createServiceC, createUIAuthoringService, createWorkspace, deleteWorkspace, exposeServiceD, fetchWorkspaces, krnlAuthClientServiceDefinition, krnlAuthClientServiceFacade, krnlCreateServiceB, krnlCreateServiceC, krnlExposeServiceD, krnlServiceADefinition, krnlServiceAFacade, krnlServiceBDefinition, krnlServiceBFacade, krnlServiceCDefinition, krnlServiceCFacade, krnlServiceDDefinition, krnlServiceDFacade, krnlStorageClientServiceDefinition, krnlStorageClientServiceFacade, krnlSystemDbClientServiceDefinition, krnlSystemDbClientServiceFacade, loadDatabase, loginAdmin, loginUser, persistDatabase, register, restoreSession, setActiveWorkspace, setSession, storageService, systemDbService, updateWorkspace, verifyPassword };