@semiont/core 0.3.3 → 0.3.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.
package/dist/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import { Subject, Observable } from 'rxjs';
2
2
  import { randomBytes } from 'crypto';
3
- import Ajv from 'ajv';
4
- import addFormats from 'ajv-formats';
3
+ import { parse } from 'smol-toml';
5
4
 
6
5
  // src/branded-types.ts
7
6
  function email(value) {
@@ -569,1740 +568,32 @@ function didToAgent(did) {
569
568
  // Use user ID as name since we don't have full user data
570
569
  };
571
570
  }
572
-
573
- // src/config/configuration-error.ts
574
- var ConfigurationError = class extends Error {
575
- constructor(message, environment, suggestion, cause) {
576
- super(message);
577
- this.environment = environment;
578
- this.suggestion = suggestion;
579
- this.name = "ConfigurationError";
580
- this.cause = cause;
581
- }
582
- cause;
583
- /**
584
- * Format the error nicely for CLI output
585
- */
586
- toString() {
587
- let output = `\u274C ${this.message}`;
588
- if (this.environment) {
589
- output += `
590
- Environment: ${this.environment}`;
591
- }
592
- if (this.suggestion) {
593
- output += `
594
- \u{1F4A1} Suggestion: ${this.suggestion}`;
595
- }
596
- return output;
597
- }
598
- };
599
-
600
- // src/config/config.schema.json
601
- var config_schema_default = {
602
- $schema: "http://json-schema.org/draft-07/schema#",
603
- $id: "https://semiont.org/schemas/config.json",
604
- definitions: {
605
- PlatformType: {
606
- type: "string",
607
- enum: [
608
- "posix",
609
- "container",
610
- "aws",
611
- "external"
612
- ]
613
- },
614
- ServicePlatformConfig: {
615
- type: "object",
616
- properties: {
617
- type: {
618
- $ref: "#/definitions/PlatformType"
619
- }
620
- },
621
- required: [
622
- "type"
623
- ]
624
- },
625
- ResourceRequirements: {
626
- type: "object",
627
- properties: {
628
- cpu: {
629
- type: "string"
630
- },
631
- memory: {
632
- type: "string"
633
- },
634
- gpu: {
635
- type: "integer"
636
- },
637
- gpus: {
638
- type: "integer"
639
- },
640
- replicas: {
641
- type: "integer"
642
- },
643
- ephemeralStorage: {
644
- type: "string"
645
- },
646
- memoryReservation: {
647
- type: "string"
648
- }
649
- },
650
- additionalProperties: false
651
- },
652
- SecurityRequirements: {
653
- type: "object",
654
- properties: {
655
- readOnlyRootFilesystem: {
656
- type: "boolean"
657
- },
658
- runAsNonRoot: {
659
- type: "boolean"
660
- },
661
- runAsUser: {
662
- type: "integer"
663
- },
664
- runAsGroup: {
665
- type: "integer"
666
- },
667
- capabilities: {
668
- oneOf: [
669
- {
670
- type: "array",
671
- items: {
672
- type: "string"
673
- }
674
- },
675
- {
676
- type: "object",
677
- properties: {
678
- add: {
679
- type: "array",
680
- items: {
681
- type: "string"
682
- }
683
- },
684
- drop: {
685
- type: "array",
686
- items: {
687
- type: "string"
688
- }
689
- }
690
- }
691
- }
692
- ]
693
- },
694
- privileged: {
695
- type: "boolean"
696
- },
697
- allowPrivilegeEscalation: {
698
- type: "boolean"
699
- }
700
- },
701
- additionalProperties: false
702
- },
703
- BuildRequirements: {
704
- type: "object",
705
- properties: {
706
- dockerfile: {
707
- type: "string"
708
- },
709
- buildContext: {
710
- type: "string"
711
- },
712
- buildArgs: {
713
- type: "object",
714
- additionalProperties: {
715
- type: "string"
716
- }
717
- },
718
- buildTarget: {
719
- type: "string"
720
- },
721
- prebuilt: {
722
- type: "boolean"
723
- },
724
- noCache: {
725
- type: "boolean"
726
- }
727
- },
728
- additionalProperties: false
729
- },
730
- BackendServiceConfig: {
731
- type: "object",
732
- properties: {
733
- platform: {
734
- $ref: "#/definitions/ServicePlatformConfig"
735
- },
736
- devMode: {
737
- type: "boolean"
738
- },
739
- command: {
740
- type: "string"
741
- },
742
- port: {
743
- type: "integer"
744
- },
745
- publicURL: {
746
- type: "string"
747
- },
748
- corsOrigin: {
749
- type: "string"
750
- },
751
- image: {
752
- type: "string"
753
- },
754
- cpu: {
755
- type: "string"
756
- },
757
- memory: {
758
- type: "string"
759
- },
760
- semiontRepo: {
761
- type: "string"
762
- },
763
- databaseUrl: {
764
- type: "string"
765
- },
766
- projectRoot: {
767
- type: "string"
768
- },
769
- timeout: {
770
- type: "integer"
771
- },
772
- wait: {
773
- type: "integer"
774
- },
775
- logsEndpoint: {
776
- type: "string"
777
- },
778
- tag: {
779
- type: "string"
780
- },
781
- resources: {
782
- $ref: "#/definitions/ResourceRequirements"
783
- },
784
- security: {
785
- $ref: "#/definitions/SecurityRequirements"
786
- },
787
- build: {
788
- oneOf: [
789
- {
790
- type: "boolean"
791
- },
792
- {
793
- $ref: "#/definitions/BuildRequirements"
794
- }
795
- ]
796
- },
797
- dockerfile: {
798
- type: "string"
799
- },
800
- buildContext: {
801
- type: "string"
802
- },
803
- buildArgs: {
804
- type: "object",
805
- additionalProperties: {
806
- type: "string"
807
- }
808
- },
809
- buildTarget: {
810
- type: "string"
811
- },
812
- prebuilt: {
813
- type: "boolean"
814
- },
815
- noCache: {
816
- type: "boolean"
817
- },
818
- secrets: {
819
- type: "array",
820
- items: {
821
- type: "string"
822
- }
823
- },
824
- labels: {
825
- type: "object",
826
- additionalProperties: {
827
- type: "string"
828
- }
829
- },
830
- annotations: {
831
- type: "object",
832
- additionalProperties: {
833
- type: "string"
834
- }
835
- },
836
- dependencies: {
837
- type: "array",
838
- items: {
839
- type: "string"
840
- }
841
- },
842
- externalDependencies: {
843
- type: "array",
844
- items: {
845
- oneOf: [
846
- {
847
- type: "string"
848
- },
849
- {
850
- type: "object",
851
- properties: {
852
- name: {
853
- type: "string"
854
- },
855
- url: {
856
- type: "string"
857
- },
858
- required: {
859
- type: "boolean"
860
- },
861
- healthCheck: {
862
- type: "string"
863
- }
864
- }
865
- }
866
- ]
867
- }
868
- },
869
- redisUrl: {
870
- type: "string"
871
- },
872
- environment: {
873
- type: "object",
874
- additionalProperties: {
875
- type: "string"
876
- }
877
- },
878
- env: {
879
- type: "object",
880
- additionalProperties: {
881
- type: "string"
882
- }
883
- }
884
- },
885
- required: [
886
- "platform",
887
- "port",
888
- "publicURL",
889
- "corsOrigin"
890
- ],
891
- additionalProperties: false
892
- },
893
- FrontendServiceConfig: {
894
- type: "object",
895
- properties: {
896
- platform: {
897
- $ref: "#/definitions/ServicePlatformConfig"
898
- },
899
- devMode: {
900
- type: "boolean"
901
- },
902
- command: {
903
- type: "string"
904
- },
905
- port: {
906
- type: "integer"
907
- },
908
- siteName: {
909
- type: "string"
910
- },
911
- image: {
912
- type: "string"
913
- },
914
- semiontRepo: {
915
- type: "string"
916
- },
917
- projectRoot: {
918
- type: "string"
919
- },
920
- databaseUrl: {
921
- type: "string"
922
- },
923
- timeout: {
924
- type: "integer"
925
- },
926
- wait: {
927
- type: "integer"
928
- },
929
- logsEndpoint: {
930
- type: "string"
931
- },
932
- tag: {
933
- type: "string"
934
- },
935
- resources: {
936
- $ref: "#/definitions/ResourceRequirements"
937
- },
938
- security: {
939
- $ref: "#/definitions/SecurityRequirements"
940
- },
941
- build: {
942
- oneOf: [
943
- {
944
- type: "boolean"
945
- },
946
- {
947
- $ref: "#/definitions/BuildRequirements"
948
- }
949
- ]
950
- },
951
- dockerfile: {
952
- type: "string"
953
- },
954
- buildContext: {
955
- type: "string"
956
- },
957
- buildArgs: {
958
- type: "object",
959
- additionalProperties: {
960
- type: "string"
961
- }
962
- },
963
- buildTarget: {
964
- type: "string"
965
- },
966
- prebuilt: {
967
- type: "boolean"
968
- },
969
- noCache: {
970
- type: "boolean"
971
- },
972
- secrets: {
973
- type: "array",
974
- items: {
975
- type: "string"
976
- }
977
- },
978
- labels: {
979
- type: "object",
980
- additionalProperties: {
981
- type: "string"
982
- }
983
- },
984
- annotations: {
985
- type: "object",
986
- additionalProperties: {
987
- type: "string"
988
- }
989
- },
990
- dependencies: {
991
- type: "array",
992
- items: {
993
- type: "string"
994
- }
995
- },
996
- externalDependencies: {
997
- type: "array",
998
- items: {
999
- oneOf: [
1000
- {
1001
- type: "string"
1002
- },
1003
- {
1004
- type: "object",
1005
- properties: {
1006
- name: {
1007
- type: "string"
1008
- },
1009
- url: {
1010
- type: "string"
1011
- },
1012
- required: {
1013
- type: "boolean"
1014
- },
1015
- healthCheck: {
1016
- type: "string"
1017
- }
1018
- }
1019
- }
1020
- ]
1021
- }
1022
- },
1023
- environment: {
1024
- type: "object",
1025
- additionalProperties: {
1026
- type: "string"
1027
- }
1028
- },
1029
- env: {
1030
- type: "object",
1031
- additionalProperties: {
1032
- type: "string"
1033
- }
1034
- },
1035
- publicURL: {
1036
- type: "string"
1037
- },
1038
- allowedOrigins: {
1039
- type: "array",
1040
- items: {
1041
- type: "string"
1042
- }
1043
- }
1044
- },
1045
- required: [
1046
- "platform",
1047
- "port",
1048
- "siteName"
1049
- ],
1050
- additionalProperties: false
1051
- },
1052
- ProxyServiceConfig: {
1053
- type: "object",
1054
- properties: {
1055
- platform: {
1056
- $ref: "#/definitions/ServicePlatformConfig"
1057
- },
1058
- type: {
1059
- type: "string",
1060
- enum: ["envoy", "nginx", "haproxy"],
1061
- default: "envoy"
1062
- },
1063
- port: {
1064
- type: "integer",
1065
- default: 8080
1066
- },
1067
- adminPort: {
1068
- type: "integer",
1069
- default: 9901
1070
- },
1071
- backendPort: {
1072
- type: "integer",
1073
- default: 4e3
1074
- },
1075
- frontendPort: {
1076
- type: "integer",
1077
- default: 3e3
1078
- },
1079
- image: {
1080
- type: "string",
1081
- default: "envoyproxy/envoy:v1.28-latest"
1082
- },
1083
- configPath: {
1084
- type: "string"
1085
- },
1086
- timeout: {
1087
- type: "integer"
1088
- },
1089
- wait: {
1090
- type: "integer"
1091
- },
1092
- logsEndpoint: {
1093
- type: "string"
1094
- },
1095
- tag: {
1096
- type: "string"
1097
- },
1098
- resources: {
1099
- $ref: "#/definitions/ResourceRequirements"
1100
- },
1101
- security: {
1102
- $ref: "#/definitions/SecurityRequirements"
1103
- },
1104
- environment: {
1105
- type: "object",
1106
- additionalProperties: {
1107
- type: "string"
1108
- }
1109
- },
1110
- env: {
1111
- type: "object",
1112
- additionalProperties: {
1113
- type: "string"
1114
- }
1115
- }
1116
- },
1117
- required: [
1118
- "platform",
1119
- "type",
1120
- "port"
1121
- ],
1122
- additionalProperties: false
1123
- },
1124
- DatabaseServiceConfig: {
1125
- type: "object",
1126
- properties: {
1127
- platform: {
1128
- $ref: "#/definitions/ServicePlatformConfig"
1129
- },
1130
- type: {
1131
- type: "string"
1132
- },
1133
- name: {
1134
- type: "string"
1135
- },
1136
- host: {
1137
- type: "string"
1138
- },
1139
- port: {
1140
- type: "integer"
1141
- },
1142
- environment: {
1143
- type: "object",
1144
- additionalProperties: {
1145
- type: "string"
1146
- }
1147
- },
1148
- env: {
1149
- type: "object",
1150
- additionalProperties: {
1151
- type: "string"
1152
- }
1153
- },
1154
- description: {
1155
- type: "string"
1156
- },
1157
- command: {
1158
- type: "string"
1159
- },
1160
- image: {
1161
- type: "string"
1162
- },
1163
- user: {
1164
- type: "string"
1165
- },
1166
- username: {
1167
- type: "string"
1168
- },
1169
- password: {
1170
- type: "string"
1171
- },
1172
- database: {
1173
- type: "string"
1174
- },
1175
- storageSize: {
1176
- type: "string"
1177
- },
1178
- timeout: {
1179
- type: "integer"
1180
- },
1181
- wait: {
1182
- type: "integer"
1183
- },
1184
- logsEndpoint: {
1185
- type: "string"
1186
- },
1187
- tag: {
1188
- type: "string"
1189
- },
1190
- resources: {
1191
- $ref: "#/definitions/ResourceRequirements"
1192
- },
1193
- security: {
1194
- $ref: "#/definitions/SecurityRequirements"
1195
- },
1196
- build: {
1197
- oneOf: [
1198
- {
1199
- type: "boolean"
1200
- },
1201
- {
1202
- $ref: "#/definitions/BuildRequirements"
1203
- }
1204
- ]
1205
- },
1206
- dockerfile: {
1207
- type: "string"
1208
- },
1209
- buildContext: {
1210
- type: "string"
1211
- },
1212
- buildArgs: {
1213
- type: "object",
1214
- additionalProperties: {
1215
- type: "string"
1216
- }
1217
- },
1218
- buildTarget: {
1219
- type: "string"
1220
- },
1221
- prebuilt: {
1222
- type: "boolean"
1223
- },
1224
- noCache: {
1225
- type: "boolean"
1226
- },
1227
- secrets: {
1228
- type: "array",
1229
- items: {
1230
- type: "string"
1231
- }
1232
- },
1233
- labels: {
1234
- type: "object",
1235
- additionalProperties: {
1236
- type: "string"
1237
- }
1238
- },
1239
- annotations: {
1240
- type: "object",
1241
- additionalProperties: {
1242
- type: "string"
1243
- }
1244
- },
1245
- dependencies: {
1246
- type: "array",
1247
- items: {
1248
- type: "string"
1249
- }
1250
- },
1251
- externalDependencies: {
1252
- type: "array",
1253
- items: {
1254
- oneOf: [
1255
- {
1256
- type: "string"
1257
- },
1258
- {
1259
- type: "object",
1260
- properties: {
1261
- name: {
1262
- type: "string"
1263
- },
1264
- url: {
1265
- type: "string"
1266
- },
1267
- required: {
1268
- type: "boolean"
1269
- },
1270
- healthCheck: {
1271
- type: "string"
1272
- }
1273
- }
1274
- }
1275
- ]
1276
- }
1277
- }
1278
- },
1279
- required: [
1280
- "platform",
1281
- "type",
1282
- "host",
1283
- "port"
1284
- ],
1285
- additionalProperties: false
1286
- },
1287
- GraphDatabaseType: {
1288
- type: "string",
1289
- enum: [
1290
- "neo4j",
1291
- "janusgraph",
1292
- "neptune",
1293
- "memory"
1294
- ]
1295
- },
1296
- GraphServiceConfig: {
1297
- type: "object",
1298
- properties: {
1299
- platform: {
1300
- $ref: "#/definitions/ServicePlatformConfig"
1301
- },
1302
- type: {
1303
- $ref: "#/definitions/GraphDatabaseType"
1304
- },
1305
- name: {
1306
- type: "string"
1307
- },
1308
- uri: {
1309
- type: "string"
1310
- },
1311
- url: {
1312
- type: "string"
1313
- },
1314
- username: {
1315
- type: "string"
1316
- },
1317
- password: {
1318
- type: "string"
1319
- },
1320
- database: {
1321
- type: "string"
1322
- },
1323
- host: {
1324
- type: "string"
1325
- },
1326
- port: {
1327
- type: "integer"
1328
- },
1329
- storage: {
1330
- type: "string"
1331
- },
1332
- index: {
1333
- type: "string"
1334
- },
1335
- endpoint: {
1336
- type: "string"
1337
- },
1338
- region: {
1339
- type: "string"
1340
- },
1341
- command: {
1342
- type: "string"
1343
- },
1344
- image: {
1345
- type: "string"
1346
- },
1347
- janusgraphVersion: {
1348
- type: "string"
1349
- },
1350
- javaOptions: {
1351
- type: "string"
1352
- },
1353
- heapSize: {
1354
- type: "string"
1355
- },
1356
- pageCacheSize: {
1357
- type: "string"
1358
- },
1359
- noAuth: {
1360
- type: "boolean"
1361
- },
1362
- dataPath: {
1363
- type: "string"
1364
- },
1365
- timeout: {
1366
- type: "integer"
1367
- },
1368
- wait: {
1369
- type: "integer"
1370
- },
1371
- logsEndpoint: {
1372
- type: "string"
1373
- },
1374
- tag: {
1375
- type: "string"
1376
- },
1377
- resources: {
1378
- $ref: "#/definitions/ResourceRequirements"
1379
- },
1380
- security: {
1381
- $ref: "#/definitions/SecurityRequirements"
1382
- },
1383
- build: {
1384
- oneOf: [
1385
- {
1386
- type: "boolean"
1387
- },
1388
- {
1389
- $ref: "#/definitions/BuildRequirements"
1390
- }
1391
- ]
1392
- },
1393
- dockerfile: {
1394
- type: "string"
1395
- },
1396
- buildContext: {
1397
- type: "string"
1398
- },
1399
- buildArgs: {
1400
- type: "object",
1401
- additionalProperties: {
1402
- type: "string"
1403
- }
1404
- },
1405
- buildTarget: {
1406
- type: "string"
1407
- },
1408
- prebuilt: {
1409
- type: "boolean"
1410
- },
1411
- noCache: {
1412
- type: "boolean"
1413
- },
1414
- secrets: {
1415
- type: "array",
1416
- items: {
1417
- type: "string"
1418
- }
1419
- },
1420
- labels: {
1421
- type: "object",
1422
- additionalProperties: {
1423
- type: "string"
1424
- }
1425
- },
1426
- annotations: {
1427
- type: "object",
1428
- additionalProperties: {
1429
- type: "string"
1430
- }
1431
- },
1432
- dependencies: {
1433
- type: "array",
1434
- items: {
1435
- type: "string"
1436
- }
1437
- },
1438
- externalDependencies: {
1439
- type: "array",
1440
- items: {
1441
- oneOf: [
1442
- {
1443
- type: "string"
1444
- },
1445
- {
1446
- type: "object",
1447
- properties: {
1448
- name: {
1449
- type: "string"
1450
- },
1451
- url: {
1452
- type: "string"
1453
- },
1454
- required: {
1455
- type: "boolean"
1456
- },
1457
- healthCheck: {
1458
- type: "string"
1459
- }
1460
- }
1461
- }
1462
- ]
1463
- }
1464
- },
1465
- environment: {
1466
- type: "object",
1467
- additionalProperties: {
1468
- type: "string"
1469
- }
1470
- },
1471
- env: {
1472
- type: "object",
1473
- additionalProperties: {
1474
- type: "string"
1475
- }
1476
- }
1477
- },
1478
- required: [
1479
- "platform",
1480
- "type"
1481
- ],
1482
- allOf: [
1483
- {
1484
- if: {
1485
- properties: {
1486
- type: {
1487
- const: "neo4j"
1488
- }
1489
- }
1490
- },
1491
- then: {
1492
- required: [
1493
- "uri",
1494
- "username",
1495
- "password",
1496
- "database"
1497
- ]
1498
- }
1499
- }
1500
- ],
1501
- additionalProperties: false
1502
- },
1503
- FilesystemServiceConfig: {
1504
- type: "object",
1505
- properties: {
1506
- platform: {
1507
- $ref: "#/definitions/ServicePlatformConfig"
1508
- },
1509
- path: {
1510
- type: "string"
1511
- },
1512
- description: {
1513
- type: "string"
1514
- },
1515
- command: {
1516
- type: "string"
1517
- },
1518
- image: {
1519
- type: "string"
1520
- },
1521
- port: {
1522
- type: "integer"
1523
- },
1524
- timeout: {
1525
- type: "integer"
1526
- },
1527
- wait: {
1528
- type: "integer"
1529
- },
1530
- logsEndpoint: {
1531
- type: "string"
1532
- },
1533
- tag: {
1534
- type: "string"
1535
- },
1536
- resources: {
1537
- $ref: "#/definitions/ResourceRequirements"
1538
- },
1539
- security: {
1540
- $ref: "#/definitions/SecurityRequirements"
1541
- },
1542
- build: {
1543
- oneOf: [
1544
- {
1545
- type: "boolean"
1546
- },
1547
- {
1548
- $ref: "#/definitions/BuildRequirements"
1549
- }
1550
- ]
1551
- },
1552
- dockerfile: {
1553
- type: "string"
1554
- },
1555
- buildContext: {
1556
- type: "string"
1557
- },
1558
- buildArgs: {
1559
- type: "object",
1560
- additionalProperties: {
1561
- type: "string"
1562
- }
1563
- },
1564
- buildTarget: {
1565
- type: "string"
1566
- },
1567
- prebuilt: {
1568
- type: "boolean"
1569
- },
1570
- noCache: {
1571
- type: "boolean"
1572
- },
1573
- secrets: {
1574
- type: "array",
1575
- items: {
1576
- type: "string"
1577
- }
1578
- },
1579
- labels: {
1580
- type: "object",
1581
- additionalProperties: {
1582
- type: "string"
1583
- }
1584
- },
1585
- annotations: {
1586
- type: "object",
1587
- additionalProperties: {
1588
- type: "string"
1589
- }
1590
- },
1591
- dependencies: {
1592
- type: "array",
1593
- items: {
1594
- type: "string"
1595
- }
1596
- },
1597
- externalDependencies: {
1598
- type: "array",
1599
- items: {
1600
- oneOf: [
1601
- {
1602
- type: "string"
1603
- },
1604
- {
1605
- type: "object",
1606
- properties: {
1607
- name: {
1608
- type: "string"
1609
- },
1610
- url: {
1611
- type: "string"
1612
- },
1613
- required: {
1614
- type: "boolean"
1615
- },
1616
- healthCheck: {
1617
- type: "string"
1618
- }
1619
- }
1620
- }
1621
- ]
1622
- }
1623
- },
1624
- environment: {
1625
- type: "object",
1626
- additionalProperties: {
1627
- type: "string"
1628
- }
1629
- },
1630
- env: {
1631
- type: "object",
1632
- additionalProperties: {
1633
- type: "string"
1634
- }
1635
- }
1636
- },
1637
- required: [
1638
- "platform",
1639
- "path"
1640
- ],
1641
- additionalProperties: false
1642
- },
1643
- InferenceServiceConfig: {
1644
- type: "object",
1645
- properties: {
1646
- platform: {
1647
- $ref: "#/definitions/ServicePlatformConfig"
1648
- },
1649
- type: {
1650
- type: "string"
1651
- },
1652
- model: {
1653
- type: "string"
1654
- },
1655
- maxTokens: {
1656
- type: "integer"
1657
- },
1658
- endpoint: {
1659
- type: "string"
1660
- },
1661
- baseURL: {
1662
- type: "string"
1663
- },
1664
- apiKey: {
1665
- type: "string"
1666
- },
1667
- command: {
1668
- type: "string"
1669
- },
1670
- image: {
1671
- type: "string"
1672
- },
1673
- port: {
1674
- type: "integer"
1675
- },
1676
- organization: {
1677
- type: "string"
1678
- },
1679
- timeout: {
1680
- type: "integer"
1681
- },
1682
- wait: {
1683
- type: "integer"
1684
- },
1685
- logsEndpoint: {
1686
- type: "string"
1687
- },
1688
- tag: {
1689
- type: "string"
1690
- },
1691
- resources: {
1692
- $ref: "#/definitions/ResourceRequirements"
1693
- },
1694
- security: {
1695
- $ref: "#/definitions/SecurityRequirements"
1696
- },
1697
- build: {
1698
- oneOf: [
1699
- {
1700
- type: "boolean"
1701
- },
1702
- {
1703
- $ref: "#/definitions/BuildRequirements"
1704
- }
1705
- ]
1706
- },
1707
- dockerfile: {
1708
- type: "string"
1709
- },
1710
- buildContext: {
1711
- type: "string"
1712
- },
1713
- buildArgs: {
1714
- type: "object",
1715
- additionalProperties: {
1716
- type: "string"
1717
- }
1718
- },
1719
- buildTarget: {
1720
- type: "string"
1721
- },
1722
- prebuilt: {
1723
- type: "boolean"
1724
- },
1725
- noCache: {
1726
- type: "boolean"
1727
- },
1728
- secrets: {
1729
- type: "array",
1730
- items: {
1731
- type: "string"
1732
- }
1733
- },
1734
- labels: {
1735
- type: "object",
1736
- additionalProperties: {
1737
- type: "string"
1738
- }
1739
- },
1740
- annotations: {
1741
- type: "object",
1742
- additionalProperties: {
1743
- type: "string"
1744
- }
1745
- },
1746
- dependencies: {
1747
- type: "array",
1748
- items: {
1749
- type: "string"
1750
- }
1751
- },
1752
- externalDependencies: {
1753
- type: "array",
1754
- items: {
1755
- oneOf: [
1756
- {
1757
- type: "string"
1758
- },
1759
- {
1760
- type: "object",
1761
- properties: {
1762
- name: {
1763
- type: "string"
1764
- },
1765
- url: {
1766
- type: "string"
1767
- },
1768
- required: {
1769
- type: "boolean"
1770
- },
1771
- healthCheck: {
1772
- type: "string"
1773
- }
1774
- }
1775
- }
1776
- ]
1777
- }
1778
- },
1779
- environment: {
1780
- type: "object",
1781
- additionalProperties: {
1782
- type: "string"
1783
- }
1784
- },
1785
- env: {
1786
- type: "object",
1787
- additionalProperties: {
1788
- type: "string"
1789
- }
1790
- }
1791
- },
1792
- required: [
1793
- "platform",
1794
- "type",
1795
- "apiKey"
1796
- ],
1797
- additionalProperties: false
1798
- },
1799
- McpServiceConfig: {
1800
- type: "object",
1801
- properties: {
1802
- platform: {
1803
- $ref: "#/definitions/ServicePlatformConfig"
1804
- },
1805
- command: {
1806
- type: "string"
1807
- },
1808
- image: {
1809
- type: "string"
1810
- },
1811
- port: {
1812
- type: "integer"
1813
- },
1814
- dependsOn: {
1815
- type: "array",
1816
- items: {
1817
- type: "string"
1818
- }
1819
- },
1820
- timeout: {
1821
- type: "integer"
1822
- },
1823
- wait: {
1824
- type: "integer"
1825
- },
1826
- logsEndpoint: {
1827
- type: "string"
1828
- },
1829
- tag: {
1830
- type: "string"
1831
- },
1832
- resources: {
1833
- $ref: "#/definitions/ResourceRequirements"
1834
- },
1835
- security: {
1836
- $ref: "#/definitions/SecurityRequirements"
1837
- },
1838
- build: {
1839
- oneOf: [
1840
- {
1841
- type: "boolean"
1842
- },
1843
- {
1844
- $ref: "#/definitions/BuildRequirements"
1845
- }
1846
- ]
1847
- },
1848
- dockerfile: {
1849
- type: "string"
1850
- },
1851
- buildContext: {
1852
- type: "string"
1853
- },
1854
- buildArgs: {
1855
- type: "object",
1856
- additionalProperties: {
1857
- type: "string"
1858
- }
1859
- },
1860
- buildTarget: {
1861
- type: "string"
1862
- },
1863
- prebuilt: {
1864
- type: "boolean"
1865
- },
1866
- noCache: {
1867
- type: "boolean"
1868
- },
1869
- secrets: {
1870
- type: "array",
1871
- items: {
1872
- type: "string"
1873
- }
1874
- },
1875
- labels: {
1876
- type: "object",
1877
- additionalProperties: {
1878
- type: "string"
1879
- }
1880
- },
1881
- annotations: {
1882
- type: "object",
1883
- additionalProperties: {
1884
- type: "string"
1885
- }
1886
- },
1887
- dependencies: {
1888
- type: "array",
1889
- items: {
1890
- type: "string"
1891
- }
1892
- },
1893
- externalDependencies: {
1894
- type: "array",
1895
- items: {
1896
- oneOf: [
1897
- {
1898
- type: "string"
1899
- },
1900
- {
1901
- type: "object",
1902
- properties: {
1903
- name: {
1904
- type: "string"
1905
- },
1906
- url: {
1907
- type: "string"
1908
- },
1909
- required: {
1910
- type: "boolean"
1911
- },
1912
- healthCheck: {
1913
- type: "string"
1914
- }
1915
- }
1916
- }
1917
- ]
1918
- }
1919
- },
1920
- environment: {
1921
- type: "object",
1922
- additionalProperties: {
1923
- type: "string"
1924
- }
1925
- },
1926
- env: {
1927
- type: "object",
1928
- additionalProperties: {
1929
- type: "string"
1930
- }
1931
- }
1932
- },
1933
- required: [
1934
- "platform"
1935
- ],
1936
- additionalProperties: false
1937
- },
1938
- ServicesConfig: {
1939
- type: "object",
1940
- properties: {
1941
- backend: {
1942
- $ref: "#/definitions/BackendServiceConfig"
1943
- },
1944
- frontend: {
1945
- $ref: "#/definitions/FrontendServiceConfig"
1946
- },
1947
- database: {
1948
- $ref: "#/definitions/DatabaseServiceConfig"
1949
- },
1950
- graph: {
1951
- $ref: "#/definitions/GraphServiceConfig"
1952
- },
1953
- filesystem: {
1954
- $ref: "#/definitions/FilesystemServiceConfig"
1955
- },
1956
- inference: {
1957
- $ref: "#/definitions/InferenceServiceConfig"
1958
- },
1959
- mcp: {
1960
- $ref: "#/definitions/McpServiceConfig"
1961
- },
1962
- proxy: {
1963
- $ref: "#/definitions/ProxyServiceConfig"
1964
- }
1965
- },
1966
- additionalProperties: true
1967
- },
1968
- SiteConfig: {
1969
- type: "object",
1970
- properties: {
1971
- siteName: {
1972
- type: "string",
1973
- minLength: 1,
1974
- description: "Display name for the site"
1975
- },
1976
- domain: {
1977
- type: "string",
1978
- minLength: 1,
1979
- description: "Primary domain for the site"
1980
- },
1981
- adminEmail: {
1982
- type: "string",
1983
- format: "email",
1984
- description: "Administrator email address"
1985
- },
1986
- supportEmail: {
1987
- type: "string",
1988
- format: "email",
1989
- description: "Support email address (optional)"
1990
- },
1991
- oauthAllowedDomains: {
1992
- type: "array",
1993
- items: {
1994
- type: "string"
1995
- },
1996
- minItems: 1,
1997
- description: "Email domains allowed for OAuth authentication"
1998
- }
1999
- },
2000
- required: [
2001
- "domain"
2002
- ],
2003
- additionalProperties: false
2004
- },
2005
- AppConfig: {
2006
- type: "object",
2007
- properties: {
2008
- features: {
2009
- type: "object",
2010
- properties: {
2011
- enableAnalytics: {
2012
- type: "boolean"
2013
- },
2014
- enableMaintenanceMode: {
2015
- type: "boolean"
2016
- },
2017
- enableDebugLogging: {
2018
- type: "boolean"
2019
- }
2020
- },
2021
- additionalProperties: false
2022
- },
2023
- security: {
2024
- type: "object",
2025
- properties: {
2026
- sessionTimeout: {
2027
- type: "integer",
2028
- minimum: 60,
2029
- description: "Session timeout in seconds"
2030
- },
2031
- maxLoginAttempts: {
2032
- type: "integer",
2033
- minimum: 1,
2034
- description: "Maximum failed login attempts before lockout"
2035
- },
2036
- corsAllowedOrigins: {
2037
- type: "array",
2038
- items: {
2039
- type: "string"
2040
- }
2041
- },
2042
- enableLocalAuth: {
2043
- type: "boolean",
2044
- description: "Enable local username/password authentication"
2045
- },
2046
- jwtSecret: {
2047
- type: "string",
2048
- minLength: 32,
2049
- description: "JWT signing secret (base64 encoded, 32+ bytes)"
2050
- }
2051
- },
2052
- additionalProperties: false
2053
- },
2054
- performance: {
2055
- type: "object",
2056
- properties: {
2057
- enableCaching: {
2058
- type: "boolean"
2059
- },
2060
- cacheTimeout: {
2061
- type: "integer",
2062
- minimum: 0,
2063
- description: "Cache timeout in seconds"
2064
- },
2065
- maxRequestSize: {
2066
- type: "string",
2067
- pattern: "^[0-9]+(kb|mb|gb)$",
2068
- description: "Maximum request size (e.g., '10mb')"
2069
- }
2070
- },
2071
- additionalProperties: false
2072
- }
2073
- },
2074
- additionalProperties: false
2075
- },
2076
- EnvironmentConfig: {
2077
- type: "object",
2078
- properties: {
2079
- _comment: {
2080
- type: "string",
2081
- description: "Optional comment for documentation"
2082
- },
2083
- _metadata: {
2084
- type: "object",
2085
- properties: {
2086
- environment: {
2087
- type: "string"
2088
- },
2089
- projectRoot: {
2090
- type: "string"
2091
- }
2092
- },
2093
- required: [
2094
- "environment",
2095
- "projectRoot"
2096
- ]
2097
- },
2098
- name: {
2099
- type: "string",
2100
- description: "Environment name"
2101
- },
2102
- platform: {
2103
- type: "object",
2104
- properties: {
2105
- default: {
2106
- $ref: "#/definitions/PlatformType"
2107
- }
2108
- }
2109
- },
2110
- services: {
2111
- $ref: "#/definitions/ServicesConfig"
2112
- },
2113
- site: {
2114
- $ref: "#/definitions/SiteConfig"
2115
- },
2116
- app: {
2117
- $ref: "#/definitions/AppConfig"
2118
- },
2119
- env: {
2120
- type: "object",
2121
- properties: {
2122
- NODE_ENV: {
2123
- type: "string",
2124
- enum: [
2125
- "development",
2126
- "production",
2127
- "test"
2128
- ]
2129
- }
2130
- },
2131
- additionalProperties: true
2132
- },
2133
- logLevel: {
2134
- type: "string",
2135
- enum: [
2136
- "error",
2137
- "warn",
2138
- "info",
2139
- "http",
2140
- "debug"
2141
- ],
2142
- description: "Logging verbosity level"
2143
- },
2144
- deployment: {
2145
- type: "object",
2146
- properties: {
2147
- imageTagStrategy: {
2148
- type: "string",
2149
- enum: [
2150
- "mutable",
2151
- "immutable",
2152
- "git-hash"
2153
- ]
2154
- }
2155
- }
2156
- }
2157
- },
2158
- required: [
2159
- "services"
2160
- ],
2161
- additionalProperties: false
2162
- },
2163
- SemiontConfig: {
2164
- type: "object",
2165
- properties: {
2166
- version: {
2167
- type: "string",
2168
- pattern: "^[0-9]+\\.[0-9]+\\.[0-9]+$",
2169
- description: "Config file version (semver)"
2170
- },
2171
- project: {
2172
- type: "string",
2173
- minLength: 1,
2174
- description: "Project name"
2175
- },
2176
- site: {
2177
- $ref: "#/definitions/SiteConfig"
2178
- },
2179
- app: {
2180
- $ref: "#/definitions/AppConfig"
2181
- },
2182
- services: {
2183
- $ref: "#/definitions/ServicesConfig"
2184
- }
2185
- },
2186
- required: [
2187
- "version",
2188
- "project",
2189
- "site"
2190
- ],
2191
- additionalProperties: false
571
+ function deepMerge(base, override) {
572
+ const result = { ...base };
573
+ for (const key of Object.keys(override)) {
574
+ const b = base[key];
575
+ const o = override[key];
576
+ if (o !== void 0 && o !== null && typeof o === "object" && !Array.isArray(o) && b !== void 0 && b !== null && typeof b === "object" && !Array.isArray(b)) {
577
+ result[key] = deepMerge(b, o);
578
+ } else if (o !== void 0) {
579
+ result[key] = o;
2192
580
  }
2193
581
  }
2194
- };
2195
-
2196
- // src/config/config-validator.ts
2197
- var ajv = new Ajv({
2198
- allErrors: true,
2199
- // Return all errors, not just the first one
2200
- coerceTypes: true,
2201
- // Coerce types (e.g., "123" -> 123)
2202
- removeAdditional: false,
2203
- // Don't remove additional properties
2204
- useDefaults: true,
2205
- // Apply default values from schema
2206
- strict: false
2207
- });
2208
- addFormats(ajv);
2209
- ajv.addSchema(config_schema_default, "config");
2210
- function validateSemiontConfig(data) {
2211
- const validate = ajv.getSchema("config#/definitions/SemiontConfig");
2212
- if (!validate) {
2213
- throw new Error("SemiontConfig schema not found");
2214
- }
2215
- const valid = validate(data);
2216
- if (!valid) {
2217
- return {
2218
- valid: false,
2219
- errors: validate.errors || null,
2220
- errorMessage: formatErrors(validate.errors || [])
2221
- };
2222
- }
2223
- return { valid: true, errors: null };
2224
- }
2225
- function validateEnvironmentConfig(data) {
2226
- const validate = ajv.getSchema("config#/definitions/EnvironmentConfig");
2227
- if (!validate) {
2228
- throw new Error("EnvironmentConfig schema not found");
2229
- }
2230
- const valid = validate(data);
2231
- if (!valid) {
2232
- return {
2233
- valid: false,
2234
- errors: validate.errors || null,
2235
- errorMessage: formatErrors(validate.errors || [])
2236
- };
2237
- }
2238
- return { valid: true, errors: null };
2239
- }
2240
- function validateSiteConfig(data) {
2241
- const validate = ajv.getSchema("config#/definitions/SiteConfig");
2242
- if (!validate) {
2243
- throw new Error("SiteConfig schema not found");
2244
- }
2245
- const valid = validate(data);
2246
- if (!valid) {
2247
- return {
2248
- valid: false,
2249
- errors: validate.errors || null,
2250
- errorMessage: formatErrors(validate.errors || [])
2251
- };
2252
- }
2253
- return { valid: true, errors: null };
2254
- }
2255
- function formatErrors(errors) {
2256
- if (errors.length === 0) return "Validation failed";
2257
- const messages = errors.map((err) => {
2258
- const path = err.instancePath || "root";
2259
- const message = err.message || "validation error";
2260
- if (err.keyword === "required" && "missingProperty" in err.params) {
2261
- return `Missing required property: ${err.params.missingProperty}`;
2262
- }
2263
- if (err.keyword === "type" && "type" in err.params) {
2264
- return `${path}: ${message} (expected ${err.params.type})`;
2265
- }
2266
- if (err.keyword === "enum" && "allowedValues" in err.params) {
2267
- return `${path}: must be one of [${err.params.allowedValues.join(", ")}]`;
2268
- }
2269
- if (err.keyword === "format") {
2270
- return `${path}: invalid format (${message})`;
2271
- }
2272
- if (err.keyword === "minLength" || err.keyword === "minItems") {
2273
- return `${path}: ${message}`;
2274
- }
2275
- return `${path}: ${message}`;
2276
- });
2277
- return messages.join("; ");
2278
- }
2279
-
2280
- // src/config/environment-loader.ts
2281
- function deepMerge(target, ...sources) {
2282
- if (!sources.length) return target;
2283
- const source = sources.shift();
2284
- if (isObject(target) && isObject(source)) {
2285
- for (const key in source) {
2286
- if (isObject(source[key])) {
2287
- if (!target[key]) Object.assign(target, { [key]: {} });
2288
- deepMerge(target[key], source[key]);
2289
- } else {
2290
- Object.assign(target, { [key]: source[key] });
2291
- }
2292
- }
2293
- }
2294
- return deepMerge(target, ...sources);
582
+ return result;
2295
583
  }
2296
584
  function resolveEnvVars(obj, env) {
2297
585
  if (typeof obj === "string") {
2298
586
  return obj.replace(/\$\{([^}]+)\}/g, (match, varName) => {
2299
- return env[varName] || match;
587
+ if (env[varName] === void 0) {
588
+ throw new Error(`Environment variable ${varName} is not set (referenced in config as ${match})`);
589
+ }
590
+ return env[varName];
2300
591
  });
2301
592
  }
2302
593
  if (Array.isArray(obj)) {
2303
594
  return obj.map((item) => resolveEnvVars(item, env));
2304
595
  }
2305
- if (obj && typeof obj === "object") {
596
+ if (obj !== null && typeof obj === "object") {
2306
597
  const resolved = {};
2307
598
  for (const key in obj) {
2308
599
  resolved[key] = resolveEnvVars(obj[key], env);
@@ -2311,94 +602,175 @@ function resolveEnvVars(obj, env) {
2311
602
  }
2312
603
  return obj;
2313
604
  }
2314
- function parseAndMergeConfigs(baseContent, envContent, env, environment, projectRoot) {
2315
- try {
2316
- let baseConfig = {};
2317
- if (baseContent) {
2318
- baseConfig = JSON.parse(baseContent);
2319
- }
2320
- const envConfig = JSON.parse(envContent);
2321
- const merged = deepMerge(
2322
- {},
2323
- { site: baseConfig.site },
2324
- // Site config from semiont.json
2325
- baseConfig.defaults || {},
2326
- // Default config from semiont.json
2327
- envConfig
2328
- // Environment-specific overrides
2329
- );
2330
- const resolved = resolveEnvVars(merged, env);
2331
- if (!resolved.services) {
2332
- resolved.services = {};
2333
- }
2334
- if (resolved.env?.NODE_ENV) {
2335
- const validNodeEnv = ["development", "production", "test"];
2336
- if (!validNodeEnv.includes(resolved.env.NODE_ENV)) {
2337
- throw new ConfigurationError(
2338
- `Invalid NODE_ENV value: ${resolved.env.NODE_ENV}`,
2339
- environment,
2340
- `NODE_ENV must be one of: ${validNodeEnv.join(", ")}`
2341
- );
2342
- }
2343
- }
2344
- const configWithMetadata = {
2345
- ...resolved,
2346
- _metadata: {
2347
- environment,
2348
- projectRoot
2349
- }
605
+ function requirePlatform(value, serviceName) {
606
+ if (!value) {
607
+ throw new Error(`platform is required for service '${serviceName}' \u2014 add 'platform = "posix"|"container"|"external"' to its config section`);
608
+ }
609
+ return value;
610
+ }
611
+ function loadTomlConfig(projectRoot, environment, globalConfigPath, reader, env) {
612
+ const projectConfigContent = reader.readIfExists(`${projectRoot}/.semiont/config`);
613
+ let projectName = "semiont-project";
614
+ let projectSite;
615
+ let projectEnvSection = {};
616
+ if (projectConfigContent) {
617
+ const projectConfig = parse(projectConfigContent);
618
+ projectName = projectConfig.project?.name ?? projectName;
619
+ projectSite = projectConfig.site;
620
+ projectEnvSection = projectConfig.environments?.[environment] ?? {};
621
+ }
622
+ const globalContent = reader.readIfExists(globalConfigPath);
623
+ const raw = globalContent ? parse(globalContent) : {};
624
+ const userEnvSection = raw.environments?.[environment] ?? {};
625
+ const envSection = deepMerge(
626
+ projectEnvSection,
627
+ userEnvSection
628
+ );
629
+ const resolved = resolveEnvVars(envSection, env);
630
+ const flatInference = resolved.inference;
631
+ const makeMeaningSection = resolved["make-meaning"];
632
+ const workersSection = resolved.workers ?? {};
633
+ const actorsSection = resolved.actors ?? {};
634
+ const defaultWorkerInference = workersSection["default"]?.inference;
635
+ const defaultMakeMeaningInference = makeMeaningSection?.default?.inference;
636
+ function mergeWithFlatInference(specific) {
637
+ if (!flatInference) return specific;
638
+ return {
639
+ apiKey: flatInference.apiKey,
640
+ maxTokens: flatInference.maxTokens,
641
+ endpoint: flatInference.endpoint,
642
+ baseURL: flatInference.baseURL,
643
+ ...specific
2350
644
  };
2351
- const validationResult = validateEnvironmentConfig(configWithMetadata);
2352
- if (!validationResult.valid) {
2353
- throw new ConfigurationError(
2354
- `Invalid environment configuration: ${validationResult.errorMessage}`,
2355
- environment,
2356
- `Fix the validation errors in your environments/${environment}.json file`
2357
- );
645
+ }
646
+ function resolveActorInference(fromMakeMeaning, fromActors) {
647
+ const base = fromMakeMeaning ?? fromActors ?? defaultMakeMeaningInference;
648
+ if (!base) return void 0;
649
+ return mergeWithFlatInference(base);
650
+ }
651
+ const actors = {};
652
+ const gathererInference = resolveActorInference(
653
+ makeMeaningSection?.actors?.gatherer?.inference,
654
+ actorsSection["gatherer"]?.inference
655
+ );
656
+ if (gathererInference) actors.gatherer = gathererInference;
657
+ const matcherInference = resolveActorInference(
658
+ makeMeaningSection?.actors?.matcher?.inference,
659
+ actorsSection["matcher"]?.inference
660
+ );
661
+ if (matcherInference) actors.matcher = matcherInference;
662
+ const workers = {};
663
+ const workerTypes = ["reference-annotation", "highlight-annotation", "assessment-annotation", "comment-annotation", "tag-annotation", "generation"];
664
+ if (defaultWorkerInference) {
665
+ workers.default = mergeWithFlatInference(defaultWorkerInference);
666
+ }
667
+ for (const wt of workerTypes) {
668
+ const specific = workersSection[wt]?.inference;
669
+ if (specific) {
670
+ workers[wt] = mergeWithFlatInference(specific);
2358
671
  }
2359
- return configWithMetadata;
2360
- } catch (error) {
2361
- if (error instanceof ConfigurationError) {
2362
- throw error;
672
+ }
673
+ const backend = resolved.backend;
674
+ const site = resolved.site ?? projectSite;
675
+ const inferenceSection = resolved.inference;
676
+ let inferenceProviders;
677
+ if (inferenceSection) {
678
+ inferenceProviders = {};
679
+ if (inferenceSection.type === "anthropic") {
680
+ inferenceProviders.anthropic = {
681
+ platform: requirePlatform(inferenceSection.platform, "inference"),
682
+ endpoint: inferenceSection.endpoint ?? "https://api.anthropic.com",
683
+ apiKey: inferenceSection.apiKey ?? ""
684
+ };
685
+ } else if (inferenceSection.type === "ollama") {
686
+ inferenceProviders.ollama = {
687
+ platform: { type: requirePlatform(inferenceSection.platform, "inference") },
688
+ baseURL: inferenceSection.baseURL,
689
+ port: inferenceSection.baseURL ? void 0 : 11434
690
+ };
2363
691
  }
2364
- if (error instanceof SyntaxError && error.message.includes("JSON")) {
2365
- throw new ConfigurationError(
2366
- `Invalid JSON syntax in configuration file`,
2367
- environment,
2368
- `Check for missing commas, quotes, or brackets. Use a JSON validator to verify syntax.`
2369
- );
692
+ }
693
+ const topLevelWorkers = {};
694
+ for (const [name, w] of Object.entries(workersSection)) {
695
+ if (w.inference) {
696
+ topLevelWorkers[name] = { inference: { type: w.inference.type, model: w.inference.model } };
2370
697
  }
2371
- const message = error instanceof Error ? error.message : String(error);
2372
- throw new ConfigurationError(
2373
- `Failed to parse environment configuration: ${message}`,
2374
- environment,
2375
- `Check the configuration files are valid JSON`
2376
- );
2377
698
  }
699
+ const topLevelActors = {};
700
+ for (const [name, a] of Object.entries(actorsSection)) {
701
+ if (a.inference) {
702
+ topLevelActors[name] = { inference: { type: a.inference.type, model: a.inference.model } };
703
+ }
704
+ }
705
+ if (makeMeaningSection?.actors?.gatherer?.inference) {
706
+ topLevelActors["gatherer"] = { inference: { type: makeMeaningSection.actors.gatherer.inference.type, model: makeMeaningSection.actors.gatherer.inference.model } };
707
+ }
708
+ if (makeMeaningSection?.actors?.matcher?.inference) {
709
+ topLevelActors["matcher"] = { inference: { type: makeMeaningSection.actors.matcher.inference.type, model: makeMeaningSection.actors.matcher.inference.model } };
710
+ }
711
+ const frontend = resolved.frontend;
712
+ const proxy = resolved.proxy;
713
+ const config = {
714
+ services: {
715
+ backend: backend ? {
716
+ platform: { type: requirePlatform(backend.platform, "backend") },
717
+ port: backend.port ?? 4e3,
718
+ publicURL: backend.publicURL ?? `http://localhost:${backend.port ?? 4e3}`,
719
+ corsOrigin: backend.corsOrigin ?? backend.frontendURL ?? "http://localhost:3000"
720
+ } : void 0,
721
+ frontend: frontend ? {
722
+ platform: { type: requirePlatform(frontend.platform, "frontend") },
723
+ port: frontend.port ?? 3e3,
724
+ siteName: site?.siteName ?? "Semiont",
725
+ publicURL: frontend.publicURL
726
+ } : void 0,
727
+ proxy: proxy ? {
728
+ platform: { type: requirePlatform(proxy.platform, "proxy") },
729
+ type: "envoy",
730
+ port: proxy.port ?? 8080,
731
+ adminPort: proxy.adminPort ?? 9901,
732
+ backendPort: backend?.port ?? 4e3,
733
+ frontendPort: frontend?.port ?? 3e3
734
+ } : void 0,
735
+ graph: resolved.graph ? {
736
+ ...resolved.graph,
737
+ platform: { type: requirePlatform(resolved.graph.platform, "graph") },
738
+ type: resolved.graph.type ?? "neo4j"
739
+ } : makeMeaningSection?.graph,
740
+ database: resolved.database ? {
741
+ platform: { type: requirePlatform(resolved.database.platform, "database") },
742
+ type: "postgres",
743
+ image: resolved.database.image,
744
+ host: resolved.database.host ?? "localhost",
745
+ port: resolved.database.port ?? 5432,
746
+ name: resolved.database.name,
747
+ user: resolved.database.user,
748
+ password: resolved.database.password
749
+ } : void 0
750
+ },
751
+ ...inferenceProviders ? { inference: inferenceProviders } : {},
752
+ ...Object.keys(topLevelWorkers).length > 0 ? { workers: topLevelWorkers } : {},
753
+ ...Object.keys(topLevelActors).length > 0 ? { actors: topLevelActors } : {},
754
+ site: site ? {
755
+ domain: site.domain ?? "localhost",
756
+ siteName: site.siteName,
757
+ adminEmail: site.adminEmail,
758
+ oauthAllowedDomains: site.oauthAllowedDomains
759
+ } : void 0,
760
+ logLevel: resolved.logLevel,
761
+ _metadata: {
762
+ environment,
763
+ projectRoot,
764
+ projectName,
765
+ ...Object.keys(actors).length > 0 ? { actors } : {},
766
+ ...Object.keys(workers).length > 0 ? { workers } : {}
767
+ }
768
+ };
769
+ return config;
2378
770
  }
2379
- function getNodeEnvForEnvironment(config) {
2380
- const nodeEnv = config.env?.NODE_ENV;
2381
- return nodeEnv || "development";
2382
- }
2383
- function listEnvironmentNames(files) {
2384
- return files.filter((file) => file.endsWith(".json")).map((file) => {
2385
- const lastSlash = Math.max(file.lastIndexOf("/"), file.lastIndexOf("\\"));
2386
- const filename = lastSlash >= 0 ? file.substring(lastSlash + 1) : file;
2387
- return filename.slice(0, -5);
2388
- }).sort();
2389
- }
2390
- function hasAWSConfig(config) {
2391
- return !!config.aws && !!config.aws.region;
2392
- }
2393
- function displayConfiguration(config) {
2394
- console.log("Environment Configuration:");
2395
- console.log(JSON.stringify(config, null, 2));
2396
- }
2397
- function createConfigLoader(reader) {
771
+ function createTomlConfigLoader(reader, globalConfigPath, env) {
2398
772
  return (projectRoot, environment) => {
2399
- const baseContent = reader.readIfExists(`${projectRoot}/semiont.json`);
2400
- const envContent = reader.readRequired(`${projectRoot}/environments/${environment}.json`);
2401
- return parseAndMergeConfigs(baseContent, envContent, process.env, environment, projectRoot);
773
+ return loadTomlConfig(projectRoot, environment, globalConfigPath, reader, env);
2402
774
  };
2403
775
  }
2404
776
 
@@ -2426,6 +798,33 @@ function validateEnvironment(value, availableEnvironments) {
2426
798
  return value;
2427
799
  }
2428
800
 
801
+ // src/config/configuration-error.ts
802
+ var ConfigurationError = class extends Error {
803
+ constructor(message, environment, suggestion, cause) {
804
+ super(message);
805
+ this.environment = environment;
806
+ this.suggestion = suggestion;
807
+ this.name = "ConfigurationError";
808
+ this.cause = cause;
809
+ }
810
+ cause;
811
+ /**
812
+ * Format the error nicely for CLI output
813
+ */
814
+ toString() {
815
+ let output = `\u274C ${this.message}`;
816
+ if (this.environment) {
817
+ output += `
818
+ Environment: ${this.environment}`;
819
+ }
820
+ if (this.suggestion) {
821
+ output += `
822
+ \u{1F4A1} Suggestion: ${this.suggestion}`;
823
+ }
824
+ return output;
825
+ }
826
+ };
827
+
2429
828
  // src/config/platform-types.ts
2430
829
  function isValidPlatformType(value) {
2431
830
  return ["aws", "container", "posix", "external"].includes(value);
@@ -2438,6 +837,6 @@ function getAllPlatformTypes() {
2438
837
  var CORE_TYPES_VERSION = "0.1.0";
2439
838
  var SDK_VERSION = "0.1.0";
2440
839
 
2441
- export { APIError, CORE_TYPES_VERSION, CREATION_METHODS, ConfigurationError, ConflictError, EventBus, NotFoundError, SDK_VERSION, ScopedEventBus, ScriptError, SemiontError, UnauthorizedError, ValidationError, accessToken, annotationId, annotationUri, applyBodyOperations, assembleAnnotation, authCode, baseUrl, burstBuffer, cloneToken, createConfigLoader, deepMerge, didToAgent, displayConfiguration, email, entityType, findBodyItem, formatErrors, generateUuid, getAllPlatformTypes, getAnnotationUriFromEvent, getEventType, getFragmentSelector, getNodeEnvForEnvironment, getSvgSelector, getTextPositionSelector, googleCredential, hasAWSConfig, isAnnotationId, isArray, isBoolean, isDefined, isEventRelatedToAnnotation, isFunction, isNull, isNullish, isNumber, isObject, isResourceEvent, isResourceId, isResourceScopedEvent, isResourceEvent2 as isStoredEvent, isString, isSystemEvent, isUndefined, isValidPlatformType, jobId, listEnvironmentNames, mcpToken, parseAndMergeConfigs, parseEnvironment, refreshToken, resolveEnvVars, resourceAnnotationUri, resourceId, resourceUri, searchQuery, userDID, userId, userToAgent, userToDid, validateEnvironment, validateEnvironmentConfig, validateSemiontConfig, validateSiteConfig, validateSvgMarkup };
840
+ export { APIError, CORE_TYPES_VERSION, CREATION_METHODS, ConfigurationError, ConflictError, EventBus, NotFoundError, SDK_VERSION, ScopedEventBus, ScriptError, SemiontError, UnauthorizedError, ValidationError, accessToken, annotationId, annotationUri, applyBodyOperations, assembleAnnotation, authCode, baseUrl, burstBuffer, cloneToken, createTomlConfigLoader, didToAgent, email, entityType, findBodyItem, generateUuid, getAllPlatformTypes, getAnnotationUriFromEvent, getEventType, getFragmentSelector, getSvgSelector, getTextPositionSelector, googleCredential, isAnnotationId, isArray, isBoolean, isDefined, isEventRelatedToAnnotation, isFunction, isNull, isNullish, isNumber, isObject, isResourceEvent, isResourceId, isResourceScopedEvent, isResourceEvent2 as isStoredEvent, isString, isSystemEvent, isUndefined, isValidPlatformType, jobId, loadTomlConfig, mcpToken, parseEnvironment, refreshToken, resourceAnnotationUri, resourceId, resourceUri, searchQuery, userDID, userId, userToAgent, userToDid, validateEnvironment, validateSvgMarkup };
2442
841
  //# sourceMappingURL=index.js.map
2443
842
  //# sourceMappingURL=index.js.map