larkway 0.3.16 → 0.3.18

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/main.js CHANGED
@@ -10379,6 +10379,769 @@ var require_proxy_from_env = __commonJS({
10379
10379
  }
10380
10380
  });
10381
10381
 
10382
+ // node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js
10383
+ var require_ms = __commonJS({
10384
+ "node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js"(exports, module) {
10385
+ var s = 1e3;
10386
+ var m = s * 60;
10387
+ var h = m * 60;
10388
+ var d = h * 24;
10389
+ var w = d * 7;
10390
+ var y = d * 365.25;
10391
+ module.exports = function(val, options) {
10392
+ options = options || {};
10393
+ var type2 = typeof val;
10394
+ if (type2 === "string" && val.length > 0) {
10395
+ return parse(val);
10396
+ } else if (type2 === "number" && isFinite(val)) {
10397
+ return options.long ? fmtLong(val) : fmtShort(val);
10398
+ }
10399
+ throw new Error(
10400
+ "val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
10401
+ );
10402
+ };
10403
+ function parse(str2) {
10404
+ str2 = String(str2);
10405
+ if (str2.length > 100) {
10406
+ return;
10407
+ }
10408
+ 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(
10409
+ str2
10410
+ );
10411
+ if (!match) {
10412
+ return;
10413
+ }
10414
+ var n = parseFloat(match[1]);
10415
+ var type2 = (match[2] || "ms").toLowerCase();
10416
+ switch (type2) {
10417
+ case "years":
10418
+ case "year":
10419
+ case "yrs":
10420
+ case "yr":
10421
+ case "y":
10422
+ return n * y;
10423
+ case "weeks":
10424
+ case "week":
10425
+ case "w":
10426
+ return n * w;
10427
+ case "days":
10428
+ case "day":
10429
+ case "d":
10430
+ return n * d;
10431
+ case "hours":
10432
+ case "hour":
10433
+ case "hrs":
10434
+ case "hr":
10435
+ case "h":
10436
+ return n * h;
10437
+ case "minutes":
10438
+ case "minute":
10439
+ case "mins":
10440
+ case "min":
10441
+ case "m":
10442
+ return n * m;
10443
+ case "seconds":
10444
+ case "second":
10445
+ case "secs":
10446
+ case "sec":
10447
+ case "s":
10448
+ return n * s;
10449
+ case "milliseconds":
10450
+ case "millisecond":
10451
+ case "msecs":
10452
+ case "msec":
10453
+ case "ms":
10454
+ return n;
10455
+ default:
10456
+ return void 0;
10457
+ }
10458
+ }
10459
+ function fmtShort(ms) {
10460
+ var msAbs = Math.abs(ms);
10461
+ if (msAbs >= d) {
10462
+ return Math.round(ms / d) + "d";
10463
+ }
10464
+ if (msAbs >= h) {
10465
+ return Math.round(ms / h) + "h";
10466
+ }
10467
+ if (msAbs >= m) {
10468
+ return Math.round(ms / m) + "m";
10469
+ }
10470
+ if (msAbs >= s) {
10471
+ return Math.round(ms / s) + "s";
10472
+ }
10473
+ return ms + "ms";
10474
+ }
10475
+ function fmtLong(ms) {
10476
+ var msAbs = Math.abs(ms);
10477
+ if (msAbs >= d) {
10478
+ return plural(ms, msAbs, d, "day");
10479
+ }
10480
+ if (msAbs >= h) {
10481
+ return plural(ms, msAbs, h, "hour");
10482
+ }
10483
+ if (msAbs >= m) {
10484
+ return plural(ms, msAbs, m, "minute");
10485
+ }
10486
+ if (msAbs >= s) {
10487
+ return plural(ms, msAbs, s, "second");
10488
+ }
10489
+ return ms + " ms";
10490
+ }
10491
+ function plural(ms, msAbs, n, name) {
10492
+ var isPlural = msAbs >= n * 1.5;
10493
+ return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
10494
+ }
10495
+ }
10496
+ });
10497
+
10498
+ // node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/common.js
10499
+ var require_common = __commonJS({
10500
+ "node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/common.js"(exports, module) {
10501
+ function setup(env) {
10502
+ createDebug.debug = createDebug;
10503
+ createDebug.default = createDebug;
10504
+ createDebug.coerce = coerce2;
10505
+ createDebug.disable = disable;
10506
+ createDebug.enable = enable;
10507
+ createDebug.enabled = enabled;
10508
+ createDebug.humanize = require_ms();
10509
+ createDebug.destroy = destroy;
10510
+ Object.keys(env).forEach((key) => {
10511
+ createDebug[key] = env[key];
10512
+ });
10513
+ createDebug.names = [];
10514
+ createDebug.skips = [];
10515
+ createDebug.formatters = {};
10516
+ function selectColor(namespace) {
10517
+ let hash = 0;
10518
+ for (let i = 0; i < namespace.length; i++) {
10519
+ hash = (hash << 5) - hash + namespace.charCodeAt(i);
10520
+ hash |= 0;
10521
+ }
10522
+ return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
10523
+ }
10524
+ createDebug.selectColor = selectColor;
10525
+ function createDebug(namespace) {
10526
+ let prevTime;
10527
+ let enableOverride = null;
10528
+ let namespacesCache;
10529
+ let enabledCache;
10530
+ function debug(...args) {
10531
+ if (!debug.enabled) {
10532
+ return;
10533
+ }
10534
+ const self2 = debug;
10535
+ const curr = Number(/* @__PURE__ */ new Date());
10536
+ const ms = curr - (prevTime || curr);
10537
+ self2.diff = ms;
10538
+ self2.prev = prevTime;
10539
+ self2.curr = curr;
10540
+ prevTime = curr;
10541
+ args[0] = createDebug.coerce(args[0]);
10542
+ if (typeof args[0] !== "string") {
10543
+ args.unshift("%O");
10544
+ }
10545
+ let index = 0;
10546
+ args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
10547
+ if (match === "%%") {
10548
+ return "%";
10549
+ }
10550
+ index++;
10551
+ const formatter = createDebug.formatters[format];
10552
+ if (typeof formatter === "function") {
10553
+ const val = args[index];
10554
+ match = formatter.call(self2, val);
10555
+ args.splice(index, 1);
10556
+ index--;
10557
+ }
10558
+ return match;
10559
+ });
10560
+ createDebug.formatArgs.call(self2, args);
10561
+ const logFn = self2.log || createDebug.log;
10562
+ logFn.apply(self2, args);
10563
+ }
10564
+ debug.namespace = namespace;
10565
+ debug.useColors = createDebug.useColors();
10566
+ debug.color = createDebug.selectColor(namespace);
10567
+ debug.extend = extend3;
10568
+ debug.destroy = createDebug.destroy;
10569
+ Object.defineProperty(debug, "enabled", {
10570
+ enumerable: true,
10571
+ configurable: false,
10572
+ get: () => {
10573
+ if (enableOverride !== null) {
10574
+ return enableOverride;
10575
+ }
10576
+ if (namespacesCache !== createDebug.namespaces) {
10577
+ namespacesCache = createDebug.namespaces;
10578
+ enabledCache = createDebug.enabled(namespace);
10579
+ }
10580
+ return enabledCache;
10581
+ },
10582
+ set: (v) => {
10583
+ enableOverride = v;
10584
+ }
10585
+ });
10586
+ if (typeof createDebug.init === "function") {
10587
+ createDebug.init(debug);
10588
+ }
10589
+ return debug;
10590
+ }
10591
+ function extend3(namespace, delimiter) {
10592
+ const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
10593
+ newDebug.log = this.log;
10594
+ return newDebug;
10595
+ }
10596
+ function enable(namespaces) {
10597
+ createDebug.save(namespaces);
10598
+ createDebug.namespaces = namespaces;
10599
+ createDebug.names = [];
10600
+ createDebug.skips = [];
10601
+ const split = (typeof namespaces === "string" ? namespaces : "").trim().replace(/\s+/g, ",").split(",").filter(Boolean);
10602
+ for (const ns of split) {
10603
+ if (ns[0] === "-") {
10604
+ createDebug.skips.push(ns.slice(1));
10605
+ } else {
10606
+ createDebug.names.push(ns);
10607
+ }
10608
+ }
10609
+ }
10610
+ function matchesTemplate(search, template) {
10611
+ let searchIndex = 0;
10612
+ let templateIndex = 0;
10613
+ let starIndex = -1;
10614
+ let matchIndex = 0;
10615
+ while (searchIndex < search.length) {
10616
+ if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*")) {
10617
+ if (template[templateIndex] === "*") {
10618
+ starIndex = templateIndex;
10619
+ matchIndex = searchIndex;
10620
+ templateIndex++;
10621
+ } else {
10622
+ searchIndex++;
10623
+ templateIndex++;
10624
+ }
10625
+ } else if (starIndex !== -1) {
10626
+ templateIndex = starIndex + 1;
10627
+ matchIndex++;
10628
+ searchIndex = matchIndex;
10629
+ } else {
10630
+ return false;
10631
+ }
10632
+ }
10633
+ while (templateIndex < template.length && template[templateIndex] === "*") {
10634
+ templateIndex++;
10635
+ }
10636
+ return templateIndex === template.length;
10637
+ }
10638
+ function disable() {
10639
+ const namespaces = [
10640
+ ...createDebug.names,
10641
+ ...createDebug.skips.map((namespace) => "-" + namespace)
10642
+ ].join(",");
10643
+ createDebug.enable("");
10644
+ return namespaces;
10645
+ }
10646
+ function enabled(name) {
10647
+ for (const skip of createDebug.skips) {
10648
+ if (matchesTemplate(name, skip)) {
10649
+ return false;
10650
+ }
10651
+ }
10652
+ for (const ns of createDebug.names) {
10653
+ if (matchesTemplate(name, ns)) {
10654
+ return true;
10655
+ }
10656
+ }
10657
+ return false;
10658
+ }
10659
+ function coerce2(val) {
10660
+ if (val instanceof Error) {
10661
+ return val.stack || val.message;
10662
+ }
10663
+ return val;
10664
+ }
10665
+ function destroy() {
10666
+ console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
10667
+ }
10668
+ createDebug.enable(createDebug.load());
10669
+ return createDebug;
10670
+ }
10671
+ module.exports = setup;
10672
+ }
10673
+ });
10674
+
10675
+ // node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/browser.js
10676
+ var require_browser = __commonJS({
10677
+ "node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/browser.js"(exports, module) {
10678
+ exports.formatArgs = formatArgs;
10679
+ exports.save = save;
10680
+ exports.load = load2;
10681
+ exports.useColors = useColors;
10682
+ exports.storage = localstorage();
10683
+ exports.destroy = /* @__PURE__ */ (() => {
10684
+ let warned = false;
10685
+ return () => {
10686
+ if (!warned) {
10687
+ warned = true;
10688
+ console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
10689
+ }
10690
+ };
10691
+ })();
10692
+ exports.colors = [
10693
+ "#0000CC",
10694
+ "#0000FF",
10695
+ "#0033CC",
10696
+ "#0033FF",
10697
+ "#0066CC",
10698
+ "#0066FF",
10699
+ "#0099CC",
10700
+ "#0099FF",
10701
+ "#00CC00",
10702
+ "#00CC33",
10703
+ "#00CC66",
10704
+ "#00CC99",
10705
+ "#00CCCC",
10706
+ "#00CCFF",
10707
+ "#3300CC",
10708
+ "#3300FF",
10709
+ "#3333CC",
10710
+ "#3333FF",
10711
+ "#3366CC",
10712
+ "#3366FF",
10713
+ "#3399CC",
10714
+ "#3399FF",
10715
+ "#33CC00",
10716
+ "#33CC33",
10717
+ "#33CC66",
10718
+ "#33CC99",
10719
+ "#33CCCC",
10720
+ "#33CCFF",
10721
+ "#6600CC",
10722
+ "#6600FF",
10723
+ "#6633CC",
10724
+ "#6633FF",
10725
+ "#66CC00",
10726
+ "#66CC33",
10727
+ "#9900CC",
10728
+ "#9900FF",
10729
+ "#9933CC",
10730
+ "#9933FF",
10731
+ "#99CC00",
10732
+ "#99CC33",
10733
+ "#CC0000",
10734
+ "#CC0033",
10735
+ "#CC0066",
10736
+ "#CC0099",
10737
+ "#CC00CC",
10738
+ "#CC00FF",
10739
+ "#CC3300",
10740
+ "#CC3333",
10741
+ "#CC3366",
10742
+ "#CC3399",
10743
+ "#CC33CC",
10744
+ "#CC33FF",
10745
+ "#CC6600",
10746
+ "#CC6633",
10747
+ "#CC9900",
10748
+ "#CC9933",
10749
+ "#CCCC00",
10750
+ "#CCCC33",
10751
+ "#FF0000",
10752
+ "#FF0033",
10753
+ "#FF0066",
10754
+ "#FF0099",
10755
+ "#FF00CC",
10756
+ "#FF00FF",
10757
+ "#FF3300",
10758
+ "#FF3333",
10759
+ "#FF3366",
10760
+ "#FF3399",
10761
+ "#FF33CC",
10762
+ "#FF33FF",
10763
+ "#FF6600",
10764
+ "#FF6633",
10765
+ "#FF9900",
10766
+ "#FF9933",
10767
+ "#FFCC00",
10768
+ "#FFCC33"
10769
+ ];
10770
+ function useColors() {
10771
+ if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) {
10772
+ return true;
10773
+ }
10774
+ if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
10775
+ return false;
10776
+ }
10777
+ let m;
10778
+ return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
10779
+ typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
10780
+ // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
10781
+ 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
10782
+ typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
10783
+ }
10784
+ function formatArgs(args) {
10785
+ args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module.exports.humanize(this.diff);
10786
+ if (!this.useColors) {
10787
+ return;
10788
+ }
10789
+ const c = "color: " + this.color;
10790
+ args.splice(1, 0, c, "color: inherit");
10791
+ let index = 0;
10792
+ let lastC = 0;
10793
+ args[0].replace(/%[a-zA-Z%]/g, (match) => {
10794
+ if (match === "%%") {
10795
+ return;
10796
+ }
10797
+ index++;
10798
+ if (match === "%c") {
10799
+ lastC = index;
10800
+ }
10801
+ });
10802
+ args.splice(lastC, 0, c);
10803
+ }
10804
+ exports.log = console.debug || console.log || (() => {
10805
+ });
10806
+ function save(namespaces) {
10807
+ try {
10808
+ if (namespaces) {
10809
+ exports.storage.setItem("debug", namespaces);
10810
+ } else {
10811
+ exports.storage.removeItem("debug");
10812
+ }
10813
+ } catch (error) {
10814
+ }
10815
+ }
10816
+ function load2() {
10817
+ let r;
10818
+ try {
10819
+ r = exports.storage.getItem("debug") || exports.storage.getItem("DEBUG");
10820
+ } catch (error) {
10821
+ }
10822
+ if (!r && typeof process !== "undefined" && "env" in process) {
10823
+ r = process.env.DEBUG;
10824
+ }
10825
+ return r;
10826
+ }
10827
+ function localstorage() {
10828
+ try {
10829
+ return localStorage;
10830
+ } catch (error) {
10831
+ }
10832
+ }
10833
+ module.exports = require_common()(exports);
10834
+ var { formatters } = module.exports;
10835
+ formatters.j = function(v) {
10836
+ try {
10837
+ return JSON.stringify(v);
10838
+ } catch (error) {
10839
+ return "[UnexpectedJSONParseError]: " + error.message;
10840
+ }
10841
+ };
10842
+ }
10843
+ });
10844
+
10845
+ // node_modules/.pnpm/has-flag@4.0.0/node_modules/has-flag/index.js
10846
+ var require_has_flag = __commonJS({
10847
+ "node_modules/.pnpm/has-flag@4.0.0/node_modules/has-flag/index.js"(exports, module) {
10848
+ "use strict";
10849
+ module.exports = (flag, argv = process.argv) => {
10850
+ const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
10851
+ const position = argv.indexOf(prefix + flag);
10852
+ const terminatorPosition = argv.indexOf("--");
10853
+ return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
10854
+ };
10855
+ }
10856
+ });
10857
+
10858
+ // node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js
10859
+ var require_supports_color = __commonJS({
10860
+ "node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js"(exports, module) {
10861
+ "use strict";
10862
+ var os2 = __require("os");
10863
+ var tty = __require("tty");
10864
+ var hasFlag = require_has_flag();
10865
+ var { env } = process;
10866
+ var forceColor;
10867
+ if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
10868
+ forceColor = 0;
10869
+ } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
10870
+ forceColor = 1;
10871
+ }
10872
+ if ("FORCE_COLOR" in env) {
10873
+ if (env.FORCE_COLOR === "true") {
10874
+ forceColor = 1;
10875
+ } else if (env.FORCE_COLOR === "false") {
10876
+ forceColor = 0;
10877
+ } else {
10878
+ forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
10879
+ }
10880
+ }
10881
+ function translateLevel(level) {
10882
+ if (level === 0) {
10883
+ return false;
10884
+ }
10885
+ return {
10886
+ level,
10887
+ hasBasic: true,
10888
+ has256: level >= 2,
10889
+ has16m: level >= 3
10890
+ };
10891
+ }
10892
+ function supportsColor(haveStream, streamIsTTY) {
10893
+ if (forceColor === 0) {
10894
+ return 0;
10895
+ }
10896
+ if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
10897
+ return 3;
10898
+ }
10899
+ if (hasFlag("color=256")) {
10900
+ return 2;
10901
+ }
10902
+ if (haveStream && !streamIsTTY && forceColor === void 0) {
10903
+ return 0;
10904
+ }
10905
+ const min = forceColor || 0;
10906
+ if (env.TERM === "dumb") {
10907
+ return min;
10908
+ }
10909
+ if (process.platform === "win32") {
10910
+ const osRelease = os2.release().split(".");
10911
+ if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
10912
+ return Number(osRelease[2]) >= 14931 ? 3 : 2;
10913
+ }
10914
+ return 1;
10915
+ }
10916
+ if ("CI" in env) {
10917
+ if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
10918
+ return 1;
10919
+ }
10920
+ return min;
10921
+ }
10922
+ if ("TEAMCITY_VERSION" in env) {
10923
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
10924
+ }
10925
+ if (env.COLORTERM === "truecolor") {
10926
+ return 3;
10927
+ }
10928
+ if ("TERM_PROGRAM" in env) {
10929
+ const version = parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
10930
+ switch (env.TERM_PROGRAM) {
10931
+ case "iTerm.app":
10932
+ return version >= 3 ? 3 : 2;
10933
+ case "Apple_Terminal":
10934
+ return 2;
10935
+ }
10936
+ }
10937
+ if (/-256(color)?$/i.test(env.TERM)) {
10938
+ return 2;
10939
+ }
10940
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
10941
+ return 1;
10942
+ }
10943
+ if ("COLORTERM" in env) {
10944
+ return 1;
10945
+ }
10946
+ return min;
10947
+ }
10948
+ function getSupportLevel(stream) {
10949
+ const level = supportsColor(stream, stream && stream.isTTY);
10950
+ return translateLevel(level);
10951
+ }
10952
+ module.exports = {
10953
+ supportsColor: getSupportLevel,
10954
+ stdout: translateLevel(supportsColor(true, tty.isatty(1))),
10955
+ stderr: translateLevel(supportsColor(true, tty.isatty(2)))
10956
+ };
10957
+ }
10958
+ });
10959
+
10960
+ // node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/node.js
10961
+ var require_node = __commonJS({
10962
+ "node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/node.js"(exports, module) {
10963
+ var tty = __require("tty");
10964
+ var util2 = __require("util");
10965
+ exports.init = init;
10966
+ exports.log = log;
10967
+ exports.formatArgs = formatArgs;
10968
+ exports.save = save;
10969
+ exports.load = load2;
10970
+ exports.useColors = useColors;
10971
+ exports.destroy = util2.deprecate(
10972
+ () => {
10973
+ },
10974
+ "Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."
10975
+ );
10976
+ exports.colors = [6, 2, 3, 4, 5, 1];
10977
+ try {
10978
+ const supportsColor = require_supports_color();
10979
+ if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
10980
+ exports.colors = [
10981
+ 20,
10982
+ 21,
10983
+ 26,
10984
+ 27,
10985
+ 32,
10986
+ 33,
10987
+ 38,
10988
+ 39,
10989
+ 40,
10990
+ 41,
10991
+ 42,
10992
+ 43,
10993
+ 44,
10994
+ 45,
10995
+ 56,
10996
+ 57,
10997
+ 62,
10998
+ 63,
10999
+ 68,
11000
+ 69,
11001
+ 74,
11002
+ 75,
11003
+ 76,
11004
+ 77,
11005
+ 78,
11006
+ 79,
11007
+ 80,
11008
+ 81,
11009
+ 92,
11010
+ 93,
11011
+ 98,
11012
+ 99,
11013
+ 112,
11014
+ 113,
11015
+ 128,
11016
+ 129,
11017
+ 134,
11018
+ 135,
11019
+ 148,
11020
+ 149,
11021
+ 160,
11022
+ 161,
11023
+ 162,
11024
+ 163,
11025
+ 164,
11026
+ 165,
11027
+ 166,
11028
+ 167,
11029
+ 168,
11030
+ 169,
11031
+ 170,
11032
+ 171,
11033
+ 172,
11034
+ 173,
11035
+ 178,
11036
+ 179,
11037
+ 184,
11038
+ 185,
11039
+ 196,
11040
+ 197,
11041
+ 198,
11042
+ 199,
11043
+ 200,
11044
+ 201,
11045
+ 202,
11046
+ 203,
11047
+ 204,
11048
+ 205,
11049
+ 206,
11050
+ 207,
11051
+ 208,
11052
+ 209,
11053
+ 214,
11054
+ 215,
11055
+ 220,
11056
+ 221
11057
+ ];
11058
+ }
11059
+ } catch (error) {
11060
+ }
11061
+ exports.inspectOpts = Object.keys(process.env).filter((key) => {
11062
+ return /^debug_/i.test(key);
11063
+ }).reduce((obj, key) => {
11064
+ const prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, (_, k) => {
11065
+ return k.toUpperCase();
11066
+ });
11067
+ let val = process.env[key];
11068
+ if (/^(yes|on|true|enabled)$/i.test(val)) {
11069
+ val = true;
11070
+ } else if (/^(no|off|false|disabled)$/i.test(val)) {
11071
+ val = false;
11072
+ } else if (val === "null") {
11073
+ val = null;
11074
+ } else {
11075
+ val = Number(val);
11076
+ }
11077
+ obj[prop] = val;
11078
+ return obj;
11079
+ }, {});
11080
+ function useColors() {
11081
+ return "colors" in exports.inspectOpts ? Boolean(exports.inspectOpts.colors) : tty.isatty(process.stderr.fd);
11082
+ }
11083
+ function formatArgs(args) {
11084
+ const { namespace: name, useColors: useColors2 } = this;
11085
+ if (useColors2) {
11086
+ const c = this.color;
11087
+ const colorCode = "\x1B[3" + (c < 8 ? c : "8;5;" + c);
11088
+ const prefix = ` ${colorCode};1m${name} \x1B[0m`;
11089
+ args[0] = prefix + args[0].split("\n").join("\n" + prefix);
11090
+ args.push(colorCode + "m+" + module.exports.humanize(this.diff) + "\x1B[0m");
11091
+ } else {
11092
+ args[0] = getDate() + name + " " + args[0];
11093
+ }
11094
+ }
11095
+ function getDate() {
11096
+ if (exports.inspectOpts.hideDate) {
11097
+ return "";
11098
+ }
11099
+ return (/* @__PURE__ */ new Date()).toISOString() + " ";
11100
+ }
11101
+ function log(...args) {
11102
+ return process.stderr.write(util2.formatWithOptions(exports.inspectOpts, ...args) + "\n");
11103
+ }
11104
+ function save(namespaces) {
11105
+ if (namespaces) {
11106
+ process.env.DEBUG = namespaces;
11107
+ } else {
11108
+ delete process.env.DEBUG;
11109
+ }
11110
+ }
11111
+ function load2() {
11112
+ return process.env.DEBUG;
11113
+ }
11114
+ function init(debug) {
11115
+ debug.inspectOpts = {};
11116
+ const keys = Object.keys(exports.inspectOpts);
11117
+ for (let i = 0; i < keys.length; i++) {
11118
+ debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
11119
+ }
11120
+ }
11121
+ module.exports = require_common()(exports);
11122
+ var { formatters } = module.exports;
11123
+ formatters.o = function(v) {
11124
+ this.inspectOpts.colors = this.useColors;
11125
+ return util2.inspect(v, this.inspectOpts).split("\n").map((str2) => str2.trim()).join(" ");
11126
+ };
11127
+ formatters.O = function(v) {
11128
+ this.inspectOpts.colors = this.useColors;
11129
+ return util2.inspect(v, this.inspectOpts);
11130
+ };
11131
+ }
11132
+ });
11133
+
11134
+ // node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/index.js
11135
+ var require_src = __commonJS({
11136
+ "node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/index.js"(exports, module) {
11137
+ if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) {
11138
+ module.exports = require_browser();
11139
+ } else {
11140
+ module.exports = require_node();
11141
+ }
11142
+ }
11143
+ });
11144
+
10382
11145
  // node_modules/.pnpm/follow-redirects@1.16.0/node_modules/follow-redirects/debug.js
10383
11146
  var require_debug = __commonJS({
10384
11147
  "node_modules/.pnpm/follow-redirects@1.16.0/node_modules/follow-redirects/debug.js"(exports, module) {
@@ -10386,7 +11149,7 @@ var require_debug = __commonJS({
10386
11149
  module.exports = function() {
10387
11150
  if (!debug) {
10388
11151
  try {
10389
- debug = __require("debug")("follow-redirects");
11152
+ debug = require_src()("follow-redirects");
10390
11153
  } catch (error) {
10391
11154
  }
10392
11155
  if (typeof debug !== "function") {
@@ -14687,7 +15450,7 @@ var require_object_inspect = __commonJS({
14687
15450
  } else if (indexOf(seen, obj) >= 0) {
14688
15451
  return "[Circular]";
14689
15452
  }
14690
- function inspect(value, from, noIndent) {
15453
+ function inspect2(value, from, noIndent) {
14691
15454
  if (from) {
14692
15455
  seen = $arrSlice.call(seen);
14693
15456
  seen.push(from);
@@ -14705,7 +15468,7 @@ var require_object_inspect = __commonJS({
14705
15468
  }
14706
15469
  if (typeof obj === "function" && !isRegExp(obj)) {
14707
15470
  var name = nameOf(obj);
14708
- var keys = arrObjKeys(obj, inspect);
15471
+ var keys = arrObjKeys(obj, inspect2);
14709
15472
  return "[Function" + (name ? ": " + name : " (anonymous)") + "]" + (keys.length > 0 ? " { " + $join.call(keys, ", ") + " }" : "");
14710
15473
  }
14711
15474
  if (isSymbol(obj)) {
@@ -14729,16 +15492,16 @@ var require_object_inspect = __commonJS({
14729
15492
  if (obj.length === 0) {
14730
15493
  return "[]";
14731
15494
  }
14732
- var xs = arrObjKeys(obj, inspect);
15495
+ var xs = arrObjKeys(obj, inspect2);
14733
15496
  if (indent && !singleLineValues(xs)) {
14734
15497
  return "[" + indentedJoin(xs, indent) + "]";
14735
15498
  }
14736
15499
  return "[ " + $join.call(xs, ", ") + " ]";
14737
15500
  }
14738
15501
  if (isError(obj)) {
14739
- var parts = arrObjKeys(obj, inspect);
15502
+ var parts = arrObjKeys(obj, inspect2);
14740
15503
  if (!("cause" in Error.prototype) && "cause" in obj && !isEnumerable.call(obj, "cause")) {
14741
- return "{ [" + String(obj) + "] " + $join.call($concat.call("[cause]: " + inspect(obj.cause), parts), ", ") + " }";
15504
+ return "{ [" + String(obj) + "] " + $join.call($concat.call("[cause]: " + inspect2(obj.cause), parts), ", ") + " }";
14742
15505
  }
14743
15506
  if (parts.length === 0) {
14744
15507
  return "[" + String(obj) + "]";
@@ -14756,7 +15519,7 @@ var require_object_inspect = __commonJS({
14756
15519
  var mapParts = [];
14757
15520
  if (mapForEach) {
14758
15521
  mapForEach.call(obj, function(value, key) {
14759
- mapParts.push(inspect(key, obj, true) + " => " + inspect(value, obj));
15522
+ mapParts.push(inspect2(key, obj, true) + " => " + inspect2(value, obj));
14760
15523
  });
14761
15524
  }
14762
15525
  return collectionOf("Map", mapSize.call(obj), mapParts, indent);
@@ -14765,7 +15528,7 @@ var require_object_inspect = __commonJS({
14765
15528
  var setParts = [];
14766
15529
  if (setForEach) {
14767
15530
  setForEach.call(obj, function(value) {
14768
- setParts.push(inspect(value, obj));
15531
+ setParts.push(inspect2(value, obj));
14769
15532
  });
14770
15533
  }
14771
15534
  return collectionOf("Set", setSize.call(obj), setParts, indent);
@@ -14780,16 +15543,16 @@ var require_object_inspect = __commonJS({
14780
15543
  return weakCollectionOf("WeakRef");
14781
15544
  }
14782
15545
  if (isNumber(obj)) {
14783
- return markBoxed(inspect(Number(obj)));
15546
+ return markBoxed(inspect2(Number(obj)));
14784
15547
  }
14785
15548
  if (isBigInt(obj)) {
14786
- return markBoxed(inspect(bigIntValueOf.call(obj)));
15549
+ return markBoxed(inspect2(bigIntValueOf.call(obj)));
14787
15550
  }
14788
15551
  if (isBoolean2(obj)) {
14789
15552
  return markBoxed(booleanValueOf.call(obj));
14790
15553
  }
14791
15554
  if (isString(obj)) {
14792
- return markBoxed(inspect(String(obj)));
15555
+ return markBoxed(inspect2(String(obj)));
14793
15556
  }
14794
15557
  if (typeof window !== "undefined" && obj === window) {
14795
15558
  return "{ [object Window] }";
@@ -14798,7 +15561,7 @@ var require_object_inspect = __commonJS({
14798
15561
  return "{ [object globalThis] }";
14799
15562
  }
14800
15563
  if (!isDate(obj) && !isRegExp(obj)) {
14801
- var ys = arrObjKeys(obj, inspect);
15564
+ var ys = arrObjKeys(obj, inspect2);
14802
15565
  var isPlainObject = gPO ? gPO(obj) === Object.prototype : obj instanceof Object || obj.constructor === Object;
14803
15566
  var protoTag = obj instanceof Object ? "" : "null prototype";
14804
15567
  var stringTag = !isPlainObject && toStringTag && Object(obj) === obj && toStringTag in obj ? $slice.call(toStr(obj), 8, -1) : protoTag ? "Object" : "";
@@ -15052,13 +15815,13 @@ var require_object_inspect = __commonJS({
15052
15815
  var lineJoiner = "\n" + indent.prev + indent.base;
15053
15816
  return lineJoiner + $join.call(xs, "," + lineJoiner) + "\n" + indent.prev;
15054
15817
  }
15055
- function arrObjKeys(obj, inspect) {
15818
+ function arrObjKeys(obj, inspect2) {
15056
15819
  var isArr = isArray(obj);
15057
15820
  var xs = [];
15058
15821
  if (isArr) {
15059
15822
  xs.length = obj.length;
15060
15823
  for (var i = 0; i < obj.length; i++) {
15061
- xs[i] = has(obj, i) ? inspect(obj[i], obj) : "";
15824
+ xs[i] = has(obj, i) ? inspect2(obj[i], obj) : "";
15062
15825
  }
15063
15826
  }
15064
15827
  var syms = typeof gOPS === "function" ? gOPS(obj) : [];
@@ -15079,15 +15842,15 @@ var require_object_inspect = __commonJS({
15079
15842
  if (hasShammedSymbols && symMap["$" + key] instanceof Symbol) {
15080
15843
  continue;
15081
15844
  } else if ($test.call(/[^\w$]/, key)) {
15082
- xs.push(inspect(key, obj) + ": " + inspect(obj[key], obj));
15845
+ xs.push(inspect2(key, obj) + ": " + inspect2(obj[key], obj));
15083
15846
  } else {
15084
- xs.push(key + ": " + inspect(obj[key], obj));
15847
+ xs.push(key + ": " + inspect2(obj[key], obj));
15085
15848
  }
15086
15849
  }
15087
15850
  if (typeof gOPS === "function") {
15088
15851
  for (var j = 0; j < syms.length; j++) {
15089
15852
  if (isEnumerable.call(obj, syms[j])) {
15090
- xs.push("[" + inspect(syms[j]) + "]: " + inspect(obj[syms[j]], obj));
15853
+ xs.push("[" + inspect2(syms[j]) + "]: " + inspect2(obj[syms[j]], obj));
15091
15854
  }
15092
15855
  }
15093
15856
  }
@@ -15100,7 +15863,7 @@ var require_object_inspect = __commonJS({
15100
15863
  var require_side_channel_list = __commonJS({
15101
15864
  "node_modules/.pnpm/side-channel-list@1.0.1/node_modules/side-channel-list/index.js"(exports, module) {
15102
15865
  "use strict";
15103
- var inspect = require_object_inspect();
15866
+ var inspect2 = require_object_inspect();
15104
15867
  var $TypeError = require_type();
15105
15868
  var listGetNode = function(list, key, isDelete) {
15106
15869
  var prev = list;
@@ -15154,7 +15917,7 @@ var require_side_channel_list = __commonJS({
15154
15917
  var channel = {
15155
15918
  assert: function(key) {
15156
15919
  if (!channel.has(key)) {
15157
- throw new $TypeError("Side channel does not contain " + inspect(key));
15920
+ throw new $TypeError("Side channel does not contain " + inspect2(key));
15158
15921
  }
15159
15922
  },
15160
15923
  "delete": function(key) {
@@ -15218,7 +15981,7 @@ var require_side_channel_map = __commonJS({
15218
15981
  "use strict";
15219
15982
  var GetIntrinsic = require_get_intrinsic();
15220
15983
  var callBound = require_call_bound();
15221
- var inspect = require_object_inspect();
15984
+ var inspect2 = require_object_inspect();
15222
15985
  var $TypeError = require_type();
15223
15986
  var $Map = GetIntrinsic("%Map%", true);
15224
15987
  var $mapGet = callBound("Map.prototype.get", true);
@@ -15232,7 +15995,7 @@ var require_side_channel_map = __commonJS({
15232
15995
  var channel = {
15233
15996
  assert: function(key) {
15234
15997
  if (!channel.has(key)) {
15235
- throw new $TypeError("Side channel does not contain " + inspect(key));
15998
+ throw new $TypeError("Side channel does not contain " + inspect2(key));
15236
15999
  }
15237
16000
  },
15238
16001
  "delete": function(key) {
@@ -15274,7 +16037,7 @@ var require_side_channel_weakmap = __commonJS({
15274
16037
  "use strict";
15275
16038
  var GetIntrinsic = require_get_intrinsic();
15276
16039
  var callBound = require_call_bound();
15277
- var inspect = require_object_inspect();
16040
+ var inspect2 = require_object_inspect();
15278
16041
  var getSideChannelMap = require_side_channel_map();
15279
16042
  var $TypeError = require_type();
15280
16043
  var $WeakMap = GetIntrinsic("%WeakMap%", true);
@@ -15290,7 +16053,7 @@ var require_side_channel_weakmap = __commonJS({
15290
16053
  var channel = {
15291
16054
  assert: function(key) {
15292
16055
  if (!channel.has(key)) {
15293
- throw new $TypeError("Side channel does not contain " + inspect(key));
16056
+ throw new $TypeError("Side channel does not contain " + inspect2(key));
15294
16057
  }
15295
16058
  },
15296
16059
  "delete": function(key) {
@@ -15346,7 +16109,7 @@ var require_side_channel = __commonJS({
15346
16109
  "node_modules/.pnpm/side-channel@1.1.0/node_modules/side-channel/index.js"(exports, module) {
15347
16110
  "use strict";
15348
16111
  var $TypeError = require_type();
15349
- var inspect = require_object_inspect();
16112
+ var inspect2 = require_object_inspect();
15350
16113
  var getSideChannelList = require_side_channel_list();
15351
16114
  var getSideChannelMap = require_side_channel_map();
15352
16115
  var getSideChannelWeakMap = require_side_channel_weakmap();
@@ -15356,7 +16119,7 @@ var require_side_channel = __commonJS({
15356
16119
  var channel = {
15357
16120
  assert: function(key) {
15358
16121
  if (!channel.has(key)) {
15359
- throw new $TypeError("Side channel does not contain " + inspect(key));
16122
+ throw new $TypeError("Side channel does not contain " + inspect2(key));
15360
16123
  }
15361
16124
  },
15362
16125
  "delete": function(key) {
@@ -115155,7 +115918,16 @@ var PermissionsConfig = external_exports.object({
115155
115918
  * curl, wget, python3, basic POSIX tools); add things like
115156
115919
  * "Bash(pnpm *)" / "Bash(NEXT_PUBLIC_PORT=* *)" here.
115157
115920
  */
115158
- allowExtra: external_exports.array(external_exports.string()).default([])
115921
+ allowExtra: external_exports.array(external_exports.string()).default([]),
115922
+ /**
115923
+ * Permission posture for the Claude backend (and the bypass flag for Codex).
115924
+ * Unset (undefined) = the bridge default `bypassPermissions`, which aligns
115925
+ * the Claude backend with Codex's existing full-host posture and avoids
115926
+ * acceptEdits gating necessary Bash (e.g. lark-cli) in headless `-p` mode.
115927
+ * Set to `acceptEdits` / `ask` to TIGHTEN: Claude Code then routes Bash
115928
+ * through its allow-list gate (the stricter, future "real allow-list" path).
115929
+ */
115930
+ mode: external_exports.enum(["acceptEdits", "ask", "bypassPermissions"]).optional()
115159
115931
  }).default({ allowExtra: [] });
115160
115932
  var ChatEntry = external_exports.object({
115161
115933
  label: external_exports.string().min(1, "chats[].label is required (human-readable name)"),
@@ -115419,6 +116191,10 @@ var MAX_MESSAGE_ATTEMPTS = 5;
115419
116191
  var OPEN_CHAT_DISCOVERY_LOOKBACK_MS = 9e4;
115420
116192
  var OPEN_CHAT_DISCOVERY_BOOTSTRAP_LOOKBACK_MS = 30 * 60 * 1e3;
115421
116193
  var PROCESSING_REACTION_EMOJI = "Typing";
116194
+ var GAP_FILL_MAX_ATTEMPTS = 3;
116195
+ var GAP_FILL_BACKOFF_BASE_MS = 1e3;
116196
+ var UNRESOLVED_WINDOW_MAX_CHATS = 50;
116197
+ var UNRESOLVED_WINDOW_MAX_AGE_MS = 30 * 60 * 1e3;
115422
116198
  function stripAtMarkup(s) {
115423
116199
  return s.replace(/<at\b[^>]*>.*?<\/at>/gi, "").replace(/<at\b[^>]*\/>/gi, "").trim();
115424
116200
  }
@@ -115619,6 +116395,27 @@ var ChannelClient = class {
115619
116395
  * search space.
115620
116396
  */
115621
116397
  recentlySeenChatIds = /* @__PURE__ */ new Set();
116398
+ /**
116399
+ * PER-CHAT unresolved gapFill windows: chatId → the OLDEST windowStart (ms) for
116400
+ * which that chat's lark-cli history pull still failed after all retries. On a
116401
+ * later gapFill that ACTUALLY pulls this chat, we extend the look-back to cover
116402
+ * its oldest unresolved windowStart and only clear it once the pull truly
116403
+ * reached back that far (its `--start` <= the tracked windowStart). Per-chat (not
116404
+ * a single shared list) so a successful run over chat-set {B} can never falsely
116405
+ * resolve chat A's window (BLOCKER 1), and the look-back-vs-clamp mismatch can
116406
+ * never mark a window resolved before it was reached (BLOCKER 2).
116407
+ *
116408
+ * Bounded: one timestamp per chat (so naturally bounded by #chats), pruned by age
116409
+ * (UNRESOLVED_WINDOW_MAX_AGE_MS — older = unrecoverable from history anyway) and
116410
+ * capped at UNRESOLVED_WINDOW_MAX_CHATS tracked chats.
116411
+ */
116412
+ unresolvedGapWindowByChat = /* @__PURE__ */ new Map();
116413
+ /**
116414
+ * Backoff sleep used by the per-chat history-pull retry. Indirected through a
116415
+ * field purely so tests can observe/await the backoff deterministically; in
116416
+ * production it is the real timer-based {@link sleep}.
116417
+ */
116418
+ gapFillSleep = sleep;
115622
116419
  openChatDiscoveryTimer = null;
115623
116420
  openChatDiscoveryRunning = false;
115624
116421
  openChatDiscoveryBootstrapped = false;
@@ -115640,6 +116437,28 @@ var ChannelClient = class {
115640
116437
  }
115641
116438
  this.opts = opts;
115642
116439
  }
116440
+ /**
116441
+ * TEST SEAM (deletable): override the gap-fill retry backoff sleep so unit
116442
+ * tests can observe the backoff durations and avoid real timers. No-op for
116443
+ * production — the default is the real {@link sleep}. Returns the recorded
116444
+ * backoff arg via the provided callback's own bookkeeping.
116445
+ */
116446
+ setGapFillSleepForTest(fn) {
116447
+ this.gapFillSleep = fn;
116448
+ }
116449
+ /** TEST-ONLY read of the per-chat unresolved-window replay map (chatId → windowStart). */
116450
+ unresolvedGapWindowsForTest() {
116451
+ return new Map(this.unresolvedGapWindowByChat);
116452
+ }
116453
+ /**
116454
+ * TEST-ONLY direct gapFill invocation with an explicit chat-set override —
116455
+ * mirrors exactly how open-chat discovery calls gapFill on a SUBSET of chats.
116456
+ * Used to reproduce the cross-chat-set replay isolation (BLOCKER 1) without
116457
+ * standing up the full discovery timer.
116458
+ */
116459
+ async gapFillForTest(disconnectAt, chatIds) {
116460
+ await this.gapFill(disconnectAt, (s) => console.log(`[channel.client] ${s}`), chatIds);
116461
+ }
115643
116462
  /**
115644
116463
  * Async iterator over inbound events — interface-compatible with LarkClient.
115645
116464
  * Connects the WS on first call. The SDK's policy gate (requireMention +
@@ -115705,7 +116524,25 @@ var ChannelClient = class {
115705
116524
  // ── WS robustness knobs (node-sdk ≥1.64; all OFF by default) ──────────
115706
116525
  // Abort a handshake that hangs on a stuck DNS/proxy/NAT path so the retry
115707
116526
  // loop can try again, instead of waiting indefinitely. Successful TLS
115708
- // handshakes are tens of ms; 15s is a wide safety margin.
116527
+ // handshakes are tens of ms; 15s is a wide safety margin. KEPT ON: it is
116528
+ // the right behaviour (abort + reconnect beats hanging forever).
116529
+ //
116530
+ // CAVEAT — raw '_WebSocket' 'error' on abort: when this timeout fires the
116531
+ // SDK aborts the underlying ws, which emits a RAW 'error' event on the
116532
+ // socket. That socket is owned privately inside node-sdk's WSClient
116533
+ // (no public `on()`, no accessor for the raw ws — verified against
116534
+ // node-sdk 1.67.0 types: WSClient is not an EventEmitter and keeps the
116535
+ // `_WebSocket` in a closure), so we CANNOT attach a precise 'error'
116536
+ // listener here. With no listener, Node re-throws it as an
116537
+ // uncaughtException → it would kill the whole (multi-bot) process.
116538
+ // → That raw error is instead caught by the process-level crash guard
116539
+ // in main.ts (registerCrashGuard: uncaughtException handler that logs
116540
+ // and never exits). The channel-level `channel.on("error", …)` below
116541
+ // is a DIFFERENT, higher-level error and does NOT cover this raw case.
116542
+ // → Residual uncertainty (left for acceptance load-testing): that the
116543
+ // process guard reliably catches this specific raw abort path under
116544
+ // real network flap. If a future node-sdk / @larksuite/channel exposes
116545
+ // the ws or attaches its own listener, prefer that and drop the guard.
115709
116546
  handshakeTimeoutMs: 15e3,
115710
116547
  // Liveness watchdog (SECONDS): if no inbound frame arrives within this
115711
116548
  // window after the last ping, treat the socket as dead and reconnect —
@@ -115822,9 +116659,6 @@ var ChannelClient = class {
115822
116659
  const MAX_GAP_FILL_WINDOW_MS = 5 * 60 * 1e3;
115823
116660
  const BUFFER_MS = 3e4;
115824
116661
  const now = Date.now();
115825
- const windowStart = Math.max(disconnectAt - BUFFER_MS, now - MAX_GAP_FILL_WINDOW_MS);
115826
- const startIso = new Date(windowStart).toISOString();
115827
- const endIso = new Date(now + BUFFER_MS).toISOString();
115828
116662
  const larkCli = this.opts.larkCliPath ?? "lark-cli";
115829
116663
  const profileArgs = this.opts.larkCliProfile ? ["--profile", this.opts.larkCliProfile] : [];
115830
116664
  const botOpenId = this.opts.botOpenId;
@@ -115834,16 +116668,29 @@ var ChannelClient = class {
115834
116668
  ...this.opts.allowedChatIds,
115835
116669
  ...this.recentlySeenChatIds
115836
116670
  ]);
116671
+ this.pruneUnresolvedGapWindows(now);
116672
+ let oldestRelevantUnresolved = Infinity;
116673
+ for (const chatId of gapFillChatIds) {
116674
+ const ws = this.unresolvedGapWindowByChat.get(chatId);
116675
+ if (ws !== void 0 && ws < oldestRelevantUnresolved) oldestRelevantUnresolved = ws;
116676
+ }
116677
+ const hasReplay = oldestRelevantUnresolved !== Infinity;
116678
+ const lookBackFrom = Math.min(disconnectAt, hasReplay ? oldestRelevantUnresolved : disconnectAt);
116679
+ const clampCeilingMs = hasReplay ? UNRESOLVED_WINDOW_MAX_AGE_MS : MAX_GAP_FILL_WINDOW_MS;
116680
+ const windowStart = Math.max(lookBackFrom - BUFFER_MS, now - clampCeilingMs);
116681
+ const startIso = new Date(windowStart).toISOString();
116682
+ const endIso = new Date(now + BUFFER_MS).toISOString();
115837
116683
  if (gapFillChatIds.size === 0) {
115838
116684
  log(
115839
116685
  `gap-fill skipped: no known chats for window=${startIso}..${endIso} (allowedChatIds is empty and no live chat has been seen yet)`
115840
116686
  );
115841
116687
  return;
115842
116688
  }
116689
+ let anyChatFailed = false;
115843
116690
  for (const chatId of gapFillChatIds) {
115844
116691
  if (this.closed) break;
115845
116692
  try {
115846
- const { stdout } = await execFile(larkCli, [
116693
+ const args = [
115847
116694
  "im",
115848
116695
  "+chat-messages-list",
115849
116696
  "--as",
@@ -115862,7 +116709,8 @@ var ChannelClient = class {
115862
116709
  "json",
115863
116710
  "--no-reactions",
115864
116711
  ...profileArgs
115865
- ]);
116712
+ ];
116713
+ const { stdout } = await this.execWithRetry(larkCli, args, chatId, log);
115866
116714
  let messages;
115867
116715
  try {
115868
116716
  messages = parseLarkCliMessages(stdout) ?? [];
@@ -115930,16 +116778,91 @@ var ChannelClient = class {
115930
116778
  this.queue.push(ev);
115931
116779
  totalDispatched++;
115932
116780
  }
116781
+ this.resolveUnresolvedGapWindow(chatId, windowStart);
115933
116782
  } catch (e) {
116783
+ anyChatFailed = true;
116784
+ this.recordUnresolvedGapWindow(chatId, windowStart, log);
115934
116785
  log(
115935
- `gap-fill: lark-cli failed for chat ${chatId}: ` + (e instanceof Error ? e.message : String(e))
116786
+ `gap-fill: lark-cli failed for chat ${chatId} after ${GAP_FILL_MAX_ATTEMPTS} attempt(s): ` + (e instanceof Error ? e.message : String(e))
115936
116787
  );
115937
116788
  }
115938
116789
  }
115939
116790
  log(
115940
- `gap-fill complete: window=${startIso}..${endIso}, fetched=${totalFetched}, dispatched=${totalDispatched}`
116791
+ `gap-fill complete: window=${startIso}..${endIso}, fetched=${totalFetched}, dispatched=${totalDispatched}` + (anyChatFailed ? ` (some chats failed \u2014 per-chat windows queued for replay)` : ``)
115941
116792
  );
115942
116793
  }
116794
+ /**
116795
+ * Run a lark-cli history pull with bounded retries + exponential backoff.
116796
+ * Retries on ANY thrown error (transient TLS timeout being the motivating case),
116797
+ * up to {@link GAP_FILL_MAX_ATTEMPTS}. Backoff is GAP_FILL_BACKOFF_BASE_MS *
116798
+ * 2^(attempt-1) (~1s / 2s). Re-throws the last error if all attempts fail so the
116799
+ * caller can flag the window for replay. Backoff goes through {@link gapFillSleep}
116800
+ * (injectable) so tests can observe it deterministically.
116801
+ */
116802
+ async execWithRetry(larkCli, args, chatId, log) {
116803
+ let lastErr;
116804
+ for (let attempt = 1; attempt <= GAP_FILL_MAX_ATTEMPTS; attempt++) {
116805
+ if (this.closed) throw lastErr ?? new Error("closed");
116806
+ try {
116807
+ return await execFile(larkCli, args);
116808
+ } catch (e) {
116809
+ lastErr = e;
116810
+ if (attempt < GAP_FILL_MAX_ATTEMPTS) {
116811
+ const backoffMs = GAP_FILL_BACKOFF_BASE_MS * 2 ** (attempt - 1);
116812
+ log(
116813
+ `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))
116814
+ );
116815
+ await this.gapFillSleep(backoffMs);
116816
+ }
116817
+ }
116818
+ }
116819
+ throw lastErr;
116820
+ }
116821
+ /** Drop per-chat unresolved windows older than the replay max age (unrecoverable). */
116822
+ pruneUnresolvedGapWindows(now) {
116823
+ const cutoff = now - UNRESOLVED_WINDOW_MAX_AGE_MS;
116824
+ for (const [chatId, windowStart] of this.unresolvedGapWindowByChat) {
116825
+ if (windowStart < cutoff) this.unresolvedGapWindowByChat.delete(chatId);
116826
+ }
116827
+ }
116828
+ /**
116829
+ * Record (or keep the OLDEST) unresolved window for a chat whose pull failed.
116830
+ * Bounded by chat count: if the map is at capacity and this is a new chat, we
116831
+ * evict the chat with the NEWEST window (least at risk of aging out) so the
116832
+ * oldest at-risk windows survive to be replayed first.
116833
+ */
116834
+ recordUnresolvedGapWindow(chatId, windowStart, log) {
116835
+ const existing = this.unresolvedGapWindowByChat.get(chatId);
116836
+ if (existing !== void 0 && existing <= windowStart) return;
116837
+ if (existing === void 0 && this.unresolvedGapWindowByChat.size >= UNRESOLVED_WINDOW_MAX_CHATS) {
116838
+ let newestChat = null;
116839
+ let newestWs = -Infinity;
116840
+ for (const [c, ws] of this.unresolvedGapWindowByChat) {
116841
+ if (ws > newestWs) {
116842
+ newestWs = ws;
116843
+ newestChat = c;
116844
+ }
116845
+ }
116846
+ if (newestChat !== null && newestWs > windowStart) this.unresolvedGapWindowByChat.delete(newestChat);
116847
+ else if (newestChat !== null) return;
116848
+ }
116849
+ this.unresolvedGapWindowByChat.set(chatId, windowStart);
116850
+ log(
116851
+ `gap-fill: queued unresolved window for chat ${chatId} start=${new Date(windowStart).toISOString()} (tracked chats=${this.unresolvedGapWindowByChat.size})`
116852
+ );
116853
+ }
116854
+ /**
116855
+ * Resolve a chat's unresolved window on a SUCCESSFUL pull — but ONLY if this
116856
+ * run's `coveredFrom` (its lark-cli `--start`) actually reached back to at or
116857
+ * before the tracked windowStart. If the clamp kept `coveredFrom` NEWER than the
116858
+ * tracked window, the old window was NOT really covered → keep it queued so a
116859
+ * later, wider replay can reach it (BLOCKER 2).
116860
+ */
116861
+ resolveUnresolvedGapWindow(chatId, coveredFrom) {
116862
+ const tracked = this.unresolvedGapWindowByChat.get(chatId);
116863
+ if (tracked === void 0) return;
116864
+ if (coveredFrom <= tracked) this.unresolvedGapWindowByChat.delete(chatId);
116865
+ }
115943
116866
  startOpenChatDiscovery(log) {
115944
116867
  if (this.opts.allowedChatIds.size > 0) return;
115945
116868
  if (this.openChatDiscoveryTimer) return;
@@ -118857,7 +119780,7 @@ var BridgeHandler = class {
118857
119780
  runtimeWarnings: this.runtimeWarnings()
118858
119781
  });
118859
119782
  const backend = this.deps.botConfig?.backend ?? "claude";
118860
- const permissionMode = this.deps.permissionMode ?? (isAgentWorkspace ? "acceptEdits" : "bypassPermissions");
119783
+ const permissionMode = this.deps.permissionMode ?? "bypassPermissions";
118861
119784
  const timeoutMs = this.deps.subprocessTimeoutMs ?? 60 * 60 * 1e3;
118862
119785
  const handle = createRunner(backend).run({
118863
119786
  prompt,
@@ -123226,6 +124149,30 @@ function runtimeRequirementsForBots(bots) {
123226
124149
  });
123227
124150
  }
123228
124151
 
124152
+ // src/crashGuard.ts
124153
+ import { inspect } from "node:util";
124154
+ function handleUncaughtException(err, origin, log = console) {
124155
+ log.error(
124156
+ `[larkway] uncaughtException (origin=${origin}) \u2014 bridge STAYS UP (crash guard). Likely a transient WS handshake-timeout raw socket error; if it recurs, investigate:`,
124157
+ err
124158
+ );
124159
+ }
124160
+ function handleUnhandledRejection(reason, log = console) {
124161
+ const rendered = reason instanceof Error ? reason : inspect(reason, { depth: 4 });
124162
+ log.error(
124163
+ "[larkway] unhandledRejection \u2014 bridge STAYS UP (crash guard). Full reason:",
124164
+ rendered
124165
+ );
124166
+ }
124167
+ function registerCrashGuard(log = console) {
124168
+ process.on("uncaughtException", (err, origin) => {
124169
+ handleUncaughtException(err, origin, log);
124170
+ });
124171
+ process.on("unhandledRejection", (reason) => {
124172
+ handleUnhandledRejection(reason, log);
124173
+ });
124174
+ }
124175
+
123229
124176
  // src/main.ts
123230
124177
  var STATUS_WRITE_INTERVAL_MS = 3e4;
123231
124178
  var VERSION = resolveLarkwayVersion(import.meta.url);
@@ -123392,6 +124339,9 @@ async function runV2Mode({
123392
124339
  sessionStore,
123393
124340
  conventions,
123394
124341
  permissionsAllowExtra: configJson.permissions.allowExtra,
124342
+ // Unset → handler defaults to bypassPermissions (aligns Claude with Codex
124343
+ // full-host posture); set to acceptEdits/ask to tighten via config.
124344
+ permissionMode: configJson.permissions.mode,
123395
124345
  peers: resolvedPeers,
123396
124346
  botConfig: {
123397
124347
  id: bot.id,
@@ -123489,6 +124439,7 @@ async function runV2Mode({
123489
124439
  process.on("SIGTERM", () => {
123490
124440
  void shutdown("SIGTERM");
123491
124441
  });
124442
+ registerCrashGuard();
123492
124443
  if (dryRun) {
123493
124444
  console.log("[dry-run] V2 mode \u2014 all bots wired OK, exiting.");
123494
124445
  await Promise.all(