@spzhongwin/skill-logger-plugin 1.0.14 → 1.0.15

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/dist/index.js CHANGED
@@ -1,6 +1,2757 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
8
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
9
+ }) : x)(function(x) {
10
+ if (typeof require !== "undefined") return require.apply(this, arguments);
11
+ throw Error('Dynamic require of "' + x + '" is not supported');
12
+ });
13
+ var __commonJS = (cb, mod) => function __require2() {
14
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
15
+ };
16
+ var __copyProps = (to, from, except, desc) => {
17
+ if (from && typeof from === "object" || typeof from === "function") {
18
+ for (let key of __getOwnPropNames(from))
19
+ if (!__hasOwnProp.call(to, key) && key !== except)
20
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21
+ }
22
+ return to;
23
+ };
24
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
+ // If the importer is in node compatibility mode or this is not an ESM
26
+ // file that has been converted to a CommonJS file using a Babel-
27
+ // compatible transform (i.e. "__esModule" has not been set), then set
28
+ // "default" to the CommonJS "module.exports" for node compatibility.
29
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
30
+ mod
31
+ ));
32
+
33
+ // node_modules/adm-zip/util/constants.js
34
+ var require_constants = __commonJS({
35
+ "node_modules/adm-zip/util/constants.js"(exports, module) {
36
+ module.exports = {
37
+ /* The local file header */
38
+ LOCHDR: 30,
39
+ // LOC header size
40
+ LOCSIG: 67324752,
41
+ // "PK\003\004"
42
+ LOCVER: 4,
43
+ // version needed to extract
44
+ LOCFLG: 6,
45
+ // general purpose bit flag
46
+ LOCHOW: 8,
47
+ // compression method
48
+ LOCTIM: 10,
49
+ // modification time (2 bytes time, 2 bytes date)
50
+ LOCCRC: 14,
51
+ // uncompressed file crc-32 value
52
+ LOCSIZ: 18,
53
+ // compressed size
54
+ LOCLEN: 22,
55
+ // uncompressed size
56
+ LOCNAM: 26,
57
+ // filename length
58
+ LOCEXT: 28,
59
+ // extra field length
60
+ /* The Data descriptor */
61
+ EXTSIG: 134695760,
62
+ // "PK\007\008"
63
+ EXTHDR: 16,
64
+ // EXT header size
65
+ EXTCRC: 4,
66
+ // uncompressed file crc-32 value
67
+ EXTSIZ: 8,
68
+ // compressed size
69
+ EXTLEN: 12,
70
+ // uncompressed size
71
+ /* The central directory file header */
72
+ CENHDR: 46,
73
+ // CEN header size
74
+ CENSIG: 33639248,
75
+ // "PK\001\002"
76
+ CENVEM: 4,
77
+ // version made by
78
+ CENVER: 6,
79
+ // version needed to extract
80
+ CENFLG: 8,
81
+ // encrypt, decrypt flags
82
+ CENHOW: 10,
83
+ // compression method
84
+ CENTIM: 12,
85
+ // modification time (2 bytes time, 2 bytes date)
86
+ CENCRC: 16,
87
+ // uncompressed file crc-32 value
88
+ CENSIZ: 20,
89
+ // compressed size
90
+ CENLEN: 24,
91
+ // uncompressed size
92
+ CENNAM: 28,
93
+ // filename length
94
+ CENEXT: 30,
95
+ // extra field length
96
+ CENCOM: 32,
97
+ // file comment length
98
+ CENDSK: 34,
99
+ // volume number start
100
+ CENATT: 36,
101
+ // internal file attributes
102
+ CENATX: 38,
103
+ // external file attributes (host system dependent)
104
+ CENOFF: 42,
105
+ // LOC header offset
106
+ /* The entries in the end of central directory */
107
+ ENDHDR: 22,
108
+ // END header size
109
+ ENDSIG: 101010256,
110
+ // "PK\005\006"
111
+ ENDSUB: 8,
112
+ // number of entries on this disk
113
+ ENDTOT: 10,
114
+ // total number of entries
115
+ ENDSIZ: 12,
116
+ // central directory size in bytes
117
+ ENDOFF: 16,
118
+ // offset of first CEN header
119
+ ENDCOM: 20,
120
+ // zip file comment length
121
+ END64HDR: 20,
122
+ // zip64 END header size
123
+ END64SIG: 117853008,
124
+ // zip64 Locator signature, "PK\006\007"
125
+ END64START: 4,
126
+ // number of the disk with the start of the zip64
127
+ END64OFF: 8,
128
+ // relative offset of the zip64 end of central directory
129
+ END64NUMDISKS: 16,
130
+ // total number of disks
131
+ ZIP64SIG: 101075792,
132
+ // zip64 signature, "PK\006\006"
133
+ ZIP64HDR: 56,
134
+ // zip64 record minimum size
135
+ ZIP64LEAD: 12,
136
+ // leading bytes at the start of the record, not counted by the value stored in ZIP64SIZE
137
+ ZIP64SIZE: 4,
138
+ // zip64 size of the central directory record
139
+ ZIP64VEM: 12,
140
+ // zip64 version made by
141
+ ZIP64VER: 14,
142
+ // zip64 version needed to extract
143
+ ZIP64DSK: 16,
144
+ // zip64 number of this disk
145
+ ZIP64DSKDIR: 20,
146
+ // number of the disk with the start of the record directory
147
+ ZIP64SUB: 24,
148
+ // number of entries on this disk
149
+ ZIP64TOT: 32,
150
+ // total number of entries
151
+ ZIP64SIZB: 40,
152
+ // zip64 central directory size in bytes
153
+ ZIP64OFF: 48,
154
+ // offset of start of central directory with respect to the starting disk number
155
+ ZIP64EXTRA: 56,
156
+ // extensible data sector
157
+ /* Compression methods */
158
+ STORED: 0,
159
+ // no compression
160
+ SHRUNK: 1,
161
+ // shrunk
162
+ REDUCED1: 2,
163
+ // reduced with compression factor 1
164
+ REDUCED2: 3,
165
+ // reduced with compression factor 2
166
+ REDUCED3: 4,
167
+ // reduced with compression factor 3
168
+ REDUCED4: 5,
169
+ // reduced with compression factor 4
170
+ IMPLODED: 6,
171
+ // imploded
172
+ // 7 reserved for Tokenizing compression algorithm
173
+ DEFLATED: 8,
174
+ // deflated
175
+ ENHANCED_DEFLATED: 9,
176
+ // enhanced deflated
177
+ PKWARE: 10,
178
+ // PKWare DCL imploded
179
+ // 11 reserved by PKWARE
180
+ BZIP2: 12,
181
+ // compressed using BZIP2
182
+ // 13 reserved by PKWARE
183
+ LZMA: 14,
184
+ // LZMA
185
+ // 15-17 reserved by PKWARE
186
+ IBM_TERSE: 18,
187
+ // compressed using IBM TERSE
188
+ IBM_LZ77: 19,
189
+ // IBM LZ77 z
190
+ AES_ENCRYPT: 99,
191
+ // WinZIP AES encryption method
192
+ /* General purpose bit flag */
193
+ // values can obtained with expression 2**bitnr
194
+ FLG_ENC: 1,
195
+ // Bit 0: encrypted file
196
+ FLG_COMP1: 2,
197
+ // Bit 1, compression option
198
+ FLG_COMP2: 4,
199
+ // Bit 2, compression option
200
+ FLG_DESC: 8,
201
+ // Bit 3, data descriptor
202
+ FLG_ENH: 16,
203
+ // Bit 4, enhanced deflating
204
+ FLG_PATCH: 32,
205
+ // Bit 5, indicates that the file is compressed patched data.
206
+ FLG_STR: 64,
207
+ // Bit 6, strong encryption (patented)
208
+ // Bits 7-10: Currently unused.
209
+ FLG_EFS: 2048,
210
+ // Bit 11: Language encoding flag (EFS)
211
+ // Bit 12: Reserved by PKWARE for enhanced compression.
212
+ // Bit 13: encrypted the Central Directory (patented).
213
+ // Bits 14-15: Reserved by PKWARE.
214
+ FLG_MSK: 4096,
215
+ // mask header values
216
+ /* Load type */
217
+ FILE: 2,
218
+ BUFFER: 1,
219
+ NONE: 0,
220
+ /* 4.5 Extensible data fields */
221
+ EF_ID: 0,
222
+ EF_SIZE: 2,
223
+ /* Header IDs */
224
+ ID_ZIP64: 1,
225
+ ID_AVINFO: 7,
226
+ ID_PFS: 8,
227
+ ID_OS2: 9,
228
+ ID_NTFS: 10,
229
+ ID_OPENVMS: 12,
230
+ ID_UNIX: 13,
231
+ ID_FORK: 14,
232
+ ID_PATCH: 15,
233
+ ID_X509_PKCS7: 20,
234
+ ID_X509_CERTID_F: 21,
235
+ ID_X509_CERTID_C: 22,
236
+ ID_STRONGENC: 23,
237
+ ID_RECORD_MGT: 24,
238
+ ID_X509_PKCS7_RL: 25,
239
+ ID_IBM1: 101,
240
+ ID_IBM2: 102,
241
+ ID_POSZIP: 18064,
242
+ EF_ZIP64_OR_32: 4294967295,
243
+ EF_ZIP64_OR_16: 65535,
244
+ EF_ZIP64_SUNCOMP: 0,
245
+ EF_ZIP64_SCOMP: 8,
246
+ EF_ZIP64_RHO: 16,
247
+ EF_ZIP64_DSN: 24
248
+ };
249
+ }
250
+ });
251
+
252
+ // node_modules/adm-zip/util/errors.js
253
+ var require_errors = __commonJS({
254
+ "node_modules/adm-zip/util/errors.js"(exports) {
255
+ var errors = {
256
+ /* Header error messages */
257
+ INVALID_LOC: "Invalid LOC header (bad signature)",
258
+ INVALID_CEN: "Invalid CEN header (bad signature)",
259
+ INVALID_END: "Invalid END header (bad signature)",
260
+ /* Descriptor */
261
+ DESCRIPTOR_NOT_EXIST: "No descriptor present",
262
+ DESCRIPTOR_UNKNOWN: "Unknown descriptor format",
263
+ DESCRIPTOR_FAULTY: "Descriptor data is malformed",
264
+ /* ZipEntry error messages*/
265
+ NO_DATA: "Nothing to decompress",
266
+ BAD_CRC: "CRC32 checksum failed {0}",
267
+ FILE_IN_THE_WAY: "There is a file in the way: {0}",
268
+ UNKNOWN_METHOD: "Invalid/unsupported compression method",
269
+ /* Inflater error messages */
270
+ AVAIL_DATA: "inflate::Available inflate data did not terminate",
271
+ INVALID_DISTANCE: "inflate::Invalid literal/length or distance code in fixed or dynamic block",
272
+ TO_MANY_CODES: "inflate::Dynamic block code description: too many length or distance codes",
273
+ INVALID_REPEAT_LEN: "inflate::Dynamic block code description: repeat more than specified lengths",
274
+ INVALID_REPEAT_FIRST: "inflate::Dynamic block code description: repeat lengths with no first length",
275
+ INCOMPLETE_CODES: "inflate::Dynamic block code description: code lengths codes incomplete",
276
+ INVALID_DYN_DISTANCE: "inflate::Dynamic block code description: invalid distance code lengths",
277
+ INVALID_CODES_LEN: "inflate::Dynamic block code description: invalid literal/length code lengths",
278
+ INVALID_STORE_BLOCK: "inflate::Stored block length did not match one's complement",
279
+ INVALID_BLOCK_TYPE: "inflate::Invalid block type (type == 3)",
280
+ /* ADM-ZIP error messages */
281
+ CANT_EXTRACT_FILE: "Could not extract the file",
282
+ CANT_OVERRIDE: "Target file already exists",
283
+ DISK_ENTRY_TOO_LARGE: "Number of disk entries is too large",
284
+ NO_ZIP: "No zip file was loaded",
285
+ NO_ENTRY: "Entry doesn't exist",
286
+ DIRECTORY_CONTENT_ERROR: "A directory cannot have content",
287
+ FILE_NOT_FOUND: 'File not found: "{0}"',
288
+ NOT_IMPLEMENTED: "Not implemented",
289
+ INVALID_FILENAME: "Invalid filename",
290
+ INVALID_FORMAT: "Invalid or unsupported zip format. No END header found",
291
+ INVALID_PASS_PARAM: "Incompatible password parameter",
292
+ WRONG_PASSWORD: "Wrong Password",
293
+ /* ADM-ZIP */
294
+ COMMENT_TOO_LONG: "Comment is too long",
295
+ // Comment can be max 65535 bytes long (NOTE: some non-US characters may take more space)
296
+ EXTRA_FIELD_PARSE_ERROR: "Extra field parsing error"
297
+ };
298
+ function E(message) {
299
+ return function(...args) {
300
+ if (args.length) {
301
+ message = message.replace(/\{(\d)\}/g, (_, n) => args[n] || "");
302
+ }
303
+ return new Error("ADM-ZIP: " + message);
304
+ };
305
+ }
306
+ for (const msg of Object.keys(errors)) {
307
+ exports[msg] = E(errors[msg]);
308
+ }
309
+ }
310
+ });
311
+
312
+ // node_modules/adm-zip/util/utils.js
313
+ var require_utils = __commonJS({
314
+ "node_modules/adm-zip/util/utils.js"(exports, module) {
315
+ var fsystem = __require("fs");
316
+ var pth = __require("path");
317
+ var Constants = require_constants();
318
+ var Errors = require_errors();
319
+ var isWin = typeof process === "object" && "win32" === process.platform;
320
+ var is_Obj = (obj) => typeof obj === "object" && obj !== null;
321
+ var crcTable = new Uint32Array(256).map((t, c) => {
322
+ for (let k = 0; k < 8; k++) {
323
+ if ((c & 1) !== 0) {
324
+ c = 3988292384 ^ c >>> 1;
325
+ } else {
326
+ c >>>= 1;
327
+ }
328
+ }
329
+ return c >>> 0;
330
+ });
331
+ function Utils(opts) {
332
+ this.sep = pth.sep;
333
+ this.fs = fsystem;
334
+ if (is_Obj(opts)) {
335
+ if (is_Obj(opts.fs) && typeof opts.fs.statSync === "function") {
336
+ this.fs = opts.fs;
337
+ }
338
+ }
339
+ }
340
+ module.exports = Utils;
341
+ Utils.prototype.makeDir = function(folder) {
342
+ const self = this;
343
+ function mkdirSync(fpath) {
344
+ let resolvedPath = fpath.split(self.sep)[0];
345
+ fpath.split(self.sep).forEach(function(name) {
346
+ if (!name || name.substr(-1, 1) === ":") return;
347
+ resolvedPath += self.sep + name;
348
+ var stat;
349
+ try {
350
+ stat = self.fs.statSync(resolvedPath);
351
+ } catch (e) {
352
+ if (e.message && e.message.startsWith("ENOENT")) {
353
+ self.fs.mkdirSync(resolvedPath);
354
+ } else {
355
+ throw e;
356
+ }
357
+ }
358
+ if (stat && stat.isFile()) throw Errors.FILE_IN_THE_WAY(`"${resolvedPath}"`);
359
+ });
360
+ }
361
+ mkdirSync(folder);
362
+ };
363
+ Utils.prototype.writeFileTo = function(path11, content, overwrite, attr) {
364
+ const self = this;
365
+ if (self.fs.existsSync(path11)) {
366
+ if (!overwrite) return false;
367
+ var stat = self.fs.statSync(path11);
368
+ if (stat.isDirectory()) {
369
+ return false;
370
+ }
371
+ }
372
+ var folder = pth.dirname(path11);
373
+ if (!self.fs.existsSync(folder)) {
374
+ self.makeDir(folder);
375
+ }
376
+ var fd;
377
+ try {
378
+ fd = self.fs.openSync(path11, "w", 438);
379
+ } catch (e) {
380
+ self.fs.chmodSync(path11, 438);
381
+ fd = self.fs.openSync(path11, "w", 438);
382
+ }
383
+ if (fd) {
384
+ try {
385
+ self.fs.writeSync(fd, content, 0, content.length, 0);
386
+ } finally {
387
+ self.fs.closeSync(fd);
388
+ }
389
+ }
390
+ self.fs.chmodSync(path11, attr || 438);
391
+ return true;
392
+ };
393
+ Utils.prototype.writeFileToAsync = function(path11, content, overwrite, attr, callback) {
394
+ if (typeof attr === "function") {
395
+ callback = attr;
396
+ attr = void 0;
397
+ }
398
+ const self = this;
399
+ self.fs.exists(path11, function(exist) {
400
+ if (exist && !overwrite) return callback(false);
401
+ self.fs.stat(path11, function(err, stat) {
402
+ if (exist && stat && stat.isDirectory()) {
403
+ return callback(false);
404
+ }
405
+ var folder = pth.dirname(path11);
406
+ self.fs.exists(folder, function(exists) {
407
+ if (!exists) {
408
+ try {
409
+ self.makeDir(folder);
410
+ } catch (e) {
411
+ return callback(false);
412
+ }
413
+ }
414
+ const writeToFd = function(fd) {
415
+ self.fs.write(fd, content, 0, content.length, 0, function(writeErr) {
416
+ self.fs.close(fd, function() {
417
+ if (writeErr) return callback(false);
418
+ self.fs.chmod(path11, attr || 438, function() {
419
+ callback(true);
420
+ });
421
+ });
422
+ });
423
+ };
424
+ self.fs.open(path11, "w", 438, function(err2, fd) {
425
+ if (err2) {
426
+ self.fs.chmod(path11, 438, function() {
427
+ self.fs.open(path11, "w", 438, function(retryErr, fd2) {
428
+ if (retryErr || !fd2) return callback(false);
429
+ writeToFd(fd2);
430
+ });
431
+ });
432
+ } else if (fd) {
433
+ writeToFd(fd);
434
+ } else {
435
+ callback(false);
436
+ }
437
+ });
438
+ });
439
+ });
440
+ });
441
+ };
442
+ Utils.prototype.findFiles = function(path11) {
443
+ const self = this;
444
+ function findSync(dir, pattern, recursive, visited) {
445
+ if (typeof pattern === "boolean") {
446
+ recursive = pattern;
447
+ pattern = void 0;
448
+ }
449
+ let files = [];
450
+ self.fs.readdirSync(dir).forEach(function(file) {
451
+ const path12 = pth.join(dir, file);
452
+ const stat = self.fs.statSync(path12);
453
+ if (!pattern || pattern.test(path12)) {
454
+ files.push(pth.normalize(path12) + (stat.isDirectory() ? self.sep : ""));
455
+ }
456
+ if (stat.isDirectory() && recursive) {
457
+ const realDir = self.fs.realpathSync(path12);
458
+ if (!visited.has(realDir)) {
459
+ visited.add(realDir);
460
+ files = files.concat(findSync(path12, pattern, recursive, visited));
461
+ }
462
+ }
463
+ });
464
+ return files;
465
+ }
466
+ return findSync(path11, void 0, true, /* @__PURE__ */ new Set([self.fs.realpathSync(path11)]));
467
+ };
468
+ Utils.prototype.findFilesAsync = function(dir, cb) {
469
+ const self = this;
470
+ const results = [];
471
+ let finished = false;
472
+ const finish = function(err) {
473
+ if (finished) return;
474
+ finished = true;
475
+ cb(err, err ? void 0 : results);
476
+ };
477
+ const walk = function(dir2, visited, done) {
478
+ self.fs.readdir(dir2, function(err, list) {
479
+ if (err) return done(err);
480
+ let pending = list.length;
481
+ if (!pending) return done();
482
+ list.forEach(function(name) {
483
+ const file = pth.join(dir2, name);
484
+ self.fs.stat(file, function(err2, stat) {
485
+ if (err2) return done(err2);
486
+ if (!stat) {
487
+ if (!--pending) done();
488
+ return;
489
+ }
490
+ results.push(pth.normalize(file) + (stat.isDirectory() ? self.sep : ""));
491
+ if (!stat.isDirectory()) {
492
+ if (!--pending) done();
493
+ return;
494
+ }
495
+ self.fs.realpath(file, function(err3, realDir) {
496
+ if (err3) return done(err3);
497
+ if (visited.has(realDir)) {
498
+ if (!--pending) done();
499
+ return;
500
+ }
501
+ visited.add(realDir);
502
+ walk(file, visited, function(err4) {
503
+ if (err4) return done(err4);
504
+ if (!--pending) done();
505
+ });
506
+ });
507
+ });
508
+ });
509
+ });
510
+ };
511
+ self.fs.realpath(dir, function(err, realDir) {
512
+ if (err) return finish(err);
513
+ walk(dir, /* @__PURE__ */ new Set([realDir]), finish);
514
+ });
515
+ };
516
+ Utils.prototype.getAttributes = function() {
517
+ };
518
+ Utils.prototype.setAttributes = function() {
519
+ };
520
+ Utils.crc32update = function(crc, byte) {
521
+ return crcTable[(crc ^ byte) & 255] ^ crc >>> 8;
522
+ };
523
+ Utils.crc32 = function(buf) {
524
+ if (typeof buf === "string") {
525
+ buf = Buffer.from(buf, "utf8");
526
+ }
527
+ let len = buf.length;
528
+ let crc = ~0;
529
+ for (let off = 0; off < len; ) crc = Utils.crc32update(crc, buf[off++]);
530
+ return ~crc >>> 0;
531
+ };
532
+ Utils.methodToString = function(method) {
533
+ switch (method) {
534
+ case Constants.STORED:
535
+ return "STORED (" + method + ")";
536
+ case Constants.DEFLATED:
537
+ return "DEFLATED (" + method + ")";
538
+ default:
539
+ return "UNSUPPORTED (" + method + ")";
540
+ }
541
+ };
542
+ Utils.canonical = function(path11) {
543
+ if (!path11) return "";
544
+ const safeSuffix = pth.posix.normalize("/" + path11.split("\\").join("/"));
545
+ return pth.join(".", safeSuffix);
546
+ };
547
+ Utils.zipnamefix = function(path11) {
548
+ if (!path11) return "";
549
+ const safeSuffix = pth.posix.normalize("/" + path11.split("\\").join("/"));
550
+ return pth.posix.join(".", safeSuffix);
551
+ };
552
+ Utils.findLast = function(arr, callback) {
553
+ if (!Array.isArray(arr)) throw new TypeError("arr is not array");
554
+ const len = arr.length >>> 0;
555
+ for (let i = len - 1; i >= 0; i--) {
556
+ if (callback(arr[i], i, arr)) {
557
+ return arr[i];
558
+ }
559
+ }
560
+ return void 0;
561
+ };
562
+ Utils.sanitize = function(prefix, name) {
563
+ prefix = pth.resolve(pth.normalize(prefix));
564
+ var parts = name.split("/");
565
+ for (var i = 0, l = parts.length; i < l; i++) {
566
+ var path11 = pth.normalize(pth.join(prefix, parts.slice(i, l).join(pth.sep)));
567
+ if (path11 === prefix || path11.startsWith(prefix + pth.sep)) {
568
+ return path11;
569
+ }
570
+ }
571
+ return pth.normalize(pth.join(prefix, pth.basename(name)));
572
+ };
573
+ Utils.toBuffer = function toBuffer(input, encoder) {
574
+ if (Buffer.isBuffer(input)) {
575
+ return input;
576
+ } else if (input instanceof Uint8Array) {
577
+ return Buffer.from(input);
578
+ } else {
579
+ return typeof input === "string" ? encoder(input) : Buffer.alloc(0);
580
+ }
581
+ };
582
+ Utils.readBigUInt64LE = function(buffer, index) {
583
+ const lo = buffer.readUInt32LE(index);
584
+ const hi = buffer.readUInt32LE(index + 4);
585
+ return hi * 4294967296 + lo;
586
+ };
587
+ Utils.writeBigUInt64LE = function(buffer, value, index) {
588
+ const lo = value >>> 0;
589
+ const hi = Math.floor(value / 4294967296) >>> 0;
590
+ buffer.writeUInt32LE(lo, index);
591
+ buffer.writeUInt32LE(hi, index + 4);
592
+ };
593
+ Utils.fromDOS2Date = function(val) {
594
+ return new Date((val >> 25 & 127) + 1980, Math.max((val >> 21 & 15) - 1, 0), Math.max(val >> 16 & 31, 1), val >> 11 & 31, val >> 5 & 63, (val & 31) << 1);
595
+ };
596
+ Utils.fromDate2DOS = function(val) {
597
+ let date = 0;
598
+ let time = 0;
599
+ if (val.getFullYear() > 1979) {
600
+ date = (val.getFullYear() - 1980 & 127) << 9 | val.getMonth() + 1 << 5 | val.getDate();
601
+ time = val.getHours() << 11 | val.getMinutes() << 5 | val.getSeconds() >> 1;
602
+ }
603
+ return date << 16 | time;
604
+ };
605
+ Utils.isWin = isWin;
606
+ Utils.crcTable = crcTable;
607
+ }
608
+ });
609
+
610
+ // node_modules/adm-zip/util/fattr.js
611
+ var require_fattr = __commonJS({
612
+ "node_modules/adm-zip/util/fattr.js"(exports, module) {
613
+ var pth = __require("path");
614
+ module.exports = function(path11, { fs: fs9 }) {
615
+ var _path = path11 || "", _obj = newAttr(), _stat = null;
616
+ function newAttr() {
617
+ return {
618
+ directory: false,
619
+ readonly: false,
620
+ hidden: false,
621
+ executable: false,
622
+ mtime: 0,
623
+ atime: 0
624
+ };
625
+ }
626
+ if (_path && fs9.existsSync(_path)) {
627
+ _stat = fs9.statSync(_path);
628
+ _obj.directory = _stat.isDirectory();
629
+ _obj.mtime = _stat.mtime;
630
+ _obj.atime = _stat.atime;
631
+ _obj.executable = (73 & _stat.mode) !== 0;
632
+ _obj.readonly = (128 & _stat.mode) === 0;
633
+ _obj.hidden = pth.basename(_path)[0] === ".";
634
+ } else {
635
+ console.warn("Invalid path: " + _path);
636
+ }
637
+ return {
638
+ get directory() {
639
+ return _obj.directory;
640
+ },
641
+ get readOnly() {
642
+ return _obj.readonly;
643
+ },
644
+ get hidden() {
645
+ return _obj.hidden;
646
+ },
647
+ get mtime() {
648
+ return _obj.mtime;
649
+ },
650
+ get atime() {
651
+ return _obj.atime;
652
+ },
653
+ get executable() {
654
+ return _obj.executable;
655
+ },
656
+ decodeAttributes: function() {
657
+ },
658
+ encodeAttributes: function() {
659
+ },
660
+ toJSON: function() {
661
+ return {
662
+ path: _path,
663
+ isDirectory: _obj.directory,
664
+ isReadOnly: _obj.readonly,
665
+ isHidden: _obj.hidden,
666
+ isExecutable: _obj.executable,
667
+ mTime: _obj.mtime,
668
+ aTime: _obj.atime
669
+ };
670
+ },
671
+ toString: function() {
672
+ return JSON.stringify(this.toJSON(), null, " ");
673
+ }
674
+ };
675
+ };
676
+ }
677
+ });
678
+
679
+ // node_modules/adm-zip/util/decoder.js
680
+ var require_decoder = __commonJS({
681
+ "node_modules/adm-zip/util/decoder.js"(exports, module) {
682
+ module.exports = {
683
+ efs: true,
684
+ encode: (data) => Buffer.from(data, "utf8"),
685
+ decode: (data) => data.toString("utf8")
686
+ };
687
+ }
688
+ });
689
+
690
+ // node_modules/adm-zip/util/index.js
691
+ var require_util = __commonJS({
692
+ "node_modules/adm-zip/util/index.js"(exports, module) {
693
+ module.exports = require_utils();
694
+ module.exports.Constants = require_constants();
695
+ module.exports.Errors = require_errors();
696
+ module.exports.FileAttr = require_fattr();
697
+ module.exports.decoder = require_decoder();
698
+ }
699
+ });
700
+
701
+ // node_modules/adm-zip/headers/entryHeader.js
702
+ var require_entryHeader = __commonJS({
703
+ "node_modules/adm-zip/headers/entryHeader.js"(exports, module) {
704
+ var Utils = require_util();
705
+ var Constants = Utils.Constants;
706
+ module.exports = function() {
707
+ var _verMade = 20, _version = 10, _flags = 0, _method = 0, _time = 0, _crc = 0, _compressedSize = 0, _size = 0, _fnameLen = 0, _extraLen = 0, _comLen = 0, _diskStart = 0, _inattr = 0, _attr = 0, _offset = 0;
708
+ _verMade |= Utils.isWin ? 2560 : 768;
709
+ _flags |= Constants.FLG_EFS;
710
+ const _localHeader = {
711
+ extraLen: 0
712
+ };
713
+ const uint32 = (val) => Math.max(0, val) >>> 0;
714
+ const uint16 = (val) => Math.max(0, val) & 65535;
715
+ const uint8 = (val) => Math.max(0, val) & 255;
716
+ _time = Utils.fromDate2DOS(/* @__PURE__ */ new Date());
717
+ return {
718
+ get made() {
719
+ return _verMade;
720
+ },
721
+ set made(val) {
722
+ _verMade = val;
723
+ },
724
+ get version() {
725
+ return _version;
726
+ },
727
+ set version(val) {
728
+ _version = val;
729
+ },
730
+ get flags() {
731
+ return _flags;
732
+ },
733
+ set flags(val) {
734
+ _flags = val;
735
+ },
736
+ get flags_efs() {
737
+ return (_flags & Constants.FLG_EFS) > 0;
738
+ },
739
+ set flags_efs(val) {
740
+ if (val) {
741
+ _flags |= Constants.FLG_EFS;
742
+ } else {
743
+ _flags &= ~Constants.FLG_EFS;
744
+ }
745
+ },
746
+ get flags_desc() {
747
+ return (_flags & Constants.FLG_DESC) > 0;
748
+ },
749
+ set flags_desc(val) {
750
+ if (val) {
751
+ _flags |= Constants.FLG_DESC;
752
+ } else {
753
+ _flags &= ~Constants.FLG_DESC;
754
+ }
755
+ },
756
+ get method() {
757
+ return _method;
758
+ },
759
+ set method(val) {
760
+ switch (val) {
761
+ case Constants.STORED:
762
+ this.version = 10;
763
+ break;
764
+ case Constants.DEFLATED:
765
+ default:
766
+ this.version = 20;
767
+ }
768
+ _method = val;
769
+ },
770
+ get time() {
771
+ return Utils.fromDOS2Date(this.timeval);
772
+ },
773
+ set time(val) {
774
+ val = new Date(val);
775
+ this.timeval = Utils.fromDate2DOS(val);
776
+ },
777
+ get timeval() {
778
+ return _time;
779
+ },
780
+ set timeval(val) {
781
+ _time = uint32(val);
782
+ },
783
+ get timeHighByte() {
784
+ return uint8(_time >>> 8);
785
+ },
786
+ get crc() {
787
+ return _crc;
788
+ },
789
+ set crc(val) {
790
+ _crc = uint32(val);
791
+ },
792
+ get compressedSize() {
793
+ return _compressedSize;
794
+ },
795
+ set compressedSize(val) {
796
+ _compressedSize = uint32(val);
797
+ },
798
+ get size() {
799
+ return _size;
800
+ },
801
+ set size(val) {
802
+ _size = uint32(val);
803
+ },
804
+ get fileNameLength() {
805
+ return _fnameLen;
806
+ },
807
+ set fileNameLength(val) {
808
+ _fnameLen = val;
809
+ },
810
+ get extraLength() {
811
+ return _extraLen;
812
+ },
813
+ set extraLength(val) {
814
+ _extraLen = val;
815
+ },
816
+ get extraLocalLength() {
817
+ return _localHeader.extraLen;
818
+ },
819
+ set extraLocalLength(val) {
820
+ _localHeader.extraLen = val;
821
+ },
822
+ get commentLength() {
823
+ return _comLen;
824
+ },
825
+ set commentLength(val) {
826
+ _comLen = val;
827
+ },
828
+ get diskNumStart() {
829
+ return _diskStart;
830
+ },
831
+ set diskNumStart(val) {
832
+ _diskStart = uint32(val);
833
+ },
834
+ get inAttr() {
835
+ return _inattr;
836
+ },
837
+ set inAttr(val) {
838
+ _inattr = uint32(val);
839
+ },
840
+ get attr() {
841
+ return _attr;
842
+ },
843
+ set attr(val) {
844
+ _attr = uint32(val);
845
+ },
846
+ // get Unix file permissions
847
+ get fileAttr() {
848
+ return (_attr || 0) >> 16 & 4095;
849
+ },
850
+ get offset() {
851
+ return _offset;
852
+ },
853
+ set offset(val) {
854
+ _offset = uint32(val);
855
+ },
856
+ get encrypted() {
857
+ return (_flags & Constants.FLG_ENC) === Constants.FLG_ENC;
858
+ },
859
+ get centralHeaderSize() {
860
+ return Constants.CENHDR + _fnameLen + _extraLen + _comLen;
861
+ },
862
+ get realDataOffset() {
863
+ return _offset + Constants.LOCHDR + _localHeader.fnameLen + _localHeader.extraLen;
864
+ },
865
+ get localHeader() {
866
+ return _localHeader;
867
+ },
868
+ loadLocalHeaderFromBinary: function(input) {
869
+ var data = input.slice(_offset, _offset + Constants.LOCHDR);
870
+ if (data.readUInt32LE(0) !== Constants.LOCSIG) {
871
+ throw Utils.Errors.INVALID_LOC();
872
+ }
873
+ _localHeader.version = data.readUInt16LE(Constants.LOCVER);
874
+ _localHeader.flags = data.readUInt16LE(Constants.LOCFLG);
875
+ _localHeader.flags_desc = (_localHeader.flags & Constants.FLG_DESC) > 0;
876
+ _localHeader.method = data.readUInt16LE(Constants.LOCHOW);
877
+ _localHeader.time = data.readUInt32LE(Constants.LOCTIM);
878
+ _localHeader.crc = data.readUInt32LE(Constants.LOCCRC);
879
+ _localHeader.compressedSize = data.readUInt32LE(Constants.LOCSIZ);
880
+ _localHeader.size = data.readUInt32LE(Constants.LOCLEN);
881
+ _localHeader.fnameLen = data.readUInt16LE(Constants.LOCNAM);
882
+ _localHeader.extraLen = data.readUInt16LE(Constants.LOCEXT);
883
+ const extraStart = _offset + Constants.LOCHDR + _localHeader.fnameLen;
884
+ const extraEnd = extraStart + _localHeader.extraLen;
885
+ return input.slice(extraStart, extraEnd);
886
+ },
887
+ loadFromBinary: function(data) {
888
+ if (data.length !== Constants.CENHDR || data.readUInt32LE(0) !== Constants.CENSIG) {
889
+ throw Utils.Errors.INVALID_CEN();
890
+ }
891
+ _verMade = data.readUInt16LE(Constants.CENVEM);
892
+ _version = data.readUInt16LE(Constants.CENVER);
893
+ _flags = data.readUInt16LE(Constants.CENFLG);
894
+ _method = data.readUInt16LE(Constants.CENHOW);
895
+ _time = data.readUInt32LE(Constants.CENTIM);
896
+ _crc = data.readUInt32LE(Constants.CENCRC);
897
+ _compressedSize = data.readUInt32LE(Constants.CENSIZ);
898
+ _size = data.readUInt32LE(Constants.CENLEN);
899
+ _fnameLen = data.readUInt16LE(Constants.CENNAM);
900
+ _extraLen = data.readUInt16LE(Constants.CENEXT);
901
+ _comLen = data.readUInt16LE(Constants.CENCOM);
902
+ _diskStart = data.readUInt16LE(Constants.CENDSK);
903
+ _inattr = data.readUInt16LE(Constants.CENATT);
904
+ _attr = data.readUInt32LE(Constants.CENATX);
905
+ _offset = data.readUInt32LE(Constants.CENOFF);
906
+ },
907
+ localHeaderToBinary: function() {
908
+ var data = Buffer.alloc(Constants.LOCHDR);
909
+ data.writeUInt32LE(Constants.LOCSIG, 0);
910
+ data.writeUInt16LE(_version, Constants.LOCVER);
911
+ data.writeUInt16LE(_flags & ~Constants.FLG_DESC, Constants.LOCFLG);
912
+ data.writeUInt16LE(_method, Constants.LOCHOW);
913
+ data.writeUInt32LE(_time, Constants.LOCTIM);
914
+ data.writeUInt32LE(_crc, Constants.LOCCRC);
915
+ data.writeUInt32LE(_compressedSize, Constants.LOCSIZ);
916
+ data.writeUInt32LE(_size, Constants.LOCLEN);
917
+ data.writeUInt16LE(_fnameLen, Constants.LOCNAM);
918
+ data.writeUInt16LE(_localHeader.extraLen, Constants.LOCEXT);
919
+ return data;
920
+ },
921
+ centralHeaderToBinary: function() {
922
+ var data = Buffer.alloc(Constants.CENHDR + _fnameLen + _extraLen + _comLen);
923
+ data.writeUInt32LE(Constants.CENSIG, 0);
924
+ data.writeUInt16LE(_verMade, Constants.CENVEM);
925
+ data.writeUInt16LE(_version, Constants.CENVER);
926
+ data.writeUInt16LE(_flags & ~Constants.FLG_DESC, Constants.CENFLG);
927
+ data.writeUInt16LE(_method, Constants.CENHOW);
928
+ data.writeUInt32LE(_time, Constants.CENTIM);
929
+ data.writeUInt32LE(_crc, Constants.CENCRC);
930
+ data.writeUInt32LE(_compressedSize, Constants.CENSIZ);
931
+ data.writeUInt32LE(_size, Constants.CENLEN);
932
+ data.writeUInt16LE(_fnameLen, Constants.CENNAM);
933
+ data.writeUInt16LE(_extraLen, Constants.CENEXT);
934
+ data.writeUInt16LE(_comLen, Constants.CENCOM);
935
+ data.writeUInt16LE(_diskStart, Constants.CENDSK);
936
+ data.writeUInt16LE(_inattr, Constants.CENATT);
937
+ data.writeUInt32LE(_attr, Constants.CENATX);
938
+ data.writeUInt32LE(_offset, Constants.CENOFF);
939
+ return data;
940
+ },
941
+ toJSON: function() {
942
+ const bytes = function(nr) {
943
+ return nr + " bytes";
944
+ };
945
+ return {
946
+ made: _verMade,
947
+ version: _version,
948
+ flags: _flags,
949
+ method: Utils.methodToString(_method),
950
+ time: this.time,
951
+ crc: "0x" + _crc.toString(16).toUpperCase(),
952
+ compressedSize: bytes(_compressedSize),
953
+ size: bytes(_size),
954
+ fileNameLength: bytes(_fnameLen),
955
+ extraLength: bytes(_extraLen),
956
+ commentLength: bytes(_comLen),
957
+ diskNumStart: _diskStart,
958
+ inAttr: _inattr,
959
+ attr: _attr,
960
+ offset: _offset,
961
+ centralHeaderSize: bytes(Constants.CENHDR + _fnameLen + _extraLen + _comLen)
962
+ };
963
+ },
964
+ toString: function() {
965
+ return JSON.stringify(this.toJSON(), null, " ");
966
+ }
967
+ };
968
+ };
969
+ }
970
+ });
971
+
972
+ // node_modules/adm-zip/headers/mainHeader.js
973
+ var require_mainHeader = __commonJS({
974
+ "node_modules/adm-zip/headers/mainHeader.js"(exports, module) {
975
+ var Utils = require_util();
976
+ var Constants = Utils.Constants;
977
+ module.exports = function() {
978
+ var _volumeEntries = 0, _totalEntries = 0, _size = 0, _offset = 0, _commentLength = 0;
979
+ const needsZip64 = () => _volumeEntries > Constants.EF_ZIP64_OR_16 || _totalEntries > Constants.EF_ZIP64_OR_16 || _size > Constants.EF_ZIP64_OR_32 || _offset > Constants.EF_ZIP64_OR_32;
980
+ return {
981
+ get diskEntries() {
982
+ return _volumeEntries;
983
+ },
984
+ set diskEntries(val) {
985
+ _volumeEntries = _totalEntries = val;
986
+ },
987
+ get totalEntries() {
988
+ return _totalEntries;
989
+ },
990
+ set totalEntries(val) {
991
+ _totalEntries = _volumeEntries = val;
992
+ },
993
+ get size() {
994
+ return _size;
995
+ },
996
+ set size(val) {
997
+ _size = val;
998
+ },
999
+ get offset() {
1000
+ return _offset;
1001
+ },
1002
+ set offset(val) {
1003
+ _offset = val;
1004
+ },
1005
+ get commentLength() {
1006
+ return _commentLength;
1007
+ },
1008
+ set commentLength(val) {
1009
+ _commentLength = val;
1010
+ },
1011
+ get mainHeaderSize() {
1012
+ return (needsZip64() ? Constants.ZIP64HDR + Constants.END64HDR : 0) + Constants.ENDHDR + _commentLength;
1013
+ },
1014
+ loadFromBinary: function(data) {
1015
+ if ((data.length !== Constants.ENDHDR || data.readUInt32LE(0) !== Constants.ENDSIG) && (data.length < Constants.ZIP64HDR || data.readUInt32LE(0) !== Constants.ZIP64SIG)) {
1016
+ throw Utils.Errors.INVALID_END();
1017
+ }
1018
+ if (data.readUInt32LE(0) === Constants.ENDSIG) {
1019
+ _volumeEntries = data.readUInt16LE(Constants.ENDSUB);
1020
+ _totalEntries = data.readUInt16LE(Constants.ENDTOT);
1021
+ _size = data.readUInt32LE(Constants.ENDSIZ);
1022
+ _offset = data.readUInt32LE(Constants.ENDOFF);
1023
+ _commentLength = data.readUInt16LE(Constants.ENDCOM);
1024
+ } else {
1025
+ _volumeEntries = Utils.readBigUInt64LE(data, Constants.ZIP64SUB);
1026
+ _totalEntries = Utils.readBigUInt64LE(data, Constants.ZIP64TOT);
1027
+ _size = Utils.readBigUInt64LE(data, Constants.ZIP64SIZB);
1028
+ _offset = Utils.readBigUInt64LE(data, Constants.ZIP64OFF);
1029
+ _commentLength = 0;
1030
+ }
1031
+ },
1032
+ toBinary: function() {
1033
+ if (!needsZip64()) {
1034
+ var b = Buffer.alloc(Constants.ENDHDR + _commentLength);
1035
+ b.writeUInt32LE(Constants.ENDSIG, 0);
1036
+ b.writeUInt32LE(0, 4);
1037
+ b.writeUInt16LE(_volumeEntries, Constants.ENDSUB);
1038
+ b.writeUInt16LE(_totalEntries, Constants.ENDTOT);
1039
+ b.writeUInt32LE(_size, Constants.ENDSIZ);
1040
+ b.writeUInt32LE(_offset, Constants.ENDOFF);
1041
+ b.writeUInt16LE(_commentLength, Constants.ENDCOM);
1042
+ b.fill(" ", Constants.ENDHDR);
1043
+ return b;
1044
+ }
1045
+ var b = Buffer.alloc(this.mainHeaderSize);
1046
+ let offset = 0;
1047
+ b.writeUInt32LE(Constants.ZIP64SIG, offset);
1048
+ Utils.writeBigUInt64LE(b, Constants.ZIP64HDR - Constants.ZIP64LEAD, offset + Constants.ZIP64SIZE);
1049
+ b.writeUInt16LE(45, offset + Constants.ZIP64VEM);
1050
+ b.writeUInt16LE(45, offset + Constants.ZIP64VER);
1051
+ b.writeUInt32LE(0, offset + Constants.ZIP64DSK);
1052
+ b.writeUInt32LE(0, offset + Constants.ZIP64DSKDIR);
1053
+ Utils.writeBigUInt64LE(b, _volumeEntries, offset + Constants.ZIP64SUB);
1054
+ Utils.writeBigUInt64LE(b, _totalEntries, offset + Constants.ZIP64TOT);
1055
+ Utils.writeBigUInt64LE(b, _size, offset + Constants.ZIP64SIZB);
1056
+ Utils.writeBigUInt64LE(b, _offset, offset + Constants.ZIP64OFF);
1057
+ const zip64EndOffset = _offset + _size;
1058
+ offset += Constants.ZIP64HDR;
1059
+ b.writeUInt32LE(Constants.END64SIG, offset);
1060
+ b.writeUInt32LE(0, offset + Constants.END64START);
1061
+ Utils.writeBigUInt64LE(b, zip64EndOffset, offset + Constants.END64OFF);
1062
+ b.writeUInt32LE(1, offset + Constants.END64NUMDISKS);
1063
+ offset += Constants.END64HDR;
1064
+ b.writeUInt32LE(Constants.ENDSIG, offset);
1065
+ b.writeUInt32LE(0, offset + 4);
1066
+ b.writeUInt16LE(Math.min(_volumeEntries, Constants.EF_ZIP64_OR_16), offset + Constants.ENDSUB);
1067
+ b.writeUInt16LE(Math.min(_totalEntries, Constants.EF_ZIP64_OR_16), offset + Constants.ENDTOT);
1068
+ b.writeUInt32LE(Math.min(_size, Constants.EF_ZIP64_OR_32), offset + Constants.ENDSIZ);
1069
+ b.writeUInt32LE(Math.min(_offset, Constants.EF_ZIP64_OR_32), offset + Constants.ENDOFF);
1070
+ b.writeUInt16LE(_commentLength, offset + Constants.ENDCOM);
1071
+ b.fill(" ", offset + Constants.ENDHDR);
1072
+ return b;
1073
+ },
1074
+ toJSON: function() {
1075
+ const offset = function(nr, len) {
1076
+ let offs = nr.toString(16).toUpperCase();
1077
+ while (offs.length < len) offs = "0" + offs;
1078
+ return "0x" + offs;
1079
+ };
1080
+ return {
1081
+ diskEntries: _volumeEntries,
1082
+ totalEntries: _totalEntries,
1083
+ size: _size + " bytes",
1084
+ offset: offset(_offset, 4),
1085
+ commentLength: _commentLength
1086
+ };
1087
+ },
1088
+ toString: function() {
1089
+ return JSON.stringify(this.toJSON(), null, " ");
1090
+ }
1091
+ };
1092
+ };
1093
+ }
1094
+ });
1095
+
1096
+ // node_modules/adm-zip/headers/index.js
1097
+ var require_headers = __commonJS({
1098
+ "node_modules/adm-zip/headers/index.js"(exports) {
1099
+ exports.EntryHeader = require_entryHeader();
1100
+ exports.MainHeader = require_mainHeader();
1101
+ }
1102
+ });
1103
+
1104
+ // node_modules/adm-zip/methods/deflater.js
1105
+ var require_deflater = __commonJS({
1106
+ "node_modules/adm-zip/methods/deflater.js"(exports, module) {
1107
+ module.exports = function(inbuf) {
1108
+ var zlib = __require("zlib");
1109
+ var opts = { chunkSize: (parseInt(inbuf.length / 1024) + 1) * 1024 };
1110
+ return {
1111
+ deflate: function() {
1112
+ return zlib.deflateRawSync(inbuf, opts);
1113
+ },
1114
+ deflateAsync: function(callback) {
1115
+ var tmp = zlib.createDeflateRaw(opts), parts = [], total = 0;
1116
+ tmp.on("data", function(data) {
1117
+ parts.push(data);
1118
+ total += data.length;
1119
+ });
1120
+ tmp.on("end", function() {
1121
+ var buf = Buffer.alloc(total), written = 0;
1122
+ buf.fill(0);
1123
+ for (var i = 0; i < parts.length; i++) {
1124
+ var part = parts[i];
1125
+ part.copy(buf, written);
1126
+ written += part.length;
1127
+ }
1128
+ callback && callback(buf);
1129
+ });
1130
+ tmp.end(inbuf);
1131
+ }
1132
+ };
1133
+ };
1134
+ }
1135
+ });
1136
+
1137
+ // node_modules/adm-zip/methods/inflater.js
1138
+ var require_inflater = __commonJS({
1139
+ "node_modules/adm-zip/methods/inflater.js"(exports, module) {
1140
+ var version = +(process?.versions?.node ?? "").split(".")[0] || 0;
1141
+ module.exports = function(inbuf, expectedLength) {
1142
+ var zlib = __require("zlib");
1143
+ const option = version >= 15 && expectedLength > 0 ? { maxOutputLength: expectedLength } : {};
1144
+ return {
1145
+ inflate: function() {
1146
+ return zlib.inflateRawSync(inbuf, option);
1147
+ },
1148
+ inflateAsync: function(callback) {
1149
+ var tmp = zlib.createInflateRaw(option), parts = [], total = 0;
1150
+ tmp.on("data", function(data) {
1151
+ parts.push(data);
1152
+ total += data.length;
1153
+ });
1154
+ tmp.on("end", function() {
1155
+ var buf = Buffer.alloc(total), written = 0;
1156
+ buf.fill(0);
1157
+ for (var i = 0; i < parts.length; i++) {
1158
+ var part = parts[i];
1159
+ part.copy(buf, written);
1160
+ written += part.length;
1161
+ }
1162
+ callback && callback(buf);
1163
+ });
1164
+ tmp.end(inbuf);
1165
+ }
1166
+ };
1167
+ };
1168
+ }
1169
+ });
1170
+
1171
+ // node_modules/adm-zip/methods/zipcrypto.js
1172
+ var require_zipcrypto = __commonJS({
1173
+ "node_modules/adm-zip/methods/zipcrypto.js"(exports, module) {
1174
+ "use strict";
1175
+ var { randomFillSync } = __require("crypto");
1176
+ var Errors = require_errors();
1177
+ var crctable = new Uint32Array(256).map((t, crc) => {
1178
+ for (let j = 0; j < 8; j++) {
1179
+ if (0 !== (crc & 1)) {
1180
+ crc = crc >>> 1 ^ 3988292384;
1181
+ } else {
1182
+ crc >>>= 1;
1183
+ }
1184
+ }
1185
+ return crc >>> 0;
1186
+ });
1187
+ var uMul = (a, b) => Math.imul(a, b) >>> 0;
1188
+ var crc32update = (pCrc32, bval) => {
1189
+ return crctable[(pCrc32 ^ bval) & 255] ^ pCrc32 >>> 8;
1190
+ };
1191
+ var genSalt = () => {
1192
+ if ("function" === typeof randomFillSync) {
1193
+ return randomFillSync(Buffer.alloc(12));
1194
+ } else {
1195
+ return genSalt.node();
1196
+ }
1197
+ };
1198
+ genSalt.node = () => {
1199
+ const salt = Buffer.alloc(12);
1200
+ const len = salt.length;
1201
+ for (let i = 0; i < len; i++) salt[i] = Math.random() * 256 & 255;
1202
+ return salt;
1203
+ };
1204
+ var config = {
1205
+ genSalt
1206
+ };
1207
+ function Initkeys(pw) {
1208
+ const pass = Buffer.isBuffer(pw) ? pw : Buffer.from(pw);
1209
+ this.keys = new Uint32Array([305419896, 591751049, 878082192]);
1210
+ for (let i = 0; i < pass.length; i++) {
1211
+ this.updateKeys(pass[i]);
1212
+ }
1213
+ }
1214
+ Initkeys.prototype.updateKeys = function(byteValue) {
1215
+ const keys = this.keys;
1216
+ keys[0] = crc32update(keys[0], byteValue);
1217
+ keys[1] += keys[0] & 255;
1218
+ keys[1] = uMul(keys[1], 134775813) + 1;
1219
+ keys[2] = crc32update(keys[2], keys[1] >>> 24);
1220
+ return byteValue;
1221
+ };
1222
+ Initkeys.prototype.next = function() {
1223
+ const k = (this.keys[2] | 2) >>> 0;
1224
+ return uMul(k, k ^ 1) >> 8 & 255;
1225
+ };
1226
+ function make_decrypter(pwd) {
1227
+ const keys = new Initkeys(pwd);
1228
+ return function(data) {
1229
+ const result = Buffer.alloc(data.length);
1230
+ let pos = 0;
1231
+ for (let c of data) {
1232
+ result[pos++] = keys.updateKeys(c ^ keys.next());
1233
+ }
1234
+ return result;
1235
+ };
1236
+ }
1237
+ function make_encrypter(pwd) {
1238
+ const keys = new Initkeys(pwd);
1239
+ return function(data, result, pos = 0) {
1240
+ if (!result) result = Buffer.alloc(data.length);
1241
+ for (let c of data) {
1242
+ const k = keys.next();
1243
+ result[pos++] = c ^ k;
1244
+ keys.updateKeys(c);
1245
+ }
1246
+ return result;
1247
+ };
1248
+ }
1249
+ function decrypt(data, header, pwd) {
1250
+ if (!data || !Buffer.isBuffer(data) || data.length < 12) {
1251
+ return Buffer.alloc(0);
1252
+ }
1253
+ const decrypter = make_decrypter(pwd);
1254
+ const salt = decrypter(data.slice(0, 12));
1255
+ const verifyByte = (header.flags & 8) === 8 ? header.timeHighByte : header.crc >>> 24;
1256
+ if (salt[11] !== verifyByte) {
1257
+ throw Errors.WRONG_PASSWORD();
1258
+ }
1259
+ return decrypter(data.slice(12));
1260
+ }
1261
+ function _salter(data) {
1262
+ if (Buffer.isBuffer(data) && data.length >= 12) {
1263
+ config.genSalt = function() {
1264
+ return data.slice(0, 12);
1265
+ };
1266
+ } else if (data === "node") {
1267
+ config.genSalt = genSalt.node;
1268
+ } else {
1269
+ config.genSalt = genSalt;
1270
+ }
1271
+ }
1272
+ function encrypt(data, header, pwd, oldlike = false) {
1273
+ if (data == null) data = Buffer.alloc(0);
1274
+ if (!Buffer.isBuffer(data)) data = Buffer.from(data.toString());
1275
+ const encrypter = make_encrypter(pwd);
1276
+ const salt = config.genSalt();
1277
+ salt[11] = header.crc >>> 24 & 255;
1278
+ if (oldlike) salt[10] = header.crc >>> 16 & 255;
1279
+ const result = Buffer.alloc(data.length + 12);
1280
+ encrypter(salt, result);
1281
+ return encrypter(data, result, 12);
1282
+ }
1283
+ module.exports = { decrypt, encrypt, _salter };
1284
+ }
1285
+ });
1286
+
1287
+ // node_modules/adm-zip/methods/index.js
1288
+ var require_methods = __commonJS({
1289
+ "node_modules/adm-zip/methods/index.js"(exports) {
1290
+ exports.Deflater = require_deflater();
1291
+ exports.Inflater = require_inflater();
1292
+ exports.ZipCrypto = require_zipcrypto();
1293
+ }
1294
+ });
1295
+
1296
+ // node_modules/adm-zip/zipEntry.js
1297
+ var require_zipEntry = __commonJS({
1298
+ "node_modules/adm-zip/zipEntry.js"(exports, module) {
1299
+ var Utils = require_util();
1300
+ var Headers = require_headers();
1301
+ var Constants = Utils.Constants;
1302
+ var Methods = require_methods();
1303
+ module.exports = function(options, input) {
1304
+ var _centralHeader = new Headers.EntryHeader(), _entryName = Buffer.alloc(0), _comment = Buffer.alloc(0), _isDirectory = false, uncompressedData = null, _extra = Buffer.alloc(0), _extralocal = Buffer.alloc(0), _efs = true;
1305
+ const opts = options;
1306
+ const decoder = typeof opts.decoder === "object" ? opts.decoder : Utils.decoder;
1307
+ _efs = decoder.hasOwnProperty("efs") ? decoder.efs : false;
1308
+ function getCompressedDataFromZip() {
1309
+ if (!input || !(input instanceof Uint8Array)) {
1310
+ return Buffer.alloc(0);
1311
+ }
1312
+ _extralocal = _centralHeader.loadLocalHeaderFromBinary(input);
1313
+ return input.slice(_centralHeader.realDataOffset, _centralHeader.realDataOffset + _centralHeader.compressedSize);
1314
+ }
1315
+ function crc32OK(data) {
1316
+ const expectedCrc = _centralHeader.flags_desc || _centralHeader.localHeader.flags_desc ? _centralHeader.crc : _centralHeader.localHeader.crc;
1317
+ return Utils.crc32(data) === expectedCrc;
1318
+ }
1319
+ function decompress(async, callback, pass) {
1320
+ if (typeof callback === "undefined" && typeof async === "string") {
1321
+ pass = async;
1322
+ async = void 0;
1323
+ }
1324
+ if (_isDirectory) {
1325
+ if (async && callback) {
1326
+ callback(Buffer.alloc(0), Utils.Errors.DIRECTORY_CONTENT_ERROR());
1327
+ }
1328
+ return Buffer.alloc(0);
1329
+ }
1330
+ var compressedData = getCompressedDataFromZip();
1331
+ if (compressedData.length === 0) {
1332
+ if (async && callback) callback(compressedData);
1333
+ return compressedData;
1334
+ }
1335
+ if (_centralHeader.encrypted) {
1336
+ if ("string" !== typeof pass && !Buffer.isBuffer(pass)) {
1337
+ throw Utils.Errors.INVALID_PASS_PARAM();
1338
+ }
1339
+ compressedData = Methods.ZipCrypto.decrypt(compressedData, _centralHeader, pass);
1340
+ }
1341
+ var data;
1342
+ switch (_centralHeader.method) {
1343
+ case Utils.Constants.STORED:
1344
+ data = Buffer.alloc(compressedData.length);
1345
+ compressedData.copy(data);
1346
+ if (!crc32OK(data)) {
1347
+ if (async && callback) callback(data, Utils.Errors.BAD_CRC());
1348
+ throw Utils.Errors.BAD_CRC();
1349
+ } else {
1350
+ if (async && callback) callback(data);
1351
+ return data;
1352
+ }
1353
+ case Utils.Constants.DEFLATED:
1354
+ var inflater = new Methods.Inflater(compressedData, _centralHeader.size);
1355
+ if (!async) {
1356
+ data = inflater.inflate();
1357
+ if (!crc32OK(data)) {
1358
+ throw Utils.Errors.BAD_CRC(`"${decoder.decode(_entryName)}"`);
1359
+ }
1360
+ return data;
1361
+ } else {
1362
+ inflater.inflateAsync(function(result) {
1363
+ if (callback) {
1364
+ if (!crc32OK(result)) {
1365
+ callback(result, Utils.Errors.BAD_CRC());
1366
+ } else {
1367
+ callback(result);
1368
+ }
1369
+ }
1370
+ });
1371
+ }
1372
+ break;
1373
+ default:
1374
+ if (async && callback) callback(Buffer.alloc(0), Utils.Errors.UNKNOWN_METHOD());
1375
+ throw Utils.Errors.UNKNOWN_METHOD();
1376
+ }
1377
+ }
1378
+ function compress(async, callback) {
1379
+ if ((!uncompressedData || !uncompressedData.length) && Buffer.isBuffer(input)) {
1380
+ if (async && callback) callback(getCompressedDataFromZip());
1381
+ return getCompressedDataFromZip();
1382
+ }
1383
+ if (uncompressedData.length && !_isDirectory) {
1384
+ var compressedData;
1385
+ switch (_centralHeader.method) {
1386
+ case Utils.Constants.STORED:
1387
+ _centralHeader.compressedSize = _centralHeader.size;
1388
+ compressedData = Buffer.alloc(uncompressedData.length);
1389
+ uncompressedData.copy(compressedData);
1390
+ if (async && callback) callback(compressedData);
1391
+ return compressedData;
1392
+ default:
1393
+ case Utils.Constants.DEFLATED:
1394
+ var deflater = new Methods.Deflater(uncompressedData);
1395
+ if (!async) {
1396
+ var deflated = deflater.deflate();
1397
+ _centralHeader.compressedSize = deflated.length;
1398
+ return deflated;
1399
+ } else {
1400
+ deflater.deflateAsync(function(data) {
1401
+ compressedData = Buffer.alloc(data.length);
1402
+ _centralHeader.compressedSize = data.length;
1403
+ data.copy(compressedData);
1404
+ callback && callback(compressedData);
1405
+ });
1406
+ }
1407
+ deflater = null;
1408
+ break;
1409
+ }
1410
+ } else if (async && callback) {
1411
+ callback(Buffer.alloc(0));
1412
+ } else {
1413
+ return Buffer.alloc(0);
1414
+ }
1415
+ }
1416
+ function readUInt64LE(buffer, offset) {
1417
+ return Utils.readBigUInt64LE(buffer, offset);
1418
+ }
1419
+ function parseExtra(data) {
1420
+ try {
1421
+ var offset = 0;
1422
+ var signature, size, part;
1423
+ while (offset + 4 < data.length) {
1424
+ signature = data.readUInt16LE(offset);
1425
+ offset += 2;
1426
+ size = data.readUInt16LE(offset);
1427
+ offset += 2;
1428
+ part = data.slice(offset, offset + size);
1429
+ offset += size;
1430
+ if (Constants.ID_ZIP64 === signature) {
1431
+ parseZip64ExtendedInformation(part);
1432
+ }
1433
+ }
1434
+ } catch (error) {
1435
+ throw Utils.Errors.EXTRA_FIELD_PARSE_ERROR();
1436
+ }
1437
+ }
1438
+ function parseZip64ExtendedInformation(data) {
1439
+ var size, compressedSize, offset, diskNumStart;
1440
+ if (data.length >= Constants.EF_ZIP64_SCOMP) {
1441
+ size = readUInt64LE(data, Constants.EF_ZIP64_SUNCOMP);
1442
+ if (_centralHeader.size === Constants.EF_ZIP64_OR_32) {
1443
+ _centralHeader.size = size;
1444
+ }
1445
+ }
1446
+ if (data.length >= Constants.EF_ZIP64_RHO) {
1447
+ compressedSize = readUInt64LE(data, Constants.EF_ZIP64_SCOMP);
1448
+ if (_centralHeader.compressedSize === Constants.EF_ZIP64_OR_32) {
1449
+ _centralHeader.compressedSize = compressedSize;
1450
+ }
1451
+ }
1452
+ if (data.length >= Constants.EF_ZIP64_DSN) {
1453
+ offset = readUInt64LE(data, Constants.EF_ZIP64_RHO);
1454
+ if (_centralHeader.offset === Constants.EF_ZIP64_OR_32) {
1455
+ _centralHeader.offset = offset;
1456
+ }
1457
+ }
1458
+ if (data.length >= Constants.EF_ZIP64_DSN + 4) {
1459
+ diskNumStart = data.readUInt32LE(Constants.EF_ZIP64_DSN);
1460
+ if (_centralHeader.diskNumStart === Constants.EF_ZIP64_OR_16) {
1461
+ _centralHeader.diskNumStart = diskNumStart;
1462
+ }
1463
+ }
1464
+ }
1465
+ return {
1466
+ get entryName() {
1467
+ return decoder.decode(_entryName);
1468
+ },
1469
+ get rawEntryName() {
1470
+ return _entryName;
1471
+ },
1472
+ set entryName(val) {
1473
+ _entryName = Utils.toBuffer(val, decoder.encode);
1474
+ var lastChar = _entryName[_entryName.length - 1];
1475
+ _isDirectory = lastChar === 47 || lastChar === 92;
1476
+ _centralHeader.fileNameLength = _entryName.length;
1477
+ },
1478
+ get efs() {
1479
+ if (typeof _efs === "function") {
1480
+ return _efs(this.entryName);
1481
+ } else {
1482
+ return _efs;
1483
+ }
1484
+ },
1485
+ get extra() {
1486
+ return _extra;
1487
+ },
1488
+ set extra(val) {
1489
+ _extra = val;
1490
+ _centralHeader.extraLength = val.length;
1491
+ parseExtra(val);
1492
+ },
1493
+ get comment() {
1494
+ return decoder.decode(_comment);
1495
+ },
1496
+ set comment(val) {
1497
+ _comment = Utils.toBuffer(val, decoder.encode);
1498
+ _centralHeader.commentLength = _comment.length;
1499
+ if (_comment.length > 65535) throw Utils.Errors.COMMENT_TOO_LONG();
1500
+ },
1501
+ get name() {
1502
+ const n = decoder.decode(_entryName);
1503
+ return _isDirectory ? n.replace(/[/\\]$/, "").split("/").pop() : n.split("/").pop();
1504
+ },
1505
+ get isDirectory() {
1506
+ return _isDirectory;
1507
+ },
1508
+ getCompressedData: function() {
1509
+ return compress(false, null);
1510
+ },
1511
+ getCompressedDataAsync: function(callback) {
1512
+ compress(true, callback);
1513
+ },
1514
+ setData: function(value) {
1515
+ uncompressedData = Utils.toBuffer(value, Utils.decoder.encode);
1516
+ if (!_isDirectory && uncompressedData.length) {
1517
+ _centralHeader.size = uncompressedData.length;
1518
+ _centralHeader.method = Utils.Constants.DEFLATED;
1519
+ _centralHeader.crc = Utils.crc32(value);
1520
+ _centralHeader.changed = true;
1521
+ } else {
1522
+ _centralHeader.method = Utils.Constants.STORED;
1523
+ }
1524
+ },
1525
+ getData: function(pass) {
1526
+ if (_centralHeader.changed) {
1527
+ return uncompressedData;
1528
+ } else {
1529
+ return decompress(false, null, pass);
1530
+ }
1531
+ },
1532
+ getDataAsync: function(callback, pass) {
1533
+ if (_centralHeader.changed) {
1534
+ callback(uncompressedData);
1535
+ } else {
1536
+ decompress(true, callback, pass);
1537
+ }
1538
+ },
1539
+ set attr(attr) {
1540
+ _centralHeader.attr = attr;
1541
+ },
1542
+ get attr() {
1543
+ return _centralHeader.attr;
1544
+ },
1545
+ set header(data) {
1546
+ _centralHeader.loadFromBinary(data);
1547
+ },
1548
+ get header() {
1549
+ return _centralHeader;
1550
+ },
1551
+ packCentralHeader: function() {
1552
+ _centralHeader.flags_efs = this.efs;
1553
+ _centralHeader.extraLength = _extra.length;
1554
+ var header = _centralHeader.centralHeaderToBinary();
1555
+ var addpos = Utils.Constants.CENHDR;
1556
+ _entryName.copy(header, addpos);
1557
+ addpos += _entryName.length;
1558
+ _extra.copy(header, addpos);
1559
+ addpos += _centralHeader.extraLength;
1560
+ _comment.copy(header, addpos);
1561
+ return header;
1562
+ },
1563
+ packLocalHeader: function() {
1564
+ let addpos = 0;
1565
+ _centralHeader.flags_efs = this.efs;
1566
+ _centralHeader.extraLocalLength = _extralocal.length;
1567
+ const localHeaderBuf = _centralHeader.localHeaderToBinary();
1568
+ const localHeader = Buffer.alloc(localHeaderBuf.length + _entryName.length + _centralHeader.extraLocalLength);
1569
+ localHeaderBuf.copy(localHeader, addpos);
1570
+ addpos += localHeaderBuf.length;
1571
+ _entryName.copy(localHeader, addpos);
1572
+ addpos += _entryName.length;
1573
+ _extralocal.copy(localHeader, addpos);
1574
+ addpos += _extralocal.length;
1575
+ return localHeader;
1576
+ },
1577
+ toJSON: function() {
1578
+ const bytes = function(nr) {
1579
+ return "<" + (nr && nr.length + " bytes buffer" || "null") + ">";
1580
+ };
1581
+ return {
1582
+ entryName: this.entryName,
1583
+ name: this.name,
1584
+ comment: this.comment,
1585
+ isDirectory: this.isDirectory,
1586
+ header: _centralHeader.toJSON(),
1587
+ compressedData: bytes(input),
1588
+ data: bytes(uncompressedData)
1589
+ };
1590
+ },
1591
+ toString: function() {
1592
+ return JSON.stringify(this.toJSON(), null, " ");
1593
+ }
1594
+ };
1595
+ };
1596
+ }
1597
+ });
1598
+
1599
+ // node_modules/adm-zip/zipFile.js
1600
+ var require_zipFile = __commonJS({
1601
+ "node_modules/adm-zip/zipFile.js"(exports, module) {
1602
+ var ZipEntry = require_zipEntry();
1603
+ var Headers = require_headers();
1604
+ var Utils = require_util();
1605
+ module.exports = function(inBuffer, options) {
1606
+ var entryList = [], entryTable = /* @__PURE__ */ Object.create(null), _comment = Buffer.alloc(0), mainHeader = new Headers.MainHeader(), loadedEntries = false;
1607
+ var password = null;
1608
+ const temporary = /* @__PURE__ */ new Set();
1609
+ const opts = options;
1610
+ const { noSort, decoder } = opts;
1611
+ if (inBuffer) {
1612
+ readMainHeader(opts.readEntries);
1613
+ } else {
1614
+ loadedEntries = true;
1615
+ }
1616
+ function makeTemporaryFolders() {
1617
+ const foldersList = /* @__PURE__ */ new Set();
1618
+ for (const elem of Object.keys(entryTable)) {
1619
+ const elements = elem.split("/");
1620
+ elements.pop();
1621
+ if (!elements.length) continue;
1622
+ for (let i = 0; i < elements.length; i++) {
1623
+ const sub = elements.slice(0, i + 1).join("/") + "/";
1624
+ foldersList.add(sub);
1625
+ }
1626
+ }
1627
+ for (const elem of foldersList) {
1628
+ if (!(elem in entryTable)) {
1629
+ const tempfolder = new ZipEntry(opts);
1630
+ tempfolder.entryName = elem;
1631
+ tempfolder.attr = 16;
1632
+ tempfolder.temporary = true;
1633
+ entryList.push(tempfolder);
1634
+ entryTable[tempfolder.entryName] = tempfolder;
1635
+ temporary.add(tempfolder);
1636
+ }
1637
+ }
1638
+ }
1639
+ function readEntries() {
1640
+ loadedEntries = true;
1641
+ entryTable = /* @__PURE__ */ Object.create(null);
1642
+ if (mainHeader.diskEntries > (inBuffer.length - mainHeader.offset) / Utils.Constants.CENHDR) {
1643
+ throw Utils.Errors.DISK_ENTRY_TOO_LARGE();
1644
+ }
1645
+ entryList = new Array(mainHeader.diskEntries);
1646
+ var index = mainHeader.offset;
1647
+ for (var i = 0; i < entryList.length; i++) {
1648
+ var tmp = index, entry = new ZipEntry(opts, inBuffer);
1649
+ entry.header = inBuffer.slice(tmp, tmp += Utils.Constants.CENHDR);
1650
+ entry.entryName = inBuffer.slice(tmp, tmp += entry.header.fileNameLength);
1651
+ if (entry.header.extraLength) {
1652
+ entry.extra = inBuffer.slice(tmp, tmp += entry.header.extraLength);
1653
+ }
1654
+ if (entry.header.commentLength) entry.comment = inBuffer.slice(tmp, tmp + entry.header.commentLength);
1655
+ index += entry.header.centralHeaderSize;
1656
+ entryList[i] = entry;
1657
+ entryTable[entry.entryName] = entry;
1658
+ }
1659
+ temporary.clear();
1660
+ makeTemporaryFolders();
1661
+ }
1662
+ function readMainHeader(readNow) {
1663
+ var i = inBuffer.length - Utils.Constants.ENDHDR, max = Math.max(0, i - 65535), n = max, endStart = inBuffer.length, endOffset = -1, commentEnd = 0;
1664
+ const trailingSpace = typeof opts.trailingSpace === "boolean" ? opts.trailingSpace : false;
1665
+ if (trailingSpace) max = 0;
1666
+ for (i; i >= n; i--) {
1667
+ if (inBuffer[i] !== 80) continue;
1668
+ if (inBuffer.readUInt32LE(i) === Utils.Constants.ENDSIG) {
1669
+ endOffset = i;
1670
+ commentEnd = i;
1671
+ endStart = i + Utils.Constants.ENDHDR;
1672
+ n = i - Utils.Constants.END64HDR;
1673
+ continue;
1674
+ }
1675
+ if (inBuffer.readUInt32LE(i) === Utils.Constants.END64SIG) {
1676
+ n = max;
1677
+ continue;
1678
+ }
1679
+ if (inBuffer.readUInt32LE(i) === Utils.Constants.ZIP64SIG) {
1680
+ endOffset = i;
1681
+ endStart = i + Utils.readBigUInt64LE(inBuffer, i + Utils.Constants.ZIP64SIZE) + Utils.Constants.ZIP64LEAD;
1682
+ break;
1683
+ }
1684
+ }
1685
+ if (endOffset == -1) throw Utils.Errors.INVALID_FORMAT();
1686
+ mainHeader.loadFromBinary(inBuffer.slice(endOffset, endStart));
1687
+ if (mainHeader.commentLength) {
1688
+ _comment = inBuffer.slice(commentEnd + Utils.Constants.ENDHDR);
1689
+ }
1690
+ if (readNow) readEntries();
1691
+ }
1692
+ function sortEntries() {
1693
+ if (entryList.length > 1 && !noSort) {
1694
+ entryList = entryList.map((entry) => ({ entry, key: entry.entryName.toLowerCase() })).sort((a, b) => a.key.localeCompare(b.key)).map((pair) => pair.entry);
1695
+ }
1696
+ }
1697
+ return {
1698
+ /**
1699
+ * Returns an array of ZipEntry objects existent in the current opened archive
1700
+ * @return Array
1701
+ */
1702
+ get entries() {
1703
+ if (!loadedEntries) {
1704
+ readEntries();
1705
+ }
1706
+ return entryList.filter((e) => !temporary.has(e));
1707
+ },
1708
+ /**
1709
+ * Archive comment
1710
+ * @return {String}
1711
+ */
1712
+ get comment() {
1713
+ return decoder.decode(_comment);
1714
+ },
1715
+ set comment(val) {
1716
+ _comment = Utils.toBuffer(val, decoder.encode);
1717
+ mainHeader.commentLength = _comment.length;
1718
+ },
1719
+ getEntryCount: function() {
1720
+ if (!loadedEntries) {
1721
+ return mainHeader.diskEntries;
1722
+ }
1723
+ return entryList.length;
1724
+ },
1725
+ forEach: function(callback) {
1726
+ this.entries.forEach(callback);
1727
+ },
1728
+ /**
1729
+ * Returns a reference to the entry with the given name or null if entry is inexistent
1730
+ *
1731
+ * @param entryName
1732
+ * @return ZipEntry
1733
+ */
1734
+ getEntry: function(entryName) {
1735
+ if (!loadedEntries) {
1736
+ readEntries();
1737
+ }
1738
+ return entryTable[entryName] || null;
1739
+ },
1740
+ /**
1741
+ * Adds the given entry to the entry list
1742
+ *
1743
+ * @param entry
1744
+ */
1745
+ setEntry: function(entry) {
1746
+ if (!loadedEntries) {
1747
+ readEntries();
1748
+ }
1749
+ entryList.push(entry);
1750
+ entryTable[entry.entryName] = entry;
1751
+ mainHeader.totalEntries = entryList.length;
1752
+ },
1753
+ /**
1754
+ * Removes the file with the given name from the entry list.
1755
+ *
1756
+ * If the entry is a directory, then all nested files and directories will be removed
1757
+ * @param entryName
1758
+ * @returns {void}
1759
+ */
1760
+ deleteFile: function(entryName, withsubfolders = true) {
1761
+ if (!loadedEntries) {
1762
+ readEntries();
1763
+ }
1764
+ const entry = entryTable[entryName];
1765
+ const list = this.getEntryChildren(entry, withsubfolders).map((child) => child.entryName);
1766
+ list.forEach(this.deleteEntry);
1767
+ },
1768
+ /**
1769
+ * Removes the entry with the given name from the entry list.
1770
+ *
1771
+ * @param {string} entryName
1772
+ * @returns {void}
1773
+ */
1774
+ deleteEntry: function(entryName) {
1775
+ if (!loadedEntries) {
1776
+ readEntries();
1777
+ }
1778
+ const entry = entryTable[entryName];
1779
+ const index = entryList.indexOf(entry);
1780
+ if (index >= 0) {
1781
+ entryList.splice(index, 1);
1782
+ delete entryTable[entryName];
1783
+ mainHeader.totalEntries = entryList.length;
1784
+ }
1785
+ },
1786
+ /**
1787
+ * Iterates and returns all nested files and directories of the given entry
1788
+ *
1789
+ * @param entry
1790
+ * @return Array
1791
+ */
1792
+ getEntryChildren: function(entry, subfolders = true) {
1793
+ if (!loadedEntries) {
1794
+ readEntries();
1795
+ }
1796
+ if (typeof entry === "object") {
1797
+ if (entry.isDirectory && subfolders) {
1798
+ const list = [];
1799
+ const name = entry.entryName;
1800
+ for (const zipEntry of entryList) {
1801
+ if (zipEntry.entryName.startsWith(name)) {
1802
+ list.push(zipEntry);
1803
+ }
1804
+ }
1805
+ return list;
1806
+ } else {
1807
+ return [entry];
1808
+ }
1809
+ }
1810
+ return [];
1811
+ },
1812
+ /**
1813
+ * How many child elements entry has
1814
+ *
1815
+ * @param {ZipEntry} entry
1816
+ * @return {integer}
1817
+ */
1818
+ getChildCount: function(entry) {
1819
+ if (entry && entry.isDirectory) {
1820
+ const list = this.getEntryChildren(entry);
1821
+ return list.includes(entry) ? list.length - 1 : list.length;
1822
+ }
1823
+ return 0;
1824
+ },
1825
+ /**
1826
+ * Returns the zip file
1827
+ *
1828
+ * @return Buffer
1829
+ */
1830
+ compressToBuffer: function() {
1831
+ if (!loadedEntries) {
1832
+ readEntries();
1833
+ }
1834
+ sortEntries();
1835
+ const dataBlock = [];
1836
+ const headerBlocks = [];
1837
+ let totalSize = 0;
1838
+ let dindex = 0;
1839
+ mainHeader.size = 0;
1840
+ mainHeader.offset = 0;
1841
+ let totalEntries = 0;
1842
+ for (const entry of this.entries) {
1843
+ const compressedData = entry.getCompressedData();
1844
+ entry.header.offset = dindex;
1845
+ const localHeader = entry.packLocalHeader();
1846
+ const dataLength = localHeader.length + compressedData.length;
1847
+ dindex += dataLength;
1848
+ dataBlock.push(localHeader);
1849
+ dataBlock.push(compressedData);
1850
+ const centralHeader = entry.packCentralHeader();
1851
+ headerBlocks.push(centralHeader);
1852
+ mainHeader.size += centralHeader.length;
1853
+ totalSize += dataLength + centralHeader.length;
1854
+ totalEntries++;
1855
+ }
1856
+ totalSize += mainHeader.mainHeaderSize;
1857
+ mainHeader.offset = dindex;
1858
+ mainHeader.totalEntries = totalEntries;
1859
+ dindex = 0;
1860
+ const outBuffer = Buffer.alloc(totalSize);
1861
+ for (const content of dataBlock) {
1862
+ content.copy(outBuffer, dindex);
1863
+ dindex += content.length;
1864
+ }
1865
+ for (const content of headerBlocks) {
1866
+ content.copy(outBuffer, dindex);
1867
+ dindex += content.length;
1868
+ }
1869
+ const mh = mainHeader.toBinary();
1870
+ if (_comment) {
1871
+ _comment.copy(mh, mh.length - _comment.length);
1872
+ }
1873
+ mh.copy(outBuffer, dindex);
1874
+ inBuffer = outBuffer;
1875
+ loadedEntries = false;
1876
+ return outBuffer;
1877
+ },
1878
+ toAsyncBuffer: function(onSuccess, onFail, onItemStart, onItemEnd) {
1879
+ try {
1880
+ if (!loadedEntries) {
1881
+ readEntries();
1882
+ }
1883
+ sortEntries();
1884
+ const dataBlock = [];
1885
+ const centralHeaders = [];
1886
+ let totalSize = 0;
1887
+ let dindex = 0;
1888
+ let totalEntries = 0;
1889
+ mainHeader.size = 0;
1890
+ mainHeader.offset = 0;
1891
+ const compress2Buffer = function(entryLists) {
1892
+ if (entryLists.length > 0) {
1893
+ const entry = entryLists.shift();
1894
+ const name = entry.entryName + entry.extra.toString();
1895
+ if (onItemStart) onItemStart(name);
1896
+ entry.getCompressedDataAsync(function(compressedData) {
1897
+ if (onItemEnd) onItemEnd(name);
1898
+ entry.header.offset = dindex;
1899
+ const localHeader = entry.packLocalHeader();
1900
+ const dataLength = localHeader.length + compressedData.length;
1901
+ dindex += dataLength;
1902
+ dataBlock.push(localHeader);
1903
+ dataBlock.push(compressedData);
1904
+ const centalHeader = entry.packCentralHeader();
1905
+ centralHeaders.push(centalHeader);
1906
+ mainHeader.size += centalHeader.length;
1907
+ totalSize += dataLength + centalHeader.length;
1908
+ totalEntries++;
1909
+ compress2Buffer(entryLists);
1910
+ });
1911
+ } else {
1912
+ totalSize += mainHeader.mainHeaderSize;
1913
+ mainHeader.offset = dindex;
1914
+ mainHeader.totalEntries = totalEntries;
1915
+ dindex = 0;
1916
+ const outBuffer = Buffer.alloc(totalSize);
1917
+ dataBlock.forEach(function(content) {
1918
+ content.copy(outBuffer, dindex);
1919
+ dindex += content.length;
1920
+ });
1921
+ centralHeaders.forEach(function(content) {
1922
+ content.copy(outBuffer, dindex);
1923
+ dindex += content.length;
1924
+ });
1925
+ const mh = mainHeader.toBinary();
1926
+ if (_comment) {
1927
+ _comment.copy(mh, mh.length - _comment.length);
1928
+ }
1929
+ mh.copy(outBuffer, dindex);
1930
+ inBuffer = outBuffer;
1931
+ loadedEntries = false;
1932
+ onSuccess(outBuffer);
1933
+ }
1934
+ };
1935
+ compress2Buffer(Array.from(this.entries));
1936
+ } catch (e) {
1937
+ onFail(e);
1938
+ }
1939
+ }
1940
+ };
1941
+ };
1942
+ }
1943
+ });
1944
+
1945
+ // node_modules/adm-zip/adm-zip.js
1946
+ var require_adm_zip = __commonJS({
1947
+ "node_modules/adm-zip/adm-zip.js"(exports, module) {
1948
+ var Utils = require_util();
1949
+ var pth = __require("path");
1950
+ var ZipEntry = require_zipEntry();
1951
+ var ZipFile = require_zipFile();
1952
+ var get_Bool = (...val) => Utils.findLast(val, (c) => typeof c === "boolean");
1953
+ var get_Str = (...val) => Utils.findLast(val, (c) => typeof c === "string");
1954
+ var get_Fun = (...val) => Utils.findLast(val, (c) => typeof c === "function");
1955
+ var defaultOptions = {
1956
+ // option "noSort" : if true it disables files sorting
1957
+ noSort: false,
1958
+ // read entries during load (initial loading may be slower)
1959
+ readEntries: false,
1960
+ // default method is none
1961
+ method: Utils.Constants.NONE,
1962
+ // file system
1963
+ fs: null
1964
+ };
1965
+ module.exports = function(input, options) {
1966
+ let inBuffer = null;
1967
+ const opts = Object.assign(/* @__PURE__ */ Object.create(null), defaultOptions);
1968
+ if (input && "object" === typeof input) {
1969
+ if (!(input instanceof Uint8Array)) {
1970
+ Object.assign(opts, input);
1971
+ input = opts.input ? opts.input : void 0;
1972
+ if (opts.input) delete opts.input;
1973
+ }
1974
+ if (Buffer.isBuffer(input)) {
1975
+ inBuffer = input;
1976
+ opts.method = Utils.Constants.BUFFER;
1977
+ input = void 0;
1978
+ }
1979
+ }
1980
+ Object.assign(opts, options);
1981
+ const filetools = new Utils(opts);
1982
+ const applyDirAttributes = (dirEntries) => {
1983
+ dirEntries.filter((d) => d.attr).sort((a, b) => b.path.length - a.path.length).forEach((d) => filetools.fs.chmodSync(d.path, d.attr));
1984
+ };
1985
+ if (typeof opts.decoder !== "object" || typeof opts.decoder.encode !== "function" || typeof opts.decoder.decode !== "function") {
1986
+ opts.decoder = Utils.decoder;
1987
+ }
1988
+ if (input && "string" === typeof input) {
1989
+ if (filetools.fs.existsSync(input)) {
1990
+ opts.method = Utils.Constants.FILE;
1991
+ opts.filename = input;
1992
+ inBuffer = filetools.fs.readFileSync(input);
1993
+ } else {
1994
+ throw Utils.Errors.INVALID_FILENAME();
1995
+ }
1996
+ }
1997
+ const _zip = new ZipFile(inBuffer, opts);
1998
+ const { canonical, sanitize, zipnamefix } = Utils;
1999
+ function getEntry(entry) {
2000
+ if (entry && _zip) {
2001
+ var item;
2002
+ if (typeof entry === "string") item = _zip.getEntry(pth.posix.normalize(entry));
2003
+ if (typeof entry === "object" && typeof entry.entryName !== "undefined" && typeof entry.header !== "undefined") item = _zip.getEntry(entry.entryName);
2004
+ if (item) {
2005
+ return item;
2006
+ }
2007
+ }
2008
+ return null;
2009
+ }
2010
+ function fixPath(zipPath) {
2011
+ const { join, normalize, sep } = pth.posix;
2012
+ return join(pth.isAbsolute(zipPath) ? "/" : ".", normalize(sep + zipPath.split("\\").join(sep) + sep));
2013
+ }
2014
+ function filenameFilter(filterfn) {
2015
+ if (filterfn instanceof RegExp) {
2016
+ return /* @__PURE__ */ (function(rx) {
2017
+ return function(filename) {
2018
+ return rx.test(filename);
2019
+ };
2020
+ })(filterfn);
2021
+ } else if ("function" !== typeof filterfn) {
2022
+ return () => true;
2023
+ }
2024
+ return filterfn;
2025
+ }
2026
+ const relativePath = (local, entry) => {
2027
+ let lastChar = entry.slice(-1);
2028
+ lastChar = lastChar === filetools.sep ? filetools.sep : "";
2029
+ return pth.relative(local, entry) + lastChar;
2030
+ };
2031
+ return {
2032
+ /**
2033
+ * Extracts the given entry from the archive and returns the content as a Buffer object
2034
+ * @param {ZipEntry|string} entry ZipEntry object or String with the full path of the entry
2035
+ * @param {Buffer|string} [pass] - password
2036
+ * @return Buffer or Null in case of error
2037
+ */
2038
+ readFile: function(entry, pass) {
2039
+ var item = getEntry(entry);
2040
+ return item && item.getData(pass) || null;
2041
+ },
2042
+ /**
2043
+ * Returns how many child elements has on entry (directories) on files it is always 0
2044
+ * @param {ZipEntry|string} entry ZipEntry object or String with the full path of the entry
2045
+ * @returns {integer}
2046
+ */
2047
+ childCount: function(entry) {
2048
+ const item = getEntry(entry);
2049
+ if (item) {
2050
+ return _zip.getChildCount(item);
2051
+ }
2052
+ },
2053
+ /**
2054
+ * Asynchronous readFile
2055
+ * @param {ZipEntry|string} entry ZipEntry object or String with the full path of the entry
2056
+ * @param {callback} callback
2057
+ *
2058
+ * @return Buffer or Null in case of error
2059
+ */
2060
+ readFileAsync: function(entry, callback) {
2061
+ var item = getEntry(entry);
2062
+ if (item) {
2063
+ item.getDataAsync(callback);
2064
+ } else {
2065
+ callback(null, "getEntry failed for:" + entry);
2066
+ }
2067
+ },
2068
+ /**
2069
+ * Extracts the given entry from the archive and returns the content as plain text in the given encoding
2070
+ * @param {ZipEntry|string} entry - ZipEntry object or String with the full path of the entry
2071
+ * @param {string} encoding - Optional. If no encoding is specified utf8 is used
2072
+ *
2073
+ * @return String
2074
+ */
2075
+ readAsText: function(entry, encoding) {
2076
+ var item = getEntry(entry);
2077
+ if (item) {
2078
+ var data = item.getData();
2079
+ if (data && data.length) {
2080
+ return data.toString(encoding || "utf8");
2081
+ }
2082
+ }
2083
+ return "";
2084
+ },
2085
+ /**
2086
+ * Asynchronous readAsText
2087
+ * @param {ZipEntry|string} entry ZipEntry object or String with the full path of the entry
2088
+ * @param {callback} callback
2089
+ * @param {string} [encoding] - Optional. If no encoding is specified utf8 is used
2090
+ *
2091
+ * @return String
2092
+ */
2093
+ readAsTextAsync: function(entry, callback, encoding) {
2094
+ var item = getEntry(entry);
2095
+ if (item) {
2096
+ item.getDataAsync(function(data, err) {
2097
+ if (err) {
2098
+ callback(data, err);
2099
+ return;
2100
+ }
2101
+ if (data && data.length) {
2102
+ callback(data.toString(encoding || "utf8"));
2103
+ } else {
2104
+ callback("");
2105
+ }
2106
+ });
2107
+ } else {
2108
+ callback("");
2109
+ }
2110
+ },
2111
+ /**
2112
+ * Remove the entry from the file or the entry and all it's nested directories and files if the given entry is a directory
2113
+ *
2114
+ * @param {ZipEntry|string} entry
2115
+ * @param {boolean} withsubfolders
2116
+ * @returns {void}
2117
+ */
2118
+ deleteFile: function(entry, withsubfolders = true) {
2119
+ var item = getEntry(entry);
2120
+ if (item) {
2121
+ _zip.deleteFile(item.entryName, withsubfolders);
2122
+ }
2123
+ },
2124
+ /**
2125
+ * Remove the entry from the file or directory without affecting any nested entries
2126
+ *
2127
+ * @param {ZipEntry|string} entry
2128
+ * @returns {void}
2129
+ */
2130
+ deleteEntry: function(entry) {
2131
+ var item = getEntry(entry);
2132
+ if (item) {
2133
+ _zip.deleteEntry(item.entryName);
2134
+ }
2135
+ },
2136
+ /**
2137
+ * Adds a comment to the zip. The zip must be rewritten after adding the comment.
2138
+ *
2139
+ * @param {string} comment
2140
+ */
2141
+ addZipComment: function(comment) {
2142
+ _zip.comment = comment;
2143
+ },
2144
+ /**
2145
+ * Returns the zip comment
2146
+ *
2147
+ * @return String
2148
+ */
2149
+ getZipComment: function() {
2150
+ return _zip.comment || "";
2151
+ },
2152
+ /**
2153
+ * Adds a comment to a specified zipEntry. The zip must be rewritten after adding the comment
2154
+ * The comment cannot exceed 65535 characters in length
2155
+ *
2156
+ * @param {ZipEntry} entry
2157
+ * @param {string} comment
2158
+ */
2159
+ addZipEntryComment: function(entry, comment) {
2160
+ var item = getEntry(entry);
2161
+ if (item) {
2162
+ item.comment = comment;
2163
+ }
2164
+ },
2165
+ /**
2166
+ * Returns the comment of the specified entry
2167
+ *
2168
+ * @param {ZipEntry} entry
2169
+ * @return String
2170
+ */
2171
+ getZipEntryComment: function(entry) {
2172
+ var item = getEntry(entry);
2173
+ if (item) {
2174
+ return item.comment || "";
2175
+ }
2176
+ return "";
2177
+ },
2178
+ /**
2179
+ * Updates the content of an existing entry inside the archive. The zip must be rewritten after updating the content
2180
+ *
2181
+ * @param {ZipEntry} entry
2182
+ * @param {Buffer} content
2183
+ */
2184
+ updateFile: function(entry, content) {
2185
+ var item = getEntry(entry);
2186
+ if (item) {
2187
+ item.setData(content);
2188
+ }
2189
+ },
2190
+ /**
2191
+ * Adds a file from the disk to the archive
2192
+ *
2193
+ * @param {string} localPath File to add to zip
2194
+ * @param {string} [zipPath] Optional path inside the zip
2195
+ * @param {string} [zipName] Optional name for the file
2196
+ * @param {string} [comment] Optional file comment
2197
+ */
2198
+ addLocalFile: function(localPath, zipPath, zipName, comment) {
2199
+ if (filetools.fs.existsSync(localPath)) {
2200
+ zipPath = zipPath ? fixPath(zipPath) : "";
2201
+ const p = pth.win32.basename(pth.win32.normalize(localPath));
2202
+ zipPath += zipName ? zipName : p;
2203
+ const _attr = filetools.fs.statSync(localPath);
2204
+ const data = _attr.isFile() ? filetools.fs.readFileSync(localPath) : Buffer.alloc(0);
2205
+ if (_attr.isDirectory()) zipPath += filetools.sep;
2206
+ this.addFile(zipPath, data, comment, _attr);
2207
+ } else {
2208
+ throw Utils.Errors.FILE_NOT_FOUND(localPath);
2209
+ }
2210
+ },
2211
+ /**
2212
+ * Callback for showing if everything was done.
2213
+ *
2214
+ * @callback doneCallback
2215
+ * @param {Error} err - Error object
2216
+ * @param {boolean} done - was request fully completed
2217
+ */
2218
+ /**
2219
+ * Adds a file from the disk to the archive
2220
+ *
2221
+ * @param {(object|string)} options - options object, if it is string it us used as localPath.
2222
+ * @param {string} options.localPath - Local path to the file.
2223
+ * @param {string} [options.comment] - Optional file comment.
2224
+ * @param {string} [options.zipPath] - Optional path inside the zip
2225
+ * @param {string} [options.zipName] - Optional name for the file
2226
+ * @param {doneCallback} callback - The callback that handles the response.
2227
+ */
2228
+ addLocalFileAsync: function(options2, callback) {
2229
+ options2 = typeof options2 === "object" ? options2 : { localPath: options2 };
2230
+ const localPath = pth.resolve(options2.localPath);
2231
+ const { comment } = options2;
2232
+ let { zipPath, zipName } = options2;
2233
+ const self = this;
2234
+ filetools.fs.stat(localPath, function(err, stats) {
2235
+ if (err) return callback(err, false);
2236
+ zipPath = zipPath ? fixPath(zipPath) : "";
2237
+ const p = pth.win32.basename(pth.win32.normalize(localPath));
2238
+ zipPath += zipName ? zipName : p;
2239
+ if (stats.isFile()) {
2240
+ filetools.fs.readFile(localPath, function(err2, data) {
2241
+ if (err2) return callback(err2, false);
2242
+ self.addFile(zipPath, data, comment, stats);
2243
+ return setImmediate(callback, void 0, true);
2244
+ });
2245
+ } else if (stats.isDirectory()) {
2246
+ zipPath += filetools.sep;
2247
+ self.addFile(zipPath, Buffer.alloc(0), comment, stats);
2248
+ return setImmediate(callback, void 0, true);
2249
+ }
2250
+ });
2251
+ },
2252
+ /**
2253
+ * Adds a local directory and all its nested files and directories to the archive
2254
+ *
2255
+ * @param {string} localPath - local path to the folder
2256
+ * @param {string} [zipPath] - optional path inside zip
2257
+ * @param {(RegExp|function)} [filter] - optional RegExp or Function if files match will be included.
2258
+ */
2259
+ addLocalFolder: function(localPath, zipPath, filter) {
2260
+ filter = filenameFilter(filter);
2261
+ zipPath = zipPath ? fixPath(zipPath) : "";
2262
+ localPath = pth.normalize(localPath);
2263
+ if (filetools.fs.existsSync(localPath)) {
2264
+ const items = filetools.findFiles(localPath);
2265
+ const self = this;
2266
+ if (items.length) {
2267
+ for (const filepath of items) {
2268
+ const p = pth.join(zipPath, relativePath(localPath, filepath));
2269
+ if (filter(p)) {
2270
+ self.addLocalFile(filepath, pth.dirname(p));
2271
+ }
2272
+ }
2273
+ }
2274
+ } else {
2275
+ throw Utils.Errors.FILE_NOT_FOUND(localPath);
2276
+ }
2277
+ },
2278
+ /**
2279
+ * Asynchronous addLocalFolder
2280
+ * @param {string} localPath
2281
+ * @param {callback} callback
2282
+ * @param {string} [zipPath] optional path inside zip
2283
+ * @param {RegExp|function} [filter] optional RegExp or Function if files match will
2284
+ * be included.
2285
+ */
2286
+ addLocalFolderAsync: function(localPath, callback, zipPath, filter) {
2287
+ filter = filenameFilter(filter);
2288
+ zipPath = zipPath ? fixPath(zipPath) : "";
2289
+ localPath = pth.normalize(localPath);
2290
+ var self = this;
2291
+ filetools.fs.open(localPath, "r", function(err) {
2292
+ if (err && err.code === "ENOENT") {
2293
+ callback(void 0, Utils.Errors.FILE_NOT_FOUND(localPath));
2294
+ } else if (err) {
2295
+ callback(void 0, err);
2296
+ } else {
2297
+ var items = filetools.findFiles(localPath);
2298
+ var i = -1;
2299
+ var next = function() {
2300
+ i += 1;
2301
+ if (i < items.length) {
2302
+ var filepath = items[i];
2303
+ var p = relativePath(localPath, filepath).split("\\").join("/");
2304
+ p = p.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^\x20-\x7E]/g, "");
2305
+ if (filter(p)) {
2306
+ filetools.fs.stat(filepath, function(er0, stats) {
2307
+ if (er0) callback(void 0, er0);
2308
+ if (stats.isFile()) {
2309
+ filetools.fs.readFile(filepath, function(er1, data) {
2310
+ if (er1) {
2311
+ callback(void 0, er1);
2312
+ } else {
2313
+ self.addFile(zipPath + p, data, "", stats);
2314
+ next();
2315
+ }
2316
+ });
2317
+ } else {
2318
+ self.addFile(zipPath + p + "/", Buffer.alloc(0), "", stats);
2319
+ next();
2320
+ }
2321
+ });
2322
+ } else {
2323
+ process.nextTick(() => {
2324
+ next();
2325
+ });
2326
+ }
2327
+ } else {
2328
+ callback(true, void 0);
2329
+ }
2330
+ };
2331
+ next();
2332
+ }
2333
+ });
2334
+ },
2335
+ /**
2336
+ * Adds a local directory and all its nested files and directories to the archive
2337
+ *
2338
+ * @param {object | string} options - options object, if it is string it us used as localPath.
2339
+ * @param {string} options.localPath - Local path to the folder.
2340
+ * @param {string} [options.zipPath] - optional path inside zip.
2341
+ * @param {RegExp|function} [options.filter] - optional RegExp or Function if files match will be included.
2342
+ * @param {function|string} [options.namefix] - optional function to help fix filename
2343
+ * @param {doneCallback} callback - The callback that handles the response.
2344
+ *
2345
+ */
2346
+ addLocalFolderAsync2: function(options2, callback) {
2347
+ const self = this;
2348
+ options2 = typeof options2 === "object" ? options2 : { localPath: options2 };
2349
+ const localPath = pth.resolve(fixPath(options2.localPath));
2350
+ let { zipPath, filter, namefix } = options2;
2351
+ if (filter instanceof RegExp) {
2352
+ filter = /* @__PURE__ */ (function(rx) {
2353
+ return function(filename) {
2354
+ return rx.test(filename);
2355
+ };
2356
+ })(filter);
2357
+ } else if ("function" !== typeof filter) {
2358
+ filter = function() {
2359
+ return true;
2360
+ };
2361
+ }
2362
+ zipPath = zipPath ? fixPath(zipPath) : "";
2363
+ if (namefix === "latin1") {
2364
+ namefix = (str) => str.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^\x20-\x7E]/g, "");
2365
+ }
2366
+ if (typeof namefix !== "function") namefix = (str) => str;
2367
+ const relPathFix = (entry) => pth.join(zipPath, namefix(relativePath(localPath, entry)));
2368
+ const fileNameFix = (entry) => pth.win32.basename(pth.win32.normalize(namefix(entry)));
2369
+ filetools.fs.open(localPath, "r", function(err) {
2370
+ if (err && err.code === "ENOENT") {
2371
+ callback(void 0, Utils.Errors.FILE_NOT_FOUND(localPath));
2372
+ } else if (err) {
2373
+ callback(void 0, err);
2374
+ } else {
2375
+ filetools.findFilesAsync(localPath, function(err2, fileEntries) {
2376
+ if (err2) return callback(err2);
2377
+ fileEntries = fileEntries.filter((dir) => filter(relPathFix(dir)));
2378
+ if (!fileEntries.length) callback(void 0, false);
2379
+ setImmediate(
2380
+ fileEntries.reverse().reduce(function(next, entry) {
2381
+ return function(err3, done) {
2382
+ if (err3 || done === false) return setImmediate(next, err3, false);
2383
+ self.addLocalFileAsync(
2384
+ {
2385
+ localPath: entry,
2386
+ zipPath: pth.dirname(relPathFix(entry)),
2387
+ zipName: fileNameFix(entry)
2388
+ },
2389
+ next
2390
+ );
2391
+ };
2392
+ }, callback)
2393
+ );
2394
+ });
2395
+ }
2396
+ });
2397
+ },
2398
+ /**
2399
+ * Adds a local directory and all its nested files and directories to the archive
2400
+ *
2401
+ * @param {string} localPath - path where files will be extracted
2402
+ * @param {object} props - optional properties
2403
+ * @param {string} [props.zipPath] - optional path inside zip
2404
+ * @param {RegExp|function} [props.filter] - optional RegExp or Function if files match will be included.
2405
+ * @param {function|string} [props.namefix] - optional function to help fix filename
2406
+ */
2407
+ addLocalFolderPromise: function(localPath, props) {
2408
+ return new Promise((resolve, reject) => {
2409
+ this.addLocalFolderAsync2(Object.assign({ localPath }, props), (err, done) => {
2410
+ if (err) reject(err);
2411
+ if (done) resolve(this);
2412
+ });
2413
+ });
2414
+ },
2415
+ /**
2416
+ * Allows you to create a entry (file or directory) in the zip file.
2417
+ * If you want to create a directory the entryName must end in / and a null buffer should be provided.
2418
+ * Comment and attributes are optional
2419
+ *
2420
+ * @param {string} entryName
2421
+ * @param {Buffer | string} content - file content as buffer or utf8 coded string
2422
+ * @param {string} [comment] - file comment
2423
+ * @param {number | object} [attr] - number as unix file permissions, object as filesystem Stats object
2424
+ */
2425
+ addFile: function(entryName, content, comment, attr) {
2426
+ entryName = zipnamefix(entryName);
2427
+ let entry = getEntry(entryName);
2428
+ const update = entry != null;
2429
+ if (!update) {
2430
+ entry = new ZipEntry(opts);
2431
+ entry.entryName = entryName;
2432
+ }
2433
+ entry.comment = comment || "";
2434
+ const isStat = "object" === typeof attr && attr instanceof filetools.fs.Stats;
2435
+ if (isStat) {
2436
+ entry.header.time = attr.mtime;
2437
+ }
2438
+ var fileattr = entry.isDirectory ? 16 : 0;
2439
+ let unix = entry.isDirectory ? 16384 : 32768;
2440
+ if (isStat) {
2441
+ unix |= 4095 & attr.mode;
2442
+ } else if ("number" === typeof attr) {
2443
+ unix |= 4095 & attr;
2444
+ } else {
2445
+ unix |= entry.isDirectory ? 493 : 420;
2446
+ }
2447
+ fileattr = (fileattr | unix << 16) >>> 0;
2448
+ entry.attr = fileattr;
2449
+ entry.setData(content);
2450
+ if (!update) _zip.setEntry(entry);
2451
+ return entry;
2452
+ },
2453
+ /**
2454
+ * Returns an array of ZipEntry objects representing the files and folders inside the archive
2455
+ *
2456
+ * @param {string} [password]
2457
+ * @returns Array
2458
+ */
2459
+ getEntries: function(password) {
2460
+ _zip.password = password;
2461
+ return _zip ? _zip.entries : [];
2462
+ },
2463
+ /**
2464
+ * Returns a ZipEntry object representing the file or folder specified by ``name``.
2465
+ *
2466
+ * @param {string} name
2467
+ * @return ZipEntry
2468
+ */
2469
+ getEntry: function(name) {
2470
+ return getEntry(name);
2471
+ },
2472
+ getEntryCount: function() {
2473
+ return _zip.getEntryCount();
2474
+ },
2475
+ forEach: function(callback) {
2476
+ return _zip.forEach(callback);
2477
+ },
2478
+ /**
2479
+ * Extracts the given entry to the given targetPath
2480
+ * If the entry is a directory inside the archive, the entire directory and it's subdirectories will be extracted
2481
+ *
2482
+ * @param {string|ZipEntry} entry - ZipEntry object or String with the full path of the entry
2483
+ * @param {string} targetPath - Target folder where to write the file
2484
+ * @param {boolean} [maintainEntryPath=true] - If maintainEntryPath is true and the entry is inside a folder, the entry folder will be created in targetPath as well. Default is TRUE
2485
+ * @param {boolean} [overwrite=false] - If the file already exists at the target path, the file will be overwriten if this is true.
2486
+ * @param {boolean} [keepOriginalPermission=false] - The file will be set as the permission from the entry if this is true.
2487
+ * @param {string} [outFileName] - String If set will override the filename of the extracted file (Only works if the entry is a file)
2488
+ *
2489
+ * @return Boolean
2490
+ */
2491
+ extractEntryTo: function(entry, targetPath, maintainEntryPath, overwrite, keepOriginalPermission, outFileName) {
2492
+ overwrite = get_Bool(false, overwrite);
2493
+ keepOriginalPermission = get_Bool(false, keepOriginalPermission);
2494
+ maintainEntryPath = get_Bool(true, maintainEntryPath);
2495
+ outFileName = get_Str(keepOriginalPermission, outFileName);
2496
+ var item = getEntry(entry);
2497
+ if (!item) {
2498
+ throw Utils.Errors.NO_ENTRY();
2499
+ }
2500
+ var entryName = canonical(item.entryName);
2501
+ var target = sanitize(targetPath, outFileName && !item.isDirectory ? canonical(outFileName) : maintainEntryPath ? entryName : pth.basename(entryName));
2502
+ if (item.isDirectory) {
2503
+ var children = _zip.getEntryChildren(item);
2504
+ children.forEach(function(child) {
2505
+ if (child.isDirectory) return;
2506
+ var content2 = child.getData();
2507
+ if (!content2) {
2508
+ throw Utils.Errors.CANT_EXTRACT_FILE();
2509
+ }
2510
+ var name = canonical(maintainEntryPath ? child.entryName : child.entryName.substring(item.entryName.length));
2511
+ var childName = sanitize(targetPath, name);
2512
+ const fileAttr2 = keepOriginalPermission ? child.header.fileAttr : void 0;
2513
+ filetools.writeFileTo(childName, content2, overwrite, fileAttr2);
2514
+ });
2515
+ return true;
2516
+ }
2517
+ var content = item.getData(_zip.password);
2518
+ if (!content) throw Utils.Errors.CANT_EXTRACT_FILE();
2519
+ if (filetools.fs.existsSync(target) && !overwrite) {
2520
+ throw Utils.Errors.CANT_OVERRIDE();
2521
+ }
2522
+ const fileAttr = keepOriginalPermission ? entry.header.fileAttr : void 0;
2523
+ filetools.writeFileTo(target, content, overwrite, fileAttr);
2524
+ return true;
2525
+ },
2526
+ /**
2527
+ * Test the archive
2528
+ * @param {string} [pass]
2529
+ */
2530
+ test: function(pass) {
2531
+ if (!_zip) {
2532
+ return false;
2533
+ }
2534
+ for (var entry of _zip.entries) {
2535
+ try {
2536
+ if (entry.isDirectory) {
2537
+ continue;
2538
+ }
2539
+ var content = entry.getData(pass);
2540
+ if (!content) {
2541
+ return false;
2542
+ }
2543
+ } catch (err) {
2544
+ return false;
2545
+ }
2546
+ }
2547
+ return true;
2548
+ },
2549
+ /**
2550
+ * Extracts the entire archive to the given location
2551
+ *
2552
+ * @param {string} targetPath Target location
2553
+ * @param {boolean} [overwrite=false] If the file already exists at the target path, the file will be overwriten if this is true.
2554
+ * Default is FALSE
2555
+ * @param {boolean} [keepOriginalPermission=false] The file will be set as the permission from the entry if this is true.
2556
+ * Default is FALSE
2557
+ * @param {string|Buffer} [pass] password
2558
+ */
2559
+ extractAllTo: function(targetPath, overwrite, keepOriginalPermission, pass) {
2560
+ keepOriginalPermission = get_Bool(false, keepOriginalPermission);
2561
+ pass = get_Str(keepOriginalPermission, pass);
2562
+ overwrite = get_Bool(false, overwrite);
2563
+ if (!_zip) throw Utils.Errors.NO_ZIP();
2564
+ const dirEntries = [];
2565
+ _zip.entries.forEach(function(entry) {
2566
+ var entryName = sanitize(targetPath, canonical(entry.entryName));
2567
+ if (entry.isDirectory) {
2568
+ filetools.makeDir(entryName);
2569
+ if (keepOriginalPermission) dirEntries.push({ path: entryName, attr: entry.header.fileAttr });
2570
+ return;
2571
+ }
2572
+ var content = entry.getData(pass);
2573
+ if (!content) {
2574
+ throw Utils.Errors.CANT_EXTRACT_FILE();
2575
+ }
2576
+ const fileAttr = keepOriginalPermission ? entry.header.fileAttr : void 0;
2577
+ filetools.writeFileTo(entryName, content, overwrite, fileAttr);
2578
+ try {
2579
+ filetools.fs.utimesSync(entryName, entry.header.time, entry.header.time);
2580
+ } catch (err) {
2581
+ }
2582
+ });
2583
+ applyDirAttributes(dirEntries);
2584
+ },
2585
+ /**
2586
+ * Asynchronous extractAllTo
2587
+ *
2588
+ * @param {string} targetPath Target location
2589
+ * @param {boolean} [overwrite=false] If the file already exists at the target path, the file will be overwriten if this is true.
2590
+ * Default is FALSE
2591
+ * @param {boolean} [keepOriginalPermission=false] The file will be set as the permission from the entry if this is true.
2592
+ * Default is FALSE
2593
+ * @param {function} callback The callback will be executed when all entries are extracted successfully or any error is thrown.
2594
+ */
2595
+ extractAllToAsync: function(targetPath, overwrite, keepOriginalPermission, callback) {
2596
+ callback = get_Fun(overwrite, keepOriginalPermission, callback);
2597
+ keepOriginalPermission = get_Bool(false, keepOriginalPermission);
2598
+ overwrite = get_Bool(false, overwrite);
2599
+ if (!callback) {
2600
+ return new Promise((resolve, reject) => {
2601
+ this.extractAllToAsync(targetPath, overwrite, keepOriginalPermission, function(err) {
2602
+ if (err) {
2603
+ reject(err);
2604
+ } else {
2605
+ resolve(this);
2606
+ }
2607
+ });
2608
+ });
2609
+ }
2610
+ if (!_zip) {
2611
+ callback(Utils.Errors.NO_ZIP());
2612
+ return;
2613
+ }
2614
+ targetPath = pth.resolve(targetPath);
2615
+ const getPath = (entry) => sanitize(targetPath, pth.normalize(canonical(entry.entryName)));
2616
+ const getError = (msg, file) => new Error(msg + ': "' + file + '"');
2617
+ const dirEntries = [];
2618
+ const fileEntries = [];
2619
+ _zip.entries.forEach((e) => {
2620
+ if (e.isDirectory) {
2621
+ dirEntries.push(e);
2622
+ } else {
2623
+ fileEntries.push(e);
2624
+ }
2625
+ });
2626
+ const deferredDirAttr = [];
2627
+ for (const entry of dirEntries) {
2628
+ const dirPath = getPath(entry);
2629
+ const dirAttr = keepOriginalPermission ? entry.header.fileAttr : void 0;
2630
+ try {
2631
+ filetools.makeDir(dirPath);
2632
+ } catch (er) {
2633
+ callback(getError("Unable to create folder", dirPath));
2634
+ continue;
2635
+ }
2636
+ if (dirAttr) deferredDirAttr.push({ path: dirPath, attr: dirAttr });
2637
+ try {
2638
+ filetools.fs.utimesSync(dirPath, entry.header.time, entry.header.time);
2639
+ } catch (er) {
2640
+ }
2641
+ }
2642
+ const done = (err) => {
2643
+ if (!err) {
2644
+ try {
2645
+ applyDirAttributes(deferredDirAttr);
2646
+ } catch (er) {
2647
+ return callback(getError("Unable to set folder permissions", er.path || ""));
2648
+ }
2649
+ }
2650
+ callback(err);
2651
+ };
2652
+ fileEntries.reverse().reduce(function(next, entry) {
2653
+ return function(err) {
2654
+ if (err) {
2655
+ next(err);
2656
+ } else {
2657
+ const entryName = pth.normalize(canonical(entry.entryName));
2658
+ const filePath = sanitize(targetPath, entryName);
2659
+ entry.getDataAsync(function(content, err_1) {
2660
+ if (err_1) {
2661
+ next(err_1);
2662
+ } else if (!content) {
2663
+ next(Utils.Errors.CANT_EXTRACT_FILE());
2664
+ } else {
2665
+ const fileAttr = keepOriginalPermission ? entry.header.fileAttr : void 0;
2666
+ filetools.writeFileToAsync(filePath, content, overwrite, fileAttr, function(succ) {
2667
+ if (!succ) {
2668
+ return next(getError("Unable to write file", filePath));
2669
+ }
2670
+ filetools.fs.utimes(filePath, entry.header.time, entry.header.time, function() {
2671
+ next();
2672
+ });
2673
+ });
2674
+ }
2675
+ });
2676
+ }
2677
+ };
2678
+ }, done)();
2679
+ },
2680
+ /**
2681
+ * Writes the newly created zip file to disk at the specified location or if a zip was opened and no ``targetFileName`` is provided, it will overwrite the opened zip
2682
+ *
2683
+ * @param {string} targetFileName
2684
+ * @param {function} callback
2685
+ */
2686
+ writeZip: function(targetFileName, callback) {
2687
+ if (arguments.length === 1) {
2688
+ if (typeof targetFileName === "function") {
2689
+ callback = targetFileName;
2690
+ targetFileName = "";
2691
+ }
2692
+ }
2693
+ if (!targetFileName && opts.filename) {
2694
+ targetFileName = opts.filename;
2695
+ }
2696
+ if (!targetFileName) return;
2697
+ var zipData = _zip.compressToBuffer();
2698
+ if (zipData) {
2699
+ var ok = filetools.writeFileTo(targetFileName, zipData, true);
2700
+ if (typeof callback === "function") callback(!ok ? new Error("failed") : null, "");
2701
+ }
2702
+ },
2703
+ /**
2704
+ *
2705
+ * @param {string} targetFileName
2706
+ * @param {object} [props]
2707
+ * @param {boolean} [props.overwrite=true] If the file already exists at the target path, the file will be overwriten if this is true.
2708
+ * @param {boolean} [props.perm] The file will be set as the permission from the entry if this is true.
2709
+
2710
+ * @returns {Promise<void>}
2711
+ */
2712
+ writeZipPromise: function(targetFileName, props) {
2713
+ const { overwrite, perm } = Object.assign({ overwrite: true }, props);
2714
+ return new Promise((resolve, reject) => {
2715
+ if (!targetFileName && opts.filename) targetFileName = opts.filename;
2716
+ if (!targetFileName) reject("ADM-ZIP: ZIP File Name Missing");
2717
+ this.toBufferPromise().then((zipData) => {
2718
+ const ret = (done) => done ? resolve(done) : reject("ADM-ZIP: Wasn't able to write zip file");
2719
+ filetools.writeFileToAsync(targetFileName, zipData, overwrite, perm, ret);
2720
+ }, reject);
2721
+ });
2722
+ },
2723
+ /**
2724
+ * @returns {Promise<Buffer>} A promise to the Buffer.
2725
+ */
2726
+ toBufferPromise: function() {
2727
+ return new Promise((resolve, reject) => {
2728
+ _zip.toAsyncBuffer(resolve, reject);
2729
+ });
2730
+ },
2731
+ /**
2732
+ * Returns the content of the entire zip file as a Buffer object
2733
+ *
2734
+ * @prop {function} [onSuccess]
2735
+ * @prop {function} [onFail]
2736
+ * @prop {function} [onItemStart]
2737
+ * @prop {function} [onItemEnd]
2738
+ * @returns {Buffer}
2739
+ */
2740
+ toBuffer: function(onSuccess, onFail, onItemStart, onItemEnd) {
2741
+ if (typeof onSuccess === "function") {
2742
+ _zip.toAsyncBuffer(onSuccess, onFail, onItemStart, onItemEnd);
2743
+ return null;
2744
+ }
2745
+ return _zip.compressToBuffer();
2746
+ }
2747
+ };
2748
+ };
2749
+ }
2750
+ });
2751
+
1
2752
  // src/index.ts
2
- import fs7 from "node:fs";
3
- import path9 from "node:path";
2753
+ import fs8 from "node:fs";
2754
+ import path10 from "node:path";
4
2755
  import { fileURLToPath as fileURLToPath2 } from "node:url";
5
2756
  import os4 from "node:os";
6
2757
 
@@ -101,11 +2852,11 @@ var ActiveSkills = class {
101
2852
  };
102
2853
 
103
2854
  // src/updater.ts
2855
+ var import_adm_zip = __toESM(require_adm_zip(), 1);
104
2856
  import fs3 from "node:fs/promises";
105
2857
  import fsSync from "node:fs";
106
2858
  import path3 from "node:path";
107
2859
  import os2 from "node:os";
108
- import { execFile } from "node:child_process";
109
2860
  import { randomUUID, createHash } from "node:crypto";
110
2861
 
111
2862
  // src/skill-version.ts
@@ -138,37 +2889,27 @@ function parseSkillVersion(content) {
138
2889
  }
139
2890
 
140
2891
  // src/updater.ts
141
- var EXTRACT_TIMEOUT_MS = 3e4;
142
2892
  var ATTEMPT_COOLDOWN_MS = 30 * 60 * 1e3;
143
2893
  function skillIdentityHash(code, version) {
144
2894
  return createHash("sha256").update(`${code} ${code} ${version}`).digest("hex");
145
2895
  }
146
- function extractorCommandForPlatform(platform, zipPath, destDir) {
147
- return platform === "darwin" ? { command: "ditto", args: ["-x", "-k", zipPath, destDir] } : { command: "unzip", args: ["-o", "-q", zipPath, "-d", destDir] };
148
- }
149
- function runExtractor(command, args) {
150
- return new Promise((resolve, reject) => {
151
- const child = execFile(command, args, {
152
- encoding: "utf8",
153
- timeout: EXTRACT_TIMEOUT_MS,
154
- killSignal: "SIGKILL",
155
- maxBuffer: 1024 * 1024
156
- }, (error, _stdout, stderr) => {
157
- if (!error) {
158
- resolve();
159
- return;
160
- }
161
- const detail = String(stderr || "").trim();
162
- const timeout = error.killed ? `\uFF0C\u8D85\u8FC7 ${EXTRACT_TIMEOUT_MS}ms \u5DF2\u7EC8\u6B62` : "";
163
- reject(new Error(`${command} \u89E3\u538B\u5931\u8D25${timeout}: ${detail || error.message}`));
164
- });
165
- child.stdin?.end();
166
- });
167
- }
168
2896
  async function systemUnzip(zipPath, destDir) {
169
2897
  await fs3.mkdir(destDir, { recursive: true });
170
- const { command, args } = extractorCommandForPlatform(process.platform, zipPath, destDir);
171
- await runExtractor(command, args);
2898
+ const destRoot = path3.resolve(destDir);
2899
+ const zip = new import_adm_zip.default(zipPath);
2900
+ for (const entry of zip.getEntries()) {
2901
+ const normalizedName = entry.entryName.replace(/\\/g, "/");
2902
+ const outPath = path3.resolve(destRoot, normalizedName);
2903
+ if (outPath !== destRoot && !outPath.startsWith(destRoot + path3.sep)) {
2904
+ throw new Error(`ZIP \u5305\u542B\u975E\u6CD5\u8DEF\u5F84: ${entry.entryName}`);
2905
+ }
2906
+ if (entry.isDirectory) {
2907
+ await fs3.mkdir(outPath, { recursive: true });
2908
+ continue;
2909
+ }
2910
+ await fs3.mkdir(path3.dirname(outPath), { recursive: true });
2911
+ await fs3.writeFile(outPath, entry.getData());
2912
+ }
172
2913
  }
173
2914
  var SkillUpdater = class {
174
2915
  getConfig;
@@ -486,7 +3227,7 @@ var SkillUpdater = class {
486
3227
  emit("download.file.written", { bytes: buf.byteLength });
487
3228
  const staging = path3.join(work, "staging");
488
3229
  const unzipStartedAt = Date.now();
489
- emit("unzip.start", { extractor: process.platform === "darwin" ? "ditto" : "unzip" });
3230
+ emit("unzip.start", { extractor: "adm-zip" });
490
3231
  await this.unzip(zipPath, staging);
491
3232
  emit("unzip.completed", { elapsedMs: Date.now() - unzipStartedAt });
492
3233
  const srcRoot = await this.locateSkillRoot(staging, 0);
@@ -1370,18 +4111,18 @@ var ConfigSync = class {
1370
4111
  };
1371
4112
 
1372
4113
  // src/reporter.ts
1373
- import fs5 from "node:fs/promises";
1374
- import path6 from "node:path";
4114
+ import fs6 from "node:fs/promises";
4115
+ import path7 from "node:path";
1375
4116
 
1376
4117
  // src/identity.ts
1377
4118
  import os3 from "node:os";
1378
- import { execFile as execFile2 } from "node:child_process";
1379
- import { promisify } from "node:util";
1380
- var execFileAsync = promisify(execFile2);
4119
+ import fs5 from "node:fs/promises";
4120
+ import path6 from "node:path";
1381
4121
  async function getGitConfigValue(key) {
1382
4122
  try {
1383
- const { stdout } = await execFileAsync("git", ["config", "--global", key]);
1384
- return stdout.trim();
4123
+ const gitConfigPath = path6.join(os3.homedir(), ".gitconfig");
4124
+ const content = await fs5.readFile(gitConfigPath, "utf-8");
4125
+ return parseGitConfigValue(content, key);
1385
4126
  } catch {
1386
4127
  console.warn(
1387
4128
  `[skill-logger-plugin] git config --global ${key} \u672A\u8BBE\u7F6E\u3002\u53EF\u6267\u884C\uFF1Agit config --global ${key} '<value>'`
@@ -1389,6 +4130,26 @@ async function getGitConfigValue(key) {
1389
4130
  return "";
1390
4131
  }
1391
4132
  }
4133
+ function parseGitConfigValue(content, key) {
4134
+ const [section, name] = key.split(".");
4135
+ if (!section || !name) return "";
4136
+ let inTargetSection = false;
4137
+ for (const rawLine of content.split(/\r?\n/)) {
4138
+ const line = rawLine.trim();
4139
+ if (!line || line.startsWith("#") || line.startsWith(";")) continue;
4140
+ const sectionMatch = /^\[([^\]]+)\]$/.exec(line);
4141
+ if (sectionMatch) {
4142
+ inTargetSection = sectionMatch[1].trim() === section;
4143
+ continue;
4144
+ }
4145
+ if (!inTargetSection) continue;
4146
+ const kv = /^([A-Za-z0-9_.-]+)\s*=\s*(.*)$/.exec(line);
4147
+ if (kv?.[1] === name) {
4148
+ return kv[2].trim().replace(/^"|"$/g, "");
4149
+ }
4150
+ }
4151
+ return "";
4152
+ }
1392
4153
  var GitIdentityProvider = class {
1393
4154
  cached;
1394
4155
  async getIdentity() {
@@ -1440,9 +4201,9 @@ var Reporter = class {
1440
4201
  const ts = (/* @__PURE__ */ new Date()).toISOString();
1441
4202
  const logLine = `[${ts}] [${level}] [skill-logger-plugin] ${msg}
1442
4203
  `;
1443
- const logDir = path6.dirname(this.paths.eventsLogPath);
1444
- await fs5.mkdir(logDir, { recursive: true });
1445
- await fs5.appendFile(path6.join(logDir, "skill-logger.err.log"), logLine);
4204
+ const logDir = path7.dirname(this.paths.eventsLogPath);
4205
+ await fs6.mkdir(logDir, { recursive: true });
4206
+ await fs6.appendFile(path7.join(logDir, "skill-logger.err.log"), logLine);
1446
4207
  if (level === "INFO" && this.isDebug) {
1447
4208
  console.log("[skill-logger-plugin/reporter]", ...args);
1448
4209
  } else if (level === "WARN" || level === "ERROR") {
@@ -1475,8 +4236,8 @@ var Reporter = class {
1475
4236
  } catch {
1476
4237
  return;
1477
4238
  }
1478
- await fs5.mkdir(path6.dirname(this.paths.eventsLogPath), { recursive: true });
1479
- await fs5.appendFile(this.paths.eventsLogPath, line + "\n");
4239
+ await fs6.mkdir(path7.dirname(this.paths.eventsLogPath), { recursive: true });
4240
+ await fs6.appendFile(this.paths.eventsLogPath, line + "\n");
1480
4241
  } catch (err) {
1481
4242
  void this.writeFallbackLog("ERROR", "\u5199\u4E8B\u4EF6\u65E5\u5FD7\u5931\u8D25", this.paths.eventsLogPath, err);
1482
4243
  }
@@ -1546,19 +4307,19 @@ var Reporter = class {
1546
4307
  void this.writeFallbackLog("WARN", "flush skipped: reportBaseUrl \u6CA1\u6709\u914D\u7F6E\uFF01\u8BF7\u68C0\u67E5 openclaw.json \u63D2\u4EF6\u914D\u7F6E\u662F\u5426\u6B63\u786E\u52A0\u8F7D\u3002");
1547
4308
  return;
1548
4309
  }
1549
- const logDir = path6.dirname(this.paths.eventsLogPath);
4310
+ const logDir = path7.dirname(this.paths.eventsLogPath);
1550
4311
  try {
1551
- await fs5.access(this.paths.eventsLogPath);
4312
+ await fs6.access(this.paths.eventsLogPath);
1552
4313
  const timestamp = Date.now();
1553
- const rotatedPath = path6.join(logDir, `events.${timestamp}.jsonl`);
1554
- await fs5.rename(this.paths.eventsLogPath, rotatedPath);
1555
- this.debug(`Rotated active log to ${path6.basename(rotatedPath)}`);
4314
+ const rotatedPath = path7.join(logDir, `events.${timestamp}.jsonl`);
4315
+ await fs6.rename(this.paths.eventsLogPath, rotatedPath);
4316
+ this.debug(`Rotated active log to ${path7.basename(rotatedPath)}`);
1556
4317
  } catch {
1557
4318
  }
1558
4319
  let files = [];
1559
4320
  try {
1560
- const dirEntries = await fs5.readdir(logDir);
1561
- files = dirEntries.filter((f) => f.startsWith("events.") && f.endsWith(".jsonl") && f !== "events.jsonl").map((f) => path6.join(logDir, f));
4321
+ const dirEntries = await fs6.readdir(logDir);
4322
+ files = dirEntries.filter((f) => f.startsWith("events.") && f.endsWith(".jsonl") && f !== "events.jsonl").map((f) => path7.join(logDir, f));
1562
4323
  } catch {
1563
4324
  return;
1564
4325
  }
@@ -1571,10 +4332,10 @@ var Reporter = class {
1571
4332
  const url = config.reportBaseUrl.replace(/\/$/, "") + "/skill_report/batch";
1572
4333
  for (const filePath of files) {
1573
4334
  try {
1574
- const content = await fs5.readFile(filePath, "utf-8");
4335
+ const content = await fs6.readFile(filePath, "utf-8");
1575
4336
  const lines = this.linesOf(content);
1576
4337
  if (lines.length === 0) {
1577
- await fs5.unlink(filePath);
4338
+ await fs6.unlink(filePath);
1578
4339
  continue;
1579
4340
  }
1580
4341
  let cursor = 0;
@@ -1603,8 +4364,8 @@ var Reporter = class {
1603
4364
  if (config.authToken) headers.Authorization = config.authToken;
1604
4365
  const res = await this.fetchImpl(url, { method: "POST", headers, body });
1605
4366
  if (!res.ok) {
1606
- const errBody = await res.text().catch(() => "\u65E0\u6CD5\u8BFB\u53D6\u54CD\u5E94\u4F53");
1607
- await this.writeFallbackLog("ERROR", `\u6279\u91CF\u4E0A\u62A5\u5931\u8D25 (\u6587\u4EF6 ${path6.basename(filePath)}), HTTP`, res.status, "\u670D\u52A1\u7AEF\u8FD4\u56DE\u4FE1\u606F:", errBody);
4367
+ const errBody = await res.text?.().catch(() => "\u65E0\u6CD5\u8BFB\u53D6\u54CD\u5E94\u4F53") ?? "\u65E0\u6CD5\u8BFB\u53D6\u54CD\u5E94\u4F53";
4368
+ await this.writeFallbackLog("ERROR", `\u6279\u91CF\u4E0A\u62A5\u5931\u8D25 (\u6587\u4EF6 ${path7.basename(filePath)}), HTTP`, res.status, "\u670D\u52A1\u7AEF\u8FD4\u56DE\u4FE1\u606F:", errBody);
1608
4369
  if (res.status === 400 || res.status === 413 || res.status === 422) {
1609
4370
  await this.writeFallbackLog("WARN", `\u62A5\u6587\u88AB\u670D\u52A1\u5668\u6C38\u4E45\u62D2\u7EDD\uFF0C\u4E22\u5F03\u8BE5\u6279\u6B21\u4EE5\u91CA\u653E\u961F\u5217`);
1610
4371
  cursor += slice.length;
@@ -1613,17 +4374,17 @@ var Reporter = class {
1613
4374
  allSuccess = false;
1614
4375
  break;
1615
4376
  }
1616
- this.debug(`Successfully reported batch of ${events.length} events from ${path6.basename(filePath)}`);
4377
+ this.debug(`Successfully reported batch of ${events.length} events from ${path7.basename(filePath)}`);
1617
4378
  cursor += slice.length;
1618
4379
  }
1619
4380
  if (allSuccess) {
1620
- await fs5.unlink(filePath);
1621
- this.debug(`Deleted fully processed file: ${path6.basename(filePath)}`);
4381
+ await fs6.unlink(filePath);
4382
+ this.debug(`Deleted fully processed file: ${path7.basename(filePath)}`);
1622
4383
  } else {
1623
- this.debug(`File ${path6.basename(filePath)} partially failed. Keeping it for next flush.`);
4384
+ this.debug(`File ${path7.basename(filePath)} partially failed. Keeping it for next flush.`);
1624
4385
  }
1625
4386
  } catch (err) {
1626
- await this.writeFallbackLog("ERROR", `\u5904\u7406\u6587\u4EF6 ${path6.basename(filePath)} \u5F02\u5E38:`, err);
4387
+ await this.writeFallbackLog("ERROR", `\u5904\u7406\u6587\u4EF6 ${path7.basename(filePath)} \u5F02\u5E38:`, err);
1627
4388
  }
1628
4389
  }
1629
4390
  } catch (err) {
@@ -1636,8 +4397,8 @@ var Reporter = class {
1636
4397
 
1637
4398
  // src/ws-client.ts
1638
4399
  import WebSocket from "ws";
1639
- import path7 from "path";
1640
- import fs6 from "fs/promises";
4400
+ import path8 from "path";
4401
+ import fs7 from "fs/promises";
1641
4402
  import { DatabaseSync } from "node:sqlite";
1642
4403
  var HEARTBEAT_INTERVAL_MS = 3e4;
1643
4404
  var HEARTBEAT_ACK_TIMEOUT_MS = 75e3;
@@ -1652,7 +4413,7 @@ function parseAssistantWorkspaceAgentId(entryName) {
1652
4413
  return `${ASSISTANT_AGENT_PREFIX}${suffix}`;
1653
4414
  }
1654
4415
  function normalizeAssistantUserId(userId) {
1655
- const safeUserId = path7.basename(userId);
4416
+ const safeUserId = path8.basename(userId);
1656
4417
  if (safeUserId !== userId) return void 0;
1657
4418
  const pureId = safeUserId.startsWith(ASSISTANT_AGENT_PREFIX) ? safeUserId.slice(ASSISTANT_AGENT_PREFIX.length) : safeUserId;
1658
4419
  if (!ASSISTANT_WORKSPACE_ID_RE.test(pureId)) return void 0;
@@ -1662,7 +4423,7 @@ function shouldSyncBuiltInTemplate(action, isBuiltIn) {
1662
4423
  return action === "UPDATE_SKILL" && isBuiltIn === true;
1663
4424
  }
1664
4425
  function defaultOpenclawSqlitePath() {
1665
- return path7.join(openclawHome(), "state", "openclaw.sqlite");
4426
+ return path8.join(openclawHome(), "state", "openclaw.sqlite");
1666
4427
  }
1667
4428
  function readCronJobsByAgentId(agentId, sqlitePath = defaultOpenclawSqlitePath(), onError) {
1668
4429
  let db;
@@ -1702,10 +4463,10 @@ var GatewayWsClient = class {
1702
4463
  }
1703
4464
  }
1704
4465
  logLine += "\n";
1705
- const logsDir = path7.join(openclawHome(), "logs");
1706
- fs6.mkdir(logsDir, { recursive: true }).then(() => {
1707
- const logPath = path7.join(logsDir, "skill-logger.err");
1708
- fs6.appendFile(logPath, logLine).catch(() => {
4466
+ const logsDir = path8.join(openclawHome(), "logs");
4467
+ fs7.mkdir(logsDir, { recursive: true }).then(() => {
4468
+ const logPath = path8.join(logsDir, "skill-logger.err");
4469
+ fs7.appendFile(logPath, logLine).catch(() => {
1709
4470
  });
1710
4471
  }).catch(() => {
1711
4472
  });
@@ -1825,7 +4586,7 @@ var GatewayWsClient = class {
1825
4586
  const rootPath = openclawHome();
1826
4587
  let entries = [];
1827
4588
  try {
1828
- entries = await fs6.readdir(rootPath);
4589
+ entries = await fs7.readdir(rootPath);
1829
4590
  } catch (e) {
1830
4591
  this.appendLogToFile("WARN", "AgentScan", "OpenClaw home is not readable; skipping this scan cycle", e);
1831
4592
  return;
@@ -2006,13 +4767,13 @@ var GatewayWsClient = class {
2006
4767
  this.appendLogToFile("WARN", "Command", `Message dropped: missing userId`, msg);
2007
4768
  return;
2008
4769
  }
2009
- const safeCode = code ? path7.basename(code) : void 0;
4770
+ const safeCode = code ? path8.basename(code) : void 0;
2010
4771
  const pureId = normalizeAssistantUserId(userId);
2011
4772
  if (!pureId) {
2012
4773
  this.reply(replyId, { success: false, message: `Invalid userId: ${userId}`, action });
2013
4774
  return;
2014
4775
  }
2015
- const targetDir = path7.join(openclawHome(), `workspace-assistant-${pureId}`, "skills");
4776
+ const targetDir = path8.join(openclawHome(), `workspace-assistant-${pureId}`, "skills");
2016
4777
  try {
2017
4778
  if (action === "INSTALL_SKILL") {
2018
4779
  if (!safeCode) throw new Error("Missing code parameter");
@@ -2031,14 +4792,14 @@ var GatewayWsClient = class {
2031
4792
  if (!safeCode) throw new Error("Missing code parameter");
2032
4793
  console.log(`[skill-logger-plugin][WS] Executing UNINSTALL for user ${userId}, code: ${safeCode}`);
2033
4794
  this.appendLogToFile("INFO", "Command", `UNINSTALL_SKILL received`, { userId, code: safeCode });
2034
- const skillPath = path7.join(targetDir, safeCode);
2035
- await fs6.rm(skillPath, { recursive: true, force: true });
4795
+ const skillPath = path8.join(targetDir, safeCode);
4796
+ await fs7.rm(skillPath, { recursive: true, force: true });
2036
4797
  this.reply(replyId, { success: true, message: `Skill ${safeCode} removed`, action });
2037
4798
  } else if (action === "LIST_SKILLS") {
2038
4799
  let list = [];
2039
4800
  let targetDirExists = false;
2040
4801
  try {
2041
- const targetStat = await fs6.stat(targetDir);
4802
+ const targetStat = await fs7.stat(targetDir);
2042
4803
  targetDirExists = targetStat.isDirectory();
2043
4804
  } catch (err) {
2044
4805
  if (err?.code !== "ENOENT") throw err;
@@ -2046,18 +4807,18 @@ var GatewayWsClient = class {
2046
4807
  if (!targetDirExists) {
2047
4808
  throw new Error(`Target skills directory does not exist: ${targetDir}`);
2048
4809
  }
2049
- const entries = await fs6.readdir(targetDir, { withFileTypes: true });
4810
+ const entries = await fs7.readdir(targetDir, { withFileTypes: true });
2050
4811
  const dirs = entries.filter((e) => (e.isDirectory() || e.isSymbolicLink()) && !e.name.startsWith("."));
2051
4812
  for (const e of dirs) {
2052
- const skillDir = path7.join(targetDir, e.name);
2053
- const skillMdPath = path7.join(skillDir, "SKILL.md");
4813
+ const skillDir = path8.join(targetDir, e.name);
4814
+ const skillMdPath = path8.join(skillDir, "SKILL.md");
2054
4815
  try {
2055
- const stat = await fs6.stat(skillMdPath);
4816
+ const stat = await fs7.stat(skillMdPath);
2056
4817
  if (!stat.isFile()) continue;
2057
4818
  } catch (err) {
2058
4819
  continue;
2059
4820
  }
2060
- const metaPath = path7.join(skillDir, ".meta.json");
4821
+ const metaPath = path8.join(skillDir, ".meta.json");
2061
4822
  let isPlatform = false;
2062
4823
  let isBuiltIn2 = e.isSymbolicLink();
2063
4824
  let metaData = null;
@@ -2065,7 +4826,7 @@ var GatewayWsClient = class {
2065
4826
  let description = "";
2066
4827
  let skillVersion = "";
2067
4828
  try {
2068
- const mdContent = await fs6.readFile(skillMdPath, "utf8");
4829
+ const mdContent = await fs7.readFile(skillMdPath, "utf8");
2069
4830
  const fm = /^---\r?\n([\s\S]*?)\r?\n---/.exec(mdContent)?.[1] ?? "";
2070
4831
  const parsedName = /(^|\n)name:\s*(.+)/.exec(fm)?.[2]?.trim();
2071
4832
  if (parsedName) name = parsedName;
@@ -2076,7 +4837,7 @@ var GatewayWsClient = class {
2076
4837
  } catch (err) {
2077
4838
  }
2078
4839
  try {
2079
- const metaContent = await fs6.readFile(metaPath, "utf8");
4840
+ const metaContent = await fs7.readFile(metaPath, "utf8");
2080
4841
  const parsed = JSON.parse(metaContent);
2081
4842
  if (parsed) {
2082
4843
  if (parsed.ownerId === "CMS" || parsed.ownerId === "CMS_COMPAT") isPlatform = true;
@@ -2124,10 +4885,10 @@ var GatewayWsClient = class {
2124
4885
  });
2125
4886
  setTimeout(async () => {
2126
4887
  try {
2127
- const additionalTargetDirs = syncBuiltInTemplate ? [path7.join(openclawHome(), "workspace-xgjk-assistant-template", "skills")] : [];
2128
- const userSkillDir = path7.join(openclawHome(), `workspace-assistant-${pureId}`, ".user", "skills", safeCode);
4888
+ const additionalTargetDirs = syncBuiltInTemplate ? [path8.join(openclawHome(), "workspace-xgjk-assistant-template", "skills")] : [];
4889
+ const userSkillDir = path8.join(openclawHome(), `workspace-assistant-${pureId}`, ".user", "skills", safeCode);
2129
4890
  try {
2130
- await fs6.stat(userSkillDir);
4891
+ await fs7.stat(userSkillDir);
2131
4892
  additionalTargetDirs.push(userSkillDir);
2132
4893
  } catch {
2133
4894
  }
@@ -2174,12 +4935,12 @@ var GatewayWsClient = class {
2174
4935
  const { name, version: version2, downloadUrl, skills } = msg;
2175
4936
  console.log(`[skill-logger-plugin][WS] Executing INSTALL_EXPERT for user ${userId}, code: ${safeCode}`);
2176
4937
  this.appendLogToFile("INFO", "Command", `INSTALL_EXPERT received`, { userId, code: safeCode, version: version2, downloadUrl });
2177
- const userSkillRoot = path7.join(openclawHome(), `workspace-assistant-${pureId}`, ".user");
2178
- const expertTarget = path7.join(userSkillRoot, "experts", safeCode);
4938
+ const userSkillRoot = path8.join(openclawHome(), `workspace-assistant-${pureId}`, ".user");
4939
+ const expertTarget = path8.join(userSkillRoot, "experts", safeCode);
2179
4940
  let skipInstall = false;
2180
- const metaPath = path7.join(expertTarget, ".meta.json");
4941
+ const metaPath = path8.join(expertTarget, ".meta.json");
2181
4942
  try {
2182
- const raw = await fs6.readFile(metaPath, "utf-8");
4943
+ const raw = await fs7.readFile(metaPath, "utf-8");
2183
4944
  const existing = JSON.parse(raw);
2184
4945
  if (existing.version && existing.version === (version2 || "1.0.0")) {
2185
4946
  skipInstall = true;
@@ -2187,16 +4948,16 @@ var GatewayWsClient = class {
2187
4948
  } catch {
2188
4949
  }
2189
4950
  if (!skipInstall) {
2190
- await fs6.mkdir(path7.dirname(expertTarget), { recursive: true });
4951
+ await fs7.mkdir(path8.dirname(expertTarget), { recursive: true });
2191
4952
  const expertResult = await this.options.updater.installZipFromUrl(downloadUrl, expertTarget);
2192
4953
  if (!expertResult.success) {
2193
4954
  throw new Error(`\u4E13\u5BB6\u5B89\u88C5\u5931\u8D25: ${expertResult.message}`);
2194
4955
  }
2195
4956
  }
2196
4957
  const meta = { code: safeCode, name, version: version2 || "1.0.0", installedAt: Date.now() };
2197
- await fs6.writeFile(metaPath, JSON.stringify(meta, null, 2));
2198
- const skillTargetRoot = path7.join(userSkillRoot, "skills");
2199
- await fs6.mkdir(skillTargetRoot, { recursive: true });
4958
+ await fs7.writeFile(metaPath, JSON.stringify(meta, null, 2));
4959
+ const skillTargetRoot = path8.join(userSkillRoot, "skills");
4960
+ await fs7.mkdir(skillTargetRoot, { recursive: true });
2200
4961
  const skillResults = [];
2201
4962
  if (Array.isArray(skills)) {
2202
4963
  for (const sk of skills) {
@@ -2205,7 +4966,7 @@ var GatewayWsClient = class {
2205
4966
  continue;
2206
4967
  }
2207
4968
  try {
2208
- const skTarget = path7.join(skillTargetRoot, sk.code);
4969
+ const skTarget = path8.join(skillTargetRoot, sk.code);
2209
4970
  const result = await this.options.updater.installZipFromUrl(sk.downloadUrl, skTarget);
2210
4971
  skillResults.push(`${sk.code}: ${result.success ? "\u6210\u529F" : "\u5931\u8D25 - " + result.message}`);
2211
4972
  } catch (e) {
@@ -2223,23 +4984,23 @@ var GatewayWsClient = class {
2223
4984
  if (!safeCode) throw new Error("Missing code parameter");
2224
4985
  console.log(`[skill-logger-plugin][WS] Executing UNINSTALL_EXPERT for user ${userId}, code: ${safeCode}`);
2225
4986
  this.appendLogToFile("INFO", "Command", `UNINSTALL_EXPERT received`, { userId, code: safeCode });
2226
- const expertPath = path7.join(openclawHome(), `workspace-assistant-${pureId}`, ".user", "experts", safeCode);
2227
- await fs6.rm(expertPath, { recursive: true, force: true });
4987
+ const expertPath = path8.join(openclawHome(), `workspace-assistant-${pureId}`, ".user", "experts", safeCode);
4988
+ await fs7.rm(expertPath, { recursive: true, force: true });
2228
4989
  this.reply(replyId, { success: true, message: `\u4E13\u5BB6 ${safeCode} \u5DF2\u5378\u8F7D`, action });
2229
4990
  } else if (action === "LIST_EXPERTS") {
2230
4991
  console.log(`[skill-logger-plugin][WS] Executing LIST_EXPERTS for user ${userId}`);
2231
4992
  this.appendLogToFile("INFO", "Command", `LIST_EXPERTS received`, { userId });
2232
- const expertsDir = path7.join(openclawHome(), `workspace-assistant-${pureId}`, ".user", "experts");
4993
+ const expertsDir = path8.join(openclawHome(), `workspace-assistant-${pureId}`, ".user", "experts");
2233
4994
  const list = [];
2234
4995
  try {
2235
- const stat = await fs6.stat(expertsDir);
4996
+ const stat = await fs7.stat(expertsDir);
2236
4997
  if (stat.isDirectory()) {
2237
- const entries = await fs6.readdir(expertsDir, { withFileTypes: true });
4998
+ const entries = await fs7.readdir(expertsDir, { withFileTypes: true });
2238
4999
  for (const e of entries) {
2239
5000
  if (!e.isDirectory()) continue;
2240
- const metaPath = path7.join(expertsDir, e.name, ".meta.json");
5001
+ const metaPath = path8.join(expertsDir, e.name, ".meta.json");
2241
5002
  try {
2242
- const raw = await fs6.readFile(metaPath, "utf-8");
5003
+ const raw = await fs7.readFile(metaPath, "utf-8");
2243
5004
  const meta = JSON.parse(raw);
2244
5005
  list.push({
2245
5006
  code: meta.code || e.name,
@@ -2293,7 +5054,7 @@ var GatewayWsClient = class {
2293
5054
  };
2294
5055
 
2295
5056
  // src/hooks.ts
2296
- import path8 from "node:path";
5057
+ import path9 from "node:path";
2297
5058
  import { randomUUID as randomUUID2 } from "node:crypto";
2298
5059
  var PENDING_TTL_MS = 30 * 60 * 1e3;
2299
5060
  var PENDING_MAX = 5e3;
@@ -2302,7 +5063,7 @@ function toMySQLDateTime(d) {
2302
5063
  return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`;
2303
5064
  }
2304
5065
  function isSkillMdReadPath(filePath) {
2305
- return path8.basename(filePath) === "SKILL.md";
5066
+ return path9.basename(filePath) === "SKILL.md";
2306
5067
  }
2307
5068
  function extractAppKey(event, ctx) {
2308
5069
  try {
@@ -2442,27 +5203,6 @@ var Hooks = class {
2442
5203
  this.sessionAppKeys.set(sk, rawAppKey);
2443
5204
  }
2444
5205
  }
2445
- onManualErrorRecord(args, ctx) {
2446
- const sk = this.sessionKeyOf(ctx);
2447
- let appKey = sk ? this.sessionAppKeys.get(sk) : void 0;
2448
- this.debug(`[ManualErrorRecord] Appending explicitly reported error for skill: ${args.skill_name}`);
2449
- this.emit({
2450
- event_id: randomUUID2(),
2451
- event_type: "function_call",
2452
- skill_name: args.skill_name || "unknown_skill",
2453
- skill_version: this.configSync.getVersion(args.skill_name),
2454
- function_name: args.tool_name || "unknown_tool",
2455
- invoke_tool: "report_skill_error",
2456
- args: args.input_args ? { raw_args: args.input_args } : void 0,
2457
- status: "error",
2458
- error_message: args.error_message,
2459
- app_key: appKey || "",
2460
- session_id: sk,
2461
- agent_id: ctx.agentId,
2462
- run_id: ctx.runId,
2463
- called_at: toMySQLDateTime(/* @__PURE__ */ new Date())
2464
- });
2465
- }
2466
5206
  onBeforeToolCall(event, ctx) {
2467
5207
  try {
2468
5208
  this.sweepStalePending();
@@ -2503,8 +5243,8 @@ var Hooks = class {
2503
5243
  if (toolName === "read") {
2504
5244
  const filePath = params.path ?? params.file_path ?? "";
2505
5245
  if (!isSkillMdReadPath(filePath)) return;
2506
- const rootDir = path8.dirname(filePath);
2507
- const skillName = this.configSync.resolveSkillName(rootDir) || path8.basename(rootDir);
5246
+ const rootDir = path9.dirname(filePath);
5247
+ const skillName = this.configSync.resolveSkillName(rootDir) || path9.basename(rootDir);
2508
5248
  if (!skillName) return;
2509
5249
  this.debug(`Intercepted 'read' for SKILL.md. Attributed to skill: ${skillName}`);
2510
5250
  this.recordTrigger(skillName, "inline", "read", ctx, appKey);
@@ -2704,9 +5444,9 @@ var definition = {
2704
5444
  register(api) {
2705
5445
  let pkgVersion = "unknown";
2706
5446
  try {
2707
- const dir = path9.dirname(fileURLToPath2(import.meta.url));
2708
- const pkgPath = path9.join(dir, "..", "package.json");
2709
- const pkg = JSON.parse(fs7.readFileSync(pkgPath, "utf-8"));
5447
+ const dir = path10.dirname(fileURLToPath2(import.meta.url));
5448
+ const pkgPath = path10.join(dir, "..", "package.json");
5449
+ const pkg = JSON.parse(fs8.readFileSync(pkgPath, "utf-8"));
2710
5450
  if (pkg.version) pkgVersion = pkg.version;
2711
5451
  } catch {
2712
5452
  }
@@ -2723,34 +5463,6 @@ var definition = {
2723
5463
  const configSync = new ConfigSync({ paths, getConfig, updater });
2724
5464
  const reporter = new Reporter({ paths, getConfig });
2725
5465
  const hooks = new Hooks(reporter, configSync, activeSkills, getConfig);
2726
- if (typeof api.registerTool === "function") {
2727
- try {
2728
- api.registerTool((ctx) => ({
2729
- name: "report_skill_error",
2730
- description: "\u5F53\u8C03\u7528\u5176\u4ED6\u6280\u80FD\u6216\u5DE5\u5177\u53D1\u751F\u9519\u8BEF\u65F6\uFF0C\u8BF7\u8C03\u7528\u6B64\u5DE5\u5177\u5C06\u9519\u8BEF\u4FE1\u606F\u8FDB\u884C\u4E0A\u62A5\u8BB0\u5F55\u3002",
2731
- parameters: {
2732
- type: "object",
2733
- properties: {
2734
- skill_name: { type: "string", description: "\u53D1\u751F\u9519\u8BEF\u7684\u6280\u80FD\u540D\u79F0" },
2735
- tool_name: { type: "string", description: "\u53D1\u751F\u9519\u8BEF\u7684\u5177\u4F53\u5DE5\u5177\u540D\u79F0" },
2736
- error_message: { type: "string", description: "\u5177\u4F53\u7684\u62A5\u9519\u539F\u56E0\u6216\u5F02\u5E38\u6808" },
2737
- input_args: { type: "string", description: "\u5F53\u65F6\u4F20\u5165\u8BE5\u5DE5\u5177\u7684\u53C2\u6570\uFF08\u53EF\u9009\uFF09" }
2738
- },
2739
- required: ["skill_name", "tool_name", "error_message"]
2740
- },
2741
- execute: async (args) => {
2742
- hooks.onManualErrorRecord(args, ctx);
2743
- return { content: [{ type: "text", text: "\u5DF2\u6210\u529F\u4E0A\u62A5\u9519\u8BEF\u8BB0\u5F55\u3002" }] };
2744
- }
2745
- }), { name: "report_skill_error" });
2746
- } catch (err) {
2747
- if (typeof api.logger?.error === "function") {
2748
- api.logger.error("[skill-logger-plugin] Failed to register or inject 'report_skill_error' tool:", err);
2749
- } else {
2750
- console.error("[skill-logger-plugin] Failed to register or inject 'report_skill_error' tool:", err);
2751
- }
2752
- }
2753
- }
2754
5466
  let reconcileTimer;
2755
5467
  const sessionUpdatedSkills = /* @__PURE__ */ new Set();
2756
5468
  api.on("message_received", (event, ctx) => {
@@ -2758,10 +5470,9 @@ var definition = {
2758
5470
  hooks.onMessageReceived(event, ctx);
2759
5471
  });
2760
5472
  api.on("before_prompt_build", () => {
2761
- let appendStr = "\u3010\u5168\u5C40\u5F3A\u5236\u7EA6\u675F\u3011\u5982\u679C\u51FA\u73B0\u8C03\u7528\u6280\u80FD(skill)\u6216\u5DE5\u5177\u6267\u884C\u62A5\u9519\u3001\u5F02\u5E38\u65F6\uFF0C\u8BF7\u52A1\u5FC5\u4E3B\u52A8\u8C03\u7528 report_skill_error \u8FD9\u4E2A\u5DE5\u5177\uFF0C\u5C06\u5177\u4F53\u7684\u9519\u8BEF\u4FE1\u606F\u3001\u5DE5\u5177\u540D\u79F0\u7B49\u8FDB\u884C\u4E0A\u62A5\u8BB0\u5F55\u3002\n";
5473
+ let appendStr = "";
2762
5474
  if (sessionUpdatedSkills.size > 0) {
2763
- appendStr += `
2764
- \u3010\u7CFB\u7EDF\u73AF\u5883\u5B9E\u65F6\u901A\u77E5\u3011\uFF1A\u5728\u5F53\u524D\u5BF9\u8BDD\u671F\u95F4\uFF0C\u4EE5\u4E0B\u6280\u80FD\u5DF2\u88AB\u66F4\u65B0\u6216\u91CD\u88C5\uFF1A[${Array.from(sessionUpdatedSkills).join(", ")}]\u3002\u5982\u679C\u4F60\u4E4B\u524D\u8C03\u7528\u5B83\u9047\u5230\u4E86\u62A5\u9519\uFF0C\u8BF7\u7ACB\u5373\u629B\u5F03\u65E7\u7684\u7ECF\u9A8C\uFF0C\u91CD\u65B0\u9605\u8BFB\u5B83\u7684\u8BF4\u660E\u5E76\u4EE5\u6700\u65B0\u7ED3\u679C\u4E3A\u51C6\uFF01`;
5475
+ appendStr = `\u3010\u7CFB\u7EDF\u73AF\u5883\u5B9E\u65F6\u901A\u77E5\u3011\uFF1A\u5728\u5F53\u524D\u5BF9\u8BDD\u671F\u95F4\uFF0C\u4EE5\u4E0B\u6280\u80FD\u5DF2\u88AB\u66F4\u65B0\u6216\u91CD\u88C5\uFF1A[${Array.from(sessionUpdatedSkills).join(", ")}]\u3002\u5982\u679C\u4F60\u4E4B\u524D\u8C03\u7528\u5B83\u9047\u5230\u4E86\u62A5\u9519\uFF0C\u8BF7\u7ACB\u5373\u629B\u5F03\u65E7\u7684\u7ECF\u9A8C\uFF0C\u91CD\u65B0\u9605\u8BFB\u5B83\u7684\u8BF4\u660E\u5E76\u4EE5\u6700\u65B0\u7ED3\u679C\u4E3A\u51C6\uFF01`;
2765
5476
  }
2766
5477
  return { appendSystemContext: appendStr.trim() };
2767
5478
  });