@qianhaoq/dsh-dota2ai 0.2.14 → 0.2.15

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 (2) hide show
  1. package/lib/index.js +57 -64
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -13141,7 +13141,7 @@ import { join as join5 } from "node:path";
13141
13141
 
13142
13142
  // lib/agent/review/schema.js
13143
13143
  var DEEP_REVIEW_SCHEMA = "dota2.ai/deep-review@1";
13144
- var DEEP_REVIEW_PROMPT_VERSION = 80;
13144
+ var DEEP_REVIEW_PROMPT_VERSION = 81;
13145
13145
  var MAX_REFS = 3;
13146
13146
  var MAX_FINDINGS = 3;
13147
13147
  var MAX_HIGHLIGHTS = 4;
@@ -17675,6 +17675,8 @@ init_knowledge();
17675
17675
  var require5 = createRequire4(import.meta.url);
17676
17676
  var ITEM_NAMES4 = names_default.items;
17677
17677
  var ABILITY_TEXT = abilities_default2;
17678
+ var HERO_CONST = heroes_default;
17679
+ var ITEM_CONST = items_default;
17678
17680
  var DMG_WORD2 = { P: "physical", M: "magical", U: "pure" };
17679
17681
  var TOP_KILLERS = 2;
17680
17682
  var BY_SLUG2 = HEROES_BY_KEY;
@@ -17744,6 +17746,21 @@ var ATTACK_WAYS = [
17744
17746
  ["evasion", (it) => stat(it, "bonus_evasion") > 0],
17745
17747
  ["armor", (it) => stat(it, "bonus_armor") >= ARMOR_WORTH_NAMING]
17746
17748
  ];
17749
+ function dispelOf(text) {
17750
+ if (/strong dispel/i.test(text)) return "strong";
17751
+ if (/basic dispel|dispels? the target/i.test(text)) return "basic";
17752
+ return null;
17753
+ }
17754
+ function dispelTarget(key, text) {
17755
+ const team = ITEM_CONST[key]?.target_team;
17756
+ const teams = (Array.isArray(team) ? team : [team]).filter(Boolean);
17757
+ if (teams.includes("Enemy") || teams.includes("Both") || /can (?:only )?be cast on[^.]*enemy units|dispels the target/i.test(text)) return "an_enemy_target";
17758
+ const beh = ITEM_CONST[key]?.behavior;
17759
+ if (teams.includes("Friendly") || (Array.isArray(beh) ? beh : [beh]).includes("No Target") || /applies a (basic|strong) dispel|is applied and you/i.test(text)) return "self_or_allies";
17760
+ return null;
17761
+ }
17762
+ var DISPEL_WAY = ["applies_a_dispel", (it, text) => dispelOf(text) != null];
17763
+ ATTACK_WAYS.push(DISPEL_WAY);
17747
17764
  var SPELL_WAYS = [
17748
17765
  ["spell_immunity", (it, text) => /negative effect from enemy spells has no effect|debuff immunity to (yourself|you)/i.test(text)],
17749
17766
  ["magic_damage_barrier", (it, text) => /magic damage barrier/i.test(text)],
@@ -17760,7 +17777,13 @@ function waysOf(it, ways) {
17760
17777
  const text = (it?.abilities ?? []).map((a) => `${a?.title ?? ""}: ${a?.description ?? ""}`).join(" ");
17761
17778
  return ways.filter(([, test]) => test(it, text)).map(([w]) => w);
17762
17779
  }
17763
- var MAX_ITEMS_ON_THEIR_DAMAGE = 14;
17780
+ function attackOf(heroId, constants = HERO_CONST) {
17781
+ const h = heroId == null ? null : constants?.[String(heroId)];
17782
+ const type = typeof h?.attack_type === "string" ? h.attack_type.toLowerCase() : null;
17783
+ if (type !== "melee" && type !== "ranged") return null;
17784
+ return { type, ...Number.isFinite(h.attack_range) ? { range: h.attack_range } : {} };
17785
+ }
17786
+ var MAX_ITEMS_ON_THEIR_DAMAGE = 18;
17764
17787
  function roleOf(match, hero, trace = null, seatKey = null) {
17765
17788
  let coachRole = null;
17766
17789
  let coachHero = null;
@@ -17970,8 +17993,31 @@ function buildCheck(trace, args = {}, ctx = {}) {
17970
17993
  const against = a >= b ? "attacks" : "abilities";
17971
17994
  const ways = against === "attacks" ? ATTACK_WAYS : SPELL_WAYS;
17972
17995
  const items = shopBig.map((k3) => ({ k: k3, how: waysOf(pd.items[k3], ways) })).filter((x) => x.how.length).sort((x, y) => (pd.items[x.k].cost ?? 0) - (pd.items[y.k].cost ?? 0) || x.k.localeCompare(y.k)).slice(0, MAX_ITEMS_ON_THEIR_DAMAGE);
17973
- return { against_their: against, items: items.map(({ k: k3, how }) => ({ ...itemEntry(k3), how })) };
17996
+ const kit = theirKit(e.enemy);
17997
+ const relation = (k3) => {
17998
+ const it = pd.items[k3];
17999
+ const text = (it?.abilities ?? []).map((x) => `${x?.title ?? ""}: ${x?.description ?? ""}`).join(" ");
18000
+ const dispel = dispelOf(text);
18001
+ const removable = dispel ? kit.filter((a2) => a2.dispelled_by === "basic" || dispel === "strong" && a2.dispelled_by === "strong").map((a2) => a2.name) : [];
18002
+ const on = dispel ? dispelTarget(k3, text) : null;
18003
+ const disarm = { melee: stat(it, "disarm_melee"), ranged: stat(it, "disarm_range") };
18004
+ return {
18005
+ // `dispel_lands_on`: an enemy it is cast on (removes what sits on that enemy), or the player and allies
18006
+ // (removes what sits on them); null when the data does not say.
18007
+ ...dispel ? { applies_dispel: dispel, dispel_lands_on: on, their_abilities_marked_removable_by_it: removable } : {},
18008
+ ...disarm.melee != null || disarm.ranged != null ? { disarm_seconds: Object.fromEntries(Object.entries(disarm).filter(([, v]) => v != null)) } : {},
18009
+ .../pierces debuff immunity/i.test(text) ? { goes_through_debuff_immunity: true } : {}
18010
+ };
18011
+ };
18012
+ return { against_their: against, items: items.map(({ k: k3, how }) => ({ ...itemEntry(k3), how, ...relation(k3) })) };
18013
+ };
18014
+ const theirKit = (enemy) => {
18015
+ const other2 = BY_SLUG2.get(enemy);
18016
+ const list = other2 ? pd.heroAbilities(other2.id) : null;
18017
+ return Array.isArray(list) ? list.map((a) => ({ name: a[lang] ?? a.en, dispelled_by: a.dispel ?? null })) : [];
17974
18018
  };
18019
+ const theirAttack = (other2) => attackOf(other2?.id);
18020
+ const theirBigItems = (enemy) => (itemTimeline(trace, { hero: enemy }).items ?? []).filter((i) => big(i.item)).sort((x, y) => x.first_held.t - y.first_held.t).map((i) => ({ item: i.item, name: itemName2(i.item, lang), first_held: i.first_held.clock }));
17975
18021
  const answersToTopKillers = killers.map((e) => {
17976
18022
  const other2 = BY_SLUG2.get(e.enemy);
17977
18023
  const abilities = other2 ? pd.heroAbilities(other2.id) : null;
@@ -17993,9 +18039,14 @@ function buildCheck(trace, args = {}, ctx = {}) {
17993
18039
  // Absent means Valve's data does not say; it is not "no".
17994
18040
  ...typeof a.pierces === "boolean" ? { goes_through_spell_immunity: a.pierces } : {},
17995
18041
  ...a.dispel ? { dispelled_by: a.dispel } : {},
18042
+ // How it is cast, in OpenDota's words ("No Target", "Passive", "Unit Target"); absent when not listed.
18043
+ ...ABILITY_TEXT[a.id]?.behavior ? { cast: ABILITY_TEXT[a.id].behavior } : {},
17996
18044
  ...text ? { valve_text: String(text).replace(/\s+/g, " ").slice(0, 320) } : {}
17997
18045
  };
17998
18046
  }) : null,
18047
+ // Null when the constants do not say: unknown, not "ranged" or "melee".
18048
+ their_attack: theirAttack(other2),
18049
+ their_big_items: theirBigItems(e.enemy),
17999
18050
  // The shop's big items whose Valve data acts on the kind of damage this enemy did in the player's deaths, cheapest
18000
18051
  // first, each with what it does: every one, whatever the player's role. The model weighs them (cost, timing, this
18001
18052
  // hero's kit); no item is picked here. Null when the split of the damage is not known.
@@ -18064,7 +18115,7 @@ function buildCheck(trace, args = {}, ctx = {}) {
18064
18115
  most_built_in_this_bracket: bracketCore,
18065
18116
  most_built_by_pros_on_this_hero: core.length ? { pro_games: row.games, played_on_releases: row.releases, ...fromBefore ? { from_the_patch_before_this_game: true } : sample.few_games ? { few_games: true } : {}, window: "finished between 10:00 and 24:59", items: core } : null,
18066
18117
  gap_closers: { mine: myGap ? { item: myGap.item, name: itemName2(myGap.item, lang), first_held: myGap.first_held.clock } : null, enemies: theirGaps },
18067
- note: `answers_to_top_killers is per enemy who killed the player most: Valve's text of that hero's abilities (valve_text is the current release's wording; the flags are this game's release), the shop's big items whose Valve data acts on the kind of damage that enemy did in the deaths (items_acting_on_their_damage: against_their attacks or abilities, cheapest first, \`how\` each acts on it, read off this patch's item data, whatever the role \u2014 a list to weigh, not a pick), the items pros on this hero build clearly more often against it (association, not proof); known_for is the site's curated threat tags of that hero. built_for is what the site's curated lists and Valve's item stats say an item is for; an empty list means "not classified", not "offensive". On my_big_items_in_order, first_purchased is when the player finished buying the item (direct buy or last required component/recipe, null if absent/ambiguous), first_held is when it first sat in a usable inventory slot (not stash, backpack, or courier), delivery_delay_seconds is first_held minus first_purchased when positive, and my_team_courier_deaths_during_delivery lists hero-killed team couriers in [first_purchased, first_held] (a factual lead, not proof of courier owner or cargo). estimated_minutes_of_my_farm = item cost / my_economy.gold_per_min when that is known; "gives" and "does" are Valve's data. player_already_held_for_this_purpose groups big items the player already finished by the threats they cover. Shares of damage are over the 12 seconds before each death, of all damage taken in them (the two sums count enemy heroes only). An item built from a big item already held counts only the gold on top of it (gold_on_top_of_items_already_held). Pro shares are professional games, not this bracket; most_built_in_this_bracket (when present) is public games of this bracket and role (STRATZ).`,
18118
+ note: `answers_to_top_killers is per enemy who killed the player most: Valve's text of that hero's abilities (valve_text is the current release's wording; the flags are this game's release), the shop's big items whose Valve data acts on the kind of damage that enemy did in the deaths (items_acting_on_their_damage: against_their attacks or abilities, cheapest first, \`how\` each acts on it, read off this patch's item data, whatever the role \u2014 a list to weigh, not a pick; with an item's dispel: applies_dispel, dispel_lands_on an enemy it is cast on or on self_or_allies, and their_abilities_marked_removable_by_it \u2014 which of that enemy's abilities Valve marks removable by that dispel, wherever the effect sits, as the ability's own text says; disarm_seconds; goes_through_debuff_immunity), their_attack (melee or ranged, range) and their_big_items (with when each was first held), the items pros on this hero build clearly more often against it (association, not proof); known_for is the site's curated threat tags of that hero. built_for is what the site's curated lists and Valve's item stats say an item is for; an empty list means "not classified", not "offensive". On my_big_items_in_order, first_purchased is when the player finished buying the item (direct buy or last required component/recipe, null if absent/ambiguous), first_held is when it first sat in a usable inventory slot (not stash, backpack, or courier), delivery_delay_seconds is first_held minus first_purchased when positive, and my_team_courier_deaths_during_delivery lists hero-killed team couriers in [first_purchased, first_held] (a factual lead, not proof of courier owner or cargo). estimated_minutes_of_my_farm = item cost / my_economy.gold_per_min when that is known; "gives" and "does" are Valve's data. player_already_held_for_this_purpose groups big items the player already finished by the threats they cover. Shares of damage are over the 12 seconds before each death, of all damage taken in them (the two sums count enemy heroes only). An item built from a big item already held counts only the gold on top of it (gold_on_top_of_items_already_held). Pro shares are professional games, not this bracket; most_built_in_this_bracket (when present) is public games of this bracket and role (STRATZ).`,
18068
18119
  gaps: [
18069
18120
  ...role.kind ? [] : [{ topic: "role", reason: ctx.match ? role.gaps[0] ?? "role_not_established" : "no_match_data_for_this_game" }],
18070
18121
  ...economy ? [
@@ -18180,7 +18231,7 @@ var HERO2 = { type: "string", description: `Hero key as in match_overview, e.g.
18180
18231
  var SITUATION_TOOLS = [
18181
18232
  {
18182
18233
  name: "build_check",
18183
- description: "The player's build against what killed them. Gives their role and 1\u20135 position (from parsed match lanes or inferred from the replay), their economy (`my_economy`: GPM, net worth / 20:00 gold when known), where the damage in their deaths came from (which enemy, attacks or abilities), each big item they bought in order with its purchase vs delivery timing (`first_purchased`, `first_held`, positive `delivery_delay_seconds`, and any `my_team_courier_deaths_during_delivery`, alongside match-wide `my_team_courier_deaths`), its cost, what Valve lists for it and what it is for (built_for: an answer to attack damage, to spell damage, to disables, a gap closer, magic resistance, armor \u2014 empty means not classified), the gold put into each purpose, which big items the player already held for each purpose (player_already_held_for_this_purpose), for each of the (up to two) enemies who killed them most what that hero's abilities do in Valve's words, the shop's big items whose Valve data acts on that enemy's kind of damage (disarm, push, physical immunity, damage block or return, lowered attack speed, armor; or spell immunity, magic barrier, magic resistance) with their cost, and the items pros on this hero build clearly more often against that hero (answers_to_top_killers), each with what it does, `estimated_minutes_of_my_farm` (item cost divided by the player's GPM) and whether the player held it, what players of this bracket and role build on the hero in public games (most_built_in_this_bracket, when known), the hero's most-built professional items with when the player had them, and when each side got its first gap closer (Blink Dagger and the like). Use it before saying anything about what an item is, what the player's build answered, or what to buy.",
18234
+ description: "The player's build against what killed them. Gives their role and 1\u20135 position (from parsed match lanes or inferred from the replay), their economy (`my_economy`: GPM, net worth / 20:00 gold when known), where the damage in their deaths came from (which enemy, attacks or abilities), each big item they bought in order with its purchase vs delivery timing (`first_purchased`, `first_held`, positive `delivery_delay_seconds`, and any `my_team_courier_deaths_during_delivery`, alongside match-wide `my_team_courier_deaths`), its cost, what Valve lists for it and what it is for (built_for: an answer to attack damage, to spell damage, to disables, a gap closer, magic resistance, armor \u2014 empty means not classified), the gold put into each purpose, which big items the player already held for each purpose (player_already_held_for_this_purpose), for each of the (up to two) enemies who killed them most what that hero's abilities do in Valve's words, how that enemy attacks (melee or ranged) and the big items they held with when, the shop's big items whose Valve data acts on that enemy's kind of damage (disarm, push, physical immunity, damage block or return, lowered attack speed, armor, a dispel \u2014 on whom it lands and which of that enemy's abilities Valve marks removable by it; or spell immunity, magic barrier, magic resistance) with their cost, and the items pros on this hero build clearly more often against that hero (answers_to_top_killers), each with what it does, `estimated_minutes_of_my_farm` (item cost divided by the player's GPM) and whether the player held it, what players of this bracket and role build on the hero in public games (most_built_in_this_bracket, when known), the hero's most-built professional items with when the player had them, and when each side got its first gap closer (Blink Dagger and the like). Use it before saying anything about what an item is, what the player's build answered, or what to buy.",
18184
18235
  input_schema: { type: "object", properties: { hero: HERO2 }, required: ["hero"], additionalProperties: false },
18185
18236
  run: buildCheck
18186
18237
  },
@@ -25354,7 +25405,6 @@ function createTracePipeline(deps) {
25354
25405
 
25355
25406
  // lib/agent/service.js
25356
25407
  var HERO_BY_SLUG2 = HEROES_BY_KEY;
25357
- var FALLBACK_PROBE_WINDOW = 10;
25358
25408
  var MAX_KEPT_JOBS = 200;
25359
25409
  var BEAT_MS = 15e3;
25360
25410
  var STALE_MS = 9e4;
@@ -25429,13 +25479,6 @@ function createAgentService(deps) {
25429
25479
  return null;
25430
25480
  }
25431
25481
  };
25432
- const listKeys = async (prefix) => {
25433
- try {
25434
- return typeof docs?.list === "function" ? await docs.list(prefix) : null;
25435
- } catch {
25436
- return null;
25437
- }
25438
- };
25439
25482
  const write = async (key, value) => {
25440
25483
  try {
25441
25484
  if (docs) await docs.put(key, value);
@@ -25538,52 +25581,7 @@ function createAgentService(deps) {
25538
25581
  return extractLegacyRecord(legacy, L3, check, version);
25539
25582
  };
25540
25583
  const storedExact = (matchId, hero, lang, plan = null, model = null) => storedAtVersion(matchId, hero, lang, plan, model, DEEP_REVIEW_PROMPT_VERSION);
25541
- const storedFallback = async (matchId, hero, lang, plan = null, model = null) => {
25542
- if (!docs || DEEP_REVIEW_PROMPT_VERSION <= 1) return null;
25543
- const L3 = normalizeUiLang(lang);
25544
- const check = { hero, matchId, plan };
25545
- if (typeof docs.list === "function") {
25546
- const prefix = `${matchId}.${hero}.`;
25547
- const keys = await listKeys(prefix);
25548
- if (!Array.isArray(keys)) return null;
25549
- const modelId = idOf(model);
25550
- const tail = `${plan ? `.plan-${plan}` : ""}${modelId && modelId !== DEFAULT_AGENT_MODEL ? `.m-${modelId}` : ""}.review.json`;
25551
- const byVersion = /* @__PURE__ */ new Map();
25552
- for (const k3 of keys) {
25553
- if (!k3.startsWith(prefix) || !k3.endsWith(tail) || k3.length <= prefix.length + tail.length) continue;
25554
- const mid = k3.slice(prefix.length, k3.length - tail.length);
25555
- const match = /^(?:([a-z]{2})\.)?p([1-9]\d*)$/.exec(mid);
25556
- if (!match) continue;
25557
- if (match[1] && match[1] !== L3) continue;
25558
- const v = Number(match[2]);
25559
- if (!Number.isSafeInteger(v) || v < 1 || v >= DEEP_REVIEW_PROMPT_VERSION) continue;
25560
- const slot = byVersion.get(v) ?? {};
25561
- if (match[1]) slot.perLang = k3;
25562
- else slot.bundle = k3;
25563
- byVersion.set(v, slot);
25564
- }
25565
- const versions = [...byVersion.keys()].sort((a, b) => b - a);
25566
- for (const v of versions) {
25567
- const slot = byVersion.get(v);
25568
- if (slot.bundle) {
25569
- const hit = extractBundleRecord(await read(slot.bundle), L3, check, v);
25570
- if (hit) return hit;
25571
- }
25572
- if (slot.perLang) {
25573
- const hit = extractLegacyRecord(await read(slot.perLang), L3, check, v);
25574
- if (hit) return hit;
25575
- }
25576
- }
25577
- return null;
25578
- }
25579
- const floor = Math.max(1, DEEP_REVIEW_PROMPT_VERSION - FALLBACK_PROBE_WINDOW);
25580
- for (let v = DEEP_REVIEW_PROMPT_VERSION - 1; v >= floor; v -= 1) {
25581
- const hit = await storedAtVersion(matchId, hero, L3, plan, model, v);
25582
- if (hit) return hit;
25583
- }
25584
- return null;
25585
- };
25586
- const stored = async (matchId, hero, lang, plan = null, model = null) => await storedExact(matchId, hero, lang, plan, model) ?? await storedFallback(matchId, hero, lang, plan, model);
25584
+ const stored = storedExact;
25587
25585
  async function parseState(matchId) {
25588
25586
  const id = String(matchId);
25589
25587
  const local = parses.get(id);
@@ -25911,11 +25909,6 @@ function createAgentService(deps) {
25911
25909
  if (marker?.state === "running" && now() - (marker.at ?? 0) < REVIEW_STALE_MS && (job?.state !== "failed" || (marker.at ?? 0) >= (job.at ?? 0))) return { status: "running", steps: marker.steps ?? [] };
25912
25910
  const hasFailed = job?.state === "failed" || marker?.state === "failed" && now() - (marker.at ?? 0) < 6e4;
25913
25911
  const failedReason = job?.state === "failed" ? job.reason : marker?.reason;
25914
- const fallback = await storedFallback(matchId, key, L3, p, m);
25915
- if (fallback) {
25916
- const payload = readyPayload(fallback, fallback.review, fallback.prompt_version);
25917
- return hasFailed ? { ...payload, refresh_failed: { reason: failedReason ?? null } } : payload;
25918
- }
25919
25912
  if (hasFailed) return { status: "failed", reason: failedReason };
25920
25913
  return { status: "none" };
25921
25914
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qianhaoq/dsh-dota2ai",
3
- "version": "0.2.14",
3
+ "version": "0.2.15",
4
4
  "description": "dota2.ai for DSH: standalone replay review page, DSH host-model agent, coach tools and skill",
5
5
  "icon": "./icon.svg",
6
6
  "homepage": "https://dota2.ai",