@trainheroic-unofficial/coach-mcp 4.1.0 → 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.
- package/dist/server.mjs +28 -3
- package/package.json +3 -3
package/dist/server.mjs
CHANGED
|
@@ -1321,6 +1321,28 @@ var TrainHeroicHttpError = class extends Error {
|
|
|
1321
1321
|
this.responseBody = diagnostics.responseBody === void 0 ? void 0 : safeResponseBodyDiagnostics(diagnostics.responseBody);
|
|
1322
1322
|
}
|
|
1323
1323
|
};
|
|
1324
|
+
/**
|
|
1325
|
+
* True for statuses that mean TrainHeroic's servers could not be reached or did not answer: a
|
|
1326
|
+
* gateway failure (502, 503, 504) or a Cloudflare edge error (520-530). TrainHeroic sits behind
|
|
1327
|
+
* Cloudflare, so a 522 means the edge timed out connecting to TrainHeroic's origin. These describe
|
|
1328
|
+
* an upstream outage, so the same request can succeed when retried later.
|
|
1329
|
+
*/
|
|
1330
|
+
function isTrainHeroicUnavailableStatus(status) {
|
|
1331
|
+
return status === 502 || status === 503 || status === 504 || status >= 520 && status <= 530;
|
|
1332
|
+
}
|
|
1333
|
+
/**
|
|
1334
|
+
* Thrown when TrainHeroic answers with an outage status (see `isTrainHeroicUnavailableStatus`).
|
|
1335
|
+
* The message tells the reader to retry later, so a model relaying it does not ask the user to
|
|
1336
|
+
* re-check credentials that are fine.
|
|
1337
|
+
*/
|
|
1338
|
+
var TrainHeroicUnavailableError = class extends Error {
|
|
1339
|
+
name = "TrainHeroicUnavailableError";
|
|
1340
|
+
status;
|
|
1341
|
+
constructor(status) {
|
|
1342
|
+
super(`TrainHeroic is not responding right now (HTTP ${status}). Try again in a few minutes.`);
|
|
1343
|
+
this.status = status;
|
|
1344
|
+
}
|
|
1345
|
+
};
|
|
1324
1346
|
/** Call observability hooks without allowing them to change SDK behavior. */
|
|
1325
1347
|
function notifyHttpError(handler, method, url, status, diagnostics = {}) {
|
|
1326
1348
|
if (!handler) return;
|
|
@@ -1348,8 +1370,10 @@ function authUrl() {
|
|
|
1348
1370
|
return DEFAULT_AUTH_URL;
|
|
1349
1371
|
}
|
|
1350
1372
|
/**
|
|
1351
|
-
* Authenticate against TrainHeroic. Returns the session bundle, or null
|
|
1352
|
-
*
|
|
1373
|
+
* Authenticate against TrainHeroic. Returns the session bundle, or null when TrainHeroic
|
|
1374
|
+
* rejects the login. Throws `TrainHeroicUnavailableError` when TrainHeroic is unreachable (an
|
|
1375
|
+
* outage status such as a Cloudflare 522), so callers can tell the user to retry later.
|
|
1376
|
+
* TrainHeroic returns only { id, scope, role, session_id } (verified in
|
|
1353
1377
|
* the Phase 0 spike: no refresh_token, no api_token, no TTL). The 48-char session_id
|
|
1354
1378
|
* is sent as the `session-token` header and works against both API hosts.
|
|
1355
1379
|
*/
|
|
@@ -1369,6 +1393,7 @@ async function loginTrainHeroic(email, password, options = {}) {
|
|
|
1369
1393
|
if (!res.ok) {
|
|
1370
1394
|
await res.body?.cancel().catch(() => {});
|
|
1371
1395
|
notifyHttpError(options.onHttpError, "POST", url, res.status);
|
|
1396
|
+
if (isTrainHeroicUnavailableStatus(res.status)) throw new TrainHeroicUnavailableError(res.status);
|
|
1372
1397
|
return null;
|
|
1373
1398
|
}
|
|
1374
1399
|
const data = await res.json().catch(() => null);
|
|
@@ -5299,7 +5324,7 @@ var JsonFileLibraryCache = class {
|
|
|
5299
5324
|
};
|
|
5300
5325
|
//#endregion
|
|
5301
5326
|
//#region package.json
|
|
5302
|
-
var version = "4.
|
|
5327
|
+
var version = "4.2.0";
|
|
5303
5328
|
//#endregion
|
|
5304
5329
|
//#region src/server.ts
|
|
5305
5330
|
function main() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trainheroic-unofficial/coach-mcp",
|
|
3
|
-
"version": "4.
|
|
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.
|
|
25
|
-
"@trainheroic-unofficial/js": "4.
|
|
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",
|