Skip to content

Conversation

@rgarcia
Copy link
Contributor

@rgarcia rgarcia commented Oct 24, 2025

  • add node, playwright, and tsx to the images
  • add an endpoint that takes in code and executes it within a shim that provides a page Playwright object

Note

Adds /playwright/execute API to run TypeScript/Playwright code against the running Chromium via a tsx-based executor, and installs Node.js 22 + Playwright tooling in images.

  • API/Backend:
    • Introduces POST /playwright/execute to run arbitrary TS/Playwright code with timeout; serializes runs via ApiService.playwrightMu.
    • Implements handler ExecutePlaywrightCode executing tsx /usr/local/lib/playwright-executor.ts <tmp.ts> and returning JSON {success,result|error,stdout,stderr}.
    • Updates generated OAPI types/clients/routers for new request/response models (ExecutePlaywrightRequest/Result).
  • Runtime:
    • Adds server/runtime/playwright-executor.ts connecting to ws://127.0.0.1:9222 via playwright-core, exposing page/context/browser, returning JSON.
  • Images:
    • Installs Node.js 22.x, recreates npm/npx/corepack links; globally installs typescript, playwright-core, tsx in both chromium-headful and chromium-headless images.
    • Copies playwright-executor.ts into /usr/local/lib/.
  • Tests:
    • Adds E2E test TestPlaywrightExecuteAPI validating navigation to example.com and returned title.
  • Spec:
    • Extends openapi.yaml and embedded swagger; regenerates server/lib/oapi.

Written by Cursor Bugbot for commit aaccaeb. This will update automatically on new commits. Configure here.

@rgarcia rgarcia requested a review from hiroTamada October 24, 2025 18:27
@mesa-dot-dev
Copy link

mesa-dot-dev bot commented Oct 24, 2025

Mesa Description

  • add node, playwright, and tsx to the images
  • add an endpoint that takes in code and executes it within a shim that provides a page Playwright object

Note

Adds POST /playwright/execute to run user TypeScript/Playwright code via tsx against Chromium, updates images with Node.js 22 + Playwright, and includes an e2e test.

  • API:
    • New Endpoint: POST /playwright/execute to run Playwright/TypeScript code with timeout; returns {success,result,error,stdout,stderr} (server/cmd/api/api/playwright.go).
    • OpenAPI + Generated Client/Server: Spec and codegen updated to expose request/response types and routing (server/openapi.yaml, server/lib/oapi/oapi.go).
  • Runtime:
    • Executor: Add server/runtime/playwright-executor.ts invoked via tsx, connecting to ws://127.0.0.1:9222 and evaluating provided code.
  • Containers:
    • Install Node.js 22, typescript, playwright-core, and tsx; copy executor into image (images/chromium-headful/Dockerfile, images/chromium-headless/image/Dockerfile).
  • Tests:
    • Add e2e test executing a simple Playwright script and asserting result (server/e2e/e2e_chromium_test.go).

Written by Cursor Bugbot for commit 8251b07. This will update automatically on new commits. Configure here.

Description generated by Mesa. Update settings

Copy link

@mesa-dot-dev mesa-dot-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Performed full review of 174e365...e809a85

Tip

Help

Configure your agents

Mesa Docs

Slash Commands:

  • /review - Request a full code review
  • /review latest - Review only changes since the last review
  • /describe - Generate PR description. This will update the PR body or issue comment depending on your configuration
  • /help - Get help with Mesa commands and configuration options

7 files reviewed | 0 comments | Edit Agent Settings

Copy link
Contributor

@hiroTamada hiroTamada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the point of this making the playwright code and chrome physically close to each other to avoid network connectivity issue and latency?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, does it make the image bigger?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes by 200-300 MB

@hiroTamada
Copy link
Contributor

I actually wonder if this endpoint is thread safe or not. Would concurrent script executions break chrome?

cursor[bot]

This comment was marked as outdated.

@rgarcia
Copy link
Contributor Author

rgarcia commented Oct 27, 2025

Is the point of this making the playwright code and chrome physically close to each other to avoid network connectivity issue and latency?

yes, exactly!

@rgarcia rgarcia merged commit 6d144ca into main Oct 27, 2025
5 checks passed
@rgarcia rgarcia deleted the raf/kernel-458-ad-hoc-playwright-code-exec-api branch October 27, 2025 17:28
Sayan- added a commit that referenced this pull request Nov 10, 2025
## Overview

Following up on #84.
Install and allow running against patchright instead of only playwright

## Testing

Build + ran both headful + headless images. Confirmed execution working
as expected with `curl`:

```sh
curl -sS http://localhost:444/playwright/execute \
  -H 'Content-Type: application/json' \
  -d '{"code":"await page.goto(\"https://example.com\"); return await page.title();"}'
{"result":"Example Domain","success":true}
```

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Adds Patchright support across images and runtime, selectable via
PLAYWRIGHT_ENGINE, and tweaks headless Chromium flags.
> 
> - **Runtime**
> - Update `server/runtime/playwright-executor.ts` to dynamically select
`chromium` from `patchright` or `playwright-core` based on
`PLAYWRIGHT_ENGINE`.
> - **Images**
> - Install `patchright` globally alongside `playwright-core`,
`typescript`, and `tsx` in `images/chromium-headful/Dockerfile` and
`images/chromium-headless/image/Dockerfile`.
> - **Scripts**
> - Pass through `PLAYWRIGHT_ENGINE` env in
`images/chromium-headful/run-docker.sh` and
`images/chromium-headless/run-docker.sh`.
> - **Chromium Flags (Headless)**
> - Adjust defaults in `images/chromium-headless/image/wrapper.sh` by
removing several flags (e.g., `--disable-component-update`,
`--disable-default-apps`, `--disable-extensions`,
`--enable-automation`).
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
50d5bb3. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants