@yishiguji/tokenarena 0.8.4 → 0.8.6
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.js +69 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2120,9 +2120,14 @@ import { homedir as homedir12 } from "os";
|
|
|
2120
2120
|
import { join as join13 } from "path";
|
|
2121
2121
|
var TOOL_ID8 = "kimi-code";
|
|
2122
2122
|
var TOOL_NAME8 = "Kimi Code";
|
|
2123
|
-
var DEFAULT_SESSIONS_DIR3 = join13(homedir12(), ".kimi", "sessions");
|
|
2124
|
-
var DEFAULT_CONFIG_PATH = join13(homedir12(), ".kimi", "
|
|
2125
|
-
var USER_EVENT_TYPES = /* @__PURE__ */ new Set([
|
|
2123
|
+
var DEFAULT_SESSIONS_DIR3 = join13(homedir12(), ".kimi-code", "sessions");
|
|
2124
|
+
var DEFAULT_CONFIG_PATH = join13(homedir12(), ".kimi-code", "workspaces.json");
|
|
2125
|
+
var USER_EVENT_TYPES = /* @__PURE__ */ new Set([
|
|
2126
|
+
"UserMessage",
|
|
2127
|
+
"user_message",
|
|
2128
|
+
"Input",
|
|
2129
|
+
"turn.prompt"
|
|
2130
|
+
]);
|
|
2126
2131
|
var ASSISTANT_EVENT_TYPES = /* @__PURE__ */ new Set([
|
|
2127
2132
|
"AssistantMessage",
|
|
2128
2133
|
"assistant_message",
|
|
@@ -2158,9 +2163,23 @@ function findWireFiles(baseDir) {
|
|
|
2158
2163
|
withFileTypes: true
|
|
2159
2164
|
})) {
|
|
2160
2165
|
if (!session.isDirectory()) continue;
|
|
2161
|
-
const
|
|
2162
|
-
|
|
2163
|
-
|
|
2166
|
+
const newWireFile = join13(
|
|
2167
|
+
workDirPath,
|
|
2168
|
+
session.name,
|
|
2169
|
+
"agents",
|
|
2170
|
+
"main",
|
|
2171
|
+
"wire.jsonl"
|
|
2172
|
+
);
|
|
2173
|
+
if (existsSync13(newWireFile)) {
|
|
2174
|
+
results.push({ filePath: newWireFile, workDirHash: workDir.name });
|
|
2175
|
+
continue;
|
|
2176
|
+
}
|
|
2177
|
+
const legacyWireFile = join13(workDirPath, session.name, "wire.jsonl");
|
|
2178
|
+
if (existsSync13(legacyWireFile)) {
|
|
2179
|
+
results.push({
|
|
2180
|
+
filePath: legacyWireFile,
|
|
2181
|
+
workDirHash: workDir.name
|
|
2182
|
+
});
|
|
2164
2183
|
}
|
|
2165
2184
|
}
|
|
2166
2185
|
} catch {
|
|
@@ -2199,9 +2218,15 @@ function loadProjectMap(configPath) {
|
|
|
2199
2218
|
const config = JSON.parse(content);
|
|
2200
2219
|
const workspaces = config.workspaces || config.projects || {};
|
|
2201
2220
|
for (const [hash, info] of Object.entries(workspaces)) {
|
|
2202
|
-
|
|
2221
|
+
let pathValue;
|
|
2222
|
+
if (typeof info === "string") {
|
|
2223
|
+
pathValue = info;
|
|
2224
|
+
} else {
|
|
2225
|
+
pathValue = info.root || info.path || info.dir || void 0;
|
|
2226
|
+
}
|
|
2203
2227
|
if (!pathValue) continue;
|
|
2204
|
-
|
|
2228
|
+
const name = typeof info === "object" && info.name ? info.name : getPathLeaf5(pathValue);
|
|
2229
|
+
projectMap.set(hash, name);
|
|
2205
2230
|
}
|
|
2206
2231
|
} catch {
|
|
2207
2232
|
}
|
|
@@ -2240,6 +2265,42 @@ var KimiCodeParser = class {
|
|
|
2240
2265
|
} catch {
|
|
2241
2266
|
continue;
|
|
2242
2267
|
}
|
|
2268
|
+
if (obj.type === "usage.record") {
|
|
2269
|
+
const timestampValue2 = obj.time;
|
|
2270
|
+
const timestamp2 = timestampValue2 ? new Date(timestampValue2) : null;
|
|
2271
|
+
if (!timestamp2 || Number.isNaN(timestamp2.getTime())) continue;
|
|
2272
|
+
const usage = obj.usage;
|
|
2273
|
+
if (!usage) continue;
|
|
2274
|
+
const inputTokens2 = toSafeNumber7(
|
|
2275
|
+
usage.input_other ?? usage.inputOther
|
|
2276
|
+
);
|
|
2277
|
+
const outputTokens2 = toSafeNumber7(usage.output);
|
|
2278
|
+
const cachedTokens2 = toSafeNumber7(
|
|
2279
|
+
usage.input_cache_read ?? usage.inputCacheRead
|
|
2280
|
+
);
|
|
2281
|
+
if (inputTokens2 === 0 && outputTokens2 === 0 && cachedTokens2 === 0) {
|
|
2282
|
+
continue;
|
|
2283
|
+
}
|
|
2284
|
+
sessionEvents.push({
|
|
2285
|
+
sessionId,
|
|
2286
|
+
source: TOOL_ID8,
|
|
2287
|
+
project,
|
|
2288
|
+
timestamp: timestamp2,
|
|
2289
|
+
role: "assistant"
|
|
2290
|
+
});
|
|
2291
|
+
entries.push({
|
|
2292
|
+
sessionId,
|
|
2293
|
+
source: TOOL_ID8,
|
|
2294
|
+
model: obj.model || currentModel,
|
|
2295
|
+
project,
|
|
2296
|
+
timestamp: timestamp2,
|
|
2297
|
+
inputTokens: inputTokens2,
|
|
2298
|
+
outputTokens: outputTokens2,
|
|
2299
|
+
reasoningTokens: 0,
|
|
2300
|
+
cachedTokens: cachedTokens2
|
|
2301
|
+
});
|
|
2302
|
+
continue;
|
|
2303
|
+
}
|
|
2243
2304
|
const payload = obj.payload;
|
|
2244
2305
|
if (!payload) continue;
|
|
2245
2306
|
if (payload.model) {
|