mbagley's profile picture
mbagley

local-shell-access

Public

722 Downloads

3 stars

2 forks

README

mbagley/local-shell-access

LM Studio plugin that lets the model run commands in the user's local shell. Companion to mbagley/agent-browser: where that plugin gives a model a browser it can drive, this one gives it a terminal.

This is a power tool. Any command the model emits runs as your user, on your machine, with your permissions — including destructive ones (rm -rf, network egress, package installs, git pushes, …). Only enable it for models you trust, and prefer running with a model and prompt that asks before doing anything irreversible.

Prerequisites

  • LM Studio with plugins enabled.
  • A POSIX shell available on the system (/bin/zsh, /bin/bash, /bin/sh) on macOS / Linux, or cmd.exe / powershell.exe on Windows.

LM Studio's plugin runtime starts with a stripped PATH and does not inherit the user's interactive shell environment. To make commands behave the same as they would in your terminal, this plugin auto-detects your shell (from $SHELL, falling back to your login shell in /etc/passwd, then to /bin/zsh / /bin/bash) and invokes it with -l -c by default so your login profile is sourced. That is what restores your real PATH, version-manager hooks, etc. Aliases defined only in interactive rc files (.zshrc, .bashrc) are typically not available — put PATH and env in .zprofile / .bash_profile if you need them.

Develop

npm install
npm run dev          # lms dev — auto-rebuilds and reloads the plugin in LM Studio
npm run test:verify  # build + integration test against the local shell

Publish

npm run push  # lms push

Tools

ToolPurpose
shell_execRun a command. Supports pipes, redirects, &&, globs, command substitution, optional cwd / env / timeout_ms overrides. Returns exit code, stdout, stderr.
shell_infoReport the resolved shell binary, args template, default cwd, user, hostname, and platform. Useful as a first orienting call.

Each shell_exec call spawns a fresh shell process — there is no persistent session, so cd and exported vars do not carry over between calls. Chain steps in one command (cd /tmp && ls) or pass cwd per-call.

Configuration

FieldDefaultNotes
shell(auto-detect)Absolute path to a shell binary. Blank = auto.
loginShelltruePass -l so the login profile is sourced. Disable for faster startup if your environment doesn't depend on profile-sourced PATH.
defaultCwd(home)Working directory when the model doesn't specify one.
timeoutMs60000Default per-command timeout. SIGTERM, then SIGKILL after a 2s grace.
maxOutputBytes262144Per-stream cap on captured stdout/stderr. Output past this is truncated with a marker.