recoder-code 2.2.8 ā 2.2.9
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/cli/simple-setup.js +7 -7
- package/cli/user-onboarding.js +65 -5
- package/package.json +2 -2
- package/setup.js +6 -4
package/cli/simple-setup.js
CHANGED
|
@@ -137,30 +137,30 @@ class SimpleSetup {
|
|
|
137
137
|
async testApiKey(apiKey) {
|
|
138
138
|
try {
|
|
139
139
|
const https = require('https');
|
|
140
|
-
|
|
140
|
+
|
|
141
141
|
return new Promise((resolve) => {
|
|
142
142
|
const options = {
|
|
143
|
-
hostname: '
|
|
143
|
+
hostname: 'openrouter.ai',
|
|
144
144
|
port: 443,
|
|
145
|
-
path: '/v1/models',
|
|
145
|
+
path: '/api/v1/models',
|
|
146
146
|
method: 'GET',
|
|
147
147
|
headers: {
|
|
148
148
|
'Authorization': `Bearer ${apiKey}`,
|
|
149
149
|
'Content-Type': 'application/json'
|
|
150
150
|
},
|
|
151
|
-
timeout:
|
|
151
|
+
timeout: 10000
|
|
152
152
|
};
|
|
153
|
-
|
|
153
|
+
|
|
154
154
|
const req = https.request(options, (res) => {
|
|
155
155
|
resolve(res.statusCode === 200);
|
|
156
156
|
});
|
|
157
|
-
|
|
157
|
+
|
|
158
158
|
req.on('error', () => resolve(false));
|
|
159
159
|
req.on('timeout', () => {
|
|
160
160
|
req.destroy();
|
|
161
161
|
resolve(false);
|
|
162
162
|
});
|
|
163
|
-
|
|
163
|
+
|
|
164
164
|
req.end();
|
|
165
165
|
});
|
|
166
166
|
} catch (error) {
|
package/cli/user-onboarding.js
CHANGED
|
@@ -74,6 +74,43 @@ class UserOnboarding {
|
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
/**
|
|
78
|
+
* Test API key validity
|
|
79
|
+
*/
|
|
80
|
+
async testApiKey(apiKey) {
|
|
81
|
+
try {
|
|
82
|
+
const https = require('https');
|
|
83
|
+
|
|
84
|
+
return new Promise((resolve) => {
|
|
85
|
+
const options = {
|
|
86
|
+
hostname: 'openrouter.ai',
|
|
87
|
+
port: 443,
|
|
88
|
+
path: '/api/v1/models',
|
|
89
|
+
method: 'GET',
|
|
90
|
+
headers: {
|
|
91
|
+
'Authorization': `Bearer ${apiKey}`,
|
|
92
|
+
'Content-Type': 'application/json'
|
|
93
|
+
},
|
|
94
|
+
timeout: 10000
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const req = https.request(options, (res) => {
|
|
98
|
+
resolve(res.statusCode === 200);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
req.on('error', () => resolve(false));
|
|
102
|
+
req.on('timeout', () => {
|
|
103
|
+
req.destroy();
|
|
104
|
+
resolve(false);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
req.end();
|
|
108
|
+
});
|
|
109
|
+
} catch (error) {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
77
114
|
/**
|
|
78
115
|
* Get API key from user
|
|
79
116
|
*/
|
|
@@ -81,12 +118,35 @@ class UserOnboarding {
|
|
|
81
118
|
console.log(chalk.yellow('\nš API Key Setup'));
|
|
82
119
|
console.log(chalk.white('To use Recoder Code, you need an API key from OpenRouter.'));
|
|
83
120
|
console.log(chalk.gray('š” Get your free API key at: https://openrouter.ai/keys\n'));
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
121
|
+
|
|
122
|
+
while (true) {
|
|
123
|
+
const apiKey = await new Promise((resolve) => {
|
|
124
|
+
this.rl.question(chalk.cyan('Enter your OpenRouter API key: '), (answer) => {
|
|
125
|
+
resolve(answer.trim());
|
|
126
|
+
});
|
|
88
127
|
});
|
|
89
|
-
|
|
128
|
+
|
|
129
|
+
if (!apiKey || apiKey.length === 0) {
|
|
130
|
+
console.log(chalk.red('ā API key cannot be empty\n'));
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (!apiKey.startsWith('sk-or-v1-')) {
|
|
135
|
+
console.log(chalk.red('ā Invalid format. OpenRouter keys start with "sk-or-v1-"\n'));
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Test the API key
|
|
140
|
+
console.log(chalk.gray('š Testing API key...'));
|
|
141
|
+
const isValid = await this.testApiKey(apiKey);
|
|
142
|
+
|
|
143
|
+
if (isValid) {
|
|
144
|
+
console.log(chalk.green('ā
API key is valid!\n'));
|
|
145
|
+
return apiKey;
|
|
146
|
+
} else {
|
|
147
|
+
console.log(chalk.red('ā API key test failed. Please check and try again.\n'));
|
|
148
|
+
}
|
|
149
|
+
}
|
|
90
150
|
}
|
|
91
151
|
|
|
92
152
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "recoder-code",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.9",
|
|
4
4
|
"description": "š AI-powered development platform - Chat with 32+ models, build projects, automate workflows. Free models included!",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"production:check": "npm run lint && npm run typecheck && npm run security:audit",
|
|
35
35
|
"production:bundle": "npm run production:check && npm run build:production",
|
|
36
36
|
"production:deploy": "npm run production:bundle && npm publish --access public",
|
|
37
|
-
"postinstall": "node -e \"console.log('\\\\nš Recoder-Code v2.2.
|
|
37
|
+
"postinstall": "node -e \"console.log('\\\\nš Recoder-Code v2.2.9 installed!\\\\n\\\\nā
Quick Start: recoder-code\\\\nš” Get API key: https://openrouter.ai\\\\n')\"",
|
|
38
38
|
"prepare": "echo 'Package prepared for distribution'",
|
|
39
39
|
"prepublishOnly": "npm run prepare && npm run security:audit"
|
|
40
40
|
},
|
package/setup.js
CHANGED
|
@@ -481,14 +481,15 @@ class EnhancedSetupWizard {
|
|
|
481
481
|
process.stdout.write(question);
|
|
482
482
|
process.stdin.setRawMode(true);
|
|
483
483
|
process.stdin.resume();
|
|
484
|
-
|
|
484
|
+
|
|
485
485
|
let password = '';
|
|
486
|
-
|
|
486
|
+
const dataHandler = (char) => {
|
|
487
487
|
char = char.toString();
|
|
488
|
-
|
|
488
|
+
|
|
489
489
|
if (char === '\r' || char === '\n') {
|
|
490
490
|
process.stdin.setRawMode(false);
|
|
491
491
|
process.stdin.pause();
|
|
492
|
+
process.stdin.removeListener('data', dataHandler);
|
|
492
493
|
process.stdout.write('\n');
|
|
493
494
|
resolve(password);
|
|
494
495
|
} else if (char === '\u0003') {
|
|
@@ -502,7 +503,8 @@ class EnhancedSetupWizard {
|
|
|
502
503
|
password += char;
|
|
503
504
|
process.stdout.write('*');
|
|
504
505
|
}
|
|
505
|
-
}
|
|
506
|
+
};
|
|
507
|
+
process.stdin.on('data', dataHandler);
|
|
506
508
|
} else {
|
|
507
509
|
this.rl.question(question, resolve);
|
|
508
510
|
}
|