@pulso/companion 0.3.1 → 0.3.2
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 +19 -30
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2292,18 +2292,20 @@ print(text)`;
|
|
|
2292
2292
|
}
|
|
2293
2293
|
// ── NEW: Process Management ─────────────────────────────
|
|
2294
2294
|
case "sys_process_list": {
|
|
2295
|
+
const sortBy = params.sort_by || "cpu";
|
|
2296
|
+
const limit = Math.min(Number(params.limit) || 15, 30);
|
|
2297
|
+
const sortCol = sortBy === "mem" ? "-k4" : "-k3";
|
|
2295
2298
|
const result = await runShell(
|
|
2296
|
-
`ps
|
|
2299
|
+
`ps -Ae -o user,pid,%cpu,%mem,command | sort -nr ${sortCol} | head -${limit}`
|
|
2297
2300
|
);
|
|
2298
|
-
const
|
|
2299
|
-
|
|
2300
|
-
const [user, pid, cpu, mem, ...cmdParts] = l.split("|");
|
|
2301
|
+
const processes = result.trim().split("\n").filter((l) => l.trim()).map((l) => {
|
|
2302
|
+
const parts = l.trim().split(/\s+/);
|
|
2301
2303
|
return {
|
|
2302
|
-
user:
|
|
2303
|
-
pid:
|
|
2304
|
-
cpu:
|
|
2305
|
-
mem:
|
|
2306
|
-
command:
|
|
2304
|
+
user: parts[0],
|
|
2305
|
+
pid: parts[1],
|
|
2306
|
+
cpu: parts[2] + "%",
|
|
2307
|
+
mem: parts[3] + "%",
|
|
2308
|
+
command: parts.slice(4).join(" ").slice(0, 80)
|
|
2307
2309
|
};
|
|
2308
2310
|
});
|
|
2309
2311
|
return { success: true, data: { processes } };
|
|
@@ -2408,30 +2410,17 @@ print(text)`;
|
|
|
2408
2410
|
case "sys_audio_devices": {
|
|
2409
2411
|
const audioAction = params.action || "list";
|
|
2410
2412
|
if (audioAction === "list") {
|
|
2411
|
-
const
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
end repeat
|
|
2418
|
-
end tell
|
|
2419
|
-
return output`);
|
|
2420
|
-
if (!result.trim()) {
|
|
2421
|
-
const spResult = await runShell(
|
|
2422
|
-
`system_profiler SPAudioDataType 2>/dev/null | grep "Device Name" | sed 's/.*: //'`
|
|
2423
|
-
);
|
|
2424
|
-
return {
|
|
2425
|
-
success: true,
|
|
2426
|
-
data: {
|
|
2427
|
-
devices: spResult.trim().split("\n").filter((d) => d)
|
|
2428
|
-
}
|
|
2429
|
-
};
|
|
2430
|
-
}
|
|
2413
|
+
const spResult = await runShell(
|
|
2414
|
+
`system_profiler SPAudioDataType 2>/dev/null | grep -E "Device Name|Output Source" | sed 's/.*: //'`
|
|
2415
|
+
);
|
|
2416
|
+
const currentOut = await runShell(
|
|
2417
|
+
`osascript -e 'output volume of (get volume settings)'`
|
|
2418
|
+
).catch(() => "");
|
|
2431
2419
|
return {
|
|
2432
2420
|
success: true,
|
|
2433
2421
|
data: {
|
|
2434
|
-
devices:
|
|
2422
|
+
devices: spResult.trim().split("\n").filter((d) => d),
|
|
2423
|
+
currentVolume: currentOut.trim()
|
|
2435
2424
|
}
|
|
2436
2425
|
};
|
|
2437
2426
|
} else if (audioAction === "switch") {
|