@chrischall/warapp-mcp 0.11.0 → 0.12.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 +3 -3
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +10 -8
- package/dist/analysis/cards-in-effect.js +10 -1
- package/dist/analysis/chat-mentions.js +17 -0
- package/dist/analysis/commander-fog.js +126 -0
- package/dist/analysis/end-game-stats.js +149 -0
- package/dist/analysis/local-deploy.js +3 -2
- package/dist/analysis/outlook.js +133 -55
- package/dist/analysis/picks.js +125 -0
- package/dist/analysis/plan/commander.js +3 -2
- package/dist/analysis/plan/deploy-estimates.js +11 -7
- package/dist/analysis/plan/estimates.js +63 -9
- package/dist/analysis/plan/relations.js +24 -14
- package/dist/analysis/plan/shared.js +21 -0
- package/dist/analysis/plan/threats.js +74 -5
- package/dist/analysis/player.js +23 -10
- package/dist/analysis/relations.js +29 -4
- package/dist/analysis/scale.js +71 -0
- package/dist/analysis/single-pick.js +356 -0
- package/dist/bundle.js +2559 -594
- package/dist/finished-store.js +30 -0
- package/dist/index.js +1 -1
- package/dist/known-mods.js +33 -0
- package/dist/map-stats.js +24 -2
- package/dist/mod-alliances.js +217 -0
- package/dist/mod-data.js +160 -0
- package/dist/my-games.js +53 -2
- package/dist/normalize.js +7 -0
- package/dist/outlook-log.js +13 -0
- package/dist/protocol/methods.js +14 -2
- package/dist/tools/card-advice.js +29 -9
- package/dist/tools/card-effects.js +3 -1
- package/dist/tools/card-support-advice.js +1 -1
- package/dist/tools/chat-inbox.js +61 -8
- package/dist/tools/check-plan.js +101 -10
- package/dist/tools/close-finished-game.js +110 -0
- package/dist/tools/commander-check.js +80 -1
- package/dist/tools/diplomacy.js +11 -2
- package/dist/tools/end-of-game.js +57 -3
- package/dist/tools/game.js +7 -3
- package/dist/tools/how-lost.js +68 -5
- package/dist/tools/index.js +21 -1
- package/dist/tools/map.js +50 -1
- package/dist/tools/mod-alliances.js +191 -0
- package/dist/tools/my-games.js +12 -1
- package/dist/tools/pace.js +44 -0
- package/dist/tools/picks.js +41 -1
- package/dist/tools/relations.js +16 -1
- package/dist/tools/session.js +20 -6
- package/dist/tools/stress-opponents.js +25 -2
- package/dist/tools/turn.js +257 -32
- package/dist/tools/write-kit.js +1 -0
- package/dist/version.js +1 -1
- package/manifest.json +10 -2
- package/mint.yaml +3 -4
- package/package.json +1 -1
- package/server.json +2 -2
- package/skills/warapp-mcp/SKILL.md +57 -9
package/dist/protocol/methods.js
CHANGED
|
@@ -31,6 +31,12 @@ export const Method = {
|
|
|
31
31
|
GetTerritoryPicks: 81,
|
|
32
32
|
UnCommit: 82,
|
|
33
33
|
GetTurns: 83,
|
|
34
|
+
/**
|
|
35
|
+
* #523: the end-of-game window's data, which the client asks for when it shows that window (`EndGameWindowVM`) and
|
|
36
|
+
* which sets my seat's SeenEndGameWindow — the flag the app's My Games (the Default list) drops a finished game on.
|
|
37
|
+
* Parameters as UnCommit's (auth, int32 game id), read from the bundle's writer; UNVERIFIED live.
|
|
38
|
+
*/
|
|
39
|
+
GetEndGameWindowData: 85,
|
|
34
40
|
Subscribe: 242,
|
|
35
41
|
GameUpdated: 245,
|
|
36
42
|
GetInAppNotifications: 323,
|
|
@@ -154,6 +160,10 @@ export function writeBeginFirstTurnParams(w, gameId) {
|
|
|
154
160
|
export function writeUnCommitParams(w, gameId) {
|
|
155
161
|
w.int32(gameId);
|
|
156
162
|
}
|
|
163
|
+
/** GetEndGameWindowData(auth, gameId) — the parameters after the auth block (#523; the bundle's writer, UNVERIFIED live). */
|
|
164
|
+
export function writeGetEndGameWindowDataParams(w, gameId) {
|
|
165
|
+
w.int32(gameId);
|
|
166
|
+
}
|
|
157
167
|
/** The page size the client always asks GetInAppNotifications for. */
|
|
158
168
|
export const NOTIFICATIONS_PAGE_SIZE = 30;
|
|
159
169
|
/**
|
|
@@ -457,9 +467,11 @@ export const TARGETED_CARD_PLAYS = new Set([
|
|
|
457
467
|
* and the result carries `cardPlayCheck`. Airlift left it once verified live 2026-11-16 (#296), Diplomacy
|
|
458
468
|
* once verified live 2026-11-18 (#369: played through warapp_submit_turn, read in force on later boards),
|
|
459
469
|
* Reconnaissance once war.app accepted it live 2026-11-20 (#443: a turn with the play committed, no error;
|
|
460
|
-
* withdrawn before it resolved, so the reveal itself is not yet seen)
|
|
470
|
+
* withdrawn before it resolved, so the reveal itself is not yet seen), and Gift once verified live 2026-11-23
|
|
471
|
+
* (#435: played through warapp_submit_turn to a teammate; after the turn resolved the territory was the
|
|
472
|
+
* teammate's and the card had left the team hand).
|
|
461
473
|
*/
|
|
462
|
-
const VERIFIED_CARD_PLAYS = new Set(['Airlift', 'Diplomacy', 'Reconnaissance']);
|
|
474
|
+
const VERIFIED_CARD_PLAYS = new Set(['Airlift', 'Diplomacy', 'Reconnaissance', 'Gift']);
|
|
463
475
|
export const UNVERIFIED_CARD_PLAYS = new Set([...TARGETED_CARD_PLAYS].filter((kind) => !VERIFIED_CARD_PLAYS.has(kind)));
|
|
464
476
|
function need(v, card, what) {
|
|
465
477
|
if (v === undefined)
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
// players), the team's hand, Order Delay's place, my Bomb and Emergency Blockade, the
|
|
3
3
|
// opponents' Bomb and Emergency Blockade when they can hold one, the cards in effect
|
|
4
4
|
// (Diplomacy, Sanctions), and (PLAN-TEAMS D2) where to play my Diplomacy, Sanctions, Airlift and
|
|
5
|
-
// Gift. Read-only; everything here is advice — of these only the advised Order Delay
|
|
6
|
-
//
|
|
5
|
+
// Gift. Read-only; everything here is advice — of these only the advised Order Delay, a completing Gift
|
|
6
|
+
// (#435, verified live) and a spy card whose play is verified live (#434) are added to the orders; my Bomb
|
|
7
|
+
// and Emergency Blockade and the other D2 cards carry an `order` to pass to warapp_submit_turn.
|
|
7
8
|
import { adviseOrderDelay, CARD_BLOCKADE, CARD_ORDER_DELAY, CARD_REINFORCEMENT, isMyCard, readActiveCards, readTurnReinforcementPlays } from '../cards.js';
|
|
8
9
|
import { blockadeOffer, bombAdvice, bombExposure, wallOffer, wallThreats } from '../analysis/card-threats.js';
|
|
9
10
|
import { bonusTerritories } from '../analysis/bonuses.js';
|
|
@@ -279,7 +280,7 @@ export function adviseCards(input) {
|
|
|
279
280
|
}
|
|
280
281
|
warnings.push('Active cards are read from the live board by an unverified decoder (#163): check them in the game.');
|
|
281
282
|
}
|
|
282
|
-
// PLAN-TEAMS D2: my Diplomacy, Sanctions, Airlift and Gift — advice only,
|
|
283
|
+
// PLAN-TEAMS D2: my Diplomacy, Sanctions, Airlift and Gift, each with its order — advice only, save a completing Gift (#435).
|
|
283
284
|
const atPeace = new Set((view.active ?? []).flatMap((a) => (a.card === 'Diplomacy' && a.players?.includes(me.id) ? a.players.filter((p) => p !== me.id) : [])));
|
|
284
285
|
// #424: the cards in force whose last turn this is (gone by the next): chained, not passed over.
|
|
285
286
|
const lastTurn = new Set((view.active ?? []).flatMap((a) => a.card === 'Diplomacy' && a.players?.includes(me.id) && turn !== null && a.untilTurn === turn + 1 ? a.players.filter((p) => p !== me.id) : []));
|
|
@@ -327,10 +328,22 @@ export function seenReinforcementPlays(settings, seen) {
|
|
|
327
328
|
const read = [...seen.keys()].sort((a, b) => a - b);
|
|
328
329
|
return { read, plays: read.flatMap((turn) => seen.get(turn).map((player) => ({ player, turn }))) };
|
|
329
330
|
}
|
|
331
|
+
/**
|
|
332
|
+
* A progressive Reinforcement card's formula from its settings: `Mode` 1 / `ProgressiveByNumberOfTerritories`
|
|
333
|
+
* (by territories) or 2 / `ProgressiveByTurnNumber` (by turn), with a usable `ProgressivePercentage`. The names
|
|
334
|
+
* are the mod API's `ReinforcementCardMode`; the numbers follow its order — both UNVERIFIED against GameFeed.
|
|
335
|
+
* `undefined` for a flat card (Mode 0 / Fixed, or none) or an unknown one.
|
|
336
|
+
*/
|
|
337
|
+
function progressiveCard(rec) {
|
|
338
|
+
const mode = rec.Mode === undefined ? undefined : String(rec.Mode).toLowerCase();
|
|
339
|
+
const by = mode === '1' || mode === 'progressivebynumberofterritories' ? 'territories' : mode === '2' || mode === 'progressivebyturnnumber' ? 'turns' : undefined;
|
|
340
|
+
const pct = Number(rec.ProgressivePercentage);
|
|
341
|
+
return by && Number.isFinite(pct) && pct > 0 ? { by, percentage: pct } : undefined;
|
|
342
|
+
}
|
|
330
343
|
/**
|
|
331
344
|
* #164: an opponent's Reinforcement card for the threat model: the first turn one can be in a hand,
|
|
332
|
-
* the armies it adds (a fixed card's `FixedArmies
|
|
333
|
-
*
|
|
345
|
+
* the armies it adds (a fixed card's `FixedArmies`; a progressive card's formula in `progressive`, each
|
|
346
|
+
* opponent valued by it, with the Reinforcement card in my hand as `armies`, 0 with none) and the capturing turns each further card takes. `undefined` when no Reinforcement card
|
|
334
347
|
* is in play, none ever comes, or what it adds is unknown.
|
|
335
348
|
*
|
|
336
349
|
* #427 (proposed, owner approval pending): the clock runs at the EXPECTED weighted rate — the card's
|
|
@@ -354,12 +367,19 @@ export function opponentReinforcement(settings, hand) {
|
|
|
354
367
|
if (firstTurns === null)
|
|
355
368
|
return undefined;
|
|
356
369
|
const raw = settings.raw.ReinforcementCard;
|
|
357
|
-
const
|
|
370
|
+
const rec = typeof raw === 'object' && raw !== null ? raw : {};
|
|
371
|
+
const fixed = Number(rec.FixedArmies);
|
|
358
372
|
const inHand = hand.find((c) => c.type === CARD_REINFORCEMENT && c.armies !== undefined && c.armies > 0)?.armies;
|
|
359
|
-
const
|
|
360
|
-
|
|
373
|
+
const progressive = progressiveCard(rec);
|
|
374
|
+
const armies = !progressive && Number.isFinite(fixed) && fixed > 0 ? Math.floor(fixed) : inHand;
|
|
375
|
+
if (!progressive && (armies === undefined || armies <= 0))
|
|
361
376
|
return undefined;
|
|
362
377
|
const second = turnsFor(2);
|
|
363
378
|
// Pieces arrive at the end of a turn, so the first card is playable the turn after its last piece.
|
|
364
|
-
return {
|
|
379
|
+
return {
|
|
380
|
+
firstTurn: firstTurns + 1,
|
|
381
|
+
armies: armies ?? 0,
|
|
382
|
+
turnsPerCard: second === null ? null : Math.max(1, second - firstTurns),
|
|
383
|
+
...(progressive ? { progressive } : {}),
|
|
384
|
+
};
|
|
365
385
|
}
|
|
@@ -28,7 +28,7 @@ export const CARDS_IN_EFFECT_UNVERIFIED = 'The cards in effect are read from the
|
|
|
28
28
|
*/
|
|
29
29
|
export function sanctionMyIncome(income, effect, opts) {
|
|
30
30
|
if (!effect.sanctionsOnMe.length)
|
|
31
|
-
return { income, applied: false, warnings: [] };
|
|
31
|
+
return { income, applied: false, unmodelled: false, warnings: [] };
|
|
32
32
|
const pcts = effect.sanctionsOnMe.map((s) => s.percentage);
|
|
33
33
|
const pctText = pcts.map((p) => `${Math.round(p * 100)}%`).join(' then ');
|
|
34
34
|
const until = Math.max(...effect.sanctionsOnMe.map((s) => s.untilTurn));
|
|
@@ -36,6 +36,7 @@ export function sanctionMyIncome(income, effect, opts) {
|
|
|
36
36
|
return {
|
|
37
37
|
income,
|
|
38
38
|
applied: false,
|
|
39
|
+
unmodelled: true,
|
|
39
40
|
warnings: [
|
|
40
41
|
`Sanctions are on you (${pctText}, until turn ${until}): under Local Deployment the plan does not know which pools the cut comes from, so it plans on ${income} — deploy what the game shows.`,
|
|
41
42
|
],
|
|
@@ -44,6 +45,7 @@ export function sanctionMyIncome(income, effect, opts) {
|
|
|
44
45
|
return {
|
|
45
46
|
income: cut,
|
|
46
47
|
applied: true,
|
|
48
|
+
unmodelled: false,
|
|
47
49
|
warnings: [`Sanctions are on you (${pctText}, until turn ${until}): the plan's income is ${cut}, not ${income} (the client's rule, rounded to the nearest).`],
|
|
48
50
|
};
|
|
49
51
|
}
|
|
@@ -169,7 +169,7 @@ export function supportAdvice(input) {
|
|
|
169
169
|
if (gifts.length) {
|
|
170
170
|
const g = giftAdvice(cb, input.plan.team?.sharedBonuses ?? [], gifts.length);
|
|
171
171
|
if (g) {
|
|
172
|
-
// #435: a completing gift goes into the orders
|
|
172
|
+
// #435: a completing gift goes into the orders, its play verified live 2026-11-23 (as #434's spy cards).
|
|
173
173
|
const live = !(input.unverifiedPlays ?? UNVERIFIED_CARD_PLAYS).has('Gift');
|
|
174
174
|
view.gift = {
|
|
175
175
|
player: g.player,
|
package/dist/tools/chat-inbox.js
CHANGED
|
@@ -9,6 +9,8 @@ import { gameIdArg, readAnnotations, respond, untrustedDescription, untrustedTex
|
|
|
9
9
|
import { mintMeta } from './hints.js';
|
|
10
10
|
import { BRIDGE_NOTE } from './live.js';
|
|
11
11
|
import { fetchMyGames } from './my-games.js';
|
|
12
|
+
import { mentionsOf } from '../analysis/chat-mentions.js';
|
|
13
|
+
import { readBoardHistory } from '../trend.js';
|
|
12
14
|
/**
|
|
13
15
|
* #322: a finished game whose chat flags read clear is still read when it is among this many newest finished games
|
|
14
16
|
* (by id) in the list. A message GameFeed alone holds (a surrender "gg" sent as the game ended) leaves war.app's unread
|
|
@@ -33,7 +35,8 @@ export function recentClearFinished(games) {
|
|
|
33
35
|
export const INBOX_TIME_BUDGET_MS = 40_000;
|
|
34
36
|
/** The clock the budget is read on; tests replace `now`. */
|
|
35
37
|
export const inboxClock = { now: () => performance.now() };
|
|
36
|
-
const ONLY = ['all', 'private', 'toMe'];
|
|
38
|
+
const ONLY = ['all', 'private', 'toMe', 'mentionsMe'];
|
|
39
|
+
const PUBLIC_CHAT = ['messages', 'summary'];
|
|
37
40
|
/** Games read per call, at most (each costs a GameFeed read and a GameRefresh). */
|
|
38
41
|
export const MAX_INBOX_GAMES = 10;
|
|
39
42
|
/** The most game ids a call may name. */
|
|
@@ -46,6 +49,21 @@ const errorText = (e) => {
|
|
|
46
49
|
const s = e instanceof Error ? e.message : String(e);
|
|
47
50
|
return s.length > ERROR_MAX ? `${s.slice(0, ERROR_MAX - 1)}…` : s;
|
|
48
51
|
};
|
|
52
|
+
/**
|
|
53
|
+
* What `mentionsMe` matches in one game: my name there and the territories I hold — from GameFeed's standing when it
|
|
54
|
+
* has one, else the newest board this server cached for the game (no extra request); names from the cached map.
|
|
55
|
+
*/
|
|
56
|
+
async function mentionTargets(ctx, game, me) {
|
|
57
|
+
const mine = me ? playersByInGameId(game.players).get(me.inGameId) : undefined;
|
|
58
|
+
if (!mine)
|
|
59
|
+
return { names: [], territories: [] };
|
|
60
|
+
let board = game.standing;
|
|
61
|
+
if (!board && ctx.dataDir)
|
|
62
|
+
board = (await readBoardHistory(ctx.dataDir, game.id, mine.id)).at(-1)?.board;
|
|
63
|
+
const held = new Set((board?.territories ?? []).filter((t) => t.owner.kind === 'player' && t.owner.playerId === mine.id).map((t) => t.territoryId));
|
|
64
|
+
const names = new Map((game.map?.territories ?? []).map((t) => [t.id, t.name]));
|
|
65
|
+
return { names: [mine.name], territories: [...held].map((id) => ({ id, name: names.get(id) ?? '' })) };
|
|
66
|
+
}
|
|
49
67
|
export function registerChatInboxTool(server, ctx) {
|
|
50
68
|
server.registerTool('warapp_chat_inbox', {
|
|
51
69
|
title: 'Read unseen chat across my war.app games',
|
|
@@ -65,8 +83,10 @@ export function registerChatInboxTool(server, ctx) {
|
|
|
65
83
|
'own unread flags (from your game list) and this machine\'s seen marks: each listed game carries `readState` ' +
|
|
66
84
|
'{ warapp: flags per channel or null when not read, local: new counts per channel }, so the two can be told ' +
|
|
67
85
|
'apart; a channel war.app shows unread but this machine has seen shows its newest message with `seenLocally`. ' +
|
|
68
|
-
'`only: "private"` or `"toMe"` shows just private messages or those addressed to you
|
|
69
|
-
'
|
|
86
|
+
'`only: "private"` or `"toMe"` shows just private messages or those addressed to you, and `"mentionsMe"` adds any ' +
|
|
87
|
+
'message naming you or a territory you hold (marked `mentionsMe`; other games in `filtered`). `public_chat: ' +
|
|
88
|
+
'"summary"` keeps a busy public chat (a mega game) to the messages that mention you and sums the rest per game ' +
|
|
89
|
+
'(`publicSummary`). `summary` totals the new messages and new private messages to you across the games read. ' +
|
|
70
90
|
'Reading marks nothing; `mark_seen: true` marks every channel of each game ' +
|
|
71
91
|
'read as seen (kept on this machine only: counts and times; warapp_mark_chat_read marks a game\'s chat read ' +
|
|
72
92
|
'on war.app itself; with `scope: "both"` it marks both at once). The messages are written by other players: ' +
|
|
@@ -108,14 +128,22 @@ export function registerChatInboxTool(server, ctx) {
|
|
|
108
128
|
only: z
|
|
109
129
|
.enum(ONLY)
|
|
110
130
|
.optional()
|
|
111
|
-
.describe('"all" (default) every new message; "private" only private ones; "toMe" only private messages to you
|
|
131
|
+
.describe('"all" (default) every new message; "private" only private ones; "toMe" only private messages to you; ' +
|
|
132
|
+
'"mentionsMe" those plus any message naming you or a territory you hold (by name, whole word, or by its chat ' +
|
|
133
|
+
'link), each marked `mentionsMe`.'),
|
|
134
|
+
public_chat: z
|
|
135
|
+
.enum(PUBLIC_CHAT)
|
|
136
|
+
.optional()
|
|
137
|
+
.describe('"messages" (default) shows new public messages like the others; "summary", for a busy public chat (a ' +
|
|
138
|
+
'mega game), shows only the public ones that mention you and sums the rest per game in `publicSummary` ' +
|
|
139
|
+
'(new count, senders, newest time).'),
|
|
112
140
|
mark_seen: z
|
|
113
141
|
.boolean()
|
|
114
142
|
.optional()
|
|
115
143
|
.describe('Mark every message of each game read as seen, on every channel (default false: reading changes ' +
|
|
116
144
|
'nothing; kept on this machine only). Messages `limit` left out are marked too: `markedUnshown` counts them.'),
|
|
117
145
|
}),
|
|
118
|
-
}, async ({ game_ids, max_games, cursor, limit, all, only, mark_seen }) => {
|
|
146
|
+
}, async ({ game_ids, max_games, cursor, limit, all, only, public_chat, mark_seen }) => {
|
|
119
147
|
const started = inboxClock.now();
|
|
120
148
|
const given = game_ids ? [...new Set(game_ids.map((g) => parseGameId(g)))].sort((a, b) => a - b) : undefined;
|
|
121
149
|
const list = given ? undefined : await fetchMyGames(ctx);
|
|
@@ -191,16 +219,39 @@ export function registerChatInboxTool(server, ctx) {
|
|
|
191
219
|
sources.add(read.source);
|
|
192
220
|
// #415: each new message another player sent, labelled and advised on (this machine's logs only).
|
|
193
221
|
const reading = chatReader(read.lines, game, me, await chatAdviceContext(ctx, game, me));
|
|
222
|
+
const toMeAt = (l) => l.channel === 'private' && me !== undefined && l.to === me.inGameId;
|
|
223
|
+
// Mentions of me (my name, a territory I hold), read only when asked for: no other read is costlier.
|
|
224
|
+
const wantMentions = only === 'mentionsMe' || public_chat === 'summary';
|
|
225
|
+
const targets = wantMentions ? await mentionTargets(ctx, game, me) : undefined;
|
|
226
|
+
const mentioned = (i) => {
|
|
227
|
+
const l = read.lines[i];
|
|
228
|
+
return targets !== undefined && !isMine(l) && mentionsOf(l.text, targets) !== undefined;
|
|
229
|
+
};
|
|
194
230
|
const keep = (i) => {
|
|
195
231
|
const l = read.lines[i];
|
|
232
|
+
if (public_chat === 'summary' && l.channel === 'public' && !mentioned(i))
|
|
233
|
+
return false;
|
|
196
234
|
if (only === 'private')
|
|
197
235
|
return l.channel === 'private';
|
|
198
236
|
if (only === 'toMe')
|
|
199
|
-
return l
|
|
237
|
+
return toMeAt(l);
|
|
238
|
+
if (only === 'mentionsMe')
|
|
239
|
+
return toMeAt(l) || mentioned(i);
|
|
200
240
|
return true;
|
|
201
241
|
};
|
|
202
|
-
const
|
|
203
|
-
|
|
242
|
+
const candidates = [...new Set([...freshAt.slice(-n), ...warappOnlyAt])].sort((a, b) => a - b);
|
|
243
|
+
const shownAt = candidates.filter(keep);
|
|
244
|
+
// The public summary: every new public message of others, whether shown (a mention) or summed.
|
|
245
|
+
const freshPublic = public_chat === 'summary' ? freshAt.filter((i) => read.lines[i].channel === 'public' && !isMine(read.lines[i])) : [];
|
|
246
|
+
const publicSummary = freshPublic.length
|
|
247
|
+
? {
|
|
248
|
+
newMessages: freshPublic.length,
|
|
249
|
+
mentionsShown: freshPublic.filter((i) => shownAt.includes(i)).length,
|
|
250
|
+
senders: new Set(freshPublic.map((i) => read.lines[i].sender ?? read.lines[i].senderName ?? null)).size,
|
|
251
|
+
newestTime: read.lines[freshPublic.at(-1)].time ?? null,
|
|
252
|
+
}
|
|
253
|
+
: undefined;
|
|
254
|
+
if (((only && only !== 'all') || public_chat === 'summary') && !shownAt.length && !publicSummary) {
|
|
204
255
|
filtered.push(id);
|
|
205
256
|
continue;
|
|
206
257
|
}
|
|
@@ -209,6 +260,7 @@ export function registerChatInboxTool(server, ctx) {
|
|
|
209
260
|
...shown(read.lines[i], fresh[i], game.players, byInGame, me, game.map),
|
|
210
261
|
...readingFields(reading(i, fresh[i])),
|
|
211
262
|
...(fresh[i] ? {} : { seenLocally: true }),
|
|
263
|
+
...(wantMentions && mentioned(i) ? { mentionsMe: true } : {}),
|
|
212
264
|
}));
|
|
213
265
|
if (messages.some((m) => 'intent' in m))
|
|
214
266
|
advised = true;
|
|
@@ -230,6 +282,7 @@ export function registerChatInboxTool(server, ctx) {
|
|
|
230
282
|
local: unread,
|
|
231
283
|
},
|
|
232
284
|
messages,
|
|
285
|
+
...(publicSummary ? { publicSummary } : {}),
|
|
233
286
|
...(mark_seen ? { markedSeen: marked ?? [] } : {}),
|
|
234
287
|
...(marked && fresh_.length > messages.filter((m) => m.new).length
|
|
235
288
|
? { markedUnshown: fresh_.length - messages.filter((m) => m.new).length }
|
package/dist/tools/check-plan.js
CHANGED
|
@@ -20,6 +20,7 @@ import { withTeammateOrders } from '../team-orders.js';
|
|
|
20
20
|
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
|
+
import { allyAttackLine, attacksOnAllies, modAllianceWarnings } from './mod-alliances.js';
|
|
23
24
|
import { avoidPlayersArg, avoidTerritoriesArg, gameIdArg, graphOf, knownIncomeArg, namer, readAnnotations, respond, untrustedDescription, untrustedText, viewArg } from './common.js';
|
|
24
25
|
import { lookupMeta } from './hints.js';
|
|
25
26
|
import { HEADROOM_COMPACT, headroomView, readTripwires, safeHeadroom, teamsOf, tripwireWarnings, untrustedDeploy } from './survival.js';
|
|
@@ -30,8 +31,11 @@ import { resolveTerritory } from './resolve.js';
|
|
|
30
31
|
import { BELOW_PLAN_BASIS, boardHistory, bordersBelowPlan, currentTurn, truceRelations, friendsOf, guardOffWarnings, modsWarning, plannerSettings, requirePlayingSeat, requireTurnPhase, turnOrdersArg, } from './turn.js';
|
|
31
32
|
import { resolveTeamsFor } from './team-source.js';
|
|
32
33
|
import { stressOpponents } from './stress-opponents.js';
|
|
33
|
-
import {
|
|
34
|
+
import { sanctionPercentage } from '../analysis/cards-in-effect.js';
|
|
35
|
+
import { COMMANDER_SIZING, commanderCheckOn, defaultFoggedCount, foggedAttackersArg, foggedCommanderOn, foggedCommanderText, myLargestStack } from './commander-check.js';
|
|
36
|
+
import { DEFAULT_FOGGED_ATTACKERS, foggedStack } from '../analysis/commander-fog.js';
|
|
34
37
|
import { captureCheck, checkPlanLog } from './decision-capture.js';
|
|
38
|
+
import { farSummary, opponentScope } from '../analysis/scale.js';
|
|
35
39
|
const VIEWS = ['compact', 'full'];
|
|
36
40
|
const MAX_ENEMY_DEPLOY = 10_000;
|
|
37
41
|
/** Replies listed beside the worst one on the compact view; the full view lists the stress test's own maximum. */
|
|
@@ -63,7 +67,9 @@ export const CHECK_PLAN_NOT_COVERED = [
|
|
|
63
67
|
export function registerCheckPlanTool(server, ctx) {
|
|
64
68
|
server.registerTool('warapp_check_plan', {
|
|
65
69
|
title: 'Stress-test a planned turn in a war.app game',
|
|
66
|
-
description: untrustedDescription('Stress-test a list of orders for your turn in an in-progress war.app (Warzone) game before you submit it
|
|
70
|
+
description: untrustedDescription('Stress-test a list of orders for your turn in an in-progress war.app (Warzone) game before you submit it ' +
|
|
71
|
+
'(in a game of more than 16 opponents, `unseenOpponents` lists only those near your land — `unseenOpponentsMore` ' +
|
|
72
|
+
'counts the rest — and `scale` sums the opponents not in view or within 2 steps of your land): ' +
|
|
67
73
|
'the orders (the `orders` array warapp_plan_turn returns, or your own edit of it) are carried out on the ' +
|
|
68
74
|
'live board, turn rules included (deploys first, then attacks and transfers interleaved in the zigzag move ' +
|
|
69
75
|
'order; each order an attack or a transfer by who holds its target when it runs; kill rates, the guard ' +
|
|
@@ -89,7 +95,10 @@ export function registerCheckPlanTool(server, ctx) {
|
|
|
89
95
|
'board, `commander` says where it stands after the orders, the armies there and `needs`: the armies its ' +
|
|
90
96
|
'territory needs to survive every reply tried, by the check warapp_submit_turn refuses on (each reply at the larger ' +
|
|
91
97
|
'of the estimate and your income, enemy_deploy only raising it, both move orders, your Airlifts counted); when a ' +
|
|
92
|
-
'reply kills it, the summary starts with it.
|
|
98
|
+
'reply kills it, the summary starts with it. `commander.fogged` tests it against `fogged_attackers` (default as warapp_plan_turn: 2 in a Commanders free-for-all of eight or more players under fog, else off) ' +
|
|
99
|
+
'unknown opponents the fog may hide within two moves of where it ends, striking together (each a start of the ' +
|
|
100
|
+
"game's starting armies, else your largest stack, plus a deploy of your income; luck-free): `safe`, `needs`, where " +
|
|
101
|
+
'they may come from; the summary names it when it can fall, and it never changes `safe`. Exact with no luck and ' +
|
|
93
102
|
'straight rounding; otherwise battles are resolved at their expectation and `exact` is false. It does not ' +
|
|
94
103
|
`try: ${CHECK_PLAN_NOT_COVERED.join('; ')}. When this server kept your pick list, \`award\` says what the ` +
|
|
95
104
|
"award of picks showed (as in warapp_plan_turn): the opponent's proven starts stand on the board the " +
|
|
@@ -98,7 +107,9 @@ export function registerCheckPlanTool(server, ctx) {
|
|
|
98
107
|
'`headroom` lists, weakest first, each border of yours with the smallest single deploy by a neighbouring opponent that ' +
|
|
99
108
|
'takes it after these orders, and what falls with it (the bonuses it breaks, the territories behind it and their bonus ' +
|
|
100
109
|
'income). An opponent whose estimate one observation broke (see warapp_plan_turn) is tried at the larger of what it ' +
|
|
101
|
-
'implied and your own income (`enemyDeploy` source `untrusted`), said in the first warning. ' +
|
|
110
|
+
'implied and your own income (`enemyDeploy` source `untrusted`), said in the first warning. Each `enemyDeploy` entry ' +
|
|
111
|
+
"shows the Reinforcement card the clock says it may hold apart as `cardBonus` (in `deploy` unless `assume_enemy_cards` is " +
|
|
112
|
+
'"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). ' +
|
|
102
113
|
'`belowPlan` compares these orders with the default plan made now on the same board (warapp_plan_turn with no ' +
|
|
103
114
|
'options, the award of picks read as it reads it), or with its border guess when the deploys given are the ' +
|
|
104
115
|
"guess's (`belowPlanAgainst`: plan or guess): each border they leave below what that plan leaves standing there, " +
|
|
@@ -109,6 +120,8 @@ export function registerCheckPlanTool(server, ctx) {
|
|
|
109
120
|
'against a break too — each reply that attacks a territory a truce covers is marked `breaksTruce`, and ' +
|
|
110
121
|
'`safeIfTruceHolds` is the verdict over the other replies (null when every reply is a break); a partner-approved ' +
|
|
111
122
|
'truce exception on this turn opens its territories (no break) and is listed under `relations`. ' +
|
|
123
|
+
'In a game running the Diplomacy 2 mod, an ally is such a truce too, and a warning names any order that attacks ' +
|
|
124
|
+
'a territory an ally holds (the game skips it; its armies sit idle). ' +
|
|
112
125
|
`Refuses outside a turn phase. ${BRIDGE_NOTE} Read-only on ` +
|
|
113
126
|
'war.app; it never submits orders.'),
|
|
114
127
|
_meta: lookupMeta(['check my plan', 'stress test my orders', 'what can my opponent do to this turn', 'is this plan safe']),
|
|
@@ -134,6 +147,10 @@ export function registerCheckPlanTool(server, ctx) {
|
|
|
134
147
|
'observation has made its estimate untrusted, the larger of what it implied and your own income). ' +
|
|
135
148
|
'Income in the fog is unseen, so raise it to test a stronger opponent.'),
|
|
136
149
|
known_income: knownIncomeArg,
|
|
150
|
+
fogged_attackers: foggedAttackersArg.describe(`With your commander on the board: how many unknown opponents the fog may hide within two moves of where it ends ` +
|
|
151
|
+
`strike it together (default ${DEFAULT_FOGGED_ATTACKERS} in a free-for-all of eight or more players under fog, as warapp_plan_turn; else 0, which skips the test). Each is taken as a player's start ` +
|
|
152
|
+
"(the game's starting armies, else your largest stack) plus a deploy of your income. Reported as `commander.fogged`; " +
|
|
153
|
+
'never changes `safe`.'),
|
|
137
154
|
avoid_territories: avoidTerritoriesArg,
|
|
138
155
|
avoid_players: avoidPlayersArg,
|
|
139
156
|
first_mover: z
|
|
@@ -141,10 +158,16 @@ export function registerCheckPlanTool(server, ctx) {
|
|
|
141
158
|
.optional()
|
|
142
159
|
.describe('Who moves first this turn, when you know (under cyclic move order it alternates every turn). Omit to ' +
|
|
143
160
|
'try both.'),
|
|
161
|
+
assume_enemy_cards: z
|
|
162
|
+
.enum(['none', 'clock'])
|
|
163
|
+
.optional()
|
|
164
|
+
.describe('"clock" (default): each opponent the Reinforcement card clock says may hold a card (one due, none of its plays ' +
|
|
165
|
+
'seen since) deploys that card on top of its estimate; "none": the replies are sized without it. Each ' +
|
|
166
|
+
"`enemyDeploy` entry shows the card apart as `cardBonus`, so run both to see which risks rest on a guessed card."),
|
|
144
167
|
view: viewArg(VIEWS, `compact (default) gives the verdict, the worst reply and up to ${COMPACT_OTHERS} more; "full" adds every ` +
|
|
145
168
|
'reply listed, each order\'s result unanswered and the rules assumed.'),
|
|
146
169
|
}),
|
|
147
|
-
}, async ({ game_id, player, orders, enemy_deploy, known_income, avoid_territories, avoid_players, first_mover, view }) => {
|
|
170
|
+
}, async ({ game_id, player, orders, enemy_deploy, known_income, fogged_attackers, avoid_territories, avoid_players, first_mover, assume_enemy_cards, view }) => {
|
|
148
171
|
const feed = await ctx.client.getGame(game_id, { settings: true });
|
|
149
172
|
requireTurnPhase(feed);
|
|
150
173
|
const map = mapOf(feed);
|
|
@@ -275,7 +298,9 @@ export function registerCheckPlanTool(server, ctx) {
|
|
|
275
298
|
ignored.push('a card play other than Order Priority or Reinforcement');
|
|
276
299
|
}
|
|
277
300
|
}
|
|
278
|
-
// The same per-opponent estimates warapp_plan_turn works from (stress-opponents.ts)
|
|
301
|
+
// The same per-opponent estimates warapp_plan_turn works from (stress-opponents.ts); an opponent's
|
|
302
|
+
// Reinforcement card the clock adds is on top unless `assume_enemy_cards` is "none".
|
|
303
|
+
const assumeCards = assume_enemy_cards ?? 'clock';
|
|
279
304
|
const so = stressOpponents({
|
|
280
305
|
graph,
|
|
281
306
|
map,
|
|
@@ -292,6 +317,7 @@ export function registerCheckPlanTool(server, ctx) {
|
|
|
292
317
|
...(opening ? { opening } : {}),
|
|
293
318
|
...(mapPace ? { mapPace } : {}),
|
|
294
319
|
...(enemy_deploy !== undefined ? { enemyDeploy: enemy_deploy } : {}),
|
|
320
|
+
assumeCards,
|
|
295
321
|
// #444: the stated incomes scale the other opponents' prior, as warapp_plan_turn has them.
|
|
296
322
|
...(intel.knownIncome?.length ? { known: intel.knownIncome } : {}),
|
|
297
323
|
});
|
|
@@ -323,7 +349,7 @@ export function registerCheckPlanTool(server, ctx) {
|
|
|
323
349
|
const opponents = so.opponents.map((o) => {
|
|
324
350
|
const known = knownOf.get(o.id);
|
|
325
351
|
if (known !== undefined)
|
|
326
|
-
return { ...o, deploy: known + (o.card ?? 0) };
|
|
352
|
+
return { ...o, deploy: known + (assumeCards === 'none' ? 0 : (o.card ?? 0)) };
|
|
327
353
|
const untrusted = untrustedOf.get(o.id);
|
|
328
354
|
return enemy_deploy !== undefined || untrusted === undefined ? o : { ...o, deploy: Math.max(untrusted, o.deploy) };
|
|
329
355
|
});
|
|
@@ -335,8 +361,10 @@ export function registerCheckPlanTool(server, ctx) {
|
|
|
335
361
|
// `income` is the board's, card armies out — the same figure warapp_plan_turn passes.
|
|
336
362
|
// PLAN-TEAMS D3: a Diplomacy card in effect that the decoder is sure of is a truce here in any format
|
|
337
363
|
// (T9: the game enforces it). Its player stays among the opponents too: the decoder is unverified.
|
|
338
|
-
|
|
339
|
-
|
|
364
|
+
// T9 too: a Diplomacy 2 mod alliance (read only in a game that runs the mod) is a truce the game enforces.
|
|
365
|
+
const resolvedTruces = await truceRelations(ctx, { game, me, turn, graph, board: seen, boards: history.boards, myIncome: income, tracks, diplomacy: effect.diplomacy });
|
|
366
|
+
const truces = resolvedTruces?.relations ?? [];
|
|
367
|
+
const modRead = resolvedTruces?.mod;
|
|
340
368
|
const binding = truces.filter((r) => !friend(r.player) &&
|
|
341
369
|
(r.enforced
|
|
342
370
|
? r.enforcedUntil === undefined || turn === null || turn < r.enforcedUntil
|
|
@@ -561,7 +589,22 @@ export function registerCheckPlanTool(server, ctx) {
|
|
|
561
589
|
// The count and `needs` come from one run (the commander check's), so the line never pairs a count
|
|
562
590
|
// the full run found with armies the targeted run says hold.
|
|
563
591
|
const commanderLine = guard ? commanderText(guard, guard.killers) : undefined;
|
|
592
|
+
// Part 5 (mega game): my commander against unknown opponents in the fog striking it together (report only).
|
|
593
|
+
const fogged = guard
|
|
594
|
+
? foggedCommanderOn({
|
|
595
|
+
graph,
|
|
596
|
+
board,
|
|
597
|
+
me: me.id,
|
|
598
|
+
settings,
|
|
599
|
+
deploys,
|
|
600
|
+
moves,
|
|
601
|
+
count: fogged_attackers ?? defaultFoggedCount(game),
|
|
602
|
+
stack: foggedStack(game.settings?.initialPlayerArmiesPerTerritory, myLargestStack(board, me.id)),
|
|
603
|
+
deploy: income,
|
|
604
|
+
})
|
|
605
|
+
: undefined;
|
|
564
606
|
const summary = (guard && (guard.killers > 0 || guard.lostUnanswered) && commanderLine ? `${commanderLine} ` : '') +
|
|
607
|
+
(fogged && !fogged.safe ? `${foggedCommanderText(fogged)} ` : '') +
|
|
565
608
|
(report.safe === null
|
|
566
609
|
? `Nothing could be tested this turn: no opposing stack in view touches you.${blind}${ahead}`
|
|
567
610
|
: report.safe
|
|
@@ -589,6 +632,8 @@ export function registerCheckPlanTool(server, ctx) {
|
|
|
589
632
|
const o = board.territories.find((t) => t.territoryId === id)?.owner;
|
|
590
633
|
return o?.kind === 'player' ? o.playerId : undefined;
|
|
591
634
|
};
|
|
635
|
+
// A Diplomacy 2 ally's territory (owner at the start of the turn): the game skips the attack, its armies sit idle.
|
|
636
|
+
const allyHits = modRead ? attacksOnAllies(modRead, moves, ownerOf) : [];
|
|
592
637
|
const avoidedHits = [...new Set(moves.map((m) => m.to))].filter((to) => !mine.has(to) && (avoidT.has(to) || avoidP.has(ownerOf(to) ?? Number.NaN)));
|
|
593
638
|
const warnings = [
|
|
594
639
|
// The owner, 2026-11-17: while an older build stands in for a client this server cannot read, say so first.
|
|
@@ -597,6 +642,13 @@ export function registerCheckPlanTool(server, ctx) {
|
|
|
597
642
|
...(avoidedHits.length
|
|
598
643
|
? [`These orders attack ${avoidedHits.map((t) => name(t)).join(', ')}, which you asked to avoid (avoid_territories / avoid_players).`]
|
|
599
644
|
: []),
|
|
645
|
+
...(allyHits.length
|
|
646
|
+
? [
|
|
647
|
+
`These orders attack a Diplomacy 2 ally — ${allyHits.map((a) => allyAttackLine(a, (t) => name(t).name)).join('; ')}: ` +
|
|
648
|
+
'the game skips each such attack and its armies sit idle this turn (warapp_submit_turn refuses it unless attack_ally is true).',
|
|
649
|
+
]
|
|
650
|
+
: []),
|
|
651
|
+
...(modRead ? modAllianceWarnings(modRead) : []),
|
|
600
652
|
// #275 (b): an untrusted estimate is the first thing said (not under an explicit enemy_deploy).
|
|
601
653
|
...(enemy_deploy === undefined ? tripwireWarnings(trip.tripwires, (w) => untrustedOf.get(w.player) ?? untrustedDeploy(w, income), (p) => estimates.find((x) => x.playerId === p)?.estimate) : []),
|
|
602
654
|
...(award ? assumedWarning(award) : []),
|
|
@@ -628,7 +680,20 @@ export function registerCheckPlanTool(server, ctx) {
|
|
|
628
680
|
: []),
|
|
629
681
|
];
|
|
630
682
|
const atRiskList = (rows) => rows.slice(0, LIST_MAX);
|
|
683
|
+
// Scale: a large game (more than LARGE_GAME_OPPONENTS opponents) lists only the opponents near my land and
|
|
684
|
+
// sums the rest in `scale`; every other game is unchanged.
|
|
685
|
+
const scope = opponentScope(graph, seen, me.id, opponents.map((o) => o.id));
|
|
686
|
+
const inScope = (p) => !scope.large || scope.near.includes(p);
|
|
631
687
|
return respond(view, VIEWS, (rung) => ({
|
|
688
|
+
...(scope.large
|
|
689
|
+
? {
|
|
690
|
+
scale: {
|
|
691
|
+
opponents: scope.near.length + scope.far.length,
|
|
692
|
+
near: scope.near.length,
|
|
693
|
+
far: farSummary(scope.far, (p) => opponents.find((o) => o.id === p)?.deploy),
|
|
694
|
+
},
|
|
695
|
+
}
|
|
696
|
+
: {}),
|
|
632
697
|
game: { id: game.id, name: game.name ?? null, turn },
|
|
633
698
|
player: { id: me.id, name: me.name },
|
|
634
699
|
safe: report.safe,
|
|
@@ -679,10 +744,21 @@ export function registerCheckPlanTool(server, ctx) {
|
|
|
679
744
|
player: { id: o.id, name: playerName.get(o.id) ?? String(o.id) },
|
|
680
745
|
deploy: o.deploy,
|
|
681
746
|
source: enemy_deploy !== undefined ? 'enemy_deploy' : knownOf.has(o.id) ? 'known_income' : untrustedOf.has(o.id) ? 'untrusted' : 'estimate',
|
|
747
|
+
// The Reinforcement card the clock says it may hold, apart: in `deploy` under assume_enemy_cards "clock" only.
|
|
748
|
+
...(o.cardBonus !== undefined && enemy_deploy === undefined
|
|
749
|
+
? { cardBonus: o.cardBonus, ...(o.cardBonusBasis !== undefined ? { cardBonusBasis: o.cardBonusBasis } : {}) }
|
|
750
|
+
: {}),
|
|
751
|
+
// Sanctions on it: its estimate's income before and after the cut (the card left out).
|
|
752
|
+
...(o.sanctioned?.applied && o.sanctioned.after !== undefined
|
|
753
|
+
? { sanctionApplied: { player: o.id, percentage: sanctionPercentage(o.sanctioned.percentages), before: o.sanctioned.before, after: o.sanctioned.after } }
|
|
754
|
+
: {}),
|
|
682
755
|
})),
|
|
756
|
+
// Whether the replies carry the card the clock adds (default "clock").
|
|
757
|
+
assumeEnemyCards: assumeCards,
|
|
683
758
|
// #180: in a free-for-all, whether you lead (any two opponents are then tried together).
|
|
684
759
|
leader,
|
|
685
|
-
unseenOpponents: opponents.filter((o) => !inView.has(o.id)).map((o) => ({ id: o.id, name: playerName.get(o.id) ?? String(o.id) })),
|
|
760
|
+
unseenOpponents: opponents.filter((o) => !inView.has(o.id) && inScope(o.id)).map((o) => ({ id: o.id, name: playerName.get(o.id) ?? String(o.id) })),
|
|
761
|
+
...(scope.large ? { unseenOpponentsMore: opponents.filter((o) => !inView.has(o.id) && !inScope(o.id)).length } : {}),
|
|
686
762
|
plan: {
|
|
687
763
|
captures: report.baseline.captured.map(name),
|
|
688
764
|
failedAttacks: report.baseline.failed.map(name),
|
|
@@ -722,6 +798,21 @@ export function registerCheckPlanTool(server, ctx) {
|
|
|
722
798
|
sizing: COMMANDER_SIZING,
|
|
723
799
|
// A Blockade or Gift of its territory, which the check does not simulate (the submit refuses it).
|
|
724
800
|
...(checked.cards ? { cards: checked.cards } : {}),
|
|
801
|
+
// Part 5: against unknown opponents the fog may hide within two moves, striking together.
|
|
802
|
+
...(fogged
|
|
803
|
+
? {
|
|
804
|
+
fogged: {
|
|
805
|
+
text: foggedCommanderText(fogged),
|
|
806
|
+
safe: fogged.safe,
|
|
807
|
+
needs: fogged.needs,
|
|
808
|
+
armies: fogged.armies,
|
|
809
|
+
attackers: fogged.attackers,
|
|
810
|
+
from: fogged.from.map((f) => ({ territory: name(f.territory), ...(f.via !== undefined ? { via: name(f.via) } : {}), armies: f.armies })),
|
|
811
|
+
stack: fogged.stack,
|
|
812
|
+
deploy: fogged.deploy,
|
|
813
|
+
},
|
|
814
|
+
}
|
|
815
|
+
: {}),
|
|
725
816
|
},
|
|
726
817
|
}
|
|
727
818
|
: {}),
|