feat: add Pi subagent scheduler and child runtime

This commit is contained in:
2026-08-23 12:40:22 +08:00
parent b806c78139
commit f1c7cd8ad4
21 changed files with 1986 additions and 53 deletions

View File

@@ -52,6 +52,7 @@ export type PiWorkerProcessOptions = {
cwd: string;
configDir: string;
sessionDir: string;
tools?: readonly string[];
additionalArgs?: readonly string[];
env?: NodeJS.ProcessEnv;
sensitiveValues?: readonly string[];
@@ -64,6 +65,7 @@ export type PiWorkerProcessOptions = {
export function buildPiRpcArgs(
sessionDir: string,
additionalArgs: readonly string[] = [],
tools: readonly string[] = ['read', 'bash', 'edit', 'write', 'grep', 'find', 'ls', 'ask_user'],
): string[] {
return [
'--mode', 'rpc',
@@ -75,7 +77,7 @@ export function buildPiRpcArgs(
'--no-themes',
'--no-context-files',
'--no-approve',
'--tools', 'read,bash,edit,write,grep,find,ls,ask_user',
'--tools', tools.join(','),
...additionalArgs,
];
}
@@ -217,7 +219,11 @@ export class PiWorkerProcess {
async start(): Promise<this> {
if (this.child) throw new Error('Pi worker process already started');
const generation = this.generationValue;
const args = buildPiRpcArgs(this.options.sessionDir, this.options.additionalArgs);
const args = buildPiRpcArgs(
this.options.sessionDir,
this.options.additionalArgs,
this.options.tools,
);
assertSensitiveValuesAbsentFromArgs(args, this.options.sensitiveValues);
const child = spawn(
this.options.executablePath,