dsh-multigameassistant 2.1.1 → 2.2.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 +16 -1
- package/lib/analyzer.js +37 -81
- package/lib/browser.js +1 -1
- package/lib/{chunk-5PDYWE24.js → chunk-26JIEF6M.js} +153 -5
- package/lib/{chunk-SHTX4AGU.js → chunk-6DSSLS7I.js} +26 -0
- package/lib/{chunk-VOTN4IHB.js → chunk-EKTA4OYC.js} +3 -3
- package/lib/{chunk-UQLHGLMP.js → chunk-I4NHWXKH.js} +3 -3
- package/lib/{chunk-FBDVN6Q2.js → chunk-ICJLH3DP.js} +1 -1
- package/lib/chunk-J4QJC6UZ.js +22944 -0
- package/lib/chunk-J4QJC6UZ.js.LEGAL.txt +8 -0
- package/lib/{chunk-MQG5FLOG.js → chunk-KTOQFJ7R.js} +381 -36
- package/lib/{chunk-NM6H6WCQ.js → chunk-NEUZQ7TI.js} +237 -16
- package/lib/emulator.js +2 -2
- package/lib/feishu.js +5 -5
- package/lib/game-intel.js +454 -57
- package/lib/gateway.js +14 -6
- package/lib/guard.js +2 -2
- package/lib/intervene.js +8 -6
- package/lib/low-context.js +3 -3
- package/lib/monitor.js +4 -4
- package/lib/notify.js +5 -5
- package/lib/orchestrator.js +8 -8
- package/lib/qqbot.js +5 -5
- package/lib/runner.js +4 -4
- package/lib/scheduler.js +2 -2
- package/lib/script-registry.js +33 -3705
- package/lib/webapi-GDSF5EWP.js +2481 -0
- package/package.json +1 -1
- package/skills/game-intel.md +9 -1
- package/skills/script-analysis.md +30 -3
- package/skills/web-reading.md +7 -2
- package/web/assets/index-C5cMI4PK.css +1 -0
- package/web/assets/index-ClYIoZUR.js +244 -0
- package/web/assets/index-ClYIoZUR.js.map +1 -0
- package/web/index.html +2 -2
- package/lib/chunk-RFCFA5P5.js +0 -11
- package/lib/games/arknights/game.yaml +0 -36
- package/lib/games/endfield/game.yaml +0 -25
- package/lib/games/starrail/game.yaml +0 -33
- package/lib/packs/maa/adg.script.yaml +0 -220
- package/lib/packs/maaend/adg.script.yaml +0 -160
- package/lib/packs/march7th/adg.script.yaml +0 -216
- package/web/assets/index-CL3SeTW9.css +0 -1
- package/web/assets/index-GYwpGP3f.js +0 -244
- package/web/assets/index-GYwpGP3f.js.map +0 -1
package/lib/game-intel.js
CHANGED
|
@@ -1,44 +1,43 @@
|
|
|
1
1
|
import { createRequire as __adgCreateRequire } from 'node:module'; import { dirname as __adgDirname } from 'node:path'; import { fileURLToPath as __adgFileURLToPath } from 'node:url'; const require = __adgCreateRequire(import.meta.url); const __filename = __adgFileURLToPath(import.meta.url); const __dirname = __adgDirname(__filename);
|
|
2
|
-
import {
|
|
3
|
-
GAMES_DIR
|
|
4
|
-
} from "./chunk-RFCFA5P5.js";
|
|
5
2
|
import {
|
|
6
3
|
GAME_GUIDE_FILE,
|
|
7
4
|
GAME_MANIFEST_FILE,
|
|
8
5
|
GameManifest,
|
|
9
6
|
parseGameManifest
|
|
10
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-26JIEF6M.js";
|
|
11
8
|
import {
|
|
12
9
|
sessionConversations
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
10
|
+
} from "./chunk-I4NHWXKH.js";
|
|
11
|
+
import "./chunk-KTOQFJ7R.js";
|
|
12
|
+
import "./chunk-ICJLH3DP.js";
|
|
16
13
|
import {
|
|
17
14
|
ExeIcons,
|
|
18
15
|
writeFileAtomic
|
|
19
16
|
} from "./chunk-RESS7WVY.js";
|
|
20
17
|
import {
|
|
21
18
|
GAMES_CAPABILITY,
|
|
19
|
+
GameNotice,
|
|
22
20
|
GamesSettings,
|
|
23
21
|
OWN_IMAGE,
|
|
24
22
|
OWN_SOURCE,
|
|
25
23
|
SCREEN_SOURCE,
|
|
26
24
|
SHOT_IMAGE,
|
|
27
25
|
taskMessage
|
|
28
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-NEUZQ7TI.js";
|
|
29
27
|
import {
|
|
30
28
|
external_exports
|
|
31
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-6DSSLS7I.js";
|
|
32
30
|
import "./chunk-2UFLGPDY.js";
|
|
33
31
|
|
|
34
32
|
// packages/game-intel/lib/index.js
|
|
35
|
-
import { createHash } from "node:crypto";
|
|
33
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
36
34
|
import { existsSync } from "node:fs";
|
|
37
35
|
import { mkdir as mkdir2, readdir, readFile as readFile2, rm, writeFile } from "node:fs/promises";
|
|
38
36
|
import { isAbsolute, join as join2, resolve } from "node:path";
|
|
39
37
|
import { Service } from "@deepseek-ai/cordis";
|
|
40
38
|
|
|
41
39
|
// packages/game-intel/lib/calendar.js
|
|
40
|
+
import { createHash } from "node:crypto";
|
|
42
41
|
import { mkdir, readFile } from "node:fs/promises";
|
|
43
42
|
import { join } from "node:path";
|
|
44
43
|
|
|
@@ -180,6 +179,10 @@ function saidBy(item, source) {
|
|
|
180
179
|
return item.screen === void 0 ? void 0 : { endsAt: item.screen.endsAt, cover: item.screen.image };
|
|
181
180
|
return item.facts[source];
|
|
182
181
|
}
|
|
182
|
+
var MAX_NOTICES = 40;
|
|
183
|
+
function noticeKey(url, title) {
|
|
184
|
+
return url !== void 0 && url !== "" ? `u:${url.trim().replace(/[?#].*$/, "").replace(/\/+$/, "").toLowerCase()}` : `t:${title.trim().replace(/\s+/g, " ").toLowerCase()}`;
|
|
185
|
+
}
|
|
183
186
|
var StoredSchema = external_exports.object({
|
|
184
187
|
activities: external_exports.array(external_exports.looseObject({ id: external_exports.string(), game: external_exports.string(), name: external_exports.string() })).default([]),
|
|
185
188
|
refreshed: external_exports.record(external_exports.string(), external_exports.object({ at: external_exports.number(), ok: external_exports.boolean(), count: external_exports.number(), detail: external_exports.string().optional() })).default({}),
|
|
@@ -187,14 +190,21 @@ var StoredSchema = external_exports.object({
|
|
|
187
190
|
report: external_exports.object({ lastSentAt: external_exports.number().optional(), lastDay: external_exports.string().optional(), lastResult: external_exports.string().optional(), lastText: external_exports.string().optional() }).default({}),
|
|
188
191
|
versions: external_exports.record(external_exports.string(), external_exports.object({ name: external_exports.string(), title: external_exports.string().optional(), startsAt: external_exports.number().optional(), endsAt: external_exports.number().optional(), cover: external_exports.string().optional(), source: external_exports.string(), at: external_exports.number() })).default({}),
|
|
189
192
|
pools: external_exports.record(external_exports.string(), external_exports.array(external_exports.object({ name: external_exports.string(), type: external_exports.string().optional(), startsAt: external_exports.number().optional(), endsAt: external_exports.number(), cover: external_exports.string().optional(), up: external_exports.array(external_exports.string()) }))).default({}),
|
|
190
|
-
settings: external_exports.object({
|
|
193
|
+
settings: external_exports.object({
|
|
194
|
+
report: GamesSettings.shape.report.partial().default({}),
|
|
195
|
+
followed: external_exports.array(external_exports.string()).default([]),
|
|
196
|
+
/** Game packs taken off the game page (the pack stays installed). */
|
|
197
|
+
hidden: external_exports.array(external_exports.string()).default([])
|
|
198
|
+
}).default({ report: {}, followed: [], hidden: [] }),
|
|
191
199
|
/** Pages the user added to a game (games/source/add), by game. */
|
|
192
|
-
links: external_exports.record(external_exports.string(), external_exports.array(external_exports.object({ id: external_exports.string(), name: external_exports.string(), url: external_exports.string(), at: external_exports.number() }))).default({})
|
|
200
|
+
links: external_exports.record(external_exports.string(), external_exports.array(external_exports.object({ id: external_exports.string(), name: external_exports.string(), url: external_exports.string(), at: external_exports.number() }))).default({}),
|
|
201
|
+
/** Announcements (version updates, long-term notices, news), by game. */
|
|
202
|
+
notices: external_exports.record(external_exports.string(), external_exports.array(GameNotice)).default({})
|
|
193
203
|
});
|
|
194
204
|
var Calendar = class {
|
|
195
205
|
#dir;
|
|
196
206
|
#items = [];
|
|
197
|
-
#saved = { refreshed: {}, readings: {}, report: {}, settings: { report: {}, followed: [] }, versions: {}, pools: {}, links: {} };
|
|
207
|
+
#saved = { refreshed: {}, readings: {}, report: {}, settings: { report: {}, followed: [], hidden: [] }, versions: {}, pools: {}, links: {}, notices: {} };
|
|
198
208
|
constructor(dir) {
|
|
199
209
|
this.#dir = dir;
|
|
200
210
|
}
|
|
@@ -205,7 +215,7 @@ var Calendar = class {
|
|
|
205
215
|
try {
|
|
206
216
|
const saved = StoredSchema.parse(JSON.parse(await readFile(this.file, "utf8")));
|
|
207
217
|
this.#items = saved.activities.map((a) => migrate({ todo: [], done: [], ...a, names: Array.isArray(a["names"]) ? a["names"] : [a.name] }));
|
|
208
|
-
this.#saved = { refreshed: saved.refreshed, readings: saved.readings, report: saved.report, settings: saved.settings, versions: saved.versions, pools: saved.pools, links: saved.links };
|
|
218
|
+
this.#saved = { refreshed: saved.refreshed, readings: saved.readings, report: saved.report, settings: saved.settings, versions: saved.versions, pools: saved.pools, links: saved.links, notices: saved.notices };
|
|
209
219
|
} catch {
|
|
210
220
|
}
|
|
211
221
|
}
|
|
@@ -225,7 +235,7 @@ var Calendar = class {
|
|
|
225
235
|
}
|
|
226
236
|
get settings() {
|
|
227
237
|
const saved = Object.fromEntries(Object.entries(this.#saved.settings.report).filter(([, v]) => v !== void 0));
|
|
228
|
-
return { report: { ...DEFAULT_SETTINGS.report, ...saved }, followed: [...this.#saved.settings.followed] };
|
|
238
|
+
return { report: { ...DEFAULT_SETTINGS.report, ...saved }, followed: [...this.#saved.settings.followed], hidden: [...this.#saved.settings.hidden] };
|
|
229
239
|
}
|
|
230
240
|
get report() {
|
|
231
241
|
return this.#saved.report;
|
|
@@ -255,6 +265,10 @@ var Calendar = class {
|
|
|
255
265
|
for (const p of list)
|
|
256
266
|
if (p.cover !== void 0)
|
|
257
267
|
out.add(p.cover);
|
|
268
|
+
for (const list of Object.values(this.#saved.notices))
|
|
269
|
+
for (const n of list)
|
|
270
|
+
if (n.cover !== void 0)
|
|
271
|
+
out.add(n.cover);
|
|
258
272
|
return out;
|
|
259
273
|
}
|
|
260
274
|
version(game) {
|
|
@@ -293,6 +307,79 @@ var Calendar = class {
|
|
|
293
307
|
await this.save();
|
|
294
308
|
return this.settings;
|
|
295
309
|
}
|
|
310
|
+
/** Take a game pack off the game page, or put it back (its events are kept for then). */
|
|
311
|
+
async hide(gameId, hidden) {
|
|
312
|
+
const list = this.#saved.settings.hidden.filter((id) => id !== gameId);
|
|
313
|
+
this.#saved.settings.hidden = hidden ? [...list, gameId] : list;
|
|
314
|
+
await this.save();
|
|
315
|
+
}
|
|
316
|
+
/** Forget everything about a game (one made here that is deleted): its events, readings, version, pools and pages. */
|
|
317
|
+
async forget(gameId) {
|
|
318
|
+
this.#items = this.#items.filter((a) => a.game !== gameId);
|
|
319
|
+
for (const key of [gameId, `${gameId}#web`])
|
|
320
|
+
delete this.#saved.readings[key];
|
|
321
|
+
delete this.#saved.refreshed[gameId];
|
|
322
|
+
delete this.#saved.versions[gameId];
|
|
323
|
+
delete this.#saved.pools[gameId];
|
|
324
|
+
delete this.#saved.links[gameId];
|
|
325
|
+
delete this.#saved.notices[gameId];
|
|
326
|
+
this.#saved.settings.hidden = this.#saved.settings.hidden.filter((id) => id !== gameId);
|
|
327
|
+
await this.save();
|
|
328
|
+
}
|
|
329
|
+
/** Announcements (of one game, or all): the long-term ones first, then the newest. */
|
|
330
|
+
notices(game) {
|
|
331
|
+
const all = game === void 0 ? Object.values(this.#saved.notices).flat() : this.#saved.notices[game] ?? [];
|
|
332
|
+
return [...all].sort((a, b) => Number(b.lasting === true) - Number(a.lasting === true) || (b.publishedAt ?? b.at) - (a.publishedAt ?? a.at));
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Keep announcements a data site gives or the agent read. One already kept
|
|
336
|
+
* (the same address, else the same title) is brought up to date; besides
|
|
337
|
+
* the long-term ones, the newest ${MAX_NOTICES} are kept.
|
|
338
|
+
* @returns them as kept.
|
|
339
|
+
*/
|
|
340
|
+
async applyNotices(game, source, read, now) {
|
|
341
|
+
const list = [...this.#saved.notices[game] ?? []];
|
|
342
|
+
const out = [];
|
|
343
|
+
for (const n of read) {
|
|
344
|
+
const title = n.title.replace(/\s+/g, " ").trim();
|
|
345
|
+
if (title === "")
|
|
346
|
+
continue;
|
|
347
|
+
const url = n.url?.trim() || void 0;
|
|
348
|
+
const key = noticeKey(url, title);
|
|
349
|
+
const at = list.findIndex((x) => noticeKey(x.url, x.title) === key || url !== void 0 && x.url === void 0 && noticeKey(void 0, x.title) === noticeKey(void 0, title));
|
|
350
|
+
const before = at < 0 ? void 0 : list[at];
|
|
351
|
+
const keep = (value, old) => value ?? old;
|
|
352
|
+
const publishedAt = keep(n.publishedAt, before?.publishedAt);
|
|
353
|
+
const version = keep(n.version?.trim() || void 0, before?.version);
|
|
354
|
+
const summary = keep(n.summary?.trim() || void 0, before?.summary);
|
|
355
|
+
const cover = keep(n.cover?.trim() || void 0, before?.cover);
|
|
356
|
+
const lasting = n.lasting ?? before?.lasting;
|
|
357
|
+
const next = {
|
|
358
|
+
id: before?.id ?? `${game}/${createHash("sha1").update(key).digest("hex").slice(0, 12)}`,
|
|
359
|
+
game,
|
|
360
|
+
title,
|
|
361
|
+
kind: n.kind,
|
|
362
|
+
source,
|
|
363
|
+
at: now,
|
|
364
|
+
...publishedAt === void 0 ? {} : { publishedAt },
|
|
365
|
+
...version === void 0 ? {} : { version },
|
|
366
|
+
...summary === void 0 ? {} : { summary: summary.slice(0, 600) },
|
|
367
|
+
...(url ?? before?.url) === void 0 ? {} : { url: url ?? before?.url },
|
|
368
|
+
...cover === void 0 ? {} : { cover },
|
|
369
|
+
...lasting === true ? { lasting: true } : {}
|
|
370
|
+
};
|
|
371
|
+
if (at < 0)
|
|
372
|
+
list.push(next);
|
|
373
|
+
else
|
|
374
|
+
list[at] = next;
|
|
375
|
+
out.push(next);
|
|
376
|
+
}
|
|
377
|
+
const lastingOnes = list.filter((x) => x.lasting === true);
|
|
378
|
+
const rest = list.filter((x) => x.lasting !== true).sort((a, b) => (b.publishedAt ?? b.at) - (a.publishedAt ?? a.at)).slice(0, MAX_NOTICES);
|
|
379
|
+
this.#saved.notices[game] = [...lastingOnes, ...rest];
|
|
380
|
+
await this.save();
|
|
381
|
+
return out;
|
|
382
|
+
}
|
|
296
383
|
/** Follow or stop following an SRA game; stopping forgets its events. */
|
|
297
384
|
async follow(sra, follow, gameId) {
|
|
298
385
|
const list = this.#saved.settings.followed.filter((id) => id !== sra);
|
|
@@ -987,6 +1074,55 @@ function isLong(a) {
|
|
|
987
1074
|
}
|
|
988
1075
|
|
|
989
1076
|
// packages/game-intel/lib/sources.js
|
|
1077
|
+
var STEAM_CLAN_IMAGE = "https://clan.akamai.steamstatic.com/images";
|
|
1078
|
+
var UPDATE_WORDS = /patch|update|hotfix|bug ?fix|fixes|release notes|changelog|版本|更新|补丁|修复|热修/i;
|
|
1079
|
+
var VERSION_IN_TITLE = /\bv?\d+\.\d+(?:\.\d+){0,2}[a-z]?\b/i;
|
|
1080
|
+
function plainSteamText(text) {
|
|
1081
|
+
return text.replace(/\[img[^\]]*\][\s\S]*?\[\/img\]/gi, " ").replace(/\{STEAM_CLAN_IMAGE\}\S*/g, " ").replace(/\[\/?[a-z0-9*]+(?:[= ][^\]]*)?\]/gi, " ").replace(/<[^>]+>/g, " ").replace(/ /g, " ").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/\s+/g, " ").trim();
|
|
1082
|
+
}
|
|
1083
|
+
function steamImage(text) {
|
|
1084
|
+
const raw = /\[img(?:\s+src="([^"]+)")?[^\]]*\]([^[]*)\[\/img\]/i.exec(text) ?? /<img[^>]+src="([^"]+)"/i.exec(text);
|
|
1085
|
+
const found = (raw?.[1] ?? raw?.[2])?.trim();
|
|
1086
|
+
if (found === void 0 || found === "")
|
|
1087
|
+
return void 0;
|
|
1088
|
+
const url = found.replace("{STEAM_CLAN_IMAGE}", STEAM_CLAN_IMAGE);
|
|
1089
|
+
return url.startsWith("https://") ? url : void 0;
|
|
1090
|
+
}
|
|
1091
|
+
function parseSteam(body) {
|
|
1092
|
+
const items = body?.appnews?.newsitems;
|
|
1093
|
+
if (!Array.isArray(items))
|
|
1094
|
+
throw new Error("Steam \u65B0\u95FB\u7684\u683C\u5F0F\u4E0D\u5BF9\uFF08\u6CA1\u6709 appnews.newsitems\uFF09");
|
|
1095
|
+
const out = [];
|
|
1096
|
+
for (const raw of items) {
|
|
1097
|
+
const item = raw;
|
|
1098
|
+
const title = typeof item["title"] === "string" ? item["title"].trim() : "";
|
|
1099
|
+
if (title === "")
|
|
1100
|
+
continue;
|
|
1101
|
+
const contents = typeof item["contents"] === "string" ? item["contents"] : "";
|
|
1102
|
+
const tags = Array.isArray(item["tags"]) ? item["tags"].filter((t) => typeof t === "string") : [];
|
|
1103
|
+
const summary = plainSteamText(contents);
|
|
1104
|
+
const cover = steamImage(contents);
|
|
1105
|
+
const version = VERSION_IN_TITLE.exec(title)?.[0];
|
|
1106
|
+
out.push({
|
|
1107
|
+
title,
|
|
1108
|
+
kind: tags.includes("patchnotes") || UPDATE_WORDS.test(title) ? "update" : "notice",
|
|
1109
|
+
...typeof item["date"] === "number" ? { publishedAt: item["date"] * 1e3 } : {},
|
|
1110
|
+
...typeof item["url"] === "string" && item["url"].startsWith("https://") ? { url: item["url"] } : {},
|
|
1111
|
+
...summary === "" ? {} : { summary: summary.length > 240 ? `${summary.slice(0, 240)}\u2026` : summary },
|
|
1112
|
+
...cover === void 0 ? {} : { cover },
|
|
1113
|
+
...version === void 0 ? {} : { version }
|
|
1114
|
+
});
|
|
1115
|
+
}
|
|
1116
|
+
return out;
|
|
1117
|
+
}
|
|
1118
|
+
async function readSteam(steam, fetchImpl, signal) {
|
|
1119
|
+
const url = `https://api.steampowered.com/ISteamNews/GetNewsForApp/v2/?appid=${steam.appid}&count=20&feeds=steam_community_announcements&format=json`;
|
|
1120
|
+
const timeout = AbortSignal.timeout(TIMEOUT_MS);
|
|
1121
|
+
const response = await fetchImpl(url, { signal: signal === void 0 ? timeout : AbortSignal.any([signal, timeout]), headers: { "user-agent": USER_AGENT, accept: "application/json" } });
|
|
1122
|
+
if (!response.ok)
|
|
1123
|
+
throw new Error(response.status === 403 || response.status === 404 ? `Steam \u4E0A\u6CA1\u6709 app ${steam.appid} \u7684\u65B0\u95FB\uFF08HTTP ${response.status}\uFF09` : `HTTP ${response.status}`);
|
|
1124
|
+
return parseSteam(await response.json());
|
|
1125
|
+
}
|
|
990
1126
|
var USER_AGENT = "MultiGameAssistant/0.6 (game event calendar; +https://github.com/haaahhhis/MultiGameAssistant)";
|
|
991
1127
|
var TIMEOUT_MS = 25e3;
|
|
992
1128
|
var MAX_PAGES = 4;
|
|
@@ -1269,6 +1405,7 @@ function tool(spec) {
|
|
|
1269
1405
|
};
|
|
1270
1406
|
}
|
|
1271
1407
|
var GAME = { type: "string", description: "\u6E38\u620F id\uFF08game_list \u53EF\u67E5\uFF09\uFF0C\u4F8B\u5982 arknights\u3001starrail\u3001endfield\u3002" };
|
|
1408
|
+
var NOTICE_KIND = { update: "\u7248\u672C\u66F4\u65B0", notice: "\u516C\u544A", news: "\u8D44\u8BAF" };
|
|
1272
1409
|
function gameTools(deps) {
|
|
1273
1410
|
const known = (id) => {
|
|
1274
1411
|
const game = deps.games().find((g) => g.id === id || g.name === id || g.aliases.includes(id));
|
|
@@ -1301,7 +1438,7 @@ function gameTools(deps) {
|
|
|
1301
1438
|
return [
|
|
1302
1439
|
tool({
|
|
1303
1440
|
name: "game_add",
|
|
1304
|
-
description: "\u7ED9\u4E00\u4E2A\u8FD8\u6CA1\u6709\u6E38\u620F\u5305\u7684\u6E38\u620F\u5EFA\u4E00\u4E2A\uFF08\u7528\u6237\u81EA\u5DF1\u7684\u6E38\u620F\u5305\uFF09\uFF0C\u4E4B\u540E\u6E38\u620F\u9875\u5C31\u80FD\u663E\u793A\u5B83\u7684\u6D3B\u52A8\u3002\u6765\u6E90\
|
|
1441
|
+
description: "\u7ED9\u4E00\u4E2A\u8FD8\u6CA1\u6709\u6E38\u620F\u5305\u7684\u6E38\u620F\u5EFA\u4E00\u4E2A\uFF08\u7528\u6237\u81EA\u5DF1\u7684\u6E38\u620F\u5305\uFF0C\u540C\u4E00\u4E2A id \u518D\u5199\u5C31\u662F\u6539\u5B83\uFF09\uFF0C\u4E4B\u540E\u6E38\u620F\u9875\u5C31\u80FD\u663E\u793A\u5B83\u7684\u6D3B\u52A8\u548C\u516C\u544A\u3002\u6765\u6E90\u56DB\u79CD\uFF1Asra\uFF08SRA \u516C\u5171 API \u7684\u6E38\u620F id\uFF09\u3001smw\uFF08Semantic MediaWiki \u7684 api.php \u67E5\u8BE2\uFF0C\u80FD\u8BFB\u5230\u6D3B\u52A8\u8D77\u6B62\u65F6\u95F4\uFF09\u3001steam_appid\uFF08Steam \u4E0A\u7684\u5B98\u65B9\u516C\u544A\uFF1A\u7248\u672C\u66F4\u65B0\u3001\u8865\u4E01\u8BF4\u660E\uFF0C\u5355\u673A\u6E38\u620F\u7528\uFF09\u3001\u53EA\u6709 homepage\uFF08\u5B98\u7F51\u516C\u544A\u7B49\uFF0C\u7531 agent \u8BFB\uFF09\u3002\u5355\u673A\u6E38\u620F\uFF08\u6CA1\u6709\u9650\u65F6\u6D3B\u52A8\uFF09\u5199 single=true\uFF0C\u6E38\u620F\u9875\u5148\u5217\u516C\u544A\u3002\u80FD\u81EA\u52A8\u8BFB\u7684\u4F1A\u9A6C\u4E0A\u8BFB\u4E00\u6B21\u3002\u7528\u6237\u8BF4\u300C\u52A0\u4E00\u4E2A XX \u6E38\u620F\u300D\u6216\u6E38\u620F\u9875\u8BA9\u4F60\u627E\u6765\u6E90\u65F6\u7528\u3002",
|
|
1305
1442
|
properties: {
|
|
1306
1443
|
id: { type: "string", description: "\u5C0F\u5199\u82F1\u6587\u3001\u6570\u5B57\u548C\u77ED\u6A2A\u7EBF\uFF0C\u4F8B\u5982 wuthering-waves\u3002" },
|
|
1307
1444
|
name: { type: "string", description: "\u4E2D\u6587\u6B63\u5F0F\u540D\u3002" },
|
|
@@ -1318,12 +1455,14 @@ function gameTools(deps) {
|
|
|
1318
1455
|
name: { type: "string", description: "\u7ED9\u4EBA\u770B\u7684\u540D\u5B57\uFF0C\u4F8B\u5982\u300C\u5B98\u7F51\u65B0\u95FB\u300D\u3002" },
|
|
1319
1456
|
homepage: { type: "string", description: "\u4EBA\u80FD\u6253\u5F00\u7684\u9875\u9762\u5730\u5740\u3002" },
|
|
1320
1457
|
sra_game: { type: "string", description: "SRA \u516C\u5171 API \u7684\u6E38\u620F id\uFF08\u53EF\u9009\uFF09\u3002" },
|
|
1321
|
-
smw: { type: "object", description: "Semantic MediaWiki \u67E5\u8BE2\uFF08\u53EF\u9009\uFF09\uFF1A{ api, conditions, title?, start, end, shopEnd?, dates: date|text, page? }\u3002" }
|
|
1458
|
+
smw: { type: "object", description: "Semantic MediaWiki \u67E5\u8BE2\uFF08\u53EF\u9009\uFF09\uFF1A{ api, conditions, title?, start, end, shopEnd?, dates: date|text, page? }\u3002" },
|
|
1459
|
+
steam_appid: { type: "number", description: "Steam \u7684 app id\uFF08\u53EF\u9009\uFF0C\u5546\u5E97\u9875 store.steampowered.com/app/<\u6570\u5B57> \u91CC\u7684\u6570\u5B57\uFF09\uFF1A\u63D2\u4EF6\u6BCF\u5929\u8BFB\u5B83\u5728 Steam \u7684\u5B98\u65B9\u516C\u544A\uFF08\u7248\u672C\u66F4\u65B0\u3001\u8865\u4E01\u8BF4\u660E\uFF09\u3002sra_game\u3001smw\u3001steam_appid \u4E00\u4E2A\u6765\u6E90\u53EA\u5199\u4E00\u4E2A\u3002" }
|
|
1322
1460
|
},
|
|
1323
1461
|
required: ["id", "name"],
|
|
1324
1462
|
additionalProperties: false
|
|
1325
1463
|
}
|
|
1326
1464
|
},
|
|
1465
|
+
single: { type: "boolean", description: "\u5355\u673A\u6E38\u620F\uFF08\u4E70\u65AD\u5236\u3001\u6CA1\u6709\u9650\u65F6\u6D3B\u52A8\uFF09\uFF1A\u6E38\u620F\u9875\u5148\u5217\u516C\u544A\u548C\u7248\u672C\u66F4\u65B0\u3002" },
|
|
1327
1466
|
guide: { type: "string", description: "GAME.md \u6B63\u6587\uFF08\u53EF\u9009\uFF09\uFF1A\u54EA\u4E9B\u6765\u6E90\u770B\u4EC0\u4E48\u3001\u516C\u544A\u9875\u600E\u4E48\u627E\u6D3B\u52A8\u3002" }
|
|
1328
1467
|
},
|
|
1329
1468
|
required: ["id", "name", "sources"],
|
|
@@ -1336,7 +1475,8 @@ function gameTools(deps) {
|
|
|
1336
1475
|
aliases: external_exports.array(external_exports.string()).nullish(),
|
|
1337
1476
|
timezone: external_exports.string().nullish(),
|
|
1338
1477
|
daily_reset: external_exports.string().nullish(),
|
|
1339
|
-
sources: external_exports.array(external_exports.object({ id: external_exports.string(), name: external_exports.string(), homepage: external_exports.string().nullish(), sra_game: external_exports.string().nullish(), smw: external_exports.record(external_exports.string(), external_exports.unknown()).nullish() })).min(1),
|
|
1478
|
+
sources: external_exports.array(external_exports.object({ id: external_exports.string(), name: external_exports.string(), homepage: external_exports.string().nullish(), sra_game: external_exports.string().nullish(), smw: external_exports.record(external_exports.string(), external_exports.unknown()).nullish(), steam_appid: external_exports.number().int().positive().nullish() })).min(1),
|
|
1479
|
+
single: external_exports.boolean().nullish(),
|
|
1340
1480
|
guide: external_exports.string().nullish()
|
|
1341
1481
|
}), args);
|
|
1342
1482
|
const manifest = {
|
|
@@ -1345,12 +1485,14 @@ function gameTools(deps) {
|
|
|
1345
1485
|
...a.aliases == null ? {} : { aliases: a.aliases },
|
|
1346
1486
|
...a.timezone == null ? {} : { timezone: a.timezone },
|
|
1347
1487
|
...a.daily_reset == null ? {} : { dailyReset: a.daily_reset },
|
|
1488
|
+
...a.single === true ? { single: true } : {},
|
|
1348
1489
|
sources: a.sources.map((s) => ({
|
|
1349
1490
|
id: s.id,
|
|
1350
1491
|
name: s.name,
|
|
1351
1492
|
...s.homepage == null ? {} : { homepage: s.homepage },
|
|
1352
1493
|
...s.sra_game == null ? {} : { sra: { game: s.sra_game } },
|
|
1353
|
-
...s.smw == null ? {} : { smw: s.smw }
|
|
1494
|
+
...s.smw == null ? {} : { smw: s.smw },
|
|
1495
|
+
...s.steam_appid == null ? {} : { steam: { appid: s.steam_appid } }
|
|
1354
1496
|
}))
|
|
1355
1497
|
};
|
|
1356
1498
|
const game = await deps.add(manifest, a.guide ?? void 0);
|
|
@@ -1380,7 +1522,7 @@ function gameTools(deps) {
|
|
|
1380
1522
|
}),
|
|
1381
1523
|
tool({
|
|
1382
1524
|
name: "game_activities",
|
|
1383
|
-
description: "\u6D3B\u52A8\u65E5\u5386\uFF1A\u5404\u6E38\u620F\u8FDB\u884C\u4E2D\u548C\u5373\u5C06\u5F00\u59CB\u7684\u6D3B\u52A8\u3001\u7ED3\u675F\u65F6\u95F4\u548C\u5269\u4F59\u5929\u6570\u3001\u5728\u6E38\u620F\u91CC\u8BFB\u5230\u7684\u672A\u5B8C\u6210\u9879\u3002\u7528\u6237\u95EE\u300C\u65B9\u821F\u6709\u4EC0\u4E48\u6D3B\u52A8\u300D\u300C\u8FD8\u5269\u51E0\u5929\u300D\u65F6\u5148\u770B\u8FD9\u4E2A\uFF1B\u592A\u4E45\u6CA1\u5237\u65B0\uFF08refreshed \u5F88\u65E7\uFF09\u5C31\u5148 game_sites_refresh\u3002",
|
|
1525
|
+
description: "\u6D3B\u52A8\u65E5\u5386\u548C\u516C\u544A\uFF1A\u5404\u6E38\u620F\u8FDB\u884C\u4E2D\u548C\u5373\u5C06\u5F00\u59CB\u7684\u6D3B\u52A8\u3001\u7ED3\u675F\u65F6\u95F4\u548C\u5269\u4F59\u5929\u6570\u3001\u5728\u6E38\u620F\u91CC\u8BFB\u5230\u7684\u672A\u5B8C\u6210\u9879\uFF0C\u4EE5\u53CA\u6700\u8FD1\u7684\u516C\u544A\uFF08\u7248\u672C\u66F4\u65B0\u3001\u957F\u671F\u516C\u544A\uFF1B\u5355\u673A\u6E38\u620F\u4E3B\u8981\u770B\u8FD9\u4E2A\uFF09\u3002\u7528\u6237\u95EE\u300C\u65B9\u821F\u6709\u4EC0\u4E48\u6D3B\u52A8\u300D\u300C\u8FD8\u5269\u51E0\u5929\u300D\u300CXX \u6700\u8FD1\u66F4\u65B0\u4E86\u4EC0\u4E48\u300D\u65F6\u5148\u770B\u8FD9\u4E2A\uFF1B\u592A\u4E45\u6CA1\u5237\u65B0\uFF08refreshed \u5F88\u65E7\uFF09\u5C31\u5148 game_sites_refresh\u3002",
|
|
1384
1526
|
properties: { game: { ...GAME, description: "\u53EA\u770B\u8FD9\u4E2A\u6E38\u620F\uFF08\u4E0D\u586B\u770B\u5168\u90E8\uFF09\u3002" } },
|
|
1385
1527
|
readOnly: true,
|
|
1386
1528
|
kind: "read",
|
|
@@ -1389,7 +1531,26 @@ function gameTools(deps) {
|
|
|
1389
1531
|
const a = parse(external_exports.object({ game: external_exports.string().nullish() }), args);
|
|
1390
1532
|
const games = a.game == null ? deps.games() : [known(a.game)];
|
|
1391
1533
|
return {
|
|
1392
|
-
games: games.map((g) =>
|
|
1534
|
+
games: games.map((g) => {
|
|
1535
|
+
const notices = deps.notices(g.id).slice(0, 10);
|
|
1536
|
+
return {
|
|
1537
|
+
game: g.id,
|
|
1538
|
+
name: g.name,
|
|
1539
|
+
...g.single === true ? { single_player: true } : {},
|
|
1540
|
+
activities: deps.activities(g.id).map((x) => brief(x, g.timezone)),
|
|
1541
|
+
...notices.length === 0 ? {} : { notices: notices.map((n) => ({
|
|
1542
|
+
id: n.id,
|
|
1543
|
+
title: n.title,
|
|
1544
|
+
kind: NOTICE_KIND[n.kind],
|
|
1545
|
+
...n.publishedAt === void 0 ? {} : { date: shortDate(n.publishedAt, g.timezone) },
|
|
1546
|
+
...n.version === void 0 ? {} : { version: n.version },
|
|
1547
|
+
...n.summary === void 0 ? {} : { summary: n.summary },
|
|
1548
|
+
...n.url === void 0 ? {} : { url: n.url },
|
|
1549
|
+
...n.lasting === true ? { lasting: true } : {},
|
|
1550
|
+
from: n.source.name
|
|
1551
|
+
})) }
|
|
1552
|
+
};
|
|
1553
|
+
})
|
|
1393
1554
|
};
|
|
1394
1555
|
}
|
|
1395
1556
|
}),
|
|
@@ -1474,6 +1635,75 @@ function gameTools(deps) {
|
|
|
1474
1635
|
};
|
|
1475
1636
|
}
|
|
1476
1637
|
}),
|
|
1638
|
+
tool({
|
|
1639
|
+
name: "game_notice",
|
|
1640
|
+
description: [
|
|
1641
|
+
"\u628A\u8BFB\u5230\u7684\u516C\u544A\u8BB0\u5230\u6E38\u620F\u9875\u7684\u300C\u516C\u544A\u300D\u91CC\uFF0C\u5B83\u4EEC\u4E0D\u662F\u6709\u8D77\u6B62\u65F6\u95F4\u7684\u9650\u65F6\u6D3B\u52A8\uFF08\u9650\u65F6\u6D3B\u52A8\u7528 game_record\uFF09\uFF1A",
|
|
1642
|
+
"kind=update \u7248\u672C\u66F4\u65B0\u3001\u8865\u4E01\u8BF4\u660E\uFF08\u5199\u4E0A\u7248\u672C\u53F7\uFF09\uFF1Bkind=notice \u516C\u544A\uFF0C\u957F\u671F\u6709\u6548\u7684\uFF08\u5E38\u9A7B\u89C4\u5219\u3001\u957F\u671F\u6D3B\u52A8\u8BF4\u660E\u3001\u505C\u670D / \u7EF4\u62A4\u5B89\u6392\uFF09\u5199 lasting=true\uFF0C\u4F1A\u4E00\u76F4\u7559\u5728\u6700\u524D\u9762\uFF1Bkind=news \u5176\u4ED6\u8D44\u8BAF\u3002",
|
|
1643
|
+
"\u5355\u673A\u6E38\u620F\u4E3B\u8981\u8BB0\u8FD9\u4E2A\u3002\u540C\u4E00\u4E2A\u7F51\u5740\uFF08\u6CA1\u6709\u7F51\u5740\u65F6\u540C\u4E00\u4E2A\u6807\u9898\uFF09\u518D\u8BB0\u5C31\u662F\u66F4\u65B0\u539F\u6765\u90A3\u6761\uFF1Blasting=false \u53EF\u4EE5\u628A\u957F\u671F\u516C\u544A\u6536\u56DE\u3002\u53EA\u8BB0\u6709\u51FA\u5904\u7684\u5185\u5BB9\uFF0Csummary \u7528\u4E00\u4E24\u53E5\u4E2D\u6587\u5199\u6E05\u695A\u6539\u4E86\u4EC0\u4E48\u3002"
|
|
1644
|
+
].join(""),
|
|
1645
|
+
properties: {
|
|
1646
|
+
game: GAME,
|
|
1647
|
+
notices: {
|
|
1648
|
+
type: "array",
|
|
1649
|
+
description: "\u6BCF\u7BC7\u516C\u544A\u4E00\u6761\u3002",
|
|
1650
|
+
items: {
|
|
1651
|
+
type: "object",
|
|
1652
|
+
properties: {
|
|
1653
|
+
title: { type: "string", description: "\u516C\u544A\u6807\u9898\uFF08\u539F\u6587\uFF09\u3002" },
|
|
1654
|
+
kind: { type: "string", enum: ["update", "notice", "news"], description: "update\uFF1A\u7248\u672C\u66F4\u65B0 / \u8865\u4E01\uFF1Bnotice\uFF1A\u516C\u544A\uFF1Bnews\uFF1A\u5176\u4ED6\u8D44\u8BAF\u3002" },
|
|
1655
|
+
published_at: { type: "string", description: "\u53D1\u5E03\u65E5\u671F\uFF0C\u5199\u6210 2026/11/19 \u6216 2026/11/19 10:00\uFF08\u6E38\u620F\u670D\u52A1\u5668\u65F6\u95F4\uFF09\u3002" },
|
|
1656
|
+
version: { type: "string", description: "kind=update\uFF1A\u7248\u672C\u53F7\uFF0C\u4F8B\u5982 v1.0.3\u3002" },
|
|
1657
|
+
summary: { type: "string", description: "\u4E00\u4E24\u53E5\u8BDD\uFF1A\u6539\u4E86\u4EC0\u4E48\u3001\u8981\u6CE8\u610F\u4EC0\u4E48\u3002" },
|
|
1658
|
+
url: { type: "string", description: "\u516C\u544A\u7684\u7F51\u5740\u3002" },
|
|
1659
|
+
cover: { type: "string", description: "\u516C\u544A\u914D\u56FE\u7684\u5730\u5740\uFF08https\uFF0C\u53EF\u9009\uFF09\u3002" },
|
|
1660
|
+
lasting: { type: "boolean", description: "\u957F\u671F\u6709\u6548\u7684\u516C\u544A\uFF0C\u4E00\u76F4\u7559\u5728\u6700\u524D\u9762\uFF1Bfalse \u6536\u56DE\u3002" }
|
|
1661
|
+
},
|
|
1662
|
+
required: ["title", "kind"],
|
|
1663
|
+
additionalProperties: false
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
},
|
|
1667
|
+
required: ["game", "notices"],
|
|
1668
|
+
kind: "other",
|
|
1669
|
+
title: (a) => `\u8BB0\u5F55\u516C\u544A\uFF1A${String(a["game"] ?? "")}`,
|
|
1670
|
+
execute: async (args) => {
|
|
1671
|
+
const a = parse(external_exports.object({
|
|
1672
|
+
game: external_exports.string(),
|
|
1673
|
+
notices: external_exports.array(external_exports.object({
|
|
1674
|
+
title: external_exports.string().trim().min(1).max(200),
|
|
1675
|
+
kind: external_exports.enum(["update", "notice", "news"]),
|
|
1676
|
+
published_at: external_exports.string().nullish(),
|
|
1677
|
+
version: external_exports.string().max(40).nullish(),
|
|
1678
|
+
summary: external_exports.string().max(600).nullish(),
|
|
1679
|
+
url: external_exports.string().nullish(),
|
|
1680
|
+
cover: external_exports.string().nullish(),
|
|
1681
|
+
lasting: external_exports.boolean().nullish()
|
|
1682
|
+
})).min(1).max(30)
|
|
1683
|
+
}), args);
|
|
1684
|
+
const game = known(a.game);
|
|
1685
|
+
const notices = a.notices.map((n) => {
|
|
1686
|
+
const at = n.published_at == null ? void 0 : parseDateText(n.published_at, game.timezone, deps.now());
|
|
1687
|
+
const url = n.url != null && /^https?:\/\//.test(n.url) ? n.url : void 0;
|
|
1688
|
+
const cover = n.cover != null && n.cover.startsWith("https://") ? n.cover : void 0;
|
|
1689
|
+
return {
|
|
1690
|
+
title: n.title,
|
|
1691
|
+
kind: n.kind,
|
|
1692
|
+
...at == null ? {} : { publishedAt: at },
|
|
1693
|
+
...n.version == null ? {} : { version: n.version },
|
|
1694
|
+
...n.summary == null ? {} : { summary: n.summary },
|
|
1695
|
+
...url === void 0 ? {} : { url },
|
|
1696
|
+
...cover === void 0 ? {} : { cover },
|
|
1697
|
+
...n.lasting == null ? {} : { lasting: n.lasting }
|
|
1698
|
+
};
|
|
1699
|
+
});
|
|
1700
|
+
const kept = await deps.recordNotices(game.id, notices);
|
|
1701
|
+
return {
|
|
1702
|
+
recorded: kept.map((n) => ({ id: n.id, title: n.title, kind: NOTICE_KIND[n.kind], ...n.publishedAt === void 0 ? {} : { date: shortDate(n.publishedAt, game.timezone) }, ...n.lasting === true ? { lasting: true } : {} })),
|
|
1703
|
+
next: "\u8BB0\u4E0B\u4E86\uFF0C\u6E38\u620F\u9875\u7684\u300C\u516C\u544A\u300D\u91CC\u80FD\u770B\u5230\u3002"
|
|
1704
|
+
};
|
|
1705
|
+
}
|
|
1706
|
+
}),
|
|
1477
1707
|
tool({
|
|
1478
1708
|
name: "game_activity_save",
|
|
1479
1709
|
description: [
|
|
@@ -1617,7 +1847,11 @@ function gameTools(deps) {
|
|
|
1617
1847
|
var ConfigSchema = external_exports.object({
|
|
1618
1848
|
/** The calendar and screenshots: `<dataDir>/games/`; the user's Game Packs: `<dataDir>/games/<id>/game.yaml`. */
|
|
1619
1849
|
dataDir: external_exports.string().min(1),
|
|
1620
|
-
/**
|
|
1850
|
+
/**
|
|
1851
|
+
* The official Game Packs: the 技能库's downloads (`<dataDir>/skill-hub/skills/game-<id>/game.yaml`,
|
|
1852
|
+
* beside the guide the hub registers as a skill). The app ships none; deleting one there removes the game.
|
|
1853
|
+
* @default <dataDir>/skill-hub/skills
|
|
1854
|
+
*/
|
|
1621
1855
|
gamesDir: external_exports.string().optional()
|
|
1622
1856
|
});
|
|
1623
1857
|
var GAME_ROLE = {
|
|
@@ -1650,6 +1884,8 @@ var AdgGameIntel = class extends Service {
|
|
|
1650
1884
|
fetch = (url, init) => fetch(url, init);
|
|
1651
1885
|
clock = realClock;
|
|
1652
1886
|
games = [];
|
|
1887
|
+
/** Every game pack there is, the ones taken off the game page too (`games` is what the page shows). */
|
|
1888
|
+
allGames = [];
|
|
1653
1889
|
daily;
|
|
1654
1890
|
dir;
|
|
1655
1891
|
/** Game programs' icons (exe-icon.ts). */
|
|
@@ -1664,7 +1900,7 @@ var AdgGameIntel = class extends Service {
|
|
|
1664
1900
|
const log = ctx.logger("adg-game-intel");
|
|
1665
1901
|
this.log = log;
|
|
1666
1902
|
this.dir = join2(spec.dataDir, "games");
|
|
1667
|
-
this.builtinDir = spec.gamesDir ??
|
|
1903
|
+
this.builtinDir = spec.gamesDir ?? join2(spec.dataDir, "skill-hub", "skills");
|
|
1668
1904
|
this.calendar = new Calendar(this.dir);
|
|
1669
1905
|
this.icons = new ExeIcons(join2(this.dir, "icons"));
|
|
1670
1906
|
const calendar = this.calendar;
|
|
@@ -1708,7 +1944,7 @@ var AdgGameIntel = class extends Service {
|
|
|
1708
1944
|
}
|
|
1709
1945
|
try {
|
|
1710
1946
|
const owner = { games: [game.manifest.id, game.manifest.name] };
|
|
1711
|
-
disposers.push(scoped.adgGateway.skillScope.register({ ...skill, source: game.builtin ? "bundled" : "custom", path: join2(game.dir, GAME_GUIDE_FILE), resourceBase: { kind: "directory", path: game.dir }, owner }));
|
|
1947
|
+
disposers.push(scoped.adgGateway.skillScope.register({ ...skill, source: game.builtin ? "bundled" : "custom", path: join2(game.dir, GAME_GUIDE_FILE), resourceBase: { kind: "directory", path: game.dir }, owner, kind: "game-pack" }));
|
|
1712
1948
|
} catch (error) {
|
|
1713
1949
|
log.warn(`game ${game.manifest.id}: skill not registered: ${error instanceof Error ? error.message : String(error)}`);
|
|
1714
1950
|
}
|
|
@@ -1724,6 +1960,11 @@ var AdgGameIntel = class extends Service {
|
|
|
1724
1960
|
for (const tool2 of gameTools({
|
|
1725
1961
|
games: () => this.infos(),
|
|
1726
1962
|
activities: (game) => calendar.list(game),
|
|
1963
|
+
notices: (game) => calendar.notices(game),
|
|
1964
|
+
recordNotices: async (game, notices) => {
|
|
1965
|
+
await this.ready;
|
|
1966
|
+
return this.recordNotices(game, notices);
|
|
1967
|
+
},
|
|
1727
1968
|
refresh: async (game) => {
|
|
1728
1969
|
await this.ready;
|
|
1729
1970
|
return this.refresh(game);
|
|
@@ -1786,7 +2027,8 @@ var AdgGameIntel = class extends Service {
|
|
|
1786
2027
|
"games/list": async () => {
|
|
1787
2028
|
await this.ready;
|
|
1788
2029
|
await this.loadGames(log);
|
|
1789
|
-
|
|
2030
|
+
const shown = new Set(this.games.map((g) => g.manifest.id));
|
|
2031
|
+
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() } } };
|
|
1790
2032
|
},
|
|
1791
2033
|
"games/refresh": async (params) => {
|
|
1792
2034
|
await this.ready;
|
|
@@ -1852,15 +2094,25 @@ var AdgGameIntel = class extends Service {
|
|
|
1852
2094
|
},
|
|
1853
2095
|
"games/discover": async (params) => {
|
|
1854
2096
|
await this.ready;
|
|
1855
|
-
return { sessionId: await this.discover(params.
|
|
2097
|
+
return { sessionId: await this.discover(params.game) };
|
|
2098
|
+
},
|
|
2099
|
+
"games/create": async (params) => {
|
|
2100
|
+
await this.ready;
|
|
2101
|
+
return { game: await this.createGame(params.name) };
|
|
2102
|
+
},
|
|
2103
|
+
"games/remove": async (params) => {
|
|
2104
|
+
await this.ready;
|
|
2105
|
+
await this.removeGame(params.game);
|
|
2106
|
+
return {};
|
|
1856
2107
|
},
|
|
1857
2108
|
"games/catalog": async () => {
|
|
1858
2109
|
await this.ready;
|
|
1859
|
-
|
|
2110
|
+
await this.loadGames(log);
|
|
1860
2111
|
return {
|
|
1861
2112
|
games: SRA_GAMES.map((g) => {
|
|
1862
|
-
const
|
|
1863
|
-
|
|
2113
|
+
const shown = this.games.find((l) => l.manifest.sources.some((s) => s.sra?.game === g.sra));
|
|
2114
|
+
const pack = shown === void 0 || shown.followed === true ? void 0 : shown.manifest.id;
|
|
2115
|
+
return { sra: g.sra, name: g.name, followed: shown !== void 0, ...pack === void 0 ? {} : { pack } };
|
|
1864
2116
|
})
|
|
1865
2117
|
};
|
|
1866
2118
|
},
|
|
@@ -1869,11 +2121,7 @@ var AdgGameIntel = class extends Service {
|
|
|
1869
2121
|
const { sra, follow } = params;
|
|
1870
2122
|
if (!SRA_GAMES.some((g) => g.sra === sra))
|
|
1871
2123
|
throw new Error(`SRA \u516C\u5171 API \u6CA1\u6709\u6E38\u620F ${sra}`);
|
|
1872
|
-
await
|
|
1873
|
-
await this.loadGames(log);
|
|
1874
|
-
changed();
|
|
1875
|
-
if (follow && this.games.some((g) => g.manifest.id === followedId(sra)))
|
|
1876
|
-
void this.refresh(followedId(sra)).catch(() => []);
|
|
2124
|
+
await this.showSra(sra, follow);
|
|
1877
2125
|
return {};
|
|
1878
2126
|
},
|
|
1879
2127
|
"games/activity/progress": async (params) => {
|
|
@@ -1928,7 +2176,7 @@ var AdgGameIntel = class extends Service {
|
|
|
1928
2176
|
}
|
|
1929
2177
|
if (!this.calendar.pictures().has(url) && !this.games.some((g) => g.manifest.art === url))
|
|
1930
2178
|
throw new Error("\u8FD9\u5F20\u56FE\u7247\u4E0D\u662F\u6570\u636E\u7AD9\u6216\u6E38\u620F\u5305\u7ED9\u7684\u5730\u5740");
|
|
1931
|
-
const name =
|
|
2179
|
+
const name = createHash2("sha256").update(url).digest("hex").slice(0, 32);
|
|
1932
2180
|
const dir = join2(this.dir, "images");
|
|
1933
2181
|
for (const [ext2, mediaType2] of IMAGE_TYPES) {
|
|
1934
2182
|
const cached = await readFile2(join2(dir, `${name}.${ext2}`)).catch(() => void 0);
|
|
@@ -1970,12 +2218,15 @@ var AdgGameIntel = class extends Service {
|
|
|
1970
2218
|
try {
|
|
1971
2219
|
const manifest = parseGameManifest(text, `${id}/${GAME_MANIFEST_FILE}`);
|
|
1972
2220
|
const guide = await readFile2(join2(dir, GAME_GUIDE_FILE), "utf8").catch(() => void 0);
|
|
1973
|
-
found.set(manifest.id, { manifest, dir, builtin, ...guide === void 0 ? {} : { guide } });
|
|
2221
|
+
found.set(manifest.id, { manifest, dir, builtin, ...builtin ? {} : { own: true }, ...guide === void 0 ? {} : { guide } });
|
|
1974
2222
|
} catch (error) {
|
|
1975
2223
|
log.warn(`game pack ${id}: ${error instanceof Error ? error.message : String(error)}`);
|
|
1976
2224
|
}
|
|
1977
2225
|
}
|
|
1978
2226
|
}
|
|
2227
|
+
this.allGames = [...found.values()];
|
|
2228
|
+
for (const id of this.calendar.settings.hidden ?? [])
|
|
2229
|
+
found.delete(id);
|
|
1979
2230
|
const covered = new Set([...found.values()].flatMap((g) => g.manifest.sources.map((s) => s.sra?.game).filter((s) => s !== void 0)));
|
|
1980
2231
|
for (const sra of this.calendar.settings.followed) {
|
|
1981
2232
|
const game = SRA_GAMES.find((g) => g.sra === sra);
|
|
@@ -2095,7 +2346,7 @@ var AdgGameIntel = class extends Service {
|
|
|
2095
2346
|
const ext = imageType(bytes);
|
|
2096
2347
|
if (ext === void 0)
|
|
2097
2348
|
throw new Error("\u4E0D\u662F\u652F\u6301\u7684\u56FE\u7247\uFF08png\u3001jpg\u3001gif\u3001webp\u3001avif\uFF09");
|
|
2098
|
-
const file = `${
|
|
2349
|
+
const file = `${createHash2("sha256").update(bytes).digest("hex").slice(0, 32)}.${ext}`;
|
|
2099
2350
|
const dir = this.imageDir(kind);
|
|
2100
2351
|
await mkdir2(dir, { recursive: true });
|
|
2101
2352
|
await writeFile(join2(dir, file), bytes);
|
|
@@ -2244,7 +2495,8 @@ var AdgGameIntel = class extends Service {
|
|
|
2244
2495
|
}
|
|
2245
2496
|
infos() {
|
|
2246
2497
|
const scripts = this.scriptsByGame();
|
|
2247
|
-
return this.games.map(({ manifest: m, builtin, followed }) => {
|
|
2498
|
+
return this.games.map(({ manifest: m, builtin, followed, own }) => {
|
|
2499
|
+
const sra = m.sources.map((s) => s.sra?.game).filter((id) => id !== void 0);
|
|
2248
2500
|
const refreshed = this.calendar.refreshed(m.id);
|
|
2249
2501
|
const reading = this.calendar.reading(m.id);
|
|
2250
2502
|
const webReading = this.calendar.reading(`${m.id}#web`);
|
|
@@ -2257,10 +2509,13 @@ var AdgGameIntel = class extends Service {
|
|
|
2257
2509
|
scripts: scripts.get(m.id) ?? m.scripts,
|
|
2258
2510
|
timezone: m.timezone,
|
|
2259
2511
|
...m.screen === void 0 ? {} : { screen: { target: m.screen.target, ...m.screen.window === void 0 ? {} : { window: m.screen.window } } },
|
|
2260
|
-
sources: m.sources.map((s) => ({ id: s.id, name: s.name, ...s.homepage === void 0 ? {} : { homepage: s.homepage }, auto: s.smw !== void 0 || s.sra !== void 0, .../^link-\d+$/.test(s.id) && this.calendar.links(m.id).some((l) => l.id === s.id) ? { added: true } : {} })),
|
|
2512
|
+
sources: m.sources.map((s) => ({ id: s.id, name: s.name, ...s.homepage === void 0 ? {} : { homepage: s.homepage }, auto: s.smw !== void 0 || s.sra !== void 0 || s.steam !== void 0, .../^link-\d+$/.test(s.id) && this.calendar.links(m.id).some((l) => l.id === s.id) ? { added: true } : {} })),
|
|
2261
2513
|
builtin,
|
|
2262
2514
|
...m.art === void 0 ? {} : { art: m.art },
|
|
2263
2515
|
...followed === true ? { followed: true } : {},
|
|
2516
|
+
...sra.length === 0 ? {} : { sra },
|
|
2517
|
+
...own === true ? { own: true } : {},
|
|
2518
|
+
...m.single === true ? { single: true } : {},
|
|
2264
2519
|
...refreshed === void 0 ? {} : { refreshed },
|
|
2265
2520
|
...reading === void 0 ? {} : { reading },
|
|
2266
2521
|
...webReading === void 0 ? {} : { webReading },
|
|
@@ -2275,18 +2530,24 @@ var AdgGameIntel = class extends Service {
|
|
|
2275
2530
|
const games = gameId === void 0 ? this.games : [this.game(gameId)];
|
|
2276
2531
|
const results = [];
|
|
2277
2532
|
for (const { manifest } of games) {
|
|
2278
|
-
const sources = manifest.sources.filter((s) => s.smw !== void 0 || s.sra !== void 0);
|
|
2533
|
+
const sources = manifest.sources.filter((s) => s.smw !== void 0 || s.sra !== void 0 || s.steam !== void 0);
|
|
2279
2534
|
if (sources.length === 0) {
|
|
2280
|
-
|
|
2535
|
+
const where = manifest.sources.map((s) => s.homepage).filter(Boolean).join(" \u6216 ") || "\u5B98\u7F51\u516C\u544A";
|
|
2536
|
+
results.push({ game: manifest.id, ok: false, count: 0, detail: manifest.single === true ? `\u6CA1\u6709\u80FD\u76F4\u63A5\u8BFB\u7684\u516C\u544A\u6765\u6E90\uFF1A\u7528 web_fetch \u770B ${where}\uFF0C\u7248\u672C\u66F4\u65B0\u548C\u516C\u544A\u7528 game_notice \u8BB0\u4E0B` : `\u6CA1\u6709\u80FD\u76F4\u63A5\u8BFB\u7684\u6570\u636E\u7AD9\uFF1A\u7528 web_fetch\uFF08\u53EA\u62FF\u5230\u7A7A\u58F3\u65F6\u7528\u5185\u7F6E\u6D4F\u89C8\u5668\uFF09\u770B ${where}\uFF0C\u518D\u7528 game_record\uFF08source=site\uFF09\u8BB0\u4E0B` });
|
|
2281
2537
|
continue;
|
|
2282
2538
|
}
|
|
2283
2539
|
const failures = [];
|
|
2284
2540
|
let count = 0;
|
|
2541
|
+
let notices = 0;
|
|
2285
2542
|
let version;
|
|
2286
2543
|
let pools;
|
|
2287
2544
|
for (const source of sources) {
|
|
2288
2545
|
const now = this.clock.now();
|
|
2289
2546
|
try {
|
|
2547
|
+
if (source.steam !== void 0) {
|
|
2548
|
+
notices += (await this.calendar.applyNotices(manifest.id, { id: source.id, name: source.name }, await readSteam(source.steam, this.fetch), now)).length;
|
|
2549
|
+
continue;
|
|
2550
|
+
}
|
|
2290
2551
|
let events;
|
|
2291
2552
|
if (source.sra !== void 0) {
|
|
2292
2553
|
const read = await readSra(source.sra, manifest, now, this.fetch);
|
|
@@ -2303,17 +2564,28 @@ var AdgGameIntel = class extends Service {
|
|
|
2303
2564
|
failures.push(`${source.name}\uFF1A${error instanceof Error ? error.message : String(error)}`);
|
|
2304
2565
|
}
|
|
2305
2566
|
}
|
|
2306
|
-
if (failures.length > 0 && count === 0)
|
|
2567
|
+
if (failures.length > 0 && count + notices === 0)
|
|
2307
2568
|
await this.calendar.refreshFailed(manifest.id, failures.join("\uFF1B"), this.clock.now());
|
|
2308
2569
|
else
|
|
2309
2570
|
await this.calendar.refreshDone(manifest.id, this.calendar.list(manifest.id).filter((a) => a.sources?.some((s) => !s.web) === true).length, this.clock.now(), version, pools);
|
|
2310
|
-
results.push({ game: manifest.id, ok: failures.length === 0 || count > 0, count, ...failures.length === 0 ? {} : { detail: failures.join("\uFF1B") } });
|
|
2571
|
+
results.push({ game: manifest.id, ok: failures.length === 0 || count + notices > 0, count, ...notices === 0 ? {} : { notices }, ...failures.length === 0 ? {} : { detail: failures.join("\uFF1B") } });
|
|
2311
2572
|
this.changed(manifest.id);
|
|
2312
2573
|
}
|
|
2313
2574
|
await this.sweepImages();
|
|
2314
2575
|
return results;
|
|
2315
2576
|
}
|
|
2316
2577
|
// ── what the agent read ──
|
|
2578
|
+
/** Announcements the agent read (game_notice), each credited to the site it came from. */
|
|
2579
|
+
async recordNotices(gameId, notices) {
|
|
2580
|
+
this.game(gameId);
|
|
2581
|
+
const kept = [];
|
|
2582
|
+
for (const notice of notices) {
|
|
2583
|
+
const host = notice.url !== void 0 && URL.canParse(notice.url) ? hostName(notice.url) : void 0;
|
|
2584
|
+
kept.push(...await this.calendar.applyNotices(gameId, { id: "agent", name: host === void 0 ? "agent \u67E5\u5230" : `${host}\uFF08agent \u67E5\u5230\uFF09` }, [notice], this.clock.now()));
|
|
2585
|
+
}
|
|
2586
|
+
this.changed(gameId);
|
|
2587
|
+
return kept;
|
|
2588
|
+
}
|
|
2317
2589
|
async record(gameId, from, events, sessionId, keep) {
|
|
2318
2590
|
const { manifest } = this.game(gameId);
|
|
2319
2591
|
const shot = from === "screen" && keep && sessionId !== void 0 ? this.ctx.get("adgIntervene")?.lastShot(sessionId) : void 0;
|
|
@@ -2382,7 +2654,7 @@ var AdgGameIntel = class extends Service {
|
|
|
2382
2654
|
const manifest = parsed.data;
|
|
2383
2655
|
const existing = this.games.find((g) => g.manifest.id === manifest.id);
|
|
2384
2656
|
if (existing !== void 0 && existing.builtin && existing.followed !== true)
|
|
2385
|
-
throw new Error(`\u5DF2\u7ECF\u6709\
|
|
2657
|
+
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`);
|
|
2386
2658
|
const dir = join2(this.dir, manifest.id);
|
|
2387
2659
|
await mkdir2(dir, { recursive: true });
|
|
2388
2660
|
await writeFile(join2(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
|
|
@@ -2397,31 +2669,148 @@ description: ${JSON.stringify(`${manifest.name}\u7684\u6D3B\u52A8\u548C\u8D44\u8
|
|
|
2397
2669
|
${guide.trim()}
|
|
2398
2670
|
`);
|
|
2399
2671
|
}
|
|
2672
|
+
if (this.calendar.settings.hidden?.includes(manifest.id) === true)
|
|
2673
|
+
await this.calendar.hide(manifest.id, false);
|
|
2400
2674
|
await this.loadGames(this.log);
|
|
2401
2675
|
this.changed(manifest.id);
|
|
2402
2676
|
if (manifest.sources.some((s) => s.smw !== void 0 || s.sra !== void 0))
|
|
2403
2677
|
void this.refresh(manifest.id).catch(() => []);
|
|
2404
2678
|
return this.infos().find((g) => g.id === manifest.id);
|
|
2405
2679
|
}
|
|
2406
|
-
|
|
2407
|
-
|
|
2680
|
+
// ── which games are on the page (apart from the 技能库's packs) ──
|
|
2681
|
+
/**
|
|
2682
|
+
* Show an SRA game, or stop: a game pack that reads it (from the 技能库 or
|
|
2683
|
+
* made here) is shown or taken off with it, the pack staying installed;
|
|
2684
|
+
* without one the API is followed. @returns the game's id on the page.
|
|
2685
|
+
*/
|
|
2686
|
+
async showSra(sra, show) {
|
|
2687
|
+
const packs = this.allGames.filter((g) => g.manifest.sources.some((s) => s.sra?.game === sra));
|
|
2688
|
+
for (const pack of packs)
|
|
2689
|
+
await this.calendar.hide(pack.manifest.id, !show);
|
|
2690
|
+
await this.calendar.follow(sra, show && packs.length === 0, followedId(sra));
|
|
2691
|
+
await this.loadGames(this.log);
|
|
2692
|
+
this.changed();
|
|
2693
|
+
const id = packs[0]?.manifest.id ?? followedId(sra);
|
|
2694
|
+
if (show && this.games.some((g) => g.manifest.id === id))
|
|
2695
|
+
void this.refresh(id).catch(() => []);
|
|
2696
|
+
return id;
|
|
2697
|
+
}
|
|
2698
|
+
/**
|
|
2699
|
+
* Put a game on the page by its name: one there already is it; one taken
|
|
2700
|
+
* off comes back; one the SRA public API knows is followed; any other is
|
|
2701
|
+
* made here, empty (no sources yet), for the agent to find its sources from
|
|
2702
|
+
* its page. No pack is downloaded: the page offers the 技能库's for it.
|
|
2703
|
+
* @returns its id.
|
|
2704
|
+
*/
|
|
2705
|
+
async createGame(name) {
|
|
2706
|
+
const wanted = name.trim();
|
|
2707
|
+
if (wanted === "")
|
|
2708
|
+
throw new Error("\u5199\u4E00\u4E2A\u6E38\u620F\u540D");
|
|
2709
|
+
const key = wanted.toLowerCase();
|
|
2710
|
+
await this.loadGames(this.log);
|
|
2711
|
+
const named = (g) => [g.manifest.id, g.manifest.name, ...g.manifest.aliases].some((n) => n.toLowerCase() === key);
|
|
2712
|
+
const shown = this.games.find(named);
|
|
2713
|
+
if (shown !== void 0)
|
|
2714
|
+
return shown.manifest.id;
|
|
2715
|
+
const away = this.allGames.find(named);
|
|
2716
|
+
if (away !== void 0) {
|
|
2717
|
+
await this.calendar.hide(away.manifest.id, false);
|
|
2718
|
+
await this.loadGames(this.log);
|
|
2719
|
+
this.changed(away.manifest.id);
|
|
2720
|
+
return away.manifest.id;
|
|
2721
|
+
}
|
|
2722
|
+
const sra = SRA_GAMES.find((g) => g.sra === key || g.name.toLowerCase() === key || g.words.some((w) => w.toLowerCase() === key));
|
|
2723
|
+
if (sra !== void 0)
|
|
2724
|
+
return this.showSra(sra.sra, true);
|
|
2725
|
+
const id = await this.freeId(wanted);
|
|
2726
|
+
const dir = join2(this.dir, id);
|
|
2727
|
+
await mkdir2(dir, { recursive: true });
|
|
2728
|
+
await writeFile(join2(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
|
|
2729
|
+
${JSON.stringify({ id, name: wanted, sources: [] }, null, 2)}
|
|
2730
|
+
`);
|
|
2731
|
+
await this.loadGames(this.log);
|
|
2732
|
+
this.changed(id);
|
|
2733
|
+
return id;
|
|
2734
|
+
}
|
|
2735
|
+
/** An id for a game made by name: its letters and digits, else a short fingerprint of the name; not one in use. */
|
|
2736
|
+
async freeId(name) {
|
|
2737
|
+
const slug = name.normalize("NFKD").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
2738
|
+
const base = slug.length >= 2 ? slug.slice(0, 40).replace(/-+$/, "") : `game-${createHash2("sha256").update(name).digest("hex").slice(0, 8)}`;
|
|
2739
|
+
const taken = /* @__PURE__ */ new Set([
|
|
2740
|
+
...this.allGames.map((g) => g.manifest.id),
|
|
2741
|
+
...SRA_GAMES.map((g) => followedId(g.sra)),
|
|
2742
|
+
// Folders the plugin keeps beside the packs.
|
|
2743
|
+
"images",
|
|
2744
|
+
"evidence",
|
|
2745
|
+
"icons",
|
|
2746
|
+
...await readdir(this.dir).catch(() => [])
|
|
2747
|
+
]);
|
|
2748
|
+
for (let n = 1; ; n++) {
|
|
2749
|
+
const id = n === 1 ? base : `${base}-${n}`;
|
|
2750
|
+
if (!taken.has(id))
|
|
2751
|
+
return id;
|
|
2752
|
+
}
|
|
2753
|
+
}
|
|
2754
|
+
/**
|
|
2755
|
+
* Take a game off the page: an SRA game is no longer followed, a game pack
|
|
2756
|
+
* from the 技能库 is hidden (it stays installed, with its skills), one made
|
|
2757
|
+
* here is deleted with its events.
|
|
2758
|
+
*/
|
|
2759
|
+
async removeGame(gameId) {
|
|
2760
|
+
await this.loadGames(this.log);
|
|
2761
|
+
const game = this.game(gameId);
|
|
2762
|
+
const sras = game.manifest.sources.map((s) => s.sra?.game).filter((s) => s !== void 0);
|
|
2763
|
+
if (game.followed === true) {
|
|
2764
|
+
for (const sra of sras)
|
|
2765
|
+
await this.calendar.follow(sra, false, gameId);
|
|
2766
|
+
} else if (game.own === true) {
|
|
2767
|
+
await rm(game.dir, { recursive: true, force: true });
|
|
2768
|
+
await this.calendar.forget(gameId);
|
|
2769
|
+
} else {
|
|
2770
|
+
await this.calendar.hide(gameId, true);
|
|
2771
|
+
}
|
|
2772
|
+
for (const sra of sras)
|
|
2773
|
+
if (this.calendar.settings.followed.includes(sra))
|
|
2774
|
+
await this.calendar.follow(sra, false, followedId(sra));
|
|
2775
|
+
await this.loadGames(this.log);
|
|
2776
|
+
if (this.games.some((g) => g.manifest.id === gameId)) {
|
|
2777
|
+
await this.calendar.hide(gameId, true);
|
|
2778
|
+
await this.loadGames(this.log);
|
|
2779
|
+
}
|
|
2780
|
+
this.changed();
|
|
2781
|
+
}
|
|
2782
|
+
/**
|
|
2783
|
+
* The agent finds where a game on the page can be read (one added by name
|
|
2784
|
+
* has no sources yet) and writes them into its game pack (game_add, the same
|
|
2785
|
+
* id), from the game's page, which shows it working (its web reading). An
|
|
2786
|
+
* official pack is not rewritten: the agent reads the web for it instead.
|
|
2787
|
+
*/
|
|
2788
|
+
async discover(gameId) {
|
|
2789
|
+
const game = this.game(gameId);
|
|
2790
|
+
if (game.builtin && game.followed !== true)
|
|
2791
|
+
return this.readWeb(gameId);
|
|
2792
|
+
const { manifest } = game;
|
|
2408
2793
|
const sessions = this.ctx.get("sessionController");
|
|
2409
2794
|
if (sessions === void 0)
|
|
2410
2795
|
throw new Error("agent \u73B0\u5728\u4E0D\u53EF\u7528\uFF08\u4F1A\u8BDD\u670D\u52A1\u6CA1\u6709\u52A0\u8F7D\uFF09");
|
|
2411
|
-
const conversations = sessionConversations(sessions, () => this.ctx.get("adgGateway")?.workspaceDir(),
|
|
2412
|
-
const sessionId = await conversations.home(GAME_ROLE.id);
|
|
2796
|
+
const conversations = sessionConversations(sessions, () => this.ctx.get("adgGateway")?.workspaceDir(), (id, f) => this.ctx.get("adgGateway")?.skillScope.setFocus(id, f) ?? Promise.resolve(), () => this.ctx.get("adgGateway"));
|
|
2797
|
+
const sessionId = await conversations.home(GAME_ROLE.id, { focus: { games: [manifest.id] } });
|
|
2798
|
+
await this.calendar.setReading(`${manifest.id}#web`, { state: "running", at: this.clock.now(), sessionId });
|
|
2799
|
+
this.changed(manifest.id);
|
|
2413
2800
|
const known = SRA_GAMES.map((g) => `${g.sra}\uFF08${g.name}\uFF09`).join("\u3001");
|
|
2801
|
+
const has = manifest.sources.length === 0 ? "\u8FD8\u6CA1\u6709\u4EFB\u4F55\u6765\u6E90" : `\u73B0\u5728\u7684\u6765\u6E90\uFF1A${manifest.sources.map((s) => s.name).join("\u3001")}`;
|
|
2414
2802
|
const prompt = [
|
|
2415
|
-
`\
|
|
2416
|
-
`1. SRA \u516C\u5171 API\uFF1A\u5DF2\u77E5\u7684\u6E38\u620F id \u6709 ${known}\u3002\u662F\u5176\u4E2D\u4E4B\u4E00\u5C31\
|
|
2803
|
+
`\u6E38\u620F\u9875\u4E0A\u6709\u300C${manifest.name}\u300D\uFF08\u6E38\u620F id\uFF1A${manifest.id}\uFF09\uFF0C${has}\u3002\u6309\u6280\u80FD web-reading \u627E\u80FD\u8BFB\u5230\u5B83\u6D3B\u52A8\u548C\u8D44\u8BAF\u7684\u6765\u6E90\uFF0C\u5199\u8FDB\u5B83\u7684\u6E38\u620F\u5305\uFF1A`,
|
|
2804
|
+
`1. SRA \u516C\u5171 API\uFF1A\u5DF2\u77E5\u7684\u6E38\u620F id \u6709 ${known}\u3002\u5B83\u662F\u5176\u4E2D\u4E4B\u4E00\uFF0C\u5C31\u5199\u4E00\u4E2A sra \u6765\u6E90\uFF1A{ "id": "sra", "name": "SRA \u516C\u5171 API", "sra": { "game": "<\u90A3\u4E2A id>" } }\u3002`,
|
|
2417
2805
|
"2. Wiki\uFF1AB \u7AD9\u6E38\u620F WIKI\uFF08wiki.biligame.com/<\u7F29\u5199>\uFF09\u6216\u5B98\u65B9 / \u73A9\u5BB6 Wiki\uFF0C\u8BD5\u5B83\u7684 api.php?action=ask \u80FD\u4E0D\u80FD\u67E5\u5230\u5E26\u5F00\u59CB\u3001\u7ED3\u675F\u65F6\u95F4\u7684\u6D3B\u52A8\u9875\uFF1B\u80FD\u7684\u8BDD\u5199\u6210 smw \u6765\u6E90\uFF08conditions\u3001start\u3001end \u7B49\u5C5E\u6027\u540D\u7167\u5B9E\u5199\uFF0Cdates \u6309\u5B58\u6CD5\u9009 date \u6216 text\uFF09\u3002",
|
|
2418
2806
|
"3. \u5B98\u7F51\u7684\u65B0\u95FB / \u516C\u544A\u5217\u8868\u9875\uFF1A\u5199\u6210\u53EA\u6709 homepage \u7684\u6765\u6E90\uFF08agent \u8BFB\uFF09\u3002",
|
|
2419
|
-
"
|
|
2420
|
-
|
|
2807
|
+
" \u5355\u673A\u6E38\u620F\uFF08\u4E70\u65AD\u5236\u3001\u6CA1\u6709\u9650\u65F6\u6D3B\u52A8\u7684\uFF09\uFF1A\u5728 Steam \u4E0A\u6709\u7684\uFF0C\u518D\u5199\u4E00\u4E2A Steam \u6765\u6E90\uFF08steam_appid \u662F\u5546\u5E97\u9875 store.steampowered.com/app/<\u6570\u5B57> \u91CC\u7684\u6570\u5B57\uFF09\uFF0C\u63D2\u4EF6\u6BCF\u5929\u81EA\u52A8\u8BFB\u5B83\u5728 Steam \u7684\u5B98\u65B9\u516C\u544A\uFF08\u7248\u672C\u66F4\u65B0\u3001\u8865\u4E01\u8BF4\u660E\uFF09\uFF1Bgame_add \u65F6\u5199 single=true\u3002",
|
|
2808
|
+
`4. \u7528 game_add \u5199\u5B83\u7684\u6E38\u620F\u5305\uFF1Aid \u4E00\u5B9A\u7528 ${manifest.id}\uFF08\u6362\u4E86 id \u6E38\u620F\u9875\u4E0A\u5C31\u6210\u4E86\u53E6\u4E00\u4E2A\u6E38\u620F\uFF09\uFF0Cname \u7528\u5B83\u7684\u4E2D\u6587\u6B63\u5F0F\u540D\uFF08\u7528\u6237\u5199\u7684\u540D\u5B57\u662F\u300C${manifest.name}\u300D\uFF09\uFF0Caliases \u5199\u5E38\u89C1\u7B80\u79F0\uFF0Ctimezone \u5199\u670D\u52A1\u5668\u65F6\u533A\uFF0Csources \u5199\u627E\u5230\u7684\uFF08\u539F\u6765\u6709\u7684\u4FDD\u7559\uFF09\uFF1Bguide \u5199\u51E0\u884C\uFF1A\u54EA\u4E9B\u6765\u6E90\u770B\u4EC0\u4E48\u3001\u516C\u544A\u9875\u600E\u4E48\u627E\u6D3B\u52A8\u3002`,
|
|
2809
|
+
"5. \u5199\u597D\u540E game_activities \u770B\u8BFB\u5230\u4E86\u4EC0\u4E48\uFF1B\u53EA\u6709\u7F51\u9875\u6765\u6E90\u7684\uFF0C\u5C31\u6309\u6280\u80FD\u8BFB\u4E00\u6B21\u516C\u544A\u9875\uFF0C\u7528 game_record\uFF08source=site\uFF09\u8BB0\u4E0B\u6D3B\u52A8\u3002\u5355\u673A\u6E38\u620F\u8BFB\u4E00\u6B21\u5B98\u65B9\u7684\u66F4\u65B0\u65E5\u5FD7\uFF0C\u7528 game_notice \u8BB0\u4E0B\u6700\u8FD1\u7684\u7248\u672C\u66F4\u65B0\u548C\u957F\u671F\u516C\u544A\u3002",
|
|
2810
|
+
"6. \u627E\u4E0D\u5230\u8FD9\u4E2A\u6E38\u620F\uFF08\u540D\u5B57\u4E0D\u5BF9\u3001\u6CA1\u6709\u516C\u5F00\u7684\u6D3B\u52A8\u4FE1\u606F\uFF09\u5C31\u4E0D\u8981 game_add\uFF0C\u76F4\u63A5\u8BF4\u660E\u627E\u4E86\u54EA\u91CC\u3001\u4E3A\u4EC0\u4E48\u6CA1\u627E\u5230\u3002",
|
|
2421
2811
|
"\u4E0D\u8981\u5411\u7528\u6237\u63D0\u95EE\uFF1B\u6700\u540E\u544A\u8BC9\u7528\u6237\u52A0\u4E86\u4EC0\u4E48\u6765\u6E90\u3001\u54EA\u4E9B\u80FD\u81EA\u52A8\u8BFB\u3001\u73B0\u5728\u6709\u51E0\u4E2A\u6D3B\u52A8\u3002"
|
|
2422
2812
|
].join("\n");
|
|
2423
|
-
void conversations.ask(sessionId, taskMessage("\u4F60", `\
|
|
2424
|
-
}).finally(() => this.changed());
|
|
2813
|
+
void conversations.ask(sessionId, taskMessage("\u4F60", `\u627E\u6D3B\u52A8\u6765\u6E90\uFF1A${manifest.name}`, prompt), AbortSignal.timeout(READ_TIMEOUT_MS)).then((answer) => this.calendar.setReading(`${manifest.id}#web`, { state: "done", at: this.clock.now(), sessionId, summary: answer.slice(0, 400) }), (error) => this.calendar.setReading(`${manifest.id}#web`, { state: "failed", at: this.clock.now(), sessionId, summary: error instanceof Error ? error.message : String(error) })).finally(() => this.changed(manifest.id));
|
|
2425
2814
|
return sessionId;
|
|
2426
2815
|
}
|
|
2427
2816
|
async readWeb(gameId, sourceId) {
|
|
@@ -2437,13 +2826,19 @@ ${guide.trim()}
|
|
|
2437
2826
|
await this.calendar.setReading(`${manifest.id}#web`, { state: "running", at: this.clock.now(), sessionId });
|
|
2438
2827
|
this.changed(manifest.id);
|
|
2439
2828
|
const where = chosen.length === 0 ? "\u6E38\u620F\u5305\u91CC\u6CA1\u6709\u5199\u7F51\u9875\u6765\u6E90\uFF1A\u6309\u6280\u80FD web-reading \u7684\u987A\u5E8F\u81EA\u5DF1\u627E\uFF08\u5148 SRA \u516C\u5171 API \u548C Wiki \u63A5\u53E3\uFF0C\u518D\u5B98\u7F51\u516C\u544A\uFF0C\u6700\u540E web_search\uFF09\u3002" : `\u8981\u8BFB\u7684\u6765\u6E90\uFF1A${chosen.map((s) => `${s.name}${s.homepage === void 0 ? "" : `\uFF08${s.homepage}\uFF09`}`).join("\uFF1B")}\u3002`;
|
|
2440
|
-
const prompt = [
|
|
2829
|
+
const prompt = (manifest.single === true ? [
|
|
2830
|
+
`\u4E0A\u7F51\u67E5\u5355\u673A\u6E38\u620F\u300C${manifest.name}\u300D\u6700\u8FD1\u7684\u5B98\u65B9\u516C\u544A\uFF08\u6E38\u620F id\uFF1A${manifest.id}\uFF09\uFF0C\u6309\u6280\u80FD web-reading \u548C game-intel\uFF1A`,
|
|
2831
|
+
`1. \u5148 game_activities\uFF08game=${manifest.id}\uFF09\u770B\u5DF2\u7ECF\u8BB0\u4E86\u54EA\u4E9B\u516C\u544A\uFF0C\u4E0D\u7528\u91CD\u590D\u8BB0\u3002`,
|
|
2832
|
+
`2. ${where}\u770B\u5B98\u65B9\u7684\u66F4\u65B0\u65E5\u5FD7\u6216\u516C\u544A\u5217\u8868\uFF08Steam \u65B0\u95FB\u3001\u5B98\u7F51\u535A\u5BA2\u3001\u516C\u544A\u9875\uFF09\uFF0C\u53EA\u6253\u5F00\u6700\u8FD1\u7684\u51E0\u7BC7\u3002`,
|
|
2833
|
+
"3. \u7248\u672C\u66F4\u65B0\u3001\u8865\u4E01\u8BF4\u660E\u7528 game_notice \u8BB0\u4E0B\uFF08kind=update\uFF0C\u5199\u4E0A\u7248\u672C\u53F7\u3001\u53D1\u5E03\u65E5\u671F\u3001\u4E00\u4E24\u53E5\u6539\u4E86\u4EC0\u4E48\u548C\u7F51\u5740\uFF1B\u6709\u914D\u56FE\u5C31\u5199\u8FDB cover\uFF09\uFF1B\u957F\u671F\u6709\u6548\u7684\u516C\u544A kind=notice\u3001lasting=true\uFF1B\u5176\u4ED6\u8D44\u8BAF kind=news\u3002\u5355\u673A\u6E38\u620F\u4E00\u822C\u6CA1\u6709\u9650\u65F6\u6D3B\u52A8\uFF0C\u771F\u6709\uFF08\u9650\u65F6\u6298\u6263\u3001\u8054\u52A8\u3001\u8282\u65E5\u6D3B\u52A8\uFF09\u624D\u7528 game_record\u3002",
|
|
2834
|
+
"4. \u4E0D\u6253\u5F00\u6E38\u620F\uFF0C\u4E0D\u5411\u7528\u6237\u63D0\u95EE\u3002\u6700\u540E\u7528\u4E24\u4E09\u53E5\u8BDD\u603B\u7ED3\uFF1A\u6700\u65B0\u7248\u672C\u662F\u4EC0\u4E48\u3001\u6539\u4E86\u4EC0\u4E48\u3001\u6709\u6CA1\u6709\u8981\u6CE8\u610F\u7684\u516C\u544A\u3002"
|
|
2835
|
+
] : [
|
|
2441
2836
|
`\u4E0A\u7F51\u67E5\u300C${manifest.name}\u300D\u73B0\u5728\u7684\u6D3B\u52A8\u548C\u6700\u65B0\u6D88\u606F\uFF08\u6E38\u620F id\uFF1A${manifest.id}\uFF09\uFF0C\u6309\u6280\u80FD web-reading \u548C game-intel\uFF1A`,
|
|
2442
2837
|
`1. \u5148 game_activities\uFF08game=${manifest.id}\uFF09\u770B\u65E5\u5386\u91CC\u5DF2\u7ECF\u6709\u4EC0\u4E48\uFF0C\u4E0D\u7528\u91CD\u590D\u67E5\u3002`,
|
|
2443
2838
|
`2. ${where}\u5148\u8BFB\u5217\u8868\u9875\uFF0C\u53EA\u6253\u5F00\u6700\u8FD1\u7684\u6D3B\u52A8\u3001\u7248\u672C\u548C\u7EF4\u62A4\u516C\u544A\u3002`,
|
|
2444
|
-
"3. \u6BCF\u4E2A\u627E\u5230\u8D77\u6B62\u65F6\u95F4\u7684\u6D3B\u52A8\u7528 game_record\uFF08source=site\uFF0C\u5199\u4E0A url\uFF1B\u516C\u544A\u91CC\u6709\u8FD9\u4E2A\u6D3B\u52A8\u7684\u914D\u56FE\u5C31\u628A\u56FE\u7247\u5730\u5740\u5199\u8FDB cover\uFF09\u8BB0\u4E0B\uFF1B\u53EA\u8BB0\u6709\u786E\u5207\u51FA\u5904\u7684\u65F6\u95F4\u3002",
|
|
2839
|
+
"3. \u6BCF\u4E2A\u627E\u5230\u8D77\u6B62\u65F6\u95F4\u7684\u6D3B\u52A8\u7528 game_record\uFF08source=site\uFF0C\u5199\u4E0A url\uFF1B\u516C\u544A\u91CC\u6709\u8FD9\u4E2A\u6D3B\u52A8\u7684\u914D\u56FE\u5C31\u628A\u56FE\u7247\u5730\u5740\u5199\u8FDB cover\uFF09\u8BB0\u4E0B\uFF1B\u53EA\u8BB0\u6709\u786E\u5207\u51FA\u5904\u7684\u65F6\u95F4\u3002\u7248\u672C\u66F4\u65B0\u516C\u544A\u548C\u957F\u671F\u6709\u6548\u7684\u516C\u544A\uFF08\u6CA1\u6709\u7ED3\u675F\u65F6\u95F4\u7684\uFF09\u7528 game_notice \u8BB0\u4E0B\uFF08kind=update \u6216 notice\uFF0C\u957F\u671F\u7684\u5199 lasting=true\uFF09\u3002",
|
|
2445
2840
|
"4. \u4E0D\u6253\u5F00\u6E38\u620F\uFF0C\u4E0D\u5411\u7528\u6237\u63D0\u95EE\u3002\u6700\u540E\u7528\u4E24\u4E09\u53E5\u8BDD\u603B\u7ED3\uFF1A\u73B0\u5728\u6709\u54EA\u4E9B\u6D3B\u52A8\u3001\u54EA\u4E9B\u5FEB\u7ED3\u675F\u3001\u6709\u4EC0\u4E48\u65B0\u6D88\u606F\uFF08\u65B0\u7248\u672C\u3001\u7EF4\u62A4\u3001\u798F\u5229\uFF09\u3002"
|
|
2446
|
-
].join("\n");
|
|
2841
|
+
]).join("\n");
|
|
2447
2842
|
void conversations.ask(sessionId, taskMessage("\u4F60", `\u6E38\u620F\u8D44\u8BAF\uFF1A${manifest.name}`, prompt), AbortSignal.timeout(READ_TIMEOUT_MS)).then((answer) => this.calendar.setReading(`${manifest.id}#web`, { state: "done", at: this.clock.now(), sessionId, summary: answer.slice(0, 400) }), (error) => this.calendar.setReading(`${manifest.id}#web`, { state: "failed", at: this.clock.now(), sessionId, summary: error instanceof Error ? error.message : String(error) })).finally(() => this.changed(manifest.id));
|
|
2448
2843
|
return sessionId;
|
|
2449
2844
|
}
|
|
@@ -2609,8 +3004,10 @@ export {
|
|
|
2609
3004
|
parseDateText,
|
|
2610
3005
|
parseRemaining,
|
|
2611
3006
|
parseSra,
|
|
3007
|
+
parseSteam,
|
|
2612
3008
|
readSmw,
|
|
2613
3009
|
readSra,
|
|
3010
|
+
readSteam,
|
|
2614
3011
|
readValue,
|
|
2615
3012
|
realClock,
|
|
2616
3013
|
recentDigest,
|