@erosolaraijs/cure 2.6.1 → 2.7.0

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": "@erosolaraijs/cure",
3
- "version": "2.6.1",
3
+ "version": "2.7.0",
4
4
  "description": "AI-powered unified cancer treatment framework with multi-provider support for medical research and patient care",
5
5
  "main": "dist/bin/cure.js",
6
6
  "type": "module",
package/src/bin/cure.ts CHANGED
@@ -351,12 +351,15 @@ async function callXAI(userMessage: string): Promise<string> {
351
351
 
352
352
  resolve(assistantMessage);
353
353
  } else if (response.error) {
354
- resolve(`${colors.red}API Error: ${response.error.message}${colors.reset}`);
354
+ const errMsg = typeof response.error === 'string'
355
+ ? response.error
356
+ : response.error.message || response.error.code || JSON.stringify(response.error);
357
+ resolve(`${colors.red}API Error: ${errMsg}${colors.reset}`);
355
358
  } else {
356
- resolve(`${colors.red}Unexpected response format${colors.reset}`);
359
+ resolve(`${colors.red}Unexpected response: ${JSON.stringify(response).slice(0, 300)}${colors.reset}`);
357
360
  }
358
361
  } catch (e) {
359
- resolve(`${colors.red}Failed to parse response${colors.reset}`);
362
+ resolve(`${colors.red}Failed to parse response: ${data.slice(0, 200)}${colors.reset}`);
360
363
  }
361
364
  });
362
365
  });
@@ -426,12 +429,15 @@ async function callOpenAI(userMessage: string): Promise<string> {
426
429
 
427
430
  resolve(assistantMessage);
428
431
  } else if (response.error) {
429
- resolve(`${colors.red}API Error: ${response.error.message}${colors.reset}`);
432
+ const errMsg = typeof response.error === 'string'
433
+ ? response.error
434
+ : response.error.message || response.error.code || JSON.stringify(response.error);
435
+ resolve(`${colors.red}API Error: ${errMsg}${colors.reset}`);
430
436
  } else {
431
- resolve(`${colors.red}Unexpected response format${colors.reset}`);
437
+ resolve(`${colors.red}Unexpected response: ${JSON.stringify(response).slice(0, 300)}${colors.reset}`);
432
438
  }
433
439
  } catch (e) {
434
- resolve(`${colors.red}Failed to parse response${colors.reset}`);
440
+ resolve(`${colors.red}Failed to parse response: ${data.slice(0, 200)}${colors.reset}`);
435
441
  }
436
442
  });
437
443
  });
@@ -680,6 +686,121 @@ async function processInput(input: string): Promise<void> {
680
686
  }
681
687
  }
682
688
 
689
+ // Intelligent intent detection - auto-run tools for cancer cure requests
690
+ const lowerInput = input.toLowerCase();
691
+
692
+ // Detect "cure cancer" intent
693
+ if (lowerInput.includes('cure') && (lowerInput.includes('cancer') || lowerInput.includes('tumor') || lowerInput.includes('oncolog'))) {
694
+ console.log(`\n${colors.cyan}🧬 Activating Cancer Cure Protocol...${colors.reset}\n`);
695
+
696
+ // Extract cancer type if mentioned
697
+ const cancerTypes: Record<string, string> = {
698
+ 'lung': 'NSCLC', 'nsclc': 'NSCLC', 'sclc': 'SCLC',
699
+ 'breast': 'Breast', 'brca': 'Breast',
700
+ 'colon': 'Colorectal', 'colorectal': 'Colorectal', 'rectal': 'Colorectal',
701
+ 'prostate': 'Prostate', 'pancreatic': 'Pancreatic', 'pancreas': 'Pancreatic',
702
+ 'liver': 'Liver', 'hepatocellular': 'Liver', 'hcc': 'Liver',
703
+ 'kidney': 'Kidney', 'renal': 'Kidney', 'rcc': 'Kidney',
704
+ 'bladder': 'Bladder', 'melanoma': 'Melanoma', 'skin': 'Melanoma',
705
+ 'leukemia': 'Leukemia', 'aml': 'AML', 'all': 'ALL', 'cml': 'CML', 'cll': 'CLL',
706
+ 'lymphoma': 'Lymphoma', 'hodgkin': 'Hodgkin', 'nhl': 'NHL',
707
+ 'myeloma': 'Myeloma', 'multiple myeloma': 'Myeloma',
708
+ 'ovarian': 'Ovarian', 'cervical': 'Cervical', 'uterine': 'Uterine', 'endometrial': 'Endometrial',
709
+ 'gastric': 'Gastric', 'stomach': 'Gastric', 'esophageal': 'Esophageal',
710
+ 'brain': 'Brain', 'glioblastoma': 'GBM', 'gbm': 'GBM', 'glioma': 'Glioma',
711
+ 'thyroid': 'Thyroid', 'head and neck': 'HeadNeck', 'hnscc': 'HNSCC',
712
+ 'sarcoma': 'Sarcoma', 'bone': 'Bone', 'testicular': 'Testicular'
713
+ };
714
+
715
+ let detectedCancer = 'Comprehensive';
716
+ let detectedStage = 'All';
717
+ const detectedMutations: string[] = [];
718
+
719
+ for (const [keyword, cancerName] of Object.entries(cancerTypes)) {
720
+ if (lowerInput.includes(keyword)) {
721
+ detectedCancer = cancerName;
722
+ break;
723
+ }
724
+ }
725
+
726
+ // Extract stage if mentioned
727
+ const stageMatch = lowerInput.match(/stage\s*([iv1234]+|[1-4]|early|late|advanced|metastatic)/i);
728
+ if (stageMatch) {
729
+ const stageMap: Record<string, string> = {
730
+ 'i': 'I', '1': 'I', 'early': 'I-II',
731
+ 'ii': 'II', '2': 'II',
732
+ 'iii': 'III', '3': 'III',
733
+ 'iv': 'IV', '4': 'IV', 'late': 'IV', 'advanced': 'III-IV', 'metastatic': 'IV'
734
+ };
735
+ detectedStage = stageMap[stageMatch[1].toLowerCase()] || stageMatch[1].toUpperCase();
736
+ }
737
+
738
+ // Extract mutations if mentioned
739
+ const mutationPatterns = ['egfr', 'kras', 'braf', 'her2', 'alk', 'ros1', 'ntrk', 'met', 'ret', 'brca', 'tp53', 'pik3ca', 'pd-l1', 'msi-h', 'tmb-h'];
740
+ for (const mut of mutationPatterns) {
741
+ if (lowerInput.includes(mut)) {
742
+ detectedMutations.push(mut.toUpperCase().replace('-', '_'));
743
+ }
744
+ }
745
+
746
+ console.log(`${colors.bold}Detected Parameters:${colors.reset}`);
747
+ console.log(` Cancer Type: ${colors.yellow}${detectedCancer}${colors.reset}`);
748
+ console.log(` Stage: ${colors.yellow}${detectedStage}${colors.reset}`);
749
+ if (detectedMutations.length > 0) {
750
+ console.log(` Mutations: ${colors.yellow}${detectedMutations.join(', ')}${colors.reset}`);
751
+ }
752
+ console.log();
753
+
754
+ // Run the comprehensive cure protocol
755
+ await generateCureProtocol(detectedCancer, detectedStage, detectedMutations);
756
+
757
+ // Also run clinical trials search
758
+ console.log(`\n${colors.cyan}🔬 Searching Clinical Trials...${colors.reset}\n`);
759
+ await findClinicalTrials(detectedCancer, detectedMutations);
760
+
761
+ // Run drug discovery for key targets
762
+ if (detectedMutations.length > 0) {
763
+ console.log(`\n${colors.cyan}💊 Analyzing Drug Targets...${colors.reset}\n`);
764
+ await discoverTargets(detectedMutations[0], detectedCancer);
765
+ }
766
+
767
+ // Now enhance with AI analysis
768
+ console.log(`\n${colors.cyan}🤖 AI Analysis...${colors.reset}`);
769
+ const enhancedPrompt = `Based on the cure protocol, clinical trials, and drug targets shown above for ${detectedCancer} cancer (stage ${detectedStage}${detectedMutations.length > 0 ? `, mutations: ${detectedMutations.join(', ')}` : ''}), provide a brief personalized summary with:
770
+ 1. Top 3 recommended treatment approaches in order of priority
771
+ 2. Most promising clinical trial categories to explore
772
+ 3. Key biomarkers to test if not already done
773
+ 4. Expected outcomes with current best treatments
774
+ Keep it concise and actionable.`;
775
+
776
+ const aiResponse = await callAI(enhancedPrompt);
777
+ console.log(`\n${aiResponse}`);
778
+ return;
779
+ }
780
+
781
+ // Detect treatment/drug questions - run safety checks
782
+ if ((lowerInput.includes('drug') || lowerInput.includes('medication') || lowerInput.includes('treatment')) &&
783
+ (lowerInput.includes('interact') || lowerInput.includes('safe') || lowerInput.includes('combine'))) {
784
+ // Extract drug names and run safety check
785
+ const commonDrugs = ['pembrolizumab', 'nivolumab', 'atezolizumab', 'ipilimumab', 'trastuzumab', 'bevacizumab',
786
+ 'osimertinib', 'alectinib', 'crizotinib', 'dabrafenib', 'trametinib', 'vemurafenib', 'sotorasib',
787
+ 'olaparib', 'rucaparib', 'niraparib', 'carboplatin', 'cisplatin', 'paclitaxel', 'docetaxel',
788
+ 'doxorubicin', 'cyclophosphamide', 'methotrexate', 'fluorouracil', '5-fu', 'capecitabine',
789
+ 'irinotecan', 'oxaliplatin', 'gemcitabine', 'pemetrexed', 'rituximab', 'obinutuzumab'];
790
+
791
+ const foundDrugs: string[] = [];
792
+ for (const drug of commonDrugs) {
793
+ if (lowerInput.includes(drug)) {
794
+ foundDrugs.push(drug.charAt(0).toUpperCase() + drug.slice(1));
795
+ }
796
+ }
797
+
798
+ if (foundDrugs.length >= 2) {
799
+ console.log(`\n${colors.cyan}💊 Running Drug Safety Check...${colors.reset}\n`);
800
+ await checkDrugSafety(foundDrugs[0], foundDrugs[1], foundDrugs.slice(2));
801
+ }
802
+ }
803
+
683
804
  // AI-powered response for natural language
684
805
  console.log(`\n${colors.dim}Thinking...${colors.reset}`);
685
806
  const response = await callAI(input);