npm-noxyai 1.0.0 → 1.0.2

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.
Files changed (2) hide show
  1. package/index.js +56 -2
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,2 +1,56 @@
1
- #!/usr/bin/env node
2
- console.log("NoxyAI CLI is running!");
1
+ // --- COMMAND: login ---
2
+ async function login() {
3
+ console.log('Initializing login...');
4
+ try {
5
+ const initRes = await fetch(`${BASE_URL}/api/cli/init`, { method: 'POST' });
6
+ const { deviceCode, verificationUrl, interval } = await initRes.json();
7
+
8
+ console.log('\n=============================================');
9
+ console.log('Action Required: Please authenticate your terminal');
10
+ console.log(`Open this URL in your browser:\n\n -> ${verificationUrl} <-`);
11
+ console.log('=============================================\n');
12
+ console.log('Waiting for confirmation...');
13
+
14
+ const pollInterval = setInterval(async () => {
15
+ const pollRes = await fetch(`${BASE_URL}/api/cli/poll`, {
16
+ method: 'POST',
17
+ headers: { 'Content-Type': 'application/json' },
18
+ body: JSON.stringify({ deviceCode })
19
+ });
20
+
21
+ const data = await pollRes.json();
22
+
23
+ if (data.status === 'success') {
24
+ clearInterval(pollInterval);
25
+ saveToken(data.token);
26
+
27
+ // ASCII ART SUCCESS MESSAGE
28
+ console.clear();
29
+ console.log(`\n\x1b[36m
30
+ ___ ___ ___ ___ ___
31
+ /\\__\\ /\\ \\ |\\__\\ |\\__\\ /\\ \\ ___
32
+ /::| | /::\\ \\ |:| | |:| | /::\\ \\ /\\ \\
33
+ /:|:| | /:/\\:\\ \\ |:| | |:| | /:/\\:\\ \\ \\:\\ \\
34
+ /:/|:| |__ /:/ \\:\\ \\ |:|__|__ |:|__|__ /::\\~\\:\\ \\ /::\\__\\
35
+ /:/ |:| /\\__\\ /:/__/ \\:\\__\\ ____/::::\\__\\ /::::\\__\\ /:/\\:\\ \\:\\__\\ __/:/\\/__/
36
+ \\/__|:|/:/ / \\:\\ \\ /:/ / \\::::/~~/~ /:/~~/~ \\/__\\:\\/:/ / /\\/:/ /
37
+ |:/:/ / \\:\\ /:/ / ~~|:|~~| /:/ / \\::/ / \\::/__/
38
+ |::/ / \\:\\/:/ / |:| | \\/__/ /:/ / \\:\\__\\
39
+ /:/ / \\::/ / |:| | /:/ / \\/__/
40
+ \\/__/ \\/__/ \\|__| \\/__/
41
+ \x1b[0m`);
42
+ console.log('\n✅ Login successful! Terminal connected.');
43
+ console.log('Try running: noxyai chat "Hello, world!"\n');
44
+ process.exit(0);
45
+ } else if (data.error) {
46
+ clearInterval(pollInterval);
47
+ console.error(`\n❌ Login failed: ${data.error}`);
48
+ process.exit(1);
49
+ }
50
+ }, interval * 1000);
51
+
52
+ } catch (error) {
53
+ console.error('Failed to connect to NoxyAI server.', error.message);
54
+ }
55
+ }
56
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "npm-noxyai",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {