@ultrst-armada/kloks 1.8.0 → 1.10.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.
@@ -575,6 +575,129 @@ 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
+
683
+ type UIComponentPurpose = 'service-ui' | 'general-purpose' | 'application-specific';
684
+ type UIComponentPromotion = 'always' | 'usually' | 'never';
685
+ interface UIComponentArtifact {
686
+ artifactId: string;
687
+ schemaVersion: string;
688
+ purpose: UIComponentPurpose;
689
+ promotion: UIComponentPromotion;
690
+ origin: 'kult' | 'theta' | 'kelt' | 'other';
691
+ context: UIAuthoringContext;
692
+ name: string;
693
+ description: string;
694
+ rootAsset?: AssetRef;
695
+ session: UIAuthoringSession;
696
+ }
697
+ declare function getUIComponentPurpose(context: UIAuthoringContext): UIComponentPurpose;
698
+ declare function getUIComponentPromotion(purpose: UIComponentPurpose): UIComponentPromotion;
699
+ declare function buildUIComponentArtifact(session: UIAuthoringSession): UIComponentArtifact;
700
+
578
701
  declare const KLOKS_CANONICAL_CONTRACT: {
579
702
  package: string;
580
703
  version: string;
@@ -594,4 +717,4 @@ declare const KLOKS_CANONICAL_CONTRACT: {
594
717
  validateCompatibility: (consumerSymbols?: string[]) => CompatibilityCheckResult;
595
718
  };
596
719
 
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 };
720
+ 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 UIComponentArtifact, type UIComponentPromotion, type UIComponentPurpose, type UIRequirementMode, UI_AUTHORING_SCHEMA_VERSION, type WireAnimationConfig, WireAnimationConfigSchema, type WireCurveStyle, WireCurveStyleSchema, type WireEndpoint2D, WireEndpoint2DSchema, type WireVisualConfig, WireVisualConfigSchema, buildServiceUISchema, buildUIComponentArtifact, createKloksSnapshot, diffContractSnapshots, getUIComponentPromotion, getUIComponentPurpose, suggestUIComponent, validateConsumerSurfaceCompatibility };
@@ -381,6 +381,92 @@ 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
+
442
+ // src/uiAuthoringArtifactSchema.ts
443
+ function getUIComponentPurpose(context) {
444
+ if (context === "service") return "service-ui";
445
+ if (context === "general-component") return "general-purpose";
446
+ return "application-specific";
447
+ }
448
+ function getUIComponentPromotion(purpose) {
449
+ if (purpose === "service-ui" || purpose === "general-purpose") return "always";
450
+ return "usually";
451
+ }
452
+ function buildUIComponentArtifact(session) {
453
+ const purpose = getUIComponentPurpose(session.context);
454
+ const origin = session.metadata.origin === "kult" || session.metadata.origin === "theta" || session.metadata.origin === "kelt" ? session.metadata.origin : "other";
455
+ const root = session.nodes.find((node) => node.kind === "component" && !node.parentId)?.assetRef;
456
+ return {
457
+ artifactId: "kloks.ui-artifact." + session.sessionId,
458
+ schemaVersion: "1.0.0",
459
+ purpose,
460
+ promotion: getUIComponentPromotion(purpose),
461
+ origin,
462
+ context: session.context,
463
+ name: session.metadata.name || session.sessionId,
464
+ description: session.metadata.description || "",
465
+ rootAsset: root,
466
+ session
467
+ };
468
+ }
469
+
384
470
  // src/index.ts
385
471
  var KLOKS_CANONICAL_CONTRACT = {
386
472
  package: "@ultrst-armada/kloks",
@@ -407,11 +493,17 @@ export {
407
493
  SocketGeometryConfigSchema,
408
494
  SocketPosition2DSchema,
409
495
  SocketStyleConfigSchema,
496
+ UI_AUTHORING_SCHEMA_VERSION,
410
497
  WireAnimationConfigSchema,
411
498
  WireCurveStyleSchema,
412
499
  WireEndpoint2DSchema,
413
500
  WireVisualConfigSchema,
501
+ buildServiceUISchema,
502
+ buildUIComponentArtifact,
414
503
  createKloksSnapshot,
415
504
  diffContractSnapshots,
505
+ getUIComponentPromotion,
506
+ getUIComponentPurpose,
507
+ suggestUIComponent,
416
508
  validateConsumerSurfaceCompatibility
417
509
  };
@@ -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 };
@@ -1651,6 +1651,265 @@ var StorageService = class {
1651
1651
  };
1652
1652
  var storageService = new StorageService();
1653
1653
 
1654
+ // src/client-services/monacoIdeService.ts
1655
+ var activeMonacoService;
1656
+ var MonacoIdeServiceDefinition = createServiceDefinition({
1657
+ id: "kloks.service.monacoIde",
1658
+ name: "MonacoIdeService",
1659
+ version: "1.0.0",
1660
+ state: { initial: { sessions: {} } },
1661
+ operations: {
1662
+ createSession: {
1663
+ id: "MonacoIdeService.createSession",
1664
+ name: "createSession",
1665
+ handler: async (input, ctx) => {
1666
+ const sessionId = input.sessionId || `monaco-${Date.now().toString(36)}`;
1667
+ const now = Date.now();
1668
+ const session = {
1669
+ sessionId,
1670
+ document: { uri: input.uri, language: input.language, value: input.value, version: 1, diagnostics: [] },
1671
+ options: input.options || {},
1672
+ createdAt: now,
1673
+ updatedAt: now
1674
+ };
1675
+ activeMonacoService.setState({ sessions: { ...activeMonacoService.getState().sessions, [sessionId]: session } });
1676
+ return session;
1677
+ }
1678
+ },
1679
+ updateDocument: {
1680
+ id: "MonacoIdeService.updateDocument",
1681
+ name: "updateDocument",
1682
+ handler: async (input, ctx) => {
1683
+ const current = activeMonacoService.getState().sessions[input.sessionId];
1684
+ if (!current) throw new Error(`Unknown Monaco session: ${input.sessionId}`);
1685
+ const document = {
1686
+ ...current.document,
1687
+ value: input.value,
1688
+ language: input.language || current.document.language,
1689
+ version: current.document.version + 1
1690
+ };
1691
+ const session = { ...current, document, updatedAt: Date.now() };
1692
+ activeMonacoService.setState({ sessions: { ...activeMonacoService.getState().sessions, [session.sessionId]: session } });
1693
+ return session;
1694
+ }
1695
+ },
1696
+ setDiagnostics: {
1697
+ id: "MonacoIdeService.setDiagnostics",
1698
+ name: "setDiagnostics",
1699
+ handler: async (input, ctx) => {
1700
+ const current = activeMonacoService.getState().sessions[input.sessionId];
1701
+ if (!current) throw new Error(`Unknown Monaco session: ${input.sessionId}`);
1702
+ const session = {
1703
+ ...current,
1704
+ document: { ...current.document, diagnostics: input.diagnostics },
1705
+ updatedAt: Date.now()
1706
+ };
1707
+ activeMonacoService.setState({ sessions: { ...activeMonacoService.getState().sessions, [session.sessionId]: session } });
1708
+ return session;
1709
+ }
1710
+ },
1711
+ setOptions: {
1712
+ id: "MonacoIdeService.setOptions",
1713
+ name: "setOptions",
1714
+ handler: async (input, ctx) => {
1715
+ const current = activeMonacoService.getState().sessions[input.sessionId];
1716
+ if (!current) throw new Error(`Unknown Monaco session: ${input.sessionId}`);
1717
+ const session = { ...current, options: { ...current.options, ...input.options }, updatedAt: Date.now() };
1718
+ activeMonacoService.setState({ sessions: { ...activeMonacoService.getState().sessions, [session.sessionId]: session } });
1719
+ return session;
1720
+ }
1721
+ },
1722
+ getSession: {
1723
+ id: "MonacoIdeService.getSession",
1724
+ name: "getSession",
1725
+ handler: async (input, ctx) => activeMonacoService.getState().sessions[input.sessionId] || null
1726
+ },
1727
+ disposeSession: {
1728
+ id: "MonacoIdeService.disposeSession",
1729
+ name: "disposeSession",
1730
+ handler: async (input, ctx) => {
1731
+ const sessions = { ...activeMonacoService.getState().sessions };
1732
+ delete sessions[input.sessionId];
1733
+ activeMonacoService.setState({ sessions });
1734
+ return { disposed: true, sessionId: input.sessionId };
1735
+ }
1736
+ }
1737
+ }
1738
+ });
1739
+ function createMonacoIdeService() {
1740
+ activeMonacoService = createService(MonacoIdeServiceDefinition);
1741
+ return activeMonacoService;
1742
+ }
1743
+ var defaultMonacoIdeService = createMonacoIdeService();
1744
+ var MonacoIdeServiceFacade = {
1745
+ id: MonacoIdeServiceDefinition.id,
1746
+ name: MonacoIdeServiceDefinition.name,
1747
+ version: MonacoIdeServiceDefinition.version,
1748
+ runtime: "client",
1749
+ deployment: "local",
1750
+ definition: MonacoIdeServiceDefinition,
1751
+ service: defaultMonacoIdeService,
1752
+ createInstance: createMonacoIdeService,
1753
+ execute: async (operation, input) => {
1754
+ await defaultMonacoIdeService.start();
1755
+ return defaultMonacoIdeService.call(operation, input);
1756
+ }
1757
+ };
1758
+
1759
+ // src/client-services/uiAuthoringService.ts
1760
+ import { buildServiceUISchema, buildUIComponentArtifact, suggestUIComponent } from "@ultrst-armada/kloks/contracts";
1761
+ var activeUIAuthoringService;
1762
+ var UIAuthoringServiceDefinition = createServiceDefinition({
1763
+ id: "kloks.service.uiAuthoring",
1764
+ name: "UIAuthoringService",
1765
+ version: "1.0.0",
1766
+ state: { initial: { sessions: {} } },
1767
+ operations: {
1768
+ createSession: {
1769
+ id: "UIAuthoringService.createSession",
1770
+ name: "createSession",
1771
+ handler: async (input, ctx) => {
1772
+ const sessionId = input.sessionId || `ui-authoring-${Date.now().toString(36)}`;
1773
+ const session = {
1774
+ sessionId,
1775
+ context: input.context,
1776
+ nodes: [],
1777
+ bindings: [],
1778
+ operations: input.operations || [],
1779
+ metadata: input.metadata || {}
1780
+ };
1781
+ activeUIAuthoringService.setState({ sessions: { ...activeUIAuthoringService.getState().sessions, [sessionId]: session } });
1782
+ return session;
1783
+ }
1784
+ },
1785
+ replaceSession: {
1786
+ id: "UIAuthoringService.replaceSession",
1787
+ name: "replaceSession",
1788
+ handler: async (input, ctx) => {
1789
+ if (input.sessionId !== input.session.sessionId) throw new Error("Session id mismatch.");
1790
+ return updateSession(activeUIAuthoringService, input.sessionId, () => input.session);
1791
+ }
1792
+ },
1793
+ addNode: {
1794
+ id: "UIAuthoringService.addNode",
1795
+ name: "addNode",
1796
+ handler: async (input, ctx) => updateSession(activeUIAuthoringService, input.sessionId, (session) => ({
1797
+ ...session,
1798
+ nodes: [...session.nodes.filter((node) => node.id !== input.node.id), input.node]
1799
+ }))
1800
+ },
1801
+ updateNode: {
1802
+ id: "UIAuthoringService.updateNode",
1803
+ name: "updateNode",
1804
+ handler: async (input, ctx) => updateSession(activeUIAuthoringService, input.sessionId, (session) => ({
1805
+ ...session,
1806
+ nodes: session.nodes.map((node) => node.id === input.nodeId ? { ...node, ...input.patch } : node)
1807
+ }))
1808
+ },
1809
+ removeNode: {
1810
+ id: "UIAuthoringService.removeNode",
1811
+ name: "removeNode",
1812
+ handler: async (input, ctx) => updateSession(activeUIAuthoringService, input.sessionId, (session) => ({
1813
+ ...session,
1814
+ nodes: session.nodes.filter((node) => node.id !== input.nodeId && node.parentId !== input.nodeId)
1815
+ }))
1816
+ },
1817
+ setBinding: {
1818
+ id: "UIAuthoringService.setBinding",
1819
+ name: "setBinding",
1820
+ handler: async (input, ctx) => updateSession(activeUIAuthoringService, input.sessionId, (session) => ({
1821
+ ...session,
1822
+ bindings: [...session.bindings.filter((binding) => binding.componentId !== input.binding.componentId || binding.property !== input.binding.property), input.binding]
1823
+ }))
1824
+ },
1825
+ setOperations: {
1826
+ id: "UIAuthoringService.setOperations",
1827
+ name: "setOperations",
1828
+ handler: async (input, ctx) => updateSession(activeUIAuthoringService, input.sessionId, (session) => ({ ...session, operations: input.operations }))
1829
+ },
1830
+ validate: {
1831
+ id: "UIAuthoringService.validate",
1832
+ name: "validate",
1833
+ handler: async (input, ctx) => validateSession(getSession(activeUIAuthoringService, input.sessionId))
1834
+ },
1835
+ serialize: {
1836
+ id: "UIAuthoringService.serialize",
1837
+ name: "serialize",
1838
+ handler: async (input, ctx) => JSON.stringify(getSession(activeUIAuthoringService, input.sessionId), null, 2)
1839
+ },
1840
+ generateArtifact: {
1841
+ id: "UIAuthoringService.generateArtifact",
1842
+ name: "generateArtifact",
1843
+ handler: async (input, ctx) => buildUIComponentArtifact(getSession(activeUIAuthoringService, input.sessionId))
1844
+ },
1845
+ generateServiceUI: {
1846
+ id: "UIAuthoringService.generateServiceUI",
1847
+ name: "generateServiceUI",
1848
+ handler: async (input, ctx) => buildServiceUISchema(getSession(activeUIAuthoringService, input.sessionId))
1849
+ },
1850
+ suggestComponent: {
1851
+ id: "UIAuthoringService.suggestComponent",
1852
+ name: "suggestComponent",
1853
+ handler: async (input) => suggestUIComponent(input.fieldType)
1854
+ },
1855
+ getSession: {
1856
+ id: "UIAuthoringService.getSession",
1857
+ name: "getSession",
1858
+ handler: async (input, ctx) => activeUIAuthoringService.getState().sessions[input.sessionId] || null
1859
+ }
1860
+ }
1861
+ });
1862
+ function getSession(service, sessionId) {
1863
+ const session = service.getState().sessions[sessionId];
1864
+ if (!session) throw new Error(`Unknown UI authoring session: ${sessionId}`);
1865
+ return session;
1866
+ }
1867
+ function updateSession(service, sessionId, update) {
1868
+ const session = update(getSession(service, sessionId));
1869
+ service.setState({ sessions: { ...service.getState().sessions, [sessionId]: session } });
1870
+ return session;
1871
+ }
1872
+ function validateSession(session) {
1873
+ const errors = [];
1874
+ const warnings = [];
1875
+ if (!session.nodes.some((node) => node.kind === "page")) errors.push("At least one page is required.");
1876
+ const ids = /* @__PURE__ */ new Set();
1877
+ for (const node of session.nodes) {
1878
+ if (ids.has(node.id)) errors.push(`Duplicate authoring node id: ${node.id}`);
1879
+ ids.add(node.id);
1880
+ if (node.parentId && !session.nodes.some((parent) => parent.id === node.parentId)) errors.push(`Missing parent for node: ${node.id}`);
1881
+ if (node.kind === "page" && node.parentId) errors.push(`Page cannot have a parent: ${node.id}`);
1882
+ if (node.kind === "section" && node.parentId && !session.nodes.some((parent) => parent.id === node.parentId && parent.kind === "page")) errors.push(`Section parent must be a page: ${node.id}`);
1883
+ if (node.kind === "component" && node.parentId && !session.nodes.some((parent) => parent.id === node.parentId && parent.kind === "section")) errors.push(`Component parent must be a section: ${node.id}`);
1884
+ }
1885
+ if (session.nodes.some((node) => node.kind === "component" && !node.assetRef)) errors.push("Every component node requires a FLOKS asset reference.");
1886
+ if (session.context === "service" && !session.metadata.serviceId) errors.push("Service authoring requires metadata.serviceId.");
1887
+ for (const binding of session.bindings) {
1888
+ if (!session.nodes.some((node) => node.id === binding.componentId)) errors.push(`Binding references missing component: ${binding.componentId}`);
1889
+ }
1890
+ if (!session.operations.length) warnings.push("No service operations have been attached to this authoring session.");
1891
+ return { valid: errors.length === 0, errors, warnings };
1892
+ }
1893
+ function createUIAuthoringService() {
1894
+ activeUIAuthoringService = createService(UIAuthoringServiceDefinition);
1895
+ return activeUIAuthoringService;
1896
+ }
1897
+ var defaultUIAuthoringService = createUIAuthoringService();
1898
+ var UIAuthoringServiceFacade = {
1899
+ id: UIAuthoringServiceDefinition.id,
1900
+ name: UIAuthoringServiceDefinition.name,
1901
+ version: UIAuthoringServiceDefinition.version,
1902
+ runtime: "client",
1903
+ deployment: "local",
1904
+ definition: UIAuthoringServiceDefinition,
1905
+ service: defaultUIAuthoringService,
1906
+ createInstance: createUIAuthoringService,
1907
+ execute: async (operation, input) => {
1908
+ await defaultUIAuthoringService.start();
1909
+ return defaultUIAuthoringService.call(operation, input);
1910
+ }
1911
+ };
1912
+
1654
1913
  // src/client-services/index.ts
1655
1914
  var AuthClientServiceDefinition = createServiceDefinition({
1656
1915
  id: "kloks.service.auth",
@@ -1973,6 +2232,8 @@ export {
1973
2232
  AuthServiceUISchema,
1974
2233
  CLEAN_DATABASE_CLUSTER,
1975
2234
  DEFAULT_CONNECTIONS,
2235
+ MonacoIdeServiceDefinition,
2236
+ MonacoIdeServiceFacade,
1976
2237
  STORAGE_KEY_CONNECTIONS,
1977
2238
  ServiceADefinition,
1978
2239
  ServiceAFacade,
@@ -1990,10 +2251,14 @@ export {
1990
2251
  SystemDbClientServiceFacade,
1991
2252
  SystemDbService,
1992
2253
  SystemDbServiceUISchema,
2254
+ UIAuthoringServiceDefinition,
2255
+ UIAuthoringServiceFacade,
1993
2256
  authService,
1994
2257
  clearSession,
2258
+ createMonacoIdeService,
1995
2259
  createServiceB,
1996
2260
  createServiceC,
2261
+ createUIAuthoringService,
1997
2262
  createWorkspace,
1998
2263
  deleteWorkspace,
1999
2264
  exposeServiceD,
@@ -7,29 +7,6 @@ import {
7
7
  instantiateSubgraph
8
8
  } from "./chunk-S22PMERU.js";
9
9
  import "./chunk-RHRXPY2U.js";
10
- import {
11
- LifecycleCycleError,
12
- LifecycleGraph,
13
- SKIPO_STATE,
14
- SkipoStateEngine,
15
- useLifecycleScope,
16
- useSkipoBind,
17
- useSkipoState
18
- } from "./chunk-EW4ACSZB.js";
19
- import {
20
- CommandApi,
21
- GhostStore,
22
- GraphStore
23
- } from "./chunk-4UVGXFEM.js";
24
- import {
25
- BaseGraph,
26
- BaseNode,
27
- BaseViewWindow,
28
- CustomGraph,
29
- CustomNode,
30
- CustomViewWindow,
31
- DEFAULT_GRAPH_SETTINGS
32
- } from "./chunk-KG6QYS26.js";
33
10
  import {
34
11
  AttractionEngine,
35
12
  GhostInferenceEngine,
@@ -45,6 +22,20 @@ import {
45
22
  WireTypeRegistry,
46
23
  initializeDefaultGraphRules
47
24
  } from "./chunk-TZOL3RN7.js";
25
+ import {
26
+ CommandApi,
27
+ GhostStore,
28
+ GraphStore
29
+ } from "./chunk-4UVGXFEM.js";
30
+ import {
31
+ BaseGraph,
32
+ BaseNode,
33
+ BaseViewWindow,
34
+ CustomGraph,
35
+ CustomNode,
36
+ CustomViewWindow,
37
+ DEFAULT_GRAPH_SETTINGS
38
+ } from "./chunk-KG6QYS26.js";
48
39
  import {
49
40
  AutoSolidify,
50
41
  SpatialEngine,
@@ -58,6 +49,15 @@ import {
58
49
  import {
59
50
  CompatibilityMatrix
60
51
  } from "./chunk-ISFNY7EZ.js";
52
+ import {
53
+ LifecycleCycleError,
54
+ LifecycleGraph,
55
+ SKIPO_STATE,
56
+ SkipoStateEngine,
57
+ useLifecycleScope,
58
+ useSkipoBind,
59
+ useSkipoState
60
+ } from "./chunk-EW4ACSZB.js";
61
61
 
62
62
  // ../../node_modules/.pnpm/@ultrst-armada+krnl@1.0.3/node_modules/@ultrst-armada/krnl/packages/core/dist/index.js
63
63
  var ServiceStateStore = class {
@@ -1,9 +1,9 @@
1
- import {
2
- findUserWorkspace
3
- } from "./chunk-6K75XXFD.js";
4
1
  import {
5
2
  StorageAdapterFactory
6
3
  } from "./chunk-SHZAQTIT.js";
4
+ import {
5
+ findUserWorkspace
6
+ } from "./chunk-6K75XXFD.js";
7
7
 
8
8
  // src/services/workspaceGraphService.ts
9
9
  function slugify(name) {