@chrischall/warapp-mcp 0.8.0 → 0.9.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/dist/bundle.js CHANGED
@@ -1814,12 +1814,12 @@ var require_checks = __commonJS({
1814
1814
  exports.$ZodCheckNumberFormat = core.$constructor("$ZodCheckNumberFormat", (inst, def) => {
1815
1815
  exports.$ZodCheck.init(inst, def);
1816
1816
  def.format = def.format || "float64";
1817
- const isInt16 = def.format?.includes("int");
1818
- const origin = isInt16 ? "int" : "number";
1817
+ const isInt17 = def.format?.includes("int");
1818
+ const origin = isInt17 ? "int" : "number";
1819
1819
  const [minimum, maximum] = util.NUMBER_FORMAT_RANGES[def.format];
1820
1820
  inst._zod.check = (payload) => {
1821
1821
  const input2 = payload.value;
1822
- if (isInt16) {
1822
+ if (isInt17) {
1823
1823
  if (!Number.isInteger(input2)) {
1824
1824
  payload.issues.push({
1825
1825
  expected: origin,
@@ -4607,14 +4607,14 @@ var require_schemas = __commonJS({
4607
4607
  function leafPattern2(schema) {
4608
4608
  const def = schema._zod.def;
4609
4609
  let pattern = def.pattern;
4610
- let isInt16 = !!def.format?.includes("int");
4610
+ let isInt17 = !!def.format?.includes("int");
4611
4611
  let minimum;
4612
4612
  let maximum;
4613
4613
  for (const ch of def.checks ?? []) {
4614
4614
  const d = ch._zod.def;
4615
4615
  if (d.pattern)
4616
4616
  pattern = d.pattern;
4617
- isInt16 || (isInt16 = !!d.format?.includes("int"));
4617
+ isInt17 || (isInt17 = !!d.format?.includes("int"));
4618
4618
  const lo = d.minimum ?? d.length;
4619
4619
  const hi = d.maximum ?? d.length;
4620
4620
  if (lo !== void 0 && (minimum === void 0 || lo > minimum))
@@ -4629,7 +4629,7 @@ var require_schemas = __commonJS({
4629
4629
  if (minimum !== void 0 || maximum !== void 0)
4630
4630
  return regexes.string({ minimum, maximum }).source;
4631
4631
  const own2 = schema._zod.pattern;
4632
- return (isInt16 && own2 === regexes.number ? regexes.integer : own2)?.source;
4632
+ return (isInt17 && own2 === regexes.number ? regexes.integer : own2)?.source;
4633
4633
  }
4634
4634
  function partPattern2(schema) {
4635
4635
  const def = schema._zod.def;
@@ -18897,8 +18897,8 @@ var require_json_schema_processors = __commonJS({
18897
18897
  exports.stringProcessor = stringProcessor2;
18898
18898
  var numberProcessor2 = (schema, ctx, _json, params) => {
18899
18899
  const json2 = _json;
18900
- const { minimum, maximum, multipleOf, exclusiveMaximum, exclusiveMinimum, isInt: isInt16 } = aggregateChecks2(schema);
18901
- json2.type = isInt16 ? "integer" : "number";
18900
+ const { minimum, maximum, multipleOf, exclusiveMaximum, exclusiveMinimum, isInt: isInt17 } = aggregateChecks2(schema);
18901
+ json2.type = isInt17 ? "integer" : "number";
18902
18902
  const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
18903
18903
  const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
18904
18904
  const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
@@ -20767,8 +20767,8 @@ var require_schemas2 = __commonJS({
20767
20767
  return Math.min(maximum ?? Number.POSITIVE_INFINITY, exclusiveMaximum ?? Number.POSITIVE_INFINITY);
20768
20768
  },
20769
20769
  isInt: (inst) => {
20770
- const { isInt: isInt16, multipleOf } = processors.aggregateChecks(inst);
20771
- return !!isInt16 || !!multipleOf?.some(Number.isSafeInteger);
20770
+ const { isInt: isInt17, multipleOf } = processors.aggregateChecks(inst);
20771
+ return !!isInt17 || !!multipleOf?.some(Number.isSafeInteger);
20772
20772
  },
20773
20773
  format: (inst) => processors.aggregateChecks(inst).format ?? null
20774
20774
  }, {
@@ -76700,12 +76700,12 @@ var $ZodCheckMultipleOf = /* @__PURE__ */ $constructor("$ZodCheckMultipleOf", (i
76700
76700
  var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat", (inst, def) => {
76701
76701
  $ZodCheck.init(inst, def);
76702
76702
  def.format = def.format || "float64";
76703
- const isInt16 = def.format?.includes("int");
76704
- const origin = isInt16 ? "int" : "number";
76703
+ const isInt17 = def.format?.includes("int");
76704
+ const origin = isInt17 ? "int" : "number";
76705
76705
  const [minimum, maximum] = NUMBER_FORMAT_RANGES[def.format];
76706
76706
  inst._zod.check = (payload) => {
76707
76707
  const input2 = payload.value;
76708
- if (isInt16) {
76708
+ if (isInt17) {
76709
76709
  if (!Number.isInteger(input2)) {
76710
76710
  payload.issues.push({
76711
76711
  expected: origin,
@@ -79368,14 +79368,14 @@ function handleReadonlyResult(payload) {
79368
79368
  function leafPattern(schema) {
79369
79369
  const def = schema._zod.def;
79370
79370
  let pattern = def.pattern;
79371
- let isInt16 = !!def.format?.includes("int");
79371
+ let isInt17 = !!def.format?.includes("int");
79372
79372
  let minimum;
79373
79373
  let maximum;
79374
79374
  for (const ch of def.checks ?? []) {
79375
79375
  const d = ch._zod.def;
79376
79376
  if (d.pattern)
79377
79377
  pattern = d.pattern;
79378
- isInt16 || (isInt16 = !!d.format?.includes("int"));
79378
+ isInt17 || (isInt17 = !!d.format?.includes("int"));
79379
79379
  const lo = d.minimum ?? d.length;
79380
79380
  const hi = d.maximum ?? d.length;
79381
79381
  if (lo !== void 0 && (minimum === void 0 || lo > minimum))
@@ -79390,7 +79390,7 @@ function leafPattern(schema) {
79390
79390
  if (minimum !== void 0 || maximum !== void 0)
79391
79391
  return string4({ minimum, maximum }).source;
79392
79392
  const own2 = schema._zod.pattern;
79393
- return (isInt16 && own2 === number4 ? integer : own2)?.source;
79393
+ return (isInt17 && own2 === number4 ? integer : own2)?.source;
79394
79394
  }
79395
79395
  function partPattern(schema) {
79396
79396
  const def = schema._zod.def;
@@ -90815,8 +90815,8 @@ var stringProcessor = (schema, ctx, _json, _params) => {
90815
90815
  };
90816
90816
  var numberProcessor = (schema, ctx, _json, params) => {
90817
90817
  const json2 = _json;
90818
- const { minimum, maximum, multipleOf, exclusiveMaximum, exclusiveMinimum, isInt: isInt16 } = aggregateChecks(schema);
90819
- json2.type = isInt16 ? "integer" : "number";
90818
+ const { minimum, maximum, multipleOf, exclusiveMaximum, exclusiveMinimum, isInt: isInt17 } = aggregateChecks(schema);
90819
+ json2.type = isInt17 ? "integer" : "number";
90820
90820
  const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
90821
90821
  const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
90822
90822
  const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
@@ -92345,8 +92345,8 @@ var ZodNumber = /* @__PURE__ */ $constructor(
92345
92345
  return Math.min(maximum ?? Number.POSITIVE_INFINITY, exclusiveMaximum ?? Number.POSITIVE_INFINITY);
92346
92346
  },
92347
92347
  isInt: (inst) => {
92348
- const { isInt: isInt16, multipleOf } = aggregateChecks(inst);
92349
- return !!isInt16 || !!multipleOf?.some(Number.isSafeInteger);
92348
+ const { isInt: isInt17, multipleOf } = aggregateChecks(inst);
92349
+ return !!isInt17 || !!multipleOf?.some(Number.isSafeInteger);
92350
92350
  },
92351
92351
  format: (inst) => aggregateChecks(inst).format ?? null
92352
92352
  }, {
@@ -99451,6 +99451,24 @@ function readActiveCards(info) {
99451
99451
  if (standing) walk(standing, 0);
99452
99452
  return out;
99453
99453
  }
99454
+ var GAME_TURN = /\.GameTurn$/;
99455
+ var REINFORCEMENT_PLAY = /\.GameOrderPlayCardReinforcement$/;
99456
+ function readTurnReinforcementPlays(info) {
99457
+ if (!isObj(info)) return void 0;
99458
+ const turn = fields(info).find((v) => isObj(v) && typeof v.$type === "string" && GAME_TURN.test(v.$type));
99459
+ if (!turn) return void 0;
99460
+ const own2 = fields(turn);
99461
+ const ints3 = own2.filter((v) => typeof v === "number" && Number.isInteger(v));
99462
+ const orders = own2.find((v) => Array.isArray(v));
99463
+ if (ints3.length !== 1 || !orders) return void 0;
99464
+ const players = [];
99465
+ for (const o of orders) {
99466
+ if (!isObj(o) || typeof o.$type !== "string" || !REINFORCEMENT_PLAY.test(o.$type)) continue;
99467
+ const player2 = fields(o).filter((v) => typeof v === "number" && Number.isInteger(v)).at(-1);
99468
+ if (player2 !== void 0) players.push(player2);
99469
+ }
99470
+ return { turn: ints3[0] + 1, players };
99471
+ }
99454
99472
 
99455
99473
  // src/strategy/card-clock.ts
99456
99474
  var isRec = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
@@ -101871,6 +101889,7 @@ function planEnemyEstimates(input2) {
101871
101889
  turn,
101872
101890
  fog: ctx.fog,
101873
101891
  reinforcement: ctx.reinforcement,
101892
+ ...ctx.reinforcementPlays ? { plays: ctx.reinforcementPlays } : {},
101874
101893
  ...previousBoard && input2.previousOrders ? { previousOrders: input2.previousOrders } : {}
101875
101894
  });
101876
101895
  const priced = applyKnown(
@@ -105211,13 +105230,16 @@ function borderThreats(pc, ps, input2, src, forces) {
105211
105230
  `Player ${p}'s tracked income of ${c.was} counts the Reinforcement card it played on turn ${c.turns.join(", ")}: ${c.income} without it (#427), so the card is counted once, on the clock, not carried as income.`
105212
105231
  );
105213
105232
  }
105233
+ const cardPlaysRead = input2.game?.reinforcementPlays !== void 0;
105234
+ const perCard = input2.game?.reinforcement?.turnsPerCard;
105235
+ const cardDue = (t) => perCard === null || perCard === void 0 ? "never (no further card comes)" : `turn ${t + Math.max(1, perCard)}`;
105214
105236
  if (e.card)
105215
105237
  warnings.push(
105216
- `Player ${p} may hold a Reinforcement card from turn ${e.card.due} (the card clock${e.cardPlayed !== null ? `; it last played one on turn ${e.cardPlayed}` : ""}): +${e.card.armies} added to its deploy, ~${e.estimate} in all, until a deployment above its income is seen; one card at most is counted, though more may be in hand after a long time due.`
105238
+ `Player ${p} may hold a Reinforcement card from turn ${e.card.due} (the card clock${e.cardPlayed !== null ? `; it last played one on turn ${e.cardPlayed}${e.cardSeen ? ", seen in the orders" : ""}` : ""}): +${e.card.armies} added to its deploy, ~${e.estimate} in all, until ${cardPlaysRead ? "a play is seen in the orders" : "a deployment above its income is seen"}; one card at most is counted, though more may be in hand after a long time due.`
105217
105239
  );
105218
105240
  else if (e.cardPlayed !== null)
105219
105241
  warnings.push(
105220
- e.source === "exact" ? `Player ${p}'s Reinforcement card is taken as played on turn ${e.cardPlayed} (a deployment above its exact income), so none is added until the next can be due; armies the board misread, or that moved into view out of a territory whose armies the fog hid, can look the same, so it may still hold one and the estimate errs low.` : `Player ${p}'s Reinforcement card is taken as played on turn ${e.cardPlayed} (a deployment of a card's armies over its visible income), so none is added until the next can be due; income the fog hides can look the same, so it may still hold one and the estimate errs low.`
105242
+ e.cardSeen ? `Player ${p} played a Reinforcement card on turn ${e.cardPlayed} (seen in that turn's orders: card plays are not fogged in this game), so none is added until the next can be due: ${cardDue(e.cardPlayed)}.` : e.source === "exact" ? `Player ${p}'s Reinforcement card is taken as played on turn ${e.cardPlayed} (a deployment above its exact income), so none is added until the next can be due; armies the board misread, or that moved into view out of a territory whose armies the fog hid, can look the same, so it may still hold one and the estimate errs low.` : `Player ${p}'s Reinforcement card is taken as played on turn ${e.cardPlayed} (a deployment of a card's armies over its visible income), so none is added until the next can be due; income the fog hides can look the same, so it may still hold one and the estimate errs low.`
105221
105243
  );
105222
105244
  const income = e.estimate - (e.card?.armies ?? 0);
105223
105245
  if (e.sanctioned) {
@@ -106052,8 +106074,10 @@ function closestBonus(pc, ps, input2, prev, hd) {
106052
106074
  }
106053
106075
  const turnNow = pc.game.turn ?? null;
106054
106076
  const base = Math.max(0, Math.floor(input2.settings?.baseIncome ?? DEFAULT_BASE_INCOME));
106077
+ let spreadNearest;
106055
106078
  if (turnNow !== null && turnNow >= 2 && turnNow <= SPREAD_LAST_TURN && !holdsBonus && mine3.length >= SPREAD_TERRITORIES && income <= base + SPREAD_INCOME_SLACK) {
106056
106079
  const nearest = committing ? byCloseness.find((p) => !p.focus) ?? byCloseness[0] : void 0;
106080
+ spreadNearest = nearest;
106057
106081
  ps.warnings.push(
106058
106082
  `${mine3.length} territories, ${noBonusText}: the captures are spread (income ${income}, base ${base}). ` + (nearest ? `Nearest bonus to complete: ${bonusName(nearest.bonusId)}, ${nearest.cost} armies to finish${fogNote(nearest)}${standingNote(nearest)}, ${turnsText(nearest)}${income > 0 ? ` at income ${income}` : ""} (rule 4f).` : "No bonus is worth completing from here.") + " Complete one before taking more territories outside it (#319)."
106059
106083
  );
@@ -106063,7 +106087,7 @@ function closestBonus(pc, ps, input2, prev, hd) {
106063
106087
  const take = toTake(survivors);
106064
106088
  return take !== null && take <= counter ? `${label3(t)} can be retaken after it breaks ${bonusName(bonusId)}: ${survivors} survivors need ${take} to take, against ~${counter} next turn.` : void 0;
106065
106089
  };
106066
- return { holdsBonus, neutralsInReach, committing, advancedLast, fromMine, depthOf, turnsOf, scoreRank, byCloseness, turnsText, retakeChecks, retakeWarning };
106090
+ return { holdsBonus, neutralsInReach, committing, advancedLast, fromMine, depthOf, turnsOf, scoreRank, byCloseness, turnsText, spreadNearest, retakeChecks, retakeWarning };
106067
106091
  }
106068
106092
 
106069
106093
  // src/analysis/plan/after-leftover.ts
@@ -106349,6 +106373,7 @@ function captureHelper(pc, ps, pass, book, threats, hd, tgt, prev) {
106349
106373
  const need2 = b ? Math.max(0, holdArmies(b.threat) - unitsAt(x)) : 0;
106350
106374
  return Math.max(need2 - (stayAt(x) - avail.get(x)), keepOf(x, t));
106351
106375
  };
106376
+ const barred = (x, t) => ps.bind !== void 0 && ps.bind.from.has(x) && !ps.bind.members.has(t);
106352
106377
  const strikes = /* @__PURE__ */ new Set();
106353
106378
  const r3Exempt = /* @__PURE__ */ new Set();
106354
106379
  const worstCase = /* @__PURE__ */ new Map();
@@ -106410,6 +106435,7 @@ function captureHelper(pc, ps, pass, book, threats, hd, tgt, prev) {
106410
106435
  const tg = targets.get(t);
106411
106436
  const spare = (x) => noSplit ? avail.get(x) : force ? avail.get(x) - Math.max(force.keep, coverOf(x)) : holdSource(x, t) ? avail.get(x) - holdKeep(x, t) : movableFor(x, t);
106412
106437
  if (force && orderOf(force.from)) return false;
106438
+ if (force && barred(force.from, t)) return false;
106413
106439
  const held = (x) => mustHold(x, t, Math.max(avail.get(x), tg.cost));
106414
106440
  if (force) {
106415
106441
  const h = held(force.from);
@@ -106419,7 +106445,7 @@ function captureHelper(pc, ps, pass, book, threats, hd, tgt, prev) {
106419
106445
  }
106420
106446
  }
106421
106447
  const open5 = (x) => (!locked.has(x) || !force && holdSource(x, t)) && (!conceded.has(x) || x === fromConceded || concededSource(x, t, tg.cost));
106422
- const usable = (x) => open5(x) && !held(x) && !(noSplit && coverOf(x) > 0);
106448
+ const usable = (x) => open5(x) && !held(x) && !(noSplit && coverOf(x) > 0) && !barred(x, t);
106423
106449
  const sources = force ? [force.from] : tg.sources.filter((x) => usable(x) && !orderOf(x)).sort((a, b) => avail.get(b) - avail.get(a) || a - b);
106424
106450
  const needAt = (x) => Math.max(0, tg.cost - spare(x));
106425
106451
  const src = local || leadSteps.has(t) ? sources.find((x) => needAt(x) <= spareAt(x)) ?? (leadSteps.has(t) ? [...sources].sort((a, b) => needAt(a) - needAt(b) || a - b)[0] : sources[0]) : sources[0];
@@ -106521,7 +106547,7 @@ function captureHelper(pc, ps, pass, book, threats, hd, tgt, prev) {
106521
106547
  const tg = targets.get(t);
106522
106548
  if (unitsAt(t) > 0) return null;
106523
106549
  const eligible = tg.sources.filter(
106524
- (x) => !locked.has(x) && !conceded.has(x) && !myCommanders.has(x) && avail.get(x) > 0 && !orderOf(x) && !(noSplit && coverOf(x) > 0) && !mustHold(x, t, avail.get(x))
106550
+ (x) => !locked.has(x) && !conceded.has(x) && !myCommanders.has(x) && !barred(x, t) && avail.get(x) > 0 && !orderOf(x) && !(noSplit && coverOf(x) > 0) && !mustHold(x, t, avail.get(x))
106525
106551
  ).sort((a, b) => avail.get(b) - avail.get(a) || a - b);
106526
106552
  const off = rates.offensiveKillRate;
106527
106553
  const def = rates.defensiveKillRate;
@@ -107058,6 +107084,34 @@ function bonusPasses(pc, ps, book, hd, tgt, prev) {
107058
107084
  return { snapshot, complete: complete2, unstaged, stage, stopped, stoppedLine, denied, outgrows, gateStop, tryExpand, advance: advance2 };
107059
107085
  }
107060
107086
 
107087
+ // src/analysis/plan/spread-bind.ts
107088
+ function spreadBind(pc, ps, tgt) {
107089
+ const p = tgt.spreadNearest;
107090
+ if (!p) return void 0;
107091
+ const { g, mine: mine3, mineSet, reserve, label: label3, bonusName, bonusTs } = pc;
107092
+ const steps = p.remaining.filter((t) => tgt.targets.has(t) && neighborsOf(g, t).some((x) => mineSet.has(x))).sort((a, b) => a - b);
107093
+ if (!steps.length) return void 0;
107094
+ const missing = new Set(p.remaining);
107095
+ const members2 = new Set(bonusTs.get(p.bonusId) ?? p.remaining);
107096
+ const beside = new Set(mine3.filter((x) => neighborsOf(g, x).some((t) => missing.has(t))));
107097
+ const open5 = () => steps.some((t) => !ps.captured.has(t));
107098
+ const line = `#319 binds the deploys (#416): until ${bonusName(p.bonusId)}'s reachable step${steps.length === 1 ? "" : "s"} (${steps.map(label3).join(", ")}) ${steps.length === 1 ? "is" : "are"} taken, plain expansion and advances into other bonuses spend no deploys and no armies on ${[...beside].sort((a, b) => a - b).map(label3).join(", ")}.`;
107099
+ const bound = (exempt, f) => {
107100
+ if (exempt || ps.bind || !open5()) return f();
107101
+ if (!ps.rationale.includes(line)) ps.rationale.push(line);
107102
+ const withheld = Math.max(0, ps.budget - reserve);
107103
+ ps.budget -= withheld;
107104
+ ps.bind = { from: beside, members: members2 };
107105
+ try {
107106
+ return f();
107107
+ } finally {
107108
+ ps.budget += withheld;
107109
+ ps.bind = void 0;
107110
+ }
107111
+ };
107112
+ return { bonusId: p.bonusId, open: open5, bound };
107113
+ }
107114
+
107061
107115
  // src/analysis/plan/completed.ts
107062
107116
  function completedMembers(pc, ps, threats, open5, stays) {
107063
107117
  const { g, mine: mine3, mineSet, completedBy, bonusTs, unitsAt, toTake } = pc;
@@ -111699,6 +111753,9 @@ function planPass(input2, pass) {
111699
111753
  const caps = capturesPhase(pc, ps, pass, book, threats, hd, tgt);
111700
111754
  const { strikes, worstCase, defendersAt, tryCapture, snapshot, complete: complete2, tryExpand, advance: advance2 } = caps;
111701
111755
  const stages = twoMoveStages(pc, tgt);
111756
+ const bind = spreadBind(pc, ps, tgt);
111757
+ const bound = (exempt, f) => bind ? bind.bound(exempt, f) : f();
111758
+ const otherBonus = (p) => p.focus || p.bonusId === bind?.bonusId;
111702
111759
  const { struck } = strikesPhase(pc, ps, book, threats, hd, tgt, caps);
111703
111760
  guardOffRaids(pc, ps, book, hd, tgt, threats, worstCase, input2.previousBoard);
111704
111761
  if (balanced) {
@@ -111802,10 +111859,10 @@ function planPass(input2, pass) {
111802
111859
  worthOf.set(p.bonusId, p.net === p.value ? `+${p.value}` : `+${p.value}, net +${p.net}`);
111803
111860
  if (p.completable)
111804
111861
  candidates2.push({ kind: "complete", score, cost: p.cost, id: p.bonusId, value: p.net, focus: p.focus, borders: p.borders, run: spend(() => complete2(p)) });
111805
- candidates2.push({ kind: "advance", score, cost: p.cost, id: p.bonusId, value: p.net, focus: p.focus, borders: p.borders, run: spend(() => advance2(p)) });
111862
+ candidates2.push({ kind: "advance", score, cost: p.cost, id: p.bonusId, value: p.net, focus: p.focus, borders: p.borders, run: spend(() => bound(otherBonus(p), () => advance2(p))) });
111806
111863
  }
111807
111864
  for (const st of stages)
111808
- candidates2.push({ kind: "stage", score: st.net / st.cost, cost: st.cost, id: st.bonusId, value: st.net, focus: false, borders: 0, target: st.via, run: spend(() => stageTwoMove(pc, ps, st, gainWith, tryExpand)) });
111865
+ candidates2.push({ kind: "stage", score: st.net / st.cost, cost: st.cost, id: st.bonusId, value: st.net, focus: false, borders: 0, target: st.via, run: spend(() => bound(st.bonusId === bind?.bonusId, () => stageTwoMove(pc, ps, st, gainWith, tryExpand))) });
111809
111866
  const races = oneVsOne ? raceTargets(pc, targets, captured) : [];
111810
111867
  if (races.length) rationale.push(raceLine(pc, races));
111811
111868
  for (const r of races)
@@ -112271,11 +112328,11 @@ function planPass(input2, pass) {
112271
112328
  }
112272
112329
  if (goal !== "complete-bonus")
112273
112330
  for (const st of stages) {
112274
- stageTwoMove(pc, ps, st, gainWith, tryExpand);
112331
+ bound(st.bonusId === bind?.bonusId, () => stageTwoMove(pc, ps, st, gainWith, tryExpand));
112275
112332
  garrisonCompleted();
112276
112333
  }
112277
112334
  for (const p of byCloseness) {
112278
- advance2(p);
112335
+ bound(otherBonus(p), () => advance2(p));
112279
112336
  garrisonCompleted();
112280
112337
  }
112281
112338
  captureInsteadOfHold(pc, ps, book, threats, hd, tgt, caps);
@@ -112295,12 +112352,13 @@ function planPass(input2, pass) {
112295
112352
  const eligible = [...targets.values()].filter((t) => !captured.has(t.id) && plainEligible(pc, tgt, t.id, t.enemy));
112296
112353
  const plainScore = plainOrderCosts(pc, tgt, eligible.map((t) => t.id));
112297
112354
  const rest = eligible.sort((a, b) => plainScore.get(a.id) - plainScore.get(b.id) || a.cost - b.cost || a.id - b.id);
112298
- for (const t of rest) {
112355
+ const nearestTs = bind ? new Set(bonusTs.get(bind.bonusId)) : void 0;
112356
+ for (const t of rest) bound(nearestTs?.has(t.id) ?? true, () => {
112299
112357
  const gain = gainWith([t.id]);
112300
- if (gain < 0 && !inFocus(t.id)) continue;
112358
+ if (gain < 0 && !inFocus(t.id)) return;
112301
112359
  if (tgt.emptyEnemies.has(t.id)) {
112302
112360
  if (gain >= 0) tryEmptyEnemy(pc, ps, book, tgt, caps, t.id);
112303
- continue;
112361
+ return;
112304
112362
  }
112305
112363
  {
112306
112364
  const refused = plainEconomy(pc, tgt, t.id, gain);
@@ -112311,13 +112369,13 @@ function planPass(input2, pass) {
112311
112369
  rationale.push(
112312
112370
  worth > 0 ? `Do not expand into ${label3(t.id)}: it adds +${worth} a turn and loses ~${lost} armies, more than ${pc.capturePaybackTurns} turns of it pay back.` : `Do not expand into ${label3(t.id)}: it adds no income and loses ~${lost} armies (more than ${PLAIN_EXPANSION_LOSS}), in no bonus worth completing.`
112313
112371
  );
112314
- continue;
112372
+ return;
112315
112373
  }
112316
112374
  }
112317
112375
  const reason = onlyNoLoss(pc, tgt, t.id) ? `expands territory: a no-loss capture (its defenders kill none of the attackers; what lands stays mine), so the cost of finishing its bonus does not stop it (#426)` : "expands territory";
112318
112376
  if (tgt.denials.has(t.id)) withoutTransit(pc, tgt, t.id, () => tryExpand(t.id, reason));
112319
112377
  else tryExpand(t.id, reason);
112320
- }
112378
+ });
112321
112379
  dropEmptyEnemyTargets(ps, tgt, empties);
112322
112380
  }
112323
112381
  const { saveStep, standStill } = neverStandStill(pc, ps, book, threats, hd, tgt, caps);
@@ -112435,7 +112493,7 @@ function planPass(input2, pass) {
112435
112493
  }
112436
112494
  const { leadSpareFor } = leadStrikes(pc, ps, book, threats, hd, tgt, caps, holdLocked, strikeStack);
112437
112495
  const keepWhole = /* @__PURE__ */ new Set([...strikeStack ? [strikeStack.id] : [], ...staging ? [staging.from] : []]);
112438
- const takenAfter = afterLeftoverCaptures(pc, ps, book, threats, hd, tgt, caps, beforeLeftover, keepWhole, poolDeployed);
112496
+ const takenAfter = bound(false, () => afterLeftoverCaptures(pc, ps, book, threats, hd, tgt, caps, beforeLeftover, keepWhole, poolDeployed));
112439
112497
  if (offered && !moves.some((m) => m.kind === "attack" && m.from === offered.at && takenAfter.includes(m.to))) offered.revert();
112440
112498
  const rounding = s.roundingMode ?? "StraightRound";
112441
112499
  const killsBy = (n) => guaranteedKills(n, rates.offensiveKillRate, luck, rounding);
@@ -113729,16 +113787,31 @@ function openingArmies(g, board, when = {}) {
113729
113787
  if (g.territoryById.has(t.territoryId) && t.armies !== null && t.owner.kind === "player") counts.add(t.armies);
113730
113788
  return counts.size === 1 ? [...counts][0] : null;
113731
113789
  }
113732
- function cardsCounted(played, r, turn) {
113790
+ function cardsCounted(played, r, turn, seen2 = /* @__PURE__ */ new Set()) {
113733
113791
  let due = r.firstTurn;
113792
+ let anchor2 = r.firstTurn;
113793
+ let since = 0;
113794
+ const step = r.turnsPerCard === null ? null : Math.max(1, r.turnsPerCard);
113734
113795
  const counted = [];
113735
113796
  for (const t of [...new Set(played)].sort(byNum2)) {
113736
- if (t < due || t >= turn) continue;
113797
+ if (t >= turn) continue;
113798
+ const certain = seen2.has(t);
113799
+ if (!certain && t < due) continue;
113737
113800
  counted.push(t);
113738
- due = r.turnsPerCard === null ? Infinity : Math.max(t + 1, r.firstTurn + counted.length * Math.max(1, r.turnsPerCard));
113801
+ if (certain) {
113802
+ anchor2 = t;
113803
+ since = 1;
113804
+ } else since++;
113805
+ due = step === null ? Infinity : Math.max(t + 1, anchor2 + since * step);
113739
113806
  }
113740
113807
  return { counted, due };
113741
113808
  }
113809
+ function playsOf(inferred, playerId, plays) {
113810
+ if (!plays) return { turns: [...inferred], seen: /* @__PURE__ */ new Set() };
113811
+ const read = new Set(plays.read);
113812
+ const seen2 = new Set(plays.plays.filter((x) => x.player === playerId).map((x) => x.turn));
113813
+ return { turns: [...inferred.filter((t) => !read.has(t)), ...seen2], seen: seen2 };
113814
+ }
113742
113815
  function risingTracked(turns) {
113743
113816
  const n = turns.length;
113744
113817
  if (n < 3) return null;
@@ -113824,7 +113897,8 @@ function enemyDeployEstimates(g, board, me, settings = {}, previous, tracks, pri
113824
113897
  let cardInTrack = null;
113825
113898
  if (usable && tracked !== null && when.reinforcement && when.reinforcement.armies > 0 && when.turn !== null && when.turn !== void 0) {
113826
113899
  const r = when.reinforcement;
113827
- const plays = new Set(cardsCounted(usable.turns.filter((x) => above(x.low, x.visibleIncome)).map((x) => x.from), r, when.turn).counted);
113900
+ const read = playsOf(usable.turns.filter((x) => above(x.low, x.visibleIncome)).map((x) => x.from), playerId, when.plays);
113901
+ const plays = new Set(cardsCounted(read.turns, r, when.turn, read.seen).counted);
113828
113902
  const top = usable.turns.filter((x) => x.observed >= tracked);
113829
113903
  if (top.length && top.every((x) => plays.has(x.from))) {
113830
113904
  const without = Math.max(
@@ -113943,10 +114017,13 @@ function enemyDeployEstimates(g, board, me, settings = {}, previous, tracks, pri
113943
114017
  }
113944
114018
  let card = null;
113945
114019
  let cardPlayed = null;
114020
+ let cardSeen = false;
113946
114021
  if (when.reinforcement && when.turn !== null && when.turn !== void 0) {
113947
114022
  const r = when.reinforcement;
113948
- const { counted, due } = cardsCounted(played, r, when.turn);
114023
+ const read = playsOf(played, playerId, when.plays);
114024
+ const { counted, due } = cardsCounted(read.turns, r, when.turn, read.seen);
113949
114025
  cardPlayed = counted.at(-1) ?? null;
114026
+ cardSeen = cardPlayed !== null && read.seen.has(cardPlayed);
113950
114027
  if (when.turn >= due && r.armies > 0) card = { armies: r.armies, due };
113951
114028
  }
113952
114029
  const estimate = income + (card?.armies ?? 0);
@@ -113977,6 +114054,7 @@ function enemyDeployEstimates(g, board, me, settings = {}, previous, tracks, pri
113977
114054
  exact: exact2,
113978
114055
  card,
113979
114056
  cardPlayed,
114057
+ ...cardSeen ? { cardSeen: true } : {},
113980
114058
  ...cardInTrack ? { cardInTrack } : {},
113981
114059
  ...priorFull !== null && priorFigure < priorFull ? { stated: { full: priorFull, scaled: priorFigure, lower: seen2, midpoint: statedMid } } : {}
113982
114060
  };
@@ -115089,7 +115167,7 @@ function serverBuild() {
115089
115167
  }
115090
115168
 
115091
115169
  // src/version.ts
115092
- var VERSION2 = "0.8.0";
115170
+ var VERSION2 = "0.9.0";
115093
115171
 
115094
115172
  // src/decision-log.ts
115095
115173
  var DECISION_LOG_VERSION = 1;
@@ -118528,7 +118606,7 @@ async function pruneBoardCaches(dir) {
118528
118606
  } catch {
118529
118607
  }
118530
118608
  }
118531
- var EMPTY2 = () => ({ turns: {}, orders: {}, expected: {}, estimates: {}, tripwires: [] });
118609
+ var EMPTY2 = () => ({ turns: {}, orders: {}, expected: {}, estimates: {}, tripwires: [], seenPlays: {} });
118532
118610
  async function readCache(dir, gameId, playerId) {
118533
118611
  try {
118534
118612
  const c = JSON.parse(await readFile6(boardCachePath(dir, gameId), "utf8"));
@@ -118537,7 +118615,8 @@ async function readCache(dir, gameId, playerId) {
118537
118615
  orders: isRec9(c.orders) ? c.orders : {},
118538
118616
  expected: isRec9(c.expected) ? c.expected : {},
118539
118617
  estimates: isRec9(c.estimates) ? c.estimates : {},
118540
- tripwires: Array.isArray(c.tripwires) ? c.tripwires : []
118618
+ tripwires: Array.isArray(c.tripwires) ? c.tripwires : [],
118619
+ seenPlays: isRec9(c.seenPlays) ? c.seenPlays : {}
118541
118620
  };
118542
118621
  if (isRec9(c.turns)) return { turns: c.turns, ...rest };
118543
118622
  if (typeof c.turn === "number") return { turns: { [String(c.turn)]: c.board }, ...rest };
@@ -118551,7 +118630,8 @@ function extras(cache) {
118551
118630
  ...Object.keys(cache.orders).length ? { orders: cache.orders } : {},
118552
118631
  ...Object.keys(cache.expected).length ? { expected: cache.expected } : {},
118553
118632
  ...Object.keys(cache.estimates).length ? { estimates: cache.estimates } : {},
118554
- ...cache.tripwires.length ? { tripwires: cache.tripwires } : {}
118633
+ ...cache.tripwires.length ? { tripwires: cache.tripwires } : {},
118634
+ ...Object.keys(cache.seenPlays).length ? { seenPlays: cache.seenPlays } : {}
118555
118635
  };
118556
118636
  }
118557
118637
  async function readCachedTurns(dir, gameId, playerId) {
@@ -118718,6 +118798,27 @@ async function writeSurvival(dir, gameId, playerId, turn, s) {
118718
118798
  return false;
118719
118799
  }
118720
118800
  }
118801
+ async function readSeenPlays(dir, gameId, playerId) {
118802
+ const { seenPlays } = await readCache(dir, gameId, playerId);
118803
+ const out = /* @__PURE__ */ new Map();
118804
+ for (const turn of newestTurns(seenPlays, Infinity, SURVIVAL_TURNS)) {
118805
+ const v = seenPlays[String(turn)];
118806
+ if (Array.isArray(v)) out.set(turn, v.filter((p) => isNum(p) && Number.isInteger(p)));
118807
+ }
118808
+ return out;
118809
+ }
118810
+ async function writeSeenPlays(dir, gameId, playerId, turn, players) {
118811
+ try {
118812
+ const cache = await readCache(dir, gameId, playerId);
118813
+ const all2 = { ...cache.seenPlays, [String(turn)]: [...players] };
118814
+ const seenPlays = {};
118815
+ for (const n of newestTurns(all2, Infinity, SURVIVAL_TURNS)) seenPlays[String(n)] = all2[String(n)];
118816
+ await writeCache(dir, { gameId, playerId, turns: cache.turns, ...extras({ ...cache, seenPlays }) });
118817
+ return true;
118818
+ } catch {
118819
+ return false;
118820
+ }
118821
+ }
118721
118822
 
118722
118823
  // src/client.ts
118723
118824
  var BASE_URL = "https://war.app";
@@ -140485,6 +140586,7 @@ function teammateDict(info) {
140485
140586
  }
140486
140587
  return void 0;
140487
140588
  }
140589
+ var orderClass = (o) => isObj(o) ? shortName(o.$type) : "unknown";
140488
140590
  function armiesOf2(a) {
140489
140591
  if (!isObj(a) || a.$type !== ARMIES2) return void 0;
140490
140592
  const f = fields(a);
@@ -140493,22 +140595,25 @@ function armiesOf2(a) {
140493
140595
  const units = f.find((x) => Array.isArray(x)) ?? [];
140494
140596
  return { count: numbers[0], commander: units.some((u) => isObj(u) && u.$type === COMMANDER2) };
140495
140597
  }
140496
- function readOrder(o, out) {
140497
- const type = String(o.$type);
140598
+ function decodeOrder(o) {
140599
+ if (!isObj(o) || typeof o.$type !== "string" || !o.$type.startsWith(ORDER_PREFIX)) return void 0;
140600
+ const type = o.$type;
140498
140601
  const f = fields(o);
140499
140602
  const ints3 = f.filter(isInt8);
140500
140603
  if (type === DEPLOY) {
140501
- if (ints3.length < 2) return false;
140502
- out.deploys.push({ territoryId: ints3[0], armies: ints3[1] });
140503
- return true;
140604
+ if (ints3.length < 2) return void 0;
140605
+ return { kind: "deploy", territoryId: ints3[0], armies: ints3[1] };
140504
140606
  }
140505
140607
  if (type === ATTACK_TRANSFER) {
140506
140608
  const [attackTeammates, mode, percent, from, armies, to] = f;
140507
140609
  const army = armiesOf2(armies);
140508
- if (typeof attackTeammates !== "boolean" || typeof percent !== "boolean" || !isInt8(mode) || !isInt8(from) || !isInt8(to) || !army) return false;
140610
+ if (typeof attackTeammates !== "boolean" || typeof percent !== "boolean" || !isInt8(mode) || !isInt8(from) || !isInt8(to) || !army) {
140611
+ return void 0;
140612
+ }
140509
140613
  const m = MODES2[mode];
140510
- if (!m) return false;
140511
- out.moves.push({
140614
+ if (!m) return void 0;
140615
+ return {
140616
+ kind: "move",
140512
140617
  from,
140513
140618
  to,
140514
140619
  armies: army.count,
@@ -140516,21 +140621,35 @@ function readOrder(o, out) {
140516
140621
  ...percent ? { percent: true } : {},
140517
140622
  ...attackTeammates ? { attackTeammates: true } : {},
140518
140623
  ...army.commander ? { commander: true } : {}
140519
- });
140520
- return true;
140521
- }
140522
- const cardId = f.map(normalizeGuid).find((g) => g !== void 0);
140523
- if (type === DISCARD) {
140524
- out.discards.push(cardId !== void 0 ? { cardId } : {});
140525
- return true;
140624
+ };
140526
140625
  }
140626
+ const at2 = f.findIndex((v) => normalizeGuid(v) !== void 0);
140627
+ const cardId = at2 >= 0 ? normalizeGuid(f[at2]) : void 0;
140628
+ if (type === DISCARD) return { kind: "discard", ...cardId !== void 0 ? { cardId } : {} };
140527
140629
  if (type.startsWith(PLAY_CARD)) {
140528
140630
  const cls = type.slice(PLAY_CARD.length);
140529
140631
  const t = CARD_CLASS_TYPES[cls] ?? cardTypeByName(cls) ?? null;
140530
- out.cards.push({ ...cardId !== void 0 ? { cardId } : {}, type: t, name: t !== null ? cardTypeName(t) : cls || "card" });
140531
- return true;
140632
+ return {
140633
+ kind: "card",
140634
+ cls,
140635
+ type: t,
140636
+ name: t !== null ? cardTypeName(t) : cls || "card",
140637
+ ...cardId !== void 0 ? { cardId } : {},
140638
+ own: at2 >= 0 ? f.slice(0, at2) : []
140639
+ };
140532
140640
  }
140533
- return false;
140641
+ return void 0;
140642
+ }
140643
+ function readOrder(o, out) {
140644
+ const d = decodeOrder(o);
140645
+ if (!d) return false;
140646
+ if (d.kind === "deploy") out.deploys.push({ territoryId: d.territoryId, armies: d.armies });
140647
+ else if (d.kind === "move") {
140648
+ const { kind: _kind, ...move2 } = d;
140649
+ out.moves.push(move2);
140650
+ } else if (d.kind === "discard") out.discards.push(d.cardId !== void 0 ? { cardId: d.cardId } : {});
140651
+ else out.cards.push({ ...d.cardId !== void 0 ? { cardId: d.cardId } : {}, type: d.type, name: d.name });
140652
+ return true;
140534
140653
  }
140535
140654
  function ordersOf2(list3) {
140536
140655
  if (!Array.isArray(list3)) return null;
@@ -141618,6 +141737,21 @@ function cardPieceOption(settings, hand) {
141618
141737
  const v = capturePieceValue(settings, inHand);
141619
141738
  return v.armies !== null && v.armies > 0 ? { cardPieceValue: v.armies } : {};
141620
141739
  }
141740
+ function lastTurnPlays(info, players, turn) {
141741
+ const read = readTurnReinforcementPlays(info);
141742
+ if (!read || turn === null || read.turn !== turn - 1) return void 0;
141743
+ const byInGame = playersByInGameId(players);
141744
+ return { turn: read.turn, players: read.players.flatMap((id) => byInGame.has(id) ? [byInGame.get(id).id] : []) };
141745
+ }
141746
+ function reinforcementPlaysShown(settings) {
141747
+ const clock = cardClock(settings);
141748
+ return clock !== void 0 && clock.playsHidden === false && clock.cards.some((c) => c.card === "Reinforcement");
141749
+ }
141750
+ function seenReinforcementPlays(settings, seen2) {
141751
+ if (!reinforcementPlaysShown(settings) || seen2.size === 0) return void 0;
141752
+ const read = [...seen2.keys()].sort((a, b) => a - b);
141753
+ return { read, plays: read.flatMap((turn) => seen2.get(turn).map((player2) => ({ player: player2, turn }))) };
141754
+ }
141621
141755
  function opponentReinforcement(settings, hand) {
141622
141756
  const clock = cardClock(settings);
141623
141757
  const entry = clock?.cards.find((c) => c.card === "Reinforcement");
@@ -144812,7 +144946,7 @@ async function teamOf(ctx, game, warnings) {
144812
144946
  }
144813
144947
  }
144814
144948
  var TEAM_LIST_NOTES = [
144815
- "A teammate's list is read from the live board's TeammateOrders (client bundle, UNVERIFIED live, V5), else from GetTerritoryPicks with the teammate's id (UNVERIFIED, V6); a list that cannot be read is unknown, and the plan is then the one made without it.",
144949
+ "A teammate's list is read from the live board's TeammateOrders (client bundle, UNVERIFIED live for picks, V5), else from GetTerritoryPicks with the teammate's id (verified live, V6); a list that cannot be read is unknown, and the plan is then the one made without it.",
144816
144950
  "The award order of a team game is UNVERIFIED: the mirrored list is laid out for a reversing order, and `splits` names the bonuses a repeating order would split between you. Agree a list in team chat before relying on it."
144817
144951
  ];
144818
144952
  function registerPickTools(server, ctx, deps = {}) {
@@ -144873,6 +145007,8 @@ function registerPickTools(server, ctx, deps = {}) {
144873
145007
  warnings.push(
144874
145008
  `Your teammate's list (player ${unreadMates.join(", ")}) could not be read, so this plan cannot avoid their picks: hold the submit until it can be read or a list is agreed in team chat (warapp_submit_picks refuses meanwhile unless without_teammate_list: true).`
144875
145009
  );
145010
+ const notMates = (team ?? []).filter((_, i2) => mateLists[i2]?.refused === "not-teammate").map((p) => p.id);
145011
+ if (notMates.length) warnings.push(notTeammateWarning(notMates));
144876
145012
  const lists = mateLists.map((l) => l?.territories ?? []);
144877
145013
  const budgetMs = picksBudgetMs(deps.env);
144878
145014
  let plan;
@@ -144960,7 +145096,7 @@ function registerPickTools(server, ctx, deps = {}) {
144960
145096
  return {
144961
145097
  id: p.id,
144962
145098
  name: untrustedText(p.name),
144963
- picks: read ? { source: read.source, territories: read.territories.map(name) } : null
145099
+ picks: read ? { source: read.source, territories: read.territories.map(name), ...read.refused ? { refused: read.refused } : {} } : null
144964
145100
  };
144965
145101
  }),
144966
145102
  opponents: Math.max(0, players - 1 - team.length),
@@ -148746,7 +148882,7 @@ function claimedCardUses(uses, claimed) {
148746
148882
  function claimedCardWarning(uses) {
148747
148883
  if (!uses.length) return void 0;
148748
148884
  const each = uses.map((u) => `${u.mine === "play" ? "plays" : "discards"} the ${u.card.name} card ${u.card.id}, which player ${u.player} has already entered a ${u.theirs} of`);
148749
- return `These orders ${each.join("; ")}. A team shares one hand and must not use one card twice: leave it to them, or agree in team chat who uses it before committing. Their entered orders are read from the live board (UNVERIFIED live, V5).`;
148885
+ return `These orders ${each.join("; ")}. A team shares one hand and must not use one card twice: leave it to them, or agree in team chat who uses it before committing. Their entered orders are read from the live board (V5, verified live before commit).`;
148750
148886
  }
148751
148887
  function unclaimedFirst(hand, claimed) {
148752
148888
  const ids2 = new Set(claimed.map((c) => c.card.id));
@@ -151039,6 +151175,11 @@ async function livePlanSetup(ctx, a) {
151039
151175
  const outlook = gameOutlook(outlookInput);
151040
151176
  const picking = ctx.dataDir ? await readPickRecord(ctx.dataDir, game.id, me.id) : void 0;
151041
151177
  const opponents = game.players.filter((p) => p.id !== me.id && (p.state ?? "Playing") === "Playing").length;
151178
+ const lastPlays = lastTurnPlays(info, game.players, turn);
151179
+ const playsShown = reinforcementPlaysShown(game.settings);
151180
+ const keptPlays = playsShown && ctx.dataDir ? await readSeenPlays(ctx.dataDir, game.id, me.id) : /* @__PURE__ */ new Map();
151181
+ if (lastPlays) keptPlays.set(lastPlays.turn, lastPlays.players);
151182
+ const reinforcementPlays = seenReinforcementPlays(game.settings, keptPlays);
151042
151183
  const mapPace = await fogPaceFor(
151043
151184
  ctx.dataDir,
151044
151185
  a.env,
@@ -151072,7 +151213,9 @@ async function livePlanSetup(ctx, a) {
151072
151213
  ...opening ? { opening } : {},
151073
151214
  ...mapPace ? { mapPace } : {},
151074
151215
  // #164: an opponent's Reinforcement card, from the turn the card clock says one can be in hand.
151075
- ...opponentReinforcement(game.settings, hand) ? { reinforcement: opponentReinforcement(game.settings, hand) } : {}
151216
+ ...opponentReinforcement(game.settings, hand) ? { reinforcement: opponentReinforcement(game.settings, hand) } : {},
151217
+ // #427: the Reinforcement plays seen in the turns' orders (card plays not fogged): a play restarts the clock.
151218
+ ...reinforcementPlays ? { reinforcementPlays } : {}
151076
151219
  };
151077
151220
  const truces = await truceRelations(ctx, {
151078
151221
  game,
@@ -151227,7 +151370,9 @@ async function livePlanSetup(ctx, a) {
151227
151370
  estimates,
151228
151371
  trip,
151229
151372
  teams,
151230
- commerce
151373
+ commerce,
151374
+ // #427: the last turn's Reinforcement plays, for warapp_plan_turn to keep (only when plays show).
151375
+ seenPlays: playsShown ? lastPlays : void 0
151231
151376
  };
151232
151377
  }
151233
151378
  async function commanderCheck(ctx, a) {
@@ -151490,6 +151635,7 @@ function registerTurnTools(server, ctx, opts = {}) {
151490
151635
  const whatIf = goal !== void 0 || enemy_deploy !== void 0;
151491
151636
  if (ctx.dataDir && turn !== null)
151492
151637
  await writeBoardCache(ctx.dataDir, game.id, me.id, turn, seen2, whatIf ? void 0 : plan.expected.nextIncome);
151638
+ if (ctx.dataDir && setup.seenPlays) await writeSeenPlays(ctx.dataDir, game.id, me.id, setup.seenPlays.turn, setup.seenPlays.players);
151493
151639
  await keepTripwires(ctx.dataDir, game.id, me.id, turn, setup.trip);
151494
151640
  if (ctx.dataDir && turn !== null && !whatIf)
151495
151641
  await recordProfile(ctx.dataDir, opts.env, game, me, [...history.boards, { turn, board: seen2 }], teamsKnown);
@@ -152100,7 +152246,7 @@ function registerTurnTools(server, ctx, opts = {}) {
152100
152246
  },
152101
152247
  {
152102
152248
  name: "warapp_submit_turn",
152103
- description: `Commit your orders for the current turn of a war.app (Warzone) game: card plays, deploys, then attacks/transfers (territories by id or name, cards by id or type name \u2014 usually the \`orders\` from warapp_plan_turn, reviewed with the user). Plays Reinforcement, Order Priority, Order Delay and Blockade (with a \`target\` of yours; an Order Delay goes after every move unless it has \`before\`: a move number to place it above, unverified live) from your hand, and the targeted cards \u2014 Spy (\`player\`), Reconnaissance (\`target\`), Surveillance (\`bonus\`), Airlift (\`from\` yours, \`to\` yours or a teammate's, \`armies\`, optional \`commander\`), Gift (\`target\` yours, \`player\`), Diplomacy (\`players\`: two), Sanctions (\`player\`), Bomb (\`target\` next to yours, not yours or a teammate's) and Emergency Blockade (\`target\` yours, never your commander's), encoded as the client does (the Airlift and Diplomacy verified live; the others not yet), each refused where war.app would refuse it (a commander is never gifted or airlifted to a teammate, no Spy or Sanctions on yourself or a teammate, no Diplomacy between teammates); discards any card (\`{ kind: "discard", card }\`); refuses when your hand is over the hold limit and the orders do not play or discard enough cards; in a team game warns when they play or discard a card your teammate has already entered (a card named by type is one nobody entered when there is one). The orders reach the game and cannot be withdrawn here; when the turn resolves, other players see the results. Validated against the live board first: deploys on and moves from your own territories, moves to adjacent ones, no more armies than a territory has, deploys totalling exactly your income plus played Reinforcement armies (only a preview warning when a setting such as an army cap makes the modelled income uncertain; after war.app's error 11, resend with the game's own number as \`income\`); under Local Deployment, each held bonus's armies deployed inside that bonus; under No-Split, at most one attack or transfer per territory (and a warning when one sends less than the whole stack, which war.app moves anyway); under Multi-Attack, a move (not a deploy) may go on from a territory an earlier move in the list captures (warapp_plan_turn obeys these and the kill rates). A move may carry options, each refused unless the game allows it: \`mode\` "transfer-only" (AllowTransferOnly) or "attack-only" (AllowAttackOnly), \`percent\` (AllowPercentageAttacks: \`armies\` is a percentage of what can move when it runs), \`commander\` (take your commander along; \`armies\` 0 sends it alone) and \`attack_teammates\` (team games); these are encoded as the client does but not yet verified live. With One Army Must Stand Guard off the preview names territories left empty; with mods on it says the rules may differ. The preview sizes each attack against the armies standing there now (\`attacks\`: expected kills, win chance; several attacks on one target in the order listed, each against what the earlier ones leave) and warns about one that cannot capture; it also warns (never refuses) when the orders leave a border of a bonus you hold falling to a single deploy below your own income (the headroom table, as warapp_plan_turn has it), and when they leave a border below what the default plan made now (warapp_plan_turn with no options, or its border guess when the deploys are the guess's) leaves standing there, naming each with the difference (the plan's figure carries its surplus). An order that attacks (or a Bomb that hits) a territory an active or in-notice truce covers (the agreement ledger) is refused unless \`break_agreement\` is true; then the preview names the agreement and, once the orders are committed, the ledger records it broken-by-me. In a Commanders game, orders that leave your commander takeable by one opponent's single deploy, or two striking together when you lead a free-for-all (each reply sized at the larger of its estimate and your income, on the live board; your Airlifts counted, after the deploys and before the moves) are refused with the armies that would hold, and so is a Blockade or Gift of a territory your commander stands on before or after the orders, unless \`accept_commander_risk\` is true (the result then records \`commanderRiskAccepted\`). The orders sent are kept in this server's decision log beside the turn's plan; when they differ from it, \`override_reason\` (and \`override_by\`) say why. Always sent as the signed-in war.app account; refuses if you have already committed this turn. Success is confirmed from game state (turn advanced, or your orders marked committed). ${BRIDGE_NOTE} ${CONFIRM_INJECTION_RULE}`,
152249
+ description: `Commit your orders for the current turn of a war.app (Warzone) game: card plays, deploys, then attacks/transfers (territories by id or name, cards by id or type name \u2014 usually the \`orders\` from warapp_plan_turn, reviewed with the user). Plays Reinforcement, Order Priority, Order Delay and Blockade (with a \`target\` of yours; an Order Delay goes after every move unless it has \`before\`: a move number to place it above, unverified live) from your hand, and the targeted cards \u2014 Spy (\`player\`), Reconnaissance (\`target\`), Surveillance (\`bonus\`), Airlift (\`from\` yours, \`to\` yours or a teammate's, \`armies\`, optional \`commander\`), Gift (\`target\` yours, \`player\`), Diplomacy (\`players\`: two), Sanctions (\`player\`), Bomb (\`target\` next to yours, not yours or a teammate's) and Emergency Blockade (\`target\` yours, never your commander's), encoded as the client does (the Airlift and Diplomacy verified live; the others not yet), each refused where war.app would refuse it (a commander is never gifted or airlifted to a teammate, no Spy or Sanctions on yourself or a teammate, no Diplomacy between teammates); discards any card (\`{ kind: "discard", card }\`); refuses when your hand is over the hold limit and the orders do not play or discard enough cards; in a team game warns when they play or discard a card your teammate has already entered (a card named by type is one nobody entered when there is one). The orders reach the game and cannot be withdrawn here; when the turn resolves, other players see the results. Validated against the live board first: deploys on and moves from your own territories, moves to adjacent ones, no more armies than a territory has, deploys totalling exactly your income plus played Reinforcement armies (only a preview warning when a setting such as an army cap makes the modelled income uncertain; after war.app's error 11, resend with the game's own number as \`income\`); under Local Deployment, each held bonus's armies deployed inside that bonus; under No-Split, at most one attack or transfer per territory (and a warning when one sends less than the whole stack, which war.app moves anyway); under Multi-Attack, a move (not a deploy) may go on from a territory an earlier move in the list captures (warapp_plan_turn obeys these and the kill rates). A move may carry options, each refused unless the game allows it: \`mode\` "transfer-only" (AllowTransferOnly) or "attack-only" (AllowAttackOnly), \`percent\` (AllowPercentageAttacks: \`armies\` is a percentage of what can move when it runs), \`commander\` (take your commander along; \`armies\` 0 sends it alone) and \`attack_teammates\` (team games); these are encoded as the client does but not yet verified live. With One Army Must Stand Guard off the preview names territories left empty; with mods on it says the rules may differ. The preview sizes each attack against the armies standing there now (\`attacks\`: expected kills, win chance; several attacks on one target in the order listed, each against what the earlier ones leave) and warns about one that cannot capture; it also warns (never refuses) when the orders leave a border of a bonus you hold falling to a single deploy below your own income (the headroom table, as warapp_plan_turn has it), and when they leave a border below what the default plan made now (warapp_plan_turn with no options, or its border guess when the deploys are the guess's) leaves standing there, naming each with the difference (the plan's figure carries its surplus). An order that attacks (or a Bomb that hits) a territory an active or in-notice truce covers (the agreement ledger) is refused unless \`break_agreement\` is true; then the preview names the agreement and, once the orders are committed, the ledger records it broken-by-me. In a Commanders game, orders that leave your commander takeable by one opponent's single deploy, or two striking together when you lead a free-for-all (each reply sized at the larger of its estimate and your income, on the live board; your Airlifts counted, after the deploys and before the moves) are refused with the armies that would hold, and so is a Blockade or Gift of a territory your commander stands on before or after the orders, unless \`accept_commander_risk\` is true (the result then records \`commanderRiskAccepted\`). The orders sent are kept in this server's decision log beside the turn's plan; when they differ from it, \`override_reason\` (and \`override_by\`) say why. Always sent as the signed-in war.app account; refuses if you have already committed this turn (to change committed orders: warapp_get_my_orders reads them back in this shape, warapp_uncommit_turn withdraws them, then resubmit). Success is confirmed from game state (turn advanced, or your orders marked committed). ${BRIDGE_NOTE} ${CONFIRM_INJECTION_RULE}`,
152104
152250
  annotations: toolAnnotations({
152105
152251
  title: "Submit a war.app turn",
152106
152252
  readOnly: false,
@@ -153240,22 +153386,33 @@ async function resolveTeamsFor(ctx, game, me) {
153240
153386
  // src/tools/team.ts
153241
153387
  var NOTES2 = [
153242
153388
  "GameFeed's player team is UNVERIFIED (V1); when it sends none, the team comes from GetMyGames (from the client bundle).",
153243
- 'Teammate orders and picks come from the live board\'s TeammateOrders (client bundle, UNVERIFIED live, V5): `null` means unknown \u2014 none entered, or war.app did not send them \u2014 never "nothing entered".',
153244
- "While distributing, a teammate's picks not in the board are asked with GetTerritoryPicks and the teammate's id (UNVERIFIED, V6); a refusal reads as unknown.",
153389
+ 'Teammate orders and picks come from the live board\'s TeammateOrders (orders entered before the teammate commits verified live, V5; the pick list there unverified): `null` means unknown \u2014 none entered, or war.app did not send them \u2014 never "nothing entered".',
153390
+ "While distributing, a teammate's picks not in the board are asked with GetTerritoryPicks and the teammate's id (verified live, V6); war.app refusing an opponent's list (187) or any list in automatic distribution (188) is `refused`, any other refusal unknown.",
153245
153391
  "The team's hand is every card under me and my teammates: war.app keeps each player's cards under that player's id (`heldBy`), and the limit is the team's (V8, verified)."
153246
153392
  ];
153247
153393
  var DISTRIBUTING2 = "DistributingTerritories";
153248
153394
  var BOARD_STATES = /* @__PURE__ */ new Set(["Playing", DISTRIBUTING2]);
153395
+ var PICKS_REFUSALS = {
153396
+ 187: "not-teammate",
153397
+ // CannotGetOpponentsPicks
153398
+ 188: "automatic-distribution"
153399
+ // CannotGetPicksInAutomaticDistribution
153400
+ };
153249
153401
  async function readTeammatePicks(ctx, gameId, mate, entry) {
153250
153402
  if (entry?.picks) return { source: "teammate-orders", territories: entry.picks };
153251
153403
  const inGame = inGameOf(mate);
153252
153404
  if (inGame === void 0) return null;
153253
153405
  try {
153254
153406
  return { source: "territory-picks", territories: await loadPicks(ctx, gameId, inGame) };
153255
- } catch {
153407
+ } catch (e) {
153408
+ const refused = e instanceof WarappServerError ? PICKS_REFUSALS[e.code] : void 0;
153409
+ if (refused) return { source: "territory-picks", territories: [], refused };
153256
153410
  return null;
153257
153411
  }
153258
153412
  }
153413
+ function notTeammateWarning(players) {
153414
+ return `War.app refused the pick list of player ${players.join(", ")} as an opponent's (GetTerritoryPicks error 187, CannotGetOpponentsPicks): it does not count them as your teammate, so the team read may be wrong. Their list never becomes readable; the plan treats it as empty.`;
153415
+ }
153259
153416
  function registerTeamTool(server, ctx) {
153260
153417
  server.registerTool(
153261
153418
  "warapp_get_team",
@@ -153324,7 +153481,7 @@ function registerTeamTool(server, ctx) {
153324
153481
  let picks = null;
153325
153482
  if (game.state === DISTRIBUTING2 && board) {
153326
153483
  const read2 = await readTeammatePicks(ctx, game.id, p, entry);
153327
- picks = read2 && { source: read2.source, territories: read2.territories.map(name) };
153484
+ picks = read2 && { source: read2.source, territories: read2.territories.map(name), ...read2.refused ? { refused: read2.refused } : {} };
153328
153485
  }
153329
153486
  teammates.push({
153330
153487
  id: p.id,
@@ -153647,11 +153804,16 @@ function registerLiveTools(server, ctx) {
153647
153804
  `war.app expects at least ${bounds.min} picks here (the territories each player is granted); got ${picks.length}, which it may reject.`
153648
153805
  );
153649
153806
  const unread = [];
153807
+ const notMates = [];
153650
153808
  if (isTeamGame(game.players)) {
153651
153809
  const entries2 = teammateOrdersOf(info, game.players);
153652
- for (const mate of teammatesOf(game.players, me).filter((p) => (p.state ?? "Playing") === "Playing"))
153653
- if (await readTeammatePicks(ctx, game.id, mate, entries2?.find((e) => e.playerId === mate.id)) === null) unread.push(mate.id);
153810
+ for (const mate of teammatesOf(game.players, me).filter((p) => (p.state ?? "Playing") === "Playing")) {
153811
+ const read = await readTeammatePicks(ctx, game.id, mate, entries2?.find((e) => e.playerId === mate.id));
153812
+ if (read === null) unread.push(mate.id);
153813
+ else if (read.refused === "not-teammate") notMates.push(mate.id);
153814
+ }
153654
153815
  }
153816
+ if (notMates.length) lengthWarnings.push(notTeammateWarning(notMates));
153655
153817
  if (unread.length && without_teammate_list !== true)
153656
153818
  throw new McpToolError(
153657
153819
  `Your teammate's list (player ${unread.join(", ")}) could not be read, so an overlap with yours cannot be seen: a pick you both list goes to one of you.`,
@@ -159263,7 +159425,7 @@ var DISTRIBUTING5 = "DistributingTerritories";
159263
159425
  var PLAYING4 = "Playing";
159264
159426
  var BRIEF_NOTES = [
159265
159427
  'Data for a team-chat message, never sent: word it and send it with warapp_send_chat (channel: "team"). In a team everything true and concrete is shared; promise only what the plan does.',
159266
- `Teams come from GameFeed, else your game list (unverified, V1). Your teammates' entered orders and picks are read from the live board (UNVERIFIED live, V5; picks fall back to GetTerritoryPicks, V6): none read means unknown, so no conflict can be named \u2014 not "no conflict".`,
159428
+ `Teams come from GameFeed, else your game list (unverified, V1). Your teammates' entered orders and picks are read from the live board (orders verified live before a commit, V5; picks there unverified, falling back to GetTerritoryPicks, verified, V6): none read means unknown, so no conflict can be named \u2014 not "no conflict".`,
159267
159429
  "What a plain move onto a teammate's territory does is unverified (V7): every ask to move armies onto one is advice to your teammate, never an order of yours, and warapp_plan_turn never puts one in `orders`."
159268
159430
  ];
159269
159431
  var CONFLICT_NOTE = "`same-target`: you both attack it \u2014 whichever lands second moves onto your teammate's territory (V7), so one of you should switch, unless it is a joint capture (`joint`); `bonus`: their attack takes a member of a bonus your plan completes (`completes`) or captures into (a bonus pays one holder: agree who takes it); `attacks-me`: an order of theirs attacks your territory; `onto-mine`: a plain order of theirs moves onto your territory (what it does is V7).";
@@ -159465,6 +159627,179 @@ async function firstTurnPicks(ctx, game, me, board) {
159465
159627
  return reading ? picksLost(record4.list, reading) : null;
159466
159628
  }
159467
159629
 
159630
+ // src/my-orders.ts
159631
+ var ORDER_PREFIX2 = "warlight.shared.GameOrder";
159632
+ var isInt16 = (v) => typeof v === "number" && Number.isInteger(v);
159633
+ var isOrder = (v) => isObj(v) && typeof v.$type === "string" && v.$type.startsWith(ORDER_PREFIX2);
159634
+ function readMyOrderList(info) {
159635
+ if (!isObj(info)) return void 0;
159636
+ const lists = fields(info).filter(
159637
+ (v) => Array.isArray(v) && v.length > 0 && v.every((o) => o === null || isOrder(o)) && v.some(isOrder)
159638
+ );
159639
+ return lists.length === 1 ? lists[0].filter((o) => o !== null) : void 0;
159640
+ }
159641
+ var TERRITORY_CARDS = /* @__PURE__ */ new Set(["Blockade", "Abandon", "Bomb", "Reconnaissance"]);
159642
+ var PLAYER_CARDS = /* @__PURE__ */ new Set(["Spy", "Sanctions"]);
159643
+ var PLAIN_CARDS = /* @__PURE__ */ new Set(["Reinforcement", "OrderPriority", "OrderDelay"]);
159644
+ function myOrdersOf2(info, players) {
159645
+ const list3 = readMyOrderList(info);
159646
+ if (!list3) return null;
159647
+ const byInGame = playersByInGameId(players);
159648
+ const feedId = (inGame) => inGame === 0 ? 0 : byInGame.get(inGame)?.id;
159649
+ const orders = [];
159650
+ const unread = [];
159651
+ let movesSeen = 0;
159652
+ const delays = [];
159653
+ for (const raw of list3) {
159654
+ const cls = orderClass(raw);
159655
+ const d = decodeOrder(raw);
159656
+ if (!d) {
159657
+ unread.push(cls);
159658
+ continue;
159659
+ }
159660
+ if (d.kind === "deploy") {
159661
+ orders.push({ kind: "deploy", territory: d.territoryId, armies: d.armies });
159662
+ continue;
159663
+ }
159664
+ if (d.kind === "move") {
159665
+ movesSeen += 1;
159666
+ orders.push({
159667
+ kind: "move",
159668
+ from: d.from,
159669
+ to: d.to,
159670
+ armies: d.armies,
159671
+ ...d.mode === "attack" ? { mode: "attack-only" } : {},
159672
+ ...d.mode === "transfer" ? { mode: "transfer-only" } : {},
159673
+ ...d.percent ? { percent: true } : {},
159674
+ ...d.attackTeammates ? { attack_teammates: true } : {},
159675
+ ...d.commander ? { commander: true } : {}
159676
+ });
159677
+ continue;
159678
+ }
159679
+ if (d.kind === "discard") {
159680
+ if (d.cardId === void 0) unread.push(`${cls} (no card id)`);
159681
+ else orders.push({ kind: "discard", card: d.cardId });
159682
+ continue;
159683
+ }
159684
+ const card = { kind: "card", card: d.cardId ?? d.name, cardType: d.name };
159685
+ const ints3 = d.own.filter(isInt16);
159686
+ let fieldsOf2;
159687
+ let missingPlayer;
159688
+ const who2 = (n) => {
159689
+ if (n === void 0) return void 0;
159690
+ const id = feedId(n);
159691
+ if (id === void 0) missingPlayer = n;
159692
+ return id;
159693
+ };
159694
+ if (PLAIN_CARDS.has(d.cls)) fieldsOf2 = {};
159695
+ else if (TERRITORY_CARDS.has(d.cls) && ints3.length === 1) fieldsOf2 = { target: ints3[0] };
159696
+ else if (d.cls === "Surveillance" && ints3.length === 1) fieldsOf2 = { bonus: ints3[0] };
159697
+ else if (PLAYER_CARDS.has(d.cls) && ints3.length === 1) fieldsOf2 = { player: who2(ints3[0]) };
159698
+ else if (d.cls === "Gift" && ints3.length === 2) fieldsOf2 = { target: ints3[1], player: who2(ints3[0]) };
159699
+ else if (d.cls === "Diplomacy" && ints3.length === 2) fieldsOf2 = { players: [who2(ints3[0]), who2(ints3[1])] };
159700
+ else if (d.cls === "Airlift") {
159701
+ const army = armiesOf2(d.own[0]);
159702
+ if (army && ints3.length === 3) {
159703
+ fieldsOf2 = { from: ints3[0], to: ints3[2], armies: army.count, ...army.commander ? { commander: true } : {} };
159704
+ }
159705
+ }
159706
+ if (missingPlayer !== void 0) {
159707
+ unread.push(`${cls} (player ${missingPlayer} is not in the game)`);
159708
+ continue;
159709
+ }
159710
+ if (!fieldsOf2) {
159711
+ unread.push(cls);
159712
+ continue;
159713
+ }
159714
+ const order = { ...card, ...fieldsOf2 };
159715
+ orders.push(order);
159716
+ if (d.cls === "OrderDelay") delays.push({ order, movesBefore: movesSeen });
159717
+ }
159718
+ for (const { order, movesBefore } of delays) if (movesBefore < movesSeen) order.before = movesBefore + 1;
159719
+ return { orders, unread };
159720
+ }
159721
+
159722
+ // src/tools/my-orders.ts
159723
+ async function readMyOrders(ctx, game) {
159724
+ try {
159725
+ const { info } = await readLatestBoard(ctx, game.id);
159726
+ return { read: myOrdersOf2(info, game.players) };
159727
+ } catch (e) {
159728
+ return { read: null, failure: e instanceof Error ? e.message : String(e) };
159729
+ }
159730
+ }
159731
+ function shownOrders(orders, game) {
159732
+ const map2 = game.map ? mapOf(game) : void 0;
159733
+ const t = (id) => map2 ? `${untrustedText(namer(map2)(id).name)} (${id})` : `territory ${id}`;
159734
+ const b = (id) => map2 ? `${untrustedText(bonusNamer(map2)(id).name)} (${id})` : `bonus ${id}`;
159735
+ const p = (id) => {
159736
+ if (id === 0) return "neutral";
159737
+ const seat = game.players.find((x) => x.id === id);
159738
+ return seat ? `${untrustedText(seat.name)} (${id})` : `player ${id}`;
159739
+ };
159740
+ return orders.map((o) => {
159741
+ if (o.kind === "deploy") return `Deploy ${o.armies} on ${t(o.territory)}`;
159742
+ if (o.kind === "discard") return `Discard card ${o.card}`;
159743
+ if (o.kind === "move") {
159744
+ const opts = [o.mode, o.percent ? "percent" : void 0, o.commander ? "with commander" : void 0, o.attack_teammates ? "attack teammates" : void 0].filter((x) => x !== void 0);
159745
+ return `Move ${o.armies}${o.percent ? "%" : ""} ${t(o.from)} \u2192 ${t(o.to)}${opts.length ? ` (${opts.join(", ")})` : ""}`;
159746
+ }
159747
+ const parts = [
159748
+ o.target !== void 0 ? `on ${t(o.target)}` : void 0,
159749
+ o.player !== void 0 ? `player ${p(o.player)}` : void 0,
159750
+ o.players ? `between ${p(o.players[0])} and ${p(o.players[1])}` : void 0,
159751
+ o.bonus !== void 0 ? `on ${b(o.bonus)}` : void 0,
159752
+ o.from !== void 0 && o.to !== void 0 ? `${o.armies ?? 0} ${t(o.from)} \u2192 ${t(o.to)}${o.commander ? " with commander" : ""}` : void 0,
159753
+ o.before !== void 0 ? `above move ${o.before}` : void 0
159754
+ ].filter((x) => x !== void 0);
159755
+ return `Play ${o.cardType} card${parts.length ? ` ${parts.join(", ")}` : ""}`;
159756
+ });
159757
+ }
159758
+ var COMMITTED_NOTE = 'Read from the live board: war.app\'s own copy of your committed orders (what the web client shows in "Modify orders"), verified live. Pass `orders` to warapp_submit_turn unchanged to resubmit them (after warapp_uncommit_turn), or edit them first. `cardType` and `shown` are for display only.';
159759
+ var ENTERED_NOTE = "Your orders are not committed: these are the orders war.app holds as entered for you, which is UNVERIFIED live (only committed orders have been checked). Pass `orders` to warapp_submit_turn to commit them.";
159760
+ var UNKNOWN_NOTE = 'war.app sent no list of your orders for this turn, so they are unknown (null), never "none": nothing entered, or not sent. Check the web client before submitting replacements.';
159761
+ function registerMyOrdersTool(server, ctx) {
159762
+ server.registerTool(
159763
+ "warapp_get_my_orders",
159764
+ {
159765
+ title: "Read back my orders for this war.app turn",
159766
+ description: untrustedDescription(
159767
+ `Your own orders for the current turn of a war.app (Warzone) game, read back from war.app \u2014 the orders the web client shows again in "Modify orders": whether they are committed, and the deploys, moves (with their options), card plays (card GUID and targets: territory, player, bonus, Airlift from/to/armies, Order Delay \`before\`) and discards in exactly the shape warapp_submit_turn takes (ids; players by GameFeed id), plus \`shown\`, one readable line per order with names. Use it before warapp_uncommit_turn, or after, to resubmit a committed turn unchanged or with one order added \u2014 hand-made orders included. \`orders\` is null when war.app sent none or the board could not be read: unknown, never "none". Committed orders are verified live; entered but uncommitted ones are not. Refuses outside a turn phase. ${BRIDGE_NOTE} Read-only.`
159768
+ ),
159769
+ _meta: lookupMeta(["my orders", "my committed orders", "read back my orders", "resubmit my turn", "modify orders", "what did i order"]),
159770
+ annotations: readAnnotations("Read back my war.app orders"),
159771
+ inputSchema: external_exports.object({ game_id: gameIdArg })
159772
+ },
159773
+ async ({ game_id }) => {
159774
+ const gameId = parseGameId(game_id);
159775
+ const game = await ctx.client.getGame(gameId);
159776
+ requireTurnPhase(game);
159777
+ const token = await ctx.myInviteToken().catch(() => void 0);
159778
+ if (token === void 0) throw accountUnknown(ctx, "your orders cannot be read");
159779
+ const seat = game.players.find((p) => p.id === token);
159780
+ if (!seat) {
159781
+ throw new McpToolError(`The signed-in war.app account is not a player in game ${game.id}.`, {
159782
+ hint: "Check the game id with warapp_my_games."
159783
+ });
159784
+ }
159785
+ const { read, failure: failure2 } = await readMyOrders(ctx, game);
159786
+ const warnings = failure2 ? [`The live board could not be read (${failure2}): your orders are unknown.`] : [];
159787
+ return respond(void 0, ["compact"], () => ({
159788
+ game: { id: game.id, name: game.name === void 0 ? null : untrustedText(game.name), turn: currentTurn(game) },
159789
+ committed: seat.hasCommittedOrders,
159790
+ orders: read?.orders ?? null,
159791
+ shown: read ? shownOrders(read.orders, game) : null,
159792
+ ...read?.unread.length ? { unread: read.unread } : {},
159793
+ note: !read ? UNKNOWN_NOTE : seat.hasCommittedOrders ? COMMITTED_NOTE : ENTERED_NOTE,
159794
+ ...read?.unread.length ? {
159795
+ unreadNote: "Orders war.app holds that this server could not read back: they are not in `orders`, so resubmitting `orders` would drop them. Check the web client."
159796
+ } : {},
159797
+ ...warnings.length ? { warnings } : {}
159798
+ }));
159799
+ }
159800
+ );
159801
+ }
159802
+
159468
159803
  // src/tools/uncommit.ts
159469
159804
  var UNCOMMIT_ERRORS = {
159470
159805
  99: "The other players committed their orders first, so the turn is resolving with yours; they could not be withdrawn.",
@@ -159493,7 +159828,7 @@ function registerUncommitTool(server, ctx) {
159493
159828
  },
159494
159829
  {
159495
159830
  name: "warapp_uncommit_turn",
159496
- description: `Withdraw your committed orders for the current turn of a war.app (Warzone) game (war.app's UnCommit, the client's "Modify orders"), so a corrected turn can be submitted with warapp_submit_turn before the turn resolves. Refuses outside a turn phase, for a game you are not playing, or when your orders are not committed. The game then waits on you again, so recommit before the boot timer runs out. Always as the signed-in war.app account; the outcome is read back from GameFeed (\`uncommitted\`, \`unconfirmed\`, or \`unknown\` when war.app did not answer \u2014 never resend blindly). A truce recorded broken-by-me on that turn stays recorded (\`agreementsStillBroken\`). ${BRIDGE_NOTE} ${CONFIRM_INJECTION_RULE}`,
159831
+ description: `Withdraw your committed orders for the current turn of a war.app (Warzone) game (war.app's UnCommit, the client's "Modify orders"), so a corrected turn can be submitted with warapp_submit_turn before the turn resolves. Refuses outside a turn phase, for a game you are not playing, or when your orders are not committed. The game then waits on you again, so recommit before the boot timer runs out. Always as the signed-in war.app account; the outcome is read back from GameFeed (\`uncommitted\`, \`unconfirmed\`, or \`unknown\` when war.app did not answer \u2014 never resend blindly). A truce recorded broken-by-me on that turn stays recorded (\`agreementsStillBroken\`). The orders being withdrawn are read back first and carried in the preview and the result (\`withdrawnOrders\`, in warapp_submit_turn's shape; null when unreadable), and warapp_get_my_orders reads them any time. ${BRIDGE_NOTE} ${CONFIRM_INJECTION_RULE}`,
159497
159832
  annotations: toolAnnotations({
159498
159833
  title: "Withdraw committed war.app orders",
159499
159834
  readOnly: false,
@@ -159510,6 +159845,17 @@ function registerUncommitTool(server, ctx) {
159510
159845
  const name = game.name ?? `game ${game.id}`;
159511
159846
  const turn = currentTurn(game);
159512
159847
  const turnLabel = turn === null ? "this turn" : `turn ${turn}`;
159848
+ const mine3 = await readMyOrders(ctx, game);
159849
+ const withdrawn = mine3.read ? {
159850
+ orders: mine3.read.orders,
159851
+ shown: shownOrders(mine3.read.orders, game),
159852
+ ...mine3.read.unread.length ? { unread: mine3.read.unread } : {},
159853
+ note: "Your committed orders as war.app holds them: pass `orders` to warapp_submit_turn to resubmit them."
159854
+ } : {
159855
+ orders: null,
159856
+ // The failure's own words stay out: the preview is what the user approves, and a retry's wording may differ.
159857
+ note: mine3.failure ? "Your committed orders could not be read (the live board did not answer): note them in the web client before withdrawing." : "war.app sent no list of your committed orders, so they are unknown: note them in the web client before withdrawing."
159858
+ };
159513
159859
  return {
159514
159860
  gate: {
159515
159861
  action: "warapp.uncommit_turn",
@@ -159524,6 +159870,7 @@ function registerUncommitTool(server, ctx) {
159524
159870
  warning: `This withdraws your committed orders for ${turnLabel} of game ${game.id}. The game then waits on you again: submit corrected orders with warapp_submit_turn before the boot timer runs out, or you may be booted.`,
159525
159871
  account: shownAccount(seat.name, seat.id),
159526
159872
  game: { id: game.id, name: game.name === void 0 ? null : untrustedText(game.name), turn },
159873
+ withdrawnOrders: withdrawn,
159527
159874
  untrusted: UNTRUSTED_PREVIEW_NOTE
159528
159875
  }
159529
159876
  },
@@ -159532,13 +159879,14 @@ function registerUncommitTool(server, ctx) {
159532
159879
  name,
159533
159880
  me: seat.id,
159534
159881
  turnsBefore: game.numberOfTurns ?? null,
159535
- turn
159882
+ turn,
159883
+ withdrawnOrders: mine3.read?.orders ?? null
159536
159884
  }
159537
159885
  };
159538
159886
  },
159539
- async execute({ gameId, name, me, turnsBefore, turn }) {
159887
+ async execute({ gameId, name, me, turnsBefore, turn, withdrawnOrders }) {
159540
159888
  await requireApprovedAccount(ctx, writeAccount(me));
159541
- const base = { game: { id: gameId, name }, turn };
159889
+ const base = { game: { id: gameId, name }, turn, withdrawnOrders };
159542
159890
  const check2 = "Check warapp_get_game (your committed flag, the turn count) before doing anything else.";
159543
159891
  const unconfirmed = (warning) => ({ status: "unconfirmed", outcome: "unconfirmed", ...base, warning });
159544
159892
  return sendAndVerify({
@@ -159573,7 +159921,7 @@ function registerUncommitTool(server, ctx) {
159573
159921
  status: "uncommitted",
159574
159922
  outcome: "confirmed",
159575
159923
  ...base,
159576
- detail: "Your orders are withdrawn and the game is waiting on you again: submit corrected orders with warapp_submit_turn (e.g. from warapp_plan_turn) before the boot timer runs out.",
159924
+ detail: "Your orders are withdrawn and the game is waiting on you again: submit corrected orders with warapp_submit_turn before the boot timer runs out \u2014 `withdrawnOrders` as they were (or edited), or a new plan from warapp_plan_turn.",
159577
159925
  ...stillBroken.length ? {
159578
159926
  agreementsStillBroken: stillBroken,
159579
159927
  warning: `${stillBroken.length === 1 ? "Agreement" : "Agreements"} ${stillBroken.join(", ")} ${stillBroken.length === 1 ? "is" : "are"} recorded broken-by-me on turn ${turn} (warapp_submit_turn's break_agreement, when these orders were committed). If the withdrawn orders were that break, they never ran, but broken-by-me is final: the ledger and the partner's player record keep it, and this withdrawal does not undo it. Tell the owner; record a new agreement (warapp_record_agreement) if the truce is to go on.`
@@ -161560,6 +161908,7 @@ function registerAllTools(server, deps = {}) {
161560
161908
  registerWhereTool(server, live, deps.env ? { env: deps.env } : {});
161561
161909
  registerProfileOpponentsTool(server, live, deps.env ? { env: deps.env } : {});
161562
161910
  registerUncommitTool(server, live);
161911
+ registerMyOrdersTool(server, live);
161563
161912
  registerChatTools(server, live, deps.env ? { env: deps.env } : {});
161564
161913
  registerChatInboxTool(server, live);
161565
161914
  registerMarkChatReadTool(server, live);