Skip to content

feat(plugins): add native CI Runners plugin with direct runner API and deployment - #29

Open
drakestapleton wants to merge 1 commit into
MiaAI-Lab:mainfrom
drakestapleton:feat/ci-runners-plugin
Open

drakestapleton wants to merge 1 commit into
MiaAI-Lab:mainfrom
drakestapleton:feat/ci-runners-plugin

Conversation

@drakestapleton

Copy link
Copy Markdown

Summary

Adds bundled native plugin support to m3/plugin-host and ships a first-party CI Runners native plugin (m3/plugins/ci-runners/) for managing self-hosted CI runners, running a direct API layer to those runners, and deploying new runners.

What's Included

  1. Bundled Native Plugin Support (m3/plugin-host/)

    • PluginHostManager now discovers bundled native plugins under m3/plugins/ alongside user-installed plugins in ~/.m3/plugins/ (with user overrides taking precedence).
    • Marks bundled plugins with builtin: true, prevents accidental uninstall deletion (while still allowing Enable/Disable), resolves "node" sidecar commands to process.execPath under Node, and passes M3_HOME_DIR / M3_PLUGIN_DATA_DIR (~/.m3/userdata/plugins/<id>) to sidecars.
    • M3PluginSlotHost hides the Remove button for built-in plugins.
    • Zero upstream T3 files modified.
  2. Native CI Runners Plugin (m3/plugins/ci-runners/)

    • Direct Runner API Layer (runnerApi.mjs, server.mjs): Uniform REST API for probing live health/capacity, listing runs, triggering runs, cancelling runs, and fetching logs across:
      • Custom M3 HTTP Runner (direct HTTP daemon API)
      • GitHub Actions (self-hosted runners + workflow dispatches/runs/jobs/cancel)
      • GitLab Runner (runner fleet + pipelines/jobs/traces/cancel)
      • Forgejo / Gitea Actions (runners + workflow dispatches/runs/jobs/cancel)
    • Self-Hosted Runner Deployment (runnerDeployer.mjs): Generates auditable Docker Compose, docker run, hardened Linux systemd units, and SSH bootstrap scripts, plus direct argv-based execution for local Docker or remote SSH (POST /api/deploy/execute) with optional auto-registration. Includes a zero-dependency m3-runner-agent.mjs self-hosted HTTP runner daemon (GET /api/deploy/agent-script).
    • Sandboxed UI (ui/index.html): Three tabs (Runners, Runs & Logs, Deploy Runner) wired to /api/m3-plugins/sdk.js, including one-click "Send Logs to Agent" (M3Plugin.injectPrompt) to hand failing CI traces straight to the active coding agent.
    • Secret Hygiene (runnerStore.mjs): Tokens are stored locally at 0600 under ~/.m3/userdata/plugins/ci-runners/runners.json and always masked in API responses (tokenSet + tokenPreview).

Verification

  • vp test run m3/plugin-host/PluginHostManager.test.ts m3/plugins/ci-runners/ciRunners.test.ts — 6/6 tests passed (built-in auto-discovery + sidecar spawn + uninstall guard, secret masking, end-to-end loopback probe/trigger/list/logs/cancel, Docker/systemd/SSH deployment plan generation).
  • vp fmt --check, vp lint (0 errors), vp run --filter @t3tools/web typecheck, and vp run i18n:check all passed.

Model & harness: Gemini 4 Neon (Medium) via Antigravity.

@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:XXL labels Nov 25, 2026
@MiaAI-Lab

Copy link
Copy Markdown
Owner

Not merged. The builtin-discovery change is small, but the bundled CI Runners plugin can't ship as is:

  1. Remote code execution, on by default. /api/m3-plugins/* has no auth on the server, builtins start enabled (saved?.enabled ?? true) and auto-start, and the plugin exposes POST /api/deploy/execute, which runs docker run with a caller-chosen image and workDir volume. Anyone who can reach the port (LAN, tailnet, tunnel) gets root through Docker. readJsonBody ignores content-type, so a cross-origin text/plain POST from any web page to localhost also works. trigger sends an arbitrary command to a runner too.
  2. Token exfiltration. updateRunner keeps the stored token when apiBaseUrl changes. PATCH the URL to an attacker host, call probe, and the GitHub/GitLab/Forgejo token is sent there. probeRunner also returns response bytes from any URL (readable SSRF).
  3. Shell injection in SSH deploy. remoteInstallScript interpolates workDir unquoted, and displayDockerCmd doesn't quote backticks, $(), <, >.
  4. The deployed runner agent is an open shell by default. It binds 0.0.0.0, accepts any request when no token is set, and Docker publishes the port.
  5. Not packaged. DEFAULT_BUILTIN_PLUGINS_DIR resolves ../../plugins from import.meta.url, which only works from source. Desktop/npm/SEA builds don't ship m3/plugins, and discovery fails silently.
  6. Regression for existing plugins. Swapping "node" for process.execPath makes the SEA build run t3 server.mjs for every user plugin.

Scope-wise, a ~2,700-line deployment tool belongs in a separately installable plugin, not bundled and default-on in every install. A PR with only the builtin-discovery change (default off, packaged, no execPath swap) would be reviewable on its own.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants