@mynitorai/sdk 0.2.3 → 0.2.4
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.d.ts +6 -0
- package/dist/cli.js +64 -0
- package/package.json +4 -1
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
/**
|
|
4
|
+
* MyNitor CLI - Quick Verification Utility
|
|
5
|
+
*/
|
|
6
|
+
const { init } = require('./index');
|
|
7
|
+
async function run() {
|
|
8
|
+
const apiKey = process.env.MYNITOR_API_KEY;
|
|
9
|
+
if (!apiKey) {
|
|
10
|
+
console.error('❌ Error: MYNITOR_API_KEY environment variable is not set.');
|
|
11
|
+
process.exit(1);
|
|
12
|
+
}
|
|
13
|
+
const command = process.argv[2];
|
|
14
|
+
if (command === 'ping') {
|
|
15
|
+
console.log('🚀 MyNitor: Sending verification signal to Cloud API...');
|
|
16
|
+
try {
|
|
17
|
+
const mn = init({
|
|
18
|
+
apiKey,
|
|
19
|
+
environment: 'onboarding-test'
|
|
20
|
+
});
|
|
21
|
+
// Trigger a manual event to verify connection
|
|
22
|
+
// We use a custom internal method or just a standard track if available
|
|
23
|
+
// In the current SDK, we can use the private sendEvent if it were public,
|
|
24
|
+
// or just trigger instrument() and a small log.
|
|
25
|
+
// For now, let's just use a fetch directly to verify connectivity
|
|
26
|
+
// and trigger the onboarding checkmark.
|
|
27
|
+
const endpoint = 'https://app.mynitor.ai/api/v1/events';
|
|
28
|
+
const response = await fetch(endpoint, {
|
|
29
|
+
method: 'POST',
|
|
30
|
+
headers: {
|
|
31
|
+
'Content-Type': 'application/json',
|
|
32
|
+
'Authorization': `Bearer ${apiKey}`
|
|
33
|
+
},
|
|
34
|
+
body: JSON.stringify({
|
|
35
|
+
event_version: '1.0',
|
|
36
|
+
timestamp: new Date().toISOString(),
|
|
37
|
+
agent: 'mynitor-cli',
|
|
38
|
+
workflow: 'onboarding-ping',
|
|
39
|
+
status: 'success',
|
|
40
|
+
metadata: { source: 'cli-ping' }
|
|
41
|
+
})
|
|
42
|
+
});
|
|
43
|
+
if (response.ok) {
|
|
44
|
+
console.log('✅ Connection verified! Event sent to MyNitor Cloud.');
|
|
45
|
+
console.log('✨ Check your onboarding dashboard for the green checkmark.');
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
const text = await response.text();
|
|
49
|
+
console.error(`❌ Failed to send event: ${response.status} ${response.statusText}`);
|
|
50
|
+
console.error(`Response: ${text}`);
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
console.error('❌ Network Error: Could not reach MyNitor Cloud.');
|
|
56
|
+
console.error(error);
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
console.log('Usage: npx @mynitorai/sdk ping');
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
run();
|
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mynitorai/sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "Production safety and observability for AI systems.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"mynitor": "dist/cli.js"
|
|
8
|
+
},
|
|
6
9
|
"types": "dist/index.d.ts",
|
|
7
10
|
"files": [
|
|
8
11
|
"dist"
|