@albinocrabs/o-switcher 0.3.0 → 0.4.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.
- package/CHANGELOG.md +11 -0
- package/dist/{chunk-XXH633FY.js → chunk-2EYMYNKS.js} +3 -101
- package/dist/chunk-BHHR2U5B.cjs +123 -0
- package/dist/chunk-HAEEX3KB.js +106 -0
- package/dist/chunk-I6RDAZBR.js +231 -0
- package/dist/chunk-QKEHCM2F.cjs +234 -0
- package/dist/{chunk-H72U2MNG.cjs → chunk-TGYAV5TV.cjs} +18 -128
- package/dist/index.cjs +104 -103
- package/dist/index.js +3 -2
- package/dist/plugin.cjs +60 -67
- package/dist/plugin.js +41 -48
- package/dist/proxy/cli.cjs +91 -0
- package/dist/proxy/cli.d.cts +1 -0
- package/dist/proxy/cli.d.ts +1 -0
- package/dist/proxy/cli.js +89 -0
- package/package.json +4 -1
- package/src/tui.tsx +11 -3
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkTGYAV5TV_cjs = require('./chunk-TGYAV5TV.cjs');
|
|
4
|
+
var chunkBHHR2U5B_cjs = require('./chunk-BHHR2U5B.cjs');
|
|
4
5
|
var crypto = require('crypto');
|
|
5
6
|
|
|
6
7
|
// src/mode/detection.ts
|
|
@@ -631,7 +632,7 @@ var createStreamStitcher = (_requestId) => {
|
|
|
631
632
|
|
|
632
633
|
// src/execution/audit-collector.ts
|
|
633
634
|
var createAuditCollector = (logger, requestId) => {
|
|
634
|
-
const requestLogger =
|
|
635
|
+
const requestLogger = chunkBHHR2U5B_cjs.createRequestLogger(logger, requestId);
|
|
635
636
|
const attempts = [];
|
|
636
637
|
const segments = [];
|
|
637
638
|
return {
|
|
@@ -661,7 +662,7 @@ var createAuditCollector = (logger, requestId) => {
|
|
|
661
662
|
// src/execution/orchestrator.ts
|
|
662
663
|
var createExecutionOrchestrator = (deps) => ({
|
|
663
664
|
async execute(request) {
|
|
664
|
-
const requestId = request.request_id ||
|
|
665
|
+
const requestId = request.request_id || chunkBHHR2U5B_cjs.generateCorrelationId();
|
|
665
666
|
const auditCollector = createAuditCollector(deps.logger, requestId);
|
|
666
667
|
const stitcher = createStreamStitcher();
|
|
667
668
|
const startMs = Date.now();
|
|
@@ -760,7 +761,7 @@ var createExecutionOrchestrator = (deps) => ({
|
|
|
760
761
|
};
|
|
761
762
|
} finally {
|
|
762
763
|
auditCollector.flush(outcome, finalTarget);
|
|
763
|
-
const requestLogger =
|
|
764
|
+
const requestLogger = chunkBHHR2U5B_cjs.createRequestLogger(deps.logger, requestId);
|
|
764
765
|
const endMs = Date.now();
|
|
765
766
|
requestLogger.info(
|
|
766
767
|
{
|
|
@@ -891,279 +892,279 @@ var validateBearerToken = (authHeader, expectedToken) => {
|
|
|
891
892
|
|
|
892
893
|
Object.defineProperty(exports, "ADMISSION_RESULTS", {
|
|
893
894
|
enumerable: true,
|
|
894
|
-
get: function () { return
|
|
895
|
+
get: function () { return chunkTGYAV5TV_cjs.ADMISSION_RESULTS; }
|
|
895
896
|
});
|
|
896
897
|
Object.defineProperty(exports, "BackoffConfigSchema", {
|
|
897
898
|
enumerable: true,
|
|
898
|
-
get: function () { return
|
|
899
|
+
get: function () { return chunkTGYAV5TV_cjs.BackoffConfigSchema; }
|
|
899
900
|
});
|
|
900
901
|
Object.defineProperty(exports, "ConfigValidationError", {
|
|
901
902
|
enumerable: true,
|
|
902
|
-
get: function () { return
|
|
903
|
+
get: function () { return chunkTGYAV5TV_cjs.ConfigValidationError; }
|
|
903
904
|
});
|
|
904
905
|
Object.defineProperty(exports, "DEFAULT_ALPHA", {
|
|
905
906
|
enumerable: true,
|
|
906
|
-
get: function () { return
|
|
907
|
+
get: function () { return chunkTGYAV5TV_cjs.DEFAULT_ALPHA; }
|
|
907
908
|
});
|
|
908
909
|
Object.defineProperty(exports, "DEFAULT_BACKOFF_BASE_MS", {
|
|
909
910
|
enumerable: true,
|
|
910
|
-
get: function () { return
|
|
911
|
+
get: function () { return chunkTGYAV5TV_cjs.DEFAULT_BACKOFF_BASE_MS; }
|
|
911
912
|
});
|
|
912
913
|
Object.defineProperty(exports, "DEFAULT_BACKOFF_JITTER", {
|
|
913
914
|
enumerable: true,
|
|
914
|
-
get: function () { return
|
|
915
|
+
get: function () { return chunkTGYAV5TV_cjs.DEFAULT_BACKOFF_JITTER; }
|
|
915
916
|
});
|
|
916
917
|
Object.defineProperty(exports, "DEFAULT_BACKOFF_MAX_MS", {
|
|
917
918
|
enumerable: true,
|
|
918
|
-
get: function () { return
|
|
919
|
+
get: function () { return chunkTGYAV5TV_cjs.DEFAULT_BACKOFF_MAX_MS; }
|
|
919
920
|
});
|
|
920
921
|
Object.defineProperty(exports, "DEFAULT_BACKOFF_MULTIPLIER", {
|
|
921
922
|
enumerable: true,
|
|
922
|
-
get: function () { return
|
|
923
|
+
get: function () { return chunkTGYAV5TV_cjs.DEFAULT_BACKOFF_MULTIPLIER; }
|
|
923
924
|
});
|
|
924
925
|
Object.defineProperty(exports, "DEFAULT_BACKOFF_PARAMS", {
|
|
925
926
|
enumerable: true,
|
|
926
|
-
get: function () { return
|
|
927
|
+
get: function () { return chunkTGYAV5TV_cjs.DEFAULT_BACKOFF_PARAMS; }
|
|
927
928
|
});
|
|
928
929
|
Object.defineProperty(exports, "DEFAULT_FAILOVER_BUDGET", {
|
|
929
930
|
enumerable: true,
|
|
930
|
-
get: function () { return
|
|
931
|
+
get: function () { return chunkTGYAV5TV_cjs.DEFAULT_FAILOVER_BUDGET; }
|
|
931
932
|
});
|
|
932
933
|
Object.defineProperty(exports, "DEFAULT_RETRY", {
|
|
933
934
|
enumerable: true,
|
|
934
|
-
get: function () { return
|
|
935
|
+
get: function () { return chunkTGYAV5TV_cjs.DEFAULT_RETRY; }
|
|
935
936
|
});
|
|
936
937
|
Object.defineProperty(exports, "DEFAULT_RETRY_BUDGET", {
|
|
937
938
|
enumerable: true,
|
|
938
|
-
get: function () { return
|
|
939
|
+
get: function () { return chunkTGYAV5TV_cjs.DEFAULT_RETRY_BUDGET; }
|
|
939
940
|
});
|
|
940
941
|
Object.defineProperty(exports, "DEFAULT_TIMEOUT_MS", {
|
|
941
942
|
enumerable: true,
|
|
942
|
-
get: function () { return
|
|
943
|
+
get: function () { return chunkTGYAV5TV_cjs.DEFAULT_TIMEOUT_MS; }
|
|
943
944
|
});
|
|
944
945
|
Object.defineProperty(exports, "DualBreaker", {
|
|
945
946
|
enumerable: true,
|
|
946
|
-
get: function () { return
|
|
947
|
+
get: function () { return chunkTGYAV5TV_cjs.DualBreaker; }
|
|
947
948
|
});
|
|
948
949
|
Object.defineProperty(exports, "EXCLUSION_REASONS", {
|
|
949
950
|
enumerable: true,
|
|
950
|
-
get: function () { return
|
|
951
|
+
get: function () { return chunkTGYAV5TV_cjs.EXCLUSION_REASONS; }
|
|
951
952
|
});
|
|
952
953
|
Object.defineProperty(exports, "ErrorClassSchema", {
|
|
953
954
|
enumerable: true,
|
|
954
|
-
get: function () { return
|
|
955
|
+
get: function () { return chunkTGYAV5TV_cjs.ErrorClassSchema; }
|
|
955
956
|
});
|
|
956
957
|
Object.defineProperty(exports, "INITIAL_HEALTH_SCORE", {
|
|
957
958
|
enumerable: true,
|
|
958
|
-
get: function () { return
|
|
959
|
-
});
|
|
960
|
-
Object.defineProperty(exports, "REDACT_PATHS", {
|
|
961
|
-
enumerable: true,
|
|
962
|
-
get: function () { return chunkH72U2MNG_cjs.REDACT_PATHS; }
|
|
959
|
+
get: function () { return chunkTGYAV5TV_cjs.INITIAL_HEALTH_SCORE; }
|
|
963
960
|
});
|
|
964
961
|
Object.defineProperty(exports, "SwitcherConfigSchema", {
|
|
965
962
|
enumerable: true,
|
|
966
|
-
get: function () { return
|
|
963
|
+
get: function () { return chunkTGYAV5TV_cjs.SwitcherConfigSchema; }
|
|
967
964
|
});
|
|
968
965
|
Object.defineProperty(exports, "TARGET_STATES", {
|
|
969
966
|
enumerable: true,
|
|
970
|
-
get: function () { return
|
|
967
|
+
get: function () { return chunkTGYAV5TV_cjs.TARGET_STATES; }
|
|
971
968
|
});
|
|
972
969
|
Object.defineProperty(exports, "TargetConfigSchema", {
|
|
973
970
|
enumerable: true,
|
|
974
|
-
get: function () { return
|
|
971
|
+
get: function () { return chunkTGYAV5TV_cjs.TargetConfigSchema; }
|
|
975
972
|
});
|
|
976
973
|
Object.defineProperty(exports, "TargetRegistry", {
|
|
977
974
|
enumerable: true,
|
|
978
|
-
get: function () { return
|
|
979
|
-
});
|
|
980
|
-
Object.defineProperty(exports, "addProfile", {
|
|
981
|
-
enumerable: true,
|
|
982
|
-
get: function () { return chunkH72U2MNG_cjs.addProfile; }
|
|
975
|
+
get: function () { return chunkTGYAV5TV_cjs.TargetRegistry; }
|
|
983
976
|
});
|
|
984
977
|
Object.defineProperty(exports, "applyConfigDiff", {
|
|
985
978
|
enumerable: true,
|
|
986
|
-
get: function () { return
|
|
979
|
+
get: function () { return chunkTGYAV5TV_cjs.applyConfigDiff; }
|
|
987
980
|
});
|
|
988
981
|
Object.defineProperty(exports, "checkHardRejects", {
|
|
989
982
|
enumerable: true,
|
|
990
|
-
get: function () { return
|
|
983
|
+
get: function () { return chunkTGYAV5TV_cjs.checkHardRejects; }
|
|
991
984
|
});
|
|
992
985
|
Object.defineProperty(exports, "computeBackoffMs", {
|
|
993
986
|
enumerable: true,
|
|
994
|
-
get: function () { return
|
|
987
|
+
get: function () { return chunkTGYAV5TV_cjs.computeBackoffMs; }
|
|
995
988
|
});
|
|
996
989
|
Object.defineProperty(exports, "computeConfigDiff", {
|
|
997
990
|
enumerable: true,
|
|
998
|
-
get: function () { return
|
|
991
|
+
get: function () { return chunkTGYAV5TV_cjs.computeConfigDiff; }
|
|
999
992
|
});
|
|
1000
993
|
Object.defineProperty(exports, "computeCooldownMs", {
|
|
1001
994
|
enumerable: true,
|
|
1002
|
-
get: function () { return
|
|
995
|
+
get: function () { return chunkTGYAV5TV_cjs.computeCooldownMs; }
|
|
1003
996
|
});
|
|
1004
997
|
Object.defineProperty(exports, "computeScore", {
|
|
1005
998
|
enumerable: true,
|
|
1006
|
-
get: function () { return
|
|
999
|
+
get: function () { return chunkTGYAV5TV_cjs.computeScore; }
|
|
1007
1000
|
});
|
|
1008
1001
|
Object.defineProperty(exports, "createAdmissionController", {
|
|
1009
1002
|
enumerable: true,
|
|
1010
|
-
get: function () { return
|
|
1011
|
-
});
|
|
1012
|
-
Object.defineProperty(exports, "createAuditLogger", {
|
|
1013
|
-
enumerable: true,
|
|
1014
|
-
get: function () { return chunkH72U2MNG_cjs.createAuditLogger; }
|
|
1003
|
+
get: function () { return chunkTGYAV5TV_cjs.createAdmissionController; }
|
|
1015
1004
|
});
|
|
1016
1005
|
Object.defineProperty(exports, "createAuthWatcher", {
|
|
1017
1006
|
enumerable: true,
|
|
1018
|
-
get: function () { return
|
|
1007
|
+
get: function () { return chunkTGYAV5TV_cjs.createAuthWatcher; }
|
|
1019
1008
|
});
|
|
1020
1009
|
Object.defineProperty(exports, "createCircuitBreaker", {
|
|
1021
1010
|
enumerable: true,
|
|
1022
|
-
get: function () { return
|
|
1011
|
+
get: function () { return chunkTGYAV5TV_cjs.createCircuitBreaker; }
|
|
1023
1012
|
});
|
|
1024
1013
|
Object.defineProperty(exports, "createConcurrencyTracker", {
|
|
1025
1014
|
enumerable: true,
|
|
1026
|
-
get: function () { return
|
|
1015
|
+
get: function () { return chunkTGYAV5TV_cjs.createConcurrencyTracker; }
|
|
1027
1016
|
});
|
|
1028
1017
|
Object.defineProperty(exports, "createCooldownManager", {
|
|
1029
1018
|
enumerable: true,
|
|
1030
|
-
get: function () { return
|
|
1019
|
+
get: function () { return chunkTGYAV5TV_cjs.createCooldownManager; }
|
|
1031
1020
|
});
|
|
1032
1021
|
Object.defineProperty(exports, "createFailoverOrchestrator", {
|
|
1033
1022
|
enumerable: true,
|
|
1034
|
-
get: function () { return
|
|
1023
|
+
get: function () { return chunkTGYAV5TV_cjs.createFailoverOrchestrator; }
|
|
1035
1024
|
});
|
|
1036
1025
|
Object.defineProperty(exports, "createLogSubscriber", {
|
|
1037
1026
|
enumerable: true,
|
|
1038
|
-
get: function () { return
|
|
1027
|
+
get: function () { return chunkTGYAV5TV_cjs.createLogSubscriber; }
|
|
1039
1028
|
});
|
|
1040
1029
|
Object.defineProperty(exports, "createOperatorTools", {
|
|
1041
1030
|
enumerable: true,
|
|
1042
|
-
get: function () { return
|
|
1031
|
+
get: function () { return chunkTGYAV5TV_cjs.createOperatorTools; }
|
|
1043
1032
|
});
|
|
1044
1033
|
Object.defineProperty(exports, "createProfileTools", {
|
|
1045
1034
|
enumerable: true,
|
|
1046
|
-
get: function () { return
|
|
1035
|
+
get: function () { return chunkTGYAV5TV_cjs.createProfileTools; }
|
|
1047
1036
|
});
|
|
1048
1037
|
Object.defineProperty(exports, "createRegistry", {
|
|
1049
1038
|
enumerable: true,
|
|
1050
|
-
get: function () { return
|
|
1051
|
-
});
|
|
1052
|
-
Object.defineProperty(exports, "createRequestLogger", {
|
|
1053
|
-
enumerable: true,
|
|
1054
|
-
get: function () { return chunkH72U2MNG_cjs.createRequestLogger; }
|
|
1039
|
+
get: function () { return chunkTGYAV5TV_cjs.createRegistry; }
|
|
1055
1040
|
});
|
|
1056
1041
|
Object.defineProperty(exports, "createRequestTraceBuffer", {
|
|
1057
1042
|
enumerable: true,
|
|
1058
|
-
get: function () { return
|
|
1043
|
+
get: function () { return chunkTGYAV5TV_cjs.createRequestTraceBuffer; }
|
|
1059
1044
|
});
|
|
1060
1045
|
Object.defineProperty(exports, "createRetryPolicy", {
|
|
1061
1046
|
enumerable: true,
|
|
1062
|
-
get: function () { return
|
|
1047
|
+
get: function () { return chunkTGYAV5TV_cjs.createRetryPolicy; }
|
|
1063
1048
|
});
|
|
1064
1049
|
Object.defineProperty(exports, "createRoutingEventBus", {
|
|
1065
1050
|
enumerable: true,
|
|
1066
|
-
get: function () { return
|
|
1051
|
+
get: function () { return chunkTGYAV5TV_cjs.createRoutingEventBus; }
|
|
1067
1052
|
});
|
|
1068
1053
|
Object.defineProperty(exports, "disableTarget", {
|
|
1069
1054
|
enumerable: true,
|
|
1070
|
-
get: function () { return
|
|
1055
|
+
get: function () { return chunkTGYAV5TV_cjs.disableTarget; }
|
|
1071
1056
|
});
|
|
1072
1057
|
Object.defineProperty(exports, "discoverTargets", {
|
|
1073
1058
|
enumerable: true,
|
|
1074
|
-
get: function () { return
|
|
1059
|
+
get: function () { return chunkTGYAV5TV_cjs.discoverTargets; }
|
|
1075
1060
|
});
|
|
1076
1061
|
Object.defineProperty(exports, "discoverTargetsFromProfiles", {
|
|
1077
1062
|
enumerable: true,
|
|
1078
|
-
get: function () { return
|
|
1063
|
+
get: function () { return chunkTGYAV5TV_cjs.discoverTargetsFromProfiles; }
|
|
1079
1064
|
});
|
|
1080
1065
|
Object.defineProperty(exports, "drainTarget", {
|
|
1081
1066
|
enumerable: true,
|
|
1082
|
-
get: function () { return
|
|
1083
|
-
});
|
|
1084
|
-
Object.defineProperty(exports, "generateCorrelationId", {
|
|
1085
|
-
enumerable: true,
|
|
1086
|
-
get: function () { return chunkH72U2MNG_cjs.generateCorrelationId; }
|
|
1067
|
+
get: function () { return chunkTGYAV5TV_cjs.drainTarget; }
|
|
1087
1068
|
});
|
|
1088
1069
|
Object.defineProperty(exports, "getExclusionReason", {
|
|
1089
1070
|
enumerable: true,
|
|
1090
|
-
get: function () { return
|
|
1071
|
+
get: function () { return chunkTGYAV5TV_cjs.getExclusionReason; }
|
|
1091
1072
|
});
|
|
1092
1073
|
Object.defineProperty(exports, "getTargetStateTransition", {
|
|
1093
1074
|
enumerable: true,
|
|
1094
|
-
get: function () { return
|
|
1075
|
+
get: function () { return chunkTGYAV5TV_cjs.getTargetStateTransition; }
|
|
1095
1076
|
});
|
|
1096
1077
|
Object.defineProperty(exports, "inspectRequest", {
|
|
1097
1078
|
enumerable: true,
|
|
1098
|
-
get: function () { return
|
|
1079
|
+
get: function () { return chunkTGYAV5TV_cjs.inspectRequest; }
|
|
1099
1080
|
});
|
|
1100
1081
|
Object.defineProperty(exports, "isRetryable", {
|
|
1101
1082
|
enumerable: true,
|
|
1102
|
-
get: function () { return
|
|
1103
|
-
});
|
|
1104
|
-
Object.defineProperty(exports, "listProfiles", {
|
|
1105
|
-
enumerable: true,
|
|
1106
|
-
get: function () { return chunkH72U2MNG_cjs.listProfiles; }
|
|
1083
|
+
get: function () { return chunkTGYAV5TV_cjs.isRetryable; }
|
|
1107
1084
|
});
|
|
1108
1085
|
Object.defineProperty(exports, "listTargets", {
|
|
1109
1086
|
enumerable: true,
|
|
1110
|
-
get: function () { return
|
|
1111
|
-
});
|
|
1112
|
-
Object.defineProperty(exports, "loadProfiles", {
|
|
1113
|
-
enumerable: true,
|
|
1114
|
-
get: function () { return chunkH72U2MNG_cjs.loadProfiles; }
|
|
1115
|
-
});
|
|
1116
|
-
Object.defineProperty(exports, "nextProfileId", {
|
|
1117
|
-
enumerable: true,
|
|
1118
|
-
get: function () { return chunkH72U2MNG_cjs.nextProfileId; }
|
|
1087
|
+
get: function () { return chunkTGYAV5TV_cjs.listTargets; }
|
|
1119
1088
|
});
|
|
1120
1089
|
Object.defineProperty(exports, "normalizeLatency", {
|
|
1121
1090
|
enumerable: true,
|
|
1122
|
-
get: function () { return
|
|
1091
|
+
get: function () { return chunkTGYAV5TV_cjs.normalizeLatency; }
|
|
1123
1092
|
});
|
|
1124
1093
|
Object.defineProperty(exports, "pauseTarget", {
|
|
1125
1094
|
enumerable: true,
|
|
1126
|
-
get: function () { return
|
|
1095
|
+
get: function () { return chunkTGYAV5TV_cjs.pauseTarget; }
|
|
1127
1096
|
});
|
|
1128
1097
|
Object.defineProperty(exports, "reloadConfig", {
|
|
1129
1098
|
enumerable: true,
|
|
1130
|
-
get: function () { return
|
|
1131
|
-
});
|
|
1132
|
-
Object.defineProperty(exports, "removeProfile", {
|
|
1133
|
-
enumerable: true,
|
|
1134
|
-
get: function () { return chunkH72U2MNG_cjs.removeProfile; }
|
|
1099
|
+
get: function () { return chunkTGYAV5TV_cjs.reloadConfig; }
|
|
1135
1100
|
});
|
|
1136
1101
|
Object.defineProperty(exports, "resumeTarget", {
|
|
1137
1102
|
enumerable: true,
|
|
1138
|
-
get: function () { return
|
|
1139
|
-
});
|
|
1140
|
-
Object.defineProperty(exports, "saveProfiles", {
|
|
1141
|
-
enumerable: true,
|
|
1142
|
-
get: function () { return chunkH72U2MNG_cjs.saveProfiles; }
|
|
1103
|
+
get: function () { return chunkTGYAV5TV_cjs.resumeTarget; }
|
|
1143
1104
|
});
|
|
1144
1105
|
Object.defineProperty(exports, "selectTarget", {
|
|
1145
1106
|
enumerable: true,
|
|
1146
|
-
get: function () { return
|
|
1107
|
+
get: function () { return chunkTGYAV5TV_cjs.selectTarget; }
|
|
1147
1108
|
});
|
|
1148
1109
|
Object.defineProperty(exports, "switchProfile", {
|
|
1149
1110
|
enumerable: true,
|
|
1150
|
-
get: function () { return
|
|
1111
|
+
get: function () { return chunkTGYAV5TV_cjs.switchProfile; }
|
|
1151
1112
|
});
|
|
1152
1113
|
Object.defineProperty(exports, "switchToNextProfile", {
|
|
1153
1114
|
enumerable: true,
|
|
1154
|
-
get: function () { return
|
|
1115
|
+
get: function () { return chunkTGYAV5TV_cjs.switchToNextProfile; }
|
|
1155
1116
|
});
|
|
1156
1117
|
Object.defineProperty(exports, "updateHealthScore", {
|
|
1157
1118
|
enumerable: true,
|
|
1158
|
-
get: function () { return
|
|
1119
|
+
get: function () { return chunkTGYAV5TV_cjs.updateHealthScore; }
|
|
1159
1120
|
});
|
|
1160
1121
|
Object.defineProperty(exports, "updateLatencyEma", {
|
|
1161
1122
|
enumerable: true,
|
|
1162
|
-
get: function () { return
|
|
1123
|
+
get: function () { return chunkTGYAV5TV_cjs.updateLatencyEma; }
|
|
1163
1124
|
});
|
|
1164
1125
|
Object.defineProperty(exports, "validateConfig", {
|
|
1165
1126
|
enumerable: true,
|
|
1166
|
-
get: function () { return
|
|
1127
|
+
get: function () { return chunkTGYAV5TV_cjs.validateConfig; }
|
|
1128
|
+
});
|
|
1129
|
+
Object.defineProperty(exports, "REDACT_PATHS", {
|
|
1130
|
+
enumerable: true,
|
|
1131
|
+
get: function () { return chunkBHHR2U5B_cjs.REDACT_PATHS; }
|
|
1132
|
+
});
|
|
1133
|
+
Object.defineProperty(exports, "addProfile", {
|
|
1134
|
+
enumerable: true,
|
|
1135
|
+
get: function () { return chunkBHHR2U5B_cjs.addProfile; }
|
|
1136
|
+
});
|
|
1137
|
+
Object.defineProperty(exports, "createAuditLogger", {
|
|
1138
|
+
enumerable: true,
|
|
1139
|
+
get: function () { return chunkBHHR2U5B_cjs.createAuditLogger; }
|
|
1140
|
+
});
|
|
1141
|
+
Object.defineProperty(exports, "createRequestLogger", {
|
|
1142
|
+
enumerable: true,
|
|
1143
|
+
get: function () { return chunkBHHR2U5B_cjs.createRequestLogger; }
|
|
1144
|
+
});
|
|
1145
|
+
Object.defineProperty(exports, "generateCorrelationId", {
|
|
1146
|
+
enumerable: true,
|
|
1147
|
+
get: function () { return chunkBHHR2U5B_cjs.generateCorrelationId; }
|
|
1148
|
+
});
|
|
1149
|
+
Object.defineProperty(exports, "listProfiles", {
|
|
1150
|
+
enumerable: true,
|
|
1151
|
+
get: function () { return chunkBHHR2U5B_cjs.listProfiles; }
|
|
1152
|
+
});
|
|
1153
|
+
Object.defineProperty(exports, "loadProfiles", {
|
|
1154
|
+
enumerable: true,
|
|
1155
|
+
get: function () { return chunkBHHR2U5B_cjs.loadProfiles; }
|
|
1156
|
+
});
|
|
1157
|
+
Object.defineProperty(exports, "nextProfileId", {
|
|
1158
|
+
enumerable: true,
|
|
1159
|
+
get: function () { return chunkBHHR2U5B_cjs.nextProfileId; }
|
|
1160
|
+
});
|
|
1161
|
+
Object.defineProperty(exports, "removeProfile", {
|
|
1162
|
+
enumerable: true,
|
|
1163
|
+
get: function () { return chunkBHHR2U5B_cjs.removeProfile; }
|
|
1164
|
+
});
|
|
1165
|
+
Object.defineProperty(exports, "saveProfiles", {
|
|
1166
|
+
enumerable: true,
|
|
1167
|
+
get: function () { return chunkBHHR2U5B_cjs.saveProfiles; }
|
|
1167
1168
|
});
|
|
1168
1169
|
exports.HEURISTIC_PATTERNS = HEURISTIC_PATTERNS;
|
|
1169
1170
|
exports.PROVIDER_PATTERNS = PROVIDER_PATTERNS;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export { ADMISSION_RESULTS, BackoffConfigSchema, ConfigValidationError, DEFAULT_ALPHA, DEFAULT_BACKOFF_BASE_MS, DEFAULT_BACKOFF_JITTER, DEFAULT_BACKOFF_MAX_MS, DEFAULT_BACKOFF_MULTIPLIER, DEFAULT_BACKOFF_PARAMS, DEFAULT_FAILOVER_BUDGET, DEFAULT_RETRY, DEFAULT_RETRY_BUDGET, DEFAULT_TIMEOUT_MS, DualBreaker, EXCLUSION_REASONS, ErrorClassSchema, INITIAL_HEALTH_SCORE, SwitcherConfigSchema, TARGET_STATES, TargetConfigSchema, TargetRegistry, applyConfigDiff, checkHardRejects, computeBackoffMs, computeConfigDiff, computeCooldownMs, computeScore, createAdmissionController, createAuthWatcher, createCircuitBreaker, createConcurrencyTracker, createCooldownManager, createFailoverOrchestrator, createLogSubscriber, createOperatorTools, createProfileTools, createRegistry, createRequestTraceBuffer, createRetryPolicy, createRoutingEventBus, disableTarget, discoverTargets, discoverTargetsFromProfiles, drainTarget, getExclusionReason, getTargetStateTransition, inspectRequest, isRetryable, listTargets, normalizeLatency, pauseTarget, reloadConfig, resumeTarget, selectTarget, switchProfile, switchToNextProfile, updateHealthScore, updateLatencyEma, validateConfig } from './chunk-2EYMYNKS.js';
|
|
2
|
+
import { createRequestLogger, generateCorrelationId } from './chunk-HAEEX3KB.js';
|
|
3
|
+
export { REDACT_PATHS, addProfile, createAuditLogger, createRequestLogger, generateCorrelationId, listProfiles, loadProfiles, nextProfileId, removeProfile, saveProfiles } from './chunk-HAEEX3KB.js';
|
|
3
4
|
import { timingSafeEqual } from 'crypto';
|
|
4
5
|
|
|
5
6
|
// src/mode/detection.ts
|
package/dist/plugin.cjs
CHANGED
|
@@ -2,63 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var os = require('os');
|
|
9
|
-
|
|
10
|
-
var STATE_DIR = path.join(os.homedir(), ".local", "share", "o-switcher");
|
|
11
|
-
var STATE_FILE = path.join(STATE_DIR, "tui-state.json");
|
|
12
|
-
var STATE_TMP = path.join(STATE_DIR, "tui-state.json.tmp");
|
|
13
|
-
var writeStateAtomic = async (state) => {
|
|
14
|
-
await promises.mkdir(path.dirname(STATE_FILE), { recursive: true });
|
|
15
|
-
const json = JSON.stringify(state);
|
|
16
|
-
await promises.writeFile(STATE_TMP, json, "utf8");
|
|
17
|
-
await promises.rename(STATE_TMP, STATE_FILE);
|
|
18
|
-
};
|
|
19
|
-
var createStateWriter = (debounceMs = 500) => {
|
|
20
|
-
let pending;
|
|
21
|
-
let timer;
|
|
22
|
-
let writePromise = Promise.resolve();
|
|
23
|
-
const doWrite = () => {
|
|
24
|
-
if (!pending) return;
|
|
25
|
-
const snapshot = pending;
|
|
26
|
-
pending = void 0;
|
|
27
|
-
writePromise = writeStateAtomic(snapshot).catch(() => void 0);
|
|
28
|
-
};
|
|
29
|
-
const write = (state) => {
|
|
30
|
-
pending = state;
|
|
31
|
-
if (timer) clearTimeout(timer);
|
|
32
|
-
timer = setTimeout(doWrite, debounceMs);
|
|
33
|
-
};
|
|
34
|
-
const flush = async () => {
|
|
35
|
-
if (timer) {
|
|
36
|
-
clearTimeout(timer);
|
|
37
|
-
timer = void 0;
|
|
38
|
-
}
|
|
39
|
-
doWrite();
|
|
40
|
-
await writePromise;
|
|
41
|
-
};
|
|
42
|
-
return { write, flush };
|
|
43
|
-
};
|
|
5
|
+
var chunkTGYAV5TV_cjs = require('./chunk-TGYAV5TV.cjs');
|
|
6
|
+
var chunkQKEHCM2F_cjs = require('./chunk-QKEHCM2F.cjs');
|
|
7
|
+
var chunkBHHR2U5B_cjs = require('./chunk-BHHR2U5B.cjs');
|
|
44
8
|
|
|
45
9
|
// src/plugin.ts
|
|
46
10
|
var initializeSwitcher = (rawConfig) => {
|
|
47
|
-
const config =
|
|
48
|
-
const registry =
|
|
49
|
-
const logger =
|
|
50
|
-
const eventBus =
|
|
11
|
+
const config = chunkTGYAV5TV_cjs.validateConfig(rawConfig);
|
|
12
|
+
const registry = chunkTGYAV5TV_cjs.createRegistry(config);
|
|
13
|
+
const logger = chunkBHHR2U5B_cjs.createAuditLogger();
|
|
14
|
+
const eventBus = chunkTGYAV5TV_cjs.createRoutingEventBus();
|
|
51
15
|
const circuitBreakers = /* @__PURE__ */ new Map();
|
|
52
16
|
for (const target of registry.getAllTargets()) {
|
|
53
17
|
circuitBreakers.set(
|
|
54
18
|
target.target_id,
|
|
55
|
-
|
|
19
|
+
chunkTGYAV5TV_cjs.createCircuitBreaker(target.target_id, config.circuit_breaker, eventBus)
|
|
56
20
|
);
|
|
57
21
|
}
|
|
58
|
-
const concurrency =
|
|
59
|
-
const cooldownManager =
|
|
60
|
-
const traceBuffer =
|
|
61
|
-
|
|
22
|
+
const concurrency = chunkTGYAV5TV_cjs.createConcurrencyTracker(config.concurrency_limit);
|
|
23
|
+
const cooldownManager = chunkTGYAV5TV_cjs.createCooldownManager(registry, eventBus);
|
|
24
|
+
const traceBuffer = chunkTGYAV5TV_cjs.createRequestTraceBuffer(100);
|
|
25
|
+
chunkTGYAV5TV_cjs.createLogSubscriber(eventBus, logger);
|
|
62
26
|
const configRef = {
|
|
63
27
|
current: () => config,
|
|
64
28
|
swap: () => {
|
|
@@ -94,10 +58,10 @@ var snapshotState = (state) => {
|
|
|
94
58
|
};
|
|
95
59
|
};
|
|
96
60
|
var server = async (_input) => {
|
|
97
|
-
const logger =
|
|
61
|
+
const logger = chunkBHHR2U5B_cjs.createAuditLogger({ level: "info" });
|
|
98
62
|
logger.info("O-Switcher plugin initializing");
|
|
99
63
|
const state = {};
|
|
100
|
-
const stateWriter = createStateWriter();
|
|
64
|
+
const stateWriter = chunkQKEHCM2F_cjs.createStateWriter();
|
|
101
65
|
const publishTuiState = () => {
|
|
102
66
|
const snapshot = snapshotState(state);
|
|
103
67
|
if (snapshot) stateWriter.write(snapshot);
|
|
@@ -137,17 +101,17 @@ var server = async (_input) => {
|
|
|
137
101
|
rawConfig["targets"] && Array.isArray(rawConfig["targets"]) && rawConfig["targets"].length > 0
|
|
138
102
|
);
|
|
139
103
|
if (!hasExplicitTargets) {
|
|
140
|
-
const profileStore = await
|
|
104
|
+
const profileStore = await chunkBHHR2U5B_cjs.loadProfiles().catch(() => ({}));
|
|
141
105
|
const profileKeys = Object.keys(profileStore);
|
|
142
106
|
if (profileKeys.length > 0) {
|
|
143
|
-
const profileTargets =
|
|
107
|
+
const profileTargets = chunkTGYAV5TV_cjs.discoverTargetsFromProfiles(profileStore);
|
|
144
108
|
rawConfig["targets"] = profileTargets;
|
|
145
109
|
logger.info(
|
|
146
110
|
{ discovered: profileTargets.length, profiles: profileKeys },
|
|
147
111
|
"Auto-discovered targets from O-Switcher profiles"
|
|
148
112
|
);
|
|
149
113
|
} else if (providerConfig && typeof providerConfig === "object") {
|
|
150
|
-
const discoveredTargets =
|
|
114
|
+
const discoveredTargets = chunkTGYAV5TV_cjs.discoverTargets(providerConfig);
|
|
151
115
|
if (discoveredTargets.length === 0) {
|
|
152
116
|
logger.warn("No providers found \u2014 running in passthrough mode");
|
|
153
117
|
return;
|
|
@@ -167,7 +131,29 @@ var server = async (_input) => {
|
|
|
167
131
|
Object.assign(state, initialized);
|
|
168
132
|
logger.info({ targets: state.registry?.getAllTargets().length }, "O-Switcher initialized");
|
|
169
133
|
publishTuiState();
|
|
170
|
-
|
|
134
|
+
const proxyEnabled = switcherConfig?.["proxy"] !== false && !process.env["VITEST"];
|
|
135
|
+
if (proxyEnabled) {
|
|
136
|
+
const proxyPort = Number(switcherConfig?.["proxy_port"] ?? 4444);
|
|
137
|
+
try {
|
|
138
|
+
const proxy = await chunkQKEHCM2F_cjs.createProxy({
|
|
139
|
+
port: proxyPort,
|
|
140
|
+
provider: "openai",
|
|
141
|
+
maxRetries: 3
|
|
142
|
+
});
|
|
143
|
+
await proxy.start();
|
|
144
|
+
logger.info({ port: proxyPort }, "Proxy started \u2014 rotating API keys on 429");
|
|
145
|
+
if (providerConfig) {
|
|
146
|
+
const providerEntry = providerConfig["openai"];
|
|
147
|
+
if (providerEntry && typeof providerEntry === "object") {
|
|
148
|
+
providerEntry["baseURL"] = `http://localhost:${proxyPort}/v1`;
|
|
149
|
+
logger.info("Patched openai provider baseURL to proxy");
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
} catch (proxyErr) {
|
|
153
|
+
logger.warn({ err: proxyErr }, "Proxy failed to start \u2014 continuing without key rotation");
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
state.authWatcher = chunkTGYAV5TV_cjs.createAuthWatcher({ logger });
|
|
171
157
|
await state.authWatcher.start();
|
|
172
158
|
logger.info("Auth watcher started");
|
|
173
159
|
} catch (err) {
|
|
@@ -182,7 +168,7 @@ var server = async (_input) => {
|
|
|
182
168
|
*/
|
|
183
169
|
async "chat.params"(input, output) {
|
|
184
170
|
if (!state.registry) return;
|
|
185
|
-
const requestId =
|
|
171
|
+
const requestId = chunkBHHR2U5B_cjs.generateCorrelationId();
|
|
186
172
|
const targets = state.registry.getAllTargets();
|
|
187
173
|
const providerId = input.provider?.info?.id ?? input.provider?.info?.name ?? input.model?.providerID ?? void 0;
|
|
188
174
|
if (!providerId) return;
|
|
@@ -239,35 +225,42 @@ var server = async (_input) => {
|
|
|
239
225
|
state.registry.recordObservation(target.target_id, 0);
|
|
240
226
|
state.circuitBreakers?.get(target.target_id)?.recordFailure();
|
|
241
227
|
publishTuiState();
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
);
|
|
246
|
-
if (
|
|
247
|
-
|
|
248
|
-
|
|
228
|
+
const errorObj = error;
|
|
229
|
+
const statusCode = errorObj.statusCode ?? errorObj.error?.statusCode;
|
|
230
|
+
const errorName = String(errorObj.name ?? errorObj.error ?? "");
|
|
231
|
+
const isRateLimit = statusCode === 429 || statusCode === "429" || errorName.includes("RateLimitError") || errorName.includes("QuotaExceeded");
|
|
232
|
+
if (isRateLimit) {
|
|
233
|
+
state.logger?.info(
|
|
234
|
+
{ target_id: target.target_id, statusCode },
|
|
235
|
+
"Rate limit hit \u2014 switching profile"
|
|
236
|
+
);
|
|
237
|
+
chunkTGYAV5TV_cjs.switchToNextProfile({
|
|
249
238
|
provider: providerId,
|
|
250
239
|
currentProfileId: target.target_id,
|
|
251
|
-
excludeProfileIds: unhealthyIds,
|
|
252
240
|
logger: state.logger
|
|
253
241
|
}).then((result) => {
|
|
254
242
|
if (result.success) {
|
|
255
243
|
state.logger?.info(
|
|
256
244
|
{ from: result.from, to: result.to, provider: providerId },
|
|
257
|
-
"
|
|
245
|
+
"Switched to next profile after rate limit"
|
|
258
246
|
);
|
|
259
247
|
}
|
|
260
248
|
}).catch((err) => {
|
|
261
|
-
state.logger?.warn({ err }, "Failed to
|
|
249
|
+
state.logger?.warn({ err }, "Failed to switch profile");
|
|
262
250
|
});
|
|
251
|
+
} else {
|
|
252
|
+
state.logger?.info(
|
|
253
|
+
{ target_id: target.target_id, event_type: event.type },
|
|
254
|
+
"Recorded failure from session event"
|
|
255
|
+
);
|
|
263
256
|
}
|
|
264
257
|
}
|
|
265
258
|
}
|
|
266
259
|
}
|
|
267
260
|
},
|
|
268
261
|
tool: {
|
|
269
|
-
...
|
|
270
|
-
...
|
|
262
|
+
...chunkTGYAV5TV_cjs.createProfileTools(),
|
|
263
|
+
...chunkTGYAV5TV_cjs.createOperatorTools(lazyOperatorDeps)
|
|
271
264
|
}
|
|
272
265
|
};
|
|
273
266
|
return hooks;
|