ropilot 0.1.30 → 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.
- package/lib/proxy.js +44 -2
- package/lib/setup.js +8 -22
- 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/lib/setup.js
CHANGED
|
@@ -246,31 +246,17 @@ function getDefaultPrompts() {
|
|
|
246
246
|
}
|
|
247
247
|
|
|
248
248
|
/**
|
|
249
|
-
* Generate
|
|
250
|
-
* Windows needs cmd /c wrapper for npx to work properly
|
|
249
|
+
* Generate .mcp.json for Claude Code MCP server configuration
|
|
251
250
|
*/
|
|
252
251
|
function generateMcpJson() {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
ropilot: {
|
|
259
|
-
command: "cmd",
|
|
260
|
-
args: ["/c", "npx", "ropilot", "serve"]
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
}, null, 2);
|
|
264
|
-
} else {
|
|
265
|
-
return JSON.stringify({
|
|
266
|
-
mcpServers: {
|
|
267
|
-
ropilot: {
|
|
268
|
-
command: "npx",
|
|
269
|
-
args: ["ropilot", "serve"]
|
|
270
|
-
}
|
|
252
|
+
return JSON.stringify({
|
|
253
|
+
mcpServers: {
|
|
254
|
+
ropilot: {
|
|
255
|
+
command: "npx",
|
|
256
|
+
args: ["ropilot", "serve"]
|
|
271
257
|
}
|
|
272
|
-
}
|
|
273
|
-
}
|
|
258
|
+
}
|
|
259
|
+
}, null, 2);
|
|
274
260
|
}
|
|
275
261
|
|
|
276
262
|
/**
|