@thebriangao/totem 1.4.4 → 2.0.0
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/.dev.vars.example +5 -0
- package/.dockerignore +5 -0
- package/.env.example +29 -20
- package/CHANGELOG.md +99 -1
- package/CONTRIBUTING.md +48 -116
- package/Dockerfile +46 -12
- package/README.md +172 -498
- package/SECURITY.md +36 -59
- package/TOOLS.md +448 -311
- package/WHOOP.md +497 -2659
- package/assets/brand/SOURCES.md +38 -0
- package/assets/brand/totem.png +0 -0
- package/assets/brand/totem.svg +13 -0
- package/assets/fonts/Manrope-OFL.txt +93 -0
- package/assets/fonts/manrope-latin.woff2 +0 -0
- package/dist/build_info.js +5 -0
- package/dist/build_info.js.map +1 -0
- package/dist/cli/app.js +675 -0
- package/dist/cli/app.js.map +1 -0
- package/dist/cli/auth.js +297 -0
- package/dist/cli/auth.js.map +1 -0
- package/dist/cli/auth_flow.js +268 -0
- package/dist/cli/auth_flow.js.map +1 -0
- package/dist/cli/browser_login.js +368 -0
- package/dist/cli/browser_login.js.map +1 -0
- package/dist/cli/clients.js +403 -0
- package/dist/cli/clients.js.map +1 -0
- package/dist/cli/deploy_record.js +96 -0
- package/dist/cli/deploy_record.js.map +1 -0
- package/dist/cli/index.js +39 -575
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/links.js +28 -0
- package/dist/cli/links.js.map +1 -0
- package/dist/cli/logo.js +63 -0
- package/dist/cli/logo.js.map +1 -0
- package/dist/cli/setup.js +1157 -1017
- package/dist/cli/setup.js.map +1 -1
- package/dist/cli/spawn.js +80 -0
- package/dist/cli/spawn.js.map +1 -0
- package/dist/cli/sys.js +219 -0
- package/dist/cli/sys.js.map +1 -0
- package/dist/cli/ui.js +712 -463
- package/dist/cli/ui.js.map +1 -1
- package/dist/cli/update.js +425 -282
- package/dist/cli/update.js.map +1 -1
- package/dist/cloudflare/token_store.js +48 -0
- package/dist/cloudflare/token_store.js.map +1 -0
- package/dist/cloudflare/worker.js +155 -0
- package/dist/cloudflare/worker.js.map +1 -0
- package/dist/data/behaviors.js +2733 -617
- package/dist/data/behaviors.js.map +1 -1
- package/dist/data/endpoint_catalog.js +2681 -0
- package/dist/data/endpoint_catalog.js.map +1 -0
- package/dist/data/exercises.js +373 -4859
- package/dist/data/exercises.js.map +1 -1
- package/dist/data/garments.js +19 -0
- package/dist/data/garments.js.map +1 -0
- package/dist/data/sports.js +219 -208
- package/dist/data/sports.js.map +1 -1
- package/dist/lib/activity_list.js +123 -0
- package/dist/lib/activity_list.js.map +1 -0
- package/dist/lib/activity_records.js +195 -0
- package/dist/lib/activity_records.js.map +1 -0
- package/dist/lib/activity_results.js +44 -0
- package/dist/lib/activity_results.js.map +1 -0
- package/dist/lib/activity_types.js +164 -0
- package/dist/lib/activity_types.js.map +1 -0
- package/dist/lib/brand.js +63 -0
- package/dist/lib/brand.js.map +1 -0
- package/dist/lib/clock.js +24 -0
- package/dist/lib/clock.js.map +1 -0
- package/dist/lib/coach_session.js +345 -0
- package/dist/lib/coach_session.js.map +1 -0
- package/dist/lib/concurrency.js.map +1 -1
- package/dist/lib/dates.js +19 -0
- package/dist/lib/dates.js.map +1 -1
- package/dist/lib/env_file.js +195 -0
- package/dist/lib/env_file.js.map +1 -0
- package/dist/lib/health_plans_write.js +44 -0
- package/dist/lib/health_plans_write.js.map +1 -0
- package/dist/lib/heart_rate.js +34 -0
- package/dist/lib/heart_rate.js.map +1 -0
- package/dist/lib/highlight.js +81 -0
- package/dist/lib/highlight.js.map +1 -0
- package/dist/lib/install_links.js +47 -0
- package/dist/lib/install_links.js.map +1 -0
- package/dist/lib/instant.js +50 -0
- package/dist/lib/instant.js.map +1 -0
- package/dist/lib/journal_behaviors.js +382 -0
- package/dist/lib/journal_behaviors.js.map +1 -0
- package/dist/lib/lift_catalog.js +218 -0
- package/dist/lib/lift_catalog.js.map +1 -0
- package/dist/lib/lift_history.js +66 -0
- package/dist/lib/lift_history.js.map +1 -0
- package/dist/lib/lift_sets.js +146 -0
- package/dist/lib/lift_sets.js.map +1 -0
- package/dist/lib/lift_tool.js +20 -0
- package/dist/lib/lift_tool.js.map +1 -0
- package/dist/lib/profile_settings.js +101 -0
- package/dist/lib/profile_settings.js.map +1 -0
- package/dist/lib/screen_content.js +44 -0
- package/dist/lib/screen_content.js.map +1 -0
- package/dist/lib/timezone.js +48 -6
- package/dist/lib/timezone.js.map +1 -1
- package/dist/lib/walk.js +6 -1
- package/dist/lib/walk.js.map +1 -1
- package/dist/lib/weight_readings.js +61 -0
- package/dist/lib/weight_readings.js.map +1 -0
- package/dist/projections/activities.js +193 -0
- package/dist/projections/activities.js.map +1 -0
- package/dist/projections/alarm_schedule.js +102 -0
- package/dist/projections/alarm_schedule.js.map +1 -0
- package/dist/projections/coach.js +203 -0
- package/dist/projections/coach.js.map +1 -0
- package/dist/projections/community.js +165 -0
- package/dist/projections/community.js.map +1 -0
- package/dist/projections/health_features.js +167 -0
- package/dist/projections/health_features.js.map +1 -0
- package/dist/projections/hormonal_insights.js +239 -0
- package/dist/projections/hormonal_insights.js.map +1 -0
- package/dist/projections/journal_v2.js +157 -0
- package/dist/projections/journal_v2.js.map +1 -0
- package/dist/projections/lift_cards.js +115 -0
- package/dist/projections/lift_cards.js.map +1 -0
- package/dist/projections/lift_exercise_v2.js +131 -0
- package/dist/projections/lift_exercise_v2.js.map +1 -0
- package/dist/projections/lift_library_v2.js +67 -0
- package/dist/projections/lift_library_v2.js.map +1 -0
- package/dist/projections/lift_sessions.js +211 -0
- package/dist/projections/lift_sessions.js.map +1 -0
- package/dist/projections/memory.js +95 -0
- package/dist/projections/memory.js.map +1 -0
- package/dist/projections/milestones.js +119 -0
- package/dist/projections/milestones.js.map +1 -0
- package/dist/projections/profile_v2.js +150 -0
- package/dist/projections/profile_v2.js.map +1 -0
- package/dist/projections/settings_v2.js +153 -0
- package/dist/projections/settings_v2.js.map +1 -0
- package/dist/projections/sleep.js +4 -21
- package/dist/projections/sleep.js.map +1 -1
- package/dist/projections/v2/calendar.js +43 -0
- package/dist/projections/v2/calendar.js.map +1 -0
- package/dist/projections/v2/core_common.js +86 -0
- package/dist/projections/v2/core_common.js.map +1 -0
- package/dist/projections/v2/core_home.js +136 -0
- package/dist/projections/v2/core_home.js.map +1 -0
- package/dist/projections/v2/core_sleep_need.js +23 -0
- package/dist/projections/v2/core_sleep_need.js.map +1 -0
- package/dist/projections/v2/day.js +92 -0
- package/dist/projections/v2/day.js.map +1 -0
- package/dist/projections/v2/heart_rate.js +54 -0
- package/dist/projections/v2/heart_rate.js.map +1 -0
- package/dist/projections/v2/history.js +140 -0
- package/dist/projections/v2/history.js.map +1 -0
- package/dist/projections/v2/now.js +39 -0
- package/dist/projections/v2/now.js.map +1 -0
- package/dist/projections/v2/recovery.js +77 -0
- package/dist/projections/v2/recovery.js.map +1 -0
- package/dist/projections/v2/sleep.js +218 -0
- package/dist/projections/v2/sleep.js.map +1 -0
- package/dist/projections/v2/strain.js +39 -0
- package/dist/projections/v2/strain.js.map +1 -0
- package/dist/projections/v2/stress.js +92 -0
- package/dist/projections/v2/stress.js.map +1 -0
- package/dist/projections/v2/trend.js +205 -0
- package/dist/projections/v2/trend.js.map +1 -0
- package/dist/projections/weekly_plan.js +66 -0
- package/dist/projections/weekly_plan.js.map +1 -0
- package/dist/projections/weight_readings.js +57 -0
- package/dist/projections/weight_readings.js.map +1 -0
- package/dist/projections/workout.js +37 -15
- package/dist/projections/workout.js.map +1 -1
- package/dist/schemas/activities.js +123 -0
- package/dist/schemas/activities.js.map +1 -0
- package/dist/schemas/alarm_schedule.js +62 -0
- package/dist/schemas/alarm_schedule.js.map +1 -0
- package/dist/schemas/coach.js +76 -8
- package/dist/schemas/coach.js.map +1 -1
- package/dist/schemas/community.js +70 -0
- package/dist/schemas/community.js.map +1 -0
- package/dist/schemas/health.js +36 -0
- package/dist/schemas/health.js.map +1 -0
- package/dist/schemas/hormonal_insights.js +90 -0
- package/dist/schemas/hormonal_insights.js.map +1 -0
- package/dist/schemas/journal.js +4 -0
- package/dist/schemas/journal.js.map +1 -1
- package/dist/schemas/journal_v2.js +106 -0
- package/dist/schemas/journal_v2.js.map +1 -0
- package/dist/schemas/memory.js +42 -0
- package/dist/schemas/memory.js.map +1 -0
- package/dist/schemas/milestones.js +39 -0
- package/dist/schemas/milestones.js.map +1 -0
- package/dist/schemas/profile_v2.js +60 -0
- package/dist/schemas/profile_v2.js.map +1 -0
- package/dist/schemas/settings_v2.js +56 -0
- package/dist/schemas/settings_v2.js.map +1 -0
- package/dist/schemas/sleep.js +8 -1
- package/dist/schemas/sleep.js.map +1 -1
- package/dist/schemas/strength.js +10 -1
- package/dist/schemas/strength.js.map +1 -1
- package/dist/schemas/strength_v2.js +190 -0
- package/dist/schemas/strength_v2.js.map +1 -0
- package/dist/schemas/v2/calendar.js +8 -0
- package/dist/schemas/v2/calendar.js.map +1 -0
- package/dist/schemas/v2/core_common.js +42 -0
- package/dist/schemas/v2/core_common.js.map +1 -0
- package/dist/schemas/v2/day.js +73 -0
- package/dist/schemas/v2/day.js.map +1 -0
- package/dist/schemas/v2/now.js +25 -0
- package/dist/schemas/v2/now.js.map +1 -0
- package/dist/schemas/v2/recovery.js +35 -0
- package/dist/schemas/v2/recovery.js.map +1 -0
- package/dist/schemas/v2/sleep.js +44 -0
- package/dist/schemas/v2/sleep.js.map +1 -0
- package/dist/schemas/v2/strain.js +16 -0
- package/dist/schemas/v2/strain.js.map +1 -0
- package/dist/schemas/v2/stress.js +20 -0
- package/dist/schemas/v2/stress.js.map +1 -0
- package/dist/schemas/v2/trend.js +42 -0
- package/dist/schemas/v2/trend.js.map +1 -0
- package/dist/schemas/weekly_plan.js +31 -0
- package/dist/schemas/weekly_plan.js.map +1 -0
- package/dist/schemas/weight.js +28 -0
- package/dist/schemas/weight.js.map +1 -0
- package/dist/scripts/build_behaviors.js +114 -0
- package/dist/scripts/build_behaviors.js.map +1 -0
- package/dist/scripts/cognito_bootstrap.js +9 -277
- package/dist/scripts/cognito_bootstrap.js.map +1 -1
- package/dist/scripts/gen_activity_catalogs.js +104 -0
- package/dist/scripts/gen_activity_catalogs.js.map +1 -0
- package/dist/server-admin.js +156 -0
- package/dist/server-admin.js.map +1 -0
- package/dist/server-http.js +270 -48
- package/dist/server-http.js.map +1 -1
- package/dist/server.js +136 -23
- package/dist/server.js.map +1 -1
- package/dist/tools/annotations.js +15 -0
- package/dist/tools/annotations.js.map +1 -0
- package/dist/tools/define.js +31 -0
- package/dist/tools/define.js.map +1 -0
- package/dist/tools/register.js +59 -94
- package/dist/tools/register.js.map +1 -1
- package/dist/tools/resources.js +70 -0
- package/dist/tools/resources.js.map +1 -0
- package/dist/tools/slim_schema.js +90 -0
- package/dist/tools/slim_schema.js.map +1 -0
- package/dist/tools/v2/activity_delete.js +63 -17
- package/dist/tools/v2/activity_delete.js.map +1 -1
- package/dist/tools/v2/activity_edit.js +396 -0
- package/dist/tools/v2/activity_edit.js.map +1 -0
- package/dist/tools/v2/activity_log.js +152 -0
- package/dist/tools/v2/activity_log.js.map +1 -0
- package/dist/tools/v2/calendar.js +19 -21
- package/dist/tools/v2/calendar.js.map +1 -1
- package/dist/tools/v2/coach_ask.js +74 -110
- package/dist/tools/v2/coach_ask.js.map +1 -1
- package/dist/tools/v2/coach_history.js +120 -0
- package/dist/tools/v2/coach_history.js.map +1 -0
- package/dist/tools/v2/community.js +124 -0
- package/dist/tools/v2/community.js.map +1 -0
- package/dist/tools/v2/cycle.js +63 -15
- package/dist/tools/v2/cycle.js.map +1 -1
- package/dist/tools/v2/cycle_log.js +289 -32
- package/dist/tools/v2/cycle_log.js.map +1 -1
- package/dist/tools/v2/day.js +126 -24
- package/dist/tools/v2/day.js.map +1 -1
- package/dist/tools/v2/health.js +116 -0
- package/dist/tools/v2/health.js.map +1 -0
- package/dist/tools/v2/hr_zones_set.js +134 -34
- package/dist/tools/v2/hr_zones_set.js.map +1 -1
- package/dist/tools/v2/journal.js +75 -17
- package/dist/tools/v2/journal.js.map +1 -1
- package/dist/tools/v2/journal_log.js +306 -65
- package/dist/tools/v2/journal_log.js.map +1 -1
- package/dist/tools/v2/lift_exercise.js +125 -22
- package/dist/tools/v2/lift_exercise.js.map +1 -1
- package/dist/tools/v2/lift_exercise_set.js +291 -0
- package/dist/tools/v2/lift_exercise_set.js.map +1 -0
- package/dist/tools/v2/lift_library.js +51 -12
- package/dist/tools/v2/lift_library.js.map +1 -1
- package/dist/tools/v2/lift_log.js +309 -72
- package/dist/tools/v2/lift_log.js.map +1 -1
- package/dist/tools/v2/lift_sessions.js +248 -0
- package/dist/tools/v2/lift_sessions.js.map +1 -0
- package/dist/tools/v2/lift_template.js +232 -0
- package/dist/tools/v2/lift_template.js.map +1 -0
- package/dist/tools/v2/memory.js +45 -0
- package/dist/tools/v2/memory.js.map +1 -0
- package/dist/tools/v2/memory_set.js +107 -0
- package/dist/tools/v2/memory_set.js.map +1 -0
- package/dist/tools/v2/milestones.js +50 -0
- package/dist/tools/v2/milestones.js.map +1 -0
- package/dist/tools/v2/now.js +49 -0
- package/dist/tools/v2/now.js.map +1 -0
- package/dist/tools/v2/preferences.js +51 -0
- package/dist/tools/v2/preferences.js.map +1 -0
- package/dist/tools/v2/preferences_set.js +388 -0
- package/dist/tools/v2/preferences_set.js.map +1 -0
- package/dist/tools/v2/profile.js +54 -22
- package/dist/tools/v2/profile.js.map +1 -1
- package/dist/tools/v2/profile_update.js +167 -55
- package/dist/tools/v2/profile_update.js.map +1 -1
- package/dist/tools/v2/raw.js +91 -34
- package/dist/tools/v2/raw.js.map +1 -1
- package/dist/tools/v2/recovery.js +37 -23
- package/dist/tools/v2/recovery.js.map +1 -1
- package/dist/tools/v2/sleep.js +52 -16
- package/dist/tools/v2/sleep.js.map +1 -1
- package/dist/tools/v2/smart_alarm.js +54 -20
- package/dist/tools/v2/smart_alarm.js.map +1 -1
- package/dist/tools/v2/smart_alarm_set.js +264 -86
- package/dist/tools/v2/smart_alarm_set.js.map +1 -1
- package/dist/tools/v2/strain.js +15 -15
- package/dist/tools/v2/strain.js.map +1 -1
- package/dist/tools/v2/stress.js +17 -15
- package/dist/tools/v2/stress.js.map +1 -1
- package/dist/tools/v2/trend.js +56 -20
- package/dist/tools/v2/trend.js.map +1 -1
- package/dist/tools/v2/weekly_plan.js +30 -0
- package/dist/tools/v2/weekly_plan.js.map +1 -0
- package/dist/tools/v2/weekly_plan_set.js +134 -0
- package/dist/tools/v2/weekly_plan_set.js.map +1 -0
- package/dist/tools/v2/weight.js +56 -0
- package/dist/tools/v2/weight.js.map +1 -0
- package/dist/tools/v2/weight_log.js +188 -0
- package/dist/tools/v2/weight_log.js.map +1 -0
- package/dist/tools/v2/workouts.js +159 -25
- package/dist/tools/v2/workouts.js.map +1 -1
- package/dist/version.js +6 -0
- package/dist/version.js.map +1 -0
- package/dist/whoop/bff.js +94 -0
- package/dist/whoop/bff.js.map +1 -0
- package/dist/whoop/client.js +392 -18
- package/dist/whoop/client.js.map +1 -1
- package/dist/whoop/cognito.js +106 -79
- package/dist/whoop/cognito.js.map +1 -1
- package/dist/whoop/connect_page.js +165 -0
- package/dist/whoop/connect_page.js.map +1 -0
- package/dist/whoop/consent_font.js +287 -0
- package/dist/whoop/consent_font.js.map +1 -0
- package/dist/whoop/consent_logos.js +22 -0
- package/dist/whoop/consent_logos.js.map +1 -0
- package/dist/whoop/consent_page.js +291 -0
- package/dist/whoop/consent_page.js.map +1 -0
- package/dist/whoop/constants.js +5 -1
- package/dist/whoop/constants.js.map +1 -1
- package/dist/whoop/device.js +4 -4
- package/dist/whoop/device.js.map +1 -1
- package/dist/whoop/errors.js +85 -4
- package/dist/whoop/errors.js.map +1 -1
- package/dist/whoop/init_timezone.js +57 -17
- package/dist/whoop/init_timezone.js.map +1 -1
- package/dist/whoop/installation.js +15 -10
- package/dist/whoop/installation.js.map +1 -1
- package/dist/whoop/json_out.js +52 -6
- package/dist/whoop/json_out.js.map +1 -1
- package/dist/whoop/oauth_provider.js +81 -78
- package/dist/whoop/oauth_provider.js.map +1 -1
- package/dist/whoop/token_lock.js +331 -0
- package/dist/whoop/token_lock.js.map +1 -0
- package/dist/whoop/token_manager.js +536 -42
- package/dist/whoop/token_manager.js.map +1 -1
- package/dist/whoop/token_store.js +303 -36
- package/dist/whoop/token_store.js.map +1 -1
- package/dist/whoop/units.js +28 -0
- package/dist/whoop/units.js.map +1 -0
- package/package.json +29 -13
- package/scripts/build-mcpb.mjs +72 -0
- package/scripts/embed-consent-font.mjs +34 -0
- package/scripts/readme-media.ts +195 -0
- package/scripts/tools-md.ts +89 -0
- package/scripts/whoop-md.ts +119 -0
- package/src/build_info.ts +4 -0
- package/src/cli/app.ts +696 -0
- package/src/cli/auth.ts +350 -0
- package/src/cli/auth_flow.ts +356 -0
- package/src/cli/browser_login.ts +402 -0
- package/src/cli/clients.ts +467 -0
- package/src/cli/deploy_record.ts +100 -0
- package/src/cli/index.ts +41 -583
- package/src/cli/links.ts +43 -0
- package/src/cli/logo.ts +64 -0
- package/src/cli/setup.ts +1147 -979
- package/src/cli/spawn.ts +88 -0
- package/src/cli/sys.ts +267 -0
- package/src/cli/ui.ts +778 -436
- package/src/cli/update.ts +436 -274
- package/src/cloudflare/runtime.d.ts +27 -0
- package/src/cloudflare/token_store.ts +57 -0
- package/src/cloudflare/worker.ts +174 -0
- package/src/data/behaviors.ts +2760 -622
- package/src/data/endpoint_catalog.ts +2695 -0
- package/src/data/exercises.ts +379 -4861
- package/src/data/garments.ts +28 -0
- package/src/data/sports.ts +239 -211
- package/src/lib/activity_list.ts +150 -0
- package/src/lib/activity_records.ts +213 -0
- package/src/lib/activity_results.ts +51 -0
- package/src/lib/activity_types.ts +176 -0
- package/src/lib/brand.ts +71 -0
- package/src/lib/clock.ts +16 -0
- package/src/lib/coach_session.ts +434 -0
- package/src/lib/dates.ts +18 -0
- package/src/lib/env_file.ts +191 -0
- package/src/lib/health_plans_write.ts +53 -0
- package/src/lib/heart_rate.ts +42 -0
- package/src/lib/highlight.ts +71 -0
- package/src/lib/install_links.ts +61 -0
- package/src/lib/instant.ts +54 -0
- package/src/lib/journal_behaviors.ts +453 -0
- package/src/lib/lift_catalog.ts +258 -0
- package/src/lib/lift_history.ts +75 -0
- package/src/lib/lift_sets.ts +164 -0
- package/src/lib/lift_tool.ts +25 -0
- package/src/lib/profile_settings.ts +102 -0
- package/src/lib/screen_content.ts +40 -0
- package/src/lib/timezone.ts +44 -8
- package/src/lib/walk.ts +4 -1
- package/src/lib/weight_readings.ts +82 -0
- package/src/projections/activities.ts +199 -0
- package/src/projections/alarm_schedule.ts +98 -0
- package/src/projections/coach.ts +218 -0
- package/src/projections/community.ts +187 -0
- package/src/projections/health_features.ts +191 -0
- package/src/projections/hormonal_insights.ts +277 -0
- package/src/projections/journal_v2.ts +173 -0
- package/src/projections/lift_cards.ts +131 -0
- package/src/projections/lift_exercise_v2.ts +147 -0
- package/src/projections/lift_library_v2.ts +77 -0
- package/src/projections/lift_sessions.ts +250 -0
- package/src/projections/memory.ts +100 -0
- package/src/projections/milestones.ts +133 -0
- package/src/projections/profile_v2.ts +166 -0
- package/src/projections/settings_v2.ts +179 -0
- package/src/projections/sleep.ts +7 -21
- package/src/projections/v2/calendar.ts +48 -0
- package/src/projections/v2/core_common.ts +95 -0
- package/src/projections/v2/core_home.ts +177 -0
- package/src/projections/v2/core_sleep_need.ts +37 -0
- package/src/projections/v2/day.ts +162 -0
- package/src/projections/v2/heart_rate.ts +73 -0
- package/src/projections/v2/history.ts +153 -0
- package/src/projections/v2/now.ts +59 -0
- package/src/projections/v2/recovery.ts +120 -0
- package/src/projections/v2/sleep.ts +281 -0
- package/src/projections/v2/strain.ts +63 -0
- package/src/projections/v2/stress.ts +111 -0
- package/src/projections/v2/trend.ts +242 -0
- package/src/projections/weekly_plan.ts +79 -0
- package/src/projections/weight_readings.ts +57 -0
- package/src/projections/workout.ts +36 -17
- package/src/schemas/activities.ts +136 -0
- package/src/schemas/alarm_schedule.ts +70 -0
- package/src/schemas/coach.ts +98 -8
- package/src/schemas/community.ts +77 -0
- package/src/schemas/health.ts +36 -0
- package/src/schemas/hormonal_insights.ts +108 -0
- package/src/schemas/journal.ts +4 -0
- package/src/schemas/journal_v2.ts +112 -0
- package/src/schemas/memory.ts +48 -0
- package/src/schemas/milestones.ts +48 -0
- package/src/schemas/profile_v2.ts +63 -0
- package/src/schemas/settings_v2.ts +63 -0
- package/src/schemas/sleep.ts +9 -1
- package/src/schemas/strength.ts +10 -1
- package/src/schemas/strength_v2.ts +210 -0
- package/src/schemas/v2/calendar.ts +8 -0
- package/src/schemas/v2/core_common.ts +50 -0
- package/src/schemas/v2/day.ts +79 -0
- package/src/schemas/v2/now.ts +25 -0
- package/src/schemas/v2/recovery.ts +38 -0
- package/src/schemas/v2/sleep.ts +46 -0
- package/src/schemas/v2/strain.ts +16 -0
- package/src/schemas/v2/stress.ts +20 -0
- package/src/schemas/v2/trend.ts +45 -0
- package/src/schemas/weekly_plan.ts +36 -0
- package/src/schemas/weight.ts +53 -0
- package/src/scripts/build_behaviors.ts +116 -0
- package/src/scripts/cognito_bootstrap.ts +10 -249
- package/src/scripts/gen_activity_catalogs.ts +121 -0
- package/src/server-admin.ts +171 -0
- package/src/server-http.ts +290 -53
- package/src/server.ts +130 -26
- package/src/tools/annotations.ts +25 -0
- package/src/tools/define.ts +53 -0
- package/src/tools/register.ts +64 -94
- package/src/tools/resources.ts +92 -0
- package/src/tools/slim_schema.ts +102 -0
- package/src/tools/v2/activity_delete.ts +61 -23
- package/src/tools/v2/activity_edit.ts +378 -0
- package/src/tools/v2/activity_log.ts +154 -0
- package/src/tools/v2/calendar.ts +22 -21
- package/src/tools/v2/coach_ask.ts +83 -119
- package/src/tools/v2/coach_history.ts +140 -0
- package/src/tools/v2/community.ts +137 -0
- package/src/tools/v2/cycle.ts +78 -20
- package/src/tools/v2/cycle_log.ts +291 -40
- package/src/tools/v2/day.ts +126 -25
- package/src/tools/v2/health.ts +114 -0
- package/src/tools/v2/hr_zones_set.ts +132 -45
- package/src/tools/v2/journal.ts +78 -23
- package/src/tools/v2/journal_log.ts +321 -69
- package/src/tools/v2/lift_exercise.ts +135 -27
- package/src/tools/v2/lift_exercise_set.ts +272 -0
- package/src/tools/v2/lift_library.ts +57 -21
- package/src/tools/v2/lift_log.ts +325 -83
- package/src/tools/v2/lift_sessions.ts +255 -0
- package/src/tools/v2/lift_template.ts +229 -0
- package/src/tools/v2/memory.ts +54 -0
- package/src/tools/v2/memory_set.ts +110 -0
- package/src/tools/v2/milestones.ts +59 -0
- package/src/tools/v2/now.ts +61 -0
- package/src/tools/v2/preferences.ts +61 -0
- package/src/tools/v2/preferences_set.ts +403 -0
- package/src/tools/v2/profile.ts +56 -26
- package/src/tools/v2/profile_update.ts +151 -60
- package/src/tools/v2/raw.ts +89 -36
- package/src/tools/v2/recovery.ts +44 -25
- package/src/tools/v2/sleep.ts +57 -18
- package/src/tools/v2/smart_alarm.ts +62 -24
- package/src/tools/v2/smart_alarm_set.ts +240 -90
- package/src/tools/v2/strain.ts +19 -16
- package/src/tools/v2/stress.ts +22 -17
- package/src/tools/v2/trend.ts +58 -20
- package/src/tools/v2/weekly_plan.ts +38 -0
- package/src/tools/v2/weekly_plan_set.ts +132 -0
- package/src/tools/v2/weight.ts +61 -0
- package/src/tools/v2/weight_log.ts +193 -0
- package/src/tools/v2/workouts.ts +156 -26
- package/src/version.ts +5 -0
- package/src/whoop/bff.ts +84 -0
- package/src/whoop/client.ts +448 -18
- package/src/whoop/cognito.ts +110 -99
- package/src/whoop/connect_page.ts +183 -0
- package/src/whoop/consent_font.ts +289 -0
- package/src/whoop/consent_logos.ts +24 -0
- package/src/whoop/consent_page.ts +326 -0
- package/src/whoop/constants.ts +5 -1
- package/src/whoop/device.ts +4 -4
- package/src/whoop/errors.ts +89 -4
- package/src/whoop/init_timezone.ts +57 -16
- package/src/whoop/installation.ts +16 -7
- package/src/whoop/json_out.ts +51 -6
- package/src/whoop/oauth_provider.ts +84 -91
- package/src/whoop/token_lock.ts +345 -0
- package/src/whoop/token_manager.ts +580 -53
- package/src/whoop/token_store.ts +341 -32
- package/src/whoop/units.ts +35 -0
- package/wrangler.jsonc +17 -0
- package/assets/banner.svg +0 -38
- package/dist/data/endpoints.js +0 -320
- package/dist/data/endpoints.js.map +0 -1
- package/dist/lib/format.js +0 -22
- package/dist/lib/format.js.map +0 -1
- package/dist/lib/stats.js +0 -32
- package/dist/lib/stats.js.map +0 -1
- package/dist/projections/calendar.js +0 -33
- package/dist/projections/calendar.js.map +0 -1
- package/dist/projections/communities.js +0 -105
- package/dist/projections/communities.js.map +0 -1
- package/dist/projections/cycle.js +0 -81
- package/dist/projections/cycle.js.map +0 -1
- package/dist/projections/hr_zones.js +0 -35
- package/dist/projections/hr_zones.js.map +0 -1
- package/dist/projections/journal.js +0 -56
- package/dist/projections/journal.js.map +0 -1
- package/dist/projections/leaderboard.js +0 -37
- package/dist/projections/leaderboard.js.map +0 -1
- package/dist/projections/lift_exercise.js +0 -22
- package/dist/projections/lift_exercise.js.map +0 -1
- package/dist/projections/lift_history.js +0 -133
- package/dist/projections/lift_history.js.map +0 -1
- package/dist/projections/lift_library.js +0 -71
- package/dist/projections/lift_library.js.map +0 -1
- package/dist/projections/lift_progression.js +0 -138
- package/dist/projections/lift_progression.js.map +0 -1
- package/dist/projections/lift_prs.js +0 -20
- package/dist/projections/lift_prs.js.map +0 -1
- package/dist/projections/live_hr.js +0 -19
- package/dist/projections/live_hr.js.map +0 -1
- package/dist/projections/live_state.js +0 -23
- package/dist/projections/live_state.js.map +0 -1
- package/dist/projections/live_stress.js +0 -11
- package/dist/projections/live_stress.js.map +0 -1
- package/dist/projections/performance_assessment.js +0 -15
- package/dist/projections/performance_assessment.js.map +0 -1
- package/dist/projections/profile.js +0 -59
- package/dist/projections/profile.js.map +0 -1
- package/dist/projections/recovery.js +0 -131
- package/dist/projections/recovery.js.map +0 -1
- package/dist/projections/sleep_need.js +0 -32
- package/dist/projections/sleep_need.js.map +0 -1
- package/dist/projections/smart_alarm.js +0 -45
- package/dist/projections/smart_alarm.js.map +0 -1
- package/dist/projections/strain.js +0 -128
- package/dist/projections/strain.js.map +0 -1
- package/dist/projections/stress.js +0 -86
- package/dist/projections/stress.js.map +0 -1
- package/dist/projections/today.js +0 -129
- package/dist/projections/today.js.map +0 -1
- package/dist/projections/trend.js +0 -149
- package/dist/projections/trend.js.map +0 -1
- package/dist/projections/workouts.js +0 -37
- package/dist/projections/workouts.js.map +0 -1
- package/dist/schemas/calendar.js +0 -12
- package/dist/schemas/calendar.js.map +0 -1
- package/dist/schemas/communities.js +0 -51
- package/dist/schemas/communities.js.map +0 -1
- package/dist/schemas/compare.js +0 -15
- package/dist/schemas/compare.js.map +0 -1
- package/dist/schemas/leaderboard.js +0 -25
- package/dist/schemas/leaderboard.js.map +0 -1
- package/dist/schemas/live.js +0 -26
- package/dist/schemas/live.js.map +0 -1
- package/dist/schemas/performance.js +0 -12
- package/dist/schemas/performance.js.map +0 -1
- package/dist/schemas/profile.js +0 -39
- package/dist/schemas/profile.js.map +0 -1
- package/dist/schemas/recovery.js +0 -27
- package/dist/schemas/recovery.js.map +0 -1
- package/dist/schemas/settings.js +0 -26
- package/dist/schemas/settings.js.map +0 -1
- package/dist/schemas/sleep_need.js +0 -15
- package/dist/schemas/sleep_need.js.map +0 -1
- package/dist/schemas/smart_alarm.js +0 -36
- package/dist/schemas/smart_alarm.js.map +0 -1
- package/dist/schemas/strain.js +0 -24
- package/dist/schemas/strain.js.map +0 -1
- package/dist/schemas/stress.js +0 -16
- package/dist/schemas/stress.js.map +0 -1
- package/dist/schemas/today.js +0 -38
- package/dist/schemas/today.js.map +0 -1
- package/dist/schemas/trend.js +0 -50
- package/dist/schemas/trend.js.map +0 -1
- package/dist/schemas/womens_health.js +0 -23
- package/dist/schemas/womens_health.js.map +0 -1
- package/dist/tools/v2/activity_create.js +0 -64
- package/dist/tools/v2/activity_create.js.map +0 -1
- package/dist/tools/v2/behavior_impact.js +0 -36
- package/dist/tools/v2/behavior_impact.js.map +0 -1
- package/dist/tools/v2/communities.js +0 -60
- package/dist/tools/v2/communities.js.map +0 -1
- package/dist/tools/v2/compare.js +0 -67
- package/dist/tools/v2/compare.js.map +0 -1
- package/dist/tools/v2/endpoints.js +0 -28
- package/dist/tools/v2/endpoints.js.map +0 -1
- package/dist/tools/v2/hidden_metric.js +0 -28
- package/dist/tools/v2/hidden_metric.js.map +0 -1
- package/dist/tools/v2/hr_zones.js +0 -24
- package/dist/tools/v2/hr_zones.js.map +0 -1
- package/dist/tools/v2/journal_autopop.js +0 -19
- package/dist/tools/v2/journal_autopop.js.map +0 -1
- package/dist/tools/v2/journal_catalog.js +0 -44
- package/dist/tools/v2/journal_catalog.js.map +0 -1
- package/dist/tools/v2/leaderboard.js +0 -79
- package/dist/tools/v2/leaderboard.js.map +0 -1
- package/dist/tools/v2/lift_catalog.js +0 -47
- package/dist/tools/v2/lift_catalog.js.map +0 -1
- package/dist/tools/v2/lift_custom_exercise.js +0 -108
- package/dist/tools/v2/lift_custom_exercise.js.map +0 -1
- package/dist/tools/v2/lift_history.js +0 -39
- package/dist/tools/v2/lift_history.js.map +0 -1
- package/dist/tools/v2/lift_progression.js +0 -30
- package/dist/tools/v2/lift_progression.js.map +0 -1
- package/dist/tools/v2/lift_prs.js +0 -21
- package/dist/tools/v2/lift_prs.js.map +0 -1
- package/dist/tools/v2/lift_template_save.js +0 -83
- package/dist/tools/v2/lift_template_save.js.map +0 -1
- package/dist/tools/v2/live_hr.js +0 -21
- package/dist/tools/v2/live_hr.js.map +0 -1
- package/dist/tools/v2/live_state.js +0 -21
- package/dist/tools/v2/live_state.js.map +0 -1
- package/dist/tools/v2/live_stress.js +0 -22
- package/dist/tools/v2/live_stress.js.map +0 -1
- package/dist/tools/v2/performance_assessment.js +0 -38
- package/dist/tools/v2/performance_assessment.js.map +0 -1
- package/dist/tools/v2/sleep_need.js +0 -21
- package/dist/tools/v2/sleep_need.js.map +0 -1
- package/dist/tools/v2/sports_catalog.js +0 -26
- package/dist/tools/v2/sports_catalog.js.map +0 -1
- package/dist/tools/v2/symptom_log.js +0 -72
- package/dist/tools/v2/symptom_log.js.map +0 -1
- package/dist/tools/v2/today.js +0 -30
- package/dist/tools/v2/today.js.map +0 -1
- package/dist/tools/v2/workout.js +0 -23
- package/dist/tools/v2/workout.js.map +0 -1
- package/dist/whoop/build_lift_body.js +0 -67
- package/dist/whoop/build_lift_body.js.map +0 -1
- package/dist/whoop/session_state.js +0 -34
- package/dist/whoop/session_state.js.map +0 -1
- package/dist/whoop/types.js +0 -82
- package/dist/whoop/types.js.map +0 -1
- package/src/data/endpoints.ts +0 -319
- package/src/lib/format.ts +0 -27
- package/src/lib/stats.ts +0 -35
- package/src/projections/calendar.ts +0 -46
- package/src/projections/communities.ts +0 -135
- package/src/projections/cycle.ts +0 -85
- package/src/projections/hr_zones.ts +0 -43
- package/src/projections/journal.ts +0 -55
- package/src/projections/leaderboard.ts +0 -49
- package/src/projections/lift_exercise.ts +0 -29
- package/src/projections/lift_history.ts +0 -140
- package/src/projections/lift_library.ts +0 -70
- package/src/projections/lift_progression.ts +0 -138
- package/src/projections/lift_prs.ts +0 -23
- package/src/projections/live_hr.ts +0 -21
- package/src/projections/live_state.ts +0 -28
- package/src/projections/live_stress.ts +0 -13
- package/src/projections/performance_assessment.ts +0 -19
- package/src/projections/profile.ts +0 -71
- package/src/projections/recovery.ts +0 -133
- package/src/projections/sleep_need.ts +0 -36
- package/src/projections/smart_alarm.ts +0 -70
- package/src/projections/strain.ts +0 -131
- package/src/projections/stress.ts +0 -95
- package/src/projections/today.ts +0 -166
- package/src/projections/trend.ts +0 -149
- package/src/projections/workouts.ts +0 -36
- package/src/schemas/calendar.ts +0 -13
- package/src/schemas/communities.ts +0 -56
- package/src/schemas/compare.ts +0 -17
- package/src/schemas/leaderboard.ts +0 -26
- package/src/schemas/live.ts +0 -31
- package/src/schemas/performance.ts +0 -13
- package/src/schemas/profile.ts +0 -40
- package/src/schemas/recovery.ts +0 -28
- package/src/schemas/settings.ts +0 -30
- package/src/schemas/sleep_need.ts +0 -16
- package/src/schemas/smart_alarm.ts +0 -40
- package/src/schemas/strain.ts +0 -25
- package/src/schemas/stress.ts +0 -17
- package/src/schemas/today.ts +0 -39
- package/src/schemas/trend.ts +0 -53
- package/src/schemas/womens_health.ts +0 -26
- package/src/tools/v2/activity_create.ts +0 -74
- package/src/tools/v2/behavior_impact.ts +0 -39
- package/src/tools/v2/communities.ts +0 -65
- package/src/tools/v2/compare.ts +0 -83
- package/src/tools/v2/endpoints.ts +0 -32
- package/src/tools/v2/hidden_metric.ts +0 -33
- package/src/tools/v2/hr_zones.ts +0 -29
- package/src/tools/v2/journal_autopop.ts +0 -26
- package/src/tools/v2/journal_catalog.ts +0 -48
- package/src/tools/v2/leaderboard.ts +0 -92
- package/src/tools/v2/lift_catalog.ts +0 -48
- package/src/tools/v2/lift_custom_exercise.ts +0 -117
- package/src/tools/v2/lift_history.ts +0 -52
- package/src/tools/v2/lift_progression.ts +0 -34
- package/src/tools/v2/lift_prs.ts +0 -26
- package/src/tools/v2/lift_template_save.ts +0 -89
- package/src/tools/v2/live_hr.ts +0 -26
- package/src/tools/v2/live_state.ts +0 -26
- package/src/tools/v2/live_stress.ts +0 -27
- package/src/tools/v2/performance_assessment.ts +0 -44
- package/src/tools/v2/sleep_need.ts +0 -26
- package/src/tools/v2/sports_catalog.ts +0 -32
- package/src/tools/v2/symptom_log.ts +0 -78
- package/src/tools/v2/today.ts +0 -35
- package/src/tools/v2/workout.ts +0 -28
- package/src/whoop/build_lift_body.ts +0 -84
- package/src/whoop/session_state.ts +0 -41
- package/src/whoop/types.ts +0 -89
package/src/server.ts
CHANGED
|
@@ -6,41 +6,115 @@
|
|
|
6
6
|
import { config as loadEnv } from "dotenv";
|
|
7
7
|
import { fileURLToPath } from "node:url";
|
|
8
8
|
import { dirname, resolve } from "node:path";
|
|
9
|
+
import { existsSync } from "node:fs";
|
|
9
10
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
10
11
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
11
12
|
import { WhoopClient } from "./whoop/client.js";
|
|
12
|
-
import { TokenManager } from "./whoop/token_manager.js";
|
|
13
|
-
import {
|
|
13
|
+
import { TokenManager, keepAliveMsFromEnv } from "./whoop/token_manager.js";
|
|
14
|
+
import { TokenLock } from "./whoop/token_lock.js";
|
|
15
|
+
import {
|
|
16
|
+
FileTokenStore, MemoryTokenStore, LEGACY_TOKEN_KEYS, inContainer, migrateFromEnv, onMountedVolume,
|
|
17
|
+
resolveTokenFilePath, type TokenStore,
|
|
18
|
+
} from "./whoop/token_store.js";
|
|
19
|
+
import { deleteEnvKeys } from "./lib/env_file.js";
|
|
14
20
|
import { registerTools } from "./tools/register.js";
|
|
15
21
|
import { startTimezoneAutoDetect } from "./whoop/init_timezone.js";
|
|
16
22
|
import { resolveInstallationId } from "./whoop/installation.js";
|
|
17
|
-
import { versionStaleWarning } from "./whoop/device.js";
|
|
23
|
+
import { getInstallationId, versionStaleWarning } from "./whoop/device.js";
|
|
24
|
+
import { BUILD_ID } from "./build_info.js";
|
|
25
|
+
import { VERSION } from "./version.js";
|
|
26
|
+
import { serverIdentity } from "./lib/brand.js";
|
|
18
27
|
|
|
19
28
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
20
29
|
const ENV_PATH = resolve(__dirname, "../.env");
|
|
21
30
|
loadEnv({ path: ENV_PATH, quiet: true });
|
|
22
31
|
|
|
32
|
+
const log = (message: string): void => console.error(`[totem] ${message}`);
|
|
33
|
+
|
|
23
34
|
function requireEnv(key: string): string {
|
|
24
35
|
const v = process.env[key];
|
|
25
|
-
if (!v) throw new Error(`Missing ${key} in environment
|
|
36
|
+
if (!v) throw new Error(`Missing ${key} in environment.`);
|
|
26
37
|
return v;
|
|
27
38
|
}
|
|
28
39
|
|
|
29
|
-
|
|
30
|
-
|
|
40
|
+
/**
|
|
41
|
+
* The token store (G6). A file by default; `WHOOP_TOKEN_STORE=memory` only for
|
|
42
|
+
* local throwaway runs, because WHOOP rotates the refresh token on every refresh
|
|
43
|
+
* and a restart would strand a memory-only login.
|
|
44
|
+
*/
|
|
45
|
+
function chooseStore(transport: string): TokenStore {
|
|
46
|
+
const mode = (process.env.WHOOP_TOKEN_STORE ?? "file").toLowerCase();
|
|
31
47
|
if (mode === "memory") {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
48
|
+
if (inContainer() || transport === "http") {
|
|
49
|
+
// Not an error: v1's `totem cloud` set this as a host secret, so every
|
|
50
|
+
// deployment upgraded from v1 still carries it. Refusing to boot would take
|
|
51
|
+
// those servers down on upgrade. A memory-only login can't survive in a
|
|
52
|
+
// deployment (WHOOP rotates the refresh token on every refresh, so a restart
|
|
53
|
+
// would lose it), so the setting is ignored here and the token file is used.
|
|
54
|
+
log(
|
|
55
|
+
"WHOOP_TOKEN_STORE=memory is ignored in a container or remote deployment (a restart would lose the login). " +
|
|
56
|
+
"Using the token file instead. Remove the old WHOOP_TOKEN_STORE secret, and mount a volume for " +
|
|
57
|
+
"TOTEM_TOKEN_FILE (the image uses /data/tokens.json) so the login survives restarts.",
|
|
58
|
+
);
|
|
59
|
+
const store = new FileTokenStore(resolveTokenFilePath(process.env));
|
|
60
|
+
store.assertWritable();
|
|
61
|
+
return store;
|
|
62
|
+
}
|
|
63
|
+
log("WHOOP_TOKEN_STORE=memory: the login lives only in this process; a restart needs `totem auth` again.");
|
|
64
|
+
return new MemoryTokenStore(migrateFromEnv(process.env));
|
|
65
|
+
}
|
|
66
|
+
const store = new FileTokenStore(resolveTokenFilePath(process.env));
|
|
67
|
+
store.assertWritable();
|
|
68
|
+
return store;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** First run after v1: move WHOOP_IOS_BEARER_TOKEN / WHOOP_COGNITO_REFRESH_TOKEN into the token file. */
|
|
72
|
+
function migrateLegacyTokens(store: TokenStore): void {
|
|
73
|
+
if (!store.path) return;
|
|
74
|
+
let existing;
|
|
75
|
+
try {
|
|
76
|
+
existing = store.load();
|
|
77
|
+
} catch (error) {
|
|
78
|
+
log((error as Error).message);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const legacy = migrateFromEnv(process.env);
|
|
82
|
+
if (existing) {
|
|
83
|
+
if (legacy) log(`ignoring ${LEGACY_TOKEN_KEYS.join("/")} from the environment: ${store.path} holds the login.`);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (!legacy) return;
|
|
87
|
+
store.save(legacy);
|
|
88
|
+
log(`moved the WHOOP login from ${LEGACY_TOKEN_KEYS.join("/")} into ${store.path}.`);
|
|
89
|
+
if (existsSync(ENV_PATH)) {
|
|
90
|
+
try {
|
|
91
|
+
deleteEnvKeys(ENV_PATH, [...LEGACY_TOKEN_KEYS, "WHOOP_PASSWORD"]);
|
|
92
|
+
} catch {
|
|
93
|
+
// read-only .env: the token file wins anyway
|
|
94
|
+
}
|
|
36
95
|
}
|
|
37
|
-
return new EnvFileTokenStore(ENV_PATH);
|
|
38
96
|
}
|
|
39
97
|
|
|
40
98
|
async function main(): Promise<void> {
|
|
99
|
+
log(`build=${BUILD_ID}`);
|
|
100
|
+
const transport = (process.env.MCP_TRANSPORT ?? "stdio").toLowerCase();
|
|
101
|
+
|
|
102
|
+
const store = chooseStore(transport);
|
|
103
|
+
migrateLegacyTokens(store);
|
|
104
|
+
if (store.path && inContainer() && onMountedVolume(store.path) === false) {
|
|
105
|
+
log(`${store.path} is not on a mounted volume: a restart or redeploy will lose the WHOOP login (run \`totem auth\` again after one).`);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// The device identity lives with the login so it survives container restarts.
|
|
109
|
+
let saved = null;
|
|
110
|
+
try {
|
|
111
|
+
saved = store.load();
|
|
112
|
+
} catch {
|
|
113
|
+
// reported by the token manager below; the server still starts
|
|
114
|
+
}
|
|
115
|
+
if (!process.env.WHOOP_INSTALLATION_ID && saved?.installation_id) process.env.WHOOP_INSTALLATION_ID = saved.installation_id;
|
|
41
116
|
// Generate + persist a stable per-install identifier before any request goes
|
|
42
|
-
// out, so every data request carries the same `x-whoop-installation-identifier
|
|
43
|
-
// the iOS app sends. Persisted to the env file like the tokens.
|
|
117
|
+
// out, so every data request carries the same `x-whoop-installation-identifier`.
|
|
44
118
|
resolveInstallationId(ENV_PATH);
|
|
45
119
|
|
|
46
120
|
// Warn (once, at boot) if the bundled iOS app version has gone stale enough to
|
|
@@ -48,38 +122,68 @@ async function main(): Promise<void> {
|
|
|
48
122
|
const stale = versionStaleWarning();
|
|
49
123
|
if (stale) console.error(stale);
|
|
50
124
|
|
|
125
|
+
let client: WhoopClient | undefined;
|
|
51
126
|
const tokenManager = new TokenManager({
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
127
|
+
store,
|
|
128
|
+
lock: store.path ? new TokenLock({ path: `${store.path}.lock` }) : null,
|
|
129
|
+
keepAliveMs: keepAliveMsFromEnv(process.env.TOTEM_KEEPALIVE_HOURS),
|
|
130
|
+
onFatal: () => {
|
|
131
|
+
// Logged by the manager. Exit so the host restarts us and the problem is loud.
|
|
132
|
+
setTimeout(() => process.exit(1), 100).unref();
|
|
133
|
+
},
|
|
134
|
+
onLoginChange: (record) => {
|
|
135
|
+
if (record?.user_id) process.env.WHOOP_USER_ID = String(record.user_id);
|
|
136
|
+
if (client) {
|
|
137
|
+
client.invalidateAll(); // never serve one account's cached data to another
|
|
138
|
+
if (record) startTimezoneAutoDetect(client);
|
|
139
|
+
}
|
|
140
|
+
},
|
|
56
141
|
});
|
|
142
|
+
tokenManager.start();
|
|
143
|
+
process.once("exit", () => tokenManager.stop()); // releases the lock
|
|
57
144
|
|
|
58
|
-
const
|
|
145
|
+
const current = tokenManager.current();
|
|
146
|
+
if (current && !current.installation_id) tokenManager.annotate({ installation_id: getInstallationId() });
|
|
147
|
+
const status = tokenManager.status();
|
|
148
|
+
if (status.state === "no-login") log("no WHOOP login yet. Run `totem auth` (on a deployment it pushes the login to this server).");
|
|
149
|
+
else if (status.state === "handed-off") log(`this login was handed to ${status.handed_off_to}; run \`totem auth --local\` for a separate local login.`);
|
|
150
|
+
else log(`WHOOP login: ${status.source}, ${status.role}, token file ${status.store}`);
|
|
151
|
+
|
|
152
|
+
const whoop = new WhoopClient({
|
|
153
|
+
getToken: () => tokenManager.getToken(),
|
|
154
|
+
onUnauthorized: (token) => tokenManager.invalidate(token),
|
|
155
|
+
});
|
|
156
|
+
client = whoop;
|
|
59
157
|
|
|
60
158
|
// Tier 2 of the timezone resolution chain: auto-detect from Whoop's profile
|
|
61
159
|
// so responses come back in the user's local TZ without manual config.
|
|
62
160
|
// No-op if WHOOP_TIMEZONE is set (env var wins). Fires async — does not
|
|
63
161
|
// block server startup.
|
|
64
|
-
startTimezoneAutoDetect(
|
|
65
|
-
|
|
66
|
-
const transport = (process.env.MCP_TRANSPORT ?? "stdio").toLowerCase();
|
|
162
|
+
if (current) startTimezoneAutoDetect(whoop);
|
|
67
163
|
|
|
68
164
|
if (transport === "http") {
|
|
69
165
|
const { startHttpServer } = await import("./server-http.js");
|
|
70
|
-
await startHttpServer(
|
|
166
|
+
await startHttpServer(whoop, {
|
|
71
167
|
authToken: requireEnv("MCP_AUTH_TOKEN"),
|
|
168
|
+
tokens: tokenManager,
|
|
169
|
+
installationId: () => getInstallationId(),
|
|
72
170
|
});
|
|
73
171
|
return;
|
|
74
172
|
}
|
|
75
173
|
|
|
76
|
-
// stdio (default — local Claude Desktop / Claude Code)
|
|
77
|
-
|
|
78
|
-
|
|
174
|
+
// stdio (default — local Claude Desktop / Claude Code). The default SIGTERM
|
|
175
|
+
// handler skips 'exit' handlers, so route signals through process.exit to
|
|
176
|
+
// release the token lock.
|
|
177
|
+
for (const signal of ["SIGINT", "SIGTERM", "SIGHUP"] as const) process.once(signal, () => process.exit(0));
|
|
178
|
+
const server = new McpServer(serverIdentity(VERSION));
|
|
179
|
+
registerTools(server, whoop);
|
|
79
180
|
await server.connect(new StdioServerTransport());
|
|
80
181
|
}
|
|
81
182
|
|
|
82
183
|
main().catch((err) => {
|
|
83
|
-
|
|
184
|
+
// A startup failure is something the user has to act on: print the message,
|
|
185
|
+
// not a stack trace (set TOTEM_DEBUG=1 for the stack).
|
|
186
|
+
console.error(`[totem] fatal: ${err instanceof Error ? err.message : String(err)}`);
|
|
187
|
+
if (process.env.TOTEM_DEBUG && err instanceof Error && err.stack) console.error(err.stack);
|
|
84
188
|
process.exit(1);
|
|
85
189
|
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// MCP tool annotations (spec 2025-03-26+). Clients use these hints to sort and
|
|
2
|
+
// gate tools — claude.ai, for one, groups a connector's tools into read-only vs
|
|
3
|
+
// write/delete and lets the user set permissions per group. They are hints, not
|
|
4
|
+
// enforcement: the confirm:true preview gate on write tools still applies.
|
|
5
|
+
// Adopted from PR #37 (@a2br); the v2 classification lives on each tool.
|
|
6
|
+
import type { ToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
|
|
7
|
+
|
|
8
|
+
/** Only reads: GETs or local catalog lookups. */
|
|
9
|
+
export const READ_ONLY: ToolAnnotations = { readOnlyHint: true, openWorldHint: false };
|
|
10
|
+
|
|
11
|
+
/** Writes that only add new records (a new activity, lift, coach chat). */
|
|
12
|
+
export const WRITE_ADDITIVE: ToolAnnotations = { readOnlyHint: false, destructiveHint: false, openWorldHint: false };
|
|
13
|
+
|
|
14
|
+
/** Writes that can overwrite, clear or delete existing data or settings. */
|
|
15
|
+
export const WRITE_DESTRUCTIVE: ToolAnnotations = { readOnlyHint: false, destructiveHint: true, openWorldHint: false };
|
|
16
|
+
|
|
17
|
+
/** Mark a tool whose effects reach beyond WHOOP's typed data (raw passthrough, the coach). */
|
|
18
|
+
export function openWorld(base: ToolAnnotations): ToolAnnotations {
|
|
19
|
+
return { ...base, openWorldHint: true };
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Mark a write that is safe to repeat with the same input (same end state). */
|
|
23
|
+
export function idempotent(base: ToolAnnotations): ToolAnnotations {
|
|
24
|
+
return { ...base, idempotentHint: true };
|
|
25
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// One registration path for every v2 tool: description, zod input shape, MCP
|
|
2
|
+
// annotations, and a handler that returns a zod-validated projection as JSON text.
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
5
|
+
import type { ToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
|
|
6
|
+
import { WhoopProjectionError } from "../whoop/errors.js";
|
|
7
|
+
import { jsonOut } from "../whoop/json_out.js";
|
|
8
|
+
import { timezoneSettled } from "../whoop/init_timezone.js";
|
|
9
|
+
|
|
10
|
+
export type ToolResult = { content: Array<{ type: "text"; text: string }>; isError?: boolean };
|
|
11
|
+
|
|
12
|
+
export interface ToolSpec<Shape extends z.ZodRawShape> {
|
|
13
|
+
name: `whoop_${string}`;
|
|
14
|
+
description: string;
|
|
15
|
+
input: Shape;
|
|
16
|
+
annotations: ToolAnnotations;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function defineTool<Shape extends z.ZodRawShape>(
|
|
20
|
+
server: McpServer,
|
|
21
|
+
spec: ToolSpec<Shape>,
|
|
22
|
+
handler: (args: z.infer<z.ZodObject<Shape>>) => Promise<ToolResult>,
|
|
23
|
+
): void {
|
|
24
|
+
server.registerTool(
|
|
25
|
+
spec.name,
|
|
26
|
+
{ description: spec.description, inputSchema: spec.input, annotations: spec.annotations },
|
|
27
|
+
// On a UTC host the member's timezone is looked up from their profile at
|
|
28
|
+
// boot; a handler that ran before it landed read "today" off the UTC clock.
|
|
29
|
+
// This resolves at once except during the first seconds after a cold start.
|
|
30
|
+
// The SDK's callback typing is generic over the shape; the cast keeps each
|
|
31
|
+
// tool's handler typed by its own zod shape.
|
|
32
|
+
(async (args: z.infer<z.ZodObject<Shape>>) => {
|
|
33
|
+
await timezoneSettled();
|
|
34
|
+
return handler(args);
|
|
35
|
+
}) as never,
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Validate a projection against its output schema and wrap it as tool output. */
|
|
40
|
+
export function respond<S extends z.ZodTypeAny>(
|
|
41
|
+
tool: string,
|
|
42
|
+
schema: S,
|
|
43
|
+
value: unknown,
|
|
44
|
+
options: { compact?: boolean } = {},
|
|
45
|
+
): ToolResult {
|
|
46
|
+
try {
|
|
47
|
+
const out = schema.parse(value);
|
|
48
|
+
return { content: [{ type: "text", text: jsonOut(out, options) }] };
|
|
49
|
+
} catch (e) {
|
|
50
|
+
if (e instanceof z.ZodError) throw new WhoopProjectionError(tool, e);
|
|
51
|
+
throw e;
|
|
52
|
+
}
|
|
53
|
+
}
|
package/src/tools/register.ts
CHANGED
|
@@ -1,120 +1,90 @@
|
|
|
1
|
+
// The v2 tool surface: 41 tools (24 read, 17 write) and 5 catalog resources.
|
|
2
|
+
// Reads are consolidated (one tool per question a person asks); writes stay
|
|
3
|
+
// split by risk so each tool's MCP annotation means something.
|
|
1
4
|
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
5
|
import type { WhoopClient } from "../whoop/client.js";
|
|
3
6
|
|
|
4
|
-
//
|
|
5
|
-
import { registerToday } from "./v2/today.js";
|
|
7
|
+
// Daily picture
|
|
6
8
|
import { registerDay } from "./v2/day.js";
|
|
7
|
-
import { registerProfile } from "./v2/profile.js";
|
|
8
|
-
import { registerCalendar } from "./v2/calendar.js";
|
|
9
|
-
// Deep dives
|
|
10
9
|
import { registerRecovery } from "./v2/recovery.js";
|
|
11
10
|
import { registerSleep } from "./v2/sleep.js";
|
|
12
11
|
import { registerStrain } from "./v2/strain.js";
|
|
13
|
-
// Trends + compare
|
|
14
|
-
import { registerTrend } from "./v2/trend.js";
|
|
15
|
-
import { registerCompare } from "./v2/compare.js";
|
|
16
|
-
// Stress + sleep_need
|
|
17
12
|
import { registerStress } from "./v2/stress.js";
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
import {
|
|
21
|
-
import { registerLiveState } from "./v2/live_state.js";
|
|
22
|
-
import { registerLiveStress } from "./v2/live_stress.js";
|
|
13
|
+
import { registerNow } from "./v2/now.js";
|
|
14
|
+
import { registerTrend } from "./v2/trend.js";
|
|
15
|
+
import { registerCalendar } from "./v2/calendar.js";
|
|
23
16
|
// Activities
|
|
24
17
|
import { registerWorkouts } from "./v2/workouts.js";
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
18
|
+
import { registerActivityLog } from "./v2/activity_log.js";
|
|
19
|
+
import { registerActivityEdit } from "./v2/activity_edit.js";
|
|
27
20
|
import { registerActivityDelete } from "./v2/activity_delete.js";
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
import { registerLiftPrs } from "./v2/lift_prs.js";
|
|
21
|
+
// Strength
|
|
22
|
+
import { registerLiftSessions } from "./v2/lift_sessions.js";
|
|
31
23
|
import { registerLiftExercise } from "./v2/lift_exercise.js";
|
|
32
|
-
import { registerLiftProgression } from "./v2/lift_progression.js";
|
|
33
|
-
import { registerLiftHistory } from "./v2/lift_history.js";
|
|
34
24
|
import { registerLiftLibrary } from "./v2/lift_library.js";
|
|
35
|
-
import { registerLiftCatalog } from "./v2/lift_catalog.js";
|
|
36
|
-
// Strength writes
|
|
37
25
|
import { registerLiftLog } from "./v2/lift_log.js";
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
26
|
+
import { registerLiftTemplate } from "./v2/lift_template.js";
|
|
27
|
+
import { registerLiftExerciseSet } from "./v2/lift_exercise_set.js";
|
|
40
28
|
// Journal
|
|
41
29
|
import { registerJournal } from "./v2/journal.js";
|
|
42
|
-
import { registerJournalCatalog } from "./v2/journal_catalog.js";
|
|
43
|
-
import { registerBehaviorImpact } from "./v2/behavior_impact.js";
|
|
44
30
|
import { registerJournalLog } from "./v2/journal_log.js";
|
|
45
|
-
|
|
46
|
-
|
|
31
|
+
// Coach and memory
|
|
32
|
+
import { registerCoachAsk } from "./v2/coach_ask.js";
|
|
33
|
+
import { registerCoachHistory } from "./v2/coach_history.js";
|
|
34
|
+
import { registerMemory } from "./v2/memory.js";
|
|
35
|
+
import { registerMemorySet } from "./v2/memory_set.js";
|
|
36
|
+
// Body, cycle, plans
|
|
37
|
+
import { registerWeight } from "./v2/weight.js";
|
|
38
|
+
import { registerWeightLog } from "./v2/weight_log.js";
|
|
47
39
|
import { registerCycle } from "./v2/cycle.js";
|
|
48
40
|
import { registerCycleLog } from "./v2/cycle_log.js";
|
|
49
|
-
import {
|
|
50
|
-
|
|
51
|
-
import {
|
|
52
|
-
|
|
53
|
-
// Smart alarm
|
|
41
|
+
import { registerWeeklyPlan } from "./v2/weekly_plan.js";
|
|
42
|
+
import { registerWeeklyPlanSet } from "./v2/weekly_plan_set.js";
|
|
43
|
+
import { registerMilestones } from "./v2/milestones.js";
|
|
44
|
+
// Settings
|
|
54
45
|
import { registerSmartAlarm } from "./v2/smart_alarm.js";
|
|
55
46
|
import { registerSmartAlarmSet } from "./v2/smart_alarm_set.js";
|
|
56
|
-
|
|
57
|
-
import {
|
|
58
|
-
import { registerCommunities } from "./v2/communities.js";
|
|
59
|
-
// Settings
|
|
60
|
-
import { registerHrZones } from "./v2/hr_zones.js";
|
|
61
|
-
import { registerHrZonesSet } from "./v2/hr_zones_set.js";
|
|
47
|
+
import { registerProfile } from "./v2/profile.js";
|
|
48
|
+
import { registerHealth } from "./v2/health.js";
|
|
62
49
|
import { registerProfileUpdate } from "./v2/profile_update.js";
|
|
63
|
-
import {
|
|
64
|
-
|
|
50
|
+
import { registerHrZonesSet } from "./v2/hr_zones_set.js";
|
|
51
|
+
import { registerPreferences } from "./v2/preferences.js";
|
|
52
|
+
import { registerPreferencesSet } from "./v2/preferences_set.js";
|
|
53
|
+
// Community
|
|
54
|
+
import { registerCommunity } from "./v2/community.js";
|
|
55
|
+
// Escape hatch
|
|
65
56
|
import { registerRaw } from "./v2/raw.js";
|
|
66
|
-
import {
|
|
57
|
+
import { registerResources } from "./resources.js";
|
|
58
|
+
import { installSlimToolList } from "./slim_schema.js";
|
|
59
|
+
|
|
60
|
+
type Register = (server: McpServer, client: WhoopClient) => void;
|
|
61
|
+
|
|
62
|
+
/** Read-only tools (24). */
|
|
63
|
+
export const READ_TOOLS: readonly Register[] = [
|
|
64
|
+
registerDay, registerRecovery, registerSleep, registerStrain, registerStress, registerNow, registerTrend, registerCalendar,
|
|
65
|
+
registerWorkouts,
|
|
66
|
+
registerLiftSessions, registerLiftExercise, registerLiftLibrary,
|
|
67
|
+
registerJournal,
|
|
68
|
+
registerCoachHistory, registerMemory,
|
|
69
|
+
registerWeight, registerCycle, registerWeeklyPlan, registerMilestones,
|
|
70
|
+
registerSmartAlarm, registerProfile, registerPreferences, registerHealth,
|
|
71
|
+
registerCommunity,
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
/** Write tools (17), whoop_raw included. Each previews unless confirm:true. */
|
|
75
|
+
export const WRITE_TOOLS: readonly Register[] = [
|
|
76
|
+
registerActivityLog, registerActivityEdit, registerActivityDelete,
|
|
77
|
+
registerLiftLog, registerLiftTemplate, registerLiftExerciseSet,
|
|
78
|
+
registerJournalLog,
|
|
79
|
+
registerCoachAsk, registerMemorySet,
|
|
80
|
+
registerWeightLog, registerCycleLog, registerWeeklyPlanSet,
|
|
81
|
+
registerSmartAlarmSet, registerProfileUpdate, registerHrZonesSet, registerPreferencesSet,
|
|
82
|
+
registerRaw,
|
|
83
|
+
];
|
|
67
84
|
|
|
68
85
|
export function registerTools(server: McpServer, client: WhoopClient): void {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
registerCalendar(server, client);
|
|
74
|
-
registerRecovery(server, client);
|
|
75
|
-
registerSleep(server, client);
|
|
76
|
-
registerStrain(server, client);
|
|
77
|
-
registerTrend(server, client);
|
|
78
|
-
registerCompare(server, client);
|
|
79
|
-
registerStress(server, client);
|
|
80
|
-
registerSleepNeed(server, client);
|
|
81
|
-
registerLiveHr(server, client);
|
|
82
|
-
registerLiveState(server, client);
|
|
83
|
-
registerLiveStress(server, client);
|
|
84
|
-
registerWorkouts(server, client);
|
|
85
|
-
registerWorkout(server, client);
|
|
86
|
-
registerSportsCatalog(server, client);
|
|
87
|
-
registerLiftPrs(server, client);
|
|
88
|
-
registerLiftExercise(server, client);
|
|
89
|
-
registerLiftProgression(server, client);
|
|
90
|
-
registerLiftHistory(server, client);
|
|
91
|
-
registerLiftLibrary(server, client);
|
|
92
|
-
registerLiftCatalog(server, client);
|
|
93
|
-
registerJournal(server, client);
|
|
94
|
-
registerJournalCatalog(server, client);
|
|
95
|
-
registerBehaviorImpact(server, client);
|
|
96
|
-
registerCycle(server, client);
|
|
97
|
-
registerPerformanceAssessment(server, client);
|
|
98
|
-
registerSmartAlarm(server, client);
|
|
99
|
-
registerLeaderboard(server, client);
|
|
100
|
-
registerCommunities(server, client);
|
|
101
|
-
registerHrZones(server, client);
|
|
102
|
-
// Writes (14: 13 + coach_ask)
|
|
103
|
-
registerActivityCreate(server, client);
|
|
104
|
-
registerActivityDelete(server, client);
|
|
105
|
-
registerLiftLog(server, client);
|
|
106
|
-
registerLiftTemplateSave(server, client);
|
|
107
|
-
registerLiftCustomExercise(server, client);
|
|
108
|
-
registerJournalLog(server, client);
|
|
109
|
-
registerJournalAutopop(server, client);
|
|
110
|
-
registerCycleLog(server, client);
|
|
111
|
-
registerSymptomLog(server, client);
|
|
112
|
-
registerSmartAlarmSet(server, client);
|
|
113
|
-
registerHrZonesSet(server, client);
|
|
114
|
-
registerProfileUpdate(server, client);
|
|
115
|
-
registerHiddenMetric(server, client);
|
|
116
|
-
registerCoachAsk(server, client);
|
|
117
|
-
// Escape (2)
|
|
118
|
-
registerRaw(server, client);
|
|
119
|
-
registerEndpoints(server, client);
|
|
86
|
+
for (const register of READ_TOOLS) register(server, client);
|
|
87
|
+
for (const register of WRITE_TOOLS) register(server, client);
|
|
88
|
+
registerResources(server);
|
|
89
|
+
installSlimToolList(server);
|
|
120
90
|
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// The bundled catalogs as MCP resources (they were four tools in v1). A resource
|
|
2
|
+
// costs nothing per turn: a client reads it only when asked. Rows are columnar
|
|
3
|
+
// ({columns, rows}) so a full read stays small.
|
|
4
|
+
//
|
|
5
|
+
// Some MCP clients never show resources to the model, so no tool depends on
|
|
6
|
+
// them: every tool that takes a name (activity type, exercise, behaviour)
|
|
7
|
+
// resolves it itself and returns the closest matches on a miss.
|
|
8
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
9
|
+
import { ACTIVITY_TYPES } from "../data/sports.js";
|
|
10
|
+
import { EXERCISES, EXERCISE_FILTER_OPTIONS } from "../data/exercises.js";
|
|
11
|
+
import { BEHAVIORS } from "../data/behaviors.js";
|
|
12
|
+
import { GARMENTS } from "../data/garments.js";
|
|
13
|
+
import { ENDPOINT_CATALOG } from "../data/endpoint_catalog.js";
|
|
14
|
+
|
|
15
|
+
interface CatalogResource {
|
|
16
|
+
name: string;
|
|
17
|
+
uri: string;
|
|
18
|
+
title: string;
|
|
19
|
+
description: string;
|
|
20
|
+
build: () => unknown;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const CATALOG_RESOURCES: readonly CatalogResource[] = [
|
|
24
|
+
{
|
|
25
|
+
name: "sports",
|
|
26
|
+
uri: "whoop://catalog/sports",
|
|
27
|
+
title: "WHOOP activity types",
|
|
28
|
+
description: "Every activity type WHOOP accepts: internal_name (what whoop_activity_log takes), display name, sport_id, and whether it scores as CARDIO, RECOVERY or SLEEP.",
|
|
29
|
+
build: () => ({
|
|
30
|
+
columns: ["internal_name", "name", "sport_id", "score_type"],
|
|
31
|
+
rows: ACTIVITY_TYPES.map((t) => [t.internal_name, t.name, t.sport_id, t.score_type]),
|
|
32
|
+
}),
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: "exercises",
|
|
36
|
+
uri: "whoop://catalog/exercises",
|
|
37
|
+
title: "WHOOP Strength Trainer exercises",
|
|
38
|
+
description: "The official exercise catalog: exercise_id (what the lift tools take), name, equipment, primary muscle, how volume is entered, and whether WHOOP estimates a 1RM for it. Custom exercises are per-account: see whoop_lift_library.",
|
|
39
|
+
build: () => ({
|
|
40
|
+
columns: ["exercise_id", "name", "equipment", "primary_muscle", "volume_input_format", "e1rm_eligible"],
|
|
41
|
+
rows: EXERCISES.map((e) => [e.exercise_id, e.name, e.raw_equipment ?? e.equipment, e.primary_muscle, e.volume_input_format ?? null, e.e1rm_eligible ?? null]),
|
|
42
|
+
filter_options: EXERCISE_FILTER_OPTIONS,
|
|
43
|
+
}),
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: "behaviors",
|
|
47
|
+
uri: "whoop://catalog/behaviors",
|
|
48
|
+
title: "WHOOP Journal behaviours",
|
|
49
|
+
description: "The stock Journal behaviours: id (what whoop_journal_log takes), title, category, and the magnitude each accepts (units and range, or the allowed choices). Custom behaviours are per-account: see whoop_journal.",
|
|
50
|
+
build: () => ({
|
|
51
|
+
columns: ["id", "title", "category", "units", "min", "max", "choices"],
|
|
52
|
+
rows: BEHAVIORS.map((b) => {
|
|
53
|
+
const m = b.magnitude_spec;
|
|
54
|
+
return [
|
|
55
|
+
b.behavior_tracker_id, b.title, b.category, m?.units ?? null, m?.minimum ?? null, m?.maximum ?? null,
|
|
56
|
+
m && m.choices.length ? m.choices.map((c) => `${c.value}=${c.label}`) : null,
|
|
57
|
+
];
|
|
58
|
+
}),
|
|
59
|
+
}),
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: "garments",
|
|
63
|
+
uri: "whoop://catalog/garments",
|
|
64
|
+
title: "WHOOP strap locations",
|
|
65
|
+
description: "Where the strap can be worn (garment_id for activity tools), and which strap generations support each.",
|
|
66
|
+
build: () => ({
|
|
67
|
+
columns: ["id", "name", "strap_location", "straps"],
|
|
68
|
+
rows: GARMENTS.map((g) => [g.id, g.name, g.strap_location, g.straps]),
|
|
69
|
+
}),
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: "endpoints",
|
|
73
|
+
uri: "whoop://catalog/endpoints",
|
|
74
|
+
title: "WHOOP private API endpoints",
|
|
75
|
+
description: "Every endpoint totem has verified against the live WHOOP app API, with its verdict and the tool that wraps it. Use with whoop_raw when no tool fits.",
|
|
76
|
+
build: () => ({
|
|
77
|
+
columns: ["method", "path", "verdict", "tools"],
|
|
78
|
+
rows: ENDPOINT_CATALOG.map((e) => [e.method, e.path, e.verdict, e.tools.length ? e.tools : null]),
|
|
79
|
+
}),
|
|
80
|
+
},
|
|
81
|
+
];
|
|
82
|
+
|
|
83
|
+
export function registerResources(server: McpServer): void {
|
|
84
|
+
for (const r of CATALOG_RESOURCES) {
|
|
85
|
+
server.registerResource(
|
|
86
|
+
r.name,
|
|
87
|
+
r.uri,
|
|
88
|
+
{ title: r.title, description: r.description, mimeType: "application/json" },
|
|
89
|
+
async (uri) => ({ contents: [{ uri: uri.href, mimeType: "application/json", text: JSON.stringify(r.build()) }] }),
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
}
|