codeam-cli 1.4.31 → 1.4.33
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 +14 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -116,7 +116,7 @@ var import_qrcode_terminal = __toESM(require("qrcode-terminal"));
|
|
|
116
116
|
// package.json
|
|
117
117
|
var package_default = {
|
|
118
118
|
name: "codeam-cli",
|
|
119
|
-
version: "1.4.
|
|
119
|
+
version: "1.4.33",
|
|
120
120
|
description: "Remote control Claude Code from your mobile device",
|
|
121
121
|
main: "dist/index.js",
|
|
122
122
|
bin: {
|
|
@@ -1338,6 +1338,8 @@ function extractText(content) {
|
|
|
1338
1338
|
}
|
|
1339
1339
|
return "";
|
|
1340
1340
|
}
|
|
1341
|
+
var MAX_CONVERSATION_MESSAGES = 100;
|
|
1342
|
+
var MAX_MESSAGE_TEXT_LENGTH = 2e3;
|
|
1341
1343
|
function parseJsonl(filePath) {
|
|
1342
1344
|
const messages = [];
|
|
1343
1345
|
let raw;
|
|
@@ -1357,15 +1359,15 @@ function parseJsonl(filePath) {
|
|
|
1357
1359
|
const uuid = record["uuid"] ?? `${Date.now()}-${Math.random()}`;
|
|
1358
1360
|
if (type === "user" && msg) {
|
|
1359
1361
|
const text = extractText(msg["content"]).trim();
|
|
1360
|
-
if (text) messages.push({ id: uuid, role: "user", text, timestamp });
|
|
1362
|
+
if (text) messages.push({ id: uuid, role: "user", text: text.slice(0, MAX_MESSAGE_TEXT_LENGTH), timestamp });
|
|
1361
1363
|
} else if (type === "assistant" && msg) {
|
|
1362
1364
|
const text = extractText(msg["content"]).trim();
|
|
1363
|
-
if (text) messages.push({ id: uuid, role: "agent", text, timestamp });
|
|
1365
|
+
if (text) messages.push({ id: uuid, role: "agent", text: text.slice(0, MAX_MESSAGE_TEXT_LENGTH), timestamp });
|
|
1364
1366
|
}
|
|
1365
1367
|
} catch {
|
|
1366
1368
|
}
|
|
1367
1369
|
}
|
|
1368
|
-
return messages;
|
|
1370
|
+
return messages.slice(-MAX_CONVERSATION_MESSAGES);
|
|
1369
1371
|
}
|
|
1370
1372
|
function post(endpoint, body) {
|
|
1371
1373
|
return new Promise((resolve) => {
|
|
@@ -1382,7 +1384,7 @@ function post(endpoint, body) {
|
|
|
1382
1384
|
"Content-Type": "application/json",
|
|
1383
1385
|
"Content-Length": Buffer.byteLength(payload)
|
|
1384
1386
|
},
|
|
1385
|
-
timeout:
|
|
1387
|
+
timeout: 15e3
|
|
1386
1388
|
},
|
|
1387
1389
|
(res) => {
|
|
1388
1390
|
res.resume();
|
|
@@ -1435,6 +1437,7 @@ var HistoryService = class {
|
|
|
1435
1437
|
currentConversationId = null;
|
|
1436
1438
|
_rateLimitReset = null;
|
|
1437
1439
|
_quotaPercent = null;
|
|
1440
|
+
_quotaFetchedAt = 0;
|
|
1438
1441
|
/** Store rate limit reset info detected from Claude Code output */
|
|
1439
1442
|
setRateLimitReset(reset) {
|
|
1440
1443
|
this._rateLimitReset = reset;
|
|
@@ -1445,10 +1448,15 @@ var HistoryService = class {
|
|
|
1445
1448
|
/** Store weekly quota usage percentage parsed from /usage output */
|
|
1446
1449
|
setQuotaPercent(percent) {
|
|
1447
1450
|
this._quotaPercent = percent;
|
|
1451
|
+
this._quotaFetchedAt = Date.now();
|
|
1448
1452
|
}
|
|
1449
1453
|
getQuotaPercent() {
|
|
1450
1454
|
return this._quotaPercent;
|
|
1451
1455
|
}
|
|
1456
|
+
/** Check if the quota cache is stale (older than ttlMs, default 30 min) */
|
|
1457
|
+
isQuotaStale(ttlMs = 30 * 60 * 1e3) {
|
|
1458
|
+
return this._quotaPercent === null || Date.now() - this._quotaFetchedAt > ttlMs;
|
|
1459
|
+
}
|
|
1452
1460
|
get projectDir() {
|
|
1453
1461
|
return path4.join(os4.homedir(), ".claude", "projects", encodeCwd(this.cwd));
|
|
1454
1462
|
}
|
|
@@ -1698,8 +1706,6 @@ async function start() {
|
|
|
1698
1706
|
const cwd = process.cwd();
|
|
1699
1707
|
const ws = new WebSocketService(session.id, pluginId);
|
|
1700
1708
|
const historySvc = new HistoryService(pluginId, cwd);
|
|
1701
|
-
let turnCount = 0;
|
|
1702
|
-
const USAGE_FETCH_INTERVAL = 5;
|
|
1703
1709
|
let quotaFetchInProgress = false;
|
|
1704
1710
|
function fetchQuotaUsage() {
|
|
1705
1711
|
if (quotaFetchInProgress) return;
|
|
@@ -1808,8 +1814,7 @@ except Exception:sys.exit(0)
|
|
|
1808
1814
|
}, (reset) => {
|
|
1809
1815
|
historySvc.setRateLimitReset(reset);
|
|
1810
1816
|
}, () => {
|
|
1811
|
-
|
|
1812
|
-
if (turnCount % USAGE_FETCH_INTERVAL === 1) {
|
|
1817
|
+
if (historySvc.isQuotaStale()) {
|
|
1813
1818
|
fetchQuotaUsage();
|
|
1814
1819
|
}
|
|
1815
1820
|
});
|