@chrischall/warapp-mcp 0.22.1 → 0.23.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/.claude-plugin/marketplace.json +3 -3
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/README.md +49 -3
  4. package/dist/analysis/coalition.js +3 -2
  5. package/dist/analysis/outlook.js +42 -2
  6. package/dist/analysis/plan/captures.js +3 -1
  7. package/dist/analysis/plan/relations.js +1 -1
  8. package/dist/analysis/plan/report.js +2 -2
  9. package/dist/analysis/plan/targets.js +48 -12
  10. package/dist/analysis/plan/threats.js +55 -2
  11. package/dist/analysis/planner.js +2 -1
  12. package/dist/analysis/relations.js +40 -7
  13. package/dist/bundle.js +10250 -3744
  14. package/dist/chat.js +93 -3
  15. package/dist/clans.js +308 -0
  16. package/dist/forums.js +70 -0
  17. package/dist/friends.js +83 -0
  18. package/dist/index.js +1 -1
  19. package/dist/invite-code.js +46 -0
  20. package/dist/join-color.js +23 -13
  21. package/dist/ladders.js +360 -0
  22. package/dist/mail.js +295 -0
  23. package/dist/my-games.js +18 -1
  24. package/dist/notifications.js +22 -4
  25. package/dist/open-games.js +29 -2
  26. package/dist/outlook-log.js +1 -0
  27. package/dist/protocol/bundle.js +4 -4
  28. package/dist/protocol/codec.js +1 -1
  29. package/dist/protocol/methods.js +690 -8
  30. package/dist/protocol/rpc.js +28 -3
  31. package/dist/push/socketio.js +2 -2
  32. package/dist/quickmatch.js +264 -0
  33. package/dist/surrender-pending.js +62 -2
  34. package/dist/templates.js +451 -0
  35. package/dist/tools/boot-player.js +165 -0
  36. package/dist/tools/calibration-harness.js +8 -1
  37. package/dist/tools/calibration.js +14 -2
  38. package/dist/tools/chat.js +19 -0
  39. package/dist/tools/clan-writes.js +208 -0
  40. package/dist/tools/clans.js +181 -0
  41. package/dist/tools/end-game-common.js +49 -0
  42. package/dist/tools/forums.js +535 -0
  43. package/dist/tools/friends.js +50 -0
  44. package/dist/tools/game.js +21 -3
  45. package/dist/tools/index.js +39 -0
  46. package/dist/tools/invites.js +347 -0
  47. package/dist/tools/join-game.js +4 -4
  48. package/dist/tools/ladders.js +418 -0
  49. package/dist/tools/leave-game.js +85 -27
  50. package/dist/tools/live-context.js +2 -2
  51. package/dist/tools/mail.js +600 -0
  52. package/dist/tools/my-games.js +50 -6
  53. package/dist/tools/notifications.js +12 -3
  54. package/dist/tools/nudge.js +178 -0
  55. package/dist/tools/quickmatch.js +481 -0
  56. package/dist/tools/react.js +177 -0
  57. package/dist/tools/relations.js +3 -2
  58. package/dist/tools/session.js +6 -2
  59. package/dist/tools/team-surrender.js +206 -0
  60. package/dist/tools/templates.js +342 -0
  61. package/dist/tools/tournaments.js +495 -0
  62. package/dist/tools/turn.js +4 -1
  63. package/dist/tools/vote-to-end.js +142 -0
  64. package/dist/tools/write-kit.js +22 -1
  65. package/dist/tournaments.js +321 -0
  66. package/dist/trend.js +1 -0
  67. package/dist/version.js +1 -1
  68. package/manifest.json +190 -2
  69. package/mint.yaml +3 -4
  70. package/package.json +1 -1
  71. package/server.json +2 -2
  72. package/skills/warapp-mcp/SKILL.md +39 -6
@@ -8,6 +8,7 @@
8
8
  // the filters as a constant 0, and the one other list it asks takes `count` 100), so a wider
9
9
  // count is how the whole list is read. UNVERIFIED live: that `All` lists lobbies and finished
10
10
  // games together and that the server honours a count above 10.
11
+ import { mailSignal } from '../mail.js';
11
12
  import { untrustedEnvelope } from '@chrischall/mcp-utils';
12
13
  import { z } from 'zod';
13
14
  import { BOOT_NOTE, briefGameLine, gameStateName, isFinished, readMyGames, summarizeMyGames } from '../my-games.js';
@@ -19,15 +20,18 @@ import { holdsSeat, playerStateName } from '../player-states.js';
19
20
  import { sweepFinished } from './end-of-game.js';
20
21
  import { accountUnknown } from './write-kit.js';
21
22
  import { rememberPace } from './pace.js';
22
- import { pendingSurrenders, surrenderOwed } from '../surrender-pending.js';
23
+ import { endVotesOf, pendingSurrenders, surrenderOwed, teamSurrenderOf } from '../surrender-pending.js';
23
24
  import { readDetailsSeats, SURRENDER_PENDING_NOTE, surrenderMayBePending } from './surrender-pending.js';
24
25
  const VIEWS = ['compact', 'brief'];
25
26
  /** The note line a brief answer ends with when the list may be partial (a `-- ` line is never a game). */
26
27
  const partialLine = (listed) => `-- the list may be partial: war.app returned ${listed} games, the most this server asks for`;
27
- function briefResult(games, partialOf) {
28
+ function briefResult(games, partialOf, mailFlagged) {
28
29
  const lines = games.length ? games.map(briefGameLine) : ['-- none'];
29
30
  if (partialOf !== undefined)
30
31
  lines.push(partialLine(partialOf));
32
+ // #629: war.app's unread-mail check, from the list's own replies.
33
+ if (mailFlagged === true)
34
+ lines.push('-- war.app flags unread mail or notifications: read them with warapp_mail_inbox');
31
35
  return { content: [{ type: 'text', text: JSON.stringify(untrustedEnvelope(lines, { note: WARAPP_UNTRUSTED_NOTE })) }] };
32
36
  }
33
37
  /**
@@ -93,6 +97,7 @@ const SURRENDER_READ_BATCH = 4;
93
97
  */
94
98
  export async function myGamesSurrenders(ctx, games, me) {
95
99
  const byGame = new Map();
100
+ const votes = new Map();
96
101
  const eligible = games.filter((g) => {
97
102
  const mine = g.players.find((p) => p.id === me);
98
103
  return surrenderMayBePending(gameStateName(g.stateCode), mine ? playerStateName(mine.stateCode) : undefined);
@@ -110,9 +115,37 @@ export async function myGamesSurrenders(ctx, games, me) {
110
115
  byGame.set(g.id, s
111
116
  ? pendingSurrenders(s, me).map((p) => ({ ...p, name: names.has(p.inGameId) ? untrustedText(names.get(p.inGameId)) : null }))
112
117
  : null);
118
+ if (s)
119
+ votes.set(g.id, gameVotes(s, me, names));
113
120
  });
114
121
  }
115
- return { byGame, skipped: eligible.length - read.length };
122
+ return { byGame, votes, skipped: eligible.length - read.length };
123
+ }
124
+ /** The note `warapp_my_games` carries beside `teamSurrender` / `endVotes`. */
125
+ export const VOTES_NOTE = 'teamSurrender (a team surrender proposed on your team: who proposed, voted yes or no, and who has still to vote; ' +
126
+ 'owedByMe true: your vote is awaited — warapp_team_surrender) and endVotes (who voted to end the game and who still ' +
127
+ 'plays without voting — warapp_vote_to_end) are read from the same game details, UNVERIFIED live; absent when there is ' +
128
+ 'none or they did not read.';
129
+ /** {@link GameVotes} from one game's details seats (`me`: my in-game id; `names`: the list's names by in-game id). */
130
+ export function gameVotes(seats, me, names) {
131
+ const view = (ids) => ids.map((id) => ({ inGameId: id, name: names.has(id) ? untrustedText(names.get(id)) : null }));
132
+ const out = {};
133
+ const ts = teamSurrenderOf(seats, me);
134
+ if (ts?.available && ts.open) {
135
+ out.teamSurrender = {
136
+ open: true,
137
+ proposer: view([ts.proposer])[0],
138
+ yes: view(ts.yes),
139
+ no: view(ts.no),
140
+ waiting: view(ts.waiting),
141
+ myVote: ts.myVote,
142
+ owedByMe: ts.myVote === 'none',
143
+ };
144
+ }
145
+ const ev = endVotesOf(seats, me);
146
+ if (ev?.voted.length)
147
+ out.endVotes = { voted: view(ev.voted), notYet: view(ev.notYet), myVote: ev.myVote };
148
+ return out;
116
149
  }
117
150
  /**
118
151
  * The finished games of `me` (in-game id) in a GetMyGames list where its seat was held, newest first: the
@@ -140,10 +173,16 @@ export function registerMyGamesTool(server, ctx, deps = {}) {
140
173
  'the game details (unverified live; null when not read or unreadable, never "none"; empty without a read ' +
141
174
  'for a lobby, a finished game or a game you no longer play in, where none can wait on you); the top-level ' +
142
175
  'surrenderPending counts the games where one waits on you, and those games come first too. ' +
176
+ 'From the same details read, a team surrender proposed on your team is `teamSurrender` (proposer, yes, no, still to vote, ' +
177
+ '`owedByMe`; act with warapp_team_surrender) and a game someone voted to end carries `endVotes` (voted, not yet, `myVote`; ' +
178
+ 'warapp_vote_to_end); both unverified live and absent when there is none. ' +
143
179
  'Each game also carries unreadChat, from the game list itself (no extra request): whether war.app shows unread ' +
144
180
  'chat per channel (public, team, private, group) and toMe (unread private chat is addressed to you) — flags, ' +
145
181
  'not counts; null when they did not read. Games with unread private chat come right after the ones waiting on ' +
146
182
  'you, and the top-level unreadPrivateGames counts them; read them with warapp_chat_inbox. ' +
183
+ 'The top-level `mail` is war.app\'s unread-mail check from the list\'s own replies (`flagged`: either of its two flags ' +
184
+ 'set — war.app does not name which is mail and which the notifications badge; null when no reply carried it; ' +
185
+ 'unverified live); read mail with warapp_mail_inbox. ' +
147
186
  'A game being played or picked with your seat playing carries `boot` (pace, from the game list: its boot ' +
148
187
  'time, your banked time, their sum, and while it waits on you `leftMinutes`, the sum less how long your turn has ' +
149
188
  'run, with `soon` under 6 hours in a multi-day game; unverified live). #504: an opening turn (`opening`: picks, or ' +
@@ -181,13 +220,16 @@ export function registerMyGamesTool(server, ctx, deps = {}) {
181
220
  const endOfGame = sweep && (sweep.processed.length || sweep.pending) ? { endOfGame: sweep } : {};
182
221
  const kept = include_finished ? raw : raw.filter((g) => !isFinished(g));
183
222
  const summary = summarizeMyGames(kept, me);
223
+ // #629: the unread-mail check war.app piggybacked on the list's replies (no extra request).
224
+ const mail = mailSignal(ctx.rpc.unreadMail);
184
225
  if (view === 'brief')
185
- return briefResult(summary, partial ? raw.length : undefined);
226
+ return briefResult(summary, partial ? raw.length : undefined, mail.flagged);
186
227
  const finishedLeftOut = raw.length - kept.length;
187
228
  // #317: the surrenders pending in each game (the game details; null: not read or unreadable, never "none";
188
229
  // #327: [] without a read where none can wait on me).
189
- const { byGame, skipped } = await myGamesSurrenders(ctx, kept, me);
190
- const withSurrenders = summary.map((g) => ({ ...g, surrenderPending: byGame.get(g.id) ?? null }));
230
+ const { byGame, votes, skipped } = await myGamesSurrenders(ctx, kept, me);
231
+ // #630/#631: an open team-surrender vote and the votes to end ride on the same details read.
232
+ const withSurrenders = summary.map((g) => ({ ...g, surrenderPending: byGame.get(g.id) ?? null, ...(votes.get(g.id) ?? {}) }));
191
233
  // A game waiting on my acceptance waits on me too: it goes first with the turns waiting on me.
192
234
  const first = (g) => g.waitingOnYou || surrenderOwed(g.surrenderPending);
193
235
  const games = [...withSurrenders.filter(first), ...withSurrenders.filter((g) => !first(g))];
@@ -197,6 +239,7 @@ export function registerMyGamesTool(server, ctx, deps = {}) {
197
239
  count: games.length,
198
240
  waitingOnYou: games.filter((g) => g.waitingOnYou).length,
199
241
  unreadPrivateGames: games.filter((g) => g.unreadChat?.private === true).length,
242
+ mail,
200
243
  // Pace: games close to a boot (boot time plus bank, less my turn so far): under six hours in a multi-day game,
201
244
  // and (#504) an opening or real-time turn from a quarter of its time left.
202
245
  ...(games.some((g) => g.boot)
@@ -210,6 +253,7 @@ export function registerMyGamesTool(server, ctx, deps = {}) {
210
253
  surrenderNote: SURRENDER_PENDING_NOTE +
211
254
  (unread ? ` The details of ${unread} game(s) could not be read.` : '') +
212
255
  (skipped ? ` ${skipped} more game(s) were not read (at most ${MAX_SURRENDER_READS} per call).` : ''),
256
+ ...(games.some((g) => 'teamSurrender' in g || 'endVotes' in g) ? { votesNote: VOTES_NOTE } : {}),
213
257
  listed: raw.length,
214
258
  ...(finishedLeftOut ? { finishedLeftOut } : {}),
215
259
  complete: !partial,
@@ -1,6 +1,6 @@
1
1
  // warapp_get_notifications, warapp_dismiss_notification and warapp_delete_notification (#311): war.app's
2
- // in-app notifications (the client's "In App Notifications" screen), read with GetInAppNotifications (323),
3
- // marked read with AcknowledgeInAppNotifications (325) and deleted with DeleteInAppNotification (324, the
2
+ // in-app notifications (the client's "In App Notifications" screen), read with GetInAppNotifications (325 in protocol 244),
3
+ // marked read with AcknowledgeInAppNotifications (327) and deleted with DeleteInAppNotification (326, the
4
4
  // client's Delete button). All read from the client bundle, UNVERIFIED live (docs/WEB-PROTOCOL.md,
5
5
  // Notifications and read marks).
6
6
  //
@@ -15,6 +15,7 @@
15
15
  // already gone. Neither sends anything to any player. Automated chat stays off (D2): neither is a send.
16
16
  import { CONFIRM_INJECTION_RULE, toolAnnotations } from '@chrischall/mcp-utils';
17
17
  import { z } from 'zod';
18
+ import { mailSignal } from '../mail.js';
18
19
  import { classifyNotification, readInAppNotifications } from '../notifications.js';
19
20
  import { hasUnfoldedProfile, profileEnabled } from '../profile-store.js';
20
21
  import { END_OF_GAME_PER_CALL, endOfGame, finishedAccount, needsEndOfGame } from './end-of-game.js';
@@ -138,6 +139,10 @@ async function foldEndedGames(ctx, env, games) {
138
139
  }
139
140
  return out;
140
141
  }
142
+ /** #629: the mail threads the unread notifications link to, once each, in the list's order. */
143
+ const unreadThreadsOf = (notes) => [
144
+ ...new Set(notes.filter((n) => n.unread && n.discussionId !== undefined).map((n) => n.discussionId)),
145
+ ];
141
146
  /** The games the game-ended notifications name, once each, in the list's order. */
142
147
  const endedGames = (notes) => [
143
148
  ...new Set(notes.filter((n) => n.kind === 'game-ended' && n.gameId !== null).map((n) => n.gameId)),
@@ -159,7 +164,9 @@ export function registerNotificationTools(server, ctx, opts = {}) {
159
164
  description: untrustedDescription("Your war.app (Warzone) in-app notifications (the client's notifications screen, war.app's " +
160
165
  'GetInAppNotifications), 30 per page, by id only: each with `id` (what warapp_dismiss_notification takes), ' +
161
166
  '`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` (plus `localTime` when WARAPP_TIMEZONE is set) and `unread`. The title and body are never shown (they carry other ' +
167
+ 'game its link names, or null), `time` (plus `localTime` when WARAPP_TIMEZONE is set), `unread`, and `discussionId` when ' +
168
+ 'its link names a mail thread. `mail` is the unread-mail signal: war.app\'s unread-mail check from this reply (`flagged`) ' +
169
+ 'and `unreadThreads`, the mail threads unread notifications link to (read them with warapp_get_mail_thread). The title and body are never shown (they carry other ' +
163
170
  "players' names). " +
164
171
  '`total` is how many notifications war.app holds; pass `next` back as `start` for the next page; ' +
165
172
  '`unread_only` keeps the unread ones of the page. A game-ended notification runs the end-of-game pass on ' +
@@ -191,6 +198,8 @@ export function registerNotificationTools(server, ctx, opts = {}) {
191
198
  ...(next !== undefined ? { next } : {}),
192
199
  ...(profilesFolded.length ? { profilesFolded } : {}),
193
200
  ...(passes.processed.length || passes.pending ? { endOfGame: passes } : {}),
201
+ // #629: unread mail — war.app's unread-mail check from this reply, and the mail threads unread notifications link to.
202
+ mail: { ...mailSignal(ctx.rpc.unreadMail), unreadThreads: unreadThreadsOf(all) },
194
203
  unverified: NOTIFICATIONS_UNVERIFIED,
195
204
  }));
196
205
  });
@@ -0,0 +1,178 @@
1
+ // warapp_nudge_player (#641): remind a player who is holding a game up with the web client's Nudge
2
+ // (method 8), gated on the user's confirmation. Read from the client bundle, UNVERIFIED live
3
+ // (docs/WEB-PROTOCOL.md, Nudging a player).
4
+ //
5
+ // The game is read from GameFeed first, and the nudge is refused where the data says it is not owed: a
6
+ // finished game or a lobby, a seat of mine that no longer plays, the player myself, an AI seat, a seat
7
+ // no longer playing (not its turn), and a player GameFeed shows as already committed. war.app decides the
8
+ // rest (one nudge a day per player, and none early in a turn): its refusals are worded here, 227
9
+ // (`Blocklisted`) as that player having blocked me.
10
+ //
11
+ // A nudge carries one of war.app's four preset reminders, never our text; it still reaches another player,
12
+ // so an automated one (the owner did not ask for it) is refused unless WARAPP_CHAT_AUTOMATION is on, as
13
+ // warapp_send_chat's is. The reply carries no result and nothing about a nudge can be read back, so a
14
+ // nudge war.app accepted is `accepted`; no answer is `unknown`, never resent.
15
+ import { CONFIRM_INJECTION_RULE, McpToolError, toolAnnotations } from '@chrischall/mcp-utils';
16
+ import { z } from 'zod';
17
+ import { AUTOMATED_CHAT_OFF, chatAutomationMode } from '../chat-automation.js';
18
+ import { parseGameId } from '../client.js';
19
+ import { inGameOf } from '../live.js';
20
+ import { Method, NUDGE_MESSAGES, writeNudgeParams } from '../protocol/methods.js';
21
+ import { gameIdArg, shownAccount, UNTRUSTED_PREVIEW_NOTE, untrustedText } from './common.js';
22
+ import { mintMeta } from './hints.js';
23
+ import { requireApprovedAccount, writeAccount } from './live-context.js';
24
+ import { BRIDGE_NOTE } from './live.js';
25
+ import { resolvePlayer } from './resolve.js';
26
+ import { defineGatedWrite, mySeat, refuse, requireMe, requirePlaying, sendAndVerify, worded } from './write-kit.js';
27
+ const PLAYING = 'Playing';
28
+ const FINISHED = 'Finished';
29
+ const DISTRIBUTING = 'DistributingTerritories';
30
+ /** The Nudge refusals the client handles, worded here from the codes' meaning (read from the bundle, UNVERIFIED live). */
31
+ const NUDGE_ERRORS = {
32
+ 227: 'That player has blocked you (war.app\'s Blocklisted), so war.app refused the nudge: nothing reached them.',
33
+ 30: 'war.app would not nudge that player now (CannotNudge): they were nudged recently, the turn just advanced, or it is too early in the turn to nudge.',
34
+ 4: 'war.app says the game has ended, so there is no one to nudge.',
35
+ 7: 'You or that player are no longer in the game, so war.app refused the nudge.',
36
+ 77: 'war.app refused the reminder chosen (InvalidNudgeMessage).',
37
+ };
38
+ /** What each preset reminder says, in our words (war.app sends its own text). */
39
+ const MEANS = {
40
+ turn: 'tells them it is their turn',
41
+ hurry: 'a blunt hurry-up',
42
+ polite: 'asks politely that they take their turn when they can',
43
+ holding_up: 'says they are holding the game up',
44
+ };
45
+ const MESSAGE_KEYS = Object.keys(NUDGE_MESSAGES);
46
+ /** The player to nudge in `game`, refused where the data says a nudge is not owed. */
47
+ function nudgeable(game, me, input) {
48
+ if (game.state === FINISHED)
49
+ refuse(`Game ${game.id} is over, so there is no one to nudge.`, 'Check warapp_get_game.');
50
+ if (game.state !== PLAYING && game.state !== DISTRIBUTING) {
51
+ refuse(`Game ${game.id} has not started (game state: ${game.state}), so it is no one's turn and there is no one to nudge.`, 'A lobby fills on its own; check warapp_get_game.');
52
+ }
53
+ const seat = mySeat(game, me);
54
+ requirePlaying(game, seat);
55
+ const target = resolvePlayer(game.players, input);
56
+ if (target.id === me)
57
+ refuse('That is you: you cannot nudge yourself (a nudge reminds another player), so nothing was sent.', 'Name the player holding the game up.');
58
+ const who = `${untrustedText(target.name)} (${target.id})`;
59
+ if (target.isAI || target.humanTurnedIntoAI) {
60
+ refuse(`${who} is played by an AI in game ${game.id}, which takes its own turn: nothing was sent.`, 'Check warapp_get_game.');
61
+ }
62
+ if (target.state !== PLAYING) {
63
+ refuse(`It is not their turn: ${who} is no longer playing game ${game.id} (state: ${target.state ?? 'unknown'}), so nothing was sent.`, 'Check warapp_get_game.');
64
+ }
65
+ if (target.hasCommittedOrders) {
66
+ refuse(`${who} has already committed this turn of game ${game.id}, so there is nothing to nudge them for.`, 'Check warapp_get_game for who has not committed.');
67
+ }
68
+ const inGameId = inGameOf(target);
69
+ if (inGameId === undefined)
70
+ refuse(`${who} has no in-game id war.app can be told, so nothing was sent.`, 'Check warapp_get_game.');
71
+ return { seat, target, inGameId };
72
+ }
73
+ export function registerNudgeTool(server, ctx) {
74
+ defineGatedWrite(server, {
75
+ title: 'Nudge a player holding up a war.app game',
76
+ _meta: mintMeta('send', ['nudge player', 'remind player to take turn', 'hurry up opponent']),
77
+ }, {
78
+ name: 'warapp_nudge_player',
79
+ description: "Nudge a player who is holding up a war.app (Warzone) game (war.app's Nudge): war.app sends them a reminder " +
80
+ 'notification with one of its four preset lines (`message`: `turn`, `hurry`, `polite` (default) or ' +
81
+ '`holding_up`); no text of ours is sent. Refuses a finished game or a lobby, a game you are not playing, yourself, ' +
82
+ 'an AI seat, a player no longer playing (it is not their turn) and a player GameFeed shows as already committed. ' +
83
+ 'war.app allows one nudge a day per player and none early in a turn, and refuses a player who has blocked you ' +
84
+ '(said plainly). Pass `automated: true` for a nudge the owner did not ask for: refused unless ' +
85
+ 'WARAPP_CHAT_AUTOMATION is on. Always as the signed-in war.app account; nothing about a nudge can be read back, so ' +
86
+ "a nudge war.app accepted is `nudged` (`accepted`), and no answer is `unknown` — never resend blindly. Read from " +
87
+ `war.app's client code, UNVERIFIED live. ${BRIDGE_NOTE} ${CONFIRM_INJECTION_RULE}`,
88
+ annotations: toolAnnotations({
89
+ title: 'Nudge a war.app player',
90
+ readOnly: false,
91
+ destructive: true,
92
+ idempotent: false,
93
+ openWorld: true,
94
+ }),
95
+ inputSchema: z.object({
96
+ game_id: gameIdArg,
97
+ player: z.union([z.string(), z.number()]).describe('The player to nudge: a name or GameFeed id from the game.'),
98
+ message: z
99
+ .enum(MESSAGE_KEYS)
100
+ .optional()
101
+ .describe("war.app's preset reminder: `turn` (it is your turn), `hurry` (a blunt hurry-up), `polite` (please take your " +
102
+ 'turn when you can; default) or `holding_up` (you are holding the game up).'),
103
+ automated: z
104
+ .boolean()
105
+ .optional()
106
+ .describe('true for a nudge the owner did not tell you to send. Refused unless WARAPP_CHAT_AUTOMATION is on; default false.'),
107
+ }),
108
+ async plan({ game_id, player, message, automated }) {
109
+ const auto = automated === true;
110
+ if (auto && (ctx.chatAutomation ?? chatAutomationMode()) !== 'on') {
111
+ throw new McpToolError(`Refused: ${AUTOMATED_CHAT_OFF}. Nothing was sent.`, {
112
+ hint: 'Tell the owner who is holding the game up and let them nudge; or the owner turns WARAPP_CHAT_AUTOMATION on.',
113
+ });
114
+ }
115
+ const gameId = parseGameId(game_id);
116
+ const me = await requireMe(ctx);
117
+ const game = await ctx.client.getGame(gameId, { map: false });
118
+ const { seat, target, inGameId } = nudgeable(game, me, player);
119
+ const chosen = message ?? 'polite';
120
+ const index = NUDGE_MESSAGES[chosen];
121
+ return {
122
+ gate: {
123
+ action: 'warapp.nudge_player',
124
+ // By id only: the names are other players' words and go, delimited, in labelled fields.
125
+ summary: `Nudge player ${target.id} in war.app game ${gameId} (${chosen} reminder)`,
126
+ account: writeAccount(me),
127
+ target: `${gameId}:${target.id}`,
128
+ payload: { method: 'Nudge', gameId, playerId: inGameId, message: index },
129
+ willSend: { game: gameId, player: target.id, inGameId, message: chosen },
130
+ preview: {
131
+ warning: `This sends player ${target.id} in game ${gameId} war.app's ${chosen} reminder: a notification only they see.`,
132
+ account: shownAccount(seat.name, me),
133
+ game: { id: gameId, name: game.name === undefined ? null : untrustedText(game.name), state: game.state },
134
+ player: { id: target.id, inGameId, name: untrustedText(target.name) },
135
+ message: { key: chosen, index, means: MEANS[chosen] },
136
+ note: 'war.app allows one nudge a day per player and none early in a turn; it refuses a player who has blocked you.',
137
+ ...(auto ? { automated: true, automatedNote: 'An automated nudge (WARAPP_CHAT_AUTOMATION is on): the owner did not ask for it.' } : {}),
138
+ untrusted: UNTRUSTED_PREVIEW_NOTE,
139
+ },
140
+ },
141
+ state: {
142
+ gameId,
143
+ name: game.name ?? `game ${gameId}`,
144
+ me,
145
+ player: { id: target.id, inGameId },
146
+ message: chosen,
147
+ automated: auto,
148
+ },
149
+ };
150
+ },
151
+ async execute({ gameId, name, me, player, message, automated }) {
152
+ await requireApprovedAccount(ctx, writeAccount(me));
153
+ const base = { game: { id: gameId, name }, player, message, ...(automated ? { automated: true } : {}) };
154
+ return sendAndVerify({
155
+ send: async () => {
156
+ await ctx.rpc.call('Nudge', Method.Nudge, (w) => writeNudgeParams(w, { playerId: player.inGameId, gameId, message: NUDGE_MESSAGES[message] }));
157
+ },
158
+ refused: worded(NUDGE_ERRORS),
159
+ unanswered: (failure) => ({
160
+ status: 'unknown',
161
+ outcome: 'unknown',
162
+ ...base,
163
+ warning: `war.app did not confirm the nudge (${failure}), so it may already have gone out. Do not nudge again today.`,
164
+ }),
165
+ // A nudge leaves nothing in game state to read back (war.app keeps when a player was last nudged
166
+ // in records this server does not read).
167
+ readBack: async () => undefined,
168
+ unreadable: (failure) => ({ status: 'unconfirmed', outcome: 'unconfirmed', ...base, warning: failure }),
169
+ classify: () => ({
170
+ status: 'nudged',
171
+ outcome: 'accepted',
172
+ ...base,
173
+ detail: 'war.app accepted the nudge: it sends the player its reminder. Nothing about it can be read back.',
174
+ }),
175
+ });
176
+ },
177
+ });
178
+ }