2026-04-29 12:24:44 +08:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
const BASE_URL = (process.env.MNOTE_UI_BASE_URL || "http://127.0.0.1:3000").replace(/\/+$/, "");
|
|
|
|
|
const REQUEST_TIMEOUT_MS = Number(process.env.MNOTE_SMOKE_TIMEOUT_MS || 20_000);
|
|
|
|
|
|
|
|
|
|
function assert(condition, message) {
|
|
|
|
|
if (!condition) {
|
|
|
|
|
throw new Error(message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function fetchWithTimeout(path, init = {}) {
|
|
|
|
|
const controller = new AbortController();
|
|
|
|
|
const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
|
|
|
|
|
try {
|
|
|
|
|
return await fetch(`${BASE_URL}${path}`, {
|
|
|
|
|
...init,
|
|
|
|
|
signal: controller.signal,
|
|
|
|
|
});
|
|
|
|
|
} finally {
|
|
|
|
|
clearTimeout(timeout);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function readTextResponse(path, init) {
|
|
|
|
|
const response = await fetchWithTimeout(path, init);
|
|
|
|
|
const text = await response.text();
|
|
|
|
|
assert(response.ok, `${path} 请求失败: ${response.status} ${text.slice(0, 200)}`);
|
|
|
|
|
return { response, text };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function checkSearchShell() {
|
|
|
|
|
const { response, text } = await readTextResponse("/search?workspaceId=ws_task116&q=Rust");
|
|
|
|
|
assert(response.headers.get("x-mnote-web-owner") === "mnote-web", "Search shell 缺少 mnote-web owner header");
|
|
|
|
|
assert(response.headers.get("x-mnote-web-shell") === "search", "Search shell 缺少 search shell header");
|
|
|
|
|
assert(text.includes("mnote.search_shell.v1"), "Search shell 缺少 contract schema");
|
2026-04-30 05:46:36 +08:00
|
|
|
assert(text.includes("search_interaction_island"), "Search shell 缺少 search interaction island");
|
|
|
|
|
return { owner: "mnote-web", shell: "search", island: "search_interaction_island" };
|
2026-04-29 12:24:44 +08:00
|
|
|
}
|
|
|
|
|
|
2026-07-25 14:25:37 +08:00
|
|
|
async function checkAgentTools() {
|
|
|
|
|
const { response, text } = await readTextResponse("/api/mnote/tools/manifest");
|
2026-04-29 12:24:44 +08:00
|
|
|
const payload = JSON.parse(text);
|
2026-07-25 14:25:37 +08:00
|
|
|
const schema = payload?.manifest?.schemaVersion || payload?.schema || payload?.contract?.schema || "";
|
|
|
|
|
assert(
|
|
|
|
|
schema === "mnote.agent_tool_manifest.v1" || String(text).includes("mnote.agent_tool_manifest.v1"),
|
|
|
|
|
`tools manifest schema 不正确: ${schema || text.slice(0, 200)}`,
|
|
|
|
|
);
|
|
|
|
|
const owner = response.headers.get("x-mnote-agent-tool-owner") || payload?.owner || "";
|
|
|
|
|
return { owner: owner || "mnote-web-agent-tools", schema: "mnote.agent_tool_manifest.v1" };
|
2026-04-29 12:24:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function checkMindmapShell() {
|
|
|
|
|
const { response, text } = await readTextResponse("/mindmap/doc_task116/mind_task116");
|
|
|
|
|
assert(response.headers.get("x-mnote-web-owner") === "mnote-web", "Mindmap shell 缺少 mnote-web owner header");
|
|
|
|
|
assert(response.headers.get("x-mnote-web-shell") === "mindmap", "Mindmap shell 缺少 mindmap shell header");
|
|
|
|
|
assert(text.includes("mnote.mindmap_shell.v1"), "Mindmap shell 缺少 contract schema");
|
|
|
|
|
assert(text.includes('data-react-island="mindmap_runtime"'), "Mindmap shell 缺少 mindmap runtime island");
|
|
|
|
|
return { owner: "mnote-web", shell: "mindmap", island: "mindmap_runtime" };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function main() {
|
|
|
|
|
const search = await checkSearchShell();
|
2026-07-25 14:25:37 +08:00
|
|
|
const agentTools = await checkAgentTools();
|
2026-04-29 12:24:44 +08:00
|
|
|
const mindmap = await checkMindmapShell();
|
|
|
|
|
console.log(
|
|
|
|
|
JSON.stringify(
|
|
|
|
|
{
|
|
|
|
|
ok: true,
|
|
|
|
|
baseUrl: BASE_URL,
|
|
|
|
|
results: {
|
|
|
|
|
search,
|
2026-07-25 14:25:37 +08:00
|
|
|
agentTools,
|
2026-04-29 12:24:44 +08:00
|
|
|
mindmap,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
null,
|
|
|
|
|
2,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
main().catch((error) => {
|
|
|
|
|
console.error(error instanceof Error ? error.stack || error.message : String(error));
|
|
|
|
|
process.exit(1);
|
|
|
|
|
});
|