aicodeswitch 4.0.2 → 4.0.4
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/README.md +1 -1
- package/dist/server/fs-database.js +30 -2
- package/dist/server/proxy-server.js +318 -108
- package/dist/ui/assets/index-Dl-B9pXM.js +514 -0
- package/dist/ui/index.html +1 -1
- package/package.json +1 -1
- package/dist/ui/assets/index-BRHavnvn.js +0 -514
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ AI Code Switch 是帮助你在本地管理 AI 编程工具接入大模型的工
|
|
|
29
29
|
* 导入和导出:一键备份数据,在多太电脑间共享aicodeswitch配置
|
|
30
30
|
* 自定义API Key,支持B/S架构,让aicodeswitch成为在线服务,提供给团队使用
|
|
31
31
|
* 数据完全本地,自主可控
|
|
32
|
-
* 特殊语法:在发送的提示词最前面添加`[!]
|
|
32
|
+
* 特殊语法:在发送的提示词最前面添加`[!]`来直接切换为高智商模型服务(`[x]`关闭),简单快捷
|
|
33
33
|
* 服务端部署,可随时随地使用
|
|
34
34
|
|
|
35
35
|
## 桌面客户端
|
|
@@ -233,6 +233,12 @@ class FileSystemDatabaseManager {
|
|
|
233
233
|
writable: true,
|
|
234
234
|
value: 10 * 1024 * 1024
|
|
235
235
|
}); // 10MB
|
|
236
|
+
Object.defineProperty(this, "MAX_ERROR_LOG_FIELD_SIZE", {
|
|
237
|
+
enumerable: true,
|
|
238
|
+
configurable: true,
|
|
239
|
+
writable: true,
|
|
240
|
+
value: 256 * 1024
|
|
241
|
+
}); // 256KB 单个字段最大长度
|
|
236
242
|
Object.defineProperty(this, "LOG_RETENTION_DAYS", {
|
|
237
243
|
enumerable: true,
|
|
238
244
|
configurable: true,
|
|
@@ -899,7 +905,14 @@ class FileSystemDatabaseManager {
|
|
|
899
905
|
}
|
|
900
906
|
saveErrorLogs() {
|
|
901
907
|
return __awaiter(this, void 0, void 0, function* () {
|
|
902
|
-
|
|
908
|
+
try {
|
|
909
|
+
yield promises_1.default.writeFile(this.errorLogsFile, JSON.stringify(this.errorLogs, null, 2));
|
|
910
|
+
}
|
|
911
|
+
catch (e) {
|
|
912
|
+
console.error('[DB] Failed to save error logs, clearing to prevent crash:', e);
|
|
913
|
+
this.errorLogs = [];
|
|
914
|
+
yield promises_1.default.writeFile(this.errorLogsFile, '[]');
|
|
915
|
+
}
|
|
903
916
|
this.errorLogsCountCache = null;
|
|
904
917
|
});
|
|
905
918
|
}
|
|
@@ -973,6 +986,9 @@ class FileSystemDatabaseManager {
|
|
|
973
986
|
apiKey: (_d = current === null || current === void 0 ? void 0 : current.apiKey) !== null && _d !== void 0 ? _d : '',
|
|
974
987
|
enableFailover: (_e = current === null || current === void 0 ? void 0 : current.enableFailover) !== null && _e !== void 0 ? _e : true,
|
|
975
988
|
failoverRecoverySeconds: normalizeFailoverRecoverySeconds(current === null || current === void 0 ? void 0 : current.failoverRecoverySeconds),
|
|
989
|
+
ruleGlobalTimeout: typeof (current === null || current === void 0 ? void 0 : current.ruleGlobalTimeout) === 'number' && current.ruleGlobalTimeout > 0
|
|
990
|
+
? current.ruleGlobalTimeout
|
|
991
|
+
: undefined,
|
|
976
992
|
enableAgentTeams: (_f = current === null || current === void 0 ? void 0 : current.enableAgentTeams) !== null && _f !== void 0 ? _f : false,
|
|
977
993
|
enableBypassPermissionsSupport: (_g = current === null || current === void 0 ? void 0 : current.enableBypassPermissionsSupport) !== null && _g !== void 0 ? _g : false,
|
|
978
994
|
codexModelReasoningEffort: isCodexReasoningEffort(current === null || current === void 0 ? void 0 : current.codexModelReasoningEffort)
|
|
@@ -1724,11 +1740,20 @@ class FileSystemDatabaseManager {
|
|
|
1724
1740
|
}
|
|
1725
1741
|
return false;
|
|
1726
1742
|
}
|
|
1743
|
+
truncateForErrorLog(value) {
|
|
1744
|
+
if (value === undefined || value === null)
|
|
1745
|
+
return undefined;
|
|
1746
|
+
const str = typeof value === 'string' ? value : JSON.stringify(value);
|
|
1747
|
+
if (!str || str.length <= this.MAX_ERROR_LOG_FIELD_SIZE)
|
|
1748
|
+
return str || undefined;
|
|
1749
|
+
return str.substring(0, this.MAX_ERROR_LOG_FIELD_SIZE) + `\n...[truncated, original size: ${str.length} chars]`;
|
|
1750
|
+
}
|
|
1727
1751
|
// Error log operations
|
|
1728
1752
|
addErrorLog(log) {
|
|
1729
1753
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1730
1754
|
const id = crypto_1.default.randomUUID();
|
|
1731
|
-
this.
|
|
1755
|
+
const truncatedLog = Object.assign(Object.assign({}, log), { requestBody: this.truncateForErrorLog(log.requestBody), responseBody: this.truncateForErrorLog(log.responseBody), errorStack: this.truncateForErrorLog(log.errorStack), upstreamRequest: log.upstreamRequest ? Object.assign(Object.assign({}, log.upstreamRequest), { body: this.truncateForErrorLog(log.upstreamRequest.body) }) : undefined });
|
|
1756
|
+
this.errorLogs.push(Object.assign(Object.assign({}, truncatedLog), { id }));
|
|
1732
1757
|
yield this.saveErrorLogs();
|
|
1733
1758
|
});
|
|
1734
1759
|
}
|
|
@@ -1955,6 +1980,9 @@ class FileSystemDatabaseManager {
|
|
|
1955
1980
|
merged.codexModelReasoningEffort = DEFAULT_CODEX_REASONING_EFFORT;
|
|
1956
1981
|
}
|
|
1957
1982
|
merged.failoverRecoverySeconds = normalizeFailoverRecoverySeconds(merged.failoverRecoverySeconds);
|
|
1983
|
+
if (typeof merged.ruleGlobalTimeout !== 'number' || merged.ruleGlobalTimeout <= 0) {
|
|
1984
|
+
merged.ruleGlobalTimeout = undefined;
|
|
1985
|
+
}
|
|
1958
1986
|
this.config = merged;
|
|
1959
1987
|
yield this.saveConfig();
|
|
1960
1988
|
return true;
|