@yusukeshib/pi-babysit 0.3.13 → 0.3.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -18
- package/index.ts +986 -117
- package/package.json +1 -1
- package/rpc-stream-proxy.mjs +70 -10
- package/self-reap.ts +23 -10
package/README.md
CHANGED
|
@@ -56,10 +56,10 @@ programs** (installers, wizards, REPLs): type with `babysit_send`
|
|
|
56
56
|
|
|
57
57
|
| Tool | What it does |
|
|
58
58
|
| ---- | ------------ |
|
|
59
|
-
| `babysit_run` | Run any command (`command`, optional `name`/`pty`/`timeout`/`idleTimeout`/`retryOnWorkerDeath`)
|
|
60
|
-
| `babysit_check` |
|
|
59
|
+
| `babysit_run` | Run any command (`command`, optional `name`/`pty`/`timeout`/`idleTimeout`/`retryOnWorkerDeath`/`notificationGroup`). Set `foreground: true` when the next step needs the result in the same tool call, avoiding a separate `babysit_wait` turn. Or start a named subagent (`profile: "subagent"`, `task`, optional `name`/`agent`/`model`/`tools`/`maxDepth` and `maxCost`/`maxTurns`/`maxToolCalls`/`maxUsageTokens` budgets). `maxDepth` defaults to 1 and can only be set by the top-level caller. Quick commands return inline; longer ones continue in the background |
|
|
60
|
+
| `babysit_check` | Without an id, list running sessions by default (`state: "all"` includes history; `state`/`kind` filters are available). With an id, inspect one session, tail bounded recent output, or search its raw log with `pattern`; `screen: true` captures TUIs and subagents otherwise show structured live progress |
|
|
61
61
|
| `babysit_send` | Process: type `text` / press `keys` into the PTY. Subagent: steer mid-run, or send a follow-up task when idle (`mode: auto/steer/task`) |
|
|
62
|
-
| `babysit_wait` | Block until done: process exit (or `expect: "regex"` readiness marker), subagent task completion. Multi-wait: `ids` + `mode: "any"\|"all"` |
|
|
62
|
+
| `babysit_wait` | Block until done: process exit (or `expect: "regex"` readiness marker), subagent task completion. Multi-wait: up to 32 unique `ids` + `mode: "any"\|"all"` |
|
|
63
63
|
| `babysit_kill` | Terminate a session, verify terminal state, then suppress the exit notification |
|
|
64
64
|
|
|
65
65
|
The built-in `bash` tool is removed from the active tool set so the model does
|
|
@@ -73,6 +73,7 @@ re-enables `bash`, including shell backgrounding (`… &`, `nohup`, `setsid`,
|
|
|
73
73
|
| Command | What it does |
|
|
74
74
|
| ------- | ------------ |
|
|
75
75
|
| `/babysit` | Arrow-key picker over all sessions. Renders an **inline snapshot** (no tmux): running **process** → current rendered screen + recent output + a copy-paste `babysit attach` take-over hint (detach `Ctrl-\ Ctrl-\`); running **subagent** → read-only progress (RPC stdin stays untouchable); finished → summary. Re-run `/babysit` to refresh |
|
|
76
|
+
| `/babysit gc [days]` | Preview and confirm deletion of old Pi-session roots (default 14 days). Active leases, live supervisor/child PIDs, unknown states, the current root, and recent roots are retained; deletion uses a GC lock and atomic rename |
|
|
76
77
|
|
|
77
78
|
A minimal widget above the editor shows live counts
|
|
78
79
|
(`N processes · M subagents working · K idle`).
|
|
@@ -94,18 +95,24 @@ babysit_check { id: "cargo-test", lines: 50 }
|
|
|
94
95
|
babysit_check { id: "cargo-test", pattern: "FAIL|ERROR", lines: 50 }
|
|
95
96
|
```
|
|
96
97
|
|
|
97
|
-
Tail and search results are capped at 200 lines, and
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
98
|
+
Tail and search results are capped at 200 lines, and ordinary returned tool
|
|
99
|
+
results (including lifecycle headers) are clipped to 8 KB. A single explicitly
|
|
100
|
+
waited-for subagent answer may use up to 24 KB; multi-session wait results default
|
|
101
|
+
to the 8 KB inline-output limit and can opt into a larger cap with `maxBytes`.
|
|
102
|
+
Pattern search returns the latest matching lines with line numbers. Prefer a
|
|
103
|
+
targeted pattern over a broad tail, and do not read a potentially large log file
|
|
104
|
+
in full. Subagent crashes return structured errors plus the full log path, never
|
|
105
|
+
a raw RPC JSON tail.
|
|
106
|
+
|
|
107
|
+
Subagent logs compact Pi's streaming `message_update` events before they are
|
|
108
|
+
recorded. Pi repeats the complete growing assistant message and partial snapshot
|
|
109
|
+
on every token; pi-babysit retains only the incremental delta. Compact RPC
|
|
110
|
+
logging is the default and also removes duplicate payloads from `message_start`,
|
|
111
|
+
`turn_end`, successful `tool_execution_end`, and `agent_end`, while preserving
|
|
112
|
+
authoritative `message_end`, failures, responses, and errors. Parked-process
|
|
113
|
+
state is materialized as a small boolean so completion detection is unchanged.
|
|
114
|
+
Set `PI_BABYSIT_RPC_LOG_MODE=standard` only when legacy lifecycle payloads are
|
|
115
|
+
needed for debugging. Live `/babysit` and attach views render either format.
|
|
109
116
|
|
|
110
117
|
All shell commands, including `pwd` and Git, go through `babysit_run`. Bundle
|
|
111
118
|
closely related tiny observations when doing so safely reduces tool turns.
|
|
@@ -127,7 +134,11 @@ because blindly rerunning an arbitrary command can duplicate side effects.
|
|
|
127
134
|
`pi.sendMessage(…, { triggerTurn: true, deliverAs: "steer" })` containing every
|
|
128
135
|
deliverable exit observed in that poll (deduped via `meta/<id>.json`). Waiting
|
|
129
136
|
for idleness prevents an immediately-following `babysit_wait` from racing the
|
|
130
|
-
poller and receiving a duplicate completion.
|
|
137
|
+
poller and receiving a duplicate completion. Background process calls emitted
|
|
138
|
+
together in one assistant message automatically share a notification group;
|
|
139
|
+
an explicit `notificationGroup` overrides this. Group members wait for every
|
|
140
|
+
currently running member to stop and then share one notification even when
|
|
141
|
+
their exits span multiple polls.
|
|
131
142
|
`babysit_kill` and an exit already reported by `babysit_wait` suppress the
|
|
132
143
|
notification.
|
|
133
144
|
- **Subagent**: `babysit_wait` blocks on `babysit expect '"type":"agent_settled"'`.
|
|
@@ -143,7 +154,13 @@ because blindly rerunning an arbitrary command can duplicate side effects.
|
|
|
143
154
|
|
|
144
155
|
Subagents load `self-reap.ts`, which exits an idle finished subagent after a
|
|
145
156
|
grace window (`PI_BABYSIT_REAP_AFTER`, default 120s) using the same parked-turn
|
|
146
|
-
rule, so a subagent waiting on a long build is never false-killed.
|
|
157
|
+
rule, so a subagent waiting on a long build is never false-killed. Give bounded
|
|
158
|
+
recon/review tasks at least one cost, turn, tool-call, or token budget; omit
|
|
159
|
+
budgets only for intentionally open-ended work. Optional task budgets are
|
|
160
|
+
checked by the parent poller. On the first exceeded limit the worker
|
|
161
|
+
is steered to stop using tools and return its best answer; if it remains active
|
|
162
|
+
after `PI_BABYSIT_BUDGET_GRACE`, termination is verified before the task is
|
|
163
|
+
marked budget-killed. Usage shown by check/wait is cumulative for the task.
|
|
147
164
|
|
|
148
165
|
## Environment overrides
|
|
149
166
|
|
|
@@ -153,9 +170,13 @@ rule, so a subagent waiting on a long build is never false-killed.
|
|
|
153
170
|
| `PI_BABYSIT_BIN` | `pi` | agent binary for subagents |
|
|
154
171
|
| `PI_BABYSIT_CLI` | `babysit` | babysit binary |
|
|
155
172
|
| `PI_BABYSIT_VIEW_CMD` | bundled `format-stream.mjs` | live-attach pretty printer for subagent JSONL (`""` disables) |
|
|
173
|
+
| `PI_BABYSIT_QUICK_GRACE` | `2s` | interactive process grace before a still-running command is returned as background work; use `foreground: true` to wait explicitly |
|
|
156
174
|
| `PI_BABYSIT_REAP_AFTER` | `120s` | idle grace before a finished subagent self-exits (`off`/`none`/`0` disables) |
|
|
175
|
+
| `PI_BABYSIT_BUDGET_GRACE` | `30s` | grace after a subagent budget is exceeded before verified termination |
|
|
176
|
+
| `PI_BABYSIT_RPC_LOG_MODE` | `compact` | `compact` removes duplicate RPC lifecycle payloads; `standard` opts into legacy payloads |
|
|
177
|
+
| `PI_BABYSIT_RETENTION_DAYS` | unset | when set to a positive number, remove safe terminal roots older than this at session startup |
|
|
157
178
|
| `PI_BABYSIT_TAIL_MAX_BYTES` | `8000` | cap for explicit log tails/screens returned by `babysit_check` |
|
|
158
|
-
| `PI_BABYSIT_INLINE_OUTPUT_MAX_BYTES` | `8000` | cap for complete output
|
|
179
|
+
| `PI_BABYSIT_INLINE_OUTPUT_MAX_BYTES` | `8000` | cap for complete process output and aggregate multi-wait results |
|
|
159
180
|
| `PI_BABYSIT_NOTIFY_OUTPUT_MAX_BYTES` | `2000` | per-process output cap for unsolicited completion notifications (`0` omits all output) |
|
|
160
181
|
| `PI_BABYSIT_NOTIFY_COMMAND_MAX_BYTES` | `240` | cap for each command preview in completion notifications |
|
|
161
182
|
| `PI_BABYSIT_NOTIFY_BATCH_MAX_BYTES` | `8000` | hard cap for one aggregated completion notification |
|