@haemmid/pi-processes
Agent-facing background process manager for Pi and pi-web automation workflows.
Package details
Install @haemmid/pi-processes from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:@haemmid/pi-processes- Package
@haemmid/pi-processes- Version
0.10.0- Published
- Jul 3, 2026
- Downloads
- 762/mo · 618/wk
- Author
- haemmid
- License
- MIT
- Types
- extension
- Size
- 336.3 KB
- Dependencies
- 1 dependency · 2 peers
Pi manifest JSON
{
"extensions": [
"./src/index.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
⚙️ pi-processes
Agent-facing process manager for Pi and pi-web automation workflows.
pi-processes lets the agent start, inspect, restart, and stop long-running commands through a managed process tool instead of fragile shell backgrounding.
Designed for use with jmfederico/pi-web.
Why
Agents often waste time or break sessions by running:
npm run dev &nohup pnpm dev ...pkill -f vite- repeated
timeout 10 npm run dev
This package gives the agent a stable process lifecycle instead:
process startprocess listprocess outputprocess restartprocess kill
Table of Contents
- Features
- Install
- Usage
- Configuration
- Tool API
- Killing processes
- Limitations
- Development
- Acknowledgements
- Changelog
- License
Features
- Agent-facing
processtool — start, list, kill, get output, get log paths, and clear managed processes. - File-backed logs — process output is preserved in temp files outside the agent context window.
- Background-command interception — optional guardrails steer the agent away from shell backgrounding,
nohup, and obvious long-running foreground commands, and toward theprocesstool. - Session cleanup — managed processes are terminated when the session shuts down.
- Duplicate name protection — refuses to spawn if a live process with the same name already exists.
- Dedicated
restartaction — safely awaits kill before starting a new process.
Install
Install from npm:
pi install npm:@haemmid/pi-processes
Install from git:
pi install git:github.com/haemmid/pi-processes
Or install from a local checkout:
pi install /path/to/pi-processes
Usage
The process tool is for the agent, not for direct user input. Ask the agent to start or inspect long-running work.
Example user prompts:
Start the dev server with pnpm dev and call it backend-dev.
Show me the latest output from backend-dev.
Stop the backend-dev process.
The agent should start managed processes through the process tool instead of running shell backgrounding such as command &, nohup, disown, or setsid.
Astro / Vite workflow
For Astro/Vite dev servers, ask the agent:
Use the process tool for the Astro dev server.
Ensure `npm run dev -- --host 0.0.0.0` is running as `my-site:astro`.
Use `process output` when you need logs.
Do not restart after ordinary .astro, .ts, or .css edits.
Restart only after package/config/env changes or if the server exits.
Typical tool flow:
process list
process ensure "npm run dev -- --host 0.0.0.0" name="my-site:astro"
process output name="my-site:astro"
process wait url="http://localhost:4321" name="my-site:astro"
process restart "npm run dev -- --host 0.0.0.0" name="my-site:astro"
process kill name="my-site:astro"
Demo
Configuration
Global config lives in:
~/.pi/agent/extensions/process.json
Example:
{
"output": {
"defaultTailLines": 100,
"maxOutputLines": 200
},
"execution": {
"shellPath": "/absolute/path/to/bash"
},
"interception": {
"blockBackgroundCommands": true
}
}
Options:
output.defaultTailLines— default number of lines returned byprocess output.output.maxOutputLines— hard cap forprocess output.execution.shellPath— absolute shell path override used for process startup.interception.blockBackgroundCommands— block shell backgrounding and obvious long-running foreground commands such aspnpm dev,docker compose up,tail -f, orkubectl port-forward, and guide the agent to use theprocesstool instead.
Tool API
The tool is named process.
Actions
| Action | Description |
|---|---|
start |
Start a managed process (refuses if a live process with the same name exists). |
ensure |
Idempotent start: reuse existing process if name+command+cwd match, start new otherwise. |
restart |
Kill existing process and start a new one (safe: await kill → start). |
list |
List managed processes. |
output |
Return a one-off tailed stdout/stderr snapshot. |
logs |
Return file paths for stdout, stderr, and combined logs. |
kill |
Terminate or force-kill a process. |
clear |
Remove finished processes from the manager. |
wait / wait_for |
Poll until a URL responds or a log pattern appears in process output. |
Tool-call examples
process start "pnpm dev" name="backend-dev"
process start "pnpm test --watch" name="tests"
process start "pnpm dev" name="backend-dev" cwd="/path/to/project"
process ensure "pnpm dev" name="backend-dev"
process ensure "pnpm dev" name="backend-dev" cwd="/path/to/project"
process restart "pnpm dev" name="backend-dev"
process restart "pnpm dev" name="backend-dev" force=true
process list
process output id="proc_1"
process output name="backend-dev"
process logs id="proc_1"
process logs name="backend-dev"
process kill id="backend-dev"
process kill name="backend-dev" force=true
process clear
process wait url="http://localhost:4321" name="my-site:astro"
process wait log="Local" name="my-site:astro" timeout_ms=15000
Field rules
start/ensure/restartrequirecommandandname.output,logs,kill, andwaitaccept eitherid(exact process ID) orname(process name).killacceptsforce=trueto sendSIGKILLinstead ofSIGTERM.waitrequires exactly one ofurlorlog;timeout_msdefaults to 10000,interval_msto 500.startrefuses if a live process with the same name is already running.ensurereuses existing process when name+command+cwd match; returns conflict error otherwise.restartsafely kills the existing process (awaited) before starting a new one.restartacceptsforce=trueto sendSIGKILLinstead ofSIGTERM.restartwaits for the old process to exit; if it does not exit within the timeout, the replacement is not started. Useforce=trueor inspect logs.start/ensure/restartacceptcwdto override the working directory (defaults to session cwd).output,logs, andkillreturn an error if bothidandnameare provided.
Killing processes
process kill id="..."sendsSIGTERM.process kill id="..." force=truesendsSIGKILL.- Tool-triggered kills never notify the agent.
Limitations
- Linux/macOS only. The extension disables itself on Windows.
- Session-scoped. Processes are cleaned up on session shutdown.
- Not a system service manager. Does not persist process registry across sessions.
- Manages only tool-started processes. Does not track externally started processes.
- No TUI widgets. Does not provide
/psoverlays or status widgets. - Node.js 18+ required. Native
fetchis used byprocess waitURL checks.
Development
There are no Git hooks installed by this repository. Before committing or opening a PR, consider running:
pnpm typecheck
pnpm lint
pnpm test
After dependency changes, also verify the lockfile with:
pnpm install --frozen-lockfile --ignore-scripts
Acknowledgements
This package started as a fork of mjakl/pi-processes, which was based on aliou/pi-processes. This fork focuses specifically on plain-text, pi-web-friendly, agent-facing process management without TUI widgets or overlays.
Changelog
See CHANGELOG.md.
License
MIT