refactor(desktop): give the agentenv provider name an entry file and name the build computer's controlled routes as a port (#11600)

* refactor(desktop): give the agentenv provider name its own entry file and move ComputerRelease into src/domain

* refactor(desktop): name the build computer's controlled routes and controller answer as a port (#11604)
This commit is contained in:
morluto authored and GitHub committed 2026-11-16 08:51:27 +08:00
1 parent 2910fc0b13
commit 793ab582be
26 files changed
+146 -87

No files matched your search

+7 -11
View File
@@ -11,8 +11,11 @@ import {
guestFileAnswerBytes,
guestFileAnswerCeiling,
guestFileAnswerWorkingBytes,
type AgentEnvComputer,
} from "./AgentEnvComputer.js";
import type {
BuildControllerAnswer,
ControlledComputer,
} from "../ports/BuildComputerControl.js";
const CONTROLLER = fileURLToPath(
new URL("../../bridge/agentenv/capture.py", import.meta.url),
@@ -64,12 +67,6 @@ const controllerArgumentPieces = (text: string): readonly string[] => {
return pieces;
};
/** The computer routes REA's build controller uses, and the control token's redaction for what it reads. */
export type ControlledComputer = Pick<
AgentEnvComputer,
"exec" | "homeFiles" | "redacted"
>;
/**
* Run one command of REA's build controller in the computer, as its user and
* in its home, and return the JSON object it answers with. The controller's
@@ -145,8 +142,8 @@ export const runBuildController = async (
);
};
/** What REA's build controller answers a command with. The wire format stays here. */
export const answerSchema = z.looseObject({
/** What REA's build controller answers a command with. The wire format stays here; the port names its fields. */
export const answerSchema: z.ZodType<BuildControllerAnswer> = z.looseObject({
error: z.string().optional(),
/** Why the controller refused a request before acting on it, such as a state path outside the home. */
refused: z.string().optional(),
@@ -170,7 +167,6 @@ export const answerSchema = z.looseObject({
.looseObject({ lists: z.int().nonnegative(), error: z.string().optional() })
.optional(),
});
export type Answer = z.infer<typeof answerSchema>;
/** One controller command, its answer parsed. */
export const controller = async (
@@ -178,7 +174,7 @@ export const controller = async (
command: "start" | "mark" | "stop",
argumentsJson: Readonly<Record<string, JsonValue>>,
options: { readonly timeoutS: number; readonly signal: AbortSignal },
): Promise<Answer> =>
): Promise<BuildControllerAnswer> =>
answerSchema.parse(
await runBuildController(computer, command, argumentsJson, options),
);