2026-04-30 05:46:36 +08:00
|
|
|
|
#!/usr/bin/env node
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
2026-07-25 14:25:37 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 历史:曾验证 /api/hermes/bridge structured write 合同。
|
|
|
|
|
|
* Wave 10:Hermes bridge 已删除;改为负向门禁(404),主链用 /api/mnote/tools + Pi Lab。
|
|
|
|
|
|
* tools manifest 可能需登录(401 仍表示路由挂载,区别于 404)。
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2026-04-30 05:46:36 +08:00
|
|
|
|
const assert = require("node:assert");
|
|
|
|
|
|
|
|
|
|
|
|
const BASE_URL = (process.env.MNOTE_UI_BASE_URL || "http://127.0.0.1:3000").replace(/\/$/, "");
|
|
|
|
|
|
|
|
|
|
|
|
async function main() {
|
|
|
|
|
|
const response = await fetch(`${BASE_URL}/api/hermes/bridge`, {
|
|
|
|
|
|
method: "POST",
|
|
|
|
|
|
headers: { "content-type": "application/json" },
|
|
|
|
|
|
body: JSON.stringify({
|
|
|
|
|
|
stream: true,
|
|
|
|
|
|
scope: "document",
|
|
|
|
|
|
messages: [{ role: "user", content: "生成摘要" }],
|
|
|
|
|
|
context: { documentId: "doc_1", workspaceId: "ws_demo" },
|
|
|
|
|
|
}),
|
|
|
|
|
|
});
|
2026-07-25 14:25:37 +08:00
|
|
|
|
const text = await response.text();
|
|
|
|
|
|
assert.equal(
|
|
|
|
|
|
response.status,
|
|
|
|
|
|
404,
|
|
|
|
|
|
`legacy /api/hermes/bridge 应已删除,实际 ${response.status}: ${text.slice(0, 300)}`,
|
|
|
|
|
|
);
|
2026-04-30 05:46:36 +08:00
|
|
|
|
|
2026-07-25 14:25:37 +08:00
|
|
|
|
const tools = await fetch(`${BASE_URL}/api/mnote/tools/manifest`);
|
|
|
|
|
|
const toolsText = await tools.text();
|
|
|
|
|
|
assert.notEqual(
|
|
|
|
|
|
tools.status,
|
|
|
|
|
|
404,
|
|
|
|
|
|
`/api/mnote/tools/manifest 路由应挂载(200 或 401),实际 ${tools.status}`,
|
|
|
|
|
|
);
|
|
|
|
|
|
// 未登录时 401;已登录时 200 且含 schema
|
|
|
|
|
|
if (tools.status === 200) {
|
|
|
|
|
|
assert.ok(
|
|
|
|
|
|
toolsText.includes("mnote.agent_tool_manifest.v1"),
|
|
|
|
|
|
"tools manifest 应使用 mnote.agent_tool_manifest.v1",
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
console.log(
|
|
|
|
|
|
JSON.stringify(
|
|
|
|
|
|
{
|
|
|
|
|
|
ok: true,
|
|
|
|
|
|
legacyHermesBridge: { status: 404 },
|
|
|
|
|
|
agentTools: {
|
|
|
|
|
|
status: tools.status,
|
|
|
|
|
|
mounted: true,
|
|
|
|
|
|
schemaOk: tools.status === 200 ? toolsText.includes("mnote.agent_tool_manifest.v1") : null,
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
null,
|
|
|
|
|
|
2,
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
2026-04-30 05:46:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
main().catch((error) => {
|
|
|
|
|
|
console.error(error instanceof Error ? error.stack || error.message : String(error));
|
|
|
|
|
|
process.exit(1);
|
|
|
|
|
|
});
|