@trainheroic-unofficial/coach-mcp 3.3.2 → 3.4.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.
Files changed (2) hide show
  1. package/dist/server.mjs +46 -15
  2. package/package.json +5 -5
package/dist/server.mjs CHANGED
@@ -238,6 +238,12 @@ z.object({
238
238
  programWorkoutId: idArgSchema,
239
239
  date: dateString
240
240
  });
241
+ z.object({
242
+ date: dateString,
243
+ programWorkoutId: idArgSchema,
244
+ notes: z.string().optional(),
245
+ rpe: z.number().int().min(1).max(10).optional()
246
+ }).refine((v) => v.notes !== void 0 || v.rpe !== void 0, { message: "Provide notes and/or rpe" });
241
247
  const presentedNullNumber = z.number().nullable();
242
248
  const presentedNullString = z.string().nullable();
243
249
  /** Flattened exercise within a presented workout: prescriptions, logged results, units. */
@@ -263,6 +269,8 @@ const athleteWorkoutViewSchema = z.object({
263
269
  program: presentedNullString,
264
270
  team: presentedNullString,
265
271
  instruction: presentedNullString,
272
+ notes: presentedNullString,
273
+ rpe: presentedNullNumber,
266
274
  logged: z.boolean(),
267
275
  personal: z.boolean(),
268
276
  blocks: z.array(athleteWorkoutBlockSchema)
@@ -572,6 +580,13 @@ z.object({
572
580
  groupId: z.number(),
573
581
  date: z.string()
574
582
  });
583
+ z.object({
584
+ programWorkoutId: z.number(),
585
+ savedWorkoutId: z.number(),
586
+ date: z.string(),
587
+ notes: z.string(),
588
+ rpe: nullableNumber
589
+ });
575
590
  const workoutReadExerciseOutputSchema = z.object({
576
591
  order: z.number(),
577
592
  title: z.string(),
@@ -739,23 +754,23 @@ function toId(value) {
739
754
  const READ = {
740
755
  readOnlyHint: true,
741
756
  destructiveHint: false,
742
- openWorldHint: true
757
+ openWorldHint: false
743
758
  };
744
759
  const ADDITIVE = {
745
760
  readOnlyHint: false,
746
761
  destructiveHint: false,
747
- openWorldHint: true
762
+ openWorldHint: false
748
763
  };
749
764
  const SYNC = {
750
765
  readOnlyHint: false,
751
766
  idempotentHint: true,
752
767
  destructiveHint: false,
753
- openWorldHint: true
768
+ openWorldHint: false
754
769
  };
755
770
  const DESTRUCTIVE = {
756
771
  readOnlyHint: false,
757
772
  destructiveHint: true,
758
- openWorldHint: true
773
+ openWorldHint: false
759
774
  };
760
775
  /**
761
776
  * Run a tool body, converting thrown errors into an in-band tool error. Generic so a caller that
@@ -1325,6 +1340,15 @@ function isPersonalSession(pw) {
1325
1340
  return isRecord(pw) && pw.personal_cal === true;
1326
1341
  }
1327
1342
  /**
1343
+ * The `saved_workout` blob on a program-workout range item, or null if the athlete has no saved
1344
+ * copy yet. Session notes, RPE, and set writes all resolve through this.
1345
+ */
1346
+ function savedWorkoutOf(pw) {
1347
+ if (!isRecord(pw)) return null;
1348
+ const ssw = isRecord(pw.summarizedSavedWorkout) ? pw.summarizedSavedWorkout : {};
1349
+ return isRecord(ssw.saved_workout) ? ssw.saved_workout : null;
1350
+ }
1351
+ /**
1328
1352
  * Rank candidate rows for a free-text query (FTS5 replacement). Higher is better:
1329
1353
  * exact title, then prefix, then count of matched tokens, with shorter titles and
1330
1354
  * standard (non-custom) exercises preferred on ties.
@@ -1562,7 +1586,7 @@ function mergeAthleteWorkout(raw) {
1562
1586
  const rec = raw;
1563
1587
  const ssw = isRecord(rec.summarizedSavedWorkout) ? rec.summarizedSavedWorkout : {};
1564
1588
  const workout = isRecord(ssw.workout) ? ssw.workout : {};
1565
- const saved = isRecord(ssw.saved_workout) ? ssw.saved_workout : {};
1589
+ const saved = savedWorkoutOf(rec) ?? {};
1566
1590
  const prescriptionSets = (Array.isArray(workout.workoutSets) ? workout.workoutSets : []).filter(isRecord);
1567
1591
  const logged = savedSets(saved);
1568
1592
  const performedById = performedSlotsByExerciseId(logged);
@@ -1591,6 +1615,8 @@ function mergeAthleteWorkout(raw) {
1591
1615
  program: str$1(rec.program_title),
1592
1616
  team: str$1(rec.team_title),
1593
1617
  instruction: str$1(workout.instruction),
1618
+ notes: str$1(saved.notes),
1619
+ rpe: coerceInt(saved.rpe),
1594
1620
  logged: blocks.some((b) => b.exercises.some((e) => e.sets.some((s) => s.performed !== null))),
1595
1621
  personal: isPersonalSession(rec),
1596
1622
  blocks
@@ -1638,6 +1664,8 @@ function presentAthleteWorkout(raw) {
1638
1664
  program: w.program,
1639
1665
  team: w.team,
1640
1666
  instruction: w.instruction,
1667
+ notes: w.notes,
1668
+ rpe: w.rpe,
1641
1669
  logged: w.logged,
1642
1670
  personal: w.personal,
1643
1671
  blocks: w.blocks.map(toStringBlock)
@@ -1757,7 +1785,7 @@ function presentCoachAthleteTraining(raw, athleteId, year, month) {
1757
1785
  completed: coerceInt(item.completed) === 1,
1758
1786
  rpe: coerceInt(item.rpe),
1759
1787
  durationMin: coerceInt(item.session_duration),
1760
- notes: typeof item.notes === "string" && item.notes !== "" ? item.notes : null,
1788
+ notes: str$1(item.notes),
1761
1789
  exercises
1762
1790
  });
1763
1791
  }
@@ -1977,9 +2005,7 @@ function assertUniqueExerciseResults(results) {
1977
2005
  function findSavedWorkoutSet(workouts, savedWorkoutSetId) {
1978
2006
  const available = [];
1979
2007
  for (const pw of workouts) {
1980
- const rec = pw;
1981
- const ssw = isRecord(rec.summarizedSavedWorkout) ? rec.summarizedSavedWorkout : {};
1982
- const sw = isRecord(ssw.saved_workout) ? ssw.saved_workout : null;
2008
+ const sw = savedWorkoutOf(pw);
1983
2009
  if (!sw) continue;
1984
2010
  const sets = Array.isArray(sw.workoutSets) ? sw.workoutSets : [];
1985
2011
  for (const s of sets) {
@@ -2199,8 +2225,7 @@ function eachPrescribedExercise(workouts) {
2199
2225
  const rows = [];
2200
2226
  for (const pw of workouts) {
2201
2227
  const rec = pw;
2202
- const ssw = isRecord(rec.summarizedSavedWorkout) ? rec.summarizedSavedWorkout : {};
2203
- const sw = isRecord(ssw.saved_workout) ? ssw.saved_workout : null;
2228
+ const sw = savedWorkoutOf(rec);
2204
2229
  if (!sw) continue;
2205
2230
  const sets = [...Array.isArray(sw.workoutSets) ? sw.workoutSets : [], ...Array.isArray(sw.addedWorkoutSets) ? sw.addedWorkoutSets : []];
2206
2231
  for (const s of sets) {
@@ -3933,7 +3958,10 @@ function registerAthleteTools(server, ctx) {
3933
3958
  confirm: z.boolean().optional()
3934
3959
  },
3935
3960
  outputSchema: toolOutputSchema(athleteInviteOutputSchema),
3936
- annotations: DESTRUCTIVE
3961
+ annotations: {
3962
+ ...DESTRUCTIVE,
3963
+ openWorldHint: true
3964
+ }
3937
3965
  }, ({ teamId, emails, message, confirm }, extra) => attempt(async () => {
3938
3966
  const list = asEmailList(emails);
3939
3967
  if (list.length === 0) return errorResult("Provide at least one email address to invite.");
@@ -3974,7 +4002,7 @@ function registerAthleteTools(server, ctx) {
3974
4002
  readOnlyHint: false,
3975
4003
  idempotentHint: true,
3976
4004
  destructiveHint: false,
3977
- openWorldHint: true
4005
+ openWorldHint: false
3978
4006
  }
3979
4007
  }, ({ athleteIds }) => apiCall(ctx, "PUT", "/v5/athletes/restore", { body: { athleteIds: athleteIds.map(toId) } }));
3980
4008
  registerAthleteLogTools(server, ctx);
@@ -4619,7 +4647,10 @@ function registerWrites(server, ctx) {
4619
4647
  confirm: z.boolean().optional()
4620
4648
  },
4621
4649
  outputSchema: toolOutputSchema(messageSentOutputSchema),
4622
- annotations: DESTRUCTIVE
4650
+ annotations: {
4651
+ ...DESTRUCTIVE,
4652
+ openWorldHint: true
4653
+ }
4623
4654
  }, ({ streamId, text, replyTo, confirm }, extra) => attempt(async () => {
4624
4655
  const id = toId(streamId);
4625
4656
  const blocked = confirmGate(extra, `Send this message to stream ${id}? It is athlete-facing and immediate.`, confirm);
@@ -4693,7 +4724,7 @@ var JsonFileLibraryCache = class {
4693
4724
  };
4694
4725
  //#endregion
4695
4726
  //#region package.json
4696
- var version = "3.3.2";
4727
+ var version = "3.4.0";
4697
4728
  //#endregion
4698
4729
  //#region src/server.ts
4699
4730
  function main() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trainheroic-unofficial/coach-mcp",
3
- "version": "3.3.2",
3
+ "version": "3.4.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -21,15 +21,15 @@
21
21
  "dependencies": {
22
22
  "@modelcontextprotocol/server": "2.0.0",
23
23
  "zod": "^4.4.3",
24
- "@trainheroic-unofficial/core": "3.3.2",
25
- "@trainheroic-unofficial/js": "3.3.2"
24
+ "@trainheroic-unofficial/core": "3.4.0",
25
+ "@trainheroic-unofficial/js": "3.4.0"
26
26
  },
27
27
  "devDependencies": {
28
- "@types/node": "^26.2.0",
28
+ "@types/node": "^26.3.0",
29
29
  "tsdown": "^0.22.14",
30
30
  "tsx": "^4.23.12",
31
31
  "typescript": "^7.0.2",
32
- "vitest": "^4.1.10"
32
+ "vitest": "^4.1.11"
33
33
  },
34
34
  "scripts": {
35
35
  "start": "tsx src/server.ts",