feat: queue codex remote control actions
This commit is contained in:
@@ -664,6 +664,26 @@ function normalizeInterruptPollIntervalMs(config) {
|
||||
return Number.isFinite(value) && value >= 0 ? Math.floor(value) : 750;
|
||||
}
|
||||
|
||||
function canHandleCodexRemoteControlMaintenanceTask(task) {
|
||||
return (
|
||||
task?.taskType === "device_maintenance" &&
|
||||
task?.maintenanceKind === "codex_remote_control" &&
|
||||
(task?.codexRemoteControlAction === "start" || task?.codexRemoteControlAction === "stop")
|
||||
);
|
||||
}
|
||||
|
||||
function buildCodexRemoteControlMaintenanceReply(task, result) {
|
||||
const actionLabel = task.codexRemoteControlAction === "start" ? "已启动" : "已停止";
|
||||
const lines = [`Codex Remote Control ${actionLabel}。`];
|
||||
if (result.commandLabel) {
|
||||
lines.push(`本机命令:${result.commandLabel}`);
|
||||
}
|
||||
if (result.outputSummary) {
|
||||
lines.push(`返回摘要:${result.outputSummary}`);
|
||||
}
|
||||
return lines.join("\n");
|
||||
}
|
||||
|
||||
async function claimSkillLifecycleRequest(config, runtime) {
|
||||
const response = await fetch(
|
||||
`${config.controlPlaneUrl.replace(/\/$/, "")}/api/v1/devices/${config.deviceId}/skill-requests/claim`,
|
||||
@@ -881,6 +901,23 @@ async function runMasterAgentTask(config, runtime, task) {
|
||||
try {
|
||||
let activeChild = null;
|
||||
const executionResult = await (async () => {
|
||||
if (canHandleCodexRemoteControlMaintenanceTask(task)) {
|
||||
const daemonResult = await runCodexRemoteControlDaemonAction(
|
||||
task.codexRemoteControlAction,
|
||||
config,
|
||||
);
|
||||
if (daemonResult.status === "failed") {
|
||||
throw new Error(
|
||||
daemonResult.error ||
|
||||
daemonResult.outputSummary ||
|
||||
`CODEX_REMOTE_CONTROL_${String(task.codexRemoteControlAction).toUpperCase()}_FAILED`,
|
||||
);
|
||||
}
|
||||
return {
|
||||
replyBody: buildCodexRemoteControlMaintenanceReply(task, daemonResult),
|
||||
};
|
||||
}
|
||||
|
||||
if (canHandleBrowserControlTask(task)) {
|
||||
const browserResult = await executeBrowserControlTask(task, config);
|
||||
if (browserResult.status === "failed") {
|
||||
|
||||
Reference in New Issue
Block a user