aicodeswitch 6.0.0 → 6.0.2

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.
@@ -55,6 +55,10 @@ const isClaudePermissionDefaultMode = (value) => {
55
55
  const isValidAutocompactPct = (v) => {
56
56
  return typeof v === 'number' && Number.isInteger(v) && v >= 1 && v <= 100;
57
57
  };
58
+ // 最大重试次数校验:正整数(1-20),非法值返回 undefined(由 write 函数兜底默认 5)
59
+ const isValidMaxRetries = (v) => {
60
+ return typeof v === 'number' && Number.isInteger(v) && v >= 1 && v <= 20;
61
+ };
58
62
  const normalizeFailoverRecoverySeconds = (value) => {
59
63
  const parsed = typeof value === 'number' ? value : Number(value);
60
64
  if (!Number.isFinite(parsed) || parsed <= 0) {
@@ -190,6 +194,7 @@ class FileSystemDatabaseManager {
190
194
  value: {
191
195
  'claude-code': { tool: 'claude-code', routeId: null },
192
196
  'codex': { tool: 'codex', routeId: null },
197
+ 'opencode': { tool: 'opencode', routeId: null },
193
198
  }
194
199
  });
195
200
  // 持久化统计数据
@@ -552,6 +557,7 @@ class FileSystemDatabaseManager {
552
557
  this.toolBindings = {
553
558
  'claude-code': parsed['claude-code'] || { tool: 'claude-code', routeId: null },
554
559
  'codex': parsed['codex'] || { tool: 'codex', routeId: null },
560
+ 'opencode': parsed['opencode'] || { tool: 'opencode', routeId: null },
555
561
  };
556
562
  }
557
563
  catch (_a) {
@@ -559,6 +565,7 @@ class FileSystemDatabaseManager {
559
565
  this.toolBindings = {
560
566
  'claude-code': { tool: 'claude-code', routeId: null },
561
567
  'codex': { tool: 'codex', routeId: null },
568
+ 'opencode': { tool: 'opencode', routeId: null },
562
569
  };
563
570
  }
564
571
  });
@@ -833,6 +840,15 @@ class FileSystemDatabaseManager {
833
840
  if (typeof this.config.autocompactPctOverride !== 'undefined' && !isValidAutocompactPct(this.config.autocompactPctOverride)) {
834
841
  this.config.autocompactPctOverride = undefined;
835
842
  }
843
+ if (typeof this.config.claudeMaxRetries !== 'undefined' && !isValidMaxRetries(this.config.claudeMaxRetries)) {
844
+ this.config.claudeMaxRetries = undefined;
845
+ }
846
+ if (typeof this.config.codexMaxRetries !== 'undefined' && !isValidMaxRetries(this.config.codexMaxRetries)) {
847
+ this.config.codexMaxRetries = undefined;
848
+ }
849
+ if (typeof this.config.opencodeMaxRetries !== 'undefined' && !isValidMaxRetries(this.config.opencodeMaxRetries)) {
850
+ this.config.opencodeMaxRetries = undefined;
851
+ }
836
852
  this.config.failoverRecoverySeconds = normalizeFailoverRecoverySeconds(this.config.failoverRecoverySeconds);
837
853
  if (typeof this.config.ruleGlobalTimeout !== 'number' || this.config.ruleGlobalTimeout <= 0) {
838
854
  this.config.ruleGlobalTimeout = undefined;
@@ -908,7 +924,7 @@ class FileSystemDatabaseManager {
908
924
  // Only migrate routes that are explicitly active and have a targetType
909
925
  if (route.isActive === true && route.targetType) {
910
926
  const tool = route.targetType;
911
- if (tool === 'claude-code' || tool === 'codex') {
927
+ if (tool === 'claude-code' || tool === 'codex' || tool === 'opencode') {
912
928
  // Only write if tool-bindings doesn't already have a binding
913
929
  // (avoid overwriting user's newer tool-binding choices)
914
930
  if (!((_a = this.toolBindings[tool]) === null || _a === void 0 ? void 0 : _a.routeId)) {
@@ -1749,6 +1765,15 @@ class FileSystemDatabaseManager {
1749
1765
  if (typeof merged.autocompactPctOverride !== 'undefined' && !isValidAutocompactPct(merged.autocompactPctOverride)) {
1750
1766
  merged.autocompactPctOverride = undefined;
1751
1767
  }
1768
+ if (typeof merged.claudeMaxRetries !== 'undefined' && !isValidMaxRetries(merged.claudeMaxRetries)) {
1769
+ merged.claudeMaxRetries = undefined;
1770
+ }
1771
+ if (typeof merged.codexMaxRetries !== 'undefined' && !isValidMaxRetries(merged.codexMaxRetries)) {
1772
+ merged.codexMaxRetries = undefined;
1773
+ }
1774
+ if (typeof merged.opencodeMaxRetries !== 'undefined' && !isValidMaxRetries(merged.opencodeMaxRetries)) {
1775
+ merged.opencodeMaxRetries = undefined;
1776
+ }
1752
1777
  merged.failoverRecoverySeconds = normalizeFailoverRecoverySeconds(merged.failoverRecoverySeconds);
1753
1778
  if (typeof merged.ruleGlobalTimeout !== 'number' || merged.ruleGlobalTimeout <= 0) {
1754
1779
  merged.ruleGlobalTimeout = undefined;