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.
@@ -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-DSWWQWQH.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";
@@ -136,6 +136,9 @@ function pastBetween(all, a, b, name) {
136
136
  var MAX_THREAD_MESSAGES = 10;
137
137
  var MAX_HOPS = 3;
138
138
  var MAX_CHAIN_MESSAGES = 30;
139
+ function failedReply(error) {
140
+ return { blocks: [], outcome: "failed", ended: error instanceof Error ? error.message : String(error) };
141
+ }
139
142
  function createHandOffDesk(deps) {
140
143
  const now = deps.now ?? Date.now;
141
144
  const live = /* @__PURE__ */ new Map();
@@ -149,9 +152,18 @@ function createHandOffDesk(deps) {
149
152
  chainTop(thread).said++;
150
153
  await save(thread, { ...patch, messages: [...thread.item.messages ?? [], { from, kind, text, at: now() }] });
151
154
  };
152
- const toWorker = (thread, message2) => {
153
- thread.turns.push(deps.converse(thread.item.toSession, message2, thread.signal, [], { insert: true }));
155
+ const deliver = (session, message2, signal, parentSessionId) => {
156
+ const receipt = Promise.withResolvers();
157
+ const reply = deps.converse(session, message2, signal, [], { insert: true, parentSessionId, onAccepted: receipt.resolve });
158
+ void reply.then(() => receipt.resolve(), receipt.reject);
159
+ return { accepted: receipt.promise, reply };
160
+ };
161
+ const toWorker = (thread, message2, record) => {
162
+ const { accepted, reply } = deliver(thread.item.toSession, message2, thread.signal, thread.item.ownerSession);
163
+ const recorded = accepted.then(record);
164
+ thread.turns.push(recorded.then(() => reply, () => ({ blocks: [] })).catch(failedReply));
154
165
  thread.wake();
166
+ return recorded;
155
167
  };
156
168
  const askerKind = (agent) => agent === void 0 || agent === MAIN ? "main" : "lead";
157
169
  const late = async ({ thread: id, fromSession, from, kind, text }) => {
@@ -170,29 +182,39 @@ function createHandOffDesk(deps) {
170
182
  if (worker && askerNow === "")
171
183
  throw new Error(`\u8FD9\u4EF6\u4E8B\u662F${item.by}\u4EA4\u7684\uFF0C\u6CA1\u6709\u4EBA\u5728\u7B49\u6D88\u606F\uFF1A\u8981\u544A\u8BC9\u8C01\u5C31\u91CD\u65B0\u4EA4\u7ED9\u5B83`);
172
184
  const said = kind === "done" && (!worker || item.state !== "failed") ? "update" : kind;
173
- await deps.record({ ...item, messages: [...item.messages ?? [], { from, kind: said, text, at: now() }] });
174
185
  const message2 = threadMessage({ from, kind: said === "done" ? "update" : said, thread: id, title: item.title, text: said === "done" ? `\u8865\u4EA4\u7ED3\u8BBA\uFF1A${text}` : text, reader: worker ? askerKind(askerAgent) : "worker", closed: true });
175
186
  const recipient = worker ? askerNow : workerNow;
176
- void deps.converse(recipient, message2, AbortSignal.timeout(RELAY_TIMEOUT_MS), [], { insert: true }).catch(() => {
177
- });
187
+ await deliver(recipient, message2, AbortSignal.timeout(RELAY_TIMEOUT_MS), workingOn(recipient)?.item.ownerSession).accepted;
188
+ const latest = deps.threads?.().find((h) => h.id === id) ?? item;
189
+ await deps.record({ ...latest, messages: [...latest.messages ?? [], { from, kind: said, text, at: now() }] });
178
190
  return "\u5DF2\u7ECF\u9001\u5230\u5BF9\u65B9\u90A3\u91CC\u4E86\u3002";
179
191
  };
180
192
  const toAsker = (thread, message2, asked) => {
181
- void deps.converse(thread.item.fromSession, message2, AbortSignal.any([thread.signal, AbortSignal.timeout(RELAY_TIMEOUT_MS)]), [], { insert: true }).then((answer) => {
193
+ const session = thread.item.fromSession;
194
+ const { reply, accepted } = deliver(session, message2, AbortSignal.any([thread.signal, AbortSignal.timeout(RELAY_TIMEOUT_MS)]), workingOn(session)?.item.ownerSession);
195
+ void reply.then((answer) => {
182
196
  if (!asked || !thread.awaiting || thread.deferred || !live.has(thread.item.id))
183
197
  return;
184
198
  const said = finalText(answer).trim();
185
- void answered(thread, thread.item.by, said === "" || isQuiet(said) ? "\uFF08\u5B83\u6CA1\u6709\u56DE\u7B54\uFF1A\u6309\u4F60\u81EA\u5DF1\u7684\u5224\u65AD\u63A5\u7740\u505A\u3002\uFF09" : said);
199
+ return answered(thread, thread.item.by, said === "" || isQuiet(said) ? "\uFF08\u5B83\u6CA1\u6709\u56DE\u7B54\uFF1A\u6309\u4F60\u81EA\u5DF1\u7684\u5224\u65AD\u63A5\u7740\u505A\u3002\uFF09" : said);
186
200
  }, () => {
187
201
  if (asked && thread.awaiting && live.has(thread.item.id))
188
- void answered(thread, thread.item.by, "\uFF08\u6CA1\u6709\u7B49\u5230\u56DE\u7B54\uFF1A\u6309\u4F60\u81EA\u5DF1\u7684\u5224\u65AD\u63A5\u7740\u505A\u3002\uFF09");
202
+ return answered(thread, thread.item.by, "\uFF08\u6CA1\u6709\u7B49\u5230\u56DE\u7B54\uFF1A\u6309\u4F60\u81EA\u5DF1\u7684\u5224\u65AD\u63A5\u7740\u505A\u3002\uFF09");
203
+ }).catch((error) => {
204
+ if (!thread.awaiting || !live.has(thread.item.id))
205
+ return;
206
+ thread.awaiting = false;
207
+ thread.turns.push(Promise.resolve(failedReply(error)));
208
+ thread.wake();
189
209
  });
210
+ return accepted;
190
211
  };
191
212
  const answered = async (thread, from, text) => {
192
- thread.awaiting = false;
193
- thread.deferred = false;
194
- toWorker(thread, threadMessage({ from, kind: "answer", thread: thread.item.id, title: thread.item.title, text }));
195
- await say(thread, from, "answer", text, { state: "running" });
213
+ await toWorker(thread, threadMessage({ from, kind: "answer", thread: thread.item.id, title: thread.item.title, text }), () => {
214
+ thread.awaiting = false;
215
+ thread.deferred = false;
216
+ return say(thread, from, "answer", text, { state: "running" });
217
+ });
196
218
  };
197
219
  return {
198
220
  refusal(fromSession, to, fromAgent, toName = to) {
@@ -248,15 +270,16 @@ function createHandOffDesk(deps) {
248
270
  return "\u7ED3\u8BBA\u5DF2\u7ECF\u4EA4\u56DE\u53BB\u4E86\u3002\u8FD9\u4E00\u8F6E\u53EF\u4EE5\u7ED3\u675F\u4E86\u3002";
249
271
  case "update":
250
272
  if (!worker) {
251
- thread.deferred = true;
252
- await say(thread, from, "update", text);
253
- toWorker(thread, threadMessage({ from, kind, thread: id, title: thread.item.title, text }));
273
+ await toWorker(thread, threadMessage({ from, kind, thread: id, title: thread.item.title, text }), () => {
274
+ thread.deferred = true;
275
+ return say(thread, from, "update", text);
276
+ });
254
277
  return "\u5DF2\u7ECF\u544A\u8BC9\u5B83\u4E86\u3002\u6709\u7ED3\u679C\u8981\u56DE\u7B54\u5B83\u7684\u8BDD\uFF0C\u7528 kind: answer\u3002";
255
278
  }
256
279
  await say(thread, from, "update", text);
257
280
  if (thread.item.fromSession === "")
258
281
  return "\u8BB0\u4E0B\u4E86\u3002\u63A5\u7740\u505A\u3002";
259
- toAsker(thread, threadMessage({ from, kind, thread: id, title: thread.item.title, text, reader: askerKind(thread.input.from?.agent) }), false);
282
+ await toAsker(thread, threadMessage({ from, kind, thread: id, title: thread.item.title, text, reader: askerKind(thread.input.from?.agent) }), false);
260
283
  return "\u5DF2\u7ECF\u9001\u5230\u5BF9\u65B9\u90A3\u91CC\u4E86\u3002\u63A5\u7740\u505A\u3002";
261
284
  case "question":
262
285
  if (worker) {
@@ -264,11 +287,10 @@ function createHandOffDesk(deps) {
264
287
  throw new Error(`\u8FD9\u4EF6\u4E8B\u662F${asker}\u4EA4\u7684\uFF0C\u6CA1\u6709\u4EBA\u7B49\u7740\u56DE\u7B54\uFF1A\u6309\u4F60\u81EA\u5DF1\u7684\u5224\u65AD\u505A\uFF0C\u628A\u8981\u95EE\u7684\u5199\u8FDB\u7ED3\u8BBA`);
265
288
  thread.awaiting = true;
266
289
  await say(thread, from, "question", text, { state: "waiting" });
267
- toAsker(thread, threadMessage({ from, kind, thread: id, title: thread.item.title, text }), true);
290
+ await toAsker(thread, threadMessage({ from, kind, thread: id, title: thread.item.title, text }), true);
268
291
  return `\u5DF2\u7ECF\u95EE\u4E86${asker}\u3002\u5B83\u56DE\u7B54\u540E\u4F1A\u4F5C\u4E3A\u4E00\u6761\u65B0\u6D88\u606F\u53D1\u5230\u8FD9\u91CC\uFF1A\u73B0\u5728\u7ED3\u675F\u8FD9\u4E00\u8F6E\uFF0C\u4E0D\u8981\u66FF\u5B83\u56DE\u7B54\u3002`;
269
292
  }
270
- toWorker(thread, threadMessage({ from, kind, thread: id, title: thread.item.title, text }));
271
- await say(thread, from, "question", text);
293
+ await toWorker(thread, threadMessage({ from, kind, thread: id, title: thread.item.title, text }), () => say(thread, from, "question", text));
272
294
  return `\u5DF2\u7ECF\u95EE\u4E86\u300C${thread.item.to}\u300D\u3002\u5B83\u56DE\u7B54\u540E\u4F1A\u4F5C\u4E3A\u4E00\u6761\u65B0\u6D88\u606F\u53D1\u5230\u8FD9\u91CC\uFF1A\u73B0\u5728\u7ED3\u675F\u8FD9\u4E00\u8F6E\u3002`;
273
295
  case "answer":
274
296
  if (!worker) {
@@ -276,7 +298,7 @@ function createHandOffDesk(deps) {
276
298
  return "\u5DF2\u7ECF\u56DE\u7B54\u4E86\u3002\u73B0\u5728\u7ED3\u675F\u8FD9\u4E00\u8F6E\u3002";
277
299
  }
278
300
  await say(thread, from, "answer", text);
279
- toAsker(thread, threadMessage({ from, kind, thread: id, title: thread.item.title, text, reader: askerKind(thread.input.from?.agent) }), false);
301
+ await toAsker(thread, threadMessage({ from, kind, thread: id, title: thread.item.title, text, reader: askerKind(thread.input.from?.agent) }), false);
280
302
  return "\u5DF2\u7ECF\u56DE\u7B54\u4E86\u3002\u63A5\u7740\u505A\u3002";
281
303
  }
282
304
  },
@@ -399,7 +421,7 @@ function createHandOffDesk(deps) {
399
421
  ...thread.consulted.size === 0 ? {} : { consulted: [...thread.consulted] },
400
422
  ...input.from?.agent === void 0 || input.from.agent === MAIN ? {} : { toLead: true }
401
423
  });
402
- const back = deps.converse(fromSession, message2, AbortSignal.timeout(RELAY_TIMEOUT_MS));
424
+ const back = deps.converse(fromSession, message2, AbortSignal.timeout(RELAY_TIMEOUT_MS), [], { parentSessionId: parent?.item.ownerSession });
403
425
  if (parent !== void 0 && live.has(parent.item.id))
404
426
  parent.turns.push(back.catch(() => ({ blocks: [] })));
405
427
  void back.then((answer) => input.relayed?.(answer), () => {
@@ -426,44 +448,65 @@ function sessionConversations(sessions, _cwd = () => void 0, focus, app) {
426
448
  const converse = async (sessionId, text, signal, images = [], options = {}) => {
427
449
  signal.throwIfAborted();
428
450
  const controller = new AbortController();
451
+ const observing = AbortSignal.any([signal, controller.signal]);
429
452
  const requestId = `notify-${crypto.randomUUID()}`;
430
453
  const turn = { started: false };
431
- let stopping;
432
- const abort = () => {
433
- controller.abort(signal.reason);
434
- stopping = Promise.resolve().then(async () => {
435
- if (turn.started || options.isolated) {
436
- try {
437
- await sessions.cancel?.({ sessionId });
438
- } finally {
439
- app?.()?.stopSubAgents?.(sessionId);
440
- }
441
- if (!turn.started)
442
- await unqueue(sessions, sessionId, requestId);
443
- } else
444
- await unqueue(sessions, sessionId, requestId);
445
- }).catch(() => {
446
- });
454
+ let parent = options.parentSessionId;
455
+ let childMessageId;
456
+ let iterator;
457
+ const cancel = async () => {
458
+ if (parent !== void 0) {
459
+ if (turn.started || options.isolated)
460
+ app?.()?.stopSubAgent(sessionId);
461
+ else if (childMessageId !== void 0) {
462
+ await sessions.updateQueue?.({ sessionId, itemId: childMessageId, action: { kind: "remove" } });
463
+ }
464
+ return;
465
+ }
466
+ if (turn.started || options.isolated) {
467
+ try {
468
+ await sessions.cancel?.({ sessionId });
469
+ } finally {
470
+ app?.()?.stopSubAgents?.(sessionId);
471
+ }
472
+ }
473
+ if (!turn.started)
474
+ await unqueue(sessions, sessionId, requestId);
447
475
  };
448
- signal.addEventListener("abort", abort, { once: true });
449
476
  try {
450
- const iterator = sessions.follow({ address: { kind: "session", sessionId }, assistantStream: true, maxMessages: 1 }, controller.signal)[Symbol.asyncIterator]();
477
+ const summary = parent === void 0 ? (await sessions.list({}, observing)).items.find((s) => s.sessionId === sessionId) : void 0;
478
+ if (summary?.origin === "subagent") {
479
+ parent = summary.parentSessionId;
480
+ if (parent === void 0)
481
+ throw new Error("\u5B50\u4EFB\u52A1\u7F3A\u5C11\u6240\u5C5E\u4F1A\u8BDD\uFF0C\u65E0\u6CD5\u6295\u9012\u6D88\u606F");
482
+ }
483
+ const id = sessionId;
484
+ const address = parent === void 0 ? { kind: "session", sessionId: id } : { kind: "subagent", parentSessionId: parent, childSessionId: id, mode: "unknown" };
485
+ iterator = sessions.follow({ address, assistantStream: true, maxMessages: 1 }, observing)[Symbol.asyncIterator]();
451
486
  const first = await iterator.next();
452
487
  if (first.done === true)
453
488
  throw new Error("\u4F1A\u8BDD\u6CA1\u6709\u6253\u5F00");
454
- await sessions.prompt({
489
+ const prompt = {
455
490
  requestId,
456
- sessionId,
457
- mode: options.insert === true && await running(sessions, sessionId, controller.signal) ? "steer" : "queue",
458
491
  content: [{ type: "text", text }, ...images.map((png) => ({ type: "image", mediaType: "image/png", data: png.toString("base64") }))],
459
492
  clientTimeZone: Intl.DateTimeFormat().resolvedOptions().timeZone
460
- }, controller.signal);
493
+ };
494
+ if (parent !== void 0) {
495
+ const receipt = await gateway().promptChild({ ...prompt, childSessionId: id, delivery: options.insert ? "steer" : "queue" }, observing);
496
+ childMessageId = receipt.messageId;
497
+ } else {
498
+ await sessions.prompt({ ...prompt, sessionId: id, mode: options.insert && summary?.running ? "steer" : "queue" }, observing);
499
+ }
500
+ signal.throwIfAborted();
501
+ options.onAccepted?.();
461
502
  const settled = app?.()?.settled;
462
- return await workReply(iterator, requestId, text, turn, settled === void 0 ? void 0 : () => settled.call(app(), sessionId, controller.signal), options.onWorkerReport);
503
+ return await workReply(iterator, requestId, text, turn, settled === void 0 ? void 0 : () => settled.call(app(), sessionId, observing), options.onWorkerReport);
463
504
  } finally {
464
- signal.removeEventListener("abort", abort);
465
505
  controller.abort();
466
- await stopping;
506
+ if (signal.aborted && iterator !== void 0)
507
+ await cancel().catch(() => {
508
+ });
509
+ await iterator?.return?.();
467
510
  }
468
511
  };
469
512
  const gateway = () => {
@@ -525,10 +568,6 @@ function sessionConversations(sessions, _cwd = () => void 0, focus, app) {
525
568
  converse
526
569
  };
527
570
  }
528
- async function running(sessions, sessionId, signal) {
529
- const { items } = await sessions.list({}, signal);
530
- return items.find((s) => s.sessionId === sessionId)?.running === true;
531
- }
532
571
  async function unqueue(sessions, sessionId, requestId) {
533
572
  if (sessions.updateQueue === void 0)
534
573
  return;
@@ -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";