@trainheroic-unofficial/athlete-mcp 3.0.0 → 3.0.1

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.
Files changed (2) hide show
  1. package/dist/server.mjs +10 -57
  2. package/package.json +3 -3
package/dist/server.mjs CHANGED
@@ -822,7 +822,7 @@ async function getJson(client, path, label) {
822
822
  if (!res.ok) throw new Error(`${label} failed (HTTP ${res.status}).`);
823
823
  return res.data;
824
824
  }
825
- async function getArray$1(client, path, label) {
825
+ async function getArray(client, path, label) {
826
826
  const res = await client.request("GET", path);
827
827
  if (!res.ok || !Array.isArray(res.data)) throw new Error(`${label} failed (HTTP ${res.status}).`);
828
828
  return res.data;
@@ -838,10 +838,10 @@ function fetchAthletePrefs(client) {
838
838
  return getJson(client, "/1.0/athlete/prefs", "athlete prefs");
839
839
  }
840
840
  function fetchWorkingMaxes(client) {
841
- return getArray$1(client, "/2.0/athlete/workingMax", "athlete working maxes");
841
+ return getArray(client, "/2.0/athlete/workingMax", "athlete working maxes");
842
842
  }
843
843
  function fetchExerciseHistoryList(client) {
844
- return getArray$1(client, "/v5/users/exercises/history", "athlete exercise history list");
844
+ return getArray(client, "/v5/users/exercises/history", "athlete exercise history list");
845
845
  }
846
846
  /** Free-text search over the athlete's logged exercises (FTS replacement via rankSearch). */
847
847
  async function searchExerciseHistory(client, query, limit = 20) {
@@ -851,7 +851,7 @@ function fetchExerciseHistoryDetail(client, exerciseId, userId) {
851
851
  return getJson(client, `/v5/exercises/${exerciseId}/history?userId=${userId}`, "athlete exercise history");
852
852
  }
853
853
  function fetchPersonalRecords(client, exerciseId) {
854
- return getArray$1(client, `/v5/exercises/${exerciseId}/personalRecords`, "athlete personal records");
854
+ return getArray(client, `/v5/exercises/${exerciseId}/personalRecords`, "athlete personal records");
855
855
  }
856
856
  /** Last performance + PR for an exercise. `date` (YYYY-MM-DD) is required by the API. */
857
857
  function fetchExerciseStats(client, exerciseId, userId, date) {
@@ -859,7 +859,7 @@ function fetchExerciseStats(client, exerciseId, userId, date) {
859
859
  }
860
860
  /** Scheduled + completed workouts in an inclusive YYYY-MM-DD window. */
861
861
  function fetchAthleteWorkouts(client, startDate, endDate) {
862
- return getArray$1(client, `/3.0/athlete/programworkout/range?startDate=${startDate}&endDate=${endDate}`, "athlete workouts");
862
+ return getArray(client, `/3.0/athlete/programworkout/range?startDate=${startDate}&endDate=${endDate}`, "athlete workouts");
863
863
  }
864
864
  function fetchLeaderboard(client, workoutId, opts = {}) {
865
865
  const qs = new URLSearchParams();
@@ -1212,22 +1212,6 @@ function presentExerciseHistory(detail) {
1212
1212
  };
1213
1213
  }
1214
1214
  //#endregion
1215
- //#region ../js/src/coach-athlete-calendar.ts
1216
- async function getArray(client, path, label) {
1217
- const res = await client.request("GET", path);
1218
- if (!res.ok || !Array.isArray(res.data)) throw new Error(`${label} failed (HTTP ${res.status}).`);
1219
- return res.data;
1220
- }
1221
- /**
1222
- * A coach's view of a roster athlete's scheduled + completed workouts in an inclusive
1223
- * YYYY-MM-DD window (`/3.0/coach/athlete/programworkout/range/{athleteId}`). Returns the same
1224
- * `ProgramWorkout[]` shape as `fetchAthleteWorkouts`, so the same presenters and
1225
- * `findSavedWorkoutSet` apply — it just reads another athlete's data through the coach surface.
1226
- */
1227
- function fetchCoachAthleteWorkouts(client, athleteId, startDate, endDate) {
1228
- return getArray(client, `/3.0/coach/athlete/programworkout/range/${athleteId}?startDate=${startDate}&endDate=${endDate}`, "coach athlete workouts");
1229
- }
1230
- //#endregion
1231
1215
  //#region ../js/src/exercise-set-payload.ts
1232
1216
  function slotData(exercise, key) {
1233
1217
  const value = exercise?.[key];
@@ -1443,28 +1427,6 @@ async function logAthleteSet(client, args) {
1443
1427
  };
1444
1428
  }
1445
1429
  /**
1446
- * Coach "Log for Athlete": record set results for a roster athlete on their behalf, via the
1447
- * coach surface — `PUT /1.0/coach/savedworkoutsetexercise/{id}/{athleteId}` (the data write)
1448
- * then `PUT /1.0/coach/savedworkoutset/{id}/{athleteId}` (mark complete). Same two-step
1449
- * contract as {@link logAthleteSet}; the bodies are identical except each is stamped with
1450
- * `athleteId`. The day is located through the coach range endpoint for that athlete.
1451
- *
1452
- * NOTE: TrainHeroic's seeded *demo* athletes are read-only for results and return 401 on the
1453
- * data-write step; real (invited) athletes accept it.
1454
- */
1455
- async function logForAthlete(client, args) {
1456
- const workouts = await fetchCoachAthleteWorkouts(client, args.athleteId, args.date, args.date);
1457
- const r = await writeSetResults(client, {
1458
- role: "coach",
1459
- athleteId: args.athleteId
1460
- }, workouts, args.savedWorkoutSetId, args.results, "log");
1461
- return {
1462
- savedWorkoutSetId: r.savedWorkoutSetId,
1463
- exercisesLogged: r.exercisesWritten,
1464
- setCompleted: r.setCompleted
1465
- };
1466
- }
1467
- /**
1468
1430
  * Swap the exercise prescribed in one of an athlete's saved-workout slots for a different
1469
1431
  * exercise — the API equivalent of the app's per-athlete "swap exercise":
1470
1432
  * `PUT /v5/savedWorkoutSetExercises/{savedWorkoutSetExerciseId}?exerciseId={exerciseId}` with an
@@ -1707,7 +1669,7 @@ function findScheduledMatches(workouts, exerciseIds) {
1707
1669
  return out;
1708
1670
  }
1709
1671
  /** Group resolved exercises by saved set and write each set via the given log target. */
1710
- async function logResolvedExercises(client, target, date, resolved) {
1672
+ async function logResolvedExercises(client, target, workouts, resolved) {
1711
1673
  const bySet = /* @__PURE__ */ new Map();
1712
1674
  for (const r of resolved) {
1713
1675
  const list = bySet.get(r.savedWorkoutSetId) ?? [];
@@ -1719,19 +1681,10 @@ async function logResolvedExercises(client, target, date, resolved) {
1719
1681
  }
1720
1682
  const out = [];
1721
1683
  for (const [savedWorkoutSetId, results] of bySet) {
1722
- const written = target.role === "coach" ? await logForAthlete(client, {
1723
- athleteId: target.athleteId,
1724
- date,
1725
- savedWorkoutSetId,
1726
- results
1727
- }) : await logAthleteSet(client, {
1728
- date,
1729
- savedWorkoutSetId,
1730
- results
1731
- });
1684
+ const written = await writeSetResults(client, target, workouts, savedWorkoutSetId, results, "log");
1732
1685
  out.push({
1733
1686
  savedWorkoutSetId: written.savedWorkoutSetId,
1734
- exercisesLogged: written.exercisesLogged
1687
+ exercisesLogged: written.exercisesWritten
1735
1688
  });
1736
1689
  }
1737
1690
  return out;
@@ -1769,7 +1722,7 @@ async function logAdHocSession(client, args) {
1769
1722
  sets: e.sets
1770
1723
  };
1771
1724
  });
1772
- const sets = await logResolvedExercises(client, { role: "athlete" }, args.date, resolved);
1725
+ const sets = await logResolvedExercises(client, { role: "athlete" }, await fetchAthleteWorkouts(client, args.date, args.date), resolved);
1773
1726
  const result = {
1774
1727
  date: args.date,
1775
1728
  created,
@@ -2150,7 +2103,7 @@ function registerAthleteTrainingTools(server, ctx) {
2150
2103
  }
2151
2104
  //#endregion
2152
2105
  //#region package.json
2153
- var version = "3.0.0";
2106
+ var version = "3.0.1";
2154
2107
  //#endregion
2155
2108
  //#region src/server.ts
2156
2109
  function main() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trainheroic-unofficial/athlete-mcp",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -21,8 +21,8 @@
21
21
  "dependencies": {
22
22
  "@modelcontextprotocol/server": "2.0.0",
23
23
  "zod": "^4.4.3",
24
- "@trainheroic-unofficial/core": "3.0.0",
25
- "@trainheroic-unofficial/js": "3.0.0"
24
+ "@trainheroic-unofficial/core": "3.0.1",
25
+ "@trainheroic-unofficial/js": "3.0.1"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@types/node": "^26.2.0",