feat(coding): add core host api composition
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
import type { ConversationInteraction } from '../contracts';
|
||||
import type {
|
||||
ConversationInteraction,
|
||||
ConversationInteractionResponse,
|
||||
} from '../contracts';
|
||||
import type { PiRpcCommand, PiRpcEvent } from './rpc-client';
|
||||
import type { PiGenerationResourceInput, PiWorkerPoolState } from './worker-pool';
|
||||
|
||||
@@ -17,12 +20,6 @@ interface StoredInteraction {
|
||||
untrack(): void;
|
||||
}
|
||||
|
||||
export type PiInteractionResponse =
|
||||
| { interactionId: string; cancelled: true }
|
||||
| { interactionId: string; optionId: string }
|
||||
| { interactionId: string; confirmed: boolean }
|
||||
| { interactionId: string; value: string };
|
||||
|
||||
function dialogEvent(event: PiRpcEvent): event is PiRpcEvent & {
|
||||
id: string;
|
||||
method: 'select' | 'confirm' | 'input' | 'editor';
|
||||
@@ -101,7 +98,7 @@ export class PiInteractionStore {
|
||||
return structuredClone(interaction);
|
||||
}
|
||||
|
||||
async respond(conversationId: string, response: PiInteractionResponse): Promise<ConversationInteraction> {
|
||||
async respond(conversationId: string, response: ConversationInteractionResponse): Promise<ConversationInteraction> {
|
||||
const stored = this.pending.get(this.key(conversationId, response.interactionId));
|
||||
if (!stored) throw new Error('Pi interaction is not pending');
|
||||
if (stored.phase === 'responding') throw new Error('Pi interaction response is already in progress');
|
||||
|
||||
Reference in New Issue
Block a user