@kahinmcp/kahin 0.1.4 → 0.1.5
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/bin/kahin.mjs
CHANGED
|
@@ -1,77 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// kahin
|
|
2
|
+
// kahin launcher — kahin MCP server'ı başlatır.
|
|
3
3
|
// Kurulum: pnpm add -g @kahinmcp/kahin
|
|
4
4
|
|
|
5
5
|
import { spawn } from "node:child_process";
|
|
6
|
-
import { mkdirSync, existsSync, copyFileSync, readdirSync } from "node:fs";
|
|
7
|
-
import { homedir, tmpdir } from "node:os";
|
|
8
|
-
import { dirname, join } from "node:path";
|
|
9
|
-
import { fileURLToPath } from "node:url";
|
|
10
6
|
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
if (!wheelName) {
|
|
15
|
-
process.stderr.write(`[kahin] Wheel bulunamadı: ${VENDOR}/kahin-*.whl\n`);
|
|
16
|
-
process.exit(1);
|
|
17
|
-
}
|
|
18
|
-
const WHEEL = join(VENDOR, wheelName);
|
|
19
|
-
const HOME = process.env.KAHIN_HOME || join(homedir(), ".local", "share", "kahin");
|
|
20
|
-
const VENV = join(HOME, "venv");
|
|
21
|
-
const PY = process.platform === "win32" ? join(VENV, "Scripts", "python.exe") : join(VENV, "bin", "python");
|
|
22
|
-
const MARKER = join(HOME, "version");
|
|
23
|
-
const LOG = join(tmpdir(), "kahin-setup.log");
|
|
24
|
-
|
|
25
|
-
function sh(cmd, args, opts = {}) {
|
|
26
|
-
return new Promise((resolve) => {
|
|
27
|
-
const c = spawn(cmd, args, { stdio: ["ignore", "ignore", "pipe"], ...opts });
|
|
28
|
-
c.stderr.on("data", (d) => process.stderr.write(`[kahin] ${d}`));
|
|
29
|
-
c.on("close", (code) => resolve(code));
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
async function setup() {
|
|
34
|
-
if (!existsSync(WHEEL)) {
|
|
35
|
-
process.stderr.write(`[kahin] Wheel bulunamadı: ${WHEEL}\n`);
|
|
36
|
-
process.exit(1);
|
|
37
|
-
}
|
|
38
|
-
mkdirSync(HOME, { recursive: true });
|
|
39
|
-
const needsInstall = !existsSync(PY) || !existsSync(MARKER) || (await import("node:fs/promises")).readFile(MARKER, "utf8").catch(() => "") !== wheelName;
|
|
40
|
-
if (!needsInstall) return;
|
|
41
|
-
|
|
42
|
-
process.stderr.write("[kahin] Python ortamı kuruluyor (ilk sefer) — ~30 sn...\n");
|
|
43
|
-
const start = Date.now();
|
|
44
|
-
const wheelCopy = join(HOME, wheelName);
|
|
45
|
-
copyFileSync(WHEEL, wheelCopy);
|
|
46
|
-
let code;
|
|
47
|
-
if (process.env.UV && existsSync(process.env.UV)) {
|
|
48
|
-
code = await sh(process.env.UV, ["venv", "--python", "3.12", VENV]);
|
|
49
|
-
if (code === 0) code = await sh(process.env.UV, ["pip", "install", "--python", PY, wheelCopy]);
|
|
50
|
-
} else if (existsSync(join(homedir(), ".local", "bin", "uv"))) {
|
|
51
|
-
code = await sh(join(homedir(), ".local", "bin", "uv"), ["venv", "--python", "3.12", VENV]);
|
|
52
|
-
if (code === 0) code = await sh(join(homedir(), ".local", "bin", "uv"), ["pip", "install", "--python", PY, wheelCopy]);
|
|
53
|
-
} else {
|
|
54
|
-
code = await sh("python3", ["-m", "venv", VENV]);
|
|
55
|
-
if (code === 0) code = await sh(PY, ["-m", "pip", "install", "-U", "pip", "-q"], { env: { ...process.env, PIP_DISABLE_PIP_VERSION_CHECK: "1" } });
|
|
56
|
-
if (code === 0) code = await sh(PY, ["-m", "pip", "install", wheelCopy]);
|
|
57
|
-
}
|
|
58
|
-
if (code !== 0) {
|
|
59
|
-
process.stderr.write(`[kahin] Kurulum başarısız. Log: ${LOG} — elle kur: python3 -m venv ${VENV} && ${PY} -m pip install ${wheelCopy}\n`);
|
|
60
|
-
process.exit(1);
|
|
61
|
-
}
|
|
62
|
-
(await import("node:fs/promises")).writeFile(MARKER, wheelName);
|
|
63
|
-
process.stderr.write(`[kahin] Hazır (${((Date.now() - start) / 1000).toFixed(0)} sn).\n`);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const argv = process.argv.slice(2);
|
|
67
|
-
const upgrade = argv.includes("--upgrade") || argv.includes("--update");
|
|
68
|
-
const args = argv.filter((a) => a !== "--upgrade" && a !== "--update");
|
|
69
|
-
if (upgrade) {
|
|
70
|
-
await import("node:fs/promises").then((fs) => fs.rm(MARKER, { force: true }));
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
await setup();
|
|
74
|
-
const child = spawn(PY, ["-m", "kahin.oracle", ...args], { stdio: "inherit" });
|
|
7
|
+
const args = process.argv.slice(2);
|
|
8
|
+
const py = process.env.KAHIN_PY || "python3";
|
|
9
|
+
const child = spawn(py, ["-m", "kahin.oracle", ...args], { stdio: "inherit" });
|
|
75
10
|
child.on("exit", (code, signal) => {
|
|
76
11
|
if (signal) process.kill(process.pid, signal);
|
|
77
12
|
process.exit(code ?? 0);
|
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kahinmcp/kahin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Kahin — CDP ansiklopedisi + anti-detect browser otomasyon MCP sunucusu. Obscura ve Camoufox motorlarını kullanır, motor seçimini ajana bırakır.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"kahin": "bin/kahin.mjs"
|
|
7
7
|
},
|
|
8
8
|
"files": [
|
|
9
9
|
"bin",
|
|
10
|
-
"lib/vendor",
|
|
11
10
|
"LICENSE"
|
|
12
11
|
],
|
|
13
12
|
"engines": {
|
|
Binary file
|