feat: add codex remote control daemon actions
This commit is contained in:
@@ -41,6 +41,9 @@ import {
|
||||
checkBossAgentOtaUpdate,
|
||||
getBossAgentOtaRunnerConfig,
|
||||
} from "./boss-agent-ota-runner.mjs";
|
||||
import {
|
||||
runCodexRemoteControlDaemonAction,
|
||||
} from "./codex-remote-control-daemon.mjs";
|
||||
import {
|
||||
sanitizeSensitiveTaskFailureDetailForLog,
|
||||
sanitizeSensitiveTaskFailureDetailForTransport,
|
||||
@@ -1554,6 +1557,41 @@ const server = createServer(async (request, response) => {
|
||||
return;
|
||||
}
|
||||
|
||||
const codexRemoteControlMatch = requestUrl.pathname.match(
|
||||
/^\/api\/v1\/boss-agent\/codex-remote-control\/(start|stop)$/,
|
||||
);
|
||||
if (codexRemoteControlMatch && request.method === "POST") {
|
||||
const action = codexRemoteControlMatch[1];
|
||||
const result = await runCodexRemoteControlDaemonAction(action, config);
|
||||
runtime.lastCodexRemoteControlAction = {
|
||||
action,
|
||||
status: result.status,
|
||||
at: new Date().toISOString(),
|
||||
commandLabel: result.commandLabel,
|
||||
outputSummary: result.outputSummary,
|
||||
};
|
||||
await postAppLog(config, runtime, {
|
||||
level: result.status === "failed" ? "error" : "info",
|
||||
category: result.status === "failed"
|
||||
? "local_agent.codex_remote_control_failed"
|
||||
: "local_agent.codex_remote_control_changed",
|
||||
message: result.status === "failed"
|
||||
? `Codex Remote Control ${action} 失败`
|
||||
: `Codex Remote Control 已${action === "start" ? "启动" : "停止"}`,
|
||||
detail: result.outputSummary,
|
||||
mirrorToMaster: result.status === "failed",
|
||||
});
|
||||
const wantsJson = String(request.headers.accept || "").includes("application/json");
|
||||
if (!wantsJson) {
|
||||
response.writeHead(302, { Location: "/boss-agent?tab=overview" });
|
||||
response.end();
|
||||
return;
|
||||
}
|
||||
response.writeHead(result.status === "failed" ? 400 : 200, { "Content-Type": "application/json" });
|
||||
response.end(JSON.stringify({ ok: result.status !== "failed", result }));
|
||||
return;
|
||||
}
|
||||
|
||||
if (requestUrl.pathname === "/api/v1/boss-agent/permissions/open") {
|
||||
const target = requestUrl.searchParams.get("target") || "core";
|
||||
const returnTab = normalizeBossAgentTab(requestUrl.searchParams.get("returnTab") ?? "permissions");
|
||||
|
||||
Reference in New Issue
Block a user