@wirecat/tg-cli 0.99.0 → 0.101.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 (117) hide show
  1. package/README.md +6 -5
  2. package/dist/bin/tg.js +23 -28
  3. package/dist/bundle/adapter-A3VD4Y6Z.js +2790 -0
  4. package/dist/bundle/all-profiles-UPVNHXB2.js +264 -0
  5. package/dist/bundle/anthropic-IRKNWPIB.js +71 -0
  6. package/dist/bundle/bot-api-UNTQG2M5.js +39793 -0
  7. package/dist/bundle/bot-history-V4RTY5K7.js +167 -0
  8. package/dist/bundle/bun-2JZPG2NL.js +169 -0
  9. package/dist/bundle/bun-sqlite-TZHKM225.js +70 -0
  10. package/dist/bundle/chunk-22PQUX72.js +190 -0
  11. package/dist/bundle/chunk-2DGOFLDA.js +58 -0
  12. package/dist/bundle/chunk-2SJOUK6J.js +2 -0
  13. package/dist/bundle/chunk-2XBSVRT2.js +98 -0
  14. package/dist/bundle/chunk-3KHKYYCR.js +24782 -0
  15. package/dist/bundle/chunk-4ZS73HTJ.js +6848 -0
  16. package/dist/bundle/chunk-54R2GDQ3.js +119 -0
  17. package/dist/bundle/chunk-5GKXETRP.js +1345 -0
  18. package/dist/bundle/chunk-5KU4UQBM.js +570 -0
  19. package/dist/bundle/chunk-5TPT2S2Z.js +41 -0
  20. package/dist/bundle/chunk-64DK7S4F.js +76 -0
  21. package/dist/bundle/chunk-6IPY2QRG.js +82 -0
  22. package/dist/bundle/chunk-7BFO3DY6.js +21 -0
  23. package/dist/bundle/chunk-7CBUCTB6.js +1142 -0
  24. package/dist/bundle/chunk-A5JSTZZZ.js +122 -0
  25. package/dist/bundle/chunk-ACGTFLEB.js +1275 -0
  26. package/dist/bundle/chunk-AFV74GK3.js +50 -0
  27. package/dist/bundle/chunk-AVWK4NCW.js +24600 -0
  28. package/dist/bundle/chunk-BJG6JA5U.js +35 -0
  29. package/dist/bundle/chunk-BX6HH4F6.js +215 -0
  30. package/dist/bundle/chunk-BXQS5RCE.js +8170 -0
  31. package/dist/bundle/chunk-CJ6IYCYP.js +583 -0
  32. package/dist/bundle/chunk-DG62L57H.js +2795 -0
  33. package/dist/bundle/chunk-DYNSP6FW.js +33720 -0
  34. package/dist/bundle/chunk-F7TDFWXY.js +82 -0
  35. package/dist/bundle/chunk-G2US6LJB.js +35 -0
  36. package/dist/bundle/chunk-G3ZRY436.js +3077 -0
  37. package/dist/bundle/chunk-G77QOTXE.js +18 -0
  38. package/dist/bundle/chunk-H6OXALTJ.js +45 -0
  39. package/dist/bundle/chunk-LPB2MDUW.js +452 -0
  40. package/dist/bundle/chunk-MLLJ74LM.js +24 -0
  41. package/dist/bundle/chunk-N5UFBWDM.js +166 -0
  42. package/dist/bundle/chunk-NC5WS7OP.js +31 -0
  43. package/dist/bundle/chunk-NKJJJAIJ.js +237 -0
  44. package/dist/bundle/chunk-NMGO6LW6.js +1950 -0
  45. package/dist/bundle/chunk-ODSVNH3H.js +18588 -0
  46. package/dist/bundle/chunk-OEJ5DMCX.js +2374 -0
  47. package/dist/bundle/chunk-OILBDLWL.js +724 -0
  48. package/dist/bundle/chunk-OPBTNQ35.js +1007 -0
  49. package/dist/bundle/chunk-PUBS2F5J.js +35803 -0
  50. package/dist/bundle/chunk-PYTOIDSM.js +153 -0
  51. package/dist/bundle/chunk-QOWSVDPZ.js +3526 -0
  52. package/dist/bundle/chunk-QYVVRQTN.js +73 -0
  53. package/dist/bundle/chunk-RF54YDBB.js +46 -0
  54. package/dist/bundle/chunk-RVCS7Q3A.js +6672 -0
  55. package/dist/bundle/chunk-S2JSZWEC.js +277 -0
  56. package/dist/bundle/chunk-S7ZNLLY5.js +54 -0
  57. package/dist/bundle/chunk-TGREFJVA.js +2315 -0
  58. package/dist/bundle/chunk-U46UNBMT.js +524 -0
  59. package/dist/bundle/chunk-UN6CKIBN.js +285 -0
  60. package/dist/bundle/chunk-VA5YEJS3.js +161 -0
  61. package/dist/bundle/chunk-VCGL2ETF.js +78 -0
  62. package/dist/bundle/chunk-VRSN7VLO.js +63 -0
  63. package/dist/bundle/chunk-VYDTI254.js +3332 -0
  64. package/dist/bundle/chunk-W2336E7Y.js +886 -0
  65. package/dist/bundle/chunk-X4Y2ROJI.js +541 -0
  66. package/dist/bundle/chunk-XCKD54TN.js +100 -0
  67. package/dist/bundle/chunk-ZEOCU24Z.js +738 -0
  68. package/dist/bundle/chunk-ZJVZXJOG.js +71 -0
  69. package/dist/bundle/chunk-ZV24I2UJ.js +25 -0
  70. package/dist/bundle/chunk-ZZLKX62Z.js +928 -0
  71. package/dist/bundle/command-contract-TKDI7E56.js +31 -0
  72. package/dist/bundle/dist-RJMT44PL.js +7577 -0
  73. package/dist/bundle/echarts-QZ6PR3VC.js +42501 -0
  74. package/dist/bundle/embed-UBXCXSRD.js +35 -0
  75. package/dist/bundle/embedder-B4ZTKC23.js +108 -0
  76. package/dist/bundle/entry-BTUTHO5M.js +14 -0
  77. package/dist/bundle/first-run-UC4HRIFV.js +24 -0
  78. package/dist/bundle/first-screen-SMCX6YKY.js +29 -0
  79. package/dist/bundle/identity-QSDEGDH7.js +11 -0
  80. package/dist/bundle/instructions-BBGLZKO3.js +9 -0
  81. package/dist/bundle/mcp-4Y37G2UY.js +165 -0
  82. package/dist/bundle/node-IUL5HSYI.js +2340 -0
  83. package/dist/bundle/node-LZZX22VR.js +176 -0
  84. package/dist/bundle/node-UPPL626U.js +21 -0
  85. package/dist/bundle/node-sqlite-BPGT6T5U.js +46 -0
  86. package/dist/bundle/oauth-XNE2KPKJ.js +18 -0
  87. package/dist/bundle/open-SXGYZLB5.js +20 -0
  88. package/dist/bundle/process-GPUXC4PG.js +91 -0
  89. package/dist/bundle/program-NEXEAL7T.js +1060 -0
  90. package/dist/bundle/prompt-SORGLEYI.js +13 -0
  91. package/dist/bundle/proxy-transport-G4MA6BGU.js +17 -0
  92. package/dist/bundle/recognize-UJBXORVD.js +191 -0
  93. package/dist/bundle/remote-W72AR7KH.js +26 -0
  94. package/dist/bundle/rerank-3Y2VZM3J.js +49 -0
  95. package/dist/bundle/serve-VDZIVOPR.js +196 -0
  96. package/dist/bundle/server-BERXP4GW.js +785 -0
  97. package/dist/bundle/server-ZFHN4GUF.js +178 -0
  98. package/dist/bundle/state-DGR4EE3E.js +34 -0
  99. package/dist/bundle/store-MRCFSCZD.js +121 -0
  100. package/dist/bundle/store-maintenance-command-DCMZDMYS.js +46 -0
  101. package/dist/bundle/tg.js +40 -0
  102. package/dist/commands/context.d.ts.map +1 -1
  103. package/dist/commands/context.js +3 -1
  104. package/dist/commands/context.js.map +1 -1
  105. package/dist/install/postinstall.js +1 -1
  106. package/dist/install/postinstall.js.map +1 -1
  107. package/dist/program.js +1 -1
  108. package/dist/program.js.map +1 -1
  109. package/dist/telegram/errors.js +1 -1
  110. package/dist/telegram/errors.js.map +1 -1
  111. package/dist/version.d.ts +1 -1
  112. package/dist/version.d.ts.map +1 -1
  113. package/dist/version.js +1 -1
  114. package/dist/version.js.map +1 -1
  115. package/install/windows.ps1 +1 -1
  116. package/package.json +6 -4
  117. package/skills/{wirecat-tg → tg-cli}/SKILL.md +4 -4
@@ -0,0 +1,122 @@
1
+ import { createRequire as __tgRequire } from "node:module";
2
+ const require = __tgRequire(import.meta.url);
3
+ import {
4
+ unit
5
+ } from "./chunk-ACGTFLEB.js";
6
+ import {
7
+ CliError
8
+ } from "./chunk-OEJ5DMCX.js";
9
+ import {
10
+ __name
11
+ } from "./chunk-AFV74GK3.js";
12
+
13
+ // node_modules/.pnpm/@wirecat+cli-core@0.466.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._f7e4048410ccbe1e801fd184c043d197/node_modules/@wirecat/cli-core/dist/embeddings/remote.js
14
+ import { setTimeout } from "node:timers/promises";
15
+ var OPENAI_URL = "https://api.openai.com/v1";
16
+ var OPENAI_MODELS = {
17
+ "text-embedding-3-small": { dims: 1536, perMillion: 0.02 },
18
+ "text-embedding-3-large": { dims: 3072, perMillion: 0.13 }
19
+ };
20
+ var DEFAULT_OPENAI_MODEL = "text-embedding-3-small";
21
+ var PER_REQUEST = 256;
22
+ var LOCAL = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "[::1]", "::1"]);
23
+ var isLocal = /* @__PURE__ */ __name((baseUrl) => LOCAL.has(new URL(baseUrl).hostname), "isLocal");
24
+ var remoteModel = /* @__PURE__ */ __name(({ model = DEFAULT_OPENAI_MODEL, baseUrl, dims }) => {
25
+ const known = baseUrl === void 0 ? OPENAI_MODELS[model] : void 0;
26
+ if (baseUrl === void 0 && !known) {
27
+ throw new CliError("validation_error", `OpenAI has no embedding model ${model} here \u2014 one of: ${Object.keys(OPENAI_MODELS).join(", ")}; another server takes --base-url`);
28
+ }
29
+ const size = dims ?? known?.dims;
30
+ if (size === void 0)
31
+ throw new CliError("validation_error", "with --base-url, say the vector size with --dims");
32
+ return {
33
+ provider: baseUrl === void 0 ? "openai" : `url:${new URL(baseUrl).host}`,
34
+ model,
35
+ dims: size,
36
+ baseUrl: baseUrl ?? OPENAI_URL,
37
+ shorten: known !== void 0 && size !== known.dims,
38
+ ...known ? { price: { perMillion: known.perMillion, read: "2026-10-02" } } : {}
39
+ };
40
+ }, "remoteModel");
41
+ var remoteKey = /* @__PURE__ */ __name(({ provider, model, dims }) => `${provider}:${model}:${dims}`, "remoteKey");
42
+ var openRemote = /* @__PURE__ */ __name((remote, apiKey, { concurrency = 4, fetch: post = fetch, tries = 5 } = {}) => {
43
+ const request = /* @__PURE__ */ __name(async (input) => {
44
+ for (let attempt = 1; ; attempt++) {
45
+ let response;
46
+ try {
47
+ response = await post(`${remote.baseUrl.replace(/\/$/, "")}/embeddings`, {
48
+ method: "POST",
49
+ headers: {
50
+ "content-type": "application/json",
51
+ ...apiKey ? { authorization: `Bearer ${apiKey}` } : {}
52
+ },
53
+ body: JSON.stringify({
54
+ model: remote.model,
55
+ input,
56
+ encoding_format: "float",
57
+ ...remote.shorten ? { dimensions: remote.dims } : {}
58
+ })
59
+ });
60
+ } catch {
61
+ if (attempt >= tries)
62
+ throw new CliError("network_error", `${remote.provider} could not be reached`);
63
+ await setTimeout(1e3 * attempt);
64
+ continue;
65
+ }
66
+ if (response.ok) {
67
+ const body = await response.json();
68
+ const data = [...body.data ?? []].sort((a, b) => a.index - b.index);
69
+ if (data.length !== input.length || data.some(({ embedding }) => embedding.length !== remote.dims)) {
70
+ throw new CliError("invalid_response", `${remote.provider} answered with vectors of another number or size than ${input.length} \xD7 ${remote.dims}`);
71
+ }
72
+ return data.map(({ embedding }) => unit(Float32Array.from(embedding)));
73
+ }
74
+ const code = await errorCode(response);
75
+ if (response.status === 401 || response.status === 403) {
76
+ throw new CliError("authentication_error", `${remote.provider} refused the key (HTTP ${response.status}${code}) \u2014 set it again with \`models keys set\``);
77
+ }
78
+ const again = response.status === 429 || response.status >= 500;
79
+ if (!again || attempt >= tries) {
80
+ throw new CliError(response.status === 429 ? "rate_limited" : "provider_error", `${remote.provider} answered HTTP ${response.status}${code}`);
81
+ }
82
+ const wait = Number(response.headers.get("retry-after"));
83
+ await setTimeout(Number.isFinite(wait) && wait > 0 ? wait * 1e3 : 1e3 * 2 ** attempt);
84
+ }
85
+ }, "request");
86
+ return {
87
+ model: { id: remote.model, dims: remote.dims },
88
+ embed: /* @__PURE__ */ __name(async (texts) => {
89
+ const parts = [];
90
+ for (let start = 0; start < texts.length; start += PER_REQUEST)
91
+ parts.push(texts.slice(start, start + PER_REQUEST));
92
+ const results = new Array(parts.length);
93
+ let next = 0;
94
+ await Promise.all(Array.from({ length: Math.min(concurrency, parts.length) }, async () => {
95
+ for (let index = next++; index < parts.length; index = next++)
96
+ results[index] = await request(parts[index]);
97
+ }));
98
+ return results.flat();
99
+ }, "embed"),
100
+ close: /* @__PURE__ */ __name(async () => {
101
+ }, "close")
102
+ };
103
+ }, "openRemote");
104
+ var errorCode = /* @__PURE__ */ __name(async (response) => {
105
+ try {
106
+ const body = await response.json();
107
+ const code = body.error?.code ?? body.error?.type;
108
+ return typeof code === "string" && /^[\w.-]{1,64}$/.test(code) ? `, ${code}` : "";
109
+ } catch {
110
+ return "";
111
+ }
112
+ }, "errorCode");
113
+
114
+ export {
115
+ OPENAI_URL,
116
+ OPENAI_MODELS,
117
+ DEFAULT_OPENAI_MODEL,
118
+ isLocal,
119
+ remoteModel,
120
+ remoteKey,
121
+ openRemote
122
+ };