Add gui/cli capability conflict guards

This commit is contained in:
kris
2026-04-06 10:22:07 +08:00
parent d04eca4703
commit 27ab594921
5 changed files with 1191 additions and 8 deletions

View File

@@ -70,6 +70,11 @@ async function resolveHeartbeatProjects(config, runtime) {
}
async function postHeartbeat(config, runtime, heartbeatProjects) {
const now = new Date().toISOString();
const preferredExecutionMode =
config.preferredExecutionMode === "gui" || config.preferredExecutionMode === "cli"
? config.preferredExecutionMode
: undefined;
const response = await fetch(`${config.controlPlaneUrl.replace(/\/$/, "")}/api/device-heartbeat`, {
method: "POST",
headers: { "Content-Type": "application/json" },
@@ -83,6 +88,19 @@ async function postHeartbeat(config, runtime, heartbeatProjects) {
status: config.status,
quota5h: config.quota5h,
quota7d: config.quota7d,
capabilities: {
gui: {
connected: Boolean(config.guiConnected),
lastSeenAt: now,
lastActiveProjectId: "",
},
cli: {
connected: true,
lastSeenAt: now,
lastActiveProjectId: "",
},
},
preferredExecutionMode,
projects: heartbeatProjects.projects,
projectCandidates: heartbeatProjects.projectCandidates,
endpoint: config.endpoint,