switchroom 0.18.12 → 0.18.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/dist/agent-scheduler/index.js +8 -0
  2. package/dist/auth-broker/index.js +63 -65
  3. package/dist/cli/ms-365-write-pretool.mjs +31 -8
  4. package/dist/cli/notion-write-pretool.mjs +9 -1
  5. package/dist/cli/skill-validate-pretool.mjs +144 -2847
  6. package/dist/cli/switchroom.js +952 -3126
  7. package/dist/host-control/main.js +216 -2862
  8. package/dist/vault/approvals/kernel-server.js +67 -0
  9. package/dist/vault/broker/server.js +98 -44
  10. package/package.json +1 -1
  11. package/telegram-plugin/dist/bridge/bridge.js +49 -3
  12. package/telegram-plugin/dist/gateway/gateway.js +656 -2326
  13. package/telegram-plugin/dist/server.js +65 -3
  14. package/telegram-plugin/format.ts +19 -0
  15. package/telegram-plugin/gateway/approval-hold.ts +21 -2
  16. package/telegram-plugin/gateway/callback-query-handlers.ts +12 -0
  17. package/telegram-plugin/gateway/gateway.ts +221 -73
  18. package/telegram-plugin/history.ts +51 -0
  19. package/telegram-plugin/inline-keyboard-callbacks.ts +94 -0
  20. package/telegram-plugin/model-unavailable.ts +41 -11
  21. package/telegram-plugin/outbound-field-redact.ts +69 -0
  22. package/telegram-plugin/render/render.ts +32 -14
  23. package/telegram-plugin/scoped-approval.ts +11 -2
  24. package/telegram-plugin/secret-detect/chunker.ts +18 -4
  25. package/telegram-plugin/secret-detect/index.ts +12 -56
  26. package/telegram-plugin/send-gate-degraded.test.ts +131 -0
  27. package/telegram-plugin/send-gate.test.ts +25 -6
  28. package/telegram-plugin/send-gate.ts +82 -8
  29. package/telegram-plugin/session-tail.ts +82 -7
  30. package/telegram-plugin/subagent-watcher.ts +71 -16
  31. package/telegram-plugin/tests/approval-hold-outcome.test.ts +36 -5
  32. package/telegram-plugin/tests/callback-query-handlers.test.ts +65 -0
  33. package/telegram-plugin/tests/gateway-outbound-redact.test.ts +57 -0
  34. package/telegram-plugin/tests/history.test.ts +115 -0
  35. package/telegram-plugin/tests/inbound-message-types.test.ts +5 -1
  36. package/telegram-plugin/tests/inline-keyboard-callbacks.test.ts +164 -0
  37. package/telegram-plugin/tests/operator-events-session-tail.test.ts +74 -0
  38. package/telegram-plugin/tests/outbound-field-redact.test.ts +107 -0
  39. package/telegram-plugin/tests/reaction-gate-routing.test.ts +173 -0
  40. package/telegram-plugin/tests/render/render.test.ts +88 -0
  41. package/telegram-plugin/tests/scoped-approval.test.ts +27 -0
  42. package/telegram-plugin/tests/secret-detect-chunk-overlap.test.ts +65 -0
  43. package/telegram-plugin/tests/secret-detect-oauth-code.test.ts +5 -4
  44. package/telegram-plugin/tests/session-tail-sidecar-reap.test.ts +268 -0
  45. package/telegram-plugin/tests/subagent-watcher-fd-leak.test.ts +275 -0
  46. package/telegram-plugin/tests/worktree-watch-cwds.test.ts +215 -1
  47. package/telegram-plugin/worktree-watch-cwds.ts +194 -5
  48. package/telegram-plugin/secret-detect/secretlint-source.ts +0 -95
  49. package/telegram-plugin/tests/secret-detect-secretlint.test.ts +0 -105
@@ -1855,12 +1855,12 @@ var require_common = __commonJS((exports, module) => {
1855
1855
  if (!debug.enabled) {
1856
1856
  return;
1857
1857
  }
1858
- const self2 = debug;
1858
+ const self = debug;
1859
1859
  const curr = Number(new Date);
1860
1860
  const ms = curr - (prevTime || curr);
1861
- self2.diff = ms;
1862
- self2.prev = prevTime;
1863
- self2.curr = curr;
1861
+ self.diff = ms;
1862
+ self.prev = prevTime;
1863
+ self.curr = curr;
1864
1864
  prevTime = curr;
1865
1865
  args[0] = createDebug.coerce(args[0]);
1866
1866
  if (typeof args[0] !== "string") {
@@ -1875,15 +1875,15 @@ var require_common = __commonJS((exports, module) => {
1875
1875
  const formatter = createDebug.formatters[format];
1876
1876
  if (typeof formatter === "function") {
1877
1877
  const val = args[index];
1878
- match = formatter.call(self2, val);
1878
+ match = formatter.call(self, val);
1879
1879
  args.splice(index, 1);
1880
1880
  index--;
1881
1881
  }
1882
1882
  return match;
1883
1883
  });
1884
- createDebug.formatArgs.call(self2, args);
1885
- const logFn = self2.log || createDebug.log;
1886
- logFn.apply(self2, args);
1884
+ createDebug.formatArgs.call(self, args);
1885
+ const logFn = self.log || createDebug.log;
1886
+ logFn.apply(self, args);
1887
1887
  }
1888
1888
  debug.namespace = namespace;
1889
1889
  debug.useColors = createDebug.useColors();
@@ -6713,6 +6713,9 @@ function escapeMarkdown(text) {
6713
6713
  function codeSpanSafe(s) {
6714
6714
  return s.replace(/`/g, "`\u200b");
6715
6715
  }
6716
+ function escapeLinkHref(href) {
6717
+ return href.replace(/\\/g, "\\\\").replace(/\(/g, "\\(").replace(/\)/g, "\\)");
6718
+ }
6716
6719
  function repairEscapedWhitespace(text) {
6717
6720
  if (!/\\[nrt"\\]/.test(text))
6718
6721
  return text;
@@ -11551,7 +11554,7 @@ function decodeResponse(line) {
11551
11554
  const obj = JSON.parse(line);
11552
11555
  return ResponseSchema.parse(obj);
11553
11556
  }
11554
- var MAX_FRAME_BYTES, AgentNameSchema, GetRequestSchema, PutRequestSchema, ListRequestSchema, MintGrantRequestSchema, ListGrantsRequestSchema, RevokeGrantRequestSchema, StatusRequestSchema, LockRequestSchema, PreflightAccessRequestSchema, OkPreflightAccessResponseSchema, ApprovalRequestRequestSchema, ApprovalLookupRequestSchema, ApprovalConsumeRequestSchema, ApprovalRevokeRequestSchema, ApprovalListRequestSchema, ApprovalDecisionModeSchema, ApprovalRecordRequestSchema, ApprovalConsumeRecordRequestSchema, RequestSchema, VaultEntrySchema, ErrorCode, OkEntryResponseSchema, OkKeysResponseSchema, BrokerStatus, OkStatusResponseSchema, OkLockResponseSchema, OkPutResponseSchema, OkMintGrantResponseSchema, GrantMetaSchema, OkListGrantsResponseSchema, OkRevokeGrantResponseSchema, OkApprovalRequestResponseSchema, ApprovalDecisionMetaSchema, OkApprovalLookupResponseSchema, OkApprovalConsumeResponseSchema, OkApprovalRevokeResponseSchema, OkApprovalListResponseSchema, OkApprovalRecordResponseSchema, OkApprovalConsumeRecordResponseSchema, ErrorResponseSchema, ResponseSchema;
11557
+ var MAX_FRAME_BYTES, AgentNameSchema, GetRequestSchema, PutRequestSchema, ListRequestSchema, MintGrantRequestSchema, ListGrantsRequestSchema, RevokeGrantRequestSchema, StatusRequestSchema, LockRequestSchema, PreflightAccessRequestSchema, OkPreflightAccessResponseSchema, ApprovalRequestRequestSchema, ApprovalLookupRequestSchema, ApprovalLookupByRequestRequestSchema, ApprovalConsumeRequestSchema, ApprovalRevokeRequestSchema, ApprovalListRequestSchema, ApprovalDecisionModeSchema, ApprovalRecordRequestSchema, ApprovalConsumeRecordRequestSchema, RequestSchema, VaultEntrySchema, ErrorCode, OkEntryResponseSchema, OkKeysResponseSchema, BrokerStatus, OkStatusResponseSchema, OkLockResponseSchema, OkPutResponseSchema, OkMintGrantResponseSchema, GrantMetaSchema, OkListGrantsResponseSchema, OkRevokeGrantResponseSchema, OkApprovalRequestResponseSchema, ApprovalDecisionMetaSchema, OkApprovalLookupResponseSchema, OkApprovalConsumeResponseSchema, OkApprovalRevokeResponseSchema, OkApprovalListResponseSchema, OkApprovalRecordResponseSchema, OkApprovalConsumeRecordResponseSchema, ErrorResponseSchema, ResponseSchema;
11555
11558
  var init_protocol = __esm(() => {
11556
11559
  init_zod();
11557
11560
  init_peercred();
@@ -11651,6 +11654,13 @@ var init_protocol = __esm(() => {
11651
11654
  action: exports_external.string().min(1),
11652
11655
  current_approver_set: exports_external.array(exports_external.string())
11653
11656
  });
11657
+ ApprovalLookupByRequestRequestSchema = exports_external.object({
11658
+ v: exports_external.literal(1),
11659
+ op: exports_external.literal("approval_lookup_by_request"),
11660
+ agent_unit: exports_external.string().min(1),
11661
+ request_id: exports_external.string().regex(/^[0-9a-f]{32}$/),
11662
+ current_approver_set: exports_external.array(exports_external.string())
11663
+ });
11654
11664
  ApprovalConsumeRequestSchema = exports_external.object({
11655
11665
  v: exports_external.literal(1),
11656
11666
  op: exports_external.literal("approval_consume"),
@@ -11705,6 +11715,7 @@ var init_protocol = __esm(() => {
11705
11715
  RevokeGrantRequestSchema,
11706
11716
  ApprovalRequestRequestSchema,
11707
11717
  ApprovalLookupRequestSchema,
11718
+ ApprovalLookupByRequestRequestSchema,
11708
11719
  ApprovalConsumeRequestSchema,
11709
11720
  ApprovalRevokeRequestSchema,
11710
11721
  ApprovalListRequestSchema,
@@ -27861,10 +27872,11 @@ function chunk(text4) {
27861
27872
  }
27862
27873
  return out;
27863
27874
  }
27864
- var CHUNK_THRESHOLD, WINDOW_SIZE, OVERLAP = 1024;
27875
+ var CHUNK_THRESHOLD, WINDOW_SIZE, OVERLAP;
27865
27876
  var init_chunker = __esm(() => {
27866
27877
  CHUNK_THRESHOLD = 32 * 1024;
27867
27878
  WINDOW_SIZE = 16 * 1024;
27879
+ OVERLAP = 8 * 1024;
27868
27880
  });
27869
27881
 
27870
27882
  // secret-detect/suppressor.ts
@@ -27954,1935 +27966,6 @@ var init_url_redact = __esm(() => {
27954
27966
  URL_RE2 = /\b(?:https?|wss?|ftp):\/\/[^\s<>"']+/gi;
27955
27967
  });
27956
27968
 
27957
- // ../node_modules/.bun/boundary@2.0.0/node_modules/boundary/lib/index.js
27958
- var require_lib = __commonJS((exports2) => {
27959
- Object.defineProperty(exports2, "__esModule", { value: true });
27960
- exports2.binarySearch = exports2.upperBound = exports2.lowerBound = exports2.compare = undefined;
27961
- function compare(v1, v2) {
27962
- return v1 < v2;
27963
- }
27964
- exports2.compare = compare;
27965
- function upperBound(array, value, comp = compare) {
27966
- let len = array.length;
27967
- let i = 0;
27968
- while (len) {
27969
- let diff = len >>> 1;
27970
- let cursor = i + diff;
27971
- if (comp(value, array[cursor])) {
27972
- len = diff;
27973
- } else {
27974
- i = cursor + 1;
27975
- len -= diff + 1;
27976
- }
27977
- }
27978
- return i;
27979
- }
27980
- exports2.upperBound = upperBound;
27981
- function lowerBound(array, value, comp = compare) {
27982
- let len = array.length;
27983
- let i = 0;
27984
- while (len) {
27985
- let diff = len >>> 1;
27986
- let cursor = i + diff;
27987
- if (comp(array[cursor], value)) {
27988
- i = cursor + 1;
27989
- len -= diff + 1;
27990
- } else {
27991
- len = diff;
27992
- }
27993
- }
27994
- return i;
27995
- }
27996
- exports2.lowerBound = lowerBound;
27997
- function binarySearch(array, value, comp = compare) {
27998
- let cursor = lowerBound(array, value, comp);
27999
- return cursor !== array.length && !comp(value, array[cursor]);
28000
- }
28001
- exports2.binarySearch = binarySearch;
28002
- });
28003
-
28004
- // ../node_modules/.bun/structured-source@4.0.0/node_modules/structured-source/lib/structured-source.js
28005
- var require_structured_source = __commonJS((exports2) => {
28006
- Object.defineProperty(exports2, "__esModule", { value: true });
28007
- exports2.StructuredSource = undefined;
28008
- var boundary_1 = require_lib();
28009
-
28010
- class StructuredSource {
28011
- constructor(source) {
28012
- this.indice = [0];
28013
- let regexp = /[\r\n\u2028\u2029]/g;
28014
- const length = source.length;
28015
- regexp.lastIndex = 0;
28016
- while (true) {
28017
- let result = regexp.exec(source);
28018
- if (!result) {
28019
- break;
28020
- }
28021
- let index2 = result.index;
28022
- if (source.charCodeAt(index2) === 13 && source.charCodeAt(index2 + 1) === 10) {
28023
- index2 += 1;
28024
- }
28025
- let nextIndex = index2 + 1;
28026
- if (length < nextIndex) {
28027
- break;
28028
- }
28029
- this.indice.push(nextIndex);
28030
- regexp.lastIndex = nextIndex;
28031
- }
28032
- }
28033
- get line() {
28034
- return this.indice.length;
28035
- }
28036
- locationToRange(loc) {
28037
- return [this.positionToIndex(loc.start), this.positionToIndex(loc.end)];
28038
- }
28039
- rangeToLocation(range) {
28040
- return {
28041
- start: this.indexToPosition(range[0]),
28042
- end: this.indexToPosition(range[1])
28043
- };
28044
- }
28045
- positionToIndex(pos2) {
28046
- let start = this.indice[pos2.line - 1];
28047
- return start + pos2.column;
28048
- }
28049
- indexToPosition(index2) {
28050
- const startLine = (0, boundary_1.upperBound)(this.indice, index2);
28051
- return {
28052
- line: startLine,
28053
- column: index2 - this.indice[startLine - 1]
28054
- };
28055
- }
28056
- }
28057
- exports2.StructuredSource = StructuredSource;
28058
- });
28059
- // ../node_modules/.bun/@secretlint+core@12.2.0/node_modules/@secretlint/core/module/SecretLintSourceCodeImpl.js
28060
- var import_structured_source;
28061
- var init_SecretLintSourceCodeImpl = __esm(() => {
28062
- import_structured_source = __toESM(require_structured_source(), 1);
28063
- });
28064
-
28065
- // ../node_modules/.bun/@secretlint+core@12.2.0/node_modules/@secretlint/core/module/helper/promise-event-emitter.js
28066
- class EventEmitter {
28067
- #listeners = new Map;
28068
- on(type, listener) {
28069
- const prevSet = this.#listeners.get(type);
28070
- const listenerSet = prevSet ?? new Set;
28071
- listenerSet?.add(listener);
28072
- this.#listeners.set(type, listenerSet);
28073
- }
28074
- emit(type, ...args) {
28075
- const listenerSet = this.#listeners.get(type);
28076
- if (!listenerSet) {
28077
- return;
28078
- }
28079
- for (const listenerSetElement of listenerSet) {
28080
- listenerSetElement(...args);
28081
- }
28082
- }
28083
- off(type, listener) {
28084
- const listenerSet = this.#listeners.get(type);
28085
- if (!listenerSet) {
28086
- return;
28087
- }
28088
- for (const listenerSetElement of listenerSet) {
28089
- if (listenerSetElement === listener) {
28090
- listenerSet.delete(listener);
28091
- }
28092
- }
28093
- }
28094
- removeAllListeners() {
28095
- this.#listeners.clear();
28096
- }
28097
- listenerCount(type) {
28098
- return this.#listeners.get(type)?.size ?? 0;
28099
- }
28100
- listeners(type) {
28101
- return Array.from(this.#listeners.get(type) ?? []);
28102
- }
28103
- }
28104
- // ../node_modules/.bun/@secretlint+core@12.2.0/node_modules/@secretlint/core/module/RuleContext.js
28105
- var init_RuleContext = () => {};
28106
- // ../node_modules/.bun/@secretlint+profiler@12.2.0/node_modules/@secretlint/profiler/module/index.js
28107
- class SecretLintProfiler {
28108
- perf;
28109
- entries = [];
28110
- measures = [];
28111
- executionPromises = [];
28112
- constructor(options) {
28113
- this.perf = options.perf;
28114
- const pattern = /(.*?)::end(\|\|.*)?/;
28115
- const observer = new options.PerformanceObserver((items) => {
28116
- const entries = items.getEntries();
28117
- entries.forEach((entry) => {
28118
- if (entry.entryType === "mark") {
28119
- const match = entry.name.match(pattern);
28120
- const endIdentifier = match ? match[1] : undefined;
28121
- const suffix = match && match[2] ? match[2] : "";
28122
- if (endIdentifier) {
28123
- const startIdentifier = `${endIdentifier}::start`;
28124
- this.entries.find((savedEntry) => {
28125
- return savedEntry.name === startIdentifier;
28126
- });
28127
- if (startIdentifier) {
28128
- this.executionPromises.push(Promise.resolve().then(() => {
28129
- this.perf.measure(endIdentifier + suffix, `${endIdentifier}::start${suffix}`, `${endIdentifier}::end${suffix}`);
28130
- }));
28131
- }
28132
- }
28133
- this.entries.push(entry);
28134
- } else if (entry.entryType === "measure") {
28135
- this.measures.push(entry);
28136
- }
28137
- });
28138
- });
28139
- observer.observe({ entryTypes: ["mark", "measure"] });
28140
- }
28141
- mark(marker) {
28142
- if ("id" in marker) {
28143
- this.perf.mark(`${marker.type}||${marker.id}`);
28144
- } else {
28145
- this.perf.mark(marker.type);
28146
- }
28147
- }
28148
- waifForExecutionPromises = () => {
28149
- return Promise.all(this.executionPromises).finally(() => {
28150
- this.executionPromises.length = 0;
28151
- });
28152
- };
28153
- async getEntries() {
28154
- await this.waifForExecutionPromises();
28155
- return this.entries;
28156
- }
28157
- async getMeasures() {
28158
- await this.waifForExecutionPromises();
28159
- return this.measures;
28160
- }
28161
- }
28162
-
28163
- // ../node_modules/.bun/@secretlint+profiler@12.2.0/node_modules/@secretlint/profiler/module/node.js
28164
- import perf_hooks from "node:perf_hooks";
28165
-
28166
- class NullPerformanceObserver {
28167
- disconnect() {}
28168
- observe(_options) {}
28169
- }
28170
- var secretLintProfiler;
28171
- var init_node = __esm(() => {
28172
- secretLintProfiler = new SecretLintProfiler({
28173
- perf: perf_hooks.performance,
28174
- PerformanceObserver: perf_hooks.PerformanceObserver ? perf_hooks.PerformanceObserver : NullPerformanceObserver
28175
- });
28176
- });
28177
-
28178
- // ../node_modules/.bun/@secretlint+core@12.2.0/node_modules/@secretlint/core/module/RunningEvents.js
28179
- var init_RunningEvents = __esm(() => {
28180
- init_node();
28181
- });
28182
-
28183
- // ../node_modules/.bun/@secretlint+core@12.2.0/node_modules/@secretlint/core/module/RulePresetContext.js
28184
- var init_RulePresetContext = __esm(() => {
28185
- init_RuleContext();
28186
- });
28187
- // ../node_modules/.bun/@secretlint+core@12.2.0/node_modules/@secretlint/core/module/messages/index.js
28188
- var init_messages = () => {};
28189
-
28190
- // ../node_modules/.bun/@secretlint+core@12.2.0/node_modules/@secretlint/core/module/index.js
28191
- var import_debug2, debug2;
28192
- var init_module = __esm(() => {
28193
- init_SecretLintSourceCodeImpl();
28194
- init_RuleContext();
28195
- init_RunningEvents();
28196
- init_node();
28197
- init_RulePresetContext();
28198
- init_messages();
28199
- import_debug2 = __toESM(require_src(), 1);
28200
- debug2 = import_debug2.default("@secretlint/core");
28201
- });
28202
-
28203
- // ../node_modules/.bun/@secretlint+secretlint-rule-preset-recommend@12.2.0/node_modules/@secretlint/secretlint-rule-preset-recommend/module/index.js
28204
- function requireLodash_uniq() {
28205
- if (hasRequiredLodash_uniq)
28206
- return lodash_uniq;
28207
- hasRequiredLodash_uniq = 1;
28208
- var LARGE_ARRAY_SIZE = 200;
28209
- var HASH_UNDEFINED = "__lodash_hash_undefined__";
28210
- var INFINITY = 1 / 0;
28211
- var funcTag = "[object Function]", genTag = "[object GeneratorFunction]";
28212
- var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
28213
- var reIsHostCtor = /^\[object .+?Constructor\]$/;
28214
- var freeGlobal = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
28215
- var freeSelf = typeof self == "object" && self && self.Object === Object && self;
28216
- var root = freeGlobal || freeSelf || Function("return this")();
28217
- function arrayIncludes(array, value) {
28218
- var length = array ? array.length : 0;
28219
- return !!length && baseIndexOf(array, value, 0) > -1;
28220
- }
28221
- function baseFindIndex(array, predicate, fromIndex, fromRight) {
28222
- var length = array.length, index2 = fromIndex + -1;
28223
- while (++index2 < length) {
28224
- if (predicate(array[index2], index2, array)) {
28225
- return index2;
28226
- }
28227
- }
28228
- return -1;
28229
- }
28230
- function baseIndexOf(array, value, fromIndex) {
28231
- if (value !== value) {
28232
- return baseFindIndex(array, baseIsNaN, fromIndex);
28233
- }
28234
- var index2 = fromIndex - 1, length = array.length;
28235
- while (++index2 < length) {
28236
- if (array[index2] === value) {
28237
- return index2;
28238
- }
28239
- }
28240
- return -1;
28241
- }
28242
- function baseIsNaN(value) {
28243
- return value !== value;
28244
- }
28245
- function cacheHas(cache, key) {
28246
- return cache.has(key);
28247
- }
28248
- function getValue(object, key) {
28249
- return object == null ? undefined : object[key];
28250
- }
28251
- function isHostObject(value) {
28252
- var result = false;
28253
- if (value != null && typeof value.toString != "function") {
28254
- try {
28255
- result = !!(value + "");
28256
- } catch (e) {}
28257
- }
28258
- return result;
28259
- }
28260
- function setToArray(set) {
28261
- var index2 = -1, result = Array(set.size);
28262
- set.forEach(function(value) {
28263
- result[++index2] = value;
28264
- });
28265
- return result;
28266
- }
28267
- var arrayProto = Array.prototype, funcProto = Function.prototype, objectProto = Object.prototype;
28268
- var coreJsData = root["__core-js_shared__"];
28269
- var maskSrcKey = function() {
28270
- var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || "");
28271
- return uid ? "Symbol(src)_1." + uid : "";
28272
- }();
28273
- var funcToString = funcProto.toString;
28274
- var hasOwnProperty2 = objectProto.hasOwnProperty;
28275
- var objectToString = objectProto.toString;
28276
- var reIsNative = RegExp("^" + funcToString.call(hasOwnProperty2).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$");
28277
- var splice2 = arrayProto.splice;
28278
- var Map2 = getNative(root, "Map"), Set2 = getNative(root, "Set"), nativeCreate = getNative(Object, "create");
28279
- function Hash(entries) {
28280
- var index2 = -1, length = entries ? entries.length : 0;
28281
- this.clear();
28282
- while (++index2 < length) {
28283
- var entry = entries[index2];
28284
- this.set(entry[0], entry[1]);
28285
- }
28286
- }
28287
- function hashClear() {
28288
- this.__data__ = nativeCreate ? nativeCreate(null) : {};
28289
- }
28290
- function hashDelete(key) {
28291
- return this.has(key) && delete this.__data__[key];
28292
- }
28293
- function hashGet(key) {
28294
- var data = this.__data__;
28295
- if (nativeCreate) {
28296
- var result = data[key];
28297
- return result === HASH_UNDEFINED ? undefined : result;
28298
- }
28299
- return hasOwnProperty2.call(data, key) ? data[key] : undefined;
28300
- }
28301
- function hashHas(key) {
28302
- var data = this.__data__;
28303
- return nativeCreate ? data[key] !== undefined : hasOwnProperty2.call(data, key);
28304
- }
28305
- function hashSet(key, value) {
28306
- var data = this.__data__;
28307
- data[key] = nativeCreate && value === undefined ? HASH_UNDEFINED : value;
28308
- return this;
28309
- }
28310
- Hash.prototype.clear = hashClear;
28311
- Hash.prototype["delete"] = hashDelete;
28312
- Hash.prototype.get = hashGet;
28313
- Hash.prototype.has = hashHas;
28314
- Hash.prototype.set = hashSet;
28315
- function ListCache(entries) {
28316
- var index2 = -1, length = entries ? entries.length : 0;
28317
- this.clear();
28318
- while (++index2 < length) {
28319
- var entry = entries[index2];
28320
- this.set(entry[0], entry[1]);
28321
- }
28322
- }
28323
- function listCacheClear() {
28324
- this.__data__ = [];
28325
- }
28326
- function listCacheDelete(key) {
28327
- var data = this.__data__, index2 = assocIndexOf(data, key);
28328
- if (index2 < 0) {
28329
- return false;
28330
- }
28331
- var lastIndex = data.length - 1;
28332
- if (index2 == lastIndex) {
28333
- data.pop();
28334
- } else {
28335
- splice2.call(data, index2, 1);
28336
- }
28337
- return true;
28338
- }
28339
- function listCacheGet(key) {
28340
- var data = this.__data__, index2 = assocIndexOf(data, key);
28341
- return index2 < 0 ? undefined : data[index2][1];
28342
- }
28343
- function listCacheHas(key) {
28344
- return assocIndexOf(this.__data__, key) > -1;
28345
- }
28346
- function listCacheSet(key, value) {
28347
- var data = this.__data__, index2 = assocIndexOf(data, key);
28348
- if (index2 < 0) {
28349
- data.push([key, value]);
28350
- } else {
28351
- data[index2][1] = value;
28352
- }
28353
- return this;
28354
- }
28355
- ListCache.prototype.clear = listCacheClear;
28356
- ListCache.prototype["delete"] = listCacheDelete;
28357
- ListCache.prototype.get = listCacheGet;
28358
- ListCache.prototype.has = listCacheHas;
28359
- ListCache.prototype.set = listCacheSet;
28360
- function MapCache(entries) {
28361
- var index2 = -1, length = entries ? entries.length : 0;
28362
- this.clear();
28363
- while (++index2 < length) {
28364
- var entry = entries[index2];
28365
- this.set(entry[0], entry[1]);
28366
- }
28367
- }
28368
- function mapCacheClear() {
28369
- this.__data__ = {
28370
- hash: new Hash,
28371
- map: new (Map2 || ListCache),
28372
- string: new Hash
28373
- };
28374
- }
28375
- function mapCacheDelete(key) {
28376
- return getMapData(this, key)["delete"](key);
28377
- }
28378
- function mapCacheGet(key) {
28379
- return getMapData(this, key).get(key);
28380
- }
28381
- function mapCacheHas(key) {
28382
- return getMapData(this, key).has(key);
28383
- }
28384
- function mapCacheSet(key, value) {
28385
- getMapData(this, key).set(key, value);
28386
- return this;
28387
- }
28388
- MapCache.prototype.clear = mapCacheClear;
28389
- MapCache.prototype["delete"] = mapCacheDelete;
28390
- MapCache.prototype.get = mapCacheGet;
28391
- MapCache.prototype.has = mapCacheHas;
28392
- MapCache.prototype.set = mapCacheSet;
28393
- function SetCache(values2) {
28394
- var index2 = -1, length = values2 ? values2.length : 0;
28395
- this.__data__ = new MapCache;
28396
- while (++index2 < length) {
28397
- this.add(values2[index2]);
28398
- }
28399
- }
28400
- function setCacheAdd(value) {
28401
- this.__data__.set(value, HASH_UNDEFINED);
28402
- return this;
28403
- }
28404
- function setCacheHas(value) {
28405
- return this.__data__.has(value);
28406
- }
28407
- SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
28408
- SetCache.prototype.has = setCacheHas;
28409
- function assocIndexOf(array, key) {
28410
- var length = array.length;
28411
- while (length--) {
28412
- if (eq(array[length][0], key)) {
28413
- return length;
28414
- }
28415
- }
28416
- return -1;
28417
- }
28418
- function baseIsNative(value) {
28419
- if (!isObject2(value) || isMasked(value)) {
28420
- return false;
28421
- }
28422
- var pattern = isFunction2(value) || isHostObject(value) ? reIsNative : reIsHostCtor;
28423
- return pattern.test(toSource(value));
28424
- }
28425
- function baseUniq(array, iteratee, comparator) {
28426
- var index2 = -1, includes2 = arrayIncludes, length = array.length, isCommon = true, result = [], seen = result;
28427
- if (length >= LARGE_ARRAY_SIZE) {
28428
- var set = createSet(array);
28429
- if (set) {
28430
- return setToArray(set);
28431
- }
28432
- isCommon = false;
28433
- includes2 = cacheHas;
28434
- seen = new SetCache;
28435
- } else {
28436
- seen = result;
28437
- }
28438
- outer:
28439
- while (++index2 < length) {
28440
- var value = array[index2], computed = value;
28441
- value = value !== 0 ? value : 0;
28442
- if (isCommon && computed === computed) {
28443
- var seenIndex = seen.length;
28444
- while (seenIndex--) {
28445
- if (seen[seenIndex] === computed) {
28446
- continue outer;
28447
- }
28448
- }
28449
- result.push(value);
28450
- } else if (!includes2(seen, computed, comparator)) {
28451
- if (seen !== result) {
28452
- seen.push(computed);
28453
- }
28454
- result.push(value);
28455
- }
28456
- }
28457
- return result;
28458
- }
28459
- var createSet = !(Set2 && 1 / setToArray(new Set2([, -0]))[1] == INFINITY) ? noop : function(values2) {
28460
- return new Set2(values2);
28461
- };
28462
- function getMapData(map, key) {
28463
- var data = map.__data__;
28464
- return isKeyable(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
28465
- }
28466
- function getNative(object, key) {
28467
- var value = getValue(object, key);
28468
- return baseIsNative(value) ? value : undefined;
28469
- }
28470
- function isKeyable(value) {
28471
- var type = typeof value;
28472
- return type == "string" || type == "number" || type == "symbol" || type == "boolean" ? value !== "__proto__" : value === null;
28473
- }
28474
- function isMasked(func) {
28475
- return !!maskSrcKey && maskSrcKey in func;
28476
- }
28477
- function toSource(func) {
28478
- if (func != null) {
28479
- try {
28480
- return funcToString.call(func);
28481
- } catch (e) {}
28482
- try {
28483
- return func + "";
28484
- } catch (e) {}
28485
- }
28486
- return "";
28487
- }
28488
- function uniq(array) {
28489
- return array && array.length ? baseUniq(array) : [];
28490
- }
28491
- function eq(value, other) {
28492
- return value === other || value !== value && other !== other;
28493
- }
28494
- function isFunction2(value) {
28495
- var tag = isObject2(value) ? objectToString.call(value) : "";
28496
- return tag == funcTag || tag == genTag;
28497
- }
28498
- function isObject2(value) {
28499
- var type = typeof value;
28500
- return !!value && (type == "object" || type == "function");
28501
- }
28502
- function noop() {}
28503
- lodash_uniq = uniq;
28504
- return lodash_uniq;
28505
- }
28506
- function requireLodash_uniqwith() {
28507
- if (hasRequiredLodash_uniqwith)
28508
- return lodash_uniqwith;
28509
- hasRequiredLodash_uniqwith = 1;
28510
- var LARGE_ARRAY_SIZE = 200;
28511
- var HASH_UNDEFINED = "__lodash_hash_undefined__";
28512
- var INFINITY = 1 / 0;
28513
- var funcTag = "[object Function]", genTag = "[object GeneratorFunction]";
28514
- var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
28515
- var reIsHostCtor = /^\[object .+?Constructor\]$/;
28516
- var freeGlobal = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
28517
- var freeSelf = typeof self == "object" && self && self.Object === Object && self;
28518
- var root = freeGlobal || freeSelf || Function("return this")();
28519
- function arrayIncludes(array, value) {
28520
- var length = array ? array.length : 0;
28521
- return !!length && baseIndexOf(array, value, 0) > -1;
28522
- }
28523
- function arrayIncludesWith(array, value, comparator) {
28524
- var index2 = -1, length = array ? array.length : 0;
28525
- while (++index2 < length) {
28526
- if (comparator(value, array[index2])) {
28527
- return true;
28528
- }
28529
- }
28530
- return false;
28531
- }
28532
- function baseFindIndex(array, predicate, fromIndex, fromRight) {
28533
- var length = array.length, index2 = fromIndex + -1;
28534
- while (++index2 < length) {
28535
- if (predicate(array[index2], index2, array)) {
28536
- return index2;
28537
- }
28538
- }
28539
- return -1;
28540
- }
28541
- function baseIndexOf(array, value, fromIndex) {
28542
- if (value !== value) {
28543
- return baseFindIndex(array, baseIsNaN, fromIndex);
28544
- }
28545
- var index2 = fromIndex - 1, length = array.length;
28546
- while (++index2 < length) {
28547
- if (array[index2] === value) {
28548
- return index2;
28549
- }
28550
- }
28551
- return -1;
28552
- }
28553
- function baseIsNaN(value) {
28554
- return value !== value;
28555
- }
28556
- function cacheHas(cache, key) {
28557
- return cache.has(key);
28558
- }
28559
- function getValue(object, key) {
28560
- return object == null ? undefined : object[key];
28561
- }
28562
- function isHostObject(value) {
28563
- var result = false;
28564
- if (value != null && typeof value.toString != "function") {
28565
- try {
28566
- result = !!(value + "");
28567
- } catch (e) {}
28568
- }
28569
- return result;
28570
- }
28571
- function setToArray(set) {
28572
- var index2 = -1, result = Array(set.size);
28573
- set.forEach(function(value) {
28574
- result[++index2] = value;
28575
- });
28576
- return result;
28577
- }
28578
- var arrayProto = Array.prototype, funcProto = Function.prototype, objectProto = Object.prototype;
28579
- var coreJsData = root["__core-js_shared__"];
28580
- var maskSrcKey = function() {
28581
- var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || "");
28582
- return uid ? "Symbol(src)_1." + uid : "";
28583
- }();
28584
- var funcToString = funcProto.toString;
28585
- var hasOwnProperty2 = objectProto.hasOwnProperty;
28586
- var objectToString = objectProto.toString;
28587
- var reIsNative = RegExp("^" + funcToString.call(hasOwnProperty2).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$");
28588
- var splice2 = arrayProto.splice;
28589
- var Map2 = getNative(root, "Map"), Set2 = getNative(root, "Set"), nativeCreate = getNative(Object, "create");
28590
- function Hash(entries) {
28591
- var index2 = -1, length = entries ? entries.length : 0;
28592
- this.clear();
28593
- while (++index2 < length) {
28594
- var entry = entries[index2];
28595
- this.set(entry[0], entry[1]);
28596
- }
28597
- }
28598
- function hashClear() {
28599
- this.__data__ = nativeCreate ? nativeCreate(null) : {};
28600
- }
28601
- function hashDelete(key) {
28602
- return this.has(key) && delete this.__data__[key];
28603
- }
28604
- function hashGet(key) {
28605
- var data = this.__data__;
28606
- if (nativeCreate) {
28607
- var result = data[key];
28608
- return result === HASH_UNDEFINED ? undefined : result;
28609
- }
28610
- return hasOwnProperty2.call(data, key) ? data[key] : undefined;
28611
- }
28612
- function hashHas(key) {
28613
- var data = this.__data__;
28614
- return nativeCreate ? data[key] !== undefined : hasOwnProperty2.call(data, key);
28615
- }
28616
- function hashSet(key, value) {
28617
- var data = this.__data__;
28618
- data[key] = nativeCreate && value === undefined ? HASH_UNDEFINED : value;
28619
- return this;
28620
- }
28621
- Hash.prototype.clear = hashClear;
28622
- Hash.prototype["delete"] = hashDelete;
28623
- Hash.prototype.get = hashGet;
28624
- Hash.prototype.has = hashHas;
28625
- Hash.prototype.set = hashSet;
28626
- function ListCache(entries) {
28627
- var index2 = -1, length = entries ? entries.length : 0;
28628
- this.clear();
28629
- while (++index2 < length) {
28630
- var entry = entries[index2];
28631
- this.set(entry[0], entry[1]);
28632
- }
28633
- }
28634
- function listCacheClear() {
28635
- this.__data__ = [];
28636
- }
28637
- function listCacheDelete(key) {
28638
- var data = this.__data__, index2 = assocIndexOf(data, key);
28639
- if (index2 < 0) {
28640
- return false;
28641
- }
28642
- var lastIndex = data.length - 1;
28643
- if (index2 == lastIndex) {
28644
- data.pop();
28645
- } else {
28646
- splice2.call(data, index2, 1);
28647
- }
28648
- return true;
28649
- }
28650
- function listCacheGet(key) {
28651
- var data = this.__data__, index2 = assocIndexOf(data, key);
28652
- return index2 < 0 ? undefined : data[index2][1];
28653
- }
28654
- function listCacheHas(key) {
28655
- return assocIndexOf(this.__data__, key) > -1;
28656
- }
28657
- function listCacheSet(key, value) {
28658
- var data = this.__data__, index2 = assocIndexOf(data, key);
28659
- if (index2 < 0) {
28660
- data.push([key, value]);
28661
- } else {
28662
- data[index2][1] = value;
28663
- }
28664
- return this;
28665
- }
28666
- ListCache.prototype.clear = listCacheClear;
28667
- ListCache.prototype["delete"] = listCacheDelete;
28668
- ListCache.prototype.get = listCacheGet;
28669
- ListCache.prototype.has = listCacheHas;
28670
- ListCache.prototype.set = listCacheSet;
28671
- function MapCache(entries) {
28672
- var index2 = -1, length = entries ? entries.length : 0;
28673
- this.clear();
28674
- while (++index2 < length) {
28675
- var entry = entries[index2];
28676
- this.set(entry[0], entry[1]);
28677
- }
28678
- }
28679
- function mapCacheClear() {
28680
- this.__data__ = {
28681
- hash: new Hash,
28682
- map: new (Map2 || ListCache),
28683
- string: new Hash
28684
- };
28685
- }
28686
- function mapCacheDelete(key) {
28687
- return getMapData(this, key)["delete"](key);
28688
- }
28689
- function mapCacheGet(key) {
28690
- return getMapData(this, key).get(key);
28691
- }
28692
- function mapCacheHas(key) {
28693
- return getMapData(this, key).has(key);
28694
- }
28695
- function mapCacheSet(key, value) {
28696
- getMapData(this, key).set(key, value);
28697
- return this;
28698
- }
28699
- MapCache.prototype.clear = mapCacheClear;
28700
- MapCache.prototype["delete"] = mapCacheDelete;
28701
- MapCache.prototype.get = mapCacheGet;
28702
- MapCache.prototype.has = mapCacheHas;
28703
- MapCache.prototype.set = mapCacheSet;
28704
- function SetCache(values2) {
28705
- var index2 = -1, length = values2 ? values2.length : 0;
28706
- this.__data__ = new MapCache;
28707
- while (++index2 < length) {
28708
- this.add(values2[index2]);
28709
- }
28710
- }
28711
- function setCacheAdd(value) {
28712
- this.__data__.set(value, HASH_UNDEFINED);
28713
- return this;
28714
- }
28715
- function setCacheHas(value) {
28716
- return this.__data__.has(value);
28717
- }
28718
- SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
28719
- SetCache.prototype.has = setCacheHas;
28720
- function assocIndexOf(array, key) {
28721
- var length = array.length;
28722
- while (length--) {
28723
- if (eq(array[length][0], key)) {
28724
- return length;
28725
- }
28726
- }
28727
- return -1;
28728
- }
28729
- function baseIsNative(value) {
28730
- if (!isObject2(value) || isMasked(value)) {
28731
- return false;
28732
- }
28733
- var pattern = isFunction2(value) || isHostObject(value) ? reIsNative : reIsHostCtor;
28734
- return pattern.test(toSource(value));
28735
- }
28736
- function baseUniq(array, iteratee, comparator) {
28737
- var index2 = -1, includes2 = arrayIncludes, length = array.length, isCommon = true, result = [], seen = result;
28738
- if (comparator) {
28739
- isCommon = false;
28740
- includes2 = arrayIncludesWith;
28741
- } else if (length >= LARGE_ARRAY_SIZE) {
28742
- var set = createSet(array);
28743
- if (set) {
28744
- return setToArray(set);
28745
- }
28746
- isCommon = false;
28747
- includes2 = cacheHas;
28748
- seen = new SetCache;
28749
- } else {
28750
- seen = result;
28751
- }
28752
- outer:
28753
- while (++index2 < length) {
28754
- var value = array[index2], computed = value;
28755
- value = comparator || value !== 0 ? value : 0;
28756
- if (isCommon && computed === computed) {
28757
- var seenIndex = seen.length;
28758
- while (seenIndex--) {
28759
- if (seen[seenIndex] === computed) {
28760
- continue outer;
28761
- }
28762
- }
28763
- result.push(value);
28764
- } else if (!includes2(seen, computed, comparator)) {
28765
- if (seen !== result) {
28766
- seen.push(computed);
28767
- }
28768
- result.push(value);
28769
- }
28770
- }
28771
- return result;
28772
- }
28773
- var createSet = !(Set2 && 1 / setToArray(new Set2([, -0]))[1] == INFINITY) ? noop : function(values2) {
28774
- return new Set2(values2);
28775
- };
28776
- function getMapData(map, key) {
28777
- var data = map.__data__;
28778
- return isKeyable(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
28779
- }
28780
- function getNative(object, key) {
28781
- var value = getValue(object, key);
28782
- return baseIsNative(value) ? value : undefined;
28783
- }
28784
- function isKeyable(value) {
28785
- var type = typeof value;
28786
- return type == "string" || type == "number" || type == "symbol" || type == "boolean" ? value !== "__proto__" : value === null;
28787
- }
28788
- function isMasked(func) {
28789
- return !!maskSrcKey && maskSrcKey in func;
28790
- }
28791
- function toSource(func) {
28792
- if (func != null) {
28793
- try {
28794
- return funcToString.call(func);
28795
- } catch (e) {}
28796
- try {
28797
- return func + "";
28798
- } catch (e) {}
28799
- }
28800
- return "";
28801
- }
28802
- function uniqWith(array, comparator) {
28803
- return array && array.length ? baseUniq(array, undefined, comparator) : [];
28804
- }
28805
- function eq(value, other) {
28806
- return value === other || value !== value && other !== other;
28807
- }
28808
- function isFunction2(value) {
28809
- var tag = isObject2(value) ? objectToString.call(value) : "";
28810
- return tag == funcTag || tag == genTag;
28811
- }
28812
- function isObject2(value) {
28813
- var type = typeof value;
28814
- return !!value && (type == "object" || type == "function");
28815
- }
28816
- function noop() {}
28817
- lodash_uniqwith = uniqWith;
28818
- return lodash_uniqwith;
28819
- }
28820
- function requireLodash_sortby() {
28821
- if (hasRequiredLodash_sortby)
28822
- return lodash_sortby.exports;
28823
- hasRequiredLodash_sortby = 1;
28824
- (function(module, exports$1) {
28825
- var LARGE_ARRAY_SIZE = 200;
28826
- var FUNC_ERROR_TEXT = "Expected a function";
28827
- var HASH_UNDEFINED = "__lodash_hash_undefined__";
28828
- var UNORDERED_COMPARE_FLAG = 1, PARTIAL_COMPARE_FLAG = 2;
28829
- var MAX_SAFE_INTEGER = 9007199254740991;
28830
- var argsTag = "[object Arguments]", arrayTag = "[object Array]", boolTag = "[object Boolean]", dateTag = "[object Date]", errorTag = "[object Error]", funcTag = "[object Function]", genTag = "[object GeneratorFunction]", mapTag = "[object Map]", numberTag = "[object Number]", objectTag = "[object Object]", promiseTag = "[object Promise]", regexpTag = "[object RegExp]", setTag = "[object Set]", stringTag = "[object String]", symbolTag = "[object Symbol]", weakMapTag = "[object WeakMap]";
28831
- var arrayBufferTag = "[object ArrayBuffer]", dataViewTag = "[object DataView]", float32Tag = "[object Float32Array]", float64Tag = "[object Float64Array]", int8Tag = "[object Int8Array]", int16Tag = "[object Int16Array]", int32Tag = "[object Int32Array]", uint8Tag = "[object Uint8Array]", uint8ClampedTag = "[object Uint8ClampedArray]", uint16Tag = "[object Uint16Array]", uint32Tag = "[object Uint32Array]";
28832
- var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, reIsPlainProp = /^\w*$/, reLeadingDot = /^\./, rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
28833
- var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
28834
- var reEscapeChar = /\\(\\)?/g;
28835
- var reIsHostCtor = /^\[object .+?Constructor\]$/;
28836
- var reIsUint = /^(?:0|[1-9]\d*)$/;
28837
- var typedArrayTags = {};
28838
- typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true;
28839
- typedArrayTags[argsTag] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag] = typedArrayTags[mapTag] = typedArrayTags[numberTag] = typedArrayTags[objectTag] = typedArrayTags[regexpTag] = typedArrayTags[setTag] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;
28840
- var freeGlobal = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
28841
- var freeSelf = typeof self == "object" && self && self.Object === Object && self;
28842
- var root = freeGlobal || freeSelf || Function("return this")();
28843
- var freeExports = exports$1 && !exports$1.nodeType && exports$1;
28844
- var freeModule = freeExports && true && module && !module.nodeType && module;
28845
- var moduleExports = freeModule && freeModule.exports === freeExports;
28846
- var freeProcess = moduleExports && freeGlobal.process;
28847
- var nodeUtil = function() {
28848
- try {
28849
- return freeProcess && freeProcess.binding("util");
28850
- } catch (e) {}
28851
- }();
28852
- var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
28853
- function apply(func, thisArg, args) {
28854
- switch (args.length) {
28855
- case 0:
28856
- return func.call(thisArg);
28857
- case 1:
28858
- return func.call(thisArg, args[0]);
28859
- case 2:
28860
- return func.call(thisArg, args[0], args[1]);
28861
- case 3:
28862
- return func.call(thisArg, args[0], args[1], args[2]);
28863
- }
28864
- return func.apply(thisArg, args);
28865
- }
28866
- function arrayMap(array, iteratee) {
28867
- var index2 = -1, length = array ? array.length : 0, result = Array(length);
28868
- while (++index2 < length) {
28869
- result[index2] = iteratee(array[index2], index2, array);
28870
- }
28871
- return result;
28872
- }
28873
- function arrayPush(array, values2) {
28874
- var index2 = -1, length = values2.length, offset = array.length;
28875
- while (++index2 < length) {
28876
- array[offset + index2] = values2[index2];
28877
- }
28878
- return array;
28879
- }
28880
- function arraySome(array, predicate) {
28881
- var index2 = -1, length = array ? array.length : 0;
28882
- while (++index2 < length) {
28883
- if (predicate(array[index2], index2, array)) {
28884
- return true;
28885
- }
28886
- }
28887
- return false;
28888
- }
28889
- function baseProperty(key) {
28890
- return function(object) {
28891
- return object == null ? undefined : object[key];
28892
- };
28893
- }
28894
- function baseSortBy(array, comparer) {
28895
- var length = array.length;
28896
- array.sort(comparer);
28897
- while (length--) {
28898
- array[length] = array[length].value;
28899
- }
28900
- return array;
28901
- }
28902
- function baseTimes(n, iteratee) {
28903
- var index2 = -1, result = Array(n);
28904
- while (++index2 < n) {
28905
- result[index2] = iteratee(index2);
28906
- }
28907
- return result;
28908
- }
28909
- function baseUnary(func) {
28910
- return function(value) {
28911
- return func(value);
28912
- };
28913
- }
28914
- function getValue(object, key) {
28915
- return object == null ? undefined : object[key];
28916
- }
28917
- function isHostObject(value) {
28918
- var result = false;
28919
- if (value != null && typeof value.toString != "function") {
28920
- try {
28921
- result = !!(value + "");
28922
- } catch (e) {}
28923
- }
28924
- return result;
28925
- }
28926
- function mapToArray(map) {
28927
- var index2 = -1, result = Array(map.size);
28928
- map.forEach(function(value, key) {
28929
- result[++index2] = [key, value];
28930
- });
28931
- return result;
28932
- }
28933
- function overArg(func, transform) {
28934
- return function(arg) {
28935
- return func(transform(arg));
28936
- };
28937
- }
28938
- function setToArray(set) {
28939
- var index2 = -1, result = Array(set.size);
28940
- set.forEach(function(value) {
28941
- result[++index2] = value;
28942
- });
28943
- return result;
28944
- }
28945
- var arrayProto = Array.prototype, funcProto = Function.prototype, objectProto = Object.prototype;
28946
- var coreJsData = root["__core-js_shared__"];
28947
- var maskSrcKey = function() {
28948
- var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || "");
28949
- return uid ? "Symbol(src)_1." + uid : "";
28950
- }();
28951
- var funcToString = funcProto.toString;
28952
- var hasOwnProperty2 = objectProto.hasOwnProperty;
28953
- var objectToString = objectProto.toString;
28954
- var reIsNative = RegExp("^" + funcToString.call(hasOwnProperty2).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$");
28955
- var { Symbol: Symbol2, Uint8Array: Uint8Array2 } = root, propertyIsEnumerable = objectProto.propertyIsEnumerable, splice2 = arrayProto.splice, spreadableSymbol = Symbol2 ? Symbol2.isConcatSpreadable : undefined;
28956
- var nativeKeys = overArg(Object.keys, Object), nativeMax = Math.max;
28957
- var DataView2 = getNative(root, "DataView"), Map2 = getNative(root, "Map"), Promise2 = getNative(root, "Promise"), Set2 = getNative(root, "Set"), WeakMap2 = getNative(root, "WeakMap"), nativeCreate = getNative(Object, "create");
28958
- var dataViewCtorString = toSource(DataView2), mapCtorString = toSource(Map2), promiseCtorString = toSource(Promise2), setCtorString = toSource(Set2), weakMapCtorString = toSource(WeakMap2);
28959
- var symbolProto = Symbol2 ? Symbol2.prototype : undefined, symbolValueOf = symbolProto ? symbolProto.valueOf : undefined, symbolToString = symbolProto ? symbolProto.toString : undefined;
28960
- function Hash(entries) {
28961
- var index2 = -1, length = entries ? entries.length : 0;
28962
- this.clear();
28963
- while (++index2 < length) {
28964
- var entry = entries[index2];
28965
- this.set(entry[0], entry[1]);
28966
- }
28967
- }
28968
- function hashClear() {
28969
- this.__data__ = nativeCreate ? nativeCreate(null) : {};
28970
- }
28971
- function hashDelete(key) {
28972
- return this.has(key) && delete this.__data__[key];
28973
- }
28974
- function hashGet(key) {
28975
- var data = this.__data__;
28976
- if (nativeCreate) {
28977
- var result = data[key];
28978
- return result === HASH_UNDEFINED ? undefined : result;
28979
- }
28980
- return hasOwnProperty2.call(data, key) ? data[key] : undefined;
28981
- }
28982
- function hashHas(key) {
28983
- var data = this.__data__;
28984
- return nativeCreate ? data[key] !== undefined : hasOwnProperty2.call(data, key);
28985
- }
28986
- function hashSet(key, value) {
28987
- var data = this.__data__;
28988
- data[key] = nativeCreate && value === undefined ? HASH_UNDEFINED : value;
28989
- return this;
28990
- }
28991
- Hash.prototype.clear = hashClear;
28992
- Hash.prototype["delete"] = hashDelete;
28993
- Hash.prototype.get = hashGet;
28994
- Hash.prototype.has = hashHas;
28995
- Hash.prototype.set = hashSet;
28996
- function ListCache(entries) {
28997
- var index2 = -1, length = entries ? entries.length : 0;
28998
- this.clear();
28999
- while (++index2 < length) {
29000
- var entry = entries[index2];
29001
- this.set(entry[0], entry[1]);
29002
- }
29003
- }
29004
- function listCacheClear() {
29005
- this.__data__ = [];
29006
- }
29007
- function listCacheDelete(key) {
29008
- var data = this.__data__, index2 = assocIndexOf(data, key);
29009
- if (index2 < 0) {
29010
- return false;
29011
- }
29012
- var lastIndex = data.length - 1;
29013
- if (index2 == lastIndex) {
29014
- data.pop();
29015
- } else {
29016
- splice2.call(data, index2, 1);
29017
- }
29018
- return true;
29019
- }
29020
- function listCacheGet(key) {
29021
- var data = this.__data__, index2 = assocIndexOf(data, key);
29022
- return index2 < 0 ? undefined : data[index2][1];
29023
- }
29024
- function listCacheHas(key) {
29025
- return assocIndexOf(this.__data__, key) > -1;
29026
- }
29027
- function listCacheSet(key, value) {
29028
- var data = this.__data__, index2 = assocIndexOf(data, key);
29029
- if (index2 < 0) {
29030
- data.push([key, value]);
29031
- } else {
29032
- data[index2][1] = value;
29033
- }
29034
- return this;
29035
- }
29036
- ListCache.prototype.clear = listCacheClear;
29037
- ListCache.prototype["delete"] = listCacheDelete;
29038
- ListCache.prototype.get = listCacheGet;
29039
- ListCache.prototype.has = listCacheHas;
29040
- ListCache.prototype.set = listCacheSet;
29041
- function MapCache(entries) {
29042
- var index2 = -1, length = entries ? entries.length : 0;
29043
- this.clear();
29044
- while (++index2 < length) {
29045
- var entry = entries[index2];
29046
- this.set(entry[0], entry[1]);
29047
- }
29048
- }
29049
- function mapCacheClear() {
29050
- this.__data__ = {
29051
- hash: new Hash,
29052
- map: new (Map2 || ListCache),
29053
- string: new Hash
29054
- };
29055
- }
29056
- function mapCacheDelete(key) {
29057
- return getMapData(this, key)["delete"](key);
29058
- }
29059
- function mapCacheGet(key) {
29060
- return getMapData(this, key).get(key);
29061
- }
29062
- function mapCacheHas(key) {
29063
- return getMapData(this, key).has(key);
29064
- }
29065
- function mapCacheSet(key, value) {
29066
- getMapData(this, key).set(key, value);
29067
- return this;
29068
- }
29069
- MapCache.prototype.clear = mapCacheClear;
29070
- MapCache.prototype["delete"] = mapCacheDelete;
29071
- MapCache.prototype.get = mapCacheGet;
29072
- MapCache.prototype.has = mapCacheHas;
29073
- MapCache.prototype.set = mapCacheSet;
29074
- function SetCache(values2) {
29075
- var index2 = -1, length = values2 ? values2.length : 0;
29076
- this.__data__ = new MapCache;
29077
- while (++index2 < length) {
29078
- this.add(values2[index2]);
29079
- }
29080
- }
29081
- function setCacheAdd(value) {
29082
- this.__data__.set(value, HASH_UNDEFINED);
29083
- return this;
29084
- }
29085
- function setCacheHas(value) {
29086
- return this.__data__.has(value);
29087
- }
29088
- SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
29089
- SetCache.prototype.has = setCacheHas;
29090
- function Stack(entries) {
29091
- this.__data__ = new ListCache(entries);
29092
- }
29093
- function stackClear() {
29094
- this.__data__ = new ListCache;
29095
- }
29096
- function stackDelete(key) {
29097
- return this.__data__["delete"](key);
29098
- }
29099
- function stackGet(key) {
29100
- return this.__data__.get(key);
29101
- }
29102
- function stackHas(key) {
29103
- return this.__data__.has(key);
29104
- }
29105
- function stackSet(key, value) {
29106
- var cache = this.__data__;
29107
- if (cache instanceof ListCache) {
29108
- var pairs = cache.__data__;
29109
- if (!Map2 || pairs.length < LARGE_ARRAY_SIZE - 1) {
29110
- pairs.push([key, value]);
29111
- return this;
29112
- }
29113
- cache = this.__data__ = new MapCache(pairs);
29114
- }
29115
- cache.set(key, value);
29116
- return this;
29117
- }
29118
- Stack.prototype.clear = stackClear;
29119
- Stack.prototype["delete"] = stackDelete;
29120
- Stack.prototype.get = stackGet;
29121
- Stack.prototype.has = stackHas;
29122
- Stack.prototype.set = stackSet;
29123
- function arrayLikeKeys(value, inherited) {
29124
- var result = isArray2(value) || isArguments(value) ? baseTimes(value.length, String) : [];
29125
- var length = result.length, skipIndexes = !!length;
29126
- for (var key in value) {
29127
- if (hasOwnProperty2.call(value, key) && !(skipIndexes && (key == "length" || isIndex(key, length)))) {
29128
- result.push(key);
29129
- }
29130
- }
29131
- return result;
29132
- }
29133
- function assocIndexOf(array, key) {
29134
- var length = array.length;
29135
- while (length--) {
29136
- if (eq(array[length][0], key)) {
29137
- return length;
29138
- }
29139
- }
29140
- return -1;
29141
- }
29142
- var baseEach = createBaseEach(baseForOwn);
29143
- function baseFlatten(array, depth, predicate, isStrict, result) {
29144
- var index2 = -1, length = array.length;
29145
- predicate || (predicate = isFlattenable);
29146
- result || (result = []);
29147
- while (++index2 < length) {
29148
- var value = array[index2];
29149
- if (predicate(value)) {
29150
- {
29151
- arrayPush(result, value);
29152
- }
29153
- } else {
29154
- result[result.length] = value;
29155
- }
29156
- }
29157
- return result;
29158
- }
29159
- var baseFor = createBaseFor();
29160
- function baseForOwn(object, iteratee) {
29161
- return object && baseFor(object, iteratee, keys);
29162
- }
29163
- function baseGet(object, path2) {
29164
- path2 = isKey(path2, object) ? [path2] : castPath(path2);
29165
- var index2 = 0, length = path2.length;
29166
- while (object != null && index2 < length) {
29167
- object = object[toKey(path2[index2++])];
29168
- }
29169
- return index2 && index2 == length ? object : undefined;
29170
- }
29171
- function baseGetTag(value) {
29172
- return objectToString.call(value);
29173
- }
29174
- function baseHasIn(object, key) {
29175
- return object != null && key in Object(object);
29176
- }
29177
- function baseIsEqual(value, other, customizer, bitmask, stack) {
29178
- if (value === other) {
29179
- return true;
29180
- }
29181
- if (value == null || other == null || !isObject2(value) && !isObjectLike(other)) {
29182
- return value !== value && other !== other;
29183
- }
29184
- return baseIsEqualDeep(value, other, baseIsEqual, customizer, bitmask, stack);
29185
- }
29186
- function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) {
29187
- var objIsArr = isArray2(object), othIsArr = isArray2(other), objTag = arrayTag, othTag = arrayTag;
29188
- if (!objIsArr) {
29189
- objTag = getTag(object);
29190
- objTag = objTag == argsTag ? objectTag : objTag;
29191
- }
29192
- if (!othIsArr) {
29193
- othTag = getTag(other);
29194
- othTag = othTag == argsTag ? objectTag : othTag;
29195
- }
29196
- var objIsObj = objTag == objectTag && !isHostObject(object), othIsObj = othTag == objectTag && !isHostObject(other), isSameTag = objTag == othTag;
29197
- if (isSameTag && !objIsObj) {
29198
- stack || (stack = new Stack);
29199
- return objIsArr || isTypedArray(object) ? equalArrays(object, other, equalFunc, customizer, bitmask, stack) : equalByTag(object, other, objTag, equalFunc, customizer, bitmask, stack);
29200
- }
29201
- if (!(bitmask & PARTIAL_COMPARE_FLAG)) {
29202
- var objIsWrapped = objIsObj && hasOwnProperty2.call(object, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty2.call(other, "__wrapped__");
29203
- if (objIsWrapped || othIsWrapped) {
29204
- var objUnwrapped = objIsWrapped ? object.value() : object, othUnwrapped = othIsWrapped ? other.value() : other;
29205
- stack || (stack = new Stack);
29206
- return equalFunc(objUnwrapped, othUnwrapped, customizer, bitmask, stack);
29207
- }
29208
- }
29209
- if (!isSameTag) {
29210
- return false;
29211
- }
29212
- stack || (stack = new Stack);
29213
- return equalObjects(object, other, equalFunc, customizer, bitmask, stack);
29214
- }
29215
- function baseIsMatch(object, source, matchData, customizer) {
29216
- var index2 = matchData.length, length = index2;
29217
- if (object == null) {
29218
- return !length;
29219
- }
29220
- object = Object(object);
29221
- while (index2--) {
29222
- var data = matchData[index2];
29223
- if (data[2] ? data[1] !== object[data[0]] : !(data[0] in object)) {
29224
- return false;
29225
- }
29226
- }
29227
- while (++index2 < length) {
29228
- data = matchData[index2];
29229
- var key = data[0], objValue = object[key], srcValue = data[1];
29230
- if (data[2]) {
29231
- if (objValue === undefined && !(key in object)) {
29232
- return false;
29233
- }
29234
- } else {
29235
- var stack = new Stack;
29236
- var result;
29237
- if (!(result === undefined ? baseIsEqual(srcValue, objValue, customizer, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack) : result)) {
29238
- return false;
29239
- }
29240
- }
29241
- }
29242
- return true;
29243
- }
29244
- function baseIsNative(value) {
29245
- if (!isObject2(value) || isMasked(value)) {
29246
- return false;
29247
- }
29248
- var pattern = isFunction2(value) || isHostObject(value) ? reIsNative : reIsHostCtor;
29249
- return pattern.test(toSource(value));
29250
- }
29251
- function baseIsTypedArray(value) {
29252
- return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objectToString.call(value)];
29253
- }
29254
- function baseIteratee(value) {
29255
- if (typeof value == "function") {
29256
- return value;
29257
- }
29258
- if (value == null) {
29259
- return identity;
29260
- }
29261
- if (typeof value == "object") {
29262
- return isArray2(value) ? baseMatchesProperty(value[0], value[1]) : baseMatches(value);
29263
- }
29264
- return property(value);
29265
- }
29266
- function baseKeys(object) {
29267
- if (!isPrototype(object)) {
29268
- return nativeKeys(object);
29269
- }
29270
- var result = [];
29271
- for (var key in Object(object)) {
29272
- if (hasOwnProperty2.call(object, key) && key != "constructor") {
29273
- result.push(key);
29274
- }
29275
- }
29276
- return result;
29277
- }
29278
- function baseMap(collection, iteratee) {
29279
- var index2 = -1, result = isArrayLike(collection) ? Array(collection.length) : [];
29280
- baseEach(collection, function(value, key, collection2) {
29281
- result[++index2] = iteratee(value, key, collection2);
29282
- });
29283
- return result;
29284
- }
29285
- function baseMatches(source) {
29286
- var matchData = getMatchData(source);
29287
- if (matchData.length == 1 && matchData[0][2]) {
29288
- return matchesStrictComparable(matchData[0][0], matchData[0][1]);
29289
- }
29290
- return function(object) {
29291
- return object === source || baseIsMatch(object, source, matchData);
29292
- };
29293
- }
29294
- function baseMatchesProperty(path2, srcValue) {
29295
- if (isKey(path2) && isStrictComparable(srcValue)) {
29296
- return matchesStrictComparable(toKey(path2), srcValue);
29297
- }
29298
- return function(object) {
29299
- var objValue = get(object, path2);
29300
- return objValue === undefined && objValue === srcValue ? hasIn(object, path2) : baseIsEqual(srcValue, objValue, undefined, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG);
29301
- };
29302
- }
29303
- function baseOrderBy(collection, iteratees, orders) {
29304
- var index2 = -1;
29305
- iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(baseIteratee));
29306
- var result = baseMap(collection, function(value, key, collection2) {
29307
- var criteria = arrayMap(iteratees, function(iteratee) {
29308
- return iteratee(value);
29309
- });
29310
- return { criteria, index: ++index2, value };
29311
- });
29312
- return baseSortBy(result, function(object, other) {
29313
- return compareMultiple(object, other, orders);
29314
- });
29315
- }
29316
- function basePropertyDeep(path2) {
29317
- return function(object) {
29318
- return baseGet(object, path2);
29319
- };
29320
- }
29321
- function baseRest(func, start) {
29322
- start = nativeMax(start === undefined ? func.length - 1 : start, 0);
29323
- return function() {
29324
- var args = arguments, index2 = -1, length = nativeMax(args.length - start, 0), array = Array(length);
29325
- while (++index2 < length) {
29326
- array[index2] = args[start + index2];
29327
- }
29328
- index2 = -1;
29329
- var otherArgs = Array(start + 1);
29330
- while (++index2 < start) {
29331
- otherArgs[index2] = args[index2];
29332
- }
29333
- otherArgs[start] = array;
29334
- return apply(func, this, otherArgs);
29335
- };
29336
- }
29337
- function baseToString(value) {
29338
- if (typeof value == "string") {
29339
- return value;
29340
- }
29341
- if (isSymbol(value)) {
29342
- return symbolToString ? symbolToString.call(value) : "";
29343
- }
29344
- var result = value + "";
29345
- return result == "0" && 1 / value == -Infinity ? "-0" : result;
29346
- }
29347
- function castPath(value) {
29348
- return isArray2(value) ? value : stringToPath(value);
29349
- }
29350
- function compareAscending(value, other) {
29351
- if (value !== other) {
29352
- var valIsDefined = value !== undefined, valIsNull = value === null, valIsReflexive = value === value, valIsSymbol = isSymbol(value);
29353
- var othIsDefined = other !== undefined, othIsNull = other === null, othIsReflexive = other === other, othIsSymbol = isSymbol(other);
29354
- if (!othIsNull && !othIsSymbol && !valIsSymbol && value > other || valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol || valIsNull && othIsDefined && othIsReflexive || !valIsDefined && othIsReflexive || !valIsReflexive) {
29355
- return 1;
29356
- }
29357
- if (!valIsNull && !valIsSymbol && !othIsSymbol && value < other || othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol || othIsNull && valIsDefined && valIsReflexive || !othIsDefined && valIsReflexive || !othIsReflexive) {
29358
- return -1;
29359
- }
29360
- }
29361
- return 0;
29362
- }
29363
- function compareMultiple(object, other, orders) {
29364
- var index2 = -1, objCriteria = object.criteria, othCriteria = other.criteria, length = objCriteria.length, ordersLength = orders.length;
29365
- while (++index2 < length) {
29366
- var result = compareAscending(objCriteria[index2], othCriteria[index2]);
29367
- if (result) {
29368
- if (index2 >= ordersLength) {
29369
- return result;
29370
- }
29371
- var order = orders[index2];
29372
- return result * (order == "desc" ? -1 : 1);
29373
- }
29374
- }
29375
- return object.index - other.index;
29376
- }
29377
- function createBaseEach(eachFunc, fromRight) {
29378
- return function(collection, iteratee) {
29379
- if (collection == null) {
29380
- return collection;
29381
- }
29382
- if (!isArrayLike(collection)) {
29383
- return eachFunc(collection, iteratee);
29384
- }
29385
- var length = collection.length, index2 = -1, iterable = Object(collection);
29386
- while (++index2 < length) {
29387
- if (iteratee(iterable[index2], index2, iterable) === false) {
29388
- break;
29389
- }
29390
- }
29391
- return collection;
29392
- };
29393
- }
29394
- function createBaseFor(fromRight) {
29395
- return function(object, iteratee, keysFunc) {
29396
- var index2 = -1, iterable = Object(object), props = keysFunc(object), length = props.length;
29397
- while (length--) {
29398
- var key = props[++index2];
29399
- if (iteratee(iterable[key], key, iterable) === false) {
29400
- break;
29401
- }
29402
- }
29403
- return object;
29404
- };
29405
- }
29406
- function equalArrays(array, other, equalFunc, customizer, bitmask, stack) {
29407
- var isPartial = bitmask & PARTIAL_COMPARE_FLAG, arrLength = array.length, othLength = other.length;
29408
- if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
29409
- return false;
29410
- }
29411
- var stacked = stack.get(array);
29412
- if (stacked && stack.get(other)) {
29413
- return stacked == other;
29414
- }
29415
- var index2 = -1, result = true, seen = bitmask & UNORDERED_COMPARE_FLAG ? new SetCache : undefined;
29416
- stack.set(array, other);
29417
- stack.set(other, array);
29418
- while (++index2 < arrLength) {
29419
- var arrValue = array[index2], othValue = other[index2];
29420
- if (customizer) {
29421
- var compared = isPartial ? customizer(othValue, arrValue, index2, other, array, stack) : customizer(arrValue, othValue, index2, array, other, stack);
29422
- }
29423
- if (compared !== undefined) {
29424
- if (compared) {
29425
- continue;
29426
- }
29427
- result = false;
29428
- break;
29429
- }
29430
- if (seen) {
29431
- if (!arraySome(other, function(othValue2, othIndex) {
29432
- if (!seen.has(othIndex) && (arrValue === othValue2 || equalFunc(arrValue, othValue2, customizer, bitmask, stack))) {
29433
- return seen.add(othIndex);
29434
- }
29435
- })) {
29436
- result = false;
29437
- break;
29438
- }
29439
- } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) {
29440
- result = false;
29441
- break;
29442
- }
29443
- }
29444
- stack["delete"](array);
29445
- stack["delete"](other);
29446
- return result;
29447
- }
29448
- function equalByTag(object, other, tag, equalFunc, customizer, bitmask, stack) {
29449
- switch (tag) {
29450
- case dataViewTag:
29451
- if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) {
29452
- return false;
29453
- }
29454
- object = object.buffer;
29455
- other = other.buffer;
29456
- case arrayBufferTag:
29457
- if (object.byteLength != other.byteLength || !equalFunc(new Uint8Array2(object), new Uint8Array2(other))) {
29458
- return false;
29459
- }
29460
- return true;
29461
- case boolTag:
29462
- case dateTag:
29463
- case numberTag:
29464
- return eq(+object, +other);
29465
- case errorTag:
29466
- return object.name == other.name && object.message == other.message;
29467
- case regexpTag:
29468
- case stringTag:
29469
- return object == other + "";
29470
- case mapTag:
29471
- var convert2 = mapToArray;
29472
- case setTag:
29473
- var isPartial = bitmask & PARTIAL_COMPARE_FLAG;
29474
- convert2 || (convert2 = setToArray);
29475
- if (object.size != other.size && !isPartial) {
29476
- return false;
29477
- }
29478
- var stacked = stack.get(object);
29479
- if (stacked) {
29480
- return stacked == other;
29481
- }
29482
- bitmask |= UNORDERED_COMPARE_FLAG;
29483
- stack.set(object, other);
29484
- var result = equalArrays(convert2(object), convert2(other), equalFunc, customizer, bitmask, stack);
29485
- stack["delete"](object);
29486
- return result;
29487
- case symbolTag:
29488
- if (symbolValueOf) {
29489
- return symbolValueOf.call(object) == symbolValueOf.call(other);
29490
- }
29491
- }
29492
- return false;
29493
- }
29494
- function equalObjects(object, other, equalFunc, customizer, bitmask, stack) {
29495
- var isPartial = bitmask & PARTIAL_COMPARE_FLAG, objProps = keys(object), objLength = objProps.length, othProps = keys(other), othLength = othProps.length;
29496
- if (objLength != othLength && !isPartial) {
29497
- return false;
29498
- }
29499
- var index2 = objLength;
29500
- while (index2--) {
29501
- var key = objProps[index2];
29502
- if (!(isPartial ? key in other : hasOwnProperty2.call(other, key))) {
29503
- return false;
29504
- }
29505
- }
29506
- var stacked = stack.get(object);
29507
- if (stacked && stack.get(other)) {
29508
- return stacked == other;
29509
- }
29510
- var result = true;
29511
- stack.set(object, other);
29512
- stack.set(other, object);
29513
- var skipCtor = isPartial;
29514
- while (++index2 < objLength) {
29515
- key = objProps[index2];
29516
- var objValue = object[key], othValue = other[key];
29517
- if (customizer) {
29518
- var compared = isPartial ? customizer(othValue, objValue, key, other, object, stack) : customizer(objValue, othValue, key, object, other, stack);
29519
- }
29520
- if (!(compared === undefined ? objValue === othValue || equalFunc(objValue, othValue, customizer, bitmask, stack) : compared)) {
29521
- result = false;
29522
- break;
29523
- }
29524
- skipCtor || (skipCtor = key == "constructor");
29525
- }
29526
- if (result && !skipCtor) {
29527
- var objCtor = object.constructor, othCtor = other.constructor;
29528
- if (objCtor != othCtor && (("constructor" in object) && ("constructor" in other)) && !(typeof objCtor == "function" && objCtor instanceof objCtor && typeof othCtor == "function" && othCtor instanceof othCtor)) {
29529
- result = false;
29530
- }
29531
- }
29532
- stack["delete"](object);
29533
- stack["delete"](other);
29534
- return result;
29535
- }
29536
- function getMapData(map, key) {
29537
- var data = map.__data__;
29538
- return isKeyable(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
29539
- }
29540
- function getMatchData(object) {
29541
- var result = keys(object), length = result.length;
29542
- while (length--) {
29543
- var key = result[length], value = object[key];
29544
- result[length] = [key, value, isStrictComparable(value)];
29545
- }
29546
- return result;
29547
- }
29548
- function getNative(object, key) {
29549
- var value = getValue(object, key);
29550
- return baseIsNative(value) ? value : undefined;
29551
- }
29552
- var getTag = baseGetTag;
29553
- if (DataView2 && getTag(new DataView2(new ArrayBuffer(1))) != dataViewTag || Map2 && getTag(new Map2) != mapTag || Promise2 && getTag(Promise2.resolve()) != promiseTag || Set2 && getTag(new Set2) != setTag || WeakMap2 && getTag(new WeakMap2) != weakMapTag) {
29554
- getTag = function(value) {
29555
- var result = objectToString.call(value), Ctor = result == objectTag ? value.constructor : undefined, ctorString = Ctor ? toSource(Ctor) : undefined;
29556
- if (ctorString) {
29557
- switch (ctorString) {
29558
- case dataViewCtorString:
29559
- return dataViewTag;
29560
- case mapCtorString:
29561
- return mapTag;
29562
- case promiseCtorString:
29563
- return promiseTag;
29564
- case setCtorString:
29565
- return setTag;
29566
- case weakMapCtorString:
29567
- return weakMapTag;
29568
- }
29569
- }
29570
- return result;
29571
- };
29572
- }
29573
- function hasPath(object, path2, hasFunc) {
29574
- path2 = isKey(path2, object) ? [path2] : castPath(path2);
29575
- var result, index2 = -1, length = path2.length;
29576
- while (++index2 < length) {
29577
- var key = toKey(path2[index2]);
29578
- if (!(result = object != null && hasFunc(object, key))) {
29579
- break;
29580
- }
29581
- object = object[key];
29582
- }
29583
- if (result) {
29584
- return result;
29585
- }
29586
- var length = object ? object.length : 0;
29587
- return !!length && isLength(length) && isIndex(key, length) && (isArray2(object) || isArguments(object));
29588
- }
29589
- function isFlattenable(value) {
29590
- return isArray2(value) || isArguments(value) || !!(spreadableSymbol && value && value[spreadableSymbol]);
29591
- }
29592
- function isIndex(value, length) {
29593
- length = length == null ? MAX_SAFE_INTEGER : length;
29594
- return !!length && (typeof value == "number" || reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length);
29595
- }
29596
- function isIterateeCall(value, index2, object) {
29597
- if (!isObject2(object)) {
29598
- return false;
29599
- }
29600
- var type = typeof index2;
29601
- if (type == "number" ? isArrayLike(object) && isIndex(index2, object.length) : type == "string" && (index2 in object)) {
29602
- return eq(object[index2], value);
29603
- }
29604
- return false;
29605
- }
29606
- function isKey(value, object) {
29607
- if (isArray2(value)) {
29608
- return false;
29609
- }
29610
- var type = typeof value;
29611
- if (type == "number" || type == "symbol" || type == "boolean" || value == null || isSymbol(value)) {
29612
- return true;
29613
- }
29614
- return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object(object);
29615
- }
29616
- function isKeyable(value) {
29617
- var type = typeof value;
29618
- return type == "string" || type == "number" || type == "symbol" || type == "boolean" ? value !== "__proto__" : value === null;
29619
- }
29620
- function isMasked(func) {
29621
- return !!maskSrcKey && maskSrcKey in func;
29622
- }
29623
- function isPrototype(value) {
29624
- var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto;
29625
- return value === proto;
29626
- }
29627
- function isStrictComparable(value) {
29628
- return value === value && !isObject2(value);
29629
- }
29630
- function matchesStrictComparable(key, srcValue) {
29631
- return function(object) {
29632
- if (object == null) {
29633
- return false;
29634
- }
29635
- return object[key] === srcValue && (srcValue !== undefined || (key in Object(object)));
29636
- };
29637
- }
29638
- var stringToPath = memoize(function(string3) {
29639
- string3 = toString2(string3);
29640
- var result = [];
29641
- if (reLeadingDot.test(string3)) {
29642
- result.push("");
29643
- }
29644
- string3.replace(rePropName, function(match, number, quote, string4) {
29645
- result.push(quote ? string4.replace(reEscapeChar, "$1") : number || match);
29646
- });
29647
- return result;
29648
- });
29649
- function toKey(value) {
29650
- if (typeof value == "string" || isSymbol(value)) {
29651
- return value;
29652
- }
29653
- var result = value + "";
29654
- return result == "0" && 1 / value == -Infinity ? "-0" : result;
29655
- }
29656
- function toSource(func) {
29657
- if (func != null) {
29658
- try {
29659
- return funcToString.call(func);
29660
- } catch (e) {}
29661
- try {
29662
- return func + "";
29663
- } catch (e) {}
29664
- }
29665
- return "";
29666
- }
29667
- var sortBy = baseRest(function(collection, iteratees) {
29668
- if (collection == null) {
29669
- return [];
29670
- }
29671
- var length = iteratees.length;
29672
- if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
29673
- iteratees = [];
29674
- } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
29675
- iteratees = [iteratees[0]];
29676
- }
29677
- return baseOrderBy(collection, baseFlatten(iteratees), []);
29678
- });
29679
- function memoize(func, resolver2) {
29680
- if (typeof func != "function" || resolver2 && typeof resolver2 != "function") {
29681
- throw new TypeError(FUNC_ERROR_TEXT);
29682
- }
29683
- var memoized = function() {
29684
- var args = arguments, key = resolver2 ? resolver2.apply(this, args) : args[0], cache = memoized.cache;
29685
- if (cache.has(key)) {
29686
- return cache.get(key);
29687
- }
29688
- var result = func.apply(this, args);
29689
- memoized.cache = cache.set(key, result);
29690
- return result;
29691
- };
29692
- memoized.cache = new (memoize.Cache || MapCache);
29693
- return memoized;
29694
- }
29695
- memoize.Cache = MapCache;
29696
- function eq(value, other) {
29697
- return value === other || value !== value && other !== other;
29698
- }
29699
- function isArguments(value) {
29700
- return isArrayLikeObject(value) && hasOwnProperty2.call(value, "callee") && (!propertyIsEnumerable.call(value, "callee") || objectToString.call(value) == argsTag);
29701
- }
29702
- var isArray2 = Array.isArray;
29703
- function isArrayLike(value) {
29704
- return value != null && isLength(value.length) && !isFunction2(value);
29705
- }
29706
- function isArrayLikeObject(value) {
29707
- return isObjectLike(value) && isArrayLike(value);
29708
- }
29709
- function isFunction2(value) {
29710
- var tag = isObject2(value) ? objectToString.call(value) : "";
29711
- return tag == funcTag || tag == genTag;
29712
- }
29713
- function isLength(value) {
29714
- return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
29715
- }
29716
- function isObject2(value) {
29717
- var type = typeof value;
29718
- return !!value && (type == "object" || type == "function");
29719
- }
29720
- function isObjectLike(value) {
29721
- return !!value && typeof value == "object";
29722
- }
29723
- function isSymbol(value) {
29724
- return typeof value == "symbol" || isObjectLike(value) && objectToString.call(value) == symbolTag;
29725
- }
29726
- var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
29727
- function toString2(value) {
29728
- return value == null ? "" : baseToString(value);
29729
- }
29730
- function get(object, path2, defaultValue) {
29731
- var result = object == null ? undefined : baseGet(object, path2);
29732
- return result === undefined ? defaultValue : result;
29733
- }
29734
- function hasIn(object, path2) {
29735
- return object != null && hasPath(object, path2, baseHasIn);
29736
- }
29737
- function keys(object) {
29738
- return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
29739
- }
29740
- function identity(value) {
29741
- return value;
29742
- }
29743
- function property(path2) {
29744
- return isKey(path2) ? baseProperty(toKey(path2)) : basePropertyDeep(path2);
29745
- }
29746
- module.exports = sortBy;
29747
- })(lodash_sortby, lodash_sortby.exports);
29748
- return lodash_sortby.exports;
29749
- }
29750
- function requireEscapeStringRegexp() {
29751
- if (hasRequiredEscapeStringRegexp)
29752
- return escapeStringRegexp2;
29753
- hasRequiredEscapeStringRegexp = 1;
29754
- escapeStringRegexp2 = (string3) => {
29755
- if (typeof string3 !== "string") {
29756
- throw new TypeError("Expected a string");
29757
- }
29758
- return string3.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
29759
- };
29760
- return escapeStringRegexp2;
29761
- }
29762
- function requireRegexpParse() {
29763
- if (hasRequiredRegexpParse)
29764
- return regexpParse;
29765
- hasRequiredRegexpParse = 1;
29766
- Object.defineProperty(regexpParse, "__esModule", { value: true });
29767
- regexpParse.isRegExpString = regexpParse.parseRegExpString = undefined;
29768
- var REGEXP_LITERAL_PATTERN = /^\/(.+)\/([guimysd]*)$/;
29769
- var parseRegExpString = function(str) {
29770
- var result = str.match(REGEXP_LITERAL_PATTERN);
29771
- if (!result) {
29772
- return null;
29773
- }
29774
- return {
29775
- source: result[1],
29776
- flagString: result[2]
29777
- };
29778
- };
29779
- regexpParse.parseRegExpString = parseRegExpString;
29780
- var isRegExpString = function(str) {
29781
- return REGEXP_LITERAL_PATTERN.test(str);
29782
- };
29783
- regexpParse.isRegExpString = isRegExpString;
29784
- return regexpParse;
29785
- }
29786
- function requireRegexpStringMatcher() {
29787
- if (hasRequiredRegexpStringMatcher)
29788
- return regexpStringMatcher;
29789
- hasRequiredRegexpStringMatcher = 1;
29790
- (function(exports$1) {
29791
- var __importDefault = regexpStringMatcher && regexpStringMatcher.__importDefault || function(mod) {
29792
- return mod && mod.__esModule ? mod : { default: mod };
29793
- };
29794
- Object.defineProperty(exports$1, "__esModule", { value: true });
29795
- exports$1.matchPatterns = exports$1.createRegExp = undefined;
29796
- var lodash_uniq_1 = __importDefault(requireLodash_uniq());
29797
- var lodash_uniqwith_1 = __importDefault(requireLodash_uniqwith());
29798
- var lodash_sortby_1 = __importDefault(requireLodash_sortby());
29799
- var escape_string_regexp_1 = __importDefault(requireEscapeStringRegexp());
29800
- var regexp_parse_1 = requireRegexpParse();
29801
- var DEFAULT_FLAGS = "ug";
29802
- var defaultFlags = function(flagsString) {
29803
- if (flagsString.length === 0) {
29804
- return DEFAULT_FLAGS;
29805
- }
29806
- return (0, lodash_uniq_1.default)((flagsString + DEFAULT_FLAGS).split("")).join("");
29807
- };
29808
- var createRegExp = function(patternString, defaultFlag) {
29809
- if (defaultFlag === undefined) {
29810
- defaultFlag = DEFAULT_FLAGS;
29811
- }
29812
- if (patternString.length === 0) {
29813
- throw new Error("Empty string can not handled");
29814
- }
29815
- if ((0, regexp_parse_1.isRegExpString)(patternString)) {
29816
- var regExpStructure = (0, regexp_parse_1.parseRegExpString)(patternString);
29817
- if (regExpStructure) {
29818
- return new RegExp(regExpStructure.source, defaultFlags(regExpStructure.flagString));
29819
- }
29820
- throw new Error('"'.concat(patternString, '" can not parse as RegExp.'));
29821
- } else {
29822
- return new RegExp((0, escape_string_regexp_1.default)(patternString), defaultFlag);
29823
- }
29824
- };
29825
- exports$1.createRegExp = createRegExp;
29826
- var isEqualMatchPatternResult = function(a, b) {
29827
- return a.startIndex === b.startIndex && a.endIndex === b.endIndex && a.match === b.match;
29828
- };
29829
- var matchPatterns = function(text4, regExpLikeStrings) {
29830
- var matchPatternResults = [];
29831
- regExpLikeStrings.map(function(patternString) {
29832
- return (0, exports$1.createRegExp)(patternString);
29833
- }).forEach(function(regExp) {
29834
- var results = text4.matchAll(regExp);
29835
- Array.from(results).forEach(function(result) {
29836
- if (result.index === undefined) {
29837
- return;
29838
- }
29839
- var match = result[0];
29840
- var index2 = result.index;
29841
- matchPatternResults.push({
29842
- match,
29843
- captures: result.slice(1),
29844
- startIndex: index2,
29845
- endIndex: index2 + match.length
29846
- });
29847
- });
29848
- });
29849
- var uniqResults = (0, lodash_uniqwith_1.default)(matchPatternResults, isEqualMatchPatternResult);
29850
- return (0, lodash_sortby_1.default)(uniqResults, ["startIndex", "endIndex"]);
29851
- };
29852
- exports$1.matchPatterns = matchPatterns;
29853
- })(regexpStringMatcher);
29854
- return regexpStringMatcher;
29855
- }
29856
- var commonjsGlobal, regexpStringMatcher, lodash_uniq, hasRequiredLodash_uniq, lodash_uniqwith, hasRequiredLodash_uniqwith, lodash_sortby, hasRequiredLodash_sortby, escapeStringRegexp2, hasRequiredEscapeStringRegexp, regexpParse, hasRequiredRegexpParse, hasRequiredRegexpStringMatcher, regexpStringMatcherExports, OID_DATA, OID_SHA1, OID_SHA256, OID_SHA384, OID_SHA512, typeMap;
29857
- var init_module2 = __esm(() => {
29858
- commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
29859
- regexpStringMatcher = {};
29860
- lodash_sortby = { exports: {} };
29861
- lodash_sortby.exports;
29862
- regexpParse = {};
29863
- regexpStringMatcherExports = requireRegexpStringMatcher();
29864
- OID_DATA = new Uint8Array([42, 134, 72, 134, 247, 13, 1, 7, 1]);
29865
- OID_SHA1 = new Uint8Array([43, 14, 3, 2, 26]);
29866
- OID_SHA256 = new Uint8Array([96, 134, 72, 1, 101, 3, 4, 2, 1]);
29867
- OID_SHA384 = new Uint8Array([96, 134, 72, 1, 101, 3, 4, 2, 2]);
29868
- OID_SHA512 = new Uint8Array([96, 134, 72, 1, 101, 3, 4, 2, 3]);
29869
- typeMap = new Map([
29870
- ["ghp", "GitHub personal access tokens"],
29871
- ["gho", "OAuth access tokens"],
29872
- ["ghu", "GitHub user-to-server tokens"],
29873
- ["ghs", "GitHub server-to-server tokens"],
29874
- ["ghr", "refresh tokens"],
29875
- ["github_pat", "fine-grained personal access tokens"]
29876
- ]);
29877
- });
29878
-
29879
- // secret-detect/secretlint-source.ts
29880
- var init_secretlint_source = __esm(() => {
29881
- init_module();
29882
- init_module2();
29883
- init_suppressor();
29884
- });
29885
-
29886
27969
  // secret-detect/index.ts
29887
27970
  function detectSecrets(text4) {
29888
27971
  if (!text4 || text4.length === 0)
@@ -29982,7 +28065,6 @@ var init_secret_detect = __esm(() => {
29982
28065
  init_chunker();
29983
28066
  init_suppressor();
29984
28067
  init_url_redact();
29985
- init_secretlint_source();
29986
28068
  });
29987
28069
 
29988
28070
  // secret-detect/redact.ts
@@ -30091,6 +28173,25 @@ function initHistory(stateDir, retentionDays = 30) {
30091
28173
  throw err;
30092
28174
  }
30093
28175
  }
28176
+ const LOGICAL_KEY_INDEX = "idx_messages_logical_key";
28177
+ const logicalKeyIndexExists = db.prepare(`SELECT 1 FROM sqlite_master WHERE type = 'index' AND name = ?`).get(LOGICAL_KEY_INDEX) != null;
28178
+ if (!logicalKeyIndexExists) {
28179
+ db.exec(`
28180
+ DELETE FROM messages
28181
+ WHERE rowid NOT IN (
28182
+ SELECT keep_rowid FROM (
28183
+ SELECT rowid AS keep_rowid,
28184
+ ROW_NUMBER() OVER (
28185
+ PARTITION BY chat_id, COALESCE(thread_id, ''), message_id
28186
+ ORDER BY ts DESC, rowid DESC
28187
+ ) AS rn
28188
+ FROM messages
28189
+ )
28190
+ WHERE rn = 1
28191
+ )
28192
+ `);
28193
+ db.exec(`CREATE UNIQUE INDEX IF NOT EXISTS ${LOGICAL_KEY_INDEX} ` + `ON messages (chat_id, COALESCE(thread_id, ''), message_id)`);
28194
+ }
30094
28195
  for (const suffix of ["", "-shm", "-wal"]) {
30095
28196
  const f = path2 + suffix;
30096
28197
  if (existsSync21(f)) {
@@ -30420,6 +28521,13 @@ function formatResetRelative(target, now = new Date) {
30420
28521
  var OAUTH_BETA = "oauth-2025-04-20", DEFAULT_USER_AGENT = "claude-cli/1.0.0 (external, cli)", DEFAULT_PROBE_MODEL = "claude-haiku-4-5-20251001";
30421
28522
  var init_quota_check = () => {};
30422
28523
 
28524
+ // ../src/util/atomic.ts
28525
+ import { closeSync as closeSync5, constants as constants2, fsyncSync as fsyncSync2, openSync as openSync5, renameSync as renameSync10, rmSync as rmSync5, writeSync as writeSync4 } from "node:fs";
28526
+ var TMP_OPEN_FLAGS;
28527
+ var init_atomic = __esm(() => {
28528
+ TMP_OPEN_FLAGS = constants2.O_WRONLY | constants2.O_CREAT | constants2.O_EXCL | (constants2.O_NOFOLLOW ?? 0);
28529
+ });
28530
+
30423
28531
  // ../node_modules/.bun/handlebars@4.7.9/node_modules/handlebars/dist/cjs/handlebars/utils.js
30424
28532
  var require_utils = __commonJS((exports2) => {
30425
28533
  exports2.__esModule = true;
@@ -31783,7 +29891,7 @@ var require_parser2 = __commonJS((exports2, module) => {
31783
29891
  throw new Error(str);
31784
29892
  },
31785
29893
  parse: function parse3(input) {
31786
- var self2 = this, stack = [0], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1;
29894
+ var self = this, stack = [0], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1;
31787
29895
  this.lexer.setInput(input);
31788
29896
  this.lexer.yy = this.yy;
31789
29897
  this.yy.lexer = this.lexer;
@@ -31802,9 +29910,9 @@ var require_parser2 = __commonJS((exports2, module) => {
31802
29910
  }
31803
29911
  function lex() {
31804
29912
  var token;
31805
- token = self2.lexer.lex() || 1;
29913
+ token = self.lexer.lex() || 1;
31806
29914
  if (typeof token !== "number") {
31807
- token = self2.symbols_[token] || token;
29915
+ token = self.symbols_[token] || token;
31808
29916
  }
31809
29917
  return token;
31810
29918
  }
@@ -35963,7 +34071,7 @@ var require_printer = __commonJS((exports2) => {
35963
34071
  });
35964
34072
 
35965
34073
  // ../node_modules/.bun/handlebars@4.7.9/node_modules/handlebars/lib/index.js
35966
- var require_lib2 = __commonJS((exports2, module) => {
34074
+ var require_lib = __commonJS((exports2, module) => {
35967
34075
  var handlebars = require_handlebars()["default"];
35968
34076
  var printer = require_printer();
35969
34077
  handlebars.PrintVisitor = printer.PrintVisitor;
@@ -37040,7 +35148,7 @@ var init_boot_probes = __esm(() => {
37040
35148
  });
37041
35149
 
37042
35150
  // gateway/boot-issue-cache.ts
37043
- import { existsSync as existsSync39, readFileSync as readFileSync41, writeFileSync as writeFileSync32, mkdirSync as mkdirSync31, renameSync as renameSync15 } from "fs";
35151
+ import { existsSync as existsSync39, readFileSync as readFileSync41, writeFileSync as writeFileSync32, mkdirSync as mkdirSync31, renameSync as renameSync16 } from "fs";
37044
35152
  import { dirname as dirname12 } from "path";
37045
35153
  function fingerprintProbe(key, r) {
37046
35154
  if (r.status === "ok")
@@ -37133,7 +35241,7 @@ function loadCache(path2, now = Date.now) {
37133
35241
  parsed = JSON.parse(raw);
37134
35242
  } catch {
37135
35243
  try {
37136
- renameSync15(path2, `${path2}.corrupt-${now()}`);
35244
+ renameSync16(path2, `${path2}.corrupt-${now()}`);
37137
35245
  } catch {}
37138
35246
  return { ...EMPTY_CACHE, probes: {} };
37139
35247
  }
@@ -37170,7 +35278,7 @@ function applyAndSave(path2, cache, diff) {
37170
35278
  mkdirSync31(dirname12(path2), { recursive: true });
37171
35279
  const tmp = `${path2}.tmp`;
37172
35280
  writeFileSync32(tmp, JSON.stringify(next), { mode: 384 });
37173
- renameSync15(tmp, path2);
35281
+ renameSync16(tmp, path2);
37174
35282
  } catch {}
37175
35283
  return next;
37176
35284
  }
@@ -37183,7 +35291,7 @@ var init_boot_issue_cache = __esm(() => {
37183
35291
 
37184
35292
  // gateway/config-snapshot.ts
37185
35293
  import { createHash as createHash3 } from "crypto";
37186
- import { existsSync as existsSync40, readFileSync as readFileSync42, writeFileSync as writeFileSync33, mkdirSync as mkdirSync32, renameSync as renameSync16 } from "fs";
35294
+ import { existsSync as existsSync40, readFileSync as readFileSync42, writeFileSync as writeFileSync33, mkdirSync as mkdirSync32, renameSync as renameSync17 } from "fs";
37187
35295
  import { dirname as dirname13 } from "path";
37188
35296
  function hashStringArray(items) {
37189
35297
  if (!items || items.length === 0)
@@ -37261,7 +35369,7 @@ function loadSnapshot(path2, now = Date.now) {
37261
35369
  parsed = JSON.parse(raw);
37262
35370
  } catch {
37263
35371
  try {
37264
- renameSync16(path2, `${path2}.corrupt-${now()}`);
35372
+ renameSync17(path2, `${path2}.corrupt-${now()}`);
37265
35373
  } catch {}
37266
35374
  return null;
37267
35375
  }
@@ -37285,7 +35393,7 @@ function persistSnapshot(path2, snapshot) {
37285
35393
  mkdirSync32(dirname13(path2), { recursive: true });
37286
35394
  const tmp = `${path2}.tmp`;
37287
35395
  writeFileSync33(tmp, JSON.stringify(snapshot), { mode: 384 });
37288
- renameSync16(tmp, path2);
35396
+ renameSync17(tmp, path2);
37289
35397
  } catch {}
37290
35398
  }
37291
35399
  var init_config_snapshot = __esm(() => {
@@ -39090,13 +37198,13 @@ import {
39090
37198
  writeFileSync as writeFileSync43,
39091
37199
  mkdirSync as mkdirSync40,
39092
37200
  readdirSync as readdirSync12,
39093
- rmSync as rmSync5,
37201
+ rmSync as rmSync6,
39094
37202
  statSync as statSync16,
39095
- renameSync as renameSync19,
37203
+ renameSync as renameSync20,
39096
37204
  realpathSync as realpathSync4,
39097
37205
  chmodSync as chmodSync12,
39098
- openSync as openSync11,
39099
- closeSync as closeSync11,
37206
+ openSync as openSync12,
37207
+ closeSync as closeSync12,
39100
37208
  existsSync as existsSync50,
39101
37209
  unlinkSync as unlinkSync24,
39102
37210
  appendFileSync as appendFileSync6
@@ -39327,6 +37435,20 @@ function decodeAskCallback(data) {
39327
37435
  return { askId: m[2], idx };
39328
37436
  }
39329
37437
 
37438
+ // outbound-field-redact.ts
37439
+ function redactAskUserFields(question, options, redact) {
37440
+ return {
37441
+ question: redact(question),
37442
+ options: options.map((opt) => redact(opt))
37443
+ };
37444
+ }
37445
+ function redactChecklistFields(title, tasks, redact) {
37446
+ return {
37447
+ title: title != null ? redact(title) : title,
37448
+ tasks: tasks?.map((task) => task.text != null ? { ...task, text: redact(task.text) } : task)
37449
+ };
37450
+ }
37451
+
39330
37452
  // interrupt-marker.ts
39331
37453
  function parseInterruptMarker(text) {
39332
37454
  const trimmed = text.trimStart();
@@ -43085,6 +41207,16 @@ import { mkdirSync as mkdirSync8, writeFileSync as writeFileSync7 } from "fs";
43085
41207
  import { homedir as homedir5 } from "os";
43086
41208
  import { join as join10 } from "path";
43087
41209
 
41210
+ // telegram-button-constraints.ts
41211
+ var TELEGRAM_BUTTON_LIMITS = {
41212
+ TEXT_MAX: 64,
41213
+ URL_MAX: 2048,
41214
+ CALLBACK_DATA_MAX: 64,
41215
+ COPY_TEXT_MAX: 256,
41216
+ LOGIN_URL_MAX: 2048,
41217
+ SWITCH_INLINE_QUERY_MAX: 256
41218
+ };
41219
+
43088
41220
  // inline-keyboard-callbacks.ts
43089
41221
  var AGENT_CALLBACK_PREFIX = "agent:";
43090
41222
  var AGENT_CALLBACK_DATA_MAX = 64 - AGENT_CALLBACK_PREFIX.length;
@@ -45530,6 +43662,12 @@ ${trimmed.replace(/```/g, "`\u200b``")}
45530
43662
  }
45531
43663
  }
45532
43664
  async function handleAuthDashboardCallback(ctx) {
43665
+ const senderId = String(ctx.from?.id ?? "");
43666
+ const access = loadAccess();
43667
+ if (!access.allowFrom.includes(senderId)) {
43668
+ await ctx.answerCallbackQuery({ text: "Not authorized." }).catch(() => {});
43669
+ return;
43670
+ }
45533
43671
  const data = ctx.callbackQuery?.data ?? "";
45534
43672
  const currentAgent = getMyAgentName();
45535
43673
  if (data.startsWith("auth:use:")) {
@@ -49973,7 +48111,7 @@ function initializeContent(effects) {
49973
48111
  var document2 = { tokenize: initializeDocument };
49974
48112
  var containerConstruct = { tokenize: tokenizeContainer };
49975
48113
  function initializeDocument(effects) {
49976
- const self2 = this;
48114
+ const self = this;
49977
48115
  const stack = [];
49978
48116
  let continued = 0;
49979
48117
  let childFlow;
@@ -49983,38 +48121,38 @@ function initializeDocument(effects) {
49983
48121
  function start(code) {
49984
48122
  if (continued < stack.length) {
49985
48123
  const item = stack[continued];
49986
- self2.containerState = item[1];
48124
+ self.containerState = item[1];
49987
48125
  ok(item[0].continuation, "expected `continuation` to be defined on container construct");
49988
48126
  return effects.attempt(item[0].continuation, documentContinue, checkNewContainers)(code);
49989
48127
  }
49990
48128
  return checkNewContainers(code);
49991
48129
  }
49992
48130
  function documentContinue(code) {
49993
- ok(self2.containerState, "expected `containerState` to be defined after continuation");
48131
+ ok(self.containerState, "expected `containerState` to be defined after continuation");
49994
48132
  continued++;
49995
- if (self2.containerState._closeFlow) {
49996
- self2.containerState._closeFlow = undefined;
48133
+ if (self.containerState._closeFlow) {
48134
+ self.containerState._closeFlow = undefined;
49997
48135
  if (childFlow) {
49998
48136
  closeFlow();
49999
48137
  }
50000
- const indexBeforeExits = self2.events.length;
48138
+ const indexBeforeExits = self.events.length;
50001
48139
  let indexBeforeFlow = indexBeforeExits;
50002
48140
  let point;
50003
48141
  while (indexBeforeFlow--) {
50004
- if (self2.events[indexBeforeFlow][0] === "exit" && self2.events[indexBeforeFlow][1].type === types2.chunkFlow) {
50005
- point = self2.events[indexBeforeFlow][1].end;
48142
+ if (self.events[indexBeforeFlow][0] === "exit" && self.events[indexBeforeFlow][1].type === types2.chunkFlow) {
48143
+ point = self.events[indexBeforeFlow][1].end;
50006
48144
  break;
50007
48145
  }
50008
48146
  }
50009
48147
  ok(point, "could not find previous flow chunk");
50010
48148
  exitContainers(continued);
50011
48149
  let index = indexBeforeExits;
50012
- while (index < self2.events.length) {
50013
- self2.events[index][1].end = { ...point };
48150
+ while (index < self.events.length) {
48151
+ self.events[index][1].end = { ...point };
50014
48152
  index++;
50015
48153
  }
50016
- splice(self2.events, indexBeforeFlow + 1, 0, self2.events.slice(indexBeforeExits));
50017
- self2.events.length = index;
48154
+ splice(self.events, indexBeforeFlow + 1, 0, self.events.slice(indexBeforeExits));
48155
+ self.events.length = index;
50018
48156
  return checkNewContainers(code);
50019
48157
  }
50020
48158
  return start(code);
@@ -50027,9 +48165,9 @@ function initializeDocument(effects) {
50027
48165
  if (childFlow.currentConstruct && childFlow.currentConstruct.concrete) {
50028
48166
  return flowStart(code);
50029
48167
  }
50030
- self2.interrupt = Boolean(childFlow.currentConstruct && !childFlow._gfmTableDynamicInterruptHack);
48168
+ self.interrupt = Boolean(childFlow.currentConstruct && !childFlow._gfmTableDynamicInterruptHack);
50031
48169
  }
50032
- self2.containerState = {};
48170
+ self.containerState = {};
50033
48171
  return effects.check(containerConstruct, thereIsANewContainer, thereIsNoNewContainer)(code);
50034
48172
  }
50035
48173
  function thereIsANewContainer(code) {
@@ -50039,19 +48177,19 @@ function initializeDocument(effects) {
50039
48177
  return documentContinued(code);
50040
48178
  }
50041
48179
  function thereIsNoNewContainer(code) {
50042
- self2.parser.lazy[self2.now().line] = continued !== stack.length;
50043
- lineStartOffset = self2.now().offset;
48180
+ self.parser.lazy[self.now().line] = continued !== stack.length;
48181
+ lineStartOffset = self.now().offset;
50044
48182
  return flowStart(code);
50045
48183
  }
50046
48184
  function documentContinued(code) {
50047
- self2.containerState = {};
48185
+ self.containerState = {};
50048
48186
  return effects.attempt(containerConstruct, containerContinue, flowStart)(code);
50049
48187
  }
50050
48188
  function containerContinue(code) {
50051
- ok(self2.currentConstruct, "expected `currentConstruct` to be defined on tokenizer");
50052
- ok(self2.containerState, "expected `containerState` to be defined on tokenizer");
48189
+ ok(self.currentConstruct, "expected `currentConstruct` to be defined on tokenizer");
48190
+ ok(self.containerState, "expected `containerState` to be defined on tokenizer");
50053
48191
  continued++;
50054
- stack.push([self2.currentConstruct, self2.containerState]);
48192
+ stack.push([self.currentConstruct, self.containerState]);
50055
48193
  return documentContinued(code);
50056
48194
  }
50057
48195
  function flowStart(code) {
@@ -50062,7 +48200,7 @@ function initializeDocument(effects) {
50062
48200
  effects.consume(code);
50063
48201
  return;
50064
48202
  }
50065
- childFlow = childFlow || self2.parser.flow(self2.now());
48203
+ childFlow = childFlow || self.parser.flow(self.now());
50066
48204
  effects.enter(types2.chunkFlow, {
50067
48205
  _tokenizer: childFlow,
50068
48206
  contentType: constants.contentTypeFlow,
@@ -50081,7 +48219,7 @@ function initializeDocument(effects) {
50081
48219
  effects.consume(code);
50082
48220
  writeToChild(effects.exit(types2.chunkFlow));
50083
48221
  continued = 0;
50084
- self2.interrupt = undefined;
48222
+ self.interrupt = undefined;
50085
48223
  return start;
50086
48224
  }
50087
48225
  effects.consume(code);
@@ -50089,7 +48227,7 @@ function initializeDocument(effects) {
50089
48227
  }
50090
48228
  function writeToChild(token, endOfFile) {
50091
48229
  ok(childFlow, "expected `childFlow` to be defined when continuing");
50092
- const stream = self2.sliceStream(token);
48230
+ const stream = self.sliceStream(token);
50093
48231
  if (endOfFile)
50094
48232
  stream.push(null);
50095
48233
  token.previous = childToken;
@@ -50098,21 +48236,21 @@ function initializeDocument(effects) {
50098
48236
  childToken = token;
50099
48237
  childFlow.defineSkip(token.start);
50100
48238
  childFlow.write(stream);
50101
- if (self2.parser.lazy[token.start.line]) {
48239
+ if (self.parser.lazy[token.start.line]) {
50102
48240
  let index = childFlow.events.length;
50103
48241
  while (index--) {
50104
48242
  if (childFlow.events[index][1].start.offset < lineStartOffset && (!childFlow.events[index][1].end || childFlow.events[index][1].end.offset > lineStartOffset)) {
50105
48243
  return;
50106
48244
  }
50107
48245
  }
50108
- const indexBeforeExits = self2.events.length;
48246
+ const indexBeforeExits = self.events.length;
50109
48247
  let indexBeforeFlow = indexBeforeExits;
50110
48248
  let seen;
50111
48249
  let point;
50112
48250
  while (indexBeforeFlow--) {
50113
- if (self2.events[indexBeforeFlow][0] === "exit" && self2.events[indexBeforeFlow][1].type === types2.chunkFlow) {
48251
+ if (self.events[indexBeforeFlow][0] === "exit" && self.events[indexBeforeFlow][1].type === types2.chunkFlow) {
50114
48252
  if (seen) {
50115
- point = self2.events[indexBeforeFlow][1].end;
48253
+ point = self.events[indexBeforeFlow][1].end;
50116
48254
  break;
50117
48255
  }
50118
48256
  seen = true;
@@ -50121,31 +48259,31 @@ function initializeDocument(effects) {
50121
48259
  ok(point, "could not find previous flow chunk");
50122
48260
  exitContainers(continued);
50123
48261
  index = indexBeforeExits;
50124
- while (index < self2.events.length) {
50125
- self2.events[index][1].end = { ...point };
48262
+ while (index < self.events.length) {
48263
+ self.events[index][1].end = { ...point };
50126
48264
  index++;
50127
48265
  }
50128
- splice(self2.events, indexBeforeFlow + 1, 0, self2.events.slice(indexBeforeExits));
50129
- self2.events.length = index;
48266
+ splice(self.events, indexBeforeFlow + 1, 0, self.events.slice(indexBeforeExits));
48267
+ self.events.length = index;
50130
48268
  }
50131
48269
  }
50132
48270
  function exitContainers(size) {
50133
48271
  let index = stack.length;
50134
48272
  while (index-- > size) {
50135
48273
  const entry = stack[index];
50136
- self2.containerState = entry[1];
48274
+ self.containerState = entry[1];
50137
48275
  ok(entry[0].exit, "expected `exit` to be defined on container construct");
50138
- entry[0].exit.call(self2, effects);
48276
+ entry[0].exit.call(self, effects);
50139
48277
  }
50140
48278
  stack.length = size;
50141
48279
  }
50142
48280
  function closeFlow() {
50143
- ok(self2.containerState, "expected `containerState` to be defined when closing flow");
48281
+ ok(self.containerState, "expected `containerState` to be defined when closing flow");
50144
48282
  ok(childFlow, "expected `childFlow` to be defined when closing it");
50145
48283
  childFlow.write([codes.eof]);
50146
48284
  childToken = undefined;
50147
48285
  childFlow = undefined;
50148
- self2.containerState._closeFlow = undefined;
48286
+ self.containerState._closeFlow = undefined;
50149
48287
  }
50150
48288
  }
50151
48289
  function tokenizeContainer(effects, ok2, nok) {
@@ -50422,11 +48560,11 @@ var blockQuote = {
50422
48560
  tokenize: tokenizeBlockQuoteStart
50423
48561
  };
50424
48562
  function tokenizeBlockQuoteStart(effects, ok2, nok) {
50425
- const self2 = this;
48563
+ const self = this;
50426
48564
  return start;
50427
48565
  function start(code) {
50428
48566
  if (code === codes.greaterThan) {
50429
- const state = self2.containerState;
48567
+ const state = self.containerState;
50430
48568
  ok(state, "expected `containerState` to be defined in container");
50431
48569
  if (!state.open) {
50432
48570
  effects.enter(types2.blockQuote, { _container: true });
@@ -50453,12 +48591,12 @@ function tokenizeBlockQuoteStart(effects, ok2, nok) {
50453
48591
  }
50454
48592
  }
50455
48593
  function tokenizeBlockQuoteContinuation(effects, ok2, nok) {
50456
- const self2 = this;
48594
+ const self = this;
50457
48595
  return contStart;
50458
48596
  function contStart(code) {
50459
48597
  if (markdownSpace(code)) {
50460
- ok(self2.parser.constructs.disable.null, "expected `disable.null` to be populated");
50461
- return factorySpace(effects, contBefore, types2.linePrefix, self2.parser.constructs.disable.null.includes("codeIndented") ? undefined : constants.tabSize)(code);
48598
+ ok(self.parser.constructs.disable.null, "expected `disable.null` to be populated");
48599
+ return factorySpace(effects, contBefore, types2.linePrefix, self.parser.constructs.disable.null.includes("codeIndented") ? undefined : constants.tabSize)(code);
50462
48600
  }
50463
48601
  return contBefore(code);
50464
48602
  }
@@ -50501,7 +48639,7 @@ var characterReference = {
50501
48639
  tokenize: tokenizeCharacterReference
50502
48640
  };
50503
48641
  function tokenizeCharacterReference(effects, ok2, nok) {
50504
- const self2 = this;
48642
+ const self = this;
50505
48643
  let size = 0;
50506
48644
  let max;
50507
48645
  let test;
@@ -50544,7 +48682,7 @@ function tokenizeCharacterReference(effects, ok2, nok) {
50544
48682
  function value(code) {
50545
48683
  if (code === codes.semicolon && size) {
50546
48684
  const token = effects.exit(types2.characterReferenceValue);
50547
- if (test === asciiAlphanumeric && !decodeNamedCharacterReference(self2.sliceSerialize(token))) {
48685
+ if (test === asciiAlphanumeric && !decodeNamedCharacterReference(self.sliceSerialize(token))) {
50548
48686
  return nok(code);
50549
48687
  }
50550
48688
  effects.enter(types2.characterReferenceMarker);
@@ -50571,7 +48709,7 @@ var codeFenced = {
50571
48709
  tokenize: tokenizeCodeFenced
50572
48710
  };
50573
48711
  function tokenizeCodeFenced(effects, ok2, nok) {
50574
- const self2 = this;
48712
+ const self = this;
50575
48713
  const closeStart = { partial: true, tokenize: tokenizeCloseStart };
50576
48714
  let initialPrefix = 0;
50577
48715
  let sizeOpen = 0;
@@ -50582,7 +48720,7 @@ function tokenizeCodeFenced(effects, ok2, nok) {
50582
48720
  }
50583
48721
  function beforeSequenceOpen(code) {
50584
48722
  ok(code === codes.graveAccent || code === codes.tilde, "expected `` ` `` or `~`");
50585
- const tail = self2.events[self2.events.length - 1];
48723
+ const tail = self.events[self.events.length - 1];
50586
48724
  initialPrefix = tail && tail[1].type === types2.linePrefix ? tail[2].sliceSerialize(tail[1], true).length : 0;
50587
48725
  marker = code;
50588
48726
  effects.enter(types2.codeFenced);
@@ -50605,7 +48743,7 @@ function tokenizeCodeFenced(effects, ok2, nok) {
50605
48743
  function infoBefore(code) {
50606
48744
  if (code === codes.eof || markdownLineEnding(code)) {
50607
48745
  effects.exit(types2.codeFencedFence);
50608
- return self2.interrupt ? ok2(code) : effects.check(nonLazyContinuation, atNonLazyBreak, after)(code);
48746
+ return self.interrupt ? ok2(code) : effects.check(nonLazyContinuation, atNonLazyBreak, after)(code);
50609
48747
  }
50610
48748
  effects.enter(types2.codeFencedFenceInfo);
50611
48749
  effects.enter(types2.chunkString, { contentType: constants.contentTypeString });
@@ -50692,9 +48830,9 @@ function tokenizeCodeFenced(effects, ok2, nok) {
50692
48830
  return start2;
50693
48831
  }
50694
48832
  function start2(code) {
50695
- ok(self2.parser.constructs.disable.null, "expected `disable.null` to be populated");
48833
+ ok(self.parser.constructs.disable.null, "expected `disable.null` to be populated");
50696
48834
  effects2.enter(types2.codeFencedFence);
50697
- return markdownSpace(code) ? factorySpace(effects2, beforeSequenceClose, types2.linePrefix, self2.parser.constructs.disable.null.includes("codeIndented") ? undefined : constants.tabSize)(code) : beforeSequenceClose(code);
48835
+ return markdownSpace(code) ? factorySpace(effects2, beforeSequenceClose, types2.linePrefix, self.parser.constructs.disable.null.includes("codeIndented") ? undefined : constants.tabSize)(code) : beforeSequenceClose(code);
50698
48836
  }
50699
48837
  function beforeSequenceClose(code) {
50700
48838
  if (code === marker) {
@@ -50725,7 +48863,7 @@ function tokenizeCodeFenced(effects, ok2, nok) {
50725
48863
  }
50726
48864
  }
50727
48865
  function tokenizeNonLazyContinuation(effects, ok2, nok) {
50728
- const self2 = this;
48866
+ const self = this;
50729
48867
  return start;
50730
48868
  function start(code) {
50731
48869
  if (code === codes.eof) {
@@ -50738,7 +48876,7 @@ function tokenizeNonLazyContinuation(effects, ok2, nok) {
50738
48876
  return lineStart;
50739
48877
  }
50740
48878
  function lineStart(code) {
50741
- return self2.parser.lazy[self2.now().line] ? nok(code) : ok2(code);
48879
+ return self.parser.lazy[self.now().line] ? nok(code) : ok2(code);
50742
48880
  }
50743
48881
  }
50744
48882
  // ../node_modules/.bun/micromark-core-commonmark@2.0.3/node_modules/micromark-core-commonmark/dev/lib/code-indented.js
@@ -50748,7 +48886,7 @@ var codeIndented = {
50748
48886
  };
50749
48887
  var furtherStart = { partial: true, tokenize: tokenizeFurtherStart };
50750
48888
  function tokenizeCodeIndented(effects, ok2, nok) {
50751
- const self2 = this;
48889
+ const self = this;
50752
48890
  return start;
50753
48891
  function start(code) {
50754
48892
  ok(markdownSpace(code));
@@ -50756,7 +48894,7 @@ function tokenizeCodeIndented(effects, ok2, nok) {
50756
48894
  return factorySpace(effects, afterPrefix, types2.linePrefix, constants.tabSize + 1)(code);
50757
48895
  }
50758
48896
  function afterPrefix(code) {
50759
- const tail = self2.events[self2.events.length - 1];
48897
+ const tail = self.events[self.events.length - 1];
50760
48898
  return tail && tail[1].type === types2.linePrefix && tail[2].sliceSerialize(tail[1], true).length >= constants.tabSize ? atBreak(code) : nok(code);
50761
48899
  }
50762
48900
  function atBreak(code) {
@@ -50783,10 +48921,10 @@ function tokenizeCodeIndented(effects, ok2, nok) {
50783
48921
  }
50784
48922
  }
50785
48923
  function tokenizeFurtherStart(effects, ok2, nok) {
50786
- const self2 = this;
48924
+ const self = this;
50787
48925
  return furtherStart2;
50788
48926
  function furtherStart2(code) {
50789
- if (self2.parser.lazy[self2.now().line]) {
48927
+ if (self.parser.lazy[self.now().line]) {
50790
48928
  return nok(code);
50791
48929
  }
50792
48930
  if (markdownLineEnding(code)) {
@@ -50798,7 +48936,7 @@ function tokenizeFurtherStart(effects, ok2, nok) {
50798
48936
  return factorySpace(effects, afterPrefix, types2.linePrefix, constants.tabSize + 1)(code);
50799
48937
  }
50800
48938
  function afterPrefix(code) {
50801
- const tail = self2.events[self2.events.length - 1];
48939
+ const tail = self.events[self.events.length - 1];
50802
48940
  return tail && tail[1].type === types2.linePrefix && tail[2].sliceSerialize(tail[1], true).length >= constants.tabSize ? ok2(code) : markdownLineEnding(code) ? furtherStart2(code) : nok(code);
50803
48941
  }
50804
48942
  }
@@ -50850,14 +48988,14 @@ function previous(code) {
50850
48988
  return code !== codes.graveAccent || this.events[this.events.length - 1][1].type === types2.characterEscape;
50851
48989
  }
50852
48990
  function tokenizeCodeText(effects, ok2, nok) {
50853
- const self2 = this;
48991
+ const self = this;
50854
48992
  let sizeOpen = 0;
50855
48993
  let size;
50856
48994
  let token;
50857
48995
  return start;
50858
48996
  function start(code) {
50859
48997
  ok(code === codes.graveAccent, "expected `` ` ``");
50860
- ok(previous.call(self2, self2.previous), "expected correct previous");
48998
+ ok(previous.call(self, self.previous), "expected correct previous");
50861
48999
  effects.enter(types2.codeText);
50862
49000
  effects.enter(types2.codeTextSequence);
50863
49001
  return sequenceOpen(code);
@@ -51201,7 +49339,7 @@ function tokenizeContent(effects, ok2) {
51201
49339
  }
51202
49340
  }
51203
49341
  function tokenizeContinuation(effects, ok2, nok) {
51204
- const self2 = this;
49342
+ const self = this;
51205
49343
  return startLookahead;
51206
49344
  function startLookahead(code) {
51207
49345
  ok(markdownLineEnding(code), "expected a line ending");
@@ -51215,12 +49353,12 @@ function tokenizeContinuation(effects, ok2, nok) {
51215
49353
  if (code === codes.eof || markdownLineEnding(code)) {
51216
49354
  return nok(code);
51217
49355
  }
51218
- ok(self2.parser.constructs.disable.null, "expected `disable.null` to be populated");
51219
- const tail = self2.events[self2.events.length - 1];
51220
- if (!self2.parser.constructs.disable.null.includes("codeIndented") && tail && tail[1].type === types2.linePrefix && tail[2].sliceSerialize(tail[1], true).length >= constants.tabSize) {
49356
+ ok(self.parser.constructs.disable.null, "expected `disable.null` to be populated");
49357
+ const tail = self.events[self.events.length - 1];
49358
+ if (!self.parser.constructs.disable.null.includes("codeIndented") && tail && tail[1].type === types2.linePrefix && tail[2].sliceSerialize(tail[1], true).length >= constants.tabSize) {
51221
49359
  return ok2(code);
51222
49360
  }
51223
- return effects.interrupt(self2.parser.constructs.flow, nok, ok2)(code);
49361
+ return effects.interrupt(self.parser.constructs.flow, nok, ok2)(code);
51224
49362
  }
51225
49363
  }
51226
49364
  // ../node_modules/.bun/micromark-factory-destination@2.0.1/node_modules/micromark-factory-destination/dev/index.js
@@ -51313,7 +49451,7 @@ function factoryDestination(effects, ok2, nok, type, literalType2, literalMarker
51313
49451
 
51314
49452
  // ../node_modules/.bun/micromark-factory-label@2.0.1/node_modules/micromark-factory-label/dev/index.js
51315
49453
  function factoryLabel(effects, ok2, nok, type, markerType, stringType2) {
51316
- const self2 = this;
49454
+ const self = this;
51317
49455
  let size = 0;
51318
49456
  let seen;
51319
49457
  return start;
@@ -51327,7 +49465,7 @@ function factoryLabel(effects, ok2, nok, type, markerType, stringType2) {
51327
49465
  return atBreak;
51328
49466
  }
51329
49467
  function atBreak(code) {
51330
- if (size > constants.linkReferenceSizeMax || code === codes.eof || code === codes.leftSquareBracket || code === codes.rightSquareBracket && !seen || code === codes.caret && !size && "_hiddenFootnoteSupport" in self2.parser.constructs) {
49468
+ if (size > constants.linkReferenceSizeMax || code === codes.eof || code === codes.leftSquareBracket || code === codes.rightSquareBracket && !seen || code === codes.caret && !size && "_hiddenFootnoteSupport" in self.parser.constructs) {
51331
49469
  return nok(code);
51332
49470
  }
51333
49471
  if (code === codes.rightSquareBracket) {
@@ -51450,7 +49588,7 @@ function factoryWhitespace(effects, ok2) {
51450
49588
  var definition = { name: "definition", tokenize: tokenizeDefinition };
51451
49589
  var titleBefore = { partial: true, tokenize: tokenizeTitleBefore };
51452
49590
  function tokenizeDefinition(effects, ok2, nok) {
51453
- const self2 = this;
49591
+ const self = this;
51454
49592
  let identifier;
51455
49593
  return start;
51456
49594
  function start(code) {
@@ -51459,10 +49597,10 @@ function tokenizeDefinition(effects, ok2, nok) {
51459
49597
  }
51460
49598
  function before(code) {
51461
49599
  ok(code === codes.leftSquareBracket, "expected `[`");
51462
- return factoryLabel.call(self2, effects, labelAfter, nok, types2.definitionLabel, types2.definitionLabelMarker, types2.definitionLabelString)(code);
49600
+ return factoryLabel.call(self, effects, labelAfter, nok, types2.definitionLabel, types2.definitionLabelMarker, types2.definitionLabelString)(code);
51463
49601
  }
51464
49602
  function labelAfter(code) {
51465
- identifier = normalizeIdentifier(self2.sliceSerialize(self2.events[self2.events.length - 1][1]).slice(1, -1));
49603
+ identifier = normalizeIdentifier(self.sliceSerialize(self.events[self.events.length - 1][1]).slice(1, -1));
51466
49604
  if (code === codes.colon) {
51467
49605
  effects.enter(types2.definitionMarker);
51468
49606
  effects.consume(code);
@@ -51486,7 +49624,7 @@ function tokenizeDefinition(effects, ok2, nok) {
51486
49624
  function afterWhitespace(code) {
51487
49625
  if (code === codes.eof || markdownLineEnding(code)) {
51488
49626
  effects.exit(types2.definition);
51489
- self2.parser.defined.push(identifier);
49627
+ self.parser.defined.push(identifier);
51490
49628
  return ok2(code);
51491
49629
  }
51492
49630
  return nok(code);
@@ -51718,7 +49856,7 @@ function resolveToHtmlFlow(events) {
51718
49856
  return events;
51719
49857
  }
51720
49858
  function tokenizeHtmlFlow(effects, ok2, nok) {
51721
- const self2 = this;
49859
+ const self = this;
51722
49860
  let marker;
51723
49861
  let closingTag;
51724
49862
  let buffer;
@@ -51748,7 +49886,7 @@ function tokenizeHtmlFlow(effects, ok2, nok) {
51748
49886
  if (code === codes.questionMark) {
51749
49887
  effects.consume(code);
51750
49888
  marker = constants.htmlInstruction;
51751
- return self2.interrupt ? ok2 : continuationDeclarationInside;
49889
+ return self.interrupt ? ok2 : continuationDeclarationInside;
51752
49890
  }
51753
49891
  if (asciiAlpha(code)) {
51754
49892
  ok(code !== null);
@@ -51773,14 +49911,14 @@ function tokenizeHtmlFlow(effects, ok2, nok) {
51773
49911
  if (asciiAlpha(code)) {
51774
49912
  effects.consume(code);
51775
49913
  marker = constants.htmlDeclaration;
51776
- return self2.interrupt ? ok2 : continuationDeclarationInside;
49914
+ return self.interrupt ? ok2 : continuationDeclarationInside;
51777
49915
  }
51778
49916
  return nok(code);
51779
49917
  }
51780
49918
  function commentOpenInside(code) {
51781
49919
  if (code === codes.dash) {
51782
49920
  effects.consume(code);
51783
- return self2.interrupt ? ok2 : continuationDeclarationInside;
49921
+ return self.interrupt ? ok2 : continuationDeclarationInside;
51784
49922
  }
51785
49923
  return nok(code);
51786
49924
  }
@@ -51789,7 +49927,7 @@ function tokenizeHtmlFlow(effects, ok2, nok) {
51789
49927
  if (code === value.charCodeAt(index++)) {
51790
49928
  effects.consume(code);
51791
49929
  if (index === value.length) {
51792
- return self2.interrupt ? ok2 : continuation;
49930
+ return self.interrupt ? ok2 : continuation;
51793
49931
  }
51794
49932
  return cdataOpenInside;
51795
49933
  }
@@ -51810,7 +49948,7 @@ function tokenizeHtmlFlow(effects, ok2, nok) {
51810
49948
  const name = buffer.toLowerCase();
51811
49949
  if (!slash && !closingTag && htmlRawNames.includes(name)) {
51812
49950
  marker = constants.htmlRaw;
51813
- return self2.interrupt ? ok2(code) : continuation(code);
49951
+ return self.interrupt ? ok2(code) : continuation(code);
51814
49952
  }
51815
49953
  if (htmlBlockNames.includes(buffer.toLowerCase())) {
51816
49954
  marker = constants.htmlBasic;
@@ -51818,10 +49956,10 @@ function tokenizeHtmlFlow(effects, ok2, nok) {
51818
49956
  effects.consume(code);
51819
49957
  return basicSelfClosing;
51820
49958
  }
51821
- return self2.interrupt ? ok2(code) : continuation(code);
49959
+ return self.interrupt ? ok2(code) : continuation(code);
51822
49960
  }
51823
49961
  marker = constants.htmlComplete;
51824
- return self2.interrupt && !self2.parser.lazy[self2.now().line] ? nok(code) : closingTag ? completeClosingTagAfter(code) : completeAttributeNameBefore(code);
49962
+ return self.interrupt && !self.parser.lazy[self.now().line] ? nok(code) : closingTag ? completeClosingTagAfter(code) : completeAttributeNameBefore(code);
51825
49963
  }
51826
49964
  if (code === codes.dash || asciiAlphanumeric(code)) {
51827
49965
  effects.consume(code);
@@ -51833,7 +49971,7 @@ function tokenizeHtmlFlow(effects, ok2, nok) {
51833
49971
  function basicSelfClosing(code) {
51834
49972
  if (code === codes.greaterThan) {
51835
49973
  effects.consume(code);
51836
- return self2.interrupt ? ok2 : continuation;
49974
+ return self.interrupt ? ok2 : continuation;
51837
49975
  }
51838
49976
  return nok(code);
51839
49977
  }
@@ -52047,7 +50185,7 @@ function tokenizeHtmlFlow(effects, ok2, nok) {
52047
50185
  }
52048
50186
  }
52049
50187
  function tokenizeNonLazyContinuationStart(effects, ok2, nok) {
52050
- const self2 = this;
50188
+ const self = this;
52051
50189
  return start;
52052
50190
  function start(code) {
52053
50191
  if (markdownLineEnding(code)) {
@@ -52059,7 +50197,7 @@ function tokenizeNonLazyContinuationStart(effects, ok2, nok) {
52059
50197
  return nok(code);
52060
50198
  }
52061
50199
  function after(code) {
52062
- return self2.parser.lazy[self2.now().line] ? nok(code) : ok2(code);
50200
+ return self.parser.lazy[self.now().line] ? nok(code) : ok2(code);
52063
50201
  }
52064
50202
  }
52065
50203
  function tokenizeBlankLineBefore(effects, ok2, nok) {
@@ -52075,7 +50213,7 @@ function tokenizeBlankLineBefore(effects, ok2, nok) {
52075
50213
  // ../node_modules/.bun/micromark-core-commonmark@2.0.3/node_modules/micromark-core-commonmark/dev/lib/html-text.js
52076
50214
  var htmlText = { name: "htmlText", tokenize: tokenizeHtmlText };
52077
50215
  function tokenizeHtmlText(effects, ok2, nok) {
52078
- const self2 = this;
50216
+ const self = this;
52079
50217
  let marker;
52080
50218
  let index;
52081
50219
  let returnState;
@@ -52370,8 +50508,8 @@ function tokenizeHtmlText(effects, ok2, nok) {
52370
50508
  return lineEndingAfter;
52371
50509
  }
52372
50510
  function lineEndingAfter(code) {
52373
- ok(self2.parser.constructs.disable.null, "expected `disable.null` to be populated");
52374
- return markdownSpace(code) ? factorySpace(effects, lineEndingAfterPrefix, types2.linePrefix, self2.parser.constructs.disable.null.includes("codeIndented") ? undefined : constants.tabSize)(code) : lineEndingAfterPrefix(code);
50511
+ ok(self.parser.constructs.disable.null, "expected `disable.null` to be populated");
50512
+ return markdownSpace(code) ? factorySpace(effects, lineEndingAfterPrefix, types2.linePrefix, self.parser.constructs.disable.null.includes("codeIndented") ? undefined : constants.tabSize)(code) : lineEndingAfterPrefix(code);
52375
50513
  }
52376
50514
  function lineEndingAfterPrefix(code) {
52377
50515
  effects.enter(types2.htmlTextData);
@@ -52470,13 +50608,13 @@ function resolveToLabelEnd(events, context) {
52470
50608
  return events;
52471
50609
  }
52472
50610
  function tokenizeLabelEnd(effects, ok2, nok) {
52473
- const self2 = this;
52474
- let index = self2.events.length;
50611
+ const self = this;
50612
+ let index = self.events.length;
52475
50613
  let labelStart;
52476
50614
  let defined;
52477
50615
  while (index--) {
52478
- if ((self2.events[index][1].type === types2.labelImage || self2.events[index][1].type === types2.labelLink) && !self2.events[index][1]._balanced) {
52479
- labelStart = self2.events[index][1];
50616
+ if ((self.events[index][1].type === types2.labelImage || self.events[index][1].type === types2.labelLink) && !self.events[index][1]._balanced) {
50617
+ labelStart = self.events[index][1];
52480
50618
  break;
52481
50619
  }
52482
50620
  }
@@ -52489,7 +50627,7 @@ function tokenizeLabelEnd(effects, ok2, nok) {
52489
50627
  if (labelStart._inactive) {
52490
50628
  return labelEndNok(code);
52491
50629
  }
52492
- defined = self2.parser.defined.includes(normalizeIdentifier(self2.sliceSerialize({ start: labelStart.end, end: self2.now() })));
50630
+ defined = self.parser.defined.includes(normalizeIdentifier(self.sliceSerialize({ start: labelStart.end, end: self.now() })));
52493
50631
  effects.enter(types2.labelEnd);
52494
50632
  effects.enter(types2.labelMarker);
52495
50633
  effects.consume(code);
@@ -52563,14 +50701,14 @@ function tokenizeResource(effects, ok2, nok) {
52563
50701
  }
52564
50702
  }
52565
50703
  function tokenizeReferenceFull(effects, ok2, nok) {
52566
- const self2 = this;
50704
+ const self = this;
52567
50705
  return referenceFull;
52568
50706
  function referenceFull(code) {
52569
50707
  ok(code === codes.leftSquareBracket, "expected left bracket");
52570
- return factoryLabel.call(self2, effects, referenceFullAfter, referenceFullMissing, types2.reference, types2.referenceMarker, types2.referenceString)(code);
50708
+ return factoryLabel.call(self, effects, referenceFullAfter, referenceFullMissing, types2.reference, types2.referenceMarker, types2.referenceString)(code);
52571
50709
  }
52572
50710
  function referenceFullAfter(code) {
52573
- return self2.parser.defined.includes(normalizeIdentifier(self2.sliceSerialize(self2.events[self2.events.length - 1][1]).slice(1, -1))) ? ok2(code) : nok(code);
50711
+ return self.parser.defined.includes(normalizeIdentifier(self.sliceSerialize(self.events[self.events.length - 1][1]).slice(1, -1))) ? ok2(code) : nok(code);
52574
50712
  }
52575
50713
  function referenceFullMissing(code) {
52576
50714
  return nok(code);
@@ -52604,7 +50742,7 @@ var labelStartImage = {
52604
50742
  tokenize: tokenizeLabelStartImage
52605
50743
  };
52606
50744
  function tokenizeLabelStartImage(effects, ok2, nok) {
52607
- const self2 = this;
50745
+ const self = this;
52608
50746
  return start;
52609
50747
  function start(code) {
52610
50748
  ok(code === codes.exclamationMark, "expected `!`");
@@ -52625,7 +50763,7 @@ function tokenizeLabelStartImage(effects, ok2, nok) {
52625
50763
  return nok(code);
52626
50764
  }
52627
50765
  function after(code) {
52628
- return code === codes.caret && "_hiddenFootnoteSupport" in self2.parser.constructs ? nok(code) : ok2(code);
50766
+ return code === codes.caret && "_hiddenFootnoteSupport" in self.parser.constructs ? nok(code) : ok2(code);
52629
50767
  }
52630
50768
  }
52631
50769
  // ../node_modules/.bun/micromark-core-commonmark@2.0.3/node_modules/micromark-core-commonmark/dev/lib/label-start-link.js
@@ -52635,7 +50773,7 @@ var labelStartLink = {
52635
50773
  tokenize: tokenizeLabelStartLink
52636
50774
  };
52637
50775
  function tokenizeLabelStartLink(effects, ok2, nok) {
52638
- const self2 = this;
50776
+ const self = this;
52639
50777
  return start;
52640
50778
  function start(code) {
52641
50779
  ok(code === codes.leftSquareBracket, "expected `[`");
@@ -52647,7 +50785,7 @@ function tokenizeLabelStartLink(effects, ok2, nok) {
52647
50785
  return after;
52648
50786
  }
52649
50787
  function after(code) {
52650
- return code === codes.caret && "_hiddenFootnoteSupport" in self2.parser.constructs ? nok(code) : ok2(code);
50788
+ return code === codes.caret && "_hiddenFootnoteSupport" in self.parser.constructs ? nok(code) : ok2(code);
52651
50789
  }
52652
50790
  }
52653
50791
  // ../node_modules/.bun/micromark-core-commonmark@2.0.3/node_modules/micromark-core-commonmark/dev/lib/line-ending.js
@@ -52715,24 +50853,24 @@ var listItemPrefixWhitespaceConstruct = {
52715
50853
  };
52716
50854
  var indentConstruct = { partial: true, tokenize: tokenizeIndent };
52717
50855
  function tokenizeListStart(effects, ok2, nok) {
52718
- const self2 = this;
52719
- const tail = self2.events[self2.events.length - 1];
50856
+ const self = this;
50857
+ const tail = self.events[self.events.length - 1];
52720
50858
  let initialSize = tail && tail[1].type === types2.linePrefix ? tail[2].sliceSerialize(tail[1], true).length : 0;
52721
50859
  let size = 0;
52722
50860
  return start;
52723
50861
  function start(code) {
52724
- ok(self2.containerState, "expected state");
52725
- const kind = self2.containerState.type || (code === codes.asterisk || code === codes.plusSign || code === codes.dash ? types2.listUnordered : types2.listOrdered);
52726
- if (kind === types2.listUnordered ? !self2.containerState.marker || code === self2.containerState.marker : asciiDigit(code)) {
52727
- if (!self2.containerState.type) {
52728
- self2.containerState.type = kind;
50862
+ ok(self.containerState, "expected state");
50863
+ const kind = self.containerState.type || (code === codes.asterisk || code === codes.plusSign || code === codes.dash ? types2.listUnordered : types2.listOrdered);
50864
+ if (kind === types2.listUnordered ? !self.containerState.marker || code === self.containerState.marker : asciiDigit(code)) {
50865
+ if (!self.containerState.type) {
50866
+ self.containerState.type = kind;
52729
50867
  effects.enter(kind, { _container: true });
52730
50868
  }
52731
50869
  if (kind === types2.listUnordered) {
52732
50870
  effects.enter(types2.listItemPrefix);
52733
50871
  return code === codes.asterisk || code === codes.dash ? effects.check(thematicBreak, nok, atMarker)(code) : atMarker(code);
52734
50872
  }
52735
- if (!self2.interrupt || code === codes.digit1) {
50873
+ if (!self.interrupt || code === codes.digit1) {
52736
50874
  effects.enter(types2.listItemPrefix);
52737
50875
  effects.enter(types2.listItemValue);
52738
50876
  return inside(code);
@@ -52741,29 +50879,29 @@ function tokenizeListStart(effects, ok2, nok) {
52741
50879
  return nok(code);
52742
50880
  }
52743
50881
  function inside(code) {
52744
- ok(self2.containerState, "expected state");
50882
+ ok(self.containerState, "expected state");
52745
50883
  if (asciiDigit(code) && ++size < constants.listItemValueSizeMax) {
52746
50884
  effects.consume(code);
52747
50885
  return inside;
52748
50886
  }
52749
- if ((!self2.interrupt || size < 2) && (self2.containerState.marker ? code === self2.containerState.marker : code === codes.rightParenthesis || code === codes.dot)) {
50887
+ if ((!self.interrupt || size < 2) && (self.containerState.marker ? code === self.containerState.marker : code === codes.rightParenthesis || code === codes.dot)) {
52750
50888
  effects.exit(types2.listItemValue);
52751
50889
  return atMarker(code);
52752
50890
  }
52753
50891
  return nok(code);
52754
50892
  }
52755
50893
  function atMarker(code) {
52756
- ok(self2.containerState, "expected state");
50894
+ ok(self.containerState, "expected state");
52757
50895
  ok(code !== codes.eof, "eof (`null`) is not a marker");
52758
50896
  effects.enter(types2.listItemMarker);
52759
50897
  effects.consume(code);
52760
50898
  effects.exit(types2.listItemMarker);
52761
- self2.containerState.marker = self2.containerState.marker || code;
52762
- return effects.check(blankLine, self2.interrupt ? nok : onBlank, effects.attempt(listItemPrefixWhitespaceConstruct, endOfPrefix, otherPrefix));
50899
+ self.containerState.marker = self.containerState.marker || code;
50900
+ return effects.check(blankLine, self.interrupt ? nok : onBlank, effects.attempt(listItemPrefixWhitespaceConstruct, endOfPrefix, otherPrefix));
52763
50901
  }
52764
50902
  function onBlank(code) {
52765
- ok(self2.containerState, "expected state");
52766
- self2.containerState.initialBlankLine = true;
50903
+ ok(self.containerState, "expected state");
50904
+ self.containerState.initialBlankLine = true;
52767
50905
  initialSize++;
52768
50906
  return endOfPrefix(code);
52769
50907
  }
@@ -52777,50 +50915,50 @@ function tokenizeListStart(effects, ok2, nok) {
52777
50915
  return nok(code);
52778
50916
  }
52779
50917
  function endOfPrefix(code) {
52780
- ok(self2.containerState, "expected state");
52781
- self2.containerState.size = initialSize + self2.sliceSerialize(effects.exit(types2.listItemPrefix), true).length;
50918
+ ok(self.containerState, "expected state");
50919
+ self.containerState.size = initialSize + self.sliceSerialize(effects.exit(types2.listItemPrefix), true).length;
52782
50920
  return ok2(code);
52783
50921
  }
52784
50922
  }
52785
50923
  function tokenizeListContinuation(effects, ok2, nok) {
52786
- const self2 = this;
52787
- ok(self2.containerState, "expected state");
52788
- self2.containerState._closeFlow = undefined;
50924
+ const self = this;
50925
+ ok(self.containerState, "expected state");
50926
+ self.containerState._closeFlow = undefined;
52789
50927
  return effects.check(blankLine, onBlank, notBlank);
52790
50928
  function onBlank(code) {
52791
- ok(self2.containerState, "expected state");
52792
- ok(typeof self2.containerState.size === "number", "expected size");
52793
- self2.containerState.furtherBlankLines = self2.containerState.furtherBlankLines || self2.containerState.initialBlankLine;
52794
- return factorySpace(effects, ok2, types2.listItemIndent, self2.containerState.size + 1)(code);
50929
+ ok(self.containerState, "expected state");
50930
+ ok(typeof self.containerState.size === "number", "expected size");
50931
+ self.containerState.furtherBlankLines = self.containerState.furtherBlankLines || self.containerState.initialBlankLine;
50932
+ return factorySpace(effects, ok2, types2.listItemIndent, self.containerState.size + 1)(code);
52795
50933
  }
52796
50934
  function notBlank(code) {
52797
- ok(self2.containerState, "expected state");
52798
- if (self2.containerState.furtherBlankLines || !markdownSpace(code)) {
52799
- self2.containerState.furtherBlankLines = undefined;
52800
- self2.containerState.initialBlankLine = undefined;
50935
+ ok(self.containerState, "expected state");
50936
+ if (self.containerState.furtherBlankLines || !markdownSpace(code)) {
50937
+ self.containerState.furtherBlankLines = undefined;
50938
+ self.containerState.initialBlankLine = undefined;
52801
50939
  return notInCurrentItem(code);
52802
50940
  }
52803
- self2.containerState.furtherBlankLines = undefined;
52804
- self2.containerState.initialBlankLine = undefined;
50941
+ self.containerState.furtherBlankLines = undefined;
50942
+ self.containerState.initialBlankLine = undefined;
52805
50943
  return effects.attempt(indentConstruct, ok2, notInCurrentItem)(code);
52806
50944
  }
52807
50945
  function notInCurrentItem(code) {
52808
- ok(self2.containerState, "expected state");
52809
- self2.containerState._closeFlow = true;
52810
- self2.interrupt = undefined;
52811
- ok(self2.parser.constructs.disable.null, "expected `disable.null` to be populated");
52812
- return factorySpace(effects, effects.attempt(list, ok2, nok), types2.linePrefix, self2.parser.constructs.disable.null.includes("codeIndented") ? undefined : constants.tabSize)(code);
50946
+ ok(self.containerState, "expected state");
50947
+ self.containerState._closeFlow = true;
50948
+ self.interrupt = undefined;
50949
+ ok(self.parser.constructs.disable.null, "expected `disable.null` to be populated");
50950
+ return factorySpace(effects, effects.attempt(list, ok2, nok), types2.linePrefix, self.parser.constructs.disable.null.includes("codeIndented") ? undefined : constants.tabSize)(code);
52813
50951
  }
52814
50952
  }
52815
50953
  function tokenizeIndent(effects, ok2, nok) {
52816
- const self2 = this;
52817
- ok(self2.containerState, "expected state");
52818
- ok(typeof self2.containerState.size === "number", "expected size");
52819
- return factorySpace(effects, afterPrefix, types2.listItemIndent, self2.containerState.size + 1);
50954
+ const self = this;
50955
+ ok(self.containerState, "expected state");
50956
+ ok(typeof self.containerState.size === "number", "expected size");
50957
+ return factorySpace(effects, afterPrefix, types2.listItemIndent, self.containerState.size + 1);
52820
50958
  function afterPrefix(code) {
52821
- ok(self2.containerState, "expected state");
52822
- const tail = self2.events[self2.events.length - 1];
52823
- return tail && tail[1].type === types2.listItemIndent && tail[2].sliceSerialize(tail[1], true).length === self2.containerState.size ? ok2(code) : nok(code);
50959
+ ok(self.containerState, "expected state");
50960
+ const tail = self.events[self.events.length - 1];
50961
+ return tail && tail[1].type === types2.listItemIndent && tail[2].sliceSerialize(tail[1], true).length === self.containerState.size ? ok2(code) : nok(code);
52824
50962
  }
52825
50963
  }
52826
50964
  function tokenizeListEnd(effects) {
@@ -52829,11 +50967,11 @@ function tokenizeListEnd(effects) {
52829
50967
  effects.exit(this.containerState.type);
52830
50968
  }
52831
50969
  function tokenizeListItemPrefixWhitespace(effects, ok2, nok) {
52832
- const self2 = this;
52833
- ok(self2.parser.constructs.disable.null, "expected `disable.null` to be populated");
52834
- return factorySpace(effects, afterPrefix, types2.listItemPrefixWhitespace, self2.parser.constructs.disable.null.includes("codeIndented") ? undefined : constants.tabSize + 1);
50970
+ const self = this;
50971
+ ok(self.parser.constructs.disable.null, "expected `disable.null` to be populated");
50972
+ return factorySpace(effects, afterPrefix, types2.listItemPrefixWhitespace, self.parser.constructs.disable.null.includes("codeIndented") ? undefined : constants.tabSize + 1);
52835
50973
  function afterPrefix(code) {
52836
- const tail = self2.events[self2.events.length - 1];
50974
+ const tail = self.events[self.events.length - 1];
52837
50975
  return !markdownSpace(code) && tail && tail[1].type === types2.listItemPrefixWhitespace ? ok2(code) : nok(code);
52838
50976
  }
52839
50977
  }
@@ -52887,20 +51025,20 @@ function resolveToSetextUnderline(events, context) {
52887
51025
  return events;
52888
51026
  }
52889
51027
  function tokenizeSetextUnderline(effects, ok2, nok) {
52890
- const self2 = this;
51028
+ const self = this;
52891
51029
  let marker;
52892
51030
  return start;
52893
51031
  function start(code) {
52894
- let index = self2.events.length;
51032
+ let index = self.events.length;
52895
51033
  let paragraph;
52896
51034
  ok(code === codes.dash || code === codes.equalsTo, "expected `=` or `-`");
52897
51035
  while (index--) {
52898
- if (self2.events[index][1].type !== types2.lineEnding && self2.events[index][1].type !== types2.linePrefix && self2.events[index][1].type !== types2.content) {
52899
- paragraph = self2.events[index][1].type === types2.paragraph;
51036
+ if (self.events[index][1].type !== types2.lineEnding && self.events[index][1].type !== types2.linePrefix && self.events[index][1].type !== types2.content) {
51037
+ paragraph = self.events[index][1].type === types2.paragraph;
52900
51038
  break;
52901
51039
  }
52902
51040
  }
52903
- if (!self2.parser.lazy[self2.now().line] && (self2.interrupt || paragraph)) {
51041
+ if (!self.parser.lazy[self.now().line] && (self.interrupt || paragraph)) {
52904
51042
  effects.enter(types2.setextHeadingLine);
52905
51043
  marker = code;
52906
51044
  return before(code);
@@ -52930,7 +51068,7 @@ function tokenizeSetextUnderline(effects, ok2, nok) {
52930
51068
  // ../node_modules/.bun/micromark@4.0.2/node_modules/micromark/dev/lib/initialize/flow.js
52931
51069
  var flow = { tokenize: initializeFlow };
52932
51070
  function initializeFlow(effects) {
52933
- const self2 = this;
51071
+ const self = this;
52934
51072
  const initial = effects.attempt(blankLine, atBlankEnding, effects.attempt(this.parser.constructs.flowInitial, afterConstruct, factorySpace(effects, effects.attempt(this.parser.constructs.flow, afterConstruct, effects.attempt(content2, afterConstruct)), types2.linePrefix)));
52935
51073
  return initial;
52936
51074
  function atBlankEnding(code) {
@@ -52942,7 +51080,7 @@ function initializeFlow(effects) {
52942
51080
  effects.enter(types2.lineEndingBlank);
52943
51081
  effects.consume(code);
52944
51082
  effects.exit(types2.lineEndingBlank);
52945
- self2.currentConstruct = undefined;
51083
+ self.currentConstruct = undefined;
52946
51084
  return initial;
52947
51085
  }
52948
51086
  function afterConstruct(code) {
@@ -52954,7 +51092,7 @@ function initializeFlow(effects) {
52954
51092
  effects.enter(types2.lineEnding);
52955
51093
  effects.consume(code);
52956
51094
  effects.exit(types2.lineEnding);
52957
- self2.currentConstruct = undefined;
51095
+ self.currentConstruct = undefined;
52958
51096
  return initial;
52959
51097
  }
52960
51098
  }
@@ -52969,7 +51107,7 @@ function initializeFactory(field) {
52969
51107
  tokenize: initializeText
52970
51108
  };
52971
51109
  function initializeText(effects) {
52972
- const self2 = this;
51110
+ const self = this;
52973
51111
  const constructs2 = this.parser.constructs[field];
52974
51112
  const text2 = effects.attempt(constructs2, start, notText);
52975
51113
  return start;
@@ -53003,7 +51141,7 @@ function initializeFactory(field) {
53003
51141
  ok(Array.isArray(list2), "expected `disable.null` to be populated");
53004
51142
  while (++index < list2.length) {
53005
51143
  const item = list2[index];
53006
- if (!item.previous || item.previous.call(self2, self2.previous)) {
51144
+ if (!item.previous || item.previous.call(self, self.previous)) {
53007
51145
  return true;
53008
51146
  }
53009
51147
  }
@@ -54379,12 +52517,12 @@ text3[codes.lowercaseH] = [emailAutolink, protocolAutolink];
54379
52517
  text3[codes.uppercaseW] = [emailAutolink, wwwAutolink];
54380
52518
  text3[codes.lowercaseW] = [emailAutolink, wwwAutolink];
54381
52519
  function tokenizeEmailAutolink(effects, ok2, nok) {
54382
- const self2 = this;
52520
+ const self = this;
54383
52521
  let dot;
54384
52522
  let data;
54385
52523
  return start;
54386
52524
  function start(code2) {
54387
- if (!gfmAtext(code2) || !previousEmail.call(self2, self2.previous) || previousUnbalanced(self2.events)) {
52525
+ if (!gfmAtext(code2) || !previousEmail.call(self, self.previous) || previousUnbalanced(self.events)) {
54388
52526
  return nok(code2);
54389
52527
  }
54390
52528
  effects.enter("literalAutolink");
@@ -54419,7 +52557,7 @@ function tokenizeEmailAutolink(effects, ok2, nok) {
54419
52557
  return emailDomain;
54420
52558
  }
54421
52559
  function emailDomainAfter(code2) {
54422
- if (data && dot && asciiAlpha(self2.previous)) {
52560
+ if (data && dot && asciiAlpha(self.previous)) {
54423
52561
  effects.exit("literalAutolinkEmail");
54424
52562
  effects.exit("literalAutolink");
54425
52563
  return ok2(code2);
@@ -54428,10 +52566,10 @@ function tokenizeEmailAutolink(effects, ok2, nok) {
54428
52566
  }
54429
52567
  }
54430
52568
  function tokenizeWwwAutolink(effects, ok2, nok) {
54431
- const self2 = this;
52569
+ const self = this;
54432
52570
  return wwwStart;
54433
52571
  function wwwStart(code2) {
54434
- if (code2 !== codes.uppercaseW && code2 !== codes.lowercaseW || !previousWww.call(self2, self2.previous) || previousUnbalanced(self2.events)) {
52572
+ if (code2 !== codes.uppercaseW && code2 !== codes.lowercaseW || !previousWww.call(self, self.previous) || previousUnbalanced(self.events)) {
54435
52573
  return nok(code2);
54436
52574
  }
54437
52575
  effects.enter("literalAutolink");
@@ -54445,12 +52583,12 @@ function tokenizeWwwAutolink(effects, ok2, nok) {
54445
52583
  }
54446
52584
  }
54447
52585
  function tokenizeProtocolAutolink(effects, ok2, nok) {
54448
- const self2 = this;
52586
+ const self = this;
54449
52587
  let buffer = "";
54450
52588
  let seen = false;
54451
52589
  return protocolStart;
54452
52590
  function protocolStart(code2) {
54453
- if ((code2 === codes.uppercaseH || code2 === codes.lowercaseH) && previousProtocol.call(self2, self2.previous) && !previousUnbalanced(self2.events)) {
52591
+ if ((code2 === codes.uppercaseH || code2 === codes.lowercaseH) && previousProtocol.call(self, self.previous) && !previousUnbalanced(self.events)) {
54454
52592
  effects.enter("literalAutolink");
54455
52593
  effects.enter("literalAutolinkHttp");
54456
52594
  buffer += String.fromCodePoint(code2);
@@ -54685,12 +52823,12 @@ function gfmFootnote() {
54685
52823
  };
54686
52824
  }
54687
52825
  function tokenizePotentialGfmFootnoteCall(effects, ok2, nok) {
54688
- const self2 = this;
54689
- let index2 = self2.events.length;
54690
- const defined = self2.parser.gfmFootnotes || (self2.parser.gfmFootnotes = []);
52826
+ const self = this;
52827
+ let index2 = self.events.length;
52828
+ const defined = self.parser.gfmFootnotes || (self.parser.gfmFootnotes = []);
54691
52829
  let labelStart;
54692
52830
  while (index2--) {
54693
- const token = self2.events[index2][1];
52831
+ const token = self.events[index2][1];
54694
52832
  if (token.type === types2.labelImage) {
54695
52833
  labelStart = token;
54696
52834
  break;
@@ -54705,7 +52843,7 @@ function tokenizePotentialGfmFootnoteCall(effects, ok2, nok) {
54705
52843
  if (!labelStart || !labelStart._balanced) {
54706
52844
  return nok(code2);
54707
52845
  }
54708
- const id = normalizeIdentifier(self2.sliceSerialize({ start: labelStart.end, end: self2.now() }));
52846
+ const id = normalizeIdentifier(self.sliceSerialize({ start: labelStart.end, end: self.now() }));
54709
52847
  if (id.codePointAt(0) !== codes.caret || !defined.includes(id.slice(1))) {
54710
52848
  return nok(code2);
54711
52849
  }
@@ -54771,8 +52909,8 @@ function resolveToPotentialGfmFootnoteCall(events, context) {
54771
52909
  return events;
54772
52910
  }
54773
52911
  function tokenizeGfmFootnoteCall(effects, ok2, nok) {
54774
- const self2 = this;
54775
- const defined = self2.parser.gfmFootnotes || (self2.parser.gfmFootnotes = []);
52912
+ const self = this;
52913
+ const defined = self.parser.gfmFootnotes || (self.parser.gfmFootnotes = []);
54776
52914
  let size = 0;
54777
52915
  let data;
54778
52916
  return start;
@@ -54801,7 +52939,7 @@ function tokenizeGfmFootnoteCall(effects, ok2, nok) {
54801
52939
  if (code2 === codes.rightSquareBracket) {
54802
52940
  effects.exit("chunkString");
54803
52941
  const token = effects.exit("gfmFootnoteCallString");
54804
- if (!defined.includes(normalizeIdentifier(self2.sliceSerialize(token)))) {
52942
+ if (!defined.includes(normalizeIdentifier(self.sliceSerialize(token)))) {
54805
52943
  return nok(code2);
54806
52944
  }
54807
52945
  effects.enter("gfmFootnoteCallLabelMarker");
@@ -54827,8 +52965,8 @@ function tokenizeGfmFootnoteCall(effects, ok2, nok) {
54827
52965
  }
54828
52966
  }
54829
52967
  function tokenizeDefinitionStart(effects, ok2, nok) {
54830
- const self2 = this;
54831
- const defined = self2.parser.gfmFootnotes || (self2.parser.gfmFootnotes = []);
52968
+ const self = this;
52969
+ const defined = self.parser.gfmFootnotes || (self.parser.gfmFootnotes = []);
54832
52970
  let identifier;
54833
52971
  let size = 0;
54834
52972
  let data;
@@ -54860,7 +52998,7 @@ function tokenizeDefinitionStart(effects, ok2, nok) {
54860
52998
  if (code2 === codes.rightSquareBracket) {
54861
52999
  effects.exit("chunkString");
54862
53000
  const token = effects.exit("gfmFootnoteDefinitionLabelString");
54863
- identifier = normalizeIdentifier(self2.sliceSerialize(token));
53001
+ identifier = normalizeIdentifier(self.sliceSerialize(token));
54864
53002
  effects.enter("gfmFootnoteDefinitionLabelMarker");
54865
53003
  effects.consume(code2);
54866
53004
  effects.exit("gfmFootnoteDefinitionLabelMarker");
@@ -54905,10 +53043,10 @@ function gfmFootnoteDefinitionEnd(effects) {
54905
53043
  effects.exit("gfmFootnoteDefinition");
54906
53044
  }
54907
53045
  function tokenizeIndent2(effects, ok2, nok) {
54908
- const self2 = this;
53046
+ const self = this;
54909
53047
  return factorySpace(effects, afterPrefix, "gfmFootnoteDefinitionIndent", constants.tabSize + 1);
54910
53048
  function afterPrefix(code2) {
54911
- const tail = self2.events[self2.events.length - 1];
53049
+ const tail = self.events[self.events.length - 1];
54912
53050
  return tail && tail[1].type === "gfmFootnoteDefinitionIndent" && tail[2].sliceSerialize(tail[1], true).length === constants.tabSize ? ok2(code2) : nok(code2);
54913
53051
  }
54914
53052
  }
@@ -55098,23 +53236,23 @@ function gfmTable() {
55098
53236
  };
55099
53237
  }
55100
53238
  function tokenizeTable(effects, ok2, nok) {
55101
- const self2 = this;
53239
+ const self = this;
55102
53240
  let size = 0;
55103
53241
  let sizeB = 0;
55104
53242
  let seen;
55105
53243
  return start;
55106
53244
  function start(code2) {
55107
- let index2 = self2.events.length - 1;
53245
+ let index2 = self.events.length - 1;
55108
53246
  while (index2 > -1) {
55109
- const type = self2.events[index2][1].type;
53247
+ const type = self.events[index2][1].type;
55110
53248
  if (type === types2.lineEnding || type === types2.linePrefix)
55111
53249
  index2--;
55112
53250
  else
55113
53251
  break;
55114
53252
  }
55115
- const tail = index2 > -1 ? self2.events[index2][1].type : null;
53253
+ const tail = index2 > -1 ? self.events[index2][1].type : null;
55116
53254
  const next = tail === "tableHead" || tail === "tableRow" ? bodyRowStart : headRowBefore;
55117
- if (next === bodyRowStart && self2.parser.lazy[self2.now().line]) {
53255
+ if (next === bodyRowStart && self.parser.lazy[self.now().line]) {
55118
53256
  return nok(code2);
55119
53257
  }
55120
53258
  return next(code2);
@@ -55139,7 +53277,7 @@ function tokenizeTable(effects, ok2, nok) {
55139
53277
  if (markdownLineEnding(code2)) {
55140
53278
  if (sizeB > 1) {
55141
53279
  sizeB = 0;
55142
- self2.interrupt = true;
53280
+ self.interrupt = true;
55143
53281
  effects.exit("tableRow");
55144
53282
  effects.enter(types2.lineEnding);
55145
53283
  effects.consume(code2);
@@ -55182,15 +53320,15 @@ function tokenizeTable(effects, ok2, nok) {
55182
53320
  return headRowData(code2);
55183
53321
  }
55184
53322
  function headDelimiterStart(code2) {
55185
- self2.interrupt = false;
55186
- if (self2.parser.lazy[self2.now().line]) {
53323
+ self.interrupt = false;
53324
+ if (self.parser.lazy[self.now().line]) {
55187
53325
  return nok(code2);
55188
53326
  }
55189
53327
  effects.enter("tableDelimiterRow");
55190
53328
  seen = false;
55191
53329
  if (markdownSpace(code2)) {
55192
- ok(self2.parser.constructs.disable.null, "expected `disabled.null`");
55193
- return factorySpace(effects, headDelimiterBefore, types2.linePrefix, self2.parser.constructs.disable.null.includes("codeIndented") ? undefined : constants.tabSize)(code2);
53330
+ ok(self.parser.constructs.disable.null, "expected `disabled.null`");
53331
+ return factorySpace(effects, headDelimiterBefore, types2.linePrefix, self.parser.constructs.disable.null.includes("codeIndented") ? undefined : constants.tabSize)(code2);
55194
53332
  }
55195
53333
  return headDelimiterBefore(code2);
55196
53334
  }
@@ -55481,11 +53619,11 @@ function gfmTaskListItem() {
55481
53619
  };
55482
53620
  }
55483
53621
  function tokenizeTasklistCheck(effects, ok2, nok) {
55484
- const self2 = this;
53622
+ const self = this;
55485
53623
  return open;
55486
53624
  function open(code2) {
55487
53625
  ok(code2 === codes.leftSquareBracket, "expected `[`");
55488
- if (self2.previous !== codes.eof || !self2._gfmTasklistFirstContentOfListItem) {
53626
+ if (self.previous !== codes.eof || !self._gfmTasklistFirstContentOfListItem) {
55489
53627
  return nok(code2);
55490
53628
  }
55491
53629
  effects.enter("taskListCheck");
@@ -56319,34 +54457,36 @@ function parse2(markdown) {
56319
54457
  }
56320
54458
 
56321
54459
  // render/render.ts
56322
- function renderInline(node2) {
54460
+ function renderInline(node2, ctx = {}) {
56323
54461
  switch (node2.type) {
56324
54462
  case "plain":
56325
54463
  return escapeMarkdown(node2.text);
56326
54464
  case "bold":
56327
- return `**${renderInlineChildren(node2.children)}**`;
54465
+ return `**${renderInlineChildren(node2.children, ctx)}**`;
56328
54466
  case "italic":
56329
- return `*${renderInlineChildren(node2.children)}*`;
54467
+ return `*${renderInlineChildren(node2.children, ctx)}*`;
56330
54468
  case "underline":
56331
- return `__${renderInlineChildren(node2.children)}__`;
54469
+ return `__${renderInlineChildren(node2.children, ctx)}__`;
56332
54470
  case "strike":
56333
- return `~~${renderInlineChildren(node2.children)}~~`;
54471
+ return `~~${renderInlineChildren(node2.children, ctx)}~~`;
56334
54472
  case "spoiler":
56335
- return `||${renderInlineChildren(node2.children)}||`;
54473
+ return `||${renderInlineChildren(node2.children, ctx)}||`;
56336
54474
  case "highlight":
56337
- return `==${renderInlineChildren(node2.children)}==`;
56338
- case "code":
56339
- return `\`${codeSpanSafe(node2.text)}\``;
54475
+ return `==${renderInlineChildren(node2.children, ctx)}==`;
54476
+ case "code": {
54477
+ const safe = codeSpanSafe(node2.text);
54478
+ return `\`${ctx.inTableCell ? safe.replace(/\|/g, "\\|") : safe}\``;
54479
+ }
56340
54480
  case "link":
56341
- return `[${renderInlineChildren(node2.children)}](${node2.href})`;
54481
+ return `[${renderInlineChildren(node2.children, ctx)}](${escapeLinkHref(node2.href)})`;
56342
54482
  default: {
56343
54483
  const _exhaustive = node2;
56344
54484
  return escapeMarkdown(_exhaustive.text ?? "");
56345
54485
  }
56346
54486
  }
56347
54487
  }
56348
- function renderInlineChildren(children) {
56349
- return children.map(renderInline).join("");
54488
+ function renderInlineChildren(children, ctx = {}) {
54489
+ return children.map((child) => renderInline(child, ctx)).join("");
56350
54490
  }
56351
54491
  function prefixLines(text4, prefix) {
56352
54492
  return text4.split(`
@@ -56398,7 +54538,7 @@ function renderList(node2) {
56398
54538
  return node2.items.map((item, i) => renderListItem(item, node2.ordered, start + i)).join(sep);
56399
54539
  }
56400
54540
  function renderTableCell(cells) {
56401
- return renderInlineChildren(cells.children).replace(/\n+/g, " ");
54541
+ return renderInlineChildren(cells.children, { inTableCell: true }).replace(/\n+/g, " ");
56402
54542
  }
56403
54543
  function alignSeparator(align) {
56404
54544
  switch (align) {
@@ -57035,6 +55175,14 @@ class TokenBucket {
57035
55175
  return this.tokens;
57036
55176
  }
57037
55177
  }
55178
+ var PRIORITY_RANK = {
55179
+ cosmetic: 0,
55180
+ useful: 1,
55181
+ critical: 2
55182
+ };
55183
+ function maxPriority(a, b) {
55184
+ return PRIORITY_RANK[b] > PRIORITY_RANK[a] ? b : a;
55185
+ }
57038
55186
  function hashPayload(payload) {
57039
55187
  let s;
57040
55188
  if (typeof payload === "string") {
@@ -57317,7 +55465,18 @@ function createSendGate(config) {
57317
55465
  p.resolve(undefined);
57318
55466
  continue;
57319
55467
  }
57320
- await admit(bucketsFor(opts));
55468
+ if (p.priorityClass === "critical") {
55469
+ const outcome = await admitPriority(bucketsFor(opts), "critical");
55470
+ if (outcome.result === "failfast") {
55471
+ counters.failedFast++;
55472
+ const retryAfterSec = Math.ceil((outcome.untilTs - clock.now()) / 1000);
55473
+ openScopedWindowsForOpts(opts, outcome.untilTs);
55474
+ p.reject(makeFloodWaitActiveError(retryAfterSec, outcome.untilTs, null));
55475
+ continue;
55476
+ }
55477
+ } else {
55478
+ await admit(bucketsFor(opts));
55479
+ }
57321
55480
  state.lastSentMs = clock.now();
57322
55481
  try {
57323
55482
  const res = await p.fn();
@@ -57354,6 +55513,7 @@ function createSendGate(config) {
57354
55513
  }
57355
55514
  }
57356
55515
  if (state.pending) {
55516
+ state.pending.priorityClass = maxPriority(state.pending.priorityClass, opts.priorityClass ?? "useful");
57357
55517
  if (state.pending.hash !== hash) {
57358
55518
  counters.coalesced++;
57359
55519
  state.pending.hash = hash;
@@ -57376,7 +55536,8 @@ function createSendGate(config) {
57376
55536
  fn,
57377
55537
  promise,
57378
55538
  resolve: resolve4,
57379
- reject
55539
+ reject,
55540
+ priorityClass: opts.priorityClass ?? "useful"
57380
55541
  };
57381
55542
  state.pending = pending;
57382
55543
  if (!state.running)
@@ -57437,7 +55598,11 @@ function createSendGate(config) {
57437
55598
  return { gate, openFloodWindow, stats };
57438
55599
  }
57439
55600
  function sendGateEnabledFromEnv(env = process.env) {
57440
- return env.SWITCHROOM_TELEGRAM_SEND_GATE === "1";
55601
+ const v = env.SWITCHROOM_TELEGRAM_SEND_GATE;
55602
+ if (v == null)
55603
+ return true;
55604
+ const t = v.trim().toLowerCase();
55605
+ return !(t === "0" || t === "false" || t === "off" || t === "no");
57441
55606
  }
57442
55607
 
57443
55608
  // send-gate-observability.ts
@@ -66296,21 +64461,21 @@ function recordOperatorEvent(event, now = Date.now()) {
66296
64461
  // model-unavailable.ts
66297
64462
  init_quota_check();
66298
64463
  init_card_format();
64464
+ var transientUpstreamSignals = [
64465
+ "not your usage limit",
64466
+ "not your account",
64467
+ "not your account's",
64468
+ "temporarily limiting requests",
64469
+ "temporarily rate",
64470
+ "server is temporarily",
64471
+ "would exceed your account\u2019s rate limit",
64472
+ "would exceed your account's rate limit"
64473
+ ];
66299
64474
  function detectModelUnavailable(stderr) {
66300
64475
  if (typeof stderr !== "string" || stderr.length === 0)
66301
64476
  return null;
66302
64477
  const sample = stderr.length > 16384 ? stderr.slice(0, 16384) : stderr;
66303
64478
  const lower = sample.toLowerCase();
66304
- const transientUpstreamSignals = [
66305
- "not your usage limit",
66306
- "not your account",
66307
- "not your account's",
66308
- "temporarily limiting requests",
66309
- "temporarily rate",
66310
- "server is temporarily",
66311
- "would exceed your account\u2019s rate limit",
66312
- "would exceed your account's rate limit"
66313
- ];
66314
64479
  if (transientUpstreamSignals.some((s) => lower.includes(s))) {
66315
64480
  const resetAt = parseResetTime(sample);
66316
64481
  return resetAt !== undefined ? { kind: "overload", resetAt, raw: stderr } : { kind: "overload", raw: stderr };
@@ -67446,7 +65611,7 @@ async function sendReplyChunks(deps, state3) {
67446
65611
  }
67447
65612
 
67448
65613
  // telegram-button-constraints.ts
67449
- var TELEGRAM_BUTTON_LIMITS = {
65614
+ var TELEGRAM_BUTTON_LIMITS2 = {
67450
65615
  TEXT_MAX: 64,
67451
65616
  URL_MAX: 2048,
67452
65617
  CALLBACK_DATA_MAX: 64,
@@ -67459,23 +65624,23 @@ function validateInlineButton(button, path2) {
67459
65624
  const textField = typeof button.text === "string" ? button.text : null;
67460
65625
  if (textField === null || textField.length === 0) {
67461
65626
  errors2.push({ path: path2, field: "text", reason: "missing or empty text" });
67462
- } else if (textField.length > TELEGRAM_BUTTON_LIMITS.TEXT_MAX) {
65627
+ } else if (textField.length > TELEGRAM_BUTTON_LIMITS2.TEXT_MAX) {
67463
65628
  errors2.push({
67464
65629
  path: path2,
67465
65630
  field: "text",
67466
- reason: `text exceeds ${TELEGRAM_BUTTON_LIMITS.TEXT_MAX}-char limit`,
65631
+ reason: `text exceeds ${TELEGRAM_BUTTON_LIMITS2.TEXT_MAX}-char limit`,
67467
65632
  actualLength: textField.length,
67468
- limit: TELEGRAM_BUTTON_LIMITS.TEXT_MAX
65633
+ limit: TELEGRAM_BUTTON_LIMITS2.TEXT_MAX
67469
65634
  });
67470
65635
  }
67471
65636
  if (typeof button.url === "string") {
67472
- if (button.url.length > TELEGRAM_BUTTON_LIMITS.URL_MAX) {
65637
+ if (button.url.length > TELEGRAM_BUTTON_LIMITS2.URL_MAX) {
67473
65638
  errors2.push({
67474
65639
  path: path2,
67475
65640
  field: "url",
67476
- reason: `url exceeds ${TELEGRAM_BUTTON_LIMITS.URL_MAX}-char limit`,
65641
+ reason: `url exceeds ${TELEGRAM_BUTTON_LIMITS2.URL_MAX}-char limit`,
67477
65642
  actualLength: button.url.length,
67478
- limit: TELEGRAM_BUTTON_LIMITS.URL_MAX
65643
+ limit: TELEGRAM_BUTTON_LIMITS2.URL_MAX
67479
65644
  });
67480
65645
  }
67481
65646
  if (!/^https?:\/\//i.test(button.url) && !button.url.startsWith("tg://")) {
@@ -67488,13 +65653,13 @@ function validateInlineButton(button, path2) {
67488
65653
  }
67489
65654
  if (typeof button.callback_data === "string") {
67490
65655
  const bytes = new TextEncoder().encode(button.callback_data).byteLength;
67491
- if (bytes > TELEGRAM_BUTTON_LIMITS.CALLBACK_DATA_MAX) {
65656
+ if (bytes > TELEGRAM_BUTTON_LIMITS2.CALLBACK_DATA_MAX) {
67492
65657
  errors2.push({
67493
65658
  path: path2,
67494
65659
  field: "callback_data",
67495
- reason: `callback_data exceeds ${TELEGRAM_BUTTON_LIMITS.CALLBACK_DATA_MAX}-byte limit`,
65660
+ reason: `callback_data exceeds ${TELEGRAM_BUTTON_LIMITS2.CALLBACK_DATA_MAX}-byte limit`,
67496
65661
  actualLength: bytes,
67497
- limit: TELEGRAM_BUTTON_LIMITS.CALLBACK_DATA_MAX
65662
+ limit: TELEGRAM_BUTTON_LIMITS2.CALLBACK_DATA_MAX
67498
65663
  });
67499
65664
  }
67500
65665
  }
@@ -67507,25 +65672,25 @@ function validateInlineButton(button, path2) {
67507
65672
  field: "copy_text.text",
67508
65673
  reason: "missing or empty copy_text.text"
67509
65674
  });
67510
- } else if (copyText.length > TELEGRAM_BUTTON_LIMITS.COPY_TEXT_MAX) {
65675
+ } else if (copyText.length > TELEGRAM_BUTTON_LIMITS2.COPY_TEXT_MAX) {
67511
65676
  errors2.push({
67512
65677
  path: path2,
67513
65678
  field: "copy_text.text",
67514
- reason: `copy_text.text exceeds ${TELEGRAM_BUTTON_LIMITS.COPY_TEXT_MAX}-char limit`,
65679
+ reason: `copy_text.text exceeds ${TELEGRAM_BUTTON_LIMITS2.COPY_TEXT_MAX}-char limit`,
67515
65680
  actualLength: copyText.length,
67516
- limit: TELEGRAM_BUTTON_LIMITS.COPY_TEXT_MAX
65681
+ limit: TELEGRAM_BUTTON_LIMITS2.COPY_TEXT_MAX
67517
65682
  });
67518
65683
  }
67519
65684
  }
67520
65685
  if (button.login_url && typeof button.login_url === "object") {
67521
65686
  const lu = button.login_url;
67522
- if (typeof lu.url === "string" && lu.url.length > TELEGRAM_BUTTON_LIMITS.LOGIN_URL_MAX) {
65687
+ if (typeof lu.url === "string" && lu.url.length > TELEGRAM_BUTTON_LIMITS2.LOGIN_URL_MAX) {
67523
65688
  errors2.push({
67524
65689
  path: path2,
67525
65690
  field: "login_url.url",
67526
- reason: `login_url.url exceeds ${TELEGRAM_BUTTON_LIMITS.LOGIN_URL_MAX}-char limit`,
65691
+ reason: `login_url.url exceeds ${TELEGRAM_BUTTON_LIMITS2.LOGIN_URL_MAX}-char limit`,
67527
65692
  actualLength: lu.url.length,
67528
- limit: TELEGRAM_BUTTON_LIMITS.LOGIN_URL_MAX
65693
+ limit: TELEGRAM_BUTTON_LIMITS2.LOGIN_URL_MAX
67529
65694
  });
67530
65695
  }
67531
65696
  }
@@ -67566,6 +65731,40 @@ function wrapAgentCallbacks(keyboard) {
67566
65731
  return cleaned;
67567
65732
  }));
67568
65733
  }
65734
+ function redactAgentKeyboard(keyboard, redactFn) {
65735
+ const clamp = (s, max) => s.length > max ? s.slice(0, max) : s;
65736
+ return keyboard.map((row) => row.map((btn) => {
65737
+ const out = { ...btn };
65738
+ if (typeof out.text === "string") {
65739
+ out.text = clamp(redactFn(out.text), TELEGRAM_BUTTON_LIMITS.TEXT_MAX);
65740
+ }
65741
+ if (typeof out.ack_text === "string")
65742
+ out.ack_text = redactFn(out.ack_text);
65743
+ const siq = out.switch_inline_query;
65744
+ if (typeof siq === "string") {
65745
+ out.switch_inline_query = clamp(redactFn(siq), TELEGRAM_BUTTON_LIMITS.SWITCH_INLINE_QUERY_MAX);
65746
+ }
65747
+ const siqc = out.switch_inline_query_current_chat;
65748
+ if (typeof siqc === "string") {
65749
+ out.switch_inline_query_current_chat = clamp(redactFn(siqc), TELEGRAM_BUTTON_LIMITS.SWITCH_INLINE_QUERY_MAX);
65750
+ }
65751
+ const cc = out.switch_inline_query_chosen_chat;
65752
+ if (cc != null && typeof cc === "object" && typeof cc.query === "string") {
65753
+ out.switch_inline_query_chosen_chat = {
65754
+ ...cc,
65755
+ query: clamp(redactFn(cc.query), TELEGRAM_BUTTON_LIMITS.SWITCH_INLINE_QUERY_MAX)
65756
+ };
65757
+ }
65758
+ const ct = out.copy_text;
65759
+ if (ct != null && typeof ct === "object" && typeof ct.text === "string") {
65760
+ out.copy_text = {
65761
+ ...ct,
65762
+ text: clamp(redactFn(ct.text), TELEGRAM_BUTTON_LIMITS.COPY_TEXT_MAX)
65763
+ };
65764
+ }
65765
+ return out;
65766
+ }));
65767
+ }
67569
65768
  function extractAgentButtonMeta(keyboard) {
67570
65769
  const out = new Map;
67571
65770
  for (const row of keyboard) {
@@ -70718,6 +68917,7 @@ function extractConfirmation(pane) {
70718
68917
 
70719
68918
  // ../src/agents/scaffold.ts
70720
68919
  import { join as join32, resolve as resolve6 } from "node:path";
68920
+ init_atomic();
70721
68921
  init_schema();
70722
68922
 
70723
68923
  // ../src/config/users.ts
@@ -70759,7 +68959,7 @@ init_overlay_loader();
70759
68959
  var AUDIT_ROOT = join30(homedir9(), ".switchroom", "audit");
70760
68960
 
70761
68961
  // ../src/agents/profiles.ts
70762
- var import_handlebars = __toESM(require_lib2(), 1);
68962
+ var import_handlebars = __toESM(require_lib(), 1);
70763
68963
  import { readFileSync as readFileSync26, writeFileSync as writeFileSync22, existsSync as existsSync26, readdirSync as readdirSync5, statSync as statSync8, copyFileSync, mkdirSync as mkdirSync22, realpathSync as realpathSync2 } from "node:fs";
70764
68964
  import { resolve as resolve5, join as join31, sep as pathSep } from "node:path";
70765
68965
  var PROFILES_ROOT = resolve5(import.meta.dirname, "../../profiles");
@@ -73345,7 +71545,7 @@ function recordWebhookEvent(rec, deps = {}) {
73345
71545
  }
73346
71546
 
73347
71547
  // gateway/ipc-server.ts
73348
- import { renameSync as renameSync10, unlinkSync as unlinkSync14, chmodSync as chmodSync9 } from "fs";
71548
+ import { renameSync as renameSync11, unlinkSync as unlinkSync14, chmodSync as chmodSync9 } from "fs";
73349
71549
  var MAX_BUFFER_SIZE = 1024 * 1024;
73350
71550
  var VALID_OPERATOR_KINDS = new Set([
73351
71551
  "credentials-expired",
@@ -73554,7 +71754,7 @@ function createIpcServer(options) {
73554
71754
  heartbeatTimeoutMs = 30000
73555
71755
  } = options;
73556
71756
  try {
73557
- renameSync10(socketPath, socketPath + ".bak");
71757
+ renameSync11(socketPath, socketPath + ".bak");
73558
71758
  } catch {}
73559
71759
  try {
73560
71760
  unlinkSync14(socketPath + ".bak");
@@ -73944,7 +72144,7 @@ function createIpcServer(options) {
73944
72144
  clientBySocketId.clear();
73945
72145
  server.stop(true);
73946
72146
  try {
73947
- renameSync10(socketPath, socketPath + ".bak");
72147
+ renameSync11(socketPath, socketPath + ".bak");
73948
72148
  } catch {}
73949
72149
  }
73950
72150
  };
@@ -76629,12 +74829,12 @@ function skillProposalKeyboard(id) {
76629
74829
 
76630
74830
  // ../src/self-improve/skill-proposals.ts
76631
74831
  import {
76632
- closeSync as closeSync5,
74832
+ closeSync as closeSync6,
76633
74833
  existsSync as existsSync33,
76634
74834
  mkdirSync as mkdirSync27,
76635
- openSync as openSync5,
74835
+ openSync as openSync6,
76636
74836
  readFileSync as readFileSync31,
76637
- writeSync as writeSync4
74837
+ writeSync as writeSync5
76638
74838
  } from "node:fs";
76639
74839
  import { join as join37 } from "node:path";
76640
74840
  import { randomUUID as randomUUID5 } from "node:crypto";
@@ -76654,12 +74854,12 @@ function ensureDir3(stateDir) {
76654
74854
  }
76655
74855
  }
76656
74856
  function appendLine2(path2, obj) {
76657
- const fd = openSync5(path2, "a");
74857
+ const fd = openSync6(path2, "a");
76658
74858
  try {
76659
- writeSync4(fd, JSON.stringify(obj) + `
74859
+ writeSync5(fd, JSON.stringify(obj) + `
76660
74860
  `);
76661
74861
  } finally {
76662
- closeSync5(fd);
74862
+ closeSync6(fd);
76663
74863
  }
76664
74864
  }
76665
74865
  function readLines2(path2, isValid2) {
@@ -77260,11 +75460,11 @@ function escapeBody2(s) {
77260
75460
  }
77261
75461
 
77262
75462
  // gateway/pid-file.ts
77263
- import { writeFileSync as writeFileSync26, readFileSync as readFileSync32, unlinkSync as unlinkSync15, renameSync as renameSync11 } from "node:fs";
75463
+ import { writeFileSync as writeFileSync26, readFileSync as readFileSync32, unlinkSync as unlinkSync15, renameSync as renameSync12 } from "node:fs";
77264
75464
  function writePidFile(path2, record) {
77265
75465
  const tmp = `${path2}.tmp-${process.pid}-${Date.now()}`;
77266
75466
  writeFileSync26(tmp, JSON.stringify(record), "utf-8");
77267
- renameSync11(tmp, path2);
75467
+ renameSync12(tmp, path2);
77268
75468
  }
77269
75469
  function clearPidFile(path2) {
77270
75470
  try {
@@ -77485,11 +75685,11 @@ function safeCount(fn) {
77485
75685
  }
77486
75686
 
77487
75687
  // gateway/session-marker.ts
77488
- import { writeFileSync as writeFileSync27, readFileSync as readFileSync34, renameSync as renameSync12, unlinkSync as unlinkSync16 } from "node:fs";
75688
+ import { writeFileSync as writeFileSync27, readFileSync as readFileSync34, renameSync as renameSync13, unlinkSync as unlinkSync16 } from "node:fs";
77489
75689
  function writeSessionMarker(path2, marker) {
77490
75690
  const tmp = `${path2}.tmp-${process.pid}-${Date.now()}`;
77491
75691
  writeFileSync27(tmp, JSON.stringify(marker), "utf-8");
77492
- renameSync12(tmp, path2);
75692
+ renameSync13(tmp, path2);
77493
75693
  }
77494
75694
  function readSessionMarker(path2) {
77495
75695
  try {
@@ -77515,12 +75715,12 @@ function shouldFireRestartBanner(input) {
77515
75715
  }
77516
75716
 
77517
75717
  // gateway/clean-shutdown-marker.ts
77518
- import { writeFileSync as writeFileSync28, readFileSync as readFileSync35, renameSync as renameSync13, unlinkSync as unlinkSync17 } from "node:fs";
75718
+ import { writeFileSync as writeFileSync28, readFileSync as readFileSync35, renameSync as renameSync14, unlinkSync as unlinkSync17 } from "node:fs";
77519
75719
  var DEFAULT_MAX_AGE_MS = 60000;
77520
75720
  function writeCleanShutdownMarker(path2, marker) {
77521
75721
  const tmp = `${path2}.tmp-${process.pid}-${Date.now()}`;
77522
75722
  writeFileSync28(tmp, JSON.stringify(marker), "utf-8");
77523
- renameSync13(tmp, path2);
75723
+ renameSync14(tmp, path2);
77524
75724
  }
77525
75725
  function readCleanShutdownMarker(path2) {
77526
75726
  try {
@@ -77960,7 +76160,6 @@ init_generic_entropy();
77960
76160
  init_chunker();
77961
76161
  init_suppressor();
77962
76162
  init_url_redact();
77963
- init_secretlint_source();
77964
76163
  function detectSecrets2(text4) {
77965
76164
  if (!text4 || text4.length === 0)
77966
76165
  return [];
@@ -78131,10 +76330,10 @@ function classifyAdminGate(text4, myAgentName) {
78131
76330
  // subagent-watcher.ts
78132
76331
  import {
78133
76332
  existsSync as existsSync35,
78134
- openSync as openSync7,
76333
+ openSync as openSync8,
78135
76334
  readSync as readSync2,
78136
76335
  statSync as statSync10,
78137
- closeSync as closeSync7,
76336
+ closeSync as closeSync8,
78138
76337
  watch,
78139
76338
  readdirSync as readdirSync6,
78140
76339
  readFileSync as readFileSync37
@@ -78206,6 +76405,27 @@ function getNestedObj(obj, key) {
78206
76405
  var DEFAULT_OPERATOR_EVENT_COOLDOWN_MS2 = 5 * 60000;
78207
76406
  var cooldownMap2 = new Map;
78208
76407
 
76408
+ // model-unavailable.ts
76409
+ init_quota_check();
76410
+ init_card_format();
76411
+ var transientUpstreamSignals2 = [
76412
+ "not your usage limit",
76413
+ "not your account",
76414
+ "not your account's",
76415
+ "temporarily limiting requests",
76416
+ "temporarily rate",
76417
+ "server is temporarily",
76418
+ "would exceed your account\u2019s rate limit",
76419
+ "would exceed your account's rate limit"
76420
+ ];
76421
+ function isTransientUpstreamSignal(text4) {
76422
+ if (typeof text4 !== "string" || text4.length === 0)
76423
+ return false;
76424
+ const sample = text4.length > 16384 ? text4.slice(0, 16384) : text4;
76425
+ const lower = sample.toLowerCase();
76426
+ return transientUpstreamSignals2.some((s) => lower.includes(s));
76427
+ }
76428
+
78209
76429
  // session-tail.ts
78210
76430
  function sanitizeCwdToProjectName(cwd) {
78211
76431
  return cwd.replace(/[^a-zA-Z0-9]/g, "-");
@@ -78389,7 +76609,8 @@ function detectErrorInTranscriptLine(line) {
78389
76609
  const status = typeof obj.apiErrorStatus === "number" ? obj.apiErrorStatus : null;
78390
76610
  const errStr = typeof obj.error === "string" ? obj.error : "";
78391
76611
  const text4 = extractAssistantText(obj);
78392
- const kind2 = status === 429 ? "quota-exhausted" : classifyClaudeError({ type: errStr, status, message: text4 });
76612
+ const kind2 = status === 429 ? isTransientUpstreamSignal(`${text4}
76613
+ ${errStr}`) ? "rate-limited" : "quota-exhausted" : classifyClaudeError({ type: errStr, status, message: text4 });
78393
76614
  return {
78394
76615
  kind: kind2,
78395
76616
  raw: obj,
@@ -78619,10 +76840,10 @@ function recordNestedSubagentDispatch(db2, args) {
78619
76840
 
78620
76841
  // gateway/turn-active-marker.ts
78621
76842
  import {
78622
- closeSync as closeSync6,
76843
+ closeSync as closeSync7,
78623
76844
  existsSync as existsSync34,
78624
76845
  mkdirSync as mkdirSync28,
78625
- openSync as openSync6,
76846
+ openSync as openSync7,
78626
76847
  readFileSync as readFileSync36,
78627
76848
  statSync as statSync9,
78628
76849
  unlinkSync as unlinkSync18,
@@ -78640,8 +76861,8 @@ function touchTurnActiveMarker(stateDir) {
78640
76861
  utimesSync(path2, now, now);
78641
76862
  } catch {
78642
76863
  try {
78643
- const fd = openSync6(path2, "r+");
78644
- closeSync6(fd);
76864
+ const fd = openSync7(path2, "r+");
76865
+ closeSync7(fd);
78645
76866
  } catch {}
78646
76867
  }
78647
76868
  }
@@ -79048,8 +77269,8 @@ function startSubagentWatcher(config) {
79048
77269
  existsSync: existsSync35,
79049
77270
  readdirSync: readdirSync6,
79050
77271
  statSync: statSync10,
79051
- openSync: openSync7,
79052
- closeSync: closeSync7,
77272
+ openSync: openSync8,
77273
+ closeSync: closeSync8,
79053
77274
  readSync: readSync2,
79054
77275
  watch
79055
77276
  };
@@ -79135,22 +77356,27 @@ function startSubagentWatcher(config) {
79135
77356
  } else {
79136
77357
  maybySendStateTransition(agentId);
79137
77358
  }
79138
- try {
79139
- tail.watcher = fs2.watch(filePath, () => {
79140
- if (stopped)
79141
- return;
79142
- const entry2 = registry.get(agentId);
79143
- const t = tails2.get(agentId);
79144
- if (!entry2 || !t)
79145
- return;
79146
- checkBootPromotionGrowth(entry2, t, nowFn());
79147
- readSubTail(entry2, t, nowFn(), (desc) => {
79148
- log?.(`subagent-watcher: description updated for ${agentId}: ${desc}`);
79149
- }, fs2, log, db2, parentStateDir, config.onUnstall, cleanupTerminalAgent, config.onProgress);
79150
- maybySendStateTransition(agentId);
79151
- });
79152
- } catch (err) {
79153
- log?.(`subagent-watcher: fs.watch failed for ${agentId}: ${err.message}`);
77359
+ const needsWatcher = !entry.historical || entry.bootPromotionPending != null;
77360
+ if (needsWatcher) {
77361
+ try {
77362
+ tail.watcher = fs2.watch(filePath, () => {
77363
+ if (stopped)
77364
+ return;
77365
+ const entry2 = registry.get(agentId);
77366
+ const t = tails2.get(agentId);
77367
+ if (!entry2 || !t)
77368
+ return;
77369
+ checkBootPromotionGrowth(entry2, t, nowFn());
77370
+ readSubTail(entry2, t, nowFn(), (desc) => {
77371
+ log?.(`subagent-watcher: description updated for ${agentId}: ${desc}`);
77372
+ }, fs2, log, db2, parentStateDir, config.onUnstall, cleanupTerminalAgent, config.onProgress);
77373
+ maybySendStateTransition(agentId);
77374
+ });
77375
+ } catch (err) {
77376
+ log?.(`subagent-watcher: fs.watch failed for ${agentId}: ${err.message}`);
77377
+ }
77378
+ } else {
77379
+ log?.(`subagent-watcher: ${agentId} historical/terminal at registration \u2014 not opening an FSWatcher (no live transition to observe)`);
79154
77380
  }
79155
77381
  }
79156
77382
  function checkBootPromotionGrowth(entry, tail, n) {
@@ -79185,7 +77411,13 @@ function startSubagentWatcher(config) {
79185
77411
  }
79186
77412
  if (n >= pending.deadlineAt) {
79187
77413
  entry.bootPromotionPending = undefined;
79188
- log?.(`subagent-watcher: ${entry.agentId} never observed post-boot JSONL growth within the window \u2014 leaving historical/orphan (not promoting; avoids synthesising a stale 'completed' handback from a worker killed before this restart)`);
77414
+ if (tail.watcher) {
77415
+ try {
77416
+ tail.watcher.close();
77417
+ } catch {}
77418
+ tail.watcher = null;
77419
+ }
77420
+ log?.(`subagent-watcher: ${entry.agentId} never observed post-boot JSONL growth within the window \u2014 leaving historical/orphan (not promoting; avoids synthesising a stale 'completed' handback from a worker killed before this restart); released growth-confirmation FSWatcher`);
79189
77421
  }
79190
77422
  }
79191
77423
  function maybySendStateTransition(agentId) {
@@ -79455,9 +77687,21 @@ function startSubagentWatcher(config) {
79455
77687
  maybySendStateTransition(entry.agentId);
79456
77688
  }
79457
77689
  }
77690
+ function pruneVanishedDirWatchers() {
77691
+ for (const [dirPath, w] of dirWatchers) {
77692
+ if (!fs2.existsSync(dirPath)) {
77693
+ try {
77694
+ w.close();
77695
+ } catch {}
77696
+ dirWatchers.delete(dirPath);
77697
+ log?.(`subagent-watcher: released dir watcher for vanished ${dirPath}`);
77698
+ }
77699
+ }
77700
+ }
79458
77701
  function rescanSubagentDirs() {
79459
77702
  if (stopped)
79460
77703
  return;
77704
+ pruneVanishedDirWatchers();
79461
77705
  const claudeHome = join39(agentDir, ".claude");
79462
77706
  const projectsRoot = join39(claudeHome, "projects");
79463
77707
  if (!fs2.existsSync(projectsRoot))
@@ -79666,7 +77910,7 @@ import {
79666
77910
  readdirSync as readdirSync7,
79667
77911
  unlinkSync as unlinkSync19,
79668
77912
  existsSync as existsSync36,
79669
- renameSync as renameSync14
77913
+ renameSync as renameSync15
79670
77914
  } from "node:fs";
79671
77915
  import { join as join40, resolve as resolve8 } from "node:path";
79672
77916
  import { homedir as homedir13 } from "node:os";
@@ -79679,6 +77923,14 @@ function recordPath(id) {
79679
77923
  function ensureDir4() {
79680
77924
  mkdirSync29(registryDir(), { recursive: true });
79681
77925
  }
77926
+ function writeRecord(record) {
77927
+ ensureDir4();
77928
+ const target = recordPath(record.id);
77929
+ const tmp = `${target}.tmp${process.pid}`;
77930
+ writeFileSync30(tmp, JSON.stringify(record, null, 2) + `
77931
+ `, { mode: 384 });
77932
+ renameSync15(tmp, target);
77933
+ }
79682
77934
  function readRecord(id) {
79683
77935
  const path2 = recordPath(id);
79684
77936
  try {
@@ -79702,6 +77954,18 @@ function listRecords() {
79702
77954
  }
79703
77955
  return records;
79704
77956
  }
77957
+ function touchHeartbeat(id, onAfterRead) {
77958
+ const rec = readRecord(id);
77959
+ if (!rec)
77960
+ return;
77961
+ onAfterRead?.();
77962
+ if (!recordExists(id))
77963
+ return;
77964
+ writeRecord({ ...rec, heartbeatAt: new Date().toISOString() });
77965
+ }
77966
+ function recordExists(id) {
77967
+ return existsSync36(recordPath(id));
77968
+ }
79705
77969
 
79706
77970
  // worktree-watch-cwds.ts
79707
77971
  import { realpathSync as realpathSync3 } from "node:fs";
@@ -79713,12 +77977,16 @@ function defaultDeriveName(agentDir) {
79713
77977
  const leaf = basename7(agentDir).trim();
79714
77978
  return leaf;
79715
77979
  }
79716
- function ownedWorktreeCwds(opts) {
79717
- let resolved = opts.self != null ? opts.self : "";
79718
- if (resolved === "" && opts.agentDir != null && opts.agentDir !== "") {
79719
- const derive = opts.deriveName ?? defaultDeriveName;
79720
- resolved = derive(opts.agentDir) || "";
77980
+ function resolveOwnerIdentity(self, agentDir, deriveName) {
77981
+ let resolved = self != null ? self : "";
77982
+ if (resolved === "" && agentDir != null && agentDir !== "") {
77983
+ const derive = deriveName ?? defaultDeriveName;
77984
+ resolved = derive(agentDir) || "";
79721
77985
  }
77986
+ return resolved;
77987
+ }
77988
+ function ownedWorktreeCwds(opts) {
77989
+ const resolved = resolveOwnerIdentity(opts.self, opts.agentDir, opts.deriveName);
79722
77990
  if (resolved === "") {
79723
77991
  if (!identityEscalated) {
79724
77992
  identityEscalated = true;
@@ -79739,6 +78007,59 @@ function ownedWorktreeCwds(opts) {
79739
78007
  return [];
79740
78008
  }
79741
78009
  }
78010
+ var DEFAULT_HEARTBEAT_REFRESH_INTERVAL_MS = 2 * 60000;
78011
+ function refreshOwnedWorktreeHeartbeats(opts) {
78012
+ const identity = resolveOwnerIdentity(opts.self, opts.agentDir, opts.deriveName);
78013
+ if (identity === "")
78014
+ return 0;
78015
+ const nowMs2 = (opts.now ?? Date.now)();
78016
+ const minInterval = opts.minRefreshIntervalMs ?? DEFAULT_HEARTBEAT_REFRESH_INTERVAL_MS;
78017
+ let records;
78018
+ try {
78019
+ records = opts.listRecords();
78020
+ } catch {
78021
+ return 0;
78022
+ }
78023
+ let touched = 0;
78024
+ for (const r of records) {
78025
+ if (r.ownerAgent !== identity)
78026
+ continue;
78027
+ if (minInterval > 0 && r.heartbeatAt != null) {
78028
+ const age = nowMs2 - new Date(r.heartbeatAt).getTime();
78029
+ if (Number.isFinite(age) && age >= 0 && age < minInterval)
78030
+ continue;
78031
+ }
78032
+ try {
78033
+ opts.touchHeartbeat(r.id);
78034
+ touched++;
78035
+ } catch (err) {
78036
+ opts.log?.(`worktree heartbeat refresh failed for ${r.id}: ${err.message}`);
78037
+ }
78038
+ }
78039
+ return touched;
78040
+ }
78041
+ function makeWorktreeWatchProvider(opts) {
78042
+ return () => {
78043
+ refreshOwnedWorktreeHeartbeats({
78044
+ self: opts.self,
78045
+ agentDir: opts.agentDir,
78046
+ listRecords: opts.listRecords,
78047
+ touchHeartbeat: opts.touchHeartbeat,
78048
+ minRefreshIntervalMs: opts.minRefreshIntervalMs,
78049
+ now: opts.now,
78050
+ deriveName: opts.deriveName,
78051
+ log: opts.log
78052
+ });
78053
+ return ownedWorktreeCwds({
78054
+ self: opts.self,
78055
+ agentDir: opts.agentDir,
78056
+ listRecords: opts.listRecords,
78057
+ realpath: opts.realpath,
78058
+ deriveName: opts.deriveName,
78059
+ log: opts.log
78060
+ });
78061
+ };
78062
+ }
79742
78063
 
79743
78064
  // gateway/gateway.ts
79744
78065
  init_boot_card();
@@ -79775,7 +78096,7 @@ function determineRestartReason(opts) {
79775
78096
  init_boot_card();
79776
78097
 
79777
78098
  // gateway/update-announce.ts
79778
- import { existsSync as existsSync41, mkdirSync as mkdirSync33, openSync as openSync8, closeSync as closeSync8, readFileSync as readFileSync44 } from "node:fs";
78099
+ import { existsSync as existsSync41, mkdirSync as mkdirSync33, openSync as openSync9, closeSync as closeSync9, readFileSync as readFileSync44 } from "node:fs";
79779
78100
  import { join as join45 } from "node:path";
79780
78101
  import { homedir as homedir15 } from "node:os";
79781
78102
 
@@ -79978,8 +78299,8 @@ function claimUpdateAnnouncement(requestId, opts = {}) {
79978
78299
  const safeId = requestId.replace(/[^A-Za-z0-9_.-]/g, "_").slice(0, 200);
79979
78300
  const path2 = join45(dir, safeId);
79980
78301
  try {
79981
- const fd = openSync8(path2, "wx");
79982
- closeSync8(fd);
78302
+ const fd = openSync9(path2, "wx");
78303
+ closeSync9(fd);
79983
78304
  return true;
79984
78305
  } catch {
79985
78306
  return false;
@@ -80202,17 +78523,17 @@ import { join as join47 } from "node:path";
80202
78523
 
80203
78524
  // ../src/issues/store.ts
80204
78525
  import {
80205
- closeSync as closeSync9,
78526
+ closeSync as closeSync10,
80206
78527
  existsSync as existsSync42,
80207
78528
  mkdirSync as mkdirSync34,
80208
- openSync as openSync9,
78529
+ openSync as openSync10,
80209
78530
  readdirSync as readdirSync9,
80210
78531
  readFileSync as readFileSync46,
80211
- renameSync as renameSync17,
78532
+ renameSync as renameSync18,
80212
78533
  statSync as statSync11,
80213
78534
  unlinkSync as unlinkSync20,
80214
78535
  writeFileSync as writeFileSync36,
80215
- writeSync as writeSync5
78536
+ writeSync as writeSync6
80216
78537
  } from "node:fs";
80217
78538
  import { join as join46 } from "node:path";
80218
78539
  import { randomBytes as randomBytes7 } from "node:crypto";
@@ -80295,7 +78616,7 @@ function writeAll(stateDir, events) {
80295
78616
  `) + `
80296
78617
  `;
80297
78618
  writeFileSync36(tmp, body, "utf-8");
80298
- renameSync17(tmp, path2);
78619
+ renameSync18(tmp, path2);
80299
78620
  }
80300
78621
  var ORPHAN_TMP_TTL_MS = 60000;
80301
78622
  var TMP_PREFIX = `${ISSUES_FILE}.tmp-`;
@@ -80327,9 +78648,9 @@ function withLock(stateDir, fn) {
80327
78648
  let fd = null;
80328
78649
  while (fd === null) {
80329
78650
  try {
80330
- fd = openSync9(lockPath, "wx");
78651
+ fd = openSync10(lockPath, "wx");
80331
78652
  try {
80332
- writeSync5(fd, String(process.pid));
78653
+ writeSync6(fd, String(process.pid));
80333
78654
  } catch {}
80334
78655
  } catch (err) {
80335
78656
  const e = err;
@@ -80347,7 +78668,7 @@ function withLock(stateDir, fn) {
80347
78668
  return fn();
80348
78669
  } finally {
80349
78670
  try {
80350
- closeSync9(fd);
78671
+ closeSync10(fd);
80351
78672
  } catch {}
80352
78673
  try {
80353
78674
  unlinkSync20(lockPath);
@@ -81184,7 +79505,7 @@ function isDestructiveBashCommand(command) {
81184
79505
  return true;
81185
79506
  if (/>\s*\/(dev|etc|boot|sys|proc)\b/.test(c))
81186
79507
  return true;
81187
- if (/\bgit\b/.test(c) && /(push\b[^|;&]*(--force|-f\b|--force-with-lease)|push\s+[^\s]*\s+\+|reset\s+--hard|clean\s+-[a-z]*[fd]|filter-branch|reflog\s+expire|update-ref\s+-d|branch\s+-d{1,2}\b|checkout\s+--\s|restore\b)/.test(c))
79508
+ if (/\bgit\b/.test(c) && /(push\b[^|;&]*(--force|-f\b|--force-with-lease)|push\s+[^\s]*\s+\+|reset\s+--hard|clean\s+-[a-z]*[fd]|filter-branch|reflog\s+expire|update-ref\s+-d|branch\s+-d{1,2}\b|checkout\b[^|;&]*(\s-f\b|\s--force\b|\s--(\s|$)|\s\.(\s|$|\/))|stash\s+(drop|clear|pop)\b|restore\b)/.test(c))
81188
79509
  return true;
81189
79510
  if (/(^|\s|;|&&|\|\||\()(shutdown|reboot|halt|poweroff|kill|killall|pkill)\b/.test(c))
81190
79511
  return true;
@@ -82069,10 +80390,10 @@ init_auth_snapshot_format2();
82069
80390
 
82070
80391
  // gateway/turn-active-marker.ts
82071
80392
  import {
82072
- closeSync as closeSync10,
80393
+ closeSync as closeSync11,
82073
80394
  existsSync as existsSync46,
82074
80395
  mkdirSync as mkdirSync37,
82075
- openSync as openSync10,
80396
+ openSync as openSync11,
82076
80397
  readFileSync as readFileSync50,
82077
80398
  statSync as statSync13,
82078
80399
  unlinkSync as unlinkSync21,
@@ -82097,8 +80418,8 @@ function touchTurnActiveMarker2(stateDir) {
82097
80418
  utimesSync2(path2, now, now);
82098
80419
  } catch {
82099
80420
  try {
82100
- const fd = openSync10(path2, "r+");
82101
- closeSync10(fd);
80421
+ const fd = openSync11(path2, "r+");
80422
+ closeSync11(fd);
82102
80423
  } catch {}
82103
80424
  }
82104
80425
  }
@@ -82149,10 +80470,10 @@ function readTurnActiveMarkerAgeMs(stateDir, now) {
82149
80470
  }
82150
80471
 
82151
80472
  // ../src/build-info.ts
82152
- var VERSION = "0.18.12";
82153
- var COMMIT_SHA = "bf47fc66";
82154
- var COMMIT_DATE = "2026-07-11T12:54:09Z";
82155
- var LATEST_PR = 3124;
80473
+ var VERSION = "0.18.13";
80474
+ var COMMIT_SHA = "58d180bf";
80475
+ var COMMIT_DATE = "2026-07-12T00:08:55Z";
80476
+ var LATEST_PR = 3156;
82156
80477
  var COMMITS_AHEAD_OF_TAG = 0;
82157
80478
 
82158
80479
  // gateway/boot-version.ts
@@ -83512,7 +81833,7 @@ function selectResumeBuilder(endedVia, opts) {
83512
81833
  }
83513
81834
 
83514
81835
  // gateway/bridge-dead-watchdog.ts
83515
- import { readFileSync as readFileSync52, writeFileSync as writeFileSync41, renameSync as renameSync18, unlinkSync as unlinkSync22 } from "node:fs";
81836
+ import { readFileSync as readFileSync52, writeFileSync as writeFileSync41, renameSync as renameSync19, unlinkSync as unlinkSync22 } from "node:fs";
83516
81837
 
83517
81838
  // gateway/cron-session.ts
83518
81839
  var CRON_IDENTITY_SUFFIX2 = "-cron";
@@ -83567,7 +81888,7 @@ function readFreshCrashLogTail(path2, opts = {}) {
83567
81888
  function writeBridgeDeadEscalationMarker(path2, marker) {
83568
81889
  const tmp = `${path2}.tmp-${process.pid}-${Date.now()}`;
83569
81890
  writeFileSync41(tmp, JSON.stringify(marker), "utf8");
83570
- renameSync18(tmp, path2);
81891
+ renameSync19(tmp, path2);
83571
81892
  }
83572
81893
  function consumeBridgeDeadEscalationMarker(path2, nowMs2 = Date.now(), maxAgeMs = ESCALATION_MARKER_MAX_AGE_MS) {
83573
81894
  let marker = null;
@@ -84299,7 +82620,7 @@ function readAccessFile() {
84299
82620
  if (err.code === "ENOENT")
84300
82621
  return defaultAccess();
84301
82622
  try {
84302
- renameSync19(ACCESS_FILE, `${ACCESS_FILE}.corrupt-${Date.now()}`);
82623
+ renameSync20(ACCESS_FILE, `${ACCESS_FILE}.corrupt-${Date.now()}`);
84303
82624
  } catch {}
84304
82625
  process.stderr.write(`telegram gateway: access.json is corrupt, moved aside. Starting fresh.
84305
82626
  `);
@@ -84347,7 +82668,7 @@ function saveAccess(a) {
84347
82668
  const tmp = ACCESS_FILE + ".tmp";
84348
82669
  writeFileSync43(tmp, JSON.stringify(a, null, 2) + `
84349
82670
  `, { mode: 384 });
84350
- renameSync19(tmp, ACCESS_FILE);
82671
+ renameSync20(tmp, ACCESS_FILE);
84351
82672
  }
84352
82673
  function pruneExpired(a) {
84353
82674
  const now = Date.now();
@@ -84540,11 +82861,11 @@ try {
84540
82861
  writeFileSync43(pendingEnvTmp, lines.join(`
84541
82862
  `) + `
84542
82863
  `, { mode: 384 });
84543
- renameSync19(pendingEnvTmp, pendingEnvPath);
82864
+ renameSync20(pendingEnvTmp, pendingEnvPath);
84544
82865
  process.stderr.write(`telegram gateway: pending-turn env written to ${pendingEnvPath} turnKey=${pending2.turn_key} endedVia=${pending2.ended_via ?? "open"}
84545
82866
  `);
84546
82867
  } else if (existsSync50(pendingEnvPath)) {
84547
- rmSync5(pendingEnvPath, { force: true });
82868
+ rmSync6(pendingEnvPath, { force: true });
84548
82869
  process.stderr.write(`telegram gateway: pending-turn env cleared (clean previous shutdown)
84549
82870
  `);
84550
82871
  }
@@ -84640,10 +82961,10 @@ function checkApprovals() {
84640
82961
  }
84641
82962
  for (const senderId of files) {
84642
82963
  const file = join54(APPROVED_DIR, senderId);
84643
- bot.api.sendMessage(senderId, "Paired! Say hi to Claude.").then(() => rmSync5(file, { force: true }), (err) => {
82964
+ bot.api.sendMessage(senderId, "Paired! Say hi to Claude.").then(() => rmSync6(file, { force: true }), (err) => {
84644
82965
  process.stderr.write(`telegram gateway: failed to send approval confirm: ${err}
84645
82966
  `);
84646
- rmSync5(file, { force: true });
82967
+ rmSync6(file, { force: true });
84647
82968
  });
84648
82969
  }
84649
82970
  }
@@ -84747,7 +83068,7 @@ var OBLIGATION_STORE_PATH = join54(STATE_DIR, "obligations.json");
84747
83068
  var obligationStoreFs = {
84748
83069
  readFileSync: (p) => readFileSync54(p, "utf8"),
84749
83070
  writeFileSync: (p, d) => writeFileSync43(p, d),
84750
- renameSync: (a, b) => renameSync19(a, b),
83071
+ renameSync: (a, b) => renameSync20(a, b),
84751
83072
  existsSync: (p) => existsSync50(p)
84752
83073
  };
84753
83074
  var obligationLedger = new ObligationLedger(OBLIGATION_REPRESENT_MAX, {
@@ -85492,7 +83813,7 @@ function emitTurnRecord(turn, endedAt) {
85492
83813
  return;
85493
83814
  }
85494
83815
  },
85495
- rename: (from, to) => renameSync19(from, to)
83816
+ rename: (from, to) => renameSync20(from, to)
85496
83817
  });
85497
83818
  appendFileSync6(turnsPath, rec);
85498
83819
  } catch {}
@@ -85847,6 +84168,16 @@ var rawRobustApiCall = createRetryApiCall2({
85847
84168
  });
85848
84169
  var robustApiCall = (fn, opts) => sendGate.gate(() => rawRobustApiCall(fn, opts), opts);
85849
84170
  var swallowingApiCall = createSwallowingRetryApiCall(robustApiCall, (line) => process.stderr.write(line));
84171
+ var gatedSetMessageReaction = (chatId, messageId, reaction) => robustApiCall(() => lockedBot.api.setMessageReaction(chatId, messageId, reaction), {
84172
+ chat_id: chatId,
84173
+ verb: "set-message-reaction",
84174
+ priorityClass: "cosmetic"
84175
+ });
84176
+ var sendReaction = (chatId, messageId, emoji) => gatedSetMessageReaction(chatId, messageId, [{ type: "emoji", emoji }]);
84177
+ var redactAuthCodeApi = {
84178
+ deleteMessage: (chatId, messageId) => bot.api.deleteMessage(chatId, messageId),
84179
+ setMessageReaction: (chatId, messageId, reaction) => gatedSetMessageReaction(chatId, messageId, reaction)
84180
+ };
85850
84181
  var recordTypingFloodWait = makeFloodWaitRecorder2(FLOOD_STATE_PATH);
85851
84182
  var nonEssentialApiCall = createRetryApiCall2({
85852
84183
  maxRetries: 1,
@@ -86955,7 +85286,7 @@ var STATUS_PIN_STORE_PATH = join54(STATE_DIR, "status-pins.json");
86955
85286
  var statusPinStoreFs = {
86956
85287
  readFileSync: (p) => readFileSync54(p, "utf8"),
86957
85288
  writeFileSync: (p, d) => writeFileSync43(p, d),
86958
- renameSync: (a, b) => renameSync19(a, b),
85289
+ renameSync: (a, b) => renameSync20(a, b),
86959
85290
  existsSync: (p) => existsSync50(p)
86960
85291
  };
86961
85292
  var statusPinPersistEnabled = !STATIC && PIN_STATUS_WHILE_WORKING;
@@ -86963,7 +85294,7 @@ var ACTIVITY_CARD_STORE_PATH = join54(STATE_DIR, "activity-cards-pending.json");
86963
85294
  var activityCardStoreFs = {
86964
85295
  readFileSync: (p) => readFileSync54(p, "utf8"),
86965
85296
  writeFileSync: (p, d) => writeFileSync43(p, d),
86966
- renameSync: (a, b) => renameSync19(a, b),
85297
+ renameSync: (a, b) => renameSync20(a, b),
86967
85298
  existsSync: (p) => existsSync50(p)
86968
85299
  };
86969
85300
  var activityCardPersistEnabled = !STATIC;
@@ -86971,7 +85302,7 @@ var QUEUED_CARD_STORE_PATH = join54(STATE_DIR, "queued-cards-pending.json");
86971
85302
  var queuedCardStoreFs = {
86972
85303
  readFileSync: (p) => readFileSync54(p, "utf8"),
86973
85304
  writeFileSync: (p, d) => writeFileSync43(p, d),
86974
- renameSync: (a, b) => renameSync19(a, b),
85305
+ renameSync: (a, b) => renameSync20(a, b),
86975
85306
  existsSync: (p) => existsSync50(p)
86976
85307
  };
86977
85308
  var queuedCardPersistEnabled = !STATIC;
@@ -87703,7 +86034,7 @@ var inboundSpool = STATIC ? undefined : createInboundSpool({
87703
86034
  appendFileSync: (p, d) => appendFileSync6(p, d),
87704
86035
  readFileSync: (p) => readFileSync54(p, "utf8"),
87705
86036
  writeFileSync: (p, d) => writeFileSync43(p, d),
87706
- renameSync: (a, b) => renameSync19(a, b),
86037
+ renameSync: (a, b) => renameSync20(a, b),
87707
86038
  existsSync: (p) => existsSync50(p),
87708
86039
  statSizeSync: (p) => statSync16(p).size
87709
86040
  },
@@ -88467,9 +86798,9 @@ var ipcServer = createIpcServer({
88467
86798
  });
88468
86799
  },
88469
86800
  async onRolloutStatusPost(client3, msg) {
88470
- const self2 = process.env.SWITCHROOM_AGENT_NAME;
88471
- if (self2 && msg.agentName !== self2) {
88472
- process.stderr.write(`telegram gateway: rollout_status_post rejected \u2014 agent mismatch (${msg.agentName} != ${self2})
86801
+ const self = process.env.SWITCHROOM_AGENT_NAME;
86802
+ if (self && msg.agentName !== self) {
86803
+ process.stderr.write(`telegram gateway: rollout_status_post rejected \u2014 agent mismatch (${msg.agentName} != ${self})
88473
86804
  `);
88474
86805
  try {
88475
86806
  client3.send({ type: "rollout_status_posted", requestId: msg.requestId, ok: false, reason: "agent mismatch" });
@@ -88502,9 +86833,9 @@ var ipcServer = createIpcServer({
88502
86833
  }
88503
86834
  },
88504
86835
  onRolloutStatusEdit(_client, msg) {
88505
- const self2 = process.env.SWITCHROOM_AGENT_NAME;
88506
- if (self2 && msg.agentName !== self2) {
88507
- process.stderr.write(`telegram gateway: rollout_status_edit rejected \u2014 agent mismatch (${msg.agentName} != ${self2})
86836
+ const self = process.env.SWITCHROOM_AGENT_NAME;
86837
+ if (self && msg.agentName !== self) {
86838
+ process.stderr.write(`telegram gateway: rollout_status_edit rejected \u2014 agent mismatch (${msg.agentName} != ${self})
88508
86839
  `);
88509
86840
  return;
88510
86841
  }
@@ -88542,9 +86873,9 @@ var ipcServer = createIpcServer({
88542
86873
  }
88543
86874
  },
88544
86875
  onSendOutbound(_client, msg) {
88545
- const self2 = process.env.SWITCHROOM_AGENT_NAME;
88546
- if (self2 && msg.agentName !== self2) {
88547
- process.stderr.write(`telegram gateway: send_outbound rejected \u2014 agent mismatch (${msg.agentName} != ${self2})
86876
+ const self = process.env.SWITCHROOM_AGENT_NAME;
86877
+ if (self && msg.agentName !== self) {
86878
+ process.stderr.write(`telegram gateway: send_outbound rejected \u2014 agent mismatch (${msg.agentName} != ${self})
88548
86879
  `);
88549
86880
  return;
88550
86881
  }
@@ -88571,9 +86902,9 @@ var ipcServer = createIpcServer({
88571
86902
  fireFleetAutoFallback(msg.agentName, untilMs);
88572
86903
  },
88573
86904
  onQueryPendingPermission(client3, msg) {
88574
- const self2 = process.env.SWITCHROOM_AGENT_NAME;
88575
- if (self2 && msg.agentName !== self2) {
88576
- process.stderr.write(`telegram gateway: query_pending_permission rejected \u2014 agent mismatch (${msg.agentName} != ${self2})
86905
+ const self = process.env.SWITCHROOM_AGENT_NAME;
86906
+ if (self && msg.agentName !== self) {
86907
+ process.stderr.write(`telegram gateway: query_pending_permission rejected \u2014 agent mismatch (${msg.agentName} != ${self})
88577
86908
  `);
88578
86909
  try {
88579
86910
  client3.send({ type: "pending_permission_status", correlationId: msg.correlationId, pending: false });
@@ -88597,8 +86928,8 @@ var ipcServer = createIpcServer({
88597
86928
  onCheckPreApproved(client3, msg) {
88598
86929
  let preApproved = false;
88599
86930
  try {
88600
- const self2 = process.env.SWITCHROOM_AGENT_NAME;
88601
- if (!self2 || msg.agentName === self2) {
86931
+ const self = process.env.SWITCHROOM_AGENT_NAME;
86932
+ if (!self || msg.agentName === self) {
88602
86933
  preApproved = isDiffPreApprovedLive(msg.agentName, msg.unifiedDiff);
88603
86934
  }
88604
86935
  } catch (err) {
@@ -88614,9 +86945,9 @@ var ipcServer = createIpcServer({
88614
86945
  }
88615
86946
  },
88616
86947
  onPostSkillProposal(_client, msg) {
88617
- const self2 = process.env.SWITCHROOM_AGENT_NAME;
88618
- if (self2 && msg.agentName !== self2) {
88619
- process.stderr.write(`telegram gateway: post_skill_proposal rejected \u2014 agent mismatch (${msg.agentName} != ${self2})
86948
+ const self = process.env.SWITCHROOM_AGENT_NAME;
86949
+ if (self && msg.agentName !== self) {
86950
+ process.stderr.write(`telegram gateway: post_skill_proposal rejected \u2014 agent mismatch (${msg.agentName} != ${self})
88620
86951
  `);
88621
86952
  return;
88622
86953
  }
@@ -88850,10 +87181,11 @@ async function executeSendChecklist(args) {
88850
87181
  const replyTo = args.reply_to != null ? Number(args.reply_to) : undefined;
88851
87182
  const protectContent = args.protect_content === true;
88852
87183
  assertAllowedChat(chat_id);
87184
+ const { title: redactedTitle, tasks: redactedTasks } = redactChecklistFields(title, tasks, (t) => redactOutboundText(t, "send_checklist"));
88853
87185
  const sent = await rawSendChecklist({
88854
87186
  chat_id,
88855
- title,
88856
- tasks,
87187
+ title: redactedTitle,
87188
+ tasks: redactedTasks,
88857
87189
  ...threadId != null ? { message_thread_id: threadId } : {},
88858
87190
  ...replyTo != null ? { reply_to_message_id: replyTo } : {},
88859
87191
  ...protectContent ? { protect_content: true } : {}
@@ -88911,7 +87243,8 @@ async function executeUpdateChecklist(args) {
88911
87243
  const title = args.title;
88912
87244
  const tasks = args.tasks;
88913
87245
  assertAllowedChat(chat_id);
88914
- await rawEditMessageChecklist({ chat_id, message_id, title, tasks });
87246
+ const { title: redactedTitle, tasks: redactedTasks } = redactChecklistFields(title, tasks, (t) => redactOutboundText(t, "update_checklist"));
87247
+ await rawEditMessageChecklist({ chat_id, message_id, title: redactedTitle, tasks: redactedTasks });
88915
87248
  process.stderr.write(`telegram gateway: update_checklist: updated chatId=${chat_id} messageId=${message_id}
88916
87249
  `);
88917
87250
  return { content: [{ type: "text", text: `checklist updated (id: ${message_id})` }] };
@@ -89235,8 +87568,9 @@ ${url}`;
89235
87568
  const summary = validationErrors.map((e) => `${e.path}.${e.field}: ${e.reason}`).join("; ");
89236
87569
  throw new Error(`inline_keyboard validation failed: ${summary}`);
89237
87570
  }
89238
- replyButtonMeta = extractAgentButtonMeta(rawKeyboard);
89239
- replyMarkup = { inline_keyboard: wrapAgentCallbacks(rawKeyboard) };
87571
+ const redactedKeyboard = redactAgentKeyboard(rawKeyboard, (s) => redactOutboundText(s, "reply_inline_keyboard"));
87572
+ replyButtonMeta = extractAgentButtonMeta(redactedKeyboard);
87573
+ replyMarkup = { inline_keyboard: wrapAgentCallbacks(redactedKeyboard) };
89240
87574
  }
89241
87575
  if (useOnDemandButton && voiceOutPlan.ttsChunks.length > 0 && voiceOutPlan.ttsChunks[0].length > 0) {
89242
87576
  if (!mayInjectListenButton(rawKeyboard)) {
@@ -89724,6 +88058,9 @@ async function executeProgressUpdate(args) {
89724
88058
  async function executeAskUser(rawArgs) {
89725
88059
  const args = validateAskUserArgs(rawArgs);
89726
88060
  assertAllowedChat(args.chatId);
88061
+ const scrubbed = redactAskUserFields(args.question, args.options, (t) => redactOutboundText(t, "ask_user"));
88062
+ args.question = scrubbed.question;
88063
+ args.options = scrubbed.options;
89727
88064
  const threadId = resolveThreadId(args.chatId, args.threadId);
89728
88065
  let replyTo = args.replyTo;
89729
88066
  if (replyTo == null && HISTORY_ENABLED) {
@@ -90474,9 +88811,7 @@ async function executeReact(args) {
90474
88811
  if (!args.emoji)
90475
88812
  throw new Error("react: emoji is required");
90476
88813
  assertAllowedChat(String(args.chat_id ?? ""));
90477
- await lockedBot.api.setMessageReaction(String(args.chat_id ?? ""), Number(args.message_id), [
90478
- { type: "emoji", emoji: args.emoji }
90479
- ]);
88814
+ await sendReaction(String(args.chat_id ?? ""), Number(args.message_id), args.emoji);
90480
88815
  return { content: [{ type: "text", text: "reacted" }] };
90481
88816
  }
90482
88817
  async function executeDownloadAttachment(args) {
@@ -91869,6 +90204,7 @@ function handleSessionEvent(ev) {
91869
90204
  }
91870
90205
  }
91871
90206
  function handlePtyPartial(text5) {
90207
+ text5 = redactOutboundText(text5, "pty_preview");
91872
90208
  const turn = currentTurn;
91873
90209
  const state4 = {
91874
90210
  currentSessionChatId: turn?.sessionChatId ?? null,
@@ -92076,9 +90412,7 @@ function maybeEarlyAckReaction(ctx, from) {
92076
90412
  const access = loadAccess();
92077
90413
  if (!access.allowFrom.includes(String(from.id)))
92078
90414
  return;
92079
- bot.api.setMessageReaction(chatId, msgId, [
92080
- { type: "emoji", emoji: "\uD83D\uDC40" }
92081
- ]).catch(() => {});
90415
+ sendReaction(chatId, msgId, "\uD83D\uDC40").catch(() => {});
92082
90416
  logStreamingEvent({ kind: "early_ack_reaction", chatId, messageId: msgId, emoji: "\uD83D\uDC40" });
92083
90417
  emitChatAction(chatId, null, "typing");
92084
90418
  }
@@ -92159,9 +90493,7 @@ async function handleInbound(ctx, text5, downloadImage, attachment, extraAttachm
92159
90493
  `);
92160
90494
  if (inFlight) {
92161
90495
  if (msgId != null) {
92162
- bot.api.setMessageReaction(chat_id, msgId, [
92163
- { type: "emoji", emoji: "\u26A1" }
92164
- ]).catch(() => {});
90496
+ sendReaction(chat_id, msgId, "\u26A1").catch(() => {});
92165
90497
  }
92166
90498
  await executeHaltNow("stop-keyword");
92167
90499
  }
@@ -92185,9 +90517,7 @@ async function handleInbound(ctx, text5, downloadImage, attachment, extraAttachm
92185
90517
  process.stderr.write(`telegram gateway: interrupt-marker received chat_id=${chat_id} agent=${agentName3 ?? "-"} body_len=${interrupt.body.length} empty=${interrupt.emptyBody} defer=${deferInterrupt} in_flight=${toolFlightTracker.inFlightCount()}
92186
90518
  `);
92187
90519
  if (msgId != null) {
92188
- bot.api.setMessageReaction(chat_id, msgId, [
92189
- { type: "emoji", emoji: "\u26A1" }
92190
- ]).catch(() => {});
90520
+ sendReaction(chat_id, msgId, "\u26A1").catch(() => {});
92191
90521
  }
92192
90522
  if (interrupt.emptyBody) {
92193
90523
  await executeHaltNow("bang-empty");
@@ -92258,9 +90588,7 @@ async function handleInbound(ctx, text5, downloadImage, attachment, extraAttachm
92258
90588
  });
92259
90589
  if (msgId != null) {
92260
90590
  const emoji = behavior === "allow" ? "\u2705" : "\u274C";
92261
- bot.api.setMessageReaction(chat_id, msgId, [
92262
- { type: "emoji", emoji }
92263
- ]).catch(() => {});
90591
+ sendReaction(chat_id, msgId, emoji).catch(() => {});
92264
90592
  }
92265
90593
  return;
92266
90594
  }
@@ -92284,7 +90612,7 @@ The fleet's active account hasn't changed. Send \`/auth use ${escapeHtmlForTg2(p
92284
90612
  } catch (err) {
92285
90613
  await switchroomReply(ctx, `**/auth add code failed:** ${escapeHtmlForTg2(err?.message ?? String(err))}`, { html: true });
92286
90614
  }
92287
- redactAuthCodeMessage(bot.api, chat_id, msgId ?? null, (line) => process.stderr.write(line));
90615
+ redactAuthCodeMessage(redactAuthCodeApi, chat_id, msgId ?? null, (line) => process.stderr.write(line));
92288
90616
  return;
92289
90617
  }
92290
90618
  cancelAccountAuthSession(pendingAdd);
@@ -92296,33 +90624,33 @@ The fleet's active account hasn't changed. Send \`/auth use ${escapeHtmlForTg2(p
92296
90624
  if (elapsed < REAUTH_INTERCEPT_TTL_MS) {
92297
90625
  if (pendingLoop.submitting) {
92298
90626
  await switchroomReply(ctx, "_Still finishing the previous paste \u2014 one moment._", { html: true });
92299
- redactAuthCodeMessage(bot.api, chat_id, msgId ?? null, (line) => process.stderr.write(line));
90627
+ redactAuthCodeMessage(redactAuthCodeApi, chat_id, msgId ?? null, (line) => process.stderr.write(line));
92300
90628
  return;
92301
90629
  }
92302
90630
  const result2 = await submitLoopbackRedirect(pendingLoop, text5.trim());
92303
90631
  if (result2.ok) {
92304
90632
  pendingLoopbackFlows.delete(interceptKey);
92305
90633
  await switchroomReply(ctx, `\u2713 ${pendingLoop.provider === "google" ? "Google" : "Microsoft"} account \`${escapeHtmlForTg2(pendingLoop.email)}\` registered with the auth-broker.`, { html: true });
92306
- redactAuthCodeMessage(bot.api, chat_id, msgId ?? null, (line) => process.stderr.write(line));
90634
+ redactAuthCodeMessage(redactAuthCodeApi, chat_id, msgId ?? null, (line) => process.stderr.write(line));
92307
90635
  return;
92308
90636
  }
92309
90637
  if (result2.retryable) {
92310
90638
  await switchroomReply(ctx, `**Paste not accepted:** ${escapeHtmlForTg2(result2.reason)}
92311
90639
  Re-open the consent URL, approve, and paste the full \`127.0.0.1\` URL from your address bar. \`/auth ${pendingLoop.provider} cancel\` to abort.`, { html: true });
92312
- redactAuthCodeMessage(bot.api, chat_id, msgId ?? null, (line) => process.stderr.write(line));
90640
+ redactAuthCodeMessage(redactAuthCodeApi, chat_id, msgId ?? null, (line) => process.stderr.write(line));
92313
90641
  return;
92314
90642
  }
92315
90643
  cancelLoopbackFlow(pendingLoop);
92316
90644
  pendingLoopbackFlows.delete(interceptKey);
92317
90645
  await switchroomReply(ctx, `**/auth ${pendingLoop.provider} add failed:** ${escapeHtmlForTg2(result2.reason)}`, { html: true });
92318
- redactAuthCodeMessage(bot.api, chat_id, msgId ?? null, (line) => process.stderr.write(line));
90646
+ redactAuthCodeMessage(redactAuthCodeApi, chat_id, msgId ?? null, (line) => process.stderr.write(line));
92319
90647
  return;
92320
90648
  }
92321
90649
  cancelLoopbackFlow(pendingLoop);
92322
90650
  pendingLoopbackFlows.delete(interceptKey);
92323
90651
  }
92324
90652
  if (shouldConsumeLoopbackPaste(text5)) {
92325
- redactAuthCodeMessage(bot.api, chat_id, msgId ?? null, (line) => process.stderr.write(line));
90653
+ redactAuthCodeMessage(redactAuthCodeApi, chat_id, msgId ?? null, (line) => process.stderr.write(line));
92326
90654
  await switchroomReply(ctx, "_That looked like an OAuth redirect/code, so I removed it from chat and did not forward it. If a Google/Microsoft account add is in progress, re-run the add command and paste the fresh " + "`127.0.0.1` URL \u2014 the previous code may have expired._", { html: true });
92327
90655
  return;
92328
90656
  }
@@ -92346,7 +90674,7 @@ ${preBlock(formatSwitchroomOutput(errorText))}`, { html: true });
92346
90674
  await switchroomReply(ctx, formatted.text, { html: true });
92347
90675
  }
92348
90676
  }
92349
- redactAuthCodeMessage(bot.api, chat_id, msgId ?? null, (line) => process.stderr.write(line));
90677
+ redactAuthCodeMessage(redactAuthCodeApi, chat_id, msgId ?? null, (line) => process.stderr.write(line));
92350
90678
  return;
92351
90679
  }
92352
90680
  pendingReauthFlows.delete(interceptKey);
@@ -92635,9 +90963,9 @@ ${preBlock(write.output)}`;
92635
90963
  }
92636
90964
  if (access.statusReactions !== false) {
92637
90965
  if (isSteering) {
92638
- bot.api.setMessageReaction(chat_id, msgId, [{ type: "emoji", emoji: "\uD83E\uDD1D" }]).catch(() => {});
90966
+ sendReaction(chat_id, msgId, "\uD83E\uDD1D").catch(() => {});
92639
90967
  } else if (priorTurnInFlight) {
92640
- bot.api.setMessageReaction(chat_id, msgId, [{ type: "emoji", emoji: "\uD83D\uDC40" }]).catch(() => {});
90968
+ sendReaction(chat_id, msgId, "\uD83D\uDC40").catch(() => {});
92641
90969
  logStreamingEvent({ kind: "inbound_ack", chatId: chat_id, messageId: msgId, ackDelayMs: Date.now() - inboundReceivedAt });
92642
90970
  } else {
92643
90971
  const sKey = streamKey2(chat_id, messageThreadId);
@@ -92653,9 +90981,7 @@ ${preBlock(write.output)}`;
92653
90981
  }
92654
90982
  const ctrlTurnToken = `${chat_id}:${msgId}`;
92655
90983
  const ctrl = new StatusReactionController(async (emoji) => {
92656
- await bot.api.setMessageReaction(chat_id, msgId, [
92657
- { type: "emoji", emoji }
92658
- ]);
90984
+ await sendReaction(chat_id, msgId, emoji);
92659
90985
  noteSignal(key, Date.now());
92660
90986
  }, allowedReactions, {
92661
90987
  onTransition: (emoji) => {
@@ -92697,9 +91023,7 @@ ${preBlock(write.output)}`;
92697
91023
  }
92698
91024
  }
92699
91025
  } else if (access.ackReaction) {
92700
- bot.api.setMessageReaction(chat_id, msgId, [
92701
- { type: "emoji", emoji: access.ackReaction }
92702
- ]).catch(() => {});
91026
+ sendReaction(chat_id, msgId, access.ackReaction).catch(() => {});
92703
91027
  logStreamingEvent({ kind: "inbound_ack", chatId: chat_id, messageId: msgId, ackDelayMs: Date.now() - inboundReceivedAt });
92704
91028
  }
92705
91029
  }
@@ -93152,7 +91476,7 @@ function clearRestartMarker() {
93152
91476
  if (!p)
93153
91477
  return;
93154
91478
  try {
93155
- rmSync5(p, { force: true });
91479
+ rmSync6(p, { force: true });
93156
91480
  process.stderr.write(`telegram gateway: restart-marker: cleared path=${p}
93157
91481
  `);
93158
91482
  } catch {}
@@ -93312,7 +91636,7 @@ function spawnSwitchroomDetached(args, onFailure) {
93312
91636
  let outFd = null;
93313
91637
  try {
93314
91638
  mkdirSync40(STATE_DIR, { recursive: true });
93315
- outFd = openSync11(logPath, "a");
91639
+ outFd = openSync12(logPath, "a");
93316
91640
  writeFileSync43(logPath, `
93317
91641
  [${new Date().toISOString()}] spawn ${SWITCHROOM_CLI} ${fullArgs.join(" ")}
93318
91642
  `, { flag: "a" });
@@ -93327,7 +91651,7 @@ function spawnSwitchroomDetached(args, onFailure) {
93327
91651
  });
93328
91652
  if (outFd != null) {
93329
91653
  try {
93330
- closeSync11(outFd);
91654
+ closeSync12(outFd);
93331
91655
  } catch {}
93332
91656
  }
93333
91657
  if (onFailure) {
@@ -93386,7 +91710,7 @@ async function sweepBeforeSelfRestart() {
93386
91710
  `);
93387
91711
  }
93388
91712
  try {
93389
- await sweepActiveReactions(agentDir, (chatId, messageId) => lockedBot.api.setMessageReaction(chatId, messageId, [{ type: "emoji", emoji: "\uD83D\uDC4D" }]), { log: (msg) => process.stderr.write(`telegram gateway: pre-restart reaction sweep \u2014 ${msg}
91713
+ await sweepActiveReactions(agentDir, (chatId, messageId) => sendReaction(chatId, messageId, "\uD83D\uDC4D"), { log: (msg) => process.stderr.write(`telegram gateway: pre-restart reaction sweep \u2014 ${msg}
93390
91714
  `) });
93391
91715
  } catch (err) {
93392
91716
  process.stderr.write(`telegram gateway: pre-restart reaction sweep threw: ${err.message}
@@ -95999,7 +94323,10 @@ bot.command("usage", async (ctx) => {
95999
94323
  demo,
96000
94324
  ...staleCachedAtMs != null ? { staleCachedAtMs } : probeResp.results.length > 0 ? { liveProbedAtMs: renderNow.getTime() } : { probeFailed: true }
96001
94325
  });
96002
- const kbRows = buildSnapshotKeyboard3(snapshots, { now: new Date, demo });
94326
+ let kbRows = buildSnapshotKeyboard3(snapshots, { now: new Date, demo });
94327
+ if (ctx.chat?.type !== "private") {
94328
+ kbRows = kbRows.filter((row) => !row.some((b) => b.callbackData?.startsWith("auth:use:")));
94329
+ }
96003
94330
  const keyboard = new import_grammy13.InlineKeyboard;
96004
94331
  kbRows.forEach((row, ri) => {
96005
94332
  if (ri > 0)
@@ -96091,6 +94418,12 @@ registerOpsInfoCommands(bot, {
96091
94418
  bot.on("callback_query:data", async (ctx) => {
96092
94419
  const data = ctx.callbackQuery.data;
96093
94420
  if (data.startsWith("auth:")) {
94421
+ const access2 = loadAccess();
94422
+ const senderId2 = String(ctx.from?.id ?? "");
94423
+ if (!access2.allowFrom.includes(senderId2)) {
94424
+ await ctx.answerCallbackQuery({ text: "Not authorized." });
94425
+ return;
94426
+ }
96094
94427
  await handleAuthDashboardCallback(ctx);
96095
94428
  return;
96096
94429
  }
@@ -97058,9 +95391,7 @@ async function handleAckOnly(ctx, kind, opts = {}) {
97058
95391
  const chat_id = String(ctx.chat.id);
97059
95392
  const msgId = ctx.message?.message_id;
97060
95393
  if (msgId != null) {
97061
- bot.api.setMessageReaction(chat_id, msgId, [
97062
- { type: "emoji", emoji: opts.emoji ?? "\uD83D\uDC40" }
97063
- ]).catch(() => {});
95394
+ sendReaction(chat_id, msgId, opts.emoji ?? "\uD83D\uDC40").catch(() => {});
97064
95395
  }
97065
95396
  const prefix = opts.warn ? "WARN " : "";
97066
95397
  process.stderr.write(`telegram gateway: ${prefix}inbound ${kind} ack-only chat_id=${chat_id} from=${ctx.from?.id ?? "?"}
@@ -97084,9 +95415,7 @@ async function handleRefusal(ctx, kind, refusalText) {
97084
95415
  const msgId = ctx.message?.message_id;
97085
95416
  const messageThreadId = ctx.message?.message_thread_id;
97086
95417
  if (msgId != null) {
97087
- bot.api.setMessageReaction(chat_id, msgId, [
97088
- { type: "emoji", emoji: "\uD83D\uDEAB" }
97089
- ]).catch(() => {});
95418
+ sendReaction(chat_id, msgId, "\uD83D\uDEAB").catch(() => {});
97090
95419
  }
97091
95420
  await swallowingApiCall(() => bot.api.sendMessage(chat_id, refusalText, messageThreadId != null ? { message_thread_id: messageThreadId } : {}), {
97092
95421
  chat_id,
@@ -97739,7 +96068,7 @@ process.on("SIGINT", () => void shutdown("SIGINT"));
97739
96068
  {
97740
96069
  const startupAgentDir = resolveAgentDirFromEnv();
97741
96070
  if (startupAgentDir != null) {
97742
- sweepActiveReactions(startupAgentDir, (chatId, messageId) => lockedBot.api.setMessageReaction(chatId, messageId, [{ type: "emoji", emoji: "\uD83D\uDC4D" }]), { log: (msg) => process.stderr.write(`telegram gateway: startup reaction sweep \u2014 ${msg}
96071
+ sweepActiveReactions(startupAgentDir, (chatId, messageId) => sendReaction(chatId, messageId, "\uD83D\uDC4D"), { log: (msg) => process.stderr.write(`telegram gateway: startup reaction sweep \u2014 ${msg}
97743
96072
  `) });
97744
96073
  }
97745
96074
  }
@@ -98206,10 +96535,11 @@ var didOneTimeSetup = false;
98206
96535
  subagentWatcher = startSubagentWatcher({
98207
96536
  agentDir: watcherAgentDir,
98208
96537
  agentCwd: watcherAgentDir,
98209
- extraWatchCwdsProvider: () => ownedWorktreeCwds({
96538
+ extraWatchCwdsProvider: makeWorktreeWatchProvider({
98210
96539
  self: process.env.SWITCHROOM_AGENT_NAME,
98211
- listRecords,
98212
96540
  agentDir: process.env.SWITCHROOM_WORKTREE_IDENTITY_FALLBACK === "0" ? undefined : watcherAgentDir,
96541
+ listRecords,
96542
+ touchHeartbeat,
98213
96543
  log: (msg) => process.stderr.write(`telegram gateway: ${msg}
98214
96544
  `)
98215
96545
  }),