@@ -12,6 +12,7 @@ export interface RunOpts {
1212 workspace ?: string
1313 chatState ?: string
1414 confirm ?: boolean
15+ prompt ?: boolean
1516}
1617
1718export enum RunEventType {
@@ -344,23 +345,27 @@ export class Run {
344345 } )
345346
346347 res . on ( "aborted" , ( ) => {
347- if ( this . state !== RunState . Finished ) {
348+ if ( this . state !== RunState . Finished && this . state !== RunState . Error ) {
348349 this . state = RunState . Error
349350 this . err = "Run has been aborted"
350351 reject ( this . err )
351352 }
352353 } )
353354
354355 res . on ( "error" , ( error : Error ) => {
355- this . state = RunState . Error
356- this . err = error . message || ""
356+ if ( this . state !== RunState . Error ) {
357+ this . state = RunState . Error
358+ this . err = error . message || ""
359+ }
357360 reject ( this . err )
358361 } )
359362 } )
360363
361364 this . req . on ( "error" , ( error : Error ) => {
362- this . state = RunState . Error
363- this . err = error . message || ""
365+ if ( this . state !== RunState . Error ) {
366+ this . state = RunState . Error
367+ this . err = error . message || ""
368+ }
364369 reject ( this . err )
365370 } )
366371
@@ -434,6 +439,13 @@ export class Run {
434439 this . state = RunState . Creating
435440 }
436441
442+ if ( f . type === RunEventType . Prompt && ! this . opts . prompt ) {
443+ this . state = RunState . Error
444+ this . err = `prompt occurred when prompt was not allowed: Message: ${ f . message } \nFields: ${ f . fields } \nSensitive: ${ f . sensitive } `
445+ this . close ( )
446+ return ""
447+ }
448+
437449 if ( f . type === RunEventType . RunStart ) {
438450 this . state = RunState . Running
439451 } else if ( f . type === RunEventType . RunFinish ) {
0 commit comments