ci / rust (pull_request) Successful in 4m37s
`just dev` builds maestro and runs the whole local stack in one command — registry (:8080), daemon (:7070), and the Vite web UI (:5173) — waits for each to be healthy, and tears all three down on Ctrl-C. Previously the Justfile only had frontend/CI recipes; running the project meant hand-starting the registry and daemon in separate terminals. Also fix attach under the Vite dev server: `/api/attach/:id` is a daemon-served broker WebSocket (NAP-243), not a registry route, so the old catch-all `/api` proxy sent it to the registry and got 404. Route `/api/attach` to the daemon (overridable via MAESTRO_DAEMON) and keep everything else on the registry — the same split the production maestro-web binary does. Verified: handshake now returns 101 and PTY bytes stream. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
58 lines
2.0 KiB
TypeScript
58 lines
2.0 KiB
TypeScript
import { defineConfig, loadEnv } from "vite";
|
|
|
|
// Where the dev proxy forwards `/api/*` (and the events WS) to. Default to a
|
|
// local `maestro-registry` on 127.0.0.1:8080. Override by exporting either:
|
|
// MAESTRO_REGISTRY=https://maestro-registry.example.com (preferred)
|
|
// MAESTRO_REGISTRY=wss://maestro-registry.example.com/daemon
|
|
// The second form (the daemon-facing URL) is normalised: ws/wss → http/https
|
|
// and any trailing `/daemon` is stripped, since the proxy needs the base URL.
|
|
function resolveProxyTarget(raw: string | undefined): string {
|
|
if (!raw) return "http://127.0.0.1:8080";
|
|
return raw
|
|
.replace(/^wss:\/\//, "https://")
|
|
.replace(/^ws:\/\//, "http://")
|
|
.replace(/\/daemon\/?$/, "")
|
|
.replace(/\/+$/, "");
|
|
}
|
|
|
|
export default defineConfig(({ mode }) => {
|
|
const env = loadEnv(mode, process.cwd(), "");
|
|
const target = resolveProxyTarget(env.MAESTRO_REGISTRY);
|
|
const secure = target.startsWith("https://");
|
|
// `/api/attach/:id` is a DAEMON-served broker WebSocket (NAP-243), not a
|
|
// registry route — the registry returns 404 for it. In production the
|
|
// `maestro-web` binary splits this traffic; in dev we replicate that here by
|
|
// forwarding `/api/attach` straight to the local daemon. Override with
|
|
// MAESTRO_DAEMON; defaults to the standard local daemon bind.
|
|
const daemonTarget = env.MAESTRO_DAEMON
|
|
? resolveProxyTarget(env.MAESTRO_DAEMON)
|
|
: "http://127.0.0.1:7070";
|
|
return {
|
|
build: {
|
|
target: "es2022",
|
|
outDir: "dist",
|
|
emptyOutDir: true,
|
|
sourcemap: false,
|
|
},
|
|
server: {
|
|
port: 5173,
|
|
// NOTE: order matters — Vite uses the first matching key, so the more
|
|
// specific `/api/attach` must come before the catch-all `/api`.
|
|
proxy: {
|
|
"/api/attach": {
|
|
target: daemonTarget,
|
|
changeOrigin: false,
|
|
ws: true,
|
|
secure: false,
|
|
},
|
|
"/api": {
|
|
target,
|
|
changeOrigin: secure,
|
|
ws: true,
|
|
secure: false,
|
|
},
|
|
},
|
|
},
|
|
};
|
|
});
|