@trainheroic-unofficial/core 0.4.0 → 0.4.2

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 CHANGED
@@ -59,6 +59,17 @@ declare const NOT_CONFIRMED = "Not confirmed. Re-run with confirm:true, or conne
59
59
  */
60
60
  declare function confirmGate(server: McpServer, requestId: string | number | undefined, message: string, confirmArg: boolean | undefined): Promise<boolean>;
61
61
  //#endregion
62
+ //#region src/instructions.d.ts
63
+ /**
64
+ * Server-level guidance passed as the MCP `instructions` string. The host model receives it
65
+ * in the initialize result and treats it like a system hint. Its job is to stop tool-layer
66
+ * implementation details from leaking into user-facing replies: by default a model narrates
67
+ * capability using the raw snake_case tool name (e.g. `athlete_session_create`), and the tool
68
+ * descriptions here reference each other by name to drive correct chaining, which primes that
69
+ * leak further. This tells the host to keep that wiring internal and speak in app terms.
70
+ */
71
+ declare const SERVER_INSTRUCTIONS: string;
72
+ //#endregion
62
73
  //#region src/tools/reads.d.ts
63
74
  /** Read-only coach/athlete queries. Exercise lookups live in the exercise store tools. */
64
75
  declare function registerReadTools(server: McpServer, ctx: ToolContext): void;
@@ -116,4 +127,4 @@ declare function registerWorkoutTools(server: McpServer, ctx: ToolContext): void
116
127
  /** Live messaging: list/read conversations, draft a message, and the gated send/delete. */
117
128
  declare function registerMessagingTools(server: McpServer, ctx: ToolContext): void;
118
129
  //#endregion
119
- export { AthleteContext, BudgetHint, DEFAULT_RESULT_BUDGET, DESTRUCTIVE, NOT_CONFIRMED, READ, SYNC, ToolContext, apiCall, attempt, boundedSerialize, confirmGate, errorResult, idParam, jsonResult, registerAnalyticsTools, registerAthleteTools, registerAthleteTrainingTools, registerExerciseTools, registerMessagingTools, registerReadTools, registerTeamTools, registerWorkoutTools, resultBudget, toId };
130
+ export { AthleteContext, BudgetHint, DEFAULT_RESULT_BUDGET, DESTRUCTIVE, NOT_CONFIRMED, READ, SERVER_INSTRUCTIONS, SYNC, ToolContext, apiCall, attempt, boundedSerialize, confirmGate, errorResult, idParam, jsonResult, registerAnalyticsTools, registerAthleteTools, registerAthleteTrainingTools, registerExerciseTools, registerMessagingTools, registerReadTools, registerTeamTools, registerWorkoutTools, resultBudget, toId };
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;
@@ -188,6 +188,17 @@ async function confirmGate(server, requestId, message, confirmArg) {
188
188
  }
189
189
  }
190
190
  //#endregion
191
+ //#region src/instructions.ts
192
+ /**
193
+ * Server-level guidance passed as the MCP `instructions` string. The host model receives it
194
+ * in the initialize result and treats it like a system hint. Its job is to stop tool-layer
195
+ * implementation details from leaking into user-facing replies: by default a model narrates
196
+ * capability using the raw snake_case tool name (e.g. `athlete_session_create`), and the tool
197
+ * descriptions here reference each other by name to drive correct chaining, which primes that
198
+ * leak further. This tells the host to keep that wiring internal and speak in app terms.
199
+ */
200
+ const SERVER_INSTRUCTIONS = "Speak to the user in plain, everyday language about their training. Describe what you are doing in the TrainHeroic app's own terms (for example, say you are creating a workout rather than naming a tool). Do not surface internal tool names (the snake_case identifiers such as athlete_session_create), raw parameter names, or numeric ids in your replies unless the user explicitly asks for them; they are implementation details. The tool descriptions cross-reference each other by name only so you can chain them correctly. Keep that wiring to yourself.";
201
+ //#endregion
191
202
  //#region src/tools/reads.ts
192
203
  function enc(value) {
193
204
  return encodeURIComponent(String(value));
@@ -418,6 +429,41 @@ function registerExerciseTools$1(server, ctx, userId) {
418
429
  annotations: READ
419
430
  }, ({ exerciseId, date }) => attempt(async () => jsonResult(await fetchExerciseStats(ctx.client, toId(exerciseId), await userId(), date))));
420
431
  }
432
+ /** Create a personal workout session and add exercises to it. */
433
+ function registerSessionTools(server, ctx) {
434
+ server.registerTool("athlete_session_create", {
435
+ title: "Create personal workout session",
436
+ 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.",
437
+ inputSchema: { date: dateString },
438
+ annotations: {
439
+ readOnlyHint: false,
440
+ destructiveHint: false,
441
+ openWorldHint: true
442
+ }
443
+ }, ({ date }) => attempt(async () => jsonResult(await createPersonalWorkout(ctx.client, date))));
444
+ server.registerTool("athlete_session_add_exercises", {
445
+ title: "Add exercises to a personal workout session",
446
+ 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.",
447
+ inputSchema: {
448
+ workoutId: idParam,
449
+ exercises: z.array(z.object({
450
+ exerciseId: idParam,
451
+ order: z.number().int().positive()
452
+ })).min(1)
453
+ },
454
+ annotations: {
455
+ readOnlyHint: false,
456
+ destructiveHint: false,
457
+ openWorldHint: true
458
+ }
459
+ }, ({ workoutId, exercises }) => attempt(async () => {
460
+ const mapped = exercises.map((e) => ({
461
+ exerciseId: toId(e.exerciseId),
462
+ order: e.order
463
+ }));
464
+ 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." });
465
+ }));
466
+ }
421
467
  /** The gated set-logging write. */
422
468
  function registerLogTool(server, ctx) {
423
469
  server.registerTool("athlete_log_set", {
@@ -468,6 +514,7 @@ function registerAthleteTrainingTools(server, ctx) {
468
514
  };
469
515
  registerProfileTools(server, ctx, whoami, userId);
470
516
  registerExerciseTools$1(server, ctx, userId);
517
+ registerSessionTools(server, ctx);
471
518
  registerLogTool(server, ctx);
472
519
  }
473
520
  //#endregion
@@ -1051,4 +1098,4 @@ function registerMessagingTools(server, ctx) {
1051
1098
  registerWrites(server, ctx);
1052
1099
  }
1053
1100
  //#endregion
1054
- export { DEFAULT_RESULT_BUDGET, DESTRUCTIVE, NOT_CONFIRMED, READ, SYNC, apiCall, attempt, boundedSerialize, confirmGate, errorResult, idParam, jsonResult, registerAnalyticsTools, registerAthleteTools, registerAthleteTrainingTools, registerExerciseTools, registerMessagingTools, registerReadTools, registerTeamTools, registerWorkoutTools, resultBudget, toId };
1101
+ export { DEFAULT_RESULT_BUDGET, DESTRUCTIVE, NOT_CONFIRMED, READ, SERVER_INSTRUCTIONS, SYNC, apiCall, attempt, boundedSerialize, confirmGate, errorResult, idParam, jsonResult, registerAnalyticsTools, registerAthleteTools, registerAthleteTrainingTools, registerExerciseTools, registerMessagingTools, registerReadTools, registerTeamTools, registerWorkoutTools, resultBudget, toId };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trainheroic-unofficial/core",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
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.0",
29
- "@trainheroic-unofficial/js": "0.4.0"
28
+ "@trainheroic-unofficial/dto": "0.4.2",
29
+ "@trainheroic-unofficial/js": "0.4.2"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@types/node": "^26.0.0",