feat(coding-runtime): add managed Pi extension host
This commit is contained in:
@@ -127,6 +127,19 @@ export class PiRpcClient {
|
||||
throw lastError;
|
||||
}
|
||||
|
||||
async send(command: PiRpcCommand): Promise<void> {
|
||||
if (!command.type) throw new Error('Pi RPC command type is required');
|
||||
if (this.invalidated) throw this.invalidated;
|
||||
try {
|
||||
await this.write(`${JSON.stringify(command)}\n`);
|
||||
} catch (error) {
|
||||
throw new PiProcessError('PI_RPC_WRITE_FAILED', `Could not write Pi RPC ${command.type}`, {
|
||||
cause: error,
|
||||
generation: this.generation,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
accept(value: unknown): void {
|
||||
if (!recordValue(value) || typeof value.type !== 'string') {
|
||||
throw new PiProcessError('PI_RPC_PROTOCOL_ERROR', 'Pi RPC record must be an object with a type');
|
||||
|
||||
Reference in New Issue
Block a user