larkway 0.3.16 → 0.3.17
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/README.md +1 -1
- package/README.zh.md +1 -1
- package/dist/cli/index.js +926 -12
- package/dist/main.js +972 -33
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -10740,6 +10740,769 @@ var require_proxy_from_env = __commonJS({
|
|
|
10740
10740
|
}
|
|
10741
10741
|
});
|
|
10742
10742
|
|
|
10743
|
+
// node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js
|
|
10744
|
+
var require_ms = __commonJS({
|
|
10745
|
+
"node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js"(exports, module) {
|
|
10746
|
+
var s = 1e3;
|
|
10747
|
+
var m = s * 60;
|
|
10748
|
+
var h = m * 60;
|
|
10749
|
+
var d = h * 24;
|
|
10750
|
+
var w = d * 7;
|
|
10751
|
+
var y = d * 365.25;
|
|
10752
|
+
module.exports = function(val, options) {
|
|
10753
|
+
options = options || {};
|
|
10754
|
+
var type2 = typeof val;
|
|
10755
|
+
if (type2 === "string" && val.length > 0) {
|
|
10756
|
+
return parse(val);
|
|
10757
|
+
} else if (type2 === "number" && isFinite(val)) {
|
|
10758
|
+
return options.long ? fmtLong(val) : fmtShort(val);
|
|
10759
|
+
}
|
|
10760
|
+
throw new Error(
|
|
10761
|
+
"val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
|
|
10762
|
+
);
|
|
10763
|
+
};
|
|
10764
|
+
function parse(str2) {
|
|
10765
|
+
str2 = String(str2);
|
|
10766
|
+
if (str2.length > 100) {
|
|
10767
|
+
return;
|
|
10768
|
+
}
|
|
10769
|
+
var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
|
|
10770
|
+
str2
|
|
10771
|
+
);
|
|
10772
|
+
if (!match) {
|
|
10773
|
+
return;
|
|
10774
|
+
}
|
|
10775
|
+
var n = parseFloat(match[1]);
|
|
10776
|
+
var type2 = (match[2] || "ms").toLowerCase();
|
|
10777
|
+
switch (type2) {
|
|
10778
|
+
case "years":
|
|
10779
|
+
case "year":
|
|
10780
|
+
case "yrs":
|
|
10781
|
+
case "yr":
|
|
10782
|
+
case "y":
|
|
10783
|
+
return n * y;
|
|
10784
|
+
case "weeks":
|
|
10785
|
+
case "week":
|
|
10786
|
+
case "w":
|
|
10787
|
+
return n * w;
|
|
10788
|
+
case "days":
|
|
10789
|
+
case "day":
|
|
10790
|
+
case "d":
|
|
10791
|
+
return n * d;
|
|
10792
|
+
case "hours":
|
|
10793
|
+
case "hour":
|
|
10794
|
+
case "hrs":
|
|
10795
|
+
case "hr":
|
|
10796
|
+
case "h":
|
|
10797
|
+
return n * h;
|
|
10798
|
+
case "minutes":
|
|
10799
|
+
case "minute":
|
|
10800
|
+
case "mins":
|
|
10801
|
+
case "min":
|
|
10802
|
+
case "m":
|
|
10803
|
+
return n * m;
|
|
10804
|
+
case "seconds":
|
|
10805
|
+
case "second":
|
|
10806
|
+
case "secs":
|
|
10807
|
+
case "sec":
|
|
10808
|
+
case "s":
|
|
10809
|
+
return n * s;
|
|
10810
|
+
case "milliseconds":
|
|
10811
|
+
case "millisecond":
|
|
10812
|
+
case "msecs":
|
|
10813
|
+
case "msec":
|
|
10814
|
+
case "ms":
|
|
10815
|
+
return n;
|
|
10816
|
+
default:
|
|
10817
|
+
return void 0;
|
|
10818
|
+
}
|
|
10819
|
+
}
|
|
10820
|
+
function fmtShort(ms) {
|
|
10821
|
+
var msAbs = Math.abs(ms);
|
|
10822
|
+
if (msAbs >= d) {
|
|
10823
|
+
return Math.round(ms / d) + "d";
|
|
10824
|
+
}
|
|
10825
|
+
if (msAbs >= h) {
|
|
10826
|
+
return Math.round(ms / h) + "h";
|
|
10827
|
+
}
|
|
10828
|
+
if (msAbs >= m) {
|
|
10829
|
+
return Math.round(ms / m) + "m";
|
|
10830
|
+
}
|
|
10831
|
+
if (msAbs >= s) {
|
|
10832
|
+
return Math.round(ms / s) + "s";
|
|
10833
|
+
}
|
|
10834
|
+
return ms + "ms";
|
|
10835
|
+
}
|
|
10836
|
+
function fmtLong(ms) {
|
|
10837
|
+
var msAbs = Math.abs(ms);
|
|
10838
|
+
if (msAbs >= d) {
|
|
10839
|
+
return plural(ms, msAbs, d, "day");
|
|
10840
|
+
}
|
|
10841
|
+
if (msAbs >= h) {
|
|
10842
|
+
return plural(ms, msAbs, h, "hour");
|
|
10843
|
+
}
|
|
10844
|
+
if (msAbs >= m) {
|
|
10845
|
+
return plural(ms, msAbs, m, "minute");
|
|
10846
|
+
}
|
|
10847
|
+
if (msAbs >= s) {
|
|
10848
|
+
return plural(ms, msAbs, s, "second");
|
|
10849
|
+
}
|
|
10850
|
+
return ms + " ms";
|
|
10851
|
+
}
|
|
10852
|
+
function plural(ms, msAbs, n, name) {
|
|
10853
|
+
var isPlural = msAbs >= n * 1.5;
|
|
10854
|
+
return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
|
|
10855
|
+
}
|
|
10856
|
+
}
|
|
10857
|
+
});
|
|
10858
|
+
|
|
10859
|
+
// node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/common.js
|
|
10860
|
+
var require_common = __commonJS({
|
|
10861
|
+
"node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/common.js"(exports, module) {
|
|
10862
|
+
function setup(env) {
|
|
10863
|
+
createDebug.debug = createDebug;
|
|
10864
|
+
createDebug.default = createDebug;
|
|
10865
|
+
createDebug.coerce = coerce2;
|
|
10866
|
+
createDebug.disable = disable;
|
|
10867
|
+
createDebug.enable = enable;
|
|
10868
|
+
createDebug.enabled = enabled;
|
|
10869
|
+
createDebug.humanize = require_ms();
|
|
10870
|
+
createDebug.destroy = destroy;
|
|
10871
|
+
Object.keys(env).forEach((key) => {
|
|
10872
|
+
createDebug[key] = env[key];
|
|
10873
|
+
});
|
|
10874
|
+
createDebug.names = [];
|
|
10875
|
+
createDebug.skips = [];
|
|
10876
|
+
createDebug.formatters = {};
|
|
10877
|
+
function selectColor(namespace) {
|
|
10878
|
+
let hash = 0;
|
|
10879
|
+
for (let i = 0; i < namespace.length; i++) {
|
|
10880
|
+
hash = (hash << 5) - hash + namespace.charCodeAt(i);
|
|
10881
|
+
hash |= 0;
|
|
10882
|
+
}
|
|
10883
|
+
return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
|
|
10884
|
+
}
|
|
10885
|
+
createDebug.selectColor = selectColor;
|
|
10886
|
+
function createDebug(namespace) {
|
|
10887
|
+
let prevTime;
|
|
10888
|
+
let enableOverride = null;
|
|
10889
|
+
let namespacesCache;
|
|
10890
|
+
let enabledCache;
|
|
10891
|
+
function debug(...args) {
|
|
10892
|
+
if (!debug.enabled) {
|
|
10893
|
+
return;
|
|
10894
|
+
}
|
|
10895
|
+
const self2 = debug;
|
|
10896
|
+
const curr = Number(/* @__PURE__ */ new Date());
|
|
10897
|
+
const ms = curr - (prevTime || curr);
|
|
10898
|
+
self2.diff = ms;
|
|
10899
|
+
self2.prev = prevTime;
|
|
10900
|
+
self2.curr = curr;
|
|
10901
|
+
prevTime = curr;
|
|
10902
|
+
args[0] = createDebug.coerce(args[0]);
|
|
10903
|
+
if (typeof args[0] !== "string") {
|
|
10904
|
+
args.unshift("%O");
|
|
10905
|
+
}
|
|
10906
|
+
let index = 0;
|
|
10907
|
+
args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
|
|
10908
|
+
if (match === "%%") {
|
|
10909
|
+
return "%";
|
|
10910
|
+
}
|
|
10911
|
+
index++;
|
|
10912
|
+
const formatter = createDebug.formatters[format];
|
|
10913
|
+
if (typeof formatter === "function") {
|
|
10914
|
+
const val = args[index];
|
|
10915
|
+
match = formatter.call(self2, val);
|
|
10916
|
+
args.splice(index, 1);
|
|
10917
|
+
index--;
|
|
10918
|
+
}
|
|
10919
|
+
return match;
|
|
10920
|
+
});
|
|
10921
|
+
createDebug.formatArgs.call(self2, args);
|
|
10922
|
+
const logFn = self2.log || createDebug.log;
|
|
10923
|
+
logFn.apply(self2, args);
|
|
10924
|
+
}
|
|
10925
|
+
debug.namespace = namespace;
|
|
10926
|
+
debug.useColors = createDebug.useColors();
|
|
10927
|
+
debug.color = createDebug.selectColor(namespace);
|
|
10928
|
+
debug.extend = extend3;
|
|
10929
|
+
debug.destroy = createDebug.destroy;
|
|
10930
|
+
Object.defineProperty(debug, "enabled", {
|
|
10931
|
+
enumerable: true,
|
|
10932
|
+
configurable: false,
|
|
10933
|
+
get: () => {
|
|
10934
|
+
if (enableOverride !== null) {
|
|
10935
|
+
return enableOverride;
|
|
10936
|
+
}
|
|
10937
|
+
if (namespacesCache !== createDebug.namespaces) {
|
|
10938
|
+
namespacesCache = createDebug.namespaces;
|
|
10939
|
+
enabledCache = createDebug.enabled(namespace);
|
|
10940
|
+
}
|
|
10941
|
+
return enabledCache;
|
|
10942
|
+
},
|
|
10943
|
+
set: (v) => {
|
|
10944
|
+
enableOverride = v;
|
|
10945
|
+
}
|
|
10946
|
+
});
|
|
10947
|
+
if (typeof createDebug.init === "function") {
|
|
10948
|
+
createDebug.init(debug);
|
|
10949
|
+
}
|
|
10950
|
+
return debug;
|
|
10951
|
+
}
|
|
10952
|
+
function extend3(namespace, delimiter) {
|
|
10953
|
+
const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
|
|
10954
|
+
newDebug.log = this.log;
|
|
10955
|
+
return newDebug;
|
|
10956
|
+
}
|
|
10957
|
+
function enable(namespaces) {
|
|
10958
|
+
createDebug.save(namespaces);
|
|
10959
|
+
createDebug.namespaces = namespaces;
|
|
10960
|
+
createDebug.names = [];
|
|
10961
|
+
createDebug.skips = [];
|
|
10962
|
+
const split = (typeof namespaces === "string" ? namespaces : "").trim().replace(/\s+/g, ",").split(",").filter(Boolean);
|
|
10963
|
+
for (const ns of split) {
|
|
10964
|
+
if (ns[0] === "-") {
|
|
10965
|
+
createDebug.skips.push(ns.slice(1));
|
|
10966
|
+
} else {
|
|
10967
|
+
createDebug.names.push(ns);
|
|
10968
|
+
}
|
|
10969
|
+
}
|
|
10970
|
+
}
|
|
10971
|
+
function matchesTemplate(search, template) {
|
|
10972
|
+
let searchIndex = 0;
|
|
10973
|
+
let templateIndex = 0;
|
|
10974
|
+
let starIndex = -1;
|
|
10975
|
+
let matchIndex = 0;
|
|
10976
|
+
while (searchIndex < search.length) {
|
|
10977
|
+
if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*")) {
|
|
10978
|
+
if (template[templateIndex] === "*") {
|
|
10979
|
+
starIndex = templateIndex;
|
|
10980
|
+
matchIndex = searchIndex;
|
|
10981
|
+
templateIndex++;
|
|
10982
|
+
} else {
|
|
10983
|
+
searchIndex++;
|
|
10984
|
+
templateIndex++;
|
|
10985
|
+
}
|
|
10986
|
+
} else if (starIndex !== -1) {
|
|
10987
|
+
templateIndex = starIndex + 1;
|
|
10988
|
+
matchIndex++;
|
|
10989
|
+
searchIndex = matchIndex;
|
|
10990
|
+
} else {
|
|
10991
|
+
return false;
|
|
10992
|
+
}
|
|
10993
|
+
}
|
|
10994
|
+
while (templateIndex < template.length && template[templateIndex] === "*") {
|
|
10995
|
+
templateIndex++;
|
|
10996
|
+
}
|
|
10997
|
+
return templateIndex === template.length;
|
|
10998
|
+
}
|
|
10999
|
+
function disable() {
|
|
11000
|
+
const namespaces = [
|
|
11001
|
+
...createDebug.names,
|
|
11002
|
+
...createDebug.skips.map((namespace) => "-" + namespace)
|
|
11003
|
+
].join(",");
|
|
11004
|
+
createDebug.enable("");
|
|
11005
|
+
return namespaces;
|
|
11006
|
+
}
|
|
11007
|
+
function enabled(name) {
|
|
11008
|
+
for (const skip of createDebug.skips) {
|
|
11009
|
+
if (matchesTemplate(name, skip)) {
|
|
11010
|
+
return false;
|
|
11011
|
+
}
|
|
11012
|
+
}
|
|
11013
|
+
for (const ns of createDebug.names) {
|
|
11014
|
+
if (matchesTemplate(name, ns)) {
|
|
11015
|
+
return true;
|
|
11016
|
+
}
|
|
11017
|
+
}
|
|
11018
|
+
return false;
|
|
11019
|
+
}
|
|
11020
|
+
function coerce2(val) {
|
|
11021
|
+
if (val instanceof Error) {
|
|
11022
|
+
return val.stack || val.message;
|
|
11023
|
+
}
|
|
11024
|
+
return val;
|
|
11025
|
+
}
|
|
11026
|
+
function destroy() {
|
|
11027
|
+
console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
|
|
11028
|
+
}
|
|
11029
|
+
createDebug.enable(createDebug.load());
|
|
11030
|
+
return createDebug;
|
|
11031
|
+
}
|
|
11032
|
+
module.exports = setup;
|
|
11033
|
+
}
|
|
11034
|
+
});
|
|
11035
|
+
|
|
11036
|
+
// node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/browser.js
|
|
11037
|
+
var require_browser = __commonJS({
|
|
11038
|
+
"node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/browser.js"(exports, module) {
|
|
11039
|
+
exports.formatArgs = formatArgs;
|
|
11040
|
+
exports.save = save;
|
|
11041
|
+
exports.load = load2;
|
|
11042
|
+
exports.useColors = useColors;
|
|
11043
|
+
exports.storage = localstorage();
|
|
11044
|
+
exports.destroy = /* @__PURE__ */ (() => {
|
|
11045
|
+
let warned = false;
|
|
11046
|
+
return () => {
|
|
11047
|
+
if (!warned) {
|
|
11048
|
+
warned = true;
|
|
11049
|
+
console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
|
|
11050
|
+
}
|
|
11051
|
+
};
|
|
11052
|
+
})();
|
|
11053
|
+
exports.colors = [
|
|
11054
|
+
"#0000CC",
|
|
11055
|
+
"#0000FF",
|
|
11056
|
+
"#0033CC",
|
|
11057
|
+
"#0033FF",
|
|
11058
|
+
"#0066CC",
|
|
11059
|
+
"#0066FF",
|
|
11060
|
+
"#0099CC",
|
|
11061
|
+
"#0099FF",
|
|
11062
|
+
"#00CC00",
|
|
11063
|
+
"#00CC33",
|
|
11064
|
+
"#00CC66",
|
|
11065
|
+
"#00CC99",
|
|
11066
|
+
"#00CCCC",
|
|
11067
|
+
"#00CCFF",
|
|
11068
|
+
"#3300CC",
|
|
11069
|
+
"#3300FF",
|
|
11070
|
+
"#3333CC",
|
|
11071
|
+
"#3333FF",
|
|
11072
|
+
"#3366CC",
|
|
11073
|
+
"#3366FF",
|
|
11074
|
+
"#3399CC",
|
|
11075
|
+
"#3399FF",
|
|
11076
|
+
"#33CC00",
|
|
11077
|
+
"#33CC33",
|
|
11078
|
+
"#33CC66",
|
|
11079
|
+
"#33CC99",
|
|
11080
|
+
"#33CCCC",
|
|
11081
|
+
"#33CCFF",
|
|
11082
|
+
"#6600CC",
|
|
11083
|
+
"#6600FF",
|
|
11084
|
+
"#6633CC",
|
|
11085
|
+
"#6633FF",
|
|
11086
|
+
"#66CC00",
|
|
11087
|
+
"#66CC33",
|
|
11088
|
+
"#9900CC",
|
|
11089
|
+
"#9900FF",
|
|
11090
|
+
"#9933CC",
|
|
11091
|
+
"#9933FF",
|
|
11092
|
+
"#99CC00",
|
|
11093
|
+
"#99CC33",
|
|
11094
|
+
"#CC0000",
|
|
11095
|
+
"#CC0033",
|
|
11096
|
+
"#CC0066",
|
|
11097
|
+
"#CC0099",
|
|
11098
|
+
"#CC00CC",
|
|
11099
|
+
"#CC00FF",
|
|
11100
|
+
"#CC3300",
|
|
11101
|
+
"#CC3333",
|
|
11102
|
+
"#CC3366",
|
|
11103
|
+
"#CC3399",
|
|
11104
|
+
"#CC33CC",
|
|
11105
|
+
"#CC33FF",
|
|
11106
|
+
"#CC6600",
|
|
11107
|
+
"#CC6633",
|
|
11108
|
+
"#CC9900",
|
|
11109
|
+
"#CC9933",
|
|
11110
|
+
"#CCCC00",
|
|
11111
|
+
"#CCCC33",
|
|
11112
|
+
"#FF0000",
|
|
11113
|
+
"#FF0033",
|
|
11114
|
+
"#FF0066",
|
|
11115
|
+
"#FF0099",
|
|
11116
|
+
"#FF00CC",
|
|
11117
|
+
"#FF00FF",
|
|
11118
|
+
"#FF3300",
|
|
11119
|
+
"#FF3333",
|
|
11120
|
+
"#FF3366",
|
|
11121
|
+
"#FF3399",
|
|
11122
|
+
"#FF33CC",
|
|
11123
|
+
"#FF33FF",
|
|
11124
|
+
"#FF6600",
|
|
11125
|
+
"#FF6633",
|
|
11126
|
+
"#FF9900",
|
|
11127
|
+
"#FF9933",
|
|
11128
|
+
"#FFCC00",
|
|
11129
|
+
"#FFCC33"
|
|
11130
|
+
];
|
|
11131
|
+
function useColors() {
|
|
11132
|
+
if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) {
|
|
11133
|
+
return true;
|
|
11134
|
+
}
|
|
11135
|
+
if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
|
|
11136
|
+
return false;
|
|
11137
|
+
}
|
|
11138
|
+
let m;
|
|
11139
|
+
return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
|
|
11140
|
+
typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
|
|
11141
|
+
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
|
11142
|
+
typeof navigator !== "undefined" && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
|
|
11143
|
+
typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
|
|
11144
|
+
}
|
|
11145
|
+
function formatArgs(args) {
|
|
11146
|
+
args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module.exports.humanize(this.diff);
|
|
11147
|
+
if (!this.useColors) {
|
|
11148
|
+
return;
|
|
11149
|
+
}
|
|
11150
|
+
const c = "color: " + this.color;
|
|
11151
|
+
args.splice(1, 0, c, "color: inherit");
|
|
11152
|
+
let index = 0;
|
|
11153
|
+
let lastC = 0;
|
|
11154
|
+
args[0].replace(/%[a-zA-Z%]/g, (match) => {
|
|
11155
|
+
if (match === "%%") {
|
|
11156
|
+
return;
|
|
11157
|
+
}
|
|
11158
|
+
index++;
|
|
11159
|
+
if (match === "%c") {
|
|
11160
|
+
lastC = index;
|
|
11161
|
+
}
|
|
11162
|
+
});
|
|
11163
|
+
args.splice(lastC, 0, c);
|
|
11164
|
+
}
|
|
11165
|
+
exports.log = console.debug || console.log || (() => {
|
|
11166
|
+
});
|
|
11167
|
+
function save(namespaces) {
|
|
11168
|
+
try {
|
|
11169
|
+
if (namespaces) {
|
|
11170
|
+
exports.storage.setItem("debug", namespaces);
|
|
11171
|
+
} else {
|
|
11172
|
+
exports.storage.removeItem("debug");
|
|
11173
|
+
}
|
|
11174
|
+
} catch (error) {
|
|
11175
|
+
}
|
|
11176
|
+
}
|
|
11177
|
+
function load2() {
|
|
11178
|
+
let r;
|
|
11179
|
+
try {
|
|
11180
|
+
r = exports.storage.getItem("debug") || exports.storage.getItem("DEBUG");
|
|
11181
|
+
} catch (error) {
|
|
11182
|
+
}
|
|
11183
|
+
if (!r && typeof process !== "undefined" && "env" in process) {
|
|
11184
|
+
r = process.env.DEBUG;
|
|
11185
|
+
}
|
|
11186
|
+
return r;
|
|
11187
|
+
}
|
|
11188
|
+
function localstorage() {
|
|
11189
|
+
try {
|
|
11190
|
+
return localStorage;
|
|
11191
|
+
} catch (error) {
|
|
11192
|
+
}
|
|
11193
|
+
}
|
|
11194
|
+
module.exports = require_common()(exports);
|
|
11195
|
+
var { formatters } = module.exports;
|
|
11196
|
+
formatters.j = function(v) {
|
|
11197
|
+
try {
|
|
11198
|
+
return JSON.stringify(v);
|
|
11199
|
+
} catch (error) {
|
|
11200
|
+
return "[UnexpectedJSONParseError]: " + error.message;
|
|
11201
|
+
}
|
|
11202
|
+
};
|
|
11203
|
+
}
|
|
11204
|
+
});
|
|
11205
|
+
|
|
11206
|
+
// node_modules/.pnpm/has-flag@4.0.0/node_modules/has-flag/index.js
|
|
11207
|
+
var require_has_flag = __commonJS({
|
|
11208
|
+
"node_modules/.pnpm/has-flag@4.0.0/node_modules/has-flag/index.js"(exports, module) {
|
|
11209
|
+
"use strict";
|
|
11210
|
+
module.exports = (flag, argv = process.argv) => {
|
|
11211
|
+
const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
|
|
11212
|
+
const position = argv.indexOf(prefix + flag);
|
|
11213
|
+
const terminatorPosition = argv.indexOf("--");
|
|
11214
|
+
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
11215
|
+
};
|
|
11216
|
+
}
|
|
11217
|
+
});
|
|
11218
|
+
|
|
11219
|
+
// node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js
|
|
11220
|
+
var require_supports_color = __commonJS({
|
|
11221
|
+
"node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js"(exports, module) {
|
|
11222
|
+
"use strict";
|
|
11223
|
+
var os2 = __require("os");
|
|
11224
|
+
var tty = __require("tty");
|
|
11225
|
+
var hasFlag = require_has_flag();
|
|
11226
|
+
var { env } = process;
|
|
11227
|
+
var forceColor;
|
|
11228
|
+
if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
|
|
11229
|
+
forceColor = 0;
|
|
11230
|
+
} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
|
|
11231
|
+
forceColor = 1;
|
|
11232
|
+
}
|
|
11233
|
+
if ("FORCE_COLOR" in env) {
|
|
11234
|
+
if (env.FORCE_COLOR === "true") {
|
|
11235
|
+
forceColor = 1;
|
|
11236
|
+
} else if (env.FORCE_COLOR === "false") {
|
|
11237
|
+
forceColor = 0;
|
|
11238
|
+
} else {
|
|
11239
|
+
forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
|
|
11240
|
+
}
|
|
11241
|
+
}
|
|
11242
|
+
function translateLevel(level) {
|
|
11243
|
+
if (level === 0) {
|
|
11244
|
+
return false;
|
|
11245
|
+
}
|
|
11246
|
+
return {
|
|
11247
|
+
level,
|
|
11248
|
+
hasBasic: true,
|
|
11249
|
+
has256: level >= 2,
|
|
11250
|
+
has16m: level >= 3
|
|
11251
|
+
};
|
|
11252
|
+
}
|
|
11253
|
+
function supportsColor(haveStream, streamIsTTY) {
|
|
11254
|
+
if (forceColor === 0) {
|
|
11255
|
+
return 0;
|
|
11256
|
+
}
|
|
11257
|
+
if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
|
|
11258
|
+
return 3;
|
|
11259
|
+
}
|
|
11260
|
+
if (hasFlag("color=256")) {
|
|
11261
|
+
return 2;
|
|
11262
|
+
}
|
|
11263
|
+
if (haveStream && !streamIsTTY && forceColor === void 0) {
|
|
11264
|
+
return 0;
|
|
11265
|
+
}
|
|
11266
|
+
const min = forceColor || 0;
|
|
11267
|
+
if (env.TERM === "dumb") {
|
|
11268
|
+
return min;
|
|
11269
|
+
}
|
|
11270
|
+
if (process.platform === "win32") {
|
|
11271
|
+
const osRelease = os2.release().split(".");
|
|
11272
|
+
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
11273
|
+
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
11274
|
+
}
|
|
11275
|
+
return 1;
|
|
11276
|
+
}
|
|
11277
|
+
if ("CI" in env) {
|
|
11278
|
+
if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
|
|
11279
|
+
return 1;
|
|
11280
|
+
}
|
|
11281
|
+
return min;
|
|
11282
|
+
}
|
|
11283
|
+
if ("TEAMCITY_VERSION" in env) {
|
|
11284
|
+
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
11285
|
+
}
|
|
11286
|
+
if (env.COLORTERM === "truecolor") {
|
|
11287
|
+
return 3;
|
|
11288
|
+
}
|
|
11289
|
+
if ("TERM_PROGRAM" in env) {
|
|
11290
|
+
const version = parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
|
11291
|
+
switch (env.TERM_PROGRAM) {
|
|
11292
|
+
case "iTerm.app":
|
|
11293
|
+
return version >= 3 ? 3 : 2;
|
|
11294
|
+
case "Apple_Terminal":
|
|
11295
|
+
return 2;
|
|
11296
|
+
}
|
|
11297
|
+
}
|
|
11298
|
+
if (/-256(color)?$/i.test(env.TERM)) {
|
|
11299
|
+
return 2;
|
|
11300
|
+
}
|
|
11301
|
+
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
|
11302
|
+
return 1;
|
|
11303
|
+
}
|
|
11304
|
+
if ("COLORTERM" in env) {
|
|
11305
|
+
return 1;
|
|
11306
|
+
}
|
|
11307
|
+
return min;
|
|
11308
|
+
}
|
|
11309
|
+
function getSupportLevel(stream) {
|
|
11310
|
+
const level = supportsColor(stream, stream && stream.isTTY);
|
|
11311
|
+
return translateLevel(level);
|
|
11312
|
+
}
|
|
11313
|
+
module.exports = {
|
|
11314
|
+
supportsColor: getSupportLevel,
|
|
11315
|
+
stdout: translateLevel(supportsColor(true, tty.isatty(1))),
|
|
11316
|
+
stderr: translateLevel(supportsColor(true, tty.isatty(2)))
|
|
11317
|
+
};
|
|
11318
|
+
}
|
|
11319
|
+
});
|
|
11320
|
+
|
|
11321
|
+
// node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/node.js
|
|
11322
|
+
var require_node = __commonJS({
|
|
11323
|
+
"node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/node.js"(exports, module) {
|
|
11324
|
+
var tty = __require("tty");
|
|
11325
|
+
var util2 = __require("util");
|
|
11326
|
+
exports.init = init;
|
|
11327
|
+
exports.log = log;
|
|
11328
|
+
exports.formatArgs = formatArgs;
|
|
11329
|
+
exports.save = save;
|
|
11330
|
+
exports.load = load2;
|
|
11331
|
+
exports.useColors = useColors;
|
|
11332
|
+
exports.destroy = util2.deprecate(
|
|
11333
|
+
() => {
|
|
11334
|
+
},
|
|
11335
|
+
"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."
|
|
11336
|
+
);
|
|
11337
|
+
exports.colors = [6, 2, 3, 4, 5, 1];
|
|
11338
|
+
try {
|
|
11339
|
+
const supportsColor = require_supports_color();
|
|
11340
|
+
if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
|
|
11341
|
+
exports.colors = [
|
|
11342
|
+
20,
|
|
11343
|
+
21,
|
|
11344
|
+
26,
|
|
11345
|
+
27,
|
|
11346
|
+
32,
|
|
11347
|
+
33,
|
|
11348
|
+
38,
|
|
11349
|
+
39,
|
|
11350
|
+
40,
|
|
11351
|
+
41,
|
|
11352
|
+
42,
|
|
11353
|
+
43,
|
|
11354
|
+
44,
|
|
11355
|
+
45,
|
|
11356
|
+
56,
|
|
11357
|
+
57,
|
|
11358
|
+
62,
|
|
11359
|
+
63,
|
|
11360
|
+
68,
|
|
11361
|
+
69,
|
|
11362
|
+
74,
|
|
11363
|
+
75,
|
|
11364
|
+
76,
|
|
11365
|
+
77,
|
|
11366
|
+
78,
|
|
11367
|
+
79,
|
|
11368
|
+
80,
|
|
11369
|
+
81,
|
|
11370
|
+
92,
|
|
11371
|
+
93,
|
|
11372
|
+
98,
|
|
11373
|
+
99,
|
|
11374
|
+
112,
|
|
11375
|
+
113,
|
|
11376
|
+
128,
|
|
11377
|
+
129,
|
|
11378
|
+
134,
|
|
11379
|
+
135,
|
|
11380
|
+
148,
|
|
11381
|
+
149,
|
|
11382
|
+
160,
|
|
11383
|
+
161,
|
|
11384
|
+
162,
|
|
11385
|
+
163,
|
|
11386
|
+
164,
|
|
11387
|
+
165,
|
|
11388
|
+
166,
|
|
11389
|
+
167,
|
|
11390
|
+
168,
|
|
11391
|
+
169,
|
|
11392
|
+
170,
|
|
11393
|
+
171,
|
|
11394
|
+
172,
|
|
11395
|
+
173,
|
|
11396
|
+
178,
|
|
11397
|
+
179,
|
|
11398
|
+
184,
|
|
11399
|
+
185,
|
|
11400
|
+
196,
|
|
11401
|
+
197,
|
|
11402
|
+
198,
|
|
11403
|
+
199,
|
|
11404
|
+
200,
|
|
11405
|
+
201,
|
|
11406
|
+
202,
|
|
11407
|
+
203,
|
|
11408
|
+
204,
|
|
11409
|
+
205,
|
|
11410
|
+
206,
|
|
11411
|
+
207,
|
|
11412
|
+
208,
|
|
11413
|
+
209,
|
|
11414
|
+
214,
|
|
11415
|
+
215,
|
|
11416
|
+
220,
|
|
11417
|
+
221
|
|
11418
|
+
];
|
|
11419
|
+
}
|
|
11420
|
+
} catch (error) {
|
|
11421
|
+
}
|
|
11422
|
+
exports.inspectOpts = Object.keys(process.env).filter((key) => {
|
|
11423
|
+
return /^debug_/i.test(key);
|
|
11424
|
+
}).reduce((obj, key) => {
|
|
11425
|
+
const prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, (_, k) => {
|
|
11426
|
+
return k.toUpperCase();
|
|
11427
|
+
});
|
|
11428
|
+
let val = process.env[key];
|
|
11429
|
+
if (/^(yes|on|true|enabled)$/i.test(val)) {
|
|
11430
|
+
val = true;
|
|
11431
|
+
} else if (/^(no|off|false|disabled)$/i.test(val)) {
|
|
11432
|
+
val = false;
|
|
11433
|
+
} else if (val === "null") {
|
|
11434
|
+
val = null;
|
|
11435
|
+
} else {
|
|
11436
|
+
val = Number(val);
|
|
11437
|
+
}
|
|
11438
|
+
obj[prop] = val;
|
|
11439
|
+
return obj;
|
|
11440
|
+
}, {});
|
|
11441
|
+
function useColors() {
|
|
11442
|
+
return "colors" in exports.inspectOpts ? Boolean(exports.inspectOpts.colors) : tty.isatty(process.stderr.fd);
|
|
11443
|
+
}
|
|
11444
|
+
function formatArgs(args) {
|
|
11445
|
+
const { namespace: name, useColors: useColors2 } = this;
|
|
11446
|
+
if (useColors2) {
|
|
11447
|
+
const c = this.color;
|
|
11448
|
+
const colorCode = "\x1B[3" + (c < 8 ? c : "8;5;" + c);
|
|
11449
|
+
const prefix = ` ${colorCode};1m${name} \x1B[0m`;
|
|
11450
|
+
args[0] = prefix + args[0].split("\n").join("\n" + prefix);
|
|
11451
|
+
args.push(colorCode + "m+" + module.exports.humanize(this.diff) + "\x1B[0m");
|
|
11452
|
+
} else {
|
|
11453
|
+
args[0] = getDate() + name + " " + args[0];
|
|
11454
|
+
}
|
|
11455
|
+
}
|
|
11456
|
+
function getDate() {
|
|
11457
|
+
if (exports.inspectOpts.hideDate) {
|
|
11458
|
+
return "";
|
|
11459
|
+
}
|
|
11460
|
+
return (/* @__PURE__ */ new Date()).toISOString() + " ";
|
|
11461
|
+
}
|
|
11462
|
+
function log(...args) {
|
|
11463
|
+
return process.stderr.write(util2.formatWithOptions(exports.inspectOpts, ...args) + "\n");
|
|
11464
|
+
}
|
|
11465
|
+
function save(namespaces) {
|
|
11466
|
+
if (namespaces) {
|
|
11467
|
+
process.env.DEBUG = namespaces;
|
|
11468
|
+
} else {
|
|
11469
|
+
delete process.env.DEBUG;
|
|
11470
|
+
}
|
|
11471
|
+
}
|
|
11472
|
+
function load2() {
|
|
11473
|
+
return process.env.DEBUG;
|
|
11474
|
+
}
|
|
11475
|
+
function init(debug) {
|
|
11476
|
+
debug.inspectOpts = {};
|
|
11477
|
+
const keys = Object.keys(exports.inspectOpts);
|
|
11478
|
+
for (let i = 0; i < keys.length; i++) {
|
|
11479
|
+
debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
|
|
11480
|
+
}
|
|
11481
|
+
}
|
|
11482
|
+
module.exports = require_common()(exports);
|
|
11483
|
+
var { formatters } = module.exports;
|
|
11484
|
+
formatters.o = function(v) {
|
|
11485
|
+
this.inspectOpts.colors = this.useColors;
|
|
11486
|
+
return util2.inspect(v, this.inspectOpts).split("\n").map((str2) => str2.trim()).join(" ");
|
|
11487
|
+
};
|
|
11488
|
+
formatters.O = function(v) {
|
|
11489
|
+
this.inspectOpts.colors = this.useColors;
|
|
11490
|
+
return util2.inspect(v, this.inspectOpts);
|
|
11491
|
+
};
|
|
11492
|
+
}
|
|
11493
|
+
});
|
|
11494
|
+
|
|
11495
|
+
// node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/index.js
|
|
11496
|
+
var require_src = __commonJS({
|
|
11497
|
+
"node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/index.js"(exports, module) {
|
|
11498
|
+
if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) {
|
|
11499
|
+
module.exports = require_browser();
|
|
11500
|
+
} else {
|
|
11501
|
+
module.exports = require_node();
|
|
11502
|
+
}
|
|
11503
|
+
}
|
|
11504
|
+
});
|
|
11505
|
+
|
|
10743
11506
|
// node_modules/.pnpm/follow-redirects@1.16.0/node_modules/follow-redirects/debug.js
|
|
10744
11507
|
var require_debug = __commonJS({
|
|
10745
11508
|
"node_modules/.pnpm/follow-redirects@1.16.0/node_modules/follow-redirects/debug.js"(exports, module) {
|
|
@@ -10747,7 +11510,7 @@ var require_debug = __commonJS({
|
|
|
10747
11510
|
module.exports = function() {
|
|
10748
11511
|
if (!debug) {
|
|
10749
11512
|
try {
|
|
10750
|
-
debug =
|
|
11513
|
+
debug = require_src()("follow-redirects");
|
|
10751
11514
|
} catch (error) {
|
|
10752
11515
|
}
|
|
10753
11516
|
if (typeof debug !== "function") {
|
|
@@ -111330,7 +112093,7 @@ function channelMsgToLarkEvent(msg) {
|
|
|
111330
112093
|
create_time: m?.["create_time"] ?? String(msg.createTime ?? Date.now())
|
|
111331
112094
|
};
|
|
111332
112095
|
}
|
|
111333
|
-
var import_node_sdk, execFile4, LEARNED_CHATS_LIMIT, SEEN_MESSAGES_LIMIT, MAX_MESSAGE_ATTEMPTS, OPEN_CHAT_DISCOVERY_LOOKBACK_MS, OPEN_CHAT_DISCOVERY_BOOTSTRAP_LOOKBACK_MS, PROCESSING_REACTION_EMOJI, DEFAULT_CONNECT_GRACE_MS, ChannelClient;
|
|
112096
|
+
var import_node_sdk, execFile4, LEARNED_CHATS_LIMIT, SEEN_MESSAGES_LIMIT, MAX_MESSAGE_ATTEMPTS, OPEN_CHAT_DISCOVERY_LOOKBACK_MS, OPEN_CHAT_DISCOVERY_BOOTSTRAP_LOOKBACK_MS, PROCESSING_REACTION_EMOJI, GAP_FILL_MAX_ATTEMPTS, GAP_FILL_BACKOFF_BASE_MS, UNRESOLVED_WINDOW_MAX_CHATS, UNRESOLVED_WINDOW_MAX_AGE_MS, DEFAULT_CONNECT_GRACE_MS, ChannelClient;
|
|
111334
112097
|
var init_channelClient = __esm({
|
|
111335
112098
|
"src/lark/channelClient.ts"() {
|
|
111336
112099
|
"use strict";
|
|
@@ -111344,6 +112107,10 @@ var init_channelClient = __esm({
|
|
|
111344
112107
|
OPEN_CHAT_DISCOVERY_LOOKBACK_MS = 9e4;
|
|
111345
112108
|
OPEN_CHAT_DISCOVERY_BOOTSTRAP_LOOKBACK_MS = 30 * 60 * 1e3;
|
|
111346
112109
|
PROCESSING_REACTION_EMOJI = "Typing";
|
|
112110
|
+
GAP_FILL_MAX_ATTEMPTS = 3;
|
|
112111
|
+
GAP_FILL_BACKOFF_BASE_MS = 1e3;
|
|
112112
|
+
UNRESOLVED_WINDOW_MAX_CHATS = 50;
|
|
112113
|
+
UNRESOLVED_WINDOW_MAX_AGE_MS = 30 * 60 * 1e3;
|
|
111347
112114
|
DEFAULT_CONNECT_GRACE_MS = 3e3;
|
|
111348
112115
|
ChannelClient = class {
|
|
111349
112116
|
opts;
|
|
@@ -111408,6 +112175,27 @@ var init_channelClient = __esm({
|
|
|
111408
112175
|
* search space.
|
|
111409
112176
|
*/
|
|
111410
112177
|
recentlySeenChatIds = /* @__PURE__ */ new Set();
|
|
112178
|
+
/**
|
|
112179
|
+
* PER-CHAT unresolved gapFill windows: chatId → the OLDEST windowStart (ms) for
|
|
112180
|
+
* which that chat's lark-cli history pull still failed after all retries. On a
|
|
112181
|
+
* later gapFill that ACTUALLY pulls this chat, we extend the look-back to cover
|
|
112182
|
+
* its oldest unresolved windowStart and only clear it once the pull truly
|
|
112183
|
+
* reached back that far (its `--start` <= the tracked windowStart). Per-chat (not
|
|
112184
|
+
* a single shared list) so a successful run over chat-set {B} can never falsely
|
|
112185
|
+
* resolve chat A's window (BLOCKER 1), and the look-back-vs-clamp mismatch can
|
|
112186
|
+
* never mark a window resolved before it was reached (BLOCKER 2).
|
|
112187
|
+
*
|
|
112188
|
+
* Bounded: one timestamp per chat (so naturally bounded by #chats), pruned by age
|
|
112189
|
+
* (UNRESOLVED_WINDOW_MAX_AGE_MS — older = unrecoverable from history anyway) and
|
|
112190
|
+
* capped at UNRESOLVED_WINDOW_MAX_CHATS tracked chats.
|
|
112191
|
+
*/
|
|
112192
|
+
unresolvedGapWindowByChat = /* @__PURE__ */ new Map();
|
|
112193
|
+
/**
|
|
112194
|
+
* Backoff sleep used by the per-chat history-pull retry. Indirected through a
|
|
112195
|
+
* field purely so tests can observe/await the backoff deterministically; in
|
|
112196
|
+
* production it is the real timer-based {@link sleep}.
|
|
112197
|
+
*/
|
|
112198
|
+
gapFillSleep = sleep;
|
|
111411
112199
|
openChatDiscoveryTimer = null;
|
|
111412
112200
|
openChatDiscoveryRunning = false;
|
|
111413
112201
|
openChatDiscoveryBootstrapped = false;
|
|
@@ -111429,6 +112217,28 @@ var init_channelClient = __esm({
|
|
|
111429
112217
|
}
|
|
111430
112218
|
this.opts = opts;
|
|
111431
112219
|
}
|
|
112220
|
+
/**
|
|
112221
|
+
* TEST SEAM (deletable): override the gap-fill retry backoff sleep so unit
|
|
112222
|
+
* tests can observe the backoff durations and avoid real timers. No-op for
|
|
112223
|
+
* production — the default is the real {@link sleep}. Returns the recorded
|
|
112224
|
+
* backoff arg via the provided callback's own bookkeeping.
|
|
112225
|
+
*/
|
|
112226
|
+
setGapFillSleepForTest(fn) {
|
|
112227
|
+
this.gapFillSleep = fn;
|
|
112228
|
+
}
|
|
112229
|
+
/** TEST-ONLY read of the per-chat unresolved-window replay map (chatId → windowStart). */
|
|
112230
|
+
unresolvedGapWindowsForTest() {
|
|
112231
|
+
return new Map(this.unresolvedGapWindowByChat);
|
|
112232
|
+
}
|
|
112233
|
+
/**
|
|
112234
|
+
* TEST-ONLY direct gapFill invocation with an explicit chat-set override —
|
|
112235
|
+
* mirrors exactly how open-chat discovery calls gapFill on a SUBSET of chats.
|
|
112236
|
+
* Used to reproduce the cross-chat-set replay isolation (BLOCKER 1) without
|
|
112237
|
+
* standing up the full discovery timer.
|
|
112238
|
+
*/
|
|
112239
|
+
async gapFillForTest(disconnectAt, chatIds) {
|
|
112240
|
+
await this.gapFill(disconnectAt, (s) => console.log(`[channel.client] ${s}`), chatIds);
|
|
112241
|
+
}
|
|
111432
112242
|
/**
|
|
111433
112243
|
* Async iterator over inbound events — interface-compatible with LarkClient.
|
|
111434
112244
|
* Connects the WS on first call. The SDK's policy gate (requireMention +
|
|
@@ -111494,7 +112304,25 @@ var init_channelClient = __esm({
|
|
|
111494
112304
|
// ── WS robustness knobs (node-sdk ≥1.64; all OFF by default) ──────────
|
|
111495
112305
|
// Abort a handshake that hangs on a stuck DNS/proxy/NAT path so the retry
|
|
111496
112306
|
// loop can try again, instead of waiting indefinitely. Successful TLS
|
|
111497
|
-
// handshakes are tens of ms; 15s is a wide safety margin.
|
|
112307
|
+
// handshakes are tens of ms; 15s is a wide safety margin. KEPT ON: it is
|
|
112308
|
+
// the right behaviour (abort + reconnect beats hanging forever).
|
|
112309
|
+
//
|
|
112310
|
+
// CAVEAT — raw '_WebSocket' 'error' on abort: when this timeout fires the
|
|
112311
|
+
// SDK aborts the underlying ws, which emits a RAW 'error' event on the
|
|
112312
|
+
// socket. That socket is owned privately inside node-sdk's WSClient
|
|
112313
|
+
// (no public `on()`, no accessor for the raw ws — verified against
|
|
112314
|
+
// node-sdk 1.67.0 types: WSClient is not an EventEmitter and keeps the
|
|
112315
|
+
// `_WebSocket` in a closure), so we CANNOT attach a precise 'error'
|
|
112316
|
+
// listener here. With no listener, Node re-throws it as an
|
|
112317
|
+
// uncaughtException → it would kill the whole (multi-bot) process.
|
|
112318
|
+
// → That raw error is instead caught by the process-level crash guard
|
|
112319
|
+
// in main.ts (registerCrashGuard: uncaughtException handler that logs
|
|
112320
|
+
// and never exits). The channel-level `channel.on("error", …)` below
|
|
112321
|
+
// is a DIFFERENT, higher-level error and does NOT cover this raw case.
|
|
112322
|
+
// → Residual uncertainty (left for acceptance load-testing): that the
|
|
112323
|
+
// process guard reliably catches this specific raw abort path under
|
|
112324
|
+
// real network flap. If a future node-sdk / @larksuite/channel exposes
|
|
112325
|
+
// the ws or attaches its own listener, prefer that and drop the guard.
|
|
111498
112326
|
handshakeTimeoutMs: 15e3,
|
|
111499
112327
|
// Liveness watchdog (SECONDS): if no inbound frame arrives within this
|
|
111500
112328
|
// window after the last ping, treat the socket as dead and reconnect —
|
|
@@ -111611,9 +112439,6 @@ var init_channelClient = __esm({
|
|
|
111611
112439
|
const MAX_GAP_FILL_WINDOW_MS = 5 * 60 * 1e3;
|
|
111612
112440
|
const BUFFER_MS = 3e4;
|
|
111613
112441
|
const now = Date.now();
|
|
111614
|
-
const windowStart = Math.max(disconnectAt - BUFFER_MS, now - MAX_GAP_FILL_WINDOW_MS);
|
|
111615
|
-
const startIso = new Date(windowStart).toISOString();
|
|
111616
|
-
const endIso = new Date(now + BUFFER_MS).toISOString();
|
|
111617
112442
|
const larkCli = this.opts.larkCliPath ?? "lark-cli";
|
|
111618
112443
|
const profileArgs = this.opts.larkCliProfile ? ["--profile", this.opts.larkCliProfile] : [];
|
|
111619
112444
|
const botOpenId = this.opts.botOpenId;
|
|
@@ -111623,16 +112448,29 @@ var init_channelClient = __esm({
|
|
|
111623
112448
|
...this.opts.allowedChatIds,
|
|
111624
112449
|
...this.recentlySeenChatIds
|
|
111625
112450
|
]);
|
|
112451
|
+
this.pruneUnresolvedGapWindows(now);
|
|
112452
|
+
let oldestRelevantUnresolved = Infinity;
|
|
112453
|
+
for (const chatId of gapFillChatIds) {
|
|
112454
|
+
const ws = this.unresolvedGapWindowByChat.get(chatId);
|
|
112455
|
+
if (ws !== void 0 && ws < oldestRelevantUnresolved) oldestRelevantUnresolved = ws;
|
|
112456
|
+
}
|
|
112457
|
+
const hasReplay = oldestRelevantUnresolved !== Infinity;
|
|
112458
|
+
const lookBackFrom = Math.min(disconnectAt, hasReplay ? oldestRelevantUnresolved : disconnectAt);
|
|
112459
|
+
const clampCeilingMs = hasReplay ? UNRESOLVED_WINDOW_MAX_AGE_MS : MAX_GAP_FILL_WINDOW_MS;
|
|
112460
|
+
const windowStart = Math.max(lookBackFrom - BUFFER_MS, now - clampCeilingMs);
|
|
112461
|
+
const startIso = new Date(windowStart).toISOString();
|
|
112462
|
+
const endIso = new Date(now + BUFFER_MS).toISOString();
|
|
111626
112463
|
if (gapFillChatIds.size === 0) {
|
|
111627
112464
|
log(
|
|
111628
112465
|
`gap-fill skipped: no known chats for window=${startIso}..${endIso} (allowedChatIds is empty and no live chat has been seen yet)`
|
|
111629
112466
|
);
|
|
111630
112467
|
return;
|
|
111631
112468
|
}
|
|
112469
|
+
let anyChatFailed = false;
|
|
111632
112470
|
for (const chatId of gapFillChatIds) {
|
|
111633
112471
|
if (this.closed) break;
|
|
111634
112472
|
try {
|
|
111635
|
-
const
|
|
112473
|
+
const args = [
|
|
111636
112474
|
"im",
|
|
111637
112475
|
"+chat-messages-list",
|
|
111638
112476
|
"--as",
|
|
@@ -111651,7 +112489,8 @@ var init_channelClient = __esm({
|
|
|
111651
112489
|
"json",
|
|
111652
112490
|
"--no-reactions",
|
|
111653
112491
|
...profileArgs
|
|
111654
|
-
]
|
|
112492
|
+
];
|
|
112493
|
+
const { stdout: stdout2 } = await this.execWithRetry(larkCli, args, chatId, log);
|
|
111655
112494
|
let messages;
|
|
111656
112495
|
try {
|
|
111657
112496
|
messages = parseLarkCliMessages(stdout2) ?? [];
|
|
@@ -111719,16 +112558,91 @@ var init_channelClient = __esm({
|
|
|
111719
112558
|
this.queue.push(ev);
|
|
111720
112559
|
totalDispatched++;
|
|
111721
112560
|
}
|
|
112561
|
+
this.resolveUnresolvedGapWindow(chatId, windowStart);
|
|
111722
112562
|
} catch (e) {
|
|
112563
|
+
anyChatFailed = true;
|
|
112564
|
+
this.recordUnresolvedGapWindow(chatId, windowStart, log);
|
|
111723
112565
|
log(
|
|
111724
|
-
`gap-fill: lark-cli failed for chat ${chatId}: ` + (e instanceof Error ? e.message : String(e))
|
|
112566
|
+
`gap-fill: lark-cli failed for chat ${chatId} after ${GAP_FILL_MAX_ATTEMPTS} attempt(s): ` + (e instanceof Error ? e.message : String(e))
|
|
111725
112567
|
);
|
|
111726
112568
|
}
|
|
111727
112569
|
}
|
|
111728
112570
|
log(
|
|
111729
|
-
`gap-fill complete: window=${startIso}..${endIso}, fetched=${totalFetched}, dispatched=${totalDispatched}`
|
|
112571
|
+
`gap-fill complete: window=${startIso}..${endIso}, fetched=${totalFetched}, dispatched=${totalDispatched}` + (anyChatFailed ? ` (some chats failed \u2014 per-chat windows queued for replay)` : ``)
|
|
111730
112572
|
);
|
|
111731
112573
|
}
|
|
112574
|
+
/**
|
|
112575
|
+
* Run a lark-cli history pull with bounded retries + exponential backoff.
|
|
112576
|
+
* Retries on ANY thrown error (transient TLS timeout being the motivating case),
|
|
112577
|
+
* up to {@link GAP_FILL_MAX_ATTEMPTS}. Backoff is GAP_FILL_BACKOFF_BASE_MS *
|
|
112578
|
+
* 2^(attempt-1) (~1s / 2s). Re-throws the last error if all attempts fail so the
|
|
112579
|
+
* caller can flag the window for replay. Backoff goes through {@link gapFillSleep}
|
|
112580
|
+
* (injectable) so tests can observe it deterministically.
|
|
112581
|
+
*/
|
|
112582
|
+
async execWithRetry(larkCli, args, chatId, log) {
|
|
112583
|
+
let lastErr;
|
|
112584
|
+
for (let attempt = 1; attempt <= GAP_FILL_MAX_ATTEMPTS; attempt++) {
|
|
112585
|
+
if (this.closed) throw lastErr ?? new Error("closed");
|
|
112586
|
+
try {
|
|
112587
|
+
return await execFile4(larkCli, args);
|
|
112588
|
+
} catch (e) {
|
|
112589
|
+
lastErr = e;
|
|
112590
|
+
if (attempt < GAP_FILL_MAX_ATTEMPTS) {
|
|
112591
|
+
const backoffMs = GAP_FILL_BACKOFF_BASE_MS * 2 ** (attempt - 1);
|
|
112592
|
+
log(
|
|
112593
|
+
`gap-fill: lark-cli pull failed for chat ${chatId} (attempt ${attempt}/${GAP_FILL_MAX_ATTEMPTS}) \u2014 retrying in ${backoffMs}ms: ` + (e instanceof Error ? e.message : String(e))
|
|
112594
|
+
);
|
|
112595
|
+
await this.gapFillSleep(backoffMs);
|
|
112596
|
+
}
|
|
112597
|
+
}
|
|
112598
|
+
}
|
|
112599
|
+
throw lastErr;
|
|
112600
|
+
}
|
|
112601
|
+
/** Drop per-chat unresolved windows older than the replay max age (unrecoverable). */
|
|
112602
|
+
pruneUnresolvedGapWindows(now) {
|
|
112603
|
+
const cutoff = now - UNRESOLVED_WINDOW_MAX_AGE_MS;
|
|
112604
|
+
for (const [chatId, windowStart] of this.unresolvedGapWindowByChat) {
|
|
112605
|
+
if (windowStart < cutoff) this.unresolvedGapWindowByChat.delete(chatId);
|
|
112606
|
+
}
|
|
112607
|
+
}
|
|
112608
|
+
/**
|
|
112609
|
+
* Record (or keep the OLDEST) unresolved window for a chat whose pull failed.
|
|
112610
|
+
* Bounded by chat count: if the map is at capacity and this is a new chat, we
|
|
112611
|
+
* evict the chat with the NEWEST window (least at risk of aging out) so the
|
|
112612
|
+
* oldest at-risk windows survive to be replayed first.
|
|
112613
|
+
*/
|
|
112614
|
+
recordUnresolvedGapWindow(chatId, windowStart, log) {
|
|
112615
|
+
const existing = this.unresolvedGapWindowByChat.get(chatId);
|
|
112616
|
+
if (existing !== void 0 && existing <= windowStart) return;
|
|
112617
|
+
if (existing === void 0 && this.unresolvedGapWindowByChat.size >= UNRESOLVED_WINDOW_MAX_CHATS) {
|
|
112618
|
+
let newestChat = null;
|
|
112619
|
+
let newestWs = -Infinity;
|
|
112620
|
+
for (const [c, ws] of this.unresolvedGapWindowByChat) {
|
|
112621
|
+
if (ws > newestWs) {
|
|
112622
|
+
newestWs = ws;
|
|
112623
|
+
newestChat = c;
|
|
112624
|
+
}
|
|
112625
|
+
}
|
|
112626
|
+
if (newestChat !== null && newestWs > windowStart) this.unresolvedGapWindowByChat.delete(newestChat);
|
|
112627
|
+
else if (newestChat !== null) return;
|
|
112628
|
+
}
|
|
112629
|
+
this.unresolvedGapWindowByChat.set(chatId, windowStart);
|
|
112630
|
+
log(
|
|
112631
|
+
`gap-fill: queued unresolved window for chat ${chatId} start=${new Date(windowStart).toISOString()} (tracked chats=${this.unresolvedGapWindowByChat.size})`
|
|
112632
|
+
);
|
|
112633
|
+
}
|
|
112634
|
+
/**
|
|
112635
|
+
* Resolve a chat's unresolved window on a SUCCESSFUL pull — but ONLY if this
|
|
112636
|
+
* run's `coveredFrom` (its lark-cli `--start`) actually reached back to at or
|
|
112637
|
+
* before the tracked windowStart. If the clamp kept `coveredFrom` NEWER than the
|
|
112638
|
+
* tracked window, the old window was NOT really covered → keep it queued so a
|
|
112639
|
+
* later, wider replay can reach it (BLOCKER 2).
|
|
112640
|
+
*/
|
|
112641
|
+
resolveUnresolvedGapWindow(chatId, coveredFrom) {
|
|
112642
|
+
const tracked = this.unresolvedGapWindowByChat.get(chatId);
|
|
112643
|
+
if (tracked === void 0) return;
|
|
112644
|
+
if (coveredFrom <= tracked) this.unresolvedGapWindowByChat.delete(chatId);
|
|
112645
|
+
}
|
|
111732
112646
|
startOpenChatDiscovery(log) {
|
|
111733
112647
|
if (this.opts.allowedChatIds.size > 0) return;
|
|
111734
112648
|
if (this.openChatDiscoveryTimer) return;
|
|
@@ -116339,7 +117253,7 @@ var require_canvas = __commonJS({
|
|
|
116339
117253
|
});
|
|
116340
117254
|
|
|
116341
117255
|
// node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/browser.js
|
|
116342
|
-
var
|
|
117256
|
+
var require_browser2 = __commonJS({
|
|
116343
117257
|
"node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/browser.js"(exports) {
|
|
116344
117258
|
var canPromise = require_can_promise();
|
|
116345
117259
|
var QRCode2 = require_qrcode();
|
|
@@ -116486,7 +117400,7 @@ var require_server = __commonJS({
|
|
|
116486
117400
|
}
|
|
116487
117401
|
}
|
|
116488
117402
|
exports.create = QRCode2.create;
|
|
116489
|
-
exports.toCanvas =
|
|
117403
|
+
exports.toCanvas = require_browser2().toCanvas;
|
|
116490
117404
|
exports.toString = function toString3(text, opts, cb) {
|
|
116491
117405
|
const params = checkParams(text, opts, cb);
|
|
116492
117406
|
const type2 = params.opts ? params.opts.type : void 0;
|