dsh-multigameassistant 2.0.4 → 2.1.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.
Files changed (40) hide show
  1. package/cordis.patch.yml +178 -4
  2. package/lib/analyzer.js +135 -26
  3. package/lib/browser.js +279 -0
  4. package/lib/{chunk-XHP3SLMO.js → chunk-77ZYHRN7.js} +292 -6
  5. package/lib/{chunk-UOVFYP7C.js → chunk-EOWM56PA.js} +398 -58
  6. package/lib/chunk-FH64SAZU.js +605 -0
  7. package/lib/{chunk-IZENRXQ6.js → chunk-MEKSHT6V.js} +1797 -575
  8. package/lib/chunk-RESS7WVY.js +157 -0
  9. package/lib/{chunk-SA72K6M2.js → chunk-SHTX4AGU.js} +1 -3572
  10. package/lib/{chunk-4PNYIZVU.js → chunk-TWUATN5X.js} +13 -9
  11. package/lib/chunk-V2X4PLF5.js +3730 -0
  12. package/lib/emulator.js +5 -3
  13. package/lib/feishu.js +8 -5
  14. package/lib/game-intel.js +91 -8
  15. package/lib/gateway.js +9 -5
  16. package/lib/guard.js +5 -3
  17. package/lib/intervene.js +62 -17
  18. package/lib/low-context.js +71 -87
  19. package/lib/monitor.js +90 -10
  20. package/lib/notify.js +6 -4
  21. package/lib/orchestrator.js +97 -27
  22. package/lib/packs/maa/adg.script.yaml +119 -1
  23. package/lib/packs/maaend/adg.script.yaml +74 -4
  24. package/lib/packs/march7th/adg.script.yaml +116 -0
  25. package/lib/qqbot.js +8 -5
  26. package/lib/runner.js +18 -5
  27. package/lib/scheduler.js +4 -2
  28. package/lib/script-registry.js +203 -214
  29. package/package.json +5 -4
  30. package/skills/pipeline-planning.md +8 -5
  31. package/skills/script-analysis.md +70 -10
  32. package/skills/web-reading.md +2 -0
  33. package/web/assets/index-C-csjWiw.js +244 -0
  34. package/web/assets/index-C-csjWiw.js.map +1 -0
  35. package/web/assets/index-CjtVfcDS.css +1 -0
  36. package/web/index.html +2 -2
  37. package/lib/chunk-CCAB6XXZ.js +0 -34
  38. package/web/assets/index-BqeCz6LB.css +0 -1
  39. package/web/assets/index-CCaVm9ks.js +0 -242
  40. package/web/assets/index-CCaVm9ks.js.map +0 -1
@@ -0,0 +1,157 @@
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
+
3
+ // packages/protocol/lib/exe-icon.js
4
+ import { execFile } from "node:child_process";
5
+ import { createHash } from "node:crypto";
6
+ import { existsSync } from "node:fs";
7
+ import { mkdir, readFile, stat, writeFile } from "node:fs/promises";
8
+ import { join, resolve as absolute } from "node:path";
9
+ var ICON_SIZE = 256;
10
+ var TIMEOUT_MS = 2e4;
11
+ var SCRIPT = String.raw`
12
+ $ErrorActionPreference = 'Stop'
13
+ $path = $env:ADG_ICON_PATH
14
+ $size = [int]$env:ADG_ICON_SIZE
15
+ Add-Type -ReferencedAssemblies System.Drawing -TypeDefinition @'
16
+ using System;
17
+ using System.Drawing;
18
+ using System.Drawing.Imaging;
19
+ using System.IO;
20
+ using System.Runtime.InteropServices;
21
+ [ComImport, Guid("bcc18b79-ba16-442f-80c4-8a59c30c463b"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
22
+ interface IShellItemImageFactory { [PreserveSig] int GetImage(AdgSize size, int flags, out IntPtr bitmap); }
23
+ [StructLayout(LayoutKind.Sequential)] struct AdgSize { public int cx; public int cy; }
24
+ public static class AdgExeIcon {
25
+ [DllImport("shell32.dll", CharSet = CharSet.Unicode, PreserveSig = false)]
26
+ static extern void SHCreateItemFromParsingName(string path, IntPtr bc, [MarshalAs(UnmanagedType.LPStruct)] Guid riid, [MarshalAs(UnmanagedType.Interface)] out IShellItemImageFactory item);
27
+ [DllImport("gdi32.dll")] static extern bool DeleteObject(IntPtr handle);
28
+ public static string Png(string path, int size) {
29
+ IShellItemImageFactory factory;
30
+ SHCreateItemFromParsingName(path, IntPtr.Zero, typeof(IShellItemImageFactory).GUID, out factory);
31
+ IntPtr handle;
32
+ // SIIGBF_BIGGERSIZEOK | SIIGBF_ICONONLY: the icon, never a thumbnail of the file.
33
+ int hr = factory.GetImage(new AdgSize { cx = size, cy = size }, 0x1 | 0x4, out handle);
34
+ if (hr != 0) Marshal.ThrowExceptionForHR(hr);
35
+ try {
36
+ using (Bitmap rgb = Image.FromHbitmap(handle)) {
37
+ Rectangle all = new Rectangle(0, 0, rgb.Width, rgb.Height);
38
+ BitmapData bits = rgb.LockBits(all, ImageLockMode.ReadOnly, rgb.PixelFormat);
39
+ try {
40
+ // FromHbitmap drops the alpha channel's meaning, not its bytes: read them again as ARGB.
41
+ using (Bitmap argb = new Bitmap(bits.Width, bits.Height, bits.Stride, PixelFormat.Format32bppArgb, bits.Scan0))
42
+ using (MemoryStream png = new MemoryStream()) {
43
+ argb.Save(png, ImageFormat.Png);
44
+ return Convert.ToBase64String(png.ToArray());
45
+ }
46
+ } finally { rgb.UnlockBits(bits); }
47
+ }
48
+ } finally { DeleteObject(handle); }
49
+ }
50
+ }
51
+ '@
52
+ [Console]::Out.Write([AdgExeIcon]::Png($path, $size))
53
+ `;
54
+ var FALLBACK = String.raw`
55
+ $ErrorActionPreference = 'Stop'
56
+ Add-Type -AssemblyName System.Drawing
57
+ $icon = [System.Drawing.Icon]::ExtractAssociatedIcon($env:ADG_ICON_PATH)
58
+ $png = New-Object IO.MemoryStream
59
+ $icon.ToBitmap().Save($png, [System.Drawing.Imaging.ImageFormat]::Png)
60
+ [Console]::Out.Write([Convert]::ToBase64String($png.ToArray()))
61
+ `;
62
+ async function extractExeIcon(path, signal) {
63
+ if (process.platform !== "win32")
64
+ throw new Error("\u53EA\u6709 Windows \u4E0A\u80FD\u8BFB\u7A0B\u5E8F\u56FE\u6807");
65
+ try {
66
+ return await runIcon(SCRIPT, path, signal);
67
+ } catch (e) {
68
+ if (signal?.aborted === true)
69
+ throw e;
70
+ return runIcon(FALLBACK, path, signal);
71
+ }
72
+ }
73
+ function runIcon(script, path, signal) {
74
+ return new Promise((resolve, reject) => {
75
+ execFile("powershell.exe", ["-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-Command", script], {
76
+ env: { ...process.env, ADG_ICON_PATH: absolute(path), ADG_ICON_SIZE: String(ICON_SIZE) },
77
+ timeout: TIMEOUT_MS,
78
+ windowsHide: true,
79
+ maxBuffer: 16 * 1024 * 1024,
80
+ ...signal === void 0 ? {} : { signal }
81
+ }, (error, stdout, stderr) => {
82
+ if (error !== null) {
83
+ reject(new Error(`\u8BFB\u4E0D\u5230 ${path} \u7684\u56FE\u6807\uFF1A${(stderr || error.message).trim().split("\n")[0]}`));
84
+ return;
85
+ }
86
+ const png = Buffer.from(stdout.trim(), "base64");
87
+ if (png.length < 8 || png.readUInt32BE(0) !== 2303741511) {
88
+ reject(new Error(`\u8BFB\u4E0D\u5230 ${path} \u7684\u56FE\u6807`));
89
+ return;
90
+ }
91
+ resolve(png);
92
+ });
93
+ });
94
+ }
95
+ var ExeIcons = class {
96
+ #dir;
97
+ #extract;
98
+ #pending = /* @__PURE__ */ new Map();
99
+ constructor(dir, extract = extractExeIcon) {
100
+ this.#dir = dir;
101
+ this.#extract = extract;
102
+ }
103
+ /** @returns the program's icon as PNG. @throws Error when the program is gone or has no icon. */
104
+ async png(path, signal) {
105
+ const info = await stat(path).catch(() => void 0);
106
+ if (info === void 0 || !info.isFile())
107
+ throw new Error(`\u627E\u4E0D\u5230 ${path}`);
108
+ const key = createHash("sha1").update(`${path.toLowerCase()}|${info.mtimeMs}|${info.size}`).digest("hex");
109
+ const file = join(this.#dir, `${key}.png`);
110
+ if (existsSync(file))
111
+ return readFile(file);
112
+ let pending = this.#pending.get(key);
113
+ if (pending === void 0) {
114
+ pending = this.#extract(path, signal).then(async (png) => {
115
+ await mkdir(this.#dir, { recursive: true });
116
+ await writeFile(file, png);
117
+ return png;
118
+ }).finally(() => this.#pending.delete(key));
119
+ this.#pending.set(key, pending);
120
+ }
121
+ return pending;
122
+ }
123
+ };
124
+
125
+ // packages/protocol/lib/node.js
126
+ import { randomBytes } from "node:crypto";
127
+ import { mkdir as mkdir2, rename, rm, writeFile as writeFile2 } from "node:fs/promises";
128
+ import { dirname } from "node:path";
129
+ var queues = /* @__PURE__ */ new Map();
130
+ function writeFileAtomic(file, text) {
131
+ const previous = queues.get(file) ?? Promise.resolve();
132
+ const next = previous.catch(() => {
133
+ }).then(async () => {
134
+ await mkdir2(dirname(file), { recursive: true });
135
+ const tmp = `${file}.${process.pid}.${randomBytes(4).toString("hex")}.tmp`;
136
+ try {
137
+ await writeFile2(tmp, text);
138
+ await rename(tmp, file);
139
+ } catch (error) {
140
+ await rm(tmp, { force: true }).catch(() => {
141
+ });
142
+ throw error;
143
+ }
144
+ });
145
+ queues.set(file, next);
146
+ void next.finally(() => {
147
+ if (queues.get(file) === next)
148
+ queues.delete(file);
149
+ }).catch(() => {
150
+ });
151
+ return next;
152
+ }
153
+
154
+ export {
155
+ ExeIcons,
156
+ writeFileAtomic
157
+ };