@visibe.ai/node 0.1.23 → 0.1.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -224,19 +224,28 @@ function applyIntegration(client, name, visibe) {
224
224
  // Integrations are loaded lazily to avoid import errors when the peer
225
225
  // dependency is not installed. Each integration module exports a
226
226
  // `patchClient(client, name, visibe)` that returns a restore function.
227
- const constructorName = client?.constructor?.name ?? '';
227
+ // Walk the prototype chain to collect all ancestor class names.
228
+ // This handles subclasses (including our own PatchedOpenAI wrapper) without
229
+ // requiring the direct constructor to have a specific name.
230
+ const ancestorNames = new Set();
231
+ let ctor = client?.constructor;
232
+ while (ctor && ctor.name) {
233
+ ancestorNames.add(ctor.name);
234
+ ctor = Object.getPrototypeOf(ctor);
235
+ }
236
+ const has = (name) => ancestorNames.has(name);
228
237
  try {
229
- if (constructorName === 'OpenAI') {
238
+ if (has('OpenAI')) {
230
239
  // eslint-disable-next-line @typescript-eslint/no-require-imports
231
240
  const { patchOpenAIClient } = require('./integrations/openai');
232
241
  return patchOpenAIClient(client, name, visibe);
233
242
  }
234
- if (constructorName === 'Anthropic') {
243
+ if (has('Anthropic')) {
235
244
  // eslint-disable-next-line @typescript-eslint/no-require-imports
236
245
  const { patchAnthropicClient } = require('./integrations/anthropic');
237
246
  return patchAnthropicClient(client, name, visibe);
238
247
  }
239
- if (constructorName === 'BedrockRuntimeClient') {
248
+ if (has('BedrockRuntimeClient')) {
240
249
  // eslint-disable-next-line @typescript-eslint/no-require-imports
241
250
  const { patchBedrockClient } = require('./integrations/bedrock');
242
251
  return patchBedrockClient(client, name, visibe);
@@ -220,19 +220,28 @@ function applyIntegration(client, name, visibe) {
220
220
  // Integrations are loaded lazily to avoid import errors when the peer
221
221
  // dependency is not installed. Each integration module exports a
222
222
  // `patchClient(client, name, visibe)` that returns a restore function.
223
- const constructorName = client?.constructor?.name ?? '';
223
+ // Walk the prototype chain to collect all ancestor class names.
224
+ // This handles subclasses (including our own PatchedOpenAI wrapper) without
225
+ // requiring the direct constructor to have a specific name.
226
+ const ancestorNames = new Set();
227
+ let ctor = client?.constructor;
228
+ while (ctor && ctor.name) {
229
+ ancestorNames.add(ctor.name);
230
+ ctor = Object.getPrototypeOf(ctor);
231
+ }
232
+ const has = (name) => ancestorNames.has(name);
224
233
  try {
225
- if (constructorName === 'OpenAI') {
234
+ if (has('OpenAI')) {
226
235
  // eslint-disable-next-line @typescript-eslint/no-require-imports
227
236
  const { patchOpenAIClient } = require('./integrations/openai');
228
237
  return patchOpenAIClient(client, name, visibe);
229
238
  }
230
- if (constructorName === 'Anthropic') {
239
+ if (has('Anthropic')) {
231
240
  // eslint-disable-next-line @typescript-eslint/no-require-imports
232
241
  const { patchAnthropicClient } = require('./integrations/anthropic');
233
242
  return patchAnthropicClient(client, name, visibe);
234
243
  }
235
- if (constructorName === 'BedrockRuntimeClient') {
244
+ if (has('BedrockRuntimeClient')) {
236
245
  // eslint-disable-next-line @typescript-eslint/no-require-imports
237
246
  const { patchBedrockClient } = require('./integrations/bedrock');
238
247
  return patchBedrockClient(client, name, visibe);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visibe.ai/node",
3
- "version": "0.1.23",
3
+ "version": "0.1.24",
4
4
  "description": "AI Agent Observability — Track OpenAI, LangChain, LangGraph, Bedrock, Vercel AI, Anthropic",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",