@jeffreycao/copilot-api 1.15.0 → 1.16.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/README.md +95 -71
- package/README.zh-CN.md +157 -91
- package/dist/auth-CRonPTZQ.js +2 -0
- package/dist/{auth-DqCboaUp.js → auth-CskgMMwz.js} +9 -2
- package/dist/auth-CskgMMwz.js.map +1 -0
- package/dist/main.js +2 -2
- package/dist/{server-DZtBoW6V.js → server-DWY7PmxG.js} +40 -14
- package/dist/server-DWY7PmxG.js.map +1 -0
- package/dist/{start-i6nxPCwq.js → start-YxEMb8V2.js} +3 -3
- package/dist/{start-i6nxPCwq.js.map → start-YxEMb8V2.js.map} +1 -1
- package/dist/token-DArgO8vi.js.map +1 -1
- package/package.json +1 -1
- package/dist/auth-BuVLgbbO.js +0 -2
- package/dist/auth-DqCboaUp.js.map +0 -1
- package/dist/server-DZtBoW6V.js.map +0 -1
|
@@ -193,22 +193,26 @@ function registerProcessCleanup(handler) {
|
|
|
193
193
|
//#region src/lib/logger.ts
|
|
194
194
|
const LOG_RETENTION_MS = 10080 * 60 * 1e3;
|
|
195
195
|
const CLEANUP_INTERVAL_MS = 1440 * 60 * 1e3;
|
|
196
|
-
const
|
|
196
|
+
const LOG_DIR_ENV = "COPILOT_API_LOG_DIR";
|
|
197
|
+
const DEFAULT_LOG_DIR = path.join(PATHS.APP_DIR, "logs");
|
|
197
198
|
const FLUSH_INTERVAL_MS = 1e3;
|
|
198
199
|
const MAX_BUFFER_SIZE = 100;
|
|
200
|
+
const getLogDir = () => process.env[LOG_DIR_ENV]?.trim() || DEFAULT_LOG_DIR;
|
|
199
201
|
const logStreams = /* @__PURE__ */ new Map();
|
|
200
202
|
const logBuffers = /* @__PURE__ */ new Map();
|
|
201
203
|
let runtimeInitialized = false;
|
|
202
204
|
let flushInterval;
|
|
203
205
|
let cleanupInterval;
|
|
204
206
|
const ensureLogDirectory = () => {
|
|
205
|
-
|
|
207
|
+
const logDir = getLogDir();
|
|
208
|
+
if (!fs.existsSync(logDir)) fs.mkdirSync(logDir, { recursive: true });
|
|
206
209
|
};
|
|
207
210
|
const cleanupOldLogs = () => {
|
|
208
|
-
|
|
211
|
+
const logDir = getLogDir();
|
|
212
|
+
if (!fs.existsSync(logDir)) return;
|
|
209
213
|
const now = Date.now();
|
|
210
|
-
for (const entry of fs.readdirSync(
|
|
211
|
-
const filePath = path.join(
|
|
214
|
+
for (const entry of fs.readdirSync(logDir)) {
|
|
215
|
+
const filePath = path.join(logDir, entry);
|
|
212
216
|
let stats;
|
|
213
217
|
try {
|
|
214
218
|
stats = fs.statSync(filePath);
|
|
@@ -247,7 +251,13 @@ const flushBuffer = (filePath) => {
|
|
|
247
251
|
const flushAllBuffers = () => {
|
|
248
252
|
for (const filePath of logBuffers.keys()) flushBuffer(filePath);
|
|
249
253
|
};
|
|
250
|
-
const
|
|
254
|
+
const flushAndCloseLogStreams = () => {
|
|
255
|
+
flushAllBuffers();
|
|
256
|
+
for (const stream of logStreams.values()) stream.end();
|
|
257
|
+
logStreams.clear();
|
|
258
|
+
logBuffers.clear();
|
|
259
|
+
};
|
|
260
|
+
const shutdownLoggerRuntime = () => {
|
|
251
261
|
if (flushInterval) {
|
|
252
262
|
clearInterval(flushInterval);
|
|
253
263
|
flushInterval = void 0;
|
|
@@ -256,10 +266,8 @@ const cleanup = () => {
|
|
|
256
266
|
clearInterval(cleanupInterval);
|
|
257
267
|
cleanupInterval = void 0;
|
|
258
268
|
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
logStreams.clear();
|
|
262
|
-
logBuffers.clear();
|
|
269
|
+
flushAndCloseLogStreams();
|
|
270
|
+
runtimeInitialized = false;
|
|
263
271
|
};
|
|
264
272
|
const initializeLoggerRuntime = () => {
|
|
265
273
|
if (runtimeInitialized) return;
|
|
@@ -270,7 +278,7 @@ const initializeLoggerRuntime = () => {
|
|
|
270
278
|
maybeUnref(flushInterval);
|
|
271
279
|
cleanupInterval = setInterval(cleanupOldLogs, CLEANUP_INTERVAL_MS);
|
|
272
280
|
maybeUnref(cleanupInterval);
|
|
273
|
-
registerProcessCleanup(
|
|
281
|
+
registerProcessCleanup(shutdownLoggerRuntime);
|
|
274
282
|
};
|
|
275
283
|
const getLogStream = (filePath) => {
|
|
276
284
|
initializeLoggerRuntime();
|
|
@@ -319,7 +327,7 @@ const createHandlerLogger = (name) => {
|
|
|
319
327
|
const date = logObj.date;
|
|
320
328
|
const dateKey = date.toLocaleDateString("sv-SE");
|
|
321
329
|
const timestamp = date.toLocaleString("sv-SE", { hour12: false });
|
|
322
|
-
const filePath = path.join(
|
|
330
|
+
const filePath = path.join(getLogDir(), `${sanitizedName}-${dateKey}.log`);
|
|
323
331
|
const message = formatArgs(logObj.args);
|
|
324
332
|
const traceIdStr = traceId ? ` [${traceId}]` : "";
|
|
325
333
|
appendLine(filePath, `[${timestamp}] [${logObj.type}] [${logObj.tag || name}]${traceIdStr}${message ? ` ${message}` : ""}`);
|
|
@@ -1031,6 +1039,7 @@ const BUILTIN_PROVIDER_CURRENCIES = {
|
|
|
1031
1039
|
codex: "USD",
|
|
1032
1040
|
dashscope: "CNY",
|
|
1033
1041
|
deepseek: "CNY",
|
|
1042
|
+
kimi: "USD",
|
|
1034
1043
|
"opencode-go": "USD"
|
|
1035
1044
|
};
|
|
1036
1045
|
const BUILTIN_PROVIDER_PRICING = {
|
|
@@ -1163,7 +1172,12 @@ const BUILTIN_PROVIDER_PRICING = {
|
|
|
1163
1172
|
input: 6,
|
|
1164
1173
|
maxInputTokens: 1e6,
|
|
1165
1174
|
output: 24
|
|
1166
|
-
}] }
|
|
1175
|
+
}] },
|
|
1176
|
+
"kimi/kimi-k3": {
|
|
1177
|
+
cachedInput: 2,
|
|
1178
|
+
input: 20,
|
|
1179
|
+
output: 100
|
|
1180
|
+
}
|
|
1167
1181
|
},
|
|
1168
1182
|
deepseek: {
|
|
1169
1183
|
"deepseek-v4-flash": {
|
|
@@ -1281,6 +1295,18 @@ const BUILTIN_PROVIDER_PRICING = {
|
|
|
1281
1295
|
maxInputTokens: 512e3,
|
|
1282
1296
|
output: 2.4
|
|
1283
1297
|
}] }
|
|
1298
|
+
},
|
|
1299
|
+
kimi: {
|
|
1300
|
+
k3: {
|
|
1301
|
+
cachedInput: .3,
|
|
1302
|
+
input: 3,
|
|
1303
|
+
output: 15
|
|
1304
|
+
},
|
|
1305
|
+
"k3-256k": {
|
|
1306
|
+
cachedInput: .3,
|
|
1307
|
+
input: 3,
|
|
1308
|
+
output: 15
|
|
1309
|
+
}
|
|
1284
1310
|
}
|
|
1285
1311
|
};
|
|
1286
1312
|
function resolveTokenUsageCost(input) {
|
|
@@ -7938,4 +7964,4 @@ server.route("/:provider/images", providerImageRoutes);
|
|
|
7938
7964
|
//#endregion
|
|
7939
7965
|
export { server };
|
|
7940
7966
|
|
|
7941
|
-
//# sourceMappingURL=server-
|
|
7967
|
+
//# sourceMappingURL=server-DWY7PmxG.js.map
|