@henryqw/pi-process

Bounded UTF-8 child-process execution for Pi packages.

Packages

Package details

package

Install @henryqw/pi-process from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:@henryqw/pi-process
Package
@henryqw/pi-process
Version
0.2.1
Published
Oct 17, 2026
Downloads
1,512/mo · 483/wk
Author
henrywang
License
MIT
Types
package
Size
11.8 KB
Dependencies
0 dependencies · 0 peers

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

@henryqw/pi-process

Run one argv-only child process. Limit UTF-8 output and execution time. Cancel the process when necessary.

Install

npm install @henryqw/pi-process

Use

import { spawnBounded } from "@henryqw/pi-process";

const result = await spawnBounded("git", ["status"], { cwd: process.cwd() });
if (result.code !== 0 || result.killed) throw new Error(result.stderr);

spawnBounded accepts an optional UTF-8 string on stdin. It strictly decodes stdout and stderr. The default timeout is 30 seconds. Pass timeoutMs: null for a process without an elapsed-time limit. Cancellation and output limits still apply.

Each output stream has a 64 KiB limit. Set stdoutTailBytes to keep only the end of stdout instead of applying the stdout limit. The retained text has complete UTF-8 characters.

On POSIX systems, cancellation and timeout terminate the child process group. Invalid command, argument, and working-directory values cause failure before a child starts.

API

Surface Type Purpose
spawnBounded function Run one bounded argv-only child process.
Exec type Describe the executor call signature.
ExecOptions type Configure cwd, cancellation, timeout, limits, and string stdin.
ExecResult type Return stdout, stderr, exit code, kill state, and tail truncation.