# Process Manager

> Monitor running processes with live CPU/RAM usage and end tasks - works on Windows, macOS and Linux

| | |
|---|---|
| Version | 1.0.0 |
| Category | Monitoring |
| Permissions | shell.exec, process.control |

# Process Manager

Live view of the processes running on the host machine — CPU %, memory, and an "End task" button,
like the OS task manager. Works on Windows, macOS and Linux, in the desktop app and in the Web
Dashboard (where it still reports the machine hosting the app, not the browser's device).

**Type:** `exec` (no backend) — the widget shells out through `window['kazuo-ai'].localExec()`.
See `.claude/skills/kazuo-create-plugin/references/plugin-examples.md`.

## Files

- `manifest.json` — metadata, `defaultSettings`, `defaultWidgetConfig`, `platforms`
  (`win`/`mac`/`linux`/`webapp`)
- `widget.html` / `js/widget.js` / `css/widget.css` — CPU + memory meters, process table, settings overlay
- `settings.html` / `js/settings.js` / `css/settings.css` — same two fields as the widget overlay
  (intentionally duplicated), used by the Plugin Manager screen and the pop-out window
- `locales/en.json5` / `locales/vi.json5` — UI strings (`widget.*` / `settings.*`)

## How the numbers are collected

`localExec` runs on the machine hosting the app in BOTH runtimes (the Web Dashboard forwards it over
its WebSocket to the same `child_process.exec`), so the widget must not infer the OS from
`navigator.userAgent` — a phone browser viewing a Windows host would guess wrong. It asks the host
instead: `echo %OS%` prints `Windows_NT` under cmd.exe and stays literal under a POSIX shell. Probed
once per widget load, then cached.

One shell command per refresh, parsed in `js/widget.js`:

| OS | Command | Notes |
|----|---------|-------|
| Windows | `powershell -EncodedCommand …` (`Get-Process` + `Win32_OperatingSystem`) | base64 UTF-16LE avoids cmd.exe quoting problems; returns JSON |
| macOS / Linux | `getconf _NPROCESSORS_ONLN`, `/proc/meminfo` or `sysctl`+`vm_stat`, `ps -axo pid=,rss=,time=,args=` | per-OS parts fail silently on the other OS, so one string covers both |

Both probes report **cumulative** CPU seconds per process, so the percentage is a delta between two
consecutive samples: `(cpuNow - cpuBefore) / (elapsed × cores) × 100`. The first sample after opening
the widget therefore shows `--` in the CPU column.

"End task" runs `taskkill /F /PID …` on Windows and `kill -9 …` elsewhere, after the shared
`confirm()` modal. Killing a process owned by another user needs elevation; the error is surfaced in
the toolbar status line.

## Default settings

- `refreshInterval` — default `5` (seconds; `0` disables auto-refresh)
- `groupByName` — default `false` (merge processes sharing a name into one row, summing CPU/RAM)

## Test

Open Kazuo AI → Plugin Manager — this plugin appears automatically (the host scans `plugins-library/`
on its own, no registration needed) → Install → Enable.
