@@ -284,19 +284,14 @@ function instrumentMethod<T extends unknown[], R>(
284284 */
285285function createDeepProxy < T extends object > ( target : T , currentPath = '' , options ?: GoogleGenAIOptions ) : T {
286286 return new Proxy ( target , {
287- get ( obj : object , prop : string ) : unknown {
288- const value = ( obj as Record < string , unknown > ) [ prop ] ;
287+ get : ( t , prop ) => {
288+ const value = Reflect . get ( t , prop ) ;
289289 const methodPath = buildMethodPath ( currentPath , String ( prop ) ) ;
290290
291291 if ( typeof value === 'function' && shouldInstrument ( methodPath ) ) {
292292 // Special case: chats.create is synchronous but needs both instrumentation AND result proxying
293293 if ( methodPath === CHATS_CREATE_METHOD ) {
294- const instrumentedMethod = instrumentMethod (
295- value as ( ...args : unknown [ ] ) => unknown ,
296- methodPath ,
297- obj ,
298- options ,
299- ) ;
294+ const instrumentedMethod = instrumentMethod ( value as ( ...args : unknown [ ] ) => unknown , methodPath , t , options ) ;
300295 return function instrumentedAndProxiedCreate ( ...args : unknown [ ] ) : unknown {
301296 const result = instrumentedMethod ( ...args ) ;
302297 // If the result is an object (like a chat instance), proxy it too
@@ -307,12 +302,12 @@ function createDeepProxy<T extends object>(target: T, currentPath = '', options?
307302 } ;
308303 }
309304
310- return instrumentMethod ( value as ( ...args : unknown [ ] ) => Promise < unknown > , methodPath , obj , options ) ;
305+ return instrumentMethod ( value as ( ...args : unknown [ ] ) => Promise < unknown > , methodPath , t , options ) ;
311306 }
312307
313308 if ( typeof value === 'function' ) {
314309 // Bind non-instrumented functions to preserve the original `this` context
315- return value . bind ( obj ) ;
310+ return value . bind ( t ) ;
316311 }
317312
318313 if ( value && typeof value === 'object' ) {
0 commit comments