@@ -7716,6 +7716,7 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
77167716 const emitEvent = emit ( events , command ) ;
77177717 const requestNode = context . node ;
77187718 if ( command . feedback !== undefined ) {
7719+ const messageId = MessageId . make ( `approval-feedback:${ command . requestId } ` ) ;
77197720 // Record the reply for every client without dispatching a prompt to the parent agent.
77207721 yield * emitEvent ( {
77217722 type : "message.updated" ,
@@ -7724,7 +7725,7 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
77247725 nodeId : runtimeRequest . nodeId ,
77257726 occurredAt : now ,
77267727 payload : {
7727- id : MessageId . make ( `approval-feedback: ${ command . requestId } ` ) ,
7728+ id : messageId ,
77287729 threadId : command . threadId ,
77297730 runId : requestNode ?. runId ?? null ,
77307731 nodeId : runtimeRequest . nodeId ,
@@ -7738,6 +7739,43 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
77387739 updatedAt : now ,
77397740 } ,
77407741 } ) ;
7742+ yield * emitEvent ( {
7743+ type : "turn-item.updated" ,
7744+ threadId : command . threadId ,
7745+ ...( requestNode ?. runId == null ? { } : { runId : requestNode . runId } ) ,
7746+ nodeId : runtimeRequest . nodeId ,
7747+ occurredAt : now ,
7748+ payload : {
7749+ id : idAllocator . derive . userTurnItem ( { messageId } ) ,
7750+ threadId : command . threadId ,
7751+ runId : requestNode ?. runId ?? null ,
7752+ nodeId : runtimeRequest . nodeId ,
7753+ providerThreadId :
7754+ context . item ?. providerThreadId ?? requestNode ?. providerThreadId ?? null ,
7755+ providerTurnId : runtimeRequest . providerTurnId ,
7756+ nativeItemRef : null ,
7757+ parentItemId : null ,
7758+ ordinal : yield * projectionStore
7759+ . getNextTurnItemOrdinal ( command . threadId )
7760+ . pipe (
7761+ Effect . mapError (
7762+ ( cause ) => new OrchestratorProjectionError ( { threadId : command . threadId , cause } ) ,
7763+ ) ,
7764+ ) ,
7765+ status : "completed" ,
7766+ title : null ,
7767+ startedAt : now ,
7768+ completedAt : now ,
7769+ updatedAt : now ,
7770+ type : "user_message" ,
7771+ messageId,
7772+ inputIntent : "steer" ,
7773+ text : command . feedback ,
7774+ attachments : [ ] ,
7775+ createdBy : "user" ,
7776+ creationSource : "server" ,
7777+ } ,
7778+ } ) ;
77417779 }
77427780 const resolvedNodeStatus =
77437781 command . decision === "decline" || command . decision === "cancel"
0 commit comments