@chrischall/warapp-mcp 0.16.0 → 0.18.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/analysis/income-calibration.js +57 -1
- package/dist/bundle.js +187 -27
- package/dist/decision-log.js +40 -2
- package/dist/map-store.js +69 -2
- package/dist/my-games.js +50 -10
- package/dist/review-export.js +1 -1
- package/dist/tools/calibration.js +5 -2
- package/dist/tools/decision-capture.js +8 -1
- package/dist/tools/my-games.js +13 -5
- package/dist/tools/pace.js +25 -8
- package/dist/tools/push.js +15 -1
- package/dist/version.js +1 -1
- package/manifest.json +1 -1
- package/package.json +1 -1
- package/server.json +2 -2
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
},
|
|
8
8
|
"metadata": {
|
|
9
9
|
"description": "MCP server for war.app (Warzone) — your games, players, settings, map bonuses and chokepoints, board analysis and route planning through war.app's per-player GameFeed API, plus the live board, territory picks, cards, turn planning and submission, turn notifications and game chat through your signed-in war.app tab (joining, leaving or surrendering a game, closing out a finished game, accepting another player's surrender, Begin on a speed first turn, picks, turn orders, withdrawing them, chat sends, marking notifications and chat read, deleting notifications, importing local history and linking a session are confirm-gated).",
|
|
10
|
-
"version": "0.
|
|
10
|
+
"version": "0.18.0"
|
|
11
11
|
},
|
|
12
12
|
"plugins": [
|
|
13
13
|
{
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"displayName": "war.app (Warzone)",
|
|
16
16
|
"source": "./",
|
|
17
17
|
"description": "war.app (Warzone) game advisor for Claude — games, maps, bonuses, routes, live board, picks, turns, cards and chat",
|
|
18
|
-
"version": "0.
|
|
18
|
+
"version": "0.18.0",
|
|
19
19
|
"author": {
|
|
20
20
|
"name": "Chris Hall"
|
|
21
21
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "warapp-mcp",
|
|
3
3
|
"displayName": "war.app (Warzone)",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.18.0",
|
|
5
5
|
"description": "war.app (Warzone) game advisor for Claude — games, maps, bonuses, routes, live board, picks, turns, cards and chat",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Chris Hall",
|
|
@@ -17,6 +17,53 @@ export function seatBand(seats) {
|
|
|
17
17
|
return 'unknown';
|
|
18
18
|
return seats === 2 ? '2' : seats <= 6 ? '3-6' : seats <= 16 ? '7-16' : '17-up';
|
|
19
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* #586: the step that held a low estimate (under {@link CATCH_UP_SHARE} of the truth) down, read from the
|
|
22
|
+
* tracker's logged figures (#587's `track`), first match in this order:
|
|
23
|
+
* - `after-tracker`: the tracker's income reached it; a later stage (blend, thin evidence, a known income) did not;
|
|
24
|
+
* - `rise-cap`: a window reading reached it and #418's rise cap held the income;
|
|
25
|
+
* - `tripwire`: a window reading reached it and #418's over-read tripwire stepped it down;
|
|
26
|
+
* - `window`: a window reading reached it and the income still did not (a carry lowered by broken bonuses, …);
|
|
27
|
+
* - `ceiling`: a reading reached it before the could-earn cap, which cut it;
|
|
28
|
+
* - `ambiguous`: only the high end reached it (the ambiguous armies #123 reads as moves, not deploys);
|
|
29
|
+
* - `readings`: nothing the boards showed reached it (fog, a thin frontier);
|
|
30
|
+
* - `no-track`: the estimate used no track (the prior or the visible income alone);
|
|
31
|
+
* - `unlogged`: logged before #586 kept the track: no step can be named.
|
|
32
|
+
*/
|
|
33
|
+
export const HELD_BY = ['after-tracker', 'rise-cap', 'tripwire', 'window', 'ceiling', 'ambiguous', 'readings', 'no-track', 'unlogged'];
|
|
34
|
+
/** #586: {@link HELD_BY}'s step for one estimate; `null` when it reached {@link CATCH_UP_SHARE} of the truth. Pure. */
|
|
35
|
+
export function heldByOf(estimate, truth, track, stages) {
|
|
36
|
+
const target = CATCH_UP_SHARE * truth;
|
|
37
|
+
if (truth <= 0 || estimate >= target)
|
|
38
|
+
return null;
|
|
39
|
+
if (!track)
|
|
40
|
+
return stages && stages.tracked === null ? 'no-track' : 'unlogged';
|
|
41
|
+
if (track.income === null || !track.window.length)
|
|
42
|
+
return 'no-track';
|
|
43
|
+
if (track.income >= target)
|
|
44
|
+
return 'after-tracker';
|
|
45
|
+
const most = (f) => Math.max(...track.window.map(f));
|
|
46
|
+
if (most((x) => x.observed) >= target)
|
|
47
|
+
return track.rise ? 'rise-cap' : track.trip ? 'tripwire' : 'window';
|
|
48
|
+
if (most((x) => Math.max(x.raw, x.high)) >= target && most((x) => x.cap) < target)
|
|
49
|
+
return 'ceiling';
|
|
50
|
+
if (most((x) => Math.min(x.high, x.cap)) >= target)
|
|
51
|
+
return 'ambiguous';
|
|
52
|
+
return 'readings';
|
|
53
|
+
}
|
|
54
|
+
export function heldByView(samples) {
|
|
55
|
+
const low = samples.filter((s) => s.heldBy !== null);
|
|
56
|
+
const named = low.filter((s) => s.heldBy !== 'unlogged');
|
|
57
|
+
const steps = {};
|
|
58
|
+
for (const step of HELD_BY) {
|
|
59
|
+
if (step === 'unlogged')
|
|
60
|
+
continue;
|
|
61
|
+
const n = named.filter((s) => s.heldBy === step).length;
|
|
62
|
+
if (n)
|
|
63
|
+
steps[step] = { n, share: r3(n / named.length) };
|
|
64
|
+
}
|
|
65
|
+
return { low: low.length, steps, unlogged: low.length - named.length };
|
|
66
|
+
}
|
|
20
67
|
const r3 = (x) => Math.round(x * 1000) / 1000;
|
|
21
68
|
export function errorView(samples) {
|
|
22
69
|
const n = samples.length;
|
|
@@ -72,6 +119,7 @@ export function incomeSamples(games) {
|
|
|
72
119
|
method: logged.get(a.player)?.method ?? null,
|
|
73
120
|
leader: top !== null && a.truth >= top,
|
|
74
121
|
stages: logged.get(a.player)?.stages ?? null,
|
|
122
|
+
heldBy: heldByOf(a.estimate, a.truth, logged.get(a.player)?.track, logged.get(a.player)?.stages ?? null),
|
|
75
123
|
});
|
|
76
124
|
}
|
|
77
125
|
}
|
|
@@ -81,11 +129,13 @@ export function incomeSamples(games) {
|
|
|
81
129
|
/**
|
|
82
130
|
* Per game and opponent, a turn whose true income is at least {@link JUMP_FACTOR} × the turn before (both
|
|
83
131
|
* read, the earlier above 0) is a jump; its lag is the turns from it to the first logged estimate of that
|
|
84
|
-
* opponent at or after it that reaches {@link CATCH_UP_SHARE} of that turn's truth.
|
|
132
|
+
* opponent at or after it that reaches {@link CATCH_UP_SHARE} of that turn's truth. A jump on a turn with no
|
|
133
|
+
* estimate of that opponent logged is `unwatched` and left out (#586). Pure.
|
|
85
134
|
*/
|
|
86
135
|
export function catchUp(games) {
|
|
87
136
|
const lagsList = [];
|
|
88
137
|
let censored = 0;
|
|
138
|
+
let unwatched = 0;
|
|
89
139
|
for (const g of games) {
|
|
90
140
|
const turns = turnKeys(g.turns);
|
|
91
141
|
const truth = new Map(); // player → turn → income
|
|
@@ -106,6 +156,10 @@ export function catchUp(games) {
|
|
|
106
156
|
const before = series.get(t - 1);
|
|
107
157
|
if (before === undefined || before <= 0 || income < JUMP_FACTOR * before || t > last)
|
|
108
158
|
continue;
|
|
159
|
+
if (!estimates.has(t)) {
|
|
160
|
+
unwatched++;
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
109
163
|
let lag = null;
|
|
110
164
|
for (const u of [...estimates.keys()].filter((u) => u >= t).sort((a, b) => a - b)) {
|
|
111
165
|
const truthU = series.get(u) ?? income;
|
|
@@ -133,6 +187,7 @@ export function catchUp(games) {
|
|
|
133
187
|
medianLag: n ? (n % 2 ? sorted[n >> 1] : (sorted[(n >> 1) - 1] + sorted[n >> 1]) / 2) : null,
|
|
134
188
|
lags,
|
|
135
189
|
censored,
|
|
190
|
+
unwatched,
|
|
136
191
|
};
|
|
137
192
|
}
|
|
138
193
|
export function consequences(games) {
|
|
@@ -276,5 +331,6 @@ export function incomeCalibration(games) {
|
|
|
276
331
|
worst,
|
|
277
332
|
byStage: stageErrors(samples),
|
|
278
333
|
trackedWhatIf: trackedWhatIf(samples),
|
|
334
|
+
heldBy: heldByView(samples),
|
|
279
335
|
};
|
|
280
336
|
}
|
package/dist/bundle.js
CHANGED
|
@@ -115386,6 +115386,7 @@ async function withPathLock(path, fn) {
|
|
|
115386
115386
|
var MAX_STORED_MAPS = 40;
|
|
115387
115387
|
var MAX_MAP_AGE_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
115388
115388
|
var MAX_GAME_INDEX = 500;
|
|
115389
|
+
var MAX_PINNED_GAMES = 1e3;
|
|
115389
115390
|
var VERSION = 1;
|
|
115390
115391
|
var MAP_FILE = /^\d+\.json$/;
|
|
115391
115392
|
var isRec2 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
@@ -115394,6 +115395,7 @@ var isIntArray = (v) => Array.isArray(v) && v.every(isInt);
|
|
|
115394
115395
|
var mapsDir = (dir) => join5(dir, "maps");
|
|
115395
115396
|
var mapStorePath = (dir, mapId) => join5(mapsDir(dir), `${mapId}.json`);
|
|
115396
115397
|
var indexPath = (dir) => join5(mapsDir(dir), "games.json");
|
|
115398
|
+
var pinsPath = (dir) => join5(mapsDir(dir), "pinned.json");
|
|
115397
115399
|
async function writeJsonAtomic(path, folder, body) {
|
|
115398
115400
|
await mkdir(folder, { recursive: true, mode: 448 });
|
|
115399
115401
|
const tmp = `${path}.${process.pid}.${randomBytes3(4).toString("hex")}.tmp`;
|
|
@@ -115470,9 +115472,10 @@ async function readStoredMapEntry(dir, mapId, opts = {}) {
|
|
|
115470
115472
|
}
|
|
115471
115473
|
async function evictMaps(dir, keep) {
|
|
115472
115474
|
const folder = mapsDir(dir);
|
|
115475
|
+
const pinned = new Set((await readPins(dir)).map(([, m]) => `${m}.json`));
|
|
115473
115476
|
const files = [];
|
|
115474
115477
|
for (const name of await readdir(folder)) {
|
|
115475
|
-
if (!MAP_FILE.test(name)) continue;
|
|
115478
|
+
if (!MAP_FILE.test(name) || pinned.has(name)) continue;
|
|
115476
115479
|
try {
|
|
115477
115480
|
files.push({ name, at: (await stat(join5(folder, name))).mtimeMs });
|
|
115478
115481
|
} catch {
|
|
@@ -115545,6 +115548,44 @@ async function rememberGameMap(dir, gameId, mapId) {
|
|
|
115545
115548
|
return false;
|
|
115546
115549
|
}
|
|
115547
115550
|
}
|
|
115551
|
+
async function readPins(dir) {
|
|
115552
|
+
try {
|
|
115553
|
+
const raw = JSON.parse(await readFile(pinsPath(dir), "utf8"));
|
|
115554
|
+
if (!isRec2(raw) || raw.version !== VERSION || !Array.isArray(raw.pins)) return [];
|
|
115555
|
+
return raw.pins.filter((e) => Array.isArray(e) && e.length === 2 && isInt(e[0]) && isInt(e[1]));
|
|
115556
|
+
} catch {
|
|
115557
|
+
return [];
|
|
115558
|
+
}
|
|
115559
|
+
}
|
|
115560
|
+
async function pinStoredMap(dir, mapId, gameId) {
|
|
115561
|
+
try {
|
|
115562
|
+
return await withPathLock(pinsPath(dir), async () => {
|
|
115563
|
+
const pins = await readPins(dir);
|
|
115564
|
+
if (pins.some(([g, m]) => g === gameId && m === mapId)) return false;
|
|
115565
|
+
const next = pins.filter(([g]) => g !== gameId);
|
|
115566
|
+
next.push([gameId, mapId]);
|
|
115567
|
+
await writeJsonAtomic(pinsPath(dir), mapsDir(dir), { version: VERSION, pins: next.slice(-MAX_PINNED_GAMES) });
|
|
115568
|
+
return true;
|
|
115569
|
+
});
|
|
115570
|
+
} catch {
|
|
115571
|
+
return false;
|
|
115572
|
+
}
|
|
115573
|
+
}
|
|
115574
|
+
async function unpinGames(dir, gameIds) {
|
|
115575
|
+
if (!gameIds.length) return false;
|
|
115576
|
+
const gone = new Set(gameIds);
|
|
115577
|
+
try {
|
|
115578
|
+
return await withPathLock(pinsPath(dir), async () => {
|
|
115579
|
+
const pins = await readPins(dir);
|
|
115580
|
+
const next = pins.filter(([g]) => !gone.has(g));
|
|
115581
|
+
if (next.length === pins.length) return false;
|
|
115582
|
+
await writeJsonAtomic(pinsPath(dir), mapsDir(dir), { version: VERSION, pins: next });
|
|
115583
|
+
return true;
|
|
115584
|
+
});
|
|
115585
|
+
} catch {
|
|
115586
|
+
return false;
|
|
115587
|
+
}
|
|
115588
|
+
}
|
|
115548
115589
|
|
|
115549
115590
|
// src/build-id.ts
|
|
115550
115591
|
import { createHash as createHash4 } from "node:crypto";
|
|
@@ -115630,7 +115671,7 @@ function serverBuild() {
|
|
|
115630
115671
|
}
|
|
115631
115672
|
|
|
115632
115673
|
// src/version.ts
|
|
115633
|
-
var VERSION2 = "0.
|
|
115674
|
+
var VERSION2 = "0.18.0";
|
|
115634
115675
|
|
|
115635
115676
|
// src/decision-log.ts
|
|
115636
115677
|
var DECISION_LOG_VERSION = 1;
|
|
@@ -115746,6 +115787,10 @@ function encodeInput(input2) {
|
|
|
115746
115787
|
}
|
|
115747
115788
|
function loggedEstimates(estimates, tracks) {
|
|
115748
115789
|
const methods = new Map((tracks ?? []).flatMap((t) => t.incomeMethod ? [[t.playerId, t.incomeMethod]] : []));
|
|
115790
|
+
const internals = new Map((tracks ?? []).flatMap((t) => {
|
|
115791
|
+
const logged2 = loggedTrack(t);
|
|
115792
|
+
return logged2 ? [[t.playerId, logged2]] : [];
|
|
115793
|
+
}));
|
|
115749
115794
|
return [...estimates].sort((a, b) => a.playerId - b.playerId).map((e) => ({
|
|
115750
115795
|
player: e.playerId,
|
|
115751
115796
|
estimate: e.estimate,
|
|
@@ -115753,9 +115798,36 @@ function loggedEstimates(estimates, tracks) {
|
|
|
115753
115798
|
coverage: e.coverage?.share ?? null,
|
|
115754
115799
|
thin: !!e.thinEvidence,
|
|
115755
115800
|
...methods.has(e.playerId) ? { method: methods.get(e.playerId) } : {},
|
|
115756
|
-
stages: estimateStages(e)
|
|
115801
|
+
stages: estimateStages(e),
|
|
115802
|
+
...internals.has(e.playerId) ? { track: internals.get(e.playerId) } : {}
|
|
115757
115803
|
}));
|
|
115758
115804
|
}
|
|
115805
|
+
function loggedTrack(t) {
|
|
115806
|
+
if (t.income === void 0) return void 0;
|
|
115807
|
+
const window = new Set(t.incomeTurns ?? []);
|
|
115808
|
+
const turns = (t.turns ?? []).filter((x) => window.has(x.from));
|
|
115809
|
+
return {
|
|
115810
|
+
income: t.income,
|
|
115811
|
+
window: turns.map((x) => ({
|
|
115812
|
+
turn: x.from,
|
|
115813
|
+
observed: x.observed,
|
|
115814
|
+
raw: x.raw,
|
|
115815
|
+
low: x.low,
|
|
115816
|
+
high: x.high,
|
|
115817
|
+
cap: x.cap,
|
|
115818
|
+
coverage: x.coverage?.share ?? null,
|
|
115819
|
+
...x.captureFloor !== void 0 ? { captureFloor: x.captureFloor } : {},
|
|
115820
|
+
...x.accounted ? { accounted: true } : {},
|
|
115821
|
+
...x.fogCaptures ? { fogCaptures: x.fogCaptures.income } : {}
|
|
115822
|
+
})),
|
|
115823
|
+
...t.incomeLowered ? { lowered: t.incomeLowered } : {},
|
|
115824
|
+
...t.incomeRise ? { rise: { ...t.incomeRise } } : {},
|
|
115825
|
+
...t.observedLow ? { observedLow: { ...t.observedLow } } : {},
|
|
115826
|
+
...t.incomeTrip ? { trip: { ...t.incomeTrip } } : {},
|
|
115827
|
+
...t.incomeJump ? { jump: { turn: t.incomeJump.turn, observed: t.incomeJump.observed, before: t.incomeJump.before, verdict: t.incomeJump.verdict } } : {},
|
|
115828
|
+
...typeof t.topUp === "number" ? { topUp: t.topUp } : {}
|
|
115829
|
+
};
|
|
115830
|
+
}
|
|
115759
115831
|
function earnedIncome(input2) {
|
|
115760
115832
|
const { income, cardArmies } = input2 ?? {};
|
|
115761
115833
|
if (typeof income !== "number") return void 0;
|
|
@@ -115817,7 +115889,8 @@ function logOf(c, gameId) {
|
|
|
115817
115889
|
...isRec3(c.seats) ? { seats: c.seats } : {},
|
|
115818
115890
|
...isRec3(c.join) ? { join: c.join } : {},
|
|
115819
115891
|
...isRec3(c.opponents) ? { opponents: c.opponents } : {},
|
|
115820
|
-
...isRec3(c.picks) ? { picks: c.picks } : {}
|
|
115892
|
+
...isRec3(c.picks) ? { picks: c.picks } : {},
|
|
115893
|
+
...isInt2(c.mapId) ? { mapId: c.mapId } : {}
|
|
115821
115894
|
};
|
|
115822
115895
|
}
|
|
115823
115896
|
var hasContent = (log) => Object.keys(log.turns).length > 0 || !!log.events?.length || !!log.join || !!log.seats || !!log.opponents || !!log.picks;
|
|
@@ -115906,7 +115979,7 @@ async function recordDecision(dir, gameId, playerId, rec2, opts = {}) {
|
|
|
115906
115979
|
[String(rec2.turn)]: { ...entry, ...was?.chat ? { chat: was.chat } : {}, ...was?.checks ? { checks: was.checks } : {} }
|
|
115907
115980
|
};
|
|
115908
115981
|
encodeBoards(turns, boards);
|
|
115909
|
-
return { ...log, turns };
|
|
115982
|
+
return { ...log, ...rec2.mapId !== void 0 ? { mapId: rec2.mapId } : {}, turns };
|
|
115910
115983
|
},
|
|
115911
115984
|
opts
|
|
115912
115985
|
);
|
|
@@ -116441,6 +116514,7 @@ async function pruneDecisionLogs(dir, caps = {}) {
|
|
|
116441
116514
|
} catch {
|
|
116442
116515
|
}
|
|
116443
116516
|
}
|
|
116517
|
+
await unpinGames(dir, removed);
|
|
116444
116518
|
return removed;
|
|
116445
116519
|
}
|
|
116446
116520
|
|
|
@@ -137565,6 +137639,7 @@ function gameIdsOf(body) {
|
|
|
137565
137639
|
|
|
137566
137640
|
// src/tools/decision-capture.ts
|
|
137567
137641
|
import { createHash as createHash7 } from "node:crypto";
|
|
137642
|
+
import { existsSync as existsSync3 } from "node:fs";
|
|
137568
137643
|
|
|
137569
137644
|
// src/join-color.ts
|
|
137570
137645
|
var GAME_COLOR = "warlight.shared.GameColor";
|
|
@@ -137753,15 +137828,34 @@ function bootClockOf(f) {
|
|
|
137753
137828
|
return { bootMs: boot, bankedMs: banked, turnForMs: turnFor, realTime };
|
|
137754
137829
|
}
|
|
137755
137830
|
var BOOT_WARN_MINUTES = 6 * 60;
|
|
137756
|
-
var
|
|
137757
|
-
|
|
137758
|
-
|
|
137831
|
+
var OPENING_LAST_TURN = 4;
|
|
137832
|
+
var BOOT_SHARE_WARN = 0.25;
|
|
137833
|
+
var BOOT_NOTE = `From the game list: the game's boot time plus your banked time, less how long your turn has run (the web client shows the first two together beside each game). Banked time is eaten once the boot time is spent. A multi-day game is close to a boot under ${BOOT_WARN_MINUTES / 60} hours left; an opening turn (picks, or turns 1 to ${OPENING_LAST_TURN}: a missed one delays the first bonus) or a real-time turn also with a quarter of its time or less left (#504). The fields are read from war.app's client; the arithmetic is unverified live, and for a real-time game unverified at all.`;
|
|
137834
|
+
function bootSoon(leftMinutes, g) {
|
|
137835
|
+
const byShare = (g.opening || g.realTime) === true && leftMinutes <= g.allowanceMinutes * BOOT_SHARE_WARN;
|
|
137836
|
+
return byShare || !g.realTime && leftMinutes < BOOT_WARN_MINUTES;
|
|
137837
|
+
}
|
|
137838
|
+
function bootView(clock, waitingOnYou, opening = false) {
|
|
137839
|
+
if (!clock || !(clock.bootMs > 0) || clock.bootMs >= NEVER_MS) return void 0;
|
|
137759
137840
|
const min = (ms) => Math.max(0, Math.floor(ms / 6e4));
|
|
137760
137841
|
const bootMinutes = min(clock.bootMs);
|
|
137761
137842
|
const bankedMinutes = clock.bankedMs >= NEVER_MS ? 0 : min(clock.bankedMs);
|
|
137762
137843
|
const allowanceMinutes = bootMinutes + bankedMinutes;
|
|
137763
137844
|
const leftMinutes = waitingOnYou ? Math.max(0, allowanceMinutes - min(clock.turnForMs)) : null;
|
|
137764
|
-
|
|
137845
|
+
const soon = leftMinutes !== null && bootSoon(leftMinutes, { allowanceMinutes, realTime: clock.realTime, opening });
|
|
137846
|
+
return {
|
|
137847
|
+
bootMinutes,
|
|
137848
|
+
bankedMinutes,
|
|
137849
|
+
allowanceMinutes,
|
|
137850
|
+
leftMinutes,
|
|
137851
|
+
...clock.realTime ? { realTime: true } : {},
|
|
137852
|
+
...opening ? { opening: true } : {},
|
|
137853
|
+
soon,
|
|
137854
|
+
...soon && opening ? { openingSoon: true } : {}
|
|
137855
|
+
};
|
|
137856
|
+
}
|
|
137857
|
+
function isOpening(stateCode, lastTurn) {
|
|
137858
|
+
return stateCode === GAME_DISTRIBUTING || stateCode === GAME_PLAYING && lastTurn + 1 >= 1 && lastTurn + 1 <= OPENING_LAST_TURN;
|
|
137765
137859
|
}
|
|
137766
137860
|
function minutesText(m) {
|
|
137767
137861
|
const d = Math.floor(m / 1440);
|
|
@@ -137784,7 +137878,7 @@ function summarizeMyGames(games, myInGameId2) {
|
|
|
137784
137878
|
const me = g.players.find((p) => p.id === myInGameId2);
|
|
137785
137879
|
const active = g.stateCode === GAME_PLAYING || g.stateCode === GAME_DISTRIBUTING;
|
|
137786
137880
|
const waitingOnYou = active && me !== void 0 && me.stateCode === PLAYER_PLAYING && !me.committed;
|
|
137787
|
-
const boot = active && me?.stateCode === PLAYER_PLAYING ? bootView(g.boot, waitingOnYou) : void 0;
|
|
137881
|
+
const boot = active && me?.stateCode === PLAYER_PLAYING ? bootView(g.boot, waitingOnYou, isOpening(g.stateCode, g.lastTurn)) : void 0;
|
|
137788
137882
|
return {
|
|
137789
137883
|
id: g.id,
|
|
137790
137884
|
name: g.name,
|
|
@@ -137801,8 +137895,10 @@ function summarizeMyGames(games, myInGameId2) {
|
|
|
137801
137895
|
};
|
|
137802
137896
|
});
|
|
137803
137897
|
const privateUnread = (g) => !g.waitingOnYou && g.unreadChat?.private === true;
|
|
137898
|
+
const openingSoon = (g) => g.waitingOnYou && g.boot?.openingSoon === true;
|
|
137804
137899
|
return [
|
|
137805
|
-
...out.filter((
|
|
137900
|
+
...out.filter(openingSoon).sort((a, b) => (a.boot?.leftMinutes ?? 0) - (b.boot?.leftMinutes ?? 0)),
|
|
137901
|
+
...out.filter((g) => g.waitingOnYou && !openingSoon(g)),
|
|
137806
137902
|
...out.filter(privateUnread),
|
|
137807
137903
|
...out.filter((g) => !g.waitingOnYou && !privateUnread(g))
|
|
137808
137904
|
];
|
|
@@ -137825,7 +137921,7 @@ function briefGameLine(game) {
|
|
|
137825
137921
|
const u = game.unreadChat;
|
|
137826
137922
|
const others = u ? ["public", "team", "group"].filter((c) => u[c]) : [];
|
|
137827
137923
|
const unread = (u?.private ? " \u2014 unread private" : "") + (others.length ? ` \u2014 unread ${others.join(", ")}` : "");
|
|
137828
|
-
const soon = game.boot?.soon && game.boot.leftMinutes !== null ? ` \u2014 boot in ${minutesText(game.boot.leftMinutes)}` : "";
|
|
137924
|
+
const soon = game.boot?.soon && game.boot.leftMinutes !== null ? ` \u2014 ${game.boot.openingSoon ? "opening turn, " : ""}boot in ${minutesText(game.boot.leftMinutes)}` : "";
|
|
137829
137925
|
const tail = ` \u2014 ${where} \u2014 ${game.waitingOnYou ? "waiting on you" : "waiting on others"}${soon}${unread}`;
|
|
137830
137926
|
const flat = game.name.replace(/\s+/g, " ").trim() || "(untitled)";
|
|
137831
137927
|
const escaped = flat.startsWith("-- ") || flat.startsWith("\\") ? `\\${flat}` : flat;
|
|
@@ -138634,12 +138730,14 @@ var bonusesOf = (graph) => new Map([...graph.bonusById.keys()].map((id) => [id,
|
|
|
138634
138730
|
async function capturePlan(ctx, a) {
|
|
138635
138731
|
if (!ctx.dataDir) return;
|
|
138636
138732
|
const opts = modeOf2(ctx);
|
|
138637
|
-
|
|
138733
|
+
const mapId = a.graph.map.id;
|
|
138734
|
+
const wrote = await recordDecision(
|
|
138638
138735
|
ctx.dataDir,
|
|
138639
138736
|
a.gameId,
|
|
138640
138737
|
a.me,
|
|
138641
138738
|
{
|
|
138642
138739
|
turn: a.turn,
|
|
138740
|
+
mapId,
|
|
138643
138741
|
board: a.board,
|
|
138644
138742
|
...a.plannedBoard ? { plannedBoard: a.plannedBoard } : {},
|
|
138645
138743
|
input: a.input,
|
|
@@ -138654,6 +138752,7 @@ async function capturePlan(ctx, a) {
|
|
|
138654
138752
|
},
|
|
138655
138753
|
opts
|
|
138656
138754
|
);
|
|
138755
|
+
if (wrote || existsSync3(decisionLogPath(ctx.dataDir, a.gameId))) await pinStoredMap(ctx.dataDir, mapId, a.gameId);
|
|
138657
138756
|
if (a.turn < 2) return;
|
|
138658
138757
|
try {
|
|
138659
138758
|
await fillOutcome(
|
|
@@ -152273,24 +152372,40 @@ var snapshots = /* @__PURE__ */ new WeakMap();
|
|
|
152273
152372
|
function rememberPace(owner, games, at2) {
|
|
152274
152373
|
snapshots.set(owner, {
|
|
152275
152374
|
at: at2,
|
|
152276
|
-
games: games.flatMap(
|
|
152375
|
+
games: games.flatMap(
|
|
152376
|
+
(g) => g.boot?.leftMinutes != null && !g.boot.realTime ? [
|
|
152377
|
+
{
|
|
152378
|
+
id: g.id,
|
|
152379
|
+
name: g.name,
|
|
152380
|
+
leftMinutes: g.boot.leftMinutes,
|
|
152381
|
+
allowanceMinutes: g.boot.allowanceMinutes,
|
|
152382
|
+
...g.boot.opening ? { opening: true } : {}
|
|
152383
|
+
}
|
|
152384
|
+
] : []
|
|
152385
|
+
)
|
|
152277
152386
|
});
|
|
152278
152387
|
}
|
|
152279
152388
|
function forgetPaceGame(owner, gameId) {
|
|
152280
152389
|
const s = snapshots.get(owner);
|
|
152281
152390
|
if (s) snapshots.set(owner, { ...s, games: s.games.filter((g) => g.id !== gameId) });
|
|
152282
152391
|
}
|
|
152283
|
-
var PACE_NOTE = `Read from the last game list this server read (warapp_my_games and the chat inbox read it): each game waiting on you whose boot time plus your banked time, less how long your turn has run, is under ${BOOT_WARN_MINUTES / 60} hours away now. Unverified live; call warapp_my_games for a fresh read.`;
|
|
152392
|
+
var PACE_NOTE = `Read from the last game list this server read (warapp_my_games and the chat inbox read it): each game waiting on you whose boot time plus your banked time, less how long your turn has run, is under ${BOOT_WARN_MINUTES / 60} hours away now, or (#504) an opening turn (picks, or turns 1 to ${OPENING_LAST_TURN}) with a quarter of that time or less left; real-time games are not kept. Unverified live; call warapp_my_games for a fresh read.`;
|
|
152284
152393
|
function paceStatus(owner, now) {
|
|
152285
152394
|
const s = snapshots.get(owner);
|
|
152286
152395
|
if (!s) return void 0;
|
|
152287
152396
|
const ago = Math.max(0, Math.floor((now - s.at) / 6e4));
|
|
152288
|
-
const
|
|
152289
|
-
|
|
152397
|
+
const bootSoon2 = s.games.map((g) => ({ ...g, leftMinutes: Math.max(0, g.leftMinutes - ago) })).filter((g) => bootSoon(g.leftMinutes, g)).sort((a, b) => Number(b.opening === true) - Number(a.opening === true) || a.leftMinutes - b.leftMinutes || a.id - b.id).map((g) => ({
|
|
152398
|
+
id: g.id,
|
|
152399
|
+
name: untrustedText(g.name),
|
|
152400
|
+
leftMinutes: g.leftMinutes,
|
|
152401
|
+
left: minutesText(g.leftMinutes),
|
|
152402
|
+
...g.opening ? { opening: true } : {}
|
|
152403
|
+
}));
|
|
152404
|
+
return { listReadMinutesAgo: ago, bootSoon: bootSoon2, note: PACE_NOTE };
|
|
152290
152405
|
}
|
|
152291
152406
|
function paceWarning(p) {
|
|
152292
152407
|
if (!p?.bootSoon.length) return void 0;
|
|
152293
|
-
return `Boot close: ${p.bootSoon.map((g) => `game ${g.id} in ${g.left}`).join(", ")} \u2014 take ${p.bootSoon.length === 1 ? "that turn" : "those turns"} (under ${BOOT_WARN_MINUTES / 60} hours left, boot time plus bank).`;
|
|
152408
|
+
return `Boot close: ${p.bootSoon.map((g) => `game ${g.id} in ${g.left}${g.opening ? " (opening turn)" : ""}`).join(", ")} \u2014 take ${p.bootSoon.length === 1 ? "that turn" : "those turns"} (under ${BOOT_WARN_MINUTES / 60} hours left, boot time plus bank${p.bootSoon.some((g) => g.opening) ? "; an opening turn from a quarter of its time left, and first: a missed one delays the first bonus" : ""}).`;
|
|
152294
152409
|
}
|
|
152295
152410
|
|
|
152296
152411
|
// src/tools/stress-opponents.ts
|
|
@@ -156907,7 +157022,7 @@ function registerMyGamesTool(server, ctx, deps = {}) {
|
|
|
156907
157022
|
{
|
|
156908
157023
|
title: "List my war.app games and which need me",
|
|
156909
157024
|
description: untrustedDescription(
|
|
156910
|
-
`Your war.app (Warzone) games, games waiting on you first: each with its id, name, state (WaitingForPlayers, DistributingTerritories, Playing, Finished), turn, players (name, state, whether they have committed this turn) and waitingOnYou \u2014 true when the game is being played or distributing territories, you are still playing, and you have not committed \u2014 and surrenderPending: the surrenders other players asked for that are still pending, each with owedByMe (true: waiting for you to accept it), read from the game details (unverified live; null when not read or unreadable, never "none"; empty without a read for a lobby, a finished game or a game you no longer play in, where none can wait on you); the top-level surrenderPending counts the games where one waits on you, and those games come first too. Each game also carries unreadChat, from the game list itself (no extra request): whether war.app shows unread chat per channel (public, team, private, group) and toMe (unread private chat is addressed to you) \u2014 flags, not counts; null when they did not read. Games with unread private chat come right after the ones waiting on you, and the top-level unreadPrivateGames counts them; read them with warapp_chat_inbox. A
|
|
157025
|
+
`Your war.app (Warzone) games, games waiting on you first: each with its id, name, state (WaitingForPlayers, DistributingTerritories, Playing, Finished), turn, players (name, state, whether they have committed this turn) and waitingOnYou \u2014 true when the game is being played or distributing territories, you are still playing, and you have not committed \u2014 and surrenderPending: the surrenders other players asked for that are still pending, each with owedByMe (true: waiting for you to accept it), read from the game details (unverified live; null when not read or unreadable, never "none"; empty without a read for a lobby, a finished game or a game you no longer play in, where none can wait on you); the top-level surrenderPending counts the games where one waits on you, and those games come first too. Each game also carries unreadChat, from the game list itself (no extra request): whether war.app shows unread chat per channel (public, team, private, group) and toMe (unread private chat is addressed to you) \u2014 flags, not counts; null when they did not read. Games with unread private chat come right after the ones waiting on you, and the top-level unreadPrivateGames counts them; read them with warapp_chat_inbox. A game being played or picked with your seat playing carries \`boot\` (pace, from the game list: its boot time, your banked time, their sum, and while it waits on you \`leftMinutes\`, the sum less how long your turn has run, with \`soon\` under 6 hours in a multi-day game; unverified live). #504: an opening turn (\`opening\`: picks, or turns 1 to 4, where a missed turn delays the first bonus) is also \`soon\` with a quarter of that time or less left, and then \`openingSoon\`: those games come first, soonest first, and \`openingBootSoon\` counts them; a real-time game (\`realTime\`) is \`soon\` only at a quarter or less. \`bootSoon\` counts the games close to a boot, and brief adds " \u2014 boot in \u2026" (" \u2014 opening turn, boot in \u2026") to them. Finished games are left out unless \`include_finished\` (\`finishedLeftOut\` counts them). \`listed\` is how many games war.app returned and \`complete\` false (with a \`warning\`) means the list may be partial. Use the id with the other warapp tools. Each call also gives up to two of your newest 250 finished games not yet processed their end-of-game pass (\`endOfGame\`: each game's history read once from GameFeed and kept name-free for later games; \`pending\` counts the rest). ${BRIDGE_NOTE} Read-only.`
|
|
156911
157026
|
),
|
|
156912
157027
|
_meta: canonicalMeta("whats-new", ["my games", "warzone", "whose turn", "games waiting on me", "which games need me"]),
|
|
156913
157028
|
annotations: readAnnotations("List my war.app games"),
|
|
@@ -156937,8 +157052,13 @@ function registerMyGamesTool(server, ctx, deps = {}) {
|
|
|
156937
157052
|
count: games.length,
|
|
156938
157053
|
waitingOnYou: games.filter((g) => g.waitingOnYou).length,
|
|
156939
157054
|
unreadPrivateGames: games.filter((g) => g.unreadChat?.private === true).length,
|
|
156940
|
-
// Pace:
|
|
156941
|
-
|
|
157055
|
+
// Pace: games close to a boot (boot time plus bank, less my turn so far): under six hours in a multi-day game,
|
|
157056
|
+
// and (#504) an opening or real-time turn from a quarter of its time left.
|
|
157057
|
+
...games.some((g) => g.boot) ? {
|
|
157058
|
+
bootSoon: games.filter((g) => g.boot?.soon).length,
|
|
157059
|
+
...games.some((g) => g.boot?.openingSoon) ? { openingBootSoon: games.filter((g) => g.boot?.openingSoon).length } : {},
|
|
157060
|
+
bootNote: BOOT_NOTE
|
|
157061
|
+
} : {},
|
|
156942
157062
|
surrenderPending: games.filter((g) => surrenderOwed(g.surrenderPending)).length,
|
|
156943
157063
|
surrenderNote: SURRENDER_PENDING_NOTE + (unread ? ` The details of ${unread} game(s) could not be read.` : "") + (skipped ? ` ${skipped} more game(s) were not read (at most ${MAX_SURRENDER_READS} per call).` : ""),
|
|
156944
157064
|
listed: raw.length,
|
|
@@ -162076,6 +162196,11 @@ function endedReason(game, playerId) {
|
|
|
162076
162196
|
if (me?.state !== void 0 && me.state !== "Playing") return `You are out of this game (your state: ${me.state}).`;
|
|
162077
162197
|
return void 0;
|
|
162078
162198
|
}
|
|
162199
|
+
function readyOrder(ready, bootSoon2) {
|
|
162200
|
+
const set2 = new Set(ready);
|
|
162201
|
+
const first = bootSoon2.map((g) => g.id).filter((id) => set2.has(id));
|
|
162202
|
+
return [...first, ...ready.filter((id) => !first.includes(id))];
|
|
162203
|
+
}
|
|
162079
162204
|
function checkOf(game, playerId, surrenders) {
|
|
162080
162205
|
const ended = endedReason(game, playerId);
|
|
162081
162206
|
return {
|
|
@@ -162249,7 +162374,7 @@ function registerPushTools(server, ctx, push, deps = {}) {
|
|
|
162249
162374
|
{
|
|
162250
162375
|
title: "Wait for my turn in war.app games",
|
|
162251
162376
|
description: untrustedDescription(
|
|
162252
|
-
"Wait until one of the given war.app (Warzone) games is waiting on you \u2014 the game is being played or its territories picked, you are still playing, and you have not committed \u2014 and return as soon as it is, or at the timeout (default 300 s, max 1800 s) \u2014 or at once with `game_over` when every game has finished or your seat is out (each says why in `ended`). It checks each game once at the start, then listens to war.app's push notifications \u2014 over a direct WebSocket while a linked war.app session serves calls, else through your signed-in war.app tab (ContextMint Bridge) \u2014 and re-checks a game whenever war.app says it changed, and every game after the push socket reconnects. It also returns (status `surrender_pending`) when another player's surrender waits for you to accept it (each game's `surrenderPending`, read from the game details, unverified live: null when unreadable, never \"none\"; empty without a read for a lobby, a finished game or one you no longer play in; after one failed read it stops asking for the rest of the wait and says why in `surrenderUnread`), unless `ignore_surrenders`. Pass the game ids to watch (1\u201320), or omit them to watch every game of yours being played or picked (the first 20, as warapp_my_games lists them). Reports progress while it waits and stops when the call is cancelled. Then plan with warapp_plan_turn (or pick with warapp_submit_picks). Read-only."
|
|
162377
|
+
"Wait until one of the given war.app (Warzone) games is waiting on you \u2014 the game is being played or its territories picked, you are still playing, and you have not committed \u2014 and return as soon as it is, or at the timeout (default 300 s, max 1800 s) \u2014 or at once with `game_over` when every game has finished or your seat is out (each says why in `ended`). It checks each game once at the start, then listens to war.app's push notifications \u2014 over a direct WebSocket while a linked war.app session serves calls, else through your signed-in war.app tab (ContextMint Bridge) \u2014 and re-checks a game whenever war.app says it changed, and every game after the push socket reconnects. It also returns (status `surrender_pending`) when another player's surrender waits for you to accept it (each game's `surrenderPending`, read from the game details, unverified live: null when unreadable, never \"none\"; empty without a read for a lobby, a finished game or one you no longer play in; after one failed read it stops asking for the rest of the wait and says why in `surrenderUnread`), unless `ignore_surrenders`. #504: `bootSoon` names the watched games close to a boot as the last game list read saw them (no request of its own; omitted without one): opening turns first (`opening`: picks or turns 1 to 4, from a quarter of the time left), then under 6 hours; take those turns first. Pass the game ids to watch (1\u201320), or omit them to watch every game of yours being played or picked (the first 20, as warapp_my_games lists them). Reports progress while it waits and stops when the call is cancelled. Then plan with warapp_plan_turn (or pick with warapp_submit_picks). Read-only."
|
|
162253
162378
|
),
|
|
162254
162379
|
_meta: mintMeta("whats-new", ["is it my turn", "wait for my turn", "tell me when it is my turn", "warzone turn ready"]),
|
|
162255
162380
|
annotations: readAnnotations("Wait for my war.app turn"),
|
|
@@ -162316,10 +162441,13 @@ function registerPushTools(server, ctx, push, deps = {}) {
|
|
|
162316
162441
|
...progress ? { progress } : {}
|
|
162317
162442
|
});
|
|
162318
162443
|
const st = push.status();
|
|
162444
|
+
const watched = new Set(ids2);
|
|
162445
|
+
const bootSoon2 = (paceStatus(ctx, Date.now())?.bootSoon ?? []).filter((g) => watched.has(g.id));
|
|
162319
162446
|
return respond(void 0, VIEWS13, () => ({
|
|
162320
162447
|
status: out.status,
|
|
162321
162448
|
watching: ids2,
|
|
162322
|
-
...out.status === "your_turn" ? { ready: out.games.filter((g) => g.waitingOnYou).map((g) => g.id) } : {},
|
|
162449
|
+
...out.status === "your_turn" ? { ready: readyOrder(out.games.filter((g) => g.waitingOnYou).map((g) => g.id), bootSoon2) } : {},
|
|
162450
|
+
...bootSoon2.length ? { bootSoon: bootSoon2 } : {},
|
|
162323
162451
|
// #317: the games where a surrender waits on my acceptance, whatever the status.
|
|
162324
162452
|
...out.games.some((g) => g.surrenderOwed) ? { surrenders: out.games.filter((g) => g.surrenderOwed).map((g) => g.id) } : {},
|
|
162325
162453
|
games: out.games.map((g) => out.chatActivity.includes(g.id) ? { ...g, chatActivity: true } : g),
|
|
@@ -165274,6 +165402,30 @@ function seatBand(seats) {
|
|
|
165274
165402
|
if (seats === null || seats < 2) return "unknown";
|
|
165275
165403
|
return seats === 2 ? "2" : seats <= 6 ? "3-6" : seats <= 16 ? "7-16" : "17-up";
|
|
165276
165404
|
}
|
|
165405
|
+
var HELD_BY = ["after-tracker", "rise-cap", "tripwire", "window", "ceiling", "ambiguous", "readings", "no-track", "unlogged"];
|
|
165406
|
+
function heldByOf(estimate, truth, track, stages) {
|
|
165407
|
+
const target = CATCH_UP_SHARE * truth;
|
|
165408
|
+
if (truth <= 0 || estimate >= target) return null;
|
|
165409
|
+
if (!track) return stages && stages.tracked === null ? "no-track" : "unlogged";
|
|
165410
|
+
if (track.income === null || !track.window.length) return "no-track";
|
|
165411
|
+
if (track.income >= target) return "after-tracker";
|
|
165412
|
+
const most = (f) => Math.max(...track.window.map(f));
|
|
165413
|
+
if (most((x) => x.observed) >= target) return track.rise ? "rise-cap" : track.trip ? "tripwire" : "window";
|
|
165414
|
+
if (most((x) => Math.max(x.raw, x.high)) >= target && most((x) => x.cap) < target) return "ceiling";
|
|
165415
|
+
if (most((x) => Math.min(x.high, x.cap)) >= target) return "ambiguous";
|
|
165416
|
+
return "readings";
|
|
165417
|
+
}
|
|
165418
|
+
function heldByView(samples) {
|
|
165419
|
+
const low = samples.filter((s) => s.heldBy !== null);
|
|
165420
|
+
const named3 = low.filter((s) => s.heldBy !== "unlogged");
|
|
165421
|
+
const steps = {};
|
|
165422
|
+
for (const step of HELD_BY) {
|
|
165423
|
+
if (step === "unlogged") continue;
|
|
165424
|
+
const n = named3.filter((s) => s.heldBy === step).length;
|
|
165425
|
+
if (n) steps[step] = { n, share: r3(n / named3.length) };
|
|
165426
|
+
}
|
|
165427
|
+
return { low: low.length, steps, unlogged: low.length - named3.length };
|
|
165428
|
+
}
|
|
165277
165429
|
var r3 = (x) => Math.round(x * 1e3) / 1e3;
|
|
165278
165430
|
function errorView(samples) {
|
|
165279
165431
|
const n = samples.length;
|
|
@@ -165321,7 +165473,8 @@ function incomeSamples(games) {
|
|
|
165321
165473
|
thin: a.thin,
|
|
165322
165474
|
method: logged2.get(a.player)?.method ?? null,
|
|
165323
165475
|
leader: top !== null && a.truth >= top,
|
|
165324
|
-
stages: logged2.get(a.player)?.stages ?? null
|
|
165476
|
+
stages: logged2.get(a.player)?.stages ?? null,
|
|
165477
|
+
heldBy: heldByOf(a.estimate, a.truth, logged2.get(a.player)?.track, logged2.get(a.player)?.stages ?? null)
|
|
165325
165478
|
});
|
|
165326
165479
|
}
|
|
165327
165480
|
}
|
|
@@ -165331,6 +165484,7 @@ function incomeSamples(games) {
|
|
|
165331
165484
|
function catchUp(games) {
|
|
165332
165485
|
const lagsList = [];
|
|
165333
165486
|
let censored = 0;
|
|
165487
|
+
let unwatched = 0;
|
|
165334
165488
|
for (const g of games) {
|
|
165335
165489
|
const turns = turnKeys2(g.turns);
|
|
165336
165490
|
const truth = /* @__PURE__ */ new Map();
|
|
@@ -165347,6 +165501,10 @@ function catchUp(games) {
|
|
|
165347
165501
|
for (const [t, income] of [...series].sort((a, b) => a[0] - b[0])) {
|
|
165348
165502
|
const before = series.get(t - 1);
|
|
165349
165503
|
if (before === void 0 || before <= 0 || income < JUMP_FACTOR * before || t > last) continue;
|
|
165504
|
+
if (!estimates.has(t)) {
|
|
165505
|
+
unwatched++;
|
|
165506
|
+
continue;
|
|
165507
|
+
}
|
|
165350
165508
|
let lag = null;
|
|
165351
165509
|
for (const u of [...estimates.keys()].filter((u2) => u2 >= t).sort((a, b) => a - b)) {
|
|
165352
165510
|
const truthU = series.get(u) ?? income;
|
|
@@ -165370,7 +165528,8 @@ function catchUp(games) {
|
|
|
165370
165528
|
meanLag: n ? r3(sorted.reduce((s, x) => s + x, 0) / n) : null,
|
|
165371
165529
|
medianLag: n ? n % 2 ? sorted[n >> 1] : (sorted[(n >> 1) - 1] + sorted[n >> 1]) / 2 : null,
|
|
165372
165530
|
lags,
|
|
165373
|
-
censored
|
|
165531
|
+
censored,
|
|
165532
|
+
unwatched
|
|
165374
165533
|
};
|
|
165375
165534
|
}
|
|
165376
165535
|
function consequences(games) {
|
|
@@ -165486,7 +165645,8 @@ function incomeCalibration(games) {
|
|
|
165486
165645
|
consequences: consequences(games),
|
|
165487
165646
|
worst,
|
|
165488
165647
|
byStage: stageErrors(samples),
|
|
165489
|
-
trackedWhatIf: trackedWhatIf(samples)
|
|
165648
|
+
trackedWhatIf: trackedWhatIf(samples),
|
|
165649
|
+
heldBy: heldByView(samples)
|
|
165490
165650
|
};
|
|
165491
165651
|
}
|
|
165492
165652
|
|
|
@@ -165958,7 +166118,7 @@ function registerCalibrationTool(server, dataDir2) {
|
|
|
165958
166118
|
{
|
|
165959
166119
|
title: "Score the income estimates against finished games",
|
|
165960
166120
|
_meta: mintMeta("lookup", ["how accurate are the income estimates", "calibrate opponent income", "estimate accuracy"]),
|
|
165961
|
-
description: `Score the opponent income estimates this server planned with against the truth its finished games kept (the decision log's end-of-game truth): each estimate \xF7 the true income, and its signed error in armies, overall and by format, seats, phase (turns 1\u20134, 5\u201310, 11+), frontier coverage band, estimate source, thin evidence, the tracker's income method (rise-capped or not; logged since #569), leader vs trailer, and phase by coverage; the catch-up lag after a true income jump of 1.5\xD7 or more (turns until the estimate reaches two thirds of the truth); a consequences proxy (turns that lost a territory the plan did not concede, with an estimate under half the truth vs without); the largest misses; each pipeline stage's figure \xF7 the truth (visible, observed, tracked, prior, stated, blend, thin, known; logged since #568); and what correcting the tracked figure by its coverage band would have read at dampings 0 to 1 (leave one game out). \`samples: true\` adds the scored rows (at most ${MAX_SAMPLES}), name-free, as a fixture set; \`harness: true\` also runs the #318 harness over the cached boards (tracker, fog prior and plan estimate by coverage band, and the opening benchmark), which can take a while on many games. Games are numbered by their place in the report, never by id, and no player is named. Makes no war.app request and writes nothing. Read-only.`,
|
|
166121
|
+
description: `Score the opponent income estimates this server planned with against the truth its finished games kept (the decision log's end-of-game truth): each estimate \xF7 the true income, and its signed error in armies, overall and by format, seats, phase (turns 1\u20134, 5\u201310, 11+), frontier coverage band, estimate source, thin evidence, the tracker's income method (rise-capped or not; logged since #569), leader vs trailer, and phase by coverage; the catch-up lag after a true income jump of 1.5\xD7 or more (turns until the estimate reaches two thirds of the truth; only jumps on a planned turn, the rest counted as unwatched); a consequences proxy (turns that lost a territory the plan did not concede, with an estimate under half the truth vs without); the largest misses; each pipeline stage's figure \xF7 the truth (visible, observed, tracked, prior, stated, blend, thin, known; logged since #568); for each estimate under two thirds of the truth, the tracker step that held it (rise cap, tripwire, window, could-earn ceiling, ambiguous armies, readings, a later stage, or no track; logged since #586); and what correcting the tracked figure by its coverage band would have read at dampings 0 to 1 (leave one game out). \`samples: true\` adds the scored rows (at most ${MAX_SAMPLES}), name-free, as a fixture set; \`harness: true\` also runs the #318 harness over the cached boards (tracker, fog prior and plan estimate by coverage band, and the opening benchmark), which can take a while on many games. Games are numbered by their place in the report, never by id, and no player is named. Makes no war.app request and writes nothing. Read-only.`,
|
|
165962
166122
|
annotations: toolAnnotations({ title: "Income estimate calibration", readOnly: true, destructive: false, idempotent: true, openWorld: false }),
|
|
165963
166123
|
inputSchema: external_exports.object({
|
|
165964
166124
|
samples: external_exports.boolean().optional().describe(`Also return the scored rows, name-free (default false; at most ${MAX_SAMPLES}).`),
|
package/dist/decision-log.js
CHANGED
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
import { open, readdir, readFile, stat, unlink } from 'node:fs/promises';
|
|
58
58
|
import { join } from 'node:path';
|
|
59
59
|
import { estimateOff } from './analysis/decision-truth.js';
|
|
60
|
-
import { writeJsonAtomic } from './map-store.js';
|
|
60
|
+
import { unpinGames, writeJsonAtomic } from './map-store.js';
|
|
61
61
|
import { withPathLock } from './path-lock.js';
|
|
62
62
|
import { serverBuild } from './build-id.js';
|
|
63
63
|
import { VERSION } from './version.js';
|
|
@@ -241,6 +241,10 @@ export function decodeInput(logged, board, graph) {
|
|
|
241
241
|
/** The estimates as logged: ids, figures and flags only. */
|
|
242
242
|
export function loggedEstimates(estimates, tracks) {
|
|
243
243
|
const methods = new Map((tracks ?? []).flatMap((t) => (t.incomeMethod ? [[t.playerId, t.incomeMethod]] : [])));
|
|
244
|
+
const internals = new Map((tracks ?? []).flatMap((t) => {
|
|
245
|
+
const logged = loggedTrack(t);
|
|
246
|
+
return logged ? [[t.playerId, logged]] : [];
|
|
247
|
+
}));
|
|
244
248
|
return [...estimates]
|
|
245
249
|
.sort((a, b) => a.playerId - b.playerId)
|
|
246
250
|
.map((e) => ({
|
|
@@ -251,8 +255,39 @@ export function loggedEstimates(estimates, tracks) {
|
|
|
251
255
|
thin: !!e.thinEvidence,
|
|
252
256
|
...(methods.has(e.playerId) ? { method: methods.get(e.playerId) } : {}),
|
|
253
257
|
stages: estimateStages(e),
|
|
258
|
+
...(internals.has(e.playerId) ? { track: internals.get(e.playerId) } : {}),
|
|
254
259
|
}));
|
|
255
260
|
}
|
|
261
|
+
/** #586: {@link LoggedTrack} of one track; `undefined` for a track with no income field (one built by hand). */
|
|
262
|
+
export function loggedTrack(t) {
|
|
263
|
+
if (t.income === undefined)
|
|
264
|
+
return undefined;
|
|
265
|
+
const window = new Set(t.incomeTurns ?? []);
|
|
266
|
+
const turns = (t.turns ?? []).filter((x) => window.has(x.from));
|
|
267
|
+
return {
|
|
268
|
+
income: t.income,
|
|
269
|
+
window: turns.map((x) => ({
|
|
270
|
+
turn: x.from,
|
|
271
|
+
observed: x.observed,
|
|
272
|
+
raw: x.raw,
|
|
273
|
+
low: x.low,
|
|
274
|
+
high: x.high,
|
|
275
|
+
cap: x.cap,
|
|
276
|
+
coverage: x.coverage?.share ?? null,
|
|
277
|
+
...(x.captureFloor !== undefined ? { captureFloor: x.captureFloor } : {}),
|
|
278
|
+
...(x.accounted ? { accounted: true } : {}),
|
|
279
|
+
...(x.fogCaptures ? { fogCaptures: x.fogCaptures.income } : {}),
|
|
280
|
+
})),
|
|
281
|
+
...(t.incomeLowered ? { lowered: t.incomeLowered } : {}),
|
|
282
|
+
...(t.incomeRise ? { rise: { ...t.incomeRise } } : {}),
|
|
283
|
+
...(t.observedLow ? { observedLow: { ...t.observedLow } } : {}),
|
|
284
|
+
...(t.incomeTrip ? { trip: { ...t.incomeTrip } } : {}),
|
|
285
|
+
...(t.incomeJump
|
|
286
|
+
? { jump: { turn: t.incomeJump.turn, observed: t.incomeJump.observed, before: t.incomeJump.before, verdict: t.incomeJump.verdict } }
|
|
287
|
+
: {}),
|
|
288
|
+
...(typeof t.topUp === 'number' ? { topUp: t.topUp } : {}),
|
|
289
|
+
};
|
|
290
|
+
}
|
|
256
291
|
/** My income as `input` gives it, card armies out; `undefined` when it holds none. */
|
|
257
292
|
function earnedIncome(input) {
|
|
258
293
|
const { income, cardArmies } = (input ?? {});
|
|
@@ -330,6 +365,7 @@ function logOf(c, gameId) {
|
|
|
330
365
|
...(isRec(c.join) ? { join: c.join } : {}),
|
|
331
366
|
...(isRec(c.opponents) ? { opponents: c.opponents } : {}),
|
|
332
367
|
...(isRec(c.picks) ? { picks: c.picks } : {}),
|
|
368
|
+
...(isInt(c.mapId) ? { mapId: c.mapId } : {}),
|
|
333
369
|
};
|
|
334
370
|
}
|
|
335
371
|
/** Whether a log holds anything: a turn, or per-game context (#437). */
|
|
@@ -442,7 +478,7 @@ export async function recordDecision(dir, gameId, playerId, rec, opts = {}) {
|
|
|
442
478
|
[String(rec.turn)]: { ...entry, ...(was?.chat ? { chat: was.chat } : {}), ...(was?.checks ? { checks: was.checks } : {}) },
|
|
443
479
|
};
|
|
444
480
|
encodeBoards(turns, boards);
|
|
445
|
-
return { ...log, turns };
|
|
481
|
+
return { ...log, ...(rec.mapId !== undefined ? { mapId: rec.mapId } : {}), turns };
|
|
446
482
|
}, opts);
|
|
447
483
|
}
|
|
448
484
|
catch {
|
|
@@ -1128,5 +1164,7 @@ export async function pruneDecisionLogs(dir, caps = {}) {
|
|
|
1128
1164
|
// Gone already, or not removable: leave it.
|
|
1129
1165
|
}
|
|
1130
1166
|
}
|
|
1167
|
+
// #586: a pruned log no longer keeps its map pinned.
|
|
1168
|
+
await unpinGames(dir, removed);
|
|
1131
1169
|
return removed;
|
|
1132
1170
|
}
|
package/dist/map-store.js
CHANGED
|
@@ -20,6 +20,10 @@
|
|
|
20
20
|
// - `<dataDir>/maps/games.json`: `{ version: 1, games: [[gameId, mapId], …] }`, newest last, at most
|
|
21
21
|
// MAX_GAME_INDEX entries — which map a game is on, so a game seen before a restart is still asked
|
|
22
22
|
// `GetMap=false`.
|
|
23
|
+
// - `<dataDir>/maps/pinned.json` (#586): `{ version: 1, pins: [[gameId, mapId], …] }`, newest last, at most
|
|
24
|
+
// MAX_PINNED_GAMES entries — the maps of games with a decision log (src/decision-log.ts), pinned when a turn
|
|
25
|
+
// is planned and unpinned when the log is pruned. A pinned map is never evicted and does not count toward
|
|
26
|
+
// MAX_STORED_MAPS, so a logged game can still be replayed offline after many other maps were used.
|
|
23
27
|
//
|
|
24
28
|
// Files are 0600 in a 0700 folder and written atomically; every read is loose (a bad file is ignored,
|
|
25
29
|
// and replaced by the next write) and nothing here throws. Another process sharing the data directory
|
|
@@ -34,6 +38,8 @@ export const MAX_STORED_MAPS = 40;
|
|
|
34
38
|
export const MAX_MAP_AGE_MS = 30 * 24 * 60 * 60 * 1000;
|
|
35
39
|
/** Game → map entries kept in the index; the oldest goes first. */
|
|
36
40
|
export const MAX_GAME_INDEX = 500;
|
|
41
|
+
/** #586: games whose map is pinned; the oldest pin goes first. As many as the decision log keeps games (1000). */
|
|
42
|
+
export const MAX_PINNED_GAMES = 1000;
|
|
37
43
|
const VERSION = 1;
|
|
38
44
|
const MAP_FILE = /^\d+\.json$/;
|
|
39
45
|
const isRec = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
@@ -42,6 +48,7 @@ const isIntArray = (v) => Array.isArray(v) && v.every(isInt);
|
|
|
42
48
|
export const mapsDir = (dir) => join(dir, 'maps');
|
|
43
49
|
export const mapStorePath = (dir, mapId) => join(mapsDir(dir), `${mapId}.json`);
|
|
44
50
|
const indexPath = (dir) => join(mapsDir(dir), 'games.json');
|
|
51
|
+
const pinsPath = (dir) => join(mapsDir(dir), 'pinned.json');
|
|
45
52
|
/** Write `body` as JSON at `path` atomically (0600; folder 0700). */
|
|
46
53
|
export async function writeJsonAtomic(path, folder, body) {
|
|
47
54
|
await mkdir(folder, { recursive: true, mode: 0o700 });
|
|
@@ -140,12 +147,16 @@ export async function readStoredMapEntry(dir, mapId, opts = {}) {
|
|
|
140
147
|
return undefined;
|
|
141
148
|
}
|
|
142
149
|
}
|
|
143
|
-
/**
|
|
150
|
+
/**
|
|
151
|
+
* Delete the least recently used maps beyond {@link MAX_STORED_MAPS}, keeping `keep` and every pinned map (#586),
|
|
152
|
+
* which do not count toward the cap. Best effort.
|
|
153
|
+
*/
|
|
144
154
|
async function evictMaps(dir, keep) {
|
|
145
155
|
const folder = mapsDir(dir);
|
|
156
|
+
const pinned = new Set((await readPins(dir)).map(([, m]) => `${m}.json`));
|
|
146
157
|
const files = [];
|
|
147
158
|
for (const name of await readdir(folder)) {
|
|
148
|
-
if (!MAP_FILE.test(name))
|
|
159
|
+
if (!MAP_FILE.test(name) || pinned.has(name))
|
|
149
160
|
continue;
|
|
150
161
|
try {
|
|
151
162
|
files.push({ name, at: (await stat(join(folder, name))).mtimeMs });
|
|
@@ -240,3 +251,59 @@ export async function rememberGameMap(dir, gameId, mapId) {
|
|
|
240
251
|
return false;
|
|
241
252
|
}
|
|
242
253
|
}
|
|
254
|
+
/** #586: the pins, loosely: unusable entries are dropped. */
|
|
255
|
+
async function readPins(dir) {
|
|
256
|
+
try {
|
|
257
|
+
const raw = JSON.parse(await readFile(pinsPath(dir), 'utf8'));
|
|
258
|
+
if (!isRec(raw) || raw.version !== VERSION || !Array.isArray(raw.pins))
|
|
259
|
+
return [];
|
|
260
|
+
return raw.pins.filter((e) => Array.isArray(e) && e.length === 2 && isInt(e[0]) && isInt(e[1]));
|
|
261
|
+
}
|
|
262
|
+
catch {
|
|
263
|
+
return [];
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
/** #586: the map ids pinned by a game's decision log. Never throws. */
|
|
267
|
+
export async function pinnedMapIds(dir) {
|
|
268
|
+
return new Set((await readPins(dir)).map(([, m]) => m));
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* #586: pin `mapId` for `gameId` (a game with a decision log), so the stored map is never evicted while the log is
|
|
272
|
+
* kept; an existing pin for the game is moved to the newest. `true` when written (`false` when already pinned so,
|
|
273
|
+
* or on failure); never throws.
|
|
274
|
+
*/
|
|
275
|
+
export async function pinStoredMap(dir, mapId, gameId) {
|
|
276
|
+
try {
|
|
277
|
+
return await withPathLock(pinsPath(dir), async () => {
|
|
278
|
+
const pins = await readPins(dir);
|
|
279
|
+
if (pins.some(([g, m]) => g === gameId && m === mapId))
|
|
280
|
+
return false;
|
|
281
|
+
const next = pins.filter(([g]) => g !== gameId);
|
|
282
|
+
next.push([gameId, mapId]);
|
|
283
|
+
await writeJsonAtomic(pinsPath(dir), mapsDir(dir), { version: VERSION, pins: next.slice(-MAX_PINNED_GAMES) });
|
|
284
|
+
return true;
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
catch {
|
|
288
|
+
return false;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
/** #586: drop the pins of `gameIds` (their decision logs were pruned). `true` when written; never throws. */
|
|
292
|
+
export async function unpinGames(dir, gameIds) {
|
|
293
|
+
if (!gameIds.length)
|
|
294
|
+
return false;
|
|
295
|
+
const gone = new Set(gameIds);
|
|
296
|
+
try {
|
|
297
|
+
return await withPathLock(pinsPath(dir), async () => {
|
|
298
|
+
const pins = await readPins(dir);
|
|
299
|
+
const next = pins.filter(([g]) => !gone.has(g));
|
|
300
|
+
if (next.length === pins.length)
|
|
301
|
+
return false;
|
|
302
|
+
await writeJsonAtomic(pinsPath(dir), mapsDir(dir), { version: VERSION, pins: next });
|
|
303
|
+
return true;
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
catch {
|
|
307
|
+
return false;
|
|
308
|
+
}
|
|
309
|
+
}
|
package/dist/my-games.js
CHANGED
|
@@ -160,19 +160,54 @@ function bootClockOf(f) {
|
|
|
160
160
|
}
|
|
161
161
|
/** Under this many minutes left before a boot, a game is reported as close to one (and `warapp_session_status` warns). */
|
|
162
162
|
export const BOOT_WARN_MINUTES = 6 * 60;
|
|
163
|
+
/**
|
|
164
|
+
* #504: the last turn counted as the opening. A missed turn 1–4 delays the first bonus by a turn or more (three of
|
|
165
|
+
* the twelve games whose first bonus came after the winner's had one), so those turns are flagged earlier.
|
|
166
|
+
*/
|
|
167
|
+
export const OPENING_LAST_TURN = 4;
|
|
168
|
+
/** #504: an opening turn (or a real-time turn) is close to a boot with this share of its allowance or less left. */
|
|
169
|
+
export const BOOT_SHARE_WARN = 0.25;
|
|
163
170
|
export const BOOT_NOTE = "From the game list: the game's boot time plus your banked time, less how long your turn has run (the web client " +
|
|
164
|
-
'shows the first two together beside each game). Banked time is eaten once the boot time is spent.
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
171
|
+
'shows the first two together beside each game). Banked time is eaten once the boot time is spent. A multi-day ' +
|
|
172
|
+
`game is close to a boot under ${BOOT_WARN_MINUTES / 60} hours left; an opening turn (picks, or turns 1 to ` +
|
|
173
|
+
`${OPENING_LAST_TURN}: a missed one delays the first bonus) or a real-time turn also with a quarter of its time or ` +
|
|
174
|
+
"less left (#504). The fields are read from war.app's client; the arithmetic is unverified live, and for a real-time " +
|
|
175
|
+
'game unverified at all.';
|
|
176
|
+
/**
|
|
177
|
+
* #504: whether `leftMinutes` is close to a boot: under {@link BOOT_WARN_MINUTES} in a multi-day game, and in an
|
|
178
|
+
* opening turn or a real-time game also at a quarter of the allowance or less (a real-time turn has no six-hour line).
|
|
179
|
+
*/
|
|
180
|
+
export function bootSoon(leftMinutes, g) {
|
|
181
|
+
const byShare = (g.opening || g.realTime) === true && leftMinutes <= g.allowanceMinutes * BOOT_SHARE_WARN;
|
|
182
|
+
return byShare || (!g.realTime && leftMinutes < BOOT_WARN_MINUTES);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* A game's boot view, or undefined: no boot time, the clock unread, or not a game I play. `opening`: the game is
|
|
186
|
+
* picking territories or on turns 1–{@link OPENING_LAST_TURN} (#504; a real-time game is reported since #504 too).
|
|
187
|
+
*/
|
|
188
|
+
export function bootView(clock, waitingOnYou, opening = false) {
|
|
189
|
+
if (!clock || !(clock.bootMs > 0) || clock.bootMs >= NEVER_MS)
|
|
169
190
|
return undefined;
|
|
170
191
|
const min = (ms) => Math.max(0, Math.floor(ms / 60_000));
|
|
171
192
|
const bootMinutes = min(clock.bootMs);
|
|
172
193
|
const bankedMinutes = clock.bankedMs >= NEVER_MS ? 0 : min(clock.bankedMs);
|
|
173
194
|
const allowanceMinutes = bootMinutes + bankedMinutes;
|
|
174
195
|
const leftMinutes = waitingOnYou ? Math.max(0, allowanceMinutes - min(clock.turnForMs)) : null;
|
|
175
|
-
|
|
196
|
+
const soon = leftMinutes !== null && bootSoon(leftMinutes, { allowanceMinutes, realTime: clock.realTime, opening });
|
|
197
|
+
return {
|
|
198
|
+
bootMinutes,
|
|
199
|
+
bankedMinutes,
|
|
200
|
+
allowanceMinutes,
|
|
201
|
+
leftMinutes,
|
|
202
|
+
...(clock.realTime ? { realTime: true } : {}),
|
|
203
|
+
...(opening ? { opening: true } : {}),
|
|
204
|
+
soon,
|
|
205
|
+
...(soon && opening ? { openingSoon: true } : {}),
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
/** #504: picking territories, or playing turns 1 to {@link OPENING_LAST_TURN}. */
|
|
209
|
+
export function isOpening(stateCode, lastTurn) {
|
|
210
|
+
return stateCode === GAME_DISTRIBUTING || (stateCode === GAME_PLAYING && lastTurn + 1 >= 1 && lastTurn + 1 <= OPENING_LAST_TURN);
|
|
176
211
|
}
|
|
177
212
|
/** Minutes as `2d 3h`, `5h 20m` or `45m`. */
|
|
178
213
|
export function minutesText(m) {
|
|
@@ -207,7 +242,7 @@ export function summarizeMyGames(games, myInGameId) {
|
|
|
207
242
|
const me = g.players.find((p) => p.id === myInGameId);
|
|
208
243
|
const active = g.stateCode === GAME_PLAYING || g.stateCode === GAME_DISTRIBUTING;
|
|
209
244
|
const waitingOnYou = active && me !== undefined && me.stateCode === PLAYER_PLAYING && !me.committed;
|
|
210
|
-
const boot = active && me?.stateCode === PLAYER_PLAYING ? bootView(g.boot, waitingOnYou) : undefined;
|
|
245
|
+
const boot = active && me?.stateCode === PLAYER_PLAYING ? bootView(g.boot, waitingOnYou, isOpening(g.stateCode, g.lastTurn)) : undefined;
|
|
211
246
|
return {
|
|
212
247
|
id: g.id,
|
|
213
248
|
name: g.name,
|
|
@@ -223,10 +258,13 @@ export function summarizeMyGames(games, myInGameId) {
|
|
|
223
258
|
...(boot ? { boot } : {}),
|
|
224
259
|
};
|
|
225
260
|
});
|
|
226
|
-
// Waiting on me first
|
|
261
|
+
// Waiting on me first — #504: an opening turn close to a boot before the rest, soonest first — then unread
|
|
262
|
+
// private chat, then the rest (war.app's order within each).
|
|
227
263
|
const privateUnread = (g) => !g.waitingOnYou && g.unreadChat?.private === true;
|
|
264
|
+
const openingSoon = (g) => g.waitingOnYou && g.boot?.openingSoon === true;
|
|
228
265
|
return [
|
|
229
|
-
...out.filter((
|
|
266
|
+
...out.filter(openingSoon).sort((a, b) => (a.boot?.leftMinutes ?? 0) - (b.boot?.leftMinutes ?? 0)),
|
|
267
|
+
...out.filter((g) => g.waitingOnYou && !openingSoon(g)),
|
|
230
268
|
...out.filter(privateUnread),
|
|
231
269
|
...out.filter((g) => !g.waitingOnYou && !privateUnread(g)),
|
|
232
270
|
];
|
|
@@ -281,7 +319,9 @@ export function briefGameLine(game) {
|
|
|
281
319
|
const u = game.unreadChat;
|
|
282
320
|
const others = u ? ['public', 'team', 'group'].filter((c) => u[c]) : [];
|
|
283
321
|
const unread = (u?.private ? ' — unread private' : '') + (others.length ? ` — unread ${others.join(', ')}` : '');
|
|
284
|
-
const soon = game.boot?.soon && game.boot.leftMinutes !== null
|
|
322
|
+
const soon = game.boot?.soon && game.boot.leftMinutes !== null
|
|
323
|
+
? ` — ${game.boot.openingSoon ? 'opening turn, ' : ''}boot in ${minutesText(game.boot.leftMinutes)}`
|
|
324
|
+
: '';
|
|
285
325
|
const tail = ` — ${where} — ${game.waitingOnYou ? 'waiting on you' : 'waiting on others'}${soon}${unread}`;
|
|
286
326
|
const flat = game.name.replace(/\s+/g, ' ').trim() || '(untitled)';
|
|
287
327
|
const escaped = flat.startsWith('-- ') || flat.startsWith('\\') ? `\\${flat}` : flat;
|
package/dist/review-export.js
CHANGED
|
@@ -97,7 +97,7 @@ export async function reviewGame(dir, gameId, opts = {}) {
|
|
|
97
97
|
const found = await findFinished(dir, salt, gameId, cached, game);
|
|
98
98
|
const me = cached ?? found.me;
|
|
99
99
|
const finished = typeof found.record === 'object' ? found.record : null;
|
|
100
|
-
const mapId = finished?.mapId ?? game?.settings?.mapId;
|
|
100
|
+
const mapId = finished?.mapId ?? game?.settings?.mapId ?? log?.mapId;
|
|
101
101
|
const stored = mapId !== undefined ? await readStoredMap(dir, mapId, { maxAgeMs: Number.POSITIVE_INFINITY }) : undefined;
|
|
102
102
|
const key = salt && me !== undefined ? finishedGameKey(salt, me, gameId) : undefined;
|
|
103
103
|
const mapRecord = mapId !== undefined ? keyedEntry(mapRecordPath(dir, mapId), await readMapRecord(dir, mapId), key) : { state: 'missing', value: null };
|
|
@@ -64,9 +64,12 @@ export function registerCalibrationTool(server, dataDir) {
|
|
|
64
64
|
'overall and by format, seats, phase (turns 1–4, 5–10, 11+), frontier coverage band, estimate source, thin ' +
|
|
65
65
|
'evidence, the tracker\'s income method (rise-capped or not; logged since #569), leader vs trailer, and phase ' +
|
|
66
66
|
'by coverage; the catch-up lag after a true income jump of 1.5× or more (turns until the estimate reaches two ' +
|
|
67
|
-
'thirds of the truth
|
|
67
|
+
'thirds of the truth; only jumps on a planned turn, the rest counted as unwatched); a consequences proxy ' +
|
|
68
|
+
'(turns that lost a territory the plan did not concede, with an ' +
|
|
68
69
|
'estimate under half the truth vs without); the largest misses; each pipeline stage\'s figure ÷ the truth ' +
|
|
69
|
-
'(visible, observed, tracked, prior, stated, blend, thin, known; logged since #568);
|
|
70
|
+
'(visible, observed, tracked, prior, stated, blend, thin, known; logged since #568); for each estimate under ' +
|
|
71
|
+
'two thirds of the truth, the tracker step that held it (rise cap, tripwire, window, could-earn ceiling, ' +
|
|
72
|
+
'ambiguous armies, readings, a later stage, or no track; logged since #586); and what correcting the ' +
|
|
70
73
|
'tracked figure by its coverage band would have read at dampings 0 to 1 (leave one game out). `samples: true` adds the scored rows ' +
|
|
71
74
|
`(at most ${MAX_SAMPLES}), name-free, as a fixture set; \`harness: true\` also runs the #318 harness over the ` +
|
|
72
75
|
'cached boards (tracker, fog prior and plan estimate by coverage band, and the opening benchmark), which can ' +
|
|
@@ -19,9 +19,11 @@
|
|
|
19
19
|
// `pickWarningCode`), `capturePicksSent` (warapp_submit_picks after a send) and `capturePicksAward` (the award
|
|
20
20
|
// `loadAward` reads on turn 1, once).
|
|
21
21
|
import { createHash } from 'node:crypto';
|
|
22
|
+
import { existsSync } from 'node:fs';
|
|
22
23
|
import { parseFeedTime } from '../normalize.js';
|
|
23
24
|
import { bonusTerritories } from '../analysis/bonuses.js';
|
|
24
25
|
import { policyChecks } from '../open-games.js';
|
|
26
|
+
import { pinStoredMap } from '../map-store.js';
|
|
25
27
|
import { nameFreeSettings } from '../replay.js';
|
|
26
28
|
import { readSeenTurn } from '../turn-orders.js';
|
|
27
29
|
import { recordPicksAdvice, recordPicksAward, recordPicksSent, decisionLogMode, decisionLogOwner, decisionLogPath, decisionOutcome, recordGameEvent, recordJoin, recordOpponentRead, recordSeats, fillOutcome, recordChat, recordCheck, recordDecision, recordObservations, recordSeenTurn, recordSubmission, } from '../decision-log.js';
|
|
@@ -36,8 +38,10 @@ export async function capturePlan(ctx, a) {
|
|
|
36
38
|
if (!ctx.dataDir)
|
|
37
39
|
return;
|
|
38
40
|
const opts = modeOf(ctx);
|
|
39
|
-
|
|
41
|
+
const mapId = a.graph.map.id;
|
|
42
|
+
const wrote = await recordDecision(ctx.dataDir, a.gameId, a.me, {
|
|
40
43
|
turn: a.turn,
|
|
44
|
+
mapId,
|
|
41
45
|
board: a.board,
|
|
42
46
|
...(a.plannedBoard ? { plannedBoard: a.plannedBoard } : {}),
|
|
43
47
|
input: a.input,
|
|
@@ -50,6 +54,9 @@ export async function capturePlan(ctx, a) {
|
|
|
50
54
|
...(a.cards ? { cards: a.cards } : {}),
|
|
51
55
|
...(a.times ? { times: a.times } : {}),
|
|
52
56
|
}, opts);
|
|
57
|
+
// #586: keep the map of every game with a decision log, so its turns can be replayed offline.
|
|
58
|
+
if (wrote || existsSync(decisionLogPath(ctx.dataDir, a.gameId)))
|
|
59
|
+
await pinStoredMap(ctx.dataDir, mapId, a.gameId);
|
|
53
60
|
if (a.turn < 2)
|
|
54
61
|
return;
|
|
55
62
|
try {
|
package/dist/tools/my-games.js
CHANGED
|
@@ -144,10 +144,13 @@ export function registerMyGamesTool(server, ctx, deps = {}) {
|
|
|
144
144
|
'chat per channel (public, team, private, group) and toMe (unread private chat is addressed to you) — flags, ' +
|
|
145
145
|
'not counts; null when they did not read. Games with unread private chat come right after the ones waiting on ' +
|
|
146
146
|
'you, and the top-level unreadPrivateGames counts them; read them with warapp_chat_inbox. ' +
|
|
147
|
-
'A
|
|
147
|
+
'A game being played or picked with your seat playing carries `boot` (pace, from the game list: its boot ' +
|
|
148
148
|
'time, your banked time, their sum, and while it waits on you `leftMinutes`, the sum less how long your turn has ' +
|
|
149
|
-
'run, with `soon` under 6 hours; unverified live)
|
|
150
|
-
'
|
|
149
|
+
'run, with `soon` under 6 hours in a multi-day game; unverified live). #504: an opening turn (`opening`: picks, or ' +
|
|
150
|
+
'turns 1 to 4, where a missed turn delays the first bonus) is also `soon` with a quarter of that time or less left, ' +
|
|
151
|
+
'and then `openingSoon`: those games come first, soonest first, and `openingBootSoon` counts them; a real-time ' +
|
|
152
|
+
'game (`realTime`) is `soon` only at a quarter or less. `bootSoon` counts the games close to a boot, and brief adds ' +
|
|
153
|
+
'" — boot in …" (" — opening turn, boot in …") to them. ' +
|
|
151
154
|
'Finished games are left out unless ' +
|
|
152
155
|
'`include_finished` (`finishedLeftOut` counts them). `listed` is how many games war.app returned and ' +
|
|
153
156
|
'`complete` false (with a `warning`) means the list may be partial. Use the id with the other warapp tools. ' +
|
|
@@ -194,9 +197,14 @@ export function registerMyGamesTool(server, ctx, deps = {}) {
|
|
|
194
197
|
count: games.length,
|
|
195
198
|
waitingOnYou: games.filter((g) => g.waitingOnYou).length,
|
|
196
199
|
unreadPrivateGames: games.filter((g) => g.unreadChat?.private === true).length,
|
|
197
|
-
// Pace:
|
|
200
|
+
// Pace: games close to a boot (boot time plus bank, less my turn so far): under six hours in a multi-day game,
|
|
201
|
+
// and (#504) an opening or real-time turn from a quarter of its time left.
|
|
198
202
|
...(games.some((g) => g.boot)
|
|
199
|
-
? {
|
|
203
|
+
? {
|
|
204
|
+
bootSoon: games.filter((g) => g.boot?.soon).length,
|
|
205
|
+
...(games.some((g) => g.boot?.openingSoon) ? { openingBootSoon: games.filter((g) => g.boot?.openingSoon).length } : {}),
|
|
206
|
+
bootNote: BOOT_NOTE,
|
|
207
|
+
}
|
|
200
208
|
: {}),
|
|
201
209
|
surrenderPending: games.filter((g) => surrenderOwed(g.surrenderPending)).length,
|
|
202
210
|
surrenderNote: SURRENDER_PENDING_NOTE +
|
package/dist/tools/pace.js
CHANGED
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
// Pace: the boot clocks of my multi-day games, as the last game-list read in this process saw them
|
|
2
2
|
// (warapp_my_games, warapp_chat_inbox and every other tool that lists my games through `fetchMyGames`), so
|
|
3
3
|
// warapp_session_status can warn of a boot close by without a war.app request of its own.
|
|
4
|
-
import { BOOT_WARN_MINUTES, minutesText } from '../my-games.js';
|
|
4
|
+
import { BOOT_WARN_MINUTES, bootSoon as isBootSoon, minutesText, OPENING_LAST_TURN } from '../my-games.js';
|
|
5
5
|
import { untrustedText } from './common.js';
|
|
6
6
|
const snapshots = new WeakMap();
|
|
7
7
|
/** Keep the boot clocks of `games` (summarized for me) as read at `at`, for the context `owner`. */
|
|
8
8
|
export function rememberPace(owner, games, at) {
|
|
9
9
|
snapshots.set(owner, {
|
|
10
10
|
at,
|
|
11
|
-
games: games.flatMap((g) =>
|
|
11
|
+
games: games.flatMap((g) => g.boot?.leftMinutes != null && !g.boot.realTime
|
|
12
|
+
? [
|
|
13
|
+
{
|
|
14
|
+
id: g.id,
|
|
15
|
+
name: g.name,
|
|
16
|
+
leftMinutes: g.boot.leftMinutes,
|
|
17
|
+
allowanceMinutes: g.boot.allowanceMinutes,
|
|
18
|
+
...(g.boot.opening ? { opening: true } : {}),
|
|
19
|
+
},
|
|
20
|
+
]
|
|
21
|
+
: []),
|
|
12
22
|
});
|
|
13
23
|
}
|
|
14
24
|
/**
|
|
@@ -22,7 +32,8 @@ export function forgetPaceGame(owner, gameId) {
|
|
|
22
32
|
}
|
|
23
33
|
export const PACE_NOTE = `Read from the last game list this server read (warapp_my_games and the chat inbox read it): each game waiting on you ` +
|
|
24
34
|
`whose boot time plus your banked time, less how long your turn has run, is under ${BOOT_WARN_MINUTES / 60} hours ` +
|
|
25
|
-
|
|
35
|
+
`away now, or (#504) an opening turn (picks, or turns 1 to ${OPENING_LAST_TURN}) with a quarter of that time or less ` +
|
|
36
|
+
'left; real-time games are not kept. Unverified live; call warapp_my_games for a fresh read.';
|
|
26
37
|
export function paceStatus(owner, now) {
|
|
27
38
|
const s = snapshots.get(owner);
|
|
28
39
|
if (!s)
|
|
@@ -30,15 +41,21 @@ export function paceStatus(owner, now) {
|
|
|
30
41
|
const ago = Math.max(0, Math.floor((now - s.at) / 60_000));
|
|
31
42
|
const bootSoon = s.games
|
|
32
43
|
.map((g) => ({ ...g, leftMinutes: Math.max(0, g.leftMinutes - ago) }))
|
|
33
|
-
.filter((g) => g.leftMinutes
|
|
34
|
-
.sort((a, b) => a.leftMinutes - b.leftMinutes || a.id - b.id)
|
|
35
|
-
.map((g) => ({
|
|
44
|
+
.filter((g) => isBootSoon(g.leftMinutes, g))
|
|
45
|
+
.sort((a, b) => Number(b.opening === true) - Number(a.opening === true) || a.leftMinutes - b.leftMinutes || a.id - b.id)
|
|
46
|
+
.map((g) => ({
|
|
47
|
+
id: g.id,
|
|
48
|
+
name: untrustedText(g.name),
|
|
49
|
+
leftMinutes: g.leftMinutes,
|
|
50
|
+
left: minutesText(g.leftMinutes),
|
|
51
|
+
...(g.opening ? { opening: true } : {}),
|
|
52
|
+
}));
|
|
36
53
|
return { listReadMinutesAgo: ago, bootSoon, note: PACE_NOTE };
|
|
37
54
|
}
|
|
38
55
|
/** The warning line for the games close to a boot, or undefined. */
|
|
39
56
|
export function paceWarning(p) {
|
|
40
57
|
if (!p?.bootSoon.length)
|
|
41
58
|
return undefined;
|
|
42
|
-
return (`Boot close: ${p.bootSoon.map((g) => `game ${g.id} in ${g.left}`).join(', ')} — take ${p.bootSoon.length === 1 ? 'that turn' : 'those turns'} ` +
|
|
43
|
-
`(under ${BOOT_WARN_MINUTES / 60} hours left, boot time plus bank).`);
|
|
59
|
+
return (`Boot close: ${p.bootSoon.map((g) => `game ${g.id} in ${g.left}${g.opening ? ' (opening turn)' : ''}`).join(', ')} — take ${p.bootSoon.length === 1 ? 'that turn' : 'those turns'} ` +
|
|
60
|
+
`(under ${BOOT_WARN_MINUTES / 60} hours left, boot time plus bank${p.bootSoon.some((g) => g.opening) ? '; an opening turn from a quarter of its time left, and first: a missed one delays the first bonus' : ''}).`);
|
|
44
61
|
}
|
package/dist/tools/push.js
CHANGED
|
@@ -11,6 +11,7 @@ import { currentTurn, gameIdArg, readAnnotations, respond, untrustedDescription
|
|
|
11
11
|
import { lookupMeta, mintMeta } from './hints.js';
|
|
12
12
|
import { failureText, FROZEN_TAB_HINT } from './live-context.js';
|
|
13
13
|
import { fetchMyGames } from './my-games.js';
|
|
14
|
+
import { paceStatus } from './pace.js';
|
|
14
15
|
import { requireMe } from './write-kit.js';
|
|
15
16
|
import { surrenderOwed } from '../surrender-pending.js';
|
|
16
17
|
import { fetchDetailsSeats, readPendingSurrenders, SURRENDER_PENDING_NOTE, surrenderOwedLine } from './surrender-pending.js';
|
|
@@ -42,6 +43,12 @@ function endedReason(game, playerId) {
|
|
|
42
43
|
return `You are out of this game (your state: ${me.state}).`;
|
|
43
44
|
return undefined;
|
|
44
45
|
}
|
|
46
|
+
/** #504: the ready games with the ones close to a boot first, in `bootSoon`'s order (opening turns first). */
|
|
47
|
+
export function readyOrder(ready, bootSoon) {
|
|
48
|
+
const set = new Set(ready);
|
|
49
|
+
const first = bootSoon.map((g) => g.id).filter((id) => set.has(id));
|
|
50
|
+
return [...first, ...ready.filter((id) => !first.includes(id))];
|
|
51
|
+
}
|
|
45
52
|
export function checkOf(game, playerId, surrenders) {
|
|
46
53
|
const ended = endedReason(game, playerId);
|
|
47
54
|
return {
|
|
@@ -277,6 +284,9 @@ export function registerPushTools(server, ctx, push, deps = {}) {
|
|
|
277
284
|
'details, unverified live: null when unreadable, never "none"; empty without a read for a lobby, a finished ' +
|
|
278
285
|
'game or one you no longer play in; after one failed read it stops asking for the ' +
|
|
279
286
|
'rest of the wait and says why in `surrenderUnread`), unless `ignore_surrenders`. ' +
|
|
287
|
+
'#504: `bootSoon` names the watched games close to a boot as the last game list read saw them (no request of its ' +
|
|
288
|
+
'own; omitted without one): opening turns first (`opening`: picks or turns 1 to 4, from a quarter of the time ' +
|
|
289
|
+
'left), then under 6 hours; take those turns first. ' +
|
|
280
290
|
'Pass the game ids to watch (1–20), or omit them to watch every game ' +
|
|
281
291
|
'of yours being played or picked (the first 20, as warapp_my_games lists them). Reports progress while it ' +
|
|
282
292
|
'waits and stops when the call is cancelled. Then plan with warapp_plan_turn (or pick with ' +
|
|
@@ -370,10 +380,14 @@ export function registerPushTools(server, ctx, push, deps = {}) {
|
|
|
370
380
|
...(progress ? { progress } : {}),
|
|
371
381
|
});
|
|
372
382
|
const st = push.status();
|
|
383
|
+
// #504: the watched games close to a boot, from the last game list read (no request of its own).
|
|
384
|
+
const watched = new Set(ids);
|
|
385
|
+
const bootSoon = (paceStatus(ctx, Date.now())?.bootSoon ?? []).filter((g) => watched.has(g.id));
|
|
373
386
|
return respond(undefined, VIEWS, () => ({
|
|
374
387
|
status: out.status,
|
|
375
388
|
watching: ids,
|
|
376
|
-
...(out.status === 'your_turn' ? { ready: out.games.filter((g) => g.waitingOnYou).map((g) => g.id) } : {}),
|
|
389
|
+
...(out.status === 'your_turn' ? { ready: readyOrder(out.games.filter((g) => g.waitingOnYou).map((g) => g.id), bootSoon) } : {}),
|
|
390
|
+
...(bootSoon.length ? { bootSoon } : {}),
|
|
377
391
|
// #317: the games where a surrender waits on my acceptance, whatever the status.
|
|
378
392
|
...(out.games.some((g) => g.surrenderOwed) ? { surrenders: out.games.filter((g) => g.surrenderOwed).map((g) => g.id) } : {}),
|
|
379
393
|
games: out.games.map((g) => (out.chatActivity.includes(g.id) ? { ...g, chatActivity: true } : g)),
|
package/dist/version.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// Single source of truth for the server version. release-please bumps the
|
|
2
2
|
// literal on the marked line (registered in release-please-config.json
|
|
3
3
|
// extra-files); every other module imports VERSION from here.
|
|
4
|
-
export const VERSION = '0.
|
|
4
|
+
export const VERSION = '0.18.0'; // x-release-please-version
|
package/manifest.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"manifest_version": "0.3",
|
|
4
4
|
"name": "warapp-mcp",
|
|
5
5
|
"display_name": "war.app (Warzone)",
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.18.0",
|
|
7
7
|
"description": "war.app (Warzone) game advisor for Claude — your games, maps, bonuses, board analysis and routes via the GameFeed API, plus your games list (waiting on you first), opponent scouting with your head-to-head, the live board, territory picks, cards, turn planning and submission, turn notifications, and chat through your signed-in war.app tab (ContextMint Bridge). Joining, leaving or surrendering a game, closing out a finished game, accepting another player's surrender, Begin on a speed first turn, picks, turn orders, withdrawing them, chat sends, marking notifications and chat read, deleting notifications, importing local history into a hosted server and linking a session (local only) are confirm-gated.",
|
|
8
8
|
"author": {
|
|
9
9
|
"name": "Chris Hall",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chrischall/warapp-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"mcpName": "io.github.chrischall/warapp-mcp",
|
|
5
5
|
"description": "war.app (Warzone) game advisor MCP server for Claude — games, maps, bonuses and board analysis via the GameFeed API, plus your games list, opponent scouting, the live board, territory picks, cards, turn planning and submission, turn notifications and chat through your signed-in war.app tab. Developed and maintained by AI (Claude Code).",
|
|
6
6
|
"author": "Claude Code (AI) <https://www.anthropic.com/claude>",
|
package/server.json
CHANGED
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
"url": "https://github.com/chrischall/warapp-mcp",
|
|
7
7
|
"source": "github"
|
|
8
8
|
},
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.18.0",
|
|
10
10
|
"packages": [
|
|
11
11
|
{
|
|
12
12
|
"registryType": "npm",
|
|
13
13
|
"identifier": "@chrischall/warapp-mcp",
|
|
14
|
-
"version": "0.
|
|
14
|
+
"version": "0.18.0",
|
|
15
15
|
"transport": {
|
|
16
16
|
"type": "stdio"
|
|
17
17
|
},
|