dsh-multigameassistant 2.2.3 → 2.3.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/cordis.patch.yml +6 -2
- package/lib/analyzer.js +80 -15
- package/lib/{chunk-LXHF6AKU.js → chunk-7EFZ5KR6.js} +99 -6
- package/lib/{chunk-YTIR5JW4.js → chunk-AJMAUHPI.js} +7 -5
- package/lib/{chunk-RGEGJH6R.js → chunk-TXW3NMBH.js} +209 -10
- package/lib/{chunk-6NJSSOB6.js → chunk-VBWSM7LF.js} +8 -5
- package/lib/{chunk-A6YQRWHZ.js → chunk-VG32XPZH.js} +2 -2
- package/lib/{chunk-TELJUUBZ.js → chunk-X5YYRNYA.js} +24 -13
- package/lib/{chunk-KMVQK5CI.js → chunk-Y3ZZBBLV.js} +1 -1
- package/lib/emulator.js +810 -12
- package/lib/feishu.js +4 -4
- package/lib/game-intel.js +1006 -53
- package/lib/gateway.js +3 -3
- package/lib/guard.js +159 -42
- package/lib/intervene.js +4 -4
- package/lib/low-context.js +2 -2
- package/lib/monitor.js +3 -3
- package/lib/notify.js +4 -4
- package/lib/orchestrator.js +6 -6
- package/lib/qqbot.js +4 -4
- package/lib/runner.js +3 -3
- package/lib/scheduler.js +1 -1
- package/lib/script-registry.js +6 -6
- package/package.json +1 -1
- package/skills/game-intel.md +12 -0
- package/skills/script-analysis.md +27 -2
- package/web/assets/index-CNGPsX3a.css +1 -0
- package/web/assets/index-mX8hPa2E.js +256 -0
- package/web/assets/index-mX8hPa2E.js.map +1 -0
- package/web/index.html +2 -2
- package/web/assets/index-DwItOcWq.css +0 -1
- package/web/assets/index-YiJ--jV1.js +0 -255
- package/web/assets/index-YiJ--jV1.js.map +0 -1
- /package/lib/{chunk-YTIR5JW4.js.LEGAL.txt → chunk-AJMAUHPI.js.LEGAL.txt} +0 -0
package/lib/game-intel.js
CHANGED
|
@@ -3,14 +3,16 @@ import {
|
|
|
3
3
|
GAME_GUIDE_FILE,
|
|
4
4
|
GAME_MANIFEST_FILE,
|
|
5
5
|
GameManifest,
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
GameSource,
|
|
7
|
+
parseGameManifest,
|
|
8
|
+
routineLogs
|
|
9
|
+
} from "./chunk-TXW3NMBH.js";
|
|
8
10
|
import {
|
|
9
11
|
finalText,
|
|
10
12
|
sessionConversations
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
13
|
+
} from "./chunk-VG32XPZH.js";
|
|
14
|
+
import "./chunk-VBWSM7LF.js";
|
|
15
|
+
import "./chunk-Y3ZZBBLV.js";
|
|
14
16
|
import {
|
|
15
17
|
ExeIcons,
|
|
16
18
|
writeFileAtomic
|
|
@@ -26,7 +28,7 @@ import {
|
|
|
26
28
|
SCREEN_SOURCE,
|
|
27
29
|
SHOT_IMAGE,
|
|
28
30
|
taskMessage
|
|
29
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-7EFZ5KR6.js";
|
|
30
32
|
import {
|
|
31
33
|
external_exports
|
|
32
34
|
} from "./chunk-6DSSLS7I.js";
|
|
@@ -37,8 +39,8 @@ import {
|
|
|
37
39
|
// packages/game-intel/lib/index.js
|
|
38
40
|
import { createHash as createHash2 } from "node:crypto";
|
|
39
41
|
import { existsSync } from "node:fs";
|
|
40
|
-
import { mkdir, readdir, readFile as
|
|
41
|
-
import { isAbsolute, join as
|
|
42
|
+
import { mkdir, readdir, readFile as readFile3, rm, stat, writeFile } from "node:fs/promises";
|
|
43
|
+
import { isAbsolute, join as join3, resolve } from "node:path";
|
|
42
44
|
import { Service } from "@deepseek-ai/cordis";
|
|
43
45
|
|
|
44
46
|
// packages/game-intel/lib/calendar.js
|
|
@@ -359,8 +361,18 @@ var Calendar = class {
|
|
|
359
361
|
return this.#saved.readings[game];
|
|
360
362
|
}
|
|
361
363
|
/** Banners still open. */
|
|
364
|
+
/** Banners still open: the data sites', then those the agent read on the web that no site lists. */
|
|
362
365
|
pools(game, now) {
|
|
363
|
-
|
|
366
|
+
const site = (this.#saved.pools[game] ?? []).filter((p) => p.endsAt > now);
|
|
367
|
+
const read = (this.#saved.pools[`${game}#agent`] ?? []).filter((p) => p.endsAt > now && !site.some((s) => sameEvent([s.name], [p.name])));
|
|
368
|
+
return [...site, ...read].sort((a, b) => a.endsAt - b.endsAt);
|
|
369
|
+
}
|
|
370
|
+
/** Banners the agent read on the web (game_pool): one of the same name is replaced; ended ones go. Kept apart from the sites', which a refresh replaces. */
|
|
371
|
+
async recordPools(game, pools, now) {
|
|
372
|
+
const key = `${game}#agent`;
|
|
373
|
+
const kept = (this.#saved.pools[key] ?? []).filter((p) => p.endsAt > now && !pools.some((n) => sameEvent([n.name], [p.name])));
|
|
374
|
+
this.#saved.pools[key] = [...kept, ...pools.map((p) => ({ ...p, up: [...p.up] }))];
|
|
375
|
+
await this.save();
|
|
364
376
|
}
|
|
365
377
|
/** Every picture address a data site gave: the only ones the host will fetch. */
|
|
366
378
|
pictures() {
|
|
@@ -450,6 +462,7 @@ var Calendar = class {
|
|
|
450
462
|
delete this.#saved.refreshed[gameId];
|
|
451
463
|
delete this.#saved.versions[gameId];
|
|
452
464
|
delete this.#saved.pools[gameId];
|
|
465
|
+
delete this.#saved.pools[`${gameId}#agent`];
|
|
453
466
|
delete this.#saved.links[gameId];
|
|
454
467
|
delete this.#saved.notices[gameId];
|
|
455
468
|
this.#saved.settings.hidden = this.#saved.settings.hidden.filter((id) => id !== gameId);
|
|
@@ -4579,8 +4592,15 @@ async function readSmw(smw, game, now, fetchImpl, signal) {
|
|
|
4579
4592
|
}
|
|
4580
4593
|
async function withCovers(api, pattern, events, fetchImpl, signal) {
|
|
4581
4594
|
const fileOf = (e) => `File:${pattern.replace("{page}", e.aliases[0] ?? e.name)}`;
|
|
4595
|
+
const urls = await fileUrls(api, events.map(fileOf), fetchImpl, signal);
|
|
4596
|
+
return events.map((e) => {
|
|
4597
|
+
const cover = urls.get(fileOf(e));
|
|
4598
|
+
return cover === void 0 ? e : { ...e, cover };
|
|
4599
|
+
});
|
|
4600
|
+
}
|
|
4601
|
+
async function fileUrls(api, files, fetchImpl, signal) {
|
|
4582
4602
|
const urls = /* @__PURE__ */ new Map();
|
|
4583
|
-
const titles = [...new Set(
|
|
4603
|
+
const titles = [...new Set(files)];
|
|
4584
4604
|
for (let i = 0; i < titles.length; i += 40) {
|
|
4585
4605
|
const chunk = titles.slice(i, i + 40);
|
|
4586
4606
|
try {
|
|
@@ -4598,11 +4618,107 @@ async function withCovers(api, pattern, events, fetchImpl, signal) {
|
|
|
4598
4618
|
} catch {
|
|
4599
4619
|
}
|
|
4600
4620
|
}
|
|
4601
|
-
return
|
|
4602
|
-
|
|
4603
|
-
|
|
4621
|
+
return urls;
|
|
4622
|
+
}
|
|
4623
|
+
function poolSince(src, now, timeZone) {
|
|
4624
|
+
return sinceText({ dates: src.dates === "text" ? "text" : "date" }, now, timeZone);
|
|
4625
|
+
}
|
|
4626
|
+
function poolValue(src, value, timeZone, now) {
|
|
4627
|
+
const at = readValue(value, timeZone, now);
|
|
4628
|
+
if (src.dates !== "local" || typeof at !== "number" || typeof value !== "object")
|
|
4629
|
+
return at;
|
|
4630
|
+
return at - zoneOffset(at, timeZone);
|
|
4631
|
+
}
|
|
4632
|
+
var FILE_PAGE = /^(?:文件|File|Image|图像):/i;
|
|
4633
|
+
function parsePools(results, src, timeZone, now) {
|
|
4634
|
+
if (typeof results !== "object" || results === null || Array.isArray(results))
|
|
4635
|
+
return [];
|
|
4636
|
+
const pools = [];
|
|
4637
|
+
const clean = (t) => t === void 0 || t.includes("{{{") ? void 0 : t;
|
|
4638
|
+
for (const [page, raw] of Object.entries(results)) {
|
|
4639
|
+
const out = raw.printouts ?? {};
|
|
4640
|
+
const first = (prop) => prop === void 0 ? void 0 : out[prop]?.[0];
|
|
4641
|
+
const endsAt = poolValue(src, first(src.end), timeZone, now);
|
|
4642
|
+
if (typeof endsAt !== "number" || endsAt < now)
|
|
4643
|
+
continue;
|
|
4644
|
+
const startsAt = poolValue(src, first(src.start), timeZone, now);
|
|
4645
|
+
const pageName = page.split("#").at(-1).replace(FILE_PAGE, "").replace(/.(?:png|jpe?g|gif|webp)$/i, "").trim();
|
|
4646
|
+
const name = clean(textValue(first(src.title))) ?? pageName;
|
|
4647
|
+
const type = clean(textValue(first(src.type)));
|
|
4648
|
+
const up = [...new Set(src.up.flatMap((prop) => (out[prop] ?? []).map(textValue)).map(clean).filter((t) => t !== void 0))];
|
|
4649
|
+
pools.push({ page: page.split("#")[0], name, endsAt, up, ...typeof startsAt === "number" ? { startsAt } : {}, ...type === void 0 ? {} : { type } });
|
|
4650
|
+
}
|
|
4651
|
+
return pools.sort((a, b) => a.endsAt - b.endsAt);
|
|
4652
|
+
}
|
|
4653
|
+
async function readPools(src, game, now, fetchImpl, signal) {
|
|
4654
|
+
const show = [src.title, src.type, src.start, src.end, ...src.up].filter((p) => p !== void 0).map((p) => `|?${p}`).join("");
|
|
4655
|
+
const query = `${src.conditions}[[${src.end}::>${poolSince(src, now, game.timezone)}]]${show}|limit=${src.limit}`;
|
|
4656
|
+
const timeout = AbortSignal.timeout(TIMEOUT_MS);
|
|
4657
|
+
let body;
|
|
4658
|
+
try {
|
|
4659
|
+
const response = await fetchImpl(`${src.api}?action=ask&format=json&query=${encodeURIComponent(query)}`, { signal: signal === void 0 ? timeout : AbortSignal.any([signal, timeout]), headers: { "user-agent": USER_AGENT, accept: "application/json" } });
|
|
4660
|
+
if (!response.ok)
|
|
4661
|
+
throw new Error(`HTTP ${response.status}`);
|
|
4662
|
+
body = await response.json();
|
|
4663
|
+
} catch (error) {
|
|
4664
|
+
const why = error instanceof Error ? error.name === "TimeoutError" ? `${TIMEOUT_MS / 1e3} \u79D2\u6CA1\u6709\u54CD\u5E94` : error.name === "SyntaxError" ? "\u8FD4\u56DE\u7684\u4E0D\u662F JSON\uFF08\u53EF\u80FD\u88AB\u7AD9\u70B9\u7684\u9632\u62A4\u62E6\u4E0B\u4E86\uFF09" : error.message : String(error);
|
|
4665
|
+
throw new Error(`${new URL(src.api).host} \u7684\u5361\u6C60\u8BFB\u4E0D\u5230\uFF1A${why}`);
|
|
4666
|
+
}
|
|
4667
|
+
if (body.error !== void 0)
|
|
4668
|
+
throw new Error(`${new URL(src.api).host} \u4E0D\u63A5\u53D7\u5361\u6C60\u67E5\u8BE2\uFF1A${body.error.info ?? "\u672A\u77E5\u9519\u8BEF"}`);
|
|
4669
|
+
const pools = parsePools(body.query?.results, src, game.timezone, now);
|
|
4670
|
+
const fileOf = (p) => FILE_PAGE.test(p.page) ? p.page : src.image === void 0 ? void 0 : `File:${src.image.replace("{page}", p.page)}`;
|
|
4671
|
+
const files = pools.map(fileOf).filter((f) => f !== void 0);
|
|
4672
|
+
const urls = files.length === 0 ? /* @__PURE__ */ new Map() : await fileUrls(src.api, files, fetchImpl, signal);
|
|
4673
|
+
return pools.map(({ page, ...p }) => {
|
|
4674
|
+
const f = fileOf({ page, name: p.name });
|
|
4675
|
+
const cover = f === void 0 ? void 0 : urls.get(f);
|
|
4676
|
+
return cover === void 0 ? p : { ...p, cover };
|
|
4604
4677
|
});
|
|
4605
4678
|
}
|
|
4679
|
+
function parseHoyo(body, now) {
|
|
4680
|
+
const banners = body?.banners;
|
|
4681
|
+
if (!Array.isArray(banners))
|
|
4682
|
+
throw new Error("\u683C\u5F0F\u4E0D\u5BF9\uFF08\u6CA1\u6709 banners\uFF09");
|
|
4683
|
+
const pools = [];
|
|
4684
|
+
for (const raw of banners) {
|
|
4685
|
+
const b = raw ?? {};
|
|
4686
|
+
const seconds = (v) => typeof v === "number" && v > 0 ? v * 1e3 : void 0;
|
|
4687
|
+
const endsAt = seconds(b["end_time"]);
|
|
4688
|
+
if (endsAt === void 0 || endsAt < now)
|
|
4689
|
+
continue;
|
|
4690
|
+
const startsAt = seconds(b["start_time"]);
|
|
4691
|
+
const items = ["characters", "weapons", "light_cones", "w_engines", "bangboos"].flatMap((k) => Array.isArray(b[k]) ? b[k] : []).filter((i) => typeof i["name"] === "string" && i["name"].trim() !== "").sort((x, y) => Number(y["rarity"] ?? 0) - Number(x["rarity"] ?? 0));
|
|
4692
|
+
if (items.length === 0)
|
|
4693
|
+
continue;
|
|
4694
|
+
const top = items[0];
|
|
4695
|
+
const icon = typeof top["icon"] === "string" && /^https:\/\/\S+$/.test(top["icon"]) ? top["icon"] : void 0;
|
|
4696
|
+
const weapon = !Array.isArray(b["characters"]) || b["characters"].length === 0;
|
|
4697
|
+
const named = typeof b["name"] === "string" && b["name"].trim() !== "" ? b["name"].trim() : void 0;
|
|
4698
|
+
pools.push({
|
|
4699
|
+
name: named ?? `${String(top["name"]).trim()}${weapon ? " \u6B66\u5668" : ""}`,
|
|
4700
|
+
endsAt,
|
|
4701
|
+
up: [...new Set(items.map((i) => String(i["name"]).trim()))],
|
|
4702
|
+
...startsAt === void 0 ? {} : { startsAt },
|
|
4703
|
+
...named === void 0 ? { type: weapon ? "\u6B66\u5668 / \u5149\u9525" : "\u89D2\u8272" } : {},
|
|
4704
|
+
...icon === void 0 ? {} : { cover: icon }
|
|
4705
|
+
});
|
|
4706
|
+
}
|
|
4707
|
+
return pools.sort((a, b) => a.endsAt - b.endsAt);
|
|
4708
|
+
}
|
|
4709
|
+
async function readHoyo(src, now, fetchImpl, signal) {
|
|
4710
|
+
const url = `${src.api.replace(/\/$/, "")}/${src.game}/calendar?lang=${src.lang}`;
|
|
4711
|
+
const timeout = AbortSignal.timeout(TIMEOUT_MS);
|
|
4712
|
+
try {
|
|
4713
|
+
const response = await fetchImpl(url, { signal: signal === void 0 ? timeout : AbortSignal.any([signal, timeout]), headers: { "user-agent": USER_AGENT, accept: "application/json" } });
|
|
4714
|
+
if (!response.ok)
|
|
4715
|
+
throw new Error(`HTTP ${response.status}`);
|
|
4716
|
+
return parseHoyo(await response.json(), now);
|
|
4717
|
+
} catch (error) {
|
|
4718
|
+
const why = error instanceof Error ? error.name === "TimeoutError" ? `${TIMEOUT_MS / 1e3} \u79D2\u6CA1\u6709\u54CD\u5E94` : error.message : String(error);
|
|
4719
|
+
throw new Error(`${new URL(src.api).host} \u7684\u5361\u6C60\u8BFB\u4E0D\u5230\uFF1A${why}`);
|
|
4720
|
+
}
|
|
4721
|
+
}
|
|
4606
4722
|
function parseSra(body, timeZone, now) {
|
|
4607
4723
|
const b = typeof body === "object" && body !== null ? body : {};
|
|
4608
4724
|
const str = (v) => typeof v === "string" && v.trim() !== "" ? v.trim() : void 0;
|
|
@@ -4812,6 +4928,26 @@ var DailyReport = class {
|
|
|
4812
4928
|
};
|
|
4813
4929
|
|
|
4814
4930
|
// packages/game-intel/lib/report.js
|
|
4931
|
+
var WEEK_WARN_MS = 2 * MS.DAY;
|
|
4932
|
+
function routineLines(game, now) {
|
|
4933
|
+
const lines = [];
|
|
4934
|
+
for (const [period, label] of [["daily", "\u65E5\u5E38"], ["weekly", "\u5468\u5E38"]]) {
|
|
4935
|
+
const list = (game.routines ?? []).filter((r) => r.period === period);
|
|
4936
|
+
if (list.length === 0)
|
|
4937
|
+
continue;
|
|
4938
|
+
const missing = list.filter((r) => r.done === void 0);
|
|
4939
|
+
const done = list.length - missing.length;
|
|
4940
|
+
const resets = list.find((r) => r.resetsAt !== void 0)?.resetsAt;
|
|
4941
|
+
if (missing.length === 0) {
|
|
4942
|
+
lines.push(`\xB7 ${label} ${done}/${list.length} \u90FD\u505A\u5B8C\u4E86`);
|
|
4943
|
+
continue;
|
|
4944
|
+
}
|
|
4945
|
+
const warn = period === "weekly" && resets !== void 0 && resets - now < WEEK_WARN_MS;
|
|
4946
|
+
const when = resets === void 0 ? "" : `\uFF08${shortDate(resets, game.timezone)} \u91CD\u7F6E${warn ? `\uFF0C${leftText(resets, now)}` : ""}\uFF09`;
|
|
4947
|
+
lines.push(`\xB7 ${warn ? "\u26A0 " : ""}${label} ${done}/${list.length}\uFF0C\u8FD8\u5DEE\uFF1A${missing.map((r) => r.name).join("\u3001")}${when}`);
|
|
4948
|
+
}
|
|
4949
|
+
return lines;
|
|
4950
|
+
}
|
|
4815
4951
|
var UPCOMING_MS = 3 * MS.DAY;
|
|
4816
4952
|
function buildReport(games, activities, settings, now) {
|
|
4817
4953
|
const local = wallClock(now, Intl.DateTimeFormat().resolvedOptions().timeZone);
|
|
@@ -4825,7 +4961,8 @@ function buildReport(games, activities, settings, now) {
|
|
|
4825
4961
|
const mine = activities.filter((a) => a.game === game.id);
|
|
4826
4962
|
const running = mine.filter((a) => (a.startsAt ?? 0) <= now && Math.max(a.endsAt ?? Infinity, a.shopEndsAt ?? 0) > now);
|
|
4827
4963
|
const upcoming = mine.filter((a) => a.startsAt !== void 0 && a.startsAt > now && a.startsAt - now <= UPCOMING_MS);
|
|
4828
|
-
|
|
4964
|
+
const routines = routineLines(game, now);
|
|
4965
|
+
if (running.length === 0 && upcoming.length === 0 && routines.length === 0)
|
|
4829
4966
|
continue;
|
|
4830
4967
|
const long = running.filter((a) => isLong(a) && a.todo.length === 0 && daysLeft(a.endsAt, now) >= settings.soonDays);
|
|
4831
4968
|
const lines = running.filter((a) => !long.includes(a)).map((a) => {
|
|
@@ -4844,7 +4981,7 @@ function buildReport(games, activities, settings, now) {
|
|
|
4844
4981
|
lines.push(`\xB7 \u957F\u671F\uFF1A${long.map((a) => `${a.name}\uFF08${leftText(a.endsAt, now)}\uFF09`).join("\u3001")}`);
|
|
4845
4982
|
}
|
|
4846
4983
|
sections.push(`\u3010${game.name}\u3011
|
|
4847
|
-
${lines.join("\n")}`);
|
|
4984
|
+
${[...routines, ...lines].join("\n")}`);
|
|
4848
4985
|
}
|
|
4849
4986
|
if (sections.length === 0)
|
|
4850
4987
|
return { title, text: "\u4ECA\u5929\u6CA1\u6709\u8FDB\u884C\u4E2D\u7684\u6D3B\u52A8\uFF08\u6216\u8005\u8FD8\u6CA1\u8BFB\u5230\uFF09\u3002\u53EF\u4EE5\u5728\u300C\u6E38\u620F\u300D\u9875\u5237\u65B0\u6570\u636E\u7AD9\uFF0C\u6216\u8BA9 agent \u8FDB\u6E38\u620F\u770B\u770B\u3002", count: 0 };
|
|
@@ -4883,9 +5020,10 @@ function recentDigest(games, activities, settings, now) {
|
|
|
4883
5020
|
text += `\uFF1B\u8FDB\u5EA6 ${a.progress}`;
|
|
4884
5021
|
lines.push(text);
|
|
4885
5022
|
}
|
|
4886
|
-
|
|
5023
|
+
const routines = routineLines(game, now);
|
|
5024
|
+
if (lines.length + routines.length > 0)
|
|
4887
5025
|
sections.push(`\u3010${game.name}\u3011
|
|
4888
|
-
${lines.join("\n")}`);
|
|
5026
|
+
${[...routines, ...lines].join("\n")}`);
|
|
4889
5027
|
}
|
|
4890
5028
|
return sections.length === 0 ? void 0 : sections.join("\n\n");
|
|
4891
5029
|
}
|
|
@@ -4960,6 +5098,7 @@ function matchScripts(scripts, games) {
|
|
|
4960
5098
|
var SRA_GAMES = [
|
|
4961
5099
|
{ sra: "sr", name: "\u5D29\u574F\uFF1A\u661F\u7A79\u94C1\u9053", timezone: "Asia/Shanghai", words: ["\u661F\u7A79\u94C1\u9053", "\u661F\u94C1", "\u5D29\u94C1", "Star Rail", "StarRail", "HSR", "March7th", "\u4E09\u6708\u4E03"] },
|
|
4962
5100
|
{ sra: "ys", name: "\u539F\u795E", timezone: "Asia/Shanghai", words: ["Genshin", "BetterGI", "better-genshin"] },
|
|
5101
|
+
{ sra: "bh3", name: "\u5D29\u574F3", timezone: "Asia/Shanghai", words: ["\u5D29\u574F3", "\u5D29\u574F\u4E09", "Honkai Impact 3", "HonkaiImpact3rd"] },
|
|
4963
5102
|
{ sra: "zzz", name: "\u7EDD\u533A\u96F6", timezone: "Asia/Shanghai", words: ["Zenless", "ZZZ", "OneDragon", "\u4E00\u6761\u9F99"] },
|
|
4964
5103
|
{ sra: "ww", name: "\u9E23\u6F6E", timezone: "Asia/Shanghai", words: ["Wuthering", "ok-ww", "okww", "WutheringWaves"] },
|
|
4965
5104
|
{ sra: "nte", name: "\u5F02\u73AF", timezone: "Asia/Shanghai", words: ["Neverness"] },
|
|
@@ -4986,6 +5125,253 @@ function followedManifest(game) {
|
|
|
4986
5125
|
sources: [{ id: "sra", name: "SRA \u516C\u5171 API", homepage: "https://starrailassistant.top/reference/public-api/", sra: { game: game.sra } }]
|
|
4987
5126
|
});
|
|
4988
5127
|
}
|
|
5128
|
+
var POOL_SOURCES = {
|
|
5129
|
+
// PRTS: one file page per banner (its key art), with the CN server's open and close times.
|
|
5130
|
+
ak: GameSource.parse({
|
|
5131
|
+
id: "prts-pools",
|
|
5132
|
+
name: "PRTS \u5BFB\u8BBF",
|
|
5133
|
+
homepage: "https://prts.wiki/w/\u5361\u6C60\u4E00\u89C8/\u9650\u65F6\u5BFB\u8BBF",
|
|
5134
|
+
pools: { api: "https://prts.wiki/api.php", conditions: "[[\u5BFB\u8BBF\u540Dcn::+]]", title: "\u5BFB\u8BBF\u540Dcn", start: "\u5BFB\u8BBF\u5F00\u542F\u65F6\u95F4cn", end: "\u5BFB\u8BBF\u5173\u95ED\u65F6\u95F4cn", up: ["\u51FA\u7387\u63D0\u5347\u5E72\u5458"] }
|
|
5135
|
+
}),
|
|
5136
|
+
ys: GameSource.parse({
|
|
5137
|
+
id: "hoyo-pools",
|
|
5138
|
+
name: "\u7948\u613F\uFF08ennead API\uFF09",
|
|
5139
|
+
homepage: "https://api.ennead.cc/mihoyo/genshin/calendar?lang=zh-cn",
|
|
5140
|
+
hoyo: { game: "genshin" }
|
|
5141
|
+
})
|
|
5142
|
+
};
|
|
5143
|
+
var givesPools = (s) => s.pools !== void 0 || s.hoyo !== void 0;
|
|
5144
|
+
function poolSources(manifest) {
|
|
5145
|
+
const own = manifest.sources.filter(givesPools);
|
|
5146
|
+
if (own.length > 0)
|
|
5147
|
+
return own;
|
|
5148
|
+
return [...new Set(manifest.sources.map((s) => s.sra?.game).filter((g) => g !== void 0))].map((g) => POOL_SOURCES[g]).filter((s) => s !== void 0);
|
|
5149
|
+
}
|
|
5150
|
+
|
|
5151
|
+
// packages/game-intel/lib/routines.js
|
|
5152
|
+
import { readFile as readFile2 } from "node:fs/promises";
|
|
5153
|
+
import { join as join2 } from "node:path";
|
|
5154
|
+
function hm(at) {
|
|
5155
|
+
const [h, m] = at.split(":").map(Number);
|
|
5156
|
+
return [h, m];
|
|
5157
|
+
}
|
|
5158
|
+
function dailyPeriod(now, timeZone, reset) {
|
|
5159
|
+
const [h, m] = hm(reset);
|
|
5160
|
+
const w = wallClock(now, timeZone);
|
|
5161
|
+
let start = zonedTime(w.year, w.month, w.day, h, m, timeZone);
|
|
5162
|
+
if (start > now)
|
|
5163
|
+
start = zonedTime(w.year, w.month, w.day - 1, h, m, timeZone);
|
|
5164
|
+
const s = wallClock(start, timeZone);
|
|
5165
|
+
return { start, end: zonedTime(s.year, s.month, s.day + 1, h, m, timeZone) };
|
|
5166
|
+
}
|
|
5167
|
+
function weeklyPeriod(now, timeZone, day, at) {
|
|
5168
|
+
const [h, m] = hm(at);
|
|
5169
|
+
const w = wallClock(now, timeZone);
|
|
5170
|
+
const weekday = (new Date(Date.UTC(w.year, w.month - 1, w.day)).getUTCDay() + 6) % 7 + 1;
|
|
5171
|
+
const back = (weekday - day + 7) % 7;
|
|
5172
|
+
let start = zonedTime(w.year, w.month, w.day - back, h, m, timeZone);
|
|
5173
|
+
if (start > now)
|
|
5174
|
+
start = zonedTime(w.year, w.month, w.day - back - 7, h, m, timeZone);
|
|
5175
|
+
const s = wallClock(start, timeZone);
|
|
5176
|
+
return { start, end: zonedTime(s.year, s.month, s.day + 7, h, m, timeZone) };
|
|
5177
|
+
}
|
|
5178
|
+
function resetsOf(manifest, now) {
|
|
5179
|
+
return {
|
|
5180
|
+
daily: dailyPeriod(now, manifest.timezone, manifest.dailyReset),
|
|
5181
|
+
weekly: weeklyPeriod(now, manifest.timezone, manifest.weeklyReset.day, manifest.weeklyReset.at ?? manifest.dailyReset)
|
|
5182
|
+
};
|
|
5183
|
+
}
|
|
5184
|
+
function patternText(pattern) {
|
|
5185
|
+
return pattern.replace(/\\([^a-zA-Z0-9])/g, "$1").replace(/\\[dswbDSWB]/g, "").replace(/\(\?[:=!]/g, "(").replace(/\.\*\??|\.\+\??/g, "\u2026").replace(/[?*+^$]/g, "").replace(/\|/g, " / ").replace(/[()[\]{}]/g, "").replace(/\s+/g, " ").trim();
|
|
5186
|
+
}
|
|
5187
|
+
function compile(patterns) {
|
|
5188
|
+
const out = [];
|
|
5189
|
+
for (const p of patterns) {
|
|
5190
|
+
try {
|
|
5191
|
+
out.push(new RegExp(p));
|
|
5192
|
+
} catch {
|
|
5193
|
+
}
|
|
5194
|
+
}
|
|
5195
|
+
return out;
|
|
5196
|
+
}
|
|
5197
|
+
function gameRoutines(manifest, scripts, own, hidden) {
|
|
5198
|
+
const out = /* @__PURE__ */ new Map();
|
|
5199
|
+
for (const r of manifest.routines) {
|
|
5200
|
+
if (out.has(r.id))
|
|
5201
|
+
continue;
|
|
5202
|
+
const logs = routineLogs(r);
|
|
5203
|
+
out.set(r.id, {
|
|
5204
|
+
id: r.id,
|
|
5205
|
+
name: r.name,
|
|
5206
|
+
period: r.period,
|
|
5207
|
+
...r.description === void 0 ? {} : { description: r.description },
|
|
5208
|
+
from: "game",
|
|
5209
|
+
events: compile(r.events ?? []),
|
|
5210
|
+
links: logs.length === 0 ? [] : [{ logs: compile(logs), tasks: [], text: logs.map((p) => `\u811A\u672C\u65E5\u5FD7\u300C${patternText(p)}\u300D`) }]
|
|
5211
|
+
});
|
|
5212
|
+
}
|
|
5213
|
+
for (const script of scripts) {
|
|
5214
|
+
for (const r of script.manifest?.routines ?? []) {
|
|
5215
|
+
const logs = routineLogs(r);
|
|
5216
|
+
const tasks = r.tasks ?? [];
|
|
5217
|
+
const titles = tasks.map((t) => script.manifest?.tasks.find((x) => x.id === t)?.title ?? t);
|
|
5218
|
+
const link2 = {
|
|
5219
|
+
script: script.id,
|
|
5220
|
+
scriptName: script.name,
|
|
5221
|
+
logs: compile(logs),
|
|
5222
|
+
tasks,
|
|
5223
|
+
text: [...logs.map((p) => `${script.name} \u65E5\u5FD7\u300C${patternText(p)}\u300D`), ...titles.length === 0 ? [] : [`${script.name}\u300C${titles.join("\u300D\u300C")}\u300D\u8FD0\u884C\u6210\u529F`]]
|
|
5224
|
+
};
|
|
5225
|
+
const known = out.get(r.id);
|
|
5226
|
+
if (known !== void 0) {
|
|
5227
|
+
if (link2.text.length > 0)
|
|
5228
|
+
known.links.push(link2);
|
|
5229
|
+
continue;
|
|
5230
|
+
}
|
|
5231
|
+
out.set(r.id, {
|
|
5232
|
+
id: r.id,
|
|
5233
|
+
name: r.name,
|
|
5234
|
+
period: r.period,
|
|
5235
|
+
...r.description === void 0 ? {} : { description: r.description },
|
|
5236
|
+
from: `script:${script.id}`,
|
|
5237
|
+
events: compile(r.events ?? []),
|
|
5238
|
+
links: link2.text.length === 0 ? [] : [link2]
|
|
5239
|
+
});
|
|
5240
|
+
}
|
|
5241
|
+
}
|
|
5242
|
+
for (const r of own)
|
|
5243
|
+
if (!out.has(r.id))
|
|
5244
|
+
out.set(r.id, { id: r.id, name: r.name, period: r.period, from: "own", events: [], links: [] });
|
|
5245
|
+
return [...out.values()].filter((r) => !hidden.includes(r.id));
|
|
5246
|
+
}
|
|
5247
|
+
function routineEvents(def, activities, now) {
|
|
5248
|
+
if (def.period !== "event" || def.events.length === 0)
|
|
5249
|
+
return [];
|
|
5250
|
+
return activities.filter((a) => def.events.some((re) => re.test(a.name)) && (a.endsAt ?? Infinity) > now).sort((a, b) => Number((b.startsAt ?? 0) <= now) - Number((a.startsAt ?? 0) <= now) || (a.startsAt ?? 0) - (b.startsAt ?? 0));
|
|
5251
|
+
}
|
|
5252
|
+
function periodKey(def, resets, events, now) {
|
|
5253
|
+
if (def.period === "daily")
|
|
5254
|
+
return { key: `d:${resets.daily.start}`, start: resets.daily.start, end: resets.daily.end };
|
|
5255
|
+
if (def.period === "weekly")
|
|
5256
|
+
return { key: `w:${resets.weekly.start}`, start: resets.weekly.start, end: resets.weekly.end };
|
|
5257
|
+
const running = events.find((a) => (a.startsAt ?? 0) <= now);
|
|
5258
|
+
return running === void 0 ? void 0 : { key: `e:${running.id}`, start: running.startsAt ?? 0, ...running.endsAt === void 0 ? {} : { end: running.endsAt } };
|
|
5259
|
+
}
|
|
5260
|
+
function withOfficialRoutines(mine, official) {
|
|
5261
|
+
if (official === void 0 || official.routines.length === 0)
|
|
5262
|
+
return mine;
|
|
5263
|
+
const taskIds = new Set(mine.tasks.map((t) => t.id));
|
|
5264
|
+
const own = new Map(mine.routines.map((r) => [r.id, r]));
|
|
5265
|
+
const routines = [...mine.routines.map((r) => {
|
|
5266
|
+
const theirs = official.routines.find((o) => o.id === r.id);
|
|
5267
|
+
if (theirs === void 0)
|
|
5268
|
+
return r;
|
|
5269
|
+
const logs = [.../* @__PURE__ */ new Set([...routineLogs(r), ...routineLogs(theirs)])];
|
|
5270
|
+
const tasks = [.../* @__PURE__ */ new Set([...r.tasks ?? [], ...(theirs.tasks ?? []).filter((t) => taskIds.has(t))])];
|
|
5271
|
+
return { ...r, ...logs.length === 0 ? {} : { log: logs }, ...tasks.length === 0 ? {} : { tasks }, ...r.events === void 0 && theirs.events !== void 0 ? { events: theirs.events } : {} };
|
|
5272
|
+
})];
|
|
5273
|
+
for (const r of official.routines) {
|
|
5274
|
+
if (own.has(r.id))
|
|
5275
|
+
continue;
|
|
5276
|
+
const tasks = (r.tasks ?? []).filter((t) => taskIds.has(t));
|
|
5277
|
+
const { tasks: _dropped, ...rest } = r;
|
|
5278
|
+
routines.push(tasks.length === 0 ? rest : { ...rest, tasks });
|
|
5279
|
+
}
|
|
5280
|
+
return { tasks: mine.tasks, routines };
|
|
5281
|
+
}
|
|
5282
|
+
var Done = external_exports.object({
|
|
5283
|
+
key: external_exports.string(),
|
|
5284
|
+
at: external_exports.number(),
|
|
5285
|
+
by: external_exports.enum(["log", "task", "agent", "user"]),
|
|
5286
|
+
detail: external_exports.string().optional(),
|
|
5287
|
+
script: external_exports.string().optional(),
|
|
5288
|
+
runId: external_exports.string().optional()
|
|
5289
|
+
});
|
|
5290
|
+
var BookSchema = external_exports.object({
|
|
5291
|
+
/** By game, then routine id: the last time it was done (only counts in its period). */
|
|
5292
|
+
done: external_exports.record(external_exports.string(), external_exports.record(external_exports.string(), Done)).default({}),
|
|
5293
|
+
/** The user's own, by game. */
|
|
5294
|
+
own: external_exports.record(external_exports.string(), external_exports.array(external_exports.object({ id: external_exports.string(), name: external_exports.string(), period: external_exports.enum(["daily", "weekly"]), at: external_exports.number() }))).default({}),
|
|
5295
|
+
/** Pack routines the user took off the page, by game. */
|
|
5296
|
+
hidden: external_exports.record(external_exports.string(), external_exports.array(external_exports.string())).default({})
|
|
5297
|
+
});
|
|
5298
|
+
var RoutineBook = class {
|
|
5299
|
+
#file;
|
|
5300
|
+
#book = { done: {}, own: {}, hidden: {} };
|
|
5301
|
+
constructor(dir) {
|
|
5302
|
+
this.#file = join2(dir, "routines.json");
|
|
5303
|
+
}
|
|
5304
|
+
async load() {
|
|
5305
|
+
try {
|
|
5306
|
+
this.#book = BookSchema.parse(JSON.parse(await readFile2(this.#file, "utf8")));
|
|
5307
|
+
} catch {
|
|
5308
|
+
}
|
|
5309
|
+
}
|
|
5310
|
+
async #save() {
|
|
5311
|
+
await writeFileAtomic(this.#file, `${JSON.stringify(this.#book, null, 1)}
|
|
5312
|
+
`);
|
|
5313
|
+
}
|
|
5314
|
+
done(game, routine, key) {
|
|
5315
|
+
const d = this.#book.done[game]?.[routine];
|
|
5316
|
+
return d?.key === key ? d : void 0;
|
|
5317
|
+
}
|
|
5318
|
+
/** Mark it done in the period `key`. @returns false when it already was (the first word stands). */
|
|
5319
|
+
async mark(game, routine, done) {
|
|
5320
|
+
if (this.#book.done[game]?.[routine]?.key === done.key)
|
|
5321
|
+
return false;
|
|
5322
|
+
(this.#book.done[game] ??= {})[routine] = done;
|
|
5323
|
+
await this.#save();
|
|
5324
|
+
return true;
|
|
5325
|
+
}
|
|
5326
|
+
async unmark(game, routine) {
|
|
5327
|
+
if (this.#book.done[game]?.[routine] === void 0)
|
|
5328
|
+
return;
|
|
5329
|
+
delete this.#book.done[game][routine];
|
|
5330
|
+
await this.#save();
|
|
5331
|
+
}
|
|
5332
|
+
own(game) {
|
|
5333
|
+
return [...this.#book.own[game] ?? []];
|
|
5334
|
+
}
|
|
5335
|
+
async addOwn(game, name, period, at) {
|
|
5336
|
+
const list = this.#book.own[game] ??= [];
|
|
5337
|
+
let n = list.length + 1;
|
|
5338
|
+
while (list.some((r) => r.id === `own-${n}`))
|
|
5339
|
+
n++;
|
|
5340
|
+
const routine = { id: `own-${n}`, name: name.trim(), period, at };
|
|
5341
|
+
list.push(routine);
|
|
5342
|
+
await this.#save();
|
|
5343
|
+
return routine;
|
|
5344
|
+
}
|
|
5345
|
+
/** Delete the user's own (true), or hide a pack's (false). */
|
|
5346
|
+
async remove(game, routine) {
|
|
5347
|
+
const own = this.#book.own[game] ?? [];
|
|
5348
|
+
if (own.some((r) => r.id === routine)) {
|
|
5349
|
+
this.#book.own[game] = own.filter((r) => r.id !== routine);
|
|
5350
|
+
delete this.#book.done[game]?.[routine];
|
|
5351
|
+
await this.#save();
|
|
5352
|
+
return true;
|
|
5353
|
+
}
|
|
5354
|
+
const hidden = this.#book.hidden[game] ??= [];
|
|
5355
|
+
if (!hidden.includes(routine))
|
|
5356
|
+
hidden.push(routine);
|
|
5357
|
+
await this.#save();
|
|
5358
|
+
return false;
|
|
5359
|
+
}
|
|
5360
|
+
hidden(game) {
|
|
5361
|
+
return [...this.#book.hidden[game] ?? []];
|
|
5362
|
+
}
|
|
5363
|
+
async restore(game) {
|
|
5364
|
+
delete this.#book.hidden[game];
|
|
5365
|
+
await this.#save();
|
|
5366
|
+
}
|
|
5367
|
+
/** Forget a game (one made here that is deleted). */
|
|
5368
|
+
async forget(game) {
|
|
5369
|
+
delete this.#book.done[game];
|
|
5370
|
+
delete this.#book.own[game];
|
|
5371
|
+
delete this.#book.hidden[game];
|
|
5372
|
+
await this.#save();
|
|
5373
|
+
}
|
|
5374
|
+
};
|
|
4989
5375
|
|
|
4990
5376
|
// packages/game-intel/lib/reading-tasks.js
|
|
4991
5377
|
var ReadingTasks = class {
|
|
@@ -5348,7 +5734,9 @@ function gameTools(deps) {
|
|
|
5348
5734
|
screen: g.screen === void 0 ? "\u672A\u8BBE\u7F6E" : g.screen.target === "emulator" ? "target=emulator" : `target=window${g.screen.window === void 0 ? "\uFF08\u5148 window_list \u627E\u7A97\u53E3\uFF09" : `\uFF0Cwindow=${g.screen.window}`}`,
|
|
5349
5735
|
sources: g.sources.map((s) => ({ name: s.name, auto: s.auto, ...s.homepage === void 0 ? {} : { homepage: s.homepage } })),
|
|
5350
5736
|
...g.refreshed === void 0 ? {} : { refreshed: { at: new Date(g.refreshed.at).toISOString(), ok: g.refreshed.ok, count: g.refreshed.count, ...g.refreshed.detail === void 0 ? {} : { detail: g.refreshed.detail } } },
|
|
5351
|
-
...g.reading === void 0 ? {} : { last_read_in_game: new Date(g.reading.at).toISOString() }
|
|
5737
|
+
...g.reading === void 0 ? {} : { last_read_in_game: new Date(g.reading.at).toISOString() },
|
|
5738
|
+
...g.pools?.length ? { pools: g.pools.map((p) => ({ name: p.name, ends: shortDate(p.endsAt, g.timezone), ...p.up.length ? { up: p.up.slice(0, 6) } : {} })) } : {},
|
|
5739
|
+
...g.routines?.length ? { routines: g.routines.map((r) => ({ name: r.name, period: r.period === "daily" ? "\u65E5\u5E38" : r.period === "weekly" ? "\u5468\u5E38" : "\u5468\u671F\u73A9\u6CD5", done: r.done !== void 0 })) } : {}
|
|
5352
5740
|
}))
|
|
5353
5741
|
})
|
|
5354
5742
|
}),
|
|
@@ -5560,6 +5948,132 @@ function gameTools(deps) {
|
|
|
5560
5948
|
};
|
|
5561
5949
|
}
|
|
5562
5950
|
}),
|
|
5951
|
+
tool({
|
|
5952
|
+
name: "game_routine",
|
|
5953
|
+
description: [
|
|
5954
|
+
"\u6E38\u620F\u9875\u300C\u65E5\u5E38 \xB7 \u5468\u5E38\u300D\u7684\u6E05\u5355\uFF1Aaction=list \u770B\u6BCF\u4E00\u9879\u8FD9\u4E00\u671F\uFF08\u4ECA\u5929\u3001\u8FD9\u5468\u3001\u8FD9\u4E00\u671F\u5468\u671F\u73A9\u6CD5\uFF09\u505A\u6CA1\u505A\u5B8C\u3001\u8C01\u52FE\u7684\u3001\u9760\u4EC0\u4E48\u81EA\u52A8\u52FE\u3001\u4EC0\u4E48\u65F6\u5019\u91CD\u7F6E\uFF1Baction=set \u52FE\u4E0A\u6216\u53D6\u6D88\u4E00\u9879\u3002",
|
|
5955
|
+
"\u811A\u672C\u65E5\u5FD7\u6216\u4EFB\u52A1\u6210\u529F\u80FD\u8BC1\u660E\u7684\u9879\u76EE\u63D2\u4EF6\u4F1A\u81EA\u5DF1\u52FE\uFF0C\u4E5F\u4F1A\u56DE\u5934\u8BFB\u8FD9\u4E00\u671F\u65E9\u4E9B\u65F6\u5019\u7684\u8FD0\u884C\u8BB0\u5F55\u8865\u4E0A\uFF08list \u4E4B\u524D\u5DF2\u7ECF\u8BFB\u8FC7\u4E00\u904D\uFF09\u2014\u2014\u6240\u4EE5\u5148 list\uFF0C\u6CA1\u52FE\u4E0A\u7684\u518D\u67E5\u539F\u56E0\uFF1A\u811A\u672C\u5305\u6CA1\u5199 routines\u3001log \u5199\u7684\u4E0D\u662F\u65E5\u5FD7\u91CC\u771F\u5B9E\u7684\u539F\u6587\u3001\u6216\u8005\u786E\u5B9E\u6CA1\u505A\u3002",
|
|
5956
|
+
"set \u53EA\u5728\u4F60\u4EB2\u773C\u770B\u5230\u5B8C\u6210\u8BC1\u636E\u65F6\u7528\uFF08\u8FD0\u884C\u65E5\u5FD7\u91CC\u7684\u539F\u6587\u3001\u6E38\u620F\u753B\u9762\u4E0A\u7684\u5B8C\u6210\u6587\u5B57\uFF09\uFF0Cevidence \u5199\u539F\u6587\u548C\u51FA\u5904\uFF1B\u9875\u9762\u4E0A\u4F1A\u663E\u793A\u6210\u300Cagent \u8BB0\u7684\u300D\uFF0C\u548C\u7528\u6237\u81EA\u5DF1\u52FE\u7684\u5206\u5F00\u3002\u4E0D\u8981\u7528\u6D4F\u89C8\u5668\u70B9\u6E38\u620F\u9875\u3001\u6216\u8C03\u7528\u63A5\u53E3\u53BB\u52FE\uFF0C\u90A3\u6837\u4F1A\u88AB\u5F53\u6210\u7528\u6237\u52FE\u7684\u3002"
|
|
5957
|
+
].join(""),
|
|
5958
|
+
properties: {
|
|
5959
|
+
game: GAME,
|
|
5960
|
+
action: { type: "string", enum: ["list", "set"], description: "list\uFF1A\u770B\u6E05\u5355\uFF1Bset\uFF1A\u52FE\u4E0A\u6216\u53D6\u6D88\u4E00\u9879\u3002" },
|
|
5961
|
+
routine: { type: "string", description: "action=set\uFF1A\u65E5\u5E38\u7684 id \u6216\u540D\u79F0\uFF08\u7167 list \u91CC\u7684\u5199\uFF09\u3002" },
|
|
5962
|
+
done: { type: "boolean", description: "action=set\uFF1Atrue \u52FE\u4E0A\uFF08\u9ED8\u8BA4\uFF09\uFF0Cfalse \u53D6\u6D88\u3002" },
|
|
5963
|
+
evidence: { type: "string", description: "action=set \u4E14 done=true\uFF1A\u770B\u5230\u7684\u5B8C\u6210\u8BC1\u636E\u539F\u6587\u548C\u51FA\u5904\uFF0C\u4F8B\u5982\u300CMAA \u8FD0\u884C run-\u2026 \u65E5\u5FD7\uFF1A\u5B8C\u6210\u4EFB\u52A1: \u57FA\u5EFA\u6362\u73ED\u300D\u6216\u300C\u6E38\u620F\u753B\u9762\uFF1A\u6BCF\u65E5\u5B9E\u8BAD 500/500\u300D\u3002" }
|
|
5964
|
+
},
|
|
5965
|
+
required: ["game", "action"],
|
|
5966
|
+
kind: "other",
|
|
5967
|
+
title: (a) => `${a["action"] === "set" ? "\u52FE\u9009\u65E5\u5E38" : "\u65E5\u5E38\u6E05\u5355"}\uFF1A${String(a["game"] ?? "")}`,
|
|
5968
|
+
execute: async (args) => {
|
|
5969
|
+
const a = parse(external_exports.object({
|
|
5970
|
+
game: external_exports.string(),
|
|
5971
|
+
action: external_exports.enum(["list", "set"]),
|
|
5972
|
+
routine: external_exports.string().trim().min(1).max(80).nullish(),
|
|
5973
|
+
done: external_exports.boolean().nullish(),
|
|
5974
|
+
evidence: external_exports.string().trim().max(300).nullish()
|
|
5975
|
+
}), args);
|
|
5976
|
+
const game = known(a.game);
|
|
5977
|
+
const PERIOD = { daily: "\u65E5\u5E38", weekly: "\u5468\u5E38", event: "\u5468\u671F\u73A9\u6CD5" };
|
|
5978
|
+
const BY = { log: "\u811A\u672C\u65E5\u5FD7", task: "\u811A\u672C\u4EFB\u52A1\u6210\u529F", agent: "agent \u8BB0\u7684", user: "\u7528\u6237\u81EA\u5DF1\u52FE\u7684" };
|
|
5979
|
+
const view = (r) => ({
|
|
5980
|
+
id: r.id,
|
|
5981
|
+
name: r.name,
|
|
5982
|
+
kind: PERIOD[r.period],
|
|
5983
|
+
done: r.done === void 0 ? false : { at: new Date(r.done.at).toLocaleString("zh-CN", { timeZone: game.timezone, hour12: false }), by: BY[r.done.by], ...r.done.detail === void 0 ? {} : { detail: r.done.detail }, ...r.done.script === void 0 ? {} : { script: r.done.script } },
|
|
5984
|
+
auto: r.links.length > 0 ? r.links : "\u6CA1\u6709\uFF1A\u53EA\u80FD\u624B\u52A8\u52FE\uFF08\u811A\u672C\u5305\u91CC\u52A0 routines \u7684 log \u6216 tasks \u624D\u4F1A\u81EA\u52A8\u52FE\uFF09",
|
|
5985
|
+
...r.resetsAt === void 0 ? {} : { resets: shortDate(r.resetsAt, game.timezone) }
|
|
5986
|
+
});
|
|
5987
|
+
if (a.action === "list") {
|
|
5988
|
+
const status = await deps.routines(game.id);
|
|
5989
|
+
return {
|
|
5990
|
+
routines: status.routines.map(view),
|
|
5991
|
+
next: status.routines.length === 0 ? "\u8FD9\u4E2A\u6E38\u620F\u8FD8\u6CA1\u6709\u65E5\u5E38\u5468\u5E38\uFF1A\u6E38\u620F\u5305\u6216\u73A9\u5B83\u7684\u811A\u672C\u5305\u91CC\u5199 routines \u624D\u4F1A\u5217\u51FA\u6765\u3002" : "\u6CA1\u52FE\u4E0A\u7684\u9879\u76EE\uFF1A\u5148\u770B auto \u91CC\u7684\u65E5\u5FD7\u539F\u6587\u5728\u8FD9\u4E00\u671F\u7684\u8FD0\u884C\u65E5\u5FD7\u91CC\u6709\u6CA1\u6709\uFF08script_run_log \u641C\u7D22\uFF09\uFF0C\u6709\u5C31\u662F\u63D2\u4EF6\u6CA1\u8BFB\u5230\uFF0C\u544A\u8BC9\u7528\u6237\uFF1B\u6CA1\u6709\u5C31\u662F\u8FD8\u6CA1\u505A\u6216\u811A\u672C\u5305\u7684 log \u5199\u5F97\u4E0D\u5BF9\u3002"
|
|
5992
|
+
};
|
|
5993
|
+
}
|
|
5994
|
+
if (a.routine == null)
|
|
5995
|
+
throw new Error("action=set \u8981\u5199 routine\uFF08\u7167 list \u91CC\u7684 id \u6216\u540D\u79F0\uFF09");
|
|
5996
|
+
const done = a.done ?? true;
|
|
5997
|
+
if (done && (a.evidence == null || a.evidence.length < 4))
|
|
5998
|
+
throw new Error("\u52FE\u4E0A\u8981\u5199 evidence\uFF1A\u4F60\u770B\u5230\u7684\u5B8C\u6210\u8BC1\u636E\u539F\u6587\u548C\u51FA\u5904\uFF08\u65E5\u5FD7\u884C\u3001\u6E38\u620F\u753B\u9762\u4E0A\u7684\u6587\u5B57\uFF09\u3002\u6CA1\u6709\u8BC1\u636E\u5C31\u4E0D\u8981\u52FE\u3002");
|
|
5999
|
+
const routine = await deps.setRoutine(game.id, a.routine, done, a.evidence ?? void 0);
|
|
6000
|
+
return { routine: view(routine), next: done ? "\u52FE\u4E0A\u4E86\uFF0C\u6E38\u620F\u9875\u663E\u793A\u4E3A\u300Cagent \u8BB0\u7684\u300D\u3002" : "\u53D6\u6D88\u4E86\u3002" };
|
|
6001
|
+
}
|
|
6002
|
+
}),
|
|
6003
|
+
tool({
|
|
6004
|
+
name: "game_pool",
|
|
6005
|
+
description: [
|
|
6006
|
+
"\u628A\u8BFB\u5230\u7684\u5361\u6C60\uFF08\u7948\u613F\u3001\u8DC3\u8FC1\u3001\u8C03\u9891\u3001\u5524\u53D6\u3001\u5BFB\u8BBF\u7B49\u62BD\u5361\u6C60\uFF09\u8BB0\u5230\u6E38\u620F\u9875\u7684\u300C\u5361\u6C60\u300D\u91CC\uFF1A\u6BCF\u4E2A\u5361\u6C60\u5199\u540D\u79F0\u3001UP \u7684\u89D2\u8272\u6216\u6B66\u5668\uFF08\u4E94\u661F\u5728\u524D\uFF09\u3001\u5F00\u59CB\u548C\u7ED3\u675F\u65F6\u95F4\uFF08\u6E38\u620F\u670D\u52A1\u5668\u65F6\u95F4\uFF09\u3002",
|
|
6007
|
+
"\u8BFB\u5B98\u65B9\u516C\u544A\u3001\u6E38\u620F\u5185\u516C\u544A\u6216 Wiki \u65F6\u770B\u5230\u5361\u6C60\u5C31\u8BB0\uFF0C\u6570\u636E\u7AD9\u5DF2\u7ECF\u5217\u51FA\u7684\u5361\u6C60\u4E0D\u7528\u518D\u8BB0\uFF1B\u540C\u540D\u7684\u518D\u8BB0\u5C31\u662F\u66F4\u65B0\u539F\u6765\u90A3\u6761\uFF0C\u7ED3\u675F\u4E86\u7684\u4F1A\u81EA\u5DF1\u6E05\u6389\u3002\u53EA\u8BB0\u6709\u51FA\u5904\u3001\u6709\u7ED3\u675F\u65F6\u95F4\u7684\u3002"
|
|
6008
|
+
].join(""),
|
|
6009
|
+
properties: {
|
|
6010
|
+
game: GAME,
|
|
6011
|
+
pools: {
|
|
6012
|
+
type: "array",
|
|
6013
|
+
description: "\u6BCF\u4E2A\u5361\u6C60\u4E00\u6761\u3002",
|
|
6014
|
+
items: {
|
|
6015
|
+
type: "object",
|
|
6016
|
+
properties: {
|
|
6017
|
+
name: { type: "string", description: "\u5361\u6C60\u540D\uFF0C\u4F8B\u5982\u300C\u8776\u7ACB\u950B\u9537\u300D\u6216\u300C\u89D2\u8272\u6D3B\u52A8\u8DC3\u8FC1\uFF1A\u9EC4\u6CC9\u300D\u3002" },
|
|
6018
|
+
type: { type: "string", description: "\u5361\u6C60\u7C7B\u578B\uFF0C\u4F8B\u5982 \u89D2\u8272\u6D3B\u52A8\u8DC3\u8FC1\u3001\u5149\u9525\u6D3B\u52A8\u8DC3\u8FC1\u3001\u6B66\u5668\u6D3B\u52A8\u7948\u613F\uFF08\u53EF\u9009\uFF09\u3002" },
|
|
6019
|
+
up: { type: "array", items: { type: "string" }, description: "\u6982\u7387 UP \u7684\u89D2\u8272\u6216\u6B66\u5668\uFF0C\u4E94\u661F\u5728\u524D\u3002" },
|
|
6020
|
+
starts_at: { type: "string", description: "\u5F00\u59CB\u65F6\u95F4\uFF0C\u5199\u6210 2026/12/02 12:00\uFF08\u6E38\u620F\u670D\u52A1\u5668\u65F6\u95F4\uFF09\uFF1B\u300C\u7248\u672C\u66F4\u65B0\u540E\u300D\u8FD9\u7C7B\u5199\u7248\u672C\u5F00\u59CB\u7684\u65F6\u95F4\u3002" },
|
|
6021
|
+
ends_at: { type: "string", description: "\u7ED3\u675F\u65F6\u95F4\uFF0C\u5199\u6210 2026/12/22 14:59\uFF08\u6E38\u620F\u670D\u52A1\u5668\u65F6\u95F4\uFF09\u3002" },
|
|
6022
|
+
cover: { type: "string", description: "\u5361\u6C60\u6216\u7B2C\u4E00\u4E2A UP \u89D2\u8272\u7684\u56FE\u7247\uFF08https\uFF0C\u53EF\u9009\uFF09\u3002" }
|
|
6023
|
+
},
|
|
6024
|
+
required: ["name", "ends_at"],
|
|
6025
|
+
additionalProperties: false
|
|
6026
|
+
}
|
|
6027
|
+
}
|
|
6028
|
+
},
|
|
6029
|
+
required: ["game", "pools"],
|
|
6030
|
+
kind: "other",
|
|
6031
|
+
title: (a) => `\u8BB0\u5F55\u5361\u6C60\uFF1A${String(a["game"] ?? "")}`,
|
|
6032
|
+
execute: async (args) => {
|
|
6033
|
+
const a = parse(external_exports.object({
|
|
6034
|
+
game: external_exports.string(),
|
|
6035
|
+
pools: external_exports.array(external_exports.object({
|
|
6036
|
+
name: external_exports.string().trim().min(1).max(80),
|
|
6037
|
+
type: external_exports.string().trim().max(40).nullish(),
|
|
6038
|
+
up: external_exports.array(external_exports.string().trim().min(1).max(40)).max(20).nullish(),
|
|
6039
|
+
starts_at: external_exports.string().nullish(),
|
|
6040
|
+
ends_at: external_exports.string(),
|
|
6041
|
+
cover: external_exports.string().nullish()
|
|
6042
|
+
})).min(1).max(20)
|
|
6043
|
+
}), args);
|
|
6044
|
+
const game = known(a.game);
|
|
6045
|
+
const now = deps.now();
|
|
6046
|
+
const skipped = [];
|
|
6047
|
+
const pools = [];
|
|
6048
|
+
for (const p of a.pools) {
|
|
6049
|
+
const endsAt = parseDateText(p.ends_at, game.timezone, now);
|
|
6050
|
+
if (typeof endsAt !== "number") {
|
|
6051
|
+
skipped.push({ name: p.name, reason: `\u7ED3\u675F\u65F6\u95F4\u300C${p.ends_at}\u300D\u8BFB\u4E0D\u61C2\uFF0C\u5199\u6210 2026/12/22 14:59` });
|
|
6052
|
+
continue;
|
|
6053
|
+
}
|
|
6054
|
+
if (endsAt <= now) {
|
|
6055
|
+
skipped.push({ name: p.name, reason: "\u5DF2\u7ECF\u7ED3\u675F\u4E86" });
|
|
6056
|
+
continue;
|
|
6057
|
+
}
|
|
6058
|
+
const startsAt = p.starts_at == null ? void 0 : parseDateText(p.starts_at, game.timezone, now);
|
|
6059
|
+
pools.push({
|
|
6060
|
+
name: p.name,
|
|
6061
|
+
endsAt,
|
|
6062
|
+
up: p.up ?? [],
|
|
6063
|
+
...typeof startsAt === "number" ? { startsAt } : {},
|
|
6064
|
+
...p.type == null || p.type === "" ? {} : { type: p.type },
|
|
6065
|
+
...p.cover != null && /^https:\/\/\S+$/.test(p.cover) ? { cover: p.cover } : {}
|
|
6066
|
+
});
|
|
6067
|
+
}
|
|
6068
|
+
const open = pools.length === 0 ? void 0 : await deps.recordPools(game.id, pools);
|
|
6069
|
+
return {
|
|
6070
|
+
recorded: pools.map((p) => ({ name: p.name, ends: shortDate(p.endsAt, game.timezone), ...p.up.length ? { up: p.up } : {} })),
|
|
6071
|
+
...skipped.length ? { skipped } : {},
|
|
6072
|
+
...open === void 0 ? {} : { open_now: open },
|
|
6073
|
+
next: pools.length ? "\u8BB0\u4E0B\u4E86\uFF0C\u6E38\u620F\u9875\u7684\u300C\u5361\u6C60\u300D\u91CC\u80FD\u770B\u5230\u3002" : "\u4E00\u4E2A\u90FD\u6CA1\u8BB0\u4E0B\uFF1A\u770B skipped \u91CC\u7684\u539F\u56E0\u3002"
|
|
6074
|
+
};
|
|
6075
|
+
}
|
|
6076
|
+
}),
|
|
5563
6077
|
tool({
|
|
5564
6078
|
name: "game_activity_save",
|
|
5565
6079
|
description: [
|
|
@@ -5700,7 +6214,7 @@ function gameTools(deps) {
|
|
|
5700
6214
|
}
|
|
5701
6215
|
|
|
5702
6216
|
// packages/game-intel/lib/index.js
|
|
5703
|
-
var readsItself = (s) => s.smw !== void 0 || s.sra !== void 0 || s.steam !== void 0;
|
|
6217
|
+
var readsItself = (s) => s.smw !== void 0 || s.sra !== void 0 || s.steam !== void 0 || givesPools(s);
|
|
5704
6218
|
var ConfigSchema = external_exports.object({
|
|
5705
6219
|
/** The calendar and screenshots: `<dataDir>/games/`; the user's Game Packs: `<dataDir>/games/<id>/game.yaml`. */
|
|
5706
6220
|
dataDir: external_exports.string().min(1),
|
|
@@ -5720,7 +6234,8 @@ var GAME_ROLE = {
|
|
|
5720
6234
|
// Games and their screens, and what scripts ran (for the daily report); no installing, runs or pipelines.
|
|
5721
6235
|
// skill_hub_list: its reading prompt and game_list send it there when a game's skill is missing.
|
|
5722
6236
|
// browser_*: official sites and wikis that need clicking through (the built-in browser).
|
|
5723
|
-
|
|
6237
|
+
// script_run_log: why a 日常 did not tick is answered from the run's own lines (game_routine sends it there).
|
|
6238
|
+
tools: ["game_*", "screen_*", "window_*", "browser_*", "emulator_status", "emulator_start", "script_list", "script_tasks", "script_runs", "script_run_log", "skill_hub_list", "system_info", "skill_focus", "skill_save"],
|
|
5724
6239
|
duty: [
|
|
5725
6240
|
"# \u4F60\u7684\u89D2\u8272\uFF1A\u6E38\u620F",
|
|
5726
6241
|
"\u4F60\u662F MultiGameAssistant \u7684\u300C\u6E38\u620F\u300Dagent\uFF1A\u8BFB\u6E38\u620F\u7684\u6D3B\u52A8\u3001\u8D44\u8BAF\u548C\u8FDB\u5EA6\u5E76\u8BB0\u4E0B\u6765\uFF08game_record\uFF09\uFF0C\u5199\u65E5\u62A5\uFF0C\u6DFB\u52A0\u6E38\u620F\u3002",
|
|
@@ -5731,11 +6246,13 @@ var SKILL = new URL("../skills/game-intel.md", import.meta.url);
|
|
|
5731
6246
|
var WEB_SKILL = new URL("../skills/web-reading.md", import.meta.url);
|
|
5732
6247
|
var IMAGE_TYPES = [["jpg", "image/jpeg"], ["png", "image/png"], ["webp", "image/webp"], ["gif", "image/gif"], ["avif", "image/avif"]];
|
|
5733
6248
|
var MAX_IMAGE_BYTES = 8 * 1024 * 1024;
|
|
5734
|
-
var WEB_DELIVERY = "\u4F60\u662F\u6B64\u6B21\u7F51\u9875\u63A2\u67E5\u7684\u6267\u884C\u8005\u3002\u6309\u6765\u6E90\u8BFB\u53D6\u8FD1\u671F\u5217\u8868\u53CA\u540E\u7EED\u9875\uFF0C\u76F4\u5230\u65E5\u671F\u8FB9\u754C\u6216\u672B\u9875\u3002\u7F51\u9875\u53EA\u6709\u5C11\u91CF\u7ED3\u679C\u6216\u8BFB\u4E0D\u5230\u6B63\u6587\u65F6\uFF0C\u6838\u5BF9\u5176\u4ED6\u72EC\u7ACB\u7684\u5B98\u65B9\u6765\u6E90\u3002\u5C06\u6BCF\u7BC7\u5DF2\u6838\u5B9E\u7684\u516C\u544A\u7528 game_notice \u6279\u91CF\u5165\u5E93\uFF0C\u6709\u65F6\u95F4\u8303\u56F4\u7684\u6D3B\u52A8\u7528 game_record \u5165\u5E93\u3002\u56FE\u7247\u4F18\u5148\u53D6\u6B63\u6587\u9996\u56FE\u3001\u5206\u4EAB\u56FE\u6216\u63A5\u53E3\u539F\u56FE\uFF1B\u5DF2\u6709\u6761\u76EE\u53EF\u4EE5\u8865\u56FE\u3002\u7528 game_activities \u6838\u5BF9\u5199\u5165\u7ED3\u679C\u3002\u6700\u540E\u4EA4\u56DE\u6240\u6709\u5019\u9009\uFF0C\u8868\u5934\u4E3A\u300C\u6807\u9898 | \u65E5\u671F | \u76F4\u94FE | \u914D\u56FE\u300D\uFF0C\u6BCF\u884C\u4E00\u7BC7\u3002\u5355\u5217\u300C\u8DF3\u8FC7 \u5B8C\u6574\u7F51\u5740 | \u5177\u4F53\u7406\u7531\u300D\u3002\u4EA4\u4EE3\u5B9E\u9645\u8986\u76D6\u7684\u6765\u6E90\u3001\u65E5\u671F\u8FB9\u754C\u548C\u8BFB\u53D6\u5931\u8D25\u5904\u3002";
|
|
6249
|
+
var WEB_DELIVERY = "\u4F60\u662F\u6B64\u6B21\u7F51\u9875\u63A2\u67E5\u7684\u6267\u884C\u8005\u3002\u6309\u6765\u6E90\u8BFB\u53D6\u8FD1\u671F\u5217\u8868\u53CA\u540E\u7EED\u9875\uFF0C\u76F4\u5230\u65E5\u671F\u8FB9\u754C\u6216\u672B\u9875\u3002\u7F51\u9875\u53EA\u6709\u5C11\u91CF\u7ED3\u679C\u6216\u8BFB\u4E0D\u5230\u6B63\u6587\u65F6\uFF0C\u6838\u5BF9\u5176\u4ED6\u72EC\u7ACB\u7684\u5B98\u65B9\u6765\u6E90\u3002\u5C06\u6BCF\u7BC7\u5DF2\u6838\u5B9E\u7684\u516C\u544A\u7528 game_notice \u6279\u91CF\u5165\u5E93\uFF0C\u6709\u65F6\u95F4\u8303\u56F4\u7684\u6D3B\u52A8\u7528 game_record \u5165\u5E93\uFF0C\u5361\u6C60\uFF08\u7948\u613F\u3001\u8DC3\u8FC1\u3001\u8C03\u9891\u3001\u5524\u53D6\u3001\u5BFB\u8BBF\uFF09\u7528 game_pool \u5165\u5E93\u3002\u56FE\u7247\u4F18\u5148\u53D6\u6B63\u6587\u9996\u56FE\u3001\u5206\u4EAB\u56FE\u6216\u63A5\u53E3\u539F\u56FE\uFF1B\u5DF2\u6709\u6761\u76EE\u53EF\u4EE5\u8865\u56FE\u3002\u7528 game_activities \u6838\u5BF9\u5199\u5165\u7ED3\u679C\u3002\u6700\u540E\u4EA4\u56DE\u6240\u6709\u5019\u9009\uFF0C\u8868\u5934\u4E3A\u300C\u6807\u9898 | \u65E5\u671F | \u76F4\u94FE | \u914D\u56FE\u300D\uFF0C\u6BCF\u884C\u4E00\u7BC7\u3002\u5355\u5217\u300C\u8DF3\u8FC7 \u5B8C\u6574\u7F51\u5740 | \u5177\u4F53\u7406\u7531\u300D\u3002\u4EA4\u4EE3\u5B9E\u9645\u8986\u76D6\u7684\u6765\u6E90\u3001\u65E5\u671F\u8FB9\u754C\u548C\u8BFB\u53D6\u5931\u8D25\u5904\u3002";
|
|
5735
6250
|
var SUMMARY_TIMEOUT_MS = 3 * 6e4;
|
|
5736
6251
|
var AdgGameIntel = class extends Service {
|
|
5737
6252
|
static inject = ["adgNotify"];
|
|
5738
6253
|
calendar;
|
|
6254
|
+
/** What is done of each game's 日常 / 周常 (routines.ts). */
|
|
6255
|
+
routines;
|
|
5739
6256
|
ready;
|
|
5740
6257
|
/** Injectable for tests. */
|
|
5741
6258
|
fetch = (url, init) => fetch(url, init);
|
|
@@ -5757,10 +6274,12 @@ var AdgGameIntel = class extends Service {
|
|
|
5757
6274
|
const spec = ConfigSchema.parse(config);
|
|
5758
6275
|
const log = ctx.logger("adg-game-intel");
|
|
5759
6276
|
this.log = log;
|
|
5760
|
-
this.dir =
|
|
5761
|
-
this.builtinDir = spec.gamesDir ??
|
|
6277
|
+
this.dir = join3(spec.dataDir, "games");
|
|
6278
|
+
this.builtinDir = spec.gamesDir ?? join3(spec.dataDir, "skill-hub", "skills");
|
|
5762
6279
|
this.calendar = new Calendar(this.dir);
|
|
5763
|
-
|
|
6280
|
+
const routines = new RoutineBook(this.dir);
|
|
6281
|
+
this.routines = routines;
|
|
6282
|
+
this.icons = new ExeIcons(join3(this.dir, "icons"));
|
|
5764
6283
|
const calendar = this.calendar;
|
|
5765
6284
|
const changed = (game) => ctx.get("adgGateway")?.broadcast("games/changed", game === void 0 ? {} : { game });
|
|
5766
6285
|
this.readings = new ReadingTasks(async (key, reading) => {
|
|
@@ -5774,6 +6293,7 @@ var AdgGameIntel = class extends Service {
|
|
|
5774
6293
|
lastDay: () => calendar.report.lastDay,
|
|
5775
6294
|
send: async (day) => {
|
|
5776
6295
|
await this.refresh().catch(() => []);
|
|
6296
|
+
await this.backfill(true);
|
|
5777
6297
|
await this.sendReport(day);
|
|
5778
6298
|
},
|
|
5779
6299
|
log: { warn: (m) => log.warn(m) }
|
|
@@ -5781,6 +6301,7 @@ var AdgGameIntel = class extends Service {
|
|
|
5781
6301
|
this.daily = daily;
|
|
5782
6302
|
this.ready = (async () => {
|
|
5783
6303
|
await calendar.load();
|
|
6304
|
+
await routines.load();
|
|
5784
6305
|
await this.loadGames(log);
|
|
5785
6306
|
await this.adoptEvidence().catch((error) => log.warn(`old screenshots not converted: ${String(error)}`));
|
|
5786
6307
|
await calendar.rederive((game) => this.timezone(game)).catch((error) => log.warn(`calendar not worked out again: ${String(error)}`));
|
|
@@ -5791,10 +6312,10 @@ var AdgGameIntel = class extends Service {
|
|
|
5791
6312
|
const disposers = [];
|
|
5792
6313
|
void (async () => {
|
|
5793
6314
|
await this.ready;
|
|
5794
|
-
const guide = parseFrontmatter(await
|
|
6315
|
+
const guide = parseFrontmatter(await readFile3(SKILL, "utf8"));
|
|
5795
6316
|
if (guide !== void 0)
|
|
5796
6317
|
disposers.push(scoped.adgGateway.generalSkill({ ...guide, source: "bundled" }, () => scoped.skills.register({ ...guide, source: "bundled" })));
|
|
5797
|
-
const web = parseFrontmatter(await
|
|
6318
|
+
const web = parseFrontmatter(await readFile3(WEB_SKILL, "utf8"));
|
|
5798
6319
|
if (web !== void 0)
|
|
5799
6320
|
disposers.push(scoped.adgGateway.generalSkill({ ...web, source: "bundled" }, () => scoped.skills.register({ ...web, source: "bundled" })));
|
|
5800
6321
|
for (const game of this.games) {
|
|
@@ -5807,7 +6328,7 @@ var AdgGameIntel = class extends Service {
|
|
|
5807
6328
|
}
|
|
5808
6329
|
try {
|
|
5809
6330
|
const owner = { games: [game.manifest.id, game.manifest.name] };
|
|
5810
|
-
disposers.push(scoped.adgGateway.skillScope.register({ ...skill, source: game.builtin ? "bundled" : "custom", path:
|
|
6331
|
+
disposers.push(scoped.adgGateway.skillScope.register({ ...skill, source: game.builtin ? "bundled" : "custom", path: join3(game.dir, GAME_GUIDE_FILE), resourceBase: { kind: "directory", path: game.dir }, owner, kind: "game-pack" }));
|
|
5811
6332
|
} catch (error) {
|
|
5812
6333
|
log.warn(`game ${game.manifest.id}: skill not registered: ${error instanceof Error ? error.message : String(error)}`);
|
|
5813
6334
|
}
|
|
@@ -5828,6 +6349,18 @@ var AdgGameIntel = class extends Service {
|
|
|
5828
6349
|
await this.ready;
|
|
5829
6350
|
return this.recordNotices(game, notices);
|
|
5830
6351
|
},
|
|
6352
|
+
routines: (game) => this.routineStatus(game),
|
|
6353
|
+
setRoutine: async (game, routine, done, evidence) => {
|
|
6354
|
+
await this.ready;
|
|
6355
|
+
return this.setRoutine(game, routine, done, "agent", evidence);
|
|
6356
|
+
},
|
|
6357
|
+
recordPools: async (game, pools) => {
|
|
6358
|
+
await this.ready;
|
|
6359
|
+
this.game(game);
|
|
6360
|
+
await calendar.recordPools(game, pools, this.clock.now());
|
|
6361
|
+
this.changed(game);
|
|
6362
|
+
return calendar.pools(game, this.clock.now()).length;
|
|
6363
|
+
},
|
|
5831
6364
|
refresh: async (game) => {
|
|
5832
6365
|
await this.ready;
|
|
5833
6366
|
return this.refresh(game);
|
|
@@ -5881,6 +6414,19 @@ var AdgGameIntel = class extends Service {
|
|
|
5881
6414
|
dispose();
|
|
5882
6415
|
};
|
|
5883
6416
|
}));
|
|
6417
|
+
ctx.inject(["adgRunner"], (scoped) => {
|
|
6418
|
+
scoped.effect(() => scoped.adgRunner.runner.watch({
|
|
6419
|
+
line: (run, line2) => this.routineLine(run, line2),
|
|
6420
|
+
state: (run) => this.routineRun(run)
|
|
6421
|
+
}), "adg-game-intel routines");
|
|
6422
|
+
void this.ready.then(() => this.backfill(true));
|
|
6423
|
+
});
|
|
6424
|
+
ctx.inject(["adgScripts"], (scoped) => {
|
|
6425
|
+
scoped.effect(() => scoped.adgScripts.library.onPacksChanged(() => {
|
|
6426
|
+
this.runHits.clear();
|
|
6427
|
+
void this.ready.then(() => this.backfill(true));
|
|
6428
|
+
}), "adg-game-intel routines on pack changes");
|
|
6429
|
+
});
|
|
5884
6430
|
ctx.inject(["adgGateway"], (scoped) => {
|
|
5885
6431
|
scoped.effect(() => scoped.adgGateway.role(GAME_ROLE), "adg-game-intel role");
|
|
5886
6432
|
scoped.adgGateway.register({
|
|
@@ -5890,6 +6436,7 @@ var AdgGameIntel = class extends Service {
|
|
|
5890
6436
|
"games/list": async () => {
|
|
5891
6437
|
await this.ready;
|
|
5892
6438
|
await this.loadGames(log);
|
|
6439
|
+
void this.backfill();
|
|
5893
6440
|
const shown = new Set(this.games.map((g) => g.manifest.id));
|
|
5894
6441
|
return { games: this.infos(), activities: calendar.list().filter((a) => shown.has(a.game)), notices: calendar.notices().filter((n) => shown.has(n.game)), settings: calendar.settings, report: { ...calendar.report, ...this.daily.next() === void 0 ? {} : { next: this.daily.next() } } };
|
|
5895
6442
|
},
|
|
@@ -5942,13 +6489,23 @@ var AdgGameIntel = class extends Service {
|
|
|
5942
6489
|
throw new Error("\u8FD9\u4E2A\u6D3B\u52A8\u6CA1\u6709\u4FDD\u5B58\u622A\u56FE");
|
|
5943
6490
|
if (screen.image !== void 0)
|
|
5944
6491
|
return this.picture(screen.image);
|
|
5945
|
-
return { mediaType: "image/png", data: (await
|
|
6492
|
+
return { mediaType: "image/png", data: (await readFile3(this.evidenceFile(id))).toString("base64") };
|
|
5946
6493
|
},
|
|
5947
6494
|
"games/icon": async (params, call) => {
|
|
5948
6495
|
await this.ready;
|
|
5949
6496
|
const icon = await this.icon(params.game, call.signal);
|
|
5950
6497
|
return icon === null ? {} : { icon };
|
|
5951
6498
|
},
|
|
6499
|
+
"games/android/locate": async (params, call) => {
|
|
6500
|
+
await this.ready;
|
|
6501
|
+
const found = await this.locateAndroid(params.scriptId, call.signal);
|
|
6502
|
+
changed();
|
|
6503
|
+
return found;
|
|
6504
|
+
},
|
|
6505
|
+
"games/android/app": async (params) => {
|
|
6506
|
+
const info = await ctx.get("adgEmulators")?.appInfo?.(params.package, false);
|
|
6507
|
+
return { ...info?.label === void 0 ? {} : { label: info.label }, ...info?.icon === void 0 ? {} : { icon: info.icon } };
|
|
6508
|
+
},
|
|
5952
6509
|
"games/image": async (params) => {
|
|
5953
6510
|
await this.ready;
|
|
5954
6511
|
return this.picture(params.url);
|
|
@@ -6007,6 +6564,31 @@ var AdgGameIntel = class extends Service {
|
|
|
6007
6564
|
await this.showSra(sra, follow);
|
|
6008
6565
|
return {};
|
|
6009
6566
|
},
|
|
6567
|
+
"games/routine/set": async (params) => {
|
|
6568
|
+
await this.ready;
|
|
6569
|
+
const p = params;
|
|
6570
|
+
await this.setRoutine(p.game, p.routine, p.done, "user");
|
|
6571
|
+
return {};
|
|
6572
|
+
},
|
|
6573
|
+
"games/routine/add": async (params) => {
|
|
6574
|
+
await this.ready;
|
|
6575
|
+
const p = params;
|
|
6576
|
+
const { manifest } = this.game(p.game);
|
|
6577
|
+
const own = await this.routines.addOwn(p.game, p.name, p.period, this.clock.now());
|
|
6578
|
+
changed(p.game);
|
|
6579
|
+
return { routine: this.routineInfo(manifest, this.scriptsOf(p.game)).routines.find((r) => r.id === own.id) };
|
|
6580
|
+
},
|
|
6581
|
+
"games/routine/remove": async (params) => {
|
|
6582
|
+
await this.ready;
|
|
6583
|
+
const p = params;
|
|
6584
|
+
this.game(p.game);
|
|
6585
|
+
if (p.restore === true)
|
|
6586
|
+
await this.routines.restore(p.game);
|
|
6587
|
+
else if (p.routine !== void 0)
|
|
6588
|
+
await this.routines.remove(p.game, p.routine);
|
|
6589
|
+
changed(p.game);
|
|
6590
|
+
return {};
|
|
6591
|
+
},
|
|
6010
6592
|
"games/activity/progress": async (params) => {
|
|
6011
6593
|
await this.ready;
|
|
6012
6594
|
const { activityId, ...patch } = params;
|
|
@@ -6052,7 +6634,7 @@ var AdgGameIntel = class extends Service {
|
|
|
6052
6634
|
if (OWN_IMAGE.test(url) || SHOT_IMAGE.test(url)) {
|
|
6053
6635
|
const [kind, file] = url.split(":");
|
|
6054
6636
|
const mediaType2 = IMAGE_TYPES.find(([ext2]) => file.endsWith(`.${ext2}`))[1];
|
|
6055
|
-
const bytes2 = await
|
|
6637
|
+
const bytes2 = await readFile3(join3(this.imageDir(kind), file)).catch(() => {
|
|
6056
6638
|
throw new Error("\u8FD9\u5F20\u56FE\u7247\u5DF2\u7ECF\u4E0D\u5728\u4E86");
|
|
6057
6639
|
});
|
|
6058
6640
|
return { mediaType: mediaType2, data: bytes2.toString("base64") };
|
|
@@ -6060,9 +6642,9 @@ var AdgGameIntel = class extends Service {
|
|
|
6060
6642
|
if (!this.calendar.pictures().has(url) && !this.games.some((g) => g.manifest.art === url))
|
|
6061
6643
|
throw new Error("\u8FD9\u5F20\u56FE\u7247\u4E0D\u662F\u6570\u636E\u7AD9\u6216\u6E38\u620F\u5305\u7ED9\u7684\u5730\u5740");
|
|
6062
6644
|
const name = createHash2("sha256").update(url).digest("hex").slice(0, 32);
|
|
6063
|
-
const dir =
|
|
6645
|
+
const dir = join3(this.dir, "images");
|
|
6064
6646
|
for (const [ext2, mediaType2] of IMAGE_TYPES) {
|
|
6065
|
-
const cached = await
|
|
6647
|
+
const cached = await readFile3(join3(dir, `${name}.${ext2}`)).catch(() => void 0);
|
|
6066
6648
|
if (cached !== void 0)
|
|
6067
6649
|
return { mediaType: mediaType2, data: cached.toString("base64") };
|
|
6068
6650
|
}
|
|
@@ -6077,7 +6659,7 @@ var AdgGameIntel = class extends Service {
|
|
|
6077
6659
|
if (bytes.length > MAX_IMAGE_BYTES)
|
|
6078
6660
|
throw new Error("\u56FE\u7247\u592A\u5927");
|
|
6079
6661
|
await mkdir(dir, { recursive: true });
|
|
6080
|
-
await writeFile(
|
|
6662
|
+
await writeFile(join3(dir, `${name}.${ext}`), bytes);
|
|
6081
6663
|
return { mediaType, data: bytes.toString("base64") };
|
|
6082
6664
|
}
|
|
6083
6665
|
// ── games ──
|
|
@@ -6091,20 +6673,20 @@ var AdgGameIntel = class extends Service {
|
|
|
6091
6673
|
continue;
|
|
6092
6674
|
}
|
|
6093
6675
|
for (const id of entries) {
|
|
6094
|
-
const dir =
|
|
6676
|
+
const dir = join3(base, id);
|
|
6095
6677
|
let text;
|
|
6096
6678
|
try {
|
|
6097
|
-
text = await
|
|
6679
|
+
text = await readFile3(join3(dir, GAME_MANIFEST_FILE), "utf8");
|
|
6098
6680
|
} catch {
|
|
6099
6681
|
continue;
|
|
6100
6682
|
}
|
|
6101
6683
|
try {
|
|
6102
6684
|
const manifest = parseGameManifest(text, `${id}/${GAME_MANIFEST_FILE}`);
|
|
6103
6685
|
for (const source of manifest.sources) {
|
|
6104
|
-
if (!source.steam && !source.sra && !source.smw)
|
|
6686
|
+
if (!source.steam && !source.sra && !source.smw && !givesPools(source))
|
|
6105
6687
|
source.steam = steamNewsSource(source.homepage);
|
|
6106
6688
|
}
|
|
6107
|
-
const guide = await
|
|
6689
|
+
const guide = await readFile3(join3(dir, GAME_GUIDE_FILE), "utf8").catch(() => void 0);
|
|
6108
6690
|
found.set(manifest.id, { manifest, dir, builtin, ...builtin ? {} : { own: true }, ...guide === void 0 ? {} : { guide } });
|
|
6109
6691
|
} catch (error) {
|
|
6110
6692
|
log.warn(`game pack ${id}: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -6181,7 +6763,7 @@ var AdgGameIntel = class extends Service {
|
|
|
6181
6763
|
throw new Error(`\u627E\u4E0D\u5230\u56FE\u7247\u6587\u4EF6\uFF1A${full}`);
|
|
6182
6764
|
if (info.size > MAX_IMAGE_BYTES)
|
|
6183
6765
|
throw new Error("\u56FE\u7247\u592A\u5927\uFF08\u6700\u591A 8 MB\uFF09");
|
|
6184
|
-
return
|
|
6766
|
+
return readFile3(full);
|
|
6185
6767
|
}
|
|
6186
6768
|
timezone(game) {
|
|
6187
6769
|
return this.games.find((g) => g.manifest.id === game)?.manifest.timezone ?? "Asia/Shanghai";
|
|
@@ -6244,7 +6826,7 @@ var AdgGameIntel = class extends Service {
|
|
|
6244
6826
|
const path = from.replace(/^file:\/\/\/?/i, "");
|
|
6245
6827
|
const workspace = this.ctx.get("adgGateway")?.workspaceDir();
|
|
6246
6828
|
const full = isAbsolute(path) || workspace === void 0 ? path : resolve(workspace, path);
|
|
6247
|
-
return
|
|
6829
|
+
return readFile3(full).catch(() => {
|
|
6248
6830
|
throw new Error(`\u8BFB\u4E0D\u5230\u56FE\u7247\u6587\u4EF6\uFF1A${full}`);
|
|
6249
6831
|
});
|
|
6250
6832
|
}
|
|
@@ -6261,18 +6843,18 @@ var AdgGameIntel = class extends Service {
|
|
|
6261
6843
|
const file = `${createHash2("sha256").update(bytes).digest("hex").slice(0, 32)}.${ext}`;
|
|
6262
6844
|
const dir = this.imageDir(kind);
|
|
6263
6845
|
await mkdir(dir, { recursive: true });
|
|
6264
|
-
await writeFile(
|
|
6846
|
+
await writeFile(join3(dir, file), bytes);
|
|
6265
6847
|
return `${kind}:${file}`;
|
|
6266
6848
|
}
|
|
6267
6849
|
imageDir(kind) {
|
|
6268
|
-
return
|
|
6850
|
+
return join3(this.dir, "images", kind === "own" ? "own" : "shots");
|
|
6269
6851
|
}
|
|
6270
6852
|
/** Pictures the user added, and screenshots, that no event has any more. */
|
|
6271
6853
|
async sweepImages() {
|
|
6272
6854
|
for (const [kind, used] of [["own", this.calendar.ownImages()], ["shot", this.calendar.shotImages()]]) {
|
|
6273
6855
|
const dir = this.imageDir(kind);
|
|
6274
6856
|
const files = await readdir(dir).catch(() => []);
|
|
6275
|
-
await Promise.all(files.filter((f) => !used.has(`${kind}:${f}`)).map((f) => rm(
|
|
6857
|
+
await Promise.all(files.filter((f) => !used.has(`${kind}:${f}`)).map((f) => rm(join3(dir, f), { force: true }).catch(() => {
|
|
6276
6858
|
})));
|
|
6277
6859
|
}
|
|
6278
6860
|
}
|
|
@@ -6330,8 +6912,17 @@ var AdgGameIntel = class extends Service {
|
|
|
6330
6912
|
const mine = new Set([...byName, ...byDescription].filter(([, ids]) => ids.includes(gameId)).map(([rid]) => rid));
|
|
6331
6913
|
return { items: items.filter((i) => mine.has(i.rid)), from };
|
|
6332
6914
|
}
|
|
6333
|
-
/**
|
|
6915
|
+
/**
|
|
6916
|
+
* A game's icon, for its avatar: its PC program's, else its app's in the
|
|
6917
|
+
* emulator (a game played there first: `screen.target: emulator`); null when neither is known.
|
|
6918
|
+
*/
|
|
6334
6919
|
async icon(gameId, signal) {
|
|
6920
|
+
const phoneFirst = this.games.find((g) => g.manifest.id === gameId)?.manifest.screen?.target === "emulator";
|
|
6921
|
+
if (phoneFirst)
|
|
6922
|
+
return await this.androidIcon(gameId) ?? this.pcIcon(gameId, signal);
|
|
6923
|
+
return await this.pcIcon(gameId, signal) ?? this.androidIcon(gameId);
|
|
6924
|
+
}
|
|
6925
|
+
async pcIcon(gameId, signal) {
|
|
6335
6926
|
const program = await this.program(gameId);
|
|
6336
6927
|
if (program === void 0)
|
|
6337
6928
|
return null;
|
|
@@ -6342,6 +6933,92 @@ var AdgGameIntel = class extends Service {
|
|
|
6342
6933
|
return null;
|
|
6343
6934
|
}
|
|
6344
6935
|
}
|
|
6936
|
+
/**
|
|
6937
|
+
* The icon of the game's app in the emulator: one read before (on the
|
|
6938
|
+
* script page's 在模拟器里查找, or earlier here), else read now when the
|
|
6939
|
+
* emulator is already up; it is never started for an icon.
|
|
6940
|
+
*/
|
|
6941
|
+
async androidIcon(gameId) {
|
|
6942
|
+
const emulators = this.ctx.get("adgEmulators");
|
|
6943
|
+
if (emulators?.appInfo === void 0)
|
|
6944
|
+
return null;
|
|
6945
|
+
const packages = await this.androidPackages(gameId);
|
|
6946
|
+
for (const pkg of packages) {
|
|
6947
|
+
const icon = (await emulators.appInfo(pkg, false).catch(() => void 0))?.icon;
|
|
6948
|
+
if (icon !== void 0)
|
|
6949
|
+
return icon;
|
|
6950
|
+
}
|
|
6951
|
+
for (const pkg of packages.slice(0, 6)) {
|
|
6952
|
+
const icon = (await emulators.appInfo(pkg, true).catch(() => void 0))?.icon;
|
|
6953
|
+
if (icon !== void 0)
|
|
6954
|
+
return icon;
|
|
6955
|
+
}
|
|
6956
|
+
return null;
|
|
6957
|
+
}
|
|
6958
|
+
/** A game's Android packages: what its scripts start (saved on the script page, or their packs'), then the game pack's builds. */
|
|
6959
|
+
async androidPackages(gameId) {
|
|
6960
|
+
const runner = this.ctx.get("adgRunner")?.runner;
|
|
6961
|
+
const library = this.ctx.get("adgScripts")?.library;
|
|
6962
|
+
const out = [];
|
|
6963
|
+
const add = (pkg) => {
|
|
6964
|
+
if (pkg !== void 0 && !out.includes(pkg))
|
|
6965
|
+
out.push(pkg);
|
|
6966
|
+
};
|
|
6967
|
+
const scripts = this.scriptsOf(gameId);
|
|
6968
|
+
for (const id of scripts)
|
|
6969
|
+
add((await runner?.launch.get(id).catch(() => void 0))?.androidPackage);
|
|
6970
|
+
for (const id of scripts) {
|
|
6971
|
+
let pack;
|
|
6972
|
+
try {
|
|
6973
|
+
pack = library?.packOf(id) ?? library?.pack(id);
|
|
6974
|
+
} catch {
|
|
6975
|
+
pack = void 0;
|
|
6976
|
+
}
|
|
6977
|
+
add(pack?.manifest.game?.android?.package);
|
|
6978
|
+
}
|
|
6979
|
+
for (const p of this.games.find((g) => g.manifest.id === gameId)?.manifest.android?.packages ?? [])
|
|
6980
|
+
add(p.package);
|
|
6981
|
+
return out;
|
|
6982
|
+
}
|
|
6983
|
+
/**
|
|
6984
|
+
* Which installed app in the emulator is the game a script plays: hints from
|
|
6985
|
+
* the script's pack (game.name, game.android.package), its saved package,
|
|
6986
|
+
* and the game packs that list the script (names, aliases, android.packages:
|
|
6987
|
+
* one per client, like MAA's 客户端类型).
|
|
6988
|
+
*/
|
|
6989
|
+
async locateAndroid(scriptId, signal) {
|
|
6990
|
+
const emulators = this.ctx.get("adgEmulators");
|
|
6991
|
+
if (emulators?.findApps === void 0)
|
|
6992
|
+
throw new Error("\u6A21\u62DF\u5668\u63D2\u4EF6\u6CA1\u6709\u52A0\u8F7D");
|
|
6993
|
+
const library = this.ctx.get("adgScripts")?.library;
|
|
6994
|
+
let pack;
|
|
6995
|
+
try {
|
|
6996
|
+
pack = library?.packOf(scriptId)?.manifest;
|
|
6997
|
+
} catch {
|
|
6998
|
+
pack = void 0;
|
|
6999
|
+
}
|
|
7000
|
+
const settings = await this.ctx.get("adgRunner")?.runner.launch.get(scriptId).catch(() => void 0);
|
|
7001
|
+
const games = this.games.filter((g) => this.scriptsOf(g.manifest.id).includes(scriptId)).map((g) => g.manifest);
|
|
7002
|
+
const packages = [];
|
|
7003
|
+
const add = (p) => {
|
|
7004
|
+
const same = packages.find((q) => q.package.toLowerCase() === p.package.toLowerCase());
|
|
7005
|
+
if (same === void 0)
|
|
7006
|
+
packages.push({ package: p.package, source: p.source, ...p.client === void 0 ? {} : { client: p.client } });
|
|
7007
|
+
else if (same.client === void 0 && p.client !== void 0)
|
|
7008
|
+
same.client = p.client;
|
|
7009
|
+
};
|
|
7010
|
+
for (const g of games)
|
|
7011
|
+
for (const p of g.android?.packages ?? [])
|
|
7012
|
+
add({ package: p.package, client: p.client, source: `\u300C${g.name}\u300D\u8D44\u6599\u91CC\u7684${p.client ?? ""}\u5305\u540D` });
|
|
7013
|
+
if (pack?.game?.android?.package !== void 0)
|
|
7014
|
+
add({ package: pack.game.android.package, source: "\u811A\u672C\u5305\u5199\u7684\u5305\u540D" });
|
|
7015
|
+
if (settings?.androidPackage !== void 0)
|
|
7016
|
+
add({ package: settings.androidPackage, source: "\u4E4B\u524D\u4FDD\u5B58\u7684\u5305\u540D" });
|
|
7017
|
+
const names = [...new Set([pack?.game?.name, ...games.flatMap((g) => [g.name, ...g.aliases])].filter((n) => n !== void 0 && n.trim() !== ""))];
|
|
7018
|
+
if (packages.length === 0 && names.length === 0)
|
|
7019
|
+
throw new Error("\u4E0D\u77E5\u9053\u8FD9\u4E2A\u811A\u672C\u73A9\u7684\u662F\u54EA\u4E2A\u6E38\u620F\uFF1A\u811A\u672C\u5305\u6CA1\u6709\u5199 game\uFF0C\u6E38\u620F\u9875\u4E5F\u6CA1\u6709\u5173\u8054\u5B83");
|
|
7020
|
+
return emulators.findApps({ packages, names }, signal);
|
|
7021
|
+
}
|
|
6345
7022
|
/**
|
|
6346
7023
|
* Where a game's PC program is: the one a script that plays it starts (its
|
|
6347
7024
|
* saved 游戏位置), else where 自动查找 finds the program the packs that play
|
|
@@ -6405,6 +7082,240 @@ var AdgGameIntel = class extends Service {
|
|
|
6405
7082
|
throw new Error(`\u6CA1\u6709\u6E38\u620F\u300C${id}\u300D`);
|
|
6406
7083
|
return game;
|
|
6407
7084
|
}
|
|
7085
|
+
// ── 日常 / 周常 ──
|
|
7086
|
+
/**
|
|
7087
|
+
* The packs of the scripts that play a game (pack ids or library script ids), once each, with their names.
|
|
7088
|
+
* A user pack keeps the routines of the official one it replaced (withOfficialRoutines).
|
|
7089
|
+
*/
|
|
7090
|
+
scriptPacks(ids) {
|
|
7091
|
+
const library = this.ctx.get("adgScripts")?.library;
|
|
7092
|
+
if (library === void 0)
|
|
7093
|
+
return [];
|
|
7094
|
+
const names = new Map(library.list().scripts.map((s) => [s.id, s.name]));
|
|
7095
|
+
const out = /* @__PURE__ */ new Map();
|
|
7096
|
+
for (const id of ids) {
|
|
7097
|
+
let pack;
|
|
7098
|
+
try {
|
|
7099
|
+
pack = library.packOf(id);
|
|
7100
|
+
} catch {
|
|
7101
|
+
pack = void 0;
|
|
7102
|
+
}
|
|
7103
|
+
pack ??= library.pack(id);
|
|
7104
|
+
if (pack === void 0 || out.has(pack.manifest.id))
|
|
7105
|
+
continue;
|
|
7106
|
+
out.set(pack.manifest.id, { id: pack.manifest.id, name: names.get(id) ?? pack.manifest.name, manifest: withOfficialRoutines(pack.manifest, pack.over?.manifest) });
|
|
7107
|
+
}
|
|
7108
|
+
return [...out.values()];
|
|
7109
|
+
}
|
|
7110
|
+
routineDefs(manifest, scripts) {
|
|
7111
|
+
return gameRoutines(manifest, this.scriptPacks(scripts), this.routines.own(manifest.id), this.routines.hidden(manifest.id));
|
|
7112
|
+
}
|
|
7113
|
+
/** A game's routines as the page shows them, with what is done in the current period. */
|
|
7114
|
+
routineInfo(m, scripts) {
|
|
7115
|
+
const now = this.clock.now();
|
|
7116
|
+
const resets = resetsOf(m, now);
|
|
7117
|
+
const activities = this.calendar.list(m.id);
|
|
7118
|
+
const hidden = this.routines.hidden(m.id).length;
|
|
7119
|
+
const routines = this.routineDefs(m, scripts).map((def) => {
|
|
7120
|
+
const events = routineEvents(def, activities, now);
|
|
7121
|
+
const period = periodKey(def, resets, events, now);
|
|
7122
|
+
let done = period === void 0 ? void 0 : this.routines.done(m.id, def.id, period.key);
|
|
7123
|
+
if (def.period === "event") {
|
|
7124
|
+
const running = events.find((a) => (a.startsAt ?? 0) <= now);
|
|
7125
|
+
done = running?.finished === void 0 ? void 0 : done ?? { at: running.finished.at, by: "user" };
|
|
7126
|
+
}
|
|
7127
|
+
if (done !== void 0)
|
|
7128
|
+
done = { at: done.at, by: done.by, ...done.detail === void 0 ? {} : { detail: done.detail }, ...done.script === void 0 ? {} : { script: done.script }, ...done.runId === void 0 ? {} : { runId: done.runId } };
|
|
7129
|
+
return {
|
|
7130
|
+
id: def.id,
|
|
7131
|
+
name: def.name,
|
|
7132
|
+
period: def.period,
|
|
7133
|
+
from: def.from,
|
|
7134
|
+
links: def.links.flatMap((l) => l.text),
|
|
7135
|
+
...def.description === void 0 ? {} : { description: def.description },
|
|
7136
|
+
...done === void 0 ? {} : { done },
|
|
7137
|
+
...period?.end === void 0 ? {} : { resetsAt: period.end },
|
|
7138
|
+
...def.period === "event" ? { activities: events.map((a) => a.id) } : {}
|
|
7139
|
+
};
|
|
7140
|
+
});
|
|
7141
|
+
return { routines, resets: { daily: resets.daily.end, weekly: resets.weekly.end }, ...hidden === 0 ? {} : { hiddenRoutines: hidden } };
|
|
7142
|
+
}
|
|
7143
|
+
/** A game's routines as the agent reads them (game_routine), after looking through the period's runs. */
|
|
7144
|
+
async routineStatus(gameId) {
|
|
7145
|
+
await this.ready;
|
|
7146
|
+
const { manifest } = this.game(gameId);
|
|
7147
|
+
await this.backfill(true);
|
|
7148
|
+
const info = this.routineInfo(manifest, this.scriptsOf(gameId));
|
|
7149
|
+
return { game: gameId, routines: info.routines ?? [], resets: info.resets };
|
|
7150
|
+
}
|
|
7151
|
+
/**
|
|
7152
|
+
* Tick a routine off for the current period, or take it back: the person on
|
|
7153
|
+
* the game page (`user`), or an agent that saw it done (`agent`, with what it
|
|
7154
|
+
* saw). Found by id or by name.
|
|
7155
|
+
*/
|
|
7156
|
+
async setRoutine(gameId, routine, done, by = "user", detail) {
|
|
7157
|
+
const { manifest } = this.game(gameId);
|
|
7158
|
+
const defs = this.routineDefs(manifest, this.scriptsOf(gameId));
|
|
7159
|
+
const def = defs.find((r) => r.id === routine) ?? defs.find((r) => r.name === routine.trim());
|
|
7160
|
+
if (def === void 0)
|
|
7161
|
+
throw new Error(`\u6CA1\u6709\u65E5\u5E38\u300C${routine}\u300D\uFF1B\u6709\uFF1A${defs.map((r) => `${r.name}\uFF08${r.id}\uFF09`).join("\u3001") || "\u6CA1\u6709"}`);
|
|
7162
|
+
const now = this.clock.now();
|
|
7163
|
+
const events = routineEvents(def, this.calendar.list(gameId), now);
|
|
7164
|
+
const period = periodKey(def, resetsOf(manifest, now), events, now);
|
|
7165
|
+
if (period === void 0)
|
|
7166
|
+
throw new Error(`\u300C${def.name}\u300D\u73B0\u5728\u6CA1\u6709\u6B63\u5728\u8FDB\u884C\u7684\u4E00\u671F`);
|
|
7167
|
+
if (done) {
|
|
7168
|
+
await this.routines.unmark(gameId, def.id);
|
|
7169
|
+
await this.routines.mark(gameId, def.id, { key: period.key, at: now, by, ...detail === void 0 || detail.trim() === "" ? {} : { detail: detail.trim().slice(0, 200) } });
|
|
7170
|
+
} else
|
|
7171
|
+
await this.routines.unmark(gameId, def.id);
|
|
7172
|
+
const running = events.find((a) => (a.startsAt ?? 0) <= now);
|
|
7173
|
+
if (def.period === "event" && running !== void 0)
|
|
7174
|
+
await this.calendar.progress(running.id, { finished: done }, now);
|
|
7175
|
+
this.changed(gameId);
|
|
7176
|
+
return this.routineInfo(manifest, this.scriptsOf(gameId)).routines.find((r) => r.id === def.id);
|
|
7177
|
+
}
|
|
7178
|
+
/** The routines a run can tick off, worked out once per run: of the games its script plays, its pack's links and the games' own. */
|
|
7179
|
+
runHits = /* @__PURE__ */ new Map();
|
|
7180
|
+
runsDone = /* @__PURE__ */ new Set();
|
|
7181
|
+
ticking = Promise.resolve();
|
|
7182
|
+
routineHits(run) {
|
|
7183
|
+
const known = this.runHits.get(run.id);
|
|
7184
|
+
if (known !== void 0)
|
|
7185
|
+
return known;
|
|
7186
|
+
const hits = this.findHits(run);
|
|
7187
|
+
if (this.games.length > 0)
|
|
7188
|
+
this.runHits.set(run.id, hits);
|
|
7189
|
+
return hits;
|
|
7190
|
+
}
|
|
7191
|
+
findHits(run) {
|
|
7192
|
+
const hits = [];
|
|
7193
|
+
let packId;
|
|
7194
|
+
try {
|
|
7195
|
+
packId = this.ctx.get("adgScripts")?.library.packOf(run.scriptId)?.manifest.id;
|
|
7196
|
+
} catch {
|
|
7197
|
+
packId = void 0;
|
|
7198
|
+
}
|
|
7199
|
+
const byGame = this.scriptsByGame();
|
|
7200
|
+
for (const { manifest } of this.games) {
|
|
7201
|
+
const scripts = byGame.get(manifest.id) ?? manifest.scripts;
|
|
7202
|
+
if (!scripts.includes(run.scriptId) && (packId === void 0 || !scripts.includes(packId)))
|
|
7203
|
+
continue;
|
|
7204
|
+
for (const def of this.routineDefs(manifest, scripts)) {
|
|
7205
|
+
for (const link2 of def.links)
|
|
7206
|
+
if (link2.script === void 0 || link2.script === packId)
|
|
7207
|
+
hits.push({ game: manifest.id, def, link: link2 });
|
|
7208
|
+
}
|
|
7209
|
+
}
|
|
7210
|
+
return hits;
|
|
7211
|
+
}
|
|
7212
|
+
routineLine(run, line2) {
|
|
7213
|
+
if (run.kind !== "task" || line2.source === "adg")
|
|
7214
|
+
return;
|
|
7215
|
+
for (const hit of this.routineHits(run)) {
|
|
7216
|
+
if (hit.link.logs.some((re) => re.test(line2.text)))
|
|
7217
|
+
void this.tick(hit.game, hit.def, { at: line2.at, by: "log", detail: line2.text.trim().slice(0, 200), script: run.scriptName, runId: run.id });
|
|
7218
|
+
}
|
|
7219
|
+
}
|
|
7220
|
+
routineRun(run) {
|
|
7221
|
+
if (run.endedAt === void 0 || this.runsDone.has(run.id))
|
|
7222
|
+
return;
|
|
7223
|
+
this.runsDone.add(run.id);
|
|
7224
|
+
if (run.kind === "task" && run.state === "succeeded") {
|
|
7225
|
+
for (const hit of this.routineHits(run)) {
|
|
7226
|
+
if (hit.link.tasks.includes(run.taskId))
|
|
7227
|
+
void this.tick(hit.game, hit.def, { at: run.endedAt, by: "task", detail: run.taskTitle, script: run.scriptName, runId: run.id });
|
|
7228
|
+
}
|
|
7229
|
+
}
|
|
7230
|
+
setTimeout(() => {
|
|
7231
|
+
this.runHits.delete(run.id);
|
|
7232
|
+
this.runsDone.delete(run.id);
|
|
7233
|
+
}, 6e4).unref?.();
|
|
7234
|
+
}
|
|
7235
|
+
/**
|
|
7236
|
+
* Tick a routine off for its current period (one at a time: the book is one
|
|
7237
|
+
* file). What happened before the period began (yesterday's log line, last
|
|
7238
|
+
* week's run) does not count. @returns whether it was ticked off now.
|
|
7239
|
+
*/
|
|
7240
|
+
tick(gameId, def, done) {
|
|
7241
|
+
const result = this.ticking.then(async () => {
|
|
7242
|
+
await this.ready;
|
|
7243
|
+
const { manifest } = this.game(gameId);
|
|
7244
|
+
const now = this.clock.now();
|
|
7245
|
+
const events = routineEvents(def, this.calendar.list(gameId), now);
|
|
7246
|
+
const period = periodKey(def, resetsOf(manifest, now), events, now);
|
|
7247
|
+
if (period === void 0 || done.at < period.start || !await this.routines.mark(gameId, def.id, { key: period.key, ...done }))
|
|
7248
|
+
return false;
|
|
7249
|
+
const running = events.find((a) => (a.startsAt ?? 0) <= now);
|
|
7250
|
+
if (def.period === "event" && running !== void 0 && running.finished === void 0)
|
|
7251
|
+
await this.calendar.progress(running.id, { finished: true }, now);
|
|
7252
|
+
this.changed(gameId);
|
|
7253
|
+
return true;
|
|
7254
|
+
}).catch((error) => {
|
|
7255
|
+
this.log.warn(`routine ${def.id} of ${gameId} not ticked off: ${error instanceof Error ? error.message : String(error)}`);
|
|
7256
|
+
return false;
|
|
7257
|
+
});
|
|
7258
|
+
this.ticking = result;
|
|
7259
|
+
return result;
|
|
7260
|
+
}
|
|
7261
|
+
/** Runs already looked through, with the links they were read for (read again when those change). */
|
|
7262
|
+
scanned = /* @__PURE__ */ new Map();
|
|
7263
|
+
backfilling;
|
|
7264
|
+
backfilledAt = 0;
|
|
7265
|
+
/**
|
|
7266
|
+
* Tick off what the period's saved runs show: runs that ended before a
|
|
7267
|
+
* routine or its log pattern existed (an agent rewrote the pack), or before
|
|
7268
|
+
* this version. Each run is read once per set of links; `force` skips the
|
|
7269
|
+
* once-a-minute limit. @returns how many were ticked off.
|
|
7270
|
+
*/
|
|
7271
|
+
backfill(force = false) {
|
|
7272
|
+
if (this.backfilling !== void 0)
|
|
7273
|
+
return this.backfilling;
|
|
7274
|
+
if (!force && this.clock.now() - this.backfilledAt < 6e4)
|
|
7275
|
+
return Promise.resolve(0);
|
|
7276
|
+
this.backfilling = (async () => {
|
|
7277
|
+
await this.ready;
|
|
7278
|
+
const runner = this.ctx.get("adgRunner")?.runner;
|
|
7279
|
+
if (runner === void 0 || this.games.length === 0)
|
|
7280
|
+
return 0;
|
|
7281
|
+
const since = this.clock.now() - 42 * 24 * 36e5;
|
|
7282
|
+
let ticked = 0;
|
|
7283
|
+
for (const run of runner.list().filter((r) => r.kind === "task" && r.endedAt !== void 0 && r.startedAt >= since).reverse()) {
|
|
7284
|
+
const hits = this.findHits(run);
|
|
7285
|
+
if (hits.length === 0)
|
|
7286
|
+
continue;
|
|
7287
|
+
const signature = hits.map((h) => `${h.game}/${h.def.id}:${h.link.logs.map((r) => r.source).join("|")}:${h.link.tasks.join(",")}`).join(";");
|
|
7288
|
+
if (this.scanned.get(run.id) === signature)
|
|
7289
|
+
continue;
|
|
7290
|
+
if (run.state === "succeeded") {
|
|
7291
|
+
for (const h of hits)
|
|
7292
|
+
if (h.link.tasks.includes(run.taskId))
|
|
7293
|
+
ticked += Number(await this.tick(h.game, h.def, { at: run.endedAt, by: "task", detail: run.taskTitle, script: run.scriptName, runId: run.id }));
|
|
7294
|
+
}
|
|
7295
|
+
const patterns = [...new Set(hits.flatMap((h) => h.link.logs.map((re) => re.source)))];
|
|
7296
|
+
if (patterns.length > 0) {
|
|
7297
|
+
const read = await runner.readLog(run.id, { search: `/${patterns.join("|")}/`, limit: 2e3 }).catch(() => void 0);
|
|
7298
|
+
for (const line2 of read?.lines ?? []) {
|
|
7299
|
+
if (line2.source === "adg")
|
|
7300
|
+
continue;
|
|
7301
|
+
for (const h of hits) {
|
|
7302
|
+
if (h.link.logs.some((re) => re.test(line2.text)))
|
|
7303
|
+
ticked += Number(await this.tick(h.game, h.def, { at: line2.at, by: "log", detail: line2.text.trim().slice(0, 200), script: run.scriptName, runId: run.id }));
|
|
7304
|
+
}
|
|
7305
|
+
}
|
|
7306
|
+
}
|
|
7307
|
+
this.scanned.set(run.id, signature);
|
|
7308
|
+
}
|
|
7309
|
+
return ticked;
|
|
7310
|
+
})().catch((error) => {
|
|
7311
|
+
this.log.warn(`routines not filled in from past runs: ${error instanceof Error ? error.message : String(error)}`);
|
|
7312
|
+
return 0;
|
|
7313
|
+
}).finally(() => {
|
|
7314
|
+
this.backfilling = void 0;
|
|
7315
|
+
this.backfilledAt = this.clock.now();
|
|
7316
|
+
});
|
|
7317
|
+
return this.backfilling;
|
|
7318
|
+
}
|
|
6408
7319
|
infos() {
|
|
6409
7320
|
const scripts = this.scriptsByGame();
|
|
6410
7321
|
return this.games.map(({ manifest: m, builtin, followed, own }) => {
|
|
@@ -6422,7 +7333,7 @@ var AdgGameIntel = class extends Service {
|
|
|
6422
7333
|
scripts: scripts.get(m.id) ?? m.scripts,
|
|
6423
7334
|
timezone: m.timezone,
|
|
6424
7335
|
...m.screen === void 0 ? {} : { screen: { target: m.screen.target, ...m.screen.window === void 0 ? {} : { window: m.screen.window } } },
|
|
6425
|
-
sources: m.sources.map((s) => ({ id: s.id, name: s.name, ...s.homepage === void 0 ? {} : { homepage: s.homepage }, auto: readsItself(s), .../^link-\d+$/.test(s.id) && this.calendar.links(m.id).some((l) => l.id === s.id) ? { added: true } : {} })),
|
|
7336
|
+
sources: [...m.sources, ...poolSources(m).filter((s) => !m.sources.includes(s))].map((s) => ({ id: s.id, name: s.name, ...s.homepage === void 0 ? {} : { homepage: s.homepage }, auto: readsItself(s), .../^link-\d+$/.test(s.id) && this.calendar.links(m.id).some((l) => l.id === s.id) ? { added: true } : {} })),
|
|
6426
7337
|
builtin,
|
|
6427
7338
|
...m.art === void 0 ? {} : { art: m.art },
|
|
6428
7339
|
...banner === void 0 ? {} : { banner },
|
|
@@ -6434,7 +7345,8 @@ var AdgGameIntel = class extends Service {
|
|
|
6434
7345
|
...reading === void 0 ? {} : { reading },
|
|
6435
7346
|
...webReading === void 0 ? {} : { webReading },
|
|
6436
7347
|
...version === void 0 ? {} : { version },
|
|
6437
|
-
...pools.length === 0 ? {} : { pools }
|
|
7348
|
+
...pools.length === 0 ? {} : { pools },
|
|
7349
|
+
...m.single === true ? {} : this.routineInfo(m, scripts.get(m.id) ?? m.scripts)
|
|
6438
7350
|
};
|
|
6439
7351
|
});
|
|
6440
7352
|
}
|
|
@@ -6455,6 +7367,7 @@ var AdgGameIntel = class extends Service {
|
|
|
6455
7367
|
let notices = 0;
|
|
6456
7368
|
let version;
|
|
6457
7369
|
let pools;
|
|
7370
|
+
let wikiPools;
|
|
6458
7371
|
for (const source of sources) {
|
|
6459
7372
|
signal?.throwIfAborted();
|
|
6460
7373
|
const now = this.clock.now();
|
|
@@ -6463,6 +7376,10 @@ var AdgGameIntel = class extends Service {
|
|
|
6463
7376
|
notices += (await this.calendar.applyNotices(manifest.id, { id: source.id, name: source.name }, await readSteam(source.steam, this.fetch, signal), now)).length;
|
|
6464
7377
|
continue;
|
|
6465
7378
|
}
|
|
7379
|
+
if (givesPools(source)) {
|
|
7380
|
+
(wikiPools ??= []).push(...await this.readBanners(source, manifest, now, signal));
|
|
7381
|
+
continue;
|
|
7382
|
+
}
|
|
6466
7383
|
let events;
|
|
6467
7384
|
if (source.sra !== void 0) {
|
|
6468
7385
|
const read = await readSra(source.sra, manifest, now, this.fetch, signal);
|
|
@@ -6479,6 +7396,19 @@ var AdgGameIntel = class extends Service {
|
|
|
6479
7396
|
failures.push(`${source.name}\uFF1A${error instanceof Error ? error.message : String(error)}`);
|
|
6480
7397
|
}
|
|
6481
7398
|
}
|
|
7399
|
+
if ((pools?.length ?? 0) === 0 && selected === void 0) {
|
|
7400
|
+
for (const source of poolSources(manifest).filter((s) => !sources.includes(s))) {
|
|
7401
|
+
try {
|
|
7402
|
+
(wikiPools ??= []).push(...await this.readBanners(source, manifest, this.clock.now(), signal));
|
|
7403
|
+
} catch (error) {
|
|
7404
|
+
failures.push(`${source.name}\uFF1A${error instanceof Error ? error.message : String(error)}`);
|
|
7405
|
+
}
|
|
7406
|
+
}
|
|
7407
|
+
}
|
|
7408
|
+
if ((pools?.length ?? 0) === 0 && wikiPools !== void 0)
|
|
7409
|
+
pools = wikiPools;
|
|
7410
|
+
else if ((pools?.length ?? 0) === 0 && poolSources(manifest).length > 0)
|
|
7411
|
+
pools = void 0;
|
|
6482
7412
|
if (failures.length > 0 && count + notices === 0)
|
|
6483
7413
|
await this.calendar.refreshFailed(manifest.id, failures.join("\uFF1B"), this.clock.now());
|
|
6484
7414
|
else
|
|
@@ -6489,6 +7419,10 @@ var AdgGameIntel = class extends Service {
|
|
|
6489
7419
|
await this.sweepImages();
|
|
6490
7420
|
return results;
|
|
6491
7421
|
}
|
|
7422
|
+
/** A banner source (a wiki's SMW data, ennead's miHoYo calendar). */
|
|
7423
|
+
readBanners(source, manifest, now, signal) {
|
|
7424
|
+
return source.pools !== void 0 ? readPools(source.pools, manifest, now, this.fetch, signal) : readHoyo(source.hoyo, now, this.fetch, signal);
|
|
7425
|
+
}
|
|
6492
7426
|
// ── what the agent read ──
|
|
6493
7427
|
/** Announcements the agent read (game_notice), each credited to the site it came from. */
|
|
6494
7428
|
async recordNotices(gameId, notices) {
|
|
@@ -6533,7 +7467,7 @@ var AdgGameIntel = class extends Service {
|
|
|
6533
7467
|
if (a.screen?.evidence !== true || a.screen.image !== void 0)
|
|
6534
7468
|
continue;
|
|
6535
7469
|
const file = this.evidenceFile(a.id);
|
|
6536
|
-
const bytes = await
|
|
7470
|
+
const bytes = await readFile3(file).catch(() => void 0);
|
|
6537
7471
|
if (bytes === void 0)
|
|
6538
7472
|
continue;
|
|
6539
7473
|
const kept = await this.keepImage(bytes, "shot").catch(() => void 0);
|
|
@@ -6547,7 +7481,7 @@ var AdgGameIntel = class extends Service {
|
|
|
6547
7481
|
}
|
|
6548
7482
|
/** Where a screenshot was kept before `shot:` pictures. */
|
|
6549
7483
|
evidenceFile(activityId) {
|
|
6550
|
-
return
|
|
7484
|
+
return join3(this.dir, "evidence", `${activityId.replace(/[^\p{L}\p{N}-]+/gu, "_")}.png`);
|
|
6551
7485
|
}
|
|
6552
7486
|
/** Ask the agent to read the game screen, in a session of its own. @returns the session id. */
|
|
6553
7487
|
/**
|
|
@@ -6575,13 +7509,13 @@ var AdgGameIntel = class extends Service {
|
|
|
6575
7509
|
const existing = this.games.find((g) => g.manifest.id === manifest.id);
|
|
6576
7510
|
if (existing !== void 0 && existing.builtin && existing.followed !== true)
|
|
6577
7511
|
throw new Error(`\u5DF2\u7ECF\u6709\u6280\u80FD\u5E93\u7684\u6E38\u620F\u5305\u300C${existing.manifest.name}\u300D\uFF08${manifest.id}\uFF09\uFF0C\u6362\u4E00\u4E2A id\uFF0C\u6216\u8005\u76F4\u63A5\u7528\u5B83`);
|
|
6578
|
-
const dir =
|
|
7512
|
+
const dir = join3(this.dir, manifest.id);
|
|
6579
7513
|
await mkdir(dir, { recursive: true });
|
|
6580
|
-
await writeFile(
|
|
7514
|
+
await writeFile(join3(dir, GAME_MANIFEST_FILE), `# \u7531 agent \u7528 game_add \u5199\u7684\u6E38\u620F\u5305\uFF1B\u53EF\u4EE5\u76F4\u63A5\u6539\uFF08JSON \u4E5F\u662F YAML\uFF09\u3002
|
|
6581
7515
|
${JSON.stringify(input, null, 2)}
|
|
6582
7516
|
`);
|
|
6583
7517
|
if (guide !== void 0 && guide.trim() !== "") {
|
|
6584
|
-
await writeFile(
|
|
7518
|
+
await writeFile(join3(dir, GAME_GUIDE_FILE), `---
|
|
6585
7519
|
name: game-${manifest.id}
|
|
6586
7520
|
description: ${JSON.stringify(`${manifest.name}\u7684\u6D3B\u52A8\u548C\u8D44\u8BAF\uFF1A\u4ECE\u54EA\u91CC\u770B\u3001\u600E\u4E48\u770B\u3002\u7528\u6237\u95EE${manifest.name}\u7684\u6D3B\u52A8\u65F6\u4F7F\u7528\u3002`)}
|
|
6587
7521
|
---
|
|
@@ -6643,9 +7577,9 @@ ${guide.trim()}
|
|
|
6643
7577
|
if (sra !== void 0)
|
|
6644
7578
|
return this.showSra(sra.sra, true);
|
|
6645
7579
|
const id = await this.freeId(wanted);
|
|
6646
|
-
const dir =
|
|
7580
|
+
const dir = join3(this.dir, id);
|
|
6647
7581
|
await mkdir(dir, { recursive: true });
|
|
6648
|
-
await writeFile(
|
|
7582
|
+
await writeFile(join3(dir, GAME_MANIFEST_FILE), `# \u5728\u6E38\u620F\u9875\u6309\u540D\u5B57\u6DFB\u52A0\u7684\u6E38\u620F\uFF1A\u6765\u6E90\u7531 agent \u627E\uFF08\u6E38\u620F\u9875\u4E0A\u7684\u300C\u8BA9 agent \u53BB\u627E\u300D\uFF09\uFF0C\u4E5F\u53EF\u4EE5\u76F4\u63A5\u6539\uFF08JSON \u4E5F\u662F YAML\uFF09\u3002
|
|
6649
7583
|
${JSON.stringify({ id, name: wanted, sources: [] }, null, 2)}
|
|
6650
7584
|
`);
|
|
6651
7585
|
await this.loadGames(this.log);
|
|
@@ -6691,6 +7625,7 @@ ${JSON.stringify({ id, name: wanted, sources: [] }, null, 2)}
|
|
|
6691
7625
|
} else if (game.own === true) {
|
|
6692
7626
|
await rm(game.dir, { recursive: true, force: true });
|
|
6693
7627
|
await this.calendar.forget(gameId);
|
|
7628
|
+
await this.routines.forget(gameId);
|
|
6694
7629
|
} else {
|
|
6695
7630
|
await this.calendar.hide(gameId, true);
|
|
6696
7631
|
}
|
|
@@ -6900,7 +7835,13 @@ ${JSON.stringify({ id, name: wanted, sources: [] }, null, 2)}
|
|
|
6900
7835
|
return { title, text };
|
|
6901
7836
|
}
|
|
6902
7837
|
reportGames() {
|
|
6903
|
-
|
|
7838
|
+
const scripts = this.scriptsByGame();
|
|
7839
|
+
return this.games.map((g) => ({
|
|
7840
|
+
id: g.manifest.id,
|
|
7841
|
+
name: g.manifest.name,
|
|
7842
|
+
timezone: g.manifest.timezone,
|
|
7843
|
+
...g.manifest.single === true ? {} : { routines: this.routineInfo(g.manifest, scripts.get(g.manifest.id) ?? g.manifest.scripts).routines }
|
|
7844
|
+
}));
|
|
6904
7845
|
}
|
|
6905
7846
|
/**
|
|
6906
7847
|
* The agent's summary of the recent events (just started, ending soon,
|
|
@@ -6922,7 +7863,7 @@ ${JSON.stringify({ id, name: wanted, sources: [] }, null, 2)}
|
|
|
6922
7863
|
const work = await conversations.prepareTask(GAME_ROLE.id, `\u65E5\u62A5\uFF1A${local.month}\u6708${local.day}\u65E5`);
|
|
6923
7864
|
const prompt = [
|
|
6924
7865
|
"\u628A\u4E0B\u9762\u8FD9\u4E9B\u8FD1\u671F\u7684\u6E38\u620F\u6D3B\u52A8\u5199\u6210\u4ECA\u5929\u53D1\u5230\u98DE\u4E66\u7684\u65E5\u62A5\u6B63\u6587\u3002\u53EA\u6839\u636E\u7ED9\u51FA\u7684\u5185\u5BB9\u5199\uFF0C\u4E0D\u8C03\u7528\u5DE5\u5177\uFF0C\u4E0D\u63D0\u95EE\u3002",
|
|
6925
|
-
"\u8981\u6C42\uFF1A\u4E2D\u6587\uFF0C\u6309\u6E38\u620F\u5206\u6BB5\uFF08\u6BB5\u9996\u7528\u3010\u6E38\u620F\u540D\u3011\uFF09\uFF0C\u6BCF\u4E2A\u6E38\u620F\u4E00\u4E24\u53E5\uFF1B\u5148\u8BF4\u5FEB\u7ED3\u675F\u4E14\u6CA1\u505A\u5B8C\u7684\uFF08\u5199\u6E05\u5269\u51E0\u5929\u3001\u8FD8\u5DEE\u4EC0\u4E48\uFF09\uFF0C\
|
|
7866
|
+
"\u8981\u6C42\uFF1A\u4E2D\u6587\uFF0C\u6309\u6E38\u620F\u5206\u6BB5\uFF08\u6BB5\u9996\u7528\u3010\u6E38\u620F\u540D\u3011\uFF09\uFF0C\u6BCF\u4E2A\u6E38\u620F\u4E00\u4E24\u53E5\uFF1B\u5148\u8BF4\u65E5\u5E38\u3001\u5468\u5E38\u8FD8\u5DEE\u54EA\u51E0\u9879\u3001\u4EC0\u4E48\u65F6\u5019\u91CD\u7F6E\uFF08\u90FD\u505A\u5B8C\u4E86\u4E00\u53E5\u5E26\u8FC7\uFF1B\u5468\u5E38\u5FEB\u91CD\u7F6E\u8FD8\u6CA1\u505A\u5B8C\u8981\u63D0\u9192\uFF09\uFF0C\u518D\u8BF4\u5FEB\u7ED3\u675F\u4E14\u6CA1\u505A\u5B8C\u7684\u6D3B\u52A8\uFF08\u5199\u6E05\u5269\u51E0\u5929\u3001\u8FD8\u5DEE\u4EC0\u4E48\uFF09\uFF0C\u6700\u540E\u8BF4\u521A\u5F00\u59CB\u548C\u5373\u5C06\u5F00\u59CB\u7684\uFF1B\u7528\u6237\u5DF2\u505A\u5B8C\u7684\u4E0D\u7528\u63D0\u9192\uFF1B\u4E0D\u7528 Markdown \u6807\u9898\u3001\u52A0\u7C97\u6216\u8868\u683C\uFF1B\u6574\u7BC7\u4E0D\u8D85\u8FC7 12 \u884C\u3002\u8BED\u6C14\u3001\u79F0\u547C\u548C\u81EA\u79F0\u6309\u4F60\u7684\u300C\u56DE\u590D\u98CE\u683C\u300D\u6765\uFF08\u6CA1\u6709\u8BBE\u5B9A\u5C31\u5E73\u5B9E\u5730\u5199\uFF09\uFF1A\u53EF\u4EE5\u7528\u4E00\u53E5\u7B26\u5408\u98CE\u683C\u7684\u8BDD\u5F00\u5934\uFF0C\u5185\u5BB9\u7167\u4E0A\u9762\u7684\u8981\u6C42\uFF0C\u4E0D\u8981\u5BA2\u5957\u7684\u7ED3\u675F\u8BED\u3002",
|
|
6926
7867
|
"",
|
|
6927
7868
|
digest
|
|
6928
7869
|
].join("\n");
|
|
@@ -6989,10 +7930,15 @@ export {
|
|
|
6989
7930
|
DailyReport,
|
|
6990
7931
|
GAME_ROLE,
|
|
6991
7932
|
OWN_FIELDS,
|
|
7933
|
+
POOL_SOURCES,
|
|
7934
|
+
RoutineBook,
|
|
6992
7935
|
buildReport,
|
|
7936
|
+
dailyPeriod,
|
|
6993
7937
|
daysLeft,
|
|
6994
7938
|
lib_default as default,
|
|
7939
|
+
gameRoutines,
|
|
6995
7940
|
gameTools,
|
|
7941
|
+
givesPools,
|
|
6996
7942
|
idKey,
|
|
6997
7943
|
imageType,
|
|
6998
7944
|
leftText,
|
|
@@ -7000,9 +7946,15 @@ export {
|
|
|
7000
7946
|
nameKey,
|
|
7001
7947
|
parseAsk,
|
|
7002
7948
|
parseDateText,
|
|
7949
|
+
parseHoyo,
|
|
7950
|
+
parsePools,
|
|
7003
7951
|
parseRemaining,
|
|
7004
7952
|
parseSra,
|
|
7005
7953
|
parseSteam,
|
|
7954
|
+
patternText,
|
|
7955
|
+
poolSources,
|
|
7956
|
+
readHoyo,
|
|
7957
|
+
readPools,
|
|
7006
7958
|
readSmw,
|
|
7007
7959
|
readSra,
|
|
7008
7960
|
readSteam,
|
|
@@ -7013,5 +7965,6 @@ export {
|
|
|
7013
7965
|
shortDate,
|
|
7014
7966
|
smwQuery,
|
|
7015
7967
|
wallClock,
|
|
7968
|
+
weeklyPeriod,
|
|
7016
7969
|
zonedTime
|
|
7017
7970
|
};
|