@moonshot-ai/kimi-code 2.3.3 → 2.4.1

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 (81) hide show
  1. package/dist/main.mjs +48232 -43236
  2. package/dist/search-worker.mjs +140 -178
  3. package/dist-web/assets/{CodeBlockNode-x8gR_NJ_.js → CodeBlockNode-CIvtz3rC.js} +2 -2
  4. package/dist-web/assets/{PreCodeBlock-D94rgfjG.js → PreCodeBlock-0BTr2u9k.js} +1 -1
  5. package/dist-web/assets/{Tooltip-Ck3rGjEN.js → Tooltip-Bp1e70sS.js} +1 -1
  6. package/dist-web/assets/{abnfDiagram-VRR7QNED-D8ez8uim.js → abnfDiagram-VRR7QNED-BzciCMyj.js} +1 -1
  7. package/dist-web/assets/{arc-CRRKlX-p.js → arc-4PKHZ2Zx.js} +1 -1
  8. package/dist-web/assets/{architectureDiagram-ZJ3FMSHR-ddPbJ_Dn.js → architectureDiagram-ZJ3FMSHR-CIqzehcx.js} +1 -1
  9. package/dist-web/assets/{blockDiagram-677ZJIJ3-BRka2cox.js → blockDiagram-677ZJIJ3-Bv3AbJqy.js} +1 -1
  10. package/dist-web/assets/{c4Diagram-LMCZKHZV-BDG3tEBQ.js → c4Diagram-LMCZKHZV-ua7RLDxT.js} +1 -1
  11. package/dist-web/assets/channel-BS-tcXRb.js +1 -0
  12. package/dist-web/assets/{chunk-2Q5K7J3B-Bj3vlj3y.js → chunk-2Q5K7J3B-BeojjKsX.js} +1 -1
  13. package/dist-web/assets/{chunk-32BRIVSS-B8gSFtLK.js → chunk-32BRIVSS-D2IgetQa.js} +1 -1
  14. package/dist-web/assets/{chunk-5VM5RSS4-CnrQ4AgJ.js → chunk-5VM5RSS4-Dkn-fxlG.js} +1 -1
  15. package/dist-web/assets/{chunk-EX3LRPZG-4ZFETIzN.js → chunk-EX3LRPZG-abn_GMDv.js} +1 -1
  16. package/dist-web/assets/{chunk-JWPE2WC7-CFaSk12U.js → chunk-JWPE2WC7-BKR6Y3yk.js} +1 -1
  17. package/dist-web/assets/{chunk-MOJQB5TN-nz6Iv7r_.js → chunk-MOJQB5TN-B4UC1pfd.js} +1 -1
  18. package/dist-web/assets/{chunk-RYQCIY6F-MtH8gVIz.js → chunk-RYQCIY6F-DuDIe_Cq.js} +1 -1
  19. package/dist-web/assets/{chunk-V7JOEXUC-DUDFnGWS.js → chunk-V7JOEXUC-B97KqnD7.js} +1 -1
  20. package/dist-web/assets/{chunk-VR4S4FIN-DMqAUMdK.js → chunk-VR4S4FIN-DHc63ntL.js} +1 -1
  21. package/dist-web/assets/{chunk-XXDRQBXY-BRRtW_Of.js → chunk-XXDRQBXY-6qaw7w5g.js} +1 -1
  22. package/dist-web/assets/classDiagram-OUVF2IWQ-BWNjjMKo.js +1 -0
  23. package/dist-web/assets/classDiagram-v2-EOCWNBFH-BWNjjMKo.js +1 -0
  24. package/dist-web/assets/{cose-bilkent-JH36ORCC-D8ns0-Kn.js → cose-bilkent-JH36ORCC-ALcn1ouo.js} +1 -1
  25. package/dist-web/assets/{cynefin-VYW2F7L2-Bp-nxK3W.js → cynefin-VYW2F7L2-D_D6kr1y.js} +1 -1
  26. package/dist-web/assets/{cynefinDiagram-TSTJHNR4-PvbCPnDc.js → cynefinDiagram-TSTJHNR4-D5csSXzh.js} +1 -1
  27. package/dist-web/assets/{dagre-VKFMJZFB-BzVLGs_J.js → dagre-VKFMJZFB-Do6ll7aw.js} +1 -1
  28. package/dist-web/assets/{diagram-FQU43EPY-rDegz4b3.js → diagram-FQU43EPY-DHDgQBmC.js} +1 -1
  29. package/dist-web/assets/{diagram-G47NLZAW-D-K95T9W.js → diagram-G47NLZAW-DT9HOlo3.js} +1 -1
  30. package/dist-web/assets/{diagram-NH7WQ7WH-vAxkrrkL.js → diagram-NH7WQ7WH-BPtcOMpd.js} +1 -1
  31. package/dist-web/assets/{diagram-OA4YK3LP-BnCNL17Z.js → diagram-OA4YK3LP-BKEkNEVz.js} +1 -1
  32. package/dist-web/assets/{diagram-WEI45ONY-Cq5_ZmJn.js → diagram-WEI45ONY-CUUMN87B.js} +1 -1
  33. package/dist-web/assets/{ebnfDiagram-CCIWWBDH-ydUyyG4g.js → ebnfDiagram-CCIWWBDH-NtQfpgNl.js} +1 -1
  34. package/dist-web/assets/{erDiagram-Q63AITRT-1GF9mnaH.js → erDiagram-Q63AITRT-ChxUNo-4.js} +1 -1
  35. package/dist-web/assets/{flowDiagram-23GEKE2U-Dp3ubqO7.js → flowDiagram-23GEKE2U-BNsN5cGH.js} +1 -1
  36. package/dist-web/assets/{ganttDiagram-NO4QXBWP-6TLLIXAF.js → ganttDiagram-NO4QXBWP-D9tMVsBi.js} +1 -1
  37. package/dist-web/assets/{gitGraphDiagram-IHSO6WYX-D3uFEC45.js → gitGraphDiagram-IHSO6WYX-9yTtc4VI.js} +1 -1
  38. package/dist-web/assets/{index-Dnz6Zudc.js → index-9agYyXUg.js} +496 -497
  39. package/dist-web/assets/{index-CWMEBP78.js → index-CEGyVnHs.js} +1 -1
  40. package/dist-web/assets/{index-CM1IMrEN.js → index-sZnHaBWV.js} +1 -1
  41. package/dist-web/assets/index-yug3cXfh.css +1 -0
  42. package/dist-web/assets/{index10-bV3Rt9BF.js → index10-C8bGx-ID.js} +1 -1
  43. package/dist-web/assets/{index5-CjSUSUGm.js → index5-B_Wel8bR.js} +1 -1
  44. package/dist-web/assets/{index6-DNCbjemX.js → index6-lG6s3iq1.js} +1 -1
  45. package/dist-web/assets/{index8-Cv4eRvXY.js → index8-pijDpFaZ.js} +1 -1
  46. package/dist-web/assets/{index9-BIqXoaM4.js → index9-C_MEX8yC.js} +1 -1
  47. package/dist-web/assets/{infoDiagram-FWYZ7A6U-CbULgfiG.js → infoDiagram-FWYZ7A6U-Bu6M_URV.js} +1 -1
  48. package/dist-web/assets/{ishikawaDiagram-FXEZZL3T-CzOmYQGA.js → ishikawaDiagram-FXEZZL3T-grXWwCyy.js} +1 -1
  49. package/dist-web/assets/{journeyDiagram-5HDEW3XC-Bn6UdTtP.js → journeyDiagram-5HDEW3XC-Czw-i4V4.js} +1 -1
  50. package/dist-web/assets/{kanban-definition-HUTT4EX6-D46M2hPT.js → kanban-definition-HUTT4EX6-DUWKibvr.js} +1 -1
  51. package/dist-web/assets/{linear-rQmBrEzK.js → linear-Dsz1tuoz.js} +1 -1
  52. package/dist-web/assets/{markstream-UDoFrbnV.js → markstream-DB_TBaXu.js} +2 -2
  53. package/dist-web/assets/{mermaid.core-AN7v7N47.js → mermaid.core-BQA5l5RT.js} +4 -4
  54. package/dist-web/assets/{mindmap-definition-LN4V7U3C-D6hZ84pJ.js → mindmap-definition-LN4V7U3C-Cgsg95JW.js} +1 -1
  55. package/dist-web/assets/{pegDiagram-2B236MQR-Dqj-SYF9.js → pegDiagram-2B236MQR-4X-iNyHB.js} +1 -1
  56. package/dist-web/assets/{pieDiagram-ENE6RG2P-Bxrj0TDW.js → pieDiagram-ENE6RG2P-CeOoBX4R.js} +1 -1
  57. package/dist-web/assets/{quadrantDiagram-ABIIQ3AL-CtlNm0IB.js → quadrantDiagram-ABIIQ3AL-CuvHhFkH.js} +1 -1
  58. package/dist-web/assets/{railroadDiagram-RFXS5EU6-ABT3be4u.js → railroadDiagram-RFXS5EU6-SfO4p82T.js} +1 -1
  59. package/dist-web/assets/{requirementDiagram-TGXJPOKE-DbHli6K8.js → requirementDiagram-TGXJPOKE-1ecNeeTX.js} +1 -1
  60. package/dist-web/assets/{sankeyDiagram-HTMAVEWB-BFMFIBNb.js → sankeyDiagram-HTMAVEWB-jS2hRzZb.js} +1 -1
  61. package/dist-web/assets/{sequenceDiagram-DBY2YBRQ-DVB5lIDi.js → sequenceDiagram-DBY2YBRQ-Cp4JbCdc.js} +1 -1
  62. package/dist-web/assets/{sizeCapture-X5ZJPWSS-D1OKv4-0.js → sizeCapture-X5ZJPWSS-BkuxoZbc.js} +1 -1
  63. package/dist-web/assets/{stateDiagram-2N3HPSRC-C1Huslxu.js → stateDiagram-2N3HPSRC-BmE_ZWLb.js} +1 -1
  64. package/dist-web/assets/stateDiagram-v2-6OUMAXLB-UkAmuVip.js +1 -0
  65. package/dist-web/assets/{swimlanes-5IMT3BWC-Dq3EyHqU.js → swimlanes-5IMT3BWC-DgmFWkRC.js} +2 -2
  66. package/dist-web/assets/swimlanesDiagram-G3AALYLV-BQ38uzZv.js +8 -0
  67. package/dist-web/assets/{timeline-definition-FHXFAJF6-Cmkj9bPT.js → timeline-definition-FHXFAJF6-VfePnGSk.js} +1 -1
  68. package/dist-web/assets/{vennDiagram-L72KCM5P-Bur71wRn.js → vennDiagram-L72KCM5P-BhO5s8SQ.js} +1 -1
  69. package/dist-web/assets/{vue.runtime.esm-bundler-CSen4mnJ.js → vue.runtime.esm-bundler-GDwfREi3.js} +1 -1
  70. package/dist-web/assets/{wardleyDiagram-EHGQE667-Ctr798MD.js → wardleyDiagram-EHGQE667-DmKC3IBX.js} +1 -1
  71. package/dist-web/assets/{xychartDiagram-FW5EYKEG-Dvaf_OjS.js → xychartDiagram-FW5EYKEG-DEVXLTrd.js} +1 -1
  72. package/dist-web/index.html +2 -2
  73. package/native/darwin/prebuilds/darwin-arm64/darwin-platform.node +0 -0
  74. package/native/darwin/prebuilds/darwin-x64/darwin-platform.node +0 -0
  75. package/package.json +9 -9
  76. package/dist-web/assets/channel-CsfHBtue.js +0 -1
  77. package/dist-web/assets/classDiagram-OUVF2IWQ-Cf1m8L1F.js +0 -1
  78. package/dist-web/assets/classDiagram-v2-EOCWNBFH-Cf1m8L1F.js +0 -1
  79. package/dist-web/assets/index-Cj6xJi2l.css +0 -32
  80. package/dist-web/assets/stateDiagram-v2-6OUMAXLB-ui4kGWzh.js +0 -1
  81. package/dist-web/assets/swimlanesDiagram-G3AALYLV-CLWojsyT.js +0 -8
@@ -7,7 +7,7 @@ import fs$1, { open, readFile, readdir, rm, stat } from "node:fs/promises";
7
7
  import os from "node:os";
8
8
  import { AsyncLocalStorage } from "node:async_hooks";
9
9
 
10
- //#region ../../packages/minidb/src/worker-runtime.ts
10
+ // ../../packages/minidb/src/worker-runtime.ts
11
11
  let configuredEntry = null;
12
12
  function assertRegularFile(filePath) {
13
13
  let stat;
@@ -56,8 +56,7 @@ function getTextBuildWorkerRuntimeState() {
56
56
  };
57
57
  }
58
58
 
59
- //#endregion
60
- //#region ../../packages/kap-server/src/search/contract.ts
59
+ // ../../packages/kap-server/src/search/contract.ts
61
60
  var GlobalSearchError = class extends Error {
62
61
  reason;
63
62
  constructor(reason, message) {
@@ -67,8 +66,7 @@ var GlobalSearchError = class extends Error {
67
66
  }
68
67
  };
69
68
 
70
- //#endregion
71
- //#region ../../packages/minidb/src/skiplist.ts
69
+ // ../../packages/minidb/src/skiplist.ts
72
70
  const MAX_LEVEL = 32;
73
71
  const P = .25;
74
72
  const cmpNumber = (a, b) => a - b;
@@ -439,8 +437,7 @@ var SkipList = class SkipList {
439
437
  }
440
438
  };
441
439
 
442
- //#endregion
443
- //#region ../../packages/minidb/src/store.ts
440
+ // ../../packages/minidb/src/store.ts
444
441
  const toKStr$1 = (key) => typeof key === "string" ? key : Buffer.from(key).toString("binary");
445
442
  const fromKStr$1 = (kstr) => Buffer.from(kstr, "binary");
446
443
  const DISK_REF_BYTES = 64;
@@ -888,8 +885,7 @@ var Store = class {
888
885
  }
889
886
  };
890
887
 
891
- //#endregion
892
- //#region ../../packages/minidb/src/op-tracker.ts
888
+ // ../../packages/minidb/src/op-tracker.ts
893
889
  var OpTracker = class {
894
890
  count = 0;
895
891
  open = true;
@@ -956,9 +952,8 @@ var OpTracker = class {
956
952
  }
957
953
  };
958
954
 
959
- //#endregion
960
- //#region ../../packages/minidb/src/wal.ts
961
- const POLICIES = new Set([
955
+ // ../../packages/minidb/src/wal.ts
956
+ const POLICIES = /* @__PURE__ */ new Set([
962
957
  "always",
963
958
  "everysec",
964
959
  "no"
@@ -1323,8 +1318,7 @@ var WAL = class {
1323
1318
  }
1324
1319
  };
1325
1320
 
1326
- //#endregion
1327
- //#region ../../packages/minidb/src/value-reader.ts
1321
+ // ../../packages/minidb/src/value-reader.ts
1328
1322
  /** Promise wrapper over fs.read (the callback API runs on the libuv thread
1329
1323
  * pool for a plain fd; fs.promises has no fd-level read). Shared with the
1330
1324
  * postings file's async read. */
@@ -1433,12 +1427,11 @@ var ValueReader = class {
1433
1427
  }
1434
1428
  };
1435
1429
 
1436
- //#endregion
1437
- //#region ../../packages/minidb/src/crc32.ts
1430
+ // ../../packages/minidb/src/crc32.ts
1438
1431
  const POLY = 3988292384;
1439
1432
  let TABLE = null;
1440
1433
  function buildTable() {
1441
- const t = new Uint32Array(256);
1434
+ const t = /* @__PURE__ */ new Uint32Array(256);
1442
1435
  for (let n = 0; n < 256; n++) {
1443
1436
  let c = n;
1444
1437
  for (let k = 0; k < 8; k++) c = c & 1 ? POLY ^ c >>> 1 : c >>> 1;
@@ -1460,8 +1453,7 @@ function crc32(buf, prev = 0) {
1460
1453
  return (c ^ 4294967295) >>> 0;
1461
1454
  }
1462
1455
 
1463
- //#endregion
1464
- //#region ../../packages/minidb/src/codec.ts
1456
+ // ../../packages/minidb/src/codec.ts
1465
1457
  const MAGIC = Buffer.from([77, 68]);
1466
1458
  const TYPE_SET = 1;
1467
1459
  const TYPE_DEL = 2;
@@ -1603,7 +1595,7 @@ async function readFrameRefAtAsync(fd, pos, size) {
1603
1595
  const metaLen = header.readUInt32LE(10);
1604
1596
  if (keyLen > 65535) return null;
1605
1597
  const frameLen = 22 + keyLen + valLen + metaLen + 4;
1606
- if (frameLen < 22 + 4) return null;
1598
+ if (frameLen < 26) return null;
1607
1599
  if (size - pos < frameLen) return null;
1608
1600
  let crc = 0;
1609
1601
  let crcPos = pos + 2;
@@ -1657,7 +1649,7 @@ function parseFrameRefInWindow(win, winStart, winLen, pos, size) {
1657
1649
  const metaLen = win.readUInt32LE(o + 10);
1658
1650
  if (keyLen > 65535) return null;
1659
1651
  const frameLen = 22 + keyLen + valLen + metaLen + 4;
1660
- if (frameLen < 22 + 4) return null;
1652
+ if (frameLen < 26) return null;
1661
1653
  if (size - pos < frameLen) return null;
1662
1654
  if (avail < frameLen) return "window";
1663
1655
  let crc = 0;
@@ -1839,8 +1831,7 @@ function scanBatchOpRefs(body, bodyOff) {
1839
1831
  return ops;
1840
1832
  }
1841
1833
 
1842
- //#endregion
1843
- //#region ../../packages/minidb/src/generation.ts
1834
+ // ../../packages/minidb/src/generation.ts
1844
1835
  /** The primary data pair recovery pairs up: the snapshot, then the WAL. */
1845
1836
  const SNAPSHOT_FILE = "db.snapshot";
1846
1837
  const WAL_FILE = "db.wal";
@@ -1963,8 +1954,7 @@ function isStaleTmpFile(name) {
1963
1954
  * always safe for the writer to delete, for any index name. */
1964
1955
  const STALE_POSTINGS_TMP_PATTERN = /^db\.text-.*\.postings\.tmp$/;
1965
1956
 
1966
- //#endregion
1967
- //#region ../../packages/minidb/src/query.ts
1957
+ // ../../packages/minidb/src/query.ts
1968
1958
  function tokenizePath(path) {
1969
1959
  if (Array.isArray(path)) return [...path];
1970
1960
  const tokens = [];
@@ -2087,8 +2077,7 @@ function match(doc, filter) {
2087
2077
  return true;
2088
2078
  }
2089
2079
 
2090
- //#endregion
2091
- //#region ../../packages/minidb/src/text-index/tokenize.ts
2080
+ // ../../packages/minidb/src/text-index/tokenize.ts
2092
2081
  const LATIN = /[a-z0-9]+/g;
2093
2082
  const CJK = /[\u3400-\u9fff\u3040-\u30ff\uff00-\uffef]+/g;
2094
2083
  const MAX_TERM_CHARS = 65535;
@@ -2127,8 +2116,7 @@ function extractText(fields, doc) {
2127
2116
  return stringLeaves(doc).join(" ");
2128
2117
  }
2129
2118
 
2130
- //#endregion
2131
- //#region ../../packages/minidb/src/recovery.ts
2119
+ // ../../packages/minidb/src/recovery.ts
2132
2120
  function readAtSync$1(fd, off, len) {
2133
2121
  if (len === 0) return Buffer.alloc(0);
2134
2122
  const buf = Buffer.allocUnsafe(len);
@@ -2498,8 +2486,7 @@ async function catchUpWalAsync(walPath, offset, anchor, apply) {
2498
2486
  }
2499
2487
  }
2500
2488
 
2501
- //#endregion
2502
- //#region ../../packages/minidb/src/rename-replace.ts
2489
+ // ../../packages/minidb/src/rename-replace.ts
2503
2490
  const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
2504
2491
  async function retryEperm(op, opts = {}) {
2505
2492
  const retries = opts.retries ?? 100;
@@ -2519,8 +2506,7 @@ async function renameReplace(src, dst, opts = {}) {
2519
2506
  return withWindowsEpermRetry(() => fs$1.rename(src, dst), opts);
2520
2507
  }
2521
2508
 
2522
- //#endregion
2523
- //#region ../../packages/minidb/src/snapshot.ts
2509
+ // ../../packages/minidb/src/snapshot.ts
2524
2510
  const yieldToLoop$1 = () => new Promise((r) => setImmediate(r));
2525
2511
  const FLUSH_BYTES$3 = 1 << 20;
2526
2512
  /** Stage 6 defaults: at most this many positioned reads in flight, and at
@@ -2563,12 +2549,13 @@ async function writeSnapshot(store, tmpPath, opts = {}) {
2563
2549
  batchBytes = 0;
2564
2550
  };
2565
2551
  const writeRecord = async (key, value, expireAt, dt) => {
2552
+ const meta = dt ? Buffer.from(JSON.stringify({ dt })) : null;
2566
2553
  const frame = encodeFrame({
2567
2554
  type: 1,
2568
2555
  key,
2569
2556
  value,
2570
2557
  expireAt,
2571
- meta: dt ? Buffer.from(JSON.stringify({ dt })) : null
2558
+ meta
2572
2559
  });
2573
2560
  const frameOff = bytes + batchBytes;
2574
2561
  locs.set(key.toString("binary"), {
@@ -2655,13 +2642,12 @@ async function writeSnapshot(store, tmpPath, opts = {}) {
2655
2642
  };
2656
2643
  }
2657
2644
 
2658
- //#endregion
2659
- //#region ../../packages/minidb/src/compaction.ts
2645
+ // ../../packages/minidb/src/compaction.ts
2660
2646
  function shouldCompact(db) {
2661
2647
  return Boolean(db.wal && db.wal.size >= db.compactThresholdBytes);
2662
2648
  }
2663
2649
  const COPY_CHUNK = 1 << 20;
2664
- const SMALL_DELTA = 64 * 1024;
2650
+ const SMALL_DELTA = 65536;
2665
2651
  const rotateReplace = (src, dst) => renameReplace(src, dst);
2666
2652
  const MAX_PRECOPY_PASSES = 5;
2667
2653
  const CONVERGE_RATIO = .7;
@@ -2843,8 +2829,7 @@ async function runCompaction(db) {
2843
2829
  }
2844
2830
  }
2845
2831
 
2846
- //#endregion
2847
- //#region ../../packages/minidb/src/index-manager.ts
2832
+ // ../../packages/minidb/src/index-manager.ts
2848
2833
  var UniqueViolationError = class extends Error {
2849
2834
  constructor(index, value) {
2850
2835
  super(`unique index "${index}" violation on value ${JSON.stringify(value)}`);
@@ -3172,10 +3157,14 @@ var IndexManager = class IndexManager {
3172
3157
  const idx = this.get(name);
3173
3158
  if (idx.type !== "range") throw new Error(`index "${name}" is not a range index`);
3174
3159
  const r = {};
3175
- if (opts.min !== void 0) if (opts.minExclusive) r.gt = opts.min;
3176
- else r.gte = opts.min;
3177
- if (opts.max !== void 0) if (opts.maxExclusive) r.lt = opts.max;
3178
- else r.lte = opts.max;
3160
+ if (opts.min !== void 0) {
3161
+ if (opts.minExclusive) r.gt = opts.min;
3162
+ else r.gte = opts.min;
3163
+ }
3164
+ if (opts.max !== void 0) {
3165
+ if (opts.maxExclusive) r.lt = opts.max;
3166
+ else r.lte = opts.max;
3167
+ }
3179
3168
  if (opts.offset) r.offset = opts.offset;
3180
3169
  if (opts.count !== void 0) r.count = opts.count;
3181
3170
  if (opts.reverse) r.reverse = true;
@@ -3347,8 +3336,7 @@ var IndexManager = class IndexManager {
3347
3336
  }
3348
3337
  };
3349
3338
 
3350
- //#endregion
3351
- //#region ../../packages/minidb/src/dt-index.ts
3339
+ // ../../packages/minidb/src/dt-index.ts
3352
3340
  var DtIndex = class {
3353
3341
  cols = /* @__PURE__ */ new Map();
3354
3342
  byKey = /* @__PURE__ */ new Map();
@@ -3507,8 +3495,7 @@ var DtIndex = class {
3507
3495
  }
3508
3496
  };
3509
3497
 
3510
- //#endregion
3511
- //#region ../../packages/minidb/src/text-postings.ts
3498
+ // ../../packages/minidb/src/text-postings.ts
3512
3499
  const HEADER_LEN = 10;
3513
3500
  const CRC_LEN = 4;
3514
3501
  const FLUSH_BYTES$2 = 1 << 20;
@@ -3592,7 +3579,7 @@ function encodeRecord(term, df, payload) {
3592
3579
  }
3593
3580
  /** Decode + CRC-verify a record frame. */
3594
3581
  function decodeRecord(buf) {
3595
- if (buf.length < HEADER_LEN + CRC_LEN) throw new Error("postings: record too short");
3582
+ if (buf.length < 14) throw new Error("postings: record too short");
3596
3583
  if (buf.readUInt32LE(buf.length - CRC_LEN) !== crc32(buf.subarray(0, buf.length - CRC_LEN))) throw new Error("postings: record crc mismatch");
3597
3584
  let o = 0;
3598
3585
  const termLen = buf.readUInt16LE(o);
@@ -3750,8 +3737,7 @@ var PostingsFile = class PostingsFile {
3750
3737
  }
3751
3738
  };
3752
3739
 
3753
- //#endregion
3754
- //#region ../../packages/minidb/src/text-index/types.ts
3740
+ // ../../packages/minidb/src/text-index/types.ts
3755
3741
  const EMPTY_MAP = /* @__PURE__ */ new Map();
3756
3742
  /** Bounded collector for the K best hits by (score desc, key asc). The heap
3757
3743
  * root holds the WORST kept hit, so a new candidate enters only when it beats
@@ -3801,8 +3787,7 @@ var TopK = class TopK {
3801
3787
  }
3802
3788
  };
3803
3789
 
3804
- //#endregion
3805
- //#region ../../packages/minidb/src/text-index/builder.ts
3790
+ // ../../packages/minidb/src/text-index/builder.ts
3806
3791
  const BUILD_YIELD_DOCS = 512;
3807
3792
  const BUILD_YIELD_TOKENS = 5e5;
3808
3793
  /** Staged text-index rebuild (see TextIndex.beginBuild): feed docs with
@@ -3880,8 +3865,7 @@ async function feedBuild(b, entries) {
3880
3865
  await b.commit();
3881
3866
  }
3882
3867
 
3883
- //#endregion
3884
- //#region ../../packages/minidb/src/text-index/image.ts
3868
+ // ../../packages/minidb/src/text-index/image.ts
3885
3869
  /** Stage-5 generation build: a synchronous deep-enough snapshot of the live
3886
3870
  * state for image serialization. The maps/arrays are copied so later
3887
3871
  * mutations of the live index never reach the serialized image. Must run
@@ -4070,8 +4054,7 @@ function repointPostings(s, newPath) {
4070
4054
  s.pf.path = newPath;
4071
4055
  }
4072
4056
 
4073
- //#endregion
4074
- //#region ../../packages/minidb/src/text-index/index.ts
4057
+ // ../../packages/minidb/src/text-index/index.ts
4075
4058
  /**
4076
4059
  * Raised by text searches while the index's base is (re)building. The
4077
4060
  * no-generation fallback open path defers the corpus-scale base build to a
@@ -4161,7 +4144,7 @@ var TextIndex = class TextIndex {
4161
4144
  this.queryTokenizer = opts.queryTokenizer ?? this.tokenizer;
4162
4145
  this.path = opts.postingsPath ?? null;
4163
4146
  this.cacheTerms = opts.cacheTerms ?? 1024;
4164
- this.cacheBytesCap = opts.cacheBytes ?? 64 * 1024 * 1024;
4147
+ this.cacheBytesCap = opts.cacheBytes ?? 67108864;
4165
4148
  if (!this.path) this.memBase = /* @__PURE__ */ new Map();
4166
4149
  }
4167
4150
  /** Approximate byte weight of a cached decoded list (entry pairs plus the
@@ -4838,8 +4821,7 @@ function* aggToSorted(agg) {
4838
4821
  };
4839
4822
  }
4840
4823
 
4841
- //#endregion
4842
- //#region ../../packages/minidb/src/compound-index.ts
4824
+ // ../../packages/minidb/src/compound-index.ts
4843
4825
  function getPath(doc, path) {
4844
4826
  return path.split(".").reduce((o, k) => o === null || o === void 0 ? void 0 : o[k], doc);
4845
4827
  }
@@ -5128,8 +5110,7 @@ var CompoundIndexManager = class CompoundIndexManager {
5128
5110
  }
5129
5111
  };
5130
5112
 
5131
- //#endregion
5132
- //#region ../../packages/minidb/src/value-codec.ts
5113
+ // ../../packages/minidb/src/value-codec.ts
5133
5114
  const BUFFER = {
5134
5115
  encode: (v) => {
5135
5116
  if (!Buffer.isBuffer(v)) throw new TypeError("value must be a Buffer (use valueCodec: \"string\" or \"json\")");
@@ -5213,8 +5194,7 @@ async function resolveValueMode(mode, dir, maxMemoryBytes) {
5213
5194
  return await fileSize(path.join(dir, "db.snapshot")) + await fileSize(path.join(dir, "db.wal")) > maxMemoryBytes ? "disk" : "memory";
5214
5195
  }
5215
5196
 
5216
- //#endregion
5217
- //#region ../../packages/minidb/src/serialize.ts
5197
+ // ../../packages/minidb/src/serialize.ts
5218
5198
  /** Create a serializing executor: functions submitted to it run strictly one
5219
5199
  * at a time, in submission order. The executor itself never rejects; each
5220
5200
  * call settles with its own function's result or error. */
@@ -5235,8 +5215,7 @@ function createSerializer() {
5235
5215
  };
5236
5216
  }
5237
5217
 
5238
- //#endregion
5239
- //#region ../../packages/minidb/src/lockfile.ts
5218
+ // ../../packages/minidb/src/lockfile.ts
5240
5219
  var LockError = class extends Error {
5241
5220
  code = "ELOCKED";
5242
5221
  constructor(message) {
@@ -5497,8 +5476,7 @@ var LockFile = class {
5497
5476
  }
5498
5477
  };
5499
5478
 
5500
- //#endregion
5501
- //#region ../../packages/minidb/src/maintenance.ts
5479
+ // ../../packages/minidb/src/maintenance.ts
5502
5480
  var MaintenanceBackpressureError = class extends Error {
5503
5481
  code = "MAINTENANCE_BACKPRESSURE";
5504
5482
  constructor(kind) {
@@ -5811,8 +5789,7 @@ const defaultWorkerSlots = new WorkerSlots(Math.max(1, Math.min(2, Math.floor(os
5811
5789
  * full-text builds are never dropped onto the main thread UNCONDITIONALLY. */
5812
5790
  const TEXT_BUILD_SLOT_WAIT_MS = 3e4;
5813
5791
 
5814
- //#endregion
5815
- //#region ../../packages/minidb/src/memory-guard.ts
5792
+ // ../../packages/minidb/src/memory-guard.ts
5816
5793
  var MemoryGuard = class {
5817
5794
  deps;
5818
5795
  /** pk, insertion-ordered by last touch (Map/Set iteration order): front =
@@ -5876,8 +5853,7 @@ var MemoryGuard = class {
5876
5853
  }
5877
5854
  };
5878
5855
 
5879
- //#endregion
5880
- //#region ../../packages/minidb/src/backup.ts
5856
+ // ../../packages/minidb/src/backup.ts
5881
5857
  /** Unique suffixes for backup's temp/aside dirs (see copyBackupAtomic). */
5882
5858
  let backupTmpSeq = 0;
5883
5859
  /** The rejection a write op gets while a backup holds the write gate: the
@@ -6004,8 +5980,7 @@ async function copyIfExists(dir, name, destDir) {
6004
5980
  }
6005
5981
  }
6006
5982
 
6007
- //#endregion
6008
- //#region ../../packages/minidb/src/query-engine.ts
5983
+ // ../../packages/minidb/src/query-engine.ts
6009
5984
  /** Lazy one-shot candidate filter — keeps query pipelines streaming so a
6010
5985
  * bounded query stops after `skip + limit` matches instead of materializing
6011
5986
  * every candidate. */
@@ -6168,21 +6143,23 @@ var QueryEngine = class {
6168
6143
  if (fast !== null) return fast;
6169
6144
  let keys = null;
6170
6145
  if (typeof q.key === "string") keys = [toKStr(q.key)];
6171
- else if (q.key && typeof q.key === "object") if (q.key.prefix) {
6172
- const p = toKStr(q.key.prefix);
6173
- keys = this.deps.store().rawKeys({
6174
- gte: p,
6175
- lt: p + "￿"
6176
- });
6177
- } else {
6178
- const opts = {};
6179
- for (const b of [
6180
- "gte",
6181
- "gt",
6182
- "lte",
6183
- "lt"
6184
- ]) if (q.key[b] !== void 0) opts[b] = q.key[b];
6185
- keys = this.deps.store().rawKeys(canonRange(opts));
6146
+ else if (q.key && typeof q.key === "object") {
6147
+ if (q.key.prefix) {
6148
+ const p = toKStr(q.key.prefix);
6149
+ keys = this.deps.store().rawKeys({
6150
+ gte: p,
6151
+ lt: p + "￿"
6152
+ });
6153
+ } else {
6154
+ const opts = {};
6155
+ for (const b of [
6156
+ "gte",
6157
+ "gt",
6158
+ "lte",
6159
+ "lt"
6160
+ ]) if (q.key[b] !== void 0) opts[b] = q.key[b];
6161
+ keys = this.deps.store().rawKeys(canonRange(opts));
6162
+ }
6186
6163
  }
6187
6164
  if (q.dt) for (const [col, cond] of Object.entries(q.dt)) {
6188
6165
  const set = new Set(this.deps.dt.range(col, cond).map((r) => r.key));
@@ -6273,21 +6250,23 @@ var QueryEngine = class {
6273
6250
  if (fast !== null) return fast;
6274
6251
  let keys = null;
6275
6252
  if (typeof q.key === "string") keys = [toKStr(q.key)];
6276
- else if (q.key && typeof q.key === "object") if (q.key.prefix) {
6277
- const p = toKStr(q.key.prefix);
6278
- keys = this.deps.store().rawKeys({
6279
- gte: p,
6280
- lt: p + "￿"
6281
- });
6282
- } else {
6283
- const opts = {};
6284
- for (const b of [
6285
- "gte",
6286
- "gt",
6287
- "lte",
6288
- "lt"
6289
- ]) if (q.key[b] !== void 0) opts[b] = q.key[b];
6290
- keys = this.deps.store().rawKeys(canonRange(opts));
6253
+ else if (q.key && typeof q.key === "object") {
6254
+ if (q.key.prefix) {
6255
+ const p = toKStr(q.key.prefix);
6256
+ keys = this.deps.store().rawKeys({
6257
+ gte: p,
6258
+ lt: p + "￿"
6259
+ });
6260
+ } else {
6261
+ const opts = {};
6262
+ for (const b of [
6263
+ "gte",
6264
+ "gt",
6265
+ "lte",
6266
+ "lt"
6267
+ ]) if (q.key[b] !== void 0) opts[b] = q.key[b];
6268
+ keys = this.deps.store().rawKeys(canonRange(opts));
6269
+ }
6291
6270
  }
6292
6271
  if (q.dt) for (const [col, cond] of Object.entries(q.dt)) {
6293
6272
  const set = new Set(this.deps.dt.range(col, cond).map((r) => r.key));
@@ -6432,8 +6411,7 @@ var QueryEngine = class {
6432
6411
  }
6433
6412
  };
6434
6413
 
6435
- //#endregion
6436
- //#region ../../packages/minidb/src/gen-codec.ts
6414
+ // ../../packages/minidb/src/gen-codec.ts
6437
6415
  /** Thrown by every reader on a malformed/truncated/crc-mismatched generation
6438
6416
  * file. Distinct from CorruptFrameError so the loader can route precisely. */
6439
6417
  var GenerationCorruptError = class extends Error {
@@ -7198,8 +7176,7 @@ async function readTextDocsImageAsync(r, yieldEvery = 32768) {
7198
7176
  };
7199
7177
  }
7200
7178
 
7201
- //#endregion
7202
- //#region ../../packages/minidb/src/generation-files.ts
7179
+ // ../../packages/minidb/src/generation-files.ts
7203
7180
  function generationsDir(dir) {
7204
7181
  return path.join(dir, GENERATIONS_DIR);
7205
7182
  }
@@ -7345,8 +7322,7 @@ async function sweepGenerationTemps(dir) {
7345
7322
  }).catch(() => {});
7346
7323
  }
7347
7324
 
7348
- //#endregion
7349
- //#region ../../packages/minidb/src/trigram.ts
7325
+ // ../../packages/minidb/src/trigram.ts
7350
7326
  const HASH_MASK = (1 << 22) - 1;
7351
7327
  /** Normalize text for literal matching: Unicode NFKC (fullwidth `$` -> `$`,
7352
7328
  * compatibility glyphs folded) + lowercase. The search layer's confirmation
@@ -7372,8 +7348,7 @@ function createNgramTokenizer(opts = {}) {
7372
7348
  };
7373
7349
  }
7374
7350
 
7375
- //#endregion
7376
- //#region ../../packages/minidb/src/text-registry.ts
7351
+ // ../../packages/minidb/src/text-registry.ts
7377
7352
  /** Map a persisted tokenizer name to the TextIndex tokenizer pair. 'default'
7378
7353
  * (or a legacy definition without the field) returns empty options, keeping
7379
7354
  * the built-in tokenizer path untouched. The query side only diverges for
@@ -7557,8 +7532,7 @@ var TextRegistry = class {
7557
7532
  }
7558
7533
  };
7559
7534
 
7560
- //#endregion
7561
- //#region ../../packages/minidb/src/worker/text-build-core.ts
7535
+ // ../../packages/minidb/src/worker/text-build-core.ts
7562
7536
  function abortError() {
7563
7537
  const err = /* @__PURE__ */ new Error("text build aborted");
7564
7538
  err.name = "AbortError";
@@ -7705,7 +7679,8 @@ var SegmentReader = class SegmentReader {
7705
7679
  const payloadLen = this.buf.readUInt32LE(o + 2 + termLen + 4);
7706
7680
  const recLen = 2 + termLen + 8 + payloadLen + 4;
7707
7681
  if (avail >= recLen) {
7708
- const rec = decodeRecord(Buffer.from(this.buf.subarray(o, o + recLen)));
7682
+ const recBuf = Buffer.from(this.buf.subarray(o, o + recLen));
7683
+ const rec = decodeRecord(recBuf);
7709
7684
  this.current = {
7710
7685
  term: rec.term,
7711
7686
  df: rec.df,
@@ -8080,8 +8055,7 @@ async function mergeSegments(segments, writer, dict) {
8080
8055
  }
8081
8056
  }
8082
8057
 
8083
- //#endregion
8084
- //#region ../../packages/minidb/src/worker/text-build.ts
8058
+ // ../../packages/minidb/src/worker/text-build.ts
8085
8059
  var WorkerTextBuildError = class extends Error {
8086
8060
  code = "WORKER_TEXT_BUILD_FAILED";
8087
8061
  aborted;
@@ -8356,11 +8330,12 @@ function startInline(spec, opts, reason) {
8356
8330
  }, opts.abortPollMs ?? DEFAULT_ABORT_POLL_MS);
8357
8331
  poll.unref?.();
8358
8332
  }
8359
- const promise = buildTextArtifacts({
8333
+ const inner = {
8360
8334
  ...spec,
8361
8335
  signal: controller.signal,
8362
8336
  onProgress: opts.onProgress
8363
- }).finally(() => {
8337
+ };
8338
+ const promise = buildTextArtifacts(inner).finally(() => {
8364
8339
  if (poll !== null) clearInterval(poll);
8365
8340
  if (opts.signal && onOwnerAbort) opts.signal.removeEventListener("abort", onOwnerAbort);
8366
8341
  });
@@ -8376,8 +8351,7 @@ function startInline(spec, opts, reason) {
8376
8351
  };
8377
8352
  }
8378
8353
 
8379
- //#endregion
8380
- //#region ../../packages/minidb/src/generation-loader.ts
8354
+ // ../../packages/minidb/src/generation-loader.ts
8381
8355
  /** Store-image parse/filter records per event-loop slice on the open path
8382
8356
  * (the bulk load's own slicing lives in Store.bulkLoadRefsAsync). */
8383
8357
  const STORE_IMAGE_RECORDS_PER_SLICE = 8192;
@@ -8727,8 +8701,7 @@ var GenerationLoader = class {
8727
8701
  }
8728
8702
  };
8729
8703
 
8730
- //#endregion
8731
- //#region ../../packages/minidb/src/generation-builder.ts
8704
+ // ../../packages/minidb/src/generation-builder.ts
8732
8705
  /** The open-time index rebuild yields to the event loop every this many
8733
8706
  * records, so a huge Store walk never hard-blocks the host (mirrors the
8734
8707
  * BUILD_YIELD_DOCS watermark in text-index/builder.ts — 512 records bounds a
@@ -8750,12 +8723,12 @@ var GenerationBuildAborted = class extends Error {
8750
8723
  * bounded both by op count and by accumulated value bytes (each queued op
8751
8724
  * pins its value buffer). */
8752
8725
  const GEN_BUILD_QUEUE_CAP = 1e6;
8753
- const GEN_BUILD_QUEUE_BYTES_CAP = 512 * 1024 * 1024;
8726
+ const GEN_BUILD_QUEUE_BYTES_CAP = 536870912;
8754
8727
  /** Trigger-(b) thresholds for the open-time background build: a generation
8755
8728
  * whose WAL delta replay exceeded either is refreshed in the background so
8756
8729
  * the next open is cheap (the per-op replay path is for small deltas only). */
8757
8730
  const GEN_BUILD_WAL_DELTA_OPS = 4096;
8758
- const GEN_BUILD_WAL_DELTA_BYTES = 4 * 1024 * 1024;
8731
+ const GEN_BUILD_WAL_DELTA_BYTES = 4194304;
8759
8732
  /** Below this live-doc count the stage-6 worker spawn is not worth it: the
8760
8733
  * in-thread staged build finishes in milliseconds, so the corpus threshold
8761
8734
  * keeps small databases on the zero-overhead path. */
@@ -8838,7 +8811,8 @@ var GenerationBuilder = class {
8838
8811
  const gens = generationsDir(this.deps.dir());
8839
8812
  const prevCurrent = await readCurrent(this.deps.dir());
8840
8813
  const existing = await listGenerations(this.deps.dir());
8841
- const id = generationId(Math.max(prevCurrent ? existing.find((g) => g.id === prevCurrent)?.n ?? 0 : 0, existing[0]?.n ?? 0) + 1);
8814
+ const nextN = Math.max(prevCurrent ? existing.find((g) => g.id === prevCurrent)?.n ?? 0 : 0, existing[0]?.n ?? 0) + 1;
8815
+ const id = generationId(nextN);
8842
8816
  const tmpName = `${id}.tmp-${process.pid}`;
8843
8817
  const tmpDir = path.join(gens, tmpName);
8844
8818
  const gb = {
@@ -9074,12 +9048,14 @@ var GenerationBuilder = class {
9074
9048
  const dictionaryPath = path.join(tmpDir, textDictionaryFile(r.name));
9075
9049
  const baseDocsPath = path.join(tmpDir, `${textDocsFile(r.name)}.base`);
9076
9050
  await verifyFileCrcAsync(postingsPath, r.postingsInfo);
9077
- const dictEntries = (await readTextDictionaryImageAsync(await readGenerationFileCheckedAsync(dictionaryPath, "MDTD", 1, r.dictionaryInfo))).map((e) => [e.term, {
9051
+ const dictPayload = await readGenerationFileCheckedAsync(dictionaryPath, "MDTD", 1, r.dictionaryInfo);
9052
+ const dictEntries = (await readTextDictionaryImageAsync(dictPayload)).map((e) => [e.term, {
9078
9053
  off: e.off,
9079
9054
  len: e.len,
9080
9055
  df: e.df
9081
9056
  }]);
9082
- const baseDocs = await readBaseDocsImageAsync(await readGenerationFileCheckedAsync(baseDocsPath, BASE_DOCS_MAGIC, 1, r.baseDocsInfo));
9057
+ const baseDocsPayload = await readGenerationFileCheckedAsync(baseDocsPath, BASE_DOCS_MAGIC, 1, r.baseDocsInfo);
9058
+ const baseDocs = await readBaseDocsImageAsync(baseDocsPayload);
9083
9059
  const containers = await TextIndex.prepareRebaseContainers(dictEntries, baseDocs.keys, baseDocs.docLens);
9084
9060
  target.ti.commitRebase({
9085
9061
  postingsPath,
@@ -9268,8 +9244,7 @@ var GenerationBuilder = class {
9268
9244
  }
9269
9245
  };
9270
9246
 
9271
- //#endregion
9272
- //#region ../../packages/minidb/src/wal-group.ts
9247
+ // ../../packages/minidb/src/wal-group.ts
9273
9248
  var WalGroupTracker = class {
9274
9249
  deps;
9275
9250
  /** Pre-group rollback state of every in-flight flush group, keyed per WAL:
@@ -9416,8 +9391,7 @@ var WalGroupTracker = class {
9416
9391
  }
9417
9392
  };
9418
9393
 
9419
- //#endregion
9420
- //#region ../../packages/minidb/src/write-path.ts
9394
+ // ../../packages/minidb/src/write-path.ts
9421
9395
  var WritePath = class {
9422
9396
  deps;
9423
9397
  /** Scratch out-param for applyOp's pre-state capture. Live only within the
@@ -9825,9 +9799,10 @@ var WritePath = class {
9825
9799
  }
9826
9800
  for (const ti of this.deps.textRegistry.text.values()) {
9827
9801
  const tokens = op.textTokens?.get(ti);
9828
- if (tokens !== void 0) if (tokens === null) ti.remove(op.pk);
9829
- else ti.addPrepared(op.pk, tokens);
9830
- else if (this.deps.indexable(op.canonical)) ti.add(op.pk, op.canonical);
9802
+ if (tokens !== void 0) {
9803
+ if (tokens === null) ti.remove(op.pk);
9804
+ else ti.addPrepared(op.pk, tokens);
9805
+ } else if (this.deps.indexable(op.canonical)) ti.add(op.pk, op.canonical);
9831
9806
  else ti.remove(op.pk);
9832
9807
  }
9833
9808
  } else if (op.type === 2) {
@@ -10015,8 +9990,7 @@ var WritePath = class {
10015
9990
  }
10016
9991
  };
10017
9992
 
10018
- //#endregion
10019
- //#region ../../packages/minidb/src/wipe.ts
9993
+ // ../../packages/minidb/src/wipe.ts
10020
9994
  async function acquireWithWait(lock, timeoutMs) {
10021
9995
  const deadline = Date.now() + timeoutMs;
10022
9996
  let delay = 10;
@@ -10060,8 +10034,7 @@ async function wipeStoreDir(opts) {
10060
10034
  return "wiped";
10061
10035
  }
10062
10036
 
10063
- //#endregion
10064
- //#region ../../packages/minidb/src/lifecycle.ts
10037
+ // ../../packages/minidb/src/lifecycle.ts
10065
10038
  /** The open() flow: configure, acquire, recover, and kick background
10066
10039
  * maintenance. On success the host instance is fully open; on failure every
10067
10040
  * acquired resource is released before the error rethrows. */
@@ -10112,11 +10085,12 @@ async function openMiniDb(db, opts, hooks) {
10112
10085
  });
10113
10086
  if (!db.readOnly) {
10114
10087
  db.lock = new LockFile(path.join(db.dir, "db.lock"));
10115
- if (!await db.lock.acquire()) if (opts.onLockFail === "readonly") {
10116
- db.readOnly = true;
10117
- db.lock = null;
10118
- } else throw new LockError(`database is locked by another process: ${db.dir}`);
10119
- else {
10088
+ if (!await db.lock.acquire()) {
10089
+ if (opts.onLockFail === "readonly") {
10090
+ db.readOnly = true;
10091
+ db.lock = null;
10092
+ } else throw new LockError(`database is locked by another process: ${db.dir}`);
10093
+ } else {
10120
10094
  const heldToken = db.lock.heldToken;
10121
10095
  if (heldToken !== void 0) try {
10122
10096
  opts.onLockAcquired?.({ token: heldToken });
@@ -10331,8 +10305,7 @@ async function openOrRebuildMiniDb(opts, hooks, open) {
10331
10305
  }
10332
10306
  }
10333
10307
 
10334
- //#endregion
10335
- //#region ../../packages/minidb/src/index-admin.ts
10308
+ // ../../packages/minidb/src/index-admin.ts
10336
10309
  var IndexAdmin = class {
10337
10310
  deps;
10338
10311
  constructor(deps) {
@@ -10492,8 +10465,7 @@ var IndexAdmin = class {
10492
10465
  }
10493
10466
  };
10494
10467
 
10495
- //#endregion
10496
- //#region ../../packages/minidb/src/read-path.ts
10468
+ // ../../packages/minidb/src/read-path.ts
10497
10469
  var ReadPath = class {
10498
10470
  deps;
10499
10471
  constructor(deps) {
@@ -10624,8 +10596,7 @@ var ReadPath = class {
10624
10596
  }
10625
10597
  };
10626
10598
 
10627
- //#endregion
10628
- //#region ../../packages/minidb/src/stats.ts
10599
+ // ../../packages/minidb/src/stats.ts
10629
10600
  /** Create the MiniDb stats object (all counters zeroed). */
10630
10601
  function createMiniDbStats() {
10631
10602
  return {
@@ -10718,8 +10689,7 @@ function createMiniDbStats() {
10718
10689
  };
10719
10690
  }
10720
10691
 
10721
- //#endregion
10722
- //#region ../../packages/minidb/src/lifecycle-status.ts
10692
+ // ../../packages/minidb/src/lifecycle-status.ts
10723
10693
  /** The mutable tracker behind MiniDb.lifecycleStatus(); driven by the
10724
10694
  * lifecycle facets through the LifecycleHost / GenerationLoaderDeps views
10725
10695
  * (same shared-by-reference discipline as the stats object). */
@@ -10789,8 +10759,7 @@ var LifecycleTracker = class {
10789
10759
  }
10790
10760
  };
10791
10761
 
10792
- //#endregion
10793
- //#region ../../packages/minidb/src/mini-db.ts
10762
+ // ../../packages/minidb/src/mini-db.ts
10794
10763
  var MiniDb = class MiniDb {
10795
10764
  dir;
10796
10765
  walPath;
@@ -10839,7 +10808,7 @@ var MiniDb = class MiniDb {
10839
10808
  catchUpChain = Promise.resolve();
10840
10809
  readOnly = false;
10841
10810
  lock = null;
10842
- compactThresholdBytes = 64 * 1024 * 1024;
10811
+ compactThresholdBytes = 67108864;
10843
10812
  autoCompact = true;
10844
10813
  compacting = false;
10845
10814
  _compactDone = null;
@@ -10916,7 +10885,7 @@ var MiniDb = class MiniDb {
10916
10885
  * next build uses the in-thread staged path. */
10917
10886
  textWorkerDisabled = false;
10918
10887
  /** Stage 6: worker aggregation memory budget. */
10919
- textBuildMemoryBytes = 128 * 1024 * 1024;
10888
+ textBuildMemoryBytes = 134217728;
10920
10889
  /** TUI-safe worker-slot policy: how long a worker-eligible text build
10921
10890
  * queues for a process-wide slot before the bounded inline core is
10922
10891
  * allowed as the last resort (never the unbounded staged aggregation). */
@@ -11506,12 +11475,14 @@ var MiniDb = class MiniDb {
11506
11475
  if (result.scannedLiveKeys > sizeAtCheckpoint) throw new Error(`text build scanned ${result.scannedLiveKeys} live keys > checkpoint store ${sizeAtCheckpoint} (pinning protocol violation)`);
11507
11476
  const r = result.indexes[0];
11508
11477
  await verifyFileCrcAsync(postingsPath, r.postingsInfo);
11509
- const dictEntries = (await readTextDictionaryImageAsync(await readGenerationFileCheckedAsync(dictionaryPath, "MDTD", 1, r.dictionaryInfo))).map((e) => [e.term, {
11478
+ const dictPayload = await readGenerationFileCheckedAsync(dictionaryPath, "MDTD", 1, r.dictionaryInfo);
11479
+ const dictEntries = (await readTextDictionaryImageAsync(dictPayload)).map((e) => [e.term, {
11510
11480
  off: e.off,
11511
11481
  len: e.len,
11512
11482
  df: e.df
11513
11483
  }]);
11514
- const baseDocs = await readBaseDocsImageAsync(await readGenerationFileCheckedAsync(baseDocsPath, BASE_DOCS_MAGIC, 1, r.baseDocsInfo));
11484
+ const baseDocsPayload = await readGenerationFileCheckedAsync(baseDocsPath, BASE_DOCS_MAGIC, 1, r.baseDocsInfo);
11485
+ const baseDocs = await readBaseDocsImageAsync(baseDocsPayload);
11515
11486
  const containers = await TextIndex.prepareRebaseContainers(dictEntries, baseDocs.keys, baseDocs.docLens);
11516
11487
  const finalPostingsPath = tmpDir !== null ? this.textPostingsPath(name) : postingsPath;
11517
11488
  if (tmpDir !== null) await fs$1.rename(postingsPath, finalPostingsPath);
@@ -11940,8 +11911,7 @@ var MiniDb = class MiniDb {
11940
11911
  }
11941
11912
  };
11942
11913
 
11943
- //#endregion
11944
- //#region ../../packages/minidb/src/error-classification.ts
11914
+ // ../../packages/minidb/src/error-classification.ts
11945
11915
  function classifyStorageError(error) {
11946
11916
  if (error instanceof AggregateError) return error.errors.some((inner) => classifyStorageError(inner) === "rebuild") ? "rebuild" : "transient";
11947
11917
  if (error instanceof SyntaxError || error instanceof CorruptFrameError) return "rebuild";
@@ -11950,12 +11920,10 @@ function classifyStorageError(error) {
11950
11920
  return "transient";
11951
11921
  }
11952
11922
 
11953
- //#endregion
11954
- //#region ../../packages/kap-server/src/search/docs.ts
11923
+ // ../../packages/kap-server/src/search/docs.ts
11955
11924
  const MAX_DOC_TEXT_CHARS = 2e4;
11956
11925
 
11957
- //#endregion
11958
- //#region ../../packages/kap-server/src/search/match.ts
11926
+ // ../../packages/kap-server/src/search/match.ts
11959
11927
  function boundaryWidth(q) {
11960
11928
  return q.mode !== "literal" && q.sort === "score" ? 3 : 2;
11961
11929
  }
@@ -12020,13 +11988,12 @@ var RowTopK = class {
12020
11988
  return this.a.sort((x, y) => compareRows(this.q, x, y));
12021
11989
  }
12022
11990
  };
12023
- const DEADLINE_CHECK_STRIDE = 64;
12024
11991
  function matchDocs(q, docs, boundary, budget) {
12025
11992
  const literalQuery = q.literalQuery;
12026
11993
  const rows = [];
12027
11994
  let i = 0;
12028
11995
  for (const { key, value: doc, score } of docs) {
12029
- if ((i++ & DEADLINE_CHECK_STRIDE - 1) === 0 && Date.now() > budget.deadlineAt) return {
11996
+ if ((i++ & 63) === 0 && Date.now() > budget.deadlineAt) return {
12030
11997
  rows,
12031
11998
  incomplete: "deadline"
12032
11999
  };
@@ -12127,8 +12094,7 @@ function decodePageToken(q, source, token, generation) {
12127
12094
  };
12128
12095
  }
12129
12096
 
12130
- //#endregion
12131
- //#region ../../packages/agent-core-v2/src/agent/media/mediaRef.ts
12097
+ // ../../packages/agent-core-v2/src/agent/media/mediaRef.ts
12132
12098
  const IMAGE_MIME_BY_SUFFIX = Object.freeze({
12133
12099
  ".png": "image/png",
12134
12100
  ".jpg": "image/jpeg",
@@ -12202,24 +12168,23 @@ function matchSingleMediaPathTag(text) {
12202
12168
  return tag.index === 0 && tag.text.length === trimmed.length ? tag : void 0;
12203
12169
  }
12204
12170
 
12205
- //#endregion
12206
- //#region ../../packages/kap-server/src/search/wireExtract.ts
12171
+ // ../../packages/kap-server/src/search/wireExtract.ts
12207
12172
  const NONE = { kind: "none" };
12208
12173
  const ENSURE = { kind: "ensure" };
12209
12174
  const STEP_NONE = { kind: "none" };
12210
- const NON_USER_ORIGIN_KINDS = new Set([
12175
+ const NON_USER_ORIGIN_KINDS = /* @__PURE__ */ new Set([
12211
12176
  "injection",
12212
12177
  "system_trigger",
12213
12178
  "retry",
12214
12179
  "compaction_summary"
12215
12180
  ]);
12216
- const HIDDEN_USER_ORIGINS = new Set([
12181
+ const HIDDEN_USER_ORIGINS = /* @__PURE__ */ new Set([
12217
12182
  "injection",
12218
12183
  "system_trigger",
12219
12184
  "retry"
12220
12185
  ]);
12221
- const TURN_OPENING_SYSTEM_TRIGGERS = new Set(["goal_continuation", "subagent"]);
12222
- const MARKER_USER_ORIGINS = new Set([
12186
+ const TURN_OPENING_SYSTEM_TRIGGERS = /* @__PURE__ */ new Set(["goal_continuation", "subagent"]);
12187
+ const MARKER_USER_ORIGINS = /* @__PURE__ */ new Set([
12223
12188
  "skill_activation",
12224
12189
  "plugin_command",
12225
12190
  "compaction_summary"
@@ -12396,8 +12361,7 @@ function analyzeWireLine(line) {
12396
12361
  };
12397
12362
  }
12398
12363
 
12399
- //#endregion
12400
- //#region ../../packages/kap-server/src/search/indexCore.ts
12364
+ // ../../packages/kap-server/src/search/indexCore.ts
12401
12365
  const TEXT_INDEX_NAME = "body";
12402
12366
  const TRI_INDEX_NAME = "tri";
12403
12367
  const WIRE_FILENAME = "wire.jsonl";
@@ -13580,8 +13544,7 @@ function docKeyPrefix(sessionId, file) {
13580
13544
  return `${sessionId}/${file.agentId}/${file.source}:`;
13581
13545
  }
13582
13546
 
13583
- //#endregion
13584
- //#region ../../packages/kap-server/src/search/worker/entry.ts
13547
+ // ../../packages/kap-server/src/search/worker/entry.ts
13585
13548
  const data = workerData;
13586
13549
  if (typeof data.textBuildWorkerPath === "string") try {
13587
13550
  configureTextBuildWorkerRuntime(data.textBuildWorkerPath);
@@ -13736,5 +13699,4 @@ post({
13736
13699
  v: 1
13737
13700
  });
13738
13701
 
13739
- //#endregion
13740
13702
  export { };