@chrischall/warapp-mcp 0.3.1 → 0.4.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/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/dist/bundle.js +417 -55
- package/dist/direct/transport.js +153 -11
- package/dist/protocol/bundle.js +263 -18
- package/dist/protocol/rpc.js +18 -1
- package/dist/tools/begin-turn.js +3 -5
- package/dist/tools/check-plan.js +3 -1
- package/dist/tools/healthcheck.js +64 -8
- package/dist/tools/index.js +2 -1
- package/dist/tools/live-context.js +71 -6
- package/dist/tools/session.js +20 -4
- package/dist/tools/turn.js +9 -1
- package/dist/version.js +1 -1
- package/manifest.json +1 -1
- package/package.json +1 -1
- package/server.json +2 -2
package/dist/bundle.js
CHANGED
|
@@ -117350,6 +117350,25 @@ var WarappBundle = class {
|
|
|
117350
117350
|
interp;
|
|
117351
117351
|
/** Loaded from the cache because the current version could not be looked up. */
|
|
117352
117352
|
fallback = false;
|
|
117353
|
+
/** Set when this is the pinned known-good client standing in for a refused current one. */
|
|
117354
|
+
standInFor;
|
|
117355
|
+
/** Set while this build stands in for a refused current client: the window (see {@link StandInWindow}). */
|
|
117356
|
+
standIn;
|
|
117357
|
+
/** The SHA-256 of this build's bytes (set by {@link loadBundle}); a build without one is never recorded. */
|
|
117358
|
+
digest;
|
|
117359
|
+
/** Records this build as one that decoded a live board (set by {@link loadBundle}). */
|
|
117360
|
+
recorder;
|
|
117361
|
+
recorded;
|
|
117362
|
+
/**
|
|
117363
|
+
* A live board decoded with this build, every byte consumed: record it as a build that works, so a
|
|
117364
|
+
* later client this server cannot read is stood in for by it (the owner, 2026-11-17: fall back
|
|
117365
|
+
* gracefully). Once per loaded bundle; never throws.
|
|
117366
|
+
*/
|
|
117367
|
+
markDecoded() {
|
|
117368
|
+
if (this.recorded) return this.recorded.then((r) => r === "recorded" ? "unchanged" : r);
|
|
117369
|
+
this.recorded = this.recorder ? this.recorder().catch(() => "failed") : Promise.resolve("unchanged");
|
|
117370
|
+
return this.recorded;
|
|
117371
|
+
}
|
|
117353
117372
|
/** The built-in reader helpers checked against this bundle's own definitions at load. */
|
|
117354
117373
|
dialectCheck;
|
|
117355
117374
|
/** What this bundle's decoding rests on, for the tools to show (#148). */
|
|
@@ -117358,7 +117377,9 @@ var WarappBundle = class {
|
|
|
117358
117377
|
return {
|
|
117359
117378
|
bundleVersion: this.version,
|
|
117360
117379
|
fallback: this.fallback,
|
|
117361
|
-
helpers: { verified: [...verified], unverified: [...unverified], ...reasons ? { reasons: { ...reasons } } : {} }
|
|
117380
|
+
helpers: { verified: [...verified], unverified: [...unverified], ...reasons ? { reasons: { ...reasons } } : {} },
|
|
117381
|
+
...this.standInFor ? { standInFor: { ...this.standInFor } } : {},
|
|
117382
|
+
...this.standIn ? { standIn: { ...this.standIn } } : {}
|
|
117362
117383
|
};
|
|
117363
117384
|
}
|
|
117364
117385
|
/** Whether a type name is registered in this bundle. */
|
|
@@ -117381,6 +117402,11 @@ var WarappBundle = class {
|
|
|
117381
117402
|
return this.interp.readClass(typeNameOrVar, reader2, budget);
|
|
117382
117403
|
}
|
|
117383
117404
|
};
|
|
117405
|
+
var KNOWN_GOOD_BUNDLE = {
|
|
117406
|
+
version: "639294131571648437",
|
|
117407
|
+
digest: "dec5cf174f6affb9e4c08802534cf8c6c6496eff977847aaf1497535e3371404"
|
|
117408
|
+
};
|
|
117409
|
+
var bundleUrlOf = (version3) => `https://${BUNDLE_HOST}${BUNDLE_PATH}?v=${version3}`;
|
|
117384
117410
|
var BUNDLE_FILE = /^([A-Za-z0-9._-]{1,64})\.([0-9a-f]{64})\.js$/;
|
|
117385
117411
|
var LEGACY_FILE = /^[A-Za-z0-9._-]{1,64}\.js(?:\.sha256)?$/;
|
|
117386
117412
|
var PARTIAL_FILE = /^[A-Za-z0-9._-]{1,64}(?:\.[0-9a-f]{64})?\.js(?:\.sha256)?\.tmp-(\d+)(?:-[0-9a-f]+)?$/;
|
|
@@ -117407,7 +117433,7 @@ async function abandoned(file2, pid) {
|
|
|
117407
117433
|
async function pruneBundles(dir, keep) {
|
|
117408
117434
|
try {
|
|
117409
117435
|
for (const name of await readdir4(dir)) {
|
|
117410
|
-
if (name
|
|
117436
|
+
if (keep.includes(name)) continue;
|
|
117411
117437
|
const partial2 = PARTIAL_FILE.exec(name);
|
|
117412
117438
|
if (!partial2 && !BUNDLE_FILE.test(name) && !LEGACY_FILE.test(name)) continue;
|
|
117413
117439
|
if (partial2 && !await abandoned(join7(dir, name), Number(partial2[1]))) continue;
|
|
@@ -117473,18 +117499,143 @@ async function readVerified(file2, digest) {
|
|
|
117473
117499
|
await rm(file2, { force: true });
|
|
117474
117500
|
return null;
|
|
117475
117501
|
}
|
|
117502
|
+
var isDialectRefusal = (e) => e instanceof BundleError && (e.kind === "dialect-mismatch" || e.kind === "dialect-unverified");
|
|
117503
|
+
async function cacheBundle(dataDir2, dir, name, src) {
|
|
117504
|
+
await ensurePrivateDir(dataDir2);
|
|
117505
|
+
await ensurePrivateDir(dir);
|
|
117506
|
+
await writePrivateAtomic(join7(dir, name), Buffer.from(src, "utf8"));
|
|
117507
|
+
}
|
|
117508
|
+
var KNOWN_GOOD_FILE = "known-good.json";
|
|
117509
|
+
var STAND_IN_FILE = "stand-in.json";
|
|
117510
|
+
var MAX_KNOWN_GOOD = 3;
|
|
117511
|
+
var DIGEST = /^[0-9a-f]{64}$/;
|
|
117512
|
+
var isRecorded = (v) => {
|
|
117513
|
+
if (typeof v !== "object" || v === null) return false;
|
|
117514
|
+
const r = v;
|
|
117515
|
+
return typeof r.version === "string" && SAFE_VERSION.test(r.version) && typeof r.digest === "string" && DIGEST.test(r.digest) && typeof r.verifiedAt === "string";
|
|
117516
|
+
};
|
|
117517
|
+
async function readKnownGood(dir) {
|
|
117518
|
+
let text;
|
|
117519
|
+
try {
|
|
117520
|
+
text = await readFile4(join7(dir, KNOWN_GOOD_FILE), "utf8");
|
|
117521
|
+
} catch (e) {
|
|
117522
|
+
return e.code === "ENOENT" ? [] : "unreadable";
|
|
117523
|
+
}
|
|
117524
|
+
try {
|
|
117525
|
+
const parsed = JSON.parse(text);
|
|
117526
|
+
const builds = parsed?.builds;
|
|
117527
|
+
if (!Array.isArray(builds)) return "unreadable";
|
|
117528
|
+
return builds.filter(isRecorded);
|
|
117529
|
+
} catch {
|
|
117530
|
+
return "unreadable";
|
|
117531
|
+
}
|
|
117532
|
+
}
|
|
117533
|
+
async function recordKnownGood(dataDir2, entry) {
|
|
117534
|
+
if (!isRecorded(entry)) return "failed";
|
|
117535
|
+
const dir = join7(dataDir2, "bundle");
|
|
117536
|
+
const file2 = join7(dir, KNOWN_GOOD_FILE);
|
|
117537
|
+
return withPathLock(file2, async () => {
|
|
117538
|
+
const builds = await readKnownGood(dir);
|
|
117539
|
+
if (builds === "unreadable") return "unreadable";
|
|
117540
|
+
const rest = builds.filter((b) => !(b.version === entry.version && b.digest === entry.digest));
|
|
117541
|
+
const next = [entry, ...rest].slice(0, MAX_KNOWN_GOOD);
|
|
117542
|
+
try {
|
|
117543
|
+
await ensurePrivateDir(dataDir2);
|
|
117544
|
+
await ensurePrivateDir(dir);
|
|
117545
|
+
await writePrivateAtomic(file2, `${JSON.stringify({ builds: next }, null, 2)}
|
|
117546
|
+
`);
|
|
117547
|
+
return "recorded";
|
|
117548
|
+
} catch {
|
|
117549
|
+
return "failed";
|
|
117550
|
+
}
|
|
117551
|
+
});
|
|
117552
|
+
}
|
|
117553
|
+
async function readWindow(dir) {
|
|
117554
|
+
try {
|
|
117555
|
+
const w = JSON.parse(await readFile4(join7(dir, STAND_IN_FILE), "utf8"));
|
|
117556
|
+
if (typeof w.refusedVersion === "string" && typeof w.since === "string" && !Number.isNaN(Date.parse(w.since))) {
|
|
117557
|
+
return { refusedVersion: w.refusedVersion, since: w.since };
|
|
117558
|
+
}
|
|
117559
|
+
} catch {
|
|
117560
|
+
}
|
|
117561
|
+
return void 0;
|
|
117562
|
+
}
|
|
117563
|
+
async function openWindow(dataDir2, dir, refusedVersion, reason, now) {
|
|
117564
|
+
const kept = await readWindow(dir);
|
|
117565
|
+
if (kept?.refusedVersion === refusedVersion) return kept.since;
|
|
117566
|
+
const since = new Date(now).toISOString();
|
|
117567
|
+
try {
|
|
117568
|
+
await ensurePrivateDir(dataDir2);
|
|
117569
|
+
await ensurePrivateDir(dir);
|
|
117570
|
+
await writePrivateAtomic(join7(dir, STAND_IN_FILE), `${JSON.stringify({ refusedVersion, since, reason }, null, 2)}
|
|
117571
|
+
`);
|
|
117572
|
+
} catch {
|
|
117573
|
+
}
|
|
117574
|
+
return since;
|
|
117575
|
+
}
|
|
117576
|
+
async function closeWindow(dir) {
|
|
117577
|
+
await rm(join7(dir, STAND_IN_FILE), { force: true }).catch(() => void 0);
|
|
117578
|
+
}
|
|
117579
|
+
async function loadPinned(opts, dir, kg) {
|
|
117580
|
+
const name = bundleName(kg.version, kg.digest);
|
|
117581
|
+
let src = await readVerified(join7(dir, name), kg.digest);
|
|
117582
|
+
if (src === null) {
|
|
117583
|
+
let fetched;
|
|
117584
|
+
try {
|
|
117585
|
+
fetched = await opts.fetchText(bundleUrlOf(kg.version));
|
|
117586
|
+
} catch {
|
|
117587
|
+
return void 0;
|
|
117588
|
+
}
|
|
117589
|
+
if (sha256(Buffer.from(fetched, "utf8")) !== kg.digest || !looksLikeBundle(fetched)) return void 0;
|
|
117590
|
+
try {
|
|
117591
|
+
await cacheBundle(opts.dataDir, dir, name, fetched);
|
|
117592
|
+
} catch {
|
|
117593
|
+
return void 0;
|
|
117594
|
+
}
|
|
117595
|
+
src = fetched;
|
|
117596
|
+
}
|
|
117597
|
+
try {
|
|
117598
|
+
const bundle = new WarappBundle(src, kg.version, opts.interp);
|
|
117599
|
+
bundle.digest = kg.digest;
|
|
117600
|
+
return { bundle, name };
|
|
117601
|
+
} catch {
|
|
117602
|
+
return void 0;
|
|
117603
|
+
}
|
|
117604
|
+
}
|
|
117605
|
+
function withRecorder(opts, bundle) {
|
|
117606
|
+
const now = opts.now ?? Date.now;
|
|
117607
|
+
bundle.recorder = async () => {
|
|
117608
|
+
if (!bundle.digest) return "unchanged";
|
|
117609
|
+
return recordKnownGood(opts.dataDir, { version: bundle.version, digest: bundle.digest, verifiedAt: new Date(now()).toISOString() });
|
|
117610
|
+
};
|
|
117611
|
+
return bundle;
|
|
117612
|
+
}
|
|
117613
|
+
async function recordedNames(dir) {
|
|
117614
|
+
const builds = await readKnownGood(dir);
|
|
117615
|
+
return builds === "unreadable" ? [] : builds.map((b) => bundleName(b.version, b.digest));
|
|
117616
|
+
}
|
|
117476
117617
|
async function loadBundle(opts) {
|
|
117477
117618
|
const pageUrl = opts.pageUrl ?? DEFAULT_PAGE_URL;
|
|
117478
117619
|
const dir = join7(opts.dataDir, "bundle");
|
|
117620
|
+
const kg = opts.knownGood === void 0 ? KNOWN_GOOD_BUNDLE : opts.knownGood;
|
|
117621
|
+
const now = opts.now ?? Date.now;
|
|
117479
117622
|
let source;
|
|
117480
117623
|
try {
|
|
117481
117624
|
source = discoverBundleUrl(await opts.fetchText(pageUrl), pageUrl);
|
|
117482
117625
|
} catch (e) {
|
|
117483
|
-
const
|
|
117484
|
-
|
|
117485
|
-
|
|
117486
|
-
|
|
117487
|
-
|
|
117626
|
+
for (const c of await cachedNewestFirst(dir)) {
|
|
117627
|
+
const src2 = await readVerified(c.file, c.digest);
|
|
117628
|
+
if (src2 === null) continue;
|
|
117629
|
+
try {
|
|
117630
|
+
const b = new WarappBundle(src2, c.version, opts.interp);
|
|
117631
|
+
b.fallback = true;
|
|
117632
|
+
b.digest = c.digest;
|
|
117633
|
+
return withRecorder(opts, b);
|
|
117634
|
+
} catch (err) {
|
|
117635
|
+
if (!isDialectRefusal(err)) throw err;
|
|
117636
|
+
}
|
|
117637
|
+
}
|
|
117638
|
+
throw e;
|
|
117488
117639
|
}
|
|
117489
117640
|
const { url: url4, version: version3 } = source;
|
|
117490
117641
|
const cached3 = await newestVerified(dir, version3);
|
|
@@ -117497,17 +117648,39 @@ async function loadBundle(opts) {
|
|
|
117497
117648
|
if (!looksLikeBundle(src)) {
|
|
117498
117649
|
throw new BundleError("bad-bundle", `${url4} does not look like the war.app client bundle`);
|
|
117499
117650
|
}
|
|
117500
|
-
|
|
117501
|
-
await
|
|
117502
|
-
const bytes = Buffer.from(src, "utf8");
|
|
117503
|
-
name = bundleName(version3, sha256(bytes));
|
|
117504
|
-
await writePrivateAtomic(join7(dir, name), bytes);
|
|
117651
|
+
name = bundleName(version3, sha256(Buffer.from(src, "utf8")));
|
|
117652
|
+
await cacheBundle(opts.dataDir, dir, name, src);
|
|
117505
117653
|
}
|
|
117506
|
-
const
|
|
117507
|
-
await
|
|
117508
|
-
|
|
117654
|
+
const keepKnownGood = kg ? [bundleName(kg.version, kg.digest)] : [];
|
|
117655
|
+
const keepRecorded = await recordedNames(dir);
|
|
117656
|
+
let bundle;
|
|
117657
|
+
try {
|
|
117658
|
+
bundle = new WarappBundle(src, version3, opts.interp);
|
|
117659
|
+
} catch (e) {
|
|
117660
|
+
if (!isDialectRefusal(e)) throw e;
|
|
117661
|
+
const recorded = await readKnownGood(dir);
|
|
117662
|
+
const candidates = [
|
|
117663
|
+
...recorded === "unreadable" ? [] : recorded.map(({ version: v, digest }) => ({ version: v, digest })),
|
|
117664
|
+
...kg ? [kg] : []
|
|
117665
|
+
].filter((c, i2, all2) => c.version !== version3 && all2.findIndex((o) => o.version === c.version && o.digest === c.digest) === i2);
|
|
117666
|
+
for (const c of candidates) {
|
|
117667
|
+
const standIn = await loadPinned(opts, dir, c);
|
|
117668
|
+
if (!standIn) continue;
|
|
117669
|
+
const since = await openWindow(opts.dataDir, dir, version3, e.message, now());
|
|
117670
|
+
standIn.bundle.standInFor = { version: version3, reason: e.message };
|
|
117671
|
+
standIn.bundle.standIn = { version: c.version, refusedVersion: version3, since, reason: e.message };
|
|
117672
|
+
await pruneBundles(dir, [name, standIn.name, ...keepKnownGood, ...keepRecorded]);
|
|
117673
|
+
return withRecorder(opts, standIn.bundle);
|
|
117674
|
+
}
|
|
117675
|
+
throw e;
|
|
117676
|
+
}
|
|
117677
|
+
bundle.digest = name.slice(version3.length + 1, -".js".length);
|
|
117678
|
+
await closeWindow(dir);
|
|
117679
|
+
await pruneBundles(dir, [name, ...keepKnownGood, ...keepRecorded]);
|
|
117680
|
+
return withRecorder(opts, bundle);
|
|
117509
117681
|
}
|
|
117510
117682
|
var FALLBACK_RETRY_MS = 5 * 6e4;
|
|
117683
|
+
var STAND_IN_RETRY_MS = 60 * 6e4;
|
|
117511
117684
|
var BundleProvider = class {
|
|
117512
117685
|
constructor(opts) {
|
|
117513
117686
|
this.opts = opts;
|
|
@@ -117524,11 +117697,13 @@ var BundleProvider = class {
|
|
|
117524
117697
|
this.pending = p;
|
|
117525
117698
|
p.then(
|
|
117526
117699
|
(b) => {
|
|
117527
|
-
if (
|
|
117700
|
+
if (this.pending !== p) return;
|
|
117701
|
+
if (b.standInFor) this.fallbackUntil = now() + STAND_IN_RETRY_MS;
|
|
117702
|
+
else if (b.fallback) this.fallbackUntil = now() + FALLBACK_RETRY_MS;
|
|
117528
117703
|
},
|
|
117529
117704
|
(e) => {
|
|
117530
117705
|
if (this.pending !== p) return;
|
|
117531
|
-
if (
|
|
117706
|
+
if (isDialectRefusal(e)) {
|
|
117532
117707
|
this.fallbackUntil = now() + FALLBACK_RETRY_MS;
|
|
117533
117708
|
} else this.pending = null;
|
|
117534
117709
|
}
|
|
@@ -117550,6 +117725,8 @@ function methodTakesAuth(methodId) {
|
|
|
117550
117725
|
return !NO_AUTH_METHODS.has(methodId);
|
|
117551
117726
|
}
|
|
117552
117727
|
var SERVER_ERROR_MESSAGES = {
|
|
117728
|
+
// AuthFailed (live 2026-11-17): war.app's answer when the request's session is not signed in.
|
|
117729
|
+
3: "war.app refused the request as not signed in (AuthFailed): the war.app session this server uses is signed out.",
|
|
117553
117730
|
10: "war.app refused the order sequence \u2014 card plays must come in turn-phase order.",
|
|
117554
117731
|
11: "Your orders deploy more or fewer armies than you are receiving this turn. Please verify your orders deploy the correct number.",
|
|
117555
117732
|
51: "You hold more cards than this game allows, so war.app requires you to play or discard one this turn.",
|
|
@@ -117563,6 +117740,17 @@ var SERVER_ERROR_MESSAGES = {
|
|
|
117563
117740
|
750: "Sorry, the slot you joined is no longer available. Please try again with a different slot."
|
|
117564
117741
|
};
|
|
117565
117742
|
var MAX_SERVER_MESSAGE = 200;
|
|
117743
|
+
var ProtocolVersionError = class extends McpToolError {
|
|
117744
|
+
constructor(methodName, answered) {
|
|
117745
|
+
super(`war.app answered ${methodName} in protocol version ${answered}; this server reads version ${PROTOCOL_VERSION}.`, {
|
|
117746
|
+
kind: "unknown",
|
|
117747
|
+
hint: "The war.app client may have changed; this server needs an update to read it."
|
|
117748
|
+
});
|
|
117749
|
+
this.answered = answered;
|
|
117750
|
+
}
|
|
117751
|
+
answered;
|
|
117752
|
+
name = "ProtocolVersionError";
|
|
117753
|
+
};
|
|
117566
117754
|
var WarappServerError = class extends McpToolError {
|
|
117567
117755
|
constructor(code2, message) {
|
|
117568
117756
|
super(message, { kind: "unknown" });
|
|
@@ -117644,10 +117832,7 @@ var WarappRpc = class {
|
|
|
117644
117832
|
);
|
|
117645
117833
|
}
|
|
117646
117834
|
if (env.version !== PROTOCOL_VERSION) {
|
|
117647
|
-
throw new
|
|
117648
|
-
`war.app answered ${methodName} in protocol version ${env.version}; this server reads version ${PROTOCOL_VERSION}.`,
|
|
117649
|
-
{ kind: "unknown", hint: "The war.app client may have changed; this server needs an update to read it." }
|
|
117650
|
-
);
|
|
117835
|
+
throw new ProtocolVersionError(methodName, env.version);
|
|
117651
117836
|
}
|
|
117652
117837
|
if (env.method !== methodId) {
|
|
117653
117838
|
throw new McpToolError(`war.app answered ${methodName} (method ${methodId}) with method ${env.method}.`, {
|
|
@@ -124776,7 +124961,7 @@ async function captureBearerHeader(opts) {
|
|
|
124776
124961
|
}
|
|
124777
124962
|
|
|
124778
124963
|
// src/version.ts
|
|
124779
|
-
var VERSION2 = "0.
|
|
124964
|
+
var VERSION2 = "0.4.0";
|
|
124780
124965
|
|
|
124781
124966
|
// src/transport-bridge.ts
|
|
124782
124967
|
var SERVER_NAME = "warapp-mcp";
|
|
@@ -125168,15 +125353,52 @@ function beginFirstError(game) {
|
|
|
125168
125353
|
async function loadLiveTerritories(ctx, game) {
|
|
125169
125354
|
return (await loadLiveGame(ctx, game)).territories;
|
|
125170
125355
|
}
|
|
125356
|
+
var PROTOCOL_UPDATE_ISSUE = "https://github.com/chrischall/warapp-mcp/issues/340";
|
|
125357
|
+
function standInLine(w) {
|
|
125358
|
+
if (!w) return void 0;
|
|
125359
|
+
return `war.app ships a client this server cannot read yet (${w.refusedVersion}), so the client build ${w.version}, which war.app still answers, stands in and decodes the board (since ${w.since}). Boards still decode exactly; war.app may stop answering the old build at any time, and this server then needs its update (#340, ${PROTOCOL_UPDATE_ISSUE}).`;
|
|
125360
|
+
}
|
|
125361
|
+
function standInOf(ctx) {
|
|
125362
|
+
return ctx.decoderReport()?.standIn;
|
|
125363
|
+
}
|
|
125364
|
+
var StandInClosedError = class extends McpToolError {
|
|
125365
|
+
constructor(window, cause) {
|
|
125366
|
+
const why = cause instanceof Error ? cause.message : String(cause);
|
|
125367
|
+
super(
|
|
125368
|
+
`war.app no longer answers the client build ${window.version} this server has decoded with since ${window.since} (standing in for ${window.refusedVersion}, which this server cannot read yet): ${why} Nothing was decoded; the old client is no longer accepted, so this server needs the protocol update (#340).`,
|
|
125369
|
+
{
|
|
125370
|
+
kind: "unknown",
|
|
125371
|
+
hint: `The old client is no longer accepted: this server needs the protocol update (${PROTOCOL_UPDATE_ISSUE}). Play in the war.app web client until then.`,
|
|
125372
|
+
cause
|
|
125373
|
+
}
|
|
125374
|
+
);
|
|
125375
|
+
this.window = window;
|
|
125376
|
+
}
|
|
125377
|
+
window;
|
|
125378
|
+
name = "StandInClosedError";
|
|
125379
|
+
};
|
|
125380
|
+
var isLayoutFailure = (e) => e instanceof ProtocolVersionError || e instanceof LiveBoardFormatError || e instanceof ProtocolError3 || e instanceof InterpError;
|
|
125381
|
+
async function windowClosed(ctx, bundle, e) {
|
|
125382
|
+
if (!isLayoutFailure(e)) return e;
|
|
125383
|
+
const b = bundle ?? await ctx.bundle().catch(() => void 0);
|
|
125384
|
+
const w = b?.report?.().standIn;
|
|
125385
|
+
return w ? new StandInClosedError(w, e) : e;
|
|
125386
|
+
}
|
|
125387
|
+
async function readLatestBoard(ctx, gameId) {
|
|
125388
|
+
let bundle;
|
|
125389
|
+
try {
|
|
125390
|
+
const env = await ctx.rpc.call("GetLatestGameInfo", Method.GetLatestGameInfo, (w) => writeGetLatestGameInfoParams(w, gameId));
|
|
125391
|
+
bundle = await ctx.bundle();
|
|
125392
|
+
const info = readLatestGameInfo(bundle, env.body);
|
|
125393
|
+
const territories = standingFromInfo(info);
|
|
125394
|
+
if (territories) await bundle.markDecoded?.();
|
|
125395
|
+
return { info, territories };
|
|
125396
|
+
} catch (e) {
|
|
125397
|
+
throw await windowClosed(ctx, bundle, e);
|
|
125398
|
+
}
|
|
125399
|
+
}
|
|
125171
125400
|
async function loadLiveGame(ctx, game) {
|
|
125172
|
-
const
|
|
125173
|
-
"GetLatestGameInfo",
|
|
125174
|
-
Method.GetLatestGameInfo,
|
|
125175
|
-
(w) => writeGetLatestGameInfoParams(w, game.id)
|
|
125176
|
-
);
|
|
125177
|
-
const bundle = await ctx.bundle();
|
|
125178
|
-
const info = readLatestGameInfo(bundle, env.body);
|
|
125179
|
-
const territories = standingFromInfo(info);
|
|
125401
|
+
const { info, territories } = await readLatestBoard(ctx, game.id);
|
|
125180
125402
|
if (!territories) {
|
|
125181
125403
|
if (awaitsBegin(game)) throw beginFirstError(game);
|
|
125182
125404
|
throw new McpToolError(`war.app has no board for game ${game.id} yet (game state: ${game.state}).`, {
|
|
@@ -125526,6 +125748,45 @@ function looksSignedOut(requestedUrl, res) {
|
|
|
125526
125748
|
if (/\/services\b/i.test(reqPath) && !looksLikeHexFrame(res.body)) return true;
|
|
125527
125749
|
return false;
|
|
125528
125750
|
}
|
|
125751
|
+
var SIGNED_IN_PROBE_URL = `${SESSION_ORIGIN}/InviteToken`;
|
|
125752
|
+
var AUTH_FAILED_CODE = 3;
|
|
125753
|
+
var INVITE_TOKEN_TEXT = /Your invite token is\s*\d{5,20}/;
|
|
125754
|
+
function signInVerdict(res) {
|
|
125755
|
+
let path = "";
|
|
125756
|
+
try {
|
|
125757
|
+
path = new URL(res.url).pathname;
|
|
125758
|
+
} catch {
|
|
125759
|
+
path = "";
|
|
125760
|
+
}
|
|
125761
|
+
if (SIGNIN_PATH.test(path)) return "signed-out";
|
|
125762
|
+
if (res.status !== 200) return "unknown";
|
|
125763
|
+
if (INVITE_TOKEN_TEXT.test(res.body)) return "signed-in";
|
|
125764
|
+
if (hasPasswordInput(res.body)) return "signed-out";
|
|
125765
|
+
return "unknown";
|
|
125766
|
+
}
|
|
125767
|
+
function isAuthFailedReply(body) {
|
|
125768
|
+
if (!looksLikeHexFrame(body)) return false;
|
|
125769
|
+
try {
|
|
125770
|
+
return decodeReplyEnvelope(fromHex(body.trim())).error?.code === AUTH_FAILED_CODE;
|
|
125771
|
+
} catch {
|
|
125772
|
+
return false;
|
|
125773
|
+
}
|
|
125774
|
+
}
|
|
125775
|
+
var isServicesUrl = (url4) => {
|
|
125776
|
+
try {
|
|
125777
|
+
return /\/services\b/i.test(new URL(url4).pathname);
|
|
125778
|
+
} catch {
|
|
125779
|
+
return false;
|
|
125780
|
+
}
|
|
125781
|
+
};
|
|
125782
|
+
var isProbeUrl = (url4) => {
|
|
125783
|
+
try {
|
|
125784
|
+
const u = new URL(url4);
|
|
125785
|
+
return u.origin === SESSION_ORIGIN && u.pathname === new URL(SIGNED_IN_PROBE_URL).pathname;
|
|
125786
|
+
} catch {
|
|
125787
|
+
return false;
|
|
125788
|
+
}
|
|
125789
|
+
};
|
|
125529
125790
|
var DirectBridge = class {
|
|
125530
125791
|
constructor(store, fetchImpl = fetchViaPublic, hostSignIn = false) {
|
|
125531
125792
|
this.store = store;
|
|
@@ -125535,6 +125796,24 @@ var DirectBridge = class {
|
|
|
125535
125796
|
store;
|
|
125536
125797
|
fetchImpl;
|
|
125537
125798
|
hostSignIn;
|
|
125799
|
+
/** One GET of {@link SIGNED_IN_PROBE_URL} with the session; `none` when no session is linked. Never throws. */
|
|
125800
|
+
async checkSignedIn(signal) {
|
|
125801
|
+
const sess = await this.store.read();
|
|
125802
|
+
if (!sess) return "none";
|
|
125803
|
+
return this.probe(sess.authToken, signal);
|
|
125804
|
+
}
|
|
125805
|
+
async probe(token, signal) {
|
|
125806
|
+
try {
|
|
125807
|
+
const res = await this.fetchImpl(SIGNED_IN_PROBE_URL, {
|
|
125808
|
+
method: "GET",
|
|
125809
|
+
headers: { cookie: `AuthToken=${token}` },
|
|
125810
|
+
...signal ? { signal } : {}
|
|
125811
|
+
});
|
|
125812
|
+
return signInVerdict(res);
|
|
125813
|
+
} catch {
|
|
125814
|
+
return "unknown";
|
|
125815
|
+
}
|
|
125816
|
+
}
|
|
125538
125817
|
async fetch(init, signal) {
|
|
125539
125818
|
const sess = await this.store.read();
|
|
125540
125819
|
if (!sess) throw new SessionNotLinkedError(this.hostSignIn ? { hostSignIn: true } : {});
|
|
@@ -125563,13 +125842,19 @@ var DirectBridge = class {
|
|
|
125563
125842
|
});
|
|
125564
125843
|
}
|
|
125565
125844
|
}
|
|
125566
|
-
|
|
125567
|
-
|
|
125845
|
+
const suspect = looksSignedOut(url4, res) || answered && isServicesUrl(url4) && isAuthFailedReply(res.body);
|
|
125846
|
+
if (suspect) {
|
|
125847
|
+
const verdict = isProbeUrl(url4) && isSafeToReplay(init.method) ? signInVerdict(res) : await this.probe(token, signal);
|
|
125848
|
+
if (verdict !== "signed-in") {
|
|
125849
|
+
throw new SessionExpiredError({ capturedAt: sess.capturedAt, hostSignIn: this.hostSignIn || sess.origin === "host" });
|
|
125850
|
+
}
|
|
125568
125851
|
}
|
|
125569
125852
|
return { status: res.status, body: res.body, url: res.url };
|
|
125570
125853
|
}
|
|
125571
125854
|
};
|
|
125572
125855
|
var RELINK_CHECK_MS = 5e3;
|
|
125856
|
+
var WALL_RETRY_BASE_MS = 6e4;
|
|
125857
|
+
var WALL_RETRY_MAX_MS = 30 * 6e4;
|
|
125573
125858
|
function createDirectFirstBridge(opts) {
|
|
125574
125859
|
const env = opts.env ?? process.env;
|
|
125575
125860
|
const hosted = isHosted(env);
|
|
@@ -125584,10 +125869,15 @@ function createDirectFirstBridge(opts) {
|
|
|
125584
125869
|
let wall = null;
|
|
125585
125870
|
let stale = false;
|
|
125586
125871
|
let lastRelinkCheck = Number.NEGATIVE_INFINITY;
|
|
125872
|
+
let wallsInARow = 0;
|
|
125587
125873
|
const onFallback = ({ error: error62 }) => {
|
|
125588
|
-
const next = error62 instanceof SessionExpiredError ? { kind: "session", capturedAt: error62.capturedAt ?? null } : error62 instanceof SessionNotLinkedError ? { kind: "session", capturedAt: null } : { kind: "edge" };
|
|
125589
|
-
wall = next;
|
|
125590
125874
|
const why = error62 instanceof SessionExpiredError ? "the linked war.app session is signed out" : error62 instanceof SessionNotLinkedError ? "no war.app session is linked" : "the site edge refused the direct request";
|
|
125875
|
+
const since = now();
|
|
125876
|
+
wallsInARow += 1;
|
|
125877
|
+
const retryAt = hosted ? since + Math.min(WALL_RETRY_BASE_MS * 2 ** (wallsInARow - 1), WALL_RETRY_MAX_MS) : null;
|
|
125878
|
+
const timing = { reason: why, since, retryAt };
|
|
125879
|
+
const next = error62 instanceof SessionExpiredError ? { kind: "session", capturedAt: error62.capturedAt ?? null, ...timing } : error62 instanceof SessionNotLinkedError ? { kind: "session", capturedAt: null, ...timing } : { kind: "edge", ...timing };
|
|
125880
|
+
wall = next;
|
|
125591
125881
|
log(
|
|
125592
125882
|
`[warapp-mcp] Direct transport unavailable (${why}) \u2014 switching to the ContextMint Bridge browser bridge. Keep a ${SESSION_HOST} tab open and approve the pairing prompt in the extension if one appears` + (next.kind !== "session" ? "." : hostSignIn ? `. ${HOST_SIGN_IN_ADVICE}` : hosted ? "." : "; run warapp_link_session to return to the direct transport.")
|
|
125593
125883
|
);
|
|
@@ -125603,11 +125893,15 @@ function createDirectFirstBridge(opts) {
|
|
|
125603
125893
|
onFallback
|
|
125604
125894
|
});
|
|
125605
125895
|
let legs = build2();
|
|
125606
|
-
const
|
|
125607
|
-
if (wall
|
|
125896
|
+
const liftWall = () => {
|
|
125897
|
+
if (!wall) return;
|
|
125608
125898
|
wall = null;
|
|
125609
125899
|
legs = build2();
|
|
125610
125900
|
};
|
|
125901
|
+
const liftSessionWall = () => {
|
|
125902
|
+
if (wall?.kind !== "session") return;
|
|
125903
|
+
liftWall();
|
|
125904
|
+
};
|
|
125611
125905
|
const relinkedSinceWall = async () => {
|
|
125612
125906
|
if (wall?.kind !== "session") return false;
|
|
125613
125907
|
const t = now();
|
|
@@ -125621,12 +125915,16 @@ function createDirectFirstBridge(opts) {
|
|
|
125621
125915
|
liftSessionWall();
|
|
125622
125916
|
stale = false;
|
|
125623
125917
|
}
|
|
125918
|
+
if (mode === "auto" && wall?.retryAt != null && now() >= wall.retryAt) liftWall();
|
|
125624
125919
|
let reached;
|
|
125625
125920
|
return legs.run(async (leg, ctx) => {
|
|
125626
125921
|
if (leg === direct) {
|
|
125627
125922
|
try {
|
|
125628
125923
|
const res = await direct.fetch(init, ctx.signal);
|
|
125629
|
-
if (res.status === 200)
|
|
125924
|
+
if (res.status === 200) {
|
|
125925
|
+
stale = false;
|
|
125926
|
+
wallsInARow = 0;
|
|
125927
|
+
}
|
|
125630
125928
|
return res;
|
|
125631
125929
|
} catch (err) {
|
|
125632
125930
|
if (err instanceof SessionExpiredError) {
|
|
@@ -125648,6 +125946,23 @@ function createDirectFirstBridge(opts) {
|
|
|
125648
125946
|
bridgeTransport: () => legs.bridgeTransport(),
|
|
125649
125947
|
stats: () => legs.stats(),
|
|
125650
125948
|
sessionStale: () => stale,
|
|
125949
|
+
wall: () => wall ? {
|
|
125950
|
+
kind: wall.kind,
|
|
125951
|
+
reason: wall.reason,
|
|
125952
|
+
since: new Date(wall.since).toISOString(),
|
|
125953
|
+
retryAt: wall.retryAt === null ? null : new Date(wall.retryAt).toISOString()
|
|
125954
|
+
} : null,
|
|
125955
|
+
checkSession: async () => {
|
|
125956
|
+
const verdict = await direct.checkSignedIn();
|
|
125957
|
+
if (verdict === "signed-in") {
|
|
125958
|
+
stale = false;
|
|
125959
|
+
wallsInARow = 0;
|
|
125960
|
+
if (mode === "auto") liftWall();
|
|
125961
|
+
} else if (verdict === "signed-out") {
|
|
125962
|
+
stale = true;
|
|
125963
|
+
}
|
|
125964
|
+
return verdict;
|
|
125965
|
+
},
|
|
125651
125966
|
sessionLinked: () => {
|
|
125652
125967
|
stale = false;
|
|
125653
125968
|
if (mode === "auto") liftSessionWall();
|
|
@@ -125823,12 +126138,7 @@ function beginnable(game, me) {
|
|
|
125823
126138
|
requirePlaying(game, mySeat(game, me));
|
|
125824
126139
|
}
|
|
125825
126140
|
async function liveBoard(ctx, gameId) {
|
|
125826
|
-
|
|
125827
|
-
"GetLatestGameInfo",
|
|
125828
|
-
Method.GetLatestGameInfo,
|
|
125829
|
-
(w) => writeGetLatestGameInfoParams(w, gameId)
|
|
125830
|
-
);
|
|
125831
|
-
return standingFromInfo(readLatestGameInfo(await ctx.bundle(), env.body)) ?? void 0;
|
|
126141
|
+
return (await readLatestBoard(ctx, gameId)).territories ?? void 0;
|
|
125832
126142
|
}
|
|
125833
126143
|
function registerBeginTurnTool(server, ctx) {
|
|
125834
126144
|
defineGatedWrite(
|
|
@@ -138020,6 +138330,8 @@ function registerTurnTools(server, ctx, opts = {}) {
|
|
|
138020
138330
|
const guessOrders = guess ? guessOrdersOf(orders, guess) : void 0;
|
|
138021
138331
|
const owedLine = surrenderOwedLine(surrenders);
|
|
138022
138332
|
if (owedLine) warnings.unshift(owedLine);
|
|
138333
|
+
const standInNote = standInLine(standInOf(ctx));
|
|
138334
|
+
if (standInNote) warnings.unshift(standInNote);
|
|
138023
138335
|
const paceRecord = PACE_TURNS.includes(turnsCompleted(game)) ? await mapRecordFor(ctx.dataDir, opts.env, game.settings?.mapId) : void 0;
|
|
138024
138336
|
const pace = paceRecord && paceRecord !== "unreadable" ? paceView(paceRecord, turnsCompleted(game), myIncome) : void 0;
|
|
138025
138337
|
return respond(view, VIEWS6, (rung) => ({
|
|
@@ -138646,6 +138958,8 @@ function registerTurnTools(server, ctx, opts = {}) {
|
|
|
138646
138958
|
})
|
|
138647
138959
|
);
|
|
138648
138960
|
if (belowPlan) warnings.push(belowPlan);
|
|
138961
|
+
const standInNote = standInLine(standInOf(ctx));
|
|
138962
|
+
if (standInNote) warnings.unshift(standInNote);
|
|
138649
138963
|
const merged = /* @__PURE__ */ new Map();
|
|
138650
138964
|
for (const d of deploys) {
|
|
138651
138965
|
const m = merged.get(d.territory.id);
|
|
@@ -141281,6 +141595,8 @@ function registerCheckPlanTool(server, ctx) {
|
|
|
141281
141595
|
});
|
|
141282
141596
|
const belowPlan = await bordersBelowPlan(ctx, { game, map: map2, me, turn, territories, info, history, teamsKnown, given: { deploys, moves } });
|
|
141283
141597
|
const warnings = [
|
|
141598
|
+
// The owner, 2026-11-17: while an older build stands in for a client this server cannot read, say so first.
|
|
141599
|
+
...[standInLine(standInOf(ctx))].filter((w) => w !== void 0),
|
|
141284
141600
|
// #275 (b): an untrusted estimate is the first thing said (not under an explicit enemy_deploy).
|
|
141285
141601
|
...enemy_deploy === void 0 ? tripwireWarnings(trip.tripwires, (w) => untrustedOf.get(w.player) ?? untrustedDeploy(w, income), (p) => estimates.find((x) => x.playerId === p)?.estimate) : [],
|
|
141286
141602
|
...award ? assumedWarning(award) : [],
|
|
@@ -141629,6 +141945,10 @@ function registerGameTool(server, client, dir, env, identity) {
|
|
|
141629
141945
|
// src/tools/healthcheck.ts
|
|
141630
141946
|
var PROBE_PATH = `/API/GameFeed?GameID=${PROBE_GAME_ID}&GetMap=false`;
|
|
141631
141947
|
var BRIDGE_PROBE_PATH = "/";
|
|
141948
|
+
function withStandIn(health, deps) {
|
|
141949
|
+
const w = deps.standIn?.();
|
|
141950
|
+
return w ? { ...health, standIn: w } : health;
|
|
141951
|
+
}
|
|
141632
141952
|
function sessionSummary(env, now) {
|
|
141633
141953
|
const s = readSessionSync(env);
|
|
141634
141954
|
if (!s) return { linked: false };
|
|
@@ -141641,6 +141961,24 @@ function transportHealth(status, env, now) {
|
|
|
141641
141961
|
}
|
|
141642
141962
|
function registerHealthcheckTool(server, bridge2, direct, deps = {}) {
|
|
141643
141963
|
const now = deps.now ?? Date.now;
|
|
141964
|
+
let lastCheck = {};
|
|
141965
|
+
const checkSession = async () => {
|
|
141966
|
+
lastCheck = {};
|
|
141967
|
+
if (!direct.checkSession || direct.status().mode === "fetchproxy") return void 0;
|
|
141968
|
+
if (!readSessionSync(deps.env)) return void 0;
|
|
141969
|
+
const verdict = await direct.checkSession().catch(() => "unknown");
|
|
141970
|
+
if (verdict === "none") return void 0;
|
|
141971
|
+
const wall = direct.wall?.() ?? null;
|
|
141972
|
+
lastCheck = { sessionCheck: verdict, ...wall ? { wall } : {} };
|
|
141973
|
+
return verdict;
|
|
141974
|
+
};
|
|
141975
|
+
const health = () => withStandIn({ ...transportHealth(direct.status(), deps.env, now), ...lastCheck }, deps);
|
|
141976
|
+
const signedOut = () => new SessionExpiredError({ hostSignIn: readSessionSync(deps.env)?.origin === "host" });
|
|
141977
|
+
const classifySignedOut = (err) => err instanceof SessionExpiredError ? {
|
|
141978
|
+
kind: "session_expired",
|
|
141979
|
+
hint: "war.app shows the session the live tools use as signed out. " + (err.hostSignIn ? HOST_SIGN_IN_ADVICE : "Run warapp_link_session to relink.")
|
|
141980
|
+
} : void 0;
|
|
141981
|
+
let resolvedVerdict;
|
|
141644
141982
|
registerAdaptiveHealthcheckTool({
|
|
141645
141983
|
server,
|
|
141646
141984
|
prefix: "warapp",
|
|
@@ -141655,32 +141993,42 @@ function registerHealthcheckTool(server, bridge2, direct, deps = {}) {
|
|
|
141655
141993
|
bridge: {
|
|
141656
141994
|
probePath: BRIDGE_PROBE_PATH,
|
|
141657
141995
|
transport: () => bridge2.transport(),
|
|
141658
|
-
path:
|
|
141996
|
+
path: health,
|
|
141659
141997
|
probeFn: async (path) => {
|
|
141660
|
-
const
|
|
141998
|
+
const verdict = await checkSession();
|
|
141999
|
+
if (verdict === "signed-out") throw signedOut();
|
|
142000
|
+
const viaRouter = verdict === "signed-in" && direct.ready !== void 0;
|
|
142001
|
+
const leg = viaRouter ? await direct.ready() : await bridge2.ready();
|
|
142002
|
+
const res = await leg.fetch({ method: "GET", path });
|
|
141661
142003
|
if (res.status !== 200) {
|
|
141662
|
-
throw new McpToolError(`war.app answered HTTP ${res.status} through the bridge.`, {
|
|
142004
|
+
throw new McpToolError(`war.app answered HTTP ${res.status}${viaRouter ? "" : " through the bridge"}.`, {
|
|
141663
142005
|
status: res.status,
|
|
141664
142006
|
kind: "http"
|
|
141665
142007
|
});
|
|
141666
142008
|
}
|
|
141667
142009
|
return res.body;
|
|
141668
|
-
}
|
|
142010
|
+
},
|
|
142011
|
+
classifyThrown: classifySignedOut
|
|
141669
142012
|
},
|
|
141670
142013
|
credential: {
|
|
141671
142014
|
probePath: PROBE_PATH,
|
|
141672
142015
|
resolveCredential: async () => {
|
|
141673
|
-
|
|
142016
|
+
resolvedVerdict = await checkSession();
|
|
142017
|
+
const detail2 = health();
|
|
141674
142018
|
try {
|
|
141675
142019
|
readCredentials(deps.env);
|
|
141676
|
-
return { source: "env", detail:
|
|
142020
|
+
return { source: "env", detail: detail2 };
|
|
141677
142021
|
} catch (e) {
|
|
141678
|
-
if (e instanceof WarappConfigError) return { source: null, detail: { ...
|
|
142022
|
+
if (e instanceof WarappConfigError) return { source: null, detail: { ...detail2, reason: e.message } };
|
|
141679
142023
|
throw e;
|
|
141680
142024
|
}
|
|
141681
142025
|
},
|
|
141682
|
-
probeFn: () =>
|
|
141683
|
-
|
|
142026
|
+
probeFn: async () => {
|
|
142027
|
+
const res = await new WarappClient(deps).probeAuth();
|
|
142028
|
+
if (resolvedVerdict === "signed-out") throw signedOut();
|
|
142029
|
+
return res;
|
|
142030
|
+
},
|
|
142031
|
+
classifyThrown: (err) => err instanceof McpToolError && err.kind === "credential_rejected" ? { kind: "credential_rejected", hint: AUTH_FAILED_HINT } : classifySignedOut(err),
|
|
141684
142032
|
hints: { no_credential: `Set WARAPP_EMAIL and WARAPP_API_TOKEN (token from ${TOKEN_URL}).` }
|
|
141685
142033
|
}
|
|
141686
142034
|
});
|
|
@@ -142253,7 +142601,9 @@ function registerSessionTools(server, deps) {
|
|
|
142253
142601
|
return {
|
|
142254
142602
|
decoder: {
|
|
142255
142603
|
...d,
|
|
142256
|
-
...d.
|
|
142604
|
+
...d.standInFor ? {
|
|
142605
|
+
note: `war.app's current client (${d.standInFor.version}) cannot be read by this server, so the client release it was written for (still served by war.app) is decoding boards; war.app answers this server in that layout.`
|
|
142606
|
+
} : d.fallback ? { note: "A cached copy of war.app's client is decoding boards: the current version could not be looked up." } : {}
|
|
142257
142607
|
}
|
|
142258
142608
|
};
|
|
142259
142609
|
};
|
|
@@ -142271,11 +142621,13 @@ function registerSessionTools(server, deps) {
|
|
|
142271
142621
|
async () => {
|
|
142272
142622
|
if (hosted && hostToken === "ok") {
|
|
142273
142623
|
const pt2 = deps.pushTransport?.();
|
|
142624
|
+
const wall = deps.transport.wall?.() ?? null;
|
|
142274
142625
|
const base = {
|
|
142275
142626
|
hosted: true,
|
|
142276
142627
|
linked: true,
|
|
142277
142628
|
linkedBy: "host",
|
|
142278
142629
|
activeTransport: deps.transport.activeLeg(),
|
|
142630
|
+
...wall ? { wall } : {},
|
|
142279
142631
|
...pt2 ? { pushTransport: pt2 } : {},
|
|
142280
142632
|
...decoderView(),
|
|
142281
142633
|
hostedNote: NOTE_HOSTED_DIRECT
|
|
@@ -142304,7 +142656,16 @@ function registerSessionTools(server, deps) {
|
|
|
142304
142656
|
return respond(void 0, ["compact"], () => {
|
|
142305
142657
|
if (!session) return { linked: false, activeTransport, ...push, hint: HINT_NOT_LINKED };
|
|
142306
142658
|
const ageSeconds = Math.max(0, Math.round((now() - Date.parse(session.capturedAt)) / 1e3));
|
|
142307
|
-
const
|
|
142659
|
+
const wall = deps.transport.wall?.() ?? null;
|
|
142660
|
+
const base = {
|
|
142661
|
+
linked: true,
|
|
142662
|
+
host: session.host,
|
|
142663
|
+
capturedAt: session.capturedAt,
|
|
142664
|
+
ageSeconds,
|
|
142665
|
+
activeTransport,
|
|
142666
|
+
...wall ? { wall } : {},
|
|
142667
|
+
...push
|
|
142668
|
+
};
|
|
142308
142669
|
return deps.transport.sessionStale() ? { ...base, sessionExpired: true, hint: HINT_EXPIRED } : base;
|
|
142309
142670
|
});
|
|
142310
142671
|
}
|
|
@@ -146894,7 +147255,7 @@ function registerAllTools(server, deps = {}) {
|
|
|
146894
147255
|
// The cached signed-in account is discarded whenever the account behind the router may have changed.
|
|
146895
147256
|
identity: () => bridge2.identityState()
|
|
146896
147257
|
});
|
|
146897
|
-
registerHealthcheckTool(server, fetchproxy, bridge2, deps);
|
|
147258
|
+
registerHealthcheckTool(server, fetchproxy, bridge2, { ...deps, standIn: () => live.decoderReport()?.standIn });
|
|
146898
147259
|
registerGameTool(server, client, () => dataDir(deps.env), deps.env, () => live.myInviteToken());
|
|
146899
147260
|
registerMapTool(server, client, live);
|
|
146900
147261
|
registerMapStatsTool(server, {
|
|
@@ -146943,6 +147304,7 @@ function registerAllTools(server, deps = {}) {
|
|
|
146943
147304
|
transport: {
|
|
146944
147305
|
activeLeg: () => bridge2.status().transport,
|
|
146945
147306
|
sessionStale: () => bridge2.sessionStale(),
|
|
147307
|
+
wall: () => bridge2.wall(),
|
|
146946
147308
|
sessionLinked: () => bridge2.sessionLinked()
|
|
146947
147309
|
},
|
|
146948
147310
|
pushTransport: () => push.status().transport,
|