@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.
Files changed (2) hide show
  1. package/dist/index.js +19 -30
  2. 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 aux --sort=-%mem | head -25 | awk '{printf "%s|%s|%s|%s|", $1, $2, $3, $4; for(i=11;i<=NF;i++) printf "%s ", $i; print ""}'`
2299
+ `ps -Ae -o user,pid,%cpu,%mem,command | sort -nr ${sortCol} | head -${limit}`
2297
2300
  );
2298
- const lines = result.trim().split("\n").slice(1);
2299
- const processes = lines.map((l) => {
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: user?.trim(),
2303
- pid: pid?.trim(),
2304
- cpu: cpu?.trim() + "%",
2305
- mem: mem?.trim() + "%",
2306
- command: cmdParts.join("|").trim()
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 result = await runAppleScript(`
2412
- set output to ""
2413
- tell application "System Events"
2414
- set audioOut to name of every audio output device
2415
- repeat with d in audioOut
2416
- set output to output & d & linefeed
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: result.trim().split("\n").filter((d) => d)
2422
+ devices: spResult.trim().split("\n").filter((d) => d),
2423
+ currentVolume: currentOut.trim()
2435
2424
  }
2436
2425
  };
2437
2426
  } else if (audioAction === "switch") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pulso/companion",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "type": "module",
5
5
  "description": "Pulso Companion — gives your AI agent real control over your computer",
6
6
  "bin": {