@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
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
// whoop_activity_log: replaces v1 whoop_activity_create and PR #29's
|
|
2
|
+
// whoop_nap_create (@k-vasily), folded into one v2 create.
|
|
3
|
+
//
|
|
4
|
+
// POST cd/v2/create-activity {activity_internal_name, start_time, end_time,
|
|
5
|
+
// gps_enabled[, garment_id]} takes every v2 type: CARDIO, RECOVERY, nap and sleep
|
|
6
|
+
// (SPEC.md §4.3, §4.4). Timestamps need milliseconds (offsets are fine).
|
|
7
|
+
// Read-back: cardio-details for CARDIO/RECOVERY; sleep-details for naps and
|
|
8
|
+
// sleeps, because cardio-details 400s while a sleep is pending.
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
11
|
+
import type { WhoopClient } from "../../whoop/client.js";
|
|
12
|
+
import { defineTool, respond } from "../define.js";
|
|
13
|
+
import { WRITE_ADDITIVE } from "../annotations.js";
|
|
14
|
+
import { preview } from "../../whoop/write_safety.js";
|
|
15
|
+
import { get } from "../../whoop/bff.js";
|
|
16
|
+
import { ActivityLogOut } from "../../schemas/activities.js";
|
|
17
|
+
import { assertNotFuture, canonicalUtc } from "../../lib/dates.js";
|
|
18
|
+
import { describeType, resolveActivityTypeLive, resolveGarment } from "../../lib/activity_types.js";
|
|
19
|
+
import {
|
|
20
|
+
CARDIO_DETAILS_V1, CREATE_PATH, readActivityAs, recordFromActivity, sameInstant, type ActivityRecord,
|
|
21
|
+
} from "../../lib/activity_records.js";
|
|
22
|
+
import { MAIN_SLEEP_WARNING, errorResult, writeRejection } from "../../lib/activity_results.js";
|
|
23
|
+
import { instantInput, toInstant } from "../../lib/instant.js";
|
|
24
|
+
|
|
25
|
+
const MIN_DURATION_MS = 60_000;
|
|
26
|
+
const SLEEP_READBACK_DELAYS_MS = [0, 2_000, 5_000];
|
|
27
|
+
|
|
28
|
+
export interface ActivityToolOptions {
|
|
29
|
+
/** Delay between read-back attempts (tests pass a no-op). */
|
|
30
|
+
sleep?: (ms: number) => Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
const realSleep = (ms: number): Promise<void> => new Promise((r) => setTimeout(r, ms));
|
|
33
|
+
|
|
34
|
+
export function registerActivityLog(server: McpServer, client: WhoopClient, opts: ActivityToolOptions = {}): void {
|
|
35
|
+
const sleep = opts.sleep ?? realSleep;
|
|
36
|
+
defineTool(server, {
|
|
37
|
+
name: "whoop_activity_log",
|
|
38
|
+
description:
|
|
39
|
+
"Log a past activity, nap or main sleep over start–end (≥1 min, not in the future); WHOOP scores it from strap data. type is an " +
|
|
40
|
+
"internal_name (\"sauna\", \"nap\", \"sleep\"), display name or sport_id; a miss returns the closest. Overlaps are refused. A main " +
|
|
41
|
+
"sleep permanently re-cuts the day's cycles. Previews unless confirm:true.",
|
|
42
|
+
input: {
|
|
43
|
+
type: z.string().optional(),
|
|
44
|
+
sport_id: z.number().int().optional().describe("Instead of type"),
|
|
45
|
+
start: instantInput(),
|
|
46
|
+
end: instantInput(),
|
|
47
|
+
gps_enabled: z.boolean().default(false),
|
|
48
|
+
garment_id: z.number().int().optional().describe("Strap location id; a miss lists them"),
|
|
49
|
+
confirm: z.boolean().default(false),
|
|
50
|
+
},
|
|
51
|
+
annotations: WRITE_ADDITIVE,
|
|
52
|
+
}, async ({ type, sport_id, start: startIn, end: endIn, gps_enabled, garment_id, confirm }) => {
|
|
53
|
+
const start = toInstant(startIn, undefined, "start");
|
|
54
|
+
const end = toInstant(endIn, undefined, "end");
|
|
55
|
+
if ((type === undefined) === (sport_id === undefined)) {
|
|
56
|
+
return errorResult({ error: "Pass exactly one of type or sport_id." });
|
|
57
|
+
}
|
|
58
|
+
const resolved = await resolveActivityTypeLive(client, type ?? sport_id!);
|
|
59
|
+
if (!resolved.ok) return errorResult({ error: resolved.error, suggestions: resolved.suggestions });
|
|
60
|
+
const t = resolved.type;
|
|
61
|
+
|
|
62
|
+
const startMs = Date.parse(start);
|
|
63
|
+
const endMs = Date.parse(end);
|
|
64
|
+
if (endMs - startMs < MIN_DURATION_MS) {
|
|
65
|
+
return errorResult({ error: "end must be at least one minute after start." });
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
assertNotFuture(end, "end");
|
|
69
|
+
} catch (e) {
|
|
70
|
+
return errorResult({ error: (e as Error).message });
|
|
71
|
+
}
|
|
72
|
+
if (garment_id !== undefined) {
|
|
73
|
+
const g = resolveGarment(garment_id);
|
|
74
|
+
if (!g.ok) return errorResult({ error: g.error });
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const body: Record<string, unknown> = {
|
|
78
|
+
activity_internal_name: t.internal_name,
|
|
79
|
+
start_time: canonicalUtc(startMs),
|
|
80
|
+
end_time: canonicalUtc(endMs),
|
|
81
|
+
gps_enabled,
|
|
82
|
+
};
|
|
83
|
+
if (garment_id !== undefined) body.garment_id = garment_id;
|
|
84
|
+
const warnings: string[] = [];
|
|
85
|
+
if (t.internal_name === "sleep") warnings.push(MAIN_SLEEP_WARNING);
|
|
86
|
+
if (gps_enabled && !t.has_gps) warnings.push(`${t.name} isn't a GPS type in WHOOP's catalog; gps_enabled has no known effect.`);
|
|
87
|
+
|
|
88
|
+
if (!confirm) {
|
|
89
|
+
return respond("whoop_activity_log", ActivityLogOut, preview("POST", CREATE_PATH, {
|
|
90
|
+
body,
|
|
91
|
+
type: describeType(t),
|
|
92
|
+
score_type: t.score_type,
|
|
93
|
+
sport_id: t.sport_id,
|
|
94
|
+
duration_ms: endMs - startMs,
|
|
95
|
+
warnings,
|
|
96
|
+
}));
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
let response: unknown;
|
|
100
|
+
try {
|
|
101
|
+
response = await client.post(CREATE_PATH, body);
|
|
102
|
+
} catch (e) {
|
|
103
|
+
const rejected = writeRejection(e, CREATE_PATH);
|
|
104
|
+
if (rejected) return rejected;
|
|
105
|
+
throw e;
|
|
106
|
+
}
|
|
107
|
+
const rec = recordFromActivity(response);
|
|
108
|
+
if (!rec) return errorResult({ error: "WHOOP answered without an activity id; check whoop_workouts before retrying.", endpoint: CREATE_PATH });
|
|
109
|
+
|
|
110
|
+
// Read back through the kind-specific screen (fresh). A just-created sleep
|
|
111
|
+
// can take a few seconds to become readable.
|
|
112
|
+
const scoreType = rec.score_type ?? t.score_type;
|
|
113
|
+
const delays = scoreType === "SLEEP" ? SLEEP_READBACK_DELAYS_MS : [0, 2_000];
|
|
114
|
+
let back: ActivityRecord | null = null;
|
|
115
|
+
let readError: string | null = null;
|
|
116
|
+
for (const delay of delays) {
|
|
117
|
+
if (delay) await sleep(delay);
|
|
118
|
+
try {
|
|
119
|
+
back = await readActivityAs(client, rec.id, scoreType);
|
|
120
|
+
readError = null;
|
|
121
|
+
if (back) break;
|
|
122
|
+
} catch (e) {
|
|
123
|
+
readError = (e as Error).message;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
const typeMatches = back?.type === t.internal_name;
|
|
127
|
+
const windowMatches = sameInstant(back?.start, body.start_time as string) && sameInstant(back?.end, body.end_time as string);
|
|
128
|
+
if (!back) warnings.push(`Couldn't read the activity back (${readError ?? `${scoreType === "SLEEP" ? "sleep-details" : CARDIO_DETAILS_V1} said 404`}); check whoop_workouts or whoop_sleep.`);
|
|
129
|
+
else if (!typeMatches) {
|
|
130
|
+
warnings.push(t.internal_name === "sleep" && back.type === "nap"
|
|
131
|
+
? "WHOOP saved it as a nap, not a main sleep (the cycle probably already has a main sleep)."
|
|
132
|
+
: `WHOOP shows it as ${back.type ?? "an unknown type"}, not ${t.internal_name}.`);
|
|
133
|
+
} else if (!windowMatches) warnings.push(`WHOOP shows the window as ${back.start} – ${back.end}.`);
|
|
134
|
+
if (scoreType !== "SLEEP" && rec.score_state === "pending") {
|
|
135
|
+
warnings.push("Pending: WHOOP scores it from strap data in the window; with none it stays INCOMPLETE (strain \"---\").");
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const cycleId = get(response, "activity", "cycle_id");
|
|
139
|
+
const linkable = get(response, "strength_trainer_linkable");
|
|
140
|
+
return respond("whoop_activity_log", ActivityLogOut, {
|
|
141
|
+
created: true,
|
|
142
|
+
activity_id: rec.id,
|
|
143
|
+
type: rec.type,
|
|
144
|
+
score_type: rec.score_type,
|
|
145
|
+
start: rec.start,
|
|
146
|
+
end: rec.end,
|
|
147
|
+
version: rec.version,
|
|
148
|
+
strength_trainer_linkable: typeof linkable === "boolean" ? linkable : null,
|
|
149
|
+
cycle_id_informational: typeof cycleId === "number" ? cycleId : null,
|
|
150
|
+
verified: Boolean(back && typeMatches && windowMatches),
|
|
151
|
+
warnings,
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
}
|
package/src/tools/v2/calendar.ts
CHANGED
|
@@ -1,33 +1,34 @@
|
|
|
1
|
+
// whoop_calendar (v2): GET /home-service/v1/calendar/{pillar}?date=, or the journal calendar.
|
|
1
2
|
import { z } from "zod";
|
|
2
3
|
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
4
|
import type { WhoopClient } from "../../whoop/client.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { WhoopProjectionError } from "../../whoop/errors.js";
|
|
7
|
-
import { jsonOut } from "../../whoop/json_out.js";
|
|
5
|
+
import { defineTool, respond } from "../define.js";
|
|
6
|
+
import { READ_ONLY } from "../annotations.js";
|
|
8
7
|
import { todayIso } from "../../lib/dates.js";
|
|
8
|
+
import { CalendarV2Out } from "../../schemas/v2/calendar.js";
|
|
9
|
+
import { CALENDAR_PILLARS, projectCalendarV2 } from "../../projections/v2/calendar.js";
|
|
10
|
+
|
|
11
|
+
const NAME = "whoop_calendar";
|
|
9
12
|
|
|
10
13
|
export function registerCalendar(server: McpServer, client: WhoopClient): void {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"Month-at-a-glance calendar grid for the month containing the given date: each day's recovery STATE — GREEN (high), YELLOW (medium), or RED (low). The grid only exposes the state, not numeric recovery/sleep/strain scores; for a specific day's numbers use whoop_day.",
|
|
14
|
+
defineTool(
|
|
15
|
+
server,
|
|
14
16
|
{
|
|
15
|
-
|
|
17
|
+
name: NAME,
|
|
18
|
+
description:
|
|
19
|
+
"Month grid for one pillar: days has one character per day (days[0] = the 1st): H/M/L = high/medium/low, J = journal " +
|
|
20
|
+
"entry, '-' = data but no score, '.' = no data. No numbers; whoop_day has a day's scores.",
|
|
21
|
+
input: {
|
|
22
|
+
date: z.iso.date().optional().describe("Any day in the month"),
|
|
23
|
+
pillar: z.enum(CALENDAR_PILLARS).default("recovery"),
|
|
24
|
+
},
|
|
25
|
+
annotations: READ_ONLY,
|
|
16
26
|
},
|
|
17
|
-
async ({ date }) => {
|
|
27
|
+
async ({ date, pillar }) => {
|
|
18
28
|
const d = date ?? todayIso();
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
]);
|
|
23
|
-
const projected = projectCalendar({ overview, recovery, date: d });
|
|
24
|
-
try {
|
|
25
|
-
const out = CalendarOut.parse(projected);
|
|
26
|
-
return { content: [{ type: "text", text: jsonOut(out) }] };
|
|
27
|
-
} catch (e) {
|
|
28
|
-
if (e instanceof z.ZodError) throw new WhoopProjectionError("whoop_calendar", e);
|
|
29
|
-
throw e;
|
|
30
|
-
}
|
|
29
|
+
const path = pillar === "journal" ? `/journal-service/v2/journals/${d}/calendar` : `/home-service/v1/calendar/${pillar}`;
|
|
30
|
+
const raw = await client.get(path, pillar === "journal" ? {} : { date: d });
|
|
31
|
+
return respond(NAME, CalendarV2Out, projectCalendarV2(raw, pillar, d));
|
|
31
32
|
},
|
|
32
33
|
);
|
|
33
34
|
}
|
|
@@ -1,131 +1,95 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
3
|
import type { WhoopClient } from "../../whoop/client.js";
|
|
4
|
-
import {
|
|
4
|
+
import { defineTool, respond } from "../define.js";
|
|
5
|
+
import { WRITE_DESTRUCTIVE, openWorld } from "../annotations.js";
|
|
5
6
|
import { preview } from "../../whoop/write_safety.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
7
|
+
import { todayIso } from "../../lib/dates.js";
|
|
8
|
+
import { COACH_AGENTS, CoachAskOut, type CoachAgent } from "../../schemas/coach.js";
|
|
9
|
+
import { AGENT_SOURCES, REPORT_PREFIX } from "../../projections/coach.js";
|
|
10
|
+
import {
|
|
11
|
+
AI,
|
|
12
|
+
DEFAULT_TIMING,
|
|
13
|
+
askCoach,
|
|
14
|
+
dailyFingerprint,
|
|
15
|
+
parseImage,
|
|
16
|
+
type AskPlan,
|
|
17
|
+
type CoachTiming,
|
|
18
|
+
} from "../../lib/coach_session.js";
|
|
8
19
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
{
|
|
25
|
-
type: "text",
|
|
26
|
-
text: jsonOut(
|
|
27
|
-
preview("POST", "/ai-conversation-bff/v1/conversation + /turn", {
|
|
28
|
-
message: message.slice(0, 100),
|
|
29
|
-
context,
|
|
30
|
-
}),
|
|
31
|
-
),
|
|
32
|
-
},
|
|
33
|
-
],
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
// Conversation creation response: { metadata: { id, ... }, turns: [...], tag }
|
|
37
|
-
const conv = await client.post<{
|
|
38
|
-
metadata?: { id?: string };
|
|
39
|
-
conversation_id?: string;
|
|
40
|
-
id?: string;
|
|
41
|
-
}>("/ai-conversation-bff/v1/conversation", {
|
|
42
|
-
context,
|
|
43
|
-
fingerprint: `CHAT_WITH_AGENT${context}_${new Date().toISOString().slice(0, 10)}`,
|
|
44
|
-
source_type: "CHAT_WITH_AGENT",
|
|
45
|
-
chat_entrypoint_experience: "STANDARD",
|
|
46
|
-
tracking_capabilities: {
|
|
47
|
-
is_dismiss_tracking_enabled: false,
|
|
48
|
-
is_seen_tracking_enabled: true,
|
|
49
|
-
},
|
|
50
|
-
});
|
|
51
|
-
const conversationId = conv.metadata?.id ?? conv.conversation_id ?? conv.id ?? "";
|
|
20
|
+
const TOOL = "whoop_coach_ask";
|
|
21
|
+
const REPORTS = new Set<CoachAgent>(["daily_outlook", "day_in_review"]);
|
|
22
|
+
|
|
23
|
+
export const coachAskInput = {
|
|
24
|
+
message: z.string().trim().min(1).max(4000).optional(),
|
|
25
|
+
agent: z.enum(COACH_AGENTS).default("coach").describe("activity needs activity_id"),
|
|
26
|
+
activity_id: z.uuid().optional(),
|
|
27
|
+
thread: z.string().min(1).max(200).optional()
|
|
28
|
+
.describe("From whoop_coach_history"),
|
|
29
|
+
new_thread: z.boolean().default(false),
|
|
30
|
+
image_base64: z.string().max(7_200_000).optional().describe("PNG or JPEG, ≤5 MB"),
|
|
31
|
+
confirm: z.boolean().default(false),
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
type Input = z.infer<z.ZodObject<typeof coachAskInput>>;
|
|
52
35
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
is_dismiss_tracking_enabled: false,
|
|
62
|
-
is_seen_tracking_enabled: true,
|
|
63
|
-
},
|
|
64
|
-
},
|
|
36
|
+
/** Validate the input and build the plan (pure; throws a readable error). */
|
|
37
|
+
export function planAsk(input: Input, localDate: string = todayIso()): AskPlan {
|
|
38
|
+
const report = REPORTS.has(input.agent);
|
|
39
|
+
if (input.thread && input.new_thread) throw new Error("Use either thread (continue) or new_thread (start fresh), not both.");
|
|
40
|
+
if (report) {
|
|
41
|
+
if (input.thread || input.new_thread || input.image_base64 || input.message) {
|
|
42
|
+
throw new Error(
|
|
43
|
+
`agent ${input.agent} only generates or opens the current cycle's report. To reply to it, pass its fingerprint as thread with your message.`,
|
|
65
44
|
);
|
|
66
|
-
|
|
45
|
+
}
|
|
46
|
+
} else if (!input.message) {
|
|
47
|
+
throw new Error("message is required.");
|
|
48
|
+
}
|
|
49
|
+
if (input.agent === "activity" && !input.activity_id && !input.thread) throw new Error("agent activity needs activity_id.");
|
|
50
|
+
if (input.activity_id && input.agent !== "activity") throw new Error("activity_id only applies to agent activity.");
|
|
51
|
+
const plan: AskPlan = { agent: input.agent, newThread: input.new_thread, localDate };
|
|
52
|
+
if (input.message) plan.message = input.message;
|
|
53
|
+
if (input.activity_id) plan.activityId = input.activity_id;
|
|
54
|
+
if (input.thread) plan.thread = input.thread;
|
|
55
|
+
if (input.image_base64) plan.image = parseImage(input.image_base64);
|
|
56
|
+
return plan;
|
|
57
|
+
}
|
|
67
58
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const t = (itemContent as Record<string, unknown>).text;
|
|
85
|
-
if (typeof t === "string") return t;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return null;
|
|
91
|
-
}
|
|
59
|
+
function previewFor(plan: AskPlan) {
|
|
60
|
+
if (plan.agent === "daily_outlook" || plan.agent === "day_in_review") {
|
|
61
|
+
return preview("POST", `${AI}/conversation`, {
|
|
62
|
+
fingerprint: `${REPORT_PREFIX[plan.agent]}<current cycle, read from home at send>`,
|
|
63
|
+
effect: "Opens the current cycle's report, generating it first if it doesn't exist yet.",
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
const thread = plan.thread ?? (plan.newThread ? `${dailyFingerprint(plan.agent, plan.localDate)}-<new>` : dailyFingerprint(plan.agent, plan.localDate, plan.activityId));
|
|
67
|
+
return preview("POST", `${AI}/conversation/${thread}/turn`, {
|
|
68
|
+
thread,
|
|
69
|
+
mode: plan.thread ? "continue listed thread" : plan.newThread ? "new thread" : "today's thread (created if needed)",
|
|
70
|
+
source_id: plan.thread ? null : AGENT_SOURCES[plan.agent]!.source_id,
|
|
71
|
+
image_bytes: plan.image ? plan.image.bytes : null,
|
|
72
|
+
warning: "The coach can create, edit or delete activities, save memories and draft templates if the message asks. Activity writes come back in actions; a saved memory shows only in the reply text.",
|
|
73
|
+
});
|
|
74
|
+
}
|
|
92
75
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
);
|
|
111
|
-
status = typeof r.turn_status === "string" ? r.turn_status.toUpperCase() : status;
|
|
112
|
-
const latest = extractText(Array.isArray(r.messages) ? r.messages : []);
|
|
113
|
-
if (latest !== null) {
|
|
114
|
-
stableFor = latest === responseText ? stableFor + 1 : 0;
|
|
115
|
-
responseText = latest;
|
|
116
|
-
}
|
|
117
|
-
if (TERMINAL.includes(status)) break; // server marked the turn done
|
|
118
|
-
if (responseText !== null && stableFor >= 2) break; // stream settled
|
|
119
|
-
}
|
|
120
|
-
const out = CoachAskOut.parse({
|
|
121
|
-
conversation_id: conversationId,
|
|
122
|
-
turn_id: turnId,
|
|
123
|
-
response_text: responseText,
|
|
124
|
-
turn_status: status,
|
|
125
|
-
polled_iterations: polled,
|
|
126
|
-
timed_out: polled === 30,
|
|
127
|
-
});
|
|
128
|
-
return { content: [{ type: "text", text: jsonOut(out) }] };
|
|
76
|
+
export function registerCoachAsk(server: McpServer, client: WhoopClient, timing: CoachTiming = DEFAULT_TIMING): void {
|
|
77
|
+
defineTool(
|
|
78
|
+
server,
|
|
79
|
+
{
|
|
80
|
+
name: TOOL,
|
|
81
|
+
description:
|
|
82
|
+
"Ask WHOOP Coach (AI) and wait for the reply (up to ~50 s). One thread per agent per day; thread continues one from " +
|
|
83
|
+
"whoop_coach_history. Agents daily_outlook and day_in_review generate or open the current cycle's report and take no message. The " +
|
|
84
|
+
"coach can really create, edit and delete activities when asked (listed in actions); a saved memory shows only in the reply text. " +
|
|
85
|
+
"Previews unless confirm:true.",
|
|
86
|
+
input: coachAskInput,
|
|
87
|
+
annotations: openWorld(WRITE_DESTRUCTIVE),
|
|
88
|
+
},
|
|
89
|
+
async (input) => {
|
|
90
|
+
const plan = planAsk(input);
|
|
91
|
+
if (!input.confirm) return respond(TOOL, CoachAskOut, previewFor(plan));
|
|
92
|
+
return respond(TOOL, CoachAskOut, await askCoach(client, plan, timing));
|
|
129
93
|
},
|
|
130
94
|
);
|
|
131
95
|
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
import type { WhoopClient } from "../../whoop/client.js";
|
|
4
|
+
import { defineTool, respond } from "../define.js";
|
|
5
|
+
import { READ_ONLY } from "../annotations.js";
|
|
6
|
+
import { CoachHistoryOut, type CoachConversationT, type CoachHistoryOutT } from "../../schemas/coach.js";
|
|
7
|
+
import {
|
|
8
|
+
AGENT_SOURCES,
|
|
9
|
+
REPORT_PREFIX,
|
|
10
|
+
assistantText,
|
|
11
|
+
projectTranscript,
|
|
12
|
+
recommendationPath,
|
|
13
|
+
turnStatus,
|
|
14
|
+
} from "../../projections/coach.js";
|
|
15
|
+
import {
|
|
16
|
+
FAILED,
|
|
17
|
+
fetchRecommendations,
|
|
18
|
+
findListed,
|
|
19
|
+
listConversations,
|
|
20
|
+
openConversation,
|
|
21
|
+
reportFingerprint,
|
|
22
|
+
resolveCycleId,
|
|
23
|
+
} from "../../lib/coach_session.js";
|
|
24
|
+
import { todayIso } from "../../lib/dates.js";
|
|
25
|
+
|
|
26
|
+
const TOOL = "whoop_coach_history";
|
|
27
|
+
|
|
28
|
+
export const coachHistoryInput = {
|
|
29
|
+
view: z.enum(["list", "transcript", "outlook"]).default("list"),
|
|
30
|
+
limit: z.number().int().min(1).max(50).optional().describe("Default 10 rows, or the 5 newest turns"),
|
|
31
|
+
cursor: z.string().min(1).max(500).optional(),
|
|
32
|
+
fingerprint: z.string().min(1).max(200).optional().describe("transcript: from view list"),
|
|
33
|
+
kind: z.enum(["daily_outlook", "day_in_review"]).default("daily_outlook"),
|
|
34
|
+
date: z.iso.date().optional().describe("outlook only"),
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
type Input = z.infer<z.ZodObject<typeof coachHistoryInput>>;
|
|
38
|
+
|
|
39
|
+
async function transcript(client: WhoopClient, input: Input): Promise<CoachHistoryOutT> {
|
|
40
|
+
if (!input.fingerprint) throw new Error("view transcript needs a fingerprint from view list.");
|
|
41
|
+
// Reopening an unlisted fingerprint would create it (and generate an outlook),
|
|
42
|
+
// so only fingerprints present in a fresh list are reopened (S23).
|
|
43
|
+
const listed = await findListed(client, (c) => c.fingerprint === input.fingerprint);
|
|
44
|
+
if (!listed) {
|
|
45
|
+
throw new Error(`"${input.fingerprint}" isn't in your coach history, so totem won't open it (opening an unlisted fingerprint creates it). Use view list to find one.`);
|
|
46
|
+
}
|
|
47
|
+
const conversation = await openConversation(client, {
|
|
48
|
+
fingerprint: listed.fingerprint,
|
|
49
|
+
source_type: "UNKNOWN",
|
|
50
|
+
...(listed.source_id ? { source_id: listed.source_id } : {}),
|
|
51
|
+
});
|
|
52
|
+
const { total, turns } = projectTranscript(conversation, input.limit ?? 5);
|
|
53
|
+
return {
|
|
54
|
+
view: "transcript",
|
|
55
|
+
fingerprint: listed.fingerprint,
|
|
56
|
+
agent: listed.agent ?? listed.source_id,
|
|
57
|
+
title: listed.title,
|
|
58
|
+
total_turns: total,
|
|
59
|
+
turns,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async function outlook(client: WhoopClient, input: Input): Promise<CoachHistoryOutT> {
|
|
64
|
+
if (input.date && input.date > todayIso()) throw new Error(`${input.date} is in the future; reports exist only for past days and today.`);
|
|
65
|
+
const kind = input.kind;
|
|
66
|
+
const warnings: string[] = [];
|
|
67
|
+
// The cycle id is resolved from home right before use and never kept (S19).
|
|
68
|
+
const fingerprint = reportFingerprint(kind, await resolveCycleId(client, input.date));
|
|
69
|
+
// Sleep edits re-cut cycles, so today's report can sit under an older cycle id
|
|
70
|
+
// (ai §4.5): for today, a same-kind report in the TODAY group also counts,
|
|
71
|
+
// but only when the current cycle's own report isn't listed.
|
|
72
|
+
const older: { hit: CoachConversationT | null } = { hit: null };
|
|
73
|
+
const exact = await findListed(client, (c) => {
|
|
74
|
+
if (c.fingerprint === fingerprint) return true;
|
|
75
|
+
if (!older.hit && !input.date && c.fingerprint.startsWith(REPORT_PREFIX[kind]) && c.day?.toUpperCase() === "TODAY") older.hit = c;
|
|
76
|
+
return false;
|
|
77
|
+
});
|
|
78
|
+
const listed = exact ?? older.hit;
|
|
79
|
+
if (listed && listed.fingerprint !== fingerprint) {
|
|
80
|
+
warnings.push("Today's report is listed under an older cycle id (the cycle was re-cut after it was generated).");
|
|
81
|
+
}
|
|
82
|
+
if (!listed) {
|
|
83
|
+
return {
|
|
84
|
+
view: "outlook",
|
|
85
|
+
available: false,
|
|
86
|
+
fingerprint: null,
|
|
87
|
+
status: null,
|
|
88
|
+
text: null,
|
|
89
|
+
recommendations: null,
|
|
90
|
+
note: `Not generated for this cycle. whoop_coach_ask {agent:"${kind}"} generates it (current cycle only).`,
|
|
91
|
+
warnings,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
const conversation = await openConversation(client, {
|
|
95
|
+
fingerprint: listed.fingerprint,
|
|
96
|
+
source_type: "UNKNOWN",
|
|
97
|
+
source_id: listed.source_id ?? AGENT_SOURCES[kind]!.source_id,
|
|
98
|
+
});
|
|
99
|
+
const turns = Array.isArray(conversation.turns) ? conversation.turns : [];
|
|
100
|
+
const first = turns[0] ?? null;
|
|
101
|
+
const status = turnStatus(first);
|
|
102
|
+
const done = status === "COMPLETE";
|
|
103
|
+
if (status === FAILED) warnings.push("WHOOP failed to generate this report (turn FAILED); it won't complete.");
|
|
104
|
+
else if (!done) warnings.push("The report is still being generated; try again shortly.");
|
|
105
|
+
return {
|
|
106
|
+
view: "outlook",
|
|
107
|
+
available: true,
|
|
108
|
+
fingerprint: listed.fingerprint,
|
|
109
|
+
status: done ? null : status,
|
|
110
|
+
text: assistantText(first),
|
|
111
|
+
recommendations: done ? await fetchRecommendations(client, recommendationPath(first)) : null,
|
|
112
|
+
note: turns.length > 1 ? `${turns.length - 1} follow-up turn(s); view transcript shows them.` : null,
|
|
113
|
+
warnings,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export function registerCoachHistory(server: McpServer, client: WhoopClient): void {
|
|
118
|
+
defineTool(
|
|
119
|
+
server,
|
|
120
|
+
{
|
|
121
|
+
name: TOOL,
|
|
122
|
+
description:
|
|
123
|
+
"Read WHOOP Coach history. list: conversations (fingerprint, title, agent, day), newest first. transcript: a listed thread's " +
|
|
124
|
+
"turns, with the actions the coach took. outlook: a day's Daily Outlook or Day in Review, only if it already exists " +
|
|
125
|
+
"(whoop_coach_ask generates one). To reply, pass a fingerprint to whoop_coach_ask as thread.",
|
|
126
|
+
input: coachHistoryInput,
|
|
127
|
+
annotations: READ_ONLY,
|
|
128
|
+
},
|
|
129
|
+
async (input) => {
|
|
130
|
+
if (input.view === "transcript") return respond(TOOL, CoachHistoryOut, await transcript(client, input));
|
|
131
|
+
if (input.view === "outlook") return respond(TOOL, CoachHistoryOut, await outlook(client, input));
|
|
132
|
+
const page = await listConversations(client, input.limit ?? 10, input.cursor);
|
|
133
|
+
return respond(TOOL, CoachHistoryOut, {
|
|
134
|
+
view: "list",
|
|
135
|
+
conversations: page.conversations.map((c) => ({ fingerprint: c.fingerprint, title: c.title, agent: c.agent ?? c.source_id, day: c.day })),
|
|
136
|
+
next_cursor: page.next_cursor,
|
|
137
|
+
});
|
|
138
|
+
},
|
|
139
|
+
);
|
|
140
|
+
}
|