@mynitorai/sdk 0.2.5 → 0.2.6
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/cli.js +68 -0
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -11,6 +11,74 @@ async function run() {
|
|
|
11
11
|
process.exit(1);
|
|
12
12
|
}
|
|
13
13
|
const command = process.argv[2];
|
|
14
|
+
if (command === 'doctor') {
|
|
15
|
+
const pkg = require('../package.json');
|
|
16
|
+
console.log(`🩺 MyNitor Doctor (v${pkg.version})`);
|
|
17
|
+
console.log('---------------------------');
|
|
18
|
+
if (!apiKey) {
|
|
19
|
+
console.error('❌ API Key: Missing (MYNITOR_API_KEY not found in env)');
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
const prefix = apiKey.substring(0, 8);
|
|
23
|
+
const last4 = apiKey.substring(apiKey.length - 4);
|
|
24
|
+
console.log(`✅ API Key: Detected (${prefix}...${last4})`);
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
console.log('📡 Testing Connection...');
|
|
28
|
+
const res = await fetch('https://app.mynitor.ai/api/v1/onboarding/status', {
|
|
29
|
+
headers: { 'Authorization': `Bearer ${apiKey}` }
|
|
30
|
+
});
|
|
31
|
+
if (res.ok) {
|
|
32
|
+
const data = await res.json();
|
|
33
|
+
console.log(`✅ Connection: MyNitor Cloud is reachable`);
|
|
34
|
+
console.log(`✅ Organization: ${data.orgId || 'Verified'}`);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
console.error(`❌ Connection: API returned ${res.status} (${res.statusText})`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
console.error('❌ Connection: Failed to reach app.mynitor.ai');
|
|
42
|
+
}
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (command === 'mock') {
|
|
46
|
+
console.log('🎭 MyNitor: Sending mock OpenAI event to Cloud API...');
|
|
47
|
+
try {
|
|
48
|
+
const response = await fetch('https://app.mynitor.ai/api/v1/events', {
|
|
49
|
+
method: 'POST',
|
|
50
|
+
headers: {
|
|
51
|
+
'Content-Type': 'application/json',
|
|
52
|
+
'Authorization': `Bearer ${apiKey}`
|
|
53
|
+
},
|
|
54
|
+
body: JSON.stringify({
|
|
55
|
+
event_version: '1.0',
|
|
56
|
+
timestamp: new Date().toISOString(),
|
|
57
|
+
agent: 'mynitor-cli-mock',
|
|
58
|
+
workflow: 'diagnostic-mock',
|
|
59
|
+
provider: 'openai',
|
|
60
|
+
model: 'gpt-4o',
|
|
61
|
+
input_tokens: 150,
|
|
62
|
+
output_tokens: 450,
|
|
63
|
+
latency_ms: 1200,
|
|
64
|
+
status: 'success',
|
|
65
|
+
metadata: { type: 'diagnostic-mock' }
|
|
66
|
+
})
|
|
67
|
+
});
|
|
68
|
+
if (response.ok) {
|
|
69
|
+
console.log('✅ Mock event sent successfully!');
|
|
70
|
+
console.log('✨ Check your dashboard /events page to see the generated data.');
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
const text = await response.text();
|
|
74
|
+
console.error(`❌ Failed: ${response.status} ${text}`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
console.error('❌ Network Error:', error);
|
|
79
|
+
}
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
14
82
|
if (command === 'ping') {
|
|
15
83
|
console.log('🚀 MyNitor: Sending verification signal to Cloud API...');
|
|
16
84
|
try {
|