@albinocrabs/o-switcher 0.1.1 → 0.2.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/dist/index.cjs CHANGED
@@ -1,8 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkVABBGKSR_cjs = require('./chunk-VABBGKSR.cjs');
3
+ var chunkTJ7ZGZHD_cjs = require('./chunk-TJ7ZGZHD.cjs');
4
4
  var crypto = require('crypto');
5
- var tool = require('@opencode-ai/plugin/tool');
6
5
 
7
6
  // src/mode/detection.ts
8
7
  var detectDeploymentMode = (hint) => {
@@ -632,7 +631,7 @@ var createStreamStitcher = (_requestId) => {
632
631
 
633
632
  // src/execution/audit-collector.ts
634
633
  var createAuditCollector = (logger, requestId) => {
635
- const requestLogger = chunkVABBGKSR_cjs.createRequestLogger(logger, requestId);
634
+ const requestLogger = chunkTJ7ZGZHD_cjs.createRequestLogger(logger, requestId);
636
635
  const attempts = [];
637
636
  const segments = [];
638
637
  return {
@@ -662,7 +661,7 @@ var createAuditCollector = (logger, requestId) => {
662
661
  // src/execution/orchestrator.ts
663
662
  var createExecutionOrchestrator = (deps) => ({
664
663
  async execute(request) {
665
- const requestId = request.request_id || chunkVABBGKSR_cjs.generateCorrelationId();
664
+ const requestId = request.request_id || chunkTJ7ZGZHD_cjs.generateCorrelationId();
666
665
  const auditCollector = createAuditCollector(deps.logger, requestId);
667
666
  const stitcher = createStreamStitcher();
668
667
  const startMs = Date.now();
@@ -704,7 +703,12 @@ var createExecutionOrchestrator = (deps) => ({
704
703
  outcome = "success";
705
704
  finalTarget = failoverResult.target_id;
706
705
  const attemptValue = failoverResult.value;
707
- const continuationMode = stitcher.segmentCount() === 0 ? "same_target_resume" : "same_target_resume";
706
+ const continuationMode = stitcher.segmentCount() === 0 ? "same_target_resume" : determineContinuationMode(
707
+ stitcher.assemble().segments[stitcher.segmentCount() - 1].source_target_id,
708
+ failoverResult.target_id,
709
+ true
710
+ // same model assumption in plugin-only mode
711
+ );
708
712
  stitcher.addSegment(attemptValue.buffer, {
709
713
  request_id: requestId,
710
714
  segment_id: stitcher.segmentCount(),
@@ -756,7 +760,7 @@ var createExecutionOrchestrator = (deps) => ({
756
760
  };
757
761
  } finally {
758
762
  auditCollector.flush(outcome, finalTarget);
759
- const requestLogger = chunkVABBGKSR_cjs.createRequestLogger(deps.logger, requestId);
763
+ const requestLogger = chunkTJ7ZGZHD_cjs.createRequestLogger(deps.logger, requestId);
760
764
  const endMs = Date.now();
761
765
  requestLogger.info(
762
766
  {
@@ -884,342 +888,274 @@ var validateBearerToken = (authHeader, expectedToken) => {
884
888
  }
885
889
  return { authorized: true };
886
890
  };
887
- var { schema: z } = tool.tool;
888
- var createOperatorTools = (deps) => ({
889
- listTargets: tool.tool({
890
- description: "List all routing targets with health scores, states, and circuit breaker status.",
891
- args: {},
892
- async execute() {
893
- deps.logger.info({ op: "listTargets" }, "operator: listTargets");
894
- const result = chunkVABBGKSR_cjs.listTargets(deps);
895
- return JSON.stringify(result, null, 2);
896
- }
897
- }),
898
- pauseTarget: tool.tool({
899
- description: "Pause a target, preventing new requests from being routed to it.",
900
- args: { target_id: z.string().min(1) },
901
- async execute(args) {
902
- deps.logger.info({ op: "pauseTarget", target_id: args.target_id }, "operator: pauseTarget");
903
- const result = chunkVABBGKSR_cjs.pauseTarget(deps, args.target_id);
904
- return JSON.stringify(result, null, 2);
905
- }
906
- }),
907
- resumeTarget: tool.tool({
908
- description: "Resume a previously paused or disabled target, allowing new requests.",
909
- args: { target_id: z.string().min(1) },
910
- async execute(args) {
911
- deps.logger.info({ op: "resumeTarget", target_id: args.target_id }, "operator: resumeTarget");
912
- const result = chunkVABBGKSR_cjs.resumeTarget(deps, args.target_id);
913
- return JSON.stringify(result, null, 2);
914
- }
915
- }),
916
- drainTarget: tool.tool({
917
- description: "Drain a target, allowing in-flight requests to complete but preventing new ones.",
918
- args: { target_id: z.string().min(1) },
919
- async execute(args) {
920
- deps.logger.info({ op: "drainTarget", target_id: args.target_id }, "operator: drainTarget");
921
- const result = chunkVABBGKSR_cjs.drainTarget(deps, args.target_id);
922
- return JSON.stringify(result, null, 2);
923
- }
924
- }),
925
- disableTarget: tool.tool({
926
- description: "Disable a target entirely, removing it from routing.",
927
- args: { target_id: z.string().min(1) },
928
- async execute(args) {
929
- deps.logger.info(
930
- { op: "disableTarget", target_id: args.target_id },
931
- "operator: disableTarget"
932
- );
933
- const result = chunkVABBGKSR_cjs.disableTarget(deps, args.target_id);
934
- return JSON.stringify(result, null, 2);
935
- }
936
- }),
937
- inspectRequest: tool.tool({
938
- description: "Inspect a request trace by ID, showing attempts, segments, and outcome.",
939
- args: { request_id: z.string().min(1) },
940
- async execute(args) {
941
- deps.logger.info(
942
- { op: "inspectRequest", request_id: args.request_id },
943
- "operator: inspectRequest"
944
- );
945
- const result = chunkVABBGKSR_cjs.inspectRequest(deps, args.request_id);
946
- return JSON.stringify(result, null, 2);
947
- }
948
- }),
949
- reloadConfig: tool.tool({
950
- description: "Reload routing configuration with diff-apply. Validates new config before applying.",
951
- args: { config: z.record(z.string(), z.unknown()) },
952
- async execute(args) {
953
- deps.logger.info({ op: "reloadConfig" }, "operator: reloadConfig");
954
- const result = chunkVABBGKSR_cjs.reloadConfig(deps, args.config);
955
- return JSON.stringify(result, null, 2);
956
- }
957
- })
958
- });
959
891
 
960
892
  Object.defineProperty(exports, "ADMISSION_RESULTS", {
961
893
  enumerable: true,
962
- get: function () { return chunkVABBGKSR_cjs.ADMISSION_RESULTS; }
894
+ get: function () { return chunkTJ7ZGZHD_cjs.ADMISSION_RESULTS; }
963
895
  });
964
896
  Object.defineProperty(exports, "BackoffConfigSchema", {
965
897
  enumerable: true,
966
- get: function () { return chunkVABBGKSR_cjs.BackoffConfigSchema; }
898
+ get: function () { return chunkTJ7ZGZHD_cjs.BackoffConfigSchema; }
967
899
  });
968
900
  Object.defineProperty(exports, "ConfigValidationError", {
969
901
  enumerable: true,
970
- get: function () { return chunkVABBGKSR_cjs.ConfigValidationError; }
902
+ get: function () { return chunkTJ7ZGZHD_cjs.ConfigValidationError; }
971
903
  });
972
904
  Object.defineProperty(exports, "DEFAULT_ALPHA", {
973
905
  enumerable: true,
974
- get: function () { return chunkVABBGKSR_cjs.DEFAULT_ALPHA; }
906
+ get: function () { return chunkTJ7ZGZHD_cjs.DEFAULT_ALPHA; }
975
907
  });
976
908
  Object.defineProperty(exports, "DEFAULT_BACKOFF_BASE_MS", {
977
909
  enumerable: true,
978
- get: function () { return chunkVABBGKSR_cjs.DEFAULT_BACKOFF_BASE_MS; }
910
+ get: function () { return chunkTJ7ZGZHD_cjs.DEFAULT_BACKOFF_BASE_MS; }
979
911
  });
980
912
  Object.defineProperty(exports, "DEFAULT_BACKOFF_JITTER", {
981
913
  enumerable: true,
982
- get: function () { return chunkVABBGKSR_cjs.DEFAULT_BACKOFF_JITTER; }
914
+ get: function () { return chunkTJ7ZGZHD_cjs.DEFAULT_BACKOFF_JITTER; }
983
915
  });
984
916
  Object.defineProperty(exports, "DEFAULT_BACKOFF_MAX_MS", {
985
917
  enumerable: true,
986
- get: function () { return chunkVABBGKSR_cjs.DEFAULT_BACKOFF_MAX_MS; }
918
+ get: function () { return chunkTJ7ZGZHD_cjs.DEFAULT_BACKOFF_MAX_MS; }
987
919
  });
988
920
  Object.defineProperty(exports, "DEFAULT_BACKOFF_MULTIPLIER", {
989
921
  enumerable: true,
990
- get: function () { return chunkVABBGKSR_cjs.DEFAULT_BACKOFF_MULTIPLIER; }
922
+ get: function () { return chunkTJ7ZGZHD_cjs.DEFAULT_BACKOFF_MULTIPLIER; }
991
923
  });
992
924
  Object.defineProperty(exports, "DEFAULT_BACKOFF_PARAMS", {
993
925
  enumerable: true,
994
- get: function () { return chunkVABBGKSR_cjs.DEFAULT_BACKOFF_PARAMS; }
926
+ get: function () { return chunkTJ7ZGZHD_cjs.DEFAULT_BACKOFF_PARAMS; }
995
927
  });
996
928
  Object.defineProperty(exports, "DEFAULT_FAILOVER_BUDGET", {
997
929
  enumerable: true,
998
- get: function () { return chunkVABBGKSR_cjs.DEFAULT_FAILOVER_BUDGET; }
930
+ get: function () { return chunkTJ7ZGZHD_cjs.DEFAULT_FAILOVER_BUDGET; }
999
931
  });
1000
932
  Object.defineProperty(exports, "DEFAULT_RETRY", {
1001
933
  enumerable: true,
1002
- get: function () { return chunkVABBGKSR_cjs.DEFAULT_RETRY; }
934
+ get: function () { return chunkTJ7ZGZHD_cjs.DEFAULT_RETRY; }
1003
935
  });
1004
936
  Object.defineProperty(exports, "DEFAULT_RETRY_BUDGET", {
1005
937
  enumerable: true,
1006
- get: function () { return chunkVABBGKSR_cjs.DEFAULT_RETRY_BUDGET; }
938
+ get: function () { return chunkTJ7ZGZHD_cjs.DEFAULT_RETRY_BUDGET; }
1007
939
  });
1008
940
  Object.defineProperty(exports, "DEFAULT_TIMEOUT_MS", {
1009
941
  enumerable: true,
1010
- get: function () { return chunkVABBGKSR_cjs.DEFAULT_TIMEOUT_MS; }
942
+ get: function () { return chunkTJ7ZGZHD_cjs.DEFAULT_TIMEOUT_MS; }
1011
943
  });
1012
944
  Object.defineProperty(exports, "DualBreaker", {
1013
945
  enumerable: true,
1014
- get: function () { return chunkVABBGKSR_cjs.DualBreaker; }
946
+ get: function () { return chunkTJ7ZGZHD_cjs.DualBreaker; }
1015
947
  });
1016
948
  Object.defineProperty(exports, "EXCLUSION_REASONS", {
1017
949
  enumerable: true,
1018
- get: function () { return chunkVABBGKSR_cjs.EXCLUSION_REASONS; }
950
+ get: function () { return chunkTJ7ZGZHD_cjs.EXCLUSION_REASONS; }
1019
951
  });
1020
952
  Object.defineProperty(exports, "ErrorClassSchema", {
1021
953
  enumerable: true,
1022
- get: function () { return chunkVABBGKSR_cjs.ErrorClassSchema; }
954
+ get: function () { return chunkTJ7ZGZHD_cjs.ErrorClassSchema; }
1023
955
  });
1024
956
  Object.defineProperty(exports, "INITIAL_HEALTH_SCORE", {
1025
957
  enumerable: true,
1026
- get: function () { return chunkVABBGKSR_cjs.INITIAL_HEALTH_SCORE; }
958
+ get: function () { return chunkTJ7ZGZHD_cjs.INITIAL_HEALTH_SCORE; }
1027
959
  });
1028
960
  Object.defineProperty(exports, "REDACT_PATHS", {
1029
961
  enumerable: true,
1030
- get: function () { return chunkVABBGKSR_cjs.REDACT_PATHS; }
962
+ get: function () { return chunkTJ7ZGZHD_cjs.REDACT_PATHS; }
1031
963
  });
1032
964
  Object.defineProperty(exports, "SwitcherConfigSchema", {
1033
965
  enumerable: true,
1034
- get: function () { return chunkVABBGKSR_cjs.SwitcherConfigSchema; }
966
+ get: function () { return chunkTJ7ZGZHD_cjs.SwitcherConfigSchema; }
1035
967
  });
1036
968
  Object.defineProperty(exports, "TARGET_STATES", {
1037
969
  enumerable: true,
1038
- get: function () { return chunkVABBGKSR_cjs.TARGET_STATES; }
970
+ get: function () { return chunkTJ7ZGZHD_cjs.TARGET_STATES; }
1039
971
  });
1040
972
  Object.defineProperty(exports, "TargetConfigSchema", {
1041
973
  enumerable: true,
1042
- get: function () { return chunkVABBGKSR_cjs.TargetConfigSchema; }
974
+ get: function () { return chunkTJ7ZGZHD_cjs.TargetConfigSchema; }
1043
975
  });
1044
976
  Object.defineProperty(exports, "TargetRegistry", {
1045
977
  enumerable: true,
1046
- get: function () { return chunkVABBGKSR_cjs.TargetRegistry; }
978
+ get: function () { return chunkTJ7ZGZHD_cjs.TargetRegistry; }
1047
979
  });
1048
980
  Object.defineProperty(exports, "addProfile", {
1049
981
  enumerable: true,
1050
- get: function () { return chunkVABBGKSR_cjs.addProfile; }
982
+ get: function () { return chunkTJ7ZGZHD_cjs.addProfile; }
1051
983
  });
1052
984
  Object.defineProperty(exports, "applyConfigDiff", {
1053
985
  enumerable: true,
1054
- get: function () { return chunkVABBGKSR_cjs.applyConfigDiff; }
986
+ get: function () { return chunkTJ7ZGZHD_cjs.applyConfigDiff; }
1055
987
  });
1056
988
  Object.defineProperty(exports, "checkHardRejects", {
1057
989
  enumerable: true,
1058
- get: function () { return chunkVABBGKSR_cjs.checkHardRejects; }
990
+ get: function () { return chunkTJ7ZGZHD_cjs.checkHardRejects; }
1059
991
  });
1060
992
  Object.defineProperty(exports, "computeBackoffMs", {
1061
993
  enumerable: true,
1062
- get: function () { return chunkVABBGKSR_cjs.computeBackoffMs; }
994
+ get: function () { return chunkTJ7ZGZHD_cjs.computeBackoffMs; }
1063
995
  });
1064
996
  Object.defineProperty(exports, "computeConfigDiff", {
1065
997
  enumerable: true,
1066
- get: function () { return chunkVABBGKSR_cjs.computeConfigDiff; }
998
+ get: function () { return chunkTJ7ZGZHD_cjs.computeConfigDiff; }
1067
999
  });
1068
1000
  Object.defineProperty(exports, "computeCooldownMs", {
1069
1001
  enumerable: true,
1070
- get: function () { return chunkVABBGKSR_cjs.computeCooldownMs; }
1002
+ get: function () { return chunkTJ7ZGZHD_cjs.computeCooldownMs; }
1071
1003
  });
1072
1004
  Object.defineProperty(exports, "computeScore", {
1073
1005
  enumerable: true,
1074
- get: function () { return chunkVABBGKSR_cjs.computeScore; }
1006
+ get: function () { return chunkTJ7ZGZHD_cjs.computeScore; }
1075
1007
  });
1076
1008
  Object.defineProperty(exports, "createAdmissionController", {
1077
1009
  enumerable: true,
1078
- get: function () { return chunkVABBGKSR_cjs.createAdmissionController; }
1010
+ get: function () { return chunkTJ7ZGZHD_cjs.createAdmissionController; }
1079
1011
  });
1080
1012
  Object.defineProperty(exports, "createAuditLogger", {
1081
1013
  enumerable: true,
1082
- get: function () { return chunkVABBGKSR_cjs.createAuditLogger; }
1014
+ get: function () { return chunkTJ7ZGZHD_cjs.createAuditLogger; }
1083
1015
  });
1084
1016
  Object.defineProperty(exports, "createAuthWatcher", {
1085
1017
  enumerable: true,
1086
- get: function () { return chunkVABBGKSR_cjs.createAuthWatcher; }
1018
+ get: function () { return chunkTJ7ZGZHD_cjs.createAuthWatcher; }
1087
1019
  });
1088
1020
  Object.defineProperty(exports, "createCircuitBreaker", {
1089
1021
  enumerable: true,
1090
- get: function () { return chunkVABBGKSR_cjs.createCircuitBreaker; }
1022
+ get: function () { return chunkTJ7ZGZHD_cjs.createCircuitBreaker; }
1091
1023
  });
1092
1024
  Object.defineProperty(exports, "createConcurrencyTracker", {
1093
1025
  enumerable: true,
1094
- get: function () { return chunkVABBGKSR_cjs.createConcurrencyTracker; }
1026
+ get: function () { return chunkTJ7ZGZHD_cjs.createConcurrencyTracker; }
1095
1027
  });
1096
1028
  Object.defineProperty(exports, "createCooldownManager", {
1097
1029
  enumerable: true,
1098
- get: function () { return chunkVABBGKSR_cjs.createCooldownManager; }
1030
+ get: function () { return chunkTJ7ZGZHD_cjs.createCooldownManager; }
1099
1031
  });
1100
1032
  Object.defineProperty(exports, "createFailoverOrchestrator", {
1101
1033
  enumerable: true,
1102
- get: function () { return chunkVABBGKSR_cjs.createFailoverOrchestrator; }
1034
+ get: function () { return chunkTJ7ZGZHD_cjs.createFailoverOrchestrator; }
1103
1035
  });
1104
1036
  Object.defineProperty(exports, "createLogSubscriber", {
1105
1037
  enumerable: true,
1106
- get: function () { return chunkVABBGKSR_cjs.createLogSubscriber; }
1038
+ get: function () { return chunkTJ7ZGZHD_cjs.createLogSubscriber; }
1039
+ });
1040
+ Object.defineProperty(exports, "createOperatorTools", {
1041
+ enumerable: true,
1042
+ get: function () { return chunkTJ7ZGZHD_cjs.createOperatorTools; }
1107
1043
  });
1108
1044
  Object.defineProperty(exports, "createProfileTools", {
1109
1045
  enumerable: true,
1110
- get: function () { return chunkVABBGKSR_cjs.createProfileTools; }
1046
+ get: function () { return chunkTJ7ZGZHD_cjs.createProfileTools; }
1111
1047
  });
1112
1048
  Object.defineProperty(exports, "createRegistry", {
1113
1049
  enumerable: true,
1114
- get: function () { return chunkVABBGKSR_cjs.createRegistry; }
1050
+ get: function () { return chunkTJ7ZGZHD_cjs.createRegistry; }
1115
1051
  });
1116
1052
  Object.defineProperty(exports, "createRequestLogger", {
1117
1053
  enumerable: true,
1118
- get: function () { return chunkVABBGKSR_cjs.createRequestLogger; }
1054
+ get: function () { return chunkTJ7ZGZHD_cjs.createRequestLogger; }
1119
1055
  });
1120
1056
  Object.defineProperty(exports, "createRequestTraceBuffer", {
1121
1057
  enumerable: true,
1122
- get: function () { return chunkVABBGKSR_cjs.createRequestTraceBuffer; }
1058
+ get: function () { return chunkTJ7ZGZHD_cjs.createRequestTraceBuffer; }
1123
1059
  });
1124
1060
  Object.defineProperty(exports, "createRetryPolicy", {
1125
1061
  enumerable: true,
1126
- get: function () { return chunkVABBGKSR_cjs.createRetryPolicy; }
1062
+ get: function () { return chunkTJ7ZGZHD_cjs.createRetryPolicy; }
1127
1063
  });
1128
1064
  Object.defineProperty(exports, "createRoutingEventBus", {
1129
1065
  enumerable: true,
1130
- get: function () { return chunkVABBGKSR_cjs.createRoutingEventBus; }
1066
+ get: function () { return chunkTJ7ZGZHD_cjs.createRoutingEventBus; }
1131
1067
  });
1132
1068
  Object.defineProperty(exports, "disableTarget", {
1133
1069
  enumerable: true,
1134
- get: function () { return chunkVABBGKSR_cjs.disableTarget; }
1070
+ get: function () { return chunkTJ7ZGZHD_cjs.disableTarget; }
1135
1071
  });
1136
1072
  Object.defineProperty(exports, "discoverTargets", {
1137
1073
  enumerable: true,
1138
- get: function () { return chunkVABBGKSR_cjs.discoverTargets; }
1074
+ get: function () { return chunkTJ7ZGZHD_cjs.discoverTargets; }
1139
1075
  });
1140
1076
  Object.defineProperty(exports, "discoverTargetsFromProfiles", {
1141
1077
  enumerable: true,
1142
- get: function () { return chunkVABBGKSR_cjs.discoverTargetsFromProfiles; }
1078
+ get: function () { return chunkTJ7ZGZHD_cjs.discoverTargetsFromProfiles; }
1143
1079
  });
1144
1080
  Object.defineProperty(exports, "drainTarget", {
1145
1081
  enumerable: true,
1146
- get: function () { return chunkVABBGKSR_cjs.drainTarget; }
1082
+ get: function () { return chunkTJ7ZGZHD_cjs.drainTarget; }
1147
1083
  });
1148
1084
  Object.defineProperty(exports, "generateCorrelationId", {
1149
1085
  enumerable: true,
1150
- get: function () { return chunkVABBGKSR_cjs.generateCorrelationId; }
1086
+ get: function () { return chunkTJ7ZGZHD_cjs.generateCorrelationId; }
1151
1087
  });
1152
1088
  Object.defineProperty(exports, "getExclusionReason", {
1153
1089
  enumerable: true,
1154
- get: function () { return chunkVABBGKSR_cjs.getExclusionReason; }
1090
+ get: function () { return chunkTJ7ZGZHD_cjs.getExclusionReason; }
1155
1091
  });
1156
1092
  Object.defineProperty(exports, "getTargetStateTransition", {
1157
1093
  enumerable: true,
1158
- get: function () { return chunkVABBGKSR_cjs.getTargetStateTransition; }
1094
+ get: function () { return chunkTJ7ZGZHD_cjs.getTargetStateTransition; }
1159
1095
  });
1160
1096
  Object.defineProperty(exports, "inspectRequest", {
1161
1097
  enumerable: true,
1162
- get: function () { return chunkVABBGKSR_cjs.inspectRequest; }
1098
+ get: function () { return chunkTJ7ZGZHD_cjs.inspectRequest; }
1163
1099
  });
1164
1100
  Object.defineProperty(exports, "isRetryable", {
1165
1101
  enumerable: true,
1166
- get: function () { return chunkVABBGKSR_cjs.isRetryable; }
1102
+ get: function () { return chunkTJ7ZGZHD_cjs.isRetryable; }
1167
1103
  });
1168
1104
  Object.defineProperty(exports, "listProfiles", {
1169
1105
  enumerable: true,
1170
- get: function () { return chunkVABBGKSR_cjs.listProfiles; }
1106
+ get: function () { return chunkTJ7ZGZHD_cjs.listProfiles; }
1171
1107
  });
1172
1108
  Object.defineProperty(exports, "listTargets", {
1173
1109
  enumerable: true,
1174
- get: function () { return chunkVABBGKSR_cjs.listTargets; }
1110
+ get: function () { return chunkTJ7ZGZHD_cjs.listTargets; }
1175
1111
  });
1176
1112
  Object.defineProperty(exports, "loadProfiles", {
1177
1113
  enumerable: true,
1178
- get: function () { return chunkVABBGKSR_cjs.loadProfiles; }
1114
+ get: function () { return chunkTJ7ZGZHD_cjs.loadProfiles; }
1179
1115
  });
1180
1116
  Object.defineProperty(exports, "nextProfileId", {
1181
1117
  enumerable: true,
1182
- get: function () { return chunkVABBGKSR_cjs.nextProfileId; }
1118
+ get: function () { return chunkTJ7ZGZHD_cjs.nextProfileId; }
1183
1119
  });
1184
1120
  Object.defineProperty(exports, "normalizeLatency", {
1185
1121
  enumerable: true,
1186
- get: function () { return chunkVABBGKSR_cjs.normalizeLatency; }
1122
+ get: function () { return chunkTJ7ZGZHD_cjs.normalizeLatency; }
1187
1123
  });
1188
1124
  Object.defineProperty(exports, "pauseTarget", {
1189
1125
  enumerable: true,
1190
- get: function () { return chunkVABBGKSR_cjs.pauseTarget; }
1126
+ get: function () { return chunkTJ7ZGZHD_cjs.pauseTarget; }
1191
1127
  });
1192
1128
  Object.defineProperty(exports, "reloadConfig", {
1193
1129
  enumerable: true,
1194
- get: function () { return chunkVABBGKSR_cjs.reloadConfig; }
1130
+ get: function () { return chunkTJ7ZGZHD_cjs.reloadConfig; }
1195
1131
  });
1196
1132
  Object.defineProperty(exports, "removeProfile", {
1197
1133
  enumerable: true,
1198
- get: function () { return chunkVABBGKSR_cjs.removeProfile; }
1134
+ get: function () { return chunkTJ7ZGZHD_cjs.removeProfile; }
1199
1135
  });
1200
1136
  Object.defineProperty(exports, "resumeTarget", {
1201
1137
  enumerable: true,
1202
- get: function () { return chunkVABBGKSR_cjs.resumeTarget; }
1138
+ get: function () { return chunkTJ7ZGZHD_cjs.resumeTarget; }
1203
1139
  });
1204
1140
  Object.defineProperty(exports, "saveProfiles", {
1205
1141
  enumerable: true,
1206
- get: function () { return chunkVABBGKSR_cjs.saveProfiles; }
1142
+ get: function () { return chunkTJ7ZGZHD_cjs.saveProfiles; }
1207
1143
  });
1208
1144
  Object.defineProperty(exports, "selectTarget", {
1209
1145
  enumerable: true,
1210
- get: function () { return chunkVABBGKSR_cjs.selectTarget; }
1146
+ get: function () { return chunkTJ7ZGZHD_cjs.selectTarget; }
1211
1147
  });
1212
1148
  Object.defineProperty(exports, "updateHealthScore", {
1213
1149
  enumerable: true,
1214
- get: function () { return chunkVABBGKSR_cjs.updateHealthScore; }
1150
+ get: function () { return chunkTJ7ZGZHD_cjs.updateHealthScore; }
1215
1151
  });
1216
1152
  Object.defineProperty(exports, "updateLatencyEma", {
1217
1153
  enumerable: true,
1218
- get: function () { return chunkVABBGKSR_cjs.updateLatencyEma; }
1154
+ get: function () { return chunkTJ7ZGZHD_cjs.updateLatencyEma; }
1219
1155
  });
1220
1156
  Object.defineProperty(exports, "validateConfig", {
1221
1157
  enumerable: true,
1222
- get: function () { return chunkVABBGKSR_cjs.validateConfig; }
1158
+ get: function () { return chunkTJ7ZGZHD_cjs.validateConfig; }
1223
1159
  });
1224
1160
  exports.HEURISTIC_PATTERNS = HEURISTIC_PATTERNS;
1225
1161
  exports.PROVIDER_PATTERNS = PROVIDER_PATTERNS;
@@ -1228,7 +1164,6 @@ exports.classify = classify;
1228
1164
  exports.createAuditCollector = createAuditCollector;
1229
1165
  exports.createExecutionOrchestrator = createExecutionOrchestrator;
1230
1166
  exports.createModeAdapter = createModeAdapter;
1231
- exports.createOperatorTools = createOperatorTools;
1232
1167
  exports.createStreamBuffer = createStreamBuffer;
1233
1168
  exports.createStreamStitcher = createStreamStitcher;
1234
1169
  exports.detectDeploymentMode = detectDeploymentMode;
package/dist/index.js CHANGED
@@ -1,7 +1,6 @@
1
- import { createRequestLogger, generateCorrelationId, reloadConfig, inspectRequest, disableTarget, drainTarget, resumeTarget, pauseTarget, listTargets } from './chunk-IKNWSNAS.js';
2
- 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, REDACT_PATHS, SwitcherConfigSchema, TARGET_STATES, TargetConfigSchema, TargetRegistry, addProfile, applyConfigDiff, checkHardRejects, computeBackoffMs, computeConfigDiff, computeCooldownMs, computeScore, createAdmissionController, createAuditLogger, createAuthWatcher, createCircuitBreaker, createConcurrencyTracker, createCooldownManager, createFailoverOrchestrator, createLogSubscriber, createProfileTools, createRegistry, createRequestLogger, createRequestTraceBuffer, createRetryPolicy, createRoutingEventBus, disableTarget, discoverTargets, discoverTargetsFromProfiles, drainTarget, generateCorrelationId, getExclusionReason, getTargetStateTransition, inspectRequest, isRetryable, listProfiles, listTargets, loadProfiles, nextProfileId, normalizeLatency, pauseTarget, reloadConfig, removeProfile, resumeTarget, saveProfiles, selectTarget, updateHealthScore, updateLatencyEma, validateConfig } from './chunk-IKNWSNAS.js';
1
+ import { createRequestLogger, generateCorrelationId } from './chunk-7ITX5623.js';
2
+ 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, REDACT_PATHS, SwitcherConfigSchema, TARGET_STATES, TargetConfigSchema, TargetRegistry, addProfile, applyConfigDiff, checkHardRejects, computeBackoffMs, computeConfigDiff, computeCooldownMs, computeScore, createAdmissionController, createAuditLogger, createAuthWatcher, createCircuitBreaker, createConcurrencyTracker, createCooldownManager, createFailoverOrchestrator, createLogSubscriber, createOperatorTools, createProfileTools, createRegistry, createRequestLogger, createRequestTraceBuffer, createRetryPolicy, createRoutingEventBus, disableTarget, discoverTargets, discoverTargetsFromProfiles, drainTarget, generateCorrelationId, getExclusionReason, getTargetStateTransition, inspectRequest, isRetryable, listProfiles, listTargets, loadProfiles, nextProfileId, normalizeLatency, pauseTarget, reloadConfig, removeProfile, resumeTarget, saveProfiles, selectTarget, updateHealthScore, updateLatencyEma, validateConfig } from './chunk-7ITX5623.js';
3
3
  import { timingSafeEqual } from 'crypto';
4
- import { tool } from '@opencode-ai/plugin/tool';
5
4
 
6
5
  // src/mode/detection.ts
7
6
  var detectDeploymentMode = (hint) => {
@@ -703,7 +702,12 @@ var createExecutionOrchestrator = (deps) => ({
703
702
  outcome = "success";
704
703
  finalTarget = failoverResult.target_id;
705
704
  const attemptValue = failoverResult.value;
706
- const continuationMode = stitcher.segmentCount() === 0 ? "same_target_resume" : "same_target_resume";
705
+ const continuationMode = stitcher.segmentCount() === 0 ? "same_target_resume" : determineContinuationMode(
706
+ stitcher.assemble().segments[stitcher.segmentCount() - 1].source_target_id,
707
+ failoverResult.target_id,
708
+ true
709
+ // same model assumption in plugin-only mode
710
+ );
707
711
  stitcher.addSegment(attemptValue.buffer, {
708
712
  request_id: requestId,
709
713
  segment_id: stitcher.segmentCount(),
@@ -883,77 +887,5 @@ var validateBearerToken = (authHeader, expectedToken) => {
883
887
  }
884
888
  return { authorized: true };
885
889
  };
886
- var { schema: z } = tool;
887
- var createOperatorTools = (deps) => ({
888
- listTargets: tool({
889
- description: "List all routing targets with health scores, states, and circuit breaker status.",
890
- args: {},
891
- async execute() {
892
- deps.logger.info({ op: "listTargets" }, "operator: listTargets");
893
- const result = listTargets(deps);
894
- return JSON.stringify(result, null, 2);
895
- }
896
- }),
897
- pauseTarget: tool({
898
- description: "Pause a target, preventing new requests from being routed to it.",
899
- args: { target_id: z.string().min(1) },
900
- async execute(args) {
901
- deps.logger.info({ op: "pauseTarget", target_id: args.target_id }, "operator: pauseTarget");
902
- const result = pauseTarget(deps, args.target_id);
903
- return JSON.stringify(result, null, 2);
904
- }
905
- }),
906
- resumeTarget: tool({
907
- description: "Resume a previously paused or disabled target, allowing new requests.",
908
- args: { target_id: z.string().min(1) },
909
- async execute(args) {
910
- deps.logger.info({ op: "resumeTarget", target_id: args.target_id }, "operator: resumeTarget");
911
- const result = resumeTarget(deps, args.target_id);
912
- return JSON.stringify(result, null, 2);
913
- }
914
- }),
915
- drainTarget: tool({
916
- description: "Drain a target, allowing in-flight requests to complete but preventing new ones.",
917
- args: { target_id: z.string().min(1) },
918
- async execute(args) {
919
- deps.logger.info({ op: "drainTarget", target_id: args.target_id }, "operator: drainTarget");
920
- const result = drainTarget(deps, args.target_id);
921
- return JSON.stringify(result, null, 2);
922
- }
923
- }),
924
- disableTarget: tool({
925
- description: "Disable a target entirely, removing it from routing.",
926
- args: { target_id: z.string().min(1) },
927
- async execute(args) {
928
- deps.logger.info(
929
- { op: "disableTarget", target_id: args.target_id },
930
- "operator: disableTarget"
931
- );
932
- const result = disableTarget(deps, args.target_id);
933
- return JSON.stringify(result, null, 2);
934
- }
935
- }),
936
- inspectRequest: tool({
937
- description: "Inspect a request trace by ID, showing attempts, segments, and outcome.",
938
- args: { request_id: z.string().min(1) },
939
- async execute(args) {
940
- deps.logger.info(
941
- { op: "inspectRequest", request_id: args.request_id },
942
- "operator: inspectRequest"
943
- );
944
- const result = inspectRequest(deps, args.request_id);
945
- return JSON.stringify(result, null, 2);
946
- }
947
- }),
948
- reloadConfig: tool({
949
- description: "Reload routing configuration with diff-apply. Validates new config before applying.",
950
- args: { config: z.record(z.string(), z.unknown()) },
951
- async execute(args) {
952
- deps.logger.info({ op: "reloadConfig" }, "operator: reloadConfig");
953
- const result = reloadConfig(deps, args.config);
954
- return JSON.stringify(result, null, 2);
955
- }
956
- })
957
- });
958
890
 
959
- export { HEURISTIC_PATTERNS, PROVIDER_PATTERNS, TEMPORAL_QUOTA_PATTERN, classify, createAuditCollector, createExecutionOrchestrator, createModeAdapter, createOperatorTools, createStreamBuffer, createStreamStitcher, detectDeploymentMode, determineContinuationMode, directSignalFromResponse, extractRetryAfterMs, getModeCapabilities, getSignalFidelity, heuristicSignalFromEvent, validateBearerToken };
891
+ export { HEURISTIC_PATTERNS, PROVIDER_PATTERNS, TEMPORAL_QUOTA_PATTERN, classify, createAuditCollector, createExecutionOrchestrator, createModeAdapter, createStreamBuffer, createStreamStitcher, detectDeploymentMode, determineContinuationMode, directSignalFromResponse, extractRetryAfterMs, getModeCapabilities, getSignalFidelity, heuristicSignalFromEvent, validateBearerToken };