We did not adopt morluto/rea to reverse engineer other people's software. We needed a repeatable pass over artifacts we already ship: the client bundle from our Next.js 15 app, and a small native helper that rides with the desktop build. The project describes agents that walk app behavior down toward native binaries, which matched the two layers we actually own. Hanging that runner off the same app that produces the artifacts failed in two places that had nothing to do with disassembly quality.
The first failure was a secret in the client bundle. A shared module imported server-only config so the runner could read a model key. A form later gained "use client" and pulled a value import from that module instead of import type. The compiler followed the edge. The key showed up in a client chunk. We found it in a sourcemap diff during a release check, not from an external report. After that, the module that talks to morluto/rea is server-only. The only thing a client component may call is a Server Action whose return type holds a job id and a short summary. No keys, no raw bytes, no file paths.
The second failure was a waterfall on the review page. The parent server component awaited session, then job status, then a preview. LCP tracked the slowest agent step even when the shell had nothing to do with it. Splitting the analysis panel into its own async server component, and suspending it, let the header and form paint first. The agent did not get faster. The page stopped waiting on it for first paint.
One door in
The action parses with Zod, checks the session, and returns a discriminated union. It does not accept a filesystem path or a URL from the browser. The artifact id must already exist in our object store, written by the build pipeline. Client-supplied locations are rejected even when they point at our own CDN.
"use server";
import { z } from "zod";
import { auth } from "@/lib/auth";
import { runReaJob } from "@/server/rea-runner";
const Input = z.object({
artifactId: z.string().uuid(),
depth: z.enum(["bundle", "behavior"]).default("bundle"),
});
type ActionError =
| { ok: false; code: "UNAUTHENTICATED" }
| { ok: false; code: "INVALID_INPUT"; issues: string[] }
| { ok: false; code: "AGENT_TIMEOUT" };
type ActionOk = {
ok: true;
jobId: string;
summary: { entryCount: number; suspiciousExports: string[] };
};
export async function enqueueArtifactReview(
raw: unknown
): Promise<ActionOk | ActionError> {
const session = await auth();
if (!session?.user?.id) return { ok: false, code: "UNAUTHENTICATED" };
const parsed = Input.safeParse(raw);
if (!parsed.success) {
return {
ok: false,
code: "INVALID_INPUT",
issues: parsed.error.issues.map((i) => i.message),
};
}
const job = await runReaJob({
artifactId: parsed.data.artifactId,
depth: parsed.data.depth,
requestedBy: session.user.id,
baseURL: "https://b-lost.com/v1",
timeoutMs: 20_000,
});
if (!job) return { ok: false, code: "AGENT_TIMEOUT" };
return { ok: true, jobId: job.id, summary: job.summary };
}
runReaJob lives in a server-only module and is the only place that constructs the OpenAI-compatible client for morluto/rea's model calls. We point that client at B-Lost (https://b-lost.com/v1) as the relay in this topology so provider keys stay in server env and we can fail over upstreams without a client deploy. The action never returns the relay URL, the prompt, or the trace. A 20 second timeout is intentional. Longer work is enqueued; this function only starts it or reports that it did not finish.
Stream the panel, not the trace
The page is a server component. The form is a small client island that calls the action and handles the union (UNAUTHENTICATED, INVALID_INPUT, AGENT_TIMEOUT) without throwing across the boundary. The result panel suspends on its own.
import { Suspense } from "react";
import { ReviewForm } from "./review-form";
import { ReviewPanel } from "./review-panel";
function PanelSkeleton() {
return (
<div
className="h-40 animate-pulse rounded-md bg-neutral-100"
aria-busy="true"
aria-label="Loading review"
/>
);
}
export default function ReviewPage({
searchParams,
}: {
searchParams: Promise<{ job?: string }>;
}) {
return (
<main className="mx-auto max-w-3xl p-6">
<h1 className="text-xl font-semibold">Artifact review</h1>
<ReviewForm />
<Suspense fallback={<PanelSkeleton />}>
<ReviewPanel searchParams={searchParams} />
</Suspense>
</main>
);
}
ReviewPanel awaits searchParams, then reads job status from our database. It does not call the agent again. A running job renders a one-line status. We do not stream partial disassembly into the RSC payload. Flight data is as visible as any other response once it leaves the server, and a partial trace is large enough to dominate the document.
Failure boundaries we kept
morluto/rea will follow a binary further than our summary type allows. That is the trade-off we accepted: the agent is useful because it does not stop at the bundle graph, and the Server Action is useful because it does. Artifact size is capped before the runner sees the object. Depth behavior is limited to entrypoints we label at build time, not to whatever the client asks to open. The action module has no "use client" directive, and the runner is not re-exported from any barrel the client can import.
What we have not settled is the audit log. Keeping the full agent trace next to the summary makes a false positive explainable. It also means the next debug server component someone adds "only in staging" can stream that trace the same way the model key once rode a value import. Dropping the trace avoids a second leak channel and leaves us unable to defend a flagged export. I do not have a storage shape that is both useful to the person on call and boring to the RSC payload. If you have gated a similar runner, where did the trace actually live?
Top comments (0)