dsh-multigameassistant 2.0.5 → 2.1.1

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.
Files changed (37) hide show
  1. package/cordis.patch.yml +178 -4
  2. package/lib/analyzer.js +6 -4
  3. package/lib/browser.js +279 -0
  4. package/lib/{chunk-KHO3SRUJ.js → chunk-5PDYWE24.js} +4 -2
  5. package/lib/{chunk-YG4B5G7F.js → chunk-B4UT4NYH.js} +1 -0
  6. package/lib/{chunk-IOBYH4RN.js → chunk-FBDVN6Q2.js} +76 -1
  7. package/lib/{chunk-TD4YFQWE.js → chunk-MQG5FLOG.js} +629 -167
  8. package/lib/chunk-NM6H6WCQ.js +3753 -0
  9. package/lib/chunk-RESS7WVY.js +157 -0
  10. package/lib/{chunk-BTT2GBTQ.js → chunk-SHTX4AGU.js} +1 -3670
  11. package/lib/{chunk-4Q4EH73S.js → chunk-UQLHGLMP.js} +13 -9
  12. package/lib/{chunk-PAJOD6LV.js → chunk-VOTN4IHB.js} +384 -54
  13. package/lib/emulator.js +6 -4
  14. package/lib/feishu.js +8 -6
  15. package/lib/game-intel.js +90 -9
  16. package/lib/gateway.js +11 -6
  17. package/lib/guard.js +5 -3
  18. package/lib/intervene.js +62 -18
  19. package/lib/low-context.js +13 -2
  20. package/lib/monitor.js +90 -10
  21. package/lib/notify.js +6 -5
  22. package/lib/orchestrator.js +14 -10
  23. package/lib/qqbot.js +8 -6
  24. package/lib/runner.js +18 -5
  25. package/lib/scheduler.js +4 -2
  26. package/lib/script-registry.js +345 -216
  27. package/package.json +5 -4
  28. package/skills/pipeline-planning.md +1 -1
  29. package/skills/web-reading.md +2 -0
  30. package/web/assets/index-CL3SeTW9.css +1 -0
  31. package/web/assets/index-GYwpGP3f.js +244 -0
  32. package/web/assets/index-GYwpGP3f.js.map +1 -0
  33. package/web/index.html +2 -2
  34. package/lib/chunk-CCAB6XXZ.js +0 -34
  35. package/web/assets/index-BuStplKb.js +0 -242
  36. package/web/assets/index-BuStplKb.js.map +0 -1
  37. package/web/assets/index-CSB3B28L.css +0 -1
package/lib/monitor.js CHANGED
@@ -1,23 +1,27 @@
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
  parseDuration
4
- } from "./chunk-PAJOD6LV.js";
5
- import "./chunk-KHO3SRUJ.js";
4
+ } from "./chunk-VOTN4IHB.js";
5
+ import "./chunk-5PDYWE24.js";
6
6
  import {
7
7
  writeFileAtomic
8
- } from "./chunk-CCAB6XXZ.js";
8
+ } from "./chunk-RESS7WVY.js";
9
9
  import {
10
10
  Incident,
11
11
  MONITOR_CAPABILITY,
12
- MonitorSettings,
12
+ MonitorSettings
13
+ } from "./chunk-NM6H6WCQ.js";
14
+ import {
13
15
  external_exports
14
- } from "./chunk-BTT2GBTQ.js";
16
+ } from "./chunk-SHTX4AGU.js";
15
17
  import "./chunk-2UFLGPDY.js";
16
18
 
17
19
  // packages/monitor/lib/index.js
18
20
  import { Service } from "@deepseek-ai/cordis";
19
21
 
20
22
  // packages/monitor/lib/monitor.js
23
+ var KEEP_SCREENSHOTS_MS = 7 * 864e5;
24
+ var TIDY_SCREENSHOTS_EVERY_MS = 24 * 60 * 6e4;
21
25
  var DEFAULT_STALL_SECONDS = 60;
22
26
  var OLD_DEFAULT_STALL_SECONDS = 30;
23
27
  var STALL_HEADROOM = 1.5;
@@ -45,6 +49,9 @@ var Monitor = class {
45
49
  /** Serializes work per run so recovery steps never interleave. */
46
50
  #queues = /* @__PURE__ */ new Map();
47
51
  #seq = 0;
52
+ /** When screenshots were last tidied (tick does it once a day). */
53
+ #shotsTidiedAt = 0;
54
+ #tidyingShots;
48
55
  constructor(deps) {
49
56
  this.#deps = deps;
50
57
  this.#now = deps.now ?? Date.now;
@@ -61,6 +68,49 @@ var Monitor = class {
61
68
  this.#unwatch = this.#deps.runner.watch({ state: (run) => this.#onState(run), line: (run, line) => this.#onLine(run, line) });
62
69
  if (tickMs > 0)
63
70
  this.#timer = setInterval(() => this.tick(), tickMs);
71
+ void this.#tidyInBackground();
72
+ }
73
+ /**
74
+ * Delete screenshots past {@link KEEP_SCREENSHOTS_MS} and those of
75
+ * incidents no longer kept; incidents whose screenshot is gone say so
76
+ * (`screenshot: false`). A call while a pass is going waits for that one.
77
+ * @returns how many were deleted.
78
+ */
79
+ tidyScreenshots() {
80
+ this.#tidyingShots ??= this.#tidyScreenshots().finally(() => {
81
+ this.#tidyingShots = void 0;
82
+ });
83
+ return this.#tidyingShots;
84
+ }
85
+ async #tidyScreenshots() {
86
+ const store = this.#deps.store;
87
+ if (store.screenshots === void 0 || store.removeScreenshot === void 0)
88
+ return 0;
89
+ this.#shotsTidiedAt = this.#now();
90
+ const byId = new Map(this.#incidents.map((i) => [i.id, i]));
91
+ const present = /* @__PURE__ */ new Set();
92
+ let removed = 0;
93
+ for (const shot of await store.screenshots()) {
94
+ if (byId.has(shot.id) && this.#now() - shot.at < KEEP_SCREENSHOTS_MS) {
95
+ present.add(shot.id);
96
+ continue;
97
+ }
98
+ await store.removeScreenshot(shot.id).then(() => {
99
+ removed++;
100
+ }, (error) => this.#deps.log.warn(`deleting the screenshot of ${shot.id} failed: ${message(error)}`));
101
+ }
102
+ const gone = this.#incidents.filter((i) => i.screenshot && !present.has(i.id) && this.#now() - i.createdAt > 6e4);
103
+ for (const incident of gone)
104
+ incident.screenshot = false;
105
+ if (gone.length > 0)
106
+ await store.saveIncidents(this.#incidents).catch((error) => this.#deps.log.warn(`saving incidents failed: ${message(error)}`));
107
+ if (removed > 0)
108
+ this.#deps.log.info(`deleted ${removed} incident screenshot(s) older than ${KEEP_SCREENSHOTS_MS / 864e5} days or of incidents no longer kept`);
109
+ return removed;
110
+ }
111
+ #tidyInBackground() {
112
+ return this.tidyScreenshots().then(() => {
113
+ }, (error) => this.#deps.log.warn(`tidying incident screenshots failed: ${message(error)}`));
64
114
  }
65
115
  stop() {
66
116
  clearInterval(this.#timer);
@@ -202,20 +252,28 @@ var Monitor = class {
202
252
  /** Check every running run for stalls and overtime. */
203
253
  tick() {
204
254
  const now = this.#now();
255
+ if (now - this.#shotsTidiedAt >= TIDY_SCREENSHOTS_EVERY_MS) {
256
+ this.#shotsTidiedAt = now;
257
+ void this.#tidyInBackground();
258
+ }
205
259
  for (const watched of this.#watched.values()) {
206
260
  const { run } = watched;
207
261
  if (run.endedAt !== void 0 || run.state !== "running")
208
262
  continue;
209
263
  const manifest = this.#deps.packOf(run.scriptId)?.manifest;
210
264
  const stall = this.stallFor(run.scriptId);
265
+ const held = this.#held(run.id);
266
+ if (held.now)
267
+ continue;
211
268
  const stallMs = stall.seconds > 0 && (watched.sawScriptLine || stall.source !== "default") ? stall.seconds * 1e3 : void 0;
212
- if (stallMs !== void 0 && watched.stalled === void 0 && now - watched.lastScriptLineAt > stallMs) {
213
- const text = `\u5DF2\u7ECF ${quiet(now - watched.lastScriptLineAt)}\u6CA1\u6709\u65B0\u7684\u65E5\u5FD7\uFF0C\u53EF\u80FD\u5361\u4F4F\u4E86\uFF08\u8FD9\u4E2A\u811A\u672C\u8D85\u8FC7 ${quiet(stallMs)}\u6CA1\u52A8\u9759\u5C31\u7B97\u5361\u4F4F${stall.source === "default" ? "\uFF0C\u9ED8\u8BA4\u503C" : ""}\uFF09`;
269
+ const quietMs = now - watched.lastScriptLineAt - (held.ms - watched.heldAtLine);
270
+ if (stallMs !== void 0 && watched.stalled === void 0 && quietMs > stallMs) {
271
+ const text = `\u5DF2\u7ECF ${quiet(quietMs)}\u6CA1\u6709\u65B0\u7684\u65E5\u5FD7\uFF0C\u53EF\u80FD\u5361\u4F4F\u4E86\uFF08\u8FD9\u4E2A\u811A\u672C\u8D85\u8FC7 ${quiet(stallMs)}\u6CA1\u52A8\u9759\u5C31\u7B97\u5361\u4F4F${stall.source === "default" ? "\uFF0C\u9ED8\u8BA4\u503C" : ""}\uFF09`;
214
272
  this.#deps.runner.warn(run.id, text);
215
273
  watched.stalled = this.#raise(run, "stalled", "stalled", text).id;
216
274
  }
217
275
  const expected = parseDuration(manifest?.tasks.find((t) => t.id === run.taskId)?.expectedDuration);
218
- if (expected !== void 0 && !watched.overtime && now - run.startedAt > expected * 2) {
276
+ if (expected !== void 0 && !watched.overtime && now - run.startedAt - held.ms > expected * 2) {
219
277
  watched.overtime = true;
220
278
  const text = `\u5DF2\u8FD0\u884C\u8D85\u8FC7\u9884\u8BA1\u65F6\u957F\u7684 2 \u500D\uFF08\u9884\u8BA1 ${manifest?.tasks.find((t) => t.id === run.taskId)?.expectedDuration}\uFF09`;
221
279
  this.#deps.runner.warn(run.id, text);
@@ -223,13 +281,17 @@ var Monitor = class {
223
281
  }
224
282
  }
225
283
  }
284
+ /** How long an intervention has held this run paused (InterventionPort.heldPaused). */
285
+ #held(runId) {
286
+ return this.#deps.intervene?.()?.heldPaused?.(runId) ?? { ms: 0, now: false };
287
+ }
226
288
  // ── runner feed ───────────────────────────────────────────────────────
227
289
  #track(run) {
228
290
  let watched = this.#watched.get(run.id);
229
291
  if (watched === void 0) {
230
292
  const chain = run.retryOf === void 0 ? run.id : this.#chains.get(run.retryOf) ?? run.retryOf;
231
293
  this.#chains.set(run.id, chain);
232
- watched = { run, chain, lastScriptLineAt: this.#now(), sawScriptLine: false, overtime: false, longestQuietMs: 0, troubled: false };
294
+ watched = { run, chain, lastScriptLineAt: this.#now(), heldAtLine: this.#held(run.id).ms, sawScriptLine: false, overtime: false, longestQuietMs: 0, troubled: false };
233
295
  this.#watched.set(run.id, watched);
234
296
  }
235
297
  watched.run = run;
@@ -243,6 +305,7 @@ var Monitor = class {
243
305
  if (watched.sawScriptLine)
244
306
  watched.longestQuietMs = Math.max(watched.longestQuietMs, line.at - watched.lastScriptLineAt);
245
307
  watched.lastScriptLineAt = line.at;
308
+ watched.heldAtLine = this.#held(run.id).ms;
246
309
  watched.sawScriptLine = true;
247
310
  if (watched.stalled !== void 0) {
248
311
  const stalled = this.#incidents.find((i) => i.id === watched.stalled);
@@ -655,7 +718,7 @@ function explain(stderr, fallback) {
655
718
  }
656
719
 
657
720
  // packages/monitor/lib/store.js
658
- import { mkdir, readFile as readFile2, writeFile } from "node:fs/promises";
721
+ import { mkdir, readdir, readFile as readFile2, rm as rm2, stat, writeFile } from "node:fs/promises";
659
722
  import { join as join2 } from "node:path";
660
723
  var FileIncidentStore = class {
661
724
  dir;
@@ -685,6 +748,23 @@ var FileIncidentStore = class {
685
748
  readScreenshot(incidentId) {
686
749
  return readFile2(join2(this.dir, "shots", `${safe(incidentId)}.png`)).catch(() => void 0);
687
750
  }
751
+ /** Incident ids are word characters and dashes, so a file name is its incident's id. */
752
+ async screenshots() {
753
+ const dir = join2(this.dir, "shots");
754
+ const names = await readdir(dir).catch(() => []);
755
+ const out = [];
756
+ for (const name of names) {
757
+ if (!name.toLowerCase().endsWith(".png"))
758
+ continue;
759
+ const at = await stat(join2(dir, name)).then((s) => s.mtimeMs, () => void 0);
760
+ if (at !== void 0)
761
+ out.push({ id: name.slice(0, -".png".length), at });
762
+ }
763
+ return out;
764
+ }
765
+ async removeScreenshot(incidentId) {
766
+ await rm2(join2(this.dir, "shots", `${safe(incidentId)}.png`), { force: true });
767
+ }
688
768
  async write(name, text) {
689
769
  await writeFileAtomic(join2(this.dir, name), text);
690
770
  }
package/lib/notify.js CHANGED
@@ -16,11 +16,12 @@ import {
16
16
  replyPlain,
17
17
  sessionConversations,
18
18
  textReply
19
- } from "./chunk-4Q4EH73S.js";
20
- import "./chunk-TD4YFQWE.js";
21
- import "./chunk-IOBYH4RN.js";
22
- import "./chunk-CCAB6XXZ.js";
23
- import "./chunk-BTT2GBTQ.js";
19
+ } from "./chunk-UQLHGLMP.js";
20
+ import "./chunk-MQG5FLOG.js";
21
+ import "./chunk-FBDVN6Q2.js";
22
+ import "./chunk-RESS7WVY.js";
23
+ import "./chunk-NM6H6WCQ.js";
24
+ import "./chunk-SHTX4AGU.js";
24
25
  import "./chunk-2UFLGPDY.js";
25
26
  export {
26
27
  AdgNotify,
@@ -4,21 +4,21 @@ import {
4
4
  PARAMS_SCHEMA,
5
5
  parseDuration,
6
6
  taskParams
7
- } from "./chunk-PAJOD6LV.js";
7
+ } from "./chunk-VOTN4IHB.js";
8
8
  import {
9
9
  TaskInputError,
10
10
  renderTask
11
- } from "./chunk-KHO3SRUJ.js";
11
+ } from "./chunk-5PDYWE24.js";
12
12
  import {
13
13
  MAIN,
14
14
  finalText,
15
15
  sessionConversations
16
- } from "./chunk-4Q4EH73S.js";
17
- import "./chunk-TD4YFQWE.js";
18
- import "./chunk-IOBYH4RN.js";
16
+ } from "./chunk-UQLHGLMP.js";
17
+ import "./chunk-MQG5FLOG.js";
18
+ import "./chunk-FBDVN6Q2.js";
19
19
  import {
20
20
  writeFileAtomic
21
- } from "./chunk-CCAB6XXZ.js";
21
+ } from "./chunk-RESS7WVY.js";
22
22
  import {
23
23
  AgentTask,
24
24
  AgentTaskId,
@@ -30,11 +30,13 @@ import {
30
30
  PipelineRun,
31
31
  PowerAction,
32
32
  expandSlash,
33
- external_exports,
34
33
  isMarker,
35
34
  taskMessage,
36
35
  withStartEnd
37
- } from "./chunk-BTT2GBTQ.js";
36
+ } from "./chunk-NM6H6WCQ.js";
37
+ import {
38
+ external_exports
39
+ } from "./chunk-SHTX4AGU.js";
38
40
  import "./chunk-2UFLGPDY.js";
39
41
 
40
42
  // packages/orchestrator/lib/index.js
@@ -480,10 +482,12 @@ var Engine = class {
480
482
  switch (node.kind) {
481
483
  case "script-task": {
482
484
  let current = await this.#deps.runner.start(node.scriptId, node.taskId, node.params, { profile: node.profile, signal });
485
+ if (current.endedAt !== void 0 && current.state === "failed") {
486
+ this.#addRun(active, node.id, current);
487
+ return { ok: false, detail: current.outcome ?? "\u6CA1\u6709\u542F\u52A8" };
488
+ }
483
489
  for (; ; ) {
484
490
  this.#addRun(active, node.id, current);
485
- if (current.endedAt !== void 0 && current.state === "failed")
486
- return { ok: false, detail: current.outcome ?? "\u6CA1\u6709\u542F\u52A8" };
487
491
  const ended = await this.#deps.runner.finished(current.id);
488
492
  if (this.#deps.runner.held?.(current.id) === true)
489
493
  this.#set(active, node.id, { detail: "\u8FD0\u884C\u51FA\u4E86\u95EE\u9898\uFF0C\u6B63\u5728\u5904\u7406\uFF1A\u5904\u7406\u597D\u3001\u91CD\u65B0\u8DD1\u6210\u529F\uFF0C\u6216\u4F60\u9009\u300C\u91CD\u8BD5\u300D\u300C\u5FFD\u7565\u300D\u4E4B\u540E\u518D\u5F80\u4E0B\u8D70" });
package/lib/qqbot.js CHANGED
@@ -4,19 +4,21 @@ import {
4
4
  questionText,
5
5
  replyMarkdown,
6
6
  replyPlain
7
- } from "./chunk-4Q4EH73S.js";
8
- import "./chunk-TD4YFQWE.js";
9
- import "./chunk-IOBYH4RN.js";
7
+ } from "./chunk-UQLHGLMP.js";
8
+ import "./chunk-MQG5FLOG.js";
9
+ import "./chunk-FBDVN6Q2.js";
10
10
  import {
11
11
  writeFileAtomic
12
- } from "./chunk-CCAB6XXZ.js";
12
+ } from "./chunk-RESS7WVY.js";
13
13
  import {
14
14
  QQBOT_CAPABILITY,
15
15
  QQBOT_SECRET_REF,
16
16
  QQPending,
17
- QQSettings,
17
+ QQSettings
18
+ } from "./chunk-NM6H6WCQ.js";
19
+ import {
18
20
  external_exports
19
- } from "./chunk-BTT2GBTQ.js";
21
+ } from "./chunk-SHTX4AGU.js";
20
22
  import "./chunk-2UFLGPDY.js";
21
23
 
22
24
  // packages/qqbot/lib/index.js
package/lib/runner.js CHANGED
@@ -3,10 +3,14 @@ import {
3
3
  AdgRunner,
4
4
  BusyError,
5
5
  ConfigProfiles,
6
+ KEEP_DAYS,
7
+ LIVE_LOG_MAX,
6
8
  LogTail,
9
+ PACK_AFTER_MS,
7
10
  PARAMS_SCHEMA,
8
11
  ResourceLocks,
9
12
  Runner,
13
+ SCRIPT_LOG_BUDGET,
10
14
  TOOL_NAMES,
11
15
  applyPatches,
12
16
  declaredFiles,
@@ -16,21 +20,28 @@ import {
16
20
  lib_default,
17
21
  parseDuration,
18
22
  parseValue,
23
+ readRunLog,
19
24
  runnerTools,
20
25
  setIn,
21
- taskParams
22
- } from "./chunk-PAJOD6LV.js";
23
- import "./chunk-KHO3SRUJ.js";
24
- import "./chunk-BTT2GBTQ.js";
26
+ taskParams,
27
+ tidyRuns
28
+ } from "./chunk-VOTN4IHB.js";
29
+ import "./chunk-5PDYWE24.js";
30
+ import "./chunk-NM6H6WCQ.js";
31
+ import "./chunk-SHTX4AGU.js";
25
32
  import "./chunk-2UFLGPDY.js";
26
33
  export {
27
34
  AdgRunner,
28
35
  BusyError,
29
36
  ConfigProfiles,
37
+ KEEP_DAYS,
38
+ LIVE_LOG_MAX,
30
39
  LogTail,
40
+ PACK_AFTER_MS,
31
41
  PARAMS_SCHEMA,
32
42
  ResourceLocks,
33
43
  Runner,
44
+ SCRIPT_LOG_BUDGET,
34
45
  TOOL_NAMES,
35
46
  applyPatches,
36
47
  declaredFiles,
@@ -40,7 +51,9 @@ export {
40
51
  killTree,
41
52
  parseDuration,
42
53
  parseValue,
54
+ readRunLog,
43
55
  runnerTools,
44
56
  setIn,
45
- taskParams
57
+ taskParams,
58
+ tidyRuns
46
59
  };
package/lib/scheduler.js CHANGED
@@ -1,8 +1,10 @@
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
- SCHEDULE_CAPABILITY,
3
+ SCHEDULE_CAPABILITY
4
+ } from "./chunk-NM6H6WCQ.js";
5
+ import {
4
6
  external_exports
5
- } from "./chunk-BTT2GBTQ.js";
7
+ } from "./chunk-SHTX4AGU.js";
6
8
  import "./chunk-2UFLGPDY.js";
7
9
 
8
10
  // packages/scheduler/lib/index.js