codeam-cli 1.4.11 → 1.4.13
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 +17 -20
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -115,7 +115,7 @@ var import_qrcode_terminal = __toESM(require("qrcode-terminal"));
|
|
|
115
115
|
// package.json
|
|
116
116
|
var package_default = {
|
|
117
117
|
name: "codeam-cli",
|
|
118
|
-
version: "1.4.
|
|
118
|
+
version: "1.4.13",
|
|
119
119
|
description: "Remote control Claude Code from your mobile device",
|
|
120
120
|
main: "dist/index.js",
|
|
121
121
|
bin: {
|
|
@@ -1437,34 +1437,36 @@ var HistoryService = class {
|
|
|
1437
1437
|
}
|
|
1438
1438
|
}).sort((a, b) => b.mtime - a.mtime);
|
|
1439
1439
|
if (files.length === 0) return null;
|
|
1440
|
-
let targetFile = files[0].name;
|
|
1441
1440
|
if (this.currentConversationId) {
|
|
1442
1441
|
const conversationFile = `${this.currentConversationId}.jsonl`;
|
|
1443
|
-
const
|
|
1444
|
-
if (
|
|
1445
|
-
|
|
1442
|
+
const idx = files.findIndex((f) => f.name === conversationFile);
|
|
1443
|
+
if (idx > 0) {
|
|
1444
|
+
const [target] = files.splice(idx, 1);
|
|
1445
|
+
files.unshift(target);
|
|
1446
1446
|
}
|
|
1447
1447
|
}
|
|
1448
|
+
const MAX_FILES_TO_TRY = 3;
|
|
1449
|
+
for (let i = 0; i < Math.min(files.length, MAX_FILES_TO_TRY); i++) {
|
|
1450
|
+
const result = this.extractUsageFromFile(path4.join(dir, files[i].name));
|
|
1451
|
+
if (result) return result;
|
|
1452
|
+
}
|
|
1453
|
+
return null;
|
|
1454
|
+
}
|
|
1455
|
+
extractUsageFromFile(filePath) {
|
|
1448
1456
|
let raw;
|
|
1449
1457
|
try {
|
|
1450
|
-
raw = fs4.readFileSync(
|
|
1458
|
+
raw = fs4.readFileSync(filePath, "utf8");
|
|
1451
1459
|
} catch {
|
|
1452
1460
|
return null;
|
|
1453
1461
|
}
|
|
1454
1462
|
let lastUsage = null;
|
|
1455
1463
|
let lastModel = null;
|
|
1456
|
-
|
|
1457
|
-
let hasAnyMessages = false;
|
|
1458
|
-
const lines = raw.split("\n").filter(Boolean);
|
|
1459
|
-
for (const line of lines) {
|
|
1464
|
+
for (const line of raw.split("\n").filter(Boolean)) {
|
|
1460
1465
|
try {
|
|
1461
1466
|
const record = JSON.parse(line);
|
|
1462
|
-
if (record["type"] === "user" || record["type"] === "assistant") {
|
|
1463
|
-
hasAnyMessages = true;
|
|
1464
|
-
}
|
|
1465
1467
|
if (record["type"] === "assistant") {
|
|
1466
|
-
assistantMessageCount++;
|
|
1467
1468
|
const msg = record["message"];
|
|
1469
|
+
if (msg?.["model"] === "<synthetic>") continue;
|
|
1468
1470
|
const usage = msg?.["usage"];
|
|
1469
1471
|
if (usage && (usage["input_tokens"] !== void 0 || usage["prompt_tokens"] !== void 0)) {
|
|
1470
1472
|
lastUsage = usage;
|
|
@@ -1474,12 +1476,7 @@ var HistoryService = class {
|
|
|
1474
1476
|
} catch {
|
|
1475
1477
|
}
|
|
1476
1478
|
}
|
|
1477
|
-
if (!lastUsage)
|
|
1478
|
-
if (hasAnyMessages) {
|
|
1479
|
-
return { used: 0, total: 2e5, percent: 0, model: lastModel, outputTokens: 0, cacheReadTokens: 0 };
|
|
1480
|
-
}
|
|
1481
|
-
return null;
|
|
1482
|
-
}
|
|
1479
|
+
if (!lastUsage) return null;
|
|
1483
1480
|
const inputTokens = (lastUsage["input_tokens"] ?? lastUsage["prompt_tokens"] ?? 0) + (lastUsage["cache_read_input_tokens"] ?? 0) + (lastUsage["cache_creation_input_tokens"] ?? 0);
|
|
1484
1481
|
const outputTokens = lastUsage["output_tokens"] ?? lastUsage["completion_tokens"] ?? 0;
|
|
1485
1482
|
const total = 2e5;
|