feat(coding-runtime): add managed Pi extension host
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user