hocai-connect 0.10.2 → 0.11.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 (2) hide show
  1. package/dist/cli.js +31 -4
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -39734,7 +39734,7 @@ var TOOLS = {
39734
39734
  ],
39735
39735
  WORK: ["Read", "Write", "Edit", "Glob", "Grep"]
39736
39736
  };
39737
- var VERSION = "0.10.2";
39737
+ var VERSION = "0.11.0";
39738
39738
  function claudeArgs(job, o, port) {
39739
39739
  const mcp = {
39740
39740
  mcpServers: {
@@ -39786,6 +39786,7 @@ function buildHttpServer(o) {
39786
39786
  const checkOrigin = (req, res) => {
39787
39787
  const origin = req.headers.origin;
39788
39788
  if (!origin || !o.origins.includes(origin)) {
39789
+ if (origin) cors(res, origin);
39789
39790
  json3(res, 403, { error: "Ch\u1EC9 trang hocAI m\u1EDBi g\u1ECDi \u0111\u01B0\u1EE3c c\u1EA7u n\u1ED1i n\xE0y" });
39790
39791
  return false;
39791
39792
  }
@@ -40242,6 +40243,17 @@ async function latestVersion(pkg = "hocai-connect") {
40242
40243
  return null;
40243
40244
  }
40244
40245
  }
40246
+ function defaultOrigins(env) {
40247
+ if (env && env.trim()) return env.split(",").map((s) => s.trim()).filter(Boolean);
40248
+ return [
40249
+ "https://camerasrent.com",
40250
+ "https://www.camerasrent.com",
40251
+ // Giữ lại cho tới khi không còn helper nào trỏ vào đây nữa.
40252
+ "http://103.154.62.225:8090",
40253
+ "http://localhost:5173",
40254
+ "http://localhost:5174"
40255
+ ];
40256
+ }
40245
40257
 
40246
40258
  // apps/mcp/src/cli.ts
40247
40259
  var HOCAI_DIR = (0, import_node_path5.join)((0, import_node_os3.homedir)(), ".hocai");
@@ -40249,7 +40261,7 @@ var CREDS = (0, import_node_path5.join)(HOCAI_DIR, "config.json");
40249
40261
  var APP_DIR = (0, import_node_path5.join)(HOCAI_DIR, "app");
40250
40262
  var APP_CLI = (0, import_node_path5.join)(APP_DIR, "cli.js");
40251
40263
  var LOG_DIR = (0, import_node_path5.join)(HOCAI_DIR, "log");
40252
- var WEB = () => process.env.HOCAI_WEB_URL ?? "http://103.154.62.225:8090";
40264
+ var WEB = () => process.env.HOCAI_WEB_URL ?? "https://camerasrent.com";
40253
40265
  var API_DEFAULT = () => process.env.HOCAI_API_URL ?? `${WEB()}/api`;
40254
40266
  var PORT = Number(process.env.MCP_HTTP_PORT ?? 4100);
40255
40267
  var say = (s) => process.stderr.write(s + "\n");
@@ -40398,6 +40410,13 @@ function caiDichVu() {
40398
40410
  p.install.forEach((c, i) => {
40399
40411
  if (i === 0) {
40400
40412
  chay(c, true);
40413
+ if ((0, import_node_os3.platform)() === "darwin") {
40414
+ const nhan = `gui/${process.getuid?.() ?? 501}/${p.label}`;
40415
+ for (let lan = 0; lan < 20; lan++) {
40416
+ if (!chay(["launchctl", "print", nhan], true)) break;
40417
+ nghi(250);
40418
+ }
40419
+ }
40401
40420
  return;
40402
40421
  }
40403
40422
  for (let lan = 0; lan < 5; lan++) {
@@ -40412,7 +40431,7 @@ function goDichVu() {
40412
40431
  for (const c of p.uninstall) chay(c, true);
40413
40432
  if (p.file) (0, import_node_fs3.rmSync)(p.file, { force: true });
40414
40433
  }
40415
- var LENH = ["mcp", "run", "update", "status", "stop", "logs", "quen", "help", "--help", "-h"];
40434
+ var LENH = ["mcp", "run", "update", "status", "stop", "logs", "quen", "help", "--help", "-h", "entry"];
40416
40435
  var TRO_GIUP = `hocai-connect \u2014 n\u1ED1i Claude tr\xEAn m\xE1y b\u1EA1n v\xE0o hocAI
40417
40436
 
40418
40437
  npx hocai-connect c\xE0i v\xE0 b\u1EADt. M\xE1y t\u1EF1 n\u1ED1i l\u1EA1i m\u1ED7i l\u1EA7n b\u1EADt m\xE1y.
@@ -40429,6 +40448,10 @@ async function main() {
40429
40448
  say(TRO_GIUP);
40430
40449
  return;
40431
40450
  }
40451
+ if (cmd === "entry") {
40452
+ process.stdout.write(__filename + "\n");
40453
+ return;
40454
+ }
40432
40455
  if (cmd && !LENH.includes(cmd)) {
40433
40456
  say(`Kh\xF4ng c\xF3 l\u1EC7nh "${cmd}".`);
40434
40457
  say("");
@@ -40547,7 +40570,11 @@ async function main() {
40547
40570
  }
40548
40571
  const srv = buildHttpServer({
40549
40572
  token: creds.token,
40550
- origins: (process.env.HOCAI_WEB_ORIGINS ?? `${WEB()},http://localhost:5173,http://localhost:5174`).split(","),
40573
+ // Danh sách CỐ ĐỊNH gồm cả địa chỉ cũ, không ghép từ `WEB()`.
40574
+ //
40575
+ // Ghép từ `WEB()` thì đổi `WEB()` là mất gốc cũ, và mọi helper đã cài từ
40576
+ // chối trang mới trong im lặng. Xem `defaultOrigins`.
40577
+ origins: defaultOrigins(process.env.HOCAI_WEB_ORIGINS),
40551
40578
  claudeBin: claudeBin(),
40552
40579
  me: identity.current
40553
40580
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hocai-connect",
3
- "version": "0.10.2",
3
+ "version": "0.11.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"