feat(coding-runtime): add managed Pi extension host

This commit is contained in:
2026-08-23 09:39:12 +08:00
parent 47159b3cbd
commit 3861c3286a
22 changed files with 1673 additions and 16 deletions

View File

@@ -24,6 +24,7 @@ export interface PiConversationWorker {
command: PiRpcCommand,
options?: PiRpcRequestOptions,
): Promise<PiRpcResponse<T>>;
send(command: PiRpcCommand): Promise<void>;
subscribe(listener: (event: PiRpcEvent) => void): () => void;
subscribeInvalidation(listener: (error: PiProcessError) => void): () => void;
stop(): Promise<PiWorkerStopResult>;
@@ -365,6 +366,18 @@ export class PiWorkerPool {
}
}
async send(conversationId: string, command: PiRpcCommand): Promise<void> {
let record = this.workers.get(conversationId);
if (!record || record.state === 'crashed') throw new Error('Conversation worker is not available');
if (record.rebuildFlight) record = await record.rebuildFlight;
await record.worker.send(command);
}
getActiveRun(conversationId: string): { runId: string; generation: number } | null {
const active = this.activeRuns.get(conversationId);
return active ? { ...active } : null;
}
failTopLevel(conversationId: string, runId: string, error: Error): void {
const active = this.activeRuns.get(conversationId);
if (active?.runId === runId) {