集成 OpenHub 与 WeKnora Page AI

This commit is contained in:
Agent Board
2026-06-26 20:01:02 +08:00
parent dabaf03bd7
commit e433c07061
63 changed files with 12678 additions and 332 deletions
+42
View File
@@ -3,11 +3,14 @@ const { spawn } = require("node:child_process");
const net = require("node:net");
const { test } = require("node:test");
const {
buildDefaultOpenHubCommand,
resolveBackendExecutable,
ensurePortFree,
isPortFree,
resolveOpenHubHealthPlan,
resolveRuntimePlan,
shouldStartBackend,
shouldStartOpenHub,
} = require("./desktop-hot.js");
function findFreePort() {
@@ -127,6 +130,8 @@ test("默认热启动计划只使用 mnote-web 作为 3000 owner", () => {
MNOTE_WEB_BIND: "0.0.0.0:3000",
MNOTE_WEB_PUBLIC_BIND: "127.0.0.1:3000",
MNOTE_OPENCODE_BASE_URL: "http://127.0.0.1:4096",
MNOTE_OPENHUB_BASE_URL: "http://127.0.0.1:18080",
MNOTE_OPENHUB_DISABLE_GIT_SNAPSHOT_RESTORE: "1",
});
});
@@ -137,3 +142,40 @@ test("默认跳过 FastAPI 后端,只有显式开启时才启动", () => {
assert.equal(shouldStartBackend({ BACKEND_CMD: "custom-backend" }), true);
assert.equal(shouldStartBackend({ ENABLE_BACKEND: "1", SKIP_BACKEND: "1" }), false);
});
test("OpenHub FastAPI 默认跳过,显式开启或命令覆盖时才启动", () => {
assert.equal(shouldStartOpenHub({}), false);
assert.equal(shouldStartOpenHub({ ENABLE_OPENHUB: "1" }), true);
assert.equal(shouldStartOpenHub({ ENABLE_OPENHUB: "true" }), true);
assert.equal(shouldStartOpenHub({ OPENHUB_CMD: "custom-openhub" }), true);
assert.equal(shouldStartOpenHub({ ENABLE_OPENHUB: "1", SKIP_OPENHUB: "1" }), false);
});
test("OpenHub health plan 包含 FastAPI、Redis、opencode 和默认关闭 Git snapshot/restore", () => {
const plan = resolveOpenHubHealthPlan({
ENABLE_OPENHUB: "1",
REQUIRE_OPENHUB_HEALTH: "1",
OPENHUB_PORT: "18081",
OPENCODE_PORT: "4097",
OPENHUB_REDIS_HEALTH_URL: "http://127.0.0.1:6379/health",
});
assert.equal(plan.enabled, true);
assert.equal(plan.openhub.url, "http://127.0.0.1:18081/health");
assert.equal(plan.openhub.required, true);
assert.equal(plan.redis.url, "http://127.0.0.1:6379/health");
assert.equal(plan.redis.skipped, false);
assert.equal(plan.opencode.url, "http://127.0.0.1:4097/global/health");
assert.deepEqual(plan.gitSnapshotRestore, {
env: "MNOTE_OPENHUB_DISABLE_GIT_SNAPSHOT_RESTORE",
value: "1",
defaultDisabled: true,
});
});
test("OpenHub 默认命令只启动 FastAPI,不包含 snapshot/restore 写操作", () => {
const command = buildDefaultOpenHubCommand(18082);
assert.match(command, /uvicorn app\.main:app/);
assert.match(command, /--port 18082/);
assert.doesNotMatch(command, /snapshot|restore|revert|kill-port/i);
});