feat(manager): expose safe VPS edge health

This commit is contained in:
DCCONSTRUCTIONS
2026-08-22 13:08:04 +03:00
parent 07ffb22d38
commit 6ed4414a97
14 changed files with 464 additions and 42 deletions
+3
View File
@@ -287,6 +287,9 @@ export function createControlCoreApp({
commandTransport: typedCommandRuntime
? "typed-service-ping-v1"
: "disabled",
edgeChannelStatus: edgeChannelStatusProvider
? edgeChannelStatusProvider()
: null,
},
);
return writeJson(response, 200, { ok: true, workspace });
@@ -50,7 +50,7 @@ export async function getDeviceProjectWorkspace(
client,
actor,
projectId,
{ commandTransport = "disabled" } = {},
{ commandTransport = "disabled", edgeChannelStatus = null } = {},
) {
const project = await findProjectWithCapability(
client,
@@ -204,7 +204,8 @@ export async function getDeviceProjectWorkspace(
);
const edges = await client.query(
`select de.id, de.edge_key, de.display_name, de.deployment_ref,
de.lifecycle_state, de.created_at, de.updated_at
de.lifecycle_state, de.channel_lifecycle_state,
de.channel_generation_ref, de.created_at, de.updated_at
from device_edges de
where $2::boolean
or exists (
@@ -333,7 +334,10 @@ export async function getDeviceProjectWorkspace(
adapterPackages: adapterPackages.rows.map(adapterPackageView),
adapterVersions: adapterVersions.rows.map(adapterVersionView),
modelProfiles: modelProfiles.rows.map(modelProfileView),
edges: edges.rows.map(edgeView),
edges: edges.rows.map((row) => edgeView(
row,
edgeChannelRuntime(edgeChannelStatus, `edge:${row.id}`),
)),
routes: routes.rows.map(routeView),
sessions: sessions.rows.map(sessionView),
bindings: bindings.rows.map(bindingView),
@@ -496,18 +500,41 @@ function modelProfileView(row) {
};
}
function edgeView(row) {
function edgeView(row, runtime) {
const channelLifecycleState = row.channel_lifecycle_state ?? "disabled";
return {
edgeRef: `edge:${row.id}`,
edgeKey: row.edge_key,
displayName: row.display_name,
deploymentRef: row.deployment_ref ?? null,
lifecycleState: row.lifecycle_state,
channel: {
lifecycleState: channelLifecycleState,
generationRef: row.channel_generation_ref ?? null,
runtimeState: channelLifecycleState === "active"
? runtime?.channel ?? "unobserved"
: channelLifecycleState,
lastErrorCode: runtime?.lastErrorCode ?? null,
},
createdAt: toIso(row.created_at),
updatedAt: toIso(row.updated_at),
};
}
function edgeChannelRuntime(status, edgeRef) {
if (!status || !Array.isArray(status.edges)) return null;
const value = status.edges.find((item) => item?.edgeRegistrationId === edgeRef);
if (!value) return null;
return {
channel: ["accepted", "connecting", "absent"].includes(value.channel)
? value.channel
: "unobserved",
lastErrorCode: typeof value.lastErrorCode === "string"
? value.lastErrorCode.slice(0, 128)
: null,
};
}
function routeView(row) {
return {
routeRef: `route:${row.id}`,