@vtstech/pi-status 1.1.8 → 1.2.0

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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/status.js +10 -11
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtstech/pi-status",
3
- "version": "1.1.8",
3
+ "version": "1.2.0",
4
4
  "description": "System monitor / status bar extension for Pi Coding Agent",
5
5
  "main": "status.js",
6
6
  "keywords": ["pi-extensions"],
@@ -14,7 +14,7 @@
14
14
  "url": "https://github.com/VTSTech/pi-coding-agent"
15
15
  },
16
16
  "dependencies": {
17
- "@vtstech/pi-shared": "1.1.8"
17
+ "@vtstech/pi-shared": "1.2.0"
18
18
  },
19
19
  "peerDependencies": {
20
20
  "@mariozechner/pi-coding-agent": ">=0.66"
package/status.js CHANGED
@@ -29,7 +29,7 @@ function status_temp_default(pi) {
29
29
  let footerModel = "";
30
30
  let footerNativeCtx = "";
31
31
  let nativeCtxModel = "";
32
- let isLocalProvider = true;
32
+ let isLocalProvider2 = true;
33
33
  let versionsText = "";
34
34
  let cachedPromptText = null;
35
35
  let securityFlashTool = "";
@@ -68,13 +68,13 @@ function status_temp_default(pi) {
68
68
  const used = total - os.freemem();
69
69
  return { used, total };
70
70
  }
71
- function getSwap() {
71
+ async function getSwap() {
72
72
  if (process.platform !== "linux") {
73
73
  debugLog("status", "swap detection skipped: not a Linux platform");
74
74
  return null;
75
75
  }
76
76
  try {
77
- const out = fs.readFileSync("/proc/meminfo", "utf-8");
77
+ const out = await fs.promises.readFile("/proc/meminfo", "utf-8");
78
78
  const swapTotal2 = Number(out.match(/SwapTotal:\s+(\d+)/)?.[1]) * 1024;
79
79
  const swapFree = Number(out.match(/SwapFree:\s+(\d+)/)?.[1]) * 1024;
80
80
  if (swapTotal2 > 0) return { used: swapTotal2 - swapFree, total: swapTotal2 };
@@ -84,16 +84,15 @@ function status_temp_default(pi) {
84
84
  return null;
85
85
  }
86
86
  function detectLocalProvider(modelsJson) {
87
- const isLocalUrl = (url) => url.includes("localhost") || url.includes("127.0.0.1") || url.includes("0.0.0.0");
88
87
  try {
89
88
  const ctxUrl = currentCtx?.provider?.baseUrl || currentCtx?.provider?.url || "";
90
- if (ctxUrl) return isLocalUrl(ctxUrl);
89
+ if (ctxUrl) return isLocalProvider2(ctxUrl);
91
90
  const modelId = footerModel || "";
92
91
  if (modelsJson && modelId) {
93
92
  for (const provider of Object.values(modelsJson.providers || {})) {
94
93
  const url = provider.baseUrl || "";
95
94
  if ((provider.models || []).some((m) => m.id === modelId)) {
96
- return isLocalUrl(url);
95
+ return isLocalProvider2(url);
97
96
  }
98
97
  }
99
98
  }
@@ -139,11 +138,11 @@ function status_temp_default(pi) {
139
138
  const theme = ctxTheme;
140
139
  const dim2 = (s) => theme?.fg?.("dim", s) ?? s;
141
140
  const green2 = (s) => theme?.fg?.("success", s) ?? s;
142
- ctxUi.setStatus("status-cpu", isLocalProvider ? `${dim2("CPU")} ${green2(cpuUsage.toFixed(0) + "%")}` : void 0);
143
- ctxUi.setStatus("status-ram", isLocalProvider ? `${dim2("RAM")} ${green2(fmtBytes(memUsed) + "/" + fmtBytes(memTotal))}` : void 0);
141
+ ctxUi.setStatus("status-cpu", isLocalProvider2 ? `${dim2("CPU")} ${green2(cpuUsage.toFixed(0) + "%")}` : void 0);
142
+ ctxUi.setStatus("status-ram", isLocalProvider2 ? `${dim2("RAM")} ${green2(fmtBytes(memUsed) + "/" + fmtBytes(memTotal))}` : void 0);
144
143
  ctxUi.setStatus(
145
144
  "status-swap",
146
- isLocalProvider && hasSwap && swapUsed > 0 ? `${dim2("Swap")} ${green2(fmtBytes(swapUsed) + "/" + fmtBytes(swapTotal))}` : void 0
145
+ isLocalProvider2 && hasSwap && swapUsed > 0 ? `${dim2("Swap")} ${green2(fmtBytes(swapUsed) + "/" + fmtBytes(swapTotal))}` : void 0
147
146
  );
148
147
  const ctxParts = [];
149
148
  if (footerNativeCtx) ctxParts.push(`${dim2("CtxMax:")}${green2(footerNativeCtx)}`);
@@ -185,7 +184,7 @@ function status_temp_default(pi) {
185
184
  ctxUi.setStatus("status-versions", `${dim2("pi:")}${green2(versionsText.replace(/^pi:/, ""))}`);
186
185
  }
187
186
  }
188
- function updateMetrics() {
187
+ async function updateMetrics() {
189
188
  cpuUsage = getCpuUsage();
190
189
  const mem = getMem();
191
190
  memUsed = mem.used;
@@ -199,7 +198,7 @@ function status_temp_default(pi) {
199
198
  hasSwap = false;
200
199
  }
201
200
  const modelsJson = readModelsJson();
202
- isLocalProvider = modelsJson ? detectLocalProvider(modelsJson) : false;
201
+ isLocalProvider2 = modelsJson ? detectLocalProvider(modelsJson) : false;
203
202
  if (currentCtx) {
204
203
  footerModel = currentCtx.model?.id || "";
205
204
  const modelId = currentCtx.model?.id || "";