private async stdin(query: Query): Promise<void> {
const data = this.encoder.encode(JSON.stringify(query) + "\n");
await this.writer.ready;
await this.writer.write(data);
this.writer.releaseLock();
}
private async stdout(): Promise<AIObject> {
const result = await this.reader.read();
if (result.done) {
throw new Error("Stream finished unexpectedly.");
}
const responseStr = this.decoder.decode(result.value);
return JSON.parse(responseStr) as AIObject;
}
private async stdin(query: Query): Promise<void> {
const data = this.encoder.encode(JSON.stringify(query) + "\n");
await this.writer.ready;
await this.writer.write(data);
this.writer.releaseLock();
}
private async stdout(): Promise<AIObject> {
const result = await this.reader.read();
if (result.done) {
throw new Error("Stream finished unexpectedly.");
}
const responseStr = this.decoder.decode(result.value);
return JSON.parse(responseStr) as AIObject;
}