caelum0x 174222bcaa feat: Builder-Track named-user tools, bio + evidence-intelligence platform, Apache-2.0
Builds PaperTrail from the base skeleton into a full evidence-verification platform
for the "Built with Claude: Life Sciences" hackathon (Builder Track).

New named-user features (Build Beyond the Bench):
- Lab Notebook Companion — rough bench notes -> structured, searchable, grounded
  experiment records (lib/labNotebook, /console/lab-notebook, migration 0059)
- Clinical Trial Matcher — de-identified patient notes -> ranked eligible
  ClinicalTrials.gov trials with per-criterion inclusion/exclusion reasoning
  (lib/trialMatcher, /console/trial-matcher, migrations 0060)

Platform:
- Deterministic verification moat (biostats recompute, exact-span grounding)
- 11 biomedical evidence engines (FAERS, GWAS, Open Targets, ChEMBL, ClinVar,
  PharmGKB, PubTator, DDI, repurposing, biomarker, unified verifier)
- Evidence Intelligence (KG, dossier, provenance/export, RWE) + enterprise
  governance (RBAC, /api/v1 gateway, metering, audit chain, retention)
- 17 OSS projects assimilated into native TypeScript on our stack (backend/engines
  retained + credited in NOTICE)
- Multi-format upload (PDF/DOCX/XLSX/CSV/MD/TXT), logo, marketing site
- Next.js 16 upgrade, benchmark harness (honest smoke-test caveat)

Licensing: Apache-2.0 (LICENSE + NOTICE).
2026-07-10 16:23:13 +03:00

123 lines
3.2 KiB
JavaScript

// index.js
const WebSocket = require('ws');
class GPTResearcher {
constructor(options = {}) {
this.host = options.host || 'http://localhost:8000';
this.socket = null;
this.responseCallbacks = new Map();
this.logListener = options.logListener;
this.tone = options.tone || 'Reflective';
}
async initializeWebSocket() {
if (!this.socket) {
const protocol = this.host.includes('https') ? 'wss:' : 'ws:';
const cleanHost = this.host.replace('http://', '').replace('https://', '');
const ws_uri = `${protocol}//${cleanHost}/ws`;
this.socket = new WebSocket(ws_uri);
this.socket.onopen = () => {
console.log('WebSocket connection established');
};
this.socket.onmessage = (event) => {
const data = JSON.parse(event.data);
// Handle logs with custom listener if provided
if (this.logListener) {
this.logListener(data);
} else {
console.log('WebSocket data received:', data);
}
const callback = this.responseCallbacks.get('current');
};
this.socket.onclose = () => {
console.log('WebSocket connection closed');
this.socket = null;
};
this.socket.onerror = (error) => {
console.error('WebSocket error:', error);
};
}
}
async sendMessage({
task,
useHTTP = false,
reportType = 'research_report',
reportSource = 'web',
queryDomains = [],
tone = 'Reflective',
query,
moreContext
}) {
const data = {
task: query ? `${query}. Additional context: ${moreContext}` : task,
report_type: reportType,
report_source: reportSource,
headers: {},
tone: tone,
query_domains: queryDomains
};
if (useHTTP) {
return this.sendHttpRequest(data);
}
return new Promise((resolve, reject) => {
if (!this.socket || this.socket.readyState !== WebSocket.OPEN) {
this.initializeWebSocket();
}
const payload = "start " + JSON.stringify(data);
this.responseCallbacks.set('current', {
onProgress: (progressData) => {
resolve({ type: 'progress', data: progressData });
},
onComplete: (finalData) => {
resolve({ type: 'complete', data: finalData });
}
});
if (this.socket.readyState === WebSocket.OPEN) {
this.socket.send(payload);
console.log('Message sent:', payload);
} else {
this.socket.onopen = () => {
this.socket.send(payload);
console.log('Message sent after connection:', payload);
};
}
});
}
async sendHttpRequest(data) {
try {
const response = await axios.post(`${this.host}/report/`, data);
return { message: 'success', data: response.data };
} catch (error) {
console.error('HTTP request error:', error);
return { message: 'error', error: error.message };
}
}
async getReport(reportId) {
try {
const response = await axios.get(`${this.host}/report/${reportId}`);
return response;
} catch (error) {
console.error('HTTP request error:', error);
return { message: 'error', error: error.message };
}
}
}
module.exports = GPTResearcher;