@yusukeshib/pi-babysit 0.2.1 → 0.2.3
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/index.ts +27 -6
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -1197,6 +1197,8 @@ export default function (pi: ExtensionAPI) {
|
|
|
1197
1197
|
label: "Babysit: run",
|
|
1198
1198
|
description:
|
|
1199
1199
|
"Start a supervised background session under babysit (NON-BLOCKING; returns a session id). " +
|
|
1200
|
+
"In non-interactive mode (`pi -p`, no UI) process mode instead BLOCKS until the command " +
|
|
1201
|
+
"exits and returns its output inline — there is no notification loop to resume a parked turn. " +
|
|
1200
1202
|
"Two modes: (1) `command` — run any long-lived or slow command (build, tests, dev server, " +
|
|
1201
1203
|
"watcher, interactive TUI) in a PTY; you get an AUTOMATIC notification when it exits, and " +
|
|
1202
1204
|
"you can type into it with babysit_send and read its screen with babysit_check. " +
|
|
@@ -1207,7 +1209,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
1207
1209
|
"Run a command or a pi subagent as a supervised background session (non-blocking); returns a session id",
|
|
1208
1210
|
promptGuidelines: [
|
|
1209
1211
|
"Run every long-lived or slow command through babysit_run instead of bash: builds, test suites, dev servers, watchers, `tail -f`, anything expected to take more than a few seconds. Give it a clear stable `name` (e.g. cargo-build).",
|
|
1210
|
-
"babysit_run { command }
|
|
1212
|
+
"After babysit_run { command } starts a process, end your response immediately so the automatic process-end notification can resume you; NEVER poll with babysit_check or sleep. Set continueAfterStart: true only when you have immediate, specific, non-polling work to do next. Call babysit_wait when you must consume the result inside the current turn (optionally with `expect` to wait for a readiness line like 'listening on').",
|
|
1211
1213
|
"babysit_run gives full PTY control: drive interactive programs (installers, wizards, REPLs) with babysit_send (text or named keys) and read the rendered screen with babysit_check { screen: true }.",
|
|
1212
1214
|
"Delegate self-contained tasks (codebase recon, a parallelizable subtask, work that would pollute your context) with babysit_run { profile: \"subagent\", task }. Launch several for independent subtasks; they run concurrently.",
|
|
1213
1215
|
"After spawning subagents, do not idle-wait and do not end your turn to wait for them: keep making progress, then call babysit_wait (ids + mode any/all) when you need their results. Steer or send follow-up tasks with babysit_send; kill runaways with babysit_kill.",
|
|
@@ -1311,6 +1313,23 @@ export default function (pi: ExtensionAPI) {
|
|
|
1311
1313
|
};
|
|
1312
1314
|
}
|
|
1313
1315
|
await refreshWidget(ctx);
|
|
1316
|
+
|
|
1317
|
+
// One-shot / non-interactive mode (e.g. `pi -p`): there is no live
|
|
1318
|
+
// event loop to deliver the exit notification, and ending the turn
|
|
1319
|
+
// would exit pi entirely — orphaning the babysat process and losing
|
|
1320
|
+
// the session (the agent "settles" the moment it is told the turn will
|
|
1321
|
+
// stop). So block inline like a normal command and return the full
|
|
1322
|
+
// outcome in THIS turn. The process still runs under babysit (logged,
|
|
1323
|
+
// killable), we just wait for it here instead of fire-and-forget.
|
|
1324
|
+
if (!ctx.hasUI) {
|
|
1325
|
+
const outcome = await waitForExit(res.id, parseDurMs(params.timeout), _signal);
|
|
1326
|
+
return {
|
|
1327
|
+
content: [{ type: "text", text: outcome.text }],
|
|
1328
|
+
isError: !outcome.ok,
|
|
1329
|
+
details: { id: res.id, kind: "process", command: params.command },
|
|
1330
|
+
};
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1314
1333
|
const continueAfter = params.continueAfterStart === true;
|
|
1315
1334
|
const nextStep = continueAfter
|
|
1316
1335
|
? "Continue with specific non-polling work now; the exit notification will arrive on its own."
|
|
@@ -1327,11 +1346,13 @@ export default function (pi: ExtensionAPI) {
|
|
|
1327
1346
|
},
|
|
1328
1347
|
],
|
|
1329
1348
|
details: { id: res.id, kind: "process", command: params.command },
|
|
1330
|
-
//
|
|
1331
|
-
//
|
|
1332
|
-
//
|
|
1333
|
-
//
|
|
1334
|
-
|
|
1349
|
+
// Do not return `terminate: true` here. In RPC/subagent hosts that hint
|
|
1350
|
+
// can shut down the hosting pi worker, whose process-tree cleanup then
|
|
1351
|
+
// kills the otherwise detached babysit supervisor and closes its PTY
|
|
1352
|
+
// (observed as an immediate `^D`). The prompt contract tells the model
|
|
1353
|
+
// to stop after this result instead; the NOTIFY_MARKER still identifies
|
|
1354
|
+
// a parked turn to the parent/self-reaper logic.
|
|
1355
|
+
terminate: false,
|
|
1335
1356
|
};
|
|
1336
1357
|
}
|
|
1337
1358
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yusukeshib/pi-babysit",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Run anything long-lived under babysit — one supervision substrate for processes and pi subagents, surfaced to the agent as babysit_run/check/send/wait/kill.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|