A Pi extension that overrides bash and adds a process tool with OpenClaw-style background execution.
bashauto-backgrounds long commands afteryieldMs(default 10000ms)bash background=truestarts immediately in background- In-memory job tracking (per Pi session)
processactions:list,poll,log,write,kill,clear,remove- Simple KISS/YAGNI implementation (in-memory state, optional PTY via
node-pty)
cd ~/code/pi-process
npm installThen load in Pi:
pi -e ~/code/pi-process/src/index.tsOr add it to ~/.pi/agent/extensions/ (or .pi/extensions/) and use /reload.
Parameters:
command(required)timeout(seconds, optional)yieldMs(milliseconds, default10000)background(boolean, optional)pty(boolean, optional; requires@lydell/node-pty)
Behavior:
- If command completes before
yieldMs, returns foreground output. - Otherwise returns
status=runningandsessionId.
Parameters:
action:list | poll | log | write | kill | clear | removesessionId: required for all actions exceptlistoffset,limit: optional paging forlog(line-based)data,eof: optional stdin input forwrite
Use these in a fresh Pi session after loading the extension. These are end-to-end prompts where the agent should decide when to use bash vs process.
Prompt to agent:
Run `ping -c 20 google.com`. If it backgrounds, keep polling until it completes, then summarize packet loss and avg latency.
What success looks like:
- First
bashcall runs ~10s and backgrounds with a session id. - Agent then calls
process pollrepeatedly. - Final response includes completed ping stats.
Prompt to agent:
Run `uname -a` and show me the result.
What success looks like:
- Agent uses
bashonly. - No
processfollow-up needed.
Prompt to agent:
Start `cat` in background. Write `hello\n` to stdin, poll to verify output, then stop it.
What success looks like:
- Agent gets a running session id from
bash. - Agent uses
process writewithdata(and optionaleof) to send stdin. - Agent confirms echoed output via
process poll. - Agent stops it with
process kill(orremove).
Prompt to agent:
Start `sleep 15 && echo done` in background and do not wait for completion. Just tell me the session id.
What success looks like:
- Agent starts background work and returns session id.
- Agent does not keep polling.
Prompt to agent:
Run `sleep 30` with timeout 3 seconds and report what happened.
What success looks like:
- Command is terminated by timeout.
- Agent reports timeout outcome (foreground or via
processstate).
Prompt to agent:
Run `python3` with pty=true, send `print(2+2)\n` via process write, then send eof=true and report output.
What success looks like:
- bash session starts with PTY and backgrounds/foregrounds as needed
- process write sends input into REPL
- output includes
4
- Jobs are scoped to the current Pi session.
- Jobs are in-memory only and cleaned up after a TTL.
user_bash(!cmd) is intentionally not modified in v1.