@lightharu/krouter 1.8.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/LICENSE +679 -0
- package/README.md +238 -0
- package/dist-web/assets/index-CM4-0adf.css +1 -0
- package/dist-web/assets/index-DCslvfUR.js +139 -0
- package/dist-web/favicon.svg +9 -0
- package/dist-web/icon.svg +9 -0
- package/dist-web/index.html +19 -0
- package/out-server/main/kiroAuthSync.js +249 -0
- package/out-server/main/kproxy/certManager.js +262 -0
- package/out-server/main/kproxy/index.js +254 -0
- package/out-server/main/kproxy/mitmProxy.js +475 -0
- package/out-server/main/kproxy/types.js +23 -0
- package/out-server/main/proxy/accountPool.js +543 -0
- package/out-server/main/proxy/clientConfig.js +596 -0
- package/out-server/main/proxy/index.js +25 -0
- package/out-server/main/proxy/kiroApi.js +1996 -0
- package/out-server/main/proxy/logger.js +407 -0
- package/out-server/main/proxy/modelCatalog.js +75 -0
- package/out-server/main/proxy/promptCacheTracker.js +301 -0
- package/out-server/main/proxy/proxyServer.js +3543 -0
- package/out-server/main/proxy/selfSignedCert.js +179 -0
- package/out-server/main/proxy/systemProxy.js +250 -0
- package/out-server/main/proxy/tokenCounter.js +164 -0
- package/out-server/main/proxy/toolNameRegistry.js +57 -0
- package/out-server/main/proxy/translator.js +1084 -0
- package/out-server/main/proxy/types.js +3 -0
- package/out-server/main/registration/browser-identity.js +184 -0
- package/out-server/main/registration/chainProxy.js +349 -0
- package/out-server/main/registration/config.js +58 -0
- package/out-server/main/registration/email-service.js +801 -0
- package/out-server/main/registration/fingerprint.js +352 -0
- package/out-server/main/registration/http-utils.js +148 -0
- package/out-server/main/registration/jwe.js +74 -0
- package/out-server/main/registration/names.js +142 -0
- package/out-server/main/registration/proton-mail-window.js +339 -0
- package/out-server/main/registration/registrar.js +1715 -0
- package/out-server/main/registration/tlsClientPool.js +70 -0
- package/out-server/main/registration/xxtea.js +161 -0
- package/out-server/main/runtimePaths.js +19 -0
- package/out-server/main/utils/redact.js +95 -0
- package/out-server/server/index.js +1272 -0
- package/out-server/server/services/accountExtras.js +105 -0
- package/out-server/server/services/accountProfileHydration.js +95 -0
- package/out-server/server/services/authFlows.js +509 -0
- package/out-server/server/services/dashboardTunnel.js +315 -0
- package/out-server/server/services/diagnostics.js +326 -0
- package/out-server/server/services/kiroAccounts.js +431 -0
- package/out-server/server/services/kiroSettings.js +260 -0
- package/out-server/server/services/kproxyRuntime.js +264 -0
- package/out-server/server/services/localKiroCredentials.js +320 -0
- package/out-server/server/services/machineIdRuntime.js +327 -0
- package/out-server/server/services/protonBrowserRuntime.js +724 -0
- package/out-server/server/services/proxyRuntime.js +523 -0
- package/out-server/server/services/registrationRuntime.js +106 -0
- package/out-server/server/store.js +266 -0
- package/package.json +113 -0
- package/resources/tls-client-xgo-1.14.0-windows-amd64.dll +0 -0
- package/scripts/kiro-manager-cli.cjs +3 -0
- package/scripts/krouter-cli.cjs +509 -0
- package/src/renderer/src/assets/krouter-logo.svg +11 -0
- package/src/renderer/src/assets/krouter-mark.svg +9 -0
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.proxyLogger = exports.proxyLogStore = void 0;
|
|
37
|
+
exports.interceptConsole = interceptConsole;
|
|
38
|
+
// 代理服务器日志模块
|
|
39
|
+
const fs = __importStar(require("fs"));
|
|
40
|
+
const path = __importStar(require("path"));
|
|
41
|
+
const redact_1 = require("../utils/redact");
|
|
42
|
+
const runtimePaths_1 = require("../runtimePaths");
|
|
43
|
+
const DEFAULT_CONFIG = {
|
|
44
|
+
enabled: false,
|
|
45
|
+
maxFileSize: 10 * 1024 * 1024, // 10MB
|
|
46
|
+
maxFiles: 5,
|
|
47
|
+
logToConsole: true
|
|
48
|
+
};
|
|
49
|
+
class ProxyLogger {
|
|
50
|
+
config;
|
|
51
|
+
logStream = null;
|
|
52
|
+
currentLogFile = '';
|
|
53
|
+
currentFileSize = 0;
|
|
54
|
+
constructor() {
|
|
55
|
+
this.config = { ...DEFAULT_CONFIG };
|
|
56
|
+
}
|
|
57
|
+
configure(config) {
|
|
58
|
+
this.config = { ...this.config, ...config };
|
|
59
|
+
if (this.config.enabled && !this.config.logDir) {
|
|
60
|
+
// 默认日志目录
|
|
61
|
+
this.config.logDir = path.join((0, runtimePaths_1.getRuntimeUserDataPath)(), 'logs', 'proxy');
|
|
62
|
+
}
|
|
63
|
+
if (this.config.enabled) {
|
|
64
|
+
this.initLogFile();
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
this.close();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
initLogFile() {
|
|
71
|
+
if (!this.config.logDir)
|
|
72
|
+
return;
|
|
73
|
+
try {
|
|
74
|
+
// 确保目录存在
|
|
75
|
+
fs.mkdirSync(this.config.logDir, { recursive: true });
|
|
76
|
+
// 创建新的日志文件
|
|
77
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
78
|
+
this.currentLogFile = path.join(this.config.logDir, `proxy-${timestamp}.log`);
|
|
79
|
+
this.logStream = fs.createWriteStream(this.currentLogFile, { flags: 'a' });
|
|
80
|
+
this.currentFileSize = 0;
|
|
81
|
+
this.info('Logger', 'Log file initialized', { file: this.currentLogFile });
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
console.error('[ProxyLogger] Failed to init log file:', error);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
rotateIfNeeded() {
|
|
88
|
+
if (!this.config.maxFileSize || this.currentFileSize < this.config.maxFileSize) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
this.close();
|
|
92
|
+
this.cleanOldLogs();
|
|
93
|
+
this.initLogFile();
|
|
94
|
+
}
|
|
95
|
+
cleanOldLogs() {
|
|
96
|
+
if (!this.config.logDir || !this.config.maxFiles)
|
|
97
|
+
return;
|
|
98
|
+
try {
|
|
99
|
+
const files = fs.readdirSync(this.config.logDir)
|
|
100
|
+
.filter(f => f.startsWith('proxy-') && f.endsWith('.log'))
|
|
101
|
+
.map(f => ({
|
|
102
|
+
name: f,
|
|
103
|
+
path: path.join(this.config.logDir, f),
|
|
104
|
+
time: fs.statSync(path.join(this.config.logDir, f)).mtime.getTime()
|
|
105
|
+
}))
|
|
106
|
+
.sort((a, b) => b.time - a.time);
|
|
107
|
+
// 删除超出数量限制的旧文件
|
|
108
|
+
while (files.length >= this.config.maxFiles) {
|
|
109
|
+
const oldest = files.pop();
|
|
110
|
+
if (oldest) {
|
|
111
|
+
fs.unlinkSync(oldest.path);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
console.error('[ProxyLogger] Failed to clean old logs:', error);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
isWriting = false;
|
|
120
|
+
write(rawEntry) {
|
|
121
|
+
// 统一脱敏:message + data 里的代理账密 / token / password 等,避免明文落盘或上屏
|
|
122
|
+
const entry = {
|
|
123
|
+
...rawEntry,
|
|
124
|
+
message: (0, redact_1.redactString)(rawEntry.message),
|
|
125
|
+
data: rawEntry.data === undefined ? undefined : (0, redact_1.redactValue)(rawEntry.data)
|
|
126
|
+
};
|
|
127
|
+
const line = JSON.stringify(entry) + '\n';
|
|
128
|
+
if (this.config.logToConsole) {
|
|
129
|
+
const prefix = `[${entry.level}][${entry.category}]`;
|
|
130
|
+
// 设置 flag 防止 console 拦截器重复写入 proxyLogStore
|
|
131
|
+
this.isWriting = true;
|
|
132
|
+
if (entry.level === 'ERROR') {
|
|
133
|
+
console.error(prefix, entry.message, entry.data || '');
|
|
134
|
+
}
|
|
135
|
+
else if (entry.level === 'WARN') {
|
|
136
|
+
console.warn(prefix, entry.message, entry.data || '');
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
console.log(prefix, entry.message, entry.data || '');
|
|
140
|
+
}
|
|
141
|
+
this.isWriting = false;
|
|
142
|
+
}
|
|
143
|
+
if (this.config.enabled && this.logStream) {
|
|
144
|
+
this.logStream.write(line);
|
|
145
|
+
this.currentFileSize += Buffer.byteLength(line);
|
|
146
|
+
this.rotateIfNeeded();
|
|
147
|
+
}
|
|
148
|
+
// 同时添加到内存存储(用于 UI 显示)
|
|
149
|
+
exports.proxyLogStore.add(entry);
|
|
150
|
+
}
|
|
151
|
+
get _isWriting() { return this.isWriting; }
|
|
152
|
+
debug(category, message, data) {
|
|
153
|
+
this.write({
|
|
154
|
+
timestamp: new Date().toISOString(),
|
|
155
|
+
level: 'DEBUG',
|
|
156
|
+
category,
|
|
157
|
+
message,
|
|
158
|
+
data
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
info(category, message, data) {
|
|
162
|
+
this.write({
|
|
163
|
+
timestamp: new Date().toISOString(),
|
|
164
|
+
level: 'INFO',
|
|
165
|
+
category,
|
|
166
|
+
message,
|
|
167
|
+
data
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
warn(category, message, data) {
|
|
171
|
+
this.write({
|
|
172
|
+
timestamp: new Date().toISOString(),
|
|
173
|
+
level: 'WARN',
|
|
174
|
+
category,
|
|
175
|
+
message,
|
|
176
|
+
data
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
error(category, message, data) {
|
|
180
|
+
this.write({
|
|
181
|
+
timestamp: new Date().toISOString(),
|
|
182
|
+
level: 'ERROR',
|
|
183
|
+
category,
|
|
184
|
+
message,
|
|
185
|
+
data
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
// 记录请求
|
|
189
|
+
request(info) {
|
|
190
|
+
this.info('Request', `${info.method} ${info.path}`, info);
|
|
191
|
+
}
|
|
192
|
+
// 记录响应
|
|
193
|
+
response(info) {
|
|
194
|
+
if (info.error) {
|
|
195
|
+
this.error('Response', `${info.path} -> ${info.status}`, info);
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
this.info('Response', `${info.path} -> ${info.status}`, info);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
// 记录 Token 刷新
|
|
202
|
+
tokenRefresh(accountId, success, error) {
|
|
203
|
+
if (success) {
|
|
204
|
+
this.info('TokenRefresh', `Account ${accountId} refreshed successfully`);
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
this.error('TokenRefresh', `Account ${accountId} refresh failed`, { error });
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
close() {
|
|
211
|
+
if (this.logStream) {
|
|
212
|
+
this.logStream.end();
|
|
213
|
+
this.logStream = null;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
getLogDir() {
|
|
217
|
+
return this.config.logDir;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
// 内存日志存储(用于 UI 显示)
|
|
221
|
+
//
|
|
222
|
+
// 性能修复要点:
|
|
223
|
+
// 1. maxLogs 从 100万 降至 5万 — 避免序列化数百 MB 大对象阻塞主进程
|
|
224
|
+
// 2. save() 改为异步 fs.promises.writeFile — 不再 freeze 主进程事件循环
|
|
225
|
+
// 3. 单次写盘原子化(in-flight guard)防止并发 writeFile 导致竞态
|
|
226
|
+
// 4. 写盘节流间隔从 5s 提至 30s — 大幅降低高频日志场景下的 IO 频率
|
|
227
|
+
// 5. 应用退出时通过 flushSaveNow() 强制写盘,防止数据丢失
|
|
228
|
+
class ProxyLogStore {
|
|
229
|
+
logs = [];
|
|
230
|
+
// 5 万条 × 平均 200 字节 ≈ 10 MB;既能覆盖常规调试需求,又把单次写盘成本控制在可接受范围内
|
|
231
|
+
maxLogs = 50000;
|
|
232
|
+
listeners = [];
|
|
233
|
+
storePath = '';
|
|
234
|
+
initialized = false;
|
|
235
|
+
initialize(userDataPath) {
|
|
236
|
+
if (this.initialized)
|
|
237
|
+
return;
|
|
238
|
+
this.initialized = true;
|
|
239
|
+
this.storePath = path.join(userDataPath, 'proxy-logs.json');
|
|
240
|
+
this.load();
|
|
241
|
+
}
|
|
242
|
+
load() {
|
|
243
|
+
try {
|
|
244
|
+
if (fs.existsSync(this.storePath)) {
|
|
245
|
+
const data = fs.readFileSync(this.storePath, 'utf-8');
|
|
246
|
+
const parsed = JSON.parse(data);
|
|
247
|
+
// 验证并过滤有效的日志条目
|
|
248
|
+
const filtered = Array.isArray(parsed) ? parsed.filter((log) => {
|
|
249
|
+
if (!log.timestamp || isNaN(new Date(log.timestamp).getTime()))
|
|
250
|
+
return false;
|
|
251
|
+
if (!log.level || !log.category)
|
|
252
|
+
return false;
|
|
253
|
+
return true;
|
|
254
|
+
}) : [];
|
|
255
|
+
// 加载时也施加上限,避免旧版本遗留的超大日志文件导致首次启动卡顿
|
|
256
|
+
this.logs = filtered.length > this.maxLogs ? filtered.slice(-this.maxLogs) : filtered;
|
|
257
|
+
console.log(`[ProxyLogStore] Loaded ${this.logs.length} valid logs`);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
catch (error) {
|
|
261
|
+
console.error('[ProxyLogStore] Failed to load logs:', error);
|
|
262
|
+
this.logs = [];
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
/** 异步保存日志(不阻塞主进程事件循环)。并发调用通过 in-flight 标志合并。 */
|
|
266
|
+
writeInFlight = false;
|
|
267
|
+
writePending = false;
|
|
268
|
+
async save() {
|
|
269
|
+
if (this.writeInFlight) {
|
|
270
|
+
// 已有写盘进行中:标记 pending,让其完成后立即重写最新数据
|
|
271
|
+
this.writePending = true;
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
this.writeInFlight = true;
|
|
275
|
+
try {
|
|
276
|
+
// 拷贝引用快照(不复制数组)以保证 JSON.stringify 期间数据稳定
|
|
277
|
+
const snapshot = this.logs;
|
|
278
|
+
await fs.promises.writeFile(this.storePath, JSON.stringify(snapshot), 'utf-8');
|
|
279
|
+
}
|
|
280
|
+
catch (error) {
|
|
281
|
+
console.error('[ProxyLogStore] Failed to save logs:', error);
|
|
282
|
+
}
|
|
283
|
+
finally {
|
|
284
|
+
this.writeInFlight = false;
|
|
285
|
+
if (this.writePending) {
|
|
286
|
+
this.writePending = false;
|
|
287
|
+
// 用 microtask 而不是立即递归,避免栈深问题
|
|
288
|
+
queueMicrotask(() => { void this.save(); });
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
saveTimer = null;
|
|
293
|
+
add(entry) {
|
|
294
|
+
this.logs.push(entry);
|
|
295
|
+
// 超过最大数量时删除最旧的
|
|
296
|
+
if (this.logs.length > this.maxLogs) {
|
|
297
|
+
this.logs = this.logs.slice(-this.maxLogs);
|
|
298
|
+
}
|
|
299
|
+
// 通知监听器(异常隔离)
|
|
300
|
+
for (const listener of this.listeners) {
|
|
301
|
+
try {
|
|
302
|
+
listener(entry);
|
|
303
|
+
}
|
|
304
|
+
catch { /* ignore */ }
|
|
305
|
+
}
|
|
306
|
+
// 节流调度异步保存
|
|
307
|
+
this.scheduleSave();
|
|
308
|
+
}
|
|
309
|
+
scheduleSave() {
|
|
310
|
+
if (this.saveTimer)
|
|
311
|
+
return; // 已调度,等待 flush
|
|
312
|
+
this.saveTimer = setTimeout(() => {
|
|
313
|
+
this.saveTimer = null;
|
|
314
|
+
void this.save();
|
|
315
|
+
}, 30_000); // 30 秒批量写盘一次(异步、不阻塞)
|
|
316
|
+
}
|
|
317
|
+
/** 强制立即写盘(用于退出场景),保证最新数据落盘 */
|
|
318
|
+
async flushSaveNow() {
|
|
319
|
+
if (this.saveTimer) {
|
|
320
|
+
clearTimeout(this.saveTimer);
|
|
321
|
+
this.saveTimer = null;
|
|
322
|
+
}
|
|
323
|
+
await this.save();
|
|
324
|
+
}
|
|
325
|
+
getAll() {
|
|
326
|
+
return [...this.logs];
|
|
327
|
+
}
|
|
328
|
+
getLast(count) {
|
|
329
|
+
return this.logs.slice(-count);
|
|
330
|
+
}
|
|
331
|
+
clear() {
|
|
332
|
+
this.logs = [];
|
|
333
|
+
void this.save();
|
|
334
|
+
}
|
|
335
|
+
count() {
|
|
336
|
+
return this.logs.length;
|
|
337
|
+
}
|
|
338
|
+
onLog(listener) {
|
|
339
|
+
this.listeners.push(listener);
|
|
340
|
+
return () => {
|
|
341
|
+
const index = this.listeners.indexOf(listener);
|
|
342
|
+
if (index >= 0) {
|
|
343
|
+
this.listeners.splice(index, 1);
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
exports.proxyLogStore = new ProxyLogStore();
|
|
349
|
+
// 单例导出
|
|
350
|
+
exports.proxyLogger = new ProxyLogger();
|
|
351
|
+
// 拦截主进程 console 输出,自动转发到 proxyLogStore
|
|
352
|
+
// 这样所有 console.log/warn/error 都能在日志页面显示
|
|
353
|
+
let consoleIntercepted = false;
|
|
354
|
+
function interceptConsole() {
|
|
355
|
+
if (consoleIntercepted)
|
|
356
|
+
return;
|
|
357
|
+
consoleIntercepted = true;
|
|
358
|
+
const originalLog = console.log;
|
|
359
|
+
const originalWarn = console.warn;
|
|
360
|
+
const originalError = console.error;
|
|
361
|
+
const parseConsoleCategory = (args) => {
|
|
362
|
+
const first = String(args[0] || '');
|
|
363
|
+
// 匹配 [Category] 或 [INFO][Category] 格式
|
|
364
|
+
const bracketMatch = first.match(/^\[(?:DEBUG|INFO|WARN|ERROR)\]?\[?([^\]]*)\]?\s*(.*)/);
|
|
365
|
+
if (bracketMatch) {
|
|
366
|
+
return { category: bracketMatch[1] || 'App', message: bracketMatch[2] || '' };
|
|
367
|
+
}
|
|
368
|
+
const simpleMatch = first.match(/^\[([^\]]+)\]\s*(.*)/);
|
|
369
|
+
if (simpleMatch) {
|
|
370
|
+
return { category: simpleMatch[1], message: simpleMatch[2] || '' };
|
|
371
|
+
}
|
|
372
|
+
return { category: 'App', message: first };
|
|
373
|
+
};
|
|
374
|
+
const buildEntry = (args, level) => {
|
|
375
|
+
const { category, message } = parseConsoleCategory(args);
|
|
376
|
+
const rest = args.slice(1);
|
|
377
|
+
// data: 后续参数(对象/数组保留结构,字符串拼接)
|
|
378
|
+
let data = undefined;
|
|
379
|
+
if (rest.length === 1) {
|
|
380
|
+
data = rest[0];
|
|
381
|
+
}
|
|
382
|
+
else if (rest.length > 1) {
|
|
383
|
+
// 如果全是字符串,拼成一个;否则保持数组
|
|
384
|
+
const allStrings = rest.every(r => typeof r === 'string');
|
|
385
|
+
data = allStrings ? rest.join(' ') : rest;
|
|
386
|
+
}
|
|
387
|
+
return { timestamp: new Date().toISOString(), level, category, message, data };
|
|
388
|
+
};
|
|
389
|
+
console.log = (...args) => {
|
|
390
|
+
originalLog.apply(console, args);
|
|
391
|
+
if (exports.proxyLogger._isWriting)
|
|
392
|
+
return;
|
|
393
|
+
exports.proxyLogStore.add(buildEntry(args, 'INFO'));
|
|
394
|
+
};
|
|
395
|
+
console.warn = (...args) => {
|
|
396
|
+
originalWarn.apply(console, args);
|
|
397
|
+
if (exports.proxyLogger._isWriting)
|
|
398
|
+
return;
|
|
399
|
+
exports.proxyLogStore.add(buildEntry(args, 'WARN'));
|
|
400
|
+
};
|
|
401
|
+
console.error = (...args) => {
|
|
402
|
+
originalError.apply(console, args);
|
|
403
|
+
if (exports.proxyLogger._isWriting)
|
|
404
|
+
return;
|
|
405
|
+
exports.proxyLogStore.add(buildEntry(args, 'ERROR'));
|
|
406
|
+
};
|
|
407
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.KIRO_PROXY_MODEL_PRESETS = exports.KIRO_PROXY_PREFERRED_MODEL_IDS = void 0;
|
|
4
|
+
exports.normalizeKiroModelIdForCompare = normalizeKiroModelIdForCompare;
|
|
5
|
+
exports.isAutoKiroModelId = isAutoKiroModelId;
|
|
6
|
+
exports.KIRO_PROXY_PREFERRED_MODEL_IDS = [
|
|
7
|
+
'claude-sonnet-4.5',
|
|
8
|
+
'claude-sonnet-4',
|
|
9
|
+
'claude-opus-4.8',
|
|
10
|
+
'claude-opus-4.7',
|
|
11
|
+
'claude-opus-4.5',
|
|
12
|
+
'claude-haiku-4.5'
|
|
13
|
+
];
|
|
14
|
+
exports.KIRO_PROXY_MODEL_PRESETS = [
|
|
15
|
+
{
|
|
16
|
+
id: 'claude-sonnet-4.5',
|
|
17
|
+
name: 'Claude Sonnet 4.5',
|
|
18
|
+
description: 'Claude Sonnet 4.5 for Kiro coding and agent tasks',
|
|
19
|
+
inputTypes: ['TEXT', 'IMAGE'],
|
|
20
|
+
maxInputTokens: 200000,
|
|
21
|
+
maxOutputTokens: 64000,
|
|
22
|
+
modelProvider: 'anthropic'
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
id: 'claude-sonnet-4',
|
|
26
|
+
name: 'Claude Sonnet 4',
|
|
27
|
+
description: 'Claude Sonnet 4 for Kiro coding and reasoning',
|
|
28
|
+
inputTypes: ['TEXT', 'IMAGE'],
|
|
29
|
+
maxInputTokens: 200000,
|
|
30
|
+
maxOutputTokens: 64000,
|
|
31
|
+
modelProvider: 'anthropic'
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
id: 'claude-opus-4.8',
|
|
35
|
+
name: 'Claude Opus 4.8',
|
|
36
|
+
description: 'Claude Opus 4.8 for Kiro Power accounts',
|
|
37
|
+
inputTypes: ['TEXT', 'IMAGE'],
|
|
38
|
+
maxInputTokens: 200000,
|
|
39
|
+
maxOutputTokens: 64000,
|
|
40
|
+
modelProvider: 'anthropic'
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
id: 'claude-opus-4.7',
|
|
44
|
+
name: 'Claude Opus 4.7',
|
|
45
|
+
description: 'Claude Opus 4.7 for Kiro Power accounts',
|
|
46
|
+
inputTypes: ['TEXT', 'IMAGE'],
|
|
47
|
+
maxInputTokens: 200000,
|
|
48
|
+
maxOutputTokens: 64000,
|
|
49
|
+
modelProvider: 'anthropic'
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
id: 'claude-opus-4.5',
|
|
53
|
+
name: 'Claude Opus 4.5',
|
|
54
|
+
description: 'Claude Opus 4.5 for Kiro Power accounts',
|
|
55
|
+
inputTypes: ['TEXT', 'IMAGE'],
|
|
56
|
+
maxInputTokens: 200000,
|
|
57
|
+
maxOutputTokens: 64000,
|
|
58
|
+
modelProvider: 'anthropic'
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
id: 'claude-haiku-4.5',
|
|
62
|
+
name: 'Claude Haiku 4.5',
|
|
63
|
+
description: 'Claude Haiku 4.5 for fast Kiro tasks',
|
|
64
|
+
inputTypes: ['TEXT', 'IMAGE'],
|
|
65
|
+
maxInputTokens: 200000,
|
|
66
|
+
maxOutputTokens: 64000,
|
|
67
|
+
modelProvider: 'anthropic'
|
|
68
|
+
}
|
|
69
|
+
];
|
|
70
|
+
function normalizeKiroModelIdForCompare(id) {
|
|
71
|
+
return id.trim().toLowerCase().replace(/^(claude-(?:sonnet|haiku|opus)-\d+)-(\d+)(.*)$/u, '$1.$2$3');
|
|
72
|
+
}
|
|
73
|
+
function isAutoKiroModelId(id) {
|
|
74
|
+
return normalizeKiroModelIdForCompare(id) === 'auto';
|
|
75
|
+
}
|