hocai-connect 0.4.0 → 0.5.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/dist/cli.js +51 -6
- package/package.json +4 -1
package/dist/cli.js
CHANGED
|
@@ -39587,7 +39587,7 @@ var TOOLS = {
|
|
|
39587
39587
|
],
|
|
39588
39588
|
WORK: ["Read", "Write", "Edit", "Glob", "Grep"]
|
|
39589
39589
|
};
|
|
39590
|
-
var VERSION = "0.
|
|
39590
|
+
var VERSION = "0.5.0";
|
|
39591
39591
|
function claudeArgs(job, o, port) {
|
|
39592
39592
|
const mcp = {
|
|
39593
39593
|
mcpServers: {
|
|
@@ -40027,6 +40027,49 @@ function absoluteApiUrl(raw, webUrl, fallback) {
|
|
|
40027
40027
|
return fallback;
|
|
40028
40028
|
}
|
|
40029
40029
|
}
|
|
40030
|
+
function diagnosePortBusy(info, meId) {
|
|
40031
|
+
if (!info || info.ten !== "hocai-connect") {
|
|
40032
|
+
return {
|
|
40033
|
+
loai: "OTHER_PROGRAM",
|
|
40034
|
+
noi: "C\u1ED5ng 4100 \u0111ang b\u1ECB m\u1ED9t ch\u01B0\u01A1ng tr\xECnh kh\xE1c chi\u1EBFm (kh\xF4ng ph\u1EA3i hocai-connect).\n\u0110\xF3ng ch\u01B0\u01A1ng tr\xECnh \u0111\xF3, ho\u1EB7c ch\u1EA1y c\u1ED5ng kh\xE1c: MCP_HTTP_PORT=4101 npx hocai-connect\n\u2014 nh\u01B0ng nh\u1EDB trang hocAI ch\u1EC9 g\u1ECDi c\u1ED5ng 4100, n\xEAn \u0111\u1ED5i c\u1ED5ng th\xEC trang s\u1EBD kh\xF4ng th\u1EA5y m\xE1y b\u1EA1n.",
|
|
40035
|
+
thoat: 1
|
|
40036
|
+
};
|
|
40037
|
+
}
|
|
40038
|
+
if (info.user === void 0) {
|
|
40039
|
+
return {
|
|
40040
|
+
loai: "UNKNOWN_VERSION",
|
|
40041
|
+
noi: `C\u1ED5ng 4100 \u0111ang c\xF3 m\u1ED9t hocai-connect b\u1EA3n c\u0169 (${info.phienBan ?? "kh\xF4ng r\xF5"}) ch\u1EA1y \u2014 b\u1EA3n \u0111\xF3 ch\u01B0a cho bi\u1EBFt n\xF3 n\u1ED1i b\u1EB1ng t\xE0i kho\u1EA3n n\xE0o.
|
|
40042
|
+
\u0110\xF3ng c\u1EEDa s\u1ED5 Terminal \u0111\xF3 (Ctrl+C) r\u1ED3i ch\u1EA1y l\u1EA1i l\u1EC7nh n\xE0y.`,
|
|
40043
|
+
thoat: 1
|
|
40044
|
+
};
|
|
40045
|
+
}
|
|
40046
|
+
if (info.user && info.user.id === meId) {
|
|
40047
|
+
return {
|
|
40048
|
+
loai: "SAME_USER",
|
|
40049
|
+
noi: `M\xE1y n\xE0y \u0111ang ch\u1EA1y r\u1ED3i \u2014 hocai-connect c\u1EE7a ${info.user.ten} \u0111\xE3 m\u1EDF \u1EDF m\u1ED9t c\u1EEDa s\u1ED5 Terminal kh\xE1c.
|
|
40050
|
+
Kh\xF4ng c\u1EA7n l\xE0m g\xEC th\xEAm. C\u1EE9 quay l\u1EA1i trang hocAI v\xE0 l\xE0m b\xE0i.`,
|
|
40051
|
+
thoat: 0
|
|
40052
|
+
};
|
|
40053
|
+
}
|
|
40054
|
+
return {
|
|
40055
|
+
loai: "OTHER_USER",
|
|
40056
|
+
noi: info.user ? `C\u1ED5ng 4100 \u0111ang c\xF3 hocai-connect ch\u1EA1y d\u01B0\u1EDBi t\xE0i kho\u1EA3n ${info.user.ten}, kh\xF4ng ph\u1EA3i t\xE0i kho\u1EA3n b\u1EA1n.
|
|
40057
|
+
\u0110\xF3ng c\u1EEDa s\u1ED5 Terminal \u0111\xF3 (Ctrl+C) r\u1ED3i ch\u1EA1y l\u1EA1i l\u1EC7nh n\xE0y.` : "C\u1ED5ng 4100 \u0111ang c\xF3 m\u1ED9t hocai-connect ch\u1EA1y b\u1EB1ng ch\xECa kho\xE1 \u0111\xE3 b\u1ECB thu h\u1ED3i.\n\u0110\xF3ng c\u1EEDa s\u1ED5 Terminal \u0111\xF3 (Ctrl+C) r\u1ED3i ch\u1EA1y l\u1EA1i l\u1EC7nh n\xE0y.",
|
|
40058
|
+
thoat: 1
|
|
40059
|
+
};
|
|
40060
|
+
}
|
|
40061
|
+
async function askPortOwner(port, origin) {
|
|
40062
|
+
try {
|
|
40063
|
+
const res = await fetch(`http://127.0.0.1:${port}/`, {
|
|
40064
|
+
headers: { origin },
|
|
40065
|
+
signal: AbortSignal.timeout(1500)
|
|
40066
|
+
});
|
|
40067
|
+
if (!res.ok) return null;
|
|
40068
|
+
return await res.json();
|
|
40069
|
+
} catch {
|
|
40070
|
+
return null;
|
|
40071
|
+
}
|
|
40072
|
+
}
|
|
40030
40073
|
|
|
40031
40074
|
// apps/mcp/src/cli.ts
|
|
40032
40075
|
var HOCAI_DIR = (0, import_node_path5.join)((0, import_node_os3.homedir)(), ".hocai");
|
|
@@ -40162,11 +40205,13 @@ async function main() {
|
|
|
40162
40205
|
me: identity.current
|
|
40163
40206
|
});
|
|
40164
40207
|
srv.on("error", (e) => {
|
|
40165
|
-
if (e.code
|
|
40166
|
-
|
|
40167
|
-
|
|
40168
|
-
|
|
40169
|
-
|
|
40208
|
+
if (e.code !== "EADDRINUSE") throw e;
|
|
40209
|
+
void askPortOwner(PORT, WEB()).then((info) => {
|
|
40210
|
+
const d = diagnosePortBusy(info, me.id);
|
|
40211
|
+
say("");
|
|
40212
|
+
say(d.noi);
|
|
40213
|
+
process.exit(d.thoat);
|
|
40214
|
+
});
|
|
40170
40215
|
});
|
|
40171
40216
|
srv.listen(PORT, "127.0.0.1", () => {
|
|
40172
40217
|
say("");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hocai-connect",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Nối Claude trên máy học viên vào hocAI, và chạy việc AI ngay tại đó",
|
|
5
5
|
"bin": {
|
|
6
6
|
"hocai-connect": "bin.js"
|
|
@@ -9,6 +9,9 @@
|
|
|
9
9
|
"bin.js",
|
|
10
10
|
"dist/"
|
|
11
11
|
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"prepublishOnly": "cd ../.. && npm run build:connect"
|
|
14
|
+
},
|
|
12
15
|
"engines": {
|
|
13
16
|
"node": ">=20"
|
|
14
17
|
},
|