@yusukeshib/pi-babysit 0.6.34 → 0.6.35

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.
Files changed (3) hide show
  1. package/README.md +29 -3
  2. package/index.ts +31 -7
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -86,7 +86,7 @@ Descriptions are display metadata, not shell code, stdin, or instructions sent
86
86
  to the subagent.
87
87
 
88
88
  ```text
89
- babysit_run { description: "Run regression tests", command: "bun test", foreground: true }
89
+ babysit_run { description: "Run regression tests", command: "bun test", foreground: true, timeout: "10m" }
90
90
  babysit_run { description: "Review the authentication changes", profile: "subagent", task: "Review the authentication diff for security regressions", maxTurns: 5 }
91
91
  babysit_check { description: "Inspect build errors", id: "build", pattern: "ERROR" }
92
92
  babysit_wait { description: "Wait for the build to finish", id: "build" }
@@ -112,8 +112,8 @@ SSH aliases, keys, known hosts, and ProxyJump are handled by babysit/SSH;
112
112
  pi-babysit does not install remote software or copy credentials.
113
113
 
114
114
  ```text
115
- babysit_run { description: "Run tests on Linux", host: "yusuke-t4", cwd: "/home/yusuke/project", command: "bun test", foreground: true, returnLines: 30 }
116
- babysit_run { description: "Open a remote Python REPL", host: "user@server", command: "python3 -i", name: "remote-repl", continueAfterStart: true }
115
+ babysit_run { description: "Run tests on Linux", host: "yusuke-t4", cwd: "/home/yusuke/project", command: "bun test", foreground: true, timeout: "10m", returnLines: 30 }
116
+ babysit_run { description: "Open a remote Python REPL", host: "user@server", command: "python3 -i", name: "remote-repl", timeout: "none", continueAfterStart: true }
117
117
  babysit_check { description: "Read the remote REPL screen", id: "remote-repl", screen: true }
118
118
  babysit_send { description: "Evaluate a value in the remote REPL", id: "remote-repl", text: "print(42)" }
119
119
  babysit_kill { description: "Close the remote REPL", id: "remote-repl" }
@@ -269,6 +269,32 @@ on `PATH`, or `PI_BABYSIT_PI_PACKAGE_DIR`. Built-in tools use Pi's renderers;
269
269
  extension tools fall back to generic rendering. Live `/babysit` and attach views render either profile, as well as logs
270
270
  written by older pi-babysit releases.
271
271
 
272
+ ## Execution timeouts
273
+
274
+ Commands default to an absolute **60s execution timeout**, in both foreground
275
+ and background mode, locally and over SSH. Subagents retain their **15m**
276
+ default. The babysit supervisor terminates the process when its deadline is
277
+ reached; a foreground call then returns the terminal result to the agent rather
278
+ than waiting forever. This is an execution limit, not an output-inactivity
279
+ limit or the quick-command background grace period.
280
+
281
+ Set a longer positive duration explicitly for slow work. Only an explicit
282
+ `timeout: "none"` disables the deadline, and only for background runs in
283
+ interactive/RPC mode. It is rejected with `foreground: true` or in non-interactive
284
+ mode, which always waits inline. Empty strings, zero durations, `off`, and
285
+ `never` are rejected rather than forwarded as babysit's infinite-timeout aliases.
286
+
287
+ ```text
288
+ babysit_run { description: "Run a long test suite", command: "bun test", foreground: true, timeout: "10m" }
289
+ babysit_run { description: "Start the development server", command: "bun run dev", name: "dev-server", timeout: "none", continueAfterStart: true }
290
+ ```
291
+
292
+ `idleTimeout` remains disabled by default: a silent command is not necessarily
293
+ stuck. `babysit_wait.timeout` limits only that wait, not the underlying process,
294
+ and its default remains unlimited; the process's execution timeout still applies.
295
+ To wait for readiness of an intentionally unbounded server, set a finite wait
296
+ such as `babysit_wait { description: "Wait for server readiness", id: "dev-server", expect: "listening", timeout: "15s" }`.
297
+
272
298
  ## Process ownership, interruption, shutdown, and reload
273
299
 
274
300
  An inline process wait (`foreground: true`, or process execution in a non-UI
package/index.ts CHANGED
@@ -2131,6 +2131,28 @@ async function reserveUniqueSessionId(name: string): Promise<string> {
2131
2131
  return id;
2132
2132
  }
2133
2133
 
2134
+ /** Resolve a bounded execution deadline before invoking the supervisor. */
2135
+ export function resolveRunTimeout(timeout: string | undefined, isSubagent: boolean, waitsInline: boolean): string {
2136
+ const value = timeout === undefined ? (isSubagent ? "15m" : "60s") : timeout.trim().toLowerCase();
2137
+ if (value === "none") {
2138
+ if (waitsInline) {
2139
+ throw new Error('timeout: "none" requires a background run; foreground and non-interactive runs need a finite timeout.');
2140
+ }
2141
+ return value;
2142
+ }
2143
+ // babysit also accepts empty/zero/off/never as infinite deadlines. Do not
2144
+ // forward those aliases: unbounded execution must be an explicit "none".
2145
+ const match = /^(\d+)\s*(ms|s|m|h|d)?$/.exec(value);
2146
+ const amount = match ? Number(match[1]) : NaN;
2147
+ const unit = match?.[2] ?? "s";
2148
+ const multipliers: Record<string, number> = { ms: 1, s: 1_000, m: 60_000, h: 3_600_000, d: 86_400_000 };
2149
+ const multiplier = multipliers[unit]!;
2150
+ if (!Number.isSafeInteger(amount * multiplier) || amount <= 0) {
2151
+ throw new Error('Invalid timeout: use a positive duration (e.g. "60s", "10m") or explicit "none" for a background run.');
2152
+ }
2153
+ return `${amount}${unit}`;
2154
+ }
2155
+
2134
2156
  interface ProcOpts {
2135
2157
  description: string;
2136
2158
  name?: string;
@@ -2138,7 +2160,7 @@ interface ProcOpts {
2138
2160
  cwd?: string;
2139
2161
  host?: string;
2140
2162
  env?: Record<string, string | undefined>;
2141
- timeout?: string; // default: none — dev servers may run indefinitely
2163
+ timeout: string; // resolved to 60s unless explicitly overridden
2142
2164
  idleTimeout?: string;
2143
2165
  pty: boolean;
2144
2166
  notificationGroup?: string;
@@ -2179,7 +2201,7 @@ async function spawnProcess(opts: ProcOpts): Promise<{ id: string } | { error: s
2179
2201
  const remote = !!opts.host && opts.host !== "local";
2180
2202
  const bsArgs = ["run", "-d", "--json", "--size", "120x40"];
2181
2203
  if (!opts.pty) bsArgs.push("--no-tty");
2182
- if (opts.timeout && opts.timeout !== "none") bsArgs.push("--timeout", opts.timeout);
2204
+ if (opts.timeout !== "none") bsArgs.push("--timeout", opts.timeout);
2183
2205
  if (opts.idleTimeout && opts.idleTimeout !== "none")
2184
2206
  bsArgs.push("--idle-timeout", opts.idleTimeout);
2185
2207
  const reservedId = remote ? await reserveUniqueSessionId(opts.name ?? "remote-proc") : opts.name ? await reserveUniqueSessionId(opts.name) : undefined;
@@ -3908,6 +3930,7 @@ export default function (pi: ExtensionAPI) {
3908
3930
  promptSnippet: "Run supervised commands or bounded pi subagents with context-safe logs",
3909
3931
  promptGuidelines: [
3910
3932
  "Use babysit_run for shell commands and give meaningful sessions a stable name; bundle tiny related read-only observations into one command.",
3933
+ "babysit_run commands default to a 60s execution timeout (subagents: 15m). Set a longer timeout for long-running work; timeout: none is allowed only for explicit background runs, never foreground or non-interactive runs.",
3911
3934
  "Use babysit_run foreground mode for one process or subagent whose result is needed now; never issue sibling foreground runs in parallel. For parallel process checks, start background runs with continueAfterStart and collect them with one multi-session babysit_wait.",
3912
3935
  "Use returnPattern/returnLines for noisy commands. During edit/fix loops run targeted checks first and one full validation suite at the end instead of repeating every full gate.",
3913
3936
  "After a background process starts, stop the turn for its automatic notification; never poll or sleep. Use continueAfterStart only for specific non-polling process work.",
@@ -3991,7 +4014,7 @@ export default function (pi: ExtensionAPI) {
3991
4014
  timeout: Type.Optional(
3992
4015
  Type.String({
3993
4016
  description:
3994
- "Absolute auto-kill after this long (e.g. 30m). Default: none for processes (dev servers may run forever), 15m for subagents. 'none' disables.",
4017
+ "Absolute auto-kill after a positive duration (e.g. 60s, 10m). Default: 60s for processes, 15m for subagents. Explicit 'none' disables only for background runs; forbidden with foreground or in non-interactive mode. Zero/empty/off/never are invalid.",
3995
4018
  }),
3996
4019
  ),
3997
4020
  reapAfter: Type.Optional(
@@ -4053,8 +4076,10 @@ export default function (pi: ExtensionAPI) {
4053
4076
  }),
4054
4077
  async execute(_id, params, _signal, _onUpdate, ctx) {
4055
4078
  const description = params.description.trim();
4056
- await requireBabysit();
4057
4079
  const isSubagent = params.profile === "subagent";
4080
+ const waitsInline = !ctx.hasUI || params.foreground === true;
4081
+ const timeout = resolveRunTimeout(params.timeout, isSubagent, waitsInline);
4082
+ await requireBabysit();
4058
4083
  validateProcessHost(params.host);
4059
4084
  if (isSubagent && (params.cwd !== undefined || (params.host && params.host !== "local"))) throw new Error("host/cwd are process-only options; remote subagents are not supported.");
4060
4085
  if (params.host && params.host !== "local" && params.retryOnWorkerDeath) throw new Error("Remote automatic launch retries are unsupported; reconcile the tracked session explicitly.");
@@ -4142,7 +4167,6 @@ export default function (pi: ExtensionAPI) {
4142
4167
 
4143
4168
  // --- process mode ---
4144
4169
  if (!isSubagent) {
4145
- const waitsInline = !ctx.hasUI || params.foreground === true;
4146
4170
  const lifecycle = resolveProcessLifecycle(params.lifecycle, waitsInline);
4147
4171
  if (params.returnPattern) {
4148
4172
  try {
@@ -4165,7 +4189,7 @@ export default function (pi: ExtensionAPI) {
4165
4189
  command: params.command as string,
4166
4190
  host: params.host,
4167
4191
  cwd: params.cwd ?? (params.host && params.host !== "local" ? undefined : ctx.cwd),
4168
- timeout: params.timeout,
4192
+ timeout,
4169
4193
  idleTimeout: params.idleTimeout,
4170
4194
  pty: params.pty ?? true,
4171
4195
  env: processSessionEnvironment(ctx, pi.getThinkingLevel()),
@@ -4330,7 +4354,7 @@ export default function (pi: ExtensionAPI) {
4330
4354
  }
4331
4355
  : undefined,
4332
4356
  reapAfter: params.reapAfter,
4333
- timeout: params.timeout ?? "15m",
4357
+ timeout,
4334
4358
  idleTimeout: params.idleTimeout,
4335
4359
  });
4336
4360
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yusukeshib/pi-babysit",
3
- "version": "0.6.34",
3
+ "version": "0.6.35",
4
4
  "description": "Run any shell command and pi subagents under babysit, with context-safe captured output.",
5
5
  "keywords": [
6
6
  "pi-package",