refactor(mcp): move the session tools out of mcp/ so the runner can reuse them
Merged
SA
5d ago+125+125+012345678901234567890123456789-75-75-01234567890123456789
A refactor with no behavior change. It's the base for #1972, which runs the MCP session's tools in the runner's worker to attach to a held test.
- The session tools moved from
packages/e2e/src/mcp/topackages/e2e/src/session-tools/:tools.ts,catalog.ts,test-lines.ts,run-code.ts,code-parse.ts,code-surface.ts, andrecording.ts. Nothing insession-tools/imports frommcp/, sorun/can use them without importing frommcp/. RunCodeSessionandCatalogOptionsnow ask only for the members the code reads. A host with a different kind of attempt can supply them.mcp/session.tsstill passes the full objects.createStepExecutioninpackages/core/src/agent/step-execution.tsbuilds theStepAccounting,ObservationFeed, andActionDispatcherthatact.tsbuilt inline, on one shared queue, and returns the context bindings.act.tscalls it. #1972 can call it too, where it copied this wiring by hand before.
// packages/core/src/agent/step-execution.ts
export function createStepExecution(runtime: AgentContext, options: StepExecutionOptions): StepExecution;
The public .d.ts files of e2e and @e2e-dev/core are unchanged, so there's no changeset.
Verified
Ran it locally: yes
- Testbed, the built
e2e mcpover stdio. A normal session opens and the moved tools run:
> open_session {target: "web"}
Session <id> open on target "web" (platform web, engine web 0.16.1), headless
> tools
Session <id> on target "web": 32 tools. Run one with call {tool, args}; tools {tool} shows a tool's arguments.
> call {tool: "locate", args: {role: "link", name: "Todos"}}
1 node matches getByRole("link", name: "Todos"). | Use: screen.getByRole("link", "Todos")
> call {tool: "run_code"}
All 2 statements passed. | 1. passed: await screen.getByRole("link", "Todos").tap(); | 2. passed: await expect(screen.getByRole("heading", "Todos")).toBeVisible();
> call {tool: "test_lines"}
Draft test body from this session's actions, in order (3 lines): await app.open(); await screen.getByRole("link", "Todos").tap(); ...
> call {tool: "screenshot"}
Screenshot attached: 768 by 432 pixels
> close_session
Session <id> closed (closed by the agent); 4 tool calls ran.
- A fresh-context review compared the old
act.tswiring withcreateStepExecutionline by line: the construction order, the shared queue, the option values, and the lazytracecallback are the same.