@trainheroic-unofficial/core 3.7.1 → 3.7.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 +3 -3
- package/dist/index.mjs +14 -4
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -98,9 +98,9 @@ export declare const NOT_CONFIRMED = "Not confirmed — the user declined. Nothi
|
|
|
98
98
|
* confirmation message ever needs data fetched first, that fetch must be idempotent.
|
|
99
99
|
*
|
|
100
100
|
* Written once in the 2026 `inputRequired` style: modern clients retry with `inputResponses`.
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
* the
|
|
101
|
+
* MCP correctly rejects unsupported embedded requests with `-32021`. This application has an
|
|
102
|
+
* alternate `confirm: true` flow, so a modern client that does not declare form elicitation gets
|
|
103
|
+
* a model-readable tool error that tells it how to recover while the gate remains closed.
|
|
104
104
|
*/
|
|
105
105
|
export declare function confirmGate(ctx: ServerContext, message: string, confirmArg: boolean | undefined): ToolHandlerResult | undefined;
|
|
106
106
|
//#endregion
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { athleteExerciseCatalogOutputSchema, athleteExerciseNoteArgsSchema, athleteExerciseNoteOutputSchema, athleteInviteOutputSchema, athleteMainLiftPrsOutputSchema, athletePrefsSchema, athletePrescribeSetArgsSchema, athleteProfileOutputSchema, athleteSessionRemoveArgsSchema, athleteSessionRemovedOutputSchema, athleteWorkingMaxListSchema, athleteWorkoutNoteArgsSchema, athleteWorkoutNoteObject, athleteWorkoutNoteOutputSchema, athleteWorkoutsOutputSchema, blockSpecSchema, coachAthleteTrainingOutputSchema, coachLogSessionArgsSchema, coachLogSetArgsSchema, coachPrescribeSetArgsSchema, commentDraftSchema, dateString, exerciseCreateSchema, exerciseCreatedOutputSchema, exerciseDeletedOutputSchema, exerciseForgottenOutputSchema, exerciseGetOutputSchema, exerciseHistoryOutputSchema, exerciseResolveOutputSchema, exerciseStatsSchema, exerciseSwapOutputSchema, exerciseUpdateSchema, exerciseViewSchema, idArgSchema, logSessionArgsSchema, logSetArgsSchema, logTargetsOutputSchema, messageDeletedOutputSchema, messageDraftOutputSchema, messageSentOutputSchema, opaqueOutputSchema, parseWorkoutDate, personalRecordListSchema, personalWorkoutCreatedOutputSchema, programCreatedOutputSchema, programDeletedOutputSchema, removedSessionOutputSchema, rosterActivityOutputSchema, sessionLogOutputSchema, sessionTemplateCreateSchema, sessionTemplateCreatedOutputSchema, setLogOutputSchema, setPrescriptionOutputSchema, swapAthleteExerciseArgsSchema, teamPublishPatchObject, teamPublishPatchSchema, teamVolumeOutputSchema, toolOutputSchema, userSimpleSchema, workoutBuildOutputSchema, workoutPublishOutputSchema, workoutReadOutputSchema } from "@trainheroic-unofficial/dto";
|
|
2
|
-
import { acceptedContent, inputRequired, inputResponse } from "@modelcontextprotocol/server";
|
|
2
|
+
import { CLIENT_CAPABILITIES_META_KEY, acceptedContent, inputRequired, inputResponse } from "@modelcontextprotocol/server";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { ANALYTICS_METRIC_KEYS, PROGRAM_KINDS, SESSION_TEMPLATES_LIST_PATH, addExercisesToWorkout, buildCommentPayload, buildSession, coerceInt, collectAdvisories, copySession, createPersonalWorkout, createProgram, createSessionTemplate, definedProps, deleteComment, deleteProgram, exerciseUnits, fetchAthleteCircuits, fetchAthleteMainLiftPRs, fetchAthletePrefs, fetchAthleteProfileSummary, fetchAthleteProgrammingPrograms, fetchAthleteUser, fetchAthleteWorkouts, fetchCoachAthleteCalendarSummary, fetchCoachAthleteWorkouts, fetchExerciseHistoryDetail, fetchExerciseHistoryList, fetchExerciseStats, fetchLeaderboard, fetchPersonalRecords, fetchRecentExercises, fetchRosterActivity, fetchRosterMainLiftPRs, fetchStreams, fetchTeamAthleteIds, fetchWorkingMaxes, historyInRange, inviteAthletes, isRecord, logAdHocSession, logAthleteSet, logForAthlete, logSessionForAthlete, prescribeAthleteSet, prescribeForAthlete, presentAthleteWorkouts, presentCoachAthleteTraining, presentExerciseHistory, presentLogTargets, publishSession, queryAnalytics, readLive, readSession, removePersonalWorkout, removeSession, resolveBuildProgramId, searchExerciseHistory, selectWorkouts, selectWorkoutsByProgram, sendComment, setAthleteExerciseNote, setAthleteWorkoutNote, setSplitSummary, summarizeAthleteWorkouts, swapAthleteExercise, teamPublishTarget, teamVolume, toSetResults, updateTeam, updateTeamPublishSettings } from "@trainheroic-unofficial/js";
|
|
5
5
|
//#region src/context.ts
|
|
@@ -226,6 +226,15 @@ async function apiCall(ctx, method, path, options, hint) {
|
|
|
226
226
|
const NOT_CONFIRMED = "Not confirmed — the user declined. Nothing was changed.";
|
|
227
227
|
/** Appended to the prompt so the fallback survives whichever way a client surfaces the request. */
|
|
228
228
|
const FALLBACK_HINT = " (If you cannot show this prompt, re-run the tool with confirm:true once the user has agreed.)";
|
|
229
|
+
const CONFIRMATION_REQUIRED = "Ask the user to approve this action, then retry the tool with confirm:true only after they agree. Nothing was changed.";
|
|
230
|
+
/** `undefined` means a legacy request, whose capability check belongs to the SDK's shim. */
|
|
231
|
+
function modernClientSupportsFormElicitation(ctx) {
|
|
232
|
+
const envelope = ctx.mcpReq.envelope;
|
|
233
|
+
if (envelope === void 0) return void 0;
|
|
234
|
+
const elicitation = envelope[CLIENT_CAPABILITIES_META_KEY]?.elicitation;
|
|
235
|
+
if (elicitation === void 0) return false;
|
|
236
|
+
return elicitation.form !== void 0 || elicitation.url === void 0;
|
|
237
|
+
}
|
|
229
238
|
/**
|
|
230
239
|
* Confirm a destructive/athlete-facing action.
|
|
231
240
|
*
|
|
@@ -241,14 +250,15 @@ const FALLBACK_HINT = " (If you cannot show this prompt, re-run the tool with co
|
|
|
241
250
|
* confirmation message ever needs data fetched first, that fetch must be idempotent.
|
|
242
251
|
*
|
|
243
252
|
* Written once in the 2026 `inputRequired` style: modern clients retry with `inputResponses`.
|
|
244
|
-
*
|
|
245
|
-
*
|
|
246
|
-
* the
|
|
253
|
+
* MCP correctly rejects unsupported embedded requests with `-32021`. This application has an
|
|
254
|
+
* alternate `confirm: true` flow, so a modern client that does not declare form elicitation gets
|
|
255
|
+
* a model-readable tool error that tells it how to recover while the gate remains closed.
|
|
247
256
|
*/
|
|
248
257
|
function confirmGate(ctx, message, confirmArg) {
|
|
249
258
|
if (confirmArg === true) return void 0;
|
|
250
259
|
if (acceptedContent(ctx.mcpReq.inputResponses, "confirm")?.confirm === true) return void 0;
|
|
251
260
|
if (inputResponse(ctx.mcpReq.inputResponses, "confirm").kind !== "missing") return errorResult(NOT_CONFIRMED);
|
|
261
|
+
if (modernClientSupportsFormElicitation(ctx) === false) return errorResult(`${message} ${CONFIRMATION_REQUIRED}`);
|
|
252
262
|
const prompt = message + FALLBACK_HINT;
|
|
253
263
|
return inputRequired({ inputRequests: { confirm: inputRequired.elicit({
|
|
254
264
|
message: prompt,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trainheroic-unofficial/core",
|
|
3
|
-
"version": "3.7.
|
|
3
|
+
"version": "3.7.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/server": "2.0.0",
|
|
27
27
|
"zod": "^4.6.3",
|
|
28
|
-
"@trainheroic-unofficial/dto": "3.7.
|
|
29
|
-
"@trainheroic-unofficial/js": "3.7.
|
|
28
|
+
"@trainheroic-unofficial/dto": "3.7.2",
|
|
29
|
+
"@trainheroic-unofficial/js": "3.7.2"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/node": "^26.5.1",
|