codesesh 1.0.4 → 1.0.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/README.md +5 -4
- package/dist/{chunk-W4PZHL2C.js → chunk-4ND6AT6W.js} +154 -92
- package/dist/chunk-4ND6AT6W.js.map +1 -0
- package/dist/chunk-4QFNZCBR.js +1271 -0
- package/dist/chunk-4QFNZCBR.js.map +1 -0
- package/dist/{chunk-MBZ4VV4C.js → chunk-A3MT6L6Z.js} +3 -3
- package/dist/chunk-COZSWVCH.js +89 -0
- package/dist/chunk-COZSWVCH.js.map +1 -0
- package/dist/{chunk-YCUN52HA.js → chunk-L3DDWTYV.js} +81 -115
- package/dist/chunk-L3DDWTYV.js.map +1 -0
- package/dist/{chunk-BYB77UAJ.js → chunk-XQDYKKRC.js} +139 -80
- package/dist/chunk-XQDYKKRC.js.map +1 -0
- package/dist/{chunk-3SXCTDD6.js → chunk-YZ6XCSVQ.js} +4 -3
- package/dist/{discovery-K3GLISI6.js → discovery-ADSQARBV.js} +11 -5
- package/dist/index.js +1538 -1030
- package/dist/index.js.map +1 -1
- package/dist/project-identity-worker.js +4 -4
- package/dist/scan-refresh-worker.js +17 -7
- package/dist/scan-refresh-worker.js.map +1 -1
- package/dist/search-index-worker.js +16 -8
- package/dist/search-index-worker.js.map +1 -1
- package/dist/session-detail-worker.js +79 -0
- package/dist/session-detail-worker.js.map +1 -0
- package/dist/smart-tag-worker.js +3 -3
- package/dist/web/assets/CustomTimeWindowDialog-D2bx7uDv.js +1 -0
- package/dist/web/assets/InteractiveReceipt-BFpIdno8.js +1 -0
- package/dist/web/assets/OverviewScreen-D_KXfiJi.js +1 -0
- package/dist/web/assets/{PrismHighlighter-B1a2dPJO.js → PrismHighlighter-BgVkYu_S.js} +1 -1
- package/dist/web/assets/Projects-CN44UpuR.js +1 -0
- package/dist/web/assets/SearchResultsPanel-CWD01v-a.js +1 -0
- package/dist/web/assets/SessionDetail-D8taQ6Tl.js +53 -0
- package/dist/web/assets/api-B9lJtVbO.js +1 -0
- package/dist/web/assets/index-XpolWMY4.js +1423 -0
- package/dist/web/assets/index-xbEEMszv.css +1 -0
- package/dist/web/assets/session-indexes-fib48ZKn.js +4 -0
- package/dist/web/assets/translate-Dmym1ZDl.js +2 -0
- package/dist/web/assets/utils-Bk66u8b3.js +1 -0
- package/dist/web/index.html +7 -7
- package/package.json +3 -3
- package/dist/chunk-BYB77UAJ.js.map +0 -1
- package/dist/chunk-G4HRD3AR.js +0 -246
- package/dist/chunk-G4HRD3AR.js.map +0 -1
- package/dist/chunk-W4PZHL2C.js.map +0 -1
- package/dist/chunk-YCUN52HA.js.map +0 -1
- package/dist/web/assets/InteractiveReceipt-Dk50TBsH.js +0 -1
- package/dist/web/assets/OverviewScreen-5hvQVp4H.js +0 -1
- package/dist/web/assets/Projects-Cy_v2yep.js +0 -1
- package/dist/web/assets/SearchResultsPanel-DfheEwpz.js +0 -1
- package/dist/web/assets/SessionDetail-DRI8R3st.js +0 -53
- package/dist/web/assets/api-GP9UCedC.js +0 -1
- package/dist/web/assets/contract-xJyW5u7a.js +0 -2
- package/dist/web/assets/index-Bd-YkWkZ.css +0 -1
- package/dist/web/assets/index-DEjvzumm.js +0 -1410
- package/dist/web/assets/panel-ND0J63d3.js +0 -1
- package/dist/web/assets/session-indexes-BsgjUoc1.js +0 -4
- package/dist/web/assets/utils-C7BqyxxV.js +0 -1
- /package/dist/{chunk-MBZ4VV4C.js.map → chunk-A3MT6L6Z.js.map} +0 -0
- /package/dist/{chunk-3SXCTDD6.js.map → chunk-YZ6XCSVQ.js.map} +0 -0
- /package/dist/{discovery-K3GLISI6.js.map → discovery-ADSQARBV.js.map} +0 -0
|
@@ -32,9 +32,9 @@ import {
|
|
|
32
32
|
reportFieldMismatch,
|
|
33
33
|
resolveSessionTitle,
|
|
34
34
|
safeParseJsonRecord
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-4ND6AT6W.js";
|
|
36
36
|
|
|
37
|
-
// ../core/dist/chunk-
|
|
37
|
+
// ../core/dist/chunk-PGD63YEI.mjs
|
|
38
38
|
import { statSync } from "fs";
|
|
39
39
|
import { readdirSync, statSync as statSync2 } from "fs";
|
|
40
40
|
import { join } from "path";
|
|
@@ -470,9 +470,11 @@ var FileSystemSessionSource = class extends BaseAgent {
|
|
|
470
470
|
count: (options) => this.listSessionSources(options).length
|
|
471
471
|
};
|
|
472
472
|
sourceFileStats = /* @__PURE__ */ new Map();
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
return
|
|
473
|
+
/** 解析单个源并写入 metaMap,返回会话 head(解析失败/不可见返回 null)。 */
|
|
474
|
+
scanSessionSource(sourcePath, options) {
|
|
475
|
+
return getParsedSession(
|
|
476
|
+
this.scanSessionSourceResult({ sessionId: "", sourcePath, fingerprint: "" }, options)
|
|
477
|
+
);
|
|
476
478
|
}
|
|
477
479
|
scanSessionSourceOutcome(source, options) {
|
|
478
480
|
const previousMeta = this.sessionMetaMap.get(source.sessionId);
|
|
@@ -602,9 +604,6 @@ var SingleFileSessionSource = class extends FileSystemSessionSource {
|
|
|
602
604
|
}
|
|
603
605
|
return result;
|
|
604
606
|
}
|
|
605
|
-
scanSessionSource(sourcePath, options) {
|
|
606
|
-
return getParsedSession(this.parseSessionSource(sourcePath, options));
|
|
607
|
-
}
|
|
608
607
|
scanSessionSourceResult(source, options) {
|
|
609
608
|
return this.parseSessionSource(source.sourcePath, options);
|
|
610
609
|
}
|
|
@@ -841,6 +840,7 @@ function extractClaudeUsage(data, msg) {
|
|
|
841
840
|
if (!key) return null;
|
|
842
841
|
return {
|
|
843
842
|
key,
|
|
843
|
+
model: asString(msg["model"])?.trim() || void 0,
|
|
844
844
|
input: readUsageNumber(usage, "input_tokens"),
|
|
845
845
|
output: readUsageNumber(usage, "output_tokens"),
|
|
846
846
|
cacheRead: readUsageNumber(usage, "cache_read_input_tokens"),
|
|
@@ -849,7 +849,7 @@ function extractClaudeUsage(data, msg) {
|
|
|
849
849
|
}
|
|
850
850
|
var ClaudeRecordConverter = class {
|
|
851
851
|
// --- Record conversion ---
|
|
852
|
-
convertRecord(data, builder, assistantUuidToToolCalls,
|
|
852
|
+
convertRecord(data, builder, assistantUuidToToolCalls, requestMessages, childSessionIdByToolUseId) {
|
|
853
853
|
if (data["isMeta"] === true) return;
|
|
854
854
|
const msgType = String(data["type"] ?? "");
|
|
855
855
|
if (isInternalEventType(msgType)) return;
|
|
@@ -858,7 +858,7 @@ var ClaudeRecordConverter = class {
|
|
|
858
858
|
data,
|
|
859
859
|
builder,
|
|
860
860
|
assistantUuidToToolCalls,
|
|
861
|
-
|
|
861
|
+
requestMessages,
|
|
862
862
|
childSessionIdByToolUseId
|
|
863
863
|
);
|
|
864
864
|
} else if (msgType === "user") {
|
|
@@ -867,11 +867,15 @@ var ClaudeRecordConverter = class {
|
|
|
867
867
|
this.convertToolResultRecord(data, builder);
|
|
868
868
|
}
|
|
869
869
|
}
|
|
870
|
-
convertAssistantRecord(data, builder, assistantUuidToToolCalls,
|
|
870
|
+
convertAssistantRecord(data, builder, assistantUuidToToolCalls, requestMessages, childSessionIdByToolUseId) {
|
|
871
871
|
const msg = asRecord(data["message"]) ?? {};
|
|
872
872
|
const timestampMs = parseClaudeTimestampMs(data);
|
|
873
|
+
const model = asString(msg["model"])?.trim();
|
|
873
874
|
const rawContent = asArray(msg["content"]) ?? [];
|
|
874
875
|
const uuid = String(data["uuid"] ?? "");
|
|
876
|
+
const usage = extractClaudeUsage(data, msg);
|
|
877
|
+
let usageMessage = usage ? requestMessages.get(usage.key) : void 0;
|
|
878
|
+
if (usage && !usageMessage) builder.beginTurn();
|
|
875
879
|
const toolCallIds = [];
|
|
876
880
|
for (const item of rawContent) {
|
|
877
881
|
const part = asRecord(item);
|
|
@@ -882,10 +886,10 @@ var ClaudeRecordConverter = class {
|
|
|
882
886
|
if (text) {
|
|
883
887
|
const message2 = builder.appendAssistantPart(
|
|
884
888
|
this.buildReasoningPart(text, timestampMs),
|
|
885
|
-
{ id: uuid, timestampMs, agent: "claude" },
|
|
889
|
+
{ id: uuid, timestampMs, agent: "claude", model },
|
|
886
890
|
{ deduplicateTail: true }
|
|
887
891
|
);
|
|
888
|
-
|
|
892
|
+
usageMessage ??= message2;
|
|
889
893
|
}
|
|
890
894
|
continue;
|
|
891
895
|
}
|
|
@@ -897,11 +901,12 @@ var ClaudeRecordConverter = class {
|
|
|
897
901
|
{
|
|
898
902
|
id: uuid,
|
|
899
903
|
timestampMs,
|
|
900
|
-
agent: "claude"
|
|
904
|
+
agent: "claude",
|
|
905
|
+
model
|
|
901
906
|
},
|
|
902
907
|
{ deduplicateTail: true }
|
|
903
908
|
);
|
|
904
|
-
|
|
909
|
+
usageMessage ??= message2;
|
|
905
910
|
}
|
|
906
911
|
continue;
|
|
907
912
|
}
|
|
@@ -911,11 +916,11 @@ var ClaudeRecordConverter = class {
|
|
|
911
916
|
const toolPart2 = this.buildToolPart(part, timestampMs);
|
|
912
917
|
const message = builder.appendToolCall(
|
|
913
918
|
toolPart2,
|
|
914
|
-
{ id: uuid, timestampMs, agent: "claude", subagentId },
|
|
919
|
+
{ id: uuid, timestampMs, agent: "claude", subagentId, model },
|
|
915
920
|
{ modeOnCreate: "tool" }
|
|
916
921
|
);
|
|
917
922
|
if (subagentId) message.subagent_id = subagentId;
|
|
918
|
-
|
|
923
|
+
usageMessage ??= message;
|
|
919
924
|
if (toolCallId) {
|
|
920
925
|
toolCallIds.push(toolCallId);
|
|
921
926
|
}
|
|
@@ -923,6 +928,26 @@ var ClaudeRecordConverter = class {
|
|
|
923
928
|
if (toolCallIds.length > 0) {
|
|
924
929
|
assistantUuidToToolCalls.set(uuid, toolCallIds);
|
|
925
930
|
}
|
|
931
|
+
if (usage) {
|
|
932
|
+
usageMessage ??= builder.appendMessage({
|
|
933
|
+
id: uuid,
|
|
934
|
+
role: "assistant",
|
|
935
|
+
timestampMs,
|
|
936
|
+
agent: "claude",
|
|
937
|
+
model
|
|
938
|
+
});
|
|
939
|
+
requestMessages.set(usage.key, usageMessage);
|
|
940
|
+
usageMessage.model = usage.model;
|
|
941
|
+
usageMessage.tokens = {
|
|
942
|
+
input: usage.input + usage.cacheCreate + usage.cacheRead,
|
|
943
|
+
output: usage.output,
|
|
944
|
+
cache_read: usage.cacheRead,
|
|
945
|
+
cache_create: usage.cacheCreate
|
|
946
|
+
};
|
|
947
|
+
usageMessage.time_completed = timestampMs;
|
|
948
|
+
usageMessage.cost = estimateTokenCost(usage.model, usageMessage.tokens) ?? 0;
|
|
949
|
+
usageMessage.cost_source = usageMessage.cost > 0 ? "estimated" : void 0;
|
|
950
|
+
}
|
|
926
951
|
}
|
|
927
952
|
convertUserRecord(data, builder, assistantUuidToToolCalls) {
|
|
928
953
|
const msg = asRecord(data["message"]) ?? {};
|
|
@@ -1000,27 +1025,6 @@ var ClaudeRecordConverter = class {
|
|
|
1000
1025
|
time_created: timestampMs
|
|
1001
1026
|
};
|
|
1002
1027
|
}
|
|
1003
|
-
applyAssistantMetadata(message, data, msg, countedUsageKeys) {
|
|
1004
|
-
const model = msg["model"];
|
|
1005
|
-
if (model && typeof model === "string" && !message.model) {
|
|
1006
|
-
message.model = model;
|
|
1007
|
-
}
|
|
1008
|
-
const usage = extractClaudeUsage(data, msg);
|
|
1009
|
-
if (usage && !message.tokens && !countedUsageKeys.has(usage.key)) {
|
|
1010
|
-
countedUsageKeys.add(usage.key);
|
|
1011
|
-
message.tokens = {
|
|
1012
|
-
input: usage.input + usage.cacheCreate + usage.cacheRead,
|
|
1013
|
-
output: usage.output,
|
|
1014
|
-
cache_read: usage.cacheRead,
|
|
1015
|
-
cache_create: usage.cacheCreate
|
|
1016
|
-
};
|
|
1017
|
-
const cost = estimateTokenCost(message.model, message.tokens);
|
|
1018
|
-
if (cost !== null) {
|
|
1019
|
-
message.cost = cost;
|
|
1020
|
-
message.cost_source = "estimated";
|
|
1021
|
-
}
|
|
1022
|
-
}
|
|
1023
|
-
}
|
|
1024
1028
|
// --- User content normalization ---
|
|
1025
1029
|
normalizeUserTextParts(content, timestampMs) {
|
|
1026
1030
|
if (typeof content === "string") {
|
|
@@ -1372,7 +1376,7 @@ var TranscriptBuilder = class {
|
|
|
1372
1376
|
};
|
|
1373
1377
|
}
|
|
1374
1378
|
};
|
|
1375
|
-
var HEAD_INDEX_VERSION = "claudecode-head-
|
|
1379
|
+
var HEAD_INDEX_VERSION = "claudecode-head-v9";
|
|
1376
1380
|
function resolveClaudeCodeDataRoot() {
|
|
1377
1381
|
return resolveHomePath("CLAUDE_CONFIG_DIR", ".claude");
|
|
1378
1382
|
}
|
|
@@ -1431,7 +1435,7 @@ var ClaudeCodeAgent = class extends SingleFileSessionSource {
|
|
|
1431
1435
|
const allSources = this.walkFiles(projectDirs, (entry) => entry.name.endsWith(".jsonl"), {
|
|
1432
1436
|
recursive: true
|
|
1433
1437
|
});
|
|
1434
|
-
this.indexChildContexts(allSources
|
|
1438
|
+
this.indexChildContexts(allSources);
|
|
1435
1439
|
const indexedSources = allSources.flatMap((source) => {
|
|
1436
1440
|
const child = this.childContextsBySource.get(source.file);
|
|
1437
1441
|
if (!child && !projectDirSet.has(dirname(source.file))) return [];
|
|
@@ -1447,6 +1451,7 @@ var ClaudeCodeAgent = class extends SingleFileSessionSource {
|
|
|
1447
1451
|
({ source }) => matchesScanWindow(source.stat.mtimeMs, options)
|
|
1448
1452
|
);
|
|
1449
1453
|
if (options?.from != null || options?.to != null) {
|
|
1454
|
+
const knownSessionIds = new Set(indexedSources.map(({ sessionId }) => sessionId));
|
|
1450
1455
|
const childrenByParent = /* @__PURE__ */ new Map();
|
|
1451
1456
|
for (const indexed of indexedSources) {
|
|
1452
1457
|
const parentId = indexed.child?.parentSessionId;
|
|
@@ -1467,7 +1472,7 @@ var ClaudeCodeAgent = class extends SingleFileSessionSource {
|
|
|
1467
1472
|
const indexed = windowSelectedById.get(sessionId);
|
|
1468
1473
|
if (!indexed) return false;
|
|
1469
1474
|
const parentId = indexed.child?.parentSessionId;
|
|
1470
|
-
if (!parentId) {
|
|
1475
|
+
if (!parentId || !knownSessionIds.has(parentId)) {
|
|
1471
1476
|
acceptedIds.add(sessionId);
|
|
1472
1477
|
return true;
|
|
1473
1478
|
}
|
|
@@ -1483,7 +1488,9 @@ var ClaudeCodeAgent = class extends SingleFileSessionSource {
|
|
|
1483
1488
|
}
|
|
1484
1489
|
}
|
|
1485
1490
|
if (options?.includeRelatedSessions !== false) {
|
|
1486
|
-
const pending = [...connectedSelected.values()].filter(
|
|
1491
|
+
const pending = [...connectedSelected.values()].filter(
|
|
1492
|
+
({ child }) => !child?.parentSessionId || !knownSessionIds.has(child.parentSessionId)
|
|
1493
|
+
).map(({ sessionId }) => sessionId);
|
|
1487
1494
|
while (pending.length > 0) {
|
|
1488
1495
|
const parentId = pending.pop();
|
|
1489
1496
|
for (const child of childrenByParent.get(parentId) ?? []) {
|
|
@@ -1532,14 +1539,14 @@ var ClaudeCodeAgent = class extends SingleFileSessionSource {
|
|
|
1532
1539
|
this.ensureChildIndex();
|
|
1533
1540
|
const builder = new TranscriptBuilder();
|
|
1534
1541
|
const assistantUuidToToolCalls = /* @__PURE__ */ new Map();
|
|
1535
|
-
const
|
|
1542
|
+
const requestMessages = /* @__PURE__ */ new Map();
|
|
1536
1543
|
for (const record of readJsonlFile(meta.sourcePath)) {
|
|
1537
1544
|
try {
|
|
1538
1545
|
CLAUDE_RECORD_CONVERTER.convertRecord(
|
|
1539
1546
|
record,
|
|
1540
1547
|
builder,
|
|
1541
1548
|
assistantUuidToToolCalls,
|
|
1542
|
-
|
|
1549
|
+
requestMessages,
|
|
1543
1550
|
this.childSessionIdByToolUseId
|
|
1544
1551
|
);
|
|
1545
1552
|
} catch {
|
|
@@ -1589,33 +1596,18 @@ var ClaudeCodeAgent = class extends SingleFileSessionSource {
|
|
|
1589
1596
|
this.indexChildContexts(
|
|
1590
1597
|
this.walkFiles(projectDirs, (entry) => entry.name.endsWith(".jsonl"), {
|
|
1591
1598
|
recursive: true
|
|
1592
|
-
})
|
|
1593
|
-
projectDirs
|
|
1599
|
+
})
|
|
1594
1600
|
);
|
|
1595
1601
|
}
|
|
1596
|
-
indexChildContexts(sources
|
|
1602
|
+
indexChildContexts(sources) {
|
|
1597
1603
|
this.childContextsBySource.clear();
|
|
1598
1604
|
this.childSessionIdByToolUseId.clear();
|
|
1599
|
-
const projectDirSet = new Set(projectDirs);
|
|
1600
|
-
const contexts = /* @__PURE__ */ new Map();
|
|
1601
|
-
const knownSessionIds = /* @__PURE__ */ new Set();
|
|
1602
1605
|
for (const source of sources) {
|
|
1603
1606
|
const child = this.readChildContext(source.file);
|
|
1604
|
-
if (!child)
|
|
1605
|
-
|
|
1606
|
-
knownSessionIds.add(basename(source.file, ".jsonl"));
|
|
1607
|
-
}
|
|
1608
|
-
continue;
|
|
1609
|
-
}
|
|
1610
|
-
contexts.set(source.file, child);
|
|
1611
|
-
knownSessionIds.add(child.sessionId);
|
|
1612
|
-
}
|
|
1613
|
-
for (const [sourcePath, child] of contexts) {
|
|
1614
|
-
const parentSessionId = child.parentSessionId && knownSessionIds.has(child.parentSessionId) ? child.parentSessionId : null;
|
|
1615
|
-
const normalized = parentSessionId === child.parentSessionId ? child : { ...child, parentSessionId };
|
|
1616
|
-
this.childContextsBySource.set(sourcePath, normalized);
|
|
1607
|
+
if (!child) continue;
|
|
1608
|
+
this.childContextsBySource.set(source.file, child);
|
|
1617
1609
|
if (child.toolUseId) {
|
|
1618
|
-
this.childSessionIdByToolUseId.set(child.toolUseId,
|
|
1610
|
+
this.childSessionIdByToolUseId.set(child.toolUseId, child.sessionId);
|
|
1619
1611
|
}
|
|
1620
1612
|
}
|
|
1621
1613
|
this.childIndexReady = true;
|
|
@@ -1651,8 +1643,7 @@ var ClaudeCodeAgent = class extends SingleFileSessionSource {
|
|
|
1651
1643
|
const sessionId = asString(metadata?.["agentId"])?.trim() || fileStem.replace(/^agent-/, "");
|
|
1652
1644
|
if (!sessionId) return null;
|
|
1653
1645
|
const parentAgentId = asString(metadata?.["parentAgentId"])?.trim();
|
|
1654
|
-
const
|
|
1655
|
-
const parentSessionId = candidateParentId && this.hasChildParent(sourcePath, projectDir, candidateParentId) ? candidateParentId : null;
|
|
1646
|
+
const parentSessionId = parentAgentId || basename(parentDir) || null;
|
|
1656
1647
|
const name = asString(metadata?.["name"])?.trim();
|
|
1657
1648
|
const description = asString(metadata?.["description"])?.trim();
|
|
1658
1649
|
const context = {
|
|
@@ -1666,14 +1657,6 @@ var ClaudeCodeAgent = class extends SingleFileSessionSource {
|
|
|
1666
1657
|
this.childContextCache.set(sourcePath, { metaMtimeMs, context });
|
|
1667
1658
|
return context;
|
|
1668
1659
|
}
|
|
1669
|
-
hasChildParent(sourcePath, projectDir, parentSessionId) {
|
|
1670
|
-
const subagentsDir = dirname(sourcePath);
|
|
1671
|
-
return [
|
|
1672
|
-
join3(projectDir, parentSessionId + ".jsonl"),
|
|
1673
|
-
join3(subagentsDir, "agent-" + parentSessionId + ".jsonl"),
|
|
1674
|
-
join3(subagentsDir, parentSessionId + ".jsonl")
|
|
1675
|
-
].some((path) => existsSync2(path));
|
|
1676
|
-
}
|
|
1677
1660
|
createFileSessionMeta(head, source) {
|
|
1678
1661
|
const child = this.getChildContext(source.file);
|
|
1679
1662
|
const projectDir = child?.projectDir ?? dirname(source.file);
|
|
@@ -1744,7 +1727,7 @@ var ClaudeCodeAgent = class extends SingleFileSessionSource {
|
|
|
1744
1727
|
let totalCacheCreateTokens = 0;
|
|
1745
1728
|
let totalCost = 0;
|
|
1746
1729
|
const modelUsageMap = {};
|
|
1747
|
-
const
|
|
1730
|
+
const usageByRequest = /* @__PURE__ */ new Map();
|
|
1748
1731
|
let messageTitle = null;
|
|
1749
1732
|
for (const line of readJsonlFileLines(filePath)) {
|
|
1750
1733
|
let data;
|
|
@@ -1791,36 +1774,28 @@ var ClaudeCodeAgent = class extends SingleFileSessionSource {
|
|
|
1791
1774
|
}
|
|
1792
1775
|
if (role === "assistant") {
|
|
1793
1776
|
const usage = extractClaudeUsage(data, msg);
|
|
1794
|
-
if (usage
|
|
1795
|
-
countedUsageKeys.add(usage.key);
|
|
1796
|
-
const inputTokens = usage.input;
|
|
1797
|
-
const cacheRead = usage.cacheRead;
|
|
1798
|
-
const cacheCreate = usage.cacheCreate;
|
|
1799
|
-
const outputTokens = usage.output;
|
|
1800
|
-
totalInputTokens += inputTokens + cacheRead + cacheCreate;
|
|
1801
|
-
totalOutputTokens += outputTokens;
|
|
1802
|
-
totalCacheReadTokens += cacheRead;
|
|
1803
|
-
totalCacheCreateTokens += cacheCreate;
|
|
1804
|
-
const m = asString(msg["model"]);
|
|
1805
|
-
if (m?.trim()) {
|
|
1806
|
-
const name = m.trim();
|
|
1807
|
-
const msgTotal = inputTokens + cacheRead + cacheCreate + outputTokens;
|
|
1808
|
-
modelUsageMap[name] = (modelUsageMap[name] ?? 0) + msgTotal;
|
|
1809
|
-
const cost = estimateTokenCost(name, {
|
|
1810
|
-
input: inputTokens + cacheRead + cacheCreate,
|
|
1811
|
-
output: outputTokens,
|
|
1812
|
-
cache_read: cacheRead,
|
|
1813
|
-
cache_create: cacheCreate
|
|
1814
|
-
});
|
|
1815
|
-
if (cost !== null) totalCost += cost;
|
|
1816
|
-
}
|
|
1817
|
-
}
|
|
1777
|
+
if (usage) usageByRequest.set(usage.key, usage);
|
|
1818
1778
|
}
|
|
1819
1779
|
}
|
|
1820
1780
|
} catch {
|
|
1821
1781
|
}
|
|
1822
1782
|
}
|
|
1823
1783
|
if (lineIndex === 0) return skippedSession("empty file");
|
|
1784
|
+
for (const usage of usageByRequest.values()) {
|
|
1785
|
+
const input = usage.input + usage.cacheRead + usage.cacheCreate;
|
|
1786
|
+
totalInputTokens += input;
|
|
1787
|
+
totalOutputTokens += usage.output;
|
|
1788
|
+
totalCacheReadTokens += usage.cacheRead;
|
|
1789
|
+
totalCacheCreateTokens += usage.cacheCreate;
|
|
1790
|
+
if (!usage.model) continue;
|
|
1791
|
+
modelUsageMap[usage.model] = (modelUsageMap[usage.model] ?? 0) + input + usage.output;
|
|
1792
|
+
totalCost += estimateTokenCost(usage.model, {
|
|
1793
|
+
input,
|
|
1794
|
+
output: usage.output,
|
|
1795
|
+
cache_read: usage.cacheRead,
|
|
1796
|
+
cache_create: usage.cacheCreate
|
|
1797
|
+
}) ?? 0;
|
|
1798
|
+
}
|
|
1824
1799
|
const directory = cwd ?? projectDir;
|
|
1825
1800
|
const directoryTitle = basenameTitle(directory) || basenameTitle(projectDir);
|
|
1826
1801
|
const title = resolveSessionTitle(explicitTitle, messageTitle, directoryTitle);
|
|
@@ -2703,9 +2678,6 @@ var KimiAgent = class extends FileSystemSessionSource {
|
|
|
2703
2678
|
}
|
|
2704
2679
|
return refs;
|
|
2705
2680
|
}
|
|
2706
|
-
scanSessionSource(sourcePath) {
|
|
2707
|
-
return getParsedSession(this.parseSessionHeadResult(sourcePath));
|
|
2708
|
-
}
|
|
2709
2681
|
scanSessionSourceResult(source) {
|
|
2710
2682
|
return this.parseSessionHeadResult(source.sourcePath);
|
|
2711
2683
|
}
|
|
@@ -3405,9 +3377,6 @@ var KimiCodeAgent = class extends FileSystemSessionSource {
|
|
|
3405
3377
|
return false;
|
|
3406
3378
|
});
|
|
3407
3379
|
}
|
|
3408
|
-
scanSessionSource(sourcePath) {
|
|
3409
|
-
return getParsedSession(this.parseSessionHeadResult(sourcePath));
|
|
3410
|
-
}
|
|
3411
3380
|
scanSessionSourceResult(source) {
|
|
3412
3381
|
return this.parseSessionHeadResult(source.sourcePath);
|
|
3413
3382
|
}
|
|
@@ -5339,7 +5308,12 @@ var CursorAgent = class extends DatabaseSessionSource {
|
|
|
5339
5308
|
root: dataPath,
|
|
5340
5309
|
path: join8(dataPath, "globalStorage", "state.vscdb")
|
|
5341
5310
|
},
|
|
5342
|
-
{
|
|
5311
|
+
{
|
|
5312
|
+
root: dataPath,
|
|
5313
|
+
path: join8(dataPath, "workspaceStorage"),
|
|
5314
|
+
// Read-only SQLite opens can rewrite shared memory without changing sessions.
|
|
5315
|
+
ignoredFileNames: ["state.vscdb-shm"]
|
|
5316
|
+
}
|
|
5343
5317
|
] : []
|
|
5344
5318
|
};
|
|
5345
5319
|
}
|
|
@@ -7002,9 +6976,6 @@ var GrokAgent = class extends FileSystemSessionSource {
|
|
|
7002
6976
|
];
|
|
7003
6977
|
});
|
|
7004
6978
|
}
|
|
7005
|
-
scanSessionSource(sourcePath) {
|
|
7006
|
-
return getParsedSession(this.parseSessionHeadResult(sourcePath));
|
|
7007
|
-
}
|
|
7008
6979
|
scanSessionSourceResult(source) {
|
|
7009
6980
|
return this.parseSessionHeadResult(source.sourcePath);
|
|
7010
6981
|
}
|
|
@@ -8154,11 +8125,6 @@ var DshAgent = class extends FileSystemSessionSource {
|
|
|
8154
8125
|
return refs;
|
|
8155
8126
|
}
|
|
8156
8127
|
/** The scan window is applied during enumeration, so parsing needs no options. */
|
|
8157
|
-
scanSessionSource(sourcePath) {
|
|
8158
|
-
return getParsedSession(
|
|
8159
|
-
this.scanSessionSourceResult({ sessionId: "", sourcePath, fingerprint: "" })
|
|
8160
|
-
);
|
|
8161
|
-
}
|
|
8162
8128
|
scanSessionSourceResult(source) {
|
|
8163
8129
|
const encoding = encodingOfPath(source.sourcePath);
|
|
8164
8130
|
const { header, projection } = this.parseSession(source.sourcePath, encoding);
|
|
@@ -8419,4 +8385,4 @@ export {
|
|
|
8419
8385
|
createRegisteredAgents,
|
|
8420
8386
|
getAgentInfoMap
|
|
8421
8387
|
};
|
|
8422
|
-
//# sourceMappingURL=chunk-
|
|
8388
|
+
//# sourceMappingURL=chunk-L3DDWTYV.js.map
|