@yusukeshib/pi-babysit 0.3.17 → 0.5.0
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 +30 -18
- package/index.ts +703 -163
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@ reachable from anywhere (`~/.pi-babysit/<pi-session-id>/`). Two kinds:
|
|
|
33
33
|
| kind | started by | completion | on completion |
|
|
34
34
|
| ---- | ---------- | ---------- | ------------- |
|
|
35
35
|
| **process** | `babysit_run { command }` | process **exit** | automatic notification message (`triggerTurn`), batched for all exits observed in the same poll — the agent may end its turn after starting and is resumed on exit, same contract as the old `process` tool |
|
|
36
|
-
| **subagent** | `babysit_run { profile: "subagent", task }` | `agent_settled` in the RPC event stream (
|
|
36
|
+
| **subagent** | `babysit_run { profile: "subagent", task }` | `agent_settled` in the RPC event stream (worker remains reusable during its idle grace) | `foreground: true` returns the answer and nested usage in the same tool call; background workers must be collected with `babysit_wait` before the parent finishes, and remain reusable until self-reap |
|
|
37
37
|
|
|
38
38
|
The **profile is a tool parameter, not a separate tool set**: domain knowledge
|
|
39
39
|
(RPC bookkeeping, per-task byte offsets, parked-turn detection, PTY-safe
|
|
@@ -56,9 +56,9 @@ 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`/`notificationGroup`). Set `foreground: true`
|
|
60
|
-
| `babysit_check` | Without an id, list
|
|
61
|
-
| `babysit_send` | Process: type `text` / press `keys` into the PTY. Subagent: steer mid-run, or send a follow-up task when
|
|
59
|
+
| `babysit_run` | Run any command (`command`, optional `name`/`pty`/`timeout`/`idleTimeout`/`retryOnWorkerDeath`/`notificationGroup`). Set `foreground: true` for one process or subagent whose result is needed in the same tool call; use `returnPattern`/`returnLines`/`maxBytes` to keep noisy process output bounded. Or start a named background subagent (`profile: "subagent"`, `task`, optional `name`/`agent`/`model`/`tools`/`maxDepth` and budget fields), then always collect it with `babysit_wait`. `maxDepth` defaults to 1. Quick commands return inline; longer process runs notify in the background |
|
|
60
|
+
| `babysit_check` | Without an id, list sessions with state/kind filters. With an id, inspect bounded output, search with `pattern`, or capture a TUI with `screen: true`; `maxBytes` overrides the 4 KB default up to 24 KB |
|
|
61
|
+
| `babysit_send` | Process: type `text` / press `keys` into the PTY. Subagent: steer mid-run, or send a follow-up task when confirmed settled (`mode: auto/steer/task`); explicit task mode rejects busy, parked, or unknown state |
|
|
62
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
|
|
|
@@ -95,10 +95,12 @@ babysit_check { id: "cargo-test", lines: 50 }
|
|
|
95
95
|
babysit_check { id: "cargo-test", pattern: "FAIL|ERROR", lines: 50 }
|
|
96
96
|
```
|
|
97
97
|
|
|
98
|
-
Tail and search results are capped at 200 lines
|
|
99
|
-
|
|
100
|
-
waited-for subagent answer may use up to 24 KB;
|
|
101
|
-
to the 8 KB inline-output limit and can opt
|
|
98
|
+
Tail and search results are capped at 200 lines and default to a 4 KB total
|
|
99
|
+
result cap; `babysit_check.maxBytes` can raise or lower that per call (up to
|
|
100
|
+
24 KB). A single explicitly waited-for subagent answer may use up to 24 KB;
|
|
101
|
+
multi-session wait results default to the 8 KB inline-output limit and can opt
|
|
102
|
+
into a larger cap with `maxBytes`. Foreground runs can apply `returnPattern` or
|
|
103
|
+
`returnLines` before output enters context, avoiding a follow-up check turn.
|
|
102
104
|
Pattern search returns the latest matching lines with line numbers. Prefer a
|
|
103
105
|
targeted pattern over a broad tail, and do not read a potentially large log file
|
|
104
106
|
in full. Subagent crashes return structured errors plus the full log path, never
|
|
@@ -115,7 +117,12 @@ Set `PI_BABYSIT_RPC_LOG_MODE=standard` only when legacy lifecycle payloads are
|
|
|
115
117
|
needed for debugging. Live `/babysit` and attach views render either format.
|
|
116
118
|
|
|
117
119
|
All shell commands, including `pwd` and Git, go through `babysit_run`. Bundle
|
|
118
|
-
closely related tiny observations when doing so safely reduces tool turns.
|
|
120
|
+
closely related tiny observations when doing so safely reduces tool turns. For
|
|
121
|
+
parallel checks, do not issue sibling `foreground: true` calls: start them with
|
|
122
|
+
`continueAfterStart: true` and collect them in one multi-session `babysit_wait`.
|
|
123
|
+
During fix loops, prefer targeted checks after each edit and one full validation
|
|
124
|
+
suite at the end. Background subagents must likewise be collected before the
|
|
125
|
+
parent task finishes so their answer and nested usage are not lost.
|
|
119
126
|
Set `PI_BABYSIT_ALLOW_BASH=1` only as an explicit emergency escape hatch.
|
|
120
127
|
|
|
121
128
|
## Unexpected worker loss
|
|
@@ -141,7 +148,10 @@ because blindly rerunning an arbitrary command can duplicate side effects.
|
|
|
141
148
|
their exits span multiple polls.
|
|
142
149
|
`babysit_kill` and an exit already reported by `babysit_wait` suppress the
|
|
143
150
|
notification.
|
|
144
|
-
- **Subagent**: `babysit_wait` blocks on
|
|
151
|
+
- **Subagent**: `foreground: true` or `babysit_wait` blocks on
|
|
152
|
+
`babysit expect '"type":"agent_settled"'`. A background task that settles or
|
|
153
|
+
exits before it is collected emits one ready-to-collect reminder; the parent
|
|
154
|
+
must still call `babysit_wait` so the answer and nested usage are persisted.
|
|
145
155
|
Unlike `agent_end`, `agent_settled` cannot precede an automatic retry,
|
|
146
156
|
compaction retry, or queued continuation. A settled run containing a
|
|
147
157
|
**parked** toolResult — a `babysit_run { command }` result carrying the
|
|
@@ -157,12 +167,14 @@ grace window (`PI_BABYSIT_REAP_AFTER`, default 120s) using the same parked-turn
|
|
|
157
167
|
rule, so a subagent waiting on a long build is never false-killed. Give bounded
|
|
158
168
|
recon/review tasks at least one cost, turn, tool-call, or token budget; omit
|
|
159
169
|
budgets only for intentionally open-ended work. Optional task budgets are
|
|
160
|
-
observed by the parent poller.
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
`PI_BABYSIT_BUDGET_GRACE`, termination is verified before
|
|
165
|
-
budget-killed. Usage shown by check/wait is cumulative
|
|
170
|
+
observed by the parent poller. At 80% of a limit the worker is steered to wrap
|
|
171
|
+
up; reaching the configured limit starts the hard grace immediately, even if a
|
|
172
|
+
wedged worker cannot accept steering. An in-flight model call or parallel tool
|
|
173
|
+
batch can still overshoot before the next poll. If the worker remains active
|
|
174
|
+
after `PI_BABYSIT_BUDGET_GRACE`, termination is verified before it is marked
|
|
175
|
+
budget-killed. Usage shown by check/wait is cumulative, and the first terminal
|
|
176
|
+
wait for each task charges that nested usage exactly once to the parent Pi
|
|
177
|
+
session totals.
|
|
166
178
|
|
|
167
179
|
## Environment overrides
|
|
168
180
|
|
|
@@ -176,8 +188,8 @@ budget-killed. Usage shown by check/wait is cumulative for the task.
|
|
|
176
188
|
| `PI_BABYSIT_REAP_AFTER` | `120s` | idle grace before a finished subagent self-exits (`off`/`none`/`0` disables) |
|
|
177
189
|
| `PI_BABYSIT_BUDGET_GRACE` | `90s` | grace after a subagent budget is exceeded before verified termination |
|
|
178
190
|
| `PI_BABYSIT_RPC_LOG_MODE` | `compact` | `compact` removes duplicate RPC lifecycle payloads; `standard` opts into legacy payloads |
|
|
179
|
-
| `PI_BABYSIT_RETENTION_DAYS` |
|
|
180
|
-
| `PI_BABYSIT_TAIL_MAX_BYTES` | `
|
|
191
|
+
| `PI_BABYSIT_RETENTION_DAYS` | `3` | at most once per day, remove safe terminal roots older than this; set `0` to disable automatic retention |
|
|
192
|
+
| `PI_BABYSIT_TAIL_MAX_BYTES` | `4000` | default cap for explicit log tails/screens returned by `babysit_check`; override per call with `maxBytes` |
|
|
181
193
|
| `PI_BABYSIT_INLINE_OUTPUT_MAX_BYTES` | `8000` | cap for complete process output and aggregate multi-wait results |
|
|
182
194
|
| `PI_BABYSIT_NOTIFY_OUTPUT_MAX_BYTES` | `2000` | per-process output cap for unsolicited completion notifications (`0` omits all output) |
|
|
183
195
|
| `PI_BABYSIT_NOTIFY_COMMAND_MAX_BYTES` | `240` | cap for each command preview in completion notifications |
|