* fix(server): serve agent MCP over the 2026-07-28 protocol Reasoning: - The bundled `@modelcontextprotocol/sdk@1.29.0` only speaks up to protocol `2025-11-25`, while current MCP clients (Claude Code, Codex, Grok CLI, ACP harnesses) send `mcp-protocol-version: 2026-07-28` and get `400 Bad Request: Unsupported protocol version` on the first request after `initialize`. The agent then runs without any Paseo tool, so `list_agents`, `create_agent`, and the rest silently disappear from the tool surface (#3009). - Widening the accepted version list (the approach in #4570 / #4375) hides the rejection but leaves the server implementing 2025 semantics while telling the client it speaks 2026-07-28. Changes: - Replace the v1 `StreamableHTTPServerTransport` wiring in `bootstrap.ts` with the v2 dual-era `createMcpHandler(..., { legacy: "stateless" })` plus `toNodeHandler` from `@modelcontextprotocol/node`. Modern 2026-07-28 requests and 2025-era clients are served by the same handler; per-request stateless serving is unchanged. - Move `agent/mcp-server.ts` to `@modelcontextprotocol/server` (`McpServer`, `ServerContext`, `context.mcpReq.signal`). - Keep `@modelcontextprotocol/sdk` for the existing client-side integrations (e.g. the OMP MCP bridge). - Assert the JSON-RPC `-32602` rejection in `mcp-server.test.ts`: a call to an unregistered tool is a protocol error, which the v1 server folded into an `isError` result. Verification: - `npx tsc -p packages/server/tsconfig.server.json` clean; `npm run typecheck` clean; `oxfmt`/`oxlint` clean on the touched files. - `npm ci --dry-run` accepts the lockfile. - `packages/server`: `mcp-server.test.ts` 194/194, `agent-mcp.e2e.test.ts` 8/8, `mcp-parity.e2e.test.ts` 38/38. - Manual check on macOS against a real daemon: a `dsh` agent (sends 2026-07-28) lists Paseo tools (`create_workspace`, `list_workspaces`, `create_agent`) and the daemon logs zero `MCP transport error` / `Unsupported protocol version` entries. * test(server): cover the modern MCP envelope on the agent endpoint Reasoning: - Greptile flagged that the tool registration used a `registerTool` re-cast, which defeats the SDK's type check on a path every agent tool call goes through. - The modern (2026-07-28) path had no regression coverage, so a looser "accept the version header" implementation would also pass the existing tests. Changes: - Narrow only the schema at the registration boundary (`inputSchema as StandardSchemaWithJSON`) and document why: Paseo declares schemas through the `zod` root entry, the SDK types them through `zod/v4` core; same runtime, distinct type identities. - Add a modern-protocol test that drives `createMcpHandler` with a per-request envelope (`_meta` protocol version + `mcp-method` header) and asserts the catalog tools come back. Verification: - `npx vitest run src/server/agent/mcp-server.test.ts` 195/195. - `npx tsc -p packages/server/tsconfig.server.json` clean; `oxfmt` / `oxlint` clean. * test(server): expect the agent MCP handler's own rejection The stateless MCP handler answers a body-less POST with 415 (unsupported media type) instead of the old transport's 406. The smoke test only needs the route to be live before the reload and gone after it, so assert that answer and say why the code changed. * fix(server): give native host tools the schema the agent MCP serves The agent MCP endpoint now registers tools with @modelcontextprotocol/server, which converts input schemas with zod at the draft 2020-12 target. The OpenCode bridge and OMP host tools still serialized through the v1 SDK internals as draft-07, so the plugin parity test (native schema equals advertised schema) failed. Serialize with the same zod conversion so one schema reaches both paths, and drop the dependency on unexported v1 SDK internals. OpenCode reads both dialects and defaults to 2020-12. OMP rewrites draft-07 to 2020-12 before sending to a model. * test(server): negotiate the agent MCP with pinned, auto and legacy clients Drive a real daemon's /mcp/agents with @modelcontextprotocol/client 2.4.0: - pinned to 2026-07-28: fails on the v1 transport ("server did not offer pinned protocol version 2026-07-28"). - auto: falls back to 2025-11-25 on the v1 transport. The test also asserts that the daemon logs no transport errors. - legacy: the 2025-era compatibility guard. Run the block in test:integration so CI keeps it, and translate the modern envelope test comment to English. * test(ci): route the agent MCP negotiation block through server integration The block shares the existing name-filtered vitest invocation, so it adds no extra vitest start to the Windows integration job. * test(website): play the orchestration scene on a held page clock The scene player advances at most 64ms per animation frame, so on a CI runner where headless WebKit paints a few frames a second the scene ran in slow motion and missed the 20s wait for the subagents pill. The test now pauses Playwright's page clock after hydration, checks the empty chat, then runs the clock past the scene before asserting the roster. --------- Co-authored-by: Ouyang Xingyuan <galaxyroaming@qq.com>
327 lines
15 KiB
TypeScript
327 lines
15 KiB
TypeScript
import { expect, test, waitForHydration, type Locator, type Page } from "./fixtures";
|
|
|
|
const desktopName =
|
|
"Paseo desktop app with coding agents, a conversation, and a code diff open side by side";
|
|
|
|
/** Opens the homepage once it has hydrated, so the router's scroll reset cannot undo a later scroll. */
|
|
async function openHomepage(page: Page, window = { width: 1512, height: 930 }) {
|
|
await page.setViewportSize(window);
|
|
await page.goto("/");
|
|
await waitForHydration(page);
|
|
}
|
|
|
|
async function viewPhones(page: Page) {
|
|
await page.getByRole("img", { name: "Paseo agent chat", exact: true }).scrollIntoViewIfNeeded();
|
|
}
|
|
|
|
async function expectScreenContentInsidePhone(page: Page, name: string, time: string) {
|
|
const phone = page.getByRole("img", { name, exact: true });
|
|
const clock = phone.getByText(time, { exact: true });
|
|
await expect(clock).toBeVisible();
|
|
await expect(async () => {
|
|
const frame = await phone.boundingBox();
|
|
const content = await clock.boundingBox();
|
|
expect(frame).not.toBeNull();
|
|
expect(content).not.toBeNull();
|
|
if (!frame || !content) throw new Error("Phone screen is not rendered");
|
|
expect(content.x).toBeGreaterThanOrEqual(frame.x);
|
|
expect(content.y).toBeGreaterThanOrEqual(frame.y);
|
|
expect(content.x + content.width).toBeLessThanOrEqual(frame.x + frame.width);
|
|
expect(content.y + content.height).toBeLessThanOrEqual(frame.y + frame.height);
|
|
}).toPass({ timeout: 5000 });
|
|
}
|
|
|
|
async function cornerProportion(mockup: Locator) {
|
|
return mockup.evaluate((element) => {
|
|
const radius = getComputedStyle(element).borderTopLeftRadius.split(" ")[0];
|
|
if (radius.endsWith("%")) return Number.parseFloat(radius) / 100;
|
|
return Number.parseFloat(radius) / element.getBoundingClientRect().width;
|
|
});
|
|
}
|
|
|
|
async function resizeToPhone(page: Page) {
|
|
await page.setViewportSize({ width: 390, height: 844 });
|
|
await page.getByRole("img", { name: desktopName, exact: true }).scrollIntoViewIfNeeded();
|
|
}
|
|
|
|
test("the three phone mockups show their screen content", async ({ page }) => {
|
|
await openHomepage(page);
|
|
await viewPhones(page);
|
|
await expectScreenContentInsidePhone(page, "Paseo workspace drawer", "18:54");
|
|
await expectScreenContentInsidePhone(page, "Paseo agent chat", "18:53");
|
|
await expectScreenContentInsidePhone(page, "Paseo diff view", "18:55");
|
|
});
|
|
|
|
test("desktop mockup corners shrink in proportion on a phone", async ({ page }) => {
|
|
await openHomepage(page);
|
|
const mockup = page.getByRole("img", { name: desktopName, exact: true });
|
|
const desktopCorner = await cornerProportion(mockup);
|
|
expect(desktopCorner).toBeGreaterThan(0);
|
|
await resizeToPhone(page);
|
|
await expect.poll(() => cornerProportion(mockup)).toBeCloseTo(desktopCorner, 3);
|
|
});
|
|
|
|
/** Each hero pill and one thing only its finished scene draws. */
|
|
const HERO_SCENES = [
|
|
{ pill: "Orchestration", shows: "Pi · GLM-5.2" },
|
|
{ pill: "Remote", shows: "Tailscale" },
|
|
{ pill: "Code review", shows: "Feedback sent to Codex" },
|
|
{ pill: "Pull requests", shows: "https://github.com/getpaseo/paseo/pull/3981" },
|
|
{ pill: "Plugins", shows: "app-tests (macos)" },
|
|
];
|
|
|
|
/** Clicks a hero pill until its scene starts. A click before hydration selects nothing. */
|
|
async function playScene(page: Page, pill: string, opensWith: Locator) {
|
|
await expect(async () => {
|
|
await page.getByRole("button", { name: pill, exact: true }).click();
|
|
await expect(opensWith).toBeVisible({ timeout: 500 });
|
|
}).toPass({ timeout: 10_000 });
|
|
}
|
|
|
|
test("each hero pill shows its finished scene when motion is reduced", async ({ page }) => {
|
|
await page.emulateMedia({ reducedMotion: "reduce" });
|
|
await openHomepage(page);
|
|
const mockup = page.getByRole("img", { name: desktopName, exact: true });
|
|
await mockup.scrollIntoViewIfNeeded();
|
|
// Last to first, so the opening scene is also reached by a click.
|
|
for (const scene of HERO_SCENES.toReversed()) {
|
|
await playScene(page, scene.pill, mockup.getByText(scene.shows, { exact: true }).first());
|
|
}
|
|
});
|
|
|
|
test("the hero opens on orchestration across providers and machines", async ({ page }) => {
|
|
await page.emulateMedia({ reducedMotion: "reduce" });
|
|
await openHomepage(page);
|
|
const mockup = page.getByRole("img", { name: desktopName, exact: true });
|
|
await expect(page.getByRole("button", { name: "Orchestration", exact: true })).toHaveAttribute(
|
|
"aria-pressed",
|
|
"true",
|
|
);
|
|
for (const agent of ["Codex · GPT-5.6-Sol", "OpenCode · Kimi K3", "Pi · GLM-5.2"]) {
|
|
await expect(mockup.getByText(agent, { exact: true })).toBeVisible();
|
|
}
|
|
// The task on another machine carries that host's badge in its tool call and its subagent row.
|
|
for (const remoteTask of ["OpenCode · fix/menu-bar-icon", "OpenCode · Kimi K3"]) {
|
|
const row = mockup.getByText(remoteTask, { exact: true }).locator("xpath=..");
|
|
await expect(row.getByText("mac-mini", { exact: true })).toBeVisible();
|
|
}
|
|
});
|
|
|
|
test("the orchestration scene plays from an empty chat to the open roster of subagents", async ({
|
|
page,
|
|
}) => {
|
|
// The scene clock moves at most 64ms per animation frame. Headless WebKit on a busy CI runner
|
|
// paints a few frames a second, so on the real clock the scene plays in slow motion and misses
|
|
// any wall-clock timeout. The test holds the page clock and plays the scene itself.
|
|
await page.clock.install();
|
|
await openHomepage(page);
|
|
await page.clock.pauseAt(await page.evaluate(() => Date.now() + 1000));
|
|
const mockup = page.getByRole("img", { name: desktopName, exact: true });
|
|
const composer = mockup.getByText("Message the agent, tag @files, or use /commands and /skills");
|
|
await playScene(page, "Orchestration", composer);
|
|
await expect(mockup.getByText("Create agent", { exact: true })).toHaveCount(0);
|
|
await expect(mockup.getByText("3 subagents", { exact: true })).toHaveCount(0);
|
|
|
|
// The orchestrator lists the issues and the agent profiles, launches three agents and says so,
|
|
// then the pointer clicks the pill and the roster opens. Ten seconds outlasts the scene.
|
|
await page.clock.runFor(10_000);
|
|
await expect(mockup.getByText("3 subagents", { exact: true })).toBeVisible();
|
|
await expect(mockup.getByText("gh issue list --label ready", { exact: true })).toBeVisible();
|
|
await expect(mockup.getByText("List agent profiles", { exact: true })).toBeVisible();
|
|
await expect(
|
|
mockup.getByText(
|
|
"I will launch the UI agent on your mac-mini, because that issue is specific to macOS.",
|
|
),
|
|
).toBeVisible();
|
|
await expect(mockup.getByText("Create agent", { exact: true })).toHaveCount(3);
|
|
await expect(
|
|
mockup.getByText("All three are launched. Paseo will notify me when each one finishes."),
|
|
).toBeVisible();
|
|
await expect(mockup.getByText("Pi · GLM-5.2", { exact: true })).toBeVisible();
|
|
});
|
|
|
|
test("the opening scene waits until most of the mockup is on screen", async ({ page }) => {
|
|
await openHomepage(page);
|
|
const mockup = page.getByRole("img", { name: desktopName, exact: true });
|
|
const request = mockup.getByText("Fix the issues labeled ready, one worktree each.");
|
|
await expect(mockup).not.toBeInViewport({ ratio: 0.6 });
|
|
|
|
// A scene that started at load sends the request within three seconds.
|
|
await page.waitForTimeout(4500);
|
|
await expect(request).toHaveCount(0);
|
|
|
|
await mockup.scrollIntoViewIfNeeded();
|
|
await expect(request).toBeVisible({ timeout: 10_000 });
|
|
});
|
|
|
|
test("the opening scene starts in a window shorter than most of the mockup", async ({ page }) => {
|
|
await openHomepage(page, { width: 1400, height: 320 });
|
|
const mockup = page.getByRole("img", { name: desktopName, exact: true });
|
|
const request = mockup.getByText("Fix the issues labeled ready, one worktree each.");
|
|
await mockup.scrollIntoViewIfNeeded();
|
|
await expect(mockup).not.toBeInViewport({ ratio: 0.6 });
|
|
await expect(request).toBeVisible({ timeout: 10_000 });
|
|
});
|
|
|
|
test("the plugins scene installs the panel, then changes it on request", async ({ page }) => {
|
|
await openHomepage(page);
|
|
const mockup = page.getByRole("img", { name: desktopName, exact: true });
|
|
const changesPanel = mockup.getByText("Uncommitted", { exact: true });
|
|
const pluginPanel = mockup.getByText("Recently merged", { exact: true });
|
|
const failingCheck = mockup.getByText("app-tests (macos)", { exact: true });
|
|
await playScene(page, "Plugins", page.getByRole("button", { name: "Plugins", pressed: true }));
|
|
await expect(changesPanel).toBeVisible();
|
|
await expect(pluginPanel).toHaveCount(0);
|
|
|
|
// Installing the plugin swaps the docked panel for the one the agent built.
|
|
await expect(pluginPanel).toBeVisible({ timeout: 20_000 });
|
|
await expect(changesPanel).toHaveCount(0);
|
|
await expect(failingCheck).toHaveCount(0);
|
|
|
|
// The second request reloads the plugin and the open panel lists the failing check.
|
|
await expect(failingCheck).toBeVisible({ timeout: 15_000 });
|
|
await expect(
|
|
mockup.getByText("paseo plugin reload release-radar", { exact: true }),
|
|
).toBeVisible();
|
|
});
|
|
|
|
test("the code review scene comments on a line and sends the feedback to an agent", async ({
|
|
page,
|
|
}) => {
|
|
await openHomepage(page);
|
|
const mockup = page.getByRole("img", { name: desktopName, exact: true });
|
|
const comment = mockup.getByText("Add “write”. The agent edits files too.", { exact: true });
|
|
const sendFeedback = mockup.getByText("Send feedback (1)", { exact: true });
|
|
await playScene(
|
|
page,
|
|
"Code review",
|
|
page.getByRole("button", { name: "Code review", pressed: true }),
|
|
);
|
|
await expect(comment).toHaveCount(0);
|
|
|
|
// The pointer opens the editor on a line, and the typed comment is saved under that line.
|
|
await expect(sendFeedback).toBeVisible({ timeout: 10_000 });
|
|
await expect(comment).toBeVisible();
|
|
|
|
// Send feedback asks which agent, and the sent comment leaves the diff.
|
|
await expect(mockup.getByText("Claude Code", { exact: true })).toHaveCount(2, {
|
|
timeout: 10_000,
|
|
});
|
|
await expect(mockup.getByText("Feedback sent to Codex", { exact: true })).toBeVisible({
|
|
timeout: 10_000,
|
|
});
|
|
await expect(sendFeedback).toHaveCount(0);
|
|
await expect(comment).toHaveCount(0);
|
|
});
|
|
|
|
test("picking a scene brings the pills and the whole mockup on screen", async ({ page }) => {
|
|
await openHomepage(page);
|
|
const mockup = page.getByRole("img", { name: desktopName, exact: true });
|
|
await expect(mockup).not.toBeInViewport({ ratio: 0.9 });
|
|
|
|
await playScene(page, "Remote", page.getByRole("button", { name: "Remote", pressed: true }));
|
|
await expect(mockup).toBeInViewport({ ratio: 0.99 });
|
|
await expect(page.getByRole("button", { name: "Remote", exact: true })).toBeInViewport({
|
|
ratio: 1,
|
|
});
|
|
});
|
|
|
|
test("picking a scene in a window too short for the mockup keeps the pills on screen", async ({
|
|
page,
|
|
}) => {
|
|
await openHomepage(page);
|
|
await page.setViewportSize({ width: 1280, height: 600 });
|
|
const mockup = page.getByRole("img", { name: desktopName, exact: true });
|
|
await expect(mockup).not.toBeInViewport();
|
|
|
|
await playScene(page, "Remote", page.getByRole("button", { name: "Remote", pressed: true }));
|
|
await expect(mockup).toBeInViewport({ ratio: 0.7 });
|
|
await expect(page.getByRole("button", { name: "Remote", exact: true })).toBeInViewport({
|
|
ratio: 1,
|
|
});
|
|
});
|
|
|
|
test("picking a scene while the hero is still sliding in keeps the pills on screen", async ({
|
|
page,
|
|
}) => {
|
|
// Reduced motion makes the scroll instant, so the test does not wait for one to settle.
|
|
await page.emulateMedia({ reducedMotion: "reduce" });
|
|
await openHomepage(page, { width: 1280, height: 700 });
|
|
const mockup = page.getByRole("img", { name: desktopName, exact: true });
|
|
await playScene(page, "Remote", page.getByRole("button", { name: "Remote", pressed: true }));
|
|
|
|
// The hero slides up 40px as it enters. The test waits for that to end, puts the same 40px back
|
|
// on the container, picks a scene, and lets the slide end again. A click during a real slide
|
|
// does the same, but only inside the first second after load.
|
|
const sliding = page
|
|
.getByRole("button", { name: "Remote", exact: true })
|
|
.locator("xpath=../../../..");
|
|
await expect(sliding).toHaveCSS("transform", "none");
|
|
await page.evaluate(() => window.scrollTo(0, 0));
|
|
await expect(mockup).not.toBeInViewport({ ratio: 0.99 });
|
|
const slideBy = (pixels: number) =>
|
|
sliding.evaluate((container, y) => {
|
|
container.style.transform = y === 0 ? "none" : `translateY(${y}px)`;
|
|
}, pixels);
|
|
|
|
const codeReview = page.getByRole("button", { name: "Code review", exact: true });
|
|
await slideBy(40);
|
|
await codeReview.click();
|
|
await slideBy(0);
|
|
expect(await page.evaluate(() => window.scrollY)).toBeGreaterThan(0);
|
|
await expect(codeReview).toBeInViewport({ ratio: 1 });
|
|
});
|
|
|
|
test("the remote scene lists hosts with how each connects and its round trip time", async ({
|
|
page,
|
|
}) => {
|
|
await openHomepage(page);
|
|
const mockup = page.getByRole("img", { name: desktopName, exact: true });
|
|
await expect(async () => {
|
|
await page.getByRole("button", { name: "Remote", exact: true }).click();
|
|
await expect(mockup.getByText("Hosts", { exact: true })).toBeVisible({ timeout: 500 });
|
|
}).toPass({ timeout: 10_000 });
|
|
for (const fact of ["Local", "Relay", "Tailscale", "SSH", "38ms", "mo@workstation"]) {
|
|
await expect(mockup.getByText(fact, { exact: true })).toBeVisible();
|
|
}
|
|
});
|
|
|
|
/** Opacity as rendered: the element's own times every ancestor's. */
|
|
async function renderedOpacity(locator: Locator) {
|
|
return locator.evaluate((element) => {
|
|
let opacity = 1;
|
|
for (let node: Element | null = element; node; node = node.parentElement) {
|
|
opacity *= Number.parseFloat(getComputedStyle(node).opacity);
|
|
}
|
|
return opacity;
|
|
});
|
|
}
|
|
|
|
test("the plugin demo plays through to the panel the agent built", async ({ page }) => {
|
|
await openHomepage(page);
|
|
const builtPanelRow = page.getByText("Add Gruvbox theme", { exact: true });
|
|
expect(await renderedOpacity(builtPanelRow)).toBe(0);
|
|
|
|
// Hydration can reset the scroll position, so keep the demo in view until it finishes.
|
|
const heading = page.getByRole("heading", { name: "Ask Paseo to change Paseo" });
|
|
await expect(async () => {
|
|
await heading.scrollIntoViewIfNeeded();
|
|
expect(await renderedOpacity(builtPanelRow)).toBe(1);
|
|
}).toPass({ timeout: 15_000 });
|
|
expect(await renderedOpacity(page.getByText("Review queue is in your sidebar."))).toBe(1);
|
|
});
|
|
|
|
test("the plugin demo shows its finished state when motion is reduced", async ({ page }) => {
|
|
await page.emulateMedia({ reducedMotion: "reduce" });
|
|
await openHomepage(page);
|
|
const builtPanelRow = page.getByText("Add Gruvbox theme", { exact: true });
|
|
const panel = builtPanelRow.locator("xpath=ancestor::div[contains(@class, 'md:border-l')]");
|
|
const heading = page.getByRole("heading", { name: "Ask Paseo to change Paseo" });
|
|
|
|
await expect(async () => {
|
|
await heading.scrollIntoViewIfNeeded();
|
|
expect(await renderedOpacity(builtPanelRow)).toBe(1);
|
|
}).toPass({ timeout: 2_000 });
|
|
expect(await panel.evaluate((element) => getComputedStyle(element).transform)).toBe("none");
|
|
});
|