8 Downloads

README

Shell (jev-guarded) - LM Studio plugin

Gives local models a shell_run tool. Every command is safety-checked before it runs, using TypeSafe's jev model plus a small deterministic deny list. Pipes, redirects, && and $(...) work because commands run through /bin/sh -c.

Setup

  • npm install
  • Give the plugin your jev API key (see below).
  • npm run dev (runs lms dev) to try it in LM Studio, or npm run push to install it.

Providing the jev API key

Either of these works; the plugin setting wins if both are set:

  • Plugin settings (most reliable): in LM Studio open the plugin's settings and paste the key into "Jev API key". The field is masked on screen, but LM Studio stores plugin settings in its own config files, so treat that file as holding your key.
  • Environment variable: export JEV_API_KEY for the LM Studio process. LM Studio started from the Dock or Finder, or a plugin process started by an already-running LM Studio background service, may not inherit variables from ~/.zshrc or from launchctl setenv. If commands are refused with "no jev API key", use the plugin setting instead.

If no key is found, every command is refused with a message saying so; nothing runs unchecked. The key is removed from the environment of the commands the tool runs, so a model cannot read it back with env.

How a command is judged

  • Hard deny (code, never overridden): sudo/su, recursive delete or chmod/chown on /, ~ or *, writes to system paths or ~/.ssh, mkfs, dd to devices, fork bombs, and piping downloads into a shell. It looks inside pipelines, $(...), backticks, sh -c, eval and wrappers like env/nohup.
  • Jev (one request, six parallel questions): five yes/no hazards (destroys data, touches the system, network exfiltration, privilege or persistence, obfuscation) plus a 0-3 severity score.
  • Thresholds (settings): a hazard at or above the block threshold, or severity at or above the severity level, is refused as unsafe. A hazard at or above the uncertain threshold is refused as unconfirmed. If jev cannot be reached, the command is refused.

Refusals come back to the model as Blocked: ... text that tells it to hand off to you.

Known limits

  • The hard-deny layer is best-effort pattern matching, not a sandbox. It will not catch everything (for example xargs -I{} rm -rf {}); jev is the second line of defense.
  • Jev is a probabilistic model. Tune thresholds on your own commands with npm run calibrate.
  • In the first calibration run (defaults 0.70 / 0.35 / 2), 20 of 20 dangerous commands were refused and 18 of 20 safe commands passed. The two refusals were commands that overwrite an existing file (echo hello > notes.txt, cp config.example.json config.json). Raise the thresholds if that is too strict.
  • macOS and Linux only (uses /bin/sh and process groups).

Tests

npm test runs the offline unit tests. npm run calibrate calls the real jev API (needs JEV_API_KEY).