@trainheroic-unofficial/core 1.1.1 → 1.3.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/dist/index.d.mts +5 -1
- package/dist/index.mjs +85 -13
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -73,6 +73,10 @@ declare const SERVER_INSTRUCTIONS: string;
|
|
|
73
73
|
//#region src/tools/reads.d.ts
|
|
74
74
|
declare function registerReadTools(server: McpServer, ctx: ToolContext): void;
|
|
75
75
|
//#endregion
|
|
76
|
+
//#region src/tools/main-lifts.d.ts
|
|
77
|
+
/** Coach main-lift PR reads: one athlete, or the whole roster at once. */
|
|
78
|
+
declare function registerMainLiftTools(server: McpServer, ctx: ToolContext): void;
|
|
79
|
+
//#endregion
|
|
76
80
|
//#region src/tools/athlete-training.d.ts
|
|
77
81
|
/**
|
|
78
82
|
* Athlete tools need only the client (no exercise-library index), so they take a narrower
|
|
@@ -135,4 +139,4 @@ declare function registerWorkoutTools(server: McpServer, ctx: ToolContext): void
|
|
|
135
139
|
/** Live messaging: list/read conversations, draft a message, and the gated send/delete. */
|
|
136
140
|
declare function registerMessagingTools(server: McpServer, ctx: ToolContext): void;
|
|
137
141
|
//#endregion
|
|
138
|
-
export { AthleteContext, BudgetHint, DEFAULT_RESULT_BUDGET, DESTRUCTIVE, NOT_CONFIRMED, READ, SERVER_INSTRUCTIONS, SYNC, ToolContext, apiCall, attempt, boundedSerialize, confirmGate, errorResult, idParam, jsonResult, mapSessionExercises, registerAnalyticsTools, registerAthleteTools, registerAthleteTrainingTools, registerExerciseTools, registerMessagingTools, registerReadTools, registerTeamTools, registerWorkoutTools, resultBudget, toId };
|
|
142
|
+
export { AthleteContext, BudgetHint, DEFAULT_RESULT_BUDGET, DESTRUCTIVE, NOT_CONFIRMED, READ, SERVER_INSTRUCTIONS, SYNC, ToolContext, apiCall, attempt, boundedSerialize, confirmGate, errorResult, idParam, jsonResult, mapSessionExercises, registerAnalyticsTools, registerAthleteTools, registerAthleteTrainingTools, registerExerciseTools, registerMainLiftTools, registerMessagingTools, registerReadTools, registerTeamTools, registerWorkoutTools, resultBudget, toId };
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { blockSpecSchema, coachLogSessionArgsSchema, coachLogSetArgsSchema, commentDraftSchema, dateString, exerciseCreateSchema, idArgSchema, logSessionArgsSchema, logSetArgsSchema, parseWorkoutDate } from "@trainheroic-unofficial/dto";
|
|
1
|
+
import { blockSpecSchema, coachLogSessionArgsSchema, coachLogSetArgsSchema, coachPrescribeSetArgsSchema, commentDraftSchema, dateString, exerciseCreateSchema, idArgSchema, logSessionArgsSchema, logSetArgsSchema, parseWorkoutDate, swapAthleteExerciseArgsSchema } from "@trainheroic-unofficial/dto";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import { ANALYTICS_METRIC_KEYS, addExercisesToWorkout, buildCommentPayload, buildSession, coerceInt, collectAdvisories, copySession, createPersonalWorkout, definedProps, deleteComment, exerciseUnits, fetchAthletePrefs, fetchAthleteProfileSummary, fetchAthleteUser, fetchAthleteWorkouts, fetchCoachAthleteCalendarSummary, fetchCoachAthleteWorkouts, fetchExerciseHistoryDetail, fetchExerciseHistoryList, fetchExerciseStats, fetchLeaderboard, fetchPersonalRecords, fetchRosterActivity, fetchStreams, fetchTeamAthleteIds, fetchWorkingMaxes, inviteAthletes, isRecord, logAdHocSession, logAthleteSet, logForAthlete, logSessionForAthlete, presentAthleteWorkouts, presentCoachAthleteTraining, presentExerciseHistory, publishSession, queryAnalytics, readLive, readSession, removeSession, searchExerciseHistory, selectWorkouts, sendComment, summarizeAthleteWorkouts, teamVolume } from "@trainheroic-unofficial/js";
|
|
3
|
+
import { ANALYTICS_METRIC_KEYS, addExercisesToWorkout, buildCommentPayload, buildSession, coerceInt, collectAdvisories, copySession, createPersonalWorkout, definedProps, deleteComment, exerciseUnits, fetchAthleteMainLiftPRs, fetchAthletePrefs, fetchAthleteProfileSummary, fetchAthleteUser, fetchAthleteWorkouts, fetchCoachAthleteCalendarSummary, fetchCoachAthleteWorkouts, fetchExerciseHistoryDetail, fetchExerciseHistoryList, fetchExerciseStats, fetchLeaderboard, fetchPersonalRecords, fetchRosterActivity, fetchRosterMainLiftPRs, fetchStreams, fetchTeamAthleteIds, fetchWorkingMaxes, inviteAthletes, isRecord, logAdHocSession, logAthleteSet, logForAthlete, logSessionForAthlete, prescribeForAthlete, presentAthleteWorkouts, presentCoachAthleteTraining, presentExerciseHistory, publishSession, queryAnalytics, readLive, readSession, removeSession, searchExerciseHistory, selectWorkouts, sendComment, summarizeAthleteWorkouts, swapAthleteExercise, teamVolume, toSetResults } from "@trainheroic-unofficial/js";
|
|
4
4
|
//#region src/context.ts
|
|
5
5
|
/** A tool argument that accepts a numeric id as a number or a string of digits. */
|
|
6
6
|
const idParam = idArgSchema;
|
|
@@ -405,6 +405,37 @@ function registerReadTools(server, ctx) {
|
|
|
405
405
|
registerTeamVolume(server, ctx);
|
|
406
406
|
}
|
|
407
407
|
//#endregion
|
|
408
|
+
//#region src/tools/main-lifts.ts
|
|
409
|
+
const monthsParam = z.number().int().positive().max(36).optional();
|
|
410
|
+
const ATHLETE_DESC = "A roster athlete's personal records for the main barbell lifts (squat, bench press, deadlift, overhead press, clean & jerk, snatch). Pass athleteId from list_athletes — nothing else. It auto-discovers which exercise VARIANT the athlete actually logs for each lift (e.g. 'Back Squat', not the empty 'Squat' library entry) by scanning their recent training, so you do NOT resolve exercise ids yourself. Returns one row per lift family in a fixed order; a lift the athlete has not logged comes back with null fields (no PR yet). `months` (default 12) is how far back to look for the logged variants.";
|
|
411
|
+
const ROSTER_DESC = "Every roster athlete's main-lift PRs in one call — the squad board for squat/bench/deadlift/overhead press/clean & jerk/snatch. Same per-athlete discovery as athlete_main_lift_prs, fanned out across the roster (bounded), so it makes many upstream calls; expect a few seconds on a big roster. Optional athleteIds restricts it to a subset (else the whole roster from /v5/athletes); `months` (default 12) sets the look-back for logged variants.";
|
|
412
|
+
/** Coach main-lift PR reads: one athlete, or the whole roster at once. */
|
|
413
|
+
function registerMainLiftTools(server, ctx) {
|
|
414
|
+
server.registerTool("athlete_main_lift_prs", {
|
|
415
|
+
title: "Athlete main-lift PRs (roster)",
|
|
416
|
+
description: ATHLETE_DESC,
|
|
417
|
+
inputSchema: {
|
|
418
|
+
athleteId: idParam,
|
|
419
|
+
months: monthsParam
|
|
420
|
+
},
|
|
421
|
+
annotations: READ
|
|
422
|
+
}, ({ athleteId, months }) => attempt(async () => jsonResult(await fetchAthleteMainLiftPRs(ctx.client, toId(athleteId), months !== void 0 ? { months } : {}))));
|
|
423
|
+
server.registerTool("roster_main_lift_prs", {
|
|
424
|
+
title: "Roster main-lift PRs",
|
|
425
|
+
description: ROSTER_DESC,
|
|
426
|
+
inputSchema: {
|
|
427
|
+
months: monthsParam,
|
|
428
|
+
athleteIds: z.array(idParam).optional()
|
|
429
|
+
},
|
|
430
|
+
annotations: READ
|
|
431
|
+
}, ({ months, athleteIds }) => attempt(async () => {
|
|
432
|
+
return jsonResult(await fetchRosterMainLiftPRs(ctx.client, {
|
|
433
|
+
...athleteIds ? { athleteIds: athleteIds.map(toId) } : {},
|
|
434
|
+
...months !== void 0 ? { months } : {}
|
|
435
|
+
}), { hint: "Pass athleteIds to scope to a few athletes, or lower months, to shrink this." });
|
|
436
|
+
}));
|
|
437
|
+
}
|
|
438
|
+
//#endregion
|
|
408
439
|
//#region src/tools/athlete-training.ts
|
|
409
440
|
/** Identity, profile, prefs, working maxes, leaderboard. */
|
|
410
441
|
function registerProfileTools(server, ctx, whoami, userId) {
|
|
@@ -719,6 +750,8 @@ function registerAthleteTools(server, ctx) {
|
|
|
719
750
|
}
|
|
720
751
|
}, ({ athleteIds }) => apiCall(ctx, "PUT", "/v5/athletes/restore", { body: { athleteIds: athleteIds.map(toId) } }));
|
|
721
752
|
registerAthleteLogTools(server, ctx);
|
|
753
|
+
registerAthleteSwapTool(server, ctx);
|
|
754
|
+
registerAthletePrescribeTool(server, ctx);
|
|
722
755
|
}
|
|
723
756
|
/**
|
|
724
757
|
* Coach "Log for Athlete": read a roster athlete's saved workouts (to get the log ids), then
|
|
@@ -753,20 +786,11 @@ function registerAthleteLogTools(server, ctx) {
|
|
|
753
786
|
}, ({ athleteId, date, savedWorkoutSetId, results, confirm }, extra) => attempt(async () => {
|
|
754
787
|
const aId = toId(athleteId);
|
|
755
788
|
if (!await confirmGate(server, extra.requestId, `Log results to athlete ${aId}'s saved workout set ${toId(savedWorkoutSetId)} on ${date}? This writes to their coach-visible training log.`, confirm)) return errorResult(NOT_CONFIRMED);
|
|
756
|
-
const mapped = results.map((r) => ({
|
|
757
|
-
savedWorkoutSetExerciseId: toId(r.savedWorkoutSetExerciseId),
|
|
758
|
-
sets: r.sets.map((s) => {
|
|
759
|
-
const slot = {};
|
|
760
|
-
if (s.param1 !== void 0) slot.param1 = s.param1;
|
|
761
|
-
if (s.param2 !== void 0) slot.param2 = s.param2;
|
|
762
|
-
return slot;
|
|
763
|
-
})
|
|
764
|
-
}));
|
|
765
789
|
return jsonResult(await logForAthlete(ctx.client, {
|
|
766
790
|
athleteId: aId,
|
|
767
791
|
date,
|
|
768
792
|
savedWorkoutSetId: toId(savedWorkoutSetId),
|
|
769
|
-
results:
|
|
793
|
+
results: toSetResults(results)
|
|
770
794
|
}));
|
|
771
795
|
}));
|
|
772
796
|
server.registerTool("coach_log_session", {
|
|
@@ -787,6 +811,54 @@ function registerAthleteLogTools(server, ctx) {
|
|
|
787
811
|
}));
|
|
788
812
|
}));
|
|
789
813
|
}
|
|
814
|
+
/**
|
|
815
|
+
* Coach per-athlete exercise swap, kept in its own function so registerAthleteLogTools stays
|
|
816
|
+
* under the oxlint max-lines-per-function cap.
|
|
817
|
+
*/
|
|
818
|
+
function registerAthleteSwapTool(server, ctx) {
|
|
819
|
+
server.registerTool("swap_athlete_exercise", {
|
|
820
|
+
title: "Swap one exercise in a roster athlete's prescribed workout",
|
|
821
|
+
description: "Coach-facing write: replace one exercise in a roster athlete's scheduled workout with a different one, for that athlete only — the API equivalent of the app's per-athlete \"swap exercise\". The team/program prescription is left untouched, so other athletes on the same program keep the original exercise. Give savedWorkoutSetExerciseId (the athlete's own slot, from athlete_saved_workouts with raw:true) and exerciseId (the replacement, from exercise_resolve / exercise_search). Seeded demo athletes are read-only and will fail; use a real (invited) athlete. Requires confirmation (elicitation or confirm:true).",
|
|
822
|
+
inputSchema: {
|
|
823
|
+
...swapAthleteExerciseArgsSchema.shape,
|
|
824
|
+
confirm: z.boolean().optional()
|
|
825
|
+
},
|
|
826
|
+
annotations: DESTRUCTIVE
|
|
827
|
+
}, ({ savedWorkoutSetExerciseId, exerciseId, confirm }, extra) => attempt(async () => {
|
|
828
|
+
const sweId = toId(savedWorkoutSetExerciseId);
|
|
829
|
+
const exId = toId(exerciseId);
|
|
830
|
+
if (!await confirmGate(server, extra.requestId, `Swap the exercise in saved workout slot ${sweId} to exercise ${exId}? This changes what this athlete is prescribed (their copy only).`, confirm)) return errorResult(NOT_CONFIRMED);
|
|
831
|
+
return jsonResult(await swapAthleteExercise(ctx.client, {
|
|
832
|
+
savedWorkoutSetExerciseId: sweId,
|
|
833
|
+
exerciseId: exId
|
|
834
|
+
}));
|
|
835
|
+
}));
|
|
836
|
+
}
|
|
837
|
+
/**
|
|
838
|
+
* Coach prescription override, kept in its own function so registerAthleteTools stays under the
|
|
839
|
+
* oxlint max-lines-per-function cap. Lets a coach set the prescribed reps/weight for one of a
|
|
840
|
+
* roster athlete's saved workout sets without marking it done — "prescribe weights for an athlete".
|
|
841
|
+
*/
|
|
842
|
+
function registerAthletePrescribeTool(server, ctx) {
|
|
843
|
+
server.registerTool("prescribe_athlete_set", {
|
|
844
|
+
title: "Prescribe reps/weight for a roster athlete's set",
|
|
845
|
+
description: "Coach-facing write: set the prescribed reps and/or weight for one of a roster athlete's scheduled workout sets, for that athlete only, WITHOUT marking it done — the API equivalent of the app's editing an athlete's prescribed values (\"prescribe weights for an athlete\"). The set stays open for the athlete to log against, and the team/program prescription is left untouched, so other athletes keep the original targets. param1 is reps, param2 is weight; pass one sets[] entry per prescribed set. The write REPLACES the slot's prescribed values (the sets you pass become the whole prescription, and an omitted param is cleared), so give the full per-set prescription you want. Get athleteId from list_athletes; get savedWorkoutSetId + savedWorkoutSetExerciseId from athlete_saved_workouts (raw:true) for that athlete/day. To record a set as PERFORMED instead, use log_athlete_set. Seeded demo athletes are read-only and will fail; use a real (invited) athlete. Requires confirmation (elicitation or confirm:true).",
|
|
846
|
+
inputSchema: {
|
|
847
|
+
...coachPrescribeSetArgsSchema.shape,
|
|
848
|
+
confirm: z.boolean().optional()
|
|
849
|
+
},
|
|
850
|
+
annotations: DESTRUCTIVE
|
|
851
|
+
}, ({ athleteId, date, savedWorkoutSetId, results, confirm }, extra) => attempt(async () => {
|
|
852
|
+
const aId = toId(athleteId);
|
|
853
|
+
if (!await confirmGate(server, extra.requestId, `Set prescribed values on athlete ${aId}'s saved workout set ${toId(savedWorkoutSetId)} on ${date}? This changes what this athlete is prescribed (their copy only); it does not mark the set done.`, confirm)) return errorResult(NOT_CONFIRMED);
|
|
854
|
+
return jsonResult(await prescribeForAthlete(ctx.client, {
|
|
855
|
+
athleteId: aId,
|
|
856
|
+
date,
|
|
857
|
+
savedWorkoutSetId: toId(savedWorkoutSetId),
|
|
858
|
+
results: toSetResults(results)
|
|
859
|
+
}));
|
|
860
|
+
}));
|
|
861
|
+
}
|
|
790
862
|
//#endregion
|
|
791
863
|
//#region src/tools/teams.ts
|
|
792
864
|
const ADDITIVE = {
|
|
@@ -1181,4 +1253,4 @@ function registerMessagingTools(server, ctx) {
|
|
|
1181
1253
|
registerWrites(server, ctx);
|
|
1182
1254
|
}
|
|
1183
1255
|
//#endregion
|
|
1184
|
-
export { DEFAULT_RESULT_BUDGET, DESTRUCTIVE, NOT_CONFIRMED, READ, SERVER_INSTRUCTIONS, SYNC, apiCall, attempt, boundedSerialize, confirmGate, errorResult, idParam, jsonResult, mapSessionExercises, registerAnalyticsTools, registerAthleteTools, registerAthleteTrainingTools, registerExerciseTools, registerMessagingTools, registerReadTools, registerTeamTools, registerWorkoutTools, resultBudget, toId };
|
|
1256
|
+
export { DEFAULT_RESULT_BUDGET, DESTRUCTIVE, NOT_CONFIRMED, READ, SERVER_INSTRUCTIONS, SYNC, apiCall, attempt, boundedSerialize, confirmGate, errorResult, idParam, jsonResult, mapSessionExercises, registerAnalyticsTools, registerAthleteTools, registerAthleteTrainingTools, registerExerciseTools, registerMainLiftTools, registerMessagingTools, registerReadTools, registerTeamTools, registerWorkoutTools, resultBudget, toId };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trainheroic-unofficial/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"@cfworker/json-schema": "^4.1.1",
|
|
26
26
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
27
27
|
"zod": "^4.4.3",
|
|
28
|
-
"@trainheroic-unofficial/dto": "1.
|
|
29
|
-
"@trainheroic-unofficial/js": "1.
|
|
28
|
+
"@trainheroic-unofficial/dto": "1.3.0",
|
|
29
|
+
"@trainheroic-unofficial/js": "1.3.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/node": "^26.0.0",
|