@wirecat/tg-cli 0.133.0 → 0.135.0

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 (153) hide show
  1. package/README.md +2 -3
  2. package/contracts/wirecat.json +82 -2
  3. package/dist/bin/tg.js +2 -2
  4. package/dist/bot/generated/types.d.ts +188 -0
  5. package/dist/bot/generated/types.d.ts.map +1 -1
  6. package/dist/bundle/{adapter-GSGX3WBH.js → adapter-OHJF6PB5.js} +104 -69
  7. package/dist/bundle/agent-QPF2KU4I.js +37 -0
  8. package/dist/bundle/{all-profiles-VOCJ55YH.js → all-profiles-LQ73BIFB.js} +62 -20
  9. package/dist/bundle/{anthropic-J6CTLU3W.js → anthropic-YYBMT2HD.js} +5 -5
  10. package/dist/bundle/{app-server-GVFGA4TJ.js → app-server-HV4C4CSA.js} +72 -62
  11. package/dist/bundle/{bot-api-LWONPIGK.js → bot-api-URQXWMVR.js} +73 -92
  12. package/dist/bundle/{bot-history-XOW7Y2GC.js → bot-history-FRLCHPDQ.js} +23 -22
  13. package/dist/bundle/{bun-436CH6CP.js → bun-J3ML43BO.js} +2 -2
  14. package/dist/bundle/{bun-sqlite-ZLB5RK5Q.js → bun-sqlite-ZNB2B2DL.js} +6 -6
  15. package/dist/bundle/{chunk-UGS57TT5.js → chunk-24G3SEXH.js} +2 -2
  16. package/dist/bundle/chunk-27F6QBPY.js +555 -0
  17. package/dist/bundle/{chunk-6VCSOQFL.js → chunk-2OFCIF2W.js} +2 -2
  18. package/dist/bundle/{chunk-VGN5YXYI.js → chunk-2U7XA4IH.js} +2 -100
  19. package/dist/bundle/{chunk-LBZEZO32.js → chunk-4CLSIEWN.js} +65 -43
  20. package/dist/bundle/chunk-5CEKH6R6.js +340 -0
  21. package/dist/bundle/{chunk-SMI2EUH4.js → chunk-5WEEK65F.js} +1 -1
  22. package/dist/bundle/{chunk-OX73ERZW.js → chunk-6VWVYPH2.js} +3 -4
  23. package/dist/bundle/{chunk-5HKPQPD4.js → chunk-6WS474NQ.js} +6 -6
  24. package/dist/bundle/{chunk-IYAXLLGR.js → chunk-7GWOGEWJ.js} +6 -6
  25. package/dist/bundle/{chunk-TPD37ECC.js → chunk-AMRMU23L.js} +16 -3
  26. package/dist/bundle/{chunk-ZHO3TPHM.js → chunk-B2UXNYCD.js} +30 -15
  27. package/dist/bundle/{chunk-YY6FGKGD.js → chunk-B4ZMFU5I.js} +2 -2
  28. package/dist/bundle/{chunk-54WLIPIQ.js → chunk-BFKPMG5T.js} +1 -1
  29. package/dist/bundle/{chunk-KHUXDSXN.js → chunk-BQSODAU3.js} +1 -1
  30. package/dist/bundle/{chunk-N3JUHGKM.js → chunk-BXUMZWMN.js} +3786 -3364
  31. package/dist/bundle/{chunk-VTQMR3XG.js → chunk-E2VIO7RY.js} +3 -3
  32. package/dist/bundle/{chunk-UZ63ORMY.js → chunk-F5FOS64B.js} +4 -4
  33. package/dist/bundle/{chunk-LIQMUDIZ.js → chunk-GCUFGDKE.js} +2 -2
  34. package/dist/bundle/chunk-GUERS64O.js +108 -0
  35. package/dist/bundle/{chunk-5LRTYBZW.js → chunk-HILS2UL7.js} +12 -12
  36. package/dist/bundle/{chunk-6S77EKZU.js → chunk-IOJOLV25.js} +17 -15
  37. package/dist/bundle/{chunk-IBCXEVNY.js → chunk-JBS4VPAX.js} +3 -3
  38. package/dist/bundle/{chunk-5L44DSHV.js → chunk-K5QGBYDL.js} +4 -4
  39. package/dist/bundle/{chunk-NO2LIHWA.js → chunk-KKXF6TSS.js} +1 -1
  40. package/dist/bundle/chunk-L2ZQDTDU.js +7 -0
  41. package/dist/bundle/{chunk-HB5DP6L5.js → chunk-LFPUW7DR.js} +18 -18
  42. package/dist/bundle/{chunk-QWO7L4UH.js → chunk-LGYATGQI.js} +7 -7
  43. package/dist/bundle/{chunk-IH4Z3KZU.js → chunk-MA27675E.js} +2 -2
  44. package/dist/bundle/{chunk-6H2NW6HK.js → chunk-MDI7554C.js} +3 -3
  45. package/dist/bundle/{chunk-KVFUH5IT.js → chunk-MMZ4QAKJ.js} +1 -1
  46. package/dist/bundle/{chunk-XOX4BX5A.js → chunk-MOPBEBVS.js} +4 -4
  47. package/dist/bundle/{chunk-XKOMP3HV.js → chunk-MPRXUTIK.js} +6 -6
  48. package/dist/bundle/{chunk-QYLZD4DS.js → chunk-N7F5KT6U.js} +1 -1
  49. package/dist/bundle/{chunk-KUA24HWG.js → chunk-NBP6LXSY.js} +2 -2
  50. package/dist/bundle/{chunk-UQYL6TJ7.js → chunk-NP46ZKQW.js} +4 -4
  51. package/dist/bundle/{chunk-QGWISM4W.js → chunk-NRSJXUUO.js} +34 -28
  52. package/dist/bundle/{chunk-7NYP4RBO.js → chunk-NVWZ7S3I.js} +2294 -1221
  53. package/dist/bundle/chunk-OBIMTRA7.js +80 -0
  54. package/dist/bundle/{chunk-VWJTYAIQ.js → chunk-OQJURSRL.js} +17 -17
  55. package/dist/bundle/chunk-OU3WN4YH.js +50 -0
  56. package/dist/bundle/{chunk-VCAOH45X.js → chunk-PBK2ECXT.js} +1 -1
  57. package/dist/bundle/{chunk-TTDZVWDU.js → chunk-PHAFT2BO.js} +1 -1
  58. package/dist/bundle/{chunk-NTWXL2QV.js → chunk-PKIGE4NE.js} +2 -2
  59. package/dist/bundle/{chunk-5D4AEUVA.js → chunk-PL5P7UKW.js} +434 -1
  60. package/dist/bundle/{chunk-NAXOT35J.js → chunk-QBRQLOZA.js} +3 -3
  61. package/dist/bundle/{chunk-RABUG4KA.js → chunk-QD4MTOI7.js} +511 -472
  62. package/dist/bundle/{chunk-LOS4D6ZB.js → chunk-QHQ52UMF.js} +159 -569
  63. package/dist/bundle/{chunk-6CHIGUCY.js → chunk-R2G3MWEF.js} +31 -20
  64. package/dist/bundle/{chunk-THYGLTRB.js → chunk-RCEP5OXD.js} +7 -7
  65. package/dist/bundle/chunk-RHJ2VGHV.js +353 -0
  66. package/dist/bundle/{chunk-QVGEL66U.js → chunk-RXBKVNOK.js} +53 -11
  67. package/dist/bundle/{chunk-ZYAHZKYF.js → chunk-RZ7POTFA.js} +3 -3
  68. package/dist/bundle/{chunk-KEN4B57V.js → chunk-S7PIM4GG.js} +2 -2
  69. package/dist/bundle/{chunk-BXVB42KJ.js → chunk-SIDGH56R.js} +2 -2
  70. package/dist/bundle/{chunk-XDQU5HBO.js → chunk-SRMELB6Q.js} +12 -12
  71. package/dist/bundle/{chunk-SMU6NA7F.js → chunk-SVPNU7PD.js} +4 -4
  72. package/dist/bundle/{chunk-JPNVEPS4.js → chunk-TB2MG6PE.js} +2351 -2028
  73. package/dist/bundle/{chunk-JGMXBAGH.js → chunk-UN5TH2CG.js} +156 -434
  74. package/dist/bundle/{chunk-YAPDU3SV.js → chunk-V3ZWYMXT.js} +1 -1
  75. package/dist/bundle/{chunk-7NF3V5L2.js → chunk-VFU25P57.js} +4 -4
  76. package/dist/bundle/{chunk-LQQSDGQ6.js → chunk-VJEMCJPL.js} +56 -46
  77. package/dist/bundle/{chunk-UIAKLELF.js → chunk-VK2NDTBS.js} +94 -64
  78. package/dist/bundle/{chunk-UKBK2VWZ.js → chunk-W6A2OZ3C.js} +232 -176
  79. package/dist/bundle/{chunk-IPPCQ7IK.js → chunk-WDI6LA4X.js} +2 -2
  80. package/dist/bundle/{chunk-N7QREPZW.js → chunk-WTGRQGQL.js} +16 -9
  81. package/dist/bundle/{chunk-57KJ3TRS.js → chunk-WUCTF2XE.js} +9 -9
  82. package/dist/bundle/{chunk-JKSD43L7.js → chunk-WZCRCCOZ.js} +6 -6
  83. package/dist/bundle/{chunk-H7ML7X3G.js → chunk-XB6O445X.js} +144 -10
  84. package/dist/bundle/{chunk-O6JUVATT.js → chunk-XKFES4EM.js} +35 -12
  85. package/dist/bundle/chunk-YBUX6EAK.js +388 -0
  86. package/dist/bundle/{chunk-WCYKVX3B.js → chunk-YMRL7MYS.js} +7 -7
  87. package/dist/bundle/{chunk-M6QOM6SL.js → chunk-Z6M6NZUX.js} +1 -1
  88. package/dist/bundle/chunk-ZCDRXKCR.js +727 -0
  89. package/dist/bundle/{chunk-6A44ZZFC.js → chunk-ZJ3S4S6H.js} +43 -64
  90. package/dist/bundle/{chunk-TCI7I6YF.js → chunk-ZL7TJXFL.js} +11 -25
  91. package/dist/bundle/{chunk-2KQDJHF3.js → chunk-ZMBVZWUW.js} +29 -1
  92. package/dist/bundle/{chunk-OWY52JBO.js → chunk-ZMTASSIB.js} +7 -7
  93. package/dist/bundle/{chunk-D2SJLZSH.js → chunk-ZQ5ERQHO.js} +2 -2
  94. package/dist/bundle/{chunk-CEJYNB3I.js → chunk-ZWVDXVG3.js} +4 -4
  95. package/dist/bundle/command-contract-K4MU32K6.js +37 -0
  96. package/dist/bundle/{command-server-entry-AE27QXTE.js → command-server-entry-XP6BVJIK.js} +27 -27
  97. package/dist/bundle/{decode-RQPPZ72F.js → decode-TUB45ALX.js} +5 -5
  98. package/dist/bundle/{dispatch-KQO2MCSH.js → dispatch-ICPUKMEG.js} +8 -8
  99. package/dist/bundle/dist-PAKDDIBT.js +191 -0
  100. package/dist/bundle/{echarts-FZRIACN4.js → echarts-HJ7D7XTM.js} +2 -2
  101. package/dist/bundle/{embed-TOSWWMDL.js → embed-4QDN36YF.js} +6 -6
  102. package/dist/bundle/{embedder-JHIQSBGD.js → embedder-Q7ID2LEG.js} +9 -9
  103. package/dist/bundle/{entry-DU4KRXTG.js → entry-Z6VRZP7F.js} +9 -9
  104. package/dist/bundle/{failure-3YC3YGYO.js → failure-PEPNEEK7.js} +2 -2
  105. package/dist/bundle/{first-run-DQQT4FID.js → first-run-GKBEHAAX.js} +12 -12
  106. package/dist/bundle/first-screen-IA3ONZ75.js +37 -0
  107. package/dist/bundle/{instructions-WI64CJQ6.js → instructions-26ZXYYMY.js} +1 -1
  108. package/dist/bundle/{mcp-VMS6PBCU.js → mcp-KGWT6TGO.js} +2 -2
  109. package/dist/bundle/meeting-combined-KUV2HP52.js +23 -0
  110. package/dist/bundle/{meeting-model-XNRSREIK.js → meeting-model-JB7X4CA3.js} +11 -11
  111. package/dist/bundle/{meeting-semantic-OOSCHQMB.js → meeting-semantic-MQNUVG33.js} +6 -6
  112. package/dist/bundle/{node-JLKDNVKV.js → node-RIANITAT.js} +2 -2
  113. package/dist/bundle/{node-sqlite-YOGH26O2.js → node-sqlite-I2P26Z3S.js} +7 -7
  114. package/dist/bundle/{oauth-FOMXM5HP.js → oauth-GFMJL2ZZ.js} +8 -8
  115. package/dist/bundle/{open-SM2UXUKM.js → open-CWVYEFNN.js} +5 -5
  116. package/dist/bundle/{openai-J2H7S6ZF.js → openai-PQLK7YTJ.js} +15 -15
  117. package/dist/bundle/{process-HI7OZBOI.js → process-P4D4KFWE.js} +1 -1
  118. package/dist/bundle/{program-VY4HFU25.js → program-MF4QZJKH.js} +70 -64
  119. package/dist/bundle/{prompt-NUUVFMOF.js → prompt-JWIOYU53.js} +5 -5
  120. package/dist/bundle/{proxy-transport-AN4VMRRN.js → proxy-transport-DWY6ABVT.js} +5 -5
  121. package/dist/bundle/{recognize-MALJHPDI.js → recognize-IPJL4CQZ.js} +4 -4
  122. package/dist/bundle/{remote-QUDRSTS2.js → remote-DVY6F6YO.js} +9 -9
  123. package/dist/bundle/{rerank-2DSO3D3S.js → rerank-XSPWLBIO.js} +7 -7
  124. package/dist/bundle/{serve-NCJ52MY3.js → serve-AJAVEH2M.js} +15 -15
  125. package/dist/bundle/server-GGXUR5BZ.js +78 -0
  126. package/dist/bundle/{server-Y3M544AM.js → server-GII7NIKF.js} +65 -54
  127. package/dist/bundle/{sqlite-runtime-NJUSXVKK.js → sqlite-runtime-KFDYJTUO.js} +6 -6
  128. package/dist/bundle/{state-AVOWQVET.js → state-76OJSCQC.js} +6 -6
  129. package/dist/bundle/{store-MMIYOL4H.js → store-2KJS4YMH.js} +28 -17
  130. package/dist/bundle/{store-BZ5ICDRP.js → store-FBP2J23G.js} +20 -19
  131. package/dist/bundle/store-maintenance-command-NUWOUZ62.js +65 -0
  132. package/dist/bundle/surface-EGSHCISG.js +64 -0
  133. package/dist/bundle/tg.js +13 -13
  134. package/dist/telegram/adapter.d.ts +9 -2
  135. package/dist/telegram/adapter.d.ts.map +1 -1
  136. package/dist/telegram/adapter.js +5 -6
  137. package/dist/telegram/adapter.js.map +1 -1
  138. package/dist/telegram/messages.d.ts +12 -0
  139. package/dist/telegram/messages.d.ts.map +1 -1
  140. package/dist/telegram/messages.js +40 -0
  141. package/dist/telegram/messages.js.map +1 -1
  142. package/dist/version.d.ts +1 -1
  143. package/dist/version.js +1 -1
  144. package/package.json +3 -3
  145. package/skills/tg-cli/SKILL.md +7 -4
  146. package/skills/tg-cli/references/messages.md +5 -1
  147. package/skills/tg-cli/references/search.md +2 -0
  148. package/dist/bundle/chunk-SHTHNBHG.js +0 -2
  149. package/dist/bundle/command-contract-TQIARAB4.js +0 -37
  150. package/dist/bundle/first-screen-7N4CTZSA.js +0 -37
  151. package/dist/bundle/meeting-combined-3RAOFQ7M.js +0 -23
  152. package/dist/bundle/server-CHGON5I2.js +0 -70
  153. package/dist/bundle/store-maintenance-command-VKZ4WHUB.js +0 -61
@@ -2,7 +2,7 @@ import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  defineReasons
5
- } from "./chunk-QVGEL66U.js";
5
+ } from "./chunk-RXBKVNOK.js";
6
6
 
7
7
  // dist/reasons.js
8
8
  var REASONS = defineReasons([
@@ -26,7 +26,7 @@ var REASONS = defineReasons([
26
26
  ].map(([reason, code, message]) => ({ reason, code, message, details: [] })));
27
27
 
28
28
  // dist/version.js
29
- var VERSION = "0.133.0";
29
+ var VERSION = "0.135.0";
30
30
 
31
31
  // dist/identity.js
32
32
  var TG = {
@@ -2,7 +2,7 @@ import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  tagOf
5
- } from "./chunk-IH4Z3KZU.js";
5
+ } from "./chunk-MA27675E.js";
6
6
  import {
7
7
  QUERY_LIMITS,
8
8
  parseLucene,
@@ -10,19 +10,19 @@ import {
10
10
  queryError,
11
11
  validateQuery,
12
12
  walkQuery
13
- } from "./chunk-RABUG4KA.js";
13
+ } from "./chunk-QD4MTOI7.js";
14
14
  import {
15
15
  safeParse
16
- } from "./chunk-QVGEL66U.js";
16
+ } from "./chunk-RXBKVNOK.js";
17
17
  import {
18
18
  CliError,
19
19
  isCliError
20
- } from "./chunk-LIQMUDIZ.js";
20
+ } from "./chunk-GCUFGDKE.js";
21
21
  import {
22
22
  __name
23
23
  } from "./chunk-ZVVMGPBJ.js";
24
24
 
25
- // node_modules/.pnpm/@wirecat+cli-core@0.681.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.106.0_commander@15_8d845c31697914d824aa80d8eec93941/node_modules/@wirecat/cli-core/dist/search/fusion.js
25
+ // node_modules/.pnpm/@wirecat+cli-core@0.718.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.126.1_commander@15_05e4e157d64d32ce6fc62270b9552a1d/node_modules/@wirecat/cli-core/dist/search/fusion.js
26
26
  var RRF_K = 60;
27
27
  var fuseRanked = /* @__PURE__ */ __name((lists, facts) => {
28
28
  const rows = lists.flatMap((list) => list.map((item, rank) => ({ item, vote: 1 / (RRF_K + rank + 1), ...facts(item) })));
@@ -30,7 +30,7 @@ var fuseRanked = /* @__PURE__ */ __name((lists, facts) => {
30
30
  return rows.sort((a, b) => Number(b.exact === true) - Number(a.exact === true) || (ranking ? Number(b.ranked) - Number(a.ranked) || b.vote - a.vote : 0) || b.at - a.at).map(({ item }) => item);
31
31
  }, "fuseRanked");
32
32
 
33
- // node_modules/.pnpm/@wirecat+cli-core@0.681.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.106.0_commander@15_8d845c31697914d824aa80d8eec93941/node_modules/@wirecat/cli-core/dist/search/lucene/types.js
33
+ // node_modules/.pnpm/@wirecat+cli-core@0.718.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.126.1_commander@15_05e4e157d64d32ce6fc62270b9552a1d/node_modules/@wirecat/cli-core/dist/search/lucene/types.js
34
34
  var QUERY_VERSION = 1;
35
35
  var QUERY_LIMITS2 = {
36
36
  ...QUERY_LIMITS,
@@ -59,6 +59,12 @@ function outOfTime(limitMs = QUERY_LIMITS2.milliseconds) {
59
59
  }
60
60
  __name(outOfTime, "outOfTime");
61
61
  var isQueryLimit = /* @__PURE__ */ __name((error) => isCliError(error) && (error.details.reason === "query.too-large" || error.details.reason === "query.time-limit"), "isQueryLimit");
62
+ var SQLITE_TOO_LARGE = /nested too deep|too many terms in compound SELECT|Expression tree is too large|parser stack overflow/;
63
+ var sqliteLimit = /* @__PURE__ */ __name((error) => {
64
+ if (error instanceof Error && SQLITE_TOO_LARGE.test(error.message))
65
+ exhausted("nodes");
66
+ return error;
67
+ }, "sqliteLimit");
62
68
  function exhausted(budget) {
63
69
  throw new CliError("validation_error", `search exceeded its ${budget} budget \u2014 narrow the chat or date range`, {
64
70
  reason: "query.too-large",
@@ -75,7 +81,7 @@ function tooWideTerm([term], budget) {
75
81
  }
76
82
  __name(tooWideTerm, "tooWideTerm");
77
83
 
78
- // node_modules/.pnpm/@wirecat+cli-core@0.681.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.106.0_commander@15_8d845c31697914d824aa80d8eec93941/node_modules/@wirecat/cli-core/dist/search/lucene/registry.js
84
+ // node_modules/.pnpm/@wirecat+cli-core@0.718.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.126.1_commander@15_05e4e157d64d32ce6fc62270b9552a1d/node_modules/@wirecat/cli-core/dist/search/lucene/registry.js
79
85
  var FIELD_VERSION = 2;
80
86
  var UNITS = {
81
87
  "": 1,
@@ -604,7 +610,7 @@ var validateAst = /* @__PURE__ */ __name((input, options = {}) => {
604
610
  return validateFields(parsed.output, options);
605
611
  }, "validateAst");
606
612
 
607
- // node_modules/.pnpm/@wirecat+cli-core@0.681.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.106.0_commander@15_8d845c31697914d824aa80d8eec93941/node_modules/@wirecat/cli-core/dist/search/lucene/plain.js
613
+ // node_modules/.pnpm/@wirecat+cli-core@0.718.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.126.1_commander@15_05e4e157d64d32ce6fc62270b9552a1d/node_modules/@wirecat/cli-core/dist/search/lucene/plain.js
608
614
  var REPAIRED = /* @__PURE__ */ new Set([
609
615
  "query.invalid-syntax",
610
616
  "query.unclosed-literal",
@@ -648,7 +654,7 @@ var literal = /* @__PURE__ */ __name((word, keepParens, fields) => {
648
654
  const prefix = FIELD_PREFIX.exec(word);
649
655
  const field = prefix && fields.has(prefix[1] ?? "") ? prefix[0] : "";
650
656
  const rest = word.slice(field.length);
651
- const opening = keepParens ? /^[(+-]*/u.exec(rest)?.[0] ?? "" : "";
657
+ const opening = keepParens ? (field ? /^\(*/u : /^[(+-]*/u).exec(rest)?.[0] ?? "" : "";
652
658
  const closing = keepParens ? /\)*$/u.exec(rest.slice(opening.length))?.[0] ?? "" : "";
653
659
  const body = rest.slice(opening.length, rest.length - closing.length);
654
660
  if (!body)
@@ -756,6 +762,7 @@ export {
756
762
  searchTimeLimit,
757
763
  outOfTime,
758
764
  isQueryLimit,
765
+ sqliteLimit,
759
766
  exhausted,
760
767
  tooWideTerm,
761
768
  FIELD_VERSION,
@@ -2,20 +2,20 @@ import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  unit
5
- } from "./chunk-6A44ZZFC.js";
5
+ } from "./chunk-ZJ3S4S6H.js";
6
6
  import {
7
7
  PLAIN_HTTP_REFUSED,
8
8
  modelAddressAllowed,
9
9
  onThisComputer
10
- } from "./chunk-H7ML7X3G.js";
10
+ } from "./chunk-XB6O445X.js";
11
11
  import {
12
12
  readSharedSection,
13
13
  sharedConfigPath,
14
14
  writeSharedSection
15
- } from "./chunk-WCYKVX3B.js";
15
+ } from "./chunk-YMRL7MYS.js";
16
16
  import {
17
17
  storePath
18
- } from "./chunk-6VCSOQFL.js";
18
+ } from "./chunk-2OFCIF2W.js";
19
19
  import {
20
20
  boolean,
21
21
  isoTimestamp,
@@ -23,18 +23,18 @@ import {
23
23
  safeParse,
24
24
  strictObject,
25
25
  string
26
- } from "./chunk-QVGEL66U.js";
26
+ } from "./chunk-RXBKVNOK.js";
27
27
  import {
28
28
  CliError
29
- } from "./chunk-LIQMUDIZ.js";
29
+ } from "./chunk-GCUFGDKE.js";
30
30
  import {
31
31
  __name
32
32
  } from "./chunk-ZVVMGPBJ.js";
33
33
 
34
- // node_modules/.pnpm/@wirecat+cli-core@0.681.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.106.0_commander@15_8d845c31697914d824aa80d8eec93941/node_modules/@wirecat/cli-core/dist/embeddings/remote.js
34
+ // node_modules/.pnpm/@wirecat+cli-core@0.718.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.126.1_commander@15_05e4e157d64d32ce6fc62270b9552a1d/node_modules/@wirecat/cli-core/dist/embeddings/remote.js
35
35
  import { setTimeout } from "node:timers/promises";
36
36
 
37
- // node_modules/.pnpm/@wirecat+cli-core@0.681.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.106.0_commander@15_8d845c31697914d824aa80d8eec93941/node_modules/@wirecat/cli-core/dist/models/local-only.js
37
+ // node_modules/.pnpm/@wirecat+cli-core@0.718.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.126.1_commander@15_05e4e157d64d32ce6fc62270b9552a1d/node_modules/@wirecat/cli-core/dist/models/local-only.js
38
38
  var SECTION = "local_only";
39
39
  var Setting = strictObject({
40
40
  on: boolean(),
@@ -68,7 +68,7 @@ var refuseModelAddress = /* @__PURE__ */ __name((env, address, what) => {
68
68
  refuseOffComputer(env, address, what);
69
69
  }, "refuseModelAddress");
70
70
 
71
- // node_modules/.pnpm/@wirecat+cli-core@0.681.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.106.0_commander@15_8d845c31697914d824aa80d8eec93941/node_modules/@wirecat/cli-core/dist/embeddings/remote.js
71
+ // node_modules/.pnpm/@wirecat+cli-core@0.718.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.126.1_commander@15_05e4e157d64d32ce6fc62270b9552a1d/node_modules/@wirecat/cli-core/dist/embeddings/remote.js
72
72
  var OPENAI_URL = "https://api.openai.com/v1";
73
73
  var OPENAI_MODELS = {
74
74
  "text-embedding-3-small": { dims: 1536, perMillion: 0.02 },
@@ -3,15 +3,15 @@ const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  filesPresent,
5
5
  sharedModelsDirectory
6
- } from "./chunk-5L44DSHV.js";
6
+ } from "./chunk-K5QGBYDL.js";
7
7
  import {
8
8
  readSharedSection,
9
9
  sharedConfigPath,
10
10
  writeSharedSection
11
- } from "./chunk-WCYKVX3B.js";
11
+ } from "./chunk-YMRL7MYS.js";
12
12
  import {
13
13
  storePath
14
- } from "./chunk-6VCSOQFL.js";
14
+ } from "./chunk-2OFCIF2W.js";
15
15
  import {
16
16
  array,
17
17
  check,
@@ -32,15 +32,15 @@ import {
32
32
  string,
33
33
  trim,
34
34
  url
35
- } from "./chunk-QVGEL66U.js";
35
+ } from "./chunk-RXBKVNOK.js";
36
36
  import {
37
37
  CliError
38
- } from "./chunk-LIQMUDIZ.js";
38
+ } from "./chunk-GCUFGDKE.js";
39
39
  import {
40
40
  __name
41
41
  } from "./chunk-ZVVMGPBJ.js";
42
42
 
43
- // node_modules/.pnpm/@wirecat+cli-core@0.681.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.106.0_commander@15_8d845c31697914d824aa80d8eec93941/node_modules/@wirecat/cli-core/dist/embeddings/models.js
43
+ // node_modules/.pnpm/@wirecat+cli-core@0.718.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.126.1_commander@15_05e4e157d64d32ce6fc62270b9552a1d/node_modules/@wirecat/cli-core/dist/embeddings/models.js
44
44
  import { existsSync } from "node:fs";
45
45
  import { join } from "node:path";
46
46
  var huggingFace = /* @__PURE__ */ __name((repository, commit) => (name) => `https://huggingface.co/${repository}/resolve/${commit}/${name}`, "huggingFace");
@@ -3,12 +3,97 @@ const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  CliError,
5
5
  isCliError
6
- } from "./chunk-LIQMUDIZ.js";
6
+ } from "./chunk-GCUFGDKE.js";
7
7
  import {
8
8
  __name
9
9
  } from "./chunk-ZVVMGPBJ.js";
10
10
 
11
- // node_modules/.pnpm/@wirecat+cli-base@0.106.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/http/hosts.js
11
+ // node_modules/.pnpm/@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/http/body.js
12
+ var interrupted = /* @__PURE__ */ __name((signal) => isCliError(signal.reason) ? signal.reason : new CliError(signal.reason instanceof Error && signal.reason.name === "TimeoutError" ? "timeout" : "cancelled", "HTTP response read was interrupted"), "interrupted");
13
+ var checked = /* @__PURE__ */ __name((signal) => {
14
+ if (signal?.aborted)
15
+ throw interrupted(signal);
16
+ }, "checked");
17
+ var abortable = /* @__PURE__ */ __name(async (pending, signal) => {
18
+ if (!signal)
19
+ return pending;
20
+ let abort = /* @__PURE__ */ __name(() => {
21
+ }, "abort");
22
+ const stopped = new Promise((_, reject) => {
23
+ abort = /* @__PURE__ */ __name(() => reject(interrupted(signal)), "abort");
24
+ signal.addEventListener("abort", abort, { once: true });
25
+ if (signal.aborted)
26
+ abort();
27
+ });
28
+ try {
29
+ return await Promise.race([pending, stopped]);
30
+ } finally {
31
+ signal.removeEventListener("abort", abort);
32
+ }
33
+ }, "abortable");
34
+ var readJsonResponse = /* @__PURE__ */ __name(async (response, options) => {
35
+ const { maxBytes, signal } = options ?? {};
36
+ if (!Number.isSafeInteger(maxBytes) || maxBytes < 1)
37
+ throw new CliError("validation_error", "maxBytes must be a positive safe integer");
38
+ if (signal !== void 0 && !(signal instanceof AbortSignal))
39
+ throw new CliError("validation_error", "signal must be an AbortSignal");
40
+ if (signal?.aborted) {
41
+ void response.body?.cancel().catch(() => {
42
+ });
43
+ throw interrupted(signal);
44
+ }
45
+ const length = response.headers.get("content-length");
46
+ if (length !== null && (!/^\d+$/.test(length) || Number(length) > maxBytes)) {
47
+ void response.body?.cancel().catch(() => {
48
+ });
49
+ throw new CliError("invalid_response", "HTTP response exceeds the byte budget");
50
+ }
51
+ if (!response.body)
52
+ throw new CliError("invalid_response", "HTTP response has no body");
53
+ if (response.body.locked)
54
+ throw new CliError("invalid_response", "HTTP response body is already in use");
55
+ const reader = response.body.getReader();
56
+ const chunks = [];
57
+ let bytes = 0;
58
+ try {
59
+ for (; ; ) {
60
+ checked(signal);
61
+ const part = await abortable(reader.read(), signal);
62
+ checked(signal);
63
+ if (part.done)
64
+ break;
65
+ if (!(part.value instanceof Uint8Array))
66
+ throw new CliError("invalid_response", "HTTP response is not bytes");
67
+ bytes += part.value.byteLength;
68
+ if (bytes > maxBytes)
69
+ throw new CliError("invalid_response", "HTTP response exceeds the byte budget");
70
+ if (part.value.byteLength)
71
+ chunks.push(new Uint8Array(part.value));
72
+ }
73
+ const body = new Uint8Array(bytes);
74
+ let offset = 0;
75
+ for (const chunk of chunks) {
76
+ body.set(chunk, offset);
77
+ offset += chunk.byteLength;
78
+ }
79
+ try {
80
+ return JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(body));
81
+ } catch {
82
+ throw new CliError("invalid_response", "HTTP response is not valid UTF-8 JSON");
83
+ }
84
+ } catch (error) {
85
+ checked(signal);
86
+ if (isCliError(error))
87
+ throw error;
88
+ throw new CliError("network_error", "HTTP response could not be read");
89
+ } finally {
90
+ void reader.cancel().catch(() => {
91
+ });
92
+ reader.releaseLock();
93
+ }
94
+ }, "readJsonResponse");
95
+
96
+ // node_modules/.pnpm/@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/http/hosts.js
12
97
  var LABEL = "[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?";
13
98
  var HOST_PATTERN = new RegExp(`^(?:${LABEL}(?:\\.${LABEL})*|\\*\\.${LABEL}(?:\\.${LABEL})+)$`);
14
99
  var hostProblems = /* @__PURE__ */ __name((hosts) => [
@@ -20,7 +105,7 @@ var hostCovered = /* @__PURE__ */ __name((hostname, hosts) => {
20
105
  return hosts.some((host) => host.startsWith("*.") ? name.endsWith(host.slice(1)) : name === host);
21
106
  }, "hostCovered");
22
107
 
23
- // node_modules/.pnpm/@wirecat+cli-base@0.106.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/http/fetch.js
108
+ // node_modules/.pnpm/@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/http/fetch.js
24
109
  var HOST_FETCH_TIMEOUT_MS = 3e4;
25
110
  var REDIRECTS = 5;
26
111
  var REDIRECT_STATUSES = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
@@ -46,7 +131,7 @@ var released = /* @__PURE__ */ __name((response, clear) => {
46
131
  return Object.defineProperties(wrapped, { url: { value: url }, redirected: { value: redirected } });
47
132
  }, "released");
48
133
  var undeclared = /* @__PURE__ */ __name((url) => new CliError("configuration_error", `${url.hostname} is not a host this CLI declares: add "${url.hostname}" to \`hosts\` in its WCAT identity and run cli-dev manifest`, { reason: "network.host-undeclared", sent: false }), "undeclared");
49
- var checked = /* @__PURE__ */ __name((url, hosts) => {
134
+ var checked2 = /* @__PURE__ */ __name((url, hosts) => {
50
135
  if (url.protocol !== "https:" && url.protocol !== "http:")
51
136
  throw new CliError("validation_error", `only http and https are fetched, not ${url.protocol.replace(/:$/, "")}`, {
52
137
  sent: false
@@ -55,14 +140,35 @@ var checked = /* @__PURE__ */ __name((url, hosts) => {
55
140
  throw undeclared(url);
56
141
  return url;
57
142
  }, "checked");
143
+ var ENCODED_SLASH = /%2f|%5c/i;
144
+ var scopeOf = /* @__PURE__ */ __name((scope) => {
145
+ if (scope === void 0)
146
+ return void 0;
147
+ if (!URL.canParse(scope))
148
+ throw new CliError("configuration_error", `credentialScope ${scope} is not a URL`);
149
+ const { origin, pathname } = new URL(scope);
150
+ const prefix = pathname.endsWith("/") ? pathname : `${pathname}/`;
151
+ return (url) => url.origin === origin && (url.pathname === pathname || url.pathname.startsWith(prefix)) && !ENCODED_SLASH.test(url.pathname);
152
+ }, "scopeOf");
153
+ var signedHeaders = /* @__PURE__ */ __name((headers) => CREDENTIAL_HEADERS.some((name) => headers.has(name)), "signedHeaders");
154
+ var NOT_SENT = /* @__PURE__ */ new Set(["EAI_AGAIN", "ENOTFOUND", "ECONNREFUSED"]);
155
+ var neverSent = /* @__PURE__ */ __name((error) => {
156
+ for (let at = error, depth = 0; at instanceof Error && depth < 4; at = at.cause, depth++) {
157
+ const code = at.code;
158
+ if (typeof code === "string" && NOT_SENT.has(code))
159
+ return true;
160
+ }
161
+ return false;
162
+ }, "neverSent");
58
163
  var hostFetch = /* @__PURE__ */ __name((options) => {
59
164
  const problems = hostProblems(options.hosts);
60
165
  if (problems.length > 0)
61
166
  throw new CliError("configuration_error", problems.join("; "));
62
167
  const { hosts, fetch: send = globalThis.fetch, timeoutMs = HOST_FETCH_TIMEOUT_MS, redirects = REDIRECTS } = options;
168
+ const inScope = scopeOf(options.credentialScope);
63
169
  return async (input, init = {}) => {
64
170
  const request = input instanceof Request ? input : void 0;
65
- let url = checked(new URL(request?.url ?? String(input)), hosts);
171
+ let url = checked2(new URL(request?.url ?? String(input)), hosts);
66
172
  const caller = init.signal ?? request?.signal;
67
173
  const timeout = deadline(timeoutMs);
68
174
  const signal = caller ? AbortSignal.any([caller, timeout.signal]) : timeout.signal;
@@ -70,8 +176,14 @@ var hostFetch = /* @__PURE__ */ __name((options) => {
70
176
  let method = (init.method ?? request?.method ?? "GET").toUpperCase();
71
177
  let body = init.body ?? request?.body ?? void 0;
72
178
  const headers = new Headers(init.headers ?? request?.headers);
179
+ if (inScope && signedHeaders(headers) && !inScope(url))
180
+ throw new CliError("configuration_error", `the sign-in goes only under ${options.credentialScope}, not ${url.origin}${url.pathname}`, {
181
+ sent: false
182
+ });
183
+ let answered = false;
73
184
  try {
74
185
  let response = await send(input, { ...init, signal, ...follow ? { redirect: "manual" } : {} });
186
+ answered = true;
75
187
  for (let hop = 0; follow && REDIRECT_STATUSES.has(response.status); hop += 1) {
76
188
  const location = response.headers.get("location");
77
189
  if (!location)
@@ -80,7 +192,7 @@ var hostFetch = /* @__PURE__ */ __name((options) => {
80
192
  throw new CliError("invalid_response", `more than ${redirects} redirects from ${url.hostname}`);
81
193
  void response.body?.cancel().catch(() => {
82
194
  });
83
- const next = checked(new URL(location, url), hosts);
195
+ const next = checked2(new URL(location, url), hosts);
84
196
  if (response.status === 303 || (response.status === 301 || response.status === 302) && method === "POST") {
85
197
  method = method === "HEAD" ? "HEAD" : "GET";
86
198
  body = void 0;
@@ -88,7 +200,7 @@ var hostFetch = /* @__PURE__ */ __name((options) => {
88
200
  headers.delete("content-length");
89
201
  } else if (body instanceof ReadableStream)
90
202
  throw new CliError("invalid_response", `${url.hostname} redirected a streamed body, which cannot be sent again`);
91
- if (next.origin !== url.origin)
203
+ if (inScope ? !inScope(next) : next.origin !== url.origin)
92
204
  for (const name of CREDENTIAL_HEADERS)
93
205
  headers.delete(name);
94
206
  url = next;
@@ -103,12 +215,15 @@ var hostFetch = /* @__PURE__ */ __name((options) => {
103
215
  throw isCliError(caller.reason) ? caller.reason : new CliError("cancelled", "request cancelled");
104
216
  if (timeout.signal.aborted)
105
217
  throw new CliError("timeout", `${url.hostname} did not answer within ${timeoutMs} ms`, { retryable: true });
106
- throw new CliError("network_error", `${url.hostname} could not be reached`, { retryable: true });
218
+ throw new CliError("network_error", `${url.hostname} could not be reached`, {
219
+ retryable: true,
220
+ ...!answered && neverSent(error) ? { sent: false } : {}
221
+ });
107
222
  }
108
223
  };
109
224
  }, "hostFetch");
110
225
 
111
- // node_modules/.pnpm/@wirecat+cli-base@0.106.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/http/index.js
226
+ // node_modules/.pnpm/@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/http/index.js
112
227
  var parseRetryAfter = /* @__PURE__ */ __name((header, now) => {
113
228
  if (!header)
114
229
  return void 0;
@@ -131,8 +246,25 @@ var parseRateLimitReset = /* @__PURE__ */ __name((header, now) => {
131
246
  return delta > 0 ? delta : void 0;
132
247
  }, "parseRateLimitReset");
133
248
  var providerWaitMs = /* @__PURE__ */ __name((headers, now) => parseRetryAfter(headers.get("retry-after"), now) ?? parseRateLimitReset(headers.get("x-ratelimit-reset"), now), "providerWaitMs");
249
+ var statusToCode = /* @__PURE__ */ __name((status) => {
250
+ if (status === 400 || status === 422)
251
+ return "validation_error";
252
+ if (status === 401)
253
+ return "authentication_error";
254
+ if (status === 403)
255
+ return "permission_error";
256
+ if (status === 404)
257
+ return "not_found";
258
+ if (status === 408)
259
+ return "timeout";
260
+ if (status === 429)
261
+ return "rate_limited";
262
+ if (status === 502 || status === 503 || status === 504)
263
+ return "provider_unavailable";
264
+ return "provider_error";
265
+ }, "statusToCode");
134
266
 
135
- // node_modules/.pnpm/@wirecat+cli-core@0.681.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.106.0_commander@15_8d845c31697914d824aa80d8eec93941/node_modules/@wirecat/cli-core/dist/models/endpoint.js
267
+ // node_modules/.pnpm/@wirecat+cli-core@0.718.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.126.1_commander@15_05e4e157d64d32ce6fc62270b9552a1d/node_modules/@wirecat/cli-core/dist/models/endpoint.js
136
268
  var endpoint = /* @__PURE__ */ __name((value) => {
137
269
  try {
138
270
  const url = new URL(value);
@@ -186,8 +318,10 @@ var endpointFetch = /* @__PURE__ */ __name((address, timeoutMs) => {
186
318
  }, "endpointFetch");
187
319
 
188
320
  export {
321
+ readJsonResponse,
189
322
  hostFetch,
190
323
  providerWaitMs,
324
+ statusToCode,
191
325
  endpoint,
192
326
  onThisComputer,
193
327
  modelAddressAllowed,
@@ -2,15 +2,15 @@ import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  normalize
5
- } from "./chunk-TTDZVWDU.js";
5
+ } from "./chunk-PHAFT2BO.js";
6
6
  import {
7
7
  CliError
8
- } from "./chunk-LIQMUDIZ.js";
8
+ } from "./chunk-GCUFGDKE.js";
9
9
  import {
10
10
  __name
11
11
  } from "./chunk-ZVVMGPBJ.js";
12
12
 
13
- // node_modules/.pnpm/@wirecat+cli-core@0.681.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.106.0_commander@15_8d845c31697914d824aa80d8eec93941/node_modules/@wirecat/cli-core/dist/search/languages.js
13
+ // node_modules/.pnpm/@wirecat+cli-core@0.718.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.126.1_commander@15_05e4e157d64d32ce6fc62270b9552a1d/node_modules/@wirecat/cli-core/dist/search/languages.js
14
14
  var LANGUAGES = [
15
15
  { name: "russian", code: "ru", label: "Russian", script: "cyrillic", dictionary: "dictionary-ru" },
16
16
  { name: "english", code: "en", label: "English", script: "latin", dictionary: "dictionary-en" },
@@ -18,7 +18,7 @@ var LANGUAGES = [
18
18
  ];
19
19
  var languagesOf = /* @__PURE__ */ __name((script) => LANGUAGES.filter((one) => one.script === script).map(({ name }) => name), "languagesOf");
20
20
 
21
- // node_modules/.pnpm/@wirecat+cli-core@0.681.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.106.0_commander@15_8d845c31697914d824aa80d8eec93941/node_modules/@wirecat/cli-core/dist/search/snowball/base-stemmer.js
21
+ // node_modules/.pnpm/@wirecat+cli-core@0.718.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.126.1_commander@15_05e4e157d64d32ce6fc62270b9552a1d/node_modules/@wirecat/cli-core/dist/search/snowball/base-stemmer.js
22
22
  var BaseStemmer = class {
23
23
  static {
24
24
  __name(this, "BaseStemmer");
@@ -393,7 +393,7 @@ var BaseStemmer = class {
393
393
  }
394
394
  };
395
395
 
396
- // node_modules/.pnpm/@wirecat+cli-core@0.681.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.106.0_commander@15_8d845c31697914d824aa80d8eec93941/node_modules/@wirecat/cli-core/dist/search/snowball/english-stemmer.js
396
+ // node_modules/.pnpm/@wirecat+cli-core@0.718.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.126.1_commander@15_05e4e157d64d32ce6fc62270b9552a1d/node_modules/@wirecat/cli-core/dist/search/snowball/english-stemmer.js
397
397
  var a_0 = [
398
398
  ["arsen", -1],
399
399
  ["commun", -1],
@@ -1094,7 +1094,7 @@ var english_stemmer_default = class extends BaseStemmer {
1094
1094
  stemWord = this.stem;
1095
1095
  };
1096
1096
 
1097
- // node_modules/.pnpm/@wirecat+cli-core@0.681.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.106.0_commander@15_8d845c31697914d824aa80d8eec93941/node_modules/@wirecat/cli-core/dist/search/snowball/russian-stemmer.js
1097
+ // node_modules/.pnpm/@wirecat+cli-core@0.718.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.126.1_commander@15_05e4e157d64d32ce6fc62270b9552a1d/node_modules/@wirecat/cli-core/dist/search/snowball/russian-stemmer.js
1098
1098
  var a_02 = [
1099
1099
  ["\u0432", 1],
1100
1100
  ["\u0438\u0432", 2, 1],
@@ -1517,7 +1517,7 @@ var russian_stemmer_default = class extends BaseStemmer {
1517
1517
  stemWord = this.stem;
1518
1518
  };
1519
1519
 
1520
- // node_modules/.pnpm/@wirecat+cli-core@0.681.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.106.0_commander@15_8d845c31697914d824aa80d8eec93941/node_modules/@wirecat/cli-core/dist/search/snowball/spanish-stemmer.js
1520
+ // node_modules/.pnpm/@wirecat+cli-core@0.718.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.126.1_commander@15_05e4e157d64d32ce6fc62270b9552a1d/node_modules/@wirecat/cli-core/dist/search/snowball/spanish-stemmer.js
1521
1521
  var a_03 = [
1522
1522
  ["", 6],
1523
1523
  ["\xE1", 1, 1],
@@ -2193,12 +2193,13 @@ var spanish_stemmer_default = class extends BaseStemmer {
2193
2193
  stemWord = this.stem;
2194
2194
  };
2195
2195
 
2196
- // node_modules/.pnpm/@wirecat+cli-core@0.681.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.106.0_commander@15_8d845c31697914d824aa80d8eec93941/node_modules/@wirecat/cli-core/dist/search/stem.js
2196
+ // node_modules/.pnpm/@wirecat+cli-core@0.718.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.126.1_commander@15_05e4e157d64d32ce6fc62270b9552a1d/node_modules/@wirecat/cli-core/dist/search/stem.js
2197
2197
  var SNOWBALL_VERSION = "3.1.1";
2198
2198
  var CYRILLIC_STEMMERS = [...languagesOf("cyrillic"), "none"];
2199
2199
  var LATIN_STEMMERS = [...languagesOf("latin"), "none"];
2200
2200
  var DEFAULT_STEMMERS = { cyrillic: "russian", latin: "english,spanish" };
2201
2201
  var DEFAULT_STEMMERS_VERSION = 2;
2202
+ var START_LETTERS = 4;
2202
2203
  var STEM_SEPARATOR = "0stemsep0";
2203
2204
  var STEM_CACHE_LIMIT = 2e5;
2204
2205
  var analyzerIdentity = /* @__PURE__ */ __name((stemmers) => `snowball-${SNOWBALL_VERSION} cyrillic=${stemmers.cyrillic} latin=${stemmers.latin}`, "analyzerIdentity");
@@ -2233,7 +2234,12 @@ var snowball = {
2233
2234
  english: /* @__PURE__ */ __name(() => new english_stemmer_default(), "english"),
2234
2235
  none: /* @__PURE__ */ __name(() => null, "none")
2235
2236
  };
2236
- var createStemmer = /* @__PURE__ */ __name((stemmers = DEFAULT_STEMMERS, { cacheLimit = STEM_CACHE_LIMIT } = {}) => {
2237
+ var cutsDeep = /* @__PURE__ */ __name((stemmer, token) => {
2238
+ const word = [...normalize(token.normalize("NFC").toLowerCase().replace(MARKS, ""))];
2239
+ const stem = [...stemmer.stemToken(token)];
2240
+ return stem.length < 4 && word.length - stem.length >= 2;
2241
+ }, "cutsDeep");
2242
+ var createStemmer = /* @__PURE__ */ __name((stemmers = DEFAULT_STEMMERS, { cacheLimit = STEM_CACHE_LIMIT, whole = /* @__PURE__ */ new Set() } = {}) => {
2237
2243
  const valid = parseStemmers(stemmers);
2238
2244
  const cyrillic = snowball[valid.cyrillic]();
2239
2245
  const latinNames = valid.latin.split(",");
@@ -2258,6 +2264,21 @@ var createStemmer = /* @__PURE__ */ __name((stemmers = DEFAULT_STEMMERS, { cache
2258
2264
  return stem;
2259
2265
  }, "stemOf");
2260
2266
  const stemToken = /* @__PURE__ */ __name((token) => stemOf(token, 0), "stemToken");
2267
+ const queryStemOf = /* @__PURE__ */ __name((token, variant) => {
2268
+ const word = normalize(token.normalize("NFC").toLowerCase().replace(MARKS, ""));
2269
+ return whole.has(word) ? word : stemOf(token, variant);
2270
+ }, "queryStemOf");
2271
+ const querySequences = /* @__PURE__ */ __name((text) => {
2272
+ const seen = /* @__PURE__ */ new Set();
2273
+ return latins.flatMap((_, variant) => {
2274
+ const sequence = tokensOf(text).map((token) => queryStemOf(token, variant)).filter(Boolean);
2275
+ const key = sequence.join(" ");
2276
+ if (seen.has(key))
2277
+ return [];
2278
+ seen.add(key);
2279
+ return [sequence];
2280
+ });
2281
+ }, "querySequences");
2261
2282
  const tokensOf = /* @__PURE__ */ __name((text) => text.normalize("NFC").toLowerCase().match(TOKEN) ?? [], "tokensOf");
2262
2283
  const stemSequences = /* @__PURE__ */ __name((text) => {
2263
2284
  const tokens = tokensOf(text);
@@ -2279,16 +2300,16 @@ var createStemmer = /* @__PURE__ */ __name((stemmers = DEFAULT_STEMMERS, { cache
2279
2300
  stemSequences,
2280
2301
  indexText: /* @__PURE__ */ __name((text) => stemSequences(text).map((sequence) => sequence.join(" ")).filter(Boolean).join(` ${STEM_SEPARATOR} `), "indexText"),
2281
2302
  phrases: /* @__PURE__ */ __name((text) => {
2282
- const phrases = stemSequences(text).filter((sequence) => sequence.length > 0).map((sequence) => `"${sequence.join(" ").replaceAll('"', '""')}"`);
2303
+ const phrases = querySequences(text).filter((sequence) => sequence.length > 0).map((sequence) => `"${sequence.join(" ").replaceAll('"', '""')}"`);
2283
2304
  return phrases.length ? phrases.join(" OR ") : void 0;
2284
2305
  }, "phrases"),
2285
- explain: /* @__PURE__ */ __name((text) => tokensOf(text).flatMap((word) => {
2306
+ explain: /* @__PURE__ */ __name((text, { query = false } = {}) => tokensOf(text).flatMap((word) => {
2286
2307
  const bare = word.replace(MARKS, "");
2287
2308
  const script = CYRILLIC.test(bare) ? "cyrillic" : LATIN.test(bare) ? "latin" : "none";
2288
2309
  const variants = script === "latin" ? latinNames.map((name, variant) => ({ name, variant })) : [{ name: script === "cyrillic" ? valid.cyrillic : "none", variant: 0 }];
2289
2310
  const seen = /* @__PURE__ */ new Set();
2290
2311
  return variants.flatMap(({ name, variant }) => {
2291
- const stem = stemOf(word, variant);
2312
+ const stem = query ? queryStemOf(word, variant) : stemOf(word, variant);
2292
2313
  if (!stem || seen.has(stem))
2293
2314
  return [];
2294
2315
  seen.add(stem);
@@ -2303,8 +2324,10 @@ export {
2303
2324
  SNOWBALL_VERSION,
2304
2325
  DEFAULT_STEMMERS,
2305
2326
  DEFAULT_STEMMERS_VERSION,
2327
+ START_LETTERS,
2306
2328
  STEM_SEPARATOR,
2307
2329
  analyzerIdentity,
2308
2330
  parseStemmers,
2331
+ cutsDeep,
2309
2332
  createStemmer
2310
2333
  };