claude-scope 0.8.41 → 0.8.44
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/claude-scope.cjs +76 -46
- package/package.json +1 -1
package/dist/claude-scope.cjs
CHANGED
|
@@ -3574,7 +3574,7 @@ var init_context_widget = __esm({
|
|
|
3574
3574
|
const current_usage = contextWindow.current_usage;
|
|
3575
3575
|
const context_window_size = contextWindow.context_window_size;
|
|
3576
3576
|
const used_percentage = contextWindow.used_percentage;
|
|
3577
|
-
if (used_percentage !== void 0) {
|
|
3577
|
+
if (used_percentage !== void 0 && used_percentage > 0) {
|
|
3578
3578
|
const renderData2 = {
|
|
3579
3579
|
used: 0,
|
|
3580
3580
|
// Will be calculated from percentage
|
|
@@ -26221,6 +26221,24 @@ function generateRichLayout(style, themeName) {
|
|
|
26221
26221
|
count: theme.tools.count
|
|
26222
26222
|
}
|
|
26223
26223
|
}
|
|
26224
|
+
],
|
|
26225
|
+
"3": [
|
|
26226
|
+
{
|
|
26227
|
+
id: "sysmon",
|
|
26228
|
+
style,
|
|
26229
|
+
colors: {
|
|
26230
|
+
cpu: theme.sysmon.cpu,
|
|
26231
|
+
ram: theme.sysmon.ram,
|
|
26232
|
+
disk: theme.sysmon.disk,
|
|
26233
|
+
network: theme.sysmon.network,
|
|
26234
|
+
separator: theme.sysmon.separator
|
|
26235
|
+
}
|
|
26236
|
+
}
|
|
26237
|
+
],
|
|
26238
|
+
"4": [
|
|
26239
|
+
{
|
|
26240
|
+
id: "empty-line"
|
|
26241
|
+
}
|
|
26224
26242
|
]
|
|
26225
26243
|
}
|
|
26226
26244
|
};
|
|
@@ -26539,40 +26557,6 @@ init_model_widget();
|
|
|
26539
26557
|
|
|
26540
26558
|
// src/widgets/sysmon-widget.ts
|
|
26541
26559
|
init_widget_types();
|
|
26542
|
-
|
|
26543
|
-
// src/providers/metrics-cache.ts
|
|
26544
|
-
var MetricsCache = class {
|
|
26545
|
-
cached = null;
|
|
26546
|
-
cacheTime = 0;
|
|
26547
|
-
ttlMs;
|
|
26548
|
-
constructor(ttlMs = 1e3) {
|
|
26549
|
-
this.ttlMs = ttlMs;
|
|
26550
|
-
}
|
|
26551
|
-
/**
|
|
26552
|
-
* Get cached metrics or fetch fresh if cache expired
|
|
26553
|
-
* @param fetcher - Function to fetch fresh metrics
|
|
26554
|
-
* @returns Cached or fresh metrics, or null if fetcher returns null
|
|
26555
|
-
*/
|
|
26556
|
-
async get(fetcher) {
|
|
26557
|
-
const now = Date.now();
|
|
26558
|
-
if (this.cached && now - this.cacheTime < this.ttlMs) {
|
|
26559
|
-
return this.cached;
|
|
26560
|
-
}
|
|
26561
|
-
const fresh = await fetcher();
|
|
26562
|
-
this.cached = fresh;
|
|
26563
|
-
this.cacheTime = now;
|
|
26564
|
-
return fresh;
|
|
26565
|
-
}
|
|
26566
|
-
/**
|
|
26567
|
-
* Clear the cache
|
|
26568
|
-
*/
|
|
26569
|
-
clear() {
|
|
26570
|
-
this.cached = null;
|
|
26571
|
-
this.cacheTime = 0;
|
|
26572
|
-
}
|
|
26573
|
-
};
|
|
26574
|
-
|
|
26575
|
-
// src/widgets/sysmon-widget.ts
|
|
26576
26560
|
init_theme();
|
|
26577
26561
|
|
|
26578
26562
|
// src/widgets/sysmon/styles.ts
|
|
@@ -26644,14 +26628,10 @@ var SysmonWidget = class {
|
|
|
26644
26628
|
provider;
|
|
26645
26629
|
_lineOverride;
|
|
26646
26630
|
styleFn = sysmonStyles.balanced;
|
|
26647
|
-
cache;
|
|
26648
|
-
cacheTtlMs = 1e3;
|
|
26649
|
-
// 1 second cache
|
|
26650
26631
|
enabled = true;
|
|
26651
26632
|
constructor(colors2, provider) {
|
|
26652
26633
|
this.colors = colors2 ?? DEFAULT_THEME;
|
|
26653
26634
|
this.provider = provider ?? null;
|
|
26654
|
-
this.cache = new MetricsCache(this.cacheTtlMs);
|
|
26655
26635
|
}
|
|
26656
26636
|
async initialize(context) {
|
|
26657
26637
|
this.enabled = context.config?.enabled !== false;
|
|
@@ -26660,7 +26640,7 @@ var SysmonWidget = class {
|
|
|
26660
26640
|
if (!this.provider || !this.isEnabled()) {
|
|
26661
26641
|
return null;
|
|
26662
26642
|
}
|
|
26663
|
-
const metrics = await this.
|
|
26643
|
+
const metrics = await this.provider.getMetrics();
|
|
26664
26644
|
if (!metrics) {
|
|
26665
26645
|
return null;
|
|
26666
26646
|
}
|
|
@@ -26672,7 +26652,6 @@ var SysmonWidget = class {
|
|
|
26672
26652
|
return this.enabled && this.provider !== null;
|
|
26673
26653
|
}
|
|
26674
26654
|
async cleanup() {
|
|
26675
|
-
this.cache.clear();
|
|
26676
26655
|
}
|
|
26677
26656
|
setStyle(style = "balanced") {
|
|
26678
26657
|
const fn = sysmonStyles[style];
|
|
@@ -26798,13 +26777,51 @@ async function loadSystemInformation() {
|
|
|
26798
26777
|
}
|
|
26799
26778
|
}
|
|
26800
26779
|
}
|
|
26780
|
+
var NETWORK_STATS_FILE = "/tmp/claude-scope-network-stats.json";
|
|
26781
|
+
function loadNetworkStatsSync() {
|
|
26782
|
+
try {
|
|
26783
|
+
const fs2 = require("node:fs");
|
|
26784
|
+
if (!fs2.existsSync(NETWORK_STATS_FILE)) {
|
|
26785
|
+
return /* @__PURE__ */ new Map();
|
|
26786
|
+
}
|
|
26787
|
+
const text = fs2.readFileSync(NETWORK_STATS_FILE, "utf-8");
|
|
26788
|
+
const data = JSON.parse(text);
|
|
26789
|
+
if (Date.now() - data.lastUpdate > 5 * 60 * 1e3) {
|
|
26790
|
+
return /* @__PURE__ */ new Map();
|
|
26791
|
+
}
|
|
26792
|
+
return new Map(
|
|
26793
|
+
Object.entries(data.stats).map(([key, value]) => [
|
|
26794
|
+
key,
|
|
26795
|
+
{ rx: value.rx, tx: value.tx, time: value.time }
|
|
26796
|
+
])
|
|
26797
|
+
);
|
|
26798
|
+
} catch {
|
|
26799
|
+
return /* @__PURE__ */ new Map();
|
|
26800
|
+
}
|
|
26801
|
+
}
|
|
26802
|
+
function saveNetworkStatsSync(stats) {
|
|
26803
|
+
try {
|
|
26804
|
+
const fs2 = require("node:fs");
|
|
26805
|
+
const data = {
|
|
26806
|
+
stats: Object.fromEntries(stats),
|
|
26807
|
+
lastUpdate: Date.now()
|
|
26808
|
+
};
|
|
26809
|
+
fs2.writeFileSync(NETWORK_STATS_FILE, JSON.stringify(data), "utf-8");
|
|
26810
|
+
} catch {
|
|
26811
|
+
}
|
|
26812
|
+
}
|
|
26801
26813
|
var SystemProvider = class {
|
|
26802
26814
|
intervalId;
|
|
26803
|
-
lastNetworkStats
|
|
26815
|
+
lastNetworkStats;
|
|
26804
26816
|
lastErrorTime = 0;
|
|
26805
26817
|
ERROR_LOG_INTERVAL = 6e4;
|
|
26806
26818
|
// 1 minute
|
|
26807
26819
|
initialized = false;
|
|
26820
|
+
statsLoaded = false;
|
|
26821
|
+
constructor() {
|
|
26822
|
+
this.lastNetworkStats = loadNetworkStatsSync();
|
|
26823
|
+
this.statsLoaded = true;
|
|
26824
|
+
}
|
|
26808
26825
|
async ensureInitialized() {
|
|
26809
26826
|
if (!this.initialized) {
|
|
26810
26827
|
await loadSystemInformation();
|
|
@@ -26823,7 +26840,9 @@ var SystemProvider = class {
|
|
|
26823
26840
|
si.fsSize(),
|
|
26824
26841
|
si.networkStats()
|
|
26825
26842
|
]);
|
|
26826
|
-
const cpuPercent = Math.round(
|
|
26843
|
+
const cpuPercent = Math.round(
|
|
26844
|
+
cpuLoad.cpus && cpuLoad.cpus.length > 0 ? Math.max(...cpuLoad.cpus.map((cpu) => cpu.load)) : cpuLoad.currentLoad ?? 0
|
|
26845
|
+
);
|
|
26827
26846
|
const memUsedGB = mem.active / 1024 / 1024 / 1024;
|
|
26828
26847
|
const memTotalGB = mem.total / 1024 / 1024 / 1024;
|
|
26829
26848
|
const memPercent = Math.round(mem.active / mem.total * 100);
|
|
@@ -26878,16 +26897,27 @@ var SystemProvider = class {
|
|
|
26878
26897
|
}
|
|
26879
26898
|
const ifaceKey = iface.iface;
|
|
26880
26899
|
const last = this.lastNetworkStats.get(ifaceKey);
|
|
26900
|
+
const now = Date.now();
|
|
26881
26901
|
if (!last) {
|
|
26882
|
-
this.lastNetworkStats.set(ifaceKey, {
|
|
26902
|
+
this.lastNetworkStats.set(ifaceKey, {
|
|
26903
|
+
rx: iface.rx_bytes,
|
|
26904
|
+
tx: iface.tx_bytes,
|
|
26905
|
+
time: now
|
|
26906
|
+
});
|
|
26907
|
+
saveNetworkStatsSync(this.lastNetworkStats);
|
|
26883
26908
|
return { rxSec: 0, txSec: 0 };
|
|
26884
26909
|
}
|
|
26885
|
-
const timeDiff =
|
|
26910
|
+
const timeDiff = Math.max(0.1, (now - last.time) / 1e3);
|
|
26886
26911
|
const rxDiff = iface.rx_bytes - last.rx;
|
|
26887
26912
|
const txDiff = iface.tx_bytes - last.tx;
|
|
26888
26913
|
const rx_sec = rxDiff / timeDiff / 1024 / 1024;
|
|
26889
26914
|
const tx_sec = txDiff / timeDiff / 1024 / 1024;
|
|
26890
|
-
this.lastNetworkStats.set(ifaceKey, {
|
|
26915
|
+
this.lastNetworkStats.set(ifaceKey, {
|
|
26916
|
+
rx: iface.rx_bytes,
|
|
26917
|
+
tx: iface.tx_bytes,
|
|
26918
|
+
time: now
|
|
26919
|
+
});
|
|
26920
|
+
saveNetworkStatsSync(this.lastNetworkStats);
|
|
26891
26921
|
return {
|
|
26892
26922
|
rxSec: Math.max(0, Number(rx_sec.toFixed(2))),
|
|
26893
26923
|
txSec: Math.max(0, Number(tx_sec.toFixed(2)))
|