feat: complete hermes page ai runtime bff

This commit is contained in:
lix-2026
2026-05-15 23:20:25 +08:00
parent 0e6cf5cf13
commit 01fdd2a8c3
7 changed files with 4326 additions and 259 deletions
@@ -76,7 +76,7 @@ async function main() {
}),
});
});
await page.route(`**/api/hermes/client/sessions/${sessionId}`, async (route) => {
await page.route(`**/api/hermes/client/sessions/${sessionId}/resume`, async (route) => {
await route.fulfill({
status: 200,
headers: { "content-type": "application/json" },
@@ -96,7 +96,9 @@ async function main() {
await route.fulfill({
status: 200,
headers: { "content-type": "text/event-stream; charset=utf-8" },
body: `data: ${JSON.stringify({ event: "run.aborted", run_id: runId, session_id: sessionId })}\n\n`,
body:
`data: ${JSON.stringify({ event: "run.aborted", run_id: runId, session_id: sessionId })}\n\n` +
`data: ${JSON.stringify({ event: "message.delta", run_id: runId, session_id: sessionId, delta: "SHOULD_NOT_APPEAR_AFTER_ABORT" })}\n\n`,
});
});
await page.route(`**/api/hermes/client/runs/${runId}/abort`, async (route) => {
@@ -105,7 +107,16 @@ async function main() {
await route.fulfill({
status: 200,
headers: { "content-type": "application/json" },
body: JSON.stringify({ ok: true, runId, status: "aborted" }),
body: JSON.stringify({
ok: true,
runId,
status: "aborted",
runtime: { sessionId, runId, status: "aborted" },
events: [
{ event: "abort.started", runId },
{ event: "abort.completed", runId },
],
}),
});
});
@@ -150,6 +161,14 @@ async function main() {
null,
{ timeout: UI_TIMEOUT_MS },
);
await page.waitForTimeout(100);
const drawerTextAfterAbort = await page.locator('[data-testid="wolai-page-ai-drawer"]').textContent({
timeout: UI_TIMEOUT_MS,
});
assert(
!drawerTextAfterAbort.includes("SHOULD_NOT_APPEAR_AFTER_ABORT"),
"abort 后不应继续追加该 run 的 assistant delta",
);
assert(sessionBodies.some((body) => body.profile === "default"), "创建 session 必须携带 profile");
assert(abortBodies.some((body) => body.reason === "page_ai_user_stop"), "停止 run 必须调用 Hermes abort API");