@@ -395,80 +395,75 @@ describe("V2 environment commands", () => {
395395 } ) . pipe ( Effect . provide ( layerTestCrypto ) ) ,
396396 ) ;
397397
398- it . effect . each ( [
399- "waiting" ,
400- "completed" ,
401- "failed" ,
402- "interrupted" ,
403- "cancelled" ,
404- "rolled_back" ,
405- ] as const ) ( "dispatches Stop for %s runs with background commands except rollback" , ( status ) =>
406- Effect . gen ( function * ( ) {
407- const waitingRunId = RunId . make ( "run-waiting" ) ;
408- const projection : OrchestrationV2ThreadProjection = {
409- ...v2Projection ,
410- runs : [
411- {
412- id : waitingRunId ,
413- threadId : v2ThreadId ,
414- ordinal : 1 ,
415- providerInstanceId : v2Projection . thread . providerInstanceId ,
416- modelSelection : v2Projection . thread . modelSelection ,
417- providerThreadId : null ,
418- userMessageId : MessageId . make ( "message-waiting" ) ,
419- rootNodeId : null ,
420- activeAttemptId : null ,
421- status,
422- requestedAt : v2Now ,
423- startedAt : v2Now ,
424- completedAt : null ,
425- checkpointId : null ,
426- contextHandoffId : null ,
427- } ,
428- ] ,
429- turnItems : [
430- {
431- id : TurnItemId . make ( "background-command" ) ,
432- threadId : v2ThreadId ,
433- runId : waitingRunId ,
434- nodeId : null ,
435- providerThreadId : null ,
436- providerTurnId : null ,
437- nativeItemRef : null ,
438- parentItemId : null ,
439- ordinal : 1 ,
440- status : "running" ,
441- title : null ,
442- startedAt : v2Now ,
443- completedAt : null ,
444- updatedAt : v2Now ,
445- type : "command_execution" ,
446- input : "vp run dev" ,
447- } ,
448- ] ,
449- } ;
450- const commands : OrchestrationV2Command [ ] = [ ] ;
451- const supervisor = yield * makeSupervisor ( { commands, projects : [ ] , projection } ) ;
452-
453- const result = yield * interruptThreadTurn ( { threadId : v2ThreadId } ) . pipe (
454- Effect . provideService ( EnvironmentSupervisor . EnvironmentSupervisor , supervisor ) ,
455- ) ;
456-
457- expect ( result ) . toEqual ( { sequence : status === "rolled_back" ? 0 : 1 } ) ;
458- expect ( commands ) . toEqual (
459- status === "rolled_back"
460- ? [ ]
461- : [
462- {
463- type : "run.interrupt" ,
464- commandId : expect . any ( String ) ,
465- threadId : v2ThreadId ,
466- runId : waitingRunId ,
467- holdQueue : true ,
468- } ,
469- ] ,
470- ) ;
471- } ) . pipe ( Effect . provide ( layerTestCrypto ) ) ,
398+ it . effect . each ( [ "waiting" , "completed" , "rolled_back" ] as const ) (
399+ "dispatches Stop for %s runs with background commands except rollback" ,
400+ ( status ) =>
401+ Effect . gen ( function * ( ) {
402+ const waitingRunId = RunId . make ( "run-waiting" ) ;
403+ const projection : OrchestrationV2ThreadProjection = {
404+ ...v2Projection ,
405+ runs : [
406+ {
407+ id : waitingRunId ,
408+ threadId : v2ThreadId ,
409+ ordinal : 1 ,
410+ providerInstanceId : v2Projection . thread . providerInstanceId ,
411+ modelSelection : v2Projection . thread . modelSelection ,
412+ providerThreadId : null ,
413+ userMessageId : MessageId . make ( "message-waiting" ) ,
414+ rootNodeId : null ,
415+ activeAttemptId : null ,
416+ status,
417+ requestedAt : v2Now ,
418+ startedAt : v2Now ,
419+ completedAt : null ,
420+ checkpointId : null ,
421+ contextHandoffId : null ,
422+ } ,
423+ ] ,
424+ turnItems : [
425+ {
426+ id : TurnItemId . make ( "background-command" ) ,
427+ threadId : v2ThreadId ,
428+ runId : waitingRunId ,
429+ nodeId : null ,
430+ providerThreadId : null ,
431+ providerTurnId : null ,
432+ nativeItemRef : null ,
433+ parentItemId : null ,
434+ ordinal : 1 ,
435+ status : "running" ,
436+ title : null ,
437+ startedAt : v2Now ,
438+ completedAt : null ,
439+ updatedAt : v2Now ,
440+ type : "command_execution" ,
441+ input : "vp run dev" ,
442+ } ,
443+ ] ,
444+ } ;
445+ const commands : OrchestrationV2Command [ ] = [ ] ;
446+ const supervisor = yield * makeSupervisor ( { commands, projects : [ ] , projection } ) ;
447+
448+ const result = yield * interruptThreadTurn ( { threadId : v2ThreadId } ) . pipe (
449+ Effect . provideService ( EnvironmentSupervisor . EnvironmentSupervisor , supervisor ) ,
450+ ) ;
451+
452+ expect ( result ) . toEqual ( { sequence : status === "rolled_back" ? 0 : 1 } ) ;
453+ expect ( commands ) . toEqual (
454+ status === "rolled_back"
455+ ? [ ]
456+ : [
457+ {
458+ type : "run.interrupt" ,
459+ commandId : expect . any ( String ) ,
460+ threadId : v2ThreadId ,
461+ runId : waitingRunId ,
462+ holdQueue : true ,
463+ } ,
464+ ] ,
465+ ) ;
466+ } ) . pipe ( Effect . provide ( layerTestCrypto ) ) ,
472467 ) ;
473468
474469 it . effect ( "validates identified checkpoints locally for older servers" , ( ) =>
0 commit comments