@chrischall/warapp-mcp 0.13.1 → 0.15.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.
Files changed (58) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/README.md +9 -6
  4. package/dist/analysis/airlift-plan.js +288 -0
  5. package/dist/analysis/blockade-plan.js +178 -0
  6. package/dist/analysis/bomb-plan.js +72 -0
  7. package/dist/analysis/card-threats.js +10 -9
  8. package/dist/analysis/cards-in-effect.js +20 -0
  9. package/dist/analysis/combat.js +5 -0
  10. package/dist/analysis/coordination.js +47 -0
  11. package/dist/analysis/income-calibration.js +280 -0
  12. package/dist/analysis/intel.js +1 -1
  13. package/dist/analysis/lookahead.js +4 -0
  14. package/dist/analysis/opponents.js +52 -3
  15. package/dist/analysis/plan/deploy-estimates.js +1 -1
  16. package/dist/analysis/plan/estimates.js +40 -6
  17. package/dist/analysis/plan/relations.js +57 -8
  18. package/dist/analysis/plan/threats.js +1 -1
  19. package/dist/analysis/player-record.js +1 -0
  20. package/dist/analysis/relations.js +40 -0
  21. package/dist/analysis/stress.js +42 -2
  22. package/dist/analysis/turn-sim.js +62 -0
  23. package/dist/bundle.js +24486 -21811
  24. package/dist/card-state.js +157 -0
  25. package/dist/decision-log.js +44 -5
  26. package/dist/local-time.js +142 -0
  27. package/dist/relations-store.js +30 -5
  28. package/dist/tools/airlift-readback.js +87 -0
  29. package/dist/tools/alternative-orders.js +21 -0
  30. package/dist/tools/begin-turn.js +19 -5
  31. package/dist/tools/calibration-harness.js +102 -0
  32. package/dist/tools/calibration.js +110 -0
  33. package/dist/tools/card-advice.js +5 -4
  34. package/dist/tools/card-plays.js +32 -20
  35. package/dist/tools/card-state-view.js +26 -0
  36. package/dist/tools/card-support-advice.js +25 -8
  37. package/dist/tools/chat-inbox.js +1 -1
  38. package/dist/tools/chat.js +1 -1
  39. package/dist/tools/check-plan.js +113 -9
  40. package/dist/tools/common.js +14 -0
  41. package/dist/tools/decision-capture.js +14 -1
  42. package/dist/tools/game.js +11 -2
  43. package/dist/tools/index.js +13 -1
  44. package/dist/tools/notifications.js +1 -1
  45. package/dist/tools/opponents.js +2 -0
  46. package/dist/tools/player-card-readback.js +45 -0
  47. package/dist/tools/relations.js +146 -14
  48. package/dist/tools/sanctions-played.js +51 -0
  49. package/dist/tools/stress-opponents.js +8 -4
  50. package/dist/tools/turn-history.js +214 -0
  51. package/dist/tools/turn.js +504 -20
  52. package/dist/turn-orders.js +64 -0
  53. package/dist/version.js +1 -1
  54. package/manifest.json +17 -2
  55. package/mint.yaml +7 -0
  56. package/package.json +1 -1
  57. package/server.json +8 -2
  58. package/skills/warapp-mcp/SKILL.md +9 -1
@@ -5,6 +5,7 @@ import { CONFIRM_INJECTION_RULE, McpToolError, toolAnnotations } from '@chrischa
5
5
  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
+ import { statedShifts, statedShiftWarning } from '../analysis/plan/estimates.js';
8
9
  import { parseGameId } from '../client.js';
9
10
  import { COMMANDER_STRENGTH, luckFraction, straightKills } from '../analysis/combat.js';
10
11
  import { guardOffExposure } from '../analysis/guard-off.js';
@@ -22,18 +23,26 @@ import { KNOWN_MODS } from '../known-mods.js';
22
23
  import { assumedWarning, awardView, firstMoverFor, loadAward, openingThreat } from './award.js';
23
24
  import { boardCardsInEffect, CARDS_IN_EFFECT_UNVERIFIED, sanctionMyIncome } from './card-effects.js';
24
25
  import { sanctionPercentage } from '../analysis/cards-in-effect.js';
25
- import { readMyOrderList } from '../my-orders.js';
26
+ import { myOrdersOf as committedOrdersOf, readMyOrderList } from '../my-orders.js';
27
+ import { checkAirlifts, checkTargeted, mismatchMessage, recordedWithCommit, sentAirlifts, sentTargeted, targetedMismatchParts } from './airlift-readback.js';
28
+ import { checkPlayerCards, playerCardMismatchParts, READ_BACK_PLAYER_CARDS, sentPlayerCards } from './player-card-readback.js';
29
+ import { alternativeOrders, cardsLeftAfter, playsCardType } from './alternative-orders.js';
30
+ /** The territory-targeted card plays read back after a commit (owner request 2026-11-24, part B). */
31
+ const READ_BACK_TARGETED = new Set(['Bomb', 'Blockade', 'EmergencyBlockade']);
32
+ import { compareScores, planAirlift, STAGING_DISCOUNT } from '../analysis/airlift-plan.js';
33
+ import { planBomb } from '../analysis/bomb-plan.js';
34
+ import { planBlockade, planWall } from '../analysis/blockade-plan.js';
26
35
  import { breaksInOrders } from '../mod-alliances.js';
27
36
  import { allyAttackLine, attacksOnAllies, MOD_ALLIANCES_NOTE, modAllianceWarnings, readModAlliances } from './mod-alliances.js';
28
37
  import { adviseCards, cardGame, cardPieceOption, giftInOrders, intelOrders, handOwners, lastTurnPlays, opponentCanHold, opponentReinforcement, reinforcementPlaysShown, seenReinforcementPlays, TEAM_HAND } from './card-advice.js';
29
- import { currentTurn, turnsCompleted, gameIdArg, knownIncomeArg, avoidPlayersArg, avoidTerritoriesArg, graphOf, namer, readAnnotations, respond, shownAccount, UNTRUSTED_PREVIEW_NOTE, untrustedDescription, untrustedText, viewArg, } from './common.js';
38
+ import { currentTurn, turnsCompleted, gameIdArg, knownIncomeArg, avoidPlayersArg, avoidTerritoriesArg, graphOf, namer, playerNamer, readAnnotations, respond, shownAccount, UNTRUSTED_PREVIEW_NOTE, untrustedDescription, untrustedText, viewArg, } from './common.js';
30
39
  import { lookupMeta, mintMeta } from './hints.js';
31
40
  import { chatSummary, privateToMeUnread, privateToMeWarning } from './chat.js';
32
41
  import { blockedLog, CHAT_BLOCKS_NOTE, chatSeats, planChatView, planStanding, turnChatBlocks, withBlocks } from './chat-advice.js';
33
42
  import { chatBlockLine } from '../analysis/chat-blocks.js';
34
43
  import { chatAutomationMode, chatBlocksTurnMode } from '../chat-automation.js';
35
44
  import { readPendingSurrenders, surrenderOwedLine } from './surrender-pending.js';
36
- import { failureText, loadLiveGame, requireApprovedAccount, standInLine, standInOf, writeAccount } from './live-context.js';
45
+ import { failureText, loadLiveGame, readLatestBoard, requireApprovedAccount, standInLine, standInOf, writeAccount } from './live-context.js';
37
46
  import { BRIDGE_NOTE, playerArg, resolveMe } from './live.js';
38
47
  import { guessOrdersOf, guessView } from './guess-view.js';
39
48
  import { guessSalt, peekGuessSalt } from '../guess-salt.js';
@@ -57,18 +66,19 @@ import { cardArmyCeiling, cardClock } from '../strategy/card-clock.js';
57
66
  import { hasCostlyBonus, noteContext, notesFor } from '../strategy/notes.js';
58
67
  import { sinceLastTurn } from '../analysis/since-last.js';
59
68
  import { readOutlookLog, recordOutlook } from '../outlook-log.js';
60
- import { bootTimes, captureChat, capturePlan, captureObservation, captureSent, cardAdviceLog, handLog, submitChecksLog } from './decision-capture.js';
69
+ import { bootTimes, captureChat, capturePlan, captureObservation, captureSeenTurn, captureSent, cardAdviceLog, handLog, submitChecksLog } from './decision-capture.js';
61
70
  import { chatTruces } from '../analysis/chat-read.js';
62
71
  import { readDecisionLog, scrubNames } from '../decision-log.js';
63
72
  import { readPickRecord } from '../pick-list.js';
64
73
  import { commitmentWarnings } from '../analysis/commitments.js';
65
74
  import { MAX_EXCEPTION_NOTE, planRelationsFrom, truceBreaksIn } from '../analysis/relations.js';
66
- import { exceptionNote, recordBrokenByMe, recordPartnerApproved } from './relations.js';
75
+ import { coordinationView, exceptionNote, recordBrokenByMe, recordPartnerApproved } from './relations.js';
67
76
  import { readPlayerRecord } from '../player-record-store.js';
68
77
  import { withTeammateOrders } from '../team-orders.js';
69
78
  import { claimedCardUses, claimedCardWarning, teamCardClaims, teamCardLimit, teamCardRoles, teamHandLeft, unclaimedFirst, } from '../team-cards.js';
70
79
  import { isTeamGame, teammatesOf } from '../teams.js';
71
80
  import { readLedger, recordTruceUsage } from '../relations-store.js';
81
+ import { coordinationDue, coordinationLine } from '../analysis/coordination.js';
72
82
  import { resolveIntel } from '../analysis/intel.js';
73
83
  import { readSiegeMemory, writeSiegeMemory } from '../siege-store.js';
74
84
  import { readBonusAttempts, writeBonusAttempts } from '../bonus-attempt-store.js';
@@ -169,7 +179,8 @@ const turnOrderArg = z.discriminatedUnion('kind', [
169
179
  player: playerRef
170
180
  .optional()
171
181
  .describe("Spy: the opponent to see (0 or \"neutral\": the neutral, when the game's Spy card allows it). Sanctions: the player whose " +
172
- 'income it cuts. Gift: who receives `target`. Id or name.'),
182
+ "income it changes — an opponent when the game's percentage is positive, yourself (or a teammate) when it is negative " +
183
+ '(a boost). Gift: who receives `target`. Id or name.'),
173
184
  players: z
174
185
  .array(playerRef)
175
186
  .length(2)
@@ -1512,7 +1523,7 @@ export async function livePlanSetup(ctx, a) {
1512
1523
  game, me, turn, graph, board: seen, boards: history.boards, myIncome: boardIncome, tracks, diplomacy: effect.diplomacy,
1513
1524
  });
1514
1525
  // The per-opponent estimates the plan works from (as planTurn reads them), for the tripwire and the border guess.
1515
- const { estimates } = planEnemyEstimates({
1526
+ const estimateArgs = {
1516
1527
  graph,
1517
1528
  board,
1518
1529
  me: me.id,
@@ -1526,7 +1537,12 @@ export async function livePlanSetup(ctx, a) {
1526
1537
  game: gameContext,
1527
1538
  turn,
1528
1539
  ...(effect.sanctionsOnOthers.length ? { sanctions: effect.sanctionsOnOthers } : {}),
1529
- });
1540
+ };
1541
+ const { estimates } = planEnemyEstimates(estimateArgs);
1542
+ // #567: the opponents a known income moves through #444's scale (the planner's own estimates carry it).
1543
+ const known = a.args?.knownIncome?.length && a.args.enemyDeploy === undefined ? a.args.knownIncome : undefined;
1544
+ const scaled = known ? planEnemyEstimates({ ...estimateArgs, known }) : undefined;
1545
+ const shifts = scaled ? statedShifts(estimates, scaled.estimates, scaled.prior) : [];
1530
1546
  // #275 (b): the opponents whose estimate an observation broke: their held-bonus borders are sized for
1531
1547
  // the larger of what tripped it and my own income (the board's, card armies out).
1532
1548
  const teams = teamsOf(game.players);
@@ -1642,11 +1658,314 @@ export async function livePlanSetup(ctx, a) {
1642
1658
  return {
1643
1659
  graph, seen, award, board, opening, mover, settings, rules, owners, hand, myHand, myCards, teamClaimed, handUnknown, inGame, cards,
1644
1660
  boardIncome, income, trend, previousOrders, tracks, outlookInput, outlook, picking, opponents, gameContext, truces, input,
1645
- effect, sanction, incomeCap, capUnknown: incomeOnBoard.capUnknown === true, estimates, trip, teams, commerce,
1661
+ effect, sanction, incomeCap, capUnknown: incomeOnBoard.capUnknown === true, estimates, trip, teams, commerce, statedShifts: shifts,
1646
1662
  // #427: the last turn's Reinforcement plays, for warapp_plan_turn to keep (only when plays show).
1647
1663
  seenPlays: playsShown ? lastPlays : undefined,
1648
1664
  };
1649
1665
  }
1666
+ /** The Airlift card's type id. */
1667
+ const CARD_AIRLIFT = 6;
1668
+ /**
1669
+ * Owner request 2026-11-24 (part 3): `airliftPlan`, the best plan that plays my Airlift cards, beside the plain plan
1670
+ * (`src/analysis/airlift-plan.ts`; the plain plan and its `orders` never change). Only when I hold an Airlift card:
1671
+ * `undefined` otherwise, so a hand without one adds no field. Its orders are the plain orders' card plays and
1672
+ * discards, the Airlift plays, then the Airlift plan's deploys and moves; the advised Order Delay is left out (its
1673
+ * place names a move of the plain plan) and, when it had to leave the hand, discarded instead. A plan the submit's
1674
+ * commander check would refuse while the plain plan passes it is not offered.
1675
+ */
1676
+ async function airliftPlanView(a) {
1677
+ const used = new Set([...a.cards.plays, ...a.cards.discards].map((c) => c.id));
1678
+ const held = a.myCards.filter((c) => c.type === CARD_AIRLIFT);
1679
+ if (!held.length)
1680
+ return undefined;
1681
+ const free = held.filter((c) => !used.has(c.id));
1682
+ const playable = Math.max(0, free.length - a.keepCards);
1683
+ const none = (note) => ({ airliftPlan: null, airliftPlanNote: note });
1684
+ if (!playable)
1685
+ return none(`You hold ${held.length} Airlift card${held.length === 1 ? '' : 's'}, ${free.length < held.length ? 'the plain plan already uses some, and ' : ''}` +
1686
+ `${a.keepCards} ${a.keepCards === 1 ? 'is' : 'are'} kept in reserve (keep_cards): no Airlift plan.`);
1687
+ if (a.gift.cards.length)
1688
+ return none('The plain plan plays a Gift, which lands after an Airlift: no Airlift plan is made beside it.');
1689
+ const guardOn = a.game.settings?.oneArmyStandsGuard !== false;
1690
+ const found = planAirlift({ input: a.setup.input, plain: a.plan, cards: playable, guard: guardOn });
1691
+ if (!found.best)
1692
+ return none(`No Airlift beats the plain plan by its own measure (next income if its conceded borders fall, plus ${STAGING_DISCOUNT} × ` +
1693
+ `a staged capture's bonus next turn, then next income, ` +
1694
+ `fewer concessions, more captures): ${found.considered} tried${found.invalid ? `, ${found.invalid} dropped as orders the submit would refuse` : ''}.`);
1695
+ const best = found.best;
1696
+ const moves = best.plan.moves.map((m) => ({ from: m.from, to: m.to, armies: m.armies, ...(m.commander ? { withCommander: true } : {}) }));
1697
+ const checked = await commanderCheck(a.ctx, {
1698
+ game: a.game,
1699
+ me: a.me,
1700
+ map: a.map,
1701
+ seen: a.seen,
1702
+ turn: a.turn,
1703
+ info: a.info,
1704
+ hand: a.hand,
1705
+ income: a.setup.boardIncome,
1706
+ tripwires: a.setup.trip.tripwires,
1707
+ deploys: best.plan.deploys,
1708
+ moves,
1709
+ // #558: the Airlift orders carry the plain card plays, an advised Order Priority included.
1710
+ orderPriority: playsCardType(a.orders, a.myCards, CARD_ORDER_PRIORITY),
1711
+ ...(a.enemyDeploy !== undefined ? { floor: a.enemyDeploy } : {}),
1712
+ killedBy: false,
1713
+ airlifts: best.airlifts.map(({ from, to, armies }) => ({ from, to, armies })),
1714
+ });
1715
+ if (checked?.risk && a.plainCommanderSafe)
1716
+ return none('The best Airlift plan would leave your commander takeable (warapp_submit_turn would refuse it), so none is offered.');
1717
+ const lifts = best.airlifts.map((l, i) => ({ ...l, card: free[i].id }));
1718
+ // #558: the advised Order Delay is discarded only when the plain card choice had to shed it.
1719
+ const orders = alternativeOrders({
1720
+ orders: a.orders,
1721
+ delayOrder: a.delayOrder,
1722
+ playedDelay: a.playedDelay,
1723
+ delayMustGo: a.playedDelay !== undefined && a.cards.discards.some((c) => c.id === a.playedDelay),
1724
+ cardPlays: lifts.map((l) => ({ kind: 'card', card: l.card, from: l.from, to: l.to, armies: l.armies })),
1725
+ deploys: best.plan.deploys.map((d) => ({ kind: 'deploy', territory: d.territoryId, armies: d.armies })),
1726
+ moves: best.plan.moves.map((m) => ({ kind: 'move', from: m.from, to: m.to, armies: m.armies, ...(m.commander ? { commander: true } : {}) })),
1727
+ });
1728
+ const minus = (x, y) => x.filter((v) => !y.includes(v)).sort((p, q) => p - q);
1729
+ const atRisk = (p) => (p.expected.bonusesAtRisk ?? []).map((b) => b.bonusId);
1730
+ return {
1731
+ airliftPlan: {
1732
+ airlifts: lifts.map((l) => ({ from: a.name(l.from), to: a.name(l.to), armies: l.armies, kind: l.kind })),
1733
+ // Owner decision 2026-11-24 (A, DRAFT): an Airlift staged for next turn's capture.
1734
+ ...(lifts.some((l) => l.staging)
1735
+ ? {
1736
+ staging: lifts.flatMap((l) => l.staging
1737
+ ? [{ target: a.name(l.staging.target), from: a.name(l.to), nextTurnAttack: l.staging.attack, defendersSizedFor: l.staging.defenders, bonusValue: l.staging.gain }]
1738
+ : []),
1739
+ }
1740
+ : {}),
1741
+ orders,
1742
+ expected: {
1743
+ captures: best.plan.expected.captures,
1744
+ bonusesCompleted: best.plan.expected.bonusesCompleted,
1745
+ nextIncome: best.plan.expected.nextIncome,
1746
+ ...(best.plan.expected.nextIncomeIfConcededFall !== undefined ? { nextIncomeIfConcededFall: best.plan.expected.nextIncomeIfConcededFall } : {}),
1747
+ },
1748
+ delta: {
1749
+ twoTurn: Math.round((best.score.twoTurn - best.plainScore.twoTurn) * 100) / 100,
1750
+ nextIncomeIfConcededFall: best.score.safeIncome - best.plainScore.safeIncome,
1751
+ nextIncome: best.score.nextIncome - best.plainScore.nextIncome,
1752
+ captures: best.score.captures - best.plainScore.captures,
1753
+ borders: { saved: minus(a.plan.conceded, best.plan.conceded), conceded: minus(best.plan.conceded, a.plan.conceded) },
1754
+ bonuses: {
1755
+ completed: minus(best.plan.expected.bonusesCompleted, a.plan.expected.bonusesCompleted),
1756
+ notCompleted: minus(a.plan.expected.bonusesCompleted, best.plan.expected.bonusesCompleted),
1757
+ saved: minus(atRisk(a.plan), atRisk(best.plan)),
1758
+ atRisk: minus(atRisk(best.plan), atRisk(a.plan)),
1759
+ },
1760
+ },
1761
+ cardsSpent: lifts.length,
1762
+ // #558: the Airlift cards the plain plan leaves, less those this plan spends.
1763
+ cardsLeft: cardsLeftAfter({ held: held.length, free: free.length, spent: lifts.length }),
1764
+ keepCards: a.keepCards,
1765
+ considered: best.considered,
1766
+ ...(checked ? { commander: { safe: !checked.risk, ...(checked.risk ? { needs: checked.risk.needs } : {}) } } : {}),
1767
+ note: AIRLIFT_PLAN_NOTE,
1768
+ },
1769
+ };
1770
+ }
1771
+ /** The Bomb card's type id. */
1772
+ const CARD_BOMB = 13;
1773
+ /**
1774
+ * Owner request 2026-11-24 (part B): `bombPlan`, the best plan that plays one Bomb card, beside the plain plan
1775
+ * (`src/analysis/bomb-plan.ts`; the plain plan and its `orders` never change). Only when I hold a Bomb card. Its
1776
+ * orders: the plain card plays and discards, the Bomb play, then the Bomb plan's deploys and moves (the advised Order
1777
+ * Delay left out, as in the Airlift plan). A plan the submit's commander check would refuse while the plain plan
1778
+ * passes it is not offered.
1779
+ */
1780
+ async function bombPlanView(a) {
1781
+ const used = new Set([...a.cards.plays, ...a.cards.discards].map((c) => c.id));
1782
+ const held = a.myCards.filter((c) => c.type === CARD_BOMB);
1783
+ if (!held.length)
1784
+ return undefined;
1785
+ const free = held.filter((c) => !used.has(c.id));
1786
+ const none = (note) => ({ bombPlan: null, bombPlanNote: note });
1787
+ if (!free.length)
1788
+ return none('The plain plan already plays or discards your Bomb card: no Bomb plan.');
1789
+ const found = planBomb({ input: a.setup.input, plain: a.plan, cards: free.length });
1790
+ if (!found.best)
1791
+ return none(`No Bomb beats the plain plan by its own measure (next income if its conceded borders fall, then next income, fewer ` +
1792
+ `concessions, more captures): ${found.considered} target${found.considered === 1 ? '' : 's'} tried.`);
1793
+ const best = found.best;
1794
+ const checked = await commanderCheck(a.ctx, {
1795
+ game: a.game,
1796
+ me: a.me,
1797
+ map: a.map,
1798
+ seen: a.seen,
1799
+ turn: a.turn,
1800
+ info: a.info,
1801
+ hand: a.hand,
1802
+ income: a.setup.boardIncome,
1803
+ tripwires: a.setup.trip.tripwires,
1804
+ deploys: best.plan.deploys,
1805
+ moves: best.plan.moves.map((m) => ({ from: m.from, to: m.to, armies: m.armies, ...(m.commander ? { withCommander: true } : {}) })),
1806
+ orderPriority: playsCardType(a.orders, a.myCards, CARD_ORDER_PRIORITY),
1807
+ ...(a.enemyDeploy !== undefined ? { floor: a.enemyDeploy } : {}),
1808
+ killedBy: false,
1809
+ });
1810
+ if (checked?.risk && a.plainCommanderSafe)
1811
+ return none('The best Bomb plan would leave your commander takeable (warapp_submit_turn would refuse it), so none is offered.');
1812
+ const card = free[0].id;
1813
+ // #558: the advised Order Delay is discarded only when the plain card choice had to shed it.
1814
+ const orders = alternativeOrders({
1815
+ orders: a.orders,
1816
+ delayOrder: a.delayOrder,
1817
+ playedDelay: a.playedDelay,
1818
+ delayMustGo: a.playedDelay !== undefined && a.cards.discards.some((c) => c.id === a.playedDelay),
1819
+ cardPlays: [{ kind: 'card', card, target: best.bomb.target }],
1820
+ deploys: best.plan.deploys.map((d) => ({ kind: 'deploy', territory: d.territoryId, armies: d.armies })),
1821
+ moves: best.plan.moves.map((m) => ({ kind: 'move', from: m.from, to: m.to, armies: m.armies, ...(m.commander ? { commander: true } : {}) })),
1822
+ });
1823
+ const minus = (x, y) => x.filter((v) => !y.includes(v)).sort((p, q) => p - q);
1824
+ return {
1825
+ bombPlan: {
1826
+ bomb: { target: a.name(best.bomb.target), kind: best.bomb.kind, armies: best.bomb.armies, leaves: best.bomb.left },
1827
+ orders,
1828
+ expected: {
1829
+ captures: best.plan.expected.captures,
1830
+ bonusesCompleted: best.plan.expected.bonusesCompleted,
1831
+ nextIncome: best.plan.expected.nextIncome,
1832
+ ...(best.plan.expected.nextIncomeIfConcededFall !== undefined ? { nextIncomeIfConcededFall: best.plan.expected.nextIncomeIfConcededFall } : {}),
1833
+ },
1834
+ delta: {
1835
+ nextIncomeIfConcededFall: best.score.safeIncome - best.plainScore.safeIncome,
1836
+ nextIncome: best.score.nextIncome - best.plainScore.nextIncome,
1837
+ captures: best.score.captures - best.plainScore.captures,
1838
+ borders: { saved: minus(a.plan.conceded, best.plan.conceded), conceded: minus(best.plan.conceded, a.plan.conceded) },
1839
+ },
1840
+ cardsSpent: 1,
1841
+ cardsLeft: cardsLeftAfter({ held: held.length, free: free.length, spent: 1 }),
1842
+ considered: found.considered,
1843
+ ...(checked ? { commander: { safe: !checked.risk, ...(checked.risk ? { needs: checked.risk.needs } : {}) } } : {}),
1844
+ note: BOMB_PLAN_NOTE,
1845
+ },
1846
+ };
1847
+ }
1848
+ /** The Emergency Blockade card's type id (the Blockade's is `CARD_BLOCKADE`, from src/cards.ts). */
1849
+ const CARD_EMERGENCY_BLOCKADE = 3;
1850
+ /**
1851
+ * Owner request 2026-11-24 (part B): `blockadePlan`, the best wall plan beside the plain plan, whose `orders` never
1852
+ * change (`src/analysis/blockade-plan.ts`). Only when I hold an Emergency Blockade or a Blockade card: an Emergency
1853
+ * Blockade walls a conceded border before every move (`planWall`, the walled board planned), a Blockade walls a
1854
+ * territory after the attacks while the stress-tested line keeps it mine (`planBlockade`, the plain orders plus the
1855
+ * card); each is worth the bonus its fall would hand an opponent (× 0.8, owner-approved 2026-11-24), and the better
1856
+ * of the two is offered (`card` names it).
1857
+ */
1858
+ async function blockadePlanView(a) {
1859
+ const used = new Set([...a.cards.plays, ...a.cards.discards].map((c) => c.id));
1860
+ const walls = a.myCards.filter((c) => c.type === CARD_EMERGENCY_BLOCKADE);
1861
+ const blockades = a.myCards.filter((c) => c.type === CARD_BLOCKADE);
1862
+ if (!walls.length && !blockades.length)
1863
+ return undefined;
1864
+ const none = (note) => ({ blockadePlan: null, blockadePlanNote: note });
1865
+ const multiplierOf = (key) => {
1866
+ const raw = a.game.settings?.raw[key];
1867
+ return typeof raw === 'object' && raw !== null ? Number(raw.MultiplyAmount) : Number.NaN;
1868
+ };
1869
+ // Each wall card held and not used by the plain plan: the Emergency Blockade (phase 37, the walled board planned) and
1870
+ // the Blockade (phase 60, owner decision 2026-11-24: the plain orders plus the card); the better plan is offered.
1871
+ const freeWalls = walls.filter((c) => !used.has(c.id));
1872
+ const freeBlockades = blockades.filter((c) => !used.has(c.id));
1873
+ if (!freeWalls.length && !freeBlockades.length)
1874
+ return none('The plain plan already plays or discards your wall cards: no wall plan.');
1875
+ const tries = [];
1876
+ const notes = [];
1877
+ if (freeWalls.length) {
1878
+ const m = multiplierOf('EmergencyBlockadeCard');
1879
+ if (m > 0)
1880
+ tries.push({ kind: 'EmergencyBlockade', card: freeWalls[0].id, held: walls.length, free: freeWalls.length, found: planWall({ input: a.setup.input, plain: a.plan, cards: freeWalls.length, multiplier: m }) });
1881
+ else
1882
+ notes.push("the game's settings give no Emergency Blockade multiplier");
1883
+ }
1884
+ if (freeBlockades.length) {
1885
+ const m = multiplierOf('BlockadeCard');
1886
+ if (m > 0)
1887
+ tries.push({ kind: 'Blockade', card: freeBlockades[0].id, held: blockades.length, free: freeBlockades.length, found: planBlockade({ input: a.setup.input, plain: a.plan, cards: freeBlockades.length, multiplier: m }) });
1888
+ else
1889
+ notes.push("the game's settings give no Blockade multiplier");
1890
+ }
1891
+ const winner = tries
1892
+ .filter((t) => t.found.best)
1893
+ .sort((x, y) => compareScores(x.found.best.score, y.found.best.score))[0];
1894
+ if (!winner)
1895
+ return none(`No wall beats the plain plan (with the bonus a wall denies counted): ${tries.map((t) => `${t.found.considered} ${t.kind === 'Blockade' ? 'Blockade' : 'Emergency Blockade'} target(s) tried`).join(', ') || 'none tried'}${notes.length ? `; ${notes.join('; ')}` : ''}.`);
1896
+ const found = winner.found;
1897
+ const best = found.best;
1898
+ const checked = await commanderCheck(a.ctx, {
1899
+ game: a.game,
1900
+ me: a.me,
1901
+ map: a.map,
1902
+ seen: a.seen,
1903
+ turn: a.turn,
1904
+ info: a.info,
1905
+ hand: a.hand,
1906
+ income: a.setup.boardIncome,
1907
+ tripwires: a.setup.trip.tripwires,
1908
+ deploys: best.plan.deploys,
1909
+ moves: best.plan.moves.map((m) => ({ from: m.from, to: m.to, armies: m.armies, ...(m.commander ? { withCommander: true } : {}) })),
1910
+ orderPriority: playsCardType(a.orders, a.myCards, CARD_ORDER_PRIORITY),
1911
+ ...(a.enemyDeploy !== undefined ? { floor: a.enemyDeploy } : {}),
1912
+ killedBy: false,
1913
+ });
1914
+ if (checked?.risk && a.plainCommanderSafe)
1915
+ return none('The best wall plan would leave your commander takeable (warapp_submit_turn would refuse it), so none is offered.');
1916
+ const card = winner.card;
1917
+ // A Blockade adds only its card play to the plain orders (they stand unchanged); an Emergency Blockade's plan has its
1918
+ // own, and (#558) discards the advised Order Delay only when the plain card choice had to shed it.
1919
+ const orders = winner.kind === 'Blockade'
1920
+ ? [...a.orders, { kind: 'card', card, target: best.wall.target }]
1921
+ : alternativeOrders({
1922
+ orders: a.orders,
1923
+ delayOrder: a.delayOrder,
1924
+ playedDelay: a.playedDelay,
1925
+ delayMustGo: a.playedDelay !== undefined && a.cards.discards.some((c) => c.id === a.playedDelay),
1926
+ cardPlays: [{ kind: 'card', card, target: best.wall.target }],
1927
+ deploys: best.plan.deploys.map((d) => ({ kind: 'deploy', territory: d.territoryId, armies: d.armies })),
1928
+ moves: best.plan.moves.map((m) => ({ kind: 'move', from: m.from, to: m.to, armies: m.armies, ...(m.commander ? { commander: true } : {}) })),
1929
+ });
1930
+ return {
1931
+ blockadePlan: {
1932
+ card: winner.kind === 'Blockade' ? 'Blockade' : 'Emergency Blockade',
1933
+ wall: {
1934
+ target: a.name(best.wall.target),
1935
+ armies: best.wall.armies,
1936
+ wall: best.wall.wall,
1937
+ ...(best.wall.denied ? { denies: { bonusValue: best.wall.denied, player: best.wall.deniedFrom } } : {}),
1938
+ },
1939
+ orders,
1940
+ expected: {
1941
+ captures: best.plan.expected.captures,
1942
+ nextIncome: best.plan.expected.nextIncome,
1943
+ ...(best.plan.expected.nextIncomeIfConcededFall !== undefined ? { nextIncomeIfConcededFall: best.plan.expected.nextIncomeIfConcededFall } : {}),
1944
+ },
1945
+ delta: {
1946
+ twoTurn: Math.round((best.score.twoTurn - best.plainScore.twoTurn) * 100) / 100,
1947
+ nextIncomeIfConcededFall: best.score.safeIncome - best.plainScore.safeIncome,
1948
+ nextIncome: best.score.nextIncome - best.plainScore.nextIncome,
1949
+ },
1950
+ cardsSpent: 1,
1951
+ cardsLeft: cardsLeftAfter({ held: winner.held, free: winner.free, spent: 1 }),
1952
+ considered: found.considered,
1953
+ ...(checked ? { commander: { safe: !checked.risk, ...(checked.risk ? { needs: checked.risk.needs } : {}) } } : {}),
1954
+ note: WALL_PLAN_NOTE,
1955
+ },
1956
+ };
1957
+ }
1958
+ const WALL_PLAN_NOTE = 'An alternative to `orders`, never applied: an Emergency Blockade walls a conceded border before every move (the ' +
1959
+ 'planner plans the walled board); a Blockade walls a territory after the attacks, the plain orders unchanged, only ' +
1960
+ "while the stress-tested line keeps it yours. Either turns it neutral at its armies × the game's multiplier and is " +
1961
+ 'worth the bonus its fall would hand an opponent (× 0.8, owner-approved 2026-11-24), less any bonus of yours it gives ' +
1962
+ 'up. The Emergency Blockade play\'s encoding is UNVERIFIED live. Test it with warapp_check_plan.';
1963
+ const BOMB_PLAN_NOTE = 'An alternative to `orders`, never applied: the same planner on the board the Bomb leaves (it runs after the deploys ' +
1964
+ 'and before every move; its target keeps half its armies, rounded down), compared by the plain plan\'s own measure. ' +
1965
+ 'The Bomb play\'s encoding is UNVERIFIED live. Test it with warapp_check_plan, then pass its `orders` to warapp_submit_turn if you prefer it.';
1966
+ const AIRLIFT_PLAN_NOTE = 'An alternative to `orders`, never applied: the same planner on the board the Airlifts leave (their armies land after ' +
1967
+ 'the deploys and before every move, and cannot move again that turn), compared by the plain plan\'s own measure. ' +
1968
+ 'Test it with warapp_check_plan, then pass its `orders` to warapp_submit_turn if you prefer it.';
1650
1969
  /**
1651
1970
  * #274: whether these orders leave my commander takeable by a single-deploy reply (`commanderCheckOn`,
1652
1971
  * src/tools/commander-check.ts: the one check, which warapp_check_plan reports too), each reply sized at
@@ -1920,7 +2239,7 @@ export function registerTurnTools(server, ctx, opts = {}) {
1920
2239
  'withdrawal worth a card, a commander strike) or it is the card that must go (over the hold limit the cards worth ' +
1921
2240
  'least in this game leave first; the timing cards are kept longest); never Blockade, Order Delay, Bomb or Emergency ' +
1922
2241
  'Blockade — `cards.advice` says where those pay (Order Delay above the calm orders, a Bomb target or hold it, an ' +
1923
- "Emergency Blockade wall on a conceded border that shields a bonus or your commander behind it, or kills more than it gives up, never where the stack can go around; Diplomacy on the opponent pressing you hardest when two or more do, Sanctions on the leader, an Airlift onto a " +
2242
+ "Emergency Blockade wall on a conceded border that shields a bonus or your commander behind it, or kills more than it gives up, never where the stack can go around; Diplomacy on the opponent pressing you hardest when two or more do, Sanctions on the leader (on yourself when the game's percentage is negative, with `income`: your next income before and after the boost; never a negative card on an opponent nor a positive one on you), an Airlift onto a " +
1924
2243
  "border of yours or a teammate's that falls without it, a Gift that completes a teammate's bonus, Spy, Reconnaissance or Surveillance " +
1925
2244
  'where the fog hides what the plan needs (never with fog off) — each with an `order` to pass to ' +
1926
2245
  "warapp_submit_turn, never added to the orders — save a completing Gift (verified live; the transfers it would strand are dropped) and a Reconnaissance, which go into `orders`), and the warnings flag an opponent's Bomb or Emergency Blockade and the cards in effect. Moves are listed in the " +
@@ -1964,7 +2283,9 @@ export function registerTurnTools(server, ctx, opts = {}) {
1964
2283
  'is watch; a border cap kept; a partner-approved truce exception on this turn makes its territories normal ' +
1965
2284
  'targets, listed under the truce as `exceptions`), `advice` says `give-notice` when the endgame or the partner outgrowing you made ' +
1966
2285
  'the trust watch, a truce the board shows broken is planned as an ordinary opponent, and `tacit` lists quiet ' +
1967
- 'borders with no agreement (a report, never a truce). In a game running the Diplomacy 2 mod (mod 191) each ally ' +
2286
+ 'borders with no agreement (a report, never a truce); `coordination` lists the joint attacks recorded with ' +
2287
+ 'warapp_record_agreement due this turn, each told in a rationale line ("Agreed with player P … they hit X, you ' +
2288
+ 'follow on Y") — report only, the orders never read it. In a game running the Diplomacy 2 mod (mod 191) each ally ' +
1968
2289
  'is an enforced truce in any format (`mod: "Diplomacy 2"`): the game skips attacks between allies, so none is ' +
1969
2290
  'planned and its threat is 0 this turn, but it still counts for next turn (a break applies at the end of the turn ' +
1970
2291
  'it is entered, unseen); `modAlliances` lists the allies read (UNVERIFIED live). The plan never reads what your chat promised ' +
@@ -1985,6 +2306,25 @@ export function registerTurnTools(server, ctx, opts = {}) {
1985
2306
  '`guess` is a randomized split, weighted by what each border is worth, against an opponent who would read a fixed ' +
1986
2307
  'one, and `guessOrders` the plan\'s `orders` with that split — optional (the user chooses; `orders` stay the ' +
1987
2308
  "plan's), and a model: one opponent, one deploy, its visible stacks. " +
2309
+ 'Holding an Airlift card, `airliftPlan` is an alternative beside the plan (its `orders` never change): the same ' +
2310
+ 'planner on the board after the Airlifts (an interior stack flown onto a border the plan concedes, or a conceded ' +
2311
+ "border's armies flown to the border most pressed), the best compared by the plan's own measure (next income if " +
2312
+ 'its conceded borders fall, then next income, fewer concessions, more captures) — `airlifts`, `orders` (the Airlift ' +
2313
+ 'plays included), `expected`, `delta` (income, captures, borders saved, bonuses kept or completed), `cardsSpent`, ' +
2314
+ '`cardsLeft`; `keep_cards` holds cards back; `null` with `airliftPlanNote` when none beats the plan. Airlifted armies ' +
2315
+ 'cannot attack that turn, so a capture is staged for NEXT turn instead (`staging`: an interior stack flown beside a ' +
2316
+ 'target the plan does not take whose capture completes a bonus of yours or breaks an opponent\'s, with the target, ' +
2317
+ '`nextTurnAttack` and the bonus value), scored on a two-turn objective — this turn\'s measure plus 0.8 × that bonus ' +
2318
+ '(`delta.twoTurn`) — and only when the staged stack holds against the plan\'s threat at that border. ' +
2319
+ 'Holding a Bomb card, `bombPlan` is the same kind of alternative: the planner on the board the Bomb leaves (its target ' +
2320
+ 'keeps half its armies, rounded down — an opponent\'s territory beside yours, a held bonus\'s member first, then the ' +
2321
+ 'largest stacks; never a player at peace with you) — `bomb`, `orders` (the Bomb play included), `expected`, `delta`; ' +
2322
+ '`null` with `bombPlanNote` when none beats the plan (the Bomb play\'s encoding is unverified live). ' +
2323
+ 'Holding an Emergency Blockade, `blockadePlan` walls off a border the plan concedes (neutral at its armies × the ' +
2324
+ "game's multiplier, before every move), worth the bonus its fall would hand an opponent when the wall holds this turn; " +
2325
+ 'holding a Blockade, the plain orders plus a Blockade on a territory of yours the attacks leave yours (it walls it ' +
2326
+ 'after them), worth the same denial less any bonus of yours it gives up — the better one, with `card`, `wall`, ' +
2327
+ '`orders`, `delta`. ' +
1988
2328
  '`reads` (opponent profiles, as warapp_profile_opponents reads them; reported only, the plan never uses them): ' +
1989
2329
  'each opponent in contact with a habit at the confidence bar or a label — its labels, `lastAttackTurn` (the last turn it attacked you), those habits with `n` and ' +
1990
2330
  '`basis`, `gamesMet` — a likelihood, never a certainty, and never to be quoted to another player. ' +
@@ -2073,10 +2413,18 @@ export function registerTurnTools(server, ctx, opts = {}) {
2073
2413
  'opponent may hold one too and the order ends a player). In a ' +
2074
2414
  'two-player game under a cyclic order it is remembered and later turns default to it, alternated; ' +
2075
2415
  'omitted, the default is that, else the award of picks, else unknown (`firstMover` says which).'),
2416
+ keep_cards: z.coerce
2417
+ .number()
2418
+ .int()
2419
+ .min(0)
2420
+ .max(100)
2421
+ .optional()
2422
+ .describe('Airlift cards to keep in reserve: `airliftPlan` plays only those held beyond this many (default 0). ' +
2423
+ 'Changes nothing when you hold no Airlift.'),
2076
2424
  view: viewArg(VIEWS, 'compact (default) gives the plan and orders (the profile as format, phase and standing); "full" adds each ' +
2077
2425
  'move\'s reason, the whole profile and the settings the plan assumed.'),
2078
2426
  }),
2079
- }, async ({ game_id, player, goal, siege_target, jabs, focus, reserve, enemy_deploy, known_income, fogged_attackers, avoid_territories, avoid_players, min_win_chance, first_mover, view }) => {
2427
+ }, async ({ game_id, player, goal, siege_target, jabs, focus, reserve, enemy_deploy, known_income, fogged_attackers, avoid_territories, avoid_players, min_win_chance, first_mover, keep_cards, view }) => {
2080
2428
  // The chat comes in the same GameFeed read: the fallback for the unread counts (part A1).
2081
2429
  const feed = await ctx.client.getGame(game_id, { settings: true, chat: true });
2082
2430
  requireTurnPhase(feed);
@@ -2173,6 +2521,8 @@ export function registerTurnTools(server, ctx, opts = {}) {
2173
2521
  // #427: the Reinforcement plays the last turn's orders showed (a fact, kept on a what-if plan too).
2174
2522
  if (ctx.dataDir && setup.seenPlays)
2175
2523
  await writeSeenPlays(ctx.dataDir, game.id, me.id, setup.seenPlays.turn, setup.seenPlays.players);
2524
+ // #570: every player's visible orders on the turn just resolved, kept on that turn's decision-log entry (a fact: a what-if too).
2525
+ await captureSeenTurn(ctx, game, me.id, info, turn);
2176
2526
  // #275 (b): this turn's estimates and the untrusted marks, for the next turns' tripwire. Kept on a
2177
2527
  // what-if plan too, unlike its neighbours: both come from the boards alone — the estimates are the
2178
2528
  // default ones (planEnemyEstimates never reads enemy_deploy or goal) and a mark is an observation —
@@ -2228,6 +2578,8 @@ export function registerTurnTools(server, ctx, opts = {}) {
2228
2578
  truces: inForce.map((r) => ({ player: r.player, state: r.state, coveredMine: r.coveredMine, ...(r.endsTurn !== undefined ? { endsTurn: r.endsTurn } : {}) })),
2229
2579
  ...(effect.diplomacy.length ? { enforced: new Set(effect.diplomacy.map((d) => d.player)) } : {}),
2230
2580
  ...(sanction.applied ? { sanctionsApplied: true } : {}),
2581
+ // Owner request 2026-11-24: a self-Sanctions boost is measured on the plan's next income.
2582
+ nextIncome: plan.expected.nextIncome,
2231
2583
  })
2232
2584
  : { view: {}, warnings: [] };
2233
2585
  // #412: the decision log — this turn's decision (a what-if plan is only an observation of the board,
@@ -2293,6 +2645,8 @@ export function registerTurnTools(server, ctx, opts = {}) {
2293
2645
  ...(setup.capUnknown ? [`Income ${income} is not cut by the army cap: an army count of yours is unreadable on the board.`] : []),
2294
2646
  ...[armyCapPoolsUncertainty(setup.incomeCap, settings.localDeployments)].filter((r) => r !== undefined),
2295
2647
  ...(tracks ?? []).flatMap((t) => t.warnings),
2648
+ // #567: a known income that moved another opponent's estimate through #444's scale, by how much.
2649
+ ...[statedShiftWarning(setup.statedShifts, playerNamer(game.players))].filter((w) => w !== null),
2296
2650
  ...plan.warnings,
2297
2651
  ...promised,
2298
2652
  ...modsWarning(game.settings),
@@ -2464,6 +2818,47 @@ export function registerTurnTools(server, ctx, opts = {}) {
2464
2818
  ...(advised ? { orderPriority: true } : {}),
2465
2819
  });
2466
2820
  const guessOrders = guess ? guessOrdersOf(orders, guess) : undefined;
2821
+ // Owner request 2026-11-24: with Airlift cards in hand, the best plan that plays them, ALONGSIDE the plain
2822
+ // plan (whose orders never change): candidates scored by the plain plan's own measure (airlift-plan.ts).
2823
+ const airlift = await airliftPlanView({
2824
+ ctx,
2825
+ game,
2826
+ me,
2827
+ map,
2828
+ seen,
2829
+ turn,
2830
+ info,
2831
+ hand,
2832
+ setup,
2833
+ plan,
2834
+ orders,
2835
+ myCards,
2836
+ cards,
2837
+ playedDelay,
2838
+ gift,
2839
+ delayOrder: advice.view.orderDelay?.order,
2840
+ keepCards: keep_cards ?? 0,
2841
+ plainCommanderSafe: checked?.risk === undefined,
2842
+ enemyDeploy: enemy_deploy,
2843
+ name,
2844
+ });
2845
+ // Owner request 2026-11-24 (B): with a Bomb card in hand, the best plan that plays it, ALONGSIDE the plain plan.
2846
+ const bomb = await bombPlanView({
2847
+ ctx, game, me, map, seen, turn, info, hand, setup, plan, orders, myCards, cards, playedDelay, gift,
2848
+ delayOrder: advice.view.orderDelay?.order,
2849
+ keepCards: 0,
2850
+ plainCommanderSafe: checked?.risk === undefined,
2851
+ enemyDeploy: enemy_deploy,
2852
+ name,
2853
+ });
2854
+ const wallPlan = await blockadePlanView({
2855
+ ctx, game, me, map, seen, turn, info, hand, setup, plan, orders, myCards, cards, playedDelay, gift,
2856
+ delayOrder: advice.view.orderDelay?.order,
2857
+ keepCards: 0,
2858
+ plainCommanderSafe: checked?.risk === undefined,
2859
+ enemyDeploy: enemy_deploy,
2860
+ name,
2861
+ });
2467
2862
  // #385: siege_target only means something under goal siege; say so rather than drop it silently.
2468
2863
  if (siege_target !== undefined && goal !== 'siege')
2469
2864
  warnings.push(`siege_target is ignored: it applies only with goal "siege" (this plan's goal is ${goal ?? 'chosen by the game profile'}).`);
@@ -2545,6 +2940,12 @@ export function registerTurnTools(server, ctx, opts = {}) {
2545
2940
  // #415 task 4b: the unread messages that would block the submit (report only: no order reads them). The
2546
2941
  // truces from the ledger, contact from this board, the surrenders this plan read; no request of its own.
2547
2942
  const planLedger = ctx.dataDir ? await readLedger(ctx.dataDir, game.id, me.id) : undefined;
2943
+ // Coordination notes due this turn (warapp_record_agreement `coordination`): told, never an order.
2944
+ const coordDue = turn === null ? [] : (planLedger?.coordination ?? []).filter((c) => coordinationDue(c, turn));
2945
+ const coordLines = coordDue.map((c) => coordinationLine(c, (t) => {
2946
+ const n = name(t);
2947
+ return `${n.name} (#${t})`;
2948
+ }));
2548
2949
  const blocks = chat
2549
2950
  ? turnChatBlocks(chat, game, {
2550
2951
  meId: me.id,
@@ -2612,6 +3013,7 @@ export function registerTurnTools(server, ctx, opts = {}) {
2612
3013
  // #298: the contested bonuses pushed all-in or dropped after repeated failed attempts; absent with none.
2613
3014
  ...(plan.bonusPush ? { bonusPush: plan.bonusPush } : {}),
2614
3015
  ...(coalition ? { coalition } : {}),
3016
+ ...(coordDue.length ? { coordination: coordDue.map((c) => coordinationView(c, game, map, turn ?? 0)) } : {}),
2615
3017
  // #276: the guard case first, on or off, with what it means for interior defence.
2616
3018
  profile: rung === 'full'
2617
3019
  ? { guard: guardCase(game.settings), ...plan.profile }
@@ -2672,10 +3074,18 @@ export function registerTurnTools(server, ctx, opts = {}) {
2672
3074
  ...(() => {
2673
3075
  const allies = new Set(teammatesOf(game.players, me).map((p) => p.id));
2674
3076
  const rows = estimates
2675
- .filter((e) => e.playerId !== me.id && !allies.has(e.playerId) && inScope(e.playerId) && (e.card || e.sanctioned?.applied))
2676
3077
  .map((e) => ({
3078
+ e,
3079
+ // #567: the uncapped low end its tracker read above the income it holds, and a #444 move (reported only).
3080
+ low: enemy_deploy === undefined && !knownIncome?.some((k) => k.player === e.playerId) ? tracks?.find((t) => t.playerId === e.playerId)?.observedLow : undefined,
3081
+ shift: setup.statedShifts.find((x) => x.player === e.playerId),
3082
+ }))
3083
+ .filter(({ e, low, shift }) => e.playerId !== me.id && !allies.has(e.playerId) && inScope(e.playerId) && (e.card || e.sanctioned?.applied || low || shift))
3084
+ .map(({ e, low, shift }) => ({
2677
3085
  player: playerRef(e.playerId),
2678
- deploy: e.estimate,
3086
+ deploy: shift ? shift.now : e.estimate,
3087
+ ...(low ? { observedLow: low } : {}),
3088
+ ...(shift ? { statedScaled: { was: shift.was, by: shift.by.map((b) => b.id) } } : {}),
2679
3089
  ...(e.card ? { cardBonus: e.card.armies, cardDue: e.card.due, ...(e.card.basis ? { cardBonusBasis: e.card.basis } : {}) } : {}),
2680
3090
  ...(e.sanctioned?.applied && e.sanctioned.after !== undefined
2681
3091
  ? { sanctionApplied: { player: e.playerId, percentage: sanctionPercentage(e.sanctioned.percentages), before: e.sanctioned.before, after: e.sanctioned.after } }
@@ -2961,8 +3371,12 @@ export function registerTurnTools(server, ctx, opts = {}) {
2961
3371
  ? { modAlliances: { read: truces.mod.status === 'read', allies: truces.mod.status === 'read' ? truces.mod.allies.map(playerRef) : null, note: MOD_ALLIANCES_NOTE } }
2962
3372
  : {}),
2963
3373
  warnings,
2964
- rationale: plan.rationale,
3374
+ rationale: coordLines.length ? [...plan.rationale, ...coordLines] : plan.rationale,
2965
3375
  orders,
3376
+ // Owner request 2026-11-24: only when I hold an Airlift card (no field otherwise).
3377
+ ...(airlift ?? {}),
3378
+ ...(bomb ?? {}),
3379
+ ...(wallPlan ?? {}),
2966
3380
  // The border guess, only when there is one; why there is none, full view only.
2967
3381
  ...(guess
2968
3382
  ? {
@@ -3081,11 +3495,17 @@ export function registerTurnTools(server, ctx, opts = {}) {
3081
3495
  '`commander`), Gift (`target` yours, `player`), Diplomacy (`players`: two), Sanctions (`player`), Bomb (`target` ' +
3082
3496
  "next to yours, not yours or a teammate's) and Emergency Blockade (`target` yours, never your commander's), encoded " +
3083
3497
  'as the client does (the Airlift, Diplomacy and Gift verified live, Reconnaissance accepted live; the others not yet), each refused where war.app would refuse it (a commander is never ' +
3084
- 'gifted or airlifted to a teammate, no Spy or Sanctions on yourself or a teammate, no Diplomacy between ' +
3498
+ 'gifted or airlifted to a teammate, no Spy on yourself or a teammate, Sanctions on your own side only when the game\'s ' +
3499
+ 'percentage is negative (it then raises the target\'s income: never on an opponent; a positive or unreadable one never on ' +
3500
+ 'your side), no Diplomacy between ' +
3085
3501
  'teammates); discards any card (`{ kind: "discard", card }`); refuses ' +
3086
3502
  'when your hand is over the hold limit and the orders do not play or discard enough cards; in a team game warns ' +
3087
3503
  'when they play or discard a card your teammate has already entered (a card named by type is one nobody ' +
3088
- 'entered when there is one). The ' +
3504
+ 'entered when there is one). An Airlift leaves at least one army behind while One Army Must Stand Guard is on; ' +
3505
+ 'once the orders read as committed every Airlift sent is read back from war.app\'s copy of them (the ' +
3506
+ 'warapp_get_my_orders read) and reported as `airliftReadBack` — a missing or altered one makes the result an error ' +
3507
+ 'naming it, and nothing is resent; a Bomb, Blockade, Emergency Blockade or Sanctions play is read back the same way ' +
3508
+ '(`cardReadBack`: its card and target territory or player; missing or on another target is an error). The ' +
3089
3509
  'orders reach the game and cannot be withdrawn here; when the turn resolves, other players see the results. ' +
3090
3510
  'Validated against the live board first: deploys on and moves from your own territories, moves to ' +
3091
3511
  'adjacent ones, no more armies than a territory has, deploys totalling exactly your income (after any Sanctions on you, ' +
@@ -3723,6 +4143,8 @@ export function registerTurnTools(server, ctx, opts = {}) {
3723
4143
  'your `committed` true means the orders are in. Do not resend these orders blindly — a second commit for ' +
3724
4144
  'the same turn is not known to be safe, and once the turn has resolved they would commit to the next one.';
3725
4145
  const unconfirmed = (warning) => ({ status: 'unknown', outcome: 'unconfirmed', ...base, warning });
4146
+ /** The game as read back once my orders show committed (the Airlift read-back reads its players). */
4147
+ let committedGame;
3726
4148
  const result = await sendAndVerify({
3727
4149
  send: async () => {
3728
4150
  // The reply's bool is war.app's "vacation ended" flag — never a success signal.
@@ -3768,6 +4190,7 @@ export function registerTurnTools(server, ctx, opts = {}) {
3768
4190
  };
3769
4191
  }
3770
4192
  if (after.players.find((p) => p.id === st.feedPlayerId)?.hasCommittedOrders) {
4193
+ committedGame = after;
3771
4194
  return {
3772
4195
  status: 'committed',
3773
4196
  outcome: 'confirmed',
@@ -3784,9 +4207,70 @@ export function registerTurnTools(server, ctx, opts = {}) {
3784
4207
  const withChat = st.chatReviewed ? { ...result, chatReviewed: st.chatReviewed } : result;
3785
4208
  const withRisk = st.commanderRisk ? { ...withChat, commanderRiskAccepted: st.commanderRisk } : withChat;
3786
4209
  const withExceptions = st.exceptions?.length ? { ...withRisk, exceptionsRecorded: await recordApproved(st, result.outcome === 'confirmed') } : withRisk;
3787
- if (!st.breaks?.length)
3788
- return withExceptions;
3789
- return { ...withExceptions, agreementsBroken: await recordBreaks(st, result.outcome === 'confirmed') };
4210
+ const final = st.breaks?.length ? { ...withExceptions, agreementsBroken: await recordBreaks(st, result.outcome === 'confirmed') } : withExceptions;
4211
+ // Owner request 2026-11-24: the Airlifts sent are read back from war.app's copy of my committed orders
4212
+ // (the warapp_get_my_orders read) and any missing or altered one fails loudly. Nothing is resent. The
4213
+ // player-targeted plays (Sanctions, owner request 2026-11-24) are read back the same way (`cardReadBack`).
4214
+ const lifts = sentAirlifts(st.orders);
4215
+ const aimed = sentTargeted(st.orders, READ_BACK_TARGETED);
4216
+ const aiming = st.orders.some((o) => o.kind === 'card' && READ_BACK_PLAYER_CARDS.has(o.card));
4217
+ if (!lifts.length && !aimed.length && !aiming)
4218
+ return final;
4219
+ if (!committedGame) {
4220
+ const note = result.status === 'resolved'
4221
+ ? "The turn resolved at once, so war.app no longer holds the orders to read back: check the card plays in the turn's result on the board."
4222
+ : 'The orders do not read as committed, so the card plays were not read back.';
4223
+ return {
4224
+ ...final,
4225
+ ...(lifts.length ? { airliftReadBack: { status: 'not-read', note } } : {}),
4226
+ ...(aimed.length || aiming ? { cardReadBack: { status: 'not-read', note } } : {}),
4227
+ };
4228
+ }
4229
+ const byInGame = playersByInGameId(committedGame.players);
4230
+ const aimedPlayers = sentPlayerCards(st.orders, (n) => byInGame.get(n)?.id);
4231
+ let read = null;
4232
+ let failure;
4233
+ try {
4234
+ read = committedOrdersOf((await readLatestBoard(ctx, st.gameId)).info, committedGame.players);
4235
+ }
4236
+ catch (e) {
4237
+ failure = failureText(e);
4238
+ }
4239
+ const lifted = checkAirlifts(lifts, read);
4240
+ const hit = checkTargeted(aimed, read);
4241
+ const named = checkPlayerCards(aimedPlayers, read);
4242
+ if (lifted.status === 'mismatch' || hit.status === 'mismatch' || named.status === 'mismatch') {
4243
+ const parts = lifted.status === 'mismatch' ? [mismatchMessage(lifted, st.turnNumber, st.gameId)] : [];
4244
+ const extra = [...targetedMismatchParts(hit), ...playerCardMismatchParts(named)];
4245
+ // #556: what the commit recorded (a truce break, exceptions, …) is said in the error, never dropped.
4246
+ const recorded = recordedWithCommit(final);
4247
+ const message = (parts.length
4248
+ ? `${parts[0]}${extra.length ? ` Also: ${extra.join('; ')}.` : ''}`
4249
+ : `Your orders for game ${st.gameId}, turn ${st.turnNumber} are committed, but war.app's copy of them does not match what was sent: ${extra.join('; ')}. Nothing was resent.`) +
4250
+ (recorded ? ` ${recorded}` : '');
4251
+ throw new McpToolError(message, {
4252
+ hint: 'Read the committed orders with warapp_get_my_orders. To correct them, withdraw with warapp_uncommit_turn and ' +
4253
+ 'submit again (both confirm-gated); do not resend blindly.',
4254
+ });
4255
+ }
4256
+ const unreadNote = (what) => ({ note: `Your committed orders could not be read back${failure ? ` (${failure})` : ''}: check the ${what} with warapp_get_my_orders.` });
4257
+ // Territory-targeted (Bomb) and player-targeted (Sanctions) plays share one `cardReadBack`: one kind alone keeps its
4258
+ // own shape; both together merge their lines (each line names its `target` or its `player`).
4259
+ const cards = aimed.length && (aimedPlayers.length || aiming)
4260
+ ? {
4261
+ status: [hit, named].some((x) => x.status === 'unread') ? 'unread' : 'verified',
4262
+ sent: [...hit.sent, ...named.sent],
4263
+ missing: [...hit.missing, ...named.missing],
4264
+ altered: [...hit.altered, ...named.altered],
4265
+ }
4266
+ : aimed.length
4267
+ ? hit
4268
+ : named;
4269
+ return {
4270
+ ...final,
4271
+ ...(lifts.length ? { airliftReadBack: { ...lifted, ...(lifted.status === 'unread' ? unreadNote('Airlifts') : {}) } } : {}),
4272
+ ...(aimed.length || aimedPlayers.length || aiming ? { cardReadBack: { ...cards, ...(cards.status === 'unread' ? unreadNote('card plays') : {}) } } : {}),
4273
+ };
3790
4274
  },
3791
4275
  });
3792
4276
  }