larkway 0.3.27 → 0.3.28

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/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 = __require("debug")("follow-redirects");
11513
+ debug = require_src()("follow-redirects");
10751
11514
  } catch (error) {
10752
11515
  }
10753
11516
  if (typeof debug !== "function") {
@@ -111544,7 +112307,7 @@ __export(channelClient_exports, {
111544
112307
  synthesizeCardActionEvent: () => synthesizeCardActionEvent
111545
112308
  });
111546
112309
  import { execFile as execFileCallback } from "node:child_process";
111547
- import { mkdir as mkdir3, readFile as readFile5, writeFile as writeFile4 } from "node:fs/promises";
112310
+ import { mkdir as mkdir3, readFile as readFile5, writeFile as writeFile4, rename as rename3, unlink as unlink4 } from "node:fs/promises";
111548
112311
  import path9 from "node:path";
111549
112312
  import { promisify as promisify4 } from "node:util";
111550
112313
  function stripAtMarkup(s) {
@@ -111571,7 +112334,7 @@ function resolveOpenChatDiscoveryMs(ctorValue) {
111571
112334
  } else {
111572
112335
  const env = process.env["LARKWAY_OPEN_CHAT_DISCOVERY_MS"];
111573
112336
  const parsed = env !== void 0 ? Number(env) : Number.NaN;
111574
- raw = Number.isFinite(parsed) ? parsed : 6e4;
112337
+ raw = Number.isFinite(parsed) ? parsed : DEFAULT_OPEN_CHAT_DISCOVERY_MS;
111575
112338
  }
111576
112339
  return Number.isFinite(raw) && raw > 0 ? raw : 0;
111577
112340
  }
@@ -111683,7 +112446,7 @@ function channelMsgToLarkEvent(msg) {
111683
112446
  create_time: m?.["create_time"] ?? String(msg.createTime ?? Date.now())
111684
112447
  };
111685
112448
  }
111686
- 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;
112449
+ var import_node_sdk, execFile4, LEARNED_CHATS_LIMIT, SEEN_MESSAGES_LIMIT, MAX_MESSAGE_ATTEMPTS, OPEN_CHAT_DISCOVERY_LOOKBACK_BUFFER_MS, OPEN_CHAT_DISCOVERY_BOOTSTRAP_LOOKBACK_MS, PROCESSING_REACTION_EMOJI, DEFAULT_OPEN_CHAT_DISCOVERY_MS, OPEN_CHAT_DISCOVERY_JITTER_CAP_MS, OPEN_CHAT_DISCOVERY_MAX_BACKOFF_CYCLES, GAP_FILL_MAX_ATTEMPTS, GAP_FILL_BACKOFF_BASE_MS, UNRESOLVED_WINDOW_MAX_CHATS, UNRESOLVED_WINDOW_MAX_AGE_MS, DEFAULT_CONNECT_GRACE_MS, ChannelClient;
111687
112450
  var init_channelClient = __esm({
111688
112451
  "src/lark/channelClient.ts"() {
111689
112452
  "use strict";
@@ -111696,9 +112459,12 @@ var init_channelClient = __esm({
111696
112459
  LEARNED_CHATS_LIMIT = 100;
111697
112460
  SEEN_MESSAGES_LIMIT = 1e3;
111698
112461
  MAX_MESSAGE_ATTEMPTS = 5;
111699
- OPEN_CHAT_DISCOVERY_LOOKBACK_MS = 9e4;
112462
+ OPEN_CHAT_DISCOVERY_LOOKBACK_BUFFER_MS = 3e4;
111700
112463
  OPEN_CHAT_DISCOVERY_BOOTSTRAP_LOOKBACK_MS = 30 * 60 * 1e3;
111701
112464
  PROCESSING_REACTION_EMOJI = "Typing";
112465
+ DEFAULT_OPEN_CHAT_DISCOVERY_MS = 3e5;
112466
+ OPEN_CHAT_DISCOVERY_JITTER_CAP_MS = 3e4;
112467
+ OPEN_CHAT_DISCOVERY_MAX_BACKOFF_CYCLES = 8;
111702
112468
  GAP_FILL_MAX_ATTEMPTS = 3;
111703
112469
  GAP_FILL_BACKOFF_BASE_MS = 1e3;
111704
112470
  UNRESOLVED_WINDOW_MAX_CHATS = 50;
@@ -111791,6 +112557,25 @@ var init_channelClient = __esm({
111791
112557
  openChatDiscoveryTimer = null;
111792
112558
  openChatDiscoveryRunning = false;
111793
112559
  openChatDiscoveryBootstrapped = false;
112560
+ /**
112561
+ * Consecutive discovery-cycle failures. Used to SKIP cycles with exponential
112562
+ * backoff (storm: a failing +chat-list/gap-fill shouldn't re-fire every
112563
+ * interval). Reset to 0 on the first clean cycle. {@link openChatDiscoverySkips}
112564
+ * counts how many remaining cycles to skip before the next real attempt.
112565
+ */
112566
+ openChatDiscoveryFailures = 0;
112567
+ openChatDiscoverySkips = 0;
112568
+ /**
112569
+ * Per-instance jitter offset (ms) applied to discovery scheduling so multiple
112570
+ * bots on one host don't run discovery (and its history-pull burst) in
112571
+ * lockstep. Computed once at startup. `Math.random` is fine here — this is
112572
+ * runtime scheduling code, not a determinism-sensitive workflow script.
112573
+ */
112574
+ openChatDiscoveryJitterMs = Math.floor(
112575
+ Math.random() * OPEN_CHAT_DISCOVERY_JITTER_CAP_MS
112576
+ );
112577
+ /** Monotonic suffix so overlapping atomic writes get distinct temp files. */
112578
+ atomicWriteSeq = 0;
111794
112579
  processingReactions = /* @__PURE__ */ new Map();
111795
112580
  /**
111796
112581
  * Shared messageId -> threadId map. Populated by ChannelCardClient.createCard
@@ -111822,10 +112607,31 @@ var init_channelClient = __esm({
111822
112607
  setGapFillSleepForTest(fn) {
111823
112608
  this.gapFillSleep = fn;
111824
112609
  }
112610
+ /**
112611
+ * TEST SEAM (deletable): override the per-instance open-chat discovery startup
112612
+ * jitter so tests can make the FIRST discovery run fire deterministically
112613
+ * (jitter=0) instead of waiting up to {@link OPEN_CHAT_DISCOVERY_JITTER_CAP_MS}.
112614
+ * Must be called before connect()/startOpenChatDiscovery(). No-op in production.
112615
+ */
112616
+ setOpenChatDiscoveryJitterForTest(ms) {
112617
+ this.openChatDiscoveryJitterMs = Math.max(0, ms);
112618
+ }
111825
112619
  /** TEST-ONLY read of the per-chat unresolved-window replay map (chatId → windowStart). */
111826
112620
  unresolvedGapWindowsForTest() {
111827
112621
  return new Map(this.unresolvedGapWindowByChat);
111828
112622
  }
112623
+ /**
112624
+ * TEST-ONLY: run exactly ONE open-chat discovery cycle (same code path the
112625
+ * interval timer invokes), awaited to completion. Lets tests assert the
112626
+ * storm-control behaviour (steady-state no-pull, new-chat pull, failure
112627
+ * backoff skip) deterministically without standing up real timers.
112628
+ */
112629
+ async discoverOpenChatsForTest() {
112630
+ for (let i = 0; i < 200 && this.openChatDiscoveryRunning; i++) {
112631
+ await sleep(5);
112632
+ }
112633
+ await this.discoverOpenChatsAndGapFill((s) => console.log(`[channel.client] ${s}`));
112634
+ }
111829
112635
  /**
111830
112636
  * TEST-ONLY direct gapFill invocation with an explicit chat-set override —
111831
112637
  * mirrors exactly how open-chat discovery calls gapFill on a SUBSET of chats.
@@ -111920,12 +112726,26 @@ var init_channelClient = __esm({
111920
112726
  // real network flap. If a future node-sdk / @larksuite/channel exposes
111921
112727
  // the ws or attaches its own listener, prefer that and drop the guard.
111922
112728
  handshakeTimeoutMs: 15e3,
111923
- // Liveness watchdog (SECONDS): if no inbound frame arrives within this
111924
- // window after the last ping, treat the socket as dead and reconnect —
111925
- // catches silently half-open connections that never emit a close event.
111926
- // This IS the 1.64 keepalive fix; the app-level `keepalive` watchdog
111927
- // option only exists in the split-out @larksuite/channel package, not in
111928
- // node-sdk's bundled createLarkChannel, so we don't pass it here.
112729
+ // HALF-OPEN DETECTION (SECONDS) keep this on. It terminates a socket that
112730
+ // has gone half-open (server stopped responding but never sent a FIN/close),
112731
+ // so the SDK's 'close' handler runs the normal reconnect → our gap-fill
112732
+ // recovers anything missed during the dead window.
112733
+ //
112734
+ // This does NOT mis-fire on healthy idle connections. Verified against
112735
+ // node-sdk 1.67.0 source (WSClient liveness):
112736
+ // - clearLiveness() is called on EVERY inbound frame (incl. the server's
112737
+ // pong) — a live connection cancels the watchdog within ms, so an
112738
+ // idle-but-healthy socket that still answers the ~120s server ping is
112739
+ // never killed.
112740
+ // - armLiveness() only (re)arms for pingTimeout SECONDS after each ping and
112741
+ // is a NO-OP when pingTimeout is unset → unsetting it removes half-open
112742
+ // detection ENTIRELY (no 'close' event → no reconnect → no gap-fill).
112743
+ // A silently-half-open WS on a KNOWN chat would then drop an @ that
112744
+ // neither reconnect-gap-fill nor the (now targeted) steady-state
112745
+ // discovery — which pulls 0 for already-known chats — could recover.
112746
+ //
112747
+ // So this stays as the half-open safety net; the discovery-storm fix is
112748
+ // orthogonal and SAFE precisely because this net still triggers reconnect.
111929
112749
  wsConfig: { pingTimeout: 60 }
111930
112750
  });
111931
112751
  channel.on("message", (msg) => {
@@ -112063,8 +112883,12 @@ var init_channelClient = __esm({
112063
112883
  * profile. Reactions are intentionally skipped because gap-fill only needs
112064
112884
  * message IDs and mentions.
112065
112885
  */
112066
- async gapFill(disconnectAt, log, chatIdsOverride) {
112067
- const MAX_GAP_FILL_WINDOW_MS = 5 * 60 * 1e3;
112886
+ async gapFill(disconnectAt, log, chatIdsOverride, minWindowMs) {
112887
+ const MAX_GAP_FILL_WINDOW_MS = Math.min(
112888
+ Math.max(5 * 60 * 1e3, minWindowMs ?? 0),
112889
+ // ≥5 minutes, or the caller's floor
112890
+ UNRESOLVED_WINDOW_MAX_AGE_MS
112891
+ );
112068
112892
  const BUFFER_MS = 3e4;
112069
112893
  const now = Date.now();
112070
112894
  const larkCli = this.opts.larkCliPath ?? "lark-cli";
@@ -112276,14 +113100,23 @@ var init_channelClient = __esm({
112276
113100
  if (this.openChatDiscoveryTimer) return;
112277
113101
  const intervalMs = resolveOpenChatDiscoveryMs(this.opts.openChatDiscoveryMs);
112278
113102
  if (intervalMs <= 0) return;
112279
- void this.discoverOpenChatsAndGapFill(log);
112280
- this.openChatDiscoveryTimer = setInterval(() => {
113103
+ const firstDelay = Math.min(this.openChatDiscoveryJitterMs, intervalMs);
113104
+ const startTimer = setTimeout(() => {
112281
113105
  void this.discoverOpenChatsAndGapFill(log);
112282
- }, intervalMs);
112283
- this.openChatDiscoveryTimer.unref?.();
113106
+ this.openChatDiscoveryTimer = setInterval(() => {
113107
+ void this.discoverOpenChatsAndGapFill(log);
113108
+ }, intervalMs);
113109
+ this.openChatDiscoveryTimer.unref?.();
113110
+ }, firstDelay);
113111
+ startTimer.unref?.();
113112
+ this.openChatDiscoveryTimer = startTimer;
112284
113113
  }
112285
113114
  async discoverOpenChatsAndGapFill(log) {
112286
113115
  if (this.closed || this.openChatDiscoveryRunning) return;
113116
+ if (this.openChatDiscoverySkips > 0) {
113117
+ this.openChatDiscoverySkips--;
113118
+ return;
113119
+ }
112287
113120
  this.openChatDiscoveryRunning = true;
112288
113121
  try {
112289
113122
  const larkCli = this.opts.larkCliPath ?? "lark-cli";
@@ -112292,6 +113125,7 @@ var init_channelClient = __esm({
112292
113125
  let fetched = 0;
112293
113126
  let newlyLearned = 0;
112294
113127
  const discoveredChatIds = /* @__PURE__ */ new Set();
113128
+ const newChatIds = /* @__PURE__ */ new Set();
112295
113129
  for (let page = 0; page < 10 && !this.closed; page++) {
112296
113130
  const args = [
112297
113131
  "im",
@@ -112315,7 +113149,10 @@ var init_channelClient = __esm({
112315
113149
  discoveredChatIds.add(chatId);
112316
113150
  const before = this.recentlySeenChatIds.size;
112317
113151
  this.noteSeenChat(chatId);
112318
- if (this.recentlySeenChatIds.size > before) newlyLearned++;
113152
+ if (this.recentlySeenChatIds.size > before) {
113153
+ newlyLearned++;
113154
+ newChatIds.add(chatId);
113155
+ }
112319
113156
  }
112320
113157
  const data = parsed && typeof parsed === "object" ? parsed["data"] : void 0;
112321
113158
  const hasMore = Boolean(
@@ -112329,17 +113166,34 @@ var init_channelClient = __esm({
112329
113166
  `open-chat discovery: learned ${newlyLearned} new chat(s) (known=${this.recentlySeenChatIds.size}, fetched=${fetched})`
112330
113167
  );
112331
113168
  }
112332
- if (discoveredChatIds.size > 0) {
112333
- const lookbackMs = this.openChatDiscoveryBootstrapped ? OPEN_CHAT_DISCOVERY_LOOKBACK_MS : OPEN_CHAT_DISCOVERY_BOOTSTRAP_LOOKBACK_MS;
112334
- this.openChatDiscoveryBootstrapped = true;
113169
+ const isBootstrap = !this.openChatDiscoveryBootstrapped;
113170
+ const targetChatIds = isBootstrap ? new Set(discoveredChatIds) : /* @__PURE__ */ new Set([
113171
+ ...newChatIds,
113172
+ ...[...discoveredChatIds].filter((c) => this.unresolvedGapWindowByChat.has(c))
113173
+ ]);
113174
+ this.openChatDiscoveryBootstrapped = true;
113175
+ if (targetChatIds.size > 0) {
113176
+ const intervalMs = resolveOpenChatDiscoveryMs(this.opts.openChatDiscoveryMs);
113177
+ const targetedLookbackMs = intervalMs + OPEN_CHAT_DISCOVERY_LOOKBACK_BUFFER_MS;
113178
+ const lookbackMs = isBootstrap ? OPEN_CHAT_DISCOVERY_BOOTSTRAP_LOOKBACK_MS : targetedLookbackMs;
112335
113179
  await this.gapFill(
112336
113180
  Date.now() - lookbackMs,
112337
113181
  log,
112338
- discoveredChatIds
113182
+ targetChatIds,
113183
+ isBootstrap ? void 0 : targetedLookbackMs
112339
113184
  );
112340
113185
  }
113186
+ this.openChatDiscoveryFailures = 0;
113187
+ this.openChatDiscoverySkips = 0;
112341
113188
  } catch (e) {
112342
- log(`open-chat discovery failed: ${e instanceof Error ? e.message : String(e)}`);
113189
+ this.openChatDiscoveryFailures = Math.min(
113190
+ this.openChatDiscoveryFailures + 1,
113191
+ OPEN_CHAT_DISCOVERY_MAX_BACKOFF_CYCLES
113192
+ );
113193
+ this.openChatDiscoverySkips = 2 ** (this.openChatDiscoveryFailures - 1);
113194
+ log(
113195
+ `open-chat discovery failed (backing off ${this.openChatDiscoverySkips} cycle(s)): ${e instanceof Error ? e.message : String(e)}`
113196
+ );
112343
113197
  } finally {
112344
113198
  this.openChatDiscoveryRunning = false;
112345
113199
  }
@@ -112415,25 +113269,44 @@ var init_channelClient = __esm({
112415
113269
  if (this.seenMessageIds.size === before) return;
112416
113270
  void this.persistSeenMessageIds();
112417
113271
  }
112418
- async persistSeenMessageIds() {
112419
- const file = this.seenMessagesPath();
112420
- if (!file) return;
112421
- const messages = [...this.seenMessageIds].slice(-SEEN_MESSAGES_LIMIT);
113272
+ /**
113273
+ * Atomic JSON write: serialize to a UNIQUE temp file, then `rename` over the
113274
+ * destination. Two concerns motivate this:
113275
+ * 1. Atomicity `rename` is atomic on a POSIX filesystem, so a reader (or a
113276
+ * crash) never observes a half-written file. The persist methods are
113277
+ * fire-and-forget (`void persist…`), so under a multi-bot storm several
113278
+ * writes to the SAME path can overlap; a plain `writeFile` interleaves
113279
+ * their bytes → the "Bad control character in string literal" JSON
113280
+ * corruption we saw. With tmp+rename each write lands whole-or-not-at-all.
113281
+ * 2. Per-write unique tmp name — a fixed `${file}.tmp` would itself be raced
113282
+ * by two concurrent writers. The pid + monotonic counter suffix gives each
113283
+ * in-flight write its own tmp so they can't clobber each other before the
113284
+ * rename. Best-effort cleanup on failure; losing the cache is non-fatal.
113285
+ */
113286
+ async atomicWriteJson(file, value) {
113287
+ const tmp = `${file}.${process.pid}.${this.atomicWriteSeq++}.tmp`;
112422
113288
  try {
112423
113289
  await mkdir3(path9.dirname(file), { recursive: true });
112424
- await writeFile4(file, JSON.stringify(messages, null, 2), "utf8");
113290
+ await writeFile4(tmp, JSON.stringify(value, null, 2), "utf8");
113291
+ await rename3(tmp, file);
112425
113292
  } catch {
113293
+ try {
113294
+ await unlink4(tmp);
113295
+ } catch {
113296
+ }
112426
113297
  }
112427
113298
  }
113299
+ async persistSeenMessageIds() {
113300
+ const file = this.seenMessagesPath();
113301
+ if (!file) return;
113302
+ const messages = [...this.seenMessageIds].slice(-SEEN_MESSAGES_LIMIT);
113303
+ await this.atomicWriteJson(file, messages);
113304
+ }
112428
113305
  async persistRecentlySeenChatIds() {
112429
113306
  const file = this.learnedChatsPath();
112430
113307
  if (!file) return;
112431
113308
  const chats = [...this.recentlySeenChatIds].sort().slice(-LEARNED_CHATS_LIMIT);
112432
- try {
112433
- await mkdir3(path9.dirname(file), { recursive: true });
112434
- await writeFile4(file, JSON.stringify(chats, null, 2), "utf8");
112435
- } catch {
112436
- }
113309
+ await this.atomicWriteJson(file, chats);
112437
113310
  }
112438
113311
  async addProcessingReaction(messageId) {
112439
113312
  if (this.processingReactions.has(messageId)) return;
@@ -116881,7 +117754,7 @@ var require_canvas = __commonJS({
116881
117754
  });
116882
117755
 
116883
117756
  // node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/browser.js
116884
- var require_browser = __commonJS({
117757
+ var require_browser2 = __commonJS({
116885
117758
  "node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/browser.js"(exports) {
116886
117759
  var canPromise = require_can_promise();
116887
117760
  var QRCode2 = require_qrcode();
@@ -117028,7 +117901,7 @@ var require_server = __commonJS({
117028
117901
  }
117029
117902
  }
117030
117903
  exports.create = QRCode2.create;
117031
- exports.toCanvas = require_browser().toCanvas;
117904
+ exports.toCanvas = require_browser2().toCanvas;
117032
117905
  exports.toString = function toString3(text, opts, cb) {
117033
117906
  const params = checkParams(text, opts, cb);
117034
117907
  const type2 = params.opts ? params.opts.type : void 0;
@@ -123961,17 +124834,11 @@ function defaultResponseSurfacePrototypeConfig() {
123961
124834
  enabled: true,
123962
124835
  allowed_chats: [],
123963
124836
  allowed_threads: [],
123964
- lazy_card_creation: true,
123965
124837
  kill_switch: false,
123966
124838
  post_outbound_enabled: true,
123967
124839
  cardkit_streaming_enabled: true,
123968
124840
  allow_agent_mentions: true,
123969
- allowed_mention_open_ids: [],
123970
- max_posts_per_turn: 1,
123971
- max_posts_per_window: 4,
123972
- post_window_ms: 6e4,
123973
- max_post_attempts: 3,
123974
- text_threshold_chars: 1200
124841
+ allowed_mention_open_ids: []
123975
124842
  };
123976
124843
  }
123977
124844
  var DEFAULT_RESPONSE_SURFACE_PROTOTYPE = defaultResponseSurfacePrototypeConfig();
@@ -123979,17 +124846,11 @@ var responseSurfacePrototypeConfigDefaults = () => ({
123979
124846
  enabled: true,
123980
124847
  allowed_chats: [],
123981
124848
  allowed_threads: [],
123982
- lazy_card_creation: true,
123983
124849
  kill_switch: false,
123984
124850
  post_outbound_enabled: true,
123985
124851
  cardkit_streaming_enabled: true,
123986
124852
  allow_agent_mentions: true,
123987
- allowed_mention_open_ids: [],
123988
- max_posts_per_turn: 1,
123989
- max_posts_per_window: 4,
123990
- post_window_ms: 6e4,
123991
- max_post_attempts: 3,
123992
- text_threshold_chars: 1200
124853
+ allowed_mention_open_ids: []
123993
124854
  });
123994
124855
  var ResponseSurfaceModeSchema = external_exports.enum(["card", "post", "hybrid"]);
123995
124856
  var ResponseSurfacePrimarySchema = external_exports.enum(["card", "post"]);
@@ -124046,12 +124907,6 @@ var ResponseSurfacePrototypeConfigSchema = external_exports.object({
124046
124907
  * all threads are allowed by this gate.
124047
124908
  */
124048
124909
  allowed_threads: external_exports.array(external_exports.string().min(1)).default([]),
124049
- /**
124050
- * Historical post-first gate retained for config compatibility. The default
124051
- * runtime no longer uses post-first lazy card creation; CardKit is the main
124052
- * surface and legacy cards remain the visible fallback.
124053
- */
124054
- lazy_card_creation: external_exports.boolean().default(true),
124055
124910
  /**
124056
124911
  * Runtime kill switch for emergency rollback. When true, every response
124057
124912
  * surface post path is treated as disabled even if enabled/allowlists are
@@ -124080,32 +124935,7 @@ var ResponseSurfacePrototypeConfigSchema = external_exports.object({
124080
124935
  * may choose mention targets; non-empty narrows mentions to this exact set.
124081
124936
  * Keep real IDs in private bot config, never in public docs/tests.
124082
124937
  */
124083
- allowed_mention_open_ids: external_exports.array(external_exports.string().min(1)).default([]),
124084
- /**
124085
- * Historical post dispatch cap retained for schema compatibility and
124086
- * isolated dispatcher tests.
124087
- */
124088
- max_posts_per_turn: external_exports.number().int().min(0).max(10).default(1),
124089
- /**
124090
- * Sliding-window hard cap for real post sends within one bot/chat/thread
124091
- * runtime scope. This is enforced in the production handler before a post
124092
- * transport call is attempted; exhausted windows degrade to visible cards.
124093
- */
124094
- max_posts_per_window: external_exports.number().int().min(0).max(100).default(4),
124095
- /**
124096
- * Sliding-window duration for max_posts_per_window.
124097
- */
124098
- post_window_ms: external_exports.number().int().min(1e3).max(864e5).default(6e4),
124099
- /**
124100
- * Max attempts for one logical post. Retry classification is intentionally
124101
- * narrow in PR3: only 5xx errors are retryable.
124102
- */
124103
- max_post_attempts: external_exports.number().int().min(1).max(5).default(3),
124104
- /**
124105
- * Historical threshold for removed lazy card creation experiments. Bounded
124106
- * so older config remains parseable without growing arbitrary business rules.
124107
- */
124108
- text_threshold_chars: external_exports.number().int().min(1).max(2e4).default(1200)
124938
+ allowed_mention_open_ids: external_exports.array(external_exports.string().min(1)).default([])
124109
124939
  }).default(responseSurfacePrototypeConfigDefaults);
124110
124940
 
124111
124941
  // src/config/botLoader.ts
@@ -127949,7 +128779,7 @@ __export(bridgeControl_exports, {
127949
128779
  });
127950
128780
  import { spawn as spawn2, execFile as execFile6 } from "node:child_process";
127951
128781
  import { openSync, constants as fsConstants } from "node:fs";
127952
- import { readFile as readFile9, writeFile as writeFile7, unlink as unlink4, mkdir as mkdir6, readdir as readdir5, access as access7 } from "node:fs/promises";
128782
+ import { readFile as readFile9, writeFile as writeFile7, unlink as unlink5, mkdir as mkdir6, readdir as readdir5, access as access7 } from "node:fs/promises";
127953
128783
  import { promisify as promisify6 } from "node:util";
127954
128784
  import path15 from "node:path";
127955
128785
  import process3 from "node:process";
@@ -128042,7 +128872,7 @@ async function writePid(larkwayDir, pid) {
128042
128872
  async function removePid(larkwayDir) {
128043
128873
  const pidFile = bridgePidPath(larkwayDir);
128044
128874
  try {
128045
- await unlink4(pidFile);
128875
+ await unlink5(pidFile);
128046
128876
  } catch (e) {
128047
128877
  if (e.code !== "ENOENT") throw e;
128048
128878
  }
@@ -128924,7 +129754,7 @@ function isRuntimeEventRecord(value) {
128924
129754
  // src/web/onboardSession.ts
128925
129755
  var QRCode = __toESM(require_lib3(), 1);
128926
129756
  import { randomUUID } from "node:crypto";
128927
- import { mkdir as mkdir7, writeFile as writeFile8, rename as rename3, chmod as chmod2, readFile as readFile11 } from "node:fs/promises";
129757
+ import { mkdir as mkdir7, writeFile as writeFile8, rename as rename4, chmod as chmod2, readFile as readFile11 } from "node:fs/promises";
128928
129758
  import path20 from "node:path";
128929
129759
  async function defaultRegisterApp(opts) {
128930
129760
  const sdk = await Promise.resolve().then(() => __toESM(require_lib2(), 1));
@@ -128960,7 +129790,7 @@ async function atomicWrite3(file, content) {
128960
129790
  await mkdir7(path20.dirname(file), { recursive: true });
128961
129791
  const tmp = `${file}.${process.pid}.${Date.now()}.tmp`;
128962
129792
  await writeFile8(tmp, content, "utf-8");
128963
- await rename3(tmp, file);
129793
+ await rename4(tmp, file);
128964
129794
  }
128965
129795
  async function writeSecretTo(envPath, envName, value) {
128966
129796
  if (!ENV_NAME_RE.test(envName)) {