dsh-multigameassistant 2.2.3 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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-LXHF6AKU.js";
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 Regex = external_exports.string().min(1).refine((value) => {
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: Regex }).optional(),
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: Regex.optional() }),
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 Id = external_exports.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, "lowercase letters, digits and dashes");
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: 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
- }).refine((s) => [s.smw, s.sra, s.steam].filter((x) => x !== void 0).length <= 1, "smw\u3001sra \u548C steam \u53EA\u80FD\u5199\u4E00\u4E2A");
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: 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(Id).default([]),
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-KMVQK5CI.js";
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-LXHF6AKU.js";
47
+ } from "./chunk-7EFZ5KR6.js";
47
48
  import {
48
49
  external_exports
49
50
  } from "./chunk-6DSSLS7I.js";
@@ -10206,8 +10207,10 @@ Content-Length: 0
10206
10207
  this.log.warn(`tools of the ${spec.name} agent (${agent.session.id}): ${error instanceof Error ? error.message : String(error)}`);
10207
10208
  }
10208
10209
  try {
10209
- const duty = [spec.duty, spec.subAgentOf === void 0 ? ROLE_CLOSING : void 0].filter((text2) => text2 !== void 0 && text2 !== "").join("\n\n");
10210
- const text = spec === MAIN_AGENT ? () => mainDuty(this.roles.list()) : () => duty;
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;
10211
10214
  disposers.push(agent.ctx.systemPrompt.section({ name: "adg:role", order: 10095, interpolate: false, text }));
10212
10215
  const views = this.memoryViews;
10213
10216
  if (views !== void 0) {
@@ -10832,7 +10835,7 @@ ${instruction}` }],
10832
10835
  workspaceDir() {
10833
10836
  return this.workspace;
10834
10837
  }
10835
- /** 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). */
10836
10839
  fullAccess() {
10837
10840
  return this.permissions.mode === "full";
10838
10841
  }
@@ -1,7 +1,7 @@
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
2
  import {
3
3
  convertRecord
4
- } from "./chunk-6NJSSOB6.js";
4
+ } from "./chunk-VBWSM7LF.js";
5
5
  import {
6
6
  writeFileAtomic
7
7
  } from "./chunk-RESS7WVY.js";
@@ -20,7 +20,7 @@ import {
20
20
  threadMessage,
21
21
  threadReminder,
22
22
  threadsBetween
23
- } from "./chunk-LXHF6AKU.js";
23
+ } from "./chunk-7EFZ5KR6.js";
24
24
  import {
25
25
  external_exports
26
26
  } from "./chunk-6DSSLS7I.js";
@@ -2,13 +2,14 @@ import { createRequire as __adgCreateRequire } from 'node:module'; import { dirn
2
2
  import {
3
3
  globToRegExp,
4
4
  guideView,
5
+ launchCommand,
5
6
  renderTask,
6
7
  require_dist
7
- } from "./chunk-RGEGJH6R.js";
8
+ } from "./chunk-TXW3NMBH.js";
8
9
  import {
9
10
  RUNS_CAPABILITY,
10
11
  ScriptId
11
- } from "./chunk-LXHF6AKU.js";
12
+ } from "./chunk-7EFZ5KR6.js";
12
13
  import {
13
14
  external_exports
14
15
  } from "./chunk-6DSSLS7I.js";
@@ -1207,7 +1208,7 @@ import { copyFile as copyFile2, readdir as readdir3, readFile as readFile4, rena
1207
1208
  import { join as join5 } from "node:path";
1208
1209
  import { pipeline } from "node:stream/promises";
1209
1210
  import { promisify } from "node:util";
1210
- import { createGzip, gunzip } from "node:zlib";
1211
+ import { constants as zlib, createGzip, gunzip } from "node:zlib";
1211
1212
  var LOG_FILE = "log.jsonl";
1212
1213
  var PREV_LOG_FILE = "log.prev.jsonl";
1213
1214
  var PACKED_LOG_FILE = "log.jsonl.gz";
@@ -1305,7 +1306,7 @@ async function packLog(dir) {
1305
1306
  return true;
1306
1307
  }
1307
1308
  async function readRunLog(dir) {
1308
- const packed = await readFile4(join5(dir, PACKED_LOG_FILE)).then((bytes) => gunzipAsync(bytes), () => void 0);
1309
+ const packed = await readFile4(join5(dir, PACKED_LOG_FILE)).then((bytes) => gunzipAsync(bytes, { finishFlush: zlib.Z_SYNC_FLUSH }), () => void 0);
1309
1310
  const prev = await readFile4(join5(dir, PREV_LOG_FILE), "utf8").catch(() => void 0);
1310
1311
  const current = await readFile4(join5(dir, LOG_FILE), "utf8").catch(() => void 0);
1311
1312
  if (packed === void 0 && prev === void 0 && current === void 0)
@@ -1891,9 +1892,9 @@ var Runner = class {
1891
1892
  }
1892
1893
  const exe = inside(dir, rendered.exe);
1893
1894
  const cwd = rendered.cwd === void 0 ? dir : inside(dir, rendered.cwd);
1894
- const command = (this.#options.command ?? ((file, args) => ({ file, args })))(exe, rendered.args);
1895
+ const command = (this.#options.command ?? ((file, args) => launchCommand(file, args, process.platform, process.env["ComSpec"])))(exe, rendered.args);
1895
1896
  run.info.command = [exe, ...rendered.args];
1896
- const child = spawn2(command.file, [...command.args], { cwd, windowsHide: false, stdio: ["ignore", "pipe", "pipe"] });
1897
+ const child = spawn2(command.file, [...command.args], { cwd, windowsHide: false, stdio: ["ignore", "pipe", "pipe"], windowsVerbatimArguments: command.verbatim === true });
1897
1898
  run.child = child;
1898
1899
  await new Promise((resolve2, reject) => {
1899
1900
  child.once("spawn", () => resolve2());
@@ -2864,20 +2865,30 @@ function runnerTools(runner, config) {
2864
2865
  }),
2865
2866
  tool({
2866
2867
  name: TOOL_NAMES.gamePathSet,
2867
- description: "\u4FDD\u5B58\u67D0\u4E2A\u811A\u672C\u7684 PC \u6E38\u620F\u7A0B\u5E8F\u4F4D\u7F6E\uFF08\u8FD0\u884C\u524D\u7531\u672C\u5E94\u7528\u542F\u52A8\u6E38\u620F\u65F6\u7528\uFF09\u3002\u53EA\u5728\u627E\u5230\u5E76\u786E\u8BA4\u4E86\u7A0B\u5E8F\u540E\u8C03\u7528\uFF1B\u8DEF\u5F84\u5FC5\u987B\u662F\u5B58\u5728\u7684 .exe\u3002",
2868
- properties: { id, path: { type: "string", description: "\u6E38\u620F\u7A0B\u5E8F\u7684\u5B8C\u6574\u8DEF\u5F84\uFF0C\u4F8B\u5982 D:\\Games\\Endfield\\Endfield.exe\u3002" } },
2869
- required: ["id", "path"],
2868
+ description: "\u4FDD\u5B58\u67D0\u4E2A\u811A\u672C\u8981\u73A9\u7684\u6E38\u620F\u5728\u54EA\uFF1APC \u6E38\u620F\u7A0B\u5E8F\u7684\u4F4D\u7F6E\uFF08path\uFF09\uFF0C\u6216\u6A21\u62DF\u5668\u91CC\u7528\u6237\u88C5\u7684\u90A3\u4E2A\u7248\u672C\u7684\u5305\u540D\uFF08android_package\uFF0C\u4F8B\u5982 B\u670D com.hypergryph.arknights.bilibili\uFF1B\u7528 emulator_apps \u67E5\u5230\u7684\uFF09\u3002\u8FD0\u884C\u524D\u7531\u672C\u5E94\u7528\u542F\u52A8\u3001\u5173\u95ED\u6E38\u620F\u65F6\u7528\uFF0C\u6E38\u620F\u9875\u7684\u5934\u50CF\u4E5F\u7528\u5B83\u3002\u53EA\u5728\u627E\u5230\u5E76\u786E\u8BA4\u540E\u8C03\u7528\uFF1Bpath \u5FC5\u987B\u662F\u5B58\u5728\u7684 .exe\u3002",
2869
+ properties: {
2870
+ id,
2871
+ path: { type: "string", description: "\u6E38\u620F\u7A0B\u5E8F\u7684\u5B8C\u6574\u8DEF\u5F84\uFF0C\u4F8B\u5982 D:\\Games\\Endfield\\Endfield.exe\u3002" },
2872
+ android_package: { type: "string", description: "\u6A21\u62DF\u5668\u91CC\u8FD9\u4E2A\u6E38\u620F\u7684\u5305\u540D\uFF0C\u4F8B\u5982 com.hypergryph.arknights\u3002" }
2873
+ },
2874
+ required: ["id"],
2870
2875
  kind: "other",
2871
- title: (a) => `\u4FDD\u5B58\u6E38\u620F\u4F4D\u7F6E\uFF1A${String(a["path"] ?? "")}`,
2876
+ title: (a) => `\u4FDD\u5B58\u6E38\u620F\u4F4D\u7F6E\uFF1A${String(a["path"] ?? a["android_package"] ?? "")}`,
2872
2877
  execute: async (args) => {
2873
- const a = parse(external_exports.object({ id: ScriptId, path: external_exports.string().trim().min(1) }), args);
2878
+ const a = parse(external_exports.object({ id: ScriptId, path: external_exports.string().trim().min(1).optional(), android_package: external_exports.string().trim().regex(/^[A-Za-z][\w]*(\.[A-Za-z_][\w]*)+$/, "\u5B89\u5353\u5305\u540D\u50CF com.example.game").optional() }), args);
2879
+ if (a.path === void 0 && a.android_package === void 0)
2880
+ throw new Error("\u5199 path\uFF08PC \u6E38\u620F\u7A0B\u5E8F\uFF09\u6216 android_package\uFF08\u6A21\u62DF\u5668\u91CC\u7684\u5305\u540D\uFF09");
2881
+ if (a.path === void 0) {
2882
+ const settings2 = await runner.launch.set(a.id, { androidPackage: a.android_package });
2883
+ return { saved: settings2.androidPackage, note: "\u5DF2\u4FDD\u5B58\uFF0C\u4E0B\u6B21\u8FD0\u884C\u751F\u6548" };
2884
+ }
2874
2885
  const path = a.path.replace(/^"|"$/g, "");
2875
2886
  if (!isAbsolute2(path) || !/\.exe$/i.test(path))
2876
2887
  throw new Error("\u8981\u586B .exe \u7A0B\u5E8F\u7684\u5B8C\u6574\u8DEF\u5F84");
2877
2888
  if (!existsSync2(path) || !statSync(path).isFile())
2878
2889
  throw new Error(`\u627E\u4E0D\u5230 ${path}`);
2879
- const settings = await runner.launch.set(a.id, { pcExe: path });
2880
- return { saved: settings.pcExe, process: settings.pcProcess ?? basename4(path), note: "\u5DF2\u4FDD\u5B58\uFF0C\u4E0B\u6B21\u8FD0\u884C\u751F\u6548" };
2890
+ const settings = await runner.launch.set(a.id, { pcExe: path, ...a.android_package === void 0 ? {} : { androidPackage: a.android_package } });
2891
+ return { saved: settings.pcExe, process: settings.pcProcess ?? basename4(path), ...settings.androidPackage === void 0 ? {} : { android_package: settings.androidPackage }, note: "\u5DF2\u4FDD\u5B58\uFF0C\u4E0B\u6B21\u8FD0\u884C\u751F\u6548" };
2881
2892
  }
2882
2893
  })
2883
2894
  ];
@@ -4,7 +4,7 @@ import {
4
4
  LOW_CONTEXT_WINDOW_MS,
5
5
  MAX_ARCHIVE_DAYS,
6
6
  MIN_ARCHIVE_DAYS
7
- } from "./chunk-LXHF6AKU.js";
7
+ } from "./chunk-7EFZ5KR6.js";
8
8
 
9
9
  // packages/gateway/lib/low-context.js
10
10
  import { appendFile, mkdir, readFile, stat } from "node:fs/promises";