hocai-connect 0.6.0 → 0.8.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 +90 -3
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -29237,6 +29237,63 @@ WantedBy=default.target
|
|
|
29237
29237
|
return { label: TASK_NAME, file: null, content: null, install: [], uninstall: [], log };
|
|
29238
29238
|
}
|
|
29239
29239
|
|
|
29240
|
+
// apps/mcp/src/agents.ts
|
|
29241
|
+
var NHAN = { claude: "Claude Code", codex: "Codex" };
|
|
29242
|
+
function summarizeAgents(probes) {
|
|
29243
|
+
const dong = [];
|
|
29244
|
+
const canhBao = [];
|
|
29245
|
+
for (const p of probes) {
|
|
29246
|
+
if (!p.installed) continue;
|
|
29247
|
+
if (!p.runnable) {
|
|
29248
|
+
dong.push(`\xB7 ${NHAN[p.name]}: c\xF3 trong m\xE1y nh\u01B0ng g\u1ECDi kh\xF4ng ch\u1EA1y`);
|
|
29249
|
+
canhBao.push(`${NHAN[p.name]} c\xE0i l\u1ED7i tr\xEAn m\xE1y n\xE0y \u2014 g\u1EE1 r\u1ED3i c\xE0i l\u1EA1i, ho\u1EB7c b\u1ECF qua n\u1EBFu b\u1EA1n kh\xF4ng d\xF9ng n\xF3.`);
|
|
29250
|
+
continue;
|
|
29251
|
+
}
|
|
29252
|
+
if (p.loggedIn === false) {
|
|
29253
|
+
dong.push(`\xB7 ${NHAN[p.name]}: \u0111\xE3 c\xE0i, CH\u01AFA \u0111\u0103ng nh\u1EADp`);
|
|
29254
|
+
canhBao.push(
|
|
29255
|
+
p.name === "claude" ? "Claude Code ch\u01B0a \u0111\u0103ng nh\u1EADp. Ch\u1EA1y `claude auth login` r\u1ED3i quay l\u1EA1i \u2014 ch\u01B0a \u0111\u0103ng nh\u1EADp th\xEC b\xE0i t\u1EADp kh\xF4ng ch\u1EA1y \u0111\u01B0\u1EE3c." : "Codex ch\u01B0a \u0111\u0103ng nh\u1EADp. Ch\u1EA1y `codex login` n\u1EBFu b\u1EA1n \u0111\u1ECBnh d\xF9ng n\xF3."
|
|
29256
|
+
);
|
|
29257
|
+
continue;
|
|
29258
|
+
}
|
|
29259
|
+
dong.push(`\u2713 ${NHAN[p.name]}: s\u1EB5n s\xE0ng${p.loggedIn === null ? " (kh\xF4ng ki\u1EC3m \u0111\u01B0\u1EE3c \u0111\u0103ng nh\u1EADp)" : ""}`);
|
|
29260
|
+
}
|
|
29261
|
+
const claude = probes.find((p) => p.name === "claude");
|
|
29262
|
+
const claudeSanSang = !!claude && claude.installed && claude.runnable && claude.loggedIn !== false;
|
|
29263
|
+
const codexSanSang = probes.some((p) => p.name === "codex" && p.installed && p.runnable && p.loggedIn !== false);
|
|
29264
|
+
if (!probes.some((p) => p.installed)) {
|
|
29265
|
+
canhBao.push(
|
|
29266
|
+
"M\xE1y n\xE0y ch\u01B0a c\xE0i tr\u1EE3 l\xFD AI n\xE0o. hocAI ch\u1EA1y b\xE0i t\u1EADp b\u1EB1ng Claude Code \u2014 c\xE0i n\xF3 r\u1ED3i ch\u1EA1y l\u1EA1i l\u1EC7nh n\xE0y."
|
|
29267
|
+
);
|
|
29268
|
+
} else if (!claudeSanSang && codexSanSang) {
|
|
29269
|
+
canhBao.push(
|
|
29270
|
+
"M\xE1y n\xE0y c\xF3 Codex nh\u01B0ng hocAI ch\u01B0a ch\u1EA1y b\xE0i t\u1EADp b\u1EB1ng Codex \u0111\u01B0\u1EE3c \u2014 ph\u1EA7n \u0111\xF3 g\u1ECDi Claude Code. C\xE0i Claude Code \u0111\u1EC3 l\xE0m b\xE0i."
|
|
29271
|
+
);
|
|
29272
|
+
}
|
|
29273
|
+
return { dong, canhBao, chayDuocBai: claudeSanSang };
|
|
29274
|
+
}
|
|
29275
|
+
function probeAgents(run) {
|
|
29276
|
+
const co = (b) => run("command", ["-v", b]) !== null;
|
|
29277
|
+
const probes = [];
|
|
29278
|
+
if (co("claude")) {
|
|
29279
|
+
const raw = run("claude", ["auth", "status"]);
|
|
29280
|
+
let loggedIn = null;
|
|
29281
|
+
if (raw !== null) {
|
|
29282
|
+
try {
|
|
29283
|
+
const j = JSON.parse(raw);
|
|
29284
|
+
loggedIn = typeof j.loggedIn === "boolean" ? j.loggedIn : null;
|
|
29285
|
+
} catch {
|
|
29286
|
+
}
|
|
29287
|
+
}
|
|
29288
|
+
probes.push({ name: "claude", installed: true, runnable: raw !== null, loggedIn });
|
|
29289
|
+
}
|
|
29290
|
+
if (co("codex")) {
|
|
29291
|
+
const ver = run("codex", ["--version"]);
|
|
29292
|
+
probes.push({ name: "codex", installed: true, runnable: ver !== null, loggedIn: null });
|
|
29293
|
+
}
|
|
29294
|
+
return probes;
|
|
29295
|
+
}
|
|
29296
|
+
|
|
29240
29297
|
// apps/mcp/src/server.ts
|
|
29241
29298
|
var import_promises = require("node:fs/promises");
|
|
29242
29299
|
var import_node_os = require("node:os");
|
|
@@ -39677,7 +39734,7 @@ var TOOLS = {
|
|
|
39677
39734
|
],
|
|
39678
39735
|
WORK: ["Read", "Write", "Edit", "Glob", "Grep"]
|
|
39679
39736
|
};
|
|
39680
|
-
var VERSION = "0.
|
|
39737
|
+
var VERSION = "0.8.0";
|
|
39681
39738
|
function claudeArgs(job, o, port) {
|
|
39682
39739
|
const mcp = {
|
|
39683
39740
|
mcpServers: {
|
|
@@ -40260,6 +40317,33 @@ function claudeBin() {
|
|
|
40260
40317
|
return "claude";
|
|
40261
40318
|
}
|
|
40262
40319
|
}
|
|
40320
|
+
function chayLay(cmd, args) {
|
|
40321
|
+
try {
|
|
40322
|
+
const dong = [cmd, ...args].join(" ");
|
|
40323
|
+
const o = {
|
|
40324
|
+
encoding: "utf8",
|
|
40325
|
+
timeout: 8e3,
|
|
40326
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
40327
|
+
};
|
|
40328
|
+
return (0, import_node_os3.platform)() === "win32" ? (0, import_node_child_process3.execSync)(dong, o) : (0, import_node_child_process3.execSync)(dong, { ...o, shell: "/bin/sh" });
|
|
40329
|
+
} catch (e) {
|
|
40330
|
+
const ra = e.stdout;
|
|
40331
|
+
const chu = typeof ra === "string" ? ra : ra?.toString("utf8");
|
|
40332
|
+
return chu && chu.trim() ? chu : null;
|
|
40333
|
+
}
|
|
40334
|
+
}
|
|
40335
|
+
function doTroLy() {
|
|
40336
|
+
const r = summarizeAgents(probeAgents(chayLay));
|
|
40337
|
+
if (r.dong.length) {
|
|
40338
|
+
say("");
|
|
40339
|
+
for (const d of r.dong) say(" " + d);
|
|
40340
|
+
}
|
|
40341
|
+
for (const c of r.canhBao) {
|
|
40342
|
+
say("");
|
|
40343
|
+
say("\u26A0 " + c);
|
|
40344
|
+
}
|
|
40345
|
+
return r.chayDuocBai;
|
|
40346
|
+
}
|
|
40263
40347
|
var plan = () => daemonPlan((0, import_node_os3.platform)(), { node: process.execPath, script: APP_CLI, home: (0, import_node_os3.homedir)() });
|
|
40264
40348
|
function chay(cmd, im = false) {
|
|
40265
40349
|
try {
|
|
@@ -40349,15 +40433,17 @@ async function main() {
|
|
|
40349
40433
|
}
|
|
40350
40434
|
const identity = createIdentityCache({
|
|
40351
40435
|
fetchIdentity: () => fetchIdentity(creds.api, creds.token),
|
|
40352
|
-
seed: me
|
|
40436
|
+
seed: me,
|
|
40437
|
+
ttlMs: 6e4
|
|
40353
40438
|
});
|
|
40354
40439
|
writeDesktop(creds);
|
|
40355
40440
|
addClaudeCode(creds);
|
|
40356
40441
|
if (cmd !== "run") {
|
|
40357
40442
|
const xong = caiDichVu();
|
|
40443
|
+
const sanSang = doTroLy();
|
|
40358
40444
|
say("");
|
|
40359
40445
|
say("\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550");
|
|
40360
|
-
say(` \u2713 \u0110\xE3 n\u1ED1i m\xE1y \xB7 ${me.ten}`);
|
|
40446
|
+
say(sanSang ? ` \u2713 \u0110\xE3 n\u1ED1i m\xE1y \xB7 ${me.ten}` : ` \u2713 \u0110\xE3 n\u1ED1i m\xE1y \xB7 ${me.ten} \u2014 nh\u01B0ng xem c\u1EA3nh b\xE1o \u1EDF tr\xEAn`);
|
|
40361
40447
|
if (xong) {
|
|
40362
40448
|
say(" M\xE1y n\xE0y s\u1EBD T\u1EF0 n\u1ED1i l\u1EA1i m\u1ED7i l\u1EA7n b\u1EA1n b\u1EADt m\xE1y.");
|
|
40363
40449
|
say(" Kh\xF4ng c\u1EA7n m\u1EDF Terminal n\u1EEFa, kh\xF4ng c\u1EA7n gi\u1EEF c\u1EEDa s\u1ED5 n\xE0o.");
|
|
@@ -40393,6 +40479,7 @@ async function main() {
|
|
|
40393
40479
|
process.exit(d.thoat);
|
|
40394
40480
|
});
|
|
40395
40481
|
});
|
|
40482
|
+
setInterval(() => void identity.refresh(), 6e4).unref();
|
|
40396
40483
|
srv.listen(PORT, "127.0.0.1", () => {
|
|
40397
40484
|
say("");
|
|
40398
40485
|
say("\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550");
|