Quick Start

From zero to health insights in 10 lines of TypeScript.

import { VitalClawEngine, FHIRConverter, createVitalClawPlugin } from "@vitalclaw/sdk";

// 1. Create engine
const engine = new VitalClawEngine({ userId: "user-001", providers: [] });

// 2. Listen for alerts
engine.events.on("alert:triggered", (e) => {
  if (e.type === "alert:triggered") console.log(`๐Ÿšจ ${e.alert.message}`);
});

// 3. Ingest data
const now = new Date().toISOString();
engine.ingest([
  { id: "1", userId: "user-001", metric: "heart_rate", value: 72, unit: "bpm", timestamp: now, source: "manual" },
  { id: "2", userId: "user-001", metric: "resting_heart_rate", value: 62, unit: "bpm", timestamp: now, source: "manual" },
  { id: "3", userId: "user-001", metric: "blood_oxygen", value: 97, unit: "%", timestamp: now, source: "manual" },
  { id: "4", userId: "user-001", metric: "steps", value: 8432, unit: "steps", timestamp: now, source: "manual" },
  { id: "5", userId: "user-001", metric: "sleep_duration", value: 450, unit: "minutes", timestamp: now, source: "manual" },
]);

// 4. Get summary
const summary = engine.getDailySummary();
console.log(`Wellness: ${summary.wellnessScore}/100`);
console.log(`HR: ${summary.cardiac.restingHeartRate} bpm`);
console.log(`Steps: ${summary.activity.steps}`);

// 5. Export to FHIR
const fhir = new FHIRConverter();
const bundle = fhir.toBundle(engine.query({ userId: "user-001" }));
console.log(`FHIR Observations: ${bundle.entry.length}`);

// 6. Use as ElizaOS plugin
const plugin = createVitalClawPlugin({ userId: "user-001", providers: [] });
console.log(`Actions: ${plugin.actions.map(a => a.name).join(", ")}`);

Expected Output

Wellness: 78/100
HR: 62 bpm
Steps: 8432
FHIR Observations: 5
Actions: CHECK_VITALS, DAILY_HEALTH_SUMMARY, WEEKLY_HEALTH_SUMMARY, LOG_VITALS, HEALTH_TRENDS, SET_HEALTH_ALERT

Next Steps

Now that you have the basics, explore: