ropilot 0.1.31 → 0.1.32

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/lib/proxy.js +44 -2
  2. package/package.json +1 -1
package/lib/proxy.js CHANGED
@@ -177,6 +177,40 @@ async function checkPluginUpdate() {
177
177
  }
178
178
  }
179
179
 
180
+ /**
181
+ * Validate API key with edge server
182
+ * Returns { valid: true } or { valid: false, reason: string }
183
+ */
184
+ async function validateApiKey(apiKey) {
185
+ try {
186
+ const url = `${EDGE_URL}/mcp/${apiKey}`;
187
+ const response = await fetch(url, {
188
+ method: 'POST',
189
+ headers: { 'Content-Type': 'application/json' },
190
+ body: JSON.stringify({
191
+ jsonrpc: '2.0',
192
+ id: 0,
193
+ method: 'initialize',
194
+ params: { protocolVersion: '2024-11-05', capabilities: {}, clientInfo: { name: 'validate', version: '1.0.0' } }
195
+ })
196
+ });
197
+
198
+ if (response.status === 401 || response.status === 403) {
199
+ return { valid: false, reason: 'Invalid or expired API key' };
200
+ }
201
+ if (response.status === 402) {
202
+ return { valid: false, reason: 'No credits remaining - upgrade at https://ropilot.ai' };
203
+ }
204
+ if (!response.ok) {
205
+ return { valid: false, reason: `Server error: ${response.status}` };
206
+ }
207
+ return { valid: true };
208
+ } catch (err) {
209
+ // Network error - might be offline, let it proceed and fail later
210
+ return { valid: true };
211
+ }
212
+ }
213
+
180
214
  /**
181
215
  * Run the stdio MCP server
182
216
  */
@@ -184,8 +218,16 @@ export async function serve() {
184
218
  const apiKey = getApiKey();
185
219
 
186
220
  if (!apiKey) {
187
- console.error('No API key configured.');
188
- console.error('Run "npx ropilot init" to set up Ropilot.');
221
+ console.error('[Ropilot] No API key configured.');
222
+ console.error('[Ropilot] Run "npx ropilot init" to set up Ropilot.');
223
+ process.exit(1);
224
+ }
225
+
226
+ // Validate API key before starting
227
+ const validation = await validateApiKey(apiKey);
228
+ if (!validation.valid) {
229
+ console.error(`[Ropilot] ${validation.reason}`);
230
+ console.error('[Ropilot] Update your key with "npx ropilot init" or at https://ropilot.ai');
189
231
  process.exit(1);
190
232
  }
191
233
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ropilot",
3
- "version": "0.1.31",
3
+ "version": "0.1.32",
4
4
  "description": "AI-powered Roblox development assistant - MCP CLI",
5
5
  "author": "whut",
6
6
  "license": "MIT",