@trainheroic-unofficial/athlete-mcp 4.1.1 → 4.2.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 +28 -3
  2. package/package.json +3 -3
package/dist/server.mjs CHANGED
@@ -1264,6 +1264,28 @@ var TrainHeroicHttpError = class extends Error {
1264
1264
  this.responseBody = diagnostics.responseBody === void 0 ? void 0 : safeResponseBodyDiagnostics(diagnostics.responseBody);
1265
1265
  }
1266
1266
  };
1267
+ /**
1268
+ * True for statuses that mean TrainHeroic's servers could not be reached or did not answer: a
1269
+ * gateway failure (502, 503, 504) or a Cloudflare edge error (520-530). TrainHeroic sits behind
1270
+ * Cloudflare, so a 522 means the edge timed out connecting to TrainHeroic's origin. These describe
1271
+ * an upstream outage, so the same request can succeed when retried later.
1272
+ */
1273
+ function isTrainHeroicUnavailableStatus(status) {
1274
+ return status === 502 || status === 503 || status === 504 || status >= 520 && status <= 530;
1275
+ }
1276
+ /**
1277
+ * Thrown when TrainHeroic answers with an outage status (see `isTrainHeroicUnavailableStatus`).
1278
+ * The message tells the reader to retry later, so a model relaying it does not ask the user to
1279
+ * re-check credentials that are fine.
1280
+ */
1281
+ var TrainHeroicUnavailableError = class extends Error {
1282
+ name = "TrainHeroicUnavailableError";
1283
+ status;
1284
+ constructor(status) {
1285
+ super(`TrainHeroic is not responding right now (HTTP ${status}). Try again in a few minutes.`);
1286
+ this.status = status;
1287
+ }
1288
+ };
1267
1289
  /** Call observability hooks without allowing them to change SDK behavior. */
1268
1290
  function notifyHttpError(handler, method, url, status, diagnostics = {}) {
1269
1291
  if (!handler) return;
@@ -1291,8 +1313,10 @@ function authUrl() {
1291
1313
  return DEFAULT_AUTH_URL;
1292
1314
  }
1293
1315
  /**
1294
- * Authenticate against TrainHeroic. Returns the session bundle, or null on bad
1295
- * credentials. TrainHeroic returns only { id, scope, role, session_id } (verified in
1316
+ * Authenticate against TrainHeroic. Returns the session bundle, or null when TrainHeroic
1317
+ * rejects the login. Throws `TrainHeroicUnavailableError` when TrainHeroic is unreachable (an
1318
+ * outage status such as a Cloudflare 522), so callers can tell the user to retry later.
1319
+ * TrainHeroic returns only { id, scope, role, session_id } (verified in
1296
1320
  * the Phase 0 spike: no refresh_token, no api_token, no TTL). The 48-char session_id
1297
1321
  * is sent as the `session-token` header and works against both API hosts.
1298
1322
  */
@@ -1312,6 +1336,7 @@ async function loginTrainHeroic(email, password, options = {}) {
1312
1336
  if (!res.ok) {
1313
1337
  await res.body?.cancel().catch(() => {});
1314
1338
  notifyHttpError(options.onHttpError, "POST", url, res.status);
1339
+ if (isTrainHeroicUnavailableStatus(res.status)) throw new TrainHeroicUnavailableError(res.status);
1315
1340
  return null;
1316
1341
  }
1317
1342
  const data = await res.json().catch(() => null);
@@ -3225,7 +3250,7 @@ function registerAthleteTrainingTools(server, ctx) {
3225
3250
  }
3226
3251
  //#endregion
3227
3252
  //#region package.json
3228
- var version = "4.1.1";
3253
+ var version = "4.2.0";
3229
3254
  //#endregion
3230
3255
  //#region src/server.ts
3231
3256
  function main() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trainheroic-unofficial/athlete-mcp",
3
- "version": "4.1.1",
3
+ "version": "4.2.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -21,8 +21,8 @@
21
21
  "dependencies": {
22
22
  "@modelcontextprotocol/server": "2.3.1",
23
23
  "zod": "^4.6.5",
24
- "@trainheroic-unofficial/core": "4.1.1",
25
- "@trainheroic-unofficial/js": "4.1.1"
24
+ "@trainheroic-unofficial/core": "4.2.0",
25
+ "@trainheroic-unofficial/js": "4.2.0"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@types/node": "^26.6.4",