@chrischall/warapp-mcp 0.5.0 → 0.7.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.
Files changed (125) hide show
  1. package/.claude-plugin/marketplace.json +3 -3
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/README.md +133 -8
  4. package/dist/analysis/accept-surrender.js +20 -2
  5. package/dist/analysis/calibrate.js +1 -0
  6. package/dist/analysis/card-support.js +177 -17
  7. package/dist/analysis/card-threats.js +126 -14
  8. package/dist/analysis/chat-advice.js +182 -0
  9. package/dist/analysis/chat-blocks.js +106 -0
  10. package/dist/analysis/chat-intent.js +559 -0
  11. package/dist/analysis/chat-read.js +159 -0
  12. package/dist/analysis/decision-replay.js +279 -0
  13. package/dist/analysis/decision-truth.js +146 -0
  14. package/dist/analysis/finished-game.js +62 -3
  15. package/dist/analysis/game-lessons.js +15 -10
  16. package/dist/analysis/hold-diff.js +3 -1
  17. package/dist/analysis/income-trend.js +38 -0
  18. package/dist/analysis/intel.js +75 -0
  19. package/dist/analysis/opens.js +64 -0
  20. package/dist/analysis/opponent-profile.js +121 -10
  21. package/dist/analysis/opponents.js +246 -20
  22. package/dist/analysis/outlook.js +360 -15
  23. package/dist/analysis/picks.js +91 -12
  24. package/dist/analysis/plan/after-leftover.js +4 -1
  25. package/dist/analysis/plan/bonus-attempts.js +105 -0
  26. package/dist/analysis/plan/capture-instead.js +116 -0
  27. package/dist/analysis/plan/captures.js +49 -7
  28. package/dist/analysis/plan/conceded-out.js +13 -2
  29. package/dist/analysis/plan/estimates.js +203 -30
  30. package/dist/analysis/plan/guard-off.js +2 -1
  31. package/dist/analysis/plan/holds.js +110 -9
  32. package/dist/analysis/plan/jabs.js +113 -0
  33. package/dist/analysis/plan/leftover.js +393 -8
  34. package/dist/analysis/plan/orders.js +76 -4
  35. package/dist/analysis/plan/relations.js +135 -2
  36. package/dist/analysis/plan/report.js +69 -3
  37. package/dist/analysis/plan/second-sizing.js +133 -0
  38. package/dist/analysis/plan/shared.js +279 -27
  39. package/dist/analysis/plan/siege.js +303 -0
  40. package/dist/analysis/plan/stand-still.js +9 -5
  41. package/dist/analysis/plan/state.js +8 -0
  42. package/dist/analysis/plan/stockpile.js +104 -0
  43. package/dist/analysis/plan/strike.js +39 -7
  44. package/dist/analysis/plan/targets.js +256 -110
  45. package/dist/analysis/plan/threats.js +148 -10
  46. package/dist/analysis/plan/transfers.js +57 -6
  47. package/dist/analysis/plan/two-move.js +70 -0
  48. package/dist/analysis/plan/vacated.js +124 -2
  49. package/dist/analysis/planner.js +527 -49
  50. package/dist/analysis/profile.js +13 -2
  51. package/dist/analysis/since-last.js +18 -5
  52. package/dist/analysis/stress.js +8 -2
  53. package/dist/board.js +36 -2
  54. package/dist/bonus-attempt-store.js +55 -0
  55. package/dist/build-id.js +106 -0
  56. package/dist/bundle.js +54138 -41059
  57. package/dist/cards.js +7 -5
  58. package/dist/chat-automation.js +22 -0
  59. package/dist/chat.js +35 -1
  60. package/dist/client.js +14 -0
  61. package/dist/commerce.js +111 -0
  62. package/dist/decision-log.js +1093 -0
  63. package/dist/finished-store.js +5 -1
  64. package/dist/index.js +9 -1
  65. package/dist/lessons-store.js +322 -21
  66. package/dist/live.js +43 -0
  67. package/dist/move-order.js +64 -3
  68. package/dist/normalize.js +17 -0
  69. package/dist/open-games.js +36 -16
  70. package/dist/outlook-log.js +42 -1
  71. package/dist/profile-store.js +12 -2
  72. package/dist/protocol/methods.js +62 -5
  73. package/dist/protocol/rpc.js +8 -0
  74. package/dist/relations-store.js +38 -4
  75. package/dist/review-export.js +198 -0
  76. package/dist/siege-store.js +49 -0
  77. package/dist/state-bundle.js +584 -0
  78. package/dist/state-cli.js +71 -0
  79. package/dist/strategy/notes.js +56 -0
  80. package/dist/team-cards.js +25 -0
  81. package/dist/tools/accept-surrender.js +23 -9
  82. package/dist/tools/award.js +20 -2
  83. package/dist/tools/card-advice.js +93 -28
  84. package/dist/tools/card-plays.js +2 -2
  85. package/dist/tools/card-support-advice.js +37 -7
  86. package/dist/tools/chat-advice.js +330 -0
  87. package/dist/tools/chat-inbox.js +19 -4
  88. package/dist/tools/chat.js +106 -17
  89. package/dist/tools/check-plan.js +68 -12
  90. package/dist/tools/commerce-deploy.js +33 -0
  91. package/dist/tools/common.js +31 -0
  92. package/dist/tools/decision-capture.js +459 -0
  93. package/dist/tools/end-of-game.js +151 -21
  94. package/dist/tools/game-kind.js +92 -0
  95. package/dist/tools/how-lost.js +7 -2
  96. package/dist/tools/index.js +10 -0
  97. package/dist/tools/join-game.js +10 -4
  98. package/dist/tools/live-context.js +6 -0
  99. package/dist/tools/live.js +10 -1
  100. package/dist/tools/map-curves.js +73 -0
  101. package/dist/tools/notifications.js +4 -3
  102. package/dist/tools/opponents.js +2 -0
  103. package/dist/tools/past-games.js +74 -8
  104. package/dist/tools/picks.js +61 -10
  105. package/dist/tools/profile-hook.js +62 -3
  106. package/dist/tools/profile-opponents.js +4 -0
  107. package/dist/tools/push.js +2 -2
  108. package/dist/tools/relations.js +139 -0
  109. package/dist/tools/scout.js +16 -2
  110. package/dist/tools/state.js +232 -0
  111. package/dist/tools/strategy.js +3 -3
  112. package/dist/tools/stress-opponents.js +7 -2
  113. package/dist/tools/surrender-pending.js +10 -1
  114. package/dist/tools/surrender.js +18 -3
  115. package/dist/tools/survival.js +11 -3
  116. package/dist/tools/team-brief.js +2 -2
  117. package/dist/tools/team.js +12 -3
  118. package/dist/tools/turn.js +643 -76
  119. package/dist/tools/where.js +3 -1
  120. package/dist/version.js +1 -1
  121. package/manifest.json +32 -3
  122. package/mint.yaml +37 -4
  123. package/package.json +4 -4
  124. package/server.json +20 -2
  125. package/skills/warapp-mcp/SKILL.md +73 -17
@@ -11,6 +11,7 @@ import { boardIncome, incomeRules, trackGame, trackOpponents } from '../analysis
11
11
  import { agreementChange } from '../analysis/commitments.js';
12
12
  import { playerRecord, recordDelta, recordEntryFor } from '../analysis/player-record.js';
13
13
  import { AGREEMENT_STATUSES, agreementState, breachWatch, MAX_NOTICE_TURNS, newAgreement, OPENING_STATUSES, partyRefusal, scopeRefusal, tacitTruces, TERMINAL_STATUSES, transitionAgreement, TRUCE_OUTGROW_RATIO, trust, truceEndgame, } from '../analysis/relations.js';
14
+ import { AVOID_REASONS, emptyIntel, INCOME_STALE_TURNS, intelIsEmpty } from '../analysis/intel.js';
14
15
  import { boardStateFromLive } from '../live.js';
15
16
  import { entryKey, legacyEntryKey, playerRecordEnabled, playerRecordState, readPlayerRecord, updatePlayerRecord } from '../player-record-store.js';
16
17
  import { emptyLedger, nextAgreementId, nextCommitmentId, readLedger, readLedgerForWrite, withLedgerLock, writeLedger } from '../relations-store.js';
@@ -25,9 +26,13 @@ import { mapOf } from './map.js';
25
26
  import { recordProfile } from './profile-hook.js';
26
27
  import { resolveBonus, resolvePlayer, resolveTerritory } from './resolve.js';
27
28
  import { boardHistory, plannerSettings } from './turn.js';
29
+ import { captureObservation } from './decision-capture.js';
28
30
  import { resolveTeamsFor } from './team-source.js';
29
31
  const VIEWS = ['compact', 'full'];
30
32
  const MAX_SCOPE_ITEMS = 200;
33
+ /** #386: what warapp_record_intel writes, and where. */
34
+ export const INTEL_NOTE = "Written only to the server's data directory (the game's agreement ledger: ids, turns and reason codes, no name or " +
35
+ 'message); nothing was sent to war.app or to any player. warapp_plan_turn and warapp_check_plan apply it by default.';
31
36
  /** What the results say about the board-derived parts. */
32
37
  export const RELATIONS_NOTE = 'Flags come from your own board history (the boards warapp_plan_turn, warapp_track_opponents and this tool ' +
33
38
  'cached, with the orders warapp_submit_turn sent): a fog reveal is never an event, and an event the fog leaves ' +
@@ -369,6 +374,7 @@ export function registerRelationsTools(server, ctx, opts = {}) {
369
374
  live = true;
370
375
  if (ctx.dataDir) {
371
376
  await writeBoardCache(ctx.dataDir, game.id, me.id, turn, board);
377
+ await captureObservation(ctx, game.id, me.id, [{ turn, board, source: 'live' }]);
372
378
  await writeGameRecord(ctx.dataDir, game);
373
379
  await recordProfile(ctx.dataDir, env, game, me, boards, teamsKnown);
374
380
  }
@@ -608,4 +614,137 @@ export function registerRelationsTools(server, ctx, opts = {}) {
608
614
  written: LEDGER_NOTE,
609
615
  }));
610
616
  });
617
+ server.registerTool('warapp_record_intel', {
618
+ title: 'Record avoid targets and stated incomes for a war.app game',
619
+ _meta: mintMeta('change', ['remember not to attack', 'they said their income', 'promised them a territory', 'forget the intel']),
620
+ description: untrustedDescription("Keep what diplomacy told you for a war.app (Warzone) game in this server's agreement ledger, so every " +
621
+ 'warapp_plan_turn and warapp_check_plan call applies it without being told again (another session or the ' +
622
+ 'hosted connector included): `avoid_territories` (territories never to attack — a neutral promised to ' +
623
+ '`promised_to`, say), `avoid_players` (players never to attack outside any truce, each with a `reason` code: ' +
624
+ `${AVOID_REASONS.join(', ')}) and \`known_income\` (a player's stated income, kept with the turn it was stated: ` +
625
+ '`stated_turn`, default this turn). Recording a territory, player or income again replaces its entry; `forget` ' +
626
+ 'removes entries. The plans apply them by default and report it as `intel`; an explicit `avoid_territories`, ' +
627
+ '`avoid_players` or `known_income` argument replaces the stored list of its kind for that call (an empty list ' +
628
+ `included), and a stored income more than ${INCOME_STALE_TURNS} turns old is not applied (the estimate stands, ` +
629
+ 'with a warning). Nothing is sent to war.app or to any player (no confirmation step), and the ledger keeps ids, ' +
630
+ 'turns and reason codes only: no name, no message. Refused for yourself as a player, and outside a game being played.'),
631
+ annotations: toolAnnotations({ title: 'Record war.app intel', readOnly: false, destructive: false, idempotent: true, openWorld: true }),
632
+ inputSchema: z.object({
633
+ game_id: gameIdArg,
634
+ player: playerArg,
635
+ avoid_territories: z.array(playerRef).max(MAX_SCOPE_ITEMS).optional().describe('Territories (names or ids) never to attack.'),
636
+ promised_to: playerRef.optional().describe('The player (name or id) `avoid_territories` were promised to, when one.'),
637
+ avoid_players: z
638
+ .array(z.object({ player: playerRef.describe('The player (name or GameFeed id).'), reason: z.enum(AVOID_REASONS).describe('Why.') }))
639
+ .max(50)
640
+ .optional()
641
+ .describe('Players never to attack outside any truce, each with a reason code.'),
642
+ known_income: z
643
+ .array(z.object({
644
+ player: playerRef.describe('The player (name or GameFeed id).'),
645
+ income: z.coerce.number().int().min(0).max(10_000).describe('The income it stated, per turn, card armies aside.'),
646
+ }))
647
+ .max(50)
648
+ .optional()
649
+ .describe("Players' stated incomes."),
650
+ stated_turn: z.coerce.number().int().min(0).optional().describe('The turn the incomes were stated (default this turn; never later).'),
651
+ forget: z
652
+ .object({
653
+ territories: z.array(playerRef).max(MAX_SCOPE_ITEMS).optional().describe('Territories to stop avoiding.'),
654
+ players: z.array(playerRef).max(50).optional().describe('Players to stop avoiding.'),
655
+ incomes: z.array(playerRef).max(50).optional().describe('Players whose stated income to drop.'),
656
+ })
657
+ .optional()
658
+ .describe('Entries to remove.'),
659
+ }),
660
+ }, async (args) => {
661
+ if (!ctx.dataDir) {
662
+ throw new McpToolError('This server has no data directory, so there is no ledger to record into: nothing was recorded.', {
663
+ hint: 'Set MCP_DATA_DIR, or run with a writable home directory.',
664
+ });
665
+ }
666
+ const dir = ctx.dataDir;
667
+ const refuse = (why, hint) => {
668
+ throw new McpToolError(`${why}: nothing was recorded.`, { hint });
669
+ };
670
+ const given = args.avoid_territories?.length || args.avoid_players?.length || args.known_income?.length ||
671
+ args.forget?.territories?.length || args.forget?.players?.length || args.forget?.incomes?.length;
672
+ if (!given)
673
+ refuse('Nothing to record', 'Give `avoid_territories`, `avoid_players`, `known_income` or `forget`.');
674
+ const feed = await ctx.client.getGame(args.game_id, { settings: true });
675
+ if (feed.state !== 'Playing' && feed.state !== 'DistributingTerritories')
676
+ refuse(`Game ${feed.id} is ${feed.state}: intel is recorded only while it is being played`, 'Record it once the game has started (picks included).');
677
+ const me = await resolveMe(ctx, feed.players, args.player);
678
+ const map = mapOf(feed);
679
+ const turn = Math.max(0, currentTurn(feed) ?? 0);
680
+ const other = (ref, what) => {
681
+ const p = resolvePlayer(feed.players, ref);
682
+ if (p.id === me.id)
683
+ refuse(`${what} must be another player, not yourself`, 'Name another player in the game.');
684
+ return p.id;
685
+ };
686
+ if (args.stated_turn !== undefined && args.stated_turn > turn)
687
+ refuse(`stated_turn ${args.stated_turn} is after this turn (${turn})`, 'Give the turn the income was stated, this one or earlier.');
688
+ const statedTurn = args.stated_turn ?? turn;
689
+ const promisedTo = args.promised_to !== undefined ? other(args.promised_to, '`promised_to`') : undefined;
690
+ const addT = (args.avoid_territories ?? []).map((t) => resolveTerritory(map, t).id);
691
+ const addP = (args.avoid_players ?? []).map((a) => ({ player: other(a.player, 'A player to avoid'), reason: a.reason }));
692
+ const addI = (args.known_income ?? []).map((k) => ({ player: other(k.player, 'A player whose income'), income: k.income }));
693
+ const dropT = new Set((args.forget?.territories ?? []).map((t) => resolveTerritory(map, t).id));
694
+ const dropP = new Set((args.forget?.players ?? []).map((p) => resolvePlayer(feed.players, p).id));
695
+ const dropI = new Set((args.forget?.incomes ?? []).map((p) => resolvePlayer(feed.players, p).id));
696
+ const intel = await withLedgerLock(dir, feed.id, me.id, async () => {
697
+ const read = await readLedgerForWrite(dir, feed.id, me.id);
698
+ if (read === 'unreadable') {
699
+ throw new McpToolError(`The ledger for game ${feed.id} exists but cannot be read: nothing was recorded, and the file was left as it is.`, {
700
+ hint: "Inspect or move aside the game's file under the server's data directory (relations/), then record again.",
701
+ });
702
+ }
703
+ const ledger = read ?? emptyLedger(feed.id, me.id);
704
+ const was = ledger.intel ?? emptyIntel();
705
+ const tNew = new Set(addT);
706
+ const pNew = new Set(addP.map((a) => a.player));
707
+ const iNew = new Set(addI.map((a) => a.player));
708
+ const next = {
709
+ avoidTerritories: [
710
+ ...was.avoidTerritories.filter((a) => !tNew.has(a.territory) && !dropT.has(a.territory)),
711
+ ...[...tNew].filter((t) => !dropT.has(t)).map((territory) => ({ territory, turn, ...(promisedTo !== undefined ? { promisedTo } : {}) })),
712
+ ],
713
+ avoidPlayers: [
714
+ ...was.avoidPlayers.filter((a) => !pNew.has(a.player) && !dropP.has(a.player)),
715
+ ...addP.filter((a) => !dropP.has(a.player)).map((a) => ({ player: a.player, turn, reason: a.reason })),
716
+ ],
717
+ incomes: [
718
+ ...was.incomes.filter((a) => !iNew.has(a.player) && !dropI.has(a.player)),
719
+ ...addI.filter((a) => !dropI.has(a.player)).map((a) => ({ player: a.player, income: a.income, turn: statedTurn })),
720
+ ],
721
+ };
722
+ const { intel: _old, ...rest } = ledger;
723
+ if (!(await writeLedger(dir, { ...rest, ...(intelIsEmpty(next) ? {} : { intel: next }) }))) {
724
+ throw new McpToolError(`The ledger for game ${feed.id} could not be written: nothing was recorded.`, {
725
+ hint: "Check that the server's data directory is writable.",
726
+ });
727
+ }
728
+ return next;
729
+ });
730
+ const name = namer(map);
731
+ const playerName = (id) => {
732
+ const p = feed.players.find((x) => x.id === id);
733
+ return { id, name: p ? untrustedText(p.name) : null };
734
+ };
735
+ return respond(undefined, ['compact'], () => ({
736
+ game: { id: feed.id, turn },
737
+ intel: {
738
+ avoidTerritories: intel.avoidTerritories.map((a) => ({
739
+ territory: name(a.territory),
740
+ turn: a.turn,
741
+ ...(a.promisedTo !== undefined ? { promisedTo: playerName(a.promisedTo) } : {}),
742
+ })),
743
+ avoidPlayers: intel.avoidPlayers.map((a) => ({ player: playerName(a.player), reason: a.reason, turn: a.turn })),
744
+ incomes: intel.incomes.map((a) => ({ player: playerName(a.player), income: a.income, statedTurn: a.turn })),
745
+ },
746
+ incomeStaleAfterTurns: INCOME_STALE_TURNS,
747
+ written: INTEL_NOTE,
748
+ }));
749
+ });
611
750
  }
@@ -9,6 +9,8 @@ import { gameIdArg, readAnnotations, respond, untrustedDescription } from './com
9
9
  import { lookupMeta } from './hints.js';
10
10
  import { metRead } from './profile-reads.js';
11
11
  import { resolvePlayer } from './resolve.js';
12
+ import { captureOpponentRead, turnOfGame } from './decision-capture.js';
13
+ import { decisionLogOwner, decisionLogPath } from '../decision-log.js';
12
14
  /**
13
15
  * The player's invite token (= GameFeed player id), looked up in a game or given raw, and the numeric
14
16
  * id the profile store keys it by (a raw token read as GameFeed ids are).
@@ -24,7 +26,7 @@ async function tokenOf(ctx, gameId, player) {
24
26
  }
25
27
  const game = await ctx.client.getGame(gameId, { map: false });
26
28
  const p = resolvePlayer(game.players, raw);
27
- return { token: p.feedId ?? String(p.id), id: p.id };
29
+ return { token: p.feedId ?? String(p.id), id: p.id, game };
28
30
  }
29
31
  async function page(ctx, url, what) {
30
32
  try {
@@ -60,7 +62,7 @@ export function registerScoutTool(server, ctx, opts = {}) {
60
62
  .describe('The player: a name (or part of one) in game_id, or their player id (GameFeed id / invite token).'),
61
63
  }),
62
64
  }, async ({ game_id, player }) => {
63
- const { token, id } = await tokenOf(ctx, game_id, player);
65
+ const { token, id, game } = await tokenOf(ctx, game_id, player);
64
66
  const [profileHtml, commonHtml] = await Promise.all([
65
67
  page(ctx, profileUrl(token), 'profile'),
66
68
  page(ctx, commonGamesUrl(token), 'common games'),
@@ -77,6 +79,18 @@ export function registerScoutTool(server, ctx, opts = {}) {
77
79
  const { name, ...stats } = profile;
78
80
  // Part D (docs/PLAN-PROFILES.md section 11): the cross-game read, when the record has the player.
79
81
  const met = await metRead(ctx.dataDir, env, id).catch(() => undefined);
82
+ // #437: with a game, what was read goes into its decision log (the log's own account; none: nothing kept).
83
+ if (game && ctx.dataDir) {
84
+ const owner = await decisionLogOwner(decisionLogPath(ctx.dataDir, game.id), game.id);
85
+ if (owner !== undefined && owner !== id && game.players.some((p) => p.id === owner)) {
86
+ await captureOpponentRead(ctx, game.id, owner, id, {
87
+ turn: turnOfGame(game),
88
+ level: stats.level,
89
+ ranked: stats.ranked,
90
+ bootRatePct: stats.bootRatePct,
91
+ });
92
+ }
93
+ }
80
94
  return respond(undefined, ['compact'], () => ({
81
95
  player: { id: token, name },
82
96
  profile: stats,
@@ -0,0 +1,232 @@
1
+ // Moving history into this server, and finishing the end-of-game backlog faster.
2
+ //
3
+ // warapp_upload_slots + warapp_import_state (registered only where mcp-host hands this server a blob
4
+ // store, i.e. hosted): a local install's history, written by `warapp-mcp export-state`
5
+ // (src/state-cli.ts, src/state-bundle.ts), comes in through the fleet's upload-slot pattern
6
+ // (@chrischall/mcp-utils/export: `mintUploadSlot` signs a PUT the caller curls the bundle to, and
7
+ // `resolveUploadSource` reads it back by its `blobKey`), since the bundle is far too big for one tool
8
+ // argument. The import is confirm-gated like every write here (`defineGatedWrite`): the preview shows
9
+ // the counts per store, the bundle's account against the signed-in one (another account is refused),
10
+ // and the salt on this server against the bundle's (a different one is refused unless `replace`, which
11
+ // moves this server's hashed stores aside into a backup, never deleting them). Each file's sha256 is
12
+ // checked against the manifest before anything is written. Neither the preview nor the result carries
13
+ // the salt or any file's contents. The upload is deleted once imported, and at once when it is no
14
+ // bundle (it can never import); a refusal that a retry may clear (the account, the salt) keeps it.
15
+ //
16
+ // warapp_backfill_history: the warapp_my_games sweep (src/tools/end-of-game.ts) at a bigger batch —
17
+ // up to 25 finished games not yet processed per call, each history read once, as the sweep reads it —
18
+ // with an optional wider window. Writes only this server's state; nothing goes to war.app.
19
+ import { backfillWinnerCurves } from './map-curves.js';
20
+ import { CONFIRM_INJECTION_RULE, McpToolError, toolAnnotations } from '@chrischall/mcp-utils';
21
+ import { mintUploadSlot, resolveUploadSource } from '@chrischall/mcp-utils/export';
22
+ import { z } from 'zod';
23
+ import { MAX_FINISHED_RECORDS } from '../finished-store.js';
24
+ import { profileEnabled } from '../profile-store.js';
25
+ import { applyImport, decodeBundle, MAX_BUNDLE_BYTES, planImport, StateBundleError, } from '../state-bundle.js';
26
+ import { respond } from './common.js';
27
+ import { sweepFinished, sweepWindow } from './end-of-game.js';
28
+ import { mintMeta } from './hints.js';
29
+ import { requireApprovedAccount, writeAccount } from './live-context.js';
30
+ import { BRIDGE_NOTE } from './live.js';
31
+ import { fetchMyGames, finishedGamesOf } from './my-games.js';
32
+ import { accountUnknown, defineGatedWrite, refuse } from './write-kit.js';
33
+ const SLOT_TOOL = 'warapp_upload_slots';
34
+ /** Finished games warapp_backfill_history processes per call: the default and the most. */
35
+ export const BACKFILL_DEFAULT = 10;
36
+ export const BACKFILL_MAX = 25;
37
+ export function registerStateTools(server, ctx, deps = {}) {
38
+ const env = deps.env ?? process.env;
39
+ const store = deps.store ?? undefined;
40
+ if (store)
41
+ registerImportTools(server, ctx, store);
42
+ registerBackfillTool(server, ctx, env);
43
+ }
44
+ function registerImportTools(server, ctx, store) {
45
+ server.registerTool(SLOT_TOOL, {
46
+ title: 'Get an upload URL for a warapp-mcp state bundle',
47
+ _meta: mintMeta('other', ['upload my warapp history', 'move local warapp state']),
48
+ description: 'Get a signed upload URL for a warapp-mcp state bundle (the file `warapp-mcp export-state` writes on a ' +
49
+ 'local install), so warapp_import_state can read it on this hosted server. PUT the file to `uploadUrl` with ' +
50
+ 'exactly its Content-Type (the returned `curl` does it), then call warapp_import_state with the `blobKey`. ' +
51
+ 'Changes nothing; the URL is a short-lived credential to write that one file, so share it with no one, and ' +
52
+ 'the upload is deleted once imported.',
53
+ annotations: toolAnnotations({ title: 'Upload URL for a state bundle', readOnly: true, destructive: false, idempotent: false, openWorld: true }),
54
+ inputSchema: z.object({
55
+ filename: z
56
+ .string()
57
+ .optional()
58
+ .describe('The bundle file name (default "warapp-state.json.gz"); one plain name, no path.'),
59
+ }),
60
+ }, async ({ filename }) => {
61
+ const slot = mintUploadSlot(store, { filename: filename ?? 'warapp-state.json.gz', mimeType: 'application/octet-stream' });
62
+ return respond(undefined, ['compact'], () => ({
63
+ slot,
64
+ maxBytes: MAX_BUNDLE_BYTES,
65
+ next: "Replace the curl's `<path to …>` with the bundle's path and run it, then call warapp_import_state with " +
66
+ 'blob_key set to `blobKey`: it previews first and imports only once you confirm.',
67
+ }));
68
+ });
69
+ defineGatedWrite(server, {
70
+ title: 'Import a warapp-mcp state bundle into this server',
71
+ _meta: mintMeta('change', ['import my warapp history', 'move local warapp state to hosted']),
72
+ }, {
73
+ name: 'warapp_import_state',
74
+ description: "Import a local install's warapp-mcp history (the bundle `warapp-mcp export-state` writes, uploaded with " +
75
+ 'warapp_upload_slots) into this server: the salt behind its hashed keys, the deal record and ledgers, the ' +
76
+ 'opponent profiles, lessons, map records and end-of-game records, and the per-game files of games still in ' +
77
+ "play. The preview shows the files per store, the bundle's account against the signed-in one (another " +
78
+ "account is refused) and whether this server already has a salt: a different one is refused unless " +
79
+ "`replace: true`, which moves this server's hashed stores (profiles, relations, finished, lessons, " +
80
+ 'maps-record) into a dated backup folder (never deleted), since entries under two salts would count twice. ' +
81
+ "Each file's sha256 is checked against the bundle's manifest first; files are written atomically, 0600. " +
82
+ 'Without `replace` a file already here that differs is kept. Writes only this server\'s state, never ' +
83
+ `war.app; never shows the salt or any file's contents. ${CONFIRM_INJECTION_RULE}`,
84
+ annotations: toolAnnotations({
85
+ title: 'Import a warapp-mcp state bundle',
86
+ readOnly: false,
87
+ destructive: false,
88
+ idempotent: true,
89
+ openWorld: true,
90
+ }),
91
+ inputSchema: z.object({
92
+ blob_key: z.string().describe('The `blobKey` from warapp_upload_slots, after PUTting the bundle to its URL.'),
93
+ replace: z
94
+ .boolean()
95
+ .optional()
96
+ .describe("Take the bundle's salt over a different one here: this server's hashed stores, and every file the " +
97
+ 'bundle replaces, are moved into state-backups/<time>/ first (default false).'),
98
+ }),
99
+ async plan({ blob_key, replace }) {
100
+ const dir = ctx.dataDir;
101
+ if (!dir)
102
+ refuse('This server has no data directory, so there is nowhere to import into; nothing was imported.', 'Nothing to do here.');
103
+ const source = await resolveUploadSource({ blobKey: blob_key }, { maxBytes: MAX_BUNDLE_BYTES, store, hosted: true, names: { blobKey: 'blob_key', inline: 'blob_key', path: 'blob_key', slotTool: SLOT_TOOL } });
104
+ let bundle;
105
+ try {
106
+ bundle = decodeBundle(source.bytes);
107
+ }
108
+ catch (e) {
109
+ // It can never import: drop the upload now rather than leave it to the store's retention.
110
+ await source.release();
111
+ if (e instanceof StateBundleError)
112
+ refuse(e.message, 'Export the bundle again with `warapp-mcp export-state` and upload the new file.');
113
+ throw e;
114
+ }
115
+ const me = await ctx.myInviteToken({ fresh: true }).catch(() => undefined);
116
+ if (me === undefined)
117
+ throw accountUnknown(ctx, 'nothing was imported');
118
+ const p = await planImport(dir, bundle, me);
119
+ if (!p.accountMatches) {
120
+ refuse(`The bundle is for war.app account ${p.accountId}, but account ${me} is signed in here, so nothing was imported.`, 'Sign in to war.app as the account the bundle was exported from, or export the right account (`--account`).');
121
+ }
122
+ const conflictSalt = p.salt === 'different' || p.salt === 'malformed';
123
+ if (conflictSalt && !replace) {
124
+ refuse(`This server already has a ${p.salt} salt, so its hashed history cannot be merged with the bundle's ` +
125
+ `(${p.totals.files} files); nothing was imported.`, "Call again with replace: true to move this server's hashed stores (profiles, relations, finished, lessons, " +
126
+ "maps-record) into a dated backup folder, never deleted, and take the bundle's.");
127
+ }
128
+ return {
129
+ gate: {
130
+ action: 'warapp.import_state',
131
+ summary: `Import a state bundle of ${p.totals.files} files for war.app account ${p.accountId} into this server`,
132
+ account: writeAccount(me),
133
+ target: source.sha256,
134
+ payload: { action: 'import-state', sha256: source.sha256, replace: replace === true, salt: p.salt },
135
+ willSend: { files: p.totals.files, bytes: p.totals.bytes },
136
+ preview: {
137
+ warning: "This writes this server's own state only (nothing goes to war.app or to any player)." +
138
+ (replace && conflictSalt
139
+ ? " replace: this server's hashed stores move into state-backups/<time>/ (kept, not deleted) and the bundle's salt is taken."
140
+ : '') +
141
+ (p.conflicts && !replace ? ` ${p.conflicts} file(s) here differ from the bundle's and are kept.` : '') +
142
+ (p.conflicts && replace ? ` ${p.conflicts} file(s) here that differ are moved into the backup and replaced.` : ''),
143
+ account: `war.app account ${me}`,
144
+ bundleAccount: p.accountId,
145
+ accountMatches: p.accountMatches,
146
+ bundleCreatedAt: p.createdAt,
147
+ saltOnServer: p.salt,
148
+ stores: p.stores,
149
+ totals: p.totals,
150
+ conflicts: p.conflicts,
151
+ sha256: source.sha256,
152
+ },
153
+ },
154
+ state: { me, replace: replace === true, bundle, source },
155
+ };
156
+ },
157
+ async execute({ me, replace, bundle, source }) {
158
+ await requireApprovedAccount(ctx, writeAccount(me));
159
+ let r;
160
+ try {
161
+ r = await applyImport(ctx.dataDir, bundle, { signedIn: me, replace });
162
+ }
163
+ catch (e) {
164
+ if (e instanceof StateBundleError)
165
+ throw new McpToolError(e.message, { kind: 'unknown' });
166
+ throw new McpToolError(`The import stopped part way (${e.code ?? 'write failed'}); import the same bundle again to finish it.`, {
167
+ kind: 'unknown',
168
+ });
169
+ }
170
+ const released = await source.release();
171
+ return {
172
+ status: 'imported',
173
+ outcome: 'confirmed',
174
+ ...r,
175
+ blobDeleted: released.deleted === true,
176
+ note: 'Imported. The bundle held the salt behind your hashed history: delete the local file too. Finished ' +
177
+ 'games not yet processed here get their pass from warapp_backfill_history.',
178
+ };
179
+ },
180
+ });
181
+ }
182
+ function registerBackfillTool(server, ctx, env) {
183
+ server.registerTool('warapp_backfill_history', {
184
+ title: 'Process more finished war.app games at once',
185
+ _meta: mintMeta('change', ['backfill my war.app history', 'process finished games', 'catch up past games']),
186
+ description: 'Give the end-of-game pass to up to `limit` (default 10, at most 25) of your finished war.app games not yet ' +
187
+ 'processed, newest first: each game\'s history is read ONCE from GameFeed (never again, whatever comes of ' +
188
+ 'it) and kept name-free for the opponent profiles, map records and lessons — what warapp_my_games does two ' +
189
+ 'games per call. `window` widens how many of your newest finished games are considered (default 250, at ' +
190
+ `most ${MAX_FINISHED_RECORDS}). Reports what it processed and how many remain; safe to call again until ` +
191
+ '`remaining` is 0. It also gives map records kept before the winners\' income curves were those curves, from the ' +
192
+ 'histories already kept (`winnerCurves`, no request). Writes only this server\'s state and never writes to war.app. ' +
193
+ BRIDGE_NOTE,
194
+ annotations: toolAnnotations({ title: 'Backfill finished war.app games', readOnly: false, destructive: false, idempotent: true, openWorld: true }),
195
+ inputSchema: z.object({
196
+ limit: z.number().int().min(1).max(BACKFILL_MAX).optional().describe(`Games to process this call (default ${BACKFILL_DEFAULT}, max ${BACKFILL_MAX}).`),
197
+ window: z
198
+ .number()
199
+ .int()
200
+ .min(1)
201
+ .max(MAX_FINISHED_RECORDS)
202
+ .optional()
203
+ .describe(`How many of your newest finished games to consider (default ${sweepWindow()}, max ${MAX_FINISHED_RECORDS}).`),
204
+ }),
205
+ }, async ({ limit, window }) => {
206
+ if (!ctx.dataDir)
207
+ refuse('This server has no data directory, so no history can be kept.', 'Nothing to do here.');
208
+ if (!profileEnabled(env))
209
+ refuse('The end-of-game pass is off (WARAPP_PLAYER_PROFILE=off), so nothing was read.', 'Turn profiling on to backfill.');
210
+ const { me, games } = await fetchMyGames(ctx);
211
+ const token = await ctx.myInviteToken().catch(() => undefined);
212
+ if (token === undefined)
213
+ throw accountUnknown(ctx, 'nothing was read');
214
+ const ids = finishedGamesOf(games, me);
215
+ const size = Math.min(window ?? sweepWindow(), MAX_FINISHED_RECORDS);
216
+ const r = await sweepFinished({ client: ctx.client, dataDir: ctx.dataDir, env }, token, ids, {
217
+ limit: limit ?? BACKFILL_DEFAULT,
218
+ window: size,
219
+ });
220
+ // #419: entries kept before the winners' curves were, given them from the kept histories (no request).
221
+ const winnerCurves = await backfillWinnerCurves(ctx.dataDir);
222
+ return respond(undefined, ['compact'], () => ({
223
+ winnerCurves,
224
+ processed: r.processed,
225
+ processedCount: r.processed.length,
226
+ remaining: r.pending,
227
+ finishedGames: ids.length,
228
+ window: size,
229
+ ...(ids.length > size ? { outsideWindow: ids.length - size } : {}),
230
+ }));
231
+ });
232
+ }
@@ -12,7 +12,7 @@ import { cardClock } from '../strategy/card-clock.js';
12
12
  import { cardRules } from '../cards.js';
13
13
  import { gameIdArg, graphOf, readAnnotations, respond, untrustedDescription, viewArg, WARAPP_UNTRUSTED_NOTE } from './common.js';
14
14
  import { lookupMeta } from './hints.js';
15
- import { DEFAULT_TERRITORY_LIMIT, PICK_PHASE_STATE, pickSettings } from './picks.js';
15
+ import { PICK_PHASE_STATE, pickSettings, pickTerritoryLimit } from './picks.js';
16
16
  import { mapOf } from './map.js';
17
17
  import { currentTurn } from './turn.js';
18
18
  import { FROZEN_TAB_HINT, loadLiveGame } from './live-context.js';
@@ -57,7 +57,6 @@ const mapView = (map, n, full) => ({
57
57
  function gameMapNotes(game, map) {
58
58
  const picking = game.state === PICK_PHASE_STATE;
59
59
  const playing = game.players.filter((p) => (p.state ?? 'Playing') === 'Playing').length;
60
- const limit = game.settings?.territoryLimit;
61
60
  const board = game.standing?.territories ?? [];
62
61
  const pickable = board.filter((t) => t.owner.kind === 'available').map((t) => t.territoryId);
63
62
  const neutralArmies = new Map(board.flatMap((t) => (t.owner.kind === 'neutral' && t.armies !== null ? [[t.territoryId, t.armies]] : [])));
@@ -69,7 +68,8 @@ function gameMapNotes(game, map) {
69
68
  ? {
70
69
  opening: {
71
70
  players: Math.max(2, playing || game.players.length),
72
- territoryLimit: limit && limit > 0 ? limit : DEFAULT_TERRITORY_LIMIT,
71
+ // #428: the limit set, else the full-distribution share, else the default.
72
+ territoryLimit: pickTerritoryLimit(game.settings, game.players.length, pickable.length).limit,
73
73
  pickable,
74
74
  ...(neutralArmies.size ? { neutralArmies } : {}),
75
75
  },
@@ -6,6 +6,7 @@ import { neutralizeSeats, seatEndRules, staticSeats } from '../analysis/static-s
6
6
  import { carriesTeam } from '../teams.js';
7
7
  import { opponentReinforcement } from './card-advice.js';
8
8
  import { boardCardsInEffect } from './card-effects.js';
9
+ import { commerceDeployOf } from './commerce-deploy.js';
9
10
  export function stressOpponents(input) {
10
11
  const { graph, map, game, me, seen, turn, settings, hand, info } = input;
11
12
  // #270: a player out of the game whose seat no AI plays deploys and attacks nothing: its
@@ -18,7 +19,9 @@ export function stressOpponents(input) {
18
19
  : undefined;
19
20
  // #253: what the army cap leaves me and what I earn before the cut.
20
21
  const incomeOnBoard = incomeDetail(graph, board, me.id, game.settings);
21
- const income = incomeOnBoard.income;
22
+ // #332: in a commerce game, the armies my gold buys (as warapp_plan_turn and warapp_submit_turn have it).
23
+ const commerce = commerceDeployOf(game, me, info, incomeOnBoard.income);
24
+ const income = commerce ? commerce.armies : incomeOnBoard.income;
22
25
  const earnedIncome = incomeOnBoard.cap ? incomeOnBoard.cap.uncapped : income;
23
26
  // PLAN-TEAMS D3: the cards in effect the decoder is sure of.
24
27
  const effect = boardCardsInEffect(game, me, turn, info);
@@ -47,11 +50,13 @@ export function stressOpponents(input) {
47
50
  symmetricStart: symmetricStart(game.settings),
48
51
  ...(unevenStart(game.settings) ? { unevenStart: unevenStart(game.settings) } : {}),
49
52
  ...(input.opening ? { opening: input.opening } : {}),
53
+ ...(input.mapPace ? { mapPace: input.mapPace } : {}),
50
54
  ...(game.settings?.fog !== undefined ? { fog: game.settings.fog } : {}),
51
55
  ...(opponentReinforcement(game.settings, hand) ? { reinforcement: opponentReinforcement(game.settings, hand) } : {}),
52
56
  },
53
57
  turn,
54
58
  ...(effect.sanctionsOnOthers.length ? { sanctions: effect.sanctionsOnOthers } : {}),
59
+ ...(input.known?.length && input.enemyDeploy === undefined ? { known: input.known } : {}),
55
60
  });
56
61
  const myTeam = carriesTeam(me.team) ? me.team : undefined;
57
62
  const teamOf = new Map(game.players.map((p) => [p.id, p.team]));
@@ -79,5 +84,5 @@ export function stressOpponents(input) {
79
84
  // (two at least; enemy_deploy is a what-if, not the game's standing).
80
85
  const rivals = opponents.filter((o) => inView.has(o.id));
81
86
  const leader = teams.size === 0 && rivals.length >= 2 && rivals.every((o) => earnedIncome > estimateOf(o.id));
82
- return { board, seats, tracks, incomeOnBoard, income, earnedIncome, effect, estimates, estimateOf, friend, opponents, teams, inView, leader };
87
+ return { board, seats, tracks, incomeOnBoard, income, earnedIncome, effect, estimates, estimateOf, friend, opponents, teams, inView, leader, commerce };
83
88
  }
@@ -8,6 +8,7 @@ import { inGameOf } from '../live.js';
8
8
  import { Method, writeGameRefreshParams } from '../protocol/methods.js';
9
9
  import { pendingSurrenders, readGameDetailsSeats } from '../surrender-pending.js';
10
10
  import { untrustedText } from './common.js';
11
+ import { captureGameEvent, turnOfGame } from './decision-capture.js';
11
12
  /** Where the read comes from, for a result's note. */
12
13
  export const SURRENDER_PENDING_NOTE = "Read from the game details (the web client's GameRefresh), UNVERIFIED live: a list is what the details showed " +
13
14
  '(empty: no surrender pending); null means they could not be read, not that none is pending. A lobby, a finished ' +
@@ -62,7 +63,15 @@ export async function readPendingSurrenders(ctx, game, me, read = (id) => readDe
62
63
  if (id !== undefined)
63
64
  byInGame.set(id, p);
64
65
  }
65
- return pendingSurrenders(seats, inGameOf(me), (id) => byInGame.get(id)?.id ?? null).map((p) => {
66
+ const pending = pendingSurrenders(seats, inGameOf(me), (id) => byInGame.get(id)?.id ?? null);
67
+ // #437: each pending surrender seen goes into the decision log once (by GameFeed id; one without is not kept).
68
+ for (const p of pending) {
69
+ if (p.player === null)
70
+ continue;
71
+ const detail = p.owedByMe === true ? 'owed' : p.owedByMe === false ? 'not-owed' : 'unknown';
72
+ await captureGameEvent(ctx, game.id, me.id, { turn: turnOfGame(game), kind: 'surrender-pending', player: p.player, detail }, { create: true });
73
+ }
74
+ return pending.map((p) => {
66
75
  const player = byInGame.get(p.inGameId);
67
76
  return { ...p, name: player ? untrustedText(player.name) : null };
68
77
  });
@@ -14,6 +14,7 @@ import { gameIdArg, shownAccount, UNTRUSTED_PREVIEW_NOTE, untrustedText } from '
14
14
  import { noBrowserNote } from './session.js';
15
15
  import { mintMeta } from './hints.js';
16
16
  import { requireApprovedAccount, writeAccount } from './live-context.js';
17
+ import { captureGameEvent, mySurrenderDetail, turnOfGame } from './decision-capture.js';
17
18
  import { defineGatedWrite, mySeat, refuse, requireMe, requirePlaying, sendAndVerify, worded } from './write-kit.js';
18
19
  const PLAYING = 'Playing';
19
20
  const SURRENDERED = 'SurrenderAccepted';
@@ -126,6 +127,8 @@ export function registerSurrenderTool(server, ctx) {
126
127
  ? {
127
128
  turn: log.latest.turn,
128
129
  state: log.latest.state,
130
+ // #454: the income lean beside an even state (additive).
131
+ ...(log.latest.lean ? { lean: log.latest.lean } : {}),
129
132
  heldTurns: log.latest.heldTurns,
130
133
  basis: log.latest.basis,
131
134
  // #304: the incomes compared and each opponent's frontier read; `thin` when the state rested on little.
@@ -175,13 +178,20 @@ export function registerSurrenderTool(server, ctx) {
175
178
  untrusted: UNTRUSTED_PREVIEW_NOTE,
176
179
  },
177
180
  },
178
- state: { gameId, name, me, undo: takeBack, acceptanceNeeded: acceptance.needed },
181
+ state: {
182
+ gameId,
183
+ name,
184
+ me,
185
+ undo: takeBack,
186
+ acceptanceNeeded: acceptance.needed,
187
+ logged: { turn: turnOfGame(game), detail: (({ status: _s, ...rest }) => rest)(mySurrenderDetail('pending', log)) },
188
+ },
179
189
  };
180
190
  },
181
- async execute({ gameId, name, me, undo, acceptanceNeeded }) {
191
+ async execute({ gameId, name, me, undo, acceptanceNeeded, logged }) {
182
192
  await requireApprovedAccount(ctx, writeAccount(me));
183
193
  const game = { id: gameId, name };
184
- return sendAndVerify({
194
+ const result = await sendAndVerify({
185
195
  send: async () => {
186
196
  await ctx.rpc.call('Surrender', Method.Surrender, (w) => writeSurrenderParams(w, { gameId, surrender: !undo }));
187
197
  },
@@ -242,6 +252,11 @@ export function registerSurrenderTool(server, ctx) {
242
252
  };
243
253
  },
244
254
  });
255
+ // #437: my surrender, once war.app shows it taken (accepted, or pending the others), into the decision log.
256
+ if (!undo && logged && (result.status === 'surrendered' || result.status === 'pending')) {
257
+ await captureGameEvent(ctx, gameId, me, { turn: logged.turn, kind: 'my-surrender', detail: { status: result.status, ...logged.detail } }, { create: true });
258
+ }
259
+ return result;
245
260
  },
246
261
  });
247
262
  }
@@ -144,14 +144,21 @@ export function safeHeadroom(input) {
144
144
  return [];
145
145
  }
146
146
  }
147
+ /** #306: a border whose fall costs more than the tile: a held bonus, bonus income behind it, or a breach's income. */
148
+ export const protectsSomething = (r) => r.bonuses.length > 0 || r.behindIncome > 0 || r.breach.income > 0;
147
149
  /**
148
- * The headroom table as the tools show it: names beside ids, each row with whether it is below my income.
150
+ * The headroom table as the tools show it: names beside ids, each row with whether it is below my income
151
+ * and (#306, given `estimateOf`) below its opponent's own deploy estimate (`belowOpponentEstimate`, with
152
+ * `opponentEstimate`; absent when that opponent has none) — for a leader my income flags every row. The
153
+ * compact view (#306) lists the rows that protect something first (`protectsSomething`), each part weakest
154
+ * first, so bare 1-army tiles at headroom 0 no longer crowd out the borders that decide the turn.
149
155
  * `mayBeTeammate` (the teams unknown, `resolveTeams`' `known: false`): every row says its opponent may be a teammate.
150
156
  */
151
- export function headroomView(rows, map, myIncome, full, mayBeTeammate = false) {
157
+ export function headroomView(rows, map, myIncome, full, mayBeTeammate = false, estimateOf) {
152
158
  const name = namer(map);
153
159
  const bonusName = new Map(map.bonuses.map((b) => [b.id, b.name]));
154
- return rows.slice(0, full ? rows.length : HEADROOM_COMPACT).map((r) => ({
160
+ const shown = full ? rows : [...rows.filter(protectsSomething), ...rows.filter((r) => !protectsSomething(r))].slice(0, HEADROOM_COMPACT);
161
+ return shown.map((r) => ({
155
162
  territory: name(r.territory),
156
163
  armies: r.armies,
157
164
  deploy: r.deploy,
@@ -159,6 +166,7 @@ export function headroomView(rows, map, myIncome, full, mayBeTeammate = false) {
159
166
  from: name(r.from),
160
167
  ...(r.firstMover ? { needsFirstMove: r.firstMover === 'me' ? 'you' : 'opponent' } : {}),
161
168
  belowMyIncome: r.deploy !== null && r.deploy < myIncome,
169
+ ...((est) => (est === undefined ? {} : { opponentEstimate: est, belowOpponentEstimate: r.deploy !== null && r.deploy < est }))(estimateOf?.(r.opponent)),
162
170
  bonuses: r.bonuses.map((b) => ({ id: b.id, name: bonusName.get(b.id) ?? String(b.id), value: b.value })),
163
171
  behind: r.behind.map(name),
164
172
  behindIncome: r.behindIncome,
@@ -6,8 +6,8 @@
6
6
  //
7
7
  // Read-only: it plans as warapp_plan_turn would (livePlanSetup, award not read and not written) and writes
8
8
  // nothing — no board cache, no award, no outlook. UNVERIFIED live: the teams (V1, via resolveTeams), the
9
- // teammates' entered orders (V5) and picks (V5/V6), what a move onto a teammate does (V7) and how the team hand
10
- // is keyed (V8). The pure parts are src/analysis/team-brief.ts.
9
+ // teammates' entered orders (V5) and picks (V5/V6) and what a move onto a teammate does (V7); how the team hand
10
+ // is keyed is verified (V8, #310). The pure parts are src/analysis/team-brief.ts.
11
11
  import { McpToolError } from '@chrischall/mcp-utils';
12
12
  import { z } from 'zod';
13
13
  import { readAward } from '../analysis/award.js';