@chrischall/warapp-mcp 0.22.1 → 0.23.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 +49 -3
- package/dist/analysis/coalition.js +3 -2
- package/dist/analysis/outlook.js +42 -2
- package/dist/analysis/plan/captures.js +2 -0
- package/dist/analysis/plan/report.js +2 -2
- package/dist/analysis/plan/targets.js +15 -5
- package/dist/analysis/plan/threats.js +55 -2
- package/dist/analysis/planner.js +2 -1
- package/dist/bundle.js +10186 -3727
- package/dist/chat.js +93 -3
- package/dist/clans.js +308 -0
- package/dist/forums.js +70 -0
- package/dist/friends.js +83 -0
- package/dist/index.js +1 -1
- package/dist/invite-code.js +46 -0
- package/dist/join-color.js +23 -13
- package/dist/ladders.js +360 -0
- package/dist/mail.js +295 -0
- package/dist/my-games.js +18 -1
- package/dist/notifications.js +22 -4
- package/dist/open-games.js +29 -2
- package/dist/outlook-log.js +1 -0
- package/dist/protocol/bundle.js +4 -4
- package/dist/protocol/codec.js +1 -1
- package/dist/protocol/methods.js +690 -8
- package/dist/protocol/rpc.js +28 -3
- package/dist/push/socketio.js +2 -2
- package/dist/quickmatch.js +264 -0
- package/dist/surrender-pending.js +62 -2
- package/dist/templates.js +451 -0
- package/dist/tools/boot-player.js +165 -0
- package/dist/tools/chat.js +19 -0
- package/dist/tools/clan-writes.js +208 -0
- package/dist/tools/clans.js +181 -0
- package/dist/tools/end-game-common.js +49 -0
- package/dist/tools/forums.js +535 -0
- package/dist/tools/friends.js +50 -0
- package/dist/tools/game.js +21 -3
- package/dist/tools/index.js +39 -0
- package/dist/tools/invites.js +347 -0
- package/dist/tools/join-game.js +4 -4
- package/dist/tools/ladders.js +418 -0
- package/dist/tools/leave-game.js +85 -27
- package/dist/tools/live-context.js +2 -2
- package/dist/tools/mail.js +600 -0
- package/dist/tools/my-games.js +50 -6
- package/dist/tools/notifications.js +12 -3
- package/dist/tools/nudge.js +178 -0
- package/dist/tools/quickmatch.js +481 -0
- package/dist/tools/react.js +177 -0
- package/dist/tools/session.js +6 -2
- package/dist/tools/team-surrender.js +206 -0
- package/dist/tools/templates.js +342 -0
- package/dist/tools/tournaments.js +495 -0
- package/dist/tools/turn.js +1 -1
- package/dist/tools/vote-to-end.js +142 -0
- package/dist/tools/write-kit.js +22 -1
- package/dist/tournaments.js +321 -0
- package/dist/version.js +1 -1
- package/manifest.json +190 -2
- package/mint.yaml +3 -4
- package/package.json +1 -1
- package/server.json +2 -2
- package/skills/warapp-mcp/SKILL.md +39 -6
package/dist/mail.js
ADDED
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
// war.app private mail (#629): the "Discussions" of type PrivateDiscussion. Replies are decoded by the client bundle's
|
|
2
|
+
// own readers by stable type name — `DiscussionForClient` → `Discussion` → `DiscussionPost`, `DiscussionInfo` and
|
|
3
|
+
// `PlayerInfo2` — fields by read order, checked by type, never by their minified names (docs/WEB-PROTOCOL.md, "Private
|
|
4
|
+
// mail"). UNVERIFIED live: read from the 6.09 bundle, nothing here has been checked against a real reply.
|
|
5
|
+
//
|
|
6
|
+
// Personal fields never leave this file: of a PlayerInfo2 only the name is read (its nested records — the clan and the
|
|
7
|
+
// rest — are never looked at). Subjects, post texts and names are other players' words: the tools pass them on only
|
|
8
|
+
// through untrustedText / untrustedBody.
|
|
9
|
+
//
|
|
10
|
+
// The unread signal is MessageExtrasDown's `UnreadMailCheckResults` (two bools and a date) that every /Services reply
|
|
11
|
+
// can carry; `WarappRpc.unreadMail` keeps the newest. The bundle does not name which bool is mail and which is the
|
|
12
|
+
// notifications badge (the client clears both together when its notifications screen opens), so `flagged` is either.
|
|
13
|
+
import { McpToolError } from '@chrischall/mcp-utils';
|
|
14
|
+
import { fields, isObj } from './protocol/decoded.js';
|
|
15
|
+
export const DISCUSSION_FOR_CLIENT = 'warlight.shared.discussions.DiscussionForClient';
|
|
16
|
+
export const DISCUSSION = 'warlight.shared.discussions.Discussion';
|
|
17
|
+
export const DISCUSSION_POST = 'warlight.shared.discussions.DiscussionPost';
|
|
18
|
+
export const DISCUSSION_INFO = 'warlight.shared.discussions.DiscussionInfo';
|
|
19
|
+
export const PLAYER_INFO = 'warlight.shared.PlayerInfo2';
|
|
20
|
+
export const DISCUSSION_INFOS = 'warlight.shared.discussions.DiscussionInfos';
|
|
21
|
+
export const PUBLIC_FORUM = 'warlight.shared.discussions.PublicForum';
|
|
22
|
+
/** `warlight.shared.discussions.DiscussionType`: 1 is PrivateDiscussion (mail). */
|
|
23
|
+
export const DISCUSSION_TYPE_PRIVATE = 1;
|
|
24
|
+
/** The client refuses a post to a thread whose last post is this many days old ("too old and cannot be posted to"). */
|
|
25
|
+
export const MAIL_POST_MAX_AGE_DAYS = 30;
|
|
26
|
+
/** Field positions in read order, and each record's whole field count. */
|
|
27
|
+
const DFC = { discussion: 0, forum: 2, players: 3, watchers: 4 };
|
|
28
|
+
const DFC_FIELDS = 8;
|
|
29
|
+
const D = {
|
|
30
|
+
allowAdditions: 0,
|
|
31
|
+
author: 2,
|
|
32
|
+
created: 3,
|
|
33
|
+
forumId: 9,
|
|
34
|
+
id: 11,
|
|
35
|
+
locked: 13,
|
|
36
|
+
lastPost: 15,
|
|
37
|
+
postCount: 16,
|
|
38
|
+
posts: 17,
|
|
39
|
+
players: 18,
|
|
40
|
+
subject: 20,
|
|
41
|
+
type: 21,
|
|
42
|
+
};
|
|
43
|
+
const D_FIELDS = 25;
|
|
44
|
+
const P = { added: 0, author: 2, time: 3, edited: 4, id: 6, text: 9, votes: 11 };
|
|
45
|
+
const P_FIELDS = 12;
|
|
46
|
+
const I = {
|
|
47
|
+
author: 0,
|
|
48
|
+
authorInfo: 1,
|
|
49
|
+
created: 2,
|
|
50
|
+
id: 4,
|
|
51
|
+
forumId: 6,
|
|
52
|
+
locked: 8,
|
|
53
|
+
lastPoster: 9,
|
|
54
|
+
lastPosterInfo: 10,
|
|
55
|
+
lastPost: 11,
|
|
56
|
+
posts: 13,
|
|
57
|
+
subject: 14,
|
|
58
|
+
unread: 15,
|
|
59
|
+
visibility: 16,
|
|
60
|
+
};
|
|
61
|
+
const I_FIELDS = 18;
|
|
62
|
+
const PI_NAME = 4;
|
|
63
|
+
const PI_FIELDS = 8;
|
|
64
|
+
/** A mail reply arrived in a shape this server does not understand. */
|
|
65
|
+
export class MailFormatError extends McpToolError {
|
|
66
|
+
constructor(detail) {
|
|
67
|
+
super(`war.app's mail reply arrived in an unexpected shape (${detail}).`, {
|
|
68
|
+
kind: 'unknown',
|
|
69
|
+
hint: 'The war.app client may have changed; the mail can still be read in the war.app tab.',
|
|
70
|
+
});
|
|
71
|
+
this.name = 'MailFormatError';
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const isInt = (v) => typeof v === 'number' && Number.isInteger(v);
|
|
75
|
+
const isStr = (v) => v === null || typeof v === 'string';
|
|
76
|
+
const dateOf = (v) => (v instanceof Date && Number.isFinite(v.getTime()) ? v.toISOString() : null);
|
|
77
|
+
const intsOf = (v) => (Array.isArray(v) ? v.filter(isInt) : null);
|
|
78
|
+
export function record(v, type, count) {
|
|
79
|
+
if (!isObj(v) || v.$type !== type)
|
|
80
|
+
throw new MailFormatError(`expected a ${type.split('.').pop()}`);
|
|
81
|
+
const f = fields(v);
|
|
82
|
+
if (f.length !== count)
|
|
83
|
+
throw new MailFormatError(`a ${type.split('.').pop()} has ${f.length} fields, not ${count}`);
|
|
84
|
+
return f;
|
|
85
|
+
}
|
|
86
|
+
/** A PlayerInfo2's name, and nothing else of it. */
|
|
87
|
+
function nameOf(v) {
|
|
88
|
+
if (v === null || v === undefined)
|
|
89
|
+
return null;
|
|
90
|
+
const f = record(v, PLAYER_INFO, PI_FIELDS);
|
|
91
|
+
const name = f[PI_NAME];
|
|
92
|
+
return typeof name === 'string' ? name : null;
|
|
93
|
+
}
|
|
94
|
+
/** The id → name map of a DiscussionForClient's player dict (pairs, as the interpreter gives a dict). */
|
|
95
|
+
function namesOf(v) {
|
|
96
|
+
const out = new Map();
|
|
97
|
+
if (!Array.isArray(v))
|
|
98
|
+
return out;
|
|
99
|
+
for (const e of v) {
|
|
100
|
+
if (!Array.isArray(e) || e.length !== 2 || !isInt(e[0]))
|
|
101
|
+
continue;
|
|
102
|
+
out.set(e[0], nameOf(e[1]));
|
|
103
|
+
}
|
|
104
|
+
return out;
|
|
105
|
+
}
|
|
106
|
+
function postOf(v, names) {
|
|
107
|
+
const f = record(v, DISCUSSION_POST, P_FIELDS);
|
|
108
|
+
const id = f[P.id];
|
|
109
|
+
const author = f[P.author];
|
|
110
|
+
const text = f[P.text];
|
|
111
|
+
if (!isInt(id) || !isInt(author) || !isStr(text))
|
|
112
|
+
throw new MailFormatError('a post lacks its id, author or text');
|
|
113
|
+
const added = intsOf(f[P.added]);
|
|
114
|
+
const votes = votesOf(f[P.votes]);
|
|
115
|
+
return {
|
|
116
|
+
id,
|
|
117
|
+
author: { inGameId: author, name: names.get(author) ?? null },
|
|
118
|
+
time: dateOf(f[P.time]),
|
|
119
|
+
edited: dateOf(f[P.edited]),
|
|
120
|
+
text,
|
|
121
|
+
...(added ? { addedPlayers: added } : {}),
|
|
122
|
+
...(votes.length ? { votes } : {}),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
/** A post's vote dict (pairs, as the interpreter gives a dict): player → vote. */
|
|
126
|
+
function votesOf(v) {
|
|
127
|
+
if (!Array.isArray(v))
|
|
128
|
+
return [];
|
|
129
|
+
const out = [];
|
|
130
|
+
for (const e of v)
|
|
131
|
+
if (Array.isArray(e) && e.length === 2 && isInt(e[0]) && isInt(e[1]))
|
|
132
|
+
out.push({ player: e[0], vote: e[1] });
|
|
133
|
+
return out;
|
|
134
|
+
}
|
|
135
|
+
/** The watchers text as the client reads it: a JSON list of player ids (numbers or digit strings); none is nobody. */
|
|
136
|
+
export function watchersOf(v) {
|
|
137
|
+
if (v === null || v === undefined || v === '')
|
|
138
|
+
return [];
|
|
139
|
+
if (typeof v !== 'string' || v.length > 1_000_000)
|
|
140
|
+
return null;
|
|
141
|
+
let parsed;
|
|
142
|
+
try {
|
|
143
|
+
parsed = JSON.parse(v);
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
if (!Array.isArray(parsed))
|
|
149
|
+
return null;
|
|
150
|
+
const out = [];
|
|
151
|
+
for (const e of parsed) {
|
|
152
|
+
const n = typeof e === 'number' ? e : typeof e === 'string' && /^\d{1,10}$/.test(e) ? Number(e) : NaN;
|
|
153
|
+
if (!Number.isInteger(n))
|
|
154
|
+
return null;
|
|
155
|
+
out.push(n);
|
|
156
|
+
}
|
|
157
|
+
return out;
|
|
158
|
+
}
|
|
159
|
+
const FORUM_FIELDS = 8;
|
|
160
|
+
const FORUM_ID = 6;
|
|
161
|
+
const FORUM_NAME = 7;
|
|
162
|
+
const FORUM_RULE = 1;
|
|
163
|
+
/** A PublicForum's id, name and posting rule (its other texts are never read). */
|
|
164
|
+
export function forumOf(v) {
|
|
165
|
+
const f = record(v, PUBLIC_FORUM, FORUM_FIELDS);
|
|
166
|
+
const id = f[FORUM_ID];
|
|
167
|
+
const name = f[FORUM_NAME];
|
|
168
|
+
const rule = f[FORUM_RULE];
|
|
169
|
+
if (!isInt(id) || !isStr(name))
|
|
170
|
+
throw new MailFormatError('a forum lacks its id or name');
|
|
171
|
+
return { id, name, postRule: isInt(rule) ? rule : null };
|
|
172
|
+
}
|
|
173
|
+
/** Read a GetDiscussion result (the body positioned at the result-present flag); `null` when war.app sent none. */
|
|
174
|
+
export function readDiscussion(bundle, body) {
|
|
175
|
+
if (!body.bool())
|
|
176
|
+
return null;
|
|
177
|
+
const dfc = record(bundle.readClass(DISCUSSION_FOR_CLIENT, body), DISCUSSION_FOR_CLIENT, DFC_FIELDS);
|
|
178
|
+
if (body.remaining !== 0)
|
|
179
|
+
throw new MailFormatError(`${body.remaining} bytes left unread after the thread`);
|
|
180
|
+
const d = record(dfc[DFC.discussion], DISCUSSION, D_FIELDS);
|
|
181
|
+
const names = namesOf(dfc[DFC.players]);
|
|
182
|
+
const id = d[D.id];
|
|
183
|
+
const author = d[D.author];
|
|
184
|
+
const subject = d[D.subject];
|
|
185
|
+
const postCount = d[D.postCount];
|
|
186
|
+
const locked = d[D.locked];
|
|
187
|
+
const type = d[D.type];
|
|
188
|
+
const allow = d[D.allowAdditions];
|
|
189
|
+
const forumId = d[D.forumId];
|
|
190
|
+
const forum = dfc[DFC.forum] === null || dfc[DFC.forum] === undefined ? null : forumOf(dfc[DFC.forum]);
|
|
191
|
+
if (!isInt(id) || !isInt(author) || !isStr(subject) || !isInt(postCount) || typeof locked !== 'boolean') {
|
|
192
|
+
throw new MailFormatError('a thread lacks its id, author, subject, post count or locked flag');
|
|
193
|
+
}
|
|
194
|
+
const posts = Array.isArray(d[D.posts]) ? d[D.posts].filter((p) => p !== null).map((p) => postOf(p, names)) : [];
|
|
195
|
+
const players = (intsOf(d[D.players]) ?? []).map((p) => ({ inGameId: p, name: names.get(p) ?? null }));
|
|
196
|
+
return {
|
|
197
|
+
id,
|
|
198
|
+
subject,
|
|
199
|
+
private: type === DISCUSSION_TYPE_PRIVATE,
|
|
200
|
+
type: isInt(type) ? type : null,
|
|
201
|
+
locked,
|
|
202
|
+
allowAdditions: typeof allow === 'boolean' ? allow : null,
|
|
203
|
+
author: { inGameId: author, name: names.get(author) ?? null },
|
|
204
|
+
created: dateOf(d[D.created]),
|
|
205
|
+
lastPost: dateOf(d[D.lastPost]),
|
|
206
|
+
postCount,
|
|
207
|
+
players,
|
|
208
|
+
posts,
|
|
209
|
+
forumId: isInt(forumId) ? forumId : null,
|
|
210
|
+
forum: forum ? { id: forum.id, name: forum.name } : null,
|
|
211
|
+
watchers: watchersOf(dfc[DFC.watchers]),
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
export function infoOf(v) {
|
|
215
|
+
const f = record(v, DISCUSSION_INFO, I_FIELDS);
|
|
216
|
+
const id = f[I.id];
|
|
217
|
+
const author = f[I.author];
|
|
218
|
+
const last = f[I.lastPoster];
|
|
219
|
+
const subject = f[I.subject];
|
|
220
|
+
const posts = f[I.posts];
|
|
221
|
+
const locked = f[I.locked];
|
|
222
|
+
if (!isInt(id) || !isInt(author) || !isInt(last) || !isStr(subject) || !isInt(posts) || typeof locked !== 'boolean') {
|
|
223
|
+
throw new MailFormatError('a listed thread lacks its fields');
|
|
224
|
+
}
|
|
225
|
+
return {
|
|
226
|
+
id,
|
|
227
|
+
subject,
|
|
228
|
+
author: { inGameId: author, name: nameOf(f[I.authorInfo]) },
|
|
229
|
+
created: dateOf(f[I.created]),
|
|
230
|
+
lastPoster: { inGameId: last, name: nameOf(f[I.lastPosterInfo]) },
|
|
231
|
+
lastPost: dateOf(f[I.lastPost]),
|
|
232
|
+
postCount: posts,
|
|
233
|
+
locked,
|
|
234
|
+
forumId: isInt(f[I.forumId]) ? f[I.forumId] : 0,
|
|
235
|
+
unread: f[I.unread] === true,
|
|
236
|
+
visibility: isInt(f[I.visibility]) ? f[I.visibility] : null,
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
/** Read a SearchPrivateDiscussions result (the body at the result-present flag): a list of optional DiscussionInfo. */
|
|
240
|
+
export function readDiscussionInfos(bundle, body) {
|
|
241
|
+
if (!body.bool())
|
|
242
|
+
return [];
|
|
243
|
+
const out = [];
|
|
244
|
+
const n = body.int32();
|
|
245
|
+
if (n === -1)
|
|
246
|
+
return out;
|
|
247
|
+
if (n < 0 || n > 10_000)
|
|
248
|
+
throw new MailFormatError(`a list of ${n} threads`);
|
|
249
|
+
for (let i = 0; i < n; i++) {
|
|
250
|
+
if (!body.bool())
|
|
251
|
+
continue;
|
|
252
|
+
out.push(infoOf(bundle.readClass(DISCUSSION_INFO, body)));
|
|
253
|
+
}
|
|
254
|
+
if (body.remaining !== 0)
|
|
255
|
+
throw new MailFormatError(`${body.remaining} bytes left unread after the thread list`);
|
|
256
|
+
return out;
|
|
257
|
+
}
|
|
258
|
+
/** Hosts a mail link may name (war.app, and the old Warzone domain the site still answers on). */
|
|
259
|
+
const MAIL_HOSTS = new Set(['war.app', 'www.war.app', 'warzone.com', 'www.warzone.com']);
|
|
260
|
+
/** The thread a link names (`/Discussion/?ID=<n>`, the client's own mail link), else null. */
|
|
261
|
+
export function discussionIdOfUrl(url) {
|
|
262
|
+
if (typeof url !== 'string' || url.length > 2048)
|
|
263
|
+
return null;
|
|
264
|
+
let parsed;
|
|
265
|
+
try {
|
|
266
|
+
parsed = new URL(url, 'https://war.app/');
|
|
267
|
+
}
|
|
268
|
+
catch {
|
|
269
|
+
return null;
|
|
270
|
+
}
|
|
271
|
+
if (parsed.protocol !== 'https:' && parsed.protocol !== 'http:')
|
|
272
|
+
return null;
|
|
273
|
+
if (!MAIL_HOSTS.has(parsed.hostname.toLowerCase()))
|
|
274
|
+
return null;
|
|
275
|
+
if (!/^\/discussion\/?$/i.test(parsed.pathname))
|
|
276
|
+
return null;
|
|
277
|
+
for (const [k, v] of parsed.searchParams) {
|
|
278
|
+
if (k.toLowerCase() === 'id' && /^\d{1,10}$/.test(v)) {
|
|
279
|
+
const id = Number(v);
|
|
280
|
+
if (id > 0 && id <= 0x7fffffff)
|
|
281
|
+
return id;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
return null;
|
|
285
|
+
}
|
|
286
|
+
/** The note every mail signal carries. */
|
|
287
|
+
export const MAIL_SIGNAL_NOTE = "From war.app's UnreadMailCheckResults, which rides on its replies (no extra request): `flagged` is true when " +
|
|
288
|
+
'either of its two flags is set — war.app does not name which is mail and which is the notifications badge, so ' +
|
|
289
|
+
'read the mail with warapp_mail_inbox. UNVERIFIED live.';
|
|
290
|
+
/** The mail signal a tool reports: `null` when no reply has carried one yet. */
|
|
291
|
+
export function mailSignal(check) {
|
|
292
|
+
if (!check)
|
|
293
|
+
return { flagged: null, flags: null, note: MAIL_SIGNAL_NOTE };
|
|
294
|
+
return { flagged: check.flags[0] || check.flags[1], flags: check.flags, note: MAIL_SIGNAL_NOTE };
|
|
295
|
+
}
|
package/dist/my-games.js
CHANGED
|
@@ -116,7 +116,7 @@ export function myGamesTeams(games, gameId) {
|
|
|
116
116
|
out.set(p.id, p.team);
|
|
117
117
|
return out;
|
|
118
118
|
}
|
|
119
|
-
function gameOf(g) {
|
|
119
|
+
export function gameOf(g) {
|
|
120
120
|
if (!isObj(g) || g.$type !== GAME_INFO)
|
|
121
121
|
throw new MyGamesFormatError('a game is not a GameInfo');
|
|
122
122
|
const f = fields(g);
|
|
@@ -230,6 +230,23 @@ export function readMyGames(bundle, body) {
|
|
|
230
230
|
throw new MyGamesFormatError('no game list');
|
|
231
231
|
return list.filter((g) => g !== null).map(gameOf);
|
|
232
232
|
}
|
|
233
|
+
/**
|
|
234
|
+
* A GetMyGames result's GameInfo records as the bundle decoded them, unread (#633: the invitation accept reads one
|
|
235
|
+
* the way the open-games list does, src/open-games.ts `openGameOf`). Same shape checks as {@link readMyGames}.
|
|
236
|
+
*/
|
|
237
|
+
export function readMyGameInfos(bundle, body) {
|
|
238
|
+
if (!body.bool())
|
|
239
|
+
return [];
|
|
240
|
+
const ret = bundle.readClass(MY_GAMES_RETURN, body);
|
|
241
|
+
if (!isObj(ret))
|
|
242
|
+
throw new MyGamesFormatError('no MyGamesReturn');
|
|
243
|
+
const list = fields(ret)[0];
|
|
244
|
+
if (list === null)
|
|
245
|
+
return [];
|
|
246
|
+
if (!Array.isArray(list))
|
|
247
|
+
throw new MyGamesFormatError('no game list');
|
|
248
|
+
return list.filter((g) => isObj(g) && g.$type === GAME_INFO);
|
|
249
|
+
}
|
|
233
250
|
/** Whether the game has finished. */
|
|
234
251
|
export const isFinished = (g) => g.stateCode === GAME_FINISHED;
|
|
235
252
|
/**
|
package/dist/notifications.js
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
import { McpToolError } from '@chrischall/mcp-utils';
|
|
11
11
|
import { fields, isObj } from './protocol/decoded.js';
|
|
12
12
|
import { NOTIFICATION_ID } from './protocol/methods.js';
|
|
13
|
+
import { discussionIdOfUrl } from './mail.js';
|
|
13
14
|
export { NOTIFICATIONS_PAGE_SIZE } from './protocol/methods.js';
|
|
14
15
|
export const IN_APP_NOTIFICATIONS_RETURN = 'warlight.shared.GetInAppNotificationsReturn';
|
|
15
16
|
export const IN_APP_NOTIFICATION = 'warlight.shared.InAppNotification';
|
|
@@ -95,8 +96,8 @@ function gameIdOfUrl(url) {
|
|
|
95
96
|
}
|
|
96
97
|
return null;
|
|
97
98
|
}
|
|
98
|
-
/** The
|
|
99
|
-
|
|
99
|
+
/** The id a notification's data links to by `idOf`: its `Url`, else the first of its `Urls` that names one. */
|
|
100
|
+
function linkedIdFromData(data, idOf) {
|
|
100
101
|
if (data === null || data.length > MAX_DATA)
|
|
101
102
|
return null;
|
|
102
103
|
let obj;
|
|
@@ -108,18 +109,30 @@ export function gameIdFromData(data) {
|
|
|
108
109
|
}
|
|
109
110
|
if (!isObj(obj))
|
|
110
111
|
return null;
|
|
111
|
-
const direct =
|
|
112
|
+
const direct = idOf(obj.Url);
|
|
112
113
|
if (direct !== null)
|
|
113
114
|
return direct;
|
|
114
115
|
if (Array.isArray(obj.Urls)) {
|
|
115
116
|
for (const u of obj.Urls.slice(0, 20)) {
|
|
116
|
-
const id = isObj(u) ?
|
|
117
|
+
const id = isObj(u) ? idOf(u.Url) : null;
|
|
117
118
|
if (id !== null)
|
|
118
119
|
return id;
|
|
119
120
|
}
|
|
120
121
|
}
|
|
121
122
|
return null;
|
|
122
123
|
}
|
|
124
|
+
/** The game a notification's data links to: its `Url`, else the first of its `Urls` that names one. */
|
|
125
|
+
export function gameIdFromData(data) {
|
|
126
|
+
return linkedIdFromData(data, gameIdOfUrl);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* #629: the mail thread a notification's data links to (the client's mail link, `/Discussion/?ID=`), as a mail
|
|
130
|
+
* notification ("Someone sent you War.app mail") is expected to carry — UNVERIFIED live: no mail notification has
|
|
131
|
+
* been seen.
|
|
132
|
+
*/
|
|
133
|
+
export function discussionIdFromData(data) {
|
|
134
|
+
return linkedIdFromData(data, discussionIdOfUrl);
|
|
135
|
+
}
|
|
123
136
|
/**
|
|
124
137
|
* The title of a game-ended notification, in the client's own wording (an owner's screenshot,
|
|
125
138
|
* 2026-11-16): `Game "<name>" has ended. You can now view its history`. Matched on that structure,
|
|
@@ -139,5 +152,10 @@ export function classifyNotification(n) {
|
|
|
139
152
|
gameId: gameIdFromData(n.data),
|
|
140
153
|
time: n.sent ? n.sent.toISOString() : null,
|
|
141
154
|
unread: n.unread,
|
|
155
|
+
...withDiscussion(n.data),
|
|
142
156
|
};
|
|
143
157
|
}
|
|
158
|
+
function withDiscussion(data) {
|
|
159
|
+
const id = discussionIdFromData(data);
|
|
160
|
+
return id === null ? {} : { discussionId: id };
|
|
161
|
+
}
|
package/dist/open-games.js
CHANGED
|
@@ -129,7 +129,7 @@ const isNum = (v) => typeof v === 'number' && Number.isFinite(v);
|
|
|
129
129
|
const isBool = (v) => typeof v === 'boolean';
|
|
130
130
|
const isIntList = (v) => Array.isArray(v) && v.every(isInt);
|
|
131
131
|
/** A TimeSpan in ms as war.app shows it: `3d`, `1d12h`, `6h`, `2h30m`, `5m`, `45s`. */
|
|
132
|
-
function formatDuration(ms) {
|
|
132
|
+
export function formatDuration(ms) {
|
|
133
133
|
const days = Math.floor(ms / 86_400_000);
|
|
134
134
|
const hours = Math.floor(ms / 3_600_000) % 24;
|
|
135
135
|
const mins = Math.floor(ms / 60_000) % 60;
|
|
@@ -157,7 +157,7 @@ function settingsString(s) {
|
|
|
157
157
|
return { cards, mods: parts[0] === '3' && parts[5] === 'm' };
|
|
158
158
|
}
|
|
159
159
|
/** The flags a GameInfoSettings record carries; `undefined` when it is not one. */
|
|
160
|
-
function readSettings(v) {
|
|
160
|
+
export function readSettings(v) {
|
|
161
161
|
if (!isObj(v) || v.$type !== GAME_INFO_SETTINGS)
|
|
162
162
|
return undefined;
|
|
163
163
|
const f = fieldsOf(v, GAME_INFO_SETTINGS, GAME_INFO_SETTINGS_FIELDS);
|
|
@@ -342,6 +342,33 @@ function readOpenGame(record) {
|
|
|
342
342
|
lobby: { seatedPlayerIds: seated.map((p) => p.id), colorsTaken, seated: seated.map((p) => ({ id: p.id, team: p.team, ai: p.ai })) },
|
|
343
343
|
};
|
|
344
344
|
}
|
|
345
|
+
/**
|
|
346
|
+
* One GameInfo from anywhere (#633: GetMyGames' record of a game I am invited to, read as the open-games list reads
|
|
347
|
+
* its own), as an open game and its lobby; `undefined` when it does not fit. A record without the client's field
|
|
348
|
+
* count throws {@link OpenGamesFormatError}.
|
|
349
|
+
*/
|
|
350
|
+
export function openGameOf(record) {
|
|
351
|
+
return readOpenGame(record);
|
|
352
|
+
}
|
|
353
|
+
/** GameInfoPlayer field 1: the client's ColorLockedIn (read from the bundle: the lobby sends no colour when it is set). */
|
|
354
|
+
const GP_COLOR_LOCKED = 1;
|
|
355
|
+
/** The seat of in-game id `me` in a GameInfo record; `undefined` when the record holds no such player. */
|
|
356
|
+
export function seatIn(record, me) {
|
|
357
|
+
if (!isObj(record) || record.$type !== GAME_INFO)
|
|
358
|
+
return undefined;
|
|
359
|
+
const players = fields(record)[GI.players];
|
|
360
|
+
if (!Array.isArray(players))
|
|
361
|
+
return undefined;
|
|
362
|
+
for (const p of players) {
|
|
363
|
+
const read = lobbyPlayer(p);
|
|
364
|
+
if (read?.id !== me || !isObj(p))
|
|
365
|
+
continue;
|
|
366
|
+
const locked = fields(p)[GP_COLOR_LOCKED];
|
|
367
|
+
const state = fields(p)[GP.state];
|
|
368
|
+
return { state: playerStateName(state), color: read.color, colorLocked: isBool(locked) ? locked : null };
|
|
369
|
+
}
|
|
370
|
+
return undefined;
|
|
371
|
+
}
|
|
345
372
|
/** The tournament id a GameInfoTournament carries (#423); undefined for none or a shape this server does not know. */
|
|
346
373
|
function tournamentOf(v) {
|
|
347
374
|
if (!isObj(v) || v.$type !== GAME_INFO_TOURNAMENT)
|
package/dist/outlook-log.js
CHANGED
package/dist/protocol/bundle.js
CHANGED
|
@@ -175,15 +175,15 @@ export class WarappBundle {
|
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
177
|
/**
|
|
178
|
-
* The pinned known-good client: v6.
|
|
179
|
-
* reader of this server is written for (#340). It stands in for a current client refused at load when
|
|
178
|
+
* The pinned known-good client: v6.09.0, protocol 244, the release every hand-written encoder and
|
|
179
|
+
* reader of this server is written for (#626; before it v6.08.0.2, protocol 243, #340). It stands in for a current client refused at load when
|
|
180
180
|
* no recorded build does, only with this digest. war.app's CDN ignores `?v=` and serves the current
|
|
181
181
|
* build, so it can be downloaded by version only while Cloudflare still caches that URL
|
|
182
182
|
* (docs/CLIENT-RELEASES.md): the copy kept in the data dir is what a stand-in really rests on.
|
|
183
183
|
*/
|
|
184
184
|
export const KNOWN_GOOD_BUNDLE = {
|
|
185
|
-
version: '
|
|
186
|
-
digest: '
|
|
185
|
+
version: '639313901457980872',
|
|
186
|
+
digest: '4ddcf1ff18284064991568d496c924dcc055efd18a24075b0b570b7fca2dce92',
|
|
187
187
|
};
|
|
188
188
|
/** The CDN URL of a client release, by version (the location {@link discoverBundleUrl} pins). */
|
|
189
189
|
const bundleUrlOf = (version) => `https://${BUNDLE_HOST}${BUNDLE_PATH}?v=${version}`;
|
package/dist/protocol/codec.js
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
// parameters. Replies carry a byte (1 → MessageExtrasDown follows), a kind byte
|
|
20
20
|
// (5 → a server error {code, message} follows) and the method's result.
|
|
21
21
|
export const PREAMBLE = 1514664249;
|
|
22
|
-
export const PROTOCOL_VERSION =
|
|
22
|
+
export const PROTOCOL_VERSION = 244;
|
|
23
23
|
const REPLY_FLAG = 0x8000;
|
|
24
24
|
/** Milliseconds from the Unix epoch to 2000-01-01T00:00:00Z, the protocol's date epoch. */
|
|
25
25
|
export const DATE_EPOCH_MS = Date.UTC(2000, 0, 1);
|