@mynitorai/sdk 0.1.9 → 0.2.0
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/index.d.ts +1 -0
- package/dist/index.js +10 -7
- package/dist/verify_naming.d.ts +1 -0
- package/dist/verify_naming.js +28 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -36,6 +36,9 @@ class MyNitor {
|
|
|
36
36
|
if (!MyNitor.instance) {
|
|
37
37
|
MyNitor.instance = new MyNitor(config);
|
|
38
38
|
}
|
|
39
|
+
else {
|
|
40
|
+
MyNitor.instance.config = { ...MyNitor.instance.config, ...config };
|
|
41
|
+
}
|
|
39
42
|
return MyNitor.instance;
|
|
40
43
|
}
|
|
41
44
|
/**
|
|
@@ -78,7 +81,7 @@ class MyNitor {
|
|
|
78
81
|
file: fullPath,
|
|
79
82
|
line: parseInt(match[3]),
|
|
80
83
|
functionName: func,
|
|
81
|
-
workflowGuess:
|
|
84
|
+
workflowGuess: filename
|
|
82
85
|
};
|
|
83
86
|
}
|
|
84
87
|
}
|
|
@@ -135,7 +138,7 @@ class MyNitor {
|
|
|
135
138
|
model: result.model || body.model,
|
|
136
139
|
provider: 'openai',
|
|
137
140
|
agent: 'default-agent',
|
|
138
|
-
workflow: callsite.workflowGuess,
|
|
141
|
+
workflow: this.config.workflowId || callsite.workflowGuess,
|
|
139
142
|
file: callsite.file,
|
|
140
143
|
function_name: callsite.functionName,
|
|
141
144
|
line_number: callsite.line,
|
|
@@ -153,7 +156,7 @@ class MyNitor {
|
|
|
153
156
|
model: body?.model || 'unknown',
|
|
154
157
|
provider: 'openai',
|
|
155
158
|
agent: 'default-agent',
|
|
156
|
-
workflow: callsite.workflowGuess,
|
|
159
|
+
workflow: this.config.workflowId || callsite.workflowGuess,
|
|
157
160
|
file: callsite.file,
|
|
158
161
|
function_name: callsite.functionName,
|
|
159
162
|
latency_ms: end - start,
|
|
@@ -191,7 +194,7 @@ class MyNitor {
|
|
|
191
194
|
model: result.model || body.model,
|
|
192
195
|
provider: 'anthropic',
|
|
193
196
|
agent: 'default-agent',
|
|
194
|
-
workflow: callsite.workflowGuess,
|
|
197
|
+
workflow: this.config.workflowId || callsite.workflowGuess,
|
|
195
198
|
file: callsite.file,
|
|
196
199
|
function_name: callsite.functionName,
|
|
197
200
|
line_number: callsite.line,
|
|
@@ -209,7 +212,7 @@ class MyNitor {
|
|
|
209
212
|
model: body?.model || 'unknown',
|
|
210
213
|
provider: 'anthropic',
|
|
211
214
|
agent: 'default-agent',
|
|
212
|
-
workflow: callsite.workflowGuess,
|
|
215
|
+
workflow: this.config.workflowId || callsite.workflowGuess,
|
|
213
216
|
file: callsite.file,
|
|
214
217
|
function_name: callsite.functionName,
|
|
215
218
|
latency_ms: end - start,
|
|
@@ -247,7 +250,7 @@ class MyNitor {
|
|
|
247
250
|
model: this.model || 'gemini',
|
|
248
251
|
provider: 'google',
|
|
249
252
|
agent: 'default-agent',
|
|
250
|
-
workflow: callsite.workflowGuess,
|
|
253
|
+
workflow: this.config.workflowId || callsite.workflowGuess,
|
|
251
254
|
file: callsite.file,
|
|
252
255
|
function_name: callsite.functionName,
|
|
253
256
|
line_number: callsite.line,
|
|
@@ -265,7 +268,7 @@ class MyNitor {
|
|
|
265
268
|
model: this.model || 'gemini',
|
|
266
269
|
provider: 'google',
|
|
267
270
|
agent: 'default-agent',
|
|
268
|
-
workflow: callsite.workflowGuess,
|
|
271
|
+
workflow: this.config.workflowId || callsite.workflowGuess,
|
|
269
272
|
file: callsite.file,
|
|
270
273
|
function_name: callsite.functionName,
|
|
271
274
|
latency_ms: end - start,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const index_1 = require("./index");
|
|
4
|
+
// Mock the config
|
|
5
|
+
const config = { apiKey: 'test-key' };
|
|
6
|
+
// @ts-ignore - access private static init for testing
|
|
7
|
+
const sdk = index_1.MyNitor.init(config);
|
|
8
|
+
// @ts-ignore - access private method for testing
|
|
9
|
+
const callsite = sdk.getCallSite();
|
|
10
|
+
console.log('Callsite Info:', callsite);
|
|
11
|
+
if (!callsite.workflowGuess.includes(':')) {
|
|
12
|
+
console.log('✅ PASS: Workflow guess does not contain function name.');
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
console.error('❌ FAIL: Workflow guess still contains function name.');
|
|
16
|
+
}
|
|
17
|
+
const config2 = { apiKey: 'test-key', workflowId: 'explicit-wf' };
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
const sdk2 = index_1.MyNitor.init(config2);
|
|
20
|
+
// Since we can't easily trigger a patched event in this tiny test,
|
|
21
|
+
// we'll just check if the config saved it.
|
|
22
|
+
// @ts-ignore
|
|
23
|
+
if (sdk2.config.workflowId === 'explicit-wf') {
|
|
24
|
+
console.log('✅ PASS: Config correctly stores explicit workflowId.');
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
console.error('❌ FAIL: Config failed to store explicit workflowId.');
|
|
28
|
+
}
|