@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.
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +9 -6
- package/dist/analysis/airlift-plan.js +288 -0
- package/dist/analysis/blockade-plan.js +178 -0
- package/dist/analysis/bomb-plan.js +72 -0
- package/dist/analysis/card-threats.js +10 -9
- package/dist/analysis/cards-in-effect.js +20 -0
- package/dist/analysis/combat.js +5 -0
- package/dist/analysis/coordination.js +47 -0
- package/dist/analysis/income-calibration.js +280 -0
- package/dist/analysis/intel.js +1 -1
- package/dist/analysis/lookahead.js +4 -0
- package/dist/analysis/opponents.js +52 -3
- package/dist/analysis/plan/deploy-estimates.js +1 -1
- package/dist/analysis/plan/estimates.js +40 -6
- package/dist/analysis/plan/relations.js +57 -8
- package/dist/analysis/plan/threats.js +1 -1
- package/dist/analysis/player-record.js +1 -0
- package/dist/analysis/relations.js +40 -0
- package/dist/analysis/stress.js +42 -2
- package/dist/analysis/turn-sim.js +62 -0
- package/dist/bundle.js +24486 -21811
- package/dist/card-state.js +157 -0
- package/dist/decision-log.js +44 -5
- package/dist/local-time.js +142 -0
- package/dist/relations-store.js +30 -5
- package/dist/tools/airlift-readback.js +87 -0
- package/dist/tools/alternative-orders.js +21 -0
- package/dist/tools/begin-turn.js +19 -5
- package/dist/tools/calibration-harness.js +102 -0
- package/dist/tools/calibration.js +110 -0
- package/dist/tools/card-advice.js +5 -4
- package/dist/tools/card-plays.js +32 -20
- package/dist/tools/card-state-view.js +26 -0
- package/dist/tools/card-support-advice.js +25 -8
- package/dist/tools/chat-inbox.js +1 -1
- package/dist/tools/chat.js +1 -1
- package/dist/tools/check-plan.js +113 -9
- package/dist/tools/common.js +14 -0
- package/dist/tools/decision-capture.js +14 -1
- package/dist/tools/game.js +11 -2
- package/dist/tools/index.js +13 -1
- package/dist/tools/notifications.js +1 -1
- package/dist/tools/opponents.js +2 -0
- package/dist/tools/player-card-readback.js +45 -0
- package/dist/tools/relations.js +146 -14
- package/dist/tools/sanctions-played.js +51 -0
- package/dist/tools/stress-opponents.js +8 -4
- package/dist/tools/turn-history.js +214 -0
- package/dist/tools/turn.js +504 -20
- package/dist/turn-orders.js +64 -0
- package/dist/version.js +1 -1
- package/manifest.json +17 -2
- package/mint.yaml +7 -0
- package/package.json +1 -1
- package/server.json +8 -2
- package/skills/warapp-mcp/SKILL.md +9 -1
package/dist/tools/check-plan.js
CHANGED
|
@@ -21,21 +21,25 @@ import { assumedWarning, awardView, loadAward, openingThreat } from './award.js'
|
|
|
21
21
|
import { readLedger } from '../relations-store.js';
|
|
22
22
|
import { resolveIntel } from '../analysis/intel.js';
|
|
23
23
|
import { allyAttackLine, attacksOnAllies, modAllianceWarnings } from './mod-alliances.js';
|
|
24
|
-
import { avoidPlayersArg, avoidTerritoriesArg, gameIdArg, graphOf, knownIncomeArg, namer, readAnnotations, respond, untrustedDescription, untrustedText, viewArg } from './common.js';
|
|
24
|
+
import { avoidPlayersArg, avoidTerritoriesArg, gameIdArg, graphOf, knownIncomeArg, namer, playerNamer, readAnnotations, respond, untrustedDescription, untrustedText, viewArg } from './common.js';
|
|
25
25
|
import { lookupMeta } from './hints.js';
|
|
26
26
|
import { HEADROOM_COMPACT, headroomView, readTripwires, safeHeadroom, teamsOf, tripwireWarnings, untrustedDeploy } from './survival.js';
|
|
27
27
|
import { loadLiveGame, standInLine, standInOf } from './live-context.js';
|
|
28
28
|
import { BRIDGE_NOTE, playerArg, resolveMe } from './live.js';
|
|
29
29
|
import { mapOf } from './map.js';
|
|
30
|
-
import { resolveTerritory } from './resolve.js';
|
|
30
|
+
import { resolvePlayer, resolveTerritory } from './resolve.js';
|
|
31
31
|
import { BELOW_PLAN_BASIS, boardHistory, bordersBelowPlan, currentTurn, truceRelations, friendsOf, guardOffWarnings, modsWarning, plannerSettings, requirePlayingSeat, requireTurnPhase, turnOrdersArg, } from './turn.js';
|
|
32
32
|
import { resolveTeamsFor } from './team-source.js';
|
|
33
33
|
import { stressOpponents } from './stress-opponents.js';
|
|
34
|
+
import { observedLowWarning } from '../analysis/opponents.js';
|
|
35
|
+
import { statedShiftWarning } from '../analysis/plan/estimates.js';
|
|
34
36
|
import { sanctionPercentage } from '../analysis/cards-in-effect.js';
|
|
37
|
+
import { CARD_SANCTIONS, sanctionsPlayed } from './sanctions-played.js';
|
|
35
38
|
import { COMMANDER_SIZING, commanderCheckOn, defaultFoggedCount, foggedAttackersArg, foggedCommanderOn, foggedCommanderText, myLargestStack } from './commander-check.js';
|
|
36
39
|
import { DEFAULT_FOGGED_ATTACKERS, foggedStack } from '../analysis/commander-fog.js';
|
|
37
40
|
import { captureCheck, checkPlanLog } from './decision-capture.js';
|
|
38
41
|
import { farSummary, opponentScope } from '../analysis/scale.js';
|
|
42
|
+
import { territoryCapOverruns } from '../analysis/plan/relations.js';
|
|
39
43
|
const VIEWS = ['compact', 'full'];
|
|
40
44
|
const MAX_ENEMY_DEPLOY = 10_000;
|
|
41
45
|
/** Replies listed beside the worst one on the compact view; the full view lists the stress test's own maximum. */
|
|
@@ -43,11 +47,19 @@ const COMPACT_OTHERS = 2;
|
|
|
43
47
|
/** The most territories or bonuses any one list names; the rest are a count. */
|
|
44
48
|
const LIST_MAX = 10;
|
|
45
49
|
const ORDER_PRIORITY = cardTypeByName('Order Priority');
|
|
50
|
+
const BOMB = cardTypeByName('Bomb');
|
|
51
|
+
const EMERGENCY_BLOCKADE = cardTypeByName('Emergency Blockade');
|
|
52
|
+
const BLOCKADE = cardTypeByName('Blockade');
|
|
53
|
+
/** A wall card's `MultiplyAmount` from the settings (`EmergencyBlockadeCard`, `BlockadeCard`), when the game sets one. */
|
|
54
|
+
function wallMultiplier(raw, key) {
|
|
55
|
+
const r = raw?.[key];
|
|
56
|
+
if (typeof r !== 'object' || r === null)
|
|
57
|
+
return undefined;
|
|
58
|
+
const m = Number(r.MultiplyAmount);
|
|
59
|
+
return Number.isFinite(m) && m > 0 ? m : undefined;
|
|
60
|
+
}
|
|
46
61
|
/** Card plays that change the board this test does not simulate, each with what the test does instead. */
|
|
47
|
-
const UNSIMULATED_CARDS = new Map([
|
|
48
|
-
[cardTypeByName('Bomb'), (on) => `The Bomb${on} is not simulated: the test fights at its armies before the Bomb halves them.`],
|
|
49
|
-
[cardTypeByName('Emergency Blockade'), (on) => `The Emergency Blockade${on} is not simulated: the test keeps it yours, armies unchanged.`],
|
|
50
|
-
]);
|
|
62
|
+
const UNSIMULATED_CARDS = new Map([]);
|
|
51
63
|
/** #274: the card plays the commander check reads (an Airlift simulated, the others named on its territory). */
|
|
52
64
|
const COMMANDER_CARD_KINDS = new Map([
|
|
53
65
|
[cardTypeByName('Airlift'), 'Airlift'],
|
|
@@ -62,7 +74,7 @@ export const CHECK_PLAN_NOT_COVERED = [
|
|
|
62
74
|
'a deploy split over several stacks',
|
|
63
75
|
'two opponents together other than on one of your territories, and two free-for-all opponents together at all unless you lead (see leader)',
|
|
64
76
|
'under Multi-Attack, any chain of attacks but the one most damaging per stack',
|
|
65
|
-
'cards, apart from your own Order Priority',
|
|
77
|
+
'cards, apart from your own Order Priority, Airlifts, Bombs, Emergency Blockades and Blockades',
|
|
66
78
|
];
|
|
67
79
|
export function registerCheckPlanTool(server, ctx) {
|
|
68
80
|
server.registerTool('warapp_check_plan', {
|
|
@@ -110,6 +122,9 @@ export function registerCheckPlanTool(server, ctx) {
|
|
|
110
122
|
'implied and your own income (`enemyDeploy` source `untrusted`), said in the first warning. Each `enemyDeploy` entry ' +
|
|
111
123
|
"shows the Reinforcement card the clock says it may hold apart as `cardBonus` (in `deploy` unless `assume_enemy_cards` is " +
|
|
112
124
|
'"none"; a progressive card\'s source in `cardBonusBasis`, as warapp_plan_turn has it) and, under Sanctions, `sanctionApplied` (its income before and after the cut). ' +
|
|
125
|
+
'A Sanctions card in the orders is projected onto next turn in `sanctionsPlayed` (`nextIncome`: yours from this turn\'s ' +
|
|
126
|
+
'income when the game\'s percentage is negative and you play it on yourself, an opponent\'s estimate when positive), and ' +
|
|
127
|
+
'a card on the wrong side for its sign is a warning (warapp_submit_turn refuses it). ' +
|
|
113
128
|
'`belowPlan` compares these orders with the default plan made now on the same board (warapp_plan_turn with no ' +
|
|
114
129
|
'options, the award of picks read as it reads it), or with its border guess when the deploys given are the ' +
|
|
115
130
|
"guess's (`belowPlanAgainst`: plan or guess): each border they leave below what that plan leaves standing there, " +
|
|
@@ -131,7 +146,12 @@ export function registerCheckPlanTool(server, ctx) {
|
|
|
131
146
|
player: playerArg,
|
|
132
147
|
orders: turnOrdersArg.describe('The orders to test, in the order you would submit them: deploys and moves by territory id or name (the ' +
|
|
133
148
|
'`orders` array warapp_plan_turn returns). An Order Priority card play makes your first order run before ' +
|
|
134
|
-
"everyone's;
|
|
149
|
+
"everyone's; an Airlift (`from`, `to`, `armies`) is carried out at its phase — after every deploy, before every " +
|
|
150
|
+
'move: its source loses the armies, its destination gains them, and they cannot move again that turn — so ' +
|
|
151
|
+
'every reply is tried against the board it leaves; other card plays and discards are ignored by the test ' +
|
|
152
|
+
'(a Bomb is carried out at its phase too — after every deploy, its target keeps half its armies, rounded down; an ' +
|
|
153
|
+
'Emergency Blockade before the moves and a Blockade after them turn their territory neutral at its armies × the ' +
|
|
154
|
+
"game's multiplier; a wall whose multiplier the settings do not give is named " +
|
|
135
155
|
'in `warnings` as not simulated; in a team game, a card your teammate has ' +
|
|
136
156
|
"already entered is warned of). A move's options (mode, percent, commander, " +
|
|
137
157
|
'attack_teammates) are carried out as war.app would.'),
|
|
@@ -215,7 +235,13 @@ export function registerCheckPlanTool(server, ctx) {
|
|
|
215
235
|
uses.push({ card, kind });
|
|
216
236
|
};
|
|
217
237
|
let orderPriority = false;
|
|
238
|
+
const sanctionsTargets = [];
|
|
218
239
|
const airlifts = [];
|
|
240
|
+
/** My Bombs' targets: carried out at their phase (30) by the stress test. */
|
|
241
|
+
const bombs = [];
|
|
242
|
+
/** My Emergency Blockades (phase 37) and Blockades (phase 60): carried out by the stress test with the game's multiplier. */
|
|
243
|
+
const abandons = [];
|
|
244
|
+
const blockades = [];
|
|
219
245
|
const cardTargets = [];
|
|
220
246
|
const ignored = [];
|
|
221
247
|
const unsimulatedCards = [];
|
|
@@ -263,6 +289,15 @@ export function registerCheckPlanTool(server, ctx) {
|
|
|
263
289
|
// By GUID it is looked up in my hand; by type name the name is enough (this is a what-if).
|
|
264
290
|
const guid = normalizeGuid(o.card.trim());
|
|
265
291
|
const type = guid !== undefined ? hand.find((c) => c.id === guid)?.type : cardTypeByName(o.card);
|
|
292
|
+
// Owner request 2026-11-24: a Sanctions play's income change is projected on next turn (below).
|
|
293
|
+
if (type === CARD_SANCTIONS && o.player !== undefined) {
|
|
294
|
+
try {
|
|
295
|
+
sanctionsTargets.push(resolvePlayer(game.players, o.player).id);
|
|
296
|
+
}
|
|
297
|
+
catch {
|
|
298
|
+
// A player not in the game: warapp_submit_turn refuses it; nothing is projected.
|
|
299
|
+
}
|
|
300
|
+
}
|
|
266
301
|
const unsimulated = type !== undefined ? UNSIMULATED_CARDS.get(type) : undefined;
|
|
267
302
|
if (unsimulated) {
|
|
268
303
|
let on = '';
|
|
@@ -294,8 +329,35 @@ export function registerCheckPlanTool(server, ctx) {
|
|
|
294
329
|
}
|
|
295
330
|
if (type !== undefined && type === ORDER_PRIORITY)
|
|
296
331
|
orderPriority = true;
|
|
332
|
+
else if (type === BOMB) {
|
|
333
|
+
try {
|
|
334
|
+
if (o.target !== undefined)
|
|
335
|
+
bombs.push(resolveTerritory(map, o.target).id);
|
|
336
|
+
}
|
|
337
|
+
catch {
|
|
338
|
+
// A target not on the map: warapp_submit_turn refuses it; the test goes without it.
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
else if (type === EMERGENCY_BLOCKADE || type === BLOCKADE) {
|
|
342
|
+
const key = type === BLOCKADE ? 'BlockadeCard' : 'EmergencyBlockadeCard';
|
|
343
|
+
const multiplier = wallMultiplier(game.settings?.raw, key);
|
|
344
|
+
const name = type === BLOCKADE ? 'Blockade' : 'Emergency Blockade';
|
|
345
|
+
try {
|
|
346
|
+
const target = o.target !== undefined ? resolveTerritory(map, o.target).id : undefined;
|
|
347
|
+
if (target !== undefined && multiplier !== undefined)
|
|
348
|
+
(type === BLOCKADE ? blockades : abandons).push({ target, multiplier });
|
|
349
|
+
else if (target !== undefined)
|
|
350
|
+
unsimulatedCards.push(`The ${name} on ${target} is not simulated: the game's settings give no multiplier for it.`);
|
|
351
|
+
}
|
|
352
|
+
catch {
|
|
353
|
+
// A target not on the map: warapp_submit_turn refuses it; the test goes without it.
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
else if (kindOf === 'Airlift') {
|
|
357
|
+
// Owner request 2026-11-24: the stress test carries the Airlift out at its phase (below).
|
|
358
|
+
}
|
|
297
359
|
else if (type === undefined || cardTypeName(type) !== 'Reinforcement')
|
|
298
|
-
ignored.push('a card play other than Order Priority or
|
|
360
|
+
ignored.push('a card play other than Order Priority, Reinforcement, Airlift, Bomb or a Blockade');
|
|
299
361
|
}
|
|
300
362
|
}
|
|
301
363
|
// The same per-opponent estimates warapp_plan_turn works from (stress-opponents.ts); an opponent's
|
|
@@ -374,6 +436,13 @@ export function registerCheckPlanTool(server, ctx) {
|
|
|
374
436
|
const sanction = so.commerce?.source === 'standing'
|
|
375
437
|
? { income, warnings: [], applied: false }
|
|
376
438
|
: sanctionMyIncome(income, effect, { localDeployments: settings.localDeployments === true });
|
|
439
|
+
const played = sanctionsPlayed(sanctionsTargets, {
|
|
440
|
+
settings: game.settings,
|
|
441
|
+
me: me.id,
|
|
442
|
+
friends,
|
|
443
|
+
myIncome: sanction.income,
|
|
444
|
+
estimateOf: (p) => so.estimates.find((e) => e.playerId === p)?.estimate,
|
|
445
|
+
});
|
|
377
446
|
const report = stressPlan({
|
|
378
447
|
graph,
|
|
379
448
|
board,
|
|
@@ -385,6 +454,10 @@ export function registerCheckPlanTool(server, ctx) {
|
|
|
385
454
|
...(teams.size ? { teams } : {}),
|
|
386
455
|
...(first_mover !== undefined ? { firstMover: first_mover } : {}),
|
|
387
456
|
orderPriority,
|
|
457
|
+
...(airlifts.length ? { airlifts } : {}),
|
|
458
|
+
...(bombs.length ? { bombs } : {}),
|
|
459
|
+
...(abandons.length ? { abandons } : {}),
|
|
460
|
+
...(blockades.length ? { blockades } : {}),
|
|
388
461
|
...(settings.localDeployments ? { localDeployments: true, baseIncome: gameBaseIncome(settings) } : {}),
|
|
389
462
|
...(settings.localDeployments && (settings.bonusArmyPer ?? 0) > 0 ? { perTerritoryIncome: true } : {}),
|
|
390
463
|
leader,
|
|
@@ -417,6 +490,8 @@ export function registerCheckPlanTool(server, ctx) {
|
|
|
417
490
|
await captureCheck(ctx, game.id, me.id, turn, checkPlanLog(report, { whatIf: enemy_deploy !== undefined || known_income !== undefined }));
|
|
418
491
|
const name = namer(map);
|
|
419
492
|
const playerName = new Map(game.players.map((p) => [p.id, p.name]));
|
|
493
|
+
/** #573: a player in a warning sentence, by name (delimited) and id, as warapp_track_opponents names it. */
|
|
494
|
+
const playerNamed = playerNamer(game.players);
|
|
420
495
|
const who = (id) => ({ id, name: playerName.get(id) ?? String(id) });
|
|
421
496
|
const bonusOf = (id) => {
|
|
422
497
|
const b = map.bonuses.find((x) => x.id === id);
|
|
@@ -635,10 +710,18 @@ export function registerCheckPlanTool(server, ctx) {
|
|
|
635
710
|
// A Diplomacy 2 ally's territory (owner at the start of the turn): the game skips the attack, its armies sit idle.
|
|
636
711
|
const allyHits = modRead ? attacksOnAllies(modRead, moves, ownerOf) : [];
|
|
637
712
|
const avoidedHits = [...new Set(moves.map((m) => m.to))].filter((to) => !mine.has(to) && (avoidT.has(to) || avoidP.has(ownerOf(to) ?? Number.NaN)));
|
|
713
|
+
// A territory cap I promised a truce partner, which these orders go over (armies moved off are taken to leave).
|
|
714
|
+
const capOver = territoryCapOverruns(binding, {
|
|
715
|
+
mine,
|
|
716
|
+
armiesOf: (t) => board.territories.find((x) => x.territoryId === t)?.armies ?? 0,
|
|
717
|
+
deploys,
|
|
718
|
+
moves,
|
|
719
|
+
});
|
|
638
720
|
const warnings = [
|
|
639
721
|
// The owner, 2026-11-17: while an older build stands in for a client this server cannot read, say so first.
|
|
640
722
|
...[standInLine(standInOf(ctx))].filter((w) => w !== undefined),
|
|
641
723
|
...intel.warnings,
|
|
724
|
+
...capOver.map((c) => `These orders leave ${c.armies} on ${name(c.territory).name} (#${c.territory}), above the cap of ${c.max} you agreed with player ${c.player}${c.agreement ? ` (agreement ${c.agreement})` : ''}: deploy or move less there, or record the cap lifted (caps_remove) once the partner agrees.`),
|
|
642
725
|
...(avoidedHits.length
|
|
643
726
|
? [`These orders attack ${avoidedHits.map((t) => name(t)).join(', ')}, which you asked to avoid (avoid_territories / avoid_players).`]
|
|
644
727
|
: []),
|
|
@@ -651,6 +734,14 @@ export function registerCheckPlanTool(server, ctx) {
|
|
|
651
734
|
...(modRead ? modAllianceWarnings(modRead) : []),
|
|
652
735
|
// #275 (b): an untrusted estimate is the first thing said (not under an explicit enemy_deploy).
|
|
653
736
|
...(enemy_deploy === undefined ? tripwireWarnings(trip.tripwires, (w) => untrustedOf.get(w.player) ?? untrustedDeploy(w, income), (p) => estimates.find((x) => x.playerId === p)?.estimate) : []),
|
|
737
|
+
// #567: a known income that moved another opponent's estimate through #444's scale, by how much.
|
|
738
|
+
...[statedShiftWarning(so.statedShifts, playerNamed)].filter((w) => w !== null),
|
|
739
|
+
// #567: an opponent tried at an income its tracker holds below what a turn surely read (not one given known_income).
|
|
740
|
+
...(enemy_deploy === undefined
|
|
741
|
+
? (tracks ?? [])
|
|
742
|
+
.filter((t) => t.observedLow && t.income !== null && !knownOf.has(t.playerId) && inView.has(t.playerId))
|
|
743
|
+
.map((t) => observedLowWarning(playerNamed(t.playerId), t.income, t.observedLow, t.incomeMethod))
|
|
744
|
+
: []),
|
|
654
745
|
...(award ? assumedWarning(award) : []),
|
|
655
746
|
// #270: the static seats whose territories the test read as neutrals.
|
|
656
747
|
...[...seatTerritories(award?.board ?? seen, seats)]
|
|
@@ -667,6 +758,7 @@ export function registerCheckPlanTool(server, ctx) {
|
|
|
667
758
|
? [`These orders use ${[...refused].join(', ')}: war.app would refuse them in this game, and warapp_submit_turn does; the test ran them anyway.`]
|
|
668
759
|
: []),
|
|
669
760
|
...sanction.warnings,
|
|
761
|
+
...played.warnings,
|
|
670
762
|
// #505: orders that delay the nearest bonus say by how many turns (advice only).
|
|
671
763
|
...[bonusDelayWarning(belowPlan?.bonusDelay)].filter((w) => w !== undefined),
|
|
672
764
|
...effect.unsure,
|
|
@@ -733,6 +825,8 @@ export function registerCheckPlanTool(server, ctx) {
|
|
|
733
825
|
orderPriority,
|
|
734
826
|
// #277: what I may deploy this turn, after any Sanctions on me (as warapp_plan_turn reports it).
|
|
735
827
|
income: sanction.income,
|
|
828
|
+
// Owner request 2026-11-24: the Sanctions these orders play, with the income they change next turn.
|
|
829
|
+
...(played.entries.length ? { sanctionsPlayed: played.entries } : {}),
|
|
736
830
|
deployed,
|
|
737
831
|
warnings,
|
|
738
832
|
// #386: the intel warapp_record_intel kept and what this check did with it (absent when none is kept).
|
|
@@ -752,6 +846,16 @@ export function registerCheckPlanTool(server, ctx) {
|
|
|
752
846
|
...(o.sanctioned?.applied && o.sanctioned.after !== undefined
|
|
753
847
|
? { sanctionApplied: { player: o.id, percentage: sanctionPercentage(o.sanctioned.percentages), before: o.sanctioned.before, after: o.sanctioned.after } }
|
|
754
848
|
: {}),
|
|
849
|
+
// #567: the uncapped low end its tracker read above the income it holds (reported only).
|
|
850
|
+
...(() => {
|
|
851
|
+
const t = tracks?.find((x) => x.playerId === o.id);
|
|
852
|
+
return t?.observedLow && enemy_deploy === undefined && !knownOf.has(o.id) ? { observedLow: t.observedLow } : {};
|
|
853
|
+
})(),
|
|
854
|
+
// #567: its estimate without the known incomes that scaled its fog prior (#444).
|
|
855
|
+
...(() => {
|
|
856
|
+
const sh = so.statedShifts.find((x) => x.player === o.id);
|
|
857
|
+
return sh ? { statedScaled: { was: sh.was, by: sh.by.map((b) => b.id) } } : {};
|
|
858
|
+
})(),
|
|
755
859
|
})),
|
|
756
860
|
// Whether the replies carry the card the clock adds (default "clock").
|
|
757
861
|
assumeEnemyCards: assumeCards,
|
package/dist/tools/common.js
CHANGED
|
@@ -15,6 +15,12 @@ export const knownIncomeArg = z
|
|
|
15
15
|
.array(z.object({
|
|
16
16
|
player: z.coerce.number().int().describe('The player\'s GameFeed id (as warapp_get_game lists it).'),
|
|
17
17
|
income: z.coerce.number().int().min(0).max(10_000).describe('The income it earns per turn, card armies aside.'),
|
|
18
|
+
source: z
|
|
19
|
+
.enum(['chat', 'board'])
|
|
20
|
+
.optional()
|
|
21
|
+
.describe('Where the figure came from (#567): "board" (the default) — your own what-if or board evidence — replaces only this ' +
|
|
22
|
+
"player's estimate; \"chat\" — the player stated it — also scales the fog prior of the opponents who stated none, once " +
|
|
23
|
+
'two or more players in view have stated one (#444). Incomes warapp_record_intel kept count as "chat".'),
|
|
18
24
|
}))
|
|
19
25
|
.max(50)
|
|
20
26
|
.optional()
|
|
@@ -121,6 +127,14 @@ export const UNTRUSTED_PREVIEW_NOTE = `Names and chat text in this preview (in $
|
|
|
121
127
|
* words, so delimited) and the account id the approval is bound to.
|
|
122
128
|
*/
|
|
123
129
|
export const shownAccount = (name, id) => `${name === undefined ? 'you' : untrustedText(name)} (${id})`;
|
|
130
|
+
/**
|
|
131
|
+
* A player as a warning sentence names it (#573): its name, delimited (their own words), and its GameFeed id;
|
|
132
|
+
* the bare id when the game does not list the player or names it not.
|
|
133
|
+
*/
|
|
134
|
+
export const playerNamer = (players) => (id) => {
|
|
135
|
+
const name = players.find((p) => p.id === id)?.name;
|
|
136
|
+
return name ? `${untrustedText(name)} (${id})` : String(id);
|
|
137
|
+
};
|
|
124
138
|
export const untrustedDescription = (description) => `${description} ${UNTRUSTED_DESCRIPTION_SUFFIX}`;
|
|
125
139
|
/** The `view` parameter over `views`, with a note naming what compact keeps. */
|
|
126
140
|
export const viewArg = (views, note) => viewParam(views, { note });
|
|
@@ -23,7 +23,8 @@ import { parseFeedTime } from '../normalize.js';
|
|
|
23
23
|
import { bonusTerritories } from '../analysis/bonuses.js';
|
|
24
24
|
import { policyChecks } from '../open-games.js';
|
|
25
25
|
import { nameFreeSettings } from '../replay.js';
|
|
26
|
-
import {
|
|
26
|
+
import { readSeenTurn } from '../turn-orders.js';
|
|
27
|
+
import { recordPicksAdvice, recordPicksAward, recordPicksSent, decisionLogMode, decisionLogOwner, decisionLogPath, decisionOutcome, recordGameEvent, recordJoin, recordOpponentRead, recordSeats, fillOutcome, recordChat, recordCheck, recordDecision, recordObservations, recordSeenTurn, recordSubmission, } from '../decision-log.js';
|
|
27
28
|
const modeOf = (ctx) => (ctx.decisionLog ? { mode: ctx.decisionLog } : {});
|
|
28
29
|
/** Every bonus of the map with its member territories (superbonuses flattened). */
|
|
29
30
|
const bonusesOf = (graph) => new Map([...graph.bonusById.keys()].map((id) => [id, bonusTerritories(graph, id)]));
|
|
@@ -76,6 +77,18 @@ export async function captureChat(ctx, gameId, me, turn, chat, opts = {}) {
|
|
|
76
77
|
return;
|
|
77
78
|
await recordChat(ctx.dataDir, gameId, me, turn, chat, { ...modeOf(ctx), ...opts });
|
|
78
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* #570: keep the resolved turn's visible orders (every player's, from the LatestGameInfo's GameTurn) on that
|
|
82
|
+
* turn's entry — only when the GameTurn is the turn just before `turn`, the one being played. Never throws.
|
|
83
|
+
*/
|
|
84
|
+
export async function captureSeenTurn(ctx, game, me, info, turn) {
|
|
85
|
+
if (!ctx.dataDir || turn === null)
|
|
86
|
+
return false;
|
|
87
|
+
const seen = readSeenTurn(info, game.players);
|
|
88
|
+
if (!seen || seen.turn !== turn - 1)
|
|
89
|
+
return false;
|
|
90
|
+
return recordSeenTurn(ctx.dataDir, game.id, me, seen, modeOf(ctx));
|
|
91
|
+
}
|
|
79
92
|
/** Log warapp_check_plan's summary of the turn (the latest run wins). Never throws. */
|
|
80
93
|
export async function captureCheck(ctx, gameId, me, turn, summary) {
|
|
81
94
|
if (!ctx.dataDir)
|
package/dist/tools/game.js
CHANGED
|
@@ -70,7 +70,9 @@ function compact(game) {
|
|
|
70
70
|
* (`endOfGame`, #312, src/tools/end-of-game.ts): the account is the board cache's, else `identity` (the
|
|
71
71
|
* signed-in account).
|
|
72
72
|
*/
|
|
73
|
-
export function registerGameTool(server, client, dir, env, identity
|
|
73
|
+
export function registerGameTool(server, client, dir, env, identity,
|
|
74
|
+
/** My card state from the live board (src/tools/card-state-view.ts); absent: not read. */
|
|
75
|
+
cards) {
|
|
74
76
|
server.registerTool('warapp_get_game', {
|
|
75
77
|
title: 'Get a war.app (Warzone) game',
|
|
76
78
|
description: untrustedDescription('Look up one war.app (Warzone) multiplayer game by id: its state (lobby, distributing, playing, finished), ' +
|
|
@@ -96,7 +98,12 @@ export function registerGameTool(server, client, dir, env, identity) {
|
|
|
96
98
|
'(`endOfGame.processed`); a failed read is recorded and not retried, except by a call with ' +
|
|
97
99
|
'`include_history`, which re-runs it from that read and adds the stats to a game processed before them ' +
|
|
98
100
|
'(`backfilled`). To take a finished game off the app\'s My Games use warapp_close_finished_game. ' +
|
|
99
|
-
'
|
|
101
|
+
'While the game is played or picked with a card in play, `cards` is my hand from the live board (one more ' +
|
|
102
|
+
'request): `held` (each card type with `count`), `total`, `maxCardsHold`, and `pieces` (per card in play, the ' +
|
|
103
|
+
'pieces toward the next one and `of` how many make one; read by shape, UNVERIFIED live; `null` when unread), and ' +
|
|
104
|
+
'`settings` (each card in play with a `duration`, and Sanctions\' `percentage` — negative raises the target\'s income — ' +
|
|
105
|
+
'with its `effect` and `targets`: opponents, or your side when negative) — a ' +
|
|
106
|
+
'failed read is `cardsUnread`, never an error. For the map\'s bonuses and chokepoints use warapp_get_map. Read-only.'),
|
|
100
107
|
_meta: lookupMeta(['warzone game', 'war.app game', 'whose turn is it', 'game status']),
|
|
101
108
|
annotations: readAnnotations('Get a war.app game'),
|
|
102
109
|
inputSchema: z.object({
|
|
@@ -137,7 +144,9 @@ export function registerGameTool(server, client, dir, env, identity) {
|
|
|
137
144
|
end = await endOfGame({ client, dataDir: dir(), env: env ?? process.env }, game.id, me, game, include_history ? { history: game, retry: true } : {});
|
|
138
145
|
}
|
|
139
146
|
}
|
|
147
|
+
const cardRead = cards ? await cards(game) : {};
|
|
140
148
|
const folded = {
|
|
149
|
+
...cardRead,
|
|
141
150
|
...(fold && fold.status !== 'off' ? { profileFold: fold } : {}),
|
|
142
151
|
...(lost ? { howLost: lost } : {}),
|
|
143
152
|
...(end && end.status !== 'off' ? { endOfGame: end } : {}),
|
package/dist/tools/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { readCardState } from './card-state-view.js';
|
|
1
2
|
import { defaultMapCache, WarappClient } from '../client.js';
|
|
2
3
|
import { captureSeats } from './decision-capture.js';
|
|
3
4
|
import { dataDir } from '../config.js';
|
|
@@ -40,6 +41,8 @@ import { registerLeaveGameTool } from './leave-game.js';
|
|
|
40
41
|
import { registerCloseFinishedGameTool } from './close-finished-game.js';
|
|
41
42
|
import { registerWhereTool } from './where.js';
|
|
42
43
|
import { registerStateTools } from './state.js';
|
|
44
|
+
import { registerCalibrationTool } from './calibration.js';
|
|
45
|
+
import { registerTurnHistoryTool } from './turn-history.js';
|
|
43
46
|
import { blobStoreFromEnv } from '@chrischall/mcp-utils/export';
|
|
44
47
|
import { registerProfileOpponentsTool } from './profile-opponents.js';
|
|
45
48
|
import { pushListenerFor } from '../push/listener.js';
|
|
@@ -49,8 +52,13 @@ import { createDirectFirstBridge } from '../direct/transport.js';
|
|
|
49
52
|
import { isHosted } from '../hosted.js';
|
|
50
53
|
import { registerSignInTool } from './sign-in.js';
|
|
51
54
|
import { createWarappBridge } from '../transport-bridge.js';
|
|
55
|
+
import { readTimezone, withLocalTimes } from '../local-time.js';
|
|
52
56
|
/** Every tool this server serves. index.ts and the tests share this list. */
|
|
53
57
|
export function registerAllTools(server, deps = {}) {
|
|
58
|
+
// WARAPP_TIMEZONE: every tool's timestamps gain a local-time sibling, added at the output layer (src/local-time.ts).
|
|
59
|
+
withLocalTimes(server, readTimezone(deps.env ?? process.env), () => registerEveryTool(server, deps));
|
|
60
|
+
}
|
|
61
|
+
function registerEveryTool(server, deps) {
|
|
54
62
|
// One client for the game tools, so they share the map cache. Config is
|
|
55
63
|
// deferred: the client reads credentials per call, never at construction.
|
|
56
64
|
// The map cache is kept on disk too (`<dataDir>/maps/`, src/map-store.ts),
|
|
@@ -88,7 +96,7 @@ export function registerAllTools(server, deps = {}) {
|
|
|
88
96
|
client.observeGames((game) => captureSeats(live, game));
|
|
89
97
|
registerHealthcheckTool(server, fetchproxy, bridge, { ...deps, standIn: () => live.decoderReport()?.standIn });
|
|
90
98
|
// The signed-in account names a finished game's player for its end-of-game pass when no board was cached (#312).
|
|
91
|
-
registerGameTool(server, client, () => dataDir(deps.env), deps.env, () => live.myInviteToken());
|
|
99
|
+
registerGameTool(server, client, () => dataDir(deps.env), deps.env, () => live.myInviteToken(), (game) => readCardState(live, game));
|
|
92
100
|
registerMapTool(server, client, live);
|
|
93
101
|
// Opt-in (WARAPP_STATS=1), never hosted: the tool refuses before any request
|
|
94
102
|
// when off. One collector per registration, so its 1 s throttle spans calls.
|
|
@@ -185,6 +193,10 @@ export function registerAllTools(server, deps = {}) {
|
|
|
185
193
|
...(deps.env ? { env: deps.env } : {}),
|
|
186
194
|
store: deps.blobStore === undefined ? blobStoreFromEnv(deps.env ?? process.env) : deps.blobStore,
|
|
187
195
|
});
|
|
196
|
+
// #569: the income estimates scored against finished games' truth — this server's state only, read-only.
|
|
197
|
+
registerCalibrationTool(server, () => dataDir(deps.env));
|
|
198
|
+
// #570: a game turn by turn as I saw it, beside the plan and the orders sent (the decision log), read-only.
|
|
199
|
+
registerTurnHistoryTool(server, live);
|
|
188
200
|
// Hosted only: the war.app sign-in mcp-host's authFlow captures the AuthToken from (#333 part B).
|
|
189
201
|
// Locally warapp_link_session stays the way to the direct transport.
|
|
190
202
|
if (hosted)
|
|
@@ -159,7 +159,7 @@ export function registerNotificationTools(server, ctx, opts = {}) {
|
|
|
159
159
|
description: untrustedDescription("Your war.app (Warzone) in-app notifications (the client's notifications screen, war.app's " +
|
|
160
160
|
'GetInAppNotifications), 30 per page, by id only: each with `id` (what warapp_dismiss_notification takes), ' +
|
|
161
161
|
'`kind` (`game-ended` when the title is war.app\'s "Game … has ended." line, else `other`), `gameId` (the ' +
|
|
162
|
-
'game its link names, or null), `time` and `unread`. The title and body are never shown (they carry other ' +
|
|
162
|
+
'game its link names, or null), `time` (plus `localTime` when WARAPP_TIMEZONE is set) and `unread`. The title and body are never shown (they carry other ' +
|
|
163
163
|
"players' names). " +
|
|
164
164
|
'`total` is how many notifications war.app holds; pass `next` back as `start` for the next page; ' +
|
|
165
165
|
'`unread_only` keeps the unread ones of the page. A game-ended notification runs the end-of-game pass on ' +
|
package/dist/tools/opponents.js
CHANGED
|
@@ -144,6 +144,8 @@ export function registerOpponentsTool(server, ctx, deps = {}) {
|
|
|
144
144
|
usedByPlanner: t.income !== null && t.turns.length >= TRACKED_MIN_TURNS,
|
|
145
145
|
// #250: set by one turn far above the turns before it, with what the boards say of it.
|
|
146
146
|
...(t.incomeJump ? { jump: t.incomeJump } : {}),
|
|
147
|
+
// #567: a turn of the window surely read more than the income held (reported only).
|
|
148
|
+
...(t.observedLow ? { observedLow: t.observedLow } : {}),
|
|
147
149
|
},
|
|
148
150
|
unexplainedArmies: t.unexplained,
|
|
149
151
|
// #164: large stacks last seen on a territory hidden since (the planner counts each where it can reach).
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// Owner request 2026-11-24 (self-Sanctions): after warapp_submit_turn commits, the player-targeted card plays it sent
|
|
2
|
+
// (Sanctions) are read back from war.app's own copy of my committed orders (the warapp_get_my_orders read, as the
|
|
3
|
+
// Airlift read-back does: src/tools/airlift-readback.ts) and compared: the card instance and the player it names.
|
|
4
|
+
// A missing or retargeted one makes the tool throw. Pure.
|
|
5
|
+
import { normalizeGuid } from '../cards.js';
|
|
6
|
+
/** The player-targeted card plays read back after a commit. */
|
|
7
|
+
export const READ_BACK_PLAYER_CARDS = new Set(['Sanctions']);
|
|
8
|
+
/** The plays of these kinds among the orders sent, the player by GameFeed id (`feedOf` the in-game id; unknown: left out). */
|
|
9
|
+
export function sentPlayerCards(orders, feedOf, kinds = READ_BACK_PLAYER_CARDS) {
|
|
10
|
+
return orders.flatMap((o) => {
|
|
11
|
+
if (o.kind !== 'card' || !kinds.has(o.card) || o.player === undefined)
|
|
12
|
+
return [];
|
|
13
|
+
const player = feedOf(o.player);
|
|
14
|
+
return player === undefined ? [] : [{ card: normalizeGuid(o.cardId) ?? o.cardId, kind: o.card, player }];
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
/** Compare the plays sent with my orders read back (`null`: unknown): by card instance, else the same kind and player. */
|
|
18
|
+
export function checkPlayerCards(sent, read) {
|
|
19
|
+
if (!read)
|
|
20
|
+
return { status: 'unread', sent: [...sent], missing: [], altered: [] };
|
|
21
|
+
const back = read.orders.flatMap((o) => o.kind === 'card' && o.player !== undefined ? [{ card: normalizeGuid(o.card) ?? o.card, kind: o.cardType, player: o.player }] : []);
|
|
22
|
+
const used = new Set();
|
|
23
|
+
const missing = [];
|
|
24
|
+
const altered = [];
|
|
25
|
+
for (const s of sent) {
|
|
26
|
+
let i = back.findIndex((b, k) => !used.has(k) && b.card === s.card);
|
|
27
|
+
if (i < 0)
|
|
28
|
+
i = back.findIndex((b, k) => !used.has(k) && b.kind === s.kind && b.player === s.player);
|
|
29
|
+
if (i < 0) {
|
|
30
|
+
missing.push(s);
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
used.add(i);
|
|
34
|
+
if (back[i].player !== s.player)
|
|
35
|
+
altered.push({ sent: s, read: { card: back[i].card, player: back[i].player } });
|
|
36
|
+
}
|
|
37
|
+
return { status: missing.length || altered.length ? 'mismatch' : 'verified', sent: [...sent], missing, altered };
|
|
38
|
+
}
|
|
39
|
+
/** The error message's parts for a mismatch, by id. */
|
|
40
|
+
export function playerCardMismatchParts(r) {
|
|
41
|
+
return [
|
|
42
|
+
...r.missing.map((x) => `the ${x.kind} on player ${x.player} is missing`),
|
|
43
|
+
...r.altered.map((x) => `the ${x.sent.kind} on player ${x.sent.player} reads back on player ${x.read.player}`),
|
|
44
|
+
];
|
|
45
|
+
}
|