dsh-multigameassistant 2.2.2 → 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-CCYE6H2F.js → chunk-AJMAUHPI.js} +7 -5
- package/lib/{chunk-RGEGJH6R.js → chunk-TXW3NMBH.js} +209 -10
- package/lib/{chunk-DSWWQWQH.js → chunk-VBWSM7LF.js} +28 -9
- package/lib/{chunk-6YPSKAQ5.js → chunk-VG32XPZH.js} +91 -52
- 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-CCYE6H2F.js.LEGAL.txt → chunk-AJMAUHPI.js.LEGAL.txt} +0 -0
|
@@ -2,7 +2,7 @@ import { createRequire as __adgCreateRequire } from 'node:module'; import { dirn
|
|
|
2
2
|
import {
|
|
3
3
|
ScriptFamily,
|
|
4
4
|
ScriptId
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-7EFZ5KR6.js";
|
|
6
6
|
import {
|
|
7
7
|
external_exports
|
|
8
8
|
} from "./chunk-6DSSLS7I.js";
|
|
@@ -7342,6 +7342,52 @@ var require_dist = __commonJS({
|
|
|
7342
7342
|
}
|
|
7343
7343
|
});
|
|
7344
7344
|
|
|
7345
|
+
// packages/pack-schema/lib/routine.js
|
|
7346
|
+
var Id = external_exports.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, "lowercase letters, digits and dashes");
|
|
7347
|
+
var Regex = external_exports.string().min(1).refine((value) => {
|
|
7348
|
+
try {
|
|
7349
|
+
new RegExp(value);
|
|
7350
|
+
return true;
|
|
7351
|
+
} catch {
|
|
7352
|
+
return false;
|
|
7353
|
+
}
|
|
7354
|
+
}, "invalid regular expression");
|
|
7355
|
+
var RoutinePeriod = external_exports.enum(["daily", "weekly", "event"]);
|
|
7356
|
+
var routineFields = {
|
|
7357
|
+
id: Id,
|
|
7358
|
+
name: external_exports.string().trim().min(1),
|
|
7359
|
+
period: RoutinePeriod,
|
|
7360
|
+
description: external_exports.string().trim().min(1).optional(),
|
|
7361
|
+
/**
|
|
7362
|
+
* Log lines that show it was done (regular expressions, tested on every
|
|
7363
|
+
* line of a run): in a Script Pack, that script's runs; in a Game Pack, the
|
|
7364
|
+
* runs of every script that plays the game.
|
|
7365
|
+
*/
|
|
7366
|
+
log: external_exports.union([Regex, external_exports.array(Regex).min(1)]).optional(),
|
|
7367
|
+
/**
|
|
7368
|
+
* period=event: the data sites' events it is (their names, as regular
|
|
7369
|
+
* expressions). They are listed apart from the other events, as 周期玩法.
|
|
7370
|
+
*/
|
|
7371
|
+
events: external_exports.array(Regex).min(1).optional()
|
|
7372
|
+
};
|
|
7373
|
+
function eventsNeeded(routine, issues) {
|
|
7374
|
+
if (routine.period === "event" && routine.events === void 0)
|
|
7375
|
+
issues.addIssue({ code: "custom", path: ["events"], message: "period event needs the events it is (their names)" });
|
|
7376
|
+
}
|
|
7377
|
+
var GameRoutine = external_exports.object(routineFields).superRefine(eventsNeeded);
|
|
7378
|
+
var ScriptRoutine = external_exports.object({
|
|
7379
|
+
...routineFields,
|
|
7380
|
+
/** This script's tasks: a run of one that succeeds did it. */
|
|
7381
|
+
tasks: external_exports.array(external_exports.string().regex(/^[a-z0-9][a-z0-9_-]*$/)).min(1).optional()
|
|
7382
|
+
}).superRefine(eventsNeeded);
|
|
7383
|
+
var WeeklyReset = external_exports.object({
|
|
7384
|
+
day: external_exports.number().int().min(1).max(7).default(1),
|
|
7385
|
+
at: external_exports.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/, "HH:mm").optional()
|
|
7386
|
+
});
|
|
7387
|
+
function routineLogs(routine) {
|
|
7388
|
+
return routine.log === void 0 ? [] : typeof routine.log === "string" ? [routine.log] : [...routine.log];
|
|
7389
|
+
}
|
|
7390
|
+
|
|
7345
7391
|
// packages/pack-schema/lib/manifest.js
|
|
7346
7392
|
var Requirement = external_exports.object({
|
|
7347
7393
|
/** e.g. `dotnet-desktop-runtime`, `vcredist`, `adb`, `python`, `node`, `emulator`. */
|
|
@@ -7365,7 +7411,7 @@ var ConfigFile = external_exports.object({
|
|
|
7365
7411
|
});
|
|
7366
7412
|
var open = external_exports.record(external_exports.string(), external_exports.unknown());
|
|
7367
7413
|
var RelativePath = external_exports.string().min(1).refine((p) => !p.split(/[\\/]/).includes("..") && !/^([A-Za-z]:|[\\/])/.test(p), "must stay inside the script directory");
|
|
7368
|
-
var
|
|
7414
|
+
var Regex2 = external_exports.string().min(1).refine((value) => {
|
|
7369
7415
|
try {
|
|
7370
7416
|
new RegExp(value);
|
|
7371
7417
|
return true;
|
|
@@ -7385,7 +7431,7 @@ var ParamChoices = external_exports.object({
|
|
|
7385
7431
|
/** Field shown beside it, e.g. the controller. */
|
|
7386
7432
|
detail: external_exports.string().optional(),
|
|
7387
7433
|
/** Only items whose `field` matches (a regular expression, case-insensitive). */
|
|
7388
|
-
where: external_exports.object({ field: external_exports.string().min(1), match:
|
|
7434
|
+
where: external_exports.object({ field: external_exports.string().min(1), match: Regex2 }).optional(),
|
|
7389
7435
|
/**
|
|
7390
7436
|
* New items may be made by copying an existing one (the first that
|
|
7391
7437
|
* matches `where`), so the structure stays the script's own; `set` fields
|
|
@@ -7677,7 +7723,7 @@ var ScriptManifest = external_exports.object({
|
|
|
7677
7723
|
* are tried (interface.json, version.txt…, the programs' file versions).
|
|
7678
7724
|
*/
|
|
7679
7725
|
version: external_exports.union([
|
|
7680
|
-
external_exports.object({ file: RelativePath, json: external_exports.array(external_exports.string().min(1)).min(1).optional(), pattern:
|
|
7726
|
+
external_exports.object({ file: RelativePath, json: external_exports.array(external_exports.string().min(1)).min(1).optional(), pattern: Regex2.optional() }),
|
|
7681
7727
|
external_exports.object({ exe: RelativePath })
|
|
7682
7728
|
]).optional()
|
|
7683
7729
|
}).default({ requires: [] }),
|
|
@@ -7691,6 +7737,8 @@ var ScriptManifest = external_exports.object({
|
|
|
7691
7737
|
tasks: external_exports.array(Task).default([]),
|
|
7692
7738
|
logs: Logs.default({ sources: [{ stdout: true, encoding: "auto" }], rules: [] }),
|
|
7693
7739
|
recovery: external_exports.array(Recovery).default([]),
|
|
7740
|
+
/** The game's 日常 / 周常 this script does, and how a run shows each was done (routine.ts). */
|
|
7741
|
+
routines: external_exports.array(ScriptRoutine).default([]),
|
|
7694
7742
|
game: Game.optional(),
|
|
7695
7743
|
/** The user guide shown on the 脚本 page. */
|
|
7696
7744
|
guide: Guide.optional(),
|
|
@@ -7707,6 +7755,16 @@ var ScriptManifest = external_exports.object({
|
|
|
7707
7755
|
if (manifest.launch === void 0)
|
|
7708
7756
|
issues.addIssue({ code: "custom", path: ["launch"], message: "tasks need a launch section" });
|
|
7709
7757
|
});
|
|
7758
|
+
const routineIds = /* @__PURE__ */ new Set();
|
|
7759
|
+
manifest.routines.forEach((routine, index) => {
|
|
7760
|
+
if (routineIds.has(routine.id))
|
|
7761
|
+
issues.addIssue({ code: "custom", path: ["routines", index, "id"], message: `duplicate routine id ${routine.id}` });
|
|
7762
|
+
routineIds.add(routine.id);
|
|
7763
|
+
routine.tasks?.forEach((task, at) => {
|
|
7764
|
+
if (!ids.has(task))
|
|
7765
|
+
issues.addIssue({ code: "custom", path: ["routines", index, "tasks", at], message: `no task ${task}` });
|
|
7766
|
+
});
|
|
7767
|
+
});
|
|
7710
7768
|
const tags = /* @__PURE__ */ new Set(["stalled", "failed", ...manifest.logs.rules.map((r) => r.tag ?? r.level)]);
|
|
7711
7769
|
manifest.recovery.forEach((entry, index) => {
|
|
7712
7770
|
if (!tags.has(entry.on))
|
|
@@ -7890,6 +7948,7 @@ var TOOLS = [
|
|
|
7890
7948
|
"skill_save",
|
|
7891
7949
|
"skill_hub_install",
|
|
7892
7950
|
"skill_hub_list",
|
|
7951
|
+
"emulator_apps",
|
|
7893
7952
|
"emulator_configure",
|
|
7894
7953
|
"emulator_install",
|
|
7895
7954
|
"emulator_start",
|
|
@@ -7979,10 +8038,42 @@ function parseManifest(text, file = "adg.script.yaml") {
|
|
|
7979
8038
|
}
|
|
7980
8039
|
return parsed.data;
|
|
7981
8040
|
}
|
|
8041
|
+
function strayKeys(text) {
|
|
8042
|
+
let raw;
|
|
8043
|
+
try {
|
|
8044
|
+
raw = (0, import_yaml.parse)(text, { maxAliasCount: 100 });
|
|
8045
|
+
} catch {
|
|
8046
|
+
return [];
|
|
8047
|
+
}
|
|
8048
|
+
const out = [];
|
|
8049
|
+
const isObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
8050
|
+
const check = (value, shape, where) => {
|
|
8051
|
+
if (!isObject(value))
|
|
8052
|
+
return;
|
|
8053
|
+
for (const key of Object.keys(value))
|
|
8054
|
+
if (!(key in shape))
|
|
8055
|
+
out.push(where === "" ? key : `${where}.${key}`);
|
|
8056
|
+
};
|
|
8057
|
+
const each = (value, shape, where) => {
|
|
8058
|
+
if (Array.isArray(value))
|
|
8059
|
+
value.forEach((item, i) => check(item, shape, `${where}[${i}]`));
|
|
8060
|
+
};
|
|
8061
|
+
check(raw, ScriptManifest.shape, "");
|
|
8062
|
+
if (!isObject(raw))
|
|
8063
|
+
return out;
|
|
8064
|
+
check(raw["guide"], Guide.shape, "guide");
|
|
8065
|
+
check(raw["launch"], Launch.shape, "launch");
|
|
8066
|
+
check(raw["logs"], Logs.shape, "logs");
|
|
8067
|
+
if (isObject(raw["logs"]))
|
|
8068
|
+
each(raw["logs"]["rules"], LogRule.shape, "logs.rules");
|
|
8069
|
+
each(raw["tasks"], Task.shape, "tasks");
|
|
8070
|
+
each(raw["routines"], ScriptRoutine.shape, "routines");
|
|
8071
|
+
return out;
|
|
8072
|
+
}
|
|
7982
8073
|
|
|
7983
8074
|
// packages/pack-schema/lib/game.js
|
|
7984
8075
|
var import_yaml2 = __toESM(require_dist(), 1);
|
|
7985
|
-
var
|
|
8076
|
+
var Id2 = external_exports.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, "lowercase letters, digits and dashes");
|
|
7986
8077
|
var Url = external_exports.string().url().refine((u) => /^https?:\/\//.test(u), "an http(s) address");
|
|
7987
8078
|
var SmwSource = external_exports.object({
|
|
7988
8079
|
/** The wiki's `api.php`. */
|
|
@@ -8014,31 +8105,79 @@ var SraSource = external_exports.object({
|
|
|
8014
8105
|
locale: external_exports.string().regex(/^[a-z]{2}-[A-Z]{2}$/).optional(),
|
|
8015
8106
|
api: Url.default("https://starrailassistant.top/api/v1")
|
|
8016
8107
|
});
|
|
8108
|
+
var PoolSource = external_exports.object({
|
|
8109
|
+
api: Url,
|
|
8110
|
+
/** SMW conditions picking banner pages, e.g. `[[分类:跃迁]]`. */
|
|
8111
|
+
conditions: external_exports.string().min(2),
|
|
8112
|
+
/** Property holding the banner's name; the page name when absent. */
|
|
8113
|
+
title: external_exports.string().min(1).optional(),
|
|
8114
|
+
/** Property holding its kind (角色 / 光锥 / 限定寻访…). */
|
|
8115
|
+
type: external_exports.string().min(1).optional(),
|
|
8116
|
+
start: external_exports.string().min(1),
|
|
8117
|
+
end: external_exports.string().min(1),
|
|
8118
|
+
/**
|
|
8119
|
+
* How the dates are stored: `date` and `text` as in `SmwSource.dates`;
|
|
8120
|
+
* `local`, SMW dates that hold the game's wall clock as if it were UTC
|
|
8121
|
+
* (a wiki that typed server time into a date property).
|
|
8122
|
+
*/
|
|
8123
|
+
dates: external_exports.enum(["date", "text", "local"]).default("date"),
|
|
8124
|
+
/** Properties listing who (or what) is on rate-up, in order. */
|
|
8125
|
+
up: external_exports.array(external_exports.string().min(1)).default([]),
|
|
8126
|
+
/** Pages per query. @default 50 */
|
|
8127
|
+
limit: external_exports.number().int().min(1).max(500).default(50),
|
|
8128
|
+
/** A wiki file named after each banner's page, used as its picture; a page that is itself a file (PRTS) is its own picture. */
|
|
8129
|
+
image: external_exports.string().includes("{page}").optional()
|
|
8130
|
+
});
|
|
8131
|
+
var HoyoSource = external_exports.object({
|
|
8132
|
+
game: external_exports.enum(["genshin", "starrail", "zzz"]),
|
|
8133
|
+
lang: external_exports.string().regex(/^[a-z]{2}(?:-[a-z]{2})?$/).default("zh-cn"),
|
|
8134
|
+
api: Url.default("https://api.ennead.cc/mihoyo")
|
|
8135
|
+
});
|
|
8017
8136
|
var SteamSource = external_exports.object({
|
|
8018
8137
|
/** The game's Steam app id (the number in store.steampowered.com/app/<id>/). */
|
|
8019
8138
|
appid: external_exports.number().int().positive()
|
|
8020
8139
|
});
|
|
8021
8140
|
var GameSource = external_exports.object({
|
|
8022
|
-
id:
|
|
8141
|
+
id: Id2,
|
|
8023
8142
|
name: external_exports.string().min(1),
|
|
8024
8143
|
/** Where a person (or the agent, with web_fetch) reads it. */
|
|
8025
8144
|
homepage: Url.optional(),
|
|
8026
8145
|
/** Read by the plugin itself (smw, sra or steam); without one the source is only for the agent. */
|
|
8027
8146
|
smw: SmwSource.optional(),
|
|
8028
8147
|
sra: SraSource.optional(),
|
|
8029
|
-
steam: SteamSource.optional()
|
|
8030
|
-
|
|
8148
|
+
steam: SteamSource.optional(),
|
|
8149
|
+
/** Banners on a wiki (a source of its own: a game may read its events from one site and its banners from another). */
|
|
8150
|
+
pools: PoolSource.optional(),
|
|
8151
|
+
/** miHoYo banners from ennead's API (HoyoSource). */
|
|
8152
|
+
hoyo: HoyoSource.optional()
|
|
8153
|
+
}).refine((s) => [s.smw, s.sra, s.steam, s.pools, s.hoyo].filter((x) => x !== void 0).length <= 1, "smw\u3001sra\u3001steam\u3001pools \u548C hoyo \u53EA\u80FD\u5199\u4E00\u4E2A");
|
|
8031
8154
|
var GameManifest = external_exports.object({
|
|
8032
|
-
id:
|
|
8155
|
+
id: Id2,
|
|
8033
8156
|
name: external_exports.string().min(1),
|
|
8034
8157
|
/** Other names people call it, to match the user's words and script packs' `game.name`. */
|
|
8035
8158
|
aliases: external_exports.array(external_exports.string().min(1)).default([]),
|
|
8036
8159
|
/** Script Packs that play it. */
|
|
8037
|
-
scripts: external_exports.array(
|
|
8160
|
+
scripts: external_exports.array(Id2).default([]),
|
|
8038
8161
|
/** The server's time zone: dates written without one, and where a day starts. */
|
|
8039
8162
|
timezone: external_exports.string().min(1).default("Asia/Shanghai"),
|
|
8040
8163
|
/** When the game's day rolls over, `HH:mm` server time. */
|
|
8041
8164
|
dailyReset: external_exports.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/, "HH:mm").default("04:00"),
|
|
8165
|
+
/** When its week starts over (周常): Monday at the daily reset unless said. */
|
|
8166
|
+
weeklyReset: WeeklyReset.default({ day: 1 }),
|
|
8167
|
+
/** Its 日常 and 周常, and the recurring events that are one (routine.ts); the scripts that play it add theirs. */
|
|
8168
|
+
routines: external_exports.array(GameRoutine).default([]),
|
|
8169
|
+
/**
|
|
8170
|
+
* Its Android builds, one per client, as MAA's resource/config.json
|
|
8171
|
+
* `packageName` lists Arknights' (Official, Bilibili, YoStarEN…): matched
|
|
8172
|
+
* against the apps installed in the emulator to find which one the user plays.
|
|
8173
|
+
*/
|
|
8174
|
+
android: external_exports.object({
|
|
8175
|
+
packages: external_exports.array(external_exports.object({
|
|
8176
|
+
package: external_exports.string().regex(/^[A-Za-z][\w]*(\.[A-Za-z_][\w]*)+$/, "an Android package name like com.example.game"),
|
|
8177
|
+
/** Which client, for people: 官服, B服, 国际服… */
|
|
8178
|
+
client: external_exports.string().min(1).optional()
|
|
8179
|
+
})).min(1)
|
|
8180
|
+
}).optional(),
|
|
8042
8181
|
/** How the agent sees the game: in the emulator, or its PC window. */
|
|
8043
8182
|
screen: external_exports.object({
|
|
8044
8183
|
target: external_exports.enum(["emulator", "window"]),
|
|
@@ -8141,6 +8280,60 @@ function parseJsonc(source) {
|
|
|
8141
8280
|
return JSON.parse(stripJsonc(source.replace(/^/, "")));
|
|
8142
8281
|
}
|
|
8143
8282
|
|
|
8283
|
+
// packages/pack-schema/lib/launch.js
|
|
8284
|
+
function launchCommand(file, args, platform, comspec) {
|
|
8285
|
+
if (platform === "win32" && /\.(bat|cmd)$/i.test(file)) {
|
|
8286
|
+
const unsafe = args.find((a) => /["\r\n]/.test(a));
|
|
8287
|
+
if (unsafe !== void 0)
|
|
8288
|
+
throw new Error(`\u53C2\u6570\u300C${unsafe.slice(0, 40)}\u300D\u91CC\u6709\u53CC\u5F15\u53F7\u6216\u6362\u884C\uFF0C\u4E0D\u80FD\u5B89\u5168\u5730\u4EA4\u7ED9\u6279\u5904\u7406\u542F\u52A8\u5668 ${file.split(/[\\/]/).at(-1)}`);
|
|
8289
|
+
const line = [escapeCommand(file), ...args.map(escapeArgument)].join(" ");
|
|
8290
|
+
return { file: comspec ?? "cmd.exe", args: ["/d", "/s", "/c", `"${line}"`], verbatim: true };
|
|
8291
|
+
}
|
|
8292
|
+
if (platform === "win32" && /\.ps1$/i.test(file)) {
|
|
8293
|
+
return { file: "powershell.exe", args: ["-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-File", file, ...args], verbatim: false };
|
|
8294
|
+
}
|
|
8295
|
+
return { file, args: [...args], verbatim: false };
|
|
8296
|
+
}
|
|
8297
|
+
var isScriptLauncher = (file) => /\.(bat|cmd|ps1)$/i.test(file);
|
|
8298
|
+
var META = /([()\][%!^"`<>&|;, *?])/g;
|
|
8299
|
+
function escapeCommand(file) {
|
|
8300
|
+
return file.replace(META, "^$1");
|
|
8301
|
+
}
|
|
8302
|
+
function escapeArgument(arg) {
|
|
8303
|
+
const quoted = `"${arg.replace(/(?=(\\+?)?)\1"/g, '$1$1\\"').replace(/(?=(\\+?)?)\1$/, "$1$1")}"`;
|
|
8304
|
+
return quoted.replace(META, "^$1");
|
|
8305
|
+
}
|
|
8306
|
+
|
|
8307
|
+
// packages/pack-schema/lib/patterns.js
|
|
8308
|
+
function patternIssues(manifest) {
|
|
8309
|
+
const issues = [];
|
|
8310
|
+
const check = (where, pattern) => {
|
|
8311
|
+
let re;
|
|
8312
|
+
try {
|
|
8313
|
+
re = new RegExp(pattern);
|
|
8314
|
+
} catch {
|
|
8315
|
+
return;
|
|
8316
|
+
}
|
|
8317
|
+
if (re.test(""))
|
|
8318
|
+
issues.push(`${where} \u7684\u300C${pattern}\u300D\u4F1A\u5339\u914D\u6BCF\u4E00\u884C\uFF08\u300C|\u300D\u4E24\u8FB9\u6709\u4E00\u8FB9\u662F\u7A7A\u7684\uFF1F\uFF09`);
|
|
8319
|
+
else if (/\\\\[[\]().|*+?{}]/.test(pattern))
|
|
8320
|
+
issues.push(`${where} \u7684\u300C${pattern}\u300D\u91CC\u53CD\u659C\u6760\u5199\u4E86\u4E24\u6B21\uFF1A\u5355\u5F15\u53F7 YAML \u91CC \\[ \u5C31\u662F\u6B63\u5219\u7684 \\[\uFF0C\u5199\u6210 \\\\[ \u4F1A\u53BB\u627E\u4E00\u4E2A\u53CD\u659C\u6760\uFF0C\u65E5\u5FD7\u91CC\u90A3\u4E00\u884C\u5C31\u5BF9\u4E0D\u4E0A\u4E86`);
|
|
8321
|
+
};
|
|
8322
|
+
manifest.logs?.rules.forEach((rule, i) => check(`logs.rules[${i}].match`, rule.match));
|
|
8323
|
+
manifest.routines?.forEach((routine, i) => {
|
|
8324
|
+
for (const p of routineLogs(routine))
|
|
8325
|
+
check(`routines[${i}]\uFF08${routine.name}\uFF09.log`, p);
|
|
8326
|
+
});
|
|
8327
|
+
const warnings = new Set((manifest.logs?.rules ?? []).filter((r) => r.level === "warning" && r.tag !== void 0).map((r) => r.tag));
|
|
8328
|
+
const errors = new Set((manifest.logs?.rules ?? []).filter((r) => r.level === "error" && r.tag !== void 0).map((r) => r.tag));
|
|
8329
|
+
for (const [i, r] of (manifest.recovery ?? []).entries()) {
|
|
8330
|
+
if ((r.do === "stop" || r.do === "restart") && warnings.has(r.on) && !errors.has(r.on)) {
|
|
8331
|
+
issues.push(`recovery[${i}] \u5728\u8B66\u544A\u300C${r.on}\u300D\u4E0A ${r.do}\uFF1A\u8B66\u544A\u591A\u534A\u662F\u811A\u672C\u81EA\u5DF1\u4F1A\u91CD\u8BD5\u7684\u60C5\u51B5\uFF0C${r.do === "stop" ? "\u505C\u6389" : "\u91CD\u8DD1"}\u4F1A\u6253\u65AD\u672C\u6765\u80FD\u8DD1\u5B8C\u7684\u4EFB\u52A1\uFF1B\u53EA\u7ED9\u786E\u5B9A\u8DD1\u4E0D\u4E0B\u53BB\u7684\u9519\u8BEF\uFF08level: error\uFF09\u5199\uFF0C\u6216\u8005\u53BB\u6389\u8FD9\u6761`);
|
|
8332
|
+
}
|
|
8333
|
+
}
|
|
8334
|
+
return issues;
|
|
8335
|
+
}
|
|
8336
|
+
|
|
8144
8337
|
// packages/pack-schema/lib/render.js
|
|
8145
8338
|
var TaskInputError = class extends Error {
|
|
8146
8339
|
constructor(message) {
|
|
@@ -8322,6 +8515,7 @@ var MANIFEST_FILE = "adg.script.yaml";
|
|
|
8322
8515
|
var SKILL_FILE = "SKILL.md";
|
|
8323
8516
|
|
|
8324
8517
|
export {
|
|
8518
|
+
routineLogs,
|
|
8325
8519
|
MCP_SERVER_NAME,
|
|
8326
8520
|
guideView,
|
|
8327
8521
|
guideIssues,
|
|
@@ -8329,6 +8523,8 @@ export {
|
|
|
8329
8523
|
renderTask,
|
|
8330
8524
|
require_dist,
|
|
8331
8525
|
parseManifest,
|
|
8526
|
+
strayKeys,
|
|
8527
|
+
GameSource,
|
|
8332
8528
|
GameManifest,
|
|
8333
8529
|
GAME_MANIFEST_FILE,
|
|
8334
8530
|
GAME_GUIDE_FILE,
|
|
@@ -8338,6 +8534,9 @@ export {
|
|
|
8338
8534
|
globToRegExp,
|
|
8339
8535
|
versionOfTag,
|
|
8340
8536
|
chooseAsset,
|
|
8537
|
+
launchCommand,
|
|
8538
|
+
isScriptLauncher,
|
|
8539
|
+
patternIssues,
|
|
8341
8540
|
MANIFEST_FILE,
|
|
8342
8541
|
SKILL_FILE
|
|
8343
8542
|
};
|
|
@@ -2,13 +2,14 @@ import { createRequire as __adgCreateRequire } from 'node:module'; import { dirn
|
|
|
2
2
|
import {
|
|
3
3
|
SUMMARIES_FILE,
|
|
4
4
|
summariesReader
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-Y3ZZBBLV.js";
|
|
6
6
|
import {
|
|
7
7
|
writeFileAtomic
|
|
8
8
|
} from "./chunk-RESS7WVY.js";
|
|
9
9
|
import {
|
|
10
10
|
AGENTS_CAPABILITY,
|
|
11
11
|
AGENT_AREAS,
|
|
12
|
+
APP_FILES_RULE,
|
|
12
13
|
ARCHIVE_MARK,
|
|
13
14
|
AreaPolicy,
|
|
14
15
|
COMPACTION_CAPABILITY,
|
|
@@ -43,7 +44,7 @@ import {
|
|
|
43
44
|
personaPrompt,
|
|
44
45
|
threadsBetween,
|
|
45
46
|
timetableText
|
|
46
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-7EFZ5KR6.js";
|
|
47
48
|
import {
|
|
48
49
|
external_exports
|
|
49
50
|
} from "./chunk-6DSSLS7I.js";
|
|
@@ -7476,10 +7477,12 @@ var HandOffs = class {
|
|
|
7476
7477
|
#listeners = /* @__PURE__ */ new Set();
|
|
7477
7478
|
loaded;
|
|
7478
7479
|
constructor(file, changed = () => {
|
|
7479
|
-
}) {
|
|
7480
|
+
}, log = console) {
|
|
7480
7481
|
this.#file = file;
|
|
7481
7482
|
this.#changed = changed;
|
|
7482
|
-
this.loaded = this.#load()
|
|
7483
|
+
this.loaded = this.#load().catch((error) => {
|
|
7484
|
+
log.warn(`\u5199\u56DE\u4E2D\u65AD\u4EFB\u52A1\u72B6\u6001\u5931\u8D25\uFF1A${error instanceof Error ? error.message : String(error)}`);
|
|
7485
|
+
});
|
|
7483
7486
|
}
|
|
7484
7487
|
/** Those from or to this conversation, oldest first. */
|
|
7485
7488
|
of(sessionId) {
|
|
@@ -7524,6 +7527,7 @@ var HandOffs = class {
|
|
|
7524
7527
|
async #load() {
|
|
7525
7528
|
if (this.#file === void 0)
|
|
7526
7529
|
return;
|
|
7530
|
+
let recovered = false;
|
|
7527
7531
|
try {
|
|
7528
7532
|
const saved = JSON.parse(await readFile7(this.#file, "utf8"));
|
|
7529
7533
|
if (!Array.isArray(saved))
|
|
@@ -7531,10 +7535,17 @@ var HandOffs = class {
|
|
|
7531
7535
|
for (const item of saved) {
|
|
7532
7536
|
if (typeof item?.id !== "string")
|
|
7533
7537
|
continue;
|
|
7534
|
-
|
|
7538
|
+
if (item.state === "running" || item.state === "waiting") {
|
|
7539
|
+
this.#items.set(item.id, { ...item, state: "failed", reply: "\u8F6F\u4EF6\u5173\u95ED\u65F6\u5B83\u8FD8\u6CA1\u505A\u5B8C\uFF0C\u8FD9\u4E00\u8F6E\u4E2D\u65AD\u4E86", endedAt: Date.now() });
|
|
7540
|
+
recovered = true;
|
|
7541
|
+
} else
|
|
7542
|
+
this.#items.set(item.id, item);
|
|
7535
7543
|
}
|
|
7536
7544
|
} catch {
|
|
7545
|
+
return;
|
|
7537
7546
|
}
|
|
7547
|
+
if (recovered)
|
|
7548
|
+
await this.#save();
|
|
7538
7549
|
}
|
|
7539
7550
|
};
|
|
7540
7551
|
|
|
@@ -9182,7 +9193,7 @@ var AdgGateway = class extends Service {
|
|
|
9182
9193
|
this.agentModels = new AgentModels(config.dataDir === void 0 ? void 0 : join8(config.dataDir, "agent-models.json"), config.dataDir === void 0 ? void 0 : join8(config.dataDir, "role-model.json"));
|
|
9183
9194
|
this.roles = new SessionRoles(config.dataDir === void 0 ? void 0 : join8(config.dataDir, "session-roles.json"), () => this.broadcast("roles/changed", { items: this.roles.list() }));
|
|
9184
9195
|
this.homes = new AgentHomes(config.dataDir === void 0 ? void 0 : join8(config.dataDir, "agent-homes.json"));
|
|
9185
|
-
this.handOffs = new HandOffs(config.dataDir === void 0 ? void 0 : join8(config.dataDir, "handoffs.json"), (item) => this.broadcast("handoffs/changed", { item }));
|
|
9196
|
+
this.handOffs = new HandOffs(config.dataDir === void 0 ? void 0 : join8(config.dataDir, "handoffs.json"), (item) => this.broadcast("handoffs/changed", { item }), log);
|
|
9186
9197
|
if (!this.shared)
|
|
9187
9198
|
ctx.inject(["tools", "systemPrompt"], (scoped) => {
|
|
9188
9199
|
scoped.effect(() => this.parts.attach(scoped), "adg-gateway agent parts");
|
|
@@ -10196,8 +10207,10 @@ Content-Length: 0
|
|
|
10196
10207
|
this.log.warn(`tools of the ${spec.name} agent (${agent.session.id}): ${error instanceof Error ? error.message : String(error)}`);
|
|
10197
10208
|
}
|
|
10198
10209
|
try {
|
|
10199
|
-
const duty = [spec.duty, spec.subAgentOf === void 0 ? ROLE_CLOSING : void 0].filter((text2) => text2 !== void 0 && text2 !== "").join("\n\n");
|
|
10200
|
-
const text = spec === MAIN_AGENT ? () => mainDuty(this.roles.list())
|
|
10210
|
+
const duty = [spec.duty, APP_FILES_RULE, spec.subAgentOf === void 0 ? ROLE_CLOSING : void 0].filter((text2) => text2 !== void 0 && text2 !== "").join("\n\n");
|
|
10211
|
+
const text = spec === MAIN_AGENT ? () => `${mainDuty(this.roles.list())}
|
|
10212
|
+
|
|
10213
|
+
${APP_FILES_RULE}` : () => duty;
|
|
10201
10214
|
disposers.push(agent.ctx.systemPrompt.section({ name: "adg:role", order: 10095, interpolate: false, text }));
|
|
10202
10215
|
const views = this.memoryViews;
|
|
10203
10216
|
if (views !== void 0) {
|
|
@@ -10400,6 +10413,12 @@ Content-Length: 0
|
|
|
10400
10413
|
return;
|
|
10401
10414
|
}
|
|
10402
10415
|
}
|
|
10416
|
+
promptChild(request, signal) {
|
|
10417
|
+
const service = this.ctx.get("subagents");
|
|
10418
|
+
if (!service)
|
|
10419
|
+
throw new Error("\u539F\u751F\u5B50\u4EE3\u7406\u670D\u52A1\u672A\u52A0\u8F7D");
|
|
10420
|
+
return service.prompt(request, signal);
|
|
10421
|
+
}
|
|
10403
10422
|
/** App actions are addressed to an agent's home. dsh owns child membership, model selection, settlement and parent delivery. */
|
|
10404
10423
|
async runChild(owner, childId, title, instruction, signal, images = []) {
|
|
10405
10424
|
if (!this.homes.agentOf(owner))
|
|
@@ -10816,7 +10835,7 @@ ${instruction}` }],
|
|
|
10816
10835
|
workspaceDir() {
|
|
10817
10836
|
return this.workspace;
|
|
10818
10837
|
}
|
|
10819
|
-
/** The user turned on full access (设置 → 权限): no sandbox, no approvals, no guard. */
|
|
10838
|
+
/** The user turned on full access (设置 → 权限): no sandbox, no approvals, no guard on scripts (the app's own folders stay guarded). */
|
|
10820
10839
|
fullAccess() {
|
|
10821
10840
|
return this.permissions.mode === "full";
|
|
10822
10841
|
}
|