(obj: object, prop: string)
| 325 | function createDeepProxy<T extends object>(target: T, currentPath = '', options: AnthropicAiOptions): T { |
| 326 | return new Proxy(target, { |
| 327 | get(obj: object, prop: string): unknown { |
| 328 | const value = (obj as Record<string, unknown>)[prop]; |
| 329 | const methodPath = buildMethodPath(currentPath, String(prop)); |
| 330 | |
| 331 | const instrumentedMethod = ANTHROPIC_METHOD_REGISTRY[methodPath as keyof typeof ANTHROPIC_METHOD_REGISTRY]; |
| 332 | if (typeof value === 'function' && instrumentedMethod) { |
| 333 | return instrumentMethod( |
| 334 | value as (...args: unknown[]) => unknown | Promise<unknown>, |
| 335 | methodPath, |
| 336 | instrumentedMethod, |
| 337 | obj, |
| 338 | options, |
| 339 | ); |
| 340 | } |
| 341 | |
| 342 | if (typeof value === 'function') { |
| 343 | // Bind non-instrumented functions to preserve the original `this` context, |
| 344 | return value.bind(obj); |
| 345 | } |
| 346 | |
| 347 | if (value && typeof value === 'object') { |
| 348 | return createDeepProxy(value, methodPath, options); |
| 349 | } |
| 350 | |
| 351 | return value; |
| 352 | }, |
| 353 | }) as T; |
| 354 | } |
| 355 |
nothing calls this directly
no test coverage detected