feat(coding): add core host api composition
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
import type { PrepareConversationInput } from '../contracts';
|
||||
import type { ConversationModelState } from '../contracts';
|
||||
import type {
|
||||
CodingRuntimeDiagnostics,
|
||||
ConversationModelState,
|
||||
PrepareConversationInput,
|
||||
} from '../contracts';
|
||||
import type { PiProcessError, PiProcessErrorCode } from './process-errors';
|
||||
import type {
|
||||
PiRpcCommand,
|
||||
@@ -347,6 +350,27 @@ export class PiWorkerPool {
|
||||
return record ? this.publicState(record) : null;
|
||||
}
|
||||
|
||||
getDiagnostics(): CodingRuntimeDiagnostics {
|
||||
const stage = (
|
||||
state: PiWorkerPoolState['state'],
|
||||
): CodingRuntimeDiagnostics['workers'][number]['stage'] => {
|
||||
if (state === 'spawning') return 'starting';
|
||||
if (state === 'queued') return 'queued';
|
||||
if (state === 'running') return 'running';
|
||||
if (state === 'crashed') return 'failed';
|
||||
return 'idle';
|
||||
};
|
||||
return {
|
||||
revision: this.revisions.current,
|
||||
workers: [...this.workers.values()].map((record) => ({
|
||||
conversationId: record.conversation.conversationId,
|
||||
generation: record.generation,
|
||||
state: record.state,
|
||||
stage: stage(record.state),
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
||||
async reclaimIdleWorker(signal?: AbortSignal): Promise<boolean> {
|
||||
while (true) {
|
||||
if (signal?.aborted) throw new Error('Pi idle worker reclaim cancelled');
|
||||
|
||||
Reference in New Issue
Block a user