feat: add Pi subagent scheduler and child runtime
This commit is contained in:
@@ -333,6 +333,15 @@ export class PiWorkerPool {
|
||||
return record ? this.publicState(record) : null;
|
||||
}
|
||||
|
||||
async reclaimIdleWorker(): Promise<boolean> {
|
||||
const record = [...this.workers.values()]
|
||||
.filter((candidate) => candidate.state === 'ready' || candidate.state === 'idle')
|
||||
.sort((left, right) => left.lastUsed - right.lastUsed)[0];
|
||||
if (!record) return false;
|
||||
await this.evict(record);
|
||||
return true;
|
||||
}
|
||||
|
||||
subscribe(listener: (event: PiWorkerPoolEvent) => void): () => void {
|
||||
this.listeners.add(listener);
|
||||
return () => this.listeners.delete(listener);
|
||||
|
||||
Reference in New Issue
Block a user