@erosolaraijs/cure 1.0.1 → 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.
- package/dist/bin/cure.d.ts +2 -5
- package/dist/bin/cure.d.ts.map +1 -1
- package/dist/bin/cure.js +360 -129
- package/dist/bin/cure.js.map +1 -1
- package/dist/clinician/decisionSupport.d.ts +325 -0
- package/dist/clinician/decisionSupport.d.ts.map +1 -0
- package/dist/clinician/decisionSupport.js +604 -0
- package/dist/clinician/decisionSupport.js.map +1 -0
- package/dist/clinician/index.d.ts +5 -0
- package/dist/clinician/index.d.ts.map +1 -0
- package/dist/clinician/index.js +5 -0
- package/dist/clinician/index.js.map +1 -0
- package/dist/compliance/index.d.ts +5 -0
- package/dist/compliance/index.d.ts.map +1 -0
- package/dist/compliance/index.js +5 -0
- package/dist/compliance/index.js.map +1 -0
- package/dist/index.d.ts +65 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +102 -0
- package/dist/index.js.map +1 -0
- package/dist/integrations/clinicalTrials/index.d.ts +5 -0
- package/dist/integrations/clinicalTrials/index.d.ts.map +1 -0
- package/dist/integrations/clinicalTrials/index.js +5 -0
- package/dist/integrations/clinicalTrials/index.js.map +1 -0
- package/dist/integrations/ehr/index.d.ts +5 -0
- package/dist/integrations/ehr/index.d.ts.map +1 -0
- package/dist/integrations/ehr/index.js +5 -0
- package/dist/integrations/ehr/index.js.map +1 -0
- package/dist/integrations/genomics/index.d.ts +5 -0
- package/dist/integrations/genomics/index.d.ts.map +1 -0
- package/dist/integrations/genomics/index.js +5 -0
- package/dist/integrations/genomics/index.js.map +1 -0
- package/dist/ml/index.d.ts +5 -0
- package/dist/ml/index.d.ts.map +1 -0
- package/dist/ml/index.js +5 -0
- package/dist/ml/index.js.map +1 -0
- package/dist/ml/outcomePredictor.d.ts +297 -0
- package/dist/ml/outcomePredictor.d.ts.map +1 -0
- package/dist/ml/outcomePredictor.js +823 -0
- package/dist/ml/outcomePredictor.js.map +1 -0
- package/dist/orchestrator/index.d.ts +5 -0
- package/dist/orchestrator/index.d.ts.map +1 -0
- package/dist/orchestrator/index.js +5 -0
- package/dist/orchestrator/index.js.map +1 -0
- package/dist/orchestrator/realWorldOncology.d.ts +351 -0
- package/dist/orchestrator/realWorldOncology.d.ts.map +1 -0
- package/dist/orchestrator/realWorldOncology.js +425 -0
- package/dist/orchestrator/realWorldOncology.js.map +1 -0
- package/dist/patient/index.d.ts +5 -0
- package/dist/patient/index.d.ts.map +1 -0
- package/dist/patient/index.js +5 -0
- package/dist/patient/index.js.map +1 -0
- package/dist/patient/patientPortal.d.ts +337 -0
- package/dist/patient/patientPortal.d.ts.map +1 -0
- package/dist/patient/patientPortal.js +667 -0
- package/dist/patient/patientPortal.js.map +1 -0
- package/dist/safety/drugInteractions.d.ts +230 -0
- package/dist/safety/drugInteractions.d.ts.map +1 -0
- package/dist/safety/drugInteractions.js +697 -0
- package/dist/safety/drugInteractions.js.map +1 -0
- package/dist/safety/index.d.ts +5 -0
- package/dist/safety/index.d.ts.map +1 -0
- package/dist/safety/index.js +5 -0
- package/dist/safety/index.js.map +1 -0
- package/dist/validation/index.d.ts +5 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/index.js +5 -0
- package/dist/validation/index.js.map +1 -0
- package/dist/validation/retrospectiveValidator.d.ts +246 -0
- package/dist/validation/retrospectiveValidator.d.ts.map +1 -0
- package/dist/validation/retrospectiveValidator.js +602 -0
- package/dist/validation/retrospectiveValidator.js.map +1 -0
- package/package.json +1 -1
- package/src/bin/cure.ts +412 -143
- package/src/clinician/decisionSupport.ts +949 -0
- package/src/clinician/index.ts +11 -0
- package/src/compliance/index.ts +19 -0
- package/src/integrations/clinicalTrials/index.ts +21 -0
- package/src/integrations/ehr/index.ts +32 -0
- package/src/integrations/genomics/index.ts +23 -0
- package/src/ml/index.ts +15 -0
- package/src/orchestrator/index.ts +11 -0
- package/src/orchestrator/realWorldOncology.ts +803 -0
- package/src/patient/index.ts +14 -0
- package/src/patient/patientPortal.ts +1039 -0
- package/src/safety/index.ts +14 -0
- package/src/validation/index.ts +10 -0
package/src/bin/cure.ts
CHANGED
|
@@ -1,182 +1,451 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* 全球首个人工通用智能驱动的癌症治疗统一指挥控制平台
|
|
7
|
-
* 提供完整的癌症研究、药物发现、治疗规划、患者管理和医疗系统集成能力
|
|
3
|
+
* Cure - AI Cancer Treatment Framework
|
|
4
|
+
* Interactive CLI powered by xAI Grok for precision oncology
|
|
8
5
|
*/
|
|
9
6
|
|
|
7
|
+
import * as readline from 'readline';
|
|
8
|
+
import * as https from 'https';
|
|
10
9
|
import { CancerTreatmentCapabilityModule } from '../capabilities/cancerTreatmentCapability.js';
|
|
11
10
|
|
|
11
|
+
const VERSION = '1.0.3';
|
|
12
|
+
const XAI_MODEL = 'grok-4-1-fast-reasoning';
|
|
13
|
+
|
|
14
|
+
// ANSI color codes
|
|
15
|
+
const colors = {
|
|
16
|
+
reset: '\x1b[0m',
|
|
17
|
+
bold: '\x1b[1m',
|
|
18
|
+
dim: '\x1b[2m',
|
|
19
|
+
cyan: '\x1b[36m',
|
|
20
|
+
green: '\x1b[32m',
|
|
21
|
+
yellow: '\x1b[33m',
|
|
22
|
+
blue: '\x1b[34m',
|
|
23
|
+
magenta: '\x1b[35m',
|
|
24
|
+
red: '\x1b[31m',
|
|
25
|
+
white: '\x1b[37m',
|
|
26
|
+
};
|
|
27
|
+
|
|
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
|
+
}
|
|
133
|
+
|
|
12
134
|
async function main(): Promise<void> {
|
|
13
135
|
const args = process.argv.slice(2);
|
|
14
136
|
|
|
15
|
-
// Check for version flag
|
|
16
137
|
if (args.includes('--version') || args.includes('-v')) {
|
|
17
|
-
|
|
18
|
-
console.log(`agi-core-cancer-treatment v${pkg.version}`);
|
|
138
|
+
console.log(`cure v${VERSION}`);
|
|
19
139
|
process.exit(0);
|
|
20
140
|
}
|
|
21
141
|
|
|
22
|
-
// Check for help flag
|
|
23
142
|
if (args.includes('--help') || args.includes('-h')) {
|
|
24
143
|
printHelp();
|
|
25
144
|
process.exit(0);
|
|
26
145
|
}
|
|
27
146
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
console.log('💊 最大能力癌症治疗框架 - 全面医疗与AI能力\n');
|
|
35
|
-
console.log('📊 框架提供以下核心能力:');
|
|
36
|
-
console.log(' • 个性化癌症治疗协议分析与规划');
|
|
37
|
-
console.log(' • AI驱动的药物靶点发现与设计');
|
|
38
|
-
console.log(' • 精准医疗与基因组分析管道');
|
|
39
|
-
console.log(' • 临床试验管理与优化');
|
|
40
|
-
console.log(' • 患者多维度评估与监测');
|
|
41
|
-
console.log(' • 医疗系统集成与数据协调');
|
|
42
|
-
console.log(' • 统一医疗指挥与协调系统');
|
|
43
|
-
console.log(' • 人工智能治疗决策支持\n');
|
|
44
|
-
|
|
45
|
-
console.log('✅ 癌症治疗能力框架初始化完成');
|
|
46
|
-
console.log('🚀 使用 --help 查看可用命令');
|
|
147
|
+
cancerTreatment = new CancerTreatmentCapabilityModule();
|
|
148
|
+
|
|
149
|
+
if (args.length > 0) {
|
|
150
|
+
await handleCommand(args);
|
|
151
|
+
} else {
|
|
152
|
+
await launchInteractiveMode();
|
|
47
153
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
async function launchInteractiveMode(): Promise<void> {
|
|
157
|
+
console.clear();
|
|
158
|
+
printBanner();
|
|
159
|
+
|
|
160
|
+
const rl = readline.createInterface({
|
|
161
|
+
input: process.stdin,
|
|
162
|
+
output: process.stdout,
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
const prompt = () => {
|
|
166
|
+
process.stdout.write(`\n${colors.cyan}cure${colors.reset} ${colors.dim}>${colors.reset} `);
|
|
167
|
+
};
|
|
168
|
+
|
|
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`);
|
|
175
|
+
prompt();
|
|
176
|
+
|
|
177
|
+
rl.on('line', async (input) => {
|
|
178
|
+
const trimmed = input.trim();
|
|
179
|
+
|
|
180
|
+
if (!trimmed) {
|
|
181
|
+
prompt();
|
|
182
|
+
return;
|
|
65
183
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
console.
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
console.
|
|
184
|
+
|
|
185
|
+
if (trimmed === '/exit' || trimmed === '/quit' || trimmed === 'exit' || trimmed === 'quit') {
|
|
186
|
+
console.log(`\n${colors.dim}Goodbye.${colors.reset}\n`);
|
|
187
|
+
rl.close();
|
|
188
|
+
process.exit(0);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (trimmed === '/help' || trimmed === 'help') {
|
|
192
|
+
printInteractiveHelp();
|
|
193
|
+
prompt();
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (trimmed === '/clear') {
|
|
198
|
+
console.clear();
|
|
199
|
+
printBanner();
|
|
200
|
+
conversationHistory = [];
|
|
201
|
+
console.log(`${colors.dim}Conversation cleared.${colors.reset}`);
|
|
202
|
+
prompt();
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
await processInput(trimmed);
|
|
207
|
+
prompt();
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
rl.on('close', () => {
|
|
211
|
+
process.exit(0);
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
async function processInput(input: string): Promise<void> {
|
|
216
|
+
// Slash commands
|
|
217
|
+
if (input.startsWith('/')) {
|
|
218
|
+
const parts = input.slice(1).split(' ');
|
|
219
|
+
const cmd = parts[0];
|
|
220
|
+
const args = parts.slice(1);
|
|
221
|
+
|
|
222
|
+
switch (cmd) {
|
|
223
|
+
case 'analyze':
|
|
224
|
+
await analyzePatient(args[0] || 'P001', args.includes('--genomics'));
|
|
225
|
+
return;
|
|
226
|
+
case 'plan':
|
|
227
|
+
await designTreatmentPlan(args[0] || 'P001', args[1]);
|
|
228
|
+
return;
|
|
229
|
+
case 'discover':
|
|
230
|
+
await discoverTargets(args[0] || 'EGFR', args[1] || 'Lung');
|
|
231
|
+
return;
|
|
232
|
+
case 'demo':
|
|
233
|
+
await runDemo();
|
|
234
|
+
return;
|
|
235
|
+
case 'version':
|
|
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;
|
|
242
|
+
default:
|
|
243
|
+
console.log(`\n${colors.red}Unknown command: /${cmd}${colors.reset}`);
|
|
244
|
+
console.log(`${colors.dim}Type /help for available commands.${colors.reset}`);
|
|
245
|
+
return;
|
|
84
246
|
}
|
|
85
247
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
248
|
+
|
|
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}`);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
async function analyzePatient(patientId: string, includeGenomics: boolean = false): Promise<void> {
|
|
256
|
+
console.log(`\n${colors.cyan}Analyzing patient ${patientId}...${colors.reset}\n`);
|
|
257
|
+
|
|
258
|
+
try {
|
|
259
|
+
const result = await cancerTreatment.analyzePatient(patientId, includeGenomics);
|
|
260
|
+
|
|
261
|
+
console.log(`${colors.bold}Patient Analysis${colors.reset}`);
|
|
262
|
+
console.log(`${colors.dim}─────────────────────────────${colors.reset}`);
|
|
263
|
+
console.log(` Cancer Type: ${colors.yellow}${result.analysis.cancerType}${colors.reset}`);
|
|
264
|
+
console.log(` Stage: ${colors.yellow}${result.analysis.stage}${colors.reset}`);
|
|
265
|
+
console.log(` Biomarkers: ${result.analysis.biomarkers.join(', ')}`);
|
|
266
|
+
console.log(` Survival Prob: ${colors.green}${(result.analysis.riskAssessment.survivalProbability * 100).toFixed(1)}%${colors.reset}`);
|
|
267
|
+
console.log(` Recurrence: ${colors.yellow}${(result.analysis.riskAssessment.recurrenceRisk * 100).toFixed(1)}%${colors.reset}`);
|
|
268
|
+
|
|
269
|
+
if (result.analysis.genomicProfile) {
|
|
270
|
+
console.log(`\n${colors.bold}Genomic Profile${colors.reset}`);
|
|
271
|
+
console.log(` Mutations: ${result.analysis.genomicProfile.mutations?.length || 0} detected`);
|
|
108
272
|
}
|
|
273
|
+
|
|
274
|
+
console.log(`\n${colors.green}✓ Analysis complete${colors.reset}`);
|
|
275
|
+
} catch (error) {
|
|
276
|
+
console.error(`${colors.red}✗ Analysis failed:${colors.reset}`, error);
|
|
109
277
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
async function designTreatmentPlan(patientId: string, protocolId?: string): Promise<void> {
|
|
281
|
+
console.log(`\n${colors.cyan}Designing treatment plan for ${patientId}...${colors.reset}\n`);
|
|
282
|
+
|
|
283
|
+
try {
|
|
284
|
+
const result = await cancerTreatment.designTreatmentPlan(patientId, protocolId);
|
|
285
|
+
|
|
286
|
+
console.log(`${colors.bold}Treatment Plan${colors.reset}`);
|
|
287
|
+
console.log(`${colors.dim}─────────────────────────────${colors.reset}`);
|
|
288
|
+
console.log(` Protocol: ${colors.yellow}${result.plan.protocol.name}${colors.reset}`);
|
|
289
|
+
console.log(` Modalities: ${result.plan.protocol.treatmentModalities.join(', ')}`);
|
|
290
|
+
console.log(` Est. Efficacy: ${colors.green}${(result.estimatedEfficacy * 100).toFixed(1)}%${colors.reset}`);
|
|
291
|
+
console.log(` Duration: ${result.plan.treatmentTimeline.length} weeks`);
|
|
292
|
+
|
|
293
|
+
console.log(`\n${colors.bold}Timeline${colors.reset}`);
|
|
294
|
+
result.plan.treatmentTimeline.slice(0, 4).forEach((week: any, i: number) => {
|
|
295
|
+
console.log(` Week ${i + 1}: ${week.phase} - ${week.activities.join(', ')}`);
|
|
296
|
+
});
|
|
297
|
+
if (result.plan.treatmentTimeline.length > 4) {
|
|
298
|
+
console.log(` ${colors.dim}... and ${result.plan.treatmentTimeline.length - 4} more weeks${colors.reset}`);
|
|
119
299
|
}
|
|
300
|
+
|
|
301
|
+
console.log(`\n${colors.green}✓ Plan generated${colors.reset}`);
|
|
302
|
+
} catch (error) {
|
|
303
|
+
console.error(`${colors.red}✗ Plan generation failed:${colors.reset}`, error);
|
|
120
304
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
console.log(
|
|
130
|
-
console.log(
|
|
131
|
-
console.log(
|
|
132
|
-
console.log(
|
|
133
|
-
console.log(
|
|
134
|
-
|
|
135
|
-
console.log(
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
async function discoverTargets(gene: string, cancerType: string): Promise<void> {
|
|
308
|
+
console.log(`\n${colors.cyan}Discovering drug targets for ${gene} in ${cancerType} cancer...${colors.reset}\n`);
|
|
309
|
+
|
|
310
|
+
try {
|
|
311
|
+
const result = await cancerTreatment.discoverDrugTargets(cancerType, gene);
|
|
312
|
+
|
|
313
|
+
console.log(`${colors.bold}Drug Target Discovery${colors.reset}`);
|
|
314
|
+
console.log(`${colors.dim}─────────────────────────────${colors.reset}`);
|
|
315
|
+
console.log(` Cancer Type: ${colors.yellow}${result.cancerType}${colors.reset}`);
|
|
316
|
+
console.log(` Target Gene: ${colors.yellow}${result.targetGene || 'All'}${colors.reset}`);
|
|
317
|
+
console.log(` Targets Found: ${result.discoveredTargets.length}`);
|
|
318
|
+
|
|
319
|
+
console.log(`\n${colors.bold}Top Targets${colors.reset}`);
|
|
320
|
+
result.discoveredTargets.slice(0, 5).forEach((target: any, i: number) => {
|
|
321
|
+
console.log(` ${i + 1}. ${colors.cyan}${target.gene}${colors.reset} - ${target.evidenceLevel} evidence`);
|
|
322
|
+
console.log(` ${colors.dim}Cancers: ${target.cancerTypes.slice(0, 3).join(', ')}${colors.reset}`);
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
console.log(`\n${colors.green}✓ Discovery complete${colors.reset}`);
|
|
326
|
+
} catch (error) {
|
|
327
|
+
console.error(`${colors.red}✗ Discovery failed:${colors.reset}`, error);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
async function runDemo(): Promise<void> {
|
|
332
|
+
console.log(`\n${colors.cyan}Running framework demo...${colors.reset}\n`);
|
|
333
|
+
|
|
334
|
+
try {
|
|
335
|
+
const { demonstrateCancerTreatmentFramework } = await import('../examples/cancerTreatmentDemo.js');
|
|
336
|
+
await demonstrateCancerTreatmentFramework();
|
|
337
|
+
} catch (error) {
|
|
338
|
+
console.error(`${colors.red}✗ Demo failed:${colors.reset}`, error);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
async function handleCommand(args: string[]): Promise<void> {
|
|
343
|
+
cancerTreatment = new CancerTreatmentCapabilityModule();
|
|
344
|
+
|
|
345
|
+
if (args.includes('--analyze-patient')) {
|
|
346
|
+
const patientId = args.find(a => a.startsWith('--patient='))?.split('=')[1] || 'P001';
|
|
347
|
+
await analyzePatient(patientId, args.includes('--genomics'));
|
|
348
|
+
}
|
|
349
|
+
else if (args.includes('--treatment-plan')) {
|
|
350
|
+
const patientId = args.find(a => a.startsWith('--patient='))?.split('=')[1] || 'P001';
|
|
351
|
+
const protocolId = args.find(a => a.startsWith('--protocol='))?.split('=')[1];
|
|
352
|
+
await designTreatmentPlan(patientId, protocolId);
|
|
353
|
+
}
|
|
354
|
+
else if (args.includes('--drug-discovery')) {
|
|
355
|
+
const gene = args.find(a => a.startsWith('--target='))?.split('=')[1] || 'EGFR';
|
|
356
|
+
const cancer = args.find(a => a.startsWith('--cancer='))?.split('=')[1] || 'Lung';
|
|
357
|
+
await discoverTargets(gene, cancer);
|
|
358
|
+
}
|
|
359
|
+
else if (args.includes('--demo')) {
|
|
360
|
+
await runDemo();
|
|
136
361
|
}
|
|
137
362
|
else {
|
|
138
|
-
console.log(
|
|
363
|
+
console.log(`${colors.red}Unknown command.${colors.reset} Use cure --help for usage.`);
|
|
139
364
|
process.exit(1);
|
|
140
365
|
}
|
|
141
366
|
}
|
|
142
367
|
|
|
368
|
+
function printBanner(): void {
|
|
369
|
+
console.log(`
|
|
370
|
+
${colors.cyan}${colors.bold} ╔═══════════════════════════════════════════════════════════╗
|
|
371
|
+
║ ║
|
|
372
|
+
║ ██████╗██╗ ██╗██████╗ ███████╗ ║
|
|
373
|
+
║ ██╔════╝██║ ██║██╔══██╗██╔════╝ ║
|
|
374
|
+
║ ██║ ██║ ██║██████╔╝█████╗ ║
|
|
375
|
+
║ ██║ ██║ ██║██╔══██╗██╔══╝ ║
|
|
376
|
+
║ ╚██████╗╚██████╔╝██║ ██║███████╗ ║
|
|
377
|
+
║ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝ ║
|
|
378
|
+
║ ║
|
|
379
|
+
║ AI Cancer Treatment Framework ║
|
|
380
|
+
║ Powered by xAI Grok ${XAI_MODEL} ║
|
|
381
|
+
║ ║
|
|
382
|
+
╚═══════════════════════════════════════════════════════════╝${colors.reset}
|
|
383
|
+
|
|
384
|
+
${colors.dim}v${VERSION}${colors.reset}
|
|
385
|
+
`);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
function printInteractiveHelp(): void {
|
|
389
|
+
console.log(`
|
|
390
|
+
${colors.bold}Commands${colors.reset}
|
|
391
|
+
${colors.dim}─────────────────────────────${colors.reset}
|
|
392
|
+
${colors.cyan}/analyze${colors.reset} [patient] Analyze patient data
|
|
393
|
+
${colors.cyan}/plan${colors.reset} [patient] Design treatment plan
|
|
394
|
+
${colors.cyan}/discover${colors.reset} [gene] Drug target discovery
|
|
395
|
+
${colors.cyan}/demo${colors.reset} Run framework demo
|
|
396
|
+
${colors.cyan}/model${colors.reset} Show AI model info
|
|
397
|
+
${colors.cyan}/clear${colors.reset} Clear conversation
|
|
398
|
+
${colors.cyan}/help${colors.reset} Show this help
|
|
399
|
+
${colors.cyan}/exit${colors.reset} Exit
|
|
400
|
+
|
|
401
|
+
${colors.bold}AI Chat${colors.reset}
|
|
402
|
+
${colors.dim}─────────────────────────────${colors.reset}
|
|
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"
|
|
409
|
+
`);
|
|
410
|
+
}
|
|
411
|
+
|
|
143
412
|
function printHelp(): void {
|
|
144
413
|
console.log(`
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
--
|
|
162
|
-
--
|
|
163
|
-
--
|
|
164
|
-
--
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
414
|
+
${colors.bold}Cure - AI Cancer Treatment Framework${colors.reset}
|
|
415
|
+
Powered by xAI ${XAI_MODEL}
|
|
416
|
+
|
|
417
|
+
${colors.bold}Usage:${colors.reset}
|
|
418
|
+
cure Launch interactive AI chat
|
|
419
|
+
cure [command] Run a specific command
|
|
420
|
+
|
|
421
|
+
${colors.bold}Commands:${colors.reset}
|
|
422
|
+
--analyze-patient Analyze patient data
|
|
423
|
+
--treatment-plan Design treatment plan
|
|
424
|
+
--drug-discovery Drug target discovery
|
|
425
|
+
--demo Run framework demo
|
|
426
|
+
--help, -h Show this help
|
|
427
|
+
--version, -v Show version
|
|
428
|
+
|
|
429
|
+
${colors.bold}Options:${colors.reset}
|
|
430
|
+
--patient=<id> Patient ID (default: P001)
|
|
431
|
+
--protocol=<id> Treatment protocol
|
|
432
|
+
--genomics Include genomic analysis
|
|
433
|
+
--target=<gene> Target gene (default: EGFR)
|
|
434
|
+
--cancer=<type> Cancer type (default: Lung)
|
|
435
|
+
|
|
436
|
+
${colors.bold}Environment:${colors.reset}
|
|
437
|
+
XAI_API_KEY xAI API key for AI-powered responses
|
|
438
|
+
|
|
439
|
+
${colors.bold}Examples:${colors.reset}
|
|
440
|
+
cure
|
|
441
|
+
cure --analyze-patient --patient=P001 --genomics
|
|
442
|
+
cure --drug-discovery --target=BRAF --cancer=Melanoma
|
|
443
|
+
|
|
444
|
+
${colors.dim}https://npmjs.com/package/@erosolaraijs/cure${colors.reset}
|
|
175
445
|
`);
|
|
176
446
|
}
|
|
177
447
|
|
|
178
|
-
// Run main function
|
|
179
448
|
main().catch((error) => {
|
|
180
|
-
console.error(
|
|
449
|
+
console.error(`${colors.red}Error:${colors.reset}`, error);
|
|
181
450
|
process.exit(1);
|
|
182
|
-
});
|
|
451
|
+
});
|