Skip to content

Commit

Permalink
Review feedback - thanks mike!
Browse files Browse the repository at this point in the history
  • Loading branch information
gnarf committed Jul 11, 2024
1 parent 21d1b36 commit 8e405b2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/agent/at-driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,12 @@ export class ATDriver {
const id = this._nextId++;
const rawMessage = JSON.stringify({ id, ...command });
this.log(AgentMessage.AT_DRIVER_COMMS, { direction: 'outbound', message: rawMessage });
if (this.hasClosed) throw new Error('AT-Driver connection unexpectedly closed');
this.socket.send(rawMessage);
await new Promise((resolve, reject) => {
this.socket.send(rawMessage, error => {
if (error) reject(error);
else resolve();
});
});
for await (const message of this._messages()) {
if (message.id === id) {
if (message.error) {
Expand Down Expand Up @@ -109,7 +113,6 @@ export class ATDriver {
* @returns {AsyncGenerator<string>}
*/
async *speeches() {
if (this.hasClosed) throw new Error('AT-Driver connection unexpectedly closed');
for await (const message of this._messages()) {
if (message.method === 'interaction.capturedOutput') {
yield message.params.data;
Expand Down

0 comments on commit 8e405b2

Please sign in to comment.