@@ -45,7 +45,7 @@ describe("Flumix Compatibility", () => {
4545 // Test composing multiple mixins
4646 type BaseClass = typeof AIChatAgent < TestEnv > ;
4747 type WithAuthClass = ReturnType < typeof AuthAgent < TestEnv , BaseClass > > ;
48- type ComposedClass = ReturnType < typeof OwnedAgent < WithAuthClass > > ;
48+ type ComposedClass = ReturnType < typeof OwnedAgent < TestEnv , WithAuthClass > > ;
4949 type ComposedInstance = InstanceType < ComposedClass > ;
5050
5151 // Verify it has methods from both mixins
@@ -80,15 +80,39 @@ describe("Flumix Compatibility", () => {
8080 // import it, triggering the cloudflare: protocol error. Instead, we verify
8181 // that our mixins work with flumix using a mock base class.
8282
83+ // Mock the AIChatAgent class structure for type compatibility
8384 class MockServer < Env > {
8485 constructor (
8586 // eslint-disable-next-line @typescript-eslint/no-explicit-any
86- public party : any ,
87+ public ctx : any ,
8788 public env ?: Env ,
8889 ) { }
90+
91+ // Add stub methods to satisfy AIChatAgent interface
92+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
93+ async fetch ( _request : Request ) : Promise < Response > {
94+ return new Response ( ) ;
95+ }
96+
97+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
98+ async onConnect ( _connection : any , _ctx : any ) : Promise < void > { }
99+
100+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
101+ async onMessage ( _connection : any , _message : any ) : Promise < void > { }
102+
103+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
104+ async onRequest ( _request : Request ) : Promise < Response > {
105+ return new Response ( ) ;
106+ }
107+
108+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
109+ async onClose ( _connection : any , _code : number , _reason : string , _wasClean : boolean ) : Promise < void > { }
110+
111+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
112+ onError ( _connection : any , _error : unknown ) : void { }
89113 }
90114
91- const SuperAgent = extend ( MockServer < TestEnv > )
115+ const SuperAgent = extend ( MockServer < TestEnv > as unknown as typeof AIChatAgent < TestEnv > )
92116 . with ( AuthAgent )
93117 . with ( OwnedAgent )
94118 . build ( ) ;
@@ -123,8 +147,8 @@ describe("Flumix Compatibility", () => {
123147 AUTH0_DOMAIN : "test.auth0.com" ,
124148 AUTH0_AUDIENCE : "https://api.test.com" ,
125149 } ;
126- const mockParty = { } ;
127- const instance = new SuperAgent ( mockParty , mockEnv ) ;
150+ const mockCtx = { } ;
151+ const instance = new SuperAgent ( mockCtx , mockEnv ) ;
128152 expect ( instance ) . toBeDefined ( ) ;
129153 expect ( typeof instance . getClaims ) . toBe ( "function" ) ;
130154 // eslint-disable-next-line @typescript-eslint/no-explicit-any
0 commit comments