@visibe.ai/node 0.1.8 → 0.1.9
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.
- package/dist/cjs/api.js +5 -0
- package/dist/cjs/index.js +11 -2
- package/dist/esm/api.js +5 -0
- package/dist/esm/index.js +11 -2
- package/package.json +1 -1
package/dist/cjs/api.js
CHANGED
|
@@ -12,6 +12,11 @@ class APIClient {
|
|
|
12
12
|
if (!this._enabled) {
|
|
13
13
|
process.emitWarning('[Visibe] No API key provided — tracing is disabled. Set VISIBE_API_KEY or pass apiKey= to enable.', { type: 'VisibleSDKWarning', code: 'VISIBE_NO_API_KEY' });
|
|
14
14
|
}
|
|
15
|
+
else if (options.apiKey &&
|
|
16
|
+
!options.apiKey.startsWith('sk_live_') &&
|
|
17
|
+
!options.apiKey.startsWith('sk_test_')) {
|
|
18
|
+
process.emitWarning('[Visibe] API key format unrecognized (expected sk_live_* or sk_test_*).', { type: 'VisibleSDKWarning', code: 'VISIBE_INVALID_KEY_FORMAT' });
|
|
19
|
+
}
|
|
15
20
|
}
|
|
16
21
|
// ---------------------------------------------------------------------------
|
|
17
22
|
// validateKey() — called once at startup in the background.
|
package/dist/cjs/index.js
CHANGED
|
@@ -53,7 +53,7 @@ function patchFramework(framework, client) {
|
|
|
53
53
|
case 'openai': {
|
|
54
54
|
const openaiModule = require('openai');
|
|
55
55
|
_originalOpenAI = openaiModule.OpenAI;
|
|
56
|
-
|
|
56
|
+
const PatchedOpenAI = class extends _originalOpenAI {
|
|
57
57
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
58
58
|
constructor(...args) {
|
|
59
59
|
super(...args);
|
|
@@ -63,12 +63,16 @@ function patchFramework(framework, client) {
|
|
|
63
63
|
catch { /* never crash new OpenAI() */ }
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
|
+
openaiModule.OpenAI = PatchedOpenAI;
|
|
67
|
+
// Also patch .default so that `import OpenAI from 'openai'` (esModuleInterop)
|
|
68
|
+
// picks up the instrumented class — TypeScript compiles default imports to .default.
|
|
69
|
+
openaiModule.default = PatchedOpenAI;
|
|
66
70
|
break;
|
|
67
71
|
}
|
|
68
72
|
case 'anthropic': {
|
|
69
73
|
const anthropicModule = require('@anthropic-ai/sdk');
|
|
70
74
|
_originalAnthropic = anthropicModule.Anthropic;
|
|
71
|
-
|
|
75
|
+
const PatchedAnthropic = class extends _originalAnthropic {
|
|
72
76
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
73
77
|
constructor(...args) {
|
|
74
78
|
super(...args);
|
|
@@ -78,6 +82,9 @@ function patchFramework(framework, client) {
|
|
|
78
82
|
catch { /* never crash new Anthropic() */ }
|
|
79
83
|
}
|
|
80
84
|
};
|
|
85
|
+
anthropicModule.Anthropic = PatchedAnthropic;
|
|
86
|
+
// Also patch .default for esModuleInterop default import support.
|
|
87
|
+
anthropicModule.default = PatchedAnthropic;
|
|
81
88
|
break;
|
|
82
89
|
}
|
|
83
90
|
case 'bedrock': {
|
|
@@ -173,6 +180,7 @@ async function shutdown() {
|
|
|
173
180
|
try {
|
|
174
181
|
if (_originalOpenAI) {
|
|
175
182
|
require('openai').OpenAI = _originalOpenAI;
|
|
183
|
+
require('openai').default = _originalOpenAI;
|
|
176
184
|
_originalOpenAI = null;
|
|
177
185
|
}
|
|
178
186
|
}
|
|
@@ -180,6 +188,7 @@ async function shutdown() {
|
|
|
180
188
|
try {
|
|
181
189
|
if (_originalAnthropic) {
|
|
182
190
|
require('@anthropic-ai/sdk').Anthropic = _originalAnthropic;
|
|
191
|
+
require('@anthropic-ai/sdk').default = _originalAnthropic;
|
|
183
192
|
_originalAnthropic = null;
|
|
184
193
|
}
|
|
185
194
|
}
|
package/dist/esm/api.js
CHANGED
|
@@ -9,6 +9,11 @@ export class APIClient {
|
|
|
9
9
|
if (!this._enabled) {
|
|
10
10
|
process.emitWarning('[Visibe] No API key provided — tracing is disabled. Set VISIBE_API_KEY or pass apiKey= to enable.', { type: 'VisibleSDKWarning', code: 'VISIBE_NO_API_KEY' });
|
|
11
11
|
}
|
|
12
|
+
else if (options.apiKey &&
|
|
13
|
+
!options.apiKey.startsWith('sk_live_') &&
|
|
14
|
+
!options.apiKey.startsWith('sk_test_')) {
|
|
15
|
+
process.emitWarning('[Visibe] API key format unrecognized (expected sk_live_* or sk_test_*).', { type: 'VisibleSDKWarning', code: 'VISIBE_INVALID_KEY_FORMAT' });
|
|
16
|
+
}
|
|
12
17
|
}
|
|
13
18
|
// ---------------------------------------------------------------------------
|
|
14
19
|
// validateKey() — called once at startup in the background.
|
package/dist/esm/index.js
CHANGED
|
@@ -47,7 +47,7 @@ function patchFramework(framework, client) {
|
|
|
47
47
|
case 'openai': {
|
|
48
48
|
const openaiModule = require('openai');
|
|
49
49
|
_originalOpenAI = openaiModule.OpenAI;
|
|
50
|
-
|
|
50
|
+
const PatchedOpenAI = class extends _originalOpenAI {
|
|
51
51
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
52
52
|
constructor(...args) {
|
|
53
53
|
super(...args);
|
|
@@ -57,12 +57,16 @@ function patchFramework(framework, client) {
|
|
|
57
57
|
catch { /* never crash new OpenAI() */ }
|
|
58
58
|
}
|
|
59
59
|
};
|
|
60
|
+
openaiModule.OpenAI = PatchedOpenAI;
|
|
61
|
+
// Also patch .default so that `import OpenAI from 'openai'` (esModuleInterop)
|
|
62
|
+
// picks up the instrumented class — TypeScript compiles default imports to .default.
|
|
63
|
+
openaiModule.default = PatchedOpenAI;
|
|
60
64
|
break;
|
|
61
65
|
}
|
|
62
66
|
case 'anthropic': {
|
|
63
67
|
const anthropicModule = require('@anthropic-ai/sdk');
|
|
64
68
|
_originalAnthropic = anthropicModule.Anthropic;
|
|
65
|
-
|
|
69
|
+
const PatchedAnthropic = class extends _originalAnthropic {
|
|
66
70
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
67
71
|
constructor(...args) {
|
|
68
72
|
super(...args);
|
|
@@ -72,6 +76,9 @@ function patchFramework(framework, client) {
|
|
|
72
76
|
catch { /* never crash new Anthropic() */ }
|
|
73
77
|
}
|
|
74
78
|
};
|
|
79
|
+
anthropicModule.Anthropic = PatchedAnthropic;
|
|
80
|
+
// Also patch .default for esModuleInterop default import support.
|
|
81
|
+
anthropicModule.default = PatchedAnthropic;
|
|
75
82
|
break;
|
|
76
83
|
}
|
|
77
84
|
case 'bedrock': {
|
|
@@ -167,6 +174,7 @@ export async function shutdown() {
|
|
|
167
174
|
try {
|
|
168
175
|
if (_originalOpenAI) {
|
|
169
176
|
require('openai').OpenAI = _originalOpenAI;
|
|
177
|
+
require('openai').default = _originalOpenAI;
|
|
170
178
|
_originalOpenAI = null;
|
|
171
179
|
}
|
|
172
180
|
}
|
|
@@ -174,6 +182,7 @@ export async function shutdown() {
|
|
|
174
182
|
try {
|
|
175
183
|
if (_originalAnthropic) {
|
|
176
184
|
require('@anthropic-ai/sdk').Anthropic = _originalAnthropic;
|
|
185
|
+
require('@anthropic-ai/sdk').default = _originalAnthropic;
|
|
177
186
|
_originalAnthropic = null;
|
|
178
187
|
}
|
|
179
188
|
}
|
package/package.json
CHANGED