codeam-cli 1.4.10 → 1.4.12
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 +60 -13
- 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.12",
|
|
119
119
|
description: "Remote control Claude Code from your mobile device",
|
|
120
120
|
main: "dist/index.js",
|
|
121
121
|
bin: {
|
|
@@ -492,12 +492,15 @@ var CommandRelayService = class {
|
|
|
492
492
|
const commands = data?.data;
|
|
493
493
|
if (!Array.isArray(commands)) return;
|
|
494
494
|
for (const obj of commands) {
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
495
|
+
try {
|
|
496
|
+
await this.onCommand({
|
|
497
|
+
id: obj.id,
|
|
498
|
+
sessionId: obj.sessionId,
|
|
499
|
+
type: obj.type,
|
|
500
|
+
payload: obj.payload ?? {}
|
|
501
|
+
});
|
|
502
|
+
} catch {
|
|
503
|
+
}
|
|
501
504
|
}
|
|
502
505
|
} catch {
|
|
503
506
|
}
|
|
@@ -1387,9 +1390,29 @@ var HistoryService = class {
|
|
|
1387
1390
|
}
|
|
1388
1391
|
pluginId;
|
|
1389
1392
|
cwd;
|
|
1393
|
+
currentConversationId = null;
|
|
1390
1394
|
get projectDir() {
|
|
1391
1395
|
return path4.join(os4.homedir(), ".claude", "projects", encodeCwd(this.cwd));
|
|
1392
1396
|
}
|
|
1397
|
+
/** Set the current Claude conversation ID (extracted from /cost command or session start) */
|
|
1398
|
+
setCurrentConversationId(id) {
|
|
1399
|
+
this.currentConversationId = id;
|
|
1400
|
+
}
|
|
1401
|
+
/** Extract conversation ID from Claude output (e.g., from session resume messages) */
|
|
1402
|
+
tryExtractConversationIdFromOutput(output) {
|
|
1403
|
+
const patterns = [
|
|
1404
|
+
/Resuming session[:\s]+([a-f0-9-]{36})/i,
|
|
1405
|
+
/session[:\s]+([a-f0-9-]{36})/i,
|
|
1406
|
+
/conversation[:\s]+([a-f0-9-]{36})/i
|
|
1407
|
+
];
|
|
1408
|
+
for (const pattern of patterns) {
|
|
1409
|
+
const match = output.match(pattern);
|
|
1410
|
+
if (match) {
|
|
1411
|
+
this.currentConversationId = match[1];
|
|
1412
|
+
return;
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1393
1416
|
/**
|
|
1394
1417
|
* Read the most recently modified JSONL session file and extract the
|
|
1395
1418
|
* context window usage from the last assistant message's usage field.
|
|
@@ -1414,28 +1437,52 @@ var HistoryService = class {
|
|
|
1414
1437
|
}
|
|
1415
1438
|
}).sort((a, b) => b.mtime - a.mtime);
|
|
1416
1439
|
if (files.length === 0) return null;
|
|
1440
|
+
let targetFile = files[0].name;
|
|
1441
|
+
if (this.currentConversationId) {
|
|
1442
|
+
const conversationFile = `${this.currentConversationId}.jsonl`;
|
|
1443
|
+
const exists = files.some((f) => f.name === conversationFile);
|
|
1444
|
+
if (exists) {
|
|
1445
|
+
targetFile = conversationFile;
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1417
1448
|
let raw;
|
|
1418
1449
|
try {
|
|
1419
|
-
raw = fs4.readFileSync(path4.join(dir,
|
|
1450
|
+
raw = fs4.readFileSync(path4.join(dir, targetFile), "utf8");
|
|
1420
1451
|
} catch {
|
|
1421
1452
|
return null;
|
|
1422
1453
|
}
|
|
1423
1454
|
let lastUsage = null;
|
|
1424
1455
|
let lastModel = null;
|
|
1425
|
-
|
|
1456
|
+
let assistantMessageCount = 0;
|
|
1457
|
+
let hasAnyMessages = false;
|
|
1458
|
+
const lines = raw.split("\n").filter(Boolean);
|
|
1459
|
+
for (const line of lines) {
|
|
1426
1460
|
try {
|
|
1427
1461
|
const record = JSON.parse(line);
|
|
1462
|
+
if (record["type"] === "user" || record["type"] === "assistant") {
|
|
1463
|
+
hasAnyMessages = true;
|
|
1464
|
+
}
|
|
1428
1465
|
if (record["type"] === "assistant") {
|
|
1466
|
+
assistantMessageCount++;
|
|
1429
1467
|
const msg = record["message"];
|
|
1430
|
-
if (msg?.["
|
|
1468
|
+
if (msg?.["model"] === "<synthetic>") continue;
|
|
1469
|
+
const usage = msg?.["usage"];
|
|
1470
|
+
if (usage && (usage["input_tokens"] !== void 0 || usage["prompt_tokens"] !== void 0)) {
|
|
1471
|
+
lastUsage = usage;
|
|
1472
|
+
}
|
|
1431
1473
|
if (msg?.["model"]) lastModel = msg["model"];
|
|
1432
1474
|
}
|
|
1433
1475
|
} catch {
|
|
1434
1476
|
}
|
|
1435
1477
|
}
|
|
1436
|
-
if (!lastUsage)
|
|
1437
|
-
|
|
1438
|
-
|
|
1478
|
+
if (!lastUsage) {
|
|
1479
|
+
if (hasAnyMessages) {
|
|
1480
|
+
return { used: 0, total: 2e5, percent: 0, model: lastModel, outputTokens: 0, cacheReadTokens: 0 };
|
|
1481
|
+
}
|
|
1482
|
+
return null;
|
|
1483
|
+
}
|
|
1484
|
+
const inputTokens = (lastUsage["input_tokens"] ?? lastUsage["prompt_tokens"] ?? 0) + (lastUsage["cache_read_input_tokens"] ?? 0) + (lastUsage["cache_creation_input_tokens"] ?? 0);
|
|
1485
|
+
const outputTokens = lastUsage["output_tokens"] ?? lastUsage["completion_tokens"] ?? 0;
|
|
1439
1486
|
const total = 2e5;
|
|
1440
1487
|
const percent = Math.min(100, Math.round(inputTokens / total * 100));
|
|
1441
1488
|
return { used: inputTokens, total, percent, model: lastModel, outputTokens, cacheReadTokens: lastUsage["cache_read_input_tokens"] ?? 0 };
|