@erosolaraijs/cure 1.0.2 → 1.0.3

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 (68) hide show
  1. package/dist/bin/cure.d.ts +1 -1
  2. package/dist/bin/cure.js +136 -66
  3. package/dist/bin/cure.js.map +1 -1
  4. package/dist/clinician/index.d.ts +1 -1
  5. package/dist/clinician/index.d.ts.map +1 -1
  6. package/dist/clinician/index.js +1 -1
  7. package/dist/clinician/index.js.map +1 -1
  8. package/dist/compliance/index.d.ts +1 -1
  9. package/dist/compliance/index.d.ts.map +1 -1
  10. package/dist/compliance/index.js +1 -1
  11. package/dist/compliance/index.js.map +1 -1
  12. package/dist/index.d.ts +65 -0
  13. package/dist/index.d.ts.map +1 -0
  14. package/dist/index.js +102 -0
  15. package/dist/index.js.map +1 -0
  16. package/dist/integrations/clinicalTrials/index.d.ts +1 -1
  17. package/dist/integrations/clinicalTrials/index.d.ts.map +1 -1
  18. package/dist/integrations/clinicalTrials/index.js +1 -1
  19. package/dist/integrations/clinicalTrials/index.js.map +1 -1
  20. package/dist/integrations/ehr/index.d.ts +1 -1
  21. package/dist/integrations/ehr/index.d.ts.map +1 -1
  22. package/dist/integrations/ehr/index.js +1 -1
  23. package/dist/integrations/ehr/index.js.map +1 -1
  24. package/dist/integrations/genomics/index.d.ts +1 -1
  25. package/dist/integrations/genomics/index.d.ts.map +1 -1
  26. package/dist/integrations/genomics/index.js +1 -1
  27. package/dist/integrations/genomics/index.js.map +1 -1
  28. package/dist/ml/index.d.ts +1 -1
  29. package/dist/ml/index.d.ts.map +1 -1
  30. package/dist/ml/index.js +1 -1
  31. package/dist/ml/index.js.map +1 -1
  32. package/dist/orchestrator/index.d.ts +5 -0
  33. package/dist/orchestrator/index.d.ts.map +1 -0
  34. package/dist/orchestrator/index.js +5 -0
  35. package/dist/orchestrator/index.js.map +1 -0
  36. package/dist/orchestrator/realWorldOncology.d.ts +351 -0
  37. package/dist/orchestrator/realWorldOncology.d.ts.map +1 -0
  38. package/dist/orchestrator/realWorldOncology.js +425 -0
  39. package/dist/orchestrator/realWorldOncology.js.map +1 -0
  40. package/dist/patient/index.d.ts +1 -1
  41. package/dist/patient/index.d.ts.map +1 -1
  42. package/dist/patient/index.js +1 -1
  43. package/dist/patient/index.js.map +1 -1
  44. package/dist/safety/index.d.ts +1 -1
  45. package/dist/safety/index.d.ts.map +1 -1
  46. package/dist/safety/index.js +1 -1
  47. package/dist/safety/index.js.map +1 -1
  48. package/dist/validation/index.d.ts +1 -1
  49. package/dist/validation/index.d.ts.map +1 -1
  50. package/dist/validation/index.js +1 -1
  51. package/dist/validation/index.js.map +1 -1
  52. package/package.json +1 -1
  53. package/src/bin/cure.ts +148 -70
  54. package/src/clinician/index.ts +11 -0
  55. package/src/compliance/index.ts +19 -0
  56. package/src/integrations/clinicalTrials/index.ts +21 -0
  57. package/src/integrations/ehr/index.ts +32 -0
  58. package/src/integrations/genomics/index.ts +23 -0
  59. package/src/ml/index.ts +15 -0
  60. package/src/orchestrator/index.ts +11 -0
  61. package/src/orchestrator/realWorldOncology.ts +803 -0
  62. package/src/patient/index.ts +14 -0
  63. package/src/safety/index.ts +14 -0
  64. package/src/validation/index.ts +10 -0
  65. package/dist/integrations/index.d.ts +0 -7
  66. package/dist/integrations/index.d.ts.map +0 -1
  67. package/dist/integrations/index.js +0 -10
  68. package/dist/integrations/index.js.map +0 -1
package/src/bin/cure.ts CHANGED
@@ -1,13 +1,15 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
3
  * Cure - AI Cancer Treatment Framework
4
- * Interactive CLI for precision oncology research and clinical decision support
4
+ * Interactive CLI powered by xAI Grok for precision oncology
5
5
  */
6
6
 
7
7
  import * as readline from 'readline';
8
+ import * as https from 'https';
8
9
  import { CancerTreatmentCapabilityModule } from '../capabilities/cancerTreatmentCapability.js';
9
10
 
10
- const VERSION = '1.0.2';
11
+ const VERSION = '1.0.3';
12
+ const XAI_MODEL = 'grok-4-1-fast-reasoning';
11
13
 
12
14
  // ANSI color codes
13
15
  const colors = {
@@ -24,26 +26,126 @@ const colors = {
24
26
  };
25
27
 
26
28
  let cancerTreatment: CancerTreatmentCapabilityModule;
29
+ let conversationHistory: Array<{role: string, content: string}> = [];
30
+
31
+ const SYSTEM_PROMPT = `You are Cure, an advanced AI oncologist assistant powered by the Cure Cancer Treatment Framework. You help doctors, researchers, and patients with:
32
+
33
+ 1. Cancer diagnosis and staging analysis
34
+ 2. Personalized treatment planning (chemotherapy, immunotherapy, targeted therapy, CAR-T)
35
+ 3. Drug target discovery and mechanism analysis
36
+ 4. Clinical trial matching and eligibility
37
+ 5. Genomic biomarker interpretation (EGFR, KRAS, BRAF, HER2, PD-L1, etc.)
38
+ 6. Treatment response prediction and survival analysis
39
+ 7. Drug interaction and safety checks
40
+ 8. HIPAA-compliant patient data handling
41
+
42
+ You have deep knowledge of:
43
+ - NCCN, ESMO, ASCO treatment guidelines
44
+ - FDA-approved cancer therapies and their mechanisms
45
+ - Precision medicine and molecular oncology
46
+ - Immunotherapy (checkpoint inhibitors, CAR-T, TILs)
47
+ - Targeted therapies for driver mutations
48
+ - Clinical trial design and interpretation
49
+
50
+ Be concise, scientifically accurate, and clinically relevant. When discussing specific treatments, cite evidence levels and relevant trials. Always recommend consulting with treating oncologists for actual patient care decisions.
51
+
52
+ Available commands the user can run:
53
+ - /analyze [patient_id] - Analyze patient data
54
+ - /plan [patient_id] - Design treatment plan
55
+ - /discover [gene] [cancer] - Drug target discovery
56
+ - /demo - Run framework demonstration
57
+ - /help - Show available commands`;
58
+
59
+ async function callXAI(userMessage: string): Promise<string> {
60
+ const apiKey = process.env.XAI_API_KEY;
61
+
62
+ if (!apiKey) {
63
+ return `${colors.yellow}Note: Set XAI_API_KEY environment variable for AI-powered responses.${colors.reset}\n\nI can help you with cancer treatment analysis. Try:\n /analyze P001 - Analyze patient\n /plan P001 - Design treatment plan\n /discover EGFR Lung - Find drug targets\n /demo - Run demonstration`;
64
+ }
65
+
66
+ conversationHistory.push({ role: 'user', content: userMessage });
67
+
68
+ const messages = [
69
+ { role: 'system', content: SYSTEM_PROMPT },
70
+ ...conversationHistory
71
+ ];
72
+
73
+ const requestBody = JSON.stringify({
74
+ model: XAI_MODEL,
75
+ messages: messages,
76
+ temperature: 0.7,
77
+ max_tokens: 2048
78
+ });
79
+
80
+ return new Promise((resolve, reject) => {
81
+ const options = {
82
+ hostname: 'api.x.ai',
83
+ port: 443,
84
+ path: '/v1/chat/completions',
85
+ method: 'POST',
86
+ headers: {
87
+ 'Content-Type': 'application/json',
88
+ 'Authorization': `Bearer ${apiKey}`,
89
+ 'Content-Length': Buffer.byteLength(requestBody)
90
+ }
91
+ };
92
+
93
+ const req = https.request(options, (res) => {
94
+ let data = '';
95
+ res.on('data', (chunk) => { data += chunk; });
96
+ res.on('end', () => {
97
+ try {
98
+ const response = JSON.parse(data);
99
+ if (response.choices && response.choices[0]?.message?.content) {
100
+ const assistantMessage = response.choices[0].message.content;
101
+ conversationHistory.push({ role: 'assistant', content: assistantMessage });
102
+
103
+ // Keep conversation history manageable
104
+ if (conversationHistory.length > 20) {
105
+ conversationHistory = conversationHistory.slice(-16);
106
+ }
107
+
108
+ resolve(assistantMessage);
109
+ } else if (response.error) {
110
+ resolve(`${colors.red}API Error: ${response.error.message}${colors.reset}`);
111
+ } else {
112
+ resolve(`${colors.red}Unexpected response format${colors.reset}`);
113
+ }
114
+ } catch (e) {
115
+ resolve(`${colors.red}Failed to parse response${colors.reset}`);
116
+ }
117
+ });
118
+ });
119
+
120
+ req.on('error', (e) => {
121
+ resolve(`${colors.red}Connection error: ${e.message}${colors.reset}`);
122
+ });
123
+
124
+ req.setTimeout(30000, () => {
125
+ req.destroy();
126
+ resolve(`${colors.yellow}Request timed out. Try again.${colors.reset}`);
127
+ });
128
+
129
+ req.write(requestBody);
130
+ req.end();
131
+ });
132
+ }
27
133
 
28
134
  async function main(): Promise<void> {
29
135
  const args = process.argv.slice(2);
30
136
 
31
- // Check for version flag
32
137
  if (args.includes('--version') || args.includes('-v')) {
33
138
  console.log(`cure v${VERSION}`);
34
139
  process.exit(0);
35
140
  }
36
141
 
37
- // Check for help flag
38
142
  if (args.includes('--help') || args.includes('-h')) {
39
143
  printHelp();
40
144
  process.exit(0);
41
145
  }
42
146
 
43
- // Initialize module
44
147
  cancerTreatment = new CancerTreatmentCapabilityModule();
45
148
 
46
- // Handle direct commands or launch interactive mode
47
149
  if (args.length > 0) {
48
150
  await handleCommand(args);
49
151
  } else {
@@ -64,7 +166,12 @@ async function launchInteractiveMode(): Promise<void> {
64
166
  process.stdout.write(`\n${colors.cyan}cure${colors.reset} ${colors.dim}>${colors.reset} `);
65
167
  };
66
168
 
67
- console.log(`${colors.dim}Type a command or describe what you need. Type /help for commands.${colors.reset}\n`);
169
+ const modelInfo = process.env.XAI_API_KEY
170
+ ? `${colors.green}Connected to xAI ${XAI_MODEL}${colors.reset}`
171
+ : `${colors.yellow}Set XAI_API_KEY for AI responses${colors.reset}`;
172
+
173
+ console.log(`${colors.dim}${modelInfo}${colors.reset}`);
174
+ console.log(`${colors.dim}Type your question or /help for commands.${colors.reset}\n`);
68
175
  prompt();
69
176
 
70
177
  rl.on('line', async (input) => {
@@ -90,6 +197,8 @@ async function launchInteractiveMode(): Promise<void> {
90
197
  if (trimmed === '/clear') {
91
198
  console.clear();
92
199
  printBanner();
200
+ conversationHistory = [];
201
+ console.log(`${colors.dim}Conversation cleared.${colors.reset}`);
93
202
  prompt();
94
203
  return;
95
204
  }
@@ -104,8 +213,6 @@ async function launchInteractiveMode(): Promise<void> {
104
213
  }
105
214
 
106
215
  async function processInput(input: string): Promise<void> {
107
- const lower = input.toLowerCase();
108
-
109
216
  // Slash commands
110
217
  if (input.startsWith('/')) {
111
218
  const parts = input.slice(1).split(' ');
@@ -115,71 +222,34 @@ async function processInput(input: string): Promise<void> {
115
222
  switch (cmd) {
116
223
  case 'analyze':
117
224
  await analyzePatient(args[0] || 'P001', args.includes('--genomics'));
118
- break;
225
+ return;
119
226
  case 'plan':
120
227
  await designTreatmentPlan(args[0] || 'P001', args[1]);
121
- break;
228
+ return;
122
229
  case 'discover':
123
230
  await discoverTargets(args[0] || 'EGFR', args[1] || 'Lung');
124
- break;
231
+ return;
125
232
  case 'demo':
126
233
  await runDemo();
127
- break;
234
+ return;
128
235
  case 'version':
129
- console.log(`\n${colors.cyan}cure${colors.reset} v${VERSION}`);
130
- break;
236
+ console.log(`\n${colors.cyan}cure${colors.reset} v${VERSION} (${XAI_MODEL})`);
237
+ return;
238
+ case 'model':
239
+ console.log(`\n${colors.cyan}Model:${colors.reset} ${XAI_MODEL}`);
240
+ console.log(`${colors.cyan}API:${colors.reset} ${process.env.XAI_API_KEY ? 'Connected' : 'Not configured'}`);
241
+ return;
131
242
  default:
132
243
  console.log(`\n${colors.red}Unknown command: /${cmd}${colors.reset}`);
133
244
  console.log(`${colors.dim}Type /help for available commands.${colors.reset}`);
245
+ return;
134
246
  }
135
- return;
136
- }
137
-
138
- // Natural language processing
139
- if (lower.includes('analyze') && lower.includes('patient')) {
140
- const match = input.match(/patient\s+(\w+)/i) || input.match(/P\d+/i);
141
- const patientId = match ? match[0].replace(/patient\s+/i, '') : 'P001';
142
- await analyzePatient(patientId, lower.includes('genom'));
143
- }
144
- else if (lower.includes('treatment') || lower.includes('plan')) {
145
- const match = input.match(/patient\s+(\w+)/i) || input.match(/P\d+/i);
146
- const patientId = match ? match[0].replace(/patient\s+/i, '') : 'P001';
147
- await designTreatmentPlan(patientId);
148
247
  }
149
- else if (lower.includes('drug') || lower.includes('target') || lower.includes('discover')) {
150
- const genes = ['EGFR', 'KRAS', 'BRAF', 'HER2', 'ALK', 'ROS1', 'PIK3CA', 'TP53'];
151
- const cancers = ['lung', 'breast', 'colon', 'melanoma', 'pancreatic'];
152
-
153
- let gene = 'EGFR';
154
- let cancer = 'Lung';
155
248
 
156
- for (const g of genes) {
157
- if (lower.includes(g.toLowerCase())) {
158
- gene = g;
159
- break;
160
- }
161
- }
162
- for (const c of cancers) {
163
- if (lower.includes(c)) {
164
- cancer = c.charAt(0).toUpperCase() + c.slice(1);
165
- break;
166
- }
167
- }
168
-
169
- await discoverTargets(gene, cancer);
170
- }
171
- else if (lower.includes('demo')) {
172
- await runDemo();
173
- }
174
- else {
175
- // Default response
176
- console.log(`\n${colors.cyan}I can help you with:${colors.reset}`);
177
- console.log(` ${colors.dim}•${colors.reset} Analyzing patient data`);
178
- console.log(` ${colors.dim}•${colors.reset} Designing treatment plans`);
179
- console.log(` ${colors.dim}•${colors.reset} Discovering drug targets`);
180
- console.log(` ${colors.dim}•${colors.reset} Running clinical demos`);
181
- console.log(`\n${colors.dim}Try: "analyze patient P001" or type /help${colors.reset}`);
182
- }
249
+ // AI-powered response for natural language
250
+ console.log(`\n${colors.dim}Thinking...${colors.reset}`);
251
+ const response = await callXAI(input);
252
+ console.log(`\n${response}`);
183
253
  }
184
254
 
185
255
  async function analyzePatient(patientId: string, includeGenomics: boolean = false): Promise<void> {
@@ -270,6 +340,8 @@ async function runDemo(): Promise<void> {
270
340
  }
271
341
 
272
342
  async function handleCommand(args: string[]): Promise<void> {
343
+ cancerTreatment = new CancerTreatmentCapabilityModule();
344
+
273
345
  if (args.includes('--analyze-patient')) {
274
346
  const patientId = args.find(a => a.startsWith('--patient='))?.split('=')[1] || 'P001';
275
347
  await analyzePatient(patientId, args.includes('--genomics'));
@@ -305,7 +377,7 @@ ${colors.cyan}${colors.bold} ╔═══════════════
305
377
  ║ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝ ║
306
378
  ║ ║
307
379
  ║ AI Cancer Treatment Framework ║
308
- Precision Oncology Research & Clinical Decision Support
380
+ Powered by xAI Grok ${XAI_MODEL}
309
381
  ║ ║
310
382
  ╚═══════════════════════════════════════════════════════════╝${colors.reset}
311
383
 
@@ -321,25 +393,29 @@ ${colors.dim}──────────────────────
321
393
  ${colors.cyan}/plan${colors.reset} [patient] Design treatment plan
322
394
  ${colors.cyan}/discover${colors.reset} [gene] Drug target discovery
323
395
  ${colors.cyan}/demo${colors.reset} Run framework demo
324
- ${colors.cyan}/clear${colors.reset} Clear screen
396
+ ${colors.cyan}/model${colors.reset} Show AI model info
397
+ ${colors.cyan}/clear${colors.reset} Clear conversation
325
398
  ${colors.cyan}/help${colors.reset} Show this help
326
399
  ${colors.cyan}/exit${colors.reset} Exit
327
400
 
328
- ${colors.bold}Natural Language${colors.reset}
401
+ ${colors.bold}AI Chat${colors.reset}
329
402
  ${colors.dim}─────────────────────────────${colors.reset}
330
- "analyze patient P001"
331
- "create treatment plan for P002"
332
- "find EGFR targets in lung cancer"
333
- "run demo"
403
+ Just type naturally to chat with the AI oncologist:
404
+
405
+ "What are the treatment options for EGFR+ lung cancer?"
406
+ "Explain pembrolizumab mechanism of action"
407
+ "What biomarkers predict response to immunotherapy?"
408
+ "Compare osimertinib vs erlotinib for EGFR mutations"
334
409
  `);
335
410
  }
336
411
 
337
412
  function printHelp(): void {
338
413
  console.log(`
339
414
  ${colors.bold}Cure - AI Cancer Treatment Framework${colors.reset}
415
+ Powered by xAI ${XAI_MODEL}
340
416
 
341
417
  ${colors.bold}Usage:${colors.reset}
342
- cure Launch interactive mode
418
+ cure Launch interactive AI chat
343
419
  cure [command] Run a specific command
344
420
 
345
421
  ${colors.bold}Commands:${colors.reset}
@@ -357,10 +433,12 @@ ${colors.bold}Options:${colors.reset}
357
433
  --target=<gene> Target gene (default: EGFR)
358
434
  --cancer=<type> Cancer type (default: Lung)
359
435
 
436
+ ${colors.bold}Environment:${colors.reset}
437
+ XAI_API_KEY xAI API key for AI-powered responses
438
+
360
439
  ${colors.bold}Examples:${colors.reset}
361
440
  cure
362
441
  cure --analyze-patient --patient=P001 --genomics
363
- cure --treatment-plan --patient=P001
364
442
  cure --drug-discovery --target=BRAF --cancer=Melanoma
365
443
 
366
444
  ${colors.dim}https://npmjs.com/package/@erosolaraijs/cure${colors.reset}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Clinician Decision Support Module Exports
3
+ */
4
+ export {
5
+ ClinicalDecisionSupportService,
6
+ type ClinicalRecommendation,
7
+ type ClinicianOverride,
8
+ type OverrideCategory,
9
+ type TumorBoardCase,
10
+ type AlertAcknowledgment
11
+ } from './decisionSupport.js';
@@ -0,0 +1,19 @@
1
+ /**
2
+ * HIPAA Compliance Module Exports
3
+ */
4
+ export {
5
+ HIPAAComplianceService,
6
+ type AuditLogEntry,
7
+ type AuditEventType,
8
+ type AuditAction,
9
+ type PatientConsent,
10
+ type ConsentType,
11
+ type DataCategory,
12
+ type ConsentPurpose,
13
+ type AccessPolicy,
14
+ type AccessCondition,
15
+ type AccessDecision,
16
+ type EncryptionConfig,
17
+ type EncryptedData,
18
+ type DataMaskingConfig
19
+ } from './hipaa.js';
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Clinical Trials Integration Module Exports
3
+ */
4
+ export {
5
+ ClinicalTrialsGovClient,
6
+ type ClinicalTrial,
7
+ type TrialStatus,
8
+ type TrialPhase,
9
+ type TrialIntervention,
10
+ type TrialEligibility,
11
+ type TrialLocation,
12
+ type TrialSponsor,
13
+ type TrialContact,
14
+ type TrialArm,
15
+ type TrialOutcome,
16
+ type BiomarkerRequirement,
17
+ type TrialSearchParams,
18
+ type TrialSearchResult,
19
+ type PatientProfile,
20
+ type TrialMatch
21
+ } from './clinicalTrialsGov.js';
@@ -0,0 +1,32 @@
1
+ /**
2
+ * EHR Integration Module Exports
3
+ */
4
+ export {
5
+ FHIRClient,
6
+ EpicFHIRClient,
7
+ CernerFHIRClient,
8
+ createFHIRClient,
9
+ type FHIRConfig,
10
+ type FHIRPatient,
11
+ type FHIRIdentifier,
12
+ type FHIRHumanName,
13
+ type FHIRAddress,
14
+ type FHIRContactPoint,
15
+ type FHIRCodeableConcept,
16
+ type FHIRCoding,
17
+ type FHIRExtension,
18
+ type FHIRCondition,
19
+ type FHIRObservation,
20
+ type FHIRQuantity,
21
+ type FHIRReference,
22
+ type FHIRMedicationRequest,
23
+ type FHIRDosage,
24
+ type FHIRDiagnosticReport,
25
+ type FHIRProcedure,
26
+ type FHIRBundle,
27
+ type FHIRResource,
28
+ type CancerDiagnosis,
29
+ type CancerBiomarkers,
30
+ type TreatmentHistory,
31
+ type AuditEvent
32
+ } from './fhir.js';
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Genomic Platform Integration Module Exports
3
+ */
4
+ export {
5
+ FoundationMedicineClient,
6
+ GuardantHealthClient,
7
+ TempusClient,
8
+ UnifiedGenomicsService,
9
+ createGenomicClient,
10
+ type GenomicTestOrder,
11
+ type GenomicTestResult,
12
+ type GenomicVariant,
13
+ type CopyNumberAlteration,
14
+ type GeneFusion,
15
+ type GenomicBiomarker,
16
+ type MSIResult,
17
+ type TMBResult,
18
+ type HRDResult,
19
+ type LOHResult,
20
+ type TherapyMatch,
21
+ type ClinicalTrialMatch,
22
+ type GenomicPlatformConfig
23
+ } from './genomicPlatforms.js';
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Machine Learning Module Exports
3
+ */
4
+ export {
5
+ OutcomePredictorService,
6
+ type PatientFeatures,
7
+ type TreatmentFeatures,
8
+ type ResponsePrediction,
9
+ type SurvivalPrediction,
10
+ type ToxicityPrediction,
11
+ type ResistancePrediction,
12
+ type TherapyRanking,
13
+ type MLModel,
14
+ type ModelRegistry
15
+ } from './outcomePredictor.js';
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Orchestrator Module - Real-World Oncology Service
3
+ */
4
+ export {
5
+ RealWorldOncologyService,
6
+ createRealWorldOncologyService,
7
+ type RealWorldConfig,
8
+ type RealWorldPatient,
9
+ type ComprehensiveTreatmentPlan,
10
+ type TreatmentOutcome
11
+ } from './realWorldOncology.js';