npm-noxyai 1.0.4 → 1.0.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.
@@ -25,30 +25,31 @@ function getToken() {
25
25
  async function login() {
26
26
  console.log('Initializing login...');
27
27
  try {
28
- const initRes = await fetch(`${BASE_URL}/api/cli/init`, { method: 'POST' });
28
+ const initRes = await fetch(BASE_URL + '/api/cli/init', { method: 'POST' });
29
29
  const { deviceCode, verificationUrl, interval } = await initRes.json();
30
30
 
31
31
  console.log('\n=============================================');
32
32
  console.log('Action Required: Please authenticate your terminal');
33
- console.log(`Open this URL in your browser:\n\n -> ${verificationUrl} <-`);
33
+ console.log('Open this URL in your browser:\n\n -> ' + verificationUrl + ' <-');
34
34
  console.log('=============================================\n');
35
35
  console.log('Waiting for confirmation...');
36
36
 
37
37
  const pollInterval = setInterval(async () => {
38
- const pollRes = await fetch(`${BASE_URL}/api/cli/poll`, {
39
- method: 'POST',
40
- headers: { 'Content-Type': 'application/json' },
41
- body: JSON.stringify({ deviceCode })
42
- });
43
-
44
- const data = await pollRes.json();
45
-
46
- if (data.status === 'success') {
47
- clearInterval(pollInterval);
48
- saveToken(data.token);
38
+ try {
39
+ const pollRes = await fetch(BASE_URL + '/api/cli/poll', {
40
+ method: 'POST',
41
+ headers: { 'Content-Type': 'application/json' },
42
+ body: JSON.stringify({ deviceCode })
43
+ });
49
44
 
50
- console.clear();
51
- console.log('\x1b[36m' +
45
+ const data = await pollRes.json();
46
+
47
+ if (data.status === 'success') {
48
+ clearInterval(pollInterval);
49
+ saveToken(data.token);
50
+
51
+ console.clear();
52
+ console.log('\x1b[36m' +
52
53
  ` ___ ___ ___ ___ ___
53
54
  /\\__\\ /\\ \\ |\\__\\ |\\__\\ /\\ \\ ___
54
55
  /::| | /::\\ \\ |:| | |:| | /::\\ \\ /\\ \\
@@ -60,14 +61,15 @@ async function login() {
60
61
  |::/ / \\:\\/:/ / |:| | \\/__/ /:/ / \\:\\__\\
61
62
  /:/ / \\::/ / |:| | /:/ / \\/__/
62
63
  \\/__/ \\/__/ \\|__| \\/__/` + '\x1b[0m');
63
- console.log('\n✅ Login successful! Terminal connected.');
64
- console.log('Try running: noxyai chat "Hello, world!"\n');
65
- process.exit(0);
66
- } else if (data.error) {
67
- clearInterval(pollInterval);
68
- console.error('\n❌ Login failed:', data.error);
69
- process.exit(1);
70
- }
64
+ console.log('\n✅ Login successful! Terminal connected.');
65
+ console.log('Try running: noxyai chat "Hello, world!"\n');
66
+ process.exit(0);
67
+ } else if (data.error) {
68
+ clearInterval(pollInterval);
69
+ console.error('\n❌ Login failed: ' + data.error);
70
+ process.exit(1);
71
+ }
72
+ } catch (e) {}
71
73
  }, interval * 1000);
72
74
 
73
75
  } catch (error) {
@@ -90,22 +92,22 @@ async function chat(prompt) {
90
92
  const model = 'auto';
91
93
 
92
94
  try {
93
- const res = await fetch(`${BASE_URL}/api/cli/execute`, {
95
+ const res = await fetch(BASE_URL + '/api/cli/execute', {
94
96
  method: 'POST',
95
97
  headers: {
96
98
  'Content-Type': 'application/json',
97
- 'Authorization': `Bearer ${token}`
99
+ 'Authorization': 'Bearer ' + token
98
100
  },
99
101
  body: JSON.stringify({ prompt, model })
100
102
  });
101
103
 
102
104
  if (!res.ok) {
103
105
  const errorText = await res.text();
104
- console.error(`\n❌ API Error: ${errorText}`);
106
+ console.error('\n❌ API Error: ' + errorText);
105
107
  process.exit(1);
106
108
  }
107
109
 
108
- console.log(`\n🤖 NoxyAI (${model}):\n`);
110
+ console.log('\n🤖 NoxyAI (' + model + '):\n');
109
111
 
110
112
  const reader = res.body.getReader();
111
113
  const decoder = new TextDecoder('utf-8');
@@ -134,7 +136,7 @@ async function chat(prompt) {
134
136
  }
135
137
  }
136
138
  } catch (error) {
137
- console.error('\n❌ Connection error:', error.message);
139
+ console.error('\n❌ Connection error: ' + error.message);
138
140
  }
139
141
  }
140
142
 
@@ -144,9 +146,5 @@ if (command === 'login') {
144
146
  const prompt = args.slice(1).join(' ');
145
147
  chat(prompt);
146
148
  } else {
147
- console.log(`
148
- Usage:
149
- noxyai login - Authenticate your terminal
150
- noxyai chat <prompt> - Chat with NoxyAI
151
- `);
149
+ console.log('\nUsage:\n noxyai login\n noxyai chat <prompt>\n');
152
150
  }
package/package.json CHANGED
@@ -1,13 +1,10 @@
1
1
  {
2
2
  "name": "npm-noxyai",
3
- "version": "1.0.4",
4
- "description": "",
5
- "main": "index.js",
3
+ "version": "1.0.6",
4
+ "description": "CLI for NoxyAI",
5
+ "main": "index-noxyai.js",
6
6
  "bin": {
7
- "noxyai": "./index.js"
8
- },
9
- "scripts": {
10
- "test": "echo \"Error: no test specified\" && exit 1"
7
+ "noxyai": "index-noxyai.js"
11
8
  },
12
9
  "author": "Mohammad Junaid Rather",
13
10
  "license": "ISC"