@arcteninc/core 0.0.131 → 0.0.133

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcteninc/core",
3
- "version": "0.0.131",
3
+ "version": "0.0.133",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
@@ -350,6 +350,37 @@ async function getUserIntent(rl: readline.Interface): Promise<string> {
350
350
  return intent;
351
351
  }
352
352
 
353
+ // Helper: Get JWT token from API key
354
+ async function getAuthToken(apiKey: string, serverUrl: string): Promise<string> {
355
+ try {
356
+ const response = await fetch(`${serverUrl}/token`, {
357
+ method: 'POST',
358
+ headers: {
359
+ 'Content-Type': 'application/json',
360
+ },
361
+ body: JSON.stringify({ apiKey }),
362
+ });
363
+
364
+ if (!response.ok) {
365
+ const error = await response.json();
366
+ throw new Error(error.error || 'Failed to authenticate');
367
+ }
368
+
369
+ const data = await response.json();
370
+ return data.token;
371
+ } catch (error: any) {
372
+ if (error.cause?.code === 'ENOTFOUND' || error.cause?.code === 'ECONNREFUSED' || error.message.includes('fetch')) {
373
+ console.error(`\n❌ Unable to connect to: ${serverUrl}`);
374
+ console.error('\nPossible issues:');
375
+ console.error(' • No internet connection');
376
+ console.error(' • API server is down');
377
+ console.error(' • Firewall blocking the request');
378
+ throw new Error('Connection failed');
379
+ }
380
+ throw error;
381
+ }
382
+ }
383
+
353
384
  // Step 4: Estimate cost
354
385
  async function estimateCost(apiKey: string, serverUrl: string, context: CodebaseContext): Promise<AnalysisEstimate> {
355
386
  console.log('\n💰 Estimating analysis cost...\n');
@@ -420,11 +451,14 @@ async function runAnalysis(
420
451
  ): Promise<AnalysisResult> {
421
452
  console.log('\n🤖 Analyzing with AI...\n');
422
453
 
454
+ // Get JWT token from API key
455
+ const token = await getAuthToken(apiKey, serverUrl);
456
+
423
457
  const response = await fetch(`${serverUrl}/tools/analyze`, {
424
458
  method: 'POST',
425
459
  headers: {
426
460
  'Content-Type': 'application/json',
427
- 'Authorization': `Bearer ${apiKey}`,
461
+ 'Authorization': `Bearer ${token}`,
428
462
  },
429
463
  body: JSON.stringify({ context, userIntent }),
430
464
  });
@@ -664,8 +698,8 @@ async function main() {
664
698
  }
665
699
 
666
700
  const rl = createPrompt();
667
- const serverUrl = process.env.ARCTEN_SERVER_URL || 'https://api.arcten.ai';
668
- const convexUrl = process.env.CONVEX_URL || 'https://convex.arcten.ai';
701
+ const serverUrl = process.env.ARCTEN_SERVER_URL || 'https://api.arcten.com';
702
+ const convexUrl = process.env.CONVEX_URL || 'https://convex.arcten.com';
669
703
 
670
704
  try {
671
705
  // Check for existing setup