@chrischall/warapp-mcp 0.3.0 → 0.4.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/dist/bundle.js +493 -82
- package/dist/direct/egress.js +75 -0
- package/dist/direct/sign-in.js +16 -4
- package/dist/direct/transport.js +188 -26
- package/dist/protocol/bundle.js +263 -18
- package/dist/protocol/rpc.js +18 -1
- package/dist/push/websocket.js +9 -2
- package/dist/tools/begin-turn.js +3 -5
- package/dist/tools/check-plan.js +3 -1
- package/dist/tools/healthcheck.js +64 -8
- package/dist/tools/index.js +3 -2
- package/dist/tools/live-context.js +71 -6
- package/dist/tools/session.js +20 -4
- package/dist/tools/turn.js +9 -1
- package/dist/version.js +1 -1
- package/manifest.json +1 -1
- package/package.json +1 -1
- package/server.json +2 -2
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
// and the client bundle whose readers decode the board.
|
|
4
4
|
import { McpToolError } from '@chrischall/mcp-utils';
|
|
5
5
|
import { dataDir } from '../config.js';
|
|
6
|
-
import { inGameId, readLatestGameInfo, standingFromInfo } from '../live.js';
|
|
6
|
+
import { inGameId, LiveBoardFormatError, readLatestGameInfo, standingFromInfo } from '../live.js';
|
|
7
7
|
import { BUNDLE_FETCH_TIMEOUT_MS, BUNDLE_MAX_BYTES, BundleProvider } from '../protocol/bundle.js';
|
|
8
|
+
import { ProtocolError } from '../protocol/codec.js';
|
|
9
|
+
import { InterpError } from '../protocol/interp.js';
|
|
8
10
|
import { Method, readTerritoryPicks, writeGetLatestGameInfoParams, writeGetTerritoryPicksParams, } from '../protocol/methods.js';
|
|
9
|
-
import { WarappRpc } from '../protocol/rpc.js';
|
|
11
|
+
import { ProtocolVersionError, WarappRpc } from '../protocol/rpc.js';
|
|
10
12
|
import { BRIDGE_DOMAINS } from '../transport-bridge.js';
|
|
11
13
|
import { hostedSession } from '../direct/session.js';
|
|
12
14
|
import { isHosted } from '../hosted.js';
|
|
@@ -319,12 +321,75 @@ function beginFirstError(game) {
|
|
|
319
321
|
export async function loadLiveTerritories(ctx, game) {
|
|
320
322
|
return (await loadLiveGame(ctx, game)).territories;
|
|
321
323
|
}
|
|
324
|
+
/** The issue tracking the move to the client war.app now serves (protocol 243), named in the window-closed error. */
|
|
325
|
+
export const PROTOCOL_UPDATE_ISSUE = 'https://github.com/chrischall/warapp-mcp/issues/340';
|
|
326
|
+
/**
|
|
327
|
+
* One line for a tool's warnings while a stand-in decodes: war.app ships a client this server cannot read
|
|
328
|
+
* yet, so an older build it still answers is decoding, since when. `undefined` without a stand-in.
|
|
329
|
+
*/
|
|
330
|
+
export function standInLine(w) {
|
|
331
|
+
if (!w)
|
|
332
|
+
return undefined;
|
|
333
|
+
return (`war.app ships a client this server cannot read yet (${w.refusedVersion}), so the client build ${w.version}, ` +
|
|
334
|
+
`which war.app still answers, stands in and decodes the board (since ${w.since}). Boards still decode exactly; ` +
|
|
335
|
+
`war.app may stop answering the old build at any time, and this server then needs its update (#340, ${PROTOCOL_UPDATE_ISSUE}).`);
|
|
336
|
+
}
|
|
337
|
+
/** The stand-in window of the bundle this process decodes with, if one stands in (never loads one). */
|
|
338
|
+
export function standInOf(ctx) {
|
|
339
|
+
return ctx.decoderReport()?.standIn;
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* war.app no longer answers the build that stands in: its reply did not decode with it (bytes left over, an
|
|
343
|
+
* unknown frame) or came in another protocol version. Nothing was decoded.
|
|
344
|
+
*/
|
|
345
|
+
export class StandInClosedError extends McpToolError {
|
|
346
|
+
window;
|
|
347
|
+
name = 'StandInClosedError';
|
|
348
|
+
constructor(window, cause) {
|
|
349
|
+
const why = cause instanceof Error ? cause.message : String(cause);
|
|
350
|
+
super(`war.app no longer answers the client build ${window.version} this server has decoded with since ${window.since} ` +
|
|
351
|
+
`(standing in for ${window.refusedVersion}, which this server cannot read yet): ${why} Nothing was decoded; ` +
|
|
352
|
+
'the old client is no longer accepted, so this server needs the protocol update (#340).', {
|
|
353
|
+
kind: 'unknown',
|
|
354
|
+
hint: `The old client is no longer accepted: this server needs the protocol update (${PROTOCOL_UPDATE_ISSUE}). Play in the war.app web client until then.`,
|
|
355
|
+
cause,
|
|
356
|
+
});
|
|
357
|
+
this.window = window;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
/** A failure that says the reply and the decoder disagree on the layout (or the protocol). */
|
|
361
|
+
const isLayoutFailure = (e) => e instanceof ProtocolVersionError || e instanceof LiveBoardFormatError || e instanceof ProtocolError || e instanceof InterpError;
|
|
362
|
+
/** `e`, or the window-closed error when it is a layout failure while a stand-in decodes. */
|
|
363
|
+
async function windowClosed(ctx, bundle, e) {
|
|
364
|
+
if (!isLayoutFailure(e))
|
|
365
|
+
return e;
|
|
366
|
+
const b = bundle ?? (await ctx.bundle().catch(() => undefined));
|
|
367
|
+
const w = b?.report?.().standIn;
|
|
368
|
+
return w ? new StandInClosedError(w, e) : e;
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* GetLatestGameInfo for a game, decoded: the info (`null` when war.app sent none) and its current standing.
|
|
372
|
+
* A standing that decodes with every byte read records the bundle as a build that works; a layout failure
|
|
373
|
+
* while a stand-in decodes is the window-closed error.
|
|
374
|
+
*/
|
|
375
|
+
export async function readLatestBoard(ctx, gameId) {
|
|
376
|
+
let bundle;
|
|
377
|
+
try {
|
|
378
|
+
const env = await ctx.rpc.call('GetLatestGameInfo', Method.GetLatestGameInfo, (w) => writeGetLatestGameInfoParams(w, gameId));
|
|
379
|
+
bundle = await ctx.bundle();
|
|
380
|
+
const info = readLatestGameInfo(bundle, env.body);
|
|
381
|
+
const territories = standingFromInfo(info);
|
|
382
|
+
if (territories)
|
|
383
|
+
await bundle.markDecoded?.();
|
|
384
|
+
return { info, territories };
|
|
385
|
+
}
|
|
386
|
+
catch (e) {
|
|
387
|
+
throw await windowClosed(ctx, bundle, e);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
322
390
|
/** The live board plus the decoded LatestGameInfo (cards live there); throws when war.app has no board. */
|
|
323
391
|
export async function loadLiveGame(ctx, game) {
|
|
324
|
-
const
|
|
325
|
-
const bundle = await ctx.bundle();
|
|
326
|
-
const info = readLatestGameInfo(bundle, env.body);
|
|
327
|
-
const territories = standingFromInfo(info);
|
|
392
|
+
const { info, territories } = await readLatestBoard(ctx, game.id);
|
|
328
393
|
if (!territories) {
|
|
329
394
|
if (awaitsBegin(game))
|
|
330
395
|
throw beginFirstError(game);
|
package/dist/tools/session.js
CHANGED
|
@@ -70,9 +70,14 @@ export function registerSessionTools(server, deps) {
|
|
|
70
70
|
return {
|
|
71
71
|
decoder: {
|
|
72
72
|
...d,
|
|
73
|
-
...(d.
|
|
74
|
-
? {
|
|
75
|
-
|
|
73
|
+
...(d.standInFor
|
|
74
|
+
? {
|
|
75
|
+
note: `war.app's current client (${d.standInFor.version}) cannot be read by this server, so the client release ` +
|
|
76
|
+
'it was written for (still served by war.app) is decoding boards; war.app answers this server in that layout.',
|
|
77
|
+
}
|
|
78
|
+
: d.fallback
|
|
79
|
+
? { note: "A cached copy of war.app's client is decoding boards: the current version could not be looked up." }
|
|
80
|
+
: {}),
|
|
76
81
|
},
|
|
77
82
|
};
|
|
78
83
|
};
|
|
@@ -102,11 +107,13 @@ export function registerSessionTools(server, deps) {
|
|
|
102
107
|
}, async () => {
|
|
103
108
|
if (hosted && hostToken === 'ok') {
|
|
104
109
|
const pt = deps.pushTransport?.();
|
|
110
|
+
const wall = deps.transport.wall?.() ?? null;
|
|
105
111
|
const base = {
|
|
106
112
|
hosted: true,
|
|
107
113
|
linked: true,
|
|
108
114
|
linkedBy: 'host',
|
|
109
115
|
activeTransport: deps.transport.activeLeg(),
|
|
116
|
+
...(wall ? { wall } : {}),
|
|
110
117
|
...(pt ? { pushTransport: pt } : {}),
|
|
111
118
|
...decoderView(),
|
|
112
119
|
hostedNote: NOTE_HOSTED_DIRECT,
|
|
@@ -132,7 +139,16 @@ export function registerSessionTools(server, deps) {
|
|
|
132
139
|
if (!session)
|
|
133
140
|
return { linked: false, activeTransport, ...push, hint: HINT_NOT_LINKED };
|
|
134
141
|
const ageSeconds = Math.max(0, Math.round((now() - Date.parse(session.capturedAt)) / 1000));
|
|
135
|
-
const
|
|
142
|
+
const wall = deps.transport.wall?.() ?? null;
|
|
143
|
+
const base = {
|
|
144
|
+
linked: true,
|
|
145
|
+
host: session.host,
|
|
146
|
+
capturedAt: session.capturedAt,
|
|
147
|
+
ageSeconds,
|
|
148
|
+
activeTransport,
|
|
149
|
+
...(wall ? { wall } : {}),
|
|
150
|
+
...push,
|
|
151
|
+
};
|
|
136
152
|
return deps.transport.sessionStale() ? { ...base, sessionExpired: true, hint: HINT_EXPIRED } : base;
|
|
137
153
|
});
|
|
138
154
|
});
|
package/dist/tools/turn.js
CHANGED
|
@@ -21,7 +21,7 @@ import { currentTurn, turnsCompleted, gameIdArg, graphOf, namer, readAnnotations
|
|
|
21
21
|
import { lookupMeta, mintMeta } from './hints.js';
|
|
22
22
|
import { chatSummary } from './chat.js';
|
|
23
23
|
import { readPendingSurrenders, surrenderOwedLine } from './surrender-pending.js';
|
|
24
|
-
import { failureText, loadLiveGame, requireApprovedAccount, writeAccount } from './live-context.js';
|
|
24
|
+
import { failureText, loadLiveGame, requireApprovedAccount, standInLine, standInOf, writeAccount } from './live-context.js';
|
|
25
25
|
import { BRIDGE_NOTE, playerArg, resolveMe } from './live.js';
|
|
26
26
|
import { guessOrdersOf, guessView } from './guess-view.js';
|
|
27
27
|
import { guessSalt, peekGuessSalt } from '../guess-salt.js';
|
|
@@ -1904,6 +1904,10 @@ export function registerTurnTools(server, ctx, opts = {}) {
|
|
|
1904
1904
|
const owedLine = surrenderOwedLine(surrenders);
|
|
1905
1905
|
if (owedLine)
|
|
1906
1906
|
warnings.unshift(owedLine);
|
|
1907
|
+
// The owner, 2026-11-17: while an older build stands in for a client this server cannot read, say so first.
|
|
1908
|
+
const standInNote = standInLine(standInOf(ctx));
|
|
1909
|
+
if (standInNote)
|
|
1910
|
+
warnings.unshift(standInNote);
|
|
1907
1911
|
// #312 E3: after turns 4 and 8, my income beside the pace my finished games on this map set
|
|
1908
1912
|
// (reported only: read after the plan is made, never an input to it).
|
|
1909
1913
|
const paceRecord = PACE_TURNS.includes(turnsCompleted(game))
|
|
@@ -2669,6 +2673,10 @@ export function registerTurnTools(server, ctx, opts = {}) {
|
|
|
2669
2673
|
}));
|
|
2670
2674
|
if (belowPlan)
|
|
2671
2675
|
warnings.push(belowPlan);
|
|
2676
|
+
// The owner, 2026-11-17: while an older build stands in for a client this server cannot read, say so first.
|
|
2677
|
+
const standInNote = standInLine(standInOf(ctx));
|
|
2678
|
+
if (standInNote)
|
|
2679
|
+
warnings.unshift(standInNote);
|
|
2672
2680
|
// Deploys first (as the client sends them), merged per territory.
|
|
2673
2681
|
const merged = new Map();
|
|
2674
2682
|
for (const d of deploys) {
|
package/dist/version.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// Single source of truth for the server version. release-please bumps the
|
|
2
2
|
// literal on the marked line (registered in release-please-config.json
|
|
3
3
|
// extra-files); every other module imports VERSION from here.
|
|
4
|
-
export const VERSION = '0.
|
|
4
|
+
export const VERSION = '0.4.0'; // x-release-please-version
|
package/manifest.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"manifest_version": "0.3",
|
|
4
4
|
"name": "warapp-mcp",
|
|
5
5
|
"display_name": "war.app (Warzone)",
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.4.0",
|
|
7
7
|
"description": "war.app (Warzone) game advisor for Claude — your games, maps, bonuses, board analysis and routes via the GameFeed API, plus your games list (waiting on you first), opponent scouting with your head-to-head, the live board, territory picks, cards, turn planning and submission, turn notifications, and chat through your signed-in war.app tab (ContextMint Bridge). Joining, leaving or surrendering a game, accepting another player's surrender, Begin on a speed first turn, picks, turn orders, withdrawing them, chat sends, marking notifications and chat read, deleting notifications and linking a session (local only) are confirm-gated.",
|
|
8
8
|
"author": {
|
|
9
9
|
"name": "Chris Hall",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chrischall/warapp-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"mcpName": "io.github.chrischall/warapp-mcp",
|
|
5
5
|
"description": "war.app (Warzone) game advisor MCP server for Claude — games, maps, bonuses and board analysis via the GameFeed API, plus your games list, opponent scouting, the live board, territory picks, cards, turn planning and submission, turn notifications and chat through your signed-in war.app tab. Developed and maintained by AI (Claude Code).",
|
|
6
6
|
"author": "Claude Code (AI) <https://www.anthropic.com/claude>",
|
package/server.json
CHANGED
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
"url": "https://github.com/chrischall/warapp-mcp",
|
|
7
7
|
"source": "github"
|
|
8
8
|
},
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.4.0",
|
|
10
10
|
"packages": [
|
|
11
11
|
{
|
|
12
12
|
"registryType": "npm",
|
|
13
13
|
"identifier": "@chrischall/warapp-mcp",
|
|
14
|
-
"version": "0.
|
|
14
|
+
"version": "0.4.0",
|
|
15
15
|
"transport": {
|
|
16
16
|
"type": "stdio"
|
|
17
17
|
},
|