@trainheroic-unofficial/core 0.4.0 → 0.4.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.
- package/dist/index.mjs +37 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { blockSpecSchema, commentDraftSchema, dateString, exerciseCreateSchema, idArgSchema, logSetArgsSchema, parseWorkoutDate } from "@trainheroic-unofficial/dto";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import { buildCommentPayload, buildSession, coerceInt, collectAdvisories, deleteComment, exerciseUnits, fetchAthletePrefs, fetchAthleteProfileSummary, fetchAthleteUser, fetchAthleteWorkouts, fetchExerciseHistoryDetail, fetchExerciseHistoryList, fetchExerciseStats, fetchLeaderboard, fetchPersonalRecords, fetchStreams, fetchWorkingMaxes, isRecord, logAthleteSet, presentAthleteWorkouts, presentExerciseHistory, publishSession, readLive, readSession, removeSession, searchExerciseHistory, sendComment } from "@trainheroic-unofficial/js";
|
|
3
|
+
import { addExercisesToWorkout, buildCommentPayload, buildSession, coerceInt, collectAdvisories, createPersonalWorkout, deleteComment, exerciseUnits, fetchAthletePrefs, fetchAthleteProfileSummary, fetchAthleteUser, fetchAthleteWorkouts, fetchExerciseHistoryDetail, fetchExerciseHistoryList, fetchExerciseStats, fetchLeaderboard, fetchPersonalRecords, fetchStreams, fetchWorkingMaxes, isRecord, logAthleteSet, presentAthleteWorkouts, presentExerciseHistory, publishSession, readLive, readSession, removeSession, searchExerciseHistory, sendComment } 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;
|
|
@@ -418,6 +418,41 @@ function registerExerciseTools$1(server, ctx, userId) {
|
|
|
418
418
|
annotations: READ
|
|
419
419
|
}, ({ exerciseId, date }) => attempt(async () => jsonResult(await fetchExerciseStats(ctx.client, toId(exerciseId), await userId(), date))));
|
|
420
420
|
}
|
|
421
|
+
/** Create a personal workout session and add exercises to it. */
|
|
422
|
+
function registerSessionTools(server, ctx) {
|
|
423
|
+
server.registerTool("athlete_session_create", {
|
|
424
|
+
title: "Create personal workout session",
|
|
425
|
+
description: "Create a new personal workout session for a given YYYY-MM-DD date on the athlete's personal calendar. Returns programWorkoutId, workoutId (pass to athlete_session_add_exercises), savedWorkoutId, groupId, and date.",
|
|
426
|
+
inputSchema: { date: dateString },
|
|
427
|
+
annotations: {
|
|
428
|
+
readOnlyHint: false,
|
|
429
|
+
destructiveHint: false,
|
|
430
|
+
openWorldHint: true
|
|
431
|
+
}
|
|
432
|
+
}, ({ date }) => attempt(async () => jsonResult(await createPersonalWorkout(ctx.client, date))));
|
|
433
|
+
server.registerTool("athlete_session_add_exercises", {
|
|
434
|
+
title: "Add exercises to a personal workout session",
|
|
435
|
+
description: "Add one or more exercises to a personal workout session. Get workoutId from athlete_session_create. Each item needs an exerciseId (from athlete_exercises) and a 1-based order. Returns saved workout set objects: each top-level id is a savedWorkoutSetId and savedWorkoutSetExercises[].id is a savedWorkoutSetExerciseId — both needed for athlete_log_set.",
|
|
436
|
+
inputSchema: {
|
|
437
|
+
workoutId: idParam,
|
|
438
|
+
exercises: z.array(z.object({
|
|
439
|
+
exerciseId: idParam,
|
|
440
|
+
order: z.number().int().positive()
|
|
441
|
+
})).min(1)
|
|
442
|
+
},
|
|
443
|
+
annotations: {
|
|
444
|
+
readOnlyHint: false,
|
|
445
|
+
destructiveHint: false,
|
|
446
|
+
openWorldHint: true
|
|
447
|
+
}
|
|
448
|
+
}, ({ workoutId, exercises }) => attempt(async () => {
|
|
449
|
+
const mapped = exercises.map((e) => ({
|
|
450
|
+
exerciseId: toId(e.exerciseId),
|
|
451
|
+
order: e.order
|
|
452
|
+
}));
|
|
453
|
+
return jsonResult(await addExercisesToWorkout(ctx.client, toId(workoutId), mapped), { hint: "Each top-level id is a savedWorkoutSetId; savedWorkoutSetExercises[].id is the savedWorkoutSetExerciseId for athlete_log_set." });
|
|
454
|
+
}));
|
|
455
|
+
}
|
|
421
456
|
/** The gated set-logging write. */
|
|
422
457
|
function registerLogTool(server, ctx) {
|
|
423
458
|
server.registerTool("athlete_log_set", {
|
|
@@ -468,6 +503,7 @@ function registerAthleteTrainingTools(server, ctx) {
|
|
|
468
503
|
};
|
|
469
504
|
registerProfileTools(server, ctx, whoami, userId);
|
|
470
505
|
registerExerciseTools$1(server, ctx, userId);
|
|
506
|
+
registerSessionTools(server, ctx);
|
|
471
507
|
registerLogTool(server, ctx);
|
|
472
508
|
}
|
|
473
509
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trainheroic-unofficial/core",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
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": "0.4.
|
|
29
|
-
"@trainheroic-unofficial/js": "0.4.
|
|
28
|
+
"@trainheroic-unofficial/dto": "0.4.1",
|
|
29
|
+
"@trainheroic-unofficial/js": "0.4.1"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/node": "^26.0.0",
|