@@ -41,6 +41,8 @@ import * as AcpRegistrySupport from "@t3tools/provider-acp-registry/server/AcpRe
4141import * as AcpRegistryRuntimeCoordinator from "@t3tools/provider-acp-registry/server/AcpRegistryRuntimeCoordinator" ;
4242import { ACP_SESSION_MODE_OPTION_ID } from "@t3tools/provider-acp/server/sessionConfig" ;
4343import * as AcpSessionRuntime from "@t3tools/provider-acp/server/AcpSessionRuntime" ;
44+ import { t3AcpPromptWithInstructions } from "@t3tools/provider-core/server/orchestrationInstructions" ;
45+ import { buildRuntimeInstructions } from "@t3tools/provider-core/server/runtimeInstructions" ;
4446import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator" ;
4547import {
4648 decodeAcpReplayTranscript ,
@@ -1007,6 +1009,92 @@ describe("AcpRegistryAdapterV2", () => {
10071009 } ) . pipe ( Effect . provide ( layerTest ) , Effect . scoped ) ,
10081010 ) ;
10091011
1012+ it . effect . each ( [ "before" , "after" ] as const ) (
1013+ "reconciles a full prompt echo %s acknowledgment" ,
1014+ ( ordering ) =>
1015+ Effect . gen ( function * ( ) {
1016+ const runtimeInstructions = {
1017+ type : "text" ,
1018+ text : buildRuntimeInstructions ( { harness : "acpRegistry" , model : "default" } ) ,
1019+ } ;
1020+ const promptBlocks = ( ordinal : number ) => [
1021+ {
1022+ type : "text" ,
1023+ text :
1024+ ordinal === 1
1025+ ? t3AcpPromptWithInstructions ( {
1026+ prompt : "test prompt" ,
1027+ state : { interactionMode : "default" , hasT3Mcp : false } ,
1028+ } )
1029+ : "test prompt" ,
1030+ } ,
1031+ runtimeInstructions ,
1032+ ] ;
1033+ const echo = ( messageId : string , content : ReadonlyArray < unknown > ) =>
1034+ claudeFrames . update ( CLAUDE_ROOT_SESSION , {
1035+ sessionUpdate : "user_message" ,
1036+ messageId,
1037+ content,
1038+ } ) ;
1039+ const promptText = ( ordinal : number ) =>
1040+ promptBlocks ( ordinal )
1041+ . map ( ( block ) => block . text )
1042+ . join ( "\n" ) ;
1043+ const frames = ( ordinal : number ) => {
1044+ const [ request , , acknowledgment ] = claudeFrames . prompt ( ordinal ) ;
1045+ const matching = echo ( `echo-${ ordinal } ` , promptBlocks ( ordinal ) ) ;
1046+ return [
1047+ request ,
1048+ echo ( "different-blocks" , [
1049+ {
1050+ type : "text" ,
1051+ text : promptText ( ordinal ) ,
1052+ } ,
1053+ ] ) ,
1054+ ...( ordering === "before" ? [ matching , acknowledgment ] : [ acknowledgment , matching ] ) ,
1055+ claudeFrames . update ( CLAUDE_ROOT_SESSION , {
1056+ sessionUpdate : "user_message_chunk" ,
1057+ messageId : `echo-${ ordinal } ` ,
1058+ content : { type : "text" , text : "updated echo" } ,
1059+ } ) ,
1060+ echo ( `echo-${ ordinal } ` , [ { type : "text" , text : "updated echo" } ] ) ,
1061+ echo ( "second-id" , promptBlocks ( ordinal ) ) ,
1062+ echo ( "unmatched" , [ { type : "text" , text : "Continue the review." } ] ) ,
1063+ claudeFrames . idle ( "end_turn" ) ,
1064+ ] ;
1065+ } ;
1066+ const session = yield * openClaudeReplaySession (
1067+ [
1068+ ...claudeFrames . open ,
1069+ ...frames ( 1 ) ,
1070+ ...frames ( 2 ) ,
1071+ claudeFrames . closeRequest ,
1072+ claudeFrames . closed ,
1073+ ] ,
1074+ undefined ,
1075+ false ,
1076+ ) ;
1077+ for ( const ordinal of [ 1 , 2 ] ) {
1078+ yield * session . runtime . startTurn ( session . turnInput ( ordinal ) ) ;
1079+ const events = yield * session . until ( ( event ) => event . type === "turn.terminal" ) ;
1080+ const messages = events . flatMap ( ( event ) =>
1081+ event . type === "message.updated" && event . message . role === "user"
1082+ ? [ event . message ]
1083+ : [ ] ,
1084+ ) ;
1085+ const items = events . flatMap ( ( event ) =>
1086+ event . type === "turn_item.updated" && event . turnItem . type === "user_message"
1087+ ? [ event . turnItem ]
1088+ : [ ] ,
1089+ ) ;
1090+ const expected = new Set ( [ promptText ( ordinal ) , "Continue the review." ] ) ;
1091+ assert . deepEqual ( new Set ( messages . map ( ( message ) => message . text ) ) , expected ) ;
1092+ assert . equal ( new Set ( messages . map ( ( message ) => message . id ) ) . size , 3 ) ;
1093+ assert . equal ( new Set ( items . map ( ( item ) => item . id ) ) . size , 3 ) ;
1094+ }
1095+ } ) . pipe ( Effect . provide ( layerTest ) , Effect . scoped ) ,
1096+ ) ;
1097+
10101098 it . effect ( "settles Claude's accepted foreground reply while retaining child output" , ( ) =>
10111099 Effect . gen ( function * ( ) {
10121100 const gate = makeProviderReplayGate ( [ "accepted" , "child-output" , "wake" ] ) ;
0 commit comments