@wirecat/tg-cli 0.98.0 → 0.100.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.
- package/README.md +2 -1
- package/dist/bin/tg.js +23 -28
- package/dist/bundle/adapter-2LVPMFKF.js +2790 -0
- package/dist/bundle/all-profiles-BLTK2AAB.js +255 -0
- package/dist/bundle/anthropic-RJE4XEOO.js +71 -0
- package/dist/bundle/bot-api-4XM3NVWG.js +39793 -0
- package/dist/bundle/bot-history-WVM5GEQN.js +167 -0
- package/dist/bundle/bun-UZXO2LRQ.js +169 -0
- package/dist/bundle/bun-sqlite-GJLGSQIT.js +70 -0
- package/dist/bundle/chunk-2IM4M7Q2.js +98 -0
- package/dist/bundle/chunk-2MXQ2EUN.js +1344 -0
- package/dist/bundle/chunk-2XUGPE5W.js +73 -0
- package/dist/bundle/chunk-3KHKYYCR.js +24782 -0
- package/dist/bundle/chunk-3MVHRZWR.js +2 -0
- package/dist/bundle/chunk-3N6LXAPE.js +724 -0
- package/dist/bundle/chunk-3QDPV34J.js +6668 -0
- package/dist/bundle/chunk-3S5CL55R.js +100 -0
- package/dist/bundle/chunk-4U7QOFDA.js +33511 -0
- package/dist/bundle/chunk-4VBDVZNE.js +524 -0
- package/dist/bundle/chunk-4YCLWWZ3.js +277 -0
- package/dist/bundle/chunk-66E5QDLH.js +24 -0
- package/dist/bundle/chunk-6VEOR6GD.js +166 -0
- package/dist/bundle/chunk-6YLT4YVJ.js +45 -0
- package/dist/bundle/chunk-7BFO3DY6.js +21 -0
- package/dist/bundle/chunk-A7OBVRJV.js +738 -0
- package/dist/bundle/chunk-AFV74GK3.js +50 -0
- package/dist/bundle/chunk-ASDZHG5I.js +25 -0
- package/dist/bundle/chunk-ATZ44Z77.js +3253 -0
- package/dist/bundle/chunk-AVWK4NCW.js +24600 -0
- package/dist/bundle/chunk-BAIZAZ6Q.js +82 -0
- package/dist/bundle/chunk-BJG6JA5U.js +35 -0
- package/dist/bundle/chunk-BL36RR34.js +285 -0
- package/dist/bundle/chunk-BZANDKWT.js +71 -0
- package/dist/bundle/chunk-CV5ASHTW.js +8170 -0
- package/dist/bundle/chunk-DN4QUTWU.js +78 -0
- package/dist/bundle/chunk-DVOUKGFK.js +1950 -0
- package/dist/bundle/chunk-GTURDJJD.js +570 -0
- package/dist/bundle/chunk-GYEOQS2D.js +2795 -0
- package/dist/bundle/chunk-H3X5LS6U.js +153 -0
- package/dist/bundle/chunk-HKT5EOT5.js +6848 -0
- package/dist/bundle/chunk-HXTTDIL7.js +82 -0
- package/dist/bundle/chunk-I6WZJVRT.js +1123 -0
- package/dist/bundle/chunk-JFJVS5JC.js +41 -0
- package/dist/bundle/chunk-JSKT5UZX.js +2315 -0
- package/dist/bundle/chunk-KE6L2UEG.js +3068 -0
- package/dist/bundle/chunk-LI7TXFLS.js +122 -0
- package/dist/bundle/chunk-MQNFEVAH.js +58 -0
- package/dist/bundle/chunk-MUEXF4ME.js +582 -0
- package/dist/bundle/chunk-OOOV3JBZ.js +35527 -0
- package/dist/bundle/chunk-OW3COBN5.js +1275 -0
- package/dist/bundle/chunk-P26LWFNZ.js +35 -0
- package/dist/bundle/chunk-Q26JMPBP.js +215 -0
- package/dist/bundle/chunk-QU2FJMFB.js +18282 -0
- package/dist/bundle/chunk-QY3YOOTP.js +18 -0
- package/dist/bundle/chunk-RDQMV6EU.js +46 -0
- package/dist/bundle/chunk-RER6DAHP.js +3514 -0
- package/dist/bundle/chunk-SGJYU3SB.js +54 -0
- package/dist/bundle/chunk-SMJTL5U7.js +117 -0
- package/dist/bundle/chunk-SYPL4PHV.js +76 -0
- package/dist/bundle/chunk-THVNP6S6.js +31 -0
- package/dist/bundle/chunk-U7LXA4SO.js +1007 -0
- package/dist/bundle/chunk-UD4DOZCN.js +886 -0
- package/dist/bundle/chunk-UMLPXNJI.js +63 -0
- package/dist/bundle/chunk-V4JSVH4M.js +190 -0
- package/dist/bundle/chunk-WE3LBRMB.js +2374 -0
- package/dist/bundle/chunk-WKOY3POD.js +452 -0
- package/dist/bundle/chunk-X4Y2ROJI.js +541 -0
- package/dist/bundle/chunk-YG7PNCSW.js +230 -0
- package/dist/bundle/chunk-Z2FHEIXN.js +63 -0
- package/dist/bundle/chunk-ZZLKX62Z.js +928 -0
- package/dist/bundle/command-contract-AIVKJYIR.js +31 -0
- package/dist/bundle/dist-RJMT44PL.js +7577 -0
- package/dist/bundle/echarts-YHSYUWLY.js +42501 -0
- package/dist/bundle/embed-3HGI2XIW.js +35 -0
- package/dist/bundle/embedder-2CJMZETJ.js +108 -0
- package/dist/bundle/entry-UVE53OV3.js +14 -0
- package/dist/bundle/first-run-6GYC2QS3.js +24 -0
- package/dist/bundle/first-screen-HRRLVLOG.js +29 -0
- package/dist/bundle/identity-HEV5E57G.js +11 -0
- package/dist/bundle/instructions-5UVAXSQV.js +9 -0
- package/dist/bundle/mcp-NWXBVNUA.js +165 -0
- package/dist/bundle/node-IUL5HSYI.js +2340 -0
- package/dist/bundle/node-UPPL626U.js +21 -0
- package/dist/bundle/node-YHYEGYVE.js +176 -0
- package/dist/bundle/node-sqlite-CQ33A3R2.js +46 -0
- package/dist/bundle/oauth-OB3JFAD7.js +18 -0
- package/dist/bundle/open-JHGZIXU2.js +20 -0
- package/dist/bundle/process-PSKS3N5B.js +91 -0
- package/dist/bundle/program-RPYVPNRX.js +1060 -0
- package/dist/bundle/prompt-7BXUMJGG.js +13 -0
- package/dist/bundle/proxy-transport-3EEMW2HW.js +17 -0
- package/dist/bundle/recognize-YMZPL47R.js +191 -0
- package/dist/bundle/remote-LQ3Q22NG.js +26 -0
- package/dist/bundle/rerank-SM7IYVXJ.js +49 -0
- package/dist/bundle/serve-GHUEP5H5.js +181 -0
- package/dist/bundle/server-A45HVXQY.js +178 -0
- package/dist/bundle/server-K2BQPPHN.js +785 -0
- package/dist/bundle/state-WIOL52GZ.js +30 -0
- package/dist/bundle/store-XE5AKUJZ.js +121 -0
- package/dist/bundle/store-maintenance-command-YS5E7VUN.js +46 -0
- package/dist/bundle/tg.js +40 -0
- package/dist/commands/context.d.ts.map +1 -1
- package/dist/commands/context.js +3 -2
- package/dist/commands/context.js.map +1 -1
- package/dist/telegram/errors.d.ts.map +1 -1
- package/dist/telegram/errors.js +1 -1
- package/dist/telegram/errors.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +5 -3
- package/skills/tg-cli/SKILL.md +2 -1
|
@@ -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-OW3COBN5.js";
|
|
6
|
+
import {
|
|
7
|
+
CliError
|
|
8
|
+
} from "./chunk-WE3LBRMB.js";
|
|
9
|
+
import {
|
|
10
|
+
__name
|
|
11
|
+
} from "./chunk-AFV74GK3.js";
|
|
12
|
+
|
|
13
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.452.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.63.0_commander@15._e609b9d6c8060966368a91e843fe8bd2/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
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { createRequire as __tgRequire } from "node:module";
|
|
2
|
+
const require = __tgRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
CliError
|
|
5
|
+
} from "./chunk-WE3LBRMB.js";
|
|
6
|
+
import {
|
|
7
|
+
importFrom
|
|
8
|
+
} from "./chunk-BJG6JA5U.js";
|
|
9
|
+
import {
|
|
10
|
+
__name
|
|
11
|
+
} from "./chunk-AFV74GK3.js";
|
|
12
|
+
|
|
13
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.452.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.63.0_commander@15._e609b9d6c8060966368a91e843fe8bd2/node_modules/@wirecat/cli-core/dist/store/vector-extension.js
|
|
14
|
+
import { readFileSync } from "node:fs";
|
|
15
|
+
var musl = /* @__PURE__ */ __name(() => {
|
|
16
|
+
if (process.platform !== "linux")
|
|
17
|
+
return false;
|
|
18
|
+
try {
|
|
19
|
+
return readFileSync("/proc/self/maps", "utf8").includes("ld-musl");
|
|
20
|
+
} catch {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
}, "musl");
|
|
24
|
+
var found;
|
|
25
|
+
var vectorExtension = /* @__PURE__ */ __name(() => {
|
|
26
|
+
found ??= locate();
|
|
27
|
+
return found;
|
|
28
|
+
}, "vectorExtension");
|
|
29
|
+
var locate = /* @__PURE__ */ __name(async () => {
|
|
30
|
+
const onMusl = musl();
|
|
31
|
+
const target = `${process.platform}-${process.arch}${onMusl ? "-musl" : ""}`;
|
|
32
|
+
let path;
|
|
33
|
+
try {
|
|
34
|
+
const { extensionFor } = await importFrom(new URL("store/vector-extension.js", import.meta.resolve("@wirecat/cli-core")).href, "@wirecat/cli-core-sqlite");
|
|
35
|
+
path = extensionFor({ musl: onMusl });
|
|
36
|
+
} catch {
|
|
37
|
+
path = void 0;
|
|
38
|
+
}
|
|
39
|
+
if (path === void 0) {
|
|
40
|
+
found = void 0;
|
|
41
|
+
throw new CliError("configuration_error", `the message store needs the sqlite-vec extension, and @wirecat/cli-core-sqlite has none for ${target} \u2014 reinstall the CLI so its dependencies install with it (an install that skips optional or native packages leaves it out)`, { reason: "store.vector-extension-missing", target });
|
|
42
|
+
}
|
|
43
|
+
return path;
|
|
44
|
+
}, "locate");
|
|
45
|
+
var loadVectorExtension = /* @__PURE__ */ __name((database, path) => {
|
|
46
|
+
try {
|
|
47
|
+
database.loadExtension(path);
|
|
48
|
+
} catch (error) {
|
|
49
|
+
throw new CliError("configuration_error", `the sqlite-vec extension did not load on ${process.platform}-${process.arch} \u2014 reinstall the CLI; on macOS under Bun, @wirecat/cli-core-sqlite's SQLite must be installed, since the system's cannot load extensions`, { reason: "store.vector-extension-failed", cause: error instanceof Error ? error.message : String(error) });
|
|
50
|
+
} finally {
|
|
51
|
+
database.enableLoadExtension?.(false);
|
|
52
|
+
}
|
|
53
|
+
}, "loadVectorExtension");
|
|
54
|
+
|
|
55
|
+
export {
|
|
56
|
+
vectorExtension,
|
|
57
|
+
loadVectorExtension
|
|
58
|
+
};
|