@cloudverse/aix-cli 1.1.1 → 1.2.1
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/index.js +26 -22
- 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
|
-
|
|
58
|
-
|
|
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) {
|
|
@@ -142,6 +142,7 @@ program
|
|
|
142
142
|
.option('--compliance-tier <string>', 'Compliance tier (passed through)')
|
|
143
143
|
.option('--input-tokens <number>', 'Estimated input tokens for cost simulation')
|
|
144
144
|
.option('--output-tokens <number>', 'Estimated output tokens for cost simulation')
|
|
145
|
+
.option('--preferred-providers <string>', 'Comma-separated list of preferred provider names (scoring boost)')
|
|
145
146
|
.option('--intent-json <path>', 'Path to JSON file with full request payload')
|
|
146
147
|
.option('--format <string>', 'Output format: pretty | json', 'pretty')
|
|
147
148
|
.action(async (opts) => {
|
|
@@ -183,6 +184,9 @@ program
|
|
|
183
184
|
if (opts.outputTokens)
|
|
184
185
|
payload.token_estimates.output_tokens = parseInt(opts.outputTokens);
|
|
185
186
|
}
|
|
187
|
+
if (opts.preferredProviders) {
|
|
188
|
+
payload.preferred_providers = opts.preferredProviders.split(',').map((s) => s.trim());
|
|
189
|
+
}
|
|
186
190
|
}
|
|
187
191
|
const res = await request('POST', '/api/brain/decide', payload);
|
|
188
192
|
if (!res.ok) {
|