Skip to content

lonexreb/AgentKit-Health

Repository files navigation

AgentKit Health Banner

Deploy health AI agents in minutes, not months.

Quick Start · Agent Templates · Architecture · Marketplace · API Reference · Contributing


What is AgentKit Health?

AgentKit Health is a collection of pre-built AI agent templates for health and wellness workflows. Each agent follows a consistent Sense-Think-Act lifecycle:

  1. Sense — Pulls real-time health data from 500+ wearables via Spike MCP
  2. Think — Reasons over your data using Claude (swappable to GPT/Gemini)
  3. Act — Delivers personalized protocols, alerts, and recommendations
const agent = new SleepCoachAgent({
  spikeMcpUrl: process.env.SPIKE_MCP_URL,
  llmApiKey: process.env.ANTHROPIC_API_KEY,
  userId: "user_123",
  triggers: { schedule: "0 7 * * *" }, // Run daily at 7am
});

await agent.run(); // sense() -> think() -> act()

Quick Start

Prerequisites

Install a single agent

npm install @agentkit/sleep-coach

Or clone the full monorepo

git clone https://github.com/lonexreb/AgentKit-Health.git
cd AgentKit-Health
npm install
npm run build

Configure environment

cp .env.example .env
SPIKE_MCP_URL=http://localhost:3001
ANTHROPIC_API_KEY=sk-ant-...

Run your first agent

import { SleepCoachAgent } from "@agentkit/sleep-coach";

const agent = new SleepCoachAgent({
  spikeMcpUrl: process.env.SPIKE_MCP_URL!,
  llmApiKey: process.env.ANTHROPIC_API_KEY!,
  userId: "user_123",
  triggers: { schedule: "0 7 * * *" },
  thresholds: {
    minSleepHours: 7,
    maxSleepDebt: 5,
    targetBedtime: "23:00",
    targetWakeTime: "07:00",
    minDeepSleepPct: 15,
    minRemPct: 20,
  },
});

await agent.run();

Output:

=== Sleep Coach Report ===

Score: 72/100
Summary: Moderate sleep quality with room for improvement in consistency.

Strengths:
  + Deep sleep percentage above target
  + HRV trend improving over the week

Concerns:
  - Sleep debt of 4.2 hours accumulated
  - Bedtime variance of 45 minutes

Evening Routine (start at 21:30):
  21:30 - Dim lights, enable blue light filter
  22:00 - Begin wind-down routine
  22:30 - Breathing exercises (4-7-8 pattern)
  23:00 - Lights out

Recommendations:
  [HIGH] Fix bedtime consistency: Aim for 23:00 +/- 15 min every night
  [HIGH] Address sleep debt: Add 30 min to sleep for next 5 days
  [MEDIUM] Optimize deep sleep: No caffeine after 14:00

=== End Report ===

Agent Templates

Agent Category Description Data Sources Status
Sleep Coach Sleep Monitors sleep patterns, generates nightly protocols, delivers morning debriefs Sleep, HRV Ready
Burnout Detector Stress Tracks work hours + HRV + sleep debt, alerts before burnout Sleep, HRV, Activity Stub
Circadian Scheduler Productivity Reads energy curve, auto-schedules tasks in optimal windows HRV, Heart Rate, Sleep Stub
Nutrition Timing Nutrition Monitors circadian rhythm, finds optimal eating windows Activity, Sleep Stub
Recovery Agent Recovery For athletes — strain/recovery analysis, adjusts training plans Activity, HRV, Sleep, Heart Rate Stub
Jet Lag Agent Recovery Detects timezone change, creates multi-day adaptation protocol Sleep, Activity Stub
Meeting Optimizer Productivity Reads team energy data, finds when everyone peaks HRV, Heart Rate Stub
Supplement Timing Nutrition Based on biomarkers + sleep, optimizes supplement schedule Sleep, HRV, Body Composition Stub

Agent Lifecycle

Every agent follows the same three-phase pattern:

┌──────────┐     ┌──────────┐     ┌──────────┐
│  SENSE   │────>│  THINK   │────>│   ACT    │
│          │     │          │     │          │
│ Spike MCP│     │  Claude  │     │ Notify / │
│ Health   │     │  Reason  │     │ Schedule │
│ Data     │     │  Analyze │     │ Log      │
└──────────┘     └──────────┘     └──────────┘
  • Sense: Fetches data from Spike MCP (sleep sessions, HRV readings, activity summaries, etc.)
  • Think: Sends data to Claude with domain-specific prompts, receives structured analysis and recommendations
  • Act: Delivers output (console log, webhook, push notification, calendar update)

Architecture

Monorepo Structure

AgentKit-Health/
├── packages/
│   └── core/                  # @agentkit/core
│       ├── base-agent.ts      # Abstract BaseAgent class
│       ├── spike-mcp-client.ts # Spike MCP integration
│       ├── llm-provider.ts    # Claude/GPT/Gemini abstraction
│       └── types/             # Shared TypeScript types
├── agents/
│   ├── sleep-coach/           # @agentkit/sleep-coach (reference implementation)
│   ├── burnout-detector/      # @agentkit/burnout-detector
│   ├── circadian-scheduler/   # @agentkit/circadian-scheduler
│   ├── nutrition-timing/      # @agentkit/nutrition-timing
│   ├── recovery-agent/        # @agentkit/recovery-agent
│   ├── jetlag-agent/          # @agentkit/jetlag-agent
│   ├── meeting-optimizer/     # @agentkit/meeting-optimizer
│   └── supplement-timing/     # @agentkit/supplement-timing
└── apps/
    └── marketplace/           # Next.js 14 marketplace frontend

Tech Stack

Layer Technology Purpose
Agent Framework TypeScript + Vercel AI SDK Agent lifecycle, LLM abstraction
Health Data Spike MCP 500+ wearable devices, LLM-ready data
LLM Claude API (default) Reasoning, analysis, recommendations
Validation Zod Runtime config validation + TypeScript types
Monorepo Turborepo + npm workspaces Build orchestration
Marketplace Next.js 14 + Tailwind + shadcn/ui Agent catalog and dashboard
Database Supabase User auth, purchases, agent deployments
Payments Stripe Individual agent + bundle purchases

Core Package (@agentkit/core)

The core package provides the foundation every agent builds on:

BaseAgent<TConfig, TSenseData, TDecision, TAction>

Abstract class implementing the Sense-Think-Act lifecycle:

abstract class BaseAgent<TConfig, TSenseData, TDecision, TAction = void> {
  protected spike: SpikeMcpClient;  // Health data client
  protected llm: LlmProvider;      // LLM abstraction
  protected config: TConfig;        // Validated agent config

  abstract sense(): Promise<TSenseData>;
  abstract think(data: TSenseData): Promise<TDecision>;
  abstract act(decision: TDecision): Promise<TAction>;

  async run(): Promise<TAction> {
    const data = await this.sense();
    const decision = await this.think(data);
    return this.act(decision);
  }

  protected dateRange(daysBack: number): DateRange;
}

SpikeMcpClient

Typed client for the Spike MCP server with automatic retries:

const spike = new SpikeMcpClient("http://localhost:3001");

const sleep = await spike.getSleep(userId, { start: "2026-03-10", end: "2026-03-17" });
const hrv = await spike.getHrv(userId, dateRange);
const activity = await spike.getActivity(userId, dateRange);
const heartRate = await spike.getHeartRate(userId, dateRange);
const body = await spike.getBodyComposition(userId, dateRange);

createLlmProvider

Factory for swappable LLM providers via Vercel AI SDK:

const llm = createLlmProvider("claude", process.env.ANTHROPIC_API_KEY);
const response = await llm.complete([
  { role: "system", content: "You are a sleep expert." },
  { role: "user", content: "Analyze this sleep data..." },
], { temperature: 0.3 });

API Reference

Agent Configuration

Every agent accepts a base configuration:

interface BaseAgentConfig {
  spikeMcpUrl: string;        // Spike MCP server URL
  llmApiKey: string;          // API key for the LLM provider
  llmProvider?: "claude" | "openai" | "gemini";  // Default: "claude"
  userId: string;             // User to fetch health data for
  triggers: {
    schedule: string;         // Cron expression for scheduled runs
  };
}

Each agent extends this with its own thresholds. For example, the Sleep Coach adds:

interface SleepCoachConfig extends BaseAgentConfig {
  thresholds: {
    minSleepHours: number;     // Default: 7
    maxSleepDebt: number;      // Default: 5 (hours, rolling 7d)
    targetBedtime: string;     // Default: "23:00"
    targetWakeTime: string;    // Default: "07:00"
    minDeepSleepPct: number;   // Default: 15
    minRemPct: number;         // Default: 20
  };
}

Health Data Types

interface SleepSession {
  date: string;
  totalMinutes: number;
  deepMinutes: number;
  remMinutes: number;
  lightMinutes: number;
  awakeMinutes: number;
  efficiency: number;        // 0-100
  bedtime: string;           // "HH:mm"
  wakeTime: string;
  heartRateAvg: number;
  hrvAvg: number;
}

interface HrvReading       { timestamp: string; value: number; }
interface HeartRateReading  { timestamp: string; bpm: number; }
interface ActivitySummary   { date: string; steps: number; caloriesBurned: number; activeMinutes: number; strain: number; }
interface BodyComposition   { date: string; weight: number; bodyFat?: number; }

Building a Custom Agent

Use the Sleep Coach as a reference. Create a new agent in 4 steps:

1. Define your config schema

// agents/my-agent/src/config.ts
import { z } from "zod";
import { BaseAgentConfigSchema } from "@agentkit/core";

export const MyAgentConfigSchema = BaseAgentConfigSchema.extend({
  thresholds: z.object({
    myThreshold: z.number().default(42),
  }).default({}),
});

export type MyAgentConfig = z.infer<typeof MyAgentConfigSchema>;

2. Write your prompts

// agents/my-agent/src/prompts.ts
import type { LlmMessage } from "@agentkit/core";

export const SYSTEM_PROMPT = `You are an expert health analyst...`;

export function buildPrompt(data: MySenseData): LlmMessage[] {
  return [
    { role: "system", content: SYSTEM_PROMPT },
    { role: "user", content: JSON.stringify(data) },
  ];
}

3. Implement your agent

// agents/my-agent/src/agent.ts
import { BaseAgent } from "@agentkit/core";
import { MyAgentConfigSchema, type MyAgentConfig } from "./config.js";
import { buildPrompt } from "./prompts.js";

export class MyAgent extends BaseAgent<MyAgentConfig, MySenseData, MyDecision> {
  constructor(config: MyAgentConfig) {
    super(MyAgentConfigSchema.parse(config));
  }

  async sense(): Promise<MySenseData> {
    const sleep = await this.spike.getSleep(this.config.userId, this.dateRange(7));
    return { sleep };
  }

  async think(data: MySenseData): Promise<MyDecision> {
    const messages = buildPrompt(data);
    const raw = await this.llm.complete(messages);
    return JSON.parse(raw);
  }

  async act(decision: MyDecision): Promise<void> {
    console.log("Decision:", decision);
  }
}

4. Export and publish

// agents/my-agent/src/index.ts
export { MyAgent } from "./agent.js";
export type { MyAgentConfig } from "./config.js";

Marketplace

The marketplace is a Next.js 14 app at apps/marketplace/. It serves as the storefront for browsing, purchasing, and deploying agents.

Run locally

npm run dev --filter=@agentkit/marketplace

Opens at http://localhost:3000 with:

  • Landing page — Hero, feature grid, agent previews
  • Agent catalog — Browse and filter agents by category
  • Agent detail — Data requirements, code snippets, deploy button
  • Dashboard — Monitor deployed agents

Pages

Route Description
/ Landing page with hero and feature grid
/agents Agent catalog with category filters
/agents/[slug] Individual agent detail + deploy
/dashboard Deployed agent monitoring

Development

Build all packages

npm run build

Build a specific package

npx turbo build --filter=@agentkit/core
npx turbo build --filter=@agentkit/sleep-coach

Run tests

npm run test

Run the marketplace dev server

npm run dev --filter=@agentkit/marketplace

Project commands

Command Description
npm run build Build all packages with Turborepo
npm run dev Start all dev servers
npm run test Run all tests
npm run clean Clean all build artifacts

Supported Devices

Through Spike MCP, AgentKit Health connects to 500+ health devices including:

  • Wearables: Apple Watch, Fitbit, Garmin, Whoop, Oura Ring, Samsung Galaxy Watch
  • Smart Scales: Withings, Renpho, Garmin Index
  • CGMs: Dexcom, Freestyle Libre
  • Sleep Trackers: Eight Sleep, Dreem
  • Fitness: Peloton, Strava, TrainerRoad

All data is normalized into consistent TypeScript types by the SpikeMcpClient, so your agents work with any device.


Pricing

Package Price Includes
Sleep Coach $49 Single agent
Burnout Detector $59 Single agent
Circadian Scheduler $49 Single agent
Nutrition Timing $39 Single agent
Recovery Agent $69 Single agent
Jet Lag Agent $29 Single agent
Meeting Optimizer $79 Single agent
Supplement Timing $39 Single agent
Full Bundle $199 or $29/mo All 8 agents

Roadmap

  • Core package with BaseAgent, SpikeMcpClient, LLM provider
  • Sleep Coach Agent (fully implemented)
  • 7 agent stubs with typed configs
  • Next.js marketplace frontend
  • Implement remaining 7 agents
  • Supabase auth integration
  • Stripe checkout flow
  • Agent deployment dashboard (real-time status)
  • Webhook + push notification support in act()
  • OpenAI and Gemini provider support
  • Docker containers for self-hosted deployments
  • npm package publishing

Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feat/my-agent
  3. Follow the Building a Custom Agent guide
  4. Ensure npm run build passes
  5. Submit a pull request

License

MIT


Built with Spike MCP and Claude

About

Marketplace of pre-built AI agent templates for health workflows. Deploy Sleep Coach, Burnout Detector, Recovery Agent & more in minutes.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages