@chrischall/warapp-mcp 0.23.1 → 0.23.2

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 (creating, joining, leaving or surrendering a game, accepting game invitations, closing out a finished game, accepting another player's surrender, a team surrender, a vote to end a game, booting a stalled player, Begin on a speed first turn, picks, turn orders, withdrawing them, chat sends, nudging a player, joining or leaving a ladder, answering a clan invite, joining or leaving a clan, changing quickmatch settings, voting on quickmatch templates, joining or declining a tournament, showing a tournament among your favourites, mail (new threads, replies, adding players, deleting threads), forum posts (new threads, replies, votes, watching a thread), chat reactions, marking notifications and chat read, deleting notifications, importing local history and linking a session are confirm-gated).",
10
- "version": "0.23.1"
10
+ "version": "0.23.2"
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.23.1",
18
+ "version": "0.23.2",
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.23.1",
4
+ "version": "0.23.2",
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",
@@ -16,18 +16,29 @@ const MIN_TRACK_CALIBRATION_SAMPLES = 5;
16
16
  * that the full correction would put half the estimates above the truth.
17
17
  */
18
18
  export const TRACK_CALIBRATION_DAMPING = 0.5;
19
+ /**
20
+ * #568 (owner decision 2026-11-29): a free-for-all damps less. Its 11-game calibration read the plan's estimates
21
+ * at 0.51× the truth (half under 0.5×, none over 1.5×) against 1.06× in 1v1 and 0.83× in team games; leave one
22
+ * game out on its 4 free-for-alls, 0.75 lifted the 25–50% band's tracked figure from 0.48× to 0.57× the truth
23
+ * with no more over 1.5× (15%). Team games keep {@link TRACK_CALIBRATION_DAMPING}.
24
+ */
25
+ export const FFA_TRACK_CALIBRATION_DAMPING = 0.75;
26
+ /** #568: the damping a format's tracked figures are calibrated with ({@link FFA_TRACK_CALIBRATION_DAMPING}). */
27
+ export function trackCalibrationDampingFor(format) {
28
+ return format === 'ffa' ? FFA_TRACK_CALIBRATION_DAMPING : TRACK_CALIBRATION_DAMPING;
29
+ }
19
30
  /**
20
31
  * #568: the factor a tracked figure read from `share` of its frontier is divided by: its coverage band's past
21
- * geometric mean of estimate ÷ truth (`calibration`, from lessons.json) to the {@link TRACK_CALIBRATION_DAMPING}
22
- * power; `undefined` when the band has under {@link MIN_TRACK_CALIBRATION_SAMPLES} samples or read at least the
32
+ * geometric mean of estimate ÷ truth (`calibration`, from lessons.json) to the `damping` power (by default
33
+ * {@link TRACK_CALIBRATION_DAMPING}; {@link trackCalibrationDampingFor}); `undefined` when the band has under {@link MIN_TRACK_CALIBRATION_SAMPLES} samples or read at least the
23
34
  * truth (the correction only ever raises).
24
35
  */
25
- export function trackCalibrationFactor(calibration, share) {
36
+ export function trackCalibrationFactor(calibration, share, damping = TRACK_CALIBRATION_DAMPING) {
26
37
  const band = coverageBucket(share);
27
38
  const c = calibration?.[band];
28
39
  if (!c || c.n < MIN_TRACK_CALIBRATION_SAMPLES || !(c.geoMean > 0) || c.geoMean >= 1)
29
40
  return undefined;
30
- return { band, geoMean: c.geoMean, n: c.n, factor: c.geoMean ** TRACK_CALIBRATION_DAMPING };
41
+ return { band, geoMean: c.geoMean, n: c.n, factor: c.geoMean ** damping, damping };
31
42
  }
32
43
  /**
33
44
  * The army count every visible player territory holds, when they all hold the same one (the
@@ -309,10 +320,10 @@ export function enemyDeployEstimates(g, board, me, settings = {}, previous, trac
309
320
  // lowered). The #123 bound above keeps the tracker's own figure.
310
321
  let trackCalibration = null;
311
322
  if (usable && tracked !== null && tracked > 0) {
312
- const c = trackCalibrationFactor(when.calibration, coverage ? coverage.share : null);
323
+ const c = trackCalibrationFactor(when.calibration, coverage ? coverage.share : null, when.damping);
313
324
  const figure = c ? Math.min(Math.max(couldEarn, tracked), Math.round(tracked / c.factor)) : tracked;
314
325
  if (c && figure > tracked) {
315
- trackCalibration = { raw: tracked, band: c.band, geoMean: c.geoMean, n: c.n, factor: c.factor, figure };
326
+ trackCalibration = { raw: tracked, band: c.band, geoMean: c.geoMean, n: c.n, factor: c.factor, damping: c.damping, figure };
316
327
  tracked = figure;
317
328
  }
318
329
  }
@@ -99,6 +99,7 @@ export function planEnemyEstimates(input) {
99
99
  ...(ctx.reinforcementPlays ? { plays: ctx.reinforcementPlays } : {}),
100
100
  ...(previousBoard && input.previousOrders ? { previousOrders: input.previousOrders } : {}),
101
101
  ...(ctx.trackCalibration ? { calibration: ctx.trackCalibration } : {}),
102
+ ...(ctx.trackCalibrationDamping !== undefined ? { damping: ctx.trackCalibrationDamping } : {}),
102
103
  });
103
104
  const priced = applyKnown(applyArmyPrice(applySanctions(estimates, input.sanctions ?? [], turn), input.settings?.armyCostMultiplier ?? 0), input.known ?? []);
104
105
  return { estimates: priced, prior, ...(skipped ? { priorSkipped: skipped } : {}) };
@@ -1130,7 +1130,7 @@ export function borderThreats(pc, ps, input, src, forces) {
1130
1130
  // #568: the tracked figure raised by past games' calibration in its coverage band.
1131
1131
  if (e.trackCalibration) {
1132
1132
  const c = e.trackCalibration;
1133
- warnings.push(`Player ${p}'s tracked income ~${c.raw} is raised to ~${c.figure} (#568, draft): past games' tracker read ${c.geoMean.toFixed(2)}× the true income at this frontier coverage (${c.band}, ${c.n} samples), divided by its square root (${c.factor.toFixed(2)}).`);
1133
+ warnings.push(`Player ${p}'s tracked income ~${c.raw} is raised to ~${c.figure} (#568, draft): past games' tracker read ${c.geoMean.toFixed(2)}× the true income at this frontier coverage (${c.band}, ${c.n} samples), divided by ${c.damping === 0.5 ? 'its square root' : `it to the ${c.damping} power`} (${c.factor.toFixed(2)}).`);
1134
1134
  }
1135
1135
  // #427: a card play the tracker read as income, taken out of its figure.
1136
1136
  if (e.cardInTrack) {
package/dist/bundle.js CHANGED
@@ -45745,7 +45745,7 @@ var require_snapshot_utils = __commonJS({
45745
45745
  var require_snapshot_recorder = __commonJS({
45746
45746
  "node_modules/undici/lib/mock/snapshot-recorder.js"(exports, module) {
45747
45747
  "use strict";
45748
- var { writeFile: writeFile18, readFile: readFile26, mkdir: mkdir19 } = __require("node:fs/promises");
45748
+ var { writeFile: writeFile18, readFile: readFile27, mkdir: mkdir19 } = __require("node:fs/promises");
45749
45749
  var { dirname: dirname4, resolve: resolve6 } = __require("node:path");
45750
45750
  var { setTimeout: setTimeout2, clearTimeout: clearTimeout2 } = __require("node:timers");
45751
45751
  var { InvalidArgumentError, UndiciError } = require_errors4();
@@ -45963,7 +45963,7 @@ var require_snapshot_recorder = __commonJS({
45963
45963
  throw new InvalidArgumentError("Snapshot path is required");
45964
45964
  }
45965
45965
  try {
45966
- const data2 = await readFile26(resolve6(path), "utf8");
45966
+ const data2 = await readFile27(resolve6(path), "utf8");
45967
45967
  const parsed = JSON.parse(data2);
45968
45968
  if (Array.isArray(parsed)) {
45969
45969
  this.#snapshots.clear();
@@ -102448,7 +102448,8 @@ function planEnemyEstimates(input2) {
102448
102448
  reinforcement: ctx.reinforcement,
102449
102449
  ...ctx.reinforcementPlays ? { plays: ctx.reinforcementPlays } : {},
102450
102450
  ...previousBoard && input2.previousOrders ? { previousOrders: input2.previousOrders } : {},
102451
- ...ctx.trackCalibration ? { calibration: ctx.trackCalibration } : {}
102451
+ ...ctx.trackCalibration ? { calibration: ctx.trackCalibration } : {},
102452
+ ...ctx.trackCalibrationDamping !== void 0 ? { damping: ctx.trackCalibrationDamping } : {}
102452
102453
  });
102453
102454
  const priced = applyKnown(
102454
102455
  applyArmyPrice(applySanctions(estimates, input2.sanctions ?? [], turn), input2.settings?.armyCostMultiplier ?? 0),
@@ -106022,7 +106023,7 @@ function borderThreats(pc, ps, input2, src, forces) {
106022
106023
  if (e.trackCalibration) {
106023
106024
  const c = e.trackCalibration;
106024
106025
  warnings.push(
106025
- `Player ${p}'s tracked income ~${c.raw} is raised to ~${c.figure} (#568, draft): past games' tracker read ${c.geoMean.toFixed(2)}\xD7 the true income at this frontier coverage (${c.band}, ${c.n} samples), divided by its square root (${c.factor.toFixed(2)}).`
106026
+ `Player ${p}'s tracked income ~${c.raw} is raised to ~${c.figure} (#568, draft): past games' tracker read ${c.geoMean.toFixed(2)}\xD7 the true income at this frontier coverage (${c.band}, ${c.n} samples), divided by ${c.damping === 0.5 ? "its square root" : `it to the ${c.damping} power`} (${c.factor.toFixed(2)}).`
106026
106027
  );
106027
106028
  }
106028
106029
  if (e.cardInTrack) {
@@ -114769,11 +114770,15 @@ function trackOpponents(g, boards, me, settings = {}, game) {
114769
114770
  // src/analysis/plan/deploy-estimates.ts
114770
114771
  var MIN_TRACK_CALIBRATION_SAMPLES = 5;
114771
114772
  var TRACK_CALIBRATION_DAMPING = 0.5;
114772
- function trackCalibrationFactor(calibration, share) {
114773
+ var FFA_TRACK_CALIBRATION_DAMPING = 0.75;
114774
+ function trackCalibrationDampingFor(format) {
114775
+ return format === "ffa" ? FFA_TRACK_CALIBRATION_DAMPING : TRACK_CALIBRATION_DAMPING;
114776
+ }
114777
+ function trackCalibrationFactor(calibration, share, damping = TRACK_CALIBRATION_DAMPING) {
114773
114778
  const band = coverageBucket(share);
114774
114779
  const c = calibration?.[band];
114775
114780
  if (!c || c.n < MIN_TRACK_CALIBRATION_SAMPLES || !(c.geoMean > 0) || c.geoMean >= 1) return void 0;
114776
- return { band, geoMean: c.geoMean, n: c.n, factor: c.geoMean ** TRACK_CALIBRATION_DAMPING };
114781
+ return { band, geoMean: c.geoMean, n: c.n, factor: c.geoMean ** damping, damping };
114777
114782
  }
114778
114783
  function openingArmies(g, board, when = {}) {
114779
114784
  if (when.previous !== void 0 || when.turn !== null && when.turn !== void 0 && when.turn > 1) return null;
@@ -114937,10 +114942,10 @@ function enemyDeployEstimates(g, board, me, settings = {}, previous, tracks, pri
114937
114942
  const coverage2 = usable2 ? trackCoverage(usable2.turns.filter((x) => usable2.incomeTurns.includes(x.from))) : null;
114938
114943
  let trackCalibration = null;
114939
114944
  if (usable2 && tracked !== null && tracked > 0) {
114940
- const c = trackCalibrationFactor(when.calibration, coverage2 ? coverage2.share : null);
114945
+ const c = trackCalibrationFactor(when.calibration, coverage2 ? coverage2.share : null, when.damping);
114941
114946
  const figure = c ? Math.min(Math.max(couldEarn, tracked), Math.round(tracked / c.factor)) : tracked;
114942
114947
  if (c && figure > tracked) {
114943
- trackCalibration = { raw: tracked, band: c.band, geoMean: c.geoMean, n: c.n, factor: c.factor, figure };
114948
+ trackCalibration = { raw: tracked, band: c.band, geoMean: c.geoMean, n: c.n, factor: c.factor, damping: c.damping, figure };
114944
114949
  tracked = figure;
114945
114950
  }
114946
114951
  }
@@ -116229,7 +116234,7 @@ function serverBuild() {
116229
116234
  }
116230
116235
 
116231
116236
  // src/version.ts
116232
- var VERSION2 = "0.23.1";
116237
+ var VERSION2 = "0.23.2";
116233
116238
 
116234
116239
  // src/decision-log.ts
116235
116240
  var DECISION_LOG_VERSION = 1;
@@ -116811,9 +116816,9 @@ async function recordGameEvent(dir, gameId, playerId, ev, o = {}, opts = {}) {
116811
116816
  return false;
116812
116817
  }
116813
116818
  }
116814
- async function recordJoin(dir, gameId, playerId, join31, opts = {}) {
116819
+ async function recordJoin(dir, gameId, playerId, join32, opts = {}) {
116815
116820
  try {
116816
- const kept = encodeValue(join31);
116821
+ const kept = encodeValue(join32);
116817
116822
  return await updateDecisionLog(dir, gameId, playerId, (log) => ({ ...log, join: kept }), opts);
116818
116823
  } catch {
116819
116824
  return false;
@@ -137860,9 +137865,9 @@ function parseEndRules(raw) {
137860
137865
  function parseFeedTime(s) {
137861
137866
  if (s === void 0) return void 0;
137862
137867
  const us = /^\s*(\d{1,2})\/(\d{1,2})\/(\d{4})\s+(\d{1,2}):(\d{2}):(\d{2})\s*$/.exec(s);
137863
- const iso4 = /^\s*(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2}):(\d{2})(?:\.\d+)?Z?\s*$/.exec(s);
137864
- if (!us && !iso4) return void 0;
137865
- const [, mo, d, y, h, mi, se] = us ? us.map(Number) : [0, iso4[2], iso4[3], iso4[1], iso4[4], iso4[5], iso4[6]].map(Number);
137868
+ const iso5 = /^\s*(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2}):(\d{2})(?:\.\d+)?Z?\s*$/.exec(s);
137869
+ if (!us && !iso5) return void 0;
137870
+ const [, mo, d, y, h, mi, se] = us ? us.map(Number) : [0, iso5[2], iso5[3], iso5[1], iso5[4], iso5[5], iso5[6]].map(Number);
137866
137871
  const t = Date.UTC(y, mo - 1, d, h, mi, se);
137867
137872
  return Number.isFinite(t) ? t : void 0;
137868
137873
  }
@@ -139973,9 +139978,9 @@ async function captureGameEvent(ctx, gameId, me, ev, o = {}) {
139973
139978
  if (!ctx.dataDir) return;
139974
139979
  await recordGameEvent(ctx.dataDir, gameId, me, ev, o, modeOf2(ctx));
139975
139980
  }
139976
- async function captureJoin(ctx, gameId, me, join31) {
139981
+ async function captureJoin(ctx, gameId, me, join32) {
139977
139982
  if (!ctx.dataDir) return;
139978
- await recordJoin(ctx.dataDir, gameId, me, join31, modeOf2(ctx));
139983
+ await recordJoin(ctx.dataDir, gameId, me, join32, modeOf2(ctx));
139979
139984
  }
139980
139985
  async function captureOpponentRead(ctx, gameId, me, player2, read) {
139981
139986
  if (!ctx.dataDir) return;
@@ -156081,7 +156086,7 @@ async function livePlanSetup(ctx, a) {
156081
156086
  ...mapPace ? { mapPace } : {},
156082
156087
  // #568: this format's own calibration raises each tracked figure by its coverage band's damped factor
156083
156088
  // (none in a 1v1, where the fog prior already lifts the tracker: trackCalibrationFor).
156084
- ...trackCalibration ? { trackCalibration } : {},
156089
+ ...trackCalibration ? { trackCalibration, trackCalibrationDamping: trackCalibrationDampingFor(profileFormatOf(game.players)) } : {},
156085
156090
  // #164: an opponent's Reinforcement card, from the turn the card clock says one can be in hand.
156086
156091
  ...opponentReinforcement(game.settings, hand) ? { reinforcement: opponentReinforcement(game.settings, hand) } : {},
156087
156092
  // #427: the Reinforcement plays seen in the turns' orders (card plays not fogged): a play restarts the clock.
@@ -156541,7 +156546,7 @@ async function commanderCheck(ctx, a) {
156541
156546
  info: a.info,
156542
156547
  ...opening ? { opening } : {},
156543
156548
  ...mapPace ? { mapPace } : {},
156544
- ...trackCalibration ? { trackCalibration } : {}
156549
+ ...trackCalibration ? { trackCalibration, trackCalibrationDamping: trackCalibrationDampingFor(profileFormatOf(a.game.players)) } : {}
156545
156550
  });
156546
156551
  const tripwires = a.tripwires ?? (await readTripwires({
156547
156552
  dataDir: ctx.dataDir,
@@ -162100,7 +162105,7 @@ function registerCheckPlanTool(server, ctx) {
162100
162105
  info,
162101
162106
  ...opening ? { opening } : {},
162102
162107
  ...mapPace ? { mapPace } : {},
162103
- ...trackCalibration ? { trackCalibration } : {},
162108
+ ...trackCalibration ? { trackCalibration, trackCalibrationDamping: trackCalibrationDampingFor(profileFormatOf(game.players)) } : {},
162104
162109
  ...enemy_deploy !== void 0 ? { enemyDeploy: enemy_deploy } : {},
162105
162110
  assumeCards,
162106
162111
  // #444: the stated incomes scale the other opponents' prior, as warapp_plan_turn has them.
@@ -163657,7 +163662,7 @@ function registerJoinGameTool(server, ctx) {
163657
163662
  }
163658
163663
  };
163659
163664
  },
163660
- async execute({ gameId, name: name2, url: url4, team, color, account, join: join31 }) {
163665
+ async execute({ gameId, name: name2, url: url4, team, color, account, join: join32 }) {
163661
163666
  await requireApprovedAccount(ctx, account);
163662
163667
  const game = { id: gameId, name: name2, url: url4 };
163663
163668
  let vacationEnded = false;
@@ -163695,7 +163700,7 @@ function registerJoinGameTool(server, ctx) {
163695
163700
  unreadable: () => notShown(),
163696
163701
  classify: (seated) => seated ? { status: "joined", outcome: "confirmed", game, ...extra() } : notShown()
163697
163702
  });
163698
- if (result2.outcome === "confirmed" && join31) await captureJoin(ctx, gameId, Number(account), join31);
163703
+ if (result2.outcome === "confirmed" && join32) await captureJoin(ctx, gameId, Number(account), join32);
163699
163704
  return result2;
163700
163705
  }
163701
163706
  }
@@ -166538,8 +166543,8 @@ function readTemplateLengths(body) {
166538
166543
  const n = body.int32();
166539
166544
  for (let i2 = 0; i2 < n; i2++) {
166540
166545
  const id = body.int32();
166541
- const minutes2 = body.float64();
166542
- if (Number.isFinite(minutes2)) out.set(id, minutes2);
166546
+ const minutes3 = body.float64();
166547
+ if (Number.isFinite(minutes3)) out.set(id, minutes3);
166543
166548
  }
166544
166549
  return out;
166545
166550
  }
@@ -166605,7 +166610,7 @@ function registerSettingsRead(server, ctx) {
166605
166610
  },
166606
166611
  async ({ lengths }) => {
166607
166612
  const { settings, unlocked } = await readSettings2(ctx);
166608
- let minutes2;
166613
+ let minutes3;
166609
166614
  let lengthsNote;
166610
166615
  if (lengths === true && unlocked.length > 0) {
166611
166616
  try {
@@ -166614,7 +166619,7 @@ function registerSettingsRead(server, ctx) {
166614
166619
  Method.GetTemplateLengths,
166615
166620
  (w) => writeGetTemplateLengthsParams(w, unlocked.map((t) => t.id))
166616
166621
  );
166617
- minutes2 = readTemplateLengths(env.body);
166622
+ minutes3 = readTemplateLengths(env.body);
166618
166623
  } catch (e) {
166619
166624
  lengthsNote = `The template lengths could not be read (${failureText(e)}).`;
166620
166625
  }
@@ -166624,7 +166629,7 @@ function registerSettingsRead(server, ctx) {
166624
166629
  name: shownName2(t.name),
166625
166630
  mapId: t.mapId,
166626
166631
  ...templateView(settings.templates.get(t.id) ?? QUICKMATCH_TEMPLATE_SETTINGS.off),
166627
- ...minutes2 ? { averageMinutes: minutes2.has(t.id) ? Math.round(minutes2.get(t.id)) : null } : {}
166632
+ ...minutes3 ? { averageMinutes: minutes3.has(t.id) ? Math.round(minutes3.get(t.id)) : null } : {}
166628
166633
  }));
166629
166634
  return respond(void 0, ["compact"], () => ({
166630
166635
  ...settingsView(settings),
@@ -171366,7 +171371,7 @@ function registerAcceptInviteTool(server, ctx) {
171366
171371
  }
171367
171372
  };
171368
171373
  },
171369
- async execute({ gameId, name: name2, url: url4, color, account, join: join31 }) {
171374
+ async execute({ gameId, name: name2, url: url4, color, account, join: join32 }) {
171370
171375
  await requireApprovedAccount(ctx, account);
171371
171376
  const game = { id: gameId, name: untrustedText(name2), url: url4 };
171372
171377
  let vacationEnded = false;
@@ -171399,7 +171404,7 @@ function registerAcceptInviteTool(server, ctx) {
171399
171404
  unreadable: () => notShown(),
171400
171405
  classify: (seated) => seated ? { status: "accepted", outcome: "confirmed", game, ...extra() } : notShown()
171401
171406
  });
171402
- if (result2.outcome === "confirmed" && join31) await captureJoin(ctx, gameId, Number(account), join31);
171407
+ if (result2.outcome === "confirmed" && join32) await captureJoin(ctx, gameId, Number(account), join32);
171403
171408
  return result2;
171404
171409
  }
171405
171410
  }
@@ -173543,7 +173548,117 @@ async function calibrationHarness(dir, opts = {}) {
173543
173548
  return { counts, calibration, benchmark, byEra: benchmarkByEra(eraEntries) };
173544
173549
  }
173545
173550
 
173551
+ // src/tools/calibration-job.ts
173552
+ import { existsSync as existsSync4 } from "node:fs";
173553
+ import { readFile as readFile26 } from "node:fs/promises";
173554
+ import { join as join31 } from "node:path";
173555
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
173556
+ import { Worker } from "node:worker_threads";
173557
+ var HARNESS_LIMIT_MS = 3 * 60 * 60 * 1e3;
173558
+ var harnessFolder = (dir) => join31(dir, "calibration");
173559
+ var harnessResultPath = (dir) => join31(harnessFolder(dir), "harness.json");
173560
+ var jobs = /* @__PURE__ */ new Map();
173561
+ async function readSaved(dir) {
173562
+ try {
173563
+ const v = JSON.parse(await readFile26(harnessResultPath(dir), "utf8"));
173564
+ return typeof v.finishedAt === "string" && typeof v.result === "object" && v.result !== null ? v : void 0;
173565
+ } catch {
173566
+ return void 0;
173567
+ }
173568
+ }
173569
+ var iso4 = (ms) => new Date(ms).toISOString();
173570
+ var minutes2 = (ms) => Math.round(ms / 6e4);
173571
+ async function harnessJob(dir, opts = {}) {
173572
+ const now = opts.now ?? Date.now;
173573
+ const limit = opts.limitMs ?? HARNESS_LIMIT_MS;
173574
+ const job = jobs.get(dir);
173575
+ if (job?.state === "running") {
173576
+ const ran = now() - job.startedAt;
173577
+ if (ran > limit) {
173578
+ job.stop();
173579
+ const error62 = `The harness was stopped after ${minutes2(limit)} minute${minutes2(limit) === 1 ? "" : "s"} (${job.done} of ${job.total ?? "?"} games done).`;
173580
+ jobs.set(dir, { state: "failed", error: error62 });
173581
+ return harnessJob(dir, opts);
173582
+ }
173583
+ const previous = await readSaved(dir);
173584
+ return { status: "running", done: job.done, total: job.total, startedAt: iso4(job.startedAt), minutesRunning: minutes2(ran), ...previous ? { previous } : {} };
173585
+ }
173586
+ if (job?.state === "failed") {
173587
+ if (!opts.peek) jobs.delete(dir);
173588
+ return { status: "failed", error: job.error };
173589
+ }
173590
+ const saved = await readSaved(dir);
173591
+ if (saved && !opts.rerun) return { status: "done", finishedAt: saved.finishedAt, result: saved.result };
173592
+ if (opts.peek) return { status: "none" };
173593
+ const startedAt = now();
173594
+ const running = { state: "running", startedAt, done: 0, total: null, stop: () => void 0 };
173595
+ const handle = (opts.run ?? defaultRunner())(dir, (done, total) => {
173596
+ running.done = done;
173597
+ running.total = total;
173598
+ });
173599
+ running.stop = handle.stop;
173600
+ jobs.set(dir, running);
173601
+ handle.done.then(
173602
+ async (result2) => {
173603
+ if (jobs.get(dir) !== running) return;
173604
+ try {
173605
+ await writeJsonAtomic(harnessResultPath(dir), harnessFolder(dir), { finishedAt: iso4(now()), result: result2 });
173606
+ jobs.delete(dir);
173607
+ } catch (e) {
173608
+ jobs.set(dir, { state: "failed", error: `The harness finished but its result could not be saved: ${messageOf2(e)}` });
173609
+ }
173610
+ },
173611
+ (e) => {
173612
+ if (jobs.get(dir) === running) jobs.set(dir, { state: "failed", error: messageOf2(e) });
173613
+ }
173614
+ );
173615
+ return { status: "started", startedAt: iso4(startedAt), ...saved ? { previous: saved } : {} };
173616
+ }
173617
+ var messageOf2 = (e) => (e instanceof Error ? e.message : String(e)).slice(0, 300);
173618
+ function workerFile(base = import.meta.url) {
173619
+ for (const rel of ["./calibration-worker.js", "./tools/calibration-worker.js"]) {
173620
+ const p = fileURLToPath2(new URL(rel, base));
173621
+ if (existsSync4(p)) return p;
173622
+ }
173623
+ return void 0;
173624
+ }
173625
+ function defaultRunner() {
173626
+ const file2 = workerFile();
173627
+ return file2 ? workerRunner(file2) : inProcessRunner;
173628
+ }
173629
+ function workerRunner(file2) {
173630
+ return (dir, onProgress) => {
173631
+ const worker = new Worker(file2, { workerData: { dir } });
173632
+ const done = new Promise((resolve6, reject) => {
173633
+ worker.on("message", (m) => {
173634
+ if (m.type === "progress") onProgress(m.done, m.total);
173635
+ else if (m.type === "done") resolve6(m.result);
173636
+ else if (m.type === "error") reject(new Error(m.message));
173637
+ });
173638
+ worker.on("error", reject);
173639
+ worker.on("exit", (code2) => reject(new Error(`The harness worker exited (code ${code2}) before it finished.`)));
173640
+ });
173641
+ return { done, stop: () => void worker.terminate() };
173642
+ };
173643
+ }
173644
+ var inProcessRunner = (dir, onProgress) => {
173645
+ const stop = new AbortController();
173646
+ return { done: calibrationHarness(dir, { progress: onProgress, signal: stop.signal }), stop: () => stop.abort(new Error("The harness was stopped.")) };
173647
+ };
173648
+
173546
173649
  // src/tools/calibration.ts
173650
+ var HARNESS_WAIT_MS = 25e3;
173651
+ async function harnessView(dir, rerun, waitMs = HARNESS_WAIT_MS) {
173652
+ let view = await harnessJob(dir, { rerun });
173653
+ const until = Date.now() + waitMs;
173654
+ while ((view.status === "started" || view.status === "running") && Date.now() < until) {
173655
+ await new Promise((r) => setTimeout(r, Math.min(500, Math.max(0, until - Date.now()))));
173656
+ const peek = await harnessJob(dir, { peek: true });
173657
+ if (peek.status === "none") break;
173658
+ view = peek.status === "failed" ? await harnessJob(dir) : peek;
173659
+ }
173660
+ return view;
173661
+ }
173547
173662
  var MAX_SAMPLES = 2e3;
173548
173663
  var CALIBRATION_NOTE = "Each sample is one income estimate a planned turn worked from, against that opponent's true income (base plus full bonuses, cards and the army cap aside) on the board the turn was played on, read from the finished game's history. ratio = estimate \xF7 truth; meanError = estimate \u2212 truth in armies. Reported only: nothing plans on it. Only games whose decision log was given the end-of-game truth count (games played on builds with the decision log, finished, their history read); `method` (the tracker's, incl. rise-capped) is logged only since #569. The consequences block is a proxy: a lost territory has many causes.";
173549
173664
  async function calibrationGames(dir) {
@@ -173582,28 +173697,23 @@ function registerCalibrationTool(server, dataDir2) {
173582
173697
  {
173583
173698
  title: "Score the income estimates against finished games",
173584
173699
  _meta: mintMeta("lookup", ["how accurate are the income estimates", "calibrate opponent income", "estimate accuracy"]),
173585
- 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.`,
173700
+ 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\` adds the #318 harness over the cached boards (tracker, fog prior and plan estimate by coverage band, and the opening benchmark): it runs in the background, since it can take most of an hour on many games, so the first call starts it and later calls say \`running\` (games done of total) until it is \`done\`; the result is kept, so a later call returns it at once (\`rerun: true\` starts a fresh run). Games are numbered by their place in the report, never by id, and no player is named. Makes no war.app request; writes only the harness result, in this server's own data. Read-only.`,
173586
173701
  annotations: toolAnnotations({ title: "Income estimate calibration", readOnly: true, destructive: false, idempotent: true, openWorld: false }),
173587
173702
  inputSchema: external_exports.object({
173588
173703
  samples: external_exports.boolean().optional().describe(`Also return the scored rows, name-free (default false; at most ${MAX_SAMPLES}).`),
173589
- harness: external_exports.boolean().optional().describe("Also run the #318 harness over the cached boards and the opening benchmark (default false)."),
173704
+ harness: external_exports.boolean().optional().describe("Also the #318 harness over the cached boards and the opening benchmark (default false): started in the background on the first call; call again until its status is `done`."),
173705
+ rerun: external_exports.boolean().optional().describe("With `harness`, start a fresh harness run over a kept result (default false)."),
173590
173706
  format: external_exports.enum(["1v1", "ffa", "team"]).optional().describe("Only games of this format.")
173591
173707
  })
173592
173708
  },
173593
- async ({ samples, harness, format }) => {
173709
+ async ({ samples, harness, rerun, format }) => {
173594
173710
  const dir = dataDir2();
173595
173711
  if (!dir) refuse("This server has no data directory, so there is nothing to score.", "Nothing to do here.");
173596
173712
  const src = await calibrationGames(dir);
173597
173713
  const games = format ? src.games.filter((g) => g.format === format) : src.games;
173598
173714
  const report2 = incomeCalibration(games);
173599
173715
  const rows = samples ? incomeSamples(games) : [];
173600
- const signal = currentCallSignal();
173601
- const extra = harness ? await calibrationHarness(dir, {
173602
- ...callerWantsProgress() ? {
173603
- progress: (done, total) => void reportProgress(done, total, `calibration harness: ${done} of ${total} games`).catch(() => void 0)
173604
- } : {},
173605
- ...signal ? { signal } : {}
173606
- }) : void 0;
173716
+ const job = harness ? await harnessView(dir, rerun === true) : void 0;
173607
173717
  return respond(void 0, ["compact"], () => ({
173608
173718
  readAs: CALIBRATION_NOTE,
173609
173719
  sources: {
@@ -173618,11 +173728,28 @@ function registerCalibrationTool(server, dataDir2) {
173618
173728
  empty: "No finished game with the end-of-game truth in its decision log yet: the truth is written when a finished game's history is read (warapp_backfill_history, warapp_my_games' sweep, warapp_get_game on it)."
173619
173729
  },
173620
173730
  ...samples ? { samples: rows.slice(0, MAX_SAMPLES), ...rows.length > MAX_SAMPLES ? { samplesLeftOut: rows.length - MAX_SAMPLES } : {} } : {},
173621
- ...extra ? { harness: { ...extra, approximations: HARNESS_APPROXIMATIONS } } : {}
173731
+ ...job ? { harness: harnessOut(job) } : {}
173622
173732
  }));
173623
173733
  }
173624
173734
  );
173625
173735
  }
173736
+ function harnessOut(job) {
173737
+ switch (job.status) {
173738
+ case "done":
173739
+ return { status: "done", finishedAt: job.finishedAt, ...job.result, approximations: HARNESS_APPROXIMATIONS, note: "A kept result: `rerun: true` starts a fresh run." };
173740
+ case "failed":
173741
+ return { status: "failed", error: job.error, note: "Call again with `harness: true` to start a fresh run." };
173742
+ case "started":
173743
+ case "running":
173744
+ return {
173745
+ ...job,
173746
+ ...job.previous ? { previous: { finishedAt: job.previous.finishedAt, ...job.previous.result, approximations: HARNESS_APPROXIMATIONS } } : {},
173747
+ note: "The harness runs in the background: call warapp_calibration with `harness: true` again in a few minutes for its progress, then its result."
173748
+ };
173749
+ default:
173750
+ return job;
173751
+ }
173752
+ }
173626
173753
 
173627
173754
  // src/tools/turn-history.ts
173628
173755
  var MAX_HISTORY_TURNS = 20;
@@ -0,0 +1,133 @@
1
+ // warapp_calibration's `harness: true` as a background job. The harness replays every finished game and can run
2
+ // for most of an hour on a hosted data dir; a tool call cannot wait that long: Claude Code ends a call silent for
3
+ // CLAUDE_CODE_MCP_TOOL_IDLE_TIMEOUT, mcp-host ends any call after 30 minutes, and claude.ai sends no progress token,
4
+ // so per-game progress cannot keep the call alive (mcp-utils docs/CLIENT-BEHAVIOUR.md). So the first call starts
5
+ // the run and returns; later calls read its progress, then its result, which is kept at
6
+ // `<dataDir>/calibration/harness.json` (aggregates only, name-free) so a restart still has it.
7
+ //
8
+ // The run goes in a worker thread (src/tools/calibration-worker.ts): each game is synchronous planner work, and on
9
+ // the main thread a long game would hold every other tool call of the server (the play session's) until it ended.
10
+ // Without the worker's file (a test run from src/) it runs on the main thread, yielding between games.
11
+ import { existsSync } from 'node:fs';
12
+ import { readFile } from 'node:fs/promises';
13
+ import { join } from 'node:path';
14
+ import { fileURLToPath } from 'node:url';
15
+ import { Worker } from 'node:worker_threads';
16
+ import { writeJsonAtomic } from '../map-store.js';
17
+ import { calibrationHarness } from './calibration-harness.js';
18
+ /** A run is stopped after this long (a stuck worker must not hold the job forever). */
19
+ export const HARNESS_LIMIT_MS = 3 * 60 * 60 * 1000;
20
+ export const harnessFolder = (dir) => join(dir, 'calibration');
21
+ export const harnessResultPath = (dir) => join(harnessFolder(dir), 'harness.json');
22
+ const jobs = new Map();
23
+ /** Forget every job in memory (a restart, in tests). */
24
+ export function resetHarnessJobs() {
25
+ for (const j of jobs.values())
26
+ if (j.state === 'running')
27
+ j.stop();
28
+ jobs.clear();
29
+ }
30
+ async function readSaved(dir) {
31
+ try {
32
+ const v = JSON.parse(await readFile(harnessResultPath(dir), 'utf8'));
33
+ return typeof v.finishedAt === 'string' && typeof v.result === 'object' && v.result !== null ? v : undefined;
34
+ }
35
+ catch {
36
+ return undefined;
37
+ }
38
+ }
39
+ const iso = (ms) => new Date(ms).toISOString();
40
+ const minutes = (ms) => Math.round(ms / 60_000);
41
+ /**
42
+ * The harness job over `dir`: starts a run when none is running and none is saved (or `rerun`), else reports
43
+ * the running one or the saved result. Never waits on the run. `peek` reads the state only: it starts nothing and
44
+ * leaves a failure to be reported (`none` when there is no run and no saved result).
45
+ */
46
+ export async function harnessJob(dir, opts = {}) {
47
+ const now = opts.now ?? Date.now;
48
+ const limit = opts.limitMs ?? HARNESS_LIMIT_MS;
49
+ const job = jobs.get(dir);
50
+ if (job?.state === 'running') {
51
+ const ran = now() - job.startedAt;
52
+ if (ran > limit) {
53
+ job.stop();
54
+ const error = `The harness was stopped after ${minutes(limit)} minute${minutes(limit) === 1 ? '' : 's'} (${job.done} of ${job.total ?? '?'} games done).`;
55
+ jobs.set(dir, { state: 'failed', error });
56
+ return harnessJob(dir, opts);
57
+ }
58
+ const previous = await readSaved(dir);
59
+ return { status: 'running', done: job.done, total: job.total, startedAt: iso(job.startedAt), minutesRunning: minutes(ran), ...(previous ? { previous } : {}) };
60
+ }
61
+ if (job?.state === 'failed') {
62
+ // Reported once: the next call starts again.
63
+ if (!opts.peek)
64
+ jobs.delete(dir);
65
+ return { status: 'failed', error: job.error };
66
+ }
67
+ const saved = await readSaved(dir);
68
+ if (saved && !opts.rerun)
69
+ return { status: 'done', finishedAt: saved.finishedAt, result: saved.result };
70
+ if (opts.peek)
71
+ return { status: 'none' };
72
+ const startedAt = now();
73
+ const running = { state: 'running', startedAt, done: 0, total: null, stop: () => undefined };
74
+ const handle = (opts.run ?? defaultRunner())(dir, (done, total) => {
75
+ running.done = done;
76
+ running.total = total;
77
+ });
78
+ running.stop = handle.stop;
79
+ jobs.set(dir, running);
80
+ handle.done.then(async (result) => {
81
+ if (jobs.get(dir) !== running)
82
+ return;
83
+ try {
84
+ await writeJsonAtomic(harnessResultPath(dir), harnessFolder(dir), { finishedAt: iso(now()), result });
85
+ jobs.delete(dir);
86
+ }
87
+ catch (e) {
88
+ jobs.set(dir, { state: 'failed', error: `The harness finished but its result could not be saved: ${messageOf(e)}` });
89
+ }
90
+ }, (e) => {
91
+ if (jobs.get(dir) === running)
92
+ jobs.set(dir, { state: 'failed', error: messageOf(e) });
93
+ });
94
+ return { status: 'started', startedAt: iso(startedAt), ...(saved ? { previous: saved } : {}) };
95
+ }
96
+ const messageOf = (e) => (e instanceof Error ? e.message : String(e)).slice(0, 300);
97
+ /** The worker's file beside this module, as tsc emits it (dist/tools/) or as the bundle sits (dist/). */
98
+ export function workerFile(base = import.meta.url) {
99
+ for (const rel of ['./calibration-worker.js', './tools/calibration-worker.js']) {
100
+ const p = fileURLToPath(new URL(rel, base));
101
+ if (existsSync(p))
102
+ return p;
103
+ }
104
+ return undefined;
105
+ }
106
+ function defaultRunner() {
107
+ const file = workerFile();
108
+ return file ? workerRunner(file) : inProcessRunner;
109
+ }
110
+ /** The harness in a worker thread: it posts `progress`, then `done` or `error`. */
111
+ export function workerRunner(file) {
112
+ return (dir, onProgress) => {
113
+ const worker = new Worker(file, { workerData: { dir } });
114
+ const done = new Promise((resolve, reject) => {
115
+ worker.on('message', (m) => {
116
+ if (m.type === 'progress')
117
+ onProgress(m.done, m.total);
118
+ else if (m.type === 'done')
119
+ resolve(m.result);
120
+ else if (m.type === 'error')
121
+ reject(new Error(m.message));
122
+ });
123
+ worker.on('error', reject);
124
+ worker.on('exit', (code) => reject(new Error(`The harness worker exited (code ${code}) before it finished.`)));
125
+ });
126
+ return { done, stop: () => void worker.terminate() };
127
+ };
128
+ }
129
+ /** The harness on this thread (no worker file): it yields between games and stops between them. */
130
+ export const inProcessRunner = (dir, onProgress) => {
131
+ const stop = new AbortController();
132
+ return { done: calibrationHarness(dir, { progress: onProgress, signal: stop.signal }), stop: () => stop.abort(new Error('The harness was stopped.')) };
133
+ };
@@ -0,0 +1,10 @@
1
+ // The worker thread src/tools/calibration-job.ts runs the #318 harness in, so its synchronous planner work never
2
+ // holds the server's other tool calls. It posts `progress` after each game, then `done` with the result (aggregates
3
+ // only, name-free) or `error` with a message.
4
+ import { parentPort, workerData } from 'node:worker_threads';
5
+ import { calibrationHarness } from './calibration-harness.js';
6
+ const port = parentPort;
7
+ if (port) {
8
+ const { dir } = workerData;
9
+ calibrationHarness(dir, { progress: (done, total) => port.postMessage({ type: 'progress', done, total }) }).then((result) => port.postMessage({ type: 'done', result }), (e) => port.postMessage({ type: 'error', message: e instanceof Error ? e.message : String(e) }));
10
+ }
@@ -3,17 +3,36 @@
3
3
  // can run the calibration on a hosted server whose data directory no local script can reach. The pure part is
4
4
  // src/analysis/income-calibration.ts; `harness: true` adds the #318 harness (src/tools/calibration-harness.ts).
5
5
  // Name-free: games are numbered by their place in the report, never by id; no player is named or numbered.
6
- import { callerWantsProgress, currentCallSignal, reportProgress, toolAnnotations } from '@chrischall/mcp-utils';
6
+ import { toolAnnotations } from '@chrischall/mcp-utils';
7
7
  import { z } from 'zod';
8
8
  import { incomeCalibration, incomeSamples } from '../analysis/income-calibration.js';
9
9
  import { profileFormatOf } from '../analysis/opponent-profile.js';
10
10
  import { listDecisionLogs, readDecisionLog } from '../decision-log.js';
11
11
  import { holdsSeat } from '../player-states.js';
12
12
  import { readGameRecord } from '../replay.js';
13
- import { calibrationHarness, HARNESS_APPROXIMATIONS } from './calibration-harness.js';
13
+ import { HARNESS_APPROXIMATIONS } from './calibration-harness.js';
14
+ import { harnessJob } from './calibration-job.js';
14
15
  import { respond } from './common.js';
15
16
  import { mintMeta } from './hints.js';
16
17
  import { refuse } from './write-kit.js';
18
+ /** How long a call waits for a harness run before answering with its progress (a small data dir answers at once). */
19
+ export const HARNESS_WAIT_MS = 25_000;
20
+ /**
21
+ * The harness job (src/tools/calibration-job.ts) as one call reads it: started or read, then waited on up to
22
+ * `waitMs` for the result. Never waits longer, so no call outlasts a client's timeout.
23
+ */
24
+ export async function harnessView(dir, rerun, waitMs = HARNESS_WAIT_MS) {
25
+ let view = await harnessJob(dir, { rerun });
26
+ const until = Date.now() + waitMs;
27
+ while ((view.status === 'started' || view.status === 'running') && Date.now() < until) {
28
+ await new Promise((r) => setTimeout(r, Math.min(500, Math.max(0, until - Date.now()))));
29
+ const peek = await harnessJob(dir, { peek: true });
30
+ if (peek.status === 'none')
31
+ break;
32
+ view = peek.status === 'failed' ? await harnessJob(dir) : peek;
33
+ }
34
+ return view;
35
+ }
17
36
  /** Scored rows returned at most with `samples: true`. */
18
37
  export const MAX_SAMPLES = 2000;
19
38
  export const CALIBRATION_NOTE = 'Each sample is one income estimate a planned turn worked from, against that opponent\'s true income (base plus ' +
@@ -71,17 +90,23 @@ export function registerCalibrationTool(server, dataDir) {
71
90
  'two thirds of the truth, the tracker step that held it (rise cap, tripwire, window, could-earn ceiling, ' +
72
91
  'ambiguous armies, readings, a later stage, or no track; logged since #586); and what correcting the ' +
73
92
  'tracked figure by its coverage band would have read at dampings 0 to 1 (leave one game out). `samples: true` adds the scored rows ' +
74
- `(at most ${MAX_SAMPLES}), name-free, as a fixture set; \`harness: true\` also runs the #318 harness over the ` +
75
- 'cached boards (tracker, fog prior and plan estimate by coverage band, and the opening benchmark), which can ' +
76
- 'take a while on many games. Games are numbered by their place in the report, never by id, and no player is ' +
77
- 'named. Makes no war.app request and writes nothing. Read-only.',
93
+ `(at most ${MAX_SAMPLES}), name-free, as a fixture set; \`harness: true\` adds the #318 harness over the ` +
94
+ 'cached boards (tracker, fog prior and plan estimate by coverage band, and the opening benchmark): it runs in the ' +
95
+ 'background, since it can take most of an hour on many games, so the first call starts it and later calls say ' +
96
+ '`running` (games done of total) until it is `done`; the result is kept, so a later call returns it at once ' +
97
+ '(`rerun: true` starts a fresh run). Games are numbered by their place in the report, never by id, and no player ' +
98
+ 'is named. Makes no war.app request; writes only the harness result, in this server\'s own data. Read-only.',
78
99
  annotations: toolAnnotations({ title: 'Income estimate calibration', readOnly: true, destructive: false, idempotent: true, openWorld: false }),
79
100
  inputSchema: z.object({
80
101
  samples: z.boolean().optional().describe(`Also return the scored rows, name-free (default false; at most ${MAX_SAMPLES}).`),
81
- harness: z.boolean().optional().describe('Also run the #318 harness over the cached boards and the opening benchmark (default false).'),
102
+ harness: z
103
+ .boolean()
104
+ .optional()
105
+ .describe('Also the #318 harness over the cached boards and the opening benchmark (default false): started in the background on the first call; call again until its status is `done`.'),
106
+ rerun: z.boolean().optional().describe('With `harness`, start a fresh harness run over a kept result (default false).'),
82
107
  format: z.enum(['1v1', 'ffa', 'team']).optional().describe('Only games of this format.'),
83
108
  }),
84
- }, async ({ samples, harness, format }) => {
109
+ }, async ({ samples, harness, rerun, format }) => {
85
110
  const dir = dataDir();
86
111
  if (!dir)
87
112
  refuse('This server has no data directory, so there is nothing to score.', 'Nothing to do here.');
@@ -89,19 +114,7 @@ export function registerCalibrationTool(server, dataDir) {
89
114
  const games = format ? src.games.filter((g) => g.format === format) : src.games;
90
115
  const report = incomeCalibration(games);
91
116
  const rows = samples ? incomeSamples(games) : [];
92
- // The harness replays every finished game, which can outlast the 300 s a call may stay silent:
93
- // progress after each game keeps the call alive, and a cancelled call stops between games.
94
- const signal = currentCallSignal();
95
- const extra = harness
96
- ? await calibrationHarness(dir, {
97
- ...(callerWantsProgress()
98
- ? {
99
- progress: (done, total) => void reportProgress(done, total, `calibration harness: ${done} of ${total} games`).catch(() => undefined),
100
- }
101
- : {}),
102
- ...(signal ? { signal } : {}),
103
- })
104
- : undefined;
117
+ const job = harness ? await harnessView(dir, rerun === true) : undefined;
105
118
  return respond(undefined, ['compact'], () => ({
106
119
  readAs: CALIBRATION_NOTE,
107
120
  sources: {
@@ -119,7 +132,25 @@ export function registerCalibrationTool(server, dataDir) {
119
132
  "game's history is read (warapp_backfill_history, warapp_my_games' sweep, warapp_get_game on it).",
120
133
  }),
121
134
  ...(samples ? { samples: rows.slice(0, MAX_SAMPLES), ...(rows.length > MAX_SAMPLES ? { samplesLeftOut: rows.length - MAX_SAMPLES } : {}) } : {}),
122
- ...(extra ? { harness: { ...extra, approximations: HARNESS_APPROXIMATIONS } } : {}),
135
+ ...(job ? { harness: harnessOut(job) } : {}),
123
136
  }));
124
137
  });
125
138
  }
139
+ /** The job as the tool reports it: the result with its approximations, or where the run stands and what to do. */
140
+ function harnessOut(job) {
141
+ switch (job.status) {
142
+ case 'done':
143
+ return { status: 'done', finishedAt: job.finishedAt, ...job.result, approximations: HARNESS_APPROXIMATIONS, note: 'A kept result: `rerun: true` starts a fresh run.' };
144
+ case 'failed':
145
+ return { status: 'failed', error: job.error, note: 'Call again with `harness: true` to start a fresh run.' };
146
+ case 'started':
147
+ case 'running':
148
+ return {
149
+ ...job,
150
+ ...(job.previous ? { previous: { finishedAt: job.previous.finishedAt, ...job.previous.result, approximations: HARNESS_APPROXIMATIONS } } : {}),
151
+ note: 'The harness runs in the background: call warapp_calibration with `harness: true` again in a few minutes for its progress, then its result.',
152
+ };
153
+ default:
154
+ return job;
155
+ }
156
+ }
@@ -33,6 +33,7 @@ import { resolveTeamsFor } from './team-source.js';
33
33
  import { stressOpponents } from './stress-opponents.js';
34
34
  import { observedLowWarning } from '../analysis/opponents.js';
35
35
  import { statedShiftWarning } from '../analysis/plan/estimates.js';
36
+ import { trackCalibrationDampingFor } from '../analysis/plan/deploy-estimates.js';
36
37
  import { sanctionPercentage } from '../analysis/cards-in-effect.js';
37
38
  import { CARD_SANCTIONS, sanctionsPlayed } from './sanctions-played.js';
38
39
  import { COMMANDER_SIZING, commanderCheckOn, defaultFoggedCount, foggedAttackersArg, foggedCommanderOn, foggedCommanderText, myLargestStack } from './commander-check.js';
@@ -381,7 +382,7 @@ export function registerCheckPlanTool(server, ctx) {
381
382
  info,
382
383
  ...(opening ? { opening } : {}),
383
384
  ...(mapPace ? { mapPace } : {}),
384
- ...(trackCalibration ? { trackCalibration } : {}),
385
+ ...(trackCalibration ? { trackCalibration, trackCalibrationDamping: trackCalibrationDampingFor(profileFormatOf(game.players)) } : {}),
385
386
  ...(enemy_deploy !== undefined ? { enemyDeploy: enemy_deploy } : {}),
386
387
  assumeCards,
387
388
  // #444: the stated incomes scale the other opponents' prior, as warapp_plan_turn has them.
@@ -6,6 +6,7 @@ import { z } from 'zod';
6
6
  import { CARD_BLOCKADE, CARD_ORDER_DELAY, CARD_ORDER_PRIORITY, holdsOrderPriority, playsOrderPriority, advisedOrderPriority, CARD_REINFORCEMENT, cardRules, cardTypeByName, cardTypeName, chooseCardPlays, normalizeGuid, cardsToShed, handReadable, isMyCard, readHand, reinforcementArmies, } from '../cards.js';
7
7
  import { chargeDeploys, DEFAULT_OFFENSIVE_KILL_RATE, deployPools, expectedKills, specialUnitStrength, winChance, incomeDetail, armyCapPoolsUncertainty, deployCheckUncertainties, unreadSanctionsUncertainty, overrideUncertainties, neighborsOf, PAYBACK_TURNS, planTurn, planEnemyEstimates, repulsedAttacks, borderGuess, guessSeed, AHEAD_PRESSURE_FACTOR, PRESSURE_FACTOR, symmetricStart, unevenStart, trackGame, trackOpponents, } from '../analysis/index.js';
8
8
  import { statedShifts, statedShiftWarning } from '../analysis/plan/estimates.js';
9
+ import { trackCalibrationDampingFor } from '../analysis/plan/deploy-estimates.js';
9
10
  import { parseGameId } from '../client.js';
10
11
  import { COMMANDER_STRENGTH, luckFraction, straightKills } from '../analysis/combat.js';
11
12
  import { guardOffExposure } from '../analysis/guard-off.js';
@@ -1524,7 +1525,7 @@ export async function livePlanSetup(ctx, a) {
1524
1525
  ...(mapPace ? { mapPace } : {}),
1525
1526
  // #568: this format's own calibration raises each tracked figure by its coverage band's damped factor
1526
1527
  // (none in a 1v1, where the fog prior already lifts the tracker: trackCalibrationFor).
1527
- ...(trackCalibration ? { trackCalibration } : {}),
1528
+ ...(trackCalibration ? { trackCalibration, trackCalibrationDamping: trackCalibrationDampingFor(profileFormatOf(game.players)) } : {}),
1528
1529
  // #164: an opponent's Reinforcement card, from the turn the card clock says one can be in hand.
1529
1530
  ...(opponentReinforcement(game.settings, hand) ? { reinforcement: opponentReinforcement(game.settings, hand) } : {}),
1530
1531
  // #427: the Reinforcement plays seen in the turns' orders (card plays not fogged): a play restarts the clock.
@@ -2019,7 +2020,7 @@ async function commanderCheck(ctx, a) {
2019
2020
  info: a.info,
2020
2021
  ...(opening ? { opening } : {}),
2021
2022
  ...(mapPace ? { mapPace } : {}),
2022
- ...(trackCalibration ? { trackCalibration } : {}),
2023
+ ...(trackCalibration ? { trackCalibration, trackCalibrationDamping: trackCalibrationDampingFor(profileFormatOf(a.game.players)) } : {}),
2023
2024
  });
2024
2025
  // #275: an untrusted opponent's reply is sized at least at the figure its tripwire gave it, as
2025
2026
  // warapp_check_plan's stress test tries it (read only: warapp_plan_turn keeps the marks).
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.23.1'; // x-release-please-version
4
+ export const VERSION = '0.23.2'; // 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.23.1",
6
+ "version": "0.23.2",
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). Creating, joining, leaving or surrendering a game, accepting game invitations, closing out a finished game, accepting another player's surrender, a team surrender, a vote to end a game, booting a stalled player, Begin on a speed first turn, picks, turn orders, withdrawing them, chat sends, nudging a player, joining or leaving a ladder, answering a clan invite, joining or leaving a clan, changing quickmatch settings, voting on quickmatch templates, joining or declining a tournament, showing a tournament among your favourites, mail (new threads, replies, adding players, deleting threads), forum posts (new threads, replies, votes, watching a thread), chat reactions, 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.23.1",
3
+ "version": "0.23.2",
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.23.1",
9
+ "version": "0.23.2",
10
10
  "packages": [
11
11
  {
12
12
  "registryType": "npm",
13
13
  "identifier": "@chrischall/warapp-mcp",
14
- "version": "0.23.1",
14
+ "version": "0.23.2",
15
15
  "transport": {
16
16
  "type": "stdio"
17
17
  },