@chrischall/warapp-mcp 0.17.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.
@@ -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.17.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.17.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.17.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. Pure.
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
@@ -115671,7 +115671,7 @@ function serverBuild() {
115671
115671
  }
115672
115672
 
115673
115673
  // src/version.ts
115674
- var VERSION2 = "0.17.0";
115674
+ var VERSION2 = "0.18.0";
115675
115675
 
115676
115676
  // src/decision-log.ts
115677
115677
  var DECISION_LOG_VERSION = 1;
@@ -137828,15 +137828,34 @@ function bootClockOf(f) {
137828
137828
  return { bootMs: boot, bankedMs: banked, turnForMs: turnFor, realTime };
137829
137829
  }
137830
137830
  var BOOT_WARN_MINUTES = 6 * 60;
137831
- 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. The fields are read from war.app's client; the arithmetic is unverified live.";
137832
- function bootView(clock, waitingOnYou) {
137833
- if (!clock || clock.realTime || !(clock.bootMs > 0) || clock.bootMs >= NEVER_MS) return void 0;
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;
137834
137840
  const min = (ms) => Math.max(0, Math.floor(ms / 6e4));
137835
137841
  const bootMinutes = min(clock.bootMs);
137836
137842
  const bankedMinutes = clock.bankedMs >= NEVER_MS ? 0 : min(clock.bankedMs);
137837
137843
  const allowanceMinutes = bootMinutes + bankedMinutes;
137838
137844
  const leftMinutes = waitingOnYou ? Math.max(0, allowanceMinutes - min(clock.turnForMs)) : null;
137839
- return { bootMinutes, bankedMinutes, allowanceMinutes, leftMinutes, soon: leftMinutes !== null && leftMinutes < BOOT_WARN_MINUTES };
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;
137840
137859
  }
137841
137860
  function minutesText(m) {
137842
137861
  const d = Math.floor(m / 1440);
@@ -137859,7 +137878,7 @@ function summarizeMyGames(games, myInGameId2) {
137859
137878
  const me = g.players.find((p) => p.id === myInGameId2);
137860
137879
  const active = g.stateCode === GAME_PLAYING || g.stateCode === GAME_DISTRIBUTING;
137861
137880
  const waitingOnYou = active && me !== void 0 && me.stateCode === PLAYER_PLAYING && !me.committed;
137862
- 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;
137863
137882
  return {
137864
137883
  id: g.id,
137865
137884
  name: g.name,
@@ -137876,8 +137895,10 @@ function summarizeMyGames(games, myInGameId2) {
137876
137895
  };
137877
137896
  });
137878
137897
  const privateUnread = (g) => !g.waitingOnYou && g.unreadChat?.private === true;
137898
+ const openingSoon = (g) => g.waitingOnYou && g.boot?.openingSoon === true;
137879
137899
  return [
137880
- ...out.filter((g) => g.waitingOnYou),
137900
+ ...out.filter(openingSoon).sort((a, b) => (a.boot?.leftMinutes ?? 0) - (b.boot?.leftMinutes ?? 0)),
137901
+ ...out.filter((g) => g.waitingOnYou && !openingSoon(g)),
137881
137902
  ...out.filter(privateUnread),
137882
137903
  ...out.filter((g) => !g.waitingOnYou && !privateUnread(g))
137883
137904
  ];
@@ -137900,7 +137921,7 @@ function briefGameLine(game) {
137900
137921
  const u = game.unreadChat;
137901
137922
  const others = u ? ["public", "team", "group"].filter((c) => u[c]) : [];
137902
137923
  const unread = (u?.private ? " \u2014 unread private" : "") + (others.length ? ` \u2014 unread ${others.join(", ")}` : "");
137903
- 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)}` : "";
137904
137925
  const tail = ` \u2014 ${where} \u2014 ${game.waitingOnYou ? "waiting on you" : "waiting on others"}${soon}${unread}`;
137905
137926
  const flat = game.name.replace(/\s+/g, " ").trim() || "(untitled)";
137906
137927
  const escaped = flat.startsWith("-- ") || flat.startsWith("\\") ? `\\${flat}` : flat;
@@ -152351,24 +152372,40 @@ var snapshots = /* @__PURE__ */ new WeakMap();
152351
152372
  function rememberPace(owner, games, at2) {
152352
152373
  snapshots.set(owner, {
152353
152374
  at: at2,
152354
- games: games.flatMap((g) => g.boot?.leftMinutes != null ? [{ id: g.id, name: g.name, leftMinutes: g.boot.leftMinutes }] : [])
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
+ )
152355
152386
  });
152356
152387
  }
152357
152388
  function forgetPaceGame(owner, gameId) {
152358
152389
  const s = snapshots.get(owner);
152359
152390
  if (s) snapshots.set(owner, { ...s, games: s.games.filter((g) => g.id !== gameId) });
152360
152391
  }
152361
- 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.`;
152362
152393
  function paceStatus(owner, now) {
152363
152394
  const s = snapshots.get(owner);
152364
152395
  if (!s) return void 0;
152365
152396
  const ago = Math.max(0, Math.floor((now - s.at) / 6e4));
152366
- const bootSoon = s.games.map((g) => ({ ...g, leftMinutes: Math.max(0, g.leftMinutes - ago) })).filter((g) => g.leftMinutes < BOOT_WARN_MINUTES).sort((a, b) => a.leftMinutes - b.leftMinutes || a.id - b.id).map((g) => ({ id: g.id, name: untrustedText(g.name), leftMinutes: g.leftMinutes, left: minutesText(g.leftMinutes) }));
152367
- return { listReadMinutesAgo: ago, bootSoon, note: PACE_NOTE };
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 };
152368
152405
  }
152369
152406
  function paceWarning(p) {
152370
152407
  if (!p?.bootSoon.length) return void 0;
152371
- 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" : ""}).`;
152372
152409
  }
152373
152410
 
152374
152411
  // src/tools/stress-opponents.ts
@@ -156985,7 +157022,7 @@ function registerMyGamesTool(server, ctx, deps = {}) {
156985
157022
  {
156986
157023
  title: "List my war.app games and which need me",
156987
157024
  description: untrustedDescription(
156988
- `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 multi-day 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; unverified live); \`bootSoon\` counts the games close to a boot, and brief adds " \u2014 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.`
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.`
156989
157026
  ),
156990
157027
  _meta: canonicalMeta("whats-new", ["my games", "warzone", "whose turn", "games waiting on me", "which games need me"]),
156991
157028
  annotations: readAnnotations("List my war.app games"),
@@ -157015,8 +157052,13 @@ function registerMyGamesTool(server, ctx, deps = {}) {
157015
157052
  count: games.length,
157016
157053
  waitingOnYou: games.filter((g) => g.waitingOnYou).length,
157017
157054
  unreadPrivateGames: games.filter((g) => g.unreadChat?.private === true).length,
157018
- // Pace: multi-day games whose boot is under six hours away (boot time plus bank, less my turn so far).
157019
- ...games.some((g) => g.boot) ? { bootSoon: games.filter((g) => g.boot?.soon).length, bootNote: BOOT_NOTE } : {},
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
+ } : {},
157020
157062
  surrenderPending: games.filter((g) => surrenderOwed(g.surrenderPending)).length,
157021
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).` : ""),
157022
157064
  listed: raw.length,
@@ -162154,6 +162196,11 @@ function endedReason(game, playerId) {
162154
162196
  if (me?.state !== void 0 && me.state !== "Playing") return `You are out of this game (your state: ${me.state}).`;
162155
162197
  return void 0;
162156
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
+ }
162157
162204
  function checkOf(game, playerId, surrenders) {
162158
162205
  const ended = endedReason(game, playerId);
162159
162206
  return {
@@ -162327,7 +162374,7 @@ function registerPushTools(server, ctx, push, deps = {}) {
162327
162374
  {
162328
162375
  title: "Wait for my turn in war.app games",
162329
162376
  description: untrustedDescription(
162330
- "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."
162331
162378
  ),
162332
162379
  _meta: mintMeta("whats-new", ["is it my turn", "wait for my turn", "tell me when it is my turn", "warzone turn ready"]),
162333
162380
  annotations: readAnnotations("Wait for my war.app turn"),
@@ -162394,10 +162441,13 @@ function registerPushTools(server, ctx, push, deps = {}) {
162394
162441
  ...progress ? { progress } : {}
162395
162442
  });
162396
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));
162397
162446
  return respond(void 0, VIEWS13, () => ({
162398
162447
  status: out.status,
162399
162448
  watching: ids2,
162400
- ...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 } : {},
162401
162451
  // #317: the games where a surrender waits on my acceptance, whatever the status.
162402
162452
  ...out.games.some((g) => g.surrenderOwed) ? { surrenders: out.games.filter((g) => g.surrenderOwed).map((g) => g.id) } : {},
162403
162453
  games: out.games.map((g) => out.chatActivity.includes(g.id) ? { ...g, chatActivity: true } : g),
@@ -165352,6 +165402,30 @@ function seatBand(seats) {
165352
165402
  if (seats === null || seats < 2) return "unknown";
165353
165403
  return seats === 2 ? "2" : seats <= 6 ? "3-6" : seats <= 16 ? "7-16" : "17-up";
165354
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
+ }
165355
165429
  var r3 = (x) => Math.round(x * 1e3) / 1e3;
165356
165430
  function errorView(samples) {
165357
165431
  const n = samples.length;
@@ -165399,7 +165473,8 @@ function incomeSamples(games) {
165399
165473
  thin: a.thin,
165400
165474
  method: logged2.get(a.player)?.method ?? null,
165401
165475
  leader: top !== null && a.truth >= top,
165402
- 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)
165403
165478
  });
165404
165479
  }
165405
165480
  }
@@ -165409,6 +165484,7 @@ function incomeSamples(games) {
165409
165484
  function catchUp(games) {
165410
165485
  const lagsList = [];
165411
165486
  let censored = 0;
165487
+ let unwatched = 0;
165412
165488
  for (const g of games) {
165413
165489
  const turns = turnKeys2(g.turns);
165414
165490
  const truth = /* @__PURE__ */ new Map();
@@ -165425,6 +165501,10 @@ function catchUp(games) {
165425
165501
  for (const [t, income] of [...series].sort((a, b) => a[0] - b[0])) {
165426
165502
  const before = series.get(t - 1);
165427
165503
  if (before === void 0 || before <= 0 || income < JUMP_FACTOR * before || t > last) continue;
165504
+ if (!estimates.has(t)) {
165505
+ unwatched++;
165506
+ continue;
165507
+ }
165428
165508
  let lag = null;
165429
165509
  for (const u of [...estimates.keys()].filter((u2) => u2 >= t).sort((a, b) => a - b)) {
165430
165510
  const truthU = series.get(u) ?? income;
@@ -165448,7 +165528,8 @@ function catchUp(games) {
165448
165528
  meanLag: n ? r3(sorted.reduce((s, x) => s + x, 0) / n) : null,
165449
165529
  medianLag: n ? n % 2 ? sorted[n >> 1] : (sorted[(n >> 1) - 1] + sorted[n >> 1]) / 2 : null,
165450
165530
  lags,
165451
- censored
165531
+ censored,
165532
+ unwatched
165452
165533
  };
165453
165534
  }
165454
165535
  function consequences(games) {
@@ -165564,7 +165645,8 @@ function incomeCalibration(games) {
165564
165645
  consequences: consequences(games),
165565
165646
  worst,
165566
165647
  byStage: stageErrors(samples),
165567
- trackedWhatIf: trackedWhatIf(samples)
165648
+ trackedWhatIf: trackedWhatIf(samples),
165649
+ heldBy: heldByView(samples)
165568
165650
  };
165569
165651
  }
165570
165652
 
@@ -166036,7 +166118,7 @@ function registerCalibrationTool(server, dataDir2) {
166036
166118
  {
166037
166119
  title: "Score the income estimates against finished games",
166038
166120
  _meta: mintMeta("lookup", ["how accurate are the income estimates", "calibrate opponent income", "estimate accuracy"]),
166039
- 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.`,
166040
166122
  annotations: toolAnnotations({ title: "Income estimate calibration", readOnly: true, destructive: false, idempotent: true, openWorld: false }),
166041
166123
  inputSchema: external_exports.object({
166042
166124
  samples: external_exports.boolean().optional().describe(`Also return the scored rows, name-free (default false; at most ${MAX_SAMPLES}).`),
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. The fields are ' +
165
- "read from war.app's client; the arithmetic is unverified live.";
166
- /** A multi-day game's boot view, or undefined: real-time, no boot time, the clock unread, or not a game I play. */
167
- export function bootView(clock, waitingOnYou) {
168
- if (!clock || clock.realTime || !(clock.bootMs > 0) || clock.bootMs >= NEVER_MS)
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
- return { bootMinutes, bankedMinutes, allowanceMinutes, leftMinutes, soon: leftMinutes !== null && leftMinutes < BOOT_WARN_MINUTES };
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, then unread private chat, then the rest (war.app's order within each).
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((g) => g.waitingOnYou),
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 ? ` — boot in ${minutesText(game.boot.leftMinutes)}` : '';
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;
@@ -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); a consequences proxy (turns that lost a territory the plan did not concede, with an ' +
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); and what correcting the ' +
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 ' +
@@ -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 multi-day game being played or picked with your seat playing carries `boot` (pace, from the game list: its boot ' +
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); `bootSoon` counts the games close to a boot, and brief adds ' +
150
- '" — boot in …" to them. ' +
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: multi-day games whose boot is under six hours away (boot time plus bank, less my turn so far).
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
- ? { bootSoon: games.filter((g) => g.boot?.soon).length, bootNote: BOOT_NOTE }
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 +
@@ -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) => (g.boot?.leftMinutes != null ? [{ id: g.id, name: g.name, leftMinutes: g.boot.leftMinutes }] : [])),
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
- 'away now. Unverified live; call warapp_my_games for a fresh read.';
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 < BOOT_WARN_MINUTES)
34
- .sort((a, b) => a.leftMinutes - b.leftMinutes || a.id - b.id)
35
- .map((g) => ({ id: g.id, name: untrustedText(g.name), leftMinutes: g.leftMinutes, left: minutesText(g.leftMinutes) }));
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
  }
@@ -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.17.0'; // x-release-please-version
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.17.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.17.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.17.0",
9
+ "version": "0.18.0",
10
10
  "packages": [
11
11
  {
12
12
  "registryType": "npm",
13
13
  "identifier": "@chrischall/warapp-mcp",
14
- "version": "0.17.0",
14
+ "version": "0.18.0",
15
15
  "transport": {
16
16
  "type": "stdio"
17
17
  },