@cloudverse/aix-cli 1.1.1 → 1.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.
Files changed (2) hide show
  1. package/dist/index.js +22 -22
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -21,26 +21,6 @@ program
21
21
  console.log('\n\x1b[1mAIX Device Login\x1b[0m');
22
22
  console.log('─'.repeat(50));
23
23
  console.log(` Server: ${baseUrl}\n`);
24
- let startRes;
25
- try {
26
- startRes = await request('POST', '/api/auth/device/start', {
27
- cli_version: '1.1.0',
28
- });
29
- }
30
- catch (err) {
31
- exitWithError(`Cannot connect to AIX server at ${baseUrl}`, `Network error: ${err.message}\n Try: aix login --api-url https://your-server-url`);
32
- }
33
- if (!startRes.ok) {
34
- exitWithError('Failed to start device login', JSON.stringify(startRes.data, null, 2));
35
- }
36
- const { device_code, user_code, verification_uri, verification_uri_complete, interval, expires_in } = startRes.data;
37
- if (!user_code || !verification_uri_complete || !device_code) {
38
- exitWithError('Unexpected response from server (missing device login fields)', `Server may not support device login, or the URL is incorrect.\n Server: ${baseUrl}\n Response: ${JSON.stringify(startRes.data, null, 2)}\n Try: aix login --api-url https://your-server-url`);
39
- }
40
- console.log(`\n Your verification code:\n`);
41
- console.log(` \x1b[1m\x1b[36m${user_code}\x1b[0m\n`);
42
- console.log(` Opening browser to:\n`);
43
- console.log(` \x1b[4m${verification_uri_complete}\x1b[0m\n`);
44
24
  const openBrowser = async (url) => {
45
25
  const { exec } = await import('child_process');
46
26
  const platform = process.platform;
@@ -54,8 +34,28 @@ program
54
34
  }
55
35
  });
56
36
  };
57
- await openBrowser(verification_uri_complete);
58
- console.log(` Waiting for approval (expires in ${Math.floor(expires_in / 60)} minutes)...\n`);
37
+ let startRes;
38
+ try {
39
+ startRes = await request('POST', '/api/auth/device/start', {
40
+ cli_version: '1.1.1',
41
+ });
42
+ }
43
+ catch (err) {
44
+ exitWithError(`Cannot connect to AIX server at ${baseUrl}`, `Network error: ${err.message}\n Try: aix login --api-url https://your-server-url`);
45
+ }
46
+ if (!startRes.ok) {
47
+ exitWithError('Failed to start device login', JSON.stringify(startRes.data, null, 2));
48
+ }
49
+ const { device_code, user_code, interval, expires_in } = startRes.data;
50
+ if (!user_code || !device_code) {
51
+ exitWithError('Unexpected response from server (missing device login fields)', `Server may not support device login, or the URL is incorrect.\n Server: ${baseUrl}\n Response: ${JSON.stringify(startRes.data, null, 2)}\n Try: aix login --api-url https://your-server-url`);
52
+ }
53
+ const authUrl = `${baseUrl}/cli-auth?user_code=${user_code}`;
54
+ console.log(' Opening browser to authenticate...\n');
55
+ await openBrowser(authUrl);
56
+ console.log(` If the browser didn't open, visit:\n`);
57
+ console.log(` \x1b[4m${authUrl}\x1b[0m\n`);
58
+ console.log(' Waiting for approval...\n');
59
59
  const deadline = Date.now() + expires_in * 1000;
60
60
  let pollInterval = interval * 1000;
61
61
  while (Date.now() < deadline) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudverse/aix-cli",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "description": "AIX Brain Decision Engine CLI - decision-only surface for AI workload routing",
5
5
  "type": "module",
6
6
  "bin": {